395#if !defined(CL_HPP_USE_DX_INTEROP) && defined(USE_DX_INTEROP)
396# pragma message("opencl.hpp: USE_DX_INTEROP is deprecated. Define CL_HPP_USE_DX_INTEROP instead")
397# define CL_HPP_USE_DX_INTEROP
399#if !defined(CL_HPP_USE_CL_DEVICE_FISSION) && defined(USE_CL_DEVICE_FISSION)
400# pragma message("opencl.hpp: USE_CL_DEVICE_FISSION is deprecated. Define CL_HPP_USE_CL_DEVICE_FISSION instead")
401# define CL_HPP_USE_CL_DEVICE_FISSION
403#if !defined(CL_HPP_ENABLE_EXCEPTIONS) && defined(__CL_ENABLE_EXCEPTIONS)
404# pragma message("opencl.hpp: __CL_ENABLE_EXCEPTIONS is deprecated. Define CL_HPP_ENABLE_EXCEPTIONS instead")
405# define CL_HPP_ENABLE_EXCEPTIONS
407#if !defined(CL_HPP_NO_STD_VECTOR) && defined(__NO_STD_VECTOR)
408# pragma message("opencl.hpp: __NO_STD_VECTOR is deprecated. Define CL_HPP_NO_STD_VECTOR instead")
409# define CL_HPP_NO_STD_VECTOR
411#if !defined(CL_HPP_NO_STD_STRING) && defined(__NO_STD_STRING)
412# pragma message("opencl.hpp: __NO_STD_STRING is deprecated. Define CL_HPP_NO_STD_STRING instead")
413# define CL_HPP_NO_STD_STRING
415#if defined(VECTOR_CLASS)
416# pragma message("opencl.hpp: VECTOR_CLASS is deprecated. Alias cl::vector instead")
418#if defined(STRING_CLASS)
419# pragma message("opencl.hpp: STRING_CLASS is deprecated. Alias cl::string instead.")
421#if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS) && defined(__CL_USER_OVERRIDE_ERROR_STRINGS)
422# pragma message("opencl.hpp: __CL_USER_OVERRIDE_ERROR_STRINGS is deprecated. Define CL_HPP_USER_OVERRIDE_ERROR_STRINGS instead")
423# define CL_HPP_USER_OVERRIDE_ERROR_STRINGS
428#if defined(__USE_DEV_VECTOR)
429# pragma message("opencl.hpp: __USE_DEV_VECTOR is no longer supported. Expect compilation errors")
431#if defined(__USE_DEV_STRING)
432# pragma message("opencl.hpp: __USE_DEV_STRING is no longer supported. Expect compilation errors")
436#if !defined(CL_HPP_TARGET_OPENCL_VERSION)
437# pragma message("opencl.hpp: CL_HPP_TARGET_OPENCL_VERSION is not defined. It will default to 300 (OpenCL 3.0)")
438# define CL_HPP_TARGET_OPENCL_VERSION 300
440#if CL_HPP_TARGET_OPENCL_VERSION != 100 && \
441 CL_HPP_TARGET_OPENCL_VERSION != 110 && \
442 CL_HPP_TARGET_OPENCL_VERSION != 120 && \
443 CL_HPP_TARGET_OPENCL_VERSION != 200 && \
444 CL_HPP_TARGET_OPENCL_VERSION != 210 && \
445 CL_HPP_TARGET_OPENCL_VERSION != 220 && \
446 CL_HPP_TARGET_OPENCL_VERSION != 300
447# pragma message("opencl.hpp: CL_HPP_TARGET_OPENCL_VERSION is not a valid value (100, 110, 120, 200, 210, 220 or 300). It will be set to 300 (OpenCL 3.0).")
448# undef CL_HPP_TARGET_OPENCL_VERSION
449# define CL_HPP_TARGET_OPENCL_VERSION 300
453#if defined(CL_TARGET_OPENCL_VERSION)
456#if CL_TARGET_OPENCL_VERSION < CL_HPP_TARGET_OPENCL_VERSION
457# pragma message("CL_TARGET_OPENCL_VERSION is already defined as is lower than CL_HPP_TARGET_OPENCL_VERSION")
460# define CL_TARGET_OPENCL_VERSION CL_HPP_TARGET_OPENCL_VERSION
463#if !defined(CL_HPP_MINIMUM_OPENCL_VERSION)
464# define CL_HPP_MINIMUM_OPENCL_VERSION 200
466#if CL_HPP_MINIMUM_OPENCL_VERSION != 100 && \
467 CL_HPP_MINIMUM_OPENCL_VERSION != 110 && \
468 CL_HPP_MINIMUM_OPENCL_VERSION != 120 && \
469 CL_HPP_MINIMUM_OPENCL_VERSION != 200 && \
470 CL_HPP_MINIMUM_OPENCL_VERSION != 210 && \
471 CL_HPP_MINIMUM_OPENCL_VERSION != 220 && \
472 CL_HPP_MINIMUM_OPENCL_VERSION != 300
473# pragma message("opencl.hpp: CL_HPP_MINIMUM_OPENCL_VERSION is not a valid value (100, 110, 120, 200, 210, 220 or 300). It will be set to 100")
474# undef CL_HPP_MINIMUM_OPENCL_VERSION
475# define CL_HPP_MINIMUM_OPENCL_VERSION 100
477#if CL_HPP_MINIMUM_OPENCL_VERSION > CL_HPP_TARGET_OPENCL_VERSION
478# error "CL_HPP_MINIMUM_OPENCL_VERSION must not be greater than CL_HPP_TARGET_OPENCL_VERSION"
481#if CL_HPP_MINIMUM_OPENCL_VERSION <= 100 && !defined(CL_USE_DEPRECATED_OPENCL_1_0_APIS)
482# define CL_USE_DEPRECATED_OPENCL_1_0_APIS
484#if CL_HPP_MINIMUM_OPENCL_VERSION <= 110 && !defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
485# define CL_USE_DEPRECATED_OPENCL_1_1_APIS
487#if CL_HPP_MINIMUM_OPENCL_VERSION <= 120 && !defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
488# define CL_USE_DEPRECATED_OPENCL_1_2_APIS
490#if CL_HPP_MINIMUM_OPENCL_VERSION <= 200 && !defined(CL_USE_DEPRECATED_OPENCL_2_0_APIS)
491# define CL_USE_DEPRECATED_OPENCL_2_0_APIS
493#if CL_HPP_MINIMUM_OPENCL_VERSION <= 210 && !defined(CL_USE_DEPRECATED_OPENCL_2_1_APIS)
494# define CL_USE_DEPRECATED_OPENCL_2_1_APIS
496#if CL_HPP_MINIMUM_OPENCL_VERSION <= 220 && !defined(CL_USE_DEPRECATED_OPENCL_2_2_APIS)
497# define CL_USE_DEPRECATED_OPENCL_2_2_APIS
504#if defined(CL_HPP_USE_DX_INTEROP)
505#include <CL/cl_d3d10.h>
506#include <CL/cl_dx9_media_sharing.h>
518#if (!defined(_MSC_VER) && __cplusplus < 201103L) || (defined(_MSC_VER) && _MSC_VER < 1700)
519#error Visual studio 2013 or another C++11-supporting compiler required
523#if defined(CL_HPP_USE_CL_DEVICE_FISSION) || defined(CL_HPP_USE_CL_SUB_GROUPS_KHR)
524#include <CL/cl_ext.h>
527#if defined(__APPLE__) || defined(__MACOSX)
528#include <OpenCL/opencl.h>
530#include <CL/opencl.h>
533#if (__cplusplus >= 201103L || _MSVC_LANG >= 201103L )
534#define CL_HPP_NOEXCEPT_ noexcept
536#define CL_HPP_NOEXCEPT_
539#if __cplusplus >= 201703L
540# define CL_HPP_DEFINE_STATIC_MEMBER_ inline
541#elif defined(_MSC_VER)
542# define CL_HPP_DEFINE_STATIC_MEMBER_ __declspec(selectany)
543#elif defined(__MINGW32__)
544# define CL_HPP_DEFINE_STATIC_MEMBER_ __attribute__((selectany))
546# define CL_HPP_DEFINE_STATIC_MEMBER_ __attribute__((weak))
551#if !defined(CL_API_PREFIX__VERSION_1_1_DEPRECATED)
552#define CL_API_PREFIX__VERSION_1_1_DEPRECATED
554#if !defined(CL_API_SUFFIX__VERSION_1_1_DEPRECATED)
555#define CL_API_SUFFIX__VERSION_1_1_DEPRECATED
558#if !defined(CL_API_PREFIX__VERSION_1_2_DEPRECATED)
559#define CL_API_PREFIX__VERSION_1_2_DEPRECATED
561#if !defined(CL_API_SUFFIX__VERSION_1_2_DEPRECATED)
562#define CL_API_SUFFIX__VERSION_1_2_DEPRECATED
565#if !defined(CL_CALLBACK)
578#if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY)
580 using size_type = ::size_t;
584 using size_type = size_t;
589#if defined(CL_HPP_ENABLE_EXCEPTIONS)
593#if !defined(CL_HPP_NO_STD_VECTOR)
596 template <
class T,
class Alloc = std::allocator<T> >
597 using vector = std::vector<T, Alloc>;
601#if !defined(CL_HPP_NO_STD_STRING)
604 using string = std::string;
608#if CL_HPP_TARGET_OPENCL_VERSION >= 200
610#if !defined(CL_HPP_NO_STD_UNIQUE_PTR)
615 template<
class T,
class D>
616 using pointer = std::unique_ptr<T, D>;
620#if !defined(CL_HPP_NO_STD_ARRAY)
623 template <
class T,
size_type N >
624 using array = std::array<T, N>;
630#if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY)
632 namespace compatibility {
647 for (
int i = 0; i < N; ++i) {
652 size_t(
const array<size_type, N> &rhs)
654 for (
int i = 0; i < N; ++i) {
659 size_type& operator[](
int index)
664 const size_type& operator[](
int index)
const
670 operator size_type* () {
return data_; }
673 operator const size_type* ()
const {
return data_; }
675 operator array<size_type, N>()
const
677 array<size_type, N> ret;
679 for (
int i = 0; i < N; ++i) {
688 using size_t = compatibility::size_t<N>;
695 using size_t_array = array<size_type, 3>;
708#define CL_HPP_INIT_CL_EXT_FCN_PTR_(name) \
710 pfn_##name = (PFN_##name) \
711 clGetExtensionFunctionAddress(#name); \
716#define CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, name) \
718 pfn_##name = (PFN_##name) \
719 clGetExtensionFunctionAddressForPlatform(platform, #name); \
728 class DeviceCommandQueue;
733#if defined(CL_HPP_ENABLE_EXCEPTIONS)
738 class Error :
public std::exception
742 const char * errStr_;
753 Error(cl_int err,
const char * errStr = NULL) : err_(err), errStr_(errStr)
762 virtual const char * what()
const throw ()
764 if (errStr_ == NULL) {
776 cl_int err(
void)
const {
return err_; }
778#define CL_HPP_ERR_STR_(x) #x
780#define CL_HPP_ERR_STR_(x) NULL
786#if defined(CL_HPP_ENABLE_EXCEPTIONS)
787static inline cl_int errHandler (
789 const char * errStr = NULL)
791 if (err != CL_SUCCESS) {
792 throw Error(err, errStr);
797static inline cl_int errHandler (cl_int err,
const char * errStr = NULL)
808#if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS)
809#define __GET_DEVICE_INFO_ERR CL_HPP_ERR_STR_(clGetDeviceInfo)
810#define __GET_PLATFORM_INFO_ERR CL_HPP_ERR_STR_(clGetPlatformInfo)
811#define __GET_DEVICE_IDS_ERR CL_HPP_ERR_STR_(clGetDeviceIDs)
812#define __GET_PLATFORM_IDS_ERR CL_HPP_ERR_STR_(clGetPlatformIDs)
813#define __GET_CONTEXT_INFO_ERR CL_HPP_ERR_STR_(clGetContextInfo)
814#define __GET_EVENT_INFO_ERR CL_HPP_ERR_STR_(clGetEventInfo)
815#define __GET_EVENT_PROFILE_INFO_ERR CL_HPP_ERR_STR_(clGetEventProfileInfo)
816#define __GET_MEM_OBJECT_INFO_ERR CL_HPP_ERR_STR_(clGetMemObjectInfo)
817#define __GET_IMAGE_INFO_ERR CL_HPP_ERR_STR_(clGetImageInfo)
818#define __GET_SAMPLER_INFO_ERR CL_HPP_ERR_STR_(clGetSamplerInfo)
819#define __GET_KERNEL_INFO_ERR CL_HPP_ERR_STR_(clGetKernelInfo)
820#if CL_HPP_TARGET_OPENCL_VERSION >= 120
821#define __GET_KERNEL_ARG_INFO_ERR CL_HPP_ERR_STR_(clGetKernelArgInfo)
823#if CL_HPP_TARGET_OPENCL_VERSION >= 200
824#define __GET_KERNEL_SUB_GROUP_INFO_ERR CL_HPP_ERR_STR_(clGetKernelSubGroupInfo)
826#define __GET_KERNEL_WORK_GROUP_INFO_ERR CL_HPP_ERR_STR_(clGetKernelWorkGroupInfo)
827#define __GET_PROGRAM_INFO_ERR CL_HPP_ERR_STR_(clGetProgramInfo)
828#define __GET_PROGRAM_BUILD_INFO_ERR CL_HPP_ERR_STR_(clGetProgramBuildInfo)
829#define __GET_COMMAND_QUEUE_INFO_ERR CL_HPP_ERR_STR_(clGetCommandQueueInfo)
831#define __CREATE_CONTEXT_ERR CL_HPP_ERR_STR_(clCreateContext)
832#define __CREATE_CONTEXT_FROM_TYPE_ERR CL_HPP_ERR_STR_(clCreateContextFromType)
833#define __GET_SUPPORTED_IMAGE_FORMATS_ERR CL_HPP_ERR_STR_(clGetSupportedImageFormats)
835#define __CREATE_BUFFER_ERR CL_HPP_ERR_STR_(clCreateBuffer)
836#define __COPY_ERR CL_HPP_ERR_STR_(cl::copy)
837#define __CREATE_SUBBUFFER_ERR CL_HPP_ERR_STR_(clCreateSubBuffer)
838#define __CREATE_GL_BUFFER_ERR CL_HPP_ERR_STR_(clCreateFromGLBuffer)
839#define __CREATE_GL_RENDER_BUFFER_ERR CL_HPP_ERR_STR_(clCreateFromGLBuffer)
840#define __GET_GL_OBJECT_INFO_ERR CL_HPP_ERR_STR_(clGetGLObjectInfo)
841#if CL_HPP_TARGET_OPENCL_VERSION >= 120
842#define __CREATE_IMAGE_ERR CL_HPP_ERR_STR_(clCreateImage)
843#define __CREATE_GL_TEXTURE_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture)
844#define __IMAGE_DIMENSION_ERR CL_HPP_ERR_STR_(Incorrect image dimensions)
846#define __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR CL_HPP_ERR_STR_(clSetMemObjectDestructorCallback)
848#define __CREATE_USER_EVENT_ERR CL_HPP_ERR_STR_(clCreateUserEvent)
849#define __SET_USER_EVENT_STATUS_ERR CL_HPP_ERR_STR_(clSetUserEventStatus)
850#define __SET_EVENT_CALLBACK_ERR CL_HPP_ERR_STR_(clSetEventCallback)
851#define __WAIT_FOR_EVENTS_ERR CL_HPP_ERR_STR_(clWaitForEvents)
853#define __CREATE_KERNEL_ERR CL_HPP_ERR_STR_(clCreateKernel)
854#define __SET_KERNEL_ARGS_ERR CL_HPP_ERR_STR_(clSetKernelArg)
855#define __CREATE_PROGRAM_WITH_SOURCE_ERR CL_HPP_ERR_STR_(clCreateProgramWithSource)
856#if CL_HPP_TARGET_OPENCL_VERSION >= 200
857#define __CREATE_PROGRAM_WITH_IL_ERR CL_HPP_ERR_STR_(clCreateProgramWithIL)
859#define __CREATE_PROGRAM_WITH_BINARY_ERR CL_HPP_ERR_STR_(clCreateProgramWithBinary)
860#if CL_HPP_TARGET_OPENCL_VERSION >= 210
861#define __CREATE_PROGRAM_WITH_IL_ERR CL_HPP_ERR_STR_(clCreateProgramWithIL)
863#if CL_HPP_TARGET_OPENCL_VERSION >= 120
864#define __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR CL_HPP_ERR_STR_(clCreateProgramWithBuiltInKernels)
866#define __BUILD_PROGRAM_ERR CL_HPP_ERR_STR_(clBuildProgram)
867#if CL_HPP_TARGET_OPENCL_VERSION >= 120
868#define __COMPILE_PROGRAM_ERR CL_HPP_ERR_STR_(clCompileProgram)
869#define __LINK_PROGRAM_ERR CL_HPP_ERR_STR_(clLinkProgram)
871#define __CREATE_KERNELS_IN_PROGRAM_ERR CL_HPP_ERR_STR_(clCreateKernelsInProgram)
873#if CL_HPP_TARGET_OPENCL_VERSION >= 200
874#define __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR CL_HPP_ERR_STR_(clCreateCommandQueueWithProperties)
875#define __CREATE_SAMPLER_WITH_PROPERTIES_ERR CL_HPP_ERR_STR_(clCreateSamplerWithProperties)
877#define __SET_COMMAND_QUEUE_PROPERTY_ERR CL_HPP_ERR_STR_(clSetCommandQueueProperty)
878#define __ENQUEUE_READ_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueReadBuffer)
879#define __ENQUEUE_READ_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueReadBufferRect)
880#define __ENQUEUE_WRITE_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueWriteBuffer)
881#define __ENQUEUE_WRITE_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueWriteBufferRect)
882#define __ENQEUE_COPY_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueCopyBuffer)
883#define __ENQEUE_COPY_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueCopyBufferRect)
884#define __ENQUEUE_FILL_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueFillBuffer)
885#define __ENQUEUE_READ_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueReadImage)
886#define __ENQUEUE_WRITE_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueWriteImage)
887#define __ENQUEUE_COPY_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueCopyImage)
888#define __ENQUEUE_FILL_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueFillImage)
889#define __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueCopyImageToBuffer)
890#define __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueCopyBufferToImage)
891#define __ENQUEUE_MAP_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueMapBuffer)
892#define __ENQUEUE_MAP_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueMapImage)
893#define __ENQUEUE_UNMAP_MEM_OBJECT_ERR CL_HPP_ERR_STR_(clEnqueueUnMapMemObject)
894#define __ENQUEUE_NDRANGE_KERNEL_ERR CL_HPP_ERR_STR_(clEnqueueNDRangeKernel)
895#define __ENQUEUE_NATIVE_KERNEL CL_HPP_ERR_STR_(clEnqueueNativeKernel)
896#if CL_HPP_TARGET_OPENCL_VERSION >= 120
897#define __ENQUEUE_MIGRATE_MEM_OBJECTS_ERR CL_HPP_ERR_STR_(clEnqueueMigrateMemObjects)
899#if CL_HPP_TARGET_OPENCL_VERSION >= 210
900#define __ENQUEUE_MIGRATE_SVM_ERR CL_HPP_ERR_STR_(clEnqueueSVMMigrateMem)
901#define __SET_DEFAULT_DEVICE_COMMAND_QUEUE_ERR CL_HPP_ERR_STR_(clSetDefaultDeviceCommandQueue)
905#define __ENQUEUE_ACQUIRE_GL_ERR CL_HPP_ERR_STR_(clEnqueueAcquireGLObjects)
906#define __ENQUEUE_RELEASE_GL_ERR CL_HPP_ERR_STR_(clEnqueueReleaseGLObjects)
908#define __CREATE_PIPE_ERR CL_HPP_ERR_STR_(clCreatePipe)
909#define __GET_PIPE_INFO_ERR CL_HPP_ERR_STR_(clGetPipeInfo)
912#define __RETAIN_ERR CL_HPP_ERR_STR_(Retain Object)
913#define __RELEASE_ERR CL_HPP_ERR_STR_(Release Object)
914#define __FLUSH_ERR CL_HPP_ERR_STR_(clFlush)
915#define __FINISH_ERR CL_HPP_ERR_STR_(clFinish)
916#define __VECTOR_CAPACITY_ERR CL_HPP_ERR_STR_(Vector capacity error)
918#if CL_HPP_TARGET_OPENCL_VERSION >= 210
919#define __GET_HOST_TIMER_ERR CL_HPP_ERR_STR_(clGetHostTimer)
920#define __GET_DEVICE_AND_HOST_TIMER_ERR CL_HPP_ERR_STR_(clGetDeviceAndHostTimer)
922#if CL_HPP_TARGET_OPENCL_VERSION >= 220
923#define __SET_PROGRAM_RELEASE_CALLBACK_ERR CL_HPP_ERR_STR_(clSetProgramReleaseCallback)
924#define __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR CL_HPP_ERR_STR_(clSetProgramSpecializationConstant)
931#if CL_HPP_TARGET_OPENCL_VERSION >= 120
932#define __CREATE_SUB_DEVICES_ERR CL_HPP_ERR_STR_(clCreateSubDevices)
934#define __CREATE_SUB_DEVICES_ERR CL_HPP_ERR_STR_(clCreateSubDevicesEXT)
940#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
941#define __ENQUEUE_MARKER_ERR CL_HPP_ERR_STR_(clEnqueueMarker)
942#define __ENQUEUE_WAIT_FOR_EVENTS_ERR CL_HPP_ERR_STR_(clEnqueueWaitForEvents)
943#define __ENQUEUE_BARRIER_ERR CL_HPP_ERR_STR_(clEnqueueBarrier)
944#define __UNLOAD_COMPILER_ERR CL_HPP_ERR_STR_(clUnloadCompiler)
945#define __CREATE_GL_TEXTURE_2D_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture2D)
946#define __CREATE_GL_TEXTURE_3D_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture3D)
947#define __CREATE_IMAGE2D_ERR CL_HPP_ERR_STR_(clCreateImage2D)
948#define __CREATE_IMAGE3D_ERR CL_HPP_ERR_STR_(clCreateImage3D)
954#if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
955#define __CREATE_COMMAND_QUEUE_ERR CL_HPP_ERR_STR_(clCreateCommandQueue)
956#define __ENQUEUE_TASK_ERR CL_HPP_ERR_STR_(clEnqueueTask)
957#define __CREATE_SAMPLER_ERR CL_HPP_ERR_STR_(clCreateSampler)
963#if CL_HPP_TARGET_OPENCL_VERSION >= 120
964#define __ENQUEUE_MARKER_WAIT_LIST_ERR CL_HPP_ERR_STR_(clEnqueueMarkerWithWaitList)
965#define __ENQUEUE_BARRIER_WAIT_LIST_ERR CL_HPP_ERR_STR_(clEnqueueBarrierWithWaitList)
968#if CL_HPP_TARGET_OPENCL_VERSION >= 210
969#define __CLONE_KERNEL_ERR CL_HPP_ERR_STR_(clCloneKernel)
982template<
typename Functor,
typename T>
983inline cl_int getInfoHelper(Functor f, cl_uint name, T* param,
long)
985 return f(name,
sizeof(T), param, NULL);
990template <
typename Func>
991inline cl_int getInfoHelper(Func f, cl_uint name, vector<vector<unsigned char>>* param,
int)
993 if (name != CL_PROGRAM_BINARIES) {
994 return CL_INVALID_VALUE;
998 size_type numBinaries = param->size();
999 vector<unsigned char*> binariesPointers(numBinaries);
1001 for (size_type i = 0; i < numBinaries; ++i)
1003 binariesPointers[i] = (*param)[i].data();
1006 cl_int err = f(name, numBinaries *
sizeof(
unsigned char*), binariesPointers.data(), NULL);
1008 if (err != CL_SUCCESS) {
1018template <
typename Func,
typename T>
1019inline cl_int getInfoHelper(Func f, cl_uint name, vector<T>* param,
long)
1022 cl_int err = f(name, 0, NULL, &required);
1023 if (err != CL_SUCCESS) {
1026 const size_type elements = required /
sizeof(T);
1029 vector<T> localData(elements);
1030 err = f(name, required, localData.data(), NULL);
1031 if (err != CL_SUCCESS) {
1035 *param = std::move(localData);
1047template <
typename Func,
typename T>
1048inline cl_int getInfoHelper(
1049 Func f, cl_uint name, vector<T>* param,
int,
typename T::cl_type = 0)
1052 cl_int err = f(name, 0, NULL, &required);
1053 if (err != CL_SUCCESS) {
1057 const size_type elements = required /
sizeof(
typename T::cl_type);
1059 vector<typename T::cl_type> value(elements);
1060 err = f(name, required, value.data(), NULL);
1061 if (err != CL_SUCCESS) {
1067 param->resize(elements);
1071 for (size_type i = 0; i < elements; i++) {
1072 (*param)[i] = T(value[i],
true);
1079template <
typename Func>
1080inline cl_int getInfoHelper(Func f, cl_uint name,
string* param,
long)
1083 cl_int err = f(name, 0, NULL, &required);
1084 if (err != CL_SUCCESS) {
1091 vector<char> value(required);
1092 err = f(name, required, value.data(), NULL);
1093 if (err != CL_SUCCESS) {
1097 param->assign(begin(value), prev(end(value)));
1107template <
typename Func,
size_type N>
1108inline cl_int getInfoHelper(Func f, cl_uint name, array<size_type, N>* param,
long)
1111 cl_int err = f(name, 0, NULL, &required);
1112 if (err != CL_SUCCESS) {
1116 size_type elements = required /
sizeof(size_type);
1117 vector<size_type> value(elements, 0);
1119 err = f(name, required, value.data(), NULL);
1120 if (err != CL_SUCCESS) {
1129 for (size_type i = 0; i < elements; ++i) {
1130 (*param)[i] = value[i];
1136template<
typename T>
struct ReferenceHandler;
1144template<
typename Func,
typename T>
1145inline cl_int getInfoHelper(Func f, cl_uint name, T* param,
int,
typename T::cl_type = 0)
1147 typename T::cl_type value;
1148 cl_int err = f(name,
sizeof(value), &value, NULL);
1149 if (err != CL_SUCCESS) {
1155 err = param->retain();
1156 if (err != CL_SUCCESS) {
1163#define CL_HPP_PARAM_NAME_INFO_1_0_(F) \
1164 F(cl_platform_info, CL_PLATFORM_PROFILE, string) \
1165 F(cl_platform_info, CL_PLATFORM_VERSION, string) \
1166 F(cl_platform_info, CL_PLATFORM_NAME, string) \
1167 F(cl_platform_info, CL_PLATFORM_VENDOR, string) \
1168 F(cl_platform_info, CL_PLATFORM_EXTENSIONS, string) \
1170 F(cl_device_info, CL_DEVICE_TYPE, cl_device_type) \
1171 F(cl_device_info, CL_DEVICE_VENDOR_ID, cl_uint) \
1172 F(cl_device_info, CL_DEVICE_MAX_COMPUTE_UNITS, cl_uint) \
1173 F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, cl_uint) \
1174 F(cl_device_info, CL_DEVICE_MAX_WORK_GROUP_SIZE, size_type) \
1175 F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_SIZES, cl::vector<size_type>) \
1176 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, cl_uint) \
1177 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT, cl_uint) \
1178 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT, cl_uint) \
1179 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG, cl_uint) \
1180 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT, cl_uint) \
1181 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, cl_uint) \
1182 F(cl_device_info, CL_DEVICE_MAX_CLOCK_FREQUENCY, cl_uint) \
1183 F(cl_device_info, CL_DEVICE_ADDRESS_BITS, cl_uint) \
1184 F(cl_device_info, CL_DEVICE_MAX_READ_IMAGE_ARGS, cl_uint) \
1185 F(cl_device_info, CL_DEVICE_MAX_WRITE_IMAGE_ARGS, cl_uint) \
1186 F(cl_device_info, CL_DEVICE_MAX_MEM_ALLOC_SIZE, cl_ulong) \
1187 F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_WIDTH, size_type) \
1188 F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_HEIGHT, size_type) \
1189 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_WIDTH, size_type) \
1190 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_HEIGHT, size_type) \
1191 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_DEPTH, size_type) \
1192 F(cl_device_info, CL_DEVICE_IMAGE_SUPPORT, cl_bool) \
1193 F(cl_device_info, CL_DEVICE_MAX_PARAMETER_SIZE, size_type) \
1194 F(cl_device_info, CL_DEVICE_MAX_SAMPLERS, cl_uint) \
1195 F(cl_device_info, CL_DEVICE_MEM_BASE_ADDR_ALIGN, cl_uint) \
1196 F(cl_device_info, CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE, cl_uint) \
1197 F(cl_device_info, CL_DEVICE_SINGLE_FP_CONFIG, cl_device_fp_config) \
1198 F(cl_device_info, CL_DEVICE_DOUBLE_FP_CONFIG, cl_device_fp_config) \
1199 F(cl_device_info, CL_DEVICE_HALF_FP_CONFIG, cl_device_fp_config) \
1200 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_TYPE, cl_device_mem_cache_type) \
1201 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE, cl_uint)\
1202 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_SIZE, cl_ulong) \
1203 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_SIZE, cl_ulong) \
1204 F(cl_device_info, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE, cl_ulong) \
1205 F(cl_device_info, CL_DEVICE_MAX_CONSTANT_ARGS, cl_uint) \
1206 F(cl_device_info, CL_DEVICE_LOCAL_MEM_TYPE, cl_device_local_mem_type) \
1207 F(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE, cl_ulong) \
1208 F(cl_device_info, CL_DEVICE_ERROR_CORRECTION_SUPPORT, cl_bool) \
1209 F(cl_device_info, CL_DEVICE_PROFILING_TIMER_RESOLUTION, size_type) \
1210 F(cl_device_info, CL_DEVICE_ENDIAN_LITTLE, cl_bool) \
1211 F(cl_device_info, CL_DEVICE_AVAILABLE, cl_bool) \
1212 F(cl_device_info, CL_DEVICE_COMPILER_AVAILABLE, cl_bool) \
1213 F(cl_device_info, CL_DEVICE_EXECUTION_CAPABILITIES, cl_device_exec_capabilities) \
1214 F(cl_device_info, CL_DEVICE_PLATFORM, cl_platform_id) \
1215 F(cl_device_info, CL_DEVICE_NAME, string) \
1216 F(cl_device_info, CL_DEVICE_VENDOR, string) \
1217 F(cl_device_info, CL_DRIVER_VERSION, string) \
1218 F(cl_device_info, CL_DEVICE_PROFILE, string) \
1219 F(cl_device_info, CL_DEVICE_VERSION, string) \
1220 F(cl_device_info, CL_DEVICE_EXTENSIONS, string) \
1222 F(cl_context_info, CL_CONTEXT_REFERENCE_COUNT, cl_uint) \
1223 F(cl_context_info, CL_CONTEXT_DEVICES, cl::vector<Device>) \
1224 F(cl_context_info, CL_CONTEXT_PROPERTIES, cl::vector<cl_context_properties>) \
1226 F(cl_event_info, CL_EVENT_COMMAND_QUEUE, cl::CommandQueue) \
1227 F(cl_event_info, CL_EVENT_COMMAND_TYPE, cl_command_type) \
1228 F(cl_event_info, CL_EVENT_REFERENCE_COUNT, cl_uint) \
1229 F(cl_event_info, CL_EVENT_COMMAND_EXECUTION_STATUS, cl_int) \
1231 F(cl_profiling_info, CL_PROFILING_COMMAND_QUEUED, cl_ulong) \
1232 F(cl_profiling_info, CL_PROFILING_COMMAND_SUBMIT, cl_ulong) \
1233 F(cl_profiling_info, CL_PROFILING_COMMAND_START, cl_ulong) \
1234 F(cl_profiling_info, CL_PROFILING_COMMAND_END, cl_ulong) \
1236 F(cl_mem_info, CL_MEM_TYPE, cl_mem_object_type) \
1237 F(cl_mem_info, CL_MEM_FLAGS, cl_mem_flags) \
1238 F(cl_mem_info, CL_MEM_SIZE, size_type) \
1239 F(cl_mem_info, CL_MEM_HOST_PTR, void*) \
1240 F(cl_mem_info, CL_MEM_MAP_COUNT, cl_uint) \
1241 F(cl_mem_info, CL_MEM_REFERENCE_COUNT, cl_uint) \
1242 F(cl_mem_info, CL_MEM_CONTEXT, cl::Context) \
1244 F(cl_image_info, CL_IMAGE_FORMAT, cl_image_format) \
1245 F(cl_image_info, CL_IMAGE_ELEMENT_SIZE, size_type) \
1246 F(cl_image_info, CL_IMAGE_ROW_PITCH, size_type) \
1247 F(cl_image_info, CL_IMAGE_SLICE_PITCH, size_type) \
1248 F(cl_image_info, CL_IMAGE_WIDTH, size_type) \
1249 F(cl_image_info, CL_IMAGE_HEIGHT, size_type) \
1250 F(cl_image_info, CL_IMAGE_DEPTH, size_type) \
1252 F(cl_sampler_info, CL_SAMPLER_REFERENCE_COUNT, cl_uint) \
1253 F(cl_sampler_info, CL_SAMPLER_CONTEXT, cl::Context) \
1254 F(cl_sampler_info, CL_SAMPLER_NORMALIZED_COORDS, cl_bool) \
1255 F(cl_sampler_info, CL_SAMPLER_ADDRESSING_MODE, cl_addressing_mode) \
1256 F(cl_sampler_info, CL_SAMPLER_FILTER_MODE, cl_filter_mode) \
1258 F(cl_program_info, CL_PROGRAM_REFERENCE_COUNT, cl_uint) \
1259 F(cl_program_info, CL_PROGRAM_CONTEXT, cl::Context) \
1260 F(cl_program_info, CL_PROGRAM_NUM_DEVICES, cl_uint) \
1261 F(cl_program_info, CL_PROGRAM_DEVICES, cl::vector<Device>) \
1262 F(cl_program_info, CL_PROGRAM_SOURCE, string) \
1263 F(cl_program_info, CL_PROGRAM_BINARY_SIZES, cl::vector<size_type>) \
1264 F(cl_program_info, CL_PROGRAM_BINARIES, cl::vector<cl::vector<unsigned char>>) \
1266 F(cl_program_build_info, CL_PROGRAM_BUILD_STATUS, cl_build_status) \
1267 F(cl_program_build_info, CL_PROGRAM_BUILD_OPTIONS, string) \
1268 F(cl_program_build_info, CL_PROGRAM_BUILD_LOG, string) \
1270 F(cl_kernel_info, CL_KERNEL_FUNCTION_NAME, string) \
1271 F(cl_kernel_info, CL_KERNEL_NUM_ARGS, cl_uint) \
1272 F(cl_kernel_info, CL_KERNEL_REFERENCE_COUNT, cl_uint) \
1273 F(cl_kernel_info, CL_KERNEL_CONTEXT, cl::Context) \
1274 F(cl_kernel_info, CL_KERNEL_PROGRAM, cl::Program) \
1276 F(cl_kernel_work_group_info, CL_KERNEL_WORK_GROUP_SIZE, size_type) \
1277 F(cl_kernel_work_group_info, CL_KERNEL_COMPILE_WORK_GROUP_SIZE, cl::detail::size_t_array) \
1278 F(cl_kernel_work_group_info, CL_KERNEL_LOCAL_MEM_SIZE, cl_ulong) \
1280 F(cl_command_queue_info, CL_QUEUE_CONTEXT, cl::Context) \
1281 F(cl_command_queue_info, CL_QUEUE_DEVICE, cl::Device) \
1282 F(cl_command_queue_info, CL_QUEUE_REFERENCE_COUNT, cl_uint) \
1283 F(cl_command_queue_info, CL_QUEUE_PROPERTIES, cl_command_queue_properties)
1286#define CL_HPP_PARAM_NAME_INFO_1_1_(F) \
1287 F(cl_context_info, CL_CONTEXT_NUM_DEVICES, cl_uint)\
1288 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF, cl_uint) \
1289 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR, cl_uint) \
1290 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT, cl_uint) \
1291 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_INT, cl_uint) \
1292 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG, cl_uint) \
1293 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT, cl_uint) \
1294 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE, cl_uint) \
1295 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF, cl_uint) \
1296 F(cl_device_info, CL_DEVICE_OPENCL_C_VERSION, string) \
1298 F(cl_mem_info, CL_MEM_ASSOCIATED_MEMOBJECT, cl::Memory) \
1299 F(cl_mem_info, CL_MEM_OFFSET, size_type) \
1301 F(cl_kernel_work_group_info, CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, size_type) \
1302 F(cl_kernel_work_group_info, CL_KERNEL_PRIVATE_MEM_SIZE, cl_ulong) \
1304 F(cl_event_info, CL_EVENT_CONTEXT, cl::Context)
1306#define CL_HPP_PARAM_NAME_INFO_1_2_(F) \
1307 F(cl_program_info, CL_PROGRAM_NUM_KERNELS, size_type) \
1308 F(cl_program_info, CL_PROGRAM_KERNEL_NAMES, string) \
1310 F(cl_program_build_info, CL_PROGRAM_BINARY_TYPE, cl_program_binary_type) \
1312 F(cl_kernel_info, CL_KERNEL_ATTRIBUTES, string) \
1314 F(cl_kernel_arg_info, CL_KERNEL_ARG_ADDRESS_QUALIFIER, cl_kernel_arg_address_qualifier) \
1315 F(cl_kernel_arg_info, CL_KERNEL_ARG_ACCESS_QUALIFIER, cl_kernel_arg_access_qualifier) \
1316 F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_NAME, string) \
1317 F(cl_kernel_arg_info, CL_KERNEL_ARG_NAME, string) \
1318 F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_QUALIFIER, cl_kernel_arg_type_qualifier) \
1320 F(cl_kernel_work_group_info, CL_KERNEL_GLOBAL_WORK_SIZE, cl::detail::size_t_array) \
1322 F(cl_device_info, CL_DEVICE_LINKER_AVAILABLE, cl_bool) \
1323 F(cl_device_info, CL_DEVICE_IMAGE_MAX_BUFFER_SIZE, size_type) \
1324 F(cl_device_info, CL_DEVICE_IMAGE_MAX_ARRAY_SIZE, size_type) \
1325 F(cl_device_info, CL_DEVICE_PARENT_DEVICE, cl::Device) \
1326 F(cl_device_info, CL_DEVICE_PARTITION_MAX_SUB_DEVICES, cl_uint) \
1327 F(cl_device_info, CL_DEVICE_PARTITION_PROPERTIES, cl::vector<cl_device_partition_property>) \
1328 F(cl_device_info, CL_DEVICE_PARTITION_TYPE, cl::vector<cl_device_partition_property>) \
1329 F(cl_device_info, CL_DEVICE_REFERENCE_COUNT, cl_uint) \
1330 F(cl_device_info, CL_DEVICE_PREFERRED_INTEROP_USER_SYNC, cl_bool) \
1331 F(cl_device_info, CL_DEVICE_PARTITION_AFFINITY_DOMAIN, cl_device_affinity_domain) \
1332 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS, string) \
1333 F(cl_device_info, CL_DEVICE_PRINTF_BUFFER_SIZE, size_type) \
1335 F(cl_image_info, CL_IMAGE_ARRAY_SIZE, size_type) \
1336 F(cl_image_info, CL_IMAGE_NUM_MIP_LEVELS, cl_uint) \
1337 F(cl_image_info, CL_IMAGE_NUM_SAMPLES, cl_uint)
1339#define CL_HPP_PARAM_NAME_INFO_2_0_(F) \
1340 F(cl_device_info, CL_DEVICE_QUEUE_ON_HOST_PROPERTIES, cl_command_queue_properties) \
1341 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES, cl_command_queue_properties) \
1342 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE, cl_uint) \
1343 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE, cl_uint) \
1344 F(cl_device_info, CL_DEVICE_MAX_ON_DEVICE_QUEUES, cl_uint) \
1345 F(cl_device_info, CL_DEVICE_MAX_ON_DEVICE_EVENTS, cl_uint) \
1346 F(cl_device_info, CL_DEVICE_MAX_PIPE_ARGS, cl_uint) \
1347 F(cl_device_info, CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS, cl_uint) \
1348 F(cl_device_info, CL_DEVICE_PIPE_MAX_PACKET_SIZE, cl_uint) \
1349 F(cl_device_info, CL_DEVICE_SVM_CAPABILITIES, cl_device_svm_capabilities) \
1350 F(cl_device_info, CL_DEVICE_PREFERRED_PLATFORM_ATOMIC_ALIGNMENT, cl_uint) \
1351 F(cl_device_info, CL_DEVICE_PREFERRED_GLOBAL_ATOMIC_ALIGNMENT, cl_uint) \
1352 F(cl_device_info, CL_DEVICE_PREFERRED_LOCAL_ATOMIC_ALIGNMENT, cl_uint) \
1353 F(cl_device_info, CL_DEVICE_IMAGE_PITCH_ALIGNMENT, cl_uint) \
1354 F(cl_device_info, CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT, cl_uint) \
1355 F(cl_device_info, CL_DEVICE_MAX_READ_WRITE_IMAGE_ARGS, cl_uint ) \
1356 F(cl_device_info, CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE, size_type ) \
1357 F(cl_device_info, CL_DEVICE_GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE, size_type ) \
1358 F(cl_profiling_info, CL_PROFILING_COMMAND_COMPLETE, cl_ulong) \
1359 F(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM, cl_bool) \
1360 F(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_SVM_PTRS, void**) \
1361 F(cl_command_queue_info, CL_QUEUE_SIZE, cl_uint) \
1362 F(cl_mem_info, CL_MEM_USES_SVM_POINTER, cl_bool) \
1363 F(cl_program_build_info, CL_PROGRAM_BUILD_GLOBAL_VARIABLE_TOTAL_SIZE, size_type) \
1364 F(cl_pipe_info, CL_PIPE_PACKET_SIZE, cl_uint) \
1365 F(cl_pipe_info, CL_PIPE_MAX_PACKETS, cl_uint)
1367#define CL_HPP_PARAM_NAME_INFO_SUBGROUP_KHR_(F) \
1368 F(cl_kernel_sub_group_info, CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE_KHR, size_type) \
1369 F(cl_kernel_sub_group_info, CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE_KHR, size_type)
1371#define CL_HPP_PARAM_NAME_INFO_IL_KHR_(F) \
1372 F(cl_device_info, CL_DEVICE_IL_VERSION_KHR, string) \
1373 F(cl_program_info, CL_PROGRAM_IL_KHR, cl::vector<unsigned char>)
1375#define CL_HPP_PARAM_NAME_INFO_2_1_(F) \
1376 F(cl_platform_info, CL_PLATFORM_HOST_TIMER_RESOLUTION, cl_ulong) \
1377 F(cl_program_info, CL_PROGRAM_IL, cl::vector<unsigned char>) \
1378 F(cl_device_info, CL_DEVICE_MAX_NUM_SUB_GROUPS, cl_uint) \
1379 F(cl_device_info, CL_DEVICE_IL_VERSION, string) \
1380 F(cl_device_info, CL_DEVICE_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS, cl_bool) \
1381 F(cl_command_queue_info, CL_QUEUE_DEVICE_DEFAULT, cl::DeviceCommandQueue) \
1382 F(cl_kernel_sub_group_info, CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE, size_type) \
1383 F(cl_kernel_sub_group_info, CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE, size_type) \
1384 F(cl_kernel_sub_group_info, CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT, cl::detail::size_t_array) \
1385 F(cl_kernel_sub_group_info, CL_KERNEL_MAX_NUM_SUB_GROUPS, size_type) \
1386 F(cl_kernel_sub_group_info, CL_KERNEL_COMPILE_NUM_SUB_GROUPS, size_type)
1388#define CL_HPP_PARAM_NAME_INFO_2_2_(F) \
1389 F(cl_program_info, CL_PROGRAM_SCOPE_GLOBAL_CTORS_PRESENT, cl_bool) \
1390 F(cl_program_info, CL_PROGRAM_SCOPE_GLOBAL_DTORS_PRESENT, cl_bool)
1392#define CL_HPP_PARAM_NAME_DEVICE_FISSION_(F) \
1393 F(cl_device_info, CL_DEVICE_PARENT_DEVICE_EXT, cl_device_id) \
1394 F(cl_device_info, CL_DEVICE_PARTITION_TYPES_EXT, cl::vector<cl_device_partition_property_ext>) \
1395 F(cl_device_info, CL_DEVICE_AFFINITY_DOMAINS_EXT, cl::vector<cl_device_partition_property_ext>) \
1396 F(cl_device_info, CL_DEVICE_REFERENCE_COUNT_EXT , cl_uint) \
1397 F(cl_device_info, CL_DEVICE_PARTITION_STYLE_EXT, cl::vector<cl_device_partition_property_ext>)
1399#define CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_CL3_SHARED_(F) \
1400 F(cl_platform_info, CL_PLATFORM_NUMERIC_VERSION_KHR, cl_version_khr) \
1401 F(cl_platform_info, CL_PLATFORM_EXTENSIONS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>) \
1403 F(cl_device_info, CL_DEVICE_NUMERIC_VERSION_KHR, cl_version_khr) \
1404 F(cl_device_info, CL_DEVICE_EXTENSIONS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>) \
1405 F(cl_device_info, CL_DEVICE_ILS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>) \
1406 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>)
1408#define CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_KHRONLY_(F) \
1409 F(cl_device_info, CL_DEVICE_OPENCL_C_NUMERIC_VERSION_KHR, cl_version_khr)
1411#define CL_HPP_PARAM_NAME_INFO_3_0_(F) \
1412 F(cl_platform_info, CL_PLATFORM_NUMERIC_VERSION, cl_version) \
1413 F(cl_platform_info, CL_PLATFORM_EXTENSIONS_WITH_VERSION, cl::vector<cl_name_version>) \
1415 F(cl_device_info, CL_DEVICE_NUMERIC_VERSION, cl_version) \
1416 F(cl_device_info, CL_DEVICE_EXTENSIONS_WITH_VERSION, cl::vector<cl_name_version>) \
1417 F(cl_device_info, CL_DEVICE_ILS_WITH_VERSION, cl::vector<cl_name_version>) \
1418 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS_WITH_VERSION, cl::vector<cl_name_version>) \
1419 F(cl_device_info, CL_DEVICE_ATOMIC_MEMORY_CAPABILITIES, cl_device_atomic_capabilities) \
1420 F(cl_device_info, CL_DEVICE_ATOMIC_FENCE_CAPABILITIES, cl_device_atomic_capabilities) \
1421 F(cl_device_info, CL_DEVICE_NON_UNIFORM_WORK_GROUP_SUPPORT, cl_bool) \
1422 F(cl_device_info, CL_DEVICE_OPENCL_C_ALL_VERSIONS, cl::vector<cl_name_version>) \
1423 F(cl_device_info, CL_DEVICE_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, size_type) \
1424 F(cl_device_info, CL_DEVICE_WORK_GROUP_COLLECTIVE_FUNCTIONS_SUPPORT, cl_bool) \
1425 F(cl_device_info, CL_DEVICE_GENERIC_ADDRESS_SPACE_SUPPORT, cl_bool) \
1426 F(cl_device_info, CL_DEVICE_OPENCL_C_FEATURES, cl::vector<cl_name_version>) \
1427 F(cl_device_info, CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES, cl_device_device_enqueue_capabilities) \
1428 F(cl_device_info, CL_DEVICE_PIPE_SUPPORT, cl_bool) \
1429 F(cl_device_info, CL_DEVICE_LATEST_CONFORMANCE_VERSION_PASSED, string) \
1431 F(cl_command_queue_info, CL_QUEUE_PROPERTIES_ARRAY, cl::vector<cl_queue_properties>) \
1432 F(cl_mem_info, CL_MEM_PROPERTIES, cl::vector<cl_mem_properties>) \
1433 F(cl_pipe_info, CL_PIPE_PROPERTIES, cl::vector<cl_pipe_properties>) \
1434 F(cl_sampler_info, CL_SAMPLER_PROPERTIES, cl::vector<cl_sampler_properties>)
1436template <
typename enum_type, cl_
int Name>
1439#define CL_HPP_DECLARE_PARAM_TRAITS_(token, param_name, T) \
1442struct param_traits<detail:: token,param_name> \
1444 enum { value = param_name }; \
1445 typedef T param_type; \
1448CL_HPP_PARAM_NAME_INFO_1_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1449#if CL_HPP_TARGET_OPENCL_VERSION >= 110
1450CL_HPP_PARAM_NAME_INFO_1_1_(CL_HPP_DECLARE_PARAM_TRAITS_)
1452#if CL_HPP_TARGET_OPENCL_VERSION >= 120
1453CL_HPP_PARAM_NAME_INFO_1_2_(CL_HPP_DECLARE_PARAM_TRAITS_)
1455#if CL_HPP_TARGET_OPENCL_VERSION >= 200
1456CL_HPP_PARAM_NAME_INFO_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1458#if CL_HPP_TARGET_OPENCL_VERSION >= 210
1459CL_HPP_PARAM_NAME_INFO_2_1_(CL_HPP_DECLARE_PARAM_TRAITS_)
1461#if CL_HPP_TARGET_OPENCL_VERSION >= 220
1462CL_HPP_PARAM_NAME_INFO_2_2_(CL_HPP_DECLARE_PARAM_TRAITS_)
1464#if CL_HPP_TARGET_OPENCL_VERSION >= 300
1465CL_HPP_PARAM_NAME_INFO_3_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1468#if defined(CL_HPP_USE_CL_SUB_GROUPS_KHR) && CL_HPP_TARGET_OPENCL_VERSION < 210
1469CL_HPP_PARAM_NAME_INFO_SUBGROUP_KHR_(CL_HPP_DECLARE_PARAM_TRAITS_)
1472#if defined(CL_HPP_USE_IL_KHR)
1473CL_HPP_PARAM_NAME_INFO_IL_KHR_(CL_HPP_DECLARE_PARAM_TRAITS_)
1478#define CL_HPP_PARAM_NAME_INFO_1_0_DEPRECATED_IN_2_0_(F) \
1479 F(cl_device_info, CL_DEVICE_QUEUE_PROPERTIES, cl_command_queue_properties)
1481#define CL_HPP_PARAM_NAME_INFO_1_1_DEPRECATED_IN_2_0_(F) \
1482 F(cl_device_info, CL_DEVICE_HOST_UNIFIED_MEMORY, cl_bool)
1484#define CL_HPP_PARAM_NAME_INFO_1_2_DEPRECATED_IN_2_0_(F) \
1485 F(cl_image_info, CL_IMAGE_BUFFER, cl::Buffer)
1489#if CL_HPP_TARGET_OPENCL_VERSION > 100 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 && CL_HPP_TARGET_OPENCL_VERSION < 200
1490CL_HPP_PARAM_NAME_INFO_1_0_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1492#if CL_HPP_TARGET_OPENCL_VERSION > 110 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
1493CL_HPP_PARAM_NAME_INFO_1_1_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1495#if CL_HPP_TARGET_OPENCL_VERSION > 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
1496CL_HPP_PARAM_NAME_INFO_1_2_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1499#if defined(CL_HPP_USE_CL_DEVICE_FISSION)
1500CL_HPP_PARAM_NAME_DEVICE_FISSION_(CL_HPP_DECLARE_PARAM_TRAITS_);
1503#if defined(cl_khr_extended_versioning)
1504#if CL_HPP_TARGET_OPENCL_VERSION < 300
1505CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_CL3_SHARED_(CL_HPP_DECLARE_PARAM_TRAITS_)
1507CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_KHRONLY_(CL_HPP_DECLARE_PARAM_TRAITS_)
1510#if defined(cl_khr_device_uuid)
1511using uuid_array = array<cl_uchar, CL_UUID_SIZE_KHR>;
1512using luid_array = array<cl_uchar, CL_LUID_SIZE_KHR>;
1513CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_UUID_KHR, uuid_array)
1514CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DRIVER_UUID_KHR, uuid_array)
1515CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LUID_VALID_KHR, cl_bool)
1516CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LUID_KHR, luid_array)
1517CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_NODE_MASK_KHR, cl_uint)
1520#if defined(cl_khr_pci_bus_info)
1521CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_PCI_BUS_INFO_KHR, cl_device_pci_bus_info_khr)
1524#if defined(cl_khr_integer_dot_product)
1525CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGER_DOT_PRODUCT_CAPABILITIES_KHR, cl_device_integer_dot_product_capabilities_khr)
1528#ifdef CL_PLATFORM_ICD_SUFFIX_KHR
1529CL_HPP_DECLARE_PARAM_TRAITS_(cl_platform_info, CL_PLATFORM_ICD_SUFFIX_KHR,
string)
1532#ifdef CL_DEVICE_PROFILING_TIMER_OFFSET_AMD
1533CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_PROFILING_TIMER_OFFSET_AMD, cl_ulong)
1535#ifdef CL_DEVICE_GLOBAL_FREE_MEMORY_AMD
1536CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_FREE_MEMORY_AMD, vector<size_type>)
1538#ifdef CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD
1539CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD, cl_uint)
1541#ifdef CL_DEVICE_SIMD_WIDTH_AMD
1542CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_WIDTH_AMD, cl_uint)
1544#ifdef CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD
1545CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD, cl_uint)
1547#ifdef CL_DEVICE_WAVEFRONT_WIDTH_AMD
1548CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_WAVEFRONT_WIDTH_AMD, cl_uint)
1550#ifdef CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD
1551CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD, cl_uint)
1553#ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD
1554CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD, cl_uint)
1556#ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD
1557CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD, cl_uint)
1559#ifdef CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD
1560CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD, cl_uint)
1562#ifdef CL_DEVICE_LOCAL_MEM_BANKS_AMD
1563CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LOCAL_MEM_BANKS_AMD, cl_uint)
1566#ifdef CL_DEVICE_COMPUTE_UNITS_BITFIELD_ARM
1567CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_UNITS_BITFIELD_ARM, cl_ulong)
1569#ifdef CL_DEVICE_JOB_SLOTS_ARM
1570CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_JOB_SLOTS_ARM, cl_uint)
1572#ifdef CL_DEVICE_SCHEDULING_CONTROLS_CAPABILITIES_ARM
1573CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SCHEDULING_CONTROLS_CAPABILITIES_ARM, cl_bitfield)
1575#ifdef CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_ARM
1576CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_ARM, cl_uint)
1578#ifdef CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_MODIFIER_ARM
1579CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_MODIFIER_ARM, cl_int)
1582#ifdef CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV
1583CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV, cl_uint)
1585#ifdef CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV
1586CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV, cl_uint)
1588#ifdef CL_DEVICE_REGISTERS_PER_BLOCK_NV
1589CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_REGISTERS_PER_BLOCK_NV, cl_uint)
1591#ifdef CL_DEVICE_WARP_SIZE_NV
1592CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_WARP_SIZE_NV, cl_uint)
1594#ifdef CL_DEVICE_GPU_OVERLAP_NV
1595CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GPU_OVERLAP_NV, cl_bool)
1597#ifdef CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV
1598CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV, cl_bool)
1600#ifdef CL_DEVICE_INTEGRATED_MEMORY_NV
1601CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGRATED_MEMORY_NV, cl_bool)
1606template <
typename Func,
typename T>
1608getInfo(Func f, cl_uint name, T* param)
1610 return getInfoHelper(f, name, param, 0);
1613template <
typename Func,
typename Arg0>
1616 Func f_;
const Arg0& arg0_;
1618 cl_uint param, size_type size,
void* value, size_type* size_ret)
1619 {
return f_(arg0_, param, size, value, size_ret); }
1622template <
typename Func,
typename Arg0,
typename Arg1>
1625 Func f_;
const Arg0& arg0_;
const Arg1& arg1_;
1627 cl_uint param, size_type size,
void* value, size_type* size_ret)
1628 {
return f_(arg0_, arg1_, param, size, value, size_ret); }
1631template <
typename Func,
typename Arg0,
typename T>
1633getInfo(Func f,
const Arg0& arg0, cl_uint name, T* param)
1636 return getInfoHelper(f0, name, param, 0);
1639template <
typename Func,
typename Arg0,
typename Arg1,
typename T>
1641getInfo(Func f,
const Arg0& arg0,
const Arg1& arg1, cl_uint name, T* param)
1643 GetInfoFunctor1<Func, Arg0, Arg1> f0 = { f, arg0, arg1 };
1644 return getInfoHelper(f0, name, param, 0);
1652#if CL_HPP_TARGET_OPENCL_VERSION >= 120
1669 { return ::clRetainDevice(device); }
1680 { return ::clReleaseDevice(device); }
1687struct ReferenceHandler<cl_device_id>
1690 static cl_int retain(cl_device_id)
1691 {
return CL_SUCCESS; }
1693 static cl_int release(cl_device_id)
1694 {
return CL_SUCCESS; }
1702 static cl_int retain(cl_platform_id)
1703 {
return CL_SUCCESS; }
1705 static cl_int release(cl_platform_id)
1706 {
return CL_SUCCESS; }
1712 static cl_int retain(cl_context context)
1713 { return ::clRetainContext(context); }
1714 static cl_int release(cl_context context)
1715 { return ::clReleaseContext(context); }
1721 static cl_int retain(cl_command_queue queue)
1722 { return ::clRetainCommandQueue(queue); }
1723 static cl_int release(cl_command_queue queue)
1724 { return ::clReleaseCommandQueue(queue); }
1730 static cl_int retain(cl_mem memory)
1731 { return ::clRetainMemObject(memory); }
1732 static cl_int release(cl_mem memory)
1733 { return ::clReleaseMemObject(memory); }
1739 static cl_int retain(cl_sampler sampler)
1740 { return ::clRetainSampler(sampler); }
1741 static cl_int release(cl_sampler sampler)
1742 { return ::clReleaseSampler(sampler); }
1748 static cl_int retain(cl_program program)
1749 { return ::clRetainProgram(program); }
1750 static cl_int release(cl_program program)
1751 { return ::clReleaseProgram(program); }
1757 static cl_int retain(cl_kernel kernel)
1758 { return ::clRetainKernel(kernel); }
1759 static cl_int release(cl_kernel kernel)
1760 { return ::clReleaseKernel(kernel); }
1766 static cl_int retain(cl_event event)
1767 { return ::clRetainEvent(event); }
1768 static cl_int release(cl_event event)
1769 { return ::clReleaseEvent(event); }
1773#if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
1775static cl_uint getVersion(
const vector<char> &versionInfo)
1777 int highVersion = 0;
1780 while(versionInfo[index] !=
'.' ) {
1782 highVersion += versionInfo[index]-
'0';
1786 while(versionInfo[index] !=
' ' && versionInfo[index] !=
'\0') {
1788 lowVersion += versionInfo[index]-
'0';
1791 return (highVersion << 16) | lowVersion;
1794static cl_uint getPlatformVersion(cl_platform_id platform)
1797 clGetPlatformInfo(platform, CL_PLATFORM_VERSION, 0, NULL, &size);
1799 vector<char> versionInfo(size);
1800 clGetPlatformInfo(platform, CL_PLATFORM_VERSION, size, versionInfo.data(), &size);
1801 return getVersion(versionInfo);
1804static cl_uint getDevicePlatformVersion(cl_device_id device)
1806 cl_platform_id platform;
1807 clGetDeviceInfo(device, CL_DEVICE_PLATFORM,
sizeof(platform), &platform, NULL);
1808 return getPlatformVersion(platform);
1811static cl_uint getContextPlatformVersion(cl_context context)
1816 clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, NULL, &size);
1819 vector<cl_device_id> devices(size/
sizeof(cl_device_id));
1820 clGetContextInfo(context, CL_CONTEXT_DEVICES, size, devices.data(), NULL);
1821 return getDevicePlatformVersion(devices[0]);
1825template <
typename T>
1837 Wrapper(
const cl_type &obj,
bool retainObject) : object_(obj)
1840 detail::errHandler(retain(), __RETAIN_ERR);
1846 if (object_ != NULL) { release(); }
1851 object_ = rhs.object_;
1852 detail::errHandler(retain(), __RETAIN_ERR);
1857 object_ = rhs.object_;
1864 detail::errHandler(release(), __RELEASE_ERR);
1865 object_ = rhs.object_;
1866 detail::errHandler(retain(), __RETAIN_ERR);
1874 detail::errHandler(release(), __RELEASE_ERR);
1875 object_ = rhs.object_;
1883 detail::errHandler(release(), __RELEASE_ERR);
1888 const cl_type& operator ()()
const {
return object_; }
1890 cl_type& operator ()() {
return object_; }
1892 cl_type get()
const {
return object_; }
1895 template<
typename Func,
typename U>
1896 friend inline cl_int getInfoHelper(Func, cl_uint, U*,
int,
typename U::cl_type);
1898 cl_int retain()
const
1900 if (object_ !=
nullptr) {
1908 cl_int release()
const
1910 if (object_ !=
nullptr) {
1923 typedef cl_device_id cl_type;
1927 bool referenceCountable_;
1929 static bool isReferenceCountable(cl_device_id device)
1931 bool retVal =
false;
1932#if CL_HPP_TARGET_OPENCL_VERSION >= 120
1933#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
1934 if (device != NULL) {
1935 int version = getDevicePlatformVersion(device);
1936 if(version > ((1 << 16) + 1)) {
1948 Wrapper() : object_(NULL), referenceCountable_(
false)
1952 Wrapper(
const cl_type &obj,
bool retainObject) :
1954 referenceCountable_(
false)
1956 referenceCountable_ = isReferenceCountable(obj);
1959 detail::errHandler(retain(), __RETAIN_ERR);
1970 object_ = rhs.object_;
1971 referenceCountable_ = isReferenceCountable(object_);
1972 detail::errHandler(retain(), __RETAIN_ERR);
1977 object_ = rhs.object_;
1978 referenceCountable_ = rhs.referenceCountable_;
1980 rhs.referenceCountable_ =
false;
1986 detail::errHandler(release(), __RELEASE_ERR);
1987 object_ = rhs.object_;
1988 referenceCountable_ = rhs.referenceCountable_;
1989 detail::errHandler(retain(), __RETAIN_ERR);
1997 detail::errHandler(release(), __RELEASE_ERR);
1998 object_ = rhs.object_;
1999 referenceCountable_ = rhs.referenceCountable_;
2001 rhs.referenceCountable_ =
false;
2008 detail::errHandler(release(), __RELEASE_ERR);
2010 referenceCountable_ = isReferenceCountable(object_);
2014 const cl_type& operator ()()
const {
return object_; }
2016 cl_type& operator ()() {
return object_; }
2018 cl_type get()
const {
return object_; }
2021 template<
typename Func,
typename U>
2022 friend inline cl_int getInfoHelper(Func, cl_uint, U*,
int,
typename U::cl_type);
2024 template<
typename Func,
typename U>
2025 friend inline cl_int getInfoHelper(Func, cl_uint, vector<U>*,
int,
typename U::cl_type);
2027 cl_int retain()
const
2029 if( object_ !=
nullptr && referenceCountable_ ) {
2037 cl_int release()
const
2039 if (object_ !=
nullptr && referenceCountable_) {
2048template <
typename T>
2051 return lhs() == rhs();
2054template <
typename T>
2055inline bool operator!=(
const Wrapper<T> &lhs,
const Wrapper<T> &rhs)
2057 return !operator==(lhs, rhs);
2064using BuildLogType = vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, CL_PROGRAM_BUILD_LOG>::param_type>>;
2065#if defined(CL_HPP_ENABLE_EXCEPTIONS)
2069class BuildError :
public Error
2072 BuildLogType buildLogs;
2074 BuildError(cl_int err,
const char * errStr,
const BuildLogType &vec) : Error(err, errStr), buildLogs(vec)
2078 BuildLogType getBuildLog()
const
2084 static inline cl_int buildErrHandler(
2086 const char * errStr,
2087 const BuildLogType &buildLogs)
2089 if (err != CL_SUCCESS) {
2090 throw BuildError(err, errStr, buildLogs);
2098 static inline cl_int buildErrHandler(
2100 const char * errStr,
2101 const BuildLogType &buildLogs)
2124 image_channel_order = order;
2125 image_channel_data_type = type;
2135 this->image_channel_data_type = rhs.image_channel_data_type;
2136 this->image_channel_order = rhs.image_channel_order;
2152 static std::once_flag default_initialized_;
2154 static cl_int default_error_;
2161 static void makeDefault();
2168 static void makeDefaultProvided(
const Device &p) {
2173#ifdef CL_HPP_UNIT_TEST_ENABLE
2180 static void unitTestClearDefault() {
2192 explicit Device(
const cl_device_id &device,
bool retainObject =
false) :
2193 detail::Wrapper<cl_type>(device, retainObject) { }
2200 cl_int *errResult = NULL)
2202 std::call_once(default_initialized_, makeDefault);
2203 detail::errHandler(default_error_);
2204 if (errResult != NULL) {
2205 *errResult = default_error_;
2219 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_device));
2220 detail::errHandler(default_error_);
2263 template <
typename T>
2264 cl_int
getInfo(cl_device_info name, T* param)
const
2266 return detail::errHandler(
2267 detail::getInfo(&::clGetDeviceInfo, object_, name, param),
2268 __GET_DEVICE_INFO_ERR);
2272 template <cl_device_info name>
typename
2277 detail::cl_device_info, name>::param_type param;
2278 cl_int result =
getInfo(name, ¶m);
2286#if CL_HPP_TARGET_OPENCL_VERSION >= 210
2295 cl_ulong retVal = 0;
2297 clGetHostTimer(this->get(), &retVal);
2300 __GET_HOST_TIMER_ERR);
2319 std::pair<cl_ulong, cl_ulong> retVal;
2321 clGetDeviceAndHostTimer(this->get(), &(retVal.first), &(retVal.second));
2324 __GET_DEVICE_AND_HOST_TIMER_ERR);
2335#if CL_HPP_TARGET_OPENCL_VERSION >= 120
2338 const cl_device_partition_property * properties,
2339 vector<Device>* devices)
2342 cl_int err = clCreateSubDevices(object_, properties, 0, NULL, &n);
2343 if (err != CL_SUCCESS) {
2344 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2347 vector<cl_device_id> ids(n);
2348 err = clCreateSubDevices(object_, properties, n, ids.data(), NULL);
2349 if (err != CL_SUCCESS) {
2350 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2356 devices->resize(ids.size());
2360 for (size_type i = 0; i < ids.size(); i++) {
2363 (*devices)[i] =
Device(ids[i],
false);
2369#elif defined(CL_HPP_USE_CL_DEVICE_FISSION)
2375 const cl_device_partition_property_ext * properties,
2376 vector<Device>* devices)
2378 typedef CL_API_ENTRY cl_int
2379 ( CL_API_CALL * PFN_clCreateSubDevicesEXT)(
2381 const cl_device_partition_property_ext * ,
2384 cl_uint * ) CL_API_SUFFIX__VERSION_1_1;
2386 static PFN_clCreateSubDevicesEXT pfn_clCreateSubDevicesEXT = NULL;
2387 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateSubDevicesEXT);
2390 cl_int err = pfn_clCreateSubDevicesEXT(object_, properties, 0, NULL, &n);
2391 if (err != CL_SUCCESS) {
2392 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2395 vector<cl_device_id> ids(n);
2396 err = pfn_clCreateSubDevicesEXT(object_, properties, n, ids.data(), NULL);
2397 if (err != CL_SUCCESS) {
2398 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2403 devices->resize(ids.size());
2407 for (size_type i = 0; i < ids.size(); i++) {
2410 (*devices)[i] =
Device(ids[i],
false);
2418CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Device::default_initialized_;
2419CL_HPP_DEFINE_STATIC_MEMBER_ Device Device::default_;
2420CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Device::default_error_ = CL_SUCCESS;
2432 static std::once_flag default_initialized_;
2434 static cl_int default_error_;
2441 static void makeDefault() {
2445#if defined(CL_HPP_ENABLE_EXCEPTIONS)
2453 cl_int err = ::clGetPlatformIDs(0, NULL, &n);
2454 if (err != CL_SUCCESS) {
2455 default_error_ = err;
2459 default_error_ = CL_INVALID_PLATFORM;
2463 vector<cl_platform_id> ids(n);
2464 err = ::clGetPlatformIDs(n, ids.data(), NULL);
2465 if (err != CL_SUCCESS) {
2466 default_error_ = err;
2472#if defined(CL_HPP_ENABLE_EXCEPTIONS)
2473 catch (cl::Error &e) {
2474 default_error_ = e.err();
2484 static void makeDefaultProvided(
const Platform &p) {
2489#ifdef CL_HPP_UNIT_TEST_ENABLE
2496 static void unitTestClearDefault() {
2511 explicit Platform(
const cl_platform_id &platform,
bool retainObject =
false) :
2512 detail::Wrapper<cl_type>(platform, retainObject) { }
2525 cl_int *errResult = NULL)
2527 std::call_once(default_initialized_, makeDefault);
2528 detail::errHandler(default_error_);
2529 if (errResult != NULL) {
2530 *errResult = default_error_;
2544 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_platform));
2545 detail::errHandler(default_error_);
2550 template <
typename T>
2551 cl_int
getInfo(cl_platform_info name, T* param)
const
2553 return detail::errHandler(
2554 detail::getInfo(&::clGetPlatformInfo, object_, name, param),
2555 __GET_PLATFORM_INFO_ERR);
2559 template <cl_platform_info name>
typename
2564 detail::cl_platform_info, name>::param_type param;
2565 cl_int result =
getInfo(name, ¶m);
2577 cl_device_type type,
2578 vector<Device>* devices)
const
2581 if( devices == NULL ) {
2582 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR);
2584 cl_int err = ::clGetDeviceIDs(object_, type, 0, NULL, &n);
2585 if (err != CL_SUCCESS && err != CL_DEVICE_NOT_FOUND) {
2586 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2589 vector<cl_device_id> ids(n);
2591 err = ::clGetDeviceIDs(object_, type, n, ids.data(), NULL);
2592 if (err != CL_SUCCESS) {
2593 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2602 devices->resize(ids.size());
2606 for (size_type i = 0; i < ids.size(); i++) {
2607 (*devices)[i] =
Device(ids[i],
true);
2613#if defined(CL_HPP_USE_DX_INTEROP)
2638 cl_d3d10_device_source_khr d3d_device_source,
2640 cl_d3d10_device_set_khr d3d_device_set,
2641 vector<Device>* devices)
const
2643 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clGetDeviceIDsFromD3D10KHR)(
2644 cl_platform_id platform,
2645 cl_d3d10_device_source_khr d3d_device_source,
2647 cl_d3d10_device_set_khr d3d_device_set,
2648 cl_uint num_entries,
2649 cl_device_id * devices,
2650 cl_uint* num_devices);
2652 if( devices == NULL ) {
2653 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR);
2656 static PFN_clGetDeviceIDsFromD3D10KHR pfn_clGetDeviceIDsFromD3D10KHR = NULL;
2657 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(object_, clGetDeviceIDsFromD3D10KHR);
2660 cl_int err = pfn_clGetDeviceIDsFromD3D10KHR(
2668 if (err != CL_SUCCESS) {
2669 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2672 vector<cl_device_id> ids(n);
2673 err = pfn_clGetDeviceIDsFromD3D10KHR(
2681 if (err != CL_SUCCESS) {
2682 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2690 devices->resize(ids.size());
2694 for (size_type i = 0; i < ids.size(); i++) {
2695 (*devices)[i] = Device(ids[i],
true);
2707 vector<Platform>* platforms)
2711 if( platforms == NULL ) {
2712 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_PLATFORM_IDS_ERR);
2715 cl_int err = ::clGetPlatformIDs(0, NULL, &n);
2716 if (err != CL_SUCCESS) {
2717 return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
2720 vector<cl_platform_id> ids(n);
2721 err = ::clGetPlatformIDs(n, ids.data(), NULL);
2722 if (err != CL_SUCCESS) {
2723 return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
2727 platforms->resize(ids.size());
2730 for (size_type i = 0; i < ids.size(); i++) {
2731 (*platforms)[i] =
Platform(ids[i]);
2745 Platform default_platform = Platform::getDefault(&err);
2747 *platform = default_platform;
2761 cl_int * errResult = NULL)
2764 Platform default_platform = Platform::getDefault(&err);
2768 return default_platform;
2771#if CL_HPP_TARGET_OPENCL_VERSION >= 120
2776 return ::clUnloadPlatformCompiler(object_);
2781CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Platform::default_initialized_;
2782CL_HPP_DEFINE_STATIC_MEMBER_ Platform Platform::default_;
2783CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Platform::default_error_ = CL_SUCCESS;
2789#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
2794inline CL_API_PREFIX__VERSION_1_1_DEPRECATED cl_int
2799 return ::clUnloadCompiler();
2815 static std::once_flag default_initialized_;
2817 static cl_int default_error_;
2824 static void makeDefault() {
2828#if defined(CL_HPP_ENABLE_EXCEPTIONS)
2832#if !defined(__APPLE__) && !defined(__MACOS)
2833 const Platform &p = Platform::getDefault();
2834 cl_platform_id defaultPlatform = p();
2835 cl_context_properties properties[3] = {
2836 CL_CONTEXT_PLATFORM, (cl_context_properties)defaultPlatform, 0
2839 cl_context_properties *properties =
nullptr;
2843 CL_DEVICE_TYPE_DEFAULT,
2849#if defined(CL_HPP_ENABLE_EXCEPTIONS)
2850 catch (cl::Error &e) {
2851 default_error_ = e.err();
2862 static void makeDefaultProvided(
const Context &c) {
2867#ifdef CL_HPP_UNIT_TEST_ENABLE
2874 static void unitTestClearDefault() {
2884 const vector<Device>& devices,
2885 const cl_context_properties* properties = NULL,
2886 void (CL_CALLBACK * notifyFptr)(
2896 size_type numDevices = devices.size();
2897 vector<cl_device_id> deviceIDs(numDevices);
2899 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
2900 deviceIDs[deviceIndex] = (devices[deviceIndex])();
2903 object_ = ::clCreateContext(
2904 properties, (cl_uint) numDevices,
2906 notifyFptr, data, &error);
2908 detail::errHandler(error, __CREATE_CONTEXT_ERR);
2920 const cl_context_properties* properties = NULL,
2921 void (CL_CALLBACK * notifyFptr)(
2931 cl_device_id deviceID = device();
2933 object_ = ::clCreateContext(
2936 notifyFptr, data, &error);
2938 detail::errHandler(error, __CREATE_CONTEXT_ERR);
2949 cl_device_type type,
2950 const cl_context_properties* properties = NULL,
2951 void (CL_CALLBACK * notifyFptr)(
2961#if !defined(__APPLE__) && !defined(__MACOS)
2962 cl_context_properties prop[4] = {CL_CONTEXT_PLATFORM, 0, 0, 0 };
2964 if (properties == NULL) {
2966 vector<Platform> platforms;
2967 error = Platform::get(&platforms);
2968 if (error != CL_SUCCESS) {
2969 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
2977 cl_context_properties platform_id = 0;
2978 for (
unsigned int i = 0; i < platforms.size(); i++) {
2980 vector<Device> devices;
2982#if defined(CL_HPP_ENABLE_EXCEPTIONS)
2986 error = platforms[i].getDevices(type, &devices);
2988#if defined(CL_HPP_ENABLE_EXCEPTIONS)
2989 }
catch (cl::Error& e) {
2997 if (error != CL_SUCCESS && error != CL_DEVICE_NOT_FOUND) {
2998 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
3004 if (devices.size() > 0) {
3005 platform_id = (cl_context_properties)platforms[i]();
3010 if (platform_id == 0) {
3011 detail::errHandler(CL_DEVICE_NOT_FOUND, __CREATE_CONTEXT_FROM_TYPE_ERR);
3013 *err = CL_DEVICE_NOT_FOUND;
3018 prop[1] = platform_id;
3019 properties = &prop[0];
3022 object_ = ::clCreateContextFromType(
3023 properties, type, notifyFptr, data, &error);
3025 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
3066 std::call_once(default_initialized_, makeDefault);
3067 detail::errHandler(default_error_);
3069 *err = default_error_;
3083 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_context));
3084 detail::errHandler(default_error_);
3096 explicit Context(
const cl_context& context,
bool retainObject =
false) :
3097 detail::Wrapper<cl_type>(context, retainObject) { }
3111 template <
typename T>
3112 cl_int
getInfo(cl_context_info name, T* param)
const
3114 return detail::errHandler(
3115 detail::getInfo(&::clGetContextInfo, object_, name, param),
3116 __GET_CONTEXT_INFO_ERR);
3120 template <cl_context_info name>
typename
3125 detail::cl_context_info, name>::param_type param;
3126 cl_int result =
getInfo(name, ¶m);
3139 cl_mem_object_type type,
3140 vector<ImageFormat>* formats)
const
3148 cl_int err = ::clGetSupportedImageFormats(
3155 if (err != CL_SUCCESS) {
3156 return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
3159 if (numEntries > 0) {
3160 vector<ImageFormat> value(numEntries);
3161 err = ::clGetSupportedImageFormats(
3166 (cl_image_format*)value.data(),
3168 if (err != CL_SUCCESS) {
3169 return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
3172 formats->assign(begin(value), end(value));
3183inline void Device::makeDefault()
3188#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3195 detail::errHandler(error, __CREATE_CONTEXT_ERR);
3197 if (error != CL_SUCCESS) {
3198 default_error_ = error;
3201 default_ = context.
getInfo<CL_CONTEXT_DEVICES>()[0];
3202 default_error_ = CL_SUCCESS;
3205#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3206 catch (cl::Error &e) {
3207 default_error_ = e.err();
3212CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Context::default_initialized_;
3213CL_HPP_DEFINE_STATIC_MEMBER_ Context Context::default_;
3214CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Context::default_error_ = CL_SUCCESS;
3228 Event() : detail::Wrapper<cl_type>() { }
3238 explicit Event(
const cl_event& event,
bool retainObject =
false) :
3239 detail::Wrapper<cl_type>(event, retainObject) { }
3253 template <
typename T>
3254 cl_int
getInfo(cl_event_info name, T* param)
const
3256 return detail::errHandler(
3257 detail::getInfo(&::clGetEventInfo, object_, name, param),
3258 __GET_EVENT_INFO_ERR);
3262 template <cl_event_info name>
typename
3267 detail::cl_event_info, name>::param_type param;
3268 cl_int result =
getInfo(name, ¶m);
3276 template <
typename T>
3279 return detail::errHandler(detail::getInfo(
3280 &::clGetEventProfilingInfo, object_, name, param),
3281 __GET_EVENT_PROFILE_INFO_ERR);
3285 template <cl_profiling_info name>
typename
3290 detail::cl_profiling_info, name>::param_type param;
3304 return detail::errHandler(
3305 ::clWaitForEvents(1, &object_),
3306 __WAIT_FOR_EVENTS_ERR);
3309#if CL_HPP_TARGET_OPENCL_VERSION >= 110
3316 void (CL_CALLBACK * pfn_notify)(cl_event, cl_int,
void *),
3317 void * user_data = NULL)
3319 return detail::errHandler(
3320 ::clSetEventCallback(
3325 __SET_EVENT_CALLBACK_ERR);
3336 return detail::errHandler(
3338 (cl_uint) events.size(), (events.size() > 0) ? (cl_event*)&events.front() : NULL),
3339 __WAIT_FOR_EVENTS_ERR);
3343#if CL_HPP_TARGET_OPENCL_VERSION >= 110
3357 cl_int * err = NULL)
3360 object_ = ::clCreateUserEvent(
3364 detail::errHandler(error, __CREATE_USER_EVENT_ERR);
3379 return detail::errHandler(
3380 ::clSetUserEventStatus(object_,status),
3381 __SET_USER_EVENT_STATUS_ERR);
3391WaitForEvents(
const vector<Event>& events)
3393 return detail::errHandler(
3395 (cl_uint) events.size(), (events.size() > 0) ? (cl_event*)&events.front() : NULL),
3396 __WAIT_FOR_EVENTS_ERR);
3424 explicit Memory(
const cl_mem& memory,
bool retainObject) :
3425 detail::Wrapper<cl_type>(memory, retainObject) { }
3468 template <
typename T>
3471 return detail::errHandler(
3472 detail::getInfo(&::clGetMemObjectInfo, object_, name, param),
3473 __GET_MEM_OBJECT_INFO_ERR);
3477 template <cl_mem_info name>
typename
3482 detail::cl_mem_info, name>::param_type param;
3483 cl_int result =
getInfo(name, ¶m);
3490#if CL_HPP_TARGET_OPENCL_VERSION >= 110
3505 void (CL_CALLBACK * pfn_notify)(cl_mem,
void *),
3506 void * user_data = NULL)
3508 return detail::errHandler(
3509 ::clSetMemObjectDestructorCallback(
3513 __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR);
3521template<
typename IteratorType >
3522cl_int
copy( IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer );
3523template<
typename IteratorType >
3524cl_int
copy(
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator );
3525template<
typename IteratorType >
3526cl_int
copy(
const CommandQueue &queue, IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer );
3527template<
typename IteratorType >
3528cl_int
copy(
const CommandQueue &queue,
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator );
3531#if CL_HPP_TARGET_OPENCL_VERSION >= 200
3537 static cl_svm_mem_flags getSVMMemFlags()
3544template<
class Trait = detail::SVMTraitNull>
3548 static cl_svm_mem_flags getSVMMemFlags()
3550 return CL_MEM_READ_WRITE |
3551 Trait::getSVMMemFlags();
3555template<
class Trait = detail::SVMTraitNull>
3559 static cl_svm_mem_flags getSVMMemFlags()
3561 return CL_MEM_READ_ONLY |
3562 Trait::getSVMMemFlags();
3566template<
class Trait = detail::SVMTraitNull>
3570 static cl_svm_mem_flags getSVMMemFlags()
3572 return CL_MEM_WRITE_ONLY |
3573 Trait::getSVMMemFlags();
3577template<
class Trait = SVMTraitReadWrite<>>
3581 static cl_svm_mem_flags getSVMMemFlags()
3583 return Trait::getSVMMemFlags();
3587template<
class Trait = SVMTraitReadWrite<>>
3591 static cl_svm_mem_flags getSVMMemFlags()
3593 return CL_MEM_SVM_FINE_GRAIN_BUFFER |
3594 Trait::getSVMMemFlags();
3598template<
class Trait = SVMTraitReadWrite<>>
3602 static cl_svm_mem_flags getSVMMemFlags()
3605 CL_MEM_SVM_FINE_GRAIN_BUFFER |
3606 CL_MEM_SVM_ATOMICS |
3607 Trait::getSVMMemFlags();
3618 const vector<Event>* events = NULL,
3619 Event* event = NULL);
3632template<
typename T,
class SVMTrait>
3638 typedef T value_type;
3639 typedef value_type* pointer;
3640 typedef const value_type* const_pointer;
3641 typedef value_type& reference;
3642 typedef const value_type& const_reference;
3643 typedef std::size_t size_type;
3644 typedef std::ptrdiff_t difference_type;
3646 template<
typename U>
3652 template<
typename U,
typename V>
3656 context_(
Context::getDefault())
3666 SVMAllocator(
const SVMAllocator &other) :
3667 context_(other.context_)
3671 template<
typename U>
3672 SVMAllocator(
const SVMAllocator<U, SVMTrait> &other) :
3673 context_(other.context_)
3681 pointer address(reference r) CL_HPP_NOEXCEPT_
3683 return std::addressof(r);
3686 const_pointer address(const_reference r) CL_HPP_NOEXCEPT_
3688 return std::addressof(r);
3699 typename cl::SVMAllocator<void, SVMTrait>::const_pointer = 0)
3705 SVMTrait::getSVMMemFlags(),
3708 pointer retValue =
reinterpret_cast<pointer
>(
3710#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3712 std::bad_alloc excep;
3718 if (!(SVMTrait::getSVMMemFlags() & CL_MEM_SVM_FINE_GRAIN_BUFFER)) {
3719 cl_int err =
enqueueMapSVM(retValue, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE, size*
sizeof(T));
3720 if (err != CL_SUCCESS) {
3721 std::bad_alloc excep;
3730 void deallocate(pointer p, size_type)
3732 clSVMFree(context_(), p);
3741 size_type maxSize = std::numeric_limits<size_type>::max() /
sizeof(T);
3743 for (
const Device &d : context_.
getInfo<CL_CONTEXT_DEVICES>()) {
3746 static_cast<size_type
>(d.getInfo<CL_DEVICE_MAX_MEM_ALLOC_SIZE>()));
3752 template<
class U,
class... Args >
3753 void construct(U* p, Args&&... args)
3769 return (context_==rhs.context_);
3779template<
class SVMTrait>
3782 typedef void value_type;
3783 typedef value_type* pointer;
3784 typedef const value_type* const_pointer;
3786 template<
typename U>
3792 template<
typename U,
typename V>
3796#if !defined(CL_HPP_NO_STD_UNIQUE_PTR)
3799 template<
class Alloc>
3806 typedef typename std::allocator_traits<Alloc>::pointer pointer;
3808 Deleter(
const Alloc &alloc, size_type copies) : alloc_{ alloc }, copies_{ copies }
3812 void operator()(pointer ptr)
const {
3813 Alloc tmpAlloc{ alloc_ };
3814 std::allocator_traits<Alloc>::destroy(tmpAlloc, std::addressof(*ptr));
3815 std::allocator_traits<Alloc>::deallocate(tmpAlloc, ptr, copies_);
3826template <
class T,
class Alloc,
class... Args>
3829 Alloc alloc(alloc_);
3830 static const size_type copies = 1;
3835 T* tmp = std::allocator_traits<Alloc>::allocate(alloc, copies);
3837 std::bad_alloc excep;
3841 std::allocator_traits<Alloc>::construct(
3843 std::addressof(*tmp),
3844 std::forward<Args>(args)...);
3848 catch (std::bad_alloc& b)
3850 std::allocator_traits<Alloc>::deallocate(alloc, tmp, copies);
3855template<
class T,
class SVMTrait,
class... Args >
3856cl::pointer<T, detail::Deleter<SVMAllocator<T, SVMTrait>>> allocate_svm(Args... args)
3858 SVMAllocator<T, SVMTrait> alloc;
3859 return cl::allocate_pointer<T>(alloc, args...);
3862template<
class T,
class SVMTrait,
class... Args >
3863cl::pointer<T, detail::Deleter<SVMAllocator<T, SVMTrait>>> allocate_svm(
const cl::Context &c, Args... args)
3865 SVMAllocator<T, SVMTrait> alloc(c);
3866 return cl::allocate_pointer<T>(alloc, args...);
3912 void* host_ptr = NULL,
3916 object_ = ::clCreateBuffer(context(), flags, size, host_ptr, &error);
3918 detail::errHandler(error, __CREATE_BUFFER_ERR);
3936 void* host_ptr = NULL,
3943 object_ = ::clCreateBuffer(context(), flags, size, host_ptr, &error);
3945 detail::errHandler(error, __CREATE_BUFFER_ERR);
3956 template<
typename IteratorType >
3958 IteratorType startIterator,
3959 IteratorType endIterator,
3961 bool useHostPtr =
false,
3964 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
3967 cl_mem_flags flags = 0;
3969 flags |= CL_MEM_READ_ONLY;
3972 flags |= CL_MEM_READ_WRITE;
3975 flags |= CL_MEM_USE_HOST_PTR;
3978 size_type size =
sizeof(DataType)*(endIterator - startIterator);
3983 object_ = ::clCreateBuffer(context(), flags, size,
static_cast<DataType*
>(&*startIterator), &error);
3985 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
3988 detail::errHandler(error, __CREATE_BUFFER_ERR);
3994 error =
cl::copy(startIterator, endIterator, *
this);
3995 detail::errHandler(error, __CREATE_BUFFER_ERR);
4007 template<
typename IteratorType >
4008 Buffer(
const Context &context, IteratorType startIterator, IteratorType endIterator,
4009 bool readOnly,
bool useHostPtr =
false, cl_int* err = NULL);
4015 template<
typename IteratorType >
4016 Buffer(
const CommandQueue &queue, IteratorType startIterator, IteratorType endIterator,
4017 bool readOnly,
bool useHostPtr =
false, cl_int* err = NULL);
4029 explicit Buffer(
const cl_mem& buffer,
bool retainObject =
false) :
4030 Memory(buffer, retainObject) { }
4070#if CL_HPP_TARGET_OPENCL_VERSION >= 110
4077 cl_buffer_create_type buffer_create_type,
4078 const void * buffer_create_info,
4079 cl_int * err = NULL)
4083 result.object_ = ::clCreateSubBuffer(
4090 detail::errHandler(error, __CREATE_SUBBUFFER_ERR);
4100#if defined (CL_HPP_USE_DX_INTEROP)
4109class BufferD3D10 :
public Buffer
4120 const Context& context,
4122 ID3D10Buffer* bufobj,
4123 cl_int * err = NULL) : pfn_clCreateFromD3D10BufferKHR(nullptr)
4125 typedef CL_API_ENTRY cl_mem (CL_API_CALL *PFN_clCreateFromD3D10BufferKHR)(
4126 cl_context context, cl_mem_flags flags, ID3D10Buffer* buffer,
4127 cl_int* errcode_ret);
4128 PFN_clCreateFromD3D10BufferKHR pfn_clCreateFromD3D10BufferKHR;
4129#if CL_HPP_TARGET_OPENCL_VERSION >= 120
4130 vector<cl_context_properties> props = context.getInfo<CL_CONTEXT_PROPERTIES>();
4131 cl_platform platform = -1;
4132 for(
int i = 0; i < props.size(); ++i ) {
4133 if( props[i] == CL_CONTEXT_PLATFORM ) {
4134 platform = props[i+1];
4137 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCreateFromD3D10BufferKHR);
4138#elif CL_HPP_TARGET_OPENCL_VERSION >= 110
4139 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateFromD3D10BufferKHR);
4143 object_ = pfn_clCreateFromD3D10BufferKHR(
4149 detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
4156 BufferD3D10() : Buffer() { }
4165 explicit BufferD3D10(
const cl_mem& buffer,
bool retainObject =
false) :
4166 Buffer(buffer, retainObject) { }
4172 BufferD3D10& operator = (
const cl_mem& rhs)
4174 Buffer::operator=(rhs);
4181 BufferD3D10(
const BufferD3D10& buf) :
4187 BufferD3D10& operator = (
const BufferD3D10 &buf)
4189 Buffer::operator=(buf);
4196 BufferD3D10(BufferD3D10&& buf) CL_HPP_NOEXCEPT_ : Buffer(std::move(buf)) {}
4201 BufferD3D10& operator = (BufferD3D10 &&buf)
4203 Buffer::operator=(std::move(buf));
4229 cl_int * err = NULL)
4232 object_ = ::clCreateFromGLBuffer(
4238 detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
4254 explicit BufferGL(
const cl_mem& buffer,
bool retainObject =
false) :
4255 Buffer(buffer, retainObject) { }
4297 cl_gl_object_type *type,
4298 cl_GLuint * gl_object_name)
4300 return detail::errHandler(
4301 ::clGetGLObjectInfo(object_,type,gl_object_name),
4302 __GET_GL_OBJECT_INFO_ERR);
4326 cl_int * err = NULL)
4329 object_ = ::clCreateFromGLRenderbuffer(
4335 detail::errHandler(error, __CREATE_GL_RENDER_BUFFER_ERR);
4352 Buffer(buffer, retainObject) { }
4394 cl_gl_object_type *type,
4395 cl_GLuint * gl_object_name)
4397 return detail::errHandler(
4398 ::clGetGLObjectInfo(object_,type,gl_object_name),
4399 __GET_GL_OBJECT_INFO_ERR);
4422 explicit Image(
const cl_mem& image,
bool retainObject =
false) :
4423 Memory(image, retainObject) { }
4466 template <
typename T>
4469 return detail::errHandler(
4470 detail::getInfo(&::clGetImageInfo, object_, name, param),
4471 __GET_IMAGE_INFO_ERR);
4475 template <cl_image_info name>
typename
4480 detail::cl_image_info, name>::param_type param;
4489#if CL_HPP_TARGET_OPENCL_VERSION >= 120
4508 void* host_ptr = NULL,
4513 cl_image_desc desc = {0};
4514 desc.image_type = CL_MEM_OBJECT_IMAGE1D;
4515 desc.image_width = width;
4517 object_ = ::clCreateImage(
4525 detail::errHandler(error, __CREATE_IMAGE_ERR);
4541 explicit Image1D(
const cl_mem& image1D,
bool retainObject =
false) :
4542 Image(image1D, retainObject) { }
4600 cl_image_desc desc = {0};
4601 desc.image_type = CL_MEM_OBJECT_IMAGE1D_BUFFER;
4602 desc.image_width = width;
4603 desc.buffer = buffer();
4605 object_ = ::clCreateImage(
4613 detail::errHandler(error, __CREATE_IMAGE_ERR);
4629 Image(image1D, retainObject) { }
4677 size_type arraySize,
4680 void* host_ptr = NULL,
4685 cl_image_desc desc = {0};
4686 desc.image_type = CL_MEM_OBJECT_IMAGE1D_ARRAY;
4687 desc.image_width = width;
4688 desc.image_array_size = arraySize;
4689 desc.image_row_pitch = rowPitch;
4691 object_ = ::clCreateImage(
4699 detail::errHandler(error, __CREATE_IMAGE_ERR);
4714 explicit Image1DArray(
const cl_mem& imageArray,
bool retainObject =
false) :
4715 Image(imageArray, retainObject) { }
4775 size_type row_pitch = 0,
4776 void* host_ptr = NULL,
4780 bool useCreateImage;
4782#if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
4785 cl_uint version = detail::getContextPlatformVersion(context());
4786 useCreateImage = (version >= 0x10002);
4788#elif CL_HPP_TARGET_OPENCL_VERSION >= 120
4789 useCreateImage =
true;
4791 useCreateImage =
false;
4794#if CL_HPP_TARGET_OPENCL_VERSION >= 120
4797 cl_image_desc desc = {0};
4798 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
4799 desc.image_width = width;
4800 desc.image_height = height;
4801 desc.image_row_pitch = row_pitch;
4803 object_ = ::clCreateImage(
4811 detail::errHandler(error, __CREATE_IMAGE_ERR);
4817#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
4818 if (!useCreateImage)
4820 object_ = ::clCreateImage2D(
4821 context(), flags,&format, width, height, row_pitch, host_ptr, &error);
4823 detail::errHandler(error, __CREATE_IMAGE2D_ERR);
4831#if CL_HPP_TARGET_OPENCL_VERSION >= 200 || defined(CL_HPP_USE_CL_IMAGE2D_FROM_BUFFER_KHR)
4840 const Buffer &sourceBuffer,
4843 size_type row_pitch = 0,
4844 cl_int* err =
nullptr)
4848 cl_image_desc desc = {0};
4849 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
4850 desc.image_width = width;
4851 desc.image_height = height;
4852 desc.image_row_pitch = row_pitch;
4853 desc.buffer = sourceBuffer();
4855 object_ = ::clCreateImage(
4863 detail::errHandler(error, __CREATE_IMAGE_ERR);
4864 if (err !=
nullptr) {
4870#if CL_HPP_TARGET_OPENCL_VERSION >= 200
4885 cl_channel_order order,
4886 const Image &sourceImage,
4887 cl_int* err =
nullptr)
4892 size_type sourceWidth =
4894 size_type sourceHeight =
4896 size_type sourceRowPitch =
4898 cl_uint sourceNumMIPLevels =
4900 cl_uint sourceNumSamples =
4902 cl_image_format sourceFormat =
4907 sourceFormat.image_channel_order = order;
4909 cl_image_desc desc = {0};
4910 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
4911 desc.image_width = sourceWidth;
4912 desc.image_height = sourceHeight;
4913 desc.image_row_pitch = sourceRowPitch;
4914 desc.num_mip_levels = sourceNumMIPLevels;
4915 desc.num_samples = sourceNumSamples;
4916 desc.buffer = sourceImage();
4918 object_ = ::clCreateImage(
4926 detail::errHandler(error, __CREATE_IMAGE_ERR);
4927 if (err !=
nullptr) {
4943 explicit Image2D(
const cl_mem& image2D,
bool retainObject =
false) :
4944 Image(image2D, retainObject) { }
4987#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
5011 cl_int * err = NULL)
5014 object_ = ::clCreateFromGLTexture2D(
5022 detail::errHandler(error, __CREATE_GL_TEXTURE_2D_ERR);
5039 explicit Image2DGL(
const cl_mem& image,
bool retainObject =
false) :
5040 Image2D(image, retainObject) { }
5048 Image2D::operator=(rhs);
5062 Image2D::operator=(img);
5076 Image2D::operator=(std::move(img));
5080} CL_API_SUFFIX__VERSION_1_1_DEPRECATED;
5083#if CL_HPP_TARGET_OPENCL_VERSION >= 120
5094 size_type arraySize,
5098 size_type slicePitch,
5099 void* host_ptr = NULL,
5104 cl_image_desc desc = {0};
5105 desc.image_type = CL_MEM_OBJECT_IMAGE2D_ARRAY;
5106 desc.image_width = width;
5107 desc.image_height = height;
5108 desc.image_array_size = arraySize;
5109 desc.image_row_pitch = rowPitch;
5110 desc.image_slice_pitch = slicePitch;
5112 object_ = ::clCreateImage(
5120 detail::errHandler(error, __CREATE_IMAGE_ERR);
5135 explicit Image2DArray(
const cl_mem& imageArray,
bool retainObject =
false) :
Image(imageArray, retainObject) { }
5193 size_type row_pitch = 0,
5194 size_type slice_pitch = 0,
5195 void* host_ptr = NULL,
5199 bool useCreateImage;
5201#if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
5204 cl_uint version = detail::getContextPlatformVersion(context());
5205 useCreateImage = (version >= 0x10002);
5207#elif CL_HPP_TARGET_OPENCL_VERSION >= 120
5208 useCreateImage =
true;
5210 useCreateImage =
false;
5213#if CL_HPP_TARGET_OPENCL_VERSION >= 120
5216 cl_image_desc desc = {0};
5217 desc.image_type = CL_MEM_OBJECT_IMAGE3D;
5218 desc.image_width = width;
5219 desc.image_height = height;
5220 desc.image_depth = depth;
5221 desc.image_row_pitch = row_pitch;
5222 desc.image_slice_pitch = slice_pitch;
5224 object_ = ::clCreateImage(
5232 detail::errHandler(error, __CREATE_IMAGE_ERR);
5238#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
5239 if (!useCreateImage)
5241 object_ = ::clCreateImage3D(
5242 context(), flags, &format, width, height, depth, row_pitch,
5243 slice_pitch, host_ptr, &error);
5245 detail::errHandler(error, __CREATE_IMAGE3D_ERR);
5263 explicit Image3D(
const cl_mem& image3D,
bool retainObject =
false) :
5264 Image(image3D, retainObject) { }
5305#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
5328 cl_int * err = NULL)
5331 object_ = ::clCreateFromGLTexture3D(
5339 detail::errHandler(error, __CREATE_GL_TEXTURE_3D_ERR);
5355 explicit Image3DGL(
const cl_mem& image,
bool retainObject =
false) :
5356 Image3D(image, retainObject) { }
5398#if CL_HPP_TARGET_OPENCL_VERSION >= 120
5414 cl_int * err = NULL)
5417 object_ = ::clCreateFromGLTexture(
5425 detail::errHandler(error, __CREATE_GL_TEXTURE_ERR);
5440 explicit ImageGL(
const cl_mem& image,
bool retainObject =
false) :
5441 Image(image, retainObject) { }
5443 ImageGL& operator = (
const cl_mem& rhs)
5481#if CL_HPP_TARGET_OPENCL_VERSION >= 200
5503 cl_uint packet_size,
5504 cl_uint max_packets,
5509 cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS;
5510 object_ = ::clCreatePipe(context(), flags, packet_size, max_packets,
nullptr, &error);
5512 detail::errHandler(error, __CREATE_PIPE_ERR);
5527 cl_uint packet_size,
5528 cl_uint max_packets,
5535 cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS;
5536 object_ = ::clCreatePipe(context(), flags, packet_size, max_packets,
nullptr, &error);
5538 detail::errHandler(error, __CREATE_PIPE_ERR);
5554 explicit Pipe(
const cl_mem& pipe,
bool retainObject =
false) :
5555 Memory(pipe, retainObject) { }
5596 template <
typename T>
5599 return detail::errHandler(
5600 detail::getInfo(&::clGetPipeInfo, object_, name, param),
5601 __GET_PIPE_INFO_ERR);
5605 template <cl_pipe_info name>
typename
5610 detail::cl_pipe_info, name>::param_type param;
5611 cl_int result =
getInfo(name, ¶m);
5641 cl_bool normalized_coords,
5642 cl_addressing_mode addressing_mode,
5643 cl_filter_mode filter_mode,
5648#if CL_HPP_TARGET_OPENCL_VERSION >= 200
5649 cl_sampler_properties sampler_properties[] = {
5650 CL_SAMPLER_NORMALIZED_COORDS, normalized_coords,
5651 CL_SAMPLER_ADDRESSING_MODE, addressing_mode,
5652 CL_SAMPLER_FILTER_MODE, filter_mode,
5654 object_ = ::clCreateSamplerWithProperties(
5659 detail::errHandler(error, __CREATE_SAMPLER_WITH_PROPERTIES_ERR);
5664 object_ = ::clCreateSampler(
5671 detail::errHandler(error, __CREATE_SAMPLER_ERR);
5686 explicit Sampler(
const cl_sampler& sampler,
bool retainObject =
false) :
5687 detail::Wrapper<cl_type>(sampler, retainObject) { }
5729 template <
typename T>
5730 cl_int
getInfo(cl_sampler_info name, T* param)
const
5732 return detail::errHandler(
5733 detail::getInfo(&::clGetSamplerInfo, object_, name, param),
5734 __GET_SAMPLER_INFO_ERR);
5738 template <cl_sampler_info name>
typename
5743 detail::cl_sampler_info, name>::param_type param;
5744 cl_int result =
getInfo(name, ¶m);
5754class DeviceCommandQueue;
5761 size_type sizes_[3];
5762 cl_uint dimensions_;
5793 NDRange(size_type size0, size_type size1, size_type size2)
5805 operator const size_type*()
const {
5819 return dimensions_*
sizeof(size_type);
5827 const size_type* get()
const
5834static const NDRange NullRange;
5844template <
typename T,
class Enable =
void>
5849template <
typename T>
5852 static size_type size(
const T&) {
return sizeof(T); }
5853 static const T* ptr(
const T& value) {
return &value; }
5858template <
typename T>
5861 static size_type size(
const T&) {
return sizeof(cl_mem); }
5862 static const cl_mem* ptr(
const T& value) {
return &(value()); }
5870 static size_type size(
const LocalSpaceArg& value) {
return value.size_; }
5871 static const void* ptr(
const LocalSpaceArg&) {
return NULL; }
5898 inline Kernel(
const Program& program,
const char* name, cl_int* err = NULL);
5911 explicit Kernel(
const cl_kernel& kernel,
bool retainObject =
false) :
5912 detail::Wrapper<cl_type>(kernel, retainObject) { }
5953 template <
typename T>
5954 cl_int getInfo(cl_kernel_info name, T* param)
const
5956 return detail::errHandler(
5957 detail::getInfo(&::clGetKernelInfo, object_, name, param),
5958 __GET_KERNEL_INFO_ERR);
5961 template <cl_kernel_info name>
typename
5962 detail::param_traits<detail::cl_kernel_info, name>::param_type
5963 getInfo(cl_int* err = NULL)
const
5965 typename detail::param_traits<
5966 detail::cl_kernel_info, name>::param_type param;
5967 cl_int result = getInfo(name, ¶m);
5974#if CL_HPP_TARGET_OPENCL_VERSION >= 120
5975 template <
typename T>
5976 cl_int getArgInfo(cl_uint argIndex, cl_kernel_arg_info name, T* param)
const
5978 return detail::errHandler(
5979 detail::getInfo(&::clGetKernelArgInfo, object_, argIndex, name, param),
5980 __GET_KERNEL_ARG_INFO_ERR);
5983 template <cl_kernel_arg_info name>
typename
5984 detail::param_traits<detail::cl_kernel_arg_info, name>::param_type
5985 getArgInfo(cl_uint argIndex, cl_int* err = NULL)
const
5987 typename detail::param_traits<
5988 detail::cl_kernel_arg_info, name>::param_type param;
5989 cl_int result = getArgInfo(argIndex, name, ¶m);
5997 template <
typename T>
5998 cl_int getWorkGroupInfo(
5999 const Device& device, cl_kernel_work_group_info name, T* param)
const
6001 return detail::errHandler(
6003 &::clGetKernelWorkGroupInfo, object_, device(), name, param),
6004 __GET_KERNEL_WORK_GROUP_INFO_ERR);
6007 template <cl_kernel_work_group_info name>
typename
6008 detail::param_traits<detail::cl_kernel_work_group_info, name>::param_type
6009 getWorkGroupInfo(
const Device& device, cl_int* err = NULL)
const
6011 typename detail::param_traits<
6012 detail::cl_kernel_work_group_info, name>::param_type param;
6013 cl_int result = getWorkGroupInfo(device, name, ¶m);
6020#if (CL_HPP_TARGET_OPENCL_VERSION >= 200 && defined(CL_HPP_USE_CL_SUB_GROUPS_KHR)) || CL_HPP_TARGET_OPENCL_VERSION >= 210
6021 cl_int getSubGroupInfo(
const cl::Device &dev, cl_kernel_sub_group_info name,
const cl::NDRange &range, size_type* param)
const
6023#if CL_HPP_TARGET_OPENCL_VERSION >= 210
6025 return detail::errHandler(
6026 clGetKernelSubGroupInfo(object_, dev(), name, range.
size(), range.get(),
sizeof(size_type), param,
nullptr),
6027 __GET_KERNEL_SUB_GROUP_INFO_ERR);
6031 typedef clGetKernelSubGroupInfoKHR_fn PFN_clGetKernelSubGroupInfoKHR;
6032 static PFN_clGetKernelSubGroupInfoKHR pfn_clGetKernelSubGroupInfoKHR = NULL;
6033 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetKernelSubGroupInfoKHR);
6035 return detail::errHandler(
6036 pfn_clGetKernelSubGroupInfoKHR(object_, dev(), name, range.
size(), range.get(),
sizeof(size_type), param,
nullptr),
6037 __GET_KERNEL_SUB_GROUP_INFO_ERR);
6042 template <cl_kernel_sub_group_info name>
6043 size_type getSubGroupInfo(
const cl::Device &dev,
const cl::NDRange &range, cl_int* err = NULL)
const
6046 cl_int result = getSubGroupInfo(dev, name, range, ¶m);
6054#if CL_HPP_TARGET_OPENCL_VERSION >= 200
6057 template<
typename T,
class D>
6058 cl_int
setArg(cl_uint index,
const cl::pointer<T, D> &argPtr)
6060 return detail::errHandler(
6061 ::clSetKernelArgSVMPointer(object_, index, argPtr.get()),
6062 __SET_KERNEL_ARGS_ERR);
6067 template<
typename T,
class Alloc>
6068 cl_int
setArg(cl_uint index,
const cl::vector<T, Alloc> &argPtr)
6070 return detail::errHandler(
6071 ::clSetKernelArgSVMPointer(object_, index, argPtr.data()),
6072 __SET_KERNEL_ARGS_ERR);
6077 template<
typename T>
6078 typename std::enable_if<std::is_pointer<T>::value, cl_int>::type
6081 return detail::errHandler(
6082 ::clSetKernelArgSVMPointer(object_, index, argPtr),
6083 __SET_KERNEL_ARGS_ERR);
6089 template <
typename T>
6090 typename std::enable_if<!std::is_pointer<T>::value, cl_int>::type
6093 return detail::errHandler(
6099 __SET_KERNEL_ARGS_ERR);
6102 cl_int
setArg(cl_uint index, size_type size,
const void* argPtr)
6104 return detail::errHandler(
6105 ::clSetKernelArg(object_, index, size, argPtr),
6106 __SET_KERNEL_ARGS_ERR);
6109#if CL_HPP_TARGET_OPENCL_VERSION >= 200
6116 return detail::errHandler(
6117 ::clSetKernelExecInfo(
6119 CL_KERNEL_EXEC_INFO_SVM_PTRS,
6120 sizeof(
void*)*pointerList.size(),
6121 pointerList.data()));
6128 template<
int ArrayLength>
6131 return detail::errHandler(
6132 ::clSetKernelExecInfo(
6134 CL_KERNEL_EXEC_INFO_SVM_PTRS,
6135 sizeof(
void*)*pointerList.size(),
6136 pointerList.data()));
6152 cl_bool svmEnabled_ = svmEnabled ? CL_TRUE : CL_FALSE;
6153 return detail::errHandler(
6154 ::clSetKernelExecInfo(
6156 CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM,
6163 template<
int index,
int ArrayLength,
class D,
typename T0,
typename T1,
typename... Ts>
6164 void setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList,
const pointer<T0, D> &t0,
const pointer<T1, D> &t1, Ts & ... ts)
6166 pointerList[index] =
static_cast<void*
>(t0.get());
6167 setSVMPointersHelper<index + 1, ArrayLength>(pointerList, t1, ts...);
6170 template<
int index,
int ArrayLength,
typename T0,
typename T1,
typename... Ts>
6171 typename std::enable_if<std::is_pointer<T0>::value,
void>::type
6172 setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList, T0 t0, T1 t1, Ts... ts)
6174 pointerList[index] =
static_cast<void*
>(t0);
6175 setSVMPointersHelper<index + 1, ArrayLength>(pointerList, t1, ts...);
6178 template<
int index,
int ArrayLength,
typename T0,
class D>
6179 void setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList,
const pointer<T0, D> &t0)
6181 pointerList[index] =
static_cast<void*
>(t0.get());
6185 template<
int index,
int ArrayLength,
typename T0>
6186 typename std::enable_if<std::is_pointer<T0>::value,
void>::type
6187 setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList, T0 t0)
6189 pointerList[index] =
static_cast<void*
>(t0);
6192 template<
typename T0,
typename... Ts>
6195 std::array<
void*, 1 +
sizeof...(Ts)> pointerList;
6197 setSVMPointersHelper<0, 1 +
sizeof...(Ts)>(pointerList, t0, ts...);
6198 return detail::errHandler(
6199 ::clSetKernelExecInfo(
6201 CL_KERNEL_EXEC_INFO_SVM_PTRS,
6202 sizeof(
void*)*(1 +
sizeof...(Ts)),
6203 pointerList.data()));
6206 template<
typename T>
6207 cl_int setExecInfo(cl_kernel_exec_info param_name,
const T& val)
6209 return detail::errHandler(
6210 ::clSetKernelExecInfo(
6217 template<cl_kernel_exec_info name>
6218 cl_int setExecInfo(
typename detail::param_traits<detail::cl_kernel_exec_info, name>::param_type& val)
6220 return setExecInfo(name, val);
6224#if CL_HPP_TARGET_OPENCL_VERSION >= 210
6233 Kernel retValue(clCloneKernel(this->get(), &error));
6235 detail::errHandler(error, __CLONE_KERNEL_ERR);
6247#if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6248 typedef vector<vector<unsigned char>> Binaries;
6249 typedef vector<string> Sources;
6251 typedef vector<std::pair<const void*, size_type> > Binaries;
6252 typedef vector<std::pair<const char*, size_type> > Sources;
6256 const string& source,
6262 const char * strings = source.c_str();
6263 const size_type length = source.size();
6267 object_ = ::clCreateProgramWithSource(
6268 context(), (cl_uint)1, &strings, &length, &error);
6270 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6272 if (error == CL_SUCCESS && build) {
6274 error = ::clBuildProgram(
6278#
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6286 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6296 const string& source,
6302 const char * strings = source.c_str();
6303 const size_type length = source.size();
6305 object_ = ::clCreateProgramWithSource(
6306 context(), (cl_uint)1, &strings, &length, &error);
6308 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6310 if (error == CL_SUCCESS && build) {
6311 error = ::clBuildProgram(
6315#
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6323 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6336 const Sources& sources,
6342 const size_type n = (size_type)sources.size();
6344 vector<size_type> lengths(n);
6345 vector<const char*> strings(n);
6347 for (size_type i = 0; i < n; ++i) {
6348#if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6349 strings[i] = sources[(int)i].data();
6350 lengths[i] = sources[(int)i].length();
6352 strings[i] = sources[(int)i].first;
6353 lengths[i] = sources[(int)i].second;
6357 object_ = ::clCreateProgramWithSource(
6358 context(), (cl_uint)n, strings.data(), lengths.data(), &error);
6360 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6372 const Sources& sources,
6377 const size_type n = (size_type)sources.size();
6379 vector<size_type> lengths(n);
6380 vector<const char*> strings(n);
6382 for (size_type i = 0; i < n; ++i) {
6383#if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6384 strings[i] = sources[(int)i].data();
6385 lengths[i] = sources[(int)i].length();
6387 strings[i] = sources[(int)i].first;
6388 lengths[i] = sources[(int)i].second;
6392 object_ = ::clCreateProgramWithSource(
6393 context(), (cl_uint)n, strings.data(), lengths.data(), &error);
6395 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6402#if CL_HPP_TARGET_OPENCL_VERSION >= 210 || (CL_HPP_TARGET_OPENCL_VERSION==200 && defined(CL_HPP_USE_IL_KHR))
6408 const vector<char>& IL,
6416#if CL_HPP_TARGET_OPENCL_VERSION >= 210
6418 object_ = ::clCreateProgramWithIL(
6419 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6423 typedef clCreateProgramWithILKHR_fn PFN_clCreateProgramWithILKHR;
6424 static PFN_clCreateProgramWithILKHR pfn_clCreateProgramWithILKHR = NULL;
6425 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateProgramWithILKHR);
6427 return detail::errHandler(
6428 pfn_clCreateProgramWithILKHR(
6429 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6433 detail::errHandler(error, __CREATE_PROGRAM_WITH_IL_ERR);
6435 if (error == CL_SUCCESS && build) {
6437 error = ::clBuildProgram(
6441#
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6449 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6464 const vector<char>& IL,
6470#if CL_HPP_TARGET_OPENCL_VERSION >= 210
6472 object_ = ::clCreateProgramWithIL(
6473 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6477 typedef clCreateProgramWithILKHR_fn PFN_clCreateProgramWithILKHR;
6478 static PFN_clCreateProgramWithILKHR pfn_clCreateProgramWithILKHR = NULL;
6479 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateProgramWithILKHR);
6481 return detail::errHandler(
6482 pfn_clCreateProgramWithILKHR(
6483 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6487 detail::errHandler(error, __CREATE_PROGRAM_WITH_IL_ERR);
6489 if (error == CL_SUCCESS && build) {
6490 error = ::clBuildProgram(
6494#
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6502 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6532 const vector<Device>& devices,
6533 const Binaries& binaries,
6534 vector<cl_int>* binaryStatus = NULL,
6539 const size_type numDevices = devices.size();
6542 if(binaries.size() != numDevices) {
6543 error = CL_INVALID_VALUE;
6544 detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
6552 vector<size_type> lengths(numDevices);
6553 vector<const unsigned char*> images(numDevices);
6554#if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6555 for (size_type i = 0; i < numDevices; ++i) {
6556 images[i] = binaries[i].data();
6557 lengths[i] = binaries[(int)i].size();
6560 for (size_type i = 0; i < numDevices; ++i) {
6561 images[i] = (
const unsigned char*)binaries[i].first;
6562 lengths[i] = binaries[(int)i].second;
6566 vector<cl_device_id> deviceIDs(numDevices);
6567 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6568 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6572 binaryStatus->resize(numDevices);
6575 object_ = ::clCreateProgramWithBinary(
6576 context(), (cl_uint) devices.size(),
6578 lengths.data(), images.data(), (binaryStatus != NULL && numDevices > 0)
6579 ? &binaryStatus->front()
6582 detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
6589#if CL_HPP_TARGET_OPENCL_VERSION >= 120
6596 const vector<Device>& devices,
6597 const string& kernelNames,
6603 size_type numDevices = devices.size();
6604 vector<cl_device_id> deviceIDs(numDevices);
6605 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6606 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6609 object_ = ::clCreateProgramWithBuiltInKernels(
6611 (cl_uint) devices.size(),
6613 kernelNames.c_str(),
6616 detail::errHandler(error, __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR);
6632 explicit Program(
const cl_program& program,
bool retainObject =
false) :
6633 detail::Wrapper<cl_type>(program, retainObject) { }
6635 Program& operator = (
const cl_program& rhs)
6670 const vector<Device>& devices,
6671 const char* options = NULL,
6672 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6673 void* data = NULL)
const
6675 size_type numDevices = devices.size();
6676 vector<cl_device_id> deviceIDs(numDevices);
6678 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6679 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6682 cl_int buildError = ::clBuildProgram(
6691 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6695 const Device& device,
6696 const char* options = NULL,
6697 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6698 void* data = NULL)
const
6700 cl_device_id deviceID = device();
6702 cl_int buildError = ::clBuildProgram(
6710 BuildLogType buildLog(1);
6711 buildLog.push_back(std::make_pair(device, getBuildInfo<CL_PROGRAM_BUILD_LOG>(device)));
6712 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, buildLog);
6716 const char* options = NULL,
6717 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6718 void* data = NULL)
const
6720 cl_int buildError = ::clBuildProgram(
6728 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6731#if CL_HPP_TARGET_OPENCL_VERSION >= 120
6733 const char* options = NULL,
6734 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6735 void* data = NULL)
const
6737 cl_int error = ::clCompileProgram(
6747 return detail::buildErrHandler(error, __COMPILE_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6751 template <
typename T>
6752 cl_int getInfo(cl_program_info name, T* param)
const
6754 return detail::errHandler(
6755 detail::getInfo(&::clGetProgramInfo, object_, name, param),
6756 __GET_PROGRAM_INFO_ERR);
6759 template <cl_program_info name>
typename
6760 detail::param_traits<detail::cl_program_info, name>::param_type
6761 getInfo(cl_int* err = NULL)
const
6763 typename detail::param_traits<
6764 detail::cl_program_info, name>::param_type param;
6765 cl_int result = getInfo(name, ¶m);
6772 template <
typename T>
6773 cl_int getBuildInfo(
6774 const Device& device, cl_program_build_info name, T* param)
const
6776 return detail::errHandler(
6778 &::clGetProgramBuildInfo, object_, device(), name, param),
6779 __GET_PROGRAM_BUILD_INFO_ERR);
6782 template <cl_program_build_info name>
typename
6783 detail::param_traits<detail::cl_program_build_info, name>::param_type
6784 getBuildInfo(
const Device& device, cl_int* err = NULL)
const
6786 typename detail::param_traits<
6787 detail::cl_program_build_info, name>::param_type param;
6788 cl_int result = getBuildInfo(device, name, ¶m);
6800 template <cl_program_build_info name>
6801 vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, name>::param_type>>
6804 cl_int result = CL_SUCCESS;
6806 auto devs = getInfo<CL_PROGRAM_DEVICES>(&result);
6807 vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, name>::param_type>>
6811 if (result != CL_SUCCESS) {
6820 detail::cl_program_build_info, name>::param_type param;
6821 result = getBuildInfo(d, name, ¶m);
6825 if (result != CL_SUCCESS) {
6833 if (result != CL_SUCCESS) {
6839 cl_int createKernels(vector<Kernel>* kernels)
6842 cl_int err = ::clCreateKernelsInProgram(object_, 0, NULL, &numKernels);
6843 if (err != CL_SUCCESS) {
6844 return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
6847 vector<cl_kernel> value(numKernels);
6849 err = ::clCreateKernelsInProgram(
6850 object_, numKernels, value.data(), NULL);
6851 if (err != CL_SUCCESS) {
6852 return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
6856 kernels->resize(value.size());
6860 for (size_type i = 0; i < value.size(); i++) {
6863 (*kernels)[i] = Kernel(value[i],
false);
6869#if CL_HPP_TARGET_OPENCL_VERSION >= 220
6870#if defined(CL_USE_DEPRECATED_OPENCL_2_2_APIS)
6882 void (CL_CALLBACK * pfn_notify)(cl_program program,
void * user_data),
6883 void * user_data = NULL) CL_API_SUFFIX__VERSION_2_2_DEPRECATED
6885 return detail::errHandler(
6886 ::clSetProgramReleaseCallback(
6890 __SET_PROGRAM_RELEASE_CALLBACK_ERR);
6898 template <
typename T>
6899 typename std::enable_if<!std::is_pointer<T>::value, cl_int>::type
6902 return detail::errHandler(
6903 ::clSetProgramSpecializationConstant(
6908 __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR);
6917 return detail::errHandler(
6918 ::clSetProgramSpecializationConstant(
6923 __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR);
6928#if CL_HPP_TARGET_OPENCL_VERSION >= 120
6929inline Program linkProgram(
6932 const char* options = NULL,
6933 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6937 cl_int error_local = CL_SUCCESS;
6939 cl_program programs[2] = { input1(), input2() };
6941 Context ctx = input1.getInfo<CL_PROGRAM_CONTEXT>(&error_local);
6942 if(error_local!=CL_SUCCESS) {
6943 detail::errHandler(error_local, __LINK_PROGRAM_ERR);
6946 cl_program prog = ::clLinkProgram(
6957 detail::errHandler(error_local,__COMPILE_PROGRAM_ERR);
6962 return Program(prog);
6965inline Program linkProgram(
6966 vector<Program> inputPrograms,
6967 const char* options = NULL,
6968 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6972 cl_int error_local = CL_SUCCESS;
6974 vector<cl_program> programs(inputPrograms.size());
6976 for (
unsigned int i = 0; i < inputPrograms.size(); i++) {
6977 programs[i] = inputPrograms[i]();
6981 if(inputPrograms.size() > 0) {
6982 ctx = inputPrograms[0].getInfo<CL_PROGRAM_CONTEXT>(&error_local);
6983 if(error_local!=CL_SUCCESS) {
6984 detail::errHandler(error_local, __LINK_PROGRAM_ERR);
6987 cl_program prog = ::clLinkProgram(
6992 (cl_uint)inputPrograms.size(),
6998 detail::errHandler(error_local,__COMPILE_PROGRAM_ERR);
7003 return Program(prog,
false);
7009inline cl_int cl::Program::getInfo(cl_program_info name, vector<vector<unsigned char>>* param)
const
7011 if (name != CL_PROGRAM_BINARIES) {
7012 return CL_INVALID_VALUE;
7018 vector<size_type> sizes = getInfo<CL_PROGRAM_BINARY_SIZES>();
7019 size_type numBinaries = sizes.size();
7022 param->resize(numBinaries);
7023 for (size_type i = 0; i < numBinaries; ++i) {
7024 (*param)[i].resize(sizes[i]);
7027 return detail::errHandler(
7028 detail::getInfo(&::clGetProgramInfo, object_, name, param),
7029 __GET_PROGRAM_INFO_ERR);
7036inline vector<vector<unsigned char>> cl::Program::getInfo<CL_PROGRAM_BINARIES>(cl_int* err)
const
7038 vector<vector<unsigned char>> binariesVectors;
7040 cl_int result = getInfo(CL_PROGRAM_BINARIES, &binariesVectors);
7044 return binariesVectors;
7047#if CL_HPP_TARGET_OPENCL_VERSION >= 220
7052 cl_uchar ucValue = value ? CL_UCHAR_MAX : 0;
7053 return detail::errHandler(
7054 ::clSetProgramSpecializationConstant(
7059 __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR);
7063inline Kernel::Kernel(
const Program& program,
const char* name, cl_int* err)
7067 object_ = ::clCreateKernel(program(), name, &error);
7068 detail::errHandler(error, __CREATE_KERNEL_ERR);
7076enum class QueueProperties : cl_command_queue_properties
7079 Profiling = CL_QUEUE_PROFILING_ENABLE,
7080 OutOfOrder = CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE,
7083inline QueueProperties operator|(QueueProperties lhs, QueueProperties rhs)
7085 return static_cast<QueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) |
static_cast<cl_command_queue_properties
>(rhs));
7094 static std::once_flag default_initialized_;
7096 static cl_int default_error_;
7103 static void makeDefault()
7108#if defined(CL_HPP_ENABLE_EXCEPTIONS)
7115 if (error != CL_SUCCESS) {
7116 default_error_ = error;
7120 default_ =
CommandQueue(context, device, 0, &default_error_);
7123#if defined(CL_HPP_ENABLE_EXCEPTIONS)
7124 catch (cl::Error &e) {
7125 default_error_ = e.err();
7135 static void makeDefaultProvided(
const CommandQueue &c) {
7140#ifdef CL_HPP_UNIT_TEST_ENABLE
7147 static void unitTestClearDefault() {
7158 cl_command_queue_properties properties,
7164 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7166 if (error != CL_SUCCESS) {
7173 bool useWithProperties;
7175#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7178 cl_uint version = detail::getContextPlatformVersion(context());
7179 useWithProperties = (version >= 0x20000);
7181#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7182 useWithProperties =
true;
7184 useWithProperties =
false;
7187#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7188 if (useWithProperties) {
7189 cl_queue_properties queue_properties[] = {
7190 CL_QUEUE_PROPERTIES, properties, 0 };
7191 if ((properties & CL_QUEUE_ON_DEVICE) == 0) {
7192 object_ = ::clCreateCommandQueueWithProperties(
7193 context(), device(), queue_properties, &error);
7196 error = CL_INVALID_QUEUE_PROPERTIES;
7199 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7205#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7206 if (!useWithProperties) {
7207 object_ = ::clCreateCommandQueue(
7208 context(), device(), properties, &error);
7210 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7224 QueueProperties properties,
7230 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7232 if (error != CL_SUCCESS) {
7239 bool useWithProperties;
7241#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7244 cl_uint version = detail::getContextPlatformVersion(context());
7245 useWithProperties = (version >= 0x20000);
7247#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7248 useWithProperties =
true;
7250 useWithProperties =
false;
7253#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7254 if (useWithProperties) {
7255 cl_queue_properties queue_properties[] = {
7256 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
7258 object_ = ::clCreateCommandQueueWithProperties(
7259 context(), device(), queue_properties, &error);
7261 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7267#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7268 if (!useWithProperties) {
7269 object_ = ::clCreateCommandQueue(
7270 context(), device(),
static_cast<cl_command_queue_properties
>(properties), &error);
7272 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7288 cl_command_queue_properties properties = 0,
7292 bool useWithProperties;
7293 vector<cl::Device> devices;
7294 error = context.
getInfo(CL_CONTEXT_DEVICES, &devices);
7296 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7298 if (error != CL_SUCCESS)
7306#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7309 cl_uint version = detail::getContextPlatformVersion(context());
7310 useWithProperties = (version >= 0x20000);
7312#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7313 useWithProperties =
true;
7315 useWithProperties =
false;
7318#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7319 if (useWithProperties) {
7320 cl_queue_properties queue_properties[] = {
7321 CL_QUEUE_PROPERTIES, properties, 0 };
7322 if ((properties & CL_QUEUE_ON_DEVICE) == 0) {
7323 object_ = ::clCreateCommandQueueWithProperties(
7324 context(), devices[0](), queue_properties, &error);
7327 error = CL_INVALID_QUEUE_PROPERTIES;
7330 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7336#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7337 if (!useWithProperties) {
7338 object_ = ::clCreateCommandQueue(
7339 context(), devices[0](), properties, &error);
7341 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7355 QueueProperties properties,
7359 bool useWithProperties;
7360 vector<cl::Device> devices;
7361 error = context.
getInfo(CL_CONTEXT_DEVICES, &devices);
7363 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7365 if (error != CL_SUCCESS)
7373#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7376 cl_uint version = detail::getContextPlatformVersion(context());
7377 useWithProperties = (version >= 0x20000);
7379#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7380 useWithProperties =
true;
7382 useWithProperties =
false;
7385#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7386 if (useWithProperties) {
7387 cl_queue_properties queue_properties[] = {
7388 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
7389 object_ = ::clCreateCommandQueueWithProperties(
7390 context(), devices[0](), queue_properties, &error);
7392 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7398#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7399 if (!useWithProperties) {
7400 object_ = ::clCreateCommandQueue(
7401 context(), devices[0](),
static_cast<cl_command_queue_properties
>(properties), &error);
7403 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7418 cl_command_queue_properties properties = 0,
7422 bool useWithProperties;
7424#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7427 cl_uint version = detail::getContextPlatformVersion(context());
7428 useWithProperties = (version >= 0x20000);
7430#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7431 useWithProperties =
true;
7433 useWithProperties =
false;
7436#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7437 if (useWithProperties) {
7438 cl_queue_properties queue_properties[] = {
7439 CL_QUEUE_PROPERTIES, properties, 0 };
7440 object_ = ::clCreateCommandQueueWithProperties(
7441 context(), device(), queue_properties, &error);
7443 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7449#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7450 if (!useWithProperties) {
7451 object_ = ::clCreateCommandQueue(
7452 context(), device(), properties, &error);
7454 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7469 QueueProperties properties,
7473 bool useWithProperties;
7475#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7478 cl_uint version = detail::getContextPlatformVersion(context());
7479 useWithProperties = (version >= 0x20000);
7481#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7482 useWithProperties =
true;
7484 useWithProperties =
false;
7487#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7488 if (useWithProperties) {
7489 cl_queue_properties queue_properties[] = {
7490 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
7491 object_ = ::clCreateCommandQueueWithProperties(
7492 context(), device(), queue_properties, &error);
7494 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7500#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7501 if (!useWithProperties) {
7502 object_ = ::clCreateCommandQueue(
7503 context(), device(),
static_cast<cl_command_queue_properties
>(properties), &error);
7505 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7515 std::call_once(default_initialized_, makeDefault);
7516#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7517 detail::errHandler(default_error_, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7519 detail::errHandler(default_error_, __CREATE_COMMAND_QUEUE_ERR);
7522 *err = default_error_;
7536 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_queue));
7537 detail::errHandler(default_error_);
7550 explicit CommandQueue(
const cl_command_queue& commandQueue,
bool retainObject =
false) :
7551 detail::Wrapper<cl_type>(commandQueue, retainObject) { }
7587 template <
typename T>
7588 cl_int getInfo(cl_command_queue_info name, T* param)
const
7590 return detail::errHandler(
7592 &::clGetCommandQueueInfo, object_, name, param),
7593 __GET_COMMAND_QUEUE_INFO_ERR);
7596 template <cl_command_queue_info name>
typename
7597 detail::param_traits<detail::cl_command_queue_info, name>::param_type
7598 getInfo(cl_int* err = NULL)
const
7600 typename detail::param_traits<
7601 detail::cl_command_queue_info, name>::param_type param;
7602 cl_int result = getInfo(name, ¶m);
7609 cl_int enqueueReadBuffer(
7610 const Buffer& buffer,
7615 const vector<Event>* events = NULL,
7616 Event* event = NULL)
const
7619 cl_int err = detail::errHandler(
7620 ::clEnqueueReadBuffer(
7621 object_, buffer(), blocking, offset, size,
7623 (events != NULL) ? (cl_uint) events->size() : 0,
7624 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7625 (event != NULL) ? &tmp : NULL),
7626 __ENQUEUE_READ_BUFFER_ERR);
7628 if (event != NULL && err == CL_SUCCESS)
7634 cl_int enqueueWriteBuffer(
7635 const Buffer& buffer,
7640 const vector<Event>* events = NULL,
7641 Event* event = NULL)
const
7644 cl_int err = detail::errHandler(
7645 ::clEnqueueWriteBuffer(
7646 object_, buffer(), blocking, offset, size,
7648 (events != NULL) ? (cl_uint) events->size() : 0,
7649 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7650 (event != NULL) ? &tmp : NULL),
7651 __ENQUEUE_WRITE_BUFFER_ERR);
7653 if (event != NULL && err == CL_SUCCESS)
7659 cl_int enqueueCopyBuffer(
7662 size_type src_offset,
7663 size_type dst_offset,
7665 const vector<Event>* events = NULL,
7666 Event* event = NULL)
const
7669 cl_int err = detail::errHandler(
7670 ::clEnqueueCopyBuffer(
7671 object_, src(), dst(), src_offset, dst_offset, size,
7672 (events != NULL) ? (cl_uint) events->size() : 0,
7673 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7674 (event != NULL) ? &tmp : NULL),
7675 __ENQEUE_COPY_BUFFER_ERR);
7677 if (event != NULL && err == CL_SUCCESS)
7682#if CL_HPP_TARGET_OPENCL_VERSION >= 110
7683 cl_int enqueueReadBufferRect(
7684 const Buffer& buffer,
7686 const array<size_type, 3>& buffer_offset,
7687 const array<size_type, 3>& host_offset,
7688 const array<size_type, 3>& region,
7689 size_type buffer_row_pitch,
7690 size_type buffer_slice_pitch,
7691 size_type host_row_pitch,
7692 size_type host_slice_pitch,
7694 const vector<Event>* events = NULL,
7695 Event* event = NULL)
const
7698 cl_int err = detail::errHandler(
7699 ::clEnqueueReadBufferRect(
7703 buffer_offset.data(),
7711 (events != NULL) ? (cl_uint) events->size() : 0,
7712 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7713 (event != NULL) ? &tmp : NULL),
7714 __ENQUEUE_READ_BUFFER_RECT_ERR);
7716 if (event != NULL && err == CL_SUCCESS)
7722 cl_int enqueueWriteBufferRect(
7723 const Buffer& buffer,
7725 const array<size_type, 3>& buffer_offset,
7726 const array<size_type, 3>& host_offset,
7727 const array<size_type, 3>& region,
7728 size_type buffer_row_pitch,
7729 size_type buffer_slice_pitch,
7730 size_type host_row_pitch,
7731 size_type host_slice_pitch,
7733 const vector<Event>* events = NULL,
7734 Event* event = NULL)
const
7737 cl_int err = detail::errHandler(
7738 ::clEnqueueWriteBufferRect(
7742 buffer_offset.data(),
7750 (events != NULL) ? (cl_uint) events->size() : 0,
7751 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7752 (event != NULL) ? &tmp : NULL),
7753 __ENQUEUE_WRITE_BUFFER_RECT_ERR);
7755 if (event != NULL && err == CL_SUCCESS)
7761 cl_int enqueueCopyBufferRect(
7764 const array<size_type, 3>& src_origin,
7765 const array<size_type, 3>& dst_origin,
7766 const array<size_type, 3>& region,
7767 size_type src_row_pitch,
7768 size_type src_slice_pitch,
7769 size_type dst_row_pitch,
7770 size_type dst_slice_pitch,
7771 const vector<Event>* events = NULL,
7772 Event* event = NULL)
const
7775 cl_int err = detail::errHandler(
7776 ::clEnqueueCopyBufferRect(
7787 (events != NULL) ? (cl_uint) events->size() : 0,
7788 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7789 (event != NULL) ? &tmp : NULL),
7790 __ENQEUE_COPY_BUFFER_RECT_ERR);
7792 if (event != NULL && err == CL_SUCCESS)
7798#if CL_HPP_TARGET_OPENCL_VERSION >= 120
7810 template<
typename PatternType>
7813 PatternType pattern,
7816 const vector<Event>* events = NULL,
7817 Event* event = NULL)
const
7820 cl_int err = detail::errHandler(
7821 ::clEnqueueFillBuffer(
7824 static_cast<void*
>(&pattern),
7825 sizeof(PatternType),
7828 (events != NULL) ? (cl_uint) events->size() : 0,
7829 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7830 (
event != NULL) ? &tmp : NULL),
7831 __ENQUEUE_FILL_BUFFER_ERR);
7833 if (event != NULL && err == CL_SUCCESS)
7840 cl_int enqueueReadImage(
7843 const array<size_type, 3>& origin,
7844 const array<size_type, 3>& region,
7845 size_type row_pitch,
7846 size_type slice_pitch,
7848 const vector<Event>* events = NULL,
7849 Event* event = NULL)
const
7852 cl_int err = detail::errHandler(
7853 ::clEnqueueReadImage(
7862 (events != NULL) ? (cl_uint) events->size() : 0,
7863 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7864 (event != NULL) ? &tmp : NULL),
7865 __ENQUEUE_READ_IMAGE_ERR);
7867 if (event != NULL && err == CL_SUCCESS)
7873 cl_int enqueueWriteImage(
7876 const array<size_type, 3>& origin,
7877 const array<size_type, 3>& region,
7878 size_type row_pitch,
7879 size_type slice_pitch,
7881 const vector<Event>* events = NULL,
7882 Event* event = NULL)
const
7885 cl_int err = detail::errHandler(
7886 ::clEnqueueWriteImage(
7895 (events != NULL) ? (cl_uint) events->size() : 0,
7896 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7897 (event != NULL) ? &tmp : NULL),
7898 __ENQUEUE_WRITE_IMAGE_ERR);
7900 if (event != NULL && err == CL_SUCCESS)
7906 cl_int enqueueCopyImage(
7909 const array<size_type, 3>& src_origin,
7910 const array<size_type, 3>& dst_origin,
7911 const array<size_type, 3>& region,
7912 const vector<Event>* events = NULL,
7913 Event* event = NULL)
const
7916 cl_int err = detail::errHandler(
7917 ::clEnqueueCopyImage(
7924 (events != NULL) ? (cl_uint) events->size() : 0,
7925 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7926 (event != NULL) ? &tmp : NULL),
7927 __ENQUEUE_COPY_IMAGE_ERR);
7929 if (event != NULL && err == CL_SUCCESS)
7935#if CL_HPP_TARGET_OPENCL_VERSION >= 120
7945 cl_float4 fillColor,
7946 const array<size_type, 3>& origin,
7947 const array<size_type, 3>& region,
7948 const vector<Event>* events = NULL,
7949 Event* event = NULL)
const
7952 cl_int err = detail::errHandler(
7953 ::clEnqueueFillImage(
7956 static_cast<void*
>(&fillColor),
7959 (events != NULL) ? (cl_uint) events->size() : 0,
7960 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7961 (
event != NULL) ? &tmp : NULL),
7962 __ENQUEUE_FILL_IMAGE_ERR);
7964 if (event != NULL && err == CL_SUCCESS)
7980 const array<size_type, 3>& origin,
7981 const array<size_type, 3>& region,
7982 const vector<Event>* events = NULL,
7983 Event* event = NULL)
const
7986 cl_int err = detail::errHandler(
7987 ::clEnqueueFillImage(
7990 static_cast<void*
>(&fillColor),
7993 (events != NULL) ? (cl_uint) events->size() : 0,
7994 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7995 (
event != NULL) ? &tmp : NULL),
7996 __ENQUEUE_FILL_IMAGE_ERR);
7998 if (event != NULL && err == CL_SUCCESS)
8014 const array<size_type, 3>& origin,
8015 const array<size_type, 3>& region,
8016 const vector<Event>* events = NULL,
8017 Event* event = NULL)
const
8020 cl_int err = detail::errHandler(
8021 ::clEnqueueFillImage(
8024 static_cast<void*
>(&fillColor),
8027 (events != NULL) ? (cl_uint) events->size() : 0,
8028 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8029 (
event != NULL) ? &tmp : NULL),
8030 __ENQUEUE_FILL_IMAGE_ERR);
8032 if (event != NULL && err == CL_SUCCESS)
8039 cl_int enqueueCopyImageToBuffer(
8042 const array<size_type, 3>& src_origin,
8043 const array<size_type, 3>& region,
8044 size_type dst_offset,
8045 const vector<Event>* events = NULL,
8046 Event* event = NULL)
const
8049 cl_int err = detail::errHandler(
8050 ::clEnqueueCopyImageToBuffer(
8057 (events != NULL) ? (cl_uint) events->size() : 0,
8058 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8059 (event != NULL) ? &tmp : NULL),
8060 __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR);
8062 if (event != NULL && err == CL_SUCCESS)
8068 cl_int enqueueCopyBufferToImage(
8071 size_type src_offset,
8072 const array<size_type, 3>& dst_origin,
8073 const array<size_type, 3>& region,
8074 const vector<Event>* events = NULL,
8075 Event* event = NULL)
const
8078 cl_int err = detail::errHandler(
8079 ::clEnqueueCopyBufferToImage(
8086 (events != NULL) ? (cl_uint) events->size() : 0,
8087 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8088 (event != NULL) ? &tmp : NULL),
8089 __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR);
8091 if (event != NULL && err == CL_SUCCESS)
8097 void* enqueueMapBuffer(
8098 const Buffer& buffer,
8103 const vector<Event>* events = NULL,
8104 Event* event = NULL,
8105 cl_int* err = NULL)
const
8109 void * result = ::clEnqueueMapBuffer(
8110 object_, buffer(), blocking, flags, offset, size,
8111 (events != NULL) ? (cl_uint) events->size() : 0,
8112 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8113 (event != NULL) ? &tmp : NULL,
8116 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
8120 if (event != NULL && error == CL_SUCCESS)
8126 void* enqueueMapImage(
8127 const Image& buffer,
8130 const array<size_type, 3>& origin,
8131 const array<size_type, 3>& region,
8132 size_type * row_pitch,
8133 size_type * slice_pitch,
8134 const vector<Event>* events = NULL,
8135 Event* event = NULL,
8136 cl_int* err = NULL)
const
8140 void * result = ::clEnqueueMapImage(
8141 object_, buffer(), blocking, flags,
8144 row_pitch, slice_pitch,
8145 (events != NULL) ? (cl_uint) events->size() : 0,
8146 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8147 (event != NULL) ? &tmp : NULL,
8150 detail::errHandler(error, __ENQUEUE_MAP_IMAGE_ERR);
8154 if (event != NULL && error == CL_SUCCESS)
8159#if CL_HPP_TARGET_OPENCL_VERSION >= 200
8164 template<
typename T>
8170 const vector<Event>* events = NULL,
8171 Event* event = NULL)
const
8174 cl_int err = detail::errHandler(::clEnqueueSVMMap(
8175 object_, blocking, flags,
static_cast<void*
>(ptr), size,
8176 (events != NULL) ? (cl_uint)events->size() : 0,
8177 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8178 (
event != NULL) ? &tmp : NULL),
8179 __ENQUEUE_MAP_BUFFER_ERR);
8181 if (event != NULL && err == CL_SUCCESS)
8192 template<
typename T,
class D>
8194 cl::pointer<T, D> &ptr,
8198 const vector<Event>* events = NULL,
8199 Event* event = NULL)
const
8202 cl_int err = detail::errHandler(::clEnqueueSVMMap(
8203 object_, blocking, flags,
static_cast<void*
>(ptr.get()), size,
8204 (events != NULL) ? (cl_uint)events->size() : 0,
8205 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8206 (
event != NULL) ? &tmp : NULL),
8207 __ENQUEUE_MAP_BUFFER_ERR);
8209 if (event != NULL && err == CL_SUCCESS)
8219 template<
typename T,
class Alloc>
8221 cl::vector<T, Alloc> &container,
8224 const vector<Event>* events = NULL,
8225 Event* event = NULL)
const
8228 cl_int err = detail::errHandler(::clEnqueueSVMMap(
8229 object_, blocking, flags,
static_cast<void*
>(container.data()), container.size()*
sizeof(T),
8230 (events != NULL) ? (cl_uint)events->size() : 0,
8231 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8232 (
event != NULL) ? &tmp : NULL),
8233 __ENQUEUE_MAP_BUFFER_ERR);
8235 if (event != NULL && err == CL_SUCCESS)
8242 cl_int enqueueUnmapMemObject(
8245 const vector<Event>* events = NULL,
8246 Event* event = NULL)
const
8249 cl_int err = detail::errHandler(
8250 ::clEnqueueUnmapMemObject(
8251 object_, memory(), mapped_ptr,
8252 (events != NULL) ? (cl_uint) events->size() : 0,
8253 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8254 (event != NULL) ? &tmp : NULL),
8255 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8257 if (event != NULL && err == CL_SUCCESS)
8264#if CL_HPP_TARGET_OPENCL_VERSION >= 200
8269 template<
typename T>
8272 const vector<Event>* events = NULL,
8273 Event* event = NULL)
const
8276 cl_int err = detail::errHandler(
8277 ::clEnqueueSVMUnmap(
8278 object_,
static_cast<void*
>(ptr),
8279 (events != NULL) ? (cl_uint)events->size() : 0,
8280 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8281 (
event != NULL) ? &tmp : NULL),
8282 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8284 if (event != NULL && err == CL_SUCCESS)
8294 template<
typename T,
class D>
8296 cl::pointer<T, D> &ptr,
8297 const vector<Event>* events = NULL,
8298 Event* event = NULL)
const
8301 cl_int err = detail::errHandler(
8302 ::clEnqueueSVMUnmap(
8303 object_,
static_cast<void*
>(ptr.get()),
8304 (events != NULL) ? (cl_uint)events->size() : 0,
8305 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8306 (
event != NULL) ? &tmp : NULL),
8307 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8309 if (event != NULL && err == CL_SUCCESS)
8319 template<
typename T,
class Alloc>
8321 cl::vector<T, Alloc> &container,
8322 const vector<Event>* events = NULL,
8323 Event* event = NULL)
const
8326 cl_int err = detail::errHandler(
8327 ::clEnqueueSVMUnmap(
8328 object_,
static_cast<void*
>(container.data()),
8329 (events != NULL) ? (cl_uint)events->size() : 0,
8330 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8331 (
event != NULL) ? &tmp : NULL),
8332 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8334 if (event != NULL && err == CL_SUCCESS)
8341#if CL_HPP_TARGET_OPENCL_VERSION >= 120
8354 const vector<Event> *events = 0,
8355 Event *event = 0)
const
8358 cl_int err = detail::errHandler(
8359 ::clEnqueueMarkerWithWaitList(
8361 (events != NULL) ? (cl_uint) events->size() : 0,
8362 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8363 (
event != NULL) ? &tmp : NULL),
8364 __ENQUEUE_MARKER_WAIT_LIST_ERR);
8366 if (event != NULL && err == CL_SUCCESS)
8384 const vector<Event> *events = 0,
8385 Event *event = 0)
const
8388 cl_int err = detail::errHandler(
8389 ::clEnqueueBarrierWithWaitList(
8391 (events != NULL) ? (cl_uint) events->size() : 0,
8392 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8393 (
event != NULL) ? &tmp : NULL),
8394 __ENQUEUE_BARRIER_WAIT_LIST_ERR);
8396 if (event != NULL && err == CL_SUCCESS)
8407 const vector<Memory> &memObjects,
8408 cl_mem_migration_flags flags,
8409 const vector<Event>* events = NULL,
8415 vector<cl_mem> localMemObjects(memObjects.size());
8417 for(
int i = 0; i < (int)memObjects.size(); ++i ) {
8418 localMemObjects[i] = memObjects[i]();
8421 cl_int err = detail::errHandler(
8422 ::clEnqueueMigrateMemObjects(
8424 (cl_uint)memObjects.size(),
8425 localMemObjects.data(),
8427 (events != NULL) ? (cl_uint) events->size() : 0,
8428 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8429 (
event != NULL) ? &tmp : NULL),
8430 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8432 if (event != NULL && err == CL_SUCCESS)
8440#if CL_HPP_TARGET_OPENCL_VERSION >= 210
8446 template<
typename T>
8448 const cl::vector<T*> &svmRawPointers,
8449 const cl::vector<size_type> &sizes,
8450 cl_mem_migration_flags flags = 0,
8451 const vector<Event>* events = NULL,
8452 Event* event = NULL)
const
8455 cl_int err = detail::errHandler(::clEnqueueSVMMigrateMem(
8457 svmRawPointers.size(),
static_cast<void**
>(svmRawPointers.data()),
8460 (events != NULL) ? (cl_uint)events->size() : 0,
8461 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8462 (
event != NULL) ? &tmp : NULL),
8463 __ENQUEUE_MIGRATE_SVM_ERR);
8465 if (event != NULL && err == CL_SUCCESS)
8475 template<
typename T>
8477 const cl::vector<T*> &svmRawPointers,
8478 cl_mem_migration_flags flags = 0,
8479 const vector<Event>* events = NULL,
8480 Event* event = NULL)
const
8482 return enqueueMigrateSVM(svmRawPointers, cl::vector<size_type>(svmRawPointers.size()), flags, events, event);
8491 template<
typename T,
class D>
8493 const cl::vector<cl::pointer<T, D>> &svmPointers,
8494 const cl::vector<size_type> &sizes,
8495 cl_mem_migration_flags flags = 0,
8496 const vector<Event>* events = NULL,
8497 Event* event = NULL)
const
8499 cl::vector<void*> svmRawPointers;
8500 svmRawPointers.reserve(svmPointers.size());
8501 for (
auto p : svmPointers) {
8502 svmRawPointers.push_back(
static_cast<void*
>(p.get()));
8513 template<
typename T,
class D>
8515 const cl::vector<cl::pointer<T, D>> &svmPointers,
8516 cl_mem_migration_flags flags = 0,
8517 const vector<Event>* events = NULL,
8518 Event* event = NULL)
const
8520 return enqueueMigrateSVM(svmPointers, cl::vector<size_type>(svmPointers.size()), flags, events, event);
8528 template<
typename T,
class Alloc>
8530 const cl::vector<cl::vector<T, Alloc>> &svmContainers,
8531 const cl::vector<size_type> &sizes,
8532 cl_mem_migration_flags flags = 0,
8533 const vector<Event>* events = NULL,
8534 Event* event = NULL)
const
8536 cl::vector<void*> svmRawPointers;
8537 svmRawPointers.reserve(svmContainers.size());
8538 for (
auto p : svmContainers) {
8539 svmRawPointers.push_back(
static_cast<void*
>(p.data()));
8549 template<
typename T,
class Alloc>
8551 const cl::vector<cl::vector<T, Alloc>> &svmContainers,
8552 cl_mem_migration_flags flags = 0,
8553 const vector<Event>* events = NULL,
8554 Event* event = NULL)
const
8556 return enqueueMigrateSVM(svmContainers, cl::vector<size_type>(svmContainers.size()), flags, events, event);
8561 cl_int enqueueNDRangeKernel(
8565 const NDRange& local = NullRange,
8566 const vector<Event>* events = NULL,
8567 Event* event = NULL)
const
8570 cl_int err = detail::errHandler(
8571 ::clEnqueueNDRangeKernel(
8572 object_, kernel(), (cl_uint) global.
dimensions(),
8573 offset.
dimensions() != 0 ? (
const size_type*) offset : NULL,
8574 (const size_type*) global,
8575 local.dimensions() != 0 ? (const size_type*) local : NULL,
8576 (events != NULL) ? (cl_uint) events->size() : 0,
8577 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8578 (event != NULL) ? &tmp : NULL),
8579 __ENQUEUE_NDRANGE_KERNEL_ERR);
8581 if (event != NULL && err == CL_SUCCESS)
8587#if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
8588 CL_API_PREFIX__VERSION_1_2_DEPRECATED cl_int enqueueTask(
8589 const Kernel& kernel,
8590 const vector<Event>* events = NULL,
8591 Event* event = NULL)
const CL_API_SUFFIX__VERSION_1_2_DEPRECATED
8594 cl_int err = detail::errHandler(
8597 (events != NULL) ? (cl_uint) events->size() : 0,
8598 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8599 (event != NULL) ? &tmp : NULL),
8600 __ENQUEUE_TASK_ERR);
8602 if (event != NULL && err == CL_SUCCESS)
8609 cl_int enqueueNativeKernel(
8610 void (CL_CALLBACK *userFptr)(
void *),
8611 std::pair<void*, size_type> args,
8612 const vector<Memory>* mem_objects = NULL,
8613 const vector<const void*>* mem_locs = NULL,
8614 const vector<Event>* events = NULL,
8615 Event* event = NULL)
const
8617 size_type elements = 0;
8618 if (mem_objects != NULL) {
8619 elements = mem_objects->size();
8621 vector<cl_mem> mems(elements);
8622 for (
unsigned int i = 0; i < elements; i++) {
8623 mems[i] = ((*mem_objects)[i])();
8627 cl_int err = detail::errHandler(
8628 ::clEnqueueNativeKernel(
8629 object_, userFptr, args.first, args.second,
8630 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8632 (mem_locs != NULL && mem_locs->size() > 0) ? (const void **) &mem_locs->front() : NULL,
8633 (events != NULL) ? (cl_uint) events->size() : 0,
8634 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8635 (event != NULL) ? &tmp : NULL),
8636 __ENQUEUE_NATIVE_KERNEL);
8638 if (event != NULL && err == CL_SUCCESS)
8647#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
8648 CL_API_PREFIX__VERSION_1_1_DEPRECATED
8652 cl_int err = detail::errHandler(
8655 (event != NULL) ? &tmp : NULL),
8656 __ENQUEUE_MARKER_ERR);
8658 if (event != NULL && err == CL_SUCCESS)
8664 CL_API_PREFIX__VERSION_1_1_DEPRECATED
8665 cl_int enqueueWaitForEvents(
const vector<Event>& events)
const CL_API_SUFFIX__VERSION_1_1_DEPRECATED
8667 return detail::errHandler(
8668 ::clEnqueueWaitForEvents(
8670 (cl_uint) events.size(),
8671 events.size() > 0 ? (
const cl_event*) &events.front() : NULL),
8672 __ENQUEUE_WAIT_FOR_EVENTS_ERR);
8676 cl_int enqueueAcquireGLObjects(
8677 const vector<Memory>* mem_objects = NULL,
8678 const vector<Event>* events = NULL,
8679 Event* event = NULL)
const
8682 cl_int err = detail::errHandler(
8683 ::clEnqueueAcquireGLObjects(
8685 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8686 (mem_objects != NULL && mem_objects->size() > 0) ? (const cl_mem *) &mem_objects->front(): NULL,
8687 (events != NULL) ? (cl_uint) events->size() : 0,
8688 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8689 (event != NULL) ? &tmp : NULL),
8690 __ENQUEUE_ACQUIRE_GL_ERR);
8692 if (event != NULL && err == CL_SUCCESS)
8698 cl_int enqueueReleaseGLObjects(
8699 const vector<Memory>* mem_objects = NULL,
8700 const vector<Event>* events = NULL,
8701 Event* event = NULL)
const
8704 cl_int err = detail::errHandler(
8705 ::clEnqueueReleaseGLObjects(
8707 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8708 (mem_objects != NULL && mem_objects->size() > 0) ? (const cl_mem *) &mem_objects->front(): NULL,
8709 (events != NULL) ? (cl_uint) events->size() : 0,
8710 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8711 (event != NULL) ? &tmp : NULL),
8712 __ENQUEUE_RELEASE_GL_ERR);
8714 if (event != NULL && err == CL_SUCCESS)
8720#if defined (CL_HPP_USE_DX_INTEROP)
8721typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueAcquireD3D10ObjectsKHR)(
8722 cl_command_queue command_queue, cl_uint num_objects,
8723 const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
8724 const cl_event* event_wait_list, cl_event* event);
8725typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueReleaseD3D10ObjectsKHR)(
8726 cl_command_queue command_queue, cl_uint num_objects,
8727 const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
8728 const cl_event* event_wait_list, cl_event* event);
8730 cl_int enqueueAcquireD3D10Objects(
8731 const vector<Memory>* mem_objects = NULL,
8732 const vector<Event>* events = NULL,
8733 Event* event = NULL)
const
8735 static PFN_clEnqueueAcquireD3D10ObjectsKHR pfn_clEnqueueAcquireD3D10ObjectsKHR = NULL;
8736#if CL_HPP_TARGET_OPENCL_VERSION >= 120
8737 cl_context context = getInfo<CL_QUEUE_CONTEXT>();
8738 cl::Device device(getInfo<CL_QUEUE_DEVICE>());
8739 cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>();
8740 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueAcquireD3D10ObjectsKHR);
8742#if CL_HPP_TARGET_OPENCL_VERSION >= 110
8743 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueAcquireD3D10ObjectsKHR);
8747 cl_int err = detail::errHandler(
8748 pfn_clEnqueueAcquireD3D10ObjectsKHR(
8750 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8751 (mem_objects != NULL && mem_objects->size() > 0) ? (const cl_mem *) &mem_objects->front(): NULL,
8752 (events != NULL) ? (cl_uint) events->size() : 0,
8753 (events != NULL) ? (cl_event*) &events->front() : NULL,
8754 (event != NULL) ? &tmp : NULL),
8755 __ENQUEUE_ACQUIRE_GL_ERR);
8757 if (event != NULL && err == CL_SUCCESS)
8763 cl_int enqueueReleaseD3D10Objects(
8764 const vector<Memory>* mem_objects = NULL,
8765 const vector<Event>* events = NULL,
8766 Event* event = NULL)
const
8768 static PFN_clEnqueueReleaseD3D10ObjectsKHR pfn_clEnqueueReleaseD3D10ObjectsKHR = NULL;
8769#if CL_HPP_TARGET_OPENCL_VERSION >= 120
8770 cl_context context = getInfo<CL_QUEUE_CONTEXT>();
8771 cl::Device device(getInfo<CL_QUEUE_DEVICE>());
8772 cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>();
8773 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueReleaseD3D10ObjectsKHR);
8775#if CL_HPP_TARGET_OPENCL_VERSION >= 110
8776 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueReleaseD3D10ObjectsKHR);
8780 cl_int err = detail::errHandler(
8781 pfn_clEnqueueReleaseD3D10ObjectsKHR(
8783 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8784 (mem_objects != NULL && mem_objects->size() > 0) ? (const cl_mem *) &mem_objects->front(): NULL,
8785 (events != NULL) ? (cl_uint) events->size() : 0,
8786 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8787 (event != NULL) ? &tmp : NULL),
8788 __ENQUEUE_RELEASE_GL_ERR);
8790 if (event != NULL && err == CL_SUCCESS)
8800#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
8801 CL_API_PREFIX__VERSION_1_1_DEPRECATED
8804 return detail::errHandler(
8805 ::clEnqueueBarrier(object_),
8806 __ENQUEUE_BARRIER_ERR);
8810 cl_int flush()
const
8812 return detail::errHandler(::clFlush(object_), __FLUSH_ERR);
8815 cl_int finish()
const
8817 return detail::errHandler(::clFinish(object_), __FINISH_ERR);
8821CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag CommandQueue::default_initialized_;
8822CL_HPP_DEFINE_STATIC_MEMBER_ CommandQueue CommandQueue::default_;
8823CL_HPP_DEFINE_STATIC_MEMBER_ cl_int CommandQueue::default_error_ = CL_SUCCESS;
8826#if CL_HPP_TARGET_OPENCL_VERSION >= 200
8827enum class DeviceQueueProperties : cl_command_queue_properties
8830 Profiling = CL_QUEUE_PROFILING_ENABLE,
8833inline DeviceQueueProperties operator|(DeviceQueueProperties lhs, DeviceQueueProperties rhs)
8835 return static_cast<DeviceQueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) |
static_cast<cl_command_queue_properties
>(rhs));
8859 cl_command_queue_properties mergedProperties =
8860 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
8862 cl_queue_properties queue_properties[] = {
8863 CL_QUEUE_PROPERTIES, mergedProperties, 0 };
8864 object_ = ::clCreateCommandQueueWithProperties(
8865 context(), device(), queue_properties, &error);
8867 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8879 DeviceQueueProperties properties = DeviceQueueProperties::None,
8884 cl_command_queue_properties mergedProperties =
8885 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
8886 cl_queue_properties queue_properties[] = {
8887 CL_QUEUE_PROPERTIES, mergedProperties, 0 };
8888 object_ = ::clCreateCommandQueueWithProperties(
8889 context(), device(), queue_properties, &error);
8891 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8904 DeviceQueueProperties properties = DeviceQueueProperties::None,
8909 cl_command_queue_properties mergedProperties =
8910 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
8911 cl_queue_properties queue_properties[] = {
8912 CL_QUEUE_PROPERTIES, mergedProperties,
8913 CL_QUEUE_SIZE, queueSize,
8915 object_ = ::clCreateCommandQueueWithProperties(
8916 context(), device(), queue_properties, &error);
8918 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8931 detail::Wrapper<cl_type>(commandQueue, retainObject) { }
8967 template <
typename T>
8968 cl_int getInfo(cl_command_queue_info name, T* param)
const
8970 return detail::errHandler(
8972 &::clGetCommandQueueInfo, object_, name, param),
8973 __GET_COMMAND_QUEUE_INFO_ERR);
8976 template <cl_command_queue_info name>
typename
8977 detail::param_traits<detail::cl_command_queue_info, name>::param_type
8978 getInfo(cl_int* err = NULL)
const
8980 typename detail::param_traits<
8981 detail::cl_command_queue_info, name>::param_type param;
8982 cl_int result = getInfo(name, ¶m);
8996 cl_int *err =
nullptr)
9002 cl_command_queue_properties properties =
9003 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
9004 cl_queue_properties queue_properties[] = {
9005 CL_QUEUE_PROPERTIES, properties,
9008 ::clCreateCommandQueueWithProperties(
9009 context(), device(), queue_properties, &error));
9011 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9026 const Context &context,
const Device &device, cl_int *err =
nullptr)
9030 cl_command_queue_properties properties =
9031 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
9032 cl_queue_properties queue_properties[] = {
9033 CL_QUEUE_PROPERTIES, properties,
9036 ::clCreateCommandQueueWithProperties(
9037 context(), device(), queue_properties, &error));
9039 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9054 const Context &context,
const Device &device, cl_uint queueSize, cl_int *err =
nullptr)
9058 cl_command_queue_properties properties =
9059 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
9060 cl_queue_properties queue_properties[] = {
9061 CL_QUEUE_PROPERTIES, properties,
9062 CL_QUEUE_SIZE, queueSize,
9065 ::clCreateCommandQueueWithProperties(
9066 context(), device(), queue_properties, &error));
9068 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9078#if CL_HPP_TARGET_OPENCL_VERSION >= 210
9088 error = clSetDefaultDeviceCommandQueue(context.get(), device.get(), default_queue.get());
9090 detail::errHandler(error, __SET_DEFAULT_DEVICE_COMMAND_QUEUE_ERR);
9094 return default_queue;
9102 return queue.getInfo<CL_QUEUE_DEVICE_DEFAULT>(err);
9122template<
typename IteratorType >
9125 IteratorType startIterator,
9126 IteratorType endIterator,
9131 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9134 cl_mem_flags flags = 0;
9136 flags |= CL_MEM_READ_ONLY;
9139 flags |= CL_MEM_READ_WRITE;
9142 flags |= CL_MEM_USE_HOST_PTR;
9145 size_type size =
sizeof(DataType)*(endIterator - startIterator);
9148 object_ = ::clCreateBuffer(context(), flags, size,
static_cast<DataType*
>(&*startIterator), &error);
9150 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
9153 detail::errHandler(error, __CREATE_BUFFER_ERR);
9160 detail::errHandler(error, __CREATE_BUFFER_ERR);
9165 error =
cl::copy(queue, startIterator, endIterator, *
this);
9166 detail::errHandler(error, __CREATE_BUFFER_ERR);
9173template<
typename IteratorType >
9176 IteratorType startIterator,
9177 IteratorType endIterator,
9182 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9185 cl_mem_flags flags = 0;
9187 flags |= CL_MEM_READ_ONLY;
9190 flags |= CL_MEM_READ_WRITE;
9193 flags |= CL_MEM_USE_HOST_PTR;
9196 size_type size =
sizeof(DataType)*(endIterator - startIterator);
9198 Context context = queue.getInfo<CL_QUEUE_CONTEXT>();
9201 object_ = ::clCreateBuffer(context(), flags, size,
static_cast<DataType*
>(&*startIterator), &error);
9204 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
9207 detail::errHandler(error, __CREATE_BUFFER_ERR);
9213 error =
cl::copy(queue, startIterator, endIterator, *
this);
9214 detail::errHandler(error, __CREATE_BUFFER_ERR);
9221inline cl_int enqueueReadBuffer(
9227 const vector<Event>* events = NULL,
9228 Event* event = NULL)
9233 if (error != CL_SUCCESS) {
9237 return queue.enqueueReadBuffer(buffer, blocking, offset, size, ptr, events, event);
9240inline cl_int enqueueWriteBuffer(
9241 const Buffer& buffer,
9246 const vector<Event>* events = NULL,
9247 Event* event = NULL)
9250 CommandQueue queue = CommandQueue::getDefault(&error);
9252 if (error != CL_SUCCESS) {
9256 return queue.enqueueWriteBuffer(buffer, blocking, offset, size, ptr, events, event);
9259inline void* enqueueMapBuffer(
9260 const Buffer& buffer,
9265 const vector<Event>* events = NULL,
9266 Event* event = NULL,
9270 CommandQueue queue = CommandQueue::getDefault(&error);
9271 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9276 void * result = ::clEnqueueMapBuffer(
9277 queue(), buffer(), blocking, flags, offset, size,
9278 (events != NULL) ? (cl_uint) events->size() : 0,
9279 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
9283 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9291#if CL_HPP_TARGET_OPENCL_VERSION >= 200
9303 const vector<Event>* events,
9308 if (error != CL_SUCCESS) {
9309 return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9313 ptr, blocking, flags, size, events, event);
9321template<
typename T,
class D>
9323 cl::pointer<T, D> ptr,
9327 const vector<Event>* events = NULL,
9328 Event* event = NULL)
9332 if (error != CL_SUCCESS) {
9333 return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9337 ptr, blocking, flags, size, events, event);
9345template<
typename T,
class Alloc>
9347 cl::vector<T, Alloc> container,
9350 const vector<Event>* events = NULL,
9351 Event* event = NULL)
9355 if (error != CL_SUCCESS) {
9356 return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9360 container, blocking, flags, events, event);
9365inline cl_int enqueueUnmapMemObject(
9366 const Memory& memory,
9368 const vector<Event>* events = NULL,
9369 Event* event = NULL)
9372 CommandQueue queue = CommandQueue::getDefault(&error);
9373 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9374 if (error != CL_SUCCESS) {
9379 cl_int err = detail::errHandler(
9380 ::clEnqueueUnmapMemObject(
9381 queue(), memory(), mapped_ptr,
9382 (events != NULL) ? (cl_uint)events->size() : 0,
9383 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
9384 (event != NULL) ? &tmp : NULL),
9385 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9387 if (event != NULL && err == CL_SUCCESS)
9393#if CL_HPP_TARGET_OPENCL_VERSION >= 200
9402 const vector<Event>* events = NULL,
9403 Event* event = NULL)
9407 if (error != CL_SUCCESS) {
9408 return detail::errHandler(error, __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9412 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9421template<
typename T,
class D>
9423 cl::pointer<T, D> &ptr,
9424 const vector<Event>* events = NULL,
9425 Event* event = NULL)
9429 if (error != CL_SUCCESS) {
9430 return detail::errHandler(error, __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9434 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9442template<
typename T,
class Alloc>
9444 cl::vector<T, Alloc> &container,
9445 const vector<Event>* events = NULL,
9446 Event* event = NULL)
9450 if (error != CL_SUCCESS) {
9451 return detail::errHandler(error, __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9454 return detail::errHandler(queue.
enqueueUnmapSVM(container, events, event),
9455 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9460inline cl_int enqueueCopyBuffer(
9463 size_type src_offset,
9464 size_type dst_offset,
9466 const vector<Event>* events = NULL,
9467 Event* event = NULL)
9470 CommandQueue queue = CommandQueue::getDefault(&error);
9472 if (error != CL_SUCCESS) {
9476 return queue.enqueueCopyBuffer(src, dst, src_offset, dst_offset, size, events, event);
9484template<
typename IteratorType >
9485inline cl_int
copy( IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer )
9489 if (error != CL_SUCCESS)
9492 return cl::copy(queue, startIterator, endIterator, buffer);
9500template<
typename IteratorType >
9501inline cl_int
copy(
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator )
9505 if (error != CL_SUCCESS)
9508 return cl::copy(queue, buffer, startIterator, endIterator);
9516template<
typename IteratorType >
9519 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9522 size_type length = endIterator-startIterator;
9523 size_type byteLength = length*
sizeof(DataType);
9526 static_cast<DataType*
>(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_WRITE, 0, byteLength, 0, 0, &error));
9528 if( error != CL_SUCCESS ) {
9531#if defined(_MSC_VER)
9535 stdext::checked_array_iterator<DataType*>(
9538 std::copy(startIterator, endIterator, pointer);
9541 error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
9543 if( error != CL_SUCCESS ) {
9555template<
typename IteratorType >
9558 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9561 size_type length = endIterator-startIterator;
9562 size_type byteLength = length*
sizeof(DataType);
9565 static_cast<DataType*
>(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_READ, 0, byteLength, 0, 0, &error));
9567 if( error != CL_SUCCESS ) {
9570 std::copy(pointer, pointer + length, startIterator);
9572 error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
9574 if( error != CL_SUCCESS ) {
9582#if CL_HPP_TARGET_OPENCL_VERSION >= 200
9586template<
typename T,
class Alloc>
9587inline cl_int
mapSVM(cl::vector<T, Alloc> &container)
9589 return enqueueMapSVM(container, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE);
9595template<
typename T,
class Alloc>
9603#if CL_HPP_TARGET_OPENCL_VERSION >= 110
9604inline cl_int enqueueReadBufferRect(
9605 const Buffer& buffer,
9607 const array<size_type, 3>& buffer_offset,
9608 const array<size_type, 3>& host_offset,
9609 const array<size_type, 3>& region,
9610 size_type buffer_row_pitch,
9611 size_type buffer_slice_pitch,
9612 size_type host_row_pitch,
9613 size_type host_slice_pitch,
9615 const vector<Event>* events = NULL,
9616 Event* event = NULL)
9619 CommandQueue queue = CommandQueue::getDefault(&error);
9621 if (error != CL_SUCCESS) {
9625 return queue.enqueueReadBufferRect(
9640inline cl_int enqueueWriteBufferRect(
9641 const Buffer& buffer,
9643 const array<size_type, 3>& buffer_offset,
9644 const array<size_type, 3>& host_offset,
9645 const array<size_type, 3>& region,
9646 size_type buffer_row_pitch,
9647 size_type buffer_slice_pitch,
9648 size_type host_row_pitch,
9649 size_type host_slice_pitch,
9651 const vector<Event>* events = NULL,
9652 Event* event = NULL)
9655 CommandQueue queue = CommandQueue::getDefault(&error);
9657 if (error != CL_SUCCESS) {
9661 return queue.enqueueWriteBufferRect(
9676inline cl_int enqueueCopyBufferRect(
9679 const array<size_type, 3>& src_origin,
9680 const array<size_type, 3>& dst_origin,
9681 const array<size_type, 3>& region,
9682 size_type src_row_pitch,
9683 size_type src_slice_pitch,
9684 size_type dst_row_pitch,
9685 size_type dst_slice_pitch,
9686 const vector<Event>* events = NULL,
9687 Event* event = NULL)
9690 CommandQueue queue = CommandQueue::getDefault(&error);
9692 if (error != CL_SUCCESS) {
9696 return queue.enqueueCopyBufferRect(
9711inline cl_int enqueueReadImage(
9714 const array<size_type, 3>& origin,
9715 const array<size_type, 3>& region,
9716 size_type row_pitch,
9717 size_type slice_pitch,
9719 const vector<Event>* events = NULL,
9720 Event* event = NULL)
9723 CommandQueue queue = CommandQueue::getDefault(&error);
9725 if (error != CL_SUCCESS) {
9729 return queue.enqueueReadImage(
9741inline cl_int enqueueWriteImage(
9744 const array<size_type, 3>& origin,
9745 const array<size_type, 3>& region,
9746 size_type row_pitch,
9747 size_type slice_pitch,
9749 const vector<Event>* events = NULL,
9750 Event* event = NULL)
9753 CommandQueue queue = CommandQueue::getDefault(&error);
9755 if (error != CL_SUCCESS) {
9759 return queue.enqueueWriteImage(
9771inline cl_int enqueueCopyImage(
9774 const array<size_type, 3>& src_origin,
9775 const array<size_type, 3>& dst_origin,
9776 const array<size_type, 3>& region,
9777 const vector<Event>* events = NULL,
9778 Event* event = NULL)
9781 CommandQueue queue = CommandQueue::getDefault(&error);
9783 if (error != CL_SUCCESS) {
9787 return queue.enqueueCopyImage(
9797inline cl_int enqueueCopyImageToBuffer(
9800 const array<size_type, 3>& src_origin,
9801 const array<size_type, 3>& region,
9802 size_type dst_offset,
9803 const vector<Event>* events = NULL,
9804 Event* event = NULL)
9807 CommandQueue queue = CommandQueue::getDefault(&error);
9809 if (error != CL_SUCCESS) {
9813 return queue.enqueueCopyImageToBuffer(
9823inline cl_int enqueueCopyBufferToImage(
9826 size_type src_offset,
9827 const array<size_type, 3>& dst_origin,
9828 const array<size_type, 3>& region,
9829 const vector<Event>* events = NULL,
9830 Event* event = NULL)
9833 CommandQueue queue = CommandQueue::getDefault(&error);
9835 if (error != CL_SUCCESS) {
9839 return queue.enqueueCopyBufferToImage(
9850inline cl_int flush(
void)
9853 CommandQueue queue = CommandQueue::getDefault(&error);
9855 if (error != CL_SUCCESS) {
9859 return queue.flush();
9862inline cl_int finish(
void)
9865 CommandQueue queue = CommandQueue::getDefault(&error);
9867 if (error != CL_SUCCESS) {
9872 return queue.finish();
9882 vector<Event> events_;
9884 template<
typename... Ts>
9889 queue_(CommandQueue::getDefault()),
9898 queue_(CommandQueue::getDefault()),
9907 queue_(CommandQueue::getDefault()),
9916 queue_(CommandQueue::getDefault()),
9921 events_.push_back(e);
9925 queue_(CommandQueue::getDefault()),
9930 events_.push_back(e);
9934 queue_(CommandQueue::getDefault()),
9939 events_.push_back(e);
9943 queue_(CommandQueue::getDefault()),
9953 queue_(CommandQueue::getDefault()),
9963 queue_(CommandQueue::getDefault()),
10001 offset_(NullRange),
10005 events_.push_back(e);
10010 offset_(NullRange),
10014 events_.push_back(e);
10023 events_.push_back(e);
10028 offset_(NullRange),
10038 offset_(NullRange),
10065template<
typename... Ts>
10071 template<
int index,
typename T0,
typename... T1s>
10072 void setArgs(T0&& t0, T1s&&... t1s)
10074 kernel_.
setArg(index, t0);
10075 setArgs<index + 1, T1s...>(std::forward<T1s>(t1s)...);
10078 template<
int index,
typename T0>
10079 void setArgs(T0&& t0)
10081 kernel_.
setArg(index, t0);
10084 template<
int index>
10097 cl_int * err = NULL) :
10098 kernel_(program, name.c_str(), err)
10114 setArgs<0>(std::forward<Ts>(ts)...);
10116 args.queue_.enqueueNDRangeKernel(
10139 setArgs<0>(std::forward<Ts>(ts)...);
10141 error = args.queue_.enqueueNDRangeKernel(
10152#if CL_HPP_TARGET_OPENCL_VERSION >= 200
10153 cl_int setSVMPointers(
const vector<void*> &pointerList)
10158 template<
typename T0,
typename... T1s>
10159 cl_int setSVMPointers(
const T0 &t0, T1s &... ts)
10171namespace compatibility {
10176 template<
typename... Ts>
10186 cl_int * err = NULL) :
10208 enqueueArgs, args...);
10216#undef CL_HPP_ERR_STR_
10217#if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS)
10218#undef __GET_DEVICE_INFO_ERR
10219#undef __GET_PLATFORM_INFO_ERR
10220#undef __GET_DEVICE_IDS_ERR
10221#undef __GET_PLATFORM_IDS_ERR
10222#undef __GET_CONTEXT_INFO_ERR
10223#undef __GET_EVENT_INFO_ERR
10224#undef __GET_EVENT_PROFILE_INFO_ERR
10225#undef __GET_MEM_OBJECT_INFO_ERR
10226#undef __GET_IMAGE_INFO_ERR
10227#undef __GET_SAMPLER_INFO_ERR
10228#undef __GET_KERNEL_INFO_ERR
10229#undef __GET_KERNEL_ARG_INFO_ERR
10230#undef __GET_KERNEL_SUB_GROUP_INFO_ERR
10231#undef __GET_KERNEL_WORK_GROUP_INFO_ERR
10232#undef __GET_PROGRAM_INFO_ERR
10233#undef __GET_PROGRAM_BUILD_INFO_ERR
10234#undef __GET_COMMAND_QUEUE_INFO_ERR
10235#undef __CREATE_CONTEXT_ERR
10236#undef __CREATE_CONTEXT_FROM_TYPE_ERR
10237#undef __GET_SUPPORTED_IMAGE_FORMATS_ERR
10238#undef __CREATE_BUFFER_ERR
10240#undef __CREATE_SUBBUFFER_ERR
10241#undef __CREATE_GL_BUFFER_ERR
10242#undef __CREATE_GL_RENDER_BUFFER_ERR
10243#undef __GET_GL_OBJECT_INFO_ERR
10244#undef __CREATE_IMAGE_ERR
10245#undef __CREATE_GL_TEXTURE_ERR
10246#undef __IMAGE_DIMENSION_ERR
10247#undef __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR
10248#undef __CREATE_USER_EVENT_ERR
10249#undef __SET_USER_EVENT_STATUS_ERR
10250#undef __SET_EVENT_CALLBACK_ERR
10251#undef __WAIT_FOR_EVENTS_ERR
10252#undef __CREATE_KERNEL_ERR
10253#undef __SET_KERNEL_ARGS_ERR
10254#undef __CREATE_PROGRAM_WITH_SOURCE_ERR
10255#undef __CREATE_PROGRAM_WITH_IL_ERR
10256#undef __CREATE_PROGRAM_WITH_BINARY_ERR
10257#undef __CREATE_PROGRAM_WITH_IL_ERR
10258#undef __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR
10259#undef __BUILD_PROGRAM_ERR
10260#undef __COMPILE_PROGRAM_ERR
10261#undef __LINK_PROGRAM_ERR
10262#undef __CREATE_KERNELS_IN_PROGRAM_ERR
10263#undef __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR
10264#undef __CREATE_SAMPLER_WITH_PROPERTIES_ERR
10265#undef __SET_COMMAND_QUEUE_PROPERTY_ERR
10266#undef __ENQUEUE_READ_BUFFER_ERR
10267#undef __ENQUEUE_READ_BUFFER_RECT_ERR
10268#undef __ENQUEUE_WRITE_BUFFER_ERR
10269#undef __ENQUEUE_WRITE_BUFFER_RECT_ERR
10270#undef __ENQEUE_COPY_BUFFER_ERR
10271#undef __ENQEUE_COPY_BUFFER_RECT_ERR
10272#undef __ENQUEUE_FILL_BUFFER_ERR
10273#undef __ENQUEUE_READ_IMAGE_ERR
10274#undef __ENQUEUE_WRITE_IMAGE_ERR
10275#undef __ENQUEUE_COPY_IMAGE_ERR
10276#undef __ENQUEUE_FILL_IMAGE_ERR
10277#undef __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR
10278#undef __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR
10279#undef __ENQUEUE_MAP_BUFFER_ERR
10280#undef __ENQUEUE_MAP_IMAGE_ERR
10281#undef __ENQUEUE_UNMAP_MEM_OBJECT_ERR
10282#undef __ENQUEUE_NDRANGE_KERNEL_ERR
10283#undef __ENQUEUE_NATIVE_KERNEL
10284#undef __ENQUEUE_MIGRATE_MEM_OBJECTS_ERR
10285#undef __ENQUEUE_MIGRATE_SVM_ERR
10286#undef __ENQUEUE_ACQUIRE_GL_ERR
10287#undef __ENQUEUE_RELEASE_GL_ERR
10288#undef __CREATE_PIPE_ERR
10289#undef __GET_PIPE_INFO_ERR
10291#undef __RELEASE_ERR
10294#undef __VECTOR_CAPACITY_ERR
10295#undef __CREATE_SUB_DEVICES_ERR
10296#undef __CREATE_SUB_DEVICES_ERR
10297#undef __ENQUEUE_MARKER_ERR
10298#undef __ENQUEUE_WAIT_FOR_EVENTS_ERR
10299#undef __ENQUEUE_BARRIER_ERR
10300#undef __UNLOAD_COMPILER_ERR
10301#undef __CREATE_GL_TEXTURE_2D_ERR
10302#undef __CREATE_GL_TEXTURE_3D_ERR
10303#undef __CREATE_IMAGE2D_ERR
10304#undef __CREATE_IMAGE3D_ERR
10305#undef __CREATE_COMMAND_QUEUE_ERR
10306#undef __ENQUEUE_TASK_ERR
10307#undef __CREATE_SAMPLER_ERR
10308#undef __ENQUEUE_MARKER_WAIT_LIST_ERR
10309#undef __ENQUEUE_BARRIER_WAIT_LIST_ERR
10310#undef __CLONE_KERNEL_ERR
10311#undef __GET_HOST_TIMER_ERR
10312#undef __GET_DEVICE_AND_HOST_TIMER_ERR
10317#undef CL_HPP_INIT_CL_EXT_FCN_PTR_
10318#undef CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_
10320#if defined(CL_HPP_USE_CL_DEVICE_FISSION)
10321#undef CL_HPP_PARAM_NAME_DEVICE_FISSION_
10324#undef CL_HPP_NOEXCEPT_
10325#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 & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
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(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()
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.
BufferRenderGL & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
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, const cl::vector< size_type > &sizes, cl_mem_migration_flags flags=0, const vector< Event > *events=NULL, Event *event=NULL) const
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
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 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 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
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
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 ...
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 ...
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 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.
detail::param_traits< detail::cl_context_info, name >::param_type getInfo(cl_int *err=NULL) const
Wrapper for clGetContextInfo() that returns by value.
cl_int getSupportedImageFormats(cl_mem_flags flags, cl_mem_object_type type, vector< ImageFormat > *formats) const
Gets a list of supported image formats.
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.
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.
Context & operator=(const Context &ctx)
Copy assignment to forward copy 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.
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.
detail::param_traits< detail::cl_device_info, name >::param_type getInfo(cl_int *err=NULL) const
Wrapper for clGetDeviceInfo() that returns by value.
Device(const Device &dev)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Device(Device &&dev) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
std::pair< cl_ulong, cl_ulong > getDeviceAndHostTimer(cl_int *error=nullptr)
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.
detail::param_traits< detail::cl_event_info, name >::param_type getInfo(cl_int *err=NULL) const
Wrapper for clGetEventInfo() that returns by value.
detail::param_traits< detail::cl_profiling_info, name >::param_type getProfilingInfo(cl_int *err=NULL) const
Wrapper for clGetEventProfilingInfo() that returns by value.
Event()
Default constructor - initializes to NULL.
Event & operator=(const cl_event &rhs)
Assignment operator from cl_event - takes ownership.
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 & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
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(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()
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 & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
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(const cl_mem &image3D, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Image3D & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
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.
detail::param_traits< detail::cl_image_info, name >::param_type getImageInfo(cl_int *err=NULL) const
Wrapper for clGetImageInfo() that returns by value.
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.
cl_int getImageInfo(cl_image_info name, T *param) const
Wrapper for clGetImageInfo().
Image & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
Image()
Default constructor - initializes to NULL.
Image(Image &&img) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
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.
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
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()
Default constructor - initializes to NULL.
std::enable_if<!std::is_pointer< T >::value, cl_int >::type setArg(cl_uint index, const T &value)
setArg overload taking a POD 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.
Kernel & operator=(const cl_kernel &rhs)
Assignment operator from cl_kernel - takes ownership.
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()
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.
Pipe & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
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...
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.
vector< std::pair< cl::Device, typename detail::param_traits< detail::cl_program_build_info, name >::param_type > > getBuildInfo(cl_int *err=NULL) const
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()
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 & operator=(const cl_sampler &rhs)
Assignment operator from cl_sampler - takes ownership.
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.
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)