403 #if !defined(CL_HPP_USE_DX_INTEROP) && defined(USE_DX_INTEROP)
404 # pragma message("opencl.hpp: USE_DX_INTEROP is deprecated. Define CL_HPP_USE_DX_INTEROP instead")
405 # define CL_HPP_USE_DX_INTEROP
407 #if !defined(CL_HPP_USE_CL_DEVICE_FISSION) && defined(USE_CL_DEVICE_FISSION)
408 # pragma message("opencl.hpp: USE_CL_DEVICE_FISSION is deprecated. Define CL_HPP_USE_CL_DEVICE_FISSION instead")
409 # define CL_HPP_USE_CL_DEVICE_FISSION
411 #if !defined(CL_HPP_ENABLE_EXCEPTIONS) && defined(__CL_ENABLE_EXCEPTIONS)
412 # pragma message("opencl.hpp: __CL_ENABLE_EXCEPTIONS is deprecated. Define CL_HPP_ENABLE_EXCEPTIONS instead")
413 # define CL_HPP_ENABLE_EXCEPTIONS
415 #if !defined(CL_HPP_NO_STD_VECTOR) && defined(__NO_STD_VECTOR)
416 # pragma message("opencl.hpp: __NO_STD_VECTOR is deprecated. Define CL_HPP_NO_STD_VECTOR instead")
417 # define CL_HPP_NO_STD_VECTOR
419 #if !defined(CL_HPP_NO_STD_STRING) && defined(__NO_STD_STRING)
420 # pragma message("opencl.hpp: __NO_STD_STRING is deprecated. Define CL_HPP_NO_STD_STRING instead")
421 # define CL_HPP_NO_STD_STRING
423 #if defined(VECTOR_CLASS)
424 # pragma message("opencl.hpp: VECTOR_CLASS is deprecated. Alias cl::vector instead")
426 #if defined(STRING_CLASS)
427 # pragma message("opencl.hpp: STRING_CLASS is deprecated. Alias cl::string instead.")
429 #if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS) && defined(__CL_USER_OVERRIDE_ERROR_STRINGS)
430 # pragma message("opencl.hpp: __CL_USER_OVERRIDE_ERROR_STRINGS is deprecated. Define CL_HPP_USER_OVERRIDE_ERROR_STRINGS instead")
431 # define CL_HPP_USER_OVERRIDE_ERROR_STRINGS
436 #if defined(__USE_DEV_VECTOR)
437 # pragma message("opencl.hpp: __USE_DEV_VECTOR is no longer supported. Expect compilation errors")
439 #if defined(__USE_DEV_STRING)
440 # pragma message("opencl.hpp: __USE_DEV_STRING is no longer supported. Expect compilation errors")
444 #if !defined(CL_HPP_TARGET_OPENCL_VERSION)
445 # pragma message("opencl.hpp: CL_HPP_TARGET_OPENCL_VERSION is not defined. It will default to 300 (OpenCL 3.0)")
446 # define CL_HPP_TARGET_OPENCL_VERSION 300
448 #if CL_HPP_TARGET_OPENCL_VERSION != 100 && \
449 CL_HPP_TARGET_OPENCL_VERSION != 110 && \
450 CL_HPP_TARGET_OPENCL_VERSION != 120 && \
451 CL_HPP_TARGET_OPENCL_VERSION != 200 && \
452 CL_HPP_TARGET_OPENCL_VERSION != 210 && \
453 CL_HPP_TARGET_OPENCL_VERSION != 220 && \
454 CL_HPP_TARGET_OPENCL_VERSION != 300
455 # pragma message("opencl.hpp: CL_HPP_TARGET_OPENCL_VERSION is not a valid value (100, 110, 120, 200, 210, 220 or 300). It will be set to 300 (OpenCL 3.0).")
456 # undef CL_HPP_TARGET_OPENCL_VERSION
457 # define CL_HPP_TARGET_OPENCL_VERSION 300
461 #if defined(CL_TARGET_OPENCL_VERSION)
464 #if CL_TARGET_OPENCL_VERSION < CL_HPP_TARGET_OPENCL_VERSION
465 # pragma message("CL_TARGET_OPENCL_VERSION is already defined as is lower than CL_HPP_TARGET_OPENCL_VERSION")
468 # define CL_TARGET_OPENCL_VERSION CL_HPP_TARGET_OPENCL_VERSION
471 #if !defined(CL_HPP_MINIMUM_OPENCL_VERSION)
472 # define CL_HPP_MINIMUM_OPENCL_VERSION 200
474 #if CL_HPP_MINIMUM_OPENCL_VERSION != 100 && \
475 CL_HPP_MINIMUM_OPENCL_VERSION != 110 && \
476 CL_HPP_MINIMUM_OPENCL_VERSION != 120 && \
477 CL_HPP_MINIMUM_OPENCL_VERSION != 200 && \
478 CL_HPP_MINIMUM_OPENCL_VERSION != 210 && \
479 CL_HPP_MINIMUM_OPENCL_VERSION != 220 && \
480 CL_HPP_MINIMUM_OPENCL_VERSION != 300
481 # pragma message("opencl.hpp: CL_HPP_MINIMUM_OPENCL_VERSION is not a valid value (100, 110, 120, 200, 210, 220 or 300). It will be set to 100")
482 # undef CL_HPP_MINIMUM_OPENCL_VERSION
483 # define CL_HPP_MINIMUM_OPENCL_VERSION 100
485 #if CL_HPP_MINIMUM_OPENCL_VERSION > CL_HPP_TARGET_OPENCL_VERSION
486 # error "CL_HPP_MINIMUM_OPENCL_VERSION must not be greater than CL_HPP_TARGET_OPENCL_VERSION"
489 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 100 && !defined(CL_USE_DEPRECATED_OPENCL_1_0_APIS)
490 # define CL_USE_DEPRECATED_OPENCL_1_0_APIS
492 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 110 && !defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
493 # define CL_USE_DEPRECATED_OPENCL_1_1_APIS
495 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 120 && !defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
496 # define CL_USE_DEPRECATED_OPENCL_1_2_APIS
498 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 200 && !defined(CL_USE_DEPRECATED_OPENCL_2_0_APIS)
499 # define CL_USE_DEPRECATED_OPENCL_2_0_APIS
501 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 210 && !defined(CL_USE_DEPRECATED_OPENCL_2_1_APIS)
502 # define CL_USE_DEPRECATED_OPENCL_2_1_APIS
504 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 220 && !defined(CL_USE_DEPRECATED_OPENCL_2_2_APIS)
505 # define CL_USE_DEPRECATED_OPENCL_2_2_APIS
512 #if defined(CL_HPP_USE_DX_INTEROP)
513 #include <CL/cl_d3d10.h>
514 #include <CL/cl_dx9_media_sharing.h>
518 #if defined(_MSC_VER)
526 #if (!defined(_MSC_VER) && __cplusplus < 201103L) || (defined(_MSC_VER) && _MSC_VER < 1700)
527 #error Visual studio 2013 or another C++11-supporting compiler required
531 #if defined(CL_HPP_USE_CL_DEVICE_FISSION) || defined(CL_HPP_USE_CL_SUB_GROUPS_KHR)
532 #include <CL/cl_ext.h>
535 #if defined(__APPLE__) || defined(__MACOSX)
536 #include <OpenCL/opencl.h>
538 #include <CL/opencl.h>
541 #if (__cplusplus >= 201103L || _MSVC_LANG >= 201103L )
542 #define CL_HPP_NOEXCEPT_ noexcept
544 #define CL_HPP_NOEXCEPT_
547 #if __cplusplus >= 201703L
548 # define CL_HPP_DEFINE_STATIC_MEMBER_ inline
549 #elif defined(_MSC_VER)
550 # define CL_HPP_DEFINE_STATIC_MEMBER_ __declspec(selectany)
551 #elif defined(__MINGW32__)
552 # define CL_HPP_DEFINE_STATIC_MEMBER_ __attribute__((selectany))
554 # define CL_HPP_DEFINE_STATIC_MEMBER_ __attribute__((weak))
559 #if !defined(CL_API_PREFIX__VERSION_1_1_DEPRECATED)
560 #define CL_API_PREFIX__VERSION_1_1_DEPRECATED
562 #if !defined(CL_API_SUFFIX__VERSION_1_1_DEPRECATED)
563 #define CL_API_SUFFIX__VERSION_1_1_DEPRECATED
566 #if !defined(CL_API_PREFIX__VERSION_1_2_DEPRECATED)
567 #define CL_API_PREFIX__VERSION_1_2_DEPRECATED
569 #if !defined(CL_API_SUFFIX__VERSION_1_2_DEPRECATED)
570 #define CL_API_SUFFIX__VERSION_1_2_DEPRECATED
573 #if !defined(CL_API_PREFIX__VERSION_2_2_DEPRECATED)
574 #define CL_API_PREFIX__VERSION_2_2_DEPRECATED
576 #if !defined(CL_API_SUFFIX__VERSION_2_2_DEPRECATED)
577 #define CL_API_SUFFIX__VERSION_2_2_DEPRECATED
580 #if !defined(CL_CALLBACK)
589 #include <functional>
593 #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY)
595 using size_type = ::size_t;
599 using size_type = size_t;
604 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
608 #if !defined(CL_HPP_NO_STD_VECTOR)
611 template <
class T,
class Alloc = std::allocator<T> >
612 using vector = std::vector<T, Alloc>;
616 #if !defined(CL_HPP_NO_STD_STRING)
619 using string = std::string;
623 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
625 #if !defined(CL_HPP_NO_STD_UNIQUE_PTR)
630 template<
class T,
class D>
631 using pointer = std::unique_ptr<T, D>;
635 #if !defined(CL_HPP_NO_STD_ARRAY)
638 template <
class T,
size_type N >
639 using array = std::array<T, N>;
645 #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY)
647 namespace compatibility {
662 for (
int i = 0; i < N; ++i) {
667 size_t(
const array<size_type, N> &rhs)
669 for (
int i = 0; i < N; ++i) {
674 size_type& operator[](
int index)
679 const size_type& operator[](
int index)
const
685 operator size_type* () {
return data_; }
688 operator const size_type* ()
const {
return data_; }
690 operator array<size_type, N>()
const
692 array<size_type, N> ret;
694 for (
int i = 0; i < N; ++i) {
703 using size_t = compatibility::size_t<N>;
710 using size_t_array = array<size_type, 3>;
723 #define CL_HPP_INIT_CL_EXT_FCN_PTR_(name) \
725 pfn_##name = (PFN_##name) \
726 clGetExtensionFunctionAddress(#name); \
731 #define CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, name) \
733 pfn_##name = (PFN_##name) \
734 clGetExtensionFunctionAddressForPlatform(platform, #name); \
743 class DeviceCommandQueue;
748 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
753 class Error :
public std::exception
757 const char * errStr_;
768 Error(cl_int err,
const char * errStr = NULL) : err_(err), errStr_(errStr)
777 virtual const char * what()
const throw ()
779 if (errStr_ == NULL) {
791 cl_int err(
void)
const {
return err_; }
793 #define CL_HPP_ERR_STR_(x) #x
795 #define CL_HPP_ERR_STR_(x) NULL
801 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
802 static inline cl_int errHandler (
804 const char * errStr = NULL)
806 if (err != CL_SUCCESS) {
807 throw Error(err, errStr);
812 static inline cl_int errHandler (cl_int err,
const char * errStr = NULL)
823 #if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS)
824 #define __GET_DEVICE_INFO_ERR CL_HPP_ERR_STR_(clGetDeviceInfo)
825 #define __GET_PLATFORM_INFO_ERR CL_HPP_ERR_STR_(clGetPlatformInfo)
826 #define __GET_DEVICE_IDS_ERR CL_HPP_ERR_STR_(clGetDeviceIDs)
827 #define __GET_PLATFORM_IDS_ERR CL_HPP_ERR_STR_(clGetPlatformIDs)
828 #define __GET_CONTEXT_INFO_ERR CL_HPP_ERR_STR_(clGetContextInfo)
829 #define __GET_EVENT_INFO_ERR CL_HPP_ERR_STR_(clGetEventInfo)
830 #define __GET_EVENT_PROFILE_INFO_ERR CL_HPP_ERR_STR_(clGetEventProfileInfo)
831 #define __GET_MEM_OBJECT_INFO_ERR CL_HPP_ERR_STR_(clGetMemObjectInfo)
832 #define __GET_IMAGE_INFO_ERR CL_HPP_ERR_STR_(clGetImageInfo)
833 #define __GET_SAMPLER_INFO_ERR CL_HPP_ERR_STR_(clGetSamplerInfo)
834 #define __GET_KERNEL_INFO_ERR CL_HPP_ERR_STR_(clGetKernelInfo)
835 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
836 #define __GET_KERNEL_ARG_INFO_ERR CL_HPP_ERR_STR_(clGetKernelArgInfo)
838 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
839 #define __GET_KERNEL_SUB_GROUP_INFO_ERR CL_HPP_ERR_STR_(clGetKernelSubGroupInfo)
841 #define __GET_KERNEL_WORK_GROUP_INFO_ERR CL_HPP_ERR_STR_(clGetKernelWorkGroupInfo)
842 #define __GET_PROGRAM_INFO_ERR CL_HPP_ERR_STR_(clGetProgramInfo)
843 #define __GET_PROGRAM_BUILD_INFO_ERR CL_HPP_ERR_STR_(clGetProgramBuildInfo)
844 #define __GET_COMMAND_QUEUE_INFO_ERR CL_HPP_ERR_STR_(clGetCommandQueueInfo)
846 #define __CREATE_CONTEXT_ERR CL_HPP_ERR_STR_(clCreateContext)
847 #define __CREATE_CONTEXT_FROM_TYPE_ERR CL_HPP_ERR_STR_(clCreateContextFromType)
848 #define __GET_SUPPORTED_IMAGE_FORMATS_ERR CL_HPP_ERR_STR_(clGetSupportedImageFormats)
850 #define __CREATE_BUFFER_ERR CL_HPP_ERR_STR_(clCreateBuffer)
851 #define __COPY_ERR CL_HPP_ERR_STR_(cl::copy)
852 #define __CREATE_SUBBUFFER_ERR CL_HPP_ERR_STR_(clCreateSubBuffer)
853 #define __CREATE_GL_BUFFER_ERR CL_HPP_ERR_STR_(clCreateFromGLBuffer)
854 #define __CREATE_GL_RENDER_BUFFER_ERR CL_HPP_ERR_STR_(clCreateFromGLBuffer)
855 #define __GET_GL_OBJECT_INFO_ERR CL_HPP_ERR_STR_(clGetGLObjectInfo)
856 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
857 #define __CREATE_IMAGE_ERR CL_HPP_ERR_STR_(clCreateImage)
858 #define __CREATE_GL_TEXTURE_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture)
859 #define __IMAGE_DIMENSION_ERR CL_HPP_ERR_STR_(Incorrect image dimensions)
861 #define __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR CL_HPP_ERR_STR_(clSetMemObjectDestructorCallback)
863 #define __CREATE_USER_EVENT_ERR CL_HPP_ERR_STR_(clCreateUserEvent)
864 #define __SET_USER_EVENT_STATUS_ERR CL_HPP_ERR_STR_(clSetUserEventStatus)
865 #define __SET_EVENT_CALLBACK_ERR CL_HPP_ERR_STR_(clSetEventCallback)
866 #define __WAIT_FOR_EVENTS_ERR CL_HPP_ERR_STR_(clWaitForEvents)
868 #define __CREATE_KERNEL_ERR CL_HPP_ERR_STR_(clCreateKernel)
869 #define __SET_KERNEL_ARGS_ERR CL_HPP_ERR_STR_(clSetKernelArg)
870 #define __CREATE_PROGRAM_WITH_SOURCE_ERR CL_HPP_ERR_STR_(clCreateProgramWithSource)
871 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
872 #define __CREATE_PROGRAM_WITH_IL_ERR CL_HPP_ERR_STR_(clCreateProgramWithIL)
874 #define __CREATE_PROGRAM_WITH_BINARY_ERR CL_HPP_ERR_STR_(clCreateProgramWithBinary)
875 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
876 #define __CREATE_PROGRAM_WITH_IL_ERR CL_HPP_ERR_STR_(clCreateProgramWithIL)
878 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
879 #define __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR CL_HPP_ERR_STR_(clCreateProgramWithBuiltInKernels)
881 #define __BUILD_PROGRAM_ERR CL_HPP_ERR_STR_(clBuildProgram)
882 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
883 #define __COMPILE_PROGRAM_ERR CL_HPP_ERR_STR_(clCompileProgram)
884 #define __LINK_PROGRAM_ERR CL_HPP_ERR_STR_(clLinkProgram)
886 #define __CREATE_KERNELS_IN_PROGRAM_ERR CL_HPP_ERR_STR_(clCreateKernelsInProgram)
888 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
889 #define __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR CL_HPP_ERR_STR_(clCreateCommandQueueWithProperties)
890 #define __CREATE_SAMPLER_WITH_PROPERTIES_ERR CL_HPP_ERR_STR_(clCreateSamplerWithProperties)
892 #define __SET_COMMAND_QUEUE_PROPERTY_ERR CL_HPP_ERR_STR_(clSetCommandQueueProperty)
893 #define __ENQUEUE_READ_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueReadBuffer)
894 #define __ENQUEUE_READ_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueReadBufferRect)
895 #define __ENQUEUE_WRITE_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueWriteBuffer)
896 #define __ENQUEUE_WRITE_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueWriteBufferRect)
897 #define __ENQEUE_COPY_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueCopyBuffer)
898 #define __ENQEUE_COPY_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueCopyBufferRect)
899 #define __ENQUEUE_FILL_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueFillBuffer)
900 #define __ENQUEUE_READ_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueReadImage)
901 #define __ENQUEUE_WRITE_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueWriteImage)
902 #define __ENQUEUE_COPY_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueCopyImage)
903 #define __ENQUEUE_FILL_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueFillImage)
904 #define __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueCopyImageToBuffer)
905 #define __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueCopyBufferToImage)
906 #define __ENQUEUE_MAP_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueMapBuffer)
907 #define __ENQUEUE_MAP_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueMapImage)
908 #define __ENQUEUE_UNMAP_MEM_OBJECT_ERR CL_HPP_ERR_STR_(clEnqueueUnMapMemObject)
909 #define __ENQUEUE_NDRANGE_KERNEL_ERR CL_HPP_ERR_STR_(clEnqueueNDRangeKernel)
910 #define __ENQUEUE_NATIVE_KERNEL CL_HPP_ERR_STR_(clEnqueueNativeKernel)
911 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
912 #define __ENQUEUE_MIGRATE_MEM_OBJECTS_ERR CL_HPP_ERR_STR_(clEnqueueMigrateMemObjects)
914 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
915 #define __ENQUEUE_MIGRATE_SVM_ERR CL_HPP_ERR_STR_(clEnqueueSVMMigrateMem)
916 #define __SET_DEFAULT_DEVICE_COMMAND_QUEUE_ERR CL_HPP_ERR_STR_(clSetDefaultDeviceCommandQueue)
920 #define __ENQUEUE_ACQUIRE_GL_ERR CL_HPP_ERR_STR_(clEnqueueAcquireGLObjects)
921 #define __ENQUEUE_RELEASE_GL_ERR CL_HPP_ERR_STR_(clEnqueueReleaseGLObjects)
923 #define __CREATE_PIPE_ERR CL_HPP_ERR_STR_(clCreatePipe)
924 #define __GET_PIPE_INFO_ERR CL_HPP_ERR_STR_(clGetPipeInfo)
927 #define __RETAIN_ERR CL_HPP_ERR_STR_(Retain Object)
928 #define __RELEASE_ERR CL_HPP_ERR_STR_(Release Object)
929 #define __FLUSH_ERR CL_HPP_ERR_STR_(clFlush)
930 #define __FINISH_ERR CL_HPP_ERR_STR_(clFinish)
931 #define __VECTOR_CAPACITY_ERR CL_HPP_ERR_STR_(Vector capacity error)
933 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
934 #define __GET_HOST_TIMER_ERR CL_HPP_ERR_STR_(clGetHostTimer)
935 #define __GET_DEVICE_AND_HOST_TIMER_ERR CL_HPP_ERR_STR_(clGetDeviceAndHostTimer)
937 #if CL_HPP_TARGET_OPENCL_VERSION >= 220
938 #define __SET_PROGRAM_RELEASE_CALLBACK_ERR CL_HPP_ERR_STR_(clSetProgramReleaseCallback)
939 #define __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR CL_HPP_ERR_STR_(clSetProgramSpecializationConstant)
946 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
947 #define __CREATE_SUB_DEVICES_ERR CL_HPP_ERR_STR_(clCreateSubDevices)
949 #define __CREATE_SUB_DEVICES_ERR CL_HPP_ERR_STR_(clCreateSubDevicesEXT)
955 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
956 #define __ENQUEUE_MARKER_ERR CL_HPP_ERR_STR_(clEnqueueMarker)
957 #define __ENQUEUE_WAIT_FOR_EVENTS_ERR CL_HPP_ERR_STR_(clEnqueueWaitForEvents)
958 #define __ENQUEUE_BARRIER_ERR CL_HPP_ERR_STR_(clEnqueueBarrier)
959 #define __UNLOAD_COMPILER_ERR CL_HPP_ERR_STR_(clUnloadCompiler)
960 #define __CREATE_GL_TEXTURE_2D_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture2D)
961 #define __CREATE_GL_TEXTURE_3D_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture3D)
962 #define __CREATE_IMAGE2D_ERR CL_HPP_ERR_STR_(clCreateImage2D)
963 #define __CREATE_IMAGE3D_ERR CL_HPP_ERR_STR_(clCreateImage3D)
969 #if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
970 #define __CREATE_COMMAND_QUEUE_ERR CL_HPP_ERR_STR_(clCreateCommandQueue)
971 #define __ENQUEUE_TASK_ERR CL_HPP_ERR_STR_(clEnqueueTask)
972 #define __CREATE_SAMPLER_ERR CL_HPP_ERR_STR_(clCreateSampler)
978 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
979 #define __ENQUEUE_MARKER_WAIT_LIST_ERR CL_HPP_ERR_STR_(clEnqueueMarkerWithWaitList)
980 #define __ENQUEUE_BARRIER_WAIT_LIST_ERR CL_HPP_ERR_STR_(clEnqueueBarrierWithWaitList)
983 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
984 #define __CLONE_KERNEL_ERR CL_HPP_ERR_STR_(clCloneKernel)
997 template<
typename Functor,
typename T>
998 inline cl_int getInfoHelper(Functor f, cl_uint name, T* param,
long)
1000 return f(name,
sizeof(T), param, NULL);
1005 template <
typename Func>
1006 inline cl_int getInfoHelper(Func f, cl_uint name, vector<vector<unsigned char>>* param,
int)
1008 if (name != CL_PROGRAM_BINARIES) {
1009 return CL_INVALID_VALUE;
1013 size_type numBinaries = param->size();
1014 vector<unsigned char*> binariesPointers(numBinaries);
1016 for (size_type i = 0; i < numBinaries; ++i)
1018 binariesPointers[i] = (*param)[i].data();
1021 cl_int err = f(name, numBinaries *
sizeof(
unsigned char*), binariesPointers.data(), NULL);
1023 if (err != CL_SUCCESS) {
1033 template <
typename Func,
typename T>
1034 inline cl_int getInfoHelper(Func f, cl_uint name, vector<T>* param,
long)
1037 cl_int err = f(name, 0, NULL, &required);
1038 if (err != CL_SUCCESS) {
1041 const size_type elements = required /
sizeof(T);
1044 vector<T> localData(elements);
1045 err = f(name, required, localData.data(), NULL);
1046 if (err != CL_SUCCESS) {
1050 *param = std::move(localData);
1062 template <
typename Func,
typename T>
1063 inline cl_int getInfoHelper(
1064 Func f, cl_uint name, vector<T>* param,
int,
typename T::cl_type = 0)
1067 cl_int err = f(name, 0, NULL, &required);
1068 if (err != CL_SUCCESS) {
1072 const size_type elements = required /
sizeof(
typename T::cl_type);
1074 vector<typename T::cl_type> value(elements);
1075 err = f(name, required, value.data(), NULL);
1076 if (err != CL_SUCCESS) {
1082 param->resize(elements);
1086 for (size_type i = 0; i < elements; i++) {
1087 (*param)[i] = T(value[i],
true);
1094 template <
typename Func>
1095 inline cl_int getInfoHelper(Func f, cl_uint name,
string* param,
long)
1098 cl_int err = f(name, 0, NULL, &required);
1099 if (err != CL_SUCCESS) {
1106 vector<char> value(required);
1107 err = f(name, required, value.data(), NULL);
1108 if (err != CL_SUCCESS) {
1112 param->assign(begin(value), prev(end(value)));
1122 template <
typename Func,
size_type N>
1123 inline cl_int getInfoHelper(Func f, cl_uint name, array<size_type, N>* param,
long)
1126 cl_int err = f(name, 0, NULL, &required);
1127 if (err != CL_SUCCESS) {
1131 size_type elements = required /
sizeof(size_type);
1132 vector<size_type> value(elements, 0);
1134 err = f(name, required, value.data(), NULL);
1135 if (err != CL_SUCCESS) {
1144 for (size_type i = 0; i < elements; ++i) {
1145 (*param)[i] = value[i];
1151 template<
typename T>
struct ReferenceHandler;
1159 template<
typename Func,
typename T>
1160 inline cl_int getInfoHelper(Func f, cl_uint name, T* param,
int,
typename T::cl_type = 0)
1162 typename T::cl_type value;
1163 cl_int err = f(name,
sizeof(value), &value, NULL);
1164 if (err != CL_SUCCESS) {
1170 err = param->retain();
1171 if (err != CL_SUCCESS) {
1178 #define CL_HPP_PARAM_NAME_INFO_1_0_(F) \
1179 F(cl_platform_info, CL_PLATFORM_PROFILE, string) \
1180 F(cl_platform_info, CL_PLATFORM_VERSION, string) \
1181 F(cl_platform_info, CL_PLATFORM_NAME, string) \
1182 F(cl_platform_info, CL_PLATFORM_VENDOR, string) \
1183 F(cl_platform_info, CL_PLATFORM_EXTENSIONS, string) \
1185 F(cl_device_info, CL_DEVICE_TYPE, cl_device_type) \
1186 F(cl_device_info, CL_DEVICE_VENDOR_ID, cl_uint) \
1187 F(cl_device_info, CL_DEVICE_MAX_COMPUTE_UNITS, cl_uint) \
1188 F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, cl_uint) \
1189 F(cl_device_info, CL_DEVICE_MAX_WORK_GROUP_SIZE, size_type) \
1190 F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_SIZES, cl::vector<size_type>) \
1191 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, cl_uint) \
1192 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT, cl_uint) \
1193 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT, cl_uint) \
1194 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG, cl_uint) \
1195 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT, cl_uint) \
1196 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, cl_uint) \
1197 F(cl_device_info, CL_DEVICE_MAX_CLOCK_FREQUENCY, cl_uint) \
1198 F(cl_device_info, CL_DEVICE_ADDRESS_BITS, cl_uint) \
1199 F(cl_device_info, CL_DEVICE_MAX_READ_IMAGE_ARGS, cl_uint) \
1200 F(cl_device_info, CL_DEVICE_MAX_WRITE_IMAGE_ARGS, cl_uint) \
1201 F(cl_device_info, CL_DEVICE_MAX_MEM_ALLOC_SIZE, cl_ulong) \
1202 F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_WIDTH, size_type) \
1203 F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_HEIGHT, size_type) \
1204 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_WIDTH, size_type) \
1205 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_HEIGHT, size_type) \
1206 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_DEPTH, size_type) \
1207 F(cl_device_info, CL_DEVICE_IMAGE_SUPPORT, cl_bool) \
1208 F(cl_device_info, CL_DEVICE_MAX_PARAMETER_SIZE, size_type) \
1209 F(cl_device_info, CL_DEVICE_MAX_SAMPLERS, cl_uint) \
1210 F(cl_device_info, CL_DEVICE_MEM_BASE_ADDR_ALIGN, cl_uint) \
1211 F(cl_device_info, CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE, cl_uint) \
1212 F(cl_device_info, CL_DEVICE_SINGLE_FP_CONFIG, cl_device_fp_config) \
1213 F(cl_device_info, CL_DEVICE_DOUBLE_FP_CONFIG, cl_device_fp_config) \
1214 F(cl_device_info, CL_DEVICE_HALF_FP_CONFIG, cl_device_fp_config) \
1215 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_TYPE, cl_device_mem_cache_type) \
1216 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE, cl_uint)\
1217 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_SIZE, cl_ulong) \
1218 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_SIZE, cl_ulong) \
1219 F(cl_device_info, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE, cl_ulong) \
1220 F(cl_device_info, CL_DEVICE_MAX_CONSTANT_ARGS, cl_uint) \
1221 F(cl_device_info, CL_DEVICE_LOCAL_MEM_TYPE, cl_device_local_mem_type) \
1222 F(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE, cl_ulong) \
1223 F(cl_device_info, CL_DEVICE_ERROR_CORRECTION_SUPPORT, cl_bool) \
1224 F(cl_device_info, CL_DEVICE_PROFILING_TIMER_RESOLUTION, size_type) \
1225 F(cl_device_info, CL_DEVICE_ENDIAN_LITTLE, cl_bool) \
1226 F(cl_device_info, CL_DEVICE_AVAILABLE, cl_bool) \
1227 F(cl_device_info, CL_DEVICE_COMPILER_AVAILABLE, cl_bool) \
1228 F(cl_device_info, CL_DEVICE_EXECUTION_CAPABILITIES, cl_device_exec_capabilities) \
1229 F(cl_device_info, CL_DEVICE_PLATFORM, cl_platform_id) \
1230 F(cl_device_info, CL_DEVICE_NAME, string) \
1231 F(cl_device_info, CL_DEVICE_VENDOR, string) \
1232 F(cl_device_info, CL_DRIVER_VERSION, string) \
1233 F(cl_device_info, CL_DEVICE_PROFILE, string) \
1234 F(cl_device_info, CL_DEVICE_VERSION, string) \
1235 F(cl_device_info, CL_DEVICE_EXTENSIONS, string) \
1237 F(cl_context_info, CL_CONTEXT_REFERENCE_COUNT, cl_uint) \
1238 F(cl_context_info, CL_CONTEXT_DEVICES, cl::vector<Device>) \
1239 F(cl_context_info, CL_CONTEXT_PROPERTIES, cl::vector<cl_context_properties>) \
1241 F(cl_event_info, CL_EVENT_COMMAND_QUEUE, cl::CommandQueue) \
1242 F(cl_event_info, CL_EVENT_COMMAND_TYPE, cl_command_type) \
1243 F(cl_event_info, CL_EVENT_REFERENCE_COUNT, cl_uint) \
1244 F(cl_event_info, CL_EVENT_COMMAND_EXECUTION_STATUS, cl_int) \
1246 F(cl_profiling_info, CL_PROFILING_COMMAND_QUEUED, cl_ulong) \
1247 F(cl_profiling_info, CL_PROFILING_COMMAND_SUBMIT, cl_ulong) \
1248 F(cl_profiling_info, CL_PROFILING_COMMAND_START, cl_ulong) \
1249 F(cl_profiling_info, CL_PROFILING_COMMAND_END, cl_ulong) \
1251 F(cl_mem_info, CL_MEM_TYPE, cl_mem_object_type) \
1252 F(cl_mem_info, CL_MEM_FLAGS, cl_mem_flags) \
1253 F(cl_mem_info, CL_MEM_SIZE, size_type) \
1254 F(cl_mem_info, CL_MEM_HOST_PTR, void*) \
1255 F(cl_mem_info, CL_MEM_MAP_COUNT, cl_uint) \
1256 F(cl_mem_info, CL_MEM_REFERENCE_COUNT, cl_uint) \
1257 F(cl_mem_info, CL_MEM_CONTEXT, cl::Context) \
1259 F(cl_image_info, CL_IMAGE_FORMAT, cl_image_format) \
1260 F(cl_image_info, CL_IMAGE_ELEMENT_SIZE, size_type) \
1261 F(cl_image_info, CL_IMAGE_ROW_PITCH, size_type) \
1262 F(cl_image_info, CL_IMAGE_SLICE_PITCH, size_type) \
1263 F(cl_image_info, CL_IMAGE_WIDTH, size_type) \
1264 F(cl_image_info, CL_IMAGE_HEIGHT, size_type) \
1265 F(cl_image_info, CL_IMAGE_DEPTH, size_type) \
1267 F(cl_sampler_info, CL_SAMPLER_REFERENCE_COUNT, cl_uint) \
1268 F(cl_sampler_info, CL_SAMPLER_CONTEXT, cl::Context) \
1269 F(cl_sampler_info, CL_SAMPLER_NORMALIZED_COORDS, cl_bool) \
1270 F(cl_sampler_info, CL_SAMPLER_ADDRESSING_MODE, cl_addressing_mode) \
1271 F(cl_sampler_info, CL_SAMPLER_FILTER_MODE, cl_filter_mode) \
1273 F(cl_program_info, CL_PROGRAM_REFERENCE_COUNT, cl_uint) \
1274 F(cl_program_info, CL_PROGRAM_CONTEXT, cl::Context) \
1275 F(cl_program_info, CL_PROGRAM_NUM_DEVICES, cl_uint) \
1276 F(cl_program_info, CL_PROGRAM_DEVICES, cl::vector<Device>) \
1277 F(cl_program_info, CL_PROGRAM_SOURCE, string) \
1278 F(cl_program_info, CL_PROGRAM_BINARY_SIZES, cl::vector<size_type>) \
1279 F(cl_program_info, CL_PROGRAM_BINARIES, cl::vector<cl::vector<unsigned char>>) \
1281 F(cl_program_build_info, CL_PROGRAM_BUILD_STATUS, cl_build_status) \
1282 F(cl_program_build_info, CL_PROGRAM_BUILD_OPTIONS, string) \
1283 F(cl_program_build_info, CL_PROGRAM_BUILD_LOG, string) \
1285 F(cl_kernel_info, CL_KERNEL_FUNCTION_NAME, string) \
1286 F(cl_kernel_info, CL_KERNEL_NUM_ARGS, cl_uint) \
1287 F(cl_kernel_info, CL_KERNEL_REFERENCE_COUNT, cl_uint) \
1288 F(cl_kernel_info, CL_KERNEL_CONTEXT, cl::Context) \
1289 F(cl_kernel_info, CL_KERNEL_PROGRAM, cl::Program) \
1291 F(cl_kernel_work_group_info, CL_KERNEL_WORK_GROUP_SIZE, size_type) \
1292 F(cl_kernel_work_group_info, CL_KERNEL_COMPILE_WORK_GROUP_SIZE, cl::detail::size_t_array) \
1293 F(cl_kernel_work_group_info, CL_KERNEL_LOCAL_MEM_SIZE, cl_ulong) \
1295 F(cl_command_queue_info, CL_QUEUE_CONTEXT, cl::Context) \
1296 F(cl_command_queue_info, CL_QUEUE_DEVICE, cl::Device) \
1297 F(cl_command_queue_info, CL_QUEUE_REFERENCE_COUNT, cl_uint) \
1298 F(cl_command_queue_info, CL_QUEUE_PROPERTIES, cl_command_queue_properties)
1301 #define CL_HPP_PARAM_NAME_INFO_1_1_(F) \
1302 F(cl_context_info, CL_CONTEXT_NUM_DEVICES, cl_uint)\
1303 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF, cl_uint) \
1304 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR, cl_uint) \
1305 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT, cl_uint) \
1306 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_INT, cl_uint) \
1307 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG, cl_uint) \
1308 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT, cl_uint) \
1309 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE, cl_uint) \
1310 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF, cl_uint) \
1311 F(cl_device_info, CL_DEVICE_OPENCL_C_VERSION, string) \
1313 F(cl_mem_info, CL_MEM_ASSOCIATED_MEMOBJECT, cl::Memory) \
1314 F(cl_mem_info, CL_MEM_OFFSET, size_type) \
1316 F(cl_kernel_work_group_info, CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, size_type) \
1317 F(cl_kernel_work_group_info, CL_KERNEL_PRIVATE_MEM_SIZE, cl_ulong) \
1319 F(cl_event_info, CL_EVENT_CONTEXT, cl::Context)
1321 #define CL_HPP_PARAM_NAME_INFO_1_2_(F) \
1322 F(cl_program_info, CL_PROGRAM_NUM_KERNELS, size_type) \
1323 F(cl_program_info, CL_PROGRAM_KERNEL_NAMES, string) \
1325 F(cl_program_build_info, CL_PROGRAM_BINARY_TYPE, cl_program_binary_type) \
1327 F(cl_kernel_info, CL_KERNEL_ATTRIBUTES, string) \
1329 F(cl_kernel_arg_info, CL_KERNEL_ARG_ADDRESS_QUALIFIER, cl_kernel_arg_address_qualifier) \
1330 F(cl_kernel_arg_info, CL_KERNEL_ARG_ACCESS_QUALIFIER, cl_kernel_arg_access_qualifier) \
1331 F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_NAME, string) \
1332 F(cl_kernel_arg_info, CL_KERNEL_ARG_NAME, string) \
1333 F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_QUALIFIER, cl_kernel_arg_type_qualifier) \
1335 F(cl_kernel_work_group_info, CL_KERNEL_GLOBAL_WORK_SIZE, cl::detail::size_t_array) \
1337 F(cl_device_info, CL_DEVICE_LINKER_AVAILABLE, cl_bool) \
1338 F(cl_device_info, CL_DEVICE_IMAGE_MAX_BUFFER_SIZE, size_type) \
1339 F(cl_device_info, CL_DEVICE_IMAGE_MAX_ARRAY_SIZE, size_type) \
1340 F(cl_device_info, CL_DEVICE_PARENT_DEVICE, cl::Device) \
1341 F(cl_device_info, CL_DEVICE_PARTITION_MAX_SUB_DEVICES, cl_uint) \
1342 F(cl_device_info, CL_DEVICE_PARTITION_PROPERTIES, cl::vector<cl_device_partition_property>) \
1343 F(cl_device_info, CL_DEVICE_PARTITION_TYPE, cl::vector<cl_device_partition_property>) \
1344 F(cl_device_info, CL_DEVICE_REFERENCE_COUNT, cl_uint) \
1345 F(cl_device_info, CL_DEVICE_PREFERRED_INTEROP_USER_SYNC, cl_bool) \
1346 F(cl_device_info, CL_DEVICE_PARTITION_AFFINITY_DOMAIN, cl_device_affinity_domain) \
1347 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS, string) \
1348 F(cl_device_info, CL_DEVICE_PRINTF_BUFFER_SIZE, size_type) \
1350 F(cl_image_info, CL_IMAGE_ARRAY_SIZE, size_type) \
1351 F(cl_image_info, CL_IMAGE_NUM_MIP_LEVELS, cl_uint) \
1352 F(cl_image_info, CL_IMAGE_NUM_SAMPLES, cl_uint)
1354 #define CL_HPP_PARAM_NAME_INFO_2_0_(F) \
1355 F(cl_device_info, CL_DEVICE_QUEUE_ON_HOST_PROPERTIES, cl_command_queue_properties) \
1356 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES, cl_command_queue_properties) \
1357 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE, cl_uint) \
1358 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE, cl_uint) \
1359 F(cl_device_info, CL_DEVICE_MAX_ON_DEVICE_QUEUES, cl_uint) \
1360 F(cl_device_info, CL_DEVICE_MAX_ON_DEVICE_EVENTS, cl_uint) \
1361 F(cl_device_info, CL_DEVICE_MAX_PIPE_ARGS, cl_uint) \
1362 F(cl_device_info, CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS, cl_uint) \
1363 F(cl_device_info, CL_DEVICE_PIPE_MAX_PACKET_SIZE, cl_uint) \
1364 F(cl_device_info, CL_DEVICE_SVM_CAPABILITIES, cl_device_svm_capabilities) \
1365 F(cl_device_info, CL_DEVICE_PREFERRED_PLATFORM_ATOMIC_ALIGNMENT, cl_uint) \
1366 F(cl_device_info, CL_DEVICE_PREFERRED_GLOBAL_ATOMIC_ALIGNMENT, cl_uint) \
1367 F(cl_device_info, CL_DEVICE_PREFERRED_LOCAL_ATOMIC_ALIGNMENT, cl_uint) \
1368 F(cl_device_info, CL_DEVICE_IMAGE_PITCH_ALIGNMENT, cl_uint) \
1369 F(cl_device_info, CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT, cl_uint) \
1370 F(cl_device_info, CL_DEVICE_MAX_READ_WRITE_IMAGE_ARGS, cl_uint ) \
1371 F(cl_device_info, CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE, size_type ) \
1372 F(cl_device_info, CL_DEVICE_GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE, size_type ) \
1373 F(cl_profiling_info, CL_PROFILING_COMMAND_COMPLETE, cl_ulong) \
1374 F(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM, cl_bool) \
1375 F(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_SVM_PTRS, void**) \
1376 F(cl_command_queue_info, CL_QUEUE_SIZE, cl_uint) \
1377 F(cl_mem_info, CL_MEM_USES_SVM_POINTER, cl_bool) \
1378 F(cl_program_build_info, CL_PROGRAM_BUILD_GLOBAL_VARIABLE_TOTAL_SIZE, size_type) \
1379 F(cl_pipe_info, CL_PIPE_PACKET_SIZE, cl_uint) \
1380 F(cl_pipe_info, CL_PIPE_MAX_PACKETS, cl_uint)
1382 #define CL_HPP_PARAM_NAME_INFO_SUBGROUP_KHR_(F) \
1383 F(cl_kernel_sub_group_info, CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE_KHR, size_type) \
1384 F(cl_kernel_sub_group_info, CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE_KHR, size_type)
1386 #define CL_HPP_PARAM_NAME_INFO_IL_KHR_(F) \
1387 F(cl_device_info, CL_DEVICE_IL_VERSION_KHR, string) \
1388 F(cl_program_info, CL_PROGRAM_IL_KHR, cl::vector<unsigned char>)
1390 #define CL_HPP_PARAM_NAME_INFO_2_1_(F) \
1391 F(cl_platform_info, CL_PLATFORM_HOST_TIMER_RESOLUTION, cl_ulong) \
1392 F(cl_program_info, CL_PROGRAM_IL, cl::vector<unsigned char>) \
1393 F(cl_device_info, CL_DEVICE_MAX_NUM_SUB_GROUPS, cl_uint) \
1394 F(cl_device_info, CL_DEVICE_IL_VERSION, string) \
1395 F(cl_device_info, CL_DEVICE_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS, cl_bool) \
1396 F(cl_command_queue_info, CL_QUEUE_DEVICE_DEFAULT, cl::DeviceCommandQueue) \
1397 F(cl_kernel_sub_group_info, CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE, size_type) \
1398 F(cl_kernel_sub_group_info, CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE, size_type) \
1399 F(cl_kernel_sub_group_info, CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT, cl::detail::size_t_array) \
1400 F(cl_kernel_sub_group_info, CL_KERNEL_MAX_NUM_SUB_GROUPS, size_type) \
1401 F(cl_kernel_sub_group_info, CL_KERNEL_COMPILE_NUM_SUB_GROUPS, size_type)
1403 #define CL_HPP_PARAM_NAME_INFO_2_2_(F) \
1404 F(cl_program_info, CL_PROGRAM_SCOPE_GLOBAL_CTORS_PRESENT, cl_bool) \
1405 F(cl_program_info, CL_PROGRAM_SCOPE_GLOBAL_DTORS_PRESENT, cl_bool)
1407 #define CL_HPP_PARAM_NAME_DEVICE_FISSION_(F) \
1408 F(cl_device_info, CL_DEVICE_PARENT_DEVICE_EXT, cl_device_id) \
1409 F(cl_device_info, CL_DEVICE_PARTITION_TYPES_EXT, cl::vector<cl_device_partition_property_ext>) \
1410 F(cl_device_info, CL_DEVICE_AFFINITY_DOMAINS_EXT, cl::vector<cl_device_partition_property_ext>) \
1411 F(cl_device_info, CL_DEVICE_REFERENCE_COUNT_EXT , cl_uint) \
1412 F(cl_device_info, CL_DEVICE_PARTITION_STYLE_EXT, cl::vector<cl_device_partition_property_ext>)
1414 #define CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_CL3_SHARED_(F) \
1415 F(cl_platform_info, CL_PLATFORM_NUMERIC_VERSION_KHR, cl_version_khr) \
1416 F(cl_platform_info, CL_PLATFORM_EXTENSIONS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>) \
1418 F(cl_device_info, CL_DEVICE_NUMERIC_VERSION_KHR, cl_version_khr) \
1419 F(cl_device_info, CL_DEVICE_EXTENSIONS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>) \
1420 F(cl_device_info, CL_DEVICE_ILS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>) \
1421 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>)
1423 #define CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_KHRONLY_(F) \
1424 F(cl_device_info, CL_DEVICE_OPENCL_C_NUMERIC_VERSION_KHR, cl_version_khr)
1426 #define CL_HPP_PARAM_NAME_INFO_3_0_(F) \
1427 F(cl_platform_info, CL_PLATFORM_NUMERIC_VERSION, cl_version) \
1428 F(cl_platform_info, CL_PLATFORM_EXTENSIONS_WITH_VERSION, cl::vector<cl_name_version>) \
1430 F(cl_device_info, CL_DEVICE_NUMERIC_VERSION, cl_version) \
1431 F(cl_device_info, CL_DEVICE_EXTENSIONS_WITH_VERSION, cl::vector<cl_name_version>) \
1432 F(cl_device_info, CL_DEVICE_ILS_WITH_VERSION, cl::vector<cl_name_version>) \
1433 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS_WITH_VERSION, cl::vector<cl_name_version>) \
1434 F(cl_device_info, CL_DEVICE_ATOMIC_MEMORY_CAPABILITIES, cl_device_atomic_capabilities) \
1435 F(cl_device_info, CL_DEVICE_ATOMIC_FENCE_CAPABILITIES, cl_device_atomic_capabilities) \
1436 F(cl_device_info, CL_DEVICE_NON_UNIFORM_WORK_GROUP_SUPPORT, cl_bool) \
1437 F(cl_device_info, CL_DEVICE_OPENCL_C_ALL_VERSIONS, cl::vector<cl_name_version>) \
1438 F(cl_device_info, CL_DEVICE_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, size_type) \
1439 F(cl_device_info, CL_DEVICE_WORK_GROUP_COLLECTIVE_FUNCTIONS_SUPPORT, cl_bool) \
1440 F(cl_device_info, CL_DEVICE_GENERIC_ADDRESS_SPACE_SUPPORT, cl_bool) \
1441 F(cl_device_info, CL_DEVICE_OPENCL_C_FEATURES, cl::vector<cl_name_version>) \
1442 F(cl_device_info, CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES, cl_device_device_enqueue_capabilities) \
1443 F(cl_device_info, CL_DEVICE_PIPE_SUPPORT, cl_bool) \
1444 F(cl_device_info, CL_DEVICE_LATEST_CONFORMANCE_VERSION_PASSED, string) \
1446 F(cl_command_queue_info, CL_QUEUE_PROPERTIES_ARRAY, cl::vector<cl_queue_properties>) \
1447 F(cl_mem_info, CL_MEM_PROPERTIES, cl::vector<cl_mem_properties>) \
1448 F(cl_pipe_info, CL_PIPE_PROPERTIES, cl::vector<cl_pipe_properties>) \
1449 F(cl_sampler_info, CL_SAMPLER_PROPERTIES, cl::vector<cl_sampler_properties>)
1451 template <
typename enum_type, cl_
int Name>
1454 #define CL_HPP_DECLARE_PARAM_TRAITS_(token, param_name, T) \
1457 struct param_traits<detail:: token,param_name> \
1459 enum { value = param_name }; \
1460 typedef T param_type; \
1463 CL_HPP_PARAM_NAME_INFO_1_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1464 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
1465 CL_HPP_PARAM_NAME_INFO_1_1_(CL_HPP_DECLARE_PARAM_TRAITS_)
1467 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
1468 CL_HPP_PARAM_NAME_INFO_1_2_(CL_HPP_DECLARE_PARAM_TRAITS_)
1470 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
1471 CL_HPP_PARAM_NAME_INFO_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1473 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
1474 CL_HPP_PARAM_NAME_INFO_2_1_(CL_HPP_DECLARE_PARAM_TRAITS_)
1476 #if CL_HPP_TARGET_OPENCL_VERSION >= 220
1477 CL_HPP_PARAM_NAME_INFO_2_2_(CL_HPP_DECLARE_PARAM_TRAITS_)
1479 #if CL_HPP_TARGET_OPENCL_VERSION >= 300
1480 CL_HPP_PARAM_NAME_INFO_3_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1483 #if defined(CL_HPP_USE_CL_SUB_GROUPS_KHR) && CL_HPP_TARGET_OPENCL_VERSION < 210
1484 CL_HPP_PARAM_NAME_INFO_SUBGROUP_KHR_(CL_HPP_DECLARE_PARAM_TRAITS_)
1487 #if defined(CL_HPP_USE_IL_KHR) && CL_HPP_TARGET_OPENCL_VERSION < 210
1488 CL_HPP_PARAM_NAME_INFO_IL_KHR_(CL_HPP_DECLARE_PARAM_TRAITS_)
1493 #define CL_HPP_PARAM_NAME_INFO_1_0_DEPRECATED_IN_2_0_(F) \
1494 F(cl_device_info, CL_DEVICE_QUEUE_PROPERTIES, cl_command_queue_properties)
1496 #define CL_HPP_PARAM_NAME_INFO_1_1_DEPRECATED_IN_2_0_(F) \
1497 F(cl_device_info, CL_DEVICE_HOST_UNIFIED_MEMORY, cl_bool)
1499 #define CL_HPP_PARAM_NAME_INFO_1_2_DEPRECATED_IN_2_0_(F) \
1500 F(cl_image_info, CL_IMAGE_BUFFER, cl::Buffer)
1504 #if CL_HPP_TARGET_OPENCL_VERSION > 100 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 && CL_HPP_TARGET_OPENCL_VERSION < 200
1505 CL_HPP_PARAM_NAME_INFO_1_0_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1507 #if CL_HPP_TARGET_OPENCL_VERSION > 110 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
1508 CL_HPP_PARAM_NAME_INFO_1_1_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1510 #if CL_HPP_TARGET_OPENCL_VERSION > 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
1511 CL_HPP_PARAM_NAME_INFO_1_2_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1514 #if defined(CL_HPP_USE_CL_DEVICE_FISSION)
1515 CL_HPP_PARAM_NAME_DEVICE_FISSION_(CL_HPP_DECLARE_PARAM_TRAITS_);
1518 #if defined(cl_khr_extended_versioning)
1519 #if CL_HPP_TARGET_OPENCL_VERSION < 300
1520 CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_CL3_SHARED_(CL_HPP_DECLARE_PARAM_TRAITS_)
1522 CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_KHRONLY_(CL_HPP_DECLARE_PARAM_TRAITS_)
1525 #if defined(cl_khr_device_uuid)
1526 using uuid_array = array<cl_uchar, CL_UUID_SIZE_KHR>;
1527 using luid_array = array<cl_uchar, CL_LUID_SIZE_KHR>;
1528 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_UUID_KHR, uuid_array)
1529 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DRIVER_UUID_KHR, uuid_array)
1530 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LUID_VALID_KHR, cl_bool)
1531 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LUID_KHR, luid_array)
1532 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_NODE_MASK_KHR, cl_uint)
1535 #if defined(cl_khr_pci_bus_info)
1536 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_PCI_BUS_INFO_KHR, cl_device_pci_bus_info_khr)
1539 #if defined(cl_khr_integer_dot_product)
1540 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGER_DOT_PRODUCT_CAPABILITIES_KHR, cl_device_integer_dot_product_capabilities_khr)
1541 #if defined(CL_DEVICE_INTEGER_DOT_PRODUCT_ACCELERATION_PROPERTIES_8BIT_KHR)
1542 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGER_DOT_PRODUCT_ACCELERATION_PROPERTIES_8BIT_KHR, cl_device_integer_dot_product_acceleration_properties_khr)
1543 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGER_DOT_PRODUCT_ACCELERATION_PROPERTIES_4x8BIT_PACKED_KHR, cl_device_integer_dot_product_acceleration_properties_khr)
1547 #ifdef CL_PLATFORM_ICD_SUFFIX_KHR
1548 CL_HPP_DECLARE_PARAM_TRAITS_(cl_platform_info, CL_PLATFORM_ICD_SUFFIX_KHR,
string)
1551 #ifdef CL_DEVICE_PROFILING_TIMER_OFFSET_AMD
1552 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_PROFILING_TIMER_OFFSET_AMD, cl_ulong)
1554 #ifdef CL_DEVICE_GLOBAL_FREE_MEMORY_AMD
1555 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_FREE_MEMORY_AMD, vector<size_type>)
1557 #ifdef CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD
1558 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD, cl_uint)
1560 #ifdef CL_DEVICE_SIMD_WIDTH_AMD
1561 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_WIDTH_AMD, cl_uint)
1563 #ifdef CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD
1564 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD, cl_uint)
1566 #ifdef CL_DEVICE_WAVEFRONT_WIDTH_AMD
1567 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_WAVEFRONT_WIDTH_AMD, cl_uint)
1569 #ifdef CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD
1570 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD, cl_uint)
1572 #ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD
1573 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD, cl_uint)
1575 #ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD
1576 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD, cl_uint)
1578 #ifdef CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD
1579 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD, cl_uint)
1581 #ifdef CL_DEVICE_LOCAL_MEM_BANKS_AMD
1582 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LOCAL_MEM_BANKS_AMD, cl_uint)
1584 #ifdef CL_DEVICE_BOARD_NAME_AMD
1585 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_BOARD_NAME_AMD,
string)
1588 #ifdef CL_DEVICE_COMPUTE_UNITS_BITFIELD_ARM
1589 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_UNITS_BITFIELD_ARM, cl_ulong)
1591 #ifdef CL_DEVICE_JOB_SLOTS_ARM
1592 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_JOB_SLOTS_ARM, cl_uint)
1594 #ifdef CL_DEVICE_SCHEDULING_CONTROLS_CAPABILITIES_ARM
1595 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SCHEDULING_CONTROLS_CAPABILITIES_ARM, cl_bitfield)
1597 #ifdef CL_DEVICE_SUPPORTED_REGISTER_ALLOCATIONS_ARM
1598 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SUPPORTED_REGISTER_ALLOCATIONS_ARM, vector<cl_uint>)
1600 #ifdef CL_DEVICE_MAX_WARP_COUNT_ARM
1601 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_MAX_WARP_COUNT_ARM, cl_uint)
1603 #ifdef CL_KERNEL_MAX_WARP_COUNT_ARM
1604 CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_info, CL_KERNEL_MAX_WARP_COUNT_ARM, cl_uint)
1606 #ifdef CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_ARM
1607 CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_ARM, cl_uint)
1609 #ifdef CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_MODIFIER_ARM
1610 CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_MODIFIER_ARM, cl_int)
1612 #ifdef CL_KERNEL_EXEC_INFO_WARP_COUNT_LIMIT_ARM
1613 CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_WARP_COUNT_LIMIT_ARM, cl_uint)
1615 #ifdef CL_KERNEL_EXEC_INFO_COMPUTE_UNIT_MAX_QUEUED_BATCHES_ARM
1616 CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_COMPUTE_UNIT_MAX_QUEUED_BATCHES_ARM, cl_uint)
1619 #ifdef CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV
1620 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV, cl_uint)
1622 #ifdef CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV
1623 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV, cl_uint)
1625 #ifdef CL_DEVICE_REGISTERS_PER_BLOCK_NV
1626 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_REGISTERS_PER_BLOCK_NV, cl_uint)
1628 #ifdef CL_DEVICE_WARP_SIZE_NV
1629 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_WARP_SIZE_NV, cl_uint)
1631 #ifdef CL_DEVICE_GPU_OVERLAP_NV
1632 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GPU_OVERLAP_NV, cl_bool)
1634 #ifdef CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV
1635 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV, cl_bool)
1637 #ifdef CL_DEVICE_INTEGRATED_MEMORY_NV
1638 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGRATED_MEMORY_NV, cl_bool)
1643 template <
typename Func,
typename T>
1645 getInfo(Func f, cl_uint name, T* param)
1647 return getInfoHelper(f, name, param, 0);
1650 template <
typename Func,
typename Arg0>
1653 Func f_;
const Arg0& arg0_;
1655 cl_uint param, size_type size,
void* value, size_type* size_ret)
1656 {
return f_(arg0_, param, size, value, size_ret); }
1659 template <
typename Func,
typename Arg0,
typename Arg1>
1662 Func f_;
const Arg0& arg0_;
const Arg1& arg1_;
1664 cl_uint param, size_type size,
void* value, size_type* size_ret)
1665 {
return f_(arg0_, arg1_, param, size, value, size_ret); }
1668 template <
typename Func,
typename Arg0,
typename T>
1670 getInfo(Func f,
const Arg0& arg0, cl_uint name, T* param)
1673 return getInfoHelper(f0, name, param, 0);
1676 template <
typename Func,
typename Arg0,
typename Arg1,
typename T>
1678 getInfo(Func f,
const Arg0& arg0,
const Arg1& arg1, cl_uint name, T* param)
1680 GetInfoFunctor1<Func, Arg0, Arg1> f0 = { f, arg0, arg1 };
1681 return getInfoHelper(f0, name, param, 0);
1685 template<
typename T>
1689 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
1706 { return ::clRetainDevice(device); }
1717 { return ::clReleaseDevice(device); }
1724 struct ReferenceHandler<cl_device_id>
1727 static cl_int retain(cl_device_id)
1728 {
return CL_SUCCESS; }
1730 static cl_int release(cl_device_id)
1731 {
return CL_SUCCESS; }
1739 static cl_int retain(cl_platform_id)
1740 {
return CL_SUCCESS; }
1742 static cl_int release(cl_platform_id)
1743 {
return CL_SUCCESS; }
1749 static cl_int retain(cl_context context)
1750 { return ::clRetainContext(context); }
1751 static cl_int release(cl_context context)
1752 { return ::clReleaseContext(context); }
1758 static cl_int retain(cl_command_queue queue)
1759 { return ::clRetainCommandQueue(queue); }
1760 static cl_int release(cl_command_queue queue)
1761 { return ::clReleaseCommandQueue(queue); }
1767 static cl_int retain(cl_mem memory)
1768 { return ::clRetainMemObject(memory); }
1769 static cl_int release(cl_mem memory)
1770 { return ::clReleaseMemObject(memory); }
1776 static cl_int retain(cl_sampler sampler)
1777 { return ::clRetainSampler(sampler); }
1778 static cl_int release(cl_sampler sampler)
1779 { return ::clReleaseSampler(sampler); }
1785 static cl_int retain(cl_program program)
1786 { return ::clRetainProgram(program); }
1787 static cl_int release(cl_program program)
1788 { return ::clReleaseProgram(program); }
1794 static cl_int retain(cl_kernel kernel)
1795 { return ::clRetainKernel(kernel); }
1796 static cl_int release(cl_kernel kernel)
1797 { return ::clReleaseKernel(kernel); }
1803 static cl_int retain(cl_event event)
1804 { return ::clRetainEvent(event); }
1805 static cl_int release(cl_event event)
1806 { return ::clReleaseEvent(event); }
1810 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
1812 static cl_uint getVersion(
const vector<char> &versionInfo)
1814 int highVersion = 0;
1817 while(versionInfo[index] !=
'.' ) {
1819 highVersion += versionInfo[index]-
'0';
1823 while(versionInfo[index] !=
' ' && versionInfo[index] !=
'\0') {
1825 lowVersion += versionInfo[index]-
'0';
1828 return (highVersion << 16) | lowVersion;
1831 static cl_uint getPlatformVersion(cl_platform_id platform)
1834 clGetPlatformInfo(platform, CL_PLATFORM_VERSION, 0, NULL, &size);
1836 vector<char> versionInfo(size);
1837 clGetPlatformInfo(platform, CL_PLATFORM_VERSION, size, versionInfo.data(), &size);
1838 return getVersion(versionInfo);
1841 static cl_uint getDevicePlatformVersion(cl_device_id device)
1843 cl_platform_id platform;
1844 clGetDeviceInfo(device, CL_DEVICE_PLATFORM,
sizeof(platform), &platform, NULL);
1845 return getPlatformVersion(platform);
1848 static cl_uint getContextPlatformVersion(cl_context context)
1853 clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, NULL, &size);
1856 vector<cl_device_id> devices(size/
sizeof(cl_device_id));
1857 clGetContextInfo(context, CL_CONTEXT_DEVICES, size, devices.data(), NULL);
1858 return getDevicePlatformVersion(devices[0]);
1862 template <
typename T>
1874 Wrapper(
const cl_type &obj,
bool retainObject) : object_(obj)
1877 detail::errHandler(retain(), __RETAIN_ERR);
1883 if (object_ != NULL) { release(); }
1888 object_ = rhs.object_;
1889 detail::errHandler(retain(), __RETAIN_ERR);
1894 object_ = rhs.object_;
1901 detail::errHandler(release(), __RELEASE_ERR);
1902 object_ = rhs.object_;
1903 detail::errHandler(retain(), __RETAIN_ERR);
1911 detail::errHandler(release(), __RELEASE_ERR);
1912 object_ = rhs.object_;
1920 detail::errHandler(release(), __RELEASE_ERR);
1925 const cl_type& operator ()()
const {
return object_; }
1927 cl_type& operator ()() {
return object_; }
1929 cl_type get()
const {
return object_; }
1932 template<
typename Func,
typename U>
1933 friend inline cl_int getInfoHelper(Func, cl_uint, U*,
int,
typename U::cl_type);
1935 cl_int retain()
const
1937 if (object_ !=
nullptr) {
1945 cl_int release()
const
1947 if (object_ !=
nullptr) {
1960 typedef cl_device_id cl_type;
1964 bool referenceCountable_;
1966 static bool isReferenceCountable(cl_device_id device)
1968 bool retVal =
false;
1969 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
1970 #if CL_HPP_MINIMUM_OPENCL_VERSION < 120
1971 if (device != NULL) {
1972 int version = getDevicePlatformVersion(device);
1973 if(version > ((1 << 16) + 1)) {
1986 Wrapper() : object_(NULL), referenceCountable_(
false)
1990 Wrapper(
const cl_type &obj,
bool retainObject) :
1992 referenceCountable_(
false)
1994 referenceCountable_ = isReferenceCountable(obj);
1997 detail::errHandler(retain(), __RETAIN_ERR);
2008 object_ = rhs.object_;
2009 referenceCountable_ = isReferenceCountable(object_);
2010 detail::errHandler(retain(), __RETAIN_ERR);
2015 object_ = rhs.object_;
2016 referenceCountable_ = rhs.referenceCountable_;
2018 rhs.referenceCountable_ =
false;
2024 detail::errHandler(release(), __RELEASE_ERR);
2025 object_ = rhs.object_;
2026 referenceCountable_ = rhs.referenceCountable_;
2027 detail::errHandler(retain(), __RETAIN_ERR);
2035 detail::errHandler(release(), __RELEASE_ERR);
2036 object_ = rhs.object_;
2037 referenceCountable_ = rhs.referenceCountable_;
2039 rhs.referenceCountable_ =
false;
2046 detail::errHandler(release(), __RELEASE_ERR);
2048 referenceCountable_ = isReferenceCountable(object_);
2052 const cl_type& operator ()()
const {
return object_; }
2054 cl_type& operator ()() {
return object_; }
2056 cl_type get()
const {
return object_; }
2059 template<
typename Func,
typename U>
2060 friend inline cl_int getInfoHelper(Func, cl_uint, U*,
int,
typename U::cl_type);
2062 template<
typename Func,
typename U>
2063 friend inline cl_int getInfoHelper(Func, cl_uint, vector<U>*,
int,
typename U::cl_type);
2065 cl_int retain()
const
2067 if( object_ !=
nullptr && referenceCountable_ ) {
2075 cl_int release()
const
2077 if (object_ !=
nullptr && referenceCountable_) {
2086 template <
typename T>
2089 return lhs() == rhs();
2092 template <
typename T>
2093 inline bool operator!=(
const Wrapper<T> &lhs,
const Wrapper<T> &rhs)
2095 return !operator==(lhs, rhs);
2118 image_channel_order = order;
2119 image_channel_data_type = type;
2129 this->image_channel_data_type = rhs.image_channel_data_type;
2130 this->image_channel_order = rhs.image_channel_order;
2146 static std::once_flag default_initialized_;
2148 static cl_int default_error_;
2155 static void makeDefault();
2162 static void makeDefaultProvided(
const Device &p) {
2167 #ifdef CL_HPP_UNIT_TEST_ENABLE
2174 static void unitTestClearDefault() {
2186 explicit Device(
const cl_device_id &device,
bool retainObject =
false) :
2187 detail::Wrapper<cl_type>(device, retainObject) { }
2194 cl_int *errResult = NULL)
2196 std::call_once(default_initialized_, makeDefault);
2197 detail::errHandler(default_error_);
2198 if (errResult != NULL) {
2199 *errResult = default_error_;
2213 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_device));
2214 detail::errHandler(default_error_);
2257 template <
typename T>
2258 cl_int
getInfo(cl_device_info name, T* param)
const
2260 return detail::errHandler(
2261 detail::getInfo(&::clGetDeviceInfo, object_, name, param),
2262 __GET_DEVICE_INFO_ERR);
2266 template <cl_device_info name>
typename
2271 detail::cl_device_info, name>::param_type param;
2272 cl_int result =
getInfo(name, ¶m);
2280 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
2289 cl_ulong retVal = 0;
2291 clGetHostTimer(this->get(), &retVal);
2294 __GET_HOST_TIMER_ERR);
2313 std::pair<cl_ulong, cl_ulong> retVal;
2315 clGetDeviceAndHostTimer(this->get(), &(retVal.first), &(retVal.second));
2318 __GET_DEVICE_AND_HOST_TIMER_ERR);
2329 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
2332 const cl_device_partition_property * properties,
2333 vector<Device>* devices)
2336 cl_int err = clCreateSubDevices(object_, properties, 0, NULL, &n);
2337 if (err != CL_SUCCESS) {
2338 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2341 vector<cl_device_id> ids(n);
2342 err = clCreateSubDevices(object_, properties, n, ids.data(), NULL);
2343 if (err != CL_SUCCESS) {
2344 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2350 devices->resize(ids.size());
2354 for (size_type i = 0; i < ids.size(); i++) {
2357 (*devices)[i] =
Device(ids[i],
false);
2363 #elif defined(CL_HPP_USE_CL_DEVICE_FISSION)
2369 const cl_device_partition_property_ext * properties,
2370 vector<Device>* devices)
2372 typedef CL_API_ENTRY cl_int
2373 ( CL_API_CALL * PFN_clCreateSubDevicesEXT)(
2375 const cl_device_partition_property_ext * ,
2378 cl_uint * ) CL_API_SUFFIX__VERSION_1_1;
2380 static PFN_clCreateSubDevicesEXT pfn_clCreateSubDevicesEXT = NULL;
2381 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateSubDevicesEXT);
2384 cl_int err = pfn_clCreateSubDevicesEXT(object_, properties, 0, NULL, &n);
2385 if (err != CL_SUCCESS) {
2386 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2389 vector<cl_device_id> ids(n);
2390 err = pfn_clCreateSubDevicesEXT(object_, properties, n, ids.data(), NULL);
2391 if (err != CL_SUCCESS) {
2392 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2397 devices->resize(ids.size());
2401 for (size_type i = 0; i < ids.size(); i++) {
2404 (*devices)[i] =
Device(ids[i],
false);
2412 using BuildLogType = vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, CL_PROGRAM_BUILD_LOG>::param_type>>;
2413 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
2417 class BuildError :
public Error
2420 BuildLogType buildLogs;
2422 BuildError(cl_int err,
const char * errStr,
const BuildLogType &vec) : Error(err, errStr), buildLogs(vec)
2426 BuildLogType getBuildLog()
const
2432 static inline cl_int buildErrHandler(
2434 const char * errStr,
2435 const BuildLogType &buildLogs)
2437 if (err != CL_SUCCESS) {
2438 throw BuildError(err, errStr, buildLogs);
2446 static inline cl_int buildErrHandler(
2448 const char * errStr,
2449 const BuildLogType &buildLogs)
2458 CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Device::default_initialized_;
2459 CL_HPP_DEFINE_STATIC_MEMBER_ Device Device::default_;
2460 CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Device::default_error_ = CL_SUCCESS;
2472 static std::once_flag default_initialized_;
2474 static cl_int default_error_;
2481 static void makeDefault() {
2485 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
2493 cl_int err = ::clGetPlatformIDs(0, NULL, &n);
2494 if (err != CL_SUCCESS) {
2495 default_error_ = err;
2499 default_error_ = CL_INVALID_PLATFORM;
2503 vector<cl_platform_id> ids(n);
2504 err = ::clGetPlatformIDs(n, ids.data(), NULL);
2505 if (err != CL_SUCCESS) {
2506 default_error_ = err;
2512 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
2513 catch (cl::Error &e) {
2514 default_error_ = e.err();
2524 static void makeDefaultProvided(
const Platform &p) {
2529 #ifdef CL_HPP_UNIT_TEST_ENABLE
2536 static void unitTestClearDefault() {
2551 explicit Platform(
const cl_platform_id &platform,
bool retainObject =
false) :
2552 detail::Wrapper<cl_type>(platform, retainObject) { }
2565 cl_int *errResult = NULL)
2567 std::call_once(default_initialized_, makeDefault);
2568 detail::errHandler(default_error_);
2569 if (errResult != NULL) {
2570 *errResult = default_error_;
2584 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_platform));
2585 detail::errHandler(default_error_);
2590 template <
typename T>
2591 cl_int
getInfo(cl_platform_info name, T* param)
const
2593 return detail::errHandler(
2594 detail::getInfo(&::clGetPlatformInfo, object_, name, param),
2595 __GET_PLATFORM_INFO_ERR);
2599 template <cl_platform_info name>
typename
2604 detail::cl_platform_info, name>::param_type param;
2605 cl_int result =
getInfo(name, ¶m);
2617 cl_device_type type,
2618 vector<Device>* devices)
const
2621 if( devices == NULL ) {
2622 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR);
2624 cl_int err = ::clGetDeviceIDs(object_, type, 0, NULL, &n);
2625 if (err != CL_SUCCESS && err != CL_DEVICE_NOT_FOUND) {
2626 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2629 vector<cl_device_id> ids(n);
2631 err = ::clGetDeviceIDs(object_, type, n, ids.data(), NULL);
2632 if (err != CL_SUCCESS) {
2633 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2642 devices->resize(ids.size());
2646 for (size_type i = 0; i < ids.size(); i++) {
2647 (*devices)[i] =
Device(ids[i],
true);
2653 #if defined(CL_HPP_USE_DX_INTEROP)
2678 cl_d3d10_device_source_khr d3d_device_source,
2680 cl_d3d10_device_set_khr d3d_device_set,
2681 vector<Device>* devices)
const
2683 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clGetDeviceIDsFromD3D10KHR)(
2684 cl_platform_id platform,
2685 cl_d3d10_device_source_khr d3d_device_source,
2687 cl_d3d10_device_set_khr d3d_device_set,
2688 cl_uint num_entries,
2689 cl_device_id * devices,
2690 cl_uint* num_devices);
2692 if( devices == NULL ) {
2693 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR);
2696 static PFN_clGetDeviceIDsFromD3D10KHR pfn_clGetDeviceIDsFromD3D10KHR = NULL;
2697 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(object_, clGetDeviceIDsFromD3D10KHR);
2700 cl_int err = pfn_clGetDeviceIDsFromD3D10KHR(
2708 if (err != CL_SUCCESS) {
2709 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2712 vector<cl_device_id> ids(n);
2713 err = pfn_clGetDeviceIDsFromD3D10KHR(
2721 if (err != CL_SUCCESS) {
2722 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2730 devices->resize(ids.size());
2734 for (size_type i = 0; i < ids.size(); i++) {
2735 (*devices)[i] = Device(ids[i],
true);
2747 vector<Platform>* platforms)
2751 if( platforms == NULL ) {
2752 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_PLATFORM_IDS_ERR);
2755 cl_int err = ::clGetPlatformIDs(0, NULL, &n);
2756 if (err != CL_SUCCESS) {
2757 return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
2760 vector<cl_platform_id> ids(n);
2761 err = ::clGetPlatformIDs(n, ids.data(), NULL);
2762 if (err != CL_SUCCESS) {
2763 return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
2767 platforms->resize(ids.size());
2770 for (size_type i = 0; i < ids.size(); i++) {
2771 (*platforms)[i] =
Platform(ids[i]);
2785 Platform default_platform = Platform::getDefault(&err);
2787 *platform = default_platform;
2801 cl_int * errResult = NULL)
2804 Platform default_platform = Platform::getDefault(&err);
2808 return default_platform;
2811 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
2816 return ::clUnloadPlatformCompiler(object_);
2821 CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Platform::default_initialized_;
2822 CL_HPP_DEFINE_STATIC_MEMBER_ Platform Platform::default_;
2823 CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Platform::default_error_ = CL_SUCCESS;
2829 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
2834 inline CL_API_PREFIX__VERSION_1_1_DEPRECATED cl_int
2839 return ::clUnloadCompiler();
2855 static std::once_flag default_initialized_;
2857 static cl_int default_error_;
2864 static void makeDefault() {
2868 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
2872 #if !defined(__APPLE__) && !defined(__MACOS)
2873 const Platform &p = Platform::getDefault();
2874 cl_platform_id defaultPlatform = p();
2875 cl_context_properties properties[3] = {
2876 CL_CONTEXT_PLATFORM, (cl_context_properties)defaultPlatform, 0
2879 cl_context_properties *properties =
nullptr;
2883 CL_DEVICE_TYPE_DEFAULT,
2889 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
2890 catch (cl::Error &e) {
2891 default_error_ = e.err();
2902 static void makeDefaultProvided(
const Context &c) {
2907 #ifdef CL_HPP_UNIT_TEST_ENABLE
2914 static void unitTestClearDefault() {
2924 const vector<Device>& devices,
2925 const cl_context_properties* properties = NULL,
2926 void (CL_CALLBACK * notifyFptr)(
2936 size_type numDevices = devices.size();
2937 vector<cl_device_id> deviceIDs(numDevices);
2939 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
2940 deviceIDs[deviceIndex] = (devices[deviceIndex])();
2943 object_ = ::clCreateContext(
2944 properties, (cl_uint) numDevices,
2946 notifyFptr, data, &error);
2948 detail::errHandler(error, __CREATE_CONTEXT_ERR);
2960 const cl_context_properties* properties = NULL,
2961 void (CL_CALLBACK * notifyFptr)(
2971 cl_device_id deviceID = device();
2973 object_ = ::clCreateContext(
2976 notifyFptr, data, &error);
2978 detail::errHandler(error, __CREATE_CONTEXT_ERR);
2989 cl_device_type type,
2990 const cl_context_properties* properties = NULL,
2991 void (CL_CALLBACK * notifyFptr)(
3001 #if !defined(__APPLE__) && !defined(__MACOS)
3002 cl_context_properties prop[4] = {CL_CONTEXT_PLATFORM, 0, 0, 0 };
3004 if (properties == NULL) {
3006 vector<Platform> platforms;
3007 error = Platform::get(&platforms);
3008 if (error != CL_SUCCESS) {
3009 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
3017 cl_context_properties platform_id = 0;
3018 for (
unsigned int i = 0; i < platforms.size(); i++) {
3020 vector<Device> devices;
3022 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
3026 error = platforms[i].getDevices(type, &devices);
3028 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
3029 }
catch (cl::Error& e) {
3037 if (error != CL_SUCCESS && error != CL_DEVICE_NOT_FOUND) {
3038 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
3044 if (devices.size() > 0) {
3045 platform_id = (cl_context_properties)platforms[i]();
3050 if (platform_id == 0) {
3051 detail::errHandler(CL_DEVICE_NOT_FOUND, __CREATE_CONTEXT_FROM_TYPE_ERR);
3053 *err = CL_DEVICE_NOT_FOUND;
3058 prop[1] = platform_id;
3059 properties = &prop[0];
3062 object_ = ::clCreateContextFromType(
3063 properties, type, notifyFptr, data, &error);
3065 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
3106 std::call_once(default_initialized_, makeDefault);
3107 detail::errHandler(default_error_);
3109 *err = default_error_;
3123 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_context));
3124 detail::errHandler(default_error_);
3136 explicit Context(
const cl_context& context,
bool retainObject =
false) :
3137 detail::Wrapper<cl_type>(context, retainObject) { }
3151 template <
typename T>
3152 cl_int
getInfo(cl_context_info name, T* param)
const
3154 return detail::errHandler(
3155 detail::getInfo(&::clGetContextInfo, object_, name, param),
3156 __GET_CONTEXT_INFO_ERR);
3160 template <cl_context_info name>
typename
3165 detail::cl_context_info, name>::param_type param;
3166 cl_int result =
getInfo(name, ¶m);
3179 cl_mem_object_type type,
3180 vector<ImageFormat>* formats)
const
3188 cl_int err = ::clGetSupportedImageFormats(
3195 if (err != CL_SUCCESS) {
3196 return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
3199 if (numEntries > 0) {
3200 vector<ImageFormat> value(numEntries);
3201 err = ::clGetSupportedImageFormats(
3206 (cl_image_format*)value.data(),
3208 if (err != CL_SUCCESS) {
3209 return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
3212 formats->assign(begin(value), end(value));
3223 inline void Device::makeDefault()
3228 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
3235 detail::errHandler(error, __CREATE_CONTEXT_ERR);
3237 if (error != CL_SUCCESS) {
3238 default_error_ = error;
3241 default_ = context.
getInfo<CL_CONTEXT_DEVICES>()[0];
3242 default_error_ = CL_SUCCESS;
3245 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
3246 catch (cl::Error &e) {
3247 default_error_ = e.err();
3252 CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Context::default_initialized_;
3253 CL_HPP_DEFINE_STATIC_MEMBER_ Context Context::default_;
3254 CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Context::default_error_ = CL_SUCCESS;
3268 Event() : detail::Wrapper<cl_type>() { }
3278 explicit Event(
const cl_event& event,
bool retainObject =
false) :
3279 detail::Wrapper<cl_type>(event, retainObject) { }
3293 template <
typename T>
3294 cl_int
getInfo(cl_event_info name, T* param)
const
3296 return detail::errHandler(
3297 detail::getInfo(&::clGetEventInfo, object_, name, param),
3298 __GET_EVENT_INFO_ERR);
3302 template <cl_event_info name>
typename
3307 detail::cl_event_info, name>::param_type param;
3308 cl_int result =
getInfo(name, ¶m);
3316 template <
typename T>
3319 return detail::errHandler(detail::getInfo(
3320 &::clGetEventProfilingInfo, object_, name, param),
3321 __GET_EVENT_PROFILE_INFO_ERR);
3325 template <cl_profiling_info name>
typename
3330 detail::cl_profiling_info, name>::param_type param;
3344 return detail::errHandler(
3345 ::clWaitForEvents(1, &object_),
3346 __WAIT_FOR_EVENTS_ERR);
3349 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
3356 void (CL_CALLBACK * pfn_notify)(cl_event, cl_int,
void *),
3357 void * user_data = NULL)
3359 return detail::errHandler(
3360 ::clSetEventCallback(
3365 __SET_EVENT_CALLBACK_ERR);
3376 return detail::errHandler(
3378 (cl_uint) events.size(), (events.size() > 0) ? (cl_event*)&events.front() : NULL),
3379 __WAIT_FOR_EVENTS_ERR);
3383 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
3397 cl_int * err = NULL)
3400 object_ = ::clCreateUserEvent(
3404 detail::errHandler(error, __CREATE_USER_EVENT_ERR);
3419 return detail::errHandler(
3420 ::clSetUserEventStatus(object_,status),
3421 __SET_USER_EVENT_STATUS_ERR);
3430 inline static cl_int
3431 WaitForEvents(
const vector<Event>& events)
3433 return detail::errHandler(
3435 (cl_uint) events.size(), (events.size() > 0) ? (cl_event*)&events.front() : NULL),
3436 __WAIT_FOR_EVENTS_ERR);
3464 explicit Memory(
const cl_mem& memory,
bool retainObject) :
3465 detail::Wrapper<cl_type>(memory, retainObject) { }
3508 template <
typename T>
3511 return detail::errHandler(
3512 detail::getInfo(&::clGetMemObjectInfo, object_, name, param),
3513 __GET_MEM_OBJECT_INFO_ERR);
3517 template <cl_mem_info name>
typename
3522 detail::cl_mem_info, name>::param_type param;
3523 cl_int result =
getInfo(name, ¶m);
3530 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
3545 void (CL_CALLBACK * pfn_notify)(cl_mem,
void *),
3546 void * user_data = NULL)
3548 return detail::errHandler(
3549 ::clSetMemObjectDestructorCallback(
3553 __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR);
3561 template<
typename IteratorType >
3562 cl_int
copy( IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer );
3563 template<
typename IteratorType >
3564 cl_int
copy(
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator );
3565 template<
typename IteratorType >
3566 cl_int
copy(
const CommandQueue &queue, IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer );
3567 template<
typename IteratorType >
3568 cl_int
copy(
const CommandQueue &queue,
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator );
3571 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
3577 static cl_svm_mem_flags getSVMMemFlags()
3584 template<
class Trait = detail::SVMTraitNull>
3588 static cl_svm_mem_flags getSVMMemFlags()
3590 return CL_MEM_READ_WRITE |
3591 Trait::getSVMMemFlags();
3595 template<
class Trait = detail::SVMTraitNull>
3599 static cl_svm_mem_flags getSVMMemFlags()
3601 return CL_MEM_READ_ONLY |
3602 Trait::getSVMMemFlags();
3606 template<
class Trait = detail::SVMTraitNull>
3610 static cl_svm_mem_flags getSVMMemFlags()
3612 return CL_MEM_WRITE_ONLY |
3613 Trait::getSVMMemFlags();
3617 template<
class Trait = SVMTraitReadWrite<>>
3621 static cl_svm_mem_flags getSVMMemFlags()
3623 return Trait::getSVMMemFlags();
3627 template<
class Trait = SVMTraitReadWrite<>>
3631 static cl_svm_mem_flags getSVMMemFlags()
3633 return CL_MEM_SVM_FINE_GRAIN_BUFFER |
3634 Trait::getSVMMemFlags();
3638 template<
class Trait = SVMTraitReadWrite<>>
3642 static cl_svm_mem_flags getSVMMemFlags()
3645 CL_MEM_SVM_FINE_GRAIN_BUFFER |
3646 CL_MEM_SVM_ATOMICS |
3647 Trait::getSVMMemFlags();
3652 template<
typename T>
3658 const vector<Event>* events = NULL,
3659 Event* event = NULL);
3672 template<
typename T,
class SVMTrait>
3678 typedef T value_type;
3679 typedef value_type* pointer;
3680 typedef const value_type* const_pointer;
3681 typedef value_type& reference;
3682 typedef const value_type& const_reference;
3683 typedef std::size_t size_type;
3684 typedef std::ptrdiff_t difference_type;
3686 template<
typename U>
3692 template<
typename U,
typename V>
3696 context_(
Context::getDefault())
3706 SVMAllocator(
const SVMAllocator &other) :
3707 context_(other.context_)
3711 template<
typename U>
3712 SVMAllocator(
const SVMAllocator<U, SVMTrait> &other) :
3713 context_(other.context_)
3721 pointer address(reference r) CL_HPP_NOEXCEPT_
3723 return std::addressof(r);
3726 const_pointer address(const_reference r) CL_HPP_NOEXCEPT_
3728 return std::addressof(r);
3745 SVMTrait::getSVMMemFlags(),
3748 pointer retValue =
reinterpret_cast<pointer
>(
3750 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
3752 std::bad_alloc excep;
3758 if (!(SVMTrait::getSVMMemFlags() & CL_MEM_SVM_FINE_GRAIN_BUFFER)) {
3759 cl_int err =
enqueueMapSVM(retValue, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE, size*
sizeof(T));
3760 if (err != CL_SUCCESS) {
3761 std::bad_alloc excep;
3770 void deallocate(pointer p, size_type)
3772 clSVMFree(context_(), p);
3781 size_type maxSize = std::numeric_limits<size_type>::max() /
sizeof(T);
3783 for (
const Device &d : context_.
getInfo<CL_CONTEXT_DEVICES>()) {
3786 static_cast<size_type
>(d.getInfo<CL_DEVICE_MAX_MEM_ALLOC_SIZE>()));
3792 template<
class U,
class... Args >
3793 void construct(U* p, Args&&... args)
3809 return (context_==rhs.context_);
3819 template<
class SVMTrait>
3822 typedef void value_type;
3823 typedef value_type* pointer;
3824 typedef const value_type* const_pointer;
3826 template<
typename U>
3832 template<
typename U,
typename V>
3836 #if !defined(CL_HPP_NO_STD_UNIQUE_PTR)
3839 template<
class Alloc>
3846 typedef typename std::allocator_traits<Alloc>::pointer pointer;
3848 Deleter(
const Alloc &alloc, size_type copies) : alloc_{ alloc }, copies_{ copies }
3852 void operator()(pointer ptr)
const {
3853 Alloc tmpAlloc{ alloc_ };
3854 std::allocator_traits<Alloc>::destroy(tmpAlloc, std::addressof(*ptr));
3855 std::allocator_traits<Alloc>::deallocate(tmpAlloc, ptr, copies_);
3866 template <
class T,
class Alloc,
class... Args>
3869 Alloc alloc(alloc_);
3870 static const size_type copies = 1;
3875 T* tmp = std::allocator_traits<Alloc>::allocate(alloc, copies);
3877 std::bad_alloc excep;
3881 std::allocator_traits<Alloc>::construct(
3883 std::addressof(*tmp),
3884 std::forward<Args>(args)...);
3888 catch (std::bad_alloc&)
3890 std::allocator_traits<Alloc>::deallocate(alloc, tmp, copies);
3895 template<
class T,
class SVMTrait,
class... Args >
3896 cl::pointer<T, detail::Deleter<SVMAllocator<T, SVMTrait>>> allocate_svm(Args... args)
3898 SVMAllocator<T, SVMTrait> alloc;
3899 return cl::allocate_pointer<T>(alloc, args...);
3902 template<
class T,
class SVMTrait,
class... Args >
3903 cl::pointer<T, detail::Deleter<SVMAllocator<T, SVMTrait>>> allocate_svm(
const cl::Context &c, Args... args)
3905 SVMAllocator<T, SVMTrait> alloc(c);
3906 return cl::allocate_pointer<T>(alloc, args...);
3913 template <
class T >
3919 template <
class T >
3925 template <
class T >
3952 void* host_ptr = NULL,
3956 object_ = ::clCreateBuffer(context(), flags, size, host_ptr, &error);
3958 detail::errHandler(error, __CREATE_BUFFER_ERR);
3976 void* host_ptr = NULL,
3983 object_ = ::clCreateBuffer(context(), flags, size, host_ptr, &error);
3985 detail::errHandler(error, __CREATE_BUFFER_ERR);
3996 template<
typename IteratorType >
3998 IteratorType startIterator,
3999 IteratorType endIterator,
4001 bool useHostPtr =
false,
4004 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
4007 cl_mem_flags flags = 0;
4009 flags |= CL_MEM_READ_ONLY;
4012 flags |= CL_MEM_READ_WRITE;
4015 flags |= CL_MEM_USE_HOST_PTR;
4018 size_type size =
sizeof(DataType)*(endIterator - startIterator);
4023 object_ = ::clCreateBuffer(context(), flags, size,
const_cast<DataType*
>(&*startIterator), &error);
4025 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
4028 detail::errHandler(error, __CREATE_BUFFER_ERR);
4034 error =
cl::copy(startIterator, endIterator, *
this);
4035 detail::errHandler(error, __CREATE_BUFFER_ERR);
4047 template<
typename IteratorType >
4048 Buffer(
const Context &context, IteratorType startIterator, IteratorType endIterator,
4049 bool readOnly,
bool useHostPtr =
false, cl_int* err = NULL);
4055 template<
typename IteratorType >
4056 Buffer(
const CommandQueue &queue, IteratorType startIterator, IteratorType endIterator,
4057 bool readOnly,
bool useHostPtr =
false, cl_int* err = NULL);
4069 explicit Buffer(
const cl_mem& buffer,
bool retainObject =
false) :
4070 Memory(buffer, retainObject) { }
4110 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
4117 cl_buffer_create_type buffer_create_type,
4118 const void * buffer_create_info,
4119 cl_int * err = NULL)
4123 result.object_ = ::clCreateSubBuffer(
4130 detail::errHandler(error, __CREATE_SUBBUFFER_ERR);
4140 #if defined (CL_HPP_USE_DX_INTEROP)
4149 class BufferD3D10 :
public Buffer
4160 const Context& context,
4162 ID3D10Buffer* bufobj,
4163 cl_int * err = NULL) : pfn_clCreateFromD3D10BufferKHR(nullptr)
4165 typedef CL_API_ENTRY cl_mem (CL_API_CALL *PFN_clCreateFromD3D10BufferKHR)(
4166 cl_context context, cl_mem_flags flags, ID3D10Buffer* buffer,
4167 cl_int* errcode_ret);
4168 PFN_clCreateFromD3D10BufferKHR pfn_clCreateFromD3D10BufferKHR;
4169 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
4170 vector<cl_context_properties> props = context.getInfo<CL_CONTEXT_PROPERTIES>();
4171 cl_platform platform = -1;
4172 for(
int i = 0; i < props.size(); ++i ) {
4173 if( props[i] == CL_CONTEXT_PLATFORM ) {
4174 platform = props[i+1];
4177 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCreateFromD3D10BufferKHR);
4178 #elif CL_HPP_TARGET_OPENCL_VERSION >= 110
4179 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateFromD3D10BufferKHR);
4183 object_ = pfn_clCreateFromD3D10BufferKHR(
4189 detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
4196 BufferD3D10() : Buffer() { }
4205 explicit BufferD3D10(
const cl_mem& buffer,
bool retainObject =
false) :
4206 Buffer(buffer, retainObject) { }
4212 BufferD3D10& operator = (
const cl_mem& rhs)
4221 BufferD3D10(
const BufferD3D10& buf) :
4227 BufferD3D10& operator = (
const BufferD3D10 &buf)
4236 BufferD3D10(BufferD3D10&& buf) CL_HPP_NOEXCEPT_ : Buffer(std::move(buf)) {}
4241 BufferD3D10& operator = (BufferD3D10 &&buf)
4269 cl_int * err = NULL)
4272 object_ = ::clCreateFromGLBuffer(
4278 detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
4294 explicit BufferGL(
const cl_mem& buffer,
bool retainObject =
false) :
4295 Buffer(buffer, retainObject) { }
4337 cl_gl_object_type *type,
4338 cl_GLuint * gl_object_name)
4340 return detail::errHandler(
4341 ::clGetGLObjectInfo(object_,type,gl_object_name),
4342 __GET_GL_OBJECT_INFO_ERR);
4366 cl_int * err = NULL)
4369 object_ = ::clCreateFromGLRenderbuffer(
4375 detail::errHandler(error, __CREATE_GL_RENDER_BUFFER_ERR);
4392 Buffer(buffer, retainObject) { }
4434 cl_gl_object_type *type,
4435 cl_GLuint * gl_object_name)
4437 return detail::errHandler(
4438 ::clGetGLObjectInfo(object_,type,gl_object_name),
4439 __GET_GL_OBJECT_INFO_ERR);
4462 explicit Image(
const cl_mem& image,
bool retainObject =
false) :
4463 Memory(image, retainObject) { }
4506 template <
typename T>
4509 return detail::errHandler(
4510 detail::getInfo(&::clGetImageInfo, object_, name, param),
4511 __GET_IMAGE_INFO_ERR);
4515 template <cl_image_info name>
typename
4520 detail::cl_image_info, name>::param_type param;
4529 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
4548 void* host_ptr = NULL,
4553 cl_image_desc desc = {0};
4554 desc.image_type = CL_MEM_OBJECT_IMAGE1D;
4555 desc.image_width = width;
4557 object_ = ::clCreateImage(
4565 detail::errHandler(error, __CREATE_IMAGE_ERR);
4581 explicit Image1D(
const cl_mem& image1D,
bool retainObject =
false) :
4582 Image(image1D, retainObject) { }
4640 cl_image_desc desc = {0};
4641 desc.image_type = CL_MEM_OBJECT_IMAGE1D_BUFFER;
4642 desc.image_width = width;
4643 desc.buffer = buffer();
4645 object_ = ::clCreateImage(
4653 detail::errHandler(error, __CREATE_IMAGE_ERR);
4669 Image(image1D, retainObject) { }
4717 size_type arraySize,
4720 void* host_ptr = NULL,
4725 cl_image_desc desc = {0};
4726 desc.image_type = CL_MEM_OBJECT_IMAGE1D_ARRAY;
4727 desc.image_width = width;
4728 desc.image_array_size = arraySize;
4729 desc.image_row_pitch = rowPitch;
4731 object_ = ::clCreateImage(
4739 detail::errHandler(error, __CREATE_IMAGE_ERR);
4754 explicit Image1DArray(
const cl_mem& imageArray,
bool retainObject =
false) :
4755 Image(imageArray, retainObject) { }
4815 size_type row_pitch = 0,
4816 void* host_ptr = NULL,
4820 bool useCreateImage;
4822 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
4825 cl_uint version = detail::getContextPlatformVersion(context());
4826 useCreateImage = (version >= 0x10002);
4828 #elif CL_HPP_TARGET_OPENCL_VERSION >= 120
4829 useCreateImage =
true;
4831 useCreateImage =
false;
4834 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
4837 cl_image_desc desc = {0};
4838 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
4839 desc.image_width = width;
4840 desc.image_height = height;
4841 desc.image_row_pitch = row_pitch;
4843 object_ = ::clCreateImage(
4851 detail::errHandler(error, __CREATE_IMAGE_ERR);
4857 #if CL_HPP_MINIMUM_OPENCL_VERSION < 120
4858 if (!useCreateImage)
4860 object_ = ::clCreateImage2D(
4861 context(), flags,&format, width, height, row_pitch, host_ptr, &error);
4863 detail::errHandler(error, __CREATE_IMAGE2D_ERR);
4871 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 || defined(CL_HPP_USE_CL_IMAGE2D_FROM_BUFFER_KHR)
4880 const Buffer &sourceBuffer,
4883 size_type row_pitch = 0,
4884 cl_int* err =
nullptr)
4888 cl_image_desc desc = {0};
4889 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
4890 desc.image_width = width;
4891 desc.image_height = height;
4892 desc.image_row_pitch = row_pitch;
4893 desc.buffer = sourceBuffer();
4895 object_ = ::clCreateImage(
4903 detail::errHandler(error, __CREATE_IMAGE_ERR);
4904 if (err !=
nullptr) {
4910 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
4925 cl_channel_order order,
4926 const Image &sourceImage,
4927 cl_int* err =
nullptr)
4932 size_type sourceWidth =
4934 size_type sourceHeight =
4936 size_type sourceRowPitch =
4938 cl_uint sourceNumMIPLevels =
4940 cl_uint sourceNumSamples =
4942 cl_image_format sourceFormat =
4947 sourceFormat.image_channel_order = order;
4949 cl_image_desc desc = {0};
4950 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
4951 desc.image_width = sourceWidth;
4952 desc.image_height = sourceHeight;
4953 desc.image_row_pitch = sourceRowPitch;
4954 desc.num_mip_levels = sourceNumMIPLevels;
4955 desc.num_samples = sourceNumSamples;
4956 desc.buffer = sourceImage();
4958 object_ = ::clCreateImage(
4966 detail::errHandler(error, __CREATE_IMAGE_ERR);
4967 if (err !=
nullptr) {
4983 explicit Image2D(
const cl_mem& image2D,
bool retainObject =
false) :
4984 Image(image2D, retainObject) { }
5027 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
5051 cl_int * err = NULL)
5054 object_ = ::clCreateFromGLTexture2D(
5062 detail::errHandler(error, __CREATE_GL_TEXTURE_2D_ERR);
5079 explicit Image2DGL(
const cl_mem& image,
bool retainObject =
false) :
5080 Image2D(image, retainObject) { }
5120 } CL_API_SUFFIX__VERSION_1_1_DEPRECATED;
5123 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
5134 size_type arraySize,
5138 size_type slicePitch,
5139 void* host_ptr = NULL,
5144 cl_image_desc desc = {0};
5145 desc.image_type = CL_MEM_OBJECT_IMAGE2D_ARRAY;
5146 desc.image_width = width;
5147 desc.image_height = height;
5148 desc.image_array_size = arraySize;
5149 desc.image_row_pitch = rowPitch;
5150 desc.image_slice_pitch = slicePitch;
5152 object_ = ::clCreateImage(
5160 detail::errHandler(error, __CREATE_IMAGE_ERR);
5175 explicit Image2DArray(
const cl_mem& imageArray,
bool retainObject =
false) :
Image(imageArray, retainObject) { }
5233 size_type row_pitch = 0,
5234 size_type slice_pitch = 0,
5235 void* host_ptr = NULL,
5239 bool useCreateImage;
5241 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
5244 cl_uint version = detail::getContextPlatformVersion(context());
5245 useCreateImage = (version >= 0x10002);
5247 #elif CL_HPP_TARGET_OPENCL_VERSION >= 120
5248 useCreateImage =
true;
5250 useCreateImage =
false;
5253 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
5256 cl_image_desc desc = {0};
5257 desc.image_type = CL_MEM_OBJECT_IMAGE3D;
5258 desc.image_width = width;
5259 desc.image_height = height;
5260 desc.image_depth = depth;
5261 desc.image_row_pitch = row_pitch;
5262 desc.image_slice_pitch = slice_pitch;
5264 object_ = ::clCreateImage(
5272 detail::errHandler(error, __CREATE_IMAGE_ERR);
5278 #if CL_HPP_MINIMUM_OPENCL_VERSION < 120
5279 if (!useCreateImage)
5281 object_ = ::clCreateImage3D(
5282 context(), flags, &format, width, height, depth, row_pitch,
5283 slice_pitch, host_ptr, &error);
5285 detail::errHandler(error, __CREATE_IMAGE3D_ERR);
5303 explicit Image3D(
const cl_mem& image3D,
bool retainObject =
false) :
5304 Image(image3D, retainObject) { }
5345 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
5368 cl_int * err = NULL)
5371 object_ = ::clCreateFromGLTexture3D(
5379 detail::errHandler(error, __CREATE_GL_TEXTURE_3D_ERR);
5395 explicit Image3DGL(
const cl_mem& image,
bool retainObject =
false) :
5396 Image3D(image, retainObject) { }
5438 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
5454 cl_int * err = NULL)
5457 object_ = ::clCreateFromGLTexture(
5465 detail::errHandler(error, __CREATE_GL_TEXTURE_ERR);
5480 explicit ImageGL(
const cl_mem& image,
bool retainObject =
false) :
5481 Image(image, retainObject) { }
5483 ImageGL& operator = (
const cl_mem& rhs)
5521 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
5543 cl_uint packet_size,
5544 cl_uint max_packets,
5549 cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS;
5550 object_ = ::clCreatePipe(context(), flags, packet_size, max_packets,
nullptr, &error);
5552 detail::errHandler(error, __CREATE_PIPE_ERR);
5567 cl_uint packet_size,
5568 cl_uint max_packets,
5575 cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS;
5576 object_ = ::clCreatePipe(context(), flags, packet_size, max_packets,
nullptr, &error);
5578 detail::errHandler(error, __CREATE_PIPE_ERR);
5594 explicit Pipe(
const cl_mem& pipe,
bool retainObject =
false) :
5595 Memory(pipe, retainObject) { }
5636 template <
typename T>
5639 return detail::errHandler(
5640 detail::getInfo(&::clGetPipeInfo, object_, name, param),
5641 __GET_PIPE_INFO_ERR);
5645 template <cl_pipe_info name>
typename
5650 detail::cl_pipe_info, name>::param_type param;
5651 cl_int result =
getInfo(name, ¶m);
5681 cl_bool normalized_coords,
5682 cl_addressing_mode addressing_mode,
5683 cl_filter_mode filter_mode,
5688 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
5689 cl_sampler_properties sampler_properties[] = {
5690 CL_SAMPLER_NORMALIZED_COORDS, normalized_coords,
5691 CL_SAMPLER_ADDRESSING_MODE, addressing_mode,
5692 CL_SAMPLER_FILTER_MODE, filter_mode,
5694 object_ = ::clCreateSamplerWithProperties(
5699 detail::errHandler(error, __CREATE_SAMPLER_WITH_PROPERTIES_ERR);
5704 object_ = ::clCreateSampler(
5711 detail::errHandler(error, __CREATE_SAMPLER_ERR);
5726 explicit Sampler(
const cl_sampler& sampler,
bool retainObject =
false) :
5727 detail::Wrapper<cl_type>(sampler, retainObject) { }
5769 template <
typename T>
5770 cl_int
getInfo(cl_sampler_info name, T* param)
const
5772 return detail::errHandler(
5773 detail::getInfo(&::clGetSamplerInfo, object_, name, param),
5774 __GET_SAMPLER_INFO_ERR);
5778 template <cl_sampler_info name>
typename
5783 detail::cl_sampler_info, name>::param_type param;
5784 cl_int result =
getInfo(name, ¶m);
5794 class DeviceCommandQueue;
5801 size_type sizes_[3];
5802 cl_uint dimensions_;
5833 NDRange(size_type size0, size_type size1, size_type size2)
5845 operator const size_type*()
const {
5859 return dimensions_*
sizeof(size_type);
5867 const size_type* get()
const
5874 static const NDRange NullRange;
5884 template <
typename T,
class Enable =
void>
5889 template <
typename T>
5892 static size_type size(
const T&) {
return sizeof(T); }
5893 static const T* ptr(
const T& value) {
return &value; }
5898 template <
typename T>
5901 static size_type size(
const T&) {
return sizeof(cl_mem); }
5902 static const cl_mem* ptr(
const T& value) {
return &(value()); }
5910 static size_type size(
const LocalSpaceArg& value) {
return value.size_; }
5911 static const void* ptr(
const LocalSpaceArg&) {
return NULL; }
5938 inline Kernel(
const Program& program,
const char* name, cl_int* err = NULL);
5951 explicit Kernel(
const cl_kernel& kernel,
bool retainObject =
false) :
5952 detail::Wrapper<cl_type>(kernel, retainObject) { }
5993 template <
typename T>
5994 cl_int getInfo(cl_kernel_info name, T* param)
const
5996 return detail::errHandler(
5997 detail::getInfo(&::clGetKernelInfo, object_, name, param),
5998 __GET_KERNEL_INFO_ERR);
6001 template <cl_kernel_info name>
typename
6002 detail::param_traits<detail::cl_kernel_info, name>::param_type
6003 getInfo(cl_int* err = NULL)
const
6005 typename detail::param_traits<
6006 detail::cl_kernel_info, name>::param_type param;
6007 cl_int result = getInfo(name, ¶m);
6014 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
6015 template <
typename T>
6016 cl_int getArgInfo(cl_uint argIndex, cl_kernel_arg_info name, T* param)
const
6018 return detail::errHandler(
6019 detail::getInfo(&::clGetKernelArgInfo, object_, argIndex, name, param),
6020 __GET_KERNEL_ARG_INFO_ERR);
6023 template <cl_kernel_arg_info name>
typename
6024 detail::param_traits<detail::cl_kernel_arg_info, name>::param_type
6025 getArgInfo(cl_uint argIndex, cl_int* err = NULL)
const
6027 typename detail::param_traits<
6028 detail::cl_kernel_arg_info, name>::param_type param;
6029 cl_int result = getArgInfo(argIndex, name, ¶m);
6037 template <
typename T>
6038 cl_int getWorkGroupInfo(
6039 const Device& device, cl_kernel_work_group_info name, T* param)
const
6041 return detail::errHandler(
6043 &::clGetKernelWorkGroupInfo, object_, device(), name, param),
6044 __GET_KERNEL_WORK_GROUP_INFO_ERR);
6047 template <cl_kernel_work_group_info name>
typename
6048 detail::param_traits<detail::cl_kernel_work_group_info, name>::param_type
6049 getWorkGroupInfo(
const Device& device, cl_int* err = NULL)
const
6051 typename detail::param_traits<
6052 detail::cl_kernel_work_group_info, name>::param_type param;
6053 cl_int result = getWorkGroupInfo(device, name, ¶m);
6060 #if (CL_HPP_TARGET_OPENCL_VERSION >= 200 && defined(CL_HPP_USE_CL_SUB_GROUPS_KHR)) || CL_HPP_TARGET_OPENCL_VERSION >= 210
6061 cl_int getSubGroupInfo(
const cl::Device &dev, cl_kernel_sub_group_info name,
const cl::NDRange &range, size_type* param)
const
6063 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
6065 return detail::errHandler(
6066 clGetKernelSubGroupInfo(object_, dev(), name, range.
size(), range.get(),
sizeof(size_type), param,
nullptr),
6067 __GET_KERNEL_SUB_GROUP_INFO_ERR);
6071 typedef clGetKernelSubGroupInfoKHR_fn PFN_clGetKernelSubGroupInfoKHR;
6072 static PFN_clGetKernelSubGroupInfoKHR pfn_clGetKernelSubGroupInfoKHR = NULL;
6073 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetKernelSubGroupInfoKHR);
6075 return detail::errHandler(
6076 pfn_clGetKernelSubGroupInfoKHR(object_, dev(), name, range.
size(), range.get(),
sizeof(size_type), param,
nullptr),
6077 __GET_KERNEL_SUB_GROUP_INFO_ERR);
6082 template <cl_kernel_sub_group_info name>
6083 size_type getSubGroupInfo(
const cl::Device &dev,
const cl::NDRange &range, cl_int* err = NULL)
const
6086 cl_int result = getSubGroupInfo(dev, name, range, ¶m);
6094 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
6097 template<
typename T,
class D>
6098 cl_int
setArg(cl_uint index,
const cl::pointer<T, D> &argPtr)
6100 return detail::errHandler(
6101 ::clSetKernelArgSVMPointer(object_, index, argPtr.get()),
6102 __SET_KERNEL_ARGS_ERR);
6107 template<
typename T,
class Alloc>
6108 cl_int
setArg(cl_uint index,
const cl::vector<T, Alloc> &argPtr)
6110 return detail::errHandler(
6111 ::clSetKernelArgSVMPointer(object_, index, argPtr.data()),
6112 __SET_KERNEL_ARGS_ERR);
6117 template<
typename T>
6118 typename std::enable_if<std::is_pointer<T>::value, cl_int>::type
6121 return detail::errHandler(
6122 ::clSetKernelArgSVMPointer(object_, index, argPtr),
6123 __SET_KERNEL_ARGS_ERR);
6129 template <
typename T>
6130 typename std::enable_if<!std::is_pointer<T>::value, cl_int>::type
6133 return detail::errHandler(
6139 __SET_KERNEL_ARGS_ERR);
6142 cl_int
setArg(cl_uint index, size_type size,
const void* argPtr)
6144 return detail::errHandler(
6145 ::clSetKernelArg(object_, index, size, argPtr),
6146 __SET_KERNEL_ARGS_ERR);
6149 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
6156 return detail::errHandler(
6157 ::clSetKernelExecInfo(
6159 CL_KERNEL_EXEC_INFO_SVM_PTRS,
6160 sizeof(
void*)*pointerList.size(),
6161 pointerList.data()));
6168 template<
int ArrayLength>
6171 return detail::errHandler(
6172 ::clSetKernelExecInfo(
6174 CL_KERNEL_EXEC_INFO_SVM_PTRS,
6175 sizeof(
void*)*pointerList.size(),
6176 pointerList.data()));
6192 cl_bool svmEnabled_ = svmEnabled ? CL_TRUE : CL_FALSE;
6193 return detail::errHandler(
6194 ::clSetKernelExecInfo(
6196 CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM,
6203 template<
int index,
int ArrayLength,
class D,
typename T0,
typename T1,
typename... Ts>
6204 void setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList,
const pointer<T0, D> &t0,
const pointer<T1, D> &t1, Ts & ... ts)
6206 pointerList[index] =
static_cast<void*
>(t0.get());
6207 setSVMPointersHelper<index + 1, ArrayLength>(pointerList, t1, ts...);
6210 template<
int index,
int ArrayLength,
typename T0,
typename T1,
typename... Ts>
6211 typename std::enable_if<std::is_pointer<T0>::value,
void>::type
6212 setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList, T0 t0, T1 t1, Ts... ts)
6214 pointerList[index] =
static_cast<void*
>(t0);
6215 setSVMPointersHelper<index + 1, ArrayLength>(pointerList, t1, ts...);
6218 template<
int index,
int ArrayLength,
typename T0,
class D>
6219 void setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList,
const pointer<T0, D> &t0)
6221 pointerList[index] =
static_cast<void*
>(t0.get());
6225 template<
int index,
int ArrayLength,
typename T0>
6226 typename std::enable_if<std::is_pointer<T0>::value,
void>::type
6227 setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList, T0 t0)
6229 pointerList[index] =
static_cast<void*
>(t0);
6232 template<
typename T0,
typename... Ts>
6235 std::array<
void*, 1 +
sizeof...(Ts)> pointerList;
6237 setSVMPointersHelper<0, 1 +
sizeof...(Ts)>(pointerList, t0, ts...);
6238 return detail::errHandler(
6239 ::clSetKernelExecInfo(
6241 CL_KERNEL_EXEC_INFO_SVM_PTRS,
6242 sizeof(
void*)*(1 +
sizeof...(Ts)),
6243 pointerList.data()));
6246 template<
typename T>
6247 cl_int setExecInfo(cl_kernel_exec_info param_name,
const T& val)
6249 return detail::errHandler(
6250 ::clSetKernelExecInfo(
6257 template<cl_kernel_exec_info name>
6258 cl_int setExecInfo(
typename detail::param_traits<detail::cl_kernel_exec_info, name>::param_type& val)
6260 return setExecInfo(name, val);
6264 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
6273 Kernel retValue(clCloneKernel(this->get(), &error));
6275 detail::errHandler(error, __CLONE_KERNEL_ERR);
6287 #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6288 typedef vector<vector<unsigned char>> Binaries;
6289 typedef vector<string> Sources;
6291 typedef vector<std::pair<const void*, size_type> > Binaries;
6292 typedef vector<std::pair<const char*, size_type> > Sources;
6296 const string& source,
6302 const char * strings = source.c_str();
6303 const size_type length = source.size();
6307 object_ = ::clCreateProgramWithSource(
6308 context(), (cl_uint)1, &strings, &length, &error);
6310 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6312 if (error == CL_SUCCESS && build) {
6314 error = ::clBuildProgram(
6318 #
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6326 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6336 const string& source,
6342 const char * strings = source.c_str();
6343 const size_type length = source.size();
6345 object_ = ::clCreateProgramWithSource(
6346 context(), (cl_uint)1, &strings, &length, &error);
6348 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6350 if (error == CL_SUCCESS && build) {
6351 error = ::clBuildProgram(
6355 #
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6363 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6376 const Sources& sources,
6382 const size_type n = (size_type)sources.size();
6384 vector<size_type> lengths(n);
6385 vector<const char*> strings(n);
6387 for (size_type i = 0; i < n; ++i) {
6388 #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6389 strings[i] = sources[(int)i].data();
6390 lengths[i] = sources[(int)i].length();
6392 strings[i] = sources[(int)i].first;
6393 lengths[i] = sources[(int)i].second;
6397 object_ = ::clCreateProgramWithSource(
6398 context(), (cl_uint)n, strings.data(), lengths.data(), &error);
6400 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6412 const Sources& sources,
6417 const size_type n = (size_type)sources.size();
6419 vector<size_type> lengths(n);
6420 vector<const char*> strings(n);
6422 for (size_type i = 0; i < n; ++i) {
6423 #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6424 strings[i] = sources[(int)i].data();
6425 lengths[i] = sources[(int)i].length();
6427 strings[i] = sources[(int)i].first;
6428 lengths[i] = sources[(int)i].second;
6432 object_ = ::clCreateProgramWithSource(
6433 context(), (cl_uint)n, strings.data(), lengths.data(), &error);
6435 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6442 #if CL_HPP_TARGET_OPENCL_VERSION >= 210 || (CL_HPP_TARGET_OPENCL_VERSION==200 && defined(CL_HPP_USE_IL_KHR))
6448 const vector<char>& IL,
6456 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
6458 object_ = ::clCreateProgramWithIL(
6459 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6463 typedef clCreateProgramWithILKHR_fn PFN_clCreateProgramWithILKHR;
6464 static PFN_clCreateProgramWithILKHR pfn_clCreateProgramWithILKHR = NULL;
6465 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateProgramWithILKHR);
6467 object_ = pfn_clCreateProgramWithILKHR(
6468 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6472 detail::errHandler(error, __CREATE_PROGRAM_WITH_IL_ERR);
6474 if (error == CL_SUCCESS && build) {
6476 error = ::clBuildProgram(
6480 #
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6488 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6503 const vector<char>& IL,
6509 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
6511 object_ = ::clCreateProgramWithIL(
6512 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6516 typedef clCreateProgramWithILKHR_fn PFN_clCreateProgramWithILKHR;
6517 static PFN_clCreateProgramWithILKHR pfn_clCreateProgramWithILKHR = NULL;
6518 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateProgramWithILKHR);
6520 object_ = pfn_clCreateProgramWithILKHR(
6521 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6525 detail::errHandler(error, __CREATE_PROGRAM_WITH_IL_ERR);
6527 if (error == CL_SUCCESS && build) {
6528 error = ::clBuildProgram(
6532 #
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6540 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6570 const vector<Device>& devices,
6571 const Binaries& binaries,
6572 vector<cl_int>* binaryStatus = NULL,
6577 const size_type numDevices = devices.size();
6580 if(binaries.size() != numDevices) {
6581 error = CL_INVALID_VALUE;
6582 detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
6590 vector<size_type> lengths(numDevices);
6591 vector<const unsigned char*> images(numDevices);
6592 #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6593 for (size_type i = 0; i < numDevices; ++i) {
6594 images[i] = binaries[i].data();
6595 lengths[i] = binaries[(int)i].size();
6598 for (size_type i = 0; i < numDevices; ++i) {
6599 images[i] = (
const unsigned char*)binaries[i].first;
6600 lengths[i] = binaries[(int)i].second;
6604 vector<cl_device_id> deviceIDs(numDevices);
6605 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6606 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6610 binaryStatus->resize(numDevices);
6613 object_ = ::clCreateProgramWithBinary(
6614 context(), (cl_uint) devices.size(),
6616 lengths.data(), images.data(), (binaryStatus != NULL && numDevices > 0)
6617 ? &binaryStatus->front()
6620 detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
6627 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
6634 const vector<Device>& devices,
6635 const string& kernelNames,
6641 size_type numDevices = devices.size();
6642 vector<cl_device_id> deviceIDs(numDevices);
6643 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6644 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6647 object_ = ::clCreateProgramWithBuiltInKernels(
6649 (cl_uint) devices.size(),
6651 kernelNames.c_str(),
6654 detail::errHandler(error, __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR);
6670 explicit Program(
const cl_program& program,
bool retainObject =
false) :
6671 detail::Wrapper<cl_type>(program, retainObject) { }
6673 Program& operator = (
const cl_program& rhs)
6708 const vector<Device>& devices,
6709 const char* options = NULL,
6710 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6711 void* data = NULL)
const
6713 size_type numDevices = devices.size();
6714 vector<cl_device_id> deviceIDs(numDevices);
6716 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6717 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6720 cl_int buildError = ::clBuildProgram(
6729 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6733 const Device& device,
6734 const char* options = NULL,
6735 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6736 void* data = NULL)
const
6738 cl_device_id deviceID = device();
6740 cl_int buildError = ::clBuildProgram(
6748 BuildLogType buildLog(0);
6749 buildLog.push_back(std::make_pair(device, getBuildInfo<CL_PROGRAM_BUILD_LOG>(device)));
6750 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, buildLog);
6754 const char* options = NULL,
6755 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6756 void* data = NULL)
const
6758 cl_int buildError = ::clBuildProgram(
6766 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6769 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
6771 const char* options = NULL,
6772 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6773 void* data = NULL)
const
6775 cl_int error = ::clCompileProgram(
6785 return detail::buildErrHandler(error, __COMPILE_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6789 template <
typename T>
6790 cl_int getInfo(cl_program_info name, T* param)
const
6792 return detail::errHandler(
6793 detail::getInfo(&::clGetProgramInfo, object_, name, param),
6794 __GET_PROGRAM_INFO_ERR);
6797 template <cl_program_info name>
typename
6798 detail::param_traits<detail::cl_program_info, name>::param_type
6799 getInfo(cl_int* err = NULL)
const
6801 typename detail::param_traits<
6802 detail::cl_program_info, name>::param_type param;
6803 cl_int result = getInfo(name, ¶m);
6810 template <
typename T>
6811 cl_int getBuildInfo(
6812 const Device& device, cl_program_build_info name, T* param)
const
6814 return detail::errHandler(
6816 &::clGetProgramBuildInfo, object_, device(), name, param),
6817 __GET_PROGRAM_BUILD_INFO_ERR);
6820 template <cl_program_build_info name>
typename
6821 detail::param_traits<detail::cl_program_build_info, name>::param_type
6822 getBuildInfo(
const Device& device, cl_int* err = NULL)
const
6824 typename detail::param_traits<
6825 detail::cl_program_build_info, name>::param_type param;
6826 cl_int result = getBuildInfo(device, name, ¶m);
6838 template <cl_program_build_info name>
6839 vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, name>::param_type>>
6842 cl_int result = CL_SUCCESS;
6844 auto devs = getInfo<CL_PROGRAM_DEVICES>(&result);
6845 vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, name>::param_type>>
6849 if (result != CL_SUCCESS) {
6858 detail::cl_program_build_info, name>::param_type param;
6859 result = getBuildInfo(d, name, ¶m);
6863 if (result != CL_SUCCESS) {
6871 if (result != CL_SUCCESS) {
6877 cl_int createKernels(vector<Kernel>* kernels)
6880 cl_int err = ::clCreateKernelsInProgram(object_, 0, NULL, &numKernels);
6881 if (err != CL_SUCCESS) {
6882 return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
6885 vector<cl_kernel> value(numKernels);
6887 err = ::clCreateKernelsInProgram(
6888 object_, numKernels, value.data(), NULL);
6889 if (err != CL_SUCCESS) {
6890 return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
6894 kernels->resize(value.size());
6898 for (size_type i = 0; i < value.size(); i++) {
6901 (*kernels)[i] = Kernel(value[i],
false);
6907 #if CL_HPP_TARGET_OPENCL_VERSION >= 220
6908 #if defined(CL_USE_DEPRECATED_OPENCL_2_2_APIS)
6920 void (CL_CALLBACK * pfn_notify)(cl_program program,
void * user_data),
6921 void * user_data = NULL) CL_API_SUFFIX__VERSION_2_2_DEPRECATED
6923 return detail::errHandler(
6924 ::clSetProgramReleaseCallback(
6928 __SET_PROGRAM_RELEASE_CALLBACK_ERR);
6936 template <
typename T>
6937 typename std::enable_if<!std::is_pointer<T>::value, cl_int>::type
6940 return detail::errHandler(
6941 ::clSetProgramSpecializationConstant(
6946 __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR);
6955 return detail::errHandler(
6956 ::clSetProgramSpecializationConstant(
6961 __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR);
6966 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
6967 inline Program linkProgram(
6970 const char* options = NULL,
6971 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6975 cl_int error_local = CL_SUCCESS;
6977 cl_program programs[2] = { input1(), input2() };
6979 Context ctx = input1.getInfo<CL_PROGRAM_CONTEXT>(&error_local);
6980 if(error_local!=CL_SUCCESS) {
6981 detail::errHandler(error_local, __LINK_PROGRAM_ERR);
6984 cl_program prog = ::clLinkProgram(
6995 detail::errHandler(error_local,__COMPILE_PROGRAM_ERR);
7000 return Program(prog);
7003 inline Program linkProgram(
7004 vector<Program> inputPrograms,
7005 const char* options = NULL,
7006 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
7010 cl_int error_local = CL_SUCCESS;
7012 vector<cl_program> programs(inputPrograms.size());
7014 for (
unsigned int i = 0; i < inputPrograms.size(); i++) {
7015 programs[i] = inputPrograms[i]();
7019 if(inputPrograms.size() > 0) {
7020 ctx = inputPrograms[0].getInfo<CL_PROGRAM_CONTEXT>(&error_local);
7021 if(error_local!=CL_SUCCESS) {
7022 detail::errHandler(error_local, __LINK_PROGRAM_ERR);
7025 cl_program prog = ::clLinkProgram(
7030 (cl_uint)inputPrograms.size(),
7036 detail::errHandler(error_local,__COMPILE_PROGRAM_ERR);
7041 return Program(prog,
false);
7047 inline cl_int cl::Program::getInfo(cl_program_info name, vector<vector<unsigned char>>* param)
const
7049 if (name != CL_PROGRAM_BINARIES) {
7050 return CL_INVALID_VALUE;
7056 vector<size_type> sizes = getInfo<CL_PROGRAM_BINARY_SIZES>();
7057 size_type numBinaries = sizes.size();
7060 param->resize(numBinaries);
7061 for (size_type i = 0; i < numBinaries; ++i) {
7062 (*param)[i].resize(sizes[i]);
7065 return detail::errHandler(
7066 detail::getInfo(&::clGetProgramInfo, object_, name, param),
7067 __GET_PROGRAM_INFO_ERR);
7074 inline vector<vector<unsigned char>> cl::Program::getInfo<CL_PROGRAM_BINARIES>(cl_int* err)
const
7076 vector<vector<unsigned char>> binariesVectors;
7078 cl_int result = getInfo(CL_PROGRAM_BINARIES, &binariesVectors);
7082 return binariesVectors;
7085 #if CL_HPP_TARGET_OPENCL_VERSION >= 220
7090 cl_uchar ucValue = value ? CL_UCHAR_MAX : 0;
7091 return detail::errHandler(
7092 ::clSetProgramSpecializationConstant(
7097 __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR);
7101 inline Kernel::Kernel(
const Program& program,
const char* name, cl_int* err)
7105 object_ = ::clCreateKernel(program(), name, &error);
7106 detail::errHandler(error, __CREATE_KERNEL_ERR);
7114 enum class QueueProperties : cl_command_queue_properties
7117 Profiling = CL_QUEUE_PROFILING_ENABLE,
7118 OutOfOrder = CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE,
7121 inline QueueProperties operator|(QueueProperties lhs, QueueProperties rhs)
7123 return static_cast<QueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) |
static_cast<cl_command_queue_properties
>(rhs));
7126 inline QueueProperties operator&(QueueProperties lhs, QueueProperties rhs)
7128 return static_cast<QueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) &
static_cast<cl_command_queue_properties
>(rhs));
7137 static std::once_flag default_initialized_;
7139 static cl_int default_error_;
7146 static void makeDefault()
7151 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
7158 if (error != CL_SUCCESS) {
7159 default_error_ = error;
7163 default_ =
CommandQueue(context, device, 0, &default_error_);
7166 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
7167 catch (cl::Error &e) {
7168 default_error_ = e.err();
7178 static void makeDefaultProvided(
const CommandQueue &c) {
7183 #ifdef CL_HPP_UNIT_TEST_ENABLE
7190 static void unitTestClearDefault() {
7201 cl_command_queue_properties properties,
7207 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7209 if (error != CL_SUCCESS) {
7216 bool useWithProperties;
7218 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7221 cl_uint version = detail::getContextPlatformVersion(context());
7222 useWithProperties = (version >= 0x20000);
7224 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7225 useWithProperties =
true;
7227 useWithProperties =
false;
7230 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
7231 if (useWithProperties) {
7232 cl_queue_properties queue_properties[] = {
7233 CL_QUEUE_PROPERTIES, properties, 0 };
7234 if ((properties & CL_QUEUE_ON_DEVICE) == 0) {
7235 object_ = ::clCreateCommandQueueWithProperties(
7236 context(), device(), queue_properties, &error);
7239 error = CL_INVALID_QUEUE_PROPERTIES;
7242 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7248 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7249 if (!useWithProperties) {
7250 object_ = ::clCreateCommandQueue(
7251 context(), device(), properties, &error);
7253 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7267 QueueProperties properties,
7273 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7275 if (error != CL_SUCCESS) {
7282 bool useWithProperties;
7284 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7287 cl_uint version = detail::getContextPlatformVersion(context());
7288 useWithProperties = (version >= 0x20000);
7290 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7291 useWithProperties =
true;
7293 useWithProperties =
false;
7296 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
7297 if (useWithProperties) {
7298 cl_queue_properties queue_properties[] = {
7299 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
7301 object_ = ::clCreateCommandQueueWithProperties(
7302 context(), device(), queue_properties, &error);
7304 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7310 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7311 if (!useWithProperties) {
7312 object_ = ::clCreateCommandQueue(
7313 context(), device(),
static_cast<cl_command_queue_properties
>(properties), &error);
7315 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7331 cl_command_queue_properties properties = 0,
7335 bool useWithProperties;
7336 vector<cl::Device> devices;
7337 error = context.
getInfo(CL_CONTEXT_DEVICES, &devices);
7339 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7341 if (error != CL_SUCCESS)
7349 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7352 cl_uint version = detail::getContextPlatformVersion(context());
7353 useWithProperties = (version >= 0x20000);
7355 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7356 useWithProperties =
true;
7358 useWithProperties =
false;
7361 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
7362 if (useWithProperties) {
7363 cl_queue_properties queue_properties[] = {
7364 CL_QUEUE_PROPERTIES, properties, 0 };
7365 if ((properties & CL_QUEUE_ON_DEVICE) == 0) {
7366 object_ = ::clCreateCommandQueueWithProperties(
7367 context(), devices[0](), queue_properties, &error);
7370 error = CL_INVALID_QUEUE_PROPERTIES;
7373 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7379 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7380 if (!useWithProperties) {
7381 object_ = ::clCreateCommandQueue(
7382 context(), devices[0](), properties, &error);
7384 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7398 QueueProperties properties,
7402 bool useWithProperties;
7403 vector<cl::Device> devices;
7404 error = context.
getInfo(CL_CONTEXT_DEVICES, &devices);
7406 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7408 if (error != CL_SUCCESS)
7416 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7419 cl_uint version = detail::getContextPlatformVersion(context());
7420 useWithProperties = (version >= 0x20000);
7422 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7423 useWithProperties =
true;
7425 useWithProperties =
false;
7428 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
7429 if (useWithProperties) {
7430 cl_queue_properties queue_properties[] = {
7431 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
7432 object_ = ::clCreateCommandQueueWithProperties(
7433 context(), devices[0](), queue_properties, &error);
7435 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7441 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7442 if (!useWithProperties) {
7443 object_ = ::clCreateCommandQueue(
7444 context(), devices[0](),
static_cast<cl_command_queue_properties
>(properties), &error);
7446 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7461 cl_command_queue_properties properties = 0,
7465 bool useWithProperties;
7467 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7470 cl_uint version = detail::getContextPlatformVersion(context());
7471 useWithProperties = (version >= 0x20000);
7473 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7474 useWithProperties =
true;
7476 useWithProperties =
false;
7479 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
7480 if (useWithProperties) {
7481 cl_queue_properties queue_properties[] = {
7482 CL_QUEUE_PROPERTIES, properties, 0 };
7483 object_ = ::clCreateCommandQueueWithProperties(
7484 context(), device(), queue_properties, &error);
7486 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7492 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7493 if (!useWithProperties) {
7494 object_ = ::clCreateCommandQueue(
7495 context(), device(), properties, &error);
7497 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7512 QueueProperties properties,
7516 bool useWithProperties;
7518 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7521 cl_uint version = detail::getContextPlatformVersion(context());
7522 useWithProperties = (version >= 0x20000);
7524 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7525 useWithProperties =
true;
7527 useWithProperties =
false;
7530 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
7531 if (useWithProperties) {
7532 cl_queue_properties queue_properties[] = {
7533 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
7534 object_ = ::clCreateCommandQueueWithProperties(
7535 context(), device(), queue_properties, &error);
7537 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7543 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7544 if (!useWithProperties) {
7545 object_ = ::clCreateCommandQueue(
7546 context(), device(),
static_cast<cl_command_queue_properties
>(properties), &error);
7548 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7558 std::call_once(default_initialized_, makeDefault);
7559 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
7560 detail::errHandler(default_error_, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7562 detail::errHandler(default_error_, __CREATE_COMMAND_QUEUE_ERR);
7565 *err = default_error_;
7579 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_queue));
7580 detail::errHandler(default_error_);
7593 explicit CommandQueue(
const cl_command_queue& commandQueue,
bool retainObject =
false) :
7594 detail::Wrapper<cl_type>(commandQueue, retainObject) { }
7630 template <
typename T>
7631 cl_int getInfo(cl_command_queue_info name, T* param)
const
7633 return detail::errHandler(
7635 &::clGetCommandQueueInfo, object_, name, param),
7636 __GET_COMMAND_QUEUE_INFO_ERR);
7639 template <cl_command_queue_info name>
typename
7640 detail::param_traits<detail::cl_command_queue_info, name>::param_type
7641 getInfo(cl_int* err = NULL)
const
7643 typename detail::param_traits<
7644 detail::cl_command_queue_info, name>::param_type param;
7645 cl_int result = getInfo(name, ¶m);
7652 cl_int enqueueReadBuffer(
7653 const Buffer& buffer,
7658 const vector<Event>* events = NULL,
7659 Event* event = NULL)
const
7662 cl_int err = detail::errHandler(
7663 ::clEnqueueReadBuffer(
7664 object_, buffer(), blocking, offset, size,
7666 (events != NULL) ? (cl_uint) events->size() : 0,
7667 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7668 (event != NULL) ? &tmp : NULL),
7669 __ENQUEUE_READ_BUFFER_ERR);
7671 if (event != NULL && err == CL_SUCCESS)
7677 cl_int enqueueWriteBuffer(
7678 const Buffer& buffer,
7683 const vector<Event>* events = NULL,
7684 Event* event = NULL)
const
7687 cl_int err = detail::errHandler(
7688 ::clEnqueueWriteBuffer(
7689 object_, buffer(), blocking, offset, size,
7691 (events != NULL) ? (cl_uint) events->size() : 0,
7692 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7693 (event != NULL) ? &tmp : NULL),
7694 __ENQUEUE_WRITE_BUFFER_ERR);
7696 if (event != NULL && err == CL_SUCCESS)
7702 cl_int enqueueCopyBuffer(
7705 size_type src_offset,
7706 size_type dst_offset,
7708 const vector<Event>* events = NULL,
7709 Event* event = NULL)
const
7712 cl_int err = detail::errHandler(
7713 ::clEnqueueCopyBuffer(
7714 object_, src(), dst(), src_offset, dst_offset, size,
7715 (events != NULL) ? (cl_uint) events->size() : 0,
7716 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7717 (event != NULL) ? &tmp : NULL),
7718 __ENQEUE_COPY_BUFFER_ERR);
7720 if (event != NULL && err == CL_SUCCESS)
7725 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
7726 cl_int enqueueReadBufferRect(
7727 const Buffer& buffer,
7729 const array<size_type, 3>& buffer_offset,
7730 const array<size_type, 3>& host_offset,
7731 const array<size_type, 3>& region,
7732 size_type buffer_row_pitch,
7733 size_type buffer_slice_pitch,
7734 size_type host_row_pitch,
7735 size_type host_slice_pitch,
7737 const vector<Event>* events = NULL,
7738 Event* event = NULL)
const
7741 cl_int err = detail::errHandler(
7742 ::clEnqueueReadBufferRect(
7746 buffer_offset.data(),
7754 (events != NULL) ? (cl_uint) events->size() : 0,
7755 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7756 (event != NULL) ? &tmp : NULL),
7757 __ENQUEUE_READ_BUFFER_RECT_ERR);
7759 if (event != NULL && err == CL_SUCCESS)
7765 cl_int enqueueWriteBufferRect(
7766 const Buffer& buffer,
7768 const array<size_type, 3>& buffer_offset,
7769 const array<size_type, 3>& host_offset,
7770 const array<size_type, 3>& region,
7771 size_type buffer_row_pitch,
7772 size_type buffer_slice_pitch,
7773 size_type host_row_pitch,
7774 size_type host_slice_pitch,
7776 const vector<Event>* events = NULL,
7777 Event* event = NULL)
const
7780 cl_int err = detail::errHandler(
7781 ::clEnqueueWriteBufferRect(
7785 buffer_offset.data(),
7793 (events != NULL) ? (cl_uint) events->size() : 0,
7794 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7795 (event != NULL) ? &tmp : NULL),
7796 __ENQUEUE_WRITE_BUFFER_RECT_ERR);
7798 if (event != NULL && err == CL_SUCCESS)
7804 cl_int enqueueCopyBufferRect(
7807 const array<size_type, 3>& src_origin,
7808 const array<size_type, 3>& dst_origin,
7809 const array<size_type, 3>& region,
7810 size_type src_row_pitch,
7811 size_type src_slice_pitch,
7812 size_type dst_row_pitch,
7813 size_type dst_slice_pitch,
7814 const vector<Event>* events = NULL,
7815 Event* event = NULL)
const
7818 cl_int err = detail::errHandler(
7819 ::clEnqueueCopyBufferRect(
7830 (events != NULL) ? (cl_uint) events->size() : 0,
7831 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7832 (event != NULL) ? &tmp : NULL),
7833 __ENQEUE_COPY_BUFFER_RECT_ERR);
7835 if (event != NULL && err == CL_SUCCESS)
7841 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
7853 template<
typename PatternType>
7856 PatternType pattern,
7859 const vector<Event>* events = NULL,
7860 Event* event = NULL)
const
7863 cl_int err = detail::errHandler(
7864 ::clEnqueueFillBuffer(
7867 static_cast<void*
>(&pattern),
7868 sizeof(PatternType),
7871 (events != NULL) ? (cl_uint) events->size() : 0,
7872 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7873 (event != NULL) ? &tmp : NULL),
7874 __ENQUEUE_FILL_BUFFER_ERR);
7876 if (event != NULL && err == CL_SUCCESS)
7883 cl_int enqueueReadImage(
7886 const array<size_type, 3>& origin,
7887 const array<size_type, 3>& region,
7888 size_type row_pitch,
7889 size_type slice_pitch,
7891 const vector<Event>* events = NULL,
7892 Event* event = NULL)
const
7895 cl_int err = detail::errHandler(
7896 ::clEnqueueReadImage(
7905 (events != NULL) ? (cl_uint) events->size() : 0,
7906 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7907 (event != NULL) ? &tmp : NULL),
7908 __ENQUEUE_READ_IMAGE_ERR);
7910 if (event != NULL && err == CL_SUCCESS)
7916 cl_int enqueueWriteImage(
7919 const array<size_type, 3>& origin,
7920 const array<size_type, 3>& region,
7921 size_type row_pitch,
7922 size_type slice_pitch,
7924 const vector<Event>* events = NULL,
7925 Event* event = NULL)
const
7928 cl_int err = detail::errHandler(
7929 ::clEnqueueWriteImage(
7938 (events != NULL) ? (cl_uint) events->size() : 0,
7939 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7940 (event != NULL) ? &tmp : NULL),
7941 __ENQUEUE_WRITE_IMAGE_ERR);
7943 if (event != NULL && err == CL_SUCCESS)
7949 cl_int enqueueCopyImage(
7952 const array<size_type, 3>& src_origin,
7953 const array<size_type, 3>& dst_origin,
7954 const array<size_type, 3>& region,
7955 const vector<Event>* events = NULL,
7956 Event* event = NULL)
const
7959 cl_int err = detail::errHandler(
7960 ::clEnqueueCopyImage(
7967 (events != NULL) ? (cl_uint) events->size() : 0,
7968 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7969 (event != NULL) ? &tmp : NULL),
7970 __ENQUEUE_COPY_IMAGE_ERR);
7972 if (event != NULL && err == CL_SUCCESS)
7978 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
7988 cl_float4 fillColor,
7989 const array<size_type, 3>& origin,
7990 const array<size_type, 3>& region,
7991 const vector<Event>* events = NULL,
7992 Event* event = NULL)
const
7995 cl_int err = detail::errHandler(
7996 ::clEnqueueFillImage(
7999 static_cast<void*
>(&fillColor),
8002 (events != NULL) ? (cl_uint) events->size() : 0,
8003 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8004 (event != NULL) ? &tmp : NULL),
8005 __ENQUEUE_FILL_IMAGE_ERR);
8007 if (event != NULL && err == CL_SUCCESS)
8023 const array<size_type, 3>& origin,
8024 const array<size_type, 3>& region,
8025 const vector<Event>* events = NULL,
8026 Event* event = NULL)
const
8029 cl_int err = detail::errHandler(
8030 ::clEnqueueFillImage(
8033 static_cast<void*
>(&fillColor),
8036 (events != NULL) ? (cl_uint) events->size() : 0,
8037 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8038 (event != NULL) ? &tmp : NULL),
8039 __ENQUEUE_FILL_IMAGE_ERR);
8041 if (event != NULL && err == CL_SUCCESS)
8057 const array<size_type, 3>& origin,
8058 const array<size_type, 3>& region,
8059 const vector<Event>* events = NULL,
8060 Event* event = NULL)
const
8063 cl_int err = detail::errHandler(
8064 ::clEnqueueFillImage(
8067 static_cast<void*
>(&fillColor),
8070 (events != NULL) ? (cl_uint) events->size() : 0,
8071 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8072 (event != NULL) ? &tmp : NULL),
8073 __ENQUEUE_FILL_IMAGE_ERR);
8075 if (event != NULL && err == CL_SUCCESS)
8082 cl_int enqueueCopyImageToBuffer(
8085 const array<size_type, 3>& src_origin,
8086 const array<size_type, 3>& region,
8087 size_type dst_offset,
8088 const vector<Event>* events = NULL,
8089 Event* event = NULL)
const
8092 cl_int err = detail::errHandler(
8093 ::clEnqueueCopyImageToBuffer(
8100 (events != NULL) ? (cl_uint) events->size() : 0,
8101 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8102 (event != NULL) ? &tmp : NULL),
8103 __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR);
8105 if (event != NULL && err == CL_SUCCESS)
8111 cl_int enqueueCopyBufferToImage(
8114 size_type src_offset,
8115 const array<size_type, 3>& dst_origin,
8116 const array<size_type, 3>& region,
8117 const vector<Event>* events = NULL,
8118 Event* event = NULL)
const
8121 cl_int err = detail::errHandler(
8122 ::clEnqueueCopyBufferToImage(
8129 (events != NULL) ? (cl_uint) events->size() : 0,
8130 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8131 (event != NULL) ? &tmp : NULL),
8132 __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR);
8134 if (event != NULL && err == CL_SUCCESS)
8140 void* enqueueMapBuffer(
8141 const Buffer& buffer,
8146 const vector<Event>* events = NULL,
8147 Event* event = NULL,
8148 cl_int* err = NULL)
const
8152 void * result = ::clEnqueueMapBuffer(
8153 object_, buffer(), blocking, flags, offset, size,
8154 (events != NULL) ? (cl_uint) events->size() : 0,
8155 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8156 (event != NULL) ? &tmp : NULL,
8159 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
8163 if (event != NULL && error == CL_SUCCESS)
8169 void* enqueueMapImage(
8170 const Image& buffer,
8173 const array<size_type, 3>& origin,
8174 const array<size_type, 3>& region,
8175 size_type * row_pitch,
8176 size_type * slice_pitch,
8177 const vector<Event>* events = NULL,
8178 Event* event = NULL,
8179 cl_int* err = NULL)
const
8183 void * result = ::clEnqueueMapImage(
8184 object_, buffer(), blocking, flags,
8187 row_pitch, slice_pitch,
8188 (events != NULL) ? (cl_uint) events->size() : 0,
8189 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8190 (event != NULL) ? &tmp : NULL,
8193 detail::errHandler(error, __ENQUEUE_MAP_IMAGE_ERR);
8197 if (event != NULL && error == CL_SUCCESS)
8202 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
8207 template<
typename T>
8213 const vector<Event>* events = NULL,
8214 Event* event = NULL)
const
8217 cl_int err = detail::errHandler(::clEnqueueSVMMap(
8218 object_, blocking, flags,
static_cast<void*
>(ptr), size,
8219 (events != NULL) ? (cl_uint)events->size() : 0,
8220 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8221 (event != NULL) ? &tmp : NULL),
8222 __ENQUEUE_MAP_BUFFER_ERR);
8224 if (event != NULL && err == CL_SUCCESS)
8235 template<
typename T,
class D>
8237 cl::pointer<T, D> &ptr,
8241 const vector<Event>* events = NULL,
8242 Event* event = NULL)
const
8245 cl_int err = detail::errHandler(::clEnqueueSVMMap(
8246 object_, blocking, flags,
static_cast<void*
>(ptr.get()), size,
8247 (events != NULL) ? (cl_uint)events->size() : 0,
8248 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8249 (event != NULL) ? &tmp : NULL),
8250 __ENQUEUE_MAP_BUFFER_ERR);
8252 if (event != NULL && err == CL_SUCCESS)
8262 template<
typename T,
class Alloc>
8264 cl::vector<T, Alloc> &container,
8267 const vector<Event>* events = NULL,
8268 Event* event = NULL)
const
8271 cl_int err = detail::errHandler(::clEnqueueSVMMap(
8272 object_, blocking, flags,
static_cast<void*
>(container.data()), container.size()*
sizeof(T),
8273 (events != NULL) ? (cl_uint)events->size() : 0,
8274 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8275 (event != NULL) ? &tmp : NULL),
8276 __ENQUEUE_MAP_BUFFER_ERR);
8278 if (event != NULL && err == CL_SUCCESS)
8285 cl_int enqueueUnmapMemObject(
8288 const vector<Event>* events = NULL,
8289 Event* event = NULL)
const
8292 cl_int err = detail::errHandler(
8293 ::clEnqueueUnmapMemObject(
8294 object_, memory(), mapped_ptr,
8295 (events != NULL) ? (cl_uint) events->size() : 0,
8296 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8297 (event != NULL) ? &tmp : NULL),
8298 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8300 if (event != NULL && err == CL_SUCCESS)
8307 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
8312 template<
typename T>
8315 const vector<Event>* events = NULL,
8316 Event* event = NULL)
const
8319 cl_int err = detail::errHandler(
8320 ::clEnqueueSVMUnmap(
8321 object_,
static_cast<void*
>(ptr),
8322 (events != NULL) ? (cl_uint)events->size() : 0,
8323 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8324 (event != NULL) ? &tmp : NULL),
8325 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8327 if (event != NULL && err == CL_SUCCESS)
8337 template<
typename T,
class D>
8339 cl::pointer<T, D> &ptr,
8340 const vector<Event>* events = NULL,
8341 Event* event = NULL)
const
8344 cl_int err = detail::errHandler(
8345 ::clEnqueueSVMUnmap(
8346 object_,
static_cast<void*
>(ptr.get()),
8347 (events != NULL) ? (cl_uint)events->size() : 0,
8348 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8349 (event != NULL) ? &tmp : NULL),
8350 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8352 if (event != NULL && err == CL_SUCCESS)
8362 template<
typename T,
class Alloc>
8364 cl::vector<T, Alloc> &container,
8365 const vector<Event>* events = NULL,
8366 Event* event = NULL)
const
8369 cl_int err = detail::errHandler(
8370 ::clEnqueueSVMUnmap(
8371 object_,
static_cast<void*
>(container.data()),
8372 (events != NULL) ? (cl_uint)events->size() : 0,
8373 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8374 (event != NULL) ? &tmp : NULL),
8375 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8377 if (event != NULL && err == CL_SUCCESS)
8384 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
8397 const vector<Event> *events = 0,
8398 Event *event = 0)
const
8401 cl_int err = detail::errHandler(
8402 ::clEnqueueMarkerWithWaitList(
8404 (events != NULL) ? (cl_uint) events->size() : 0,
8405 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8406 (event != NULL) ? &tmp : NULL),
8407 __ENQUEUE_MARKER_WAIT_LIST_ERR);
8409 if (event != NULL && err == CL_SUCCESS)
8427 const vector<Event> *events = 0,
8428 Event *event = 0)
const
8431 cl_int err = detail::errHandler(
8432 ::clEnqueueBarrierWithWaitList(
8434 (events != NULL) ? (cl_uint) events->size() : 0,
8435 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8436 (event != NULL) ? &tmp : NULL),
8437 __ENQUEUE_BARRIER_WAIT_LIST_ERR);
8439 if (event != NULL && err == CL_SUCCESS)
8450 const vector<Memory> &memObjects,
8451 cl_mem_migration_flags flags,
8452 const vector<Event>* events = NULL,
8458 vector<cl_mem> localMemObjects(memObjects.size());
8460 for(
int i = 0; i < (int)memObjects.size(); ++i ) {
8461 localMemObjects[i] = memObjects[i]();
8464 cl_int err = detail::errHandler(
8465 ::clEnqueueMigrateMemObjects(
8467 (cl_uint)memObjects.size(),
8468 localMemObjects.data(),
8470 (events != NULL) ? (cl_uint) events->size() : 0,
8471 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8472 (event != NULL) ? &tmp : NULL),
8473 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8475 if (event != NULL && err == CL_SUCCESS)
8483 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
8489 template<
typename T>
8491 const cl::vector<T*> &svmRawPointers,
8492 const cl::vector<size_type> &sizes,
8493 cl_mem_migration_flags flags = 0,
8494 const vector<Event>* events = NULL,
8495 Event* event = NULL)
const
8498 cl_int err = detail::errHandler(::clEnqueueSVMMigrateMem(
8500 svmRawPointers.size(),
static_cast<void**
>(svmRawPointers.data()),
8503 (events != NULL) ? (cl_uint)events->size() : 0,
8504 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8505 (event != NULL) ? &tmp : NULL),
8506 __ENQUEUE_MIGRATE_SVM_ERR);
8508 if (event != NULL && err == CL_SUCCESS)
8518 template<
typename T>
8520 const cl::vector<T*> &svmRawPointers,
8521 cl_mem_migration_flags flags = 0,
8522 const vector<Event>* events = NULL,
8523 Event* event = NULL)
const
8525 return enqueueMigrateSVM(svmRawPointers, cl::vector<size_type>(svmRawPointers.size()), flags, events, event);
8534 template<
typename T,
class D>
8536 const cl::vector<cl::pointer<T, D>> &svmPointers,
8537 const cl::vector<size_type> &sizes,
8538 cl_mem_migration_flags flags = 0,
8539 const vector<Event>* events = NULL,
8540 Event* event = NULL)
const
8542 cl::vector<void*> svmRawPointers;
8543 svmRawPointers.reserve(svmPointers.size());
8544 for (
auto p : svmPointers) {
8545 svmRawPointers.push_back(
static_cast<void*
>(p.get()));
8556 template<
typename T,
class D>
8558 const cl::vector<cl::pointer<T, D>> &svmPointers,
8559 cl_mem_migration_flags flags = 0,
8560 const vector<Event>* events = NULL,
8561 Event* event = NULL)
const
8563 return enqueueMigrateSVM(svmPointers, cl::vector<size_type>(svmPointers.size()), flags, events, event);
8571 template<
typename T,
class Alloc>
8573 const cl::vector<cl::vector<T, Alloc>> &svmContainers,
8574 const cl::vector<size_type> &sizes,
8575 cl_mem_migration_flags flags = 0,
8576 const vector<Event>* events = NULL,
8577 Event* event = NULL)
const
8579 cl::vector<void*> svmRawPointers;
8580 svmRawPointers.reserve(svmContainers.size());
8581 for (
auto p : svmContainers) {
8582 svmRawPointers.push_back(
static_cast<void*
>(p.data()));
8592 template<
typename T,
class Alloc>
8594 const cl::vector<cl::vector<T, Alloc>> &svmContainers,
8595 cl_mem_migration_flags flags = 0,
8596 const vector<Event>* events = NULL,
8597 Event* event = NULL)
const
8599 return enqueueMigrateSVM(svmContainers, cl::vector<size_type>(svmContainers.size()), flags, events, event);
8604 cl_int enqueueNDRangeKernel(
8608 const NDRange& local = NullRange,
8609 const vector<Event>* events = NULL,
8610 Event* event = NULL)
const
8613 cl_int err = detail::errHandler(
8614 ::clEnqueueNDRangeKernel(
8615 object_, kernel(), (cl_uint) global.
dimensions(),
8616 offset.
dimensions() != 0 ? (
const size_type*) offset : NULL,
8617 (
const size_type*) global,
8618 local.dimensions() != 0 ? (
const size_type*) local : NULL,
8619 (events != NULL) ? (cl_uint) events->size() : 0,
8620 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8621 (event != NULL) ? &tmp : NULL),
8622 __ENQUEUE_NDRANGE_KERNEL_ERR);
8624 if (event != NULL && err == CL_SUCCESS)
8630 #if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
8631 CL_API_PREFIX__VERSION_1_2_DEPRECATED cl_int enqueueTask(
8632 const Kernel& kernel,
8633 const vector<Event>* events = NULL,
8634 Event* event = NULL)
const CL_API_SUFFIX__VERSION_1_2_DEPRECATED
8637 cl_int err = detail::errHandler(
8640 (events != NULL) ? (cl_uint) events->size() : 0,
8641 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8642 (event != NULL) ? &tmp : NULL),
8643 __ENQUEUE_TASK_ERR);
8645 if (event != NULL && err == CL_SUCCESS)
8652 cl_int enqueueNativeKernel(
8653 void (CL_CALLBACK *userFptr)(
void *),
8654 std::pair<void*, size_type> args,
8655 const vector<Memory>* mem_objects = NULL,
8656 const vector<const void*>* mem_locs = NULL,
8657 const vector<Event>* events = NULL,
8658 Event* event = NULL)
const
8660 size_type elements = 0;
8661 if (mem_objects != NULL) {
8662 elements = mem_objects->size();
8664 vector<cl_mem> mems(elements);
8665 for (
unsigned int i = 0; i < elements; i++) {
8666 mems[i] = ((*mem_objects)[i])();
8670 cl_int err = detail::errHandler(
8671 ::clEnqueueNativeKernel(
8672 object_, userFptr, args.first, args.second,
8673 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8675 (mem_locs != NULL && mem_locs->size() > 0) ? (
const void **) &mem_locs->front() : NULL,
8676 (events != NULL) ? (cl_uint) events->size() : 0,
8677 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8678 (event != NULL) ? &tmp : NULL),
8679 __ENQUEUE_NATIVE_KERNEL);
8681 if (event != NULL && err == CL_SUCCESS)
8690 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
8691 CL_API_PREFIX__VERSION_1_1_DEPRECATED
8695 cl_int err = detail::errHandler(
8698 (event != NULL) ? &tmp : NULL),
8699 __ENQUEUE_MARKER_ERR);
8701 if (event != NULL && err == CL_SUCCESS)
8707 CL_API_PREFIX__VERSION_1_1_DEPRECATED
8708 cl_int enqueueWaitForEvents(
const vector<Event>& events)
const CL_API_SUFFIX__VERSION_1_1_DEPRECATED
8710 return detail::errHandler(
8711 ::clEnqueueWaitForEvents(
8713 (cl_uint) events.size(),
8714 events.size() > 0 ? (
const cl_event*) &events.front() : NULL),
8715 __ENQUEUE_WAIT_FOR_EVENTS_ERR);
8719 cl_int enqueueAcquireGLObjects(
8720 const vector<Memory>* mem_objects = NULL,
8721 const vector<Event>* events = NULL,
8722 Event* event = NULL)
const
8725 cl_int err = detail::errHandler(
8726 ::clEnqueueAcquireGLObjects(
8728 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8729 (mem_objects != NULL && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front(): NULL,
8730 (events != NULL) ? (cl_uint) events->size() : 0,
8731 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8732 (event != NULL) ? &tmp : NULL),
8733 __ENQUEUE_ACQUIRE_GL_ERR);
8735 if (event != NULL && err == CL_SUCCESS)
8741 cl_int enqueueReleaseGLObjects(
8742 const vector<Memory>* mem_objects = NULL,
8743 const vector<Event>* events = NULL,
8744 Event* event = NULL)
const
8747 cl_int err = detail::errHandler(
8748 ::clEnqueueReleaseGLObjects(
8750 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8751 (mem_objects != NULL && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front(): NULL,
8752 (events != NULL) ? (cl_uint) events->size() : 0,
8753 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8754 (event != NULL) ? &tmp : NULL),
8755 __ENQUEUE_RELEASE_GL_ERR);
8757 if (event != NULL && err == CL_SUCCESS)
8763 #if defined (CL_HPP_USE_DX_INTEROP)
8764 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueAcquireD3D10ObjectsKHR)(
8765 cl_command_queue command_queue, cl_uint num_objects,
8766 const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
8767 const cl_event* event_wait_list, cl_event* event);
8768 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueReleaseD3D10ObjectsKHR)(
8769 cl_command_queue command_queue, cl_uint num_objects,
8770 const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
8771 const cl_event* event_wait_list, cl_event* event);
8773 cl_int enqueueAcquireD3D10Objects(
8774 const vector<Memory>* mem_objects = NULL,
8775 const vector<Event>* events = NULL,
8776 Event* event = NULL)
const
8778 static PFN_clEnqueueAcquireD3D10ObjectsKHR pfn_clEnqueueAcquireD3D10ObjectsKHR = NULL;
8779 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
8780 cl_context context = getInfo<CL_QUEUE_CONTEXT>();
8781 cl::Device device(getInfo<CL_QUEUE_DEVICE>());
8782 cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>();
8783 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueAcquireD3D10ObjectsKHR);
8785 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
8786 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueAcquireD3D10ObjectsKHR);
8790 cl_int err = detail::errHandler(
8791 pfn_clEnqueueAcquireD3D10ObjectsKHR(
8793 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8794 (mem_objects != NULL && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front(): NULL,
8795 (events != NULL) ? (cl_uint) events->size() : 0,
8796 (events != NULL) ? (cl_event*) &events->front() : NULL,
8797 (event != NULL) ? &tmp : NULL),
8798 __ENQUEUE_ACQUIRE_GL_ERR);
8800 if (event != NULL && err == CL_SUCCESS)
8806 cl_int enqueueReleaseD3D10Objects(
8807 const vector<Memory>* mem_objects = NULL,
8808 const vector<Event>* events = NULL,
8809 Event* event = NULL)
const
8811 static PFN_clEnqueueReleaseD3D10ObjectsKHR pfn_clEnqueueReleaseD3D10ObjectsKHR = NULL;
8812 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
8813 cl_context context = getInfo<CL_QUEUE_CONTEXT>();
8814 cl::Device device(getInfo<CL_QUEUE_DEVICE>());
8815 cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>();
8816 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueReleaseD3D10ObjectsKHR);
8818 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
8819 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueReleaseD3D10ObjectsKHR);
8823 cl_int err = detail::errHandler(
8824 pfn_clEnqueueReleaseD3D10ObjectsKHR(
8826 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8827 (mem_objects != NULL && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front(): NULL,
8828 (events != NULL) ? (cl_uint) events->size() : 0,
8829 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8830 (event != NULL) ? &tmp : NULL),
8831 __ENQUEUE_RELEASE_GL_ERR);
8833 if (event != NULL && err == CL_SUCCESS)
8843 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
8844 CL_API_PREFIX__VERSION_1_1_DEPRECATED
8847 return detail::errHandler(
8848 ::clEnqueueBarrier(object_),
8849 __ENQUEUE_BARRIER_ERR);
8853 cl_int flush()
const
8855 return detail::errHandler(::clFlush(object_), __FLUSH_ERR);
8858 cl_int finish()
const
8860 return detail::errHandler(::clFinish(object_), __FINISH_ERR);
8864 CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag CommandQueue::default_initialized_;
8865 CL_HPP_DEFINE_STATIC_MEMBER_ CommandQueue CommandQueue::default_;
8866 CL_HPP_DEFINE_STATIC_MEMBER_ cl_int CommandQueue::default_error_ = CL_SUCCESS;
8869 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
8870 enum class DeviceQueueProperties : cl_command_queue_properties
8873 Profiling = CL_QUEUE_PROFILING_ENABLE,
8876 inline DeviceQueueProperties operator|(DeviceQueueProperties lhs, DeviceQueueProperties rhs)
8878 return static_cast<DeviceQueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) |
static_cast<cl_command_queue_properties
>(rhs));
8902 cl_command_queue_properties mergedProperties =
8903 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
8905 cl_queue_properties queue_properties[] = {
8906 CL_QUEUE_PROPERTIES, mergedProperties, 0 };
8907 object_ = ::clCreateCommandQueueWithProperties(
8908 context(), device(), queue_properties, &error);
8910 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8922 DeviceQueueProperties properties = DeviceQueueProperties::None,
8927 cl_command_queue_properties mergedProperties =
8928 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
8929 cl_queue_properties queue_properties[] = {
8930 CL_QUEUE_PROPERTIES, mergedProperties, 0 };
8931 object_ = ::clCreateCommandQueueWithProperties(
8932 context(), device(), queue_properties, &error);
8934 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8947 DeviceQueueProperties properties = DeviceQueueProperties::None,
8952 cl_command_queue_properties mergedProperties =
8953 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
8954 cl_queue_properties queue_properties[] = {
8955 CL_QUEUE_PROPERTIES, mergedProperties,
8956 CL_QUEUE_SIZE, queueSize,
8958 object_ = ::clCreateCommandQueueWithProperties(
8959 context(), device(), queue_properties, &error);
8961 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8974 detail::Wrapper<cl_type>(commandQueue, retainObject) { }
9010 template <
typename T>
9011 cl_int getInfo(cl_command_queue_info name, T* param)
const
9013 return detail::errHandler(
9015 &::clGetCommandQueueInfo, object_, name, param),
9016 __GET_COMMAND_QUEUE_INFO_ERR);
9019 template <cl_command_queue_info name>
typename
9020 detail::param_traits<detail::cl_command_queue_info, name>::param_type
9021 getInfo(cl_int* err = NULL)
const
9023 typename detail::param_traits<
9024 detail::cl_command_queue_info, name>::param_type param;
9025 cl_int result = getInfo(name, ¶m);
9039 cl_int *err =
nullptr)
9045 cl_command_queue_properties properties =
9046 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
9047 cl_queue_properties queue_properties[] = {
9048 CL_QUEUE_PROPERTIES, properties,
9051 ::clCreateCommandQueueWithProperties(
9052 context(), device(), queue_properties, &error));
9054 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9069 const Context &context,
const Device &device, cl_int *err =
nullptr)
9073 cl_command_queue_properties properties =
9074 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
9075 cl_queue_properties queue_properties[] = {
9076 CL_QUEUE_PROPERTIES, properties,
9079 ::clCreateCommandQueueWithProperties(
9080 context(), device(), queue_properties, &error));
9082 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9097 const Context &context,
const Device &device, cl_uint queueSize, cl_int *err =
nullptr)
9101 cl_command_queue_properties properties =
9102 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
9103 cl_queue_properties queue_properties[] = {
9104 CL_QUEUE_PROPERTIES, properties,
9105 CL_QUEUE_SIZE, queueSize,
9108 ::clCreateCommandQueueWithProperties(
9109 context(), device(), queue_properties, &error));
9111 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9121 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
9131 error = clSetDefaultDeviceCommandQueue(context.get(), device.get(), default_queue.get());
9133 detail::errHandler(error, __SET_DEFAULT_DEVICE_COMMAND_QUEUE_ERR);
9137 return default_queue;
9145 return queue.getInfo<CL_QUEUE_DEVICE_DEFAULT>(err);
9165 template<
typename IteratorType >
9168 IteratorType startIterator,
9169 IteratorType endIterator,
9174 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9177 cl_mem_flags flags = 0;
9179 flags |= CL_MEM_READ_ONLY;
9182 flags |= CL_MEM_READ_WRITE;
9185 flags |= CL_MEM_USE_HOST_PTR;
9188 size_type size =
sizeof(DataType)*(endIterator - startIterator);
9191 object_ = ::clCreateBuffer(context(), flags, size,
const_cast<DataType*
>(&*startIterator), &error);
9193 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
9196 detail::errHandler(error, __CREATE_BUFFER_ERR);
9203 detail::errHandler(error, __CREATE_BUFFER_ERR);
9208 error =
cl::copy(queue, startIterator, endIterator, *
this);
9209 detail::errHandler(error, __CREATE_BUFFER_ERR);
9216 template<
typename IteratorType >
9219 IteratorType startIterator,
9220 IteratorType endIterator,
9225 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9228 cl_mem_flags flags = 0;
9230 flags |= CL_MEM_READ_ONLY;
9233 flags |= CL_MEM_READ_WRITE;
9236 flags |= CL_MEM_USE_HOST_PTR;
9239 size_type size =
sizeof(DataType)*(endIterator - startIterator);
9241 Context context = queue.getInfo<CL_QUEUE_CONTEXT>();
9244 object_ = ::clCreateBuffer(context(), flags, size,
const_cast<DataType*
>(&*startIterator), &error);
9247 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
9250 detail::errHandler(error, __CREATE_BUFFER_ERR);
9256 error =
cl::copy(queue, startIterator, endIterator, *
this);
9257 detail::errHandler(error, __CREATE_BUFFER_ERR);
9264 inline cl_int enqueueReadBuffer(
9270 const vector<Event>* events = NULL,
9271 Event* event = NULL)
9276 if (error != CL_SUCCESS) {
9280 return queue.enqueueReadBuffer(buffer, blocking, offset, size, ptr, events, event);
9283 inline cl_int enqueueWriteBuffer(
9284 const Buffer& buffer,
9289 const vector<Event>* events = NULL,
9290 Event* event = NULL)
9293 CommandQueue queue = CommandQueue::getDefault(&error);
9295 if (error != CL_SUCCESS) {
9299 return queue.enqueueWriteBuffer(buffer, blocking, offset, size, ptr, events, event);
9302 inline void* enqueueMapBuffer(
9303 const Buffer& buffer,
9308 const vector<Event>* events = NULL,
9309 Event* event = NULL,
9313 CommandQueue queue = CommandQueue::getDefault(&error);
9314 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9319 void * result = ::clEnqueueMapBuffer(
9320 queue(), buffer(), blocking, flags, offset, size,
9321 (events != NULL) ? (cl_uint) events->size() : 0,
9322 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
9326 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9334 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
9340 template<
typename T>
9346 const vector<Event>* events,
9351 if (error != CL_SUCCESS) {
9352 return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9356 ptr, blocking, flags, size, events, event);
9364 template<
typename T,
class D>
9366 cl::pointer<T, D> &ptr,
9370 const vector<Event>* events = NULL,
9371 Event* event = NULL)
9375 if (error != CL_SUCCESS) {
9376 return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9380 ptr, blocking, flags, size, events, event);
9388 template<
typename T,
class Alloc>
9390 cl::vector<T, Alloc> &container,
9393 const vector<Event>* events = NULL,
9394 Event* event = NULL)
9398 if (error != CL_SUCCESS) {
9399 return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9403 container, blocking, flags, events, event);
9408 inline cl_int enqueueUnmapMemObject(
9409 const Memory& memory,
9411 const vector<Event>* events = NULL,
9412 Event* event = NULL)
9415 CommandQueue queue = CommandQueue::getDefault(&error);
9416 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9417 if (error != CL_SUCCESS) {
9422 cl_int err = detail::errHandler(
9423 ::clEnqueueUnmapMemObject(
9424 queue(), memory(), mapped_ptr,
9425 (events != NULL) ? (cl_uint)events->size() : 0,
9426 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
9427 (event != NULL) ? &tmp : NULL),
9428 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9430 if (event != NULL && err == CL_SUCCESS)
9436 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
9442 template<
typename T>
9445 const vector<Event>* events = NULL,
9446 Event* event = NULL)
9450 if (error != CL_SUCCESS) {
9451 return detail::errHandler(error, __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9455 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9464 template<
typename T,
class D>
9466 cl::pointer<T, D> &ptr,
9467 const vector<Event>* events = NULL,
9468 Event* event = NULL)
9472 if (error != CL_SUCCESS) {
9473 return detail::errHandler(error, __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9477 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9485 template<
typename T,
class Alloc>
9487 cl::vector<T, Alloc> &container,
9488 const vector<Event>* events = NULL,
9489 Event* event = NULL)
9493 if (error != CL_SUCCESS) {
9494 return detail::errHandler(error, __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9497 return detail::errHandler(queue.
enqueueUnmapSVM(container, events, event),
9498 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9503 inline cl_int enqueueCopyBuffer(
9506 size_type src_offset,
9507 size_type dst_offset,
9509 const vector<Event>* events = NULL,
9510 Event* event = NULL)
9513 CommandQueue queue = CommandQueue::getDefault(&error);
9515 if (error != CL_SUCCESS) {
9519 return queue.enqueueCopyBuffer(src, dst, src_offset, dst_offset, size, events, event);
9527 template<
typename IteratorType >
9528 inline cl_int
copy( IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer )
9532 if (error != CL_SUCCESS)
9535 return cl::copy(queue, startIterator, endIterator, buffer);
9543 template<
typename IteratorType >
9544 inline cl_int
copy(
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator )
9548 if (error != CL_SUCCESS)
9551 return cl::copy(queue, buffer, startIterator, endIterator);
9559 template<
typename IteratorType >
9562 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9565 size_type length = endIterator-startIterator;
9566 size_type byteLength = length*
sizeof(DataType);
9569 static_cast<DataType*
>(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_WRITE, 0, byteLength, 0, 0, &error));
9571 if( error != CL_SUCCESS ) {
9574 #if defined(_MSC_VER)
9578 stdext::checked_array_iterator<DataType*>(
9581 std::copy(startIterator, endIterator, pointer);
9584 error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
9586 if( error != CL_SUCCESS ) {
9598 template<
typename IteratorType >
9601 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9604 size_type length = endIterator-startIterator;
9605 size_type byteLength = length*
sizeof(DataType);
9608 static_cast<DataType*
>(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_READ, 0, byteLength, 0, 0, &error));
9610 if( error != CL_SUCCESS ) {
9613 std::copy(pointer, pointer + length, startIterator);
9615 error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
9617 if( error != CL_SUCCESS ) {
9625 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
9629 template<
typename T,
class Alloc>
9630 inline cl_int
mapSVM(cl::vector<T, Alloc> &container)
9632 return enqueueMapSVM(container, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE);
9638 template<
typename T,
class Alloc>
9639 inline cl_int
unmapSVM(cl::vector<T, Alloc> &container)
9646 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
9647 inline cl_int enqueueReadBufferRect(
9648 const Buffer& buffer,
9650 const array<size_type, 3>& buffer_offset,
9651 const array<size_type, 3>& host_offset,
9652 const array<size_type, 3>& region,
9653 size_type buffer_row_pitch,
9654 size_type buffer_slice_pitch,
9655 size_type host_row_pitch,
9656 size_type host_slice_pitch,
9658 const vector<Event>* events = NULL,
9659 Event* event = NULL)
9662 CommandQueue queue = CommandQueue::getDefault(&error);
9664 if (error != CL_SUCCESS) {
9668 return queue.enqueueReadBufferRect(
9683 inline cl_int enqueueWriteBufferRect(
9684 const Buffer& buffer,
9686 const array<size_type, 3>& buffer_offset,
9687 const array<size_type, 3>& host_offset,
9688 const array<size_type, 3>& region,
9689 size_type buffer_row_pitch,
9690 size_type buffer_slice_pitch,
9691 size_type host_row_pitch,
9692 size_type host_slice_pitch,
9694 const vector<Event>* events = NULL,
9695 Event* event = NULL)
9698 CommandQueue queue = CommandQueue::getDefault(&error);
9700 if (error != CL_SUCCESS) {
9704 return queue.enqueueWriteBufferRect(
9719 inline cl_int enqueueCopyBufferRect(
9722 const array<size_type, 3>& src_origin,
9723 const array<size_type, 3>& dst_origin,
9724 const array<size_type, 3>& region,
9725 size_type src_row_pitch,
9726 size_type src_slice_pitch,
9727 size_type dst_row_pitch,
9728 size_type dst_slice_pitch,
9729 const vector<Event>* events = NULL,
9730 Event* event = NULL)
9733 CommandQueue queue = CommandQueue::getDefault(&error);
9735 if (error != CL_SUCCESS) {
9739 return queue.enqueueCopyBufferRect(
9754 inline cl_int enqueueReadImage(
9757 const array<size_type, 3>& origin,
9758 const array<size_type, 3>& region,
9759 size_type row_pitch,
9760 size_type slice_pitch,
9762 const vector<Event>* events = NULL,
9763 Event* event = NULL)
9766 CommandQueue queue = CommandQueue::getDefault(&error);
9768 if (error != CL_SUCCESS) {
9772 return queue.enqueueReadImage(
9784 inline cl_int enqueueWriteImage(
9787 const array<size_type, 3>& origin,
9788 const array<size_type, 3>& region,
9789 size_type row_pitch,
9790 size_type slice_pitch,
9792 const vector<Event>* events = NULL,
9793 Event* event = NULL)
9796 CommandQueue queue = CommandQueue::getDefault(&error);
9798 if (error != CL_SUCCESS) {
9802 return queue.enqueueWriteImage(
9814 inline cl_int enqueueCopyImage(
9817 const array<size_type, 3>& src_origin,
9818 const array<size_type, 3>& dst_origin,
9819 const array<size_type, 3>& region,
9820 const vector<Event>* events = NULL,
9821 Event* event = NULL)
9824 CommandQueue queue = CommandQueue::getDefault(&error);
9826 if (error != CL_SUCCESS) {
9830 return queue.enqueueCopyImage(
9840 inline cl_int enqueueCopyImageToBuffer(
9843 const array<size_type, 3>& src_origin,
9844 const array<size_type, 3>& region,
9845 size_type dst_offset,
9846 const vector<Event>* events = NULL,
9847 Event* event = NULL)
9850 CommandQueue queue = CommandQueue::getDefault(&error);
9852 if (error != CL_SUCCESS) {
9856 return queue.enqueueCopyImageToBuffer(
9866 inline cl_int enqueueCopyBufferToImage(
9869 size_type src_offset,
9870 const array<size_type, 3>& dst_origin,
9871 const array<size_type, 3>& region,
9872 const vector<Event>* events = NULL,
9873 Event* event = NULL)
9876 CommandQueue queue = CommandQueue::getDefault(&error);
9878 if (error != CL_SUCCESS) {
9882 return queue.enqueueCopyBufferToImage(
9893 inline cl_int flush(
void)
9896 CommandQueue queue = CommandQueue::getDefault(&error);
9898 if (error != CL_SUCCESS) {
9902 return queue.flush();
9905 inline cl_int finish(
void)
9908 CommandQueue queue = CommandQueue::getDefault(&error);
9910 if (error != CL_SUCCESS) {
9915 return queue.finish();
9925 vector<Event> events_;
9927 template<
typename... Ts>
9932 queue_(CommandQueue::getDefault()),
9941 queue_(CommandQueue::getDefault()),
9950 queue_(CommandQueue::getDefault()),
9959 queue_(CommandQueue::getDefault()),
9964 events_.push_back(e);
9968 queue_(CommandQueue::getDefault()),
9973 events_.push_back(e);
9977 queue_(CommandQueue::getDefault()),
9982 events_.push_back(e);
9986 queue_(CommandQueue::getDefault()),
9996 queue_(CommandQueue::getDefault()),
10006 queue_(CommandQueue::getDefault()),
10017 offset_(NullRange),
10026 offset_(NullRange),
10044 offset_(NullRange),
10048 events_.push_back(e);
10053 offset_(NullRange),
10057 events_.push_back(e);
10066 events_.push_back(e);
10071 offset_(NullRange),
10081 offset_(NullRange),
10108 template<
typename... Ts>
10114 template<
int index,
typename T0,
typename... T1s>
10115 void setArgs(T0&& t0, T1s&&... t1s)
10117 kernel_.
setArg(index, t0);
10118 setArgs<index + 1, T1s...>(std::forward<T1s>(t1s)...);
10121 template<
int index,
typename T0>
10122 void setArgs(T0&& t0)
10124 kernel_.
setArg(index, t0);
10127 template<
int index>
10140 cl_int * err = NULL) :
10141 kernel_(program, name.c_str(), err)
10157 setArgs<0>(std::forward<Ts>(ts)...);
10159 args.queue_.enqueueNDRangeKernel(
10182 setArgs<0>(std::forward<Ts>(ts)...);
10184 error = args.queue_.enqueueNDRangeKernel(
10195 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
10196 cl_int setSVMPointers(
const vector<void*> &pointerList)
10201 template<
typename T0,
typename... T1s>
10202 cl_int setSVMPointers(
const T0 &t0, T1s &... ts)
10214 namespace compatibility {
10219 template<
typename... Ts>
10229 cl_int * err = NULL) :
10251 enqueueArgs, args...);
10259 #undef CL_HPP_ERR_STR_
10260 #if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS)
10261 #undef __GET_DEVICE_INFO_ERR
10262 #undef __GET_PLATFORM_INFO_ERR
10263 #undef __GET_DEVICE_IDS_ERR
10264 #undef __GET_PLATFORM_IDS_ERR
10265 #undef __GET_CONTEXT_INFO_ERR
10266 #undef __GET_EVENT_INFO_ERR
10267 #undef __GET_EVENT_PROFILE_INFO_ERR
10268 #undef __GET_MEM_OBJECT_INFO_ERR
10269 #undef __GET_IMAGE_INFO_ERR
10270 #undef __GET_SAMPLER_INFO_ERR
10271 #undef __GET_KERNEL_INFO_ERR
10272 #undef __GET_KERNEL_ARG_INFO_ERR
10273 #undef __GET_KERNEL_SUB_GROUP_INFO_ERR
10274 #undef __GET_KERNEL_WORK_GROUP_INFO_ERR
10275 #undef __GET_PROGRAM_INFO_ERR
10276 #undef __GET_PROGRAM_BUILD_INFO_ERR
10277 #undef __GET_COMMAND_QUEUE_INFO_ERR
10278 #undef __CREATE_CONTEXT_ERR
10279 #undef __CREATE_CONTEXT_FROM_TYPE_ERR
10280 #undef __GET_SUPPORTED_IMAGE_FORMATS_ERR
10281 #undef __CREATE_BUFFER_ERR
10283 #undef __CREATE_SUBBUFFER_ERR
10284 #undef __CREATE_GL_BUFFER_ERR
10285 #undef __CREATE_GL_RENDER_BUFFER_ERR
10286 #undef __GET_GL_OBJECT_INFO_ERR
10287 #undef __CREATE_IMAGE_ERR
10288 #undef __CREATE_GL_TEXTURE_ERR
10289 #undef __IMAGE_DIMENSION_ERR
10290 #undef __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR
10291 #undef __CREATE_USER_EVENT_ERR
10292 #undef __SET_USER_EVENT_STATUS_ERR
10293 #undef __SET_EVENT_CALLBACK_ERR
10294 #undef __WAIT_FOR_EVENTS_ERR
10295 #undef __CREATE_KERNEL_ERR
10296 #undef __SET_KERNEL_ARGS_ERR
10297 #undef __CREATE_PROGRAM_WITH_SOURCE_ERR
10298 #undef __CREATE_PROGRAM_WITH_IL_ERR
10299 #undef __CREATE_PROGRAM_WITH_BINARY_ERR
10300 #undef __CREATE_PROGRAM_WITH_IL_ERR
10301 #undef __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR
10302 #undef __BUILD_PROGRAM_ERR
10303 #undef __COMPILE_PROGRAM_ERR
10304 #undef __LINK_PROGRAM_ERR
10305 #undef __CREATE_KERNELS_IN_PROGRAM_ERR
10306 #undef __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR
10307 #undef __CREATE_SAMPLER_WITH_PROPERTIES_ERR
10308 #undef __SET_COMMAND_QUEUE_PROPERTY_ERR
10309 #undef __ENQUEUE_READ_BUFFER_ERR
10310 #undef __ENQUEUE_READ_BUFFER_RECT_ERR
10311 #undef __ENQUEUE_WRITE_BUFFER_ERR
10312 #undef __ENQUEUE_WRITE_BUFFER_RECT_ERR
10313 #undef __ENQEUE_COPY_BUFFER_ERR
10314 #undef __ENQEUE_COPY_BUFFER_RECT_ERR
10315 #undef __ENQUEUE_FILL_BUFFER_ERR
10316 #undef __ENQUEUE_READ_IMAGE_ERR
10317 #undef __ENQUEUE_WRITE_IMAGE_ERR
10318 #undef __ENQUEUE_COPY_IMAGE_ERR
10319 #undef __ENQUEUE_FILL_IMAGE_ERR
10320 #undef __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR
10321 #undef __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR
10322 #undef __ENQUEUE_MAP_BUFFER_ERR
10323 #undef __ENQUEUE_MAP_IMAGE_ERR
10324 #undef __ENQUEUE_UNMAP_MEM_OBJECT_ERR
10325 #undef __ENQUEUE_NDRANGE_KERNEL_ERR
10326 #undef __ENQUEUE_NATIVE_KERNEL
10327 #undef __ENQUEUE_MIGRATE_MEM_OBJECTS_ERR
10328 #undef __ENQUEUE_MIGRATE_SVM_ERR
10329 #undef __ENQUEUE_ACQUIRE_GL_ERR
10330 #undef __ENQUEUE_RELEASE_GL_ERR
10331 #undef __CREATE_PIPE_ERR
10332 #undef __GET_PIPE_INFO_ERR
10333 #undef __RETAIN_ERR
10334 #undef __RELEASE_ERR
10336 #undef __FINISH_ERR
10337 #undef __VECTOR_CAPACITY_ERR
10338 #undef __CREATE_SUB_DEVICES_ERR
10339 #undef __CREATE_SUB_DEVICES_ERR
10340 #undef __ENQUEUE_MARKER_ERR
10341 #undef __ENQUEUE_WAIT_FOR_EVENTS_ERR
10342 #undef __ENQUEUE_BARRIER_ERR
10343 #undef __UNLOAD_COMPILER_ERR
10344 #undef __CREATE_GL_TEXTURE_2D_ERR
10345 #undef __CREATE_GL_TEXTURE_3D_ERR
10346 #undef __CREATE_IMAGE2D_ERR
10347 #undef __CREATE_IMAGE3D_ERR
10348 #undef __CREATE_COMMAND_QUEUE_ERR
10349 #undef __ENQUEUE_TASK_ERR
10350 #undef __CREATE_SAMPLER_ERR
10351 #undef __ENQUEUE_MARKER_WAIT_LIST_ERR
10352 #undef __ENQUEUE_BARRIER_WAIT_LIST_ERR
10353 #undef __CLONE_KERNEL_ERR
10354 #undef __GET_HOST_TIMER_ERR
10355 #undef __GET_DEVICE_AND_HOST_TIMER_ERR
10360 #undef CL_HPP_INIT_CL_EXT_FCN_PTR_
10361 #undef CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_
10363 #if defined(CL_HPP_USE_CL_DEVICE_FISSION)
10364 #undef CL_HPP_PARAM_NAME_DEVICE_FISSION_
10367 #undef CL_HPP_NOEXCEPT_
10368 #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)