18#ifndef itkOpenCLKernel_h
19#define itkOpenCLKernel_h
32#include "itkCovariantVector.h"
111#define OpenCLKernelSetArgMacroH(type) cl_int SetArg(const cl_uint index, const type value);
113#define OpenCLKernelSetArgMacroCXX(type) \
114 cl_int OpenCLKernel::SetArg(const cl_uint index, const type value) \
116 return clSetKernelArg(this->m_KernelId, index, sizeof(value), (const void *)&value); \
119#define OpenCLKernelSetArgsMacroH(type0, type1, type2, type3, type4) \
120 OpenCLKernelSetArgMacroH(type0) OpenCLKernelSetArgMacroH(type1) OpenCLKernelSetArgMacroH(type2) \
121 OpenCLKernelSetArgMacroH(type3) OpenCLKernelSetArgMacroH(type4)
123#define OpenCLKernelSetArgsMacroCXX(type0, type1, type2, type3, type4) \
124 OpenCLKernelSetArgMacroCXX(type0) OpenCLKernelSetArgMacroCXX(type1) OpenCLKernelSetArgMacroCXX(type2) \
125 OpenCLKernelSetArgMacroCXX(type3) OpenCLKernelSetArgMacroCXX(type4)
130class OpenCLVectorBase;
133class OpenCLKernelPimpl;
282 this->m_DoubleAsFloat = value;
287 this->m_DoubleAsFloat =
true;
292 this->m_DoubleAsFloat =
false;
297 return this->m_DoubleAsFloat;
336 cl_int SetArg(const cl_uint index, const
void * data, const
size_t size);
641 return this->LaunchKernel();
647 template <
typename T1>
651 this->SetArg(0, arg1);
652 return this->LaunchKernel();
659 template <
typename T1,
typename T2>
663 this->SetArg(0, arg1);
664 this->SetArg(1, arg2);
665 return this->LaunchKernel();
672 template <
typename T1,
typename T2,
typename T3>
674 operator()(
const T1 & arg1,
const T2 & arg2,
const T3 & arg3)
676 this->SetArg(0, arg1);
677 this->SetArg(1, arg2);
678 this->SetArg(2, arg3);
679 return this->LaunchKernel();
686 template <
typename T1,
typename T2,
typename T3,
typename T4>
688 operator()(
const T1 & arg1,
const T2 & arg2,
const T3 & arg3,
const T4 & arg4)
690 this->SetArg(0, arg1);
691 this->SetArg(1, arg2);
692 this->SetArg(2, arg3);
693 this->SetArg(3, arg4);
694 return this->LaunchKernel();
701 template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
703 operator()(
const T1 & arg1,
const T2 & arg2,
const T3 & arg3,
const T4 & arg4,
const T5 & arg5)
705 this->SetArg(0, arg1);
706 this->SetArg(1, arg2);
707 this->SetArg(2, arg3);
708 this->SetArg(3, arg4);
709 this->SetArg(4, arg5);
710 return this->LaunchKernel();
717 template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6>
719 operator()(
const T1 & arg1,
const T2 & arg2,
const T3 & arg3,
const T4 & arg4,
const T5 & arg5,
const T6 & arg6)
721 this->SetArg(0, arg1);
722 this->SetArg(1, arg2);
723 this->SetArg(2, arg3);
724 this->SetArg(3, arg4);
725 this->SetArg(4, arg5);
726 this->SetArg(5, arg6);
727 return this->LaunchKernel();
734 template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7>
744 this->SetArg(0, arg1);
745 this->SetArg(1, arg2);
746 this->SetArg(2, arg3);
747 this->SetArg(3, arg4);
748 this->SetArg(4, arg5);
749 this->SetArg(5, arg6);
750 this->SetArg(6, arg7);
751 return this->LaunchKernel();
758 template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7,
typename T8>
769 this->SetArg(0, arg1);
770 this->SetArg(1, arg2);
771 this->SetArg(2, arg3);
772 this->SetArg(3, arg4);
773 this->SetArg(4, arg5);
774 this->SetArg(5, arg6);
775 this->SetArg(6, arg7);
776 this->SetArg(7, arg8);
777 return this->LaunchKernel();
785 template <
typename T1,
805 this->SetArg(0, arg1);
806 this->SetArg(1, arg2);
807 this->SetArg(2, arg3);
808 this->SetArg(3, arg4);
809 this->SetArg(4, arg5);
810 this->SetArg(5, arg6);
811 this->SetArg(6, arg7);
812 this->SetArg(7, arg8);
813 this->SetArg(8, arg9);
814 return this->LaunchKernel();
822 template <
typename T1,
844 this->SetArg(0, arg1);
845 this->SetArg(1, arg2);
846 this->SetArg(2, arg3);
847 this->SetArg(3, arg4);
848 this->SetArg(4, arg5);
849 this->SetArg(5, arg6);
850 this->SetArg(6, arg7);
851 this->SetArg(7, arg8);
852 this->SetArg(8, arg9);
853 this->SetArg(9, arg10);
854 return this->LaunchKernel();
859 std::unique_ptr<OpenCLKernelPimpl>
d_ptr;
879template <
typename charT,
typename traits>
880inline std::basic_ostream<charT, traits> &
885 strm <<
"OpenCLKernel(null)";
889 const char indent =
' ';
891 strm <<
"OpenCLKernel\n"
892 << indent <<
"Id: " << kernel.
GetKernelId() <<
'\n'
893 << indent <<
"Name: " << kernel.
GetName() <<
'\n'
The OpenCLContext class represents an OpenCL context.
The OpenCLDevice class represents the collection of OpenCL devices to be used by the host.
OpenCLEventList class represents a list of OpenCLEvent objects.
OpenCLEvent class represents an OpenCL event object.
The OpenCLKernel class represents an executable entry point function in an OpenCL program.
Matrix< double, 3, 3 > MatrixDouble3x3Type
Point< int, 1 > PointInt1DType
Point< int, 2 > PointInt2DType
Vector< int, 3 > VectorInt3DType
OpenCLSize GetBestLocalWorkSizeImage3D() const
void SetGlobalWorkSize(const OpenCLSize &size)
Matrix< float, 4, 4 > MatrixFloat4x4Type
void SetRoundedGlobalWorkSize(const OpenCLSize &size)
void SetDoubleAsFloat(const bool value)
OpenCLEvent operator()(const T1 &arg1, const T2 &arg2, const T3 &arg3, const T4 &arg4, const T5 &arg5, const T6 &arg6)
CovariantVector< double, 3 > CovariantVectorDouble3DType
Matrix< float, 2, 2 > MatrixFloat2x2Type
void SetLocalWorkSize(const OpenCLSize &size)
Vector< float, 2 > VectorFloat2DType
std::vcl_size_t GetNumberOfArguments() const
Vector< int, 2 > VectorInt2DType
Point< double, 2 > PointDouble2DType
OpenCLSize GetBestLocalWorkSizeImage(const std::vcl_size_t dimension) const
Point< float, 4 > PointFloat4DType
CovariantVector< float, 4 > CovariantVectorFloat4DType
OpenCLEvent operator()(const T1 &arg1, const T2 &arg2, const T3 &arg3, const T4 &arg4)
OpenCLKernel & operator=(const OpenCLKernel &other)
CovariantVector< float, 3 > CovariantVectorFloat3DType
Vector< int, 1 > VectorInt1DType
CovariantVector< int, 3 > CovariantVectorInt3DType
OpenCLSize GetLocalWorkSize() const
OpenCLEvent operator()(const T1 &arg1, const T2 &arg2, const T3 &arg3, const T4 &arg4, const T5 &arg5, const T6 &arg6, const T7 &arg7, const T8 &arg8, const T9 &arg9)
OpenCLEvent operator()(const T1 &arg1, const T2 &arg2)
OpenCLEvent operator()(const T1 &arg1, const T2 &arg2, const T3 &arg3, const T4 &arg4, const T5 &arg5)
Vector< double, 1 > VectorDouble1DType
OpenCLSize GetBestLocalWorkSizeImage2D() const
Point< double, 3 > PointDouble3DType
void SetDoubleAsFloatDisable()
Vector< int, 4 > VectorInt4DType
Matrix< float, 1, 1 > MatrixFloat1x1Type
CovariantVector< float, 2 > CovariantVectorFloat2DType
CovariantVector< float, 1 > CovariantVectorFloat1DType
OpenCLSize GetGlobalWorkOffset() const
CovariantVector< double, 2 > CovariantVectorDouble2DType
OpenCLKernel(const OpenCLKernel &other)
CovariantVector< double, 1 > CovariantVectorDouble1DType
Point< double, 4 > PointDouble4DType
OpenCLEvent operator()(const T1 &arg1, const T2 &arg2, const T3 &arg3, const T4 &arg4, const T5 &arg5, const T6 &arg6, const T7 &arg7, const T8 &arg8, const T9 &arg9, const T10 &arg10)
Point< int, 4 > PointInt4DType
OpenCLEvent operator()(const T1 &arg1, const T2 &arg2, const T3 &arg3, const T4 &arg4, const T5 &arg5, const T6 &arg6, const T7 &arg7)
OpenCLEvent operator()(const T1 &arg1, const T2 &arg2, const T3 &arg3, const T4 &arg4, const T5 &arg5, const T6 &arg6, const T7 &arg7, const T8 &arg8)
Matrix< double, 1, 1 > MatrixDouble1x1Type
CovariantVector< int, 4 > CovariantVectorInt4DType
OpenCLSize GetGlobalWorkSize() const
OpenCLKernelSetArgsMacroH(cl_uchar, cl_uchar2, cl_uchar4, cl_uchar8, cl_uchar16) OpenCLKernelSetArgsMacroH(cl_char
Vector< double, 3 > VectorDouble3DType
vcl_size_t GetPreferredWorkSizeMultiple() const
Point< float, 2 > PointFloat2DType
void SetGlobalWorkOffset(const OpenCLSize &offset)
OpenCLSize GetCompileWorkGroupSize() const
Vector< double, 2 > VectorDouble2DType
OpenCLProgram GetProgram() const
OpenCLEvent operator()(const T1 &arg1, const T2 &arg2, const T3 &arg3)
Point< double, 1 > PointDouble1DType
bool GetDoubleAsFloatEnabled()
OpenCLKernel(OpenCLContext *context, const cl_kernel id)
OpenCLSize GetCompileWorkGroupSize(const OpenCLDevice &device) const
Point< float, 3 > PointFloat3DType
Vector< float, 3 > VectorFloat3DType
Vector< double, 4 > VectorDouble4DType
std::unique_ptr< OpenCLKernelPimpl > d_ptr
OpenCLContext * GetContext() const
OpenCLEvent operator()(const T1 &arg1)
Point< int, 3 > PointInt3DType
std::string GetName() const
OpenCLSize GetBestLocalWorkSizeImage1D() const
Matrix< double, 4, 4 > MatrixDouble4x4Type
CovariantVector< int, 2 > CovariantVectorInt2DType
CovariantVector< double, 4 > CovariantVectorDouble4DType
cl_kernel GetKernelId() const
CovariantVector< int, 1 > CovariantVectorInt1DType
Point< float, 1 > PointFloat1DType
Vector< float, 4 > VectorFloat4DType
Matrix< float, 3, 3 > MatrixFloat3x3Type
void SetDoubleAsFloatEnable()
Vector< float, 1 > VectorFloat1DType
Matrix< double, 2, 2 > MatrixDouble2x2Type
The OpenCLMemoryObject class represents all common memory objects such as buffers and image objects.
The OpenCLProgram class represents an OpenCL program object.
The OpenCLSampler class represents an OpenCL sampler object.
The OpenCLSize class defines the size of an item of work for an OpenCL kernel.
The base class for the OpenCLVector implementation.
#define ITK_OPENCL_DECLARE_PRIVATE(Class)
#define OpenCLKernelSetArgsMacroH(type0, type1, type2, type3, type4)
bool ITKOpenCL_EXPORT operator==(const OpenCLCommandQueue &lhs, const OpenCLCommandQueue &rhs)
bool ITKOpenCL_EXPORT operator!=(const OpenCLCommandQueue &lhs, const OpenCLCommandQueue &rhs)
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &strm, const OpenCLCommandQueue &queue)