From: Dag Lem Date: Thu, 16 May 2013 21:38:48 +0000 (+0200) Subject: Updated cl.hpp from http://www.khronos.org/registry/cl/api/1.2/cl.hpp X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=af3449c2928f6652db6961e56e924566820cac11;p=contrib%2Fbeignet.git Updated cl.hpp from khronos.org/registry/cl/api/1.2/cl.hpp Signed-off-by: Dag Lem Reviewed-by: Zhigang Gong --- diff --git a/include/CL/cl.hpp b/include/CL/cl.hpp index 806e736..06448e2 100644 --- a/include/CL/cl.hpp +++ b/include/CL/cl.hpp @@ -29,11 +29,10 @@ * * Additions and fixes from: * Brian Cole, March 3rd 2010 and April 2012 - * Lee Howes, October 2011, March 2012 * Matt Gruenke, April 2012. * - * \version 1.2.1 - * \date September 2012 + * \version 1.2.4 + * \date January 2013 * * Optional extension support * @@ -168,12 +167,6 @@ #include #endif -// TODO: Remove once declaration is moved elsewhere -//#if !defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) -//#define CL_USE_DEPRECATED_OPENCL_1_1_APIS -//#endif // #if !defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) - - #if defined(__APPLE__) || defined(__MACOSX) #include #include @@ -393,7 +386,7 @@ static inline cl_int errHandler (cl_int err, const char * errStr = NULL) #define __BUILD_PROGRAM_ERR __ERR_STR(clBuildProgram) #if defined(CL_VERSION_1_2) #define __COMPILE_PROGRAM_ERR __ERR_STR(clCompileProgram) -#define __SET_PRINTF_CALLBACK_ERR __ERR_STR(clSetPrintfCallback) + #endif // #if defined(CL_VERSION_1_2) #define __CREATE_KERNELS_IN_PROGRAM_ERR __ERR_STR(clCreateKernelsInProgram) @@ -433,7 +426,7 @@ static inline cl_int errHandler (cl_int err, const char * errStr = NULL) #define __VECTOR_CAPACITY_ERR __ERR_STR(Vector capacity error) /** - * CL 1.1 version that uses device fission. + * CL 1.2 version that uses device fission. */ #if defined(CL_VERSION_1_2) #define __CREATE_SUB_DEVICES __ERR_STR(clCreateSubDevices) @@ -458,6 +451,13 @@ static inline cl_int errHandler (cl_int err, const char * errStr = NULL) #endif // __CL_USER_OVERRIDE_ERROR_STRINGS //! \endcond +/** + * CL 1.2 marker and barrier commands + */ +#if defined(CL_VERSION_1_2) +#define __ENQUEUE_MARKER_WAIT_LIST_ERR __ERR_STR(clEnqueueMarkerWithWaitList) +#define __ENQUEUE_BARRIER_WAIT_LIST_ERR __ERR_STR(clEnqueueBarrierWithWaitList) +#endif // #if defined(CL_VERSION_1_2) #if !defined(__USE_DEV_STRING) && !defined(__NO_STD_STRING) typedef std::string STRING_CLASS; @@ -623,10 +623,8 @@ public: //! \brief Destructor - frees memory used to hold the current value. ~string() { - if (str_ != NULL) { - delete[] str_; - str_ = NULL; - } + delete[] str_; + str_ = NULL; } //! \brief Queries the length of the string, excluding any added '\0's. @@ -2327,9 +2325,16 @@ public: cl_int* err = NULL) { cl_int error; + + ::size_t numDevices = devices.size(); + cl_device_id* deviceIDs = (cl_device_id*) alloca(numDevices * sizeof(cl_device_id)); + for( ::size_t deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) { + deviceIDs[deviceIndex] = (devices[deviceIndex])(); + } + object_ = ::clCreateContext( - properties, (cl_uint) devices.size(), - (cl_device_id*) &devices.front(), + properties, (cl_uint) numDevices, + deviceIDs, notifyFptr, data, &error); detail::errHandler(error, __CREATE_CONTEXT_ERR); @@ -2350,9 +2355,12 @@ public: cl_int* err = NULL) { cl_int error; + + cl_device_id deviceID = device(); + object_ = ::clCreateContext( properties, 1, - (cl_device_id*) &device, + &deviceID, notifyFptr, data, &error); detail::errHandler(error, __CREATE_CONTEXT_ERR); @@ -2554,25 +2562,6 @@ public: formats->assign(&value[0], &value[numEntries]); return CL_SUCCESS; } - - -#if defined(CL_VERSION_1_2) - cl_int setPrintfCallback( - void (CL_CALLBACK * pfn_notify)( - cl_context /* program */, - cl_uint /*printf_data_len */, - char * /* printf_data_ptr */, - void * /* user_data */), - void * user_data ) - { - return detail::errHandler( - ::clSetPrintfCallback( - object_, - pfn_notify, - user_data), - __SET_PRINTF_CALLBACK_ERR); - } -#endif // #if defined(CL_VERSION_1_2) }; inline Device Device::getDefault(cl_int * err) @@ -3016,7 +3005,7 @@ public: Buffer( IteratorType startIterator, IteratorType endIterator, - bool readOnly = false, + bool readOnly, bool useHostPtr = false, cl_int* err = NULL) { @@ -4121,14 +4110,14 @@ public: ImageGL& operator = (const ImageGL& rhs) { if (this != &rhs) { - ImageGL::operator=(rhs); + Image::operator=(rhs); } return *this; } ImageGL& operator = (const cl_mem& rhs) { - ImageGL::operator=(rhs); + Image::operator=(rhs); return *this; } }; @@ -4443,7 +4432,7 @@ public: { typename detail::param_traits< detail::cl_kernel_arg_info, name>::param_type param; - cl_int result = getArgInfo(name, argIndex, ¶m); + cl_int result = getArgInfo(argIndex, name, ¶m); if (err != NULL) { *err = result; } @@ -4650,9 +4639,15 @@ public: lengths[i] = binaries[(int)i].second; } + ::size_t numDevices = devices.size(); + cl_device_id* deviceIDs = (cl_device_id*) alloca(numDevices * sizeof(cl_device_id)); + for( ::size_t deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) { + deviceIDs[deviceIndex] = (devices[deviceIndex])(); + } + object_ = ::clCreateProgramWithBinary( context(), (cl_uint) devices.size(), - (cl_device_id*)&devices.front(), + deviceIDs, lengths, images, binaryStatus != NULL ? (cl_int*) &binaryStatus->front() : NULL, &error); @@ -4676,11 +4671,18 @@ public: cl_int* err = NULL) { cl_int error; + + + ::size_t numDevices = devices.size(); + cl_device_id* deviceIDs = (cl_device_id*) alloca(numDevices * sizeof(cl_device_id)); + for( ::size_t deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) { + deviceIDs[deviceIndex] = (devices[deviceIndex])(); + } object_ = ::clCreateProgramWithBuiltInKernels( context(), (cl_uint) devices.size(), - (cl_device_id*)&devices.front(), + deviceIDs, kernelNames.c_str(), &error); @@ -4717,12 +4719,18 @@ public: void (CL_CALLBACK * notifyFptr)(cl_program, void *) = NULL, void* data = NULL) const { + ::size_t numDevices = devices.size(); + cl_device_id* deviceIDs = (cl_device_id*) alloca(numDevices * sizeof(cl_device_id)); + for( ::size_t deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) { + deviceIDs[deviceIndex] = (devices[deviceIndex])(); + } + return detail::errHandler( ::clBuildProgram( object_, (cl_uint) devices.size(), - (cl_device_id*)&devices.front(), + deviceIDs, options, notifyFptr, data), @@ -5668,7 +5676,7 @@ public: (events != NULL) ? (cl_uint) events->size() : 0, (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, (event != NULL) ? &tmp : NULL), - __ENQUEUE_UNMAP_MEM_OBJECT_ERR); + __ENQUEUE_MARKER_WAIT_LIST_ERR); if (event != NULL && err == CL_SUCCESS) *event = tmp; @@ -5687,18 +5695,18 @@ public: * all events either in the event_wait_list or all previously enqueued commands, queued * before this command to command_queue, have completed. */ - cl_int clEnqueueBarrierWithWaitList( + cl_int enqueueBarrierWithWaitList( const VECTOR_CLASS *events = 0, Event *event = 0) { cl_event tmp; cl_int err = detail::errHandler( - ::clEnqueueMarkerWithWaitList( + ::clEnqueueBarrierWithWaitList( object_, (events != NULL) ? (cl_uint) events->size() : 0, (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, (event != NULL) ? &tmp : NULL), - __ENQUEUE_UNMAP_MEM_OBJECT_ERR); + __ENQUEUE_BARRIER_WAIT_LIST_ERR); if (event != NULL && err == CL_SUCCESS) *event = tmp;