18#ifndef __itkOpenCLContext_h
19#define __itkOpenCLContext_h
21#include "itkLightObject.h"
22#include "itkObjectFactory.h"
73class OpenCLVectorBase;
74class OpenCLContextPimpl;
117 DevelopmentSingleMaximumFlopsDevice = 0x0001,
118 DevelopmentMultipleMaximumFlopsDevices = 0x0002,
119 SingleMaximumFlopsDevice = 0x0004,
120 MultipleMaximumFlopsDevices = 0x0008
142 bool Create(
const std::list< OpenCLDevice > & devices );
217 const int lineNumber = 0,
const char * location =
"" );
260 const std::size_t size );
290 template<
typename T >
292 const std::size_t size )
332 const std::string & prefixSourceCode = std::string(),
333 const std::string & postfixSourceCode = std::string() );
339 const std::string & prefixSourceCode = std::string(),
340 const std::string & postfixSourceCode = std::string() );
347 const std::size_t size );
354 const std::string & prefixSourceCode = std::string(),
355 const std::string & postfixSourceCode = std::string() );
358 const std::string & sourceCode,
359 const std::string & prefixSourceCode = std::string(),
360 const std::string & postfixSourceCode = std::string(),
361 const std::string & extraBuildOptions = std::string() );
368 const std::string & prefixSourceCode = std::string(),
369 const std::string & postfixSourceCode = std::string() );
372 const std::string & fileName,
373 const std::string & prefixSourceCode = std::string(),
374 const std::string & postfixSourceCode = std::string(),
375 const std::string & extraBuildOptions = std::string() );
452 const bool releaseEvent =
false );
462 const std::string & source,
463 const std::size_t sourceSize );
472 std::unique_ptr< OpenCLContextPimpl > d_ptr;
476 cl_command_queue GetActiveQueue();
481 OpenCLContextPimpl * d );
487 OpenCLContextPimpl * d );
491 void SetUpProfiling();
495 void OpenCLDebug( const std::
string & callname );
The OpenCLBuffer class represents an OpenCL buffer object.
The OpenCLCommandQueue class represents an OpenCL a command-queue on a specific device and valid Open...
The OpenCLContext class represents an OpenCL context.
cl_int Marker(const OpenCLEventList &event_list)
SmartPointer< const Self > ConstPointer
OpenCLImage CreateImageCopy(const OpenCLImageFormat &format, const void *data, const OpenCLSize &size, const OpenCLMemoryObject::Access access)
std::list< OpenCLDevice > GetDevices() const
cl_int GetLastError() const
OpenCLProgram CreateProgramFromBinaryCode(const unsigned char *binary, const std::vcl_size_t size)
bool Create(const OpenCLPlatform &platfrom, const OpenCLDevice::DeviceType type=OpenCLDevice::Default)
OpenCLProgram BuildProgramFromSourceFile(const std::list< OpenCLDevice > &devices, const std::string &fileName, const std::string &prefixSourceCode=std::string(), const std::string &postfixSourceCode=std::string(), const std::string &extraBuildOptions=std::string())
~OpenCLContext() override
OpenCLImage CreateImageDevice(const OpenCLImageFormat &format, const OpenCLMemoryObject::Access access, const OpenCLSize &size)
const Self & operator=(const Self &)
bool Create(const OpenCLContext::CreateMethod method)
static std::string GetErrorName(const cl_int code)
OpenCLEvent BarrierAsync(const OpenCLEventList &event_list)
OpenCLCommandQueue GetCommandQueue()
OpenCLVector< T > CreateVector(const OpenCLMemoryObject::Access access, const std::vcl_size_t size)
void SetLastError(const cl_int error)
void SetContextId(cl_context id)
OpenCLProgram BuildProgramFromSourceCode(const std::string &sourceCode, const std::string &prefixSourceCode=std::string(), const std::string &postfixSourceCode=std::string())
OpenCLSampler CreateSampler(const bool normalizedCoordinates, const OpenCLSampler::AddressingMode addressingMode, const OpenCLSampler::FilterMode filterMode)
void SetCommandQueue(const OpenCLCommandQueue &queue)
cl_int Barrier(const OpenCLEventList &event_list)
OpenCLProgram BuildProgramFromSourceCode(const std::list< OpenCLDevice > &devices, const std::string &sourceCode, const std::string &prefixSourceCode=std::string(), const std::string &postfixSourceCode=std::string(), const std::string &extraBuildOptions=std::string())
OpenCLBuffer CreateBufferDevice(const OpenCLMemoryObject::Access access, const std::vcl_size_t size)
OpenCLProgram CreateProgramFromSourceFile(const std::string &filename, const std::string &prefixSourceCode=std::string(), const std::string &postfixSourceCode=std::string())
cl_context GetContextId() const
void SetDefaultDevice(const OpenCLDevice &device)
static Pointer GetInstance()
OpenCLProgram BuildProgramFromSourceFile(const std::string &fileName, const std::string &prefixSourceCode=std::string(), const std::string &postfixSourceCode=std::string())
OpenCLBuffer CreateBufferCopy(const void *data, const OpenCLMemoryObject::Access access, const std::vcl_size_t size)
OpenCLDevice GetDefaultDevice() const
OpenCLUserEvent CreateUserEvent()
OpenCLContext(const Self &other)
SmartPointer< Self > Pointer
OpenCLProgram CreateOpenCLProgram(const std::string &filename, const std::string &source, const std::vcl_size_t sourceSize)
OpenCLImage CreateImageHost(const OpenCLImageFormat &format, void *data, const OpenCLSize &size, const OpenCLMemoryObject::Access access)
static cl_int WaitForFinished(const OpenCLEventList &event_list)
OpenCLProgram CreateProgramFromSourceCode(const std::string &sourceCode, const std::string &prefixSourceCode=std::string(), const std::string &postfixSourceCode=std::string())
OpenCLEvent MarkerAsync(const OpenCLEventList &event_list)
OpenCLBuffer CreateBufferHost(void *data, const OpenCLMemoryObject::Access access, const std::vcl_size_t size)
bool Create(const OpenCLDevice::DeviceType type)
void ReportError(const cl_int code, const char *fileName="", const int lineNumber=0, const char *location="")
OpenCLCommandQueue CreateCommandQueue(const cl_command_queue_properties properties, const OpenCLDevice &device=OpenCLDevice())
std::list< OpenCLImageFormat > GetSupportedImageFormats(const OpenCLImageFormat::ImageType image_type, const cl_mem_flags flags) const
bool Create(const std::list< OpenCLDevice > &devices)
OpenCLCommandQueue GetDefaultCommandQueue()
static void SetInstance(OpenCLContext *instance)
void OpenCLProfile(cl_event clEvent, const std::string &message, const bool releaseEvent=false)
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 OpenCLImage class represents an image object is used to store a one, two or three dimensional tex...
The OpenCLKernel class represents an executable entry point function in an OpenCL program.
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 OpenCLUserEvent class represents OpenCL user events.
The base class for the OpenCLVector implementation.
The OpenCLVector class represents a templated OpenCL buffer object.
#define ITK_OPENCL_DECLARE_PRIVATE(Class)