399#if !defined(CL_HPP_USE_DX_INTEROP) && defined(USE_DX_INTEROP)
400# pragma message("opencl.hpp: USE_DX_INTEROP is deprecated. Define CL_HPP_USE_DX_INTEROP instead")
401# define CL_HPP_USE_DX_INTEROP
403#if !defined(CL_HPP_ENABLE_EXCEPTIONS) && defined(__CL_ENABLE_EXCEPTIONS)
404# pragma message("opencl.hpp: __CL_ENABLE_EXCEPTIONS is deprecated. Define CL_HPP_ENABLE_EXCEPTIONS instead")
405# define CL_HPP_ENABLE_EXCEPTIONS
407#if !defined(CL_HPP_NO_STD_VECTOR) && defined(__NO_STD_VECTOR)
408# pragma message("opencl.hpp: __NO_STD_VECTOR is deprecated. Define CL_HPP_NO_STD_VECTOR instead")
409# define CL_HPP_NO_STD_VECTOR
411#if !defined(CL_HPP_NO_STD_STRING) && defined(__NO_STD_STRING)
412# pragma message("opencl.hpp: __NO_STD_STRING is deprecated. Define CL_HPP_NO_STD_STRING instead")
413# define CL_HPP_NO_STD_STRING
415#if defined(VECTOR_CLASS)
416# pragma message("opencl.hpp: VECTOR_CLASS is deprecated. Alias cl::vector instead")
418#if defined(STRING_CLASS)
419# pragma message("opencl.hpp: STRING_CLASS is deprecated. Alias cl::string instead.")
421#if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS) && defined(__CL_USER_OVERRIDE_ERROR_STRINGS)
422# pragma message("opencl.hpp: __CL_USER_OVERRIDE_ERROR_STRINGS is deprecated. Define CL_HPP_USER_OVERRIDE_ERROR_STRINGS instead")
423# define CL_HPP_USER_OVERRIDE_ERROR_STRINGS
428#if defined(__USE_DEV_VECTOR)
429# pragma message("opencl.hpp: __USE_DEV_VECTOR is no longer supported. Expect compilation errors")
431#if defined(__USE_DEV_STRING)
432# pragma message("opencl.hpp: __USE_DEV_STRING is no longer supported. Expect compilation errors")
436#if !defined(CL_HPP_TARGET_OPENCL_VERSION)
437# pragma message("opencl.hpp: CL_HPP_TARGET_OPENCL_VERSION is not defined. It will default to 300 (OpenCL 3.0)")
438# define CL_HPP_TARGET_OPENCL_VERSION 300
440#if CL_HPP_TARGET_OPENCL_VERSION != 100 && \
441 CL_HPP_TARGET_OPENCL_VERSION != 110 && \
442 CL_HPP_TARGET_OPENCL_VERSION != 120 && \
443 CL_HPP_TARGET_OPENCL_VERSION != 200 && \
444 CL_HPP_TARGET_OPENCL_VERSION != 210 && \
445 CL_HPP_TARGET_OPENCL_VERSION != 220 && \
446 CL_HPP_TARGET_OPENCL_VERSION != 300
447# pragma message("opencl.hpp: CL_HPP_TARGET_OPENCL_VERSION is not a valid value (100, 110, 120, 200, 210, 220 or 300). It will be set to 300 (OpenCL 3.0).")
448# undef CL_HPP_TARGET_OPENCL_VERSION
449# define CL_HPP_TARGET_OPENCL_VERSION 300
453#if defined(CL_TARGET_OPENCL_VERSION)
456#if CL_TARGET_OPENCL_VERSION < CL_HPP_TARGET_OPENCL_VERSION
457# pragma message("CL_TARGET_OPENCL_VERSION is already defined as is lower than CL_HPP_TARGET_OPENCL_VERSION")
460# define CL_TARGET_OPENCL_VERSION CL_HPP_TARGET_OPENCL_VERSION
463#if !defined(CL_HPP_MINIMUM_OPENCL_VERSION)
464# define CL_HPP_MINIMUM_OPENCL_VERSION 200
466#if CL_HPP_MINIMUM_OPENCL_VERSION != 100 && \
467 CL_HPP_MINIMUM_OPENCL_VERSION != 110 && \
468 CL_HPP_MINIMUM_OPENCL_VERSION != 120 && \
469 CL_HPP_MINIMUM_OPENCL_VERSION != 200 && \
470 CL_HPP_MINIMUM_OPENCL_VERSION != 210 && \
471 CL_HPP_MINIMUM_OPENCL_VERSION != 220 && \
472 CL_HPP_MINIMUM_OPENCL_VERSION != 300
473# pragma message("opencl.hpp: CL_HPP_MINIMUM_OPENCL_VERSION is not a valid value (100, 110, 120, 200, 210, 220 or 300). It will be set to 100")
474# undef CL_HPP_MINIMUM_OPENCL_VERSION
475# define CL_HPP_MINIMUM_OPENCL_VERSION 100
477#if CL_HPP_MINIMUM_OPENCL_VERSION > CL_HPP_TARGET_OPENCL_VERSION
478# error "CL_HPP_MINIMUM_OPENCL_VERSION must not be greater than CL_HPP_TARGET_OPENCL_VERSION"
481#if CL_HPP_MINIMUM_OPENCL_VERSION <= 100 && !defined(CL_USE_DEPRECATED_OPENCL_1_0_APIS)
482# define CL_USE_DEPRECATED_OPENCL_1_0_APIS
484#if CL_HPP_MINIMUM_OPENCL_VERSION <= 110 && !defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
485# define CL_USE_DEPRECATED_OPENCL_1_1_APIS
487#if CL_HPP_MINIMUM_OPENCL_VERSION <= 120 && !defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
488# define CL_USE_DEPRECATED_OPENCL_1_2_APIS
490#if CL_HPP_MINIMUM_OPENCL_VERSION <= 200 && !defined(CL_USE_DEPRECATED_OPENCL_2_0_APIS)
491# define CL_USE_DEPRECATED_OPENCL_2_0_APIS
493#if CL_HPP_MINIMUM_OPENCL_VERSION <= 210 && !defined(CL_USE_DEPRECATED_OPENCL_2_1_APIS)
494# define CL_USE_DEPRECATED_OPENCL_2_1_APIS
496#if CL_HPP_MINIMUM_OPENCL_VERSION <= 220 && !defined(CL_USE_DEPRECATED_OPENCL_2_2_APIS)
497# define CL_USE_DEPRECATED_OPENCL_2_2_APIS
504#if defined(CL_HPP_USE_DX_INTEROP)
505#include <CL/cl_d3d10.h>
506#include <CL/cl_dx9_media_sharing.h>
518#if (!defined(_MSC_VER) && __cplusplus < 201103L) || (defined(_MSC_VER) && _MSC_VER < 1700)
519#error Visual studio 2013 or another C++11-supporting compiler required
522#if defined(__APPLE__) || defined(__MACOSX)
523#include <OpenCL/opencl.h>
525#include <CL/opencl.h>
528#if (__cplusplus >= 201103L || _MSVC_LANG >= 201103L )
529#define CL_HPP_NOEXCEPT_ noexcept
531#define CL_HPP_NOEXCEPT_
534#if __cplusplus >= 201703L
535# define CL_HPP_DEFINE_STATIC_MEMBER_ inline
536#elif defined(_MSC_VER)
537# define CL_HPP_DEFINE_STATIC_MEMBER_ __declspec(selectany)
538#elif defined(__MINGW32__)
539# define CL_HPP_DEFINE_STATIC_MEMBER_ __attribute__((selectany))
541# define CL_HPP_DEFINE_STATIC_MEMBER_ __attribute__((weak))
546#if !defined(CL_API_PREFIX__VERSION_1_1_DEPRECATED)
547#define CL_API_PREFIX__VERSION_1_1_DEPRECATED
549#if !defined(CL_API_SUFFIX__VERSION_1_1_DEPRECATED)
550#define CL_API_SUFFIX__VERSION_1_1_DEPRECATED
553#if !defined(CL_API_PREFIX__VERSION_1_2_DEPRECATED)
554#define CL_API_PREFIX__VERSION_1_2_DEPRECATED
556#if !defined(CL_API_SUFFIX__VERSION_1_2_DEPRECATED)
557#define CL_API_SUFFIX__VERSION_1_2_DEPRECATED
560#if !defined(CL_API_PREFIX__VERSION_2_2_DEPRECATED)
561#define CL_API_PREFIX__VERSION_2_2_DEPRECATED
563#if !defined(CL_API_SUFFIX__VERSION_2_2_DEPRECATED)
564#define CL_API_SUFFIX__VERSION_2_2_DEPRECATED
567#if !defined(CL_CALLBACK)
580#if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY)
582 using size_type = ::size_t;
586 using size_type = size_t;
591#if defined(CL_HPP_ENABLE_EXCEPTIONS)
595#if !defined(CL_HPP_NO_STD_VECTOR)
598 template <
class T,
class Alloc = std::allocator<T> >
599 using vector = std::vector<T, Alloc>;
603#if !defined(CL_HPP_NO_STD_STRING)
606 using string = std::string;
610#if CL_HPP_TARGET_OPENCL_VERSION >= 200
612#if !defined(CL_HPP_NO_STD_UNIQUE_PTR)
617 template<
class T,
class D>
618 using pointer = std::unique_ptr<T, D>;
622#if !defined(CL_HPP_NO_STD_ARRAY)
625 template <
class T,
size_type N >
626 using array = std::array<T, N>;
632#if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY)
634 namespace compatibility {
649 for (
int i = 0; i < N; ++i) {
654 size_t(
const array<size_type, N> &rhs)
656 for (
int i = 0; i < N; ++i) {
661 size_type& operator[](
int index)
666 const size_type& operator[](
int index)
const
672 operator size_type* () {
return data_; }
675 operator const size_type* ()
const {
return data_; }
677 operator array<size_type, N>()
const
679 array<size_type, N> ret;
681 for (
int i = 0; i < N; ++i) {
690 using size_t = compatibility::size_t<N>;
697 using size_t_array = array<size_type, 3>;
709#define CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(name) \
710 using PFN_##name = name##_fn
712#define CL_HPP_INIT_CL_EXT_FCN_PTR_(name) \
714 pfn_##name = (PFN_##name)clGetExtensionFunctionAddress(#name); \
717#define CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, name) \
719 pfn_##name = (PFN_##name) \
720 clGetExtensionFunctionAddressForPlatform(platform, #name); \
723#ifdef cl_khr_external_memory
724 enum class ExternalMemoryType : cl_external_memory_handle_type_khr;
732 class DeviceCommandQueue;
736#ifdef cl_khr_semaphore
739#if defined(cl_khr_command_buffer)
740 class CommandBufferKhr;
741 class MutableCommandKhr;
744#if defined(CL_HPP_ENABLE_EXCEPTIONS)
749 class Error :
public std::exception
753 const char * errStr_;
764 Error(cl_int err,
const char * errStr =
nullptr) : err_(err), errStr_(errStr)
773 virtual const char * what()
const throw ()
775 if (errStr_ ==
nullptr) {
787 cl_int err(
void)
const {
return err_; }
789#define CL_HPP_ERR_STR_(x) #x
791#define CL_HPP_ERR_STR_(x) nullptr
797#if defined(CL_HPP_ENABLE_EXCEPTIONS)
798static inline cl_int errHandler (
800 const char * errStr =
nullptr)
802 if (err != CL_SUCCESS) {
803 throw Error(err, errStr);
808static inline cl_int errHandler (cl_int err,
const char * errStr =
nullptr)
819#if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS)
820#define __GET_DEVICE_INFO_ERR CL_HPP_ERR_STR_(clGetDeviceInfo)
821#define __GET_PLATFORM_INFO_ERR CL_HPP_ERR_STR_(clGetPlatformInfo)
822#define __GET_DEVICE_IDS_ERR CL_HPP_ERR_STR_(clGetDeviceIDs)
823#define __GET_PLATFORM_IDS_ERR CL_HPP_ERR_STR_(clGetPlatformIDs)
824#define __GET_CONTEXT_INFO_ERR CL_HPP_ERR_STR_(clGetContextInfo)
825#define __GET_EVENT_INFO_ERR CL_HPP_ERR_STR_(clGetEventInfo)
826#define __GET_EVENT_PROFILE_INFO_ERR CL_HPP_ERR_STR_(clGetEventProfileInfo)
827#define __GET_MEM_OBJECT_INFO_ERR CL_HPP_ERR_STR_(clGetMemObjectInfo)
828#define __GET_IMAGE_INFO_ERR CL_HPP_ERR_STR_(clGetImageInfo)
829#define __GET_SAMPLER_INFO_ERR CL_HPP_ERR_STR_(clGetSamplerInfo)
830#define __GET_KERNEL_INFO_ERR CL_HPP_ERR_STR_(clGetKernelInfo)
831#if CL_HPP_TARGET_OPENCL_VERSION >= 120
832#define __GET_KERNEL_ARG_INFO_ERR CL_HPP_ERR_STR_(clGetKernelArgInfo)
834#if CL_HPP_TARGET_OPENCL_VERSION >= 210
835#define __GET_KERNEL_SUB_GROUP_INFO_ERR CL_HPP_ERR_STR_(clGetKernelSubGroupInfo)
837#define __GET_KERNEL_SUB_GROUP_INFO_ERR CL_HPP_ERR_STR_(clGetKernelSubGroupInfoKHR)
839#define __GET_KERNEL_WORK_GROUP_INFO_ERR CL_HPP_ERR_STR_(clGetKernelWorkGroupInfo)
840#define __GET_PROGRAM_INFO_ERR CL_HPP_ERR_STR_(clGetProgramInfo)
841#define __GET_PROGRAM_BUILD_INFO_ERR CL_HPP_ERR_STR_(clGetProgramBuildInfo)
842#define __GET_COMMAND_QUEUE_INFO_ERR CL_HPP_ERR_STR_(clGetCommandQueueInfo)
844#define __CREATE_CONTEXT_ERR CL_HPP_ERR_STR_(clCreateContext)
845#define __CREATE_CONTEXT_FROM_TYPE_ERR CL_HPP_ERR_STR_(clCreateContextFromType)
846#define __GET_SUPPORTED_IMAGE_FORMATS_ERR CL_HPP_ERR_STR_(clGetSupportedImageFormats)
847#if CL_HPP_TARGET_OPENCL_VERSION >= 300
848#define __SET_CONTEXT_DESCTRUCTOR_CALLBACK_ERR CL_HPP_ERR_STR_(clSetContextDestructorCallback)
851#define __CREATE_BUFFER_ERR CL_HPP_ERR_STR_(clCreateBuffer)
852#define __COPY_ERR CL_HPP_ERR_STR_(cl::copy)
853#define __CREATE_SUBBUFFER_ERR CL_HPP_ERR_STR_(clCreateSubBuffer)
854#define __CREATE_GL_BUFFER_ERR CL_HPP_ERR_STR_(clCreateFromGLBuffer)
855#define __CREATE_GL_RENDER_BUFFER_ERR CL_HPP_ERR_STR_(clCreateFromGLBuffer)
856#define __GET_GL_OBJECT_INFO_ERR CL_HPP_ERR_STR_(clGetGLObjectInfo)
857#if CL_HPP_TARGET_OPENCL_VERSION >= 120
858#define __CREATE_IMAGE_ERR CL_HPP_ERR_STR_(clCreateImage)
859#define __CREATE_GL_TEXTURE_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture)
860#define __IMAGE_DIMENSION_ERR CL_HPP_ERR_STR_(Incorrect image dimensions)
862#define __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR CL_HPP_ERR_STR_(clSetMemObjectDestructorCallback)
864#define __CREATE_USER_EVENT_ERR CL_HPP_ERR_STR_(clCreateUserEvent)
865#define __SET_USER_EVENT_STATUS_ERR CL_HPP_ERR_STR_(clSetUserEventStatus)
866#define __SET_EVENT_CALLBACK_ERR CL_HPP_ERR_STR_(clSetEventCallback)
867#define __WAIT_FOR_EVENTS_ERR CL_HPP_ERR_STR_(clWaitForEvents)
869#define __CREATE_KERNEL_ERR CL_HPP_ERR_STR_(clCreateKernel)
870#define __SET_KERNEL_ARGS_ERR CL_HPP_ERR_STR_(clSetKernelArg)
871#define __CREATE_PROGRAM_WITH_SOURCE_ERR CL_HPP_ERR_STR_(clCreateProgramWithSource)
872#define __CREATE_PROGRAM_WITH_BINARY_ERR CL_HPP_ERR_STR_(clCreateProgramWithBinary)
873#if CL_HPP_TARGET_OPENCL_VERSION >= 210
874#define __CREATE_PROGRAM_WITH_IL_ERR CL_HPP_ERR_STR_(clCreateProgramWithIL)
876#define __CREATE_PROGRAM_WITH_IL_ERR CL_HPP_ERR_STR_(clCreateProgramWithILKHR)
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)
926#define __RETAIN_ERR CL_HPP_ERR_STR_(Retain Object)
927#define __RELEASE_ERR CL_HPP_ERR_STR_(Release Object)
928#define __FLUSH_ERR CL_HPP_ERR_STR_(clFlush)
929#define __FINISH_ERR CL_HPP_ERR_STR_(clFinish)
930#define __VECTOR_CAPACITY_ERR CL_HPP_ERR_STR_(Vector capacity error)
932#if CL_HPP_TARGET_OPENCL_VERSION >= 210
933#define __GET_HOST_TIMER_ERR CL_HPP_ERR_STR_(clGetHostTimer)
934#define __GET_DEVICE_AND_HOST_TIMER_ERR CL_HPP_ERR_STR_(clGetDeviceAndHostTimer)
936#if CL_HPP_TARGET_OPENCL_VERSION >= 220
937#define __SET_PROGRAM_RELEASE_CALLBACK_ERR CL_HPP_ERR_STR_(clSetProgramReleaseCallback)
938#define __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR CL_HPP_ERR_STR_(clSetProgramSpecializationConstant)
941#ifdef cl_khr_external_memory
942#define __ENQUEUE_ACQUIRE_EXTERNAL_MEMORY_ERR CL_HPP_ERR_STR_(clEnqueueAcquireExternalMemObjectsKHR)
943#define __ENQUEUE_RELEASE_EXTERNAL_MEMORY_ERR CL_HPP_ERR_STR_(clEnqueueReleaseExternalMemObjectsKHR)
946#ifdef cl_khr_semaphore
947#define __GET_SEMAPHORE_KHR_INFO_ERR CL_HPP_ERR_STR_(clGetSemaphoreInfoKHR)
948#define __CREATE_SEMAPHORE_KHR_WITH_PROPERTIES_ERR CL_HPP_ERR_STR_(clCreateSemaphoreWithPropertiesKHR)
949#define __ENQUEUE_WAIT_SEMAPHORE_KHR_ERR CL_HPP_ERR_STR_(clEnqueueWaitSemaphoresKHR)
950#define __ENQUEUE_SIGNAL_SEMAPHORE_KHR_ERR CL_HPP_ERR_STR_(clEnqueueSignalSemaphoresKHR)
951#define __RETAIN_SEMAPHORE_KHR_ERR CL_HPP_ERR_STR_(clRetainSemaphoreKHR)
952#define __RELEASE_SEMAPHORE_KHR_ERR CL_HPP_ERR_STR_(clReleaseSemaphoreKHR)
954#if defined(cl_khr_command_buffer)
955#define __CREATE_COMMAND_BUFFER_KHR_ERR CL_HPP_ERR_STR_(clCreateCommandBufferKHR)
956#define __GET_COMMAND_BUFFER_INFO_KHR_ERR CL_HPP_ERR_STR_(clGetCommandBufferInfoKHR)
957#define __FINALIZE_COMMAND_BUFFER_KHR_ERR CL_HPP_ERR_STR_(clFinalizeCommandBufferKHR)
958#define __ENQUEUE_COMMAND_BUFFER_KHR_ERR CL_HPP_ERR_STR_(clEnqueueCommandBufferKHR)
959#define __COMMAND_BARRIER_WITH_WAIT_LIST_KHR_ERR CL_HPP_ERR_STR_(clCommandBarrierWithWaitListKHR)
960#define __COMMAND_COPY_BUFFER_KHR_ERR CL_HPP_ERR_STR_(clCommandCopyBufferKHR)
961#define __COMMAND_COPY_BUFFER_RECT_KHR_ERR CL_HPP_ERR_STR_(clCommandCopyBufferRectKHR)
962#define __COMMAND_COPY_BUFFER_TO_IMAGE_KHR_ERR CL_HPP_ERR_STR_(clCommandCopyBufferToImageKHR)
963#define __COMMAND_COPY_IMAGE_KHR_ERR CL_HPP_ERR_STR_(clCommandCopyImageKHR)
964#define __COMMAND_COPY_IMAGE_TO_BUFFER_KHR_ERR CL_HPP_ERR_STR_(clCommandCopyImageToBufferKHR)
965#define __COMMAND_FILL_BUFFER_KHR_ERR CL_HPP_ERR_STR_(clCommandFillBufferKHR)
966#define __COMMAND_FILL_IMAGE_KHR_ERR CL_HPP_ERR_STR_(clCommandFillImageKHR)
967#define __COMMAND_NDRANGE_KERNEL_KHR_ERR CL_HPP_ERR_STR_(clCommandNDRangeKernelKHR)
968#define __UPDATE_MUTABLE_COMMANDS_KHR_ERR CL_HPP_ERR_STR_(clUpdateMutableCommandsKHR)
969#define __GET_MUTABLE_COMMAND_INFO_KHR_ERR CL_HPP_ERR_STR_(clGetMutableCommandInfoKHR)
970#define __RETAIN_COMMAND_BUFFER_KHR_ERR CL_HPP_ERR_STR_(clRetainCommandBufferKHR)
971#define __RELEASE_COMMAND_BUFFER_KHR_ERR CL_HPP_ERR_STR_(clReleaseCommandBufferKHR)
977#if CL_HPP_TARGET_OPENCL_VERSION >= 120
978#define __CREATE_SUB_DEVICES_ERR CL_HPP_ERR_STR_(clCreateSubDevices)
980#define __CREATE_SUB_DEVICES_ERR CL_HPP_ERR_STR_(clCreateSubDevicesEXT)
986#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
987#define __ENQUEUE_MARKER_ERR CL_HPP_ERR_STR_(clEnqueueMarker)
988#define __ENQUEUE_WAIT_FOR_EVENTS_ERR CL_HPP_ERR_STR_(clEnqueueWaitForEvents)
989#define __ENQUEUE_BARRIER_ERR CL_HPP_ERR_STR_(clEnqueueBarrier)
990#define __UNLOAD_COMPILER_ERR CL_HPP_ERR_STR_(clUnloadCompiler)
991#define __CREATE_GL_TEXTURE_2D_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture2D)
992#define __CREATE_GL_TEXTURE_3D_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture3D)
993#define __CREATE_IMAGE2D_ERR CL_HPP_ERR_STR_(clCreateImage2D)
994#define __CREATE_IMAGE3D_ERR CL_HPP_ERR_STR_(clCreateImage3D)
1000#if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
1001#define __CREATE_COMMAND_QUEUE_ERR CL_HPP_ERR_STR_(clCreateCommandQueue)
1002#define __ENQUEUE_TASK_ERR CL_HPP_ERR_STR_(clEnqueueTask)
1003#define __CREATE_SAMPLER_ERR CL_HPP_ERR_STR_(clCreateSampler)
1009#if CL_HPP_TARGET_OPENCL_VERSION >= 120
1010#define __ENQUEUE_MARKER_WAIT_LIST_ERR CL_HPP_ERR_STR_(clEnqueueMarkerWithWaitList)
1011#define __ENQUEUE_BARRIER_WAIT_LIST_ERR CL_HPP_ERR_STR_(clEnqueueBarrierWithWaitList)
1014#if CL_HPP_TARGET_OPENCL_VERSION >= 210
1015#define __CLONE_KERNEL_ERR CL_HPP_ERR_STR_(clCloneKernel)
1021#ifdef cl_khr_external_memory
1022CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clEnqueueAcquireExternalMemObjectsKHR);
1023CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clEnqueueReleaseExternalMemObjectsKHR);
1025CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clEnqueueAcquireExternalMemObjectsKHR pfn_clEnqueueAcquireExternalMemObjectsKHR =
nullptr;
1026CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clEnqueueReleaseExternalMemObjectsKHR pfn_clEnqueueReleaseExternalMemObjectsKHR =
nullptr;
1029#ifdef cl_khr_semaphore
1030CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCreateSemaphoreWithPropertiesKHR);
1031CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clReleaseSemaphoreKHR);
1032CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clRetainSemaphoreKHR);
1033CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clEnqueueWaitSemaphoresKHR);
1034CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clEnqueueSignalSemaphoresKHR);
1035CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clGetSemaphoreInfoKHR);
1037CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCreateSemaphoreWithPropertiesKHR pfn_clCreateSemaphoreWithPropertiesKHR =
nullptr;
1038CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clReleaseSemaphoreKHR pfn_clReleaseSemaphoreKHR =
nullptr;
1039CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clRetainSemaphoreKHR pfn_clRetainSemaphoreKHR =
nullptr;
1040CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clEnqueueWaitSemaphoresKHR pfn_clEnqueueWaitSemaphoresKHR =
nullptr;
1041CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clEnqueueSignalSemaphoresKHR pfn_clEnqueueSignalSemaphoresKHR =
nullptr;
1042CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clGetSemaphoreInfoKHR pfn_clGetSemaphoreInfoKHR =
nullptr;
1045#if defined(cl_khr_command_buffer)
1046CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCreateCommandBufferKHR);
1047CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clFinalizeCommandBufferKHR);
1048CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clRetainCommandBufferKHR);
1049CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clReleaseCommandBufferKHR);
1050CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clGetCommandBufferInfoKHR);
1051CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clEnqueueCommandBufferKHR);
1052CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandBarrierWithWaitListKHR);
1053CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandCopyBufferKHR);
1054CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandCopyBufferRectKHR);
1055CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandCopyBufferToImageKHR);
1056CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandCopyImageKHR);
1057CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandCopyImageToBufferKHR);
1058CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandFillBufferKHR);
1059CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandFillImageKHR);
1060CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandNDRangeKernelKHR);
1062CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCreateCommandBufferKHR pfn_clCreateCommandBufferKHR =
nullptr;
1063CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clFinalizeCommandBufferKHR pfn_clFinalizeCommandBufferKHR =
nullptr;
1064CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clRetainCommandBufferKHR pfn_clRetainCommandBufferKHR =
nullptr;
1065CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clReleaseCommandBufferKHR pfn_clReleaseCommandBufferKHR =
nullptr;
1066CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clGetCommandBufferInfoKHR pfn_clGetCommandBufferInfoKHR =
nullptr;
1067CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clEnqueueCommandBufferKHR pfn_clEnqueueCommandBufferKHR =
nullptr;
1068CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandBarrierWithWaitListKHR pfn_clCommandBarrierWithWaitListKHR =
nullptr;
1069CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandCopyBufferKHR pfn_clCommandCopyBufferKHR =
nullptr;
1070CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandCopyBufferRectKHR pfn_clCommandCopyBufferRectKHR =
nullptr;
1071CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandCopyBufferToImageKHR pfn_clCommandCopyBufferToImageKHR =
nullptr;
1072CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandCopyImageKHR pfn_clCommandCopyImageKHR =
nullptr;
1073CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandCopyImageToBufferKHR pfn_clCommandCopyImageToBufferKHR =
nullptr;
1074CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandFillBufferKHR pfn_clCommandFillBufferKHR =
nullptr;
1075CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandFillImageKHR pfn_clCommandFillImageKHR =
nullptr;
1076CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandNDRangeKernelKHR pfn_clCommandNDRangeKernelKHR =
nullptr;
1079#if defined(cl_khr_command_buffer_mutable_dispatch)
1080CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clUpdateMutableCommandsKHR);
1081CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clGetMutableCommandInfoKHR);
1083CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clUpdateMutableCommandsKHR pfn_clUpdateMutableCommandsKHR =
nullptr;
1084CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clGetMutableCommandInfoKHR pfn_clGetMutableCommandInfoKHR =
nullptr;
1093template<
typename Functor,
typename T>
1094inline cl_int getInfoHelper(Functor f, cl_uint name, T* param,
long)
1096 return f(name,
sizeof(T), param,
nullptr);
1101template <
typename Func>
1102inline cl_int getInfoHelper(Func f, cl_uint name, vector<vector<unsigned char>>* param,
int)
1104 if (name != CL_PROGRAM_BINARIES) {
1105 return CL_INVALID_VALUE;
1109 size_type numBinaries = param->size();
1110 vector<unsigned char*> binariesPointers(numBinaries);
1112 for (size_type i = 0; i < numBinaries; ++i)
1114 binariesPointers[i] = (*param)[i].data();
1117 cl_int err = f(name, numBinaries *
sizeof(
unsigned char*), binariesPointers.data(),
nullptr);
1119 if (err != CL_SUCCESS) {
1129template <
typename Func,
typename T>
1130inline cl_int getInfoHelper(Func f, cl_uint name, vector<T>* param,
long)
1133 cl_int err = f(name, 0,
nullptr, &required);
1134 if (err != CL_SUCCESS) {
1137 const size_type elements = required /
sizeof(T);
1140 vector<T> localData(elements);
1141 err = f(name, required, localData.data(),
nullptr);
1142 if (err != CL_SUCCESS) {
1146 *param = std::move(localData);
1158template <
typename Func,
typename T>
1159inline cl_int getInfoHelper(
1160 Func f, cl_uint name, vector<T>* param,
int,
typename T::cl_type = 0)
1163 cl_int err = f(name, 0,
nullptr, &required);
1164 if (err != CL_SUCCESS) {
1168 const size_type elements = required /
sizeof(
typename T::cl_type);
1170 vector<typename T::cl_type> value(elements);
1171 err = f(name, required, value.data(),
nullptr);
1172 if (err != CL_SUCCESS) {
1178 param->resize(elements);
1182 for (size_type i = 0; i < elements; i++) {
1183 (*param)[i] = T(value[i],
true);
1190template <
typename Func>
1191inline cl_int getInfoHelper(Func f, cl_uint name,
string* param,
long)
1194 cl_int err = f(name, 0,
nullptr, &required);
1195 if (err != CL_SUCCESS) {
1202 vector<char> value(required);
1203 err = f(name, required, value.data(),
nullptr);
1204 if (err != CL_SUCCESS) {
1208 param->assign(begin(value), prev(end(value)));
1218template <
typename Func,
size_type N>
1219inline cl_int getInfoHelper(Func f, cl_uint name, array<size_type, N>* param,
long)
1222 cl_int err = f(name, 0,
nullptr, &required);
1223 if (err != CL_SUCCESS) {
1227 size_type elements = required /
sizeof(size_type);
1228 vector<size_type> value(elements, 0);
1230 err = f(name, required, value.data(),
nullptr);
1231 if (err != CL_SUCCESS) {
1240 for (size_type i = 0; i < elements; ++i) {
1241 (*param)[i] = value[i];
1247template<
typename T>
struct ReferenceHandler;
1255template<
typename Func,
typename T>
1256inline cl_int getInfoHelper(Func f, cl_uint name, T* param,
int,
typename T::cl_type = 0)
1258 typename T::cl_type value;
1259 cl_int err = f(name,
sizeof(value), &value,
nullptr);
1260 if (err != CL_SUCCESS) {
1264 if (value !=
nullptr)
1266 err = param->retain();
1267 if (err != CL_SUCCESS) {
1274#define CL_HPP_PARAM_NAME_INFO_1_0_(F) \
1275 F(cl_platform_info, CL_PLATFORM_PROFILE, string) \
1276 F(cl_platform_info, CL_PLATFORM_VERSION, string) \
1277 F(cl_platform_info, CL_PLATFORM_NAME, string) \
1278 F(cl_platform_info, CL_PLATFORM_VENDOR, string) \
1279 F(cl_platform_info, CL_PLATFORM_EXTENSIONS, string) \
1281 F(cl_device_info, CL_DEVICE_TYPE, cl_device_type) \
1282 F(cl_device_info, CL_DEVICE_VENDOR_ID, cl_uint) \
1283 F(cl_device_info, CL_DEVICE_MAX_COMPUTE_UNITS, cl_uint) \
1284 F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, cl_uint) \
1285 F(cl_device_info, CL_DEVICE_MAX_WORK_GROUP_SIZE, size_type) \
1286 F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_SIZES, cl::vector<size_type>) \
1287 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, cl_uint) \
1288 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT, cl_uint) \
1289 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT, cl_uint) \
1290 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG, cl_uint) \
1291 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT, cl_uint) \
1292 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, cl_uint) \
1293 F(cl_device_info, CL_DEVICE_MAX_CLOCK_FREQUENCY, cl_uint) \
1294 F(cl_device_info, CL_DEVICE_ADDRESS_BITS, cl_uint) \
1295 F(cl_device_info, CL_DEVICE_MAX_READ_IMAGE_ARGS, cl_uint) \
1296 F(cl_device_info, CL_DEVICE_MAX_WRITE_IMAGE_ARGS, cl_uint) \
1297 F(cl_device_info, CL_DEVICE_MAX_MEM_ALLOC_SIZE, cl_ulong) \
1298 F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_WIDTH, size_type) \
1299 F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_HEIGHT, size_type) \
1300 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_WIDTH, size_type) \
1301 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_HEIGHT, size_type) \
1302 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_DEPTH, size_type) \
1303 F(cl_device_info, CL_DEVICE_IMAGE_SUPPORT, cl_bool) \
1304 F(cl_device_info, CL_DEVICE_MAX_PARAMETER_SIZE, size_type) \
1305 F(cl_device_info, CL_DEVICE_MAX_SAMPLERS, cl_uint) \
1306 F(cl_device_info, CL_DEVICE_MEM_BASE_ADDR_ALIGN, cl_uint) \
1307 F(cl_device_info, CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE, cl_uint) \
1308 F(cl_device_info, CL_DEVICE_SINGLE_FP_CONFIG, cl_device_fp_config) \
1309 F(cl_device_info, CL_DEVICE_DOUBLE_FP_CONFIG, cl_device_fp_config) \
1310 F(cl_device_info, CL_DEVICE_HALF_FP_CONFIG, cl_device_fp_config) \
1311 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_TYPE, cl_device_mem_cache_type) \
1312 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE, cl_uint)\
1313 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_SIZE, cl_ulong) \
1314 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_SIZE, cl_ulong) \
1315 F(cl_device_info, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE, cl_ulong) \
1316 F(cl_device_info, CL_DEVICE_MAX_CONSTANT_ARGS, cl_uint) \
1317 F(cl_device_info, CL_DEVICE_LOCAL_MEM_TYPE, cl_device_local_mem_type) \
1318 F(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE, cl_ulong) \
1319 F(cl_device_info, CL_DEVICE_ERROR_CORRECTION_SUPPORT, cl_bool) \
1320 F(cl_device_info, CL_DEVICE_PROFILING_TIMER_RESOLUTION, size_type) \
1321 F(cl_device_info, CL_DEVICE_ENDIAN_LITTLE, cl_bool) \
1322 F(cl_device_info, CL_DEVICE_AVAILABLE, cl_bool) \
1323 F(cl_device_info, CL_DEVICE_COMPILER_AVAILABLE, cl_bool) \
1324 F(cl_device_info, CL_DEVICE_EXECUTION_CAPABILITIES, cl_device_exec_capabilities) \
1325 F(cl_device_info, CL_DEVICE_PLATFORM, cl_platform_id) \
1326 F(cl_device_info, CL_DEVICE_NAME, string) \
1327 F(cl_device_info, CL_DEVICE_VENDOR, string) \
1328 F(cl_device_info, CL_DRIVER_VERSION, string) \
1329 F(cl_device_info, CL_DEVICE_PROFILE, string) \
1330 F(cl_device_info, CL_DEVICE_VERSION, string) \
1331 F(cl_device_info, CL_DEVICE_EXTENSIONS, string) \
1333 F(cl_context_info, CL_CONTEXT_REFERENCE_COUNT, cl_uint) \
1334 F(cl_context_info, CL_CONTEXT_DEVICES, cl::vector<Device>) \
1335 F(cl_context_info, CL_CONTEXT_PROPERTIES, cl::vector<cl_context_properties>) \
1337 F(cl_event_info, CL_EVENT_COMMAND_QUEUE, cl::CommandQueue) \
1338 F(cl_event_info, CL_EVENT_COMMAND_TYPE, cl_command_type) \
1339 F(cl_event_info, CL_EVENT_REFERENCE_COUNT, cl_uint) \
1340 F(cl_event_info, CL_EVENT_COMMAND_EXECUTION_STATUS, cl_int) \
1342 F(cl_profiling_info, CL_PROFILING_COMMAND_QUEUED, cl_ulong) \
1343 F(cl_profiling_info, CL_PROFILING_COMMAND_SUBMIT, cl_ulong) \
1344 F(cl_profiling_info, CL_PROFILING_COMMAND_START, cl_ulong) \
1345 F(cl_profiling_info, CL_PROFILING_COMMAND_END, cl_ulong) \
1347 F(cl_mem_info, CL_MEM_TYPE, cl_mem_object_type) \
1348 F(cl_mem_info, CL_MEM_FLAGS, cl_mem_flags) \
1349 F(cl_mem_info, CL_MEM_SIZE, size_type) \
1350 F(cl_mem_info, CL_MEM_HOST_PTR, void*) \
1351 F(cl_mem_info, CL_MEM_MAP_COUNT, cl_uint) \
1352 F(cl_mem_info, CL_MEM_REFERENCE_COUNT, cl_uint) \
1353 F(cl_mem_info, CL_MEM_CONTEXT, cl::Context) \
1355 F(cl_image_info, CL_IMAGE_FORMAT, cl_image_format) \
1356 F(cl_image_info, CL_IMAGE_ELEMENT_SIZE, size_type) \
1357 F(cl_image_info, CL_IMAGE_ROW_PITCH, size_type) \
1358 F(cl_image_info, CL_IMAGE_SLICE_PITCH, size_type) \
1359 F(cl_image_info, CL_IMAGE_WIDTH, size_type) \
1360 F(cl_image_info, CL_IMAGE_HEIGHT, size_type) \
1361 F(cl_image_info, CL_IMAGE_DEPTH, size_type) \
1363 F(cl_sampler_info, CL_SAMPLER_REFERENCE_COUNT, cl_uint) \
1364 F(cl_sampler_info, CL_SAMPLER_CONTEXT, cl::Context) \
1365 F(cl_sampler_info, CL_SAMPLER_NORMALIZED_COORDS, cl_bool) \
1366 F(cl_sampler_info, CL_SAMPLER_ADDRESSING_MODE, cl_addressing_mode) \
1367 F(cl_sampler_info, CL_SAMPLER_FILTER_MODE, cl_filter_mode) \
1369 F(cl_program_info, CL_PROGRAM_REFERENCE_COUNT, cl_uint) \
1370 F(cl_program_info, CL_PROGRAM_CONTEXT, cl::Context) \
1371 F(cl_program_info, CL_PROGRAM_NUM_DEVICES, cl_uint) \
1372 F(cl_program_info, CL_PROGRAM_DEVICES, cl::vector<Device>) \
1373 F(cl_program_info, CL_PROGRAM_SOURCE, string) \
1374 F(cl_program_info, CL_PROGRAM_BINARY_SIZES, cl::vector<size_type>) \
1375 F(cl_program_info, CL_PROGRAM_BINARIES, cl::vector<cl::vector<unsigned char>>) \
1377 F(cl_program_build_info, CL_PROGRAM_BUILD_STATUS, cl_build_status) \
1378 F(cl_program_build_info, CL_PROGRAM_BUILD_OPTIONS, string) \
1379 F(cl_program_build_info, CL_PROGRAM_BUILD_LOG, string) \
1381 F(cl_kernel_info, CL_KERNEL_FUNCTION_NAME, string) \
1382 F(cl_kernel_info, CL_KERNEL_NUM_ARGS, cl_uint) \
1383 F(cl_kernel_info, CL_KERNEL_REFERENCE_COUNT, cl_uint) \
1384 F(cl_kernel_info, CL_KERNEL_CONTEXT, cl::Context) \
1385 F(cl_kernel_info, CL_KERNEL_PROGRAM, cl::Program) \
1387 F(cl_kernel_work_group_info, CL_KERNEL_WORK_GROUP_SIZE, size_type) \
1388 F(cl_kernel_work_group_info, CL_KERNEL_COMPILE_WORK_GROUP_SIZE, cl::detail::size_t_array) \
1389 F(cl_kernel_work_group_info, CL_KERNEL_LOCAL_MEM_SIZE, cl_ulong) \
1391 F(cl_command_queue_info, CL_QUEUE_CONTEXT, cl::Context) \
1392 F(cl_command_queue_info, CL_QUEUE_DEVICE, cl::Device) \
1393 F(cl_command_queue_info, CL_QUEUE_REFERENCE_COUNT, cl_uint) \
1394 F(cl_command_queue_info, CL_QUEUE_PROPERTIES, cl_command_queue_properties)
1397#define CL_HPP_PARAM_NAME_INFO_1_1_(F) \
1398 F(cl_context_info, CL_CONTEXT_NUM_DEVICES, cl_uint)\
1399 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF, cl_uint) \
1400 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR, cl_uint) \
1401 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT, cl_uint) \
1402 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_INT, cl_uint) \
1403 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG, cl_uint) \
1404 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT, cl_uint) \
1405 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE, cl_uint) \
1406 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF, cl_uint) \
1407 F(cl_device_info, CL_DEVICE_OPENCL_C_VERSION, string) \
1409 F(cl_mem_info, CL_MEM_ASSOCIATED_MEMOBJECT, cl::Memory) \
1410 F(cl_mem_info, CL_MEM_OFFSET, size_type) \
1412 F(cl_kernel_work_group_info, CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, size_type) \
1413 F(cl_kernel_work_group_info, CL_KERNEL_PRIVATE_MEM_SIZE, cl_ulong) \
1415 F(cl_event_info, CL_EVENT_CONTEXT, cl::Context)
1417#define CL_HPP_PARAM_NAME_INFO_1_2_(F) \
1418 F(cl_program_info, CL_PROGRAM_NUM_KERNELS, size_type) \
1419 F(cl_program_info, CL_PROGRAM_KERNEL_NAMES, string) \
1421 F(cl_program_build_info, CL_PROGRAM_BINARY_TYPE, cl_program_binary_type) \
1423 F(cl_kernel_info, CL_KERNEL_ATTRIBUTES, string) \
1425 F(cl_kernel_arg_info, CL_KERNEL_ARG_ADDRESS_QUALIFIER, cl_kernel_arg_address_qualifier) \
1426 F(cl_kernel_arg_info, CL_KERNEL_ARG_ACCESS_QUALIFIER, cl_kernel_arg_access_qualifier) \
1427 F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_NAME, string) \
1428 F(cl_kernel_arg_info, CL_KERNEL_ARG_NAME, string) \
1429 F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_QUALIFIER, cl_kernel_arg_type_qualifier) \
1431 F(cl_kernel_work_group_info, CL_KERNEL_GLOBAL_WORK_SIZE, cl::detail::size_t_array) \
1433 F(cl_device_info, CL_DEVICE_LINKER_AVAILABLE, cl_bool) \
1434 F(cl_device_info, CL_DEVICE_IMAGE_MAX_BUFFER_SIZE, size_type) \
1435 F(cl_device_info, CL_DEVICE_IMAGE_MAX_ARRAY_SIZE, size_type) \
1436 F(cl_device_info, CL_DEVICE_PARENT_DEVICE, cl::Device) \
1437 F(cl_device_info, CL_DEVICE_PARTITION_MAX_SUB_DEVICES, cl_uint) \
1438 F(cl_device_info, CL_DEVICE_PARTITION_PROPERTIES, cl::vector<cl_device_partition_property>) \
1439 F(cl_device_info, CL_DEVICE_PARTITION_TYPE, cl::vector<cl_device_partition_property>) \
1440 F(cl_device_info, CL_DEVICE_REFERENCE_COUNT, cl_uint) \
1441 F(cl_device_info, CL_DEVICE_PREFERRED_INTEROP_USER_SYNC, cl_bool) \
1442 F(cl_device_info, CL_DEVICE_PARTITION_AFFINITY_DOMAIN, cl_device_affinity_domain) \
1443 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS, string) \
1444 F(cl_device_info, CL_DEVICE_PRINTF_BUFFER_SIZE, size_type) \
1446 F(cl_image_info, CL_IMAGE_ARRAY_SIZE, size_type) \
1447 F(cl_image_info, CL_IMAGE_NUM_MIP_LEVELS, cl_uint) \
1448 F(cl_image_info, CL_IMAGE_NUM_SAMPLES, cl_uint)
1450#define CL_HPP_PARAM_NAME_INFO_2_0_(F) \
1451 F(cl_device_info, CL_DEVICE_QUEUE_ON_HOST_PROPERTIES, cl_command_queue_properties) \
1452 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES, cl_command_queue_properties) \
1453 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE, cl_uint) \
1454 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE, cl_uint) \
1455 F(cl_device_info, CL_DEVICE_MAX_ON_DEVICE_QUEUES, cl_uint) \
1456 F(cl_device_info, CL_DEVICE_MAX_ON_DEVICE_EVENTS, cl_uint) \
1457 F(cl_device_info, CL_DEVICE_MAX_PIPE_ARGS, cl_uint) \
1458 F(cl_device_info, CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS, cl_uint) \
1459 F(cl_device_info, CL_DEVICE_PIPE_MAX_PACKET_SIZE, cl_uint) \
1460 F(cl_device_info, CL_DEVICE_SVM_CAPABILITIES, cl_device_svm_capabilities) \
1461 F(cl_device_info, CL_DEVICE_PREFERRED_PLATFORM_ATOMIC_ALIGNMENT, cl_uint) \
1462 F(cl_device_info, CL_DEVICE_PREFERRED_GLOBAL_ATOMIC_ALIGNMENT, cl_uint) \
1463 F(cl_device_info, CL_DEVICE_PREFERRED_LOCAL_ATOMIC_ALIGNMENT, cl_uint) \
1464 F(cl_device_info, CL_DEVICE_IMAGE_PITCH_ALIGNMENT, cl_uint) \
1465 F(cl_device_info, CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT, cl_uint) \
1466 F(cl_device_info, CL_DEVICE_MAX_READ_WRITE_IMAGE_ARGS, cl_uint ) \
1467 F(cl_device_info, CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE, size_type ) \
1468 F(cl_device_info, CL_DEVICE_GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE, size_type ) \
1469 F(cl_profiling_info, CL_PROFILING_COMMAND_COMPLETE, cl_ulong) \
1470 F(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM, cl_bool) \
1471 F(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_SVM_PTRS, void**) \
1472 F(cl_command_queue_info, CL_QUEUE_SIZE, cl_uint) \
1473 F(cl_mem_info, CL_MEM_USES_SVM_POINTER, cl_bool) \
1474 F(cl_program_build_info, CL_PROGRAM_BUILD_GLOBAL_VARIABLE_TOTAL_SIZE, size_type) \
1475 F(cl_pipe_info, CL_PIPE_PACKET_SIZE, cl_uint) \
1476 F(cl_pipe_info, CL_PIPE_MAX_PACKETS, cl_uint)
1478#define CL_HPP_PARAM_NAME_INFO_SUBGROUP_KHR_(F) \
1479 F(cl_kernel_sub_group_info, CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE_KHR, size_type) \
1480 F(cl_kernel_sub_group_info, CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE_KHR, size_type)
1482#define CL_HPP_PARAM_NAME_INFO_IL_KHR_(F) \
1483 F(cl_device_info, CL_DEVICE_IL_VERSION_KHR, string) \
1484 F(cl_program_info, CL_PROGRAM_IL_KHR, cl::vector<unsigned char>)
1486#define CL_HPP_PARAM_NAME_INFO_2_1_(F) \
1487 F(cl_platform_info, CL_PLATFORM_HOST_TIMER_RESOLUTION, cl_ulong) \
1488 F(cl_program_info, CL_PROGRAM_IL, cl::vector<unsigned char>) \
1489 F(cl_device_info, CL_DEVICE_MAX_NUM_SUB_GROUPS, cl_uint) \
1490 F(cl_device_info, CL_DEVICE_IL_VERSION, string) \
1491 F(cl_device_info, CL_DEVICE_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS, cl_bool) \
1492 F(cl_command_queue_info, CL_QUEUE_DEVICE_DEFAULT, cl::DeviceCommandQueue) \
1493 F(cl_kernel_sub_group_info, CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE, size_type) \
1494 F(cl_kernel_sub_group_info, CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE, size_type) \
1495 F(cl_kernel_sub_group_info, CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT, cl::detail::size_t_array) \
1496 F(cl_kernel_sub_group_info, CL_KERNEL_MAX_NUM_SUB_GROUPS, size_type) \
1497 F(cl_kernel_sub_group_info, CL_KERNEL_COMPILE_NUM_SUB_GROUPS, size_type)
1499#define CL_HPP_PARAM_NAME_INFO_2_2_(F) \
1500 F(cl_program_info, CL_PROGRAM_SCOPE_GLOBAL_CTORS_PRESENT, cl_bool) \
1501 F(cl_program_info, CL_PROGRAM_SCOPE_GLOBAL_DTORS_PRESENT, cl_bool)
1503#define CL_HPP_PARAM_NAME_DEVICE_FISSION_EXT_(F) \
1504 F(cl_device_info, CL_DEVICE_PARENT_DEVICE_EXT, cl::Device) \
1505 F(cl_device_info, CL_DEVICE_PARTITION_TYPES_EXT, cl::vector<cl_device_partition_property_ext>) \
1506 F(cl_device_info, CL_DEVICE_AFFINITY_DOMAINS_EXT, cl::vector<cl_device_partition_property_ext>) \
1507 F(cl_device_info, CL_DEVICE_REFERENCE_COUNT_EXT , cl_uint) \
1508 F(cl_device_info, CL_DEVICE_PARTITION_STYLE_EXT, cl::vector<cl_device_partition_property_ext>)
1510#define CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_CL3_SHARED_(F) \
1511 F(cl_platform_info, CL_PLATFORM_NUMERIC_VERSION_KHR, cl_version_khr) \
1512 F(cl_platform_info, CL_PLATFORM_EXTENSIONS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>) \
1514 F(cl_device_info, CL_DEVICE_NUMERIC_VERSION_KHR, cl_version_khr) \
1515 F(cl_device_info, CL_DEVICE_EXTENSIONS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>) \
1516 F(cl_device_info, CL_DEVICE_ILS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>) \
1517 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>)
1519#define CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_KHRONLY_(F) \
1520 F(cl_device_info, CL_DEVICE_OPENCL_C_NUMERIC_VERSION_KHR, cl_version_khr)
1522#define CL_HPP_PARAM_NAME_CL_KHR_SEMAPHORE_(F) \
1523 F(cl_semaphore_info_khr, CL_SEMAPHORE_PROPERTIES_KHR, cl::vector<cl_semaphore_properties_khr>) \
1524 F(cl_platform_info, CL_PLATFORM_SEMAPHORE_TYPES_KHR, cl::vector<cl_semaphore_type_khr>) \
1525 F(cl_device_info, CL_DEVICE_SEMAPHORE_TYPES_KHR, cl::vector<cl_semaphore_type_khr>) \
1527#define CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_MEMORY_(F) \
1528 F(cl_device_info, CL_DEVICE_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR, cl::vector<cl::ExternalMemoryType>) \
1529 F(cl_platform_info, CL_PLATFORM_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR, cl::vector<cl::ExternalMemoryType>)
1531#define CL_HPP_PARAM_NAME_INFO_3_0_(F) \
1532 F(cl_platform_info, CL_PLATFORM_NUMERIC_VERSION, cl_version) \
1533 F(cl_platform_info, CL_PLATFORM_EXTENSIONS_WITH_VERSION, cl::vector<cl_name_version>) \
1535 F(cl_device_info, CL_DEVICE_NUMERIC_VERSION, cl_version) \
1536 F(cl_device_info, CL_DEVICE_EXTENSIONS_WITH_VERSION, cl::vector<cl_name_version>) \
1537 F(cl_device_info, CL_DEVICE_ILS_WITH_VERSION, cl::vector<cl_name_version>) \
1538 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS_WITH_VERSION, cl::vector<cl_name_version>) \
1539 F(cl_device_info, CL_DEVICE_ATOMIC_MEMORY_CAPABILITIES, cl_device_atomic_capabilities) \
1540 F(cl_device_info, CL_DEVICE_ATOMIC_FENCE_CAPABILITIES, cl_device_atomic_capabilities) \
1541 F(cl_device_info, CL_DEVICE_NON_UNIFORM_WORK_GROUP_SUPPORT, cl_bool) \
1542 F(cl_device_info, CL_DEVICE_OPENCL_C_ALL_VERSIONS, cl::vector<cl_name_version>) \
1543 F(cl_device_info, CL_DEVICE_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, size_type) \
1544 F(cl_device_info, CL_DEVICE_WORK_GROUP_COLLECTIVE_FUNCTIONS_SUPPORT, cl_bool) \
1545 F(cl_device_info, CL_DEVICE_GENERIC_ADDRESS_SPACE_SUPPORT, cl_bool) \
1546 F(cl_device_info, CL_DEVICE_OPENCL_C_FEATURES, cl::vector<cl_name_version>) \
1547 F(cl_device_info, CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES, cl_device_device_enqueue_capabilities) \
1548 F(cl_device_info, CL_DEVICE_PIPE_SUPPORT, cl_bool) \
1549 F(cl_device_info, CL_DEVICE_LATEST_CONFORMANCE_VERSION_PASSED, string) \
1551 F(cl_command_queue_info, CL_QUEUE_PROPERTIES_ARRAY, cl::vector<cl_queue_properties>) \
1552 F(cl_mem_info, CL_MEM_PROPERTIES, cl::vector<cl_mem_properties>) \
1553 F(cl_pipe_info, CL_PIPE_PROPERTIES, cl::vector<cl_pipe_properties>) \
1554 F(cl_sampler_info, CL_SAMPLER_PROPERTIES, cl::vector<cl_sampler_properties>) \
1556template <
typename enum_type, cl_
int Name>
1559#define CL_HPP_DECLARE_PARAM_TRAITS_(token, param_name, T) \
1562struct param_traits<detail:: token,param_name> \
1564 enum { value = param_name }; \
1565 typedef T param_type; \
1568CL_HPP_PARAM_NAME_INFO_1_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1569#if CL_HPP_TARGET_OPENCL_VERSION >= 110
1570CL_HPP_PARAM_NAME_INFO_1_1_(CL_HPP_DECLARE_PARAM_TRAITS_)
1572#if CL_HPP_TARGET_OPENCL_VERSION >= 120
1573CL_HPP_PARAM_NAME_INFO_1_2_(CL_HPP_DECLARE_PARAM_TRAITS_)
1575#if CL_HPP_TARGET_OPENCL_VERSION >= 200
1576CL_HPP_PARAM_NAME_INFO_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1578#if CL_HPP_TARGET_OPENCL_VERSION >= 210
1579CL_HPP_PARAM_NAME_INFO_2_1_(CL_HPP_DECLARE_PARAM_TRAITS_)
1581#if CL_HPP_TARGET_OPENCL_VERSION >= 220
1582CL_HPP_PARAM_NAME_INFO_2_2_(CL_HPP_DECLARE_PARAM_TRAITS_)
1584#if CL_HPP_TARGET_OPENCL_VERSION >= 300
1585CL_HPP_PARAM_NAME_INFO_3_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1588#if defined(cl_khr_subgroups) && CL_HPP_TARGET_OPENCL_VERSION < 210
1589CL_HPP_PARAM_NAME_INFO_SUBGROUP_KHR_(CL_HPP_DECLARE_PARAM_TRAITS_)
1592#if defined(cl_khr_il_program) && CL_HPP_TARGET_OPENCL_VERSION < 210
1593CL_HPP_PARAM_NAME_INFO_IL_KHR_(CL_HPP_DECLARE_PARAM_TRAITS_)
1598#define CL_HPP_PARAM_NAME_INFO_1_0_DEPRECATED_IN_2_0_(F) \
1599 F(cl_device_info, CL_DEVICE_QUEUE_PROPERTIES, cl_command_queue_properties)
1601#define CL_HPP_PARAM_NAME_INFO_1_1_DEPRECATED_IN_2_0_(F) \
1602 F(cl_device_info, CL_DEVICE_HOST_UNIFIED_MEMORY, cl_bool)
1604#define CL_HPP_PARAM_NAME_INFO_1_2_DEPRECATED_IN_2_0_(F) \
1605 F(cl_image_info, CL_IMAGE_BUFFER, cl::Buffer)
1609#if CL_HPP_TARGET_OPENCL_VERSION > 100 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 && CL_HPP_TARGET_OPENCL_VERSION < 200
1610CL_HPP_PARAM_NAME_INFO_1_0_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1612#if CL_HPP_TARGET_OPENCL_VERSION > 110 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
1613CL_HPP_PARAM_NAME_INFO_1_1_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1615#if CL_HPP_TARGET_OPENCL_VERSION > 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
1616CL_HPP_PARAM_NAME_INFO_1_2_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1619#if defined(cl_ext_device_fission)
1620CL_HPP_PARAM_NAME_DEVICE_FISSION_EXT_(CL_HPP_DECLARE_PARAM_TRAITS_)
1623#if defined(cl_khr_extended_versioning)
1624#if CL_HPP_TARGET_OPENCL_VERSION < 300
1625CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_CL3_SHARED_(CL_HPP_DECLARE_PARAM_TRAITS_)
1627CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_KHRONLY_(CL_HPP_DECLARE_PARAM_TRAITS_)
1630#if defined(cl_khr_semaphore)
1631CL_HPP_PARAM_NAME_CL_KHR_SEMAPHORE_(CL_HPP_DECLARE_PARAM_TRAITS_)
1634#ifdef cl_khr_external_memory
1635CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_MEMORY_(CL_HPP_DECLARE_PARAM_TRAITS_)
1638#if defined(cl_khr_device_uuid)
1639using uuid_array = array<cl_uchar, CL_UUID_SIZE_KHR>;
1640using luid_array = array<cl_uchar, CL_LUID_SIZE_KHR>;
1641CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_UUID_KHR, uuid_array)
1642CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DRIVER_UUID_KHR, uuid_array)
1643CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LUID_VALID_KHR, cl_bool)
1644CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LUID_KHR, luid_array)
1645CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_NODE_MASK_KHR, cl_uint)
1648#if defined(cl_khr_pci_bus_info)
1649CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_PCI_BUS_INFO_KHR, cl_device_pci_bus_info_khr)
1653#if CL_HPP_TARGET_OPENCL_VERSION < 200
1654#if defined(CL_DEVICE_IMAGE_PITCH_ALIGNMENT_KHR)
1655CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_IMAGE_PITCH_ALIGNMENT_KHR, cl_uint)
1657#if defined(CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT_KHR)
1658CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT_KHR, cl_uint)
1662#if defined(cl_khr_integer_dot_product)
1663CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGER_DOT_PRODUCT_CAPABILITIES_KHR, cl_device_integer_dot_product_capabilities_khr)
1664#if defined(CL_DEVICE_INTEGER_DOT_PRODUCT_ACCELERATION_PROPERTIES_8BIT_KHR)
1665CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGER_DOT_PRODUCT_ACCELERATION_PROPERTIES_8BIT_KHR, cl_device_integer_dot_product_acceleration_properties_khr)
1666CL_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)
1670#ifdef CL_PLATFORM_ICD_SUFFIX_KHR
1671CL_HPP_DECLARE_PARAM_TRAITS_(cl_platform_info, CL_PLATFORM_ICD_SUFFIX_KHR,
string)
1674#ifdef CL_DEVICE_PROFILING_TIMER_OFFSET_AMD
1675CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_PROFILING_TIMER_OFFSET_AMD, cl_ulong)
1677#ifdef CL_DEVICE_GLOBAL_FREE_MEMORY_AMD
1678CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_FREE_MEMORY_AMD, vector<size_type>)
1680#ifdef CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD
1681CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD, cl_uint)
1683#ifdef CL_DEVICE_SIMD_WIDTH_AMD
1684CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_WIDTH_AMD, cl_uint)
1686#ifdef CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD
1687CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD, cl_uint)
1689#ifdef CL_DEVICE_WAVEFRONT_WIDTH_AMD
1690CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_WAVEFRONT_WIDTH_AMD, cl_uint)
1692#ifdef CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD
1693CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD, cl_uint)
1695#ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD
1696CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD, cl_uint)
1698#ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD
1699CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD, cl_uint)
1701#ifdef CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD
1702CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD, cl_uint)
1704#ifdef CL_DEVICE_LOCAL_MEM_BANKS_AMD
1705CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LOCAL_MEM_BANKS_AMD, cl_uint)
1707#ifdef CL_DEVICE_BOARD_NAME_AMD
1708CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_BOARD_NAME_AMD,
string)
1711#ifdef CL_DEVICE_COMPUTE_UNITS_BITFIELD_ARM
1712CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_UNITS_BITFIELD_ARM, cl_ulong)
1714#ifdef CL_DEVICE_JOB_SLOTS_ARM
1715CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_JOB_SLOTS_ARM, cl_uint)
1717#ifdef CL_DEVICE_SCHEDULING_CONTROLS_CAPABILITIES_ARM
1718CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SCHEDULING_CONTROLS_CAPABILITIES_ARM, cl_bitfield)
1720#ifdef CL_DEVICE_SUPPORTED_REGISTER_ALLOCATIONS_ARM
1721CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SUPPORTED_REGISTER_ALLOCATIONS_ARM, vector<cl_uint>)
1723#ifdef CL_DEVICE_MAX_WARP_COUNT_ARM
1724CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_MAX_WARP_COUNT_ARM, cl_uint)
1726#ifdef CL_KERNEL_MAX_WARP_COUNT_ARM
1727CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_info, CL_KERNEL_MAX_WARP_COUNT_ARM, cl_uint)
1729#ifdef CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_ARM
1730CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_ARM, cl_uint)
1732#ifdef CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_MODIFIER_ARM
1733CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_MODIFIER_ARM, cl_int)
1735#ifdef CL_KERNEL_EXEC_INFO_WARP_COUNT_LIMIT_ARM
1736CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_WARP_COUNT_LIMIT_ARM, cl_uint)
1738#ifdef CL_KERNEL_EXEC_INFO_COMPUTE_UNIT_MAX_QUEUED_BATCHES_ARM
1739CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_COMPUTE_UNIT_MAX_QUEUED_BATCHES_ARM, cl_uint)
1742#ifdef CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV
1743CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV, cl_uint)
1745#ifdef CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV
1746CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV, cl_uint)
1748#ifdef CL_DEVICE_REGISTERS_PER_BLOCK_NV
1749CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_REGISTERS_PER_BLOCK_NV, cl_uint)
1751#ifdef CL_DEVICE_WARP_SIZE_NV
1752CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_WARP_SIZE_NV, cl_uint)
1754#ifdef CL_DEVICE_GPU_OVERLAP_NV
1755CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GPU_OVERLAP_NV, cl_bool)
1757#ifdef CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV
1758CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV, cl_bool)
1760#ifdef CL_DEVICE_INTEGRATED_MEMORY_NV
1761CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGRATED_MEMORY_NV, cl_bool)
1764#if defined(cl_khr_command_buffer)
1765CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMMAND_BUFFER_CAPABILITIES_KHR, cl_device_command_buffer_capabilities_khr)
1766CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMMAND_BUFFER_REQUIRED_QUEUE_PROPERTIES_KHR, cl_command_buffer_properties_khr)
1767CL_HPP_DECLARE_PARAM_TRAITS_(cl_command_buffer_info_khr, CL_COMMAND_BUFFER_QUEUES_KHR, cl::vector<CommandQueue>)
1768CL_HPP_DECLARE_PARAM_TRAITS_(cl_command_buffer_info_khr, CL_COMMAND_BUFFER_NUM_QUEUES_KHR, cl_uint)
1769CL_HPP_DECLARE_PARAM_TRAITS_(cl_command_buffer_info_khr, CL_COMMAND_BUFFER_REFERENCE_COUNT_KHR, cl_uint)
1770CL_HPP_DECLARE_PARAM_TRAITS_(cl_command_buffer_info_khr, CL_COMMAND_BUFFER_STATE_KHR, cl_command_buffer_state_khr)
1771CL_HPP_DECLARE_PARAM_TRAITS_(cl_command_buffer_info_khr, CL_COMMAND_BUFFER_PROPERTIES_ARRAY_KHR, cl::vector<cl_command_buffer_properties_khr>)
1774#if defined(cl_khr_command_buffer_mutable_dispatch)
1775CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_COMMAND_COMMAND_QUEUE_KHR,
CommandQueue)
1776CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_COMMAND_COMMAND_BUFFER_KHR, CommandBufferKhr)
1777CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_COMMAND_COMMAND_TYPE_KHR, cl_command_type)
1778CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_DISPATCH_PROPERTIES_ARRAY_KHR, cl::vector<cl_ndrange_kernel_command_properties_khr>)
1779CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_DISPATCH_KERNEL_KHR, cl_kernel)
1780CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_DISPATCH_DIMENSIONS_KHR, cl_uint)
1781CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_DISPATCH_GLOBAL_WORK_OFFSET_KHR, cl::vector<size_type>)
1782CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_DISPATCH_GLOBAL_WORK_SIZE_KHR, cl::vector<size_type>)
1783CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_DISPATCH_LOCAL_WORK_SIZE_KHR, cl::vector<size_type>)
1788template <
typename Func,
typename T>
1790getInfo(Func f, cl_uint name, T* param)
1792 return getInfoHelper(f, name, param, 0);
1795template <
typename Func,
typename Arg0>
1798 Func f_;
const Arg0& arg0_;
1800 cl_uint param, size_type size,
void* value, size_type* size_ret)
1801 {
return f_(arg0_, param, size, value, size_ret); }
1804template <
typename Func,
typename Arg0,
typename Arg1>
1807 Func f_;
const Arg0& arg0_;
const Arg1& arg1_;
1809 cl_uint param, size_type size,
void* value, size_type* size_ret)
1810 {
return f_(arg0_, arg1_, param, size, value, size_ret); }
1813template <
typename Func,
typename Arg0,
typename T>
1815getInfo(Func f,
const Arg0& arg0, cl_uint name, T* param)
1818 return getInfoHelper(f0, name, param, 0);
1821template <
typename Func,
typename Arg0,
typename Arg1,
typename T>
1823getInfo(Func f,
const Arg0& arg0,
const Arg1& arg1, cl_uint name, T* param)
1825 GetInfoFunctor1<Func, Arg0, Arg1> f0 = { f, arg0, arg1 };
1826 return getInfoHelper(f0, name, param, 0);
1834#if CL_HPP_TARGET_OPENCL_VERSION >= 120
1851 { return ::clRetainDevice(device); }
1862 { return ::clReleaseDevice(device); }
1869struct ReferenceHandler<cl_device_id>
1872 static cl_int retain(cl_device_id)
1873 {
return CL_SUCCESS; }
1875 static cl_int release(cl_device_id)
1876 {
return CL_SUCCESS; }
1884 static cl_int retain(cl_platform_id)
1885 {
return CL_SUCCESS; }
1887 static cl_int release(cl_platform_id)
1888 {
return CL_SUCCESS; }
1894 static cl_int retain(cl_context context)
1895 { return ::clRetainContext(context); }
1896 static cl_int release(cl_context context)
1897 { return ::clReleaseContext(context); }
1903 static cl_int retain(cl_command_queue queue)
1904 { return ::clRetainCommandQueue(queue); }
1905 static cl_int release(cl_command_queue queue)
1906 { return ::clReleaseCommandQueue(queue); }
1912 static cl_int retain(cl_mem memory)
1913 { return ::clRetainMemObject(memory); }
1914 static cl_int release(cl_mem memory)
1915 { return ::clReleaseMemObject(memory); }
1921 static cl_int retain(cl_sampler sampler)
1922 { return ::clRetainSampler(sampler); }
1923 static cl_int release(cl_sampler sampler)
1924 { return ::clReleaseSampler(sampler); }
1930 static cl_int retain(cl_program program)
1931 { return ::clRetainProgram(program); }
1932 static cl_int release(cl_program program)
1933 { return ::clReleaseProgram(program); }
1939 static cl_int retain(cl_kernel kernel)
1940 { return ::clRetainKernel(kernel); }
1941 static cl_int release(cl_kernel kernel)
1942 { return ::clReleaseKernel(kernel); }
1948 static cl_int retain(cl_event event)
1949 { return ::clRetainEvent(event); }
1950 static cl_int release(cl_event event)
1951 { return ::clReleaseEvent(event); }
1954#ifdef cl_khr_semaphore
1958 static cl_int retain(cl_semaphore_khr semaphore)
1960 if (pfn_clRetainSemaphoreKHR !=
nullptr) {
1961 return pfn_clRetainSemaphoreKHR(semaphore);
1964 return CL_INVALID_OPERATION;
1967 static cl_int release(cl_semaphore_khr semaphore)
1969 if (pfn_clReleaseSemaphoreKHR !=
nullptr) {
1970 return pfn_clReleaseSemaphoreKHR(semaphore);
1973 return CL_INVALID_OPERATION;
1977#if defined(cl_khr_command_buffer)
1979struct ReferenceHandler<cl_command_buffer_khr>
1981 static cl_int retain(cl_command_buffer_khr cmdBufferKhr)
1983 if (pfn_clRetainCommandBufferKHR ==
nullptr) {
1984 return detail::errHandler(CL_INVALID_OPERATION, __RETAIN_COMMAND_BUFFER_KHR_ERR);
1986 return pfn_clRetainCommandBufferKHR(cmdBufferKhr);
1989 static cl_int release(cl_command_buffer_khr cmdBufferKhr)
1991 if (pfn_clReleaseCommandBufferKHR ==
nullptr) {
1992 return detail::errHandler(CL_INVALID_OPERATION, __RELEASE_COMMAND_BUFFER_KHR_ERR);
1994 return pfn_clReleaseCommandBufferKHR(cmdBufferKhr);
1999struct ReferenceHandler<cl_mutable_command_khr>
2002 static cl_int retain(cl_mutable_command_khr)
2003 {
return CL_SUCCESS; }
2005 static cl_int release(cl_mutable_command_khr)
2006 {
return CL_SUCCESS; }
2011#if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
2013static cl_uint getVersion(
const vector<char> &versionInfo)
2015 int highVersion = 0;
2018 while(versionInfo[index] !=
'.' ) {
2020 highVersion += versionInfo[index]-
'0';
2024 while(versionInfo[index] !=
' ' && versionInfo[index] !=
'\0') {
2026 lowVersion += versionInfo[index]-
'0';
2029 return (highVersion << 16) | lowVersion;
2032static cl_uint getPlatformVersion(cl_platform_id platform)
2035 clGetPlatformInfo(platform, CL_PLATFORM_VERSION, 0,
nullptr, &size);
2037 vector<char> versionInfo(size);
2038 clGetPlatformInfo(platform, CL_PLATFORM_VERSION, size, versionInfo.data(), &size);
2039 return getVersion(versionInfo);
2042static cl_uint getDevicePlatformVersion(cl_device_id device)
2044 cl_platform_id platform;
2045 clGetDeviceInfo(device, CL_DEVICE_PLATFORM,
sizeof(platform), &platform,
nullptr);
2046 return getPlatformVersion(platform);
2049static cl_uint getContextPlatformVersion(cl_context context)
2054 clGetContextInfo(context, CL_CONTEXT_DEVICES, 0,
nullptr, &size);
2057 vector<cl_device_id> devices(size/
sizeof(cl_device_id));
2058 clGetContextInfo(context, CL_CONTEXT_DEVICES, size, devices.data(),
nullptr);
2059 return getDevicePlatformVersion(devices[0]);
2063template <
typename T>
2073 Wrapper() : object_(
nullptr) { }
2075 Wrapper(
const cl_type &obj,
bool retainObject) : object_(obj)
2078 detail::errHandler(retain(), __RETAIN_ERR);
2084 if (object_ !=
nullptr) { release(); }
2089 object_ = rhs.object_;
2090 detail::errHandler(retain(), __RETAIN_ERR);
2095 object_ = rhs.object_;
2096 rhs.object_ =
nullptr;
2102 detail::errHandler(release(), __RELEASE_ERR);
2103 object_ = rhs.object_;
2104 detail::errHandler(retain(), __RETAIN_ERR);
2112 detail::errHandler(release(), __RELEASE_ERR);
2113 object_ = rhs.object_;
2114 rhs.object_ =
nullptr;
2121 detail::errHandler(release(), __RELEASE_ERR);
2126 const cl_type& operator ()()
const {
return object_; }
2128 cl_type& operator ()() {
return object_; }
2130 cl_type get()
const {
return object_; }
2133 template<
typename Func,
typename U>
2134 friend inline cl_int getInfoHelper(Func, cl_uint, U*,
int,
typename U::cl_type);
2136 cl_int retain()
const
2138 if (object_ !=
nullptr) {
2146 cl_int release()
const
2148 if (object_ !=
nullptr) {
2161 typedef cl_device_id cl_type;
2165 bool referenceCountable_;
2167 static bool isReferenceCountable(cl_device_id device)
2169 bool retVal =
false;
2170#if CL_HPP_TARGET_OPENCL_VERSION >= 120
2171#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
2172 if (device !=
nullptr) {
2173 int version = getDevicePlatformVersion(device);
2174 if(version > ((1 << 16) + 1)) {
2187 Wrapper() : object_(
nullptr), referenceCountable_(
false)
2191 Wrapper(
const cl_type &obj,
bool retainObject) :
2193 referenceCountable_(
false)
2195 referenceCountable_ = isReferenceCountable(obj);
2198 detail::errHandler(retain(), __RETAIN_ERR);
2209 object_ = rhs.object_;
2210 referenceCountable_ = isReferenceCountable(object_);
2211 detail::errHandler(retain(), __RETAIN_ERR);
2216 object_ = rhs.object_;
2217 referenceCountable_ = rhs.referenceCountable_;
2218 rhs.object_ =
nullptr;
2219 rhs.referenceCountable_ =
false;
2225 detail::errHandler(release(), __RELEASE_ERR);
2226 object_ = rhs.object_;
2227 referenceCountable_ = rhs.referenceCountable_;
2228 detail::errHandler(retain(), __RETAIN_ERR);
2236 detail::errHandler(release(), __RELEASE_ERR);
2237 object_ = rhs.object_;
2238 referenceCountable_ = rhs.referenceCountable_;
2239 rhs.object_ =
nullptr;
2240 rhs.referenceCountable_ =
false;
2247 detail::errHandler(release(), __RELEASE_ERR);
2249 referenceCountable_ = isReferenceCountable(object_);
2253 const cl_type& operator ()()
const {
return object_; }
2255 cl_type& operator ()() {
return object_; }
2257 cl_type get()
const {
return object_; }
2260 template<
typename Func,
typename U>
2261 friend inline cl_int getInfoHelper(Func, cl_uint, U*,
int,
typename U::cl_type);
2263 template<
typename Func,
typename U>
2264 friend inline cl_int getInfoHelper(Func, cl_uint, vector<U>*,
int,
typename U::cl_type);
2266 cl_int retain()
const
2268 if( object_ !=
nullptr && referenceCountable_ ) {
2276 cl_int release()
const
2278 if (object_ !=
nullptr && referenceCountable_) {
2287template <
typename T>
2290 return lhs() == rhs();
2293template <
typename T>
2294inline bool operator!=(
const Wrapper<T> &lhs,
const Wrapper<T> &rhs)
2296 return !operator==(lhs, rhs);
2319 image_channel_order = order;
2320 image_channel_data_type = type;
2330 this->image_channel_data_type = rhs.image_channel_data_type;
2331 this->image_channel_order = rhs.image_channel_order;
2347 static std::once_flag default_initialized_;
2349 static cl_int default_error_;
2356 static void makeDefault();
2363 static void makeDefaultProvided(
const Device &p) {
2368#ifdef CL_HPP_UNIT_TEST_ENABLE
2375 static void unitTestClearDefault() {
2387 explicit Device(
const cl_device_id &device,
bool retainObject =
false) :
2388 detail::Wrapper<cl_type>(device, retainObject) { }
2395 cl_int *errResult =
nullptr)
2397 std::call_once(default_initialized_, makeDefault);
2398 detail::errHandler(default_error_);
2399 if (errResult !=
nullptr) {
2400 *errResult = default_error_;
2414 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_device));
2415 detail::errHandler(default_error_);
2431 template <
typename T>
2432 cl_int
getInfo(cl_device_info name, T* param)
const
2434 return detail::errHandler(
2435 detail::getInfo(&::clGetDeviceInfo, object_, name, param),
2436 __GET_DEVICE_INFO_ERR);
2440 template <cl_device_info name>
typename
2445 detail::cl_device_info, name>::param_type param;
2446 cl_int result =
getInfo(name, ¶m);
2447 if (err !=
nullptr) {
2453#if CL_HPP_TARGET_OPENCL_VERSION >= 210
2462 cl_ulong retVal = 0;
2464 clGetHostTimer(this->get(), &retVal);
2467 __GET_HOST_TIMER_ERR);
2486 std::pair<cl_ulong, cl_ulong> retVal;
2488 clGetDeviceAndHostTimer(this->get(), &(retVal.first), &(retVal.second));
2491 __GET_DEVICE_AND_HOST_TIMER_ERR);
2499#if CL_HPP_TARGET_OPENCL_VERSION >= 120
2502 const cl_device_partition_property * properties,
2503 vector<Device>* devices)
2506 cl_int err = clCreateSubDevices(object_, properties, 0,
nullptr, &n);
2507 if (err != CL_SUCCESS) {
2508 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2511 vector<cl_device_id> ids(n);
2512 err = clCreateSubDevices(object_, properties, n, ids.data(),
nullptr);
2513 if (err != CL_SUCCESS) {
2514 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2520 devices->resize(ids.size());
2524 for (size_type i = 0; i < ids.size(); i++) {
2527 (*devices)[i] =
Device(ids[i],
false);
2535#if defined(cl_ext_device_fission)
2538 const cl_device_partition_property_ext * properties,
2539 vector<Device>* devices)
2541 typedef CL_API_ENTRY cl_int
2542 ( CL_API_CALL * PFN_clCreateSubDevicesEXT)(
2544 const cl_device_partition_property_ext * ,
2547 cl_uint * ) CL_API_SUFFIX__VERSION_1_1;
2549 static PFN_clCreateSubDevicesEXT pfn_clCreateSubDevicesEXT =
nullptr;
2550#if CL_HPP_TARGET_OPENCL_VERSION >= 120
2552 cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>();
2553 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCreateSubDevicesEXT);
2555#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
2556 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateSubDevicesEXT);
2560 cl_int err = pfn_clCreateSubDevicesEXT(object_, properties, 0,
nullptr, &n);
2561 if (err != CL_SUCCESS) {
2562 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2565 vector<cl_device_id> ids(n);
2566 err = pfn_clCreateSubDevicesEXT(object_, properties, n, ids.data(),
nullptr);
2567 if (err != CL_SUCCESS) {
2568 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2573 devices->resize(ids.size());
2577 for (size_type i = 0; i < ids.size(); i++) {
2580 (*devices)[i] =
Device(ids[i],
false);
2589using BuildLogType = vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, CL_PROGRAM_BUILD_LOG>::param_type>>;
2590#if defined(CL_HPP_ENABLE_EXCEPTIONS)
2594class BuildError :
public Error
2597 BuildLogType buildLogs;
2599 BuildError(cl_int err,
const char * errStr,
const BuildLogType &vec) : Error(err, errStr), buildLogs(vec)
2603 BuildLogType getBuildLog()
const
2609 static inline cl_int buildErrHandler(
2611 const char * errStr,
2612 const BuildLogType &buildLogs)
2614 if (err != CL_SUCCESS) {
2615 throw BuildError(err, errStr, buildLogs);
2623 static inline cl_int buildErrHandler(
2625 const char * errStr,
2626 const BuildLogType &buildLogs)
2635CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Device::default_initialized_;
2636CL_HPP_DEFINE_STATIC_MEMBER_ Device Device::default_;
2637CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Device::default_error_ = CL_SUCCESS;
2649 static std::once_flag default_initialized_;
2651 static cl_int default_error_;
2658 static void makeDefault() {
2662#if defined(CL_HPP_ENABLE_EXCEPTIONS)
2670 cl_int err = ::clGetPlatformIDs(0,
nullptr, &n);
2671 if (err != CL_SUCCESS) {
2672 default_error_ = err;
2676 default_error_ = CL_INVALID_PLATFORM;
2680 vector<cl_platform_id> ids(n);
2681 err = ::clGetPlatformIDs(n, ids.data(),
nullptr);
2682 if (err != CL_SUCCESS) {
2683 default_error_ = err;
2689#if defined(CL_HPP_ENABLE_EXCEPTIONS)
2690 catch (cl::Error &e) {
2691 default_error_ = e.err();
2701 static void makeDefaultProvided(
const Platform &p) {
2706#ifdef CL_HPP_UNIT_TEST_ENABLE
2713 static void unitTestClearDefault() {
2728 explicit Platform(
const cl_platform_id &platform,
bool retainObject =
false) :
2729 detail::Wrapper<cl_type>(platform, retainObject) { }
2742 cl_int *errResult =
nullptr)
2744 std::call_once(default_initialized_, makeDefault);
2745 detail::errHandler(default_error_);
2746 if (errResult !=
nullptr) {
2747 *errResult = default_error_;
2761 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_platform));
2762 detail::errHandler(default_error_);
2767 template <
typename T>
2768 cl_int
getInfo(cl_platform_info name, T* param)
const
2770 return detail::errHandler(
2771 detail::getInfo(&::clGetPlatformInfo, object_, name, param),
2772 __GET_PLATFORM_INFO_ERR);
2776 template <cl_platform_info name>
typename
2781 detail::cl_platform_info, name>::param_type param;
2782 cl_int result =
getInfo(name, ¶m);
2783 if (err !=
nullptr) {
2794 cl_device_type type,
2795 vector<Device>* devices)
const
2798 if( devices ==
nullptr ) {
2799 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR);
2801 cl_int err = ::clGetDeviceIDs(object_, type, 0,
nullptr, &n);
2802 if (err != CL_SUCCESS && err != CL_DEVICE_NOT_FOUND) {
2803 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2806 vector<cl_device_id> ids(n);
2808 err = ::clGetDeviceIDs(object_, type, n, ids.data(),
nullptr);
2809 if (err != CL_SUCCESS) {
2810 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2819 devices->resize(ids.size());
2823 for (size_type i = 0; i < ids.size(); i++) {
2824 (*devices)[i] =
Device(ids[i],
true);
2830#if defined(CL_HPP_USE_DX_INTEROP)
2855 cl_d3d10_device_source_khr d3d_device_source,
2857 cl_d3d10_device_set_khr d3d_device_set,
2858 vector<Device>* devices)
const
2860 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clGetDeviceIDsFromD3D10KHR)(
2861 cl_platform_id platform,
2862 cl_d3d10_device_source_khr d3d_device_source,
2864 cl_d3d10_device_set_khr d3d_device_set,
2865 cl_uint num_entries,
2866 cl_device_id * devices,
2867 cl_uint* num_devices);
2869 if( devices ==
nullptr ) {
2870 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR);
2873 static PFN_clGetDeviceIDsFromD3D10KHR pfn_clGetDeviceIDsFromD3D10KHR =
nullptr;
2874#if CL_HPP_TARGET_OPENCL_VERSION >= 120
2875 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(object_, clGetDeviceIDsFromD3D10KHR);
2877#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
2878 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetDeviceIDsFromD3D10KHR);
2882 cl_int err = pfn_clGetDeviceIDsFromD3D10KHR(
2890 if (err != CL_SUCCESS) {
2891 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2894 vector<cl_device_id> ids(n);
2895 err = pfn_clGetDeviceIDsFromD3D10KHR(
2903 if (err != CL_SUCCESS) {
2904 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2912 devices->resize(ids.size());
2916 for (size_type i = 0; i < ids.size(); i++) {
2917 (*devices)[i] = Device(ids[i],
true);
2929 vector<Platform>* platforms)
2933 if( platforms ==
nullptr ) {
2934 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_PLATFORM_IDS_ERR);
2937 cl_int err = ::clGetPlatformIDs(0,
nullptr, &n);
2938 if (err != CL_SUCCESS) {
2939 return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
2942 vector<cl_platform_id> ids(n);
2943 err = ::clGetPlatformIDs(n, ids.data(),
nullptr);
2944 if (err != CL_SUCCESS) {
2945 return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
2949 platforms->resize(ids.size());
2952 for (size_type i = 0; i < ids.size(); i++) {
2953 (*platforms)[i] =
Platform(ids[i]);
2967 Platform default_platform = Platform::getDefault(&err);
2969 *platform = default_platform;
2983 cl_int * errResult =
nullptr)
2986 Platform default_platform = Platform::getDefault(&err);
2990 return default_platform;
2993#if CL_HPP_TARGET_OPENCL_VERSION >= 120
2998 return ::clUnloadPlatformCompiler(object_);
3003CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Platform::default_initialized_;
3004CL_HPP_DEFINE_STATIC_MEMBER_ Platform Platform::default_;
3005CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Platform::default_error_ = CL_SUCCESS;
3011#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
3016inline CL_API_PREFIX__VERSION_1_1_DEPRECATED cl_int
3021 return ::clUnloadCompiler();
3037 static std::once_flag default_initialized_;
3039 static cl_int default_error_;
3046 static void makeDefault() {
3050#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3054#if !defined(__APPLE__) && !defined(__MACOS)
3055 const Platform &p = Platform::getDefault();
3056 cl_platform_id defaultPlatform = p();
3057 cl_context_properties properties[3] = {
3058 CL_CONTEXT_PLATFORM, (cl_context_properties)defaultPlatform, 0
3061 cl_context_properties *properties =
nullptr;
3065 CL_DEVICE_TYPE_DEFAULT,
3071#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3072 catch (cl::Error &e) {
3073 default_error_ = e.err();
3084 static void makeDefaultProvided(
const Context &c) {
3089#ifdef CL_HPP_UNIT_TEST_ENABLE
3096 static void unitTestClearDefault() {
3106 const vector<Device>& devices,
3107 const cl_context_properties* properties =
nullptr,
3108 void (CL_CALLBACK * notifyFptr)(
3113 void* data =
nullptr,
3114 cl_int* err =
nullptr)
3118 size_type numDevices = devices.size();
3119 vector<cl_device_id> deviceIDs(numDevices);
3121 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
3122 deviceIDs[deviceIndex] = (devices[deviceIndex])();
3125 object_ = ::clCreateContext(
3126 properties, (cl_uint) numDevices,
3128 notifyFptr, data, &error);
3130 detail::errHandler(error, __CREATE_CONTEXT_ERR);
3131 if (err !=
nullptr) {
3142 const cl_context_properties* properties =
nullptr,
3143 void (CL_CALLBACK * notifyFptr)(
3148 void* data =
nullptr,
3149 cl_int* err =
nullptr)
3153 cl_device_id deviceID = device();
3155 object_ = ::clCreateContext(
3158 notifyFptr, data, &error);
3160 detail::errHandler(error, __CREATE_CONTEXT_ERR);
3161 if (err !=
nullptr) {
3171 cl_device_type type,
3172 const cl_context_properties* properties =
nullptr,
3173 void (CL_CALLBACK * notifyFptr)(
3178 void* data =
nullptr,
3179 cl_int* err =
nullptr)
3183#if !defined(__APPLE__) && !defined(__MACOS)
3184 cl_context_properties prop[4] = {CL_CONTEXT_PLATFORM, 0, 0, 0 };
3186 if (properties ==
nullptr) {
3188 vector<Platform> platforms;
3189 error = Platform::get(&platforms);
3190 if (error != CL_SUCCESS) {
3191 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
3192 if (err !=
nullptr) {
3199 cl_context_properties platform_id = 0;
3200 for (
unsigned int i = 0; i < platforms.size(); i++) {
3202 vector<Device> devices;
3204#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3208 error = platforms[i].getDevices(type, &devices);
3210#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3211 }
catch (cl::Error& e) {
3219 if (error != CL_SUCCESS && error != CL_DEVICE_NOT_FOUND) {
3220 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
3221 if (err !=
nullptr) {
3226 if (devices.size() > 0) {
3227 platform_id = (cl_context_properties)platforms[i]();
3232 if (platform_id == 0) {
3233 detail::errHandler(CL_DEVICE_NOT_FOUND, __CREATE_CONTEXT_FROM_TYPE_ERR);
3234 if (err !=
nullptr) {
3235 *err = CL_DEVICE_NOT_FOUND;
3240 prop[1] = platform_id;
3241 properties = &prop[0];
3244 object_ = ::clCreateContextFromType(
3245 properties, type, notifyFptr, data, &error);
3247 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
3248 if (err !=
nullptr) {
3260 std::call_once(default_initialized_, makeDefault);
3261 detail::errHandler(default_error_);
3262 if (err !=
nullptr) {
3263 *err = default_error_;
3277 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_context));
3278 detail::errHandler(default_error_);
3290 explicit Context(
const cl_context& context,
bool retainObject =
false) :
3291 detail::Wrapper<cl_type>(context, retainObject) { }
3305 template <
typename T>
3306 cl_int
getInfo(cl_context_info name, T* param)
const
3308 return detail::errHandler(
3309 detail::getInfo(&::clGetContextInfo, object_, name, param),
3310 __GET_CONTEXT_INFO_ERR);
3314 template <cl_context_info name>
typename
3319 detail::cl_context_info, name>::param_type param;
3320 cl_int result =
getInfo(name, ¶m);
3321 if (err !=
nullptr) {
3333 cl_mem_object_type type,
3334 vector<ImageFormat>* formats)
const
3342 cl_int err = ::clGetSupportedImageFormats(
3349 if (err != CL_SUCCESS) {
3350 return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
3353 if (numEntries > 0) {
3354 vector<ImageFormat> value(numEntries);
3355 err = ::clGetSupportedImageFormats(
3360 (cl_image_format*)value.data(),
3362 if (err != CL_SUCCESS) {
3363 return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
3366 formats->assign(begin(value), end(value));
3376#if CL_HPP_TARGET_OPENCL_VERSION >= 300
3388 void (CL_CALLBACK * pfn_notify)(cl_context,
void *),
3389 void * user_data =
nullptr)
3391 return detail::errHandler(
3392 ::clSetContextDestructorCallback(
3396 __SET_CONTEXT_DESCTRUCTOR_CALLBACK_ERR);
3401inline void Device::makeDefault()
3406#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3413 detail::errHandler(error, __CREATE_CONTEXT_ERR);
3415 if (error != CL_SUCCESS) {
3416 default_error_ = error;
3419 default_ = context.
getInfo<CL_CONTEXT_DEVICES>()[0];
3420 default_error_ = CL_SUCCESS;
3423#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3424 catch (cl::Error &e) {
3425 default_error_ = e.err();
3430CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Context::default_initialized_;
3431CL_HPP_DEFINE_STATIC_MEMBER_ Context Context::default_;
3432CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Context::default_error_ = CL_SUCCESS;
3446 Event() : detail::Wrapper<cl_type>() { }
3456 explicit Event(
const cl_event& event,
bool retainObject =
false) :
3457 detail::Wrapper<cl_type>(event, retainObject) { }
3471 template <
typename T>
3472 cl_int
getInfo(cl_event_info name, T* param)
const
3474 return detail::errHandler(
3475 detail::getInfo(&::clGetEventInfo, object_, name, param),
3476 __GET_EVENT_INFO_ERR);
3480 template <cl_event_info name>
typename
3485 detail::cl_event_info, name>::param_type param;
3486 cl_int result =
getInfo(name, ¶m);
3487 if (err !=
nullptr) {
3494 template <
typename T>
3497 return detail::errHandler(detail::getInfo(
3498 &::clGetEventProfilingInfo, object_, name, param),
3499 __GET_EVENT_PROFILE_INFO_ERR);
3503 template <cl_profiling_info name>
typename
3508 detail::cl_profiling_info, name>::param_type param;
3510 if (err !=
nullptr) {
3522 return detail::errHandler(
3523 ::clWaitForEvents(1, &object_),
3524 __WAIT_FOR_EVENTS_ERR);
3527#if CL_HPP_TARGET_OPENCL_VERSION >= 110
3534 void (CL_CALLBACK * pfn_notify)(cl_event, cl_int,
void *),
3535 void * user_data =
nullptr)
3537 return detail::errHandler(
3538 ::clSetEventCallback(
3543 __SET_EVENT_CALLBACK_ERR);
3554 static_assert(
sizeof(
cl::Event) ==
sizeof(cl_event),
3555 "Size of cl::Event must be equal to size of cl_event");
3557 return detail::errHandler(
3559 (cl_uint) events.size(), (events.size() > 0) ? (cl_event*)&events.front() :
nullptr),
3560 __WAIT_FOR_EVENTS_ERR);
3564#if CL_HPP_TARGET_OPENCL_VERSION >= 110
3578 cl_int * err =
nullptr)
3581 object_ = ::clCreateUserEvent(
3585 detail::errHandler(error, __CREATE_USER_EVENT_ERR);
3586 if (err !=
nullptr) {
3600 return detail::errHandler(
3601 ::clSetUserEventStatus(object_,status),
3602 __SET_USER_EVENT_STATUS_ERR);
3612WaitForEvents(
const vector<Event>& events)
3614 return detail::errHandler(
3616 (cl_uint) events.size(), (events.size() > 0) ? (cl_event*)&events.front() :
nullptr),
3617 __WAIT_FOR_EVENTS_ERR);
3645 explicit Memory(
const cl_mem& memory,
bool retainObject) :
3646 detail::Wrapper<cl_type>(memory, retainObject) { }
3660 template <
typename T>
3663 return detail::errHandler(
3664 detail::getInfo(&::clGetMemObjectInfo, object_, name, param),
3665 __GET_MEM_OBJECT_INFO_ERR);
3669 template <cl_mem_info name>
typename
3674 detail::cl_mem_info, name>::param_type param;
3675 cl_int result =
getInfo(name, ¶m);
3676 if (err !=
nullptr) {
3682#if CL_HPP_TARGET_OPENCL_VERSION >= 110
3697 void (CL_CALLBACK * pfn_notify)(cl_mem,
void *),
3698 void * user_data =
nullptr)
3700 return detail::errHandler(
3701 ::clSetMemObjectDestructorCallback(
3705 __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR);
3713template<
typename IteratorType >
3714cl_int
copy( IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer );
3715template<
typename IteratorType >
3716cl_int
copy(
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator );
3717template<
typename IteratorType >
3718cl_int
copy(
const CommandQueue &queue, IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer );
3719template<
typename IteratorType >
3720cl_int
copy(
const CommandQueue &queue,
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator );
3723#if CL_HPP_TARGET_OPENCL_VERSION >= 200
3729 static cl_svm_mem_flags getSVMMemFlags()
3736template<
class Trait = detail::SVMTraitNull>
3740 static cl_svm_mem_flags getSVMMemFlags()
3742 return CL_MEM_READ_WRITE |
3743 Trait::getSVMMemFlags();
3747template<
class Trait = detail::SVMTraitNull>
3751 static cl_svm_mem_flags getSVMMemFlags()
3753 return CL_MEM_READ_ONLY |
3754 Trait::getSVMMemFlags();
3758template<
class Trait = detail::SVMTraitNull>
3762 static cl_svm_mem_flags getSVMMemFlags()
3764 return CL_MEM_WRITE_ONLY |
3765 Trait::getSVMMemFlags();
3769template<
class Trait = SVMTraitReadWrite<>>
3773 static cl_svm_mem_flags getSVMMemFlags()
3775 return Trait::getSVMMemFlags();
3779template<
class Trait = SVMTraitReadWrite<>>
3783 static cl_svm_mem_flags getSVMMemFlags()
3785 return CL_MEM_SVM_FINE_GRAIN_BUFFER |
3786 Trait::getSVMMemFlags();
3790template<
class Trait = SVMTraitReadWrite<>>
3794 static cl_svm_mem_flags getSVMMemFlags()
3797 CL_MEM_SVM_FINE_GRAIN_BUFFER |
3798 CL_MEM_SVM_ATOMICS |
3799 Trait::getSVMMemFlags();
3810 const vector<Event>* events =
nullptr,
3811 Event* event =
nullptr);
3824template<
typename T,
class SVMTrait>
3830 typedef T value_type;
3831 typedef value_type* pointer;
3832 typedef const value_type* const_pointer;
3833 typedef value_type& reference;
3834 typedef const value_type& const_reference;
3835 typedef std::size_t size_type;
3836 typedef std::ptrdiff_t difference_type;
3838 template<
typename U>
3844 template<
typename U,
typename V>
3848 context_(
Context::getDefault())
3858 SVMAllocator(
const SVMAllocator &other) :
3859 context_(other.context_)
3863 template<
typename U>
3864 SVMAllocator(
const SVMAllocator<U, SVMTrait> &other) :
3865 context_(other.context_)
3873 pointer address(reference r) CL_HPP_NOEXCEPT_
3875 return std::addressof(r);
3878 const_pointer address(const_reference r) CL_HPP_NOEXCEPT_
3880 return std::addressof(r);
3897 SVMTrait::getSVMMemFlags(),
3900 pointer retValue =
reinterpret_cast<pointer
>(
3902#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3904 std::bad_alloc excep;
3910 if (!(SVMTrait::getSVMMemFlags() & CL_MEM_SVM_FINE_GRAIN_BUFFER)) {
3911 cl_int err =
enqueueMapSVM(retValue, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE, size*
sizeof(T));
3912 if (err != CL_SUCCESS) {
3913 std::bad_alloc excep;
3922 void deallocate(pointer p, size_type)
3924 clSVMFree(context_(), p);
3933 size_type maxSize = std::numeric_limits<size_type>::max() /
sizeof(T);
3935 for (
const Device &d : context_.
getInfo<CL_CONTEXT_DEVICES>()) {
3938 static_cast<size_type
>(d.getInfo<CL_DEVICE_MAX_MEM_ALLOC_SIZE>()));
3944 template<
class U,
class... Args >
3945 void construct(U* p, Args&&... args)
3961 return (context_==rhs.context_);
3971template<
class SVMTrait>
3974 typedef void value_type;
3975 typedef value_type* pointer;
3976 typedef const value_type* const_pointer;
3978 template<
typename U>
3984 template<
typename U,
typename V>
3988#if !defined(CL_HPP_NO_STD_UNIQUE_PTR)
3991 template<
class Alloc>
3998 typedef typename std::allocator_traits<Alloc>::pointer pointer;
4000 Deleter(
const Alloc &alloc, size_type copies) : alloc_{ alloc }, copies_{ copies }
4004 void operator()(pointer ptr)
const {
4005 Alloc tmpAlloc{ alloc_ };
4006 std::allocator_traits<Alloc>::destroy(tmpAlloc, std::addressof(*ptr));
4007 std::allocator_traits<Alloc>::deallocate(tmpAlloc, ptr, copies_);
4018template <
class T,
class Alloc,
class... Args>
4021 Alloc alloc(alloc_);
4022 static const size_type copies = 1;
4027 T* tmp = std::allocator_traits<Alloc>::allocate(alloc, copies);
4029 std::bad_alloc excep;
4033 std::allocator_traits<Alloc>::construct(
4035 std::addressof(*tmp),
4036 std::forward<Args>(args)...);
4040 catch (std::bad_alloc&)
4042 std::allocator_traits<Alloc>::deallocate(alloc, tmp, copies);
4047template<
class T,
class SVMTrait,
class... Args >
4048cl::pointer<T, detail::Deleter<SVMAllocator<T, SVMTrait>>> allocate_svm(Args... args)
4050 SVMAllocator<T, SVMTrait> alloc;
4051 return cl::allocate_pointer<T>(alloc, args...);
4054template<
class T,
class SVMTrait,
class... Args >
4055cl::pointer<T, detail::Deleter<SVMAllocator<T, SVMTrait>>> allocate_svm(
const cl::Context &c, Args... args)
4057 SVMAllocator<T, SVMTrait> alloc(c);
4058 return cl::allocate_pointer<T>(alloc, args...);
4104 void* host_ptr =
nullptr,
4105 cl_int* err =
nullptr)
4108 object_ = ::clCreateBuffer(context(), flags, size, host_ptr, &error);
4110 detail::errHandler(error, __CREATE_BUFFER_ERR);
4111 if (err !=
nullptr) {
4116#if CL_HPP_TARGET_OPENCL_VERSION >= 300
4129 const vector<cl_mem_properties>& properties,
4132 void* host_ptr =
nullptr,
4133 cl_int* err =
nullptr)
4137 if (properties.empty()) {
4138 object_ = ::clCreateBufferWithProperties(context(),
nullptr, flags,
4139 size, host_ptr, &error);
4142 object_ = ::clCreateBufferWithProperties(
4143 context(), properties.data(), flags, size, host_ptr, &error);
4146 detail::errHandler(error, __CREATE_BUFFER_ERR);
4147 if (err !=
nullptr) {
4165 void* host_ptr =
nullptr,
4166 cl_int* err =
nullptr) :
Buffer(
Context::getDefault(err), flags, size, host_ptr, err) { }
4168#if CL_HPP_TARGET_OPENCL_VERSION >= 300
4182 const vector<cl_mem_properties>& properties,
4185 void* host_ptr =
nullptr,
4186 cl_int* err =
nullptr) :
Buffer(
Context::getDefault(err), properties, flags, size, host_ptr, err) { }
4194 template<
typename IteratorType >
4196 IteratorType startIterator,
4197 IteratorType endIterator,
4199 bool useHostPtr =
false,
4200 cl_int* err =
nullptr)
4202 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
4205 cl_mem_flags flags = 0;
4207 flags |= CL_MEM_READ_ONLY;
4210 flags |= CL_MEM_READ_WRITE;
4213 flags |= CL_MEM_USE_HOST_PTR;
4216 size_type size =
sizeof(DataType)*(endIterator - startIterator);
4221 object_ = ::clCreateBuffer(context(), flags, size,
const_cast<DataType*
>(&*startIterator), &error);
4223 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
4226 detail::errHandler(error, __CREATE_BUFFER_ERR);
4227 if (err !=
nullptr) {
4232 error =
cl::copy(startIterator, endIterator, *
this);
4233 detail::errHandler(error, __CREATE_BUFFER_ERR);
4234 if (err !=
nullptr) {
4245 template<
typename IteratorType >
4246 Buffer(
const Context &context, IteratorType startIterator, IteratorType endIterator,
4247 bool readOnly,
bool useHostPtr =
false, cl_int* err =
nullptr);
4253 template<
typename IteratorType >
4254 Buffer(
const CommandQueue &queue, IteratorType startIterator, IteratorType endIterator,
4255 bool readOnly,
bool useHostPtr =
false, cl_int* err =
nullptr);
4267 explicit Buffer(
const cl_mem& buffer,
bool retainObject =
false) :
4268 Memory(buffer, retainObject) { }
4281#if CL_HPP_TARGET_OPENCL_VERSION >= 110
4288 cl_buffer_create_type buffer_create_type,
4289 const void * buffer_create_info,
4290 cl_int * err =
nullptr)
4294 result.object_ = ::clCreateSubBuffer(
4301 detail::errHandler(error, __CREATE_SUBBUFFER_ERR);
4302 if (err !=
nullptr) {
4311#if defined (CL_HPP_USE_DX_INTEROP)
4320class BufferD3D10 :
public Buffer
4331 const Context& context,
4333 ID3D10Buffer* bufobj,
4334 cl_int * err =
nullptr) : pfn_clCreateFromD3D10BufferKHR(nullptr)
4336 typedef CL_API_ENTRY cl_mem (CL_API_CALL *PFN_clCreateFromD3D10BufferKHR)(
4337 cl_context context, cl_mem_flags flags, ID3D10Buffer* buffer,
4338 cl_int* errcode_ret);
4339 PFN_clCreateFromD3D10BufferKHR pfn_clCreateFromD3D10BufferKHR;
4340#if CL_HPP_TARGET_OPENCL_VERSION >= 120
4341 vector<cl_context_properties> props = context.getInfo<CL_CONTEXT_PROPERTIES>();
4342 cl_platform platform =
nullptr;
4343 for(
int i = 0; i < props.size(); ++i ) {
4344 if( props[i] == CL_CONTEXT_PLATFORM ) {
4345 platform = props[i+1];
4348 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCreateFromD3D10BufferKHR);
4350#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
4351 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateFromD3D10BufferKHR);
4355 object_ = pfn_clCreateFromD3D10BufferKHR(
4362 detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
4363 if (err !=
nullptr) {
4369 BufferD3D10() : Buffer() { }
4378 explicit BufferD3D10(
const cl_mem& buffer,
bool retainObject =
false) :
4379 Buffer(buffer, retainObject) { }
4385 BufferD3D10& operator = (
const cl_mem& rhs)
4413 cl_int * err =
nullptr)
4416 object_ = ::clCreateFromGLBuffer(
4422 detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
4423 if (err !=
nullptr) {
4438 explicit BufferGL(
const cl_mem& buffer,
bool retainObject =
false) :
4439 Buffer(buffer, retainObject) { }
4454 cl_gl_object_type *type,
4455 cl_GLuint * gl_object_name)
4457 return detail::errHandler(
4458 ::clGetGLObjectInfo(object_,type,gl_object_name),
4459 __GET_GL_OBJECT_INFO_ERR);
4483 cl_int * err =
nullptr)
4486 object_ = ::clCreateFromGLRenderbuffer(
4492 detail::errHandler(error, __CREATE_GL_RENDER_BUFFER_ERR);
4493 if (err !=
nullptr) {
4509 Buffer(buffer, retainObject) { }
4524 cl_gl_object_type *type,
4525 cl_GLuint * gl_object_name)
4527 return detail::errHandler(
4528 ::clGetGLObjectInfo(object_,type,gl_object_name),
4529 __GET_GL_OBJECT_INFO_ERR);
4552 explicit Image(
const cl_mem& image,
bool retainObject =
false) :
4553 Memory(image, retainObject) { }
4568 template <
typename T>
4571 return detail::errHandler(
4572 detail::getInfo(&::clGetImageInfo, object_, name, param),
4573 __GET_IMAGE_INFO_ERR);
4577 template <cl_image_info name>
typename
4582 detail::cl_image_info, name>::param_type param;
4584 if (err !=
nullptr) {
4591#if CL_HPP_TARGET_OPENCL_VERSION >= 120
4610 void* host_ptr =
nullptr,
4611 cl_int* err =
nullptr)
4615 cl_image_desc desc = {};
4616 desc.image_type = CL_MEM_OBJECT_IMAGE1D;
4617 desc.image_width = width;
4619 object_ = ::clCreateImage(
4627 detail::errHandler(error, __CREATE_IMAGE_ERR);
4628 if (err !=
nullptr) {
4643 explicit Image1D(
const cl_mem& image1D,
bool retainObject =
false) :
4644 Image(image1D, retainObject) { }
4671 cl_int* err =
nullptr)
4675 cl_image_desc desc = {};
4676 desc.image_type = CL_MEM_OBJECT_IMAGE1D_BUFFER;
4677 desc.image_width = width;
4678 desc.buffer = buffer();
4680 object_ = ::clCreateImage(
4688 detail::errHandler(error, __CREATE_IMAGE_ERR);
4689 if (err !=
nullptr) {
4704 Image(image1D, retainObject) { }
4726 size_type arraySize,
4729 void* host_ptr =
nullptr,
4730 cl_int* err =
nullptr)
4734 cl_image_desc desc = {};
4735 desc.image_type = CL_MEM_OBJECT_IMAGE1D_ARRAY;
4736 desc.image_width = width;
4737 desc.image_array_size = arraySize;
4738 desc.image_row_pitch = rowPitch;
4740 object_ = ::clCreateImage(
4748 detail::errHandler(error, __CREATE_IMAGE_ERR);
4749 if (err !=
nullptr) {
4763 explicit Image1DArray(
const cl_mem& imageArray,
bool retainObject =
false) :
4764 Image(imageArray, retainObject) { }
4797 size_type row_pitch = 0,
4798 void* host_ptr =
nullptr,
4799 cl_int* err =
nullptr)
4802 bool useCreateImage;
4804#if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
4807 cl_uint version = detail::getContextPlatformVersion(context());
4808 useCreateImage = (version >= 0x10002);
4810#elif CL_HPP_TARGET_OPENCL_VERSION >= 120
4811 useCreateImage =
true;
4813 useCreateImage =
false;
4816#if CL_HPP_TARGET_OPENCL_VERSION >= 120
4819 cl_image_desc desc = {};
4820 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
4821 desc.image_width = width;
4822 desc.image_height = height;
4823 desc.image_row_pitch = row_pitch;
4825 object_ = ::clCreateImage(
4833 detail::errHandler(error, __CREATE_IMAGE_ERR);
4834 if (err !=
nullptr) {
4839#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
4840 if (!useCreateImage)
4842 object_ = ::clCreateImage2D(
4843 context(), flags,&format, width, height, row_pitch, host_ptr, &error);
4845 detail::errHandler(error, __CREATE_IMAGE2D_ERR);
4846 if (err !=
nullptr) {
4853#if CL_HPP_TARGET_OPENCL_VERSION >= 120
4865 const Buffer &sourceBuffer,
4868 size_type row_pitch = 0,
4869 cl_int* err =
nullptr)
4873 cl_image_desc desc = {};
4874 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
4875 desc.image_width = width;
4876 desc.image_height = height;
4877 desc.image_row_pitch = row_pitch;
4878 desc.buffer = sourceBuffer();
4880 object_ = ::clCreateImage(
4888 detail::errHandler(error, __CREATE_IMAGE_ERR);
4889 if (err !=
nullptr) {
4895#if CL_HPP_TARGET_OPENCL_VERSION >= 200
4910 cl_channel_order order,
4911 const Image &sourceImage,
4912 cl_int* err =
nullptr)
4917 size_type sourceWidth =
4919 size_type sourceHeight =
4921 size_type sourceRowPitch =
4923 cl_uint sourceNumMIPLevels =
4925 cl_uint sourceNumSamples =
4927 cl_image_format sourceFormat =
4932 sourceFormat.image_channel_order = order;
4934 cl_image_desc desc = {};
4935 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
4936 desc.image_width = sourceWidth;
4937 desc.image_height = sourceHeight;
4938 desc.image_row_pitch = sourceRowPitch;
4939 desc.num_mip_levels = sourceNumMIPLevels;
4940 desc.num_samples = sourceNumSamples;
4941 desc.buffer = sourceImage();
4943 object_ = ::clCreateImage(
4951 detail::errHandler(error, __CREATE_IMAGE_ERR);
4952 if (err !=
nullptr) {
4968 explicit Image2D(
const cl_mem& image2D,
bool retainObject =
false) :
4969 Image(image2D, retainObject) { }
4987#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
5011 cl_int * err =
nullptr)
5014 object_ = ::clCreateFromGLTexture2D(
5022 detail::errHandler(error, __CREATE_GL_TEXTURE_2D_ERR);
5023 if (err !=
nullptr) {
5039 explicit Image2DGL(
const cl_mem& image,
bool retainObject =
false) :
5040 Image2D(image, retainObject) { }
5054} CL_API_SUFFIX__VERSION_1_1_DEPRECATED;
5057#if CL_HPP_TARGET_OPENCL_VERSION >= 120
5068 size_type arraySize,
5072 size_type slicePitch,
5073 void* host_ptr =
nullptr,
5074 cl_int* err =
nullptr)
5078 cl_image_desc desc = {};
5079 desc.image_type = CL_MEM_OBJECT_IMAGE2D_ARRAY;
5080 desc.image_width = width;
5081 desc.image_height = height;
5082 desc.image_array_size = arraySize;
5083 desc.image_row_pitch = rowPitch;
5084 desc.image_slice_pitch = slicePitch;
5086 object_ = ::clCreateImage(
5094 detail::errHandler(error, __CREATE_IMAGE_ERR);
5095 if (err !=
nullptr) {
5109 explicit Image2DArray(
const cl_mem& imageArray,
bool retainObject =
false) :
Image(imageArray, retainObject) { }
5140 size_type row_pitch = 0,
5141 size_type slice_pitch = 0,
5142 void* host_ptr =
nullptr,
5143 cl_int* err =
nullptr)
5146 bool useCreateImage;
5148#if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
5151 cl_uint version = detail::getContextPlatformVersion(context());
5152 useCreateImage = (version >= 0x10002);
5154#elif CL_HPP_TARGET_OPENCL_VERSION >= 120
5155 useCreateImage =
true;
5157 useCreateImage =
false;
5160#if CL_HPP_TARGET_OPENCL_VERSION >= 120
5163 cl_image_desc desc = {};
5164 desc.image_type = CL_MEM_OBJECT_IMAGE3D;
5165 desc.image_width = width;
5166 desc.image_height = height;
5167 desc.image_depth = depth;
5168 desc.image_row_pitch = row_pitch;
5169 desc.image_slice_pitch = slice_pitch;
5171 object_ = ::clCreateImage(
5179 detail::errHandler(error, __CREATE_IMAGE_ERR);
5180 if (err !=
nullptr) {
5185#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
5186 if (!useCreateImage)
5188 object_ = ::clCreateImage3D(
5189 context(), flags, &format, width, height, depth, row_pitch,
5190 slice_pitch, host_ptr, &error);
5192 detail::errHandler(error, __CREATE_IMAGE3D_ERR);
5193 if (err !=
nullptr) {
5210 explicit Image3D(
const cl_mem& image3D,
bool retainObject =
false) :
5211 Image(image3D, retainObject) { }
5225#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
5248 cl_int * err =
nullptr)
5251 object_ = ::clCreateFromGLTexture3D(
5259 detail::errHandler(error, __CREATE_GL_TEXTURE_3D_ERR);
5260 if (err !=
nullptr) {
5275 explicit Image3DGL(
const cl_mem& image,
bool retainObject =
false) :
5276 Image3D(image, retainObject) { }
5291#if CL_HPP_TARGET_OPENCL_VERSION >= 120
5307 cl_int * err =
nullptr)
5310 object_ = ::clCreateFromGLTexture(
5318 detail::errHandler(error, __CREATE_GL_TEXTURE_ERR);
5319 if (err !=
nullptr) {
5333 explicit ImageGL(
const cl_mem& image,
bool retainObject =
false) :
5334 Image(image, retainObject) { }
5336 ImageGL& operator = (
const cl_mem& rhs)
5347#if CL_HPP_TARGET_OPENCL_VERSION >= 200
5369 cl_uint packet_size,
5370 cl_uint max_packets,
5371 cl_int* err =
nullptr)
5375 cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS;
5376 object_ = ::clCreatePipe(context(), flags, packet_size, max_packets,
nullptr, &error);
5378 detail::errHandler(error, __CREATE_PIPE_ERR);
5379 if (err !=
nullptr) {
5393 cl_uint packet_size,
5394 cl_uint max_packets,
5395 cl_int* err =
nullptr)
5401 cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS;
5402 object_ = ::clCreatePipe(context(), flags, packet_size, max_packets,
nullptr, &error);
5404 detail::errHandler(error, __CREATE_PIPE_ERR);
5405 if (err !=
nullptr) {
5420 explicit Pipe(
const cl_mem& pipe,
bool retainObject =
false) :
5421 Memory(pipe, retainObject) { }
5436 template <
typename T>
5439 return detail::errHandler(
5440 detail::getInfo(&::clGetPipeInfo, object_, name, param),
5441 __GET_PIPE_INFO_ERR);
5445 template <cl_pipe_info name>
typename
5450 detail::cl_pipe_info, name>::param_type param;
5451 cl_int result =
getInfo(name, ¶m);
5452 if (err !=
nullptr) {
5481 cl_bool normalized_coords,
5482 cl_addressing_mode addressing_mode,
5483 cl_filter_mode filter_mode,
5484 cl_int* err =
nullptr)
5488#if CL_HPP_TARGET_OPENCL_VERSION >= 200
5489 cl_sampler_properties sampler_properties[] = {
5490 CL_SAMPLER_NORMALIZED_COORDS, normalized_coords,
5491 CL_SAMPLER_ADDRESSING_MODE, addressing_mode,
5492 CL_SAMPLER_FILTER_MODE, filter_mode,
5494 object_ = ::clCreateSamplerWithProperties(
5499 detail::errHandler(error, __CREATE_SAMPLER_WITH_PROPERTIES_ERR);
5500 if (err !=
nullptr) {
5504 object_ = ::clCreateSampler(
5511 detail::errHandler(error, __CREATE_SAMPLER_ERR);
5512 if (err !=
nullptr) {
5526 explicit Sampler(
const cl_sampler& sampler,
bool retainObject =
false) :
5527 detail::Wrapper<cl_type>(sampler, retainObject) { }
5543 template <
typename T>
5544 cl_int
getInfo(cl_sampler_info name, T* param)
const
5546 return detail::errHandler(
5547 detail::getInfo(&::clGetSamplerInfo, object_, name, param),
5548 __GET_SAMPLER_INFO_ERR);
5552 template <cl_sampler_info name>
typename
5557 detail::cl_sampler_info, name>::param_type param;
5558 cl_int result =
getInfo(name, ¶m);
5559 if (err !=
nullptr) {
5568class DeviceCommandQueue;
5575 size_type sizes_[3];
5576 cl_uint dimensions_;
5607 NDRange(size_type size0, size_type size1, size_type size2)
5628 operator const size_type*()
const {
5642 return dimensions_*
sizeof(size_type);
5650 const size_type* get()
const
5657static const NDRange NullRange;
5667template <
typename T,
class Enable =
void>
5672template <
typename T>
5675 static size_type size(
const T&) {
return sizeof(T); }
5676 static const T* ptr(
const T& value) {
return &value; }
5681template <
typename T>
5684 static size_type size(
const T&) {
return sizeof(cl_mem); }
5685 static const cl_mem* ptr(
const T& value) {
return &(value()); }
5693 static size_type size(
const LocalSpaceArg& value) {
return value.size_; }
5694 static const void* ptr(
const LocalSpaceArg&) {
return nullptr; }
5721 inline Kernel(
const Program& program,
const char* name, cl_int* err =
nullptr);
5734 explicit Kernel(
const cl_kernel& kernel,
bool retainObject =
false) :
5735 detail::Wrapper<cl_type>(kernel, retainObject) { }
5751 template <
typename T>
5752 cl_int getInfo(cl_kernel_info name, T* param)
const
5754 return detail::errHandler(
5755 detail::getInfo(&::clGetKernelInfo, object_, name, param),
5756 __GET_KERNEL_INFO_ERR);
5759 template <cl_kernel_info name>
typename
5760 detail::param_traits<detail::cl_kernel_info, name>::param_type
5761 getInfo(cl_int* err =
nullptr)
const
5763 typename detail::param_traits<
5764 detail::cl_kernel_info, name>::param_type param;
5765 cl_int result = getInfo(name, ¶m);
5766 if (err !=
nullptr) {
5772#if CL_HPP_TARGET_OPENCL_VERSION >= 120
5773 template <
typename T>
5774 cl_int getArgInfo(cl_uint argIndex, cl_kernel_arg_info name, T* param)
const
5776 return detail::errHandler(
5777 detail::getInfo(&::clGetKernelArgInfo, object_, argIndex, name, param),
5778 __GET_KERNEL_ARG_INFO_ERR);
5781 template <cl_kernel_arg_info name>
typename
5782 detail::param_traits<detail::cl_kernel_arg_info, name>::param_type
5783 getArgInfo(cl_uint argIndex, cl_int* err =
nullptr)
const
5785 typename detail::param_traits<
5786 detail::cl_kernel_arg_info, name>::param_type param;
5787 cl_int result = getArgInfo(argIndex, name, ¶m);
5788 if (err !=
nullptr) {
5795 template <
typename T>
5796 cl_int getWorkGroupInfo(
5797 const Device& device, cl_kernel_work_group_info name, T* param)
const
5799 return detail::errHandler(
5801 &::clGetKernelWorkGroupInfo, object_, device(), name, param),
5802 __GET_KERNEL_WORK_GROUP_INFO_ERR);
5805 template <cl_kernel_work_group_info name>
typename
5806 detail::param_traits<detail::cl_kernel_work_group_info, name>::param_type
5807 getWorkGroupInfo(
const Device& device, cl_int* err =
nullptr)
const
5809 typename detail::param_traits<
5810 detail::cl_kernel_work_group_info, name>::param_type param;
5811 cl_int result = getWorkGroupInfo(device, name, ¶m);
5812 if (err !=
nullptr) {
5818#if defined(CL_HPP_USE_CL_SUB_GROUPS_KHR) || CL_HPP_TARGET_OPENCL_VERSION >= 210
5819 cl_int getSubGroupInfo(
const cl::Device &dev, cl_kernel_sub_group_info name,
const cl::NDRange &range, size_type* param)
const
5821#if CL_HPP_TARGET_OPENCL_VERSION >= 210
5823 return detail::errHandler(
5824 clGetKernelSubGroupInfo(object_, dev(), name, range.
size(), range.get(),
sizeof(size_type), param,
nullptr),
5825 __GET_KERNEL_SUB_GROUP_INFO_ERR);
5829 typedef clGetKernelSubGroupInfoKHR_fn PFN_clGetKernelSubGroupInfoKHR;
5830 static PFN_clGetKernelSubGroupInfoKHR pfn_clGetKernelSubGroupInfoKHR =
nullptr;
5831 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetKernelSubGroupInfoKHR);
5833 return detail::errHandler(
5834 pfn_clGetKernelSubGroupInfoKHR(object_, dev(), name, range.
size(), range.get(),
sizeof(size_type), param,
nullptr),
5835 __GET_KERNEL_SUB_GROUP_INFO_ERR);
5840 template <cl_kernel_sub_group_info name>
5841 size_type getSubGroupInfo(
const cl::Device &dev,
const cl::NDRange &range, cl_int* err =
nullptr)
const
5844 cl_int result = getSubGroupInfo(dev, name, range, ¶m);
5845 if (err !=
nullptr) {
5852#if CL_HPP_TARGET_OPENCL_VERSION >= 200
5855 template<
typename T,
class D>
5856 cl_int
setArg(cl_uint index,
const cl::pointer<T, D> &argPtr)
5858 return detail::errHandler(
5859 ::clSetKernelArgSVMPointer(object_, index, argPtr.get()),
5860 __SET_KERNEL_ARGS_ERR);
5865 template<
typename T,
class Alloc>
5866 cl_int
setArg(cl_uint index,
const cl::vector<T, Alloc> &argPtr)
5868 return detail::errHandler(
5869 ::clSetKernelArgSVMPointer(object_, index, argPtr.data()),
5870 __SET_KERNEL_ARGS_ERR);
5875 template<
typename T>
5876 typename std::enable_if<std::is_pointer<T>::value, cl_int>::type
5879 return detail::errHandler(
5880 ::clSetKernelArgSVMPointer(object_, index, argPtr),
5881 __SET_KERNEL_ARGS_ERR);
5887 template <
typename T>
5888 typename std::enable_if<!std::is_pointer<T>::value, cl_int>::type
5891 return detail::errHandler(
5897 __SET_KERNEL_ARGS_ERR);
5900 cl_int
setArg(cl_uint index, size_type size,
const void* argPtr)
5902 return detail::errHandler(
5903 ::clSetKernelArg(object_, index, size, argPtr),
5904 __SET_KERNEL_ARGS_ERR);
5907#if CL_HPP_TARGET_OPENCL_VERSION >= 200
5914 return detail::errHandler(
5915 ::clSetKernelExecInfo(
5917 CL_KERNEL_EXEC_INFO_SVM_PTRS,
5918 sizeof(
void*)*pointerList.size(),
5919 pointerList.data()));
5926 template<
int ArrayLength>
5929 return detail::errHandler(
5930 ::clSetKernelExecInfo(
5932 CL_KERNEL_EXEC_INFO_SVM_PTRS,
5933 sizeof(
void*)*pointerList.size(),
5934 pointerList.data()));
5950 cl_bool svmEnabled_ = svmEnabled ? CL_TRUE : CL_FALSE;
5951 return detail::errHandler(
5952 ::clSetKernelExecInfo(
5954 CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM,
5961 template<
int index,
int ArrayLength,
class D,
typename T0,
typename T1,
typename... Ts>
5962 void setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList,
const pointer<T0, D> &t0,
const pointer<T1, D> &t1, Ts & ... ts)
5964 pointerList[index] =
static_cast<void*
>(t0.get());
5965 setSVMPointersHelper<index + 1, ArrayLength>(pointerList, t1, ts...);
5968 template<
int index,
int ArrayLength,
typename T0,
typename T1,
typename... Ts>
5969 typename std::enable_if<std::is_pointer<T0>::value,
void>::type
5970 setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList, T0 t0, T1 t1, Ts... ts)
5972 pointerList[index] =
static_cast<void*
>(t0);
5973 setSVMPointersHelper<index + 1, ArrayLength>(pointerList, t1, ts...);
5976 template<
int index,
int ArrayLength,
typename T0,
class D>
5977 void setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList,
const pointer<T0, D> &t0)
5979 pointerList[index] =
static_cast<void*
>(t0.get());
5983 template<
int index,
int ArrayLength,
typename T0>
5984 typename std::enable_if<std::is_pointer<T0>::value,
void>::type
5985 setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList, T0 t0)
5987 pointerList[index] =
static_cast<void*
>(t0);
5990 template<
typename T0,
typename... Ts>
5993 std::array<
void*, 1 +
sizeof...(Ts)> pointerList;
5995 setSVMPointersHelper<0, 1 +
sizeof...(Ts)>(pointerList, t0, ts...);
5996 return detail::errHandler(
5997 ::clSetKernelExecInfo(
5999 CL_KERNEL_EXEC_INFO_SVM_PTRS,
6000 sizeof(
void*)*(1 +
sizeof...(Ts)),
6001 pointerList.data()));
6004 template<
typename T>
6005 cl_int setExecInfo(cl_kernel_exec_info param_name,
const T& val)
6007 return detail::errHandler(
6008 ::clSetKernelExecInfo(
6015 template<cl_kernel_exec_info name>
6016 cl_int setExecInfo(
typename detail::param_traits<detail::cl_kernel_exec_info, name>::param_type& val)
6018 return setExecInfo(name, val);
6022#if CL_HPP_TARGET_OPENCL_VERSION >= 210
6031 Kernel retValue(clCloneKernel(this->get(), &error));
6033 detail::errHandler(error, __CLONE_KERNEL_ERR);
6045#if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6046 typedef vector<vector<unsigned char>> Binaries;
6047 typedef vector<string> Sources;
6049 typedef vector<std::pair<const void*, size_type> > Binaries;
6050 typedef vector<std::pair<const char*, size_type> > Sources;
6054 const string& source,
6056 cl_int* err =
nullptr)
6060 const char * strings = source.c_str();
6061 const size_type length = source.size();
6065 object_ = ::clCreateProgramWithSource(
6066 context(), (cl_uint)1, &strings, &length, &error);
6068 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6070 if (error == CL_SUCCESS && build) {
6072 error = ::clBuildProgram(
6076#
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6084 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6087 if (err !=
nullptr) {
6094 const string& source,
6096 cl_int* err =
nullptr)
6100 const char * strings = source.c_str();
6101 const size_type length = source.size();
6103 object_ = ::clCreateProgramWithSource(
6104 context(), (cl_uint)1, &strings, &length, &error);
6106 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6108 if (error == CL_SUCCESS && build) {
6109 error = ::clBuildProgram(
6113#
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6121 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6124 if (err !=
nullptr) {
6134 const Sources& sources,
6135 cl_int* err =
nullptr)
6140 const size_type n = (size_type)sources.size();
6142 vector<size_type> lengths(n);
6143 vector<const char*> strings(n);
6145 for (size_type i = 0; i < n; ++i) {
6146#if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6147 strings[i] = sources[(int)i].data();
6148 lengths[i] = sources[(int)i].length();
6150 strings[i] = sources[(int)i].first;
6151 lengths[i] = sources[(int)i].second;
6155 object_ = ::clCreateProgramWithSource(
6156 context(), (cl_uint)n, strings.data(), lengths.data(), &error);
6158 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6159 if (err !=
nullptr) {
6170 const Sources& sources,
6171 cl_int* err =
nullptr)
6175 const size_type n = (size_type)sources.size();
6177 vector<size_type> lengths(n);
6178 vector<const char*> strings(n);
6180 for (size_type i = 0; i < n; ++i) {
6181#if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6182 strings[i] = sources[(int)i].data();
6183 lengths[i] = sources[(int)i].length();
6185 strings[i] = sources[(int)i].first;
6186 lengths[i] = sources[(int)i].second;
6190 object_ = ::clCreateProgramWithSource(
6191 context(), (cl_uint)n, strings.data(), lengths.data(), &error);
6193 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6194 if (err !=
nullptr) {
6200#if defined(CL_HPP_USE_IL_KHR) || CL_HPP_TARGET_OPENCL_VERSION >= 210
6207 const vector<char>& IL,
6209 cl_int* err =
nullptr)
6215#if CL_HPP_TARGET_OPENCL_VERSION >= 210
6217 object_ = ::clCreateProgramWithIL(
6218 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6222 typedef clCreateProgramWithILKHR_fn PFN_clCreateProgramWithILKHR;
6223 static PFN_clCreateProgramWithILKHR pfn_clCreateProgramWithILKHR =
nullptr;
6224 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateProgramWithILKHR);
6226 object_ = pfn_clCreateProgramWithILKHR(
6227 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6231 detail::errHandler(error, __CREATE_PROGRAM_WITH_IL_ERR);
6233 if (error == CL_SUCCESS && build) {
6235 error = ::clBuildProgram(
6239#
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6247 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6250 if (err !=
nullptr) {
6263 const vector<char>& IL,
6265 cl_int* err =
nullptr)
6269#if CL_HPP_TARGET_OPENCL_VERSION >= 210
6271 object_ = ::clCreateProgramWithIL(
6272 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6276 typedef clCreateProgramWithILKHR_fn PFN_clCreateProgramWithILKHR;
6277 static PFN_clCreateProgramWithILKHR pfn_clCreateProgramWithILKHR =
nullptr;
6278 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateProgramWithILKHR);
6280 object_ = pfn_clCreateProgramWithILKHR(
6281 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6285 detail::errHandler(error, __CREATE_PROGRAM_WITH_IL_ERR);
6287 if (error == CL_SUCCESS && build) {
6288 error = ::clBuildProgram(
6292#
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6300 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6303 if (err !=
nullptr) {
6330 const vector<Device>& devices,
6331 const Binaries& binaries,
6332 vector<cl_int>* binaryStatus =
nullptr,
6333 cl_int* err =
nullptr)
6337 const size_type numDevices = devices.size();
6340 if(binaries.size() != numDevices) {
6341 error = CL_INVALID_VALUE;
6342 detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
6343 if (err !=
nullptr) {
6350 vector<size_type> lengths(numDevices);
6351 vector<const unsigned char*> images(numDevices);
6352#if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6353 for (size_type i = 0; i < numDevices; ++i) {
6354 images[i] = binaries[i].data();
6355 lengths[i] = binaries[(int)i].size();
6358 for (size_type i = 0; i < numDevices; ++i) {
6359 images[i] = (
const unsigned char*)binaries[i].first;
6360 lengths[i] = binaries[(int)i].second;
6364 vector<cl_device_id> deviceIDs(numDevices);
6365 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6366 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6370 binaryStatus->resize(numDevices);
6373 object_ = ::clCreateProgramWithBinary(
6374 context(), (cl_uint) devices.size(),
6376 lengths.data(), images.data(), (binaryStatus !=
nullptr && numDevices > 0)
6377 ? &binaryStatus->front()
6380 detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
6381 if (err !=
nullptr) {
6387#if CL_HPP_TARGET_OPENCL_VERSION >= 120
6394 const vector<Device>& devices,
6395 const string& kernelNames,
6396 cl_int* err =
nullptr)
6401 size_type numDevices = devices.size();
6402 vector<cl_device_id> deviceIDs(numDevices);
6403 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6404 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6407 object_ = ::clCreateProgramWithBuiltInKernels(
6409 (cl_uint) devices.size(),
6411 kernelNames.c_str(),
6414 detail::errHandler(error, __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR);
6415 if (err !=
nullptr) {
6430 explicit Program(
const cl_program& program,
bool retainObject =
false) :
6431 detail::Wrapper<cl_type>(program, retainObject) { }
6433 Program& operator = (
const cl_program& rhs)
6441 const vector<Device>& devices,
6442 const char* options =
nullptr,
6443 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
6444 void* data =
nullptr)
const
6446 size_type numDevices = devices.size();
6447 vector<cl_device_id> deviceIDs(numDevices);
6449 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6450 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6453 cl_int buildError = ::clBuildProgram(
6462 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6466 const Device& device,
6467 const char* options =
nullptr,
6468 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
6469 void* data =
nullptr)
const
6471 cl_device_id deviceID = device();
6473 cl_int buildError = ::clBuildProgram(
6481 BuildLogType buildLog(0);
6482 buildLog.push_back(std::make_pair(device, getBuildInfo<CL_PROGRAM_BUILD_LOG>(device)));
6483 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, buildLog);
6487 const char* options =
nullptr,
6488 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
6489 void* data =
nullptr)
const
6491 cl_int buildError = ::clBuildProgram(
6499 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6502#if CL_HPP_TARGET_OPENCL_VERSION >= 120
6504 const char* options =
nullptr,
6505 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
6506 void* data =
nullptr)
const
6508 cl_int error = ::clCompileProgram(
6518 return detail::buildErrHandler(error, __COMPILE_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6522 template <
typename T>
6523 cl_int getInfo(cl_program_info name, T* param)
const
6525 return detail::errHandler(
6526 detail::getInfo(&::clGetProgramInfo, object_, name, param),
6527 __GET_PROGRAM_INFO_ERR);
6530 template <cl_program_info name>
typename
6531 detail::param_traits<detail::cl_program_info, name>::param_type
6532 getInfo(cl_int* err =
nullptr)
const
6534 typename detail::param_traits<
6535 detail::cl_program_info, name>::param_type param;
6536 cl_int result = getInfo(name, ¶m);
6537 if (err !=
nullptr) {
6543 template <
typename T>
6544 cl_int getBuildInfo(
6545 const Device& device, cl_program_build_info name, T* param)
const
6547 return detail::errHandler(
6549 &::clGetProgramBuildInfo, object_, device(), name, param),
6550 __GET_PROGRAM_BUILD_INFO_ERR);
6553 template <cl_program_build_info name>
typename
6554 detail::param_traits<detail::cl_program_build_info, name>::param_type
6555 getBuildInfo(
const Device& device, cl_int* err =
nullptr)
const
6557 typename detail::param_traits<
6558 detail::cl_program_build_info, name>::param_type param;
6559 cl_int result = getBuildInfo(device, name, ¶m);
6560 if (err !=
nullptr) {
6571 template <cl_program_build_info name>
6572 vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, name>::param_type>>
6575 cl_int result = CL_SUCCESS;
6577 auto devs = getInfo<CL_PROGRAM_DEVICES>(&result);
6578 vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, name>::param_type>>
6582 if (result != CL_SUCCESS) {
6583 if (err !=
nullptr) {
6591 detail::cl_program_build_info, name>::param_type param;
6592 result = getBuildInfo(d, name, ¶m);
6596 if (result != CL_SUCCESS) {
6601 if (err !=
nullptr) {
6604 if (result != CL_SUCCESS) {
6610 cl_int createKernels(vector<Kernel>* kernels)
6613 cl_int err = ::clCreateKernelsInProgram(object_, 0,
nullptr, &numKernels);
6614 if (err != CL_SUCCESS) {
6615 return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
6618 vector<cl_kernel> value(numKernels);
6620 err = ::clCreateKernelsInProgram(
6621 object_, numKernels, value.data(),
nullptr);
6622 if (err != CL_SUCCESS) {
6623 return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
6627 kernels->resize(value.size());
6631 for (size_type i = 0; i < value.size(); i++) {
6634 (*kernels)[i] = Kernel(value[i],
false);
6640#if CL_HPP_TARGET_OPENCL_VERSION >= 220
6641#if defined(CL_USE_DEPRECATED_OPENCL_2_2_APIS)
6653 void (CL_CALLBACK * pfn_notify)(cl_program program,
void * user_data),
6654 void * user_data =
nullptr) CL_API_SUFFIX__VERSION_2_2_DEPRECATED
6656 return detail::errHandler(
6657 ::clSetProgramReleaseCallback(
6661 __SET_PROGRAM_RELEASE_CALLBACK_ERR);
6669 template <
typename T>
6670 typename std::enable_if<!std::is_pointer<T>::value, cl_int>::type
6673 return detail::errHandler(
6674 ::clSetProgramSpecializationConstant(
6679 __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR);
6688 return detail::errHandler(
6689 ::clSetProgramSpecializationConstant(
6694 __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR);
6699#if CL_HPP_TARGET_OPENCL_VERSION >= 120
6700inline Program linkProgram(
6701 const Program& input1,
6702 const Program& input2,
6703 const char* options =
nullptr,
6704 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
6705 void* data =
nullptr,
6706 cl_int* err =
nullptr)
6708 cl_int error_local = CL_SUCCESS;
6709 cl_program programs[2] = { input1(), input2() };
6711 Context ctx = input1.getInfo<CL_PROGRAM_CONTEXT>(&error_local);
6712 if(error_local!=CL_SUCCESS) {
6713 detail::errHandler(error_local, __LINK_PROGRAM_ERR);
6716 cl_program prog = ::clLinkProgram(
6727 detail::errHandler(error_local,__COMPILE_PROGRAM_ERR);
6728 if (err !=
nullptr) {
6732 return Program(prog);
6735inline Program linkProgram(
6736 const vector<Program>& inputPrograms,
6737 const char* options =
nullptr,
6738 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
6739 void* data =
nullptr,
6740 cl_int* err =
nullptr)
6742 cl_int error_local = CL_SUCCESS;
6745 static_assert(
sizeof(
cl::Program) ==
sizeof(cl_program),
6746 "Size of cl::Program must be equal to size of cl_program");
6748 if(inputPrograms.size() > 0) {
6749 ctx = inputPrograms[0].getInfo<CL_PROGRAM_CONTEXT>(&error_local);
6750 if(error_local!=CL_SUCCESS) {
6751 detail::errHandler(error_local, __LINK_PROGRAM_ERR);
6755 cl_program prog = ::clLinkProgram(
6760 static_cast<cl_uint
>(inputPrograms.size()),
6761 reinterpret_cast<const cl_program *
>(inputPrograms.data()),
6766 detail::errHandler(error_local,__COMPILE_PROGRAM_ERR);
6767 if (err !=
nullptr) {
6771 return Program(prog);
6777inline cl_int cl::Program::getInfo(cl_program_info name, vector<vector<unsigned char>>* param)
const
6779 if (name != CL_PROGRAM_BINARIES) {
6780 return CL_INVALID_VALUE;
6786 vector<size_type> sizes = getInfo<CL_PROGRAM_BINARY_SIZES>();
6787 size_type numBinaries = sizes.size();
6790 param->resize(numBinaries);
6791 for (size_type i = 0; i < numBinaries; ++i) {
6792 (*param)[i].resize(sizes[i]);
6795 return detail::errHandler(
6796 detail::getInfo(&::clGetProgramInfo, object_, name, param),
6797 __GET_PROGRAM_INFO_ERR);
6804inline vector<vector<unsigned char>> cl::Program::getInfo<CL_PROGRAM_BINARIES>(cl_int* err)
const
6806 vector<vector<unsigned char>> binariesVectors;
6808 cl_int result = getInfo(CL_PROGRAM_BINARIES, &binariesVectors);
6809 if (err !=
nullptr) {
6812 return binariesVectors;
6815#if CL_HPP_TARGET_OPENCL_VERSION >= 220
6820 cl_uchar ucValue = value ? CL_UCHAR_MAX : 0;
6821 return detail::errHandler(
6822 ::clSetProgramSpecializationConstant(
6827 __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR);
6831inline Kernel::Kernel(
const Program& program,
const char* name, cl_int* err)
6835 object_ = ::clCreateKernel(program(), name, &error);
6836 detail::errHandler(error, __CREATE_KERNEL_ERR);
6838 if (err !=
nullptr) {
6844#ifdef cl_khr_external_memory
6845enum class ExternalMemoryType : cl_external_memory_handle_type_khr
6849 OpaqueFd = CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_FD_KHR,
6850 OpaqueWin32 = CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KHR,
6851 OpaqueWin32Kmt = CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KMT_KHR,
6853 D3D11Texture = CL_EXTERNAL_MEMORY_HANDLE_D3D11_TEXTURE_KHR,
6854 D3D11TextureKmt = CL_EXTERNAL_MEMORY_HANDLE_D3D11_TEXTURE_KMT_KHR,
6856 D3D12Heap = CL_EXTERNAL_MEMORY_HANDLE_D3D12_HEAP_KHR,
6857 D3D12Resource = CL_EXTERNAL_MEMORY_HANDLE_D3D12_RESOURCE_KHR,
6859 DmaBuf = CL_EXTERNAL_MEMORY_HANDLE_DMA_BUF_KHR,
6863enum class QueueProperties : cl_command_queue_properties
6866 Profiling = CL_QUEUE_PROFILING_ENABLE,
6867 OutOfOrder = CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE,
6870inline QueueProperties operator|(QueueProperties lhs, QueueProperties rhs)
6872 return static_cast<QueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) |
static_cast<cl_command_queue_properties
>(rhs));
6875inline QueueProperties operator&(QueueProperties lhs, QueueProperties rhs)
6877 return static_cast<QueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) &
static_cast<cl_command_queue_properties
>(rhs));
6886 static std::once_flag default_initialized_;
6888 static cl_int default_error_;
6895 static void makeDefault()
6900#if defined(CL_HPP_ENABLE_EXCEPTIONS)
6907 if (error != CL_SUCCESS) {
6908 default_error_ = error;
6912 default_ =
CommandQueue(context, device, 0, &default_error_);
6915#if defined(CL_HPP_ENABLE_EXCEPTIONS)
6916 catch (cl::Error &e) {
6917 default_error_ = e.err();
6927 static void makeDefaultProvided(
const CommandQueue &c) {
6931#ifdef cl_khr_external_memory
6932 static std::once_flag ext_memory_initialized_;
6934 static void initMemoryExtension(
const cl::Device& device)
6936 auto platform = device.
getInfo<CL_DEVICE_PLATFORM>();
6938 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueAcquireExternalMemObjectsKHR);
6939 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueReleaseExternalMemObjectsKHR);
6941 if ((pfn_clEnqueueAcquireExternalMemObjectsKHR ==
nullptr)
6942 && (pfn_clEnqueueReleaseExternalMemObjectsKHR ==
nullptr))
6944 detail::errHandler(CL_INVALID_VALUE, __ENQUEUE_ACQUIRE_EXTERNAL_MEMORY_ERR);
6950#ifdef CL_HPP_UNIT_TEST_ENABLE
6957 static void unitTestClearDefault() {
6968 cl_command_queue_properties properties,
6969 cl_int* err =
nullptr)
6974 detail::errHandler(error, __CREATE_CONTEXT_ERR);
6976 if (error != CL_SUCCESS) {
6977 if (err !=
nullptr) {
6983 bool useWithProperties;
6985#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
6988 cl_uint version = detail::getContextPlatformVersion(context());
6989 useWithProperties = (version >= 0x20000);
6991#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
6992 useWithProperties =
true;
6994 useWithProperties =
false;
6997#if CL_HPP_TARGET_OPENCL_VERSION >= 200
6998 if (useWithProperties) {
6999 cl_queue_properties queue_properties[] = {
7000 CL_QUEUE_PROPERTIES, properties, 0 };
7001 if ((properties & CL_QUEUE_ON_DEVICE) == 0) {
7002 object_ = ::clCreateCommandQueueWithProperties(
7003 context(), device(), queue_properties, &error);
7006 error = CL_INVALID_QUEUE_PROPERTIES;
7009 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7010 if (err !=
nullptr) {
7015#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7016 if (!useWithProperties) {
7017 object_ = ::clCreateCommandQueue(
7018 context(), device(), properties, &error);
7020 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7021 if (err !=
nullptr) {
7034 QueueProperties properties,
7035 cl_int* err =
nullptr)
7040 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7042 if (error != CL_SUCCESS) {
7043 if (err !=
nullptr) {
7049 bool useWithProperties;
7051#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7054 cl_uint version = detail::getContextPlatformVersion(context());
7055 useWithProperties = (version >= 0x20000);
7057#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7058 useWithProperties =
true;
7060 useWithProperties =
false;
7063#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7064 if (useWithProperties) {
7065 cl_queue_properties queue_properties[] = {
7066 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
7068 object_ = ::clCreateCommandQueueWithProperties(
7069 context(), device(), queue_properties, &error);
7071 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7072 if (err !=
nullptr) {
7077#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7078 if (!useWithProperties) {
7079 object_ = ::clCreateCommandQueue(
7080 context(), device(),
static_cast<cl_command_queue_properties
>(properties), &error);
7082 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7083 if (err !=
nullptr) {
7098 cl_command_queue_properties properties = 0,
7099 cl_int* err =
nullptr)
7102 bool useWithProperties;
7103 vector<cl::Device> devices;
7104 error = context.
getInfo(CL_CONTEXT_DEVICES, &devices);
7106 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7108 if (error != CL_SUCCESS)
7110 if (err !=
nullptr) {
7116#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7119 cl_uint version = detail::getContextPlatformVersion(context());
7120 useWithProperties = (version >= 0x20000);
7122#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7123 useWithProperties =
true;
7125 useWithProperties =
false;
7128#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7129 if (useWithProperties) {
7130 cl_queue_properties queue_properties[] = {
7131 CL_QUEUE_PROPERTIES, properties, 0 };
7132 if ((properties & CL_QUEUE_ON_DEVICE) == 0) {
7133 object_ = ::clCreateCommandQueueWithProperties(
7134 context(), devices[0](), queue_properties, &error);
7137 error = CL_INVALID_QUEUE_PROPERTIES;
7140 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7141 if (err !=
nullptr) {
7146#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7147 if (!useWithProperties) {
7148 object_ = ::clCreateCommandQueue(
7149 context(), devices[0](), properties, &error);
7151 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7152 if (err !=
nullptr) {
7165 QueueProperties properties,
7166 cl_int* err =
nullptr)
7169 bool useWithProperties;
7170 vector<cl::Device> devices;
7171 error = context.
getInfo(CL_CONTEXT_DEVICES, &devices);
7173 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7175 if (error != CL_SUCCESS)
7177 if (err !=
nullptr) {
7183#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7186 cl_uint version = detail::getContextPlatformVersion(context());
7187 useWithProperties = (version >= 0x20000);
7189#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7190 useWithProperties =
true;
7192 useWithProperties =
false;
7195#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7196 if (useWithProperties) {
7197 cl_queue_properties queue_properties[] = {
7198 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
7199 object_ = ::clCreateCommandQueueWithProperties(
7200 context(), devices[0](), queue_properties, &error);
7202 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7203 if (err !=
nullptr) {
7208#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7209 if (!useWithProperties) {
7210 object_ = ::clCreateCommandQueue(
7211 context(), devices[0](),
static_cast<cl_command_queue_properties
>(properties), &error);
7213 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7214 if (err !=
nullptr) {
7228 cl_command_queue_properties properties = 0,
7229 cl_int* err =
nullptr)
7232 bool useWithProperties;
7234#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7237 cl_uint version = detail::getContextPlatformVersion(context());
7238 useWithProperties = (version >= 0x20000);
7240#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7241 useWithProperties =
true;
7243 useWithProperties =
false;
7246#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7247 if (useWithProperties) {
7248 cl_queue_properties queue_properties[] = {
7249 CL_QUEUE_PROPERTIES, properties, 0 };
7250 object_ = ::clCreateCommandQueueWithProperties(
7251 context(), device(), queue_properties, &error);
7253 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7254 if (err !=
nullptr) {
7259#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7260 if (!useWithProperties) {
7261 object_ = ::clCreateCommandQueue(
7262 context(), device(), properties, &error);
7264 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7265 if (err !=
nullptr) {
7279 QueueProperties properties,
7280 cl_int* err =
nullptr)
7283 bool useWithProperties;
7285#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7288 cl_uint version = detail::getContextPlatformVersion(context());
7289 useWithProperties = (version >= 0x20000);
7291#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7292 useWithProperties =
true;
7294 useWithProperties =
false;
7297#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7298 if (useWithProperties) {
7299 cl_queue_properties queue_properties[] = {
7300 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
7301 object_ = ::clCreateCommandQueueWithProperties(
7302 context(), device(), queue_properties, &error);
7304 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7305 if (err !=
nullptr) {
7310#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7311 if (!useWithProperties) {
7312 object_ = ::clCreateCommandQueue(
7313 context(), device(),
static_cast<cl_command_queue_properties
>(properties), &error);
7315 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7316 if (err !=
nullptr) {
7325 std::call_once(default_initialized_, makeDefault);
7326#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7327 detail::errHandler(default_error_, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7329 detail::errHandler(default_error_, __CREATE_COMMAND_QUEUE_ERR);
7331 if (err !=
nullptr) {
7332 *err = default_error_;
7346 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_queue));
7347 detail::errHandler(default_error_);
7360 explicit CommandQueue(
const cl_command_queue& commandQueue,
bool retainObject =
false) :
7361 detail::Wrapper<cl_type>(commandQueue, retainObject) { }
7369 template <
typename T>
7370 cl_int getInfo(cl_command_queue_info name, T* param)
const
7372 return detail::errHandler(
7374 &::clGetCommandQueueInfo, object_, name, param),
7375 __GET_COMMAND_QUEUE_INFO_ERR);
7378 template <cl_command_queue_info name>
typename
7379 detail::param_traits<detail::cl_command_queue_info, name>::param_type
7380 getInfo(cl_int* err =
nullptr)
const
7382 typename detail::param_traits<
7383 detail::cl_command_queue_info, name>::param_type param;
7384 cl_int result = getInfo(name, ¶m);
7385 if (err !=
nullptr) {
7391 cl_int enqueueReadBuffer(
7392 const Buffer& buffer,
7397 const vector<Event>* events =
nullptr,
7398 Event* event =
nullptr)
const
7401 cl_int err = detail::errHandler(
7402 ::clEnqueueReadBuffer(
7403 object_, buffer(), blocking, offset, size,
7405 (events !=
nullptr) ? (cl_uint) events->size() : 0,
7406 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
7407 (event !=
nullptr) ? &tmp :
nullptr),
7408 __ENQUEUE_READ_BUFFER_ERR);
7410 if (event !=
nullptr && err == CL_SUCCESS)
7416 cl_int enqueueWriteBuffer(
7417 const Buffer& buffer,
7422 const vector<Event>* events =
nullptr,
7423 Event* event =
nullptr)
const
7426 cl_int err = detail::errHandler(
7427 ::clEnqueueWriteBuffer(
7428 object_, buffer(), blocking, offset, size,
7430 (events !=
nullptr) ? (cl_uint) events->size() : 0,
7431 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
7432 (event !=
nullptr) ? &tmp :
nullptr),
7433 __ENQUEUE_WRITE_BUFFER_ERR);
7435 if (event !=
nullptr && err == CL_SUCCESS)
7441 cl_int enqueueCopyBuffer(
7444 size_type src_offset,
7445 size_type dst_offset,
7447 const vector<Event>* events =
nullptr,
7448 Event* event =
nullptr)
const
7451 cl_int err = detail::errHandler(
7452 ::clEnqueueCopyBuffer(
7453 object_, src(), dst(), src_offset, dst_offset, size,
7454 (events !=
nullptr) ? (cl_uint) events->size() : 0,
7455 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
7456 (event !=
nullptr) ? &tmp :
nullptr),
7457 __ENQEUE_COPY_BUFFER_ERR);
7459 if (event !=
nullptr && err == CL_SUCCESS)
7464#if CL_HPP_TARGET_OPENCL_VERSION >= 110
7465 cl_int enqueueReadBufferRect(
7466 const Buffer& buffer,
7468 const array<size_type, 3>& buffer_offset,
7469 const array<size_type, 3>& host_offset,
7470 const array<size_type, 3>& region,
7471 size_type buffer_row_pitch,
7472 size_type buffer_slice_pitch,
7473 size_type host_row_pitch,
7474 size_type host_slice_pitch,
7476 const vector<Event>* events =
nullptr,
7477 Event* event =
nullptr)
const
7480 cl_int err = detail::errHandler(
7481 ::clEnqueueReadBufferRect(
7485 buffer_offset.data(),
7493 (events !=
nullptr) ? (cl_uint) events->size() : 0,
7494 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
7495 (event !=
nullptr) ? &tmp :
nullptr),
7496 __ENQUEUE_READ_BUFFER_RECT_ERR);
7498 if (event !=
nullptr && err == CL_SUCCESS)
7504 cl_int enqueueReadBufferRect(
7505 const Buffer& buffer,
7507 const array<size_type, 2>& buffer_offset,
7508 const array<size_type, 2>& host_offset,
7509 const array<size_type, 2>& region,
7510 size_type buffer_row_pitch,
7511 size_type buffer_slice_pitch,
7512 size_type host_row_pitch,
7513 size_type host_slice_pitch,
7515 const vector<Event>* events =
nullptr,
7516 Event* event =
nullptr)
const
7518 return enqueueReadBufferRect(
7521 { buffer_offset[0], buffer_offset[1], 0 },
7522 { host_offset[0], host_offset[1], 0 },
7523 { region[0], region[1], 1 },
7533 cl_int enqueueWriteBufferRect(
7534 const Buffer& buffer,
7536 const array<size_type, 3>& buffer_offset,
7537 const array<size_type, 3>& host_offset,
7538 const array<size_type, 3>& region,
7539 size_type buffer_row_pitch,
7540 size_type buffer_slice_pitch,
7541 size_type host_row_pitch,
7542 size_type host_slice_pitch,
7544 const vector<Event>* events =
nullptr,
7545 Event* event =
nullptr)
const
7548 cl_int err = detail::errHandler(
7549 ::clEnqueueWriteBufferRect(
7553 buffer_offset.data(),
7561 (events !=
nullptr) ? (cl_uint) events->size() : 0,
7562 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
7563 (event !=
nullptr) ? &tmp :
nullptr),
7564 __ENQUEUE_WRITE_BUFFER_RECT_ERR);
7566 if (event !=
nullptr && err == CL_SUCCESS)
7572 cl_int enqueueWriteBufferRect(
7573 const Buffer& buffer,
7575 const array<size_type, 2>& buffer_offset,
7576 const array<size_type, 2>& host_offset,
7577 const array<size_type, 2>& region,
7578 size_type buffer_row_pitch,
7579 size_type buffer_slice_pitch,
7580 size_type host_row_pitch,
7581 size_type host_slice_pitch,
7583 const vector<Event>* events =
nullptr,
7584 Event* event =
nullptr)
const
7586 return enqueueWriteBufferRect(
7589 { buffer_offset[0], buffer_offset[1], 0 },
7590 { host_offset[0], host_offset[1], 0 },
7591 { region[0], region[1], 1 },
7601 cl_int enqueueCopyBufferRect(
7604 const array<size_type, 3>& src_origin,
7605 const array<size_type, 3>& dst_origin,
7606 const array<size_type, 3>& region,
7607 size_type src_row_pitch,
7608 size_type src_slice_pitch,
7609 size_type dst_row_pitch,
7610 size_type dst_slice_pitch,
7611 const vector<Event>* events =
nullptr,
7612 Event* event =
nullptr)
const
7615 cl_int err = detail::errHandler(
7616 ::clEnqueueCopyBufferRect(
7627 (events !=
nullptr) ? (cl_uint) events->size() : 0,
7628 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
7629 (event !=
nullptr) ? &tmp :
nullptr),
7630 __ENQEUE_COPY_BUFFER_RECT_ERR);
7632 if (event !=
nullptr && err == CL_SUCCESS)
7638 cl_int enqueueCopyBufferRect(
7641 const array<size_type, 2>& src_origin,
7642 const array<size_type, 2>& dst_origin,
7643 const array<size_type, 2>& region,
7644 size_type src_row_pitch,
7645 size_type src_slice_pitch,
7646 size_type dst_row_pitch,
7647 size_type dst_slice_pitch,
7648 const vector<Event>* events =
nullptr,
7649 Event* event =
nullptr)
const
7651 return enqueueCopyBufferRect(
7654 { src_origin[0], src_origin[1], 0 },
7655 { dst_origin[0], dst_origin[1], 0 },
7656 { region[0], region[1], 1 },
7666#if CL_HPP_TARGET_OPENCL_VERSION >= 120
7678 template<
typename PatternType>
7681 PatternType pattern,
7684 const vector<Event>* events =
nullptr,
7685 Event* event =
nullptr)
const
7688 cl_int err = detail::errHandler(
7689 ::clEnqueueFillBuffer(
7692 static_cast<void*
>(&pattern),
7693 sizeof(PatternType),
7696 (events !=
nullptr) ? (cl_uint) events->size() : 0,
7697 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
7698 (event !=
nullptr) ? &tmp :
nullptr),
7699 __ENQUEUE_FILL_BUFFER_ERR);
7701 if (event !=
nullptr && err == CL_SUCCESS)
7708 cl_int enqueueReadImage(
7711 const array<size_type, 3>& origin,
7712 const array<size_type, 3>& region,
7713 size_type row_pitch,
7714 size_type slice_pitch,
7716 const vector<Event>* events =
nullptr,
7717 Event* event =
nullptr)
const
7720 cl_int err = detail::errHandler(
7721 ::clEnqueueReadImage(
7730 (events !=
nullptr) ? (cl_uint) events->size() : 0,
7731 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
7732 (event !=
nullptr) ? &tmp :
nullptr),
7733 __ENQUEUE_READ_IMAGE_ERR);
7735 if (event !=
nullptr && err == CL_SUCCESS)
7741 cl_int enqueueReadImage(
7744 const array<size_type, 2>& origin,
7745 const array<size_type, 2>& region,
7746 size_type row_pitch,
7747 size_type slice_pitch,
7749 const vector<Event>* events =
nullptr,
7750 Event* event =
nullptr)
const
7752 return enqueueReadImage(
7755 { origin[0], origin[1], 0 },
7756 { region[0], region[1], 1 },
7764 cl_int enqueueWriteImage(
7767 const array<size_type, 3>& origin,
7768 const array<size_type, 3>& region,
7769 size_type row_pitch,
7770 size_type slice_pitch,
7772 const vector<Event>* events =
nullptr,
7773 Event* event =
nullptr)
const
7776 cl_int err = detail::errHandler(
7777 ::clEnqueueWriteImage(
7786 (events !=
nullptr) ? (cl_uint) events->size() : 0,
7787 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
7788 (event !=
nullptr) ? &tmp :
nullptr),
7789 __ENQUEUE_WRITE_IMAGE_ERR);
7791 if (event !=
nullptr && err == CL_SUCCESS)
7797 cl_int enqueueWriteImage(
7800 const array<size_type, 2>& origin,
7801 const array<size_type, 2>& region,
7802 size_type row_pitch,
7803 size_type slice_pitch,
7805 const vector<Event>* events =
nullptr,
7806 Event* event =
nullptr)
const
7808 return enqueueWriteImage(
7811 { origin[0], origin[1], 0 },
7812 { region[0], region[1], 1 },
7820 cl_int enqueueCopyImage(
7823 const array<size_type, 3>& src_origin,
7824 const array<size_type, 3>& dst_origin,
7825 const array<size_type, 3>& region,
7826 const vector<Event>* events =
nullptr,
7827 Event* event =
nullptr)
const
7830 cl_int err = detail::errHandler(
7831 ::clEnqueueCopyImage(
7838 (events !=
nullptr) ? (cl_uint) events->size() : 0,
7839 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
7840 (event !=
nullptr) ? &tmp :
nullptr),
7841 __ENQUEUE_COPY_IMAGE_ERR);
7843 if (event !=
nullptr && err == CL_SUCCESS)
7849 cl_int enqueueCopyImage(
7852 const array<size_type, 2>& src_origin,
7853 const array<size_type, 2>& dst_origin,
7854 const array<size_type, 2>& region,
7855 const vector<Event>* events =
nullptr,
7856 Event* event =
nullptr)
const
7858 return enqueueCopyImage(
7861 { src_origin[0], src_origin[1], 0 },
7862 { dst_origin[0], dst_origin[1], 0 },
7863 { region[0], region[1], 1 },
7868#if CL_HPP_TARGET_OPENCL_VERSION >= 120
7876 template <
typename T>
7877 typename std::enable_if<std::is_same<T, cl_float4>::value ||
7878 std::is_same<T, cl_int4 >::value ||
7879 std::is_same<T, cl_uint4 >::value,
7884 const array<size_type, 3>& origin,
7885 const array<size_type, 3>& region,
7886 const vector<Event>* events =
nullptr,
7887 Event* event =
nullptr)
const
7890 cl_int err = detail::errHandler(
7891 ::clEnqueueFillImage(
7894 static_cast<void*
>(&fillColor),
7897 (events !=
nullptr) ? (cl_uint)events->size() : 0,
7898 (events !=
nullptr && events->size() > 0) ? (cl_event*)&events->front() : NULL,
7899 (event != NULL) ? &tmp :
nullptr),
7900 __ENQUEUE_FILL_IMAGE_ERR);
7902 if (event !=
nullptr && err == CL_SUCCESS) *
event = tmp;
7914 template <
typename T>
7915 typename std::enable_if<std::is_same<T, cl_float4>::value ||
7916 std::is_same<T, cl_int4 >::value ||
7917 std::is_same<T, cl_uint4 >::value, cl_int>::type
7921 const array<size_type, 2>& origin,
7922 const array<size_type, 2>& region,
7923 const vector<Event>* events =
nullptr,
7924 Event* event =
nullptr)
const
7929 { origin[0], origin[1], 0 },
7930 { region[0], region[1], 1 },
7937 cl_int enqueueCopyImageToBuffer(
7940 const array<size_type, 3>& src_origin,
7941 const array<size_type, 3>& region,
7942 size_type dst_offset,
7943 const vector<Event>* events =
nullptr,
7944 Event* event =
nullptr)
const
7947 cl_int err = detail::errHandler(
7948 ::clEnqueueCopyImageToBuffer(
7955 (events !=
nullptr) ? (cl_uint) events->size() : 0,
7956 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
7957 (event !=
nullptr) ? &tmp :
nullptr),
7958 __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR);
7960 if (event !=
nullptr && err == CL_SUCCESS)
7966 cl_int enqueueCopyImageToBuffer(
7969 const array<size_type, 2>& src_origin,
7970 const array<size_type, 2>& region,
7971 size_type dst_offset,
7972 const vector<Event>* events =
nullptr,
7973 Event* event =
nullptr)
const
7975 return enqueueCopyImageToBuffer(
7978 { src_origin[0], src_origin[1], 0 },
7979 { region[0], region[1], 1 },
7985 cl_int enqueueCopyBufferToImage(
7988 size_type src_offset,
7989 const array<size_type, 3>& dst_origin,
7990 const array<size_type, 3>& region,
7991 const vector<Event>* events =
nullptr,
7992 Event* event =
nullptr)
const
7995 cl_int err = detail::errHandler(
7996 ::clEnqueueCopyBufferToImage(
8003 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8004 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
8005 (event !=
nullptr) ? &tmp :
nullptr),
8006 __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR);
8008 if (event !=
nullptr && err == CL_SUCCESS)
8014 cl_int enqueueCopyBufferToImage(
8017 size_type src_offset,
8018 const array<size_type, 2>& dst_origin,
8019 const array<size_type, 2>& region,
8020 const vector<Event>* events =
nullptr,
8021 Event* event =
nullptr)
const
8023 return enqueueCopyBufferToImage(
8027 { dst_origin[0], dst_origin[1], 0 },
8028 { region[0], region[1], 1 },
8033 void* enqueueMapBuffer(
8034 const Buffer& buffer,
8039 const vector<Event>* events =
nullptr,
8040 Event* event =
nullptr,
8041 cl_int* err =
nullptr)
const
8045 void * result = ::clEnqueueMapBuffer(
8046 object_, buffer(), blocking, flags, offset, size,
8047 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8048 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
8049 (event !=
nullptr) ? &tmp :
nullptr,
8052 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
8053 if (err !=
nullptr) {
8056 if (event !=
nullptr && error == CL_SUCCESS)
8062 void* enqueueMapImage(
8066 const array<size_type, 3>& origin,
8067 const array<size_type, 3>& region,
8068 size_type * row_pitch,
8069 size_type * slice_pitch,
8070 const vector<Event>* events =
nullptr,
8071 Event* event =
nullptr,
8072 cl_int* err =
nullptr)
const
8076 void * result = ::clEnqueueMapImage(
8077 object_, image(), blocking, flags,
8080 row_pitch, slice_pitch,
8081 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8082 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
8083 (event !=
nullptr) ? &tmp :
nullptr,
8086 detail::errHandler(error, __ENQUEUE_MAP_IMAGE_ERR);
8087 if (err !=
nullptr) {
8090 if (event !=
nullptr && error == CL_SUCCESS)
8095 void* enqueueMapImage(
8099 const array<size_type, 2>& origin,
8100 const array<size_type, 2>& region,
8101 size_type* row_pitch,
8102 size_type* slice_pitch,
8103 const vector<Event>* events =
nullptr,
8104 Event* event =
nullptr,
8105 cl_int* err =
nullptr)
const
8107 return enqueueMapImage(image, blocking, flags,
8108 { origin[0], origin[1], 0 },
8109 { region[0], region[1], 1 }, row_pitch,
8110 slice_pitch, events, event, err);
8113#if CL_HPP_TARGET_OPENCL_VERSION >= 200
8118 template<
typename T>
8124 const vector<Event>* events =
nullptr,
8125 Event* event =
nullptr)
const
8128 cl_int err = detail::errHandler(::clEnqueueSVMMap(
8129 object_, blocking, flags,
static_cast<void*
>(ptr), size,
8130 (events !=
nullptr) ? (cl_uint)events->size() : 0,
8131 (events !=
nullptr && events->size() > 0) ? (cl_event*)&events->front() :
nullptr,
8132 (event !=
nullptr) ? &tmp :
nullptr),
8133 __ENQUEUE_MAP_BUFFER_ERR);
8135 if (event !=
nullptr && err == CL_SUCCESS)
8146 template<
typename T,
class D>
8148 cl::pointer<T, D> &ptr,
8152 const vector<Event>* events =
nullptr,
8153 Event* event =
nullptr)
const
8156 cl_int err = detail::errHandler(::clEnqueueSVMMap(
8157 object_, blocking, flags,
static_cast<void*
>(ptr.get()), size,
8158 (events !=
nullptr) ? (cl_uint)events->size() : 0,
8159 (events !=
nullptr && events->size() > 0) ? (cl_event*)&events->front() :
nullptr,
8160 (event !=
nullptr) ? &tmp :
nullptr),
8161 __ENQUEUE_MAP_BUFFER_ERR);
8163 if (event !=
nullptr && err == CL_SUCCESS)
8173 template<
typename T,
class Alloc>
8175 cl::vector<T, Alloc> &container,
8178 const vector<Event>* events =
nullptr,
8179 Event* event =
nullptr)
const
8182 cl_int err = detail::errHandler(::clEnqueueSVMMap(
8183 object_, blocking, flags,
static_cast<void*
>(container.data()), container.size()*
sizeof(T),
8184 (events !=
nullptr) ? (cl_uint)events->size() : 0,
8185 (events !=
nullptr && events->size() > 0) ? (cl_event*)&events->front() :
nullptr,
8186 (event !=
nullptr) ? &tmp :
nullptr),
8187 __ENQUEUE_MAP_BUFFER_ERR);
8189 if (event !=
nullptr && err == CL_SUCCESS)
8196 cl_int enqueueUnmapMemObject(
8199 const vector<Event>* events =
nullptr,
8200 Event* event =
nullptr)
const
8203 cl_int err = detail::errHandler(
8204 ::clEnqueueUnmapMemObject(
8205 object_, memory(), mapped_ptr,
8206 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8207 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
8208 (event !=
nullptr) ? &tmp :
nullptr),
8209 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8211 if (event !=
nullptr && err == CL_SUCCESS)
8218#if CL_HPP_TARGET_OPENCL_VERSION >= 200
8223 template<
typename T>
8226 const vector<Event>* events =
nullptr,
8227 Event* event =
nullptr)
const
8230 cl_int err = detail::errHandler(
8231 ::clEnqueueSVMUnmap(
8232 object_,
static_cast<void*
>(ptr),
8233 (events !=
nullptr) ? (cl_uint)events->size() : 0,
8234 (events !=
nullptr && events->size() > 0) ? (cl_event*)&events->front() :
nullptr,
8235 (event !=
nullptr) ? &tmp :
nullptr),
8236 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8238 if (event !=
nullptr && err == CL_SUCCESS)
8248 template<
typename T,
class D>
8250 cl::pointer<T, D> &ptr,
8251 const vector<Event>* events =
nullptr,
8252 Event* event =
nullptr)
const
8255 cl_int err = detail::errHandler(
8256 ::clEnqueueSVMUnmap(
8257 object_,
static_cast<void*
>(ptr.get()),
8258 (events !=
nullptr) ? (cl_uint)events->size() : 0,
8259 (events !=
nullptr && events->size() > 0) ? (cl_event*)&events->front() :
nullptr,
8260 (event !=
nullptr) ? &tmp :
nullptr),
8261 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8263 if (event !=
nullptr && err == CL_SUCCESS)
8273 template<
typename T,
class Alloc>
8275 cl::vector<T, Alloc> &container,
8276 const vector<Event>* events =
nullptr,
8277 Event* event =
nullptr)
const
8280 cl_int err = detail::errHandler(
8281 ::clEnqueueSVMUnmap(
8282 object_,
static_cast<void*
>(container.data()),
8283 (events !=
nullptr) ? (cl_uint)events->size() : 0,
8284 (events !=
nullptr && events->size() > 0) ? (cl_event*)&events->front() :
nullptr,
8285 (event !=
nullptr) ? &tmp :
nullptr),
8286 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8288 if (event !=
nullptr && err == CL_SUCCESS)
8295#if CL_HPP_TARGET_OPENCL_VERSION >= 120
8308 const vector<Event> *events =
nullptr,
8309 Event *event =
nullptr)
const
8312 cl_int err = detail::errHandler(
8313 ::clEnqueueMarkerWithWaitList(
8315 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8316 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
8317 (event !=
nullptr) ? &tmp :
nullptr),
8318 __ENQUEUE_MARKER_WAIT_LIST_ERR);
8320 if (event !=
nullptr && err == CL_SUCCESS)
8338 const vector<Event> *events =
nullptr,
8339 Event *event =
nullptr)
const
8342 cl_int err = detail::errHandler(
8343 ::clEnqueueBarrierWithWaitList(
8345 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8346 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
8347 (event !=
nullptr) ? &tmp :
nullptr),
8348 __ENQUEUE_BARRIER_WAIT_LIST_ERR);
8350 if (event !=
nullptr && err == CL_SUCCESS)
8361 const vector<Memory> &memObjects,
8362 cl_mem_migration_flags flags,
8363 const vector<Event>* events =
nullptr,
8364 Event* event =
nullptr
8369 vector<cl_mem> localMemObjects(memObjects.size());
8371 for(
int i = 0; i < (int)memObjects.size(); ++i ) {
8372 localMemObjects[i] = memObjects[i]();
8375 cl_int err = detail::errHandler(
8376 ::clEnqueueMigrateMemObjects(
8378 (cl_uint)memObjects.size(),
8379 localMemObjects.data(),
8381 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8382 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
8383 (event !=
nullptr) ? &tmp :
nullptr),
8384 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8386 if (event !=
nullptr && err == CL_SUCCESS)
8394#if CL_HPP_TARGET_OPENCL_VERSION >= 210
8400 template<
typename T>
8402 const cl::vector<T*> &svmRawPointers,
8403 const cl::vector<size_type> &sizes,
8404 cl_mem_migration_flags flags = 0,
8405 const vector<Event>* events =
nullptr,
8406 Event* event =
nullptr)
const
8409 cl_int err = detail::errHandler(::clEnqueueSVMMigrateMem(
8411 svmRawPointers.size(),
static_cast<void**
>(svmRawPointers.data()),
8414 (events !=
nullptr) ? (cl_uint)events->size() : 0,
8415 (events !=
nullptr && events->size() > 0) ? (cl_event*)&events->front() :
nullptr,
8416 (event !=
nullptr) ? &tmp :
nullptr),
8417 __ENQUEUE_MIGRATE_SVM_ERR);
8419 if (event !=
nullptr && err == CL_SUCCESS)
8429 template<
typename T>
8431 const cl::vector<T*> &svmRawPointers,
8432 cl_mem_migration_flags flags = 0,
8433 const vector<Event>* events =
nullptr,
8434 Event* event =
nullptr)
const
8436 return enqueueMigrateSVM(svmRawPointers, cl::vector<size_type>(svmRawPointers.size()), flags, events, event);
8445 template<
typename T,
class D>
8447 const cl::vector<cl::pointer<T, D>> &svmPointers,
8448 const cl::vector<size_type> &sizes,
8449 cl_mem_migration_flags flags = 0,
8450 const vector<Event>* events =
nullptr,
8451 Event* event =
nullptr)
const
8453 cl::vector<void*> svmRawPointers;
8454 svmRawPointers.reserve(svmPointers.size());
8455 for (
auto p : svmPointers) {
8456 svmRawPointers.push_back(
static_cast<void*
>(p.get()));
8467 template<
typename T,
class D>
8469 const cl::vector<cl::pointer<T, D>> &svmPointers,
8470 cl_mem_migration_flags flags = 0,
8471 const vector<Event>* events =
nullptr,
8472 Event* event =
nullptr)
const
8474 return enqueueMigrateSVM(svmPointers, cl::vector<size_type>(svmPointers.size()), flags, events, event);
8482 template<
typename T,
class Alloc>
8484 const cl::vector<cl::vector<T, Alloc>> &svmContainers,
8485 const cl::vector<size_type> &sizes,
8486 cl_mem_migration_flags flags = 0,
8487 const vector<Event>* events =
nullptr,
8488 Event* event =
nullptr)
const
8490 cl::vector<void*> svmRawPointers;
8491 svmRawPointers.reserve(svmContainers.size());
8492 for (
auto p : svmContainers) {
8493 svmRawPointers.push_back(
static_cast<void*
>(p.data()));
8503 template<
typename T,
class Alloc>
8505 const cl::vector<cl::vector<T, Alloc>> &svmContainers,
8506 cl_mem_migration_flags flags = 0,
8507 const vector<Event>* events =
nullptr,
8508 Event* event =
nullptr)
const
8510 return enqueueMigrateSVM(svmContainers, cl::vector<size_type>(svmContainers.size()), flags, events, event);
8515 cl_int enqueueNDRangeKernel(
8519 const NDRange& local = NullRange,
8520 const vector<Event>* events =
nullptr,
8521 Event* event =
nullptr)
const
8524 cl_int err = detail::errHandler(
8525 ::clEnqueueNDRangeKernel(
8526 object_, kernel(), (cl_uint) global.
dimensions(),
8527 offset.
dimensions() != 0 ? (
const size_type*) offset :
nullptr,
8528 (
const size_type*) global,
8529 local.dimensions() != 0 ? (
const size_type*) local :
nullptr,
8530 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8531 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
8532 (event !=
nullptr) ? &tmp :
nullptr),
8533 __ENQUEUE_NDRANGE_KERNEL_ERR);
8535 if (event !=
nullptr && err == CL_SUCCESS)
8541#if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
8542 CL_API_PREFIX__VERSION_1_2_DEPRECATED cl_int enqueueTask(
8543 const Kernel& kernel,
8544 const vector<Event>* events =
nullptr,
8545 Event* event =
nullptr) const CL_API_SUFFIX__VERSION_1_2_DEPRECATED
8548 cl_int err = detail::errHandler(
8551 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8552 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
8553 (event !=
nullptr) ? &tmp :
nullptr),
8554 __ENQUEUE_TASK_ERR);
8556 if (event !=
nullptr && err == CL_SUCCESS)
8563 cl_int enqueueNativeKernel(
8564 void (CL_CALLBACK *userFptr)(
void *),
8565 std::pair<void*, size_type> args,
8566 const vector<Memory>* mem_objects =
nullptr,
8567 const vector<const void*>* mem_locs =
nullptr,
8568 const vector<Event>* events =
nullptr,
8569 Event* event =
nullptr)
const
8572 cl_int err = detail::errHandler(
8573 ::clEnqueueNativeKernel(
8574 object_, userFptr, args.first, args.second,
8575 (mem_objects !=
nullptr) ? (cl_uint) mem_objects->size() : 0,
8576 (mem_objects->size() > 0 ) ?
reinterpret_cast<const cl_mem *
>(mem_objects->data()) :
nullptr,
8577 (mem_locs !=
nullptr && mem_locs->size() > 0) ? (
const void **) &mem_locs->front() :
nullptr,
8578 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8579 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
8580 (event !=
nullptr) ? &tmp :
nullptr),
8581 __ENQUEUE_NATIVE_KERNEL);
8583 if (event !=
nullptr && err == CL_SUCCESS)
8592#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
8593 CL_API_PREFIX__VERSION_1_1_DEPRECATED
8597 cl_int err = detail::errHandler(
8600 (event !=
nullptr) ? &tmp :
nullptr),
8601 __ENQUEUE_MARKER_ERR);
8603 if (event !=
nullptr && err == CL_SUCCESS)
8609 CL_API_PREFIX__VERSION_1_1_DEPRECATED
8610 cl_int enqueueWaitForEvents(
const vector<Event>& events)
const CL_API_SUFFIX__VERSION_1_1_DEPRECATED
8612 return detail::errHandler(
8613 ::clEnqueueWaitForEvents(
8615 (cl_uint) events.size(),
8616 events.size() > 0 ? (
const cl_event*) &events.front() :
nullptr),
8617 __ENQUEUE_WAIT_FOR_EVENTS_ERR);
8621 cl_int enqueueAcquireGLObjects(
8622 const vector<Memory>* mem_objects =
nullptr,
8623 const vector<Event>* events =
nullptr,
8624 Event* event =
nullptr)
const
8627 cl_int err = detail::errHandler(
8628 ::clEnqueueAcquireGLObjects(
8630 (mem_objects !=
nullptr) ? (cl_uint) mem_objects->size() : 0,
8631 (mem_objects !=
nullptr && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front():
nullptr,
8632 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8633 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
8634 (event !=
nullptr) ? &tmp :
nullptr),
8635 __ENQUEUE_ACQUIRE_GL_ERR);
8637 if (event !=
nullptr && err == CL_SUCCESS)
8643 cl_int enqueueReleaseGLObjects(
8644 const vector<Memory>* mem_objects =
nullptr,
8645 const vector<Event>* events =
nullptr,
8646 Event* event =
nullptr)
const
8649 cl_int err = detail::errHandler(
8650 ::clEnqueueReleaseGLObjects(
8652 (mem_objects !=
nullptr) ? (cl_uint) mem_objects->size() : 0,
8653 (mem_objects !=
nullptr && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front():
nullptr,
8654 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8655 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
8656 (event !=
nullptr) ? &tmp :
nullptr),
8657 __ENQUEUE_RELEASE_GL_ERR);
8659 if (event !=
nullptr && err == CL_SUCCESS)
8665#if defined (CL_HPP_USE_DX_INTEROP)
8666typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueAcquireD3D10ObjectsKHR)(
8667 cl_command_queue command_queue, cl_uint num_objects,
8668 const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
8669 const cl_event* event_wait_list, cl_event* event);
8670typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueReleaseD3D10ObjectsKHR)(
8671 cl_command_queue command_queue, cl_uint num_objects,
8672 const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
8673 const cl_event* event_wait_list, cl_event* event);
8675 cl_int enqueueAcquireD3D10Objects(
8676 const vector<Memory>* mem_objects =
nullptr,
8677 const vector<Event>* events =
nullptr,
8678 Event* event =
nullptr)
const
8680 static PFN_clEnqueueAcquireD3D10ObjectsKHR pfn_clEnqueueAcquireD3D10ObjectsKHR =
nullptr;
8681#if CL_HPP_TARGET_OPENCL_VERSION >= 120
8682 cl_context context = getInfo<CL_QUEUE_CONTEXT>();
8683 cl::Device device(getInfo<CL_QUEUE_DEVICE>());
8684 cl_platform_id platform = device.
getInfo<CL_DEVICE_PLATFORM>();
8685 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueAcquireD3D10ObjectsKHR);
8687#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
8688 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueAcquireD3D10ObjectsKHR);
8692 cl_int err = detail::errHandler(
8693 pfn_clEnqueueAcquireD3D10ObjectsKHR(
8695 (mem_objects !=
nullptr) ? (cl_uint) mem_objects->size() : 0,
8696 (mem_objects !=
nullptr && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front():
nullptr,
8697 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8698 (events !=
nullptr) ? (cl_event*) &events->front() :
nullptr,
8699 (event !=
nullptr) ? &tmp :
nullptr),
8700 __ENQUEUE_ACQUIRE_GL_ERR);
8702 if (event !=
nullptr && err == CL_SUCCESS)
8708 cl_int enqueueReleaseD3D10Objects(
8709 const vector<Memory>* mem_objects =
nullptr,
8710 const vector<Event>* events =
nullptr,
8711 Event* event =
nullptr)
const
8713 static PFN_clEnqueueReleaseD3D10ObjectsKHR pfn_clEnqueueReleaseD3D10ObjectsKHR =
nullptr;
8714#if CL_HPP_TARGET_OPENCL_VERSION >= 120
8715 cl_context context = getInfo<CL_QUEUE_CONTEXT>();
8716 cl::Device device(getInfo<CL_QUEUE_DEVICE>());
8717 cl_platform_id platform = device.
getInfo<CL_DEVICE_PLATFORM>();
8718 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueReleaseD3D10ObjectsKHR);
8720#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
8721 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueReleaseD3D10ObjectsKHR);
8725 cl_int err = detail::errHandler(
8726 pfn_clEnqueueReleaseD3D10ObjectsKHR(
8728 (mem_objects !=
nullptr) ? (cl_uint) mem_objects->size() : 0,
8729 (mem_objects !=
nullptr && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front():
nullptr,
8730 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8731 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
8732 (event !=
nullptr) ? &tmp :
nullptr),
8733 __ENQUEUE_RELEASE_GL_ERR);
8735 if (event !=
nullptr && err == CL_SUCCESS)
8745#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
8746 CL_API_PREFIX__VERSION_1_1_DEPRECATED
8749 return detail::errHandler(
8750 ::clEnqueueBarrier(object_),
8751 __ENQUEUE_BARRIER_ERR);
8755 cl_int flush()
const
8757 return detail::errHandler(::clFlush(object_), __FLUSH_ERR);
8760 cl_int finish()
const
8762 return detail::errHandler(::clFinish(object_), __FINISH_ERR);
8765#ifdef cl_khr_external_memory
8766 cl_int enqueueAcquireExternalMemObjects(
8767 const vector<Memory>& mem_objects,
8768 const vector<Event>* events_wait =
nullptr,
8769 Event *event =
nullptr)
8771 cl_int err = CL_INVALID_OPERATION;
8774 std::call_once(ext_memory_initialized_, initMemoryExtension, this->getInfo<CL_QUEUE_DEVICE>());
8776 if (pfn_clEnqueueAcquireExternalMemObjectsKHR)
8778 err = pfn_clEnqueueAcquireExternalMemObjectsKHR(
8780 static_cast<cl_uint
>(mem_objects.size()),
8781 (mem_objects.size() > 0) ?
reinterpret_cast<const cl_mem *
>(mem_objects.data()) :
nullptr,
8782 (events_wait !=
nullptr) ?
static_cast<cl_uint
>(events_wait->size()) : 0,
8783 (events_wait !=
nullptr && events_wait->size() > 0) ?
reinterpret_cast<const cl_event*
>(events_wait->data()) :
nullptr,
8787 detail::errHandler(err, __ENQUEUE_ACQUIRE_EXTERNAL_MEMORY_ERR);
8789 if (event !=
nullptr && err == CL_SUCCESS)
8795 cl_int enqueueReleaseExternalMemObjects(
8796 const vector<Memory>& mem_objects,
8797 const vector<Event>* events_wait =
nullptr,
8798 Event *event =
nullptr)
8800 cl_int err = CL_INVALID_OPERATION;
8803 std::call_once(ext_memory_initialized_, initMemoryExtension, this->getInfo<CL_QUEUE_DEVICE>());
8805 if (pfn_clEnqueueReleaseExternalMemObjectsKHR)
8807 err = pfn_clEnqueueReleaseExternalMemObjectsKHR(
8809 static_cast<cl_uint
>(mem_objects.size()),
8810 (mem_objects.size() > 0) ?
reinterpret_cast<const cl_mem *
>(mem_objects.data()) :
nullptr,
8811 (events_wait !=
nullptr) ?
static_cast<cl_uint
>(events_wait->size()) : 0,
8812 (events_wait !=
nullptr && events_wait->size() > 0) ?
reinterpret_cast<const cl_event*
>(events_wait->data()) :
nullptr,
8816 detail::errHandler(err, __ENQUEUE_RELEASE_EXTERNAL_MEMORY_ERR);
8818 if (event !=
nullptr && err == CL_SUCCESS)
8825#ifdef cl_khr_semaphore
8826 cl_int enqueueWaitSemaphores(
8827 const vector<Semaphore> &sema_objects,
8828 const vector<cl_semaphore_payload_khr> &sema_payloads = {},
8829 const vector<Event>* events_wait_list =
nullptr,
8830 Event *
event =
nullptr)
const;
8832 cl_int enqueueSignalSemaphores(
8833 const vector<Semaphore> &sema_objects,
8834 const vector<cl_semaphore_payload_khr>& sema_payloads = {},
8835 const vector<Event>* events_wait_list =
nullptr,
8836 Event*
event =
nullptr);
8840#ifdef cl_khr_external_memory
8841CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag CommandQueue::ext_memory_initialized_;
8844CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag CommandQueue::default_initialized_;
8845CL_HPP_DEFINE_STATIC_MEMBER_ CommandQueue CommandQueue::default_;
8846CL_HPP_DEFINE_STATIC_MEMBER_ cl_int CommandQueue::default_error_ = CL_SUCCESS;
8849#if CL_HPP_TARGET_OPENCL_VERSION >= 200
8850enum class DeviceQueueProperties : cl_command_queue_properties
8853 Profiling = CL_QUEUE_PROFILING_ENABLE,
8856inline DeviceQueueProperties operator|(DeviceQueueProperties lhs, DeviceQueueProperties rhs)
8858 return static_cast<DeviceQueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) |
static_cast<cl_command_queue_properties
>(rhs));
8882 cl_command_queue_properties mergedProperties =
8883 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
8885 cl_queue_properties queue_properties[] = {
8886 CL_QUEUE_PROPERTIES, mergedProperties, 0 };
8887 object_ = ::clCreateCommandQueueWithProperties(
8888 context(), device(), queue_properties, &error);
8890 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8891 if (err !=
nullptr) {
8902 DeviceQueueProperties properties = DeviceQueueProperties::None,
8903 cl_int* err =
nullptr)
8907 cl_command_queue_properties mergedProperties =
8908 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
8909 cl_queue_properties queue_properties[] = {
8910 CL_QUEUE_PROPERTIES, mergedProperties, 0 };
8911 object_ = ::clCreateCommandQueueWithProperties(
8912 context(), device(), queue_properties, &error);
8914 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8915 if (err !=
nullptr) {
8927 DeviceQueueProperties properties = DeviceQueueProperties::None,
8928 cl_int* err =
nullptr)
8932 cl_command_queue_properties mergedProperties =
8933 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
8934 cl_queue_properties queue_properties[] = {
8935 CL_QUEUE_PROPERTIES, mergedProperties,
8936 CL_QUEUE_SIZE, queueSize,
8938 object_ = ::clCreateCommandQueueWithProperties(
8939 context(), device(), queue_properties, &error);
8941 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8942 if (err !=
nullptr) {
8954 detail::Wrapper<cl_type>(commandQueue, retainObject) { }
8962 template <
typename T>
8963 cl_int getInfo(cl_command_queue_info name, T* param)
const
8965 return detail::errHandler(
8967 &::clGetCommandQueueInfo, object_, name, param),
8968 __GET_COMMAND_QUEUE_INFO_ERR);
8971 template <cl_command_queue_info name>
typename
8972 detail::param_traits<detail::cl_command_queue_info, name>::param_type
8973 getInfo(cl_int* err =
nullptr)
const
8975 typename detail::param_traits<
8976 detail::cl_command_queue_info, name>::param_type param;
8977 cl_int result = getInfo(name, ¶m);
8978 if (err !=
nullptr) {
8991 cl_int *err =
nullptr)
8997 cl_command_queue_properties properties =
8998 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
8999 cl_queue_properties queue_properties[] = {
9000 CL_QUEUE_PROPERTIES, properties,
9003 ::clCreateCommandQueueWithProperties(
9004 context(), device(), queue_properties, &error));
9006 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9007 if (err !=
nullptr) {
9021 const Context &context,
const Device &device, cl_int *err =
nullptr)
9025 cl_command_queue_properties properties =
9026 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
9027 cl_queue_properties queue_properties[] = {
9028 CL_QUEUE_PROPERTIES, properties,
9031 ::clCreateCommandQueueWithProperties(
9032 context(), device(), queue_properties, &error));
9034 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9035 if (err !=
nullptr) {
9049 const Context &context,
const Device &device, cl_uint queueSize, cl_int *err =
nullptr)
9053 cl_command_queue_properties properties =
9054 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
9055 cl_queue_properties queue_properties[] = {
9056 CL_QUEUE_PROPERTIES, properties,
9057 CL_QUEUE_SIZE, queueSize,
9060 ::clCreateCommandQueueWithProperties(
9061 context(), device(), queue_properties, &error));
9063 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9064 if (err !=
nullptr) {
9073#if CL_HPP_TARGET_OPENCL_VERSION >= 210
9083 error = clSetDefaultDeviceCommandQueue(context.get(), device.get(), default_queue.get());
9085 detail::errHandler(error, __SET_DEFAULT_DEVICE_COMMAND_QUEUE_ERR);
9086 if (err !=
nullptr) {
9089 return default_queue;
9097 return queue.getInfo<CL_QUEUE_DEVICE_DEFAULT>(err);
9117template<
typename IteratorType >
9120 IteratorType startIterator,
9121 IteratorType endIterator,
9126 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9129 cl_mem_flags flags = 0;
9131 flags |= CL_MEM_READ_ONLY;
9134 flags |= CL_MEM_READ_WRITE;
9137 flags |= CL_MEM_USE_HOST_PTR;
9140 size_type size =
sizeof(DataType)*(endIterator - startIterator);
9143 object_ = ::clCreateBuffer(context(), flags, size,
const_cast<DataType*
>(&*startIterator), &error);
9145 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
9148 detail::errHandler(error, __CREATE_BUFFER_ERR);
9149 if (err !=
nullptr) {
9155 detail::errHandler(error, __CREATE_BUFFER_ERR);
9156 if (err !=
nullptr) {
9160 error =
cl::copy(queue, startIterator, endIterator, *
this);
9161 detail::errHandler(error, __CREATE_BUFFER_ERR);
9162 if (err !=
nullptr) {
9168template<
typename IteratorType >
9171 IteratorType startIterator,
9172 IteratorType endIterator,
9177 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9180 cl_mem_flags flags = 0;
9182 flags |= CL_MEM_READ_ONLY;
9185 flags |= CL_MEM_READ_WRITE;
9188 flags |= CL_MEM_USE_HOST_PTR;
9191 size_type size =
sizeof(DataType)*(endIterator - startIterator);
9193 Context context = queue.getInfo<CL_QUEUE_CONTEXT>();
9196 object_ = ::clCreateBuffer(context(), flags, size,
const_cast<DataType*
>(&*startIterator), &error);
9199 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
9202 detail::errHandler(error, __CREATE_BUFFER_ERR);
9203 if (err !=
nullptr) {
9208 error =
cl::copy(queue, startIterator, endIterator, *
this);
9209 detail::errHandler(error, __CREATE_BUFFER_ERR);
9210 if (err !=
nullptr) {
9216inline cl_int enqueueReadBuffer(
9222 const vector<Event>* events =
nullptr,
9223 Event* event =
nullptr)
9228 if (error != CL_SUCCESS) {
9232 return queue.enqueueReadBuffer(buffer, blocking, offset, size, ptr, events, event);
9235inline cl_int enqueueWriteBuffer(
9236 const Buffer& buffer,
9241 const vector<Event>* events =
nullptr,
9242 Event* event =
nullptr)
9245 CommandQueue queue = CommandQueue::getDefault(&error);
9247 if (error != CL_SUCCESS) {
9251 return queue.enqueueWriteBuffer(buffer, blocking, offset, size, ptr, events, event);
9254inline void* enqueueMapBuffer(
9255 const Buffer& buffer,
9260 const vector<Event>* events =
nullptr,
9261 Event* event =
nullptr,
9262 cl_int* err =
nullptr)
9265 CommandQueue queue = CommandQueue::getDefault(&error);
9266 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9267 if (err !=
nullptr) {
9271 void * result = ::clEnqueueMapBuffer(
9272 queue(), buffer(), blocking, flags, offset, size,
9273 (events !=
nullptr) ? (cl_uint) events->size() : 0,
9274 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
9278 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9279 if (err !=
nullptr) {
9286#if CL_HPP_TARGET_OPENCL_VERSION >= 200
9298 const vector<Event>* events,
9303 if (error != CL_SUCCESS) {
9304 return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9308 ptr, blocking, flags, size, events, event);
9316template<
typename T,
class D>
9318 cl::pointer<T, D> &ptr,
9322 const vector<Event>* events =
nullptr,
9323 Event* event =
nullptr)
9327 if (error != CL_SUCCESS) {
9328 return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9332 ptr, blocking, flags, size, events, event);
9340template<
typename T,
class Alloc>
9342 cl::vector<T, Alloc> &container,
9345 const vector<Event>* events =
nullptr,
9346 Event* event =
nullptr)
9350 if (error != CL_SUCCESS) {
9351 return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9355 container, blocking, flags, events, event);
9360inline cl_int enqueueUnmapMemObject(
9361 const Memory& memory,
9363 const vector<Event>* events =
nullptr,
9364 Event* event =
nullptr)
9367 CommandQueue queue = CommandQueue::getDefault(&error);
9368 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9369 if (error != CL_SUCCESS) {
9374 cl_int err = detail::errHandler(
9375 ::clEnqueueUnmapMemObject(
9376 queue(), memory(), mapped_ptr,
9377 (events !=
nullptr) ? (cl_uint)events->size() : 0,
9378 (events !=
nullptr && events->size() > 0) ? (cl_event*)&events->front() :
nullptr,
9379 (event !=
nullptr) ? &tmp :
nullptr),
9380 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9382 if (event !=
nullptr && err == CL_SUCCESS)
9388#if CL_HPP_TARGET_OPENCL_VERSION >= 200
9397 const vector<Event>* events =
nullptr,
9398 Event* event =
nullptr)
9402 if (error != CL_SUCCESS) {
9403 return detail::errHandler(error, __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9407 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9416template<
typename T,
class D>
9418 cl::pointer<T, D> &ptr,
9419 const vector<Event>* events =
nullptr,
9420 Event* event =
nullptr)
9424 if (error != CL_SUCCESS) {
9425 return detail::errHandler(error, __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9429 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9437template<
typename T,
class Alloc>
9439 cl::vector<T, Alloc> &container,
9440 const vector<Event>* events =
nullptr,
9441 Event* event =
nullptr)
9445 if (error != CL_SUCCESS) {
9446 return detail::errHandler(error, __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9449 return detail::errHandler(queue.
enqueueUnmapSVM(container, events, event),
9450 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9455inline cl_int enqueueCopyBuffer(
9458 size_type src_offset,
9459 size_type dst_offset,
9461 const vector<Event>* events =
nullptr,
9462 Event* event =
nullptr)
9465 CommandQueue queue = CommandQueue::getDefault(&error);
9467 if (error != CL_SUCCESS) {
9471 return queue.enqueueCopyBuffer(src, dst, src_offset, dst_offset, size, events, event);
9479template<
typename IteratorType >
9480inline cl_int
copy( IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer )
9484 if (error != CL_SUCCESS)
9487 return cl::copy(queue, startIterator, endIterator, buffer);
9495template<
typename IteratorType >
9496inline cl_int
copy(
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator )
9500 if (error != CL_SUCCESS)
9503 return cl::copy(queue, buffer, startIterator, endIterator);
9511template<
typename IteratorType >
9514 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9517 size_type length = endIterator-startIterator;
9518 size_type byteLength = length*
sizeof(DataType);
9521 static_cast<DataType*
>(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_WRITE, 0, byteLength, 0, 0, &error));
9523 if( error != CL_SUCCESS ) {
9526#if defined(_MSC_VER)
9530 stdext::checked_array_iterator<DataType*>(
9533 std::copy(startIterator, endIterator, pointer);
9536 error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
9538 if( error != CL_SUCCESS ) {
9550template<
typename IteratorType >
9553 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9556 size_type length = endIterator-startIterator;
9557 size_type byteLength = length*
sizeof(DataType);
9560 static_cast<DataType*
>(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_READ, 0, byteLength, 0, 0, &error));
9562 if( error != CL_SUCCESS ) {
9565 std::copy(pointer, pointer + length, startIterator);
9567 error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
9569 if( error != CL_SUCCESS ) {
9577#if CL_HPP_TARGET_OPENCL_VERSION >= 200
9581template<
typename T,
class Alloc>
9582inline cl_int
mapSVM(cl::vector<T, Alloc> &container)
9584 return enqueueMapSVM(container, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE);
9590template<
typename T,
class Alloc>
9598#if CL_HPP_TARGET_OPENCL_VERSION >= 110
9599inline cl_int enqueueReadBufferRect(
9600 const Buffer& buffer,
9602 const array<size_type, 3>& buffer_offset,
9603 const array<size_type, 3>& host_offset,
9604 const array<size_type, 3>& region,
9605 size_type buffer_row_pitch,
9606 size_type buffer_slice_pitch,
9607 size_type host_row_pitch,
9608 size_type host_slice_pitch,
9610 const vector<Event>* events =
nullptr,
9611 Event* event =
nullptr)
9614 CommandQueue queue = CommandQueue::getDefault(&error);
9616 if (error != CL_SUCCESS) {
9620 return queue.enqueueReadBufferRect(
9635inline cl_int enqueueReadBufferRect(
9636 const Buffer& buffer,
9638 const array<size_type, 2>& buffer_offset,
9639 const array<size_type, 2>& host_offset,
9640 const array<size_type, 2>& region,
9641 size_type buffer_row_pitch,
9642 size_type buffer_slice_pitch,
9643 size_type host_row_pitch,
9644 size_type host_slice_pitch,
9646 const vector<Event>* events =
nullptr,
9647 Event* event =
nullptr)
9649 return enqueueReadBufferRect(
9652 { buffer_offset[0], buffer_offset[1], 0 },
9653 { host_offset[0], host_offset[1], 0 },
9654 { region[0], region[1], 1 },
9664inline cl_int enqueueWriteBufferRect(
9665 const Buffer& buffer,
9667 const array<size_type, 3>& buffer_offset,
9668 const array<size_type, 3>& host_offset,
9669 const array<size_type, 3>& region,
9670 size_type buffer_row_pitch,
9671 size_type buffer_slice_pitch,
9672 size_type host_row_pitch,
9673 size_type host_slice_pitch,
9675 const vector<Event>* events =
nullptr,
9676 Event* event =
nullptr)
9679 CommandQueue queue = CommandQueue::getDefault(&error);
9681 if (error != CL_SUCCESS) {
9685 return queue.enqueueWriteBufferRect(
9700inline cl_int enqueueWriteBufferRect(
9701 const Buffer& buffer,
9703 const array<size_type, 2>& buffer_offset,
9704 const array<size_type, 2>& host_offset,
9705 const array<size_type, 2>& region,
9706 size_type buffer_row_pitch,
9707 size_type buffer_slice_pitch,
9708 size_type host_row_pitch,
9709 size_type host_slice_pitch,
9711 const vector<Event>* events =
nullptr,
9712 Event* event =
nullptr)
9714 return enqueueWriteBufferRect(
9717 { buffer_offset[0], buffer_offset[1], 0 },
9718 { host_offset[0], host_offset[1], 0 },
9719 { region[0], region[1], 1 },
9729inline cl_int enqueueCopyBufferRect(
9732 const array<size_type, 3>& src_origin,
9733 const array<size_type, 3>& dst_origin,
9734 const array<size_type, 3>& region,
9735 size_type src_row_pitch,
9736 size_type src_slice_pitch,
9737 size_type dst_row_pitch,
9738 size_type dst_slice_pitch,
9739 const vector<Event>* events =
nullptr,
9740 Event* event =
nullptr)
9743 CommandQueue queue = CommandQueue::getDefault(&error);
9745 if (error != CL_SUCCESS) {
9749 return queue.enqueueCopyBufferRect(
9763inline cl_int enqueueCopyBufferRect(
9766 const array<size_type, 2>& src_origin,
9767 const array<size_type, 2>& dst_origin,
9768 const array<size_type, 2>& region,
9769 size_type src_row_pitch,
9770 size_type src_slice_pitch,
9771 size_type dst_row_pitch,
9772 size_type dst_slice_pitch,
9773 const vector<Event>* events =
nullptr,
9774 Event* event =
nullptr)
9776 return enqueueCopyBufferRect(
9779 { src_origin[0], src_origin[1], 0 },
9780 { dst_origin[0], dst_origin[1], 0 },
9781 { region[0], region[1], 1 },
9791inline cl_int enqueueReadImage(
9794 const array<size_type, 3>& origin,
9795 const array<size_type, 3>& region,
9796 size_type row_pitch,
9797 size_type slice_pitch,
9799 const vector<Event>* events =
nullptr,
9800 Event* event =
nullptr)
9803 CommandQueue queue = CommandQueue::getDefault(&error);
9805 if (error != CL_SUCCESS) {
9809 return queue.enqueueReadImage(
9821inline cl_int enqueueReadImage(
9824 const array<size_type, 2>& origin,
9825 const array<size_type, 2>& region,
9826 size_type row_pitch,
9827 size_type slice_pitch,
9829 const vector<Event>* events =
nullptr,
9830 Event* event =
nullptr)
9832 return enqueueReadImage(
9835 { origin[0], origin[1], 0 },
9836 { region[0], region[1], 1 },
9844inline cl_int enqueueWriteImage(
9847 const array<size_type, 3>& origin,
9848 const array<size_type, 3>& region,
9849 size_type row_pitch,
9850 size_type slice_pitch,
9852 const vector<Event>* events =
nullptr,
9853 Event* event =
nullptr)
9856 CommandQueue queue = CommandQueue::getDefault(&error);
9858 if (error != CL_SUCCESS) {
9862 return queue.enqueueWriteImage(
9874inline cl_int enqueueWriteImage(
9877 const array<size_type, 2>& origin,
9878 const array<size_type, 2>& region,
9879 size_type row_pitch,
9880 size_type slice_pitch,
9882 const vector<Event>* events =
nullptr,
9883 Event* event =
nullptr)
9885 return enqueueWriteImage(
9888 { origin[0], origin[1], 0 },
9889 { region[0], region[1], 1 },
9897inline cl_int enqueueCopyImage(
9900 const array<size_type, 3>& src_origin,
9901 const array<size_type, 3>& dst_origin,
9902 const array<size_type, 3>& region,
9903 const vector<Event>* events =
nullptr,
9904 Event* event =
nullptr)
9907 CommandQueue queue = CommandQueue::getDefault(&error);
9909 if (error != CL_SUCCESS) {
9913 return queue.enqueueCopyImage(
9923inline cl_int enqueueCopyImage(
9926 const array<size_type, 2>& src_origin,
9927 const array<size_type, 2>& dst_origin,
9928 const array<size_type, 2>& region,
9929 const vector<Event>* events =
nullptr,
9930 Event* event =
nullptr)
9932 return enqueueCopyImage(
9935 { src_origin[0], src_origin[1], 0 },
9936 { dst_origin[0], dst_origin[1], 0 },
9937 { region[0], region[1], 1 },
9942inline cl_int enqueueCopyImageToBuffer(
9945 const array<size_type, 3>& src_origin,
9946 const array<size_type, 3>& region,
9947 size_type dst_offset,
9948 const vector<Event>* events =
nullptr,
9949 Event* event =
nullptr)
9952 CommandQueue queue = CommandQueue::getDefault(&error);
9954 if (error != CL_SUCCESS) {
9958 return queue.enqueueCopyImageToBuffer(
9968inline cl_int enqueueCopyImageToBuffer(
9971 const array<size_type, 2>& src_origin,
9972 const array<size_type, 2>& region,
9973 size_type dst_offset,
9974 const vector<Event>* events =
nullptr,
9975 Event* event =
nullptr)
9977 return enqueueCopyImageToBuffer(
9980 { src_origin[0], src_origin[1], 0 },
9981 { region[0], region[1], 1 },
9987inline cl_int enqueueCopyBufferToImage(
9990 size_type src_offset,
9991 const array<size_type, 3>& dst_origin,
9992 const array<size_type, 3>& region,
9993 const vector<Event>* events =
nullptr,
9994 Event* event =
nullptr)
9997 CommandQueue queue = CommandQueue::getDefault(&error);
9999 if (error != CL_SUCCESS) {
10003 return queue.enqueueCopyBufferToImage(
10013inline cl_int enqueueCopyBufferToImage(
10016 size_type src_offset,
10017 const array<size_type, 2>& dst_origin,
10018 const array<size_type, 2>& region,
10019 const vector<Event>* events =
nullptr,
10020 Event* event =
nullptr)
10023 CommandQueue queue = CommandQueue::getDefault(&error);
10025 if (error != CL_SUCCESS) {
10029 return enqueueCopyBufferToImage(
10033 { dst_origin[0], dst_origin[1], 0 },
10034 { region[0], region[1], 1 },
10039inline cl_int flush(
void)
10042 CommandQueue queue = CommandQueue::getDefault(&error);
10044 if (error != CL_SUCCESS) {
10048 return queue.flush();
10051inline cl_int finish(
void)
10054 CommandQueue queue = CommandQueue::getDefault(&error);
10056 if (error != CL_SUCCESS) {
10061 return queue.finish();
10071 vector<Event> events_;
10073 template<
typename... Ts>
10078 queue_(CommandQueue::getDefault()),
10079 offset_(NullRange),
10087 queue_(CommandQueue::getDefault()),
10088 offset_(NullRange),
10096 queue_(CommandQueue::getDefault()),
10105 queue_(CommandQueue::getDefault()),
10106 offset_(NullRange),
10110 events_.push_back(e);
10114 queue_(CommandQueue::getDefault()),
10115 offset_(NullRange),
10119 events_.push_back(e);
10123 queue_(CommandQueue::getDefault()),
10128 events_.push_back(e);
10132 queue_(CommandQueue::getDefault()),
10133 offset_(NullRange),
10142 queue_(CommandQueue::getDefault()),
10143 offset_(NullRange),
10152 queue_(CommandQueue::getDefault()),
10163 offset_(NullRange),
10172 offset_(NullRange),
10190 offset_(NullRange),
10194 events_.push_back(e);
10199 offset_(NullRange),
10203 events_.push_back(e);
10212 events_.push_back(e);
10217 offset_(NullRange),
10227 offset_(NullRange),
10254template<
typename... Ts>
10260 template<
int index,
typename T0,
typename... T1s>
10261 void setArgs(T0&& t0, T1s&&... t1s)
10263 kernel_.
setArg(index, t0);
10264 setArgs<index + 1, T1s...>(std::forward<T1s>(t1s)...);
10267 template<
int index,
typename T0>
10268 void setArgs(T0&& t0)
10270 kernel_.
setArg(index, t0);
10273 template<
int index>
10286 cl_int * err =
nullptr) :
10287 kernel_(program, name.c_str(), err)
10303 setArgs<0>(std::forward<Ts>(ts)...);
10305 args.queue_.enqueueNDRangeKernel(
10328 setArgs<0>(std::forward<Ts>(ts)...);
10330 error = args.queue_.enqueueNDRangeKernel(
10341#if CL_HPP_TARGET_OPENCL_VERSION >= 200
10342 cl_int setSVMPointers(
const vector<void*> &pointerList)
10347 template<
typename T0,
typename... T1s>
10348 cl_int setSVMPointers(
const T0 &t0, T1s &... ts)
10360namespace compatibility {
10365 template<
typename... Ts>
10375 cl_int * err =
nullptr) :
10397 enqueueArgs, args...);
10402#ifdef cl_khr_semaphore
10403class Semaphore :
public detail::Wrapper<cl_semaphore_khr>
10406 Semaphore() : detail::Wrapper<cl_type>() {}
10408 const Context &context,
10409 const vector<cl_semaphore_properties_khr>& sema_props,
10410 cl_int *err =
nullptr)
10413 std::call_once(ext_init_, initExtensions, context);
10415 cl_int error = CL_INVALID_OPERATION;
10417 if (pfn_clCreateSemaphoreWithPropertiesKHR)
10419 object_ = pfn_clCreateSemaphoreWithPropertiesKHR(
10425 detail::errHandler(error, __CREATE_SEMAPHORE_KHR_WITH_PROPERTIES_ERR);
10427 if (err !=
nullptr) {
10432 const vector<cl_semaphore_properties_khr>& sema_props,
10433 cl_int* err =
nullptr):Semaphore(Context::getDefault(err), sema_props, err) {}
10435 explicit Semaphore(
const cl_semaphore_khr& semaphore,
bool retainObject =
false) :
10436 detail::Wrapper<cl_type>(semaphore, retainObject) {}
10437 Semaphore& operator = (
const cl_semaphore_khr& rhs) {
10438 detail::Wrapper<cl_type>::operator=(rhs);
10441 template <
typename T>
10442 cl_int getInfo(cl_semaphore_info_khr name, T* param)
const
10444 if (pfn_clGetSemaphoreInfoKHR ==
nullptr) {
10445 return detail::errHandler(CL_INVALID_OPERATION,
10446 __GET_SEMAPHORE_KHR_INFO_ERR);
10449 return detail::errHandler(
10450 detail::getInfo(&pfn_clGetSemaphoreInfoKHR, object_, name, param),
10451 __GET_SEMAPHORE_KHR_INFO_ERR);
10453 template <cl_semaphore_info_khr name>
typename
10454 detail::param_traits<detail::cl_semaphore_info_khr, name>::param_type
10455 getInfo(cl_int* err =
nullptr)
const
10457 typename detail::param_traits<
10458 detail::cl_semaphore_info_khr, name>::param_type param;
10459 cl_int result = getInfo(name, ¶m);
10460 if (err !=
nullptr) {
10468 if (pfn_clRetainSemaphoreKHR ==
nullptr) {
10469 return detail::errHandler(CL_INVALID_OPERATION,
10470 __RETAIN_SEMAPHORE_KHR_ERR);
10472 return pfn_clRetainSemaphoreKHR(object_);
10477 if (pfn_clReleaseSemaphoreKHR ==
nullptr) {
10478 return detail::errHandler(CL_INVALID_OPERATION,
10479 __RELEASE_SEMAPHORE_KHR_ERR);
10481 return pfn_clReleaseSemaphoreKHR(object_);
10485 static std::once_flag ext_init_;
10487 static void initExtensions(
const Context& context)
10489#if CL_HPP_TARGET_OPENCL_VERSION >= 120
10490 Device device = context.
getInfo<CL_CONTEXT_DEVICES>().at(0);
10491 cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>();
10492 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCreateSemaphoreWithPropertiesKHR);
10493 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clReleaseSemaphoreKHR);
10494 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clRetainSemaphoreKHR);
10495 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueWaitSemaphoresKHR);
10496 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueSignalSemaphoresKHR);
10497 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clGetSemaphoreInfoKHR);
10499 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateSemaphoreWithPropertiesKHR);
10500 CL_HPP_INIT_CL_EXT_FCN_PTR_(clReleaseSemaphoreKHR);
10501 CL_HPP_INIT_CL_EXT_FCN_PTR_(clRetainSemaphoreKHR);
10502 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueWaitSemaphoresKHR);
10503 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueSignalSemaphoresKHR);
10504 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetSemaphoreInfoKHR);
10506 if ((pfn_clCreateSemaphoreWithPropertiesKHR ==
nullptr) &&
10507 (pfn_clReleaseSemaphoreKHR ==
nullptr) &&
10508 (pfn_clRetainSemaphoreKHR ==
nullptr) &&
10509 (pfn_clEnqueueWaitSemaphoresKHR ==
nullptr) &&
10510 (pfn_clEnqueueSignalSemaphoresKHR ==
nullptr) &&
10511 (pfn_clGetSemaphoreInfoKHR ==
nullptr))
10513 detail::errHandler(CL_INVALID_VALUE, __CREATE_SEMAPHORE_KHR_WITH_PROPERTIES_ERR);
10519CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Semaphore::ext_init_;
10521inline cl_int CommandQueue::enqueueWaitSemaphores(
10522 const vector<Semaphore> &sema_objects,
10523 const vector<cl_semaphore_payload_khr> &sema_payloads,
10524 const vector<Event>* events_wait_list,
10525 Event *event)
const
10528 cl_int err = CL_INVALID_OPERATION;
10530 if (pfn_clEnqueueWaitSemaphoresKHR !=
nullptr) {
10531 err = pfn_clEnqueueWaitSemaphoresKHR(
10533 (cl_uint)sema_objects.size(),
10534 (
const cl_semaphore_khr *) &sema_objects.front(),
10535 (sema_payloads.size() > 0) ? &sema_payloads.front() :
nullptr,
10536 (events_wait_list !=
nullptr) ? (cl_uint) events_wait_list->size() : 0,
10537 (events_wait_list !=
nullptr && events_wait_list->size() > 0) ? (cl_event*) &events_wait_list->front() :
nullptr,
10538 (event !=
nullptr) ? &tmp :
nullptr);
10541 detail::errHandler(err, __ENQUEUE_WAIT_SEMAPHORE_KHR_ERR);
10543 if (event !=
nullptr && err == CL_SUCCESS)
10549inline cl_int CommandQueue::enqueueSignalSemaphores(
10550 const vector<Semaphore> &sema_objects,
10551 const vector<cl_semaphore_payload_khr>& sema_payloads,
10552 const vector<Event>* events_wait_list,
10556 cl_int err = CL_INVALID_OPERATION;
10558 if (pfn_clEnqueueSignalSemaphoresKHR !=
nullptr) {
10559 err = pfn_clEnqueueSignalSemaphoresKHR(
10561 (cl_uint)sema_objects.size(),
10562 (
const cl_semaphore_khr*) &sema_objects.front(),
10563 (sema_payloads.size() > 0) ? &sema_payloads.front() :
nullptr,
10564 (events_wait_list !=
nullptr) ? (cl_uint) events_wait_list->size() : 0,
10565 (events_wait_list !=
nullptr && events_wait_list->size() > 0) ? (cl_event*) &events_wait_list->front() :
nullptr,
10566 (event !=
nullptr) ? &tmp :
nullptr);
10569 detail::errHandler(err, __ENQUEUE_SIGNAL_SEMAPHORE_KHR_ERR);
10571 if (event !=
nullptr && err == CL_SUCCESS)
10579#if defined(cl_khr_command_buffer)
10583class CommandBufferKhr :
public detail::Wrapper<cl_command_buffer_khr>
10587 CommandBufferKhr() : detail::Wrapper<cl_type>() { }
10589 explicit CommandBufferKhr(
const vector<CommandQueue> &queues,
10590 cl_command_buffer_properties_khr properties = 0,
10591 cl_int* errcode_ret =
nullptr)
10593 cl_command_buffer_properties_khr command_buffer_properties[] = {
10594 CL_COMMAND_BUFFER_FLAGS_KHR, properties, 0
10598 std::call_once(ext_init_, [&] { initExtensions(queues[0].getInfo<CL_QUEUE_DEVICE>()); });
10599 cl_int error = CL_INVALID_OPERATION;
10602 "Size of cl::CommandQueue must be equal to size of cl_command_queue");
10604 if (pfn_clCreateCommandBufferKHR)
10606 object_ = pfn_clCreateCommandBufferKHR((cl_uint) queues.size(),
10607 (cl_command_queue *) &queues.front(),
10608 command_buffer_properties,
10612 detail::errHandler(error, __CREATE_COMMAND_BUFFER_KHR_ERR);
10613 if (errcode_ret !=
nullptr) {
10614 *errcode_ret = error;
10618 explicit CommandBufferKhr(
const cl_command_buffer_khr& commandBufferKhr,
bool retainObject =
false) :
10619 detail::Wrapper<cl_type>(commandBufferKhr, retainObject) { }
10621 CommandBufferKhr& operator=(
const cl_command_buffer_khr& rhs)
10623 detail::Wrapper<cl_type>::operator=(rhs);
10627 template <
typename T>
10628 cl_int getInfo(cl_command_buffer_info_khr name, T* param)
const
10630 if (pfn_clGetCommandBufferInfoKHR ==
nullptr) {
10631 return detail::errHandler(CL_INVALID_OPERATION,
10632 __GET_COMMAND_BUFFER_INFO_KHR_ERR);
10634 return detail::errHandler(
10635 detail::getInfo(pfn_clGetCommandBufferInfoKHR, object_, name, param),
10636 __GET_COMMAND_BUFFER_INFO_KHR_ERR);
10639 template <cl_command_buffer_info_khr name>
typename
10640 detail::param_traits<detail::cl_command_buffer_info_khr, name>::param_type
10641 getInfo(cl_int* err =
nullptr)
const
10643 typename detail::param_traits<
10644 detail::cl_command_buffer_info_khr, name>::param_type param;
10645 cl_int result = getInfo(name, ¶m);
10646 if (err !=
nullptr) {
10652 cl_int finalizeCommandBuffer()
const
10654 return detail::errHandler(::clFinalizeCommandBufferKHR(object_), __FINALIZE_COMMAND_BUFFER_KHR_ERR);
10657 cl_int enqueueCommandBuffer(vector<CommandQueue> &queues,
10658 const vector<Event>* events =
nullptr,
10659 Event* event =
nullptr)
10661 if (pfn_clEnqueueCommandBufferKHR ==
nullptr) {
10662 return detail::errHandler(CL_INVALID_OPERATION,
10663 __ENQUEUE_COMMAND_BUFFER_KHR_ERR);
10667 "Size of cl::CommandQueue must be equal to size of cl_command_queue");
10669 return detail::errHandler(pfn_clEnqueueCommandBufferKHR((cl_uint) queues.size(),
10670 (cl_command_queue *) &queues.front(),
10672 (events !=
nullptr) ? (cl_uint) events->size() : 0,
10673 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
10674 (cl_event*) event),
10675 __ENQUEUE_COMMAND_BUFFER_KHR_ERR);
10678 cl_int commandBarrierWithWaitList(
const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
10679 cl_sync_point_khr* sync_point =
nullptr,
10680 MutableCommandKhr* mutable_handle =
nullptr,
10681 const CommandQueue* command_queue =
nullptr)
10683 if (pfn_clCommandBarrierWithWaitListKHR ==
nullptr) {
10684 return detail::errHandler(CL_INVALID_OPERATION,
10685 __COMMAND_BARRIER_WITH_WAIT_LIST_KHR_ERR);
10688 cl_sync_point_khr tmp_sync_point;
10689 cl_int error = detail::errHandler(
10690 pfn_clCommandBarrierWithWaitListKHR(object_,
10691 (command_queue !=
nullptr) ? (*command_queue)() :
nullptr,
10692 (sync_points_vec !=
nullptr) ? (cl_uint) sync_points_vec->size() : 0,
10693 (sync_points_vec !=
nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() :
nullptr,
10694 (sync_point !=
nullptr) ? &tmp_sync_point :
nullptr,
10695 (cl_mutable_command_khr*) mutable_handle),
10696 __COMMAND_BARRIER_WITH_WAIT_LIST_KHR_ERR);
10698 if (sync_point !=
nullptr && error == CL_SUCCESS)
10699 *sync_point = tmp_sync_point;
10704 cl_int commandCopyBuffer(
const Buffer& src,
10706 size_type src_offset,
10707 size_type dst_offset,
10709 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
10710 cl_sync_point_khr* sync_point =
nullptr,
10711 MutableCommandKhr* mutable_handle =
nullptr,
10712 const CommandQueue* command_queue =
nullptr)
10714 if (pfn_clCommandCopyBufferKHR ==
nullptr) {
10715 return detail::errHandler(CL_INVALID_OPERATION,
10716 __COMMAND_COPY_BUFFER_KHR_ERR);
10719 cl_sync_point_khr tmp_sync_point;
10720 cl_int error = detail::errHandler(
10721 pfn_clCommandCopyBufferKHR(object_,
10722 (command_queue !=
nullptr) ? (*command_queue)() :
nullptr,
10728 (sync_points_vec !=
nullptr) ? (cl_uint) sync_points_vec->size() : 0,
10729 (sync_points_vec !=
nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() :
nullptr,
10730 (sync_point !=
nullptr) ? &tmp_sync_point :
nullptr,
10731 (cl_mutable_command_khr*) mutable_handle),
10732 __COMMAND_COPY_BUFFER_KHR_ERR);
10734 if (sync_point !=
nullptr && error == CL_SUCCESS)
10735 *sync_point = tmp_sync_point;
10740 cl_int commandCopyBufferRect(
const Buffer& src,
10742 const array<size_type, 3>& src_origin,
10743 const array<size_type, 3>& dst_origin,
10744 const array<size_type, 3>& region,
10745 size_type src_row_pitch,
10746 size_type src_slice_pitch,
10747 size_type dst_row_pitch,
10748 size_type dst_slice_pitch,
10749 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
10750 cl_sync_point_khr* sync_point =
nullptr,
10751 MutableCommandKhr* mutable_handle =
nullptr,
10752 const CommandQueue* command_queue =
nullptr)
10754 if (pfn_clCommandCopyBufferRectKHR ==
nullptr) {
10755 return detail::errHandler(CL_INVALID_OPERATION,
10756 __COMMAND_COPY_BUFFER_RECT_KHR_ERR);
10759 cl_sync_point_khr tmp_sync_point;
10760 cl_int error = detail::errHandler(
10761 pfn_clCommandCopyBufferRectKHR(object_,
10762 (command_queue !=
nullptr) ? (*command_queue)() :
nullptr,
10772 (sync_points_vec !=
nullptr) ? (cl_uint) sync_points_vec->size() : 0,
10773 (sync_points_vec !=
nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() :
nullptr,
10774 (sync_point !=
nullptr) ? &tmp_sync_point :
nullptr,
10775 (cl_mutable_command_khr*) mutable_handle),
10776 __COMMAND_COPY_BUFFER_RECT_KHR_ERR);
10778 if (sync_point !=
nullptr && error == CL_SUCCESS)
10779 *sync_point = tmp_sync_point;
10784 cl_int commandCopyBufferToImage(
const Buffer& src,
10786 size_type src_offset,
10787 const array<size_type, 3>& dst_origin,
10788 const array<size_type, 3>& region,
10789 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
10790 cl_sync_point_khr* sync_point =
nullptr,
10791 MutableCommandKhr* mutable_handle =
nullptr,
10792 const CommandQueue* command_queue =
nullptr)
10794 if (pfn_clCommandCopyBufferToImageKHR ==
nullptr) {
10795 return detail::errHandler(CL_INVALID_OPERATION,
10796 __COMMAND_COPY_BUFFER_TO_IMAGE_KHR_ERR);
10799 cl_sync_point_khr tmp_sync_point;
10800 cl_int error = detail::errHandler(
10801 pfn_clCommandCopyBufferToImageKHR(object_,
10802 (command_queue !=
nullptr) ? (*command_queue)() :
nullptr,
10808 (sync_points_vec !=
nullptr) ? (cl_uint) sync_points_vec->size() : 0,
10809 (sync_points_vec !=
nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() :
nullptr,
10810 (sync_point !=
nullptr) ? &tmp_sync_point :
nullptr,
10811 (cl_mutable_command_khr*) mutable_handle),
10812 __COMMAND_COPY_BUFFER_TO_IMAGE_KHR_ERR);
10814 if (sync_point !=
nullptr && error == CL_SUCCESS)
10815 *sync_point = tmp_sync_point;
10820 cl_int commandCopyImage(
const Image& src,
10822 const array<size_type, 3>& src_origin,
10823 const array<size_type, 3>& dst_origin,
10824 const array<size_type, 3>& region,
10825 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
10826 cl_sync_point_khr* sync_point =
nullptr,
10827 MutableCommandKhr* mutable_handle =
nullptr,
10828 const CommandQueue* command_queue =
nullptr)
10830 if (pfn_clCommandCopyImageKHR ==
nullptr) {
10831 return detail::errHandler(CL_INVALID_OPERATION,
10832 __COMMAND_COPY_IMAGE_KHR_ERR);
10835 cl_sync_point_khr tmp_sync_point;
10836 cl_int error = detail::errHandler(
10837 pfn_clCommandCopyImageKHR(object_,
10838 (command_queue !=
nullptr) ? (*command_queue)() :
nullptr,
10844 (sync_points_vec !=
nullptr) ? (cl_uint) sync_points_vec->size() : 0,
10845 (sync_points_vec !=
nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() :
nullptr,
10846 (sync_point !=
nullptr) ? &tmp_sync_point :
nullptr,
10847 (cl_mutable_command_khr*) mutable_handle),
10848 __COMMAND_COPY_IMAGE_KHR_ERR);
10850 if (sync_point !=
nullptr && error == CL_SUCCESS)
10851 *sync_point = tmp_sync_point;
10856 cl_int commandCopyImageToBuffer(
const Image& src,
10858 const array<size_type, 3>& src_origin,
10859 const array<size_type, 3>& region,
10860 size_type dst_offset,
10861 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
10862 cl_sync_point_khr* sync_point =
nullptr,
10863 MutableCommandKhr* mutable_handle =
nullptr,
10864 const CommandQueue* command_queue =
nullptr)
10866 if (pfn_clCommandCopyImageToBufferKHR ==
nullptr) {
10867 return detail::errHandler(CL_INVALID_OPERATION,
10868 __COMMAND_COPY_IMAGE_TO_BUFFER_KHR_ERR);
10871 cl_sync_point_khr tmp_sync_point;
10872 cl_int error = detail::errHandler(
10873 pfn_clCommandCopyImageToBufferKHR(object_,
10874 (command_queue !=
nullptr) ? (*command_queue)() :
nullptr,
10880 (sync_points_vec !=
nullptr) ? (cl_uint) sync_points_vec->size() : 0,
10881 (sync_points_vec !=
nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() :
nullptr,
10882 (sync_point !=
nullptr) ? &tmp_sync_point :
nullptr,
10883 (cl_mutable_command_khr*) mutable_handle),
10884 __COMMAND_COPY_IMAGE_TO_BUFFER_KHR_ERR);
10886 if (sync_point !=
nullptr && error == CL_SUCCESS)
10887 *sync_point = tmp_sync_point;
10892 template<
typename PatternType>
10893 cl_int commandFillBuffer(
const Buffer& buffer,
10894 PatternType pattern,
10897 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
10898 cl_sync_point_khr* sync_point =
nullptr,
10899 MutableCommandKhr* mutable_handle =
nullptr,
10900 const CommandQueue* command_queue =
nullptr)
10902 if (pfn_clCommandFillBufferKHR ==
nullptr) {
10903 return detail::errHandler(CL_INVALID_OPERATION,
10904 __COMMAND_FILL_BUFFER_KHR_ERR);
10907 cl_sync_point_khr tmp_sync_point;
10908 cl_int error = detail::errHandler(
10909 pfn_clCommandFillBufferKHR(object_,
10910 (command_queue !=
nullptr) ? (*command_queue)() :
nullptr,
10912 static_cast<void*
>(&pattern),
10913 sizeof(PatternType),
10916 (sync_points_vec !=
nullptr) ? (cl_uint) sync_points_vec->size() : 0,
10917 (sync_points_vec !=
nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() :
nullptr,
10918 (sync_point !=
nullptr) ? &tmp_sync_point :
nullptr,
10919 (cl_mutable_command_khr*) mutable_handle),
10920 __COMMAND_FILL_BUFFER_KHR_ERR);
10922 if (sync_point !=
nullptr && error == CL_SUCCESS)
10923 *sync_point = tmp_sync_point;
10928 cl_int commandFillImage(
const Image& image,
10929 cl_float4 fillColor,
10930 const array<size_type, 3>& origin,
10931 const array<size_type, 3>& region,
10932 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
10933 cl_sync_point_khr* sync_point =
nullptr,
10934 MutableCommandKhr* mutable_handle =
nullptr,
10935 const CommandQueue* command_queue =
nullptr)
10937 if (pfn_clCommandFillImageKHR ==
nullptr) {
10938 return detail::errHandler(CL_INVALID_OPERATION,
10939 __COMMAND_FILL_IMAGE_KHR_ERR);
10942 cl_sync_point_khr tmp_sync_point;
10943 cl_int error = detail::errHandler(
10944 pfn_clCommandFillImageKHR(object_,
10945 (command_queue !=
nullptr) ? (*command_queue)() :
nullptr,
10947 static_cast<void*
>(&fillColor),
10950 (sync_points_vec !=
nullptr) ? (cl_uint) sync_points_vec->size() : 0,
10951 (sync_points_vec !=
nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() :
nullptr,
10952 (sync_point !=
nullptr) ? &tmp_sync_point :
nullptr,
10953 (cl_mutable_command_khr*) mutable_handle),
10954 __COMMAND_FILL_IMAGE_KHR_ERR);
10956 if (sync_point !=
nullptr && error == CL_SUCCESS)
10957 *sync_point = tmp_sync_point;
10962 cl_int commandNDRangeKernel(
const cl::vector<cl_ndrange_kernel_command_properties_khr> &properties,
10963 const Kernel& kernel,
10964 const NDRange& offset,
10965 const NDRange& global,
10966 const NDRange& local = NullRange,
10967 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
10968 cl_sync_point_khr* sync_point =
nullptr,
10969 MutableCommandKhr* mutable_handle =
nullptr,
10970 const CommandQueue* command_queue =
nullptr)
10972 if (pfn_clCommandNDRangeKernelKHR ==
nullptr) {
10973 return detail::errHandler(CL_INVALID_OPERATION,
10974 __COMMAND_NDRANGE_KERNEL_KHR_ERR);
10977 cl_sync_point_khr tmp_sync_point;
10978 cl_int error = detail::errHandler(
10979 pfn_clCommandNDRangeKernelKHR(object_,
10980 (command_queue !=
nullptr) ? (*command_queue)() :
nullptr,
10983 (cl_uint) global.dimensions(),
10984 offset.dimensions() != 0 ? (
const size_type*) offset :
nullptr,
10985 (
const size_type*) global,
10986 local.dimensions() != 0 ? (
const size_type*) local :
nullptr,
10987 (sync_points_vec !=
nullptr) ? (cl_uint) sync_points_vec->size() : 0,
10988 (sync_points_vec !=
nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() :
nullptr,
10989 (sync_point !=
nullptr) ? &tmp_sync_point :
nullptr,
10990 (cl_mutable_command_khr*) mutable_handle),
10991 __COMMAND_NDRANGE_KERNEL_KHR_ERR);
10993 if (sync_point !=
nullptr && error == CL_SUCCESS)
10994 *sync_point = tmp_sync_point;
10999#if defined(cl_khr_command_buffer_mutable_dispatch)
11000 cl_int updateMutableCommands(
const cl_mutable_base_config_khr* mutable_config)
11002 if (pfn_clUpdateMutableCommandsKHR ==
nullptr) {
11003 return detail::errHandler(CL_INVALID_OPERATION,
11004 __UPDATE_MUTABLE_COMMANDS_KHR_ERR);
11006 return detail::errHandler(pfn_clUpdateMutableCommandsKHR(object_, mutable_config),
11007 __UPDATE_MUTABLE_COMMANDS_KHR_ERR);
11012 static std::once_flag ext_init_;
11014 static void initExtensions(
const cl::Device& device)
11016#if CL_HPP_TARGET_OPENCL_VERSION >= 120
11017 cl_platform_id platform = device.
getInfo<CL_DEVICE_PLATFORM>();
11018 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCreateCommandBufferKHR);
11019 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clFinalizeCommandBufferKHR);
11020 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clRetainCommandBufferKHR);
11021 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clReleaseCommandBufferKHR);
11022 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clGetCommandBufferInfoKHR);
11023 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueCommandBufferKHR);
11024 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandBarrierWithWaitListKHR);
11025 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandCopyBufferKHR);
11026 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandCopyBufferRectKHR);
11027 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandCopyBufferToImageKHR);
11028 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandCopyImageKHR);
11029 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandCopyImageToBufferKHR);
11030 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandFillBufferKHR);
11031 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandFillImageKHR);
11032 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandNDRangeKernelKHR);
11033#if defined(cl_khr_command_buffer_mutable_dispatch)
11034 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clUpdateMutableCommandsKHR);
11035 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clGetMutableCommandInfoKHR);
11037#elif CL_HPP_TARGET_OPENCL_VERSION >= 110
11038 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateCommandBufferKHR);
11039 CL_HPP_INIT_CL_EXT_FCN_PTR_(clFinalizeCommandBufferKHR);
11040 CL_HPP_INIT_CL_EXT_FCN_PTR_(clRetainCommandBufferKHR);
11041 CL_HPP_INIT_CL_EXT_FCN_PTR_(clReleaseCommandBufferKHR);
11042 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetCommandBufferInfoKHR);
11043 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueCommandBufferKHR);
11044 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandBarrierWithWaitListKHR);
11045 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandCopyBufferKHR);
11046 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandCopyBufferRectKHR);
11047 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandCopyBufferToImageKHR);
11048 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandCopyImageKHR);
11049 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandCopyImageToBufferKHR);
11050 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandFillBufferKHR);
11051 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandFillImageKHR);
11052 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandNDRangeKernelKHR);
11053#if defined(cl_khr_command_buffer_mutable_dispatch)
11054 CL_HPP_INIT_CL_EXT_FCN_PTR_(clUpdateMutableCommandsKHR);
11055 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetMutableCommandInfoKHR);
11058 if ((pfn_clCreateCommandBufferKHR ==
nullptr) &&
11059 (pfn_clFinalizeCommandBufferKHR ==
nullptr) &&
11060 (pfn_clRetainCommandBufferKHR ==
nullptr) &&
11061 (pfn_clReleaseCommandBufferKHR ==
nullptr) &&
11062 (pfn_clGetCommandBufferInfoKHR ==
nullptr) &&
11063 (pfn_clEnqueueCommandBufferKHR ==
nullptr) &&
11064 (pfn_clCommandBarrierWithWaitListKHR ==
nullptr) &&
11065 (pfn_clCommandCopyBufferKHR ==
nullptr) &&
11066 (pfn_clCommandCopyBufferRectKHR ==
nullptr) &&
11067 (pfn_clCommandCopyBufferToImageKHR ==
nullptr) &&
11068 (pfn_clCommandCopyImageKHR ==
nullptr) &&
11069 (pfn_clCommandCopyImageToBufferKHR ==
nullptr) &&
11070 (pfn_clCommandFillBufferKHR ==
nullptr) &&
11071 (pfn_clCommandFillImageKHR ==
nullptr) &&
11072 (pfn_clCommandNDRangeKernelKHR ==
nullptr)
11073#
if defined(cl_khr_command_buffer_mutable_dispatch)
11074 && (pfn_clUpdateMutableCommandsKHR ==
nullptr)
11075 && (pfn_clGetMutableCommandInfoKHR ==
nullptr)
11079 detail::errHandler(CL_INVALID_VALUE, __CREATE_COMMAND_BUFFER_KHR_ERR);
11084CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag CommandBufferKhr::ext_init_;
11086#if defined(cl_khr_command_buffer_mutable_dispatch)
11090class MutableCommandKhr :
public detail::Wrapper<cl_mutable_command_khr>
11094 MutableCommandKhr() : detail::Wrapper<cl_type>() { }
11096 explicit MutableCommandKhr(
const cl_mutable_command_khr& mutableCommandKhr,
bool retainObject =
false) :
11097 detail::Wrapper<cl_type>(mutableCommandKhr, retainObject) { }
11099 MutableCommandKhr& operator=(
const cl_mutable_command_khr& rhs)
11101 detail::Wrapper<cl_type>::operator=(rhs);
11105 template <
typename T>
11106 cl_int getInfo(cl_mutable_command_info_khr name, T* param)
const
11108 if (pfn_clGetMutableCommandInfoKHR ==
nullptr) {
11109 return detail::errHandler(CL_INVALID_OPERATION,
11110 __GET_MUTABLE_COMMAND_INFO_KHR_ERR);
11112 return detail::errHandler(
11113 detail::getInfo(pfn_clGetMutableCommandInfoKHR, object_, name, param),
11114 __GET_MUTABLE_COMMAND_INFO_KHR_ERR);
11117 template <cl_mutable_command_info_khr name>
typename
11118 detail::param_traits<detail::cl_mutable_command_info_khr, name>::param_type
11119 getInfo(cl_int* err =
nullptr)
const
11121 typename detail::param_traits<
11122 detail::cl_mutable_command_info_khr, name>::param_type param;
11123 cl_int result = getInfo(name, ¶m);
11124 if (err !=
nullptr) {
11135#undef CL_HPP_ERR_STR_
11136#if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS)
11137#undef __GET_DEVICE_INFO_ERR
11138#undef __GET_PLATFORM_INFO_ERR
11139#undef __GET_DEVICE_IDS_ERR
11140#undef __GET_PLATFORM_IDS_ERR
11141#undef __GET_CONTEXT_INFO_ERR
11142#undef __GET_EVENT_INFO_ERR
11143#undef __GET_EVENT_PROFILE_INFO_ERR
11144#undef __GET_MEM_OBJECT_INFO_ERR
11145#undef __GET_IMAGE_INFO_ERR
11146#undef __GET_SAMPLER_INFO_ERR
11147#undef __GET_KERNEL_INFO_ERR
11148#undef __GET_KERNEL_ARG_INFO_ERR
11149#undef __GET_KERNEL_SUB_GROUP_INFO_ERR
11150#undef __GET_KERNEL_WORK_GROUP_INFO_ERR
11151#undef __GET_PROGRAM_INFO_ERR
11152#undef __GET_PROGRAM_BUILD_INFO_ERR
11153#undef __GET_COMMAND_QUEUE_INFO_ERR
11154#undef __CREATE_CONTEXT_ERR
11155#undef __CREATE_CONTEXT_FROM_TYPE_ERR
11156#undef __CREATE_COMMAND_BUFFER_KHR_ERR
11157#undef __GET_COMMAND_BUFFER_INFO_KHR_ERR
11158#undef __FINALIZE_COMMAND_BUFFER_KHR_ERR
11159#undef __ENQUEUE_COMMAND_BUFFER_KHR_ERR
11160#undef __COMMAND_BARRIER_WITH_WAIT_LIST_KHR_ERR
11161#undef __COMMAND_COPY_BUFFER_KHR_ERR
11162#undef __COMMAND_COPY_BUFFER_RECT_KHR_ERR
11163#undef __COMMAND_COPY_BUFFER_TO_IMAGE_KHR_ERR
11164#undef __COMMAND_COPY_IMAGE_KHR_ERR
11165#undef __COMMAND_COPY_IMAGE_TO_BUFFER_KHR_ERR
11166#undef __COMMAND_FILL_BUFFER_KHR_ERR
11167#undef __COMMAND_FILL_IMAGE_KHR_ERR
11168#undef __COMMAND_NDRANGE_KERNEL_KHR_ERR
11169#undef __UPDATE_MUTABLE_COMMANDS_KHR_ERR
11170#undef __GET_MUTABLE_COMMAND_INFO_KHR_ERR
11171#undef __RETAIN_COMMAND_BUFFER_KHR_ERR
11172#undef __RELEASE_COMMAND_BUFFER_KHR_ERR
11173#undef __GET_SUPPORTED_IMAGE_FORMATS_ERR
11174#undef __SET_CONTEXT_DESCTRUCTOR_CALLBACK_ERR
11175#undef __CREATE_BUFFER_ERR
11177#undef __CREATE_SUBBUFFER_ERR
11178#undef __CREATE_GL_BUFFER_ERR
11179#undef __CREATE_GL_RENDER_BUFFER_ERR
11180#undef __GET_GL_OBJECT_INFO_ERR
11181#undef __CREATE_IMAGE_ERR
11182#undef __CREATE_GL_TEXTURE_ERR
11183#undef __IMAGE_DIMENSION_ERR
11184#undef __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR
11185#undef __CREATE_USER_EVENT_ERR
11186#undef __SET_USER_EVENT_STATUS_ERR
11187#undef __SET_EVENT_CALLBACK_ERR
11188#undef __WAIT_FOR_EVENTS_ERR
11189#undef __CREATE_KERNEL_ERR
11190#undef __SET_KERNEL_ARGS_ERR
11191#undef __CREATE_PROGRAM_WITH_SOURCE_ERR
11192#undef __CREATE_PROGRAM_WITH_BINARY_ERR
11193#undef __CREATE_PROGRAM_WITH_IL_ERR
11194#undef __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR
11195#undef __BUILD_PROGRAM_ERR
11196#undef __COMPILE_PROGRAM_ERR
11197#undef __LINK_PROGRAM_ERR
11198#undef __CREATE_KERNELS_IN_PROGRAM_ERR
11199#undef __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR
11200#undef __CREATE_SAMPLER_WITH_PROPERTIES_ERR
11201#undef __SET_COMMAND_QUEUE_PROPERTY_ERR
11202#undef __ENQUEUE_READ_BUFFER_ERR
11203#undef __ENQUEUE_READ_BUFFER_RECT_ERR
11204#undef __ENQUEUE_WRITE_BUFFER_ERR
11205#undef __ENQUEUE_WRITE_BUFFER_RECT_ERR
11206#undef __ENQEUE_COPY_BUFFER_ERR
11207#undef __ENQEUE_COPY_BUFFER_RECT_ERR
11208#undef __ENQUEUE_FILL_BUFFER_ERR
11209#undef __ENQUEUE_READ_IMAGE_ERR
11210#undef __ENQUEUE_WRITE_IMAGE_ERR
11211#undef __ENQUEUE_COPY_IMAGE_ERR
11212#undef __ENQUEUE_FILL_IMAGE_ERR
11213#undef __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR
11214#undef __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR
11215#undef __ENQUEUE_MAP_BUFFER_ERR
11216#undef __ENQUEUE_MAP_IMAGE_ERR
11217#undef __ENQUEUE_UNMAP_MEM_OBJECT_ERR
11218#undef __ENQUEUE_NDRANGE_KERNEL_ERR
11219#undef __ENQUEUE_NATIVE_KERNEL
11220#undef __ENQUEUE_MIGRATE_MEM_OBJECTS_ERR
11221#undef __ENQUEUE_MIGRATE_SVM_ERR
11222#undef __ENQUEUE_ACQUIRE_GL_ERR
11223#undef __ENQUEUE_RELEASE_GL_ERR
11224#undef __CREATE_PIPE_ERR
11225#undef __GET_PIPE_INFO_ERR
11227#undef __RELEASE_ERR
11230#undef __VECTOR_CAPACITY_ERR
11231#undef __CREATE_SUB_DEVICES_ERR
11232#undef __ENQUEUE_ACQUIRE_EXTERNAL_MEMORY_ERR
11233#undef __ENQUEUE_RELEASE_EXTERNAL_MEMORY_ERR
11234#undef __ENQUEUE_MARKER_ERR
11235#undef __ENQUEUE_WAIT_FOR_EVENTS_ERR
11236#undef __ENQUEUE_BARRIER_ERR
11237#undef __UNLOAD_COMPILER_ERR
11238#undef __CREATE_GL_TEXTURE_2D_ERR
11239#undef __CREATE_GL_TEXTURE_3D_ERR
11240#undef __CREATE_IMAGE2D_ERR
11241#undef __CREATE_IMAGE3D_ERR
11242#undef __CREATE_COMMAND_QUEUE_ERR
11243#undef __ENQUEUE_TASK_ERR
11244#undef __CREATE_SAMPLER_ERR
11245#undef __ENQUEUE_MARKER_WAIT_LIST_ERR
11246#undef __ENQUEUE_BARRIER_WAIT_LIST_ERR
11247#undef __CLONE_KERNEL_ERR
11248#undef __GET_HOST_TIMER_ERR
11249#undef __GET_DEVICE_AND_HOST_TIMER_ERR
11250#undef __GET_SEMAPHORE_KHR_INFO_ERR
11251#undef __CREATE_SEMAPHORE_KHR_WITH_PROPERTIES_ERR
11252#undef __ENQUEUE_WAIT_SEMAPHORE_KHR_ERR
11253#undef __ENQUEUE_SIGNAL_SEMAPHORE_KHR_ERR
11258#undef CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_
11259#undef CL_HPP_INIT_CL_EXT_FCN_PTR_
11260#undef CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_
11262#undef CL_HPP_NOEXCEPT_
11263#undef CL_HPP_DEFINE_STATIC_MEMBER_
Class interface for GL Buffer Memory Objects.
BufferGL(const Context &context, cl_mem_flags flags, cl_GLuint bufobj, cl_int *err=nullptr)
Constructs a BufferGL in a specified context, from a given GL buffer.
BufferGL & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
BufferGL()
Default constructor - initializes to nullptr.
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 nullptr.
Buffer(const vector< cl_mem_properties > &properties, cl_mem_flags flags, size_type size, void *host_ptr=nullptr, cl_int *err=nullptr)
Constructs a Buffer in the default context and with specified properties.
Buffer createSubBuffer(cl_mem_flags flags, cl_buffer_create_type buffer_create_type, const void *buffer_create_info, cl_int *err=nullptr)
Creates a new buffer object from this.
Buffer(cl_mem_flags flags, size_type size, void *host_ptr=nullptr, cl_int *err=nullptr)
Constructs a Buffer in the default 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(const Context &context, cl_mem_flags flags, size_type size, void *host_ptr=nullptr, cl_int *err=nullptr)
Constructs a Buffer in a specified context.
Buffer(const Context &context, const vector< cl_mem_properties > &properties, cl_mem_flags flags, size_type size, void *host_ptr=nullptr, cl_int *err=nullptr)
Constructs a Buffer in a specified context and with specified properties.
Buffer(IteratorType startIterator, IteratorType endIterator, bool readOnly, bool useHostPtr=false, cl_int *err=nullptr)
Construct a Buffer from a host container via iterators. IteratorType must be random access....
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()
Default constructor - initializes to nullptr.
BufferRenderGL(const Context &context, cl_mem_flags flags, cl_GLuint bufobj, cl_int *err=nullptr)
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.
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=nullptr, Event *event=nullptr) const
CommandQueue(const cl_command_queue &commandQueue, bool retainObject=false)
Constructor from cl_command_queue - takes ownership.
CommandQueue(const Context &context, const Device &device, cl_command_queue_properties properties=0, cl_int *err=nullptr)
Constructs a CommandQueue for a passed device and context Will return an CL_INVALID_QUEUE_PROPERTIES ...
CommandQueue(QueueProperties properties, cl_int *err=nullptr)
Constructs a CommandQueue based on passed properties. Will return an CL_INVALID_QUEUE_PROPERTIES erro...
cl_int enqueueUnmapSVM(T *ptr, const vector< Event > *events=nullptr, Event *event=nullptr) 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=nullptr, Event *event=nullptr) const
cl_int enqueueMigrateSVM(const cl::vector< cl::pointer< T, D > > &svmPointers, cl_mem_migration_flags flags=0, const vector< Event > *events=nullptr, Event *event=nullptr) const
CommandQueue(const Context &context, const Device &device, QueueProperties properties, cl_int *err=nullptr)
Constructs a CommandQueue for a passed device and context Will return an CL_INVALID_QUEUE_PROPERTIES ...
CommandQueue(cl_command_queue_properties properties, cl_int *err=nullptr)
Constructs a CommandQueue based on passed properties. Will return an CL_INVALID_QUEUE_PROPERTIES erro...
cl_int enqueueMigrateMemObjects(const vector< Memory > &memObjects, cl_mem_migration_flags flags, const vector< Event > *events=nullptr, Event *event=nullptr) const
cl_int enqueueMarkerWithWaitList(const vector< Event > *events=nullptr, Event *event=nullptr) const
std::enable_if< std::is_same< T, cl_float4 >::value||std::is_same< T, cl_int4 >::value||std::is_same< T, cl_uint4 >::value, cl_int >::type enqueueFillImage(const Image &image, T fillColor, const array< size_type, 2 > &origin, const array< size_type, 2 > ®ion, const vector< Event > *events=nullptr, Event *event=nullptr) const
cl_int enqueueMigrateSVM(const cl::vector< T * > &svmRawPointers, cl_mem_migration_flags flags=0, const vector< Event > *events=nullptr, Event *event=nullptr) const
cl_int enqueueUnmapSVM(cl::vector< T, Alloc > &container, const vector< Event > *events=nullptr, Event *event=nullptr) const
CL_API_PREFIX__VERSION_1_1_DEPRECATED cl_int enqueueMarker(Event *event=nullptr) const CL_API_SUFFIX__VERSION_1_1_DEPRECATED
static CommandQueue setDefault(const CommandQueue &default_queue)
std::enable_if< std::is_same< T, cl_float4 >::value||std::is_same< T, cl_int4 >::value||std::is_same< T, cl_uint4 >::value, cl_int >::type enqueueFillImage(const Image &image, T fillColor, const array< size_type, 3 > &origin, const array< size_type, 3 > ®ion, const vector< Event > *events=nullptr, Event *event=nullptr) const
CommandQueue(const Context &context, QueueProperties properties, cl_int *err=nullptr)
Constructs a CommandQueue for an implementation defined device in the given context Will return an CL...
CommandQueue(const Context &context, cl_command_queue_properties properties=0, cl_int *err=nullptr)
Constructs a CommandQueue for an implementation defined device in the given context Will return an CL...
cl_int enqueueMapSVM(T *ptr, cl_bool blocking, cl_map_flags flags, size_type size, const vector< Event > *events=nullptr, Event *event=nullptr) const
cl_int enqueueMigrateSVM(const cl::vector< T * > &svmRawPointers, const cl::vector< size_type > &sizes, cl_mem_migration_flags flags=0, const vector< Event > *events=nullptr, Event *event=nullptr) const
cl_int enqueueMapSVM(cl::vector< T, Alloc > &container, cl_bool blocking, cl_map_flags flags, const vector< Event > *events=nullptr, Event *event=nullptr) 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=nullptr, Event *event=nullptr) const
cl_int enqueueFillBuffer(const Buffer &buffer, PatternType pattern, size_type offset, size_type size, const vector< Event > *events=nullptr, Event *event=nullptr) const
cl_int enqueueUnmapSVM(cl::pointer< T, D > &ptr, const vector< Event > *events=nullptr, Event *event=nullptr) const
cl_int enqueueMigrateSVM(const cl::vector< cl::vector< T, Alloc > > &svmContainers, cl_mem_migration_flags flags=0, const vector< Event > *events=nullptr, Event *event=nullptr) const
cl_int enqueueMapSVM(cl::pointer< T, D > &ptr, cl_bool blocking, cl_map_flags flags, size_type size, const vector< Event > *events=nullptr, Event *event=nullptr) const
Class interface for cl_context.
Context(cl_device_type type, const cl_context_properties *properties=nullptr, void(CL_CALLBACK *notifyFptr)(const char *, const void *, size_type, void *)=nullptr, void *data=nullptr, cl_int *err=nullptr)
Constructs a context including all or a subset of devices of a specified type.
Context & operator=(const cl_context &rhs)
Assignment operator from cl_context - takes ownership.
cl_int setDestructorCallback(void(CL_CALLBACK *pfn_notify)(cl_context, void *), void *user_data=nullptr)
Registers a destructor callback function with a context.
static Context setDefault(const Context &default_context)
Context(const cl_context &context, bool retainObject=false)
Constructor from cl_context - takes ownership.
static Context getDefault(cl_int *err=nullptr)
Returns a singleton context including all devices of CL_DEVICE_TYPE_DEFAULT.
cl_int getSupportedImageFormats(cl_mem_flags flags, cl_mem_object_type type, vector< ImageFormat > *formats) const
Gets a list of supported image formats.
Context(const Device &device, const cl_context_properties *properties=nullptr, void(CL_CALLBACK *notifyFptr)(const char *, const void *, size_type, void *)=nullptr, void *data=nullptr, cl_int *err=nullptr)
Constructs a context including a specific device.
Context()
Default constructor - initializes to nullptr.
cl_int getInfo(cl_context_info name, T *param) const
Wrapper for clGetContextInfo().
detail::param_traits< detail::cl_context_info, name >::param_type getInfo(cl_int *err=nullptr) const
Wrapper for clGetContextInfo() that returns by value.
Context(const vector< Device > &devices, const cl_context_properties *properties=nullptr, void(CL_CALLBACK *notifyFptr)(const char *, const void *, size_type, void *)=nullptr, void *data=nullptr, cl_int *err=nullptr)
Constructs a context including a list of specified devices.
DeviceCommandQueue interface for device cl_command_queues.
DeviceCommandQueue(DeviceQueueProperties properties, cl_int *err=nullptr)
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=nullptr)
static DeviceCommandQueue makeDefault(const Context &context, const Device &device, cl_uint queueSize, cl_int *err=nullptr)
DeviceCommandQueue(const Context &context, const Device &device, DeviceQueueProperties properties=DeviceQueueProperties::None, cl_int *err=nullptr)
DeviceCommandQueue(const cl_command_queue &commandQueue, bool retainObject=false)
Constructor from cl_command_queue - takes ownership.
static DeviceCommandQueue makeDefault(cl_int *err=nullptr)
DeviceCommandQueue(const Context &context, const Device &device, cl_uint queueSize, DeviceQueueProperties properties=DeviceQueueProperties::None, cl_int *err=nullptr)
Class interface for cl_device_id.
detail::param_traits< detail::cl_device_info, name >::param_type getInfo(cl_int *err=nullptr) const
Wrapper for clGetDeviceInfo() that returns by value.
static Device getDefault(cl_int *errResult=nullptr)
Returns the first device on the default context.
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 nullptr.
cl_ulong getHostTimer(cl_int *error=nullptr)
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.
detail::param_traits< detail::cl_profiling_info, name >::param_type getProfilingInfo(cl_int *err=nullptr) const
Wrapper for clGetEventProfilingInfo() that returns by value.
cl_int setCallback(cl_int type, void(CL_CALLBACK *pfn_notify)(cl_event, cl_int, void *), void *user_data=nullptr)
Registers a user callback function for a specific command execution status.
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 getInfo(cl_event_info name, T *param) const
Wrapper for clGetEventInfo().
cl_int wait() const
Blocks the calling thread until this event completes.
Event()
Default constructor - initializes to nullptr.
Event & operator=(const cl_event &rhs)
Assignment operator from cl_event - takes ownership.
detail::param_traits< detail::cl_event_info, name >::param_type getInfo(cl_int *err=nullptr) const
Wrapper for clGetEventInfo() that returns by value.
static cl_int waitForEvents(const vector< Event > &events)
Blocks the calling thread until every event specified is complete.
Image interface for arrays of 1D images.
Image1DArray(const cl_mem &imageArray, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Image interface for 1D buffer images.
Image1DBuffer(const cl_mem &image1D, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Class interface for 1D Image Memory objects.
Image1D()
Default constructor - initializes to nullptr.
Image1D & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
Image1D(const Context &context, cl_mem_flags flags, ImageFormat format, size_type width, void *host_ptr=nullptr, cl_int *err=nullptr)
Constructs a 1D Image in a specified context.
Image1D(const cl_mem &image1D, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Image interface for arrays of 2D images.
Image2DArray(const cl_mem &imageArray, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Class interface for GL 2D Image Memory objects.
Image2DGL()
Default constructor - initializes to nullptr.
Image2DGL(const Context &context, cl_mem_flags flags, cl_GLenum target, cl_GLint miplevel, cl_GLuint texobj, cl_int *err=nullptr)
Constructs an Image2DGL in a specified context, from a given GL Texture.
Image2DGL(const cl_mem &image, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Class interface for 2D Image Memory objects.
Image2D(const cl_mem &image2D, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Image2D(const Context &context, cl_mem_flags flags, ImageFormat format, size_type width, size_type height, size_type row_pitch=0, void *host_ptr=nullptr, cl_int *err=nullptr)
Constructs a 2D Image in a specified context.
Image2D()
Default constructor - initializes to nullptr.
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 nullptr.
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=nullptr)
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 nullptr.
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=nullptr, cl_int *err=nullptr)
Constructs a 3D Image in a specified context.
general image interface for GL interop. We abstract the 2D and 3D GL images into a single instance he...
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=nullptr) const
Wrapper for clGetImageInfo() that returns by value.
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 nullptr.
Event operator()(const EnqueueArgs &args, Ts... ts)
Event result_type
Return type of the functor.
Class interface for cl_kernel.
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 nullptr.
std::enable_if<!std::is_pointer< T >::value, cl_int >::type setArg(cl_uint index, const T &value)
setArg overload taking a POD type
cl_int 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.
Memory(const cl_mem &memory, bool retainObject)
Constructor from cl_mem - takes ownership.
Memory()
Default constructor - initializes to nullptr.
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().
cl_int setDestructorCallback(void(CL_CALLBACK *pfn_notify)(cl_mem, void *), void *user_data=nullptr)
Registers a callback function to be called when the memory object is no longer needed.
detail::param_traits< detail::cl_mem_info, name >::param_type getInfo(cl_int *err=nullptr) const
Wrapper for clGetMemObjectInfo() that returns by value.
Class interface for specifying NDRange values.
NDRange(array< size_type, 1 > a)
Constructs one-dimensional range.
size_type dimensions() const
Queries the number of dimensions in the range.
NDRange(size_type size0, size_type size1)
Constructs two-dimensional range.
NDRange(array< size_type, 3 > a)
Constructs three-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(array< size_type, 2 > a)
Constructs two-dimensional range.
NDRange(size_type size0)
Constructs one-dimensional range.
Class interface for Pipe Memory Objects.
detail::param_traits< detail::cl_pipe_info, name >::param_type getInfo(cl_int *err=nullptr) const
Wrapper for clGetMemObjectInfo() that returns by value.
Pipe(cl_uint packet_size, cl_uint max_packets, cl_int *err=nullptr)
Constructs a Pipe in a the default context.
Pipe()
Default constructor - initializes to nullptr.
cl_int getInfo(cl_pipe_info name, T *param) const
Wrapper for clGetMemObjectInfo().
Pipe(const cl_mem &pipe, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Pipe & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
Pipe(const Context &context, cl_uint packet_size, cl_uint max_packets, cl_int *err=nullptr)
Constructs a Pipe in a specified context.
Program interface that implements cl_program.
CL_API_PREFIX__VERSION_2_2_DEPRECATED cl_int setReleaseCallback(void(CL_CALLBACK *pfn_notify)(cl_program program, void *user_data), void *user_data=nullptr) 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 Sources &sources, cl_int *err=nullptr)
Program(const Context &context, const vector< char > &IL, bool build=false, cl_int *err=nullptr)
vector< std::pair< cl::Device, typename detail::param_traits< detail::cl_program_build_info, name >::param_type > > getBuildInfo(cl_int *err=nullptr) const
Program(const vector< char > &IL, bool build=false, cl_int *err=nullptr)
Program(const Context &context, const vector< Device > &devices, const Binaries &binaries, vector< cl_int > *binaryStatus=nullptr, cl_int *err=nullptr)
cl_int setSpecializationConstant(cl_uint index, size_type size, const void *value)
Sets a SPIR-V specialization constant.
Program(const Context &context, const vector< Device > &devices, const string &kernelNames, cl_int *err=nullptr)
Program(const cl_program &program, bool retainObject=false)
Constructor from cl_program - takes ownership.
std::enable_if<!std::is_pointer< T >::value, cl_int >::type setSpecializationConstant(cl_uint index, const T &value)
Sets a SPIR-V specialization constant.
Program(const Context &context, const Sources &sources, cl_int *err=nullptr)
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.
detail::param_traits< detail::cl_sampler_info, name >::param_type getInfo(cl_int *err=nullptr) const
Wrapper for clGetSamplerInfo() that returns by value.
Sampler()
Default constructor - initializes to nullptr.
Sampler & operator=(const cl_sampler &rhs)
Assignment operator from cl_sampler - takes ownership.
cl_int getInfo(cl_sampler_info name, T *param) const
Wrapper for clGetSamplerInfo().
Sampler(const Context &context, cl_bool normalized_coords, cl_addressing_mode addressing_mode, cl_filter_mode filter_mode, cl_int *err=nullptr)
Constructs a Sampler in a specified context.
Sampler(const cl_sampler &sampler, bool retainObject=false)
Constructor from cl_sampler - takes ownership.
Class interface for user events (a subset of cl_event's).
UserEvent()
Default constructor - initializes to nullptr.
UserEvent(const Context &context, cl_int *err=nullptr)
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::pointer< T, detail::Deleter< Alloc > > allocate_pointer(const Alloc &alloc_, Args &&... args)
cl_int enqueueUnmapSVM(T *ptr, const vector< Event > *events=nullptr, Event *event=nullptr)
vector< T, cl::SVMAllocator< int, cl::SVMTraitCoarse<> > > coarse_svm_vector
Vector alias to simplify contruction of coarse-grained SVM containers.
cl_int enqueueMapSVM(T *ptr, cl_bool blocking, cl_map_flags flags, size_type size, const vector< Event > *events=nullptr, Event *event=nullptr)
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)