403#if !defined(CL_HPP_USE_DX_INTEROP) && defined(USE_DX_INTEROP)
404# pragma message("opencl.hpp: USE_DX_INTEROP is deprecated. Define CL_HPP_USE_DX_INTEROP instead")
405# define CL_HPP_USE_DX_INTEROP
407#if !defined(CL_HPP_USE_CL_DEVICE_FISSION) && defined(USE_CL_DEVICE_FISSION)
408# pragma message("opencl.hpp: USE_CL_DEVICE_FISSION is deprecated. Define CL_HPP_USE_CL_DEVICE_FISSION instead")
409# define CL_HPP_USE_CL_DEVICE_FISSION
411#if !defined(CL_HPP_ENABLE_EXCEPTIONS) && defined(__CL_ENABLE_EXCEPTIONS)
412# pragma message("opencl.hpp: __CL_ENABLE_EXCEPTIONS is deprecated. Define CL_HPP_ENABLE_EXCEPTIONS instead")
413# define CL_HPP_ENABLE_EXCEPTIONS
415#if !defined(CL_HPP_NO_STD_VECTOR) && defined(__NO_STD_VECTOR)
416# pragma message("opencl.hpp: __NO_STD_VECTOR is deprecated. Define CL_HPP_NO_STD_VECTOR instead")
417# define CL_HPP_NO_STD_VECTOR
419#if !defined(CL_HPP_NO_STD_STRING) && defined(__NO_STD_STRING)
420# pragma message("opencl.hpp: __NO_STD_STRING is deprecated. Define CL_HPP_NO_STD_STRING instead")
421# define CL_HPP_NO_STD_STRING
423#if defined(VECTOR_CLASS)
424# pragma message("opencl.hpp: VECTOR_CLASS is deprecated. Alias cl::vector instead")
426#if defined(STRING_CLASS)
427# pragma message("opencl.hpp: STRING_CLASS is deprecated. Alias cl::string instead.")
429#if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS) && defined(__CL_USER_OVERRIDE_ERROR_STRINGS)
430# pragma message("opencl.hpp: __CL_USER_OVERRIDE_ERROR_STRINGS is deprecated. Define CL_HPP_USER_OVERRIDE_ERROR_STRINGS instead")
431# define CL_HPP_USER_OVERRIDE_ERROR_STRINGS
436#if defined(__USE_DEV_VECTOR)
437# pragma message("opencl.hpp: __USE_DEV_VECTOR is no longer supported. Expect compilation errors")
439#if defined(__USE_DEV_STRING)
440# pragma message("opencl.hpp: __USE_DEV_STRING is no longer supported. Expect compilation errors")
444#if !defined(CL_HPP_TARGET_OPENCL_VERSION)
445# pragma message("opencl.hpp: CL_HPP_TARGET_OPENCL_VERSION is not defined. It will default to 300 (OpenCL 3.0)")
446# define CL_HPP_TARGET_OPENCL_VERSION 300
448#if CL_HPP_TARGET_OPENCL_VERSION != 100 && \
449 CL_HPP_TARGET_OPENCL_VERSION != 110 && \
450 CL_HPP_TARGET_OPENCL_VERSION != 120 && \
451 CL_HPP_TARGET_OPENCL_VERSION != 200 && \
452 CL_HPP_TARGET_OPENCL_VERSION != 210 && \
453 CL_HPP_TARGET_OPENCL_VERSION != 220 && \
454 CL_HPP_TARGET_OPENCL_VERSION != 300
455# pragma message("opencl.hpp: CL_HPP_TARGET_OPENCL_VERSION is not a valid value (100, 110, 120, 200, 210, 220 or 300). It will be set to 300 (OpenCL 3.0).")
456# undef CL_HPP_TARGET_OPENCL_VERSION
457# define CL_HPP_TARGET_OPENCL_VERSION 300
461#if defined(CL_TARGET_OPENCL_VERSION)
464#if CL_TARGET_OPENCL_VERSION < CL_HPP_TARGET_OPENCL_VERSION
465# pragma message("CL_TARGET_OPENCL_VERSION is already defined as is lower than CL_HPP_TARGET_OPENCL_VERSION")
468# define CL_TARGET_OPENCL_VERSION CL_HPP_TARGET_OPENCL_VERSION
471#if !defined(CL_HPP_MINIMUM_OPENCL_VERSION)
472# define CL_HPP_MINIMUM_OPENCL_VERSION 200
474#if CL_HPP_MINIMUM_OPENCL_VERSION != 100 && \
475 CL_HPP_MINIMUM_OPENCL_VERSION != 110 && \
476 CL_HPP_MINIMUM_OPENCL_VERSION != 120 && \
477 CL_HPP_MINIMUM_OPENCL_VERSION != 200 && \
478 CL_HPP_MINIMUM_OPENCL_VERSION != 210 && \
479 CL_HPP_MINIMUM_OPENCL_VERSION != 220 && \
480 CL_HPP_MINIMUM_OPENCL_VERSION != 300
481# pragma message("opencl.hpp: CL_HPP_MINIMUM_OPENCL_VERSION is not a valid value (100, 110, 120, 200, 210, 220 or 300). It will be set to 100")
482# undef CL_HPP_MINIMUM_OPENCL_VERSION
483# define CL_HPP_MINIMUM_OPENCL_VERSION 100
485#if CL_HPP_MINIMUM_OPENCL_VERSION > CL_HPP_TARGET_OPENCL_VERSION
486# error "CL_HPP_MINIMUM_OPENCL_VERSION must not be greater than CL_HPP_TARGET_OPENCL_VERSION"
489#if CL_HPP_MINIMUM_OPENCL_VERSION <= 100 && !defined(CL_USE_DEPRECATED_OPENCL_1_0_APIS)
490# define CL_USE_DEPRECATED_OPENCL_1_0_APIS
492#if CL_HPP_MINIMUM_OPENCL_VERSION <= 110 && !defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
493# define CL_USE_DEPRECATED_OPENCL_1_1_APIS
495#if CL_HPP_MINIMUM_OPENCL_VERSION <= 120 && !defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
496# define CL_USE_DEPRECATED_OPENCL_1_2_APIS
498#if CL_HPP_MINIMUM_OPENCL_VERSION <= 200 && !defined(CL_USE_DEPRECATED_OPENCL_2_0_APIS)
499# define CL_USE_DEPRECATED_OPENCL_2_0_APIS
501#if CL_HPP_MINIMUM_OPENCL_VERSION <= 210 && !defined(CL_USE_DEPRECATED_OPENCL_2_1_APIS)
502# define CL_USE_DEPRECATED_OPENCL_2_1_APIS
504#if CL_HPP_MINIMUM_OPENCL_VERSION <= 220 && !defined(CL_USE_DEPRECATED_OPENCL_2_2_APIS)
505# define CL_USE_DEPRECATED_OPENCL_2_2_APIS
512#if defined(CL_HPP_USE_DX_INTEROP)
513#include <CL/cl_d3d10.h>
514#include <CL/cl_dx9_media_sharing.h>
526#if (!defined(_MSC_VER) && __cplusplus < 201103L) || (defined(_MSC_VER) && _MSC_VER < 1700)
527#error Visual studio 2013 or another C++11-supporting compiler required
531#if defined(CL_HPP_USE_CL_DEVICE_FISSION) || defined(CL_HPP_USE_CL_SUB_GROUPS_KHR)
532#include <CL/cl_ext.h>
535#if defined(__APPLE__) || defined(__MACOSX)
536#include <OpenCL/opencl.h>
538#include <CL/opencl.h>
541#if (__cplusplus >= 201103L || _MSVC_LANG >= 201103L )
542#define CL_HPP_NOEXCEPT_ noexcept
544#define CL_HPP_NOEXCEPT_
547#if __cplusplus >= 201703L
548# define CL_HPP_DEFINE_STATIC_MEMBER_ inline
549#elif defined(_MSC_VER)
550# define CL_HPP_DEFINE_STATIC_MEMBER_ __declspec(selectany)
551#elif defined(__MINGW32__)
552# define CL_HPP_DEFINE_STATIC_MEMBER_ __attribute__((selectany))
554# define CL_HPP_DEFINE_STATIC_MEMBER_ __attribute__((weak))
559#if !defined(CL_API_PREFIX__VERSION_1_1_DEPRECATED)
560#define CL_API_PREFIX__VERSION_1_1_DEPRECATED
562#if !defined(CL_API_SUFFIX__VERSION_1_1_DEPRECATED)
563#define CL_API_SUFFIX__VERSION_1_1_DEPRECATED
566#if !defined(CL_API_PREFIX__VERSION_1_2_DEPRECATED)
567#define CL_API_PREFIX__VERSION_1_2_DEPRECATED
569#if !defined(CL_API_SUFFIX__VERSION_1_2_DEPRECATED)
570#define CL_API_SUFFIX__VERSION_1_2_DEPRECATED
573#if !defined(CL_API_PREFIX__VERSION_2_2_DEPRECATED)
574#define CL_API_PREFIX__VERSION_2_2_DEPRECATED
576#if !defined(CL_API_SUFFIX__VERSION_2_2_DEPRECATED)
577#define CL_API_SUFFIX__VERSION_2_2_DEPRECATED
580#if !defined(CL_CALLBACK)
593#if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY)
595 using size_type = ::size_t;
599 using size_type = size_t;
604#if defined(CL_HPP_ENABLE_EXCEPTIONS)
608#if !defined(CL_HPP_NO_STD_VECTOR)
611 template <
class T,
class Alloc = std::allocator<T> >
612 using vector = std::vector<T, Alloc>;
616#if !defined(CL_HPP_NO_STD_STRING)
619 using string = std::string;
623#if CL_HPP_TARGET_OPENCL_VERSION >= 200
625#if !defined(CL_HPP_NO_STD_UNIQUE_PTR)
630 template<
class T,
class D>
631 using pointer = std::unique_ptr<T, D>;
635#if !defined(CL_HPP_NO_STD_ARRAY)
638 template <
class T,
size_type N >
639 using array = std::array<T, N>;
645#if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY)
647 namespace compatibility {
662 for (
int i = 0; i < N; ++i) {
667 size_t(
const array<size_type, N> &rhs)
669 for (
int i = 0; i < N; ++i) {
674 size_type& operator[](
int index)
679 const size_type& operator[](
int index)
const
685 operator size_type* () {
return data_; }
688 operator const size_type* ()
const {
return data_; }
690 operator array<size_type, N>()
const
692 array<size_type, N> ret;
694 for (
int i = 0; i < N; ++i) {
703 using size_t = compatibility::size_t<N>;
710 using size_t_array = array<size_type, 3>;
723#define CL_HPP_INIT_CL_EXT_FCN_PTR_(name) \
725 pfn_##name = (PFN_##name) \
726 clGetExtensionFunctionAddress(#name); \
731#define CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, name) \
733 pfn_##name = (PFN_##name) \
734 clGetExtensionFunctionAddressForPlatform(platform, #name); \
743 class DeviceCommandQueue;
748#if defined(CL_HPP_ENABLE_EXCEPTIONS)
753 class Error :
public std::exception
757 const char * errStr_;
768 Error(cl_int err,
const char * errStr = NULL) : err_(err), errStr_(errStr)
777 virtual const char * what()
const throw ()
779 if (errStr_ == NULL) {
791 cl_int err(
void)
const {
return err_; }
793#define CL_HPP_ERR_STR_(x) #x
795#define CL_HPP_ERR_STR_(x) NULL
801#if defined(CL_HPP_ENABLE_EXCEPTIONS)
802static inline cl_int errHandler (
804 const char * errStr = NULL)
806 if (err != CL_SUCCESS) {
807 throw Error(err, errStr);
812static inline cl_int errHandler (cl_int err,
const char * errStr = NULL)
823#if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS)
824#define __GET_DEVICE_INFO_ERR CL_HPP_ERR_STR_(clGetDeviceInfo)
825#define __GET_PLATFORM_INFO_ERR CL_HPP_ERR_STR_(clGetPlatformInfo)
826#define __GET_DEVICE_IDS_ERR CL_HPP_ERR_STR_(clGetDeviceIDs)
827#define __GET_PLATFORM_IDS_ERR CL_HPP_ERR_STR_(clGetPlatformIDs)
828#define __GET_CONTEXT_INFO_ERR CL_HPP_ERR_STR_(clGetContextInfo)
829#define __GET_EVENT_INFO_ERR CL_HPP_ERR_STR_(clGetEventInfo)
830#define __GET_EVENT_PROFILE_INFO_ERR CL_HPP_ERR_STR_(clGetEventProfileInfo)
831#define __GET_MEM_OBJECT_INFO_ERR CL_HPP_ERR_STR_(clGetMemObjectInfo)
832#define __GET_IMAGE_INFO_ERR CL_HPP_ERR_STR_(clGetImageInfo)
833#define __GET_SAMPLER_INFO_ERR CL_HPP_ERR_STR_(clGetSamplerInfo)
834#define __GET_KERNEL_INFO_ERR CL_HPP_ERR_STR_(clGetKernelInfo)
835#if CL_HPP_TARGET_OPENCL_VERSION >= 120
836#define __GET_KERNEL_ARG_INFO_ERR CL_HPP_ERR_STR_(clGetKernelArgInfo)
838#if CL_HPP_TARGET_OPENCL_VERSION >= 200
839#define __GET_KERNEL_SUB_GROUP_INFO_ERR CL_HPP_ERR_STR_(clGetKernelSubGroupInfo)
841#define __GET_KERNEL_WORK_GROUP_INFO_ERR CL_HPP_ERR_STR_(clGetKernelWorkGroupInfo)
842#define __GET_PROGRAM_INFO_ERR CL_HPP_ERR_STR_(clGetProgramInfo)
843#define __GET_PROGRAM_BUILD_INFO_ERR CL_HPP_ERR_STR_(clGetProgramBuildInfo)
844#define __GET_COMMAND_QUEUE_INFO_ERR CL_HPP_ERR_STR_(clGetCommandQueueInfo)
846#define __CREATE_CONTEXT_ERR CL_HPP_ERR_STR_(clCreateContext)
847#define __CREATE_CONTEXT_FROM_TYPE_ERR CL_HPP_ERR_STR_(clCreateContextFromType)
848#define __GET_SUPPORTED_IMAGE_FORMATS_ERR CL_HPP_ERR_STR_(clGetSupportedImageFormats)
850#define __CREATE_BUFFER_ERR CL_HPP_ERR_STR_(clCreateBuffer)
851#define __COPY_ERR CL_HPP_ERR_STR_(cl::copy)
852#define __CREATE_SUBBUFFER_ERR CL_HPP_ERR_STR_(clCreateSubBuffer)
853#define __CREATE_GL_BUFFER_ERR CL_HPP_ERR_STR_(clCreateFromGLBuffer)
854#define __CREATE_GL_RENDER_BUFFER_ERR CL_HPP_ERR_STR_(clCreateFromGLBuffer)
855#define __GET_GL_OBJECT_INFO_ERR CL_HPP_ERR_STR_(clGetGLObjectInfo)
856#if CL_HPP_TARGET_OPENCL_VERSION >= 120
857#define __CREATE_IMAGE_ERR CL_HPP_ERR_STR_(clCreateImage)
858#define __CREATE_GL_TEXTURE_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture)
859#define __IMAGE_DIMENSION_ERR CL_HPP_ERR_STR_(Incorrect image dimensions)
861#define __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR CL_HPP_ERR_STR_(clSetMemObjectDestructorCallback)
863#define __CREATE_USER_EVENT_ERR CL_HPP_ERR_STR_(clCreateUserEvent)
864#define __SET_USER_EVENT_STATUS_ERR CL_HPP_ERR_STR_(clSetUserEventStatus)
865#define __SET_EVENT_CALLBACK_ERR CL_HPP_ERR_STR_(clSetEventCallback)
866#define __WAIT_FOR_EVENTS_ERR CL_HPP_ERR_STR_(clWaitForEvents)
868#define __CREATE_KERNEL_ERR CL_HPP_ERR_STR_(clCreateKernel)
869#define __SET_KERNEL_ARGS_ERR CL_HPP_ERR_STR_(clSetKernelArg)
870#define __CREATE_PROGRAM_WITH_SOURCE_ERR CL_HPP_ERR_STR_(clCreateProgramWithSource)
871#if CL_HPP_TARGET_OPENCL_VERSION >= 200
872#define __CREATE_PROGRAM_WITH_IL_ERR CL_HPP_ERR_STR_(clCreateProgramWithIL)
874#define __CREATE_PROGRAM_WITH_BINARY_ERR CL_HPP_ERR_STR_(clCreateProgramWithBinary)
875#if CL_HPP_TARGET_OPENCL_VERSION >= 210
876#define __CREATE_PROGRAM_WITH_IL_ERR CL_HPP_ERR_STR_(clCreateProgramWithIL)
878#if CL_HPP_TARGET_OPENCL_VERSION >= 120
879#define __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR CL_HPP_ERR_STR_(clCreateProgramWithBuiltInKernels)
881#define __BUILD_PROGRAM_ERR CL_HPP_ERR_STR_(clBuildProgram)
882#if CL_HPP_TARGET_OPENCL_VERSION >= 120
883#define __COMPILE_PROGRAM_ERR CL_HPP_ERR_STR_(clCompileProgram)
884#define __LINK_PROGRAM_ERR CL_HPP_ERR_STR_(clLinkProgram)
886#define __CREATE_KERNELS_IN_PROGRAM_ERR CL_HPP_ERR_STR_(clCreateKernelsInProgram)
888#if CL_HPP_TARGET_OPENCL_VERSION >= 200
889#define __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR CL_HPP_ERR_STR_(clCreateCommandQueueWithProperties)
890#define __CREATE_SAMPLER_WITH_PROPERTIES_ERR CL_HPP_ERR_STR_(clCreateSamplerWithProperties)
892#define __SET_COMMAND_QUEUE_PROPERTY_ERR CL_HPP_ERR_STR_(clSetCommandQueueProperty)
893#define __ENQUEUE_READ_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueReadBuffer)
894#define __ENQUEUE_READ_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueReadBufferRect)
895#define __ENQUEUE_WRITE_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueWriteBuffer)
896#define __ENQUEUE_WRITE_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueWriteBufferRect)
897#define __ENQEUE_COPY_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueCopyBuffer)
898#define __ENQEUE_COPY_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueCopyBufferRect)
899#define __ENQUEUE_FILL_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueFillBuffer)
900#define __ENQUEUE_READ_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueReadImage)
901#define __ENQUEUE_WRITE_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueWriteImage)
902#define __ENQUEUE_COPY_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueCopyImage)
903#define __ENQUEUE_FILL_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueFillImage)
904#define __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueCopyImageToBuffer)
905#define __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueCopyBufferToImage)
906#define __ENQUEUE_MAP_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueMapBuffer)
907#define __ENQUEUE_MAP_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueMapImage)
908#define __ENQUEUE_UNMAP_MEM_OBJECT_ERR CL_HPP_ERR_STR_(clEnqueueUnMapMemObject)
909#define __ENQUEUE_NDRANGE_KERNEL_ERR CL_HPP_ERR_STR_(clEnqueueNDRangeKernel)
910#define __ENQUEUE_NATIVE_KERNEL CL_HPP_ERR_STR_(clEnqueueNativeKernel)
911#if CL_HPP_TARGET_OPENCL_VERSION >= 120
912#define __ENQUEUE_MIGRATE_MEM_OBJECTS_ERR CL_HPP_ERR_STR_(clEnqueueMigrateMemObjects)
914#if CL_HPP_TARGET_OPENCL_VERSION >= 210
915#define __ENQUEUE_MIGRATE_SVM_ERR CL_HPP_ERR_STR_(clEnqueueSVMMigrateMem)
916#define __SET_DEFAULT_DEVICE_COMMAND_QUEUE_ERR CL_HPP_ERR_STR_(clSetDefaultDeviceCommandQueue)
920#define __ENQUEUE_ACQUIRE_GL_ERR CL_HPP_ERR_STR_(clEnqueueAcquireGLObjects)
921#define __ENQUEUE_RELEASE_GL_ERR CL_HPP_ERR_STR_(clEnqueueReleaseGLObjects)
923#define __CREATE_PIPE_ERR CL_HPP_ERR_STR_(clCreatePipe)
924#define __GET_PIPE_INFO_ERR CL_HPP_ERR_STR_(clGetPipeInfo)
927#define __RETAIN_ERR CL_HPP_ERR_STR_(Retain Object)
928#define __RELEASE_ERR CL_HPP_ERR_STR_(Release Object)
929#define __FLUSH_ERR CL_HPP_ERR_STR_(clFlush)
930#define __FINISH_ERR CL_HPP_ERR_STR_(clFinish)
931#define __VECTOR_CAPACITY_ERR CL_HPP_ERR_STR_(Vector capacity error)
933#if CL_HPP_TARGET_OPENCL_VERSION >= 210
934#define __GET_HOST_TIMER_ERR CL_HPP_ERR_STR_(clGetHostTimer)
935#define __GET_DEVICE_AND_HOST_TIMER_ERR CL_HPP_ERR_STR_(clGetDeviceAndHostTimer)
937#if CL_HPP_TARGET_OPENCL_VERSION >= 220
938#define __SET_PROGRAM_RELEASE_CALLBACK_ERR CL_HPP_ERR_STR_(clSetProgramReleaseCallback)
939#define __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR CL_HPP_ERR_STR_(clSetProgramSpecializationConstant)
946#if CL_HPP_TARGET_OPENCL_VERSION >= 120
947#define __CREATE_SUB_DEVICES_ERR CL_HPP_ERR_STR_(clCreateSubDevices)
949#define __CREATE_SUB_DEVICES_ERR CL_HPP_ERR_STR_(clCreateSubDevicesEXT)
955#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
956#define __ENQUEUE_MARKER_ERR CL_HPP_ERR_STR_(clEnqueueMarker)
957#define __ENQUEUE_WAIT_FOR_EVENTS_ERR CL_HPP_ERR_STR_(clEnqueueWaitForEvents)
958#define __ENQUEUE_BARRIER_ERR CL_HPP_ERR_STR_(clEnqueueBarrier)
959#define __UNLOAD_COMPILER_ERR CL_HPP_ERR_STR_(clUnloadCompiler)
960#define __CREATE_GL_TEXTURE_2D_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture2D)
961#define __CREATE_GL_TEXTURE_3D_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture3D)
962#define __CREATE_IMAGE2D_ERR CL_HPP_ERR_STR_(clCreateImage2D)
963#define __CREATE_IMAGE3D_ERR CL_HPP_ERR_STR_(clCreateImage3D)
969#if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
970#define __CREATE_COMMAND_QUEUE_ERR CL_HPP_ERR_STR_(clCreateCommandQueue)
971#define __ENQUEUE_TASK_ERR CL_HPP_ERR_STR_(clEnqueueTask)
972#define __CREATE_SAMPLER_ERR CL_HPP_ERR_STR_(clCreateSampler)
978#if CL_HPP_TARGET_OPENCL_VERSION >= 120
979#define __ENQUEUE_MARKER_WAIT_LIST_ERR CL_HPP_ERR_STR_(clEnqueueMarkerWithWaitList)
980#define __ENQUEUE_BARRIER_WAIT_LIST_ERR CL_HPP_ERR_STR_(clEnqueueBarrierWithWaitList)
983#if CL_HPP_TARGET_OPENCL_VERSION >= 210
984#define __CLONE_KERNEL_ERR CL_HPP_ERR_STR_(clCloneKernel)
997template<
typename Functor,
typename T>
998inline cl_int getInfoHelper(Functor f, cl_uint name, T* param,
long)
1000 return f(name,
sizeof(T), param, NULL);
1005template <
typename Func>
1006inline cl_int getInfoHelper(Func f, cl_uint name, vector<vector<unsigned char>>* param,
int)
1008 if (name != CL_PROGRAM_BINARIES) {
1009 return CL_INVALID_VALUE;
1013 size_type numBinaries = param->size();
1014 vector<unsigned char*> binariesPointers(numBinaries);
1016 for (size_type i = 0; i < numBinaries; ++i)
1018 binariesPointers[i] = (*param)[i].data();
1021 cl_int err = f(name, numBinaries *
sizeof(
unsigned char*), binariesPointers.data(), NULL);
1023 if (err != CL_SUCCESS) {
1033template <
typename Func,
typename T>
1034inline cl_int getInfoHelper(Func f, cl_uint name, vector<T>* param,
long)
1037 cl_int err = f(name, 0, NULL, &required);
1038 if (err != CL_SUCCESS) {
1041 const size_type elements = required /
sizeof(T);
1044 vector<T> localData(elements);
1045 err = f(name, required, localData.data(), NULL);
1046 if (err != CL_SUCCESS) {
1050 *param = std::move(localData);
1062template <
typename Func,
typename T>
1063inline cl_int getInfoHelper(
1064 Func f, cl_uint name, vector<T>* param,
int,
typename T::cl_type = 0)
1067 cl_int err = f(name, 0, NULL, &required);
1068 if (err != CL_SUCCESS) {
1072 const size_type elements = required /
sizeof(
typename T::cl_type);
1074 vector<typename T::cl_type> value(elements);
1075 err = f(name, required, value.data(), NULL);
1076 if (err != CL_SUCCESS) {
1082 param->resize(elements);
1086 for (size_type i = 0; i < elements; i++) {
1087 (*param)[i] = T(value[i],
true);
1094template <
typename Func>
1095inline cl_int getInfoHelper(Func f, cl_uint name,
string* param,
long)
1098 cl_int err = f(name, 0, NULL, &required);
1099 if (err != CL_SUCCESS) {
1106 vector<char> value(required);
1107 err = f(name, required, value.data(), NULL);
1108 if (err != CL_SUCCESS) {
1112 param->assign(begin(value), prev(end(value)));
1122template <
typename Func,
size_type N>
1123inline cl_int getInfoHelper(Func f, cl_uint name, array<size_type, N>* param,
long)
1126 cl_int err = f(name, 0, NULL, &required);
1127 if (err != CL_SUCCESS) {
1131 size_type elements = required /
sizeof(size_type);
1132 vector<size_type> value(elements, 0);
1134 err = f(name, required, value.data(), NULL);
1135 if (err != CL_SUCCESS) {
1144 for (size_type i = 0; i < elements; ++i) {
1145 (*param)[i] = value[i];
1151template<
typename T>
struct ReferenceHandler;
1159template<
typename Func,
typename T>
1160inline cl_int getInfoHelper(Func f, cl_uint name, T* param,
int,
typename T::cl_type = 0)
1162 typename T::cl_type value;
1163 cl_int err = f(name,
sizeof(value), &value, NULL);
1164 if (err != CL_SUCCESS) {
1170 err = param->retain();
1171 if (err != CL_SUCCESS) {
1178#define CL_HPP_PARAM_NAME_INFO_1_0_(F) \
1179 F(cl_platform_info, CL_PLATFORM_PROFILE, string) \
1180 F(cl_platform_info, CL_PLATFORM_VERSION, string) \
1181 F(cl_platform_info, CL_PLATFORM_NAME, string) \
1182 F(cl_platform_info, CL_PLATFORM_VENDOR, string) \
1183 F(cl_platform_info, CL_PLATFORM_EXTENSIONS, string) \
1185 F(cl_device_info, CL_DEVICE_TYPE, cl_device_type) \
1186 F(cl_device_info, CL_DEVICE_VENDOR_ID, cl_uint) \
1187 F(cl_device_info, CL_DEVICE_MAX_COMPUTE_UNITS, cl_uint) \
1188 F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, cl_uint) \
1189 F(cl_device_info, CL_DEVICE_MAX_WORK_GROUP_SIZE, size_type) \
1190 F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_SIZES, cl::vector<size_type>) \
1191 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, cl_uint) \
1192 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT, cl_uint) \
1193 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT, cl_uint) \
1194 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG, cl_uint) \
1195 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT, cl_uint) \
1196 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, cl_uint) \
1197 F(cl_device_info, CL_DEVICE_MAX_CLOCK_FREQUENCY, cl_uint) \
1198 F(cl_device_info, CL_DEVICE_ADDRESS_BITS, cl_uint) \
1199 F(cl_device_info, CL_DEVICE_MAX_READ_IMAGE_ARGS, cl_uint) \
1200 F(cl_device_info, CL_DEVICE_MAX_WRITE_IMAGE_ARGS, cl_uint) \
1201 F(cl_device_info, CL_DEVICE_MAX_MEM_ALLOC_SIZE, cl_ulong) \
1202 F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_WIDTH, size_type) \
1203 F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_HEIGHT, size_type) \
1204 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_WIDTH, size_type) \
1205 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_HEIGHT, size_type) \
1206 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_DEPTH, size_type) \
1207 F(cl_device_info, CL_DEVICE_IMAGE_SUPPORT, cl_bool) \
1208 F(cl_device_info, CL_DEVICE_MAX_PARAMETER_SIZE, size_type) \
1209 F(cl_device_info, CL_DEVICE_MAX_SAMPLERS, cl_uint) \
1210 F(cl_device_info, CL_DEVICE_MEM_BASE_ADDR_ALIGN, cl_uint) \
1211 F(cl_device_info, CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE, cl_uint) \
1212 F(cl_device_info, CL_DEVICE_SINGLE_FP_CONFIG, cl_device_fp_config) \
1213 F(cl_device_info, CL_DEVICE_DOUBLE_FP_CONFIG, cl_device_fp_config) \
1214 F(cl_device_info, CL_DEVICE_HALF_FP_CONFIG, cl_device_fp_config) \
1215 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_TYPE, cl_device_mem_cache_type) \
1216 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE, cl_uint)\
1217 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_SIZE, cl_ulong) \
1218 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_SIZE, cl_ulong) \
1219 F(cl_device_info, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE, cl_ulong) \
1220 F(cl_device_info, CL_DEVICE_MAX_CONSTANT_ARGS, cl_uint) \
1221 F(cl_device_info, CL_DEVICE_LOCAL_MEM_TYPE, cl_device_local_mem_type) \
1222 F(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE, cl_ulong) \
1223 F(cl_device_info, CL_DEVICE_ERROR_CORRECTION_SUPPORT, cl_bool) \
1224 F(cl_device_info, CL_DEVICE_PROFILING_TIMER_RESOLUTION, size_type) \
1225 F(cl_device_info, CL_DEVICE_ENDIAN_LITTLE, cl_bool) \
1226 F(cl_device_info, CL_DEVICE_AVAILABLE, cl_bool) \
1227 F(cl_device_info, CL_DEVICE_COMPILER_AVAILABLE, cl_bool) \
1228 F(cl_device_info, CL_DEVICE_EXECUTION_CAPABILITIES, cl_device_exec_capabilities) \
1229 F(cl_device_info, CL_DEVICE_PLATFORM, cl_platform_id) \
1230 F(cl_device_info, CL_DEVICE_NAME, string) \
1231 F(cl_device_info, CL_DEVICE_VENDOR, string) \
1232 F(cl_device_info, CL_DRIVER_VERSION, string) \
1233 F(cl_device_info, CL_DEVICE_PROFILE, string) \
1234 F(cl_device_info, CL_DEVICE_VERSION, string) \
1235 F(cl_device_info, CL_DEVICE_EXTENSIONS, string) \
1237 F(cl_context_info, CL_CONTEXT_REFERENCE_COUNT, cl_uint) \
1238 F(cl_context_info, CL_CONTEXT_DEVICES, cl::vector<Device>) \
1239 F(cl_context_info, CL_CONTEXT_PROPERTIES, cl::vector<cl_context_properties>) \
1241 F(cl_event_info, CL_EVENT_COMMAND_QUEUE, cl::CommandQueue) \
1242 F(cl_event_info, CL_EVENT_COMMAND_TYPE, cl_command_type) \
1243 F(cl_event_info, CL_EVENT_REFERENCE_COUNT, cl_uint) \
1244 F(cl_event_info, CL_EVENT_COMMAND_EXECUTION_STATUS, cl_int) \
1246 F(cl_profiling_info, CL_PROFILING_COMMAND_QUEUED, cl_ulong) \
1247 F(cl_profiling_info, CL_PROFILING_COMMAND_SUBMIT, cl_ulong) \
1248 F(cl_profiling_info, CL_PROFILING_COMMAND_START, cl_ulong) \
1249 F(cl_profiling_info, CL_PROFILING_COMMAND_END, cl_ulong) \
1251 F(cl_mem_info, CL_MEM_TYPE, cl_mem_object_type) \
1252 F(cl_mem_info, CL_MEM_FLAGS, cl_mem_flags) \
1253 F(cl_mem_info, CL_MEM_SIZE, size_type) \
1254 F(cl_mem_info, CL_MEM_HOST_PTR, void*) \
1255 F(cl_mem_info, CL_MEM_MAP_COUNT, cl_uint) \
1256 F(cl_mem_info, CL_MEM_REFERENCE_COUNT, cl_uint) \
1257 F(cl_mem_info, CL_MEM_CONTEXT, cl::Context) \
1259 F(cl_image_info, CL_IMAGE_FORMAT, cl_image_format) \
1260 F(cl_image_info, CL_IMAGE_ELEMENT_SIZE, size_type) \
1261 F(cl_image_info, CL_IMAGE_ROW_PITCH, size_type) \
1262 F(cl_image_info, CL_IMAGE_SLICE_PITCH, size_type) \
1263 F(cl_image_info, CL_IMAGE_WIDTH, size_type) \
1264 F(cl_image_info, CL_IMAGE_HEIGHT, size_type) \
1265 F(cl_image_info, CL_IMAGE_DEPTH, size_type) \
1267 F(cl_sampler_info, CL_SAMPLER_REFERENCE_COUNT, cl_uint) \
1268 F(cl_sampler_info, CL_SAMPLER_CONTEXT, cl::Context) \
1269 F(cl_sampler_info, CL_SAMPLER_NORMALIZED_COORDS, cl_bool) \
1270 F(cl_sampler_info, CL_SAMPLER_ADDRESSING_MODE, cl_addressing_mode) \
1271 F(cl_sampler_info, CL_SAMPLER_FILTER_MODE, cl_filter_mode) \
1273 F(cl_program_info, CL_PROGRAM_REFERENCE_COUNT, cl_uint) \
1274 F(cl_program_info, CL_PROGRAM_CONTEXT, cl::Context) \
1275 F(cl_program_info, CL_PROGRAM_NUM_DEVICES, cl_uint) \
1276 F(cl_program_info, CL_PROGRAM_DEVICES, cl::vector<Device>) \
1277 F(cl_program_info, CL_PROGRAM_SOURCE, string) \
1278 F(cl_program_info, CL_PROGRAM_BINARY_SIZES, cl::vector<size_type>) \
1279 F(cl_program_info, CL_PROGRAM_BINARIES, cl::vector<cl::vector<unsigned char>>) \
1281 F(cl_program_build_info, CL_PROGRAM_BUILD_STATUS, cl_build_status) \
1282 F(cl_program_build_info, CL_PROGRAM_BUILD_OPTIONS, string) \
1283 F(cl_program_build_info, CL_PROGRAM_BUILD_LOG, string) \
1285 F(cl_kernel_info, CL_KERNEL_FUNCTION_NAME, string) \
1286 F(cl_kernel_info, CL_KERNEL_NUM_ARGS, cl_uint) \
1287 F(cl_kernel_info, CL_KERNEL_REFERENCE_COUNT, cl_uint) \
1288 F(cl_kernel_info, CL_KERNEL_CONTEXT, cl::Context) \
1289 F(cl_kernel_info, CL_KERNEL_PROGRAM, cl::Program) \
1291 F(cl_kernel_work_group_info, CL_KERNEL_WORK_GROUP_SIZE, size_type) \
1292 F(cl_kernel_work_group_info, CL_KERNEL_COMPILE_WORK_GROUP_SIZE, cl::detail::size_t_array) \
1293 F(cl_kernel_work_group_info, CL_KERNEL_LOCAL_MEM_SIZE, cl_ulong) \
1295 F(cl_command_queue_info, CL_QUEUE_CONTEXT, cl::Context) \
1296 F(cl_command_queue_info, CL_QUEUE_DEVICE, cl::Device) \
1297 F(cl_command_queue_info, CL_QUEUE_REFERENCE_COUNT, cl_uint) \
1298 F(cl_command_queue_info, CL_QUEUE_PROPERTIES, cl_command_queue_properties)
1301#define CL_HPP_PARAM_NAME_INFO_1_1_(F) \
1302 F(cl_context_info, CL_CONTEXT_NUM_DEVICES, cl_uint)\
1303 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF, cl_uint) \
1304 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR, cl_uint) \
1305 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT, cl_uint) \
1306 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_INT, cl_uint) \
1307 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG, cl_uint) \
1308 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT, cl_uint) \
1309 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE, cl_uint) \
1310 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF, cl_uint) \
1311 F(cl_device_info, CL_DEVICE_OPENCL_C_VERSION, string) \
1313 F(cl_mem_info, CL_MEM_ASSOCIATED_MEMOBJECT, cl::Memory) \
1314 F(cl_mem_info, CL_MEM_OFFSET, size_type) \
1316 F(cl_kernel_work_group_info, CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, size_type) \
1317 F(cl_kernel_work_group_info, CL_KERNEL_PRIVATE_MEM_SIZE, cl_ulong) \
1319 F(cl_event_info, CL_EVENT_CONTEXT, cl::Context)
1321#define CL_HPP_PARAM_NAME_INFO_1_2_(F) \
1322 F(cl_program_info, CL_PROGRAM_NUM_KERNELS, size_type) \
1323 F(cl_program_info, CL_PROGRAM_KERNEL_NAMES, string) \
1325 F(cl_program_build_info, CL_PROGRAM_BINARY_TYPE, cl_program_binary_type) \
1327 F(cl_kernel_info, CL_KERNEL_ATTRIBUTES, string) \
1329 F(cl_kernel_arg_info, CL_KERNEL_ARG_ADDRESS_QUALIFIER, cl_kernel_arg_address_qualifier) \
1330 F(cl_kernel_arg_info, CL_KERNEL_ARG_ACCESS_QUALIFIER, cl_kernel_arg_access_qualifier) \
1331 F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_NAME, string) \
1332 F(cl_kernel_arg_info, CL_KERNEL_ARG_NAME, string) \
1333 F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_QUALIFIER, cl_kernel_arg_type_qualifier) \
1335 F(cl_kernel_work_group_info, CL_KERNEL_GLOBAL_WORK_SIZE, cl::detail::size_t_array) \
1337 F(cl_device_info, CL_DEVICE_LINKER_AVAILABLE, cl_bool) \
1338 F(cl_device_info, CL_DEVICE_IMAGE_MAX_BUFFER_SIZE, size_type) \
1339 F(cl_device_info, CL_DEVICE_IMAGE_MAX_ARRAY_SIZE, size_type) \
1340 F(cl_device_info, CL_DEVICE_PARENT_DEVICE, cl::Device) \
1341 F(cl_device_info, CL_DEVICE_PARTITION_MAX_SUB_DEVICES, cl_uint) \
1342 F(cl_device_info, CL_DEVICE_PARTITION_PROPERTIES, cl::vector<cl_device_partition_property>) \
1343 F(cl_device_info, CL_DEVICE_PARTITION_TYPE, cl::vector<cl_device_partition_property>) \
1344 F(cl_device_info, CL_DEVICE_REFERENCE_COUNT, cl_uint) \
1345 F(cl_device_info, CL_DEVICE_PREFERRED_INTEROP_USER_SYNC, cl_bool) \
1346 F(cl_device_info, CL_DEVICE_PARTITION_AFFINITY_DOMAIN, cl_device_affinity_domain) \
1347 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS, string) \
1348 F(cl_device_info, CL_DEVICE_PRINTF_BUFFER_SIZE, size_type) \
1350 F(cl_image_info, CL_IMAGE_ARRAY_SIZE, size_type) \
1351 F(cl_image_info, CL_IMAGE_NUM_MIP_LEVELS, cl_uint) \
1352 F(cl_image_info, CL_IMAGE_NUM_SAMPLES, cl_uint)
1354#define CL_HPP_PARAM_NAME_INFO_2_0_(F) \
1355 F(cl_device_info, CL_DEVICE_QUEUE_ON_HOST_PROPERTIES, cl_command_queue_properties) \
1356 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES, cl_command_queue_properties) \
1357 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE, cl_uint) \
1358 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE, cl_uint) \
1359 F(cl_device_info, CL_DEVICE_MAX_ON_DEVICE_QUEUES, cl_uint) \
1360 F(cl_device_info, CL_DEVICE_MAX_ON_DEVICE_EVENTS, cl_uint) \
1361 F(cl_device_info, CL_DEVICE_MAX_PIPE_ARGS, cl_uint) \
1362 F(cl_device_info, CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS, cl_uint) \
1363 F(cl_device_info, CL_DEVICE_PIPE_MAX_PACKET_SIZE, cl_uint) \
1364 F(cl_device_info, CL_DEVICE_SVM_CAPABILITIES, cl_device_svm_capabilities) \
1365 F(cl_device_info, CL_DEVICE_PREFERRED_PLATFORM_ATOMIC_ALIGNMENT, cl_uint) \
1366 F(cl_device_info, CL_DEVICE_PREFERRED_GLOBAL_ATOMIC_ALIGNMENT, cl_uint) \
1367 F(cl_device_info, CL_DEVICE_PREFERRED_LOCAL_ATOMIC_ALIGNMENT, cl_uint) \
1368 F(cl_device_info, CL_DEVICE_IMAGE_PITCH_ALIGNMENT, cl_uint) \
1369 F(cl_device_info, CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT, cl_uint) \
1370 F(cl_device_info, CL_DEVICE_MAX_READ_WRITE_IMAGE_ARGS, cl_uint ) \
1371 F(cl_device_info, CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE, size_type ) \
1372 F(cl_device_info, CL_DEVICE_GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE, size_type ) \
1373 F(cl_profiling_info, CL_PROFILING_COMMAND_COMPLETE, cl_ulong) \
1374 F(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM, cl_bool) \
1375 F(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_SVM_PTRS, void**) \
1376 F(cl_command_queue_info, CL_QUEUE_SIZE, cl_uint) \
1377 F(cl_mem_info, CL_MEM_USES_SVM_POINTER, cl_bool) \
1378 F(cl_program_build_info, CL_PROGRAM_BUILD_GLOBAL_VARIABLE_TOTAL_SIZE, size_type) \
1379 F(cl_pipe_info, CL_PIPE_PACKET_SIZE, cl_uint) \
1380 F(cl_pipe_info, CL_PIPE_MAX_PACKETS, cl_uint)
1382#define CL_HPP_PARAM_NAME_INFO_SUBGROUP_KHR_(F) \
1383 F(cl_kernel_sub_group_info, CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE_KHR, size_type) \
1384 F(cl_kernel_sub_group_info, CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE_KHR, size_type)
1386#define CL_HPP_PARAM_NAME_INFO_IL_KHR_(F) \
1387 F(cl_device_info, CL_DEVICE_IL_VERSION_KHR, string) \
1388 F(cl_program_info, CL_PROGRAM_IL_KHR, cl::vector<unsigned char>)
1390#define CL_HPP_PARAM_NAME_INFO_2_1_(F) \
1391 F(cl_platform_info, CL_PLATFORM_HOST_TIMER_RESOLUTION, cl_ulong) \
1392 F(cl_program_info, CL_PROGRAM_IL, cl::vector<unsigned char>) \
1393 F(cl_device_info, CL_DEVICE_MAX_NUM_SUB_GROUPS, cl_uint) \
1394 F(cl_device_info, CL_DEVICE_IL_VERSION, string) \
1395 F(cl_device_info, CL_DEVICE_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS, cl_bool) \
1396 F(cl_command_queue_info, CL_QUEUE_DEVICE_DEFAULT, cl::DeviceCommandQueue) \
1397 F(cl_kernel_sub_group_info, CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE, size_type) \
1398 F(cl_kernel_sub_group_info, CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE, size_type) \
1399 F(cl_kernel_sub_group_info, CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT, cl::detail::size_t_array) \
1400 F(cl_kernel_sub_group_info, CL_KERNEL_MAX_NUM_SUB_GROUPS, size_type) \
1401 F(cl_kernel_sub_group_info, CL_KERNEL_COMPILE_NUM_SUB_GROUPS, size_type)
1403#define CL_HPP_PARAM_NAME_INFO_2_2_(F) \
1404 F(cl_program_info, CL_PROGRAM_SCOPE_GLOBAL_CTORS_PRESENT, cl_bool) \
1405 F(cl_program_info, CL_PROGRAM_SCOPE_GLOBAL_DTORS_PRESENT, cl_bool)
1407#define CL_HPP_PARAM_NAME_DEVICE_FISSION_(F) \
1408 F(cl_device_info, CL_DEVICE_PARENT_DEVICE_EXT, cl_device_id) \
1409 F(cl_device_info, CL_DEVICE_PARTITION_TYPES_EXT, cl::vector<cl_device_partition_property_ext>) \
1410 F(cl_device_info, CL_DEVICE_AFFINITY_DOMAINS_EXT, cl::vector<cl_device_partition_property_ext>) \
1411 F(cl_device_info, CL_DEVICE_REFERENCE_COUNT_EXT , cl_uint) \
1412 F(cl_device_info, CL_DEVICE_PARTITION_STYLE_EXT, cl::vector<cl_device_partition_property_ext>)
1414#define CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_CL3_SHARED_(F) \
1415 F(cl_platform_info, CL_PLATFORM_NUMERIC_VERSION_KHR, cl_version_khr) \
1416 F(cl_platform_info, CL_PLATFORM_EXTENSIONS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>) \
1418 F(cl_device_info, CL_DEVICE_NUMERIC_VERSION_KHR, cl_version_khr) \
1419 F(cl_device_info, CL_DEVICE_EXTENSIONS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>) \
1420 F(cl_device_info, CL_DEVICE_ILS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>) \
1421 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>)
1423#define CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_KHRONLY_(F) \
1424 F(cl_device_info, CL_DEVICE_OPENCL_C_NUMERIC_VERSION_KHR, cl_version_khr)
1426#define CL_HPP_PARAM_NAME_INFO_3_0_(F) \
1427 F(cl_platform_info, CL_PLATFORM_NUMERIC_VERSION, cl_version) \
1428 F(cl_platform_info, CL_PLATFORM_EXTENSIONS_WITH_VERSION, cl::vector<cl_name_version>) \
1430 F(cl_device_info, CL_DEVICE_NUMERIC_VERSION, cl_version) \
1431 F(cl_device_info, CL_DEVICE_EXTENSIONS_WITH_VERSION, cl::vector<cl_name_version>) \
1432 F(cl_device_info, CL_DEVICE_ILS_WITH_VERSION, cl::vector<cl_name_version>) \
1433 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS_WITH_VERSION, cl::vector<cl_name_version>) \
1434 F(cl_device_info, CL_DEVICE_ATOMIC_MEMORY_CAPABILITIES, cl_device_atomic_capabilities) \
1435 F(cl_device_info, CL_DEVICE_ATOMIC_FENCE_CAPABILITIES, cl_device_atomic_capabilities) \
1436 F(cl_device_info, CL_DEVICE_NON_UNIFORM_WORK_GROUP_SUPPORT, cl_bool) \
1437 F(cl_device_info, CL_DEVICE_OPENCL_C_ALL_VERSIONS, cl::vector<cl_name_version>) \
1438 F(cl_device_info, CL_DEVICE_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, size_type) \
1439 F(cl_device_info, CL_DEVICE_WORK_GROUP_COLLECTIVE_FUNCTIONS_SUPPORT, cl_bool) \
1440 F(cl_device_info, CL_DEVICE_GENERIC_ADDRESS_SPACE_SUPPORT, cl_bool) \
1441 F(cl_device_info, CL_DEVICE_OPENCL_C_FEATURES, cl::vector<cl_name_version>) \
1442 F(cl_device_info, CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES, cl_device_device_enqueue_capabilities) \
1443 F(cl_device_info, CL_DEVICE_PIPE_SUPPORT, cl_bool) \
1444 F(cl_device_info, CL_DEVICE_LATEST_CONFORMANCE_VERSION_PASSED, string) \
1446 F(cl_command_queue_info, CL_QUEUE_PROPERTIES_ARRAY, cl::vector<cl_queue_properties>) \
1447 F(cl_mem_info, CL_MEM_PROPERTIES, cl::vector<cl_mem_properties>) \
1448 F(cl_pipe_info, CL_PIPE_PROPERTIES, cl::vector<cl_pipe_properties>) \
1449 F(cl_sampler_info, CL_SAMPLER_PROPERTIES, cl::vector<cl_sampler_properties>)
1451template <
typename enum_type, cl_
int Name>
1454#define CL_HPP_DECLARE_PARAM_TRAITS_(token, param_name, T) \
1457struct param_traits<detail:: token,param_name> \
1459 enum { value = param_name }; \
1460 typedef T param_type; \
1463CL_HPP_PARAM_NAME_INFO_1_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1464#if CL_HPP_TARGET_OPENCL_VERSION >= 110
1465CL_HPP_PARAM_NAME_INFO_1_1_(CL_HPP_DECLARE_PARAM_TRAITS_)
1467#if CL_HPP_TARGET_OPENCL_VERSION >= 120
1468CL_HPP_PARAM_NAME_INFO_1_2_(CL_HPP_DECLARE_PARAM_TRAITS_)
1470#if CL_HPP_TARGET_OPENCL_VERSION >= 200
1471CL_HPP_PARAM_NAME_INFO_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1473#if CL_HPP_TARGET_OPENCL_VERSION >= 210
1474CL_HPP_PARAM_NAME_INFO_2_1_(CL_HPP_DECLARE_PARAM_TRAITS_)
1476#if CL_HPP_TARGET_OPENCL_VERSION >= 220
1477CL_HPP_PARAM_NAME_INFO_2_2_(CL_HPP_DECLARE_PARAM_TRAITS_)
1479#if CL_HPP_TARGET_OPENCL_VERSION >= 300
1480CL_HPP_PARAM_NAME_INFO_3_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1483#if defined(CL_HPP_USE_CL_SUB_GROUPS_KHR) && CL_HPP_TARGET_OPENCL_VERSION < 210
1484CL_HPP_PARAM_NAME_INFO_SUBGROUP_KHR_(CL_HPP_DECLARE_PARAM_TRAITS_)
1487#if defined(CL_HPP_USE_IL_KHR) && CL_HPP_TARGET_OPENCL_VERSION < 210
1488CL_HPP_PARAM_NAME_INFO_IL_KHR_(CL_HPP_DECLARE_PARAM_TRAITS_)
1493#define CL_HPP_PARAM_NAME_INFO_1_0_DEPRECATED_IN_2_0_(F) \
1494 F(cl_device_info, CL_DEVICE_QUEUE_PROPERTIES, cl_command_queue_properties)
1496#define CL_HPP_PARAM_NAME_INFO_1_1_DEPRECATED_IN_2_0_(F) \
1497 F(cl_device_info, CL_DEVICE_HOST_UNIFIED_MEMORY, cl_bool)
1499#define CL_HPP_PARAM_NAME_INFO_1_2_DEPRECATED_IN_2_0_(F) \
1500 F(cl_image_info, CL_IMAGE_BUFFER, cl::Buffer)
1504#if CL_HPP_TARGET_OPENCL_VERSION > 100 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 && CL_HPP_TARGET_OPENCL_VERSION < 200
1505CL_HPP_PARAM_NAME_INFO_1_0_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1507#if CL_HPP_TARGET_OPENCL_VERSION > 110 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
1508CL_HPP_PARAM_NAME_INFO_1_1_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1510#if CL_HPP_TARGET_OPENCL_VERSION > 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
1511CL_HPP_PARAM_NAME_INFO_1_2_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1514#if defined(CL_HPP_USE_CL_DEVICE_FISSION)
1515CL_HPP_PARAM_NAME_DEVICE_FISSION_(CL_HPP_DECLARE_PARAM_TRAITS_);
1518#if defined(cl_khr_extended_versioning)
1519#if CL_HPP_TARGET_OPENCL_VERSION < 300
1520CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_CL3_SHARED_(CL_HPP_DECLARE_PARAM_TRAITS_)
1522CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_KHRONLY_(CL_HPP_DECLARE_PARAM_TRAITS_)
1525#if defined(cl_khr_device_uuid)
1526using uuid_array = array<cl_uchar, CL_UUID_SIZE_KHR>;
1527using luid_array = array<cl_uchar, CL_LUID_SIZE_KHR>;
1528CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_UUID_KHR, uuid_array)
1529CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DRIVER_UUID_KHR, uuid_array)
1530CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LUID_VALID_KHR, cl_bool)
1531CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LUID_KHR, luid_array)
1532CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_NODE_MASK_KHR, cl_uint)
1535#if defined(cl_khr_pci_bus_info)
1536CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_PCI_BUS_INFO_KHR, cl_device_pci_bus_info_khr)
1539#if defined(cl_khr_integer_dot_product)
1540CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGER_DOT_PRODUCT_CAPABILITIES_KHR, cl_device_integer_dot_product_capabilities_khr)
1541#if defined(CL_DEVICE_INTEGER_DOT_PRODUCT_ACCELERATION_PROPERTIES_8BIT_KHR)
1542CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGER_DOT_PRODUCT_ACCELERATION_PROPERTIES_8BIT_KHR, cl_device_integer_dot_product_acceleration_properties_khr)
1543CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGER_DOT_PRODUCT_ACCELERATION_PROPERTIES_4x8BIT_PACKED_KHR, cl_device_integer_dot_product_acceleration_properties_khr)
1547#ifdef CL_PLATFORM_ICD_SUFFIX_KHR
1548CL_HPP_DECLARE_PARAM_TRAITS_(cl_platform_info, CL_PLATFORM_ICD_SUFFIX_KHR,
string)
1551#ifdef CL_DEVICE_PROFILING_TIMER_OFFSET_AMD
1552CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_PROFILING_TIMER_OFFSET_AMD, cl_ulong)
1554#ifdef CL_DEVICE_GLOBAL_FREE_MEMORY_AMD
1555CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_FREE_MEMORY_AMD, vector<size_type>)
1557#ifdef CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD
1558CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD, cl_uint)
1560#ifdef CL_DEVICE_SIMD_WIDTH_AMD
1561CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_WIDTH_AMD, cl_uint)
1563#ifdef CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD
1564CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD, cl_uint)
1566#ifdef CL_DEVICE_WAVEFRONT_WIDTH_AMD
1567CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_WAVEFRONT_WIDTH_AMD, cl_uint)
1569#ifdef CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD
1570CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD, cl_uint)
1572#ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD
1573CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD, cl_uint)
1575#ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD
1576CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD, cl_uint)
1578#ifdef CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD
1579CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD, cl_uint)
1581#ifdef CL_DEVICE_LOCAL_MEM_BANKS_AMD
1582CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LOCAL_MEM_BANKS_AMD, cl_uint)
1584#ifdef CL_DEVICE_BOARD_NAME_AMD
1585CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_BOARD_NAME_AMD,
string)
1588#ifdef CL_DEVICE_COMPUTE_UNITS_BITFIELD_ARM
1589CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_UNITS_BITFIELD_ARM, cl_ulong)
1591#ifdef CL_DEVICE_JOB_SLOTS_ARM
1592CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_JOB_SLOTS_ARM, cl_uint)
1594#ifdef CL_DEVICE_SCHEDULING_CONTROLS_CAPABILITIES_ARM
1595CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SCHEDULING_CONTROLS_CAPABILITIES_ARM, cl_bitfield)
1597#ifdef CL_DEVICE_SUPPORTED_REGISTER_ALLOCATIONS_ARM
1598CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SUPPORTED_REGISTER_ALLOCATIONS_ARM, vector<cl_uint>)
1600#ifdef CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_ARM
1601CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_ARM, cl_uint)
1603#ifdef CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_MODIFIER_ARM
1604CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_MODIFIER_ARM, cl_int)
1607#ifdef CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV
1608CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV, cl_uint)
1610#ifdef CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV
1611CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV, cl_uint)
1613#ifdef CL_DEVICE_REGISTERS_PER_BLOCK_NV
1614CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_REGISTERS_PER_BLOCK_NV, cl_uint)
1616#ifdef CL_DEVICE_WARP_SIZE_NV
1617CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_WARP_SIZE_NV, cl_uint)
1619#ifdef CL_DEVICE_GPU_OVERLAP_NV
1620CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GPU_OVERLAP_NV, cl_bool)
1622#ifdef CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV
1623CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV, cl_bool)
1625#ifdef CL_DEVICE_INTEGRATED_MEMORY_NV
1626CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGRATED_MEMORY_NV, cl_bool)
1631template <
typename Func,
typename T>
1633getInfo(Func f, cl_uint name, T* param)
1635 return getInfoHelper(f, name, param, 0);
1638template <
typename Func,
typename Arg0>
1641 Func f_;
const Arg0& arg0_;
1643 cl_uint param, size_type size,
void* value, size_type* size_ret)
1644 {
return f_(arg0_, param, size, value, size_ret); }
1647template <
typename Func,
typename Arg0,
typename Arg1>
1650 Func f_;
const Arg0& arg0_;
const Arg1& arg1_;
1652 cl_uint param, size_type size,
void* value, size_type* size_ret)
1653 {
return f_(arg0_, arg1_, param, size, value, size_ret); }
1656template <
typename Func,
typename Arg0,
typename T>
1658getInfo(Func f,
const Arg0& arg0, cl_uint name, T* param)
1661 return getInfoHelper(f0, name, param, 0);
1664template <
typename Func,
typename Arg0,
typename Arg1,
typename T>
1666getInfo(Func f,
const Arg0& arg0,
const Arg1& arg1, cl_uint name, T* param)
1668 GetInfoFunctor1<Func, Arg0, Arg1> f0 = { f, arg0, arg1 };
1669 return getInfoHelper(f0, name, param, 0);
1677#if CL_HPP_TARGET_OPENCL_VERSION >= 120
1694 { return ::clRetainDevice(device); }
1705 { return ::clReleaseDevice(device); }
1712struct ReferenceHandler<cl_device_id>
1715 static cl_int retain(cl_device_id)
1716 {
return CL_SUCCESS; }
1718 static cl_int release(cl_device_id)
1719 {
return CL_SUCCESS; }
1727 static cl_int retain(cl_platform_id)
1728 {
return CL_SUCCESS; }
1730 static cl_int release(cl_platform_id)
1731 {
return CL_SUCCESS; }
1737 static cl_int retain(cl_context context)
1738 { return ::clRetainContext(context); }
1739 static cl_int release(cl_context context)
1740 { return ::clReleaseContext(context); }
1746 static cl_int retain(cl_command_queue queue)
1747 { return ::clRetainCommandQueue(queue); }
1748 static cl_int release(cl_command_queue queue)
1749 { return ::clReleaseCommandQueue(queue); }
1755 static cl_int retain(cl_mem memory)
1756 { return ::clRetainMemObject(memory); }
1757 static cl_int release(cl_mem memory)
1758 { return ::clReleaseMemObject(memory); }
1764 static cl_int retain(cl_sampler sampler)
1765 { return ::clRetainSampler(sampler); }
1766 static cl_int release(cl_sampler sampler)
1767 { return ::clReleaseSampler(sampler); }
1773 static cl_int retain(cl_program program)
1774 { return ::clRetainProgram(program); }
1775 static cl_int release(cl_program program)
1776 { return ::clReleaseProgram(program); }
1782 static cl_int retain(cl_kernel kernel)
1783 { return ::clRetainKernel(kernel); }
1784 static cl_int release(cl_kernel kernel)
1785 { return ::clReleaseKernel(kernel); }
1791 static cl_int retain(cl_event event)
1792 { return ::clRetainEvent(event); }
1793 static cl_int release(cl_event event)
1794 { return ::clReleaseEvent(event); }
1798#if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
1800static cl_uint getVersion(
const vector<char> &versionInfo)
1802 int highVersion = 0;
1805 while(versionInfo[index] !=
'.' ) {
1807 highVersion += versionInfo[index]-
'0';
1811 while(versionInfo[index] !=
' ' && versionInfo[index] !=
'\0') {
1813 lowVersion += versionInfo[index]-
'0';
1816 return (highVersion << 16) | lowVersion;
1819static cl_uint getPlatformVersion(cl_platform_id platform)
1822 clGetPlatformInfo(platform, CL_PLATFORM_VERSION, 0, NULL, &size);
1824 vector<char> versionInfo(size);
1825 clGetPlatformInfo(platform, CL_PLATFORM_VERSION, size, versionInfo.data(), &size);
1826 return getVersion(versionInfo);
1829static cl_uint getDevicePlatformVersion(cl_device_id device)
1831 cl_platform_id platform;
1832 clGetDeviceInfo(device, CL_DEVICE_PLATFORM,
sizeof(platform), &platform, NULL);
1833 return getPlatformVersion(platform);
1836static cl_uint getContextPlatformVersion(cl_context context)
1841 clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, NULL, &size);
1844 vector<cl_device_id> devices(size/
sizeof(cl_device_id));
1845 clGetContextInfo(context, CL_CONTEXT_DEVICES, size, devices.data(), NULL);
1846 return getDevicePlatformVersion(devices[0]);
1850template <
typename T>
1862 Wrapper(
const cl_type &obj,
bool retainObject) : object_(obj)
1865 detail::errHandler(retain(), __RETAIN_ERR);
1871 if (object_ != NULL) { release(); }
1876 object_ = rhs.object_;
1877 detail::errHandler(retain(), __RETAIN_ERR);
1882 object_ = rhs.object_;
1889 detail::errHandler(release(), __RELEASE_ERR);
1890 object_ = rhs.object_;
1891 detail::errHandler(retain(), __RETAIN_ERR);
1899 detail::errHandler(release(), __RELEASE_ERR);
1900 object_ = rhs.object_;
1908 detail::errHandler(release(), __RELEASE_ERR);
1913 const cl_type& operator ()()
const {
return object_; }
1915 cl_type& operator ()() {
return object_; }
1917 cl_type get()
const {
return object_; }
1920 template<
typename Func,
typename U>
1921 friend inline cl_int getInfoHelper(Func, cl_uint, U*,
int,
typename U::cl_type);
1923 cl_int retain()
const
1925 if (object_ !=
nullptr) {
1933 cl_int release()
const
1935 if (object_ !=
nullptr) {
1948 typedef cl_device_id cl_type;
1952 bool referenceCountable_;
1954 static bool isReferenceCountable(cl_device_id device)
1956 bool retVal =
false;
1957#if CL_HPP_TARGET_OPENCL_VERSION >= 120
1958#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
1959 if (device != NULL) {
1960 int version = getDevicePlatformVersion(device);
1961 if(version > ((1 << 16) + 1)) {
1974 Wrapper() : object_(NULL), referenceCountable_(
false)
1978 Wrapper(
const cl_type &obj,
bool retainObject) :
1980 referenceCountable_(
false)
1982 referenceCountable_ = isReferenceCountable(obj);
1985 detail::errHandler(retain(), __RETAIN_ERR);
1996 object_ = rhs.object_;
1997 referenceCountable_ = isReferenceCountable(object_);
1998 detail::errHandler(retain(), __RETAIN_ERR);
2003 object_ = rhs.object_;
2004 referenceCountable_ = rhs.referenceCountable_;
2006 rhs.referenceCountable_ =
false;
2012 detail::errHandler(release(), __RELEASE_ERR);
2013 object_ = rhs.object_;
2014 referenceCountable_ = rhs.referenceCountable_;
2015 detail::errHandler(retain(), __RETAIN_ERR);
2023 detail::errHandler(release(), __RELEASE_ERR);
2024 object_ = rhs.object_;
2025 referenceCountable_ = rhs.referenceCountable_;
2027 rhs.referenceCountable_ =
false;
2034 detail::errHandler(release(), __RELEASE_ERR);
2036 referenceCountable_ = isReferenceCountable(object_);
2040 const cl_type& operator ()()
const {
return object_; }
2042 cl_type& operator ()() {
return object_; }
2044 cl_type get()
const {
return object_; }
2047 template<
typename Func,
typename U>
2048 friend inline cl_int getInfoHelper(Func, cl_uint, U*,
int,
typename U::cl_type);
2050 template<
typename Func,
typename U>
2051 friend inline cl_int getInfoHelper(Func, cl_uint, vector<U>*,
int,
typename U::cl_type);
2053 cl_int retain()
const
2055 if( object_ !=
nullptr && referenceCountable_ ) {
2063 cl_int release()
const
2065 if (object_ !=
nullptr && referenceCountable_) {
2074template <
typename T>
2077 return lhs() == rhs();
2080template <
typename T>
2081inline bool operator!=(
const Wrapper<T> &lhs,
const Wrapper<T> &rhs)
2083 return !operator==(lhs, rhs);
2090using BuildLogType = vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, CL_PROGRAM_BUILD_LOG>::param_type>>;
2091#if defined(CL_HPP_ENABLE_EXCEPTIONS)
2095class BuildError :
public Error
2098 BuildLogType buildLogs;
2100 BuildError(cl_int err,
const char * errStr,
const BuildLogType &vec) : Error(err, errStr), buildLogs(vec)
2104 BuildLogType getBuildLog()
const
2110 static inline cl_int buildErrHandler(
2112 const char * errStr,
2113 const BuildLogType &buildLogs)
2115 if (err != CL_SUCCESS) {
2116 throw BuildError(err, errStr, buildLogs);
2124 static inline cl_int buildErrHandler(
2126 const char * errStr,
2127 const BuildLogType &buildLogs)
2150 image_channel_order = order;
2151 image_channel_data_type = type;
2161 this->image_channel_data_type = rhs.image_channel_data_type;
2162 this->image_channel_order = rhs.image_channel_order;
2178 static std::once_flag default_initialized_;
2180 static cl_int default_error_;
2187 static void makeDefault();
2194 static void makeDefaultProvided(
const Device &p) {
2199#ifdef CL_HPP_UNIT_TEST_ENABLE
2206 static void unitTestClearDefault() {
2218 explicit Device(
const cl_device_id &device,
bool retainObject =
false) :
2219 detail::Wrapper<cl_type>(device, retainObject) { }
2226 cl_int *errResult = NULL)
2228 std::call_once(default_initialized_, makeDefault);
2229 detail::errHandler(default_error_);
2230 if (errResult != NULL) {
2231 *errResult = default_error_;
2245 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_device));
2246 detail::errHandler(default_error_);
2289 template <
typename T>
2290 cl_int
getInfo(cl_device_info name, T* param)
const
2292 return detail::errHandler(
2293 detail::getInfo(&::clGetDeviceInfo, object_, name, param),
2294 __GET_DEVICE_INFO_ERR);
2298 template <cl_device_info name>
typename
2303 detail::cl_device_info, name>::param_type param;
2304 cl_int result =
getInfo(name, ¶m);
2312#if CL_HPP_TARGET_OPENCL_VERSION >= 210
2321 cl_ulong retVal = 0;
2323 clGetHostTimer(this->get(), &retVal);
2326 __GET_HOST_TIMER_ERR);
2345 std::pair<cl_ulong, cl_ulong> retVal;
2347 clGetDeviceAndHostTimer(this->get(), &(retVal.first), &(retVal.second));
2350 __GET_DEVICE_AND_HOST_TIMER_ERR);
2361#if CL_HPP_TARGET_OPENCL_VERSION >= 120
2364 const cl_device_partition_property * properties,
2365 vector<Device>* devices)
2368 cl_int err = clCreateSubDevices(object_, properties, 0, NULL, &n);
2369 if (err != CL_SUCCESS) {
2370 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2373 vector<cl_device_id> ids(n);
2374 err = clCreateSubDevices(object_, properties, n, ids.data(), NULL);
2375 if (err != CL_SUCCESS) {
2376 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2382 devices->resize(ids.size());
2386 for (size_type i = 0; i < ids.size(); i++) {
2389 (*devices)[i] =
Device(ids[i],
false);
2395#elif defined(CL_HPP_USE_CL_DEVICE_FISSION)
2401 const cl_device_partition_property_ext * properties,
2402 vector<Device>* devices)
2404 typedef CL_API_ENTRY cl_int
2405 ( CL_API_CALL * PFN_clCreateSubDevicesEXT)(
2407 const cl_device_partition_property_ext * ,
2410 cl_uint * ) CL_API_SUFFIX__VERSION_1_1;
2412 static PFN_clCreateSubDevicesEXT pfn_clCreateSubDevicesEXT = NULL;
2413 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateSubDevicesEXT);
2416 cl_int err = pfn_clCreateSubDevicesEXT(object_, properties, 0, NULL, &n);
2417 if (err != CL_SUCCESS) {
2418 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2421 vector<cl_device_id> ids(n);
2422 err = pfn_clCreateSubDevicesEXT(object_, properties, n, ids.data(), NULL);
2423 if (err != CL_SUCCESS) {
2424 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2429 devices->resize(ids.size());
2433 for (size_type i = 0; i < ids.size(); i++) {
2436 (*devices)[i] =
Device(ids[i],
false);
2444CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Device::default_initialized_;
2445CL_HPP_DEFINE_STATIC_MEMBER_ Device Device::default_;
2446CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Device::default_error_ = CL_SUCCESS;
2458 static std::once_flag default_initialized_;
2460 static cl_int default_error_;
2467 static void makeDefault() {
2471#if defined(CL_HPP_ENABLE_EXCEPTIONS)
2479 cl_int err = ::clGetPlatformIDs(0, NULL, &n);
2480 if (err != CL_SUCCESS) {
2481 default_error_ = err;
2485 default_error_ = CL_INVALID_PLATFORM;
2489 vector<cl_platform_id> ids(n);
2490 err = ::clGetPlatformIDs(n, ids.data(), NULL);
2491 if (err != CL_SUCCESS) {
2492 default_error_ = err;
2498#if defined(CL_HPP_ENABLE_EXCEPTIONS)
2499 catch (cl::Error &e) {
2500 default_error_ = e.err();
2510 static void makeDefaultProvided(
const Platform &p) {
2515#ifdef CL_HPP_UNIT_TEST_ENABLE
2522 static void unitTestClearDefault() {
2537 explicit Platform(
const cl_platform_id &platform,
bool retainObject =
false) :
2538 detail::Wrapper<cl_type>(platform, retainObject) { }
2551 cl_int *errResult = NULL)
2553 std::call_once(default_initialized_, makeDefault);
2554 detail::errHandler(default_error_);
2555 if (errResult != NULL) {
2556 *errResult = default_error_;
2570 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_platform));
2571 detail::errHandler(default_error_);
2576 template <
typename T>
2577 cl_int
getInfo(cl_platform_info name, T* param)
const
2579 return detail::errHandler(
2580 detail::getInfo(&::clGetPlatformInfo, object_, name, param),
2581 __GET_PLATFORM_INFO_ERR);
2585 template <cl_platform_info name>
typename
2590 detail::cl_platform_info, name>::param_type param;
2591 cl_int result =
getInfo(name, ¶m);
2603 cl_device_type type,
2604 vector<Device>* devices)
const
2607 if( devices == NULL ) {
2608 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR);
2610 cl_int err = ::clGetDeviceIDs(object_, type, 0, NULL, &n);
2611 if (err != CL_SUCCESS && err != CL_DEVICE_NOT_FOUND) {
2612 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2615 vector<cl_device_id> ids(n);
2617 err = ::clGetDeviceIDs(object_, type, n, ids.data(), NULL);
2618 if (err != CL_SUCCESS) {
2619 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2628 devices->resize(ids.size());
2632 for (size_type i = 0; i < ids.size(); i++) {
2633 (*devices)[i] =
Device(ids[i],
true);
2639#if defined(CL_HPP_USE_DX_INTEROP)
2664 cl_d3d10_device_source_khr d3d_device_source,
2666 cl_d3d10_device_set_khr d3d_device_set,
2667 vector<Device>* devices)
const
2669 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clGetDeviceIDsFromD3D10KHR)(
2670 cl_platform_id platform,
2671 cl_d3d10_device_source_khr d3d_device_source,
2673 cl_d3d10_device_set_khr d3d_device_set,
2674 cl_uint num_entries,
2675 cl_device_id * devices,
2676 cl_uint* num_devices);
2678 if( devices == NULL ) {
2679 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR);
2682 static PFN_clGetDeviceIDsFromD3D10KHR pfn_clGetDeviceIDsFromD3D10KHR = NULL;
2683 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(object_, clGetDeviceIDsFromD3D10KHR);
2686 cl_int err = pfn_clGetDeviceIDsFromD3D10KHR(
2694 if (err != CL_SUCCESS) {
2695 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2698 vector<cl_device_id> ids(n);
2699 err = pfn_clGetDeviceIDsFromD3D10KHR(
2707 if (err != CL_SUCCESS) {
2708 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2716 devices->resize(ids.size());
2720 for (size_type i = 0; i < ids.size(); i++) {
2721 (*devices)[i] = Device(ids[i],
true);
2733 vector<Platform>* platforms)
2737 if( platforms == NULL ) {
2738 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_PLATFORM_IDS_ERR);
2741 cl_int err = ::clGetPlatformIDs(0, NULL, &n);
2742 if (err != CL_SUCCESS) {
2743 return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
2746 vector<cl_platform_id> ids(n);
2747 err = ::clGetPlatformIDs(n, ids.data(), NULL);
2748 if (err != CL_SUCCESS) {
2749 return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
2753 platforms->resize(ids.size());
2756 for (size_type i = 0; i < ids.size(); i++) {
2757 (*platforms)[i] =
Platform(ids[i]);
2771 Platform default_platform = Platform::getDefault(&err);
2773 *platform = default_platform;
2787 cl_int * errResult = NULL)
2790 Platform default_platform = Platform::getDefault(&err);
2794 return default_platform;
2797#if CL_HPP_TARGET_OPENCL_VERSION >= 120
2802 return ::clUnloadPlatformCompiler(object_);
2807CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Platform::default_initialized_;
2808CL_HPP_DEFINE_STATIC_MEMBER_ Platform Platform::default_;
2809CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Platform::default_error_ = CL_SUCCESS;
2815#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
2820inline CL_API_PREFIX__VERSION_1_1_DEPRECATED cl_int
2825 return ::clUnloadCompiler();
2841 static std::once_flag default_initialized_;
2843 static cl_int default_error_;
2850 static void makeDefault() {
2854#if defined(CL_HPP_ENABLE_EXCEPTIONS)
2858#if !defined(__APPLE__) && !defined(__MACOS)
2859 const Platform &p = Platform::getDefault();
2860 cl_platform_id defaultPlatform = p();
2861 cl_context_properties properties[3] = {
2862 CL_CONTEXT_PLATFORM, (cl_context_properties)defaultPlatform, 0
2865 cl_context_properties *properties =
nullptr;
2869 CL_DEVICE_TYPE_DEFAULT,
2875#if defined(CL_HPP_ENABLE_EXCEPTIONS)
2876 catch (cl::Error &e) {
2877 default_error_ = e.err();
2888 static void makeDefaultProvided(
const Context &c) {
2893#ifdef CL_HPP_UNIT_TEST_ENABLE
2900 static void unitTestClearDefault() {
2910 const vector<Device>& devices,
2911 const cl_context_properties* properties = NULL,
2912 void (CL_CALLBACK * notifyFptr)(
2922 size_type numDevices = devices.size();
2923 vector<cl_device_id> deviceIDs(numDevices);
2925 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
2926 deviceIDs[deviceIndex] = (devices[deviceIndex])();
2929 object_ = ::clCreateContext(
2930 properties, (cl_uint) numDevices,
2932 notifyFptr, data, &error);
2934 detail::errHandler(error, __CREATE_CONTEXT_ERR);
2946 const cl_context_properties* properties = NULL,
2947 void (CL_CALLBACK * notifyFptr)(
2957 cl_device_id deviceID = device();
2959 object_ = ::clCreateContext(
2962 notifyFptr, data, &error);
2964 detail::errHandler(error, __CREATE_CONTEXT_ERR);
2975 cl_device_type type,
2976 const cl_context_properties* properties = NULL,
2977 void (CL_CALLBACK * notifyFptr)(
2987#if !defined(__APPLE__) && !defined(__MACOS)
2988 cl_context_properties prop[4] = {CL_CONTEXT_PLATFORM, 0, 0, 0 };
2990 if (properties == NULL) {
2992 vector<Platform> platforms;
2993 error = Platform::get(&platforms);
2994 if (error != CL_SUCCESS) {
2995 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
3003 cl_context_properties platform_id = 0;
3004 for (
unsigned int i = 0; i < platforms.size(); i++) {
3006 vector<Device> devices;
3008#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3012 error = platforms[i].getDevices(type, &devices);
3014#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3015 }
catch (cl::Error& e) {
3023 if (error != CL_SUCCESS && error != CL_DEVICE_NOT_FOUND) {
3024 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
3030 if (devices.size() > 0) {
3031 platform_id = (cl_context_properties)platforms[i]();
3036 if (platform_id == 0) {
3037 detail::errHandler(CL_DEVICE_NOT_FOUND, __CREATE_CONTEXT_FROM_TYPE_ERR);
3039 *err = CL_DEVICE_NOT_FOUND;
3044 prop[1] = platform_id;
3045 properties = &prop[0];
3048 object_ = ::clCreateContextFromType(
3049 properties, type, notifyFptr, data, &error);
3051 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
3092 std::call_once(default_initialized_, makeDefault);
3093 detail::errHandler(default_error_);
3095 *err = default_error_;
3109 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_context));
3110 detail::errHandler(default_error_);
3122 explicit Context(
const cl_context& context,
bool retainObject =
false) :
3123 detail::Wrapper<cl_type>(context, retainObject) { }
3137 template <
typename T>
3138 cl_int
getInfo(cl_context_info name, T* param)
const
3140 return detail::errHandler(
3141 detail::getInfo(&::clGetContextInfo, object_, name, param),
3142 __GET_CONTEXT_INFO_ERR);
3146 template <cl_context_info name>
typename
3151 detail::cl_context_info, name>::param_type param;
3152 cl_int result =
getInfo(name, ¶m);
3165 cl_mem_object_type type,
3166 vector<ImageFormat>* formats)
const
3174 cl_int err = ::clGetSupportedImageFormats(
3181 if (err != CL_SUCCESS) {
3182 return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
3185 if (numEntries > 0) {
3186 vector<ImageFormat> value(numEntries);
3187 err = ::clGetSupportedImageFormats(
3192 (cl_image_format*)value.data(),
3194 if (err != CL_SUCCESS) {
3195 return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
3198 formats->assign(begin(value), end(value));
3209inline void Device::makeDefault()
3214#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3221 detail::errHandler(error, __CREATE_CONTEXT_ERR);
3223 if (error != CL_SUCCESS) {
3224 default_error_ = error;
3227 default_ = context.
getInfo<CL_CONTEXT_DEVICES>()[0];
3228 default_error_ = CL_SUCCESS;
3231#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3232 catch (cl::Error &e) {
3233 default_error_ = e.err();
3238CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Context::default_initialized_;
3239CL_HPP_DEFINE_STATIC_MEMBER_ Context Context::default_;
3240CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Context::default_error_ = CL_SUCCESS;
3254 Event() : detail::Wrapper<cl_type>() { }
3264 explicit Event(
const cl_event& event,
bool retainObject =
false) :
3265 detail::Wrapper<cl_type>(event, retainObject) { }
3279 template <
typename T>
3280 cl_int
getInfo(cl_event_info name, T* param)
const
3282 return detail::errHandler(
3283 detail::getInfo(&::clGetEventInfo, object_, name, param),
3284 __GET_EVENT_INFO_ERR);
3288 template <cl_event_info name>
typename
3293 detail::cl_event_info, name>::param_type param;
3294 cl_int result =
getInfo(name, ¶m);
3302 template <
typename T>
3305 return detail::errHandler(detail::getInfo(
3306 &::clGetEventProfilingInfo, object_, name, param),
3307 __GET_EVENT_PROFILE_INFO_ERR);
3311 template <cl_profiling_info name>
typename
3316 detail::cl_profiling_info, name>::param_type param;
3330 return detail::errHandler(
3331 ::clWaitForEvents(1, &object_),
3332 __WAIT_FOR_EVENTS_ERR);
3335#if CL_HPP_TARGET_OPENCL_VERSION >= 110
3342 void (CL_CALLBACK * pfn_notify)(cl_event, cl_int,
void *),
3343 void * user_data = NULL)
3345 return detail::errHandler(
3346 ::clSetEventCallback(
3351 __SET_EVENT_CALLBACK_ERR);
3362 return detail::errHandler(
3364 (cl_uint) events.size(), (events.size() > 0) ? (cl_event*)&events.front() : NULL),
3365 __WAIT_FOR_EVENTS_ERR);
3369#if CL_HPP_TARGET_OPENCL_VERSION >= 110
3383 cl_int * err = NULL)
3386 object_ = ::clCreateUserEvent(
3390 detail::errHandler(error, __CREATE_USER_EVENT_ERR);
3405 return detail::errHandler(
3406 ::clSetUserEventStatus(object_,status),
3407 __SET_USER_EVENT_STATUS_ERR);
3417WaitForEvents(
const vector<Event>& events)
3419 return detail::errHandler(
3421 (cl_uint) events.size(), (events.size() > 0) ? (cl_event*)&events.front() : NULL),
3422 __WAIT_FOR_EVENTS_ERR);
3450 explicit Memory(
const cl_mem& memory,
bool retainObject) :
3451 detail::Wrapper<cl_type>(memory, retainObject) { }
3494 template <
typename T>
3497 return detail::errHandler(
3498 detail::getInfo(&::clGetMemObjectInfo, object_, name, param),
3499 __GET_MEM_OBJECT_INFO_ERR);
3503 template <cl_mem_info name>
typename
3508 detail::cl_mem_info, name>::param_type param;
3509 cl_int result =
getInfo(name, ¶m);
3516#if CL_HPP_TARGET_OPENCL_VERSION >= 110
3531 void (CL_CALLBACK * pfn_notify)(cl_mem,
void *),
3532 void * user_data = NULL)
3534 return detail::errHandler(
3535 ::clSetMemObjectDestructorCallback(
3539 __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR);
3547template<
typename IteratorType >
3548cl_int
copy( IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer );
3549template<
typename IteratorType >
3550cl_int
copy(
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator );
3551template<
typename IteratorType >
3552cl_int
copy(
const CommandQueue &queue, IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer );
3553template<
typename IteratorType >
3554cl_int
copy(
const CommandQueue &queue,
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator );
3557#if CL_HPP_TARGET_OPENCL_VERSION >= 200
3563 static cl_svm_mem_flags getSVMMemFlags()
3570template<
class Trait = detail::SVMTraitNull>
3574 static cl_svm_mem_flags getSVMMemFlags()
3576 return CL_MEM_READ_WRITE |
3577 Trait::getSVMMemFlags();
3581template<
class Trait = detail::SVMTraitNull>
3585 static cl_svm_mem_flags getSVMMemFlags()
3587 return CL_MEM_READ_ONLY |
3588 Trait::getSVMMemFlags();
3592template<
class Trait = detail::SVMTraitNull>
3596 static cl_svm_mem_flags getSVMMemFlags()
3598 return CL_MEM_WRITE_ONLY |
3599 Trait::getSVMMemFlags();
3603template<
class Trait = SVMTraitReadWrite<>>
3607 static cl_svm_mem_flags getSVMMemFlags()
3609 return Trait::getSVMMemFlags();
3613template<
class Trait = SVMTraitReadWrite<>>
3617 static cl_svm_mem_flags getSVMMemFlags()
3619 return CL_MEM_SVM_FINE_GRAIN_BUFFER |
3620 Trait::getSVMMemFlags();
3624template<
class Trait = SVMTraitReadWrite<>>
3628 static cl_svm_mem_flags getSVMMemFlags()
3631 CL_MEM_SVM_FINE_GRAIN_BUFFER |
3632 CL_MEM_SVM_ATOMICS |
3633 Trait::getSVMMemFlags();
3644 const vector<Event>* events = NULL,
3645 Event* event = NULL);
3658template<
typename T,
class SVMTrait>
3664 typedef T value_type;
3665 typedef value_type* pointer;
3666 typedef const value_type* const_pointer;
3667 typedef value_type& reference;
3668 typedef const value_type& const_reference;
3669 typedef std::size_t size_type;
3670 typedef std::ptrdiff_t difference_type;
3672 template<
typename U>
3678 template<
typename U,
typename V>
3682 context_(
Context::getDefault())
3692 SVMAllocator(
const SVMAllocator &other) :
3693 context_(other.context_)
3697 template<
typename U>
3698 SVMAllocator(
const SVMAllocator<U, SVMTrait> &other) :
3699 context_(other.context_)
3707 pointer address(reference r) CL_HPP_NOEXCEPT_
3709 return std::addressof(r);
3712 const_pointer address(const_reference r) CL_HPP_NOEXCEPT_
3714 return std::addressof(r);
3731 SVMTrait::getSVMMemFlags(),
3734 pointer retValue =
reinterpret_cast<pointer
>(
3736#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3738 std::bad_alloc excep;
3744 if (!(SVMTrait::getSVMMemFlags() & CL_MEM_SVM_FINE_GRAIN_BUFFER)) {
3745 cl_int err =
enqueueMapSVM(retValue, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE, size*
sizeof(T));
3746 if (err != CL_SUCCESS) {
3747 std::bad_alloc excep;
3756 void deallocate(pointer p, size_type)
3758 clSVMFree(context_(), p);
3767 size_type maxSize = std::numeric_limits<size_type>::max() /
sizeof(T);
3769 for (
const Device &d : context_.
getInfo<CL_CONTEXT_DEVICES>()) {
3772 static_cast<size_type
>(d.getInfo<CL_DEVICE_MAX_MEM_ALLOC_SIZE>()));
3778 template<
class U,
class... Args >
3779 void construct(U* p, Args&&... args)
3795 return (context_==rhs.context_);
3805template<
class SVMTrait>
3808 typedef void value_type;
3809 typedef value_type* pointer;
3810 typedef const value_type* const_pointer;
3812 template<
typename U>
3818 template<
typename U,
typename V>
3822#if !defined(CL_HPP_NO_STD_UNIQUE_PTR)
3825 template<
class Alloc>
3832 typedef typename std::allocator_traits<Alloc>::pointer pointer;
3834 Deleter(
const Alloc &alloc, size_type copies) : alloc_{ alloc }, copies_{ copies }
3838 void operator()(pointer ptr)
const {
3839 Alloc tmpAlloc{ alloc_ };
3840 std::allocator_traits<Alloc>::destroy(tmpAlloc, std::addressof(*ptr));
3841 std::allocator_traits<Alloc>::deallocate(tmpAlloc, ptr, copies_);
3852template <
class T,
class Alloc,
class... Args>
3855 Alloc alloc(alloc_);
3856 static const size_type copies = 1;
3861 T* tmp = std::allocator_traits<Alloc>::allocate(alloc, copies);
3863 std::bad_alloc excep;
3867 std::allocator_traits<Alloc>::construct(
3869 std::addressof(*tmp),
3870 std::forward<Args>(args)...);
3874 catch (std::bad_alloc& b)
3876 std::allocator_traits<Alloc>::deallocate(alloc, tmp, copies);
3881template<
class T,
class SVMTrait,
class... Args >
3882cl::pointer<T, detail::Deleter<SVMAllocator<T, SVMTrait>>> allocate_svm(Args... args)
3884 SVMAllocator<T, SVMTrait> alloc;
3885 return cl::allocate_pointer<T>(alloc, args...);
3888template<
class T,
class SVMTrait,
class... Args >
3889cl::pointer<T, detail::Deleter<SVMAllocator<T, SVMTrait>>> allocate_svm(
const cl::Context &c, Args... args)
3891 SVMAllocator<T, SVMTrait> alloc(c);
3892 return cl::allocate_pointer<T>(alloc, args...);
3938 void* host_ptr = NULL,
3942 object_ = ::clCreateBuffer(context(), flags, size, host_ptr, &error);
3944 detail::errHandler(error, __CREATE_BUFFER_ERR);
3962 void* host_ptr = NULL,
3969 object_ = ::clCreateBuffer(context(), flags, size, host_ptr, &error);
3971 detail::errHandler(error, __CREATE_BUFFER_ERR);
3982 template<
typename IteratorType >
3984 IteratorType startIterator,
3985 IteratorType endIterator,
3987 bool useHostPtr =
false,
3990 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
3993 cl_mem_flags flags = 0;
3995 flags |= CL_MEM_READ_ONLY;
3998 flags |= CL_MEM_READ_WRITE;
4001 flags |= CL_MEM_USE_HOST_PTR;
4004 size_type size =
sizeof(DataType)*(endIterator - startIterator);
4009 object_ = ::clCreateBuffer(context(), flags, size,
static_cast<DataType*
>(&*startIterator), &error);
4011 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
4014 detail::errHandler(error, __CREATE_BUFFER_ERR);
4020 error =
cl::copy(startIterator, endIterator, *
this);
4021 detail::errHandler(error, __CREATE_BUFFER_ERR);
4033 template<
typename IteratorType >
4034 Buffer(
const Context &context, IteratorType startIterator, IteratorType endIterator,
4035 bool readOnly,
bool useHostPtr =
false, cl_int* err = NULL);
4041 template<
typename IteratorType >
4042 Buffer(
const CommandQueue &queue, IteratorType startIterator, IteratorType endIterator,
4043 bool readOnly,
bool useHostPtr =
false, cl_int* err = NULL);
4055 explicit Buffer(
const cl_mem& buffer,
bool retainObject =
false) :
4056 Memory(buffer, retainObject) { }
4096#if CL_HPP_TARGET_OPENCL_VERSION >= 110
4103 cl_buffer_create_type buffer_create_type,
4104 const void * buffer_create_info,
4105 cl_int * err = NULL)
4109 result.object_ = ::clCreateSubBuffer(
4116 detail::errHandler(error, __CREATE_SUBBUFFER_ERR);
4126#if defined (CL_HPP_USE_DX_INTEROP)
4135class BufferD3D10 :
public Buffer
4146 const Context& context,
4148 ID3D10Buffer* bufobj,
4149 cl_int * err = NULL) : pfn_clCreateFromD3D10BufferKHR(nullptr)
4151 typedef CL_API_ENTRY cl_mem (CL_API_CALL *PFN_clCreateFromD3D10BufferKHR)(
4152 cl_context context, cl_mem_flags flags, ID3D10Buffer* buffer,
4153 cl_int* errcode_ret);
4154 PFN_clCreateFromD3D10BufferKHR pfn_clCreateFromD3D10BufferKHR;
4155#if CL_HPP_TARGET_OPENCL_VERSION >= 120
4156 vector<cl_context_properties> props = context.getInfo<CL_CONTEXT_PROPERTIES>();
4157 cl_platform platform = -1;
4158 for(
int i = 0; i < props.size(); ++i ) {
4159 if( props[i] == CL_CONTEXT_PLATFORM ) {
4160 platform = props[i+1];
4163 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCreateFromD3D10BufferKHR);
4164#elif CL_HPP_TARGET_OPENCL_VERSION >= 110
4165 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateFromD3D10BufferKHR);
4169 object_ = pfn_clCreateFromD3D10BufferKHR(
4175 detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
4182 BufferD3D10() : Buffer() { }
4191 explicit BufferD3D10(
const cl_mem& buffer,
bool retainObject =
false) :
4192 Buffer(buffer, retainObject) { }
4198 BufferD3D10& operator = (
const cl_mem& rhs)
4207 BufferD3D10(
const BufferD3D10& buf) :
4213 BufferD3D10& operator = (
const BufferD3D10 &buf)
4222 BufferD3D10(BufferD3D10&& buf) CL_HPP_NOEXCEPT_ : Buffer(std::move(buf)) {}
4227 BufferD3D10& operator = (BufferD3D10 &&buf)
4255 cl_int * err = NULL)
4258 object_ = ::clCreateFromGLBuffer(
4264 detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
4280 explicit BufferGL(
const cl_mem& buffer,
bool retainObject =
false) :
4281 Buffer(buffer, retainObject) { }
4323 cl_gl_object_type *type,
4324 cl_GLuint * gl_object_name)
4326 return detail::errHandler(
4327 ::clGetGLObjectInfo(object_,type,gl_object_name),
4328 __GET_GL_OBJECT_INFO_ERR);
4352 cl_int * err = NULL)
4355 object_ = ::clCreateFromGLRenderbuffer(
4361 detail::errHandler(error, __CREATE_GL_RENDER_BUFFER_ERR);
4378 Buffer(buffer, retainObject) { }
4420 cl_gl_object_type *type,
4421 cl_GLuint * gl_object_name)
4423 return detail::errHandler(
4424 ::clGetGLObjectInfo(object_,type,gl_object_name),
4425 __GET_GL_OBJECT_INFO_ERR);
4448 explicit Image(
const cl_mem& image,
bool retainObject =
false) :
4449 Memory(image, retainObject) { }
4492 template <
typename T>
4495 return detail::errHandler(
4496 detail::getInfo(&::clGetImageInfo, object_, name, param),
4497 __GET_IMAGE_INFO_ERR);
4501 template <cl_image_info name>
typename
4506 detail::cl_image_info, name>::param_type param;
4515#if CL_HPP_TARGET_OPENCL_VERSION >= 120
4534 void* host_ptr = NULL,
4539 cl_image_desc desc = {0};
4540 desc.image_type = CL_MEM_OBJECT_IMAGE1D;
4541 desc.image_width = width;
4543 object_ = ::clCreateImage(
4551 detail::errHandler(error, __CREATE_IMAGE_ERR);
4567 explicit Image1D(
const cl_mem& image1D,
bool retainObject =
false) :
4568 Image(image1D, retainObject) { }
4626 cl_image_desc desc = {0};
4627 desc.image_type = CL_MEM_OBJECT_IMAGE1D_BUFFER;
4628 desc.image_width = width;
4629 desc.buffer = buffer();
4631 object_ = ::clCreateImage(
4639 detail::errHandler(error, __CREATE_IMAGE_ERR);
4655 Image(image1D, retainObject) { }
4703 size_type arraySize,
4706 void* host_ptr = NULL,
4711 cl_image_desc desc = {0};
4712 desc.image_type = CL_MEM_OBJECT_IMAGE1D_ARRAY;
4713 desc.image_width = width;
4714 desc.image_array_size = arraySize;
4715 desc.image_row_pitch = rowPitch;
4717 object_ = ::clCreateImage(
4725 detail::errHandler(error, __CREATE_IMAGE_ERR);
4740 explicit Image1DArray(
const cl_mem& imageArray,
bool retainObject =
false) :
4741 Image(imageArray, retainObject) { }
4801 size_type row_pitch = 0,
4802 void* host_ptr = NULL,
4806 bool useCreateImage;
4808#if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
4811 cl_uint version = detail::getContextPlatformVersion(context());
4812 useCreateImage = (version >= 0x10002);
4814#elif CL_HPP_TARGET_OPENCL_VERSION >= 120
4815 useCreateImage =
true;
4817 useCreateImage =
false;
4820#if CL_HPP_TARGET_OPENCL_VERSION >= 120
4823 cl_image_desc desc = {0};
4824 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
4825 desc.image_width = width;
4826 desc.image_height = height;
4827 desc.image_row_pitch = row_pitch;
4829 object_ = ::clCreateImage(
4837 detail::errHandler(error, __CREATE_IMAGE_ERR);
4843#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
4844 if (!useCreateImage)
4846 object_ = ::clCreateImage2D(
4847 context(), flags,&format, width, height, row_pitch, host_ptr, &error);
4849 detail::errHandler(error, __CREATE_IMAGE2D_ERR);
4857#if CL_HPP_TARGET_OPENCL_VERSION >= 200 || defined(CL_HPP_USE_CL_IMAGE2D_FROM_BUFFER_KHR)
4866 const Buffer &sourceBuffer,
4869 size_type row_pitch = 0,
4870 cl_int* err =
nullptr)
4874 cl_image_desc desc = {0};
4875 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
4876 desc.image_width = width;
4877 desc.image_height = height;
4878 desc.image_row_pitch = row_pitch;
4879 desc.buffer = sourceBuffer();
4881 object_ = ::clCreateImage(
4889 detail::errHandler(error, __CREATE_IMAGE_ERR);
4890 if (err !=
nullptr) {
4896#if CL_HPP_TARGET_OPENCL_VERSION >= 200
4911 cl_channel_order order,
4912 const Image &sourceImage,
4913 cl_int* err =
nullptr)
4918 size_type sourceWidth =
4920 size_type sourceHeight =
4922 size_type sourceRowPitch =
4924 cl_uint sourceNumMIPLevels =
4926 cl_uint sourceNumSamples =
4928 cl_image_format sourceFormat =
4933 sourceFormat.image_channel_order = order;
4935 cl_image_desc desc = {0};
4936 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
4937 desc.image_width = sourceWidth;
4938 desc.image_height = sourceHeight;
4939 desc.image_row_pitch = sourceRowPitch;
4940 desc.num_mip_levels = sourceNumMIPLevels;
4941 desc.num_samples = sourceNumSamples;
4942 desc.buffer = sourceImage();
4944 object_ = ::clCreateImage(
4952 detail::errHandler(error, __CREATE_IMAGE_ERR);
4953 if (err !=
nullptr) {
4969 explicit Image2D(
const cl_mem& image2D,
bool retainObject =
false) :
4970 Image(image2D, retainObject) { }
5013#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
5037 cl_int * err = NULL)
5040 object_ = ::clCreateFromGLTexture2D(
5048 detail::errHandler(error, __CREATE_GL_TEXTURE_2D_ERR);
5065 explicit Image2DGL(
const cl_mem& image,
bool retainObject =
false) :
5066 Image2D(image, retainObject) { }
5106} CL_API_SUFFIX__VERSION_1_1_DEPRECATED;
5109#if CL_HPP_TARGET_OPENCL_VERSION >= 120
5120 size_type arraySize,
5124 size_type slicePitch,
5125 void* host_ptr = NULL,
5130 cl_image_desc desc = {0};
5131 desc.image_type = CL_MEM_OBJECT_IMAGE2D_ARRAY;
5132 desc.image_width = width;
5133 desc.image_height = height;
5134 desc.image_array_size = arraySize;
5135 desc.image_row_pitch = rowPitch;
5136 desc.image_slice_pitch = slicePitch;
5138 object_ = ::clCreateImage(
5146 detail::errHandler(error, __CREATE_IMAGE_ERR);
5161 explicit Image2DArray(
const cl_mem& imageArray,
bool retainObject =
false) :
Image(imageArray, retainObject) { }
5219 size_type row_pitch = 0,
5220 size_type slice_pitch = 0,
5221 void* host_ptr = NULL,
5225 bool useCreateImage;
5227#if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
5230 cl_uint version = detail::getContextPlatformVersion(context());
5231 useCreateImage = (version >= 0x10002);
5233#elif CL_HPP_TARGET_OPENCL_VERSION >= 120
5234 useCreateImage =
true;
5236 useCreateImage =
false;
5239#if CL_HPP_TARGET_OPENCL_VERSION >= 120
5242 cl_image_desc desc = {0};
5243 desc.image_type = CL_MEM_OBJECT_IMAGE3D;
5244 desc.image_width = width;
5245 desc.image_height = height;
5246 desc.image_depth = depth;
5247 desc.image_row_pitch = row_pitch;
5248 desc.image_slice_pitch = slice_pitch;
5250 object_ = ::clCreateImage(
5258 detail::errHandler(error, __CREATE_IMAGE_ERR);
5264#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
5265 if (!useCreateImage)
5267 object_ = ::clCreateImage3D(
5268 context(), flags, &format, width, height, depth, row_pitch,
5269 slice_pitch, host_ptr, &error);
5271 detail::errHandler(error, __CREATE_IMAGE3D_ERR);
5289 explicit Image3D(
const cl_mem& image3D,
bool retainObject =
false) :
5290 Image(image3D, retainObject) { }
5331#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
5354 cl_int * err = NULL)
5357 object_ = ::clCreateFromGLTexture3D(
5365 detail::errHandler(error, __CREATE_GL_TEXTURE_3D_ERR);
5381 explicit Image3DGL(
const cl_mem& image,
bool retainObject =
false) :
5382 Image3D(image, retainObject) { }
5424#if CL_HPP_TARGET_OPENCL_VERSION >= 120
5440 cl_int * err = NULL)
5443 object_ = ::clCreateFromGLTexture(
5451 detail::errHandler(error, __CREATE_GL_TEXTURE_ERR);
5466 explicit ImageGL(
const cl_mem& image,
bool retainObject =
false) :
5467 Image(image, retainObject) { }
5469 ImageGL& operator = (
const cl_mem& rhs)
5507#if CL_HPP_TARGET_OPENCL_VERSION >= 200
5529 cl_uint packet_size,
5530 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);
5553 cl_uint packet_size,
5554 cl_uint max_packets,
5561 cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS;
5562 object_ = ::clCreatePipe(context(), flags, packet_size, max_packets,
nullptr, &error);
5564 detail::errHandler(error, __CREATE_PIPE_ERR);
5580 explicit Pipe(
const cl_mem& pipe,
bool retainObject =
false) :
5581 Memory(pipe, retainObject) { }
5622 template <
typename T>
5625 return detail::errHandler(
5626 detail::getInfo(&::clGetPipeInfo, object_, name, param),
5627 __GET_PIPE_INFO_ERR);
5631 template <cl_pipe_info name>
typename
5636 detail::cl_pipe_info, name>::param_type param;
5637 cl_int result =
getInfo(name, ¶m);
5667 cl_bool normalized_coords,
5668 cl_addressing_mode addressing_mode,
5669 cl_filter_mode filter_mode,
5674#if CL_HPP_TARGET_OPENCL_VERSION >= 200
5675 cl_sampler_properties sampler_properties[] = {
5676 CL_SAMPLER_NORMALIZED_COORDS, normalized_coords,
5677 CL_SAMPLER_ADDRESSING_MODE, addressing_mode,
5678 CL_SAMPLER_FILTER_MODE, filter_mode,
5680 object_ = ::clCreateSamplerWithProperties(
5685 detail::errHandler(error, __CREATE_SAMPLER_WITH_PROPERTIES_ERR);
5690 object_ = ::clCreateSampler(
5697 detail::errHandler(error, __CREATE_SAMPLER_ERR);
5712 explicit Sampler(
const cl_sampler& sampler,
bool retainObject =
false) :
5713 detail::Wrapper<cl_type>(sampler, retainObject) { }
5755 template <
typename T>
5756 cl_int
getInfo(cl_sampler_info name, T* param)
const
5758 return detail::errHandler(
5759 detail::getInfo(&::clGetSamplerInfo, object_, name, param),
5760 __GET_SAMPLER_INFO_ERR);
5764 template <cl_sampler_info name>
typename
5769 detail::cl_sampler_info, name>::param_type param;
5770 cl_int result =
getInfo(name, ¶m);
5780class DeviceCommandQueue;
5787 size_type sizes_[3];
5788 cl_uint dimensions_;
5819 NDRange(size_type size0, size_type size1, size_type size2)
5831 operator const size_type*()
const {
5845 return dimensions_*
sizeof(size_type);
5853 const size_type* get()
const
5860static const NDRange NullRange;
5870template <
typename T,
class Enable =
void>
5875template <
typename T>
5878 static size_type size(
const T&) {
return sizeof(T); }
5879 static const T* ptr(
const T& value) {
return &value; }
5884template <
typename T>
5887 static size_type size(
const T&) {
return sizeof(cl_mem); }
5888 static const cl_mem* ptr(
const T& value) {
return &(value()); }
5896 static size_type size(
const LocalSpaceArg& value) {
return value.size_; }
5897 static const void* ptr(
const LocalSpaceArg&) {
return NULL; }
5924 inline Kernel(
const Program& program,
const char* name, cl_int* err = NULL);
5937 explicit Kernel(
const cl_kernel& kernel,
bool retainObject =
false) :
5938 detail::Wrapper<cl_type>(kernel, retainObject) { }
5979 template <
typename T>
5980 cl_int getInfo(cl_kernel_info name, T* param)
const
5982 return detail::errHandler(
5983 detail::getInfo(&::clGetKernelInfo, object_, name, param),
5984 __GET_KERNEL_INFO_ERR);
5987 template <cl_kernel_info name>
typename
5988 detail::param_traits<detail::cl_kernel_info, name>::param_type
5989 getInfo(cl_int* err = NULL)
const
5991 typename detail::param_traits<
5992 detail::cl_kernel_info, name>::param_type param;
5993 cl_int result = getInfo(name, ¶m);
6000#if CL_HPP_TARGET_OPENCL_VERSION >= 120
6001 template <
typename T>
6002 cl_int getArgInfo(cl_uint argIndex, cl_kernel_arg_info name, T* param)
const
6004 return detail::errHandler(
6005 detail::getInfo(&::clGetKernelArgInfo, object_, argIndex, name, param),
6006 __GET_KERNEL_ARG_INFO_ERR);
6009 template <cl_kernel_arg_info name>
typename
6010 detail::param_traits<detail::cl_kernel_arg_info, name>::param_type
6011 getArgInfo(cl_uint argIndex, cl_int* err = NULL)
const
6013 typename detail::param_traits<
6014 detail::cl_kernel_arg_info, name>::param_type param;
6015 cl_int result = getArgInfo(argIndex, name, ¶m);
6023 template <
typename T>
6024 cl_int getWorkGroupInfo(
6025 const Device& device, cl_kernel_work_group_info name, T* param)
const
6027 return detail::errHandler(
6029 &::clGetKernelWorkGroupInfo, object_, device(), name, param),
6030 __GET_KERNEL_WORK_GROUP_INFO_ERR);
6033 template <cl_kernel_work_group_info name>
typename
6034 detail::param_traits<detail::cl_kernel_work_group_info, name>::param_type
6035 getWorkGroupInfo(
const Device& device, cl_int* err = NULL)
const
6037 typename detail::param_traits<
6038 detail::cl_kernel_work_group_info, name>::param_type param;
6039 cl_int result = getWorkGroupInfo(device, name, ¶m);
6046#if (CL_HPP_TARGET_OPENCL_VERSION >= 200 && defined(CL_HPP_USE_CL_SUB_GROUPS_KHR)) || CL_HPP_TARGET_OPENCL_VERSION >= 210
6047 cl_int getSubGroupInfo(
const cl::Device &dev, cl_kernel_sub_group_info name,
const cl::NDRange &range, size_type* param)
const
6049#if CL_HPP_TARGET_OPENCL_VERSION >= 210
6051 return detail::errHandler(
6052 clGetKernelSubGroupInfo(object_, dev(), name, range.
size(), range.get(),
sizeof(size_type), param,
nullptr),
6053 __GET_KERNEL_SUB_GROUP_INFO_ERR);
6057 typedef clGetKernelSubGroupInfoKHR_fn PFN_clGetKernelSubGroupInfoKHR;
6058 static PFN_clGetKernelSubGroupInfoKHR pfn_clGetKernelSubGroupInfoKHR = NULL;
6059 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetKernelSubGroupInfoKHR);
6061 return detail::errHandler(
6062 pfn_clGetKernelSubGroupInfoKHR(object_, dev(), name, range.
size(), range.get(),
sizeof(size_type), param,
nullptr),
6063 __GET_KERNEL_SUB_GROUP_INFO_ERR);
6068 template <cl_kernel_sub_group_info name>
6069 size_type getSubGroupInfo(
const cl::Device &dev,
const cl::NDRange &range, cl_int* err = NULL)
const
6072 cl_int result = getSubGroupInfo(dev, name, range, ¶m);
6080#if CL_HPP_TARGET_OPENCL_VERSION >= 200
6083 template<
typename T,
class D>
6084 cl_int
setArg(cl_uint index,
const cl::pointer<T, D> &argPtr)
6086 return detail::errHandler(
6087 ::clSetKernelArgSVMPointer(object_, index, argPtr.get()),
6088 __SET_KERNEL_ARGS_ERR);
6093 template<
typename T,
class Alloc>
6094 cl_int
setArg(cl_uint index,
const cl::vector<T, Alloc> &argPtr)
6096 return detail::errHandler(
6097 ::clSetKernelArgSVMPointer(object_, index, argPtr.data()),
6098 __SET_KERNEL_ARGS_ERR);
6103 template<
typename T>
6104 typename std::enable_if<std::is_pointer<T>::value, cl_int>::type
6107 return detail::errHandler(
6108 ::clSetKernelArgSVMPointer(object_, index, argPtr),
6109 __SET_KERNEL_ARGS_ERR);
6115 template <
typename T>
6116 typename std::enable_if<!std::is_pointer<T>::value, cl_int>::type
6119 return detail::errHandler(
6125 __SET_KERNEL_ARGS_ERR);
6128 cl_int
setArg(cl_uint index, size_type size,
const void* argPtr)
6130 return detail::errHandler(
6131 ::clSetKernelArg(object_, index, size, argPtr),
6132 __SET_KERNEL_ARGS_ERR);
6135#if CL_HPP_TARGET_OPENCL_VERSION >= 200
6142 return detail::errHandler(
6143 ::clSetKernelExecInfo(
6145 CL_KERNEL_EXEC_INFO_SVM_PTRS,
6146 sizeof(
void*)*pointerList.size(),
6147 pointerList.data()));
6154 template<
int ArrayLength>
6157 return detail::errHandler(
6158 ::clSetKernelExecInfo(
6160 CL_KERNEL_EXEC_INFO_SVM_PTRS,
6161 sizeof(
void*)*pointerList.size(),
6162 pointerList.data()));
6178 cl_bool svmEnabled_ = svmEnabled ? CL_TRUE : CL_FALSE;
6179 return detail::errHandler(
6180 ::clSetKernelExecInfo(
6182 CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM,
6189 template<
int index,
int ArrayLength,
class D,
typename T0,
typename T1,
typename... Ts>
6190 void setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList,
const pointer<T0, D> &t0,
const pointer<T1, D> &t1, Ts & ... ts)
6192 pointerList[index] =
static_cast<void*
>(t0.get());
6193 setSVMPointersHelper<index + 1, ArrayLength>(pointerList, t1, ts...);
6196 template<
int index,
int ArrayLength,
typename T0,
typename T1,
typename... Ts>
6197 typename std::enable_if<std::is_pointer<T0>::value,
void>::type
6198 setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList, T0 t0, T1 t1, Ts... ts)
6200 pointerList[index] =
static_cast<void*
>(t0);
6201 setSVMPointersHelper<index + 1, ArrayLength>(pointerList, t1, ts...);
6204 template<
int index,
int ArrayLength,
typename T0,
class D>
6205 void setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList,
const pointer<T0, D> &t0)
6207 pointerList[index] =
static_cast<void*
>(t0.get());
6211 template<
int index,
int ArrayLength,
typename T0>
6212 typename std::enable_if<std::is_pointer<T0>::value,
void>::type
6213 setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList, T0 t0)
6215 pointerList[index] =
static_cast<void*
>(t0);
6218 template<
typename T0,
typename... Ts>
6221 std::array<
void*, 1 +
sizeof...(Ts)> pointerList;
6223 setSVMPointersHelper<0, 1 +
sizeof...(Ts)>(pointerList, t0, ts...);
6224 return detail::errHandler(
6225 ::clSetKernelExecInfo(
6227 CL_KERNEL_EXEC_INFO_SVM_PTRS,
6228 sizeof(
void*)*(1 +
sizeof...(Ts)),
6229 pointerList.data()));
6232 template<
typename T>
6233 cl_int setExecInfo(cl_kernel_exec_info param_name,
const T& val)
6235 return detail::errHandler(
6236 ::clSetKernelExecInfo(
6243 template<cl_kernel_exec_info name>
6244 cl_int setExecInfo(
typename detail::param_traits<detail::cl_kernel_exec_info, name>::param_type& val)
6246 return setExecInfo(name, val);
6250#if CL_HPP_TARGET_OPENCL_VERSION >= 210
6259 Kernel retValue(clCloneKernel(this->get(), &error));
6261 detail::errHandler(error, __CLONE_KERNEL_ERR);
6273#if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6274 typedef vector<vector<unsigned char>> Binaries;
6275 typedef vector<string> Sources;
6277 typedef vector<std::pair<const void*, size_type> > Binaries;
6278 typedef vector<std::pair<const char*, size_type> > Sources;
6282 const string& source,
6288 const char * strings = source.c_str();
6289 const size_type length = source.size();
6293 object_ = ::clCreateProgramWithSource(
6294 context(), (cl_uint)1, &strings, &length, &error);
6296 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6298 if (error == CL_SUCCESS && build) {
6300 error = ::clBuildProgram(
6304#
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6312 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6322 const string& source,
6328 const char * strings = source.c_str();
6329 const size_type length = source.size();
6331 object_ = ::clCreateProgramWithSource(
6332 context(), (cl_uint)1, &strings, &length, &error);
6334 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6336 if (error == CL_SUCCESS && build) {
6337 error = ::clBuildProgram(
6341#
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6349 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6362 const Sources& sources,
6368 const size_type n = (size_type)sources.size();
6370 vector<size_type> lengths(n);
6371 vector<const char*> strings(n);
6373 for (size_type i = 0; i < n; ++i) {
6374#if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6375 strings[i] = sources[(int)i].data();
6376 lengths[i] = sources[(int)i].length();
6378 strings[i] = sources[(int)i].first;
6379 lengths[i] = sources[(int)i].second;
6383 object_ = ::clCreateProgramWithSource(
6384 context(), (cl_uint)n, strings.data(), lengths.data(), &error);
6386 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6398 const Sources& sources,
6403 const size_type n = (size_type)sources.size();
6405 vector<size_type> lengths(n);
6406 vector<const char*> strings(n);
6408 for (size_type i = 0; i < n; ++i) {
6409#if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6410 strings[i] = sources[(int)i].data();
6411 lengths[i] = sources[(int)i].length();
6413 strings[i] = sources[(int)i].first;
6414 lengths[i] = sources[(int)i].second;
6418 object_ = ::clCreateProgramWithSource(
6419 context(), (cl_uint)n, strings.data(), lengths.data(), &error);
6421 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6428#if CL_HPP_TARGET_OPENCL_VERSION >= 210 || (CL_HPP_TARGET_OPENCL_VERSION==200 && defined(CL_HPP_USE_IL_KHR))
6434 const vector<char>& IL,
6442#if CL_HPP_TARGET_OPENCL_VERSION >= 210
6444 object_ = ::clCreateProgramWithIL(
6445 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6449 typedef clCreateProgramWithILKHR_fn PFN_clCreateProgramWithILKHR;
6450 static PFN_clCreateProgramWithILKHR pfn_clCreateProgramWithILKHR = NULL;
6451 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateProgramWithILKHR);
6453 object_ = pfn_clCreateProgramWithILKHR(
6454 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6458 detail::errHandler(error, __CREATE_PROGRAM_WITH_IL_ERR);
6460 if (error == CL_SUCCESS && build) {
6462 error = ::clBuildProgram(
6466#
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6474 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6489 const vector<char>& IL,
6495#if CL_HPP_TARGET_OPENCL_VERSION >= 210
6497 object_ = ::clCreateProgramWithIL(
6498 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6502 typedef clCreateProgramWithILKHR_fn PFN_clCreateProgramWithILKHR;
6503 static PFN_clCreateProgramWithILKHR pfn_clCreateProgramWithILKHR = NULL;
6504 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateProgramWithILKHR);
6506 object_ = pfn_clCreateProgramWithILKHR(
6507 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6511 detail::errHandler(error, __CREATE_PROGRAM_WITH_IL_ERR);
6513 if (error == CL_SUCCESS && build) {
6514 error = ::clBuildProgram(
6518#
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6526 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6556 const vector<Device>& devices,
6557 const Binaries& binaries,
6558 vector<cl_int>* binaryStatus = NULL,
6563 const size_type numDevices = devices.size();
6566 if(binaries.size() != numDevices) {
6567 error = CL_INVALID_VALUE;
6568 detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
6576 vector<size_type> lengths(numDevices);
6577 vector<const unsigned char*> images(numDevices);
6578#if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6579 for (size_type i = 0; i < numDevices; ++i) {
6580 images[i] = binaries[i].data();
6581 lengths[i] = binaries[(int)i].size();
6584 for (size_type i = 0; i < numDevices; ++i) {
6585 images[i] = (
const unsigned char*)binaries[i].first;
6586 lengths[i] = binaries[(int)i].second;
6590 vector<cl_device_id> deviceIDs(numDevices);
6591 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6592 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6596 binaryStatus->resize(numDevices);
6599 object_ = ::clCreateProgramWithBinary(
6600 context(), (cl_uint) devices.size(),
6602 lengths.data(), images.data(), (binaryStatus != NULL && numDevices > 0)
6603 ? &binaryStatus->front()
6606 detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
6613#if CL_HPP_TARGET_OPENCL_VERSION >= 120
6620 const vector<Device>& devices,
6621 const string& kernelNames,
6627 size_type numDevices = devices.size();
6628 vector<cl_device_id> deviceIDs(numDevices);
6629 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6630 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6633 object_ = ::clCreateProgramWithBuiltInKernels(
6635 (cl_uint) devices.size(),
6637 kernelNames.c_str(),
6640 detail::errHandler(error, __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR);
6656 explicit Program(
const cl_program& program,
bool retainObject =
false) :
6657 detail::Wrapper<cl_type>(program, retainObject) { }
6659 Program& operator = (
const cl_program& rhs)
6694 const vector<Device>& devices,
6695 const char* options = NULL,
6696 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6697 void* data = NULL)
const
6699 size_type numDevices = devices.size();
6700 vector<cl_device_id> deviceIDs(numDevices);
6702 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6703 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6706 cl_int buildError = ::clBuildProgram(
6715 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6719 const Device& device,
6720 const char* options = NULL,
6721 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6722 void* data = NULL)
const
6724 cl_device_id deviceID = device();
6726 cl_int buildError = ::clBuildProgram(
6734 BuildLogType buildLog(0);
6735 buildLog.push_back(std::make_pair(device, getBuildInfo<CL_PROGRAM_BUILD_LOG>(device)));
6736 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, buildLog);
6740 const char* options = NULL,
6741 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6742 void* data = NULL)
const
6744 cl_int buildError = ::clBuildProgram(
6752 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6755#if CL_HPP_TARGET_OPENCL_VERSION >= 120
6757 const char* options = NULL,
6758 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6759 void* data = NULL)
const
6761 cl_int error = ::clCompileProgram(
6771 return detail::buildErrHandler(error, __COMPILE_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6775 template <
typename T>
6776 cl_int getInfo(cl_program_info name, T* param)
const
6778 return detail::errHandler(
6779 detail::getInfo(&::clGetProgramInfo, object_, name, param),
6780 __GET_PROGRAM_INFO_ERR);
6783 template <cl_program_info name>
typename
6784 detail::param_traits<detail::cl_program_info, name>::param_type
6785 getInfo(cl_int* err = NULL)
const
6787 typename detail::param_traits<
6788 detail::cl_program_info, name>::param_type param;
6789 cl_int result = getInfo(name, ¶m);
6796 template <
typename T>
6797 cl_int getBuildInfo(
6798 const Device& device, cl_program_build_info name, T* param)
const
6800 return detail::errHandler(
6802 &::clGetProgramBuildInfo, object_, device(), name, param),
6803 __GET_PROGRAM_BUILD_INFO_ERR);
6806 template <cl_program_build_info name>
typename
6807 detail::param_traits<detail::cl_program_build_info, name>::param_type
6808 getBuildInfo(
const Device& device, cl_int* err = NULL)
const
6810 typename detail::param_traits<
6811 detail::cl_program_build_info, name>::param_type param;
6812 cl_int result = getBuildInfo(device, name, ¶m);
6824 template <cl_program_build_info name>
6825 vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, name>::param_type>>
6828 cl_int result = CL_SUCCESS;
6830 auto devs = getInfo<CL_PROGRAM_DEVICES>(&result);
6831 vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, name>::param_type>>
6835 if (result != CL_SUCCESS) {
6844 detail::cl_program_build_info, name>::param_type param;
6845 result = getBuildInfo(d, name, ¶m);
6849 if (result != CL_SUCCESS) {
6857 if (result != CL_SUCCESS) {
6863 cl_int createKernels(vector<Kernel>* kernels)
6866 cl_int err = ::clCreateKernelsInProgram(object_, 0, NULL, &numKernels);
6867 if (err != CL_SUCCESS) {
6868 return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
6871 vector<cl_kernel> value(numKernels);
6873 err = ::clCreateKernelsInProgram(
6874 object_, numKernels, value.data(), NULL);
6875 if (err != CL_SUCCESS) {
6876 return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
6880 kernels->resize(value.size());
6884 for (size_type i = 0; i < value.size(); i++) {
6887 (*kernels)[i] = Kernel(value[i],
false);
6893#if CL_HPP_TARGET_OPENCL_VERSION >= 220
6894#if defined(CL_USE_DEPRECATED_OPENCL_2_2_APIS)
6906 void (CL_CALLBACK * pfn_notify)(cl_program program,
void * user_data),
6907 void * user_data = NULL) CL_API_SUFFIX__VERSION_2_2_DEPRECATED
6909 return detail::errHandler(
6910 ::clSetProgramReleaseCallback(
6914 __SET_PROGRAM_RELEASE_CALLBACK_ERR);
6922 template <
typename T>
6923 typename std::enable_if<!std::is_pointer<T>::value, cl_int>::type
6926 return detail::errHandler(
6927 ::clSetProgramSpecializationConstant(
6932 __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR);
6941 return detail::errHandler(
6942 ::clSetProgramSpecializationConstant(
6947 __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR);
6952#if CL_HPP_TARGET_OPENCL_VERSION >= 120
6953inline Program linkProgram(
6956 const char* options = NULL,
6957 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6961 cl_int error_local = CL_SUCCESS;
6963 cl_program programs[2] = { input1(), input2() };
6965 Context ctx = input1.getInfo<CL_PROGRAM_CONTEXT>(&error_local);
6966 if(error_local!=CL_SUCCESS) {
6967 detail::errHandler(error_local, __LINK_PROGRAM_ERR);
6970 cl_program prog = ::clLinkProgram(
6981 detail::errHandler(error_local,__COMPILE_PROGRAM_ERR);
6986 return Program(prog);
6989inline Program linkProgram(
6990 vector<Program> inputPrograms,
6991 const char* options = NULL,
6992 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6996 cl_int error_local = CL_SUCCESS;
6998 vector<cl_program> programs(inputPrograms.size());
7000 for (
unsigned int i = 0; i < inputPrograms.size(); i++) {
7001 programs[i] = inputPrograms[i]();
7005 if(inputPrograms.size() > 0) {
7006 ctx = inputPrograms[0].getInfo<CL_PROGRAM_CONTEXT>(&error_local);
7007 if(error_local!=CL_SUCCESS) {
7008 detail::errHandler(error_local, __LINK_PROGRAM_ERR);
7011 cl_program prog = ::clLinkProgram(
7016 (cl_uint)inputPrograms.size(),
7022 detail::errHandler(error_local,__COMPILE_PROGRAM_ERR);
7027 return Program(prog,
false);
7033inline cl_int cl::Program::getInfo(cl_program_info name, vector<vector<unsigned char>>* param)
const
7035 if (name != CL_PROGRAM_BINARIES) {
7036 return CL_INVALID_VALUE;
7042 vector<size_type> sizes = getInfo<CL_PROGRAM_BINARY_SIZES>();
7043 size_type numBinaries = sizes.size();
7046 param->resize(numBinaries);
7047 for (size_type i = 0; i < numBinaries; ++i) {
7048 (*param)[i].resize(sizes[i]);
7051 return detail::errHandler(
7052 detail::getInfo(&::clGetProgramInfo, object_, name, param),
7053 __GET_PROGRAM_INFO_ERR);
7060inline vector<vector<unsigned char>> cl::Program::getInfo<CL_PROGRAM_BINARIES>(cl_int* err)
const
7062 vector<vector<unsigned char>> binariesVectors;
7064 cl_int result = getInfo(CL_PROGRAM_BINARIES, &binariesVectors);
7068 return binariesVectors;
7071#if CL_HPP_TARGET_OPENCL_VERSION >= 220
7076 cl_uchar ucValue = value ? CL_UCHAR_MAX : 0;
7077 return detail::errHandler(
7078 ::clSetProgramSpecializationConstant(
7083 __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR);
7087inline Kernel::Kernel(
const Program& program,
const char* name, cl_int* err)
7091 object_ = ::clCreateKernel(program(), name, &error);
7092 detail::errHandler(error, __CREATE_KERNEL_ERR);
7100enum class QueueProperties : cl_command_queue_properties
7103 Profiling = CL_QUEUE_PROFILING_ENABLE,
7104 OutOfOrder = CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE,
7107inline QueueProperties operator|(QueueProperties lhs, QueueProperties rhs)
7109 return static_cast<QueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) |
static_cast<cl_command_queue_properties
>(rhs));
7112inline QueueProperties operator&(QueueProperties lhs, QueueProperties rhs)
7114 return static_cast<QueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) &
static_cast<cl_command_queue_properties
>(rhs));
7123 static std::once_flag default_initialized_;
7125 static cl_int default_error_;
7132 static void makeDefault()
7137#if defined(CL_HPP_ENABLE_EXCEPTIONS)
7144 if (error != CL_SUCCESS) {
7145 default_error_ = error;
7149 default_ =
CommandQueue(context, device, 0, &default_error_);
7152#if defined(CL_HPP_ENABLE_EXCEPTIONS)
7153 catch (cl::Error &e) {
7154 default_error_ = e.err();
7164 static void makeDefaultProvided(
const CommandQueue &c) {
7169#ifdef CL_HPP_UNIT_TEST_ENABLE
7176 static void unitTestClearDefault() {
7187 cl_command_queue_properties properties,
7193 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7195 if (error != CL_SUCCESS) {
7202 bool useWithProperties;
7204#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7207 cl_uint version = detail::getContextPlatformVersion(context());
7208 useWithProperties = (version >= 0x20000);
7210#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7211 useWithProperties =
true;
7213 useWithProperties =
false;
7216#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7217 if (useWithProperties) {
7218 cl_queue_properties queue_properties[] = {
7219 CL_QUEUE_PROPERTIES, properties, 0 };
7220 if ((properties & CL_QUEUE_ON_DEVICE) == 0) {
7221 object_ = ::clCreateCommandQueueWithProperties(
7222 context(), device(), queue_properties, &error);
7225 error = CL_INVALID_QUEUE_PROPERTIES;
7228 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7234#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7235 if (!useWithProperties) {
7236 object_ = ::clCreateCommandQueue(
7237 context(), device(), properties, &error);
7239 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7253 QueueProperties properties,
7259 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7261 if (error != CL_SUCCESS) {
7268 bool useWithProperties;
7270#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7273 cl_uint version = detail::getContextPlatformVersion(context());
7274 useWithProperties = (version >= 0x20000);
7276#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7277 useWithProperties =
true;
7279 useWithProperties =
false;
7282#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7283 if (useWithProperties) {
7284 cl_queue_properties queue_properties[] = {
7285 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
7287 object_ = ::clCreateCommandQueueWithProperties(
7288 context(), device(), queue_properties, &error);
7290 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7296#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7297 if (!useWithProperties) {
7298 object_ = ::clCreateCommandQueue(
7299 context(), device(),
static_cast<cl_command_queue_properties
>(properties), &error);
7301 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7317 cl_command_queue_properties properties = 0,
7321 bool useWithProperties;
7322 vector<cl::Device> devices;
7323 error = context.
getInfo(CL_CONTEXT_DEVICES, &devices);
7325 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7327 if (error != CL_SUCCESS)
7335#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7338 cl_uint version = detail::getContextPlatformVersion(context());
7339 useWithProperties = (version >= 0x20000);
7341#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7342 useWithProperties =
true;
7344 useWithProperties =
false;
7347#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7348 if (useWithProperties) {
7349 cl_queue_properties queue_properties[] = {
7350 CL_QUEUE_PROPERTIES, properties, 0 };
7351 if ((properties & CL_QUEUE_ON_DEVICE) == 0) {
7352 object_ = ::clCreateCommandQueueWithProperties(
7353 context(), devices[0](), queue_properties, &error);
7356 error = CL_INVALID_QUEUE_PROPERTIES;
7359 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7365#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7366 if (!useWithProperties) {
7367 object_ = ::clCreateCommandQueue(
7368 context(), devices[0](), properties, &error);
7370 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7384 QueueProperties properties,
7388 bool useWithProperties;
7389 vector<cl::Device> devices;
7390 error = context.
getInfo(CL_CONTEXT_DEVICES, &devices);
7392 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7394 if (error != CL_SUCCESS)
7402#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7405 cl_uint version = detail::getContextPlatformVersion(context());
7406 useWithProperties = (version >= 0x20000);
7408#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7409 useWithProperties =
true;
7411 useWithProperties =
false;
7414#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7415 if (useWithProperties) {
7416 cl_queue_properties queue_properties[] = {
7417 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
7418 object_ = ::clCreateCommandQueueWithProperties(
7419 context(), devices[0](), queue_properties, &error);
7421 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7427#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7428 if (!useWithProperties) {
7429 object_ = ::clCreateCommandQueue(
7430 context(), devices[0](),
static_cast<cl_command_queue_properties
>(properties), &error);
7432 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7447 cl_command_queue_properties properties = 0,
7451 bool useWithProperties;
7453#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7456 cl_uint version = detail::getContextPlatformVersion(context());
7457 useWithProperties = (version >= 0x20000);
7459#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7460 useWithProperties =
true;
7462 useWithProperties =
false;
7465#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7466 if (useWithProperties) {
7467 cl_queue_properties queue_properties[] = {
7468 CL_QUEUE_PROPERTIES, properties, 0 };
7469 object_ = ::clCreateCommandQueueWithProperties(
7470 context(), device(), queue_properties, &error);
7472 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7478#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7479 if (!useWithProperties) {
7480 object_ = ::clCreateCommandQueue(
7481 context(), device(), properties, &error);
7483 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7498 QueueProperties properties,
7502 bool useWithProperties;
7504#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7507 cl_uint version = detail::getContextPlatformVersion(context());
7508 useWithProperties = (version >= 0x20000);
7510#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7511 useWithProperties =
true;
7513 useWithProperties =
false;
7516#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7517 if (useWithProperties) {
7518 cl_queue_properties queue_properties[] = {
7519 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
7520 object_ = ::clCreateCommandQueueWithProperties(
7521 context(), device(), queue_properties, &error);
7523 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7529#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7530 if (!useWithProperties) {
7531 object_ = ::clCreateCommandQueue(
7532 context(), device(),
static_cast<cl_command_queue_properties
>(properties), &error);
7534 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7544 std::call_once(default_initialized_, makeDefault);
7545#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7546 detail::errHandler(default_error_, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7548 detail::errHandler(default_error_, __CREATE_COMMAND_QUEUE_ERR);
7551 *err = default_error_;
7565 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_queue));
7566 detail::errHandler(default_error_);
7579 explicit CommandQueue(
const cl_command_queue& commandQueue,
bool retainObject =
false) :
7580 detail::Wrapper<cl_type>(commandQueue, retainObject) { }
7616 template <
typename T>
7617 cl_int getInfo(cl_command_queue_info name, T* param)
const
7619 return detail::errHandler(
7621 &::clGetCommandQueueInfo, object_, name, param),
7622 __GET_COMMAND_QUEUE_INFO_ERR);
7625 template <cl_command_queue_info name>
typename
7626 detail::param_traits<detail::cl_command_queue_info, name>::param_type
7627 getInfo(cl_int* err = NULL)
const
7629 typename detail::param_traits<
7630 detail::cl_command_queue_info, name>::param_type param;
7631 cl_int result = getInfo(name, ¶m);
7638 cl_int enqueueReadBuffer(
7639 const Buffer& buffer,
7644 const vector<Event>* events = NULL,
7645 Event* event = NULL)
const
7648 cl_int err = detail::errHandler(
7649 ::clEnqueueReadBuffer(
7650 object_, buffer(), blocking, offset, size,
7652 (events != NULL) ? (cl_uint) events->size() : 0,
7653 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7654 (event != NULL) ? &tmp : NULL),
7655 __ENQUEUE_READ_BUFFER_ERR);
7657 if (event != NULL && err == CL_SUCCESS)
7663 cl_int enqueueWriteBuffer(
7664 const Buffer& buffer,
7669 const vector<Event>* events = NULL,
7670 Event* event = NULL)
const
7673 cl_int err = detail::errHandler(
7674 ::clEnqueueWriteBuffer(
7675 object_, buffer(), blocking, offset, size,
7677 (events != NULL) ? (cl_uint) events->size() : 0,
7678 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7679 (event != NULL) ? &tmp : NULL),
7680 __ENQUEUE_WRITE_BUFFER_ERR);
7682 if (event != NULL && err == CL_SUCCESS)
7688 cl_int enqueueCopyBuffer(
7691 size_type src_offset,
7692 size_type dst_offset,
7694 const vector<Event>* events = NULL,
7695 Event* event = NULL)
const
7698 cl_int err = detail::errHandler(
7699 ::clEnqueueCopyBuffer(
7700 object_, src(), dst(), src_offset, dst_offset, size,
7701 (events != NULL) ? (cl_uint) events->size() : 0,
7702 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7703 (event != NULL) ? &tmp : NULL),
7704 __ENQEUE_COPY_BUFFER_ERR);
7706 if (event != NULL && err == CL_SUCCESS)
7711#if CL_HPP_TARGET_OPENCL_VERSION >= 110
7712 cl_int enqueueReadBufferRect(
7713 const Buffer& buffer,
7715 const array<size_type, 3>& buffer_offset,
7716 const array<size_type, 3>& host_offset,
7717 const array<size_type, 3>& region,
7718 size_type buffer_row_pitch,
7719 size_type buffer_slice_pitch,
7720 size_type host_row_pitch,
7721 size_type host_slice_pitch,
7723 const vector<Event>* events = NULL,
7724 Event* event = NULL)
const
7727 cl_int err = detail::errHandler(
7728 ::clEnqueueReadBufferRect(
7732 buffer_offset.data(),
7740 (events != NULL) ? (cl_uint) events->size() : 0,
7741 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7742 (event != NULL) ? &tmp : NULL),
7743 __ENQUEUE_READ_BUFFER_RECT_ERR);
7745 if (event != NULL && err == CL_SUCCESS)
7751 cl_int enqueueWriteBufferRect(
7752 const Buffer& buffer,
7754 const array<size_type, 3>& buffer_offset,
7755 const array<size_type, 3>& host_offset,
7756 const array<size_type, 3>& region,
7757 size_type buffer_row_pitch,
7758 size_type buffer_slice_pitch,
7759 size_type host_row_pitch,
7760 size_type host_slice_pitch,
7762 const vector<Event>* events = NULL,
7763 Event* event = NULL)
const
7766 cl_int err = detail::errHandler(
7767 ::clEnqueueWriteBufferRect(
7771 buffer_offset.data(),
7779 (events != NULL) ? (cl_uint) events->size() : 0,
7780 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7781 (event != NULL) ? &tmp : NULL),
7782 __ENQUEUE_WRITE_BUFFER_RECT_ERR);
7784 if (event != NULL && err == CL_SUCCESS)
7790 cl_int enqueueCopyBufferRect(
7793 const array<size_type, 3>& src_origin,
7794 const array<size_type, 3>& dst_origin,
7795 const array<size_type, 3>& region,
7796 size_type src_row_pitch,
7797 size_type src_slice_pitch,
7798 size_type dst_row_pitch,
7799 size_type dst_slice_pitch,
7800 const vector<Event>* events = NULL,
7801 Event* event = NULL)
const
7804 cl_int err = detail::errHandler(
7805 ::clEnqueueCopyBufferRect(
7816 (events != NULL) ? (cl_uint) events->size() : 0,
7817 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7818 (event != NULL) ? &tmp : NULL),
7819 __ENQEUE_COPY_BUFFER_RECT_ERR);
7821 if (event != NULL && err == CL_SUCCESS)
7827#if CL_HPP_TARGET_OPENCL_VERSION >= 120
7839 template<
typename PatternType>
7842 PatternType pattern,
7845 const vector<Event>* events = NULL,
7846 Event* event = NULL)
const
7849 cl_int err = detail::errHandler(
7850 ::clEnqueueFillBuffer(
7853 static_cast<void*
>(&pattern),
7854 sizeof(PatternType),
7857 (events != NULL) ? (cl_uint) events->size() : 0,
7858 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7859 (event != NULL) ? &tmp : NULL),
7860 __ENQUEUE_FILL_BUFFER_ERR);
7862 if (event != NULL && err == CL_SUCCESS)
7869 cl_int enqueueReadImage(
7872 const array<size_type, 3>& origin,
7873 const array<size_type, 3>& region,
7874 size_type row_pitch,
7875 size_type slice_pitch,
7877 const vector<Event>* events = NULL,
7878 Event* event = NULL)
const
7881 cl_int err = detail::errHandler(
7882 ::clEnqueueReadImage(
7891 (events != NULL) ? (cl_uint) events->size() : 0,
7892 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7893 (event != NULL) ? &tmp : NULL),
7894 __ENQUEUE_READ_IMAGE_ERR);
7896 if (event != NULL && err == CL_SUCCESS)
7902 cl_int enqueueWriteImage(
7905 const array<size_type, 3>& origin,
7906 const array<size_type, 3>& region,
7907 size_type row_pitch,
7908 size_type slice_pitch,
7910 const vector<Event>* events = NULL,
7911 Event* event = NULL)
const
7914 cl_int err = detail::errHandler(
7915 ::clEnqueueWriteImage(
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_WRITE_IMAGE_ERR);
7929 if (event != NULL && err == CL_SUCCESS)
7935 cl_int enqueueCopyImage(
7938 const array<size_type, 3>& src_origin,
7939 const array<size_type, 3>& dst_origin,
7940 const array<size_type, 3>& region,
7941 const vector<Event>* events = NULL,
7942 Event* event = NULL)
const
7945 cl_int err = detail::errHandler(
7946 ::clEnqueueCopyImage(
7953 (events != NULL) ? (cl_uint) events->size() : 0,
7954 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7955 (event != NULL) ? &tmp : NULL),
7956 __ENQUEUE_COPY_IMAGE_ERR);
7958 if (event != NULL && err == CL_SUCCESS)
7964#if CL_HPP_TARGET_OPENCL_VERSION >= 120
7974 cl_float4 fillColor,
7975 const array<size_type, 3>& origin,
7976 const array<size_type, 3>& region,
7977 const vector<Event>* events = NULL,
7978 Event* event = NULL)
const
7981 cl_int err = detail::errHandler(
7982 ::clEnqueueFillImage(
7985 static_cast<void*
>(&fillColor),
7988 (events != NULL) ? (cl_uint) events->size() : 0,
7989 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7990 (event != NULL) ? &tmp : NULL),
7991 __ENQUEUE_FILL_IMAGE_ERR);
7993 if (event != NULL && err == CL_SUCCESS)
8009 const array<size_type, 3>& origin,
8010 const array<size_type, 3>& region,
8011 const vector<Event>* events = NULL,
8012 Event* event = NULL)
const
8015 cl_int err = detail::errHandler(
8016 ::clEnqueueFillImage(
8019 static_cast<void*
>(&fillColor),
8022 (events != NULL) ? (cl_uint) events->size() : 0,
8023 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8024 (event != NULL) ? &tmp : NULL),
8025 __ENQUEUE_FILL_IMAGE_ERR);
8027 if (event != NULL && err == CL_SUCCESS)
8043 const array<size_type, 3>& origin,
8044 const array<size_type, 3>& region,
8045 const vector<Event>* events = NULL,
8046 Event* event = NULL)
const
8049 cl_int err = detail::errHandler(
8050 ::clEnqueueFillImage(
8053 static_cast<void*
>(&fillColor),
8056 (events != NULL) ? (cl_uint) events->size() : 0,
8057 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8058 (event != NULL) ? &tmp : NULL),
8059 __ENQUEUE_FILL_IMAGE_ERR);
8061 if (event != NULL && err == CL_SUCCESS)
8068 cl_int enqueueCopyImageToBuffer(
8071 const array<size_type, 3>& src_origin,
8072 const array<size_type, 3>& region,
8073 size_type dst_offset,
8074 const vector<Event>* events = NULL,
8075 Event* event = NULL)
const
8078 cl_int err = detail::errHandler(
8079 ::clEnqueueCopyImageToBuffer(
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_IMAGE_TO_BUFFER_ERR);
8091 if (event != NULL && err == CL_SUCCESS)
8097 cl_int enqueueCopyBufferToImage(
8100 size_type src_offset,
8101 const array<size_type, 3>& dst_origin,
8102 const array<size_type, 3>& region,
8103 const vector<Event>* events = NULL,
8104 Event* event = NULL)
const
8107 cl_int err = detail::errHandler(
8108 ::clEnqueueCopyBufferToImage(
8115 (events != NULL) ? (cl_uint) events->size() : 0,
8116 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8117 (event != NULL) ? &tmp : NULL),
8118 __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR);
8120 if (event != NULL && err == CL_SUCCESS)
8126 void* enqueueMapBuffer(
8127 const Buffer& buffer,
8132 const vector<Event>* events = NULL,
8133 Event* event = NULL,
8134 cl_int* err = NULL)
const
8138 void * result = ::clEnqueueMapBuffer(
8139 object_, buffer(), blocking, flags, offset, size,
8140 (events != NULL) ? (cl_uint) events->size() : 0,
8141 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8142 (event != NULL) ? &tmp : NULL,
8145 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
8149 if (event != NULL && error == CL_SUCCESS)
8155 void* enqueueMapImage(
8156 const Image& buffer,
8159 const array<size_type, 3>& origin,
8160 const array<size_type, 3>& region,
8161 size_type * row_pitch,
8162 size_type * slice_pitch,
8163 const vector<Event>* events = NULL,
8164 Event* event = NULL,
8165 cl_int* err = NULL)
const
8169 void * result = ::clEnqueueMapImage(
8170 object_, buffer(), blocking, flags,
8173 row_pitch, slice_pitch,
8174 (events != NULL) ? (cl_uint) events->size() : 0,
8175 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8176 (event != NULL) ? &tmp : NULL,
8179 detail::errHandler(error, __ENQUEUE_MAP_IMAGE_ERR);
8183 if (event != NULL && error == CL_SUCCESS)
8188#if CL_HPP_TARGET_OPENCL_VERSION >= 200
8193 template<
typename T>
8199 const vector<Event>* events = NULL,
8200 Event* event = NULL)
const
8203 cl_int err = detail::errHandler(::clEnqueueSVMMap(
8204 object_, blocking, flags,
static_cast<void*
>(ptr), size,
8205 (events != NULL) ? (cl_uint)events->size() : 0,
8206 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8207 (event != NULL) ? &tmp : NULL),
8208 __ENQUEUE_MAP_BUFFER_ERR);
8210 if (event != NULL && err == CL_SUCCESS)
8221 template<
typename T,
class D>
8223 cl::pointer<T, D> &ptr,
8227 const vector<Event>* events = NULL,
8228 Event* event = NULL)
const
8231 cl_int err = detail::errHandler(::clEnqueueSVMMap(
8232 object_, blocking, flags,
static_cast<void*
>(ptr.get()), size,
8233 (events != NULL) ? (cl_uint)events->size() : 0,
8234 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8235 (event != NULL) ? &tmp : NULL),
8236 __ENQUEUE_MAP_BUFFER_ERR);
8238 if (event != NULL && err == CL_SUCCESS)
8248 template<
typename T,
class Alloc>
8250 cl::vector<T, Alloc> &container,
8253 const vector<Event>* events = NULL,
8254 Event* event = NULL)
const
8257 cl_int err = detail::errHandler(::clEnqueueSVMMap(
8258 object_, blocking, flags,
static_cast<void*
>(container.data()), container.size()*
sizeof(T),
8259 (events != NULL) ? (cl_uint)events->size() : 0,
8260 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8261 (event != NULL) ? &tmp : NULL),
8262 __ENQUEUE_MAP_BUFFER_ERR);
8264 if (event != NULL && err == CL_SUCCESS)
8271 cl_int enqueueUnmapMemObject(
8274 const vector<Event>* events = NULL,
8275 Event* event = NULL)
const
8278 cl_int err = detail::errHandler(
8279 ::clEnqueueUnmapMemObject(
8280 object_, memory(), mapped_ptr,
8281 (events != NULL) ? (cl_uint) events->size() : 0,
8282 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8283 (event != NULL) ? &tmp : NULL),
8284 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8286 if (event != NULL && err == CL_SUCCESS)
8293#if CL_HPP_TARGET_OPENCL_VERSION >= 200
8298 template<
typename T>
8301 const vector<Event>* events = NULL,
8302 Event* event = NULL)
const
8305 cl_int err = detail::errHandler(
8306 ::clEnqueueSVMUnmap(
8307 object_,
static_cast<void*
>(ptr),
8308 (events != NULL) ? (cl_uint)events->size() : 0,
8309 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8310 (event != NULL) ? &tmp : NULL),
8311 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8313 if (event != NULL && err == CL_SUCCESS)
8323 template<
typename T,
class D>
8325 cl::pointer<T, D> &ptr,
8326 const vector<Event>* events = NULL,
8327 Event* event = NULL)
const
8330 cl_int err = detail::errHandler(
8331 ::clEnqueueSVMUnmap(
8332 object_,
static_cast<void*
>(ptr.get()),
8333 (events != NULL) ? (cl_uint)events->size() : 0,
8334 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8335 (event != NULL) ? &tmp : NULL),
8336 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8338 if (event != NULL && err == CL_SUCCESS)
8348 template<
typename T,
class Alloc>
8350 cl::vector<T, Alloc> &container,
8351 const vector<Event>* events = NULL,
8352 Event* event = NULL)
const
8355 cl_int err = detail::errHandler(
8356 ::clEnqueueSVMUnmap(
8357 object_,
static_cast<void*
>(container.data()),
8358 (events != NULL) ? (cl_uint)events->size() : 0,
8359 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8360 (event != NULL) ? &tmp : NULL),
8361 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8363 if (event != NULL && err == CL_SUCCESS)
8370#if CL_HPP_TARGET_OPENCL_VERSION >= 120
8383 const vector<Event> *events = 0,
8384 Event *event = 0)
const
8387 cl_int err = detail::errHandler(
8388 ::clEnqueueMarkerWithWaitList(
8390 (events != NULL) ? (cl_uint) events->size() : 0,
8391 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8392 (event != NULL) ? &tmp : NULL),
8393 __ENQUEUE_MARKER_WAIT_LIST_ERR);
8395 if (event != NULL && err == CL_SUCCESS)
8413 const vector<Event> *events = 0,
8414 Event *event = 0)
const
8417 cl_int err = detail::errHandler(
8418 ::clEnqueueBarrierWithWaitList(
8420 (events != NULL) ? (cl_uint) events->size() : 0,
8421 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8422 (event != NULL) ? &tmp : NULL),
8423 __ENQUEUE_BARRIER_WAIT_LIST_ERR);
8425 if (event != NULL && err == CL_SUCCESS)
8436 const vector<Memory> &memObjects,
8437 cl_mem_migration_flags flags,
8438 const vector<Event>* events = NULL,
8444 vector<cl_mem> localMemObjects(memObjects.size());
8446 for(
int i = 0; i < (int)memObjects.size(); ++i ) {
8447 localMemObjects[i] = memObjects[i]();
8450 cl_int err = detail::errHandler(
8451 ::clEnqueueMigrateMemObjects(
8453 (cl_uint)memObjects.size(),
8454 localMemObjects.data(),
8456 (events != NULL) ? (cl_uint) events->size() : 0,
8457 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8458 (event != NULL) ? &tmp : NULL),
8459 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8461 if (event != NULL && err == CL_SUCCESS)
8469#if CL_HPP_TARGET_OPENCL_VERSION >= 210
8475 template<
typename T>
8477 const cl::vector<T*> &svmRawPointers,
8478 const cl::vector<size_type> &sizes,
8479 cl_mem_migration_flags flags = 0,
8480 const vector<Event>* events = NULL,
8481 Event* event = NULL)
const
8484 cl_int err = detail::errHandler(::clEnqueueSVMMigrateMem(
8486 svmRawPointers.size(),
static_cast<void**
>(svmRawPointers.data()),
8489 (events != NULL) ? (cl_uint)events->size() : 0,
8490 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8491 (event != NULL) ? &tmp : NULL),
8492 __ENQUEUE_MIGRATE_SVM_ERR);
8494 if (event != NULL && err == CL_SUCCESS)
8504 template<
typename T>
8506 const cl::vector<T*> &svmRawPointers,
8507 cl_mem_migration_flags flags = 0,
8508 const vector<Event>* events = NULL,
8509 Event* event = NULL)
const
8511 return enqueueMigrateSVM(svmRawPointers, cl::vector<size_type>(svmRawPointers.size()), flags, events, event);
8520 template<
typename T,
class D>
8522 const cl::vector<cl::pointer<T, D>> &svmPointers,
8523 const cl::vector<size_type> &sizes,
8524 cl_mem_migration_flags flags = 0,
8525 const vector<Event>* events = NULL,
8526 Event* event = NULL)
const
8528 cl::vector<void*> svmRawPointers;
8529 svmRawPointers.reserve(svmPointers.size());
8530 for (
auto p : svmPointers) {
8531 svmRawPointers.push_back(
static_cast<void*
>(p.get()));
8542 template<
typename T,
class D>
8544 const cl::vector<cl::pointer<T, D>> &svmPointers,
8545 cl_mem_migration_flags flags = 0,
8546 const vector<Event>* events = NULL,
8547 Event* event = NULL)
const
8549 return enqueueMigrateSVM(svmPointers, cl::vector<size_type>(svmPointers.size()), flags, events, event);
8557 template<
typename T,
class Alloc>
8559 const cl::vector<cl::vector<T, Alloc>> &svmContainers,
8560 const cl::vector<size_type> &sizes,
8561 cl_mem_migration_flags flags = 0,
8562 const vector<Event>* events = NULL,
8563 Event* event = NULL)
const
8565 cl::vector<void*> svmRawPointers;
8566 svmRawPointers.reserve(svmContainers.size());
8567 for (
auto p : svmContainers) {
8568 svmRawPointers.push_back(
static_cast<void*
>(p.data()));
8578 template<
typename T,
class Alloc>
8580 const cl::vector<cl::vector<T, Alloc>> &svmContainers,
8581 cl_mem_migration_flags flags = 0,
8582 const vector<Event>* events = NULL,
8583 Event* event = NULL)
const
8585 return enqueueMigrateSVM(svmContainers, cl::vector<size_type>(svmContainers.size()), flags, events, event);
8590 cl_int enqueueNDRangeKernel(
8594 const NDRange& local = NullRange,
8595 const vector<Event>* events = NULL,
8596 Event* event = NULL)
const
8599 cl_int err = detail::errHandler(
8600 ::clEnqueueNDRangeKernel(
8601 object_, kernel(), (cl_uint) global.
dimensions(),
8602 offset.
dimensions() != 0 ? (
const size_type*) offset : NULL,
8603 (
const size_type*) global,
8604 local.dimensions() != 0 ? (
const size_type*) local : NULL,
8605 (events != NULL) ? (cl_uint) events->size() : 0,
8606 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8607 (event != NULL) ? &tmp : NULL),
8608 __ENQUEUE_NDRANGE_KERNEL_ERR);
8610 if (event != NULL && err == CL_SUCCESS)
8616#if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
8617 CL_API_PREFIX__VERSION_1_2_DEPRECATED cl_int enqueueTask(
8618 const Kernel& kernel,
8619 const vector<Event>* events = NULL,
8620 Event* event = NULL)
const CL_API_SUFFIX__VERSION_1_2_DEPRECATED
8623 cl_int err = detail::errHandler(
8626 (events != NULL) ? (cl_uint) events->size() : 0,
8627 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8628 (event != NULL) ? &tmp : NULL),
8629 __ENQUEUE_TASK_ERR);
8631 if (event != NULL && err == CL_SUCCESS)
8638 cl_int enqueueNativeKernel(
8639 void (CL_CALLBACK *userFptr)(
void *),
8640 std::pair<void*, size_type> args,
8641 const vector<Memory>* mem_objects = NULL,
8642 const vector<const void*>* mem_locs = NULL,
8643 const vector<Event>* events = NULL,
8644 Event* event = NULL)
const
8646 size_type elements = 0;
8647 if (mem_objects != NULL) {
8648 elements = mem_objects->size();
8650 vector<cl_mem> mems(elements);
8651 for (
unsigned int i = 0; i < elements; i++) {
8652 mems[i] = ((*mem_objects)[i])();
8656 cl_int err = detail::errHandler(
8657 ::clEnqueueNativeKernel(
8658 object_, userFptr, args.first, args.second,
8659 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8661 (mem_locs != NULL && mem_locs->size() > 0) ? (
const void **) &mem_locs->front() : NULL,
8662 (events != NULL) ? (cl_uint) events->size() : 0,
8663 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8664 (event != NULL) ? &tmp : NULL),
8665 __ENQUEUE_NATIVE_KERNEL);
8667 if (event != NULL && err == CL_SUCCESS)
8676#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
8677 CL_API_PREFIX__VERSION_1_1_DEPRECATED
8681 cl_int err = detail::errHandler(
8684 (event != NULL) ? &tmp : NULL),
8685 __ENQUEUE_MARKER_ERR);
8687 if (event != NULL && err == CL_SUCCESS)
8693 CL_API_PREFIX__VERSION_1_1_DEPRECATED
8694 cl_int enqueueWaitForEvents(
const vector<Event>& events)
const CL_API_SUFFIX__VERSION_1_1_DEPRECATED
8696 return detail::errHandler(
8697 ::clEnqueueWaitForEvents(
8699 (cl_uint) events.size(),
8700 events.size() > 0 ? (
const cl_event*) &events.front() : NULL),
8701 __ENQUEUE_WAIT_FOR_EVENTS_ERR);
8705 cl_int enqueueAcquireGLObjects(
8706 const vector<Memory>* mem_objects = NULL,
8707 const vector<Event>* events = NULL,
8708 Event* event = NULL)
const
8711 cl_int err = detail::errHandler(
8712 ::clEnqueueAcquireGLObjects(
8714 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8715 (mem_objects != NULL && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front(): NULL,
8716 (events != NULL) ? (cl_uint) events->size() : 0,
8717 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8718 (event != NULL) ? &tmp : NULL),
8719 __ENQUEUE_ACQUIRE_GL_ERR);
8721 if (event != NULL && err == CL_SUCCESS)
8727 cl_int enqueueReleaseGLObjects(
8728 const vector<Memory>* mem_objects = NULL,
8729 const vector<Event>* events = NULL,
8730 Event* event = NULL)
const
8733 cl_int err = detail::errHandler(
8734 ::clEnqueueReleaseGLObjects(
8736 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8737 (mem_objects != NULL && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front(): NULL,
8738 (events != NULL) ? (cl_uint) events->size() : 0,
8739 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8740 (event != NULL) ? &tmp : NULL),
8741 __ENQUEUE_RELEASE_GL_ERR);
8743 if (event != NULL && err == CL_SUCCESS)
8749#if defined (CL_HPP_USE_DX_INTEROP)
8750typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueAcquireD3D10ObjectsKHR)(
8751 cl_command_queue command_queue, cl_uint num_objects,
8752 const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
8753 const cl_event* event_wait_list, cl_event* event);
8754typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueReleaseD3D10ObjectsKHR)(
8755 cl_command_queue command_queue, cl_uint num_objects,
8756 const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
8757 const cl_event* event_wait_list, cl_event* event);
8759 cl_int enqueueAcquireD3D10Objects(
8760 const vector<Memory>* mem_objects = NULL,
8761 const vector<Event>* events = NULL,
8762 Event* event = NULL)
const
8764 static PFN_clEnqueueAcquireD3D10ObjectsKHR pfn_clEnqueueAcquireD3D10ObjectsKHR = NULL;
8765#if CL_HPP_TARGET_OPENCL_VERSION >= 120
8766 cl_context context = getInfo<CL_QUEUE_CONTEXT>();
8767 cl::Device device(getInfo<CL_QUEUE_DEVICE>());
8768 cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>();
8769 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueAcquireD3D10ObjectsKHR);
8771#if CL_HPP_TARGET_OPENCL_VERSION >= 110
8772 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueAcquireD3D10ObjectsKHR);
8776 cl_int err = detail::errHandler(
8777 pfn_clEnqueueAcquireD3D10ObjectsKHR(
8779 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8780 (mem_objects != NULL && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front(): NULL,
8781 (events != NULL) ? (cl_uint) events->size() : 0,
8782 (events != NULL) ? (cl_event*) &events->front() : NULL,
8783 (event != NULL) ? &tmp : NULL),
8784 __ENQUEUE_ACQUIRE_GL_ERR);
8786 if (event != NULL && err == CL_SUCCESS)
8792 cl_int enqueueReleaseD3D10Objects(
8793 const vector<Memory>* mem_objects = NULL,
8794 const vector<Event>* events = NULL,
8795 Event* event = NULL)
const
8797 static PFN_clEnqueueReleaseD3D10ObjectsKHR pfn_clEnqueueReleaseD3D10ObjectsKHR = NULL;
8798#if CL_HPP_TARGET_OPENCL_VERSION >= 120
8799 cl_context context = getInfo<CL_QUEUE_CONTEXT>();
8800 cl::Device device(getInfo<CL_QUEUE_DEVICE>());
8801 cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>();
8802 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueReleaseD3D10ObjectsKHR);
8804#if CL_HPP_TARGET_OPENCL_VERSION >= 110
8805 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueReleaseD3D10ObjectsKHR);
8809 cl_int err = detail::errHandler(
8810 pfn_clEnqueueReleaseD3D10ObjectsKHR(
8812 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8813 (mem_objects != NULL && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front(): NULL,
8814 (events != NULL) ? (cl_uint) events->size() : 0,
8815 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8816 (event != NULL) ? &tmp : NULL),
8817 __ENQUEUE_RELEASE_GL_ERR);
8819 if (event != NULL && err == CL_SUCCESS)
8829#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
8830 CL_API_PREFIX__VERSION_1_1_DEPRECATED
8833 return detail::errHandler(
8834 ::clEnqueueBarrier(object_),
8835 __ENQUEUE_BARRIER_ERR);
8839 cl_int flush()
const
8841 return detail::errHandler(::clFlush(object_), __FLUSH_ERR);
8844 cl_int finish()
const
8846 return detail::errHandler(::clFinish(object_), __FINISH_ERR);
8850CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag CommandQueue::default_initialized_;
8851CL_HPP_DEFINE_STATIC_MEMBER_ CommandQueue CommandQueue::default_;
8852CL_HPP_DEFINE_STATIC_MEMBER_ cl_int CommandQueue::default_error_ = CL_SUCCESS;
8855#if CL_HPP_TARGET_OPENCL_VERSION >= 200
8856enum class DeviceQueueProperties : cl_command_queue_properties
8859 Profiling = CL_QUEUE_PROFILING_ENABLE,
8862inline DeviceQueueProperties operator|(DeviceQueueProperties lhs, DeviceQueueProperties rhs)
8864 return static_cast<DeviceQueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) |
static_cast<cl_command_queue_properties
>(rhs));
8888 cl_command_queue_properties mergedProperties =
8889 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
8891 cl_queue_properties queue_properties[] = {
8892 CL_QUEUE_PROPERTIES, mergedProperties, 0 };
8893 object_ = ::clCreateCommandQueueWithProperties(
8894 context(), device(), queue_properties, &error);
8896 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8908 DeviceQueueProperties properties = DeviceQueueProperties::None,
8913 cl_command_queue_properties mergedProperties =
8914 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
8915 cl_queue_properties queue_properties[] = {
8916 CL_QUEUE_PROPERTIES, mergedProperties, 0 };
8917 object_ = ::clCreateCommandQueueWithProperties(
8918 context(), device(), queue_properties, &error);
8920 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8933 DeviceQueueProperties properties = DeviceQueueProperties::None,
8938 cl_command_queue_properties mergedProperties =
8939 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
8940 cl_queue_properties queue_properties[] = {
8941 CL_QUEUE_PROPERTIES, mergedProperties,
8942 CL_QUEUE_SIZE, queueSize,
8944 object_ = ::clCreateCommandQueueWithProperties(
8945 context(), device(), queue_properties, &error);
8947 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8960 detail::Wrapper<cl_type>(commandQueue, retainObject) { }
8996 template <
typename T>
8997 cl_int getInfo(cl_command_queue_info name, T* param)
const
8999 return detail::errHandler(
9001 &::clGetCommandQueueInfo, object_, name, param),
9002 __GET_COMMAND_QUEUE_INFO_ERR);
9005 template <cl_command_queue_info name>
typename
9006 detail::param_traits<detail::cl_command_queue_info, name>::param_type
9007 getInfo(cl_int* err = NULL)
const
9009 typename detail::param_traits<
9010 detail::cl_command_queue_info, name>::param_type param;
9011 cl_int result = getInfo(name, ¶m);
9025 cl_int *err =
nullptr)
9031 cl_command_queue_properties properties =
9032 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
9033 cl_queue_properties queue_properties[] = {
9034 CL_QUEUE_PROPERTIES, properties,
9037 ::clCreateCommandQueueWithProperties(
9038 context(), device(), queue_properties, &error));
9040 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9055 const Context &context,
const Device &device, cl_int *err =
nullptr)
9059 cl_command_queue_properties properties =
9060 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
9061 cl_queue_properties queue_properties[] = {
9062 CL_QUEUE_PROPERTIES, properties,
9065 ::clCreateCommandQueueWithProperties(
9066 context(), device(), queue_properties, &error));
9068 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9083 const Context &context,
const Device &device, cl_uint queueSize, cl_int *err =
nullptr)
9087 cl_command_queue_properties properties =
9088 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
9089 cl_queue_properties queue_properties[] = {
9090 CL_QUEUE_PROPERTIES, properties,
9091 CL_QUEUE_SIZE, queueSize,
9094 ::clCreateCommandQueueWithProperties(
9095 context(), device(), queue_properties, &error));
9097 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9107#if CL_HPP_TARGET_OPENCL_VERSION >= 210
9117 error = clSetDefaultDeviceCommandQueue(context.get(), device.get(), default_queue.get());
9119 detail::errHandler(error, __SET_DEFAULT_DEVICE_COMMAND_QUEUE_ERR);
9123 return default_queue;
9131 return queue.getInfo<CL_QUEUE_DEVICE_DEFAULT>(err);
9151template<
typename IteratorType >
9154 IteratorType startIterator,
9155 IteratorType endIterator,
9160 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9163 cl_mem_flags flags = 0;
9165 flags |= CL_MEM_READ_ONLY;
9168 flags |= CL_MEM_READ_WRITE;
9171 flags |= CL_MEM_USE_HOST_PTR;
9174 size_type size =
sizeof(DataType)*(endIterator - startIterator);
9177 object_ = ::clCreateBuffer(context(), flags, size,
static_cast<DataType*
>(&*startIterator), &error);
9179 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
9182 detail::errHandler(error, __CREATE_BUFFER_ERR);
9189 detail::errHandler(error, __CREATE_BUFFER_ERR);
9194 error =
cl::copy(queue, startIterator, endIterator, *
this);
9195 detail::errHandler(error, __CREATE_BUFFER_ERR);
9202template<
typename IteratorType >
9205 IteratorType startIterator,
9206 IteratorType endIterator,
9211 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9214 cl_mem_flags flags = 0;
9216 flags |= CL_MEM_READ_ONLY;
9219 flags |= CL_MEM_READ_WRITE;
9222 flags |= CL_MEM_USE_HOST_PTR;
9225 size_type size =
sizeof(DataType)*(endIterator - startIterator);
9227 Context context = queue.getInfo<CL_QUEUE_CONTEXT>();
9230 object_ = ::clCreateBuffer(context(), flags, size,
static_cast<DataType*
>(&*startIterator), &error);
9233 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
9236 detail::errHandler(error, __CREATE_BUFFER_ERR);
9242 error =
cl::copy(queue, startIterator, endIterator, *
this);
9243 detail::errHandler(error, __CREATE_BUFFER_ERR);
9250inline cl_int enqueueReadBuffer(
9256 const vector<Event>* events = NULL,
9257 Event* event = NULL)
9262 if (error != CL_SUCCESS) {
9266 return queue.enqueueReadBuffer(buffer, blocking, offset, size, ptr, events, event);
9269inline cl_int enqueueWriteBuffer(
9270 const Buffer& buffer,
9275 const vector<Event>* events = NULL,
9276 Event* event = NULL)
9279 CommandQueue queue = CommandQueue::getDefault(&error);
9281 if (error != CL_SUCCESS) {
9285 return queue.enqueueWriteBuffer(buffer, blocking, offset, size, ptr, events, event);
9288inline void* enqueueMapBuffer(
9289 const Buffer& buffer,
9294 const vector<Event>* events = NULL,
9295 Event* event = NULL,
9299 CommandQueue queue = CommandQueue::getDefault(&error);
9300 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9305 void * result = ::clEnqueueMapBuffer(
9306 queue(), buffer(), blocking, flags, offset, size,
9307 (events != NULL) ? (cl_uint) events->size() : 0,
9308 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
9312 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9320#if CL_HPP_TARGET_OPENCL_VERSION >= 200
9332 const vector<Event>* events,
9337 if (error != CL_SUCCESS) {
9338 return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9342 ptr, blocking, flags, size, events, event);
9350template<
typename T,
class D>
9352 cl::pointer<T, D> &ptr,
9356 const vector<Event>* events = NULL,
9357 Event* event = NULL)
9361 if (error != CL_SUCCESS) {
9362 return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9366 ptr, blocking, flags, size, events, event);
9374template<
typename T,
class Alloc>
9376 cl::vector<T, Alloc> &container,
9379 const vector<Event>* events = NULL,
9380 Event* event = NULL)
9384 if (error != CL_SUCCESS) {
9385 return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9389 container, blocking, flags, events, event);
9394inline cl_int enqueueUnmapMemObject(
9395 const Memory& memory,
9397 const vector<Event>* events = NULL,
9398 Event* event = NULL)
9401 CommandQueue queue = CommandQueue::getDefault(&error);
9402 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9403 if (error != CL_SUCCESS) {
9408 cl_int err = detail::errHandler(
9409 ::clEnqueueUnmapMemObject(
9410 queue(), memory(), mapped_ptr,
9411 (events != NULL) ? (cl_uint)events->size() : 0,
9412 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
9413 (event != NULL) ? &tmp : NULL),
9414 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9416 if (event != NULL && err == CL_SUCCESS)
9422#if CL_HPP_TARGET_OPENCL_VERSION >= 200
9431 const vector<Event>* events = NULL,
9432 Event* event = NULL)
9436 if (error != CL_SUCCESS) {
9437 return detail::errHandler(error, __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9441 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9450template<
typename T,
class D>
9452 cl::pointer<T, D> &ptr,
9453 const vector<Event>* events = NULL,
9454 Event* event = NULL)
9458 if (error != CL_SUCCESS) {
9459 return detail::errHandler(error, __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9463 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9471template<
typename T,
class Alloc>
9473 cl::vector<T, Alloc> &container,
9474 const vector<Event>* events = NULL,
9475 Event* event = NULL)
9479 if (error != CL_SUCCESS) {
9480 return detail::errHandler(error, __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9483 return detail::errHandler(queue.
enqueueUnmapSVM(container, events, event),
9484 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9489inline cl_int enqueueCopyBuffer(
9492 size_type src_offset,
9493 size_type dst_offset,
9495 const vector<Event>* events = NULL,
9496 Event* event = NULL)
9499 CommandQueue queue = CommandQueue::getDefault(&error);
9501 if (error != CL_SUCCESS) {
9505 return queue.enqueueCopyBuffer(src, dst, src_offset, dst_offset, size, events, event);
9513template<
typename IteratorType >
9514inline cl_int
copy( IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer )
9518 if (error != CL_SUCCESS)
9521 return cl::copy(queue, startIterator, endIterator, buffer);
9529template<
typename IteratorType >
9530inline cl_int
copy(
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator )
9534 if (error != CL_SUCCESS)
9537 return cl::copy(queue, buffer, startIterator, endIterator);
9545template<
typename IteratorType >
9548 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9551 size_type length = endIterator-startIterator;
9552 size_type byteLength = length*
sizeof(DataType);
9555 static_cast<DataType*
>(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_WRITE, 0, byteLength, 0, 0, &error));
9557 if( error != CL_SUCCESS ) {
9560#if defined(_MSC_VER)
9564 stdext::checked_array_iterator<DataType*>(
9567 std::copy(startIterator, endIterator, pointer);
9570 error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
9572 if( error != CL_SUCCESS ) {
9584template<
typename IteratorType >
9587 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9590 size_type length = endIterator-startIterator;
9591 size_type byteLength = length*
sizeof(DataType);
9594 static_cast<DataType*
>(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_READ, 0, byteLength, 0, 0, &error));
9596 if( error != CL_SUCCESS ) {
9599 std::copy(pointer, pointer + length, startIterator);
9601 error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
9603 if( error != CL_SUCCESS ) {
9611#if CL_HPP_TARGET_OPENCL_VERSION >= 200
9615template<
typename T,
class Alloc>
9616inline cl_int
mapSVM(cl::vector<T, Alloc> &container)
9618 return enqueueMapSVM(container, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE);
9624template<
typename T,
class Alloc>
9632#if CL_HPP_TARGET_OPENCL_VERSION >= 110
9633inline cl_int enqueueReadBufferRect(
9634 const Buffer& buffer,
9636 const array<size_type, 3>& buffer_offset,
9637 const array<size_type, 3>& host_offset,
9638 const array<size_type, 3>& region,
9639 size_type buffer_row_pitch,
9640 size_type buffer_slice_pitch,
9641 size_type host_row_pitch,
9642 size_type host_slice_pitch,
9644 const vector<Event>* events = NULL,
9645 Event* event = NULL)
9648 CommandQueue queue = CommandQueue::getDefault(&error);
9650 if (error != CL_SUCCESS) {
9654 return queue.enqueueReadBufferRect(
9669inline cl_int enqueueWriteBufferRect(
9670 const Buffer& buffer,
9672 const array<size_type, 3>& buffer_offset,
9673 const array<size_type, 3>& host_offset,
9674 const array<size_type, 3>& region,
9675 size_type buffer_row_pitch,
9676 size_type buffer_slice_pitch,
9677 size_type host_row_pitch,
9678 size_type host_slice_pitch,
9680 const vector<Event>* events = NULL,
9681 Event* event = NULL)
9684 CommandQueue queue = CommandQueue::getDefault(&error);
9686 if (error != CL_SUCCESS) {
9690 return queue.enqueueWriteBufferRect(
9705inline cl_int enqueueCopyBufferRect(
9708 const array<size_type, 3>& src_origin,
9709 const array<size_type, 3>& dst_origin,
9710 const array<size_type, 3>& region,
9711 size_type src_row_pitch,
9712 size_type src_slice_pitch,
9713 size_type dst_row_pitch,
9714 size_type dst_slice_pitch,
9715 const vector<Event>* events = NULL,
9716 Event* event = NULL)
9719 CommandQueue queue = CommandQueue::getDefault(&error);
9721 if (error != CL_SUCCESS) {
9725 return queue.enqueueCopyBufferRect(
9740inline cl_int enqueueReadImage(
9743 const array<size_type, 3>& origin,
9744 const array<size_type, 3>& region,
9745 size_type row_pitch,
9746 size_type slice_pitch,
9748 const vector<Event>* events = NULL,
9749 Event* event = NULL)
9752 CommandQueue queue = CommandQueue::getDefault(&error);
9754 if (error != CL_SUCCESS) {
9758 return queue.enqueueReadImage(
9770inline cl_int enqueueWriteImage(
9773 const array<size_type, 3>& origin,
9774 const array<size_type, 3>& region,
9775 size_type row_pitch,
9776 size_type slice_pitch,
9778 const vector<Event>* events = NULL,
9779 Event* event = NULL)
9782 CommandQueue queue = CommandQueue::getDefault(&error);
9784 if (error != CL_SUCCESS) {
9788 return queue.enqueueWriteImage(
9800inline cl_int enqueueCopyImage(
9803 const array<size_type, 3>& src_origin,
9804 const array<size_type, 3>& dst_origin,
9805 const array<size_type, 3>& region,
9806 const vector<Event>* events = NULL,
9807 Event* event = NULL)
9810 CommandQueue queue = CommandQueue::getDefault(&error);
9812 if (error != CL_SUCCESS) {
9816 return queue.enqueueCopyImage(
9826inline cl_int enqueueCopyImageToBuffer(
9829 const array<size_type, 3>& src_origin,
9830 const array<size_type, 3>& region,
9831 size_type dst_offset,
9832 const vector<Event>* events = NULL,
9833 Event* event = NULL)
9836 CommandQueue queue = CommandQueue::getDefault(&error);
9838 if (error != CL_SUCCESS) {
9842 return queue.enqueueCopyImageToBuffer(
9852inline cl_int enqueueCopyBufferToImage(
9855 size_type src_offset,
9856 const array<size_type, 3>& dst_origin,
9857 const array<size_type, 3>& region,
9858 const vector<Event>* events = NULL,
9859 Event* event = NULL)
9862 CommandQueue queue = CommandQueue::getDefault(&error);
9864 if (error != CL_SUCCESS) {
9868 return queue.enqueueCopyBufferToImage(
9879inline cl_int flush(
void)
9882 CommandQueue queue = CommandQueue::getDefault(&error);
9884 if (error != CL_SUCCESS) {
9888 return queue.flush();
9891inline cl_int finish(
void)
9894 CommandQueue queue = CommandQueue::getDefault(&error);
9896 if (error != CL_SUCCESS) {
9901 return queue.finish();
9911 vector<Event> events_;
9913 template<
typename... Ts>
9918 queue_(CommandQueue::getDefault()),
9927 queue_(CommandQueue::getDefault()),
9936 queue_(CommandQueue::getDefault()),
9945 queue_(CommandQueue::getDefault()),
9950 events_.push_back(e);
9954 queue_(CommandQueue::getDefault()),
9959 events_.push_back(e);
9963 queue_(CommandQueue::getDefault()),
9968 events_.push_back(e);
9972 queue_(CommandQueue::getDefault()),
9982 queue_(CommandQueue::getDefault()),
9992 queue_(CommandQueue::getDefault()),
10003 offset_(NullRange),
10012 offset_(NullRange),
10030 offset_(NullRange),
10034 events_.push_back(e);
10039 offset_(NullRange),
10043 events_.push_back(e);
10052 events_.push_back(e);
10057 offset_(NullRange),
10067 offset_(NullRange),
10094template<
typename... Ts>
10100 template<
int index,
typename T0,
typename... T1s>
10101 void setArgs(T0&& t0, T1s&&... t1s)
10103 kernel_.
setArg(index, t0);
10104 setArgs<index + 1, T1s...>(std::forward<T1s>(t1s)...);
10107 template<
int index,
typename T0>
10108 void setArgs(T0&& t0)
10110 kernel_.
setArg(index, t0);
10113 template<
int index>
10126 cl_int * err = NULL) :
10127 kernel_(program, name.c_str(), err)
10143 setArgs<0>(std::forward<Ts>(ts)...);
10145 args.queue_.enqueueNDRangeKernel(
10168 setArgs<0>(std::forward<Ts>(ts)...);
10170 error = args.queue_.enqueueNDRangeKernel(
10181#if CL_HPP_TARGET_OPENCL_VERSION >= 200
10182 cl_int setSVMPointers(
const vector<void*> &pointerList)
10187 template<
typename T0,
typename... T1s>
10188 cl_int setSVMPointers(
const T0 &t0, T1s &... ts)
10200namespace compatibility {
10205 template<
typename... Ts>
10215 cl_int * err = NULL) :
10237 enqueueArgs, args...);
10245#undef CL_HPP_ERR_STR_
10246#if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS)
10247#undef __GET_DEVICE_INFO_ERR
10248#undef __GET_PLATFORM_INFO_ERR
10249#undef __GET_DEVICE_IDS_ERR
10250#undef __GET_PLATFORM_IDS_ERR
10251#undef __GET_CONTEXT_INFO_ERR
10252#undef __GET_EVENT_INFO_ERR
10253#undef __GET_EVENT_PROFILE_INFO_ERR
10254#undef __GET_MEM_OBJECT_INFO_ERR
10255#undef __GET_IMAGE_INFO_ERR
10256#undef __GET_SAMPLER_INFO_ERR
10257#undef __GET_KERNEL_INFO_ERR
10258#undef __GET_KERNEL_ARG_INFO_ERR
10259#undef __GET_KERNEL_SUB_GROUP_INFO_ERR
10260#undef __GET_KERNEL_WORK_GROUP_INFO_ERR
10261#undef __GET_PROGRAM_INFO_ERR
10262#undef __GET_PROGRAM_BUILD_INFO_ERR
10263#undef __GET_COMMAND_QUEUE_INFO_ERR
10264#undef __CREATE_CONTEXT_ERR
10265#undef __CREATE_CONTEXT_FROM_TYPE_ERR
10266#undef __GET_SUPPORTED_IMAGE_FORMATS_ERR
10267#undef __CREATE_BUFFER_ERR
10269#undef __CREATE_SUBBUFFER_ERR
10270#undef __CREATE_GL_BUFFER_ERR
10271#undef __CREATE_GL_RENDER_BUFFER_ERR
10272#undef __GET_GL_OBJECT_INFO_ERR
10273#undef __CREATE_IMAGE_ERR
10274#undef __CREATE_GL_TEXTURE_ERR
10275#undef __IMAGE_DIMENSION_ERR
10276#undef __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR
10277#undef __CREATE_USER_EVENT_ERR
10278#undef __SET_USER_EVENT_STATUS_ERR
10279#undef __SET_EVENT_CALLBACK_ERR
10280#undef __WAIT_FOR_EVENTS_ERR
10281#undef __CREATE_KERNEL_ERR
10282#undef __SET_KERNEL_ARGS_ERR
10283#undef __CREATE_PROGRAM_WITH_SOURCE_ERR
10284#undef __CREATE_PROGRAM_WITH_IL_ERR
10285#undef __CREATE_PROGRAM_WITH_BINARY_ERR
10286#undef __CREATE_PROGRAM_WITH_IL_ERR
10287#undef __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR
10288#undef __BUILD_PROGRAM_ERR
10289#undef __COMPILE_PROGRAM_ERR
10290#undef __LINK_PROGRAM_ERR
10291#undef __CREATE_KERNELS_IN_PROGRAM_ERR
10292#undef __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR
10293#undef __CREATE_SAMPLER_WITH_PROPERTIES_ERR
10294#undef __SET_COMMAND_QUEUE_PROPERTY_ERR
10295#undef __ENQUEUE_READ_BUFFER_ERR
10296#undef __ENQUEUE_READ_BUFFER_RECT_ERR
10297#undef __ENQUEUE_WRITE_BUFFER_ERR
10298#undef __ENQUEUE_WRITE_BUFFER_RECT_ERR
10299#undef __ENQEUE_COPY_BUFFER_ERR
10300#undef __ENQEUE_COPY_BUFFER_RECT_ERR
10301#undef __ENQUEUE_FILL_BUFFER_ERR
10302#undef __ENQUEUE_READ_IMAGE_ERR
10303#undef __ENQUEUE_WRITE_IMAGE_ERR
10304#undef __ENQUEUE_COPY_IMAGE_ERR
10305#undef __ENQUEUE_FILL_IMAGE_ERR
10306#undef __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR
10307#undef __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR
10308#undef __ENQUEUE_MAP_BUFFER_ERR
10309#undef __ENQUEUE_MAP_IMAGE_ERR
10310#undef __ENQUEUE_UNMAP_MEM_OBJECT_ERR
10311#undef __ENQUEUE_NDRANGE_KERNEL_ERR
10312#undef __ENQUEUE_NATIVE_KERNEL
10313#undef __ENQUEUE_MIGRATE_MEM_OBJECTS_ERR
10314#undef __ENQUEUE_MIGRATE_SVM_ERR
10315#undef __ENQUEUE_ACQUIRE_GL_ERR
10316#undef __ENQUEUE_RELEASE_GL_ERR
10317#undef __CREATE_PIPE_ERR
10318#undef __GET_PIPE_INFO_ERR
10320#undef __RELEASE_ERR
10323#undef __VECTOR_CAPACITY_ERR
10324#undef __CREATE_SUB_DEVICES_ERR
10325#undef __CREATE_SUB_DEVICES_ERR
10326#undef __ENQUEUE_MARKER_ERR
10327#undef __ENQUEUE_WAIT_FOR_EVENTS_ERR
10328#undef __ENQUEUE_BARRIER_ERR
10329#undef __UNLOAD_COMPILER_ERR
10330#undef __CREATE_GL_TEXTURE_2D_ERR
10331#undef __CREATE_GL_TEXTURE_3D_ERR
10332#undef __CREATE_IMAGE2D_ERR
10333#undef __CREATE_IMAGE3D_ERR
10334#undef __CREATE_COMMAND_QUEUE_ERR
10335#undef __ENQUEUE_TASK_ERR
10336#undef __CREATE_SAMPLER_ERR
10337#undef __ENQUEUE_MARKER_WAIT_LIST_ERR
10338#undef __ENQUEUE_BARRIER_WAIT_LIST_ERR
10339#undef __CLONE_KERNEL_ERR
10340#undef __GET_HOST_TIMER_ERR
10341#undef __GET_DEVICE_AND_HOST_TIMER_ERR
10346#undef CL_HPP_INIT_CL_EXT_FCN_PTR_
10347#undef CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_
10349#if defined(CL_HPP_USE_CL_DEVICE_FISSION)
10350#undef CL_HPP_PARAM_NAME_DEVICE_FISSION_
10353#undef CL_HPP_NOEXCEPT_
10354#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.
cl_int copy(const CommandQueue &queue, const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator)
vector< T, cl::SVMAllocator< int, cl::SVMTraitFine<> > > fine_svm_vector
Vector alias to simplify contruction of fine-grained SVM containers.
cl_int copy(IteratorType startIterator, IteratorType endIterator, cl::Buffer &buffer)
LocalSpaceArg Local(size_type size)
Helper function for generating LocalSpaceArg objects.
CL_API_PREFIX__VERSION_1_1_DEPRECATED cl_int UnloadCompiler() CL_API_SUFFIX__VERSION_1_1_DEPRECATED
cl_int enqueueUnmapSVM(T *ptr, const vector< Event > *events=NULL, Event *event=NULL)
cl::pointer< T, detail::Deleter< Alloc > > allocate_pointer(const Alloc &alloc_, Args &&... args)
cl_int enqueueMapSVM(T *ptr, cl_bool blocking, cl_map_flags flags, size_type size, const vector< Event > *events=NULL, Event *event=NULL)
vector< T, cl::SVMAllocator< int, cl::SVMTraitCoarse<> > > coarse_svm_vector
Vector alias to simplify contruction of coarse-grained SVM containers.
cl_int mapSVM(cl::vector< T, Alloc > &container)
vector< T, cl::SVMAllocator< int, cl::SVMTraitAtomic<> > > atomic_svm_vector
Vector alias to simplify contruction of fine-grained SVM containers that support platform atomics.
cl_int unmapSVM(cl::vector< T, Alloc > &container)
Local address wrapper for use with Kernel::setArg.
Event type_(const EnqueueArgs &, Ts...)
Function signature of kernel functor with no event dependency.
Event result_type
Return type of the functor.
static cl_int release(cl_device_id device)
static cl_int retain(cl_device_id device)