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
47namespace itk
48{
65class OpenCLContext;
66
67class ITKOpenCL_EXPORT OpenCLKernelManager : public LightObject
68{
69public:
71
74 using Superclass = LightObject;
75 using Pointer = SmartPointer<Self>;
76 using ConstPointer = SmartPointer<const Self>;
77
79 itkNewMacro(Self);
80
82 itkTypeMacro(OpenCLKernelManager, LightObject);
83
86 GetContext() const
87 {
88 return this->m_Context;
89 }
90
93 GetKernel(const std::size_t kernelId);
94
96 LaunchKernel(const std::size_t kernelId);
97
99 LaunchKernel(const std::size_t kernelId,
100 const OpenCLSize & global_work_size,
101 const OpenCLSize & local_work_size = OpenCLSize::null,
102 const OpenCLSize & global_work_offset = OpenCLSize::null);
103
105 LaunchKernel(const std::size_t kernelId, const OpenCLEventList & event_list);
106
108 LaunchKernel(const std::size_t kernelId,
109 const OpenCLEventList & event_list,
110 const OpenCLSize & global_work_size,
111 const OpenCLSize & local_work_size = OpenCLSize::null,
112 const OpenCLSize & global_work_offset = OpenCLSize::null);
113
114 std::size_t
115 CreateKernel(const OpenCLProgram & program, const std::string & name);
116
118 BuildProgramFromSourceCode(const std::string & sourceCode,
119 const std::string & prefixSourceCode = std::string(),
120 const std::string & postfixSourceCode = std::string(),
121 const std::string & extraBuildOptions = std::string());
122
124 BuildProgramFromSourceFile(const std::string & fileName,
125 const std::string & prefixSourceCode = std::string(),
126 const std::string & postfixSourceCode = std::string(),
127 const std::string & extraBuildOptions = std::string());
128
131 void
133
136 void
138
141 void
143
144 bool
145 SetKernelArg(const std::size_t kernelId, const cl_uint argId, const std::size_t argSize, const void * argVal);
146
147 bool
148 SetKernelArgForAllKernels(const cl_uint argId, const std::size_t argSize, const void * argVal);
149
150 bool
151 SetKernelArgWithImage(const std::size_t kernelId, cl_uint argId, const GPUDataManager::Pointer manager);
152
153protected:
156
157 bool
158 CheckArgumentReady(const std::size_t kernelId);
159
160 void
161 ResetArguments(const std::size_t kernelIdx);
162
163private:
164 OpenCLContext * m_Context{};
165
171
172 std::vector<OpenCLKernel> m_Kernels{};
173 std::vector<std::vector<KernelArgumentList>> m_KernelArgumentReady{};
174};
175
176} // end namespace itk
177
178#endif /* itkOpenCLKernelManager_h */
The OpenCLContext class represents an OpenCL context.
OpenCLEventList class represents a list of OpenCLEvent objects.
OpenCLEvent class represents an OpenCL event object.
OpenCL kernel manager implemented using OpenCL.
OpenCLEvent LaunchKernel(const std::vcl_size_t kernelId, const OpenCLEventList &event_list, const OpenCLSize &global_work_size, const OpenCLSize &local_work_size=OpenCLSize::null, const OpenCLSize &global_work_offset=OpenCLSize::null)
SmartPointer< const Self > ConstPointer
OpenCLEvent LaunchKernel(const std::vcl_size_t kernelId)
OpenCLContext * GetContext() const
void ResetArguments(const std::vcl_size_t kernelIdx)
bool CheckArgumentReady(const std::vcl_size_t kernelId)
OpenCLKernel & GetKernel(const std::vcl_size_t kernelId)
bool SetKernelArgForAllKernels(const cl_uint argId, const std::vcl_size_t argSize, const void *argVal)
ITK_DISALLOW_COPY_AND_MOVE(OpenCLKernelManager)
OpenCLProgram BuildProgramFromSourceFile(const std::string &fileName, const std::string &prefixSourceCode=std::string(), const std::string &postfixSourceCode=std::string(), const std::string &extraBuildOptions=std::string())
void SetLocalWorkSizeForAllKernels(const OpenCLSize &size)
OpenCLProgram BuildProgramFromSourceCode(const std::string &sourceCode, const std::string &prefixSourceCode=std::string(), const std::string &postfixSourceCode=std::string(), const std::string &extraBuildOptions=std::string())
OpenCLEvent LaunchKernel(const std::vcl_size_t kernelId, const OpenCLEventList &event_list)
~OpenCLKernelManager() override
std::vcl_size_t CreateKernel(const OpenCLProgram &program, const std::string &name)
OpenCLEvent LaunchKernel(const std::vcl_size_t kernelId, const OpenCLSize &global_work_size, const OpenCLSize &local_work_size=OpenCLSize::null, const OpenCLSize &global_work_offset=OpenCLSize::null)
bool SetKernelArgWithImage(const std::vcl_size_t kernelId, cl_uint argId, const GPUDataManager::Pointer manager)
bool SetKernelArg(const std::vcl_size_t kernelId, const cl_uint argId, const std::vcl_size_t argSize, const void *argVal)
void SetGlobalWorkOffsetForAllKernels(const OpenCLSize &offset)
void SetGlobalWorkSizeForAllKernels(const OpenCLSize &size)
The OpenCLKernel class represents an executable entry point function in an OpenCL program.
The OpenCLProgram class represents an OpenCL program object.
The OpenCLSize class defines the size of an item of work for an OpenCL kernel.
#define ITKOpenCL_EXPORT


Generated on 2024-07-17 for elastix by doxygen 1.11.0 (9b424b03c9833626cd435af22a444888fbbb192d) elastix logo