403 #if !defined(CL_HPP_USE_DX_INTEROP) && defined(USE_DX_INTEROP)
404 # pragma message("opencl.hpp: USE_DX_INTEROP is deprecated. Define CL_HPP_USE_DX_INTEROP instead")
405 # define CL_HPP_USE_DX_INTEROP
407 #if !defined(CL_HPP_USE_CL_DEVICE_FISSION) && defined(USE_CL_DEVICE_FISSION)
408 # pragma message("opencl.hpp: USE_CL_DEVICE_FISSION is deprecated. Define CL_HPP_USE_CL_DEVICE_FISSION instead")
409 # define CL_HPP_USE_CL_DEVICE_FISSION
411 #if !defined(CL_HPP_ENABLE_EXCEPTIONS) && defined(__CL_ENABLE_EXCEPTIONS)
412 # pragma message("opencl.hpp: __CL_ENABLE_EXCEPTIONS is deprecated. Define CL_HPP_ENABLE_EXCEPTIONS instead")
413 # define CL_HPP_ENABLE_EXCEPTIONS
415 #if !defined(CL_HPP_NO_STD_VECTOR) && defined(__NO_STD_VECTOR)
416 # pragma message("opencl.hpp: __NO_STD_VECTOR is deprecated. Define CL_HPP_NO_STD_VECTOR instead")
417 # define CL_HPP_NO_STD_VECTOR
419 #if !defined(CL_HPP_NO_STD_STRING) && defined(__NO_STD_STRING)
420 # pragma message("opencl.hpp: __NO_STD_STRING is deprecated. Define CL_HPP_NO_STD_STRING instead")
421 # define CL_HPP_NO_STD_STRING
423 #if defined(VECTOR_CLASS)
424 # pragma message("opencl.hpp: VECTOR_CLASS is deprecated. Alias cl::vector instead")
426 #if defined(STRING_CLASS)
427 # pragma message("opencl.hpp: STRING_CLASS is deprecated. Alias cl::string instead.")
429 #if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS) && defined(__CL_USER_OVERRIDE_ERROR_STRINGS)
430 # pragma message("opencl.hpp: __CL_USER_OVERRIDE_ERROR_STRINGS is deprecated. Define CL_HPP_USER_OVERRIDE_ERROR_STRINGS instead")
431 # define CL_HPP_USER_OVERRIDE_ERROR_STRINGS
436 #if defined(__USE_DEV_VECTOR)
437 # pragma message("opencl.hpp: __USE_DEV_VECTOR is no longer supported. Expect compilation errors")
439 #if defined(__USE_DEV_STRING)
440 # pragma message("opencl.hpp: __USE_DEV_STRING is no longer supported. Expect compilation errors")
444 #if !defined(CL_HPP_TARGET_OPENCL_VERSION)
445 # pragma message("opencl.hpp: CL_HPP_TARGET_OPENCL_VERSION is not defined. It will default to 300 (OpenCL 3.0)")
446 # define CL_HPP_TARGET_OPENCL_VERSION 300
448 #if CL_HPP_TARGET_OPENCL_VERSION != 100 && \
449 CL_HPP_TARGET_OPENCL_VERSION != 110 && \
450 CL_HPP_TARGET_OPENCL_VERSION != 120 && \
451 CL_HPP_TARGET_OPENCL_VERSION != 200 && \
452 CL_HPP_TARGET_OPENCL_VERSION != 210 && \
453 CL_HPP_TARGET_OPENCL_VERSION != 220 && \
454 CL_HPP_TARGET_OPENCL_VERSION != 300
455 # pragma message("opencl.hpp: CL_HPP_TARGET_OPENCL_VERSION is not a valid value (100, 110, 120, 200, 210, 220 or 300). It will be set to 300 (OpenCL 3.0).")
456 # undef CL_HPP_TARGET_OPENCL_VERSION
457 # define CL_HPP_TARGET_OPENCL_VERSION 300
461 #if defined(CL_TARGET_OPENCL_VERSION)
464 #if CL_TARGET_OPENCL_VERSION < CL_HPP_TARGET_OPENCL_VERSION
465 # pragma message("CL_TARGET_OPENCL_VERSION is already defined as is lower than CL_HPP_TARGET_OPENCL_VERSION")
468 # define CL_TARGET_OPENCL_VERSION CL_HPP_TARGET_OPENCL_VERSION
471 #if !defined(CL_HPP_MINIMUM_OPENCL_VERSION)
472 # define CL_HPP_MINIMUM_OPENCL_VERSION 200
474 #if CL_HPP_MINIMUM_OPENCL_VERSION != 100 && \
475 CL_HPP_MINIMUM_OPENCL_VERSION != 110 && \
476 CL_HPP_MINIMUM_OPENCL_VERSION != 120 && \
477 CL_HPP_MINIMUM_OPENCL_VERSION != 200 && \
478 CL_HPP_MINIMUM_OPENCL_VERSION != 210 && \
479 CL_HPP_MINIMUM_OPENCL_VERSION != 220 && \
480 CL_HPP_MINIMUM_OPENCL_VERSION != 300
481 # pragma message("opencl.hpp: CL_HPP_MINIMUM_OPENCL_VERSION is not a valid value (100, 110, 120, 200, 210, 220 or 300). It will be set to 100")
482 # undef CL_HPP_MINIMUM_OPENCL_VERSION
483 # define CL_HPP_MINIMUM_OPENCL_VERSION 100
485 #if CL_HPP_MINIMUM_OPENCL_VERSION > CL_HPP_TARGET_OPENCL_VERSION
486 # error "CL_HPP_MINIMUM_OPENCL_VERSION must not be greater than CL_HPP_TARGET_OPENCL_VERSION"
489 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 100 && !defined(CL_USE_DEPRECATED_OPENCL_1_0_APIS)
490 # define CL_USE_DEPRECATED_OPENCL_1_0_APIS
492 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 110 && !defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
493 # define CL_USE_DEPRECATED_OPENCL_1_1_APIS
495 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 120 && !defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
496 # define CL_USE_DEPRECATED_OPENCL_1_2_APIS
498 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 200 && !defined(CL_USE_DEPRECATED_OPENCL_2_0_APIS)
499 # define CL_USE_DEPRECATED_OPENCL_2_0_APIS
501 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 210 && !defined(CL_USE_DEPRECATED_OPENCL_2_1_APIS)
502 # define CL_USE_DEPRECATED_OPENCL_2_1_APIS
504 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 220 && !defined(CL_USE_DEPRECATED_OPENCL_2_2_APIS)
505 # define CL_USE_DEPRECATED_OPENCL_2_2_APIS
512 #if defined(CL_HPP_USE_DX_INTEROP)
513 #include <CL/cl_d3d10.h>
514 #include <CL/cl_dx9_media_sharing.h>
518 #if defined(_MSC_VER)
526 #if (!defined(_MSC_VER) && __cplusplus < 201103L) || (defined(_MSC_VER) && _MSC_VER < 1700)
527 #error Visual studio 2013 or another C++11-supporting compiler required
531 #if defined(CL_HPP_USE_CL_DEVICE_FISSION) || defined(CL_HPP_USE_CL_SUB_GROUPS_KHR)
532 #include <CL/cl_ext.h>
535 #if defined(__APPLE__) || defined(__MACOSX)
536 #include <OpenCL/opencl.h>
538 #include <CL/opencl.h>
541 #if (__cplusplus >= 201103L || _MSVC_LANG >= 201103L )
542 #define CL_HPP_NOEXCEPT_ noexcept
544 #define CL_HPP_NOEXCEPT_
547 #if __cplusplus >= 201703L
548 # define CL_HPP_DEFINE_STATIC_MEMBER_ inline
549 #elif defined(_MSC_VER)
550 # define CL_HPP_DEFINE_STATIC_MEMBER_ __declspec(selectany)
551 #elif defined(__MINGW32__)
552 # define CL_HPP_DEFINE_STATIC_MEMBER_ __attribute__((selectany))
554 # define CL_HPP_DEFINE_STATIC_MEMBER_ __attribute__((weak))
559 #if !defined(CL_API_PREFIX__VERSION_1_1_DEPRECATED)
560 #define CL_API_PREFIX__VERSION_1_1_DEPRECATED
562 #if !defined(CL_API_SUFFIX__VERSION_1_1_DEPRECATED)
563 #define CL_API_SUFFIX__VERSION_1_1_DEPRECATED
566 #if !defined(CL_API_PREFIX__VERSION_1_2_DEPRECATED)
567 #define CL_API_PREFIX__VERSION_1_2_DEPRECATED
569 #if !defined(CL_API_SUFFIX__VERSION_1_2_DEPRECATED)
570 #define CL_API_SUFFIX__VERSION_1_2_DEPRECATED
573 #if !defined(CL_API_PREFIX__VERSION_2_2_DEPRECATED)
574 #define CL_API_PREFIX__VERSION_2_2_DEPRECATED
576 #if !defined(CL_API_SUFFIX__VERSION_2_2_DEPRECATED)
577 #define CL_API_SUFFIX__VERSION_2_2_DEPRECATED
580 #if !defined(CL_CALLBACK)
589 #include <functional>
593 #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY)
595 using size_type = ::size_t;
599 using size_type = size_t;
604 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
608 #if !defined(CL_HPP_NO_STD_VECTOR)
611 template <
class T,
class Alloc = std::allocator<T> >
612 using vector = std::vector<T, Alloc>;
616 #if !defined(CL_HPP_NO_STD_STRING)
619 using string = std::string;
623 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
625 #if !defined(CL_HPP_NO_STD_UNIQUE_PTR)
630 template<
class T,
class D>
631 using pointer = std::unique_ptr<T, D>;
635 #if !defined(CL_HPP_NO_STD_ARRAY)
638 template <
class T,
size_type N >
639 using array = std::array<T, N>;
645 #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY)
647 namespace compatibility {
662 for (
int i = 0; i < N; ++i) {
667 size_t(
const array<size_type, N> &rhs)
669 for (
int i = 0; i < N; ++i) {
674 size_type& operator[](
int index)
679 const size_type& operator[](
int index)
const
685 operator size_type* () {
return data_; }
688 operator const size_type* ()
const {
return data_; }
690 operator array<size_type, N>()
const
692 array<size_type, N> ret;
694 for (
int i = 0; i < N; ++i) {
703 using size_t = compatibility::size_t<N>;
710 using size_t_array = array<size_type, 3>;
723 #define CL_HPP_INIT_CL_EXT_FCN_PTR_(name) \
725 pfn_##name = (PFN_##name) \
726 clGetExtensionFunctionAddress(#name); \
731 #define CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, name) \
733 pfn_##name = (PFN_##name) \
734 clGetExtensionFunctionAddressForPlatform(platform, #name); \
743 class DeviceCommandQueue;
748 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
753 class Error :
public std::exception
757 const char * errStr_;
768 Error(cl_int err,
const char * errStr = NULL) : err_(err), errStr_(errStr)
777 virtual const char * what()
const throw ()
779 if (errStr_ == NULL) {
791 cl_int err(
void)
const {
return err_; }
793 #define CL_HPP_ERR_STR_(x) #x
795 #define CL_HPP_ERR_STR_(x) NULL
801 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
802 static inline cl_int errHandler (
804 const char * errStr = NULL)
806 if (err != CL_SUCCESS) {
807 throw Error(err, errStr);
812 static inline cl_int errHandler (cl_int err,
const char * errStr = NULL)
823 #if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS)
824 #define __GET_DEVICE_INFO_ERR CL_HPP_ERR_STR_(clGetDeviceInfo)
825 #define __GET_PLATFORM_INFO_ERR CL_HPP_ERR_STR_(clGetPlatformInfo)
826 #define __GET_DEVICE_IDS_ERR CL_HPP_ERR_STR_(clGetDeviceIDs)
827 #define __GET_PLATFORM_IDS_ERR CL_HPP_ERR_STR_(clGetPlatformIDs)
828 #define __GET_CONTEXT_INFO_ERR CL_HPP_ERR_STR_(clGetContextInfo)
829 #define __GET_EVENT_INFO_ERR CL_HPP_ERR_STR_(clGetEventInfo)
830 #define __GET_EVENT_PROFILE_INFO_ERR CL_HPP_ERR_STR_(clGetEventProfileInfo)
831 #define __GET_MEM_OBJECT_INFO_ERR CL_HPP_ERR_STR_(clGetMemObjectInfo)
832 #define __GET_IMAGE_INFO_ERR CL_HPP_ERR_STR_(clGetImageInfo)
833 #define __GET_SAMPLER_INFO_ERR CL_HPP_ERR_STR_(clGetSamplerInfo)
834 #define __GET_KERNEL_INFO_ERR CL_HPP_ERR_STR_(clGetKernelInfo)
835 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
836 #define __GET_KERNEL_ARG_INFO_ERR CL_HPP_ERR_STR_(clGetKernelArgInfo)
838 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
839 #define __GET_KERNEL_SUB_GROUP_INFO_ERR CL_HPP_ERR_STR_(clGetKernelSubGroupInfo)
841 #define __GET_KERNEL_WORK_GROUP_INFO_ERR CL_HPP_ERR_STR_(clGetKernelWorkGroupInfo)
842 #define __GET_PROGRAM_INFO_ERR CL_HPP_ERR_STR_(clGetProgramInfo)
843 #define __GET_PROGRAM_BUILD_INFO_ERR CL_HPP_ERR_STR_(clGetProgramBuildInfo)
844 #define __GET_COMMAND_QUEUE_INFO_ERR CL_HPP_ERR_STR_(clGetCommandQueueInfo)
846 #define __CREATE_CONTEXT_ERR CL_HPP_ERR_STR_(clCreateContext)
847 #define __CREATE_CONTEXT_FROM_TYPE_ERR CL_HPP_ERR_STR_(clCreateContextFromType)
848 #define __GET_SUPPORTED_IMAGE_FORMATS_ERR CL_HPP_ERR_STR_(clGetSupportedImageFormats)
850 #define __CREATE_BUFFER_ERR CL_HPP_ERR_STR_(clCreateBuffer)
851 #define __COPY_ERR CL_HPP_ERR_STR_(cl::copy)
852 #define __CREATE_SUBBUFFER_ERR CL_HPP_ERR_STR_(clCreateSubBuffer)
853 #define __CREATE_GL_BUFFER_ERR CL_HPP_ERR_STR_(clCreateFromGLBuffer)
854 #define __CREATE_GL_RENDER_BUFFER_ERR CL_HPP_ERR_STR_(clCreateFromGLBuffer)
855 #define __GET_GL_OBJECT_INFO_ERR CL_HPP_ERR_STR_(clGetGLObjectInfo)
856 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
857 #define __CREATE_IMAGE_ERR CL_HPP_ERR_STR_(clCreateImage)
858 #define __CREATE_GL_TEXTURE_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture)
859 #define __IMAGE_DIMENSION_ERR CL_HPP_ERR_STR_(Incorrect image dimensions)
861 #define __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR CL_HPP_ERR_STR_(clSetMemObjectDestructorCallback)
863 #define __CREATE_USER_EVENT_ERR CL_HPP_ERR_STR_(clCreateUserEvent)
864 #define __SET_USER_EVENT_STATUS_ERR CL_HPP_ERR_STR_(clSetUserEventStatus)
865 #define __SET_EVENT_CALLBACK_ERR CL_HPP_ERR_STR_(clSetEventCallback)
866 #define __WAIT_FOR_EVENTS_ERR CL_HPP_ERR_STR_(clWaitForEvents)
868 #define __CREATE_KERNEL_ERR CL_HPP_ERR_STR_(clCreateKernel)
869 #define __SET_KERNEL_ARGS_ERR CL_HPP_ERR_STR_(clSetKernelArg)
870 #define __CREATE_PROGRAM_WITH_SOURCE_ERR CL_HPP_ERR_STR_(clCreateProgramWithSource)
871 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
872 #define __CREATE_PROGRAM_WITH_IL_ERR CL_HPP_ERR_STR_(clCreateProgramWithIL)
874 #define __CREATE_PROGRAM_WITH_BINARY_ERR CL_HPP_ERR_STR_(clCreateProgramWithBinary)
875 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
876 #define __CREATE_PROGRAM_WITH_IL_ERR CL_HPP_ERR_STR_(clCreateProgramWithIL)
878 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
879 #define __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR CL_HPP_ERR_STR_(clCreateProgramWithBuiltInKernels)
881 #define __BUILD_PROGRAM_ERR CL_HPP_ERR_STR_(clBuildProgram)
882 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
883 #define __COMPILE_PROGRAM_ERR CL_HPP_ERR_STR_(clCompileProgram)
884 #define __LINK_PROGRAM_ERR CL_HPP_ERR_STR_(clLinkProgram)
886 #define __CREATE_KERNELS_IN_PROGRAM_ERR CL_HPP_ERR_STR_(clCreateKernelsInProgram)
888 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
889 #define __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR CL_HPP_ERR_STR_(clCreateCommandQueueWithProperties)
890 #define __CREATE_SAMPLER_WITH_PROPERTIES_ERR CL_HPP_ERR_STR_(clCreateSamplerWithProperties)
892 #define __SET_COMMAND_QUEUE_PROPERTY_ERR CL_HPP_ERR_STR_(clSetCommandQueueProperty)
893 #define __ENQUEUE_READ_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueReadBuffer)
894 #define __ENQUEUE_READ_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueReadBufferRect)
895 #define __ENQUEUE_WRITE_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueWriteBuffer)
896 #define __ENQUEUE_WRITE_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueWriteBufferRect)
897 #define __ENQEUE_COPY_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueCopyBuffer)
898 #define __ENQEUE_COPY_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueCopyBufferRect)
899 #define __ENQUEUE_FILL_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueFillBuffer)
900 #define __ENQUEUE_READ_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueReadImage)
901 #define __ENQUEUE_WRITE_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueWriteImage)
902 #define __ENQUEUE_COPY_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueCopyImage)
903 #define __ENQUEUE_FILL_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueFillImage)
904 #define __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueCopyImageToBuffer)
905 #define __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueCopyBufferToImage)
906 #define __ENQUEUE_MAP_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueMapBuffer)
907 #define __ENQUEUE_MAP_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueMapImage)
908 #define __ENQUEUE_UNMAP_MEM_OBJECT_ERR CL_HPP_ERR_STR_(clEnqueueUnMapMemObject)
909 #define __ENQUEUE_NDRANGE_KERNEL_ERR CL_HPP_ERR_STR_(clEnqueueNDRangeKernel)
910 #define __ENQUEUE_NATIVE_KERNEL CL_HPP_ERR_STR_(clEnqueueNativeKernel)
911 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
912 #define __ENQUEUE_MIGRATE_MEM_OBJECTS_ERR CL_HPP_ERR_STR_(clEnqueueMigrateMemObjects)
914 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
915 #define __ENQUEUE_MIGRATE_SVM_ERR CL_HPP_ERR_STR_(clEnqueueSVMMigrateMem)
916 #define __SET_DEFAULT_DEVICE_COMMAND_QUEUE_ERR CL_HPP_ERR_STR_(clSetDefaultDeviceCommandQueue)
920 #define __ENQUEUE_ACQUIRE_GL_ERR CL_HPP_ERR_STR_(clEnqueueAcquireGLObjects)
921 #define __ENQUEUE_RELEASE_GL_ERR CL_HPP_ERR_STR_(clEnqueueReleaseGLObjects)
923 #define __CREATE_PIPE_ERR CL_HPP_ERR_STR_(clCreatePipe)
924 #define __GET_PIPE_INFO_ERR CL_HPP_ERR_STR_(clGetPipeInfo)
927 #define __RETAIN_ERR CL_HPP_ERR_STR_(Retain Object)
928 #define __RELEASE_ERR CL_HPP_ERR_STR_(Release Object)
929 #define __FLUSH_ERR CL_HPP_ERR_STR_(clFlush)
930 #define __FINISH_ERR CL_HPP_ERR_STR_(clFinish)
931 #define __VECTOR_CAPACITY_ERR CL_HPP_ERR_STR_(Vector capacity error)
933 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
934 #define __GET_HOST_TIMER_ERR CL_HPP_ERR_STR_(clGetHostTimer)
935 #define __GET_DEVICE_AND_HOST_TIMER_ERR CL_HPP_ERR_STR_(clGetDeviceAndHostTimer)
937 #if CL_HPP_TARGET_OPENCL_VERSION >= 220
938 #define __SET_PROGRAM_RELEASE_CALLBACK_ERR CL_HPP_ERR_STR_(clSetProgramReleaseCallback)
939 #define __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR CL_HPP_ERR_STR_(clSetProgramSpecializationConstant)
946 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
947 #define __CREATE_SUB_DEVICES_ERR CL_HPP_ERR_STR_(clCreateSubDevices)
949 #define __CREATE_SUB_DEVICES_ERR CL_HPP_ERR_STR_(clCreateSubDevicesEXT)
955 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
956 #define __ENQUEUE_MARKER_ERR CL_HPP_ERR_STR_(clEnqueueMarker)
957 #define __ENQUEUE_WAIT_FOR_EVENTS_ERR CL_HPP_ERR_STR_(clEnqueueWaitForEvents)
958 #define __ENQUEUE_BARRIER_ERR CL_HPP_ERR_STR_(clEnqueueBarrier)
959 #define __UNLOAD_COMPILER_ERR CL_HPP_ERR_STR_(clUnloadCompiler)
960 #define __CREATE_GL_TEXTURE_2D_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture2D)
961 #define __CREATE_GL_TEXTURE_3D_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture3D)
962 #define __CREATE_IMAGE2D_ERR CL_HPP_ERR_STR_(clCreateImage2D)
963 #define __CREATE_IMAGE3D_ERR CL_HPP_ERR_STR_(clCreateImage3D)
969 #if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
970 #define __CREATE_COMMAND_QUEUE_ERR CL_HPP_ERR_STR_(clCreateCommandQueue)
971 #define __ENQUEUE_TASK_ERR CL_HPP_ERR_STR_(clEnqueueTask)
972 #define __CREATE_SAMPLER_ERR CL_HPP_ERR_STR_(clCreateSampler)
978 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
979 #define __ENQUEUE_MARKER_WAIT_LIST_ERR CL_HPP_ERR_STR_(clEnqueueMarkerWithWaitList)
980 #define __ENQUEUE_BARRIER_WAIT_LIST_ERR CL_HPP_ERR_STR_(clEnqueueBarrierWithWaitList)
983 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
984 #define __CLONE_KERNEL_ERR CL_HPP_ERR_STR_(clCloneKernel)
997 template<
typename Functor,
typename T>
998 inline cl_int getInfoHelper(Functor f, cl_uint name, T* param,
long)
1000 return f(name,
sizeof(T), param, NULL);
1005 template <
typename Func>
1006 inline cl_int getInfoHelper(Func f, cl_uint name, vector<vector<unsigned char>>* param,
int)
1008 if (name != CL_PROGRAM_BINARIES) {
1009 return CL_INVALID_VALUE;
1013 size_type numBinaries = param->size();
1014 vector<unsigned char*> binariesPointers(numBinaries);
1016 for (size_type i = 0; i < numBinaries; ++i)
1018 binariesPointers[i] = (*param)[i].data();
1021 cl_int err = f(name, numBinaries *
sizeof(
unsigned char*), binariesPointers.data(), NULL);
1023 if (err != CL_SUCCESS) {
1033 template <
typename Func,
typename T>
1034 inline cl_int getInfoHelper(Func f, cl_uint name, vector<T>* param,
long)
1037 cl_int err = f(name, 0, NULL, &required);
1038 if (err != CL_SUCCESS) {
1041 const size_type elements = required /
sizeof(T);
1044 vector<T> localData(elements);
1045 err = f(name, required, localData.data(), NULL);
1046 if (err != CL_SUCCESS) {
1050 *param = std::move(localData);
1062 template <
typename Func,
typename T>
1063 inline cl_int getInfoHelper(
1064 Func f, cl_uint name, vector<T>* param,
int,
typename T::cl_type = 0)
1067 cl_int err = f(name, 0, NULL, &required);
1068 if (err != CL_SUCCESS) {
1072 const size_type elements = required /
sizeof(
typename T::cl_type);
1074 vector<typename T::cl_type> value(elements);
1075 err = f(name, required, value.data(), NULL);
1076 if (err != CL_SUCCESS) {
1082 param->resize(elements);
1086 for (size_type i = 0; i < elements; i++) {
1087 (*param)[i] = T(value[i],
true);
1094 template <
typename Func>
1095 inline cl_int getInfoHelper(Func f, cl_uint name,
string* param,
long)
1098 cl_int err = f(name, 0, NULL, &required);
1099 if (err != CL_SUCCESS) {
1106 vector<char> value(required);
1107 err = f(name, required, value.data(), NULL);
1108 if (err != CL_SUCCESS) {
1112 param->assign(begin(value), prev(end(value)));
1122 template <
typename Func,
size_type N>
1123 inline cl_int getInfoHelper(Func f, cl_uint name, array<size_type, N>* param,
long)
1126 cl_int err = f(name, 0, NULL, &required);
1127 if (err != CL_SUCCESS) {
1131 size_type elements = required /
sizeof(size_type);
1132 vector<size_type> value(elements, 0);
1134 err = f(name, required, value.data(), NULL);
1135 if (err != CL_SUCCESS) {
1144 for (size_type i = 0; i < elements; ++i) {
1145 (*param)[i] = value[i];
1151 template<
typename T>
struct ReferenceHandler;
1159 template<
typename Func,
typename T>
1160 inline cl_int getInfoHelper(Func f, cl_uint name, T* param,
int,
typename T::cl_type = 0)
1162 typename T::cl_type value;
1163 cl_int err = f(name,
sizeof(value), &value, NULL);
1164 if (err != CL_SUCCESS) {
1170 err = param->retain();
1171 if (err != CL_SUCCESS) {
1178 #define CL_HPP_PARAM_NAME_INFO_1_0_(F) \
1179 F(cl_platform_info, CL_PLATFORM_PROFILE, string) \
1180 F(cl_platform_info, CL_PLATFORM_VERSION, string) \
1181 F(cl_platform_info, CL_PLATFORM_NAME, string) \
1182 F(cl_platform_info, CL_PLATFORM_VENDOR, string) \
1183 F(cl_platform_info, CL_PLATFORM_EXTENSIONS, string) \
1185 F(cl_device_info, CL_DEVICE_TYPE, cl_device_type) \
1186 F(cl_device_info, CL_DEVICE_VENDOR_ID, cl_uint) \
1187 F(cl_device_info, CL_DEVICE_MAX_COMPUTE_UNITS, cl_uint) \
1188 F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, cl_uint) \
1189 F(cl_device_info, CL_DEVICE_MAX_WORK_GROUP_SIZE, size_type) \
1190 F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_SIZES, cl::vector<size_type>) \
1191 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, cl_uint) \
1192 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT, cl_uint) \
1193 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT, cl_uint) \
1194 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG, cl_uint) \
1195 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT, cl_uint) \
1196 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, cl_uint) \
1197 F(cl_device_info, CL_DEVICE_MAX_CLOCK_FREQUENCY, cl_uint) \
1198 F(cl_device_info, CL_DEVICE_ADDRESS_BITS, cl_uint) \
1199 F(cl_device_info, CL_DEVICE_MAX_READ_IMAGE_ARGS, cl_uint) \
1200 F(cl_device_info, CL_DEVICE_MAX_WRITE_IMAGE_ARGS, cl_uint) \
1201 F(cl_device_info, CL_DEVICE_MAX_MEM_ALLOC_SIZE, cl_ulong) \
1202 F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_WIDTH, size_type) \
1203 F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_HEIGHT, size_type) \
1204 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_WIDTH, size_type) \
1205 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_HEIGHT, size_type) \
1206 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_DEPTH, size_type) \
1207 F(cl_device_info, CL_DEVICE_IMAGE_SUPPORT, cl_bool) \
1208 F(cl_device_info, CL_DEVICE_MAX_PARAMETER_SIZE, size_type) \
1209 F(cl_device_info, CL_DEVICE_MAX_SAMPLERS, cl_uint) \
1210 F(cl_device_info, CL_DEVICE_MEM_BASE_ADDR_ALIGN, cl_uint) \
1211 F(cl_device_info, CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE, cl_uint) \
1212 F(cl_device_info, CL_DEVICE_SINGLE_FP_CONFIG, cl_device_fp_config) \
1213 F(cl_device_info, CL_DEVICE_DOUBLE_FP_CONFIG, cl_device_fp_config) \
1214 F(cl_device_info, CL_DEVICE_HALF_FP_CONFIG, cl_device_fp_config) \
1215 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_TYPE, cl_device_mem_cache_type) \
1216 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE, cl_uint)\
1217 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_SIZE, cl_ulong) \
1218 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_SIZE, cl_ulong) \
1219 F(cl_device_info, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE, cl_ulong) \
1220 F(cl_device_info, CL_DEVICE_MAX_CONSTANT_ARGS, cl_uint) \
1221 F(cl_device_info, CL_DEVICE_LOCAL_MEM_TYPE, cl_device_local_mem_type) \
1222 F(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE, cl_ulong) \
1223 F(cl_device_info, CL_DEVICE_ERROR_CORRECTION_SUPPORT, cl_bool) \
1224 F(cl_device_info, CL_DEVICE_PROFILING_TIMER_RESOLUTION, size_type) \
1225 F(cl_device_info, CL_DEVICE_ENDIAN_LITTLE, cl_bool) \
1226 F(cl_device_info, CL_DEVICE_AVAILABLE, cl_bool) \
1227 F(cl_device_info, CL_DEVICE_COMPILER_AVAILABLE, cl_bool) \
1228 F(cl_device_info, CL_DEVICE_EXECUTION_CAPABILITIES, cl_device_exec_capabilities) \
1229 F(cl_device_info, CL_DEVICE_PLATFORM, cl_platform_id) \
1230 F(cl_device_info, CL_DEVICE_NAME, string) \
1231 F(cl_device_info, CL_DEVICE_VENDOR, string) \
1232 F(cl_device_info, CL_DRIVER_VERSION, string) \
1233 F(cl_device_info, CL_DEVICE_PROFILE, string) \
1234 F(cl_device_info, CL_DEVICE_VERSION, string) \
1235 F(cl_device_info, CL_DEVICE_EXTENSIONS, string) \
1237 F(cl_context_info, CL_CONTEXT_REFERENCE_COUNT, cl_uint) \
1238 F(cl_context_info, CL_CONTEXT_DEVICES, cl::vector<Device>) \
1239 F(cl_context_info, CL_CONTEXT_PROPERTIES, cl::vector<cl_context_properties>) \
1241 F(cl_event_info, CL_EVENT_COMMAND_QUEUE, cl::CommandQueue) \
1242 F(cl_event_info, CL_EVENT_COMMAND_TYPE, cl_command_type) \
1243 F(cl_event_info, CL_EVENT_REFERENCE_COUNT, cl_uint) \
1244 F(cl_event_info, CL_EVENT_COMMAND_EXECUTION_STATUS, cl_int) \
1246 F(cl_profiling_info, CL_PROFILING_COMMAND_QUEUED, cl_ulong) \
1247 F(cl_profiling_info, CL_PROFILING_COMMAND_SUBMIT, cl_ulong) \
1248 F(cl_profiling_info, CL_PROFILING_COMMAND_START, cl_ulong) \
1249 F(cl_profiling_info, CL_PROFILING_COMMAND_END, cl_ulong) \
1251 F(cl_mem_info, CL_MEM_TYPE, cl_mem_object_type) \
1252 F(cl_mem_info, CL_MEM_FLAGS, cl_mem_flags) \
1253 F(cl_mem_info, CL_MEM_SIZE, size_type) \
1254 F(cl_mem_info, CL_MEM_HOST_PTR, void*) \
1255 F(cl_mem_info, CL_MEM_MAP_COUNT, cl_uint) \
1256 F(cl_mem_info, CL_MEM_REFERENCE_COUNT, cl_uint) \
1257 F(cl_mem_info, CL_MEM_CONTEXT, cl::Context) \
1259 F(cl_image_info, CL_IMAGE_FORMAT, cl_image_format) \
1260 F(cl_image_info, CL_IMAGE_ELEMENT_SIZE, size_type) \
1261 F(cl_image_info, CL_IMAGE_ROW_PITCH, size_type) \
1262 F(cl_image_info, CL_IMAGE_SLICE_PITCH, size_type) \
1263 F(cl_image_info, CL_IMAGE_WIDTH, size_type) \
1264 F(cl_image_info, CL_IMAGE_HEIGHT, size_type) \
1265 F(cl_image_info, CL_IMAGE_DEPTH, size_type) \
1267 F(cl_sampler_info, CL_SAMPLER_REFERENCE_COUNT, cl_uint) \
1268 F(cl_sampler_info, CL_SAMPLER_CONTEXT, cl::Context) \
1269 F(cl_sampler_info, CL_SAMPLER_NORMALIZED_COORDS, cl_bool) \
1270 F(cl_sampler_info, CL_SAMPLER_ADDRESSING_MODE, cl_addressing_mode) \
1271 F(cl_sampler_info, CL_SAMPLER_FILTER_MODE, cl_filter_mode) \
1273 F(cl_program_info, CL_PROGRAM_REFERENCE_COUNT, cl_uint) \
1274 F(cl_program_info, CL_PROGRAM_CONTEXT, cl::Context) \
1275 F(cl_program_info, CL_PROGRAM_NUM_DEVICES, cl_uint) \
1276 F(cl_program_info, CL_PROGRAM_DEVICES, cl::vector<Device>) \
1277 F(cl_program_info, CL_PROGRAM_SOURCE, string) \
1278 F(cl_program_info, CL_PROGRAM_BINARY_SIZES, cl::vector<size_type>) \
1279 F(cl_program_info, CL_PROGRAM_BINARIES, cl::vector<cl::vector<unsigned char>>) \
1281 F(cl_program_build_info, CL_PROGRAM_BUILD_STATUS, cl_build_status) \
1282 F(cl_program_build_info, CL_PROGRAM_BUILD_OPTIONS, string) \
1283 F(cl_program_build_info, CL_PROGRAM_BUILD_LOG, string) \
1285 F(cl_kernel_info, CL_KERNEL_FUNCTION_NAME, string) \
1286 F(cl_kernel_info, CL_KERNEL_NUM_ARGS, cl_uint) \
1287 F(cl_kernel_info, CL_KERNEL_REFERENCE_COUNT, cl_uint) \
1288 F(cl_kernel_info, CL_KERNEL_CONTEXT, cl::Context) \
1289 F(cl_kernel_info, CL_KERNEL_PROGRAM, cl::Program) \
1291 F(cl_kernel_work_group_info, CL_KERNEL_WORK_GROUP_SIZE, size_type) \
1292 F(cl_kernel_work_group_info, CL_KERNEL_COMPILE_WORK_GROUP_SIZE, cl::detail::size_t_array) \
1293 F(cl_kernel_work_group_info, CL_KERNEL_LOCAL_MEM_SIZE, cl_ulong) \
1295 F(cl_command_queue_info, CL_QUEUE_CONTEXT, cl::Context) \
1296 F(cl_command_queue_info, CL_QUEUE_DEVICE, cl::Device) \
1297 F(cl_command_queue_info, CL_QUEUE_REFERENCE_COUNT, cl_uint) \
1298 F(cl_command_queue_info, CL_QUEUE_PROPERTIES, cl_command_queue_properties)
1301 #define CL_HPP_PARAM_NAME_INFO_1_1_(F) \
1302 F(cl_context_info, CL_CONTEXT_NUM_DEVICES, cl_uint)\
1303 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF, cl_uint) \
1304 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR, cl_uint) \
1305 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT, cl_uint) \
1306 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_INT, cl_uint) \
1307 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG, cl_uint) \
1308 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT, cl_uint) \
1309 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE, cl_uint) \
1310 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF, cl_uint) \
1311 F(cl_device_info, CL_DEVICE_OPENCL_C_VERSION, string) \
1313 F(cl_mem_info, CL_MEM_ASSOCIATED_MEMOBJECT, cl::Memory) \
1314 F(cl_mem_info, CL_MEM_OFFSET, size_type) \
1316 F(cl_kernel_work_group_info, CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, size_type) \
1317 F(cl_kernel_work_group_info, CL_KERNEL_PRIVATE_MEM_SIZE, cl_ulong) \
1319 F(cl_event_info, CL_EVENT_CONTEXT, cl::Context)
1321 #define CL_HPP_PARAM_NAME_INFO_1_2_(F) \
1322 F(cl_program_info, CL_PROGRAM_NUM_KERNELS, size_type) \
1323 F(cl_program_info, CL_PROGRAM_KERNEL_NAMES, string) \
1325 F(cl_program_build_info, CL_PROGRAM_BINARY_TYPE, cl_program_binary_type) \
1327 F(cl_kernel_info, CL_KERNEL_ATTRIBUTES, string) \
1329 F(cl_kernel_arg_info, CL_KERNEL_ARG_ADDRESS_QUALIFIER, cl_kernel_arg_address_qualifier) \
1330 F(cl_kernel_arg_info, CL_KERNEL_ARG_ACCESS_QUALIFIER, cl_kernel_arg_access_qualifier) \
1331 F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_NAME, string) \
1332 F(cl_kernel_arg_info, CL_KERNEL_ARG_NAME, string) \
1333 F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_QUALIFIER, cl_kernel_arg_type_qualifier) \
1335 F(cl_kernel_work_group_info, CL_KERNEL_GLOBAL_WORK_SIZE, cl::detail::size_t_array) \
1337 F(cl_device_info, CL_DEVICE_LINKER_AVAILABLE, cl_bool) \
1338 F(cl_device_info, CL_DEVICE_IMAGE_MAX_BUFFER_SIZE, size_type) \
1339 F(cl_device_info, CL_DEVICE_IMAGE_MAX_ARRAY_SIZE, size_type) \
1340 F(cl_device_info, CL_DEVICE_PARENT_DEVICE, cl::Device) \
1341 F(cl_device_info, CL_DEVICE_PARTITION_MAX_SUB_DEVICES, cl_uint) \
1342 F(cl_device_info, CL_DEVICE_PARTITION_PROPERTIES, cl::vector<cl_device_partition_property>) \
1343 F(cl_device_info, CL_DEVICE_PARTITION_TYPE, cl::vector<cl_device_partition_property>) \
1344 F(cl_device_info, CL_DEVICE_REFERENCE_COUNT, cl_uint) \
1345 F(cl_device_info, CL_DEVICE_PREFERRED_INTEROP_USER_SYNC, cl_bool) \
1346 F(cl_device_info, CL_DEVICE_PARTITION_AFFINITY_DOMAIN, cl_device_affinity_domain) \
1347 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS, string) \
1348 F(cl_device_info, CL_DEVICE_PRINTF_BUFFER_SIZE, size_type) \
1350 F(cl_image_info, CL_IMAGE_ARRAY_SIZE, size_type) \
1351 F(cl_image_info, CL_IMAGE_NUM_MIP_LEVELS, cl_uint) \
1352 F(cl_image_info, CL_IMAGE_NUM_SAMPLES, cl_uint)
1354 #define CL_HPP_PARAM_NAME_INFO_2_0_(F) \
1355 F(cl_device_info, CL_DEVICE_QUEUE_ON_HOST_PROPERTIES, cl_command_queue_properties) \
1356 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES, cl_command_queue_properties) \
1357 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE, cl_uint) \
1358 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE, cl_uint) \
1359 F(cl_device_info, CL_DEVICE_MAX_ON_DEVICE_QUEUES, cl_uint) \
1360 F(cl_device_info, CL_DEVICE_MAX_ON_DEVICE_EVENTS, cl_uint) \
1361 F(cl_device_info, CL_DEVICE_MAX_PIPE_ARGS, cl_uint) \
1362 F(cl_device_info, CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS, cl_uint) \
1363 F(cl_device_info, CL_DEVICE_PIPE_MAX_PACKET_SIZE, cl_uint) \
1364 F(cl_device_info, CL_DEVICE_SVM_CAPABILITIES, cl_device_svm_capabilities) \
1365 F(cl_device_info, CL_DEVICE_PREFERRED_PLATFORM_ATOMIC_ALIGNMENT, cl_uint) \
1366 F(cl_device_info, CL_DEVICE_PREFERRED_GLOBAL_ATOMIC_ALIGNMENT, cl_uint) \
1367 F(cl_device_info, CL_DEVICE_PREFERRED_LOCAL_ATOMIC_ALIGNMENT, cl_uint) \
1368 F(cl_device_info, CL_DEVICE_IMAGE_PITCH_ALIGNMENT, cl_uint) \
1369 F(cl_device_info, CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT, cl_uint) \
1370 F(cl_device_info, CL_DEVICE_MAX_READ_WRITE_IMAGE_ARGS, cl_uint ) \
1371 F(cl_device_info, CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE, size_type ) \
1372 F(cl_device_info, CL_DEVICE_GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE, size_type ) \
1373 F(cl_profiling_info, CL_PROFILING_COMMAND_COMPLETE, cl_ulong) \
1374 F(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM, cl_bool) \
1375 F(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_SVM_PTRS, void**) \
1376 F(cl_command_queue_info, CL_QUEUE_SIZE, cl_uint) \
1377 F(cl_mem_info, CL_MEM_USES_SVM_POINTER, cl_bool) \
1378 F(cl_program_build_info, CL_PROGRAM_BUILD_GLOBAL_VARIABLE_TOTAL_SIZE, size_type) \
1379 F(cl_pipe_info, CL_PIPE_PACKET_SIZE, cl_uint) \
1380 F(cl_pipe_info, CL_PIPE_MAX_PACKETS, cl_uint)
1382 #define CL_HPP_PARAM_NAME_INFO_SUBGROUP_KHR_(F) \
1383 F(cl_kernel_sub_group_info, CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE_KHR, size_type) \
1384 F(cl_kernel_sub_group_info, CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE_KHR, size_type)
1386 #define CL_HPP_PARAM_NAME_INFO_IL_KHR_(F) \
1387 F(cl_device_info, CL_DEVICE_IL_VERSION_KHR, string) \
1388 F(cl_program_info, CL_PROGRAM_IL_KHR, cl::vector<unsigned char>)
1390 #define CL_HPP_PARAM_NAME_INFO_2_1_(F) \
1391 F(cl_platform_info, CL_PLATFORM_HOST_TIMER_RESOLUTION, cl_ulong) \
1392 F(cl_program_info, CL_PROGRAM_IL, cl::vector<unsigned char>) \
1393 F(cl_device_info, CL_DEVICE_MAX_NUM_SUB_GROUPS, cl_uint) \
1394 F(cl_device_info, CL_DEVICE_IL_VERSION, string) \
1395 F(cl_device_info, CL_DEVICE_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS, cl_bool) \
1396 F(cl_command_queue_info, CL_QUEUE_DEVICE_DEFAULT, cl::DeviceCommandQueue) \
1397 F(cl_kernel_sub_group_info, CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE, size_type) \
1398 F(cl_kernel_sub_group_info, CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE, size_type) \
1399 F(cl_kernel_sub_group_info, CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT, cl::detail::size_t_array) \
1400 F(cl_kernel_sub_group_info, CL_KERNEL_MAX_NUM_SUB_GROUPS, size_type) \
1401 F(cl_kernel_sub_group_info, CL_KERNEL_COMPILE_NUM_SUB_GROUPS, size_type)
1403 #define CL_HPP_PARAM_NAME_INFO_2_2_(F) \
1404 F(cl_program_info, CL_PROGRAM_SCOPE_GLOBAL_CTORS_PRESENT, cl_bool) \
1405 F(cl_program_info, CL_PROGRAM_SCOPE_GLOBAL_DTORS_PRESENT, cl_bool)
1407 #define CL_HPP_PARAM_NAME_DEVICE_FISSION_(F) \
1408 F(cl_device_info, CL_DEVICE_PARENT_DEVICE_EXT, cl_device_id) \
1409 F(cl_device_info, CL_DEVICE_PARTITION_TYPES_EXT, cl::vector<cl_device_partition_property_ext>) \
1410 F(cl_device_info, CL_DEVICE_AFFINITY_DOMAINS_EXT, cl::vector<cl_device_partition_property_ext>) \
1411 F(cl_device_info, CL_DEVICE_REFERENCE_COUNT_EXT , cl_uint) \
1412 F(cl_device_info, CL_DEVICE_PARTITION_STYLE_EXT, cl::vector<cl_device_partition_property_ext>)
1414 #define CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_CL3_SHARED_(F) \
1415 F(cl_platform_info, CL_PLATFORM_NUMERIC_VERSION_KHR, cl_version_khr) \
1416 F(cl_platform_info, CL_PLATFORM_EXTENSIONS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>) \
1418 F(cl_device_info, CL_DEVICE_NUMERIC_VERSION_KHR, cl_version_khr) \
1419 F(cl_device_info, CL_DEVICE_EXTENSIONS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>) \
1420 F(cl_device_info, CL_DEVICE_ILS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>) \
1421 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>)
1423 #define CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_KHRONLY_(F) \
1424 F(cl_device_info, CL_DEVICE_OPENCL_C_NUMERIC_VERSION_KHR, cl_version_khr)
1426 #define CL_HPP_PARAM_NAME_INFO_3_0_(F) \
1427 F(cl_platform_info, CL_PLATFORM_NUMERIC_VERSION, cl_version) \
1428 F(cl_platform_info, CL_PLATFORM_EXTENSIONS_WITH_VERSION, cl::vector<cl_name_version>) \
1430 F(cl_device_info, CL_DEVICE_NUMERIC_VERSION, cl_version) \
1431 F(cl_device_info, CL_DEVICE_EXTENSIONS_WITH_VERSION, cl::vector<cl_name_version>) \
1432 F(cl_device_info, CL_DEVICE_ILS_WITH_VERSION, cl::vector<cl_name_version>) \
1433 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS_WITH_VERSION, cl::vector<cl_name_version>) \
1434 F(cl_device_info, CL_DEVICE_ATOMIC_MEMORY_CAPABILITIES, cl_device_atomic_capabilities) \
1435 F(cl_device_info, CL_DEVICE_ATOMIC_FENCE_CAPABILITIES, cl_device_atomic_capabilities) \
1436 F(cl_device_info, CL_DEVICE_NON_UNIFORM_WORK_GROUP_SUPPORT, cl_bool) \
1437 F(cl_device_info, CL_DEVICE_OPENCL_C_ALL_VERSIONS, cl::vector<cl_name_version>) \
1438 F(cl_device_info, CL_DEVICE_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, size_type) \
1439 F(cl_device_info, CL_DEVICE_WORK_GROUP_COLLECTIVE_FUNCTIONS_SUPPORT, cl_bool) \
1440 F(cl_device_info, CL_DEVICE_GENERIC_ADDRESS_SPACE_SUPPORT, cl_bool) \
1441 F(cl_device_info, CL_DEVICE_OPENCL_C_FEATURES, cl::vector<cl_name_version>) \
1442 F(cl_device_info, CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES, cl_device_device_enqueue_capabilities) \
1443 F(cl_device_info, CL_DEVICE_PIPE_SUPPORT, cl_bool) \
1444 F(cl_device_info, CL_DEVICE_LATEST_CONFORMANCE_VERSION_PASSED, string) \
1446 F(cl_command_queue_info, CL_QUEUE_PROPERTIES_ARRAY, cl::vector<cl_queue_properties>) \
1447 F(cl_mem_info, CL_MEM_PROPERTIES, cl::vector<cl_mem_properties>) \
1448 F(cl_pipe_info, CL_PIPE_PROPERTIES, cl::vector<cl_pipe_properties>) \
1449 F(cl_sampler_info, CL_SAMPLER_PROPERTIES, cl::vector<cl_sampler_properties>)
1451 template <
typename enum_type, cl_
int Name>
1454 #define CL_HPP_DECLARE_PARAM_TRAITS_(token, param_name, T) \
1457 struct param_traits<detail:: token,param_name> \
1459 enum { value = param_name }; \
1460 typedef T param_type; \
1463 CL_HPP_PARAM_NAME_INFO_1_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1464 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
1465 CL_HPP_PARAM_NAME_INFO_1_1_(CL_HPP_DECLARE_PARAM_TRAITS_)
1467 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
1468 CL_HPP_PARAM_NAME_INFO_1_2_(CL_HPP_DECLARE_PARAM_TRAITS_)
1470 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
1471 CL_HPP_PARAM_NAME_INFO_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1473 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
1474 CL_HPP_PARAM_NAME_INFO_2_1_(CL_HPP_DECLARE_PARAM_TRAITS_)
1476 #if CL_HPP_TARGET_OPENCL_VERSION >= 220
1477 CL_HPP_PARAM_NAME_INFO_2_2_(CL_HPP_DECLARE_PARAM_TRAITS_)
1479 #if CL_HPP_TARGET_OPENCL_VERSION >= 300
1480 CL_HPP_PARAM_NAME_INFO_3_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1483 #if defined(CL_HPP_USE_CL_SUB_GROUPS_KHR) && CL_HPP_TARGET_OPENCL_VERSION < 210
1484 CL_HPP_PARAM_NAME_INFO_SUBGROUP_KHR_(CL_HPP_DECLARE_PARAM_TRAITS_)
1487 #if defined(CL_HPP_USE_IL_KHR) && CL_HPP_TARGET_OPENCL_VERSION < 210
1488 CL_HPP_PARAM_NAME_INFO_IL_KHR_(CL_HPP_DECLARE_PARAM_TRAITS_)
1493 #define CL_HPP_PARAM_NAME_INFO_1_0_DEPRECATED_IN_2_0_(F) \
1494 F(cl_device_info, CL_DEVICE_QUEUE_PROPERTIES, cl_command_queue_properties)
1496 #define CL_HPP_PARAM_NAME_INFO_1_1_DEPRECATED_IN_2_0_(F) \
1497 F(cl_device_info, CL_DEVICE_HOST_UNIFIED_MEMORY, cl_bool)
1499 #define CL_HPP_PARAM_NAME_INFO_1_2_DEPRECATED_IN_2_0_(F) \
1500 F(cl_image_info, CL_IMAGE_BUFFER, cl::Buffer)
1504 #if CL_HPP_TARGET_OPENCL_VERSION > 100 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 && CL_HPP_TARGET_OPENCL_VERSION < 200
1505 CL_HPP_PARAM_NAME_INFO_1_0_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1507 #if CL_HPP_TARGET_OPENCL_VERSION > 110 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
1508 CL_HPP_PARAM_NAME_INFO_1_1_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1510 #if CL_HPP_TARGET_OPENCL_VERSION > 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
1511 CL_HPP_PARAM_NAME_INFO_1_2_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1514 #if defined(CL_HPP_USE_CL_DEVICE_FISSION)
1515 CL_HPP_PARAM_NAME_DEVICE_FISSION_(CL_HPP_DECLARE_PARAM_TRAITS_);
1518 #if defined(cl_khr_extended_versioning)
1519 #if CL_HPP_TARGET_OPENCL_VERSION < 300
1520 CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_CL3_SHARED_(CL_HPP_DECLARE_PARAM_TRAITS_)
1522 CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_KHRONLY_(CL_HPP_DECLARE_PARAM_TRAITS_)
1525 #if defined(cl_khr_device_uuid)
1526 using uuid_array = array<cl_uchar, CL_UUID_SIZE_KHR>;
1527 using luid_array = array<cl_uchar, CL_LUID_SIZE_KHR>;
1528 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_UUID_KHR, uuid_array)
1529 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DRIVER_UUID_KHR, uuid_array)
1530 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LUID_VALID_KHR, cl_bool)
1531 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LUID_KHR, luid_array)
1532 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_NODE_MASK_KHR, cl_uint)
1535 #if defined(cl_khr_pci_bus_info)
1536 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_PCI_BUS_INFO_KHR, cl_device_pci_bus_info_khr)
1539 #if defined(cl_khr_integer_dot_product)
1540 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGER_DOT_PRODUCT_CAPABILITIES_KHR, cl_device_integer_dot_product_capabilities_khr)
1541 #if defined(CL_DEVICE_INTEGER_DOT_PRODUCT_ACCELERATION_PROPERTIES_8BIT_KHR)
1542 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGER_DOT_PRODUCT_ACCELERATION_PROPERTIES_8BIT_KHR, cl_device_integer_dot_product_acceleration_properties_khr)
1543 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGER_DOT_PRODUCT_ACCELERATION_PROPERTIES_4x8BIT_PACKED_KHR, cl_device_integer_dot_product_acceleration_properties_khr)
1547 #ifdef CL_PLATFORM_ICD_SUFFIX_KHR
1548 CL_HPP_DECLARE_PARAM_TRAITS_(cl_platform_info, CL_PLATFORM_ICD_SUFFIX_KHR,
string)
1551 #ifdef CL_DEVICE_PROFILING_TIMER_OFFSET_AMD
1552 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_PROFILING_TIMER_OFFSET_AMD, cl_ulong)
1554 #ifdef CL_DEVICE_GLOBAL_FREE_MEMORY_AMD
1555 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_FREE_MEMORY_AMD, vector<size_type>)
1557 #ifdef CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD
1558 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD, cl_uint)
1560 #ifdef CL_DEVICE_SIMD_WIDTH_AMD
1561 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_WIDTH_AMD, cl_uint)
1563 #ifdef CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD
1564 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD, cl_uint)
1566 #ifdef CL_DEVICE_WAVEFRONT_WIDTH_AMD
1567 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_WAVEFRONT_WIDTH_AMD, cl_uint)
1569 #ifdef CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD
1570 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD, cl_uint)
1572 #ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD
1573 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD, cl_uint)
1575 #ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD
1576 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD, cl_uint)
1578 #ifdef CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD
1579 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD, cl_uint)
1581 #ifdef CL_DEVICE_LOCAL_MEM_BANKS_AMD
1582 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LOCAL_MEM_BANKS_AMD, cl_uint)
1584 #ifdef CL_DEVICE_BOARD_NAME_AMD
1585 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_BOARD_NAME_AMD,
string)
1588 #ifdef CL_DEVICE_COMPUTE_UNITS_BITFIELD_ARM
1589 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_UNITS_BITFIELD_ARM, cl_ulong)
1591 #ifdef CL_DEVICE_JOB_SLOTS_ARM
1592 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_JOB_SLOTS_ARM, cl_uint)
1594 #ifdef CL_DEVICE_SCHEDULING_CONTROLS_CAPABILITIES_ARM
1595 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SCHEDULING_CONTROLS_CAPABILITIES_ARM, cl_bitfield)
1597 #ifdef CL_DEVICE_SUPPORTED_REGISTER_ALLOCATIONS_ARM
1598 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SUPPORTED_REGISTER_ALLOCATIONS_ARM, vector<cl_uint>)
1600 #ifdef CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_ARM
1601 CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_ARM, cl_uint)
1603 #ifdef CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_MODIFIER_ARM
1604 CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_MODIFIER_ARM, cl_int)
1607 #ifdef CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV
1608 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV, cl_uint)
1610 #ifdef CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV
1611 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV, cl_uint)
1613 #ifdef CL_DEVICE_REGISTERS_PER_BLOCK_NV
1614 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_REGISTERS_PER_BLOCK_NV, cl_uint)
1616 #ifdef CL_DEVICE_WARP_SIZE_NV
1617 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_WARP_SIZE_NV, cl_uint)
1619 #ifdef CL_DEVICE_GPU_OVERLAP_NV
1620 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GPU_OVERLAP_NV, cl_bool)
1622 #ifdef CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV
1623 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV, cl_bool)
1625 #ifdef CL_DEVICE_INTEGRATED_MEMORY_NV
1626 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGRATED_MEMORY_NV, cl_bool)
1631 template <
typename Func,
typename T>
1633 getInfo(Func f, cl_uint name, T* param)
1635 return getInfoHelper(f, name, param, 0);
1638 template <
typename Func,
typename Arg0>
1641 Func f_;
const Arg0& arg0_;
1643 cl_uint param, size_type size,
void* value, size_type* size_ret)
1644 {
return f_(arg0_, param, size, value, size_ret); }
1647 template <
typename Func,
typename Arg0,
typename Arg1>
1650 Func f_;
const Arg0& arg0_;
const Arg1& arg1_;
1652 cl_uint param, size_type size,
void* value, size_type* size_ret)
1653 {
return f_(arg0_, arg1_, param, size, value, size_ret); }
1656 template <
typename Func,
typename Arg0,
typename T>
1658 getInfo(Func f,
const Arg0& arg0, cl_uint name, T* param)
1661 return getInfoHelper(f0, name, param, 0);
1664 template <
typename Func,
typename Arg0,
typename Arg1,
typename T>
1666 getInfo(Func f,
const Arg0& arg0,
const Arg1& arg1, cl_uint name, T* param)
1668 GetInfoFunctor1<Func, Arg0, Arg1> f0 = { f, arg0, arg1 };
1669 return getInfoHelper(f0, name, param, 0);
1673 template<
typename T>
1677 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
1694 { return ::clRetainDevice(device); }
1705 { return ::clReleaseDevice(device); }
1712 struct ReferenceHandler<cl_device_id>
1715 static cl_int retain(cl_device_id)
1716 {
return CL_SUCCESS; }
1718 static cl_int release(cl_device_id)
1719 {
return CL_SUCCESS; }
1727 static cl_int retain(cl_platform_id)
1728 {
return CL_SUCCESS; }
1730 static cl_int release(cl_platform_id)
1731 {
return CL_SUCCESS; }
1737 static cl_int retain(cl_context context)
1738 { return ::clRetainContext(context); }
1739 static cl_int release(cl_context context)
1740 { return ::clReleaseContext(context); }
1746 static cl_int retain(cl_command_queue queue)
1747 { return ::clRetainCommandQueue(queue); }
1748 static cl_int release(cl_command_queue queue)
1749 { return ::clReleaseCommandQueue(queue); }
1755 static cl_int retain(cl_mem memory)
1756 { return ::clRetainMemObject(memory); }
1757 static cl_int release(cl_mem memory)
1758 { return ::clReleaseMemObject(memory); }
1764 static cl_int retain(cl_sampler sampler)
1765 { return ::clRetainSampler(sampler); }
1766 static cl_int release(cl_sampler sampler)
1767 { return ::clReleaseSampler(sampler); }
1773 static cl_int retain(cl_program program)
1774 { return ::clRetainProgram(program); }
1775 static cl_int release(cl_program program)
1776 { return ::clReleaseProgram(program); }
1782 static cl_int retain(cl_kernel kernel)
1783 { return ::clRetainKernel(kernel); }
1784 static cl_int release(cl_kernel kernel)
1785 { return ::clReleaseKernel(kernel); }
1791 static cl_int retain(cl_event event)
1792 { return ::clRetainEvent(event); }
1793 static cl_int release(cl_event event)
1794 { return ::clReleaseEvent(event); }
1798 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
1800 static cl_uint getVersion(
const vector<char> &versionInfo)
1802 int highVersion = 0;
1805 while(versionInfo[index] !=
'.' ) {
1807 highVersion += versionInfo[index]-
'0';
1811 while(versionInfo[index] !=
' ' && versionInfo[index] !=
'\0') {
1813 lowVersion += versionInfo[index]-
'0';
1816 return (highVersion << 16) | lowVersion;
1819 static cl_uint getPlatformVersion(cl_platform_id platform)
1822 clGetPlatformInfo(platform, CL_PLATFORM_VERSION, 0, NULL, &size);
1824 vector<char> versionInfo(size);
1825 clGetPlatformInfo(platform, CL_PLATFORM_VERSION, size, versionInfo.data(), &size);
1826 return getVersion(versionInfo);
1829 static cl_uint getDevicePlatformVersion(cl_device_id device)
1831 cl_platform_id platform;
1832 clGetDeviceInfo(device, CL_DEVICE_PLATFORM,
sizeof(platform), &platform, NULL);
1833 return getPlatformVersion(platform);
1836 static cl_uint getContextPlatformVersion(cl_context context)
1841 clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, NULL, &size);
1844 vector<cl_device_id> devices(size/
sizeof(cl_device_id));
1845 clGetContextInfo(context, CL_CONTEXT_DEVICES, size, devices.data(), NULL);
1846 return getDevicePlatformVersion(devices[0]);
1850 template <
typename T>
1862 Wrapper(
const cl_type &obj,
bool retainObject) : object_(obj)
1865 detail::errHandler(retain(), __RETAIN_ERR);
1871 if (object_ != NULL) { release(); }
1876 object_ = rhs.object_;
1877 detail::errHandler(retain(), __RETAIN_ERR);
1882 object_ = rhs.object_;
1889 detail::errHandler(release(), __RELEASE_ERR);
1890 object_ = rhs.object_;
1891 detail::errHandler(retain(), __RETAIN_ERR);
1899 detail::errHandler(release(), __RELEASE_ERR);
1900 object_ = rhs.object_;
1908 detail::errHandler(release(), __RELEASE_ERR);
1913 const cl_type& operator ()()
const {
return object_; }
1915 cl_type& operator ()() {
return object_; }
1917 cl_type get()
const {
return object_; }
1920 template<
typename Func,
typename U>
1921 friend inline cl_int getInfoHelper(Func, cl_uint, U*,
int,
typename U::cl_type);
1923 cl_int retain()
const
1925 if (object_ !=
nullptr) {
1933 cl_int release()
const
1935 if (object_ !=
nullptr) {
1948 typedef cl_device_id cl_type;
1952 bool referenceCountable_;
1954 static bool isReferenceCountable(cl_device_id device)
1956 bool retVal =
false;
1957 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
1958 #if CL_HPP_MINIMUM_OPENCL_VERSION < 120
1959 if (device != NULL) {
1960 int version = getDevicePlatformVersion(device);
1961 if(version > ((1 << 16) + 1)) {
1973 Wrapper() : object_(NULL), referenceCountable_(
false)
1977 Wrapper(
const cl_type &obj,
bool retainObject) :
1979 referenceCountable_(
false)
1981 referenceCountable_ = isReferenceCountable(obj);
1984 detail::errHandler(retain(), __RETAIN_ERR);
1995 object_ = rhs.object_;
1996 referenceCountable_ = isReferenceCountable(object_);
1997 detail::errHandler(retain(), __RETAIN_ERR);
2002 object_ = rhs.object_;
2003 referenceCountable_ = rhs.referenceCountable_;
2005 rhs.referenceCountable_ =
false;
2011 detail::errHandler(release(), __RELEASE_ERR);
2012 object_ = rhs.object_;
2013 referenceCountable_ = rhs.referenceCountable_;
2014 detail::errHandler(retain(), __RETAIN_ERR);
2022 detail::errHandler(release(), __RELEASE_ERR);
2023 object_ = rhs.object_;
2024 referenceCountable_ = rhs.referenceCountable_;
2026 rhs.referenceCountable_ =
false;
2033 detail::errHandler(release(), __RELEASE_ERR);
2035 referenceCountable_ = isReferenceCountable(object_);
2039 const cl_type& operator ()()
const {
return object_; }
2041 cl_type& operator ()() {
return object_; }
2043 cl_type get()
const {
return object_; }
2046 template<
typename Func,
typename U>
2047 friend inline cl_int getInfoHelper(Func, cl_uint, U*,
int,
typename U::cl_type);
2049 template<
typename Func,
typename U>
2050 friend inline cl_int getInfoHelper(Func, cl_uint, vector<U>*,
int,
typename U::cl_type);
2052 cl_int retain()
const
2054 if( object_ !=
nullptr && referenceCountable_ ) {
2062 cl_int release()
const
2064 if (object_ !=
nullptr && referenceCountable_) {
2073 template <
typename T>
2076 return lhs() == rhs();
2079 template <
typename T>
2080 inline bool operator!=(
const Wrapper<T> &lhs,
const Wrapper<T> &rhs)
2082 return !operator==(lhs, rhs);
2089 using BuildLogType = vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, CL_PROGRAM_BUILD_LOG>::param_type>>;
2090 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
2094 class BuildError :
public Error
2097 BuildLogType buildLogs;
2099 BuildError(cl_int err,
const char * errStr,
const BuildLogType &vec) : Error(err, errStr), buildLogs(vec)
2103 BuildLogType getBuildLog()
const
2109 static inline cl_int buildErrHandler(
2111 const char * errStr,
2112 const BuildLogType &buildLogs)
2114 if (err != CL_SUCCESS) {
2115 throw BuildError(err, errStr, buildLogs);
2123 static inline cl_int buildErrHandler(
2125 const char * errStr,
2126 const BuildLogType &buildLogs)
2149 image_channel_order = order;
2150 image_channel_data_type = type;
2160 this->image_channel_data_type = rhs.image_channel_data_type;
2161 this->image_channel_order = rhs.image_channel_order;
2177 static std::once_flag default_initialized_;
2179 static cl_int default_error_;
2186 static void makeDefault();
2193 static void makeDefaultProvided(
const Device &p) {
2198 #ifdef CL_HPP_UNIT_TEST_ENABLE
2205 static void unitTestClearDefault() {
2217 explicit Device(
const cl_device_id &device,
bool retainObject =
false) :
2218 detail::Wrapper<cl_type>(device, retainObject) { }
2225 cl_int *errResult = NULL)
2227 std::call_once(default_initialized_, makeDefault);
2228 detail::errHandler(default_error_);
2229 if (errResult != NULL) {
2230 *errResult = default_error_;
2244 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_device));
2245 detail::errHandler(default_error_);
2288 template <
typename T>
2289 cl_int
getInfo(cl_device_info name, T* param)
const
2291 return detail::errHandler(
2292 detail::getInfo(&::clGetDeviceInfo, object_, name, param),
2293 __GET_DEVICE_INFO_ERR);
2297 template <cl_device_info name>
typename
2302 detail::cl_device_info, name>::param_type param;
2303 cl_int result =
getInfo(name, ¶m);
2311 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
2320 cl_ulong retVal = 0;
2322 clGetHostTimer(this->get(), &retVal);
2325 __GET_HOST_TIMER_ERR);
2344 std::pair<cl_ulong, cl_ulong> retVal;
2346 clGetDeviceAndHostTimer(this->get(), &(retVal.first), &(retVal.second));
2349 __GET_DEVICE_AND_HOST_TIMER_ERR);
2360 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
2363 const cl_device_partition_property * properties,
2364 vector<Device>* devices)
2367 cl_int err = clCreateSubDevices(object_, properties, 0, NULL, &n);
2368 if (err != CL_SUCCESS) {
2369 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2372 vector<cl_device_id> ids(n);
2373 err = clCreateSubDevices(object_, properties, n, ids.data(), NULL);
2374 if (err != CL_SUCCESS) {
2375 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2381 devices->resize(ids.size());
2385 for (size_type i = 0; i < ids.size(); i++) {
2388 (*devices)[i] =
Device(ids[i],
false);
2394 #elif defined(CL_HPP_USE_CL_DEVICE_FISSION)
2400 const cl_device_partition_property_ext * properties,
2401 vector<Device>* devices)
2403 typedef CL_API_ENTRY cl_int
2404 ( CL_API_CALL * PFN_clCreateSubDevicesEXT)(
2406 const cl_device_partition_property_ext * ,
2409 cl_uint * ) CL_API_SUFFIX__VERSION_1_1;
2411 static PFN_clCreateSubDevicesEXT pfn_clCreateSubDevicesEXT = NULL;
2412 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateSubDevicesEXT);
2415 cl_int err = pfn_clCreateSubDevicesEXT(object_, properties, 0, NULL, &n);
2416 if (err != CL_SUCCESS) {
2417 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2420 vector<cl_device_id> ids(n);
2421 err = pfn_clCreateSubDevicesEXT(object_, properties, n, ids.data(), NULL);
2422 if (err != CL_SUCCESS) {
2423 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2428 devices->resize(ids.size());
2432 for (size_type i = 0; i < ids.size(); i++) {
2435 (*devices)[i] =
Device(ids[i],
false);
2443 CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Device::default_initialized_;
2444 CL_HPP_DEFINE_STATIC_MEMBER_ Device Device::default_;
2445 CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Device::default_error_ = CL_SUCCESS;
2457 static std::once_flag default_initialized_;
2459 static cl_int default_error_;
2466 static void makeDefault() {
2470 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
2478 cl_int err = ::clGetPlatformIDs(0, NULL, &n);
2479 if (err != CL_SUCCESS) {
2480 default_error_ = err;
2484 default_error_ = CL_INVALID_PLATFORM;
2488 vector<cl_platform_id> ids(n);
2489 err = ::clGetPlatformIDs(n, ids.data(), NULL);
2490 if (err != CL_SUCCESS) {
2491 default_error_ = err;
2497 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
2498 catch (cl::Error &e) {
2499 default_error_ = e.err();
2509 static void makeDefaultProvided(
const Platform &p) {
2514 #ifdef CL_HPP_UNIT_TEST_ENABLE
2521 static void unitTestClearDefault() {
2536 explicit Platform(
const cl_platform_id &platform,
bool retainObject =
false) :
2537 detail::Wrapper<cl_type>(platform, retainObject) { }
2550 cl_int *errResult = NULL)
2552 std::call_once(default_initialized_, makeDefault);
2553 detail::errHandler(default_error_);
2554 if (errResult != NULL) {
2555 *errResult = default_error_;
2569 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_platform));
2570 detail::errHandler(default_error_);
2575 template <
typename T>
2576 cl_int
getInfo(cl_platform_info name, T* param)
const
2578 return detail::errHandler(
2579 detail::getInfo(&::clGetPlatformInfo, object_, name, param),
2580 __GET_PLATFORM_INFO_ERR);
2584 template <cl_platform_info name>
typename
2589 detail::cl_platform_info, name>::param_type param;
2590 cl_int result =
getInfo(name, ¶m);
2602 cl_device_type type,
2603 vector<Device>* devices)
const
2606 if( devices == NULL ) {
2607 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR);
2609 cl_int err = ::clGetDeviceIDs(object_, type, 0, NULL, &n);
2610 if (err != CL_SUCCESS && err != CL_DEVICE_NOT_FOUND) {
2611 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2614 vector<cl_device_id> ids(n);
2616 err = ::clGetDeviceIDs(object_, type, n, ids.data(), NULL);
2617 if (err != CL_SUCCESS) {
2618 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2627 devices->resize(ids.size());
2631 for (size_type i = 0; i < ids.size(); i++) {
2632 (*devices)[i] =
Device(ids[i],
true);
2638 #if defined(CL_HPP_USE_DX_INTEROP)
2663 cl_d3d10_device_source_khr d3d_device_source,
2665 cl_d3d10_device_set_khr d3d_device_set,
2666 vector<Device>* devices)
const
2668 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clGetDeviceIDsFromD3D10KHR)(
2669 cl_platform_id platform,
2670 cl_d3d10_device_source_khr d3d_device_source,
2672 cl_d3d10_device_set_khr d3d_device_set,
2673 cl_uint num_entries,
2674 cl_device_id * devices,
2675 cl_uint* num_devices);
2677 if( devices == NULL ) {
2678 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR);
2681 static PFN_clGetDeviceIDsFromD3D10KHR pfn_clGetDeviceIDsFromD3D10KHR = NULL;
2682 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(object_, clGetDeviceIDsFromD3D10KHR);
2685 cl_int err = pfn_clGetDeviceIDsFromD3D10KHR(
2693 if (err != CL_SUCCESS) {
2694 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2697 vector<cl_device_id> ids(n);
2698 err = pfn_clGetDeviceIDsFromD3D10KHR(
2706 if (err != CL_SUCCESS) {
2707 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2715 devices->resize(ids.size());
2719 for (size_type i = 0; i < ids.size(); i++) {
2720 (*devices)[i] = Device(ids[i],
true);
2732 vector<Platform>* platforms)
2736 if( platforms == NULL ) {
2737 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_PLATFORM_IDS_ERR);
2740 cl_int err = ::clGetPlatformIDs(0, NULL, &n);
2741 if (err != CL_SUCCESS) {
2742 return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
2745 vector<cl_platform_id> ids(n);
2746 err = ::clGetPlatformIDs(n, ids.data(), NULL);
2747 if (err != CL_SUCCESS) {
2748 return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
2752 platforms->resize(ids.size());
2755 for (size_type i = 0; i < ids.size(); i++) {
2756 (*platforms)[i] =
Platform(ids[i]);
2770 Platform default_platform = Platform::getDefault(&err);
2772 *platform = default_platform;
2786 cl_int * errResult = NULL)
2789 Platform default_platform = Platform::getDefault(&err);
2793 return default_platform;
2796 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
2801 return ::clUnloadPlatformCompiler(object_);
2806 CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Platform::default_initialized_;
2807 CL_HPP_DEFINE_STATIC_MEMBER_ Platform Platform::default_;
2808 CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Platform::default_error_ = CL_SUCCESS;
2814 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
2819 inline CL_API_PREFIX__VERSION_1_1_DEPRECATED cl_int
2824 return ::clUnloadCompiler();
2840 static std::once_flag default_initialized_;
2842 static cl_int default_error_;
2849 static void makeDefault() {
2853 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
2857 #if !defined(__APPLE__) && !defined(__MACOS)
2858 const Platform &p = Platform::getDefault();
2859 cl_platform_id defaultPlatform = p();
2860 cl_context_properties properties[3] = {
2861 CL_CONTEXT_PLATFORM, (cl_context_properties)defaultPlatform, 0
2864 cl_context_properties *properties =
nullptr;
2868 CL_DEVICE_TYPE_DEFAULT,
2874 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
2875 catch (cl::Error &e) {
2876 default_error_ = e.err();
2887 static void makeDefaultProvided(
const Context &c) {
2892 #ifdef CL_HPP_UNIT_TEST_ENABLE
2899 static void unitTestClearDefault() {
2909 const vector<Device>& devices,
2910 const cl_context_properties* properties = NULL,
2911 void (CL_CALLBACK * notifyFptr)(
2921 size_type numDevices = devices.size();
2922 vector<cl_device_id> deviceIDs(numDevices);
2924 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
2925 deviceIDs[deviceIndex] = (devices[deviceIndex])();
2928 object_ = ::clCreateContext(
2929 properties, (cl_uint) numDevices,
2931 notifyFptr, data, &error);
2933 detail::errHandler(error, __CREATE_CONTEXT_ERR);
2945 const cl_context_properties* properties = NULL,
2946 void (CL_CALLBACK * notifyFptr)(
2956 cl_device_id deviceID = device();
2958 object_ = ::clCreateContext(
2961 notifyFptr, data, &error);
2963 detail::errHandler(error, __CREATE_CONTEXT_ERR);
2974 cl_device_type type,
2975 const cl_context_properties* properties = NULL,
2976 void (CL_CALLBACK * notifyFptr)(
2986 #if !defined(__APPLE__) && !defined(__MACOS)
2987 cl_context_properties prop[4] = {CL_CONTEXT_PLATFORM, 0, 0, 0 };
2989 if (properties == NULL) {
2991 vector<Platform> platforms;
2992 error = Platform::get(&platforms);
2993 if (error != CL_SUCCESS) {
2994 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
3002 cl_context_properties platform_id = 0;
3003 for (
unsigned int i = 0; i < platforms.size(); i++) {
3005 vector<Device> devices;
3007 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
3011 error = platforms[i].getDevices(type, &devices);
3013 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
3014 }
catch (cl::Error& e) {
3022 if (error != CL_SUCCESS && error != CL_DEVICE_NOT_FOUND) {
3023 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
3029 if (devices.size() > 0) {
3030 platform_id = (cl_context_properties)platforms[i]();
3035 if (platform_id == 0) {
3036 detail::errHandler(CL_DEVICE_NOT_FOUND, __CREATE_CONTEXT_FROM_TYPE_ERR);
3038 *err = CL_DEVICE_NOT_FOUND;
3043 prop[1] = platform_id;
3044 properties = &prop[0];
3047 object_ = ::clCreateContextFromType(
3048 properties, type, notifyFptr, data, &error);
3050 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
3091 std::call_once(default_initialized_, makeDefault);
3092 detail::errHandler(default_error_);
3094 *err = default_error_;
3108 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_context));
3109 detail::errHandler(default_error_);
3121 explicit Context(
const cl_context& context,
bool retainObject =
false) :
3122 detail::Wrapper<cl_type>(context, retainObject) { }
3136 template <
typename T>
3137 cl_int
getInfo(cl_context_info name, T* param)
const
3139 return detail::errHandler(
3140 detail::getInfo(&::clGetContextInfo, object_, name, param),
3141 __GET_CONTEXT_INFO_ERR);
3145 template <cl_context_info name>
typename
3150 detail::cl_context_info, name>::param_type param;
3151 cl_int result =
getInfo(name, ¶m);
3164 cl_mem_object_type type,
3165 vector<ImageFormat>* formats)
const
3173 cl_int err = ::clGetSupportedImageFormats(
3180 if (err != CL_SUCCESS) {
3181 return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
3184 if (numEntries > 0) {
3185 vector<ImageFormat> value(numEntries);
3186 err = ::clGetSupportedImageFormats(
3191 (cl_image_format*)value.data(),
3193 if (err != CL_SUCCESS) {
3194 return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
3197 formats->assign(begin(value), end(value));
3208 inline void Device::makeDefault()
3213 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
3220 detail::errHandler(error, __CREATE_CONTEXT_ERR);
3222 if (error != CL_SUCCESS) {
3223 default_error_ = error;
3226 default_ = context.
getInfo<CL_CONTEXT_DEVICES>()[0];
3227 default_error_ = CL_SUCCESS;
3230 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
3231 catch (cl::Error &e) {
3232 default_error_ = e.err();
3237 CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Context::default_initialized_;
3238 CL_HPP_DEFINE_STATIC_MEMBER_ Context Context::default_;
3239 CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Context::default_error_ = CL_SUCCESS;
3253 Event() : detail::Wrapper<cl_type>() { }
3263 explicit Event(
const cl_event& event,
bool retainObject =
false) :
3264 detail::Wrapper<cl_type>(event, retainObject) { }
3278 template <
typename T>
3279 cl_int
getInfo(cl_event_info name, T* param)
const
3281 return detail::errHandler(
3282 detail::getInfo(&::clGetEventInfo, object_, name, param),
3283 __GET_EVENT_INFO_ERR);
3287 template <cl_event_info name>
typename
3292 detail::cl_event_info, name>::param_type param;
3293 cl_int result =
getInfo(name, ¶m);
3301 template <
typename T>
3304 return detail::errHandler(detail::getInfo(
3305 &::clGetEventProfilingInfo, object_, name, param),
3306 __GET_EVENT_PROFILE_INFO_ERR);
3310 template <cl_profiling_info name>
typename
3315 detail::cl_profiling_info, name>::param_type param;
3329 return detail::errHandler(
3330 ::clWaitForEvents(1, &object_),
3331 __WAIT_FOR_EVENTS_ERR);
3334 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
3341 void (CL_CALLBACK * pfn_notify)(cl_event, cl_int,
void *),
3342 void * user_data = NULL)
3344 return detail::errHandler(
3345 ::clSetEventCallback(
3350 __SET_EVENT_CALLBACK_ERR);
3361 return detail::errHandler(
3363 (cl_uint) events.size(), (events.size() > 0) ? (cl_event*)&events.front() : NULL),
3364 __WAIT_FOR_EVENTS_ERR);
3368 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
3382 cl_int * err = NULL)
3385 object_ = ::clCreateUserEvent(
3389 detail::errHandler(error, __CREATE_USER_EVENT_ERR);
3404 return detail::errHandler(
3405 ::clSetUserEventStatus(object_,status),
3406 __SET_USER_EVENT_STATUS_ERR);
3415 inline static cl_int
3416 WaitForEvents(
const vector<Event>& events)
3418 return detail::errHandler(
3420 (cl_uint) events.size(), (events.size() > 0) ? (cl_event*)&events.front() : NULL),
3421 __WAIT_FOR_EVENTS_ERR);
3449 explicit Memory(
const cl_mem& memory,
bool retainObject) :
3450 detail::Wrapper<cl_type>(memory, retainObject) { }
3493 template <
typename T>
3496 return detail::errHandler(
3497 detail::getInfo(&::clGetMemObjectInfo, object_, name, param),
3498 __GET_MEM_OBJECT_INFO_ERR);
3502 template <cl_mem_info name>
typename
3507 detail::cl_mem_info, name>::param_type param;
3508 cl_int result =
getInfo(name, ¶m);
3515 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
3530 void (CL_CALLBACK * pfn_notify)(cl_mem,
void *),
3531 void * user_data = NULL)
3533 return detail::errHandler(
3534 ::clSetMemObjectDestructorCallback(
3538 __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR);
3546 template<
typename IteratorType >
3547 cl_int
copy( IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer );
3548 template<
typename IteratorType >
3549 cl_int
copy(
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator );
3550 template<
typename IteratorType >
3551 cl_int
copy(
const CommandQueue &queue, IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer );
3552 template<
typename IteratorType >
3553 cl_int
copy(
const CommandQueue &queue,
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator );
3556 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
3562 static cl_svm_mem_flags getSVMMemFlags()
3569 template<
class Trait = detail::SVMTraitNull>
3573 static cl_svm_mem_flags getSVMMemFlags()
3575 return CL_MEM_READ_WRITE |
3576 Trait::getSVMMemFlags();
3580 template<
class Trait = detail::SVMTraitNull>
3584 static cl_svm_mem_flags getSVMMemFlags()
3586 return CL_MEM_READ_ONLY |
3587 Trait::getSVMMemFlags();
3591 template<
class Trait = detail::SVMTraitNull>
3595 static cl_svm_mem_flags getSVMMemFlags()
3597 return CL_MEM_WRITE_ONLY |
3598 Trait::getSVMMemFlags();
3602 template<
class Trait = SVMTraitReadWrite<>>
3606 static cl_svm_mem_flags getSVMMemFlags()
3608 return Trait::getSVMMemFlags();
3612 template<
class Trait = SVMTraitReadWrite<>>
3616 static cl_svm_mem_flags getSVMMemFlags()
3618 return CL_MEM_SVM_FINE_GRAIN_BUFFER |
3619 Trait::getSVMMemFlags();
3623 template<
class Trait = SVMTraitReadWrite<>>
3627 static cl_svm_mem_flags getSVMMemFlags()
3630 CL_MEM_SVM_FINE_GRAIN_BUFFER |
3631 CL_MEM_SVM_ATOMICS |
3632 Trait::getSVMMemFlags();
3637 template<
typename T>
3643 const vector<Event>* events = NULL,
3644 Event* event = NULL);
3657 template<
typename T,
class SVMTrait>
3663 typedef T value_type;
3664 typedef value_type* pointer;
3665 typedef const value_type* const_pointer;
3666 typedef value_type& reference;
3667 typedef const value_type& const_reference;
3668 typedef std::size_t size_type;
3669 typedef std::ptrdiff_t difference_type;
3671 template<
typename U>
3677 template<
typename U,
typename V>
3681 context_(
Context::getDefault())
3691 SVMAllocator(
const SVMAllocator &other) :
3692 context_(other.context_)
3696 template<
typename U>
3697 SVMAllocator(
const SVMAllocator<U, SVMTrait> &other) :
3698 context_(other.context_)
3706 pointer address(reference r) CL_HPP_NOEXCEPT_
3708 return std::addressof(r);
3711 const_pointer address(const_reference r) CL_HPP_NOEXCEPT_
3713 return std::addressof(r);
3730 SVMTrait::getSVMMemFlags(),
3733 pointer retValue =
reinterpret_cast<pointer
>(
3735 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
3737 std::bad_alloc excep;
3743 if (!(SVMTrait::getSVMMemFlags() & CL_MEM_SVM_FINE_GRAIN_BUFFER)) {
3744 cl_int err =
enqueueMapSVM(retValue, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE, size*
sizeof(T));
3745 if (err != CL_SUCCESS) {
3746 std::bad_alloc excep;
3755 void deallocate(pointer p, size_type)
3757 clSVMFree(context_(), p);
3766 size_type maxSize = std::numeric_limits<size_type>::max() /
sizeof(T);
3768 for (
const Device &d : context_.
getInfo<CL_CONTEXT_DEVICES>()) {
3771 static_cast<size_type
>(d.getInfo<CL_DEVICE_MAX_MEM_ALLOC_SIZE>()));
3777 template<
class U,
class... Args >
3778 void construct(U* p, Args&&... args)
3794 return (context_==rhs.context_);
3804 template<
class SVMTrait>
3807 typedef void value_type;
3808 typedef value_type* pointer;
3809 typedef const value_type* const_pointer;
3811 template<
typename U>
3817 template<
typename U,
typename V>
3821 #if !defined(CL_HPP_NO_STD_UNIQUE_PTR)
3824 template<
class Alloc>
3831 typedef typename std::allocator_traits<Alloc>::pointer pointer;
3833 Deleter(
const Alloc &alloc, size_type copies) : alloc_{ alloc }, copies_{ copies }
3837 void operator()(pointer ptr)
const {
3838 Alloc tmpAlloc{ alloc_ };
3839 std::allocator_traits<Alloc>::destroy(tmpAlloc, std::addressof(*ptr));
3840 std::allocator_traits<Alloc>::deallocate(tmpAlloc, ptr, copies_);
3851 template <
class T,
class Alloc,
class... Args>
3854 Alloc alloc(alloc_);
3855 static const size_type copies = 1;
3860 T* tmp = std::allocator_traits<Alloc>::allocate(alloc, copies);
3862 std::bad_alloc excep;
3866 std::allocator_traits<Alloc>::construct(
3868 std::addressof(*tmp),
3869 std::forward<Args>(args)...);
3873 catch (std::bad_alloc& b)
3875 std::allocator_traits<Alloc>::deallocate(alloc, tmp, copies);
3880 template<
class T,
class SVMTrait,
class... Args >
3881 cl::pointer<T, detail::Deleter<SVMAllocator<T, SVMTrait>>> allocate_svm(Args... args)
3883 SVMAllocator<T, SVMTrait> alloc;
3884 return cl::allocate_pointer<T>(alloc, args...);
3887 template<
class T,
class SVMTrait,
class... Args >
3888 cl::pointer<T, detail::Deleter<SVMAllocator<T, SVMTrait>>> allocate_svm(
const cl::Context &c, Args... args)
3890 SVMAllocator<T, SVMTrait> alloc(c);
3891 return cl::allocate_pointer<T>(alloc, args...);
3898 template <
class T >
3904 template <
class T >
3910 template <
class T >
3937 void* host_ptr = NULL,
3941 object_ = ::clCreateBuffer(context(), flags, size, host_ptr, &error);
3943 detail::errHandler(error, __CREATE_BUFFER_ERR);
3961 void* host_ptr = NULL,
3968 object_ = ::clCreateBuffer(context(), flags, size, host_ptr, &error);
3970 detail::errHandler(error, __CREATE_BUFFER_ERR);
3981 template<
typename IteratorType >
3983 IteratorType startIterator,
3984 IteratorType endIterator,
3986 bool useHostPtr =
false,
3989 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
3992 cl_mem_flags flags = 0;
3994 flags |= CL_MEM_READ_ONLY;
3997 flags |= CL_MEM_READ_WRITE;
4000 flags |= CL_MEM_USE_HOST_PTR;
4003 size_type size =
sizeof(DataType)*(endIterator - startIterator);
4008 object_ = ::clCreateBuffer(context(), flags, size,
static_cast<DataType*
>(&*startIterator), &error);
4010 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
4013 detail::errHandler(error, __CREATE_BUFFER_ERR);
4019 error =
cl::copy(startIterator, endIterator, *
this);
4020 detail::errHandler(error, __CREATE_BUFFER_ERR);
4032 template<
typename IteratorType >
4033 Buffer(
const Context &context, IteratorType startIterator, IteratorType endIterator,
4034 bool readOnly,
bool useHostPtr =
false, cl_int* err = NULL);
4040 template<
typename IteratorType >
4041 Buffer(
const CommandQueue &queue, IteratorType startIterator, IteratorType endIterator,
4042 bool readOnly,
bool useHostPtr =
false, cl_int* err = NULL);
4054 explicit Buffer(
const cl_mem& buffer,
bool retainObject =
false) :
4055 Memory(buffer, retainObject) { }
4095 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
4102 cl_buffer_create_type buffer_create_type,
4103 const void * buffer_create_info,
4104 cl_int * err = NULL)
4108 result.object_ = ::clCreateSubBuffer(
4115 detail::errHandler(error, __CREATE_SUBBUFFER_ERR);
4125 #if defined (CL_HPP_USE_DX_INTEROP)
4134 class BufferD3D10 :
public Buffer
4145 const Context& context,
4147 ID3D10Buffer* bufobj,
4148 cl_int * err = NULL) : pfn_clCreateFromD3D10BufferKHR(nullptr)
4150 typedef CL_API_ENTRY cl_mem (CL_API_CALL *PFN_clCreateFromD3D10BufferKHR)(
4151 cl_context context, cl_mem_flags flags, ID3D10Buffer* buffer,
4152 cl_int* errcode_ret);
4153 PFN_clCreateFromD3D10BufferKHR pfn_clCreateFromD3D10BufferKHR;
4154 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
4155 vector<cl_context_properties> props = context.getInfo<CL_CONTEXT_PROPERTIES>();
4156 cl_platform platform = -1;
4157 for(
int i = 0; i < props.size(); ++i ) {
4158 if( props[i] == CL_CONTEXT_PLATFORM ) {
4159 platform = props[i+1];
4162 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCreateFromD3D10BufferKHR);
4163 #elif CL_HPP_TARGET_OPENCL_VERSION >= 110
4164 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateFromD3D10BufferKHR);
4168 object_ = pfn_clCreateFromD3D10BufferKHR(
4174 detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
4181 BufferD3D10() : Buffer() { }
4190 explicit BufferD3D10(
const cl_mem& buffer,
bool retainObject =
false) :
4191 Buffer(buffer, retainObject) { }
4197 BufferD3D10& operator = (
const cl_mem& rhs)
4206 BufferD3D10(
const BufferD3D10& buf) :
4212 BufferD3D10& operator = (
const BufferD3D10 &buf)
4221 BufferD3D10(BufferD3D10&& buf) CL_HPP_NOEXCEPT_ : Buffer(std::move(buf)) {}
4226 BufferD3D10& operator = (BufferD3D10 &&buf)
4254 cl_int * err = NULL)
4257 object_ = ::clCreateFromGLBuffer(
4263 detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
4279 explicit BufferGL(
const cl_mem& buffer,
bool retainObject =
false) :
4280 Buffer(buffer, retainObject) { }
4322 cl_gl_object_type *type,
4323 cl_GLuint * gl_object_name)
4325 return detail::errHandler(
4326 ::clGetGLObjectInfo(object_,type,gl_object_name),
4327 __GET_GL_OBJECT_INFO_ERR);
4351 cl_int * err = NULL)
4354 object_ = ::clCreateFromGLRenderbuffer(
4360 detail::errHandler(error, __CREATE_GL_RENDER_BUFFER_ERR);
4377 Buffer(buffer, retainObject) { }
4419 cl_gl_object_type *type,
4420 cl_GLuint * gl_object_name)
4422 return detail::errHandler(
4423 ::clGetGLObjectInfo(object_,type,gl_object_name),
4424 __GET_GL_OBJECT_INFO_ERR);
4447 explicit Image(
const cl_mem& image,
bool retainObject =
false) :
4448 Memory(image, retainObject) { }
4491 template <
typename T>
4494 return detail::errHandler(
4495 detail::getInfo(&::clGetImageInfo, object_, name, param),
4496 __GET_IMAGE_INFO_ERR);
4500 template <cl_image_info name>
typename
4505 detail::cl_image_info, name>::param_type param;
4514 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
4533 void* host_ptr = NULL,
4538 cl_image_desc desc = {0};
4539 desc.image_type = CL_MEM_OBJECT_IMAGE1D;
4540 desc.image_width = width;
4542 object_ = ::clCreateImage(
4550 detail::errHandler(error, __CREATE_IMAGE_ERR);
4566 explicit Image1D(
const cl_mem& image1D,
bool retainObject =
false) :
4567 Image(image1D, retainObject) { }
4625 cl_image_desc desc = {0};
4626 desc.image_type = CL_MEM_OBJECT_IMAGE1D_BUFFER;
4627 desc.image_width = width;
4628 desc.buffer = buffer();
4630 object_ = ::clCreateImage(
4638 detail::errHandler(error, __CREATE_IMAGE_ERR);
4654 Image(image1D, retainObject) { }
4702 size_type arraySize,
4705 void* host_ptr = NULL,
4710 cl_image_desc desc = {0};
4711 desc.image_type = CL_MEM_OBJECT_IMAGE1D_ARRAY;
4712 desc.image_width = width;
4713 desc.image_array_size = arraySize;
4714 desc.image_row_pitch = rowPitch;
4716 object_ = ::clCreateImage(
4724 detail::errHandler(error, __CREATE_IMAGE_ERR);
4739 explicit Image1DArray(
const cl_mem& imageArray,
bool retainObject =
false) :
4740 Image(imageArray, retainObject) { }
4800 size_type row_pitch = 0,
4801 void* host_ptr = NULL,
4805 bool useCreateImage;
4807 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
4810 cl_uint version = detail::getContextPlatformVersion(context());
4811 useCreateImage = (version >= 0x10002);
4813 #elif CL_HPP_TARGET_OPENCL_VERSION >= 120
4814 useCreateImage =
true;
4816 useCreateImage =
false;
4819 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
4822 cl_image_desc desc = {0};
4823 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
4824 desc.image_width = width;
4825 desc.image_height = height;
4826 desc.image_row_pitch = row_pitch;
4828 object_ = ::clCreateImage(
4836 detail::errHandler(error, __CREATE_IMAGE_ERR);
4842 #if CL_HPP_MINIMUM_OPENCL_VERSION < 120
4843 if (!useCreateImage)
4845 object_ = ::clCreateImage2D(
4846 context(), flags,&format, width, height, row_pitch, host_ptr, &error);
4848 detail::errHandler(error, __CREATE_IMAGE2D_ERR);
4856 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 || defined(CL_HPP_USE_CL_IMAGE2D_FROM_BUFFER_KHR)
4865 const Buffer &sourceBuffer,
4868 size_type row_pitch = 0,
4869 cl_int* err =
nullptr)
4873 cl_image_desc desc = {0};
4874 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
4875 desc.image_width = width;
4876 desc.image_height = height;
4877 desc.image_row_pitch = row_pitch;
4878 desc.buffer = sourceBuffer();
4880 object_ = ::clCreateImage(
4888 detail::errHandler(error, __CREATE_IMAGE_ERR);
4889 if (err !=
nullptr) {
4895 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
4910 cl_channel_order order,
4911 const Image &sourceImage,
4912 cl_int* err =
nullptr)
4917 size_type sourceWidth =
4919 size_type sourceHeight =
4921 size_type sourceRowPitch =
4923 cl_uint sourceNumMIPLevels =
4925 cl_uint sourceNumSamples =
4927 cl_image_format sourceFormat =
4932 sourceFormat.image_channel_order = order;
4934 cl_image_desc desc = {0};
4935 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
4936 desc.image_width = sourceWidth;
4937 desc.image_height = sourceHeight;
4938 desc.image_row_pitch = sourceRowPitch;
4939 desc.num_mip_levels = sourceNumMIPLevels;
4940 desc.num_samples = sourceNumSamples;
4941 desc.buffer = sourceImage();
4943 object_ = ::clCreateImage(
4951 detail::errHandler(error, __CREATE_IMAGE_ERR);
4952 if (err !=
nullptr) {
4968 explicit Image2D(
const cl_mem& image2D,
bool retainObject =
false) :
4969 Image(image2D, retainObject) { }
5012 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
5036 cl_int * err = NULL)
5039 object_ = ::clCreateFromGLTexture2D(
5047 detail::errHandler(error, __CREATE_GL_TEXTURE_2D_ERR);
5064 explicit Image2DGL(
const cl_mem& image,
bool retainObject =
false) :
5065 Image2D(image, retainObject) { }
5105 } CL_API_SUFFIX__VERSION_1_1_DEPRECATED;
5108 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
5119 size_type arraySize,
5123 size_type slicePitch,
5124 void* host_ptr = NULL,
5129 cl_image_desc desc = {0};
5130 desc.image_type = CL_MEM_OBJECT_IMAGE2D_ARRAY;
5131 desc.image_width = width;
5132 desc.image_height = height;
5133 desc.image_array_size = arraySize;
5134 desc.image_row_pitch = rowPitch;
5135 desc.image_slice_pitch = slicePitch;
5137 object_ = ::clCreateImage(
5145 detail::errHandler(error, __CREATE_IMAGE_ERR);
5160 explicit Image2DArray(
const cl_mem& imageArray,
bool retainObject =
false) :
Image(imageArray, retainObject) { }
5218 size_type row_pitch = 0,
5219 size_type slice_pitch = 0,
5220 void* host_ptr = NULL,
5224 bool useCreateImage;
5226 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
5229 cl_uint version = detail::getContextPlatformVersion(context());
5230 useCreateImage = (version >= 0x10002);
5232 #elif CL_HPP_TARGET_OPENCL_VERSION >= 120
5233 useCreateImage =
true;
5235 useCreateImage =
false;
5238 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
5241 cl_image_desc desc = {0};
5242 desc.image_type = CL_MEM_OBJECT_IMAGE3D;
5243 desc.image_width = width;
5244 desc.image_height = height;
5245 desc.image_depth = depth;
5246 desc.image_row_pitch = row_pitch;
5247 desc.image_slice_pitch = slice_pitch;
5249 object_ = ::clCreateImage(
5257 detail::errHandler(error, __CREATE_IMAGE_ERR);
5263 #if CL_HPP_MINIMUM_OPENCL_VERSION < 120
5264 if (!useCreateImage)
5266 object_ = ::clCreateImage3D(
5267 context(), flags, &format, width, height, depth, row_pitch,
5268 slice_pitch, host_ptr, &error);
5270 detail::errHandler(error, __CREATE_IMAGE3D_ERR);
5288 explicit Image3D(
const cl_mem& image3D,
bool retainObject =
false) :
5289 Image(image3D, retainObject) { }
5330 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
5353 cl_int * err = NULL)
5356 object_ = ::clCreateFromGLTexture3D(
5364 detail::errHandler(error, __CREATE_GL_TEXTURE_3D_ERR);
5380 explicit Image3DGL(
const cl_mem& image,
bool retainObject =
false) :
5381 Image3D(image, retainObject) { }
5423 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
5439 cl_int * err = NULL)
5442 object_ = ::clCreateFromGLTexture(
5450 detail::errHandler(error, __CREATE_GL_TEXTURE_ERR);
5465 explicit ImageGL(
const cl_mem& image,
bool retainObject =
false) :
5466 Image(image, retainObject) { }
5468 ImageGL& operator = (
const cl_mem& rhs)
5506 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
5528 cl_uint packet_size,
5529 cl_uint max_packets,
5534 cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS;
5535 object_ = ::clCreatePipe(context(), flags, packet_size, max_packets,
nullptr, &error);
5537 detail::errHandler(error, __CREATE_PIPE_ERR);
5552 cl_uint packet_size,
5553 cl_uint max_packets,
5560 cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS;
5561 object_ = ::clCreatePipe(context(), flags, packet_size, max_packets,
nullptr, &error);
5563 detail::errHandler(error, __CREATE_PIPE_ERR);
5579 explicit Pipe(
const cl_mem& pipe,
bool retainObject =
false) :
5580 Memory(pipe, retainObject) { }
5621 template <
typename T>
5624 return detail::errHandler(
5625 detail::getInfo(&::clGetPipeInfo, object_, name, param),
5626 __GET_PIPE_INFO_ERR);
5630 template <cl_pipe_info name>
typename
5635 detail::cl_pipe_info, name>::param_type param;
5636 cl_int result =
getInfo(name, ¶m);
5666 cl_bool normalized_coords,
5667 cl_addressing_mode addressing_mode,
5668 cl_filter_mode filter_mode,
5673 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
5674 cl_sampler_properties sampler_properties[] = {
5675 CL_SAMPLER_NORMALIZED_COORDS, normalized_coords,
5676 CL_SAMPLER_ADDRESSING_MODE, addressing_mode,
5677 CL_SAMPLER_FILTER_MODE, filter_mode,
5679 object_ = ::clCreateSamplerWithProperties(
5684 detail::errHandler(error, __CREATE_SAMPLER_WITH_PROPERTIES_ERR);
5689 object_ = ::clCreateSampler(
5696 detail::errHandler(error, __CREATE_SAMPLER_ERR);
5711 explicit Sampler(
const cl_sampler& sampler,
bool retainObject =
false) :
5712 detail::Wrapper<cl_type>(sampler, retainObject) { }
5754 template <
typename T>
5755 cl_int
getInfo(cl_sampler_info name, T* param)
const
5757 return detail::errHandler(
5758 detail::getInfo(&::clGetSamplerInfo, object_, name, param),
5759 __GET_SAMPLER_INFO_ERR);
5763 template <cl_sampler_info name>
typename
5768 detail::cl_sampler_info, name>::param_type param;
5769 cl_int result =
getInfo(name, ¶m);
5779 class DeviceCommandQueue;
5786 size_type sizes_[3];
5787 cl_uint dimensions_;
5818 NDRange(size_type size0, size_type size1, size_type size2)
5830 operator const size_type*()
const {
5844 return dimensions_*
sizeof(size_type);
5852 const size_type* get()
const
5859 static const NDRange NullRange;
5869 template <
typename T,
class Enable =
void>
5874 template <
typename T>
5877 static size_type size(
const T&) {
return sizeof(T); }
5878 static const T* ptr(
const T& value) {
return &value; }
5883 template <
typename T>
5886 static size_type size(
const T&) {
return sizeof(cl_mem); }
5887 static const cl_mem* ptr(
const T& value) {
return &(value()); }
5895 static size_type size(
const LocalSpaceArg& value) {
return value.size_; }
5896 static const void* ptr(
const LocalSpaceArg&) {
return NULL; }
5923 inline Kernel(
const Program& program,
const char* name, cl_int* err = NULL);
5936 explicit Kernel(
const cl_kernel& kernel,
bool retainObject =
false) :
5937 detail::Wrapper<cl_type>(kernel, retainObject) { }
5978 template <
typename T>
5979 cl_int getInfo(cl_kernel_info name, T* param)
const
5981 return detail::errHandler(
5982 detail::getInfo(&::clGetKernelInfo, object_, name, param),
5983 __GET_KERNEL_INFO_ERR);
5986 template <cl_kernel_info name>
typename
5987 detail::param_traits<detail::cl_kernel_info, name>::param_type
5988 getInfo(cl_int* err = NULL)
const
5990 typename detail::param_traits<
5991 detail::cl_kernel_info, name>::param_type param;
5992 cl_int result = getInfo(name, ¶m);
5999 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
6000 template <
typename T>
6001 cl_int getArgInfo(cl_uint argIndex, cl_kernel_arg_info name, T* param)
const
6003 return detail::errHandler(
6004 detail::getInfo(&::clGetKernelArgInfo, object_, argIndex, name, param),
6005 __GET_KERNEL_ARG_INFO_ERR);
6008 template <cl_kernel_arg_info name>
typename
6009 detail::param_traits<detail::cl_kernel_arg_info, name>::param_type
6010 getArgInfo(cl_uint argIndex, cl_int* err = NULL)
const
6012 typename detail::param_traits<
6013 detail::cl_kernel_arg_info, name>::param_type param;
6014 cl_int result = getArgInfo(argIndex, name, ¶m);
6022 template <
typename T>
6023 cl_int getWorkGroupInfo(
6024 const Device& device, cl_kernel_work_group_info name, T* param)
const
6026 return detail::errHandler(
6028 &::clGetKernelWorkGroupInfo, object_, device(), name, param),
6029 __GET_KERNEL_WORK_GROUP_INFO_ERR);
6032 template <cl_kernel_work_group_info name>
typename
6033 detail::param_traits<detail::cl_kernel_work_group_info, name>::param_type
6034 getWorkGroupInfo(
const Device& device, cl_int* err = NULL)
const
6036 typename detail::param_traits<
6037 detail::cl_kernel_work_group_info, name>::param_type param;
6038 cl_int result = getWorkGroupInfo(device, name, ¶m);
6045 #if (CL_HPP_TARGET_OPENCL_VERSION >= 200 && defined(CL_HPP_USE_CL_SUB_GROUPS_KHR)) || CL_HPP_TARGET_OPENCL_VERSION >= 210
6046 cl_int getSubGroupInfo(
const cl::Device &dev, cl_kernel_sub_group_info name,
const cl::NDRange &range, size_type* param)
const
6048 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
6050 return detail::errHandler(
6051 clGetKernelSubGroupInfo(object_, dev(), name, range.
size(), range.get(),
sizeof(size_type), param,
nullptr),
6052 __GET_KERNEL_SUB_GROUP_INFO_ERR);
6056 typedef clGetKernelSubGroupInfoKHR_fn PFN_clGetKernelSubGroupInfoKHR;
6057 static PFN_clGetKernelSubGroupInfoKHR pfn_clGetKernelSubGroupInfoKHR = NULL;
6058 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetKernelSubGroupInfoKHR);
6060 return detail::errHandler(
6061 pfn_clGetKernelSubGroupInfoKHR(object_, dev(), name, range.
size(), range.get(),
sizeof(size_type), param,
nullptr),
6062 __GET_KERNEL_SUB_GROUP_INFO_ERR);
6067 template <cl_kernel_sub_group_info name>
6068 size_type getSubGroupInfo(
const cl::Device &dev,
const cl::NDRange &range, cl_int* err = NULL)
const
6071 cl_int result = getSubGroupInfo(dev, name, range, ¶m);
6079 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
6082 template<
typename T,
class D>
6083 cl_int
setArg(cl_uint index,
const cl::pointer<T, D> &argPtr)
6085 return detail::errHandler(
6086 ::clSetKernelArgSVMPointer(object_, index, argPtr.get()),
6087 __SET_KERNEL_ARGS_ERR);
6092 template<
typename T,
class Alloc>
6093 cl_int
setArg(cl_uint index,
const cl::vector<T, Alloc> &argPtr)
6095 return detail::errHandler(
6096 ::clSetKernelArgSVMPointer(object_, index, argPtr.data()),
6097 __SET_KERNEL_ARGS_ERR);
6102 template<
typename T>
6103 typename std::enable_if<std::is_pointer<T>::value, cl_int>::type
6106 return detail::errHandler(
6107 ::clSetKernelArgSVMPointer(object_, index, argPtr),
6108 __SET_KERNEL_ARGS_ERR);
6114 template <
typename T>
6115 typename std::enable_if<!std::is_pointer<T>::value, cl_int>::type
6118 return detail::errHandler(
6124 __SET_KERNEL_ARGS_ERR);
6127 cl_int
setArg(cl_uint index, size_type size,
const void* argPtr)
6129 return detail::errHandler(
6130 ::clSetKernelArg(object_, index, size, argPtr),
6131 __SET_KERNEL_ARGS_ERR);
6134 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
6141 return detail::errHandler(
6142 ::clSetKernelExecInfo(
6144 CL_KERNEL_EXEC_INFO_SVM_PTRS,
6145 sizeof(
void*)*pointerList.size(),
6146 pointerList.data()));
6153 template<
int ArrayLength>
6156 return detail::errHandler(
6157 ::clSetKernelExecInfo(
6159 CL_KERNEL_EXEC_INFO_SVM_PTRS,
6160 sizeof(
void*)*pointerList.size(),
6161 pointerList.data()));
6177 cl_bool svmEnabled_ = svmEnabled ? CL_TRUE : CL_FALSE;
6178 return detail::errHandler(
6179 ::clSetKernelExecInfo(
6181 CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM,
6188 template<
int index,
int ArrayLength,
class D,
typename T0,
typename T1,
typename... Ts>
6189 void setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList,
const pointer<T0, D> &t0,
const pointer<T1, D> &t1, Ts & ... ts)
6191 pointerList[index] =
static_cast<void*
>(t0.get());
6192 setSVMPointersHelper<index + 1, ArrayLength>(pointerList, t1, ts...);
6195 template<
int index,
int ArrayLength,
typename T0,
typename T1,
typename... Ts>
6196 typename std::enable_if<std::is_pointer<T0>::value,
void>::type
6197 setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList, T0 t0, T1 t1, Ts... ts)
6199 pointerList[index] =
static_cast<void*
>(t0);
6200 setSVMPointersHelper<index + 1, ArrayLength>(pointerList, t1, ts...);
6203 template<
int index,
int ArrayLength,
typename T0,
class D>
6204 void setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList,
const pointer<T0, D> &t0)
6206 pointerList[index] =
static_cast<void*
>(t0.get());
6210 template<
int index,
int ArrayLength,
typename T0>
6211 typename std::enable_if<std::is_pointer<T0>::value,
void>::type
6212 setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList, T0 t0)
6214 pointerList[index] =
static_cast<void*
>(t0);
6217 template<
typename T0,
typename... Ts>
6220 std::array<
void*, 1 +
sizeof...(Ts)> pointerList;
6222 setSVMPointersHelper<0, 1 +
sizeof...(Ts)>(pointerList, t0, ts...);
6223 return detail::errHandler(
6224 ::clSetKernelExecInfo(
6226 CL_KERNEL_EXEC_INFO_SVM_PTRS,
6227 sizeof(
void*)*(1 +
sizeof...(Ts)),
6228 pointerList.data()));
6231 template<
typename T>
6232 cl_int setExecInfo(cl_kernel_exec_info param_name,
const T& val)
6234 return detail::errHandler(
6235 ::clSetKernelExecInfo(
6242 template<cl_kernel_exec_info name>
6243 cl_int setExecInfo(
typename detail::param_traits<detail::cl_kernel_exec_info, name>::param_type& val)
6245 return setExecInfo(name, val);
6249 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
6258 Kernel retValue(clCloneKernel(this->get(), &error));
6260 detail::errHandler(error, __CLONE_KERNEL_ERR);
6272 #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6273 typedef vector<vector<unsigned char>> Binaries;
6274 typedef vector<string> Sources;
6276 typedef vector<std::pair<const void*, size_type> > Binaries;
6277 typedef vector<std::pair<const char*, size_type> > Sources;
6281 const string& source,
6287 const char * strings = source.c_str();
6288 const size_type length = source.size();
6292 object_ = ::clCreateProgramWithSource(
6293 context(), (cl_uint)1, &strings, &length, &error);
6295 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6297 if (error == CL_SUCCESS && build) {
6299 error = ::clBuildProgram(
6303 #
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6311 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6321 const string& source,
6327 const char * strings = source.c_str();
6328 const size_type length = source.size();
6330 object_ = ::clCreateProgramWithSource(
6331 context(), (cl_uint)1, &strings, &length, &error);
6333 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6335 if (error == CL_SUCCESS && build) {
6336 error = ::clBuildProgram(
6340 #
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6348 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6361 const Sources& sources,
6367 const size_type n = (size_type)sources.size();
6369 vector<size_type> lengths(n);
6370 vector<const char*> strings(n);
6372 for (size_type i = 0; i < n; ++i) {
6373 #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6374 strings[i] = sources[(int)i].data();
6375 lengths[i] = sources[(int)i].length();
6377 strings[i] = sources[(int)i].first;
6378 lengths[i] = sources[(int)i].second;
6382 object_ = ::clCreateProgramWithSource(
6383 context(), (cl_uint)n, strings.data(), lengths.data(), &error);
6385 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6397 const Sources& sources,
6402 const size_type n = (size_type)sources.size();
6404 vector<size_type> lengths(n);
6405 vector<const char*> strings(n);
6407 for (size_type i = 0; i < n; ++i) {
6408 #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6409 strings[i] = sources[(int)i].data();
6410 lengths[i] = sources[(int)i].length();
6412 strings[i] = sources[(int)i].first;
6413 lengths[i] = sources[(int)i].second;
6417 object_ = ::clCreateProgramWithSource(
6418 context(), (cl_uint)n, strings.data(), lengths.data(), &error);
6420 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6427 #if CL_HPP_TARGET_OPENCL_VERSION >= 210 || (CL_HPP_TARGET_OPENCL_VERSION==200 && defined(CL_HPP_USE_IL_KHR))
6433 const vector<char>& IL,
6441 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
6443 object_ = ::clCreateProgramWithIL(
6444 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6448 typedef clCreateProgramWithILKHR_fn PFN_clCreateProgramWithILKHR;
6449 static PFN_clCreateProgramWithILKHR pfn_clCreateProgramWithILKHR = NULL;
6450 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateProgramWithILKHR);
6452 object_ = pfn_clCreateProgramWithILKHR(
6453 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6457 detail::errHandler(error, __CREATE_PROGRAM_WITH_IL_ERR);
6459 if (error == CL_SUCCESS && build) {
6461 error = ::clBuildProgram(
6465 #
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6473 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6488 const vector<char>& IL,
6494 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
6496 object_ = ::clCreateProgramWithIL(
6497 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6501 typedef clCreateProgramWithILKHR_fn PFN_clCreateProgramWithILKHR;
6502 static PFN_clCreateProgramWithILKHR pfn_clCreateProgramWithILKHR = NULL;
6503 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateProgramWithILKHR);
6505 object_ = pfn_clCreateProgramWithILKHR(
6506 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6510 detail::errHandler(error, __CREATE_PROGRAM_WITH_IL_ERR);
6512 if (error == CL_SUCCESS && build) {
6513 error = ::clBuildProgram(
6517 #
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6525 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6555 const vector<Device>& devices,
6556 const Binaries& binaries,
6557 vector<cl_int>* binaryStatus = NULL,
6562 const size_type numDevices = devices.size();
6565 if(binaries.size() != numDevices) {
6566 error = CL_INVALID_VALUE;
6567 detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
6575 vector<size_type> lengths(numDevices);
6576 vector<const unsigned char*> images(numDevices);
6577 #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6578 for (size_type i = 0; i < numDevices; ++i) {
6579 images[i] = binaries[i].data();
6580 lengths[i] = binaries[(int)i].size();
6583 for (size_type i = 0; i < numDevices; ++i) {
6584 images[i] = (
const unsigned char*)binaries[i].first;
6585 lengths[i] = binaries[(int)i].second;
6589 vector<cl_device_id> deviceIDs(numDevices);
6590 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6591 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6595 binaryStatus->resize(numDevices);
6598 object_ = ::clCreateProgramWithBinary(
6599 context(), (cl_uint) devices.size(),
6601 lengths.data(), images.data(), (binaryStatus != NULL && numDevices > 0)
6602 ? &binaryStatus->front()
6605 detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
6612 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
6619 const vector<Device>& devices,
6620 const string& kernelNames,
6626 size_type numDevices = devices.size();
6627 vector<cl_device_id> deviceIDs(numDevices);
6628 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6629 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6632 object_ = ::clCreateProgramWithBuiltInKernels(
6634 (cl_uint) devices.size(),
6636 kernelNames.c_str(),
6639 detail::errHandler(error, __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR);
6655 explicit Program(
const cl_program& program,
bool retainObject =
false) :
6656 detail::Wrapper<cl_type>(program, retainObject) { }
6658 Program& operator = (
const cl_program& rhs)
6693 const vector<Device>& devices,
6694 const char* options = NULL,
6695 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6696 void* data = NULL)
const
6698 size_type numDevices = devices.size();
6699 vector<cl_device_id> deviceIDs(numDevices);
6701 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6702 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6705 cl_int buildError = ::clBuildProgram(
6714 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6718 const Device& device,
6719 const char* options = NULL,
6720 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6721 void* data = NULL)
const
6723 cl_device_id deviceID = device();
6725 cl_int buildError = ::clBuildProgram(
6733 BuildLogType buildLog(1);
6734 buildLog.push_back(std::make_pair(device, getBuildInfo<CL_PROGRAM_BUILD_LOG>(device)));
6735 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, buildLog);
6739 const char* options = NULL,
6740 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6741 void* data = NULL)
const
6743 cl_int buildError = ::clBuildProgram(
6751 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6754 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
6756 const char* options = NULL,
6757 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6758 void* data = NULL)
const
6760 cl_int error = ::clCompileProgram(
6770 return detail::buildErrHandler(error, __COMPILE_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6774 template <
typename T>
6775 cl_int getInfo(cl_program_info name, T* param)
const
6777 return detail::errHandler(
6778 detail::getInfo(&::clGetProgramInfo, object_, name, param),
6779 __GET_PROGRAM_INFO_ERR);
6782 template <cl_program_info name>
typename
6783 detail::param_traits<detail::cl_program_info, name>::param_type
6784 getInfo(cl_int* err = NULL)
const
6786 typename detail::param_traits<
6787 detail::cl_program_info, name>::param_type param;
6788 cl_int result = getInfo(name, ¶m);
6795 template <
typename T>
6796 cl_int getBuildInfo(
6797 const Device& device, cl_program_build_info name, T* param)
const
6799 return detail::errHandler(
6801 &::clGetProgramBuildInfo, object_, device(), name, param),
6802 __GET_PROGRAM_BUILD_INFO_ERR);
6805 template <cl_program_build_info name>
typename
6806 detail::param_traits<detail::cl_program_build_info, name>::param_type
6807 getBuildInfo(
const Device& device, cl_int* err = NULL)
const
6809 typename detail::param_traits<
6810 detail::cl_program_build_info, name>::param_type param;
6811 cl_int result = getBuildInfo(device, name, ¶m);
6823 template <cl_program_build_info name>
6824 vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, name>::param_type>>
6827 cl_int result = CL_SUCCESS;
6829 auto devs = getInfo<CL_PROGRAM_DEVICES>(&result);
6830 vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, name>::param_type>>
6834 if (result != CL_SUCCESS) {
6843 detail::cl_program_build_info, name>::param_type param;
6844 result = getBuildInfo(d, name, ¶m);
6848 if (result != CL_SUCCESS) {
6856 if (result != CL_SUCCESS) {
6862 cl_int createKernels(vector<Kernel>* kernels)
6865 cl_int err = ::clCreateKernelsInProgram(object_, 0, NULL, &numKernels);
6866 if (err != CL_SUCCESS) {
6867 return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
6870 vector<cl_kernel> value(numKernels);
6872 err = ::clCreateKernelsInProgram(
6873 object_, numKernels, value.data(), NULL);
6874 if (err != CL_SUCCESS) {
6875 return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
6879 kernels->resize(value.size());
6883 for (size_type i = 0; i < value.size(); i++) {
6886 (*kernels)[i] = Kernel(value[i],
false);
6892 #if CL_HPP_TARGET_OPENCL_VERSION >= 220
6893 #if defined(CL_USE_DEPRECATED_OPENCL_2_2_APIS)
6905 void (CL_CALLBACK * pfn_notify)(cl_program program,
void * user_data),
6906 void * user_data = NULL) CL_API_SUFFIX__VERSION_2_2_DEPRECATED
6908 return detail::errHandler(
6909 ::clSetProgramReleaseCallback(
6913 __SET_PROGRAM_RELEASE_CALLBACK_ERR);
6921 template <
typename T>
6922 typename std::enable_if<!std::is_pointer<T>::value, cl_int>::type
6925 return detail::errHandler(
6926 ::clSetProgramSpecializationConstant(
6931 __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR);
6940 return detail::errHandler(
6941 ::clSetProgramSpecializationConstant(
6946 __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR);
6951 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
6952 inline Program linkProgram(
6955 const char* options = NULL,
6956 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6960 cl_int error_local = CL_SUCCESS;
6962 cl_program programs[2] = { input1(), input2() };
6964 Context ctx = input1.getInfo<CL_PROGRAM_CONTEXT>(&error_local);
6965 if(error_local!=CL_SUCCESS) {
6966 detail::errHandler(error_local, __LINK_PROGRAM_ERR);
6969 cl_program prog = ::clLinkProgram(
6980 detail::errHandler(error_local,__COMPILE_PROGRAM_ERR);
6985 return Program(prog);
6988 inline Program linkProgram(
6989 vector<Program> inputPrograms,
6990 const char* options = NULL,
6991 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6995 cl_int error_local = CL_SUCCESS;
6997 vector<cl_program> programs(inputPrograms.size());
6999 for (
unsigned int i = 0; i < inputPrograms.size(); i++) {
7000 programs[i] = inputPrograms[i]();
7004 if(inputPrograms.size() > 0) {
7005 ctx = inputPrograms[0].getInfo<CL_PROGRAM_CONTEXT>(&error_local);
7006 if(error_local!=CL_SUCCESS) {
7007 detail::errHandler(error_local, __LINK_PROGRAM_ERR);
7010 cl_program prog = ::clLinkProgram(
7015 (cl_uint)inputPrograms.size(),
7021 detail::errHandler(error_local,__COMPILE_PROGRAM_ERR);
7026 return Program(prog,
false);
7032 inline cl_int cl::Program::getInfo(cl_program_info name, vector<vector<unsigned char>>* param)
const
7034 if (name != CL_PROGRAM_BINARIES) {
7035 return CL_INVALID_VALUE;
7041 vector<size_type> sizes = getInfo<CL_PROGRAM_BINARY_SIZES>();
7042 size_type numBinaries = sizes.size();
7045 param->resize(numBinaries);
7046 for (size_type i = 0; i < numBinaries; ++i) {
7047 (*param)[i].resize(sizes[i]);
7050 return detail::errHandler(
7051 detail::getInfo(&::clGetProgramInfo, object_, name, param),
7052 __GET_PROGRAM_INFO_ERR);
7059 inline vector<vector<unsigned char>> cl::Program::getInfo<CL_PROGRAM_BINARIES>(cl_int* err)
const
7061 vector<vector<unsigned char>> binariesVectors;
7063 cl_int result = getInfo(CL_PROGRAM_BINARIES, &binariesVectors);
7067 return binariesVectors;
7070 #if CL_HPP_TARGET_OPENCL_VERSION >= 220
7075 cl_uchar ucValue = value ? CL_UCHAR_MAX : 0;
7076 return detail::errHandler(
7077 ::clSetProgramSpecializationConstant(
7082 __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR);
7086 inline Kernel::Kernel(
const Program& program,
const char* name, cl_int* err)
7090 object_ = ::clCreateKernel(program(), name, &error);
7091 detail::errHandler(error, __CREATE_KERNEL_ERR);
7099 enum class QueueProperties : cl_command_queue_properties
7102 Profiling = CL_QUEUE_PROFILING_ENABLE,
7103 OutOfOrder = CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE,
7106 inline QueueProperties operator|(QueueProperties lhs, QueueProperties rhs)
7108 return static_cast<QueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) |
static_cast<cl_command_queue_properties
>(rhs));
7117 static std::once_flag default_initialized_;
7119 static cl_int default_error_;
7126 static void makeDefault()
7131 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
7138 if (error != CL_SUCCESS) {
7139 default_error_ = error;
7143 default_ =
CommandQueue(context, device, 0, &default_error_);
7146 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
7147 catch (cl::Error &e) {
7148 default_error_ = e.err();
7158 static void makeDefaultProvided(
const CommandQueue &c) {
7163 #ifdef CL_HPP_UNIT_TEST_ENABLE
7170 static void unitTestClearDefault() {
7181 cl_command_queue_properties properties,
7187 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7189 if (error != CL_SUCCESS) {
7196 bool useWithProperties;
7198 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7201 cl_uint version = detail::getContextPlatformVersion(context());
7202 useWithProperties = (version >= 0x20000);
7204 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7205 useWithProperties =
true;
7207 useWithProperties =
false;
7210 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
7211 if (useWithProperties) {
7212 cl_queue_properties queue_properties[] = {
7213 CL_QUEUE_PROPERTIES, properties, 0 };
7214 if ((properties & CL_QUEUE_ON_DEVICE) == 0) {
7215 object_ = ::clCreateCommandQueueWithProperties(
7216 context(), device(), queue_properties, &error);
7219 error = CL_INVALID_QUEUE_PROPERTIES;
7222 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7228 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7229 if (!useWithProperties) {
7230 object_ = ::clCreateCommandQueue(
7231 context(), device(), properties, &error);
7233 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7247 QueueProperties properties,
7253 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7255 if (error != CL_SUCCESS) {
7262 bool useWithProperties;
7264 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7267 cl_uint version = detail::getContextPlatformVersion(context());
7268 useWithProperties = (version >= 0x20000);
7270 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7271 useWithProperties =
true;
7273 useWithProperties =
false;
7276 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
7277 if (useWithProperties) {
7278 cl_queue_properties queue_properties[] = {
7279 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
7281 object_ = ::clCreateCommandQueueWithProperties(
7282 context(), device(), queue_properties, &error);
7284 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7290 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7291 if (!useWithProperties) {
7292 object_ = ::clCreateCommandQueue(
7293 context(), device(),
static_cast<cl_command_queue_properties
>(properties), &error);
7295 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7311 cl_command_queue_properties properties = 0,
7315 bool useWithProperties;
7316 vector<cl::Device> devices;
7317 error = context.
getInfo(CL_CONTEXT_DEVICES, &devices);
7319 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7321 if (error != CL_SUCCESS)
7329 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7332 cl_uint version = detail::getContextPlatformVersion(context());
7333 useWithProperties = (version >= 0x20000);
7335 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7336 useWithProperties =
true;
7338 useWithProperties =
false;
7341 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
7342 if (useWithProperties) {
7343 cl_queue_properties queue_properties[] = {
7344 CL_QUEUE_PROPERTIES, properties, 0 };
7345 if ((properties & CL_QUEUE_ON_DEVICE) == 0) {
7346 object_ = ::clCreateCommandQueueWithProperties(
7347 context(), devices[0](), queue_properties, &error);
7350 error = CL_INVALID_QUEUE_PROPERTIES;
7353 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7359 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7360 if (!useWithProperties) {
7361 object_ = ::clCreateCommandQueue(
7362 context(), devices[0](), properties, &error);
7364 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7378 QueueProperties properties,
7382 bool useWithProperties;
7383 vector<cl::Device> devices;
7384 error = context.
getInfo(CL_CONTEXT_DEVICES, &devices);
7386 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7388 if (error != CL_SUCCESS)
7396 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7399 cl_uint version = detail::getContextPlatformVersion(context());
7400 useWithProperties = (version >= 0x20000);
7402 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7403 useWithProperties =
true;
7405 useWithProperties =
false;
7408 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
7409 if (useWithProperties) {
7410 cl_queue_properties queue_properties[] = {
7411 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
7412 object_ = ::clCreateCommandQueueWithProperties(
7413 context(), devices[0](), queue_properties, &error);
7415 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7421 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7422 if (!useWithProperties) {
7423 object_ = ::clCreateCommandQueue(
7424 context(), devices[0](),
static_cast<cl_command_queue_properties
>(properties), &error);
7426 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7441 cl_command_queue_properties properties = 0,
7445 bool useWithProperties;
7447 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7450 cl_uint version = detail::getContextPlatformVersion(context());
7451 useWithProperties = (version >= 0x20000);
7453 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7454 useWithProperties =
true;
7456 useWithProperties =
false;
7459 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
7460 if (useWithProperties) {
7461 cl_queue_properties queue_properties[] = {
7462 CL_QUEUE_PROPERTIES, properties, 0 };
7463 object_ = ::clCreateCommandQueueWithProperties(
7464 context(), device(), queue_properties, &error);
7466 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7472 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7473 if (!useWithProperties) {
7474 object_ = ::clCreateCommandQueue(
7475 context(), device(), properties, &error);
7477 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7492 QueueProperties properties,
7496 bool useWithProperties;
7498 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7501 cl_uint version = detail::getContextPlatformVersion(context());
7502 useWithProperties = (version >= 0x20000);
7504 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7505 useWithProperties =
true;
7507 useWithProperties =
false;
7510 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
7511 if (useWithProperties) {
7512 cl_queue_properties queue_properties[] = {
7513 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
7514 object_ = ::clCreateCommandQueueWithProperties(
7515 context(), device(), queue_properties, &error);
7517 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7523 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7524 if (!useWithProperties) {
7525 object_ = ::clCreateCommandQueue(
7526 context(), device(),
static_cast<cl_command_queue_properties
>(properties), &error);
7528 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7538 std::call_once(default_initialized_, makeDefault);
7539 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
7540 detail::errHandler(default_error_, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7542 detail::errHandler(default_error_, __CREATE_COMMAND_QUEUE_ERR);
7545 *err = default_error_;
7559 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_queue));
7560 detail::errHandler(default_error_);
7573 explicit CommandQueue(
const cl_command_queue& commandQueue,
bool retainObject =
false) :
7574 detail::Wrapper<cl_type>(commandQueue, retainObject) { }
7610 template <
typename T>
7611 cl_int getInfo(cl_command_queue_info name, T* param)
const
7613 return detail::errHandler(
7615 &::clGetCommandQueueInfo, object_, name, param),
7616 __GET_COMMAND_QUEUE_INFO_ERR);
7619 template <cl_command_queue_info name>
typename
7620 detail::param_traits<detail::cl_command_queue_info, name>::param_type
7621 getInfo(cl_int* err = NULL)
const
7623 typename detail::param_traits<
7624 detail::cl_command_queue_info, name>::param_type param;
7625 cl_int result = getInfo(name, ¶m);
7632 cl_int enqueueReadBuffer(
7633 const Buffer& buffer,
7638 const vector<Event>* events = NULL,
7639 Event* event = NULL)
const
7642 cl_int err = detail::errHandler(
7643 ::clEnqueueReadBuffer(
7644 object_, buffer(), blocking, offset, size,
7646 (events != NULL) ? (cl_uint) events->size() : 0,
7647 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7648 (event != NULL) ? &tmp : NULL),
7649 __ENQUEUE_READ_BUFFER_ERR);
7651 if (event != NULL && err == CL_SUCCESS)
7657 cl_int enqueueWriteBuffer(
7658 const Buffer& buffer,
7663 const vector<Event>* events = NULL,
7664 Event* event = NULL)
const
7667 cl_int err = detail::errHandler(
7668 ::clEnqueueWriteBuffer(
7669 object_, buffer(), blocking, offset, size,
7671 (events != NULL) ? (cl_uint) events->size() : 0,
7672 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7673 (event != NULL) ? &tmp : NULL),
7674 __ENQUEUE_WRITE_BUFFER_ERR);
7676 if (event != NULL && err == CL_SUCCESS)
7682 cl_int enqueueCopyBuffer(
7685 size_type src_offset,
7686 size_type dst_offset,
7688 const vector<Event>* events = NULL,
7689 Event* event = NULL)
const
7692 cl_int err = detail::errHandler(
7693 ::clEnqueueCopyBuffer(
7694 object_, src(), dst(), src_offset, dst_offset, size,
7695 (events != NULL) ? (cl_uint) events->size() : 0,
7696 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7697 (event != NULL) ? &tmp : NULL),
7698 __ENQEUE_COPY_BUFFER_ERR);
7700 if (event != NULL && err == CL_SUCCESS)
7705 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
7706 cl_int enqueueReadBufferRect(
7707 const Buffer& buffer,
7709 const array<size_type, 3>& buffer_offset,
7710 const array<size_type, 3>& host_offset,
7711 const array<size_type, 3>& region,
7712 size_type buffer_row_pitch,
7713 size_type buffer_slice_pitch,
7714 size_type host_row_pitch,
7715 size_type host_slice_pitch,
7717 const vector<Event>* events = NULL,
7718 Event* event = NULL)
const
7721 cl_int err = detail::errHandler(
7722 ::clEnqueueReadBufferRect(
7726 buffer_offset.data(),
7734 (events != NULL) ? (cl_uint) events->size() : 0,
7735 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7736 (event != NULL) ? &tmp : NULL),
7737 __ENQUEUE_READ_BUFFER_RECT_ERR);
7739 if (event != NULL && err == CL_SUCCESS)
7745 cl_int enqueueWriteBufferRect(
7746 const Buffer& buffer,
7748 const array<size_type, 3>& buffer_offset,
7749 const array<size_type, 3>& host_offset,
7750 const array<size_type, 3>& region,
7751 size_type buffer_row_pitch,
7752 size_type buffer_slice_pitch,
7753 size_type host_row_pitch,
7754 size_type host_slice_pitch,
7756 const vector<Event>* events = NULL,
7757 Event* event = NULL)
const
7760 cl_int err = detail::errHandler(
7761 ::clEnqueueWriteBufferRect(
7765 buffer_offset.data(),
7773 (events != NULL) ? (cl_uint) events->size() : 0,
7774 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7775 (event != NULL) ? &tmp : NULL),
7776 __ENQUEUE_WRITE_BUFFER_RECT_ERR);
7778 if (event != NULL && err == CL_SUCCESS)
7784 cl_int enqueueCopyBufferRect(
7787 const array<size_type, 3>& src_origin,
7788 const array<size_type, 3>& dst_origin,
7789 const array<size_type, 3>& region,
7790 size_type src_row_pitch,
7791 size_type src_slice_pitch,
7792 size_type dst_row_pitch,
7793 size_type dst_slice_pitch,
7794 const vector<Event>* events = NULL,
7795 Event* event = NULL)
const
7798 cl_int err = detail::errHandler(
7799 ::clEnqueueCopyBufferRect(
7810 (events != NULL) ? (cl_uint) events->size() : 0,
7811 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7812 (event != NULL) ? &tmp : NULL),
7813 __ENQEUE_COPY_BUFFER_RECT_ERR);
7815 if (event != NULL && err == CL_SUCCESS)
7821 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
7833 template<
typename PatternType>
7836 PatternType pattern,
7839 const vector<Event>* events = NULL,
7840 Event* event = NULL)
const
7843 cl_int err = detail::errHandler(
7844 ::clEnqueueFillBuffer(
7847 static_cast<void*
>(&pattern),
7848 sizeof(PatternType),
7851 (events != NULL) ? (cl_uint) events->size() : 0,
7852 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7853 (event != NULL) ? &tmp : NULL),
7854 __ENQUEUE_FILL_BUFFER_ERR);
7856 if (event != NULL && err == CL_SUCCESS)
7863 cl_int enqueueReadImage(
7866 const array<size_type, 3>& origin,
7867 const array<size_type, 3>& region,
7868 size_type row_pitch,
7869 size_type slice_pitch,
7871 const vector<Event>* events = NULL,
7872 Event* event = NULL)
const
7875 cl_int err = detail::errHandler(
7876 ::clEnqueueReadImage(
7885 (events != NULL) ? (cl_uint) events->size() : 0,
7886 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7887 (event != NULL) ? &tmp : NULL),
7888 __ENQUEUE_READ_IMAGE_ERR);
7890 if (event != NULL && err == CL_SUCCESS)
7896 cl_int enqueueWriteImage(
7899 const array<size_type, 3>& origin,
7900 const array<size_type, 3>& region,
7901 size_type row_pitch,
7902 size_type slice_pitch,
7904 const vector<Event>* events = NULL,
7905 Event* event = NULL)
const
7908 cl_int err = detail::errHandler(
7909 ::clEnqueueWriteImage(
7918 (events != NULL) ? (cl_uint) events->size() : 0,
7919 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7920 (event != NULL) ? &tmp : NULL),
7921 __ENQUEUE_WRITE_IMAGE_ERR);
7923 if (event != NULL && err == CL_SUCCESS)
7929 cl_int enqueueCopyImage(
7932 const array<size_type, 3>& src_origin,
7933 const array<size_type, 3>& dst_origin,
7934 const array<size_type, 3>& region,
7935 const vector<Event>* events = NULL,
7936 Event* event = NULL)
const
7939 cl_int err = detail::errHandler(
7940 ::clEnqueueCopyImage(
7947 (events != NULL) ? (cl_uint) events->size() : 0,
7948 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7949 (event != NULL) ? &tmp : NULL),
7950 __ENQUEUE_COPY_IMAGE_ERR);
7952 if (event != NULL && err == CL_SUCCESS)
7958 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
7968 cl_float4 fillColor,
7969 const array<size_type, 3>& origin,
7970 const array<size_type, 3>& region,
7971 const vector<Event>* events = NULL,
7972 Event* event = NULL)
const
7975 cl_int err = detail::errHandler(
7976 ::clEnqueueFillImage(
7979 static_cast<void*
>(&fillColor),
7982 (events != NULL) ? (cl_uint) events->size() : 0,
7983 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7984 (event != NULL) ? &tmp : NULL),
7985 __ENQUEUE_FILL_IMAGE_ERR);
7987 if (event != NULL && err == CL_SUCCESS)
8003 const array<size_type, 3>& origin,
8004 const array<size_type, 3>& region,
8005 const vector<Event>* events = NULL,
8006 Event* event = NULL)
const
8009 cl_int err = detail::errHandler(
8010 ::clEnqueueFillImage(
8013 static_cast<void*
>(&fillColor),
8016 (events != NULL) ? (cl_uint) events->size() : 0,
8017 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8018 (event != NULL) ? &tmp : NULL),
8019 __ENQUEUE_FILL_IMAGE_ERR);
8021 if (event != NULL && err == CL_SUCCESS)
8037 const array<size_type, 3>& origin,
8038 const array<size_type, 3>& region,
8039 const vector<Event>* events = NULL,
8040 Event* event = NULL)
const
8043 cl_int err = detail::errHandler(
8044 ::clEnqueueFillImage(
8047 static_cast<void*
>(&fillColor),
8050 (events != NULL) ? (cl_uint) events->size() : 0,
8051 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8052 (event != NULL) ? &tmp : NULL),
8053 __ENQUEUE_FILL_IMAGE_ERR);
8055 if (event != NULL && err == CL_SUCCESS)
8062 cl_int enqueueCopyImageToBuffer(
8065 const array<size_type, 3>& src_origin,
8066 const array<size_type, 3>& region,
8067 size_type dst_offset,
8068 const vector<Event>* events = NULL,
8069 Event* event = NULL)
const
8072 cl_int err = detail::errHandler(
8073 ::clEnqueueCopyImageToBuffer(
8080 (events != NULL) ? (cl_uint) events->size() : 0,
8081 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8082 (event != NULL) ? &tmp : NULL),
8083 __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR);
8085 if (event != NULL && err == CL_SUCCESS)
8091 cl_int enqueueCopyBufferToImage(
8094 size_type src_offset,
8095 const array<size_type, 3>& dst_origin,
8096 const array<size_type, 3>& region,
8097 const vector<Event>* events = NULL,
8098 Event* event = NULL)
const
8101 cl_int err = detail::errHandler(
8102 ::clEnqueueCopyBufferToImage(
8109 (events != NULL) ? (cl_uint) events->size() : 0,
8110 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8111 (event != NULL) ? &tmp : NULL),
8112 __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR);
8114 if (event != NULL && err == CL_SUCCESS)
8120 void* enqueueMapBuffer(
8121 const Buffer& buffer,
8126 const vector<Event>* events = NULL,
8127 Event* event = NULL,
8128 cl_int* err = NULL)
const
8132 void * result = ::clEnqueueMapBuffer(
8133 object_, buffer(), blocking, flags, offset, size,
8134 (events != NULL) ? (cl_uint) events->size() : 0,
8135 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8136 (event != NULL) ? &tmp : NULL,
8139 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
8143 if (event != NULL && error == CL_SUCCESS)
8149 void* enqueueMapImage(
8150 const Image& buffer,
8153 const array<size_type, 3>& origin,
8154 const array<size_type, 3>& region,
8155 size_type * row_pitch,
8156 size_type * slice_pitch,
8157 const vector<Event>* events = NULL,
8158 Event* event = NULL,
8159 cl_int* err = NULL)
const
8163 void * result = ::clEnqueueMapImage(
8164 object_, buffer(), blocking, flags,
8167 row_pitch, slice_pitch,
8168 (events != NULL) ? (cl_uint) events->size() : 0,
8169 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8170 (event != NULL) ? &tmp : NULL,
8173 detail::errHandler(error, __ENQUEUE_MAP_IMAGE_ERR);
8177 if (event != NULL && error == CL_SUCCESS)
8182 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
8187 template<
typename T>
8193 const vector<Event>* events = NULL,
8194 Event* event = NULL)
const
8197 cl_int err = detail::errHandler(::clEnqueueSVMMap(
8198 object_, blocking, flags,
static_cast<void*
>(ptr), size,
8199 (events != NULL) ? (cl_uint)events->size() : 0,
8200 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8201 (event != NULL) ? &tmp : NULL),
8202 __ENQUEUE_MAP_BUFFER_ERR);
8204 if (event != NULL && err == CL_SUCCESS)
8215 template<
typename T,
class D>
8217 cl::pointer<T, D> &ptr,
8221 const vector<Event>* events = NULL,
8222 Event* event = NULL)
const
8225 cl_int err = detail::errHandler(::clEnqueueSVMMap(
8226 object_, blocking, flags,
static_cast<void*
>(ptr.get()), size,
8227 (events != NULL) ? (cl_uint)events->size() : 0,
8228 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8229 (event != NULL) ? &tmp : NULL),
8230 __ENQUEUE_MAP_BUFFER_ERR);
8232 if (event != NULL && err == CL_SUCCESS)
8242 template<
typename T,
class Alloc>
8244 cl::vector<T, Alloc> &container,
8247 const vector<Event>* events = NULL,
8248 Event* event = NULL)
const
8251 cl_int err = detail::errHandler(::clEnqueueSVMMap(
8252 object_, blocking, flags,
static_cast<void*
>(container.data()), container.size()*
sizeof(T),
8253 (events != NULL) ? (cl_uint)events->size() : 0,
8254 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8255 (event != NULL) ? &tmp : NULL),
8256 __ENQUEUE_MAP_BUFFER_ERR);
8258 if (event != NULL && err == CL_SUCCESS)
8265 cl_int enqueueUnmapMemObject(
8268 const vector<Event>* events = NULL,
8269 Event* event = NULL)
const
8272 cl_int err = detail::errHandler(
8273 ::clEnqueueUnmapMemObject(
8274 object_, memory(), mapped_ptr,
8275 (events != NULL) ? (cl_uint) events->size() : 0,
8276 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8277 (event != NULL) ? &tmp : NULL),
8278 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8280 if (event != NULL && err == CL_SUCCESS)
8287 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
8292 template<
typename T>
8295 const vector<Event>* events = NULL,
8296 Event* event = NULL)
const
8299 cl_int err = detail::errHandler(
8300 ::clEnqueueSVMUnmap(
8301 object_,
static_cast<void*
>(ptr),
8302 (events != NULL) ? (cl_uint)events->size() : 0,
8303 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8304 (event != NULL) ? &tmp : NULL),
8305 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8307 if (event != NULL && err == CL_SUCCESS)
8317 template<
typename T,
class D>
8319 cl::pointer<T, D> &ptr,
8320 const vector<Event>* events = NULL,
8321 Event* event = NULL)
const
8324 cl_int err = detail::errHandler(
8325 ::clEnqueueSVMUnmap(
8326 object_,
static_cast<void*
>(ptr.get()),
8327 (events != NULL) ? (cl_uint)events->size() : 0,
8328 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8329 (event != NULL) ? &tmp : NULL),
8330 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8332 if (event != NULL && err == CL_SUCCESS)
8342 template<
typename T,
class Alloc>
8344 cl::vector<T, Alloc> &container,
8345 const vector<Event>* events = NULL,
8346 Event* event = NULL)
const
8349 cl_int err = detail::errHandler(
8350 ::clEnqueueSVMUnmap(
8351 object_,
static_cast<void*
>(container.data()),
8352 (events != NULL) ? (cl_uint)events->size() : 0,
8353 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8354 (event != NULL) ? &tmp : NULL),
8355 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8357 if (event != NULL && err == CL_SUCCESS)
8364 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
8377 const vector<Event> *events = 0,
8378 Event *event = 0)
const
8381 cl_int err = detail::errHandler(
8382 ::clEnqueueMarkerWithWaitList(
8384 (events != NULL) ? (cl_uint) events->size() : 0,
8385 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8386 (event != NULL) ? &tmp : NULL),
8387 __ENQUEUE_MARKER_WAIT_LIST_ERR);
8389 if (event != NULL && err == CL_SUCCESS)
8407 const vector<Event> *events = 0,
8408 Event *event = 0)
const
8411 cl_int err = detail::errHandler(
8412 ::clEnqueueBarrierWithWaitList(
8414 (events != NULL) ? (cl_uint) events->size() : 0,
8415 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8416 (event != NULL) ? &tmp : NULL),
8417 __ENQUEUE_BARRIER_WAIT_LIST_ERR);
8419 if (event != NULL && err == CL_SUCCESS)
8430 const vector<Memory> &memObjects,
8431 cl_mem_migration_flags flags,
8432 const vector<Event>* events = NULL,
8438 vector<cl_mem> localMemObjects(memObjects.size());
8440 for(
int i = 0; i < (int)memObjects.size(); ++i ) {
8441 localMemObjects[i] = memObjects[i]();
8444 cl_int err = detail::errHandler(
8445 ::clEnqueueMigrateMemObjects(
8447 (cl_uint)memObjects.size(),
8448 localMemObjects.data(),
8450 (events != NULL) ? (cl_uint) events->size() : 0,
8451 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8452 (event != NULL) ? &tmp : NULL),
8453 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8455 if (event != NULL && err == CL_SUCCESS)
8463 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
8469 template<
typename T>
8471 const cl::vector<T*> &svmRawPointers,
8472 const cl::vector<size_type> &sizes,
8473 cl_mem_migration_flags flags = 0,
8474 const vector<Event>* events = NULL,
8475 Event* event = NULL)
const
8478 cl_int err = detail::errHandler(::clEnqueueSVMMigrateMem(
8480 svmRawPointers.size(),
static_cast<void**
>(svmRawPointers.data()),
8483 (events != NULL) ? (cl_uint)events->size() : 0,
8484 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8485 (event != NULL) ? &tmp : NULL),
8486 __ENQUEUE_MIGRATE_SVM_ERR);
8488 if (event != NULL && err == CL_SUCCESS)
8498 template<
typename T>
8500 const cl::vector<T*> &svmRawPointers,
8501 cl_mem_migration_flags flags = 0,
8502 const vector<Event>* events = NULL,
8503 Event* event = NULL)
const
8505 return enqueueMigrateSVM(svmRawPointers, cl::vector<size_type>(svmRawPointers.size()), flags, events, event);
8514 template<
typename T,
class D>
8516 const cl::vector<cl::pointer<T, D>> &svmPointers,
8517 const cl::vector<size_type> &sizes,
8518 cl_mem_migration_flags flags = 0,
8519 const vector<Event>* events = NULL,
8520 Event* event = NULL)
const
8522 cl::vector<void*> svmRawPointers;
8523 svmRawPointers.reserve(svmPointers.size());
8524 for (
auto p : svmPointers) {
8525 svmRawPointers.push_back(
static_cast<void*
>(p.get()));
8536 template<
typename T,
class D>
8538 const cl::vector<cl::pointer<T, D>> &svmPointers,
8539 cl_mem_migration_flags flags = 0,
8540 const vector<Event>* events = NULL,
8541 Event* event = NULL)
const
8543 return enqueueMigrateSVM(svmPointers, cl::vector<size_type>(svmPointers.size()), flags, events, event);
8551 template<
typename T,
class Alloc>
8553 const cl::vector<cl::vector<T, Alloc>> &svmContainers,
8554 const cl::vector<size_type> &sizes,
8555 cl_mem_migration_flags flags = 0,
8556 const vector<Event>* events = NULL,
8557 Event* event = NULL)
const
8559 cl::vector<void*> svmRawPointers;
8560 svmRawPointers.reserve(svmContainers.size());
8561 for (
auto p : svmContainers) {
8562 svmRawPointers.push_back(
static_cast<void*
>(p.data()));
8572 template<
typename T,
class Alloc>
8574 const cl::vector<cl::vector<T, Alloc>> &svmContainers,
8575 cl_mem_migration_flags flags = 0,
8576 const vector<Event>* events = NULL,
8577 Event* event = NULL)
const
8579 return enqueueMigrateSVM(svmContainers, cl::vector<size_type>(svmContainers.size()), flags, events, event);
8584 cl_int enqueueNDRangeKernel(
8588 const NDRange& local = NullRange,
8589 const vector<Event>* events = NULL,
8590 Event* event = NULL)
const
8593 cl_int err = detail::errHandler(
8594 ::clEnqueueNDRangeKernel(
8595 object_, kernel(), (cl_uint) global.
dimensions(),
8596 offset.
dimensions() != 0 ? (
const size_type*) offset : NULL,
8597 (
const size_type*) global,
8598 local.dimensions() != 0 ? (
const size_type*) local : NULL,
8599 (events != NULL) ? (cl_uint) events->size() : 0,
8600 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8601 (event != NULL) ? &tmp : NULL),
8602 __ENQUEUE_NDRANGE_KERNEL_ERR);
8604 if (event != NULL && err == CL_SUCCESS)
8610 #if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
8611 CL_API_PREFIX__VERSION_1_2_DEPRECATED cl_int enqueueTask(
8612 const Kernel& kernel,
8613 const vector<Event>* events = NULL,
8614 Event* event = NULL)
const CL_API_SUFFIX__VERSION_1_2_DEPRECATED
8617 cl_int err = detail::errHandler(
8620 (events != NULL) ? (cl_uint) events->size() : 0,
8621 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8622 (event != NULL) ? &tmp : NULL),
8623 __ENQUEUE_TASK_ERR);
8625 if (event != NULL && err == CL_SUCCESS)
8632 cl_int enqueueNativeKernel(
8633 void (CL_CALLBACK *userFptr)(
void *),
8634 std::pair<void*, size_type> args,
8635 const vector<Memory>* mem_objects = NULL,
8636 const vector<const void*>* mem_locs = NULL,
8637 const vector<Event>* events = NULL,
8638 Event* event = NULL)
const
8640 size_type elements = 0;
8641 if (mem_objects != NULL) {
8642 elements = mem_objects->size();
8644 vector<cl_mem> mems(elements);
8645 for (
unsigned int i = 0; i < elements; i++) {
8646 mems[i] = ((*mem_objects)[i])();
8650 cl_int err = detail::errHandler(
8651 ::clEnqueueNativeKernel(
8652 object_, userFptr, args.first, args.second,
8653 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8655 (mem_locs != NULL && mem_locs->size() > 0) ? (
const void **) &mem_locs->front() : NULL,
8656 (events != NULL) ? (cl_uint) events->size() : 0,
8657 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8658 (event != NULL) ? &tmp : NULL),
8659 __ENQUEUE_NATIVE_KERNEL);
8661 if (event != NULL && err == CL_SUCCESS)
8670 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
8671 CL_API_PREFIX__VERSION_1_1_DEPRECATED
8675 cl_int err = detail::errHandler(
8678 (event != NULL) ? &tmp : NULL),
8679 __ENQUEUE_MARKER_ERR);
8681 if (event != NULL && err == CL_SUCCESS)
8687 CL_API_PREFIX__VERSION_1_1_DEPRECATED
8688 cl_int enqueueWaitForEvents(
const vector<Event>& events)
const CL_API_SUFFIX__VERSION_1_1_DEPRECATED
8690 return detail::errHandler(
8691 ::clEnqueueWaitForEvents(
8693 (cl_uint) events.size(),
8694 events.size() > 0 ? (
const cl_event*) &events.front() : NULL),
8695 __ENQUEUE_WAIT_FOR_EVENTS_ERR);
8699 cl_int enqueueAcquireGLObjects(
8700 const vector<Memory>* mem_objects = NULL,
8701 const vector<Event>* events = NULL,
8702 Event* event = NULL)
const
8705 cl_int err = detail::errHandler(
8706 ::clEnqueueAcquireGLObjects(
8708 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8709 (mem_objects != NULL && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front(): NULL,
8710 (events != NULL) ? (cl_uint) events->size() : 0,
8711 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8712 (event != NULL) ? &tmp : NULL),
8713 __ENQUEUE_ACQUIRE_GL_ERR);
8715 if (event != NULL && err == CL_SUCCESS)
8721 cl_int enqueueReleaseGLObjects(
8722 const vector<Memory>* mem_objects = NULL,
8723 const vector<Event>* events = NULL,
8724 Event* event = NULL)
const
8727 cl_int err = detail::errHandler(
8728 ::clEnqueueReleaseGLObjects(
8730 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8731 (mem_objects != NULL && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front(): NULL,
8732 (events != NULL) ? (cl_uint) events->size() : 0,
8733 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8734 (event != NULL) ? &tmp : NULL),
8735 __ENQUEUE_RELEASE_GL_ERR);
8737 if (event != NULL && err == CL_SUCCESS)
8743 #if defined (CL_HPP_USE_DX_INTEROP)
8744 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueAcquireD3D10ObjectsKHR)(
8745 cl_command_queue command_queue, cl_uint num_objects,
8746 const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
8747 const cl_event* event_wait_list, cl_event* event);
8748 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueReleaseD3D10ObjectsKHR)(
8749 cl_command_queue command_queue, cl_uint num_objects,
8750 const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
8751 const cl_event* event_wait_list, cl_event* event);
8753 cl_int enqueueAcquireD3D10Objects(
8754 const vector<Memory>* mem_objects = NULL,
8755 const vector<Event>* events = NULL,
8756 Event* event = NULL)
const
8758 static PFN_clEnqueueAcquireD3D10ObjectsKHR pfn_clEnqueueAcquireD3D10ObjectsKHR = NULL;
8759 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
8760 cl_context context = getInfo<CL_QUEUE_CONTEXT>();
8761 cl::Device device(getInfo<CL_QUEUE_DEVICE>());
8762 cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>();
8763 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueAcquireD3D10ObjectsKHR);
8765 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
8766 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueAcquireD3D10ObjectsKHR);
8770 cl_int err = detail::errHandler(
8771 pfn_clEnqueueAcquireD3D10ObjectsKHR(
8773 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8774 (mem_objects != NULL && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front(): NULL,
8775 (events != NULL) ? (cl_uint) events->size() : 0,
8776 (events != NULL) ? (cl_event*) &events->front() : NULL,
8777 (event != NULL) ? &tmp : NULL),
8778 __ENQUEUE_ACQUIRE_GL_ERR);
8780 if (event != NULL && err == CL_SUCCESS)
8786 cl_int enqueueReleaseD3D10Objects(
8787 const vector<Memory>* mem_objects = NULL,
8788 const vector<Event>* events = NULL,
8789 Event* event = NULL)
const
8791 static PFN_clEnqueueReleaseD3D10ObjectsKHR pfn_clEnqueueReleaseD3D10ObjectsKHR = NULL;
8792 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
8793 cl_context context = getInfo<CL_QUEUE_CONTEXT>();
8794 cl::Device device(getInfo<CL_QUEUE_DEVICE>());
8795 cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>();
8796 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueReleaseD3D10ObjectsKHR);
8798 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
8799 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueReleaseD3D10ObjectsKHR);
8803 cl_int err = detail::errHandler(
8804 pfn_clEnqueueReleaseD3D10ObjectsKHR(
8806 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8807 (mem_objects != NULL && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front(): NULL,
8808 (events != NULL) ? (cl_uint) events->size() : 0,
8809 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8810 (event != NULL) ? &tmp : NULL),
8811 __ENQUEUE_RELEASE_GL_ERR);
8813 if (event != NULL && err == CL_SUCCESS)
8823 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
8824 CL_API_PREFIX__VERSION_1_1_DEPRECATED
8827 return detail::errHandler(
8828 ::clEnqueueBarrier(object_),
8829 __ENQUEUE_BARRIER_ERR);
8833 cl_int flush()
const
8835 return detail::errHandler(::clFlush(object_), __FLUSH_ERR);
8838 cl_int finish()
const
8840 return detail::errHandler(::clFinish(object_), __FINISH_ERR);
8844 CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag CommandQueue::default_initialized_;
8845 CL_HPP_DEFINE_STATIC_MEMBER_ CommandQueue CommandQueue::default_;
8846 CL_HPP_DEFINE_STATIC_MEMBER_ cl_int CommandQueue::default_error_ = CL_SUCCESS;
8849 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
8850 enum class DeviceQueueProperties : cl_command_queue_properties
8853 Profiling = CL_QUEUE_PROFILING_ENABLE,
8856 inline DeviceQueueProperties operator|(DeviceQueueProperties lhs, DeviceQueueProperties rhs)
8858 return static_cast<DeviceQueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) |
static_cast<cl_command_queue_properties
>(rhs));
8882 cl_command_queue_properties mergedProperties =
8883 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
8885 cl_queue_properties queue_properties[] = {
8886 CL_QUEUE_PROPERTIES, mergedProperties, 0 };
8887 object_ = ::clCreateCommandQueueWithProperties(
8888 context(), device(), queue_properties, &error);
8890 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8902 DeviceQueueProperties properties = DeviceQueueProperties::None,
8907 cl_command_queue_properties mergedProperties =
8908 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
8909 cl_queue_properties queue_properties[] = {
8910 CL_QUEUE_PROPERTIES, mergedProperties, 0 };
8911 object_ = ::clCreateCommandQueueWithProperties(
8912 context(), device(), queue_properties, &error);
8914 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8927 DeviceQueueProperties properties = DeviceQueueProperties::None,
8932 cl_command_queue_properties mergedProperties =
8933 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
8934 cl_queue_properties queue_properties[] = {
8935 CL_QUEUE_PROPERTIES, mergedProperties,
8936 CL_QUEUE_SIZE, queueSize,
8938 object_ = ::clCreateCommandQueueWithProperties(
8939 context(), device(), queue_properties, &error);
8941 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8954 detail::Wrapper<cl_type>(commandQueue, retainObject) { }
8990 template <
typename T>
8991 cl_int getInfo(cl_command_queue_info name, T* param)
const
8993 return detail::errHandler(
8995 &::clGetCommandQueueInfo, object_, name, param),
8996 __GET_COMMAND_QUEUE_INFO_ERR);
8999 template <cl_command_queue_info name>
typename
9000 detail::param_traits<detail::cl_command_queue_info, name>::param_type
9001 getInfo(cl_int* err = NULL)
const
9003 typename detail::param_traits<
9004 detail::cl_command_queue_info, name>::param_type param;
9005 cl_int result = getInfo(name, ¶m);
9019 cl_int *err =
nullptr)
9025 cl_command_queue_properties properties =
9026 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
9027 cl_queue_properties queue_properties[] = {
9028 CL_QUEUE_PROPERTIES, properties,
9031 ::clCreateCommandQueueWithProperties(
9032 context(), device(), queue_properties, &error));
9034 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9049 const Context &context,
const Device &device, cl_int *err =
nullptr)
9053 cl_command_queue_properties properties =
9054 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
9055 cl_queue_properties queue_properties[] = {
9056 CL_QUEUE_PROPERTIES, properties,
9059 ::clCreateCommandQueueWithProperties(
9060 context(), device(), queue_properties, &error));
9062 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9077 const Context &context,
const Device &device, cl_uint queueSize, cl_int *err =
nullptr)
9081 cl_command_queue_properties properties =
9082 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
9083 cl_queue_properties queue_properties[] = {
9084 CL_QUEUE_PROPERTIES, properties,
9085 CL_QUEUE_SIZE, queueSize,
9088 ::clCreateCommandQueueWithProperties(
9089 context(), device(), queue_properties, &error));
9091 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9101 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
9111 error = clSetDefaultDeviceCommandQueue(context.get(), device.get(), default_queue.get());
9113 detail::errHandler(error, __SET_DEFAULT_DEVICE_COMMAND_QUEUE_ERR);
9117 return default_queue;
9125 return queue.getInfo<CL_QUEUE_DEVICE_DEFAULT>(err);
9145 template<
typename IteratorType >
9148 IteratorType startIterator,
9149 IteratorType endIterator,
9154 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9157 cl_mem_flags flags = 0;
9159 flags |= CL_MEM_READ_ONLY;
9162 flags |= CL_MEM_READ_WRITE;
9165 flags |= CL_MEM_USE_HOST_PTR;
9168 size_type size =
sizeof(DataType)*(endIterator - startIterator);
9171 object_ = ::clCreateBuffer(context(), flags, size,
static_cast<DataType*
>(&*startIterator), &error);
9173 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
9176 detail::errHandler(error, __CREATE_BUFFER_ERR);
9183 detail::errHandler(error, __CREATE_BUFFER_ERR);
9188 error =
cl::copy(queue, startIterator, endIterator, *
this);
9189 detail::errHandler(error, __CREATE_BUFFER_ERR);
9196 template<
typename IteratorType >
9199 IteratorType startIterator,
9200 IteratorType endIterator,
9205 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9208 cl_mem_flags flags = 0;
9210 flags |= CL_MEM_READ_ONLY;
9213 flags |= CL_MEM_READ_WRITE;
9216 flags |= CL_MEM_USE_HOST_PTR;
9219 size_type size =
sizeof(DataType)*(endIterator - startIterator);
9221 Context context = queue.getInfo<CL_QUEUE_CONTEXT>();
9224 object_ = ::clCreateBuffer(context(), flags, size,
static_cast<DataType*
>(&*startIterator), &error);
9227 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
9230 detail::errHandler(error, __CREATE_BUFFER_ERR);
9236 error =
cl::copy(queue, startIterator, endIterator, *
this);
9237 detail::errHandler(error, __CREATE_BUFFER_ERR);
9244 inline cl_int enqueueReadBuffer(
9250 const vector<Event>* events = NULL,
9251 Event* event = NULL)
9256 if (error != CL_SUCCESS) {
9260 return queue.enqueueReadBuffer(buffer, blocking, offset, size, ptr, events, event);
9263 inline cl_int enqueueWriteBuffer(
9264 const Buffer& buffer,
9269 const vector<Event>* events = NULL,
9270 Event* event = NULL)
9273 CommandQueue queue = CommandQueue::getDefault(&error);
9275 if (error != CL_SUCCESS) {
9279 return queue.enqueueWriteBuffer(buffer, blocking, offset, size, ptr, events, event);
9282 inline void* enqueueMapBuffer(
9283 const Buffer& buffer,
9288 const vector<Event>* events = NULL,
9289 Event* event = NULL,
9293 CommandQueue queue = CommandQueue::getDefault(&error);
9294 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9299 void * result = ::clEnqueueMapBuffer(
9300 queue(), buffer(), blocking, flags, offset, size,
9301 (events != NULL) ? (cl_uint) events->size() : 0,
9302 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
9306 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9314 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
9320 template<
typename T>
9326 const vector<Event>* events,
9331 if (error != CL_SUCCESS) {
9332 return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9336 ptr, blocking, flags, size, events, event);
9344 template<
typename T,
class D>
9346 cl::pointer<T, D> &ptr,
9350 const vector<Event>* events = NULL,
9351 Event* event = NULL)
9355 if (error != CL_SUCCESS) {
9356 return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9360 ptr, blocking, flags, size, events, event);
9368 template<
typename T,
class Alloc>
9370 cl::vector<T, Alloc> &container,
9373 const vector<Event>* events = NULL,
9374 Event* event = NULL)
9378 if (error != CL_SUCCESS) {
9379 return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9383 container, blocking, flags, events, event);
9388 inline cl_int enqueueUnmapMemObject(
9389 const Memory& memory,
9391 const vector<Event>* events = NULL,
9392 Event* event = NULL)
9395 CommandQueue queue = CommandQueue::getDefault(&error);
9396 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9397 if (error != CL_SUCCESS) {
9402 cl_int err = detail::errHandler(
9403 ::clEnqueueUnmapMemObject(
9404 queue(), memory(), mapped_ptr,
9405 (events != NULL) ? (cl_uint)events->size() : 0,
9406 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
9407 (event != NULL) ? &tmp : NULL),
9408 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9410 if (event != NULL && err == CL_SUCCESS)
9416 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
9422 template<
typename T>
9425 const vector<Event>* events = NULL,
9426 Event* event = NULL)
9430 if (error != CL_SUCCESS) {
9431 return detail::errHandler(error, __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9435 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9444 template<
typename T,
class D>
9446 cl::pointer<T, D> &ptr,
9447 const vector<Event>* events = NULL,
9448 Event* event = NULL)
9452 if (error != CL_SUCCESS) {
9453 return detail::errHandler(error, __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9457 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9465 template<
typename T,
class Alloc>
9467 cl::vector<T, Alloc> &container,
9468 const vector<Event>* events = NULL,
9469 Event* event = NULL)
9473 if (error != CL_SUCCESS) {
9474 return detail::errHandler(error, __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9477 return detail::errHandler(queue.
enqueueUnmapSVM(container, events, event),
9478 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9483 inline cl_int enqueueCopyBuffer(
9486 size_type src_offset,
9487 size_type dst_offset,
9489 const vector<Event>* events = NULL,
9490 Event* event = NULL)
9493 CommandQueue queue = CommandQueue::getDefault(&error);
9495 if (error != CL_SUCCESS) {
9499 return queue.enqueueCopyBuffer(src, dst, src_offset, dst_offset, size, events, event);
9507 template<
typename IteratorType >
9508 inline cl_int
copy( IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer )
9512 if (error != CL_SUCCESS)
9515 return cl::copy(queue, startIterator, endIterator, buffer);
9523 template<
typename IteratorType >
9524 inline cl_int
copy(
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator )
9528 if (error != CL_SUCCESS)
9531 return cl::copy(queue, buffer, startIterator, endIterator);
9539 template<
typename IteratorType >
9542 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9545 size_type length = endIterator-startIterator;
9546 size_type byteLength = length*
sizeof(DataType);
9549 static_cast<DataType*
>(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_WRITE, 0, byteLength, 0, 0, &error));
9551 if( error != CL_SUCCESS ) {
9554 #if defined(_MSC_VER)
9558 stdext::checked_array_iterator<DataType*>(
9561 std::copy(startIterator, endIterator, pointer);
9564 error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
9566 if( error != CL_SUCCESS ) {
9578 template<
typename IteratorType >
9581 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9584 size_type length = endIterator-startIterator;
9585 size_type byteLength = length*
sizeof(DataType);
9588 static_cast<DataType*
>(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_READ, 0, byteLength, 0, 0, &error));
9590 if( error != CL_SUCCESS ) {
9593 std::copy(pointer, pointer + length, startIterator);
9595 error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
9597 if( error != CL_SUCCESS ) {
9605 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
9609 template<
typename T,
class Alloc>
9610 inline cl_int
mapSVM(cl::vector<T, Alloc> &container)
9612 return enqueueMapSVM(container, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE);
9618 template<
typename T,
class Alloc>
9619 inline cl_int
unmapSVM(cl::vector<T, Alloc> &container)
9626 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
9627 inline cl_int enqueueReadBufferRect(
9628 const Buffer& buffer,
9630 const array<size_type, 3>& buffer_offset,
9631 const array<size_type, 3>& host_offset,
9632 const array<size_type, 3>& region,
9633 size_type buffer_row_pitch,
9634 size_type buffer_slice_pitch,
9635 size_type host_row_pitch,
9636 size_type host_slice_pitch,
9638 const vector<Event>* events = NULL,
9639 Event* event = NULL)
9642 CommandQueue queue = CommandQueue::getDefault(&error);
9644 if (error != CL_SUCCESS) {
9648 return queue.enqueueReadBufferRect(
9663 inline cl_int enqueueWriteBufferRect(
9664 const Buffer& buffer,
9666 const array<size_type, 3>& buffer_offset,
9667 const array<size_type, 3>& host_offset,
9668 const array<size_type, 3>& region,
9669 size_type buffer_row_pitch,
9670 size_type buffer_slice_pitch,
9671 size_type host_row_pitch,
9672 size_type host_slice_pitch,
9674 const vector<Event>* events = NULL,
9675 Event* event = NULL)
9678 CommandQueue queue = CommandQueue::getDefault(&error);
9680 if (error != CL_SUCCESS) {
9684 return queue.enqueueWriteBufferRect(
9699 inline cl_int enqueueCopyBufferRect(
9702 const array<size_type, 3>& src_origin,
9703 const array<size_type, 3>& dst_origin,
9704 const array<size_type, 3>& region,
9705 size_type src_row_pitch,
9706 size_type src_slice_pitch,
9707 size_type dst_row_pitch,
9708 size_type dst_slice_pitch,
9709 const vector<Event>* events = NULL,
9710 Event* event = NULL)
9713 CommandQueue queue = CommandQueue::getDefault(&error);
9715 if (error != CL_SUCCESS) {
9719 return queue.enqueueCopyBufferRect(
9734 inline cl_int enqueueReadImage(
9737 const array<size_type, 3>& origin,
9738 const array<size_type, 3>& region,
9739 size_type row_pitch,
9740 size_type slice_pitch,
9742 const vector<Event>* events = NULL,
9743 Event* event = NULL)
9746 CommandQueue queue = CommandQueue::getDefault(&error);
9748 if (error != CL_SUCCESS) {
9752 return queue.enqueueReadImage(
9764 inline cl_int enqueueWriteImage(
9767 const array<size_type, 3>& origin,
9768 const array<size_type, 3>& region,
9769 size_type row_pitch,
9770 size_type slice_pitch,
9772 const vector<Event>* events = NULL,
9773 Event* event = NULL)
9776 CommandQueue queue = CommandQueue::getDefault(&error);
9778 if (error != CL_SUCCESS) {
9782 return queue.enqueueWriteImage(
9794 inline cl_int enqueueCopyImage(
9797 const array<size_type, 3>& src_origin,
9798 const array<size_type, 3>& dst_origin,
9799 const array<size_type, 3>& region,
9800 const vector<Event>* events = NULL,
9801 Event* event = NULL)
9804 CommandQueue queue = CommandQueue::getDefault(&error);
9806 if (error != CL_SUCCESS) {
9810 return queue.enqueueCopyImage(
9820 inline cl_int enqueueCopyImageToBuffer(
9823 const array<size_type, 3>& src_origin,
9824 const array<size_type, 3>& region,
9825 size_type dst_offset,
9826 const vector<Event>* events = NULL,
9827 Event* event = NULL)
9830 CommandQueue queue = CommandQueue::getDefault(&error);
9832 if (error != CL_SUCCESS) {
9836 return queue.enqueueCopyImageToBuffer(
9846 inline cl_int enqueueCopyBufferToImage(
9849 size_type src_offset,
9850 const array<size_type, 3>& dst_origin,
9851 const array<size_type, 3>& region,
9852 const vector<Event>* events = NULL,
9853 Event* event = NULL)
9856 CommandQueue queue = CommandQueue::getDefault(&error);
9858 if (error != CL_SUCCESS) {
9862 return queue.enqueueCopyBufferToImage(
9873 inline cl_int flush(
void)
9876 CommandQueue queue = CommandQueue::getDefault(&error);
9878 if (error != CL_SUCCESS) {
9882 return queue.flush();
9885 inline cl_int finish(
void)
9888 CommandQueue queue = CommandQueue::getDefault(&error);
9890 if (error != CL_SUCCESS) {
9895 return queue.finish();
9905 vector<Event> events_;
9907 template<
typename... Ts>
9912 queue_(CommandQueue::getDefault()),
9921 queue_(CommandQueue::getDefault()),
9930 queue_(CommandQueue::getDefault()),
9939 queue_(CommandQueue::getDefault()),
9944 events_.push_back(e);
9948 queue_(CommandQueue::getDefault()),
9953 events_.push_back(e);
9957 queue_(CommandQueue::getDefault()),
9962 events_.push_back(e);
9966 queue_(CommandQueue::getDefault()),
9976 queue_(CommandQueue::getDefault()),
9986 queue_(CommandQueue::getDefault()),
10006 offset_(NullRange),
10024 offset_(NullRange),
10028 events_.push_back(e);
10033 offset_(NullRange),
10037 events_.push_back(e);
10046 events_.push_back(e);
10051 offset_(NullRange),
10061 offset_(NullRange),
10088 template<
typename... Ts>
10094 template<
int index,
typename T0,
typename... T1s>
10095 void setArgs(T0&& t0, T1s&&... t1s)
10097 kernel_.
setArg(index, t0);
10098 setArgs<index + 1, T1s...>(std::forward<T1s>(t1s)...);
10101 template<
int index,
typename T0>
10102 void setArgs(T0&& t0)
10104 kernel_.
setArg(index, t0);
10107 template<
int index>
10120 cl_int * err = NULL) :
10121 kernel_(program, name.c_str(), err)
10137 setArgs<0>(std::forward<Ts>(ts)...);
10139 args.queue_.enqueueNDRangeKernel(
10162 setArgs<0>(std::forward<Ts>(ts)...);
10164 error = args.queue_.enqueueNDRangeKernel(
10175 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
10176 cl_int setSVMPointers(
const vector<void*> &pointerList)
10181 template<
typename T0,
typename... T1s>
10182 cl_int setSVMPointers(
const T0 &t0, T1s &... ts)
10194 namespace compatibility {
10199 template<
typename... Ts>
10209 cl_int * err = NULL) :
10231 enqueueArgs, args...);
10239 #undef CL_HPP_ERR_STR_
10240 #if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS)
10241 #undef __GET_DEVICE_INFO_ERR
10242 #undef __GET_PLATFORM_INFO_ERR
10243 #undef __GET_DEVICE_IDS_ERR
10244 #undef __GET_PLATFORM_IDS_ERR
10245 #undef __GET_CONTEXT_INFO_ERR
10246 #undef __GET_EVENT_INFO_ERR
10247 #undef __GET_EVENT_PROFILE_INFO_ERR
10248 #undef __GET_MEM_OBJECT_INFO_ERR
10249 #undef __GET_IMAGE_INFO_ERR
10250 #undef __GET_SAMPLER_INFO_ERR
10251 #undef __GET_KERNEL_INFO_ERR
10252 #undef __GET_KERNEL_ARG_INFO_ERR
10253 #undef __GET_KERNEL_SUB_GROUP_INFO_ERR
10254 #undef __GET_KERNEL_WORK_GROUP_INFO_ERR
10255 #undef __GET_PROGRAM_INFO_ERR
10256 #undef __GET_PROGRAM_BUILD_INFO_ERR
10257 #undef __GET_COMMAND_QUEUE_INFO_ERR
10258 #undef __CREATE_CONTEXT_ERR
10259 #undef __CREATE_CONTEXT_FROM_TYPE_ERR
10260 #undef __GET_SUPPORTED_IMAGE_FORMATS_ERR
10261 #undef __CREATE_BUFFER_ERR
10263 #undef __CREATE_SUBBUFFER_ERR
10264 #undef __CREATE_GL_BUFFER_ERR
10265 #undef __CREATE_GL_RENDER_BUFFER_ERR
10266 #undef __GET_GL_OBJECT_INFO_ERR
10267 #undef __CREATE_IMAGE_ERR
10268 #undef __CREATE_GL_TEXTURE_ERR
10269 #undef __IMAGE_DIMENSION_ERR
10270 #undef __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR
10271 #undef __CREATE_USER_EVENT_ERR
10272 #undef __SET_USER_EVENT_STATUS_ERR
10273 #undef __SET_EVENT_CALLBACK_ERR
10274 #undef __WAIT_FOR_EVENTS_ERR
10275 #undef __CREATE_KERNEL_ERR
10276 #undef __SET_KERNEL_ARGS_ERR
10277 #undef __CREATE_PROGRAM_WITH_SOURCE_ERR
10278 #undef __CREATE_PROGRAM_WITH_IL_ERR
10279 #undef __CREATE_PROGRAM_WITH_BINARY_ERR
10280 #undef __CREATE_PROGRAM_WITH_IL_ERR
10281 #undef __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR
10282 #undef __BUILD_PROGRAM_ERR
10283 #undef __COMPILE_PROGRAM_ERR
10284 #undef __LINK_PROGRAM_ERR
10285 #undef __CREATE_KERNELS_IN_PROGRAM_ERR
10286 #undef __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR
10287 #undef __CREATE_SAMPLER_WITH_PROPERTIES_ERR
10288 #undef __SET_COMMAND_QUEUE_PROPERTY_ERR
10289 #undef __ENQUEUE_READ_BUFFER_ERR
10290 #undef __ENQUEUE_READ_BUFFER_RECT_ERR
10291 #undef __ENQUEUE_WRITE_BUFFER_ERR
10292 #undef __ENQUEUE_WRITE_BUFFER_RECT_ERR
10293 #undef __ENQEUE_COPY_BUFFER_ERR
10294 #undef __ENQEUE_COPY_BUFFER_RECT_ERR
10295 #undef __ENQUEUE_FILL_BUFFER_ERR
10296 #undef __ENQUEUE_READ_IMAGE_ERR
10297 #undef __ENQUEUE_WRITE_IMAGE_ERR
10298 #undef __ENQUEUE_COPY_IMAGE_ERR
10299 #undef __ENQUEUE_FILL_IMAGE_ERR
10300 #undef __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR
10301 #undef __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR
10302 #undef __ENQUEUE_MAP_BUFFER_ERR
10303 #undef __ENQUEUE_MAP_IMAGE_ERR
10304 #undef __ENQUEUE_UNMAP_MEM_OBJECT_ERR
10305 #undef __ENQUEUE_NDRANGE_KERNEL_ERR
10306 #undef __ENQUEUE_NATIVE_KERNEL
10307 #undef __ENQUEUE_MIGRATE_MEM_OBJECTS_ERR
10308 #undef __ENQUEUE_MIGRATE_SVM_ERR
10309 #undef __ENQUEUE_ACQUIRE_GL_ERR
10310 #undef __ENQUEUE_RELEASE_GL_ERR
10311 #undef __CREATE_PIPE_ERR
10312 #undef __GET_PIPE_INFO_ERR
10313 #undef __RETAIN_ERR
10314 #undef __RELEASE_ERR
10316 #undef __FINISH_ERR
10317 #undef __VECTOR_CAPACITY_ERR
10318 #undef __CREATE_SUB_DEVICES_ERR
10319 #undef __CREATE_SUB_DEVICES_ERR
10320 #undef __ENQUEUE_MARKER_ERR
10321 #undef __ENQUEUE_WAIT_FOR_EVENTS_ERR
10322 #undef __ENQUEUE_BARRIER_ERR
10323 #undef __UNLOAD_COMPILER_ERR
10324 #undef __CREATE_GL_TEXTURE_2D_ERR
10325 #undef __CREATE_GL_TEXTURE_3D_ERR
10326 #undef __CREATE_IMAGE2D_ERR
10327 #undef __CREATE_IMAGE3D_ERR
10328 #undef __CREATE_COMMAND_QUEUE_ERR
10329 #undef __ENQUEUE_TASK_ERR
10330 #undef __CREATE_SAMPLER_ERR
10331 #undef __ENQUEUE_MARKER_WAIT_LIST_ERR
10332 #undef __ENQUEUE_BARRIER_WAIT_LIST_ERR
10333 #undef __CLONE_KERNEL_ERR
10334 #undef __GET_HOST_TIMER_ERR
10335 #undef __GET_DEVICE_AND_HOST_TIMER_ERR
10340 #undef CL_HPP_INIT_CL_EXT_FCN_PTR_
10341 #undef CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_
10343 #if defined(CL_HPP_USE_CL_DEVICE_FISSION)
10344 #undef CL_HPP_PARAM_NAME_DEVICE_FISSION_
10347 #undef CL_HPP_NOEXCEPT_
10348 #undef CL_HPP_DEFINE_STATIC_MEMBER_
Class interface for GL Buffer Memory Objects.
BufferGL(BufferGL &&buf) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
BufferGL()
Default constructor - initializes to NULL.
BufferGL(const Context &context, cl_mem_flags flags, cl_GLuint bufobj, cl_int *err=NULL)
Constructs a BufferGL in a specified context, from a given GL buffer.
BufferGL & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
BufferGL(const BufferGL &buf)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
cl_int getObjectInfo(cl_gl_object_type *type, cl_GLuint *gl_object_name)
Wrapper for clGetGLObjectInfo().
BufferGL(const cl_mem &buffer, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Class interface for Buffer Memory Objects.
Buffer()
Default constructor - initializes to NULL.
Buffer(const Buffer &buf)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Buffer(Buffer &&buf) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Buffer(const Context &context, cl_mem_flags flags, size_type size, void *host_ptr=NULL, cl_int *err=NULL)
Constructs a Buffer in a specified context.
Buffer(const cl_mem &buffer, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Buffer & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
Buffer(IteratorType startIterator, IteratorType endIterator, bool readOnly, bool useHostPtr=false, cl_int *err=NULL)
Construct a Buffer from a host container via iterators. IteratorType must be random access....
Buffer createSubBuffer(cl_mem_flags flags, cl_buffer_create_type buffer_create_type, const void *buffer_create_info, cl_int *err=NULL)
Creates a new buffer object from this.
Buffer(cl_mem_flags flags, size_type size, void *host_ptr=NULL, cl_int *err=NULL)
Constructs a Buffer in the default context.
Class interface for GL Render Buffer Memory Objects.
cl_int getObjectInfo(cl_gl_object_type *type, cl_GLuint *gl_object_name)
Wrapper for clGetGLObjectInfo().
BufferRenderGL(const cl_mem &buffer, bool retainObject=false)
Constructor from cl_mem - takes ownership.
BufferRenderGL(BufferRenderGL &&buf) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
BufferRenderGL & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
BufferRenderGL()
Default constructor - initializes to NULL.
BufferRenderGL(const BufferRenderGL &buf)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
BufferRenderGL(const Context &context, cl_mem_flags flags, cl_GLuint bufobj, cl_int *err=NULL)
Constructs a BufferRenderGL in a specified context, from a given GL Renderbuffer.
CommandQueue interface for cl_command_queue.
CommandQueue(QueueProperties properties, cl_int *err=NULL)
Constructs a CommandQueue based on passed properties. Will return an CL_INVALID_QUEUE_PROPERTIES erro...
CommandQueue(const cl_command_queue &commandQueue, bool retainObject=false)
Constructor from cl_command_queue - takes ownership.
cl_int enqueueFillBuffer(const Buffer &buffer, PatternType pattern, size_type offset, size_type size, const vector< Event > *events=NULL, Event *event=NULL) const
CommandQueue(CommandQueue &&queue) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
cl_int enqueueMigrateSVM(const cl::vector< cl::vector< T, Alloc >> &svmContainers, cl_mem_migration_flags flags=0, const vector< Event > *events=NULL, Event *event=NULL) const
cl_int enqueueFillImage(const Image &image, cl_uint4 fillColor, const array< size_type, 3 > &origin, const array< size_type, 3 > ®ion, const vector< Event > *events=NULL, Event *event=NULL) const
cl_int enqueueMapSVM(cl::vector< T, Alloc > &container, cl_bool blocking, cl_map_flags flags, const vector< Event > *events=NULL, Event *event=NULL) const
cl_int enqueueMigrateMemObjects(const vector< Memory > &memObjects, cl_mem_migration_flags flags, const vector< Event > *events=NULL, Event *event=NULL) const
cl_int enqueueMapSVM(cl::pointer< T, D > &ptr, cl_bool blocking, cl_map_flags flags, size_type size, const vector< Event > *events=NULL, Event *event=NULL) const
cl_int enqueueMigrateSVM(const cl::vector< T * > &svmRawPointers, cl_mem_migration_flags flags=0, const vector< Event > *events=NULL, Event *event=NULL) const
static CommandQueue setDefault(const CommandQueue &default_queue)
cl_int enqueueMarkerWithWaitList(const vector< Event > *events=0, Event *event=0) const
CommandQueue(cl_command_queue_properties properties, cl_int *err=NULL)
Constructs a CommandQueue based on passed properties. Will return an CL_INVALID_QUEUE_PROPERTIES erro...
cl_int enqueueMigrateSVM(const cl::vector< T * > &svmRawPointers, const cl::vector< size_type > &sizes, cl_mem_migration_flags flags=0, const vector< Event > *events=NULL, Event *event=NULL) const
cl_int enqueueUnmapSVM(cl::pointer< T, D > &ptr, const vector< Event > *events=NULL, Event *event=NULL) const
CommandQueue(const Context &context, const Device &device, cl_command_queue_properties properties=0, cl_int *err=NULL)
Constructs a CommandQueue for a passed device and context Will return an CL_INVALID_QUEUE_PROPERTIES ...
cl_int enqueueMigrateSVM(const cl::vector< cl::vector< T, Alloc >> &svmContainers, const cl::vector< size_type > &sizes, cl_mem_migration_flags flags=0, const vector< Event > *events=NULL, Event *event=NULL) const
CommandQueue(const Context &context, const Device &device, QueueProperties properties, cl_int *err=NULL)
Constructs a CommandQueue for a passed device and context Will return an CL_INVALID_QUEUE_PROPERTIES ...
cl_int enqueueMigrateSVM(const cl::vector< cl::pointer< T, D >> &svmPointers, cl_mem_migration_flags flags=0, const vector< Event > *events=NULL, Event *event=NULL) const
CommandQueue(const Context &context, QueueProperties properties, cl_int *err=NULL)
Constructs a CommandQueue for an implementation defined device in the given context Will return an CL...
cl_int enqueueFillImage(const Image &image, cl_float4 fillColor, const array< size_type, 3 > &origin, const array< size_type, 3 > ®ion, const vector< Event > *events=NULL, Event *event=NULL) const
CL_API_PREFIX__VERSION_1_1_DEPRECATED cl_int enqueueMarker(Event *event=NULL) const CL_API_SUFFIX__VERSION_1_1_DEPRECATED
cl_int enqueueFillImage(const Image &image, cl_int4 fillColor, const array< size_type, 3 > &origin, const array< size_type, 3 > ®ion, const vector< Event > *events=NULL, Event *event=NULL) const
CL_API_PREFIX__VERSION_1_1_DEPRECATED cl_int enqueueBarrier() const CL_API_SUFFIX__VERSION_1_1_DEPRECATED
cl_int enqueueBarrierWithWaitList(const vector< Event > *events=0, Event *event=0) const
CommandQueue(const Context &context, cl_command_queue_properties properties=0, cl_int *err=NULL)
Constructs a CommandQueue for an implementation defined device in the given context Will return an CL...
CommandQueue(const CommandQueue &queue)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
cl_int enqueueMapSVM(T *ptr, cl_bool blocking, cl_map_flags flags, size_type size, const vector< Event > *events=NULL, Event *event=NULL) const
cl_int enqueueUnmapSVM(cl::vector< T, Alloc > &container, const vector< Event > *events=NULL, Event *event=NULL) const
cl_int enqueueMigrateSVM(const cl::vector< cl::pointer< T, D >> &svmPointers, const cl::vector< size_type > &sizes, cl_mem_migration_flags flags=0, const vector< Event > *events=NULL, Event *event=NULL) const
cl_int enqueueUnmapSVM(T *ptr, const vector< Event > *events=NULL, Event *event=NULL) const
Class interface for cl_context.
Context(const vector< Device > &devices, const cl_context_properties *properties=NULL, void(CL_CALLBACK *notifyFptr)(const char *, const void *, size_type, void *)=NULL, void *data=NULL, cl_int *err=NULL)
Constructs a context including a list of specified devices.
static Context setDefault(const Context &default_context)
Context(const cl_context &context, bool retainObject=false)
Constructor from cl_context - takes ownership.
cl_int getSupportedImageFormats(cl_mem_flags flags, cl_mem_object_type type, vector< ImageFormat > *formats) const
Gets a list of supported image formats.
Context & operator=(const Context &ctx)
Copy assignment to forward copy to the superclass correctly. Required for MSVC.
Context()
Default constructor - initializes to NULL.
cl_int getInfo(cl_context_info name, T *param) const
Wrapper for clGetContextInfo().
Context(cl_device_type type, const cl_context_properties *properties=NULL, void(CL_CALLBACK *notifyFptr)(const char *, const void *, size_type, void *)=NULL, void *data=NULL, cl_int *err=NULL)
Constructs a context including all or a subset of devices of a specified type.
detail::param_traits< detail::cl_context_info, name >::param_type getInfo(cl_int *err=NULL) const
Wrapper for clGetContextInfo() that returns by value.
static Context getDefault(cl_int *err=NULL)
Returns a singleton context including all devices of CL_DEVICE_TYPE_DEFAULT.
Context(const Device &device, const cl_context_properties *properties=NULL, void(CL_CALLBACK *notifyFptr)(const char *, const void *, size_type, void *)=NULL, void *data=NULL, cl_int *err=NULL)
Constructs a context including a specific device.
Context(const Context &ctx)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Context(Context &&ctx) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
DeviceCommandQueue interface for device cl_command_queues.
DeviceCommandQueue(const Context &context, const Device &device, DeviceQueueProperties properties=DeviceQueueProperties::None, cl_int *err=NULL)
DeviceCommandQueue(const Context &context, const Device &device, cl_uint queueSize, DeviceQueueProperties properties=DeviceQueueProperties::None, cl_int *err=NULL)
static DeviceCommandQueue makeDefault(const Context &context, const Device &device, cl_int *err=nullptr)
static DeviceCommandQueue updateDefault(const Context &context, const Device &device, const DeviceCommandQueue &default_queue, cl_int *err=nullptr)
static DeviceCommandQueue getDefault(const CommandQueue &queue, cl_int *err=NULL)
static DeviceCommandQueue makeDefault(const Context &context, const Device &device, cl_uint queueSize, cl_int *err=nullptr)
DeviceCommandQueue(DeviceQueueProperties properties, cl_int *err=NULL)
DeviceCommandQueue(const DeviceCommandQueue &queue)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
DeviceCommandQueue(DeviceCommandQueue &&queue) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
DeviceCommandQueue(const cl_command_queue &commandQueue, bool retainObject=false)
Constructor from cl_command_queue - takes ownership.
static DeviceCommandQueue makeDefault(cl_int *err=nullptr)
Class interface for cl_device_id.
detail::param_traits< detail::cl_device_info, name >::param_type getInfo(cl_int *err=NULL) const
Wrapper for clGetDeviceInfo() that returns by value.
Device & operator=(const cl_device_id &rhs)
Assignment operator from cl_device_id.
cl_int getInfo(cl_device_info name, T *param) const
Wrapper for clGetDeviceInfo().
Device()
Default constructor - initializes to NULL.
cl_ulong getHostTimer(cl_int *error=nullptr)
static Device getDefault(cl_int *errResult=NULL)
Returns the first device on the default context.
Device(const Device &dev)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
std::pair< cl_ulong, cl_ulong > getDeviceAndHostTimer(cl_int *error=nullptr)
Device(Device &&dev) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
cl_int createSubDevices(const cl_device_partition_property *properties, vector< Device > *devices)
Wrapper for clCreateSubDevices().
static Device setDefault(const Device &default_device)
Device(const cl_device_id &device, bool retainObject=false)
Constructor from cl_device_id.
Class interface for cl_event.
Event(const cl_event &event, bool retainObject=false)
Constructor from cl_event - takes ownership.
cl_int getProfilingInfo(cl_profiling_info name, T *param) const
Wrapper for clGetEventProfilingInfo().
cl_int setCallback(cl_int type, void(CL_CALLBACK *pfn_notify)(cl_event, cl_int, void *), void *user_data=NULL)
Registers a user callback function for a specific command execution status.
cl_int getInfo(cl_event_info name, T *param) const
Wrapper for clGetEventInfo().
cl_int wait() const
Blocks the calling thread until this event completes.
Event()
Default constructor - initializes to NULL.
Event & operator=(const cl_event &rhs)
Assignment operator from cl_event - takes ownership.
detail::param_traits< detail::cl_profiling_info, name >::param_type getProfilingInfo(cl_int *err=NULL) const
Wrapper for clGetEventProfilingInfo() that returns by value.
detail::param_traits< detail::cl_event_info, name >::param_type getInfo(cl_int *err=NULL) const
Wrapper for clGetEventInfo() that returns by value.
static cl_int waitForEvents(const vector< Event > &events)
Blocks the calling thread until every event specified is complete.
Image interface for arrays of 1D images.
Image1DArray(const Image1DArray &img)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Image1DArray(Image1DArray &&img) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Image1DArray(const cl_mem &imageArray, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Image interface for 1D buffer images.
Image1DBuffer(const Image1DBuffer &img)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Image1DBuffer(const cl_mem &image1D, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Image1DBuffer(Image1DBuffer &&img) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Class interface for 1D Image Memory objects.
Image1D()
Default constructor - initializes to NULL.
Image1D & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
Image1D(const cl_mem &image1D, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Image1D(const Image1D &img)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Image1D(const Context &context, cl_mem_flags flags, ImageFormat format, size_type width, void *host_ptr=NULL, cl_int *err=NULL)
Constructs a 1D Image in a specified context.
Image1D(Image1D &&img) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Image interface for arrays of 2D images.
Image2DArray(const Image2DArray &img)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Image2DArray(const cl_mem &imageArray, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Image2DArray(Image2DArray &&img) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Class interface for GL 2D Image Memory objects.
Image2DGL()
Default constructor - initializes to NULL.
Image2DGL(const Image2DGL &img)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Image2DGL(Image2DGL &&img) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Image2DGL(const cl_mem &image, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Image2DGL(const Context &context, cl_mem_flags flags, cl_GLenum target, cl_GLint miplevel, cl_GLuint texobj, cl_int *err=NULL)
Constructs an Image2DGL in a specified context, from a given GL Texture.
Class interface for 2D Image Memory objects.
Image2D(const Image2D &img)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Image2D(const cl_mem &image2D, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Image2D()
Default constructor - initializes to NULL.
Image2D(Image2D &&img) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Image2D(const Context &context, cl_mem_flags flags, ImageFormat format, size_type width, size_type height, size_type row_pitch=0, void *host_ptr=NULL, cl_int *err=NULL)
Constructs a 2D Image in a specified context.
Image2D(const Context &context, ImageFormat format, const Buffer &sourceBuffer, size_type width, size_type height, size_type row_pitch=0, cl_int *err=nullptr)
Constructs a 2D Image from a buffer.
Image2D & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
Image2D(const Context &context, cl_channel_order order, const Image &sourceImage, cl_int *err=nullptr)
Constructs a 2D Image from an image.
Class interface for GL 3D Image Memory objects.
Image3DGL & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
Image3DGL()
Default constructor - initializes to NULL.
Image3DGL(Image3DGL &&img) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Image3DGL(const Image3DGL &img)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Image3DGL(const Context &context, cl_mem_flags flags, cl_GLenum target, cl_GLint miplevel, cl_GLuint texobj, cl_int *err=NULL)
Constructs an Image3DGL in a specified context, from a given GL Texture.
Image3DGL(const cl_mem &image, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Class interface for 3D Image Memory objects.
Image3D & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
Image3D(const cl_mem &image3D, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Image3D()
Default constructor - initializes to NULL.
Image3D(const Context &context, cl_mem_flags flags, ImageFormat format, size_type width, size_type height, size_type depth, size_type row_pitch=0, size_type slice_pitch=0, void *host_ptr=NULL, cl_int *err=NULL)
Constructs a 3D Image in a specified context.
Image3D(Image3D &&img) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Image3D(const Image3D &img)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
general image interface for GL interop. We abstract the 2D and 3D GL images into a single instance he...
ImageGL(const ImageGL &img)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
ImageGL(ImageGL &&img) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
ImageGL(const cl_mem &image, bool retainObject=false)
Constructor from cl_mem - takes ownership.
C++ base class for Image Memory objects.
Image(const Image &img)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Image(const cl_mem &image, bool retainObject=false)
Constructor from cl_mem - takes ownership.
detail::param_traits< detail::cl_image_info, name >::param_type getImageInfo(cl_int *err=NULL) const
Wrapper for clGetImageInfo() that returns by value.
cl_int getImageInfo(cl_image_info name, T *param) const
Wrapper for clGetImageInfo().
Image()
Default constructor - initializes to NULL.
Image(Image &&img) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Image & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
Event operator()(const EnqueueArgs &args, Ts... ts)
Event result_type
Return type of the functor.
Class interface for cl_kernel.
Kernel(Kernel &&kernel) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Kernel(const cl_kernel &kernel, bool retainObject=false)
Constructor from cl_kernel - takes ownership.
Kernel & operator=(const cl_kernel &rhs)
Assignment operator from cl_kernel - takes ownership.
cl_int setSVMPointers(const vector< void * > &pointerList)
cl_int setArg(cl_uint index, const cl::pointer< T, D > &argPtr)
setArg overload taking a shared_ptr type
Kernel()
Default constructor - initializes to NULL.
std::enable_if< std::is_pointer< T >::value, cl_int >::type setArg(cl_uint index, const T argPtr)
setArg overload taking a pointer type
Kernel(const Kernel &kernel)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
cl_int setArg(cl_uint index, const cl::vector< T, Alloc > &argPtr)
setArg overload taking a vector type.
std::enable_if<!std::is_pointer< T >::value, cl_int >::type setArg(cl_uint index, const T &value)
setArg overload taking a POD type
cl_int setSVMPointers(const std::array< void *, ArrayLength > &pointerList)
cl_int enableFineGrainedSystemSVM(bool svmEnabled)
Enable fine-grained system SVM.
Class interface for cl_mem.
cl_int setDestructorCallback(void(CL_CALLBACK *pfn_notify)(cl_mem, void *), void *user_data=NULL)
Registers a callback function to be called when the memory object is no longer needed.
Memory(const Memory &mem)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Memory(Memory &&mem) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Memory(const cl_mem &memory, bool retainObject)
Constructor from cl_mem - takes ownership.
detail::param_traits< detail::cl_mem_info, name >::param_type getInfo(cl_int *err=NULL) const
Wrapper for clGetMemObjectInfo() that returns by value.
Memory()
Default constructor - initializes to NULL.
Memory & operator=(const cl_mem &rhs)
Assignment operator from cl_mem - takes ownership.
cl_int getInfo(cl_mem_info name, T *param) const
Wrapper for clGetMemObjectInfo().
Class interface for specifying NDRange values.
size_type dimensions() const
Queries the number of dimensions in the range.
NDRange(size_type size0, size_type size1)
Constructs two-dimensional range.
NDRange(size_type size0, size_type size1, size_type size2)
Constructs three-dimensional range.
size_type size() const
Returns the size of the object in bytes based on the.
NDRange()
Default constructor - resulting range has zero dimensions.
NDRange(size_type size0)
Constructs one-dimensional range.
Class interface for Pipe Memory Objects.
Pipe(Pipe &&pipe) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Pipe(const Context &context, cl_uint packet_size, cl_uint max_packets, cl_int *err=NULL)
Constructs a Pipe in a specified context.
Pipe & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
Pipe()
Default constructor - initializes to NULL.
cl_int getInfo(cl_pipe_info name, T *param) const
Wrapper for clGetMemObjectInfo().
Pipe(cl_uint packet_size, cl_uint max_packets, cl_int *err=NULL)
Constructs a Pipe in a the default context.
Pipe(const Pipe &pipe)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Pipe(const cl_mem &pipe, bool retainObject=false)
Constructor from cl_mem - takes ownership.
detail::param_traits< detail::cl_pipe_info, name >::param_type getInfo(cl_int *err=NULL) const
Wrapper for clGetMemObjectInfo() that returns by value.
Program interface that implements cl_program.
Program(const Program &program)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Program(Program &&program) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Program(const Sources &sources, cl_int *err=NULL)
Program(const Context &context, const Sources &sources, cl_int *err=NULL)
Program(const vector< char > &IL, bool build=false, cl_int *err=NULL)
CL_API_PREFIX__VERSION_2_2_DEPRECATED cl_int setReleaseCallback(void(CL_CALLBACK *pfn_notify)(cl_program program, void *user_data), void *user_data=NULL) CL_API_SUFFIX__VERSION_2_2_DEPRECATED
Registers a callback function to be called when destructors for program scope global variables are co...
vector< std::pair< cl::Device, typename detail::param_traits< detail::cl_program_build_info, name >::param_type > > getBuildInfo(cl_int *err=NULL) const
Program(const Context &context, const vector< Device > &devices, const string &kernelNames, cl_int *err=NULL)
cl_int setSpecializationConstant(cl_uint index, size_type size, const void *value)
Sets a SPIR-V specialization constant.
Program(const cl_program &program, bool retainObject=false)
Constructor from cl_program - takes ownership.
std::enable_if<!std::is_pointer< T >::value, cl_int >::type setSpecializationConstant(cl_uint index, const T &value)
Sets a SPIR-V specialization constant.
Program(const Context &context, const vector< Device > &devices, const Binaries &binaries, vector< cl_int > *binaryStatus=NULL, cl_int *err=NULL)
Program(const Context &context, const vector< char > &IL, bool build=false, cl_int *err=NULL)
pointer allocate(size_type size, typename cl::SVMAllocator< void, SVMTrait >::const_pointer=0)
bool operator==(SVMAllocator const &rhs)
size_type max_size() const CL_HPP_NOEXCEPT_
Class interface for cl_sampler.
Sampler & operator=(const cl_sampler &rhs)
Assignment operator from cl_sampler - takes ownership.
Sampler()
Default constructor - initializes to NULL.
Sampler(const Context &context, cl_bool normalized_coords, cl_addressing_mode addressing_mode, cl_filter_mode filter_mode, cl_int *err=NULL)
Constructs a Sampler in a specified context.
Sampler(Sampler &&sam) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Sampler(const Sampler &sam)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
cl_int getInfo(cl_sampler_info name, T *param) const
Wrapper for clGetSamplerInfo().
Sampler(const cl_sampler &sampler, bool retainObject=false)
Constructor from cl_sampler - takes ownership.
detail::param_traits< detail::cl_sampler_info, name >::param_type getInfo(cl_int *err=NULL) const
Wrapper for clGetSamplerInfo() that returns by value.
Class interface for user events (a subset of cl_event's).
UserEvent()
Default constructor - initializes to NULL.
UserEvent(const Context &context, cl_int *err=NULL)
Constructs a user event on a given context.
cl_int setStatus(cl_int status)
Sets the execution status of a user event object.
The OpenCL C++ bindings are defined within this namespace.
cl_int copy(const CommandQueue &queue, const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator)
vector< T, cl::SVMAllocator< int, cl::SVMTraitFine<> >> fine_svm_vector
Vector alias to simplify contruction of fine-grained SVM containers.
cl_int copy(IteratorType startIterator, IteratorType endIterator, cl::Buffer &buffer)
LocalSpaceArg Local(size_type size)
Helper function for generating LocalSpaceArg objects.
CL_API_PREFIX__VERSION_1_1_DEPRECATED cl_int UnloadCompiler() CL_API_SUFFIX__VERSION_1_1_DEPRECATED
cl_int enqueueUnmapSVM(T *ptr, const vector< Event > *events=NULL, Event *event=NULL)
cl::pointer< T, detail::Deleter< Alloc > > allocate_pointer(const Alloc &alloc_, Args &&... args)
cl_int enqueueMapSVM(T *ptr, cl_bool blocking, cl_map_flags flags, size_type size, const vector< Event > *events=NULL, Event *event=NULL)
vector< T, cl::SVMAllocator< int, cl::SVMTraitCoarse<> >> coarse_svm_vector
Vector alias to simplify contruction of coarse-grained SVM containers.
cl_int mapSVM(cl::vector< T, Alloc > &container)
vector< T, cl::SVMAllocator< int, cl::SVMTraitAtomic<> >> atomic_svm_vector
Vector alias to simplify contruction of fine-grained SVM containers that support platform atomics.
cl_int unmapSVM(cl::vector< T, Alloc > &container)
Local address wrapper for use with Kernel::setArg.
Event type_(const EnqueueArgs &, Ts...)
Function signature of kernel functor with no event dependency.
Event result_type
Return type of the functor.
static cl_int release(cl_device_id device)
static cl_int retain(cl_device_id device)