Fraxinus  18.10
An IGT application
cxVNNclAlgorithm.h
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
12 #ifndef CXVNNCLALGORITHM_H_
13 #define CXVNNCLALGORITHM_H_
14 
15 //TODO remove, should be defined in oul instead
16 #define __CL_ENABLE_EXCEPTIONS //telling the opencl c++ wrapper to throw exceptions
17 
18 #include "cxUSFrameData.h"
19 #include "OpenCLManager.hpp"
20 #include "RuntimeMeasurementManager.hpp"
21 
22 namespace cx
23 {
28 {
29 public:
32 
39  typedef struct __frameBlock_t
40  {
41  unsigned char* data;
42  size_t length;
43  } frameBlock_t;
44 
61  virtual bool initCL(QString kernelFile,
62  int nMaxPlanes,
63  int nPlanes,
64  int method,
65  int planeMethod,
66  int nStarts,
67  float brightnessWeight,
68  float newnessWeight);
82  virtual cl::Program buildCLProgram(std::string program_src,
83  std::string kernelPath,
84  int nMaxPlanes,
85  int nPlanes,
86  int method,
87  int planeMethod,
88  int nStarts,
89  float brightnessWeight,
90  float newnessWeight);
101  virtual bool reconstruct(ProcessedUSInputDataPtr input,
102  vtkImageDataPtr outputData,
103  float radius,
104  int nClosePlanes);
105 
115  virtual bool initializeFrameBlocks(frameBlock_t* framePointers,
116  int numBlocks,
117  ProcessedUSInputDataPtr inputFrames);
125  virtual void freeFrameBlocks(frameBlock_t* framePointers,
126  int numBlocks);
127 
128 
142  virtual void fillPlaneMatrices(float *planeMatrices,
144 
148  void setProfiling(bool on);
149  double getTotalExecutionTime();
150  double getKernelExecutionTime();
151 
152 private:
153  void setKernelArguments(
154  cl::Kernel kernel,
155  int volume_xsize,
156  int volume_ysize,
157  int volume_zsize,
158  float volume_xspacing,
159  float volume_yspacing,
160  float volume_zspacing,
161  int in_xsize,
162  int in_ysize,
163  float in_xspacing,
164  float in_yspacing,
165  std::vector<cl::Buffer>& blocks,
166  cl::Buffer out_volume,
167  cl::Buffer plane_matrices,
168  cl::Buffer mask,
169  size_t plane_eqs_size,
170  size_t close_planes_size,
171  float radius);
172  size_t calculateSpaceNeededForClosePlanes(cl::Kernel kernel, cl::Device device, size_t local_work_size, size_t nPlanes_numberOfInputImages, int nClosePlanes);
173  bool isUsingTooMuchMemory(size_t outputVolumeSize, size_t inputBlocksLength, cl_ulong globalMemUse);
174  void measureAndExecuteKernel(cl::CommandQueue queue, cl::Kernel kernel, size_t global_work_size, size_t local_work_size, std::string measurementName);
175  void measureAndReadBuffer(cl::CommandQueue queue, cl::Buffer outputBuffer, size_t outputVolumeSize, void *outputData, std::string measurementName);
176 
177  void startProfiling(std::string name, cl::CommandQueue queue);
178  void stopProfiling(std::string name, cl::CommandQueue queue);
179 
180  cl::Kernel mKernel;
181  oul::ContextPtr mOulContex;
182  oul::RuntimeMeasurementsManagerPtr mRuntime;
183  std::set<std::string> mMeasurementNames;
184  std::string mKernelMeasurementName;
185 
186 };
187 
188 typedef boost::shared_ptr<VNNclAlgorithm> VNNclAlgorithmPtr;
189 
190 } /* namespace cx */
191 #endif /* CXVNNCLALGORITHM_H_ */
virtual bool initCL(QString kernelFile, int nMaxPlanes, int nPlanes, int method, int planeMethod, int nStarts, float brightnessWeight, float newnessWeight)
struct cx::VNNclAlgorithm::__frameBlock_t frameBlock_t
virtual void fillPlaneMatrices(float *planeMatrices, ProcessedUSInputDataPtr input)
virtual cl::Program buildCLProgram(std::string program_src, std::string kernelPath, int nMaxPlanes, int nPlanes, int method, int planeMethod, int nStarts, float brightnessWeight, float newnessWeight)
virtual bool reconstruct(ProcessedUSInputDataPtr input, vtkImageDataPtr outputData, float radius, int nClosePlanes)
virtual bool initializeFrameBlocks(frameBlock_t *framePointers, int numBlocks, ProcessedUSInputDataPtr inputFrames)
void setProfiling(bool on)
boost::shared_ptr< class ProcessedUSInputData > ProcessedUSInputDataPtr
virtual void freeFrameBlocks(frameBlock_t *framePointers, int numBlocks)
vtkSmartPointer< class vtkImageData > vtkImageDataPtr
boost::shared_ptr< VNNclAlgorithm > VNNclAlgorithmPtr
Namespace for all CustusX production code.