1 /*******************************************************************************
2 * Copyright (c) 2008-2015 The Khronos Group Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and/or associated documentation files (the
6 * "Materials"), to deal in the Materials without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sublicense, and/or sell copies of the Materials, and to
9 * permit persons to whom the Materials are furnished to do so, subject to
10 * the following conditions:
12 * The above copyright notice and this permission notice shall be included
13 * in all copies or substantial portions of the Materials.
15 * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS
16 * KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS
17 * SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT
18 * https://www.khronos.org/registry/
20 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
27 ******************************************************************************/
31 * \brief C++ bindings for OpenCL 1.0 (rev 48), OpenCL 1.1 (rev 33) and
33 * \author Benedict R. Gaster, Laurent Morichetti and Lee Howes
35 * Additions and fixes from:
36 * Brian Cole, March 3rd 2010 and April 2012
37 * Matt Gruenke, April 2012.
38 * Bruce Merry, February 2013.
39 * Tom Deakin and Simon McIntosh-Smith, July 2013
44 * Optional extension support
47 * cl_ext_device_fission
48 * #define USE_CL_DEVICE_FISSION
52 * \section intro Introduction
53 * For many large applications C++ is the language of choice and so it seems
54 * reasonable to define C++ bindings for OpenCL.
57 * The interface is contained with a single C++ header file \em cl.hpp and all
58 * definitions are contained within the namespace \em cl. There is no additional
59 * requirement to include \em cl.h and to use either the C++ or original C
60 * bindings it is enough to simply include \em cl.hpp.
62 * The bindings themselves are lightweight and correspond closely to the
63 * underlying C API. Using the C++ bindings introduces no additional execution
66 * For detail documentation on the bindings see:
68 * The OpenCL C++ Wrapper API 1.2 (revision 09)
69 * http://www.khronos.org/registry/cl/specs/opencl-cplusplus-1.2.pdf
71 * \section example Example
73 * The following example shows a general use case for the C++
74 * bindings, including support for the optional exception feature and
75 * also the supplied vector and string classes, see following sections for
76 * decriptions of these features.
79 * #define __CL_ENABLE_EXCEPTIONS
81 * #if defined(__APPLE__) || defined(__MACOSX)
82 * #include <OpenCL/cl.hpp>
84 * #include <CL/cl.hpp>
90 * const char * helloStr = "__kernel void "
99 * cl_int err = CL_SUCCESS;
102 * std::vector<cl::Platform> platforms;
103 * cl::Platform::get(&platforms);
104 * if (platforms.size() == 0) {
105 * std::cout << "Platform size 0\n";
109 * cl_context_properties properties[] =
110 * { CL_CONTEXT_PLATFORM, (cl_context_properties)(platforms[0])(), 0};
111 * cl::Context context(CL_DEVICE_TYPE_CPU, properties);
113 * std::vector<cl::Device> devices = context.getInfo<CL_CONTEXT_DEVICES>();
115 * cl::Program::Sources source(1,
116 * std::make_pair(helloStr,strlen(helloStr)));
117 * cl::Program program_ = cl::Program(context, source);
118 * program_.build(devices);
120 * cl::Kernel kernel(program_, "hello", &err);
123 * cl::CommandQueue queue(context, devices[0], 0, &err);
124 * queue.enqueueNDRangeKernel(
134 * catch (cl::Error err) {
144 * return EXIT_SUCCESS;
153 // The latest version of the OpenCL C++ bindings can be found on GitHub:
154 // -> https://github.com/KhronosGroup/OpenCL-CLHPP
155 #pragma message("This version of the OpenCL Host API C++ bindings is deprecated, please use cl2.hpp instead.")
161 #if defined(USE_DX_INTEROP)
162 #include <CL/cl_d3d10.h>
163 #include <CL/cl_dx9_media_sharing.h>
167 #if defined(_MSC_VER)
172 #if defined(USE_CL_DEVICE_FISSION)
173 #include <CL/cl_ext.h>
176 #if defined(__APPLE__) || defined(__MACOSX)
177 #include <OpenCL/opencl.h>
179 #include <CL/opencl.h>
182 #if (_MSC_VER >= 1700) || (__cplusplus >= 201103L)
183 #define CL_HPP_RVALUE_REFERENCES_SUPPORTED
184 #define CL_HPP_CPP11_ATOMICS_SUPPORTED
188 #if (__cplusplus >= 201103L)
189 #define CL_HPP_NOEXCEPT noexcept
191 #define CL_HPP_NOEXCEPT
195 // To avoid accidentally taking ownership of core OpenCL types
196 // such as cl_kernel constructors are made explicit
198 #if defined(CL_VERSION_1_2) && !defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
199 #define __CL_EXPLICIT_CONSTRUCTORS explicit
200 #else // #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
201 #define __CL_EXPLICIT_CONSTRUCTORS
202 #endif // #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
204 // Define deprecated prefixes and suffixes to ensure compilation
205 // in case they are not pre-defined
206 #if !defined(CL_EXT_PREFIX__VERSION_1_1_DEPRECATED)
207 #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
208 #endif // #if !defined(CL_EXT_PREFIX__VERSION_1_1_DEPRECATED)
209 #if !defined(CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED)
210 #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
211 #endif // #if !defined(CL_EXT_PREFIX__VERSION_1_1_DEPRECATED)
213 #if !defined(CL_CALLBACK)
221 #if defined(__CL_ENABLE_EXCEPTIONS)
223 #endif // #if defined(__CL_ENABLE_EXCEPTIONS)
225 #if !defined(__NO_STD_VECTOR)
229 #if !defined(__NO_STD_STRING)
233 #if defined(__ANDROID__) || defined(linux) || defined(__APPLE__) || defined(__MACOSX)
239 // Compiler specific weak linking
240 #ifndef CL_WEAK_ATTRIB_PREFIX
241 // C++17: use inline variables/functions
242 #if __cplusplus >= 201703L
243 #define CL_USE_INLINE
247 #define CL_WEAK_ATTRIB_PREFIX inline
248 #define CL_WEAK_ATTRIB_SUFFIX
250 #define CL_WEAK_ATTRIB_PREFIX __declspec(selectany)
251 #define CL_WEAK_ATTRIB_SUFFIX
252 #else // GCC, CLANG, etc.
253 #define CL_WEAK_ATTRIB_PREFIX
254 #define CL_WEAK_ATTRIB_SUFFIX __attribute__((weak))
255 #endif // CL_USE_INLINE
257 #endif // CL_WEAK_ATTRIB_PREFIX
261 * \brief The OpenCL C++ bindings are defined within this namespace.
269 * Deprecated APIs for 1.2
271 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) || (defined(CL_VERSION_1_1) && !defined(CL_VERSION_1_2))
272 #define __INIT_CL_EXT_FCN_PTR(name) \
274 pfn_##name = (PFN_##name) \
275 clGetExtensionFunctionAddress(#name); \
279 #endif // #if defined(CL_VERSION_1_1)
281 #if defined(CL_VERSION_1_2)
282 #define __INIT_CL_EXT_FCN_PTR_PLATFORM(platform, name) \
284 pfn_##name = (PFN_##name) \
285 clGetExtensionFunctionAddressForPlatform(platform, #name); \
289 #endif // #if defined(CL_VERSION_1_1)
298 #if defined(__CL_ENABLE_EXCEPTIONS)
299 /*! \brief Exception class
301 * This may be thrown by API functions when __CL_ENABLE_EXCEPTIONS is defined.
303 class Error : public std::exception
307 const char * errStr_;
309 /*! \brief Create a new CL error exception for a given error code
310 * and corresponding message.
312 * \param err error code value.
314 * \param errStr a descriptive string that must remain in scope until
315 * handling of the exception has concluded. If set, it
316 * will be returned by what().
318 Error(cl_int err, const char * errStr = NULL) : err_(err), errStr_(errStr)
323 /*! \brief Get error string associated with exception
325 * \return A memory pointer to the error message string.
327 virtual const char * what() const throw ()
329 if (errStr_ == NULL) {
337 /*! \brief Get error code associated with exception
339 * \return The error code.
341 cl_int err(void) const { return err_; }
344 #define __ERR_STR(x) #x
346 #define __ERR_STR(x) NULL
347 #endif // __CL_ENABLE_EXCEPTIONS
352 #if defined(__CL_ENABLE_EXCEPTIONS)
353 static inline cl_int errHandler (
355 const char * errStr = NULL)
357 if (err != CL_SUCCESS) {
358 throw Error(err, errStr);
363 static inline cl_int errHandler (cl_int err, const char * errStr = NULL)
365 (void) errStr; // suppress unused variable warning
368 #endif // __CL_ENABLE_EXCEPTIONS
373 //! \cond DOXYGEN_DETAIL
374 #if !defined(__CL_USER_OVERRIDE_ERROR_STRINGS)
375 #define __GET_DEVICE_INFO_ERR __ERR_STR(clGetDeviceInfo)
376 #define __GET_PLATFORM_INFO_ERR __ERR_STR(clGetPlatformInfo)
377 #define __GET_DEVICE_IDS_ERR __ERR_STR(clGetDeviceIDs)
378 #define __GET_PLATFORM_IDS_ERR __ERR_STR(clGetPlatformIDs)
379 #define __GET_CONTEXT_INFO_ERR __ERR_STR(clGetContextInfo)
380 #define __GET_EVENT_INFO_ERR __ERR_STR(clGetEventInfo)
381 #define __GET_EVENT_PROFILE_INFO_ERR __ERR_STR(clGetEventProfileInfo)
382 #define __GET_MEM_OBJECT_INFO_ERR __ERR_STR(clGetMemObjectInfo)
383 #define __GET_IMAGE_INFO_ERR __ERR_STR(clGetImageInfo)
384 #define __GET_SAMPLER_INFO_ERR __ERR_STR(clGetSamplerInfo)
385 #define __GET_KERNEL_INFO_ERR __ERR_STR(clGetKernelInfo)
386 #if defined(CL_VERSION_1_2)
387 #define __GET_KERNEL_ARG_INFO_ERR __ERR_STR(clGetKernelArgInfo)
388 #endif // #if defined(CL_VERSION_1_2)
389 #define __GET_KERNEL_WORK_GROUP_INFO_ERR __ERR_STR(clGetKernelWorkGroupInfo)
390 #define __GET_PROGRAM_INFO_ERR __ERR_STR(clGetProgramInfo)
391 #define __GET_PROGRAM_BUILD_INFO_ERR __ERR_STR(clGetProgramBuildInfo)
392 #define __GET_COMMAND_QUEUE_INFO_ERR __ERR_STR(clGetCommandQueueInfo)
394 #define __CREATE_CONTEXT_ERR __ERR_STR(clCreateContext)
395 #define __CREATE_CONTEXT_FROM_TYPE_ERR __ERR_STR(clCreateContextFromType)
396 #define __GET_SUPPORTED_IMAGE_FORMATS_ERR __ERR_STR(clGetSupportedImageFormats)
398 #define __CREATE_BUFFER_ERR __ERR_STR(clCreateBuffer)
399 #define __COPY_ERR __ERR_STR(cl::copy)
400 #define __CREATE_SUBBUFFER_ERR __ERR_STR(clCreateSubBuffer)
401 #define __CREATE_GL_BUFFER_ERR __ERR_STR(clCreateFromGLBuffer)
402 #define __CREATE_GL_RENDER_BUFFER_ERR __ERR_STR(clCreateFromGLBuffer)
403 #define __GET_GL_OBJECT_INFO_ERR __ERR_STR(clGetGLObjectInfo)
404 #if defined(CL_VERSION_1_2)
405 #define __CREATE_IMAGE_ERR __ERR_STR(clCreateImage)
406 #define __CREATE_GL_TEXTURE_ERR __ERR_STR(clCreateFromGLTexture)
407 #define __IMAGE_DIMENSION_ERR __ERR_STR(Incorrect image dimensions)
408 #endif // #if defined(CL_VERSION_1_2)
409 #define __CREATE_SAMPLER_ERR __ERR_STR(clCreateSampler)
410 #define __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR __ERR_STR(clSetMemObjectDestructorCallback)
412 #define __CREATE_USER_EVENT_ERR __ERR_STR(clCreateUserEvent)
413 #define __SET_USER_EVENT_STATUS_ERR __ERR_STR(clSetUserEventStatus)
414 #define __SET_EVENT_CALLBACK_ERR __ERR_STR(clSetEventCallback)
415 #define __WAIT_FOR_EVENTS_ERR __ERR_STR(clWaitForEvents)
417 #define __CREATE_KERNEL_ERR __ERR_STR(clCreateKernel)
418 #define __SET_KERNEL_ARGS_ERR __ERR_STR(clSetKernelArg)
419 #define __CREATE_PROGRAM_WITH_SOURCE_ERR __ERR_STR(clCreateProgramWithSource)
420 #define __CREATE_PROGRAM_WITH_BINARY_ERR __ERR_STR(clCreateProgramWithBinary)
421 #if defined(CL_VERSION_1_2)
422 #define __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR __ERR_STR(clCreateProgramWithBuiltInKernels)
423 #endif // #if defined(CL_VERSION_1_2)
424 #define __BUILD_PROGRAM_ERR __ERR_STR(clBuildProgram)
425 #if defined(CL_VERSION_1_2)
426 #define __COMPILE_PROGRAM_ERR __ERR_STR(clCompileProgram)
427 #define __LINK_PROGRAM_ERR __ERR_STR(clLinkProgram)
428 #endif // #if defined(CL_VERSION_1_2)
429 #define __CREATE_KERNELS_IN_PROGRAM_ERR __ERR_STR(clCreateKernelsInProgram)
431 #define __CREATE_COMMAND_QUEUE_ERR __ERR_STR(clCreateCommandQueue)
432 #define __SET_COMMAND_QUEUE_PROPERTY_ERR __ERR_STR(clSetCommandQueueProperty)
433 #define __ENQUEUE_READ_BUFFER_ERR __ERR_STR(clEnqueueReadBuffer)
434 #define __ENQUEUE_READ_BUFFER_RECT_ERR __ERR_STR(clEnqueueReadBufferRect)
435 #define __ENQUEUE_WRITE_BUFFER_ERR __ERR_STR(clEnqueueWriteBuffer)
436 #define __ENQUEUE_WRITE_BUFFER_RECT_ERR __ERR_STR(clEnqueueWriteBufferRect)
437 #define __ENQEUE_COPY_BUFFER_ERR __ERR_STR(clEnqueueCopyBuffer)
438 #define __ENQEUE_COPY_BUFFER_RECT_ERR __ERR_STR(clEnqueueCopyBufferRect)
439 #define __ENQUEUE_FILL_BUFFER_ERR __ERR_STR(clEnqueueFillBuffer)
440 #define __ENQUEUE_READ_IMAGE_ERR __ERR_STR(clEnqueueReadImage)
441 #define __ENQUEUE_WRITE_IMAGE_ERR __ERR_STR(clEnqueueWriteImage)
442 #define __ENQUEUE_COPY_IMAGE_ERR __ERR_STR(clEnqueueCopyImage)
443 #define __ENQUEUE_FILL_IMAGE_ERR __ERR_STR(clEnqueueFillImage)
444 #define __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR __ERR_STR(clEnqueueCopyImageToBuffer)
445 #define __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR __ERR_STR(clEnqueueCopyBufferToImage)
446 #define __ENQUEUE_MAP_BUFFER_ERR __ERR_STR(clEnqueueMapBuffer)
447 #define __ENQUEUE_MAP_IMAGE_ERR __ERR_STR(clEnqueueMapImage)
448 #define __ENQUEUE_UNMAP_MEM_OBJECT_ERR __ERR_STR(clEnqueueUnMapMemObject)
449 #define __ENQUEUE_NDRANGE_KERNEL_ERR __ERR_STR(clEnqueueNDRangeKernel)
450 #define __ENQUEUE_TASK_ERR __ERR_STR(clEnqueueTask)
451 #define __ENQUEUE_NATIVE_KERNEL __ERR_STR(clEnqueueNativeKernel)
452 #if defined(CL_VERSION_1_2)
453 #define __ENQUEUE_MIGRATE_MEM_OBJECTS_ERR __ERR_STR(clEnqueueMigrateMemObjects)
454 #endif // #if defined(CL_VERSION_1_2)
456 #define __ENQUEUE_ACQUIRE_GL_ERR __ERR_STR(clEnqueueAcquireGLObjects)
457 #define __ENQUEUE_RELEASE_GL_ERR __ERR_STR(clEnqueueReleaseGLObjects)
460 #define __RETAIN_ERR __ERR_STR(Retain Object)
461 #define __RELEASE_ERR __ERR_STR(Release Object)
462 #define __FLUSH_ERR __ERR_STR(clFlush)
463 #define __FINISH_ERR __ERR_STR(clFinish)
464 #define __VECTOR_CAPACITY_ERR __ERR_STR(Vector capacity error)
467 * CL 1.2 version that uses device fission.
469 #if defined(CL_VERSION_1_2)
470 #define __CREATE_SUB_DEVICES __ERR_STR(clCreateSubDevices)
472 #define __CREATE_SUB_DEVICES __ERR_STR(clCreateSubDevicesEXT)
473 #endif // #if defined(CL_VERSION_1_2)
476 * Deprecated APIs for 1.2
478 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) || (defined(CL_VERSION_1_1) && !defined(CL_VERSION_1_2))
479 #define __ENQUEUE_MARKER_ERR __ERR_STR(clEnqueueMarker)
480 #define __ENQUEUE_WAIT_FOR_EVENTS_ERR __ERR_STR(clEnqueueWaitForEvents)
481 #define __ENQUEUE_BARRIER_ERR __ERR_STR(clEnqueueBarrier)
482 #define __UNLOAD_COMPILER_ERR __ERR_STR(clUnloadCompiler)
483 #define __CREATE_GL_TEXTURE_2D_ERR __ERR_STR(clCreateFromGLTexture2D)
484 #define __CREATE_GL_TEXTURE_3D_ERR __ERR_STR(clCreateFromGLTexture3D)
485 #define __CREATE_IMAGE2D_ERR __ERR_STR(clCreateImage2D)
486 #define __CREATE_IMAGE3D_ERR __ERR_STR(clCreateImage3D)
487 #endif // #if defined(CL_VERSION_1_1)
489 #endif // __CL_USER_OVERRIDE_ERROR_STRINGS
493 * CL 1.2 marker and barrier commands
495 #if defined(CL_VERSION_1_2)
496 #define __ENQUEUE_MARKER_WAIT_LIST_ERR __ERR_STR(clEnqueueMarkerWithWaitList)
497 #define __ENQUEUE_BARRIER_WAIT_LIST_ERR __ERR_STR(clEnqueueBarrierWithWaitList)
498 #endif // #if defined(CL_VERSION_1_2)
500 #if !defined(__USE_DEV_STRING) && !defined(__NO_STD_STRING)
501 typedef std::string STRING_CLASS;
502 #elif !defined(__USE_DEV_STRING)
505 * \brief Simple string class, that provides a limited subset of std::string
506 * functionality but avoids many of the issues that come with that class.
508 * \note Deprecated. Please use std::string as default or
509 * re-define the string class to match the std::string
510 * interface by defining STRING_CLASS
512 class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED string
518 //! \brief Constructs an empty string, allocating no memory.
519 string(void) : size_(0), str_(NULL)
523 /*! \brief Constructs a string populated from an arbitrary value of
526 * An extra '\0' is added, in case none was contained in str.
528 * \param str the initial value of the string instance. Note that '\0'
529 * characters receive no special treatment. If NULL,
530 * the string is left empty, with a size of 0.
532 * \param size the number of characters to copy from str.
534 string(const char * str, ::size_t size) :
539 str_ = new char[size_+1];
541 memcpy(str_, str, size_ * sizeof(char));
550 /*! \brief Constructs a string populated from a null-terminated value.
552 * \param str the null-terminated initial value of the string instance.
553 * If NULL, the string is left empty, with a size of 0.
555 string(const char * str) :
560 size_= ::strlen(str);
563 str_ = new char[size_ + 1];
565 memcpy(str_, str, (size_ + 1) * sizeof(char));
570 void resize( ::size_t n )
583 char *newString = new char[n + 1];
584 ::size_t copySize = n;
591 memcpy(newString, str_, (copySize + 1) * sizeof(char));
593 if( copySize < size_ ) {
594 memset(newString + copySize, 0, size_ - copySize);
596 newString[size_] = '\0';
603 const char& operator[] ( ::size_t pos ) const
608 char& operator[] ( ::size_t pos )
613 /*! \brief Copies the value of another string to this one.
615 * \param rhs the string to copy.
617 * \returns a reference to the modified instance.
619 string& operator=(const string& rhs)
631 if (rhs.size_ == 0 || rhs.str_ == NULL) {
636 str_ = new char[rhs.size_ + 1];
640 memcpy(str_, rhs.str_, (size_ + 1) * sizeof(char));
650 /*! \brief Constructs a string by copying the value of another instance.
652 * \param rhs the string to copy.
654 string(const string& rhs) :
661 //! \brief Destructor - frees memory used to hold the current value.
668 //! \brief Queries the length of the string, excluding any added '\0's.
669 ::size_t size(void) const { return size_; }
671 //! \brief Queries the length of the string, excluding any added '\0's.
672 ::size_t length(void) const { return size(); }
674 /*! \brief Returns a pointer to the private copy held by this instance,
675 * or "" if empty/unset.
677 const char * c_str(void) const { return (str_) ? str_ : "";}
678 } CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
679 typedef cl::string STRING_CLASS;
680 #endif // #elif !defined(__USE_DEV_STRING)
682 #if !defined(__USE_DEV_VECTOR) && !defined(__NO_STD_VECTOR)
683 #define VECTOR_CLASS std::vector
684 #elif !defined(__USE_DEV_VECTOR)
685 #define VECTOR_CLASS cl::vector
687 #if !defined(__MAX_DEFAULT_VECTOR_SIZE)
688 #define __MAX_DEFAULT_VECTOR_SIZE 10
692 * \brief Fixed sized vector implementation that mirroring
694 * \note Deprecated. Please use std::vector as default or
695 * re-define the vector class to match the std::vector
696 * interface by defining VECTOR_CLASS
698 * \note Not recommended for use with custom objects as
699 * current implementation will construct N elements
701 * std::vector functionality.
702 * \brief Fixed sized vector compatible with std::vector.
705 * This differs from std::vector<> not just in memory allocation,
706 * but also in terms of when members are constructed, destroyed,
707 * and assigned instead of being copy constructed.
709 * \param T type of element contained in the vector.
711 * \param N maximum size of the vector.
713 template <typename T, unsigned int N = __MAX_DEFAULT_VECTOR_SIZE>
714 class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector
721 //! \brief Constructs an empty vector with no memory allocated.
723 size_(static_cast<unsigned int>(0))
726 //! \brief Deallocates the vector's memory and destroys all of its elements.
732 //! \brief Returns the number of elements currently contained.
733 unsigned int size(void) const
738 /*! \brief Empties the vector of all elements.
740 * This does not deallocate memory but will invoke destructors
741 * on contained elements.
750 /*! \brief Appends an element after the last valid element.
751 * Calling this on a vector that has reached capacity will throw an
752 * exception if exceptions are enabled.
754 void push_back (const T& x)
757 new (&data_[size_]) T(x);
760 detail::errHandler(CL_MEM_OBJECT_ALLOCATION_FAILURE, __VECTOR_CAPACITY_ERR);
764 /*! \brief Removes the last valid element from the vector.
765 * Calling this on an empty vector will throw an exception
766 * if exceptions are enabled.
774 detail::errHandler(CL_MEM_OBJECT_ALLOCATION_FAILURE, __VECTOR_CAPACITY_ERR);
778 /*! \brief Constructs with a value copied from another.
780 * \param vec the vector to copy.
782 vector(const vector<T, N>& vec) :
786 assign(vec.begin(), vec.end());
790 /*! \brief Constructs with a specified number of initial elements.
792 * \param size number of initial elements.
794 * \param val value of initial elements.
796 vector(unsigned int size, const T& val = T()) :
799 for (unsigned int i = 0; i < size; i++) {
804 /*! \brief Overwrites the current content with that copied from another
807 * \param rhs vector to copy.
809 * \returns a reference to this.
811 vector<T, N>& operator=(const vector<T, N>& rhs)
817 if (rhs.size_ != 0) {
818 assign(rhs.begin(), rhs.end());
826 /*! \brief Tests equality against another instance.
828 * \param vec the vector against which to compare.
830 bool operator==(vector<T,N> &vec)
832 if (size() != vec.size()) {
836 for( unsigned int i = 0; i < size(); ++i ) {
837 if( operator[](i) != vec[i] ) {
844 //! \brief Conversion operator to T*.
845 operator T* () { return data_; }
847 //! \brief Conversion operator to const T*.
848 operator const T* () const { return data_; }
850 //! \brief Tests whether this instance has any elements.
851 bool empty (void) const
856 //! \brief Returns the maximum number of elements this instance can hold.
857 unsigned int max_size (void) const
862 //! \brief Returns the maximum number of elements this instance can hold.
863 unsigned int capacity () const
868 //! \brief Resizes the vector to the given size
869 void resize(unsigned int newSize, T fill = T())
873 detail::errHandler(CL_MEM_OBJECT_ALLOCATION_FAILURE, __VECTOR_CAPACITY_ERR);
877 while (size_ < newSize)
879 new (&data_[size_]) T(fill);
882 while (size_ > newSize)
890 /*! \brief Returns a reference to a given element.
892 * \param index which element to access. *
894 * The caller is responsible for ensuring index is >= 0 and < size().
896 T& operator[](int index)
901 /*! \brief Returns a const reference to a given element.
903 * \param index which element to access.
906 * The caller is responsible for ensuring index is >= 0 and < size().
908 const T& operator[](int index) const
913 /*! \brief Assigns elements of the vector based on a source iterator range.
915 * \param start Beginning iterator of source range
916 * \param end Enditerator of source range
919 * Will throw an exception if exceptions are enabled and size exceeded.
922 void assign(I start, I end)
925 while(start != end) {
932 * \brief Const iterator class for vectors
937 const vector<T,N> *vec_;
941 * Internal iterator constructor to capture reference
942 * to the vector it iterates over rather than taking
943 * the vector by copy.
945 iterator (const vector<T,N> &vec, int index) :
962 iterator(const iterator& rhs) :
970 static iterator begin(const cl::vector<T,N> &vec)
977 static iterator end(const cl::vector<T,N> &vec)
979 iterator i(vec, vec.size());
984 bool operator==(iterator i)
986 return ((vec_ == i.vec_) &&
987 (index_ == i.index_));
990 bool operator!=(iterator i)
992 return (!(*this==i));
995 iterator& operator++()
1001 iterator operator++(int)
1003 iterator retVal(*this);
1008 iterator& operator--()
1014 iterator operator--(int)
1016 iterator retVal(*this);
1021 const T& operator *() const
1023 return (*vec_)[index_];
1027 iterator begin(void)
1029 return iterator::begin(*this);
1032 iterator begin(void) const
1034 return iterator::begin(*this);
1039 return iterator::end(*this);
1042 iterator end(void) const
1044 return iterator::end(*this);
1054 return data_[size_];
1057 const T& front(void) const
1062 const T& back(void) const
1064 return data_[size_-1];
1066 } CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
1067 #endif // #if !defined(__USE_DEV_VECTOR) && !defined(__NO_STD_VECTOR)
1074 #define __DEFAULT_NOT_INITIALIZED 1
1075 #define __DEFAULT_BEING_INITIALIZED 2
1076 #define __DEFAULT_INITIALIZED 4
1079 * Compare and exchange primitives are needed for handling of defaults
1082 #ifdef CL_HPP_CPP11_ATOMICS_SUPPORTED
1083 inline int compare_exchange(std::atomic<int> * dest, int exchange, int comparand)
1084 #else // !CL_HPP_CPP11_ATOMICS_SUPPORTED
1085 inline int compare_exchange(volatile int * dest, int exchange, int comparand)
1086 #endif // !CL_HPP_CPP11_ATOMICS_SUPPORTED
1088 #ifdef CL_HPP_CPP11_ATOMICS_SUPPORTED
1089 std::atomic_compare_exchange_strong(dest, &comparand, exchange);
1092 return (int)(_InterlockedCompareExchange(
1093 (volatile long*)dest,
1096 #else // !_MSC_VER && !CL_HPP_CPP11_ATOMICS_SUPPORTED
1097 return (__sync_val_compare_and_swap(
1101 #endif // !CL_HPP_CPP11_ATOMICS_SUPPORTED
1104 inline void fence() {
1105 #ifdef CL_HPP_CPP11_ATOMICS_SUPPORTED
1106 std::atomic_thread_fence(std::memory_order_seq_cst);
1107 #elif _MSC_VER // !CL_HPP_CPP11_ATOMICS_SUPPORTED
1108 _ReadWriteBarrier();
1109 #else // !_MSC_VER && !CL_HPP_CPP11_ATOMICS_SUPPORTED
1110 __sync_synchronize();
1111 #endif // !CL_HPP_CPP11_ATOMICS_SUPPORTED
1113 } // namespace detail
1116 /*! \brief class used to interface between C++ and
1117 * OpenCL C calls that require arrays of size_t values, whose
1118 * size is known statically.
1127 //! \brief Initialize size_t to all 0s
1130 for( int i = 0; i < N; ++i ) {
1135 ::size_t& operator[](int index)
1137 return data_[index];
1140 const ::size_t& operator[](int index) const
1142 return data_[index];
1145 //! \brief Conversion operator to T*.
1146 operator ::size_t* () { return data_; }
1148 //! \brief Conversion operator to const T*.
1149 operator const ::size_t* () const { return data_; }
1154 // Generic getInfoHelper. The final parameter is used to guide overload
1155 // resolution: the actual parameter passed is an int, which makes this
1156 // a worse conversion sequence than a specialization that declares the
1157 // parameter as an int.
1158 template<typename Functor, typename T>
1159 inline cl_int getInfoHelper(Functor f, cl_uint name, T* param, long)
1161 return f(name, sizeof(T), param, NULL);
1164 // Specialized getInfoHelper for VECTOR_CLASS params
1165 template <typename Func, typename T>
1166 inline cl_int getInfoHelper(Func f, cl_uint name, VECTOR_CLASS<T>* param, long)
1169 cl_int err = f(name, 0, NULL, &required);
1170 if (err != CL_SUCCESS) {
1174 T* value = (T*) alloca(required);
1175 err = f(name, required, value, NULL);
1176 if (err != CL_SUCCESS) {
1180 param->assign(&value[0], &value[required/sizeof(T)]);
1184 /* Specialization for reference-counted types. This depends on the
1185 * existence of Wrapper<T>::cl_type, and none of the other types having the
1186 * cl_type member. Note that simplify specifying the parameter as Wrapper<T>
1187 * does not work, because when using a derived type (e.g. Context) the generic
1188 * template will provide a better match.
1190 template <typename Func, typename T>
1191 inline cl_int getInfoHelper(Func f, cl_uint name, VECTOR_CLASS<T>* param, int, typename T::cl_type = 0)
1194 cl_int err = f(name, 0, NULL, &required);
1195 if (err != CL_SUCCESS) {
1199 typename T::cl_type * value = (typename T::cl_type *) alloca(required);
1200 err = f(name, required, value, NULL);
1201 if (err != CL_SUCCESS) {
1205 ::size_t elements = required / sizeof(typename T::cl_type);
1206 param->assign(&value[0], &value[elements]);
1207 for (::size_t i = 0; i < elements; i++)
1209 if (value[i] != NULL)
1211 err = (*param)[i].retain();
1212 if (err != CL_SUCCESS) {
1220 // Specialized for getInfo<CL_PROGRAM_BINARIES>
1221 template <typename Func>
1222 inline cl_int getInfoHelper(Func f, cl_uint name, VECTOR_CLASS<char *>* param, int)
1224 cl_int err = f(name, param->size() * sizeof(char *), &(*param)[0], NULL);
1226 if (err != CL_SUCCESS) {
1233 // Specialized GetInfoHelper for STRING_CLASS params
1234 template <typename Func>
1235 inline cl_int getInfoHelper(Func f, cl_uint name, STRING_CLASS* param, long)
1237 #if defined(__NO_STD_VECTOR) || defined(__NO_STD_STRING)
1239 cl_int err = f(name, 0, NULL, &required);
1240 if (err != CL_SUCCESS) {
1244 char* value = (char*)alloca(required);
1245 err = f(name, required, value, NULL);
1246 if (err != CL_SUCCESS) {
1254 cl_int err = f(name, 0, NULL, &required);
1255 if (err != CL_SUCCESS) {
1260 // std::string has a constant data member
1261 // a char vector does not
1262 VECTOR_CLASS<char> value(required);
1263 err = f(name, required, value.data(), NULL);
1264 if (err != CL_SUCCESS) {
1268 param->assign(value.begin(), value.end() - 1u);
1278 // Specialized GetInfoHelper for cl::size_t params
1279 template <typename Func, ::size_t N>
1280 inline cl_int getInfoHelper(Func f, cl_uint name, size_t<N>* param, long)
1283 cl_int err = f(name, 0, NULL, &required);
1284 if (err != CL_SUCCESS) {
1288 ::size_t* value = (::size_t*) alloca(required);
1289 err = f(name, required, value, NULL);
1290 if (err != CL_SUCCESS) {
1294 for(int i = 0; i < N; ++i) {
1295 (*param)[i] = value[i];
1301 template<typename T> struct ReferenceHandler;
1303 /* Specialization for reference-counted types. This depends on the
1304 * existence of Wrapper<T>::cl_type, and none of the other types having the
1305 * cl_type member. Note that simplify specifying the parameter as Wrapper<T>
1306 * does not work, because when using a derived type (e.g. Context) the generic
1307 * template will provide a better match.
1309 template<typename Func, typename T>
1310 inline cl_int getInfoHelper(Func f, cl_uint name, T* param, int, typename T::cl_type = 0)
1312 typename T::cl_type value;
1313 cl_int err = f(name, sizeof(value), &value, NULL);
1314 if (err != CL_SUCCESS) {
1320 err = param->retain();
1321 if (err != CL_SUCCESS) {
1328 #define __PARAM_NAME_INFO_1_0(F) \
1329 F(cl_platform_info, CL_PLATFORM_PROFILE, STRING_CLASS) \
1330 F(cl_platform_info, CL_PLATFORM_VERSION, STRING_CLASS) \
1331 F(cl_platform_info, CL_PLATFORM_NAME, STRING_CLASS) \
1332 F(cl_platform_info, CL_PLATFORM_VENDOR, STRING_CLASS) \
1333 F(cl_platform_info, CL_PLATFORM_EXTENSIONS, STRING_CLASS) \
1335 F(cl_device_info, CL_DEVICE_TYPE, cl_device_type) \
1336 F(cl_device_info, CL_DEVICE_VENDOR_ID, cl_uint) \
1337 F(cl_device_info, CL_DEVICE_MAX_COMPUTE_UNITS, cl_uint) \
1338 F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, cl_uint) \
1339 F(cl_device_info, CL_DEVICE_MAX_WORK_GROUP_SIZE, ::size_t) \
1340 F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_SIZES, VECTOR_CLASS< ::size_t>) \
1341 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, cl_uint) \
1342 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT, cl_uint) \
1343 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT, cl_uint) \
1344 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG, cl_uint) \
1345 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT, cl_uint) \
1346 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, cl_uint) \
1347 F(cl_device_info, CL_DEVICE_MAX_CLOCK_FREQUENCY, cl_uint) \
1348 F(cl_device_info, CL_DEVICE_ADDRESS_BITS, cl_uint) \
1349 F(cl_device_info, CL_DEVICE_MAX_READ_IMAGE_ARGS, cl_uint) \
1350 F(cl_device_info, CL_DEVICE_MAX_WRITE_IMAGE_ARGS, cl_uint) \
1351 F(cl_device_info, CL_DEVICE_MAX_MEM_ALLOC_SIZE, cl_ulong) \
1352 F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_WIDTH, ::size_t) \
1353 F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_HEIGHT, ::size_t) \
1354 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_WIDTH, ::size_t) \
1355 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_HEIGHT, ::size_t) \
1356 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_DEPTH, ::size_t) \
1357 F(cl_device_info, CL_DEVICE_IMAGE_SUPPORT, cl_bool) \
1358 F(cl_device_info, CL_DEVICE_MAX_PARAMETER_SIZE, ::size_t) \
1359 F(cl_device_info, CL_DEVICE_MAX_SAMPLERS, cl_uint) \
1360 F(cl_device_info, CL_DEVICE_MEM_BASE_ADDR_ALIGN, cl_uint) \
1361 F(cl_device_info, CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE, cl_uint) \
1362 F(cl_device_info, CL_DEVICE_SINGLE_FP_CONFIG, cl_device_fp_config) \
1363 F(cl_device_info, CL_DEVICE_DOUBLE_FP_CONFIG, cl_device_fp_config) \
1364 F(cl_device_info, CL_DEVICE_HALF_FP_CONFIG, cl_device_fp_config) \
1365 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_TYPE, cl_device_mem_cache_type) \
1366 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE, cl_uint)\
1367 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_SIZE, cl_ulong) \
1368 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_SIZE, cl_ulong) \
1369 F(cl_device_info, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE, cl_ulong) \
1370 F(cl_device_info, CL_DEVICE_MAX_CONSTANT_ARGS, cl_uint) \
1371 F(cl_device_info, CL_DEVICE_LOCAL_MEM_TYPE, cl_device_local_mem_type) \
1372 F(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE, cl_ulong) \
1373 F(cl_device_info, CL_DEVICE_ERROR_CORRECTION_SUPPORT, cl_bool) \
1374 F(cl_device_info, CL_DEVICE_PROFILING_TIMER_RESOLUTION, ::size_t) \
1375 F(cl_device_info, CL_DEVICE_ENDIAN_LITTLE, cl_bool) \
1376 F(cl_device_info, CL_DEVICE_AVAILABLE, cl_bool) \
1377 F(cl_device_info, CL_DEVICE_COMPILER_AVAILABLE, cl_bool) \
1378 F(cl_device_info, CL_DEVICE_EXECUTION_CAPABILITIES, cl_device_exec_capabilities) \
1379 F(cl_device_info, CL_DEVICE_QUEUE_PROPERTIES, cl_command_queue_properties) \
1380 F(cl_device_info, CL_DEVICE_PLATFORM, cl_platform_id) \
1381 F(cl_device_info, CL_DEVICE_NAME, STRING_CLASS) \
1382 F(cl_device_info, CL_DEVICE_VENDOR, STRING_CLASS) \
1383 F(cl_device_info, CL_DRIVER_VERSION, STRING_CLASS) \
1384 F(cl_device_info, CL_DEVICE_PROFILE, STRING_CLASS) \
1385 F(cl_device_info, CL_DEVICE_VERSION, STRING_CLASS) \
1386 F(cl_device_info, CL_DEVICE_EXTENSIONS, STRING_CLASS) \
1388 F(cl_context_info, CL_CONTEXT_REFERENCE_COUNT, cl_uint) \
1389 F(cl_context_info, CL_CONTEXT_DEVICES, VECTOR_CLASS<Device>) \
1390 F(cl_context_info, CL_CONTEXT_PROPERTIES, VECTOR_CLASS<cl_context_properties>) \
1392 F(cl_event_info, CL_EVENT_COMMAND_QUEUE, cl::CommandQueue) \
1393 F(cl_event_info, CL_EVENT_COMMAND_TYPE, cl_command_type) \
1394 F(cl_event_info, CL_EVENT_REFERENCE_COUNT, cl_uint) \
1395 F(cl_event_info, CL_EVENT_COMMAND_EXECUTION_STATUS, cl_int) \
1397 F(cl_profiling_info, CL_PROFILING_COMMAND_QUEUED, cl_ulong) \
1398 F(cl_profiling_info, CL_PROFILING_COMMAND_SUBMIT, cl_ulong) \
1399 F(cl_profiling_info, CL_PROFILING_COMMAND_START, cl_ulong) \
1400 F(cl_profiling_info, CL_PROFILING_COMMAND_END, cl_ulong) \
1402 F(cl_mem_info, CL_MEM_TYPE, cl_mem_object_type) \
1403 F(cl_mem_info, CL_MEM_FLAGS, cl_mem_flags) \
1404 F(cl_mem_info, CL_MEM_SIZE, ::size_t) \
1405 F(cl_mem_info, CL_MEM_HOST_PTR, void*) \
1406 F(cl_mem_info, CL_MEM_MAP_COUNT, cl_uint) \
1407 F(cl_mem_info, CL_MEM_REFERENCE_COUNT, cl_uint) \
1408 F(cl_mem_info, CL_MEM_CONTEXT, cl::Context) \
1410 F(cl_image_info, CL_IMAGE_FORMAT, cl_image_format) \
1411 F(cl_image_info, CL_IMAGE_ELEMENT_SIZE, ::size_t) \
1412 F(cl_image_info, CL_IMAGE_ROW_PITCH, ::size_t) \
1413 F(cl_image_info, CL_IMAGE_SLICE_PITCH, ::size_t) \
1414 F(cl_image_info, CL_IMAGE_WIDTH, ::size_t) \
1415 F(cl_image_info, CL_IMAGE_HEIGHT, ::size_t) \
1416 F(cl_image_info, CL_IMAGE_DEPTH, ::size_t) \
1418 F(cl_sampler_info, CL_SAMPLER_REFERENCE_COUNT, cl_uint) \
1419 F(cl_sampler_info, CL_SAMPLER_CONTEXT, cl::Context) \
1420 F(cl_sampler_info, CL_SAMPLER_NORMALIZED_COORDS, cl_bool) \
1421 F(cl_sampler_info, CL_SAMPLER_ADDRESSING_MODE, cl_addressing_mode) \
1422 F(cl_sampler_info, CL_SAMPLER_FILTER_MODE, cl_filter_mode) \
1424 F(cl_program_info, CL_PROGRAM_REFERENCE_COUNT, cl_uint) \
1425 F(cl_program_info, CL_PROGRAM_CONTEXT, cl::Context) \
1426 F(cl_program_info, CL_PROGRAM_NUM_DEVICES, cl_uint) \
1427 F(cl_program_info, CL_PROGRAM_DEVICES, VECTOR_CLASS<Device>) \
1428 F(cl_program_info, CL_PROGRAM_SOURCE, STRING_CLASS) \
1429 F(cl_program_info, CL_PROGRAM_BINARY_SIZES, VECTOR_CLASS< ::size_t>) \
1430 F(cl_program_info, CL_PROGRAM_BINARIES, VECTOR_CLASS<char *>) \
1432 F(cl_program_build_info, CL_PROGRAM_BUILD_STATUS, cl_build_status) \
1433 F(cl_program_build_info, CL_PROGRAM_BUILD_OPTIONS, STRING_CLASS) \
1434 F(cl_program_build_info, CL_PROGRAM_BUILD_LOG, STRING_CLASS) \
1436 F(cl_kernel_info, CL_KERNEL_FUNCTION_NAME, STRING_CLASS) \
1437 F(cl_kernel_info, CL_KERNEL_NUM_ARGS, cl_uint) \
1438 F(cl_kernel_info, CL_KERNEL_REFERENCE_COUNT, cl_uint) \
1439 F(cl_kernel_info, CL_KERNEL_CONTEXT, cl::Context) \
1440 F(cl_kernel_info, CL_KERNEL_PROGRAM, cl::Program) \
1442 F(cl_kernel_work_group_info, CL_KERNEL_WORK_GROUP_SIZE, ::size_t) \
1443 F(cl_kernel_work_group_info, CL_KERNEL_COMPILE_WORK_GROUP_SIZE, cl::size_t<3>) \
1444 F(cl_kernel_work_group_info, CL_KERNEL_LOCAL_MEM_SIZE, cl_ulong) \
1446 F(cl_command_queue_info, CL_QUEUE_CONTEXT, cl::Context) \
1447 F(cl_command_queue_info, CL_QUEUE_DEVICE, cl::Device) \
1448 F(cl_command_queue_info, CL_QUEUE_REFERENCE_COUNT, cl_uint) \
1449 F(cl_command_queue_info, CL_QUEUE_PROPERTIES, cl_command_queue_properties)
1451 #if defined(CL_VERSION_1_1)
1452 #define __PARAM_NAME_INFO_1_1(F) \
1453 F(cl_context_info, CL_CONTEXT_NUM_DEVICES, cl_uint)\
1454 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF, cl_uint) \
1455 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR, cl_uint) \
1456 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT, cl_uint) \
1457 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_INT, cl_uint) \
1458 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG, cl_uint) \
1459 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT, cl_uint) \
1460 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE, cl_uint) \
1461 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF, cl_uint) \
1462 F(cl_device_info, CL_DEVICE_HOST_UNIFIED_MEMORY, cl_bool) \
1463 F(cl_device_info, CL_DEVICE_OPENCL_C_VERSION, STRING_CLASS) \
1465 F(cl_mem_info, CL_MEM_ASSOCIATED_MEMOBJECT, cl::Memory) \
1466 F(cl_mem_info, CL_MEM_OFFSET, ::size_t) \
1468 F(cl_kernel_work_group_info, CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, ::size_t) \
1469 F(cl_kernel_work_group_info, CL_KERNEL_PRIVATE_MEM_SIZE, cl_ulong) \
1471 F(cl_event_info, CL_EVENT_CONTEXT, cl::Context)
1472 #endif // CL_VERSION_1_1
1475 #if defined(CL_VERSION_1_2)
1476 #define __PARAM_NAME_INFO_1_2(F) \
1477 F(cl_image_info, CL_IMAGE_ARRAY_SIZE, ::size_t) \
1478 F(cl_image_info, CL_IMAGE_BUFFER, cl::Buffer) \
1479 F(cl_image_info, CL_IMAGE_NUM_MIP_LEVELS, cl_uint) \
1480 F(cl_image_info, CL_IMAGE_NUM_SAMPLES, cl_uint) \
1482 F(cl_program_info, CL_PROGRAM_NUM_KERNELS, ::size_t) \
1483 F(cl_program_info, CL_PROGRAM_KERNEL_NAMES, STRING_CLASS) \
1485 F(cl_program_build_info, CL_PROGRAM_BINARY_TYPE, cl_program_binary_type) \
1487 F(cl_kernel_info, CL_KERNEL_ATTRIBUTES, STRING_CLASS) \
1489 F(cl_kernel_arg_info, CL_KERNEL_ARG_ADDRESS_QUALIFIER, cl_kernel_arg_address_qualifier) \
1490 F(cl_kernel_arg_info, CL_KERNEL_ARG_ACCESS_QUALIFIER, cl_kernel_arg_access_qualifier) \
1491 F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_NAME, STRING_CLASS) \
1492 F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_QUALIFIER, cl_kernel_arg_type_qualifier) \
1493 F(cl_kernel_arg_info, CL_KERNEL_ARG_NAME, STRING_CLASS) \
1495 F(cl_device_info, CL_DEVICE_IMAGE_MAX_BUFFER_SIZE, ::size_t) \
1496 F(cl_device_info, CL_DEVICE_IMAGE_MAX_ARRAY_SIZE, ::size_t) \
1497 F(cl_device_info, CL_DEVICE_LINKER_AVAILABLE, cl_bool) \
1498 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS, STRING_CLASS) \
1499 F(cl_device_info, CL_DEVICE_PRINTF_BUFFER_SIZE, ::size_t) \
1500 F(cl_device_info, CL_DEVICE_PREFERRED_INTEROP_USER_SYNC, cl_bool) \
1501 F(cl_device_info, CL_DEVICE_PARENT_DEVICE, cl_device_id) \
1502 F(cl_device_info, CL_DEVICE_PARTITION_MAX_SUB_DEVICES, cl_uint) \
1503 F(cl_device_info, CL_DEVICE_PARTITION_PROPERTIES, VECTOR_CLASS<cl_device_partition_property>) \
1504 F(cl_device_info, CL_DEVICE_PARTITION_AFFINITY_DOMAIN, cl_device_affinity_domain) \
1505 F(cl_device_info, CL_DEVICE_PARTITION_TYPE, VECTOR_CLASS<cl_device_partition_property>) \
1506 F(cl_device_info, CL_DEVICE_REFERENCE_COUNT, cl_uint)
1507 #endif // #if defined(CL_VERSION_1_2)
1509 #if defined(USE_CL_DEVICE_FISSION)
1510 #define __PARAM_NAME_DEVICE_FISSION(F) \
1511 F(cl_device_info, CL_DEVICE_PARENT_DEVICE_EXT, cl_device_id) \
1512 F(cl_device_info, CL_DEVICE_PARTITION_TYPES_EXT, VECTOR_CLASS<cl_device_partition_property_ext>) \
1513 F(cl_device_info, CL_DEVICE_AFFINITY_DOMAINS_EXT, VECTOR_CLASS<cl_device_partition_property_ext>) \
1514 F(cl_device_info, CL_DEVICE_REFERENCE_COUNT_EXT , cl_uint) \
1515 F(cl_device_info, CL_DEVICE_PARTITION_STYLE_EXT, VECTOR_CLASS<cl_device_partition_property_ext>)
1516 #endif // USE_CL_DEVICE_FISSION
1518 template <typename enum_type, cl_int Name>
1519 struct param_traits {};
1521 #define __CL_DECLARE_PARAM_TRAITS(token, param_name, T) \
1524 struct param_traits<detail:: token,param_name> \
1526 enum { value = param_name }; \
1527 typedef T param_type; \
1530 __PARAM_NAME_INFO_1_0(__CL_DECLARE_PARAM_TRAITS)
1531 #if defined(CL_VERSION_1_1)
1532 __PARAM_NAME_INFO_1_1(__CL_DECLARE_PARAM_TRAITS)
1533 #endif // CL_VERSION_1_1
1534 #if defined(CL_VERSION_1_2)
1535 __PARAM_NAME_INFO_1_2(__CL_DECLARE_PARAM_TRAITS)
1536 #endif // CL_VERSION_1_1
1538 #if defined(USE_CL_DEVICE_FISSION)
1539 __PARAM_NAME_DEVICE_FISSION(__CL_DECLARE_PARAM_TRAITS);
1540 #endif // USE_CL_DEVICE_FISSION
1542 #ifdef CL_PLATFORM_ICD_SUFFIX_KHR
1543 __CL_DECLARE_PARAM_TRAITS(cl_platform_info, CL_PLATFORM_ICD_SUFFIX_KHR, STRING_CLASS)
1546 #ifdef CL_DEVICE_PROFILING_TIMER_OFFSET_AMD
1547 __CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_PROFILING_TIMER_OFFSET_AMD, cl_ulong)
1550 #ifdef CL_DEVICE_GLOBAL_FREE_MEMORY_AMD
1551 __CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_GLOBAL_FREE_MEMORY_AMD, VECTOR_CLASS< ::size_t>)
1553 #ifdef CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD
1554 __CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD, cl_uint)
1556 #ifdef CL_DEVICE_SIMD_WIDTH_AMD
1557 __CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_SIMD_WIDTH_AMD, cl_uint)
1559 #ifdef CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD
1560 __CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD, cl_uint)
1562 #ifdef CL_DEVICE_WAVEFRONT_WIDTH_AMD
1563 __CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_WAVEFRONT_WIDTH_AMD, cl_uint)
1565 #ifdef CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD
1566 __CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD, cl_uint)
1568 #ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD
1569 __CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD, cl_uint)
1571 #ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD
1572 __CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD, cl_uint)
1574 #ifdef CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD
1575 __CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD, cl_uint)
1577 #ifdef CL_DEVICE_LOCAL_MEM_BANKS_AMD
1578 __CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_LOCAL_MEM_BANKS_AMD, cl_uint)
1581 #ifdef CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV
1582 __CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV, cl_uint)
1584 #ifdef CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV
1585 __CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV, cl_uint)
1587 #ifdef CL_DEVICE_REGISTERS_PER_BLOCK_NV
1588 __CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_REGISTERS_PER_BLOCK_NV, cl_uint)
1590 #ifdef CL_DEVICE_WARP_SIZE_NV
1591 __CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_WARP_SIZE_NV, cl_uint)
1593 #ifdef CL_DEVICE_GPU_OVERLAP_NV
1594 __CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_GPU_OVERLAP_NV, cl_bool)
1596 #ifdef CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV
1597 __CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV, cl_bool)
1599 #ifdef CL_DEVICE_INTEGRATED_MEMORY_NV
1600 __CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_INTEGRATED_MEMORY_NV, cl_bool)
1603 // Convenience functions
1605 template <typename Func, typename T>
1607 getInfo(Func f, cl_uint name, T* param)
1609 return getInfoHelper(f, name, param, 0);
1612 template <typename Func, typename Arg0>
1613 struct GetInfoFunctor0
1615 Func f_; const Arg0& arg0_;
1617 cl_uint param, ::size_t size, void* value, ::size_t* size_ret)
1618 { return f_(arg0_, param, size, value, size_ret); }
1621 template <typename Func, typename Arg0, typename Arg1>
1622 struct GetInfoFunctor1
1624 Func f_; const Arg0& arg0_; const Arg1& arg1_;
1626 cl_uint param, ::size_t size, void* value, ::size_t* size_ret)
1627 { return f_(arg0_, arg1_, param, size, value, size_ret); }
1630 template <typename Func, typename Arg0, typename T>
1632 getInfo(Func f, const Arg0& arg0, cl_uint name, T* param)
1634 GetInfoFunctor0<Func, Arg0> f0 = { f, arg0 };
1635 return getInfoHelper(f0, name, param, 0);
1638 template <typename Func, typename Arg0, typename Arg1, typename T>
1640 getInfo(Func f, const Arg0& arg0, const Arg1& arg1, cl_uint name, T* param)
1642 GetInfoFunctor1<Func, Arg0, Arg1> f0 = { f, arg0, arg1 };
1643 return getInfoHelper(f0, name, param, 0);
1646 template<typename T>
1647 struct ReferenceHandler
1650 #if defined(CL_VERSION_1_2)
1652 * OpenCL 1.2 devices do have retain/release.
1655 struct ReferenceHandler<cl_device_id>
1658 * Retain the device.
1659 * \param device A valid device created using createSubDevices
1661 * CL_SUCCESS if the function executed successfully.
1662 * CL_INVALID_DEVICE if device was not a valid subdevice
1663 * CL_OUT_OF_RESOURCES
1664 * CL_OUT_OF_HOST_MEMORY
1666 static cl_int retain(cl_device_id device)
1667 { return ::clRetainDevice(device); }
1669 * Retain the device.
1670 * \param device A valid device created using createSubDevices
1672 * CL_SUCCESS if the function executed successfully.
1673 * CL_INVALID_DEVICE if device was not a valid subdevice
1674 * CL_OUT_OF_RESOURCES
1675 * CL_OUT_OF_HOST_MEMORY
1677 static cl_int release(cl_device_id device)
1678 { return ::clReleaseDevice(device); }
1680 #else // #if defined(CL_VERSION_1_2)
1682 * OpenCL 1.1 devices do not have retain/release.
1685 struct ReferenceHandler<cl_device_id>
1687 // cl_device_id does not have retain().
1688 static cl_int retain(cl_device_id)
1689 { return CL_SUCCESS; }
1690 // cl_device_id does not have release().
1691 static cl_int release(cl_device_id)
1692 { return CL_SUCCESS; }
1694 #endif // #if defined(CL_VERSION_1_2)
1697 struct ReferenceHandler<cl_platform_id>
1699 // cl_platform_id does not have retain().
1700 static cl_int retain(cl_platform_id)
1701 { return CL_SUCCESS; }
1702 // cl_platform_id does not have release().
1703 static cl_int release(cl_platform_id)
1704 { return CL_SUCCESS; }
1708 struct ReferenceHandler<cl_context>
1710 static cl_int retain(cl_context context)
1711 { return ::clRetainContext(context); }
1712 static cl_int release(cl_context context)
1713 { return ::clReleaseContext(context); }
1717 struct ReferenceHandler<cl_command_queue>
1719 static cl_int retain(cl_command_queue queue)
1720 { return ::clRetainCommandQueue(queue); }
1721 static cl_int release(cl_command_queue queue)
1722 { return ::clReleaseCommandQueue(queue); }
1726 struct ReferenceHandler<cl_mem>
1728 static cl_int retain(cl_mem memory)
1729 { return ::clRetainMemObject(memory); }
1730 static cl_int release(cl_mem memory)
1731 { return ::clReleaseMemObject(memory); }
1735 struct ReferenceHandler<cl_sampler>
1737 static cl_int retain(cl_sampler sampler)
1738 { return ::clRetainSampler(sampler); }
1739 static cl_int release(cl_sampler sampler)
1740 { return ::clReleaseSampler(sampler); }
1744 struct ReferenceHandler<cl_program>
1746 static cl_int retain(cl_program program)
1747 { return ::clRetainProgram(program); }
1748 static cl_int release(cl_program program)
1749 { return ::clReleaseProgram(program); }
1753 struct ReferenceHandler<cl_kernel>
1755 static cl_int retain(cl_kernel kernel)
1756 { return ::clRetainKernel(kernel); }
1757 static cl_int release(cl_kernel kernel)
1758 { return ::clReleaseKernel(kernel); }
1762 struct ReferenceHandler<cl_event>
1764 static cl_int retain(cl_event event)
1765 { return ::clRetainEvent(event); }
1766 static cl_int release(cl_event event)
1767 { return ::clReleaseEvent(event); }
1771 // Extracts version number with major in the upper 16 bits, minor in the lower 16
1772 static cl_uint getVersion(const char *versionInfo)
1774 int highVersion = 0;
1777 while(versionInfo[index] != '.' ) {
1779 highVersion += versionInfo[index]-'0';
1783 while(versionInfo[index] != ' ' && versionInfo[index] != '\0') {
1785 lowVersion += versionInfo[index]-'0';
1788 return (highVersion << 16) | lowVersion;
1791 static cl_uint getPlatformVersion(cl_platform_id platform)
1794 clGetPlatformInfo(platform, CL_PLATFORM_VERSION, 0, NULL, &size);
1795 char *versionInfo = (char *) alloca(size);
1796 clGetPlatformInfo(platform, CL_PLATFORM_VERSION, size, &versionInfo[0], &size);
1797 return getVersion(versionInfo);
1800 static cl_uint getDevicePlatformVersion(cl_device_id device)
1802 cl_platform_id platform;
1803 clGetDeviceInfo(device, CL_DEVICE_PLATFORM, sizeof(platform), &platform, NULL);
1804 return getPlatformVersion(platform);
1807 #if defined(CL_VERSION_1_2) && defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
1808 static cl_uint getContextPlatformVersion(cl_context context)
1810 // The platform cannot be queried directly, so we first have to grab a
1811 // device and obtain its context
1813 clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, NULL, &size);
1816 cl_device_id *devices = (cl_device_id *) alloca(size);
1817 clGetContextInfo(context, CL_CONTEXT_DEVICES, size, devices, NULL);
1818 return getDevicePlatformVersion(devices[0]);
1820 #endif // #if defined(CL_VERSION_1_2) && defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
1822 template <typename T>
1832 Wrapper() : object_(NULL) { }
1834 Wrapper(const cl_type &obj) : object_(obj) { }
1838 if (object_ != NULL) { release(); }
1841 Wrapper(const Wrapper<cl_type>& rhs)
1843 object_ = rhs.object_;
1844 if (object_ != NULL) { detail::errHandler(retain(), __RETAIN_ERR); }
1847 #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
1848 Wrapper(Wrapper<cl_type>&& rhs) CL_HPP_NOEXCEPT
1850 object_ = rhs.object_;
1855 Wrapper<cl_type>& operator = (const Wrapper<cl_type>& rhs)
1858 if (object_ != NULL) { detail::errHandler(release(), __RELEASE_ERR); }
1859 object_ = rhs.object_;
1860 if (object_ != NULL) { detail::errHandler(retain(), __RETAIN_ERR); }
1865 #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
1866 Wrapper<cl_type>& operator = (Wrapper<cl_type>&& rhs)
1869 if (object_ != NULL) { detail::errHandler(release(), __RELEASE_ERR); }
1870 object_ = rhs.object_;
1877 Wrapper<cl_type>& operator = (const cl_type &rhs)
1879 if (object_ != NULL) { detail::errHandler(release(), __RELEASE_ERR); }
1884 cl_type operator ()() const { return object_; }
1886 cl_type& operator ()() { return object_; }
1889 template<typename Func, typename U>
1890 friend inline cl_int getInfoHelper(Func, cl_uint, U*, int, typename U::cl_type);
1892 cl_int retain() const
1894 return ReferenceHandler<cl_type>::retain(object_);
1897 cl_int release() const
1899 return ReferenceHandler<cl_type>::release(object_);
1904 class Wrapper<cl_device_id>
1907 typedef cl_device_id cl_type;
1911 bool referenceCountable_;
1913 static bool isReferenceCountable(cl_device_id device)
1915 bool retVal = false;
1916 if (device != NULL) {
1917 int version = getDevicePlatformVersion(device);
1918 if(version > ((1 << 16) + 1)) {
1926 Wrapper() : object_(NULL), referenceCountable_(false)
1930 Wrapper(const cl_type &obj) : object_(obj), referenceCountable_(false)
1932 referenceCountable_ = isReferenceCountable(obj);
1937 if (object_ != NULL) { release(); }
1940 Wrapper(const Wrapper<cl_type>& rhs)
1942 object_ = rhs.object_;
1943 referenceCountable_ = isReferenceCountable(object_);
1944 if (object_ != NULL) { detail::errHandler(retain(), __RETAIN_ERR); }
1947 #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
1948 Wrapper(Wrapper<cl_type>&& rhs) CL_HPP_NOEXCEPT
1950 object_ = rhs.object_;
1951 referenceCountable_ = rhs.referenceCountable_;
1953 rhs.referenceCountable_ = false;
1957 Wrapper<cl_type>& operator = (const Wrapper<cl_type>& rhs)
1960 if (object_ != NULL) { detail::errHandler(release(), __RELEASE_ERR); }
1961 object_ = rhs.object_;
1962 referenceCountable_ = rhs.referenceCountable_;
1963 if (object_ != NULL) { detail::errHandler(retain(), __RETAIN_ERR); }
1968 #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
1969 Wrapper<cl_type>& operator = (Wrapper<cl_type>&& rhs)
1972 if (object_ != NULL) { detail::errHandler(release(), __RELEASE_ERR); }
1973 object_ = rhs.object_;
1974 referenceCountable_ = rhs.referenceCountable_;
1976 rhs.referenceCountable_ = false;
1982 Wrapper<cl_type>& operator = (const cl_type &rhs)
1984 if (object_ != NULL) { detail::errHandler(release(), __RELEASE_ERR); }
1986 referenceCountable_ = isReferenceCountable(object_);
1990 cl_type operator ()() const { return object_; }
1992 cl_type& operator ()() { return object_; }
1995 template<typename Func, typename U>
1996 friend inline cl_int getInfoHelper(Func, cl_uint, U*, int, typename U::cl_type);
1998 template<typename Func, typename U>
1999 friend inline cl_int getInfoHelper(Func, cl_uint, VECTOR_CLASS<U>*, int, typename U::cl_type);
2001 cl_int retain() const
2003 if( referenceCountable_ ) {
2004 return ReferenceHandler<cl_type>::retain(object_);
2011 cl_int release() const
2013 if( referenceCountable_ ) {
2014 return ReferenceHandler<cl_type>::release(object_);
2022 } // namespace detail
2025 /*! \stuct ImageFormat
2026 * \brief Adds constructors and member functions for cl_image_format.
2028 * \see cl_image_format
2030 struct ImageFormat : public cl_image_format
2032 //! \brief Default constructor - performs no initialization.
2035 //! \brief Initializing constructor.
2036 ImageFormat(cl_channel_order order, cl_channel_type type)
2038 image_channel_order = order;
2039 image_channel_data_type = type;
2042 //! \brief Assignment operator.
2043 ImageFormat& operator = (const ImageFormat& rhs)
2046 this->image_channel_data_type = rhs.image_channel_data_type;
2047 this->image_channel_order = rhs.image_channel_order;
2053 /*! \brief Class interface for cl_device_id.
2055 * \note Copies of these objects are inexpensive, since they don't 'own'
2056 * any underlying resources or data structures.
2060 class Device : public detail::Wrapper<cl_device_id>
2063 //! \brief Default constructor - initializes to NULL.
2064 Device() : detail::Wrapper<cl_type>() { }
2066 /*! \brief Constructor from cl_device_id.
2068 * This simply copies the device ID value, which is an inexpensive operation.
2070 __CL_EXPLICIT_CONSTRUCTORS Device(const cl_device_id &device) : detail::Wrapper<cl_type>(device) { }
2072 /*! \brief Returns the first device on the default context.
2074 * \see Context::getDefault()
2076 static Device getDefault(cl_int * err = NULL);
2078 /*! \brief Assignment operator from cl_device_id.
2080 * This simply copies the device ID value, which is an inexpensive operation.
2082 Device& operator = (const cl_device_id& rhs)
2084 detail::Wrapper<cl_type>::operator=(rhs);
2088 /*! \brief Copy constructor to forward copy to the superclass correctly.
2089 * Required for MSVC.
2091 Device(const Device& dev) : detail::Wrapper<cl_type>(dev) {}
2093 /*! \brief Copy assignment to forward copy to the superclass correctly.
2094 * Required for MSVC.
2096 Device& operator = (const Device &dev)
2098 detail::Wrapper<cl_type>::operator=(dev);
2102 #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
2103 /*! \brief Move constructor to forward move to the superclass correctly.
2104 * Required for MSVC.
2106 Device(Device&& dev) CL_HPP_NOEXCEPT : detail::Wrapper<cl_type>(std::move(dev)) {}
2108 /*! \brief Move assignment to forward move to the superclass correctly.
2109 * Required for MSVC.
2111 Device& operator = (Device &&dev)
2113 detail::Wrapper<cl_type>::operator=(std::move(dev));
2116 #endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
2118 //! \brief Wrapper for clGetDeviceInfo().
2119 template <typename T>
2120 cl_int getInfo(cl_device_info name, T* param) const
2122 return detail::errHandler(
2123 detail::getInfo(&::clGetDeviceInfo, object_, name, param),
2124 __GET_DEVICE_INFO_ERR);
2127 //! \brief Wrapper for clGetDeviceInfo() that returns by value.
2128 template <cl_int name> typename
2129 detail::param_traits<detail::cl_device_info, name>::param_type
2130 getInfo(cl_int* err = NULL) const
2132 typename detail::param_traits<
2133 detail::cl_device_info, name>::param_type param;
2134 cl_int result = getInfo(name, ¶m);
2144 #if defined(CL_VERSION_1_2)
2145 //! \brief Wrapper for clCreateSubDevicesEXT().
2146 cl_int createSubDevices(
2147 const cl_device_partition_property * properties,
2148 VECTOR_CLASS<Device>* devices)
2151 cl_int err = clCreateSubDevices(object_, properties, 0, NULL, &n);
2152 if (err != CL_SUCCESS) {
2153 return detail::errHandler(err, __CREATE_SUB_DEVICES);
2156 cl_device_id* ids = (cl_device_id*) alloca(n * sizeof(cl_device_id));
2157 err = clCreateSubDevices(object_, properties, n, ids, NULL);
2158 if (err != CL_SUCCESS) {
2159 return detail::errHandler(err, __CREATE_SUB_DEVICES);
2162 devices->assign(&ids[0], &ids[n]);
2165 #endif // #if defined(CL_VERSION_1_2)
2168 * CL 1.1 version that uses device fission.
2170 #if defined(CL_VERSION_1_1)
2171 #if defined(USE_CL_DEVICE_FISSION)
2172 cl_int createSubDevices(
2173 const cl_device_partition_property_ext * properties,
2174 VECTOR_CLASS<Device>* devices)
2176 typedef CL_API_ENTRY cl_int
2177 ( CL_API_CALL * PFN_clCreateSubDevicesEXT)(
2178 cl_device_id /*in_device*/,
2179 const cl_device_partition_property_ext * /* properties */,
2180 cl_uint /*num_entries*/,
2181 cl_device_id * /*out_devices*/,
2182 cl_uint * /*num_devices*/ ) CL_EXT_SUFFIX__VERSION_1_1;
2184 static PFN_clCreateSubDevicesEXT pfn_clCreateSubDevicesEXT = NULL;
2185 __INIT_CL_EXT_FCN_PTR(clCreateSubDevicesEXT);
2188 cl_int err = pfn_clCreateSubDevicesEXT(object_, properties, 0, NULL, &n);
2189 if (err != CL_SUCCESS) {
2190 return detail::errHandler(err, __CREATE_SUB_DEVICES);
2193 cl_device_id* ids = (cl_device_id*) alloca(n * sizeof(cl_device_id));
2194 err = pfn_clCreateSubDevicesEXT(object_, properties, n, ids, NULL);
2195 if (err != CL_SUCCESS) {
2196 return detail::errHandler(err, __CREATE_SUB_DEVICES);
2199 devices->assign(&ids[0], &ids[n]);
2202 #endif // #if defined(USE_CL_DEVICE_FISSION)
2203 #endif // #if defined(CL_VERSION_1_1)
2206 /*! \brief Class interface for cl_platform_id.
2208 * \note Copies of these objects are inexpensive, since they don't 'own'
2209 * any underlying resources or data structures.
2211 * \see cl_platform_id
2213 class Platform : public detail::Wrapper<cl_platform_id>
2216 //! \brief Default constructor - initializes to NULL.
2217 Platform() : detail::Wrapper<cl_type>() { }
2219 /*! \brief Constructor from cl_platform_id.
2221 * This simply copies the platform ID value, which is an inexpensive operation.
2223 __CL_EXPLICIT_CONSTRUCTORS Platform(const cl_platform_id &platform) : detail::Wrapper<cl_type>(platform) { }
2225 /*! \brief Assignment operator from cl_platform_id.
2227 * This simply copies the platform ID value, which is an inexpensive operation.
2229 Platform& operator = (const cl_platform_id& rhs)
2231 detail::Wrapper<cl_type>::operator=(rhs);
2235 //! \brief Wrapper for clGetPlatformInfo().
2236 cl_int getInfo(cl_platform_info name, STRING_CLASS* param) const
2238 return detail::errHandler(
2239 detail::getInfo(&::clGetPlatformInfo, object_, name, param),
2240 __GET_PLATFORM_INFO_ERR);
2243 //! \brief Wrapper for clGetPlatformInfo() that returns by value.
2244 template <cl_int name> typename
2245 detail::param_traits<detail::cl_platform_info, name>::param_type
2246 getInfo(cl_int* err = NULL) const
2248 typename detail::param_traits<
2249 detail::cl_platform_info, name>::param_type param;
2250 cl_int result = getInfo(name, ¶m);
2257 /*! \brief Gets a list of devices for this platform.
2259 * Wraps clGetDeviceIDs().
2262 cl_device_type type,
2263 VECTOR_CLASS<Device>* devices) const
2266 if( devices == NULL ) {
2267 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR);
2269 cl_int err = ::clGetDeviceIDs(object_, type, 0, NULL, &n);
2270 if (err != CL_SUCCESS) {
2271 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2274 cl_device_id* ids = (cl_device_id*) alloca(n * sizeof(cl_device_id));
2275 err = ::clGetDeviceIDs(object_, type, n, ids, NULL);
2276 if (err != CL_SUCCESS) {
2277 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2280 devices->assign(&ids[0], &ids[n]);
2284 #if defined(USE_DX_INTEROP)
2285 /*! \brief Get the list of available D3D10 devices.
2287 * \param d3d_device_source.
2289 * \param d3d_object.
2291 * \param d3d_device_set.
2293 * \param devices returns a vector of OpenCL D3D10 devices found. The cl::Device
2294 * values returned in devices can be used to identify a specific OpenCL
2295 * device. If \a devices argument is NULL, this argument is ignored.
2297 * \return One of the following values:
2298 * - CL_SUCCESS if the function is executed successfully.
2300 * The application can query specific capabilities of the OpenCL device(s)
2301 * returned by cl::getDevices. This can be used by the application to
2302 * determine which device(s) to use.
2304 * \note In the case that exceptions are enabled and a return value
2305 * other than CL_SUCCESS is generated, then cl::Error exception is
2309 cl_d3d10_device_source_khr d3d_device_source,
2311 cl_d3d10_device_set_khr d3d_device_set,
2312 VECTOR_CLASS<Device>* devices) const
2314 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clGetDeviceIDsFromD3D10KHR)(
2315 cl_platform_id platform,
2316 cl_d3d10_device_source_khr d3d_device_source,
2318 cl_d3d10_device_set_khr d3d_device_set,
2319 cl_uint num_entries,
2320 cl_device_id * devices,
2321 cl_uint* num_devices);
2323 if( devices == NULL ) {
2324 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR);
2327 static PFN_clGetDeviceIDsFromD3D10KHR pfn_clGetDeviceIDsFromD3D10KHR = NULL;
2328 __INIT_CL_EXT_FCN_PTR_PLATFORM(object_, clGetDeviceIDsFromD3D10KHR);
2331 cl_int err = pfn_clGetDeviceIDsFromD3D10KHR(
2339 if (err != CL_SUCCESS) {
2340 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2343 cl_device_id* ids = (cl_device_id*) alloca(n * sizeof(cl_device_id));
2344 err = pfn_clGetDeviceIDsFromD3D10KHR(
2352 if (err != CL_SUCCESS) {
2353 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2356 devices->assign(&ids[0], &ids[n]);
2361 /*! \brief Gets a list of available platforms.
2363 * Wraps clGetPlatformIDs().
2366 VECTOR_CLASS<Platform>* platforms)
2370 if( platforms == NULL ) {
2371 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_PLATFORM_IDS_ERR);
2374 cl_int err = ::clGetPlatformIDs(0, NULL, &n);
2375 if (err != CL_SUCCESS) {
2376 return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
2379 cl_platform_id* ids = (cl_platform_id*) alloca(
2380 n * sizeof(cl_platform_id));
2381 err = ::clGetPlatformIDs(n, ids, NULL);
2382 if (err != CL_SUCCESS) {
2383 return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
2386 platforms->assign(&ids[0], &ids[n]);
2390 /*! \brief Gets the first available platform.
2392 * Wraps clGetPlatformIDs(), returning the first result.
2395 Platform * platform)
2399 if( platform == NULL ) {
2400 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_PLATFORM_IDS_ERR);
2403 cl_int err = ::clGetPlatformIDs(0, NULL, &n);
2404 if (err != CL_SUCCESS) {
2405 return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
2408 cl_platform_id* ids = (cl_platform_id*) alloca(
2409 n * sizeof(cl_platform_id));
2410 err = ::clGetPlatformIDs(n, ids, NULL);
2411 if (err != CL_SUCCESS) {
2412 return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
2419 /*! \brief Gets the first available platform, returning it by value.
2421 * Wraps clGetPlatformIDs(), returning the first result.
2423 static Platform get(
2424 cl_int * errResult = NULL)
2428 cl_int err = ::clGetPlatformIDs(0, NULL, &n);
2429 if (err != CL_SUCCESS) {
2430 detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
2431 if (errResult != NULL) {
2437 cl_platform_id* ids = (cl_platform_id*) alloca(
2438 n * sizeof(cl_platform_id));
2439 err = ::clGetPlatformIDs(n, ids, NULL);
2441 if (err != CL_SUCCESS) {
2442 detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
2443 if (errResult != NULL) {
2450 return Platform(ids[0]);
2453 static Platform getDefault(
2454 cl_int *errResult = NULL )
2456 return get(errResult);
2460 #if defined(CL_VERSION_1_2)
2461 //! \brief Wrapper for clUnloadCompiler().
2465 return ::clUnloadPlatformCompiler(object_);
2467 #endif // #if defined(CL_VERSION_1_2)
2468 }; // class Platform
2471 * Deprecated APIs for 1.2
2473 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) || (defined(CL_VERSION_1_1) && !defined(CL_VERSION_1_2))
2475 * Unload the OpenCL compiler.
2476 * \note Deprecated for OpenCL 1.2. Use Platform::unloadCompiler instead.
2478 inline CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_int
2479 UnloadCompiler() CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
2483 return ::clUnloadCompiler();
2485 #endif // #if defined(CL_VERSION_1_1)
2487 /*! \brief Class interface for cl_context.
2489 * \note Copies of these objects are shallow, meaning that the copy will refer
2490 * to the same underlying cl_context as the original. For details, see
2491 * clRetainContext() and clReleaseContext().
2496 : public detail::Wrapper<cl_context>
2500 #ifdef CL_HPP_CPP11_ATOMICS_SUPPORTED
2501 static std::atomic<int> default_initialized_;
2502 #else // !CL_HPP_CPP11_ATOMICS_SUPPORTED
2503 static volatile int default_initialized_;
2504 #endif // !CL_HPP_CPP11_ATOMICS_SUPPORTED
2505 static Context default_;
2506 static volatile cl_int default_error_;
2508 /*! \brief Constructs a context including a list of specified devices.
2510 * Wraps clCreateContext().
2513 const VECTOR_CLASS<Device>& devices,
2514 cl_context_properties* properties = NULL,
2515 void (CL_CALLBACK * notifyFptr)(
2525 ::size_t numDevices = devices.size();
2526 cl_device_id* deviceIDs = (cl_device_id*) alloca(numDevices * sizeof(cl_device_id));
2527 for( ::size_t deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
2528 deviceIDs[deviceIndex] = (devices[deviceIndex])();
2531 object_ = ::clCreateContext(
2532 properties, (cl_uint) numDevices,
2534 notifyFptr, data, &error);
2536 detail::errHandler(error, __CREATE_CONTEXT_ERR);
2543 const Device& device,
2544 cl_context_properties* properties = NULL,
2545 void (CL_CALLBACK * notifyFptr)(
2555 cl_device_id deviceID = device();
2557 object_ = ::clCreateContext(
2560 notifyFptr, data, &error);
2562 detail::errHandler(error, __CREATE_CONTEXT_ERR);
2568 /*! \brief Constructs a context including all or a subset of devices of a specified type.
2570 * Wraps clCreateContextFromType().
2573 cl_device_type type,
2574 cl_context_properties* properties = NULL,
2575 void (CL_CALLBACK * notifyFptr)(
2585 #if !defined(__APPLE__) && !defined(__MACOS)
2586 cl_context_properties prop[4] = {CL_CONTEXT_PLATFORM, 0, 0, 0 };
2588 if (properties == NULL) {
2589 // Get a valid platform ID as we cannot send in a blank one
2590 VECTOR_CLASS<Platform> platforms;
2591 error = Platform::get(&platforms);
2592 if (error != CL_SUCCESS) {
2593 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
2600 // Check the platforms we found for a device of our specified type
2601 cl_context_properties platform_id = 0;
2602 for (unsigned int i = 0; i < platforms.size(); i++) {
2604 VECTOR_CLASS<Device> devices;
2606 #if defined(__CL_ENABLE_EXCEPTIONS)
2610 error = platforms[i].getDevices(type, &devices);
2612 #if defined(__CL_ENABLE_EXCEPTIONS)
2614 // Catch if exceptions are enabled as we don't want to exit if first platform has no devices of type
2615 // We do error checking next anyway, and can throw there if needed
2618 // Only squash CL_SUCCESS and CL_DEVICE_NOT_FOUND
2619 if (error != CL_SUCCESS && error != CL_DEVICE_NOT_FOUND) {
2620 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
2626 if (devices.size() > 0) {
2627 platform_id = (cl_context_properties)platforms[i]();
2632 if (platform_id == 0) {
2633 detail::errHandler(CL_DEVICE_NOT_FOUND, __CREATE_CONTEXT_FROM_TYPE_ERR);
2635 *err = CL_DEVICE_NOT_FOUND;
2640 prop[1] = platform_id;
2641 properties = &prop[0];
2644 object_ = ::clCreateContextFromType(
2645 properties, type, notifyFptr, data, &error);
2647 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
2653 /*! \brief Copy constructor to forward copy to the superclass correctly.
2654 * Required for MSVC.
2656 Context(const Context& ctx) : detail::Wrapper<cl_type>(ctx) {}
2658 /*! \brief Copy assignment to forward copy to the superclass correctly.
2659 * Required for MSVC.
2661 Context& operator = (const Context &ctx)
2663 detail::Wrapper<cl_type>::operator=(ctx);
2667 #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
2668 /*! \brief Move constructor to forward move to the superclass correctly.
2669 * Required for MSVC.
2671 Context(Context&& ctx) CL_HPP_NOEXCEPT : detail::Wrapper<cl_type>(std::move(ctx)) {}
2673 /*! \brief Move assignment to forward move to the superclass correctly.
2674 * Required for MSVC.
2676 Context& operator = (Context &&ctx)
2678 detail::Wrapper<cl_type>::operator=(std::move(ctx));
2681 #endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
2683 /*! \brief Returns a singleton context including all devices of CL_DEVICE_TYPE_DEFAULT.
2685 * \note All calls to this function return the same cl_context as the first.
2687 static Context getDefault(cl_int * err = NULL)
2689 int state = detail::compare_exchange(
2690 &default_initialized_,
2691 __DEFAULT_BEING_INITIALIZED, __DEFAULT_NOT_INITIALIZED);
2693 if (state & __DEFAULT_INITIALIZED) {
2695 *err = default_error_;
2700 if (state & __DEFAULT_BEING_INITIALIZED) {
2701 // Assume writes will propagate eventually...
2702 while(default_initialized_ != __DEFAULT_INITIALIZED) {
2707 *err = default_error_;
2714 CL_DEVICE_TYPE_DEFAULT,
2722 default_error_ = error;
2723 // Assume writes will propagate eventually...
2724 default_initialized_ = __DEFAULT_INITIALIZED;
2729 *err = default_error_;
2735 //! \brief Default constructor - initializes to NULL.
2736 Context() : detail::Wrapper<cl_type>() { }
2738 /*! \brief Constructor from cl_context - takes ownership.
2740 * This effectively transfers ownership of a refcount on the cl_context
2741 * into the new Context object.
2743 __CL_EXPLICIT_CONSTRUCTORS Context(const cl_context& context) : detail::Wrapper<cl_type>(context) { }
2745 /*! \brief Assignment operator from cl_context - takes ownership.
2747 * This effectively transfers ownership of a refcount on the rhs and calls
2748 * clReleaseContext() on the value previously held by this instance.
2750 Context& operator = (const cl_context& rhs)
2752 detail::Wrapper<cl_type>::operator=(rhs);
2756 //! \brief Wrapper for clGetContextInfo().
2757 template <typename T>
2758 cl_int getInfo(cl_context_info name, T* param) const
2760 return detail::errHandler(
2761 detail::getInfo(&::clGetContextInfo, object_, name, param),
2762 __GET_CONTEXT_INFO_ERR);
2765 //! \brief Wrapper for clGetContextInfo() that returns by value.
2766 template <cl_int name> typename
2767 detail::param_traits<detail::cl_context_info, name>::param_type
2768 getInfo(cl_int* err = NULL) const
2770 typename detail::param_traits<
2771 detail::cl_context_info, name>::param_type param;
2772 cl_int result = getInfo(name, ¶m);
2779 /*! \brief Gets a list of supported image formats.
2781 * Wraps clGetSupportedImageFormats().
2783 cl_int getSupportedImageFormats(
2785 cl_mem_object_type type,
2786 VECTOR_CLASS<ImageFormat>* formats) const
2794 cl_int err = ::clGetSupportedImageFormats(
2801 if (err != CL_SUCCESS) {
2802 return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
2805 if (numEntries > 0) {
2806 ImageFormat* value = (ImageFormat*)
2807 alloca(numEntries * sizeof(ImageFormat));
2808 err = ::clGetSupportedImageFormats(
2813 (cl_image_format*)value,
2815 if (err != CL_SUCCESS) {
2816 return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
2819 formats->assign(&value[0], &value[numEntries]);
2828 inline Device Device::getDefault(cl_int * err)
2833 Context context = Context::getDefault(&error);
2834 detail::errHandler(error, __CREATE_CONTEXT_ERR);
2836 if (error != CL_SUCCESS) {
2842 device = context.getInfo<CL_CONTEXT_DEVICES>()[0];
2851 #ifdef CL_HPP_CPP11_ATOMICS_SUPPORTED
2852 CL_WEAK_ATTRIB_PREFIX std::atomic<int> CL_WEAK_ATTRIB_SUFFIX Context::default_initialized_;
2853 #else // !CL_HPP_CPP11_ATOMICS_SUPPORTED
2854 CL_WEAK_ATTRIB_PREFIX volatile int CL_WEAK_ATTRIB_SUFFIX Context::default_initialized_ = __DEFAULT_NOT_INITIALIZED;
2855 #endif // !CL_HPP_CPP11_ATOMICS_SUPPORTED
2857 CL_WEAK_ATTRIB_PREFIX Context CL_WEAK_ATTRIB_SUFFIX Context::default_;
2858 CL_WEAK_ATTRIB_PREFIX volatile cl_int CL_WEAK_ATTRIB_SUFFIX Context::default_error_ = CL_SUCCESS;
2860 /*! \brief Class interface for cl_event.
2862 * \note Copies of these objects are shallow, meaning that the copy will refer
2863 * to the same underlying cl_event as the original. For details, see
2864 * clRetainEvent() and clReleaseEvent().
2868 class Event : public detail::Wrapper<cl_event>
2871 //! \brief Default constructor - initializes to NULL.
2872 Event() : detail::Wrapper<cl_type>() { }
2874 /*! \brief Constructor from cl_event - takes ownership.
2876 * This effectively transfers ownership of a refcount on the cl_event
2877 * into the new Event object.
2879 __CL_EXPLICIT_CONSTRUCTORS Event(const cl_event& event) : detail::Wrapper<cl_type>(event) { }
2881 /*! \brief Assignment operator from cl_event - takes ownership.
2883 * This effectively transfers ownership of a refcount on the rhs and calls
2884 * clReleaseEvent() on the value previously held by this instance.
2886 Event& operator = (const cl_event& rhs)
2888 detail::Wrapper<cl_type>::operator=(rhs);
2892 //! \brief Wrapper for clGetEventInfo().
2893 template <typename T>
2894 cl_int getInfo(cl_event_info name, T* param) const
2896 return detail::errHandler(
2897 detail::getInfo(&::clGetEventInfo, object_, name, param),
2898 __GET_EVENT_INFO_ERR);
2901 //! \brief Wrapper for clGetEventInfo() that returns by value.
2902 template <cl_int name> typename
2903 detail::param_traits<detail::cl_event_info, name>::param_type
2904 getInfo(cl_int* err = NULL) const
2906 typename detail::param_traits<
2907 detail::cl_event_info, name>::param_type param;
2908 cl_int result = getInfo(name, ¶m);
2915 //! \brief Wrapper for clGetEventProfilingInfo().
2916 template <typename T>
2917 cl_int getProfilingInfo(cl_profiling_info name, T* param) const
2919 return detail::errHandler(detail::getInfo(
2920 &::clGetEventProfilingInfo, object_, name, param),
2921 __GET_EVENT_PROFILE_INFO_ERR);
2924 //! \brief Wrapper for clGetEventProfilingInfo() that returns by value.
2925 template <cl_int name> typename
2926 detail::param_traits<detail::cl_profiling_info, name>::param_type
2927 getProfilingInfo(cl_int* err = NULL) const
2929 typename detail::param_traits<
2930 detail::cl_profiling_info, name>::param_type param;
2931 cl_int result = getProfilingInfo(name, ¶m);
2938 /*! \brief Blocks the calling thread until this event completes.
2940 * Wraps clWaitForEvents().
2944 return detail::errHandler(
2945 ::clWaitForEvents(1, &object_),
2946 __WAIT_FOR_EVENTS_ERR);
2949 #if defined(CL_VERSION_1_1)
2950 /*! \brief Registers a user callback function for a specific command execution status.
2952 * Wraps clSetEventCallback().
2956 void (CL_CALLBACK * pfn_notify)(cl_event, cl_int, void *),
2957 void * user_data = NULL)
2959 return detail::errHandler(
2960 ::clSetEventCallback(
2965 __SET_EVENT_CALLBACK_ERR);
2969 /*! \brief Blocks the calling thread until every event specified is complete.
2971 * Wraps clWaitForEvents().
2974 waitForEvents(const VECTOR_CLASS<Event>& events)
2976 return detail::errHandler(
2978 (cl_uint) events.size(), (events.size() > 0) ? (cl_event*)&events.front() : NULL),
2979 __WAIT_FOR_EVENTS_ERR);
2983 #if defined(CL_VERSION_1_1)
2984 /*! \brief Class interface for user events (a subset of cl_event's).
2986 * See Event for details about copy semantics, etc.
2988 class UserEvent : public Event
2991 /*! \brief Constructs a user event on a given context.
2993 * Wraps clCreateUserEvent().
2996 const Context& context,
2997 cl_int * err = NULL)
3000 object_ = ::clCreateUserEvent(
3004 detail::errHandler(error, __CREATE_USER_EVENT_ERR);
3010 //! \brief Default constructor - initializes to NULL.
3011 UserEvent() : Event() { }
3013 /*! \brief Sets the execution status of a user event object.
3015 * Wraps clSetUserEventStatus().
3017 cl_int setStatus(cl_int status)
3019 return detail::errHandler(
3020 ::clSetUserEventStatus(object_,status),
3021 __SET_USER_EVENT_STATUS_ERR);
3026 /*! \brief Blocks the calling thread until every event specified is complete.
3028 * Wraps clWaitForEvents().
3030 inline static cl_int
3031 WaitForEvents(const VECTOR_CLASS<Event>& events)
3033 return detail::errHandler(
3035 (cl_uint) events.size(), (events.size() > 0) ? (cl_event*)&events.front() : NULL),
3036 __WAIT_FOR_EVENTS_ERR);
3039 /*! \brief Class interface for cl_mem.
3041 * \note Copies of these objects are shallow, meaning that the copy will refer
3042 * to the same underlying cl_mem as the original. For details, see
3043 * clRetainMemObject() and clReleaseMemObject().
3047 class Memory : public detail::Wrapper<cl_mem>
3050 //! \brief Default constructor - initializes to NULL.
3051 Memory() : detail::Wrapper<cl_type>() { }
3053 /*! \brief Constructor from cl_mem - takes ownership.
3055 * This effectively transfers ownership of a refcount on the cl_mem
3056 * into the new Memory object.
3058 __CL_EXPLICIT_CONSTRUCTORS Memory(const cl_mem& memory) : detail::Wrapper<cl_type>(memory) { }
3060 /*! \brief Assignment operator from cl_mem - takes ownership.
3062 * This effectively transfers ownership of a refcount on the rhs and calls
3063 * clReleaseMemObject() on the value previously held by this instance.
3065 Memory& operator = (const cl_mem& rhs)
3067 detail::Wrapper<cl_type>::operator=(rhs);
3071 /*! \brief Copy constructor to forward copy to the superclass correctly.
3072 * Required for MSVC.
3074 Memory(const Memory& mem) : detail::Wrapper<cl_type>(mem) {}
3076 /*! \brief Copy assignment to forward copy to the superclass correctly.
3077 * Required for MSVC.
3079 Memory& operator = (const Memory &mem)
3081 detail::Wrapper<cl_type>::operator=(mem);
3085 #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
3086 /*! \brief Move constructor to forward move to the superclass correctly.
3087 * Required for MSVC.
3089 Memory(Memory&& mem) CL_HPP_NOEXCEPT : detail::Wrapper<cl_type>(std::move(mem)) {}
3091 /*! \brief Move assignment to forward move to the superclass correctly.
3092 * Required for MSVC.
3094 Memory& operator = (Memory &&mem)
3096 detail::Wrapper<cl_type>::operator=(std::move(mem));
3099 #endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
3101 //! \brief Wrapper for clGetMemObjectInfo().
3102 template <typename T>
3103 cl_int getInfo(cl_mem_info name, T* param) const
3105 return detail::errHandler(
3106 detail::getInfo(&::clGetMemObjectInfo, object_, name, param),
3107 __GET_MEM_OBJECT_INFO_ERR);
3110 //! \brief Wrapper for clGetMemObjectInfo() that returns by value.
3111 template <cl_int name> typename
3112 detail::param_traits<detail::cl_mem_info, name>::param_type
3113 getInfo(cl_int* err = NULL) const
3115 typename detail::param_traits<
3116 detail::cl_mem_info, name>::param_type param;
3117 cl_int result = getInfo(name, ¶m);
3124 #if defined(CL_VERSION_1_1)
3125 /*! \brief Registers a callback function to be called when the memory object
3126 * is no longer needed.
3128 * Wraps clSetMemObjectDestructorCallback().
3130 * Repeated calls to this function, for a given cl_mem value, will append
3131 * to the list of functions called (in reverse order) when memory object's
3132 * resources are freed and the memory object is deleted.
3135 * The registered callbacks are associated with the underlying cl_mem
3136 * value - not the Memory class instance.
3138 cl_int setDestructorCallback(
3139 void (CL_CALLBACK * pfn_notify)(cl_mem, void *),
3140 void * user_data = NULL)
3142 return detail::errHandler(
3143 ::clSetMemObjectDestructorCallback(
3147 __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR);
3153 // Pre-declare copy functions
3155 template< typename IteratorType >
3156 cl_int copy( IteratorType startIterator, IteratorType endIterator, cl::Buffer &buffer );
3157 template< typename IteratorType >
3158 cl_int copy( const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator );
3159 template< typename IteratorType >
3160 cl_int copy( const CommandQueue &queue, IteratorType startIterator, IteratorType endIterator, cl::Buffer &buffer );
3161 template< typename IteratorType >
3162 cl_int copy( const CommandQueue &queue, const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator );
3165 /*! \brief Class interface for Buffer Memory Objects.
3167 * See Memory for details about copy semantics, etc.
3171 class Buffer : public Memory
3175 /*! \brief Constructs a Buffer in a specified context.
3177 * Wraps clCreateBuffer().
3179 * \param host_ptr Storage to be used if the CL_MEM_USE_HOST_PTR flag was
3180 * specified. Note alignment & exclusivity requirements.
3183 const Context& context,
3186 void* host_ptr = NULL,
3190 object_ = ::clCreateBuffer(context(), flags, size, host_ptr, &error);
3192 detail::errHandler(error, __CREATE_BUFFER_ERR);
3198 /*! \brief Constructs a Buffer in the default context.
3200 * Wraps clCreateBuffer().
3202 * \param host_ptr Storage to be used if the CL_MEM_USE_HOST_PTR flag was
3203 * specified. Note alignment & exclusivity requirements.
3205 * \see Context::getDefault()
3210 void* host_ptr = NULL,
3215 Context context = Context::getDefault(err);
3217 object_ = ::clCreateBuffer(context(), flags, size, host_ptr, &error);
3219 detail::errHandler(error, __CREATE_BUFFER_ERR);
3226 * \brief Construct a Buffer from a host container via iterators.
3227 * IteratorType must be random access.
3228 * If useHostPtr is specified iterators must represent contiguous data.
3230 template< typename IteratorType >
3232 IteratorType startIterator,
3233 IteratorType endIterator,
3235 bool useHostPtr = false,
3238 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
3241 cl_mem_flags flags = 0;
3243 flags |= CL_MEM_READ_ONLY;
3246 flags |= CL_MEM_READ_WRITE;
3249 flags |= CL_MEM_USE_HOST_PTR;
3252 ::size_t size = sizeof(DataType)*(endIterator - startIterator);
3254 Context context = Context::getDefault(err);
3257 object_ = ::clCreateBuffer(context(), flags, size, static_cast<DataType*>(&*startIterator), &error);
3259 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
3262 detail::errHandler(error, __CREATE_BUFFER_ERR);
3268 error = cl::copy(startIterator, endIterator, *this);
3269 detail::errHandler(error, __CREATE_BUFFER_ERR);
3277 * \brief Construct a Buffer from a host container via iterators using a specified context.
3278 * IteratorType must be random access.
3279 * If useHostPtr is specified iterators must represent contiguous data.
3281 template< typename IteratorType >
3282 Buffer(const Context &context, IteratorType startIterator, IteratorType endIterator,
3283 bool readOnly, bool useHostPtr = false, cl_int* err = NULL);
3286 * \brief Construct a Buffer from a host container via iterators using a specified queue.
3287 * If useHostPtr is specified iterators must represent contiguous data.
3289 template< typename IteratorType >
3290 Buffer(const CommandQueue &queue, IteratorType startIterator, IteratorType endIterator,
3291 bool readOnly, bool useHostPtr = false, cl_int* err = NULL);
3293 //! \brief Default constructor - initializes to NULL.
3294 Buffer() : Memory() { }
3296 /*! \brief Constructor from cl_mem - takes ownership.
3298 * See Memory for further details.
3300 __CL_EXPLICIT_CONSTRUCTORS Buffer(const cl_mem& buffer) : Memory(buffer) { }
3302 /*! \brief Assignment from cl_mem - performs shallow copy.
3304 * See Memory for further details.
3306 Buffer& operator = (const cl_mem& rhs)
3308 Memory::operator=(rhs);
3312 /*! \brief Copy constructor to forward copy to the superclass correctly.
3313 * Required for MSVC.
3315 Buffer(const Buffer& buf) : Memory(buf) {}
3317 /*! \brief Copy assignment to forward copy to the superclass correctly.
3318 * Required for MSVC.
3320 Buffer& operator = (const Buffer &buf)
3322 Memory::operator=(buf);
3326 #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
3327 /*! \brief Move constructor to forward move to the superclass correctly.
3328 * Required for MSVC.
3330 Buffer(Buffer&& buf) CL_HPP_NOEXCEPT : Memory(std::move(buf)) {}
3332 /*! \brief Move assignment to forward move to the superclass correctly.
3333 * Required for MSVC.
3335 Buffer& operator = (Buffer &&buf)
3337 Memory::operator=(std::move(buf));
3340 #endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
3342 #if defined(CL_VERSION_1_1)
3343 /*! \brief Creates a new buffer object from this.
3345 * Wraps clCreateSubBuffer().
3347 Buffer createSubBuffer(
3349 cl_buffer_create_type buffer_create_type,
3350 const void * buffer_create_info,
3351 cl_int * err = NULL)
3355 result.object_ = ::clCreateSubBuffer(
3362 detail::errHandler(error, __CREATE_SUBBUFFER_ERR);
3372 #if defined (USE_DX_INTEROP)
3373 /*! \brief Class interface for creating OpenCL buffers from ID3D10Buffer's.
3375 * This is provided to facilitate interoperability with Direct3D.
3377 * See Memory for details about copy semantics, etc.
3381 class BufferD3D10 : public Buffer
3384 typedef CL_API_ENTRY cl_mem (CL_API_CALL *PFN_clCreateFromD3D10BufferKHR)(
3385 cl_context context, cl_mem_flags flags, ID3D10Buffer* buffer,
3386 cl_int* errcode_ret);
3388 /*! \brief Constructs a BufferD3D10, in a specified context, from a
3389 * given ID3D10Buffer.
3391 * Wraps clCreateFromD3D10BufferKHR().
3394 const Context& context,
3396 ID3D10Buffer* bufobj,
3397 cl_int * err = NULL)
3399 static PFN_clCreateFromD3D10BufferKHR pfn_clCreateFromD3D10BufferKHR = NULL;
3401 #if defined(CL_VERSION_1_2)
3402 vector<cl_context_properties> props = context.getInfo<CL_CONTEXT_PROPERTIES>();
3403 cl_platform platform = -1;
3404 for( int i = 0; i < props.size(); ++i ) {
3405 if( props[i] == CL_CONTEXT_PLATFORM ) {
3406 platform = props[i+1];
3409 __INIT_CL_EXT_FCN_PTR_PLATFORM(platform, clCreateFromD3D10BufferKHR);
3411 #if defined(CL_VERSION_1_1)
3412 __INIT_CL_EXT_FCN_PTR(clCreateFromD3D10BufferKHR);
3416 object_ = pfn_clCreateFromD3D10BufferKHR(
3422 detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
3428 //! \brief Default constructor - initializes to NULL.
3429 BufferD3D10() : Buffer() { }
3431 /*! \brief Constructor from cl_mem - takes ownership.
3433 * See Memory for further details.
3435 __CL_EXPLICIT_CONSTRUCTORS BufferD3D10(const cl_mem& buffer) : Buffer(buffer) { }
3437 /*! \brief Assignment from cl_mem - performs shallow copy.
3439 * See Memory for further details.
3441 BufferD3D10& operator = (const cl_mem& rhs)
3443 Buffer::operator=(rhs);
3447 /*! \brief Copy constructor to forward copy to the superclass correctly.
3448 * Required for MSVC.
3450 BufferD3D10(const BufferD3D10& buf) : Buffer(buf) {}
3452 /*! \brief Copy assignment to forward copy to the superclass correctly.
3453 * Required for MSVC.
3455 BufferD3D10& operator = (const BufferD3D10 &buf)
3457 Buffer::operator=(buf);
3461 #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
3462 /*! \brief Move constructor to forward move to the superclass correctly.
3463 * Required for MSVC.
3465 BufferD3D10(BufferD3D10&& buf) CL_HPP_NOEXCEPT : Buffer(std::move(buf)) {}
3467 /*! \brief Move assignment to forward move to the superclass correctly.
3468 * Required for MSVC.
3470 BufferD3D10& operator = (BufferD3D10 &&buf)
3472 Buffer::operator=(std::move(buf));
3475 #endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
3479 /*! \brief Class interface for GL Buffer Memory Objects.
3481 * This is provided to facilitate interoperability with OpenGL.
3483 * See Memory for details about copy semantics, etc.
3487 class BufferGL : public Buffer
3490 /*! \brief Constructs a BufferGL in a specified context, from a given
3493 * Wraps clCreateFromGLBuffer().
3496 const Context& context,
3499 cl_int * err = NULL)
3502 object_ = ::clCreateFromGLBuffer(
3508 detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
3514 //! \brief Default constructor - initializes to NULL.
3515 BufferGL() : Buffer() { }
3517 /*! \brief Constructor from cl_mem - takes ownership.
3519 * See Memory for further details.
3521 __CL_EXPLICIT_CONSTRUCTORS BufferGL(const cl_mem& buffer) : Buffer(buffer) { }
3523 /*! \brief Assignment from cl_mem - performs shallow copy.
3525 * See Memory for further details.
3527 BufferGL& operator = (const cl_mem& rhs)
3529 Buffer::operator=(rhs);
3533 /*! \brief Copy constructor to forward copy to the superclass correctly.
3534 * Required for MSVC.
3536 BufferGL(const BufferGL& buf) : Buffer(buf) {}
3538 /*! \brief Copy assignment to forward copy to the superclass correctly.
3539 * Required for MSVC.
3541 BufferGL& operator = (const BufferGL &buf)
3543 Buffer::operator=(buf);
3547 #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
3548 /*! \brief Move constructor to forward move to the superclass correctly.
3549 * Required for MSVC.
3551 BufferGL(BufferGL&& buf) CL_HPP_NOEXCEPT : Buffer(std::move(buf)) {}
3553 /*! \brief Move assignment to forward move to the superclass correctly.
3554 * Required for MSVC.
3556 BufferGL& operator = (BufferGL &&buf)
3558 Buffer::operator=(std::move(buf));
3561 #endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
3563 //! \brief Wrapper for clGetGLObjectInfo().
3564 cl_int getObjectInfo(
3565 cl_gl_object_type *type,
3566 cl_GLuint * gl_object_name)
3568 return detail::errHandler(
3569 ::clGetGLObjectInfo(object_,type,gl_object_name),
3570 __GET_GL_OBJECT_INFO_ERR);
3574 /*! \brief C++ base class for Image Memory objects.
3576 * See Memory for details about copy semantics, etc.
3580 class Image : public Memory
3583 //! \brief Default constructor - initializes to NULL.
3584 Image() : Memory() { }
3586 /*! \brief Constructor from cl_mem - takes ownership.
3588 * See Memory for further details.
3590 __CL_EXPLICIT_CONSTRUCTORS Image(const cl_mem& image) : Memory(image) { }
3592 /*! \brief Assignment from cl_mem - performs shallow copy.
3594 * See Memory for further details.
3596 Image& operator = (const cl_mem& rhs)
3598 Memory::operator=(rhs);
3602 /*! \brief Copy constructor to forward copy to the superclass correctly.
3603 * Required for MSVC.
3605 Image(const Image& img) : Memory(img) {}
3607 /*! \brief Copy assignment to forward copy to the superclass correctly.
3608 * Required for MSVC.
3610 Image& operator = (const Image &img)
3612 Memory::operator=(img);
3616 #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
3617 /*! \brief Move constructor to forward move to the superclass correctly.
3618 * Required for MSVC.
3620 Image(Image&& img) CL_HPP_NOEXCEPT : Memory(std::move(img)) {}
3622 /*! \brief Move assignment to forward move to the superclass correctly.
3623 * Required for MSVC.
3625 Image& operator = (Image &&img)
3627 Memory::operator=(std::move(img));
3630 #endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
3633 //! \brief Wrapper for clGetImageInfo().
3634 template <typename T>
3635 cl_int getImageInfo(cl_image_info name, T* param) const
3637 return detail::errHandler(
3638 detail::getInfo(&::clGetImageInfo, object_, name, param),
3639 __GET_IMAGE_INFO_ERR);
3642 //! \brief Wrapper for clGetImageInfo() that returns by value.
3643 template <cl_int name> typename
3644 detail::param_traits<detail::cl_image_info, name>::param_type
3645 getImageInfo(cl_int* err = NULL) const
3647 typename detail::param_traits<
3648 detail::cl_image_info, name>::param_type param;
3649 cl_int result = getImageInfo(name, ¶m);
3657 #if defined(CL_VERSION_1_2)
3658 /*! \brief Class interface for 1D Image Memory objects.
3660 * See Memory for details about copy semantics, etc.
3664 class Image1D : public Image
3667 /*! \brief Constructs a 1D Image in a specified context.
3669 * Wraps clCreateImage().
3672 const Context& context,
3676 void* host_ptr = NULL,
3680 cl_image_desc desc =
3682 CL_MEM_OBJECT_IMAGE1D,
3684 0, 0, 0, 0, 0, 0, 0, 0
3686 object_ = ::clCreateImage(
3694 detail::errHandler(error, __CREATE_IMAGE_ERR);
3700 //! \brief Default constructor - initializes to NULL.
3703 /*! \brief Constructor from cl_mem - takes ownership.
3705 * See Memory for further details.
3707 __CL_EXPLICIT_CONSTRUCTORS Image1D(const cl_mem& image1D) : Image(image1D) { }
3709 /*! \brief Assignment from cl_mem - performs shallow copy.
3711 * See Memory for further details.
3713 Image1D& operator = (const cl_mem& rhs)
3715 Image::operator=(rhs);
3719 /*! \brief Copy constructor to forward copy to the superclass correctly.
3720 * Required for MSVC.
3722 Image1D(const Image1D& img) : Image(img) {}
3724 /*! \brief Copy assignment to forward copy to the superclass correctly.
3725 * Required for MSVC.
3727 Image1D& operator = (const Image1D &img)
3729 Image::operator=(img);
3733 #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
3734 /*! \brief Move constructor to forward move to the superclass correctly.
3735 * Required for MSVC.
3737 Image1D(Image1D&& img) CL_HPP_NOEXCEPT : Image(std::move(img)) {}
3739 /*! \brief Move assignment to forward move to the superclass correctly.
3740 * Required for MSVC.
3742 Image1D& operator = (Image1D &&img)
3744 Image::operator=(std::move(img));
3747 #endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
3750 /*! \class Image1DBuffer
3751 * \brief Image interface for 1D buffer images.
3753 class Image1DBuffer : public Image
3757 const Context& context,
3761 const Buffer &buffer,
3765 cl_image_desc desc =
3767 CL_MEM_OBJECT_IMAGE1D_BUFFER,
3769 0, 0, 0, 0, 0, 0, 0,
3772 object_ = ::clCreateImage(
3780 detail::errHandler(error, __CREATE_IMAGE_ERR);
3788 __CL_EXPLICIT_CONSTRUCTORS Image1DBuffer(const cl_mem& image1D) : Image(image1D) { }
3790 Image1DBuffer& operator = (const cl_mem& rhs)
3792 Image::operator=(rhs);
3796 /*! \brief Copy constructor to forward copy to the superclass correctly.
3797 * Required for MSVC.
3799 Image1DBuffer(const Image1DBuffer& img) : Image(img) {}
3801 /*! \brief Copy assignment to forward copy to the superclass correctly.
3802 * Required for MSVC.
3804 Image1DBuffer& operator = (const Image1DBuffer &img)
3806 Image::operator=(img);
3810 #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
3811 /*! \brief Move constructor to forward move to the superclass correctly.
3812 * Required for MSVC.
3814 Image1DBuffer(Image1DBuffer&& img) CL_HPP_NOEXCEPT : Image(std::move(img)) {}
3816 /*! \brief Move assignment to forward move to the superclass correctly.
3817 * Required for MSVC.
3819 Image1DBuffer& operator = (Image1DBuffer &&img)
3821 Image::operator=(std::move(img));
3824 #endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
3827 /*! \class Image1DArray
3828 * \brief Image interface for arrays of 1D images.
3830 class Image1DArray : public Image
3834 const Context& context,
3840 void* host_ptr = NULL,
3844 cl_image_desc desc =
3846 CL_MEM_OBJECT_IMAGE1D_ARRAY,
3848 0, 0, // height, depth (unused)
3853 object_ = ::clCreateImage(
3861 detail::errHandler(error, __CREATE_IMAGE_ERR);
3869 __CL_EXPLICIT_CONSTRUCTORS Image1DArray(const cl_mem& imageArray) : Image(imageArray) { }
3871 Image1DArray& operator = (const cl_mem& rhs)
3873 Image::operator=(rhs);
3877 /*! \brief Copy constructor to forward copy to the superclass correctly.
3878 * Required for MSVC.
3880 Image1DArray(const Image1DArray& img) : Image(img) {}
3882 /*! \brief Copy assignment to forward copy to the superclass correctly.
3883 * Required for MSVC.
3885 Image1DArray& operator = (const Image1DArray &img)
3887 Image::operator=(img);
3891 #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
3892 /*! \brief Move constructor to forward move to the superclass correctly.
3893 * Required for MSVC.
3895 Image1DArray(Image1DArray&& img) CL_HPP_NOEXCEPT : Image(std::move(img)) {}
3897 /*! \brief Move assignment to forward move to the superclass correctly.
3898 * Required for MSVC.
3900 Image1DArray& operator = (Image1DArray &&img)
3902 Image::operator=(std::move(img));
3905 #endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
3907 #endif // #if defined(CL_VERSION_1_2)
3910 /*! \brief Class interface for 2D Image Memory objects.
3912 * See Memory for details about copy semantics, etc.
3916 class Image2D : public Image
3919 /*! \brief Constructs a 1D Image in a specified context.
3921 * Wraps clCreateImage().
3924 const Context& context,
3929 ::size_t row_pitch = 0,
3930 void* host_ptr = NULL,
3934 bool useCreateImage;
3936 #if defined(CL_VERSION_1_2) && defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
3937 // Run-time decision based on the actual platform
3939 cl_uint version = detail::getContextPlatformVersion(context());
3940 useCreateImage = (version >= 0x10002); // OpenCL 1.2 or above
3942 #elif defined(CL_VERSION_1_2)
3943 useCreateImage = true;
3945 useCreateImage = false;
3948 #if defined(CL_VERSION_1_2)
3951 cl_image_desc desc =
3953 CL_MEM_OBJECT_IMAGE2D,
3956 0, 0, // depth, array size (unused)
3960 object_ = ::clCreateImage(
3968 detail::errHandler(error, __CREATE_IMAGE_ERR);
3973 #endif // #if defined(CL_VERSION_1_2)
3974 #if !defined(CL_VERSION_1_2) || defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
3975 if (!useCreateImage)
3977 object_ = ::clCreateImage2D(
3978 context(), flags,&format, width, height, row_pitch, host_ptr, &error);
3980 detail::errHandler(error, __CREATE_IMAGE2D_ERR);
3985 #endif // #if !defined(CL_VERSION_1_2) || defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
3988 //! \brief Default constructor - initializes to NULL.
3991 /*! \brief Constructor from cl_mem - takes ownership.
3993 * See Memory for further details.
3995 __CL_EXPLICIT_CONSTRUCTORS Image2D(const cl_mem& image2D) : Image(image2D) { }
3997 /*! \brief Assignment from cl_mem - performs shallow copy.
3999 * See Memory for further details.
4001 Image2D& operator = (const cl_mem& rhs)
4003 Image::operator=(rhs);
4007 /*! \brief Copy constructor to forward copy to the superclass correctly.
4008 * Required for MSVC.
4010 Image2D(const Image2D& img) : Image(img) {}
4012 /*! \brief Copy assignment to forward copy to the superclass correctly.
4013 * Required for MSVC.
4015 Image2D& operator = (const Image2D &img)
4017 Image::operator=(img);
4021 #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
4022 /*! \brief Move constructor to forward move to the superclass correctly.
4023 * Required for MSVC.
4025 Image2D(Image2D&& img) CL_HPP_NOEXCEPT : Image(std::move(img)) {}
4027 /*! \brief Move assignment to forward move to the superclass correctly.
4028 * Required for MSVC.
4030 Image2D& operator = (Image2D &&img)
4032 Image::operator=(std::move(img));
4035 #endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
4039 #if !defined(CL_VERSION_1_2)
4040 /*! \brief Class interface for GL 2D Image Memory objects.
4042 * This is provided to facilitate interoperability with OpenGL.
4044 * See Memory for details about copy semantics, etc.
4047 * \note Deprecated for OpenCL 1.2. Please use ImageGL instead.
4049 class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED Image2DGL CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED : public Image2D
4052 /*! \brief Constructs an Image2DGL in a specified context, from a given
4055 * Wraps clCreateFromGLTexture2D().
4058 const Context& context,
4063 cl_int * err = NULL)
4066 object_ = ::clCreateFromGLTexture2D(
4074 detail::errHandler(error, __CREATE_GL_TEXTURE_2D_ERR);
4081 //! \brief Default constructor - initializes to NULL.
4082 Image2DGL() : Image2D() { }
4084 /*! \brief Constructor from cl_mem - takes ownership.
4086 * See Memory for further details.
4088 __CL_EXPLICIT_CONSTRUCTORS Image2DGL(const cl_mem& image) : Image2D(image) { }
4090 /*! \brief Assignment from cl_mem - performs shallow copy.
4092 * See Memory for further details.
4094 Image2DGL& operator = (const cl_mem& rhs)
4096 Image2D::operator=(rhs);
4100 /*! \brief Copy constructor to forward copy to the superclass correctly.
4101 * Required for MSVC.
4103 Image2DGL(const Image2DGL& img) : Image2D(img) {}
4105 /*! \brief Copy assignment to forward copy to the superclass correctly.
4106 * Required for MSVC.
4108 Image2DGL& operator = (const Image2DGL &img)
4110 Image2D::operator=(img);
4114 #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
4115 /*! \brief Move constructor to forward move to the superclass correctly.
4116 * Required for MSVC.
4118 Image2DGL(Image2DGL&& img) CL_HPP_NOEXCEPT : Image2D(std::move(img)) {}
4120 /*! \brief Move assignment to forward move to the superclass correctly.
4121 * Required for MSVC.
4123 Image2DGL& operator = (Image2DGL &&img)
4125 Image2D::operator=(std::move(img));
4128 #endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
4130 #endif // #if !defined(CL_VERSION_1_2)
4132 #if defined(CL_VERSION_1_2)
4133 /*! \class Image2DArray
4134 * \brief Image interface for arrays of 2D images.
4136 class Image2DArray : public Image
4140 const Context& context,
4147 ::size_t slicePitch,
4148 void* host_ptr = NULL,
4152 cl_image_desc desc =
4154 CL_MEM_OBJECT_IMAGE2D_ARRAY,
4157 0, // depth (unused)
4163 object_ = ::clCreateImage(
4171 detail::errHandler(error, __CREATE_IMAGE_ERR);
4179 __CL_EXPLICIT_CONSTRUCTORS Image2DArray(const cl_mem& imageArray) : Image(imageArray) { }
4181 Image2DArray& operator = (const cl_mem& rhs)
4183 Image::operator=(rhs);
4187 /*! \brief Copy constructor to forward copy to the superclass correctly.
4188 * Required for MSVC.
4190 Image2DArray(const Image2DArray& img) : Image(img) {}
4192 /*! \brief Copy assignment to forward copy to the superclass correctly.
4193 * Required for MSVC.
4195 Image2DArray& operator = (const Image2DArray &img)
4197 Image::operator=(img);
4201 #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
4202 /*! \brief Move constructor to forward move to the superclass correctly.
4203 * Required for MSVC.
4205 Image2DArray(Image2DArray&& img) CL_HPP_NOEXCEPT : Image(std::move(img)) {}
4207 /*! \brief Move assignment to forward move to the superclass correctly.
4208 * Required for MSVC.
4210 Image2DArray& operator = (Image2DArray &&img)
4212 Image::operator=(std::move(img));
4215 #endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
4217 #endif // #if defined(CL_VERSION_1_2)
4219 /*! \brief Class interface for 3D Image Memory objects.
4221 * See Memory for details about copy semantics, etc.
4225 class Image3D : public Image
4228 /*! \brief Constructs a 3D Image in a specified context.
4230 * Wraps clCreateImage().
4233 const Context& context,
4239 ::size_t row_pitch = 0,
4240 ::size_t slice_pitch = 0,
4241 void* host_ptr = NULL,
4245 bool useCreateImage;
4247 #if defined(CL_VERSION_1_2) && defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
4248 // Run-time decision based on the actual platform
4250 cl_uint version = detail::getContextPlatformVersion(context());
4251 useCreateImage = (version >= 0x10002); // OpenCL 1.2 or above
4253 #elif defined(CL_VERSION_1_2)
4254 useCreateImage = true;
4256 useCreateImage = false;
4259 #if defined(CL_VERSION_1_2)
4262 cl_image_desc desc =
4264 CL_MEM_OBJECT_IMAGE3D,
4268 0, // array size (unused)
4273 object_ = ::clCreateImage(
4281 detail::errHandler(error, __CREATE_IMAGE_ERR);
4286 #endif // #if defined(CL_VERSION_1_2)
4287 #if !defined(CL_VERSION_1_2) || defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
4288 if (!useCreateImage)
4290 object_ = ::clCreateImage3D(
4291 context(), flags, &format, width, height, depth, row_pitch,
4292 slice_pitch, host_ptr, &error);
4294 detail::errHandler(error, __CREATE_IMAGE3D_ERR);
4299 #endif // #if !defined(CL_VERSION_1_2) || defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
4302 //! \brief Default constructor - initializes to NULL.
4303 Image3D() : Image() { }
4305 /*! \brief Constructor from cl_mem - takes ownership.
4307 * See Memory for further details.
4309 __CL_EXPLICIT_CONSTRUCTORS Image3D(const cl_mem& image3D) : Image(image3D) { }
4311 /*! \brief Assignment from cl_mem - performs shallow copy.
4313 * See Memory for further details.
4315 Image3D& operator = (const cl_mem& rhs)
4317 Image::operator=(rhs);
4321 /*! \brief Copy constructor to forward copy to the superclass correctly.
4322 * Required for MSVC.
4324 Image3D(const Image3D& img) : Image(img) {}
4326 /*! \brief Copy assignment to forward copy to the superclass correctly.
4327 * Required for MSVC.
4329 Image3D& operator = (const Image3D &img)
4331 Image::operator=(img);
4335 #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
4336 /*! \brief Move constructor to forward move to the superclass correctly.
4337 * Required for MSVC.
4339 Image3D(Image3D&& img) CL_HPP_NOEXCEPT : Image(std::move(img)) {}
4341 /*! \brief Move assignment to forward move to the superclass correctly.
4342 * Required for MSVC.
4344 Image3D& operator = (Image3D &&img)
4346 Image::operator=(std::move(img));
4349 #endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
4352 #if !defined(CL_VERSION_1_2)
4353 /*! \brief Class interface for GL 3D Image Memory objects.
4355 * This is provided to facilitate interoperability with OpenGL.
4357 * See Memory for details about copy semantics, etc.
4361 class Image3DGL : public Image3D
4364 /*! \brief Constructs an Image3DGL in a specified context, from a given
4367 * Wraps clCreateFromGLTexture3D().
4370 const Context& context,
4375 cl_int * err = NULL)
4378 object_ = ::clCreateFromGLTexture3D(
4386 detail::errHandler(error, __CREATE_GL_TEXTURE_3D_ERR);
4392 //! \brief Default constructor - initializes to NULL.
4393 Image3DGL() : Image3D() { }
4395 /*! \brief Constructor from cl_mem - takes ownership.
4397 * See Memory for further details.
4399 __CL_EXPLICIT_CONSTRUCTORS Image3DGL(const cl_mem& image) : Image3D(image) { }
4401 /*! \brief Assignment from cl_mem - performs shallow copy.
4403 * See Memory for further details.
4405 Image3DGL& operator = (const cl_mem& rhs)
4407 Image3D::operator=(rhs);
4411 /*! \brief Copy constructor to forward copy to the superclass correctly.
4412 * Required for MSVC.
4414 Image3DGL(const Image3DGL& img) : Image3D(img) {}
4416 /*! \brief Copy assignment to forward copy to the superclass correctly.
4417 * Required for MSVC.
4419 Image3DGL& operator = (const Image3DGL &img)
4421 Image3D::operator=(img);
4425 #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
4426 /*! \brief Move constructor to forward move to the superclass correctly.
4427 * Required for MSVC.
4429 Image3DGL(Image3DGL&& img) CL_HPP_NOEXCEPT : Image3D(std::move(img)) {}
4431 /*! \brief Move assignment to forward move to the superclass correctly.
4432 * Required for MSVC.
4434 Image3DGL& operator = (Image3DGL &&img)
4436 Image3D::operator=(std::move(img));
4439 #endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
4441 #endif // #if !defined(CL_VERSION_1_2)
4443 #if defined(CL_VERSION_1_2)
4445 * \brief general image interface for GL interop.
4446 * We abstract the 2D and 3D GL images into a single instance here
4447 * that wraps all GL sourced images on the grounds that setup information
4448 * was performed by OpenCL anyway.
4450 class ImageGL : public Image
4454 const Context& context,
4459 cl_int * err = NULL)
4462 object_ = ::clCreateFromGLTexture(
4470 detail::errHandler(error, __CREATE_GL_TEXTURE_ERR);
4476 ImageGL() : Image() { }
4478 __CL_EXPLICIT_CONSTRUCTORS ImageGL(const cl_mem& image) : Image(image) { }
4480 ImageGL& operator = (const cl_mem& rhs)
4482 Image::operator=(rhs);
4486 /*! \brief Copy constructor to forward copy to the superclass correctly.
4487 * Required for MSVC.
4489 ImageGL(const ImageGL& img) : Image(img) {}
4491 /*! \brief Copy assignment to forward copy to the superclass correctly.
4492 * Required for MSVC.
4494 ImageGL& operator = (const ImageGL &img)
4496 Image::operator=(img);
4500 #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
4501 /*! \brief Move constructor to forward move to the superclass correctly.
4502 * Required for MSVC.
4504 ImageGL(ImageGL&& img) CL_HPP_NOEXCEPT : Image(std::move(img)) {}
4506 /*! \brief Move assignment to forward move to the superclass correctly.
4507 * Required for MSVC.
4509 ImageGL& operator = (ImageGL &&img)
4511 Image::operator=(std::move(img));
4514 #endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
4516 #endif // #if defined(CL_VERSION_1_2)
4518 /*! \brief Class interface for GL Render Buffer Memory Objects.
4520 * This is provided to facilitate interoperability with OpenGL.
4522 * See Memory for details about copy semantics, etc.
4526 class BufferRenderGL :
4527 #if defined(CL_VERSION_1_2)
4529 #else // #if defined(CL_VERSION_1_2)
4531 #endif //#if defined(CL_VERSION_1_2)
4534 /*! \brief Constructs a BufferRenderGL in a specified context, from a given
4537 * Wraps clCreateFromGLRenderbuffer().
4540 const Context& context,
4543 cl_int * err = NULL)
4546 object_ = ::clCreateFromGLRenderbuffer(
4552 detail::errHandler(error, __CREATE_GL_RENDER_BUFFER_ERR);
4558 //! \brief Default constructor - initializes to NULL.
4559 #if defined(CL_VERSION_1_2)
4560 BufferRenderGL() : ImageGL() {};
4561 #else // #if defined(CL_VERSION_1_2)
4562 BufferRenderGL() : Image2DGL() {};
4563 #endif //#if defined(CL_VERSION_1_2)
4565 /*! \brief Constructor from cl_mem - takes ownership.
4567 * See Memory for further details.
4569 #if defined(CL_VERSION_1_2)
4570 __CL_EXPLICIT_CONSTRUCTORS BufferRenderGL(const cl_mem& buffer) : ImageGL(buffer) { }
4571 #else // #if defined(CL_VERSION_1_2)
4572 __CL_EXPLICIT_CONSTRUCTORS BufferRenderGL(const cl_mem& buffer) : Image2DGL(buffer) { }
4573 #endif //#if defined(CL_VERSION_1_2)
4576 /*! \brief Assignment from cl_mem - performs shallow copy.
4578 * See Memory for further details.
4580 BufferRenderGL& operator = (const cl_mem& rhs)
4582 #if defined(CL_VERSION_1_2)
4583 ImageGL::operator=(rhs);
4584 #else // #if defined(CL_VERSION_1_2)
4585 Image2DGL::operator=(rhs);
4586 #endif //#if defined(CL_VERSION_1_2)
4591 /*! \brief Copy constructor to forward copy to the superclass correctly.
4592 * Required for MSVC.
4594 #if defined(CL_VERSION_1_2)
4595 BufferRenderGL(const BufferRenderGL& buf) : ImageGL(buf) {}
4596 #else // #if defined(CL_VERSION_1_2)
4597 BufferRenderGL(const BufferRenderGL& buf) : Image2DGL(buf) {}
4598 #endif //#if defined(CL_VERSION_1_2)
4600 /*! \brief Copy assignment to forward copy to the superclass correctly.
4601 * Required for MSVC.
4603 BufferRenderGL& operator = (const BufferRenderGL &rhs)
4605 #if defined(CL_VERSION_1_2)
4606 ImageGL::operator=(rhs);
4607 #else // #if defined(CL_VERSION_1_2)
4608 Image2DGL::operator=(rhs);
4609 #endif //#if defined(CL_VERSION_1_2)
4613 #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
4614 /*! \brief Move constructor to forward move to the superclass correctly.
4615 * Required for MSVC.
4617 #if defined(CL_VERSION_1_2)
4618 BufferRenderGL(BufferRenderGL&& buf) CL_HPP_NOEXCEPT : ImageGL(std::move(buf)) {}
4619 #else // #if defined(CL_VERSION_1_2)
4620 BufferRenderGL(BufferRenderGL&& buf) CL_HPP_NOEXCEPT : Image2DGL(std::move(buf)) {}
4621 #endif //#if defined(CL_VERSION_1_2)
4624 /*! \brief Move assignment to forward move to the superclass correctly.
4625 * Required for MSVC.
4627 BufferRenderGL& operator = (BufferRenderGL &&buf)
4629 #if defined(CL_VERSION_1_2)
4630 ImageGL::operator=(std::move(buf));
4631 #else // #if defined(CL_VERSION_1_2)
4632 Image2DGL::operator=(std::move(buf));
4633 #endif //#if defined(CL_VERSION_1_2)
4637 #endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
4639 //! \brief Wrapper for clGetGLObjectInfo().
4640 cl_int getObjectInfo(
4641 cl_gl_object_type *type,
4642 cl_GLuint * gl_object_name)
4644 return detail::errHandler(
4645 ::clGetGLObjectInfo(object_, type, gl_object_name),
4646 __GET_GL_OBJECT_INFO_ERR);
4650 /*! \brief Class interface for cl_sampler.
4652 * \note Copies of these objects are shallow, meaning that the copy will refer
4653 * to the same underlying cl_sampler as the original. For details, see
4654 * clRetainSampler() and clReleaseSampler().
4658 class Sampler : public detail::Wrapper<cl_sampler>
4661 //! \brief Default constructor - initializes to NULL.
4664 /*! \brief Constructs a Sampler in a specified context.
4666 * Wraps clCreateSampler().
4669 const Context& context,
4670 cl_bool normalized_coords,
4671 cl_addressing_mode addressing_mode,
4672 cl_filter_mode filter_mode,
4676 object_ = ::clCreateSampler(
4683 detail::errHandler(error, __CREATE_SAMPLER_ERR);
4689 /*! \brief Constructor from cl_sampler - takes ownership.
4691 * This effectively transfers ownership of a refcount on the cl_sampler
4692 * into the new Sampler object.
4694 __CL_EXPLICIT_CONSTRUCTORS Sampler(const cl_sampler& sampler) : detail::Wrapper<cl_type>(sampler) { }
4696 /*! \brief Assignment operator from cl_sampler - takes ownership.
4698 * This effectively transfers ownership of a refcount on the rhs and calls
4699 * clReleaseSampler() on the value previously held by this instance.
4701 Sampler& operator = (const cl_sampler& rhs)
4703 detail::Wrapper<cl_type>::operator=(rhs);
4707 /*! \brief Copy constructor to forward copy to the superclass correctly.
4708 * Required for MSVC.
4710 Sampler(const Sampler& sam) : detail::Wrapper<cl_type>(sam) {}
4712 /*! \brief Copy assignment to forward copy to the superclass correctly.
4713 * Required for MSVC.
4715 Sampler& operator = (const Sampler &sam)
4717 detail::Wrapper<cl_type>::operator=(sam);
4721 #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
4722 /*! \brief Move constructor to forward move to the superclass correctly.
4723 * Required for MSVC.
4725 Sampler(Sampler&& sam) CL_HPP_NOEXCEPT : detail::Wrapper<cl_type>(std::move(sam)) {}
4727 /*! \brief Move assignment to forward move to the superclass correctly.
4728 * Required for MSVC.
4730 Sampler& operator = (Sampler &&sam)
4732 detail::Wrapper<cl_type>::operator=(std::move(sam));
4735 #endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
4737 //! \brief Wrapper for clGetSamplerInfo().
4738 template <typename T>
4739 cl_int getInfo(cl_sampler_info name, T* param) const
4741 return detail::errHandler(
4742 detail::getInfo(&::clGetSamplerInfo, object_, name, param),
4743 __GET_SAMPLER_INFO_ERR);
4746 //! \brief Wrapper for clGetSamplerInfo() that returns by value.
4747 template <cl_int name> typename
4748 detail::param_traits<detail::cl_sampler_info, name>::param_type
4749 getInfo(cl_int* err = NULL) const
4751 typename detail::param_traits<
4752 detail::cl_sampler_info, name>::param_type param;
4753 cl_int result = getInfo(name, ¶m);
4765 //! \brief Class interface for specifying NDRange values.
4770 cl_uint dimensions_;
4773 //! \brief Default constructor - resulting range has zero dimensions.
4778 //! \brief Constructs one-dimensional range.
4779 NDRange(::size_t size0)
4785 //! \brief Constructs two-dimensional range.
4786 NDRange(::size_t size0, ::size_t size1)
4793 //! \brief Constructs three-dimensional range.
4794 NDRange(::size_t size0, ::size_t size1, ::size_t size2)
4802 /*! \brief Conversion operator to const ::size_t *.
4804 * \returns a pointer to the size of the first dimension.
4806 operator const ::size_t*() const {
4807 return (const ::size_t*) sizes_;
4810 //! \brief Queries the number of dimensions in the range.
4811 ::size_t dimensions() const { return dimensions_; }
4814 //! \brief A zero-dimensional range.
4815 static const NDRange NullRange;
4817 //! \brief Local address wrapper for use with Kernel::setArg
4818 struct LocalSpaceArg
4825 template <typename T>
4826 struct KernelArgumentHandler
4828 static ::size_t size(const T&) { return sizeof(T); }
4829 static const T* ptr(const T& value) { return &value; }
4833 struct KernelArgumentHandler<LocalSpaceArg>
4835 static ::size_t size(const LocalSpaceArg& value) { return value.size_; }
4836 static const void* ptr(const LocalSpaceArg&) { return NULL; }
4843 * \brief Helper function for generating LocalSpaceArg objects.
4844 * Deprecated. Replaced with Local.
4846 inline CL_EXT_PREFIX__VERSION_1_1_DEPRECATED LocalSpaceArg
4847 __local(::size_t size) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
4848 inline LocalSpaceArg
4849 __local(::size_t size)
4851 LocalSpaceArg ret = { size };
4856 * \brief Helper function for generating LocalSpaceArg objects.
4858 inline LocalSpaceArg
4859 Local(::size_t size)
4861 LocalSpaceArg ret = { size };
4865 //class KernelFunctor;
4867 /*! \brief Class interface for cl_kernel.
4869 * \note Copies of these objects are shallow, meaning that the copy will refer
4870 * to the same underlying cl_kernel as the original. For details, see
4871 * clRetainKernel() and clReleaseKernel().
4875 class Kernel : public detail::Wrapper<cl_kernel>
4878 inline Kernel(const Program& program, const char* name, cl_int* err = NULL);
4880 //! \brief Default constructor - initializes to NULL.
4883 /*! \brief Constructor from cl_kernel - takes ownership.
4885 * This effectively transfers ownership of a refcount on the cl_kernel
4886 * into the new Kernel object.
4888 __CL_EXPLICIT_CONSTRUCTORS Kernel(const cl_kernel& kernel) : detail::Wrapper<cl_type>(kernel) { }
4890 /*! \brief Assignment operator from cl_kernel - takes ownership.
4892 * This effectively transfers ownership of a refcount on the rhs and calls
4893 * clReleaseKernel() on the value previously held by this instance.
4895 Kernel& operator = (const cl_kernel& rhs)
4897 detail::Wrapper<cl_type>::operator=(rhs);
4901 /*! \brief Copy constructor to forward copy to the superclass correctly.
4902 * Required for MSVC.
4904 Kernel(const Kernel& kernel) : detail::Wrapper<cl_type>(kernel) {}
4906 /*! \brief Copy assignment to forward copy to the superclass correctly.
4907 * Required for MSVC.
4909 Kernel& operator = (const Kernel &kernel)
4911 detail::Wrapper<cl_type>::operator=(kernel);
4915 #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
4916 /*! \brief Move constructor to forward move to the superclass correctly.
4917 * Required for MSVC.
4919 Kernel(Kernel&& kernel) CL_HPP_NOEXCEPT : detail::Wrapper<cl_type>(std::move(kernel)) {}
4921 /*! \brief Move assignment to forward move to the superclass correctly.
4922 * Required for MSVC.
4924 Kernel& operator = (Kernel &&kernel)
4926 detail::Wrapper<cl_type>::operator=(std::move(kernel));
4929 #endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
4931 template <typename T>
4932 cl_int getInfo(cl_kernel_info name, T* param) const
4934 return detail::errHandler(
4935 detail::getInfo(&::clGetKernelInfo, object_, name, param),
4936 __GET_KERNEL_INFO_ERR);
4939 template <cl_int name> typename
4940 detail::param_traits<detail::cl_kernel_info, name>::param_type
4941 getInfo(cl_int* err = NULL) const
4943 typename detail::param_traits<
4944 detail::cl_kernel_info, name>::param_type param;
4945 cl_int result = getInfo(name, ¶m);
4952 #if defined(CL_VERSION_1_2)
4953 template <typename T>
4954 cl_int getArgInfo(cl_uint argIndex, cl_kernel_arg_info name, T* param) const
4956 return detail::errHandler(
4957 detail::getInfo(&::clGetKernelArgInfo, object_, argIndex, name, param),
4958 __GET_KERNEL_ARG_INFO_ERR);
4961 template <cl_int name> typename
4962 detail::param_traits<detail::cl_kernel_arg_info, name>::param_type
4963 getArgInfo(cl_uint argIndex, cl_int* err = NULL) const
4965 typename detail::param_traits<
4966 detail::cl_kernel_arg_info, name>::param_type param;
4967 cl_int result = getArgInfo(argIndex, name, ¶m);
4973 #endif // #if defined(CL_VERSION_1_2)
4975 template <typename T>
4976 cl_int getWorkGroupInfo(
4977 const Device& device, cl_kernel_work_group_info name, T* param) const
4979 return detail::errHandler(
4981 &::clGetKernelWorkGroupInfo, object_, device(), name, param),
4982 __GET_KERNEL_WORK_GROUP_INFO_ERR);
4985 template <cl_int name> typename
4986 detail::param_traits<detail::cl_kernel_work_group_info, name>::param_type
4987 getWorkGroupInfo(const Device& device, cl_int* err = NULL) const
4989 typename detail::param_traits<
4990 detail::cl_kernel_work_group_info, name>::param_type param;
4991 cl_int result = getWorkGroupInfo(device, name, ¶m);
4998 template <typename T>
4999 cl_int setArg(cl_uint index, const T &value)
5001 return detail::errHandler(
5005 detail::KernelArgumentHandler<T>::size(value),
5006 detail::KernelArgumentHandler<T>::ptr(value)),
5007 __SET_KERNEL_ARGS_ERR);
5010 cl_int setArg(cl_uint index, ::size_t size, const void* argPtr)
5012 return detail::errHandler(
5013 ::clSetKernelArg(object_, index, size, argPtr),
5014 __SET_KERNEL_ARGS_ERR);
5019 * \brief Program interface that implements cl_program.
5021 class Program : public detail::Wrapper<cl_program>
5024 typedef VECTOR_CLASS<std::pair<const void*, ::size_t> > Binaries;
5025 typedef VECTOR_CLASS<std::pair<const char*, ::size_t> > Sources;
5028 const STRING_CLASS& source,
5034 const char * strings = source.c_str();
5035 const ::size_t length = source.size();
5037 Context context = Context::getDefault(err);
5039 object_ = ::clCreateProgramWithSource(
5040 context(), (cl_uint)1, &strings, &length, &error);
5042 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
5044 if (error == CL_SUCCESS && build) {
5046 error = ::clBuildProgram(
5054 detail::errHandler(error, __BUILD_PROGRAM_ERR);
5063 const Context& context,
5064 const STRING_CLASS& source,
5070 const char * strings = source.c_str();
5071 const ::size_t length = source.size();
5073 object_ = ::clCreateProgramWithSource(
5074 context(), (cl_uint)1, &strings, &length, &error);
5076 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
5078 if (error == CL_SUCCESS && build) {
5080 error = ::clBuildProgram(
5088 detail::errHandler(error, __BUILD_PROGRAM_ERR);
5097 const Context& context,
5098 const Sources& sources,
5103 const ::size_t n = (::size_t)sources.size();
5104 ::size_t* lengths = (::size_t*) alloca(n * sizeof(::size_t));
5105 const char** strings = (const char**) alloca(n * sizeof(const char*));
5107 for (::size_t i = 0; i < n; ++i) {
5108 strings[i] = sources[(int)i].first;
5109 lengths[i] = sources[(int)i].second;
5112 object_ = ::clCreateProgramWithSource(
5113 context(), (cl_uint)n, strings, lengths, &error);
5115 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
5122 * Construct a program object from a list of devices and a per-device list of binaries.
5123 * \param context A valid OpenCL context in which to construct the program.
5124 * \param devices A vector of OpenCL device objects for which the program will be created.
5125 * \param binaries A vector of pairs of a pointer to a binary object and its length.
5126 * \param binaryStatus An optional vector that on completion will be resized to
5127 * match the size of binaries and filled with values to specify if each binary
5128 * was successfully loaded.
5129 * Set to CL_SUCCESS if the binary was successfully loaded.
5130 * Set to CL_INVALID_VALUE if the length is 0 or the binary pointer is NULL.
5131 * Set to CL_INVALID_BINARY if the binary provided is not valid for the matching device.
5132 * \param err if non-NULL will be set to CL_SUCCESS on successful operation or one of the following errors:
5133 * CL_INVALID_CONTEXT if context is not a valid context.
5134 * CL_INVALID_VALUE if the length of devices is zero; or if the length of binaries does not match the length of devices;
5135 * or if any entry in binaries is NULL or has length 0.
5136 * CL_INVALID_DEVICE if OpenCL devices listed in devices are not in the list of devices associated with context.
5137 * CL_INVALID_BINARY if an invalid program binary was encountered for any device. binaryStatus will return specific status for each device.
5138 * CL_OUT_OF_HOST_MEMORY if there is a failure to allocate resources required by the OpenCL implementation on the host.
5141 const Context& context,
5142 const VECTOR_CLASS<Device>& devices,
5143 const Binaries& binaries,
5144 VECTOR_CLASS<cl_int>* binaryStatus = NULL,
5149 const ::size_t numDevices = devices.size();
5151 // Catch size mismatch early and return
5152 if(binaries.size() != numDevices) {
5153 error = CL_INVALID_VALUE;
5154 detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
5161 ::size_t* lengths = (::size_t*) alloca(numDevices * sizeof(::size_t));
5162 const unsigned char** images = (const unsigned char**) alloca(numDevices * sizeof(const unsigned char**));
5164 for (::size_t i = 0; i < numDevices; ++i) {
5165 images[i] = (const unsigned char*)binaries[i].first;
5166 lengths[i] = binaries[(int)i].second;
5169 cl_device_id* deviceIDs = (cl_device_id*) alloca(numDevices * sizeof(cl_device_id));
5170 for( ::size_t deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
5171 deviceIDs[deviceIndex] = (devices[deviceIndex])();
5175 binaryStatus->resize(numDevices);
5178 object_ = ::clCreateProgramWithBinary(
5179 context(), (cl_uint) devices.size(),
5181 lengths, images, (binaryStatus != NULL && numDevices > 0)
5182 ? &binaryStatus->front()
5185 detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
5192 #if defined(CL_VERSION_1_2)
5194 * Create program using builtin kernels.
5195 * \param kernelNames Semi-colon separated list of builtin kernel names
5198 const Context& context,
5199 const VECTOR_CLASS<Device>& devices,
5200 const STRING_CLASS& kernelNames,
5206 ::size_t numDevices = devices.size();
5207 cl_device_id* deviceIDs = (cl_device_id*) alloca(numDevices * sizeof(cl_device_id));
5208 for( ::size_t deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
5209 deviceIDs[deviceIndex] = (devices[deviceIndex])();
5212 object_ = ::clCreateProgramWithBuiltInKernels(
5214 (cl_uint) devices.size(),
5216 kernelNames.c_str(),
5219 detail::errHandler(error, __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR);
5224 #endif // #if defined(CL_VERSION_1_2)
5228 __CL_EXPLICIT_CONSTRUCTORS Program(const cl_program& program) : detail::Wrapper<cl_type>(program) { }
5230 Program& operator = (const cl_program& rhs)
5232 detail::Wrapper<cl_type>::operator=(rhs);
5236 /*! \brief Copy constructor to forward copy to the superclass correctly.
5237 * Required for MSVC.
5239 Program(const Program& program) : detail::Wrapper<cl_type>(program) {}
5241 /*! \brief Copy assignment to forward copy to the superclass correctly.
5242 * Required for MSVC.
5244 Program& operator = (const Program &program)
5246 detail::Wrapper<cl_type>::operator=(program);
5250 #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
5251 /*! \brief Move constructor to forward move to the superclass correctly.
5252 * Required for MSVC.
5254 Program(Program&& program) CL_HPP_NOEXCEPT : detail::Wrapper<cl_type>(std::move(program)) {}
5256 /*! \brief Move assignment to forward move to the superclass correctly.
5257 * Required for MSVC.
5259 Program& operator = (Program &&program)
5261 detail::Wrapper<cl_type>::operator=(std::move(program));
5264 #endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
5267 const VECTOR_CLASS<Device>& devices,
5268 const char* options = NULL,
5269 void (CL_CALLBACK * notifyFptr)(cl_program, void *) = NULL,
5270 void* data = NULL) const
5272 ::size_t numDevices = devices.size();
5273 cl_device_id* deviceIDs = (cl_device_id*) alloca(numDevices * sizeof(cl_device_id));
5274 for( ::size_t deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
5275 deviceIDs[deviceIndex] = (devices[deviceIndex])();
5278 return detail::errHandler(
5287 __BUILD_PROGRAM_ERR);
5291 const char* options = NULL,
5292 void (CL_CALLBACK * notifyFptr)(cl_program, void *) = NULL,
5293 void* data = NULL) const
5295 return detail::errHandler(
5303 __BUILD_PROGRAM_ERR);
5306 #if defined(CL_VERSION_1_2)
5308 const char* options = NULL,
5309 void (CL_CALLBACK * notifyFptr)(cl_program, void *) = NULL,
5310 void* data = NULL) const
5312 return detail::errHandler(
5323 __COMPILE_PROGRAM_ERR);
5327 template <typename T>
5328 cl_int getInfo(cl_program_info name, T* param) const
5330 return detail::errHandler(
5331 detail::getInfo(&::clGetProgramInfo, object_, name, param),
5332 __GET_PROGRAM_INFO_ERR);
5335 template <cl_int name> typename
5336 detail::param_traits<detail::cl_program_info, name>::param_type
5337 getInfo(cl_int* err = NULL) const
5339 typename detail::param_traits<
5340 detail::cl_program_info, name>::param_type param;
5341 cl_int result = getInfo(name, ¶m);
5348 template <typename T>
5349 cl_int getBuildInfo(
5350 const Device& device, cl_program_build_info name, T* param) const
5352 return detail::errHandler(
5354 &::clGetProgramBuildInfo, object_, device(), name, param),
5355 __GET_PROGRAM_BUILD_INFO_ERR);
5358 template <cl_int name> typename
5359 detail::param_traits<detail::cl_program_build_info, name>::param_type
5360 getBuildInfo(const Device& device, cl_int* err = NULL) const
5362 typename detail::param_traits<
5363 detail::cl_program_build_info, name>::param_type param;
5364 cl_int result = getBuildInfo(device, name, ¶m);
5371 cl_int createKernels(VECTOR_CLASS<Kernel>* kernels)
5374 cl_int err = ::clCreateKernelsInProgram(object_, 0, NULL, &numKernels);
5375 if (err != CL_SUCCESS) {
5376 return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
5379 Kernel* value = (Kernel*) alloca(numKernels * sizeof(Kernel));
5380 err = ::clCreateKernelsInProgram(
5381 object_, numKernels, (cl_kernel*) value, NULL);
5382 if (err != CL_SUCCESS) {
5383 return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
5386 kernels->assign(&value[0], &value[numKernels]);
5391 #if defined(CL_VERSION_1_2)
5392 inline Program linkProgram(
5395 const char* options = NULL,
5396 void (CL_CALLBACK * notifyFptr)(cl_program, void *) = NULL,
5400 cl_int error_local = CL_SUCCESS;
5402 cl_program programs[2] = { input1(), input2() };
5404 Context ctx = input1.getInfo<CL_PROGRAM_CONTEXT>(&error_local);
5405 if(error_local!=CL_SUCCESS) {
5406 detail::errHandler(error_local, __LINK_PROGRAM_ERR);
5409 cl_program prog = ::clLinkProgram(
5420 detail::errHandler(error_local,__COMPILE_PROGRAM_ERR);
5425 return Program(prog);
5428 inline Program linkProgram(
5429 VECTOR_CLASS<Program> inputPrograms,
5430 const char* options = NULL,
5431 void (CL_CALLBACK * notifyFptr)(cl_program, void *) = NULL,
5435 cl_int error_local = CL_SUCCESS;
5437 cl_program * programs = (cl_program*) alloca(inputPrograms.size() * sizeof(cl_program));
5439 if (programs != NULL) {
5440 for (unsigned int i = 0; i < inputPrograms.size(); i++) {
5441 programs[i] = inputPrograms[i]();
5446 if(inputPrograms.size() > 0) {
5447 ctx = inputPrograms[0].getInfo<CL_PROGRAM_CONTEXT>(&error_local);
5448 if(error_local!=CL_SUCCESS) {
5449 detail::errHandler(error_local, __LINK_PROGRAM_ERR);
5452 cl_program prog = ::clLinkProgram(
5457 (cl_uint)inputPrograms.size(),
5463 detail::errHandler(error_local,__COMPILE_PROGRAM_ERR);
5468 return Program(prog);
5473 inline VECTOR_CLASS<char *> cl::Program::getInfo<CL_PROGRAM_BINARIES>(cl_int* err) const
5475 VECTOR_CLASS< ::size_t> sizes = getInfo<CL_PROGRAM_BINARY_SIZES>();
5476 VECTOR_CLASS<char *> binaries;
5477 for (VECTOR_CLASS< ::size_t>::iterator s = sizes.begin(); s != sizes.end(); ++s)
5482 binaries.push_back(ptr);
5485 cl_int result = getInfo(CL_PROGRAM_BINARIES, &binaries);
5492 inline Kernel::Kernel(const Program& program, const char* name, cl_int* err)
5496 object_ = ::clCreateKernel(program(), name, &error);
5497 detail::errHandler(error, __CREATE_KERNEL_ERR);
5505 /*! \class CommandQueue
5506 * \brief CommandQueue interface for cl_command_queue.
5508 class CommandQueue : public detail::Wrapper<cl_command_queue>
5511 #ifdef CL_HPP_CPP11_ATOMICS_SUPPORTED
5512 static std::atomic<int> default_initialized_;
5513 #else // !CL_HPP_CPP11_ATOMICS_SUPPORTED
5514 static volatile int default_initialized_;
5515 #endif // !CL_HPP_CPP11_ATOMICS_SUPPORTED
5516 static CommandQueue default_;
5517 static volatile cl_int default_error_;
5520 cl_command_queue_properties properties,
5525 Context context = Context::getDefault(&error);
5526 detail::errHandler(error, __CREATE_CONTEXT_ERR);
5528 if (error != CL_SUCCESS) {
5534 Device device = context.getInfo<CL_CONTEXT_DEVICES>()[0];
5536 object_ = ::clCreateCommandQueue(
5537 context(), device(), properties, &error);
5539 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
5546 * \brief Constructs a CommandQueue for an implementation defined device in the given context
5548 explicit CommandQueue(
5549 const Context& context,
5550 cl_command_queue_properties properties = 0,
5554 VECTOR_CLASS<cl::Device> devices;
5555 error = context.getInfo(CL_CONTEXT_DEVICES, &devices);
5557 detail::errHandler(error, __CREATE_CONTEXT_ERR);
5559 if (error != CL_SUCCESS)
5567 object_ = ::clCreateCommandQueue(context(), devices[0](), properties, &error);
5569 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
5578 const Context& context,
5579 const Device& device,
5580 cl_command_queue_properties properties = 0,
5584 object_ = ::clCreateCommandQueue(
5585 context(), device(), properties, &error);
5587 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
5593 /*! \brief Copy constructor to forward copy to the superclass correctly.
5594 * Required for MSVC.
5596 CommandQueue(const CommandQueue& queue) : detail::Wrapper<cl_type>(queue) {}
5598 /*! \brief Copy assignment to forward copy to the superclass correctly.
5599 * Required for MSVC.
5601 CommandQueue& operator = (const CommandQueue &queue)
5603 detail::Wrapper<cl_type>::operator=(queue);
5607 #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
5608 /*! \brief Move constructor to forward move to the superclass correctly.
5609 * Required for MSVC.
5611 CommandQueue(CommandQueue&& queue) CL_HPP_NOEXCEPT : detail::Wrapper<cl_type>(std::move(queue)) {}
5613 /*! \brief Move assignment to forward move to the superclass correctly.
5614 * Required for MSVC.
5616 CommandQueue& operator = (CommandQueue &&queue)
5618 detail::Wrapper<cl_type>::operator=(std::move(queue));
5621 #endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
5623 static CommandQueue getDefault(cl_int * err = NULL)
5625 int state = detail::compare_exchange(
5626 &default_initialized_,
5627 __DEFAULT_BEING_INITIALIZED, __DEFAULT_NOT_INITIALIZED);
5629 if (state & __DEFAULT_INITIALIZED) {
5631 *err = default_error_;
5636 if (state & __DEFAULT_BEING_INITIALIZED) {
5637 // Assume writes will propagate eventually...
5638 while(default_initialized_ != __DEFAULT_INITIALIZED) {
5643 *err = default_error_;
5650 Context context = Context::getDefault(&error);
5651 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
5653 if (error != CL_SUCCESS) {
5659 Device device = context.getInfo<CL_CONTEXT_DEVICES>()[0];
5661 default_ = CommandQueue(context, device, 0, &error);
5663 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
5671 default_error_ = error;
5672 // Assume writes will propagate eventually...
5673 default_initialized_ = __DEFAULT_INITIALIZED;
5678 *err = default_error_;
5686 __CL_EXPLICIT_CONSTRUCTORS CommandQueue(const cl_command_queue& commandQueue) : detail::Wrapper<cl_type>(commandQueue) { }
5688 CommandQueue& operator = (const cl_command_queue& rhs)
5690 detail::Wrapper<cl_type>::operator=(rhs);
5694 template <typename T>
5695 cl_int getInfo(cl_command_queue_info name, T* param) const
5697 return detail::errHandler(
5699 &::clGetCommandQueueInfo, object_, name, param),
5700 __GET_COMMAND_QUEUE_INFO_ERR);
5703 template <cl_int name> typename
5704 detail::param_traits<detail::cl_command_queue_info, name>::param_type
5705 getInfo(cl_int* err = NULL) const
5707 typename detail::param_traits<
5708 detail::cl_command_queue_info, name>::param_type param;
5709 cl_int result = getInfo(name, ¶m);
5716 cl_int enqueueReadBuffer(
5717 const Buffer& buffer,
5722 const VECTOR_CLASS<Event>* events = NULL,
5723 Event* event = NULL) const
5726 cl_int err = detail::errHandler(
5727 ::clEnqueueReadBuffer(
5728 object_, buffer(), blocking, offset, size,
5730 (events != NULL) ? (cl_uint) events->size() : 0,
5731 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
5732 (event != NULL) ? &tmp : NULL),
5733 __ENQUEUE_READ_BUFFER_ERR);
5735 if (event != NULL && err == CL_SUCCESS)
5741 cl_int enqueueWriteBuffer(
5742 const Buffer& buffer,
5747 const VECTOR_CLASS<Event>* events = NULL,
5748 Event* event = NULL) const
5751 cl_int err = detail::errHandler(
5752 ::clEnqueueWriteBuffer(
5753 object_, buffer(), blocking, offset, size,
5755 (events != NULL) ? (cl_uint) events->size() : 0,
5756 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
5757 (event != NULL) ? &tmp : NULL),
5758 __ENQUEUE_WRITE_BUFFER_ERR);
5760 if (event != NULL && err == CL_SUCCESS)
5766 cl_int enqueueCopyBuffer(
5769 ::size_t src_offset,
5770 ::size_t dst_offset,
5772 const VECTOR_CLASS<Event>* events = NULL,
5773 Event* event = NULL) const
5776 cl_int err = detail::errHandler(
5777 ::clEnqueueCopyBuffer(
5778 object_, src(), dst(), src_offset, dst_offset, size,
5779 (events != NULL) ? (cl_uint) events->size() : 0,
5780 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
5781 (event != NULL) ? &tmp : NULL),
5782 __ENQEUE_COPY_BUFFER_ERR);
5784 if (event != NULL && err == CL_SUCCESS)
5789 #if defined(CL_VERSION_1_1)
5791 cl_int enqueueReadBufferRect(
5792 const Buffer& buffer,
5794 const size_t<3>& buffer_offset,
5795 const size_t<3>& host_offset,
5796 const size_t<3>& region,
5797 ::size_t buffer_row_pitch,
5798 ::size_t buffer_slice_pitch,
5799 ::size_t host_row_pitch,
5800 ::size_t host_slice_pitch,
5802 const VECTOR_CLASS<Event>* events = NULL,
5803 Event* event = NULL) const
5806 cl_int err = detail::errHandler(
5807 ::clEnqueueReadBufferRect(
5811 (const ::size_t *)buffer_offset,
5812 (const ::size_t *)host_offset,
5813 (const ::size_t *)region,
5819 (events != NULL) ? (cl_uint) events->size() : 0,
5820 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
5821 (event != NULL) ? &tmp : NULL),
5822 __ENQUEUE_READ_BUFFER_RECT_ERR);
5824 if (event != NULL && err == CL_SUCCESS)
5830 cl_int enqueueWriteBufferRect(
5831 const Buffer& buffer,
5833 const size_t<3>& buffer_offset,
5834 const size_t<3>& host_offset,
5835 const size_t<3>& region,
5836 ::size_t buffer_row_pitch,
5837 ::size_t buffer_slice_pitch,
5838 ::size_t host_row_pitch,
5839 ::size_t host_slice_pitch,
5841 const VECTOR_CLASS<Event>* events = NULL,
5842 Event* event = NULL) const
5845 cl_int err = detail::errHandler(
5846 ::clEnqueueWriteBufferRect(
5850 (const ::size_t *)buffer_offset,
5851 (const ::size_t *)host_offset,
5852 (const ::size_t *)region,
5858 (events != NULL) ? (cl_uint) events->size() : 0,
5859 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
5860 (event != NULL) ? &tmp : NULL),
5861 __ENQUEUE_WRITE_BUFFER_RECT_ERR);
5863 if (event != NULL && err == CL_SUCCESS)
5869 cl_int enqueueCopyBufferRect(
5872 const size_t<3>& src_origin,
5873 const size_t<3>& dst_origin,
5874 const size_t<3>& region,
5875 ::size_t src_row_pitch,
5876 ::size_t src_slice_pitch,
5877 ::size_t dst_row_pitch,
5878 ::size_t dst_slice_pitch,
5879 const VECTOR_CLASS<Event>* events = NULL,
5880 Event* event = NULL) const
5883 cl_int err = detail::errHandler(
5884 ::clEnqueueCopyBufferRect(
5888 (const ::size_t *)src_origin,
5889 (const ::size_t *)dst_origin,
5890 (const ::size_t *)region,
5895 (events != NULL) ? (cl_uint) events->size() : 0,
5896 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
5897 (event != NULL) ? &tmp : NULL),
5898 __ENQEUE_COPY_BUFFER_RECT_ERR);
5900 if (event != NULL && err == CL_SUCCESS)
5905 #endif //if defined(CL_VERSION_1_1)
5907 #if defined(CL_VERSION_1_2)
5909 * Enqueue a command to fill a buffer object with a pattern
5910 * of a given size. The pattern is specified a as vector.
5911 * \tparam PatternType The datatype of the pattern field.
5912 * The pattern type must be an accepted OpenCL data type.
5914 template<typename PatternType>
5915 cl_int enqueueFillBuffer(
5916 const Buffer& buffer,
5917 PatternType pattern,
5920 const VECTOR_CLASS<Event>* events = NULL,
5921 Event* event = NULL) const
5924 cl_int err = detail::errHandler(
5925 ::clEnqueueFillBuffer(
5928 static_cast<void*>(&pattern),
5929 sizeof(PatternType),
5932 (events != NULL) ? (cl_uint) events->size() : 0,
5933 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
5934 (event != NULL) ? &tmp : NULL),
5935 __ENQUEUE_FILL_BUFFER_ERR);
5937 if (event != NULL && err == CL_SUCCESS)
5942 #endif // #if defined(CL_VERSION_1_2)
5944 cl_int enqueueReadImage(
5947 const size_t<3>& origin,
5948 const size_t<3>& region,
5950 ::size_t slice_pitch,
5952 const VECTOR_CLASS<Event>* events = NULL,
5953 Event* event = NULL) const
5956 cl_int err = detail::errHandler(
5957 ::clEnqueueReadImage(
5958 object_, image(), blocking, (const ::size_t *) origin,
5959 (const ::size_t *) region, row_pitch, slice_pitch, ptr,
5960 (events != NULL) ? (cl_uint) events->size() : 0,
5961 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
5962 (event != NULL) ? &tmp : NULL),
5963 __ENQUEUE_READ_IMAGE_ERR);
5965 if (event != NULL && err == CL_SUCCESS)
5971 cl_int enqueueWriteImage(
5974 const size_t<3>& origin,
5975 const size_t<3>& region,
5977 ::size_t slice_pitch,
5979 const VECTOR_CLASS<Event>* events = NULL,
5980 Event* event = NULL) const
5983 cl_int err = detail::errHandler(
5984 ::clEnqueueWriteImage(
5985 object_, image(), blocking, (const ::size_t *) origin,
5986 (const ::size_t *) region, row_pitch, slice_pitch, ptr,
5987 (events != NULL) ? (cl_uint) events->size() : 0,
5988 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
5989 (event != NULL) ? &tmp : NULL),
5990 __ENQUEUE_WRITE_IMAGE_ERR);
5992 if (event != NULL && err == CL_SUCCESS)
5998 cl_int enqueueCopyImage(
6001 const size_t<3>& src_origin,
6002 const size_t<3>& dst_origin,
6003 const size_t<3>& region,
6004 const VECTOR_CLASS<Event>* events = NULL,
6005 Event* event = NULL) const
6008 cl_int err = detail::errHandler(
6009 ::clEnqueueCopyImage(
6010 object_, src(), dst(), (const ::size_t *) src_origin,
6011 (const ::size_t *)dst_origin, (const ::size_t *) region,
6012 (events != NULL) ? (cl_uint) events->size() : 0,
6013 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
6014 (event != NULL) ? &tmp : NULL),
6015 __ENQUEUE_COPY_IMAGE_ERR);
6017 if (event != NULL && err == CL_SUCCESS)
6023 #if defined(CL_VERSION_1_2)
6025 * Enqueue a command to fill an image object with a specified color.
6026 * \param fillColor is the color to use to fill the image.
6027 * This is a four component RGBA floating-point color value if
6028 * the image channel data type is not an unnormalized signed or
6029 * unsigned data type.
6031 cl_int enqueueFillImage(
6033 cl_float4 fillColor,
6034 const size_t<3>& origin,
6035 const size_t<3>& region,
6036 const VECTOR_CLASS<Event>* events = NULL,
6037 Event* event = NULL) const
6040 cl_int err = detail::errHandler(
6041 ::clEnqueueFillImage(
6044 static_cast<void*>(&fillColor),
6045 (const ::size_t *) origin,
6046 (const ::size_t *) region,
6047 (events != NULL) ? (cl_uint) events->size() : 0,
6048 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
6049 (event != NULL) ? &tmp : NULL),
6050 __ENQUEUE_FILL_IMAGE_ERR);
6052 if (event != NULL && err == CL_SUCCESS)
6059 * Enqueue a command to fill an image object with a specified color.
6060 * \param fillColor is the color to use to fill the image.
6061 * This is a four component RGBA signed integer color value if
6062 * the image channel data type is an unnormalized signed integer
6065 cl_int enqueueFillImage(
6068 const size_t<3>& origin,
6069 const size_t<3>& region,
6070 const VECTOR_CLASS<Event>* events = NULL,
6071 Event* event = NULL) const
6074 cl_int err = detail::errHandler(
6075 ::clEnqueueFillImage(
6078 static_cast<void*>(&fillColor),
6079 (const ::size_t *) origin,
6080 (const ::size_t *) region,
6081 (events != NULL) ? (cl_uint) events->size() : 0,
6082 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
6083 (event != NULL) ? &tmp : NULL),
6084 __ENQUEUE_FILL_IMAGE_ERR);
6086 if (event != NULL && err == CL_SUCCESS)
6093 * Enqueue a command to fill an image object with a specified color.
6094 * \param fillColor is the color to use to fill the image.
6095 * This is a four component RGBA unsigned integer color value if
6096 * the image channel data type is an unnormalized unsigned integer
6099 cl_int enqueueFillImage(
6102 const size_t<3>& origin,
6103 const size_t<3>& region,
6104 const VECTOR_CLASS<Event>* events = NULL,
6105 Event* event = NULL) const
6108 cl_int err = detail::errHandler(
6109 ::clEnqueueFillImage(
6112 static_cast<void*>(&fillColor),
6113 (const ::size_t *) origin,
6114 (const ::size_t *) region,
6115 (events != NULL) ? (cl_uint) events->size() : 0,
6116 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
6117 (event != NULL) ? &tmp : NULL),
6118 __ENQUEUE_FILL_IMAGE_ERR);
6120 if (event != NULL && err == CL_SUCCESS)
6125 #endif // #if defined(CL_VERSION_1_2)
6127 cl_int enqueueCopyImageToBuffer(
6130 const size_t<3>& src_origin,
6131 const size_t<3>& region,
6132 ::size_t dst_offset,
6133 const VECTOR_CLASS<Event>* events = NULL,
6134 Event* event = NULL) const
6137 cl_int err = detail::errHandler(
6138 ::clEnqueueCopyImageToBuffer(
6139 object_, src(), dst(), (const ::size_t *) src_origin,
6140 (const ::size_t *) region, dst_offset,
6141 (events != NULL) ? (cl_uint) events->size() : 0,
6142 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
6143 (event != NULL) ? &tmp : NULL),
6144 __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR);
6146 if (event != NULL && err == CL_SUCCESS)
6152 cl_int enqueueCopyBufferToImage(
6155 ::size_t src_offset,
6156 const size_t<3>& dst_origin,
6157 const size_t<3>& region,
6158 const VECTOR_CLASS<Event>* events = NULL,
6159 Event* event = NULL) const
6162 cl_int err = detail::errHandler(
6163 ::clEnqueueCopyBufferToImage(
6164 object_, src(), dst(), src_offset,
6165 (const ::size_t *) dst_origin, (const ::size_t *) region,
6166 (events != NULL) ? (cl_uint) events->size() : 0,
6167 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
6168 (event != NULL) ? &tmp : NULL),
6169 __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR);
6171 if (event != NULL && err == CL_SUCCESS)
6177 void* enqueueMapBuffer(
6178 const Buffer& buffer,
6183 const VECTOR_CLASS<Event>* events = NULL,
6184 Event* event = NULL,
6185 cl_int* err = NULL) const
6189 void * result = ::clEnqueueMapBuffer(
6190 object_, buffer(), blocking, flags, offset, size,
6191 (events != NULL) ? (cl_uint) events->size() : 0,
6192 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
6193 (event != NULL) ? &tmp : NULL,
6196 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
6200 if (event != NULL && error == CL_SUCCESS)
6206 void* enqueueMapImage(
6207 const Image& buffer,
6210 const size_t<3>& origin,
6211 const size_t<3>& region,
6212 ::size_t * row_pitch,
6213 ::size_t * slice_pitch,
6214 const VECTOR_CLASS<Event>* events = NULL,
6215 Event* event = NULL,
6216 cl_int* err = NULL) const
6220 void * result = ::clEnqueueMapImage(
6221 object_, buffer(), blocking, flags,
6222 (const ::size_t *) origin, (const ::size_t *) region,
6223 row_pitch, slice_pitch,
6224 (events != NULL) ? (cl_uint) events->size() : 0,
6225 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
6226 (event != NULL) ? &tmp : NULL,
6229 detail::errHandler(error, __ENQUEUE_MAP_IMAGE_ERR);
6233 if (event != NULL && error == CL_SUCCESS)
6238 cl_int enqueueUnmapMemObject(
6239 const Memory& memory,
6241 const VECTOR_CLASS<Event>* events = NULL,
6242 Event* event = NULL) const
6245 cl_int err = detail::errHandler(
6246 ::clEnqueueUnmapMemObject(
6247 object_, memory(), mapped_ptr,
6248 (events != NULL) ? (cl_uint) events->size() : 0,
6249 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
6250 (event != NULL) ? &tmp : NULL),
6251 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
6253 if (event != NULL && err == CL_SUCCESS)
6259 #if defined(CL_VERSION_1_2)
6261 * Enqueues a marker command which waits for either a list of events to complete,
6262 * or all previously enqueued commands to complete.
6264 * Enqueues a marker command which waits for either a list of events to complete,
6265 * or if the list is empty it waits for all commands previously enqueued in command_queue
6266 * to complete before it completes. This command returns an event which can be waited on,
6267 * i.e. this event can be waited on to insure that all events either in the event_wait_list
6268 * or all previously enqueued commands, queued before this command to command_queue,
6271 cl_int enqueueMarkerWithWaitList(
6272 const VECTOR_CLASS<Event> *events = 0,
6273 Event *event = 0) const
6276 cl_int err = detail::errHandler(
6277 ::clEnqueueMarkerWithWaitList(
6279 (events != NULL) ? (cl_uint) events->size() : 0,
6280 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
6281 (event != NULL) ? &tmp : NULL),
6282 __ENQUEUE_MARKER_WAIT_LIST_ERR);
6284 if (event != NULL && err == CL_SUCCESS)
6291 * A synchronization point that enqueues a barrier operation.
6293 * Enqueues a barrier command which waits for either a list of events to complete,
6294 * or if the list is empty it waits for all commands previously enqueued in command_queue
6295 * to complete before it completes. This command blocks command execution, that is, any
6296 * following commands enqueued after it do not execute until it completes. This command
6297 * returns an event which can be waited on, i.e. this event can be waited on to insure that
6298 * all events either in the event_wait_list or all previously enqueued commands, queued
6299 * before this command to command_queue, have completed.
6301 cl_int enqueueBarrierWithWaitList(
6302 const VECTOR_CLASS<Event> *events = 0,
6303 Event *event = 0) const
6306 cl_int err = detail::errHandler(
6307 ::clEnqueueBarrierWithWaitList(
6309 (events != NULL) ? (cl_uint) events->size() : 0,
6310 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
6311 (event != NULL) ? &tmp : NULL),
6312 __ENQUEUE_BARRIER_WAIT_LIST_ERR);
6314 if (event != NULL && err == CL_SUCCESS)
6321 * Enqueues a command to indicate with which device a set of memory objects
6322 * should be associated.
6324 cl_int enqueueMigrateMemObjects(
6325 const VECTOR_CLASS<Memory> &memObjects,
6326 cl_mem_migration_flags flags,
6327 const VECTOR_CLASS<Event>* events = NULL,
6333 cl_mem* localMemObjects = static_cast<cl_mem*>(alloca(memObjects.size() * sizeof(cl_mem)));
6334 for( int i = 0; i < (int)memObjects.size(); ++i ) {
6335 localMemObjects[i] = memObjects[i]();
6339 cl_int err = detail::errHandler(
6340 ::clEnqueueMigrateMemObjects(
6342 (cl_uint)memObjects.size(),
6343 static_cast<const cl_mem*>(localMemObjects),
6345 (events != NULL) ? (cl_uint) events->size() : 0,
6346 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
6347 (event != NULL) ? &tmp : NULL),
6348 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
6350 if (event != NULL && err == CL_SUCCESS)
6355 #endif // #if defined(CL_VERSION_1_2)
6357 cl_int enqueueNDRangeKernel(
6358 const Kernel& kernel,
6359 const NDRange& offset,
6360 const NDRange& global,
6361 const NDRange& local = NullRange,
6362 const VECTOR_CLASS<Event>* events = NULL,
6363 Event* event = NULL) const
6366 cl_int err = detail::errHandler(
6367 ::clEnqueueNDRangeKernel(
6368 object_, kernel(), (cl_uint) global.dimensions(),
6369 offset.dimensions() != 0 ? (const ::size_t*) offset : NULL,
6370 (const ::size_t*) global,
6371 local.dimensions() != 0 ? (const ::size_t*) local : NULL,
6372 (events != NULL) ? (cl_uint) events->size() : 0,
6373 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
6374 (event != NULL) ? &tmp : NULL),
6375 __ENQUEUE_NDRANGE_KERNEL_ERR);
6377 if (event != NULL && err == CL_SUCCESS)
6384 const Kernel& kernel,
6385 const VECTOR_CLASS<Event>* events = NULL,
6386 Event* event = NULL) const
6389 cl_int err = detail::errHandler(
6392 (events != NULL) ? (cl_uint) events->size() : 0,
6393 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
6394 (event != NULL) ? &tmp : NULL),
6395 __ENQUEUE_TASK_ERR);
6397 if (event != NULL && err == CL_SUCCESS)
6403 cl_int enqueueNativeKernel(
6404 void (CL_CALLBACK *userFptr)(void *),
6405 std::pair<void*, ::size_t> args,
6406 const VECTOR_CLASS<Memory>* mem_objects = NULL,
6407 const VECTOR_CLASS<const void*>* mem_locs = NULL,
6408 const VECTOR_CLASS<Event>* events = NULL,
6409 Event* event = NULL) const
6411 cl_mem * mems = (mem_objects != NULL && mem_objects->size() > 0)
6412 ? (cl_mem*) alloca(mem_objects->size() * sizeof(cl_mem))
6416 for (unsigned int i = 0; i < mem_objects->size(); i++) {
6417 mems[i] = ((*mem_objects)[i])();
6422 cl_int err = detail::errHandler(
6423 ::clEnqueueNativeKernel(
6424 object_, userFptr, args.first, args.second,
6425 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
6427 (mem_locs != NULL && mem_locs->size() > 0) ? (const void **) &mem_locs->front() : NULL,
6428 (events != NULL) ? (cl_uint) events->size() : 0,
6429 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
6430 (event != NULL) ? &tmp : NULL),
6431 __ENQUEUE_NATIVE_KERNEL);
6433 if (event != NULL && err == CL_SUCCESS)
6440 * Deprecated APIs for 1.2
6442 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) || (defined(CL_VERSION_1_1) && !defined(CL_VERSION_1_2))
6443 CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
6444 cl_int enqueueMarker(Event* event = NULL) const CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
6447 cl_int err = detail::errHandler(
6450 (event != NULL) ? &tmp : NULL),
6451 __ENQUEUE_MARKER_ERR);
6453 if (event != NULL && err == CL_SUCCESS)
6459 CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
6460 cl_int enqueueWaitForEvents(const VECTOR_CLASS<Event>& events) const CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
6462 return detail::errHandler(
6463 ::clEnqueueWaitForEvents(
6465 (cl_uint) events.size(),
6466 events.size() > 0 ? (const cl_event*) &events.front() : NULL),
6467 __ENQUEUE_WAIT_FOR_EVENTS_ERR);
6469 #endif // #if defined(CL_VERSION_1_1)
6471 cl_int enqueueAcquireGLObjects(
6472 const VECTOR_CLASS<Memory>* mem_objects = NULL,
6473 const VECTOR_CLASS<Event>* events = NULL,
6474 Event* event = NULL) const
6477 cl_int err = detail::errHandler(
6478 ::clEnqueueAcquireGLObjects(
6480 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
6481 (mem_objects != NULL && mem_objects->size() > 0) ? (const cl_mem *) &mem_objects->front(): NULL,
6482 (events != NULL) ? (cl_uint) events->size() : 0,
6483 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
6484 (event != NULL) ? &tmp : NULL),
6485 __ENQUEUE_ACQUIRE_GL_ERR);
6487 if (event != NULL && err == CL_SUCCESS)
6493 cl_int enqueueReleaseGLObjects(
6494 const VECTOR_CLASS<Memory>* mem_objects = NULL,
6495 const VECTOR_CLASS<Event>* events = NULL,
6496 Event* event = NULL) const
6499 cl_int err = detail::errHandler(
6500 ::clEnqueueReleaseGLObjects(
6502 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
6503 (mem_objects != NULL && mem_objects->size() > 0) ? (const cl_mem *) &mem_objects->front(): NULL,
6504 (events != NULL) ? (cl_uint) events->size() : 0,
6505 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
6506 (event != NULL) ? &tmp : NULL),
6507 __ENQUEUE_RELEASE_GL_ERR);
6509 if (event != NULL && err == CL_SUCCESS)
6515 #if defined (USE_DX_INTEROP)
6516 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueAcquireD3D10ObjectsKHR)(
6517 cl_command_queue command_queue, cl_uint num_objects,
6518 const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
6519 const cl_event* event_wait_list, cl_event* event);
6520 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueReleaseD3D10ObjectsKHR)(
6521 cl_command_queue command_queue, cl_uint num_objects,
6522 const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
6523 const cl_event* event_wait_list, cl_event* event);
6525 cl_int enqueueAcquireD3D10Objects(
6526 const VECTOR_CLASS<Memory>* mem_objects = NULL,
6527 const VECTOR_CLASS<Event>* events = NULL,
6528 Event* event = NULL) const
6530 static PFN_clEnqueueAcquireD3D10ObjectsKHR pfn_clEnqueueAcquireD3D10ObjectsKHR = NULL;
6531 #if defined(CL_VERSION_1_2)
6532 cl_context context = getInfo<CL_QUEUE_CONTEXT>();
6533 cl::Device device(getInfo<CL_QUEUE_DEVICE>());
6534 cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>();
6535 __INIT_CL_EXT_FCN_PTR_PLATFORM(platform, clEnqueueAcquireD3D10ObjectsKHR);
6537 #if defined(CL_VERSION_1_1)
6538 __INIT_CL_EXT_FCN_PTR(clEnqueueAcquireD3D10ObjectsKHR);
6542 cl_int err = detail::errHandler(
6543 pfn_clEnqueueAcquireD3D10ObjectsKHR(
6545 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
6546 (mem_objects != NULL && mem_objects->size() > 0) ? (const cl_mem *) &mem_objects->front(): NULL,
6547 (events != NULL) ? (cl_uint) events->size() : 0,
6548 (events != NULL) ? (cl_event*) &events->front() : NULL,
6549 (event != NULL) ? &tmp : NULL),
6550 __ENQUEUE_ACQUIRE_GL_ERR);
6552 if (event != NULL && err == CL_SUCCESS)
6558 cl_int enqueueReleaseD3D10Objects(
6559 const VECTOR_CLASS<Memory>* mem_objects = NULL,
6560 const VECTOR_CLASS<Event>* events = NULL,
6561 Event* event = NULL) const
6563 static PFN_clEnqueueReleaseD3D10ObjectsKHR pfn_clEnqueueReleaseD3D10ObjectsKHR = NULL;
6564 #if defined(CL_VERSION_1_2)
6565 cl_context context = getInfo<CL_QUEUE_CONTEXT>();
6566 cl::Device device(getInfo<CL_QUEUE_DEVICE>());
6567 cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>();
6568 __INIT_CL_EXT_FCN_PTR_PLATFORM(platform, clEnqueueReleaseD3D10ObjectsKHR);
6569 #endif // #if defined(CL_VERSION_1_2)
6570 #if defined(CL_VERSION_1_1)
6571 __INIT_CL_EXT_FCN_PTR(clEnqueueReleaseD3D10ObjectsKHR);
6572 #endif // #if defined(CL_VERSION_1_1)
6575 cl_int err = detail::errHandler(
6576 pfn_clEnqueueReleaseD3D10ObjectsKHR(
6578 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
6579 (mem_objects != NULL && mem_objects->size() > 0) ? (const cl_mem *) &mem_objects->front(): NULL,
6580 (events != NULL) ? (cl_uint) events->size() : 0,
6581 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
6582 (event != NULL) ? &tmp : NULL),
6583 __ENQUEUE_RELEASE_GL_ERR);
6585 if (event != NULL && err == CL_SUCCESS)
6593 * Deprecated APIs for 1.2
6595 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) || (defined(CL_VERSION_1_1) && !defined(CL_VERSION_1_2))
6596 CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
6597 cl_int enqueueBarrier() const CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
6599 return detail::errHandler(
6600 ::clEnqueueBarrier(object_),
6601 __ENQUEUE_BARRIER_ERR);
6603 #endif // #if defined(CL_VERSION_1_1)
6605 cl_int flush() const
6607 return detail::errHandler(::clFlush(object_), __FLUSH_ERR);
6610 cl_int finish() const
6612 return detail::errHandler(::clFinish(object_), __FINISH_ERR);
6616 #ifdef CL_HPP_CPP11_ATOMICS_SUPPORTED
6617 CL_WEAK_ATTRIB_PREFIX std::atomic<int> CL_WEAK_ATTRIB_SUFFIX CommandQueue::default_initialized_;
6618 #else // !CL_HPP_CPP11_ATOMICS_SUPPORTED
6619 CL_WEAK_ATTRIB_PREFIX volatile int CL_WEAK_ATTRIB_SUFFIX CommandQueue::default_initialized_ = __DEFAULT_NOT_INITIALIZED;
6620 #endif // !CL_HPP_CPP11_ATOMICS_SUPPORTED
6622 CL_WEAK_ATTRIB_PREFIX CommandQueue CL_WEAK_ATTRIB_SUFFIX CommandQueue::default_;
6623 CL_WEAK_ATTRIB_PREFIX volatile cl_int CL_WEAK_ATTRIB_SUFFIX CommandQueue::default_error_ = CL_SUCCESS;
6625 template< typename IteratorType >
6627 const Context &context,
6628 IteratorType startIterator,
6629 IteratorType endIterator,
6634 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
6637 cl_mem_flags flags = 0;
6639 flags |= CL_MEM_READ_ONLY;
6642 flags |= CL_MEM_READ_WRITE;
6645 flags |= CL_MEM_USE_HOST_PTR;
6648 ::size_t size = sizeof(DataType)*(endIterator - startIterator);
6651 object_ = ::clCreateBuffer(context(), flags, size, static_cast<DataType*>(&*startIterator), &error);
6653 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
6656 detail::errHandler(error, __CREATE_BUFFER_ERR);
6662 CommandQueue queue(context, 0, &error);
6663 detail::errHandler(error, __CREATE_BUFFER_ERR);
6668 error = cl::copy(queue, startIterator, endIterator, *this);
6669 detail::errHandler(error, __CREATE_BUFFER_ERR);
6676 template< typename IteratorType >
6678 const CommandQueue &queue,
6679 IteratorType startIterator,
6680 IteratorType endIterator,
6685 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
6688 cl_mem_flags flags = 0;
6690 flags |= CL_MEM_READ_ONLY;
6693 flags |= CL_MEM_READ_WRITE;
6696 flags |= CL_MEM_USE_HOST_PTR;
6699 ::size_t size = sizeof(DataType)*(endIterator - startIterator);
6701 Context context = queue.getInfo<CL_QUEUE_CONTEXT>();
6704 object_ = ::clCreateBuffer(context(), flags, size, static_cast<DataType*>(&*startIterator), &error);
6707 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
6710 detail::errHandler(error, __CREATE_BUFFER_ERR);
6716 error = cl::copy(queue, startIterator, endIterator, *this);
6717 detail::errHandler(error, __CREATE_BUFFER_ERR);
6724 inline cl_int enqueueReadBuffer(
6725 const Buffer& buffer,
6730 const VECTOR_CLASS<Event>* events = NULL,
6731 Event* event = NULL)
6734 CommandQueue queue = CommandQueue::getDefault(&error);
6736 if (error != CL_SUCCESS) {
6740 return queue.enqueueReadBuffer(buffer, blocking, offset, size, ptr, events, event);
6743 inline cl_int enqueueWriteBuffer(
6744 const Buffer& buffer,
6749 const VECTOR_CLASS<Event>* events = NULL,
6750 Event* event = NULL)
6753 CommandQueue queue = CommandQueue::getDefault(&error);
6755 if (error != CL_SUCCESS) {
6759 return queue.enqueueWriteBuffer(buffer, blocking, offset, size, ptr, events, event);
6762 inline void* enqueueMapBuffer(
6763 const Buffer& buffer,
6768 const VECTOR_CLASS<Event>* events = NULL,
6769 Event* event = NULL,
6773 CommandQueue queue = CommandQueue::getDefault(&error);
6774 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
6779 void * result = ::clEnqueueMapBuffer(
6780 queue(), buffer(), blocking, flags, offset, size,
6781 (events != NULL) ? (cl_uint) events->size() : 0,
6782 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
6786 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
6793 inline cl_int enqueueUnmapMemObject(
6794 const Memory& memory,
6796 const VECTOR_CLASS<Event>* events = NULL,
6797 Event* event = NULL)
6800 CommandQueue queue = CommandQueue::getDefault(&error);
6801 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
6802 if (error != CL_SUCCESS) {
6807 cl_int err = detail::errHandler(
6808 ::clEnqueueUnmapMemObject(
6809 queue(), memory(), mapped_ptr,
6810 (events != NULL) ? (cl_uint) events->size() : 0,
6811 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
6812 (event != NULL) ? &tmp : NULL),
6813 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
6815 if (event != NULL && err == CL_SUCCESS)
6821 inline cl_int enqueueCopyBuffer(
6824 ::size_t src_offset,
6825 ::size_t dst_offset,
6827 const VECTOR_CLASS<Event>* events = NULL,
6828 Event* event = NULL)
6831 CommandQueue queue = CommandQueue::getDefault(&error);
6833 if (error != CL_SUCCESS) {
6837 return queue.enqueueCopyBuffer(src, dst, src_offset, dst_offset, size, events, event);
6841 * Blocking copy operation between iterators and a buffer.
6843 * Uses default command queue.
6845 template< typename IteratorType >
6846 inline cl_int copy( IteratorType startIterator, IteratorType endIterator, cl::Buffer &buffer )
6849 CommandQueue queue = CommandQueue::getDefault(&error);
6850 if (error != CL_SUCCESS)
6853 return cl::copy(queue, startIterator, endIterator, buffer);
6857 * Blocking copy operation between iterators and a buffer.
6859 * Uses default command queue.
6861 template< typename IteratorType >
6862 inline cl_int copy( const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator )
6865 CommandQueue queue = CommandQueue::getDefault(&error);
6866 if (error != CL_SUCCESS)
6869 return cl::copy(queue, buffer, startIterator, endIterator);
6873 * Blocking copy operation between iterators and a buffer.
6875 * Uses specified queue.
6877 template< typename IteratorType >
6878 inline cl_int copy( const CommandQueue &queue, IteratorType startIterator, IteratorType endIterator, cl::Buffer &buffer )
6880 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
6883 ::size_t length = endIterator-startIterator;
6884 ::size_t byteLength = length*sizeof(DataType);
6887 static_cast<DataType*>(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_WRITE, 0, byteLength, 0, 0, &error));
6888 // if exceptions enabled, enqueueMapBuffer will throw
6889 if( error != CL_SUCCESS ) {
6892 #if defined(_MSC_VER)
6896 stdext::checked_array_iterator<DataType*>(
6899 std::copy(startIterator, endIterator, pointer);
6902 error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
6903 // if exceptions enabled, enqueueUnmapMemObject will throw
6904 if( error != CL_SUCCESS ) {
6912 * Blocking copy operation between iterators and a buffer.
6914 * Uses specified queue.
6916 template< typename IteratorType >
6917 inline cl_int copy( const CommandQueue &queue, const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator )
6919 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
6922 ::size_t length = endIterator-startIterator;
6923 ::size_t byteLength = length*sizeof(DataType);
6926 static_cast<DataType*>(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_READ, 0, byteLength, 0, 0, &error));
6927 // if exceptions enabled, enqueueMapBuffer will throw
6928 if( error != CL_SUCCESS ) {
6931 std::copy(pointer, pointer + length, startIterator);
6933 error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
6934 // if exceptions enabled, enqueueUnmapMemObject will throw
6935 if( error != CL_SUCCESS ) {
6942 #if defined(CL_VERSION_1_1)
6943 inline cl_int enqueueReadBufferRect(
6944 const Buffer& buffer,
6946 const size_t<3>& buffer_offset,
6947 const size_t<3>& host_offset,
6948 const size_t<3>& region,
6949 ::size_t buffer_row_pitch,
6950 ::size_t buffer_slice_pitch,
6951 ::size_t host_row_pitch,
6952 ::size_t host_slice_pitch,
6954 const VECTOR_CLASS<Event>* events = NULL,
6955 Event* event = NULL)
6958 CommandQueue queue = CommandQueue::getDefault(&error);
6960 if (error != CL_SUCCESS) {
6964 return queue.enqueueReadBufferRect(
6979 inline cl_int enqueueWriteBufferRect(
6980 const Buffer& buffer,
6982 const size_t<3>& buffer_offset,
6983 const size_t<3>& host_offset,
6984 const size_t<3>& region,
6985 ::size_t buffer_row_pitch,
6986 ::size_t buffer_slice_pitch,
6987 ::size_t host_row_pitch,
6988 ::size_t host_slice_pitch,
6990 const VECTOR_CLASS<Event>* events = NULL,
6991 Event* event = NULL)
6994 CommandQueue queue = CommandQueue::getDefault(&error);
6996 if (error != CL_SUCCESS) {
7000 return queue.enqueueWriteBufferRect(
7015 inline cl_int enqueueCopyBufferRect(
7018 const size_t<3>& src_origin,
7019 const size_t<3>& dst_origin,
7020 const size_t<3>& region,
7021 ::size_t src_row_pitch,
7022 ::size_t src_slice_pitch,
7023 ::size_t dst_row_pitch,
7024 ::size_t dst_slice_pitch,
7025 const VECTOR_CLASS<Event>* events = NULL,
7026 Event* event = NULL)
7029 CommandQueue queue = CommandQueue::getDefault(&error);
7031 if (error != CL_SUCCESS) {
7035 return queue.enqueueCopyBufferRect(
7050 inline cl_int enqueueReadImage(
7053 const size_t<3>& origin,
7054 const size_t<3>& region,
7056 ::size_t slice_pitch,
7058 const VECTOR_CLASS<Event>* events = NULL,
7059 Event* event = NULL)
7062 CommandQueue queue = CommandQueue::getDefault(&error);
7064 if (error != CL_SUCCESS) {
7068 return queue.enqueueReadImage(
7080 inline cl_int enqueueWriteImage(
7083 const size_t<3>& origin,
7084 const size_t<3>& region,
7086 ::size_t slice_pitch,
7088 const VECTOR_CLASS<Event>* events = NULL,
7089 Event* event = NULL)
7092 CommandQueue queue = CommandQueue::getDefault(&error);
7094 if (error != CL_SUCCESS) {
7098 return queue.enqueueWriteImage(
7110 inline cl_int enqueueCopyImage(
7113 const size_t<3>& src_origin,
7114 const size_t<3>& dst_origin,
7115 const size_t<3>& region,
7116 const VECTOR_CLASS<Event>* events = NULL,
7117 Event* event = NULL)
7120 CommandQueue queue = CommandQueue::getDefault(&error);
7122 if (error != CL_SUCCESS) {
7126 return queue.enqueueCopyImage(
7136 inline cl_int enqueueCopyImageToBuffer(
7139 const size_t<3>& src_origin,
7140 const size_t<3>& region,
7141 ::size_t dst_offset,
7142 const VECTOR_CLASS<Event>* events = NULL,
7143 Event* event = NULL)
7146 CommandQueue queue = CommandQueue::getDefault(&error);
7148 if (error != CL_SUCCESS) {
7152 return queue.enqueueCopyImageToBuffer(
7162 inline cl_int enqueueCopyBufferToImage(
7165 ::size_t src_offset,
7166 const size_t<3>& dst_origin,
7167 const size_t<3>& region,
7168 const VECTOR_CLASS<Event>* events = NULL,
7169 Event* event = NULL)
7172 CommandQueue queue = CommandQueue::getDefault(&error);
7174 if (error != CL_SUCCESS) {
7178 return queue.enqueueCopyBufferToImage(
7189 inline cl_int flush(void)
7192 CommandQueue queue = CommandQueue::getDefault(&error);
7194 if (error != CL_SUCCESS) {
7198 return queue.flush();
7201 inline cl_int finish(void)
7204 CommandQueue queue = CommandQueue::getDefault(&error);
7206 if (error != CL_SUCCESS) {
7211 return queue.finish();
7214 // Kernel Functor support
7215 // New interface as of September 2011
7216 // Requires the C++11 std::tr1::function (note do not support TR1)
7217 // Visual Studio 2010 and GCC 4.2
7221 CommandQueue queue_;
7222 const NDRange offset_;
7223 const NDRange global_;
7224 const NDRange local_;
7225 VECTOR_CLASS<Event> events_;
7227 EnqueueArgs(NDRange global) :
7228 queue_(CommandQueue::getDefault()),
7236 EnqueueArgs(NDRange global, NDRange local) :
7237 queue_(CommandQueue::getDefault()),
7245 EnqueueArgs(NDRange offset, NDRange global, NDRange local) :
7246 queue_(CommandQueue::getDefault()),
7254 EnqueueArgs(Event e, NDRange global) :
7255 queue_(CommandQueue::getDefault()),
7260 events_.push_back(e);
7263 EnqueueArgs(Event e, NDRange global, NDRange local) :
7264 queue_(CommandQueue::getDefault()),
7269 events_.push_back(e);
7272 EnqueueArgs(Event e, NDRange offset, NDRange global, NDRange local) :
7273 queue_(CommandQueue::getDefault()),
7278 events_.push_back(e);
7281 EnqueueArgs(const VECTOR_CLASS<Event> &events, NDRange global) :
7282 queue_(CommandQueue::getDefault()),
7291 EnqueueArgs(const VECTOR_CLASS<Event> &events, NDRange global, NDRange local) :
7292 queue_(CommandQueue::getDefault()),
7301 EnqueueArgs(const VECTOR_CLASS<Event> &events, NDRange offset, NDRange global, NDRange local) :
7302 queue_(CommandQueue::getDefault()),
7311 EnqueueArgs(CommandQueue &queue, NDRange global) :
7320 EnqueueArgs(CommandQueue &queue, NDRange global, NDRange local) :
7329 EnqueueArgs(CommandQueue &queue, NDRange offset, NDRange global, NDRange local) :
7338 EnqueueArgs(CommandQueue &queue, Event e, NDRange global) :
7344 events_.push_back(e);
7347 EnqueueArgs(CommandQueue &queue, Event e, NDRange global, NDRange local) :
7353 events_.push_back(e);
7356 EnqueueArgs(CommandQueue &queue, Event e, NDRange offset, NDRange global, NDRange local) :
7362 events_.push_back(e);
7365 EnqueueArgs(CommandQueue &queue, const VECTOR_CLASS<Event> &events, NDRange global) :
7375 EnqueueArgs(CommandQueue &queue, const VECTOR_CLASS<Event> &events, NDRange global, NDRange local) :
7385 EnqueueArgs(CommandQueue &queue, const VECTOR_CLASS<Event> &events, NDRange offset, NDRange global, NDRange local) :
7400 template<int index, typename T0>
7403 static void set (Kernel kernel, T0 arg)
7405 kernel.setArg(index, arg);
7410 struct SetArg<index, NullType>
7412 static void set (Kernel, NullType)
7418 typename T0, typename T1, typename T2, typename T3,
7419 typename T4, typename T5, typename T6, typename T7,
7420 typename T8, typename T9, typename T10, typename T11,
7421 typename T12, typename T13, typename T14, typename T15,
7422 typename T16, typename T17, typename T18, typename T19,
7423 typename T20, typename T21, typename T22, typename T23,
7424 typename T24, typename T25, typename T26, typename T27,
7425 typename T28, typename T29, typename T30, typename T31
7427 class KernelFunctorGlobal
7433 KernelFunctorGlobal(
7438 KernelFunctorGlobal(
7439 const Program& program,
7440 const STRING_CLASS name,
7441 cl_int * err = NULL) :
7442 kernel_(program, name.c_str(), err)
7446 const EnqueueArgs& args,
7457 T10 t10 = NullType(),
7458 T11 t11 = NullType(),
7459 T12 t12 = NullType(),
7460 T13 t13 = NullType(),
7461 T14 t14 = NullType(),
7462 T15 t15 = NullType(),
7463 T16 t16 = NullType(),
7464 T17 t17 = NullType(),
7465 T18 t18 = NullType(),
7466 T19 t19 = NullType(),
7467 T20 t20 = NullType(),
7468 T21 t21 = NullType(),
7469 T22 t22 = NullType(),
7470 T23 t23 = NullType(),
7471 T24 t24 = NullType(),
7472 T25 t25 = NullType(),
7473 T26 t26 = NullType(),
7474 T27 t27 = NullType(),
7475 T28 t28 = NullType(),
7476 T29 t29 = NullType(),
7477 T30 t30 = NullType(),
7478 T31 t31 = NullType()
7482 SetArg<0, T0>::set(kernel_, t0);
7483 SetArg<1, T1>::set(kernel_, t1);
7484 SetArg<2, T2>::set(kernel_, t2);
7485 SetArg<3, T3>::set(kernel_, t3);
7486 SetArg<4, T4>::set(kernel_, t4);
7487 SetArg<5, T5>::set(kernel_, t5);
7488 SetArg<6, T6>::set(kernel_, t6);
7489 SetArg<7, T7>::set(kernel_, t7);
7490 SetArg<8, T8>::set(kernel_, t8);
7491 SetArg<9, T9>::set(kernel_, t9);
7492 SetArg<10, T10>::set(kernel_, t10);
7493 SetArg<11, T11>::set(kernel_, t11);
7494 SetArg<12, T12>::set(kernel_, t12);
7495 SetArg<13, T13>::set(kernel_, t13);
7496 SetArg<14, T14>::set(kernel_, t14);
7497 SetArg<15, T15>::set(kernel_, t15);
7498 SetArg<16, T16>::set(kernel_, t16);
7499 SetArg<17, T17>::set(kernel_, t17);
7500 SetArg<18, T18>::set(kernel_, t18);
7501 SetArg<19, T19>::set(kernel_, t19);
7502 SetArg<20, T20>::set(kernel_, t20);
7503 SetArg<21, T21>::set(kernel_, t21);
7504 SetArg<22, T22>::set(kernel_, t22);
7505 SetArg<23, T23>::set(kernel_, t23);
7506 SetArg<24, T24>::set(kernel_, t24);
7507 SetArg<25, T25>::set(kernel_, t25);
7508 SetArg<26, T26>::set(kernel_, t26);
7509 SetArg<27, T27>::set(kernel_, t27);
7510 SetArg<28, T28>::set(kernel_, t28);
7511 SetArg<29, T29>::set(kernel_, t29);
7512 SetArg<30, T30>::set(kernel_, t30);
7513 SetArg<31, T31>::set(kernel_, t31);
7515 args.queue_.enqueueNDRangeKernel(
7528 //------------------------------------------------------------------------------------------------------
7564 struct functionImplementation_
7566 typedef detail::KernelFunctorGlobal<
7600 FunctorType functor_;
7602 functionImplementation_(const FunctorType &functor) :
7606 #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 32))
7607 // Fail variadic expansion for dev11
7608 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it.");
7613 //! \brief Return type of the functor
7614 typedef Event result_type;
7616 //! \brief Function signature of kernel functor with no event dependency.
7617 typedef Event type_(
7653 const EnqueueArgs& enqueueArgs,
7758 struct functionImplementation_
7792 typedef detail::KernelFunctorGlobal<
7824 NullType> FunctorType;
7826 FunctorType functor_;
7828 functionImplementation_(const FunctorType &functor) :
7832 #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 31))
7833 // Fail variadic expansion for dev11
7834 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it.");
7839 //! \brief Return type of the functor
7840 typedef Event result_type;
7842 //! \brief Function signature of kernel functor with no event dependency.
7843 typedef Event type_(
7878 const EnqueueArgs& enqueueArgs,
7980 struct functionImplementation_
8014 typedef detail::KernelFunctorGlobal<
8046 NullType> FunctorType;
8048 FunctorType functor_;
8050 functionImplementation_(const FunctorType &functor) :
8054 #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 30))
8055 // Fail variadic expansion for dev11
8056 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it.");
8061 //! \brief Return type of the functor
8062 typedef Event result_type;
8064 //! \brief Function signature of kernel functor with no event dependency.
8065 typedef Event type_(
8099 const EnqueueArgs& enqueueArgs,
8198 struct functionImplementation_
8232 typedef detail::KernelFunctorGlobal<
8264 NullType> FunctorType;
8266 FunctorType functor_;
8268 functionImplementation_(const FunctorType &functor) :
8272 #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 29))
8273 // Fail variadic expansion for dev11
8274 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it.");
8279 //! \brief Return type of the functor
8280 typedef Event result_type;
8282 //! \brief Function signature of kernel functor with no event dependency.
8283 typedef Event type_(
8316 const EnqueueArgs& enqueueArgs,
8412 struct functionImplementation_
8446 typedef detail::KernelFunctorGlobal<
8478 NullType> FunctorType;
8480 FunctorType functor_;
8482 functionImplementation_(const FunctorType &functor) :
8486 #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 28))
8487 // Fail variadic expansion for dev11
8488 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it.");
8493 //! \brief Return type of the functor
8494 typedef Event result_type;
8496 //! \brief Function signature of kernel functor with no event dependency.
8497 typedef Event type_(
8529 const EnqueueArgs& enqueueArgs,
8622 struct functionImplementation_
8656 typedef detail::KernelFunctorGlobal<
8688 NullType> FunctorType;
8690 FunctorType functor_;
8692 functionImplementation_(const FunctorType &functor) :
8696 #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 27))
8697 // Fail variadic expansion for dev11
8698 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it.");
8703 //! \brief Return type of the functor
8704 typedef Event result_type;
8706 //! \brief Function signature of kernel functor with no event dependency.
8707 typedef Event type_(
8738 const EnqueueArgs& enqueueArgs,
8828 struct functionImplementation_
8862 typedef detail::KernelFunctorGlobal<
8894 NullType> FunctorType;
8896 FunctorType functor_;
8898 functionImplementation_(const FunctorType &functor) :
8902 #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 26))
8903 // Fail variadic expansion for dev11
8904 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it.");
8909 //! \brief Return type of the functor
8910 typedef Event result_type;
8912 //! \brief Function signature of kernel functor with no event dependency.
8913 typedef Event type_(
8943 const EnqueueArgs& enqueueArgs,
9030 struct functionImplementation_
9064 typedef detail::KernelFunctorGlobal<
9096 NullType> FunctorType;
9098 FunctorType functor_;
9100 functionImplementation_(const FunctorType &functor) :
9104 #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 25))
9105 // Fail variadic expansion for dev11
9106 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it.");
9111 //! \brief Return type of the functor
9112 typedef Event result_type;
9114 //! \brief Function signature of kernel functor with no event dependency.
9115 typedef Event type_(
9144 const EnqueueArgs& enqueueArgs,
9228 struct functionImplementation_
9262 typedef detail::KernelFunctorGlobal<
9294 NullType> FunctorType;
9296 FunctorType functor_;
9298 functionImplementation_(const FunctorType &functor) :
9302 #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 24))
9303 // Fail variadic expansion for dev11
9304 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it.");
9309 //! \brief Return type of the functor
9310 typedef Event result_type;
9312 //! \brief Function signature of kernel functor with no event dependency.
9313 typedef Event type_(
9341 const EnqueueArgs& enqueueArgs,
9422 struct functionImplementation_
9456 typedef detail::KernelFunctorGlobal<
9488 NullType> FunctorType;
9490 FunctorType functor_;
9492 functionImplementation_(const FunctorType &functor) :
9496 #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 23))
9497 // Fail variadic expansion for dev11
9498 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it.");
9503 //! \brief Return type of the functor
9504 typedef Event result_type;
9506 //! \brief Function signature of kernel functor with no event dependency.
9507 typedef Event type_(
9534 const EnqueueArgs& enqueueArgs,
9612 struct functionImplementation_
9646 typedef detail::KernelFunctorGlobal<
9678 NullType> FunctorType;
9680 FunctorType functor_;
9682 functionImplementation_(const FunctorType &functor) :
9686 #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 22))
9687 // Fail variadic expansion for dev11
9688 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it.");
9693 //! \brief Return type of the functor
9694 typedef Event result_type;
9696 //! \brief Function signature of kernel functor with no event dependency.
9697 typedef Event type_(
9723 const EnqueueArgs& enqueueArgs,
9798 struct functionImplementation_
9832 typedef detail::KernelFunctorGlobal<
9864 NullType> FunctorType;
9866 FunctorType functor_;
9868 functionImplementation_(const FunctorType &functor) :
9872 #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 21))
9873 // Fail variadic expansion for dev11
9874 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it.");
9879 //! \brief Return type of the functor
9880 typedef Event result_type;
9882 //! \brief Function signature of kernel functor with no event dependency.
9883 typedef Event type_(
9908 const EnqueueArgs& enqueueArgs,
9980 struct functionImplementation_
10014 typedef detail::KernelFunctorGlobal<
10046 NullType> FunctorType;
10048 FunctorType functor_;
10050 functionImplementation_(const FunctorType &functor) :
10054 #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 20))
10055 // Fail variadic expansion for dev11
10056 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it.");
10061 //! \brief Return type of the functor
10062 typedef Event result_type;
10064 //! \brief Function signature of kernel functor with no event dependency.
10065 typedef Event type_(
10066 const EnqueueArgs&,
10089 const EnqueueArgs& enqueueArgs,
10158 struct functionImplementation_
10192 typedef detail::KernelFunctorGlobal<
10224 NullType> FunctorType;
10226 FunctorType functor_;
10228 functionImplementation_(const FunctorType &functor) :
10232 #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 19))
10233 // Fail variadic expansion for dev11
10234 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it.");
10239 //! \brief Return type of the functor
10240 typedef Event result_type;
10242 //! \brief Function signature of kernel functor with no event dependency.
10243 typedef Event type_(
10244 const EnqueueArgs&,
10266 const EnqueueArgs& enqueueArgs,
10332 struct functionImplementation_
10366 typedef detail::KernelFunctorGlobal<
10398 NullType> FunctorType;
10400 FunctorType functor_;
10402 functionImplementation_(const FunctorType &functor) :
10406 #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 18))
10407 // Fail variadic expansion for dev11
10408 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it.");
10413 //! \brief Return type of the functor
10414 typedef Event result_type;
10416 //! \brief Function signature of kernel functor with no event dependency.
10417 typedef Event type_(
10418 const EnqueueArgs&,
10439 const EnqueueArgs& enqueueArgs,
10502 struct functionImplementation_
10536 typedef detail::KernelFunctorGlobal<
10568 NullType> FunctorType;
10570 FunctorType functor_;
10572 functionImplementation_(const FunctorType &functor) :
10576 #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 17))
10577 // Fail variadic expansion for dev11
10578 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it.");
10583 //! \brief Return type of the functor
10584 typedef Event result_type;
10586 //! \brief Function signature of kernel functor with no event dependency.
10587 typedef Event type_(
10588 const EnqueueArgs&,
10608 const EnqueueArgs& enqueueArgs,
10668 struct functionImplementation_
10702 typedef detail::KernelFunctorGlobal<
10734 NullType> FunctorType;
10736 FunctorType functor_;
10738 functionImplementation_(const FunctorType &functor) :
10742 #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 16))
10743 // Fail variadic expansion for dev11
10744 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it.");
10749 //! \brief Return type of the functor
10750 typedef Event result_type;
10752 //! \brief Function signature of kernel functor with no event dependency.
10753 typedef Event type_(
10754 const EnqueueArgs&,
10773 const EnqueueArgs& enqueueArgs,
10830 struct functionImplementation_
10864 typedef detail::KernelFunctorGlobal<
10896 NullType> FunctorType;
10898 FunctorType functor_;
10900 functionImplementation_(const FunctorType &functor) :
10904 #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 15))
10905 // Fail variadic expansion for dev11
10906 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it.");
10911 //! \brief Return type of the functor
10912 typedef Event result_type;
10914 //! \brief Function signature of kernel functor with no event dependency.
10915 typedef Event type_(
10916 const EnqueueArgs&,
10934 const EnqueueArgs& enqueueArgs,
10988 struct functionImplementation_
11022 typedef detail::KernelFunctorGlobal<
11054 NullType> FunctorType;
11056 FunctorType functor_;
11058 functionImplementation_(const FunctorType &functor) :
11062 #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 14))
11063 // Fail variadic expansion for dev11
11064 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it.");
11069 //! \brief Return type of the functor
11070 typedef Event result_type;
11072 //! \brief Function signature of kernel functor with no event dependency.
11073 typedef Event type_(
11074 const EnqueueArgs&,
11091 const EnqueueArgs& enqueueArgs,
11142 struct functionImplementation_
11176 typedef detail::KernelFunctorGlobal<
11208 NullType> FunctorType;
11210 FunctorType functor_;
11212 functionImplementation_(const FunctorType &functor) :
11216 #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 13))
11217 // Fail variadic expansion for dev11
11218 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it.");
11223 //! \brief Return type of the functor
11224 typedef Event result_type;
11226 //! \brief Function signature of kernel functor with no event dependency.
11227 typedef Event type_(
11228 const EnqueueArgs&,
11244 const EnqueueArgs& enqueueArgs,
11292 struct functionImplementation_
11326 typedef detail::KernelFunctorGlobal<
11358 NullType> FunctorType;
11360 FunctorType functor_;
11362 functionImplementation_(const FunctorType &functor) :
11366 #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 12))
11367 // Fail variadic expansion for dev11
11368 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it.");
11373 //! \brief Return type of the functor
11374 typedef Event result_type;
11376 //! \brief Function signature of kernel functor with no event dependency.
11377 typedef Event type_(
11378 const EnqueueArgs&,
11393 const EnqueueArgs& enqueueArgs,
11438 struct functionImplementation_
11472 typedef detail::KernelFunctorGlobal<
11504 NullType> FunctorType;
11506 FunctorType functor_;
11508 functionImplementation_(const FunctorType &functor) :
11512 #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 11))
11513 // Fail variadic expansion for dev11
11514 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it.");
11519 //! \brief Return type of the functor
11520 typedef Event result_type;
11522 //! \brief Function signature of kernel functor with no event dependency.
11523 typedef Event type_(
11524 const EnqueueArgs&,
11538 const EnqueueArgs& enqueueArgs,
11580 struct functionImplementation_
11614 typedef detail::KernelFunctorGlobal<
11646 NullType> FunctorType;
11648 FunctorType functor_;
11650 functionImplementation_(const FunctorType &functor) :
11654 #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 10))
11655 // Fail variadic expansion for dev11
11656 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it.");
11661 //! \brief Return type of the functor
11662 typedef Event result_type;
11664 //! \brief Function signature of kernel functor with no event dependency.
11665 typedef Event type_(
11666 const EnqueueArgs&,
11679 const EnqueueArgs& enqueueArgs,
11718 struct functionImplementation_
11752 typedef detail::KernelFunctorGlobal<
11784 NullType> FunctorType;
11786 FunctorType functor_;
11788 functionImplementation_(const FunctorType &functor) :
11792 #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 9))
11793 // Fail variadic expansion for dev11
11794 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it.");
11799 //! \brief Return type of the functor
11800 typedef Event result_type;
11802 //! \brief Function signature of kernel functor with no event dependency.
11803 typedef Event type_(
11804 const EnqueueArgs&,
11816 const EnqueueArgs& enqueueArgs,
11852 struct functionImplementation_
11886 typedef detail::KernelFunctorGlobal<
11918 NullType> FunctorType;
11920 FunctorType functor_;
11922 functionImplementation_(const FunctorType &functor) :
11926 #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 8))
11927 // Fail variadic expansion for dev11
11928 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it.");
11933 //! \brief Return type of the functor
11934 typedef Event result_type;
11936 //! \brief Function signature of kernel functor with no event dependency.
11937 typedef Event type_(
11938 const EnqueueArgs&,
11949 const EnqueueArgs& enqueueArgs,
11982 struct functionImplementation_
12016 typedef detail::KernelFunctorGlobal<
12048 NullType> FunctorType;
12050 FunctorType functor_;
12052 functionImplementation_(const FunctorType &functor) :
12056 #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 7))
12057 // Fail variadic expansion for dev11
12058 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it.");
12063 //! \brief Return type of the functor
12064 typedef Event result_type;
12066 //! \brief Function signature of kernel functor with no event dependency.
12067 typedef Event type_(
12068 const EnqueueArgs&,
12078 const EnqueueArgs& enqueueArgs,
12108 struct functionImplementation_
12142 typedef detail::KernelFunctorGlobal<
12174 NullType> FunctorType;
12176 FunctorType functor_;
12178 functionImplementation_(const FunctorType &functor) :
12182 #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 6))
12183 // Fail variadic expansion for dev11
12184 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it.");
12189 //! \brief Return type of the functor
12190 typedef Event result_type;
12192 //! \brief Function signature of kernel functor with no event dependency.
12193 typedef Event type_(
12194 const EnqueueArgs&,
12203 const EnqueueArgs& enqueueArgs,
12230 struct functionImplementation_
12264 typedef detail::KernelFunctorGlobal<
12296 NullType> FunctorType;
12298 FunctorType functor_;
12300 functionImplementation_(const FunctorType &functor) :
12304 #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 5))
12305 // Fail variadic expansion for dev11
12306 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it.");
12311 //! \brief Return type of the functor
12312 typedef Event result_type;
12314 //! \brief Function signature of kernel functor with no event dependency.
12315 typedef Event type_(
12316 const EnqueueArgs&,
12324 const EnqueueArgs& enqueueArgs,
12348 struct functionImplementation_
12382 typedef detail::KernelFunctorGlobal<
12414 NullType> FunctorType;
12416 FunctorType functor_;
12418 functionImplementation_(const FunctorType &functor) :
12422 #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 4))
12423 // Fail variadic expansion for dev11
12424 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it.");
12429 //! \brief Return type of the functor
12430 typedef Event result_type;
12432 //! \brief Function signature of kernel functor with no event dependency.
12433 typedef Event type_(
12434 const EnqueueArgs&,
12441 const EnqueueArgs& enqueueArgs,
12462 struct functionImplementation_
12496 typedef detail::KernelFunctorGlobal<
12528 NullType> FunctorType;
12530 FunctorType functor_;
12532 functionImplementation_(const FunctorType &functor) :
12536 #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 3))
12537 // Fail variadic expansion for dev11
12538 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it.");
12543 //! \brief Return type of the functor
12544 typedef Event result_type;
12546 //! \brief Function signature of kernel functor with no event dependency.
12547 typedef Event type_(
12548 const EnqueueArgs&,
12554 const EnqueueArgs& enqueueArgs,
12572 struct functionImplementation_
12606 typedef detail::KernelFunctorGlobal<
12638 NullType> FunctorType;
12640 FunctorType functor_;
12642 functionImplementation_(const FunctorType &functor) :
12646 #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 2))
12647 // Fail variadic expansion for dev11
12648 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it.");
12653 //! \brief Return type of the functor
12654 typedef Event result_type;
12656 //! \brief Function signature of kernel functor with no event dependency.
12657 typedef Event type_(
12658 const EnqueueArgs&,
12663 const EnqueueArgs& enqueueArgs,
12678 struct functionImplementation_
12712 typedef detail::KernelFunctorGlobal<
12744 NullType> FunctorType;
12746 FunctorType functor_;
12748 functionImplementation_(const FunctorType &functor) :
12752 #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 1))
12753 // Fail variadic expansion for dev11
12754 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it.");
12759 //! \brief Return type of the functor
12760 typedef Event result_type;
12762 //! \brief Function signature of kernel functor with no event dependency.
12763 typedef Event type_(
12764 const EnqueueArgs&,
12768 const EnqueueArgs& enqueueArgs,
12783 } // namespace detail
12785 //----------------------------------------------------------------------------------------------
12788 typename T0, typename T1 = detail::NullType, typename T2 = detail::NullType,
12789 typename T3 = detail::NullType, typename T4 = detail::NullType,
12790 typename T5 = detail::NullType, typename T6 = detail::NullType,
12791 typename T7 = detail::NullType, typename T8 = detail::NullType,
12792 typename T9 = detail::NullType, typename T10 = detail::NullType,
12793 typename T11 = detail::NullType, typename T12 = detail::NullType,
12794 typename T13 = detail::NullType, typename T14 = detail::NullType,
12795 typename T15 = detail::NullType, typename T16 = detail::NullType,
12796 typename T17 = detail::NullType, typename T18 = detail::NullType,
12797 typename T19 = detail::NullType, typename T20 = detail::NullType,
12798 typename T21 = detail::NullType, typename T22 = detail::NullType,
12799 typename T23 = detail::NullType, typename T24 = detail::NullType,
12800 typename T25 = detail::NullType, typename T26 = detail::NullType,
12801 typename T27 = detail::NullType, typename T28 = detail::NullType,
12802 typename T29 = detail::NullType, typename T30 = detail::NullType,
12803 typename T31 = detail::NullType
12805 struct make_kernel :
12806 public detail::functionImplementation_<
12810 T12, T13, T14, T15,
12811 T16, T17, T18, T19,
12812 T20, T21, T22, T23,
12813 T24, T25, T26, T27,
12818 typedef detail::KernelFunctorGlobal<
12822 T12, T13, T14, T15,
12823 T16, T17, T18, T19,
12824 T20, T21, T22, T23,
12825 T24, T25, T26, T27,
12830 const Program& program,
12831 const STRING_CLASS name,
12832 cl_int * err = NULL) :
12833 detail::functionImplementation_<
12837 T12, T13, T14, T15,
12838 T16, T17, T18, T19,
12839 T20, T21, T22, T23,
12840 T24, T25, T26, T27,
12843 FunctorType(program, name, err))
12847 const Kernel kernel) :
12848 detail::functionImplementation_<
12852 T12, T13, T14, T15,
12853 T16, T17, T18, T19,
12854 T20, T21, T22, T23,
12855 T24, T25, T26, T27,
12858 FunctorType(kernel))
12863 //----------------------------------------------------------------------------------------------------------------------
12866 #if !defined(__CL_USER_OVERRIDE_ERROR_STRINGS)
12867 #undef __GET_DEVICE_INFO_ERR
12868 #undef __GET_PLATFORM_INFO_ERR
12869 #undef __GET_DEVICE_IDS_ERR
12870 #undef __GET_CONTEXT_INFO_ERR
12871 #undef __GET_EVENT_INFO_ERR
12872 #undef __GET_EVENT_PROFILE_INFO_ERR
12873 #undef __GET_MEM_OBJECT_INFO_ERR
12874 #undef __GET_IMAGE_INFO_ERR
12875 #undef __GET_SAMPLER_INFO_ERR
12876 #undef __GET_KERNEL_INFO_ERR
12877 #undef __GET_KERNEL_ARG_INFO_ERR
12878 #undef __GET_KERNEL_WORK_GROUP_INFO_ERR
12879 #undef __GET_PROGRAM_INFO_ERR
12880 #undef __GET_PROGRAM_BUILD_INFO_ERR
12881 #undef __GET_COMMAND_QUEUE_INFO_ERR
12883 #undef __CREATE_CONTEXT_ERR
12884 #undef __CREATE_CONTEXT_FROM_TYPE_ERR
12885 #undef __GET_SUPPORTED_IMAGE_FORMATS_ERR
12887 #undef __CREATE_BUFFER_ERR
12888 #undef __CREATE_SUBBUFFER_ERR
12889 #undef __CREATE_IMAGE2D_ERR
12890 #undef __CREATE_IMAGE3D_ERR
12891 #undef __CREATE_SAMPLER_ERR
12892 #undef __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR
12894 #undef __CREATE_USER_EVENT_ERR
12895 #undef __SET_USER_EVENT_STATUS_ERR
12896 #undef __SET_EVENT_CALLBACK_ERR
12897 #undef __SET_PRINTF_CALLBACK_ERR
12899 #undef __WAIT_FOR_EVENTS_ERR
12901 #undef __CREATE_KERNEL_ERR
12902 #undef __SET_KERNEL_ARGS_ERR
12903 #undef __CREATE_PROGRAM_WITH_SOURCE_ERR
12904 #undef __CREATE_PROGRAM_WITH_BINARY_ERR
12905 #undef __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR
12906 #undef __BUILD_PROGRAM_ERR
12907 #undef __CREATE_KERNELS_IN_PROGRAM_ERR
12909 #undef __CREATE_COMMAND_QUEUE_ERR
12910 #undef __SET_COMMAND_QUEUE_PROPERTY_ERR
12911 #undef __ENQUEUE_READ_BUFFER_ERR
12912 #undef __ENQUEUE_WRITE_BUFFER_ERR
12913 #undef __ENQUEUE_READ_BUFFER_RECT_ERR
12914 #undef __ENQUEUE_WRITE_BUFFER_RECT_ERR
12915 #undef __ENQEUE_COPY_BUFFER_ERR
12916 #undef __ENQEUE_COPY_BUFFER_RECT_ERR
12917 #undef __ENQUEUE_READ_IMAGE_ERR
12918 #undef __ENQUEUE_WRITE_IMAGE_ERR
12919 #undef __ENQUEUE_COPY_IMAGE_ERR
12920 #undef __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR
12921 #undef __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR
12922 #undef __ENQUEUE_MAP_BUFFER_ERR
12923 #undef __ENQUEUE_MAP_IMAGE_ERR
12924 #undef __ENQUEUE_UNMAP_MEM_OBJECT_ERR
12925 #undef __ENQUEUE_NDRANGE_KERNEL_ERR
12926 #undef __ENQUEUE_TASK_ERR
12927 #undef __ENQUEUE_NATIVE_KERNEL
12929 #undef __CL_EXPLICIT_CONSTRUCTORS
12931 #undef __UNLOAD_COMPILER_ERR
12932 #endif //__CL_USER_OVERRIDE_ERROR_STRINGS
12934 #undef __CL_FUNCTION_TYPE
12938 * Deprecated APIs for 1.2
12940 #if defined(CL_VERSION_1_1)
12941 #undef __INIT_CL_EXT_FCN_PTR
12942 #endif // #if defined(CL_VERSION_1_1)
12943 #undef __CREATE_SUB_DEVICES
12945 #if defined(USE_CL_DEVICE_FISSION)
12946 #undef __PARAM_NAME_DEVICE_FISSION
12947 #endif // USE_CL_DEVICE_FISSION
12949 #undef __DEFAULT_NOT_INITIALIZED
12950 #undef __DEFAULT_BEING_INITIALIZED
12951 #undef __DEFAULT_INITIALIZED
12953 #undef CL_HPP_RVALUE_REFERENCES_SUPPORTED
12954 #undef CL_HPP_NOEXCEPT