23 #ifndef __itkGPUKernelManager_h
24 #define __itkGPUKernelManager_h
63 bool LoadProgramFromFile(
const char* filename,
const char* cPreamble=
"");
65 bool LoadProgramFromString(
const char* cSource,
const char* cPreamble=
"");
67 int CreateKernel(
const char* kernelName);
69 cl_int GetKernelWorkGroupInfo(
int kernelIdx,
70 cl_kernel_work_group_info paramName,
void *value);
72 cl_int GetDeviceInfo(cl_kernel_work_group_info paramName,
73 size_t argSize,
void *argValue);
75 bool SetKernelArg(
int kernelIdx, cl_uint argIdx,
size_t argSize,
const void* argVal);
83 template<
class TGPUImageDataManager >
84 bool SetKernelArgWithImageAndBufferedRegion(
85 int kernelIdx, cl_uint &argIdx,
86 TGPUImageDataManager *manager)
88 if(kernelIdx < 0 || kernelIdx >= (
int)m_KernelContainer.size() )
return false;
93 errid = clSetKernelArg(m_KernelContainer[kernelIdx], argIdx,
sizeof(cl_mem),
94 manager->GetGPUBufferPointer() );
97 m_KernelArgumentReady[kernelIdx][argIdx].m_IsReady =
true;
98 m_KernelArgumentReady[kernelIdx][argIdx].m_GPUDataManager = manager;
104 errid = clSetKernelArg(m_KernelContainer[kernelIdx], argIdx,
sizeof(cl_mem),
105 manager->GetGPUBufferedRegionIndex()->GetGPUBufferPointer() );
108 m_KernelArgumentReady[kernelIdx][argIdx].m_IsReady =
true;
109 m_KernelArgumentReady[kernelIdx][argIdx].m_GPUDataManager = manager->GetGPUBufferedRegionIndex();
113 errid = clSetKernelArg(m_KernelContainer[kernelIdx], argIdx,
sizeof(cl_mem),
114 manager->GetGPUBufferedRegionSize()->GetGPUBufferPointer() );
117 m_KernelArgumentReady[kernelIdx][argIdx].m_IsReady =
true;
118 m_KernelArgumentReady[kernelIdx][argIdx].m_GPUDataManager = manager->GetGPUBufferedRegionSize();
124 bool LaunchKernel(
int kernelIdx,
int dim,
size_t *globalWorkSize,
size_t *localWorkSize);
126 bool LaunchKernel1D(
int kernelIdx,
size_t globalWorkSize,
size_t localWorkSize);
128 bool LaunchKernel2D(
int kernelIdx,
129 size_t globalWorkSizeX,
size_t globalWorkSizeY,
130 size_t localWorkSizeX,
size_t localWorkSizeY );
132 bool LaunchKernel3D(
int kernelIdx,
133 size_t globalWorkSizeX,
size_t globalWorkSizeY,
size_t globalWorkSizeZ,
134 size_t localWorkSizeX,
size_t localWorkSizeY,
size_t localWorkSizeZ );
136 void SetCurrentCommandQueue(
int queueid );
138 int GetCurrentCommandQueueID();
145 bool CheckArgumentReady(
int kernelIdx);
147 void ResetArguments(
int kernelIdx);
151 void operator=(
const Self&);