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 >= 201703L
529# define CL_HPP_DEFINE_STATIC_MEMBER_ inline
530#elif defined(_MSC_VER)
531# define CL_HPP_DEFINE_STATIC_MEMBER_ __declspec(selectany)
532#elif defined(__MINGW32__)
533# define CL_HPP_DEFINE_STATIC_MEMBER_ __attribute__((selectany))
535# define CL_HPP_DEFINE_STATIC_MEMBER_ __attribute__((weak))
540#if !defined(CL_API_PREFIX__VERSION_1_1_DEPRECATED)
541#define CL_API_PREFIX__VERSION_1_1_DEPRECATED
543#if !defined(CL_API_SUFFIX__VERSION_1_1_DEPRECATED)
544#define CL_API_SUFFIX__VERSION_1_1_DEPRECATED
547#if !defined(CL_API_PREFIX__VERSION_1_2_DEPRECATED)
548#define CL_API_PREFIX__VERSION_1_2_DEPRECATED
550#if !defined(CL_API_SUFFIX__VERSION_1_2_DEPRECATED)
551#define CL_API_SUFFIX__VERSION_1_2_DEPRECATED
554#if !defined(CL_API_PREFIX__VERSION_2_2_DEPRECATED)
555#define CL_API_PREFIX__VERSION_2_2_DEPRECATED
557#if !defined(CL_API_SUFFIX__VERSION_2_2_DEPRECATED)
558#define CL_API_SUFFIX__VERSION_2_2_DEPRECATED
561#if !defined(CL_CALLBACK)
574#if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY)
576 using size_type = ::size_t;
580 using size_type = size_t;
585#if defined(CL_HPP_ENABLE_EXCEPTIONS)
589#if !defined(CL_HPP_NO_STD_VECTOR)
592 template <
class T,
class Alloc = std::allocator<T> >
593 using vector = std::vector<T, Alloc>;
597#if !defined(CL_HPP_NO_STD_STRING)
600 using string = std::string;
604#if CL_HPP_TARGET_OPENCL_VERSION >= 200
606#if !defined(CL_HPP_NO_STD_UNIQUE_PTR)
611 template<
class T,
class D>
612 using pointer = std::unique_ptr<T, D>;
616#if !defined(CL_HPP_NO_STD_ARRAY)
619 template <
class T,
size_type N >
620 using array = std::array<T, N>;
626#if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY)
628 namespace compatibility {
643 for (
int i = 0; i < N; ++i) {
648 size_t(
const array<size_type, N> &rhs)
650 for (
int i = 0; i < N; ++i) {
655 size_type& operator[](
int index)
660 const size_type& operator[](
int index)
const
666 operator size_type* () {
return data_; }
669 operator const size_type* ()
const {
return data_; }
671 operator array<size_type, N>()
const
673 array<size_type, N> ret;
675 for (
int i = 0; i < N; ++i) {
684 using size_t = compatibility::size_t<N>;
691 using size_t_array = array<size_type, 3>;
703#define CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(name) \
704 using PFN_##name = name##_fn
706#define CL_HPP_INIT_CL_EXT_FCN_PTR_(name) \
708 pfn_##name = (PFN_##name)clGetExtensionFunctionAddress(#name); \
711#define CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, name) \
713 pfn_##name = (PFN_##name) \
714 clGetExtensionFunctionAddressForPlatform(platform, #name); \
717#ifdef cl_khr_external_memory
718 enum class ExternalMemoryType : cl_external_memory_handle_type_khr;
727 class DeviceCommandQueue;
731#ifdef cl_khr_semaphore
734#if defined(cl_khr_command_buffer)
735 class CommandBufferKhr;
736 class MutableCommandKhr;
739#if defined(CL_HPP_ENABLE_EXCEPTIONS)
744 class Error :
public std::exception
748 const char * errStr_;
759 Error(cl_int err,
const char * errStr =
nullptr) : err_(err), errStr_(errStr)
766 const char * what() const noexcept
override
768 if (errStr_ ==
nullptr) {
780 cl_int err(
void)
const {
return err_; }
782#define CL_HPP_ERR_STR_(x) #x
784#define CL_HPP_ERR_STR_(x) nullptr
790#if defined(CL_HPP_ENABLE_EXCEPTIONS)
791static inline cl_int errHandler (
793 const char * errStr =
nullptr)
795 if (err != CL_SUCCESS) {
796 throw Error(err, errStr);
801static inline cl_int errHandler (cl_int err,
const char * errStr =
nullptr)
812#if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS)
813#define __GET_DEVICE_INFO_ERR CL_HPP_ERR_STR_(clGetDeviceInfo)
814#define __GET_PLATFORM_INFO_ERR CL_HPP_ERR_STR_(clGetPlatformInfo)
815#define __GET_DEVICE_IDS_ERR CL_HPP_ERR_STR_(clGetDeviceIDs)
816#define __GET_PLATFORM_IDS_ERR CL_HPP_ERR_STR_(clGetPlatformIDs)
817#define __GET_CONTEXT_INFO_ERR CL_HPP_ERR_STR_(clGetContextInfo)
818#define __GET_EVENT_INFO_ERR CL_HPP_ERR_STR_(clGetEventInfo)
819#define __GET_EVENT_PROFILE_INFO_ERR CL_HPP_ERR_STR_(clGetEventProfileInfo)
820#define __GET_MEM_OBJECT_INFO_ERR CL_HPP_ERR_STR_(clGetMemObjectInfo)
821#define __GET_IMAGE_INFO_ERR CL_HPP_ERR_STR_(clGetImageInfo)
822#define __GET_SAMPLER_INFO_ERR CL_HPP_ERR_STR_(clGetSamplerInfo)
823#define __GET_KERNEL_INFO_ERR CL_HPP_ERR_STR_(clGetKernelInfo)
824#if CL_HPP_TARGET_OPENCL_VERSION >= 120
825#define __GET_KERNEL_ARG_INFO_ERR CL_HPP_ERR_STR_(clGetKernelArgInfo)
827#if CL_HPP_TARGET_OPENCL_VERSION >= 210
828#define __GET_KERNEL_SUB_GROUP_INFO_ERR CL_HPP_ERR_STR_(clGetKernelSubGroupInfo)
830#define __GET_KERNEL_SUB_GROUP_INFO_ERR CL_HPP_ERR_STR_(clGetKernelSubGroupInfoKHR)
832#define __GET_KERNEL_WORK_GROUP_INFO_ERR CL_HPP_ERR_STR_(clGetKernelWorkGroupInfo)
833#define __GET_PROGRAM_INFO_ERR CL_HPP_ERR_STR_(clGetProgramInfo)
834#define __GET_PROGRAM_BUILD_INFO_ERR CL_HPP_ERR_STR_(clGetProgramBuildInfo)
835#define __GET_COMMAND_QUEUE_INFO_ERR CL_HPP_ERR_STR_(clGetCommandQueueInfo)
837#define __CREATE_CONTEXT_ERR CL_HPP_ERR_STR_(clCreateContext)
838#define __CREATE_CONTEXT_FROM_TYPE_ERR CL_HPP_ERR_STR_(clCreateContextFromType)
839#define __GET_SUPPORTED_IMAGE_FORMATS_ERR CL_HPP_ERR_STR_(clGetSupportedImageFormats)
840#if CL_HPP_TARGET_OPENCL_VERSION >= 300
841#define __SET_CONTEXT_DESCTRUCTOR_CALLBACK_ERR CL_HPP_ERR_STR_(clSetContextDestructorCallback)
844#define __CREATE_BUFFER_ERR CL_HPP_ERR_STR_(clCreateBuffer)
845#define __COPY_ERR CL_HPP_ERR_STR_(cl::copy)
846#define __CREATE_SUBBUFFER_ERR CL_HPP_ERR_STR_(clCreateSubBuffer)
847#define __CREATE_GL_BUFFER_ERR CL_HPP_ERR_STR_(clCreateFromGLBuffer)
848#define __CREATE_GL_RENDER_BUFFER_ERR CL_HPP_ERR_STR_(clCreateFromGLBuffer)
849#define __GET_GL_OBJECT_INFO_ERR CL_HPP_ERR_STR_(clGetGLObjectInfo)
850#if CL_HPP_TARGET_OPENCL_VERSION >= 120
851#define __CREATE_IMAGE_ERR CL_HPP_ERR_STR_(clCreateImage)
852#define __CREATE_GL_TEXTURE_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture)
853#define __IMAGE_DIMENSION_ERR CL_HPP_ERR_STR_(Incorrect image dimensions)
855#define __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR CL_HPP_ERR_STR_(clSetMemObjectDestructorCallback)
857#define __CREATE_USER_EVENT_ERR CL_HPP_ERR_STR_(clCreateUserEvent)
858#define __SET_USER_EVENT_STATUS_ERR CL_HPP_ERR_STR_(clSetUserEventStatus)
859#define __SET_EVENT_CALLBACK_ERR CL_HPP_ERR_STR_(clSetEventCallback)
860#define __WAIT_FOR_EVENTS_ERR CL_HPP_ERR_STR_(clWaitForEvents)
862#define __CREATE_KERNEL_ERR CL_HPP_ERR_STR_(clCreateKernel)
863#define __SET_KERNEL_ARGS_ERR CL_HPP_ERR_STR_(clSetKernelArg)
864#define __CREATE_PROGRAM_WITH_SOURCE_ERR CL_HPP_ERR_STR_(clCreateProgramWithSource)
865#define __CREATE_PROGRAM_WITH_BINARY_ERR CL_HPP_ERR_STR_(clCreateProgramWithBinary)
866#if CL_HPP_TARGET_OPENCL_VERSION >= 210
867#define __CREATE_PROGRAM_WITH_IL_ERR CL_HPP_ERR_STR_(clCreateProgramWithIL)
869#define __CREATE_PROGRAM_WITH_IL_ERR CL_HPP_ERR_STR_(clCreateProgramWithILKHR)
871#if CL_HPP_TARGET_OPENCL_VERSION >= 120
872#define __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR CL_HPP_ERR_STR_(clCreateProgramWithBuiltInKernels)
874#define __BUILD_PROGRAM_ERR CL_HPP_ERR_STR_(clBuildProgram)
875#if CL_HPP_TARGET_OPENCL_VERSION >= 120
876#define __COMPILE_PROGRAM_ERR CL_HPP_ERR_STR_(clCompileProgram)
877#define __LINK_PROGRAM_ERR CL_HPP_ERR_STR_(clLinkProgram)
879#define __CREATE_KERNELS_IN_PROGRAM_ERR CL_HPP_ERR_STR_(clCreateKernelsInProgram)
881#if CL_HPP_TARGET_OPENCL_VERSION >= 200
882#define __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR CL_HPP_ERR_STR_(clCreateCommandQueueWithProperties)
883#define __CREATE_SAMPLER_WITH_PROPERTIES_ERR CL_HPP_ERR_STR_(clCreateSamplerWithProperties)
885#define __SET_COMMAND_QUEUE_PROPERTY_ERR CL_HPP_ERR_STR_(clSetCommandQueueProperty)
886#define __ENQUEUE_READ_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueReadBuffer)
887#define __ENQUEUE_READ_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueReadBufferRect)
888#define __ENQUEUE_WRITE_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueWriteBuffer)
889#define __ENQUEUE_WRITE_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueWriteBufferRect)
890#define __ENQEUE_COPY_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueCopyBuffer)
891#define __ENQEUE_COPY_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueCopyBufferRect)
892#define __ENQUEUE_FILL_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueFillBuffer)
893#define __ENQUEUE_READ_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueReadImage)
894#define __ENQUEUE_WRITE_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueWriteImage)
895#define __ENQUEUE_COPY_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueCopyImage)
896#define __ENQUEUE_FILL_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueFillImage)
897#define __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueCopyImageToBuffer)
898#define __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueCopyBufferToImage)
899#define __ENQUEUE_MAP_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueMapBuffer)
900#define __ENQUEUE_MAP_SVM_ERR CL_HPP_ERR_STR_(clEnqueueSVMMap)
901#define __ENQUEUE_FILL_SVM_ERR CL_HPP_ERR_STR_(clEnqueueSVMMemFill)
902#define __ENQUEUE_COPY_SVM_ERR CL_HPP_ERR_STR_(clEnqueueSVMMemcpy)
903#define __ENQUEUE_UNMAP_SVM_ERR CL_HPP_ERR_STR_(clEnqueueSVMUnmap)
904#define __ENQUEUE_MAP_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueMapImage)
905#define __ENQUEUE_UNMAP_MEM_OBJECT_ERR CL_HPP_ERR_STR_(clEnqueueUnMapMemObject)
906#define __ENQUEUE_NDRANGE_KERNEL_ERR CL_HPP_ERR_STR_(clEnqueueNDRangeKernel)
907#define __ENQUEUE_NATIVE_KERNEL CL_HPP_ERR_STR_(clEnqueueNativeKernel)
908#if CL_HPP_TARGET_OPENCL_VERSION >= 120
909#define __ENQUEUE_MIGRATE_MEM_OBJECTS_ERR CL_HPP_ERR_STR_(clEnqueueMigrateMemObjects)
911#if CL_HPP_TARGET_OPENCL_VERSION >= 210
912#define __ENQUEUE_MIGRATE_SVM_ERR CL_HPP_ERR_STR_(clEnqueueSVMMigrateMem)
913#define __SET_DEFAULT_DEVICE_COMMAND_QUEUE_ERR CL_HPP_ERR_STR_(clSetDefaultDeviceCommandQueue)
917#define __ENQUEUE_ACQUIRE_GL_ERR CL_HPP_ERR_STR_(clEnqueueAcquireGLObjects)
918#define __ENQUEUE_RELEASE_GL_ERR CL_HPP_ERR_STR_(clEnqueueReleaseGLObjects)
920#define __CREATE_PIPE_ERR CL_HPP_ERR_STR_(clCreatePipe)
921#define __GET_PIPE_INFO_ERR CL_HPP_ERR_STR_(clGetPipeInfo)
923#define __RETAIN_ERR CL_HPP_ERR_STR_(Retain Object)
924#define __RELEASE_ERR CL_HPP_ERR_STR_(Release Object)
925#define __FLUSH_ERR CL_HPP_ERR_STR_(clFlush)
926#define __FINISH_ERR CL_HPP_ERR_STR_(clFinish)
927#define __VECTOR_CAPACITY_ERR CL_HPP_ERR_STR_(Vector capacity error)
929#if CL_HPP_TARGET_OPENCL_VERSION >= 210
930#define __GET_HOST_TIMER_ERR CL_HPP_ERR_STR_(clGetHostTimer)
931#define __GET_DEVICE_AND_HOST_TIMER_ERR CL_HPP_ERR_STR_(clGetDeviceAndHostTimer)
933#if CL_HPP_TARGET_OPENCL_VERSION >= 220
934#define __SET_PROGRAM_RELEASE_CALLBACK_ERR CL_HPP_ERR_STR_(clSetProgramReleaseCallback)
935#define __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR CL_HPP_ERR_STR_(clSetProgramSpecializationConstant)
938#ifdef cl_khr_external_memory
939#define __ENQUEUE_ACQUIRE_EXTERNAL_MEMORY_ERR CL_HPP_ERR_STR_(clEnqueueAcquireExternalMemObjectsKHR)
940#define __ENQUEUE_RELEASE_EXTERNAL_MEMORY_ERR CL_HPP_ERR_STR_(clEnqueueReleaseExternalMemObjectsKHR)
943#ifdef cl_khr_semaphore
944#define __GET_SEMAPHORE_KHR_INFO_ERR CL_HPP_ERR_STR_(clGetSemaphoreInfoKHR)
945#define __CREATE_SEMAPHORE_KHR_WITH_PROPERTIES_ERR CL_HPP_ERR_STR_(clCreateSemaphoreWithPropertiesKHR)
946#define __ENQUEUE_WAIT_SEMAPHORE_KHR_ERR CL_HPP_ERR_STR_(clEnqueueWaitSemaphoresKHR)
947#define __ENQUEUE_SIGNAL_SEMAPHORE_KHR_ERR CL_HPP_ERR_STR_(clEnqueueSignalSemaphoresKHR)
948#define __RETAIN_SEMAPHORE_KHR_ERR CL_HPP_ERR_STR_(clRetainSemaphoreKHR)
949#define __RELEASE_SEMAPHORE_KHR_ERR CL_HPP_ERR_STR_(clReleaseSemaphoreKHR)
952#ifdef cl_khr_external_semaphore
953#define __GET_SEMAPHORE_HANDLE_FOR_TYPE_KHR_ERR CL_HPP_ERR_STR_(clGetSemaphoreHandleForTypeKHR)
956#if defined(cl_khr_command_buffer)
957#define __CREATE_COMMAND_BUFFER_KHR_ERR CL_HPP_ERR_STR_(clCreateCommandBufferKHR)
958#define __GET_COMMAND_BUFFER_INFO_KHR_ERR CL_HPP_ERR_STR_(clGetCommandBufferInfoKHR)
959#define __FINALIZE_COMMAND_BUFFER_KHR_ERR CL_HPP_ERR_STR_(clFinalizeCommandBufferKHR)
960#define __ENQUEUE_COMMAND_BUFFER_KHR_ERR CL_HPP_ERR_STR_(clEnqueueCommandBufferKHR)
961#define __COMMAND_BARRIER_WITH_WAIT_LIST_KHR_ERR CL_HPP_ERR_STR_(clCommandBarrierWithWaitListKHR)
962#define __COMMAND_COPY_BUFFER_KHR_ERR CL_HPP_ERR_STR_(clCommandCopyBufferKHR)
963#define __COMMAND_COPY_BUFFER_RECT_KHR_ERR CL_HPP_ERR_STR_(clCommandCopyBufferRectKHR)
964#define __COMMAND_COPY_BUFFER_TO_IMAGE_KHR_ERR CL_HPP_ERR_STR_(clCommandCopyBufferToImageKHR)
965#define __COMMAND_COPY_IMAGE_KHR_ERR CL_HPP_ERR_STR_(clCommandCopyImageKHR)
966#define __COMMAND_COPY_IMAGE_TO_BUFFER_KHR_ERR CL_HPP_ERR_STR_(clCommandCopyImageToBufferKHR)
967#define __COMMAND_FILL_BUFFER_KHR_ERR CL_HPP_ERR_STR_(clCommandFillBufferKHR)
968#define __COMMAND_FILL_IMAGE_KHR_ERR CL_HPP_ERR_STR_(clCommandFillImageKHR)
969#define __COMMAND_NDRANGE_KERNEL_KHR_ERR CL_HPP_ERR_STR_(clCommandNDRangeKernelKHR)
970#define __UPDATE_MUTABLE_COMMANDS_KHR_ERR CL_HPP_ERR_STR_(clUpdateMutableCommandsKHR)
971#define __GET_MUTABLE_COMMAND_INFO_KHR_ERR CL_HPP_ERR_STR_(clGetMutableCommandInfoKHR)
972#define __RETAIN_COMMAND_BUFFER_KHR_ERR CL_HPP_ERR_STR_(clRetainCommandBufferKHR)
973#define __RELEASE_COMMAND_BUFFER_KHR_ERR CL_HPP_ERR_STR_(clReleaseCommandBufferKHR)
976#if defined(cl_ext_image_requirements_info)
977#define __GET_IMAGE_REQUIREMENT_INFO_EXT_ERR CL_HPP_ERR_STR_(clGetImageRequirementsInfoEXT)
983#if CL_HPP_TARGET_OPENCL_VERSION >= 120
984#define __CREATE_SUB_DEVICES_ERR CL_HPP_ERR_STR_(clCreateSubDevices)
986#define __CREATE_SUB_DEVICES_ERR CL_HPP_ERR_STR_(clCreateSubDevicesEXT)
992#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
993#define __ENQUEUE_MARKER_ERR CL_HPP_ERR_STR_(clEnqueueMarker)
994#define __ENQUEUE_WAIT_FOR_EVENTS_ERR CL_HPP_ERR_STR_(clEnqueueWaitForEvents)
995#define __ENQUEUE_BARRIER_ERR CL_HPP_ERR_STR_(clEnqueueBarrier)
996#define __UNLOAD_COMPILER_ERR CL_HPP_ERR_STR_(clUnloadCompiler)
997#define __CREATE_GL_TEXTURE_2D_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture2D)
998#define __CREATE_GL_TEXTURE_3D_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture3D)
999#define __CREATE_IMAGE2D_ERR CL_HPP_ERR_STR_(clCreateImage2D)
1000#define __CREATE_IMAGE3D_ERR CL_HPP_ERR_STR_(clCreateImage3D)
1006#if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
1007#define __CREATE_COMMAND_QUEUE_ERR CL_HPP_ERR_STR_(clCreateCommandQueue)
1008#define __ENQUEUE_TASK_ERR CL_HPP_ERR_STR_(clEnqueueTask)
1009#define __CREATE_SAMPLER_ERR CL_HPP_ERR_STR_(clCreateSampler)
1015#if CL_HPP_TARGET_OPENCL_VERSION >= 120
1016#define __ENQUEUE_MARKER_WAIT_LIST_ERR CL_HPP_ERR_STR_(clEnqueueMarkerWithWaitList)
1017#define __ENQUEUE_BARRIER_WAIT_LIST_ERR CL_HPP_ERR_STR_(clEnqueueBarrierWithWaitList)
1020#if CL_HPP_TARGET_OPENCL_VERSION >= 210
1021#define __CLONE_KERNEL_ERR CL_HPP_ERR_STR_(clCloneKernel)
1027#ifdef cl_khr_external_memory
1028CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clEnqueueAcquireExternalMemObjectsKHR);
1029CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clEnqueueReleaseExternalMemObjectsKHR);
1031CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clEnqueueAcquireExternalMemObjectsKHR pfn_clEnqueueAcquireExternalMemObjectsKHR =
nullptr;
1032CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clEnqueueReleaseExternalMemObjectsKHR pfn_clEnqueueReleaseExternalMemObjectsKHR =
nullptr;
1035#ifdef cl_khr_semaphore
1036CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCreateSemaphoreWithPropertiesKHR);
1037CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clReleaseSemaphoreKHR);
1038CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clRetainSemaphoreKHR);
1039CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clEnqueueWaitSemaphoresKHR);
1040CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clEnqueueSignalSemaphoresKHR);
1041CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clGetSemaphoreInfoKHR);
1043CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCreateSemaphoreWithPropertiesKHR pfn_clCreateSemaphoreWithPropertiesKHR =
nullptr;
1044CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clReleaseSemaphoreKHR pfn_clReleaseSemaphoreKHR =
nullptr;
1045CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clRetainSemaphoreKHR pfn_clRetainSemaphoreKHR =
nullptr;
1046CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clEnqueueWaitSemaphoresKHR pfn_clEnqueueWaitSemaphoresKHR =
nullptr;
1047CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clEnqueueSignalSemaphoresKHR pfn_clEnqueueSignalSemaphoresKHR =
nullptr;
1048CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clGetSemaphoreInfoKHR pfn_clGetSemaphoreInfoKHR =
nullptr;
1051#ifdef cl_khr_external_semaphore
1052CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clGetSemaphoreHandleForTypeKHR);
1053CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clGetSemaphoreHandleForTypeKHR pfn_clGetSemaphoreHandleForTypeKHR =
nullptr;
1056#if defined(cl_khr_command_buffer)
1057CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCreateCommandBufferKHR);
1058CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clFinalizeCommandBufferKHR);
1059CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clRetainCommandBufferKHR);
1060CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clReleaseCommandBufferKHR);
1061CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clGetCommandBufferInfoKHR);
1062CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clEnqueueCommandBufferKHR);
1063CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandBarrierWithWaitListKHR);
1064CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandCopyBufferKHR);
1065CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandCopyBufferRectKHR);
1066CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandCopyBufferToImageKHR);
1067CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandCopyImageKHR);
1068CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandCopyImageToBufferKHR);
1069CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandFillBufferKHR);
1070CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandFillImageKHR);
1071CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandNDRangeKernelKHR);
1073CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCreateCommandBufferKHR pfn_clCreateCommandBufferKHR =
nullptr;
1074CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clFinalizeCommandBufferKHR pfn_clFinalizeCommandBufferKHR =
nullptr;
1075CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clRetainCommandBufferKHR pfn_clRetainCommandBufferKHR =
nullptr;
1076CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clReleaseCommandBufferKHR pfn_clReleaseCommandBufferKHR =
nullptr;
1077CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clGetCommandBufferInfoKHR pfn_clGetCommandBufferInfoKHR =
nullptr;
1078CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clEnqueueCommandBufferKHR pfn_clEnqueueCommandBufferKHR =
nullptr;
1079CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandBarrierWithWaitListKHR pfn_clCommandBarrierWithWaitListKHR =
nullptr;
1080CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandCopyBufferKHR pfn_clCommandCopyBufferKHR =
nullptr;
1081CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandCopyBufferRectKHR pfn_clCommandCopyBufferRectKHR =
nullptr;
1082CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandCopyBufferToImageKHR pfn_clCommandCopyBufferToImageKHR =
nullptr;
1083CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandCopyImageKHR pfn_clCommandCopyImageKHR =
nullptr;
1084CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandCopyImageToBufferKHR pfn_clCommandCopyImageToBufferKHR =
nullptr;
1085CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandFillBufferKHR pfn_clCommandFillBufferKHR =
nullptr;
1086CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandFillImageKHR pfn_clCommandFillImageKHR =
nullptr;
1087CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandNDRangeKernelKHR pfn_clCommandNDRangeKernelKHR =
nullptr;
1090#if defined(cl_khr_command_buffer_mutable_dispatch)
1091CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clUpdateMutableCommandsKHR);
1092CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clGetMutableCommandInfoKHR);
1094CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clUpdateMutableCommandsKHR pfn_clUpdateMutableCommandsKHR =
nullptr;
1095CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clGetMutableCommandInfoKHR pfn_clGetMutableCommandInfoKHR =
nullptr;
1098#if defined(cl_ext_image_requirements_info)
1099CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clGetImageRequirementsInfoEXT);
1100CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clGetImageRequirementsInfoEXT pfn_clGetImageRequirementsInfoEXT =
nullptr;
1103#if defined(cl_ext_device_fission)
1104CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCreateSubDevicesEXT);
1105CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCreateSubDevicesEXT
1106 pfn_clCreateSubDevicesEXT =
nullptr;
1115template<
typename Functor,
typename T>
1116inline cl_int getInfoHelper(Functor f, cl_uint name, T* param,
long)
1118 return f(name,
sizeof(T), param,
nullptr);
1123template <
typename Func>
1124inline cl_int getInfoHelper(Func f, cl_uint name, vector<vector<unsigned char>>* param,
int)
1126 if (name != CL_PROGRAM_BINARIES) {
1127 return CL_INVALID_VALUE;
1131 size_type numBinaries = param->size();
1132 vector<unsigned char*> binariesPointers(numBinaries);
1134 for (size_type i = 0; i < numBinaries; ++i)
1136 binariesPointers[i] = (*param)[i].data();
1139 cl_int err = f(name, numBinaries *
sizeof(
unsigned char*), binariesPointers.data(),
nullptr);
1141 if (err != CL_SUCCESS) {
1150template <
typename Func,
typename T>
1151inline cl_int getInfoHelper(Func f, cl_uint name, vector<T>* param,
long)
1154 cl_int err = f(name, 0,
nullptr, &required);
1155 if (err != CL_SUCCESS) {
1158 const size_type elements = required /
sizeof(T);
1161 vector<T> localData(elements);
1162 err = f(name, required, localData.data(),
nullptr);
1163 if (err != CL_SUCCESS) {
1167 *param = std::move(localData);
1179template <
typename Func,
typename T>
1180inline cl_int getInfoHelper(
1181 Func f, cl_uint name, vector<T>* param,
int,
typename T::cl_type = 0)
1184 cl_int err = f(name, 0,
nullptr, &required);
1185 if (err != CL_SUCCESS) {
1189 const size_type elements = required /
sizeof(
typename T::cl_type);
1191 vector<typename T::cl_type> value(elements);
1192 err = f(name, required, value.data(),
nullptr);
1193 if (err != CL_SUCCESS) {
1199 param->resize(elements);
1203 for (size_type i = 0; i < elements; i++) {
1204 (*param)[i] = T(value[i],
true);
1211template <
typename Func>
1212inline cl_int getInfoHelper(Func f, cl_uint name,
string* param,
long)
1215 cl_int err = f(name, 0,
nullptr, &required);
1216 if (err != CL_SUCCESS) {
1223 vector<char> value(required);
1224 err = f(name, required, value.data(),
nullptr);
1225 if (err != CL_SUCCESS) {
1229 param->assign(value.begin(), value.end() - 1);
1239template <
typename Func,
size_type N>
1240inline cl_int getInfoHelper(Func f, cl_uint name, array<size_type, N>* param,
long)
1243 cl_int err = f(name, 0,
nullptr, &required);
1244 if (err != CL_SUCCESS) {
1248 size_type elements = required /
sizeof(size_type);
1249 vector<size_type> value(elements, 0);
1251 err = f(name, required, value.data(),
nullptr);
1252 if (err != CL_SUCCESS) {
1261 for (size_type i = 0; i < elements; ++i) {
1262 (*param)[i] = value[i];
1268template<
typename T>
struct ReferenceHandler;
1276template<
typename Func,
typename T>
1277inline cl_int getInfoHelper(Func f, cl_uint name, T* param,
int,
typename T::cl_type = 0)
1279 typename T::cl_type value;
1280 cl_int err = f(name,
sizeof(value), &value,
nullptr);
1281 if (err != CL_SUCCESS) {
1285 if (value !=
nullptr)
1287 err = param->retain();
1288 if (err != CL_SUCCESS) {
1295#define CL_HPP_PARAM_NAME_INFO_1_0_(F) \
1296 F(cl_platform_info, CL_PLATFORM_PROFILE, string) \
1297 F(cl_platform_info, CL_PLATFORM_VERSION, string) \
1298 F(cl_platform_info, CL_PLATFORM_NAME, string) \
1299 F(cl_platform_info, CL_PLATFORM_VENDOR, string) \
1300 F(cl_platform_info, CL_PLATFORM_EXTENSIONS, string) \
1302 F(cl_device_info, CL_DEVICE_TYPE, cl_device_type) \
1303 F(cl_device_info, CL_DEVICE_VENDOR_ID, cl_uint) \
1304 F(cl_device_info, CL_DEVICE_MAX_COMPUTE_UNITS, cl_uint) \
1305 F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, cl_uint) \
1306 F(cl_device_info, CL_DEVICE_MAX_WORK_GROUP_SIZE, size_type) \
1307 F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_SIZES, cl::vector<size_type>) \
1308 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, cl_uint) \
1309 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT, cl_uint) \
1310 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT, cl_uint) \
1311 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG, cl_uint) \
1312 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT, cl_uint) \
1313 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, cl_uint) \
1314 F(cl_device_info, CL_DEVICE_MAX_CLOCK_FREQUENCY, cl_uint) \
1315 F(cl_device_info, CL_DEVICE_ADDRESS_BITS, cl_uint) \
1316 F(cl_device_info, CL_DEVICE_MAX_READ_IMAGE_ARGS, cl_uint) \
1317 F(cl_device_info, CL_DEVICE_MAX_WRITE_IMAGE_ARGS, cl_uint) \
1318 F(cl_device_info, CL_DEVICE_MAX_MEM_ALLOC_SIZE, cl_ulong) \
1319 F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_WIDTH, size_type) \
1320 F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_HEIGHT, size_type) \
1321 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_WIDTH, size_type) \
1322 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_HEIGHT, size_type) \
1323 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_DEPTH, size_type) \
1324 F(cl_device_info, CL_DEVICE_IMAGE_SUPPORT, cl_bool) \
1325 F(cl_device_info, CL_DEVICE_MAX_PARAMETER_SIZE, size_type) \
1326 F(cl_device_info, CL_DEVICE_MAX_SAMPLERS, cl_uint) \
1327 F(cl_device_info, CL_DEVICE_MEM_BASE_ADDR_ALIGN, cl_uint) \
1328 F(cl_device_info, CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE, cl_uint) \
1329 F(cl_device_info, CL_DEVICE_SINGLE_FP_CONFIG, cl_device_fp_config) \
1330 F(cl_device_info, CL_DEVICE_DOUBLE_FP_CONFIG, cl_device_fp_config) \
1331 F(cl_device_info, CL_DEVICE_HALF_FP_CONFIG, cl_device_fp_config) \
1332 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_TYPE, cl_device_mem_cache_type) \
1333 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE, cl_uint)\
1334 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_SIZE, cl_ulong) \
1335 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_SIZE, cl_ulong) \
1336 F(cl_device_info, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE, cl_ulong) \
1337 F(cl_device_info, CL_DEVICE_MAX_CONSTANT_ARGS, cl_uint) \
1338 F(cl_device_info, CL_DEVICE_LOCAL_MEM_TYPE, cl_device_local_mem_type) \
1339 F(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE, cl_ulong) \
1340 F(cl_device_info, CL_DEVICE_ERROR_CORRECTION_SUPPORT, cl_bool) \
1341 F(cl_device_info, CL_DEVICE_PROFILING_TIMER_RESOLUTION, size_type) \
1342 F(cl_device_info, CL_DEVICE_ENDIAN_LITTLE, cl_bool) \
1343 F(cl_device_info, CL_DEVICE_AVAILABLE, cl_bool) \
1344 F(cl_device_info, CL_DEVICE_COMPILER_AVAILABLE, cl_bool) \
1345 F(cl_device_info, CL_DEVICE_EXECUTION_CAPABILITIES, cl_device_exec_capabilities) \
1346 F(cl_device_info, CL_DEVICE_PLATFORM, cl::Platform) \
1347 F(cl_device_info, CL_DEVICE_NAME, string) \
1348 F(cl_device_info, CL_DEVICE_VENDOR, string) \
1349 F(cl_device_info, CL_DRIVER_VERSION, string) \
1350 F(cl_device_info, CL_DEVICE_PROFILE, string) \
1351 F(cl_device_info, CL_DEVICE_VERSION, string) \
1352 F(cl_device_info, CL_DEVICE_EXTENSIONS, string) \
1354 F(cl_context_info, CL_CONTEXT_REFERENCE_COUNT, cl_uint) \
1355 F(cl_context_info, CL_CONTEXT_DEVICES, cl::vector<Device>) \
1356 F(cl_context_info, CL_CONTEXT_PROPERTIES, cl::vector<cl_context_properties>) \
1358 F(cl_event_info, CL_EVENT_COMMAND_QUEUE, cl::CommandQueue) \
1359 F(cl_event_info, CL_EVENT_COMMAND_TYPE, cl_command_type) \
1360 F(cl_event_info, CL_EVENT_REFERENCE_COUNT, cl_uint) \
1361 F(cl_event_info, CL_EVENT_COMMAND_EXECUTION_STATUS, cl_int) \
1363 F(cl_profiling_info, CL_PROFILING_COMMAND_QUEUED, cl_ulong) \
1364 F(cl_profiling_info, CL_PROFILING_COMMAND_SUBMIT, cl_ulong) \
1365 F(cl_profiling_info, CL_PROFILING_COMMAND_START, cl_ulong) \
1366 F(cl_profiling_info, CL_PROFILING_COMMAND_END, cl_ulong) \
1368 F(cl_mem_info, CL_MEM_TYPE, cl_mem_object_type) \
1369 F(cl_mem_info, CL_MEM_FLAGS, cl_mem_flags) \
1370 F(cl_mem_info, CL_MEM_SIZE, size_type) \
1371 F(cl_mem_info, CL_MEM_HOST_PTR, void*) \
1372 F(cl_mem_info, CL_MEM_MAP_COUNT, cl_uint) \
1373 F(cl_mem_info, CL_MEM_REFERENCE_COUNT, cl_uint) \
1374 F(cl_mem_info, CL_MEM_CONTEXT, cl::Context) \
1376 F(cl_image_info, CL_IMAGE_FORMAT, cl_image_format) \
1377 F(cl_image_info, CL_IMAGE_ELEMENT_SIZE, size_type) \
1378 F(cl_image_info, CL_IMAGE_ROW_PITCH, size_type) \
1379 F(cl_image_info, CL_IMAGE_SLICE_PITCH, size_type) \
1380 F(cl_image_info, CL_IMAGE_WIDTH, size_type) \
1381 F(cl_image_info, CL_IMAGE_HEIGHT, size_type) \
1382 F(cl_image_info, CL_IMAGE_DEPTH, size_type) \
1384 F(cl_sampler_info, CL_SAMPLER_REFERENCE_COUNT, cl_uint) \
1385 F(cl_sampler_info, CL_SAMPLER_CONTEXT, cl::Context) \
1386 F(cl_sampler_info, CL_SAMPLER_NORMALIZED_COORDS, cl_bool) \
1387 F(cl_sampler_info, CL_SAMPLER_ADDRESSING_MODE, cl_addressing_mode) \
1388 F(cl_sampler_info, CL_SAMPLER_FILTER_MODE, cl_filter_mode) \
1390 F(cl_program_info, CL_PROGRAM_REFERENCE_COUNT, cl_uint) \
1391 F(cl_program_info, CL_PROGRAM_CONTEXT, cl::Context) \
1392 F(cl_program_info, CL_PROGRAM_NUM_DEVICES, cl_uint) \
1393 F(cl_program_info, CL_PROGRAM_DEVICES, cl::vector<Device>) \
1394 F(cl_program_info, CL_PROGRAM_SOURCE, string) \
1395 F(cl_program_info, CL_PROGRAM_BINARY_SIZES, cl::vector<size_type>) \
1396 F(cl_program_info, CL_PROGRAM_BINARIES, cl::vector<cl::vector<unsigned char>>) \
1398 F(cl_program_build_info, CL_PROGRAM_BUILD_STATUS, cl_build_status) \
1399 F(cl_program_build_info, CL_PROGRAM_BUILD_OPTIONS, string) \
1400 F(cl_program_build_info, CL_PROGRAM_BUILD_LOG, string) \
1402 F(cl_kernel_info, CL_KERNEL_FUNCTION_NAME, string) \
1403 F(cl_kernel_info, CL_KERNEL_NUM_ARGS, cl_uint) \
1404 F(cl_kernel_info, CL_KERNEL_REFERENCE_COUNT, cl_uint) \
1405 F(cl_kernel_info, CL_KERNEL_CONTEXT, cl::Context) \
1406 F(cl_kernel_info, CL_KERNEL_PROGRAM, cl::Program) \
1408 F(cl_kernel_work_group_info, CL_KERNEL_WORK_GROUP_SIZE, size_type) \
1409 F(cl_kernel_work_group_info, CL_KERNEL_COMPILE_WORK_GROUP_SIZE, cl::detail::size_t_array) \
1410 F(cl_kernel_work_group_info, CL_KERNEL_LOCAL_MEM_SIZE, cl_ulong) \
1412 F(cl_command_queue_info, CL_QUEUE_CONTEXT, cl::Context) \
1413 F(cl_command_queue_info, CL_QUEUE_DEVICE, cl::Device) \
1414 F(cl_command_queue_info, CL_QUEUE_REFERENCE_COUNT, cl_uint) \
1415 F(cl_command_queue_info, CL_QUEUE_PROPERTIES, cl_command_queue_properties)
1418#define CL_HPP_PARAM_NAME_INFO_1_1_(F) \
1419 F(cl_context_info, CL_CONTEXT_NUM_DEVICES, cl_uint)\
1420 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF, cl_uint) \
1421 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR, cl_uint) \
1422 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT, cl_uint) \
1423 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_INT, cl_uint) \
1424 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG, cl_uint) \
1425 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT, cl_uint) \
1426 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE, cl_uint) \
1427 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF, cl_uint) \
1428 F(cl_device_info, CL_DEVICE_OPENCL_C_VERSION, string) \
1430 F(cl_mem_info, CL_MEM_ASSOCIATED_MEMOBJECT, cl::Memory) \
1431 F(cl_mem_info, CL_MEM_OFFSET, size_type) \
1433 F(cl_kernel_work_group_info, CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, size_type) \
1434 F(cl_kernel_work_group_info, CL_KERNEL_PRIVATE_MEM_SIZE, cl_ulong) \
1436 F(cl_event_info, CL_EVENT_CONTEXT, cl::Context)
1438#define CL_HPP_PARAM_NAME_INFO_1_2_(F) \
1439 F(cl_program_info, CL_PROGRAM_NUM_KERNELS, size_type) \
1440 F(cl_program_info, CL_PROGRAM_KERNEL_NAMES, string) \
1442 F(cl_program_build_info, CL_PROGRAM_BINARY_TYPE, cl_program_binary_type) \
1444 F(cl_kernel_info, CL_KERNEL_ATTRIBUTES, string) \
1446 F(cl_kernel_arg_info, CL_KERNEL_ARG_ADDRESS_QUALIFIER, cl_kernel_arg_address_qualifier) \
1447 F(cl_kernel_arg_info, CL_KERNEL_ARG_ACCESS_QUALIFIER, cl_kernel_arg_access_qualifier) \
1448 F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_NAME, string) \
1449 F(cl_kernel_arg_info, CL_KERNEL_ARG_NAME, string) \
1450 F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_QUALIFIER, cl_kernel_arg_type_qualifier) \
1452 F(cl_kernel_work_group_info, CL_KERNEL_GLOBAL_WORK_SIZE, cl::detail::size_t_array) \
1454 F(cl_device_info, CL_DEVICE_LINKER_AVAILABLE, cl_bool) \
1455 F(cl_device_info, CL_DEVICE_IMAGE_MAX_BUFFER_SIZE, size_type) \
1456 F(cl_device_info, CL_DEVICE_IMAGE_MAX_ARRAY_SIZE, size_type) \
1457 F(cl_device_info, CL_DEVICE_PARENT_DEVICE, cl::Device) \
1458 F(cl_device_info, CL_DEVICE_PARTITION_MAX_SUB_DEVICES, cl_uint) \
1459 F(cl_device_info, CL_DEVICE_PARTITION_PROPERTIES, cl::vector<cl_device_partition_property>) \
1460 F(cl_device_info, CL_DEVICE_PARTITION_TYPE, cl::vector<cl_device_partition_property>) \
1461 F(cl_device_info, CL_DEVICE_REFERENCE_COUNT, cl_uint) \
1462 F(cl_device_info, CL_DEVICE_PREFERRED_INTEROP_USER_SYNC, cl_bool) \
1463 F(cl_device_info, CL_DEVICE_PARTITION_AFFINITY_DOMAIN, cl_device_affinity_domain) \
1464 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS, string) \
1465 F(cl_device_info, CL_DEVICE_PRINTF_BUFFER_SIZE, size_type) \
1467 F(cl_image_info, CL_IMAGE_ARRAY_SIZE, size_type) \
1468 F(cl_image_info, CL_IMAGE_NUM_MIP_LEVELS, cl_uint) \
1469 F(cl_image_info, CL_IMAGE_NUM_SAMPLES, cl_uint)
1471#define CL_HPP_PARAM_NAME_INFO_2_0_(F) \
1472 F(cl_device_info, CL_DEVICE_QUEUE_ON_HOST_PROPERTIES, cl_command_queue_properties) \
1473 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES, cl_command_queue_properties) \
1474 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE, cl_uint) \
1475 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE, cl_uint) \
1476 F(cl_device_info, CL_DEVICE_MAX_ON_DEVICE_QUEUES, cl_uint) \
1477 F(cl_device_info, CL_DEVICE_MAX_ON_DEVICE_EVENTS, cl_uint) \
1478 F(cl_device_info, CL_DEVICE_MAX_PIPE_ARGS, cl_uint) \
1479 F(cl_device_info, CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS, cl_uint) \
1480 F(cl_device_info, CL_DEVICE_PIPE_MAX_PACKET_SIZE, cl_uint) \
1481 F(cl_device_info, CL_DEVICE_SVM_CAPABILITIES, cl_device_svm_capabilities) \
1482 F(cl_device_info, CL_DEVICE_PREFERRED_PLATFORM_ATOMIC_ALIGNMENT, cl_uint) \
1483 F(cl_device_info, CL_DEVICE_PREFERRED_GLOBAL_ATOMIC_ALIGNMENT, cl_uint) \
1484 F(cl_device_info, CL_DEVICE_PREFERRED_LOCAL_ATOMIC_ALIGNMENT, cl_uint) \
1485 F(cl_device_info, CL_DEVICE_IMAGE_PITCH_ALIGNMENT, cl_uint) \
1486 F(cl_device_info, CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT, cl_uint) \
1487 F(cl_device_info, CL_DEVICE_MAX_READ_WRITE_IMAGE_ARGS, cl_uint ) \
1488 F(cl_device_info, CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE, size_type ) \
1489 F(cl_device_info, CL_DEVICE_GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE, size_type ) \
1490 F(cl_profiling_info, CL_PROFILING_COMMAND_COMPLETE, cl_ulong) \
1491 F(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM, cl_bool) \
1492 F(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_SVM_PTRS, void**) \
1493 F(cl_command_queue_info, CL_QUEUE_SIZE, cl_uint) \
1494 F(cl_mem_info, CL_MEM_USES_SVM_POINTER, cl_bool) \
1495 F(cl_program_build_info, CL_PROGRAM_BUILD_GLOBAL_VARIABLE_TOTAL_SIZE, size_type) \
1496 F(cl_pipe_info, CL_PIPE_PACKET_SIZE, cl_uint) \
1497 F(cl_pipe_info, CL_PIPE_MAX_PACKETS, cl_uint)
1499#define CL_HPP_PARAM_NAME_INFO_SUBGROUP_KHR_(F) \
1500 F(cl_kernel_sub_group_info, CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE_KHR, size_type) \
1501 F(cl_kernel_sub_group_info, CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE_KHR, size_type)
1503#define CL_HPP_PARAM_NAME_INFO_IL_KHR_(F) \
1504 F(cl_device_info, CL_DEVICE_IL_VERSION_KHR, string) \
1505 F(cl_program_info, CL_PROGRAM_IL_KHR, cl::vector<unsigned char>)
1507#define CL_HPP_PARAM_NAME_INFO_2_1_(F) \
1508 F(cl_platform_info, CL_PLATFORM_HOST_TIMER_RESOLUTION, cl_ulong) \
1509 F(cl_program_info, CL_PROGRAM_IL, cl::vector<unsigned char>) \
1510 F(cl_device_info, CL_DEVICE_MAX_NUM_SUB_GROUPS, cl_uint) \
1511 F(cl_device_info, CL_DEVICE_IL_VERSION, string) \
1512 F(cl_device_info, CL_DEVICE_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS, cl_bool) \
1513 F(cl_command_queue_info, CL_QUEUE_DEVICE_DEFAULT, cl::DeviceCommandQueue) \
1514 F(cl_kernel_sub_group_info, CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE, size_type) \
1515 F(cl_kernel_sub_group_info, CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE, size_type) \
1516 F(cl_kernel_sub_group_info, CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT, cl::detail::size_t_array) \
1517 F(cl_kernel_sub_group_info, CL_KERNEL_MAX_NUM_SUB_GROUPS, size_type) \
1518 F(cl_kernel_sub_group_info, CL_KERNEL_COMPILE_NUM_SUB_GROUPS, size_type)
1520#define CL_HPP_PARAM_NAME_INFO_2_2_(F) \
1521 F(cl_program_info, CL_PROGRAM_SCOPE_GLOBAL_CTORS_PRESENT, cl_bool) \
1522 F(cl_program_info, CL_PROGRAM_SCOPE_GLOBAL_DTORS_PRESENT, cl_bool)
1524#define CL_HPP_PARAM_NAME_DEVICE_FISSION_EXT_(F) \
1525 F(cl_device_info, CL_DEVICE_PARENT_DEVICE_EXT, cl::Device) \
1526 F(cl_device_info, CL_DEVICE_PARTITION_TYPES_EXT, cl::vector<cl_device_partition_property_ext>) \
1527 F(cl_device_info, CL_DEVICE_AFFINITY_DOMAINS_EXT, cl::vector<cl_device_partition_property_ext>) \
1528 F(cl_device_info, CL_DEVICE_REFERENCE_COUNT_EXT , cl_uint) \
1529 F(cl_device_info, CL_DEVICE_PARTITION_STYLE_EXT, cl::vector<cl_device_partition_property_ext>)
1531#define CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_CL3_SHARED_(F) \
1532 F(cl_platform_info, CL_PLATFORM_NUMERIC_VERSION_KHR, cl_version_khr) \
1533 F(cl_platform_info, CL_PLATFORM_EXTENSIONS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>) \
1535 F(cl_device_info, CL_DEVICE_NUMERIC_VERSION_KHR, cl_version_khr) \
1536 F(cl_device_info, CL_DEVICE_EXTENSIONS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>) \
1537 F(cl_device_info, CL_DEVICE_ILS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>) \
1538 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>)
1540#define CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_KHRONLY_(F) \
1541 F(cl_device_info, CL_DEVICE_OPENCL_C_NUMERIC_VERSION_KHR, cl_version_khr)
1544#define CL_HPP_PARAM_NAME_CL_KHR_SEMAPHORE_(F) \
1545 F(cl_semaphore_info_khr, CL_SEMAPHORE_CONTEXT_KHR, cl::Context) \
1546 F(cl_semaphore_info_khr, CL_SEMAPHORE_REFERENCE_COUNT_KHR, cl_uint) \
1547 F(cl_semaphore_info_khr, CL_SEMAPHORE_PROPERTIES_KHR, cl::vector<cl_semaphore_properties_khr>) \
1548 F(cl_semaphore_info_khr, CL_SEMAPHORE_TYPE_KHR, cl_semaphore_type_khr) \
1549 F(cl_semaphore_info_khr, CL_SEMAPHORE_PAYLOAD_KHR, cl_semaphore_payload_khr) \
1550 F(cl_platform_info, CL_PLATFORM_SEMAPHORE_TYPES_KHR, cl::vector<cl_semaphore_type_khr>) \
1551 F(cl_device_info, CL_DEVICE_SEMAPHORE_TYPES_KHR, cl::vector<cl_semaphore_type_khr>) \
1553#define CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_MEMORY_(F) \
1554 F(cl_device_info, CL_DEVICE_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR, cl::vector<cl::ExternalMemoryType>) \
1555 F(cl_platform_info, CL_PLATFORM_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR, cl::vector<cl::ExternalMemoryType>)
1557#define CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_(F) \
1558 F(cl_platform_info, CL_PLATFORM_SEMAPHORE_IMPORT_HANDLE_TYPES_KHR, cl::vector<cl_external_semaphore_handle_type_khr>) \
1559 F(cl_platform_info, CL_PLATFORM_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR, cl::vector<cl_external_semaphore_handle_type_khr>) \
1560 F(cl_device_info, CL_DEVICE_SEMAPHORE_IMPORT_HANDLE_TYPES_KHR, cl::vector<cl_external_semaphore_handle_type_khr>) \
1561 F(cl_device_info, CL_DEVICE_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR, cl::vector<cl_external_semaphore_handle_type_khr>) \
1562 F(cl_semaphore_info_khr, CL_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR, cl::vector<cl_external_semaphore_handle_type_khr>) \
1564#define CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_DX_FENCE_EXT(F) \
1565 F(cl_external_semaphore_handle_type_khr, CL_SEMAPHORE_HANDLE_D3D12_FENCE_KHR, void*) \
1567#define CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_OPAQUE_FD_EXT(F) \
1568 F(cl_external_semaphore_handle_type_khr, CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR, int) \
1570#define CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_SYNC_FD_EXT(F) \
1571 F(cl_external_semaphore_handle_type_khr, CL_SEMAPHORE_HANDLE_SYNC_FD_KHR, int) \
1573#define CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_WIN32_EXT(F) \
1574 F(cl_external_semaphore_handle_type_khr, CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KHR, void*) \
1575 F(cl_external_semaphore_handle_type_khr, CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KMT_KHR, void*) \
1577#define CL_HPP_PARAM_NAME_INFO_3_0_(F) \
1578 F(cl_platform_info, CL_PLATFORM_NUMERIC_VERSION, cl_version) \
1579 F(cl_platform_info, CL_PLATFORM_EXTENSIONS_WITH_VERSION, cl::vector<cl_name_version>) \
1581 F(cl_device_info, CL_DEVICE_NUMERIC_VERSION, cl_version) \
1582 F(cl_device_info, CL_DEVICE_EXTENSIONS_WITH_VERSION, cl::vector<cl_name_version>) \
1583 F(cl_device_info, CL_DEVICE_ILS_WITH_VERSION, cl::vector<cl_name_version>) \
1584 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS_WITH_VERSION, cl::vector<cl_name_version>) \
1585 F(cl_device_info, CL_DEVICE_ATOMIC_MEMORY_CAPABILITIES, cl_device_atomic_capabilities) \
1586 F(cl_device_info, CL_DEVICE_ATOMIC_FENCE_CAPABILITIES, cl_device_atomic_capabilities) \
1587 F(cl_device_info, CL_DEVICE_NON_UNIFORM_WORK_GROUP_SUPPORT, cl_bool) \
1588 F(cl_device_info, CL_DEVICE_OPENCL_C_ALL_VERSIONS, cl::vector<cl_name_version>) \
1589 F(cl_device_info, CL_DEVICE_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, size_type) \
1590 F(cl_device_info, CL_DEVICE_WORK_GROUP_COLLECTIVE_FUNCTIONS_SUPPORT, cl_bool) \
1591 F(cl_device_info, CL_DEVICE_GENERIC_ADDRESS_SPACE_SUPPORT, cl_bool) \
1592 F(cl_device_info, CL_DEVICE_OPENCL_C_FEATURES, cl::vector<cl_name_version>) \
1593 F(cl_device_info, CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES, cl_device_device_enqueue_capabilities) \
1594 F(cl_device_info, CL_DEVICE_PIPE_SUPPORT, cl_bool) \
1595 F(cl_device_info, CL_DEVICE_LATEST_CONFORMANCE_VERSION_PASSED, string) \
1597 F(cl_command_queue_info, CL_QUEUE_PROPERTIES_ARRAY, cl::vector<cl_queue_properties>) \
1598 F(cl_mem_info, CL_MEM_PROPERTIES, cl::vector<cl_mem_properties>) \
1599 F(cl_pipe_info, CL_PIPE_PROPERTIES, cl::vector<cl_pipe_properties>) \
1600 F(cl_sampler_info, CL_SAMPLER_PROPERTIES, cl::vector<cl_sampler_properties>) \
1602#define CL_HPP_PARAM_NAME_CL_IMAGE_REQUIREMENTS_EXT(F) \
1603 F(cl_image_requirements_info_ext, CL_IMAGE_REQUIREMENTS_ROW_PITCH_ALIGNMENT_EXT, size_type) \
1604 F(cl_image_requirements_info_ext, CL_IMAGE_REQUIREMENTS_BASE_ADDRESS_ALIGNMENT_EXT, size_type) \
1605 F(cl_image_requirements_info_ext, CL_IMAGE_REQUIREMENTS_SIZE_EXT, size_type) \
1606 F(cl_image_requirements_info_ext, CL_IMAGE_REQUIREMENTS_MAX_WIDTH_EXT, cl_uint) \
1607 F(cl_image_requirements_info_ext, CL_IMAGE_REQUIREMENTS_MAX_HEIGHT_EXT, cl_uint) \
1608 F(cl_image_requirements_info_ext, CL_IMAGE_REQUIREMENTS_MAX_DEPTH_EXT, cl_uint) \
1609 F(cl_image_requirements_info_ext, CL_IMAGE_REQUIREMENTS_MAX_ARRAY_SIZE_EXT, cl_uint) \
1611#define CL_HPP_PARAM_NAME_CL_IMAGE_REQUIREMENTS_SLICE_PITCH_ALIGNMENT_EXT(F) \
1612 F(cl_image_requirements_info_ext, CL_IMAGE_REQUIREMENTS_SLICE_PITCH_ALIGNMENT_EXT, size_type) \
1614template <
typename enum_type, cl_
int Name>
1617#define CL_HPP_DECLARE_PARAM_TRAITS_(token, param_name, T) \
1620struct param_traits<detail:: token,param_name> \
1622 enum { value = param_name }; \
1623 typedef T param_type; \
1626CL_HPP_PARAM_NAME_INFO_1_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1627#if CL_HPP_TARGET_OPENCL_VERSION >= 110
1628CL_HPP_PARAM_NAME_INFO_1_1_(CL_HPP_DECLARE_PARAM_TRAITS_)
1630#if CL_HPP_TARGET_OPENCL_VERSION >= 120
1631CL_HPP_PARAM_NAME_INFO_1_2_(CL_HPP_DECLARE_PARAM_TRAITS_)
1633#if CL_HPP_TARGET_OPENCL_VERSION >= 200
1634CL_HPP_PARAM_NAME_INFO_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1636#if CL_HPP_TARGET_OPENCL_VERSION >= 210
1637CL_HPP_PARAM_NAME_INFO_2_1_(CL_HPP_DECLARE_PARAM_TRAITS_)
1639#if CL_HPP_TARGET_OPENCL_VERSION >= 220
1640CL_HPP_PARAM_NAME_INFO_2_2_(CL_HPP_DECLARE_PARAM_TRAITS_)
1642#if CL_HPP_TARGET_OPENCL_VERSION >= 300
1643CL_HPP_PARAM_NAME_INFO_3_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1646#if defined(cl_khr_subgroups) && CL_HPP_TARGET_OPENCL_VERSION < 210
1647CL_HPP_PARAM_NAME_INFO_SUBGROUP_KHR_(CL_HPP_DECLARE_PARAM_TRAITS_)
1650#if defined(cl_khr_il_program) && CL_HPP_TARGET_OPENCL_VERSION < 210
1651CL_HPP_PARAM_NAME_INFO_IL_KHR_(CL_HPP_DECLARE_PARAM_TRAITS_)
1656#define CL_HPP_PARAM_NAME_INFO_1_0_DEPRECATED_IN_2_0_(F) \
1657 F(cl_device_info, CL_DEVICE_QUEUE_PROPERTIES, cl_command_queue_properties)
1659#define CL_HPP_PARAM_NAME_INFO_1_1_DEPRECATED_IN_2_0_(F) \
1660 F(cl_device_info, CL_DEVICE_HOST_UNIFIED_MEMORY, cl_bool)
1662#define CL_HPP_PARAM_NAME_INFO_1_2_DEPRECATED_IN_2_0_(F) \
1663 F(cl_image_info, CL_IMAGE_BUFFER, cl::Buffer)
1667#if CL_HPP_TARGET_OPENCL_VERSION > 100 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 && CL_HPP_TARGET_OPENCL_VERSION < 200
1668CL_HPP_PARAM_NAME_INFO_1_0_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1670#if CL_HPP_TARGET_OPENCL_VERSION > 110 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
1671CL_HPP_PARAM_NAME_INFO_1_1_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1673#if CL_HPP_TARGET_OPENCL_VERSION > 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
1674CL_HPP_PARAM_NAME_INFO_1_2_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1677#if defined(cl_ext_device_fission)
1678CL_HPP_PARAM_NAME_DEVICE_FISSION_EXT_(CL_HPP_DECLARE_PARAM_TRAITS_)
1681#if defined(cl_khr_extended_versioning)
1682#if CL_HPP_TARGET_OPENCL_VERSION < 300
1683CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_CL3_SHARED_(CL_HPP_DECLARE_PARAM_TRAITS_)
1685CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_KHRONLY_(CL_HPP_DECLARE_PARAM_TRAITS_)
1688#if defined(cl_khr_semaphore)
1689CL_HPP_PARAM_NAME_CL_KHR_SEMAPHORE_(CL_HPP_DECLARE_PARAM_TRAITS_)
1690#if defined(CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR)
1691CL_HPP_DECLARE_PARAM_TRAITS_(cl_semaphore_info_khr, CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR, cl::vector<cl::Device>)
1695#ifdef cl_khr_external_memory
1696CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_MEMORY_(CL_HPP_DECLARE_PARAM_TRAITS_)
1699#if defined(cl_khr_external_semaphore)
1700CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_(CL_HPP_DECLARE_PARAM_TRAITS_)
1703#if defined(cl_khr_external_semaphore_dx_fence)
1704CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_DX_FENCE_EXT(CL_HPP_DECLARE_PARAM_TRAITS_)
1706#if defined(cl_khr_external_semaphore_opaque_fd)
1707CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_OPAQUE_FD_EXT(CL_HPP_DECLARE_PARAM_TRAITS_)
1709#if defined(cl_khr_external_semaphore_sync_fd)
1710CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_SYNC_FD_EXT(CL_HPP_DECLARE_PARAM_TRAITS_)
1712#if defined(cl_khr_external_semaphore_win32)
1713CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_WIN32_EXT(CL_HPP_DECLARE_PARAM_TRAITS_)
1716#if defined(cl_khr_device_uuid)
1717using uuid_array = array<cl_uchar, CL_UUID_SIZE_KHR>;
1718using luid_array = array<cl_uchar, CL_LUID_SIZE_KHR>;
1719CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_UUID_KHR, uuid_array)
1720CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DRIVER_UUID_KHR, uuid_array)
1721CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LUID_VALID_KHR, cl_bool)
1722CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LUID_KHR, luid_array)
1723CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_NODE_MASK_KHR, cl_uint)
1726#if defined(cl_khr_pci_bus_info)
1727CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_PCI_BUS_INFO_KHR, cl_device_pci_bus_info_khr)
1731#if CL_HPP_TARGET_OPENCL_VERSION < 200
1732#if defined(CL_DEVICE_IMAGE_PITCH_ALIGNMENT_KHR)
1733CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_IMAGE_PITCH_ALIGNMENT_KHR, cl_uint)
1735#if defined(CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT_KHR)
1736CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT_KHR, cl_uint)
1740#if defined(cl_khr_integer_dot_product)
1741CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGER_DOT_PRODUCT_CAPABILITIES_KHR, cl_device_integer_dot_product_capabilities_khr)
1742#if defined(CL_DEVICE_INTEGER_DOT_PRODUCT_ACCELERATION_PROPERTIES_8BIT_KHR)
1743CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGER_DOT_PRODUCT_ACCELERATION_PROPERTIES_8BIT_KHR, cl_device_integer_dot_product_acceleration_properties_khr)
1744CL_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)
1748#if defined(cl_ext_image_requirements_info)
1749CL_HPP_PARAM_NAME_CL_IMAGE_REQUIREMENTS_EXT(CL_HPP_DECLARE_PARAM_TRAITS_)
1752#if defined(cl_ext_image_from_buffer)
1753CL_HPP_PARAM_NAME_CL_IMAGE_REQUIREMENTS_SLICE_PITCH_ALIGNMENT_EXT(CL_HPP_DECLARE_PARAM_TRAITS_)
1756#ifdef CL_PLATFORM_ICD_SUFFIX_KHR
1757CL_HPP_DECLARE_PARAM_TRAITS_(cl_platform_info, CL_PLATFORM_ICD_SUFFIX_KHR,
string)
1760#ifdef CL_DEVICE_PROFILING_TIMER_OFFSET_AMD
1761CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_PROFILING_TIMER_OFFSET_AMD, cl_ulong)
1763#ifdef CL_DEVICE_GLOBAL_FREE_MEMORY_AMD
1764CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_FREE_MEMORY_AMD, vector<size_type>)
1766#ifdef CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD
1767CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD, cl_uint)
1769#ifdef CL_DEVICE_SIMD_WIDTH_AMD
1770CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_WIDTH_AMD, cl_uint)
1772#ifdef CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD
1773CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD, cl_uint)
1775#ifdef CL_DEVICE_WAVEFRONT_WIDTH_AMD
1776CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_WAVEFRONT_WIDTH_AMD, cl_uint)
1778#ifdef CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD
1779CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD, cl_uint)
1781#ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD
1782CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD, cl_uint)
1784#ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD
1785CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD, cl_uint)
1787#ifdef CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD
1788CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD, cl_uint)
1790#ifdef CL_DEVICE_LOCAL_MEM_BANKS_AMD
1791CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LOCAL_MEM_BANKS_AMD, cl_uint)
1793#ifdef CL_DEVICE_BOARD_NAME_AMD
1794CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_BOARD_NAME_AMD,
string)
1797#ifdef CL_DEVICE_COMPUTE_UNITS_BITFIELD_ARM
1798CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_UNITS_BITFIELD_ARM, cl_ulong)
1800#ifdef CL_DEVICE_JOB_SLOTS_ARM
1801CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_JOB_SLOTS_ARM, cl_uint)
1803#ifdef CL_DEVICE_SCHEDULING_CONTROLS_CAPABILITIES_ARM
1804CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SCHEDULING_CONTROLS_CAPABILITIES_ARM, cl_bitfield)
1806#ifdef CL_DEVICE_SUPPORTED_REGISTER_ALLOCATIONS_ARM
1807CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SUPPORTED_REGISTER_ALLOCATIONS_ARM, vector<cl_uint>)
1809#ifdef CL_DEVICE_MAX_WARP_COUNT_ARM
1810CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_MAX_WARP_COUNT_ARM, cl_uint)
1812#ifdef CL_KERNEL_MAX_WARP_COUNT_ARM
1813CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_info, CL_KERNEL_MAX_WARP_COUNT_ARM, cl_uint)
1815#ifdef CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_ARM
1816CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_ARM, cl_uint)
1818#ifdef CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_MODIFIER_ARM
1819CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_MODIFIER_ARM, cl_int)
1821#ifdef CL_KERNEL_EXEC_INFO_WARP_COUNT_LIMIT_ARM
1822CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_WARP_COUNT_LIMIT_ARM, cl_uint)
1824#ifdef CL_KERNEL_EXEC_INFO_COMPUTE_UNIT_MAX_QUEUED_BATCHES_ARM
1825CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_COMPUTE_UNIT_MAX_QUEUED_BATCHES_ARM, cl_uint)
1828#ifdef CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV
1829CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV, cl_uint)
1831#ifdef CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV
1832CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV, cl_uint)
1834#ifdef CL_DEVICE_REGISTERS_PER_BLOCK_NV
1835CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_REGISTERS_PER_BLOCK_NV, cl_uint)
1837#ifdef CL_DEVICE_WARP_SIZE_NV
1838CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_WARP_SIZE_NV, cl_uint)
1840#ifdef CL_DEVICE_GPU_OVERLAP_NV
1841CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GPU_OVERLAP_NV, cl_bool)
1843#ifdef CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV
1844CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV, cl_bool)
1846#ifdef CL_DEVICE_INTEGRATED_MEMORY_NV
1847CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGRATED_MEMORY_NV, cl_bool)
1850#if defined(cl_khr_command_buffer)
1851CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMMAND_BUFFER_CAPABILITIES_KHR, cl_device_command_buffer_capabilities_khr)
1852CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMMAND_BUFFER_REQUIRED_QUEUE_PROPERTIES_KHR, cl_command_buffer_properties_khr)
1853CL_HPP_DECLARE_PARAM_TRAITS_(cl_command_buffer_info_khr, CL_COMMAND_BUFFER_QUEUES_KHR, cl::vector<CommandQueue>)
1854CL_HPP_DECLARE_PARAM_TRAITS_(cl_command_buffer_info_khr, CL_COMMAND_BUFFER_NUM_QUEUES_KHR, cl_uint)
1855CL_HPP_DECLARE_PARAM_TRAITS_(cl_command_buffer_info_khr, CL_COMMAND_BUFFER_REFERENCE_COUNT_KHR, cl_uint)
1856CL_HPP_DECLARE_PARAM_TRAITS_(cl_command_buffer_info_khr, CL_COMMAND_BUFFER_STATE_KHR, cl_command_buffer_state_khr)
1857CL_HPP_DECLARE_PARAM_TRAITS_(cl_command_buffer_info_khr, CL_COMMAND_BUFFER_PROPERTIES_ARRAY_KHR, cl::vector<cl_command_buffer_properties_khr>)
1860#if defined(cl_khr_command_buffer_mutable_dispatch)
1861CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_COMMAND_COMMAND_QUEUE_KHR,
CommandQueue)
1862CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_COMMAND_COMMAND_BUFFER_KHR, CommandBufferKhr)
1863CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_COMMAND_COMMAND_TYPE_KHR, cl_command_type)
1864CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_DISPATCH_PROPERTIES_ARRAY_KHR, cl::vector<cl_ndrange_kernel_command_properties_khr>)
1865CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_DISPATCH_KERNEL_KHR, cl_kernel)
1866CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_DISPATCH_DIMENSIONS_KHR, cl_uint)
1867CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_DISPATCH_GLOBAL_WORK_OFFSET_KHR, cl::vector<size_type>)
1868CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_DISPATCH_GLOBAL_WORK_SIZE_KHR, cl::vector<size_type>)
1869CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_DISPATCH_LOCAL_WORK_SIZE_KHR, cl::vector<size_type>)
1872#if defined(cl_khr_kernel_clock)
1873CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_KERNEL_CLOCK_CAPABILITIES_KHR, cl_device_kernel_clock_capabilities_khr)
1878template <
typename Func,
typename T>
1880getInfo(Func f, cl_uint name, T* param)
1882 return getInfoHelper(f, name, param, 0);
1885template <
typename Func,
typename Arg0>
1888 Func f_;
const Arg0& arg0_;
1890 cl_uint param, size_type size,
void* value, size_type* size_ret)
1891 {
return f_(arg0_, param, size, value, size_ret); }
1894template <
typename Func,
typename Arg0,
typename Arg1>
1895struct GetInfoFunctor1
1897 Func f_;
const Arg0& arg0_;
const Arg1& arg1_;
1899 cl_uint param, size_type size,
void* value, size_type* size_ret)
1900 {
return f_(arg0_, arg1_, param, size, value, size_ret); }
1903template <
typename Func,
typename Arg0,
typename T>
1905getInfo(Func f,
const Arg0& arg0, cl_uint name, T* param)
1907 GetInfoFunctor0<Func, Arg0> f0 = { f, arg0 };
1908 return getInfoHelper(f0, name, param, 0);
1911template <
typename Func,
typename Arg0,
typename Arg1,
typename T>
1913getInfo(Func f,
const Arg0& arg0,
const Arg1& arg1, cl_uint name, T* param)
1915 GetInfoFunctor1<Func, Arg0, Arg1> f0 = { f, arg0, arg1 };
1916 return getInfoHelper(f0, name, param, 0);
1924#if CL_HPP_TARGET_OPENCL_VERSION >= 120
1929struct ReferenceHandler<cl_device_id>
1940 static cl_int retain(cl_device_id device)
1941 { return ::clRetainDevice(device); }
1951 static cl_int release(cl_device_id device)
1952 { return ::clReleaseDevice(device); }
1959struct ReferenceHandler<cl_device_id>
1962 static cl_int retain(cl_device_id)
1963 {
return CL_SUCCESS; }
1965 static cl_int release(cl_device_id)
1966 {
return CL_SUCCESS; }
1974 static cl_int retain(cl_platform_id)
1975 {
return CL_SUCCESS; }
1977 static cl_int release(cl_platform_id)
1978 {
return CL_SUCCESS; }
1982struct ReferenceHandler<cl_context>
1984 static cl_int retain(cl_context context)
1985 { return ::clRetainContext(context); }
1986 static cl_int release(cl_context context)
1987 { return ::clReleaseContext(context); }
1991struct ReferenceHandler<cl_command_queue>
1993 static cl_int retain(cl_command_queue queue)
1994 { return ::clRetainCommandQueue(queue); }
1995 static cl_int release(cl_command_queue queue)
1996 { return ::clReleaseCommandQueue(queue); }
2000struct ReferenceHandler<cl_mem>
2002 static cl_int retain(cl_mem memory)
2003 { return ::clRetainMemObject(memory); }
2004 static cl_int release(cl_mem memory)
2005 { return ::clReleaseMemObject(memory); }
2009struct ReferenceHandler<cl_sampler>
2011 static cl_int retain(cl_sampler sampler)
2012 { return ::clRetainSampler(sampler); }
2013 static cl_int release(cl_sampler sampler)
2014 { return ::clReleaseSampler(sampler); }
2018struct ReferenceHandler<cl_program>
2020 static cl_int retain(cl_program program)
2021 { return ::clRetainProgram(program); }
2022 static cl_int release(cl_program program)
2023 { return ::clReleaseProgram(program); }
2027struct ReferenceHandler<cl_kernel>
2029 static cl_int retain(cl_kernel kernel)
2030 { return ::clRetainKernel(kernel); }
2031 static cl_int release(cl_kernel kernel)
2032 { return ::clReleaseKernel(kernel); }
2036struct ReferenceHandler<cl_event>
2038 static cl_int retain(cl_event event)
2039 { return ::clRetainEvent(event); }
2040 static cl_int release(cl_event event)
2041 { return ::clReleaseEvent(event); }
2044#ifdef cl_khr_semaphore
2046struct ReferenceHandler<cl_semaphore_khr>
2048 static cl_int retain(cl_semaphore_khr semaphore)
2050 if (pfn_clRetainSemaphoreKHR !=
nullptr) {
2051 return pfn_clRetainSemaphoreKHR(semaphore);
2054 return CL_INVALID_OPERATION;
2057 static cl_int release(cl_semaphore_khr semaphore)
2059 if (pfn_clReleaseSemaphoreKHR !=
nullptr) {
2060 return pfn_clReleaseSemaphoreKHR(semaphore);
2063 return CL_INVALID_OPERATION;
2067#if defined(cl_khr_command_buffer)
2069struct ReferenceHandler<cl_command_buffer_khr>
2071 static cl_int retain(cl_command_buffer_khr cmdBufferKhr)
2073 if (pfn_clRetainCommandBufferKHR ==
nullptr) {
2074 return detail::errHandler(CL_INVALID_OPERATION, __RETAIN_COMMAND_BUFFER_KHR_ERR);
2076 return pfn_clRetainCommandBufferKHR(cmdBufferKhr);
2079 static cl_int release(cl_command_buffer_khr cmdBufferKhr)
2081 if (pfn_clReleaseCommandBufferKHR ==
nullptr) {
2082 return detail::errHandler(CL_INVALID_OPERATION, __RELEASE_COMMAND_BUFFER_KHR_ERR);
2084 return pfn_clReleaseCommandBufferKHR(cmdBufferKhr);
2089struct ReferenceHandler<cl_mutable_command_khr>
2092 static cl_int retain(cl_mutable_command_khr)
2093 {
return CL_SUCCESS; }
2095 static cl_int release(cl_mutable_command_khr)
2096 {
return CL_SUCCESS; }
2101#if (CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120) || \
2102 (CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200)
2104static cl_uint getVersion(
const vector<char> &versionInfo)
2106 int highVersion = 0;
2109 while(versionInfo[index] !=
'.' ) {
2111 highVersion += versionInfo[index]-
'0';
2115 while(versionInfo[index] !=
' ' && versionInfo[index] !=
'\0') {
2117 lowVersion += versionInfo[index]-
'0';
2120 return (highVersion << 16) | lowVersion;
2123static cl_uint getPlatformVersion(cl_platform_id platform)
2126 clGetPlatformInfo(platform, CL_PLATFORM_VERSION, 0,
nullptr, &size);
2128 vector<char> versionInfo(size);
2129 clGetPlatformInfo(platform, CL_PLATFORM_VERSION, size, versionInfo.data(), &size);
2130 return getVersion(versionInfo);
2133static cl_uint getDevicePlatformVersion(cl_device_id device)
2135 cl_platform_id platform;
2136 clGetDeviceInfo(device, CL_DEVICE_PLATFORM,
sizeof(platform), &platform,
nullptr);
2137 return getPlatformVersion(platform);
2140static cl_uint getContextPlatformVersion(cl_context context)
2145 clGetContextInfo(context, CL_CONTEXT_DEVICES, 0,
nullptr, &size);
2148 vector<cl_device_id> devices(size/
sizeof(cl_device_id));
2149 clGetContextInfo(context, CL_CONTEXT_DEVICES, size, devices.data(),
nullptr);
2150 return getDevicePlatformVersion(devices[0]);
2154template <
typename T>
2164 Wrapper() : object_(
nullptr) { }
2166 Wrapper(
const cl_type &obj,
bool retainObject) : object_(obj)
2169 detail::errHandler(retain(), __RETAIN_ERR);
2175 if (object_ !=
nullptr) { release(); }
2178 Wrapper(
const Wrapper<cl_type>& rhs)
2180 object_ = rhs.object_;
2181 detail::errHandler(retain(), __RETAIN_ERR);
2184 Wrapper(Wrapper<cl_type>&& rhs)
noexcept
2186 object_ = rhs.object_;
2187 rhs.object_ =
nullptr;
2190 Wrapper<cl_type>& operator = (
const Wrapper<cl_type>& rhs)
2193 detail::errHandler(release(), __RELEASE_ERR);
2194 object_ = rhs.object_;
2195 detail::errHandler(retain(), __RETAIN_ERR);
2200 Wrapper<cl_type>& operator = (Wrapper<cl_type>&& rhs)
2203 detail::errHandler(release(), __RELEASE_ERR);
2204 object_ = rhs.object_;
2205 rhs.object_ =
nullptr;
2210 Wrapper<cl_type>& operator = (
const cl_type &rhs)
2212 detail::errHandler(release(), __RELEASE_ERR);
2217 const cl_type& operator ()()
const {
return object_; }
2219 cl_type& operator ()() {
return object_; }
2221 cl_type get()
const {
return object_; }
2224 template<
typename Func,
typename U>
2225 friend inline cl_int getInfoHelper(Func, cl_uint, U*,
int,
typename U::cl_type);
2227 cl_int retain()
const
2229 if (object_ !=
nullptr) {
2230 return ReferenceHandler<cl_type>::retain(object_);
2237 cl_int release()
const
2239 if (object_ !=
nullptr) {
2240 return ReferenceHandler<cl_type>::release(object_);
2249class Wrapper<cl_device_id>
2252 typedef cl_device_id cl_type;
2256 bool referenceCountable_;
2258 static bool isReferenceCountable(cl_device_id device)
2260 bool retVal =
false;
2261#if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
2262 if (device !=
nullptr) {
2263 int version = getDevicePlatformVersion(device);
2264 if(version > ((1 << 16) + 1)) {
2268#elif CL_HPP_TARGET_OPENCL_VERSION >= 120
2276 Wrapper() : object_(nullptr), referenceCountable_(false)
2280 Wrapper(
const cl_type &obj,
bool retainObject) :
2282 referenceCountable_(false)
2284 referenceCountable_ = isReferenceCountable(obj);
2287 detail::errHandler(retain(), __RETAIN_ERR);
2296 Wrapper(
const Wrapper<cl_type>& rhs)
2298 object_ = rhs.object_;
2299 referenceCountable_ = isReferenceCountable(object_);
2300 detail::errHandler(retain(), __RETAIN_ERR);
2303 Wrapper(Wrapper<cl_type>&& rhs)
noexcept
2305 object_ = rhs.object_;
2306 referenceCountable_ = rhs.referenceCountable_;
2307 rhs.object_ =
nullptr;
2308 rhs.referenceCountable_ =
false;
2311 Wrapper<cl_type>& operator = (
const Wrapper<cl_type>& rhs)
2314 detail::errHandler(release(), __RELEASE_ERR);
2315 object_ = rhs.object_;
2316 referenceCountable_ = rhs.referenceCountable_;
2317 detail::errHandler(retain(), __RETAIN_ERR);
2322 Wrapper<cl_type>& operator = (Wrapper<cl_type>&& rhs)
2325 detail::errHandler(release(), __RELEASE_ERR);
2326 object_ = rhs.object_;
2327 referenceCountable_ = rhs.referenceCountable_;
2328 rhs.object_ =
nullptr;
2329 rhs.referenceCountable_ =
false;
2334 Wrapper<cl_type>& operator = (
const cl_type &rhs)
2336 detail::errHandler(release(), __RELEASE_ERR);
2338 referenceCountable_ = isReferenceCountable(object_);
2342 const cl_type& operator ()()
const {
return object_; }
2344 cl_type& operator ()() {
return object_; }
2346 cl_type get()
const {
return object_; }
2349 template<
typename Func,
typename U>
2350 friend inline cl_int getInfoHelper(Func, cl_uint, U*,
int,
typename U::cl_type);
2352 template<
typename Func,
typename U>
2353 friend inline cl_int getInfoHelper(Func, cl_uint, vector<U>*,
int,
typename U::cl_type);
2355 cl_int retain()
const
2357 if( object_ !=
nullptr && referenceCountable_ ) {
2358 return ReferenceHandler<cl_type>::retain(object_);
2365 cl_int release()
const
2367 if (object_ !=
nullptr && referenceCountable_) {
2368 return ReferenceHandler<cl_type>::release(object_);
2376template <
typename T>
2377inline bool operator==(
const Wrapper<T> &lhs,
const Wrapper<T> &rhs)
2379 return lhs() == rhs();
2382template <
typename T>
2383inline bool operator!=(
const Wrapper<T> &lhs,
const Wrapper<T> &rhs)
2385 return !operator==(lhs, rhs);
2400struct ImageFormat :
public cl_image_format
2406 ImageFormat(cl_channel_order order, cl_channel_type type)
2408 image_channel_order = order;
2409 image_channel_data_type = type;
2419 this->image_channel_data_type = rhs.image_channel_data_type;
2420 this->image_channel_order = rhs.image_channel_order;
2433class Device :
public detail::Wrapper<cl_device_id>
2436 static std::once_flag default_initialized_;
2438 static cl_int default_error_;
2445 static void makeDefault();
2452 static void makeDefaultProvided(
const Device &p) {
2457#ifdef CL_HPP_UNIT_TEST_ENABLE
2464 static void unitTestClearDefault() {
2470 Device() : detail::Wrapper<cl_type>() { }
2476 explicit Device(
const cl_device_id &device,
bool retainObject =
false) :
2477 detail::Wrapper<cl_type>(device, retainObject) { }
2484 cl_int *errResult =
nullptr)
2486 std::call_once(default_initialized_, makeDefault);
2487 detail::errHandler(default_error_);
2488 if (errResult !=
nullptr) {
2489 *errResult = default_error_;
2503 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_device));
2504 detail::errHandler(default_error_);
2514 detail::Wrapper<cl_type>::operator=(rhs);
2520 template <
typename T>
2521 cl_int
getInfo(cl_device_info name, T* param)
const
2523 return detail::errHandler(
2524 detail::getInfo(&::clGetDeviceInfo, object_, name, param),
2525 __GET_DEVICE_INFO_ERR);
2529 template <cl_device_info name>
typename
2531 getInfo(cl_int* err =
nullptr)
const
2534 detail::cl_device_info, name>::param_type param;
2535 cl_int result =
getInfo(name, ¶m);
2536 if (err !=
nullptr) {
2542#if CL_HPP_TARGET_OPENCL_VERSION >= 210
2551 cl_ulong retVal = 0;
2553 clGetHostTimer(this->get(), &retVal);
2556 __GET_HOST_TIMER_ERR);
2575 std::pair<cl_ulong, cl_ulong> retVal;
2577 clGetDeviceAndHostTimer(this->get(), &(retVal.first), &(retVal.second));
2580 __GET_DEVICE_AND_HOST_TIMER_ERR);
2588#if CL_HPP_TARGET_OPENCL_VERSION >= 120
2591 vector<Device>* devices);
2594#if defined(cl_ext_device_fission)
2596 cl_int
createSubDevices(
const cl_device_partition_property_ext* properties,
2597 vector<Device>* devices);
2601using BuildLogType = vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, CL_PROGRAM_BUILD_LOG>::param_type>>;
2602#if defined(CL_HPP_ENABLE_EXCEPTIONS)
2606class BuildError :
public Error
2609 BuildLogType buildLogs;
2611 BuildError(cl_int err,
const char * errStr,
const BuildLogType &vec) : Error(err, errStr), buildLogs(vec)
2615 BuildLogType getBuildLog()
const
2621 static inline cl_int buildErrHandler(
2623 const char * errStr,
2624 const BuildLogType &buildLogs)
2626 if (err != CL_SUCCESS) {
2627 throw BuildError(err, errStr, buildLogs);
2635 static inline cl_int buildErrHandler(
2637 const char * errStr,
2638 const BuildLogType &buildLogs)
2647CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Device::default_initialized_;
2648CL_HPP_DEFINE_STATIC_MEMBER_ Device Device::default_;
2649CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Device::default_error_ = CL_SUCCESS;
2658class Platform :
public detail::Wrapper<cl_platform_id>
2661 static std::once_flag default_initialized_;
2663 static cl_int default_error_;
2670 static void makeDefault() {
2674#if defined(CL_HPP_ENABLE_EXCEPTIONS)
2682 cl_int err = ::clGetPlatformIDs(0,
nullptr, &n);
2683 if (err != CL_SUCCESS) {
2684 default_error_ = err;
2688 default_error_ = CL_INVALID_PLATFORM;
2692 vector<cl_platform_id> ids(n);
2693 err = ::clGetPlatformIDs(n, ids.data(),
nullptr);
2694 if (err != CL_SUCCESS) {
2695 default_error_ = err;
2701#if defined(CL_HPP_ENABLE_EXCEPTIONS)
2702 catch (cl::Error &e) {
2703 default_error_ = e.err();
2713 static void makeDefaultProvided(
const Platform &p) {
2718#ifdef CL_HPP_UNIT_TEST_ENABLE
2725 static void unitTestClearDefault() {
2731 Platform() : detail::Wrapper<cl_type>() { }
2740 explicit Platform(
const cl_platform_id &platform,
bool retainObject =
false) :
2741 detail::Wrapper<cl_type>(platform, retainObject) { }
2749 detail::Wrapper<cl_type>::operator=(rhs);
2754 cl_int *errResult =
nullptr)
2756 std::call_once(default_initialized_, makeDefault);
2757 detail::errHandler(default_error_);
2758 if (errResult !=
nullptr) {
2759 *errResult = default_error_;
2773 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_platform));
2774 detail::errHandler(default_error_);
2779 template <
typename T>
2780 cl_int
getInfo(cl_platform_info name, T* param)
const
2782 return detail::errHandler(
2783 detail::getInfo(&::clGetPlatformInfo, object_, name, param),
2784 __GET_PLATFORM_INFO_ERR);
2788 template <cl_platform_info name>
typename
2790 getInfo(cl_int* err =
nullptr)
const
2793 detail::cl_platform_info, name>::param_type param;
2794 cl_int result =
getInfo(name, ¶m);
2795 if (err !=
nullptr) {
2806 cl_device_type type,
2807 vector<Device>* devices)
const
2810 if( devices ==
nullptr ) {
2811 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR);
2813 cl_int err = ::clGetDeviceIDs(object_, type, 0,
nullptr, &n);
2814 if (err != CL_SUCCESS && err != CL_DEVICE_NOT_FOUND) {
2815 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2818 vector<cl_device_id> ids(n);
2820 err = ::clGetDeviceIDs(object_, type, n, ids.data(),
nullptr);
2821 if (err != CL_SUCCESS) {
2822 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2831 devices->resize(ids.size());
2835 for (size_type i = 0; i < ids.size(); i++) {
2836 (*devices)[i] = Device(ids[i],
true);
2842#if defined(CL_HPP_USE_DX_INTEROP)
2867 cl_d3d10_device_source_khr d3d_device_source,
2869 cl_d3d10_device_set_khr d3d_device_set,
2870 vector<Device>* devices)
const
2872 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clGetDeviceIDsFromD3D10KHR)(
2873 cl_platform_id platform,
2874 cl_d3d10_device_source_khr d3d_device_source,
2876 cl_d3d10_device_set_khr d3d_device_set,
2877 cl_uint num_entries,
2878 cl_device_id * devices,
2879 cl_uint* num_devices);
2881 if( devices ==
nullptr ) {
2882 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR);
2885 static PFN_clGetDeviceIDsFromD3D10KHR pfn_clGetDeviceIDsFromD3D10KHR =
nullptr;
2886#if CL_HPP_TARGET_OPENCL_VERSION >= 120
2887 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(object_, clGetDeviceIDsFromD3D10KHR);
2889#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
2890 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetDeviceIDsFromD3D10KHR);
2894 cl_int err = pfn_clGetDeviceIDsFromD3D10KHR(
2902 if (err != CL_SUCCESS) {
2903 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2906 vector<cl_device_id> ids(n);
2907 err = pfn_clGetDeviceIDsFromD3D10KHR(
2915 if (err != CL_SUCCESS) {
2916 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2924 devices->resize(ids.size());
2928 for (size_type i = 0; i < ids.size(); i++) {
2929 (*devices)[i] = Device(ids[i],
true);
2941 vector<Platform>* platforms)
2945 if( platforms ==
nullptr ) {
2946 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_PLATFORM_IDS_ERR);
2949 cl_int err = ::clGetPlatformIDs(0,
nullptr, &n);
2950 if (err != CL_SUCCESS) {
2951 return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
2954 vector<cl_platform_id> ids(n);
2955 err = ::clGetPlatformIDs(n, ids.data(),
nullptr);
2956 if (err != CL_SUCCESS) {
2957 return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
2961 platforms->resize(ids.size());
2964 for (size_type i = 0; i < ids.size(); i++) {
2965 (*platforms)[i] =
Platform(ids[i]);
2979 Platform default_platform = Platform::getDefault(&err);
2981 *platform = default_platform;
2995 cl_int * errResult =
nullptr)
2998 Platform default_platform = Platform::getDefault(&err);
3002 return default_platform;
3005#if CL_HPP_TARGET_OPENCL_VERSION >= 120
3010 return ::clUnloadPlatformCompiler(object_);
3015#if CL_HPP_TARGET_OPENCL_VERSION >= 120
3018 vector<Device>* devices)
3021 cl_int err = clCreateSubDevices(object_, properties, 0,
nullptr, &n);
3022 if (err != CL_SUCCESS)
3024 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
3027 vector<cl_device_id> ids(n);
3028 err = clCreateSubDevices(object_, properties, n, ids.data(),
nullptr);
3029 if (err != CL_SUCCESS)
3031 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
3038 devices->resize(ids.size());
3042 for (size_type i = 0; i < ids.size(); i++)
3046 (*devices)[i] =
Device(ids[i],
false);
3054#if defined(cl_ext_device_fission)
3057 vector<Device>* devices)
3059#if CL_HPP_TARGET_OPENCL_VERSION >= 120
3061 cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>()();
3062 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCreateSubDevicesEXT);
3064#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
3065 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateSubDevicesEXT);
3069 cl_int err = pfn_clCreateSubDevicesEXT(object_, properties, 0,
nullptr, &n);
3070 if (err != CL_SUCCESS)
3072 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
3075 vector<cl_device_id> ids(n);
3077 pfn_clCreateSubDevicesEXT(object_, properties, n, ids.data(),
nullptr);
3078 if (err != CL_SUCCESS)
3080 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
3086 devices->resize(ids.size());
3090 for (size_type i = 0; i < ids.size(); i++)
3094 (*devices)[i] =
Device(ids[i],
false);
3102CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Platform::default_initialized_;
3103CL_HPP_DEFINE_STATIC_MEMBER_ Platform Platform::default_;
3104CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Platform::default_error_ = CL_SUCCESS;
3110#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
3115inline CL_API_PREFIX__VERSION_1_1_DEPRECATED cl_int
3120 return ::clUnloadCompiler();
3125#if defined(cl_ext_image_requirements_info)
3126enum ImageRequirementsInfoExt : cl_image_requirements_info_ext
3128 RowPitchAlign = CL_IMAGE_REQUIREMENTS_ROW_PITCH_ALIGNMENT_EXT,
3129 BaseAddAlign = CL_IMAGE_REQUIREMENTS_BASE_ADDRESS_ALIGNMENT_EXT,
3130 Size = CL_IMAGE_REQUIREMENTS_SIZE_EXT,
3131 MaxWidth = CL_IMAGE_REQUIREMENTS_MAX_WIDTH_EXT,
3132 MaxHeight = CL_IMAGE_REQUIREMENTS_MAX_HEIGHT_EXT,
3133 MaxDepth = CL_IMAGE_REQUIREMENTS_MAX_DEPTH_EXT,
3134 MaxArraySize = CL_IMAGE_REQUIREMENTS_MAX_ARRAY_SIZE_EXT,
3135#if defined(cl_ext_image_from_buffer)
3136 SlicePitchAlign = CL_IMAGE_REQUIREMENTS_SLICE_PITCH_ALIGNMENT_EXT,
3152 :
public detail::Wrapper<cl_context>
3155 static std::once_flag default_initialized_;
3157 static cl_int default_error_;
3164 static void makeDefault() {
3168#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3172#if !defined(__APPLE__) && !defined(__MACOS)
3173 const Platform &p = Platform::getDefault();
3174 cl_platform_id defaultPlatform = p();
3175 cl_context_properties properties[3] = {
3176 CL_CONTEXT_PLATFORM, (cl_context_properties)defaultPlatform, 0
3179 cl_context_properties *properties =
nullptr;
3183 CL_DEVICE_TYPE_DEFAULT,
3189#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3190 catch (cl::Error &e) {
3191 default_error_ = e.err();
3202 static void makeDefaultProvided(
const Context &c) {
3206#if defined(cl_ext_image_requirements_info)
3207 struct ImageRequirementsInfo {
3209 ImageRequirementsInfo(cl_mem_flags f,
const cl_mem_properties* mem_properties,
const ImageFormat* format,
const cl_image_desc* desc)
3212 properties = mem_properties;
3213 image_format = format;
3217 cl_mem_flags flags = 0;
3218 const cl_mem_properties* properties;
3219 const ImageFormat* image_format;
3220 const cl_image_desc* image_desc;
3223 static cl_int getImageRequirementsInfoExtHelper(
const Context &context,
3224 const ImageRequirementsInfo &info,
3225 cl_image_requirements_info_ext param_name,
3226 size_type param_value_size,
3228 size_type* param_value_size_ret)
3231#if CL_HPP_TARGET_OPENCL_VERSION >= 120
3232 Device device = context.getInfo<CL_CONTEXT_DEVICES>().at(0);
3233 cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>()();
3234 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clGetImageRequirementsInfoEXT);
3236 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetImageRequirementsInfoEXT);
3239 if (pfn_clGetImageRequirementsInfoEXT ==
nullptr) {
3240 return detail::errHandler(CL_INVALID_OPERATION, __GET_IMAGE_REQUIREMENT_INFO_EXT_ERR);
3243 return detail::errHandler(
3244 pfn_clGetImageRequirementsInfoEXT(context(), info.properties,
3245 info.flags, info.image_format, info.image_desc, param_name,
3246 param_value_size, param_value, param_value_size_ret),
3247 __GET_IMAGE_REQUIREMENT_INFO_EXT_ERR);
3252#ifdef CL_HPP_UNIT_TEST_ENABLE
3259 static void unitTestClearDefault() {
3269 const vector<Device>& devices,
3270 const cl_context_properties* properties =
nullptr,
3271 void (CL_CALLBACK * notifyFptr)(
3276 void* data =
nullptr,
3277 cl_int* err =
nullptr)
3281 size_type numDevices = devices.size();
3282 vector<cl_device_id> deviceIDs(numDevices);
3284 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
3285 deviceIDs[deviceIndex] = (devices[deviceIndex])();
3288 object_ = ::clCreateContext(
3289 properties, (cl_uint) numDevices,
3291 notifyFptr, data, &error);
3293 detail::errHandler(error, __CREATE_CONTEXT_ERR);
3294 if (err !=
nullptr) {
3304 const Device& device,
3305 const cl_context_properties* properties =
nullptr,
3306 void (CL_CALLBACK * notifyFptr)(
3311 void* data =
nullptr,
3312 cl_int* err =
nullptr)
3316 cl_device_id deviceID = device();
3318 object_ = ::clCreateContext(
3321 notifyFptr, data, &error);
3323 detail::errHandler(error, __CREATE_CONTEXT_ERR);
3324 if (err !=
nullptr) {
3334 cl_device_type type,
3335 const cl_context_properties* properties =
nullptr,
3336 void (CL_CALLBACK * notifyFptr)(
3341 void* data =
nullptr,
3342 cl_int* err =
nullptr)
3346#if !defined(__APPLE__) && !defined(__MACOS)
3347 cl_context_properties prop[4] = {CL_CONTEXT_PLATFORM, 0, 0, 0 };
3349 if (properties ==
nullptr) {
3351 vector<Platform> platforms;
3352 error = Platform::get(&platforms);
3353 if (error != CL_SUCCESS) {
3354 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
3355 if (err !=
nullptr) {
3362 cl_context_properties platform_id = 0;
3363 for (
unsigned int i = 0; i < platforms.size(); i++) {
3365 vector<Device> devices;
3367#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3371 error = platforms[i].getDevices(type, &devices);
3373#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3374 }
catch (cl::Error& e) {
3382 if (error != CL_SUCCESS && error != CL_DEVICE_NOT_FOUND) {
3383 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
3384 if (err !=
nullptr) {
3389 if (devices.size() > 0) {
3390 platform_id = (cl_context_properties)platforms[i]();
3395 if (platform_id == 0) {
3396 detail::errHandler(CL_DEVICE_NOT_FOUND, __CREATE_CONTEXT_FROM_TYPE_ERR);
3397 if (err !=
nullptr) {
3398 *err = CL_DEVICE_NOT_FOUND;
3403 prop[1] = platform_id;
3404 properties = &prop[0];
3407 object_ = ::clCreateContextFromType(
3408 properties, type, notifyFptr, data, &error);
3410 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
3411 if (err !=
nullptr) {
3423 std::call_once(default_initialized_, makeDefault);
3424 detail::errHandler(default_error_);
3425 if (err !=
nullptr) {
3426 *err = default_error_;
3440 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_context));
3441 detail::errHandler(default_error_);
3446 Context() : detail::Wrapper<cl_type>() { }
3453 explicit Context(
const cl_context& context,
bool retainObject =
false) :
3454 detail::Wrapper<cl_type>(context, retainObject) { }
3463 detail::Wrapper<cl_type>::operator=(rhs);
3468 template <
typename T>
3469 cl_int
getInfo(cl_context_info name, T* param)
const
3471 return detail::errHandler(
3472 detail::getInfo(&::clGetContextInfo, object_, name, param),
3473 __GET_CONTEXT_INFO_ERR);
3477 template <cl_context_info name>
typename
3479 getInfo(cl_int* err =
nullptr)
const
3482 detail::cl_context_info, name>::param_type param;
3483 cl_int result =
getInfo(name, ¶m);
3484 if (err !=
nullptr) {
3496 cl_mem_object_type type,
3497 vector<ImageFormat>* formats)
const
3505 cl_int err = ::clGetSupportedImageFormats(
3512 if (err != CL_SUCCESS) {
3513 return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
3516 if (numEntries > 0) {
3517 vector<ImageFormat> value(numEntries);
3518 err = ::clGetSupportedImageFormats(
3523 (cl_image_format*)value.data(),
3525 if (err != CL_SUCCESS) {
3526 return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
3529 formats->assign(value.begin(), value.end());
3539#if defined(cl_ext_image_requirements_info)
3540 template <
typename T>
3541 cl_int getImageRequirementsInfoExt(cl_image_requirements_info_ext name,
3543 cl_mem_flags flags = 0,
3544 const cl_mem_properties* properties =
nullptr,
3545 const ImageFormat* image_format =
nullptr,
3546 const cl_image_desc* image_desc =
nullptr)
const
3548 ImageRequirementsInfo imageInfo = {flags, properties, image_format, image_desc};
3550 return detail::errHandler(
3552 Context::getImageRequirementsInfoExtHelper, *
this, imageInfo, name, param),
3553 __GET_IMAGE_REQUIREMENT_INFO_EXT_ERR);
3556 template <cl_image_requirements_info_ext type>
typename
3557 detail::param_traits<detail::cl_image_requirements_info_ext, type>::param_type
3558 getImageRequirementsInfoExt(cl_mem_flags flags = 0,
3559 const cl_mem_properties* properties =
nullptr,
3560 const ImageFormat* image_format =
nullptr,
3561 const cl_image_desc* image_desc =
nullptr,
3562 cl_int* err =
nullptr)
const
3564 typename detail::param_traits<
3565 detail::cl_image_requirements_info_ext, type>::param_type param;
3566 cl_int result = getImageRequirementsInfoExt(type, ¶m, flags, properties, image_format, image_desc);
3567 if (err !=
nullptr) {
3574#if CL_HPP_TARGET_OPENCL_VERSION >= 300
3586 void (CL_CALLBACK * pfn_notify)(cl_context,
void *),
3587 void * user_data =
nullptr)
3589 return detail::errHandler(
3590 ::clSetContextDestructorCallback(
3594 __SET_CONTEXT_DESCTRUCTOR_CALLBACK_ERR);
3599inline void Device::makeDefault()
3604#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3611 detail::errHandler(error, __CREATE_CONTEXT_ERR);
3613 if (error != CL_SUCCESS) {
3614 default_error_ = error;
3617 default_ = context.getInfo<CL_CONTEXT_DEVICES>()[0];
3618 default_error_ = CL_SUCCESS;
3621#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3622 catch (cl::Error &e) {
3623 default_error_ = e.err();
3628CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Context::default_initialized_;
3629CL_HPP_DEFINE_STATIC_MEMBER_ Context Context::default_;
3630CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Context::default_error_ = CL_SUCCESS;
3654 explicit Event(
const cl_event& event,
bool retainObject =
false) :
3669 template <
typename T>
3670 cl_int
getInfo(cl_event_info name, T* param)
const
3672 return detail::errHandler(
3673 detail::getInfo(&::clGetEventInfo, object_, name, param),
3674 __GET_EVENT_INFO_ERR);
3678 template <cl_event_info name>
typename
3680 getInfo(cl_int* err =
nullptr)
const
3683 detail::cl_event_info, name>::param_type param;
3684 cl_int result =
getInfo(name, ¶m);
3685 if (err !=
nullptr) {
3692 template <
typename T>
3695 return detail::errHandler(detail::getInfo(
3696 &::clGetEventProfilingInfo, object_, name, param),
3697 __GET_EVENT_PROFILE_INFO_ERR);
3701 template <cl_profiling_info name>
typename
3706 detail::cl_profiling_info, name>::param_type param;
3708 if (err !=
nullptr) {
3720 return detail::errHandler(
3721 ::clWaitForEvents(1, &object_),
3722 __WAIT_FOR_EVENTS_ERR);
3725#if CL_HPP_TARGET_OPENCL_VERSION >= 110
3732 void (CL_CALLBACK * pfn_notify)(cl_event, cl_int,
void *),
3733 void * user_data =
nullptr)
3735 return detail::errHandler(
3736 ::clSetEventCallback(
3741 __SET_EVENT_CALLBACK_ERR);
3752 static_assert(
sizeof(
cl::Event) ==
sizeof(cl_event),
3753 "Size of cl::Event must be equal to size of cl_event");
3755 return detail::errHandler(
3757 (cl_uint) events.size(), (events.size() > 0) ? (cl_event*)&events.front() : nullptr),
3758 __WAIT_FOR_EVENTS_ERR);
3762#if CL_HPP_TARGET_OPENCL_VERSION >= 110
3767class UserEvent :
public Event
3775 const Context& context,
3776 cl_int * err =
nullptr)
3779 object_ = ::clCreateUserEvent(
3783 detail::errHandler(error, __CREATE_USER_EVENT_ERR);
3784 if (err !=
nullptr) {
3798 return detail::errHandler(
3799 ::clSetUserEventStatus(object_,status),
3800 __SET_USER_EVENT_STATUS_ERR);
3810WaitForEvents(
const vector<Event>& events)
3812 return detail::errHandler(
3814 (cl_uint) events.size(), (events.size() > 0) ? (cl_event*)&events.front() : nullptr),
3815 __WAIT_FOR_EVENTS_ERR);
3843 explicit Memory(
const cl_mem& memory,
bool retainObject) :
3858 template <
typename T>
3859 cl_int
getInfo(cl_mem_info name, T* param)
const
3861 return detail::errHandler(
3862 detail::getInfo(&::clGetMemObjectInfo, object_, name, param),
3863 __GET_MEM_OBJECT_INFO_ERR);
3867 template <cl_mem_info name>
typename
3869 getInfo(cl_int* err =
nullptr)
const
3872 detail::cl_mem_info, name>::param_type param;
3873 cl_int result =
getInfo(name, ¶m);
3874 if (err !=
nullptr) {
3880#if CL_HPP_TARGET_OPENCL_VERSION >= 110
3895 void (CL_CALLBACK * pfn_notify)(cl_mem,
void *),
3896 void * user_data =
nullptr)
3898 return detail::errHandler(
3899 ::clSetMemObjectDestructorCallback(
3903 __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR);
3911template<
typename IteratorType >
3912cl_int
copy( IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer );
3913template<
typename IteratorType >
3914cl_int
copy(
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator );
3915template<
typename IteratorType >
3916cl_int
copy(
const CommandQueue &queue, IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer );
3917template<
typename IteratorType >
3918cl_int
copy(
const CommandQueue &queue,
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator );
3921#if CL_HPP_TARGET_OPENCL_VERSION >= 200
3927 static cl_svm_mem_flags getSVMMemFlags()
3934template<
class Trait = detail::SVMTraitNull>
3935class SVMTraitReadWrite
3938 static cl_svm_mem_flags getSVMMemFlags()
3940 return CL_MEM_READ_WRITE |
3941 Trait::getSVMMemFlags();
3945template<
class Trait = detail::SVMTraitNull>
3946class SVMTraitReadOnly
3949 static cl_svm_mem_flags getSVMMemFlags()
3951 return CL_MEM_READ_ONLY |
3952 Trait::getSVMMemFlags();
3956template<
class Trait = detail::SVMTraitNull>
3957class SVMTraitWriteOnly
3960 static cl_svm_mem_flags getSVMMemFlags()
3962 return CL_MEM_WRITE_ONLY |
3963 Trait::getSVMMemFlags();
3967template<
class Trait = SVMTraitReadWrite<>>
3971 static cl_svm_mem_flags getSVMMemFlags()
3973 return Trait::getSVMMemFlags();
3977template<
class Trait = SVMTraitReadWrite<>>
3981 static cl_svm_mem_flags getSVMMemFlags()
3983 return CL_MEM_SVM_FINE_GRAIN_BUFFER |
3984 Trait::getSVMMemFlags();
3988template<
class Trait = SVMTraitReadWrite<>>
3992 static cl_svm_mem_flags getSVMMemFlags()
3995 CL_MEM_SVM_FINE_GRAIN_BUFFER |
3996 CL_MEM_SVM_ATOMICS |
3997 Trait::getSVMMemFlags();
4008 const vector<Event>* events =
nullptr,
4009 Event* event =
nullptr);
4022template<
typename T,
class SVMTrait>
4028 typedef T value_type;
4029 typedef value_type* pointer;
4030 typedef const value_type* const_pointer;
4031 typedef value_type& reference;
4032 typedef const value_type& const_reference;
4033 typedef std::size_t size_type;
4034 typedef std::ptrdiff_t difference_type;
4036 template<
typename U>
4042 template<
typename U,
typename V>
4046 context_(
Context::getDefault())
4056 SVMAllocator(
const SVMAllocator &other) :
4057 context_(other.context_)
4061 template<
typename U>
4062 SVMAllocator(
const SVMAllocator<U, SVMTrait> &other) :
4063 context_(other.context_)
4071 pointer address(reference r)
noexcept
4073 return std::addressof(r);
4076 const_pointer address(const_reference r)
noexcept
4078 return std::addressof(r);
4089 typename cl::SVMAllocator<void, SVMTrait>::const_pointer = 0,
4096 SVMTrait::getSVMMemFlags(),
4099 pointer retValue =
reinterpret_cast<pointer
>(
4101#if defined(CL_HPP_ENABLE_EXCEPTIONS)
4103 std::bad_alloc excep;
4109 if (map && !(SVMTrait::getSVMMemFlags() & CL_MEM_SVM_FINE_GRAIN_BUFFER)) {
4110 cl_int err =
enqueueMapSVM(retValue, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE, size*
sizeof(T));
4111 if (err != CL_SUCCESS) {
4112 clSVMFree(context_(), retValue);
4114#if defined(CL_HPP_ENABLE_EXCEPTIONS)
4115 std::bad_alloc excep;
4125 void deallocate(pointer p, size_type)
4127 clSVMFree(context_(), p);
4134 size_type
max_size() const noexcept
4136 size_type maxSize = std::numeric_limits<size_type>::max() /
sizeof(T);
4138 for (
const Device &d : context_.getInfo<CL_CONTEXT_DEVICES>()) {
4141 static_cast<size_type
>(d.getInfo<CL_DEVICE_MAX_MEM_ALLOC_SIZE>()));
4147 template<
class U,
class... Args >
4148 void construct(U* p, Args&&... args)
4164 return (context_==rhs.context_);
4174template<
class SVMTrait>
4177 typedef void value_type;
4178 typedef value_type* pointer;
4179 typedef const value_type* const_pointer;
4181 template<
typename U>
4187 template<
typename U,
typename V>
4191#if !defined(CL_HPP_NO_STD_UNIQUE_PTR)
4194 template<
class Alloc>
4201 typedef typename std::allocator_traits<Alloc>::pointer pointer;
4203 Deleter(
const Alloc &alloc, size_type copies) : alloc_{ alloc }, copies_{ copies }
4207 void operator()(pointer ptr)
const {
4208 Alloc tmpAlloc{ alloc_ };
4209 std::allocator_traits<Alloc>::destroy(tmpAlloc, std::addressof(*ptr));
4210 std::allocator_traits<Alloc>::deallocate(tmpAlloc, ptr, copies_);
4221template <
class T,
class Alloc,
class... Args>
4222cl::pointer<T, detail::Deleter<Alloc>>
allocate_pointer(
const Alloc &alloc_, Args&&... args)
4224 Alloc alloc(alloc_);
4225 static const size_type copies = 1;
4230 T* tmp = std::allocator_traits<Alloc>::allocate(alloc, copies);
4232 std::bad_alloc excep;
4236 std::allocator_traits<Alloc>::construct(
4238 std::addressof(*tmp),
4239 std::forward<Args>(args)...);
4243 catch (std::bad_alloc&)
4245 std::allocator_traits<Alloc>::deallocate(alloc, tmp, copies);
4250template<
class T,
class SVMTrait,
class... Args >
4251cl::pointer<T, detail::Deleter<SVMAllocator<T, SVMTrait>>> allocate_svm(Args... args)
4253 SVMAllocator<T, SVMTrait> alloc;
4257template<
class T,
class SVMTrait,
class... Args >
4258cl::pointer<T, detail::Deleter<SVMAllocator<T, SVMTrait>>> allocate_svm(
const cl::Context &c, Args... args)
4260 SVMAllocator<T, SVMTrait> alloc(c);
4269using coarse_svm_vector = vector<T, cl::SVMAllocator<int, cl::SVMTraitCoarse<>>>;
4275using fine_svm_vector = vector<T, cl::SVMAllocator<int, cl::SVMTraitFine<>>>;
4281using atomic_svm_vector = vector<T, cl::SVMAllocator<int, cl::SVMTraitAtomic<>>>;
4292class Buffer :
public Memory
4304 const Context& context,
4307 void* host_ptr =
nullptr,
4308 cl_int* err =
nullptr)
4311 object_ = ::clCreateBuffer(context(), flags, size, host_ptr, &error);
4313 detail::errHandler(error, __CREATE_BUFFER_ERR);
4314 if (err !=
nullptr) {
4319#if CL_HPP_TARGET_OPENCL_VERSION >= 300
4331 const Context& context,
4332 const vector<cl_mem_properties>& properties,
4335 void* host_ptr =
nullptr,
4336 cl_int* err =
nullptr)
4340 if (properties.empty()) {
4341 object_ = ::clCreateBufferWithProperties(context(),
nullptr, flags,
4342 size, host_ptr, &error);
4345 object_ = ::clCreateBufferWithProperties(
4346 context(), properties.data(), flags, size, host_ptr, &error);
4349 detail::errHandler(error, __CREATE_BUFFER_ERR);
4350 if (err !=
nullptr) {
4368 void* host_ptr =
nullptr,
4369 cl_int* err =
nullptr) :
Buffer(Context::getDefault(err), flags, size, host_ptr, err) { }
4371#if CL_HPP_TARGET_OPENCL_VERSION >= 300
4385 const vector<cl_mem_properties>& properties,
4388 void* host_ptr =
nullptr,
4389 cl_int* err =
nullptr) :
Buffer(Context::getDefault(err), properties, flags, size, host_ptr, err) { }
4397 template<
typename IteratorType >
4399 IteratorType startIterator,
4400 IteratorType endIterator,
4402 bool useHostPtr =
false,
4403 cl_int* err =
nullptr)
4405 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
4408 cl_mem_flags flags = 0;
4410 flags |= CL_MEM_READ_ONLY;
4413 flags |= CL_MEM_READ_WRITE;
4416 flags |= CL_MEM_USE_HOST_PTR;
4419 size_type size =
sizeof(DataType)*(endIterator - startIterator);
4424 object_ = ::clCreateBuffer(context(), flags, size,
const_cast<DataType*
>(&*startIterator), &error);
4426 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
4429 detail::errHandler(error, __CREATE_BUFFER_ERR);
4430 if (err !=
nullptr) {
4435 error =
cl::copy(startIterator, endIterator, *
this);
4436 detail::errHandler(error, __CREATE_BUFFER_ERR);
4437 if (err !=
nullptr) {
4448 template<
typename IteratorType >
4449 Buffer(
const Context &context, IteratorType startIterator, IteratorType endIterator,
4450 bool readOnly,
bool useHostPtr =
false, cl_int* err =
nullptr);
4456 template<
typename IteratorType >
4458 bool readOnly,
bool useHostPtr =
false, cl_int* err =
nullptr);
4470 explicit Buffer(
const cl_mem& buffer,
bool retainObject =
false) :
4471 Memory(buffer, retainObject) { }
4484#if CL_HPP_TARGET_OPENCL_VERSION >= 110
4491 cl_buffer_create_type buffer_create_type,
4492 const void * buffer_create_info,
4493 cl_int * err =
nullptr)
4497 result.object_ = ::clCreateSubBuffer(
4504 detail::errHandler(error, __CREATE_SUBBUFFER_ERR);
4505 if (err !=
nullptr) {
4514#if defined (CL_HPP_USE_DX_INTEROP)
4523class BufferD3D10 :
public Buffer
4534 const Context& context,
4536 ID3D10Buffer* bufobj,
4537 cl_int * err =
nullptr) : pfn_clCreateFromD3D10BufferKHR(nullptr)
4539 typedef CL_API_ENTRY cl_mem (CL_API_CALL *PFN_clCreateFromD3D10BufferKHR)(
4540 cl_context context, cl_mem_flags flags, ID3D10Buffer* buffer,
4541 cl_int* errcode_ret);
4542 PFN_clCreateFromD3D10BufferKHR pfn_clCreateFromD3D10BufferKHR;
4543#if CL_HPP_TARGET_OPENCL_VERSION >= 120
4544 vector<cl_context_properties> props = context.getInfo<CL_CONTEXT_PROPERTIES>();
4545 cl_platform platform =
nullptr;
4546 for(
int i = 0; i < props.size(); ++i ) {
4547 if( props[i] == CL_CONTEXT_PLATFORM ) {
4548 platform = props[i+1];
4551 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCreateFromD3D10BufferKHR);
4553#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
4554 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateFromD3D10BufferKHR);
4558 object_ = pfn_clCreateFromD3D10BufferKHR(
4565 detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
4566 if (err !=
nullptr) {
4572 BufferD3D10() : Buffer() { }
4581 explicit BufferD3D10(
const cl_mem& buffer,
bool retainObject =
false) :
4582 Buffer(buffer, retainObject) { }
4588 BufferD3D10& operator = (
const cl_mem& rhs)
4590 Buffer::operator=(rhs);
4604class BufferGL :
public Buffer
4613 const Context& context,
4616 cl_int * err =
nullptr)
4619 object_ = ::clCreateFromGLBuffer(
4625 detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
4626 if (err !=
nullptr) {
4641 explicit BufferGL(
const cl_mem& buffer,
bool retainObject =
false) :
4642 Buffer(buffer, retainObject) { }
4657 cl_gl_object_type *type,
4658 cl_GLuint * gl_object_name)
4660 return detail::errHandler(
4661 ::clGetGLObjectInfo(object_,type,gl_object_name),
4662 __GET_GL_OBJECT_INFO_ERR);
4674class BufferRenderGL :
public Buffer
4683 const Context& context,
4686 cl_int * err =
nullptr)
4689 object_ = ::clCreateFromGLRenderbuffer(
4695 detail::errHandler(error, __CREATE_GL_RENDER_BUFFER_ERR);
4696 if (err !=
nullptr) {
4711 explicit BufferRenderGL(
const cl_mem& buffer,
bool retainObject =
false) :
4712 Buffer(buffer, retainObject) { }
4727 cl_gl_object_type *type,
4728 cl_GLuint * gl_object_name)
4730 return detail::errHandler(
4731 ::clGetGLObjectInfo(object_,type,gl_object_name),
4732 __GET_GL_OBJECT_INFO_ERR);
4755 explicit Image(
const cl_mem& image,
bool retainObject =
false) :
4756 Memory(image, retainObject) { }
4771 template <
typename T>
4772 cl_int
getImageInfo(cl_image_info name, T* param)
const
4774 return detail::errHandler(
4775 detail::getInfo(&::clGetImageInfo, object_, name, param),
4776 __GET_IMAGE_INFO_ERR);
4780 template <cl_image_info name>
typename
4785 detail::cl_image_info, name>::param_type param;
4787 if (err !=
nullptr) {
4794#if CL_HPP_TARGET_OPENCL_VERSION >= 120
4801class Image1D :
public Image
4809 const Context& context,
4813 void* host_ptr =
nullptr,
4814 cl_int* err =
nullptr)
4818 cl_image_desc desc = {};
4819 desc.image_type = CL_MEM_OBJECT_IMAGE1D;
4820 desc.image_width = width;
4822 object_ = ::clCreateImage(
4830 detail::errHandler(error, __CREATE_IMAGE_ERR);
4831 if (err !=
nullptr) {
4846 explicit Image1D(
const cl_mem& image1D,
bool retainObject =
false) :
4847 Image(image1D, retainObject) { }
4874 cl_int* err =
nullptr)
4878 cl_image_desc desc = {};
4879 desc.image_type = CL_MEM_OBJECT_IMAGE1D_BUFFER;
4880 desc.image_width = width;
4881 desc.buffer = buffer();
4883 object_ = ::clCreateImage(
4891 detail::errHandler(error, __CREATE_IMAGE_ERR);
4892 if (err !=
nullptr) {
4906 explicit Image1DBuffer(
const cl_mem& image1D,
bool retainObject =
false) :
4907 Image(image1D, retainObject) { }
4929 size_type arraySize,
4932 void* host_ptr =
nullptr,
4933 cl_int* err =
nullptr)
4937 cl_image_desc desc = {};
4938 desc.image_type = CL_MEM_OBJECT_IMAGE1D_ARRAY;
4939 desc.image_width = width;
4940 desc.image_array_size = arraySize;
4941 desc.image_row_pitch = rowPitch;
4943 object_ = ::clCreateImage(
4951 detail::errHandler(error, __CREATE_IMAGE_ERR);
4952 if (err !=
nullptr) {
4966 explicit Image1DArray(
const cl_mem& imageArray,
bool retainObject =
false) :
4967 Image(imageArray, retainObject) { }
5000 size_type row_pitch = 0,
5001 void* host_ptr =
nullptr,
5002 cl_int* err =
nullptr)
5005 bool useCreateImage;
5007#if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
5010 cl_uint version = detail::getContextPlatformVersion(context());
5011 useCreateImage = (version >= 0x10002);
5013#elif CL_HPP_TARGET_OPENCL_VERSION >= 120
5014 useCreateImage =
true;
5016 useCreateImage =
false;
5019#if CL_HPP_TARGET_OPENCL_VERSION >= 120
5022 cl_image_desc desc = {};
5023 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
5024 desc.image_width = width;
5025 desc.image_height = height;
5026 desc.image_row_pitch = row_pitch;
5028 object_ = ::clCreateImage(
5036 detail::errHandler(error, __CREATE_IMAGE_ERR);
5037 if (err !=
nullptr) {
5042#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
5043 if (!useCreateImage)
5045 object_ = ::clCreateImage2D(
5046 context(), flags,&format, width, height, row_pitch, host_ptr, &error);
5048 detail::errHandler(error, __CREATE_IMAGE2D_ERR);
5049 if (err !=
nullptr) {
5056#if CL_HPP_TARGET_OPENCL_VERSION >= 120
5066 const Context& context,
5068 const Buffer &sourceBuffer,
5071 size_type row_pitch = 0,
5072 cl_int* err =
nullptr)
5076 cl_image_desc desc = {};
5077 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
5078 desc.image_width = width;
5079 desc.image_height = height;
5080 desc.image_row_pitch = row_pitch;
5081 desc.buffer = sourceBuffer();
5083 object_ = ::clCreateImage(
5091 detail::errHandler(error, __CREATE_IMAGE_ERR);
5092 if (err !=
nullptr) {
5098#if CL_HPP_TARGET_OPENCL_VERSION >= 200
5112 const Context& context,
5113 cl_channel_order order,
5114 const Image &sourceImage,
5115 cl_int* err =
nullptr)
5120 size_type sourceWidth =
5121 sourceImage.getImageInfo<CL_IMAGE_WIDTH>();
5122 size_type sourceHeight =
5123 sourceImage.getImageInfo<CL_IMAGE_HEIGHT>();
5124 size_type sourceRowPitch =
5125 sourceImage.getImageInfo<CL_IMAGE_ROW_PITCH>();
5126 cl_uint sourceNumMIPLevels =
5127 sourceImage.getImageInfo<CL_IMAGE_NUM_MIP_LEVELS>();
5128 cl_uint sourceNumSamples =
5129 sourceImage.getImageInfo<CL_IMAGE_NUM_SAMPLES>();
5130 cl_image_format sourceFormat =
5131 sourceImage.getImageInfo<CL_IMAGE_FORMAT>();
5135 sourceFormat.image_channel_order = order;
5137 cl_image_desc desc = {};
5138 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
5139 desc.image_width = sourceWidth;
5140 desc.image_height = sourceHeight;
5141 desc.image_row_pitch = sourceRowPitch;
5142 desc.num_mip_levels = sourceNumMIPLevels;
5143 desc.num_samples = sourceNumSamples;
5144 desc.buffer = sourceImage();
5146 object_ = ::clCreateImage(
5154 detail::errHandler(error, __CREATE_IMAGE_ERR);
5155 if (err !=
nullptr) {
5171 explicit Image2D(
const cl_mem& image2D,
bool retainObject =
false) :
5172 Image(image2D, retainObject) { }
5190#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
5200class CL_API_PREFIX__VERSION_1_1_DEPRECATED Image2DGL :
public Image2D
5209 const Context& context,
5214 cl_int * err =
nullptr)
5217 object_ = ::clCreateFromGLTexture2D(
5225 detail::errHandler(error, __CREATE_GL_TEXTURE_2D_ERR);
5226 if (err !=
nullptr) {
5242 explicit Image2DGL(
const cl_mem& image,
bool retainObject =
false) :
5243 Image2D(image, retainObject) { }
5249 Image2DGL& operator = (
const cl_mem& rhs)
5251 Image2D::operator=(rhs);
5257} CL_API_SUFFIX__VERSION_1_1_DEPRECATED;
5260#if CL_HPP_TARGET_OPENCL_VERSION >= 120
5271 size_type arraySize,
5275 size_type slicePitch,
5276 void* host_ptr =
nullptr,
5277 cl_int* err =
nullptr)
5281 cl_image_desc desc = {};
5282 desc.image_type = CL_MEM_OBJECT_IMAGE2D_ARRAY;
5283 desc.image_width = width;
5284 desc.image_height = height;
5285 desc.image_array_size = arraySize;
5286 desc.image_row_pitch = rowPitch;
5287 desc.image_slice_pitch = slicePitch;
5289 object_ = ::clCreateImage(
5297 detail::errHandler(error, __CREATE_IMAGE_ERR);
5298 if (err !=
nullptr) {
5312 explicit Image2DArray(
const cl_mem& imageArray,
bool retainObject =
false) :
Image(imageArray, retainObject) { }
5343 size_type row_pitch = 0,
5344 size_type slice_pitch = 0,
5345 void* host_ptr =
nullptr,
5346 cl_int* err =
nullptr)
5349 bool useCreateImage;
5351#if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
5354 cl_uint version = detail::getContextPlatformVersion(context());
5355 useCreateImage = (version >= 0x10002);
5357#elif CL_HPP_TARGET_OPENCL_VERSION >= 120
5358 useCreateImage =
true;
5360 useCreateImage =
false;
5363#if CL_HPP_TARGET_OPENCL_VERSION >= 120
5366 cl_image_desc desc = {};
5367 desc.image_type = CL_MEM_OBJECT_IMAGE3D;
5368 desc.image_width = width;
5369 desc.image_height = height;
5370 desc.image_depth = depth;
5371 desc.image_row_pitch = row_pitch;
5372 desc.image_slice_pitch = slice_pitch;
5374 object_ = ::clCreateImage(
5382 detail::errHandler(error, __CREATE_IMAGE_ERR);
5383 if (err !=
nullptr) {
5388#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
5389 if (!useCreateImage)
5391 object_ = ::clCreateImage3D(
5392 context(), flags, &format, width, height, depth, row_pitch,
5393 slice_pitch, host_ptr, &error);
5395 detail::errHandler(error, __CREATE_IMAGE3D_ERR);
5396 if (err !=
nullptr) {
5413 explicit Image3D(
const cl_mem& image3D,
bool retainObject =
false) :
5414 Image(image3D, retainObject) { }
5428#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
5437class Image3DGL :
public Image3D
5446 const Context& context,
5451 cl_int * err =
nullptr)
5454 object_ = ::clCreateFromGLTexture3D(
5462 detail::errHandler(error, __CREATE_GL_TEXTURE_3D_ERR);
5463 if (err !=
nullptr) {
5478 explicit Image3DGL(
const cl_mem& image,
bool retainObject =
false) :
5479 Image3D(image, retainObject) { }
5494#if CL_HPP_TARGET_OPENCL_VERSION >= 120
5501class ImageGL :
public Image
5505 const Context& context,
5510 cl_int * err =
nullptr)
5513 object_ = ::clCreateFromGLTexture(
5521 detail::errHandler(error, __CREATE_GL_TEXTURE_ERR);
5522 if (err !=
nullptr) {
5527 ImageGL() :
Image() { }
5536 explicit ImageGL(
const cl_mem& image,
bool retainObject =
false) :
5537 Image(image, retainObject) { }
5539 ImageGL& operator = (
const cl_mem& rhs)
5550#if CL_HPP_TARGET_OPENCL_VERSION >= 200
5557class Pipe :
public Memory
5571 const Context& context,
5572 cl_uint packet_size,
5573 cl_uint max_packets,
5574 cl_int* err =
nullptr)
5578 cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS;
5579 object_ = ::clCreatePipe(context(), flags, packet_size, max_packets,
nullptr, &error);
5581 detail::errHandler(error, __CREATE_PIPE_ERR);
5582 if (err !=
nullptr) {
5596 cl_uint packet_size,
5597 cl_uint max_packets,
5598 cl_int* err =
nullptr)
5604 cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS;
5605 object_ = ::clCreatePipe(context(), flags, packet_size, max_packets,
nullptr, &error);
5607 detail::errHandler(error, __CREATE_PIPE_ERR);
5608 if (err !=
nullptr) {
5623 explicit Pipe(
const cl_mem& pipe,
bool retainObject =
false) :
5624 Memory(pipe, retainObject) { }
5639 template <
typename T>
5640 cl_int
getInfo(cl_pipe_info name, T* param)
const
5642 return detail::errHandler(
5643 detail::getInfo(&::clGetPipeInfo, object_, name, param),
5644 __GET_PIPE_INFO_ERR);
5648 template <cl_pipe_info name>
typename
5650 getInfo(cl_int* err =
nullptr)
const
5653 detail::cl_pipe_info, name>::param_type param;
5654 cl_int result =
getInfo(name, ¶m);
5655 if (err !=
nullptr) {
5684 cl_bool normalized_coords,
5685 cl_addressing_mode addressing_mode,
5686 cl_filter_mode filter_mode,
5687 cl_int* err =
nullptr)
5691#if CL_HPP_TARGET_OPENCL_VERSION >= 200
5692 cl_sampler_properties sampler_properties[] = {
5693 CL_SAMPLER_NORMALIZED_COORDS, normalized_coords,
5694 CL_SAMPLER_ADDRESSING_MODE, addressing_mode,
5695 CL_SAMPLER_FILTER_MODE, filter_mode,
5697 object_ = ::clCreateSamplerWithProperties(
5702 detail::errHandler(error, __CREATE_SAMPLER_WITH_PROPERTIES_ERR);
5703 if (err !=
nullptr) {
5707 object_ = ::clCreateSampler(
5714 detail::errHandler(error, __CREATE_SAMPLER_ERR);
5715 if (err !=
nullptr) {
5729 explicit Sampler(
const cl_sampler& sampler,
bool retainObject =
false) :
5746 template <
typename T>
5747 cl_int
getInfo(cl_sampler_info name, T* param)
const
5749 return detail::errHandler(
5750 detail::getInfo(&::clGetSamplerInfo, object_, name, param),
5751 __GET_SAMPLER_INFO_ERR);
5755 template <cl_sampler_info name>
typename
5757 getInfo(cl_int* err =
nullptr)
const
5760 detail::cl_sampler_info, name>::param_type param;
5761 cl_int result =
getInfo(name, ¶m);
5762 if (err !=
nullptr) {
5778 size_type sizes_[3];
5779 cl_uint dimensions_;
5801 NDRange(size_type size0, size_type size1)
5810 NDRange(size_type size0, size_type size1, size_type size2)
5831 operator const size_type*()
const {
5843 size_type
size()
const
5845 return dimensions_*
sizeof(size_type);
5853 const size_type* get()
const
5860static const NDRange NullRange;
5870template <
typename T,
class Enable =
void>
5875template <
typename T>
5876struct KernelArgumentHandler<T, typename std::enable_if<!std::is_base_of<cl::Memory, T>::value>::type>
5878 static size_type size(
const T&) {
return sizeof(T); }
5879 static const T* ptr(
const T& value) {
return &value; }
5884template <
typename T>
5885struct KernelArgumentHandler<T, typename std::enable_if<std::is_base_of<cl::Memory, T>::value>::type>
5887 static size_type size(
const T&) {
return sizeof(cl_mem); }
5888 static const cl_mem* ptr(
const T& value) {
return &(value()); }
5896 static size_type size(
const LocalSpaceArg& value) {
return value.size_; }
5897 static const void* ptr(
const LocalSpaceArg&) {
return nullptr; }
5907Local(size_type size)
5921class Kernel :
public detail::Wrapper<cl_kernel>
5924 inline Kernel(
const Program& program,
const string& name, cl_int* err =
nullptr);
5925 inline Kernel(
const Program& program,
const char* name, cl_int* err =
nullptr);
5938 explicit Kernel(
const cl_kernel& kernel,
bool retainObject =
false) :
5939 detail::Wrapper<cl_type>(kernel, retainObject) { }
5948 detail::Wrapper<cl_type>::operator=(rhs);
5955 template <
typename T>
5956 cl_int getInfo(cl_kernel_info name, T* param)
const
5958 return detail::errHandler(
5959 detail::getInfo(&::clGetKernelInfo, object_, name, param),
5960 __GET_KERNEL_INFO_ERR);
5963 template <cl_kernel_info name>
typename
5964 detail::param_traits<detail::cl_kernel_info, name>::param_type
5965 getInfo(cl_int* err =
nullptr)
const
5967 typename detail::param_traits<
5968 detail::cl_kernel_info, name>::param_type param;
5969 cl_int result = getInfo(name, ¶m);
5970 if (err !=
nullptr) {
5976#if CL_HPP_TARGET_OPENCL_VERSION >= 120
5977 template <
typename T>
5978 cl_int getArgInfo(cl_uint argIndex, cl_kernel_arg_info name, T* param)
const
5980 return detail::errHandler(
5981 detail::getInfo(&::clGetKernelArgInfo, object_, argIndex, name, param),
5982 __GET_KERNEL_ARG_INFO_ERR);
5985 template <cl_kernel_arg_info name>
typename
5986 detail::param_traits<detail::cl_kernel_arg_info, name>::param_type
5987 getArgInfo(cl_uint argIndex, cl_int* err =
nullptr)
const
5989 typename detail::param_traits<
5990 detail::cl_kernel_arg_info, name>::param_type param;
5991 cl_int result = getArgInfo(argIndex, name, ¶m);
5992 if (err !=
nullptr) {
5999 template <
typename T>
6000 cl_int getWorkGroupInfo(
6001 const Device& device, cl_kernel_work_group_info name, T* param)
const
6003 return detail::errHandler(
6005 &::clGetKernelWorkGroupInfo, object_, device(), name, param),
6006 __GET_KERNEL_WORK_GROUP_INFO_ERR);
6009 template <cl_kernel_work_group_info name>
typename
6010 detail::param_traits<detail::cl_kernel_work_group_info, name>::param_type
6011 getWorkGroupInfo(
const Device& device, cl_int* err =
nullptr)
const
6013 typename detail::param_traits<
6014 detail::cl_kernel_work_group_info, name>::param_type param;
6015 cl_int result = getWorkGroupInfo(device, name, ¶m);
6016 if (err !=
nullptr) {
6022#if defined(CL_HPP_USE_CL_SUB_GROUPS_KHR) || CL_HPP_TARGET_OPENCL_VERSION >= 210
6023 cl_int getSubGroupInfo(
const cl::Device &dev, cl_kernel_sub_group_info name,
const cl::NDRange &range, size_type* param)
const
6025#if CL_HPP_TARGET_OPENCL_VERSION >= 210
6027 return detail::errHandler(
6028 clGetKernelSubGroupInfo(object_, dev(), name, range.
size(), range.get(),
sizeof(size_type), param,
nullptr),
6029 __GET_KERNEL_SUB_GROUP_INFO_ERR);
6033 typedef clGetKernelSubGroupInfoKHR_fn PFN_clGetKernelSubGroupInfoKHR;
6034 static PFN_clGetKernelSubGroupInfoKHR pfn_clGetKernelSubGroupInfoKHR =
nullptr;
6035 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetKernelSubGroupInfoKHR);
6037 return detail::errHandler(
6038 pfn_clGetKernelSubGroupInfoKHR(object_, dev(), name, range.
size(), range.get(),
sizeof(size_type), param,
nullptr),
6039 __GET_KERNEL_SUB_GROUP_INFO_ERR);
6044 template <cl_kernel_sub_group_info name>
6045 size_type getSubGroupInfo(
const cl::Device &dev,
const cl::NDRange &range, cl_int* err =
nullptr)
const
6048 cl_int result = getSubGroupInfo(dev, name, range, ¶m);
6049 if (err !=
nullptr) {
6056#if CL_HPP_TARGET_OPENCL_VERSION >= 200
6059 template<
typename T,
class D>
6060 cl_int
setArg(cl_uint index,
const cl::pointer<T, D> &argPtr)
6062 return detail::errHandler(
6063 ::clSetKernelArgSVMPointer(object_, index, argPtr.get()),
6064 __SET_KERNEL_ARGS_ERR);
6069 template<
typename T,
class Alloc>
6070 cl_int
setArg(cl_uint index,
const cl::vector<T, Alloc> &argPtr)
6072 return detail::errHandler(
6073 ::clSetKernelArgSVMPointer(object_, index, argPtr.data()),
6074 __SET_KERNEL_ARGS_ERR);
6079 template<
typename T>
6080 typename std::enable_if<std::is_pointer<T>::value, cl_int>::type
6081 setArg(cl_uint index,
const T argPtr)
6083 return detail::errHandler(
6084 ::clSetKernelArgSVMPointer(object_, index, argPtr),
6085 __SET_KERNEL_ARGS_ERR);
6091 template <
typename T>
6092 typename std::enable_if<!std::is_pointer<T>::value, cl_int>::type
6093 setArg(cl_uint index,
const T &value)
6095 return detail::errHandler(
6099 detail::KernelArgumentHandler<T>::size(value),
6100 detail::KernelArgumentHandler<T>::ptr(value)),
6101 __SET_KERNEL_ARGS_ERR);
6104 cl_int
setArg(cl_uint index, size_type size,
const void* argPtr)
6106 return detail::errHandler(
6107 ::clSetKernelArg(object_, index, size, argPtr),
6108 __SET_KERNEL_ARGS_ERR);
6111#if CL_HPP_TARGET_OPENCL_VERSION >= 200
6118 return detail::errHandler(
6119 ::clSetKernelExecInfo(
6121 CL_KERNEL_EXEC_INFO_SVM_PTRS,
6122 sizeof(
void*)*pointerList.size(),
6123 pointerList.data()));
6130 template<
int ArrayLength>
6131 cl_int
setSVMPointers(
const std::array<void*, ArrayLength> &pointerList)
6133 return detail::errHandler(
6134 ::clSetKernelExecInfo(
6136 CL_KERNEL_EXEC_INFO_SVM_PTRS,
6137 sizeof(
void*)*pointerList.size(),
6138 pointerList.data()));
6154 cl_bool svmEnabled_ = svmEnabled ? CL_TRUE : CL_FALSE;
6155 return detail::errHandler(
6156 ::clSetKernelExecInfo(
6158 CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM,
6165 template<
int index,
int ArrayLength,
class D,
typename T0,
typename T1,
typename... Ts>
6166 void setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList,
const pointer<T0, D> &t0,
const pointer<T1, D> &t1, Ts & ... ts)
6168 pointerList[index] =
static_cast<void*
>(t0.get());
6169 setSVMPointersHelper<index + 1, ArrayLength>(pointerList, t1, ts...);
6172 template<
int index,
int ArrayLength,
typename T0,
typename T1,
typename... Ts>
6173 typename std::enable_if<std::is_pointer<T0>::value,
void>::type
6174 setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList, T0 t0, T1 t1, Ts... ts)
6176 pointerList[index] =
static_cast<void*
>(t0);
6177 setSVMPointersHelper<index + 1, ArrayLength>(pointerList, t1, ts...);
6180 template<
int index,
int ArrayLength,
typename T0,
class D>
6181 void setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList,
const pointer<T0, D> &t0)
6183 pointerList[index] =
static_cast<void*
>(t0.get());
6187 template<
int index,
int ArrayLength,
typename T0>
6188 typename std::enable_if<std::is_pointer<T0>::value,
void>::type
6189 setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList, T0 t0)
6191 pointerList[index] =
static_cast<void*
>(t0);
6194 template<
typename T0,
typename... Ts>
6197 std::array<
void*, 1 +
sizeof...(Ts)> pointerList;
6199 setSVMPointersHelper<0, 1 +
sizeof...(Ts)>(pointerList, t0, ts...);
6200 return detail::errHandler(
6201 ::clSetKernelExecInfo(
6203 CL_KERNEL_EXEC_INFO_SVM_PTRS,
6204 sizeof(
void*)*(1 +
sizeof...(Ts)),
6205 pointerList.data()));
6208 template<
typename T>
6209 cl_int setExecInfo(cl_kernel_exec_info param_name,
const T& val)
6211 return detail::errHandler(
6212 ::clSetKernelExecInfo(
6219 template<cl_kernel_exec_info name>
6220 cl_int setExecInfo(
typename detail::param_traits<detail::cl_kernel_exec_info, name>::param_type& val)
6222 return setExecInfo(name, val);
6226#if CL_HPP_TARGET_OPENCL_VERSION >= 210
6235 Kernel retValue(clCloneKernel(this->get(), &error));
6237 detail::errHandler(error, __CLONE_KERNEL_ERR);
6249#if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6250 typedef vector<vector<unsigned char>> Binaries;
6251 typedef vector<string> Sources;
6253 typedef vector<std::pair<const void*, size_type> > Binaries;
6254 typedef vector<std::pair<const char*, size_type> > Sources;
6258 const string& source,
6260 cl_int* err =
nullptr)
6264 const char * strings = source.c_str();
6265 const size_type length = source.size();
6269 object_ = ::clCreateProgramWithSource(
6270 context(), (cl_uint)1, &strings, &length, &error);
6272 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6274 if (error == CL_SUCCESS && build) {
6276 error = ::clBuildProgram(
6280#
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6288 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6291 if (err !=
nullptr) {
6298 const string& source,
6300 cl_int* err =
nullptr)
6304 const char * strings = source.c_str();
6305 const size_type length = source.size();
6307 object_ = ::clCreateProgramWithSource(
6308 context(), (cl_uint)1, &strings, &length, &error);
6310 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6312 if (error == CL_SUCCESS && build) {
6313 error = ::clBuildProgram(
6317#
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6325 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6328 if (err !=
nullptr) {
6338 const Sources& sources,
6339 cl_int* err =
nullptr)
6344 const size_type n = (size_type)sources.size();
6346 vector<size_type> lengths(n);
6347 vector<const char*> strings(n);
6349 for (size_type i = 0; i < n; ++i) {
6350#if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6351 strings[i] = sources[(int)i].data();
6352 lengths[i] = sources[(int)i].length();
6354 strings[i] = sources[(int)i].first;
6355 lengths[i] = sources[(int)i].second;
6359 object_ = ::clCreateProgramWithSource(
6360 context(), (cl_uint)n, strings.data(), lengths.data(), &error);
6362 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6363 if (err !=
nullptr) {
6374 const Sources& sources,
6375 cl_int* err =
nullptr)
6379 const size_type n = (size_type)sources.size();
6381 vector<size_type> lengths(n);
6382 vector<const char*> strings(n);
6384 for (size_type i = 0; i < n; ++i) {
6385#if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6386 strings[i] = sources[(int)i].data();
6387 lengths[i] = sources[(int)i].length();
6389 strings[i] = sources[(int)i].first;
6390 lengths[i] = sources[(int)i].second;
6394 object_ = ::clCreateProgramWithSource(
6395 context(), (cl_uint)n, strings.data(), lengths.data(), &error);
6397 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6398 if (err !=
nullptr) {
6403#if defined(CL_HPP_USE_IL_KHR) || CL_HPP_TARGET_OPENCL_VERSION >= 210
6410 const vector<char>& IL,
6412 cl_int* err =
nullptr)
6418#if CL_HPP_TARGET_OPENCL_VERSION >= 210
6420 object_ = ::clCreateProgramWithIL(
6421 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6425 typedef clCreateProgramWithILKHR_fn PFN_clCreateProgramWithILKHR;
6426 static PFN_clCreateProgramWithILKHR pfn_clCreateProgramWithILKHR =
nullptr;
6427 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateProgramWithILKHR);
6429 object_ = pfn_clCreateProgramWithILKHR(
6430 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6434 detail::errHandler(error, __CREATE_PROGRAM_WITH_IL_ERR);
6436 if (error == CL_SUCCESS && build) {
6438 error = ::clBuildProgram(
6442#
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6450 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6453 if (err !=
nullptr) {
6466 const vector<char>& IL,
6468 cl_int* err =
nullptr)
6472#if CL_HPP_TARGET_OPENCL_VERSION >= 210
6474 object_ = ::clCreateProgramWithIL(
6475 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6479 typedef clCreateProgramWithILKHR_fn PFN_clCreateProgramWithILKHR;
6480 static PFN_clCreateProgramWithILKHR pfn_clCreateProgramWithILKHR =
nullptr;
6481 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateProgramWithILKHR);
6483 object_ = pfn_clCreateProgramWithILKHR(
6484 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6488 detail::errHandler(error, __CREATE_PROGRAM_WITH_IL_ERR);
6490 if (error == CL_SUCCESS && build) {
6491 error = ::clBuildProgram(
6495#
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6503 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6506 if (err !=
nullptr) {
6533 const vector<Device>& devices,
6534 const Binaries& binaries,
6535 vector<cl_int>* binaryStatus =
nullptr,
6536 cl_int* err =
nullptr)
6540 const size_type numDevices = devices.size();
6543 if(binaries.size() != numDevices) {
6544 error = CL_INVALID_VALUE;
6545 detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
6546 if (err !=
nullptr) {
6552 vector<size_type> lengths(numDevices);
6553 vector<const unsigned char*> images(numDevices);
6554#if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6555 for (size_type i = 0; i < numDevices; ++i) {
6556 images[i] = binaries[i].data();
6557 lengths[i] = binaries[(int)i].size();
6560 for (size_type i = 0; i < numDevices; ++i) {
6561 images[i] = (
const unsigned char*)binaries[i].first;
6562 lengths[i] = binaries[(int)i].second;
6566 vector<cl_device_id> deviceIDs(numDevices);
6567 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6568 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6572 binaryStatus->resize(numDevices);
6575 object_ = ::clCreateProgramWithBinary(
6576 context(), (cl_uint) devices.size(),
6578 lengths.data(), images.data(), (binaryStatus !=
nullptr && numDevices > 0)
6579 ? &binaryStatus->front()
6582 detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
6583 if (err !=
nullptr) {
6589#if CL_HPP_TARGET_OPENCL_VERSION >= 120
6596 const vector<Device>& devices,
6597 const string& kernelNames,
6598 cl_int* err =
nullptr)
6603 size_type numDevices = devices.size();
6604 vector<cl_device_id> deviceIDs(numDevices);
6605 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6606 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6609 object_ = ::clCreateProgramWithBuiltInKernels(
6611 (cl_uint) devices.size(),
6613 kernelNames.c_str(),
6616 detail::errHandler(error, __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR);
6617 if (err !=
nullptr) {
6632 explicit Program(
const cl_program& program,
bool retainObject =
false) :
6635 Program& operator = (
const cl_program& rhs)
6642 const vector<Device>& devices,
6643 const string& options,
6644 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
6645 void* data =
nullptr)
const
6647 return build(devices, options.c_str(), notifyFptr, data);
6651 const vector<Device>& devices,
6652 const char* options =
nullptr,
6653 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
6654 void* data =
nullptr)
const
6656 size_type numDevices = devices.size();
6657 vector<cl_device_id> deviceIDs(numDevices);
6659 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6660 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6663 cl_int buildError = ::clBuildProgram(
6672 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6677 const string& options,
6678 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
6679 void* data =
nullptr)
const
6681 return build(device, options.c_str(), notifyFptr, data);
6686 const char* options =
nullptr,
6687 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
6688 void* data =
nullptr)
const
6690 cl_device_id deviceID = device();
6692 cl_int buildError = ::clBuildProgram(
6700 BuildLogType buildLog(0);
6701 buildLog.push_back(std::make_pair(device, getBuildInfo<CL_PROGRAM_BUILD_LOG>(device)));
6702 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, buildLog);
6706 const string& options,
6707 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
6708 void* data =
nullptr)
const
6710 return build(options.c_str(), notifyFptr, data);
6714 const char* options =
nullptr,
6715 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
6716 void* data =
nullptr)
const
6718 cl_int buildError = ::clBuildProgram(
6726 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6729#if CL_HPP_TARGET_OPENCL_VERSION >= 120
6731 const string& options,
6732 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
6733 void* data =
nullptr)
const
6735 return compile(options.c_str(), notifyFptr, data);
6739 const char* options =
nullptr,
6740 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
6741 void* data =
nullptr)
const
6743 cl_int error = ::clCompileProgram(
6753 return detail::buildErrHandler(error, __COMPILE_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6757 const string& options,
6758 const vector<Program>& inputHeaders,
6759 const vector<string>& headerIncludeNames,
6760 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
6761 void* data =
nullptr)
const
6763 return compile(options.c_str(), inputHeaders, headerIncludeNames, notifyFptr, data);
6767 const char* options,
6768 const vector<Program>& inputHeaders,
6769 const vector<string>& headerIncludeNames,
6770 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
6771 void* data =
nullptr)
const
6773 static_assert(
sizeof(
cl::Program) ==
sizeof(cl_program),
6774 "Size of cl::Program must be equal to size of cl_program");
6775 vector<const char*> headerIncludeNamesCStr;
6776 for(
const string& name: headerIncludeNames) {
6777 headerIncludeNamesCStr.push_back(name.c_str());
6779 cl_int error = ::clCompileProgram(
6784 static_cast<cl_uint
>(inputHeaders.size()),
6785 reinterpret_cast<const cl_program*
>(inputHeaders.data()),
6786 reinterpret_cast<const char**
>(headerIncludeNamesCStr.data()),
6789 return detail::buildErrHandler(error, __COMPILE_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6793 const string& options,
6794 const vector<Device>& deviceList,
6795 const vector<Program>& inputHeaders = vector<Program>(),
6796 const vector<string>& headerIncludeNames = vector<string>(),
6797 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
6798 void* data =
nullptr)
const
6800 return compile(options.c_str(), deviceList, inputHeaders, headerIncludeNames, notifyFptr, data);
6804 const char* options,
6805 const vector<Device>& deviceList,
6806 const vector<Program>& inputHeaders = vector<Program>(),
6807 const vector<string>& headerIncludeNames = vector<string>(),
6808 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
6809 void* data =
nullptr)
const
6811 static_assert(
sizeof(
cl::Program) ==
sizeof(cl_program),
6812 "Size of cl::Program must be equal to size of cl_program");
6813 vector<const char*> headerIncludeNamesCStr;
6814 for(
const string& name: headerIncludeNames) {
6815 headerIncludeNamesCStr.push_back(name.c_str());
6817 vector<cl_device_id> deviceIDList;
6818 for(
const Device& device: deviceList) {
6819 deviceIDList.push_back(device());
6821 cl_int error = ::clCompileProgram(
6823 static_cast<cl_uint
>(deviceList.size()),
6824 reinterpret_cast<const cl_device_id*
>(deviceIDList.data()),
6826 static_cast<cl_uint
>(inputHeaders.size()),
6827 reinterpret_cast<const cl_program*
>(inputHeaders.data()),
6828 reinterpret_cast<const char**
>(headerIncludeNamesCStr.data()),
6831 return detail::buildErrHandler(error, __COMPILE_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6835 template <
typename T>
6836 cl_int getInfo(cl_program_info name, T* param)
const
6838 return detail::errHandler(
6839 detail::getInfo(&::clGetProgramInfo, object_, name, param),
6840 __GET_PROGRAM_INFO_ERR);
6843 template <cl_program_info name>
typename
6845 getInfo(cl_int* err =
nullptr)
const
6848 detail::cl_program_info, name>::param_type param;
6849 cl_int result = getInfo(name, ¶m);
6850 if (err !=
nullptr) {
6856 template <
typename T>
6857 cl_int getBuildInfo(
6858 const Device& device, cl_program_build_info name, T* param)
const
6860 return detail::errHandler(
6862 &::clGetProgramBuildInfo, object_, device(), name, param),
6863 __GET_PROGRAM_BUILD_INFO_ERR);
6866 template <cl_program_build_info name>
typename
6868 getBuildInfo(
const Device& device, cl_int* err =
nullptr)
const
6871 detail::cl_program_build_info, name>::param_type param;
6872 cl_int result = getBuildInfo(device, name, ¶m);
6873 if (err !=
nullptr) {
6884 template <cl_program_build_info name>
6885 vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, name>::param_type>>
6886 getBuildInfo(cl_int *err =
nullptr)
const
6888 cl_int result = CL_SUCCESS;
6890 auto devs = getInfo<CL_PROGRAM_DEVICES>(&result);
6891 vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, name>::param_type>>
6895 if (result != CL_SUCCESS) {
6896 if (err !=
nullptr) {
6904 detail::cl_program_build_info, name>::param_type param;
6905 result = getBuildInfo(d, name, ¶m);
6909 if (result != CL_SUCCESS) {
6914 if (err !=
nullptr) {
6917 if (result != CL_SUCCESS) {
6923 cl_int createKernels(vector<Kernel>* kernels)
6926 cl_int err = ::clCreateKernelsInProgram(object_, 0,
nullptr, &numKernels);
6927 if (err != CL_SUCCESS) {
6928 return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
6931 vector<cl_kernel> value(numKernels);
6933 err = ::clCreateKernelsInProgram(
6934 object_, numKernels, value.data(),
nullptr);
6935 if (err != CL_SUCCESS) {
6936 return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
6940 kernels->resize(value.size());
6944 for (size_type i = 0; i < value.size(); i++) {
6947 (*kernels)[i] =
Kernel(value[i],
false);
6953#if CL_HPP_TARGET_OPENCL_VERSION >= 220
6954#if defined(CL_USE_DEPRECATED_OPENCL_2_2_APIS)
6966 void (CL_CALLBACK * pfn_notify)(cl_program program,
void * user_data),
6967 void * user_data =
nullptr) CL_API_SUFFIX__VERSION_2_2_DEPRECATED
6969 return detail::errHandler(
6970 ::clSetProgramReleaseCallback(
6974 __SET_PROGRAM_RELEASE_CALLBACK_ERR);
6982 template <
typename T>
6983 typename std::enable_if<!std::is_pointer<T>::value, cl_int>::type
6986 return detail::errHandler(
6987 ::clSetProgramSpecializationConstant(
6992 __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR);
7001 return detail::errHandler(
7002 ::clSetProgramSpecializationConstant(
7007 __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR);
7012#if CL_HPP_TARGET_OPENCL_VERSION >= 120
7016 const char* options =
nullptr,
7017 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7018 void* data =
nullptr,
7019 cl_int* err =
nullptr)
7021 cl_int error_local = CL_SUCCESS;
7022 cl_program programs[2] = { input1(), input2() };
7024 Context ctx = input1.getInfo<CL_PROGRAM_CONTEXT>(&error_local);
7025 if(error_local!=CL_SUCCESS) {
7026 detail::errHandler(error_local, __LINK_PROGRAM_ERR);
7029 cl_program prog = ::clLinkProgram(
7040 detail::errHandler(error_local,__COMPILE_PROGRAM_ERR);
7041 if (err !=
nullptr) {
7045 return Program(prog);
7048inline Program linkProgram(
7049 const Program& input1,
7050 const Program& input2,
7051 const string& options,
7052 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7053 void* data =
nullptr,
7054 cl_int* err =
nullptr)
7056 return linkProgram(input1, input2, options.c_str(), notifyFptr, data, err);
7059inline Program linkProgram(
7060 const vector<Program>& inputPrograms,
7061 const char* options =
nullptr,
7062 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7063 void* data =
nullptr,
7064 cl_int* err =
nullptr)
7066 cl_int error_local = CL_SUCCESS;
7069 static_assert(
sizeof(
cl::Program) ==
sizeof(cl_program),
7070 "Size of cl::Program must be equal to size of cl_program");
7072 if(inputPrograms.size() > 0) {
7073 ctx = inputPrograms[0].getInfo<CL_PROGRAM_CONTEXT>(&error_local);
7074 if(error_local!=CL_SUCCESS) {
7075 detail::errHandler(error_local, __LINK_PROGRAM_ERR);
7079 cl_program prog = ::clLinkProgram(
7084 static_cast<cl_uint
>(inputPrograms.size()),
7085 reinterpret_cast<const cl_program *
>(inputPrograms.data()),
7090 detail::errHandler(error_local,__COMPILE_PROGRAM_ERR);
7091 if (err !=
nullptr) {
7095 return Program(prog);
7098inline Program linkProgram(
7099 const vector<Program>& inputPrograms,
7100 const string& options,
7101 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7102 void* data =
nullptr,
7103 cl_int* err =
nullptr)
7105 return linkProgram(inputPrograms, options.c_str(), notifyFptr, data, err);
7111inline cl_int cl::Program::getInfo(cl_program_info name, vector<vector<unsigned char>>* param)
const
7113 if (name != CL_PROGRAM_BINARIES) {
7114 return CL_INVALID_VALUE;
7120 vector<size_type> sizes = getInfo<CL_PROGRAM_BINARY_SIZES>();
7121 size_type numBinaries = sizes.size();
7124 param->resize(numBinaries);
7125 for (size_type i = 0; i < numBinaries; ++i) {
7126 (*param)[i].resize(sizes[i]);
7129 return detail::errHandler(
7130 detail::getInfo(&::clGetProgramInfo, object_, name, param),
7131 __GET_PROGRAM_INFO_ERR);
7138inline vector<vector<unsigned char>> cl::Program::getInfo<CL_PROGRAM_BINARIES>(cl_int* err)
const
7140 vector<vector<unsigned char>> binariesVectors;
7142 cl_int result = getInfo(CL_PROGRAM_BINARIES, &binariesVectors);
7143 if (err !=
nullptr) {
7146 return binariesVectors;
7149#if CL_HPP_TARGET_OPENCL_VERSION >= 220
7154 cl_uchar ucValue = value ? CL_UCHAR_MAX : 0;
7155 return detail::errHandler(
7156 ::clSetProgramSpecializationConstant(
7161 __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR);
7165inline Kernel::Kernel(
const Program& program,
const string& name, cl_int* err)
7169 object_ = ::clCreateKernel(program(), name.c_str(), &error);
7170 detail::errHandler(error, __CREATE_KERNEL_ERR);
7172 if (err !=
nullptr) {
7177inline Kernel::Kernel(
const Program& program,
const char* name, cl_int* err)
7181 object_ = ::clCreateKernel(program(), name, &error);
7182 detail::errHandler(error, __CREATE_KERNEL_ERR);
7184 if (err !=
nullptr) {
7189#ifdef cl_khr_external_memory
7190enum class ExternalMemoryType : cl_external_memory_handle_type_khr
7194 OpaqueFd = CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_FD_KHR,
7195 OpaqueWin32 = CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KHR,
7196 OpaqueWin32Kmt = CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KMT_KHR,
7198 D3D11Texture = CL_EXTERNAL_MEMORY_HANDLE_D3D11_TEXTURE_KHR,
7199 D3D11TextureKmt = CL_EXTERNAL_MEMORY_HANDLE_D3D11_TEXTURE_KMT_KHR,
7201 D3D12Heap = CL_EXTERNAL_MEMORY_HANDLE_D3D12_HEAP_KHR,
7202 D3D12Resource = CL_EXTERNAL_MEMORY_HANDLE_D3D12_RESOURCE_KHR,
7204 DmaBuf = CL_EXTERNAL_MEMORY_HANDLE_DMA_BUF_KHR,
7208enum class QueueProperties : cl_command_queue_properties
7211 Profiling = CL_QUEUE_PROFILING_ENABLE,
7212 OutOfOrder = CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE,
7215inline QueueProperties operator|(QueueProperties lhs, QueueProperties rhs)
7217 return static_cast<QueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) |
static_cast<cl_command_queue_properties
>(rhs));
7220inline QueueProperties operator&(QueueProperties lhs, QueueProperties rhs)
7222 return static_cast<QueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) &
static_cast<cl_command_queue_properties
>(rhs));
7231 static std::once_flag default_initialized_;
7233 static cl_int default_error_;
7240 static void makeDefault()
7245#if defined(CL_HPP_ENABLE_EXCEPTIONS)
7252 if (error != CL_SUCCESS) {
7253 default_error_ = error;
7257 default_ =
CommandQueue(context, device, 0, &default_error_);
7260#if defined(CL_HPP_ENABLE_EXCEPTIONS)
7261 catch (cl::Error &e) {
7262 default_error_ = e.err();
7272 static void makeDefaultProvided(
const CommandQueue &c) {
7276#ifdef cl_khr_external_memory
7277 static std::once_flag ext_memory_initialized_;
7279 static void initMemoryExtension(
const cl::Device& device)
7281 auto platform = device.
getInfo<CL_DEVICE_PLATFORM>()();
7283 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueAcquireExternalMemObjectsKHR);
7284 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueReleaseExternalMemObjectsKHR);
7286 if ((pfn_clEnqueueAcquireExternalMemObjectsKHR ==
nullptr)
7287 && (pfn_clEnqueueReleaseExternalMemObjectsKHR ==
nullptr))
7289 detail::errHandler(CL_INVALID_VALUE, __ENQUEUE_ACQUIRE_EXTERNAL_MEMORY_ERR);
7295#ifdef CL_HPP_UNIT_TEST_ENABLE
7302 static void unitTestClearDefault() {
7313 cl_command_queue_properties properties,
7314 cl_int* err =
nullptr)
7319 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7321 if (error != CL_SUCCESS) {
7322 if (err !=
nullptr) {
7327 Device device = context.getInfo<CL_CONTEXT_DEVICES>()[0];
7328 bool useWithProperties;
7330#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7333 cl_uint version = detail::getContextPlatformVersion(context());
7334 useWithProperties = (version >= 0x20000);
7336#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7337 useWithProperties =
true;
7339 useWithProperties =
false;
7342#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7343 if (useWithProperties) {
7344 cl_queue_properties queue_properties[] = {
7345 CL_QUEUE_PROPERTIES, properties, 0 };
7346 if ((properties & CL_QUEUE_ON_DEVICE) == 0) {
7347 object_ = ::clCreateCommandQueueWithProperties(
7348 context(), device(), queue_properties, &error);
7351 error = CL_INVALID_QUEUE_PROPERTIES;
7354 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7355 if (err !=
nullptr) {
7360#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7361 if (!useWithProperties) {
7362 object_ = ::clCreateCommandQueue(
7363 context(), device(), properties, &error);
7365 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7366 if (err !=
nullptr) {
7379 QueueProperties properties,
7380 cl_int* err =
nullptr)
7385 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7387 if (error != CL_SUCCESS) {
7388 if (err !=
nullptr) {
7393 Device device = context.getInfo<CL_CONTEXT_DEVICES>()[0];
7394 bool useWithProperties;
7396#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7399 cl_uint version = detail::getContextPlatformVersion(context());
7400 useWithProperties = (version >= 0x20000);
7402#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7403 useWithProperties =
true;
7405 useWithProperties =
false;
7408#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7409 if (useWithProperties) {
7410 cl_queue_properties queue_properties[] = {
7411 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
7413 object_ = ::clCreateCommandQueueWithProperties(
7414 context(), device(), queue_properties, &error);
7416 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7417 if (err !=
nullptr) {
7422#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7423 if (!useWithProperties) {
7424 object_ = ::clCreateCommandQueue(
7425 context(), device(),
static_cast<cl_command_queue_properties
>(properties), &error);
7427 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7428 if (err !=
nullptr) {
7443 cl_command_queue_properties properties = 0,
7444 cl_int* err =
nullptr)
7447 bool useWithProperties;
7448 vector<cl::Device> devices;
7449 error = context.getInfo(CL_CONTEXT_DEVICES, &devices);
7451 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7453 if (error != CL_SUCCESS)
7455 if (err !=
nullptr) {
7461#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7464 cl_uint version = detail::getContextPlatformVersion(context());
7465 useWithProperties = (version >= 0x20000);
7467#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7468 useWithProperties =
true;
7470 useWithProperties =
false;
7473#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7474 if (useWithProperties) {
7475 cl_queue_properties queue_properties[] = {
7476 CL_QUEUE_PROPERTIES, properties, 0 };
7477 if ((properties & CL_QUEUE_ON_DEVICE) == 0) {
7478 object_ = ::clCreateCommandQueueWithProperties(
7479 context(), devices[0](), queue_properties, &error);
7482 error = CL_INVALID_QUEUE_PROPERTIES;
7485 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7486 if (err !=
nullptr) {
7491#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7492 if (!useWithProperties) {
7493 object_ = ::clCreateCommandQueue(
7494 context(), devices[0](), properties, &error);
7496 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7497 if (err !=
nullptr) {
7510 QueueProperties properties,
7511 cl_int* err =
nullptr)
7514 bool useWithProperties;
7515 vector<cl::Device> devices;
7516 error = context.getInfo(CL_CONTEXT_DEVICES, &devices);
7518 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7520 if (error != CL_SUCCESS)
7522 if (err !=
nullptr) {
7528#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7531 cl_uint version = detail::getContextPlatformVersion(context());
7532 useWithProperties = (version >= 0x20000);
7534#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7535 useWithProperties =
true;
7537 useWithProperties =
false;
7540#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7541 if (useWithProperties) {
7542 cl_queue_properties queue_properties[] = {
7543 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
7544 object_ = ::clCreateCommandQueueWithProperties(
7545 context(), devices[0](), queue_properties, &error);
7547 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7548 if (err !=
nullptr) {
7553#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7554 if (!useWithProperties) {
7555 object_ = ::clCreateCommandQueue(
7556 context(), devices[0](),
static_cast<cl_command_queue_properties
>(properties), &error);
7558 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7559 if (err !=
nullptr) {
7573 cl_command_queue_properties properties = 0,
7574 cl_int* err =
nullptr)
7577 bool useWithProperties;
7579#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7582 cl_uint version = detail::getContextPlatformVersion(context());
7583 useWithProperties = (version >= 0x20000);
7585#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7586 useWithProperties =
true;
7588 useWithProperties =
false;
7591#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7592 if (useWithProperties) {
7593 cl_queue_properties queue_properties[] = {
7594 CL_QUEUE_PROPERTIES, properties, 0 };
7595 object_ = ::clCreateCommandQueueWithProperties(
7596 context(), device(), queue_properties, &error);
7598 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7599 if (err !=
nullptr) {
7604#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7605 if (!useWithProperties) {
7606 object_ = ::clCreateCommandQueue(
7607 context(), device(), properties, &error);
7609 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7610 if (err !=
nullptr) {
7624 QueueProperties properties,
7625 cl_int* err =
nullptr)
7628 bool useWithProperties;
7630#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7633 cl_uint version = detail::getContextPlatformVersion(context());
7634 useWithProperties = (version >= 0x20000);
7636#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7637 useWithProperties =
true;
7639 useWithProperties =
false;
7642#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7643 if (useWithProperties) {
7644 cl_queue_properties queue_properties[] = {
7645 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
7646 object_ = ::clCreateCommandQueueWithProperties(
7647 context(), device(), queue_properties, &error);
7649 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7650 if (err !=
nullptr) {
7655#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7656 if (!useWithProperties) {
7657 object_ = ::clCreateCommandQueue(
7658 context(), device(),
static_cast<cl_command_queue_properties
>(properties), &error);
7660 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7661 if (err !=
nullptr) {
7670 std::call_once(default_initialized_, makeDefault);
7671#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7672 detail::errHandler(default_error_, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7674 detail::errHandler(default_error_, __CREATE_COMMAND_QUEUE_ERR);
7676 if (err !=
nullptr) {
7677 *err = default_error_;
7691 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_queue));
7692 detail::errHandler(default_error_);
7705 explicit CommandQueue(
const cl_command_queue& commandQueue,
bool retainObject =
false) :
7714 template <
typename T>
7715 cl_int getInfo(cl_command_queue_info name, T* param)
const
7717 return detail::errHandler(
7719 &::clGetCommandQueueInfo, object_, name, param),
7720 __GET_COMMAND_QUEUE_INFO_ERR);
7723 template <cl_command_queue_info name>
typename
7725 getInfo(cl_int* err =
nullptr)
const
7728 detail::cl_command_queue_info, name>::param_type param;
7729 cl_int result = getInfo(name, ¶m);
7730 if (err !=
nullptr) {
7736 cl_int enqueueReadBuffer(
7742 const vector<Event>* events =
nullptr,
7743 Event* event =
nullptr)
const
7746 cl_int err = detail::errHandler(
7747 ::clEnqueueReadBuffer(
7748 object_, buffer(), blocking, offset, size,
7750 (events !=
nullptr) ? (cl_uint) events->size() : 0,
7751 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
7752 (
event !=
nullptr) ? &tmp :
nullptr),
7753 __ENQUEUE_READ_BUFFER_ERR);
7755 if (event !=
nullptr && err == CL_SUCCESS)
7761 cl_int enqueueWriteBuffer(
7767 const vector<Event>* events =
nullptr,
7768 Event* event =
nullptr)
const
7771 cl_int err = detail::errHandler(
7772 ::clEnqueueWriteBuffer(
7773 object_, buffer(), blocking, offset, size,
7775 (events !=
nullptr) ? (cl_uint) events->size() : 0,
7776 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
7777 (
event !=
nullptr) ? &tmp :
nullptr),
7778 __ENQUEUE_WRITE_BUFFER_ERR);
7780 if (event !=
nullptr && err == CL_SUCCESS)
7786 cl_int enqueueCopyBuffer(
7789 size_type src_offset,
7790 size_type dst_offset,
7792 const vector<Event>* events =
nullptr,
7793 Event* event =
nullptr)
const
7796 cl_int err = detail::errHandler(
7797 ::clEnqueueCopyBuffer(
7798 object_, src(), dst(), src_offset, dst_offset, size,
7799 (events !=
nullptr) ? (cl_uint) events->size() : 0,
7800 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
7801 (
event !=
nullptr) ? &tmp :
nullptr),
7802 __ENQEUE_COPY_BUFFER_ERR);
7804 if (event !=
nullptr && err == CL_SUCCESS)
7809#if CL_HPP_TARGET_OPENCL_VERSION >= 110
7810 cl_int enqueueReadBufferRect(
7813 const array<size_type, 3>& buffer_offset,
7814 const array<size_type, 3>& host_offset,
7815 const array<size_type, 3>& region,
7816 size_type buffer_row_pitch,
7817 size_type buffer_slice_pitch,
7818 size_type host_row_pitch,
7819 size_type host_slice_pitch,
7821 const vector<Event>* events =
nullptr,
7822 Event* event =
nullptr)
const
7825 cl_int err = detail::errHandler(
7826 ::clEnqueueReadBufferRect(
7830 buffer_offset.data(),
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_READ_BUFFER_RECT_ERR);
7843 if (event !=
nullptr && err == CL_SUCCESS)
7849 cl_int enqueueReadBufferRect(
7852 const array<size_type, 2>& buffer_offset,
7853 const array<size_type, 2>& host_offset,
7854 const array<size_type, 2>& region,
7855 size_type buffer_row_pitch,
7856 size_type buffer_slice_pitch,
7857 size_type host_row_pitch,
7858 size_type host_slice_pitch,
7860 const vector<Event>* events =
nullptr,
7861 Event* event =
nullptr)
const
7863 return enqueueReadBufferRect(
7866 { buffer_offset[0], buffer_offset[1], 0 },
7867 { host_offset[0], host_offset[1], 0 },
7868 { region[0], region[1], 1 },
7878 cl_int enqueueWriteBufferRect(
7881 const array<size_type, 3>& buffer_offset,
7882 const array<size_type, 3>& host_offset,
7883 const array<size_type, 3>& region,
7884 size_type buffer_row_pitch,
7885 size_type buffer_slice_pitch,
7886 size_type host_row_pitch,
7887 size_type host_slice_pitch,
7889 const vector<Event>* events =
nullptr,
7890 Event* event =
nullptr)
const
7893 cl_int err = detail::errHandler(
7894 ::clEnqueueWriteBufferRect(
7898 buffer_offset.data(),
7906 (events !=
nullptr) ? (cl_uint) events->size() : 0,
7907 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
7908 (
event !=
nullptr) ? &tmp :
nullptr),
7909 __ENQUEUE_WRITE_BUFFER_RECT_ERR);
7911 if (event !=
nullptr && err == CL_SUCCESS)
7917 cl_int enqueueWriteBufferRect(
7920 const array<size_type, 2>& buffer_offset,
7921 const array<size_type, 2>& host_offset,
7922 const array<size_type, 2>& region,
7923 size_type buffer_row_pitch,
7924 size_type buffer_slice_pitch,
7925 size_type host_row_pitch,
7926 size_type host_slice_pitch,
7928 const vector<Event>* events =
nullptr,
7929 Event* event =
nullptr)
const
7931 return enqueueWriteBufferRect(
7934 { buffer_offset[0], buffer_offset[1], 0 },
7935 { host_offset[0], host_offset[1], 0 },
7936 { region[0], region[1], 1 },
7946 cl_int enqueueCopyBufferRect(
7949 const array<size_type, 3>& src_origin,
7950 const array<size_type, 3>& dst_origin,
7951 const array<size_type, 3>& region,
7952 size_type src_row_pitch,
7953 size_type src_slice_pitch,
7954 size_type dst_row_pitch,
7955 size_type dst_slice_pitch,
7956 const vector<Event>* events =
nullptr,
7957 Event* event =
nullptr)
const
7960 cl_int err = detail::errHandler(
7961 ::clEnqueueCopyBufferRect(
7972 (events !=
nullptr) ? (cl_uint) events->size() : 0,
7973 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
7974 (
event !=
nullptr) ? &tmp :
nullptr),
7975 __ENQEUE_COPY_BUFFER_RECT_ERR);
7977 if (event !=
nullptr && err == CL_SUCCESS)
7983 cl_int enqueueCopyBufferRect(
7986 const array<size_type, 2>& src_origin,
7987 const array<size_type, 2>& dst_origin,
7988 const array<size_type, 2>& region,
7989 size_type src_row_pitch,
7990 size_type src_slice_pitch,
7991 size_type dst_row_pitch,
7992 size_type dst_slice_pitch,
7993 const vector<Event>* events =
nullptr,
7994 Event* event =
nullptr)
const
7996 return enqueueCopyBufferRect(
7999 { src_origin[0], src_origin[1], 0 },
8000 { dst_origin[0], dst_origin[1], 0 },
8001 { region[0], region[1], 1 },
8011#if CL_HPP_TARGET_OPENCL_VERSION >= 120
8023 template<
typename PatternType>
8026 PatternType pattern,
8029 const vector<Event>* events =
nullptr,
8030 Event* event =
nullptr)
const
8033 cl_int err = detail::errHandler(
8034 ::clEnqueueFillBuffer(
8037 static_cast<void*
>(&pattern),
8038 sizeof(PatternType),
8041 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8042 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
8043 (
event !=
nullptr) ? &tmp :
nullptr),
8044 __ENQUEUE_FILL_BUFFER_ERR);
8046 if (event !=
nullptr && err == CL_SUCCESS)
8053 cl_int enqueueReadImage(
8056 const array<size_type, 3>& origin,
8057 const array<size_type, 3>& region,
8058 size_type row_pitch,
8059 size_type slice_pitch,
8061 const vector<Event>* events =
nullptr,
8062 Event* event =
nullptr)
const
8065 cl_int err = detail::errHandler(
8066 ::clEnqueueReadImage(
8075 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8076 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
8077 (
event !=
nullptr) ? &tmp :
nullptr),
8078 __ENQUEUE_READ_IMAGE_ERR);
8080 if (event !=
nullptr && err == CL_SUCCESS)
8086 cl_int enqueueReadImage(
8089 const array<size_type, 2>& origin,
8090 const array<size_type, 2>& region,
8091 size_type row_pitch,
8092 size_type slice_pitch,
8094 const vector<Event>* events =
nullptr,
8095 Event* event =
nullptr)
const
8097 return enqueueReadImage(
8100 { origin[0], origin[1], 0 },
8101 { region[0], region[1], 1 },
8109 cl_int enqueueWriteImage(
8112 const array<size_type, 3>& origin,
8113 const array<size_type, 3>& region,
8114 size_type row_pitch,
8115 size_type slice_pitch,
8117 const vector<Event>* events =
nullptr,
8118 Event* event =
nullptr)
const
8121 cl_int err = detail::errHandler(
8122 ::clEnqueueWriteImage(
8131 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8132 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
8133 (
event !=
nullptr) ? &tmp :
nullptr),
8134 __ENQUEUE_WRITE_IMAGE_ERR);
8136 if (event !=
nullptr && err == CL_SUCCESS)
8142 cl_int enqueueWriteImage(
8145 const array<size_type, 2>& origin,
8146 const array<size_type, 2>& region,
8147 size_type row_pitch,
8148 size_type slice_pitch,
8150 const vector<Event>* events =
nullptr,
8151 Event* event =
nullptr)
const
8153 return enqueueWriteImage(
8156 { origin[0], origin[1], 0 },
8157 { region[0], region[1], 1 },
8165 cl_int enqueueCopyImage(
8168 const array<size_type, 3>& src_origin,
8169 const array<size_type, 3>& dst_origin,
8170 const array<size_type, 3>& region,
8171 const vector<Event>* events =
nullptr,
8172 Event* event =
nullptr)
const
8175 cl_int err = detail::errHandler(
8176 ::clEnqueueCopyImage(
8183 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8184 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
8185 (
event !=
nullptr) ? &tmp :
nullptr),
8186 __ENQUEUE_COPY_IMAGE_ERR);
8188 if (event !=
nullptr && err == CL_SUCCESS)
8194 cl_int enqueueCopyImage(
8197 const array<size_type, 2>& src_origin,
8198 const array<size_type, 2>& dst_origin,
8199 const array<size_type, 2>& region,
8200 const vector<Event>* events =
nullptr,
8201 Event* event =
nullptr)
const
8203 return enqueueCopyImage(
8206 { src_origin[0], src_origin[1], 0 },
8207 { dst_origin[0], dst_origin[1], 0 },
8208 { region[0], region[1], 1 },
8213#if CL_HPP_TARGET_OPENCL_VERSION >= 120
8221 template <
typename T>
8222 typename std::enable_if<std::is_same<T, cl_float4>::value ||
8223 std::is_same<T, cl_int4 >::value ||
8224 std::is_same<T, cl_uint4 >::value,
8229 const array<size_type, 3>& origin,
8230 const array<size_type, 3>& region,
8231 const vector<Event>* events =
nullptr,
8232 Event* event =
nullptr)
const
8235 cl_int err = detail::errHandler(
8236 ::clEnqueueFillImage(
8239 static_cast<void*
>(&fillColor),
8242 (events !=
nullptr) ? (cl_uint)events->size() : 0,
8243 (events !=
nullptr && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8244 (
event != NULL) ? &tmp :
nullptr),
8245 __ENQUEUE_FILL_IMAGE_ERR);
8247 if (event !=
nullptr && err == CL_SUCCESS) *
event = tmp;
8259 template <
typename T>
8260 typename std::enable_if<std::is_same<T, cl_float4>::value ||
8261 std::is_same<T, cl_int4 >::value ||
8262 std::is_same<T, cl_uint4 >::value, cl_int>::type
8266 const array<size_type, 2>& origin,
8267 const array<size_type, 2>& region,
8268 const vector<Event>* events =
nullptr,
8269 Event* event =
nullptr)
const
8274 { origin[0], origin[1], 0 },
8275 { region[0], region[1], 1 },
8282 cl_int enqueueCopyImageToBuffer(
8285 const array<size_type, 3>& src_origin,
8286 const array<size_type, 3>& region,
8287 size_type dst_offset,
8288 const vector<Event>* events =
nullptr,
8289 Event* event =
nullptr)
const
8292 cl_int err = detail::errHandler(
8293 ::clEnqueueCopyImageToBuffer(
8300 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8301 (events != nullptr && events->size() > 0) ? (cl_event*) &events->front() : nullptr,
8302 (event != nullptr) ? &tmp : nullptr),
8303 __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR);
8305 if (event !=
nullptr && err == CL_SUCCESS)
8311 cl_int enqueueCopyImageToBuffer(
8314 const array<size_type, 2>& src_origin,
8315 const array<size_type, 2>& region,
8316 size_type dst_offset,
8317 const vector<Event>* events =
nullptr,
8318 Event* event =
nullptr)
const
8320 return enqueueCopyImageToBuffer(
8323 { src_origin[0], src_origin[1], 0 },
8324 { region[0], region[1], 1 },
8330 cl_int enqueueCopyBufferToImage(
8333 size_type src_offset,
8334 const array<size_type, 3>& dst_origin,
8335 const array<size_type, 3>& region,
8336 const vector<Event>* events =
nullptr,
8337 Event* event =
nullptr)
const
8340 cl_int err = detail::errHandler(
8341 ::clEnqueueCopyBufferToImage(
8348 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8349 (events != nullptr && events->size() > 0) ? (cl_event*) &events->front() : nullptr,
8350 (event != nullptr) ? &tmp : nullptr),
8351 __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR);
8353 if (event !=
nullptr && err == CL_SUCCESS)
8359 cl_int enqueueCopyBufferToImage(
8362 size_type src_offset,
8363 const array<size_type, 2>& dst_origin,
8364 const array<size_type, 2>& region,
8365 const vector<Event>* events =
nullptr,
8366 Event* event =
nullptr)
const
8368 return enqueueCopyBufferToImage(
8372 { dst_origin[0], dst_origin[1], 0 },
8373 { region[0], region[1], 1 },
8378 void* enqueueMapBuffer(
8379 const Buffer& buffer,
8384 const vector<Event>* events =
nullptr,
8385 Event* event =
nullptr,
8386 cl_int* err =
nullptr)
const
8390 void * result = ::clEnqueueMapBuffer(
8391 object_, buffer(), blocking, flags, offset, size,
8392 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8393 (events != nullptr && events->size() > 0) ? (cl_event*) &events->front() : nullptr,
8394 (event != nullptr) ? &tmp : nullptr,
8397 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
8398 if (err !=
nullptr) {
8401 if (event !=
nullptr && error == CL_SUCCESS)
8407 void* enqueueMapImage(
8411 const array<size_type, 3>& origin,
8412 const array<size_type, 3>& region,
8413 size_type * row_pitch,
8414 size_type * slice_pitch,
8415 const vector<Event>* events =
nullptr,
8416 Event* event =
nullptr,
8417 cl_int* err =
nullptr)
const
8421 void * result = ::clEnqueueMapImage(
8422 object_, image(), blocking, flags,
8425 row_pitch, slice_pitch,
8426 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8427 (events != nullptr && events->size() > 0) ? (cl_event*) &events->front() : nullptr,
8428 (event != nullptr) ? &tmp : nullptr,
8431 detail::errHandler(error, __ENQUEUE_MAP_IMAGE_ERR);
8432 if (err !=
nullptr) {
8435 if (event !=
nullptr && error == CL_SUCCESS)
8440 void* enqueueMapImage(
8444 const array<size_type, 2>& origin,
8445 const array<size_type, 2>& region,
8446 size_type* row_pitch,
8447 size_type* slice_pitch,
8448 const vector<Event>* events =
nullptr,
8449 Event* event =
nullptr,
8450 cl_int* err =
nullptr)
const
8452 return enqueueMapImage(image, blocking, flags,
8453 { origin[0], origin[1], 0 },
8454 { region[0], region[1], 1 }, row_pitch,
8455 slice_pitch, events, event, err);
8458#if CL_HPP_TARGET_OPENCL_VERSION >= 200
8464 template<
typename T>
8470 const vector<Event> *events =
nullptr,
8471 Event *event =
nullptr)
const {
8473 cl_int err = detail::errHandler(::clEnqueueSVMMemcpy(
8474 object_, blocking,
static_cast<void *
>(dst_ptr),
static_cast<const void *
>(src_ptr), size,
8475 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8476 (events != nullptr && events->size() > 0) ? (cl_event *) &events->front() : nullptr,
8477 (event != nullptr) ? &tmp : nullptr), __ENQUEUE_COPY_SVM_ERR);
8479 if (event !=
nullptr && err == CL_SUCCESS)
8489 template<
typename T,
class D>
8491 cl::pointer<T, D> &dst_ptr,
8492 const cl::pointer<T, D> &src_ptr,
8495 const vector<Event> *events =
nullptr,
8496 Event *event =
nullptr)
const {
8498 cl_int err = detail::errHandler(::clEnqueueSVMMemcpy(
8499 object_, blocking,
static_cast<void *
>(dst_ptr.get()),
static_cast<const void *
>(src_ptr.get()),
8501 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8502 (events != nullptr && events->size() > 0) ? (cl_event *) &events->front() : nullptr,
8503 (event != nullptr) ? &tmp : nullptr), __ENQUEUE_COPY_SVM_ERR);
8505 if (event !=
nullptr && err == CL_SUCCESS)
8515 template<
typename T,
class Alloc>
8517 cl::vector<T, Alloc> &dst_container,
8518 const cl::vector<T, Alloc> &src_container,
8520 const vector<Event> *events =
nullptr,
8521 Event *event =
nullptr)
const {
8523 if(src_container.size() != dst_container.size()){
8524 return detail::errHandler(CL_INVALID_VALUE,__ENQUEUE_COPY_SVM_ERR);
8526 cl_int err = detail::errHandler(::clEnqueueSVMMemcpy(
8527 object_, blocking,
static_cast<void *
>(dst_container.data()),
8528 static_cast<const void *
>(src_container.data()),
8529 dst_container.size() *
sizeof(T),
8530 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8531 (events != nullptr && events->size() > 0) ? (cl_event *) &events->front() : nullptr,
8532 (event != NULL) ? &tmp : nullptr), __ENQUEUE_COPY_SVM_ERR);
8534 if (event !=
nullptr && err == CL_SUCCESS)
8544 template<
typename T,
typename PatternType>
8547 PatternType pattern,
8549 const vector<Event> *events =
nullptr,
8550 Event *event =
nullptr)
const {
8552 cl_int err = detail::errHandler(::clEnqueueSVMMemFill(
8553 object_,
static_cast<void *
>(ptr),
static_cast<void *
>(&pattern),
8554 sizeof(PatternType), size,
8555 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8556 (events != nullptr && events->size() > 0) ? (cl_event *) &events->front() : nullptr,
8557 (event != nullptr) ? &tmp : nullptr), __ENQUEUE_FILL_SVM_ERR);
8559 if (event !=
nullptr && err == CL_SUCCESS)
8569 template<
typename T,
class D,
typename PatternType>
8571 cl::pointer<T, D> &ptr,
8572 PatternType pattern,
8574 const vector<Event> *events =
nullptr,
8575 Event *event =
nullptr)
const {
8577 cl_int err = detail::errHandler(::clEnqueueSVMMemFill(
8578 object_,
static_cast<void *
>(ptr.get()),
static_cast<void *
>(&pattern),
8579 sizeof(PatternType), size,
8580 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8581 (events != nullptr && events->size() > 0) ? (cl_event *) &events->front() : nullptr,
8582 (event != nullptr) ? &tmp : nullptr), __ENQUEUE_FILL_SVM_ERR);
8584 if (event !=
nullptr && err == CL_SUCCESS)
8594 template<
typename T,
class Alloc,
typename PatternType>
8596 cl::vector<T, Alloc> &container,
8597 PatternType pattern,
8598 const vector<Event> *events =
nullptr,
8599 Event* event =
nullptr)
const
8602 cl_int err = detail::errHandler(::clEnqueueSVMMemFill(
8603 object_,
static_cast<void *
>(container.data()),
static_cast<void *
>(&pattern),
8604 sizeof(PatternType), container.size() *
sizeof(T),
8605 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8606 (events != nullptr && events->size() > 0) ? (cl_event *) &events->front() : nullptr,
8607 (event != nullptr) ? &tmp : NULL), __ENQUEUE_FILL_SVM_ERR);
8609 if (event !=
nullptr && err == CL_SUCCESS)
8619 template<
typename T>
8625 const vector<Event>* events =
nullptr,
8626 Event* event =
nullptr)
const
8629 cl_int err = detail::errHandler(::clEnqueueSVMMap(
8630 object_, blocking, flags,
static_cast<void*
>(ptr), size,
8631 (events !=
nullptr) ? (cl_uint)events->size() : 0,
8632 (events != nullptr && events->size() > 0) ? (cl_event*)&events->front() : nullptr,
8633 (event != nullptr) ? &tmp : nullptr),
8634 __ENQUEUE_MAP_SVM_ERR);
8636 if (event !=
nullptr && err == CL_SUCCESS)
8647 template<
typename T,
class D>
8649 cl::pointer<T, D> &ptr,
8653 const vector<Event>* events =
nullptr,
8654 Event* event =
nullptr)
const
8657 cl_int err = detail::errHandler(::clEnqueueSVMMap(
8658 object_, blocking, flags,
static_cast<void*
>(ptr.get()), size,
8659 (events !=
nullptr) ? (cl_uint)events->size() : 0,
8660 (events != nullptr && events->size() > 0) ? (cl_event*)&events->front() : nullptr,
8661 (event != nullptr) ? &tmp : nullptr),
8662 __ENQUEUE_MAP_SVM_ERR);
8664 if (event !=
nullptr && err == CL_SUCCESS)
8674 template<
typename T,
class Alloc>
8676 cl::vector<T, Alloc> &container,
8679 const vector<Event>* events =
nullptr,
8680 Event* event =
nullptr)
const
8683 cl_int err = detail::errHandler(::clEnqueueSVMMap(
8684 object_, blocking, flags,
static_cast<void*
>(container.data()), container.size()*
sizeof(T),
8685 (events !=
nullptr) ? (cl_uint)events->size() : 0,
8686 (events != nullptr && events->size() > 0) ? (cl_event*)&events->front() : nullptr,
8687 (event != nullptr) ? &tmp : nullptr),
8688 __ENQUEUE_MAP_SVM_ERR);
8690 if (event !=
nullptr && err == CL_SUCCESS)
8697 cl_int enqueueUnmapMemObject(
8698 const Memory& memory,
8700 const vector<Event>* events =
nullptr,
8701 Event* event =
nullptr)
const
8704 cl_int err = detail::errHandler(
8705 ::clEnqueueUnmapMemObject(
8706 object_, memory(), mapped_ptr,
8707 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8708 (events != nullptr && events->size() > 0) ? (cl_event*) &events->front() : nullptr,
8709 (event != nullptr) ? &tmp : nullptr),
8710 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8712 if (event !=
nullptr && err == CL_SUCCESS)
8719#if CL_HPP_TARGET_OPENCL_VERSION >= 200
8724 template<
typename T>
8727 const vector<Event>* events =
nullptr,
8728 Event* event =
nullptr)
const
8731 cl_int err = detail::errHandler(
8732 ::clEnqueueSVMUnmap(
8733 object_,
static_cast<void*
>(ptr),
8734 (events !=
nullptr) ? (cl_uint)events->size() : 0,
8735 (events != nullptr && events->size() > 0) ? (cl_event*)&events->front() : nullptr,
8736 (event != nullptr) ? &tmp : nullptr),
8737 __ENQUEUE_UNMAP_SVM_ERR);
8739 if (event !=
nullptr && err == CL_SUCCESS)
8749 template<
typename T,
class D>
8751 cl::pointer<T, D> &ptr,
8752 const vector<Event>* events =
nullptr,
8753 Event* event =
nullptr)
const
8756 cl_int err = detail::errHandler(
8757 ::clEnqueueSVMUnmap(
8758 object_,
static_cast<void*
>(ptr.get()),
8759 (events !=
nullptr) ? (cl_uint)events->size() : 0,
8760 (events != nullptr && events->size() > 0) ? (cl_event*)&events->front() : nullptr,
8761 (event != nullptr) ? &tmp : nullptr),
8762 __ENQUEUE_UNMAP_SVM_ERR);
8764 if (event !=
nullptr && err == CL_SUCCESS)
8774 template<
typename T,
class Alloc>
8776 cl::vector<T, Alloc> &container,
8777 const vector<Event>* events =
nullptr,
8778 Event* event =
nullptr)
const
8781 cl_int err = detail::errHandler(
8782 ::clEnqueueSVMUnmap(
8783 object_,
static_cast<void*
>(container.data()),
8784 (events !=
nullptr) ? (cl_uint)events->size() : 0,
8785 (events != nullptr && events->size() > 0) ? (cl_event*)&events->front() : nullptr,
8786 (event != nullptr) ? &tmp : nullptr),
8787 __ENQUEUE_UNMAP_SVM_ERR);
8789 if (event !=
nullptr && err == CL_SUCCESS)
8796#if CL_HPP_TARGET_OPENCL_VERSION >= 120
8809 const vector<Event> *events =
nullptr,
8810 Event *event =
nullptr)
const
8813 cl_int err = detail::errHandler(
8814 ::clEnqueueMarkerWithWaitList(
8816 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8817 (events != nullptr && events->size() > 0) ? (cl_event*) &events->front() : nullptr,
8818 (event != nullptr) ? &tmp : nullptr),
8819 __ENQUEUE_MARKER_WAIT_LIST_ERR);
8821 if (event !=
nullptr && err == CL_SUCCESS)
8839 const vector<Event> *events =
nullptr,
8840 Event *event =
nullptr)
const
8843 cl_int err = detail::errHandler(
8844 ::clEnqueueBarrierWithWaitList(
8846 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8847 (events != nullptr && events->size() > 0) ? (cl_event*) &events->front() : nullptr,
8848 (event != nullptr) ? &tmp : nullptr),
8849 __ENQUEUE_BARRIER_WAIT_LIST_ERR);
8851 if (event !=
nullptr && err == CL_SUCCESS)
8862 const vector<Memory> &memObjects,
8863 cl_mem_migration_flags flags,
8864 const vector<Event>* events =
nullptr,
8865 Event* event =
nullptr
8870 vector<cl_mem> localMemObjects(memObjects.size());
8872 for(
int i = 0; i < (int)memObjects.size(); ++i ) {
8873 localMemObjects[i] = memObjects[i]();
8876 cl_int err = detail::errHandler(
8877 ::clEnqueueMigrateMemObjects(
8879 (cl_uint)memObjects.size(),
8880 localMemObjects.data(),
8882 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8883 (events != nullptr && events->size() > 0) ? (cl_event*) &events->front() : nullptr,
8884 (event != nullptr) ? &tmp : nullptr),
8885 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8887 if (event !=
nullptr && err == CL_SUCCESS)
8895#if CL_HPP_TARGET_OPENCL_VERSION >= 210
8901 template<
typename T>
8903 const cl::vector<T*> &svmRawPointers,
8904 const cl::vector<size_type> &sizes,
8905 cl_mem_migration_flags flags = 0,
8906 const vector<Event>* events =
nullptr,
8907 Event* event =
nullptr)
const
8910 cl_int err = detail::errHandler(::clEnqueueSVMMigrateMem(
8912 svmRawPointers.size(),
static_cast<void**
>(svmRawPointers.data()),
8915 (events !=
nullptr) ? (cl_uint)events->size() : 0,
8916 (events != nullptr && events->size() > 0) ? (cl_event*)&events->front() : nullptr,
8917 (event != nullptr) ? &tmp : nullptr),
8918 __ENQUEUE_MIGRATE_SVM_ERR);
8920 if (event !=
nullptr && err == CL_SUCCESS)
8930 template<
typename T>
8932 const cl::vector<T*> &svmRawPointers,
8933 cl_mem_migration_flags flags = 0,
8934 const vector<Event>* events =
nullptr,
8935 Event* event =
nullptr)
const
8937 return enqueueMigrateSVM(svmRawPointers, cl::vector<size_type>(svmRawPointers.size()), flags, events, event);
8946 template<
typename T,
class D>
8948 const cl::vector<cl::pointer<T, D>> &svmPointers,
8949 const cl::vector<size_type> &sizes,
8950 cl_mem_migration_flags flags = 0,
8951 const vector<Event>* events =
nullptr,
8952 Event* event =
nullptr)
const
8954 cl::vector<void*> svmRawPointers;
8955 svmRawPointers.reserve(svmPointers.size());
8956 for (
auto p : svmPointers) {
8957 svmRawPointers.push_back(
static_cast<void*
>(p.get()));
8968 template<
typename T,
class D>
8970 const cl::vector<cl::pointer<T, D>> &svmPointers,
8971 cl_mem_migration_flags flags = 0,
8972 const vector<Event>* events =
nullptr,
8973 Event* event =
nullptr)
const
8975 return enqueueMigrateSVM(svmPointers, cl::vector<size_type>(svmPointers.size()), flags, events, event);
8983 template<
typename T,
class Alloc>
8985 const cl::vector<cl::vector<T, Alloc>> &svmContainers,
8986 const cl::vector<size_type> &sizes,
8987 cl_mem_migration_flags flags = 0,
8988 const vector<Event>* events =
nullptr,
8989 Event* event =
nullptr)
const
8991 cl::vector<void*> svmRawPointers;
8992 svmRawPointers.reserve(svmContainers.size());
8993 for (
auto p : svmContainers) {
8994 svmRawPointers.push_back(
static_cast<void*
>(p.data()));
9004 template<
typename T,
class Alloc>
9006 const cl::vector<cl::vector<T, Alloc>> &svmContainers,
9007 cl_mem_migration_flags flags = 0,
9008 const vector<Event>* events =
nullptr,
9009 Event* event =
nullptr)
const
9011 return enqueueMigrateSVM(svmContainers, cl::vector<size_type>(svmContainers.size()), flags, events, event);
9016 cl_int enqueueNDRangeKernel(
9017 const Kernel& kernel,
9018 const NDRange& offset,
9019 const NDRange& global,
9020 const NDRange& local = NullRange,
9021 const vector<Event>* events =
nullptr,
9022 Event* event =
nullptr)
const
9025 cl_int err = detail::errHandler(
9026 ::clEnqueueNDRangeKernel(
9027 object_, kernel(), (cl_uint) global.dimensions(),
9028 offset.dimensions() != 0 ? (
const size_type*) offset : nullptr,
9029 (const size_type*) global,
9030 local.dimensions() != 0 ? (const size_type*) local : nullptr,
9031 (events != nullptr) ? (cl_uint) events->size() : 0,
9032 (events != nullptr && events->size() > 0) ? (cl_event*) &events->front() : nullptr,
9033 (event != nullptr) ? &tmp : nullptr),
9034 __ENQUEUE_NDRANGE_KERNEL_ERR);
9036 if (event !=
nullptr && err == CL_SUCCESS)
9042#if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
9043 CL_API_PREFIX__VERSION_1_2_DEPRECATED cl_int enqueueTask(
9044 const Kernel& kernel,
9045 const vector<Event>* events =
nullptr,
9046 Event* event =
nullptr) const CL_API_SUFFIX__VERSION_1_2_DEPRECATED
9049 cl_int err = detail::errHandler(
9052 (events !=
nullptr) ? (cl_uint) events->size() : 0,
9053 (events != nullptr && events->size() > 0) ? (cl_event*) &events->front() : nullptr,
9054 (event != nullptr) ? &tmp : nullptr),
9055 __ENQUEUE_TASK_ERR);
9057 if (event !=
nullptr && err == CL_SUCCESS)
9064 cl_int enqueueNativeKernel(
9065 void (CL_CALLBACK *userFptr)(
void *),
9066 std::pair<void*, size_type> args,
9067 const vector<Memory>* mem_objects =
nullptr,
9068 const vector<const void*>* mem_locs =
nullptr,
9069 const vector<Event>* events =
nullptr,
9070 Event* event =
nullptr)
const
9073 cl_int err = detail::errHandler(
9074 ::clEnqueueNativeKernel(
9075 object_, userFptr, args.first, args.second,
9076 (mem_objects !=
nullptr) ? (cl_uint) mem_objects->size() : 0,
9077 (mem_objects->size() > 0 ) ? reinterpret_cast<const cl_mem *>(mem_objects->data()) : nullptr,
9078 (mem_locs != nullptr && mem_locs->size() > 0) ? (const void **) &mem_locs->front() : nullptr,
9079 (events != nullptr) ? (cl_uint) events->size() : 0,
9080 (events != nullptr && events->size() > 0) ? (cl_event*) &events->front() : nullptr,
9081 (event != nullptr) ? &tmp : nullptr),
9082 __ENQUEUE_NATIVE_KERNEL);
9084 if (event !=
nullptr && err == CL_SUCCESS)
9093#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
9094 CL_API_PREFIX__VERSION_1_1_DEPRECATED
9095 cl_int
enqueueMarker(Event* event =
nullptr) const CL_API_SUFFIX__VERSION_1_1_DEPRECATED
9098 cl_int err = detail::errHandler(
9101 (event !=
nullptr) ? &tmp : nullptr),
9102 __ENQUEUE_MARKER_ERR);
9104 if (event !=
nullptr && err == CL_SUCCESS)
9110 CL_API_PREFIX__VERSION_1_1_DEPRECATED
9111 cl_int enqueueWaitForEvents(
const vector<Event>& events)
const CL_API_SUFFIX__VERSION_1_1_DEPRECATED
9113 return detail::errHandler(
9114 ::clEnqueueWaitForEvents(
9116 (cl_uint) events.size(),
9117 events.size() > 0 ? (
const cl_event*) &events.front() : nullptr),
9118 __ENQUEUE_WAIT_FOR_EVENTS_ERR);
9122 cl_int enqueueAcquireGLObjects(
9123 const vector<Memory>* mem_objects =
nullptr,
9124 const vector<Event>* events =
nullptr,
9125 Event* event =
nullptr)
const
9128 cl_int err = detail::errHandler(
9129 ::clEnqueueAcquireGLObjects(
9131 (mem_objects !=
nullptr) ? (cl_uint) mem_objects->size() : 0,
9132 (mem_objects != nullptr && mem_objects->size() > 0) ? (const cl_mem *) &mem_objects->front(): nullptr,
9133 (events != nullptr) ? (cl_uint) events->size() : 0,
9134 (events != nullptr && events->size() > 0) ? (cl_event*) &events->front() : nullptr,
9135 (event != nullptr) ? &tmp : nullptr),
9136 __ENQUEUE_ACQUIRE_GL_ERR);
9138 if (event !=
nullptr && err == CL_SUCCESS)
9144 cl_int enqueueReleaseGLObjects(
9145 const vector<Memory>* mem_objects =
nullptr,
9146 const vector<Event>* events =
nullptr,
9147 Event* event =
nullptr)
const
9150 cl_int err = detail::errHandler(
9151 ::clEnqueueReleaseGLObjects(
9153 (mem_objects !=
nullptr) ? (cl_uint) mem_objects->size() : 0,
9154 (mem_objects != nullptr && mem_objects->size() > 0) ? (const cl_mem *) &mem_objects->front(): nullptr,
9155 (events != nullptr) ? (cl_uint) events->size() : 0,
9156 (events != nullptr && events->size() > 0) ? (cl_event*) &events->front() : nullptr,
9157 (event != nullptr) ? &tmp : nullptr),
9158 __ENQUEUE_RELEASE_GL_ERR);
9160 if (event !=
nullptr && err == CL_SUCCESS)
9166#if defined (CL_HPP_USE_DX_INTEROP)
9167typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueAcquireD3D10ObjectsKHR)(
9168 cl_command_queue command_queue, cl_uint num_objects,
9169 const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
9170 const cl_event* event_wait_list, cl_event* event);
9171typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueReleaseD3D10ObjectsKHR)(
9172 cl_command_queue command_queue, cl_uint num_objects,
9173 const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
9174 const cl_event* event_wait_list, cl_event* event);
9176 cl_int enqueueAcquireD3D10Objects(
9177 const vector<Memory>* mem_objects =
nullptr,
9178 const vector<Event>* events =
nullptr,
9179 Event* event =
nullptr)
const
9181 static PFN_clEnqueueAcquireD3D10ObjectsKHR pfn_clEnqueueAcquireD3D10ObjectsKHR =
nullptr;
9182#if CL_HPP_TARGET_OPENCL_VERSION >= 120
9183 cl_context context = getInfo<CL_QUEUE_CONTEXT>();
9184 cl::Device device(getInfo<CL_QUEUE_DEVICE>());
9185 cl_platform_id platform = device.
getInfo<CL_DEVICE_PLATFORM>();
9186 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueAcquireD3D10ObjectsKHR);
9188#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
9189 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueAcquireD3D10ObjectsKHR);
9193 cl_int err = detail::errHandler(
9194 pfn_clEnqueueAcquireD3D10ObjectsKHR(
9196 (mem_objects !=
nullptr) ? (cl_uint) mem_objects->size() : 0,
9197 (mem_objects != nullptr && mem_objects->size() > 0) ? (const cl_mem *) &mem_objects->front(): nullptr,
9198 (events != nullptr) ? (cl_uint) events->size() : 0,
9199 (events != nullptr) ? (cl_event*) &events->front() : nullptr,
9200 (event != nullptr) ? &tmp : nullptr),
9201 __ENQUEUE_ACQUIRE_GL_ERR);
9203 if (event !=
nullptr && err == CL_SUCCESS)
9209 cl_int enqueueReleaseD3D10Objects(
9210 const vector<Memory>* mem_objects =
nullptr,
9211 const vector<Event>* events =
nullptr,
9212 Event* event =
nullptr)
const
9214 static PFN_clEnqueueReleaseD3D10ObjectsKHR pfn_clEnqueueReleaseD3D10ObjectsKHR =
nullptr;
9215#if CL_HPP_TARGET_OPENCL_VERSION >= 120
9216 cl_context context = getInfo<CL_QUEUE_CONTEXT>();
9217 cl::Device device(getInfo<CL_QUEUE_DEVICE>());
9218 cl_platform_id platform = device.
getInfo<CL_DEVICE_PLATFORM>();
9219 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueReleaseD3D10ObjectsKHR);
9221#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
9222 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueReleaseD3D10ObjectsKHR);
9226 cl_int err = detail::errHandler(
9227 pfn_clEnqueueReleaseD3D10ObjectsKHR(
9229 (mem_objects !=
nullptr) ? (cl_uint) mem_objects->size() : 0,
9230 (mem_objects != nullptr && mem_objects->size() > 0) ? (const cl_mem *) &mem_objects->front(): nullptr,
9231 (events != nullptr) ? (cl_uint) events->size() : 0,
9232 (events != nullptr && events->size() > 0) ? (cl_event*) &events->front() : nullptr,
9233 (event != nullptr) ? &tmp : nullptr),
9234 __ENQUEUE_RELEASE_GL_ERR);
9236 if (event !=
nullptr && err == CL_SUCCESS)
9246#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
9247 CL_API_PREFIX__VERSION_1_1_DEPRECATED
9248 cl_int
enqueueBarrier() const CL_API_SUFFIX__VERSION_1_1_DEPRECATED
9250 return detail::errHandler(
9251 ::clEnqueueBarrier(object_),
9252 __ENQUEUE_BARRIER_ERR);
9256 cl_int flush()
const
9258 return detail::errHandler(::clFlush(object_), __FLUSH_ERR);
9261 cl_int finish()
const
9263 return detail::errHandler(::clFinish(object_), __FINISH_ERR);
9266#ifdef cl_khr_external_memory
9267 cl_int enqueueAcquireExternalMemObjects(
9268 const vector<Memory>& mem_objects,
9269 const vector<Event>* events_wait =
nullptr,
9270 Event *event =
nullptr)
9272 cl_int err = CL_INVALID_OPERATION;
9275 std::call_once(ext_memory_initialized_, initMemoryExtension, this->getInfo<CL_QUEUE_DEVICE>());
9277 if (pfn_clEnqueueAcquireExternalMemObjectsKHR)
9279 err = pfn_clEnqueueAcquireExternalMemObjectsKHR(
9281 static_cast<cl_uint
>(mem_objects.size()),
9282 (mem_objects.size() > 0) ?
reinterpret_cast<const cl_mem *
>(mem_objects.data()) : nullptr,
9283 (events_wait != nullptr) ? static_cast<cl_uint>(events_wait->size()) : 0,
9284 (events_wait != nullptr && events_wait->size() > 0) ? reinterpret_cast<const cl_event*>(events_wait->data()) : nullptr,
9288 detail::errHandler(err, __ENQUEUE_ACQUIRE_EXTERNAL_MEMORY_ERR);
9290 if (event !=
nullptr && err == CL_SUCCESS)
9296 cl_int enqueueReleaseExternalMemObjects(
9297 const vector<Memory>& mem_objects,
9298 const vector<Event>* events_wait =
nullptr,
9299 Event *event =
nullptr)
9301 cl_int err = CL_INVALID_OPERATION;
9304 std::call_once(ext_memory_initialized_, initMemoryExtension, this->getInfo<CL_QUEUE_DEVICE>());
9306 if (pfn_clEnqueueReleaseExternalMemObjectsKHR)
9308 err = pfn_clEnqueueReleaseExternalMemObjectsKHR(
9310 static_cast<cl_uint
>(mem_objects.size()),
9311 (mem_objects.size() > 0) ?
reinterpret_cast<const cl_mem *
>(mem_objects.data()) : nullptr,
9312 (events_wait != nullptr) ? static_cast<cl_uint>(events_wait->size()) : 0,
9313 (events_wait != nullptr && events_wait->size() > 0) ? reinterpret_cast<const cl_event*>(events_wait->data()) : nullptr,
9317 detail::errHandler(err, __ENQUEUE_RELEASE_EXTERNAL_MEMORY_ERR);
9319 if (event !=
nullptr && err == CL_SUCCESS)
9326#ifdef cl_khr_semaphore
9327 cl_int enqueueWaitSemaphores(
9328 const vector<Semaphore> &sema_objects,
9329 const vector<cl_semaphore_payload_khr> &sema_payloads = {},
9330 const vector<Event>* events_wait_list =
nullptr,
9331 Event *
event =
nullptr)
const;
9333 cl_int enqueueSignalSemaphores(
9334 const vector<Semaphore> &sema_objects,
9335 const vector<cl_semaphore_payload_khr>& sema_payloads = {},
9336 const vector<Event>* events_wait_list =
nullptr,
9337 Event*
event =
nullptr);
9341#ifdef cl_khr_external_memory
9342CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag CommandQueue::ext_memory_initialized_;
9345CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag CommandQueue::default_initialized_;
9346CL_HPP_DEFINE_STATIC_MEMBER_ CommandQueue CommandQueue::default_;
9347CL_HPP_DEFINE_STATIC_MEMBER_ cl_int CommandQueue::default_error_ = CL_SUCCESS;
9350#if CL_HPP_TARGET_OPENCL_VERSION >= 200
9351enum class DeviceQueueProperties : cl_command_queue_properties
9354 Profiling = CL_QUEUE_PROFILING_ENABLE,
9357inline DeviceQueueProperties operator|(DeviceQueueProperties lhs, DeviceQueueProperties rhs)
9359 return static_cast<DeviceQueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) |
static_cast<cl_command_queue_properties
>(rhs));
9383 cl_command_queue_properties mergedProperties =
9384 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
9386 cl_queue_properties queue_properties[] = {
9387 CL_QUEUE_PROPERTIES, mergedProperties, 0 };
9388 object_ = ::clCreateCommandQueueWithProperties(
9389 context(), device(), queue_properties, &error);
9391 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9392 if (err !=
nullptr) {
9403 DeviceQueueProperties properties = DeviceQueueProperties::None,
9404 cl_int* err =
nullptr)
9408 cl_command_queue_properties mergedProperties =
9409 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
9410 cl_queue_properties queue_properties[] = {
9411 CL_QUEUE_PROPERTIES, mergedProperties, 0 };
9412 object_ = ::clCreateCommandQueueWithProperties(
9413 context(), device(), queue_properties, &error);
9415 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9416 if (err !=
nullptr) {
9428 DeviceQueueProperties properties = DeviceQueueProperties::None,
9429 cl_int* err =
nullptr)
9433 cl_command_queue_properties mergedProperties =
9434 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
9435 cl_queue_properties queue_properties[] = {
9436 CL_QUEUE_PROPERTIES, mergedProperties,
9437 CL_QUEUE_SIZE, queueSize,
9439 object_ = ::clCreateCommandQueueWithProperties(
9440 context(), device(), queue_properties, &error);
9442 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9443 if (err !=
nullptr) {
9454 explicit DeviceCommandQueue(
const cl_command_queue& commandQueue,
bool retainObject =
false) :
9455 detail::Wrapper<cl_type>(commandQueue, retainObject) { }
9459 detail::Wrapper<cl_type>::operator=(rhs);
9463 template <
typename T>
9464 cl_int getInfo(cl_command_queue_info name, T* param)
const
9466 return detail::errHandler(
9468 &::clGetCommandQueueInfo, object_, name, param),
9469 __GET_COMMAND_QUEUE_INFO_ERR);
9472 template <cl_command_queue_info name>
typename
9473 detail::param_traits<detail::cl_command_queue_info, name>::param_type
9474 getInfo(cl_int* err =
nullptr)
const
9476 typename detail::param_traits<
9477 detail::cl_command_queue_info, name>::param_type param;
9478 cl_int result = getInfo(name, ¶m);
9479 if (err !=
nullptr) {
9492 cl_int *err =
nullptr)
9498 cl_command_queue_properties properties =
9499 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
9500 cl_queue_properties queue_properties[] = {
9501 CL_QUEUE_PROPERTIES, properties,
9504 ::clCreateCommandQueueWithProperties(
9505 context(), device(), queue_properties, &error));
9507 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9508 if (err !=
nullptr) {
9522 const Context &context,
const Device &device, cl_int *err =
nullptr)
9526 cl_command_queue_properties properties =
9527 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
9528 cl_queue_properties queue_properties[] = {
9529 CL_QUEUE_PROPERTIES, properties,
9532 ::clCreateCommandQueueWithProperties(
9533 context(), device(), queue_properties, &error));
9535 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9536 if (err !=
nullptr) {
9550 const Context &context,
const Device &device, cl_uint queueSize, cl_int *err =
nullptr)
9554 cl_command_queue_properties properties =
9555 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
9556 cl_queue_properties queue_properties[] = {
9557 CL_QUEUE_PROPERTIES, properties,
9558 CL_QUEUE_SIZE, queueSize,
9561 ::clCreateCommandQueueWithProperties(
9562 context(), device(), queue_properties, &error));
9564 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9565 if (err !=
nullptr) {
9574#if CL_HPP_TARGET_OPENCL_VERSION >= 210
9584 error = clSetDefaultDeviceCommandQueue(context.get(), device.get(), default_queue.get());
9586 detail::errHandler(error, __SET_DEFAULT_DEVICE_COMMAND_QUEUE_ERR);
9587 if (err !=
nullptr) {
9590 return default_queue;
9598 return queue.getInfo<CL_QUEUE_DEVICE_DEFAULT>(err);
9618template<
typename IteratorType >
9621 IteratorType startIterator,
9622 IteratorType endIterator,
9627 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9630 cl_mem_flags flags = 0;
9632 flags |= CL_MEM_READ_ONLY;
9635 flags |= CL_MEM_READ_WRITE;
9638 flags |= CL_MEM_USE_HOST_PTR;
9641 size_type size =
sizeof(DataType)*(endIterator - startIterator);
9644 object_ = ::clCreateBuffer(context(), flags, size,
const_cast<DataType*
>(&*startIterator), &error);
9646 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
9649 detail::errHandler(error, __CREATE_BUFFER_ERR);
9650 if (err !=
nullptr) {
9656 detail::errHandler(error, __CREATE_BUFFER_ERR);
9657 if (err !=
nullptr) {
9661 error =
cl::copy(queue, startIterator, endIterator, *
this);
9662 detail::errHandler(error, __CREATE_BUFFER_ERR);
9663 if (err !=
nullptr) {
9669template<
typename IteratorType >
9671 const CommandQueue &queue,
9672 IteratorType startIterator,
9673 IteratorType endIterator,
9678 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9681 cl_mem_flags flags = 0;
9683 flags |= CL_MEM_READ_ONLY;
9686 flags |= CL_MEM_READ_WRITE;
9689 flags |= CL_MEM_USE_HOST_PTR;
9692 size_type size =
sizeof(DataType)*(endIterator - startIterator);
9694 Context context = queue.getInfo<CL_QUEUE_CONTEXT>();
9697 object_ = ::clCreateBuffer(context(), flags, size,
const_cast<DataType*
>(&*startIterator), &error);
9700 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
9703 detail::errHandler(error, __CREATE_BUFFER_ERR);
9704 if (err !=
nullptr) {
9709 error =
cl::copy(queue, startIterator, endIterator, *
this);
9710 detail::errHandler(error, __CREATE_BUFFER_ERR);
9711 if (err !=
nullptr) {
9717inline cl_int enqueueReadBuffer(
9718 const Buffer& buffer,
9723 const vector<Event>* events =
nullptr,
9724 Event* event =
nullptr)
9727 CommandQueue queue = CommandQueue::getDefault(&error);
9729 if (error != CL_SUCCESS) {
9733 return queue.enqueueReadBuffer(buffer, blocking, offset, size, ptr, events, event);
9736inline cl_int enqueueWriteBuffer(
9737 const Buffer& buffer,
9742 const vector<Event>* events =
nullptr,
9743 Event* event =
nullptr)
9746 CommandQueue queue = CommandQueue::getDefault(&error);
9748 if (error != CL_SUCCESS) {
9752 return queue.enqueueWriteBuffer(buffer, blocking, offset, size, ptr, events, event);
9755inline void* enqueueMapBuffer(
9756 const Buffer& buffer,
9761 const vector<Event>* events =
nullptr,
9762 Event* event =
nullptr,
9763 cl_int* err =
nullptr)
9766 CommandQueue queue = CommandQueue::getDefault(&error);
9767 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9768 if (err !=
nullptr) {
9772 void * result = ::clEnqueueMapBuffer(
9773 queue(), buffer(), blocking, flags, offset, size,
9774 (events !=
nullptr) ? (cl_uint) events->size() : 0,
9775 (events != nullptr && events->size() > 0) ? (cl_event*) &events->front() : nullptr,
9779 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9780 if (err !=
nullptr) {
9787#if CL_HPP_TARGET_OPENCL_VERSION >= 200
9799 const vector<Event>* events,
9803 CommandQueue queue = CommandQueue::getDefault(&error);
9804 if (error != CL_SUCCESS) {
9805 return detail::errHandler(error, __ENQUEUE_MAP_SVM_ERR);
9808 return queue.enqueueMapSVM(
9809 ptr, blocking, flags, size, events, event);
9817template<
typename T,
class D>
9819 cl::pointer<T, D> &ptr,
9823 const vector<Event>* events =
nullptr,
9824 Event* event =
nullptr)
9827 CommandQueue queue = CommandQueue::getDefault(&error);
9828 if (error != CL_SUCCESS) {
9829 return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9832 return queue.enqueueMapSVM(
9833 ptr, blocking, flags, size, events, event);
9841template<
typename T,
class Alloc>
9843 cl::vector<T, Alloc> &container,
9846 const vector<Event>* events =
nullptr,
9847 Event* event =
nullptr)
9850 CommandQueue queue = CommandQueue::getDefault(&error);
9851 if (error != CL_SUCCESS) {
9852 return detail::errHandler(error, __ENQUEUE_MAP_SVM_ERR);
9855 return queue.enqueueMapSVM(
9856 container, blocking, flags, events, event);
9861inline cl_int enqueueUnmapMemObject(
9862 const Memory& memory,
9864 const vector<Event>* events =
nullptr,
9865 Event* event =
nullptr)
9868 CommandQueue queue = CommandQueue::getDefault(&error);
9869 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9870 if (error != CL_SUCCESS) {
9875 cl_int err = detail::errHandler(
9876 ::clEnqueueUnmapMemObject(
9877 queue(), memory(), mapped_ptr,
9878 (events !=
nullptr) ? (cl_uint)events->size() : 0,
9879 (events != nullptr && events->size() > 0) ? (cl_event*)&events->front() : nullptr,
9880 (event != nullptr) ? &tmp : nullptr),
9881 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9883 if (event !=
nullptr && err == CL_SUCCESS)
9889#if CL_HPP_TARGET_OPENCL_VERSION >= 200
9898 const vector<Event>* events =
nullptr,
9899 Event* event =
nullptr)
9902 CommandQueue queue = CommandQueue::getDefault(&error);
9903 if (error != CL_SUCCESS) {
9904 return detail::errHandler(error, __ENQUEUE_UNMAP_SVM_ERR);
9907 return detail::errHandler(queue.enqueueUnmapSVM(ptr, events, event),
9908 __ENQUEUE_UNMAP_SVM_ERR);
9917template<
typename T,
class D>
9919 cl::pointer<T, D> &ptr,
9920 const vector<Event>* events =
nullptr,
9921 Event* event =
nullptr)
9924 CommandQueue queue = CommandQueue::getDefault(&error);
9925 if (error != CL_SUCCESS) {
9926 return detail::errHandler(error, __ENQUEUE_UNMAP_SVM_ERR);
9929 return detail::errHandler(queue.enqueueUnmapSVM(ptr, events, event),
9930 __ENQUEUE_UNMAP_SVM_ERR);
9938template<
typename T,
class Alloc>
9940 cl::vector<T, Alloc> &container,
9941 const vector<Event>* events =
nullptr,
9942 Event* event =
nullptr)
9945 CommandQueue queue = CommandQueue::getDefault(&error);
9946 if (error != CL_SUCCESS) {
9947 return detail::errHandler(error, __ENQUEUE_UNMAP_SVM_ERR);
9950 return detail::errHandler(queue.enqueueUnmapSVM(container, events, event),
9951 __ENQUEUE_UNMAP_SVM_ERR);
9956inline cl_int enqueueCopyBuffer(
9959 size_type src_offset,
9960 size_type dst_offset,
9962 const vector<Event>* events =
nullptr,
9963 Event* event =
nullptr)
9966 CommandQueue queue = CommandQueue::getDefault(&error);
9968 if (error != CL_SUCCESS) {
9972 return queue.enqueueCopyBuffer(src, dst, src_offset, dst_offset, size, events, event);
9980template<
typename IteratorType >
9981inline cl_int
copy( IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer )
9984 CommandQueue queue = CommandQueue::getDefault(&error);
9985 if (error != CL_SUCCESS)
9988 return cl::copy(queue, startIterator, endIterator, buffer);
9996template<
typename IteratorType >
9997inline cl_int
copy(
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator )
10000 CommandQueue queue = CommandQueue::getDefault(&error);
10001 if (error != CL_SUCCESS)
10004 return cl::copy(queue, buffer, startIterator, endIterator);
10012template<
typename IteratorType >
10013inline cl_int
copy(
const CommandQueue &queue, IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer )
10015 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
10018 size_type length = endIterator-startIterator;
10019 size_type byteLength = length*
sizeof(DataType);
10021 DataType *pointer =
10022 static_cast<DataType*
>(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_WRITE, 0, byteLength, 0, 0, &error));
10024 if( error != CL_SUCCESS ) {
10027#if defined(_MSC_VER)
10031 stdext::checked_array_iterator<DataType*>(
10034 std::copy(startIterator, endIterator, pointer);
10037 error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
10039 if( error != CL_SUCCESS ) {
10051template<
typename IteratorType >
10052inline cl_int
copy(
const CommandQueue &queue,
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator )
10054 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
10057 size_type length = endIterator-startIterator;
10058 size_type byteLength = length*
sizeof(DataType);
10060 DataType *pointer =
10061 static_cast<DataType*
>(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_READ, 0, byteLength, 0, 0, &error));
10063 if( error != CL_SUCCESS ) {
10066 std::copy(pointer, pointer + length, startIterator);
10068 error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
10070 if( error != CL_SUCCESS ) {
10078#if CL_HPP_TARGET_OPENCL_VERSION >= 200
10082template<
typename T,
class Alloc>
10083inline cl_int
mapSVM(cl::vector<T, Alloc> &container)
10085 return enqueueMapSVM(container, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE);
10091template<
typename T,
class Alloc>
10092inline cl_int
unmapSVM(cl::vector<T, Alloc> &container)
10099#if CL_HPP_TARGET_OPENCL_VERSION >= 110
10100inline cl_int enqueueReadBufferRect(
10101 const Buffer& buffer,
10103 const array<size_type, 3>& buffer_offset,
10104 const array<size_type, 3>& host_offset,
10105 const array<size_type, 3>& region,
10106 size_type buffer_row_pitch,
10107 size_type buffer_slice_pitch,
10108 size_type host_row_pitch,
10109 size_type host_slice_pitch,
10111 const vector<Event>* events =
nullptr,
10112 Event* event =
nullptr)
10115 CommandQueue queue = CommandQueue::getDefault(&error);
10117 if (error != CL_SUCCESS) {
10121 return queue.enqueueReadBufferRect(
10128 buffer_slice_pitch,
10136inline cl_int enqueueReadBufferRect(
10137 const Buffer& buffer,
10139 const array<size_type, 2>& buffer_offset,
10140 const array<size_type, 2>& host_offset,
10141 const array<size_type, 2>& region,
10142 size_type buffer_row_pitch,
10143 size_type buffer_slice_pitch,
10144 size_type host_row_pitch,
10145 size_type host_slice_pitch,
10147 const vector<Event>* events =
nullptr,
10148 Event* event =
nullptr)
10150 return enqueueReadBufferRect(
10153 { buffer_offset[0], buffer_offset[1], 0 },
10154 { host_offset[0], host_offset[1], 0 },
10155 { region[0], region[1], 1 },
10157 buffer_slice_pitch,
10165inline cl_int enqueueWriteBufferRect(
10166 const Buffer& buffer,
10168 const array<size_type, 3>& buffer_offset,
10169 const array<size_type, 3>& host_offset,
10170 const array<size_type, 3>& region,
10171 size_type buffer_row_pitch,
10172 size_type buffer_slice_pitch,
10173 size_type host_row_pitch,
10174 size_type host_slice_pitch,
10176 const vector<Event>* events =
nullptr,
10177 Event* event =
nullptr)
10180 CommandQueue queue = CommandQueue::getDefault(&error);
10182 if (error != CL_SUCCESS) {
10186 return queue.enqueueWriteBufferRect(
10193 buffer_slice_pitch,
10201inline cl_int enqueueWriteBufferRect(
10202 const Buffer& buffer,
10204 const array<size_type, 2>& buffer_offset,
10205 const array<size_type, 2>& host_offset,
10206 const array<size_type, 2>& region,
10207 size_type buffer_row_pitch,
10208 size_type buffer_slice_pitch,
10209 size_type host_row_pitch,
10210 size_type host_slice_pitch,
10212 const vector<Event>* events =
nullptr,
10213 Event* event =
nullptr)
10215 return enqueueWriteBufferRect(
10218 { buffer_offset[0], buffer_offset[1], 0 },
10219 { host_offset[0], host_offset[1], 0 },
10220 { region[0], region[1], 1 },
10222 buffer_slice_pitch,
10230inline cl_int enqueueCopyBufferRect(
10233 const array<size_type, 3>& src_origin,
10234 const array<size_type, 3>& dst_origin,
10235 const array<size_type, 3>& region,
10236 size_type src_row_pitch,
10237 size_type src_slice_pitch,
10238 size_type dst_row_pitch,
10239 size_type dst_slice_pitch,
10240 const vector<Event>* events =
nullptr,
10241 Event* event =
nullptr)
10244 CommandQueue queue = CommandQueue::getDefault(&error);
10246 if (error != CL_SUCCESS) {
10250 return queue.enqueueCopyBufferRect(
10264inline cl_int enqueueCopyBufferRect(
10267 const array<size_type, 2>& src_origin,
10268 const array<size_type, 2>& dst_origin,
10269 const array<size_type, 2>& region,
10270 size_type src_row_pitch,
10271 size_type src_slice_pitch,
10272 size_type dst_row_pitch,
10273 size_type dst_slice_pitch,
10274 const vector<Event>* events =
nullptr,
10275 Event* event =
nullptr)
10277 return enqueueCopyBufferRect(
10280 { src_origin[0], src_origin[1], 0 },
10281 { dst_origin[0], dst_origin[1], 0 },
10282 { region[0], region[1], 1 },
10292inline cl_int enqueueReadImage(
10293 const Image& image,
10295 const array<size_type, 3>& origin,
10296 const array<size_type, 3>& region,
10297 size_type row_pitch,
10298 size_type slice_pitch,
10300 const vector<Event>* events =
nullptr,
10301 Event* event =
nullptr)
10304 CommandQueue queue = CommandQueue::getDefault(&error);
10306 if (error != CL_SUCCESS) {
10310 return queue.enqueueReadImage(
10322inline cl_int enqueueReadImage(
10323 const Image& image,
10325 const array<size_type, 2>& origin,
10326 const array<size_type, 2>& region,
10327 size_type row_pitch,
10328 size_type slice_pitch,
10330 const vector<Event>* events =
nullptr,
10331 Event* event =
nullptr)
10333 return enqueueReadImage(
10336 { origin[0], origin[1], 0 },
10337 { region[0], region[1], 1 },
10345inline cl_int enqueueWriteImage(
10346 const Image& image,
10348 const array<size_type, 3>& origin,
10349 const array<size_type, 3>& region,
10350 size_type row_pitch,
10351 size_type slice_pitch,
10353 const vector<Event>* events =
nullptr,
10354 Event* event =
nullptr)
10357 CommandQueue queue = CommandQueue::getDefault(&error);
10359 if (error != CL_SUCCESS) {
10363 return queue.enqueueWriteImage(
10375inline cl_int enqueueWriteImage(
10376 const Image& image,
10378 const array<size_type, 2>& origin,
10379 const array<size_type, 2>& region,
10380 size_type row_pitch,
10381 size_type slice_pitch,
10383 const vector<Event>* events =
nullptr,
10384 Event* event =
nullptr)
10386 return enqueueWriteImage(
10389 { origin[0], origin[1], 0 },
10390 { region[0], region[1], 1 },
10398inline cl_int enqueueCopyImage(
10401 const array<size_type, 3>& src_origin,
10402 const array<size_type, 3>& dst_origin,
10403 const array<size_type, 3>& region,
10404 const vector<Event>* events =
nullptr,
10405 Event* event =
nullptr)
10408 CommandQueue queue = CommandQueue::getDefault(&error);
10410 if (error != CL_SUCCESS) {
10414 return queue.enqueueCopyImage(
10424inline cl_int enqueueCopyImage(
10427 const array<size_type, 2>& src_origin,
10428 const array<size_type, 2>& dst_origin,
10429 const array<size_type, 2>& region,
10430 const vector<Event>* events =
nullptr,
10431 Event* event =
nullptr)
10433 return enqueueCopyImage(
10436 { src_origin[0], src_origin[1], 0 },
10437 { dst_origin[0], dst_origin[1], 0 },
10438 { region[0], region[1], 1 },
10443inline cl_int enqueueCopyImageToBuffer(
10446 const array<size_type, 3>& src_origin,
10447 const array<size_type, 3>& region,
10448 size_type dst_offset,
10449 const vector<Event>* events =
nullptr,
10450 Event* event =
nullptr)
10453 CommandQueue queue = CommandQueue::getDefault(&error);
10455 if (error != CL_SUCCESS) {
10459 return queue.enqueueCopyImageToBuffer(
10469inline cl_int enqueueCopyImageToBuffer(
10472 const array<size_type, 2>& src_origin,
10473 const array<size_type, 2>& region,
10474 size_type dst_offset,
10475 const vector<Event>* events =
nullptr,
10476 Event* event =
nullptr)
10478 return enqueueCopyImageToBuffer(
10481 { src_origin[0], src_origin[1], 0 },
10482 { region[0], region[1], 1 },
10488inline cl_int enqueueCopyBufferToImage(
10491 size_type src_offset,
10492 const array<size_type, 3>& dst_origin,
10493 const array<size_type, 3>& region,
10494 const vector<Event>* events =
nullptr,
10495 Event* event =
nullptr)
10498 CommandQueue queue = CommandQueue::getDefault(&error);
10500 if (error != CL_SUCCESS) {
10504 return queue.enqueueCopyBufferToImage(
10514inline cl_int enqueueCopyBufferToImage(
10517 size_type src_offset,
10518 const array<size_type, 2>& dst_origin,
10519 const array<size_type, 2>& region,
10520 const vector<Event>* events =
nullptr,
10521 Event* event =
nullptr)
10524 CommandQueue queue = CommandQueue::getDefault(&error);
10526 if (error != CL_SUCCESS) {
10530 return enqueueCopyBufferToImage(
10534 { dst_origin[0], dst_origin[1], 0 },
10535 { region[0], region[1], 1 },
10540inline cl_int flush(
void)
10543 CommandQueue queue = CommandQueue::getDefault(&error);
10545 if (error != CL_SUCCESS) {
10549 return queue.flush();
10552inline cl_int finish(
void)
10555 CommandQueue queue = CommandQueue::getDefault(&error);
10557 if (error != CL_SUCCESS) {
10562 return queue.finish();
10572 vector<Event> events_;
10574 template<
typename... Ts>
10579 queue_(CommandQueue::getDefault()),
10580 offset_(NullRange),
10587 EnqueueArgs(NDRange global, NDRange local) :
10588 queue_(CommandQueue::getDefault()),
10589 offset_(NullRange),
10596 EnqueueArgs(NDRange offset, NDRange global, NDRange local) :
10597 queue_(CommandQueue::getDefault()),
10605 EnqueueArgs(Event e, NDRange global) :
10606 queue_(CommandQueue::getDefault()),
10607 offset_(NullRange),
10611 events_.push_back(e);
10614 EnqueueArgs(Event e, NDRange global, NDRange local) :
10615 queue_(CommandQueue::getDefault()),
10616 offset_(NullRange),
10620 events_.push_back(e);
10623 EnqueueArgs(Event e, NDRange offset, NDRange global, NDRange local) :
10624 queue_(CommandQueue::getDefault()),
10629 events_.push_back(e);
10632 EnqueueArgs(
const vector<Event> &events, NDRange global) :
10633 queue_(CommandQueue::getDefault()),
10634 offset_(NullRange),
10642 EnqueueArgs(
const vector<Event> &events, NDRange global, NDRange local) :
10643 queue_(CommandQueue::getDefault()),
10644 offset_(NullRange),
10652 EnqueueArgs(
const vector<Event> &events, NDRange offset, NDRange global, NDRange local) :
10653 queue_(CommandQueue::getDefault()),
10662 EnqueueArgs(CommandQueue &queue, NDRange global) :
10664 offset_(NullRange),
10671 EnqueueArgs(CommandQueue &queue, NDRange global, NDRange local) :
10673 offset_(NullRange),
10680 EnqueueArgs(CommandQueue &queue, NDRange offset, NDRange global, NDRange local) :
10689 EnqueueArgs(CommandQueue &queue, Event e, NDRange global) :
10691 offset_(NullRange),
10695 events_.push_back(e);
10698 EnqueueArgs(CommandQueue &queue, Event e, NDRange global, NDRange local) :
10700 offset_(NullRange),
10704 events_.push_back(e);
10707 EnqueueArgs(CommandQueue &queue, Event e, NDRange offset, NDRange global, NDRange local) :
10713 events_.push_back(e);
10716 EnqueueArgs(CommandQueue &queue,
const vector<Event> &events, NDRange global) :
10718 offset_(NullRange),
10726 EnqueueArgs(CommandQueue &queue,
const vector<Event> &events, NDRange global, NDRange local) :
10728 offset_(NullRange),
10736 EnqueueArgs(CommandQueue &queue,
const vector<Event> &events, NDRange offset, NDRange global, NDRange local) :
10755template<
typename... Ts>
10761 template<
int index,
typename T0,
typename... T1s>
10762 void setArgs(T0&& t0, T1s&&... t1s)
10764 kernel_.setArg(index, t0);
10765 setArgs<index + 1, T1s...>(std::forward<T1s>(t1s)...);
10768 template<
int index,
typename T0>
10769 void setArgs(T0&& t0)
10771 kernel_.setArg(index, t0);
10774 template<
int index>
10781 KernelFunctor(Kernel kernel) : kernel_(kernel)
10785 const Program& program,
10787 cl_int * err =
nullptr) :
10788 kernel_(program, name.c_str(), err)
10804 setArgs<0>(std::forward<Ts>(ts)...);
10806 args.queue_.enqueueNDRangeKernel(
10824 const EnqueueArgs& args,
10829 setArgs<0>(std::forward<Ts>(ts)...);
10831 error = args.queue_.enqueueNDRangeKernel(
10842#if CL_HPP_TARGET_OPENCL_VERSION >= 200
10843 cl_int setSVMPointers(
const vector<void*> &pointerList)
10845 return kernel_.setSVMPointers(pointerList);
10848 template<
typename T0,
typename... T1s>
10849 cl_int setSVMPointers(
const T0 &t0, T1s &... ts)
10851 return kernel_.setSVMPointers(t0, ts...);
10861namespace compatibility {
10866 template<
typename... Ts>
10869 typedef KernelFunctor<Ts...> FunctorType;
10871 FunctorType functor_;
10874 const Program& program,
10876 cl_int * err =
nullptr) :
10877 functor_(FunctorType(program, name, err))
10881 const Kernel kernel) :
10898 enqueueArgs, args...);
10903#ifdef cl_khr_semaphore
10905#ifdef cl_khr_external_semaphore
10906enum ExternalSemaphoreType : cl_external_semaphore_handle_type_khr
10909#ifdef cl_khr_external_semaphore_dx_fence
10910 D3D12Fence = CL_SEMAPHORE_HANDLE_D3D12_FENCE_KHR,
10912#ifdef cl_khr_external_semaphore_opaque_fd
10913 OpaqueFd = CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR,
10915#ifdef cl_khr_external_semaphore_sync_fd
10916 SyncFd = CL_SEMAPHORE_HANDLE_SYNC_FD_KHR,
10918#ifdef cl_khr_external_semaphore_win32
10919 OpaqueWin32 = CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KHR,
10920 OpaqueWin32Kmt = CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KMT_KHR,
10925class Semaphore :
public detail::Wrapper<cl_semaphore_khr>
10928 Semaphore() : detail::Wrapper<cl_type>() {}
10930 const Context &context,
10931 const vector<cl_semaphore_properties_khr>& sema_props,
10932 cl_int *err =
nullptr)
10935 std::call_once(ext_init_, initExtensions, context);
10937 cl_int error = CL_INVALID_OPERATION;
10939 if (pfn_clCreateSemaphoreWithPropertiesKHR)
10941 object_ = pfn_clCreateSemaphoreWithPropertiesKHR(
10947 detail::errHandler(error, __CREATE_SEMAPHORE_KHR_WITH_PROPERTIES_ERR);
10949 if (err !=
nullptr) {
10954 const vector<cl_semaphore_properties_khr>& sema_props,
10955 cl_int* err =
nullptr):Semaphore(Context::getDefault(err), sema_props, err) {}
10957 explicit Semaphore(
const cl_semaphore_khr& semaphore,
bool retainObject =
false) :
10958 detail::Wrapper<cl_type>(semaphore, retainObject) {}
10959 Semaphore& operator = (
const cl_semaphore_khr& rhs) {
10960 detail::Wrapper<cl_type>::operator=(rhs);
10963 template <
typename T>
10964 cl_int getInfo(cl_semaphore_info_khr name, T* param)
const
10966 if (pfn_clGetSemaphoreInfoKHR ==
nullptr) {
10967 return detail::errHandler(CL_INVALID_OPERATION,
10968 __GET_SEMAPHORE_KHR_INFO_ERR);
10971 return detail::errHandler(
10972 detail::getInfo(pfn_clGetSemaphoreInfoKHR, object_, name, param),
10973 __GET_SEMAPHORE_KHR_INFO_ERR);
10975 template <cl_semaphore_info_khr name>
typename
10976 detail::param_traits<detail::cl_semaphore_info_khr, name>::param_type
10977 getInfo(cl_int* err =
nullptr)
const
10979 typename detail::param_traits<
10980 detail::cl_semaphore_info_khr, name>::param_type param;
10981 cl_int result = getInfo(name, ¶m);
10982 if (err !=
nullptr) {
10988#ifdef cl_khr_external_semaphore
10989 template <
typename T>
10990 cl_int getHandleForTypeKHR(
10991 const Device& device, cl_external_semaphore_handle_type_khr name, T* param)
const
10993 if (pfn_clGetSemaphoreHandleForTypeKHR ==
nullptr) {
10994 return detail::errHandler(CL_INVALID_OPERATION,
10995 __GET_SEMAPHORE_HANDLE_FOR_TYPE_KHR_ERR);
10998 return detail::errHandler(
11000 pfn_clGetSemaphoreHandleForTypeKHR, object_, device(), name, param),
11001 __GET_SEMAPHORE_HANDLE_FOR_TYPE_KHR_ERR);
11004 template <cl_external_semaphore_handle_type_khr type>
typename
11005 detail::param_traits<detail::cl_external_semaphore_handle_type_khr, type>::param_type
11006 getHandleForTypeKHR(
const Device& device, cl_int* err =
nullptr)
const
11008 typename detail::param_traits<
11009 detail::cl_external_semaphore_handle_type_khr, type>::param_type param;
11010 cl_int result = getHandleForTypeKHR(device, type, ¶m);
11011 if (err !=
nullptr) {
11020 if (pfn_clRetainSemaphoreKHR ==
nullptr) {
11021 return detail::errHandler(CL_INVALID_OPERATION,
11022 __RETAIN_SEMAPHORE_KHR_ERR);
11024 return pfn_clRetainSemaphoreKHR(object_);
11029 if (pfn_clReleaseSemaphoreKHR ==
nullptr) {
11030 return detail::errHandler(CL_INVALID_OPERATION,
11031 __RELEASE_SEMAPHORE_KHR_ERR);
11033 return pfn_clReleaseSemaphoreKHR(object_);
11037 static std::once_flag ext_init_;
11039 static void initExtensions(
const Context& context)
11041#if CL_HPP_TARGET_OPENCL_VERSION >= 120
11042 Device device = context.getInfo<CL_CONTEXT_DEVICES>().at(0);
11043 cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>()();
11044 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCreateSemaphoreWithPropertiesKHR);
11045 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clReleaseSemaphoreKHR);
11046 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clRetainSemaphoreKHR);
11047 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueWaitSemaphoresKHR);
11048 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueSignalSemaphoresKHR);
11049 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clGetSemaphoreInfoKHR);
11050#ifdef cl_khr_external_semaphore
11051 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clGetSemaphoreHandleForTypeKHR);
11055 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateSemaphoreWithPropertiesKHR);
11056 CL_HPP_INIT_CL_EXT_FCN_PTR_(clReleaseSemaphoreKHR);
11057 CL_HPP_INIT_CL_EXT_FCN_PTR_(clRetainSemaphoreKHR);
11058 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueWaitSemaphoresKHR);
11059 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueSignalSemaphoresKHR);
11060 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetSemaphoreInfoKHR);
11061#ifdef cl_khr_external_semaphore
11062 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetSemaphoreHandleForTypeKHR);
11066 if ((pfn_clCreateSemaphoreWithPropertiesKHR ==
nullptr) &&
11067 (pfn_clReleaseSemaphoreKHR ==
nullptr) &&
11068 (pfn_clRetainSemaphoreKHR ==
nullptr) &&
11069 (pfn_clEnqueueWaitSemaphoresKHR ==
nullptr) &&
11070 (pfn_clEnqueueSignalSemaphoresKHR ==
nullptr) &&
11071#ifdef cl_khr_external_semaphore
11072 (pfn_clGetSemaphoreHandleForTypeKHR ==
nullptr) &&
11074 (pfn_clGetSemaphoreInfoKHR ==
nullptr))
11076 detail::errHandler(CL_INVALID_VALUE, __CREATE_SEMAPHORE_KHR_WITH_PROPERTIES_ERR);
11082CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Semaphore::ext_init_;
11084inline cl_int CommandQueue::enqueueWaitSemaphores(
11085 const vector<Semaphore> &sema_objects,
11086 const vector<cl_semaphore_payload_khr> &sema_payloads,
11087 const vector<Event>* events_wait_list,
11088 Event *event)
const
11091 cl_int err = CL_INVALID_OPERATION;
11093 if (pfn_clEnqueueWaitSemaphoresKHR !=
nullptr) {
11094 err = pfn_clEnqueueWaitSemaphoresKHR(
11096 (cl_uint)sema_objects.size(),
11097 (
const cl_semaphore_khr *) &sema_objects.front(),
11098 (sema_payloads.size() > 0) ? &sema_payloads.front() : nullptr,
11099 (events_wait_list != nullptr) ? (cl_uint) events_wait_list->size() : 0,
11100 (events_wait_list != nullptr && events_wait_list->size() > 0) ? (cl_event*) &events_wait_list->front() : nullptr,
11101 (event != nullptr) ? &tmp : nullptr);
11104 detail::errHandler(err, __ENQUEUE_WAIT_SEMAPHORE_KHR_ERR);
11106 if (event !=
nullptr && err == CL_SUCCESS)
11112inline cl_int CommandQueue::enqueueSignalSemaphores(
11113 const vector<Semaphore> &sema_objects,
11114 const vector<cl_semaphore_payload_khr>& sema_payloads,
11115 const vector<Event>* events_wait_list,
11119 cl_int err = CL_INVALID_OPERATION;
11121 if (pfn_clEnqueueSignalSemaphoresKHR !=
nullptr) {
11122 err = pfn_clEnqueueSignalSemaphoresKHR(
11124 (cl_uint)sema_objects.size(),
11125 (
const cl_semaphore_khr*) &sema_objects.front(),
11126 (sema_payloads.size() > 0) ? &sema_payloads.front() : nullptr,
11127 (events_wait_list != nullptr) ? (cl_uint) events_wait_list->size() : 0,
11128 (events_wait_list != nullptr && events_wait_list->size() > 0) ? (cl_event*) &events_wait_list->front() : nullptr,
11129 (event != nullptr) ? &tmp : nullptr);
11132 detail::errHandler(err, __ENQUEUE_SIGNAL_SEMAPHORE_KHR_ERR);
11134 if (event !=
nullptr && err == CL_SUCCESS)
11142#if defined(cl_khr_command_buffer)
11146class CommandBufferKhr :
public detail::Wrapper<cl_command_buffer_khr>
11150 CommandBufferKhr() : detail::Wrapper<cl_type>() { }
11152 explicit CommandBufferKhr(
const vector<CommandQueue> &queues,
11153 cl_command_buffer_properties_khr properties = 0,
11154 cl_int* errcode_ret =
nullptr)
11156 cl_command_buffer_properties_khr command_buffer_properties[] = {
11157 CL_COMMAND_BUFFER_FLAGS_KHR, properties, 0
11161 std::call_once(ext_init_, [&] { initExtensions(queues[0].getInfo<CL_QUEUE_DEVICE>()); });
11162 cl_int error = CL_INVALID_OPERATION;
11165 "Size of cl::CommandQueue must be equal to size of cl_command_queue");
11167 if (pfn_clCreateCommandBufferKHR)
11169 object_ = pfn_clCreateCommandBufferKHR((cl_uint) queues.size(),
11170 (cl_command_queue *) &queues.front(),
11171 command_buffer_properties,
11175 detail::errHandler(error, __CREATE_COMMAND_BUFFER_KHR_ERR);
11176 if (errcode_ret !=
nullptr) {
11177 *errcode_ret = error;
11181 explicit CommandBufferKhr(
const cl_command_buffer_khr& commandBufferKhr,
bool retainObject =
false) :
11182 detail::Wrapper<cl_type>(commandBufferKhr, retainObject) { }
11184 CommandBufferKhr& operator=(
const cl_command_buffer_khr& rhs)
11186 detail::Wrapper<cl_type>::operator=(rhs);
11190 template <
typename T>
11191 cl_int getInfo(cl_command_buffer_info_khr name, T* param)
const
11193 if (pfn_clGetCommandBufferInfoKHR ==
nullptr) {
11194 return detail::errHandler(CL_INVALID_OPERATION,
11195 __GET_COMMAND_BUFFER_INFO_KHR_ERR);
11197 return detail::errHandler(
11198 detail::getInfo(pfn_clGetCommandBufferInfoKHR, object_, name, param),
11199 __GET_COMMAND_BUFFER_INFO_KHR_ERR);
11202 template <cl_command_buffer_info_khr name>
typename
11203 detail::param_traits<detail::cl_command_buffer_info_khr, name>::param_type
11204 getInfo(cl_int* err =
nullptr)
const
11206 typename detail::param_traits<
11207 detail::cl_command_buffer_info_khr, name>::param_type param;
11208 cl_int result = getInfo(name, ¶m);
11209 if (err !=
nullptr) {
11215 cl_int finalizeCommandBuffer()
const
11217 return detail::errHandler(::clFinalizeCommandBufferKHR(object_), __FINALIZE_COMMAND_BUFFER_KHR_ERR);
11220 cl_int enqueueCommandBuffer(vector<CommandQueue> &queues,
11221 const vector<Event>* events =
nullptr,
11222 Event* event =
nullptr)
11224 if (pfn_clEnqueueCommandBufferKHR ==
nullptr) {
11225 return detail::errHandler(CL_INVALID_OPERATION,
11226 __ENQUEUE_COMMAND_BUFFER_KHR_ERR);
11230 "Size of cl::CommandQueue must be equal to size of cl_command_queue");
11232 return detail::errHandler(pfn_clEnqueueCommandBufferKHR((cl_uint) queues.size(),
11233 (cl_command_queue *) &queues.front(),
11235 (events !=
nullptr) ? (cl_uint) events->size() : 0,
11236 (events != nullptr && events->size() > 0) ? (cl_event*) &events->front() : nullptr,
11237 (cl_event*) event),
11238 __ENQUEUE_COMMAND_BUFFER_KHR_ERR);
11241 cl_int commandBarrierWithWaitList(
const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11242 cl_sync_point_khr* sync_point =
nullptr,
11243 MutableCommandKhr* mutable_handle =
nullptr,
11244 const CommandQueue* command_queue =
nullptr)
11246 if (pfn_clCommandBarrierWithWaitListKHR ==
nullptr) {
11247 return detail::errHandler(CL_INVALID_OPERATION,
11248 __COMMAND_BARRIER_WITH_WAIT_LIST_KHR_ERR);
11251 cl_sync_point_khr tmp_sync_point;
11252 cl_int error = detail::errHandler(
11253 pfn_clCommandBarrierWithWaitListKHR(object_,
11254 (command_queue !=
nullptr) ? (*command_queue)() : nullptr,
11255 (sync_points_vec != nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11256 (sync_points_vec != nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() : nullptr,
11257 (sync_point != nullptr) ? &tmp_sync_point : nullptr,
11258 (cl_mutable_command_khr*) mutable_handle),
11259 __COMMAND_BARRIER_WITH_WAIT_LIST_KHR_ERR);
11261 if (sync_point !=
nullptr && error == CL_SUCCESS)
11262 *sync_point = tmp_sync_point;
11267 cl_int commandCopyBuffer(
const Buffer& src,
11269 size_type src_offset,
11270 size_type dst_offset,
11272 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11273 cl_sync_point_khr* sync_point =
nullptr,
11274 MutableCommandKhr* mutable_handle =
nullptr,
11275 const CommandQueue* command_queue =
nullptr)
11277 if (pfn_clCommandCopyBufferKHR ==
nullptr) {
11278 return detail::errHandler(CL_INVALID_OPERATION,
11279 __COMMAND_COPY_BUFFER_KHR_ERR);
11282 cl_sync_point_khr tmp_sync_point;
11283 cl_int error = detail::errHandler(
11284 pfn_clCommandCopyBufferKHR(object_,
11285 (command_queue !=
nullptr) ? (*command_queue)() : nullptr,
11291 (sync_points_vec != nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11292 (sync_points_vec != nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() : nullptr,
11293 (sync_point != nullptr) ? &tmp_sync_point : nullptr,
11294 (cl_mutable_command_khr*) mutable_handle),
11295 __COMMAND_COPY_BUFFER_KHR_ERR);
11297 if (sync_point !=
nullptr && error == CL_SUCCESS)
11298 *sync_point = tmp_sync_point;
11303 cl_int commandCopyBufferRect(
const Buffer& src,
11305 const array<size_type, 3>& src_origin,
11306 const array<size_type, 3>& dst_origin,
11307 const array<size_type, 3>& region,
11308 size_type src_row_pitch,
11309 size_type src_slice_pitch,
11310 size_type dst_row_pitch,
11311 size_type dst_slice_pitch,
11312 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11313 cl_sync_point_khr* sync_point =
nullptr,
11314 MutableCommandKhr* mutable_handle =
nullptr,
11315 const CommandQueue* command_queue =
nullptr)
11317 if (pfn_clCommandCopyBufferRectKHR ==
nullptr) {
11318 return detail::errHandler(CL_INVALID_OPERATION,
11319 __COMMAND_COPY_BUFFER_RECT_KHR_ERR);
11322 cl_sync_point_khr tmp_sync_point;
11323 cl_int error = detail::errHandler(
11324 pfn_clCommandCopyBufferRectKHR(object_,
11325 (command_queue !=
nullptr) ? (*command_queue)() : nullptr,
11335 (sync_points_vec != nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11336 (sync_points_vec != nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() : nullptr,
11337 (sync_point != nullptr) ? &tmp_sync_point : nullptr,
11338 (cl_mutable_command_khr*) mutable_handle),
11339 __COMMAND_COPY_BUFFER_RECT_KHR_ERR);
11341 if (sync_point !=
nullptr && error == CL_SUCCESS)
11342 *sync_point = tmp_sync_point;
11347 cl_int commandCopyBufferToImage(
const Buffer& src,
11349 size_type src_offset,
11350 const array<size_type, 3>& dst_origin,
11351 const array<size_type, 3>& region,
11352 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11353 cl_sync_point_khr* sync_point =
nullptr,
11354 MutableCommandKhr* mutable_handle =
nullptr,
11355 const CommandQueue* command_queue =
nullptr)
11357 if (pfn_clCommandCopyBufferToImageKHR ==
nullptr) {
11358 return detail::errHandler(CL_INVALID_OPERATION,
11359 __COMMAND_COPY_BUFFER_TO_IMAGE_KHR_ERR);
11362 cl_sync_point_khr tmp_sync_point;
11363 cl_int error = detail::errHandler(
11364 pfn_clCommandCopyBufferToImageKHR(object_,
11365 (command_queue !=
nullptr) ? (*command_queue)() : nullptr,
11371 (sync_points_vec != nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11372 (sync_points_vec != nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() : nullptr,
11373 (sync_point != nullptr) ? &tmp_sync_point : nullptr,
11374 (cl_mutable_command_khr*) mutable_handle),
11375 __COMMAND_COPY_BUFFER_TO_IMAGE_KHR_ERR);
11377 if (sync_point !=
nullptr && error == CL_SUCCESS)
11378 *sync_point = tmp_sync_point;
11383 cl_int commandCopyImage(
const Image& src,
11385 const array<size_type, 3>& src_origin,
11386 const array<size_type, 3>& dst_origin,
11387 const array<size_type, 3>& region,
11388 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11389 cl_sync_point_khr* sync_point =
nullptr,
11390 MutableCommandKhr* mutable_handle =
nullptr,
11391 const CommandQueue* command_queue =
nullptr)
11393 if (pfn_clCommandCopyImageKHR ==
nullptr) {
11394 return detail::errHandler(CL_INVALID_OPERATION,
11395 __COMMAND_COPY_IMAGE_KHR_ERR);
11398 cl_sync_point_khr tmp_sync_point;
11399 cl_int error = detail::errHandler(
11400 pfn_clCommandCopyImageKHR(object_,
11401 (command_queue !=
nullptr) ? (*command_queue)() : nullptr,
11407 (sync_points_vec != nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11408 (sync_points_vec != nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() : nullptr,
11409 (sync_point != nullptr) ? &tmp_sync_point : nullptr,
11410 (cl_mutable_command_khr*) mutable_handle),
11411 __COMMAND_COPY_IMAGE_KHR_ERR);
11413 if (sync_point !=
nullptr && error == CL_SUCCESS)
11414 *sync_point = tmp_sync_point;
11419 cl_int commandCopyImageToBuffer(
const Image& src,
11421 const array<size_type, 3>& src_origin,
11422 const array<size_type, 3>& region,
11423 size_type dst_offset,
11424 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11425 cl_sync_point_khr* sync_point =
nullptr,
11426 MutableCommandKhr* mutable_handle =
nullptr,
11427 const CommandQueue* command_queue =
nullptr)
11429 if (pfn_clCommandCopyImageToBufferKHR ==
nullptr) {
11430 return detail::errHandler(CL_INVALID_OPERATION,
11431 __COMMAND_COPY_IMAGE_TO_BUFFER_KHR_ERR);
11434 cl_sync_point_khr tmp_sync_point;
11435 cl_int error = detail::errHandler(
11436 pfn_clCommandCopyImageToBufferKHR(object_,
11437 (command_queue !=
nullptr) ? (*command_queue)() : nullptr,
11443 (sync_points_vec != nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11444 (sync_points_vec != nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() : nullptr,
11445 (sync_point != nullptr) ? &tmp_sync_point : nullptr,
11446 (cl_mutable_command_khr*) mutable_handle),
11447 __COMMAND_COPY_IMAGE_TO_BUFFER_KHR_ERR);
11449 if (sync_point !=
nullptr && error == CL_SUCCESS)
11450 *sync_point = tmp_sync_point;
11455 template<
typename PatternType>
11456 cl_int commandFillBuffer(
const Buffer& buffer,
11457 PatternType pattern,
11460 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11461 cl_sync_point_khr* sync_point =
nullptr,
11462 MutableCommandKhr* mutable_handle =
nullptr,
11463 const CommandQueue* command_queue =
nullptr)
11465 if (pfn_clCommandFillBufferKHR ==
nullptr) {
11466 return detail::errHandler(CL_INVALID_OPERATION,
11467 __COMMAND_FILL_BUFFER_KHR_ERR);
11470 cl_sync_point_khr tmp_sync_point;
11471 cl_int error = detail::errHandler(
11472 pfn_clCommandFillBufferKHR(object_,
11473 (command_queue !=
nullptr) ? (*command_queue)() : nullptr,
11475 static_cast<void*>(&pattern),
11476 sizeof(PatternType),
11479 (sync_points_vec != nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11480 (sync_points_vec != nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() : nullptr,
11481 (sync_point != nullptr) ? &tmp_sync_point : nullptr,
11482 (cl_mutable_command_khr*) mutable_handle),
11483 __COMMAND_FILL_BUFFER_KHR_ERR);
11485 if (sync_point !=
nullptr && error == CL_SUCCESS)
11486 *sync_point = tmp_sync_point;
11491 cl_int commandFillImage(
const Image& image,
11492 cl_float4 fillColor,
11493 const array<size_type, 3>& origin,
11494 const array<size_type, 3>& region,
11495 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11496 cl_sync_point_khr* sync_point =
nullptr,
11497 MutableCommandKhr* mutable_handle =
nullptr,
11498 const CommandQueue* command_queue =
nullptr)
11500 if (pfn_clCommandFillImageKHR ==
nullptr) {
11501 return detail::errHandler(CL_INVALID_OPERATION,
11502 __COMMAND_FILL_IMAGE_KHR_ERR);
11505 cl_sync_point_khr tmp_sync_point;
11506 cl_int error = detail::errHandler(
11507 pfn_clCommandFillImageKHR(object_,
11508 (command_queue !=
nullptr) ? (*command_queue)() : nullptr,
11510 static_cast<void*>(&fillColor),
11513 (sync_points_vec != nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11514 (sync_points_vec != nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() : nullptr,
11515 (sync_point != nullptr) ? &tmp_sync_point : nullptr,
11516 (cl_mutable_command_khr*) mutable_handle),
11517 __COMMAND_FILL_IMAGE_KHR_ERR);
11519 if (sync_point !=
nullptr && error == CL_SUCCESS)
11520 *sync_point = tmp_sync_point;
11525 cl_int commandNDRangeKernel(
const cl::vector<cl_ndrange_kernel_command_properties_khr> &properties,
11526 const Kernel& kernel,
11527 const NDRange& offset,
11528 const NDRange& global,
11529 const NDRange& local = NullRange,
11530 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11531 cl_sync_point_khr* sync_point =
nullptr,
11532 MutableCommandKhr* mutable_handle =
nullptr,
11533 const CommandQueue* command_queue =
nullptr)
11535 if (pfn_clCommandNDRangeKernelKHR ==
nullptr) {
11536 return detail::errHandler(CL_INVALID_OPERATION,
11537 __COMMAND_NDRANGE_KERNEL_KHR_ERR);
11540 cl_sync_point_khr tmp_sync_point;
11541 cl_int error = detail::errHandler(
11542 pfn_clCommandNDRangeKernelKHR(object_,
11543 (command_queue !=
nullptr) ? (*command_queue)() : nullptr,
11546 (cl_uint) global.dimensions(),
11547 offset.dimensions() != 0 ? (const size_type*) offset : nullptr,
11548 (const size_type*) global,
11549 local.dimensions() != 0 ? (const size_type*) local : nullptr,
11550 (sync_points_vec != nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11551 (sync_points_vec != nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() : nullptr,
11552 (sync_point != nullptr) ? &tmp_sync_point : nullptr,
11553 (cl_mutable_command_khr*) mutable_handle),
11554 __COMMAND_NDRANGE_KERNEL_KHR_ERR);
11556 if (sync_point !=
nullptr && error == CL_SUCCESS)
11557 *sync_point = tmp_sync_point;
11562#if defined(cl_khr_command_buffer_mutable_dispatch)
11563 cl_int updateMutableCommands(
const cl_mutable_base_config_khr* mutable_config)
11565 if (pfn_clUpdateMutableCommandsKHR ==
nullptr) {
11566 return detail::errHandler(CL_INVALID_OPERATION,
11567 __UPDATE_MUTABLE_COMMANDS_KHR_ERR);
11569 return detail::errHandler(pfn_clUpdateMutableCommandsKHR(object_, mutable_config),
11570 __UPDATE_MUTABLE_COMMANDS_KHR_ERR);
11575 static std::once_flag ext_init_;
11577 static void initExtensions(
const cl::Device& device)
11579#if CL_HPP_TARGET_OPENCL_VERSION >= 120
11580 cl_platform_id platform = device.
getInfo<CL_DEVICE_PLATFORM>()();
11581 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCreateCommandBufferKHR);
11582 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clFinalizeCommandBufferKHR);
11583 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clRetainCommandBufferKHR);
11584 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clReleaseCommandBufferKHR);
11585 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clGetCommandBufferInfoKHR);
11586 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueCommandBufferKHR);
11587 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandBarrierWithWaitListKHR);
11588 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandCopyBufferKHR);
11589 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandCopyBufferRectKHR);
11590 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandCopyBufferToImageKHR);
11591 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandCopyImageKHR);
11592 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandCopyImageToBufferKHR);
11593 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandFillBufferKHR);
11594 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandFillImageKHR);
11595 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandNDRangeKernelKHR);
11596#if defined(cl_khr_command_buffer_mutable_dispatch)
11597 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clUpdateMutableCommandsKHR);
11598 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clGetMutableCommandInfoKHR);
11600#elif CL_HPP_TARGET_OPENCL_VERSION >= 110
11601 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateCommandBufferKHR);
11602 CL_HPP_INIT_CL_EXT_FCN_PTR_(clFinalizeCommandBufferKHR);
11603 CL_HPP_INIT_CL_EXT_FCN_PTR_(clRetainCommandBufferKHR);
11604 CL_HPP_INIT_CL_EXT_FCN_PTR_(clReleaseCommandBufferKHR);
11605 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetCommandBufferInfoKHR);
11606 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueCommandBufferKHR);
11607 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandBarrierWithWaitListKHR);
11608 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandCopyBufferKHR);
11609 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandCopyBufferRectKHR);
11610 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandCopyBufferToImageKHR);
11611 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandCopyImageKHR);
11612 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandCopyImageToBufferKHR);
11613 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandFillBufferKHR);
11614 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandFillImageKHR);
11615 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandNDRangeKernelKHR);
11616#if defined(cl_khr_command_buffer_mutable_dispatch)
11617 CL_HPP_INIT_CL_EXT_FCN_PTR_(clUpdateMutableCommandsKHR);
11618 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetMutableCommandInfoKHR);
11621 if ((pfn_clCreateCommandBufferKHR ==
nullptr) &&
11622 (pfn_clFinalizeCommandBufferKHR ==
nullptr) &&
11623 (pfn_clRetainCommandBufferKHR ==
nullptr) &&
11624 (pfn_clReleaseCommandBufferKHR ==
nullptr) &&
11625 (pfn_clGetCommandBufferInfoKHR ==
nullptr) &&
11626 (pfn_clEnqueueCommandBufferKHR ==
nullptr) &&
11627 (pfn_clCommandBarrierWithWaitListKHR ==
nullptr) &&
11628 (pfn_clCommandCopyBufferKHR ==
nullptr) &&
11629 (pfn_clCommandCopyBufferRectKHR ==
nullptr) &&
11630 (pfn_clCommandCopyBufferToImageKHR ==
nullptr) &&
11631 (pfn_clCommandCopyImageKHR ==
nullptr) &&
11632 (pfn_clCommandCopyImageToBufferKHR ==
nullptr) &&
11633 (pfn_clCommandFillBufferKHR ==
nullptr) &&
11634 (pfn_clCommandFillImageKHR ==
nullptr) &&
11635 (pfn_clCommandNDRangeKernelKHR ==
nullptr)
11636#
if defined(cl_khr_command_buffer_mutable_dispatch)
11637 && (pfn_clUpdateMutableCommandsKHR ==
nullptr)
11638 && (pfn_clGetMutableCommandInfoKHR ==
nullptr)
11642 detail::errHandler(CL_INVALID_VALUE, __CREATE_COMMAND_BUFFER_KHR_ERR);
11647CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag CommandBufferKhr::ext_init_;
11649#if defined(cl_khr_command_buffer_mutable_dispatch)
11653class MutableCommandKhr :
public detail::Wrapper<cl_mutable_command_khr>
11657 MutableCommandKhr() : detail::Wrapper<cl_type>() { }
11659 explicit MutableCommandKhr(
const cl_mutable_command_khr& mutableCommandKhr,
bool retainObject =
false) :
11660 detail::Wrapper<cl_type>(mutableCommandKhr, retainObject) { }
11662 MutableCommandKhr& operator=(
const cl_mutable_command_khr& rhs)
11664 detail::Wrapper<cl_type>::operator=(rhs);
11668 template <
typename T>
11669 cl_int getInfo(cl_mutable_command_info_khr name, T* param)
const
11671 if (pfn_clGetMutableCommandInfoKHR ==
nullptr) {
11672 return detail::errHandler(CL_INVALID_OPERATION,
11673 __GET_MUTABLE_COMMAND_INFO_KHR_ERR);
11675 return detail::errHandler(
11676 detail::getInfo(pfn_clGetMutableCommandInfoKHR, object_, name, param),
11677 __GET_MUTABLE_COMMAND_INFO_KHR_ERR);
11680 template <cl_mutable_command_info_khr name>
typename
11681 detail::param_traits<detail::cl_mutable_command_info_khr, name>::param_type
11682 getInfo(cl_int* err =
nullptr)
const
11684 typename detail::param_traits<
11685 detail::cl_mutable_command_info_khr, name>::param_type param;
11686 cl_int result = getInfo(name, ¶m);
11687 if (err !=
nullptr) {
11698#undef CL_HPP_ERR_STR_
11699#if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS)
11700#undef __GET_DEVICE_INFO_ERR
11701#undef __GET_PLATFORM_INFO_ERR
11702#undef __GET_DEVICE_IDS_ERR
11703#undef __GET_PLATFORM_IDS_ERR
11704#undef __GET_CONTEXT_INFO_ERR
11705#undef __GET_EVENT_INFO_ERR
11706#undef __GET_EVENT_PROFILE_INFO_ERR
11707#undef __GET_MEM_OBJECT_INFO_ERR
11708#undef __GET_IMAGE_INFO_ERR
11709#undef __GET_SAMPLER_INFO_ERR
11710#undef __GET_KERNEL_INFO_ERR
11711#undef __GET_KERNEL_ARG_INFO_ERR
11712#undef __GET_KERNEL_SUB_GROUP_INFO_ERR
11713#undef __GET_KERNEL_WORK_GROUP_INFO_ERR
11714#undef __GET_PROGRAM_INFO_ERR
11715#undef __GET_PROGRAM_BUILD_INFO_ERR
11716#undef __GET_COMMAND_QUEUE_INFO_ERR
11717#undef __CREATE_CONTEXT_ERR
11718#undef __CREATE_CONTEXT_FROM_TYPE_ERR
11719#undef __CREATE_COMMAND_BUFFER_KHR_ERR
11720#undef __GET_COMMAND_BUFFER_INFO_KHR_ERR
11721#undef __FINALIZE_COMMAND_BUFFER_KHR_ERR
11722#undef __ENQUEUE_COMMAND_BUFFER_KHR_ERR
11723#undef __COMMAND_BARRIER_WITH_WAIT_LIST_KHR_ERR
11724#undef __COMMAND_COPY_BUFFER_KHR_ERR
11725#undef __COMMAND_COPY_BUFFER_RECT_KHR_ERR
11726#undef __COMMAND_COPY_BUFFER_TO_IMAGE_KHR_ERR
11727#undef __COMMAND_COPY_IMAGE_KHR_ERR
11728#undef __COMMAND_COPY_IMAGE_TO_BUFFER_KHR_ERR
11729#undef __COMMAND_FILL_BUFFER_KHR_ERR
11730#undef __COMMAND_FILL_IMAGE_KHR_ERR
11731#undef __COMMAND_NDRANGE_KERNEL_KHR_ERR
11732#undef __UPDATE_MUTABLE_COMMANDS_KHR_ERR
11733#undef __GET_MUTABLE_COMMAND_INFO_KHR_ERR
11734#undef __RETAIN_COMMAND_BUFFER_KHR_ERR
11735#undef __RELEASE_COMMAND_BUFFER_KHR_ERR
11736#undef __GET_SUPPORTED_IMAGE_FORMATS_ERR
11737#undef __SET_CONTEXT_DESCTRUCTOR_CALLBACK_ERR
11738#undef __CREATE_BUFFER_ERR
11740#undef __CREATE_SUBBUFFER_ERR
11741#undef __CREATE_GL_BUFFER_ERR
11742#undef __CREATE_GL_RENDER_BUFFER_ERR
11743#undef __GET_GL_OBJECT_INFO_ERR
11744#undef __CREATE_IMAGE_ERR
11745#undef __CREATE_GL_TEXTURE_ERR
11746#undef __IMAGE_DIMENSION_ERR
11747#undef __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR
11748#undef __CREATE_USER_EVENT_ERR
11749#undef __SET_USER_EVENT_STATUS_ERR
11750#undef __SET_EVENT_CALLBACK_ERR
11751#undef __WAIT_FOR_EVENTS_ERR
11752#undef __CREATE_KERNEL_ERR
11753#undef __SET_KERNEL_ARGS_ERR
11754#undef __CREATE_PROGRAM_WITH_SOURCE_ERR
11755#undef __CREATE_PROGRAM_WITH_BINARY_ERR
11756#undef __CREATE_PROGRAM_WITH_IL_ERR
11757#undef __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR
11758#undef __BUILD_PROGRAM_ERR
11759#undef __COMPILE_PROGRAM_ERR
11760#undef __LINK_PROGRAM_ERR
11761#undef __CREATE_KERNELS_IN_PROGRAM_ERR
11762#undef __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR
11763#undef __CREATE_SAMPLER_WITH_PROPERTIES_ERR
11764#undef __SET_COMMAND_QUEUE_PROPERTY_ERR
11765#undef __ENQUEUE_READ_BUFFER_ERR
11766#undef __ENQUEUE_READ_BUFFER_RECT_ERR
11767#undef __ENQUEUE_WRITE_BUFFER_ERR
11768#undef __ENQUEUE_WRITE_BUFFER_RECT_ERR
11769#undef __ENQEUE_COPY_BUFFER_ERR
11770#undef __ENQEUE_COPY_BUFFER_RECT_ERR
11771#undef __ENQUEUE_FILL_BUFFER_ERR
11772#undef __ENQUEUE_READ_IMAGE_ERR
11773#undef __ENQUEUE_WRITE_IMAGE_ERR
11774#undef __ENQUEUE_COPY_IMAGE_ERR
11775#undef __ENQUEUE_FILL_IMAGE_ERR
11776#undef __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR
11777#undef __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR
11778#undef __ENQUEUE_MAP_BUFFER_ERR
11779#undef __ENQUEUE_MAP_IMAGE_ERR
11780#undef __ENQUEUE_MAP_SVM_ERR
11781#undef __ENQUEUE_FILL_SVM_ERR
11782#undef __ENQUEUE_COPY_SVM_ERR
11783#undef __ENQUEUE_UNMAP_SVM_ERR
11784#undef __ENQUEUE_MAP_IMAGE_ERR
11785#undef __ENQUEUE_UNMAP_MEM_OBJECT_ERR
11786#undef __ENQUEUE_NDRANGE_KERNEL_ERR
11787#undef __ENQUEUE_NATIVE_KERNEL
11788#undef __ENQUEUE_MIGRATE_MEM_OBJECTS_ERR
11789#undef __ENQUEUE_MIGRATE_SVM_ERR
11790#undef __ENQUEUE_ACQUIRE_GL_ERR
11791#undef __ENQUEUE_RELEASE_GL_ERR
11792#undef __CREATE_PIPE_ERR
11793#undef __GET_PIPE_INFO_ERR
11795#undef __RELEASE_ERR
11798#undef __VECTOR_CAPACITY_ERR
11799#undef __CREATE_SUB_DEVICES_ERR
11800#undef __ENQUEUE_ACQUIRE_EXTERNAL_MEMORY_ERR
11801#undef __ENQUEUE_RELEASE_EXTERNAL_MEMORY_ERR
11802#undef __ENQUEUE_MARKER_ERR
11803#undef __ENQUEUE_WAIT_FOR_EVENTS_ERR
11804#undef __ENQUEUE_BARRIER_ERR
11805#undef __UNLOAD_COMPILER_ERR
11806#undef __CREATE_GL_TEXTURE_2D_ERR
11807#undef __CREATE_GL_TEXTURE_3D_ERR
11808#undef __CREATE_IMAGE2D_ERR
11809#undef __CREATE_IMAGE3D_ERR
11810#undef __CREATE_COMMAND_QUEUE_ERR
11811#undef __ENQUEUE_TASK_ERR
11812#undef __CREATE_SAMPLER_ERR
11813#undef __ENQUEUE_MARKER_WAIT_LIST_ERR
11814#undef __ENQUEUE_BARRIER_WAIT_LIST_ERR
11815#undef __CLONE_KERNEL_ERR
11816#undef __GET_HOST_TIMER_ERR
11817#undef __GET_DEVICE_AND_HOST_TIMER_ERR
11818#undef __GET_SEMAPHORE_KHR_INFO_ERR
11819#undef __CREATE_SEMAPHORE_KHR_WITH_PROPERTIES_ERR
11820#undef __GET_IMAGE_REQUIREMENT_INFO_EXT_ERR
11821#undef __ENQUEUE_WAIT_SEMAPHORE_KHR_ERR
11822#undef __ENQUEUE_SIGNAL_SEMAPHORE_KHR_ERR
11823#undef __RETAIN_SEMAPHORE_KHR_ERR
11824#undef __RELEASE_SEMAPHORE_KHR_ERR
11825#undef __GET_SEMAPHORE_HANDLE_FOR_TYPE_KHR_ERR
11830#undef CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_
11831#undef CL_HPP_INIT_CL_EXT_FCN_PTR_
11832#undef CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_
11834#undef CL_HPP_DEFINE_STATIC_MEMBER_
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().
Class interface for Buffer Memory Objects.
Buffer()
Default constructor - initializes to nullptr.
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 & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
cl_int getObjectInfo(cl_gl_object_type *type, cl_GLuint *gl_object_name)
Wrapper for clGetGLObjectInfo().
BufferRenderGL()
Default constructor - initializes to nullptr.
BufferRenderGL & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
CommandQueue interface for cl_command_queue.
cl_int enqueueUnmapSVM(T *ptr, const vector< Event > *events=nullptr, Event *event=nullptr) const
cl_int enqueueMemcpySVM(T *dst_ptr, const T *src_ptr, cl_bool blocking, size_type size, const vector< Event > *events=nullptr, Event *event=nullptr) const
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
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
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 enqueueMemFillSVM(T *ptr, PatternType pattern, size_type size, 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
Class interface for cl_context.
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)
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()
Default constructor - initializes to nullptr.
cl_int getInfo(cl_context_info name, T *param) const
Wrapper for clGetContextInfo().
DeviceCommandQueue interface for device cl_command_queues.
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(cl_int *err=nullptr)
Class interface for cl_device_id.
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)
Class interface for cl_event.
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.
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.
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.
Image interface for 1D buffer images.
Image1D()
Default constructor - initializes to nullptr.
Image1D & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
Image interface for arrays of 2D images.
Class interface for GL 2D Image Memory objects.
Class interface for 2D Image Memory objects.
Image2D()
Default constructor - initializes to nullptr.
Image2D & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
Image3DGL()
Default constructor - initializes to nullptr.
Image3DGL & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
Class interface for 3D Image Memory objects.
Image3D & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
Image3D()
Default constructor - initializes to nullptr.
C++ base class for Image Memory objects.
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.
cl_int setSVMPointers(const vector< void * > &pointerList)
cl_int setArg(cl_uint index, const cl::pointer< T, D > &argPtr)
setArg overload taking a shared_ptr type
Kernel()
Default constructor - initializes to nullptr.
Kernel & operator=(const cl_kernel &rhs)
Assignment operator from cl_kernel - takes ownership.
cl_int enableFineGrainedSystemSVM(bool svmEnabled)
Enable fine-grained system SVM.
Class interface for cl_mem.
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.
Class interface for specifying NDRange values.
size_type dimensions() const
Queries the number of dimensions in the range.
size_type size() const
Returns the size of the object in bytes based on the.
NDRange()
Default constructor - resulting range has zero dimensions.
Pipe()
Default constructor - initializes to nullptr.
cl_int getInfo(cl_pipe_info name, T *param) const
Wrapper for clGetMemObjectInfo().
Pipe & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
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...
std::enable_if<!std::is_pointer< T >::value, cl_int >::type setSpecializationConstant(cl_uint index, const T &value)
Sets a SPIR-V specialization constant.
bool operator==(SVMAllocator const &rhs)
pointer allocate(size_type size, typename cl::SVMAllocator< void, SVMTrait >::const_pointer=0, bool map=true)
size_type max_size() const noexcept
Class interface for cl_sampler.
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().
UserEvent()
Default constructor - initializes to nullptr.
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(IteratorType startIterator, IteratorType endIterator, cl::Buffer &buffer)
vector< T, cl::SVMAllocator< int, cl::SVMTraitCoarse<> > > coarse_svm_vector
Vector alias to simplify contruction of coarse-grained SVM containers.
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
vector< T, cl::SVMAllocator< int, cl::SVMTraitFine<> > > fine_svm_vector
Vector alias to simplify contruction of fine-grained SVM containers.
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::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)
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)
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.