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:
70
73 typedef LightObject Superclass;
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
119
123
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
136protected:
137
140
141 bool CheckArgumentReady( const std::size_t kernelId );
142
143 void ResetArguments( const std::size_t kernelIdx );
144
145private:
146
147 OpenCLKernelManager( const Self & ); // purposely not implemented
148 void operator=( const Self & ); // purposely not implemented
149
151
153 {
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 */
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)
OpenCLEvent LaunchKernel(const std::vcl_size_t kernelId)
OpenCLContext * GetContext() const
std::vector< std::vector< KernelArgumentList > > m_KernelArgumentReady
void ResetArguments(const std::vcl_size_t kernelIdx)
bool CheckArgumentReady(const std::vcl_size_t kernelId)
SmartPointer< Self > Pointer
OpenCLKernel & GetKernel(const std::vcl_size_t kernelId)
bool SetKernelArgForAllKernels(const cl_uint argId, const std::vcl_size_t argSize, const void *argVal)
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::vector< OpenCLKernel > m_Kernels
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)
OpenCLKernelManager(const Self &)
SmartPointer< const Self > ConstPointer
void operator=(const Self &)
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.
Definition: itkOpenCLSize.h:50
static const Null null
Definition: itkOpenCLSize.h:62
#define ITKOpenCL_EXPORT


Generated on 1667476801 for elastix by doxygen 1.9.4 elastix logo