Commit eeb3e32c authored by Peter Eastman's avatar Peter Eastman
Browse files

Upgraded to newer version of cl.hpp

parent c14b0b8e
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2008-2010 The Khronos Group Inc. * Copyright (c) 2008-2011 The Khronos Group Inc.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and/or associated documentation files (the * copy of this software and/or associated documentation files (the
...@@ -239,7 +239,7 @@ public: ...@@ -239,7 +239,7 @@ public:
* *
* \return The error code. * \return The error code.
*/ */
const cl_int err(void) const { return err_; } cl_int err(void) const { return err_; }
}; };
#define __ERR_STR(x) #x #define __ERR_STR(x) #x
...@@ -249,7 +249,7 @@ public: ...@@ -249,7 +249,7 @@ public:
//! \cond DOXYGEN_DETAIL //! \cond DOXYGEN_DETAIL
#if !defined(__CL_USER_OVERRIDE_ERROR_STRINGS) #if !defined(__CL_USER_OVERRIDE_ERROR_STRINGS)
#define __GET_DEVICE_INFO_ERR __ERR_STR(clgetDeviceInfo) #define __GET_DEVICE_INFO_ERR __ERR_STR(clGetDeviceInfo)
#define __GET_PLATFORM_INFO_ERR __ERR_STR(clGetPlatformInfo) #define __GET_PLATFORM_INFO_ERR __ERR_STR(clGetPlatformInfo)
#define __GET_DEVICE_IDS_ERR __ERR_STR(clGetDeviceIDs) #define __GET_DEVICE_IDS_ERR __ERR_STR(clGetDeviceIDs)
#define __GET_PLATFORM_IDS_ERR __ERR_STR(clGetPlatformIDs) #define __GET_PLATFORM_IDS_ERR __ERR_STR(clGetPlatformIDs)
...@@ -265,6 +265,7 @@ public: ...@@ -265,6 +265,7 @@ public:
#define __GET_PROGRAM_BUILD_INFO_ERR __ERR_STR(clGetProgramBuildInfo) #define __GET_PROGRAM_BUILD_INFO_ERR __ERR_STR(clGetProgramBuildInfo)
#define __GET_COMMAND_QUEUE_INFO_ERR __ERR_STR(clGetCommandQueueInfo) #define __GET_COMMAND_QUEUE_INFO_ERR __ERR_STR(clGetCommandQueueInfo)
#define __CREATE_CONTEXT_ERR __ERR_STR(clCreateContext)
#define __CREATE_CONTEXT_FROM_TYPE_ERR __ERR_STR(clCreateContextFromType) #define __CREATE_CONTEXT_FROM_TYPE_ERR __ERR_STR(clCreateContextFromType)
#define __GET_SUPPORTED_IMAGE_FORMATS_ERR __ERR_STR(clGetSupportedImageFormats) #define __GET_SUPPORTED_IMAGE_FORMATS_ERR __ERR_STR(clGetSupportedImageFormats)
...@@ -438,7 +439,7 @@ private: ...@@ -438,7 +439,7 @@ private:
bool empty_; bool empty_;
public: public:
vector() : vector() :
size_(-1), size_(static_cast<unsigned int>(-1)),
empty_(true) empty_(true)
{} {}
...@@ -725,11 +726,39 @@ struct GetInfoHelper<Func, VECTOR_CLASS<char *> > ...@@ -725,11 +726,39 @@ struct GetInfoHelper<Func, VECTOR_CLASS<char *> >
static cl_int static cl_int
get(Func f, cl_uint name, VECTOR_CLASS<char *>* param) get(Func f, cl_uint name, VECTOR_CLASS<char *>* param)
{ {
cl_uint err = f(name, param->size() * sizeof(char *), &(*param)[0], NULL); ::size_t nDevices;
::size_t * binary_sizes;
char ** values;
cl_int err = f(CL_PROGRAM_NUM_DEVICES, sizeof(nDevices), &nDevices, NULL);
if (err != CL_SUCCESS) {
return err;
}
binary_sizes = (::size_t*)alloca(sizeof(::size_t)*nDevices);
err = f(CL_PROGRAM_BINARY_SIZES, sizeof(::size_t)*nDevices, binary_sizes, NULL);
if (err != CL_SUCCESS) {
return err;
}
values = (char **) alloca(sizeof(char*)*nDevices);
for(cl_uint i = 0; i < nDevices; i++ )
{
if( binary_sizes[i] != 0 )
{
values[i]= (char *)malloc( sizeof(char)*binary_sizes[i]);
}
else
{
values[i] = NULL;
}
}
err = f(name, sizeof(char *)*nDevices, values, NULL);
if (err != CL_SUCCESS) { if (err != CL_SUCCESS) {
return err; return err;
} }
param->assign(values,values+nDevices);
return CL_SUCCESS; return CL_SUCCESS;
} }
}; };
...@@ -804,7 +833,7 @@ struct GetInfoHelper<Func, CPP_TYPE> \ ...@@ -804,7 +833,7 @@ struct GetInfoHelper<Func, CPP_TYPE> \
F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_WIDTH, ::size_t) \ F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_WIDTH, ::size_t) \
F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_HEIGHT, ::size_t) \ F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_HEIGHT, ::size_t) \
F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_DEPTH, ::size_t) \ F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_DEPTH, ::size_t) \
F(cl_device_info, CL_DEVICE_IMAGE_SUPPORT, cl_uint) \ F(cl_device_info, CL_DEVICE_IMAGE_SUPPORT, cl_bool) \
F(cl_device_info, CL_DEVICE_MAX_PARAMETER_SIZE, ::size_t) \ F(cl_device_info, CL_DEVICE_MAX_PARAMETER_SIZE, ::size_t) \
F(cl_device_info, CL_DEVICE_MAX_SAMPLERS, cl_uint) \ F(cl_device_info, CL_DEVICE_MAX_SAMPLERS, cl_uint) \
F(cl_device_info, CL_DEVICE_MEM_BASE_ADDR_ALIGN, cl_uint) \ F(cl_device_info, CL_DEVICE_MEM_BASE_ADDR_ALIGN, cl_uint) \
...@@ -910,6 +939,7 @@ struct GetInfoHelper<Func, CPP_TYPE> \ ...@@ -910,6 +939,7 @@ struct GetInfoHelper<Func, CPP_TYPE> \
F(cl_device_info, CL_DEVICE_DOUBLE_FP_CONFIG, cl_device_fp_config) \ F(cl_device_info, CL_DEVICE_DOUBLE_FP_CONFIG, cl_device_fp_config) \
F(cl_device_info, CL_DEVICE_HALF_FP_CONFIG, cl_device_fp_config) \ F(cl_device_info, CL_DEVICE_HALF_FP_CONFIG, cl_device_fp_config) \
F(cl_device_info, CL_DEVICE_HOST_UNIFIED_MEMORY, cl_bool) \ F(cl_device_info, CL_DEVICE_HOST_UNIFIED_MEMORY, cl_bool) \
F(cl_device_info, CL_DEVICE_OPENCL_C_VERSION, STRING_CLASS) \
\ \
F(cl_mem_info, CL_MEM_ASSOCIATED_MEMOBJECT, cl::Memory) \ F(cl_mem_info, CL_MEM_ASSOCIATED_MEMOBJECT, cl::Memory) \
F(cl_mem_info, CL_MEM_OFFSET, ::size_t) \ F(cl_mem_info, CL_MEM_OFFSET, ::size_t) \
...@@ -932,7 +962,7 @@ struct GetInfoHelper<Func, CPP_TYPE> \ ...@@ -932,7 +962,7 @@ struct GetInfoHelper<Func, CPP_TYPE> \
template <typename enum_type, cl_int Name> template <typename enum_type, cl_int Name>
struct param_traits {}; struct param_traits {};
#define __DECLARE_PARAM_TRAITS(token, param_name, T) \ #define __CL_DECLARE_PARAM_TRAITS(token, param_name, T) \
struct token; \ struct token; \
template<> \ template<> \
struct param_traits<detail:: token,param_name> \ struct param_traits<detail:: token,param_name> \
...@@ -941,16 +971,44 @@ struct param_traits<detail:: token,param_name> \ ...@@ -941,16 +971,44 @@ struct param_traits<detail:: token,param_name> \
typedef T param_type; \ typedef T param_type; \
}; };
__PARAM_NAME_INFO_1_0(__DECLARE_PARAM_TRAITS); __PARAM_NAME_INFO_1_0(__CL_DECLARE_PARAM_TRAITS)
#if defined(CL_VERSION_1_1) #if defined(CL_VERSION_1_1)
__PARAM_NAME_INFO_1_1(__DECLARE_PARAM_TRAITS); __PARAM_NAME_INFO_1_1(__CL_DECLARE_PARAM_TRAITS)
#endif // CL_VERSION_1_1 #endif // CL_VERSION_1_1
#if defined(USE_CL_DEVICE_FISSION) #if defined(USE_CL_DEVICE_FISSION)
__PARAM_NAME_DEVICE_FISSION(__DECLARE_PARAM_TRAITS); __PARAM_NAME_DEVICE_FISSION(__CL_DECLARE_PARAM_TRAITS);
#endif // USE_CL_DEVICE_FISSION #endif // USE_CL_DEVICE_FISSION
#undef __DECLARE_PARAM_TRAITS #ifdef CL_PLATFORM_ICD_SUFFIX_KHR
__CL_DECLARE_PARAM_TRAITS(cl_platform_info, CL_PLATFORM_ICD_SUFFIX_KHR, STRING_CLASS)
#endif
#ifdef CL_DEVICE_PROFILING_TIMER_OFFSET_AMD
__CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_PROFILING_TIMER_OFFSET_AMD, cl_ulong)
#endif
#ifdef CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV
__CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV, cl_uint)
#endif
#ifdef CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV
__CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV, cl_uint)
#endif
#ifdef CL_DEVICE_REGISTERS_PER_BLOCK_NV
__CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_REGISTERS_PER_BLOCK_NV, cl_uint)
#endif
#ifdef CL_DEVICE_WARP_SIZE_NV
__CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_WARP_SIZE_NV, cl_uint)
#endif
#ifdef CL_DEVICE_GPU_OVERLAP_NV
__CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_GPU_OVERLAP_NV, cl_bool)
#endif
#ifdef CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV
__CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV, cl_bool)
#endif
#ifdef CL_DEVICE_INTEGRATED_MEMORY_NV
__CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_INTEGRATED_MEMORY_NV, cl_bool)
#endif
// Convenience functions // Convenience functions
...@@ -1089,13 +1147,17 @@ struct ReferenceHandler<cl_event> ...@@ -1089,13 +1147,17 @@ struct ReferenceHandler<cl_event>
template <typename T> template <typename T>
class Wrapper class Wrapper
{ {
protected: public:
typedef T cl_type; typedef T cl_type;
protected:
cl_type object_; cl_type object_;
public: public:
Wrapper() : object_(NULL) { } Wrapper() : object_(NULL) { }
Wrapper(const cl_type &obj) : object_(obj) { }
~Wrapper() ~Wrapper()
{ {
if (object_ != NULL) { release(); } if (object_ != NULL) { release(); }
...@@ -1115,6 +1177,13 @@ public: ...@@ -1115,6 +1177,13 @@ public:
return *this; return *this;
} }
Wrapper<cl_type>& operator = (const cl_type &rhs)
{
if (object_ != NULL) { release(); }
object_ = rhs;
return *this;
}
cl_type operator ()() const { return object_; } cl_type operator ()() const { return object_; }
cl_type& operator ()() { return object_; } cl_type& operator ()() { return object_; }
...@@ -1181,12 +1250,12 @@ struct ImageFormat : public cl_image_format ...@@ -1181,12 +1250,12 @@ struct ImageFormat : public cl_image_format
class Device : public detail::Wrapper<cl_device_id> class Device : public detail::Wrapper<cl_device_id>
{ {
public: public:
Device(cl_device_id device) { object_ = device; }
Device() : detail::Wrapper<cl_type>() { } Device() : detail::Wrapper<cl_type>() { }
Device(const Device& device) : detail::Wrapper<cl_type>(device) { } Device(const Device& device) : detail::Wrapper<cl_type>(device) { }
Device(const cl_device_id &device) : detail::Wrapper<cl_type>(device) { }
Device& operator = (const Device& rhs) Device& operator = (const Device& rhs)
{ {
if (this != &rhs) { if (this != &rhs) {
...@@ -1195,6 +1264,12 @@ public: ...@@ -1195,6 +1264,12 @@ public:
return *this; return *this;
} }
Device& operator = (const cl_device_id& rhs)
{
detail::Wrapper<cl_type>::operator=(rhs);
return *this;
}
template <typename T> template <typename T>
cl_int getInfo(cl_device_info name, T* param) const cl_int getInfo(cl_device_info name, T* param) const
{ {
...@@ -1258,12 +1333,12 @@ class Platform : public detail::Wrapper<cl_platform_id> ...@@ -1258,12 +1333,12 @@ class Platform : public detail::Wrapper<cl_platform_id>
public: public:
static const Platform null(); static const Platform null();
Platform(cl_platform_id platform) { object_ = platform; }
Platform() : detail::Wrapper<cl_type>() { } Platform() : detail::Wrapper<cl_type>() { }
Platform(const Platform& platform) : detail::Wrapper<cl_type>(platform) { } Platform(const Platform& platform) : detail::Wrapper<cl_type>(platform) { }
Platform(const cl_platform_id &platform) : detail::Wrapper<cl_type>(platform) { }
Platform& operator = (const Platform& rhs) Platform& operator = (const Platform& rhs)
{ {
if (this != &rhs) { if (this != &rhs) {
...@@ -1272,6 +1347,12 @@ public: ...@@ -1272,6 +1347,12 @@ public:
return *this; return *this;
} }
Platform& operator = (const cl_platform_id& rhs)
{
detail::Wrapper<cl_type>::operator=(rhs);
return *this;
}
cl_int getInfo(cl_platform_info name, STRING_CLASS* param) const cl_int getInfo(cl_platform_info name, STRING_CLASS* param) const
{ {
return detail::errHandler( return detail::errHandler(
...@@ -1432,7 +1513,7 @@ public: ...@@ -1432,7 +1513,7 @@ public:
(cl_device_id*) &devices.front(), (cl_device_id*) &devices.front(),
notifyFptr, data, &error); notifyFptr, data, &error);
detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR); detail::errHandler(error, __CREATE_CONTEXT_ERR);
if (err != NULL) { if (err != NULL) {
*err = error; *err = error;
} }
...@@ -1463,6 +1544,8 @@ public: ...@@ -1463,6 +1544,8 @@ public:
Context(const Context& context) : detail::Wrapper<cl_type>(context) { } Context(const Context& context) : detail::Wrapper<cl_type>(context) { }
Context(const cl_context& context) : detail::Wrapper<cl_type>(context) { }
Context& operator = (const Context& rhs) Context& operator = (const Context& rhs)
{ {
if (this != &rhs) { if (this != &rhs) {
...@@ -1471,6 +1554,12 @@ public: ...@@ -1471,6 +1554,12 @@ public:
return *this; return *this;
} }
Context& operator = (const cl_context& rhs)
{
detail::Wrapper<cl_type>::operator=(rhs);
return *this;
}
template <typename T> template <typename T>
cl_int getInfo(cl_context_info name, T* param) const cl_int getInfo(cl_context_info name, T* param) const
{ {
...@@ -1539,6 +1628,8 @@ public: ...@@ -1539,6 +1628,8 @@ public:
Event(const Event& event) : detail::Wrapper<cl_type>(event) { } Event(const Event& event) : detail::Wrapper<cl_type>(event) { }
Event(const cl_event& event) : detail::Wrapper<cl_type>(event) { }
Event& operator = (const Event& rhs) Event& operator = (const Event& rhs)
{ {
if (this != &rhs) { if (this != &rhs) {
...@@ -1547,6 +1638,12 @@ public: ...@@ -1547,6 +1638,12 @@ public:
return *this; return *this;
} }
Event& operator = (const cl_event& rhs)
{
detail::Wrapper<cl_type>::operator=(rhs);
return *this;
}
template <typename T> template <typename T>
cl_int getInfo(cl_event_info name, T* param) const cl_int getInfo(cl_event_info name, T* param) const
{ {
...@@ -1686,6 +1783,8 @@ public: ...@@ -1686,6 +1783,8 @@ public:
Memory(const Memory& memory) : detail::Wrapper<cl_type>(memory) { } Memory(const Memory& memory) : detail::Wrapper<cl_type>(memory) { }
Memory(const cl_mem& memory) : detail::Wrapper<cl_type>(memory) { }
Memory& operator = (const Memory& rhs) Memory& operator = (const Memory& rhs)
{ {
if (this != &rhs) { if (this != &rhs) {
...@@ -1694,6 +1793,12 @@ public: ...@@ -1694,6 +1793,12 @@ public:
return *this; return *this;
} }
Memory& operator = (const cl_mem& rhs)
{
detail::Wrapper<cl_type>::operator=(rhs);
return *this;
}
template <typename T> template <typename T>
cl_int getInfo(cl_mem_info name, T* param) const cl_int getInfo(cl_mem_info name, T* param) const
{ {
...@@ -1759,6 +1864,8 @@ public: ...@@ -1759,6 +1864,8 @@ public:
Buffer(const Buffer& buffer) : Memory(buffer) { } Buffer(const Buffer& buffer) : Memory(buffer) { }
Buffer(const cl_mem& buffer) : Memory(buffer) { }
Buffer& operator = (const Buffer& rhs) Buffer& operator = (const Buffer& rhs)
{ {
if (this != &rhs) { if (this != &rhs) {
...@@ -1767,6 +1874,12 @@ public: ...@@ -1767,6 +1874,12 @@ public:
return *this; return *this;
} }
Buffer& operator = (const cl_mem& rhs)
{
Memory::operator=(rhs);
return *this;
}
#if defined(CL_VERSION_1_1) #if defined(CL_VERSION_1_1)
Buffer createSubBuffer( Buffer createSubBuffer(
cl_mem_flags flags, cl_mem_flags flags,
...@@ -1827,6 +1940,8 @@ public: ...@@ -1827,6 +1940,8 @@ public:
BufferD3D10(const BufferD3D10& buffer) : Buffer(buffer) { } BufferD3D10(const BufferD3D10& buffer) : Buffer(buffer) { }
BufferD3D10(const cl_mem& buffer) : Buffer(buffer) { }
BufferD3D10& operator = (const BufferD3D10& rhs) BufferD3D10& operator = (const BufferD3D10& rhs)
{ {
if (this != &rhs) { if (this != &rhs) {
...@@ -1834,6 +1949,12 @@ public: ...@@ -1834,6 +1949,12 @@ public:
} }
return *this; return *this;
} }
BufferD3D10& operator = (const cl_mem& rhs)
{
Buffer::operator=(rhs);
return *this;
}
}; };
#endif #endif
...@@ -1866,6 +1987,8 @@ public: ...@@ -1866,6 +1987,8 @@ public:
BufferGL(const BufferGL& buffer) : Buffer(buffer) { } BufferGL(const BufferGL& buffer) : Buffer(buffer) { }
BufferGL(const cl_mem& buffer) : Buffer(buffer) { }
BufferGL& operator = (const BufferGL& rhs) BufferGL& operator = (const BufferGL& rhs)
{ {
if (this != &rhs) { if (this != &rhs) {
...@@ -1874,6 +1997,12 @@ public: ...@@ -1874,6 +1997,12 @@ public:
return *this; return *this;
} }
BufferGL& operator = (const cl_mem& rhs)
{
Buffer::operator=(rhs);
return *this;
}
cl_int getObjectInfo( cl_int getObjectInfo(
cl_gl_object_type *type, cl_gl_object_type *type,
GLuint * gl_object_name) GLuint * gl_object_name)
...@@ -1913,6 +2042,8 @@ public: ...@@ -1913,6 +2042,8 @@ public:
BufferRenderGL(const BufferGL& buffer) : Buffer(buffer) { } BufferRenderGL(const BufferGL& buffer) : Buffer(buffer) { }
BufferRenderGL(const cl_mem& buffer) : Buffer(buffer) { }
BufferRenderGL& operator = (const BufferRenderGL& rhs) BufferRenderGL& operator = (const BufferRenderGL& rhs)
{ {
if (this != &rhs) { if (this != &rhs) {
...@@ -1921,6 +2052,12 @@ public: ...@@ -1921,6 +2052,12 @@ public:
return *this; return *this;
} }
BufferRenderGL& operator = (const cl_mem& rhs)
{
Buffer::operator=(rhs);
return *this;
}
cl_int getObjectInfo( cl_int getObjectInfo(
cl_gl_object_type *type, cl_gl_object_type *type,
GLuint * gl_object_name) GLuint * gl_object_name)
...@@ -1941,6 +2078,8 @@ protected: ...@@ -1941,6 +2078,8 @@ protected:
Image(const Image& image) : Memory(image) { } Image(const Image& image) : Memory(image) { }
Image(const cl_mem& image) : Memory(image) { }
Image& operator = (const Image& rhs) Image& operator = (const Image& rhs)
{ {
if (this != &rhs) { if (this != &rhs) {
...@@ -1948,6 +2087,13 @@ protected: ...@@ -1948,6 +2087,13 @@ protected:
} }
return *this; return *this;
} }
Image& operator = (const cl_mem& rhs)
{
Memory::operator=(rhs);
return *this;
}
public: public:
template <typename T> template <typename T>
cl_int getImageInfo(cl_image_info name, T* param) const cl_int getImageInfo(cl_image_info name, T* param) const
...@@ -2001,6 +2147,8 @@ public: ...@@ -2001,6 +2147,8 @@ public:
Image2D(const Image2D& image2D) : Image(image2D) { } Image2D(const Image2D& image2D) : Image(image2D) { }
Image2D(const cl_mem& image2D) : Image(image2D) { }
Image2D& operator = (const Image2D& rhs) Image2D& operator = (const Image2D& rhs)
{ {
if (this != &rhs) { if (this != &rhs) {
...@@ -2008,6 +2156,12 @@ public: ...@@ -2008,6 +2156,12 @@ public:
} }
return *this; return *this;
} }
Image2D& operator = (const cl_mem& rhs)
{
Image::operator=(rhs);
return *this;
}
}; };
/*! \class Image2DGL /*! \class Image2DGL
...@@ -2043,6 +2197,8 @@ public: ...@@ -2043,6 +2197,8 @@ public:
Image2DGL(const Image2DGL& image) : Image2D(image) { } Image2DGL(const Image2DGL& image) : Image2D(image) { }
Image2DGL(const cl_mem& image) : Image2D(image) { }
Image2DGL& operator = (const Image2DGL& rhs) Image2DGL& operator = (const Image2DGL& rhs)
{ {
if (this != &rhs) { if (this != &rhs) {
...@@ -2050,6 +2206,12 @@ public: ...@@ -2050,6 +2206,12 @@ public:
} }
return *this; return *this;
} }
Image2DGL& operator = (const cl_mem& rhs)
{
Image2D::operator=(rhs);
return *this;
}
}; };
/*! \class Image3D /*! \class Image3D
...@@ -2085,6 +2247,8 @@ public: ...@@ -2085,6 +2247,8 @@ public:
Image3D(const Image3D& image3D) : Image(image3D) { } Image3D(const Image3D& image3D) : Image(image3D) { }
Image3D(const cl_mem& image3D) : Image(image3D) { }
Image3D& operator = (const Image3D& rhs) Image3D& operator = (const Image3D& rhs)
{ {
if (this != &rhs) { if (this != &rhs) {
...@@ -2092,6 +2256,12 @@ public: ...@@ -2092,6 +2256,12 @@ public:
} }
return *this; return *this;
} }
Image3D& operator = (const cl_mem& rhs)
{
Image::operator=(rhs);
return *this;
}
}; };
/*! \class Image2DGL /*! \class Image2DGL
...@@ -2127,6 +2297,8 @@ public: ...@@ -2127,6 +2297,8 @@ public:
Image3DGL(const Image3DGL& image) : Image3D(image) { } Image3DGL(const Image3DGL& image) : Image3D(image) { }
Image3DGL(const cl_mem& image) : Image3D(image) { }
Image3DGL& operator = (const Image3DGL& rhs) Image3DGL& operator = (const Image3DGL& rhs)
{ {
if (this != &rhs) { if (this != &rhs) {
...@@ -2134,6 +2306,12 @@ public: ...@@ -2134,6 +2306,12 @@ public:
} }
return *this; return *this;
} }
Image3DGL& operator = (const cl_mem& rhs)
{
Image3D::operator=(rhs);
return *this;
}
}; };
/*! \class Sampler /*! \class Sampler
...@@ -2167,6 +2345,8 @@ public: ...@@ -2167,6 +2345,8 @@ public:
Sampler(const Sampler& sampler) : detail::Wrapper<cl_type>(sampler) { } Sampler(const Sampler& sampler) : detail::Wrapper<cl_type>(sampler) { }
Sampler(const cl_sampler& sampler) : detail::Wrapper<cl_type>(sampler) { }
Sampler& operator = (const Sampler& rhs) Sampler& operator = (const Sampler& rhs)
{ {
if (this != &rhs) { if (this != &rhs) {
...@@ -2175,6 +2355,12 @@ public: ...@@ -2175,6 +2355,12 @@ public:
return *this; return *this;
} }
Sampler& operator = (const cl_sampler& rhs)
{
detail::Wrapper<cl_type>::operator=(rhs);
return *this;
}
template <typename T> template <typename T>
cl_int getInfo(cl_sampler_info name, T* param) const cl_int getInfo(cl_sampler_info name, T* param) const
{ {
...@@ -2293,6 +2479,8 @@ public: ...@@ -2293,6 +2479,8 @@ public:
Kernel(const Kernel& kernel) : detail::Wrapper<cl_type>(kernel) { } Kernel(const Kernel& kernel) : detail::Wrapper<cl_type>(kernel) { }
Kernel(const cl_kernel& kernel) : detail::Wrapper<cl_type>(kernel) { }
Kernel& operator = (const Kernel& rhs) Kernel& operator = (const Kernel& rhs)
{ {
if (this != &rhs) { if (this != &rhs) {
...@@ -2301,6 +2489,12 @@ public: ...@@ -2301,6 +2489,12 @@ public:
return *this; return *this;
} }
Kernel& operator = (const cl_kernel& rhs)
{
detail::Wrapper<cl_type>::operator=(rhs);
return *this;
}
template <typename T> template <typename T>
cl_int getInfo(cl_kernel_info name, T* param) const cl_int getInfo(cl_kernel_info name, T* param) const
{ {
...@@ -2446,6 +2640,8 @@ public: ...@@ -2446,6 +2640,8 @@ public:
Program(const Program& program) : detail::Wrapper<cl_type>(program) { } Program(const Program& program) : detail::Wrapper<cl_type>(program) { }
Program(const cl_program& program) : detail::Wrapper<cl_type>(program) { }
Program& operator = (const Program& rhs) Program& operator = (const Program& rhs)
{ {
if (this != &rhs) { if (this != &rhs) {
...@@ -2454,6 +2650,12 @@ public: ...@@ -2454,6 +2650,12 @@ public:
return *this; return *this;
} }
Program& operator = (const cl_program& rhs)
{
detail::Wrapper<cl_type>::operator=(rhs);
return *this;
}
cl_int build( cl_int build(
const VECTOR_CLASS<Device>& devices, const VECTOR_CLASS<Device>& devices,
const char* options = NULL, const char* options = NULL,
...@@ -2536,6 +2738,26 @@ public: ...@@ -2536,6 +2738,26 @@ public:
} }
}; };
template<>
inline VECTOR_CLASS<char *> cl::Program::getInfo<CL_PROGRAM_BINARIES>(cl_int* err) const
{
VECTOR_CLASS< ::size_t> sizes = getInfo<CL_PROGRAM_BINARY_SIZES>();
VECTOR_CLASS<char *> binaries;
for (VECTOR_CLASS< ::size_t>::iterator s = sizes.begin(); s != sizes.end(); ++s)
{
char *ptr = NULL;
if (*s != 0)
ptr = new char[*s];
binaries.push_back(ptr);
}
cl_int result = getInfo(CL_PROGRAM_BINARIES, &binaries);
if (err != NULL) {
*err = result;
}
return binaries;
}
__GET_INFO_HELPER_WITH_RETAIN(cl::Program) __GET_INFO_HELPER_WITH_RETAIN(cl::Program)
inline Kernel::Kernel(const Program& program, const char* name, cl_int* err) inline Kernel::Kernel(const Program& program, const char* name, cl_int* err)
...@@ -2577,6 +2799,8 @@ public: ...@@ -2577,6 +2799,8 @@ public:
CommandQueue(const CommandQueue& commandQueue) : detail::Wrapper<cl_type>(commandQueue) { } CommandQueue(const CommandQueue& commandQueue) : detail::Wrapper<cl_type>(commandQueue) { }
CommandQueue(const cl_command_queue& commandQueue) : detail::Wrapper<cl_type>(commandQueue) { }
CommandQueue& operator = (const CommandQueue& rhs) CommandQueue& operator = (const CommandQueue& rhs)
{ {
if (this != &rhs) { if (this != &rhs) {
...@@ -2585,6 +2809,12 @@ public: ...@@ -2585,6 +2809,12 @@ public:
return *this; return *this;
} }
CommandQueue& operator = (const cl_command_queue& rhs)
{
detail::Wrapper<cl_type>::operator=(rhs);
return *this;
}
template <typename T> template <typename T>
cl_int getInfo(cl_command_queue_info name, T* param) const cl_int getInfo(cl_command_queue_info name, T* param) const
{ {
...@@ -2616,14 +2846,20 @@ public: ...@@ -2616,14 +2846,20 @@ public:
const VECTOR_CLASS<Event>* events = NULL, const VECTOR_CLASS<Event>* events = NULL,
Event* event = NULL) const Event* event = NULL) const
{ {
return detail::errHandler( cl_event tmp;
cl_int err = detail::errHandler(
::clEnqueueReadBuffer( ::clEnqueueReadBuffer(
object_, buffer(), blocking, offset, size, object_, buffer(), blocking, offset, size,
ptr, ptr,
(events != NULL) ? (cl_uint) events->size() : 0, (events != NULL) ? (cl_uint) events->size() : 0,
(events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
(cl_event*) event), (event != NULL) ? &tmp : NULL),
__ENQUEUE_READ_BUFFER_ERR); __ENQUEUE_READ_BUFFER_ERR);
if (event != NULL && err == CL_SUCCESS)
*event = tmp;
return err;
} }
cl_int enqueueWriteBuffer( cl_int enqueueWriteBuffer(
...@@ -2635,14 +2871,20 @@ public: ...@@ -2635,14 +2871,20 @@ public:
const VECTOR_CLASS<Event>* events = NULL, const VECTOR_CLASS<Event>* events = NULL,
Event* event = NULL) const Event* event = NULL) const
{ {
return detail::errHandler( cl_event tmp;
cl_int err = detail::errHandler(
::clEnqueueWriteBuffer( ::clEnqueueWriteBuffer(
object_, buffer(), blocking, offset, size, object_, buffer(), blocking, offset, size,
ptr, ptr,
(events != NULL) ? (cl_uint) events->size() : 0, (events != NULL) ? (cl_uint) events->size() : 0,
(events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
(cl_event*) event), (event != NULL) ? &tmp : NULL),
__ENQUEUE_WRITE_BUFFER_ERR); __ENQUEUE_WRITE_BUFFER_ERR);
if (event != NULL && err == CL_SUCCESS)
*event = tmp;
return err;
} }
cl_int enqueueCopyBuffer( cl_int enqueueCopyBuffer(
...@@ -2654,13 +2896,19 @@ public: ...@@ -2654,13 +2896,19 @@ public:
const VECTOR_CLASS<Event>* events = NULL, const VECTOR_CLASS<Event>* events = NULL,
Event* event = NULL) const Event* event = NULL) const
{ {
return detail::errHandler( cl_event tmp;
cl_int err = detail::errHandler(
::clEnqueueCopyBuffer( ::clEnqueueCopyBuffer(
object_, src(), dst(), src_offset, dst_offset, size, object_, src(), dst(), src_offset, dst_offset, size,
(events != NULL) ? (cl_uint) events->size() : 0, (events != NULL) ? (cl_uint) events->size() : 0,
(events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
(cl_event*) event), (event != NULL) ? &tmp : NULL),
__ENQEUE_COPY_BUFFER_ERR); __ENQEUE_COPY_BUFFER_ERR);
if (event != NULL && err == CL_SUCCESS)
*event = tmp;
return err;
} }
#if defined(CL_VERSION_1_1) #if defined(CL_VERSION_1_1)
...@@ -2678,7 +2926,8 @@ public: ...@@ -2678,7 +2926,8 @@ public:
const VECTOR_CLASS<Event>* events = NULL, const VECTOR_CLASS<Event>* events = NULL,
Event* event = NULL) const Event* event = NULL) const
{ {
return detail::errHandler( cl_event tmp;
cl_int err = detail::errHandler(
::clEnqueueReadBufferRect( ::clEnqueueReadBufferRect(
object_, object_,
buffer(), buffer(),
...@@ -2693,8 +2942,13 @@ public: ...@@ -2693,8 +2942,13 @@ public:
ptr, ptr,
(events != NULL) ? (cl_uint) events->size() : 0, (events != NULL) ? (cl_uint) events->size() : 0,
(events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
(cl_event*) event), (event != NULL) ? &tmp : NULL),
__ENQUEUE_READ_BUFFER_RECT_ERR); __ENQUEUE_READ_BUFFER_RECT_ERR);
if (event != NULL && err == CL_SUCCESS)
*event = tmp;
return err;
} }
...@@ -2712,7 +2966,8 @@ public: ...@@ -2712,7 +2966,8 @@ public:
const VECTOR_CLASS<Event>* events = NULL, const VECTOR_CLASS<Event>* events = NULL,
Event* event = NULL) const Event* event = NULL) const
{ {
return detail::errHandler( cl_event tmp;
cl_int err = detail::errHandler(
::clEnqueueWriteBufferRect( ::clEnqueueWriteBufferRect(
object_, object_,
buffer(), buffer(),
...@@ -2727,8 +2982,13 @@ public: ...@@ -2727,8 +2982,13 @@ public:
ptr, ptr,
(events != NULL) ? (cl_uint) events->size() : 0, (events != NULL) ? (cl_uint) events->size() : 0,
(events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
(cl_event*) event), (event != NULL) ? &tmp : NULL),
__ENQUEUE_WRITE_BUFFER_RECT_ERR); __ENQUEUE_WRITE_BUFFER_RECT_ERR);
if (event != NULL && err == CL_SUCCESS)
*event = tmp;
return err;
} }
cl_int enqueueCopyBufferRect( cl_int enqueueCopyBufferRect(
...@@ -2744,7 +3004,8 @@ public: ...@@ -2744,7 +3004,8 @@ public:
const VECTOR_CLASS<Event>* events = NULL, const VECTOR_CLASS<Event>* events = NULL,
Event* event = NULL) const Event* event = NULL) const
{ {
return detail::errHandler( cl_event tmp;
cl_int err = detail::errHandler(
::clEnqueueCopyBufferRect( ::clEnqueueCopyBufferRect(
object_, object_,
src(), src(),
...@@ -2758,8 +3019,13 @@ public: ...@@ -2758,8 +3019,13 @@ public:
dst_slice_pitch, dst_slice_pitch,
(events != NULL) ? (cl_uint) events->size() : 0, (events != NULL) ? (cl_uint) events->size() : 0,
(events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
(cl_event*) event), (event != NULL) ? &tmp : NULL),
__ENQEUE_COPY_BUFFER_RECT_ERR); __ENQEUE_COPY_BUFFER_RECT_ERR);
if (event != NULL && err == CL_SUCCESS)
*event = tmp;
return err;
} }
#endif #endif
...@@ -2774,14 +3040,20 @@ public: ...@@ -2774,14 +3040,20 @@ public:
const VECTOR_CLASS<Event>* events = NULL, const VECTOR_CLASS<Event>* events = NULL,
Event* event = NULL) const Event* event = NULL) const
{ {
return detail::errHandler( cl_event tmp;
cl_int err = detail::errHandler(
::clEnqueueReadImage( ::clEnqueueReadImage(
object_, image(), blocking, (const ::size_t *) origin, object_, image(), blocking, (const ::size_t *) origin,
(const ::size_t *) region, row_pitch, slice_pitch, ptr, (const ::size_t *) region, row_pitch, slice_pitch, ptr,
(events != NULL) ? (cl_uint) events->size() : 0, (events != NULL) ? (cl_uint) events->size() : 0,
(events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
(cl_event*) event), (event != NULL) ? &tmp : NULL),
__ENQUEUE_READ_IMAGE_ERR); __ENQUEUE_READ_IMAGE_ERR);
if (event != NULL && err == CL_SUCCESS)
*event = tmp;
return err;
} }
cl_int enqueueWriteImage( cl_int enqueueWriteImage(
...@@ -2795,14 +3067,20 @@ public: ...@@ -2795,14 +3067,20 @@ public:
const VECTOR_CLASS<Event>* events = NULL, const VECTOR_CLASS<Event>* events = NULL,
Event* event = NULL) const Event* event = NULL) const
{ {
return detail::errHandler( cl_event tmp;
cl_int err = detail::errHandler(
::clEnqueueWriteImage( ::clEnqueueWriteImage(
object_, image(), blocking, (const ::size_t *) origin, object_, image(), blocking, (const ::size_t *) origin,
(const ::size_t *) region, row_pitch, slice_pitch, ptr, (const ::size_t *) region, row_pitch, slice_pitch, ptr,
(events != NULL) ? (cl_uint) events->size() : 0, (events != NULL) ? (cl_uint) events->size() : 0,
(events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
(cl_event*) event), (event != NULL) ? &tmp : NULL),
__ENQUEUE_WRITE_IMAGE_ERR); __ENQUEUE_WRITE_IMAGE_ERR);
if (event != NULL && err == CL_SUCCESS)
*event = tmp;
return err;
} }
cl_int enqueueCopyImage( cl_int enqueueCopyImage(
...@@ -2814,14 +3092,20 @@ public: ...@@ -2814,14 +3092,20 @@ public:
const VECTOR_CLASS<Event>* events = NULL, const VECTOR_CLASS<Event>* events = NULL,
Event* event = NULL) const Event* event = NULL) const
{ {
return detail::errHandler( cl_event tmp;
cl_int err = detail::errHandler(
::clEnqueueCopyImage( ::clEnqueueCopyImage(
object_, src(), dst(), (const ::size_t *) src_origin, object_, src(), dst(), (const ::size_t *) src_origin,
(const ::size_t *)dst_origin, (const ::size_t *) region, (const ::size_t *)dst_origin, (const ::size_t *) region,
(events != NULL) ? (cl_uint) events->size() : 0, (events != NULL) ? (cl_uint) events->size() : 0,
(events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
(cl_event*) event), (event != NULL) ? &tmp : NULL),
__ENQUEUE_COPY_IMAGE_ERR); __ENQUEUE_COPY_IMAGE_ERR);
if (event != NULL && err == CL_SUCCESS)
*event = tmp;
return err;
} }
cl_int enqueueCopyImageToBuffer( cl_int enqueueCopyImageToBuffer(
...@@ -2833,14 +3117,20 @@ public: ...@@ -2833,14 +3117,20 @@ public:
const VECTOR_CLASS<Event>* events = NULL, const VECTOR_CLASS<Event>* events = NULL,
Event* event = NULL) const Event* event = NULL) const
{ {
return detail::errHandler( cl_event tmp;
cl_int err = detail::errHandler(
::clEnqueueCopyImageToBuffer( ::clEnqueueCopyImageToBuffer(
object_, src(), dst(), (const ::size_t *) src_origin, object_, src(), dst(), (const ::size_t *) src_origin,
(const ::size_t *) region, dst_offset, (const ::size_t *) region, dst_offset,
(events != NULL) ? (cl_uint) events->size() : 0, (events != NULL) ? (cl_uint) events->size() : 0,
(events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
(cl_event*) event), (event != NULL) ? &tmp : NULL),
__ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR); __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR);
if (event != NULL && err == CL_SUCCESS)
*event = tmp;
return err;
} }
cl_int enqueueCopyBufferToImage( cl_int enqueueCopyBufferToImage(
...@@ -2852,14 +3142,20 @@ public: ...@@ -2852,14 +3142,20 @@ public:
const VECTOR_CLASS<Event>* events = NULL, const VECTOR_CLASS<Event>* events = NULL,
Event* event = NULL) const Event* event = NULL) const
{ {
return detail::errHandler( cl_event tmp;
cl_int err = detail::errHandler(
::clEnqueueCopyBufferToImage( ::clEnqueueCopyBufferToImage(
object_, src(), dst(), src_offset, object_, src(), dst(), src_offset,
(const ::size_t *) dst_origin, (const ::size_t *) region, (const ::size_t *) dst_origin, (const ::size_t *) region,
(events != NULL) ? (cl_uint) events->size() : 0, (events != NULL) ? (cl_uint) events->size() : 0,
(events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
(cl_event*) event), (event != NULL) ? &tmp : NULL),
__ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR); __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR);
if (event != NULL && err == CL_SUCCESS)
*event = tmp;
return err;
} }
void* enqueueMapBuffer( void* enqueueMapBuffer(
...@@ -2922,13 +3218,19 @@ public: ...@@ -2922,13 +3218,19 @@ public:
const VECTOR_CLASS<Event>* events = NULL, const VECTOR_CLASS<Event>* events = NULL,
Event* event = NULL) const Event* event = NULL) const
{ {
return detail::errHandler( cl_event tmp;
cl_int err = detail::errHandler(
::clEnqueueUnmapMemObject( ::clEnqueueUnmapMemObject(
object_, memory(), mapped_ptr, object_, memory(), mapped_ptr,
(events != NULL) ? (cl_uint) events->size() : 0, (events != NULL) ? (cl_uint) events->size() : 0,
(events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
(cl_event*) event), (event != NULL) ? &tmp : NULL),
__ENQUEUE_UNMAP_MEM_OBJECT_ERR); __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
if (event != NULL && err == CL_SUCCESS)
*event = tmp;
return err;
} }
cl_int enqueueNDRangeKernel( cl_int enqueueNDRangeKernel(
...@@ -2939,7 +3241,8 @@ public: ...@@ -2939,7 +3241,8 @@ public:
const VECTOR_CLASS<Event>* events = NULL, const VECTOR_CLASS<Event>* events = NULL,
Event* event = NULL) const Event* event = NULL) const
{ {
return detail::errHandler( cl_event tmp;
cl_int err = detail::errHandler(
::clEnqueueNDRangeKernel( ::clEnqueueNDRangeKernel(
object_, kernel(), (cl_uint) global.dimensions(), object_, kernel(), (cl_uint) global.dimensions(),
offset.dimensions() != 0 ? (const ::size_t*) offset : NULL, offset.dimensions() != 0 ? (const ::size_t*) offset : NULL,
...@@ -2947,8 +3250,13 @@ public: ...@@ -2947,8 +3250,13 @@ public:
local.dimensions() != 0 ? (const ::size_t*) local : NULL, local.dimensions() != 0 ? (const ::size_t*) local : NULL,
(events != NULL) ? (cl_uint) events->size() : 0, (events != NULL) ? (cl_uint) events->size() : 0,
(events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
(cl_event*) event), (event != NULL) ? &tmp : NULL),
__ENQUEUE_NDRANGE_KERNEL_ERR); __ENQUEUE_NDRANGE_KERNEL_ERR);
if (event != NULL && err == CL_SUCCESS)
*event = tmp;
return err;
} }
cl_int enqueueTask( cl_int enqueueTask(
...@@ -2956,17 +3264,27 @@ public: ...@@ -2956,17 +3264,27 @@ public:
const VECTOR_CLASS<Event>* events = NULL, const VECTOR_CLASS<Event>* events = NULL,
Event* event = NULL) const Event* event = NULL) const
{ {
return detail::errHandler( cl_event tmp;
cl_int err = detail::errHandler(
::clEnqueueTask( ::clEnqueueTask(
object_, kernel(), object_, kernel(),
(events != NULL) ? (cl_uint) events->size() : 0, (events != NULL) ? (cl_uint) events->size() : 0,
(events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
(cl_event*) event), (event != NULL) ? &tmp : NULL),
__ENQUEUE_TASK_ERR); __ENQUEUE_TASK_ERR);
if (event != NULL && err == CL_SUCCESS)
*event = tmp;
return err;
} }
// Different versions of cl.h define second argument differently:
// 'void (__stdcall *)(void *)' verses 'void (__cdecl *)(void *)'
// So comment out as not used by OpenMM.
#if 0
cl_int enqueueNativeKernel( cl_int enqueueNativeKernel(
void (*userFptr)(void *), void (CL_CALLBACK *userFptr)(void *),
std::pair<void*, ::size_t> args, std::pair<void*, ::size_t> args,
const VECTOR_CLASS<Memory>* mem_objects = NULL, const VECTOR_CLASS<Memory>* mem_objects = NULL,
const VECTOR_CLASS<const void*>* mem_locs = NULL, const VECTOR_CLASS<const void*>* mem_locs = NULL,
...@@ -2983,7 +3301,8 @@ public: ...@@ -2983,7 +3301,8 @@ public:
} }
} }
return detail::errHandler( cl_event tmp;
cl_int err = detail::errHandler(
::clEnqueueNativeKernel( ::clEnqueueNativeKernel(
object_, userFptr, args.first, args.second, object_, userFptr, args.first, args.second,
(mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0, (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
...@@ -2991,9 +3310,15 @@ public: ...@@ -2991,9 +3310,15 @@ public:
(mem_locs != NULL) ? (const void **) &mem_locs->front() : NULL, (mem_locs != NULL) ? (const void **) &mem_locs->front() : NULL,
(events != NULL) ? (cl_uint) events->size() : 0, (events != NULL) ? (cl_uint) events->size() : 0,
(events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
(cl_event*) event), (event != NULL) ? &tmp : NULL),
__ENQUEUE_NATIVE_KERNEL); __ENQUEUE_NATIVE_KERNEL);
if (event != NULL && err == CL_SUCCESS)
*event = tmp;
return err;
} }
#endif
cl_int enqueueMarker(Event* event = NULL) const cl_int enqueueMarker(Event* event = NULL) const
{ {
...@@ -3017,15 +3342,21 @@ public: ...@@ -3017,15 +3342,21 @@ public:
const VECTOR_CLASS<Event>* events = NULL, const VECTOR_CLASS<Event>* events = NULL,
Event* event = NULL) const Event* event = NULL) const
{ {
return detail::errHandler( cl_event tmp;
cl_int err = detail::errHandler(
::clEnqueueAcquireGLObjects( ::clEnqueueAcquireGLObjects(
object_, object_,
(mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0, (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
(mem_objects != NULL) ? (const cl_mem *) &mem_objects->front(): NULL, (mem_objects != NULL) ? (const cl_mem *) &mem_objects->front(): NULL,
(events != NULL) ? (cl_uint) events->size() : 0, (events != NULL) ? (cl_uint) events->size() : 0,
(events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
(cl_event*) event), (event != NULL) ? &tmp : NULL),
__ENQUEUE_ACQUIRE_GL_ERR); __ENQUEUE_ACQUIRE_GL_ERR);
if (event != NULL && err == CL_SUCCESS)
*event = tmp;
return err;
} }
cl_int enqueueReleaseGLObjects( cl_int enqueueReleaseGLObjects(
...@@ -3033,15 +3364,21 @@ public: ...@@ -3033,15 +3364,21 @@ public:
const VECTOR_CLASS<Event>* events = NULL, const VECTOR_CLASS<Event>* events = NULL,
Event* event = NULL) const Event* event = NULL) const
{ {
return detail::errHandler( cl_event tmp;
cl_int err = detail::errHandler(
::clEnqueueReleaseGLObjects( ::clEnqueueReleaseGLObjects(
object_, object_,
(mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0, (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
(mem_objects != NULL) ? (const cl_mem *) &mem_objects->front(): NULL, (mem_objects != NULL) ? (const cl_mem *) &mem_objects->front(): NULL,
(events != NULL) ? (cl_uint) events->size() : 0, (events != NULL) ? (cl_uint) events->size() : 0,
(events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
(cl_event*) event), (event != NULL) ? &tmp : NULL),
__ENQUEUE_RELEASE_GL_ERR); __ENQUEUE_RELEASE_GL_ERR);
if (event != NULL && err == CL_SUCCESS)
*event = tmp;
return err;
} }
#if defined (USE_DX_INTEROP) #if defined (USE_DX_INTEROP)
...@@ -3062,15 +3399,21 @@ typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueReleaseD3D10ObjectsKHR)( ...@@ -3062,15 +3399,21 @@ typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueReleaseD3D10ObjectsKHR)(
static PFN_clEnqueueAcquireD3D10ObjectsKHR pfn_clEnqueueAcquireD3D10ObjectsKHR = NULL; static PFN_clEnqueueAcquireD3D10ObjectsKHR pfn_clEnqueueAcquireD3D10ObjectsKHR = NULL;
__INIT_CL_EXT_FCN_PTR(clEnqueueAcquireD3D10ObjectsKHR); __INIT_CL_EXT_FCN_PTR(clEnqueueAcquireD3D10ObjectsKHR);
return detail::errHandler( cl_event tmp;
cl_int err = detail::errHandler(
pfn_clEnqueueAcquireD3D10ObjectsKHR( pfn_clEnqueueAcquireD3D10ObjectsKHR(
object_, object_,
(mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0, (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
(mem_objects != NULL) ? (const cl_mem *) &mem_objects->front(): NULL, (mem_objects != NULL) ? (const cl_mem *) &mem_objects->front(): NULL,
(events != NULL) ? (cl_uint) events->size() : 0, (events != NULL) ? (cl_uint) events->size() : 0,
(events != NULL) ? (cl_event*) &events->front() : NULL, (events != NULL) ? (cl_event*) &events->front() : NULL,
(cl_event*) event), (event != NULL) ? &tmp : NULL),
__ENQUEUE_ACQUIRE_GL_ERR); __ENQUEUE_ACQUIRE_GL_ERR);
if (event != NULL && err == CL_SUCCESS)
*event = tmp;
return err;
} }
cl_int enqueueReleaseD3D10Objects( cl_int enqueueReleaseD3D10Objects(
...@@ -3081,15 +3424,21 @@ typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueReleaseD3D10ObjectsKHR)( ...@@ -3081,15 +3424,21 @@ typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueReleaseD3D10ObjectsKHR)(
static PFN_clEnqueueReleaseD3D10ObjectsKHR pfn_clEnqueueReleaseD3D10ObjectsKHR = NULL; static PFN_clEnqueueReleaseD3D10ObjectsKHR pfn_clEnqueueReleaseD3D10ObjectsKHR = NULL;
__INIT_CL_EXT_FCN_PTR(clEnqueueReleaseD3D10ObjectsKHR); __INIT_CL_EXT_FCN_PTR(clEnqueueReleaseD3D10ObjectsKHR);
return detail::errHandler( cl_event tmp;
cl_int err = detail::errHandler(
pfn_clEnqueueReleaseD3D10ObjectsKHR( pfn_clEnqueueReleaseD3D10ObjectsKHR(
object_, object_,
(mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0, (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
(mem_objects != NULL) ? (const cl_mem *) &mem_objects->front(): NULL, (mem_objects != NULL) ? (const cl_mem *) &mem_objects->front(): NULL,
(events != NULL) ? (cl_uint) events->size() : 0, (events != NULL) ? (cl_uint) events->size() : 0,
(events != NULL) ? (cl_event*) &events->front() : NULL, (events != NULL) ? (cl_event*) &events->front() : NULL,
(cl_event*) event), (event != NULL) ? &tmp : NULL),
__ENQUEUE_RELEASE_GL_ERR); __ENQUEUE_RELEASE_GL_ERR);
if (event != NULL && err == CL_SUCCESS)
*event = tmp;
return err;
} }
#endif #endif
...@@ -3391,7 +3740,7 @@ inline KernelFunctor::KernelFunctor(const KernelFunctor& rhs) : ...@@ -3391,7 +3740,7 @@ inline KernelFunctor::KernelFunctor(const KernelFunctor& rhs) :
{ {
} }
Event KernelFunctor::operator()(const VECTOR_CLASS<Event>* events) Event KernelFunctor::operator()(const VECTOR_CLASS<Event>* )
{ {
Event event; Event event;
...@@ -3409,7 +3758,7 @@ Event KernelFunctor::operator()(const VECTOR_CLASS<Event>* events) ...@@ -3409,7 +3758,7 @@ Event KernelFunctor::operator()(const VECTOR_CLASS<Event>* events)
template<typename A1> template<typename A1>
Event KernelFunctor::operator()( Event KernelFunctor::operator()(
const A1& a1, const A1& a1,
const VECTOR_CLASS<Event>* events) const VECTOR_CLASS<Event>* )
{ {
Event event; Event event;
...@@ -3430,7 +3779,7 @@ template<typename A1, typename A2> ...@@ -3430,7 +3779,7 @@ template<typename A1, typename A2>
Event KernelFunctor::operator()( Event KernelFunctor::operator()(
const A1& a1, const A1& a1,
const A2& a2, const A2& a2,
const VECTOR_CLASS<Event>* events) const VECTOR_CLASS<Event>* )
{ {
Event event; Event event;
...@@ -3453,7 +3802,7 @@ Event KernelFunctor::operator()( ...@@ -3453,7 +3802,7 @@ Event KernelFunctor::operator()(
const A1& a1, const A1& a1,
const A2& a2, const A2& a2,
const A3& a3, const A3& a3,
const VECTOR_CLASS<Event>* events) const VECTOR_CLASS<Event>* )
{ {
Event event; Event event;
...@@ -3478,7 +3827,7 @@ Event KernelFunctor::operator()( ...@@ -3478,7 +3827,7 @@ Event KernelFunctor::operator()(
const A2& a2, const A2& a2,
const A3& a3, const A3& a3,
const A4& a4, const A4& a4,
const VECTOR_CLASS<Event>* events) const VECTOR_CLASS<Event>* )
{ {
Event event; Event event;
...@@ -3505,7 +3854,7 @@ Event KernelFunctor::operator()( ...@@ -3505,7 +3854,7 @@ Event KernelFunctor::operator()(
const A3& a3, const A3& a3,
const A4& a4, const A4& a4,
const A5& a5, const A5& a5,
const VECTOR_CLASS<Event>* events) const VECTOR_CLASS<Event>* )
{ {
Event event; Event event;
...@@ -3535,7 +3884,7 @@ Event KernelFunctor::operator()( ...@@ -3535,7 +3884,7 @@ Event KernelFunctor::operator()(
const A4& a4, const A4& a4,
const A5& a5, const A5& a5,
const A6& a6, const A6& a6,
const VECTOR_CLASS<Event>* events) const VECTOR_CLASS<Event>* )
{ {
Event event; Event event;
...@@ -3567,7 +3916,7 @@ Event KernelFunctor::operator()( ...@@ -3567,7 +3916,7 @@ Event KernelFunctor::operator()(
const A5& a5, const A5& a5,
const A6& a6, const A6& a6,
const A7& a7, const A7& a7,
const VECTOR_CLASS<Event>* events) const VECTOR_CLASS<Event>* )
{ {
Event event; Event event;
...@@ -3601,7 +3950,7 @@ Event KernelFunctor::operator()( ...@@ -3601,7 +3950,7 @@ Event KernelFunctor::operator()(
const A6& a6, const A6& a6,
const A7& a7, const A7& a7,
const A8& a8, const A8& a8,
const VECTOR_CLASS<Event>* events) const VECTOR_CLASS<Event>* )
{ {
Event event; Event event;
...@@ -3637,7 +3986,7 @@ Event KernelFunctor::operator()( ...@@ -3637,7 +3986,7 @@ Event KernelFunctor::operator()(
const A7& a7, const A7& a7,
const A8& a8, const A8& a8,
const A9& a9, const A9& a9,
const VECTOR_CLASS<Event>* events) const VECTOR_CLASS<Event>* )
{ {
Event event; Event event;
...@@ -3675,7 +4024,7 @@ Event KernelFunctor::operator()( ...@@ -3675,7 +4024,7 @@ Event KernelFunctor::operator()(
const A8& a8, const A8& a8,
const A9& a9, const A9& a9,
const A10& a10, const A10& a10,
const VECTOR_CLASS<Event>* events) const VECTOR_CLASS<Event>* )
{ {
Event event; Event event;
...@@ -3716,7 +4065,7 @@ Event KernelFunctor::operator()( ...@@ -3716,7 +4065,7 @@ Event KernelFunctor::operator()(
const A9& a9, const A9& a9,
const A10& a10, const A10& a10,
const A11& a11, const A11& a11,
const VECTOR_CLASS<Event>* events) const VECTOR_CLASS<Event>* )
{ {
Event event; Event event;
...@@ -3759,7 +4108,7 @@ Event KernelFunctor::operator()( ...@@ -3759,7 +4108,7 @@ Event KernelFunctor::operator()(
const A10& a10, const A10& a10,
const A11& a11, const A11& a11,
const A12& a12, const A12& a12,
const VECTOR_CLASS<Event>* events) const VECTOR_CLASS<Event>* )
{ {
Event event; Event event;
...@@ -3804,7 +4153,7 @@ Event KernelFunctor::operator()( ...@@ -3804,7 +4153,7 @@ Event KernelFunctor::operator()(
const A11& a11, const A11& a11,
const A12& a12, const A12& a12,
const A13& a13, const A13& a13,
const VECTOR_CLASS<Event>* events) const VECTOR_CLASS<Event>* )
{ {
Event event; Event event;
...@@ -3851,7 +4200,7 @@ Event KernelFunctor::operator()( ...@@ -3851,7 +4200,7 @@ Event KernelFunctor::operator()(
const A12& a12, const A12& a12,
const A13& a13, const A13& a13,
const A14& a14, const A14& a14,
const VECTOR_CLASS<Event>* events) const VECTOR_CLASS<Event>* )
{ {
Event event; Event event;
...@@ -3900,7 +4249,7 @@ Event KernelFunctor::operator()( ...@@ -3900,7 +4249,7 @@ Event KernelFunctor::operator()(
const A13& a13, const A13& a13,
const A14& a14, const A14& a14,
const A15& a15, const A15& a15,
const VECTOR_CLASS<Event>* events) const VECTOR_CLASS<Event>* )
{ {
Event event; Event event;
...@@ -3948,6 +4297,7 @@ Event KernelFunctor::operator()( ...@@ -3948,6 +4297,7 @@ Event KernelFunctor::operator()(
#undef __GET_PROGRAM_BUILD_INFO_ERR #undef __GET_PROGRAM_BUILD_INFO_ERR
#undef __GET_COMMAND_QUEUE_INFO_ERR #undef __GET_COMMAND_QUEUE_INFO_ERR
#undef __CREATE_CONTEXT_ERR
#undef __CREATE_CONTEXT_FROM_TYPE_ERR #undef __CREATE_CONTEXT_FROM_TYPE_ERR
#undef __GET_SUPPORTED_IMAGE_FORMATS_ERR #undef __GET_SUPPORTED_IMAGE_FORMATS_ERR
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment