395 #if !defined(CL_HPP_USE_DX_INTEROP) && defined(USE_DX_INTEROP)
396 # pragma message("opencl.hpp: USE_DX_INTEROP is deprecated. Define CL_HPP_USE_DX_INTEROP instead")
397 # define CL_HPP_USE_DX_INTEROP
399 #if !defined(CL_HPP_USE_CL_DEVICE_FISSION) && defined(USE_CL_DEVICE_FISSION)
400 # pragma message("opencl.hpp: USE_CL_DEVICE_FISSION is deprecated. Define CL_HPP_USE_CL_DEVICE_FISSION instead")
401 # define CL_HPP_USE_CL_DEVICE_FISSION
403 #if !defined(CL_HPP_ENABLE_EXCEPTIONS) && defined(__CL_ENABLE_EXCEPTIONS)
404 # pragma message("opencl.hpp: __CL_ENABLE_EXCEPTIONS is deprecated. Define CL_HPP_ENABLE_EXCEPTIONS instead")
405 # define CL_HPP_ENABLE_EXCEPTIONS
407 #if !defined(CL_HPP_NO_STD_VECTOR) && defined(__NO_STD_VECTOR)
408 # pragma message("opencl.hpp: __NO_STD_VECTOR is deprecated. Define CL_HPP_NO_STD_VECTOR instead")
409 # define CL_HPP_NO_STD_VECTOR
411 #if !defined(CL_HPP_NO_STD_STRING) && defined(__NO_STD_STRING)
412 # pragma message("opencl.hpp: __NO_STD_STRING is deprecated. Define CL_HPP_NO_STD_STRING instead")
413 # define CL_HPP_NO_STD_STRING
415 #if defined(VECTOR_CLASS)
416 # pragma message("opencl.hpp: VECTOR_CLASS is deprecated. Alias cl::vector instead")
418 #if defined(STRING_CLASS)
419 # pragma message("opencl.hpp: STRING_CLASS is deprecated. Alias cl::string instead.")
421 #if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS) && defined(__CL_USER_OVERRIDE_ERROR_STRINGS)
422 # pragma message("opencl.hpp: __CL_USER_OVERRIDE_ERROR_STRINGS is deprecated. Define CL_HPP_USER_OVERRIDE_ERROR_STRINGS instead")
423 # define CL_HPP_USER_OVERRIDE_ERROR_STRINGS
428 #if defined(__USE_DEV_VECTOR)
429 # pragma message("opencl.hpp: __USE_DEV_VECTOR is no longer supported. Expect compilation errors")
431 #if defined(__USE_DEV_STRING)
432 # pragma message("opencl.hpp: __USE_DEV_STRING is no longer supported. Expect compilation errors")
436 #if !defined(CL_HPP_TARGET_OPENCL_VERSION)
437 # pragma message("opencl.hpp: CL_HPP_TARGET_OPENCL_VERSION is not defined. It will default to 300 (OpenCL 3.0)")
438 # define CL_HPP_TARGET_OPENCL_VERSION 300
440 #if CL_HPP_TARGET_OPENCL_VERSION != 100 && \
441 CL_HPP_TARGET_OPENCL_VERSION != 110 && \
442 CL_HPP_TARGET_OPENCL_VERSION != 120 && \
443 CL_HPP_TARGET_OPENCL_VERSION != 200 && \
444 CL_HPP_TARGET_OPENCL_VERSION != 210 && \
445 CL_HPP_TARGET_OPENCL_VERSION != 220 && \
446 CL_HPP_TARGET_OPENCL_VERSION != 300
447 # 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).")
448 # undef CL_HPP_TARGET_OPENCL_VERSION
449 # define CL_HPP_TARGET_OPENCL_VERSION 300
453 #if defined(CL_TARGET_OPENCL_VERSION)
456 #if CL_TARGET_OPENCL_VERSION < CL_HPP_TARGET_OPENCL_VERSION
457 # pragma message("CL_TARGET_OPENCL_VERSION is already defined as is lower than CL_HPP_TARGET_OPENCL_VERSION")
460 # define CL_TARGET_OPENCL_VERSION CL_HPP_TARGET_OPENCL_VERSION
463 #if !defined(CL_HPP_MINIMUM_OPENCL_VERSION)
464 # define CL_HPP_MINIMUM_OPENCL_VERSION 200
466 #if CL_HPP_MINIMUM_OPENCL_VERSION != 100 && \
467 CL_HPP_MINIMUM_OPENCL_VERSION != 110 && \
468 CL_HPP_MINIMUM_OPENCL_VERSION != 120 && \
469 CL_HPP_MINIMUM_OPENCL_VERSION != 200 && \
470 CL_HPP_MINIMUM_OPENCL_VERSION != 210 && \
471 CL_HPP_MINIMUM_OPENCL_VERSION != 220 && \
472 CL_HPP_MINIMUM_OPENCL_VERSION != 300
473 # 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")
474 # undef CL_HPP_MINIMUM_OPENCL_VERSION
475 # define CL_HPP_MINIMUM_OPENCL_VERSION 100
477 #if CL_HPP_MINIMUM_OPENCL_VERSION > CL_HPP_TARGET_OPENCL_VERSION
478 # error "CL_HPP_MINIMUM_OPENCL_VERSION must not be greater than CL_HPP_TARGET_OPENCL_VERSION"
481 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 100 && !defined(CL_USE_DEPRECATED_OPENCL_1_0_APIS)
482 # define CL_USE_DEPRECATED_OPENCL_1_0_APIS
484 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 110 && !defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
485 # define CL_USE_DEPRECATED_OPENCL_1_1_APIS
487 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 120 && !defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
488 # define CL_USE_DEPRECATED_OPENCL_1_2_APIS
490 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 200 && !defined(CL_USE_DEPRECATED_OPENCL_2_0_APIS)
491 # define CL_USE_DEPRECATED_OPENCL_2_0_APIS
493 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 210 && !defined(CL_USE_DEPRECATED_OPENCL_2_1_APIS)
494 # define CL_USE_DEPRECATED_OPENCL_2_1_APIS
496 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 220 && !defined(CL_USE_DEPRECATED_OPENCL_2_2_APIS)
497 # define CL_USE_DEPRECATED_OPENCL_2_2_APIS
504 #if defined(CL_HPP_USE_DX_INTEROP)
505 #include <CL/cl_d3d10.h>
506 #include <CL/cl_dx9_media_sharing.h>
510 #if defined(_MSC_VER)
518 #if (!defined(_MSC_VER) && __cplusplus < 201103L) || (defined(_MSC_VER) && _MSC_VER < 1700)
519 #error Visual studio 2013 or another C++11-supporting compiler required
523 #if defined(CL_HPP_USE_CL_DEVICE_FISSION) || defined(CL_HPP_USE_CL_SUB_GROUPS_KHR)
524 #include <CL/cl_ext.h>
527 #if defined(__APPLE__) || defined(__MACOSX)
528 #include <OpenCL/opencl.h>
530 #include <CL/opencl.h>
533 #if (__cplusplus >= 201103L || _MSVC_LANG >= 201103L )
534 #define CL_HPP_NOEXCEPT_ noexcept
536 #define CL_HPP_NOEXCEPT_
539 #if __cplusplus >= 201703L
540 # define CL_HPP_DEFINE_STATIC_MEMBER_ inline
541 #elif defined(_MSC_VER)
542 # define CL_HPP_DEFINE_STATIC_MEMBER_ __declspec(selectany)
543 #elif defined(__MINGW32__)
544 # define CL_HPP_DEFINE_STATIC_MEMBER_ __attribute__((selectany))
546 # define CL_HPP_DEFINE_STATIC_MEMBER_ __attribute__((weak))
551 #if !defined(CL_API_PREFIX__VERSION_1_1_DEPRECATED)
552 #define CL_API_PREFIX__VERSION_1_1_DEPRECATED
554 #if !defined(CL_API_SUFFIX__VERSION_1_1_DEPRECATED)
555 #define CL_API_SUFFIX__VERSION_1_1_DEPRECATED
558 #if !defined(CL_API_PREFIX__VERSION_1_2_DEPRECATED)
559 #define CL_API_PREFIX__VERSION_1_2_DEPRECATED
561 #if !defined(CL_API_SUFFIX__VERSION_1_2_DEPRECATED)
562 #define CL_API_SUFFIX__VERSION_1_2_DEPRECATED
565 #if !defined(CL_CALLBACK)
574 #include <functional>
578 #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY)
580 using size_type = ::size_t;
584 using size_type = size_t;
589 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
593 #if !defined(CL_HPP_NO_STD_VECTOR)
596 template <
class T,
class Alloc = std::allocator<T> >
597 using vector = std::vector<T, Alloc>;
601 #if !defined(CL_HPP_NO_STD_STRING)
604 using string = std::string;
608 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
610 #if !defined(CL_HPP_NO_STD_UNIQUE_PTR)
615 template<
class T,
class D>
616 using pointer = std::unique_ptr<T, D>;
620 #if !defined(CL_HPP_NO_STD_ARRAY)
623 template <
class T,
size_type N >
624 using array = std::array<T, N>;
630 #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY)
632 namespace compatibility {
647 for (
int i = 0; i < N; ++i) {
652 size_t(
const array<size_type, N> &rhs)
654 for (
int i = 0; i < N; ++i) {
659 size_type& operator[](
int index)
664 const size_type& operator[](
int index)
const
670 operator size_type* () {
return data_; }
673 operator const size_type* ()
const {
return data_; }
675 operator array<size_type, N>()
const
677 array<size_type, N> ret;
679 for (
int i = 0; i < N; ++i) {
688 using size_t = compatibility::size_t<N>;
695 using size_t_array = array<size_type, 3>;
708 #define CL_HPP_INIT_CL_EXT_FCN_PTR_(name) \
710 pfn_##name = (PFN_##name) \
711 clGetExtensionFunctionAddress(#name); \
716 #define CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, name) \
718 pfn_##name = (PFN_##name) \
719 clGetExtensionFunctionAddressForPlatform(platform, #name); \
728 class DeviceCommandQueue;
733 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
738 class Error :
public std::exception
742 const char * errStr_;
753 Error(cl_int err,
const char * errStr = NULL) : err_(err), errStr_(errStr)
762 virtual const char * what()
const throw ()
764 if (errStr_ == NULL) {
776 cl_int err(
void)
const {
return err_; }
778 #define CL_HPP_ERR_STR_(x) #x
780 #define CL_HPP_ERR_STR_(x) NULL
786 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
787 static inline cl_int errHandler (
789 const char * errStr = NULL)
791 if (err != CL_SUCCESS) {
792 throw Error(err, errStr);
797 static inline cl_int errHandler (cl_int err,
const char * errStr = NULL)
808 #if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS)
809 #define __GET_DEVICE_INFO_ERR CL_HPP_ERR_STR_(clGetDeviceInfo)
810 #define __GET_PLATFORM_INFO_ERR CL_HPP_ERR_STR_(clGetPlatformInfo)
811 #define __GET_DEVICE_IDS_ERR CL_HPP_ERR_STR_(clGetDeviceIDs)
812 #define __GET_PLATFORM_IDS_ERR CL_HPP_ERR_STR_(clGetPlatformIDs)
813 #define __GET_CONTEXT_INFO_ERR CL_HPP_ERR_STR_(clGetContextInfo)
814 #define __GET_EVENT_INFO_ERR CL_HPP_ERR_STR_(clGetEventInfo)
815 #define __GET_EVENT_PROFILE_INFO_ERR CL_HPP_ERR_STR_(clGetEventProfileInfo)
816 #define __GET_MEM_OBJECT_INFO_ERR CL_HPP_ERR_STR_(clGetMemObjectInfo)
817 #define __GET_IMAGE_INFO_ERR CL_HPP_ERR_STR_(clGetImageInfo)
818 #define __GET_SAMPLER_INFO_ERR CL_HPP_ERR_STR_(clGetSamplerInfo)
819 #define __GET_KERNEL_INFO_ERR CL_HPP_ERR_STR_(clGetKernelInfo)
820 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
821 #define __GET_KERNEL_ARG_INFO_ERR CL_HPP_ERR_STR_(clGetKernelArgInfo)
823 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
824 #define __GET_KERNEL_SUB_GROUP_INFO_ERR CL_HPP_ERR_STR_(clGetKernelSubGroupInfo)
826 #define __GET_KERNEL_WORK_GROUP_INFO_ERR CL_HPP_ERR_STR_(clGetKernelWorkGroupInfo)
827 #define __GET_PROGRAM_INFO_ERR CL_HPP_ERR_STR_(clGetProgramInfo)
828 #define __GET_PROGRAM_BUILD_INFO_ERR CL_HPP_ERR_STR_(clGetProgramBuildInfo)
829 #define __GET_COMMAND_QUEUE_INFO_ERR CL_HPP_ERR_STR_(clGetCommandQueueInfo)
831 #define __CREATE_CONTEXT_ERR CL_HPP_ERR_STR_(clCreateContext)
832 #define __CREATE_CONTEXT_FROM_TYPE_ERR CL_HPP_ERR_STR_(clCreateContextFromType)
833 #define __GET_SUPPORTED_IMAGE_FORMATS_ERR CL_HPP_ERR_STR_(clGetSupportedImageFormats)
835 #define __CREATE_BUFFER_ERR CL_HPP_ERR_STR_(clCreateBuffer)
836 #define __COPY_ERR CL_HPP_ERR_STR_(cl::copy)
837 #define __CREATE_SUBBUFFER_ERR CL_HPP_ERR_STR_(clCreateSubBuffer)
838 #define __CREATE_GL_BUFFER_ERR CL_HPP_ERR_STR_(clCreateFromGLBuffer)
839 #define __CREATE_GL_RENDER_BUFFER_ERR CL_HPP_ERR_STR_(clCreateFromGLBuffer)
840 #define __GET_GL_OBJECT_INFO_ERR CL_HPP_ERR_STR_(clGetGLObjectInfo)
841 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
842 #define __CREATE_IMAGE_ERR CL_HPP_ERR_STR_(clCreateImage)
843 #define __CREATE_GL_TEXTURE_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture)
844 #define __IMAGE_DIMENSION_ERR CL_HPP_ERR_STR_(Incorrect image dimensions)
846 #define __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR CL_HPP_ERR_STR_(clSetMemObjectDestructorCallback)
848 #define __CREATE_USER_EVENT_ERR CL_HPP_ERR_STR_(clCreateUserEvent)
849 #define __SET_USER_EVENT_STATUS_ERR CL_HPP_ERR_STR_(clSetUserEventStatus)
850 #define __SET_EVENT_CALLBACK_ERR CL_HPP_ERR_STR_(clSetEventCallback)
851 #define __WAIT_FOR_EVENTS_ERR CL_HPP_ERR_STR_(clWaitForEvents)
853 #define __CREATE_KERNEL_ERR CL_HPP_ERR_STR_(clCreateKernel)
854 #define __SET_KERNEL_ARGS_ERR CL_HPP_ERR_STR_(clSetKernelArg)
855 #define __CREATE_PROGRAM_WITH_SOURCE_ERR CL_HPP_ERR_STR_(clCreateProgramWithSource)
856 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
857 #define __CREATE_PROGRAM_WITH_IL_ERR CL_HPP_ERR_STR_(clCreateProgramWithIL)
859 #define __CREATE_PROGRAM_WITH_BINARY_ERR CL_HPP_ERR_STR_(clCreateProgramWithBinary)
860 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
861 #define __CREATE_PROGRAM_WITH_IL_ERR CL_HPP_ERR_STR_(clCreateProgramWithIL)
863 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
864 #define __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR CL_HPP_ERR_STR_(clCreateProgramWithBuiltInKernels)
866 #define __BUILD_PROGRAM_ERR CL_HPP_ERR_STR_(clBuildProgram)
867 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
868 #define __COMPILE_PROGRAM_ERR CL_HPP_ERR_STR_(clCompileProgram)
869 #define __LINK_PROGRAM_ERR CL_HPP_ERR_STR_(clLinkProgram)
871 #define __CREATE_KERNELS_IN_PROGRAM_ERR CL_HPP_ERR_STR_(clCreateKernelsInProgram)
873 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
874 #define __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR CL_HPP_ERR_STR_(clCreateCommandQueueWithProperties)
875 #define __CREATE_SAMPLER_WITH_PROPERTIES_ERR CL_HPP_ERR_STR_(clCreateSamplerWithProperties)
877 #define __SET_COMMAND_QUEUE_PROPERTY_ERR CL_HPP_ERR_STR_(clSetCommandQueueProperty)
878 #define __ENQUEUE_READ_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueReadBuffer)
879 #define __ENQUEUE_READ_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueReadBufferRect)
880 #define __ENQUEUE_WRITE_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueWriteBuffer)
881 #define __ENQUEUE_WRITE_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueWriteBufferRect)
882 #define __ENQEUE_COPY_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueCopyBuffer)
883 #define __ENQEUE_COPY_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueCopyBufferRect)
884 #define __ENQUEUE_FILL_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueFillBuffer)
885 #define __ENQUEUE_READ_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueReadImage)
886 #define __ENQUEUE_WRITE_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueWriteImage)
887 #define __ENQUEUE_COPY_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueCopyImage)
888 #define __ENQUEUE_FILL_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueFillImage)
889 #define __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueCopyImageToBuffer)
890 #define __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueCopyBufferToImage)
891 #define __ENQUEUE_MAP_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueMapBuffer)
892 #define __ENQUEUE_MAP_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueMapImage)
893 #define __ENQUEUE_UNMAP_MEM_OBJECT_ERR CL_HPP_ERR_STR_(clEnqueueUnMapMemObject)
894 #define __ENQUEUE_NDRANGE_KERNEL_ERR CL_HPP_ERR_STR_(clEnqueueNDRangeKernel)
895 #define __ENQUEUE_NATIVE_KERNEL CL_HPP_ERR_STR_(clEnqueueNativeKernel)
896 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
897 #define __ENQUEUE_MIGRATE_MEM_OBJECTS_ERR CL_HPP_ERR_STR_(clEnqueueMigrateMemObjects)
899 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
900 #define __ENQUEUE_MIGRATE_SVM_ERR CL_HPP_ERR_STR_(clEnqueueSVMMigrateMem)
901 #define __SET_DEFAULT_DEVICE_COMMAND_QUEUE_ERR CL_HPP_ERR_STR_(clSetDefaultDeviceCommandQueue)
905 #define __ENQUEUE_ACQUIRE_GL_ERR CL_HPP_ERR_STR_(clEnqueueAcquireGLObjects)
906 #define __ENQUEUE_RELEASE_GL_ERR CL_HPP_ERR_STR_(clEnqueueReleaseGLObjects)
908 #define __CREATE_PIPE_ERR CL_HPP_ERR_STR_(clCreatePipe)
909 #define __GET_PIPE_INFO_ERR CL_HPP_ERR_STR_(clGetPipeInfo)
912 #define __RETAIN_ERR CL_HPP_ERR_STR_(Retain Object)
913 #define __RELEASE_ERR CL_HPP_ERR_STR_(Release Object)
914 #define __FLUSH_ERR CL_HPP_ERR_STR_(clFlush)
915 #define __FINISH_ERR CL_HPP_ERR_STR_(clFinish)
916 #define __VECTOR_CAPACITY_ERR CL_HPP_ERR_STR_(Vector capacity error)
918 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
919 #define __GET_HOST_TIMER_ERR CL_HPP_ERR_STR_(clGetHostTimer)
920 #define __GET_DEVICE_AND_HOST_TIMER_ERR CL_HPP_ERR_STR_(clGetDeviceAndHostTimer)
922 #if CL_HPP_TARGET_OPENCL_VERSION >= 220
923 #define __SET_PROGRAM_RELEASE_CALLBACK_ERR CL_HPP_ERR_STR_(clSetProgramReleaseCallback)
924 #define __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR CL_HPP_ERR_STR_(clSetProgramSpecializationConstant)
931 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
932 #define __CREATE_SUB_DEVICES_ERR CL_HPP_ERR_STR_(clCreateSubDevices)
934 #define __CREATE_SUB_DEVICES_ERR CL_HPP_ERR_STR_(clCreateSubDevicesEXT)
940 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
941 #define __ENQUEUE_MARKER_ERR CL_HPP_ERR_STR_(clEnqueueMarker)
942 #define __ENQUEUE_WAIT_FOR_EVENTS_ERR CL_HPP_ERR_STR_(clEnqueueWaitForEvents)
943 #define __ENQUEUE_BARRIER_ERR CL_HPP_ERR_STR_(clEnqueueBarrier)
944 #define __UNLOAD_COMPILER_ERR CL_HPP_ERR_STR_(clUnloadCompiler)
945 #define __CREATE_GL_TEXTURE_2D_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture2D)
946 #define __CREATE_GL_TEXTURE_3D_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture3D)
947 #define __CREATE_IMAGE2D_ERR CL_HPP_ERR_STR_(clCreateImage2D)
948 #define __CREATE_IMAGE3D_ERR CL_HPP_ERR_STR_(clCreateImage3D)
954 #if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
955 #define __CREATE_COMMAND_QUEUE_ERR CL_HPP_ERR_STR_(clCreateCommandQueue)
956 #define __ENQUEUE_TASK_ERR CL_HPP_ERR_STR_(clEnqueueTask)
957 #define __CREATE_SAMPLER_ERR CL_HPP_ERR_STR_(clCreateSampler)
963 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
964 #define __ENQUEUE_MARKER_WAIT_LIST_ERR CL_HPP_ERR_STR_(clEnqueueMarkerWithWaitList)
965 #define __ENQUEUE_BARRIER_WAIT_LIST_ERR CL_HPP_ERR_STR_(clEnqueueBarrierWithWaitList)
968 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
969 #define __CLONE_KERNEL_ERR CL_HPP_ERR_STR_(clCloneKernel)
982 template<
typename Functor,
typename T>
983 inline cl_int getInfoHelper(Functor f, cl_uint name, T* param,
long)
985 return f(name,
sizeof(T), param, NULL);
990 template <
typename Func>
991 inline cl_int getInfoHelper(Func f, cl_uint name, vector<vector<unsigned char>>* param,
int)
993 if (name != CL_PROGRAM_BINARIES) {
994 return CL_INVALID_VALUE;
998 size_type numBinaries = param->size();
999 vector<unsigned char*> binariesPointers(numBinaries);
1001 for (size_type i = 0; i < numBinaries; ++i)
1003 binariesPointers[i] = (*param)[i].data();
1006 cl_int err = f(name, numBinaries *
sizeof(
unsigned char*), binariesPointers.data(), NULL);
1008 if (err != CL_SUCCESS) {
1018 template <
typename Func,
typename T>
1019 inline cl_int getInfoHelper(Func f, cl_uint name, vector<T>* param,
long)
1022 cl_int err = f(name, 0, NULL, &required);
1023 if (err != CL_SUCCESS) {
1026 const size_type elements = required /
sizeof(T);
1029 vector<T> localData(elements);
1030 err = f(name, required, localData.data(), NULL);
1031 if (err != CL_SUCCESS) {
1035 *param = std::move(localData);
1047 template <
typename Func,
typename T>
1048 inline cl_int getInfoHelper(
1049 Func f, cl_uint name, vector<T>* param,
int,
typename T::cl_type = 0)
1052 cl_int err = f(name, 0, NULL, &required);
1053 if (err != CL_SUCCESS) {
1057 const size_type elements = required /
sizeof(
typename T::cl_type);
1059 vector<typename T::cl_type> value(elements);
1060 err = f(name, required, value.data(), NULL);
1061 if (err != CL_SUCCESS) {
1067 param->resize(elements);
1071 for (size_type i = 0; i < elements; i++) {
1072 (*param)[i] = T(value[i],
true);
1079 template <
typename Func>
1080 inline cl_int getInfoHelper(Func f, cl_uint name,
string* param,
long)
1083 cl_int err = f(name, 0, NULL, &required);
1084 if (err != CL_SUCCESS) {
1091 vector<char> value(required);
1092 err = f(name, required, value.data(), NULL);
1093 if (err != CL_SUCCESS) {
1097 param->assign(begin(value), prev(end(value)));
1107 template <
typename Func,
size_type N>
1108 inline cl_int getInfoHelper(Func f, cl_uint name, array<size_type, N>* param,
long)
1111 cl_int err = f(name, 0, NULL, &required);
1112 if (err != CL_SUCCESS) {
1116 size_type elements = required /
sizeof(size_type);
1117 vector<size_type> value(elements, 0);
1119 err = f(name, required, value.data(), NULL);
1120 if (err != CL_SUCCESS) {
1129 for (size_type i = 0; i < elements; ++i) {
1130 (*param)[i] = value[i];
1136 template<
typename T>
struct ReferenceHandler;
1144 template<
typename Func,
typename T>
1145 inline cl_int getInfoHelper(Func f, cl_uint name, T* param,
int,
typename T::cl_type = 0)
1147 typename T::cl_type value;
1148 cl_int err = f(name,
sizeof(value), &value, NULL);
1149 if (err != CL_SUCCESS) {
1155 err = param->retain();
1156 if (err != CL_SUCCESS) {
1163 #define CL_HPP_PARAM_NAME_INFO_1_0_(F) \
1164 F(cl_platform_info, CL_PLATFORM_PROFILE, string) \
1165 F(cl_platform_info, CL_PLATFORM_VERSION, string) \
1166 F(cl_platform_info, CL_PLATFORM_NAME, string) \
1167 F(cl_platform_info, CL_PLATFORM_VENDOR, string) \
1168 F(cl_platform_info, CL_PLATFORM_EXTENSIONS, string) \
1170 F(cl_device_info, CL_DEVICE_TYPE, cl_device_type) \
1171 F(cl_device_info, CL_DEVICE_VENDOR_ID, cl_uint) \
1172 F(cl_device_info, CL_DEVICE_MAX_COMPUTE_UNITS, cl_uint) \
1173 F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, cl_uint) \
1174 F(cl_device_info, CL_DEVICE_MAX_WORK_GROUP_SIZE, size_type) \
1175 F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_SIZES, cl::vector<size_type>) \
1176 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, cl_uint) \
1177 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT, cl_uint) \
1178 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT, cl_uint) \
1179 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG, cl_uint) \
1180 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT, cl_uint) \
1181 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, cl_uint) \
1182 F(cl_device_info, CL_DEVICE_MAX_CLOCK_FREQUENCY, cl_uint) \
1183 F(cl_device_info, CL_DEVICE_ADDRESS_BITS, cl_uint) \
1184 F(cl_device_info, CL_DEVICE_MAX_READ_IMAGE_ARGS, cl_uint) \
1185 F(cl_device_info, CL_DEVICE_MAX_WRITE_IMAGE_ARGS, cl_uint) \
1186 F(cl_device_info, CL_DEVICE_MAX_MEM_ALLOC_SIZE, cl_ulong) \
1187 F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_WIDTH, size_type) \
1188 F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_HEIGHT, size_type) \
1189 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_WIDTH, size_type) \
1190 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_HEIGHT, size_type) \
1191 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_DEPTH, size_type) \
1192 F(cl_device_info, CL_DEVICE_IMAGE_SUPPORT, cl_bool) \
1193 F(cl_device_info, CL_DEVICE_MAX_PARAMETER_SIZE, size_type) \
1194 F(cl_device_info, CL_DEVICE_MAX_SAMPLERS, cl_uint) \
1195 F(cl_device_info, CL_DEVICE_MEM_BASE_ADDR_ALIGN, cl_uint) \
1196 F(cl_device_info, CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE, cl_uint) \
1197 F(cl_device_info, CL_DEVICE_SINGLE_FP_CONFIG, cl_device_fp_config) \
1198 F(cl_device_info, CL_DEVICE_DOUBLE_FP_CONFIG, cl_device_fp_config) \
1199 F(cl_device_info, CL_DEVICE_HALF_FP_CONFIG, cl_device_fp_config) \
1200 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_TYPE, cl_device_mem_cache_type) \
1201 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE, cl_uint)\
1202 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_SIZE, cl_ulong) \
1203 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_SIZE, cl_ulong) \
1204 F(cl_device_info, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE, cl_ulong) \
1205 F(cl_device_info, CL_DEVICE_MAX_CONSTANT_ARGS, cl_uint) \
1206 F(cl_device_info, CL_DEVICE_LOCAL_MEM_TYPE, cl_device_local_mem_type) \
1207 F(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE, cl_ulong) \
1208 F(cl_device_info, CL_DEVICE_ERROR_CORRECTION_SUPPORT, cl_bool) \
1209 F(cl_device_info, CL_DEVICE_PROFILING_TIMER_RESOLUTION, size_type) \
1210 F(cl_device_info, CL_DEVICE_ENDIAN_LITTLE, cl_bool) \
1211 F(cl_device_info, CL_DEVICE_AVAILABLE, cl_bool) \
1212 F(cl_device_info, CL_DEVICE_COMPILER_AVAILABLE, cl_bool) \
1213 F(cl_device_info, CL_DEVICE_EXECUTION_CAPABILITIES, cl_device_exec_capabilities) \
1214 F(cl_device_info, CL_DEVICE_PLATFORM, cl_platform_id) \
1215 F(cl_device_info, CL_DEVICE_NAME, string) \
1216 F(cl_device_info, CL_DEVICE_VENDOR, string) \
1217 F(cl_device_info, CL_DRIVER_VERSION, string) \
1218 F(cl_device_info, CL_DEVICE_PROFILE, string) \
1219 F(cl_device_info, CL_DEVICE_VERSION, string) \
1220 F(cl_device_info, CL_DEVICE_EXTENSIONS, string) \
1222 F(cl_context_info, CL_CONTEXT_REFERENCE_COUNT, cl_uint) \
1223 F(cl_context_info, CL_CONTEXT_DEVICES, cl::vector<Device>) \
1224 F(cl_context_info, CL_CONTEXT_PROPERTIES, cl::vector<cl_context_properties>) \
1226 F(cl_event_info, CL_EVENT_COMMAND_QUEUE, cl::CommandQueue) \
1227 F(cl_event_info, CL_EVENT_COMMAND_TYPE, cl_command_type) \
1228 F(cl_event_info, CL_EVENT_REFERENCE_COUNT, cl_uint) \
1229 F(cl_event_info, CL_EVENT_COMMAND_EXECUTION_STATUS, cl_int) \
1231 F(cl_profiling_info, CL_PROFILING_COMMAND_QUEUED, cl_ulong) \
1232 F(cl_profiling_info, CL_PROFILING_COMMAND_SUBMIT, cl_ulong) \
1233 F(cl_profiling_info, CL_PROFILING_COMMAND_START, cl_ulong) \
1234 F(cl_profiling_info, CL_PROFILING_COMMAND_END, cl_ulong) \
1236 F(cl_mem_info, CL_MEM_TYPE, cl_mem_object_type) \
1237 F(cl_mem_info, CL_MEM_FLAGS, cl_mem_flags) \
1238 F(cl_mem_info, CL_MEM_SIZE, size_type) \
1239 F(cl_mem_info, CL_MEM_HOST_PTR, void*) \
1240 F(cl_mem_info, CL_MEM_MAP_COUNT, cl_uint) \
1241 F(cl_mem_info, CL_MEM_REFERENCE_COUNT, cl_uint) \
1242 F(cl_mem_info, CL_MEM_CONTEXT, cl::Context) \
1244 F(cl_image_info, CL_IMAGE_FORMAT, cl_image_format) \
1245 F(cl_image_info, CL_IMAGE_ELEMENT_SIZE, size_type) \
1246 F(cl_image_info, CL_IMAGE_ROW_PITCH, size_type) \
1247 F(cl_image_info, CL_IMAGE_SLICE_PITCH, size_type) \
1248 F(cl_image_info, CL_IMAGE_WIDTH, size_type) \
1249 F(cl_image_info, CL_IMAGE_HEIGHT, size_type) \
1250 F(cl_image_info, CL_IMAGE_DEPTH, size_type) \
1252 F(cl_sampler_info, CL_SAMPLER_REFERENCE_COUNT, cl_uint) \
1253 F(cl_sampler_info, CL_SAMPLER_CONTEXT, cl::Context) \
1254 F(cl_sampler_info, CL_SAMPLER_NORMALIZED_COORDS, cl_bool) \
1255 F(cl_sampler_info, CL_SAMPLER_ADDRESSING_MODE, cl_addressing_mode) \
1256 F(cl_sampler_info, CL_SAMPLER_FILTER_MODE, cl_filter_mode) \
1258 F(cl_program_info, CL_PROGRAM_REFERENCE_COUNT, cl_uint) \
1259 F(cl_program_info, CL_PROGRAM_CONTEXT, cl::Context) \
1260 F(cl_program_info, CL_PROGRAM_NUM_DEVICES, cl_uint) \
1261 F(cl_program_info, CL_PROGRAM_DEVICES, cl::vector<Device>) \
1262 F(cl_program_info, CL_PROGRAM_SOURCE, string) \
1263 F(cl_program_info, CL_PROGRAM_BINARY_SIZES, cl::vector<size_type>) \
1264 F(cl_program_info, CL_PROGRAM_BINARIES, cl::vector<cl::vector<unsigned char>>) \
1266 F(cl_program_build_info, CL_PROGRAM_BUILD_STATUS, cl_build_status) \
1267 F(cl_program_build_info, CL_PROGRAM_BUILD_OPTIONS, string) \
1268 F(cl_program_build_info, CL_PROGRAM_BUILD_LOG, string) \
1270 F(cl_kernel_info, CL_KERNEL_FUNCTION_NAME, string) \
1271 F(cl_kernel_info, CL_KERNEL_NUM_ARGS, cl_uint) \
1272 F(cl_kernel_info, CL_KERNEL_REFERENCE_COUNT, cl_uint) \
1273 F(cl_kernel_info, CL_KERNEL_CONTEXT, cl::Context) \
1274 F(cl_kernel_info, CL_KERNEL_PROGRAM, cl::Program) \
1276 F(cl_kernel_work_group_info, CL_KERNEL_WORK_GROUP_SIZE, size_type) \
1277 F(cl_kernel_work_group_info, CL_KERNEL_COMPILE_WORK_GROUP_SIZE, cl::detail::size_t_array) \
1278 F(cl_kernel_work_group_info, CL_KERNEL_LOCAL_MEM_SIZE, cl_ulong) \
1280 F(cl_command_queue_info, CL_QUEUE_CONTEXT, cl::Context) \
1281 F(cl_command_queue_info, CL_QUEUE_DEVICE, cl::Device) \
1282 F(cl_command_queue_info, CL_QUEUE_REFERENCE_COUNT, cl_uint) \
1283 F(cl_command_queue_info, CL_QUEUE_PROPERTIES, cl_command_queue_properties)
1286 #define CL_HPP_PARAM_NAME_INFO_1_1_(F) \
1287 F(cl_context_info, CL_CONTEXT_NUM_DEVICES, cl_uint)\
1288 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF, cl_uint) \
1289 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR, cl_uint) \
1290 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT, cl_uint) \
1291 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_INT, cl_uint) \
1292 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG, cl_uint) \
1293 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT, cl_uint) \
1294 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE, cl_uint) \
1295 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF, cl_uint) \
1296 F(cl_device_info, CL_DEVICE_OPENCL_C_VERSION, string) \
1298 F(cl_mem_info, CL_MEM_ASSOCIATED_MEMOBJECT, cl::Memory) \
1299 F(cl_mem_info, CL_MEM_OFFSET, size_type) \
1301 F(cl_kernel_work_group_info, CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, size_type) \
1302 F(cl_kernel_work_group_info, CL_KERNEL_PRIVATE_MEM_SIZE, cl_ulong) \
1304 F(cl_event_info, CL_EVENT_CONTEXT, cl::Context)
1306 #define CL_HPP_PARAM_NAME_INFO_1_2_(F) \
1307 F(cl_program_info, CL_PROGRAM_NUM_KERNELS, size_type) \
1308 F(cl_program_info, CL_PROGRAM_KERNEL_NAMES, string) \
1310 F(cl_program_build_info, CL_PROGRAM_BINARY_TYPE, cl_program_binary_type) \
1312 F(cl_kernel_info, CL_KERNEL_ATTRIBUTES, string) \
1314 F(cl_kernel_arg_info, CL_KERNEL_ARG_ADDRESS_QUALIFIER, cl_kernel_arg_address_qualifier) \
1315 F(cl_kernel_arg_info, CL_KERNEL_ARG_ACCESS_QUALIFIER, cl_kernel_arg_access_qualifier) \
1316 F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_NAME, string) \
1317 F(cl_kernel_arg_info, CL_KERNEL_ARG_NAME, string) \
1318 F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_QUALIFIER, cl_kernel_arg_type_qualifier) \
1320 F(cl_kernel_work_group_info, CL_KERNEL_GLOBAL_WORK_SIZE, cl::detail::size_t_array) \
1322 F(cl_device_info, CL_DEVICE_LINKER_AVAILABLE, cl_bool) \
1323 F(cl_device_info, CL_DEVICE_IMAGE_MAX_BUFFER_SIZE, size_type) \
1324 F(cl_device_info, CL_DEVICE_IMAGE_MAX_ARRAY_SIZE, size_type) \
1325 F(cl_device_info, CL_DEVICE_PARENT_DEVICE, cl::Device) \
1326 F(cl_device_info, CL_DEVICE_PARTITION_MAX_SUB_DEVICES, cl_uint) \
1327 F(cl_device_info, CL_DEVICE_PARTITION_PROPERTIES, cl::vector<cl_device_partition_property>) \
1328 F(cl_device_info, CL_DEVICE_PARTITION_TYPE, cl::vector<cl_device_partition_property>) \
1329 F(cl_device_info, CL_DEVICE_REFERENCE_COUNT, cl_uint) \
1330 F(cl_device_info, CL_DEVICE_PREFERRED_INTEROP_USER_SYNC, cl_bool) \
1331 F(cl_device_info, CL_DEVICE_PARTITION_AFFINITY_DOMAIN, cl_device_affinity_domain) \
1332 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS, string) \
1333 F(cl_device_info, CL_DEVICE_PRINTF_BUFFER_SIZE, size_type) \
1335 F(cl_image_info, CL_IMAGE_ARRAY_SIZE, size_type) \
1336 F(cl_image_info, CL_IMAGE_NUM_MIP_LEVELS, cl_uint) \
1337 F(cl_image_info, CL_IMAGE_NUM_SAMPLES, cl_uint)
1339 #define CL_HPP_PARAM_NAME_INFO_2_0_(F) \
1340 F(cl_device_info, CL_DEVICE_QUEUE_ON_HOST_PROPERTIES, cl_command_queue_properties) \
1341 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES, cl_command_queue_properties) \
1342 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE, cl_uint) \
1343 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE, cl_uint) \
1344 F(cl_device_info, CL_DEVICE_MAX_ON_DEVICE_QUEUES, cl_uint) \
1345 F(cl_device_info, CL_DEVICE_MAX_ON_DEVICE_EVENTS, cl_uint) \
1346 F(cl_device_info, CL_DEVICE_MAX_PIPE_ARGS, cl_uint) \
1347 F(cl_device_info, CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS, cl_uint) \
1348 F(cl_device_info, CL_DEVICE_PIPE_MAX_PACKET_SIZE, cl_uint) \
1349 F(cl_device_info, CL_DEVICE_SVM_CAPABILITIES, cl_device_svm_capabilities) \
1350 F(cl_device_info, CL_DEVICE_PREFERRED_PLATFORM_ATOMIC_ALIGNMENT, cl_uint) \
1351 F(cl_device_info, CL_DEVICE_PREFERRED_GLOBAL_ATOMIC_ALIGNMENT, cl_uint) \
1352 F(cl_device_info, CL_DEVICE_PREFERRED_LOCAL_ATOMIC_ALIGNMENT, cl_uint) \
1353 F(cl_device_info, CL_DEVICE_IMAGE_PITCH_ALIGNMENT, cl_uint) \
1354 F(cl_device_info, CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT, cl_uint) \
1355 F(cl_device_info, CL_DEVICE_MAX_READ_WRITE_IMAGE_ARGS, cl_uint ) \
1356 F(cl_device_info, CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE, size_type ) \
1357 F(cl_device_info, CL_DEVICE_GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE, size_type ) \
1358 F(cl_profiling_info, CL_PROFILING_COMMAND_COMPLETE, cl_ulong) \
1359 F(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM, cl_bool) \
1360 F(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_SVM_PTRS, void**) \
1361 F(cl_command_queue_info, CL_QUEUE_SIZE, cl_uint) \
1362 F(cl_mem_info, CL_MEM_USES_SVM_POINTER, cl_bool) \
1363 F(cl_program_build_info, CL_PROGRAM_BUILD_GLOBAL_VARIABLE_TOTAL_SIZE, size_type) \
1364 F(cl_pipe_info, CL_PIPE_PACKET_SIZE, cl_uint) \
1365 F(cl_pipe_info, CL_PIPE_MAX_PACKETS, cl_uint)
1367 #define CL_HPP_PARAM_NAME_INFO_SUBGROUP_KHR_(F) \
1368 F(cl_kernel_sub_group_info, CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE_KHR, size_type) \
1369 F(cl_kernel_sub_group_info, CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE_KHR, size_type)
1371 #define CL_HPP_PARAM_NAME_INFO_IL_KHR_(F) \
1372 F(cl_device_info, CL_DEVICE_IL_VERSION_KHR, string) \
1373 F(cl_program_info, CL_PROGRAM_IL_KHR, cl::vector<unsigned char>)
1375 #define CL_HPP_PARAM_NAME_INFO_2_1_(F) \
1376 F(cl_platform_info, CL_PLATFORM_HOST_TIMER_RESOLUTION, cl_ulong) \
1377 F(cl_program_info, CL_PROGRAM_IL, cl::vector<unsigned char>) \
1378 F(cl_device_info, CL_DEVICE_MAX_NUM_SUB_GROUPS, cl_uint) \
1379 F(cl_device_info, CL_DEVICE_IL_VERSION, string) \
1380 F(cl_device_info, CL_DEVICE_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS, cl_bool) \
1381 F(cl_command_queue_info, CL_QUEUE_DEVICE_DEFAULT, cl::DeviceCommandQueue) \
1382 F(cl_kernel_sub_group_info, CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE, size_type) \
1383 F(cl_kernel_sub_group_info, CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE, size_type) \
1384 F(cl_kernel_sub_group_info, CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT, cl::detail::size_t_array) \
1385 F(cl_kernel_sub_group_info, CL_KERNEL_MAX_NUM_SUB_GROUPS, size_type) \
1386 F(cl_kernel_sub_group_info, CL_KERNEL_COMPILE_NUM_SUB_GROUPS, size_type)
1388 #define CL_HPP_PARAM_NAME_INFO_2_2_(F) \
1389 F(cl_program_info, CL_PROGRAM_SCOPE_GLOBAL_CTORS_PRESENT, cl_bool) \
1390 F(cl_program_info, CL_PROGRAM_SCOPE_GLOBAL_DTORS_PRESENT, cl_bool)
1392 #define CL_HPP_PARAM_NAME_DEVICE_FISSION_(F) \
1393 F(cl_device_info, CL_DEVICE_PARENT_DEVICE_EXT, cl_device_id) \
1394 F(cl_device_info, CL_DEVICE_PARTITION_TYPES_EXT, cl::vector<cl_device_partition_property_ext>) \
1395 F(cl_device_info, CL_DEVICE_AFFINITY_DOMAINS_EXT, cl::vector<cl_device_partition_property_ext>) \
1396 F(cl_device_info, CL_DEVICE_REFERENCE_COUNT_EXT , cl_uint) \
1397 F(cl_device_info, CL_DEVICE_PARTITION_STYLE_EXT, cl::vector<cl_device_partition_property_ext>)
1399 #define CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_CL3_SHARED_(F) \
1400 F(cl_platform_info, CL_PLATFORM_NUMERIC_VERSION_KHR, cl_version_khr) \
1401 F(cl_platform_info, CL_PLATFORM_EXTENSIONS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>) \
1403 F(cl_device_info, CL_DEVICE_NUMERIC_VERSION_KHR, cl_version_khr) \
1404 F(cl_device_info, CL_DEVICE_EXTENSIONS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>) \
1405 F(cl_device_info, CL_DEVICE_ILS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>) \
1406 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>)
1408 #define CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_KHRONLY_(F) \
1409 F(cl_device_info, CL_DEVICE_OPENCL_C_NUMERIC_VERSION_KHR, cl_version_khr)
1411 #define CL_HPP_PARAM_NAME_INFO_3_0_(F) \
1412 F(cl_platform_info, CL_PLATFORM_NUMERIC_VERSION, cl_version) \
1413 F(cl_platform_info, CL_PLATFORM_EXTENSIONS_WITH_VERSION, cl::vector<cl_name_version>) \
1415 F(cl_device_info, CL_DEVICE_NUMERIC_VERSION, cl_version) \
1416 F(cl_device_info, CL_DEVICE_EXTENSIONS_WITH_VERSION, cl::vector<cl_name_version>) \
1417 F(cl_device_info, CL_DEVICE_ILS_WITH_VERSION, cl::vector<cl_name_version>) \
1418 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS_WITH_VERSION, cl::vector<cl_name_version>) \
1419 F(cl_device_info, CL_DEVICE_ATOMIC_MEMORY_CAPABILITIES, cl_device_atomic_capabilities) \
1420 F(cl_device_info, CL_DEVICE_ATOMIC_FENCE_CAPABILITIES, cl_device_atomic_capabilities) \
1421 F(cl_device_info, CL_DEVICE_NON_UNIFORM_WORK_GROUP_SUPPORT, cl_bool) \
1422 F(cl_device_info, CL_DEVICE_OPENCL_C_ALL_VERSIONS, cl::vector<cl_name_version>) \
1423 F(cl_device_info, CL_DEVICE_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, size_type) \
1424 F(cl_device_info, CL_DEVICE_WORK_GROUP_COLLECTIVE_FUNCTIONS_SUPPORT, cl_bool) \
1425 F(cl_device_info, CL_DEVICE_GENERIC_ADDRESS_SPACE_SUPPORT, cl_bool) \
1426 F(cl_device_info, CL_DEVICE_OPENCL_C_FEATURES, cl::vector<cl_name_version>) \
1427 F(cl_device_info, CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES, cl_device_device_enqueue_capabilities) \
1428 F(cl_device_info, CL_DEVICE_PIPE_SUPPORT, cl_bool) \
1429 F(cl_device_info, CL_DEVICE_LATEST_CONFORMANCE_VERSION_PASSED, string) \
1431 F(cl_command_queue_info, CL_QUEUE_PROPERTIES_ARRAY, cl::vector<cl_queue_properties>) \
1432 F(cl_mem_info, CL_MEM_PROPERTIES, cl::vector<cl_mem_properties>) \
1433 F(cl_pipe_info, CL_PIPE_PROPERTIES, cl::vector<cl_pipe_properties>) \
1434 F(cl_sampler_info, CL_SAMPLER_PROPERTIES, cl::vector<cl_sampler_properties>)
1436 template <
typename enum_type, cl_
int Name>
1439 #define CL_HPP_DECLARE_PARAM_TRAITS_(token, param_name, T) \
1442 struct param_traits<detail:: token,param_name> \
1444 enum { value = param_name }; \
1445 typedef T param_type; \
1448 CL_HPP_PARAM_NAME_INFO_1_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1449 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
1450 CL_HPP_PARAM_NAME_INFO_1_1_(CL_HPP_DECLARE_PARAM_TRAITS_)
1452 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
1453 CL_HPP_PARAM_NAME_INFO_1_2_(CL_HPP_DECLARE_PARAM_TRAITS_)
1455 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
1456 CL_HPP_PARAM_NAME_INFO_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1458 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
1459 CL_HPP_PARAM_NAME_INFO_2_1_(CL_HPP_DECLARE_PARAM_TRAITS_)
1461 #if CL_HPP_TARGET_OPENCL_VERSION >= 220
1462 CL_HPP_PARAM_NAME_INFO_2_2_(CL_HPP_DECLARE_PARAM_TRAITS_)
1464 #if CL_HPP_TARGET_OPENCL_VERSION >= 300
1465 CL_HPP_PARAM_NAME_INFO_3_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1468 #if defined(CL_HPP_USE_CL_SUB_GROUPS_KHR) && CL_HPP_TARGET_OPENCL_VERSION < 210
1469 CL_HPP_PARAM_NAME_INFO_SUBGROUP_KHR_(CL_HPP_DECLARE_PARAM_TRAITS_)
1472 #if defined(CL_HPP_USE_IL_KHR)
1473 CL_HPP_PARAM_NAME_INFO_IL_KHR_(CL_HPP_DECLARE_PARAM_TRAITS_)
1478 #define CL_HPP_PARAM_NAME_INFO_1_0_DEPRECATED_IN_2_0_(F) \
1479 F(cl_device_info, CL_DEVICE_QUEUE_PROPERTIES, cl_command_queue_properties)
1481 #define CL_HPP_PARAM_NAME_INFO_1_1_DEPRECATED_IN_2_0_(F) \
1482 F(cl_device_info, CL_DEVICE_HOST_UNIFIED_MEMORY, cl_bool)
1484 #define CL_HPP_PARAM_NAME_INFO_1_2_DEPRECATED_IN_2_0_(F) \
1485 F(cl_image_info, CL_IMAGE_BUFFER, cl::Buffer)
1489 #if CL_HPP_TARGET_OPENCL_VERSION > 100 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 && CL_HPP_TARGET_OPENCL_VERSION < 200
1490 CL_HPP_PARAM_NAME_INFO_1_0_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1492 #if CL_HPP_TARGET_OPENCL_VERSION > 110 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
1493 CL_HPP_PARAM_NAME_INFO_1_1_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1495 #if CL_HPP_TARGET_OPENCL_VERSION > 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
1496 CL_HPP_PARAM_NAME_INFO_1_2_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1499 #if defined(CL_HPP_USE_CL_DEVICE_FISSION)
1500 CL_HPP_PARAM_NAME_DEVICE_FISSION_(CL_HPP_DECLARE_PARAM_TRAITS_);
1503 #if defined(cl_khr_extended_versioning)
1504 #if CL_HPP_TARGET_OPENCL_VERSION < 300
1505 CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_CL3_SHARED_(CL_HPP_DECLARE_PARAM_TRAITS_)
1507 CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_KHRONLY_(CL_HPP_DECLARE_PARAM_TRAITS_)
1510 #if defined(cl_khr_device_uuid)
1511 using uuid_array = array<cl_uchar, CL_UUID_SIZE_KHR>;
1512 using luid_array = array<cl_uchar, CL_LUID_SIZE_KHR>;
1513 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_UUID_KHR, uuid_array)
1514 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DRIVER_UUID_KHR, uuid_array)
1515 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LUID_VALID_KHR, cl_bool)
1516 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LUID_KHR, luid_array)
1517 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_NODE_MASK_KHR, cl_uint)
1520 #if defined(cl_khr_pci_bus_info)
1521 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_PCI_BUS_INFO_KHR, cl_device_pci_bus_info_khr)
1524 #ifdef CL_PLATFORM_ICD_SUFFIX_KHR
1525 CL_HPP_DECLARE_PARAM_TRAITS_(cl_platform_info, CL_PLATFORM_ICD_SUFFIX_KHR,
string)
1528 #ifdef CL_DEVICE_PROFILING_TIMER_OFFSET_AMD
1529 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_PROFILING_TIMER_OFFSET_AMD, cl_ulong)
1531 #ifdef CL_DEVICE_GLOBAL_FREE_MEMORY_AMD
1532 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_FREE_MEMORY_AMD, vector<size_type>)
1534 #ifdef CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD
1535 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD, cl_uint)
1537 #ifdef CL_DEVICE_SIMD_WIDTH_AMD
1538 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_WIDTH_AMD, cl_uint)
1540 #ifdef CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD
1541 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD, cl_uint)
1543 #ifdef CL_DEVICE_WAVEFRONT_WIDTH_AMD
1544 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_WAVEFRONT_WIDTH_AMD, cl_uint)
1546 #ifdef CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD
1547 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD, cl_uint)
1549 #ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD
1550 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD, cl_uint)
1552 #ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD
1553 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD, cl_uint)
1555 #ifdef CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD
1556 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD, cl_uint)
1558 #ifdef CL_DEVICE_LOCAL_MEM_BANKS_AMD
1559 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LOCAL_MEM_BANKS_AMD, cl_uint)
1562 #ifdef CL_DEVICE_COMPUTE_UNITS_BITFIELD_ARM
1563 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_UNITS_BITFIELD_ARM, cl_ulong)
1565 #ifdef CL_DEVICE_JOB_SLOTS_ARM
1566 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_JOB_SLOTS_ARM, cl_uint)
1568 #ifdef CL_DEVICE_SCHEDULING_CONTROLS_CAPABILITIES_ARM
1569 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SCHEDULING_CONTROLS_CAPABILITIES_ARM, cl_bitfield)
1571 #ifdef CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_ARM
1572 CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_ARM, cl_uint)
1574 #ifdef CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_MODIFIER_ARM
1575 CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_MODIFIER_ARM, cl_int)
1578 #ifdef CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV
1579 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV, cl_uint)
1581 #ifdef CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV
1582 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV, cl_uint)
1584 #ifdef CL_DEVICE_REGISTERS_PER_BLOCK_NV
1585 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_REGISTERS_PER_BLOCK_NV, cl_uint)
1587 #ifdef CL_DEVICE_WARP_SIZE_NV
1588 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_WARP_SIZE_NV, cl_uint)
1590 #ifdef CL_DEVICE_GPU_OVERLAP_NV
1591 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GPU_OVERLAP_NV, cl_bool)
1593 #ifdef CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV
1594 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV, cl_bool)
1596 #ifdef CL_DEVICE_INTEGRATED_MEMORY_NV
1597 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGRATED_MEMORY_NV, cl_bool)
1602 template <
typename Func,
typename T>
1604 getInfo(Func f, cl_uint name, T* param)
1606 return getInfoHelper(f, name, param, 0);
1609 template <
typename Func,
typename Arg0>
1612 Func f_;
const Arg0& arg0_;
1614 cl_uint param, size_type size,
void* value, size_type* size_ret)
1615 {
return f_(arg0_, param, size, value, size_ret); }
1618 template <
typename Func,
typename Arg0,
typename Arg1>
1621 Func f_;
const Arg0& arg0_;
const Arg1& arg1_;
1623 cl_uint param, size_type size,
void* value, size_type* size_ret)
1624 {
return f_(arg0_, arg1_, param, size, value, size_ret); }
1627 template <
typename Func,
typename Arg0,
typename T>
1629 getInfo(Func f,
const Arg0& arg0, cl_uint name, T* param)
1632 return getInfoHelper(f0, name, param, 0);
1635 template <
typename Func,
typename Arg0,
typename Arg1,
typename T>
1637 getInfo(Func f,
const Arg0& arg0,
const Arg1& arg1, cl_uint name, T* param)
1639 GetInfoFunctor1<Func, Arg0, Arg1> f0 = { f, arg0, arg1 };
1640 return getInfoHelper(f0, name, param, 0);
1644 template<
typename T>
1648 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
1665 { return ::clRetainDevice(device); }
1676 { return ::clReleaseDevice(device); }
1683 struct ReferenceHandler<cl_device_id>
1686 static cl_int retain(cl_device_id)
1687 {
return CL_SUCCESS; }
1689 static cl_int release(cl_device_id)
1690 {
return CL_SUCCESS; }
1698 static cl_int retain(cl_platform_id)
1699 {
return CL_SUCCESS; }
1701 static cl_int release(cl_platform_id)
1702 {
return CL_SUCCESS; }
1708 static cl_int retain(cl_context context)
1709 { return ::clRetainContext(context); }
1710 static cl_int release(cl_context context)
1711 { return ::clReleaseContext(context); }
1717 static cl_int retain(cl_command_queue queue)
1718 { return ::clRetainCommandQueue(queue); }
1719 static cl_int release(cl_command_queue queue)
1720 { return ::clReleaseCommandQueue(queue); }
1726 static cl_int retain(cl_mem memory)
1727 { return ::clRetainMemObject(memory); }
1728 static cl_int release(cl_mem memory)
1729 { return ::clReleaseMemObject(memory); }
1735 static cl_int retain(cl_sampler sampler)
1736 { return ::clRetainSampler(sampler); }
1737 static cl_int release(cl_sampler sampler)
1738 { return ::clReleaseSampler(sampler); }
1744 static cl_int retain(cl_program program)
1745 { return ::clRetainProgram(program); }
1746 static cl_int release(cl_program program)
1747 { return ::clReleaseProgram(program); }
1753 static cl_int retain(cl_kernel kernel)
1754 { return ::clRetainKernel(kernel); }
1755 static cl_int release(cl_kernel kernel)
1756 { return ::clReleaseKernel(kernel); }
1762 static cl_int retain(cl_event event)
1763 { return ::clRetainEvent(event); }
1764 static cl_int release(cl_event event)
1765 { return ::clReleaseEvent(event); }
1769 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
1771 static cl_uint getVersion(
const vector<char> &versionInfo)
1773 int highVersion = 0;
1776 while(versionInfo[index] !=
'.' ) {
1778 highVersion += versionInfo[index]-
'0';
1782 while(versionInfo[index] !=
' ' && versionInfo[index] !=
'\0') {
1784 lowVersion += versionInfo[index]-
'0';
1787 return (highVersion << 16) | lowVersion;
1790 static cl_uint getPlatformVersion(cl_platform_id platform)
1793 clGetPlatformInfo(platform, CL_PLATFORM_VERSION, 0, NULL, &size);
1795 vector<char> versionInfo(size);
1796 clGetPlatformInfo(platform, CL_PLATFORM_VERSION, size, versionInfo.data(), &size);
1797 return getVersion(versionInfo);
1800 static cl_uint getDevicePlatformVersion(cl_device_id device)
1802 cl_platform_id platform;
1803 clGetDeviceInfo(device, CL_DEVICE_PLATFORM,
sizeof(platform), &platform, NULL);
1804 return getPlatformVersion(platform);
1807 static cl_uint getContextPlatformVersion(cl_context context)
1812 clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, NULL, &size);
1815 vector<cl_device_id> devices(size/
sizeof(cl_device_id));
1816 clGetContextInfo(context, CL_CONTEXT_DEVICES, size, devices.data(), NULL);
1817 return getDevicePlatformVersion(devices[0]);
1821 template <
typename T>
1833 Wrapper(
const cl_type &obj,
bool retainObject) : object_(obj)
1836 detail::errHandler(retain(), __RETAIN_ERR);
1842 if (object_ != NULL) { release(); }
1847 object_ = rhs.object_;
1848 detail::errHandler(retain(), __RETAIN_ERR);
1853 object_ = rhs.object_;
1860 detail::errHandler(release(), __RELEASE_ERR);
1861 object_ = rhs.object_;
1862 detail::errHandler(retain(), __RETAIN_ERR);
1870 detail::errHandler(release(), __RELEASE_ERR);
1871 object_ = rhs.object_;
1879 detail::errHandler(release(), __RELEASE_ERR);
1884 const cl_type& operator ()()
const {
return object_; }
1886 cl_type& operator ()() {
return object_; }
1888 cl_type get()
const {
return object_; }
1891 template<
typename Func,
typename U>
1892 friend inline cl_int getInfoHelper(Func, cl_uint, U*,
int,
typename U::cl_type);
1894 cl_int retain()
const
1896 if (object_ !=
nullptr) {
1904 cl_int release()
const
1906 if (object_ !=
nullptr) {
1919 typedef cl_device_id cl_type;
1923 bool referenceCountable_;
1925 static bool isReferenceCountable(cl_device_id device)
1927 bool retVal =
false;
1928 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
1929 #if CL_HPP_MINIMUM_OPENCL_VERSION < 120
1930 if (device != NULL) {
1931 int version = getDevicePlatformVersion(device);
1932 if(version > ((1 << 16) + 1)) {
1944 Wrapper() : object_(NULL), referenceCountable_(
false)
1948 Wrapper(
const cl_type &obj,
bool retainObject) :
1950 referenceCountable_(
false)
1952 referenceCountable_ = isReferenceCountable(obj);
1955 detail::errHandler(retain(), __RETAIN_ERR);
1966 object_ = rhs.object_;
1967 referenceCountable_ = isReferenceCountable(object_);
1968 detail::errHandler(retain(), __RETAIN_ERR);
1973 object_ = rhs.object_;
1974 referenceCountable_ = rhs.referenceCountable_;
1976 rhs.referenceCountable_ =
false;
1982 detail::errHandler(release(), __RELEASE_ERR);
1983 object_ = rhs.object_;
1984 referenceCountable_ = rhs.referenceCountable_;
1985 detail::errHandler(retain(), __RETAIN_ERR);
1993 detail::errHandler(release(), __RELEASE_ERR);
1994 object_ = rhs.object_;
1995 referenceCountable_ = rhs.referenceCountable_;
1997 rhs.referenceCountable_ =
false;
2004 detail::errHandler(release(), __RELEASE_ERR);
2006 referenceCountable_ = isReferenceCountable(object_);
2010 const cl_type& operator ()()
const {
return object_; }
2012 cl_type& operator ()() {
return object_; }
2014 cl_type get()
const {
return object_; }
2017 template<
typename Func,
typename U>
2018 friend inline cl_int getInfoHelper(Func, cl_uint, U*,
int,
typename U::cl_type);
2020 template<
typename Func,
typename U>
2021 friend inline cl_int getInfoHelper(Func, cl_uint, vector<U>*,
int,
typename U::cl_type);
2023 cl_int retain()
const
2025 if( object_ !=
nullptr && referenceCountable_ ) {
2033 cl_int release()
const
2035 if (object_ !=
nullptr && referenceCountable_) {
2044 template <
typename T>
2047 return lhs() == rhs();
2050 template <
typename T>
2051 inline bool operator!=(
const Wrapper<T> &lhs,
const Wrapper<T> &rhs)
2053 return !operator==(lhs, rhs);
2060 using BuildLogType = vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, CL_PROGRAM_BUILD_LOG>::param_type>>;
2061 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
2065 class BuildError :
public Error
2068 BuildLogType buildLogs;
2070 BuildError(cl_int err,
const char * errStr,
const BuildLogType &vec) : Error(err, errStr), buildLogs(vec)
2074 BuildLogType getBuildLog()
const
2080 static inline cl_int buildErrHandler(
2082 const char * errStr,
2083 const BuildLogType &buildLogs)
2085 if (err != CL_SUCCESS) {
2086 throw BuildError(err, errStr, buildLogs);
2094 static inline cl_int buildErrHandler(
2096 const char * errStr,
2097 const BuildLogType &buildLogs)
2120 image_channel_order = order;
2121 image_channel_data_type = type;
2131 this->image_channel_data_type = rhs.image_channel_data_type;
2132 this->image_channel_order = rhs.image_channel_order;
2148 static std::once_flag default_initialized_;
2150 static cl_int default_error_;
2157 static void makeDefault();
2164 static void makeDefaultProvided(
const Device &p) {
2169 #ifdef CL_HPP_UNIT_TEST_ENABLE
2176 static void unitTestClearDefault() {
2188 explicit Device(
const cl_device_id &device,
bool retainObject =
false) :
2189 detail::Wrapper<cl_type>(device, retainObject) { }
2196 cl_int *errResult = NULL)
2198 std::call_once(default_initialized_, makeDefault);
2199 detail::errHandler(default_error_);
2200 if (errResult != NULL) {
2201 *errResult = default_error_;
2215 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_device));
2216 detail::errHandler(default_error_);
2259 template <
typename T>
2260 cl_int
getInfo(cl_device_info name, T* param)
const
2262 return detail::errHandler(
2263 detail::getInfo(&::clGetDeviceInfo, object_, name, param),
2264 __GET_DEVICE_INFO_ERR);
2268 template <cl_device_info name>
typename
2273 detail::cl_device_info, name>::param_type param;
2274 cl_int result =
getInfo(name, ¶m);
2282 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
2291 cl_ulong retVal = 0;
2293 clGetHostTimer(this->get(), &retVal);
2296 __GET_HOST_TIMER_ERR);
2315 std::pair<cl_ulong, cl_ulong> retVal;
2317 clGetDeviceAndHostTimer(this->get(), &(retVal.first), &(retVal.second));
2320 __GET_DEVICE_AND_HOST_TIMER_ERR);
2331 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
2334 const cl_device_partition_property * properties,
2335 vector<Device>* devices)
2338 cl_int err = clCreateSubDevices(object_, properties, 0, NULL, &n);
2339 if (err != CL_SUCCESS) {
2340 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2343 vector<cl_device_id> ids(n);
2344 err = clCreateSubDevices(object_, properties, n, ids.data(), NULL);
2345 if (err != CL_SUCCESS) {
2346 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2352 devices->resize(ids.size());
2356 for (size_type i = 0; i < ids.size(); i++) {
2359 (*devices)[i] =
Device(ids[i],
false);
2365 #elif defined(CL_HPP_USE_CL_DEVICE_FISSION)
2371 const cl_device_partition_property_ext * properties,
2372 vector<Device>* devices)
2374 typedef CL_API_ENTRY cl_int
2375 ( CL_API_CALL * PFN_clCreateSubDevicesEXT)(
2377 const cl_device_partition_property_ext * ,
2380 cl_uint * ) CL_API_SUFFIX__VERSION_1_1;
2382 static PFN_clCreateSubDevicesEXT pfn_clCreateSubDevicesEXT = NULL;
2383 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateSubDevicesEXT);
2386 cl_int err = pfn_clCreateSubDevicesEXT(object_, properties, 0, NULL, &n);
2387 if (err != CL_SUCCESS) {
2388 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2391 vector<cl_device_id> ids(n);
2392 err = pfn_clCreateSubDevicesEXT(object_, properties, n, ids.data(), NULL);
2393 if (err != CL_SUCCESS) {
2394 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2399 devices->resize(ids.size());
2403 for (size_type i = 0; i < ids.size(); i++) {
2406 (*devices)[i] =
Device(ids[i],
false);
2414 CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Device::default_initialized_;
2415 CL_HPP_DEFINE_STATIC_MEMBER_ Device Device::default_;
2416 CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Device::default_error_ = CL_SUCCESS;
2428 static std::once_flag default_initialized_;
2430 static cl_int default_error_;
2437 static void makeDefault() {
2441 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
2449 cl_int err = ::clGetPlatformIDs(0, NULL, &n);
2450 if (err != CL_SUCCESS) {
2451 default_error_ = err;
2455 default_error_ = CL_INVALID_PLATFORM;
2459 vector<cl_platform_id> ids(n);
2460 err = ::clGetPlatformIDs(n, ids.data(), NULL);
2461 if (err != CL_SUCCESS) {
2462 default_error_ = err;
2468 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
2469 catch (cl::Error &e) {
2470 default_error_ = e.err();
2480 static void makeDefaultProvided(
const Platform &p) {
2485 #ifdef CL_HPP_UNIT_TEST_ENABLE
2492 static void unitTestClearDefault() {
2507 explicit Platform(
const cl_platform_id &platform,
bool retainObject =
false) :
2508 detail::Wrapper<cl_type>(platform, retainObject) { }
2521 cl_int *errResult = NULL)
2523 std::call_once(default_initialized_, makeDefault);
2524 detail::errHandler(default_error_);
2525 if (errResult != NULL) {
2526 *errResult = default_error_;
2540 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_platform));
2541 detail::errHandler(default_error_);
2546 template <
typename T>
2547 cl_int
getInfo(cl_platform_info name, T* param)
const
2549 return detail::errHandler(
2550 detail::getInfo(&::clGetPlatformInfo, object_, name, param),
2551 __GET_PLATFORM_INFO_ERR);
2555 template <cl_platform_info name>
typename
2560 detail::cl_platform_info, name>::param_type param;
2561 cl_int result =
getInfo(name, ¶m);
2573 cl_device_type type,
2574 vector<Device>* devices)
const
2577 if( devices == NULL ) {
2578 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR);
2580 cl_int err = ::clGetDeviceIDs(object_, type, 0, NULL, &n);
2581 if (err != CL_SUCCESS && err != CL_DEVICE_NOT_FOUND) {
2582 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2585 vector<cl_device_id> ids(n);
2587 err = ::clGetDeviceIDs(object_, type, n, ids.data(), NULL);
2588 if (err != CL_SUCCESS) {
2589 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2598 devices->resize(ids.size());
2602 for (size_type i = 0; i < ids.size(); i++) {
2603 (*devices)[i] =
Device(ids[i],
true);
2609 #if defined(CL_HPP_USE_DX_INTEROP)
2634 cl_d3d10_device_source_khr d3d_device_source,
2636 cl_d3d10_device_set_khr d3d_device_set,
2637 vector<Device>* devices)
const
2639 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clGetDeviceIDsFromD3D10KHR)(
2640 cl_platform_id platform,
2641 cl_d3d10_device_source_khr d3d_device_source,
2643 cl_d3d10_device_set_khr d3d_device_set,
2644 cl_uint num_entries,
2645 cl_device_id * devices,
2646 cl_uint* num_devices);
2648 if( devices == NULL ) {
2649 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR);
2652 static PFN_clGetDeviceIDsFromD3D10KHR pfn_clGetDeviceIDsFromD3D10KHR = NULL;
2653 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(object_, clGetDeviceIDsFromD3D10KHR);
2656 cl_int err = pfn_clGetDeviceIDsFromD3D10KHR(
2664 if (err != CL_SUCCESS) {
2665 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2668 vector<cl_device_id> ids(n);
2669 err = pfn_clGetDeviceIDsFromD3D10KHR(
2677 if (err != CL_SUCCESS) {
2678 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2686 devices->resize(ids.size());
2690 for (size_type i = 0; i < ids.size(); i++) {
2691 (*devices)[i] = Device(ids[i],
true);
2703 vector<Platform>* platforms)
2707 if( platforms == NULL ) {
2708 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_PLATFORM_IDS_ERR);
2711 cl_int err = ::clGetPlatformIDs(0, NULL, &n);
2712 if (err != CL_SUCCESS) {
2713 return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
2716 vector<cl_platform_id> ids(n);
2717 err = ::clGetPlatformIDs(n, ids.data(), NULL);
2718 if (err != CL_SUCCESS) {
2719 return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
2723 platforms->resize(ids.size());
2726 for (size_type i = 0; i < ids.size(); i++) {
2727 (*platforms)[i] =
Platform(ids[i]);
2741 Platform default_platform = Platform::getDefault(&err);
2743 *platform = default_platform;
2757 cl_int * errResult = NULL)
2760 Platform default_platform = Platform::getDefault(&err);
2764 return default_platform;
2767 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
2772 return ::clUnloadPlatformCompiler(object_);
2777 CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Platform::default_initialized_;
2778 CL_HPP_DEFINE_STATIC_MEMBER_ Platform Platform::default_;
2779 CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Platform::default_error_ = CL_SUCCESS;
2785 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
2790 inline CL_API_PREFIX__VERSION_1_1_DEPRECATED cl_int
2795 return ::clUnloadCompiler();
2811 static std::once_flag default_initialized_;
2813 static cl_int default_error_;
2820 static void makeDefault() {
2824 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
2828 #if !defined(__APPLE__) && !defined(__MACOS)
2829 const Platform &p = Platform::getDefault();
2830 cl_platform_id defaultPlatform = p();
2831 cl_context_properties properties[3] = {
2832 CL_CONTEXT_PLATFORM, (cl_context_properties)defaultPlatform, 0
2835 cl_context_properties *properties =
nullptr;
2839 CL_DEVICE_TYPE_DEFAULT,
2845 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
2846 catch (cl::Error &e) {
2847 default_error_ = e.err();
2858 static void makeDefaultProvided(
const Context &c) {
2863 #ifdef CL_HPP_UNIT_TEST_ENABLE
2870 static void unitTestClearDefault() {
2880 const vector<Device>& devices,
2881 const cl_context_properties* properties = NULL,
2882 void (CL_CALLBACK * notifyFptr)(
2892 size_type numDevices = devices.size();
2893 vector<cl_device_id> deviceIDs(numDevices);
2895 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
2896 deviceIDs[deviceIndex] = (devices[deviceIndex])();
2899 object_ = ::clCreateContext(
2900 properties, (cl_uint) numDevices,
2902 notifyFptr, data, &error);
2904 detail::errHandler(error, __CREATE_CONTEXT_ERR);
2916 const cl_context_properties* properties = NULL,
2917 void (CL_CALLBACK * notifyFptr)(
2927 cl_device_id deviceID = device();
2929 object_ = ::clCreateContext(
2932 notifyFptr, data, &error);
2934 detail::errHandler(error, __CREATE_CONTEXT_ERR);
2945 cl_device_type type,
2946 const cl_context_properties* properties = NULL,
2947 void (CL_CALLBACK * notifyFptr)(
2957 #if !defined(__APPLE__) && !defined(__MACOS)
2958 cl_context_properties prop[4] = {CL_CONTEXT_PLATFORM, 0, 0, 0 };
2960 if (properties == NULL) {
2962 vector<Platform> platforms;
2963 error = Platform::get(&platforms);
2964 if (error != CL_SUCCESS) {
2965 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
2973 cl_context_properties platform_id = 0;
2974 for (
unsigned int i = 0; i < platforms.size(); i++) {
2976 vector<Device> devices;
2978 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
2982 error = platforms[i].getDevices(type, &devices);
2984 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
2985 }
catch (cl::Error& e) {
2993 if (error != CL_SUCCESS && error != CL_DEVICE_NOT_FOUND) {
2994 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
3000 if (devices.size() > 0) {
3001 platform_id = (cl_context_properties)platforms[i]();
3006 if (platform_id == 0) {
3007 detail::errHandler(CL_DEVICE_NOT_FOUND, __CREATE_CONTEXT_FROM_TYPE_ERR);
3009 *err = CL_DEVICE_NOT_FOUND;
3014 prop[1] = platform_id;
3015 properties = &prop[0];
3018 object_ = ::clCreateContextFromType(
3019 properties, type, notifyFptr, data, &error);
3021 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
3062 std::call_once(default_initialized_, makeDefault);
3063 detail::errHandler(default_error_);
3065 *err = default_error_;
3079 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_context));
3080 detail::errHandler(default_error_);
3092 explicit Context(
const cl_context& context,
bool retainObject =
false) :
3093 detail::Wrapper<cl_type>(context, retainObject) { }
3107 template <
typename T>
3108 cl_int
getInfo(cl_context_info name, T* param)
const
3110 return detail::errHandler(
3111 detail::getInfo(&::clGetContextInfo, object_, name, param),
3112 __GET_CONTEXT_INFO_ERR);
3116 template <cl_context_info name>
typename
3121 detail::cl_context_info, name>::param_type param;
3122 cl_int result =
getInfo(name, ¶m);
3135 cl_mem_object_type type,
3136 vector<ImageFormat>* formats)
const
3144 cl_int err = ::clGetSupportedImageFormats(
3151 if (err != CL_SUCCESS) {
3152 return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
3155 if (numEntries > 0) {
3156 vector<ImageFormat> value(numEntries);
3157 err = ::clGetSupportedImageFormats(
3162 (cl_image_format*)value.data(),
3164 if (err != CL_SUCCESS) {
3165 return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
3168 formats->assign(begin(value), end(value));
3179 inline void Device::makeDefault()
3184 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
3191 detail::errHandler(error, __CREATE_CONTEXT_ERR);
3193 if (error != CL_SUCCESS) {
3194 default_error_ = error;
3197 default_ = context.
getInfo<CL_CONTEXT_DEVICES>()[0];
3198 default_error_ = CL_SUCCESS;
3201 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
3202 catch (cl::Error &e) {
3203 default_error_ = e.err();
3208 CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Context::default_initialized_;
3209 CL_HPP_DEFINE_STATIC_MEMBER_ Context Context::default_;
3210 CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Context::default_error_ = CL_SUCCESS;
3224 Event() : detail::Wrapper<cl_type>() { }
3234 explicit Event(
const cl_event& event,
bool retainObject =
false) :
3235 detail::Wrapper<cl_type>(event, retainObject) { }
3249 template <
typename T>
3250 cl_int
getInfo(cl_event_info name, T* param)
const
3252 return detail::errHandler(
3253 detail::getInfo(&::clGetEventInfo, object_, name, param),
3254 __GET_EVENT_INFO_ERR);
3258 template <cl_event_info name>
typename
3263 detail::cl_event_info, name>::param_type param;
3264 cl_int result =
getInfo(name, ¶m);
3272 template <
typename T>
3275 return detail::errHandler(detail::getInfo(
3276 &::clGetEventProfilingInfo, object_, name, param),
3277 __GET_EVENT_PROFILE_INFO_ERR);
3281 template <cl_profiling_info name>
typename
3286 detail::cl_profiling_info, name>::param_type param;
3300 return detail::errHandler(
3301 ::clWaitForEvents(1, &object_),
3302 __WAIT_FOR_EVENTS_ERR);
3305 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
3312 void (CL_CALLBACK * pfn_notify)(cl_event, cl_int,
void *),
3313 void * user_data = NULL)
3315 return detail::errHandler(
3316 ::clSetEventCallback(
3321 __SET_EVENT_CALLBACK_ERR);
3332 return detail::errHandler(
3334 (cl_uint) events.size(), (events.size() > 0) ? (cl_event*)&events.front() : NULL),
3335 __WAIT_FOR_EVENTS_ERR);
3339 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
3353 cl_int * err = NULL)
3356 object_ = ::clCreateUserEvent(
3360 detail::errHandler(error, __CREATE_USER_EVENT_ERR);
3375 return detail::errHandler(
3376 ::clSetUserEventStatus(object_,status),
3377 __SET_USER_EVENT_STATUS_ERR);
3386 inline static cl_int
3387 WaitForEvents(
const vector<Event>& events)
3389 return detail::errHandler(
3391 (cl_uint) events.size(), (events.size() > 0) ? (cl_event*)&events.front() : NULL),
3392 __WAIT_FOR_EVENTS_ERR);
3420 explicit Memory(
const cl_mem& memory,
bool retainObject) :
3421 detail::Wrapper<cl_type>(memory, retainObject) { }
3464 template <
typename T>
3467 return detail::errHandler(
3468 detail::getInfo(&::clGetMemObjectInfo, object_, name, param),
3469 __GET_MEM_OBJECT_INFO_ERR);
3473 template <cl_mem_info name>
typename
3478 detail::cl_mem_info, name>::param_type param;
3479 cl_int result =
getInfo(name, ¶m);
3486 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
3501 void (CL_CALLBACK * pfn_notify)(cl_mem,
void *),
3502 void * user_data = NULL)
3504 return detail::errHandler(
3505 ::clSetMemObjectDestructorCallback(
3509 __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR);
3517 template<
typename IteratorType >
3518 cl_int
copy( IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer );
3519 template<
typename IteratorType >
3520 cl_int
copy(
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator );
3521 template<
typename IteratorType >
3522 cl_int
copy(
const CommandQueue &queue, IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer );
3523 template<
typename IteratorType >
3524 cl_int
copy(
const CommandQueue &queue,
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator );
3527 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
3533 static cl_svm_mem_flags getSVMMemFlags()
3540 template<
class Trait = detail::SVMTraitNull>
3544 static cl_svm_mem_flags getSVMMemFlags()
3546 return CL_MEM_READ_WRITE |
3547 Trait::getSVMMemFlags();
3551 template<
class Trait = detail::SVMTraitNull>
3555 static cl_svm_mem_flags getSVMMemFlags()
3557 return CL_MEM_READ_ONLY |
3558 Trait::getSVMMemFlags();
3562 template<
class Trait = detail::SVMTraitNull>
3566 static cl_svm_mem_flags getSVMMemFlags()
3568 return CL_MEM_WRITE_ONLY |
3569 Trait::getSVMMemFlags();
3573 template<
class Trait = SVMTraitReadWrite<>>
3577 static cl_svm_mem_flags getSVMMemFlags()
3579 return Trait::getSVMMemFlags();
3583 template<
class Trait = SVMTraitReadWrite<>>
3587 static cl_svm_mem_flags getSVMMemFlags()
3589 return CL_MEM_SVM_FINE_GRAIN_BUFFER |
3590 Trait::getSVMMemFlags();
3594 template<
class Trait = SVMTraitReadWrite<>>
3598 static cl_svm_mem_flags getSVMMemFlags()
3601 CL_MEM_SVM_FINE_GRAIN_BUFFER |
3602 CL_MEM_SVM_ATOMICS |
3603 Trait::getSVMMemFlags();
3608 template<
typename T>
3614 const vector<Event>* events = NULL,
3615 Event* event = NULL);
3628 template<
typename T,
class SVMTrait>
3634 typedef T value_type;
3635 typedef value_type* pointer;
3636 typedef const value_type* const_pointer;
3637 typedef value_type& reference;
3638 typedef const value_type& const_reference;
3639 typedef std::size_t size_type;
3640 typedef std::ptrdiff_t difference_type;
3642 template<
typename U>
3648 template<
typename U,
typename V>
3652 context_(
Context::getDefault())
3662 SVMAllocator(
const SVMAllocator &other) :
3663 context_(other.context_)
3667 template<
typename U>
3668 SVMAllocator(
const SVMAllocator<U, SVMTrait> &other) :
3669 context_(other.context_)
3677 pointer address(reference r) CL_HPP_NOEXCEPT_
3679 return std::addressof(r);
3682 const_pointer address(const_reference r) CL_HPP_NOEXCEPT_
3684 return std::addressof(r);
3701 SVMTrait::getSVMMemFlags(),
3704 pointer retValue =
reinterpret_cast<pointer
>(
3706 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
3708 std::bad_alloc excep;
3714 if (!(SVMTrait::getSVMMemFlags() & CL_MEM_SVM_FINE_GRAIN_BUFFER)) {
3715 cl_int err =
enqueueMapSVM(retValue, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE, size*
sizeof(T));
3716 if (err != CL_SUCCESS) {
3717 std::bad_alloc excep;
3726 void deallocate(pointer p, size_type)
3728 clSVMFree(context_(), p);
3737 size_type maxSize = std::numeric_limits<size_type>::max() /
sizeof(T);
3739 for (
const Device &d : context_.
getInfo<CL_CONTEXT_DEVICES>()) {
3742 static_cast<size_type
>(d.getInfo<CL_DEVICE_MAX_MEM_ALLOC_SIZE>()));
3748 template<
class U,
class... Args >
3749 void construct(U* p, Args&&... args)
3765 return (context_==rhs.context_);
3775 template<
class SVMTrait>
3778 typedef void value_type;
3779 typedef value_type* pointer;
3780 typedef const value_type* const_pointer;
3782 template<
typename U>
3788 template<
typename U,
typename V>
3792 #if !defined(CL_HPP_NO_STD_UNIQUE_PTR)
3795 template<
class Alloc>
3802 typedef typename std::allocator_traits<Alloc>::pointer pointer;
3804 Deleter(
const Alloc &alloc, size_type copies) : alloc_{ alloc }, copies_{ copies }
3808 void operator()(pointer ptr)
const {
3809 Alloc tmpAlloc{ alloc_ };
3810 std::allocator_traits<Alloc>::destroy(tmpAlloc, std::addressof(*ptr));
3811 std::allocator_traits<Alloc>::deallocate(tmpAlloc, ptr, copies_);
3822 template <
class T,
class Alloc,
class... Args>
3825 Alloc alloc(alloc_);
3826 static const size_type copies = 1;
3831 T* tmp = std::allocator_traits<Alloc>::allocate(alloc, copies);
3833 std::bad_alloc excep;
3837 std::allocator_traits<Alloc>::construct(
3839 std::addressof(*tmp),
3840 std::forward<Args>(args)...);
3844 catch (std::bad_alloc& b)
3846 std::allocator_traits<Alloc>::deallocate(alloc, tmp, copies);
3851 template<
class T,
class SVMTrait,
class... Args >
3852 cl::pointer<T, detail::Deleter<SVMAllocator<T, SVMTrait>>> allocate_svm(Args... args)
3854 SVMAllocator<T, SVMTrait> alloc;
3855 return cl::allocate_pointer<T>(alloc, args...);
3858 template<
class T,
class SVMTrait,
class... Args >
3859 cl::pointer<T, detail::Deleter<SVMAllocator<T, SVMTrait>>> allocate_svm(
const cl::Context &c, Args... args)
3861 SVMAllocator<T, SVMTrait> alloc(c);
3862 return cl::allocate_pointer<T>(alloc, args...);
3869 template <
class T >
3875 template <
class T >
3881 template <
class T >
3908 void* host_ptr = NULL,
3912 object_ = ::clCreateBuffer(context(), flags, size, host_ptr, &error);
3914 detail::errHandler(error, __CREATE_BUFFER_ERR);
3932 void* host_ptr = NULL,
3939 object_ = ::clCreateBuffer(context(), flags, size, host_ptr, &error);
3941 detail::errHandler(error, __CREATE_BUFFER_ERR);
3952 template<
typename IteratorType >
3954 IteratorType startIterator,
3955 IteratorType endIterator,
3957 bool useHostPtr =
false,
3960 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
3963 cl_mem_flags flags = 0;
3965 flags |= CL_MEM_READ_ONLY;
3968 flags |= CL_MEM_READ_WRITE;
3971 flags |= CL_MEM_USE_HOST_PTR;
3974 size_type size =
sizeof(DataType)*(endIterator - startIterator);
3979 object_ = ::clCreateBuffer(context(), flags, size,
static_cast<DataType*
>(&*startIterator), &error);
3981 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
3984 detail::errHandler(error, __CREATE_BUFFER_ERR);
3990 error =
cl::copy(startIterator, endIterator, *
this);
3991 detail::errHandler(error, __CREATE_BUFFER_ERR);
4003 template<
typename IteratorType >
4004 Buffer(
const Context &context, IteratorType startIterator, IteratorType endIterator,
4005 bool readOnly,
bool useHostPtr =
false, cl_int* err = NULL);
4011 template<
typename IteratorType >
4012 Buffer(
const CommandQueue &queue, IteratorType startIterator, IteratorType endIterator,
4013 bool readOnly,
bool useHostPtr =
false, cl_int* err = NULL);
4025 explicit Buffer(
const cl_mem& buffer,
bool retainObject =
false) :
4026 Memory(buffer, retainObject) { }
4066 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
4073 cl_buffer_create_type buffer_create_type,
4074 const void * buffer_create_info,
4075 cl_int * err = NULL)
4079 result.object_ = ::clCreateSubBuffer(
4086 detail::errHandler(error, __CREATE_SUBBUFFER_ERR);
4096 #if defined (CL_HPP_USE_DX_INTEROP)
4105 class BufferD3D10 :
public Buffer
4116 const Context& context,
4118 ID3D10Buffer* bufobj,
4119 cl_int * err = NULL) : pfn_clCreateFromD3D10BufferKHR(nullptr)
4121 typedef CL_API_ENTRY cl_mem (CL_API_CALL *PFN_clCreateFromD3D10BufferKHR)(
4122 cl_context context, cl_mem_flags flags, ID3D10Buffer* buffer,
4123 cl_int* errcode_ret);
4124 PFN_clCreateFromD3D10BufferKHR pfn_clCreateFromD3D10BufferKHR;
4125 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
4126 vector<cl_context_properties> props = context.getInfo<CL_CONTEXT_PROPERTIES>();
4127 cl_platform platform = -1;
4128 for(
int i = 0; i < props.size(); ++i ) {
4129 if( props[i] == CL_CONTEXT_PLATFORM ) {
4130 platform = props[i+1];
4133 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCreateFromD3D10BufferKHR);
4134 #elif CL_HPP_TARGET_OPENCL_VERSION >= 110
4135 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateFromD3D10BufferKHR);
4139 object_ = pfn_clCreateFromD3D10BufferKHR(
4145 detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
4152 BufferD3D10() : Buffer() { }
4161 explicit BufferD3D10(
const cl_mem& buffer,
bool retainObject =
false) :
4162 Buffer(buffer, retainObject) { }
4168 BufferD3D10& operator = (
const cl_mem& rhs)
4177 BufferD3D10(
const BufferD3D10& buf) :
4183 BufferD3D10& operator = (
const BufferD3D10 &buf)
4192 BufferD3D10(BufferD3D10&& buf) CL_HPP_NOEXCEPT_ : Buffer(std::move(buf)) {}
4197 BufferD3D10& operator = (BufferD3D10 &&buf)
4225 cl_int * err = NULL)
4228 object_ = ::clCreateFromGLBuffer(
4234 detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
4250 explicit BufferGL(
const cl_mem& buffer,
bool retainObject =
false) :
4251 Buffer(buffer, retainObject) { }
4293 cl_gl_object_type *type,
4294 cl_GLuint * gl_object_name)
4296 return detail::errHandler(
4297 ::clGetGLObjectInfo(object_,type,gl_object_name),
4298 __GET_GL_OBJECT_INFO_ERR);
4322 cl_int * err = NULL)
4325 object_ = ::clCreateFromGLRenderbuffer(
4331 detail::errHandler(error, __CREATE_GL_RENDER_BUFFER_ERR);
4348 Buffer(buffer, retainObject) { }
4390 cl_gl_object_type *type,
4391 cl_GLuint * gl_object_name)
4393 return detail::errHandler(
4394 ::clGetGLObjectInfo(object_,type,gl_object_name),
4395 __GET_GL_OBJECT_INFO_ERR);
4418 explicit Image(
const cl_mem& image,
bool retainObject =
false) :
4419 Memory(image, retainObject) { }
4462 template <
typename T>
4465 return detail::errHandler(
4466 detail::getInfo(&::clGetImageInfo, object_, name, param),
4467 __GET_IMAGE_INFO_ERR);
4471 template <cl_image_info name>
typename
4476 detail::cl_image_info, name>::param_type param;
4485 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
4504 void* host_ptr = NULL,
4509 cl_image_desc desc = {0};
4510 desc.image_type = CL_MEM_OBJECT_IMAGE1D;
4511 desc.image_width = width;
4513 object_ = ::clCreateImage(
4521 detail::errHandler(error, __CREATE_IMAGE_ERR);
4537 explicit Image1D(
const cl_mem& image1D,
bool retainObject =
false) :
4538 Image(image1D, retainObject) { }
4596 cl_image_desc desc = {0};
4597 desc.image_type = CL_MEM_OBJECT_IMAGE1D_BUFFER;
4598 desc.image_width = width;
4599 desc.buffer = buffer();
4601 object_ = ::clCreateImage(
4609 detail::errHandler(error, __CREATE_IMAGE_ERR);
4625 Image(image1D, retainObject) { }
4673 size_type arraySize,
4676 void* host_ptr = NULL,
4681 cl_image_desc desc = {0};
4682 desc.image_type = CL_MEM_OBJECT_IMAGE1D_ARRAY;
4683 desc.image_width = width;
4684 desc.image_array_size = arraySize;
4685 desc.image_row_pitch = rowPitch;
4687 object_ = ::clCreateImage(
4695 detail::errHandler(error, __CREATE_IMAGE_ERR);
4710 explicit Image1DArray(
const cl_mem& imageArray,
bool retainObject =
false) :
4711 Image(imageArray, retainObject) { }
4771 size_type row_pitch = 0,
4772 void* host_ptr = NULL,
4776 bool useCreateImage;
4778 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
4781 cl_uint version = detail::getContextPlatformVersion(context());
4782 useCreateImage = (version >= 0x10002);
4784 #elif CL_HPP_TARGET_OPENCL_VERSION >= 120
4785 useCreateImage =
true;
4787 useCreateImage =
false;
4790 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
4793 cl_image_desc desc = {0};
4794 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
4795 desc.image_width = width;
4796 desc.image_height = height;
4797 desc.image_row_pitch = row_pitch;
4799 object_ = ::clCreateImage(
4807 detail::errHandler(error, __CREATE_IMAGE_ERR);
4813 #if CL_HPP_MINIMUM_OPENCL_VERSION < 120
4814 if (!useCreateImage)
4816 object_ = ::clCreateImage2D(
4817 context(), flags,&format, width, height, row_pitch, host_ptr, &error);
4819 detail::errHandler(error, __CREATE_IMAGE2D_ERR);
4827 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 || defined(CL_HPP_USE_CL_IMAGE2D_FROM_BUFFER_KHR)
4836 const Buffer &sourceBuffer,
4839 size_type row_pitch = 0,
4840 cl_int* err =
nullptr)
4844 cl_image_desc desc = {0};
4845 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
4846 desc.image_width = width;
4847 desc.image_height = height;
4848 desc.image_row_pitch = row_pitch;
4849 desc.buffer = sourceBuffer();
4851 object_ = ::clCreateImage(
4859 detail::errHandler(error, __CREATE_IMAGE_ERR);
4860 if (err !=
nullptr) {
4866 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
4881 cl_channel_order order,
4882 const Image &sourceImage,
4883 cl_int* err =
nullptr)
4888 size_type sourceWidth =
4890 size_type sourceHeight =
4892 size_type sourceRowPitch =
4894 cl_uint sourceNumMIPLevels =
4896 cl_uint sourceNumSamples =
4898 cl_image_format sourceFormat =
4903 sourceFormat.image_channel_order = order;
4905 cl_image_desc desc = {0};
4906 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
4907 desc.image_width = sourceWidth;
4908 desc.image_height = sourceHeight;
4909 desc.image_row_pitch = sourceRowPitch;
4910 desc.num_mip_levels = sourceNumMIPLevels;
4911 desc.num_samples = sourceNumSamples;
4912 desc.buffer = sourceImage();
4914 object_ = ::clCreateImage(
4922 detail::errHandler(error, __CREATE_IMAGE_ERR);
4923 if (err !=
nullptr) {
4939 explicit Image2D(
const cl_mem& image2D,
bool retainObject =
false) :
4940 Image(image2D, retainObject) { }
4983 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
5007 cl_int * err = NULL)
5010 object_ = ::clCreateFromGLTexture2D(
5018 detail::errHandler(error, __CREATE_GL_TEXTURE_2D_ERR);
5035 explicit Image2DGL(
const cl_mem& image,
bool retainObject =
false) :
5036 Image2D(image, retainObject) { }
5076 } CL_API_SUFFIX__VERSION_1_1_DEPRECATED;
5079 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
5090 size_type arraySize,
5094 size_type slicePitch,
5095 void* host_ptr = NULL,
5100 cl_image_desc desc = {0};
5101 desc.image_type = CL_MEM_OBJECT_IMAGE2D_ARRAY;
5102 desc.image_width = width;
5103 desc.image_height = height;
5104 desc.image_array_size = arraySize;
5105 desc.image_row_pitch = rowPitch;
5106 desc.image_slice_pitch = slicePitch;
5108 object_ = ::clCreateImage(
5116 detail::errHandler(error, __CREATE_IMAGE_ERR);
5131 explicit Image2DArray(
const cl_mem& imageArray,
bool retainObject =
false) :
Image(imageArray, retainObject) { }
5189 size_type row_pitch = 0,
5190 size_type slice_pitch = 0,
5191 void* host_ptr = NULL,
5195 bool useCreateImage;
5197 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
5200 cl_uint version = detail::getContextPlatformVersion(context());
5201 useCreateImage = (version >= 0x10002);
5203 #elif CL_HPP_TARGET_OPENCL_VERSION >= 120
5204 useCreateImage =
true;
5206 useCreateImage =
false;
5209 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
5212 cl_image_desc desc = {0};
5213 desc.image_type = CL_MEM_OBJECT_IMAGE3D;
5214 desc.image_width = width;
5215 desc.image_height = height;
5216 desc.image_depth = depth;
5217 desc.image_row_pitch = row_pitch;
5218 desc.image_slice_pitch = slice_pitch;
5220 object_ = ::clCreateImage(
5228 detail::errHandler(error, __CREATE_IMAGE_ERR);
5234 #if CL_HPP_MINIMUM_OPENCL_VERSION < 120
5235 if (!useCreateImage)
5237 object_ = ::clCreateImage3D(
5238 context(), flags, &format, width, height, depth, row_pitch,
5239 slice_pitch, host_ptr, &error);
5241 detail::errHandler(error, __CREATE_IMAGE3D_ERR);
5259 explicit Image3D(
const cl_mem& image3D,
bool retainObject =
false) :
5260 Image(image3D, retainObject) { }
5301 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
5324 cl_int * err = NULL)
5327 object_ = ::clCreateFromGLTexture3D(
5335 detail::errHandler(error, __CREATE_GL_TEXTURE_3D_ERR);
5351 explicit Image3DGL(
const cl_mem& image,
bool retainObject =
false) :
5352 Image3D(image, retainObject) { }
5394 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
5410 cl_int * err = NULL)
5413 object_ = ::clCreateFromGLTexture(
5421 detail::errHandler(error, __CREATE_GL_TEXTURE_ERR);
5436 explicit ImageGL(
const cl_mem& image,
bool retainObject =
false) :
5437 Image(image, retainObject) { }
5439 ImageGL& operator = (
const cl_mem& rhs)
5477 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
5499 cl_uint packet_size,
5500 cl_uint max_packets,
5505 cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS;
5506 object_ = ::clCreatePipe(context(), flags, packet_size, max_packets,
nullptr, &error);
5508 detail::errHandler(error, __CREATE_PIPE_ERR);
5523 cl_uint packet_size,
5524 cl_uint max_packets,
5531 cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS;
5532 object_ = ::clCreatePipe(context(), flags, packet_size, max_packets,
nullptr, &error);
5534 detail::errHandler(error, __CREATE_PIPE_ERR);
5550 explicit Pipe(
const cl_mem& pipe,
bool retainObject =
false) :
5551 Memory(pipe, retainObject) { }
5592 template <
typename T>
5595 return detail::errHandler(
5596 detail::getInfo(&::clGetPipeInfo, object_, name, param),
5597 __GET_PIPE_INFO_ERR);
5601 template <cl_pipe_info name>
typename
5606 detail::cl_pipe_info, name>::param_type param;
5607 cl_int result =
getInfo(name, ¶m);
5637 cl_bool normalized_coords,
5638 cl_addressing_mode addressing_mode,
5639 cl_filter_mode filter_mode,
5644 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
5645 cl_sampler_properties sampler_properties[] = {
5646 CL_SAMPLER_NORMALIZED_COORDS, normalized_coords,
5647 CL_SAMPLER_ADDRESSING_MODE, addressing_mode,
5648 CL_SAMPLER_FILTER_MODE, filter_mode,
5650 object_ = ::clCreateSamplerWithProperties(
5655 detail::errHandler(error, __CREATE_SAMPLER_WITH_PROPERTIES_ERR);
5660 object_ = ::clCreateSampler(
5667 detail::errHandler(error, __CREATE_SAMPLER_ERR);
5682 explicit Sampler(
const cl_sampler& sampler,
bool retainObject =
false) :
5683 detail::Wrapper<cl_type>(sampler, retainObject) { }
5725 template <
typename T>
5726 cl_int
getInfo(cl_sampler_info name, T* param)
const
5728 return detail::errHandler(
5729 detail::getInfo(&::clGetSamplerInfo, object_, name, param),
5730 __GET_SAMPLER_INFO_ERR);
5734 template <cl_sampler_info name>
typename
5739 detail::cl_sampler_info, name>::param_type param;
5740 cl_int result =
getInfo(name, ¶m);
5750 class DeviceCommandQueue;
5757 size_type sizes_[3];
5758 cl_uint dimensions_;
5789 NDRange(size_type size0, size_type size1, size_type size2)
5801 operator const size_type*()
const {
5815 return dimensions_*
sizeof(size_type);
5823 const size_type* get()
const
5830 static const NDRange NullRange;
5840 template <
typename T,
class Enable =
void>
5845 template <
typename T>
5848 static size_type size(
const T&) {
return sizeof(T); }
5849 static const T* ptr(
const T& value) {
return &value; }
5854 template <
typename T>
5857 static size_type size(
const T&) {
return sizeof(cl_mem); }
5858 static const cl_mem* ptr(
const T& value) {
return &(value()); }
5866 static size_type size(
const LocalSpaceArg& value) {
return value.size_; }
5867 static const void* ptr(
const LocalSpaceArg&) {
return NULL; }
5894 inline Kernel(
const Program& program,
const char* name, cl_int* err = NULL);
5907 explicit Kernel(
const cl_kernel& kernel,
bool retainObject =
false) :
5908 detail::Wrapper<cl_type>(kernel, retainObject) { }
5949 template <
typename T>
5950 cl_int getInfo(cl_kernel_info name, T* param)
const
5952 return detail::errHandler(
5953 detail::getInfo(&::clGetKernelInfo, object_, name, param),
5954 __GET_KERNEL_INFO_ERR);
5957 template <cl_kernel_info name>
typename
5958 detail::param_traits<detail::cl_kernel_info, name>::param_type
5959 getInfo(cl_int* err = NULL)
const
5961 typename detail::param_traits<
5962 detail::cl_kernel_info, name>::param_type param;
5963 cl_int result = getInfo(name, ¶m);
5970 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
5971 template <
typename T>
5972 cl_int getArgInfo(cl_uint argIndex, cl_kernel_arg_info name, T* param)
const
5974 return detail::errHandler(
5975 detail::getInfo(&::clGetKernelArgInfo, object_, argIndex, name, param),
5976 __GET_KERNEL_ARG_INFO_ERR);
5979 template <cl_kernel_arg_info name>
typename
5980 detail::param_traits<detail::cl_kernel_arg_info, name>::param_type
5981 getArgInfo(cl_uint argIndex, cl_int* err = NULL)
const
5983 typename detail::param_traits<
5984 detail::cl_kernel_arg_info, name>::param_type param;
5985 cl_int result = getArgInfo(argIndex, name, ¶m);
5993 template <
typename T>
5994 cl_int getWorkGroupInfo(
5995 const Device& device, cl_kernel_work_group_info name, T* param)
const
5997 return detail::errHandler(
5999 &::clGetKernelWorkGroupInfo, object_, device(), name, param),
6000 __GET_KERNEL_WORK_GROUP_INFO_ERR);
6003 template <cl_kernel_work_group_info name>
typename
6004 detail::param_traits<detail::cl_kernel_work_group_info, name>::param_type
6005 getWorkGroupInfo(
const Device& device, cl_int* err = NULL)
const
6007 typename detail::param_traits<
6008 detail::cl_kernel_work_group_info, name>::param_type param;
6009 cl_int result = getWorkGroupInfo(device, name, ¶m);
6016 #if (CL_HPP_TARGET_OPENCL_VERSION >= 200 && defined(CL_HPP_USE_CL_SUB_GROUPS_KHR)) || CL_HPP_TARGET_OPENCL_VERSION >= 210
6017 cl_int getSubGroupInfo(
const cl::Device &dev, cl_kernel_sub_group_info name,
const cl::NDRange &range, size_type* param)
const
6019 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
6021 return detail::errHandler(
6022 clGetKernelSubGroupInfo(object_, dev(), name, range.
size(), range.get(),
sizeof(size_type), param,
nullptr),
6023 __GET_KERNEL_SUB_GROUP_INFO_ERR);
6027 typedef clGetKernelSubGroupInfoKHR_fn PFN_clGetKernelSubGroupInfoKHR;
6028 static PFN_clGetKernelSubGroupInfoKHR pfn_clGetKernelSubGroupInfoKHR = NULL;
6029 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetKernelSubGroupInfoKHR);
6031 return detail::errHandler(
6032 pfn_clGetKernelSubGroupInfoKHR(object_, dev(), name, range.
size(), range.get(),
sizeof(size_type), param,
nullptr),
6033 __GET_KERNEL_SUB_GROUP_INFO_ERR);
6038 template <cl_kernel_sub_group_info name>
6039 size_type getSubGroupInfo(
const cl::Device &dev,
const cl::NDRange &range, cl_int* err = NULL)
const
6042 cl_int result = getSubGroupInfo(dev, name, range, ¶m);
6050 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
6053 template<
typename T,
class D>
6054 cl_int
setArg(cl_uint index,
const cl::pointer<T, D> &argPtr)
6056 return detail::errHandler(
6057 ::clSetKernelArgSVMPointer(object_, index, argPtr.get()),
6058 __SET_KERNEL_ARGS_ERR);
6063 template<
typename T,
class Alloc>
6064 cl_int
setArg(cl_uint index,
const cl::vector<T, Alloc> &argPtr)
6066 return detail::errHandler(
6067 ::clSetKernelArgSVMPointer(object_, index, argPtr.data()),
6068 __SET_KERNEL_ARGS_ERR);
6073 template<
typename T>
6074 typename std::enable_if<std::is_pointer<T>::value, cl_int>::type
6077 return detail::errHandler(
6078 ::clSetKernelArgSVMPointer(object_, index, argPtr),
6079 __SET_KERNEL_ARGS_ERR);
6085 template <
typename T>
6086 typename std::enable_if<!std::is_pointer<T>::value, cl_int>::type
6089 return detail::errHandler(
6095 __SET_KERNEL_ARGS_ERR);
6098 cl_int
setArg(cl_uint index, size_type size,
const void* argPtr)
6100 return detail::errHandler(
6101 ::clSetKernelArg(object_, index, size, argPtr),
6102 __SET_KERNEL_ARGS_ERR);
6105 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
6112 return detail::errHandler(
6113 ::clSetKernelExecInfo(
6115 CL_KERNEL_EXEC_INFO_SVM_PTRS,
6116 sizeof(
void*)*pointerList.size(),
6117 pointerList.data()));
6124 template<
int ArrayLength>
6127 return detail::errHandler(
6128 ::clSetKernelExecInfo(
6130 CL_KERNEL_EXEC_INFO_SVM_PTRS,
6131 sizeof(
void*)*pointerList.size(),
6132 pointerList.data()));
6148 cl_bool svmEnabled_ = svmEnabled ? CL_TRUE : CL_FALSE;
6149 return detail::errHandler(
6150 ::clSetKernelExecInfo(
6152 CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM,
6159 template<
int index,
int ArrayLength,
class D,
typename T0,
typename T1,
typename... Ts>
6160 void setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList,
const pointer<T0, D> &t0,
const pointer<T1, D> &t1, Ts & ... ts)
6162 pointerList[index] =
static_cast<void*
>(t0.get());
6163 setSVMPointersHelper<index + 1, ArrayLength>(pointerList, t1, ts...);
6166 template<
int index,
int ArrayLength,
typename T0,
typename T1,
typename... Ts>
6167 typename std::enable_if<std::is_pointer<T0>::value,
void>::type
6168 setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList, T0 t0, T1 t1, Ts... ts)
6170 pointerList[index] =
static_cast<void*
>(t0);
6171 setSVMPointersHelper<index + 1, ArrayLength>(pointerList, t1, ts...);
6174 template<
int index,
int ArrayLength,
typename T0,
class D>
6175 void setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList,
const pointer<T0, D> &t0)
6177 pointerList[index] =
static_cast<void*
>(t0.get());
6181 template<
int index,
int ArrayLength,
typename T0>
6182 typename std::enable_if<std::is_pointer<T0>::value,
void>::type
6183 setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList, T0 t0)
6185 pointerList[index] =
static_cast<void*
>(t0);
6188 template<
typename T0,
typename... Ts>
6191 std::array<
void*, 1 +
sizeof...(Ts)> pointerList;
6193 setSVMPointersHelper<0, 1 +
sizeof...(Ts)>(pointerList, t0, ts...);
6194 return detail::errHandler(
6195 ::clSetKernelExecInfo(
6197 CL_KERNEL_EXEC_INFO_SVM_PTRS,
6198 sizeof(
void*)*(1 +
sizeof...(Ts)),
6199 pointerList.data()));
6202 template<
typename T>
6203 cl_int setExecInfo(cl_kernel_exec_info param_name,
const T& val)
6205 return detail::errHandler(
6206 ::clSetKernelExecInfo(
6213 template<cl_kernel_exec_info name>
6214 cl_int setExecInfo(
typename detail::param_traits<detail::cl_kernel_exec_info, name>::param_type& val)
6216 return setExecInfo(name, val);
6220 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
6229 Kernel retValue(clCloneKernel(this->get(), &error));
6231 detail::errHandler(error, __CLONE_KERNEL_ERR);
6243 #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6244 typedef vector<vector<unsigned char>> Binaries;
6245 typedef vector<string> Sources;
6247 typedef vector<std::pair<const void*, size_type> > Binaries;
6248 typedef vector<std::pair<const char*, size_type> > Sources;
6252 const string& source,
6258 const char * strings = source.c_str();
6259 const size_type length = source.size();
6263 object_ = ::clCreateProgramWithSource(
6264 context(), (cl_uint)1, &strings, &length, &error);
6266 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6268 if (error == CL_SUCCESS && build) {
6270 error = ::clBuildProgram(
6274 #
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6282 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6292 const string& source,
6298 const char * strings = source.c_str();
6299 const size_type length = source.size();
6301 object_ = ::clCreateProgramWithSource(
6302 context(), (cl_uint)1, &strings, &length, &error);
6304 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6306 if (error == CL_SUCCESS && build) {
6307 error = ::clBuildProgram(
6311 #
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6319 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6332 const Sources& sources,
6338 const size_type n = (size_type)sources.size();
6340 vector<size_type> lengths(n);
6341 vector<const char*> strings(n);
6343 for (size_type i = 0; i < n; ++i) {
6344 #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6345 strings[i] = sources[(int)i].data();
6346 lengths[i] = sources[(int)i].length();
6348 strings[i] = sources[(int)i].first;
6349 lengths[i] = sources[(int)i].second;
6353 object_ = ::clCreateProgramWithSource(
6354 context(), (cl_uint)n, strings.data(), lengths.data(), &error);
6356 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6368 const Sources& sources,
6373 const size_type n = (size_type)sources.size();
6375 vector<size_type> lengths(n);
6376 vector<const char*> strings(n);
6378 for (size_type i = 0; i < n; ++i) {
6379 #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6380 strings[i] = sources[(int)i].data();
6381 lengths[i] = sources[(int)i].length();
6383 strings[i] = sources[(int)i].first;
6384 lengths[i] = sources[(int)i].second;
6388 object_ = ::clCreateProgramWithSource(
6389 context(), (cl_uint)n, strings.data(), lengths.data(), &error);
6391 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6398 #if CL_HPP_TARGET_OPENCL_VERSION >= 210 || (CL_HPP_TARGET_OPENCL_VERSION==200 && defined(CL_HPP_USE_IL_KHR))
6404 const vector<char>& IL,
6412 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
6414 object_ = ::clCreateProgramWithIL(
6415 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6419 typedef clCreateProgramWithILKHR_fn PFN_clCreateProgramWithILKHR;
6420 static PFN_clCreateProgramWithILKHR pfn_clCreateProgramWithILKHR = NULL;
6421 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateProgramWithILKHR);
6423 return detail::errHandler(
6424 pfn_clCreateProgramWithILKHR(
6425 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6429 detail::errHandler(error, __CREATE_PROGRAM_WITH_IL_ERR);
6431 if (error == CL_SUCCESS && build) {
6433 error = ::clBuildProgram(
6437 #
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6445 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6460 const vector<char>& IL,
6466 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
6468 object_ = ::clCreateProgramWithIL(
6469 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6473 typedef clCreateProgramWithILKHR_fn PFN_clCreateProgramWithILKHR;
6474 static PFN_clCreateProgramWithILKHR pfn_clCreateProgramWithILKHR = NULL;
6475 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateProgramWithILKHR);
6477 return detail::errHandler(
6478 pfn_clCreateProgramWithILKHR(
6479 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6483 detail::errHandler(error, __CREATE_PROGRAM_WITH_IL_ERR);
6485 if (error == CL_SUCCESS && build) {
6486 error = ::clBuildProgram(
6490 #
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6498 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6528 const vector<Device>& devices,
6529 const Binaries& binaries,
6530 vector<cl_int>* binaryStatus = NULL,
6535 const size_type numDevices = devices.size();
6538 if(binaries.size() != numDevices) {
6539 error = CL_INVALID_VALUE;
6540 detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
6548 vector<size_type> lengths(numDevices);
6549 vector<const unsigned char*> images(numDevices);
6550 #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6551 for (size_type i = 0; i < numDevices; ++i) {
6552 images[i] = binaries[i].data();
6553 lengths[i] = binaries[(int)i].size();
6556 for (size_type i = 0; i < numDevices; ++i) {
6557 images[i] = (
const unsigned char*)binaries[i].first;
6558 lengths[i] = binaries[(int)i].second;
6562 vector<cl_device_id> deviceIDs(numDevices);
6563 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6564 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6568 binaryStatus->resize(numDevices);
6571 object_ = ::clCreateProgramWithBinary(
6572 context(), (cl_uint) devices.size(),
6574 lengths.data(), images.data(), (binaryStatus != NULL && numDevices > 0)
6575 ? &binaryStatus->front()
6578 detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
6585 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
6592 const vector<Device>& devices,
6593 const string& kernelNames,
6599 size_type numDevices = devices.size();
6600 vector<cl_device_id> deviceIDs(numDevices);
6601 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6602 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6605 object_ = ::clCreateProgramWithBuiltInKernels(
6607 (cl_uint) devices.size(),
6609 kernelNames.c_str(),
6612 detail::errHandler(error, __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR);
6628 explicit Program(
const cl_program& program,
bool retainObject =
false) :
6629 detail::Wrapper<cl_type>(program, retainObject) { }
6631 Program& operator = (
const cl_program& rhs)
6666 const vector<Device>& devices,
6667 const char* options = NULL,
6668 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6669 void* data = NULL)
const
6671 size_type numDevices = devices.size();
6672 vector<cl_device_id> deviceIDs(numDevices);
6674 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6675 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6678 cl_int buildError = ::clBuildProgram(
6687 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6691 const Device& device,
6692 const char* options = NULL,
6693 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6694 void* data = NULL)
const
6696 cl_device_id deviceID = device();
6698 cl_int buildError = ::clBuildProgram(
6706 BuildLogType buildLog(1);
6707 buildLog.push_back(std::make_pair(device, getBuildInfo<CL_PROGRAM_BUILD_LOG>(device)));
6708 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, buildLog);
6712 const char* options = NULL,
6713 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6714 void* data = NULL)
const
6716 cl_int buildError = ::clBuildProgram(
6724 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6727 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
6729 const char* options = NULL,
6730 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6731 void* data = NULL)
const
6733 cl_int error = ::clCompileProgram(
6743 return detail::buildErrHandler(error, __COMPILE_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6747 template <
typename T>
6748 cl_int getInfo(cl_program_info name, T* param)
const
6750 return detail::errHandler(
6751 detail::getInfo(&::clGetProgramInfo, object_, name, param),
6752 __GET_PROGRAM_INFO_ERR);
6755 template <cl_program_info name>
typename
6756 detail::param_traits<detail::cl_program_info, name>::param_type
6757 getInfo(cl_int* err = NULL)
const
6759 typename detail::param_traits<
6760 detail::cl_program_info, name>::param_type param;
6761 cl_int result = getInfo(name, ¶m);
6768 template <
typename T>
6769 cl_int getBuildInfo(
6770 const Device& device, cl_program_build_info name, T* param)
const
6772 return detail::errHandler(
6774 &::clGetProgramBuildInfo, object_, device(), name, param),
6775 __GET_PROGRAM_BUILD_INFO_ERR);
6778 template <cl_program_build_info name>
typename
6779 detail::param_traits<detail::cl_program_build_info, name>::param_type
6780 getBuildInfo(
const Device& device, cl_int* err = NULL)
const
6782 typename detail::param_traits<
6783 detail::cl_program_build_info, name>::param_type param;
6784 cl_int result = getBuildInfo(device, name, ¶m);
6796 template <cl_program_build_info name>
6797 vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, name>::param_type>>
6800 cl_int result = CL_SUCCESS;
6802 auto devs = getInfo<CL_PROGRAM_DEVICES>(&result);
6803 vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, name>::param_type>>
6807 if (result != CL_SUCCESS) {
6816 detail::cl_program_build_info, name>::param_type param;
6817 result = getBuildInfo(d, name, ¶m);
6821 if (result != CL_SUCCESS) {
6829 if (result != CL_SUCCESS) {
6835 cl_int createKernels(vector<Kernel>* kernels)
6838 cl_int err = ::clCreateKernelsInProgram(object_, 0, NULL, &numKernels);
6839 if (err != CL_SUCCESS) {
6840 return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
6843 vector<cl_kernel> value(numKernels);
6845 err = ::clCreateKernelsInProgram(
6846 object_, numKernels, value.data(), NULL);
6847 if (err != CL_SUCCESS) {
6848 return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
6852 kernels->resize(value.size());
6856 for (size_type i = 0; i < value.size(); i++) {
6859 (*kernels)[i] = Kernel(value[i],
false);
6865 #if CL_HPP_TARGET_OPENCL_VERSION >= 220
6866 #if defined(CL_USE_DEPRECATED_OPENCL_2_2_APIS)
6878 void (CL_CALLBACK * pfn_notify)(cl_program program,
void * user_data),
6879 void * user_data = NULL) CL_API_SUFFIX__VERSION_2_2_DEPRECATED
6881 return detail::errHandler(
6882 ::clSetProgramReleaseCallback(
6886 __SET_PROGRAM_RELEASE_CALLBACK_ERR);
6894 template <
typename T>
6895 typename std::enable_if<!std::is_pointer<T>::value, cl_int>::type
6898 return detail::errHandler(
6899 ::clSetProgramSpecializationConstant(
6904 __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR);
6913 return detail::errHandler(
6914 ::clSetProgramSpecializationConstant(
6919 __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR);
6924 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
6925 inline Program linkProgram(
6928 const char* options = NULL,
6929 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6933 cl_int error_local = CL_SUCCESS;
6935 cl_program programs[2] = { input1(), input2() };
6937 Context ctx = input1.getInfo<CL_PROGRAM_CONTEXT>(&error_local);
6938 if(error_local!=CL_SUCCESS) {
6939 detail::errHandler(error_local, __LINK_PROGRAM_ERR);
6942 cl_program prog = ::clLinkProgram(
6953 detail::errHandler(error_local,__COMPILE_PROGRAM_ERR);
6958 return Program(prog);
6961 inline Program linkProgram(
6962 vector<Program> inputPrograms,
6963 const char* options = NULL,
6964 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6968 cl_int error_local = CL_SUCCESS;
6970 vector<cl_program> programs(inputPrograms.size());
6972 for (
unsigned int i = 0; i < inputPrograms.size(); i++) {
6973 programs[i] = inputPrograms[i]();
6977 if(inputPrograms.size() > 0) {
6978 ctx = inputPrograms[0].getInfo<CL_PROGRAM_CONTEXT>(&error_local);
6979 if(error_local!=CL_SUCCESS) {
6980 detail::errHandler(error_local, __LINK_PROGRAM_ERR);
6983 cl_program prog = ::clLinkProgram(
6988 (cl_uint)inputPrograms.size(),
6994 detail::errHandler(error_local,__COMPILE_PROGRAM_ERR);
6999 return Program(prog,
false);
7005 inline cl_int cl::Program::getInfo(cl_program_info name, vector<vector<unsigned char>>* param)
const
7007 if (name != CL_PROGRAM_BINARIES) {
7008 return CL_INVALID_VALUE;
7014 vector<size_type> sizes = getInfo<CL_PROGRAM_BINARY_SIZES>();
7015 size_type numBinaries = sizes.size();
7018 param->resize(numBinaries);
7019 for (size_type i = 0; i < numBinaries; ++i) {
7020 (*param)[i].resize(sizes[i]);
7023 return detail::errHandler(
7024 detail::getInfo(&::clGetProgramInfo, object_, name, param),
7025 __GET_PROGRAM_INFO_ERR);
7032 inline vector<vector<unsigned char>> cl::Program::getInfo<CL_PROGRAM_BINARIES>(cl_int* err)
const
7034 vector<vector<unsigned char>> binariesVectors;
7036 cl_int result = getInfo(CL_PROGRAM_BINARIES, &binariesVectors);
7040 return binariesVectors;
7043 #if CL_HPP_TARGET_OPENCL_VERSION >= 220
7048 cl_uchar ucValue = value ? CL_UCHAR_MAX : 0;
7049 return detail::errHandler(
7050 ::clSetProgramSpecializationConstant(
7055 __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR);
7059 inline Kernel::Kernel(
const Program& program,
const char* name, cl_int* err)
7063 object_ = ::clCreateKernel(program(), name, &error);
7064 detail::errHandler(error, __CREATE_KERNEL_ERR);
7072 enum class QueueProperties : cl_command_queue_properties
7075 Profiling = CL_QUEUE_PROFILING_ENABLE,
7076 OutOfOrder = CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE,
7079 inline QueueProperties operator|(QueueProperties lhs, QueueProperties rhs)
7081 return static_cast<QueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) |
static_cast<cl_command_queue_properties
>(rhs));
7090 static std::once_flag default_initialized_;
7092 static cl_int default_error_;
7099 static void makeDefault()
7104 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
7111 if (error != CL_SUCCESS) {
7112 default_error_ = error;
7116 default_ =
CommandQueue(context, device, 0, &default_error_);
7119 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
7120 catch (cl::Error &e) {
7121 default_error_ = e.err();
7131 static void makeDefaultProvided(
const CommandQueue &c) {
7136 #ifdef CL_HPP_UNIT_TEST_ENABLE
7143 static void unitTestClearDefault() {
7154 cl_command_queue_properties properties,
7160 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7162 if (error != CL_SUCCESS) {
7169 bool useWithProperties;
7171 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7174 cl_uint version = detail::getContextPlatformVersion(context());
7175 useWithProperties = (version >= 0x20000);
7177 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7178 useWithProperties =
true;
7180 useWithProperties =
false;
7183 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
7184 if (useWithProperties) {
7185 cl_queue_properties queue_properties[] = {
7186 CL_QUEUE_PROPERTIES, properties, 0 };
7187 if ((properties & CL_QUEUE_ON_DEVICE) == 0) {
7188 object_ = ::clCreateCommandQueueWithProperties(
7189 context(), device(), queue_properties, &error);
7192 error = CL_INVALID_QUEUE_PROPERTIES;
7195 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7201 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7202 if (!useWithProperties) {
7203 object_ = ::clCreateCommandQueue(
7204 context(), device(), properties, &error);
7206 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7220 QueueProperties properties,
7226 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7228 if (error != CL_SUCCESS) {
7235 bool useWithProperties;
7237 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7240 cl_uint version = detail::getContextPlatformVersion(context());
7241 useWithProperties = (version >= 0x20000);
7243 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7244 useWithProperties =
true;
7246 useWithProperties =
false;
7249 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
7250 if (useWithProperties) {
7251 cl_queue_properties queue_properties[] = {
7252 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
7254 object_ = ::clCreateCommandQueueWithProperties(
7255 context(), device(), queue_properties, &error);
7257 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7263 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7264 if (!useWithProperties) {
7265 object_ = ::clCreateCommandQueue(
7266 context(), device(),
static_cast<cl_command_queue_properties
>(properties), &error);
7268 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7284 cl_command_queue_properties properties = 0,
7288 bool useWithProperties;
7289 vector<cl::Device> devices;
7290 error = context.
getInfo(CL_CONTEXT_DEVICES, &devices);
7292 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7294 if (error != CL_SUCCESS)
7302 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7305 cl_uint version = detail::getContextPlatformVersion(context());
7306 useWithProperties = (version >= 0x20000);
7308 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7309 useWithProperties =
true;
7311 useWithProperties =
false;
7314 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
7315 if (useWithProperties) {
7316 cl_queue_properties queue_properties[] = {
7317 CL_QUEUE_PROPERTIES, properties, 0 };
7318 if ((properties & CL_QUEUE_ON_DEVICE) == 0) {
7319 object_ = ::clCreateCommandQueueWithProperties(
7320 context(), devices[0](), queue_properties, &error);
7323 error = CL_INVALID_QUEUE_PROPERTIES;
7326 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7332 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7333 if (!useWithProperties) {
7334 object_ = ::clCreateCommandQueue(
7335 context(), devices[0](), properties, &error);
7337 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7351 QueueProperties properties,
7355 bool useWithProperties;
7356 vector<cl::Device> devices;
7357 error = context.
getInfo(CL_CONTEXT_DEVICES, &devices);
7359 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7361 if (error != CL_SUCCESS)
7369 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7372 cl_uint version = detail::getContextPlatformVersion(context());
7373 useWithProperties = (version >= 0x20000);
7375 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7376 useWithProperties =
true;
7378 useWithProperties =
false;
7381 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
7382 if (useWithProperties) {
7383 cl_queue_properties queue_properties[] = {
7384 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
7385 object_ = ::clCreateCommandQueueWithProperties(
7386 context(), devices[0](), queue_properties, &error);
7388 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7394 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7395 if (!useWithProperties) {
7396 object_ = ::clCreateCommandQueue(
7397 context(), devices[0](),
static_cast<cl_command_queue_properties
>(properties), &error);
7399 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7414 cl_command_queue_properties properties = 0,
7418 bool useWithProperties;
7420 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7423 cl_uint version = detail::getContextPlatformVersion(context());
7424 useWithProperties = (version >= 0x20000);
7426 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7427 useWithProperties =
true;
7429 useWithProperties =
false;
7432 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
7433 if (useWithProperties) {
7434 cl_queue_properties queue_properties[] = {
7435 CL_QUEUE_PROPERTIES, properties, 0 };
7436 object_ = ::clCreateCommandQueueWithProperties(
7437 context(), device(), queue_properties, &error);
7439 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7445 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7446 if (!useWithProperties) {
7447 object_ = ::clCreateCommandQueue(
7448 context(), device(), properties, &error);
7450 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7465 QueueProperties properties,
7469 bool useWithProperties;
7471 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7474 cl_uint version = detail::getContextPlatformVersion(context());
7475 useWithProperties = (version >= 0x20000);
7477 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7478 useWithProperties =
true;
7480 useWithProperties =
false;
7483 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
7484 if (useWithProperties) {
7485 cl_queue_properties queue_properties[] = {
7486 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
7487 object_ = ::clCreateCommandQueueWithProperties(
7488 context(), device(), queue_properties, &error);
7490 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7496 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7497 if (!useWithProperties) {
7498 object_ = ::clCreateCommandQueue(
7499 context(), device(),
static_cast<cl_command_queue_properties
>(properties), &error);
7501 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7511 std::call_once(default_initialized_, makeDefault);
7512 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
7513 detail::errHandler(default_error_, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7515 detail::errHandler(default_error_, __CREATE_COMMAND_QUEUE_ERR);
7518 *err = default_error_;
7532 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_queue));
7533 detail::errHandler(default_error_);
7546 explicit CommandQueue(
const cl_command_queue& commandQueue,
bool retainObject =
false) :
7547 detail::Wrapper<cl_type>(commandQueue, retainObject) { }
7583 template <
typename T>
7584 cl_int getInfo(cl_command_queue_info name, T* param)
const
7586 return detail::errHandler(
7588 &::clGetCommandQueueInfo, object_, name, param),
7589 __GET_COMMAND_QUEUE_INFO_ERR);
7592 template <cl_command_queue_info name>
typename
7593 detail::param_traits<detail::cl_command_queue_info, name>::param_type
7594 getInfo(cl_int* err = NULL)
const
7596 typename detail::param_traits<
7597 detail::cl_command_queue_info, name>::param_type param;
7598 cl_int result = getInfo(name, ¶m);
7605 cl_int enqueueReadBuffer(
7606 const Buffer& buffer,
7611 const vector<Event>* events = NULL,
7612 Event* event = NULL)
const
7615 cl_int err = detail::errHandler(
7616 ::clEnqueueReadBuffer(
7617 object_, buffer(), blocking, offset, size,
7619 (events != NULL) ? (cl_uint) events->size() : 0,
7620 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7621 (event != NULL) ? &tmp : NULL),
7622 __ENQUEUE_READ_BUFFER_ERR);
7624 if (event != NULL && err == CL_SUCCESS)
7630 cl_int enqueueWriteBuffer(
7631 const Buffer& buffer,
7636 const vector<Event>* events = NULL,
7637 Event* event = NULL)
const
7640 cl_int err = detail::errHandler(
7641 ::clEnqueueWriteBuffer(
7642 object_, buffer(), blocking, offset, size,
7644 (events != NULL) ? (cl_uint) events->size() : 0,
7645 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7646 (event != NULL) ? &tmp : NULL),
7647 __ENQUEUE_WRITE_BUFFER_ERR);
7649 if (event != NULL && err == CL_SUCCESS)
7655 cl_int enqueueCopyBuffer(
7658 size_type src_offset,
7659 size_type dst_offset,
7661 const vector<Event>* events = NULL,
7662 Event* event = NULL)
const
7665 cl_int err = detail::errHandler(
7666 ::clEnqueueCopyBuffer(
7667 object_, src(), dst(), src_offset, dst_offset, size,
7668 (events != NULL) ? (cl_uint) events->size() : 0,
7669 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7670 (event != NULL) ? &tmp : NULL),
7671 __ENQEUE_COPY_BUFFER_ERR);
7673 if (event != NULL && err == CL_SUCCESS)
7678 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
7679 cl_int enqueueReadBufferRect(
7680 const Buffer& buffer,
7682 const array<size_type, 3>& buffer_offset,
7683 const array<size_type, 3>& host_offset,
7684 const array<size_type, 3>& region,
7685 size_type buffer_row_pitch,
7686 size_type buffer_slice_pitch,
7687 size_type host_row_pitch,
7688 size_type host_slice_pitch,
7690 const vector<Event>* events = NULL,
7691 Event* event = NULL)
const
7694 cl_int err = detail::errHandler(
7695 ::clEnqueueReadBufferRect(
7699 buffer_offset.data(),
7707 (events != NULL) ? (cl_uint) events->size() : 0,
7708 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7709 (event != NULL) ? &tmp : NULL),
7710 __ENQUEUE_READ_BUFFER_RECT_ERR);
7712 if (event != NULL && err == CL_SUCCESS)
7718 cl_int enqueueWriteBufferRect(
7719 const Buffer& buffer,
7721 const array<size_type, 3>& buffer_offset,
7722 const array<size_type, 3>& host_offset,
7723 const array<size_type, 3>& region,
7724 size_type buffer_row_pitch,
7725 size_type buffer_slice_pitch,
7726 size_type host_row_pitch,
7727 size_type host_slice_pitch,
7729 const vector<Event>* events = NULL,
7730 Event* event = NULL)
const
7733 cl_int err = detail::errHandler(
7734 ::clEnqueueWriteBufferRect(
7738 buffer_offset.data(),
7746 (events != NULL) ? (cl_uint) events->size() : 0,
7747 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7748 (event != NULL) ? &tmp : NULL),
7749 __ENQUEUE_WRITE_BUFFER_RECT_ERR);
7751 if (event != NULL && err == CL_SUCCESS)
7757 cl_int enqueueCopyBufferRect(
7760 const array<size_type, 3>& src_origin,
7761 const array<size_type, 3>& dst_origin,
7762 const array<size_type, 3>& region,
7763 size_type src_row_pitch,
7764 size_type src_slice_pitch,
7765 size_type dst_row_pitch,
7766 size_type dst_slice_pitch,
7767 const vector<Event>* events = NULL,
7768 Event* event = NULL)
const
7771 cl_int err = detail::errHandler(
7772 ::clEnqueueCopyBufferRect(
7783 (events != NULL) ? (cl_uint) events->size() : 0,
7784 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7785 (event != NULL) ? &tmp : NULL),
7786 __ENQEUE_COPY_BUFFER_RECT_ERR);
7788 if (event != NULL && err == CL_SUCCESS)
7794 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
7806 template<
typename PatternType>
7809 PatternType pattern,
7812 const vector<Event>* events = NULL,
7813 Event* event = NULL)
const
7816 cl_int err = detail::errHandler(
7817 ::clEnqueueFillBuffer(
7820 static_cast<void*
>(&pattern),
7821 sizeof(PatternType),
7824 (events != NULL) ? (cl_uint) events->size() : 0,
7825 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7826 (event != NULL) ? &tmp : NULL),
7827 __ENQUEUE_FILL_BUFFER_ERR);
7829 if (event != NULL && err == CL_SUCCESS)
7836 cl_int enqueueReadImage(
7839 const array<size_type, 3>& origin,
7840 const array<size_type, 3>& region,
7841 size_type row_pitch,
7842 size_type slice_pitch,
7844 const vector<Event>* events = NULL,
7845 Event* event = NULL)
const
7848 cl_int err = detail::errHandler(
7849 ::clEnqueueReadImage(
7858 (events != NULL) ? (cl_uint) events->size() : 0,
7859 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7860 (event != NULL) ? &tmp : NULL),
7861 __ENQUEUE_READ_IMAGE_ERR);
7863 if (event != NULL && err == CL_SUCCESS)
7869 cl_int enqueueWriteImage(
7872 const array<size_type, 3>& origin,
7873 const array<size_type, 3>& region,
7874 size_type row_pitch,
7875 size_type slice_pitch,
7877 const vector<Event>* events = NULL,
7878 Event* event = NULL)
const
7881 cl_int err = detail::errHandler(
7882 ::clEnqueueWriteImage(
7891 (events != NULL) ? (cl_uint) events->size() : 0,
7892 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7893 (event != NULL) ? &tmp : NULL),
7894 __ENQUEUE_WRITE_IMAGE_ERR);
7896 if (event != NULL && err == CL_SUCCESS)
7902 cl_int enqueueCopyImage(
7905 const array<size_type, 3>& src_origin,
7906 const array<size_type, 3>& dst_origin,
7907 const array<size_type, 3>& region,
7908 const vector<Event>* events = NULL,
7909 Event* event = NULL)
const
7912 cl_int err = detail::errHandler(
7913 ::clEnqueueCopyImage(
7920 (events != NULL) ? (cl_uint) events->size() : 0,
7921 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7922 (event != NULL) ? &tmp : NULL),
7923 __ENQUEUE_COPY_IMAGE_ERR);
7925 if (event != NULL && err == CL_SUCCESS)
7931 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
7941 cl_float4 fillColor,
7942 const array<size_type, 3>& origin,
7943 const array<size_type, 3>& region,
7944 const vector<Event>* events = NULL,
7945 Event* event = NULL)
const
7948 cl_int err = detail::errHandler(
7949 ::clEnqueueFillImage(
7952 static_cast<void*
>(&fillColor),
7955 (events != NULL) ? (cl_uint) events->size() : 0,
7956 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7957 (event != NULL) ? &tmp : NULL),
7958 __ENQUEUE_FILL_IMAGE_ERR);
7960 if (event != NULL && err == CL_SUCCESS)
7976 const array<size_type, 3>& origin,
7977 const array<size_type, 3>& region,
7978 const vector<Event>* events = NULL,
7979 Event* event = NULL)
const
7982 cl_int err = detail::errHandler(
7983 ::clEnqueueFillImage(
7986 static_cast<void*
>(&fillColor),
7989 (events != NULL) ? (cl_uint) events->size() : 0,
7990 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7991 (event != NULL) ? &tmp : NULL),
7992 __ENQUEUE_FILL_IMAGE_ERR);
7994 if (event != NULL && err == CL_SUCCESS)
8010 const array<size_type, 3>& origin,
8011 const array<size_type, 3>& region,
8012 const vector<Event>* events = NULL,
8013 Event* event = NULL)
const
8016 cl_int err = detail::errHandler(
8017 ::clEnqueueFillImage(
8020 static_cast<void*
>(&fillColor),
8023 (events != NULL) ? (cl_uint) events->size() : 0,
8024 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8025 (event != NULL) ? &tmp : NULL),
8026 __ENQUEUE_FILL_IMAGE_ERR);
8028 if (event != NULL && err == CL_SUCCESS)
8035 cl_int enqueueCopyImageToBuffer(
8038 const array<size_type, 3>& src_origin,
8039 const array<size_type, 3>& region,
8040 size_type dst_offset,
8041 const vector<Event>* events = NULL,
8042 Event* event = NULL)
const
8045 cl_int err = detail::errHandler(
8046 ::clEnqueueCopyImageToBuffer(
8053 (events != NULL) ? (cl_uint) events->size() : 0,
8054 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8055 (event != NULL) ? &tmp : NULL),
8056 __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR);
8058 if (event != NULL && err == CL_SUCCESS)
8064 cl_int enqueueCopyBufferToImage(
8067 size_type src_offset,
8068 const array<size_type, 3>& dst_origin,
8069 const array<size_type, 3>& region,
8070 const vector<Event>* events = NULL,
8071 Event* event = NULL)
const
8074 cl_int err = detail::errHandler(
8075 ::clEnqueueCopyBufferToImage(
8082 (events != NULL) ? (cl_uint) events->size() : 0,
8083 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8084 (event != NULL) ? &tmp : NULL),
8085 __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR);
8087 if (event != NULL && err == CL_SUCCESS)
8093 void* enqueueMapBuffer(
8094 const Buffer& buffer,
8099 const vector<Event>* events = NULL,
8100 Event* event = NULL,
8101 cl_int* err = NULL)
const
8105 void * result = ::clEnqueueMapBuffer(
8106 object_, buffer(), blocking, flags, offset, size,
8107 (events != NULL) ? (cl_uint) events->size() : 0,
8108 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8109 (event != NULL) ? &tmp : NULL,
8112 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
8116 if (event != NULL && error == CL_SUCCESS)
8122 void* enqueueMapImage(
8123 const Image& buffer,
8126 const array<size_type, 3>& origin,
8127 const array<size_type, 3>& region,
8128 size_type * row_pitch,
8129 size_type * slice_pitch,
8130 const vector<Event>* events = NULL,
8131 Event* event = NULL,
8132 cl_int* err = NULL)
const
8136 void * result = ::clEnqueueMapImage(
8137 object_, buffer(), blocking, flags,
8140 row_pitch, slice_pitch,
8141 (events != NULL) ? (cl_uint) events->size() : 0,
8142 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8143 (event != NULL) ? &tmp : NULL,
8146 detail::errHandler(error, __ENQUEUE_MAP_IMAGE_ERR);
8150 if (event != NULL && error == CL_SUCCESS)
8155 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
8160 template<
typename T>
8166 const vector<Event>* events = NULL,
8167 Event* event = NULL)
const
8170 cl_int err = detail::errHandler(::clEnqueueSVMMap(
8171 object_, blocking, flags,
static_cast<void*
>(ptr), size,
8172 (events != NULL) ? (cl_uint)events->size() : 0,
8173 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8174 (event != NULL) ? &tmp : NULL),
8175 __ENQUEUE_MAP_BUFFER_ERR);
8177 if (event != NULL && err == CL_SUCCESS)
8188 template<
typename T,
class D>
8190 cl::pointer<T, D> &ptr,
8194 const vector<Event>* events = NULL,
8195 Event* event = NULL)
const
8198 cl_int err = detail::errHandler(::clEnqueueSVMMap(
8199 object_, blocking, flags,
static_cast<void*
>(ptr.get()), size,
8200 (events != NULL) ? (cl_uint)events->size() : 0,
8201 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8202 (event != NULL) ? &tmp : NULL),
8203 __ENQUEUE_MAP_BUFFER_ERR);
8205 if (event != NULL && err == CL_SUCCESS)
8215 template<
typename T,
class Alloc>
8217 cl::vector<T, Alloc> &container,
8220 const vector<Event>* events = NULL,
8221 Event* event = NULL)
const
8224 cl_int err = detail::errHandler(::clEnqueueSVMMap(
8225 object_, blocking, flags,
static_cast<void*
>(container.data()), container.size()*
sizeof(T),
8226 (events != NULL) ? (cl_uint)events->size() : 0,
8227 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8228 (event != NULL) ? &tmp : NULL),
8229 __ENQUEUE_MAP_BUFFER_ERR);
8231 if (event != NULL && err == CL_SUCCESS)
8238 cl_int enqueueUnmapMemObject(
8241 const vector<Event>* events = NULL,
8242 Event* event = NULL)
const
8245 cl_int err = detail::errHandler(
8246 ::clEnqueueUnmapMemObject(
8247 object_, memory(), mapped_ptr,
8248 (events != NULL) ? (cl_uint) events->size() : 0,
8249 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8250 (event != NULL) ? &tmp : NULL),
8251 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8253 if (event != NULL && err == CL_SUCCESS)
8260 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
8265 template<
typename T>
8268 const vector<Event>* events = NULL,
8269 Event* event = NULL)
const
8272 cl_int err = detail::errHandler(
8273 ::clEnqueueSVMUnmap(
8274 object_,
static_cast<void*
>(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)
8290 template<
typename T,
class D>
8292 cl::pointer<T, D> &ptr,
8293 const vector<Event>* events = NULL,
8294 Event* event = NULL)
const
8297 cl_int err = detail::errHandler(
8298 ::clEnqueueSVMUnmap(
8299 object_,
static_cast<void*
>(ptr.get()),
8300 (events != NULL) ? (cl_uint)events->size() : 0,
8301 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8302 (event != NULL) ? &tmp : NULL),
8303 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8305 if (event != NULL && err == CL_SUCCESS)
8315 template<
typename T,
class Alloc>
8317 cl::vector<T, Alloc> &container,
8318 const vector<Event>* events = NULL,
8319 Event* event = NULL)
const
8322 cl_int err = detail::errHandler(
8323 ::clEnqueueSVMUnmap(
8324 object_,
static_cast<void*
>(container.data()),
8325 (events != NULL) ? (cl_uint)events->size() : 0,
8326 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8327 (event != NULL) ? &tmp : NULL),
8328 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8330 if (event != NULL && err == CL_SUCCESS)
8337 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
8350 const vector<Event> *events = 0,
8351 Event *event = 0)
const
8354 cl_int err = detail::errHandler(
8355 ::clEnqueueMarkerWithWaitList(
8357 (events != NULL) ? (cl_uint) events->size() : 0,
8358 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8359 (event != NULL) ? &tmp : NULL),
8360 __ENQUEUE_MARKER_WAIT_LIST_ERR);
8362 if (event != NULL && err == CL_SUCCESS)
8380 const vector<Event> *events = 0,
8381 Event *event = 0)
const
8384 cl_int err = detail::errHandler(
8385 ::clEnqueueBarrierWithWaitList(
8387 (events != NULL) ? (cl_uint) events->size() : 0,
8388 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8389 (event != NULL) ? &tmp : NULL),
8390 __ENQUEUE_BARRIER_WAIT_LIST_ERR);
8392 if (event != NULL && err == CL_SUCCESS)
8403 const vector<Memory> &memObjects,
8404 cl_mem_migration_flags flags,
8405 const vector<Event>* events = NULL,
8411 vector<cl_mem> localMemObjects(memObjects.size());
8413 for(
int i = 0; i < (int)memObjects.size(); ++i ) {
8414 localMemObjects[i] = memObjects[i]();
8417 cl_int err = detail::errHandler(
8418 ::clEnqueueMigrateMemObjects(
8420 (cl_uint)memObjects.size(),
8421 localMemObjects.data(),
8423 (events != NULL) ? (cl_uint) events->size() : 0,
8424 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8425 (event != NULL) ? &tmp : NULL),
8426 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8428 if (event != NULL && err == CL_SUCCESS)
8436 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
8442 template<
typename T>
8444 const cl::vector<T*> &svmRawPointers,
8445 const cl::vector<size_type> &sizes,
8446 cl_mem_migration_flags flags = 0,
8447 const vector<Event>* events = NULL,
8448 Event* event = NULL)
const
8451 cl_int err = detail::errHandler(::clEnqueueSVMMigrateMem(
8453 svmRawPointers.size(),
static_cast<void**
>(svmRawPointers.data()),
8456 (events != NULL) ? (cl_uint)events->size() : 0,
8457 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8458 (event != NULL) ? &tmp : NULL),
8459 __ENQUEUE_MIGRATE_SVM_ERR);
8461 if (event != NULL && err == CL_SUCCESS)
8471 template<
typename T>
8473 const cl::vector<T*> &svmRawPointers,
8474 cl_mem_migration_flags flags = 0,
8475 const vector<Event>* events = NULL,
8476 Event* event = NULL)
const
8478 return enqueueMigrateSVM(svmRawPointers, cl::vector<size_type>(svmRawPointers.size()), flags, events, event);
8487 template<
typename T,
class D>
8489 const cl::vector<cl::pointer<T, D>> &svmPointers,
8490 const cl::vector<size_type> &sizes,
8491 cl_mem_migration_flags flags = 0,
8492 const vector<Event>* events = NULL,
8493 Event* event = NULL)
const
8495 cl::vector<void*> svmRawPointers;
8496 svmRawPointers.reserve(svmPointers.size());
8497 for (
auto p : svmPointers) {
8498 svmRawPointers.push_back(
static_cast<void*
>(p.get()));
8509 template<
typename T,
class D>
8511 const cl::vector<cl::pointer<T, D>> &svmPointers,
8512 cl_mem_migration_flags flags = 0,
8513 const vector<Event>* events = NULL,
8514 Event* event = NULL)
const
8516 return enqueueMigrateSVM(svmPointers, cl::vector<size_type>(svmPointers.size()), flags, events, event);
8524 template<
typename T,
class Alloc>
8526 const cl::vector<cl::vector<T, Alloc>> &svmContainers,
8527 const cl::vector<size_type> &sizes,
8528 cl_mem_migration_flags flags = 0,
8529 const vector<Event>* events = NULL,
8530 Event* event = NULL)
const
8532 cl::vector<void*> svmRawPointers;
8533 svmRawPointers.reserve(svmContainers.size());
8534 for (
auto p : svmContainers) {
8535 svmRawPointers.push_back(
static_cast<void*
>(p.data()));
8545 template<
typename T,
class Alloc>
8547 const cl::vector<cl::vector<T, Alloc>> &svmContainers,
8548 cl_mem_migration_flags flags = 0,
8549 const vector<Event>* events = NULL,
8550 Event* event = NULL)
const
8552 return enqueueMigrateSVM(svmContainers, cl::vector<size_type>(svmContainers.size()), flags, events, event);
8557 cl_int enqueueNDRangeKernel(
8561 const NDRange& local = NullRange,
8562 const vector<Event>* events = NULL,
8563 Event* event = NULL)
const
8566 cl_int err = detail::errHandler(
8567 ::clEnqueueNDRangeKernel(
8568 object_, kernel(), (cl_uint) global.
dimensions(),
8569 offset.
dimensions() != 0 ? (
const size_type*) offset : NULL,
8570 (
const size_type*) global,
8571 local.dimensions() != 0 ? (
const size_type*) local : NULL,
8572 (events != NULL) ? (cl_uint) events->size() : 0,
8573 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8574 (event != NULL) ? &tmp : NULL),
8575 __ENQUEUE_NDRANGE_KERNEL_ERR);
8577 if (event != NULL && err == CL_SUCCESS)
8583 #if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
8584 CL_API_PREFIX__VERSION_1_2_DEPRECATED cl_int enqueueTask(
8585 const Kernel& kernel,
8586 const vector<Event>* events = NULL,
8587 Event* event = NULL)
const CL_API_SUFFIX__VERSION_1_2_DEPRECATED
8590 cl_int err = detail::errHandler(
8593 (events != NULL) ? (cl_uint) events->size() : 0,
8594 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8595 (event != NULL) ? &tmp : NULL),
8596 __ENQUEUE_TASK_ERR);
8598 if (event != NULL && err == CL_SUCCESS)
8605 cl_int enqueueNativeKernel(
8606 void (CL_CALLBACK *userFptr)(
void *),
8607 std::pair<void*, size_type> args,
8608 const vector<Memory>* mem_objects = NULL,
8609 const vector<const void*>* mem_locs = NULL,
8610 const vector<Event>* events = NULL,
8611 Event* event = NULL)
const
8613 size_type elements = 0;
8614 if (mem_objects != NULL) {
8615 elements = mem_objects->size();
8617 vector<cl_mem> mems(elements);
8618 for (
unsigned int i = 0; i < elements; i++) {
8619 mems[i] = ((*mem_objects)[i])();
8623 cl_int err = detail::errHandler(
8624 ::clEnqueueNativeKernel(
8625 object_, userFptr, args.first, args.second,
8626 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8628 (mem_locs != NULL && mem_locs->size() > 0) ? (
const void **) &mem_locs->front() : NULL,
8629 (events != NULL) ? (cl_uint) events->size() : 0,
8630 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8631 (event != NULL) ? &tmp : NULL),
8632 __ENQUEUE_NATIVE_KERNEL);
8634 if (event != NULL && err == CL_SUCCESS)
8643 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
8644 CL_API_PREFIX__VERSION_1_1_DEPRECATED
8648 cl_int err = detail::errHandler(
8651 (event != NULL) ? &tmp : NULL),
8652 __ENQUEUE_MARKER_ERR);
8654 if (event != NULL && err == CL_SUCCESS)
8660 CL_API_PREFIX__VERSION_1_1_DEPRECATED
8661 cl_int enqueueWaitForEvents(
const vector<Event>& events)
const CL_API_SUFFIX__VERSION_1_1_DEPRECATED
8663 return detail::errHandler(
8664 ::clEnqueueWaitForEvents(
8666 (cl_uint) events.size(),
8667 events.size() > 0 ? (
const cl_event*) &events.front() : NULL),
8668 __ENQUEUE_WAIT_FOR_EVENTS_ERR);
8672 cl_int enqueueAcquireGLObjects(
8673 const vector<Memory>* mem_objects = NULL,
8674 const vector<Event>* events = NULL,
8675 Event* event = NULL)
const
8678 cl_int err = detail::errHandler(
8679 ::clEnqueueAcquireGLObjects(
8681 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8682 (mem_objects != NULL && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front(): NULL,
8683 (events != NULL) ? (cl_uint) events->size() : 0,
8684 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8685 (event != NULL) ? &tmp : NULL),
8686 __ENQUEUE_ACQUIRE_GL_ERR);
8688 if (event != NULL && err == CL_SUCCESS)
8694 cl_int enqueueReleaseGLObjects(
8695 const vector<Memory>* mem_objects = NULL,
8696 const vector<Event>* events = NULL,
8697 Event* event = NULL)
const
8700 cl_int err = detail::errHandler(
8701 ::clEnqueueReleaseGLObjects(
8703 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8704 (mem_objects != NULL && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front(): NULL,
8705 (events != NULL) ? (cl_uint) events->size() : 0,
8706 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8707 (event != NULL) ? &tmp : NULL),
8708 __ENQUEUE_RELEASE_GL_ERR);
8710 if (event != NULL && err == CL_SUCCESS)
8716 #if defined (CL_HPP_USE_DX_INTEROP)
8717 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueAcquireD3D10ObjectsKHR)(
8718 cl_command_queue command_queue, cl_uint num_objects,
8719 const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
8720 const cl_event* event_wait_list, cl_event* event);
8721 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueReleaseD3D10ObjectsKHR)(
8722 cl_command_queue command_queue, cl_uint num_objects,
8723 const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
8724 const cl_event* event_wait_list, cl_event* event);
8726 cl_int enqueueAcquireD3D10Objects(
8727 const vector<Memory>* mem_objects = NULL,
8728 const vector<Event>* events = NULL,
8729 Event* event = NULL)
const
8731 static PFN_clEnqueueAcquireD3D10ObjectsKHR pfn_clEnqueueAcquireD3D10ObjectsKHR = NULL;
8732 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
8733 cl_context context = getInfo<CL_QUEUE_CONTEXT>();
8734 cl::Device device(getInfo<CL_QUEUE_DEVICE>());
8735 cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>();
8736 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueAcquireD3D10ObjectsKHR);
8738 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
8739 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueAcquireD3D10ObjectsKHR);
8743 cl_int err = detail::errHandler(
8744 pfn_clEnqueueAcquireD3D10ObjectsKHR(
8746 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8747 (mem_objects != NULL && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front(): NULL,
8748 (events != NULL) ? (cl_uint) events->size() : 0,
8749 (events != NULL) ? (cl_event*) &events->front() : NULL,
8750 (event != NULL) ? &tmp : NULL),
8751 __ENQUEUE_ACQUIRE_GL_ERR);
8753 if (event != NULL && err == CL_SUCCESS)
8759 cl_int enqueueReleaseD3D10Objects(
8760 const vector<Memory>* mem_objects = NULL,
8761 const vector<Event>* events = NULL,
8762 Event* event = NULL)
const
8764 static PFN_clEnqueueReleaseD3D10ObjectsKHR pfn_clEnqueueReleaseD3D10ObjectsKHR = NULL;
8765 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
8766 cl_context context = getInfo<CL_QUEUE_CONTEXT>();
8767 cl::Device device(getInfo<CL_QUEUE_DEVICE>());
8768 cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>();
8769 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueReleaseD3D10ObjectsKHR);
8771 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
8772 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueReleaseD3D10ObjectsKHR);
8776 cl_int err = detail::errHandler(
8777 pfn_clEnqueueReleaseD3D10ObjectsKHR(
8779 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8780 (mem_objects != NULL && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front(): NULL,
8781 (events != NULL) ? (cl_uint) events->size() : 0,
8782 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8783 (event != NULL) ? &tmp : NULL),
8784 __ENQUEUE_RELEASE_GL_ERR);
8786 if (event != NULL && err == CL_SUCCESS)
8796 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
8797 CL_API_PREFIX__VERSION_1_1_DEPRECATED
8800 return detail::errHandler(
8801 ::clEnqueueBarrier(object_),
8802 __ENQUEUE_BARRIER_ERR);
8806 cl_int flush()
const
8808 return detail::errHandler(::clFlush(object_), __FLUSH_ERR);
8811 cl_int finish()
const
8813 return detail::errHandler(::clFinish(object_), __FINISH_ERR);
8817 CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag CommandQueue::default_initialized_;
8818 CL_HPP_DEFINE_STATIC_MEMBER_ CommandQueue CommandQueue::default_;
8819 CL_HPP_DEFINE_STATIC_MEMBER_ cl_int CommandQueue::default_error_ = CL_SUCCESS;
8822 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
8823 enum class DeviceQueueProperties : cl_command_queue_properties
8826 Profiling = CL_QUEUE_PROFILING_ENABLE,
8829 inline DeviceQueueProperties operator|(DeviceQueueProperties lhs, DeviceQueueProperties rhs)
8831 return static_cast<DeviceQueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) |
static_cast<cl_command_queue_properties
>(rhs));
8855 cl_command_queue_properties mergedProperties =
8856 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
8858 cl_queue_properties queue_properties[] = {
8859 CL_QUEUE_PROPERTIES, mergedProperties, 0 };
8860 object_ = ::clCreateCommandQueueWithProperties(
8861 context(), device(), queue_properties, &error);
8863 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8875 DeviceQueueProperties properties = DeviceQueueProperties::None,
8880 cl_command_queue_properties mergedProperties =
8881 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
8882 cl_queue_properties queue_properties[] = {
8883 CL_QUEUE_PROPERTIES, mergedProperties, 0 };
8884 object_ = ::clCreateCommandQueueWithProperties(
8885 context(), device(), queue_properties, &error);
8887 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8900 DeviceQueueProperties properties = DeviceQueueProperties::None,
8905 cl_command_queue_properties mergedProperties =
8906 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
8907 cl_queue_properties queue_properties[] = {
8908 CL_QUEUE_PROPERTIES, mergedProperties,
8909 CL_QUEUE_SIZE, queueSize,
8911 object_ = ::clCreateCommandQueueWithProperties(
8912 context(), device(), queue_properties, &error);
8914 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8927 detail::Wrapper<cl_type>(commandQueue, retainObject) { }
8963 template <
typename T>
8964 cl_int getInfo(cl_command_queue_info name, T* param)
const
8966 return detail::errHandler(
8968 &::clGetCommandQueueInfo, object_, name, param),
8969 __GET_COMMAND_QUEUE_INFO_ERR);
8972 template <cl_command_queue_info name>
typename
8973 detail::param_traits<detail::cl_command_queue_info, name>::param_type
8974 getInfo(cl_int* err = NULL)
const
8976 typename detail::param_traits<
8977 detail::cl_command_queue_info, name>::param_type param;
8978 cl_int result = getInfo(name, ¶m);
8992 cl_int *err =
nullptr)
8998 cl_command_queue_properties properties =
8999 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
9000 cl_queue_properties queue_properties[] = {
9001 CL_QUEUE_PROPERTIES, properties,
9004 ::clCreateCommandQueueWithProperties(
9005 context(), device(), queue_properties, &error));
9007 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9022 const Context &context,
const Device &device, cl_int *err =
nullptr)
9026 cl_command_queue_properties properties =
9027 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
9028 cl_queue_properties queue_properties[] = {
9029 CL_QUEUE_PROPERTIES, properties,
9032 ::clCreateCommandQueueWithProperties(
9033 context(), device(), queue_properties, &error));
9035 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9050 const Context &context,
const Device &device, cl_uint queueSize, cl_int *err =
nullptr)
9054 cl_command_queue_properties properties =
9055 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
9056 cl_queue_properties queue_properties[] = {
9057 CL_QUEUE_PROPERTIES, properties,
9058 CL_QUEUE_SIZE, queueSize,
9061 ::clCreateCommandQueueWithProperties(
9062 context(), device(), queue_properties, &error));
9064 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9074 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
9084 error = clSetDefaultDeviceCommandQueue(context.get(), device.get(), default_queue.get());
9086 detail::errHandler(error, __SET_DEFAULT_DEVICE_COMMAND_QUEUE_ERR);
9090 return default_queue;
9098 return queue.getInfo<CL_QUEUE_DEVICE_DEFAULT>(err);
9118 template<
typename IteratorType >
9121 IteratorType startIterator,
9122 IteratorType endIterator,
9127 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9130 cl_mem_flags flags = 0;
9132 flags |= CL_MEM_READ_ONLY;
9135 flags |= CL_MEM_READ_WRITE;
9138 flags |= CL_MEM_USE_HOST_PTR;
9141 size_type size =
sizeof(DataType)*(endIterator - startIterator);
9144 object_ = ::clCreateBuffer(context(), flags, size,
static_cast<DataType*
>(&*startIterator), &error);
9146 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
9149 detail::errHandler(error, __CREATE_BUFFER_ERR);
9156 detail::errHandler(error, __CREATE_BUFFER_ERR);
9161 error =
cl::copy(queue, startIterator, endIterator, *
this);
9162 detail::errHandler(error, __CREATE_BUFFER_ERR);
9169 template<
typename IteratorType >
9172 IteratorType startIterator,
9173 IteratorType endIterator,
9178 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9181 cl_mem_flags flags = 0;
9183 flags |= CL_MEM_READ_ONLY;
9186 flags |= CL_MEM_READ_WRITE;
9189 flags |= CL_MEM_USE_HOST_PTR;
9192 size_type size =
sizeof(DataType)*(endIterator - startIterator);
9194 Context context = queue.getInfo<CL_QUEUE_CONTEXT>();
9197 object_ = ::clCreateBuffer(context(), flags, size,
static_cast<DataType*
>(&*startIterator), &error);
9200 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
9203 detail::errHandler(error, __CREATE_BUFFER_ERR);
9209 error =
cl::copy(queue, startIterator, endIterator, *
this);
9210 detail::errHandler(error, __CREATE_BUFFER_ERR);
9217 inline cl_int enqueueReadBuffer(
9223 const vector<Event>* events = NULL,
9224 Event* event = NULL)
9229 if (error != CL_SUCCESS) {
9233 return queue.enqueueReadBuffer(buffer, blocking, offset, size, ptr, events, event);
9236 inline cl_int enqueueWriteBuffer(
9237 const Buffer& buffer,
9242 const vector<Event>* events = NULL,
9243 Event* event = NULL)
9246 CommandQueue queue = CommandQueue::getDefault(&error);
9248 if (error != CL_SUCCESS) {
9252 return queue.enqueueWriteBuffer(buffer, blocking, offset, size, ptr, events, event);
9255 inline void* enqueueMapBuffer(
9256 const Buffer& buffer,
9261 const vector<Event>* events = NULL,
9262 Event* event = NULL,
9266 CommandQueue queue = CommandQueue::getDefault(&error);
9267 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9272 void * result = ::clEnqueueMapBuffer(
9273 queue(), buffer(), blocking, flags, offset, size,
9274 (events != NULL) ? (cl_uint) events->size() : 0,
9275 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
9279 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9287 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
9293 template<
typename T>
9299 const vector<Event>* events,
9304 if (error != CL_SUCCESS) {
9305 return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9309 ptr, blocking, flags, size, events, event);
9317 template<
typename T,
class D>
9319 cl::pointer<T, D> ptr,
9323 const vector<Event>* events = NULL,
9324 Event* event = NULL)
9328 if (error != CL_SUCCESS) {
9329 return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9333 ptr, blocking, flags, size, events, event);
9341 template<
typename T,
class Alloc>
9343 cl::vector<T, Alloc> container,
9346 const vector<Event>* events = NULL,
9347 Event* event = NULL)
9351 if (error != CL_SUCCESS) {
9352 return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9356 container, blocking, flags, events, event);
9361 inline cl_int enqueueUnmapMemObject(
9362 const Memory& memory,
9364 const vector<Event>* events = NULL,
9365 Event* event = NULL)
9368 CommandQueue queue = CommandQueue::getDefault(&error);
9369 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9370 if (error != CL_SUCCESS) {
9375 cl_int err = detail::errHandler(
9376 ::clEnqueueUnmapMemObject(
9377 queue(), memory(), mapped_ptr,
9378 (events != NULL) ? (cl_uint)events->size() : 0,
9379 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
9380 (event != NULL) ? &tmp : NULL),
9381 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9383 if (event != NULL && err == CL_SUCCESS)
9389 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
9395 template<
typename T>
9398 const vector<Event>* events = NULL,
9399 Event* event = NULL)
9403 if (error != CL_SUCCESS) {
9404 return detail::errHandler(error, __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9408 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9417 template<
typename T,
class D>
9419 cl::pointer<T, D> &ptr,
9420 const vector<Event>* events = NULL,
9421 Event* event = NULL)
9425 if (error != CL_SUCCESS) {
9426 return detail::errHandler(error, __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9430 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9438 template<
typename T,
class Alloc>
9440 cl::vector<T, Alloc> &container,
9441 const vector<Event>* events = NULL,
9442 Event* event = NULL)
9446 if (error != CL_SUCCESS) {
9447 return detail::errHandler(error, __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9450 return detail::errHandler(queue.
enqueueUnmapSVM(container, events, event),
9451 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9456 inline cl_int enqueueCopyBuffer(
9459 size_type src_offset,
9460 size_type dst_offset,
9462 const vector<Event>* events = NULL,
9463 Event* event = NULL)
9466 CommandQueue queue = CommandQueue::getDefault(&error);
9468 if (error != CL_SUCCESS) {
9472 return queue.enqueueCopyBuffer(src, dst, src_offset, dst_offset, size, events, event);
9480 template<
typename IteratorType >
9481 inline cl_int
copy( IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer )
9485 if (error != CL_SUCCESS)
9488 return cl::copy(queue, startIterator, endIterator, buffer);
9496 template<
typename IteratorType >
9497 inline cl_int
copy(
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator )
9501 if (error != CL_SUCCESS)
9504 return cl::copy(queue, buffer, startIterator, endIterator);
9512 template<
typename IteratorType >
9515 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9518 size_type length = endIterator-startIterator;
9519 size_type byteLength = length*
sizeof(DataType);
9522 static_cast<DataType*
>(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_WRITE, 0, byteLength, 0, 0, &error));
9524 if( error != CL_SUCCESS ) {
9527 #if defined(_MSC_VER)
9531 stdext::checked_array_iterator<DataType*>(
9534 std::copy(startIterator, endIterator, pointer);
9537 error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
9539 if( error != CL_SUCCESS ) {
9551 template<
typename IteratorType >
9554 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9557 size_type length = endIterator-startIterator;
9558 size_type byteLength = length*
sizeof(DataType);
9561 static_cast<DataType*
>(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_READ, 0, byteLength, 0, 0, &error));
9563 if( error != CL_SUCCESS ) {
9566 std::copy(pointer, pointer + length, startIterator);
9568 error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
9570 if( error != CL_SUCCESS ) {
9578 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
9582 template<
typename T,
class Alloc>
9583 inline cl_int
mapSVM(cl::vector<T, Alloc> &container)
9585 return enqueueMapSVM(container, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE);
9591 template<
typename T,
class Alloc>
9592 inline cl_int
unmapSVM(cl::vector<T, Alloc> &container)
9599 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
9600 inline cl_int enqueueReadBufferRect(
9601 const Buffer& buffer,
9603 const array<size_type, 3>& buffer_offset,
9604 const array<size_type, 3>& host_offset,
9605 const array<size_type, 3>& region,
9606 size_type buffer_row_pitch,
9607 size_type buffer_slice_pitch,
9608 size_type host_row_pitch,
9609 size_type host_slice_pitch,
9611 const vector<Event>* events = NULL,
9612 Event* event = NULL)
9615 CommandQueue queue = CommandQueue::getDefault(&error);
9617 if (error != CL_SUCCESS) {
9621 return queue.enqueueReadBufferRect(
9636 inline cl_int enqueueWriteBufferRect(
9637 const Buffer& buffer,
9639 const array<size_type, 3>& buffer_offset,
9640 const array<size_type, 3>& host_offset,
9641 const array<size_type, 3>& region,
9642 size_type buffer_row_pitch,
9643 size_type buffer_slice_pitch,
9644 size_type host_row_pitch,
9645 size_type host_slice_pitch,
9647 const vector<Event>* events = NULL,
9648 Event* event = NULL)
9651 CommandQueue queue = CommandQueue::getDefault(&error);
9653 if (error != CL_SUCCESS) {
9657 return queue.enqueueWriteBufferRect(
9672 inline cl_int enqueueCopyBufferRect(
9675 const array<size_type, 3>& src_origin,
9676 const array<size_type, 3>& dst_origin,
9677 const array<size_type, 3>& region,
9678 size_type src_row_pitch,
9679 size_type src_slice_pitch,
9680 size_type dst_row_pitch,
9681 size_type dst_slice_pitch,
9682 const vector<Event>* events = NULL,
9683 Event* event = NULL)
9686 CommandQueue queue = CommandQueue::getDefault(&error);
9688 if (error != CL_SUCCESS) {
9692 return queue.enqueueCopyBufferRect(
9707 inline cl_int enqueueReadImage(
9710 const array<size_type, 3>& origin,
9711 const array<size_type, 3>& region,
9712 size_type row_pitch,
9713 size_type slice_pitch,
9715 const vector<Event>* events = NULL,
9716 Event* event = NULL)
9719 CommandQueue queue = CommandQueue::getDefault(&error);
9721 if (error != CL_SUCCESS) {
9725 return queue.enqueueReadImage(
9737 inline cl_int enqueueWriteImage(
9740 const array<size_type, 3>& origin,
9741 const array<size_type, 3>& region,
9742 size_type row_pitch,
9743 size_type slice_pitch,
9745 const vector<Event>* events = NULL,
9746 Event* event = NULL)
9749 CommandQueue queue = CommandQueue::getDefault(&error);
9751 if (error != CL_SUCCESS) {
9755 return queue.enqueueWriteImage(
9767 inline cl_int enqueueCopyImage(
9770 const array<size_type, 3>& src_origin,
9771 const array<size_type, 3>& dst_origin,
9772 const array<size_type, 3>& region,
9773 const vector<Event>* events = NULL,
9774 Event* event = NULL)
9777 CommandQueue queue = CommandQueue::getDefault(&error);
9779 if (error != CL_SUCCESS) {
9783 return queue.enqueueCopyImage(
9793 inline cl_int enqueueCopyImageToBuffer(
9796 const array<size_type, 3>& src_origin,
9797 const array<size_type, 3>& region,
9798 size_type dst_offset,
9799 const vector<Event>* events = NULL,
9800 Event* event = NULL)
9803 CommandQueue queue = CommandQueue::getDefault(&error);
9805 if (error != CL_SUCCESS) {
9809 return queue.enqueueCopyImageToBuffer(
9819 inline cl_int enqueueCopyBufferToImage(
9822 size_type src_offset,
9823 const array<size_type, 3>& dst_origin,
9824 const array<size_type, 3>& region,
9825 const vector<Event>* events = NULL,
9826 Event* event = NULL)
9829 CommandQueue queue = CommandQueue::getDefault(&error);
9831 if (error != CL_SUCCESS) {
9835 return queue.enqueueCopyBufferToImage(
9846 inline cl_int flush(
void)
9849 CommandQueue queue = CommandQueue::getDefault(&error);
9851 if (error != CL_SUCCESS) {
9855 return queue.flush();
9858 inline cl_int finish(
void)
9861 CommandQueue queue = CommandQueue::getDefault(&error);
9863 if (error != CL_SUCCESS) {
9868 return queue.finish();
9878 vector<Event> events_;
9880 template<
typename... Ts>
9885 queue_(CommandQueue::getDefault()),
9894 queue_(CommandQueue::getDefault()),
9903 queue_(CommandQueue::getDefault()),
9912 queue_(CommandQueue::getDefault()),
9917 events_.push_back(e);
9921 queue_(CommandQueue::getDefault()),
9926 events_.push_back(e);
9930 queue_(CommandQueue::getDefault()),
9935 events_.push_back(e);
9939 queue_(CommandQueue::getDefault()),
9949 queue_(CommandQueue::getDefault()),
9959 queue_(CommandQueue::getDefault()),
10001 events_.push_back(e);
10006 offset_(NullRange),
10010 events_.push_back(e);
10019 events_.push_back(e);
10024 offset_(NullRange),
10034 offset_(NullRange),
10061 template<
typename... Ts>
10067 template<
int index,
typename T0,
typename... T1s>
10068 void setArgs(T0&& t0, T1s&&... t1s)
10070 kernel_.
setArg(index, t0);
10071 setArgs<index + 1, T1s...>(std::forward<T1s>(t1s)...);
10074 template<
int index,
typename T0>
10075 void setArgs(T0&& t0)
10077 kernel_.
setArg(index, t0);
10080 template<
int index>
10093 cl_int * err = NULL) :
10094 kernel_(program, name.c_str(), err)
10110 setArgs<0>(std::forward<Ts>(ts)...);
10112 args.queue_.enqueueNDRangeKernel(
10135 setArgs<0>(std::forward<Ts>(ts)...);
10137 error = args.queue_.enqueueNDRangeKernel(
10148 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
10149 cl_int setSVMPointers(
const vector<void*> &pointerList)
10154 template<
typename T0,
typename... T1s>
10155 cl_int setSVMPointers(
const T0 &t0, T1s &... ts)
10167 namespace compatibility {
10172 template<
typename... Ts>
10182 cl_int * err = NULL) :
10204 enqueueArgs, args...);
10212 #undef CL_HPP_ERR_STR_
10213 #if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS)
10214 #undef __GET_DEVICE_INFO_ERR
10215 #undef __GET_PLATFORM_INFO_ERR
10216 #undef __GET_DEVICE_IDS_ERR
10217 #undef __GET_PLATFORM_IDS_ERR
10218 #undef __GET_CONTEXT_INFO_ERR
10219 #undef __GET_EVENT_INFO_ERR
10220 #undef __GET_EVENT_PROFILE_INFO_ERR
10221 #undef __GET_MEM_OBJECT_INFO_ERR
10222 #undef __GET_IMAGE_INFO_ERR
10223 #undef __GET_SAMPLER_INFO_ERR
10224 #undef __GET_KERNEL_INFO_ERR
10225 #undef __GET_KERNEL_ARG_INFO_ERR
10226 #undef __GET_KERNEL_SUB_GROUP_INFO_ERR
10227 #undef __GET_KERNEL_WORK_GROUP_INFO_ERR
10228 #undef __GET_PROGRAM_INFO_ERR
10229 #undef __GET_PROGRAM_BUILD_INFO_ERR
10230 #undef __GET_COMMAND_QUEUE_INFO_ERR
10231 #undef __CREATE_CONTEXT_ERR
10232 #undef __CREATE_CONTEXT_FROM_TYPE_ERR
10233 #undef __GET_SUPPORTED_IMAGE_FORMATS_ERR
10234 #undef __CREATE_BUFFER_ERR
10236 #undef __CREATE_SUBBUFFER_ERR
10237 #undef __CREATE_GL_BUFFER_ERR
10238 #undef __CREATE_GL_RENDER_BUFFER_ERR
10239 #undef __GET_GL_OBJECT_INFO_ERR
10240 #undef __CREATE_IMAGE_ERR
10241 #undef __CREATE_GL_TEXTURE_ERR
10242 #undef __IMAGE_DIMENSION_ERR
10243 #undef __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR
10244 #undef __CREATE_USER_EVENT_ERR
10245 #undef __SET_USER_EVENT_STATUS_ERR
10246 #undef __SET_EVENT_CALLBACK_ERR
10247 #undef __WAIT_FOR_EVENTS_ERR
10248 #undef __CREATE_KERNEL_ERR
10249 #undef __SET_KERNEL_ARGS_ERR
10250 #undef __CREATE_PROGRAM_WITH_SOURCE_ERR
10251 #undef __CREATE_PROGRAM_WITH_IL_ERR
10252 #undef __CREATE_PROGRAM_WITH_BINARY_ERR
10253 #undef __CREATE_PROGRAM_WITH_IL_ERR
10254 #undef __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR
10255 #undef __BUILD_PROGRAM_ERR
10256 #undef __COMPILE_PROGRAM_ERR
10257 #undef __LINK_PROGRAM_ERR
10258 #undef __CREATE_KERNELS_IN_PROGRAM_ERR
10259 #undef __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR
10260 #undef __CREATE_SAMPLER_WITH_PROPERTIES_ERR
10261 #undef __SET_COMMAND_QUEUE_PROPERTY_ERR
10262 #undef __ENQUEUE_READ_BUFFER_ERR
10263 #undef __ENQUEUE_READ_BUFFER_RECT_ERR
10264 #undef __ENQUEUE_WRITE_BUFFER_ERR
10265 #undef __ENQUEUE_WRITE_BUFFER_RECT_ERR
10266 #undef __ENQEUE_COPY_BUFFER_ERR
10267 #undef __ENQEUE_COPY_BUFFER_RECT_ERR
10268 #undef __ENQUEUE_FILL_BUFFER_ERR
10269 #undef __ENQUEUE_READ_IMAGE_ERR
10270 #undef __ENQUEUE_WRITE_IMAGE_ERR
10271 #undef __ENQUEUE_COPY_IMAGE_ERR
10272 #undef __ENQUEUE_FILL_IMAGE_ERR
10273 #undef __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR
10274 #undef __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR
10275 #undef __ENQUEUE_MAP_BUFFER_ERR
10276 #undef __ENQUEUE_MAP_IMAGE_ERR
10277 #undef __ENQUEUE_UNMAP_MEM_OBJECT_ERR
10278 #undef __ENQUEUE_NDRANGE_KERNEL_ERR
10279 #undef __ENQUEUE_NATIVE_KERNEL
10280 #undef __ENQUEUE_MIGRATE_MEM_OBJECTS_ERR
10281 #undef __ENQUEUE_MIGRATE_SVM_ERR
10282 #undef __ENQUEUE_ACQUIRE_GL_ERR
10283 #undef __ENQUEUE_RELEASE_GL_ERR
10284 #undef __CREATE_PIPE_ERR
10285 #undef __GET_PIPE_INFO_ERR
10286 #undef __RETAIN_ERR
10287 #undef __RELEASE_ERR
10289 #undef __FINISH_ERR
10290 #undef __VECTOR_CAPACITY_ERR
10291 #undef __CREATE_SUB_DEVICES_ERR
10292 #undef __CREATE_SUB_DEVICES_ERR
10293 #undef __ENQUEUE_MARKER_ERR
10294 #undef __ENQUEUE_WAIT_FOR_EVENTS_ERR
10295 #undef __ENQUEUE_BARRIER_ERR
10296 #undef __UNLOAD_COMPILER_ERR
10297 #undef __CREATE_GL_TEXTURE_2D_ERR
10298 #undef __CREATE_GL_TEXTURE_3D_ERR
10299 #undef __CREATE_IMAGE2D_ERR
10300 #undef __CREATE_IMAGE3D_ERR
10301 #undef __CREATE_COMMAND_QUEUE_ERR
10302 #undef __ENQUEUE_TASK_ERR
10303 #undef __CREATE_SAMPLER_ERR
10304 #undef __ENQUEUE_MARKER_WAIT_LIST_ERR
10305 #undef __ENQUEUE_BARRIER_WAIT_LIST_ERR
10306 #undef __CLONE_KERNEL_ERR
10307 #undef __GET_HOST_TIMER_ERR
10308 #undef __GET_DEVICE_AND_HOST_TIMER_ERR
10313 #undef CL_HPP_INIT_CL_EXT_FCN_PTR_
10314 #undef CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_
10316 #if defined(CL_HPP_USE_CL_DEVICE_FISSION)
10317 #undef CL_HPP_PARAM_NAME_DEVICE_FISSION_
10320 #undef CL_HPP_NOEXCEPT_
10321 #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)