403 #if !defined(CL_HPP_USE_DX_INTEROP) && defined(USE_DX_INTEROP)
404 # pragma message("opencl.hpp: USE_DX_INTEROP is deprecated. Define CL_HPP_USE_DX_INTEROP instead")
405 # define CL_HPP_USE_DX_INTEROP
407 #if !defined(CL_HPP_USE_CL_DEVICE_FISSION) && defined(USE_CL_DEVICE_FISSION)
408 # pragma message("opencl.hpp: USE_CL_DEVICE_FISSION is deprecated. Define CL_HPP_USE_CL_DEVICE_FISSION instead")
409 # define CL_HPP_USE_CL_DEVICE_FISSION
411 #if !defined(CL_HPP_ENABLE_EXCEPTIONS) && defined(__CL_ENABLE_EXCEPTIONS)
412 # pragma message("opencl.hpp: __CL_ENABLE_EXCEPTIONS is deprecated. Define CL_HPP_ENABLE_EXCEPTIONS instead")
413 # define CL_HPP_ENABLE_EXCEPTIONS
415 #if !defined(CL_HPP_NO_STD_VECTOR) && defined(__NO_STD_VECTOR)
416 # pragma message("opencl.hpp: __NO_STD_VECTOR is deprecated. Define CL_HPP_NO_STD_VECTOR instead")
417 # define CL_HPP_NO_STD_VECTOR
419 #if !defined(CL_HPP_NO_STD_STRING) && defined(__NO_STD_STRING)
420 # pragma message("opencl.hpp: __NO_STD_STRING is deprecated. Define CL_HPP_NO_STD_STRING instead")
421 # define CL_HPP_NO_STD_STRING
423 #if defined(VECTOR_CLASS)
424 # pragma message("opencl.hpp: VECTOR_CLASS is deprecated. Alias cl::vector instead")
426 #if defined(STRING_CLASS)
427 # pragma message("opencl.hpp: STRING_CLASS is deprecated. Alias cl::string instead.")
429 #if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS) && defined(__CL_USER_OVERRIDE_ERROR_STRINGS)
430 # pragma message("opencl.hpp: __CL_USER_OVERRIDE_ERROR_STRINGS is deprecated. Define CL_HPP_USER_OVERRIDE_ERROR_STRINGS instead")
431 # define CL_HPP_USER_OVERRIDE_ERROR_STRINGS
436 #if defined(__USE_DEV_VECTOR)
437 # pragma message("opencl.hpp: __USE_DEV_VECTOR is no longer supported. Expect compilation errors")
439 #if defined(__USE_DEV_STRING)
440 # pragma message("opencl.hpp: __USE_DEV_STRING is no longer supported. Expect compilation errors")
444 #if !defined(CL_HPP_TARGET_OPENCL_VERSION)
445 # pragma message("opencl.hpp: CL_HPP_TARGET_OPENCL_VERSION is not defined. It will default to 300 (OpenCL 3.0)")
446 # define CL_HPP_TARGET_OPENCL_VERSION 300
448 #if CL_HPP_TARGET_OPENCL_VERSION != 100 && \
449 CL_HPP_TARGET_OPENCL_VERSION != 110 && \
450 CL_HPP_TARGET_OPENCL_VERSION != 120 && \
451 CL_HPP_TARGET_OPENCL_VERSION != 200 && \
452 CL_HPP_TARGET_OPENCL_VERSION != 210 && \
453 CL_HPP_TARGET_OPENCL_VERSION != 220 && \
454 CL_HPP_TARGET_OPENCL_VERSION != 300
455 # pragma message("opencl.hpp: CL_HPP_TARGET_OPENCL_VERSION is not a valid value (100, 110, 120, 200, 210, 220 or 300). It will be set to 300 (OpenCL 3.0).")
456 # undef CL_HPP_TARGET_OPENCL_VERSION
457 # define CL_HPP_TARGET_OPENCL_VERSION 300
461 #if defined(CL_TARGET_OPENCL_VERSION)
464 #if CL_TARGET_OPENCL_VERSION < CL_HPP_TARGET_OPENCL_VERSION
465 # pragma message("CL_TARGET_OPENCL_VERSION is already defined as is lower than CL_HPP_TARGET_OPENCL_VERSION")
468 # define CL_TARGET_OPENCL_VERSION CL_HPP_TARGET_OPENCL_VERSION
471 #if !defined(CL_HPP_MINIMUM_OPENCL_VERSION)
472 # define CL_HPP_MINIMUM_OPENCL_VERSION 200
474 #if CL_HPP_MINIMUM_OPENCL_VERSION != 100 && \
475 CL_HPP_MINIMUM_OPENCL_VERSION != 110 && \
476 CL_HPP_MINIMUM_OPENCL_VERSION != 120 && \
477 CL_HPP_MINIMUM_OPENCL_VERSION != 200 && \
478 CL_HPP_MINIMUM_OPENCL_VERSION != 210 && \
479 CL_HPP_MINIMUM_OPENCL_VERSION != 220 && \
480 CL_HPP_MINIMUM_OPENCL_VERSION != 300
481 # pragma message("opencl.hpp: CL_HPP_MINIMUM_OPENCL_VERSION is not a valid value (100, 110, 120, 200, 210, 220 or 300). It will be set to 100")
482 # undef CL_HPP_MINIMUM_OPENCL_VERSION
483 # define CL_HPP_MINIMUM_OPENCL_VERSION 100
485 #if CL_HPP_MINIMUM_OPENCL_VERSION > CL_HPP_TARGET_OPENCL_VERSION
486 # error "CL_HPP_MINIMUM_OPENCL_VERSION must not be greater than CL_HPP_TARGET_OPENCL_VERSION"
489 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 100 && !defined(CL_USE_DEPRECATED_OPENCL_1_0_APIS)
490 # define CL_USE_DEPRECATED_OPENCL_1_0_APIS
492 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 110 && !defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
493 # define CL_USE_DEPRECATED_OPENCL_1_1_APIS
495 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 120 && !defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
496 # define CL_USE_DEPRECATED_OPENCL_1_2_APIS
498 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 200 && !defined(CL_USE_DEPRECATED_OPENCL_2_0_APIS)
499 # define CL_USE_DEPRECATED_OPENCL_2_0_APIS
501 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 210 && !defined(CL_USE_DEPRECATED_OPENCL_2_1_APIS)
502 # define CL_USE_DEPRECATED_OPENCL_2_1_APIS
504 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 220 && !defined(CL_USE_DEPRECATED_OPENCL_2_2_APIS)
505 # define CL_USE_DEPRECATED_OPENCL_2_2_APIS
512 #if defined(CL_HPP_USE_DX_INTEROP)
513 #include <CL/cl_d3d10.h>
514 #include <CL/cl_dx9_media_sharing.h>
518 #if defined(_MSC_VER)
526 #if (!defined(_MSC_VER) && __cplusplus < 201103L) || (defined(_MSC_VER) && _MSC_VER < 1700)
527 #error Visual studio 2013 or another C++11-supporting compiler required
531 #if defined(CL_HPP_USE_CL_DEVICE_FISSION) || defined(CL_HPP_USE_CL_SUB_GROUPS_KHR)
532 #include <CL/cl_ext.h>
535 #if defined(__APPLE__) || defined(__MACOSX)
536 #include <OpenCL/opencl.h>
538 #include <CL/opencl.h>
541 #if (__cplusplus >= 201103L || _MSVC_LANG >= 201103L )
542 #define CL_HPP_NOEXCEPT_ noexcept
544 #define CL_HPP_NOEXCEPT_
547 #if __cplusplus >= 201703L
548 # define CL_HPP_DEFINE_STATIC_MEMBER_ inline
549 #elif defined(_MSC_VER)
550 # define CL_HPP_DEFINE_STATIC_MEMBER_ __declspec(selectany)
551 #elif defined(__MINGW32__)
552 # define CL_HPP_DEFINE_STATIC_MEMBER_ __attribute__((selectany))
554 # define CL_HPP_DEFINE_STATIC_MEMBER_ __attribute__((weak))
559 #if !defined(CL_API_PREFIX__VERSION_1_1_DEPRECATED)
560 #define CL_API_PREFIX__VERSION_1_1_DEPRECATED
562 #if !defined(CL_API_SUFFIX__VERSION_1_1_DEPRECATED)
563 #define CL_API_SUFFIX__VERSION_1_1_DEPRECATED
566 #if !defined(CL_API_PREFIX__VERSION_1_2_DEPRECATED)
567 #define CL_API_PREFIX__VERSION_1_2_DEPRECATED
569 #if !defined(CL_API_SUFFIX__VERSION_1_2_DEPRECATED)
570 #define CL_API_SUFFIX__VERSION_1_2_DEPRECATED
573 #if !defined(CL_API_PREFIX__VERSION_2_2_DEPRECATED)
574 #define CL_API_PREFIX__VERSION_2_2_DEPRECATED
576 #if !defined(CL_API_SUFFIX__VERSION_2_2_DEPRECATED)
577 #define CL_API_SUFFIX__VERSION_2_2_DEPRECATED
580 #if !defined(CL_CALLBACK)
589 #include <functional>
593 #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY)
595 using size_type = ::size_t;
599 using size_type = size_t;
604 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
608 #if !defined(CL_HPP_NO_STD_VECTOR)
611 template <
class T,
class Alloc = std::allocator<T> >
612 using vector = std::vector<T, Alloc>;
616 #if !defined(CL_HPP_NO_STD_STRING)
619 using string = std::string;
623 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
625 #if !defined(CL_HPP_NO_STD_UNIQUE_PTR)
630 template<
class T,
class D>
631 using pointer = std::unique_ptr<T, D>;
635 #if !defined(CL_HPP_NO_STD_ARRAY)
638 template <
class T,
size_type N >
639 using array = std::array<T, N>;
645 #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY)
647 namespace compatibility {
662 for (
int i = 0; i < N; ++i) {
667 size_t(
const array<size_type, N> &rhs)
669 for (
int i = 0; i < N; ++i) {
674 size_type& operator[](
int index)
679 const size_type& operator[](
int index)
const
685 operator size_type* () {
return data_; }
688 operator const size_type* ()
const {
return data_; }
690 operator array<size_type, N>()
const
692 array<size_type, N> ret;
694 for (
int i = 0; i < N; ++i) {
703 using size_t = compatibility::size_t<N>;
710 using size_t_array = array<size_type, 3>;
723 #define CL_HPP_INIT_CL_EXT_FCN_PTR_(name) \
725 pfn_##name = (PFN_##name) \
726 clGetExtensionFunctionAddress(#name); \
731 #define CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, name) \
733 pfn_##name = (PFN_##name) \
734 clGetExtensionFunctionAddressForPlatform(platform, #name); \
743 class DeviceCommandQueue;
748 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
753 class Error :
public std::exception
757 const char * errStr_;
768 Error(cl_int err,
const char * errStr = NULL) : err_(err), errStr_(errStr)
777 virtual const char * what()
const throw ()
779 if (errStr_ == NULL) {
791 cl_int err(
void)
const {
return err_; }
793 #define CL_HPP_ERR_STR_(x) #x
795 #define CL_HPP_ERR_STR_(x) NULL
801 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
802 static inline cl_int errHandler (
804 const char * errStr = NULL)
806 if (err != CL_SUCCESS) {
807 throw Error(err, errStr);
812 static inline cl_int errHandler (cl_int err,
const char * errStr = NULL)
823 #if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS)
824 #define __GET_DEVICE_INFO_ERR CL_HPP_ERR_STR_(clGetDeviceInfo)
825 #define __GET_PLATFORM_INFO_ERR CL_HPP_ERR_STR_(clGetPlatformInfo)
826 #define __GET_DEVICE_IDS_ERR CL_HPP_ERR_STR_(clGetDeviceIDs)
827 #define __GET_PLATFORM_IDS_ERR CL_HPP_ERR_STR_(clGetPlatformIDs)
828 #define __GET_CONTEXT_INFO_ERR CL_HPP_ERR_STR_(clGetContextInfo)
829 #define __GET_EVENT_INFO_ERR CL_HPP_ERR_STR_(clGetEventInfo)
830 #define __GET_EVENT_PROFILE_INFO_ERR CL_HPP_ERR_STR_(clGetEventProfileInfo)
831 #define __GET_MEM_OBJECT_INFO_ERR CL_HPP_ERR_STR_(clGetMemObjectInfo)
832 #define __GET_IMAGE_INFO_ERR CL_HPP_ERR_STR_(clGetImageInfo)
833 #define __GET_SAMPLER_INFO_ERR CL_HPP_ERR_STR_(clGetSamplerInfo)
834 #define __GET_KERNEL_INFO_ERR CL_HPP_ERR_STR_(clGetKernelInfo)
835 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
836 #define __GET_KERNEL_ARG_INFO_ERR CL_HPP_ERR_STR_(clGetKernelArgInfo)
838 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
839 #define __GET_KERNEL_SUB_GROUP_INFO_ERR CL_HPP_ERR_STR_(clGetKernelSubGroupInfo)
841 #define __GET_KERNEL_WORK_GROUP_INFO_ERR CL_HPP_ERR_STR_(clGetKernelWorkGroupInfo)
842 #define __GET_PROGRAM_INFO_ERR CL_HPP_ERR_STR_(clGetProgramInfo)
843 #define __GET_PROGRAM_BUILD_INFO_ERR CL_HPP_ERR_STR_(clGetProgramBuildInfo)
844 #define __GET_COMMAND_QUEUE_INFO_ERR CL_HPP_ERR_STR_(clGetCommandQueueInfo)
846 #define __CREATE_CONTEXT_ERR CL_HPP_ERR_STR_(clCreateContext)
847 #define __CREATE_CONTEXT_FROM_TYPE_ERR CL_HPP_ERR_STR_(clCreateContextFromType)
848 #define __GET_SUPPORTED_IMAGE_FORMATS_ERR CL_HPP_ERR_STR_(clGetSupportedImageFormats)
850 #define __CREATE_BUFFER_ERR CL_HPP_ERR_STR_(clCreateBuffer)
851 #define __COPY_ERR CL_HPP_ERR_STR_(cl::copy)
852 #define __CREATE_SUBBUFFER_ERR CL_HPP_ERR_STR_(clCreateSubBuffer)
853 #define __CREATE_GL_BUFFER_ERR CL_HPP_ERR_STR_(clCreateFromGLBuffer)
854 #define __CREATE_GL_RENDER_BUFFER_ERR CL_HPP_ERR_STR_(clCreateFromGLBuffer)
855 #define __GET_GL_OBJECT_INFO_ERR CL_HPP_ERR_STR_(clGetGLObjectInfo)
856 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
857 #define __CREATE_IMAGE_ERR CL_HPP_ERR_STR_(clCreateImage)
858 #define __CREATE_GL_TEXTURE_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture)
859 #define __IMAGE_DIMENSION_ERR CL_HPP_ERR_STR_(Incorrect image dimensions)
861 #define __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR CL_HPP_ERR_STR_(clSetMemObjectDestructorCallback)
863 #define __CREATE_USER_EVENT_ERR CL_HPP_ERR_STR_(clCreateUserEvent)
864 #define __SET_USER_EVENT_STATUS_ERR CL_HPP_ERR_STR_(clSetUserEventStatus)
865 #define __SET_EVENT_CALLBACK_ERR CL_HPP_ERR_STR_(clSetEventCallback)
866 #define __WAIT_FOR_EVENTS_ERR CL_HPP_ERR_STR_(clWaitForEvents)
868 #define __CREATE_KERNEL_ERR CL_HPP_ERR_STR_(clCreateKernel)
869 #define __SET_KERNEL_ARGS_ERR CL_HPP_ERR_STR_(clSetKernelArg)
870 #define __CREATE_PROGRAM_WITH_SOURCE_ERR CL_HPP_ERR_STR_(clCreateProgramWithSource)
871 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
872 #define __CREATE_PROGRAM_WITH_IL_ERR CL_HPP_ERR_STR_(clCreateProgramWithIL)
874 #define __CREATE_PROGRAM_WITH_BINARY_ERR CL_HPP_ERR_STR_(clCreateProgramWithBinary)
875 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
876 #define __CREATE_PROGRAM_WITH_IL_ERR CL_HPP_ERR_STR_(clCreateProgramWithIL)
878 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
879 #define __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR CL_HPP_ERR_STR_(clCreateProgramWithBuiltInKernels)
881 #define __BUILD_PROGRAM_ERR CL_HPP_ERR_STR_(clBuildProgram)
882 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
883 #define __COMPILE_PROGRAM_ERR CL_HPP_ERR_STR_(clCompileProgram)
884 #define __LINK_PROGRAM_ERR CL_HPP_ERR_STR_(clLinkProgram)
886 #define __CREATE_KERNELS_IN_PROGRAM_ERR CL_HPP_ERR_STR_(clCreateKernelsInProgram)
888 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
889 #define __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR CL_HPP_ERR_STR_(clCreateCommandQueueWithProperties)
890 #define __CREATE_SAMPLER_WITH_PROPERTIES_ERR CL_HPP_ERR_STR_(clCreateSamplerWithProperties)
892 #define __SET_COMMAND_QUEUE_PROPERTY_ERR CL_HPP_ERR_STR_(clSetCommandQueueProperty)
893 #define __ENQUEUE_READ_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueReadBuffer)
894 #define __ENQUEUE_READ_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueReadBufferRect)
895 #define __ENQUEUE_WRITE_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueWriteBuffer)
896 #define __ENQUEUE_WRITE_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueWriteBufferRect)
897 #define __ENQEUE_COPY_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueCopyBuffer)
898 #define __ENQEUE_COPY_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueCopyBufferRect)
899 #define __ENQUEUE_FILL_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueFillBuffer)
900 #define __ENQUEUE_READ_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueReadImage)
901 #define __ENQUEUE_WRITE_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueWriteImage)
902 #define __ENQUEUE_COPY_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueCopyImage)
903 #define __ENQUEUE_FILL_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueFillImage)
904 #define __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueCopyImageToBuffer)
905 #define __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueCopyBufferToImage)
906 #define __ENQUEUE_MAP_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueMapBuffer)
907 #define __ENQUEUE_MAP_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueMapImage)
908 #define __ENQUEUE_UNMAP_MEM_OBJECT_ERR CL_HPP_ERR_STR_(clEnqueueUnMapMemObject)
909 #define __ENQUEUE_NDRANGE_KERNEL_ERR CL_HPP_ERR_STR_(clEnqueueNDRangeKernel)
910 #define __ENQUEUE_NATIVE_KERNEL CL_HPP_ERR_STR_(clEnqueueNativeKernel)
911 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
912 #define __ENQUEUE_MIGRATE_MEM_OBJECTS_ERR CL_HPP_ERR_STR_(clEnqueueMigrateMemObjects)
914 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
915 #define __ENQUEUE_MIGRATE_SVM_ERR CL_HPP_ERR_STR_(clEnqueueSVMMigrateMem)
916 #define __SET_DEFAULT_DEVICE_COMMAND_QUEUE_ERR CL_HPP_ERR_STR_(clSetDefaultDeviceCommandQueue)
920 #define __ENQUEUE_ACQUIRE_GL_ERR CL_HPP_ERR_STR_(clEnqueueAcquireGLObjects)
921 #define __ENQUEUE_RELEASE_GL_ERR CL_HPP_ERR_STR_(clEnqueueReleaseGLObjects)
923 #define __CREATE_PIPE_ERR CL_HPP_ERR_STR_(clCreatePipe)
924 #define __GET_PIPE_INFO_ERR CL_HPP_ERR_STR_(clGetPipeInfo)
927 #define __RETAIN_ERR CL_HPP_ERR_STR_(Retain Object)
928 #define __RELEASE_ERR CL_HPP_ERR_STR_(Release Object)
929 #define __FLUSH_ERR CL_HPP_ERR_STR_(clFlush)
930 #define __FINISH_ERR CL_HPP_ERR_STR_(clFinish)
931 #define __VECTOR_CAPACITY_ERR CL_HPP_ERR_STR_(Vector capacity error)
933 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
934 #define __GET_HOST_TIMER_ERR CL_HPP_ERR_STR_(clGetHostTimer)
935 #define __GET_DEVICE_AND_HOST_TIMER_ERR CL_HPP_ERR_STR_(clGetDeviceAndHostTimer)
937 #if CL_HPP_TARGET_OPENCL_VERSION >= 220
938 #define __SET_PROGRAM_RELEASE_CALLBACK_ERR CL_HPP_ERR_STR_(clSetProgramReleaseCallback)
939 #define __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR CL_HPP_ERR_STR_(clSetProgramSpecializationConstant)
946 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
947 #define __CREATE_SUB_DEVICES_ERR CL_HPP_ERR_STR_(clCreateSubDevices)
949 #define __CREATE_SUB_DEVICES_ERR CL_HPP_ERR_STR_(clCreateSubDevicesEXT)
955 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
956 #define __ENQUEUE_MARKER_ERR CL_HPP_ERR_STR_(clEnqueueMarker)
957 #define __ENQUEUE_WAIT_FOR_EVENTS_ERR CL_HPP_ERR_STR_(clEnqueueWaitForEvents)
958 #define __ENQUEUE_BARRIER_ERR CL_HPP_ERR_STR_(clEnqueueBarrier)
959 #define __UNLOAD_COMPILER_ERR CL_HPP_ERR_STR_(clUnloadCompiler)
960 #define __CREATE_GL_TEXTURE_2D_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture2D)
961 #define __CREATE_GL_TEXTURE_3D_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture3D)
962 #define __CREATE_IMAGE2D_ERR CL_HPP_ERR_STR_(clCreateImage2D)
963 #define __CREATE_IMAGE3D_ERR CL_HPP_ERR_STR_(clCreateImage3D)
969 #if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
970 #define __CREATE_COMMAND_QUEUE_ERR CL_HPP_ERR_STR_(clCreateCommandQueue)
971 #define __ENQUEUE_TASK_ERR CL_HPP_ERR_STR_(clEnqueueTask)
972 #define __CREATE_SAMPLER_ERR CL_HPP_ERR_STR_(clCreateSampler)
978 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
979 #define __ENQUEUE_MARKER_WAIT_LIST_ERR CL_HPP_ERR_STR_(clEnqueueMarkerWithWaitList)
980 #define __ENQUEUE_BARRIER_WAIT_LIST_ERR CL_HPP_ERR_STR_(clEnqueueBarrierWithWaitList)
983 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
984 #define __CLONE_KERNEL_ERR CL_HPP_ERR_STR_(clCloneKernel)
997 template<
typename Functor,
typename T>
998 inline cl_int getInfoHelper(Functor f, cl_uint name, T* param,
long)
1000 return f(name,
sizeof(T), param, NULL);
1005 template <
typename Func>
1006 inline cl_int getInfoHelper(Func f, cl_uint name, vector<vector<unsigned char>>* param,
int)
1008 if (name != CL_PROGRAM_BINARIES) {
1009 return CL_INVALID_VALUE;
1013 size_type numBinaries = param->size();
1014 vector<unsigned char*> binariesPointers(numBinaries);
1016 for (size_type i = 0; i < numBinaries; ++i)
1018 binariesPointers[i] = (*param)[i].data();
1021 cl_int err = f(name, numBinaries *
sizeof(
unsigned char*), binariesPointers.data(), NULL);
1023 if (err != CL_SUCCESS) {
1033 template <
typename Func,
typename T>
1034 inline cl_int getInfoHelper(Func f, cl_uint name, vector<T>* param,
long)
1037 cl_int err = f(name, 0, NULL, &required);
1038 if (err != CL_SUCCESS) {
1041 const size_type elements = required /
sizeof(T);
1044 vector<T> localData(elements);
1045 err = f(name, required, localData.data(), NULL);
1046 if (err != CL_SUCCESS) {
1050 *param = std::move(localData);
1062 template <
typename Func,
typename T>
1063 inline cl_int getInfoHelper(
1064 Func f, cl_uint name, vector<T>* param,
int,
typename T::cl_type = 0)
1067 cl_int err = f(name, 0, NULL, &required);
1068 if (err != CL_SUCCESS) {
1072 const size_type elements = required /
sizeof(
typename T::cl_type);
1074 vector<typename T::cl_type> value(elements);
1075 err = f(name, required, value.data(), NULL);
1076 if (err != CL_SUCCESS) {
1082 param->resize(elements);
1086 for (size_type i = 0; i < elements; i++) {
1087 (*param)[i] = T(value[i],
true);
1094 template <
typename Func>
1095 inline cl_int getInfoHelper(Func f, cl_uint name,
string* param,
long)
1098 cl_int err = f(name, 0, NULL, &required);
1099 if (err != CL_SUCCESS) {
1106 vector<char> value(required);
1107 err = f(name, required, value.data(), NULL);
1108 if (err != CL_SUCCESS) {
1112 param->assign(begin(value), prev(end(value)));
1122 template <
typename Func,
size_type N>
1123 inline cl_int getInfoHelper(Func f, cl_uint name, array<size_type, N>* param,
long)
1126 cl_int err = f(name, 0, NULL, &required);
1127 if (err != CL_SUCCESS) {
1131 size_type elements = required /
sizeof(size_type);
1132 vector<size_type> value(elements, 0);
1134 err = f(name, required, value.data(), NULL);
1135 if (err != CL_SUCCESS) {
1144 for (size_type i = 0; i < elements; ++i) {
1145 (*param)[i] = value[i];
1151 template<
typename T>
struct ReferenceHandler;
1159 template<
typename Func,
typename T>
1160 inline cl_int getInfoHelper(Func f, cl_uint name, T* param,
int,
typename T::cl_type = 0)
1162 typename T::cl_type value;
1163 cl_int err = f(name,
sizeof(value), &value, NULL);
1164 if (err != CL_SUCCESS) {
1170 err = param->retain();
1171 if (err != CL_SUCCESS) {
1178 #define CL_HPP_PARAM_NAME_INFO_1_0_(F) \
1179 F(cl_platform_info, CL_PLATFORM_PROFILE, string) \
1180 F(cl_platform_info, CL_PLATFORM_VERSION, string) \
1181 F(cl_platform_info, CL_PLATFORM_NAME, string) \
1182 F(cl_platform_info, CL_PLATFORM_VENDOR, string) \
1183 F(cl_platform_info, CL_PLATFORM_EXTENSIONS, string) \
1185 F(cl_device_info, CL_DEVICE_TYPE, cl_device_type) \
1186 F(cl_device_info, CL_DEVICE_VENDOR_ID, cl_uint) \
1187 F(cl_device_info, CL_DEVICE_MAX_COMPUTE_UNITS, cl_uint) \
1188 F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, cl_uint) \
1189 F(cl_device_info, CL_DEVICE_MAX_WORK_GROUP_SIZE, size_type) \
1190 F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_SIZES, cl::vector<size_type>) \
1191 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, cl_uint) \
1192 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT, cl_uint) \
1193 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT, cl_uint) \
1194 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG, cl_uint) \
1195 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT, cl_uint) \
1196 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, cl_uint) \
1197 F(cl_device_info, CL_DEVICE_MAX_CLOCK_FREQUENCY, cl_uint) \
1198 F(cl_device_info, CL_DEVICE_ADDRESS_BITS, cl_uint) \
1199 F(cl_device_info, CL_DEVICE_MAX_READ_IMAGE_ARGS, cl_uint) \
1200 F(cl_device_info, CL_DEVICE_MAX_WRITE_IMAGE_ARGS, cl_uint) \
1201 F(cl_device_info, CL_DEVICE_MAX_MEM_ALLOC_SIZE, cl_ulong) \
1202 F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_WIDTH, size_type) \
1203 F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_HEIGHT, size_type) \
1204 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_WIDTH, size_type) \
1205 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_HEIGHT, size_type) \
1206 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_DEPTH, size_type) \
1207 F(cl_device_info, CL_DEVICE_IMAGE_SUPPORT, cl_bool) \
1208 F(cl_device_info, CL_DEVICE_MAX_PARAMETER_SIZE, size_type) \
1209 F(cl_device_info, CL_DEVICE_MAX_SAMPLERS, cl_uint) \
1210 F(cl_device_info, CL_DEVICE_MEM_BASE_ADDR_ALIGN, cl_uint) \
1211 F(cl_device_info, CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE, cl_uint) \
1212 F(cl_device_info, CL_DEVICE_SINGLE_FP_CONFIG, cl_device_fp_config) \
1213 F(cl_device_info, CL_DEVICE_DOUBLE_FP_CONFIG, cl_device_fp_config) \
1214 F(cl_device_info, CL_DEVICE_HALF_FP_CONFIG, cl_device_fp_config) \
1215 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_TYPE, cl_device_mem_cache_type) \
1216 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE, cl_uint)\
1217 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_SIZE, cl_ulong) \
1218 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_SIZE, cl_ulong) \
1219 F(cl_device_info, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE, cl_ulong) \
1220 F(cl_device_info, CL_DEVICE_MAX_CONSTANT_ARGS, cl_uint) \
1221 F(cl_device_info, CL_DEVICE_LOCAL_MEM_TYPE, cl_device_local_mem_type) \
1222 F(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE, cl_ulong) \
1223 F(cl_device_info, CL_DEVICE_ERROR_CORRECTION_SUPPORT, cl_bool) \
1224 F(cl_device_info, CL_DEVICE_PROFILING_TIMER_RESOLUTION, size_type) \
1225 F(cl_device_info, CL_DEVICE_ENDIAN_LITTLE, cl_bool) \
1226 F(cl_device_info, CL_DEVICE_AVAILABLE, cl_bool) \
1227 F(cl_device_info, CL_DEVICE_COMPILER_AVAILABLE, cl_bool) \
1228 F(cl_device_info, CL_DEVICE_EXECUTION_CAPABILITIES, cl_device_exec_capabilities) \
1229 F(cl_device_info, CL_DEVICE_PLATFORM, cl_platform_id) \
1230 F(cl_device_info, CL_DEVICE_NAME, string) \
1231 F(cl_device_info, CL_DEVICE_VENDOR, string) \
1232 F(cl_device_info, CL_DRIVER_VERSION, string) \
1233 F(cl_device_info, CL_DEVICE_PROFILE, string) \
1234 F(cl_device_info, CL_DEVICE_VERSION, string) \
1235 F(cl_device_info, CL_DEVICE_EXTENSIONS, string) \
1237 F(cl_context_info, CL_CONTEXT_REFERENCE_COUNT, cl_uint) \
1238 F(cl_context_info, CL_CONTEXT_DEVICES, cl::vector<Device>) \
1239 F(cl_context_info, CL_CONTEXT_PROPERTIES, cl::vector<cl_context_properties>) \
1241 F(cl_event_info, CL_EVENT_COMMAND_QUEUE, cl::CommandQueue) \
1242 F(cl_event_info, CL_EVENT_COMMAND_TYPE, cl_command_type) \
1243 F(cl_event_info, CL_EVENT_REFERENCE_COUNT, cl_uint) \
1244 F(cl_event_info, CL_EVENT_COMMAND_EXECUTION_STATUS, cl_int) \
1246 F(cl_profiling_info, CL_PROFILING_COMMAND_QUEUED, cl_ulong) \
1247 F(cl_profiling_info, CL_PROFILING_COMMAND_SUBMIT, cl_ulong) \
1248 F(cl_profiling_info, CL_PROFILING_COMMAND_START, cl_ulong) \
1249 F(cl_profiling_info, CL_PROFILING_COMMAND_END, cl_ulong) \
1251 F(cl_mem_info, CL_MEM_TYPE, cl_mem_object_type) \
1252 F(cl_mem_info, CL_MEM_FLAGS, cl_mem_flags) \
1253 F(cl_mem_info, CL_MEM_SIZE, size_type) \
1254 F(cl_mem_info, CL_MEM_HOST_PTR, void*) \
1255 F(cl_mem_info, CL_MEM_MAP_COUNT, cl_uint) \
1256 F(cl_mem_info, CL_MEM_REFERENCE_COUNT, cl_uint) \
1257 F(cl_mem_info, CL_MEM_CONTEXT, cl::Context) \
1259 F(cl_image_info, CL_IMAGE_FORMAT, cl_image_format) \
1260 F(cl_image_info, CL_IMAGE_ELEMENT_SIZE, size_type) \
1261 F(cl_image_info, CL_IMAGE_ROW_PITCH, size_type) \
1262 F(cl_image_info, CL_IMAGE_SLICE_PITCH, size_type) \
1263 F(cl_image_info, CL_IMAGE_WIDTH, size_type) \
1264 F(cl_image_info, CL_IMAGE_HEIGHT, size_type) \
1265 F(cl_image_info, CL_IMAGE_DEPTH, size_type) \
1267 F(cl_sampler_info, CL_SAMPLER_REFERENCE_COUNT, cl_uint) \
1268 F(cl_sampler_info, CL_SAMPLER_CONTEXT, cl::Context) \
1269 F(cl_sampler_info, CL_SAMPLER_NORMALIZED_COORDS, cl_bool) \
1270 F(cl_sampler_info, CL_SAMPLER_ADDRESSING_MODE, cl_addressing_mode) \
1271 F(cl_sampler_info, CL_SAMPLER_FILTER_MODE, cl_filter_mode) \
1273 F(cl_program_info, CL_PROGRAM_REFERENCE_COUNT, cl_uint) \
1274 F(cl_program_info, CL_PROGRAM_CONTEXT, cl::Context) \
1275 F(cl_program_info, CL_PROGRAM_NUM_DEVICES, cl_uint) \
1276 F(cl_program_info, CL_PROGRAM_DEVICES, cl::vector<Device>) \
1277 F(cl_program_info, CL_PROGRAM_SOURCE, string) \
1278 F(cl_program_info, CL_PROGRAM_BINARY_SIZES, cl::vector<size_type>) \
1279 F(cl_program_info, CL_PROGRAM_BINARIES, cl::vector<cl::vector<unsigned char>>) \
1281 F(cl_program_build_info, CL_PROGRAM_BUILD_STATUS, cl_build_status) \
1282 F(cl_program_build_info, CL_PROGRAM_BUILD_OPTIONS, string) \
1283 F(cl_program_build_info, CL_PROGRAM_BUILD_LOG, string) \
1285 F(cl_kernel_info, CL_KERNEL_FUNCTION_NAME, string) \
1286 F(cl_kernel_info, CL_KERNEL_NUM_ARGS, cl_uint) \
1287 F(cl_kernel_info, CL_KERNEL_REFERENCE_COUNT, cl_uint) \
1288 F(cl_kernel_info, CL_KERNEL_CONTEXT, cl::Context) \
1289 F(cl_kernel_info, CL_KERNEL_PROGRAM, cl::Program) \
1291 F(cl_kernel_work_group_info, CL_KERNEL_WORK_GROUP_SIZE, size_type) \
1292 F(cl_kernel_work_group_info, CL_KERNEL_COMPILE_WORK_GROUP_SIZE, cl::detail::size_t_array) \
1293 F(cl_kernel_work_group_info, CL_KERNEL_LOCAL_MEM_SIZE, cl_ulong) \
1295 F(cl_command_queue_info, CL_QUEUE_CONTEXT, cl::Context) \
1296 F(cl_command_queue_info, CL_QUEUE_DEVICE, cl::Device) \
1297 F(cl_command_queue_info, CL_QUEUE_REFERENCE_COUNT, cl_uint) \
1298 F(cl_command_queue_info, CL_QUEUE_PROPERTIES, cl_command_queue_properties)
1301 #define CL_HPP_PARAM_NAME_INFO_1_1_(F) \
1302 F(cl_context_info, CL_CONTEXT_NUM_DEVICES, cl_uint)\
1303 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF, cl_uint) \
1304 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR, cl_uint) \
1305 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT, cl_uint) \
1306 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_INT, cl_uint) \
1307 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG, cl_uint) \
1308 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT, cl_uint) \
1309 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE, cl_uint) \
1310 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF, cl_uint) \
1311 F(cl_device_info, CL_DEVICE_OPENCL_C_VERSION, string) \
1313 F(cl_mem_info, CL_MEM_ASSOCIATED_MEMOBJECT, cl::Memory) \
1314 F(cl_mem_info, CL_MEM_OFFSET, size_type) \
1316 F(cl_kernel_work_group_info, CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, size_type) \
1317 F(cl_kernel_work_group_info, CL_KERNEL_PRIVATE_MEM_SIZE, cl_ulong) \
1319 F(cl_event_info, CL_EVENT_CONTEXT, cl::Context)
1321 #define CL_HPP_PARAM_NAME_INFO_1_2_(F) \
1322 F(cl_program_info, CL_PROGRAM_NUM_KERNELS, size_type) \
1323 F(cl_program_info, CL_PROGRAM_KERNEL_NAMES, string) \
1325 F(cl_program_build_info, CL_PROGRAM_BINARY_TYPE, cl_program_binary_type) \
1327 F(cl_kernel_info, CL_KERNEL_ATTRIBUTES, string) \
1329 F(cl_kernel_arg_info, CL_KERNEL_ARG_ADDRESS_QUALIFIER, cl_kernel_arg_address_qualifier) \
1330 F(cl_kernel_arg_info, CL_KERNEL_ARG_ACCESS_QUALIFIER, cl_kernel_arg_access_qualifier) \
1331 F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_NAME, string) \
1332 F(cl_kernel_arg_info, CL_KERNEL_ARG_NAME, string) \
1333 F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_QUALIFIER, cl_kernel_arg_type_qualifier) \
1335 F(cl_kernel_work_group_info, CL_KERNEL_GLOBAL_WORK_SIZE, cl::detail::size_t_array) \
1337 F(cl_device_info, CL_DEVICE_LINKER_AVAILABLE, cl_bool) \
1338 F(cl_device_info, CL_DEVICE_IMAGE_MAX_BUFFER_SIZE, size_type) \
1339 F(cl_device_info, CL_DEVICE_IMAGE_MAX_ARRAY_SIZE, size_type) \
1340 F(cl_device_info, CL_DEVICE_PARENT_DEVICE, cl::Device) \
1341 F(cl_device_info, CL_DEVICE_PARTITION_MAX_SUB_DEVICES, cl_uint) \
1342 F(cl_device_info, CL_DEVICE_PARTITION_PROPERTIES, cl::vector<cl_device_partition_property>) \
1343 F(cl_device_info, CL_DEVICE_PARTITION_TYPE, cl::vector<cl_device_partition_property>) \
1344 F(cl_device_info, CL_DEVICE_REFERENCE_COUNT, cl_uint) \
1345 F(cl_device_info, CL_DEVICE_PREFERRED_INTEROP_USER_SYNC, cl_bool) \
1346 F(cl_device_info, CL_DEVICE_PARTITION_AFFINITY_DOMAIN, cl_device_affinity_domain) \
1347 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS, string) \
1348 F(cl_device_info, CL_DEVICE_PRINTF_BUFFER_SIZE, size_type) \
1350 F(cl_image_info, CL_IMAGE_ARRAY_SIZE, size_type) \
1351 F(cl_image_info, CL_IMAGE_NUM_MIP_LEVELS, cl_uint) \
1352 F(cl_image_info, CL_IMAGE_NUM_SAMPLES, cl_uint)
1354 #define CL_HPP_PARAM_NAME_INFO_2_0_(F) \
1355 F(cl_device_info, CL_DEVICE_QUEUE_ON_HOST_PROPERTIES, cl_command_queue_properties) \
1356 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES, cl_command_queue_properties) \
1357 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE, cl_uint) \
1358 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE, cl_uint) \
1359 F(cl_device_info, CL_DEVICE_MAX_ON_DEVICE_QUEUES, cl_uint) \
1360 F(cl_device_info, CL_DEVICE_MAX_ON_DEVICE_EVENTS, cl_uint) \
1361 F(cl_device_info, CL_DEVICE_MAX_PIPE_ARGS, cl_uint) \
1362 F(cl_device_info, CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS, cl_uint) \
1363 F(cl_device_info, CL_DEVICE_PIPE_MAX_PACKET_SIZE, cl_uint) \
1364 F(cl_device_info, CL_DEVICE_SVM_CAPABILITIES, cl_device_svm_capabilities) \
1365 F(cl_device_info, CL_DEVICE_PREFERRED_PLATFORM_ATOMIC_ALIGNMENT, cl_uint) \
1366 F(cl_device_info, CL_DEVICE_PREFERRED_GLOBAL_ATOMIC_ALIGNMENT, cl_uint) \
1367 F(cl_device_info, CL_DEVICE_PREFERRED_LOCAL_ATOMIC_ALIGNMENT, cl_uint) \
1368 F(cl_device_info, CL_DEVICE_IMAGE_PITCH_ALIGNMENT, cl_uint) \
1369 F(cl_device_info, CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT, cl_uint) \
1370 F(cl_device_info, CL_DEVICE_MAX_READ_WRITE_IMAGE_ARGS, cl_uint ) \
1371 F(cl_device_info, CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE, size_type ) \
1372 F(cl_device_info, CL_DEVICE_GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE, size_type ) \
1373 F(cl_profiling_info, CL_PROFILING_COMMAND_COMPLETE, cl_ulong) \
1374 F(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM, cl_bool) \
1375 F(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_SVM_PTRS, void**) \
1376 F(cl_command_queue_info, CL_QUEUE_SIZE, cl_uint) \
1377 F(cl_mem_info, CL_MEM_USES_SVM_POINTER, cl_bool) \
1378 F(cl_program_build_info, CL_PROGRAM_BUILD_GLOBAL_VARIABLE_TOTAL_SIZE, size_type) \
1379 F(cl_pipe_info, CL_PIPE_PACKET_SIZE, cl_uint) \
1380 F(cl_pipe_info, CL_PIPE_MAX_PACKETS, cl_uint)
1382 #define CL_HPP_PARAM_NAME_INFO_SUBGROUP_KHR_(F) \
1383 F(cl_kernel_sub_group_info, CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE_KHR, size_type) \
1384 F(cl_kernel_sub_group_info, CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE_KHR, size_type)
1386 #define CL_HPP_PARAM_NAME_INFO_IL_KHR_(F) \
1387 F(cl_device_info, CL_DEVICE_IL_VERSION_KHR, string) \
1388 F(cl_program_info, CL_PROGRAM_IL_KHR, cl::vector<unsigned char>)
1390 #define CL_HPP_PARAM_NAME_INFO_2_1_(F) \
1391 F(cl_platform_info, CL_PLATFORM_HOST_TIMER_RESOLUTION, cl_ulong) \
1392 F(cl_program_info, CL_PROGRAM_IL, cl::vector<unsigned char>) \
1393 F(cl_device_info, CL_DEVICE_MAX_NUM_SUB_GROUPS, cl_uint) \
1394 F(cl_device_info, CL_DEVICE_IL_VERSION, string) \
1395 F(cl_device_info, CL_DEVICE_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS, cl_bool) \
1396 F(cl_command_queue_info, CL_QUEUE_DEVICE_DEFAULT, cl::DeviceCommandQueue) \
1397 F(cl_kernel_sub_group_info, CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE, size_type) \
1398 F(cl_kernel_sub_group_info, CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE, size_type) \
1399 F(cl_kernel_sub_group_info, CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT, cl::detail::size_t_array) \
1400 F(cl_kernel_sub_group_info, CL_KERNEL_MAX_NUM_SUB_GROUPS, size_type) \
1401 F(cl_kernel_sub_group_info, CL_KERNEL_COMPILE_NUM_SUB_GROUPS, size_type)
1403 #define CL_HPP_PARAM_NAME_INFO_2_2_(F) \
1404 F(cl_program_info, CL_PROGRAM_SCOPE_GLOBAL_CTORS_PRESENT, cl_bool) \
1405 F(cl_program_info, CL_PROGRAM_SCOPE_GLOBAL_DTORS_PRESENT, cl_bool)
1407 #define CL_HPP_PARAM_NAME_DEVICE_FISSION_(F) \
1408 F(cl_device_info, CL_DEVICE_PARENT_DEVICE_EXT, cl_device_id) \
1409 F(cl_device_info, CL_DEVICE_PARTITION_TYPES_EXT, cl::vector<cl_device_partition_property_ext>) \
1410 F(cl_device_info, CL_DEVICE_AFFINITY_DOMAINS_EXT, cl::vector<cl_device_partition_property_ext>) \
1411 F(cl_device_info, CL_DEVICE_REFERENCE_COUNT_EXT , cl_uint) \
1412 F(cl_device_info, CL_DEVICE_PARTITION_STYLE_EXT, cl::vector<cl_device_partition_property_ext>)
1414 #define CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_CL3_SHARED_(F) \
1415 F(cl_platform_info, CL_PLATFORM_NUMERIC_VERSION_KHR, cl_version_khr) \
1416 F(cl_platform_info, CL_PLATFORM_EXTENSIONS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>) \
1418 F(cl_device_info, CL_DEVICE_NUMERIC_VERSION_KHR, cl_version_khr) \
1419 F(cl_device_info, CL_DEVICE_EXTENSIONS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>) \
1420 F(cl_device_info, CL_DEVICE_ILS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>) \
1421 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>)
1423 #define CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_KHRONLY_(F) \
1424 F(cl_device_info, CL_DEVICE_OPENCL_C_NUMERIC_VERSION_KHR, cl_version_khr)
1426 #define CL_HPP_PARAM_NAME_INFO_3_0_(F) \
1427 F(cl_platform_info, CL_PLATFORM_NUMERIC_VERSION, cl_version) \
1428 F(cl_platform_info, CL_PLATFORM_EXTENSIONS_WITH_VERSION, cl::vector<cl_name_version>) \
1430 F(cl_device_info, CL_DEVICE_NUMERIC_VERSION, cl_version) \
1431 F(cl_device_info, CL_DEVICE_EXTENSIONS_WITH_VERSION, cl::vector<cl_name_version>) \
1432 F(cl_device_info, CL_DEVICE_ILS_WITH_VERSION, cl::vector<cl_name_version>) \
1433 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS_WITH_VERSION, cl::vector<cl_name_version>) \
1434 F(cl_device_info, CL_DEVICE_ATOMIC_MEMORY_CAPABILITIES, cl_device_atomic_capabilities) \
1435 F(cl_device_info, CL_DEVICE_ATOMIC_FENCE_CAPABILITIES, cl_device_atomic_capabilities) \
1436 F(cl_device_info, CL_DEVICE_NON_UNIFORM_WORK_GROUP_SUPPORT, cl_bool) \
1437 F(cl_device_info, CL_DEVICE_OPENCL_C_ALL_VERSIONS, cl::vector<cl_name_version>) \
1438 F(cl_device_info, CL_DEVICE_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, size_type) \
1439 F(cl_device_info, CL_DEVICE_WORK_GROUP_COLLECTIVE_FUNCTIONS_SUPPORT, cl_bool) \
1440 F(cl_device_info, CL_DEVICE_GENERIC_ADDRESS_SPACE_SUPPORT, cl_bool) \
1441 F(cl_device_info, CL_DEVICE_OPENCL_C_FEATURES, cl::vector<cl_name_version>) \
1442 F(cl_device_info, CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES, cl_device_device_enqueue_capabilities) \
1443 F(cl_device_info, CL_DEVICE_PIPE_SUPPORT, cl_bool) \
1444 F(cl_device_info, CL_DEVICE_LATEST_CONFORMANCE_VERSION_PASSED, string) \
1446 F(cl_command_queue_info, CL_QUEUE_PROPERTIES_ARRAY, cl::vector<cl_queue_properties>) \
1447 F(cl_mem_info, CL_MEM_PROPERTIES, cl::vector<cl_mem_properties>) \
1448 F(cl_pipe_info, CL_PIPE_PROPERTIES, cl::vector<cl_pipe_properties>) \
1449 F(cl_sampler_info, CL_SAMPLER_PROPERTIES, cl::vector<cl_sampler_properties>)
1451 template <
typename enum_type, cl_
int Name>
1454 #define CL_HPP_DECLARE_PARAM_TRAITS_(token, param_name, T) \
1457 struct param_traits<detail:: token,param_name> \
1459 enum { value = param_name }; \
1460 typedef T param_type; \
1463 CL_HPP_PARAM_NAME_INFO_1_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1464 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
1465 CL_HPP_PARAM_NAME_INFO_1_1_(CL_HPP_DECLARE_PARAM_TRAITS_)
1467 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
1468 CL_HPP_PARAM_NAME_INFO_1_2_(CL_HPP_DECLARE_PARAM_TRAITS_)
1470 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
1471 CL_HPP_PARAM_NAME_INFO_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1473 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
1474 CL_HPP_PARAM_NAME_INFO_2_1_(CL_HPP_DECLARE_PARAM_TRAITS_)
1476 #if CL_HPP_TARGET_OPENCL_VERSION >= 220
1477 CL_HPP_PARAM_NAME_INFO_2_2_(CL_HPP_DECLARE_PARAM_TRAITS_)
1479 #if CL_HPP_TARGET_OPENCL_VERSION >= 300
1480 CL_HPP_PARAM_NAME_INFO_3_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1483 #if defined(CL_HPP_USE_CL_SUB_GROUPS_KHR) && CL_HPP_TARGET_OPENCL_VERSION < 210
1484 CL_HPP_PARAM_NAME_INFO_SUBGROUP_KHR_(CL_HPP_DECLARE_PARAM_TRAITS_)
1487 #if defined(CL_HPP_USE_IL_KHR) && CL_HPP_TARGET_OPENCL_VERSION < 210
1488 CL_HPP_PARAM_NAME_INFO_IL_KHR_(CL_HPP_DECLARE_PARAM_TRAITS_)
1493 #define CL_HPP_PARAM_NAME_INFO_1_0_DEPRECATED_IN_2_0_(F) \
1494 F(cl_device_info, CL_DEVICE_QUEUE_PROPERTIES, cl_command_queue_properties)
1496 #define CL_HPP_PARAM_NAME_INFO_1_1_DEPRECATED_IN_2_0_(F) \
1497 F(cl_device_info, CL_DEVICE_HOST_UNIFIED_MEMORY, cl_bool)
1499 #define CL_HPP_PARAM_NAME_INFO_1_2_DEPRECATED_IN_2_0_(F) \
1500 F(cl_image_info, CL_IMAGE_BUFFER, cl::Buffer)
1504 #if CL_HPP_TARGET_OPENCL_VERSION > 100 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 && CL_HPP_TARGET_OPENCL_VERSION < 200
1505 CL_HPP_PARAM_NAME_INFO_1_0_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1507 #if CL_HPP_TARGET_OPENCL_VERSION > 110 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
1508 CL_HPP_PARAM_NAME_INFO_1_1_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1510 #if CL_HPP_TARGET_OPENCL_VERSION > 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
1511 CL_HPP_PARAM_NAME_INFO_1_2_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1514 #if defined(CL_HPP_USE_CL_DEVICE_FISSION)
1515 CL_HPP_PARAM_NAME_DEVICE_FISSION_(CL_HPP_DECLARE_PARAM_TRAITS_);
1518 #if defined(cl_khr_extended_versioning)
1519 #if CL_HPP_TARGET_OPENCL_VERSION < 300
1520 CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_CL3_SHARED_(CL_HPP_DECLARE_PARAM_TRAITS_)
1522 CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_KHRONLY_(CL_HPP_DECLARE_PARAM_TRAITS_)
1525 #if defined(cl_khr_device_uuid)
1526 using uuid_array = array<cl_uchar, CL_UUID_SIZE_KHR>;
1527 using luid_array = array<cl_uchar, CL_LUID_SIZE_KHR>;
1528 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_UUID_KHR, uuid_array)
1529 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DRIVER_UUID_KHR, uuid_array)
1530 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LUID_VALID_KHR, cl_bool)
1531 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LUID_KHR, luid_array)
1532 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_NODE_MASK_KHR, cl_uint)
1535 #if defined(cl_khr_pci_bus_info)
1536 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_PCI_BUS_INFO_KHR, cl_device_pci_bus_info_khr)
1539 #if defined(cl_khr_integer_dot_product)
1540 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGER_DOT_PRODUCT_CAPABILITIES_KHR, cl_device_integer_dot_product_capabilities_khr)
1541 #if defined(CL_DEVICE_INTEGER_DOT_PRODUCT_ACCELERATION_PROPERTIES_8BIT_KHR)
1542 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGER_DOT_PRODUCT_ACCELERATION_PROPERTIES_8BIT_KHR, cl_device_integer_dot_product_acceleration_properties_khr)
1543 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGER_DOT_PRODUCT_ACCELERATION_PROPERTIES_4x8BIT_PACKED_KHR, cl_device_integer_dot_product_acceleration_properties_khr)
1547 #ifdef CL_PLATFORM_ICD_SUFFIX_KHR
1548 CL_HPP_DECLARE_PARAM_TRAITS_(cl_platform_info, CL_PLATFORM_ICD_SUFFIX_KHR,
string)
1551 #ifdef CL_DEVICE_PROFILING_TIMER_OFFSET_AMD
1552 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_PROFILING_TIMER_OFFSET_AMD, cl_ulong)
1554 #ifdef CL_DEVICE_GLOBAL_FREE_MEMORY_AMD
1555 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_FREE_MEMORY_AMD, vector<size_type>)
1557 #ifdef CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD
1558 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD, cl_uint)
1560 #ifdef CL_DEVICE_SIMD_WIDTH_AMD
1561 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_WIDTH_AMD, cl_uint)
1563 #ifdef CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD
1564 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD, cl_uint)
1566 #ifdef CL_DEVICE_WAVEFRONT_WIDTH_AMD
1567 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_WAVEFRONT_WIDTH_AMD, cl_uint)
1569 #ifdef CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD
1570 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD, cl_uint)
1572 #ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD
1573 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD, cl_uint)
1575 #ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD
1576 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD, cl_uint)
1578 #ifdef CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD
1579 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD, cl_uint)
1581 #ifdef CL_DEVICE_LOCAL_MEM_BANKS_AMD
1582 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LOCAL_MEM_BANKS_AMD, cl_uint)
1584 #ifdef CL_DEVICE_BOARD_NAME_AMD
1585 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_BOARD_NAME_AMD,
string)
1588 #ifdef CL_DEVICE_COMPUTE_UNITS_BITFIELD_ARM
1589 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_UNITS_BITFIELD_ARM, cl_ulong)
1591 #ifdef CL_DEVICE_JOB_SLOTS_ARM
1592 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_JOB_SLOTS_ARM, cl_uint)
1594 #ifdef CL_DEVICE_SCHEDULING_CONTROLS_CAPABILITIES_ARM
1595 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SCHEDULING_CONTROLS_CAPABILITIES_ARM, cl_bitfield)
1597 #ifdef CL_DEVICE_SUPPORTED_REGISTER_ALLOCATIONS_ARM
1598 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SUPPORTED_REGISTER_ALLOCATIONS_ARM, vector<cl_uint>)
1600 #ifdef CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_ARM
1601 CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_ARM, cl_uint)
1603 #ifdef CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_MODIFIER_ARM
1604 CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_MODIFIER_ARM, cl_int)
1607 #ifdef CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV
1608 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV, cl_uint)
1610 #ifdef CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV
1611 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV, cl_uint)
1613 #ifdef CL_DEVICE_REGISTERS_PER_BLOCK_NV
1614 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_REGISTERS_PER_BLOCK_NV, cl_uint)
1616 #ifdef CL_DEVICE_WARP_SIZE_NV
1617 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_WARP_SIZE_NV, cl_uint)
1619 #ifdef CL_DEVICE_GPU_OVERLAP_NV
1620 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GPU_OVERLAP_NV, cl_bool)
1622 #ifdef CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV
1623 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV, cl_bool)
1625 #ifdef CL_DEVICE_INTEGRATED_MEMORY_NV
1626 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGRATED_MEMORY_NV, cl_bool)
1631 template <
typename Func,
typename T>
1633 getInfo(Func f, cl_uint name, T* param)
1635 return getInfoHelper(f, name, param, 0);
1638 template <
typename Func,
typename Arg0>
1641 Func f_;
const Arg0& arg0_;
1643 cl_uint param, size_type size,
void* value, size_type* size_ret)
1644 {
return f_(arg0_, param, size, value, size_ret); }
1647 template <
typename Func,
typename Arg0,
typename Arg1>
1650 Func f_;
const Arg0& arg0_;
const Arg1& arg1_;
1652 cl_uint param, size_type size,
void* value, size_type* size_ret)
1653 {
return f_(arg0_, arg1_, param, size, value, size_ret); }
1656 template <
typename Func,
typename Arg0,
typename T>
1658 getInfo(Func f,
const Arg0& arg0, cl_uint name, T* param)
1661 return getInfoHelper(f0, name, param, 0);
1664 template <
typename Func,
typename Arg0,
typename Arg1,
typename T>
1666 getInfo(Func f,
const Arg0& arg0,
const Arg1& arg1, cl_uint name, T* param)
1668 GetInfoFunctor1<Func, Arg0, Arg1> f0 = { f, arg0, arg1 };
1669 return getInfoHelper(f0, name, param, 0);
1673 template<
typename T>
1677 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
1694 { return ::clRetainDevice(device); }
1705 { return ::clReleaseDevice(device); }
1712 struct ReferenceHandler<cl_device_id>
1715 static cl_int retain(cl_device_id)
1716 {
return CL_SUCCESS; }
1718 static cl_int release(cl_device_id)
1719 {
return CL_SUCCESS; }
1727 static cl_int retain(cl_platform_id)
1728 {
return CL_SUCCESS; }
1730 static cl_int release(cl_platform_id)
1731 {
return CL_SUCCESS; }
1737 static cl_int retain(cl_context context)
1738 { return ::clRetainContext(context); }
1739 static cl_int release(cl_context context)
1740 { return ::clReleaseContext(context); }
1746 static cl_int retain(cl_command_queue queue)
1747 { return ::clRetainCommandQueue(queue); }
1748 static cl_int release(cl_command_queue queue)
1749 { return ::clReleaseCommandQueue(queue); }
1755 static cl_int retain(cl_mem memory)
1756 { return ::clRetainMemObject(memory); }
1757 static cl_int release(cl_mem memory)
1758 { return ::clReleaseMemObject(memory); }
1764 static cl_int retain(cl_sampler sampler)
1765 { return ::clRetainSampler(sampler); }
1766 static cl_int release(cl_sampler sampler)
1767 { return ::clReleaseSampler(sampler); }
1773 static cl_int retain(cl_program program)
1774 { return ::clRetainProgram(program); }
1775 static cl_int release(cl_program program)
1776 { return ::clReleaseProgram(program); }
1782 static cl_int retain(cl_kernel kernel)
1783 { return ::clRetainKernel(kernel); }
1784 static cl_int release(cl_kernel kernel)
1785 { return ::clReleaseKernel(kernel); }
1791 static cl_int retain(cl_event event)
1792 { return ::clRetainEvent(event); }
1793 static cl_int release(cl_event event)
1794 { return ::clReleaseEvent(event); }
1798 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
1800 static cl_uint getVersion(
const vector<char> &versionInfo)
1802 int highVersion = 0;
1805 while(versionInfo[index] !=
'.' ) {
1807 highVersion += versionInfo[index]-
'0';
1811 while(versionInfo[index] !=
' ' && versionInfo[index] !=
'\0') {
1813 lowVersion += versionInfo[index]-
'0';
1816 return (highVersion << 16) | lowVersion;
1819 static cl_uint getPlatformVersion(cl_platform_id platform)
1822 clGetPlatformInfo(platform, CL_PLATFORM_VERSION, 0, NULL, &size);
1824 vector<char> versionInfo(size);
1825 clGetPlatformInfo(platform, CL_PLATFORM_VERSION, size, versionInfo.data(), &size);
1826 return getVersion(versionInfo);
1829 static cl_uint getDevicePlatformVersion(cl_device_id device)
1831 cl_platform_id platform;
1832 clGetDeviceInfo(device, CL_DEVICE_PLATFORM,
sizeof(platform), &platform, NULL);
1833 return getPlatformVersion(platform);
1836 static cl_uint getContextPlatformVersion(cl_context context)
1841 clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, NULL, &size);
1844 vector<cl_device_id> devices(size/
sizeof(cl_device_id));
1845 clGetContextInfo(context, CL_CONTEXT_DEVICES, size, devices.data(), NULL);
1846 return getDevicePlatformVersion(devices[0]);
1850 template <
typename T>
1862 Wrapper(
const cl_type &obj,
bool retainObject) : object_(obj)
1865 detail::errHandler(retain(), __RETAIN_ERR);
1871 if (object_ != NULL) { release(); }
1876 object_ = rhs.object_;
1877 detail::errHandler(retain(), __RETAIN_ERR);
1882 object_ = rhs.object_;
1889 detail::errHandler(release(), __RELEASE_ERR);
1890 object_ = rhs.object_;
1891 detail::errHandler(retain(), __RETAIN_ERR);
1899 detail::errHandler(release(), __RELEASE_ERR);
1900 object_ = rhs.object_;
1908 detail::errHandler(release(), __RELEASE_ERR);
1913 const cl_type& operator ()()
const {
return object_; }
1915 cl_type& operator ()() {
return object_; }
1917 cl_type get()
const {
return object_; }
1920 template<
typename Func,
typename U>
1921 friend inline cl_int getInfoHelper(Func, cl_uint, U*,
int,
typename U::cl_type);
1923 cl_int retain()
const
1925 if (object_ !=
nullptr) {
1933 cl_int release()
const
1935 if (object_ !=
nullptr) {
1948 typedef cl_device_id cl_type;
1952 bool referenceCountable_;
1954 static bool isReferenceCountable(cl_device_id device)
1956 bool retVal =
false;
1957 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
1958 #if CL_HPP_MINIMUM_OPENCL_VERSION < 120
1959 if (device != NULL) {
1960 int version = getDevicePlatformVersion(device);
1961 if(version > ((1 << 16) + 1)) {
1974 Wrapper() : object_(NULL), referenceCountable_(
false)
1978 Wrapper(
const cl_type &obj,
bool retainObject) :
1980 referenceCountable_(
false)
1982 referenceCountable_ = isReferenceCountable(obj);
1985 detail::errHandler(retain(), __RETAIN_ERR);
1996 object_ = rhs.object_;
1997 referenceCountable_ = isReferenceCountable(object_);
1998 detail::errHandler(retain(), __RETAIN_ERR);
2003 object_ = rhs.object_;
2004 referenceCountable_ = rhs.referenceCountable_;
2006 rhs.referenceCountable_ =
false;
2012 detail::errHandler(release(), __RELEASE_ERR);
2013 object_ = rhs.object_;
2014 referenceCountable_ = rhs.referenceCountable_;
2015 detail::errHandler(retain(), __RETAIN_ERR);
2023 detail::errHandler(release(), __RELEASE_ERR);
2024 object_ = rhs.object_;
2025 referenceCountable_ = rhs.referenceCountable_;
2027 rhs.referenceCountable_ =
false;
2034 detail::errHandler(release(), __RELEASE_ERR);
2036 referenceCountable_ = isReferenceCountable(object_);
2040 const cl_type& operator ()()
const {
return object_; }
2042 cl_type& operator ()() {
return object_; }
2044 cl_type get()
const {
return object_; }
2047 template<
typename Func,
typename U>
2048 friend inline cl_int getInfoHelper(Func, cl_uint, U*,
int,
typename U::cl_type);
2050 template<
typename Func,
typename U>
2051 friend inline cl_int getInfoHelper(Func, cl_uint, vector<U>*,
int,
typename U::cl_type);
2053 cl_int retain()
const
2055 if( object_ !=
nullptr && referenceCountable_ ) {
2063 cl_int release()
const
2065 if (object_ !=
nullptr && referenceCountable_) {
2074 template <
typename T>
2077 return lhs() == rhs();
2080 template <
typename T>
2081 inline bool operator!=(
const Wrapper<T> &lhs,
const Wrapper<T> &rhs)
2083 return !operator==(lhs, rhs);
2106 image_channel_order = order;
2107 image_channel_data_type = type;
2117 this->image_channel_data_type = rhs.image_channel_data_type;
2118 this->image_channel_order = rhs.image_channel_order;
2134 static std::once_flag default_initialized_;
2136 static cl_int default_error_;
2143 static void makeDefault();
2150 static void makeDefaultProvided(
const Device &p) {
2155 #ifdef CL_HPP_UNIT_TEST_ENABLE
2162 static void unitTestClearDefault() {
2174 explicit Device(
const cl_device_id &device,
bool retainObject =
false) :
2175 detail::Wrapper<cl_type>(device, retainObject) { }
2182 cl_int *errResult = NULL)
2184 std::call_once(default_initialized_, makeDefault);
2185 detail::errHandler(default_error_);
2186 if (errResult != NULL) {
2187 *errResult = default_error_;
2201 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_device));
2202 detail::errHandler(default_error_);
2245 template <
typename T>
2246 cl_int
getInfo(cl_device_info name, T* param)
const
2248 return detail::errHandler(
2249 detail::getInfo(&::clGetDeviceInfo, object_, name, param),
2250 __GET_DEVICE_INFO_ERR);
2254 template <cl_device_info name>
typename
2259 detail::cl_device_info, name>::param_type param;
2260 cl_int result =
getInfo(name, ¶m);
2268 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
2277 cl_ulong retVal = 0;
2279 clGetHostTimer(this->get(), &retVal);
2282 __GET_HOST_TIMER_ERR);
2301 std::pair<cl_ulong, cl_ulong> retVal;
2303 clGetDeviceAndHostTimer(this->get(), &(retVal.first), &(retVal.second));
2306 __GET_DEVICE_AND_HOST_TIMER_ERR);
2317 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
2320 const cl_device_partition_property * properties,
2321 vector<Device>* devices)
2324 cl_int err = clCreateSubDevices(object_, properties, 0, NULL, &n);
2325 if (err != CL_SUCCESS) {
2326 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2329 vector<cl_device_id> ids(n);
2330 err = clCreateSubDevices(object_, properties, n, ids.data(), NULL);
2331 if (err != CL_SUCCESS) {
2332 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2338 devices->resize(ids.size());
2342 for (size_type i = 0; i < ids.size(); i++) {
2345 (*devices)[i] =
Device(ids[i],
false);
2351 #elif defined(CL_HPP_USE_CL_DEVICE_FISSION)
2357 const cl_device_partition_property_ext * properties,
2358 vector<Device>* devices)
2360 typedef CL_API_ENTRY cl_int
2361 ( CL_API_CALL * PFN_clCreateSubDevicesEXT)(
2363 const cl_device_partition_property_ext * ,
2366 cl_uint * ) CL_API_SUFFIX__VERSION_1_1;
2368 static PFN_clCreateSubDevicesEXT pfn_clCreateSubDevicesEXT = NULL;
2369 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateSubDevicesEXT);
2372 cl_int err = pfn_clCreateSubDevicesEXT(object_, properties, 0, NULL, &n);
2373 if (err != CL_SUCCESS) {
2374 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2377 vector<cl_device_id> ids(n);
2378 err = pfn_clCreateSubDevicesEXT(object_, properties, n, ids.data(), NULL);
2379 if (err != CL_SUCCESS) {
2380 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2385 devices->resize(ids.size());
2389 for (size_type i = 0; i < ids.size(); i++) {
2392 (*devices)[i] =
Device(ids[i],
false);
2400 using BuildLogType = vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, CL_PROGRAM_BUILD_LOG>::param_type>>;
2401 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
2405 class BuildError :
public Error
2408 BuildLogType buildLogs;
2410 BuildError(cl_int err,
const char * errStr,
const BuildLogType &vec) : Error(err, errStr), buildLogs(vec)
2414 BuildLogType getBuildLog()
const
2420 static inline cl_int buildErrHandler(
2422 const char * errStr,
2423 const BuildLogType &buildLogs)
2425 if (err != CL_SUCCESS) {
2426 throw BuildError(err, errStr, buildLogs);
2434 static inline cl_int buildErrHandler(
2436 const char * errStr,
2437 const BuildLogType &buildLogs)
2446 CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Device::default_initialized_;
2447 CL_HPP_DEFINE_STATIC_MEMBER_ Device Device::default_;
2448 CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Device::default_error_ = CL_SUCCESS;
2460 static std::once_flag default_initialized_;
2462 static cl_int default_error_;
2469 static void makeDefault() {
2473 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
2481 cl_int err = ::clGetPlatformIDs(0, NULL, &n);
2482 if (err != CL_SUCCESS) {
2483 default_error_ = err;
2487 default_error_ = CL_INVALID_PLATFORM;
2491 vector<cl_platform_id> ids(n);
2492 err = ::clGetPlatformIDs(n, ids.data(), NULL);
2493 if (err != CL_SUCCESS) {
2494 default_error_ = err;
2500 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
2501 catch (cl::Error &e) {
2502 default_error_ = e.err();
2512 static void makeDefaultProvided(
const Platform &p) {
2517 #ifdef CL_HPP_UNIT_TEST_ENABLE
2524 static void unitTestClearDefault() {
2539 explicit Platform(
const cl_platform_id &platform,
bool retainObject =
false) :
2540 detail::Wrapper<cl_type>(platform, retainObject) { }
2553 cl_int *errResult = NULL)
2555 std::call_once(default_initialized_, makeDefault);
2556 detail::errHandler(default_error_);
2557 if (errResult != NULL) {
2558 *errResult = default_error_;
2572 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_platform));
2573 detail::errHandler(default_error_);
2578 template <
typename T>
2579 cl_int
getInfo(cl_platform_info name, T* param)
const
2581 return detail::errHandler(
2582 detail::getInfo(&::clGetPlatformInfo, object_, name, param),
2583 __GET_PLATFORM_INFO_ERR);
2587 template <cl_platform_info name>
typename
2592 detail::cl_platform_info, name>::param_type param;
2593 cl_int result =
getInfo(name, ¶m);
2605 cl_device_type type,
2606 vector<Device>* devices)
const
2609 if( devices == NULL ) {
2610 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR);
2612 cl_int err = ::clGetDeviceIDs(object_, type, 0, NULL, &n);
2613 if (err != CL_SUCCESS && err != CL_DEVICE_NOT_FOUND) {
2614 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2617 vector<cl_device_id> ids(n);
2619 err = ::clGetDeviceIDs(object_, type, n, ids.data(), NULL);
2620 if (err != CL_SUCCESS) {
2621 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2630 devices->resize(ids.size());
2634 for (size_type i = 0; i < ids.size(); i++) {
2635 (*devices)[i] =
Device(ids[i],
true);
2641 #if defined(CL_HPP_USE_DX_INTEROP)
2666 cl_d3d10_device_source_khr d3d_device_source,
2668 cl_d3d10_device_set_khr d3d_device_set,
2669 vector<Device>* devices)
const
2671 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clGetDeviceIDsFromD3D10KHR)(
2672 cl_platform_id platform,
2673 cl_d3d10_device_source_khr d3d_device_source,
2675 cl_d3d10_device_set_khr d3d_device_set,
2676 cl_uint num_entries,
2677 cl_device_id * devices,
2678 cl_uint* num_devices);
2680 if( devices == NULL ) {
2681 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR);
2684 static PFN_clGetDeviceIDsFromD3D10KHR pfn_clGetDeviceIDsFromD3D10KHR = NULL;
2685 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(object_, clGetDeviceIDsFromD3D10KHR);
2688 cl_int err = pfn_clGetDeviceIDsFromD3D10KHR(
2696 if (err != CL_SUCCESS) {
2697 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2700 vector<cl_device_id> ids(n);
2701 err = pfn_clGetDeviceIDsFromD3D10KHR(
2709 if (err != CL_SUCCESS) {
2710 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2718 devices->resize(ids.size());
2722 for (size_type i = 0; i < ids.size(); i++) {
2723 (*devices)[i] = Device(ids[i],
true);
2735 vector<Platform>* platforms)
2739 if( platforms == NULL ) {
2740 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_PLATFORM_IDS_ERR);
2743 cl_int err = ::clGetPlatformIDs(0, NULL, &n);
2744 if (err != CL_SUCCESS) {
2745 return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
2748 vector<cl_platform_id> ids(n);
2749 err = ::clGetPlatformIDs(n, ids.data(), NULL);
2750 if (err != CL_SUCCESS) {
2751 return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
2755 platforms->resize(ids.size());
2758 for (size_type i = 0; i < ids.size(); i++) {
2759 (*platforms)[i] =
Platform(ids[i]);
2773 Platform default_platform = Platform::getDefault(&err);
2775 *platform = default_platform;
2789 cl_int * errResult = NULL)
2792 Platform default_platform = Platform::getDefault(&err);
2796 return default_platform;
2799 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
2804 return ::clUnloadPlatformCompiler(object_);
2809 CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Platform::default_initialized_;
2810 CL_HPP_DEFINE_STATIC_MEMBER_ Platform Platform::default_;
2811 CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Platform::default_error_ = CL_SUCCESS;
2817 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
2822 inline CL_API_PREFIX__VERSION_1_1_DEPRECATED cl_int
2827 return ::clUnloadCompiler();
2843 static std::once_flag default_initialized_;
2845 static cl_int default_error_;
2852 static void makeDefault() {
2856 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
2860 #if !defined(__APPLE__) && !defined(__MACOS)
2861 const Platform &p = Platform::getDefault();
2862 cl_platform_id defaultPlatform = p();
2863 cl_context_properties properties[3] = {
2864 CL_CONTEXT_PLATFORM, (cl_context_properties)defaultPlatform, 0
2867 cl_context_properties *properties =
nullptr;
2871 CL_DEVICE_TYPE_DEFAULT,
2877 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
2878 catch (cl::Error &e) {
2879 default_error_ = e.err();
2890 static void makeDefaultProvided(
const Context &c) {
2895 #ifdef CL_HPP_UNIT_TEST_ENABLE
2902 static void unitTestClearDefault() {
2912 const vector<Device>& devices,
2913 const cl_context_properties* properties = NULL,
2914 void (CL_CALLBACK * notifyFptr)(
2924 size_type numDevices = devices.size();
2925 vector<cl_device_id> deviceIDs(numDevices);
2927 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
2928 deviceIDs[deviceIndex] = (devices[deviceIndex])();
2931 object_ = ::clCreateContext(
2932 properties, (cl_uint) numDevices,
2934 notifyFptr, data, &error);
2936 detail::errHandler(error, __CREATE_CONTEXT_ERR);
2948 const cl_context_properties* properties = NULL,
2949 void (CL_CALLBACK * notifyFptr)(
2959 cl_device_id deviceID = device();
2961 object_ = ::clCreateContext(
2964 notifyFptr, data, &error);
2966 detail::errHandler(error, __CREATE_CONTEXT_ERR);
2977 cl_device_type type,
2978 const cl_context_properties* properties = NULL,
2979 void (CL_CALLBACK * notifyFptr)(
2989 #if !defined(__APPLE__) && !defined(__MACOS)
2990 cl_context_properties prop[4] = {CL_CONTEXT_PLATFORM, 0, 0, 0 };
2992 if (properties == NULL) {
2994 vector<Platform> platforms;
2995 error = Platform::get(&platforms);
2996 if (error != CL_SUCCESS) {
2997 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
3005 cl_context_properties platform_id = 0;
3006 for (
unsigned int i = 0; i < platforms.size(); i++) {
3008 vector<Device> devices;
3010 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
3014 error = platforms[i].getDevices(type, &devices);
3016 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
3017 }
catch (cl::Error& e) {
3025 if (error != CL_SUCCESS && error != CL_DEVICE_NOT_FOUND) {
3026 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
3032 if (devices.size() > 0) {
3033 platform_id = (cl_context_properties)platforms[i]();
3038 if (platform_id == 0) {
3039 detail::errHandler(CL_DEVICE_NOT_FOUND, __CREATE_CONTEXT_FROM_TYPE_ERR);
3041 *err = CL_DEVICE_NOT_FOUND;
3046 prop[1] = platform_id;
3047 properties = &prop[0];
3050 object_ = ::clCreateContextFromType(
3051 properties, type, notifyFptr, data, &error);
3053 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
3094 std::call_once(default_initialized_, makeDefault);
3095 detail::errHandler(default_error_);
3097 *err = default_error_;
3111 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_context));
3112 detail::errHandler(default_error_);
3124 explicit Context(
const cl_context& context,
bool retainObject =
false) :
3125 detail::Wrapper<cl_type>(context, retainObject) { }
3139 template <
typename T>
3140 cl_int
getInfo(cl_context_info name, T* param)
const
3142 return detail::errHandler(
3143 detail::getInfo(&::clGetContextInfo, object_, name, param),
3144 __GET_CONTEXT_INFO_ERR);
3148 template <cl_context_info name>
typename
3153 detail::cl_context_info, name>::param_type param;
3154 cl_int result =
getInfo(name, ¶m);
3167 cl_mem_object_type type,
3168 vector<ImageFormat>* formats)
const
3176 cl_int err = ::clGetSupportedImageFormats(
3183 if (err != CL_SUCCESS) {
3184 return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
3187 if (numEntries > 0) {
3188 vector<ImageFormat> value(numEntries);
3189 err = ::clGetSupportedImageFormats(
3194 (cl_image_format*)value.data(),
3196 if (err != CL_SUCCESS) {
3197 return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
3200 formats->assign(begin(value), end(value));
3211 inline void Device::makeDefault()
3216 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
3223 detail::errHandler(error, __CREATE_CONTEXT_ERR);
3225 if (error != CL_SUCCESS) {
3226 default_error_ = error;
3229 default_ = context.
getInfo<CL_CONTEXT_DEVICES>()[0];
3230 default_error_ = CL_SUCCESS;
3233 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
3234 catch (cl::Error &e) {
3235 default_error_ = e.err();
3240 CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Context::default_initialized_;
3241 CL_HPP_DEFINE_STATIC_MEMBER_ Context Context::default_;
3242 CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Context::default_error_ = CL_SUCCESS;
3256 Event() : detail::Wrapper<cl_type>() { }
3266 explicit Event(
const cl_event& event,
bool retainObject =
false) :
3267 detail::Wrapper<cl_type>(event, retainObject) { }
3281 template <
typename T>
3282 cl_int
getInfo(cl_event_info name, T* param)
const
3284 return detail::errHandler(
3285 detail::getInfo(&::clGetEventInfo, object_, name, param),
3286 __GET_EVENT_INFO_ERR);
3290 template <cl_event_info name>
typename
3295 detail::cl_event_info, name>::param_type param;
3296 cl_int result =
getInfo(name, ¶m);
3304 template <
typename T>
3307 return detail::errHandler(detail::getInfo(
3308 &::clGetEventProfilingInfo, object_, name, param),
3309 __GET_EVENT_PROFILE_INFO_ERR);
3313 template <cl_profiling_info name>
typename
3318 detail::cl_profiling_info, name>::param_type param;
3332 return detail::errHandler(
3333 ::clWaitForEvents(1, &object_),
3334 __WAIT_FOR_EVENTS_ERR);
3337 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
3344 void (CL_CALLBACK * pfn_notify)(cl_event, cl_int,
void *),
3345 void * user_data = NULL)
3347 return detail::errHandler(
3348 ::clSetEventCallback(
3353 __SET_EVENT_CALLBACK_ERR);
3364 return detail::errHandler(
3366 (cl_uint) events.size(), (events.size() > 0) ? (cl_event*)&events.front() : NULL),
3367 __WAIT_FOR_EVENTS_ERR);
3371 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
3385 cl_int * err = NULL)
3388 object_ = ::clCreateUserEvent(
3392 detail::errHandler(error, __CREATE_USER_EVENT_ERR);
3407 return detail::errHandler(
3408 ::clSetUserEventStatus(object_,status),
3409 __SET_USER_EVENT_STATUS_ERR);
3418 inline static cl_int
3419 WaitForEvents(
const vector<Event>& events)
3421 return detail::errHandler(
3423 (cl_uint) events.size(), (events.size() > 0) ? (cl_event*)&events.front() : NULL),
3424 __WAIT_FOR_EVENTS_ERR);
3452 explicit Memory(
const cl_mem& memory,
bool retainObject) :
3453 detail::Wrapper<cl_type>(memory, retainObject) { }
3496 template <
typename T>
3499 return detail::errHandler(
3500 detail::getInfo(&::clGetMemObjectInfo, object_, name, param),
3501 __GET_MEM_OBJECT_INFO_ERR);
3505 template <cl_mem_info name>
typename
3510 detail::cl_mem_info, name>::param_type param;
3511 cl_int result =
getInfo(name, ¶m);
3518 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
3533 void (CL_CALLBACK * pfn_notify)(cl_mem,
void *),
3534 void * user_data = NULL)
3536 return detail::errHandler(
3537 ::clSetMemObjectDestructorCallback(
3541 __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR);
3549 template<
typename IteratorType >
3550 cl_int
copy( IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer );
3551 template<
typename IteratorType >
3552 cl_int
copy(
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator );
3553 template<
typename IteratorType >
3554 cl_int
copy(
const CommandQueue &queue, IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer );
3555 template<
typename IteratorType >
3556 cl_int
copy(
const CommandQueue &queue,
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator );
3559 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
3565 static cl_svm_mem_flags getSVMMemFlags()
3572 template<
class Trait = detail::SVMTraitNull>
3576 static cl_svm_mem_flags getSVMMemFlags()
3578 return CL_MEM_READ_WRITE |
3579 Trait::getSVMMemFlags();
3583 template<
class Trait = detail::SVMTraitNull>
3587 static cl_svm_mem_flags getSVMMemFlags()
3589 return CL_MEM_READ_ONLY |
3590 Trait::getSVMMemFlags();
3594 template<
class Trait = detail::SVMTraitNull>
3598 static cl_svm_mem_flags getSVMMemFlags()
3600 return CL_MEM_WRITE_ONLY |
3601 Trait::getSVMMemFlags();
3605 template<
class Trait = SVMTraitReadWrite<>>
3609 static cl_svm_mem_flags getSVMMemFlags()
3611 return Trait::getSVMMemFlags();
3615 template<
class Trait = SVMTraitReadWrite<>>
3619 static cl_svm_mem_flags getSVMMemFlags()
3621 return CL_MEM_SVM_FINE_GRAIN_BUFFER |
3622 Trait::getSVMMemFlags();
3626 template<
class Trait = SVMTraitReadWrite<>>
3630 static cl_svm_mem_flags getSVMMemFlags()
3633 CL_MEM_SVM_FINE_GRAIN_BUFFER |
3634 CL_MEM_SVM_ATOMICS |
3635 Trait::getSVMMemFlags();
3640 template<
typename T>
3646 const vector<Event>* events = NULL,
3647 Event* event = NULL);
3660 template<
typename T,
class SVMTrait>
3666 typedef T value_type;
3667 typedef value_type* pointer;
3668 typedef const value_type* const_pointer;
3669 typedef value_type& reference;
3670 typedef const value_type& const_reference;
3671 typedef std::size_t size_type;
3672 typedef std::ptrdiff_t difference_type;
3674 template<
typename U>
3680 template<
typename U,
typename V>
3684 context_(
Context::getDefault())
3694 SVMAllocator(
const SVMAllocator &other) :
3695 context_(other.context_)
3699 template<
typename U>
3700 SVMAllocator(
const SVMAllocator<U, SVMTrait> &other) :
3701 context_(other.context_)
3709 pointer address(reference r) CL_HPP_NOEXCEPT_
3711 return std::addressof(r);
3714 const_pointer address(const_reference r) CL_HPP_NOEXCEPT_
3716 return std::addressof(r);
3733 SVMTrait::getSVMMemFlags(),
3736 pointer retValue =
reinterpret_cast<pointer
>(
3738 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
3740 std::bad_alloc excep;
3746 if (!(SVMTrait::getSVMMemFlags() & CL_MEM_SVM_FINE_GRAIN_BUFFER)) {
3747 cl_int err =
enqueueMapSVM(retValue, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE, size*
sizeof(T));
3748 if (err != CL_SUCCESS) {
3749 std::bad_alloc excep;
3758 void deallocate(pointer p, size_type)
3760 clSVMFree(context_(), p);
3769 size_type maxSize = std::numeric_limits<size_type>::max() /
sizeof(T);
3771 for (
const Device &d : context_.
getInfo<CL_CONTEXT_DEVICES>()) {
3774 static_cast<size_type
>(d.getInfo<CL_DEVICE_MAX_MEM_ALLOC_SIZE>()));
3780 template<
class U,
class... Args >
3781 void construct(U* p, Args&&... args)
3797 return (context_==rhs.context_);
3807 template<
class SVMTrait>
3810 typedef void value_type;
3811 typedef value_type* pointer;
3812 typedef const value_type* const_pointer;
3814 template<
typename U>
3820 template<
typename U,
typename V>
3824 #if !defined(CL_HPP_NO_STD_UNIQUE_PTR)
3827 template<
class Alloc>
3834 typedef typename std::allocator_traits<Alloc>::pointer pointer;
3836 Deleter(
const Alloc &alloc, size_type copies) : alloc_{ alloc }, copies_{ copies }
3840 void operator()(pointer ptr)
const {
3841 Alloc tmpAlloc{ alloc_ };
3842 std::allocator_traits<Alloc>::destroy(tmpAlloc, std::addressof(*ptr));
3843 std::allocator_traits<Alloc>::deallocate(tmpAlloc, ptr, copies_);
3854 template <
class T,
class Alloc,
class... Args>
3857 Alloc alloc(alloc_);
3858 static const size_type copies = 1;
3863 T* tmp = std::allocator_traits<Alloc>::allocate(alloc, copies);
3865 std::bad_alloc excep;
3869 std::allocator_traits<Alloc>::construct(
3871 std::addressof(*tmp),
3872 std::forward<Args>(args)...);
3876 catch (std::bad_alloc& b)
3878 std::allocator_traits<Alloc>::deallocate(alloc, tmp, copies);
3883 template<
class T,
class SVMTrait,
class... Args >
3884 cl::pointer<T, detail::Deleter<SVMAllocator<T, SVMTrait>>> allocate_svm(Args... args)
3886 SVMAllocator<T, SVMTrait> alloc;
3887 return cl::allocate_pointer<T>(alloc, args...);
3890 template<
class T,
class SVMTrait,
class... Args >
3891 cl::pointer<T, detail::Deleter<SVMAllocator<T, SVMTrait>>> allocate_svm(
const cl::Context &c, Args... args)
3893 SVMAllocator<T, SVMTrait> alloc(c);
3894 return cl::allocate_pointer<T>(alloc, args...);
3901 template <
class T >
3907 template <
class T >
3913 template <
class T >
3940 void* host_ptr = NULL,
3944 object_ = ::clCreateBuffer(context(), flags, size, host_ptr, &error);
3946 detail::errHandler(error, __CREATE_BUFFER_ERR);
3964 void* host_ptr = NULL,
3971 object_ = ::clCreateBuffer(context(), flags, size, host_ptr, &error);
3973 detail::errHandler(error, __CREATE_BUFFER_ERR);
3984 template<
typename IteratorType >
3986 IteratorType startIterator,
3987 IteratorType endIterator,
3989 bool useHostPtr =
false,
3992 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
3995 cl_mem_flags flags = 0;
3997 flags |= CL_MEM_READ_ONLY;
4000 flags |= CL_MEM_READ_WRITE;
4003 flags |= CL_MEM_USE_HOST_PTR;
4006 size_type size =
sizeof(DataType)*(endIterator - startIterator);
4011 object_ = ::clCreateBuffer(context(), flags, size,
const_cast<DataType*
>(&*startIterator), &error);
4013 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
4016 detail::errHandler(error, __CREATE_BUFFER_ERR);
4022 error =
cl::copy(startIterator, endIterator, *
this);
4023 detail::errHandler(error, __CREATE_BUFFER_ERR);
4035 template<
typename IteratorType >
4036 Buffer(
const Context &context, IteratorType startIterator, IteratorType endIterator,
4037 bool readOnly,
bool useHostPtr =
false, cl_int* err = NULL);
4043 template<
typename IteratorType >
4044 Buffer(
const CommandQueue &queue, IteratorType startIterator, IteratorType endIterator,
4045 bool readOnly,
bool useHostPtr =
false, cl_int* err = NULL);
4057 explicit Buffer(
const cl_mem& buffer,
bool retainObject =
false) :
4058 Memory(buffer, retainObject) { }
4098 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
4105 cl_buffer_create_type buffer_create_type,
4106 const void * buffer_create_info,
4107 cl_int * err = NULL)
4111 result.object_ = ::clCreateSubBuffer(
4118 detail::errHandler(error, __CREATE_SUBBUFFER_ERR);
4128 #if defined (CL_HPP_USE_DX_INTEROP)
4137 class BufferD3D10 :
public Buffer
4148 const Context& context,
4150 ID3D10Buffer* bufobj,
4151 cl_int * err = NULL) : pfn_clCreateFromD3D10BufferKHR(nullptr)
4153 typedef CL_API_ENTRY cl_mem (CL_API_CALL *PFN_clCreateFromD3D10BufferKHR)(
4154 cl_context context, cl_mem_flags flags, ID3D10Buffer* buffer,
4155 cl_int* errcode_ret);
4156 PFN_clCreateFromD3D10BufferKHR pfn_clCreateFromD3D10BufferKHR;
4157 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
4158 vector<cl_context_properties> props = context.getInfo<CL_CONTEXT_PROPERTIES>();
4159 cl_platform platform = -1;
4160 for(
int i = 0; i < props.size(); ++i ) {
4161 if( props[i] == CL_CONTEXT_PLATFORM ) {
4162 platform = props[i+1];
4165 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCreateFromD3D10BufferKHR);
4166 #elif CL_HPP_TARGET_OPENCL_VERSION >= 110
4167 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateFromD3D10BufferKHR);
4171 object_ = pfn_clCreateFromD3D10BufferKHR(
4177 detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
4184 BufferD3D10() : Buffer() { }
4193 explicit BufferD3D10(
const cl_mem& buffer,
bool retainObject =
false) :
4194 Buffer(buffer, retainObject) { }
4200 BufferD3D10& operator = (
const cl_mem& rhs)
4209 BufferD3D10(
const BufferD3D10& buf) :
4215 BufferD3D10& operator = (
const BufferD3D10 &buf)
4224 BufferD3D10(BufferD3D10&& buf) CL_HPP_NOEXCEPT_ : Buffer(std::move(buf)) {}
4229 BufferD3D10& operator = (BufferD3D10 &&buf)
4257 cl_int * err = NULL)
4260 object_ = ::clCreateFromGLBuffer(
4266 detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
4282 explicit BufferGL(
const cl_mem& buffer,
bool retainObject =
false) :
4283 Buffer(buffer, retainObject) { }
4325 cl_gl_object_type *type,
4326 cl_GLuint * gl_object_name)
4328 return detail::errHandler(
4329 ::clGetGLObjectInfo(object_,type,gl_object_name),
4330 __GET_GL_OBJECT_INFO_ERR);
4354 cl_int * err = NULL)
4357 object_ = ::clCreateFromGLRenderbuffer(
4363 detail::errHandler(error, __CREATE_GL_RENDER_BUFFER_ERR);
4380 Buffer(buffer, retainObject) { }
4422 cl_gl_object_type *type,
4423 cl_GLuint * gl_object_name)
4425 return detail::errHandler(
4426 ::clGetGLObjectInfo(object_,type,gl_object_name),
4427 __GET_GL_OBJECT_INFO_ERR);
4450 explicit Image(
const cl_mem& image,
bool retainObject =
false) :
4451 Memory(image, retainObject) { }
4494 template <
typename T>
4497 return detail::errHandler(
4498 detail::getInfo(&::clGetImageInfo, object_, name, param),
4499 __GET_IMAGE_INFO_ERR);
4503 template <cl_image_info name>
typename
4508 detail::cl_image_info, name>::param_type param;
4517 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
4536 void* host_ptr = NULL,
4541 cl_image_desc desc = {0};
4542 desc.image_type = CL_MEM_OBJECT_IMAGE1D;
4543 desc.image_width = width;
4545 object_ = ::clCreateImage(
4553 detail::errHandler(error, __CREATE_IMAGE_ERR);
4569 explicit Image1D(
const cl_mem& image1D,
bool retainObject =
false) :
4570 Image(image1D, retainObject) { }
4628 cl_image_desc desc = {0};
4629 desc.image_type = CL_MEM_OBJECT_IMAGE1D_BUFFER;
4630 desc.image_width = width;
4631 desc.buffer = buffer();
4633 object_ = ::clCreateImage(
4641 detail::errHandler(error, __CREATE_IMAGE_ERR);
4657 Image(image1D, retainObject) { }
4705 size_type arraySize,
4708 void* host_ptr = NULL,
4713 cl_image_desc desc = {0};
4714 desc.image_type = CL_MEM_OBJECT_IMAGE1D_ARRAY;
4715 desc.image_width = width;
4716 desc.image_array_size = arraySize;
4717 desc.image_row_pitch = rowPitch;
4719 object_ = ::clCreateImage(
4727 detail::errHandler(error, __CREATE_IMAGE_ERR);
4742 explicit Image1DArray(
const cl_mem& imageArray,
bool retainObject =
false) :
4743 Image(imageArray, retainObject) { }
4803 size_type row_pitch = 0,
4804 void* host_ptr = NULL,
4808 bool useCreateImage;
4810 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
4813 cl_uint version = detail::getContextPlatformVersion(context());
4814 useCreateImage = (version >= 0x10002);
4816 #elif CL_HPP_TARGET_OPENCL_VERSION >= 120
4817 useCreateImage =
true;
4819 useCreateImage =
false;
4822 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
4825 cl_image_desc desc = {0};
4826 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
4827 desc.image_width = width;
4828 desc.image_height = height;
4829 desc.image_row_pitch = row_pitch;
4831 object_ = ::clCreateImage(
4839 detail::errHandler(error, __CREATE_IMAGE_ERR);
4845 #if CL_HPP_MINIMUM_OPENCL_VERSION < 120
4846 if (!useCreateImage)
4848 object_ = ::clCreateImage2D(
4849 context(), flags,&format, width, height, row_pitch, host_ptr, &error);
4851 detail::errHandler(error, __CREATE_IMAGE2D_ERR);
4859 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 || defined(CL_HPP_USE_CL_IMAGE2D_FROM_BUFFER_KHR)
4868 const Buffer &sourceBuffer,
4871 size_type row_pitch = 0,
4872 cl_int* err =
nullptr)
4876 cl_image_desc desc = {0};
4877 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
4878 desc.image_width = width;
4879 desc.image_height = height;
4880 desc.image_row_pitch = row_pitch;
4881 desc.buffer = sourceBuffer();
4883 object_ = ::clCreateImage(
4891 detail::errHandler(error, __CREATE_IMAGE_ERR);
4892 if (err !=
nullptr) {
4898 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
4913 cl_channel_order order,
4914 const Image &sourceImage,
4915 cl_int* err =
nullptr)
4920 size_type sourceWidth =
4922 size_type sourceHeight =
4924 size_type sourceRowPitch =
4926 cl_uint sourceNumMIPLevels =
4928 cl_uint sourceNumSamples =
4930 cl_image_format sourceFormat =
4935 sourceFormat.image_channel_order = order;
4937 cl_image_desc desc = {0};
4938 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
4939 desc.image_width = sourceWidth;
4940 desc.image_height = sourceHeight;
4941 desc.image_row_pitch = sourceRowPitch;
4942 desc.num_mip_levels = sourceNumMIPLevels;
4943 desc.num_samples = sourceNumSamples;
4944 desc.buffer = sourceImage();
4946 object_ = ::clCreateImage(
4954 detail::errHandler(error, __CREATE_IMAGE_ERR);
4955 if (err !=
nullptr) {
4971 explicit Image2D(
const cl_mem& image2D,
bool retainObject =
false) :
4972 Image(image2D, retainObject) { }
5015 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
5039 cl_int * err = NULL)
5042 object_ = ::clCreateFromGLTexture2D(
5050 detail::errHandler(error, __CREATE_GL_TEXTURE_2D_ERR);
5067 explicit Image2DGL(
const cl_mem& image,
bool retainObject =
false) :
5068 Image2D(image, retainObject) { }
5108 } CL_API_SUFFIX__VERSION_1_1_DEPRECATED;
5111 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
5122 size_type arraySize,
5126 size_type slicePitch,
5127 void* host_ptr = NULL,
5132 cl_image_desc desc = {0};
5133 desc.image_type = CL_MEM_OBJECT_IMAGE2D_ARRAY;
5134 desc.image_width = width;
5135 desc.image_height = height;
5136 desc.image_array_size = arraySize;
5137 desc.image_row_pitch = rowPitch;
5138 desc.image_slice_pitch = slicePitch;
5140 object_ = ::clCreateImage(
5148 detail::errHandler(error, __CREATE_IMAGE_ERR);
5163 explicit Image2DArray(
const cl_mem& imageArray,
bool retainObject =
false) :
Image(imageArray, retainObject) { }
5221 size_type row_pitch = 0,
5222 size_type slice_pitch = 0,
5223 void* host_ptr = NULL,
5227 bool useCreateImage;
5229 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
5232 cl_uint version = detail::getContextPlatformVersion(context());
5233 useCreateImage = (version >= 0x10002);
5235 #elif CL_HPP_TARGET_OPENCL_VERSION >= 120
5236 useCreateImage =
true;
5238 useCreateImage =
false;
5241 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
5244 cl_image_desc desc = {0};
5245 desc.image_type = CL_MEM_OBJECT_IMAGE3D;
5246 desc.image_width = width;
5247 desc.image_height = height;
5248 desc.image_depth = depth;
5249 desc.image_row_pitch = row_pitch;
5250 desc.image_slice_pitch = slice_pitch;
5252 object_ = ::clCreateImage(
5260 detail::errHandler(error, __CREATE_IMAGE_ERR);
5266 #if CL_HPP_MINIMUM_OPENCL_VERSION < 120
5267 if (!useCreateImage)
5269 object_ = ::clCreateImage3D(
5270 context(), flags, &format, width, height, depth, row_pitch,
5271 slice_pitch, host_ptr, &error);
5273 detail::errHandler(error, __CREATE_IMAGE3D_ERR);
5291 explicit Image3D(
const cl_mem& image3D,
bool retainObject =
false) :
5292 Image(image3D, retainObject) { }
5333 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
5356 cl_int * err = NULL)
5359 object_ = ::clCreateFromGLTexture3D(
5367 detail::errHandler(error, __CREATE_GL_TEXTURE_3D_ERR);
5383 explicit Image3DGL(
const cl_mem& image,
bool retainObject =
false) :
5384 Image3D(image, retainObject) { }
5426 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
5442 cl_int * err = NULL)
5445 object_ = ::clCreateFromGLTexture(
5453 detail::errHandler(error, __CREATE_GL_TEXTURE_ERR);
5468 explicit ImageGL(
const cl_mem& image,
bool retainObject =
false) :
5469 Image(image, retainObject) { }
5471 ImageGL& operator = (
const cl_mem& rhs)
5509 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
5531 cl_uint packet_size,
5532 cl_uint max_packets,
5537 cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS;
5538 object_ = ::clCreatePipe(context(), flags, packet_size, max_packets,
nullptr, &error);
5540 detail::errHandler(error, __CREATE_PIPE_ERR);
5555 cl_uint packet_size,
5556 cl_uint max_packets,
5563 cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS;
5564 object_ = ::clCreatePipe(context(), flags, packet_size, max_packets,
nullptr, &error);
5566 detail::errHandler(error, __CREATE_PIPE_ERR);
5582 explicit Pipe(
const cl_mem& pipe,
bool retainObject =
false) :
5583 Memory(pipe, retainObject) { }
5624 template <
typename T>
5627 return detail::errHandler(
5628 detail::getInfo(&::clGetPipeInfo, object_, name, param),
5629 __GET_PIPE_INFO_ERR);
5633 template <cl_pipe_info name>
typename
5638 detail::cl_pipe_info, name>::param_type param;
5639 cl_int result =
getInfo(name, ¶m);
5669 cl_bool normalized_coords,
5670 cl_addressing_mode addressing_mode,
5671 cl_filter_mode filter_mode,
5676 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
5677 cl_sampler_properties sampler_properties[] = {
5678 CL_SAMPLER_NORMALIZED_COORDS, normalized_coords,
5679 CL_SAMPLER_ADDRESSING_MODE, addressing_mode,
5680 CL_SAMPLER_FILTER_MODE, filter_mode,
5682 object_ = ::clCreateSamplerWithProperties(
5687 detail::errHandler(error, __CREATE_SAMPLER_WITH_PROPERTIES_ERR);
5692 object_ = ::clCreateSampler(
5699 detail::errHandler(error, __CREATE_SAMPLER_ERR);
5714 explicit Sampler(
const cl_sampler& sampler,
bool retainObject =
false) :
5715 detail::Wrapper<cl_type>(sampler, retainObject) { }
5757 template <
typename T>
5758 cl_int
getInfo(cl_sampler_info name, T* param)
const
5760 return detail::errHandler(
5761 detail::getInfo(&::clGetSamplerInfo, object_, name, param),
5762 __GET_SAMPLER_INFO_ERR);
5766 template <cl_sampler_info name>
typename
5771 detail::cl_sampler_info, name>::param_type param;
5772 cl_int result =
getInfo(name, ¶m);
5782 class DeviceCommandQueue;
5789 size_type sizes_[3];
5790 cl_uint dimensions_;
5821 NDRange(size_type size0, size_type size1, size_type size2)
5833 operator const size_type*()
const {
5847 return dimensions_*
sizeof(size_type);
5855 const size_type* get()
const
5862 static const NDRange NullRange;
5872 template <
typename T,
class Enable =
void>
5877 template <
typename T>
5880 static size_type size(
const T&) {
return sizeof(T); }
5881 static const T* ptr(
const T& value) {
return &value; }
5886 template <
typename T>
5889 static size_type size(
const T&) {
return sizeof(cl_mem); }
5890 static const cl_mem* ptr(
const T& value) {
return &(value()); }
5898 static size_type size(
const LocalSpaceArg& value) {
return value.size_; }
5899 static const void* ptr(
const LocalSpaceArg&) {
return NULL; }
5926 inline Kernel(
const Program& program,
const char* name, cl_int* err = NULL);
5939 explicit Kernel(
const cl_kernel& kernel,
bool retainObject =
false) :
5940 detail::Wrapper<cl_type>(kernel, retainObject) { }
5981 template <
typename T>
5982 cl_int getInfo(cl_kernel_info name, T* param)
const
5984 return detail::errHandler(
5985 detail::getInfo(&::clGetKernelInfo, object_, name, param),
5986 __GET_KERNEL_INFO_ERR);
5989 template <cl_kernel_info name>
typename
5990 detail::param_traits<detail::cl_kernel_info, name>::param_type
5991 getInfo(cl_int* err = NULL)
const
5993 typename detail::param_traits<
5994 detail::cl_kernel_info, name>::param_type param;
5995 cl_int result = getInfo(name, ¶m);
6002 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
6003 template <
typename T>
6004 cl_int getArgInfo(cl_uint argIndex, cl_kernel_arg_info name, T* param)
const
6006 return detail::errHandler(
6007 detail::getInfo(&::clGetKernelArgInfo, object_, argIndex, name, param),
6008 __GET_KERNEL_ARG_INFO_ERR);
6011 template <cl_kernel_arg_info name>
typename
6012 detail::param_traits<detail::cl_kernel_arg_info, name>::param_type
6013 getArgInfo(cl_uint argIndex, cl_int* err = NULL)
const
6015 typename detail::param_traits<
6016 detail::cl_kernel_arg_info, name>::param_type param;
6017 cl_int result = getArgInfo(argIndex, name, ¶m);
6025 template <
typename T>
6026 cl_int getWorkGroupInfo(
6027 const Device& device, cl_kernel_work_group_info name, T* param)
const
6029 return detail::errHandler(
6031 &::clGetKernelWorkGroupInfo, object_, device(), name, param),
6032 __GET_KERNEL_WORK_GROUP_INFO_ERR);
6035 template <cl_kernel_work_group_info name>
typename
6036 detail::param_traits<detail::cl_kernel_work_group_info, name>::param_type
6037 getWorkGroupInfo(
const Device& device, cl_int* err = NULL)
const
6039 typename detail::param_traits<
6040 detail::cl_kernel_work_group_info, name>::param_type param;
6041 cl_int result = getWorkGroupInfo(device, name, ¶m);
6048 #if (CL_HPP_TARGET_OPENCL_VERSION >= 200 && defined(CL_HPP_USE_CL_SUB_GROUPS_KHR)) || CL_HPP_TARGET_OPENCL_VERSION >= 210
6049 cl_int getSubGroupInfo(
const cl::Device &dev, cl_kernel_sub_group_info name,
const cl::NDRange &range, size_type* param)
const
6051 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
6053 return detail::errHandler(
6054 clGetKernelSubGroupInfo(object_, dev(), name, range.
size(), range.get(),
sizeof(size_type), param,
nullptr),
6055 __GET_KERNEL_SUB_GROUP_INFO_ERR);
6059 typedef clGetKernelSubGroupInfoKHR_fn PFN_clGetKernelSubGroupInfoKHR;
6060 static PFN_clGetKernelSubGroupInfoKHR pfn_clGetKernelSubGroupInfoKHR = NULL;
6061 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetKernelSubGroupInfoKHR);
6063 return detail::errHandler(
6064 pfn_clGetKernelSubGroupInfoKHR(object_, dev(), name, range.
size(), range.get(),
sizeof(size_type), param,
nullptr),
6065 __GET_KERNEL_SUB_GROUP_INFO_ERR);
6070 template <cl_kernel_sub_group_info name>
6071 size_type getSubGroupInfo(
const cl::Device &dev,
const cl::NDRange &range, cl_int* err = NULL)
const
6074 cl_int result = getSubGroupInfo(dev, name, range, ¶m);
6082 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
6085 template<
typename T,
class D>
6086 cl_int
setArg(cl_uint index,
const cl::pointer<T, D> &argPtr)
6088 return detail::errHandler(
6089 ::clSetKernelArgSVMPointer(object_, index, argPtr.get()),
6090 __SET_KERNEL_ARGS_ERR);
6095 template<
typename T,
class Alloc>
6096 cl_int
setArg(cl_uint index,
const cl::vector<T, Alloc> &argPtr)
6098 return detail::errHandler(
6099 ::clSetKernelArgSVMPointer(object_, index, argPtr.data()),
6100 __SET_KERNEL_ARGS_ERR);
6105 template<
typename T>
6106 typename std::enable_if<std::is_pointer<T>::value, cl_int>::type
6109 return detail::errHandler(
6110 ::clSetKernelArgSVMPointer(object_, index, argPtr),
6111 __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(
6127 __SET_KERNEL_ARGS_ERR);
6130 cl_int
setArg(cl_uint index, size_type size,
const void* argPtr)
6132 return detail::errHandler(
6133 ::clSetKernelArg(object_, index, size, argPtr),
6134 __SET_KERNEL_ARGS_ERR);
6137 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
6144 return detail::errHandler(
6145 ::clSetKernelExecInfo(
6147 CL_KERNEL_EXEC_INFO_SVM_PTRS,
6148 sizeof(
void*)*pointerList.size(),
6149 pointerList.data()));
6156 template<
int ArrayLength>
6159 return detail::errHandler(
6160 ::clSetKernelExecInfo(
6162 CL_KERNEL_EXEC_INFO_SVM_PTRS,
6163 sizeof(
void*)*pointerList.size(),
6164 pointerList.data()));
6180 cl_bool svmEnabled_ = svmEnabled ? CL_TRUE : CL_FALSE;
6181 return detail::errHandler(
6182 ::clSetKernelExecInfo(
6184 CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM,
6191 template<
int index,
int ArrayLength,
class D,
typename T0,
typename T1,
typename... Ts>
6192 void setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList,
const pointer<T0, D> &t0,
const pointer<T1, D> &t1, Ts & ... ts)
6194 pointerList[index] =
static_cast<void*
>(t0.get());
6195 setSVMPointersHelper<index + 1, ArrayLength>(pointerList, t1, ts...);
6198 template<
int index,
int ArrayLength,
typename T0,
typename T1,
typename... Ts>
6199 typename std::enable_if<std::is_pointer<T0>::value,
void>::type
6200 setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList, T0 t0, T1 t1, Ts... ts)
6202 pointerList[index] =
static_cast<void*
>(t0);
6203 setSVMPointersHelper<index + 1, ArrayLength>(pointerList, t1, ts...);
6206 template<
int index,
int ArrayLength,
typename T0,
class D>
6207 void setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList,
const pointer<T0, D> &t0)
6209 pointerList[index] =
static_cast<void*
>(t0.get());
6213 template<
int index,
int ArrayLength,
typename T0>
6214 typename std::enable_if<std::is_pointer<T0>::value,
void>::type
6215 setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList, T0 t0)
6217 pointerList[index] =
static_cast<void*
>(t0);
6220 template<
typename T0,
typename... Ts>
6223 std::array<
void*, 1 +
sizeof...(Ts)> pointerList;
6225 setSVMPointersHelper<0, 1 +
sizeof...(Ts)>(pointerList, t0, ts...);
6226 return detail::errHandler(
6227 ::clSetKernelExecInfo(
6229 CL_KERNEL_EXEC_INFO_SVM_PTRS,
6230 sizeof(
void*)*(1 +
sizeof...(Ts)),
6231 pointerList.data()));
6234 template<
typename T>
6235 cl_int setExecInfo(cl_kernel_exec_info param_name,
const T& val)
6237 return detail::errHandler(
6238 ::clSetKernelExecInfo(
6245 template<cl_kernel_exec_info name>
6246 cl_int setExecInfo(
typename detail::param_traits<detail::cl_kernel_exec_info, name>::param_type& val)
6248 return setExecInfo(name, val);
6252 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
6261 Kernel retValue(clCloneKernel(this->get(), &error));
6263 detail::errHandler(error, __CLONE_KERNEL_ERR);
6275 #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6276 typedef vector<vector<unsigned char>> Binaries;
6277 typedef vector<string> Sources;
6279 typedef vector<std::pair<const void*, size_type> > Binaries;
6280 typedef vector<std::pair<const char*, size_type> > Sources;
6284 const string& source,
6290 const char * strings = source.c_str();
6291 const size_type length = source.size();
6295 object_ = ::clCreateProgramWithSource(
6296 context(), (cl_uint)1, &strings, &length, &error);
6298 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6300 if (error == CL_SUCCESS && build) {
6302 error = ::clBuildProgram(
6306 #
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6314 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6324 const string& source,
6330 const char * strings = source.c_str();
6331 const size_type length = source.size();
6333 object_ = ::clCreateProgramWithSource(
6334 context(), (cl_uint)1, &strings, &length, &error);
6336 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6338 if (error == CL_SUCCESS && build) {
6339 error = ::clBuildProgram(
6343 #
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6351 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6364 const Sources& sources,
6370 const size_type n = (size_type)sources.size();
6372 vector<size_type> lengths(n);
6373 vector<const char*> strings(n);
6375 for (size_type i = 0; i < n; ++i) {
6376 #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6377 strings[i] = sources[(int)i].data();
6378 lengths[i] = sources[(int)i].length();
6380 strings[i] = sources[(int)i].first;
6381 lengths[i] = sources[(int)i].second;
6385 object_ = ::clCreateProgramWithSource(
6386 context(), (cl_uint)n, strings.data(), lengths.data(), &error);
6388 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6400 const Sources& sources,
6405 const size_type n = (size_type)sources.size();
6407 vector<size_type> lengths(n);
6408 vector<const char*> strings(n);
6410 for (size_type i = 0; i < n; ++i) {
6411 #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6412 strings[i] = sources[(int)i].data();
6413 lengths[i] = sources[(int)i].length();
6415 strings[i] = sources[(int)i].first;
6416 lengths[i] = sources[(int)i].second;
6420 object_ = ::clCreateProgramWithSource(
6421 context(), (cl_uint)n, strings.data(), lengths.data(), &error);
6423 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6430 #if CL_HPP_TARGET_OPENCL_VERSION >= 210 || (CL_HPP_TARGET_OPENCL_VERSION==200 && defined(CL_HPP_USE_IL_KHR))
6436 const vector<char>& IL,
6444 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
6446 object_ = ::clCreateProgramWithIL(
6447 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6451 typedef clCreateProgramWithILKHR_fn PFN_clCreateProgramWithILKHR;
6452 static PFN_clCreateProgramWithILKHR pfn_clCreateProgramWithILKHR = NULL;
6453 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateProgramWithILKHR);
6455 object_ = pfn_clCreateProgramWithILKHR(
6456 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6460 detail::errHandler(error, __CREATE_PROGRAM_WITH_IL_ERR);
6462 if (error == CL_SUCCESS && build) {
6464 error = ::clBuildProgram(
6468 #
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6476 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6491 const vector<char>& IL,
6497 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
6499 object_ = ::clCreateProgramWithIL(
6500 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6504 typedef clCreateProgramWithILKHR_fn PFN_clCreateProgramWithILKHR;
6505 static PFN_clCreateProgramWithILKHR pfn_clCreateProgramWithILKHR = NULL;
6506 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateProgramWithILKHR);
6508 object_ = pfn_clCreateProgramWithILKHR(
6509 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6513 detail::errHandler(error, __CREATE_PROGRAM_WITH_IL_ERR);
6515 if (error == CL_SUCCESS && build) {
6516 error = ::clBuildProgram(
6520 #
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6528 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6558 const vector<Device>& devices,
6559 const Binaries& binaries,
6560 vector<cl_int>* binaryStatus = NULL,
6565 const size_type numDevices = devices.size();
6568 if(binaries.size() != numDevices) {
6569 error = CL_INVALID_VALUE;
6570 detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
6578 vector<size_type> lengths(numDevices);
6579 vector<const unsigned char*> images(numDevices);
6580 #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6581 for (size_type i = 0; i < numDevices; ++i) {
6582 images[i] = binaries[i].data();
6583 lengths[i] = binaries[(int)i].size();
6586 for (size_type i = 0; i < numDevices; ++i) {
6587 images[i] = (
const unsigned char*)binaries[i].first;
6588 lengths[i] = binaries[(int)i].second;
6592 vector<cl_device_id> deviceIDs(numDevices);
6593 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6594 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6598 binaryStatus->resize(numDevices);
6601 object_ = ::clCreateProgramWithBinary(
6602 context(), (cl_uint) devices.size(),
6604 lengths.data(), images.data(), (binaryStatus != NULL && numDevices > 0)
6605 ? &binaryStatus->front()
6608 detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
6615 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
6622 const vector<Device>& devices,
6623 const string& kernelNames,
6629 size_type numDevices = devices.size();
6630 vector<cl_device_id> deviceIDs(numDevices);
6631 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6632 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6635 object_ = ::clCreateProgramWithBuiltInKernels(
6637 (cl_uint) devices.size(),
6639 kernelNames.c_str(),
6642 detail::errHandler(error, __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR);
6658 explicit Program(
const cl_program& program,
bool retainObject =
false) :
6659 detail::Wrapper<cl_type>(program, retainObject) { }
6661 Program& operator = (
const cl_program& rhs)
6696 const vector<Device>& devices,
6697 const char* options = NULL,
6698 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6699 void* data = NULL)
const
6701 size_type numDevices = devices.size();
6702 vector<cl_device_id> deviceIDs(numDevices);
6704 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6705 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6708 cl_int buildError = ::clBuildProgram(
6717 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6721 const Device& device,
6722 const char* options = NULL,
6723 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6724 void* data = NULL)
const
6726 cl_device_id deviceID = device();
6728 cl_int buildError = ::clBuildProgram(
6736 BuildLogType buildLog(0);
6737 buildLog.push_back(std::make_pair(device, getBuildInfo<CL_PROGRAM_BUILD_LOG>(device)));
6738 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, buildLog);
6742 const char* options = NULL,
6743 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6744 void* data = NULL)
const
6746 cl_int buildError = ::clBuildProgram(
6754 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6757 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
6759 const char* options = NULL,
6760 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6761 void* data = NULL)
const
6763 cl_int error = ::clCompileProgram(
6773 return detail::buildErrHandler(error, __COMPILE_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6777 template <
typename T>
6778 cl_int getInfo(cl_program_info name, T* param)
const
6780 return detail::errHandler(
6781 detail::getInfo(&::clGetProgramInfo, object_, name, param),
6782 __GET_PROGRAM_INFO_ERR);
6785 template <cl_program_info name>
typename
6786 detail::param_traits<detail::cl_program_info, name>::param_type
6787 getInfo(cl_int* err = NULL)
const
6789 typename detail::param_traits<
6790 detail::cl_program_info, name>::param_type param;
6791 cl_int result = getInfo(name, ¶m);
6798 template <
typename T>
6799 cl_int getBuildInfo(
6800 const Device& device, cl_program_build_info name, T* param)
const
6802 return detail::errHandler(
6804 &::clGetProgramBuildInfo, object_, device(), name, param),
6805 __GET_PROGRAM_BUILD_INFO_ERR);
6808 template <cl_program_build_info name>
typename
6809 detail::param_traits<detail::cl_program_build_info, name>::param_type
6810 getBuildInfo(
const Device& device, cl_int* err = NULL)
const
6812 typename detail::param_traits<
6813 detail::cl_program_build_info, name>::param_type param;
6814 cl_int result = getBuildInfo(device, name, ¶m);
6826 template <cl_program_build_info name>
6827 vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, name>::param_type>>
6830 cl_int result = CL_SUCCESS;
6832 auto devs = getInfo<CL_PROGRAM_DEVICES>(&result);
6833 vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, name>::param_type>>
6837 if (result != CL_SUCCESS) {
6846 detail::cl_program_build_info, name>::param_type param;
6847 result = getBuildInfo(d, name, ¶m);
6851 if (result != CL_SUCCESS) {
6859 if (result != CL_SUCCESS) {
6865 cl_int createKernels(vector<Kernel>* kernels)
6868 cl_int err = ::clCreateKernelsInProgram(object_, 0, NULL, &numKernels);
6869 if (err != CL_SUCCESS) {
6870 return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
6873 vector<cl_kernel> value(numKernels);
6875 err = ::clCreateKernelsInProgram(
6876 object_, numKernels, value.data(), NULL);
6877 if (err != CL_SUCCESS) {
6878 return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
6882 kernels->resize(value.size());
6886 for (size_type i = 0; i < value.size(); i++) {
6889 (*kernels)[i] = Kernel(value[i],
false);
6895 #if CL_HPP_TARGET_OPENCL_VERSION >= 220
6896 #if defined(CL_USE_DEPRECATED_OPENCL_2_2_APIS)
6908 void (CL_CALLBACK * pfn_notify)(cl_program program,
void * user_data),
6909 void * user_data = NULL) CL_API_SUFFIX__VERSION_2_2_DEPRECATED
6911 return detail::errHandler(
6912 ::clSetProgramReleaseCallback(
6916 __SET_PROGRAM_RELEASE_CALLBACK_ERR);
6924 template <
typename T>
6925 typename std::enable_if<!std::is_pointer<T>::value, cl_int>::type
6928 return detail::errHandler(
6929 ::clSetProgramSpecializationConstant(
6934 __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR);
6943 return detail::errHandler(
6944 ::clSetProgramSpecializationConstant(
6949 __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR);
6954 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
6955 inline Program linkProgram(
6958 const char* options = NULL,
6959 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6963 cl_int error_local = CL_SUCCESS;
6965 cl_program programs[2] = { input1(), input2() };
6967 Context ctx = input1.getInfo<CL_PROGRAM_CONTEXT>(&error_local);
6968 if(error_local!=CL_SUCCESS) {
6969 detail::errHandler(error_local, __LINK_PROGRAM_ERR);
6972 cl_program prog = ::clLinkProgram(
6983 detail::errHandler(error_local,__COMPILE_PROGRAM_ERR);
6988 return Program(prog);
6991 inline Program linkProgram(
6992 vector<Program> inputPrograms,
6993 const char* options = NULL,
6994 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6998 cl_int error_local = CL_SUCCESS;
7000 vector<cl_program> programs(inputPrograms.size());
7002 for (
unsigned int i = 0; i < inputPrograms.size(); i++) {
7003 programs[i] = inputPrograms[i]();
7007 if(inputPrograms.size() > 0) {
7008 ctx = inputPrograms[0].getInfo<CL_PROGRAM_CONTEXT>(&error_local);
7009 if(error_local!=CL_SUCCESS) {
7010 detail::errHandler(error_local, __LINK_PROGRAM_ERR);
7013 cl_program prog = ::clLinkProgram(
7018 (cl_uint)inputPrograms.size(),
7024 detail::errHandler(error_local,__COMPILE_PROGRAM_ERR);
7029 return Program(prog,
false);
7035 inline cl_int cl::Program::getInfo(cl_program_info name, vector<vector<unsigned char>>* param)
const
7037 if (name != CL_PROGRAM_BINARIES) {
7038 return CL_INVALID_VALUE;
7044 vector<size_type> sizes = getInfo<CL_PROGRAM_BINARY_SIZES>();
7045 size_type numBinaries = sizes.size();
7048 param->resize(numBinaries);
7049 for (size_type i = 0; i < numBinaries; ++i) {
7050 (*param)[i].resize(sizes[i]);
7053 return detail::errHandler(
7054 detail::getInfo(&::clGetProgramInfo, object_, name, param),
7055 __GET_PROGRAM_INFO_ERR);
7062 inline vector<vector<unsigned char>> cl::Program::getInfo<CL_PROGRAM_BINARIES>(cl_int* err)
const
7064 vector<vector<unsigned char>> binariesVectors;
7066 cl_int result = getInfo(CL_PROGRAM_BINARIES, &binariesVectors);
7070 return binariesVectors;
7073 #if CL_HPP_TARGET_OPENCL_VERSION >= 220
7078 cl_uchar ucValue = value ? CL_UCHAR_MAX : 0;
7079 return detail::errHandler(
7080 ::clSetProgramSpecializationConstant(
7085 __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR);
7089 inline Kernel::Kernel(
const Program& program,
const char* name, cl_int* err)
7093 object_ = ::clCreateKernel(program(), name, &error);
7094 detail::errHandler(error, __CREATE_KERNEL_ERR);
7102 enum class QueueProperties : cl_command_queue_properties
7105 Profiling = CL_QUEUE_PROFILING_ENABLE,
7106 OutOfOrder = CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE,
7109 inline QueueProperties operator|(QueueProperties lhs, QueueProperties rhs)
7111 return static_cast<QueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) |
static_cast<cl_command_queue_properties
>(rhs));
7114 inline QueueProperties operator&(QueueProperties lhs, QueueProperties rhs)
7116 return static_cast<QueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) &
static_cast<cl_command_queue_properties
>(rhs));
7125 static std::once_flag default_initialized_;
7127 static cl_int default_error_;
7134 static void makeDefault()
7139 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
7146 if (error != CL_SUCCESS) {
7147 default_error_ = error;
7151 default_ =
CommandQueue(context, device, 0, &default_error_);
7154 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
7155 catch (cl::Error &e) {
7156 default_error_ = e.err();
7166 static void makeDefaultProvided(
const CommandQueue &c) {
7171 #ifdef CL_HPP_UNIT_TEST_ENABLE
7178 static void unitTestClearDefault() {
7189 cl_command_queue_properties properties,
7195 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7197 if (error != CL_SUCCESS) {
7204 bool useWithProperties;
7206 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7209 cl_uint version = detail::getContextPlatformVersion(context());
7210 useWithProperties = (version >= 0x20000);
7212 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7213 useWithProperties =
true;
7215 useWithProperties =
false;
7218 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
7219 if (useWithProperties) {
7220 cl_queue_properties queue_properties[] = {
7221 CL_QUEUE_PROPERTIES, properties, 0 };
7222 if ((properties & CL_QUEUE_ON_DEVICE) == 0) {
7223 object_ = ::clCreateCommandQueueWithProperties(
7224 context(), device(), queue_properties, &error);
7227 error = CL_INVALID_QUEUE_PROPERTIES;
7230 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7236 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7237 if (!useWithProperties) {
7238 object_ = ::clCreateCommandQueue(
7239 context(), device(), properties, &error);
7241 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7255 QueueProperties properties,
7261 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7263 if (error != CL_SUCCESS) {
7270 bool useWithProperties;
7272 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7275 cl_uint version = detail::getContextPlatformVersion(context());
7276 useWithProperties = (version >= 0x20000);
7278 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7279 useWithProperties =
true;
7281 useWithProperties =
false;
7284 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
7285 if (useWithProperties) {
7286 cl_queue_properties queue_properties[] = {
7287 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
7289 object_ = ::clCreateCommandQueueWithProperties(
7290 context(), device(), queue_properties, &error);
7292 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7298 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7299 if (!useWithProperties) {
7300 object_ = ::clCreateCommandQueue(
7301 context(), device(),
static_cast<cl_command_queue_properties
>(properties), &error);
7303 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7319 cl_command_queue_properties properties = 0,
7323 bool useWithProperties;
7324 vector<cl::Device> devices;
7325 error = context.
getInfo(CL_CONTEXT_DEVICES, &devices);
7327 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7329 if (error != CL_SUCCESS)
7337 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7340 cl_uint version = detail::getContextPlatformVersion(context());
7341 useWithProperties = (version >= 0x20000);
7343 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7344 useWithProperties =
true;
7346 useWithProperties =
false;
7349 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
7350 if (useWithProperties) {
7351 cl_queue_properties queue_properties[] = {
7352 CL_QUEUE_PROPERTIES, properties, 0 };
7353 if ((properties & CL_QUEUE_ON_DEVICE) == 0) {
7354 object_ = ::clCreateCommandQueueWithProperties(
7355 context(), devices[0](), queue_properties, &error);
7358 error = CL_INVALID_QUEUE_PROPERTIES;
7361 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7367 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7368 if (!useWithProperties) {
7369 object_ = ::clCreateCommandQueue(
7370 context(), devices[0](), properties, &error);
7372 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7386 QueueProperties properties,
7390 bool useWithProperties;
7391 vector<cl::Device> devices;
7392 error = context.
getInfo(CL_CONTEXT_DEVICES, &devices);
7394 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7396 if (error != CL_SUCCESS)
7404 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7407 cl_uint version = detail::getContextPlatformVersion(context());
7408 useWithProperties = (version >= 0x20000);
7410 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7411 useWithProperties =
true;
7413 useWithProperties =
false;
7416 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
7417 if (useWithProperties) {
7418 cl_queue_properties queue_properties[] = {
7419 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
7420 object_ = ::clCreateCommandQueueWithProperties(
7421 context(), devices[0](), queue_properties, &error);
7423 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7429 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7430 if (!useWithProperties) {
7431 object_ = ::clCreateCommandQueue(
7432 context(), devices[0](),
static_cast<cl_command_queue_properties
>(properties), &error);
7434 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7449 cl_command_queue_properties properties = 0,
7453 bool useWithProperties;
7455 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7458 cl_uint version = detail::getContextPlatformVersion(context());
7459 useWithProperties = (version >= 0x20000);
7461 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7462 useWithProperties =
true;
7464 useWithProperties =
false;
7467 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
7468 if (useWithProperties) {
7469 cl_queue_properties queue_properties[] = {
7470 CL_QUEUE_PROPERTIES, properties, 0 };
7471 object_ = ::clCreateCommandQueueWithProperties(
7472 context(), device(), queue_properties, &error);
7474 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7480 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7481 if (!useWithProperties) {
7482 object_ = ::clCreateCommandQueue(
7483 context(), device(), properties, &error);
7485 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7500 QueueProperties properties,
7504 bool useWithProperties;
7506 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7509 cl_uint version = detail::getContextPlatformVersion(context());
7510 useWithProperties = (version >= 0x20000);
7512 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7513 useWithProperties =
true;
7515 useWithProperties =
false;
7518 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
7519 if (useWithProperties) {
7520 cl_queue_properties queue_properties[] = {
7521 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
7522 object_ = ::clCreateCommandQueueWithProperties(
7523 context(), device(), queue_properties, &error);
7525 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7531 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7532 if (!useWithProperties) {
7533 object_ = ::clCreateCommandQueue(
7534 context(), device(),
static_cast<cl_command_queue_properties
>(properties), &error);
7536 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7546 std::call_once(default_initialized_, makeDefault);
7547 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
7548 detail::errHandler(default_error_, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7550 detail::errHandler(default_error_, __CREATE_COMMAND_QUEUE_ERR);
7553 *err = default_error_;
7567 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_queue));
7568 detail::errHandler(default_error_);
7581 explicit CommandQueue(
const cl_command_queue& commandQueue,
bool retainObject =
false) :
7582 detail::Wrapper<cl_type>(commandQueue, retainObject) { }
7618 template <
typename T>
7619 cl_int getInfo(cl_command_queue_info name, T* param)
const
7621 return detail::errHandler(
7623 &::clGetCommandQueueInfo, object_, name, param),
7624 __GET_COMMAND_QUEUE_INFO_ERR);
7627 template <cl_command_queue_info name>
typename
7628 detail::param_traits<detail::cl_command_queue_info, name>::param_type
7629 getInfo(cl_int* err = NULL)
const
7631 typename detail::param_traits<
7632 detail::cl_command_queue_info, name>::param_type param;
7633 cl_int result = getInfo(name, ¶m);
7640 cl_int enqueueReadBuffer(
7641 const Buffer& buffer,
7646 const vector<Event>* events = NULL,
7647 Event* event = NULL)
const
7650 cl_int err = detail::errHandler(
7651 ::clEnqueueReadBuffer(
7652 object_, buffer(), blocking, offset, size,
7654 (events != NULL) ? (cl_uint) events->size() : 0,
7655 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7656 (event != NULL) ? &tmp : NULL),
7657 __ENQUEUE_READ_BUFFER_ERR);
7659 if (event != NULL && err == CL_SUCCESS)
7665 cl_int enqueueWriteBuffer(
7666 const Buffer& buffer,
7671 const vector<Event>* events = NULL,
7672 Event* event = NULL)
const
7675 cl_int err = detail::errHandler(
7676 ::clEnqueueWriteBuffer(
7677 object_, buffer(), blocking, offset, size,
7679 (events != NULL) ? (cl_uint) events->size() : 0,
7680 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7681 (event != NULL) ? &tmp : NULL),
7682 __ENQUEUE_WRITE_BUFFER_ERR);
7684 if (event != NULL && err == CL_SUCCESS)
7690 cl_int enqueueCopyBuffer(
7693 size_type src_offset,
7694 size_type dst_offset,
7696 const vector<Event>* events = NULL,
7697 Event* event = NULL)
const
7700 cl_int err = detail::errHandler(
7701 ::clEnqueueCopyBuffer(
7702 object_, src(), dst(), src_offset, dst_offset, size,
7703 (events != NULL) ? (cl_uint) events->size() : 0,
7704 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7705 (event != NULL) ? &tmp : NULL),
7706 __ENQEUE_COPY_BUFFER_ERR);
7708 if (event != NULL && err == CL_SUCCESS)
7713 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
7714 cl_int enqueueReadBufferRect(
7715 const Buffer& buffer,
7717 const array<size_type, 3>& buffer_offset,
7718 const array<size_type, 3>& host_offset,
7719 const array<size_type, 3>& region,
7720 size_type buffer_row_pitch,
7721 size_type buffer_slice_pitch,
7722 size_type host_row_pitch,
7723 size_type host_slice_pitch,
7725 const vector<Event>* events = NULL,
7726 Event* event = NULL)
const
7729 cl_int err = detail::errHandler(
7730 ::clEnqueueReadBufferRect(
7734 buffer_offset.data(),
7742 (events != NULL) ? (cl_uint) events->size() : 0,
7743 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7744 (event != NULL) ? &tmp : NULL),
7745 __ENQUEUE_READ_BUFFER_RECT_ERR);
7747 if (event != NULL && err == CL_SUCCESS)
7753 cl_int enqueueWriteBufferRect(
7754 const Buffer& buffer,
7756 const array<size_type, 3>& buffer_offset,
7757 const array<size_type, 3>& host_offset,
7758 const array<size_type, 3>& region,
7759 size_type buffer_row_pitch,
7760 size_type buffer_slice_pitch,
7761 size_type host_row_pitch,
7762 size_type host_slice_pitch,
7764 const vector<Event>* events = NULL,
7765 Event* event = NULL)
const
7768 cl_int err = detail::errHandler(
7769 ::clEnqueueWriteBufferRect(
7773 buffer_offset.data(),
7781 (events != NULL) ? (cl_uint) events->size() : 0,
7782 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7783 (event != NULL) ? &tmp : NULL),
7784 __ENQUEUE_WRITE_BUFFER_RECT_ERR);
7786 if (event != NULL && err == CL_SUCCESS)
7792 cl_int enqueueCopyBufferRect(
7795 const array<size_type, 3>& src_origin,
7796 const array<size_type, 3>& dst_origin,
7797 const array<size_type, 3>& region,
7798 size_type src_row_pitch,
7799 size_type src_slice_pitch,
7800 size_type dst_row_pitch,
7801 size_type dst_slice_pitch,
7802 const vector<Event>* events = NULL,
7803 Event* event = NULL)
const
7806 cl_int err = detail::errHandler(
7807 ::clEnqueueCopyBufferRect(
7818 (events != NULL) ? (cl_uint) events->size() : 0,
7819 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7820 (event != NULL) ? &tmp : NULL),
7821 __ENQEUE_COPY_BUFFER_RECT_ERR);
7823 if (event != NULL && err == CL_SUCCESS)
7829 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
7841 template<
typename PatternType>
7844 PatternType pattern,
7847 const vector<Event>* events = NULL,
7848 Event* event = NULL)
const
7851 cl_int err = detail::errHandler(
7852 ::clEnqueueFillBuffer(
7855 static_cast<void*
>(&pattern),
7856 sizeof(PatternType),
7859 (events != NULL) ? (cl_uint) events->size() : 0,
7860 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7861 (event != NULL) ? &tmp : NULL),
7862 __ENQUEUE_FILL_BUFFER_ERR);
7864 if (event != NULL && err == CL_SUCCESS)
7871 cl_int enqueueReadImage(
7874 const array<size_type, 3>& origin,
7875 const array<size_type, 3>& region,
7876 size_type row_pitch,
7877 size_type slice_pitch,
7879 const vector<Event>* events = NULL,
7880 Event* event = NULL)
const
7883 cl_int err = detail::errHandler(
7884 ::clEnqueueReadImage(
7893 (events != NULL) ? (cl_uint) events->size() : 0,
7894 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7895 (event != NULL) ? &tmp : NULL),
7896 __ENQUEUE_READ_IMAGE_ERR);
7898 if (event != NULL && err == CL_SUCCESS)
7904 cl_int enqueueWriteImage(
7907 const array<size_type, 3>& origin,
7908 const array<size_type, 3>& region,
7909 size_type row_pitch,
7910 size_type slice_pitch,
7912 const vector<Event>* events = NULL,
7913 Event* event = NULL)
const
7916 cl_int err = detail::errHandler(
7917 ::clEnqueueWriteImage(
7926 (events != NULL) ? (cl_uint) events->size() : 0,
7927 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7928 (event != NULL) ? &tmp : NULL),
7929 __ENQUEUE_WRITE_IMAGE_ERR);
7931 if (event != NULL && err == CL_SUCCESS)
7937 cl_int enqueueCopyImage(
7940 const array<size_type, 3>& src_origin,
7941 const array<size_type, 3>& dst_origin,
7942 const array<size_type, 3>& region,
7943 const vector<Event>* events = NULL,
7944 Event* event = NULL)
const
7947 cl_int err = detail::errHandler(
7948 ::clEnqueueCopyImage(
7955 (events != NULL) ? (cl_uint) events->size() : 0,
7956 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7957 (event != NULL) ? &tmp : NULL),
7958 __ENQUEUE_COPY_IMAGE_ERR);
7960 if (event != NULL && err == CL_SUCCESS)
7966 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
7976 cl_float4 fillColor,
7977 const array<size_type, 3>& origin,
7978 const array<size_type, 3>& region,
7979 const vector<Event>* events = NULL,
7980 Event* event = NULL)
const
7983 cl_int err = detail::errHandler(
7984 ::clEnqueueFillImage(
7987 static_cast<void*
>(&fillColor),
7990 (events != NULL) ? (cl_uint) events->size() : 0,
7991 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7992 (event != NULL) ? &tmp : NULL),
7993 __ENQUEUE_FILL_IMAGE_ERR);
7995 if (event != NULL && err == CL_SUCCESS)
8011 const array<size_type, 3>& origin,
8012 const array<size_type, 3>& region,
8013 const vector<Event>* events = NULL,
8014 Event* event = NULL)
const
8017 cl_int err = detail::errHandler(
8018 ::clEnqueueFillImage(
8021 static_cast<void*
>(&fillColor),
8024 (events != NULL) ? (cl_uint) events->size() : 0,
8025 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8026 (event != NULL) ? &tmp : NULL),
8027 __ENQUEUE_FILL_IMAGE_ERR);
8029 if (event != NULL && err == CL_SUCCESS)
8045 const array<size_type, 3>& origin,
8046 const array<size_type, 3>& region,
8047 const vector<Event>* events = NULL,
8048 Event* event = NULL)
const
8051 cl_int err = detail::errHandler(
8052 ::clEnqueueFillImage(
8055 static_cast<void*
>(&fillColor),
8058 (events != NULL) ? (cl_uint) events->size() : 0,
8059 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8060 (event != NULL) ? &tmp : NULL),
8061 __ENQUEUE_FILL_IMAGE_ERR);
8063 if (event != NULL && err == CL_SUCCESS)
8070 cl_int enqueueCopyImageToBuffer(
8073 const array<size_type, 3>& src_origin,
8074 const array<size_type, 3>& region,
8075 size_type dst_offset,
8076 const vector<Event>* events = NULL,
8077 Event* event = NULL)
const
8080 cl_int err = detail::errHandler(
8081 ::clEnqueueCopyImageToBuffer(
8088 (events != NULL) ? (cl_uint) events->size() : 0,
8089 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8090 (event != NULL) ? &tmp : NULL),
8091 __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR);
8093 if (event != NULL && err == CL_SUCCESS)
8099 cl_int enqueueCopyBufferToImage(
8102 size_type src_offset,
8103 const array<size_type, 3>& dst_origin,
8104 const array<size_type, 3>& region,
8105 const vector<Event>* events = NULL,
8106 Event* event = NULL)
const
8109 cl_int err = detail::errHandler(
8110 ::clEnqueueCopyBufferToImage(
8117 (events != NULL) ? (cl_uint) events->size() : 0,
8118 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8119 (event != NULL) ? &tmp : NULL),
8120 __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR);
8122 if (event != NULL && err == CL_SUCCESS)
8128 void* enqueueMapBuffer(
8129 const Buffer& buffer,
8134 const vector<Event>* events = NULL,
8135 Event* event = NULL,
8136 cl_int* err = NULL)
const
8140 void * result = ::clEnqueueMapBuffer(
8141 object_, buffer(), blocking, flags, offset, size,
8142 (events != NULL) ? (cl_uint) events->size() : 0,
8143 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8144 (event != NULL) ? &tmp : NULL,
8147 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
8151 if (event != NULL && error == CL_SUCCESS)
8157 void* enqueueMapImage(
8158 const Image& buffer,
8161 const array<size_type, 3>& origin,
8162 const array<size_type, 3>& region,
8163 size_type * row_pitch,
8164 size_type * slice_pitch,
8165 const vector<Event>* events = NULL,
8166 Event* event = NULL,
8167 cl_int* err = NULL)
const
8171 void * result = ::clEnqueueMapImage(
8172 object_, buffer(), blocking, flags,
8175 row_pitch, slice_pitch,
8176 (events != NULL) ? (cl_uint) events->size() : 0,
8177 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8178 (event != NULL) ? &tmp : NULL,
8181 detail::errHandler(error, __ENQUEUE_MAP_IMAGE_ERR);
8185 if (event != NULL && error == CL_SUCCESS)
8190 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
8195 template<
typename T>
8201 const vector<Event>* events = NULL,
8202 Event* event = NULL)
const
8205 cl_int err = detail::errHandler(::clEnqueueSVMMap(
8206 object_, blocking, flags,
static_cast<void*
>(ptr), size,
8207 (events != NULL) ? (cl_uint)events->size() : 0,
8208 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8209 (event != NULL) ? &tmp : NULL),
8210 __ENQUEUE_MAP_BUFFER_ERR);
8212 if (event != NULL && err == CL_SUCCESS)
8223 template<
typename T,
class D>
8225 cl::pointer<T, D> &ptr,
8229 const vector<Event>* events = NULL,
8230 Event* event = NULL)
const
8233 cl_int err = detail::errHandler(::clEnqueueSVMMap(
8234 object_, blocking, flags,
static_cast<void*
>(ptr.get()), size,
8235 (events != NULL) ? (cl_uint)events->size() : 0,
8236 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8237 (event != NULL) ? &tmp : NULL),
8238 __ENQUEUE_MAP_BUFFER_ERR);
8240 if (event != NULL && err == CL_SUCCESS)
8250 template<
typename T,
class Alloc>
8252 cl::vector<T, Alloc> &container,
8255 const vector<Event>* events = NULL,
8256 Event* event = NULL)
const
8259 cl_int err = detail::errHandler(::clEnqueueSVMMap(
8260 object_, blocking, flags,
static_cast<void*
>(container.data()), container.size()*
sizeof(T),
8261 (events != NULL) ? (cl_uint)events->size() : 0,
8262 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8263 (event != NULL) ? &tmp : NULL),
8264 __ENQUEUE_MAP_BUFFER_ERR);
8266 if (event != NULL && err == CL_SUCCESS)
8273 cl_int enqueueUnmapMemObject(
8276 const vector<Event>* events = NULL,
8277 Event* event = NULL)
const
8280 cl_int err = detail::errHandler(
8281 ::clEnqueueUnmapMemObject(
8282 object_, memory(), mapped_ptr,
8283 (events != NULL) ? (cl_uint) events->size() : 0,
8284 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8285 (event != NULL) ? &tmp : NULL),
8286 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8288 if (event != NULL && err == CL_SUCCESS)
8295 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
8300 template<
typename T>
8303 const vector<Event>* events = NULL,
8304 Event* event = NULL)
const
8307 cl_int err = detail::errHandler(
8308 ::clEnqueueSVMUnmap(
8309 object_,
static_cast<void*
>(ptr),
8310 (events != NULL) ? (cl_uint)events->size() : 0,
8311 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8312 (event != NULL) ? &tmp : NULL),
8313 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8315 if (event != NULL && err == CL_SUCCESS)
8325 template<
typename T,
class D>
8327 cl::pointer<T, D> &ptr,
8328 const vector<Event>* events = NULL,
8329 Event* event = NULL)
const
8332 cl_int err = detail::errHandler(
8333 ::clEnqueueSVMUnmap(
8334 object_,
static_cast<void*
>(ptr.get()),
8335 (events != NULL) ? (cl_uint)events->size() : 0,
8336 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8337 (event != NULL) ? &tmp : NULL),
8338 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8340 if (event != NULL && err == CL_SUCCESS)
8350 template<
typename T,
class Alloc>
8352 cl::vector<T, Alloc> &container,
8353 const vector<Event>* events = NULL,
8354 Event* event = NULL)
const
8357 cl_int err = detail::errHandler(
8358 ::clEnqueueSVMUnmap(
8359 object_,
static_cast<void*
>(container.data()),
8360 (events != NULL) ? (cl_uint)events->size() : 0,
8361 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8362 (event != NULL) ? &tmp : NULL),
8363 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8365 if (event != NULL && err == CL_SUCCESS)
8372 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
8385 const vector<Event> *events = 0,
8386 Event *event = 0)
const
8389 cl_int err = detail::errHandler(
8390 ::clEnqueueMarkerWithWaitList(
8392 (events != NULL) ? (cl_uint) events->size() : 0,
8393 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8394 (event != NULL) ? &tmp : NULL),
8395 __ENQUEUE_MARKER_WAIT_LIST_ERR);
8397 if (event != NULL && err == CL_SUCCESS)
8415 const vector<Event> *events = 0,
8416 Event *event = 0)
const
8419 cl_int err = detail::errHandler(
8420 ::clEnqueueBarrierWithWaitList(
8422 (events != NULL) ? (cl_uint) events->size() : 0,
8423 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8424 (event != NULL) ? &tmp : NULL),
8425 __ENQUEUE_BARRIER_WAIT_LIST_ERR);
8427 if (event != NULL && err == CL_SUCCESS)
8438 const vector<Memory> &memObjects,
8439 cl_mem_migration_flags flags,
8440 const vector<Event>* events = NULL,
8446 vector<cl_mem> localMemObjects(memObjects.size());
8448 for(
int i = 0; i < (int)memObjects.size(); ++i ) {
8449 localMemObjects[i] = memObjects[i]();
8452 cl_int err = detail::errHandler(
8453 ::clEnqueueMigrateMemObjects(
8455 (cl_uint)memObjects.size(),
8456 localMemObjects.data(),
8458 (events != NULL) ? (cl_uint) events->size() : 0,
8459 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8460 (event != NULL) ? &tmp : NULL),
8461 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8463 if (event != NULL && err == CL_SUCCESS)
8471 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
8477 template<
typename T>
8479 const cl::vector<T*> &svmRawPointers,
8480 const cl::vector<size_type> &sizes,
8481 cl_mem_migration_flags flags = 0,
8482 const vector<Event>* events = NULL,
8483 Event* event = NULL)
const
8486 cl_int err = detail::errHandler(::clEnqueueSVMMigrateMem(
8488 svmRawPointers.size(),
static_cast<void**
>(svmRawPointers.data()),
8491 (events != NULL) ? (cl_uint)events->size() : 0,
8492 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8493 (event != NULL) ? &tmp : NULL),
8494 __ENQUEUE_MIGRATE_SVM_ERR);
8496 if (event != NULL && err == CL_SUCCESS)
8506 template<
typename T>
8508 const cl::vector<T*> &svmRawPointers,
8509 cl_mem_migration_flags flags = 0,
8510 const vector<Event>* events = NULL,
8511 Event* event = NULL)
const
8513 return enqueueMigrateSVM(svmRawPointers, cl::vector<size_type>(svmRawPointers.size()), flags, events, event);
8522 template<
typename T,
class D>
8524 const cl::vector<cl::pointer<T, D>> &svmPointers,
8525 const cl::vector<size_type> &sizes,
8526 cl_mem_migration_flags flags = 0,
8527 const vector<Event>* events = NULL,
8528 Event* event = NULL)
const
8530 cl::vector<void*> svmRawPointers;
8531 svmRawPointers.reserve(svmPointers.size());
8532 for (
auto p : svmPointers) {
8533 svmRawPointers.push_back(
static_cast<void*
>(p.get()));
8544 template<
typename T,
class D>
8546 const cl::vector<cl::pointer<T, D>> &svmPointers,
8547 cl_mem_migration_flags flags = 0,
8548 const vector<Event>* events = NULL,
8549 Event* event = NULL)
const
8551 return enqueueMigrateSVM(svmPointers, cl::vector<size_type>(svmPointers.size()), flags, events, event);
8559 template<
typename T,
class Alloc>
8561 const cl::vector<cl::vector<T, Alloc>> &svmContainers,
8562 const cl::vector<size_type> &sizes,
8563 cl_mem_migration_flags flags = 0,
8564 const vector<Event>* events = NULL,
8565 Event* event = NULL)
const
8567 cl::vector<void*> svmRawPointers;
8568 svmRawPointers.reserve(svmContainers.size());
8569 for (
auto p : svmContainers) {
8570 svmRawPointers.push_back(
static_cast<void*
>(p.data()));
8580 template<
typename T,
class Alloc>
8582 const cl::vector<cl::vector<T, Alloc>> &svmContainers,
8583 cl_mem_migration_flags flags = 0,
8584 const vector<Event>* events = NULL,
8585 Event* event = NULL)
const
8587 return enqueueMigrateSVM(svmContainers, cl::vector<size_type>(svmContainers.size()), flags, events, event);
8592 cl_int enqueueNDRangeKernel(
8596 const NDRange& local = NullRange,
8597 const vector<Event>* events = NULL,
8598 Event* event = NULL)
const
8601 cl_int err = detail::errHandler(
8602 ::clEnqueueNDRangeKernel(
8603 object_, kernel(), (cl_uint) global.
dimensions(),
8604 offset.
dimensions() != 0 ? (
const size_type*) offset : NULL,
8605 (
const size_type*) global,
8606 local.dimensions() != 0 ? (
const size_type*) local : NULL,
8607 (events != NULL) ? (cl_uint) events->size() : 0,
8608 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8609 (event != NULL) ? &tmp : NULL),
8610 __ENQUEUE_NDRANGE_KERNEL_ERR);
8612 if (event != NULL && err == CL_SUCCESS)
8618 #if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
8619 CL_API_PREFIX__VERSION_1_2_DEPRECATED cl_int enqueueTask(
8620 const Kernel& kernel,
8621 const vector<Event>* events = NULL,
8622 Event* event = NULL)
const CL_API_SUFFIX__VERSION_1_2_DEPRECATED
8625 cl_int err = detail::errHandler(
8628 (events != NULL) ? (cl_uint) events->size() : 0,
8629 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8630 (event != NULL) ? &tmp : NULL),
8631 __ENQUEUE_TASK_ERR);
8633 if (event != NULL && err == CL_SUCCESS)
8640 cl_int enqueueNativeKernel(
8641 void (CL_CALLBACK *userFptr)(
void *),
8642 std::pair<void*, size_type> args,
8643 const vector<Memory>* mem_objects = NULL,
8644 const vector<const void*>* mem_locs = NULL,
8645 const vector<Event>* events = NULL,
8646 Event* event = NULL)
const
8648 size_type elements = 0;
8649 if (mem_objects != NULL) {
8650 elements = mem_objects->size();
8652 vector<cl_mem> mems(elements);
8653 for (
unsigned int i = 0; i < elements; i++) {
8654 mems[i] = ((*mem_objects)[i])();
8658 cl_int err = detail::errHandler(
8659 ::clEnqueueNativeKernel(
8660 object_, userFptr, args.first, args.second,
8661 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8663 (mem_locs != NULL && mem_locs->size() > 0) ? (
const void **) &mem_locs->front() : NULL,
8664 (events != NULL) ? (cl_uint) events->size() : 0,
8665 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8666 (event != NULL) ? &tmp : NULL),
8667 __ENQUEUE_NATIVE_KERNEL);
8669 if (event != NULL && err == CL_SUCCESS)
8678 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
8679 CL_API_PREFIX__VERSION_1_1_DEPRECATED
8683 cl_int err = detail::errHandler(
8686 (event != NULL) ? &tmp : NULL),
8687 __ENQUEUE_MARKER_ERR);
8689 if (event != NULL && err == CL_SUCCESS)
8695 CL_API_PREFIX__VERSION_1_1_DEPRECATED
8696 cl_int enqueueWaitForEvents(
const vector<Event>& events)
const CL_API_SUFFIX__VERSION_1_1_DEPRECATED
8698 return detail::errHandler(
8699 ::clEnqueueWaitForEvents(
8701 (cl_uint) events.size(),
8702 events.size() > 0 ? (
const cl_event*) &events.front() : NULL),
8703 __ENQUEUE_WAIT_FOR_EVENTS_ERR);
8707 cl_int enqueueAcquireGLObjects(
8708 const vector<Memory>* mem_objects = NULL,
8709 const vector<Event>* events = NULL,
8710 Event* event = NULL)
const
8713 cl_int err = detail::errHandler(
8714 ::clEnqueueAcquireGLObjects(
8716 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8717 (mem_objects != NULL && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front(): NULL,
8718 (events != NULL) ? (cl_uint) events->size() : 0,
8719 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8720 (event != NULL) ? &tmp : NULL),
8721 __ENQUEUE_ACQUIRE_GL_ERR);
8723 if (event != NULL && err == CL_SUCCESS)
8729 cl_int enqueueReleaseGLObjects(
8730 const vector<Memory>* mem_objects = NULL,
8731 const vector<Event>* events = NULL,
8732 Event* event = NULL)
const
8735 cl_int err = detail::errHandler(
8736 ::clEnqueueReleaseGLObjects(
8738 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8739 (mem_objects != NULL && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front(): NULL,
8740 (events != NULL) ? (cl_uint) events->size() : 0,
8741 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8742 (event != NULL) ? &tmp : NULL),
8743 __ENQUEUE_RELEASE_GL_ERR);
8745 if (event != NULL && err == CL_SUCCESS)
8751 #if defined (CL_HPP_USE_DX_INTEROP)
8752 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueAcquireD3D10ObjectsKHR)(
8753 cl_command_queue command_queue, cl_uint num_objects,
8754 const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
8755 const cl_event* event_wait_list, cl_event* event);
8756 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueReleaseD3D10ObjectsKHR)(
8757 cl_command_queue command_queue, cl_uint num_objects,
8758 const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
8759 const cl_event* event_wait_list, cl_event* event);
8761 cl_int enqueueAcquireD3D10Objects(
8762 const vector<Memory>* mem_objects = NULL,
8763 const vector<Event>* events = NULL,
8764 Event* event = NULL)
const
8766 static PFN_clEnqueueAcquireD3D10ObjectsKHR pfn_clEnqueueAcquireD3D10ObjectsKHR = NULL;
8767 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
8768 cl_context context = getInfo<CL_QUEUE_CONTEXT>();
8769 cl::Device device(getInfo<CL_QUEUE_DEVICE>());
8770 cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>();
8771 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueAcquireD3D10ObjectsKHR);
8773 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
8774 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueAcquireD3D10ObjectsKHR);
8778 cl_int err = detail::errHandler(
8779 pfn_clEnqueueAcquireD3D10ObjectsKHR(
8781 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8782 (mem_objects != NULL && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front(): NULL,
8783 (events != NULL) ? (cl_uint) events->size() : 0,
8784 (events != NULL) ? (cl_event*) &events->front() : NULL,
8785 (event != NULL) ? &tmp : NULL),
8786 __ENQUEUE_ACQUIRE_GL_ERR);
8788 if (event != NULL && err == CL_SUCCESS)
8794 cl_int enqueueReleaseD3D10Objects(
8795 const vector<Memory>* mem_objects = NULL,
8796 const vector<Event>* events = NULL,
8797 Event* event = NULL)
const
8799 static PFN_clEnqueueReleaseD3D10ObjectsKHR pfn_clEnqueueReleaseD3D10ObjectsKHR = NULL;
8800 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
8801 cl_context context = getInfo<CL_QUEUE_CONTEXT>();
8802 cl::Device device(getInfo<CL_QUEUE_DEVICE>());
8803 cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>();
8804 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueReleaseD3D10ObjectsKHR);
8806 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
8807 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueReleaseD3D10ObjectsKHR);
8811 cl_int err = detail::errHandler(
8812 pfn_clEnqueueReleaseD3D10ObjectsKHR(
8814 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8815 (mem_objects != NULL && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front(): NULL,
8816 (events != NULL) ? (cl_uint) events->size() : 0,
8817 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8818 (event != NULL) ? &tmp : NULL),
8819 __ENQUEUE_RELEASE_GL_ERR);
8821 if (event != NULL && err == CL_SUCCESS)
8831 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
8832 CL_API_PREFIX__VERSION_1_1_DEPRECATED
8835 return detail::errHandler(
8836 ::clEnqueueBarrier(object_),
8837 __ENQUEUE_BARRIER_ERR);
8841 cl_int flush()
const
8843 return detail::errHandler(::clFlush(object_), __FLUSH_ERR);
8846 cl_int finish()
const
8848 return detail::errHandler(::clFinish(object_), __FINISH_ERR);
8852 CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag CommandQueue::default_initialized_;
8853 CL_HPP_DEFINE_STATIC_MEMBER_ CommandQueue CommandQueue::default_;
8854 CL_HPP_DEFINE_STATIC_MEMBER_ cl_int CommandQueue::default_error_ = CL_SUCCESS;
8857 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
8858 enum class DeviceQueueProperties : cl_command_queue_properties
8861 Profiling = CL_QUEUE_PROFILING_ENABLE,
8864 inline DeviceQueueProperties operator|(DeviceQueueProperties lhs, DeviceQueueProperties rhs)
8866 return static_cast<DeviceQueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) |
static_cast<cl_command_queue_properties
>(rhs));
8890 cl_command_queue_properties mergedProperties =
8891 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
8893 cl_queue_properties queue_properties[] = {
8894 CL_QUEUE_PROPERTIES, mergedProperties, 0 };
8895 object_ = ::clCreateCommandQueueWithProperties(
8896 context(), device(), queue_properties, &error);
8898 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8910 DeviceQueueProperties properties = DeviceQueueProperties::None,
8915 cl_command_queue_properties mergedProperties =
8916 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
8917 cl_queue_properties queue_properties[] = {
8918 CL_QUEUE_PROPERTIES, mergedProperties, 0 };
8919 object_ = ::clCreateCommandQueueWithProperties(
8920 context(), device(), queue_properties, &error);
8922 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8935 DeviceQueueProperties properties = DeviceQueueProperties::None,
8940 cl_command_queue_properties mergedProperties =
8941 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
8942 cl_queue_properties queue_properties[] = {
8943 CL_QUEUE_PROPERTIES, mergedProperties,
8944 CL_QUEUE_SIZE, queueSize,
8946 object_ = ::clCreateCommandQueueWithProperties(
8947 context(), device(), queue_properties, &error);
8949 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8962 detail::Wrapper<cl_type>(commandQueue, retainObject) { }
8998 template <
typename T>
8999 cl_int getInfo(cl_command_queue_info name, T* param)
const
9001 return detail::errHandler(
9003 &::clGetCommandQueueInfo, object_, name, param),
9004 __GET_COMMAND_QUEUE_INFO_ERR);
9007 template <cl_command_queue_info name>
typename
9008 detail::param_traits<detail::cl_command_queue_info, name>::param_type
9009 getInfo(cl_int* err = NULL)
const
9011 typename detail::param_traits<
9012 detail::cl_command_queue_info, name>::param_type param;
9013 cl_int result = getInfo(name, ¶m);
9027 cl_int *err =
nullptr)
9033 cl_command_queue_properties properties =
9034 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
9035 cl_queue_properties queue_properties[] = {
9036 CL_QUEUE_PROPERTIES, properties,
9039 ::clCreateCommandQueueWithProperties(
9040 context(), device(), queue_properties, &error));
9042 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9057 const Context &context,
const Device &device, cl_int *err =
nullptr)
9061 cl_command_queue_properties properties =
9062 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
9063 cl_queue_properties queue_properties[] = {
9064 CL_QUEUE_PROPERTIES, properties,
9067 ::clCreateCommandQueueWithProperties(
9068 context(), device(), queue_properties, &error));
9070 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9085 const Context &context,
const Device &device, cl_uint queueSize, cl_int *err =
nullptr)
9089 cl_command_queue_properties properties =
9090 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
9091 cl_queue_properties queue_properties[] = {
9092 CL_QUEUE_PROPERTIES, properties,
9093 CL_QUEUE_SIZE, queueSize,
9096 ::clCreateCommandQueueWithProperties(
9097 context(), device(), queue_properties, &error));
9099 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9109 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
9119 error = clSetDefaultDeviceCommandQueue(context.get(), device.get(), default_queue.get());
9121 detail::errHandler(error, __SET_DEFAULT_DEVICE_COMMAND_QUEUE_ERR);
9125 return default_queue;
9133 return queue.getInfo<CL_QUEUE_DEVICE_DEFAULT>(err);
9153 template<
typename IteratorType >
9156 IteratorType startIterator,
9157 IteratorType endIterator,
9162 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9165 cl_mem_flags flags = 0;
9167 flags |= CL_MEM_READ_ONLY;
9170 flags |= CL_MEM_READ_WRITE;
9173 flags |= CL_MEM_USE_HOST_PTR;
9176 size_type size =
sizeof(DataType)*(endIterator - startIterator);
9179 object_ = ::clCreateBuffer(context(), flags, size,
const_cast<DataType*
>(&*startIterator), &error);
9181 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
9184 detail::errHandler(error, __CREATE_BUFFER_ERR);
9191 detail::errHandler(error, __CREATE_BUFFER_ERR);
9196 error =
cl::copy(queue, startIterator, endIterator, *
this);
9197 detail::errHandler(error, __CREATE_BUFFER_ERR);
9204 template<
typename IteratorType >
9207 IteratorType startIterator,
9208 IteratorType endIterator,
9213 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9216 cl_mem_flags flags = 0;
9218 flags |= CL_MEM_READ_ONLY;
9221 flags |= CL_MEM_READ_WRITE;
9224 flags |= CL_MEM_USE_HOST_PTR;
9227 size_type size =
sizeof(DataType)*(endIterator - startIterator);
9229 Context context = queue.getInfo<CL_QUEUE_CONTEXT>();
9232 object_ = ::clCreateBuffer(context(), flags, size,
const_cast<DataType*
>(&*startIterator), &error);
9235 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
9238 detail::errHandler(error, __CREATE_BUFFER_ERR);
9244 error =
cl::copy(queue, startIterator, endIterator, *
this);
9245 detail::errHandler(error, __CREATE_BUFFER_ERR);
9252 inline cl_int enqueueReadBuffer(
9258 const vector<Event>* events = NULL,
9259 Event* event = NULL)
9264 if (error != CL_SUCCESS) {
9268 return queue.enqueueReadBuffer(buffer, blocking, offset, size, ptr, events, event);
9271 inline cl_int enqueueWriteBuffer(
9272 const Buffer& buffer,
9277 const vector<Event>* events = NULL,
9278 Event* event = NULL)
9281 CommandQueue queue = CommandQueue::getDefault(&error);
9283 if (error != CL_SUCCESS) {
9287 return queue.enqueueWriteBuffer(buffer, blocking, offset, size, ptr, events, event);
9290 inline void* enqueueMapBuffer(
9291 const Buffer& buffer,
9296 const vector<Event>* events = NULL,
9297 Event* event = NULL,
9301 CommandQueue queue = CommandQueue::getDefault(&error);
9302 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9307 void * result = ::clEnqueueMapBuffer(
9308 queue(), buffer(), blocking, flags, offset, size,
9309 (events != NULL) ? (cl_uint) events->size() : 0,
9310 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
9314 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9322 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
9328 template<
typename T>
9334 const vector<Event>* events,
9339 if (error != CL_SUCCESS) {
9340 return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9344 ptr, blocking, flags, size, events, event);
9352 template<
typename T,
class D>
9354 cl::pointer<T, D> &ptr,
9358 const vector<Event>* events = NULL,
9359 Event* event = NULL)
9363 if (error != CL_SUCCESS) {
9364 return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9368 ptr, blocking, flags, size, events, event);
9376 template<
typename T,
class Alloc>
9378 cl::vector<T, Alloc> &container,
9381 const vector<Event>* events = NULL,
9382 Event* event = NULL)
9386 if (error != CL_SUCCESS) {
9387 return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9391 container, blocking, flags, events, event);
9396 inline cl_int enqueueUnmapMemObject(
9397 const Memory& memory,
9399 const vector<Event>* events = NULL,
9400 Event* event = NULL)
9403 CommandQueue queue = CommandQueue::getDefault(&error);
9404 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9405 if (error != CL_SUCCESS) {
9410 cl_int err = detail::errHandler(
9411 ::clEnqueueUnmapMemObject(
9412 queue(), memory(), mapped_ptr,
9413 (events != NULL) ? (cl_uint)events->size() : 0,
9414 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
9415 (event != NULL) ? &tmp : NULL),
9416 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9418 if (event != NULL && err == CL_SUCCESS)
9424 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
9430 template<
typename T>
9433 const vector<Event>* events = NULL,
9434 Event* event = NULL)
9438 if (error != CL_SUCCESS) {
9439 return detail::errHandler(error, __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9443 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9452 template<
typename T,
class D>
9454 cl::pointer<T, D> &ptr,
9455 const vector<Event>* events = NULL,
9456 Event* event = NULL)
9460 if (error != CL_SUCCESS) {
9461 return detail::errHandler(error, __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9465 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9473 template<
typename T,
class Alloc>
9475 cl::vector<T, Alloc> &container,
9476 const vector<Event>* events = NULL,
9477 Event* event = NULL)
9481 if (error != CL_SUCCESS) {
9482 return detail::errHandler(error, __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9485 return detail::errHandler(queue.
enqueueUnmapSVM(container, events, event),
9486 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9491 inline cl_int enqueueCopyBuffer(
9494 size_type src_offset,
9495 size_type dst_offset,
9497 const vector<Event>* events = NULL,
9498 Event* event = NULL)
9501 CommandQueue queue = CommandQueue::getDefault(&error);
9503 if (error != CL_SUCCESS) {
9507 return queue.enqueueCopyBuffer(src, dst, src_offset, dst_offset, size, events, event);
9515 template<
typename IteratorType >
9516 inline cl_int
copy( IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer )
9520 if (error != CL_SUCCESS)
9523 return cl::copy(queue, startIterator, endIterator, buffer);
9531 template<
typename IteratorType >
9532 inline cl_int
copy(
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator )
9536 if (error != CL_SUCCESS)
9539 return cl::copy(queue, buffer, startIterator, endIterator);
9547 template<
typename IteratorType >
9550 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9553 size_type length = endIterator-startIterator;
9554 size_type byteLength = length*
sizeof(DataType);
9557 static_cast<DataType*
>(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_WRITE, 0, byteLength, 0, 0, &error));
9559 if( error != CL_SUCCESS ) {
9562 #if defined(_MSC_VER)
9566 stdext::checked_array_iterator<DataType*>(
9569 std::copy(startIterator, endIterator, pointer);
9572 error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
9574 if( error != CL_SUCCESS ) {
9586 template<
typename IteratorType >
9589 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9592 size_type length = endIterator-startIterator;
9593 size_type byteLength = length*
sizeof(DataType);
9596 static_cast<DataType*
>(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_READ, 0, byteLength, 0, 0, &error));
9598 if( error != CL_SUCCESS ) {
9601 std::copy(pointer, pointer + length, startIterator);
9603 error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
9605 if( error != CL_SUCCESS ) {
9613 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
9617 template<
typename T,
class Alloc>
9618 inline cl_int
mapSVM(cl::vector<T, Alloc> &container)
9620 return enqueueMapSVM(container, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE);
9626 template<
typename T,
class Alloc>
9627 inline cl_int
unmapSVM(cl::vector<T, Alloc> &container)
9634 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
9635 inline cl_int enqueueReadBufferRect(
9636 const Buffer& buffer,
9638 const array<size_type, 3>& buffer_offset,
9639 const array<size_type, 3>& host_offset,
9640 const array<size_type, 3>& region,
9641 size_type buffer_row_pitch,
9642 size_type buffer_slice_pitch,
9643 size_type host_row_pitch,
9644 size_type host_slice_pitch,
9646 const vector<Event>* events = NULL,
9647 Event* event = NULL)
9650 CommandQueue queue = CommandQueue::getDefault(&error);
9652 if (error != CL_SUCCESS) {
9656 return queue.enqueueReadBufferRect(
9671 inline cl_int enqueueWriteBufferRect(
9672 const Buffer& buffer,
9674 const array<size_type, 3>& buffer_offset,
9675 const array<size_type, 3>& host_offset,
9676 const array<size_type, 3>& region,
9677 size_type buffer_row_pitch,
9678 size_type buffer_slice_pitch,
9679 size_type host_row_pitch,
9680 size_type host_slice_pitch,
9682 const vector<Event>* events = NULL,
9683 Event* event = NULL)
9686 CommandQueue queue = CommandQueue::getDefault(&error);
9688 if (error != CL_SUCCESS) {
9692 return queue.enqueueWriteBufferRect(
9707 inline cl_int enqueueCopyBufferRect(
9710 const array<size_type, 3>& src_origin,
9711 const array<size_type, 3>& dst_origin,
9712 const array<size_type, 3>& region,
9713 size_type src_row_pitch,
9714 size_type src_slice_pitch,
9715 size_type dst_row_pitch,
9716 size_type dst_slice_pitch,
9717 const vector<Event>* events = NULL,
9718 Event* event = NULL)
9721 CommandQueue queue = CommandQueue::getDefault(&error);
9723 if (error != CL_SUCCESS) {
9727 return queue.enqueueCopyBufferRect(
9742 inline cl_int enqueueReadImage(
9745 const array<size_type, 3>& origin,
9746 const array<size_type, 3>& region,
9747 size_type row_pitch,
9748 size_type slice_pitch,
9750 const vector<Event>* events = NULL,
9751 Event* event = NULL)
9754 CommandQueue queue = CommandQueue::getDefault(&error);
9756 if (error != CL_SUCCESS) {
9760 return queue.enqueueReadImage(
9772 inline cl_int enqueueWriteImage(
9775 const array<size_type, 3>& origin,
9776 const array<size_type, 3>& region,
9777 size_type row_pitch,
9778 size_type slice_pitch,
9780 const vector<Event>* events = NULL,
9781 Event* event = NULL)
9784 CommandQueue queue = CommandQueue::getDefault(&error);
9786 if (error != CL_SUCCESS) {
9790 return queue.enqueueWriteImage(
9802 inline cl_int enqueueCopyImage(
9805 const array<size_type, 3>& src_origin,
9806 const array<size_type, 3>& dst_origin,
9807 const array<size_type, 3>& region,
9808 const vector<Event>* events = NULL,
9809 Event* event = NULL)
9812 CommandQueue queue = CommandQueue::getDefault(&error);
9814 if (error != CL_SUCCESS) {
9818 return queue.enqueueCopyImage(
9828 inline cl_int enqueueCopyImageToBuffer(
9831 const array<size_type, 3>& src_origin,
9832 const array<size_type, 3>& region,
9833 size_type dst_offset,
9834 const vector<Event>* events = NULL,
9835 Event* event = NULL)
9838 CommandQueue queue = CommandQueue::getDefault(&error);
9840 if (error != CL_SUCCESS) {
9844 return queue.enqueueCopyImageToBuffer(
9854 inline cl_int enqueueCopyBufferToImage(
9857 size_type src_offset,
9858 const array<size_type, 3>& dst_origin,
9859 const array<size_type, 3>& region,
9860 const vector<Event>* events = NULL,
9861 Event* event = NULL)
9864 CommandQueue queue = CommandQueue::getDefault(&error);
9866 if (error != CL_SUCCESS) {
9870 return queue.enqueueCopyBufferToImage(
9881 inline cl_int flush(
void)
9884 CommandQueue queue = CommandQueue::getDefault(&error);
9886 if (error != CL_SUCCESS) {
9890 return queue.flush();
9893 inline cl_int finish(
void)
9896 CommandQueue queue = CommandQueue::getDefault(&error);
9898 if (error != CL_SUCCESS) {
9903 return queue.finish();
9913 vector<Event> events_;
9915 template<
typename... Ts>
9920 queue_(CommandQueue::getDefault()),
9929 queue_(CommandQueue::getDefault()),
9938 queue_(CommandQueue::getDefault()),
9947 queue_(CommandQueue::getDefault()),
9952 events_.push_back(e);
9956 queue_(CommandQueue::getDefault()),
9961 events_.push_back(e);
9965 queue_(CommandQueue::getDefault()),
9970 events_.push_back(e);
9974 queue_(CommandQueue::getDefault()),
9984 queue_(CommandQueue::getDefault()),
9994 queue_(CommandQueue::getDefault()),
10005 offset_(NullRange),
10014 offset_(NullRange),
10032 offset_(NullRange),
10036 events_.push_back(e);
10041 offset_(NullRange),
10045 events_.push_back(e);
10054 events_.push_back(e);
10059 offset_(NullRange),
10069 offset_(NullRange),
10096 template<
typename... Ts>
10102 template<
int index,
typename T0,
typename... T1s>
10103 void setArgs(T0&& t0, T1s&&... t1s)
10105 kernel_.
setArg(index, t0);
10106 setArgs<index + 1, T1s...>(std::forward<T1s>(t1s)...);
10109 template<
int index,
typename T0>
10110 void setArgs(T0&& t0)
10112 kernel_.
setArg(index, t0);
10115 template<
int index>
10128 cl_int * err = NULL) :
10129 kernel_(program, name.c_str(), err)
10145 setArgs<0>(std::forward<Ts>(ts)...);
10147 args.queue_.enqueueNDRangeKernel(
10170 setArgs<0>(std::forward<Ts>(ts)...);
10172 error = args.queue_.enqueueNDRangeKernel(
10183 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
10184 cl_int setSVMPointers(
const vector<void*> &pointerList)
10189 template<
typename T0,
typename... T1s>
10190 cl_int setSVMPointers(
const T0 &t0, T1s &... ts)
10202 namespace compatibility {
10207 template<
typename... Ts>
10217 cl_int * err = NULL) :
10239 enqueueArgs, args...);
10247 #undef CL_HPP_ERR_STR_
10248 #if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS)
10249 #undef __GET_DEVICE_INFO_ERR
10250 #undef __GET_PLATFORM_INFO_ERR
10251 #undef __GET_DEVICE_IDS_ERR
10252 #undef __GET_PLATFORM_IDS_ERR
10253 #undef __GET_CONTEXT_INFO_ERR
10254 #undef __GET_EVENT_INFO_ERR
10255 #undef __GET_EVENT_PROFILE_INFO_ERR
10256 #undef __GET_MEM_OBJECT_INFO_ERR
10257 #undef __GET_IMAGE_INFO_ERR
10258 #undef __GET_SAMPLER_INFO_ERR
10259 #undef __GET_KERNEL_INFO_ERR
10260 #undef __GET_KERNEL_ARG_INFO_ERR
10261 #undef __GET_KERNEL_SUB_GROUP_INFO_ERR
10262 #undef __GET_KERNEL_WORK_GROUP_INFO_ERR
10263 #undef __GET_PROGRAM_INFO_ERR
10264 #undef __GET_PROGRAM_BUILD_INFO_ERR
10265 #undef __GET_COMMAND_QUEUE_INFO_ERR
10266 #undef __CREATE_CONTEXT_ERR
10267 #undef __CREATE_CONTEXT_FROM_TYPE_ERR
10268 #undef __GET_SUPPORTED_IMAGE_FORMATS_ERR
10269 #undef __CREATE_BUFFER_ERR
10271 #undef __CREATE_SUBBUFFER_ERR
10272 #undef __CREATE_GL_BUFFER_ERR
10273 #undef __CREATE_GL_RENDER_BUFFER_ERR
10274 #undef __GET_GL_OBJECT_INFO_ERR
10275 #undef __CREATE_IMAGE_ERR
10276 #undef __CREATE_GL_TEXTURE_ERR
10277 #undef __IMAGE_DIMENSION_ERR
10278 #undef __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR
10279 #undef __CREATE_USER_EVENT_ERR
10280 #undef __SET_USER_EVENT_STATUS_ERR
10281 #undef __SET_EVENT_CALLBACK_ERR
10282 #undef __WAIT_FOR_EVENTS_ERR
10283 #undef __CREATE_KERNEL_ERR
10284 #undef __SET_KERNEL_ARGS_ERR
10285 #undef __CREATE_PROGRAM_WITH_SOURCE_ERR
10286 #undef __CREATE_PROGRAM_WITH_IL_ERR
10287 #undef __CREATE_PROGRAM_WITH_BINARY_ERR
10288 #undef __CREATE_PROGRAM_WITH_IL_ERR
10289 #undef __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR
10290 #undef __BUILD_PROGRAM_ERR
10291 #undef __COMPILE_PROGRAM_ERR
10292 #undef __LINK_PROGRAM_ERR
10293 #undef __CREATE_KERNELS_IN_PROGRAM_ERR
10294 #undef __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR
10295 #undef __CREATE_SAMPLER_WITH_PROPERTIES_ERR
10296 #undef __SET_COMMAND_QUEUE_PROPERTY_ERR
10297 #undef __ENQUEUE_READ_BUFFER_ERR
10298 #undef __ENQUEUE_READ_BUFFER_RECT_ERR
10299 #undef __ENQUEUE_WRITE_BUFFER_ERR
10300 #undef __ENQUEUE_WRITE_BUFFER_RECT_ERR
10301 #undef __ENQEUE_COPY_BUFFER_ERR
10302 #undef __ENQEUE_COPY_BUFFER_RECT_ERR
10303 #undef __ENQUEUE_FILL_BUFFER_ERR
10304 #undef __ENQUEUE_READ_IMAGE_ERR
10305 #undef __ENQUEUE_WRITE_IMAGE_ERR
10306 #undef __ENQUEUE_COPY_IMAGE_ERR
10307 #undef __ENQUEUE_FILL_IMAGE_ERR
10308 #undef __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR
10309 #undef __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR
10310 #undef __ENQUEUE_MAP_BUFFER_ERR
10311 #undef __ENQUEUE_MAP_IMAGE_ERR
10312 #undef __ENQUEUE_UNMAP_MEM_OBJECT_ERR
10313 #undef __ENQUEUE_NDRANGE_KERNEL_ERR
10314 #undef __ENQUEUE_NATIVE_KERNEL
10315 #undef __ENQUEUE_MIGRATE_MEM_OBJECTS_ERR
10316 #undef __ENQUEUE_MIGRATE_SVM_ERR
10317 #undef __ENQUEUE_ACQUIRE_GL_ERR
10318 #undef __ENQUEUE_RELEASE_GL_ERR
10319 #undef __CREATE_PIPE_ERR
10320 #undef __GET_PIPE_INFO_ERR
10321 #undef __RETAIN_ERR
10322 #undef __RELEASE_ERR
10324 #undef __FINISH_ERR
10325 #undef __VECTOR_CAPACITY_ERR
10326 #undef __CREATE_SUB_DEVICES_ERR
10327 #undef __CREATE_SUB_DEVICES_ERR
10328 #undef __ENQUEUE_MARKER_ERR
10329 #undef __ENQUEUE_WAIT_FOR_EVENTS_ERR
10330 #undef __ENQUEUE_BARRIER_ERR
10331 #undef __UNLOAD_COMPILER_ERR
10332 #undef __CREATE_GL_TEXTURE_2D_ERR
10333 #undef __CREATE_GL_TEXTURE_3D_ERR
10334 #undef __CREATE_IMAGE2D_ERR
10335 #undef __CREATE_IMAGE3D_ERR
10336 #undef __CREATE_COMMAND_QUEUE_ERR
10337 #undef __ENQUEUE_TASK_ERR
10338 #undef __CREATE_SAMPLER_ERR
10339 #undef __ENQUEUE_MARKER_WAIT_LIST_ERR
10340 #undef __ENQUEUE_BARRIER_WAIT_LIST_ERR
10341 #undef __CLONE_KERNEL_ERR
10342 #undef __GET_HOST_TIMER_ERR
10343 #undef __GET_DEVICE_AND_HOST_TIMER_ERR
10348 #undef CL_HPP_INIT_CL_EXT_FCN_PTR_
10349 #undef CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_
10351 #if defined(CL_HPP_USE_CL_DEVICE_FISSION)
10352 #undef CL_HPP_PARAM_NAME_DEVICE_FISSION_
10355 #undef CL_HPP_NOEXCEPT_
10356 #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)