go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkOpenCLKernelManager.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright UMC Utrecht and contributors
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 /*=========================================================================
19 *
20 * Copyright Insight Software Consortium
21 *
22 * Licensed under the Apache License, Version 2.0 (the "License");
23 * you may not use this file except in compliance with the License.
24 * You may obtain a copy of the License at
25 *
26 * http://www.apache.org/licenses/LICENSE-2.0.txt
27 *
28 * Unless required by applicable law or agreed to in writing, software
29 * distributed under the License is distributed on an "AS IS" BASIS,
30 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 * See the License for the specific language governing permissions and
32 * limitations under the License.
33 *
34 *=========================================================================*/
35 #ifndef __itkOpenCLKernelManager_h
36 #define __itkOpenCLKernelManager_h
37 
38 #include <itkLightObject.h>
39 #include <itkObjectFactory.h>
40 
41 #include "itkGPUDataManager.h"
42 #include "itkOpenCLContext.h"
43 #include "itkOpenCLKernel.h"
44 
45 #include <vector>
46 
47 namespace itk
48 {
65 class OpenCLContext;
66 
68 {
69 public:
70 
75  typedef SmartPointer< const Self > ConstPointer;
76 
78  itkNewMacro( Self );
79 
81  itkTypeMacro( OpenCLKernelManager, LightObject );
82 
84  OpenCLContext * GetContext() const { return this->m_Context; }
85 
87  OpenCLKernel & GetKernel( const std::size_t kernelId );
88 
89  OpenCLEvent LaunchKernel( const std::size_t kernelId );
90 
91  OpenCLEvent LaunchKernel( const std::size_t kernelId,
92  const OpenCLSize & global_work_size,
93  const OpenCLSize & local_work_size = OpenCLSize::null,
94  const OpenCLSize & global_work_offset = OpenCLSize::null );
95 
96  OpenCLEvent LaunchKernel( const std::size_t kernelId, const OpenCLEventList & event_list );
97 
98  OpenCLEvent LaunchKernel( const std::size_t kernelId,
99  const OpenCLEventList & event_list,
100  const OpenCLSize & global_work_size,
101  const OpenCLSize & local_work_size = OpenCLSize::null,
102  const OpenCLSize & global_work_offset = OpenCLSize::null );
103 
104  std::size_t CreateKernel( const OpenCLProgram & program, const std::string & name );
105 
106  OpenCLProgram BuildProgramFromSourceCode( const std::string & sourceCode,
107  const std::string & prefixSourceCode = std::string(),
108  const std::string & postfixSourceCode = std::string(),
109  const std::string & extraBuildOptions = std::string() );
110 
111  OpenCLProgram BuildProgramFromSourceFile( const std::string & fileName,
112  const std::string & prefixSourceCode = std::string(),
113  const std::string & postfixSourceCode = std::string(),
114  const std::string & extraBuildOptions = std::string() );
115 
118  void SetGlobalWorkSizeForAllKernels( const OpenCLSize & size );
119 
122  void SetLocalWorkSizeForAllKernels( const OpenCLSize & size );
123 
126  void SetGlobalWorkOffsetForAllKernels( const OpenCLSize & offset );
127 
128  bool SetKernelArg( const std::size_t kernelId,
129  const cl_uint argId, const std::size_t argSize, const void * argVal );
130 
131  bool SetKernelArgForAllKernels( const cl_uint argId,
132  const std::size_t argSize, const void * argVal );
133 
134  bool SetKernelArgWithImage( const std::size_t kernelId, cl_uint argId, const GPUDataManager::Pointer manager );
135 
136 protected:
137 
139  virtual ~OpenCLKernelManager();
140 
141  bool CheckArgumentReady( const std::size_t kernelId );
142 
143  void ResetArguments( const std::size_t kernelIdx );
144 
145 private:
146 
147  OpenCLKernelManager( const Self & ); // purposely not implemented
148  void operator=( const Self & ); // purposely not implemented
149 
151 
153  {
154  bool m_IsReady;
156  };
157 
158  std::vector< OpenCLKernel > m_Kernels;
159  std::vector< std::vector< KernelArgumentList > > m_KernelArgumentReady;
160 };
161 
162 } // end namespace itk
163 
164 #endif /* __itkOpenCLKernelManager_h */
SmartPointer< Self > Pointer
OpenCLEventList class represents a list of OpenCLEvent objects.
The OpenCLSize class defines the size of an item of work for an OpenCL kernel.
Definition: itkOpenCLSize.h:49
static const Null null
Definition: itkOpenCLSize.h:62
OpenCL kernel manager implemented using OpenCL.
The OpenCLContext class represents an OpenCL context.
std::vector< OpenCLKernel > m_Kernels
std::vector< std::vector< KernelArgumentList > > m_KernelArgumentReady
SmartPointer< const Self > ConstPointer
OpenCLContext * GetContext() const
The OpenCLKernel class represents an executable entry point function in an OpenCL program...
#define ITKOpenCL_EXPORT
The OpenCLProgram class represents an OpenCL program object.
OpenCLEvent class represents an OpenCL event object.


Generated on 04-09-2015 for elastix by doxygen 1.8.9.1 elastix logo