Medical Imaging Interaction Toolkit  2018.4.99-eed36131
Medical Imaging Interaction Toolkit
mitkOclFilter.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 
14 #ifndef __mitkOclFilter_h
15 #define __mitkOclFilter_h
16 
17 #include "mitkOclUtils.h"
18 #include "mitkCommon.h"
19 
20 #include <vector>
21 #include <usModule.h>
22 
23 #include <MitkOpenCLExports.h>
24 
25 namespace mitk
26 {
33 class MITKOPENCL_EXPORT OclFilter
34 {
35 public:
42  void AddSourceFile(const char* filename);
43 
50  void SetCompilerFlags(const char* flags);
51 
55  virtual bool IsInitialized();
56 
60  virtual unsigned long GetDeviceMemory();
61 
63  virtual ~OclFilter();
64 
65 protected:
66 
67  typedef std::vector<const char*> CStringList;
68  typedef std::vector<size_t> ClSizeList;
69 
71  OclFilter();
72 
74  OclFilter(const char* filename);
75 
77  const char* m_ClCompilerFlags;
78 
80  cl_program m_ClProgram;
81 
83  cl_command_queue m_CommandQue;
84 
86  std::string m_FilterID;
87 
89  const char* m_Preambel;
90 
92  CStringList m_ClFiles;
93 
96 
98  size_t m_LocalWorkSize[3];
99 
101  size_t m_GlobalWorkSize[3];
102 
104  void SetWorkingSize(unsigned int locx, unsigned int dimx,
105  unsigned int locy = 1, unsigned int dimy = 1,
106  unsigned int locz = 1, unsigned int dimz = 1);
107 
110  bool ExecuteKernel( cl_kernel kernel, unsigned int workSizeDim );
111 
114  bool ExecuteKernelChunks( cl_kernel kernel, unsigned int workSizeDim, size_t* chunksDim );
115 
119  bool ExecuteKernelChunksInBatches(cl_kernel kernel, unsigned int workSizeDim, size_t* chunksDim, size_t batchSize, int waitTimems);
127  bool Initialize();
128 
134  void CompileSource();
135 
142  void SetSourcePreambel(const char* preambel);
143 
148  virtual us::Module* GetModule() = 0;
149 
155  void LoadSourceFiles(CStringList &SourceCodeList, ClSizeList &SourceCodeSizeList);
156 };
157 }
158 #endif // __mitkOclFilter_h
std::string m_FilterID
Unique ID of the filter, needs to be specified in the constructor of the derived class.
Definition: mitkOclFilter.h:86
bool m_Initialized
status of the filter
Definition: mitkOclFilter.h:95
cl_program m_ClProgram
The compiled OpenCL program.
Definition: mitkOclFilter.h:80
const char * m_Preambel
source preambel for e.g. #define commands to be inserted into the OpenCL source
Definition: mitkOclFilter.h:89
DataCollection - Class to facilitate loading/accessing structured data.
std::vector< const char * > CStringList
Definition: mitkOclFilter.h:67
std::vector< vcl_size_t > ClSizeList
Definition: mitkOclFilter.h:68
CStringList m_ClFiles
List of sourcefiles that will be compiled for this filter.
Definition: mitkOclFilter.h:92
cl_command_queue m_CommandQue
Command queue for the filter.
Definition: mitkOclFilter.h:83
Superclass for all OpenCL based filter.
Definition: mitkOclFilter.h:33
const char * m_ClCompilerFlags
String that contains the compiler flags.
Definition: mitkOclFilter.h:77