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) {
1151template <
typename Func,
typename T>
1152inline cl_int getInfoHelper(Func f, cl_uint name, vector<T>* param,
long)
1155 cl_int err = f(name, 0,
nullptr, &required);
1156 if (err != CL_SUCCESS) {
1159 const size_type elements = required /
sizeof(T);
1162 vector<T> localData(elements);
1163 err = f(name, required, localData.data(),
nullptr);
1164 if (err != CL_SUCCESS) {
1168 *param = std::move(localData);
1180template <
typename Func,
typename T>
1181inline cl_int getInfoHelper(
1182 Func f, cl_uint name, vector<T>* param,
int,
typename T::cl_type = 0)
1185 cl_int err = f(name, 0,
nullptr, &required);
1186 if (err != CL_SUCCESS) {
1190 const size_type elements = required /
sizeof(
typename T::cl_type);
1192 vector<typename T::cl_type> value(elements);
1193 err = f(name, required, value.data(),
nullptr);
1194 if (err != CL_SUCCESS) {
1200 param->resize(elements);
1204 for (size_type i = 0; i < elements; i++) {
1205 (*param)[i] = T(value[i],
true);
1212template <
typename Func>
1213inline cl_int getInfoHelper(Func f, cl_uint name,
string* param,
long)
1216 cl_int err = f(name, 0,
nullptr, &required);
1217 if (err != CL_SUCCESS) {
1224 vector<char> value(required);
1225 err = f(name, required, value.data(),
nullptr);
1226 if (err != CL_SUCCESS) {
1230 param->assign(value.begin(), value.end() - 1);
1240template <
typename Func,
size_type N>
1241inline cl_int getInfoHelper(Func f, cl_uint name, array<size_type, N>* param,
long)
1244 cl_int err = f(name, 0,
nullptr, &required);
1245 if (err != CL_SUCCESS) {
1249 size_type elements = required /
sizeof(size_type);
1250 vector<size_type> value(elements, 0);
1252 err = f(name, required, value.data(),
nullptr);
1253 if (err != CL_SUCCESS) {
1262 for (size_type i = 0; i < elements; ++i) {
1263 (*param)[i] = value[i];
1269template<
typename T>
struct ReferenceHandler;
1277template<
typename Func,
typename T>
1278inline cl_int getInfoHelper(Func f, cl_uint name, T* param,
int,
typename T::cl_type = 0)
1280 typename T::cl_type value;
1281 cl_int err = f(name,
sizeof(value), &value,
nullptr);
1282 if (err != CL_SUCCESS) {
1286 if (value !=
nullptr)
1288 err = param->retain();
1289 if (err != CL_SUCCESS) {
1296#define CL_HPP_PARAM_NAME_INFO_1_0_(F) \
1297 F(cl_platform_info, CL_PLATFORM_PROFILE, string) \
1298 F(cl_platform_info, CL_PLATFORM_VERSION, string) \
1299 F(cl_platform_info, CL_PLATFORM_NAME, string) \
1300 F(cl_platform_info, CL_PLATFORM_VENDOR, string) \
1301 F(cl_platform_info, CL_PLATFORM_EXTENSIONS, string) \
1303 F(cl_device_info, CL_DEVICE_TYPE, cl_device_type) \
1304 F(cl_device_info, CL_DEVICE_VENDOR_ID, cl_uint) \
1305 F(cl_device_info, CL_DEVICE_MAX_COMPUTE_UNITS, cl_uint) \
1306 F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, cl_uint) \
1307 F(cl_device_info, CL_DEVICE_MAX_WORK_GROUP_SIZE, size_type) \
1308 F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_SIZES, cl::vector<size_type>) \
1309 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, cl_uint) \
1310 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT, cl_uint) \
1311 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT, cl_uint) \
1312 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG, cl_uint) \
1313 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT, cl_uint) \
1314 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, cl_uint) \
1315 F(cl_device_info, CL_DEVICE_MAX_CLOCK_FREQUENCY, cl_uint) \
1316 F(cl_device_info, CL_DEVICE_ADDRESS_BITS, cl_uint) \
1317 F(cl_device_info, CL_DEVICE_MAX_READ_IMAGE_ARGS, cl_uint) \
1318 F(cl_device_info, CL_DEVICE_MAX_WRITE_IMAGE_ARGS, cl_uint) \
1319 F(cl_device_info, CL_DEVICE_MAX_MEM_ALLOC_SIZE, cl_ulong) \
1320 F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_WIDTH, size_type) \
1321 F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_HEIGHT, size_type) \
1322 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_WIDTH, size_type) \
1323 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_HEIGHT, size_type) \
1324 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_DEPTH, size_type) \
1325 F(cl_device_info, CL_DEVICE_IMAGE_SUPPORT, cl_bool) \
1326 F(cl_device_info, CL_DEVICE_MAX_PARAMETER_SIZE, size_type) \
1327 F(cl_device_info, CL_DEVICE_MAX_SAMPLERS, cl_uint) \
1328 F(cl_device_info, CL_DEVICE_MEM_BASE_ADDR_ALIGN, cl_uint) \
1329 F(cl_device_info, CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE, cl_uint) \
1330 F(cl_device_info, CL_DEVICE_SINGLE_FP_CONFIG, cl_device_fp_config) \
1331 F(cl_device_info, CL_DEVICE_DOUBLE_FP_CONFIG, cl_device_fp_config) \
1332 F(cl_device_info, CL_DEVICE_HALF_FP_CONFIG, cl_device_fp_config) \
1333 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_TYPE, cl_device_mem_cache_type) \
1334 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE, cl_uint)\
1335 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_SIZE, cl_ulong) \
1336 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_SIZE, cl_ulong) \
1337 F(cl_device_info, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE, cl_ulong) \
1338 F(cl_device_info, CL_DEVICE_MAX_CONSTANT_ARGS, cl_uint) \
1339 F(cl_device_info, CL_DEVICE_LOCAL_MEM_TYPE, cl_device_local_mem_type) \
1340 F(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE, cl_ulong) \
1341 F(cl_device_info, CL_DEVICE_ERROR_CORRECTION_SUPPORT, cl_bool) \
1342 F(cl_device_info, CL_DEVICE_PROFILING_TIMER_RESOLUTION, size_type) \
1343 F(cl_device_info, CL_DEVICE_ENDIAN_LITTLE, cl_bool) \
1344 F(cl_device_info, CL_DEVICE_AVAILABLE, cl_bool) \
1345 F(cl_device_info, CL_DEVICE_COMPILER_AVAILABLE, cl_bool) \
1346 F(cl_device_info, CL_DEVICE_EXECUTION_CAPABILITIES, cl_device_exec_capabilities) \
1347 F(cl_device_info, CL_DEVICE_PLATFORM, cl::Platform) \
1348 F(cl_device_info, CL_DEVICE_NAME, string) \
1349 F(cl_device_info, CL_DEVICE_VENDOR, string) \
1350 F(cl_device_info, CL_DRIVER_VERSION, string) \
1351 F(cl_device_info, CL_DEVICE_PROFILE, string) \
1352 F(cl_device_info, CL_DEVICE_VERSION, string) \
1353 F(cl_device_info, CL_DEVICE_EXTENSIONS, string) \
1355 F(cl_context_info, CL_CONTEXT_REFERENCE_COUNT, cl_uint) \
1356 F(cl_context_info, CL_CONTEXT_DEVICES, cl::vector<Device>) \
1357 F(cl_context_info, CL_CONTEXT_PROPERTIES, cl::vector<cl_context_properties>) \
1359 F(cl_event_info, CL_EVENT_COMMAND_QUEUE, cl::CommandQueue) \
1360 F(cl_event_info, CL_EVENT_COMMAND_TYPE, cl_command_type) \
1361 F(cl_event_info, CL_EVENT_REFERENCE_COUNT, cl_uint) \
1362 F(cl_event_info, CL_EVENT_COMMAND_EXECUTION_STATUS, cl_int) \
1364 F(cl_profiling_info, CL_PROFILING_COMMAND_QUEUED, cl_ulong) \
1365 F(cl_profiling_info, CL_PROFILING_COMMAND_SUBMIT, cl_ulong) \
1366 F(cl_profiling_info, CL_PROFILING_COMMAND_START, cl_ulong) \
1367 F(cl_profiling_info, CL_PROFILING_COMMAND_END, cl_ulong) \
1369 F(cl_mem_info, CL_MEM_TYPE, cl_mem_object_type) \
1370 F(cl_mem_info, CL_MEM_FLAGS, cl_mem_flags) \
1371 F(cl_mem_info, CL_MEM_SIZE, size_type) \
1372 F(cl_mem_info, CL_MEM_HOST_PTR, void*) \
1373 F(cl_mem_info, CL_MEM_MAP_COUNT, cl_uint) \
1374 F(cl_mem_info, CL_MEM_REFERENCE_COUNT, cl_uint) \
1375 F(cl_mem_info, CL_MEM_CONTEXT, cl::Context) \
1377 F(cl_image_info, CL_IMAGE_FORMAT, cl_image_format) \
1378 F(cl_image_info, CL_IMAGE_ELEMENT_SIZE, size_type) \
1379 F(cl_image_info, CL_IMAGE_ROW_PITCH, size_type) \
1380 F(cl_image_info, CL_IMAGE_SLICE_PITCH, size_type) \
1381 F(cl_image_info, CL_IMAGE_WIDTH, size_type) \
1382 F(cl_image_info, CL_IMAGE_HEIGHT, size_type) \
1383 F(cl_image_info, CL_IMAGE_DEPTH, size_type) \
1385 F(cl_sampler_info, CL_SAMPLER_REFERENCE_COUNT, cl_uint) \
1386 F(cl_sampler_info, CL_SAMPLER_CONTEXT, cl::Context) \
1387 F(cl_sampler_info, CL_SAMPLER_NORMALIZED_COORDS, cl_bool) \
1388 F(cl_sampler_info, CL_SAMPLER_ADDRESSING_MODE, cl_addressing_mode) \
1389 F(cl_sampler_info, CL_SAMPLER_FILTER_MODE, cl_filter_mode) \
1391 F(cl_program_info, CL_PROGRAM_REFERENCE_COUNT, cl_uint) \
1392 F(cl_program_info, CL_PROGRAM_CONTEXT, cl::Context) \
1393 F(cl_program_info, CL_PROGRAM_NUM_DEVICES, cl_uint) \
1394 F(cl_program_info, CL_PROGRAM_DEVICES, cl::vector<Device>) \
1395 F(cl_program_info, CL_PROGRAM_SOURCE, string) \
1396 F(cl_program_info, CL_PROGRAM_BINARY_SIZES, cl::vector<size_type>) \
1397 F(cl_program_info, CL_PROGRAM_BINARIES, cl::vector<cl::vector<unsigned char>>) \
1399 F(cl_program_build_info, CL_PROGRAM_BUILD_STATUS, cl_build_status) \
1400 F(cl_program_build_info, CL_PROGRAM_BUILD_OPTIONS, string) \
1401 F(cl_program_build_info, CL_PROGRAM_BUILD_LOG, string) \
1403 F(cl_kernel_info, CL_KERNEL_FUNCTION_NAME, string) \
1404 F(cl_kernel_info, CL_KERNEL_NUM_ARGS, cl_uint) \
1405 F(cl_kernel_info, CL_KERNEL_REFERENCE_COUNT, cl_uint) \
1406 F(cl_kernel_info, CL_KERNEL_CONTEXT, cl::Context) \
1407 F(cl_kernel_info, CL_KERNEL_PROGRAM, cl::Program) \
1409 F(cl_kernel_work_group_info, CL_KERNEL_WORK_GROUP_SIZE, size_type) \
1410 F(cl_kernel_work_group_info, CL_KERNEL_COMPILE_WORK_GROUP_SIZE, cl::detail::size_t_array) \
1411 F(cl_kernel_work_group_info, CL_KERNEL_LOCAL_MEM_SIZE, cl_ulong) \
1413 F(cl_command_queue_info, CL_QUEUE_CONTEXT, cl::Context) \
1414 F(cl_command_queue_info, CL_QUEUE_DEVICE, cl::Device) \
1415 F(cl_command_queue_info, CL_QUEUE_REFERENCE_COUNT, cl_uint) \
1416 F(cl_command_queue_info, CL_QUEUE_PROPERTIES, cl_command_queue_properties)
1419#define CL_HPP_PARAM_NAME_INFO_1_1_(F) \
1420 F(cl_context_info, CL_CONTEXT_NUM_DEVICES, cl_uint)\
1421 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF, cl_uint) \
1422 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR, cl_uint) \
1423 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT, cl_uint) \
1424 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_INT, cl_uint) \
1425 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG, cl_uint) \
1426 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT, cl_uint) \
1427 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE, cl_uint) \
1428 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF, cl_uint) \
1429 F(cl_device_info, CL_DEVICE_OPENCL_C_VERSION, string) \
1431 F(cl_mem_info, CL_MEM_ASSOCIATED_MEMOBJECT, cl::Memory) \
1432 F(cl_mem_info, CL_MEM_OFFSET, size_type) \
1434 F(cl_kernel_work_group_info, CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, size_type) \
1435 F(cl_kernel_work_group_info, CL_KERNEL_PRIVATE_MEM_SIZE, cl_ulong) \
1437 F(cl_event_info, CL_EVENT_CONTEXT, cl::Context)
1439#define CL_HPP_PARAM_NAME_INFO_1_2_(F) \
1440 F(cl_program_info, CL_PROGRAM_NUM_KERNELS, size_type) \
1441 F(cl_program_info, CL_PROGRAM_KERNEL_NAMES, string) \
1443 F(cl_program_build_info, CL_PROGRAM_BINARY_TYPE, cl_program_binary_type) \
1445 F(cl_kernel_info, CL_KERNEL_ATTRIBUTES, string) \
1447 F(cl_kernel_arg_info, CL_KERNEL_ARG_ADDRESS_QUALIFIER, cl_kernel_arg_address_qualifier) \
1448 F(cl_kernel_arg_info, CL_KERNEL_ARG_ACCESS_QUALIFIER, cl_kernel_arg_access_qualifier) \
1449 F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_NAME, string) \
1450 F(cl_kernel_arg_info, CL_KERNEL_ARG_NAME, string) \
1451 F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_QUALIFIER, cl_kernel_arg_type_qualifier) \
1453 F(cl_kernel_work_group_info, CL_KERNEL_GLOBAL_WORK_SIZE, cl::detail::size_t_array) \
1455 F(cl_device_info, CL_DEVICE_LINKER_AVAILABLE, cl_bool) \
1456 F(cl_device_info, CL_DEVICE_IMAGE_MAX_BUFFER_SIZE, size_type) \
1457 F(cl_device_info, CL_DEVICE_IMAGE_MAX_ARRAY_SIZE, size_type) \
1458 F(cl_device_info, CL_DEVICE_PARENT_DEVICE, cl::Device) \
1459 F(cl_device_info, CL_DEVICE_PARTITION_MAX_SUB_DEVICES, cl_uint) \
1460 F(cl_device_info, CL_DEVICE_PARTITION_PROPERTIES, cl::vector<cl_device_partition_property>) \
1461 F(cl_device_info, CL_DEVICE_PARTITION_TYPE, cl::vector<cl_device_partition_property>) \
1462 F(cl_device_info, CL_DEVICE_REFERENCE_COUNT, cl_uint) \
1463 F(cl_device_info, CL_DEVICE_PREFERRED_INTEROP_USER_SYNC, cl_bool) \
1464 F(cl_device_info, CL_DEVICE_PARTITION_AFFINITY_DOMAIN, cl_device_affinity_domain) \
1465 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS, string) \
1466 F(cl_device_info, CL_DEVICE_PRINTF_BUFFER_SIZE, size_type) \
1468 F(cl_image_info, CL_IMAGE_ARRAY_SIZE, size_type) \
1469 F(cl_image_info, CL_IMAGE_NUM_MIP_LEVELS, cl_uint) \
1470 F(cl_image_info, CL_IMAGE_NUM_SAMPLES, cl_uint)
1472#define CL_HPP_PARAM_NAME_INFO_2_0_(F) \
1473 F(cl_device_info, CL_DEVICE_QUEUE_ON_HOST_PROPERTIES, cl_command_queue_properties) \
1474 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES, cl_command_queue_properties) \
1475 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE, cl_uint) \
1476 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE, cl_uint) \
1477 F(cl_device_info, CL_DEVICE_MAX_ON_DEVICE_QUEUES, cl_uint) \
1478 F(cl_device_info, CL_DEVICE_MAX_ON_DEVICE_EVENTS, cl_uint) \
1479 F(cl_device_info, CL_DEVICE_MAX_PIPE_ARGS, cl_uint) \
1480 F(cl_device_info, CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS, cl_uint) \
1481 F(cl_device_info, CL_DEVICE_PIPE_MAX_PACKET_SIZE, cl_uint) \
1482 F(cl_device_info, CL_DEVICE_SVM_CAPABILITIES, cl_device_svm_capabilities) \
1483 F(cl_device_info, CL_DEVICE_PREFERRED_PLATFORM_ATOMIC_ALIGNMENT, cl_uint) \
1484 F(cl_device_info, CL_DEVICE_PREFERRED_GLOBAL_ATOMIC_ALIGNMENT, cl_uint) \
1485 F(cl_device_info, CL_DEVICE_PREFERRED_LOCAL_ATOMIC_ALIGNMENT, cl_uint) \
1486 F(cl_device_info, CL_DEVICE_IMAGE_PITCH_ALIGNMENT, cl_uint) \
1487 F(cl_device_info, CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT, cl_uint) \
1488 F(cl_device_info, CL_DEVICE_MAX_READ_WRITE_IMAGE_ARGS, cl_uint ) \
1489 F(cl_device_info, CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE, size_type ) \
1490 F(cl_device_info, CL_DEVICE_GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE, size_type ) \
1491 F(cl_profiling_info, CL_PROFILING_COMMAND_COMPLETE, cl_ulong) \
1492 F(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM, cl_bool) \
1493 F(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_SVM_PTRS, void**) \
1494 F(cl_command_queue_info, CL_QUEUE_SIZE, cl_uint) \
1495 F(cl_mem_info, CL_MEM_USES_SVM_POINTER, cl_bool) \
1496 F(cl_program_build_info, CL_PROGRAM_BUILD_GLOBAL_VARIABLE_TOTAL_SIZE, size_type) \
1497 F(cl_pipe_info, CL_PIPE_PACKET_SIZE, cl_uint) \
1498 F(cl_pipe_info, CL_PIPE_MAX_PACKETS, cl_uint)
1500#define CL_HPP_PARAM_NAME_INFO_SUBGROUP_KHR_(F) \
1501 F(cl_kernel_sub_group_info, CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE_KHR, size_type) \
1502 F(cl_kernel_sub_group_info, CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE_KHR, size_type)
1504#define CL_HPP_PARAM_NAME_INFO_IL_KHR_(F) \
1505 F(cl_device_info, CL_DEVICE_IL_VERSION_KHR, string) \
1506 F(cl_program_info, CL_PROGRAM_IL_KHR, cl::vector<unsigned char>)
1508#define CL_HPP_PARAM_NAME_INFO_2_1_(F) \
1509 F(cl_platform_info, CL_PLATFORM_HOST_TIMER_RESOLUTION, cl_ulong) \
1510 F(cl_program_info, CL_PROGRAM_IL, cl::vector<unsigned char>) \
1511 F(cl_device_info, CL_DEVICE_MAX_NUM_SUB_GROUPS, cl_uint) \
1512 F(cl_device_info, CL_DEVICE_IL_VERSION, string) \
1513 F(cl_device_info, CL_DEVICE_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS, cl_bool) \
1514 F(cl_command_queue_info, CL_QUEUE_DEVICE_DEFAULT, cl::DeviceCommandQueue) \
1515 F(cl_kernel_sub_group_info, CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE, size_type) \
1516 F(cl_kernel_sub_group_info, CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE, size_type) \
1517 F(cl_kernel_sub_group_info, CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT, cl::detail::size_t_array) \
1518 F(cl_kernel_sub_group_info, CL_KERNEL_MAX_NUM_SUB_GROUPS, size_type) \
1519 F(cl_kernel_sub_group_info, CL_KERNEL_COMPILE_NUM_SUB_GROUPS, size_type)
1521#define CL_HPP_PARAM_NAME_INFO_2_2_(F) \
1522 F(cl_program_info, CL_PROGRAM_SCOPE_GLOBAL_CTORS_PRESENT, cl_bool) \
1523 F(cl_program_info, CL_PROGRAM_SCOPE_GLOBAL_DTORS_PRESENT, cl_bool)
1525#define CL_HPP_PARAM_NAME_DEVICE_FISSION_EXT_(F) \
1526 F(cl_device_info, CL_DEVICE_PARENT_DEVICE_EXT, cl::Device) \
1527 F(cl_device_info, CL_DEVICE_PARTITION_TYPES_EXT, cl::vector<cl_device_partition_property_ext>) \
1528 F(cl_device_info, CL_DEVICE_AFFINITY_DOMAINS_EXT, cl::vector<cl_device_partition_property_ext>) \
1529 F(cl_device_info, CL_DEVICE_REFERENCE_COUNT_EXT , cl_uint) \
1530 F(cl_device_info, CL_DEVICE_PARTITION_STYLE_EXT, cl::vector<cl_device_partition_property_ext>)
1532#define CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_CL3_SHARED_(F) \
1533 F(cl_platform_info, CL_PLATFORM_NUMERIC_VERSION_KHR, cl_version_khr) \
1534 F(cl_platform_info, CL_PLATFORM_EXTENSIONS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>) \
1536 F(cl_device_info, CL_DEVICE_NUMERIC_VERSION_KHR, cl_version_khr) \
1537 F(cl_device_info, CL_DEVICE_EXTENSIONS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>) \
1538 F(cl_device_info, CL_DEVICE_ILS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>) \
1539 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>)
1541#define CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_KHRONLY_(F) \
1542 F(cl_device_info, CL_DEVICE_OPENCL_C_NUMERIC_VERSION_KHR, cl_version_khr)
1545#define CL_HPP_PARAM_NAME_CL_KHR_SEMAPHORE_(F) \
1546 F(cl_semaphore_info_khr, CL_SEMAPHORE_CONTEXT_KHR, cl::Context) \
1547 F(cl_semaphore_info_khr, CL_SEMAPHORE_REFERENCE_COUNT_KHR, cl_uint) \
1548 F(cl_semaphore_info_khr, CL_SEMAPHORE_PROPERTIES_KHR, cl::vector<cl_semaphore_properties_khr>) \
1549 F(cl_semaphore_info_khr, CL_SEMAPHORE_TYPE_KHR, cl_semaphore_type_khr) \
1550 F(cl_semaphore_info_khr, CL_SEMAPHORE_PAYLOAD_KHR, cl_semaphore_payload_khr) \
1551 F(cl_platform_info, CL_PLATFORM_SEMAPHORE_TYPES_KHR, cl::vector<cl_semaphore_type_khr>) \
1552 F(cl_device_info, CL_DEVICE_SEMAPHORE_TYPES_KHR, cl::vector<cl_semaphore_type_khr>) \
1554#define CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_MEMORY_(F) \
1555 F(cl_device_info, CL_DEVICE_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR, cl::vector<cl::ExternalMemoryType>) \
1556 F(cl_platform_info, CL_PLATFORM_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR, cl::vector<cl::ExternalMemoryType>)
1558#define CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_(F) \
1559 F(cl_platform_info, CL_PLATFORM_SEMAPHORE_IMPORT_HANDLE_TYPES_KHR, cl::vector<cl_external_semaphore_handle_type_khr>) \
1560 F(cl_platform_info, CL_PLATFORM_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR, cl::vector<cl_external_semaphore_handle_type_khr>) \
1561 F(cl_device_info, CL_DEVICE_SEMAPHORE_IMPORT_HANDLE_TYPES_KHR, cl::vector<cl_external_semaphore_handle_type_khr>) \
1562 F(cl_device_info, CL_DEVICE_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR, cl::vector<cl_external_semaphore_handle_type_khr>) \
1563 F(cl_semaphore_info_khr, CL_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR, cl::vector<cl_external_semaphore_handle_type_khr>) \
1565#define CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_DX_FENCE_EXT(F) \
1566 F(cl_external_semaphore_handle_type_khr, CL_SEMAPHORE_HANDLE_D3D12_FENCE_KHR, void*) \
1568#define CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_OPAQUE_FD_EXT(F) \
1569 F(cl_external_semaphore_handle_type_khr, CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR, int) \
1571#define CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_SYNC_FD_EXT(F) \
1572 F(cl_external_semaphore_handle_type_khr, CL_SEMAPHORE_HANDLE_SYNC_FD_KHR, int) \
1574#define CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_WIN32_EXT(F) \
1575 F(cl_external_semaphore_handle_type_khr, CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KHR, void*) \
1576 F(cl_external_semaphore_handle_type_khr, CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KMT_KHR, void*) \
1578#define CL_HPP_PARAM_NAME_INFO_3_0_(F) \
1579 F(cl_platform_info, CL_PLATFORM_NUMERIC_VERSION, cl_version) \
1580 F(cl_platform_info, CL_PLATFORM_EXTENSIONS_WITH_VERSION, cl::vector<cl_name_version>) \
1582 F(cl_device_info, CL_DEVICE_NUMERIC_VERSION, cl_version) \
1583 F(cl_device_info, CL_DEVICE_EXTENSIONS_WITH_VERSION, cl::vector<cl_name_version>) \
1584 F(cl_device_info, CL_DEVICE_ILS_WITH_VERSION, cl::vector<cl_name_version>) \
1585 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS_WITH_VERSION, cl::vector<cl_name_version>) \
1586 F(cl_device_info, CL_DEVICE_ATOMIC_MEMORY_CAPABILITIES, cl_device_atomic_capabilities) \
1587 F(cl_device_info, CL_DEVICE_ATOMIC_FENCE_CAPABILITIES, cl_device_atomic_capabilities) \
1588 F(cl_device_info, CL_DEVICE_NON_UNIFORM_WORK_GROUP_SUPPORT, cl_bool) \
1589 F(cl_device_info, CL_DEVICE_OPENCL_C_ALL_VERSIONS, cl::vector<cl_name_version>) \
1590 F(cl_device_info, CL_DEVICE_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, size_type) \
1591 F(cl_device_info, CL_DEVICE_WORK_GROUP_COLLECTIVE_FUNCTIONS_SUPPORT, cl_bool) \
1592 F(cl_device_info, CL_DEVICE_GENERIC_ADDRESS_SPACE_SUPPORT, cl_bool) \
1593 F(cl_device_info, CL_DEVICE_OPENCL_C_FEATURES, cl::vector<cl_name_version>) \
1594 F(cl_device_info, CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES, cl_device_device_enqueue_capabilities) \
1595 F(cl_device_info, CL_DEVICE_PIPE_SUPPORT, cl_bool) \
1596 F(cl_device_info, CL_DEVICE_LATEST_CONFORMANCE_VERSION_PASSED, string) \
1598 F(cl_command_queue_info, CL_QUEUE_PROPERTIES_ARRAY, cl::vector<cl_queue_properties>) \
1599 F(cl_mem_info, CL_MEM_PROPERTIES, cl::vector<cl_mem_properties>) \
1600 F(cl_pipe_info, CL_PIPE_PROPERTIES, cl::vector<cl_pipe_properties>) \
1601 F(cl_sampler_info, CL_SAMPLER_PROPERTIES, cl::vector<cl_sampler_properties>) \
1603#define CL_HPP_PARAM_NAME_CL_IMAGE_REQUIREMENTS_EXT(F) \
1604 F(cl_image_requirements_info_ext, CL_IMAGE_REQUIREMENTS_ROW_PITCH_ALIGNMENT_EXT, size_type) \
1605 F(cl_image_requirements_info_ext, CL_IMAGE_REQUIREMENTS_BASE_ADDRESS_ALIGNMENT_EXT, size_type) \
1606 F(cl_image_requirements_info_ext, CL_IMAGE_REQUIREMENTS_SIZE_EXT, size_type) \
1607 F(cl_image_requirements_info_ext, CL_IMAGE_REQUIREMENTS_MAX_WIDTH_EXT, cl_uint) \
1608 F(cl_image_requirements_info_ext, CL_IMAGE_REQUIREMENTS_MAX_HEIGHT_EXT, cl_uint) \
1609 F(cl_image_requirements_info_ext, CL_IMAGE_REQUIREMENTS_MAX_DEPTH_EXT, cl_uint) \
1610 F(cl_image_requirements_info_ext, CL_IMAGE_REQUIREMENTS_MAX_ARRAY_SIZE_EXT, cl_uint) \
1612#define CL_HPP_PARAM_NAME_CL_IMAGE_REQUIREMENTS_SLICE_PITCH_ALIGNMENT_EXT(F) \
1613 F(cl_image_requirements_info_ext, CL_IMAGE_REQUIREMENTS_SLICE_PITCH_ALIGNMENT_EXT, size_type) \
1615template <
typename enum_type, cl_
int Name>
1618#define CL_HPP_DECLARE_PARAM_TRAITS_(token, param_name, T) \
1621struct param_traits<detail:: token,param_name> \
1623 enum { value = param_name }; \
1624 typedef T param_type; \
1627CL_HPP_PARAM_NAME_INFO_1_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1628#if CL_HPP_TARGET_OPENCL_VERSION >= 110
1629CL_HPP_PARAM_NAME_INFO_1_1_(CL_HPP_DECLARE_PARAM_TRAITS_)
1631#if CL_HPP_TARGET_OPENCL_VERSION >= 120
1632CL_HPP_PARAM_NAME_INFO_1_2_(CL_HPP_DECLARE_PARAM_TRAITS_)
1634#if CL_HPP_TARGET_OPENCL_VERSION >= 200
1635CL_HPP_PARAM_NAME_INFO_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1637#if CL_HPP_TARGET_OPENCL_VERSION >= 210
1638CL_HPP_PARAM_NAME_INFO_2_1_(CL_HPP_DECLARE_PARAM_TRAITS_)
1640#if CL_HPP_TARGET_OPENCL_VERSION >= 220
1641CL_HPP_PARAM_NAME_INFO_2_2_(CL_HPP_DECLARE_PARAM_TRAITS_)
1643#if CL_HPP_TARGET_OPENCL_VERSION >= 300
1644CL_HPP_PARAM_NAME_INFO_3_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1647#if defined(cl_khr_subgroups) && CL_HPP_TARGET_OPENCL_VERSION < 210
1648CL_HPP_PARAM_NAME_INFO_SUBGROUP_KHR_(CL_HPP_DECLARE_PARAM_TRAITS_)
1651#if defined(cl_khr_il_program) && CL_HPP_TARGET_OPENCL_VERSION < 210
1652CL_HPP_PARAM_NAME_INFO_IL_KHR_(CL_HPP_DECLARE_PARAM_TRAITS_)
1657#define CL_HPP_PARAM_NAME_INFO_1_0_DEPRECATED_IN_2_0_(F) \
1658 F(cl_device_info, CL_DEVICE_QUEUE_PROPERTIES, cl_command_queue_properties)
1660#define CL_HPP_PARAM_NAME_INFO_1_1_DEPRECATED_IN_2_0_(F) \
1661 F(cl_device_info, CL_DEVICE_HOST_UNIFIED_MEMORY, cl_bool)
1663#define CL_HPP_PARAM_NAME_INFO_1_2_DEPRECATED_IN_2_0_(F) \
1664 F(cl_image_info, CL_IMAGE_BUFFER, cl::Buffer)
1668#if CL_HPP_TARGET_OPENCL_VERSION > 100 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 && CL_HPP_TARGET_OPENCL_VERSION < 200
1669CL_HPP_PARAM_NAME_INFO_1_0_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1671#if CL_HPP_TARGET_OPENCL_VERSION > 110 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
1672CL_HPP_PARAM_NAME_INFO_1_1_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1674#if CL_HPP_TARGET_OPENCL_VERSION > 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
1675CL_HPP_PARAM_NAME_INFO_1_2_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1678#if defined(cl_ext_device_fission)
1679CL_HPP_PARAM_NAME_DEVICE_FISSION_EXT_(CL_HPP_DECLARE_PARAM_TRAITS_)
1682#if defined(cl_khr_extended_versioning)
1683#if CL_HPP_TARGET_OPENCL_VERSION < 300
1684CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_CL3_SHARED_(CL_HPP_DECLARE_PARAM_TRAITS_)
1686CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_KHRONLY_(CL_HPP_DECLARE_PARAM_TRAITS_)
1689#if defined(cl_khr_semaphore)
1690CL_HPP_PARAM_NAME_CL_KHR_SEMAPHORE_(CL_HPP_DECLARE_PARAM_TRAITS_)
1691#if defined(CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR)
1692CL_HPP_DECLARE_PARAM_TRAITS_(cl_semaphore_info_khr, CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR, cl::vector<cl::Device>)
1696#ifdef cl_khr_external_memory
1697CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_MEMORY_(CL_HPP_DECLARE_PARAM_TRAITS_)
1700#if defined(cl_khr_external_semaphore)
1701CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_(CL_HPP_DECLARE_PARAM_TRAITS_)
1704#if defined(cl_khr_external_semaphore_dx_fence)
1705CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_DX_FENCE_EXT(CL_HPP_DECLARE_PARAM_TRAITS_)
1707#if defined(cl_khr_external_semaphore_opaque_fd)
1708CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_OPAQUE_FD_EXT(CL_HPP_DECLARE_PARAM_TRAITS_)
1710#if defined(cl_khr_external_semaphore_sync_fd)
1711CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_SYNC_FD_EXT(CL_HPP_DECLARE_PARAM_TRAITS_)
1713#if defined(cl_khr_external_semaphore_win32)
1714CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_WIN32_EXT(CL_HPP_DECLARE_PARAM_TRAITS_)
1717#if defined(cl_khr_device_uuid)
1718using uuid_array = array<cl_uchar, CL_UUID_SIZE_KHR>;
1719using luid_array = array<cl_uchar, CL_LUID_SIZE_KHR>;
1720CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_UUID_KHR, uuid_array)
1721CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DRIVER_UUID_KHR, uuid_array)
1722CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LUID_VALID_KHR, cl_bool)
1723CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LUID_KHR, luid_array)
1724CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_NODE_MASK_KHR, cl_uint)
1727#if defined(cl_khr_pci_bus_info)
1728CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_PCI_BUS_INFO_KHR, cl_device_pci_bus_info_khr)
1732#if CL_HPP_TARGET_OPENCL_VERSION < 200
1733#if defined(CL_DEVICE_IMAGE_PITCH_ALIGNMENT_KHR)
1734CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_IMAGE_PITCH_ALIGNMENT_KHR, cl_uint)
1736#if defined(CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT_KHR)
1737CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT_KHR, cl_uint)
1741#if defined(cl_khr_integer_dot_product)
1742CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGER_DOT_PRODUCT_CAPABILITIES_KHR, cl_device_integer_dot_product_capabilities_khr)
1743#if defined(CL_DEVICE_INTEGER_DOT_PRODUCT_ACCELERATION_PROPERTIES_8BIT_KHR)
1744CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGER_DOT_PRODUCT_ACCELERATION_PROPERTIES_8BIT_KHR, cl_device_integer_dot_product_acceleration_properties_khr)
1745CL_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)
1749#if defined(cl_ext_image_requirements_info)
1750CL_HPP_PARAM_NAME_CL_IMAGE_REQUIREMENTS_EXT(CL_HPP_DECLARE_PARAM_TRAITS_)
1753#if defined(cl_ext_image_from_buffer)
1754CL_HPP_PARAM_NAME_CL_IMAGE_REQUIREMENTS_SLICE_PITCH_ALIGNMENT_EXT(CL_HPP_DECLARE_PARAM_TRAITS_)
1757#ifdef CL_PLATFORM_ICD_SUFFIX_KHR
1758CL_HPP_DECLARE_PARAM_TRAITS_(cl_platform_info, CL_PLATFORM_ICD_SUFFIX_KHR,
string)
1761#ifdef CL_DEVICE_PROFILING_TIMER_OFFSET_AMD
1762CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_PROFILING_TIMER_OFFSET_AMD, cl_ulong)
1764#ifdef CL_DEVICE_GLOBAL_FREE_MEMORY_AMD
1765CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_FREE_MEMORY_AMD, vector<size_type>)
1767#ifdef CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD
1768CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD, cl_uint)
1770#ifdef CL_DEVICE_SIMD_WIDTH_AMD
1771CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_WIDTH_AMD, cl_uint)
1773#ifdef CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD
1774CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD, cl_uint)
1776#ifdef CL_DEVICE_WAVEFRONT_WIDTH_AMD
1777CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_WAVEFRONT_WIDTH_AMD, cl_uint)
1779#ifdef CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD
1780CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD, cl_uint)
1782#ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD
1783CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD, cl_uint)
1785#ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD
1786CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD, cl_uint)
1788#ifdef CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD
1789CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD, cl_uint)
1791#ifdef CL_DEVICE_LOCAL_MEM_BANKS_AMD
1792CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LOCAL_MEM_BANKS_AMD, cl_uint)
1794#ifdef CL_DEVICE_BOARD_NAME_AMD
1795CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_BOARD_NAME_AMD,
string)
1798#ifdef CL_DEVICE_COMPUTE_UNITS_BITFIELD_ARM
1799CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_UNITS_BITFIELD_ARM, cl_ulong)
1801#ifdef CL_DEVICE_JOB_SLOTS_ARM
1802CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_JOB_SLOTS_ARM, cl_uint)
1804#ifdef CL_DEVICE_SCHEDULING_CONTROLS_CAPABILITIES_ARM
1805CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SCHEDULING_CONTROLS_CAPABILITIES_ARM, cl_bitfield)
1807#ifdef CL_DEVICE_SUPPORTED_REGISTER_ALLOCATIONS_ARM
1808CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SUPPORTED_REGISTER_ALLOCATIONS_ARM, vector<cl_uint>)
1810#ifdef CL_DEVICE_MAX_WARP_COUNT_ARM
1811CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_MAX_WARP_COUNT_ARM, cl_uint)
1813#ifdef CL_KERNEL_MAX_WARP_COUNT_ARM
1814CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_info, CL_KERNEL_MAX_WARP_COUNT_ARM, cl_uint)
1816#ifdef CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_ARM
1817CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_ARM, cl_uint)
1819#ifdef CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_MODIFIER_ARM
1820CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_MODIFIER_ARM, cl_int)
1822#ifdef CL_KERNEL_EXEC_INFO_WARP_COUNT_LIMIT_ARM
1823CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_WARP_COUNT_LIMIT_ARM, cl_uint)
1825#ifdef CL_KERNEL_EXEC_INFO_COMPUTE_UNIT_MAX_QUEUED_BATCHES_ARM
1826CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_COMPUTE_UNIT_MAX_QUEUED_BATCHES_ARM, cl_uint)
1829#ifdef CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV
1830CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV, cl_uint)
1832#ifdef CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV
1833CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV, cl_uint)
1835#ifdef CL_DEVICE_REGISTERS_PER_BLOCK_NV
1836CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_REGISTERS_PER_BLOCK_NV, cl_uint)
1838#ifdef CL_DEVICE_WARP_SIZE_NV
1839CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_WARP_SIZE_NV, cl_uint)
1841#ifdef CL_DEVICE_GPU_OVERLAP_NV
1842CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GPU_OVERLAP_NV, cl_bool)
1844#ifdef CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV
1845CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV, cl_bool)
1847#ifdef CL_DEVICE_INTEGRATED_MEMORY_NV
1848CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGRATED_MEMORY_NV, cl_bool)
1851#if defined(cl_khr_command_buffer)
1852CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMMAND_BUFFER_CAPABILITIES_KHR, cl_device_command_buffer_capabilities_khr)
1853CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMMAND_BUFFER_REQUIRED_QUEUE_PROPERTIES_KHR, cl_command_buffer_properties_khr)
1854CL_HPP_DECLARE_PARAM_TRAITS_(cl_command_buffer_info_khr, CL_COMMAND_BUFFER_QUEUES_KHR, cl::vector<CommandQueue>)
1855CL_HPP_DECLARE_PARAM_TRAITS_(cl_command_buffer_info_khr, CL_COMMAND_BUFFER_NUM_QUEUES_KHR, cl_uint)
1856CL_HPP_DECLARE_PARAM_TRAITS_(cl_command_buffer_info_khr, CL_COMMAND_BUFFER_REFERENCE_COUNT_KHR, cl_uint)
1857CL_HPP_DECLARE_PARAM_TRAITS_(cl_command_buffer_info_khr, CL_COMMAND_BUFFER_STATE_KHR, cl_command_buffer_state_khr)
1858CL_HPP_DECLARE_PARAM_TRAITS_(cl_command_buffer_info_khr, CL_COMMAND_BUFFER_PROPERTIES_ARRAY_KHR, cl::vector<cl_command_buffer_properties_khr>)
1861#if defined(cl_khr_command_buffer_mutable_dispatch)
1862CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_COMMAND_COMMAND_QUEUE_KHR,
CommandQueue)
1863CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_COMMAND_COMMAND_BUFFER_KHR, CommandBufferKhr)
1864CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_COMMAND_COMMAND_TYPE_KHR, cl_command_type)
1865CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_DISPATCH_PROPERTIES_ARRAY_KHR, cl::vector<cl_ndrange_kernel_command_properties_khr>)
1866CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_DISPATCH_KERNEL_KHR, cl_kernel)
1867CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_DISPATCH_DIMENSIONS_KHR, cl_uint)
1868CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_DISPATCH_GLOBAL_WORK_OFFSET_KHR, cl::vector<size_type>)
1869CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_DISPATCH_GLOBAL_WORK_SIZE_KHR, cl::vector<size_type>)
1870CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_DISPATCH_LOCAL_WORK_SIZE_KHR, cl::vector<size_type>)
1875template <
typename Func,
typename T>
1877getInfo(Func f, cl_uint name, T* param)
1879 return getInfoHelper(f, name, param, 0);
1882template <
typename Func,
typename Arg0>
1885 Func f_;
const Arg0& arg0_;
1887 cl_uint param, size_type size,
void* value, size_type* size_ret)
1888 {
return f_(arg0_, param, size, value, size_ret); }
1891template <
typename Func,
typename Arg0,
typename Arg1>
1894 Func f_;
const Arg0& arg0_;
const Arg1& arg1_;
1896 cl_uint param, size_type size,
void* value, size_type* size_ret)
1897 {
return f_(arg0_, arg1_, param, size, value, size_ret); }
1900template <
typename Func,
typename Arg0,
typename T>
1902getInfo(Func f,
const Arg0& arg0, cl_uint name, T* param)
1904 GetInfoFunctor0<Func, Arg0> f0 = { f, arg0 };
1905 return getInfoHelper(f0, name, param, 0);
1908template <
typename Func,
typename Arg0,
typename Arg1,
typename T>
1910getInfo(Func f,
const Arg0& arg0,
const Arg1& arg1, cl_uint name, T* param)
1912 GetInfoFunctor1<Func, Arg0, Arg1> f0 = { f, arg0, arg1 };
1913 return getInfoHelper(f0, name, param, 0);
1921#if CL_HPP_TARGET_OPENCL_VERSION >= 120
1938 { return ::clRetainDevice(device); }
1949 { return ::clReleaseDevice(device); }
1956struct ReferenceHandler<cl_device_id>
1959 static cl_int retain(cl_device_id)
1960 {
return CL_SUCCESS; }
1962 static cl_int release(cl_device_id)
1963 {
return CL_SUCCESS; }
1971 static cl_int retain(cl_platform_id)
1972 {
return CL_SUCCESS; }
1974 static cl_int release(cl_platform_id)
1975 {
return CL_SUCCESS; }
1981 static cl_int retain(cl_context context)
1982 { return ::clRetainContext(context); }
1983 static cl_int release(cl_context context)
1984 { return ::clReleaseContext(context); }
1990 static cl_int retain(cl_command_queue queue)
1991 { return ::clRetainCommandQueue(queue); }
1992 static cl_int release(cl_command_queue queue)
1993 { return ::clReleaseCommandQueue(queue); }
1999 static cl_int retain(cl_mem memory)
2000 { return ::clRetainMemObject(memory); }
2001 static cl_int release(cl_mem memory)
2002 { return ::clReleaseMemObject(memory); }
2008 static cl_int retain(cl_sampler sampler)
2009 { return ::clRetainSampler(sampler); }
2010 static cl_int release(cl_sampler sampler)
2011 { return ::clReleaseSampler(sampler); }
2017 static cl_int retain(cl_program program)
2018 { return ::clRetainProgram(program); }
2019 static cl_int release(cl_program program)
2020 { return ::clReleaseProgram(program); }
2026 static cl_int retain(cl_kernel kernel)
2027 { return ::clRetainKernel(kernel); }
2028 static cl_int release(cl_kernel kernel)
2029 { return ::clReleaseKernel(kernel); }
2035 static cl_int retain(cl_event event)
2036 { return ::clRetainEvent(event); }
2037 static cl_int release(cl_event event)
2038 { return ::clReleaseEvent(event); }
2041#ifdef cl_khr_semaphore
2045 static cl_int retain(cl_semaphore_khr semaphore)
2047 if (pfn_clRetainSemaphoreKHR !=
nullptr) {
2048 return pfn_clRetainSemaphoreKHR(semaphore);
2051 return CL_INVALID_OPERATION;
2054 static cl_int release(cl_semaphore_khr semaphore)
2056 if (pfn_clReleaseSemaphoreKHR !=
nullptr) {
2057 return pfn_clReleaseSemaphoreKHR(semaphore);
2060 return CL_INVALID_OPERATION;
2064#if defined(cl_khr_command_buffer)
2066struct ReferenceHandler<cl_command_buffer_khr>
2068 static cl_int retain(cl_command_buffer_khr cmdBufferKhr)
2070 if (pfn_clRetainCommandBufferKHR ==
nullptr) {
2071 return detail::errHandler(CL_INVALID_OPERATION, __RETAIN_COMMAND_BUFFER_KHR_ERR);
2073 return pfn_clRetainCommandBufferKHR(cmdBufferKhr);
2076 static cl_int release(cl_command_buffer_khr cmdBufferKhr)
2078 if (pfn_clReleaseCommandBufferKHR ==
nullptr) {
2079 return detail::errHandler(CL_INVALID_OPERATION, __RELEASE_COMMAND_BUFFER_KHR_ERR);
2081 return pfn_clReleaseCommandBufferKHR(cmdBufferKhr);
2086struct ReferenceHandler<cl_mutable_command_khr>
2089 static cl_int retain(cl_mutable_command_khr)
2090 {
return CL_SUCCESS; }
2092 static cl_int release(cl_mutable_command_khr)
2093 {
return CL_SUCCESS; }
2098#if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
2100static cl_uint getVersion(
const vector<char> &versionInfo)
2102 int highVersion = 0;
2105 while(versionInfo[index] !=
'.' ) {
2107 highVersion += versionInfo[index]-
'0';
2111 while(versionInfo[index] !=
' ' && versionInfo[index] !=
'\0') {
2113 lowVersion += versionInfo[index]-
'0';
2116 return (highVersion << 16) | lowVersion;
2119static cl_uint getPlatformVersion(cl_platform_id platform)
2122 clGetPlatformInfo(platform, CL_PLATFORM_VERSION, 0,
nullptr, &size);
2124 vector<char> versionInfo(size);
2125 clGetPlatformInfo(platform, CL_PLATFORM_VERSION, size, versionInfo.data(), &size);
2126 return getVersion(versionInfo);
2129static cl_uint getDevicePlatformVersion(cl_device_id device)
2131 cl_platform_id platform;
2132 clGetDeviceInfo(device, CL_DEVICE_PLATFORM,
sizeof(platform), &platform,
nullptr);
2133 return getPlatformVersion(platform);
2136static cl_uint getContextPlatformVersion(cl_context context)
2141 clGetContextInfo(context, CL_CONTEXT_DEVICES, 0,
nullptr, &size);
2144 vector<cl_device_id> devices(size/
sizeof(cl_device_id));
2145 clGetContextInfo(context, CL_CONTEXT_DEVICES, size, devices.data(),
nullptr);
2146 return getDevicePlatformVersion(devices[0]);
2150template <
typename T>
2160 Wrapper() : object_(
nullptr) { }
2162 Wrapper(
const cl_type &obj,
bool retainObject) : object_(obj)
2165 detail::errHandler(retain(), __RETAIN_ERR);
2171 if (object_ !=
nullptr) { release(); }
2174 Wrapper(
const Wrapper<cl_type>& rhs)
2176 object_ = rhs.object_;
2177 detail::errHandler(retain(), __RETAIN_ERR);
2180 Wrapper(Wrapper<cl_type>&& rhs)
noexcept
2182 object_ = rhs.object_;
2183 rhs.object_ =
nullptr;
2186 Wrapper<cl_type>& operator = (
const Wrapper<cl_type>& rhs)
2189 detail::errHandler(release(), __RELEASE_ERR);
2190 object_ = rhs.object_;
2191 detail::errHandler(retain(), __RETAIN_ERR);
2196 Wrapper<cl_type>& operator = (Wrapper<cl_type>&& rhs)
2199 detail::errHandler(release(), __RELEASE_ERR);
2200 object_ = rhs.object_;
2201 rhs.object_ =
nullptr;
2206 Wrapper<cl_type>& operator = (
const cl_type &rhs)
2208 detail::errHandler(release(), __RELEASE_ERR);
2213 const cl_type& operator ()()
const {
return object_; }
2215 cl_type& operator ()() {
return object_; }
2217 cl_type get()
const {
return object_; }
2220 template<
typename Func,
typename U>
2221 friend inline cl_int getInfoHelper(Func, cl_uint, U*,
int,
typename U::cl_type);
2223 cl_int retain()
const
2225 if (object_ !=
nullptr) {
2233 cl_int release()
const
2235 if (object_ !=
nullptr) {
2248 typedef cl_device_id cl_type;
2252 bool referenceCountable_;
2254 static bool isReferenceCountable(cl_device_id device)
2256 bool retVal =
false;
2257#if CL_HPP_TARGET_OPENCL_VERSION >= 120
2258#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
2259 if (device !=
nullptr) {
2260 int version = getDevicePlatformVersion(device);
2261 if(version > ((1 << 16) + 1)) {
2274 Wrapper() : object_(
nullptr), referenceCountable_(
false)
2278 Wrapper(
const cl_type &obj,
bool retainObject) :
2280 referenceCountable_(
false)
2282 referenceCountable_ = isReferenceCountable(obj);
2285 detail::errHandler(retain(), __RETAIN_ERR);
2294 Wrapper(
const Wrapper<cl_type>& rhs)
2296 object_ = rhs.object_;
2297 referenceCountable_ = isReferenceCountable(object_);
2298 detail::errHandler(retain(), __RETAIN_ERR);
2301 Wrapper(Wrapper<cl_type>&& rhs)
noexcept
2303 object_ = rhs.object_;
2304 referenceCountable_ = rhs.referenceCountable_;
2305 rhs.object_ =
nullptr;
2306 rhs.referenceCountable_ =
false;
2309 Wrapper<cl_type>& operator = (
const Wrapper<cl_type>& rhs)
2312 detail::errHandler(release(), __RELEASE_ERR);
2313 object_ = rhs.object_;
2314 referenceCountable_ = rhs.referenceCountable_;
2315 detail::errHandler(retain(), __RETAIN_ERR);
2320 Wrapper<cl_type>& operator = (Wrapper<cl_type>&& rhs)
2323 detail::errHandler(release(), __RELEASE_ERR);
2324 object_ = rhs.object_;
2325 referenceCountable_ = rhs.referenceCountable_;
2326 rhs.object_ =
nullptr;
2327 rhs.referenceCountable_ =
false;
2332 Wrapper<cl_type>& operator = (
const cl_type &rhs)
2334 detail::errHandler(release(), __RELEASE_ERR);
2336 referenceCountable_ = isReferenceCountable(object_);
2340 const cl_type& operator ()()
const {
return object_; }
2342 cl_type& operator ()() {
return object_; }
2344 cl_type get()
const {
return object_; }
2347 template<
typename Func,
typename U>
2348 friend inline cl_int getInfoHelper(Func, cl_uint, U*,
int,
typename U::cl_type);
2350 template<
typename Func,
typename U>
2351 friend inline cl_int getInfoHelper(Func, cl_uint, vector<U>*,
int,
typename U::cl_type);
2353 cl_int retain()
const
2355 if( object_ !=
nullptr && referenceCountable_ ) {
2363 cl_int release()
const
2365 if (object_ !=
nullptr && referenceCountable_) {
2374template <
typename T>
2375inline bool operator==(
const Wrapper<T> &lhs,
const Wrapper<T> &rhs)
2377 return lhs() == rhs();
2380template <
typename T>
2381inline bool operator!=(
const Wrapper<T> &lhs,
const Wrapper<T> &rhs)
2383 return !operator==(lhs, rhs);
2406 image_channel_order = order;
2407 image_channel_data_type = type;
2417 this->image_channel_data_type = rhs.image_channel_data_type;
2418 this->image_channel_order = rhs.image_channel_order;
2434 static std::once_flag default_initialized_;
2436 static cl_int default_error_;
2443 static void makeDefault();
2450 static void makeDefaultProvided(
const Device &p) {
2455#ifdef CL_HPP_UNIT_TEST_ENABLE
2462 static void unitTestClearDefault() {
2474 explicit Device(
const cl_device_id &device,
bool retainObject =
false) :
2475 detail::Wrapper<cl_type>(device, retainObject) { }
2482 cl_int *errResult =
nullptr)
2484 std::call_once(default_initialized_, makeDefault);
2485 detail::errHandler(default_error_);
2486 if (errResult !=
nullptr) {
2487 *errResult = default_error_;
2501 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_device));
2502 detail::errHandler(default_error_);
2518 template <
typename T>
2519 cl_int
getInfo(cl_device_info name, T* param)
const
2521 return detail::errHandler(
2522 detail::getInfo(&::clGetDeviceInfo, object_, name, param),
2523 __GET_DEVICE_INFO_ERR);
2527 template <cl_device_info name>
typename
2532 detail::cl_device_info, name>::param_type param;
2533 cl_int result =
getInfo(name, ¶m);
2534 if (err !=
nullptr) {
2540#if CL_HPP_TARGET_OPENCL_VERSION >= 210
2549 cl_ulong retVal = 0;
2551 clGetHostTimer(this->get(), &retVal);
2554 __GET_HOST_TIMER_ERR);
2573 std::pair<cl_ulong, cl_ulong> retVal;
2575 clGetDeviceAndHostTimer(this->get(), &(retVal.first), &(retVal.second));
2578 __GET_DEVICE_AND_HOST_TIMER_ERR);
2586#if CL_HPP_TARGET_OPENCL_VERSION >= 120
2589 vector<Device>* devices);
2592#if defined(cl_ext_device_fission)
2594 cl_int
createSubDevices(
const cl_device_partition_property_ext* properties,
2595 vector<Device>* devices);
2599using BuildLogType = vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, CL_PROGRAM_BUILD_LOG>::param_type>>;
2600#if defined(CL_HPP_ENABLE_EXCEPTIONS)
2604class BuildError :
public Error
2607 BuildLogType buildLogs;
2609 BuildError(cl_int err,
const char * errStr,
const BuildLogType &vec) : Error(err, errStr), buildLogs(vec)
2613 BuildLogType getBuildLog()
const
2619 static inline cl_int buildErrHandler(
2621 const char * errStr,
2622 const BuildLogType &buildLogs)
2624 if (err != CL_SUCCESS) {
2625 throw BuildError(err, errStr, buildLogs);
2633 static inline cl_int buildErrHandler(
2635 const char * errStr,
2636 const BuildLogType &buildLogs)
2645CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Device::default_initialized_;
2646CL_HPP_DEFINE_STATIC_MEMBER_ Device Device::default_;
2647CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Device::default_error_ = CL_SUCCESS;
2659 static std::once_flag default_initialized_;
2661 static cl_int default_error_;
2668 static void makeDefault() {
2672#if defined(CL_HPP_ENABLE_EXCEPTIONS)
2680 cl_int err = ::clGetPlatformIDs(0,
nullptr, &n);
2681 if (err != CL_SUCCESS) {
2682 default_error_ = err;
2686 default_error_ = CL_INVALID_PLATFORM;
2690 vector<cl_platform_id> ids(n);
2691 err = ::clGetPlatformIDs(n, ids.data(),
nullptr);
2692 if (err != CL_SUCCESS) {
2693 default_error_ = err;
2699#if defined(CL_HPP_ENABLE_EXCEPTIONS)
2700 catch (cl::Error &e) {
2701 default_error_ = e.err();
2711 static void makeDefaultProvided(
const Platform &p) {
2716#ifdef CL_HPP_UNIT_TEST_ENABLE
2723 static void unitTestClearDefault() {
2738 explicit Platform(
const cl_platform_id &platform,
bool retainObject =
false) :
2739 detail::Wrapper<cl_type>(platform, retainObject) { }
2752 cl_int *errResult =
nullptr)
2754 std::call_once(default_initialized_, makeDefault);
2755 detail::errHandler(default_error_);
2756 if (errResult !=
nullptr) {
2757 *errResult = default_error_;
2771 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_platform));
2772 detail::errHandler(default_error_);
2777 template <
typename T>
2778 cl_int
getInfo(cl_platform_info name, T* param)
const
2780 return detail::errHandler(
2781 detail::getInfo(&::clGetPlatformInfo, object_, name, param),
2782 __GET_PLATFORM_INFO_ERR);
2786 template <cl_platform_info name>
typename
2791 detail::cl_platform_info, name>::param_type param;
2792 cl_int result =
getInfo(name, ¶m);
2793 if (err !=
nullptr) {
2804 cl_device_type type,
2805 vector<Device>* devices)
const
2808 if( devices ==
nullptr ) {
2809 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR);
2811 cl_int err = ::clGetDeviceIDs(object_, type, 0,
nullptr, &n);
2812 if (err != CL_SUCCESS && err != CL_DEVICE_NOT_FOUND) {
2813 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2816 vector<cl_device_id> ids(n);
2818 err = ::clGetDeviceIDs(object_, type, n, ids.data(),
nullptr);
2819 if (err != CL_SUCCESS) {
2820 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2829 devices->resize(ids.size());
2833 for (size_type i = 0; i < ids.size(); i++) {
2834 (*devices)[i] =
Device(ids[i],
true);
2840#if defined(CL_HPP_USE_DX_INTEROP)
2865 cl_d3d10_device_source_khr d3d_device_source,
2867 cl_d3d10_device_set_khr d3d_device_set,
2868 vector<Device>* devices)
const
2870 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clGetDeviceIDsFromD3D10KHR)(
2871 cl_platform_id platform,
2872 cl_d3d10_device_source_khr d3d_device_source,
2874 cl_d3d10_device_set_khr d3d_device_set,
2875 cl_uint num_entries,
2876 cl_device_id * devices,
2877 cl_uint* num_devices);
2879 if( devices ==
nullptr ) {
2880 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR);
2883 static PFN_clGetDeviceIDsFromD3D10KHR pfn_clGetDeviceIDsFromD3D10KHR =
nullptr;
2884#if CL_HPP_TARGET_OPENCL_VERSION >= 120
2885 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(object_, clGetDeviceIDsFromD3D10KHR);
2887#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
2888 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetDeviceIDsFromD3D10KHR);
2892 cl_int err = pfn_clGetDeviceIDsFromD3D10KHR(
2900 if (err != CL_SUCCESS) {
2901 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2904 vector<cl_device_id> ids(n);
2905 err = pfn_clGetDeviceIDsFromD3D10KHR(
2913 if (err != CL_SUCCESS) {
2914 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2922 devices->resize(ids.size());
2926 for (size_type i = 0; i < ids.size(); i++) {
2927 (*devices)[i] = Device(ids[i],
true);
2939 vector<Platform>* platforms)
2943 if( platforms ==
nullptr ) {
2944 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_PLATFORM_IDS_ERR);
2947 cl_int err = ::clGetPlatformIDs(0,
nullptr, &n);
2948 if (err != CL_SUCCESS) {
2949 return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
2952 vector<cl_platform_id> ids(n);
2953 err = ::clGetPlatformIDs(n, ids.data(),
nullptr);
2954 if (err != CL_SUCCESS) {
2955 return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
2959 platforms->resize(ids.size());
2962 for (size_type i = 0; i < ids.size(); i++) {
2963 (*platforms)[i] =
Platform(ids[i]);
2977 Platform default_platform = Platform::getDefault(&err);
2979 *platform = default_platform;
2993 cl_int * errResult =
nullptr)
2996 Platform default_platform = Platform::getDefault(&err);
3000 return default_platform;
3003#if CL_HPP_TARGET_OPENCL_VERSION >= 120
3008 return ::clUnloadPlatformCompiler(object_);
3013#if CL_HPP_TARGET_OPENCL_VERSION >= 120
3016 vector<Device>* devices)
3019 cl_int err = clCreateSubDevices(object_, properties, 0,
nullptr, &n);
3020 if (err != CL_SUCCESS)
3022 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
3025 vector<cl_device_id> ids(n);
3026 err = clCreateSubDevices(object_, properties, n, ids.data(),
nullptr);
3027 if (err != CL_SUCCESS)
3029 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
3036 devices->resize(ids.size());
3040 for (size_type i = 0; i < ids.size(); i++)
3044 (*devices)[i] =
Device(ids[i],
false);
3052#if defined(cl_ext_device_fission)
3055 vector<Device>* devices)
3057#if CL_HPP_TARGET_OPENCL_VERSION >= 120
3059 cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>()();
3060 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCreateSubDevicesEXT);
3062#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
3063 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateSubDevicesEXT);
3067 cl_int err = pfn_clCreateSubDevicesEXT(object_, properties, 0,
nullptr, &n);
3068 if (err != CL_SUCCESS)
3070 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
3073 vector<cl_device_id> ids(n);
3075 pfn_clCreateSubDevicesEXT(object_, properties, n, ids.data(),
nullptr);
3076 if (err != CL_SUCCESS)
3078 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
3084 devices->resize(ids.size());
3088 for (size_type i = 0; i < ids.size(); i++)
3092 (*devices)[i] =
Device(ids[i],
false);
3100CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Platform::default_initialized_;
3101CL_HPP_DEFINE_STATIC_MEMBER_ Platform Platform::default_;
3102CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Platform::default_error_ = CL_SUCCESS;
3108#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
3113inline CL_API_PREFIX__VERSION_1_1_DEPRECATED cl_int
3118 return ::clUnloadCompiler();
3123#if defined(cl_ext_image_requirements_info)
3124enum ImageRequirementsInfoExt : cl_image_requirements_info_ext
3126 RowPitchAlign = CL_IMAGE_REQUIREMENTS_ROW_PITCH_ALIGNMENT_EXT,
3127 BaseAddAlign = CL_IMAGE_REQUIREMENTS_BASE_ADDRESS_ALIGNMENT_EXT,
3128 Size = CL_IMAGE_REQUIREMENTS_SIZE_EXT,
3129 MaxWidth = CL_IMAGE_REQUIREMENTS_MAX_WIDTH_EXT,
3130 MaxHeight = CL_IMAGE_REQUIREMENTS_MAX_HEIGHT_EXT,
3131 MaxDepth = CL_IMAGE_REQUIREMENTS_MAX_DEPTH_EXT,
3132 MaxArraySize = CL_IMAGE_REQUIREMENTS_MAX_ARRAY_SIZE_EXT,
3133#if defined(cl_ext_image_from_buffer)
3134 SlicePitchAlign = CL_IMAGE_REQUIREMENTS_SLICE_PITCH_ALIGNMENT_EXT,
3153 static std::once_flag default_initialized_;
3155 static cl_int default_error_;
3162 static void makeDefault() {
3166#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3170#if !defined(__APPLE__) && !defined(__MACOS)
3171 const Platform &p = Platform::getDefault();
3172 cl_platform_id defaultPlatform = p();
3173 cl_context_properties properties[3] = {
3174 CL_CONTEXT_PLATFORM, (cl_context_properties)defaultPlatform, 0
3177 cl_context_properties *properties =
nullptr;
3181 CL_DEVICE_TYPE_DEFAULT,
3187#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3188 catch (cl::Error &e) {
3189 default_error_ = e.err();
3200 static void makeDefaultProvided(
const Context &c) {
3204#if defined(cl_ext_image_requirements_info)
3205 struct ImageRequirementsInfo {
3207 ImageRequirementsInfo(cl_mem_flags f,
const cl_mem_properties* properties,
const ImageFormat* format,
const cl_image_desc* desc)
3210 properties = properties;
3211 image_format = format;
3215 cl_mem_flags flags = 0;
3216 const cl_mem_properties* properties;
3218 const cl_image_desc* image_desc;
3221 static cl_int getImageRequirementsInfoExtHelper(
const Context &context,
3222 const ImageRequirementsInfo &info,
3223 cl_image_requirements_info_ext param_name,
3224 size_type param_value_size,
3226 size_type* param_value_size_ret)
3229#if CL_HPP_TARGET_OPENCL_VERSION >= 120
3230 Device device = context.
getInfo<CL_CONTEXT_DEVICES>().at(0);
3231 cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>()();
3232 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clGetImageRequirementsInfoEXT);
3234 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetImageRequirementsInfoEXT);
3237 if (pfn_clGetImageRequirementsInfoEXT ==
nullptr) {
3238 return detail::errHandler(CL_INVALID_OPERATION, __GET_IMAGE_REQUIREMENT_INFO_EXT_ERR);
3241 return detail::errHandler(
3242 pfn_clGetImageRequirementsInfoEXT(context(), info.properties,
3243 info.flags, info.image_format, info.image_desc, param_name,
3244 param_value_size, param_value, param_value_size_ret),
3245 __GET_IMAGE_REQUIREMENT_INFO_EXT_ERR);
3250#ifdef CL_HPP_UNIT_TEST_ENABLE
3257 static void unitTestClearDefault() {
3267 const vector<Device>& devices,
3268 const cl_context_properties* properties =
nullptr,
3269 void (CL_CALLBACK * notifyFptr)(
3274 void* data =
nullptr,
3275 cl_int* err =
nullptr)
3279 size_type numDevices = devices.size();
3280 vector<cl_device_id> deviceIDs(numDevices);
3282 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
3283 deviceIDs[deviceIndex] = (devices[deviceIndex])();
3286 object_ = ::clCreateContext(
3287 properties, (cl_uint) numDevices,
3289 notifyFptr, data, &error);
3291 detail::errHandler(error, __CREATE_CONTEXT_ERR);
3292 if (err !=
nullptr) {
3303 const cl_context_properties* properties =
nullptr,
3304 void (CL_CALLBACK * notifyFptr)(
3309 void* data =
nullptr,
3310 cl_int* err =
nullptr)
3314 cl_device_id deviceID = device();
3316 object_ = ::clCreateContext(
3319 notifyFptr, data, &error);
3321 detail::errHandler(error, __CREATE_CONTEXT_ERR);
3322 if (err !=
nullptr) {
3332 cl_device_type type,
3333 const cl_context_properties* properties =
nullptr,
3334 void (CL_CALLBACK * notifyFptr)(
3339 void* data =
nullptr,
3340 cl_int* err =
nullptr)
3344#if !defined(__APPLE__) && !defined(__MACOS)
3345 cl_context_properties prop[4] = {CL_CONTEXT_PLATFORM, 0, 0, 0 };
3347 if (properties ==
nullptr) {
3349 vector<Platform> platforms;
3350 error = Platform::get(&platforms);
3351 if (error != CL_SUCCESS) {
3352 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
3353 if (err !=
nullptr) {
3360 cl_context_properties platform_id = 0;
3361 for (
unsigned int i = 0; i < platforms.size(); i++) {
3363 vector<Device> devices;
3365#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3369 error = platforms[i].getDevices(type, &devices);
3371#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3372 }
catch (cl::Error& e) {
3380 if (error != CL_SUCCESS && error != CL_DEVICE_NOT_FOUND) {
3381 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
3382 if (err !=
nullptr) {
3387 if (devices.size() > 0) {
3388 platform_id = (cl_context_properties)platforms[i]();
3393 if (platform_id == 0) {
3394 detail::errHandler(CL_DEVICE_NOT_FOUND, __CREATE_CONTEXT_FROM_TYPE_ERR);
3395 if (err !=
nullptr) {
3396 *err = CL_DEVICE_NOT_FOUND;
3401 prop[1] = platform_id;
3402 properties = &prop[0];
3405 object_ = ::clCreateContextFromType(
3406 properties, type, notifyFptr, data, &error);
3408 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
3409 if (err !=
nullptr) {
3421 std::call_once(default_initialized_, makeDefault);
3422 detail::errHandler(default_error_);
3423 if (err !=
nullptr) {
3424 *err = default_error_;
3438 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_context));
3439 detail::errHandler(default_error_);
3451 explicit Context(
const cl_context& context,
bool retainObject =
false) :
3452 detail::Wrapper<cl_type>(context, retainObject) { }
3466 template <
typename T>
3467 cl_int
getInfo(cl_context_info name, T* param)
const
3469 return detail::errHandler(
3470 detail::getInfo(&::clGetContextInfo, object_, name, param),
3471 __GET_CONTEXT_INFO_ERR);
3475 template <cl_context_info name>
typename
3480 detail::cl_context_info, name>::param_type param;
3481 cl_int result =
getInfo(name, ¶m);
3482 if (err !=
nullptr) {
3494 cl_mem_object_type type,
3495 vector<ImageFormat>* formats)
const
3503 cl_int err = ::clGetSupportedImageFormats(
3510 if (err != CL_SUCCESS) {
3511 return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
3514 if (numEntries > 0) {
3515 vector<ImageFormat> value(numEntries);
3516 err = ::clGetSupportedImageFormats(
3521 (cl_image_format*)value.data(),
3523 if (err != CL_SUCCESS) {
3524 return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
3527 formats->assign(value.begin(), value.end());
3537#if defined(cl_ext_image_requirements_info)
3538 template <
typename T>
3539 cl_int getImageRequirementsInfoExt(cl_image_requirements_info_ext name,
3541 cl_mem_flags flags = 0,
3542 const cl_mem_properties* properties =
nullptr,
3544 const cl_image_desc* image_desc =
nullptr)
const
3546 ImageRequirementsInfo imageInfo = {flags, properties, image_format, image_desc};
3548 return detail::errHandler(
3550 Context::getImageRequirementsInfoExtHelper, *
this, imageInfo, name, param),
3551 __GET_IMAGE_REQUIREMENT_INFO_EXT_ERR);
3554 template <cl_image_requirements_info_ext type>
typename
3555 detail::param_traits<detail::cl_image_requirements_info_ext, type>::param_type
3556 getImageRequirementsInfoExt(cl_mem_flags flags = 0,
3557 const cl_mem_properties* properties =
nullptr,
3558 const ImageFormat* image_format =
nullptr,
3559 const cl_image_desc* image_desc =
nullptr,
3560 cl_int* err =
nullptr)
const
3562 typename detail::param_traits<
3563 detail::cl_image_requirements_info_ext, type>::param_type param;
3564 cl_int result = getImageRequirementsInfoExt(type, ¶m, flags, properties, image_format, image_desc);
3565 if (err !=
nullptr) {
3572#if CL_HPP_TARGET_OPENCL_VERSION >= 300
3584 void (CL_CALLBACK * pfn_notify)(cl_context,
void *),
3585 void * user_data =
nullptr)
3587 return detail::errHandler(
3588 ::clSetContextDestructorCallback(
3592 __SET_CONTEXT_DESCTRUCTOR_CALLBACK_ERR);
3597inline void Device::makeDefault()
3602#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3609 detail::errHandler(error, __CREATE_CONTEXT_ERR);
3611 if (error != CL_SUCCESS) {
3612 default_error_ = error;
3615 default_ = context.
getInfo<CL_CONTEXT_DEVICES>()[0];
3616 default_error_ = CL_SUCCESS;
3619#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3620 catch (cl::Error &e) {
3621 default_error_ = e.err();
3626CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Context::default_initialized_;
3627CL_HPP_DEFINE_STATIC_MEMBER_ Context Context::default_;
3628CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Context::default_error_ = CL_SUCCESS;
3642 Event() : detail::Wrapper<cl_type>() { }
3652 explicit Event(
const cl_event& event,
bool retainObject =
false) :
3653 detail::Wrapper<cl_type>(event, retainObject) { }
3667 template <
typename T>
3668 cl_int
getInfo(cl_event_info name, T* param)
const
3670 return detail::errHandler(
3671 detail::getInfo(&::clGetEventInfo, object_, name, param),
3672 __GET_EVENT_INFO_ERR);
3676 template <cl_event_info name>
typename
3681 detail::cl_event_info, name>::param_type param;
3682 cl_int result =
getInfo(name, ¶m);
3683 if (err !=
nullptr) {
3690 template <
typename T>
3693 return detail::errHandler(detail::getInfo(
3694 &::clGetEventProfilingInfo, object_, name, param),
3695 __GET_EVENT_PROFILE_INFO_ERR);
3699 template <cl_profiling_info name>
typename
3704 detail::cl_profiling_info, name>::param_type param;
3706 if (err !=
nullptr) {
3718 return detail::errHandler(
3719 ::clWaitForEvents(1, &object_),
3720 __WAIT_FOR_EVENTS_ERR);
3723#if CL_HPP_TARGET_OPENCL_VERSION >= 110
3730 void (CL_CALLBACK * pfn_notify)(cl_event, cl_int,
void *),
3731 void * user_data =
nullptr)
3733 return detail::errHandler(
3734 ::clSetEventCallback(
3739 __SET_EVENT_CALLBACK_ERR);
3750 static_assert(
sizeof(
cl::Event) ==
sizeof(cl_event),
3751 "Size of cl::Event must be equal to size of cl_event");
3753 return detail::errHandler(
3755 (cl_uint) events.size(), (events.size() > 0) ? (cl_event*)&events.front() :
nullptr),
3756 __WAIT_FOR_EVENTS_ERR);
3760#if CL_HPP_TARGET_OPENCL_VERSION >= 110
3774 cl_int * err =
nullptr)
3777 object_ = ::clCreateUserEvent(
3781 detail::errHandler(error, __CREATE_USER_EVENT_ERR);
3782 if (err !=
nullptr) {
3796 return detail::errHandler(
3797 ::clSetUserEventStatus(object_,status),
3798 __SET_USER_EVENT_STATUS_ERR);
3808WaitForEvents(
const vector<Event>& events)
3810 return detail::errHandler(
3812 (cl_uint) events.size(), (events.size() > 0) ? (cl_event*)&events.front() : nullptr),
3813 __WAIT_FOR_EVENTS_ERR);
3841 explicit Memory(
const cl_mem& memory,
bool retainObject) :
3842 detail::Wrapper<cl_type>(memory, retainObject) { }
3856 template <
typename T>
3859 return detail::errHandler(
3860 detail::getInfo(&::clGetMemObjectInfo, object_, name, param),
3861 __GET_MEM_OBJECT_INFO_ERR);
3865 template <cl_mem_info name>
typename
3870 detail::cl_mem_info, name>::param_type param;
3871 cl_int result =
getInfo(name, ¶m);
3872 if (err !=
nullptr) {
3878#if CL_HPP_TARGET_OPENCL_VERSION >= 110
3893 void (CL_CALLBACK * pfn_notify)(cl_mem,
void *),
3894 void * user_data =
nullptr)
3896 return detail::errHandler(
3897 ::clSetMemObjectDestructorCallback(
3901 __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR);
3909template<
typename IteratorType >
3910cl_int
copy( IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer );
3911template<
typename IteratorType >
3912cl_int
copy(
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator );
3913template<
typename IteratorType >
3914cl_int
copy(
const CommandQueue &queue, IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer );
3915template<
typename IteratorType >
3916cl_int
copy(
const CommandQueue &queue,
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator );
3919#if CL_HPP_TARGET_OPENCL_VERSION >= 200
3925 static cl_svm_mem_flags getSVMMemFlags()
3932template<
class Trait = detail::SVMTraitNull>
3936 static cl_svm_mem_flags getSVMMemFlags()
3938 return CL_MEM_READ_WRITE |
3939 Trait::getSVMMemFlags();
3943template<
class Trait = detail::SVMTraitNull>
3947 static cl_svm_mem_flags getSVMMemFlags()
3949 return CL_MEM_READ_ONLY |
3950 Trait::getSVMMemFlags();
3954template<
class Trait = detail::SVMTraitNull>
3958 static cl_svm_mem_flags getSVMMemFlags()
3960 return CL_MEM_WRITE_ONLY |
3961 Trait::getSVMMemFlags();
3965template<
class Trait = SVMTraitReadWrite<>>
3969 static cl_svm_mem_flags getSVMMemFlags()
3971 return Trait::getSVMMemFlags();
3975template<
class Trait = SVMTraitReadWrite<>>
3979 static cl_svm_mem_flags getSVMMemFlags()
3981 return CL_MEM_SVM_FINE_GRAIN_BUFFER |
3982 Trait::getSVMMemFlags();
3986template<
class Trait = SVMTraitReadWrite<>>
3990 static cl_svm_mem_flags getSVMMemFlags()
3993 CL_MEM_SVM_FINE_GRAIN_BUFFER |
3994 CL_MEM_SVM_ATOMICS |
3995 Trait::getSVMMemFlags();
4006 const vector<Event>* events =
nullptr,
4007 Event* event =
nullptr);
4020template<
typename T,
class SVMTrait>
4026 typedef T value_type;
4027 typedef value_type* pointer;
4028 typedef const value_type* const_pointer;
4029 typedef value_type& reference;
4030 typedef const value_type& const_reference;
4031 typedef std::size_t size_type;
4032 typedef std::ptrdiff_t difference_type;
4034 template<
typename U>
4037 typedef SVMAllocator<U, SVMTrait> other;
4040 template<
typename U,
typename V>
4044 context_(
Context::getDefault())
4054 SVMAllocator(
const SVMAllocator &other) :
4055 context_(other.context_)
4059 template<
typename U>
4060 SVMAllocator(
const SVMAllocator<U, SVMTrait> &other) :
4061 context_(other.context_)
4069 pointer address(reference r)
noexcept
4071 return std::addressof(r);
4074 const_pointer address(const_reference r)
noexcept
4076 return std::addressof(r);
4087 typename cl::SVMAllocator<void, SVMTrait>::const_pointer = 0,
4094 SVMTrait::getSVMMemFlags(),
4097 pointer retValue =
reinterpret_cast<pointer
>(
4099#if defined(CL_HPP_ENABLE_EXCEPTIONS)
4101 std::bad_alloc excep;
4107 if (map && !(SVMTrait::getSVMMemFlags() & CL_MEM_SVM_FINE_GRAIN_BUFFER)) {
4108 cl_int err =
enqueueMapSVM(retValue, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE, size*
sizeof(T));
4109 if (err != CL_SUCCESS) {
4110 clSVMFree(context_(), retValue);
4112#if defined(CL_HPP_ENABLE_EXCEPTIONS)
4113 std::bad_alloc excep;
4123 void deallocate(pointer p, size_type)
4125 clSVMFree(context_(), p);
4134 size_type maxSize = std::numeric_limits<size_type>::max() /
sizeof(T);
4136 for (
const Device &d : context_.
getInfo<CL_CONTEXT_DEVICES>()) {
4139 static_cast<size_type
>(d.getInfo<CL_DEVICE_MAX_MEM_ALLOC_SIZE>()));
4145 template<
class U,
class... Args >
4146 void construct(U* p, Args&&... args)
4162 return (context_==rhs.context_);
4172template<
class SVMTrait>
4175 typedef void value_type;
4176 typedef value_type* pointer;
4177 typedef const value_type* const_pointer;
4179 template<
typename U>
4182 typedef SVMAllocator<U, SVMTrait> other;
4185 template<
typename U,
typename V>
4189#if !defined(CL_HPP_NO_STD_UNIQUE_PTR)
4192 template<
class Alloc>
4199 typedef typename std::allocator_traits<Alloc>::pointer pointer;
4201 Deleter(
const Alloc &alloc, size_type copies) : alloc_{ alloc }, copies_{ copies }
4205 void operator()(pointer ptr)
const {
4206 Alloc tmpAlloc{ alloc_ };
4207 std::allocator_traits<Alloc>::destroy(tmpAlloc, std::addressof(*ptr));
4208 std::allocator_traits<Alloc>::deallocate(tmpAlloc, ptr, copies_);
4219template <
class T,
class Alloc,
class... Args>
4222 Alloc alloc(alloc_);
4223 static const size_type copies = 1;
4228 T* tmp = std::allocator_traits<Alloc>::allocate(alloc, copies);
4230 std::bad_alloc excep;
4234 std::allocator_traits<Alloc>::construct(
4236 std::addressof(*tmp),
4237 std::forward<Args>(args)...);
4241 catch (std::bad_alloc&)
4243 std::allocator_traits<Alloc>::deallocate(alloc, tmp, copies);
4248template<
class T,
class SVMTrait,
class... Args >
4249cl::pointer<T, detail::Deleter<SVMAllocator<T, SVMTrait>>> allocate_svm(Args... args)
4251 SVMAllocator<T, SVMTrait> alloc;
4252 return cl::allocate_pointer<T>(alloc, args...);
4255template<
class T,
class SVMTrait,
class... Args >
4256cl::pointer<T, detail::Deleter<SVMAllocator<T, SVMTrait>>> allocate_svm(
const cl::Context &c, Args... args)
4258 SVMAllocator<T, SVMTrait> alloc(c);
4259 return cl::allocate_pointer<T>(alloc, args...);
4305 void* host_ptr =
nullptr,
4306 cl_int* err =
nullptr)
4309 object_ = ::clCreateBuffer(context(), flags, size, host_ptr, &error);
4311 detail::errHandler(error, __CREATE_BUFFER_ERR);
4312 if (err !=
nullptr) {
4317#if CL_HPP_TARGET_OPENCL_VERSION >= 300
4330 const vector<cl_mem_properties>& properties,
4333 void* host_ptr =
nullptr,
4334 cl_int* err =
nullptr)
4338 if (properties.empty()) {
4339 object_ = ::clCreateBufferWithProperties(context(),
nullptr, flags,
4340 size, host_ptr, &error);
4343 object_ = ::clCreateBufferWithProperties(
4344 context(), properties.data(), flags, size, host_ptr, &error);
4347 detail::errHandler(error, __CREATE_BUFFER_ERR);
4348 if (err !=
nullptr) {
4366 void* host_ptr =
nullptr,
4367 cl_int* err =
nullptr) :
Buffer(
Context::getDefault(err), flags, size, host_ptr, err) { }
4369#if CL_HPP_TARGET_OPENCL_VERSION >= 300
4383 const vector<cl_mem_properties>& properties,
4386 void* host_ptr =
nullptr,
4387 cl_int* err =
nullptr) :
Buffer(
Context::getDefault(err), properties, flags, size, host_ptr, err) { }
4395 template<
typename IteratorType >
4397 IteratorType startIterator,
4398 IteratorType endIterator,
4400 bool useHostPtr =
false,
4401 cl_int* err =
nullptr)
4403 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
4406 cl_mem_flags flags = 0;
4408 flags |= CL_MEM_READ_ONLY;
4411 flags |= CL_MEM_READ_WRITE;
4414 flags |= CL_MEM_USE_HOST_PTR;
4417 size_type size =
sizeof(DataType)*(endIterator - startIterator);
4422 object_ = ::clCreateBuffer(context(), flags, size,
const_cast<DataType*
>(&*startIterator), &error);
4424 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
4427 detail::errHandler(error, __CREATE_BUFFER_ERR);
4428 if (err !=
nullptr) {
4433 error =
cl::copy(startIterator, endIterator, *
this);
4434 detail::errHandler(error, __CREATE_BUFFER_ERR);
4435 if (err !=
nullptr) {
4446 template<
typename IteratorType >
4447 Buffer(
const Context &context, IteratorType startIterator, IteratorType endIterator,
4448 bool readOnly,
bool useHostPtr =
false, cl_int* err =
nullptr);
4454 template<
typename IteratorType >
4455 Buffer(
const CommandQueue &queue, IteratorType startIterator, IteratorType endIterator,
4456 bool readOnly,
bool useHostPtr =
false, cl_int* err =
nullptr);
4468 explicit Buffer(
const cl_mem& buffer,
bool retainObject =
false) :
4469 Memory(buffer, retainObject) { }
4482#if CL_HPP_TARGET_OPENCL_VERSION >= 110
4489 cl_buffer_create_type buffer_create_type,
4490 const void * buffer_create_info,
4491 cl_int * err =
nullptr)
4495 result.object_ = ::clCreateSubBuffer(
4502 detail::errHandler(error, __CREATE_SUBBUFFER_ERR);
4503 if (err !=
nullptr) {
4512#if defined (CL_HPP_USE_DX_INTEROP)
4521class BufferD3D10 :
public Buffer
4532 const Context& context,
4534 ID3D10Buffer* bufobj,
4535 cl_int * err =
nullptr) : pfn_clCreateFromD3D10BufferKHR(nullptr)
4537 typedef CL_API_ENTRY cl_mem (CL_API_CALL *PFN_clCreateFromD3D10BufferKHR)(
4538 cl_context context, cl_mem_flags flags, ID3D10Buffer* buffer,
4539 cl_int* errcode_ret);
4540 PFN_clCreateFromD3D10BufferKHR pfn_clCreateFromD3D10BufferKHR;
4541#if CL_HPP_TARGET_OPENCL_VERSION >= 120
4542 vector<cl_context_properties> props = context.getInfo<CL_CONTEXT_PROPERTIES>();
4543 cl_platform platform =
nullptr;
4544 for(
int i = 0; i < props.size(); ++i ) {
4545 if( props[i] == CL_CONTEXT_PLATFORM ) {
4546 platform = props[i+1];
4549 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCreateFromD3D10BufferKHR);
4551#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
4552 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateFromD3D10BufferKHR);
4556 object_ = pfn_clCreateFromD3D10BufferKHR(
4563 detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
4564 if (err !=
nullptr) {
4570 BufferD3D10() : Buffer() { }
4579 explicit BufferD3D10(
const cl_mem& buffer,
bool retainObject =
false) :
4580 Buffer(buffer, retainObject) { }
4586 BufferD3D10& operator = (
const cl_mem& rhs)
4614 cl_int * err =
nullptr)
4617 object_ = ::clCreateFromGLBuffer(
4623 detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
4624 if (err !=
nullptr) {
4639 explicit BufferGL(
const cl_mem& buffer,
bool retainObject =
false) :
4640 Buffer(buffer, retainObject) { }
4655 cl_gl_object_type *type,
4656 cl_GLuint * gl_object_name)
4658 return detail::errHandler(
4659 ::clGetGLObjectInfo(object_,type,gl_object_name),
4660 __GET_GL_OBJECT_INFO_ERR);
4684 cl_int * err =
nullptr)
4687 object_ = ::clCreateFromGLRenderbuffer(
4693 detail::errHandler(error, __CREATE_GL_RENDER_BUFFER_ERR);
4694 if (err !=
nullptr) {
4710 Buffer(buffer, retainObject) { }
4725 cl_gl_object_type *type,
4726 cl_GLuint * gl_object_name)
4728 return detail::errHandler(
4729 ::clGetGLObjectInfo(object_,type,gl_object_name),
4730 __GET_GL_OBJECT_INFO_ERR);
4753 explicit Image(
const cl_mem& image,
bool retainObject =
false) :
4754 Memory(image, retainObject) { }
4769 template <
typename T>
4772 return detail::errHandler(
4773 detail::getInfo(&::clGetImageInfo, object_, name, param),
4774 __GET_IMAGE_INFO_ERR);
4778 template <cl_image_info name>
typename
4783 detail::cl_image_info, name>::param_type param;
4785 if (err !=
nullptr) {
4792#if CL_HPP_TARGET_OPENCL_VERSION >= 120
4811 void* host_ptr =
nullptr,
4812 cl_int* err =
nullptr)
4816 cl_image_desc desc = {};
4817 desc.image_type = CL_MEM_OBJECT_IMAGE1D;
4818 desc.image_width = width;
4820 object_ = ::clCreateImage(
4828 detail::errHandler(error, __CREATE_IMAGE_ERR);
4829 if (err !=
nullptr) {
4844 explicit Image1D(
const cl_mem& image1D,
bool retainObject =
false) :
4845 Image(image1D, retainObject) { }
4872 cl_int* err =
nullptr)
4876 cl_image_desc desc = {};
4877 desc.image_type = CL_MEM_OBJECT_IMAGE1D_BUFFER;
4878 desc.image_width = width;
4879 desc.buffer = buffer();
4881 object_ = ::clCreateImage(
4889 detail::errHandler(error, __CREATE_IMAGE_ERR);
4890 if (err !=
nullptr) {
4905 Image(image1D, retainObject) { }
4927 size_type arraySize,
4930 void* host_ptr =
nullptr,
4931 cl_int* err =
nullptr)
4935 cl_image_desc desc = {};
4936 desc.image_type = CL_MEM_OBJECT_IMAGE1D_ARRAY;
4937 desc.image_width = width;
4938 desc.image_array_size = arraySize;
4939 desc.image_row_pitch = rowPitch;
4941 object_ = ::clCreateImage(
4949 detail::errHandler(error, __CREATE_IMAGE_ERR);
4950 if (err !=
nullptr) {
4964 explicit Image1DArray(
const cl_mem& imageArray,
bool retainObject =
false) :
4965 Image(imageArray, retainObject) { }
4998 size_type row_pitch = 0,
4999 void* host_ptr =
nullptr,
5000 cl_int* err =
nullptr)
5003 bool useCreateImage;
5005#if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
5008 cl_uint version = detail::getContextPlatformVersion(context());
5009 useCreateImage = (version >= 0x10002);
5011#elif CL_HPP_TARGET_OPENCL_VERSION >= 120
5012 useCreateImage =
true;
5014 useCreateImage =
false;
5017#if CL_HPP_TARGET_OPENCL_VERSION >= 120
5020 cl_image_desc desc = {};
5021 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
5022 desc.image_width = width;
5023 desc.image_height = height;
5024 desc.image_row_pitch = row_pitch;
5026 object_ = ::clCreateImage(
5034 detail::errHandler(error, __CREATE_IMAGE_ERR);
5035 if (err !=
nullptr) {
5040#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
5041 if (!useCreateImage)
5043 object_ = ::clCreateImage2D(
5044 context(), flags,&format, width, height, row_pitch, host_ptr, &error);
5046 detail::errHandler(error, __CREATE_IMAGE2D_ERR);
5047 if (err !=
nullptr) {
5054#if CL_HPP_TARGET_OPENCL_VERSION >= 120
5066 const Buffer &sourceBuffer,
5069 size_type row_pitch = 0,
5070 cl_int* err =
nullptr)
5074 cl_image_desc desc = {};
5075 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
5076 desc.image_width = width;
5077 desc.image_height = height;
5078 desc.image_row_pitch = row_pitch;
5079 desc.buffer = sourceBuffer();
5081 object_ = ::clCreateImage(
5089 detail::errHandler(error, __CREATE_IMAGE_ERR);
5090 if (err !=
nullptr) {
5096#if CL_HPP_TARGET_OPENCL_VERSION >= 200
5111 cl_channel_order order,
5112 const Image &sourceImage,
5113 cl_int* err =
nullptr)
5118 size_type sourceWidth =
5119 sourceImage.getImageInfo<CL_IMAGE_WIDTH>();
5120 size_type sourceHeight =
5121 sourceImage.getImageInfo<CL_IMAGE_HEIGHT>();
5122 size_type sourceRowPitch =
5123 sourceImage.getImageInfo<CL_IMAGE_ROW_PITCH>();
5124 cl_uint sourceNumMIPLevels =
5125 sourceImage.getImageInfo<CL_IMAGE_NUM_MIP_LEVELS>();
5126 cl_uint sourceNumSamples =
5127 sourceImage.getImageInfo<CL_IMAGE_NUM_SAMPLES>();
5128 cl_image_format sourceFormat =
5129 sourceImage.getImageInfo<CL_IMAGE_FORMAT>();
5133 sourceFormat.image_channel_order = order;
5135 cl_image_desc desc = {};
5136 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
5137 desc.image_width = sourceWidth;
5138 desc.image_height = sourceHeight;
5139 desc.image_row_pitch = sourceRowPitch;
5140 desc.num_mip_levels = sourceNumMIPLevels;
5141 desc.num_samples = sourceNumSamples;
5142 desc.buffer = sourceImage();
5144 object_ = ::clCreateImage(
5152 detail::errHandler(error, __CREATE_IMAGE_ERR);
5153 if (err !=
nullptr) {
5169 explicit Image2D(
const cl_mem& image2D,
bool retainObject =
false) :
5170 Image(image2D, retainObject) { }
5188#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
5212 cl_int * err =
nullptr)
5215 object_ = ::clCreateFromGLTexture2D(
5223 detail::errHandler(error, __CREATE_GL_TEXTURE_2D_ERR);
5224 if (err !=
nullptr) {
5240 explicit Image2DGL(
const cl_mem& image,
bool retainObject =
false) :
5241 Image2D(image, retainObject) { }
5249 Image2D::operator=(rhs);
5255} CL_API_SUFFIX__VERSION_1_1_DEPRECATED;
5258#if CL_HPP_TARGET_OPENCL_VERSION >= 120
5269 size_type arraySize,
5273 size_type slicePitch,
5274 void* host_ptr =
nullptr,
5275 cl_int* err =
nullptr)
5279 cl_image_desc desc = {};
5280 desc.image_type = CL_MEM_OBJECT_IMAGE2D_ARRAY;
5281 desc.image_width = width;
5282 desc.image_height = height;
5283 desc.image_array_size = arraySize;
5284 desc.image_row_pitch = rowPitch;
5285 desc.image_slice_pitch = slicePitch;
5287 object_ = ::clCreateImage(
5295 detail::errHandler(error, __CREATE_IMAGE_ERR);
5296 if (err !=
nullptr) {
5310 explicit Image2DArray(
const cl_mem& imageArray,
bool retainObject =
false) :
Image(imageArray, retainObject) { }
5341 size_type row_pitch = 0,
5342 size_type slice_pitch = 0,
5343 void* host_ptr =
nullptr,
5344 cl_int* err =
nullptr)
5347 bool useCreateImage;
5349#if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
5352 cl_uint version = detail::getContextPlatformVersion(context());
5353 useCreateImage = (version >= 0x10002);
5355#elif CL_HPP_TARGET_OPENCL_VERSION >= 120
5356 useCreateImage =
true;
5358 useCreateImage =
false;
5361#if CL_HPP_TARGET_OPENCL_VERSION >= 120
5364 cl_image_desc desc = {};
5365 desc.image_type = CL_MEM_OBJECT_IMAGE3D;
5366 desc.image_width = width;
5367 desc.image_height = height;
5368 desc.image_depth = depth;
5369 desc.image_row_pitch = row_pitch;
5370 desc.image_slice_pitch = slice_pitch;
5372 object_ = ::clCreateImage(
5380 detail::errHandler(error, __CREATE_IMAGE_ERR);
5381 if (err !=
nullptr) {
5386#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
5387 if (!useCreateImage)
5389 object_ = ::clCreateImage3D(
5390 context(), flags, &format, width, height, depth, row_pitch,
5391 slice_pitch, host_ptr, &error);
5393 detail::errHandler(error, __CREATE_IMAGE3D_ERR);
5394 if (err !=
nullptr) {
5411 explicit Image3D(
const cl_mem& image3D,
bool retainObject =
false) :
5412 Image(image3D, retainObject) { }
5426#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
5449 cl_int * err =
nullptr)
5452 object_ = ::clCreateFromGLTexture3D(
5460 detail::errHandler(error, __CREATE_GL_TEXTURE_3D_ERR);
5461 if (err !=
nullptr) {
5476 explicit Image3DGL(
const cl_mem& image,
bool retainObject =
false) :
5477 Image3D(image, retainObject) { }
5492#if CL_HPP_TARGET_OPENCL_VERSION >= 120
5508 cl_int * err =
nullptr)
5511 object_ = ::clCreateFromGLTexture(
5519 detail::errHandler(error, __CREATE_GL_TEXTURE_ERR);
5520 if (err !=
nullptr) {
5534 explicit ImageGL(
const cl_mem& image,
bool retainObject =
false) :
5535 Image(image, retainObject) { }
5537 ImageGL& operator = (
const cl_mem& rhs)
5548#if CL_HPP_TARGET_OPENCL_VERSION >= 200
5570 cl_uint packet_size,
5571 cl_uint max_packets,
5572 cl_int* err =
nullptr)
5576 cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS;
5577 object_ = ::clCreatePipe(context(), flags, packet_size, max_packets,
nullptr, &error);
5579 detail::errHandler(error, __CREATE_PIPE_ERR);
5580 if (err !=
nullptr) {
5594 cl_uint packet_size,
5595 cl_uint max_packets,
5596 cl_int* err =
nullptr)
5602 cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS;
5603 object_ = ::clCreatePipe(context(), flags, packet_size, max_packets,
nullptr, &error);
5605 detail::errHandler(error, __CREATE_PIPE_ERR);
5606 if (err !=
nullptr) {
5621 explicit Pipe(
const cl_mem& pipe,
bool retainObject =
false) :
5622 Memory(pipe, retainObject) { }
5637 template <
typename T>
5640 return detail::errHandler(
5641 detail::getInfo(&::clGetPipeInfo, object_, name, param),
5642 __GET_PIPE_INFO_ERR);
5646 template <cl_pipe_info name>
typename
5651 detail::cl_pipe_info, name>::param_type param;
5652 cl_int result =
getInfo(name, ¶m);
5653 if (err !=
nullptr) {
5682 cl_bool normalized_coords,
5683 cl_addressing_mode addressing_mode,
5684 cl_filter_mode filter_mode,
5685 cl_int* err =
nullptr)
5689#if CL_HPP_TARGET_OPENCL_VERSION >= 200
5690 cl_sampler_properties sampler_properties[] = {
5691 CL_SAMPLER_NORMALIZED_COORDS, normalized_coords,
5692 CL_SAMPLER_ADDRESSING_MODE, addressing_mode,
5693 CL_SAMPLER_FILTER_MODE, filter_mode,
5695 object_ = ::clCreateSamplerWithProperties(
5700 detail::errHandler(error, __CREATE_SAMPLER_WITH_PROPERTIES_ERR);
5701 if (err !=
nullptr) {
5705 object_ = ::clCreateSampler(
5712 detail::errHandler(error, __CREATE_SAMPLER_ERR);
5713 if (err !=
nullptr) {
5727 explicit Sampler(
const cl_sampler& sampler,
bool retainObject =
false) :
5728 detail::Wrapper<cl_type>(sampler, retainObject) { }
5744 template <
typename T>
5745 cl_int
getInfo(cl_sampler_info name, T* param)
const
5747 return detail::errHandler(
5748 detail::getInfo(&::clGetSamplerInfo, object_, name, param),
5749 __GET_SAMPLER_INFO_ERR);
5753 template <cl_sampler_info name>
typename
5758 detail::cl_sampler_info, name>::param_type param;
5759 cl_int result =
getInfo(name, ¶m);
5760 if (err !=
nullptr) {
5769class DeviceCommandQueue;
5776 size_type sizes_[3];
5777 cl_uint dimensions_;
5808 NDRange(size_type size0, size_type size1, size_type size2)
5829 operator const size_type*()
const {
5843 return dimensions_*
sizeof(size_type);
5851 const size_type* get()
const
5858static const NDRange NullRange;
5868template <
typename T,
class Enable =
void>
5873template <
typename T>
5876 static size_type size(
const T&) {
return sizeof(T); }
5877 static const T* ptr(
const T& value) {
return &value; }
5882template <
typename T>
5885 static size_type size(
const T&) {
return sizeof(cl_mem); }
5886 static const cl_mem* ptr(
const T& value) {
return &(value()); }
5894 static size_type size(
const LocalSpaceArg& value) {
return value.size_; }
5895 static const void* ptr(
const LocalSpaceArg&) {
return nullptr; }
5922 inline Kernel(
const Program& program,
const char* name, cl_int* err =
nullptr);
5935 explicit Kernel(
const cl_kernel& kernel,
bool retainObject =
false) :
5936 detail::Wrapper<cl_type>(kernel, retainObject) { }
5952 template <
typename T>
5953 cl_int getInfo(cl_kernel_info name, T* param)
const
5955 return detail::errHandler(
5956 detail::getInfo(&::clGetKernelInfo, object_, name, param),
5957 __GET_KERNEL_INFO_ERR);
5960 template <cl_kernel_info name>
typename
5961 detail::param_traits<detail::cl_kernel_info, name>::param_type
5962 getInfo(cl_int* err =
nullptr)
const
5964 typename detail::param_traits<
5965 detail::cl_kernel_info, name>::param_type param;
5966 cl_int result = getInfo(name, ¶m);
5967 if (err !=
nullptr) {
5973#if CL_HPP_TARGET_OPENCL_VERSION >= 120
5974 template <
typename T>
5975 cl_int getArgInfo(cl_uint argIndex, cl_kernel_arg_info name, T* param)
const
5977 return detail::errHandler(
5978 detail::getInfo(&::clGetKernelArgInfo, object_, argIndex, name, param),
5979 __GET_KERNEL_ARG_INFO_ERR);
5982 template <cl_kernel_arg_info name>
typename
5983 detail::param_traits<detail::cl_kernel_arg_info, name>::param_type
5984 getArgInfo(cl_uint argIndex, cl_int* err =
nullptr)
const
5986 typename detail::param_traits<
5987 detail::cl_kernel_arg_info, name>::param_type param;
5988 cl_int result = getArgInfo(argIndex, name, ¶m);
5989 if (err !=
nullptr) {
5996 template <
typename T>
5997 cl_int getWorkGroupInfo(
5998 const Device& device, cl_kernel_work_group_info name, T* param)
const
6000 return detail::errHandler(
6002 &::clGetKernelWorkGroupInfo, object_, device(), name, param),
6003 __GET_KERNEL_WORK_GROUP_INFO_ERR);
6006 template <cl_kernel_work_group_info name>
typename
6007 detail::param_traits<detail::cl_kernel_work_group_info, name>::param_type
6008 getWorkGroupInfo(
const Device& device, cl_int* err =
nullptr)
const
6010 typename detail::param_traits<
6011 detail::cl_kernel_work_group_info, name>::param_type param;
6012 cl_int result = getWorkGroupInfo(device, name, ¶m);
6013 if (err !=
nullptr) {
6019#if defined(CL_HPP_USE_CL_SUB_GROUPS_KHR) || CL_HPP_TARGET_OPENCL_VERSION >= 210
6020 cl_int getSubGroupInfo(
const cl::Device &dev, cl_kernel_sub_group_info name,
const cl::NDRange &range, size_type* param)
const
6022#if CL_HPP_TARGET_OPENCL_VERSION >= 210
6024 return detail::errHandler(
6025 clGetKernelSubGroupInfo(object_, dev(), name, range.
size(), range.get(),
sizeof(size_type), param,
nullptr),
6026 __GET_KERNEL_SUB_GROUP_INFO_ERR);
6030 typedef clGetKernelSubGroupInfoKHR_fn PFN_clGetKernelSubGroupInfoKHR;
6031 static PFN_clGetKernelSubGroupInfoKHR pfn_clGetKernelSubGroupInfoKHR =
nullptr;
6032 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetKernelSubGroupInfoKHR);
6034 return detail::errHandler(
6035 pfn_clGetKernelSubGroupInfoKHR(object_, dev(), name, range.
size(), range.get(),
sizeof(size_type), param,
nullptr),
6036 __GET_KERNEL_SUB_GROUP_INFO_ERR);
6041 template <cl_kernel_sub_group_info name>
6042 size_type getSubGroupInfo(
const cl::Device &dev,
const cl::NDRange &range, cl_int* err =
nullptr)
const
6045 cl_int result = getSubGroupInfo(dev, name, range, ¶m);
6046 if (err !=
nullptr) {
6053#if CL_HPP_TARGET_OPENCL_VERSION >= 200
6056 template<
typename T,
class D>
6057 cl_int
setArg(cl_uint index,
const cl::pointer<T, D> &argPtr)
6059 return detail::errHandler(
6060 ::clSetKernelArgSVMPointer(object_, index, argPtr.get()),
6061 __SET_KERNEL_ARGS_ERR);
6066 template<
typename T,
class Alloc>
6067 cl_int
setArg(cl_uint index,
const cl::vector<T, Alloc> &argPtr)
6069 return detail::errHandler(
6070 ::clSetKernelArgSVMPointer(object_, index, argPtr.data()),
6071 __SET_KERNEL_ARGS_ERR);
6076 template<
typename T>
6077 typename std::enable_if<std::is_pointer<T>::value, cl_int>::type
6080 return detail::errHandler(
6081 ::clSetKernelArgSVMPointer(object_, index, argPtr),
6082 __SET_KERNEL_ARGS_ERR);
6088 template <
typename T>
6089 typename std::enable_if<!std::is_pointer<T>::value, cl_int>::type
6092 return detail::errHandler(
6098 __SET_KERNEL_ARGS_ERR);
6101 cl_int
setArg(cl_uint index, size_type size,
const void* argPtr)
6103 return detail::errHandler(
6104 ::clSetKernelArg(object_, index, size, argPtr),
6105 __SET_KERNEL_ARGS_ERR);
6108#if CL_HPP_TARGET_OPENCL_VERSION >= 200
6115 return detail::errHandler(
6116 ::clSetKernelExecInfo(
6118 CL_KERNEL_EXEC_INFO_SVM_PTRS,
6119 sizeof(
void*)*pointerList.size(),
6120 pointerList.data()));
6127 template<
int ArrayLength>
6130 return detail::errHandler(
6131 ::clSetKernelExecInfo(
6133 CL_KERNEL_EXEC_INFO_SVM_PTRS,
6134 sizeof(
void*)*pointerList.size(),
6135 pointerList.data()));
6151 cl_bool svmEnabled_ = svmEnabled ? CL_TRUE : CL_FALSE;
6152 return detail::errHandler(
6153 ::clSetKernelExecInfo(
6155 CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM,
6162 template<
int index,
int ArrayLength,
class D,
typename T0,
typename T1,
typename... Ts>
6163 void setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList,
const pointer<T0, D> &t0,
const pointer<T1, D> &t1, Ts & ... ts)
6165 pointerList[index] =
static_cast<void*
>(t0.get());
6166 setSVMPointersHelper<index + 1, ArrayLength>(pointerList, t1, ts...);
6169 template<
int index,
int ArrayLength,
typename T0,
typename T1,
typename... Ts>
6170 typename std::enable_if<std::is_pointer<T0>::value,
void>::type
6171 setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList, T0 t0, T1 t1, Ts... ts)
6173 pointerList[index] =
static_cast<void*
>(t0);
6174 setSVMPointersHelper<index + 1, ArrayLength>(pointerList, t1, ts...);
6177 template<
int index,
int ArrayLength,
typename T0,
class D>
6178 void setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList,
const pointer<T0, D> &t0)
6180 pointerList[index] =
static_cast<void*
>(t0.get());
6184 template<
int index,
int ArrayLength,
typename T0>
6185 typename std::enable_if<std::is_pointer<T0>::value,
void>::type
6186 setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList, T0 t0)
6188 pointerList[index] =
static_cast<void*
>(t0);
6191 template<
typename T0,
typename... Ts>
6194 std::array<
void*, 1 +
sizeof...(Ts)> pointerList;
6196 setSVMPointersHelper<0, 1 +
sizeof...(Ts)>(pointerList, t0, ts...);
6197 return detail::errHandler(
6198 ::clSetKernelExecInfo(
6200 CL_KERNEL_EXEC_INFO_SVM_PTRS,
6201 sizeof(
void*)*(1 +
sizeof...(Ts)),
6202 pointerList.data()));
6205 template<
typename T>
6206 cl_int setExecInfo(cl_kernel_exec_info param_name,
const T& val)
6208 return detail::errHandler(
6209 ::clSetKernelExecInfo(
6216 template<cl_kernel_exec_info name>
6217 cl_int setExecInfo(
typename detail::param_traits<detail::cl_kernel_exec_info, name>::param_type& val)
6219 return setExecInfo(name, val);
6223#if CL_HPP_TARGET_OPENCL_VERSION >= 210
6232 Kernel retValue(clCloneKernel(this->get(), &error));
6234 detail::errHandler(error, __CLONE_KERNEL_ERR);
6246#if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6247 typedef vector<vector<unsigned char>> Binaries;
6248 typedef vector<string> Sources;
6250 typedef vector<std::pair<const void*, size_type> > Binaries;
6251 typedef vector<std::pair<const char*, size_type> > Sources;
6255 const string& source,
6257 cl_int* err =
nullptr)
6261 const char * strings = source.c_str();
6262 const size_type length = source.size();
6266 object_ = ::clCreateProgramWithSource(
6267 context(), (cl_uint)1, &strings, &length, &error);
6269 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6271 if (error == CL_SUCCESS && build) {
6273 error = ::clBuildProgram(
6277#
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6285 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6288 if (err !=
nullptr) {
6295 const string& source,
6297 cl_int* err =
nullptr)
6301 const char * strings = source.c_str();
6302 const size_type length = source.size();
6304 object_ = ::clCreateProgramWithSource(
6305 context(), (cl_uint)1, &strings, &length, &error);
6307 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6309 if (error == CL_SUCCESS && build) {
6310 error = ::clBuildProgram(
6314#
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6322 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6325 if (err !=
nullptr) {
6335 const Sources& sources,
6336 cl_int* err =
nullptr)
6341 const size_type n = (size_type)sources.size();
6343 vector<size_type> lengths(n);
6344 vector<const char*> strings(n);
6346 for (size_type i = 0; i < n; ++i) {
6347#if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6348 strings[i] = sources[(int)i].data();
6349 lengths[i] = sources[(int)i].length();
6351 strings[i] = sources[(int)i].first;
6352 lengths[i] = sources[(int)i].second;
6356 object_ = ::clCreateProgramWithSource(
6357 context(), (cl_uint)n, strings.data(), lengths.data(), &error);
6359 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6360 if (err !=
nullptr) {
6371 const Sources& sources,
6372 cl_int* err =
nullptr)
6376 const size_type n = (size_type)sources.size();
6378 vector<size_type> lengths(n);
6379 vector<const char*> strings(n);
6381 for (size_type i = 0; i < n; ++i) {
6382#if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6383 strings[i] = sources[(int)i].data();
6384 lengths[i] = sources[(int)i].length();
6386 strings[i] = sources[(int)i].first;
6387 lengths[i] = sources[(int)i].second;
6391 object_ = ::clCreateProgramWithSource(
6392 context(), (cl_uint)n, strings.data(), lengths.data(), &error);
6394 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6395 if (err !=
nullptr) {
6401#if defined(CL_HPP_USE_IL_KHR) || CL_HPP_TARGET_OPENCL_VERSION >= 210
6408 const vector<char>& IL,
6410 cl_int* err =
nullptr)
6416#if CL_HPP_TARGET_OPENCL_VERSION >= 210
6418 object_ = ::clCreateProgramWithIL(
6419 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6423 typedef clCreateProgramWithILKHR_fn PFN_clCreateProgramWithILKHR;
6424 static PFN_clCreateProgramWithILKHR pfn_clCreateProgramWithILKHR =
nullptr;
6425 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateProgramWithILKHR);
6427 object_ = pfn_clCreateProgramWithILKHR(
6428 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6432 detail::errHandler(error, __CREATE_PROGRAM_WITH_IL_ERR);
6434 if (error == CL_SUCCESS && build) {
6436 error = ::clBuildProgram(
6440#
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6448 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6451 if (err !=
nullptr) {
6464 const vector<char>& IL,
6466 cl_int* err =
nullptr)
6470#if CL_HPP_TARGET_OPENCL_VERSION >= 210
6472 object_ = ::clCreateProgramWithIL(
6473 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6477 typedef clCreateProgramWithILKHR_fn PFN_clCreateProgramWithILKHR;
6478 static PFN_clCreateProgramWithILKHR pfn_clCreateProgramWithILKHR =
nullptr;
6479 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateProgramWithILKHR);
6481 object_ = pfn_clCreateProgramWithILKHR(
6482 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6486 detail::errHandler(error, __CREATE_PROGRAM_WITH_IL_ERR);
6488 if (error == CL_SUCCESS && build) {
6489 error = ::clBuildProgram(
6493#
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6501 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6504 if (err !=
nullptr) {
6531 const vector<Device>& devices,
6532 const Binaries& binaries,
6533 vector<cl_int>* binaryStatus =
nullptr,
6534 cl_int* err =
nullptr)
6538 const size_type numDevices = devices.size();
6541 if(binaries.size() != numDevices) {
6542 error = CL_INVALID_VALUE;
6543 detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
6544 if (err !=
nullptr) {
6551 vector<size_type> lengths(numDevices);
6552 vector<const unsigned char*> images(numDevices);
6553#if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6554 for (size_type i = 0; i < numDevices; ++i) {
6555 images[i] = binaries[i].data();
6556 lengths[i] = binaries[(int)i].size();
6559 for (size_type i = 0; i < numDevices; ++i) {
6560 images[i] = (
const unsigned char*)binaries[i].first;
6561 lengths[i] = binaries[(int)i].second;
6565 vector<cl_device_id> deviceIDs(numDevices);
6566 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6567 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6571 binaryStatus->resize(numDevices);
6574 object_ = ::clCreateProgramWithBinary(
6575 context(), (cl_uint) devices.size(),
6577 lengths.data(), images.data(), (binaryStatus !=
nullptr && numDevices > 0)
6578 ? &binaryStatus->front()
6581 detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
6582 if (err !=
nullptr) {
6588#if CL_HPP_TARGET_OPENCL_VERSION >= 120
6595 const vector<Device>& devices,
6596 const string& kernelNames,
6597 cl_int* err =
nullptr)
6602 size_type numDevices = devices.size();
6603 vector<cl_device_id> deviceIDs(numDevices);
6604 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6605 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6608 object_ = ::clCreateProgramWithBuiltInKernels(
6610 (cl_uint) devices.size(),
6612 kernelNames.c_str(),
6615 detail::errHandler(error, __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR);
6616 if (err !=
nullptr) {
6631 explicit Program(
const cl_program& program,
bool retainObject =
false) :
6632 detail::Wrapper<cl_type>(program, retainObject) { }
6634 Program& operator = (
const cl_program& rhs)
6642 const vector<Device>& devices,
6643 const char* options =
nullptr,
6644 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
6645 void* data =
nullptr)
const
6647 size_type numDevices = devices.size();
6648 vector<cl_device_id> deviceIDs(numDevices);
6650 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6651 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6654 cl_int buildError = ::clBuildProgram(
6663 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6667 const Device& device,
6668 const char* options =
nullptr,
6669 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
6670 void* data =
nullptr)
const
6672 cl_device_id deviceID = device();
6674 cl_int buildError = ::clBuildProgram(
6682 BuildLogType buildLog(0);
6683 buildLog.push_back(std::make_pair(device, getBuildInfo<CL_PROGRAM_BUILD_LOG>(device)));
6684 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, buildLog);
6688 const char* options =
nullptr,
6689 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
6690 void* data =
nullptr)
const
6692 cl_int buildError = ::clBuildProgram(
6700 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6703#if CL_HPP_TARGET_OPENCL_VERSION >= 120
6705 const char* options =
nullptr,
6706 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
6707 void* data =
nullptr)
const
6709 cl_int error = ::clCompileProgram(
6719 return detail::buildErrHandler(error, __COMPILE_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6723 template <
typename T>
6724 cl_int getInfo(cl_program_info name, T* param)
const
6726 return detail::errHandler(
6727 detail::getInfo(&::clGetProgramInfo, object_, name, param),
6728 __GET_PROGRAM_INFO_ERR);
6731 template <cl_program_info name>
typename
6732 detail::param_traits<detail::cl_program_info, name>::param_type
6733 getInfo(cl_int* err =
nullptr)
const
6735 typename detail::param_traits<
6736 detail::cl_program_info, name>::param_type param;
6737 cl_int result = getInfo(name, ¶m);
6738 if (err !=
nullptr) {
6744 template <
typename T>
6745 cl_int getBuildInfo(
6746 const Device& device, cl_program_build_info name, T* param)
const
6748 return detail::errHandler(
6750 &::clGetProgramBuildInfo, object_, device(), name, param),
6751 __GET_PROGRAM_BUILD_INFO_ERR);
6754 template <cl_program_build_info name>
typename
6755 detail::param_traits<detail::cl_program_build_info, name>::param_type
6756 getBuildInfo(
const Device& device, cl_int* err =
nullptr)
const
6758 typename detail::param_traits<
6759 detail::cl_program_build_info, name>::param_type param;
6760 cl_int result = getBuildInfo(device, name, ¶m);
6761 if (err !=
nullptr) {
6772 template <cl_program_build_info name>
6773 vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, name>::param_type>>
6776 cl_int result = CL_SUCCESS;
6778 auto devs = getInfo<CL_PROGRAM_DEVICES>(&result);
6779 vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, name>::param_type>>
6783 if (result != CL_SUCCESS) {
6784 if (err !=
nullptr) {
6792 detail::cl_program_build_info, name>::param_type param;
6793 result = getBuildInfo(d, name, ¶m);
6797 if (result != CL_SUCCESS) {
6802 if (err !=
nullptr) {
6805 if (result != CL_SUCCESS) {
6811 cl_int createKernels(vector<Kernel>* kernels)
6814 cl_int err = ::clCreateKernelsInProgram(object_, 0,
nullptr, &numKernels);
6815 if (err != CL_SUCCESS) {
6816 return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
6819 vector<cl_kernel> value(numKernels);
6821 err = ::clCreateKernelsInProgram(
6822 object_, numKernels, value.data(),
nullptr);
6823 if (err != CL_SUCCESS) {
6824 return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
6828 kernels->resize(value.size());
6832 for (size_type i = 0; i < value.size(); i++) {
6835 (*kernels)[i] = Kernel(value[i],
false);
6841#if CL_HPP_TARGET_OPENCL_VERSION >= 220
6842#if defined(CL_USE_DEPRECATED_OPENCL_2_2_APIS)
6854 void (CL_CALLBACK * pfn_notify)(cl_program program,
void * user_data),
6855 void * user_data =
nullptr) CL_API_SUFFIX__VERSION_2_2_DEPRECATED
6857 return detail::errHandler(
6858 ::clSetProgramReleaseCallback(
6862 __SET_PROGRAM_RELEASE_CALLBACK_ERR);
6870 template <
typename T>
6871 typename std::enable_if<!std::is_pointer<T>::value, cl_int>::type
6874 return detail::errHandler(
6875 ::clSetProgramSpecializationConstant(
6880 __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR);
6889 return detail::errHandler(
6890 ::clSetProgramSpecializationConstant(
6895 __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR);
6900#if CL_HPP_TARGET_OPENCL_VERSION >= 120
6901inline Program linkProgram(
6902 const Program& input1,
6903 const Program& input2,
6904 const char* options =
nullptr,
6905 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
6906 void* data =
nullptr,
6907 cl_int* err =
nullptr)
6909 cl_int error_local = CL_SUCCESS;
6910 cl_program programs[2] = { input1(), input2() };
6912 Context ctx = input1.getInfo<CL_PROGRAM_CONTEXT>(&error_local);
6913 if(error_local!=CL_SUCCESS) {
6914 detail::errHandler(error_local, __LINK_PROGRAM_ERR);
6917 cl_program prog = ::clLinkProgram(
6928 detail::errHandler(error_local,__COMPILE_PROGRAM_ERR);
6929 if (err !=
nullptr) {
6933 return Program(prog);
6936inline Program linkProgram(
6937 const vector<Program>& inputPrograms,
6938 const char* options =
nullptr,
6939 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
6940 void* data =
nullptr,
6941 cl_int* err =
nullptr)
6943 cl_int error_local = CL_SUCCESS;
6946 static_assert(
sizeof(
cl::Program) ==
sizeof(cl_program),
6947 "Size of cl::Program must be equal to size of cl_program");
6949 if(inputPrograms.size() > 0) {
6950 ctx = inputPrograms[0].getInfo<CL_PROGRAM_CONTEXT>(&error_local);
6951 if(error_local!=CL_SUCCESS) {
6952 detail::errHandler(error_local, __LINK_PROGRAM_ERR);
6956 cl_program prog = ::clLinkProgram(
6961 static_cast<cl_uint
>(inputPrograms.size()),
6962 reinterpret_cast<const cl_program *
>(inputPrograms.data()),
6967 detail::errHandler(error_local,__COMPILE_PROGRAM_ERR);
6968 if (err !=
nullptr) {
6972 return Program(prog);
6978inline cl_int cl::Program::getInfo(cl_program_info name, vector<vector<unsigned char>>* param)
const
6980 if (name != CL_PROGRAM_BINARIES) {
6981 return CL_INVALID_VALUE;
6987 vector<size_type> sizes = getInfo<CL_PROGRAM_BINARY_SIZES>();
6988 size_type numBinaries = sizes.size();
6991 param->resize(numBinaries);
6992 for (size_type i = 0; i < numBinaries; ++i) {
6993 (*param)[i].resize(sizes[i]);
6996 return detail::errHandler(
6997 detail::getInfo(&::clGetProgramInfo, object_, name, param),
6998 __GET_PROGRAM_INFO_ERR);
7005inline vector<vector<unsigned char>> cl::Program::getInfo<CL_PROGRAM_BINARIES>(cl_int* err)
const
7007 vector<vector<unsigned char>> binariesVectors;
7009 cl_int result = getInfo(CL_PROGRAM_BINARIES, &binariesVectors);
7010 if (err !=
nullptr) {
7013 return binariesVectors;
7016#if CL_HPP_TARGET_OPENCL_VERSION >= 220
7021 cl_uchar ucValue = value ? CL_UCHAR_MAX : 0;
7022 return detail::errHandler(
7023 ::clSetProgramSpecializationConstant(
7028 __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR);
7032inline Kernel::Kernel(
const Program& program,
const char* name, cl_int* err)
7036 object_ = ::clCreateKernel(program(), name, &error);
7037 detail::errHandler(error, __CREATE_KERNEL_ERR);
7039 if (err !=
nullptr) {
7045#ifdef cl_khr_external_memory
7046enum class ExternalMemoryType : cl_external_memory_handle_type_khr
7050 OpaqueFd = CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_FD_KHR,
7051 OpaqueWin32 = CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KHR,
7052 OpaqueWin32Kmt = CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KMT_KHR,
7054 D3D11Texture = CL_EXTERNAL_MEMORY_HANDLE_D3D11_TEXTURE_KHR,
7055 D3D11TextureKmt = CL_EXTERNAL_MEMORY_HANDLE_D3D11_TEXTURE_KMT_KHR,
7057 D3D12Heap = CL_EXTERNAL_MEMORY_HANDLE_D3D12_HEAP_KHR,
7058 D3D12Resource = CL_EXTERNAL_MEMORY_HANDLE_D3D12_RESOURCE_KHR,
7060 DmaBuf = CL_EXTERNAL_MEMORY_HANDLE_DMA_BUF_KHR,
7064enum class QueueProperties : cl_command_queue_properties
7067 Profiling = CL_QUEUE_PROFILING_ENABLE,
7068 OutOfOrder = CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE,
7071inline QueueProperties operator|(QueueProperties lhs, QueueProperties rhs)
7073 return static_cast<QueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) |
static_cast<cl_command_queue_properties
>(rhs));
7076inline QueueProperties operator&(QueueProperties lhs, QueueProperties rhs)
7078 return static_cast<QueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) &
static_cast<cl_command_queue_properties
>(rhs));
7087 static std::once_flag default_initialized_;
7089 static cl_int default_error_;
7096 static void makeDefault()
7101#if defined(CL_HPP_ENABLE_EXCEPTIONS)
7108 if (error != CL_SUCCESS) {
7109 default_error_ = error;
7113 default_ =
CommandQueue(context, device, 0, &default_error_);
7116#if defined(CL_HPP_ENABLE_EXCEPTIONS)
7117 catch (cl::Error &e) {
7118 default_error_ = e.err();
7128 static void makeDefaultProvided(
const CommandQueue &c) {
7132#ifdef cl_khr_external_memory
7133 static std::once_flag ext_memory_initialized_;
7135 static void initMemoryExtension(
const cl::Device& device)
7137 auto platform = device.getInfo<CL_DEVICE_PLATFORM>()();
7139 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueAcquireExternalMemObjectsKHR);
7140 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueReleaseExternalMemObjectsKHR);
7142 if ((pfn_clEnqueueAcquireExternalMemObjectsKHR ==
nullptr)
7143 && (pfn_clEnqueueReleaseExternalMemObjectsKHR ==
nullptr))
7145 detail::errHandler(CL_INVALID_VALUE, __ENQUEUE_ACQUIRE_EXTERNAL_MEMORY_ERR);
7151#ifdef CL_HPP_UNIT_TEST_ENABLE
7158 static void unitTestClearDefault() {
7169 cl_command_queue_properties properties,
7170 cl_int* err =
nullptr)
7175 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7177 if (error != CL_SUCCESS) {
7178 if (err !=
nullptr) {
7184 bool useWithProperties;
7186#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7189 cl_uint version = detail::getContextPlatformVersion(context());
7190 useWithProperties = (version >= 0x20000);
7192#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7193 useWithProperties =
true;
7195 useWithProperties =
false;
7198#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7199 if (useWithProperties) {
7200 cl_queue_properties queue_properties[] = {
7201 CL_QUEUE_PROPERTIES, properties, 0 };
7202 if ((properties & CL_QUEUE_ON_DEVICE) == 0) {
7203 object_ = ::clCreateCommandQueueWithProperties(
7204 context(), device(), queue_properties, &error);
7207 error = CL_INVALID_QUEUE_PROPERTIES;
7210 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7211 if (err !=
nullptr) {
7216#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7217 if (!useWithProperties) {
7218 object_ = ::clCreateCommandQueue(
7219 context(), device(), properties, &error);
7221 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7222 if (err !=
nullptr) {
7235 QueueProperties properties,
7236 cl_int* err =
nullptr)
7241 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7243 if (error != CL_SUCCESS) {
7244 if (err !=
nullptr) {
7250 bool useWithProperties;
7252#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7255 cl_uint version = detail::getContextPlatformVersion(context());
7256 useWithProperties = (version >= 0x20000);
7258#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7259 useWithProperties =
true;
7261 useWithProperties =
false;
7264#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7265 if (useWithProperties) {
7266 cl_queue_properties queue_properties[] = {
7267 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
7269 object_ = ::clCreateCommandQueueWithProperties(
7270 context(), device(), queue_properties, &error);
7272 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7273 if (err !=
nullptr) {
7278#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7279 if (!useWithProperties) {
7280 object_ = ::clCreateCommandQueue(
7281 context(), device(),
static_cast<cl_command_queue_properties
>(properties), &error);
7283 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7284 if (err !=
nullptr) {
7299 cl_command_queue_properties properties = 0,
7300 cl_int* err =
nullptr)
7303 bool useWithProperties;
7304 vector<cl::Device> devices;
7305 error = context.getInfo(CL_CONTEXT_DEVICES, &devices);
7307 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7309 if (error != CL_SUCCESS)
7311 if (err !=
nullptr) {
7317#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7320 cl_uint version = detail::getContextPlatformVersion(context());
7321 useWithProperties = (version >= 0x20000);
7323#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7324 useWithProperties =
true;
7326 useWithProperties =
false;
7329#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7330 if (useWithProperties) {
7331 cl_queue_properties queue_properties[] = {
7332 CL_QUEUE_PROPERTIES, properties, 0 };
7333 if ((properties & CL_QUEUE_ON_DEVICE) == 0) {
7334 object_ = ::clCreateCommandQueueWithProperties(
7335 context(), devices[0](), queue_properties, &error);
7338 error = CL_INVALID_QUEUE_PROPERTIES;
7341 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7342 if (err !=
nullptr) {
7347#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7348 if (!useWithProperties) {
7349 object_ = ::clCreateCommandQueue(
7350 context(), devices[0](), properties, &error);
7352 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7353 if (err !=
nullptr) {
7366 QueueProperties properties,
7367 cl_int* err =
nullptr)
7370 bool useWithProperties;
7371 vector<cl::Device> devices;
7372 error = context.getInfo(CL_CONTEXT_DEVICES, &devices);
7374 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7376 if (error != CL_SUCCESS)
7378 if (err !=
nullptr) {
7384#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7387 cl_uint version = detail::getContextPlatformVersion(context());
7388 useWithProperties = (version >= 0x20000);
7390#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7391 useWithProperties =
true;
7393 useWithProperties =
false;
7396#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7397 if (useWithProperties) {
7398 cl_queue_properties queue_properties[] = {
7399 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
7400 object_ = ::clCreateCommandQueueWithProperties(
7401 context(), devices[0](), queue_properties, &error);
7403 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7404 if (err !=
nullptr) {
7409#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7410 if (!useWithProperties) {
7411 object_ = ::clCreateCommandQueue(
7412 context(), devices[0](),
static_cast<cl_command_queue_properties
>(properties), &error);
7414 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7415 if (err !=
nullptr) {
7429 cl_command_queue_properties properties = 0,
7430 cl_int* err =
nullptr)
7433 bool useWithProperties;
7435#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7438 cl_uint version = detail::getContextPlatformVersion(context());
7439 useWithProperties = (version >= 0x20000);
7441#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7442 useWithProperties =
true;
7444 useWithProperties =
false;
7447#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7448 if (useWithProperties) {
7449 cl_queue_properties queue_properties[] = {
7450 CL_QUEUE_PROPERTIES, properties, 0 };
7451 object_ = ::clCreateCommandQueueWithProperties(
7452 context(), device(), queue_properties, &error);
7454 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7455 if (err !=
nullptr) {
7460#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7461 if (!useWithProperties) {
7462 object_ = ::clCreateCommandQueue(
7463 context(), device(), properties, &error);
7465 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7466 if (err !=
nullptr) {
7480 QueueProperties properties,
7481 cl_int* err =
nullptr)
7484 bool useWithProperties;
7486#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7489 cl_uint version = detail::getContextPlatformVersion(context());
7490 useWithProperties = (version >= 0x20000);
7492#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7493 useWithProperties =
true;
7495 useWithProperties =
false;
7498#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7499 if (useWithProperties) {
7500 cl_queue_properties queue_properties[] = {
7501 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
7502 object_ = ::clCreateCommandQueueWithProperties(
7503 context(), device(), queue_properties, &error);
7505 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7506 if (err !=
nullptr) {
7511#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7512 if (!useWithProperties) {
7513 object_ = ::clCreateCommandQueue(
7514 context(), device(),
static_cast<cl_command_queue_properties
>(properties), &error);
7516 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7517 if (err !=
nullptr) {
7526 std::call_once(default_initialized_, makeDefault);
7527#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7528 detail::errHandler(default_error_, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7530 detail::errHandler(default_error_, __CREATE_COMMAND_QUEUE_ERR);
7532 if (err !=
nullptr) {
7533 *err = default_error_;
7547 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_queue));
7548 detail::errHandler(default_error_);
7561 explicit CommandQueue(
const cl_command_queue& commandQueue,
bool retainObject =
false) :
7562 detail::Wrapper<cl_type>(commandQueue, retainObject) { }
7570 template <
typename T>
7571 cl_int getInfo(cl_command_queue_info name, T* param)
const
7573 return detail::errHandler(
7575 &::clGetCommandQueueInfo, object_, name, param),
7576 __GET_COMMAND_QUEUE_INFO_ERR);
7579 template <cl_command_queue_info name>
typename
7580 detail::param_traits<detail::cl_command_queue_info, name>::param_type
7581 getInfo(cl_int* err =
nullptr)
const
7583 typename detail::param_traits<
7584 detail::cl_command_queue_info, name>::param_type param;
7585 cl_int result = getInfo(name, ¶m);
7586 if (err !=
nullptr) {
7592 cl_int enqueueReadBuffer(
7593 const Buffer& buffer,
7598 const vector<Event>* events =
nullptr,
7599 Event* event =
nullptr)
const
7602 cl_int err = detail::errHandler(
7603 ::clEnqueueReadBuffer(
7604 object_, buffer(), blocking, offset, size,
7606 (events !=
nullptr) ? (cl_uint) events->size() : 0,
7607 (events != nullptr && events->size() > 0) ? (cl_event*) &events->front() : nullptr,
7608 (event != nullptr) ? &tmp : nullptr),
7609 __ENQUEUE_READ_BUFFER_ERR);
7611 if (event !=
nullptr && err == CL_SUCCESS)
7617 cl_int enqueueWriteBuffer(
7618 const Buffer& buffer,
7623 const vector<Event>* events =
nullptr,
7624 Event* event =
nullptr)
const
7627 cl_int err = detail::errHandler(
7628 ::clEnqueueWriteBuffer(
7629 object_, buffer(), blocking, offset, size,
7631 (events !=
nullptr) ? (cl_uint) events->size() : 0,
7632 (events != nullptr && events->size() > 0) ? (cl_event*) &events->front() : nullptr,
7633 (event != nullptr) ? &tmp : nullptr),
7634 __ENQUEUE_WRITE_BUFFER_ERR);
7636 if (event !=
nullptr && err == CL_SUCCESS)
7642 cl_int enqueueCopyBuffer(
7645 size_type src_offset,
7646 size_type dst_offset,
7648 const vector<Event>* events =
nullptr,
7649 Event* event =
nullptr)
const
7652 cl_int err = detail::errHandler(
7653 ::clEnqueueCopyBuffer(
7654 object_, src(), dst(), src_offset, dst_offset, size,
7655 (events !=
nullptr) ? (cl_uint) events->size() : 0,
7656 (events != nullptr && events->size() > 0) ? (cl_event*) &events->front() : nullptr,
7657 (event != nullptr) ? &tmp : nullptr),
7658 __ENQEUE_COPY_BUFFER_ERR);
7660 if (event !=
nullptr && err == CL_SUCCESS)
7665#if CL_HPP_TARGET_OPENCL_VERSION >= 110
7666 cl_int enqueueReadBufferRect(
7667 const Buffer& buffer,
7669 const array<size_type, 3>& buffer_offset,
7670 const array<size_type, 3>& host_offset,
7671 const array<size_type, 3>& region,
7672 size_type buffer_row_pitch,
7673 size_type buffer_slice_pitch,
7674 size_type host_row_pitch,
7675 size_type host_slice_pitch,
7677 const vector<Event>* events =
nullptr,
7678 Event* event =
nullptr)
const
7681 cl_int err = detail::errHandler(
7682 ::clEnqueueReadBufferRect(
7686 buffer_offset.data(),
7694 (events !=
nullptr) ? (cl_uint) events->size() : 0,
7695 (events != nullptr && events->size() > 0) ? (cl_event*) &events->front() : nullptr,
7696 (event != nullptr) ? &tmp : nullptr),
7697 __ENQUEUE_READ_BUFFER_RECT_ERR);
7699 if (event !=
nullptr && err == CL_SUCCESS)
7705 cl_int enqueueReadBufferRect(
7706 const Buffer& buffer,
7708 const array<size_type, 2>& buffer_offset,
7709 const array<size_type, 2>& host_offset,
7710 const array<size_type, 2>& region,
7711 size_type buffer_row_pitch,
7712 size_type buffer_slice_pitch,
7713 size_type host_row_pitch,
7714 size_type host_slice_pitch,
7716 const vector<Event>* events =
nullptr,
7717 Event* event =
nullptr)
const
7719 return enqueueReadBufferRect(
7722 { buffer_offset[0], buffer_offset[1], 0 },
7723 { host_offset[0], host_offset[1], 0 },
7724 { region[0], region[1], 1 },
7734 cl_int enqueueWriteBufferRect(
7735 const Buffer& buffer,
7737 const array<size_type, 3>& buffer_offset,
7738 const array<size_type, 3>& host_offset,
7739 const array<size_type, 3>& region,
7740 size_type buffer_row_pitch,
7741 size_type buffer_slice_pitch,
7742 size_type host_row_pitch,
7743 size_type host_slice_pitch,
7745 const vector<Event>* events =
nullptr,
7746 Event* event =
nullptr)
const
7749 cl_int err = detail::errHandler(
7750 ::clEnqueueWriteBufferRect(
7754 buffer_offset.data(),
7762 (events !=
nullptr) ? (cl_uint) events->size() : 0,
7763 (events != nullptr && events->size() > 0) ? (cl_event*) &events->front() : nullptr,
7764 (event != nullptr) ? &tmp : nullptr),
7765 __ENQUEUE_WRITE_BUFFER_RECT_ERR);
7767 if (event !=
nullptr && err == CL_SUCCESS)
7773 cl_int enqueueWriteBufferRect(
7774 const Buffer& buffer,
7776 const array<size_type, 2>& buffer_offset,
7777 const array<size_type, 2>& host_offset,
7778 const array<size_type, 2>& region,
7779 size_type buffer_row_pitch,
7780 size_type buffer_slice_pitch,
7781 size_type host_row_pitch,
7782 size_type host_slice_pitch,
7784 const vector<Event>* events =
nullptr,
7785 Event* event =
nullptr)
const
7787 return enqueueWriteBufferRect(
7790 { buffer_offset[0], buffer_offset[1], 0 },
7791 { host_offset[0], host_offset[1], 0 },
7792 { region[0], region[1], 1 },
7802 cl_int enqueueCopyBufferRect(
7805 const array<size_type, 3>& src_origin,
7806 const array<size_type, 3>& dst_origin,
7807 const array<size_type, 3>& region,
7808 size_type src_row_pitch,
7809 size_type src_slice_pitch,
7810 size_type dst_row_pitch,
7811 size_type dst_slice_pitch,
7812 const vector<Event>* events =
nullptr,
7813 Event* event =
nullptr)
const
7816 cl_int err = detail::errHandler(
7817 ::clEnqueueCopyBufferRect(
7828 (events !=
nullptr) ? (cl_uint) events->size() : 0,
7829 (events != nullptr && events->size() > 0) ? (cl_event*) &events->front() : nullptr,
7830 (event != nullptr) ? &tmp : nullptr),
7831 __ENQEUE_COPY_BUFFER_RECT_ERR);
7833 if (event !=
nullptr && err == CL_SUCCESS)
7839 cl_int enqueueCopyBufferRect(
7842 const array<size_type, 2>& src_origin,
7843 const array<size_type, 2>& dst_origin,
7844 const array<size_type, 2>& region,
7845 size_type src_row_pitch,
7846 size_type src_slice_pitch,
7847 size_type dst_row_pitch,
7848 size_type dst_slice_pitch,
7849 const vector<Event>* events =
nullptr,
7850 Event* event =
nullptr)
const
7852 return enqueueCopyBufferRect(
7855 { src_origin[0], src_origin[1], 0 },
7856 { dst_origin[0], dst_origin[1], 0 },
7857 { region[0], region[1], 1 },
7867#if CL_HPP_TARGET_OPENCL_VERSION >= 120
7879 template<
typename PatternType>
7882 PatternType pattern,
7885 const vector<Event>* events =
nullptr,
7886 Event* event =
nullptr)
const
7889 cl_int err = detail::errHandler(
7890 ::clEnqueueFillBuffer(
7893 static_cast<void*
>(&pattern),
7894 sizeof(PatternType),
7897 (events !=
nullptr) ? (cl_uint) events->size() : 0,
7898 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
7899 (
event !=
nullptr) ? &tmp :
nullptr),
7900 __ENQUEUE_FILL_BUFFER_ERR);
7902 if (event !=
nullptr && err == CL_SUCCESS)
7909 cl_int enqueueReadImage(
7912 const array<size_type, 3>& origin,
7913 const array<size_type, 3>& region,
7914 size_type row_pitch,
7915 size_type slice_pitch,
7917 const vector<Event>* events =
nullptr,
7918 Event* event =
nullptr)
const
7921 cl_int err = detail::errHandler(
7922 ::clEnqueueReadImage(
7931 (events !=
nullptr) ? (cl_uint) events->size() : 0,
7932 (events != nullptr && events->size() > 0) ? (cl_event*) &events->front() : nullptr,
7933 (event != nullptr) ? &tmp : nullptr),
7934 __ENQUEUE_READ_IMAGE_ERR);
7936 if (event !=
nullptr && err == CL_SUCCESS)
7942 cl_int enqueueReadImage(
7945 const array<size_type, 2>& origin,
7946 const array<size_type, 2>& region,
7947 size_type row_pitch,
7948 size_type slice_pitch,
7950 const vector<Event>* events =
nullptr,
7951 Event* event =
nullptr)
const
7953 return enqueueReadImage(
7956 { origin[0], origin[1], 0 },
7957 { region[0], region[1], 1 },
7965 cl_int enqueueWriteImage(
7968 const array<size_type, 3>& origin,
7969 const array<size_type, 3>& region,
7970 size_type row_pitch,
7971 size_type slice_pitch,
7973 const vector<Event>* events =
nullptr,
7974 Event* event =
nullptr)
const
7977 cl_int err = detail::errHandler(
7978 ::clEnqueueWriteImage(
7987 (events !=
nullptr) ? (cl_uint) events->size() : 0,
7988 (events != nullptr && events->size() > 0) ? (cl_event*) &events->front() : nullptr,
7989 (event != nullptr) ? &tmp : nullptr),
7990 __ENQUEUE_WRITE_IMAGE_ERR);
7992 if (event !=
nullptr && err == CL_SUCCESS)
7998 cl_int enqueueWriteImage(
8001 const array<size_type, 2>& origin,
8002 const array<size_type, 2>& region,
8003 size_type row_pitch,
8004 size_type slice_pitch,
8006 const vector<Event>* events =
nullptr,
8007 Event* event =
nullptr)
const
8009 return enqueueWriteImage(
8012 { origin[0], origin[1], 0 },
8013 { region[0], region[1], 1 },
8021 cl_int enqueueCopyImage(
8024 const array<size_type, 3>& src_origin,
8025 const array<size_type, 3>& dst_origin,
8026 const array<size_type, 3>& region,
8027 const vector<Event>* events =
nullptr,
8028 Event* event =
nullptr)
const
8031 cl_int err = detail::errHandler(
8032 ::clEnqueueCopyImage(
8039 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8040 (events != nullptr && events->size() > 0) ? (cl_event*) &events->front() : nullptr,
8041 (event != nullptr) ? &tmp : nullptr),
8042 __ENQUEUE_COPY_IMAGE_ERR);
8044 if (event !=
nullptr && err == CL_SUCCESS)
8050 cl_int enqueueCopyImage(
8053 const array<size_type, 2>& src_origin,
8054 const array<size_type, 2>& dst_origin,
8055 const array<size_type, 2>& region,
8056 const vector<Event>* events =
nullptr,
8057 Event* event =
nullptr)
const
8059 return enqueueCopyImage(
8062 { src_origin[0], src_origin[1], 0 },
8063 { dst_origin[0], dst_origin[1], 0 },
8064 { region[0], region[1], 1 },
8069#if CL_HPP_TARGET_OPENCL_VERSION >= 120
8077 template <
typename T>
8078 typename std::enable_if<std::is_same<T, cl_float4>::value ||
8079 std::is_same<T, cl_int4 >::value ||
8080 std::is_same<T, cl_uint4 >::value,
8085 const array<size_type, 3>& origin,
8086 const array<size_type, 3>& region,
8087 const vector<Event>* events =
nullptr,
8088 Event* event =
nullptr)
const
8091 cl_int err = detail::errHandler(
8092 ::clEnqueueFillImage(
8095 static_cast<void*
>(&fillColor),
8098 (events !=
nullptr) ? (cl_uint)events->size() : 0,
8099 (events !=
nullptr && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8100 (
event != NULL) ? &tmp :
nullptr),
8101 __ENQUEUE_FILL_IMAGE_ERR);
8103 if (event !=
nullptr && err == CL_SUCCESS) *
event = tmp;
8115 template <
typename T>
8116 typename std::enable_if<std::is_same<T, cl_float4>::value ||
8117 std::is_same<T, cl_int4 >::value ||
8118 std::is_same<T, cl_uint4 >::value, cl_int>::type
8122 const array<size_type, 2>& origin,
8123 const array<size_type, 2>& region,
8124 const vector<Event>* events =
nullptr,
8125 Event* event =
nullptr)
const
8130 { origin[0], origin[1], 0 },
8131 { region[0], region[1], 1 },
8138 cl_int enqueueCopyImageToBuffer(
8141 const array<size_type, 3>& src_origin,
8142 const array<size_type, 3>& region,
8143 size_type dst_offset,
8144 const vector<Event>* events =
nullptr,
8145 Event* event =
nullptr)
const
8148 cl_int err = detail::errHandler(
8149 ::clEnqueueCopyImageToBuffer(
8156 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8157 (events != nullptr && events->size() > 0) ? (cl_event*) &events->front() : nullptr,
8158 (event != nullptr) ? &tmp : nullptr),
8159 __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR);
8161 if (event !=
nullptr && err == CL_SUCCESS)
8167 cl_int enqueueCopyImageToBuffer(
8170 const array<size_type, 2>& src_origin,
8171 const array<size_type, 2>& region,
8172 size_type dst_offset,
8173 const vector<Event>* events =
nullptr,
8174 Event* event =
nullptr)
const
8176 return enqueueCopyImageToBuffer(
8179 { src_origin[0], src_origin[1], 0 },
8180 { region[0], region[1], 1 },
8186 cl_int enqueueCopyBufferToImage(
8189 size_type src_offset,
8190 const array<size_type, 3>& dst_origin,
8191 const array<size_type, 3>& region,
8192 const vector<Event>* events =
nullptr,
8193 Event* event =
nullptr)
const
8196 cl_int err = detail::errHandler(
8197 ::clEnqueueCopyBufferToImage(
8204 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8205 (events != nullptr && events->size() > 0) ? (cl_event*) &events->front() : nullptr,
8206 (event != nullptr) ? &tmp : nullptr),
8207 __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR);
8209 if (event !=
nullptr && err == CL_SUCCESS)
8215 cl_int enqueueCopyBufferToImage(
8218 size_type src_offset,
8219 const array<size_type, 2>& dst_origin,
8220 const array<size_type, 2>& region,
8221 const vector<Event>* events =
nullptr,
8222 Event* event =
nullptr)
const
8224 return enqueueCopyBufferToImage(
8228 { dst_origin[0], dst_origin[1], 0 },
8229 { region[0], region[1], 1 },
8234 void* enqueueMapBuffer(
8235 const Buffer& buffer,
8240 const vector<Event>* events =
nullptr,
8241 Event* event =
nullptr,
8242 cl_int* err =
nullptr)
const
8246 void * result = ::clEnqueueMapBuffer(
8247 object_, buffer(), blocking, flags, offset, size,
8248 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8249 (events != nullptr && events->size() > 0) ? (cl_event*) &events->front() : nullptr,
8250 (event != nullptr) ? &tmp : nullptr,
8253 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
8254 if (err !=
nullptr) {
8257 if (event !=
nullptr && error == CL_SUCCESS)
8263 void* enqueueMapImage(
8267 const array<size_type, 3>& origin,
8268 const array<size_type, 3>& region,
8269 size_type * row_pitch,
8270 size_type * slice_pitch,
8271 const vector<Event>* events =
nullptr,
8272 Event* event =
nullptr,
8273 cl_int* err =
nullptr)
const
8277 void * result = ::clEnqueueMapImage(
8278 object_, image(), blocking, flags,
8281 row_pitch, slice_pitch,
8282 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8283 (events != nullptr && events->size() > 0) ? (cl_event*) &events->front() : nullptr,
8284 (event != nullptr) ? &tmp : nullptr,
8287 detail::errHandler(error, __ENQUEUE_MAP_IMAGE_ERR);
8288 if (err !=
nullptr) {
8291 if (event !=
nullptr && error == CL_SUCCESS)
8296 void* enqueueMapImage(
8300 const array<size_type, 2>& origin,
8301 const array<size_type, 2>& region,
8302 size_type* row_pitch,
8303 size_type* slice_pitch,
8304 const vector<Event>* events =
nullptr,
8305 Event* event =
nullptr,
8306 cl_int* err =
nullptr)
const
8308 return enqueueMapImage(image, blocking, flags,
8309 { origin[0], origin[1], 0 },
8310 { region[0], region[1], 1 }, row_pitch,
8311 slice_pitch, events, event, err);
8314#if CL_HPP_TARGET_OPENCL_VERSION >= 200
8320 template<
typename T>
8326 const vector<Event> *events =
nullptr,
8327 Event *event =
nullptr)
const {
8329 cl_int err = detail::errHandler(::clEnqueueSVMMemcpy(
8330 object_, blocking,
static_cast<void *
>(dst_ptr),
static_cast<const void *
>(src_ptr), size,
8331 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8332 (events !=
nullptr && events->size() > 0) ? (cl_event *) &events->front() :
nullptr,
8333 (
event !=
nullptr) ? &tmp :
nullptr), __ENQUEUE_COPY_SVM_ERR);
8335 if (event !=
nullptr && err == CL_SUCCESS)
8345 template<
typename T,
class D>
8347 cl::pointer<T, D> &dst_ptr,
8348 const cl::pointer<T, D> &src_ptr,
8351 const vector<Event> *events =
nullptr,
8352 Event *event =
nullptr)
const {
8354 cl_int err = detail::errHandler(::clEnqueueSVMMemcpy(
8355 object_, blocking,
static_cast<void *
>(dst_ptr.get()),
static_cast<const void *
>(src_ptr.get()),
8357 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8358 (events !=
nullptr && events->size() > 0) ? (cl_event *) &events->front() :
nullptr,
8359 (
event !=
nullptr) ? &tmp :
nullptr), __ENQUEUE_COPY_SVM_ERR);
8361 if (event !=
nullptr && err == CL_SUCCESS)
8371 template<
typename T,
class Alloc>
8373 cl::vector<T, Alloc> &dst_container,
8374 const cl::vector<T, Alloc> &src_container,
8376 const vector<Event> *events =
nullptr,
8377 Event *event =
nullptr)
const {
8379 if(src_container.size() != dst_container.size()){
8380 return detail::errHandler(CL_INVALID_VALUE,__ENQUEUE_COPY_SVM_ERR);
8382 cl_int err = detail::errHandler(::clEnqueueSVMMemcpy(
8383 object_, blocking,
static_cast<void *
>(dst_container.data()),
8384 static_cast<const void *
>(src_container.data()),
8385 dst_container.size() *
sizeof(T),
8386 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8387 (events !=
nullptr && events->size() > 0) ? (cl_event *) &events->front() :
nullptr,
8388 (
event != NULL) ? &tmp :
nullptr), __ENQUEUE_COPY_SVM_ERR);
8390 if (event !=
nullptr && err == CL_SUCCESS)
8400 template<
typename T,
typename PatternType>
8403 PatternType pattern,
8405 const vector<Event> *events =
nullptr,
8406 Event *event =
nullptr)
const {
8408 cl_int err = detail::errHandler(::clEnqueueSVMMemFill(
8409 object_,
static_cast<void *
>(ptr),
static_cast<void *
>(&pattern),
8410 sizeof(PatternType), size,
8411 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8412 (events !=
nullptr && events->size() > 0) ? (cl_event *) &events->front() :
nullptr,
8413 (
event !=
nullptr) ? &tmp :
nullptr), __ENQUEUE_FILL_SVM_ERR);
8415 if (event !=
nullptr && err == CL_SUCCESS)
8425 template<
typename T,
class D,
typename PatternType>
8427 cl::pointer<T, D> &ptr,
8428 PatternType pattern,
8430 const vector<Event> *events =
nullptr,
8431 Event *event =
nullptr)
const {
8433 cl_int err = detail::errHandler(::clEnqueueSVMMemFill(
8434 object_,
static_cast<void *
>(ptr.get()),
static_cast<void *
>(&pattern),
8435 sizeof(PatternType), size,
8436 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8437 (events !=
nullptr && events->size() > 0) ? (cl_event *) &events->front() :
nullptr,
8438 (
event !=
nullptr) ? &tmp :
nullptr), __ENQUEUE_FILL_SVM_ERR);
8440 if (event !=
nullptr && err == CL_SUCCESS)
8450 template<
typename T,
class Alloc,
typename PatternType>
8452 cl::vector<T, Alloc> &container,
8453 PatternType pattern,
8454 const vector<Event> *events =
nullptr,
8455 Event* event =
nullptr)
const
8458 cl_int err = detail::errHandler(::clEnqueueSVMMemFill(
8459 object_,
static_cast<void *
>(container.data()),
static_cast<void *
>(&pattern),
8460 sizeof(PatternType), container.size() *
sizeof(T),
8461 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8462 (events !=
nullptr && events->size() > 0) ? (cl_event *) &events->front() :
nullptr,
8463 (
event !=
nullptr) ? &tmp : NULL), __ENQUEUE_FILL_SVM_ERR);
8465 if (event !=
nullptr && err == CL_SUCCESS)
8475 template<
typename T>
8481 const vector<Event>* events =
nullptr,
8482 Event* event =
nullptr)
const
8485 cl_int err = detail::errHandler(::clEnqueueSVMMap(
8486 object_, blocking, flags,
static_cast<void*
>(ptr), size,
8487 (events !=
nullptr) ? (cl_uint)events->size() : 0,
8488 (events !=
nullptr && events->size() > 0) ? (cl_event*)&events->front() :
nullptr,
8489 (
event !=
nullptr) ? &tmp :
nullptr),
8490 __ENQUEUE_MAP_SVM_ERR);
8492 if (event !=
nullptr && err == CL_SUCCESS)
8503 template<
typename T,
class D>
8505 cl::pointer<T, D> &ptr,
8509 const vector<Event>* events =
nullptr,
8510 Event* event =
nullptr)
const
8513 cl_int err = detail::errHandler(::clEnqueueSVMMap(
8514 object_, blocking, flags,
static_cast<void*
>(ptr.get()), size,
8515 (events !=
nullptr) ? (cl_uint)events->size() : 0,
8516 (events !=
nullptr && events->size() > 0) ? (cl_event*)&events->front() :
nullptr,
8517 (
event !=
nullptr) ? &tmp :
nullptr),
8518 __ENQUEUE_MAP_SVM_ERR);
8520 if (event !=
nullptr && err == CL_SUCCESS)
8530 template<
typename T,
class Alloc>
8532 cl::vector<T, Alloc> &container,
8535 const vector<Event>* events =
nullptr,
8536 Event* event =
nullptr)
const
8539 cl_int err = detail::errHandler(::clEnqueueSVMMap(
8540 object_, blocking, flags,
static_cast<void*
>(container.data()), container.size()*
sizeof(T),
8541 (events !=
nullptr) ? (cl_uint)events->size() : 0,
8542 (events !=
nullptr && events->size() > 0) ? (cl_event*)&events->front() :
nullptr,
8543 (
event !=
nullptr) ? &tmp :
nullptr),
8544 __ENQUEUE_MAP_SVM_ERR);
8546 if (event !=
nullptr && err == CL_SUCCESS)
8553 cl_int enqueueUnmapMemObject(
8556 const vector<Event>* events =
nullptr,
8557 Event* event =
nullptr)
const
8560 cl_int err = detail::errHandler(
8561 ::clEnqueueUnmapMemObject(
8562 object_, memory(), mapped_ptr,
8563 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8564 (events != nullptr && events->size() > 0) ? (cl_event*) &events->front() : nullptr,
8565 (event != nullptr) ? &tmp : nullptr),
8566 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8568 if (event !=
nullptr && err == CL_SUCCESS)
8575#if CL_HPP_TARGET_OPENCL_VERSION >= 200
8580 template<
typename T>
8583 const vector<Event>* events =
nullptr,
8584 Event* event =
nullptr)
const
8587 cl_int err = detail::errHandler(
8588 ::clEnqueueSVMUnmap(
8589 object_,
static_cast<void*
>(ptr),
8590 (events !=
nullptr) ? (cl_uint)events->size() : 0,
8591 (events !=
nullptr && events->size() > 0) ? (cl_event*)&events->front() :
nullptr,
8592 (
event !=
nullptr) ? &tmp :
nullptr),
8593 __ENQUEUE_UNMAP_SVM_ERR);
8595 if (event !=
nullptr && err == CL_SUCCESS)
8605 template<
typename T,
class D>
8607 cl::pointer<T, D> &ptr,
8608 const vector<Event>* events =
nullptr,
8609 Event* event =
nullptr)
const
8612 cl_int err = detail::errHandler(
8613 ::clEnqueueSVMUnmap(
8614 object_,
static_cast<void*
>(ptr.get()),
8615 (events !=
nullptr) ? (cl_uint)events->size() : 0,
8616 (events !=
nullptr && events->size() > 0) ? (cl_event*)&events->front() :
nullptr,
8617 (
event !=
nullptr) ? &tmp :
nullptr),
8618 __ENQUEUE_UNMAP_SVM_ERR);
8620 if (event !=
nullptr && err == CL_SUCCESS)
8630 template<
typename T,
class Alloc>
8632 cl::vector<T, Alloc> &container,
8633 const vector<Event>* events =
nullptr,
8634 Event* event =
nullptr)
const
8637 cl_int err = detail::errHandler(
8638 ::clEnqueueSVMUnmap(
8639 object_,
static_cast<void*
>(container.data()),
8640 (events !=
nullptr) ? (cl_uint)events->size() : 0,
8641 (events !=
nullptr && events->size() > 0) ? (cl_event*)&events->front() :
nullptr,
8642 (
event !=
nullptr) ? &tmp :
nullptr),
8643 __ENQUEUE_UNMAP_SVM_ERR);
8645 if (event !=
nullptr && err == CL_SUCCESS)
8652#if CL_HPP_TARGET_OPENCL_VERSION >= 120
8665 const vector<Event> *events =
nullptr,
8666 Event *event =
nullptr)
const
8669 cl_int err = detail::errHandler(
8670 ::clEnqueueMarkerWithWaitList(
8672 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8673 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
8674 (
event !=
nullptr) ? &tmp :
nullptr),
8675 __ENQUEUE_MARKER_WAIT_LIST_ERR);
8677 if (event !=
nullptr && err == CL_SUCCESS)
8695 const vector<Event> *events =
nullptr,
8696 Event *event =
nullptr)
const
8699 cl_int err = detail::errHandler(
8700 ::clEnqueueBarrierWithWaitList(
8702 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8703 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
8704 (
event !=
nullptr) ? &tmp :
nullptr),
8705 __ENQUEUE_BARRIER_WAIT_LIST_ERR);
8707 if (event !=
nullptr && err == CL_SUCCESS)
8718 const vector<Memory> &memObjects,
8719 cl_mem_migration_flags flags,
8720 const vector<Event>* events =
nullptr,
8721 Event* event =
nullptr
8726 vector<cl_mem> localMemObjects(memObjects.size());
8728 for(
int i = 0; i < (int)memObjects.size(); ++i ) {
8729 localMemObjects[i] = memObjects[i]();
8732 cl_int err = detail::errHandler(
8733 ::clEnqueueMigrateMemObjects(
8735 (cl_uint)memObjects.size(),
8736 localMemObjects.data(),
8738 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8739 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
8740 (
event !=
nullptr) ? &tmp :
nullptr),
8741 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8743 if (event !=
nullptr && err == CL_SUCCESS)
8751#if CL_HPP_TARGET_OPENCL_VERSION >= 210
8757 template<
typename T>
8759 const cl::vector<T*> &svmRawPointers,
8760 const cl::vector<size_type> &sizes,
8761 cl_mem_migration_flags flags = 0,
8762 const vector<Event>* events =
nullptr,
8763 Event* event =
nullptr)
const
8766 cl_int err = detail::errHandler(::clEnqueueSVMMigrateMem(
8768 svmRawPointers.size(),
static_cast<void**
>(svmRawPointers.data()),
8771 (events !=
nullptr) ? (cl_uint)events->size() : 0,
8772 (events !=
nullptr && events->size() > 0) ? (cl_event*)&events->front() :
nullptr,
8773 (
event !=
nullptr) ? &tmp :
nullptr),
8774 __ENQUEUE_MIGRATE_SVM_ERR);
8776 if (event !=
nullptr && err == CL_SUCCESS)
8786 template<
typename T>
8788 const cl::vector<T*> &svmRawPointers,
8789 cl_mem_migration_flags flags = 0,
8790 const vector<Event>* events =
nullptr,
8791 Event* event =
nullptr)
const
8793 return enqueueMigrateSVM(svmRawPointers, cl::vector<size_type>(svmRawPointers.size()), flags, events, event);
8802 template<
typename T,
class D>
8804 const cl::vector<cl::pointer<T, D>> &svmPointers,
8805 const cl::vector<size_type> &sizes,
8806 cl_mem_migration_flags flags = 0,
8807 const vector<Event>* events =
nullptr,
8808 Event* event =
nullptr)
const
8810 cl::vector<void*> svmRawPointers;
8811 svmRawPointers.reserve(svmPointers.size());
8812 for (
auto p : svmPointers) {
8813 svmRawPointers.push_back(
static_cast<void*
>(p.get()));
8824 template<
typename T,
class D>
8826 const cl::vector<cl::pointer<T, D>> &svmPointers,
8827 cl_mem_migration_flags flags = 0,
8828 const vector<Event>* events =
nullptr,
8829 Event* event =
nullptr)
const
8831 return enqueueMigrateSVM(svmPointers, cl::vector<size_type>(svmPointers.size()), flags, events, event);
8839 template<
typename T,
class Alloc>
8841 const cl::vector<cl::vector<T, Alloc>> &svmContainers,
8842 const cl::vector<size_type> &sizes,
8843 cl_mem_migration_flags flags = 0,
8844 const vector<Event>* events =
nullptr,
8845 Event* event =
nullptr)
const
8847 cl::vector<void*> svmRawPointers;
8848 svmRawPointers.reserve(svmContainers.size());
8849 for (
auto p : svmContainers) {
8850 svmRawPointers.push_back(
static_cast<void*
>(p.data()));
8860 template<
typename T,
class Alloc>
8862 const cl::vector<cl::vector<T, Alloc>> &svmContainers,
8863 cl_mem_migration_flags flags = 0,
8864 const vector<Event>* events =
nullptr,
8865 Event* event =
nullptr)
const
8867 return enqueueMigrateSVM(svmContainers, cl::vector<size_type>(svmContainers.size()), flags, events, event);
8872 cl_int enqueueNDRangeKernel(
8876 const NDRange& local = NullRange,
8877 const vector<Event>* events =
nullptr,
8878 Event* event =
nullptr)
const
8881 cl_int err = detail::errHandler(
8882 ::clEnqueueNDRangeKernel(
8883 object_, kernel(), (cl_uint) global.dimensions(),
8884 offset.dimensions() != 0 ? (
const size_type*) offset : nullptr,
8885 (const size_type*) global,
8886 local.dimensions() != 0 ? (const size_type*) local : nullptr,
8887 (events != nullptr) ? (cl_uint) events->size() : 0,
8888 (events != nullptr && events->size() > 0) ? (cl_event*) &events->front() : nullptr,
8889 (event != nullptr) ? &tmp : nullptr),
8890 __ENQUEUE_NDRANGE_KERNEL_ERR);
8892 if (event !=
nullptr && err == CL_SUCCESS)
8898#if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
8899 CL_API_PREFIX__VERSION_1_2_DEPRECATED cl_int enqueueTask(
8900 const Kernel& kernel,
8901 const vector<Event>* events =
nullptr,
8902 Event* event =
nullptr) const CL_API_SUFFIX__VERSION_1_2_DEPRECATED
8905 cl_int err = detail::errHandler(
8908 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8909 (events != nullptr && events->size() > 0) ? (cl_event*) &events->front() : nullptr,
8910 (event != nullptr) ? &tmp : nullptr),
8911 __ENQUEUE_TASK_ERR);
8913 if (event !=
nullptr && err == CL_SUCCESS)
8920 cl_int enqueueNativeKernel(
8921 void (CL_CALLBACK *userFptr)(
void *),
8922 std::pair<void*, size_type> args,
8923 const vector<Memory>* mem_objects =
nullptr,
8924 const vector<const void*>* mem_locs =
nullptr,
8925 const vector<Event>* events =
nullptr,
8926 Event* event =
nullptr)
const
8929 cl_int err = detail::errHandler(
8930 ::clEnqueueNativeKernel(
8931 object_, userFptr, args.first, args.second,
8932 (mem_objects !=
nullptr) ? (cl_uint) mem_objects->size() : 0,
8933 (mem_objects->size() > 0 ) ? reinterpret_cast<const cl_mem *>(mem_objects->data()) : nullptr,
8934 (mem_locs != nullptr && mem_locs->size() > 0) ? (const void **) &mem_locs->front() : nullptr,
8935 (events != nullptr) ? (cl_uint) events->size() : 0,
8936 (events != nullptr && events->size() > 0) ? (cl_event*) &events->front() : nullptr,
8937 (event != nullptr) ? &tmp : nullptr),
8938 __ENQUEUE_NATIVE_KERNEL);
8940 if (event !=
nullptr && err == CL_SUCCESS)
8949#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
8950 CL_API_PREFIX__VERSION_1_1_DEPRECATED
8954 cl_int err = detail::errHandler(
8957 (event !=
nullptr) ? &tmp :
nullptr),
8958 __ENQUEUE_MARKER_ERR);
8960 if (event !=
nullptr && err == CL_SUCCESS)
8966 CL_API_PREFIX__VERSION_1_1_DEPRECATED
8967 cl_int enqueueWaitForEvents(
const vector<Event>& events)
const CL_API_SUFFIX__VERSION_1_1_DEPRECATED
8969 return detail::errHandler(
8970 ::clEnqueueWaitForEvents(
8972 (cl_uint) events.size(),
8973 events.size() > 0 ? (
const cl_event*) &events.front() : nullptr),
8974 __ENQUEUE_WAIT_FOR_EVENTS_ERR);
8978 cl_int enqueueAcquireGLObjects(
8979 const vector<Memory>* mem_objects =
nullptr,
8980 const vector<Event>* events =
nullptr,
8981 Event* event =
nullptr)
const
8984 cl_int err = detail::errHandler(
8985 ::clEnqueueAcquireGLObjects(
8987 (mem_objects !=
nullptr) ? (cl_uint) mem_objects->size() : 0,
8988 (mem_objects != nullptr && mem_objects->size() > 0) ? (const cl_mem *) &mem_objects->front(): nullptr,
8989 (events != nullptr) ? (cl_uint) events->size() : 0,
8990 (events != nullptr && events->size() > 0) ? (cl_event*) &events->front() : nullptr,
8991 (event != nullptr) ? &tmp : nullptr),
8992 __ENQUEUE_ACQUIRE_GL_ERR);
8994 if (event !=
nullptr && err == CL_SUCCESS)
9000 cl_int enqueueReleaseGLObjects(
9001 const vector<Memory>* mem_objects =
nullptr,
9002 const vector<Event>* events =
nullptr,
9003 Event* event =
nullptr)
const
9006 cl_int err = detail::errHandler(
9007 ::clEnqueueReleaseGLObjects(
9009 (mem_objects !=
nullptr) ? (cl_uint) mem_objects->size() : 0,
9010 (mem_objects != nullptr && mem_objects->size() > 0) ? (const cl_mem *) &mem_objects->front(): nullptr,
9011 (events != nullptr) ? (cl_uint) events->size() : 0,
9012 (events != nullptr && events->size() > 0) ? (cl_event*) &events->front() : nullptr,
9013 (event != nullptr) ? &tmp : nullptr),
9014 __ENQUEUE_RELEASE_GL_ERR);
9016 if (event !=
nullptr && err == CL_SUCCESS)
9022#if defined (CL_HPP_USE_DX_INTEROP)
9023typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueAcquireD3D10ObjectsKHR)(
9024 cl_command_queue command_queue, cl_uint num_objects,
9025 const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
9026 const cl_event* event_wait_list, cl_event* event);
9027typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueReleaseD3D10ObjectsKHR)(
9028 cl_command_queue command_queue, cl_uint num_objects,
9029 const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
9030 const cl_event* event_wait_list, cl_event* event);
9032 cl_int enqueueAcquireD3D10Objects(
9033 const vector<Memory>* mem_objects =
nullptr,
9034 const vector<Event>* events =
nullptr,
9035 Event* event =
nullptr)
const
9037 static PFN_clEnqueueAcquireD3D10ObjectsKHR pfn_clEnqueueAcquireD3D10ObjectsKHR =
nullptr;
9038#if CL_HPP_TARGET_OPENCL_VERSION >= 120
9039 cl_context context = getInfo<CL_QUEUE_CONTEXT>();
9040 cl::Device device(getInfo<CL_QUEUE_DEVICE>());
9041 cl_platform_id platform = device.
getInfo<CL_DEVICE_PLATFORM>();
9042 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueAcquireD3D10ObjectsKHR);
9044#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
9045 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueAcquireD3D10ObjectsKHR);
9049 cl_int err = detail::errHandler(
9050 pfn_clEnqueueAcquireD3D10ObjectsKHR(
9052 (mem_objects !=
nullptr) ? (cl_uint) mem_objects->size() : 0,
9053 (mem_objects != nullptr && mem_objects->size() > 0) ? (const cl_mem *) &mem_objects->front(): nullptr,
9054 (events != nullptr) ? (cl_uint) events->size() : 0,
9055 (events != nullptr) ? (cl_event*) &events->front() : nullptr,
9056 (event != nullptr) ? &tmp : nullptr),
9057 __ENQUEUE_ACQUIRE_GL_ERR);
9059 if (event !=
nullptr && err == CL_SUCCESS)
9065 cl_int enqueueReleaseD3D10Objects(
9066 const vector<Memory>* mem_objects =
nullptr,
9067 const vector<Event>* events =
nullptr,
9068 Event* event =
nullptr)
const
9070 static PFN_clEnqueueReleaseD3D10ObjectsKHR pfn_clEnqueueReleaseD3D10ObjectsKHR =
nullptr;
9071#if CL_HPP_TARGET_OPENCL_VERSION >= 120
9072 cl_context context = getInfo<CL_QUEUE_CONTEXT>();
9073 cl::Device device(getInfo<CL_QUEUE_DEVICE>());
9074 cl_platform_id platform = device.
getInfo<CL_DEVICE_PLATFORM>();
9075 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueReleaseD3D10ObjectsKHR);
9077#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
9078 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueReleaseD3D10ObjectsKHR);
9082 cl_int err = detail::errHandler(
9083 pfn_clEnqueueReleaseD3D10ObjectsKHR(
9085 (mem_objects !=
nullptr) ? (cl_uint) mem_objects->size() : 0,
9086 (mem_objects != nullptr && mem_objects->size() > 0) ? (const cl_mem *) &mem_objects->front(): nullptr,
9087 (events != nullptr) ? (cl_uint) events->size() : 0,
9088 (events != nullptr && events->size() > 0) ? (cl_event*) &events->front() : nullptr,
9089 (event != nullptr) ? &tmp : nullptr),
9090 __ENQUEUE_RELEASE_GL_ERR);
9092 if (event !=
nullptr && err == CL_SUCCESS)
9102#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
9103 CL_API_PREFIX__VERSION_1_1_DEPRECATED
9106 return detail::errHandler(
9107 ::clEnqueueBarrier(object_),
9108 __ENQUEUE_BARRIER_ERR);
9112 cl_int flush()
const
9114 return detail::errHandler(::clFlush(object_), __FLUSH_ERR);
9117 cl_int finish()
const
9119 return detail::errHandler(::clFinish(object_), __FINISH_ERR);
9122#ifdef cl_khr_external_memory
9123 cl_int enqueueAcquireExternalMemObjects(
9124 const vector<Memory>& mem_objects,
9125 const vector<Event>* events_wait =
nullptr,
9126 Event *event =
nullptr)
9128 cl_int err = CL_INVALID_OPERATION;
9131 std::call_once(ext_memory_initialized_, initMemoryExtension, this->getInfo<CL_QUEUE_DEVICE>());
9133 if (pfn_clEnqueueAcquireExternalMemObjectsKHR)
9135 err = pfn_clEnqueueAcquireExternalMemObjectsKHR(
9137 static_cast<cl_uint
>(mem_objects.size()),
9138 (mem_objects.size() > 0) ?
reinterpret_cast<const cl_mem *
>(mem_objects.data()) : nullptr,
9139 (events_wait != nullptr) ? static_cast<cl_uint>(events_wait->size()) : 0,
9140 (events_wait != nullptr && events_wait->size() > 0) ? reinterpret_cast<const cl_event*>(events_wait->data()) : nullptr,
9144 detail::errHandler(err, __ENQUEUE_ACQUIRE_EXTERNAL_MEMORY_ERR);
9146 if (event !=
nullptr && err == CL_SUCCESS)
9152 cl_int enqueueReleaseExternalMemObjects(
9153 const vector<Memory>& mem_objects,
9154 const vector<Event>* events_wait =
nullptr,
9155 Event *event =
nullptr)
9157 cl_int err = CL_INVALID_OPERATION;
9160 std::call_once(ext_memory_initialized_, initMemoryExtension, this->getInfo<CL_QUEUE_DEVICE>());
9162 if (pfn_clEnqueueReleaseExternalMemObjectsKHR)
9164 err = pfn_clEnqueueReleaseExternalMemObjectsKHR(
9166 static_cast<cl_uint
>(mem_objects.size()),
9167 (mem_objects.size() > 0) ?
reinterpret_cast<const cl_mem *
>(mem_objects.data()) : nullptr,
9168 (events_wait != nullptr) ? static_cast<cl_uint>(events_wait->size()) : 0,
9169 (events_wait != nullptr && events_wait->size() > 0) ? reinterpret_cast<const cl_event*>(events_wait->data()) : nullptr,
9173 detail::errHandler(err, __ENQUEUE_RELEASE_EXTERNAL_MEMORY_ERR);
9175 if (event !=
nullptr && err == CL_SUCCESS)
9182#ifdef cl_khr_semaphore
9183 cl_int enqueueWaitSemaphores(
9184 const vector<Semaphore> &sema_objects,
9185 const vector<cl_semaphore_payload_khr> &sema_payloads = {},
9186 const vector<Event>* events_wait_list =
nullptr,
9187 Event *
event =
nullptr)
const;
9189 cl_int enqueueSignalSemaphores(
9190 const vector<Semaphore> &sema_objects,
9191 const vector<cl_semaphore_payload_khr>& sema_payloads = {},
9192 const vector<Event>* events_wait_list =
nullptr,
9193 Event*
event =
nullptr);
9197#ifdef cl_khr_external_memory
9198CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag CommandQueue::ext_memory_initialized_;
9201CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag CommandQueue::default_initialized_;
9202CL_HPP_DEFINE_STATIC_MEMBER_ CommandQueue CommandQueue::default_;
9203CL_HPP_DEFINE_STATIC_MEMBER_ cl_int CommandQueue::default_error_ = CL_SUCCESS;
9206#if CL_HPP_TARGET_OPENCL_VERSION >= 200
9207enum class DeviceQueueProperties : cl_command_queue_properties
9210 Profiling = CL_QUEUE_PROFILING_ENABLE,
9213inline DeviceQueueProperties operator|(DeviceQueueProperties lhs, DeviceQueueProperties rhs)
9215 return static_cast<DeviceQueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) |
static_cast<cl_command_queue_properties
>(rhs));
9239 cl_command_queue_properties mergedProperties =
9240 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
9242 cl_queue_properties queue_properties[] = {
9243 CL_QUEUE_PROPERTIES, mergedProperties, 0 };
9244 object_ = ::clCreateCommandQueueWithProperties(
9245 context(), device(), queue_properties, &error);
9247 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9248 if (err !=
nullptr) {
9259 DeviceQueueProperties properties = DeviceQueueProperties::None,
9260 cl_int* err =
nullptr)
9264 cl_command_queue_properties mergedProperties =
9265 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
9266 cl_queue_properties queue_properties[] = {
9267 CL_QUEUE_PROPERTIES, mergedProperties, 0 };
9268 object_ = ::clCreateCommandQueueWithProperties(
9269 context(), device(), queue_properties, &error);
9271 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9272 if (err !=
nullptr) {
9284 DeviceQueueProperties properties = DeviceQueueProperties::None,
9285 cl_int* err =
nullptr)
9289 cl_command_queue_properties mergedProperties =
9290 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
9291 cl_queue_properties queue_properties[] = {
9292 CL_QUEUE_PROPERTIES, mergedProperties,
9293 CL_QUEUE_SIZE, queueSize,
9295 object_ = ::clCreateCommandQueueWithProperties(
9296 context(), device(), queue_properties, &error);
9298 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9299 if (err !=
nullptr) {
9311 detail::Wrapper<cl_type>(commandQueue, retainObject) { }
9319 template <
typename T>
9320 cl_int getInfo(cl_command_queue_info name, T* param)
const
9322 return detail::errHandler(
9324 &::clGetCommandQueueInfo, object_, name, param),
9325 __GET_COMMAND_QUEUE_INFO_ERR);
9328 template <cl_command_queue_info name>
typename
9329 detail::param_traits<detail::cl_command_queue_info, name>::param_type
9330 getInfo(cl_int* err =
nullptr)
const
9332 typename detail::param_traits<
9333 detail::cl_command_queue_info, name>::param_type param;
9334 cl_int result = getInfo(name, ¶m);
9335 if (err !=
nullptr) {
9348 cl_int *err =
nullptr)
9354 cl_command_queue_properties properties =
9355 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
9356 cl_queue_properties queue_properties[] = {
9357 CL_QUEUE_PROPERTIES, properties,
9360 ::clCreateCommandQueueWithProperties(
9361 context(), device(), queue_properties, &error));
9363 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9364 if (err !=
nullptr) {
9378 const Context &context,
const Device &device, cl_int *err =
nullptr)
9382 cl_command_queue_properties properties =
9383 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
9384 cl_queue_properties queue_properties[] = {
9385 CL_QUEUE_PROPERTIES, properties,
9388 ::clCreateCommandQueueWithProperties(
9389 context(), device(), queue_properties, &error));
9391 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9392 if (err !=
nullptr) {
9406 const Context &context,
const Device &device, cl_uint queueSize, cl_int *err =
nullptr)
9410 cl_command_queue_properties properties =
9411 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
9412 cl_queue_properties queue_properties[] = {
9413 CL_QUEUE_PROPERTIES, properties,
9414 CL_QUEUE_SIZE, queueSize,
9417 ::clCreateCommandQueueWithProperties(
9418 context(), device(), queue_properties, &error));
9420 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9421 if (err !=
nullptr) {
9430#if CL_HPP_TARGET_OPENCL_VERSION >= 210
9440 error = clSetDefaultDeviceCommandQueue(context.get(), device.get(), default_queue.get());
9442 detail::errHandler(error, __SET_DEFAULT_DEVICE_COMMAND_QUEUE_ERR);
9443 if (err !=
nullptr) {
9446 return default_queue;
9454 return queue.getInfo<CL_QUEUE_DEVICE_DEFAULT>(err);
9474template<
typename IteratorType >
9477 IteratorType startIterator,
9478 IteratorType endIterator,
9483 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9486 cl_mem_flags flags = 0;
9488 flags |= CL_MEM_READ_ONLY;
9491 flags |= CL_MEM_READ_WRITE;
9494 flags |= CL_MEM_USE_HOST_PTR;
9497 size_type size =
sizeof(DataType)*(endIterator - startIterator);
9500 object_ = ::clCreateBuffer(context(), flags, size,
const_cast<DataType*
>(&*startIterator), &error);
9502 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
9505 detail::errHandler(error, __CREATE_BUFFER_ERR);
9506 if (err !=
nullptr) {
9512 detail::errHandler(error, __CREATE_BUFFER_ERR);
9513 if (err !=
nullptr) {
9517 error =
cl::copy(queue, startIterator, endIterator, *
this);
9518 detail::errHandler(error, __CREATE_BUFFER_ERR);
9519 if (err !=
nullptr) {
9525template<
typename IteratorType >
9528 IteratorType startIterator,
9529 IteratorType endIterator,
9534 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9537 cl_mem_flags flags = 0;
9539 flags |= CL_MEM_READ_ONLY;
9542 flags |= CL_MEM_READ_WRITE;
9545 flags |= CL_MEM_USE_HOST_PTR;
9548 size_type size =
sizeof(DataType)*(endIterator - startIterator);
9553 object_ = ::clCreateBuffer(context(), flags, size,
const_cast<DataType*
>(&*startIterator), &error);
9556 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
9559 detail::errHandler(error, __CREATE_BUFFER_ERR);
9560 if (err !=
nullptr) {
9565 error =
cl::copy(queue, startIterator, endIterator, *
this);
9566 detail::errHandler(error, __CREATE_BUFFER_ERR);
9567 if (err !=
nullptr) {
9573inline cl_int enqueueReadBuffer(
9579 const vector<Event>* events =
nullptr,
9580 Event* event =
nullptr)
9585 if (error != CL_SUCCESS) {
9589 return queue.enqueueReadBuffer(buffer, blocking, offset, size, ptr, events, event);
9592inline cl_int enqueueWriteBuffer(
9593 const Buffer& buffer,
9598 const vector<Event>* events =
nullptr,
9599 Event* event =
nullptr)
9602 CommandQueue queue = CommandQueue::getDefault(&error);
9604 if (error != CL_SUCCESS) {
9608 return queue.enqueueWriteBuffer(buffer, blocking, offset, size, ptr, events, event);
9611inline void* enqueueMapBuffer(
9612 const Buffer& buffer,
9617 const vector<Event>* events =
nullptr,
9618 Event* event =
nullptr,
9619 cl_int* err =
nullptr)
9622 CommandQueue queue = CommandQueue::getDefault(&error);
9623 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9624 if (err !=
nullptr) {
9628 void * result = ::clEnqueueMapBuffer(
9629 queue(), buffer(), blocking, flags, offset, size,
9630 (events !=
nullptr) ? (cl_uint) events->size() : 0,
9631 (events != nullptr && events->size() > 0) ? (cl_event*) &events->front() : nullptr,
9635 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9636 if (err !=
nullptr) {
9643#if CL_HPP_TARGET_OPENCL_VERSION >= 200
9655 const vector<Event>* events,
9660 if (error != CL_SUCCESS) {
9661 return detail::errHandler(error, __ENQUEUE_MAP_SVM_ERR);
9664 return queue.enqueueMapSVM(
9665 ptr, blocking, flags, size, events, event);
9673template<
typename T,
class D>
9675 cl::pointer<T, D> &ptr,
9679 const vector<Event>* events =
nullptr,
9680 Event* event =
nullptr)
9684 if (error != CL_SUCCESS) {
9685 return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9688 return queue.enqueueMapSVM(
9689 ptr, blocking, flags, size, events, event);
9697template<
typename T,
class Alloc>
9699 cl::vector<T, Alloc> &container,
9702 const vector<Event>* events =
nullptr,
9703 Event* event =
nullptr)
9707 if (error != CL_SUCCESS) {
9708 return detail::errHandler(error, __ENQUEUE_MAP_SVM_ERR);
9711 return queue.enqueueMapSVM(
9712 container, blocking, flags, events, event);
9717inline cl_int enqueueUnmapMemObject(
9718 const Memory& memory,
9720 const vector<Event>* events =
nullptr,
9721 Event* event =
nullptr)
9724 CommandQueue queue = CommandQueue::getDefault(&error);
9725 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9726 if (error != CL_SUCCESS) {
9731 cl_int err = detail::errHandler(
9732 ::clEnqueueUnmapMemObject(
9733 queue(), memory(), mapped_ptr,
9734 (events !=
nullptr) ? (cl_uint)events->size() : 0,
9735 (events != nullptr && events->size() > 0) ? (cl_event*)&events->front() : nullptr,
9736 (event != nullptr) ? &tmp : nullptr),
9737 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9739 if (event !=
nullptr && err == CL_SUCCESS)
9745#if CL_HPP_TARGET_OPENCL_VERSION >= 200
9754 const vector<Event>* events =
nullptr,
9755 Event* event =
nullptr)
9759 if (error != CL_SUCCESS) {
9760 return detail::errHandler(error, __ENQUEUE_UNMAP_SVM_ERR);
9763 return detail::errHandler(queue.enqueueUnmapSVM(ptr, events, event),
9764 __ENQUEUE_UNMAP_SVM_ERR);
9773template<
typename T,
class D>
9775 cl::pointer<T, D> &ptr,
9776 const vector<Event>* events =
nullptr,
9777 Event* event =
nullptr)
9781 if (error != CL_SUCCESS) {
9782 return detail::errHandler(error, __ENQUEUE_UNMAP_SVM_ERR);
9785 return detail::errHandler(queue.enqueueUnmapSVM(ptr, events, event),
9786 __ENQUEUE_UNMAP_SVM_ERR);
9794template<
typename T,
class Alloc>
9796 cl::vector<T, Alloc> &container,
9797 const vector<Event>* events =
nullptr,
9798 Event* event =
nullptr)
9802 if (error != CL_SUCCESS) {
9803 return detail::errHandler(error, __ENQUEUE_UNMAP_SVM_ERR);
9806 return detail::errHandler(queue.enqueueUnmapSVM(container, events, event),
9807 __ENQUEUE_UNMAP_SVM_ERR);
9812inline cl_int enqueueCopyBuffer(
9815 size_type src_offset,
9816 size_type dst_offset,
9818 const vector<Event>* events =
nullptr,
9819 Event* event =
nullptr)
9822 CommandQueue queue = CommandQueue::getDefault(&error);
9824 if (error != CL_SUCCESS) {
9828 return queue.enqueueCopyBuffer(src, dst, src_offset, dst_offset, size, events, event);
9836template<
typename IteratorType >
9837inline cl_int
copy( IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer )
9841 if (error != CL_SUCCESS)
9844 return cl::copy(queue, startIterator, endIterator, buffer);
9852template<
typename IteratorType >
9853inline cl_int
copy(
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator )
9857 if (error != CL_SUCCESS)
9860 return cl::copy(queue, buffer, startIterator, endIterator);
9868template<
typename IteratorType >
9871 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9874 size_type length = endIterator-startIterator;
9875 size_type byteLength = length*
sizeof(DataType);
9878 static_cast<DataType*
>(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_WRITE, 0, byteLength, 0, 0, &error));
9880 if( error != CL_SUCCESS ) {
9883#if defined(_MSC_VER)
9887 stdext::checked_array_iterator<DataType*>(
9890 std::copy(startIterator, endIterator, pointer);
9893 error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
9895 if( error != CL_SUCCESS ) {
9907template<
typename IteratorType >
9910 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9913 size_type length = endIterator-startIterator;
9914 size_type byteLength = length*
sizeof(DataType);
9917 static_cast<DataType*
>(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_READ, 0, byteLength, 0, 0, &error));
9919 if( error != CL_SUCCESS ) {
9922 std::copy(pointer, pointer + length, startIterator);
9924 error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
9926 if( error != CL_SUCCESS ) {
9934#if CL_HPP_TARGET_OPENCL_VERSION >= 200
9938template<
typename T,
class Alloc>
9939inline cl_int
mapSVM(cl::vector<T, Alloc> &container)
9941 return enqueueMapSVM(container, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE);
9947template<
typename T,
class Alloc>
9955#if CL_HPP_TARGET_OPENCL_VERSION >= 110
9956inline cl_int enqueueReadBufferRect(
9957 const Buffer& buffer,
9959 const array<size_type, 3>& buffer_offset,
9960 const array<size_type, 3>& host_offset,
9961 const array<size_type, 3>& region,
9962 size_type buffer_row_pitch,
9963 size_type buffer_slice_pitch,
9964 size_type host_row_pitch,
9965 size_type host_slice_pitch,
9967 const vector<Event>* events =
nullptr,
9968 Event* event =
nullptr)
9971 CommandQueue queue = CommandQueue::getDefault(&error);
9973 if (error != CL_SUCCESS) {
9977 return queue.enqueueReadBufferRect(
9992inline cl_int enqueueReadBufferRect(
9993 const Buffer& buffer,
9995 const array<size_type, 2>& buffer_offset,
9996 const array<size_type, 2>& host_offset,
9997 const array<size_type, 2>& region,
9998 size_type buffer_row_pitch,
9999 size_type buffer_slice_pitch,
10000 size_type host_row_pitch,
10001 size_type host_slice_pitch,
10003 const vector<Event>* events =
nullptr,
10004 Event* event =
nullptr)
10006 return enqueueReadBufferRect(
10009 { buffer_offset[0], buffer_offset[1], 0 },
10010 { host_offset[0], host_offset[1], 0 },
10011 { region[0], region[1], 1 },
10013 buffer_slice_pitch,
10021inline cl_int enqueueWriteBufferRect(
10022 const Buffer& buffer,
10024 const array<size_type, 3>& buffer_offset,
10025 const array<size_type, 3>& host_offset,
10026 const array<size_type, 3>& region,
10027 size_type buffer_row_pitch,
10028 size_type buffer_slice_pitch,
10029 size_type host_row_pitch,
10030 size_type host_slice_pitch,
10032 const vector<Event>* events =
nullptr,
10033 Event* event =
nullptr)
10036 CommandQueue queue = CommandQueue::getDefault(&error);
10038 if (error != CL_SUCCESS) {
10042 return queue.enqueueWriteBufferRect(
10049 buffer_slice_pitch,
10057inline cl_int enqueueWriteBufferRect(
10058 const Buffer& buffer,
10060 const array<size_type, 2>& buffer_offset,
10061 const array<size_type, 2>& host_offset,
10062 const array<size_type, 2>& region,
10063 size_type buffer_row_pitch,
10064 size_type buffer_slice_pitch,
10065 size_type host_row_pitch,
10066 size_type host_slice_pitch,
10068 const vector<Event>* events =
nullptr,
10069 Event* event =
nullptr)
10071 return enqueueWriteBufferRect(
10074 { buffer_offset[0], buffer_offset[1], 0 },
10075 { host_offset[0], host_offset[1], 0 },
10076 { region[0], region[1], 1 },
10078 buffer_slice_pitch,
10086inline cl_int enqueueCopyBufferRect(
10089 const array<size_type, 3>& src_origin,
10090 const array<size_type, 3>& dst_origin,
10091 const array<size_type, 3>& region,
10092 size_type src_row_pitch,
10093 size_type src_slice_pitch,
10094 size_type dst_row_pitch,
10095 size_type dst_slice_pitch,
10096 const vector<Event>* events =
nullptr,
10097 Event* event =
nullptr)
10100 CommandQueue queue = CommandQueue::getDefault(&error);
10102 if (error != CL_SUCCESS) {
10106 return queue.enqueueCopyBufferRect(
10120inline cl_int enqueueCopyBufferRect(
10123 const array<size_type, 2>& src_origin,
10124 const array<size_type, 2>& dst_origin,
10125 const array<size_type, 2>& region,
10126 size_type src_row_pitch,
10127 size_type src_slice_pitch,
10128 size_type dst_row_pitch,
10129 size_type dst_slice_pitch,
10130 const vector<Event>* events =
nullptr,
10131 Event* event =
nullptr)
10133 return enqueueCopyBufferRect(
10136 { src_origin[0], src_origin[1], 0 },
10137 { dst_origin[0], dst_origin[1], 0 },
10138 { region[0], region[1], 1 },
10148inline cl_int enqueueReadImage(
10149 const Image& image,
10151 const array<size_type, 3>& origin,
10152 const array<size_type, 3>& region,
10153 size_type row_pitch,
10154 size_type slice_pitch,
10156 const vector<Event>* events =
nullptr,
10157 Event* event =
nullptr)
10160 CommandQueue queue = CommandQueue::getDefault(&error);
10162 if (error != CL_SUCCESS) {
10166 return queue.enqueueReadImage(
10178inline cl_int enqueueReadImage(
10179 const Image& image,
10181 const array<size_type, 2>& origin,
10182 const array<size_type, 2>& region,
10183 size_type row_pitch,
10184 size_type slice_pitch,
10186 const vector<Event>* events =
nullptr,
10187 Event* event =
nullptr)
10189 return enqueueReadImage(
10192 { origin[0], origin[1], 0 },
10193 { region[0], region[1], 1 },
10201inline cl_int enqueueWriteImage(
10202 const Image& image,
10204 const array<size_type, 3>& origin,
10205 const array<size_type, 3>& region,
10206 size_type row_pitch,
10207 size_type slice_pitch,
10209 const vector<Event>* events =
nullptr,
10210 Event* event =
nullptr)
10213 CommandQueue queue = CommandQueue::getDefault(&error);
10215 if (error != CL_SUCCESS) {
10219 return queue.enqueueWriteImage(
10231inline cl_int enqueueWriteImage(
10232 const Image& image,
10234 const array<size_type, 2>& origin,
10235 const array<size_type, 2>& region,
10236 size_type row_pitch,
10237 size_type slice_pitch,
10239 const vector<Event>* events =
nullptr,
10240 Event* event =
nullptr)
10242 return enqueueWriteImage(
10245 { origin[0], origin[1], 0 },
10246 { region[0], region[1], 1 },
10254inline cl_int enqueueCopyImage(
10257 const array<size_type, 3>& src_origin,
10258 const array<size_type, 3>& dst_origin,
10259 const array<size_type, 3>& region,
10260 const vector<Event>* events =
nullptr,
10261 Event* event =
nullptr)
10264 CommandQueue queue = CommandQueue::getDefault(&error);
10266 if (error != CL_SUCCESS) {
10270 return queue.enqueueCopyImage(
10280inline cl_int enqueueCopyImage(
10283 const array<size_type, 2>& src_origin,
10284 const array<size_type, 2>& dst_origin,
10285 const array<size_type, 2>& region,
10286 const vector<Event>* events =
nullptr,
10287 Event* event =
nullptr)
10289 return enqueueCopyImage(
10292 { src_origin[0], src_origin[1], 0 },
10293 { dst_origin[0], dst_origin[1], 0 },
10294 { region[0], region[1], 1 },
10299inline cl_int enqueueCopyImageToBuffer(
10302 const array<size_type, 3>& src_origin,
10303 const array<size_type, 3>& region,
10304 size_type dst_offset,
10305 const vector<Event>* events =
nullptr,
10306 Event* event =
nullptr)
10309 CommandQueue queue = CommandQueue::getDefault(&error);
10311 if (error != CL_SUCCESS) {
10315 return queue.enqueueCopyImageToBuffer(
10325inline cl_int enqueueCopyImageToBuffer(
10328 const array<size_type, 2>& src_origin,
10329 const array<size_type, 2>& region,
10330 size_type dst_offset,
10331 const vector<Event>* events =
nullptr,
10332 Event* event =
nullptr)
10334 return enqueueCopyImageToBuffer(
10337 { src_origin[0], src_origin[1], 0 },
10338 { region[0], region[1], 1 },
10344inline cl_int enqueueCopyBufferToImage(
10347 size_type src_offset,
10348 const array<size_type, 3>& dst_origin,
10349 const array<size_type, 3>& region,
10350 const vector<Event>* events =
nullptr,
10351 Event* event =
nullptr)
10354 CommandQueue queue = CommandQueue::getDefault(&error);
10356 if (error != CL_SUCCESS) {
10360 return queue.enqueueCopyBufferToImage(
10370inline cl_int enqueueCopyBufferToImage(
10373 size_type src_offset,
10374 const array<size_type, 2>& dst_origin,
10375 const array<size_type, 2>& region,
10376 const vector<Event>* events =
nullptr,
10377 Event* event =
nullptr)
10380 CommandQueue queue = CommandQueue::getDefault(&error);
10382 if (error != CL_SUCCESS) {
10386 return enqueueCopyBufferToImage(
10390 { dst_origin[0], dst_origin[1], 0 },
10391 { region[0], region[1], 1 },
10396inline cl_int flush(
void)
10399 CommandQueue queue = CommandQueue::getDefault(&error);
10401 if (error != CL_SUCCESS) {
10405 return queue.flush();
10408inline cl_int finish(
void)
10411 CommandQueue queue = CommandQueue::getDefault(&error);
10413 if (error != CL_SUCCESS) {
10418 return queue.finish();
10428 vector<Event> events_;
10430 template<
typename... Ts>
10435 queue_(CommandQueue::getDefault()),
10436 offset_(NullRange),
10444 queue_(CommandQueue::getDefault()),
10445 offset_(NullRange),
10453 queue_(CommandQueue::getDefault()),
10462 queue_(CommandQueue::getDefault()),
10463 offset_(NullRange),
10467 events_.push_back(e);
10471 queue_(CommandQueue::getDefault()),
10472 offset_(NullRange),
10476 events_.push_back(e);
10480 queue_(CommandQueue::getDefault()),
10485 events_.push_back(e);
10489 queue_(CommandQueue::getDefault()),
10490 offset_(NullRange),
10499 queue_(CommandQueue::getDefault()),
10500 offset_(NullRange),
10509 queue_(CommandQueue::getDefault()),
10520 offset_(NullRange),
10529 offset_(NullRange),
10547 offset_(NullRange),
10551 events_.push_back(e);
10556 offset_(NullRange),
10560 events_.push_back(e);
10569 events_.push_back(e);
10574 offset_(NullRange),
10584 offset_(NullRange),
10611template<
typename... Ts>
10617 template<
int index,
typename T0,
typename... T1s>
10618 void setArgs(T0&& t0, T1s&&... t1s)
10620 kernel_.
setArg(index, t0);
10621 setArgs<index + 1, T1s...>(std::forward<T1s>(t1s)...);
10624 template<
int index,
typename T0>
10625 void setArgs(T0&& t0)
10627 kernel_.
setArg(index, t0);
10630 template<
int index>
10643 cl_int * err =
nullptr) :
10644 kernel_(program, name.c_str(), err)
10660 setArgs<0>(std::forward<Ts>(ts)...);
10662 args.queue_.enqueueNDRangeKernel(
10685 setArgs<0>(std::forward<Ts>(ts)...);
10687 error = args.queue_.enqueueNDRangeKernel(
10698#if CL_HPP_TARGET_OPENCL_VERSION >= 200
10699 cl_int setSVMPointers(
const vector<void*> &pointerList)
10704 template<
typename T0,
typename... T1s>
10705 cl_int setSVMPointers(
const T0 &t0, T1s &... ts)
10717namespace compatibility {
10722 template<
typename... Ts>
10732 cl_int * err =
nullptr) :
10754 enqueueArgs, args...);
10759#ifdef cl_khr_semaphore
10761#ifdef cl_khr_external_semaphore
10762enum ExternalSemaphoreType : cl_external_semaphore_handle_type_khr
10765#ifdef cl_khr_external_semaphore_dx_fence
10766 D3D12Fence = CL_SEMAPHORE_HANDLE_D3D12_FENCE_KHR,
10768#ifdef cl_khr_external_semaphore_opaque_fd
10769 OpaqueFd = CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR,
10771#ifdef cl_khr_external_semaphore_sync_fd
10772 SyncFd = CL_SEMAPHORE_HANDLE_SYNC_FD_KHR,
10774#ifdef cl_khr_external_semaphore_win32
10775 OpaqueWin32 = CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KHR,
10776 OpaqueWin32Kmt = CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KMT_KHR,
10781class Semaphore :
public detail::Wrapper<cl_semaphore_khr>
10784 Semaphore() : detail::Wrapper<cl_type>() {}
10786 const Context &context,
10787 const vector<cl_semaphore_properties_khr>& sema_props,
10788 cl_int *err =
nullptr)
10791 std::call_once(ext_init_, initExtensions, context);
10793 cl_int error = CL_INVALID_OPERATION;
10795 if (pfn_clCreateSemaphoreWithPropertiesKHR)
10797 object_ = pfn_clCreateSemaphoreWithPropertiesKHR(
10803 detail::errHandler(error, __CREATE_SEMAPHORE_KHR_WITH_PROPERTIES_ERR);
10805 if (err !=
nullptr) {
10810 const vector<cl_semaphore_properties_khr>& sema_props,
10811 cl_int* err =
nullptr):Semaphore(Context::getDefault(err), sema_props, err) {}
10813 explicit Semaphore(
const cl_semaphore_khr& semaphore,
bool retainObject =
false) :
10814 detail::Wrapper<cl_type>(semaphore, retainObject) {}
10815 Semaphore& operator = (
const cl_semaphore_khr& rhs) {
10816 detail::Wrapper<cl_type>::operator=(rhs);
10819 template <
typename T>
10820 cl_int getInfo(cl_semaphore_info_khr name, T* param)
const
10822 if (pfn_clGetSemaphoreInfoKHR ==
nullptr) {
10823 return detail::errHandler(CL_INVALID_OPERATION,
10824 __GET_SEMAPHORE_KHR_INFO_ERR);
10827 return detail::errHandler(
10828 detail::getInfo(pfn_clGetSemaphoreInfoKHR, object_, name, param),
10829 __GET_SEMAPHORE_KHR_INFO_ERR);
10831 template <cl_semaphore_info_khr name>
typename
10832 detail::param_traits<detail::cl_semaphore_info_khr, name>::param_type
10833 getInfo(cl_int* err =
nullptr)
const
10835 typename detail::param_traits<
10836 detail::cl_semaphore_info_khr, name>::param_type param;
10837 cl_int result = getInfo(name, ¶m);
10838 if (err !=
nullptr) {
10844#ifdef cl_khr_external_semaphore
10845 template <
typename T>
10846 cl_int getHandleForTypeKHR(
10847 const Device& device, cl_external_semaphore_handle_type_khr name, T* param)
const
10849 if (pfn_clGetSemaphoreHandleForTypeKHR ==
nullptr) {
10850 return detail::errHandler(CL_INVALID_OPERATION,
10851 __GET_SEMAPHORE_HANDLE_FOR_TYPE_KHR_ERR);
10854 return detail::errHandler(
10856 pfn_clGetSemaphoreHandleForTypeKHR, object_, device(), name, param),
10857 __GET_SEMAPHORE_HANDLE_FOR_TYPE_KHR_ERR);
10860 template <cl_external_semaphore_handle_type_khr type>
typename
10861 detail::param_traits<detail::cl_external_semaphore_handle_type_khr, type>::param_type
10862 getHandleForTypeKHR(
const Device& device, cl_int* err =
nullptr)
const
10864 typename detail::param_traits<
10865 detail::cl_external_semaphore_handle_type_khr, type>::param_type param;
10866 cl_int result = getHandleForTypeKHR(device, type, ¶m);
10867 if (err !=
nullptr) {
10876 if (pfn_clRetainSemaphoreKHR ==
nullptr) {
10877 return detail::errHandler(CL_INVALID_OPERATION,
10878 __RETAIN_SEMAPHORE_KHR_ERR);
10880 return pfn_clRetainSemaphoreKHR(object_);
10885 if (pfn_clReleaseSemaphoreKHR ==
nullptr) {
10886 return detail::errHandler(CL_INVALID_OPERATION,
10887 __RELEASE_SEMAPHORE_KHR_ERR);
10889 return pfn_clReleaseSemaphoreKHR(object_);
10893 static std::once_flag ext_init_;
10895 static void initExtensions(
const Context& context)
10897#if CL_HPP_TARGET_OPENCL_VERSION >= 120
10898 Device device = context.getInfo<CL_CONTEXT_DEVICES>().at(0);
10899 cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>()();
10900 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCreateSemaphoreWithPropertiesKHR);
10901 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clReleaseSemaphoreKHR);
10902 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clRetainSemaphoreKHR);
10903 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueWaitSemaphoresKHR);
10904 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueSignalSemaphoresKHR);
10905 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clGetSemaphoreInfoKHR);
10906#ifdef cl_khr_external_semaphore
10907 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clGetSemaphoreHandleForTypeKHR);
10911 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateSemaphoreWithPropertiesKHR);
10912 CL_HPP_INIT_CL_EXT_FCN_PTR_(clReleaseSemaphoreKHR);
10913 CL_HPP_INIT_CL_EXT_FCN_PTR_(clRetainSemaphoreKHR);
10914 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueWaitSemaphoresKHR);
10915 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueSignalSemaphoresKHR);
10916 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetSemaphoreInfoKHR);
10917#ifdef cl_khr_external_semaphore
10918 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetSemaphoreHandleForTypeKHR);
10922 if ((pfn_clCreateSemaphoreWithPropertiesKHR ==
nullptr) &&
10923 (pfn_clReleaseSemaphoreKHR ==
nullptr) &&
10924 (pfn_clRetainSemaphoreKHR ==
nullptr) &&
10925 (pfn_clEnqueueWaitSemaphoresKHR ==
nullptr) &&
10926 (pfn_clEnqueueSignalSemaphoresKHR ==
nullptr) &&
10927#ifdef cl_khr_external_semaphore
10928 (pfn_clGetSemaphoreHandleForTypeKHR ==
nullptr) &&
10930 (pfn_clGetSemaphoreInfoKHR ==
nullptr))
10932 detail::errHandler(CL_INVALID_VALUE, __CREATE_SEMAPHORE_KHR_WITH_PROPERTIES_ERR);
10938CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Semaphore::ext_init_;
10940inline cl_int CommandQueue::enqueueWaitSemaphores(
10941 const vector<Semaphore> &sema_objects,
10942 const vector<cl_semaphore_payload_khr> &sema_payloads,
10943 const vector<Event>* events_wait_list,
10944 Event *event)
const
10947 cl_int err = CL_INVALID_OPERATION;
10949 if (pfn_clEnqueueWaitSemaphoresKHR !=
nullptr) {
10950 err = pfn_clEnqueueWaitSemaphoresKHR(
10952 (cl_uint)sema_objects.size(),
10953 (
const cl_semaphore_khr *) &sema_objects.front(),
10954 (sema_payloads.size() > 0) ? &sema_payloads.front() : nullptr,
10955 (events_wait_list != nullptr) ? (cl_uint) events_wait_list->size() : 0,
10956 (events_wait_list != nullptr && events_wait_list->size() > 0) ? (cl_event*) &events_wait_list->front() : nullptr,
10957 (event != nullptr) ? &tmp : nullptr);
10960 detail::errHandler(err, __ENQUEUE_WAIT_SEMAPHORE_KHR_ERR);
10962 if (event !=
nullptr && err == CL_SUCCESS)
10968inline cl_int CommandQueue::enqueueSignalSemaphores(
10969 const vector<Semaphore> &sema_objects,
10970 const vector<cl_semaphore_payload_khr>& sema_payloads,
10971 const vector<Event>* events_wait_list,
10975 cl_int err = CL_INVALID_OPERATION;
10977 if (pfn_clEnqueueSignalSemaphoresKHR !=
nullptr) {
10978 err = pfn_clEnqueueSignalSemaphoresKHR(
10980 (cl_uint)sema_objects.size(),
10981 (
const cl_semaphore_khr*) &sema_objects.front(),
10982 (sema_payloads.size() > 0) ? &sema_payloads.front() : nullptr,
10983 (events_wait_list != nullptr) ? (cl_uint) events_wait_list->size() : 0,
10984 (events_wait_list != nullptr && events_wait_list->size() > 0) ? (cl_event*) &events_wait_list->front() : nullptr,
10985 (event != nullptr) ? &tmp : nullptr);
10988 detail::errHandler(err, __ENQUEUE_SIGNAL_SEMAPHORE_KHR_ERR);
10990 if (event !=
nullptr && err == CL_SUCCESS)
10998#if defined(cl_khr_command_buffer)
11002class CommandBufferKhr :
public detail::Wrapper<cl_command_buffer_khr>
11006 CommandBufferKhr() : detail::Wrapper<cl_type>() { }
11008 explicit CommandBufferKhr(
const vector<CommandQueue> &queues,
11009 cl_command_buffer_properties_khr properties = 0,
11010 cl_int* errcode_ret =
nullptr)
11012 cl_command_buffer_properties_khr command_buffer_properties[] = {
11013 CL_COMMAND_BUFFER_FLAGS_KHR, properties, 0
11017 std::call_once(ext_init_, [&] { initExtensions(queues[0].getInfo<CL_QUEUE_DEVICE>()); });
11018 cl_int error = CL_INVALID_OPERATION;
11021 "Size of cl::CommandQueue must be equal to size of cl_command_queue");
11023 if (pfn_clCreateCommandBufferKHR)
11025 object_ = pfn_clCreateCommandBufferKHR((cl_uint) queues.size(),
11026 (cl_command_queue *) &queues.front(),
11027 command_buffer_properties,
11031 detail::errHandler(error, __CREATE_COMMAND_BUFFER_KHR_ERR);
11032 if (errcode_ret !=
nullptr) {
11033 *errcode_ret = error;
11037 explicit CommandBufferKhr(
const cl_command_buffer_khr& commandBufferKhr,
bool retainObject =
false) :
11038 detail::Wrapper<cl_type>(commandBufferKhr, retainObject) { }
11040 CommandBufferKhr& operator=(
const cl_command_buffer_khr& rhs)
11042 detail::Wrapper<cl_type>::operator=(rhs);
11046 template <
typename T>
11047 cl_int getInfo(cl_command_buffer_info_khr name, T* param)
const
11049 if (pfn_clGetCommandBufferInfoKHR ==
nullptr) {
11050 return detail::errHandler(CL_INVALID_OPERATION,
11051 __GET_COMMAND_BUFFER_INFO_KHR_ERR);
11053 return detail::errHandler(
11054 detail::getInfo(pfn_clGetCommandBufferInfoKHR, object_, name, param),
11055 __GET_COMMAND_BUFFER_INFO_KHR_ERR);
11058 template <cl_command_buffer_info_khr name>
typename
11059 detail::param_traits<detail::cl_command_buffer_info_khr, name>::param_type
11060 getInfo(cl_int* err =
nullptr)
const
11062 typename detail::param_traits<
11063 detail::cl_command_buffer_info_khr, name>::param_type param;
11064 cl_int result = getInfo(name, ¶m);
11065 if (err !=
nullptr) {
11071 cl_int finalizeCommandBuffer()
const
11073 return detail::errHandler(::clFinalizeCommandBufferKHR(object_), __FINALIZE_COMMAND_BUFFER_KHR_ERR);
11076 cl_int enqueueCommandBuffer(vector<CommandQueue> &queues,
11077 const vector<Event>* events =
nullptr,
11078 Event* event =
nullptr)
11080 if (pfn_clEnqueueCommandBufferKHR ==
nullptr) {
11081 return detail::errHandler(CL_INVALID_OPERATION,
11082 __ENQUEUE_COMMAND_BUFFER_KHR_ERR);
11086 "Size of cl::CommandQueue must be equal to size of cl_command_queue");
11088 return detail::errHandler(pfn_clEnqueueCommandBufferKHR((cl_uint) queues.size(),
11089 (cl_command_queue *) &queues.front(),
11091 (events !=
nullptr) ? (cl_uint) events->size() : 0,
11092 (events != nullptr && events->size() > 0) ? (cl_event*) &events->front() : nullptr,
11093 (cl_event*) event),
11094 __ENQUEUE_COMMAND_BUFFER_KHR_ERR);
11097 cl_int commandBarrierWithWaitList(
const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11098 cl_sync_point_khr* sync_point =
nullptr,
11099 MutableCommandKhr* mutable_handle =
nullptr,
11100 const CommandQueue* command_queue =
nullptr)
11102 if (pfn_clCommandBarrierWithWaitListKHR ==
nullptr) {
11103 return detail::errHandler(CL_INVALID_OPERATION,
11104 __COMMAND_BARRIER_WITH_WAIT_LIST_KHR_ERR);
11107 cl_sync_point_khr tmp_sync_point;
11108 cl_int error = detail::errHandler(
11109 pfn_clCommandBarrierWithWaitListKHR(object_,
11110 (command_queue !=
nullptr) ? (*command_queue)() : nullptr,
11111 (sync_points_vec != nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11112 (sync_points_vec != nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() : nullptr,
11113 (sync_point != nullptr) ? &tmp_sync_point : nullptr,
11114 (cl_mutable_command_khr*) mutable_handle),
11115 __COMMAND_BARRIER_WITH_WAIT_LIST_KHR_ERR);
11117 if (sync_point !=
nullptr && error == CL_SUCCESS)
11118 *sync_point = tmp_sync_point;
11123 cl_int commandCopyBuffer(
const Buffer& src,
11125 size_type src_offset,
11126 size_type dst_offset,
11128 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11129 cl_sync_point_khr* sync_point =
nullptr,
11130 MutableCommandKhr* mutable_handle =
nullptr,
11131 const CommandQueue* command_queue =
nullptr)
11133 if (pfn_clCommandCopyBufferKHR ==
nullptr) {
11134 return detail::errHandler(CL_INVALID_OPERATION,
11135 __COMMAND_COPY_BUFFER_KHR_ERR);
11138 cl_sync_point_khr tmp_sync_point;
11139 cl_int error = detail::errHandler(
11140 pfn_clCommandCopyBufferKHR(object_,
11141 (command_queue !=
nullptr) ? (*command_queue)() : nullptr,
11147 (sync_points_vec != nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11148 (sync_points_vec != nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() : nullptr,
11149 (sync_point != nullptr) ? &tmp_sync_point : nullptr,
11150 (cl_mutable_command_khr*) mutable_handle),
11151 __COMMAND_COPY_BUFFER_KHR_ERR);
11153 if (sync_point !=
nullptr && error == CL_SUCCESS)
11154 *sync_point = tmp_sync_point;
11159 cl_int commandCopyBufferRect(
const Buffer& src,
11161 const array<size_type, 3>& src_origin,
11162 const array<size_type, 3>& dst_origin,
11163 const array<size_type, 3>& region,
11164 size_type src_row_pitch,
11165 size_type src_slice_pitch,
11166 size_type dst_row_pitch,
11167 size_type dst_slice_pitch,
11168 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11169 cl_sync_point_khr* sync_point =
nullptr,
11170 MutableCommandKhr* mutable_handle =
nullptr,
11171 const CommandQueue* command_queue =
nullptr)
11173 if (pfn_clCommandCopyBufferRectKHR ==
nullptr) {
11174 return detail::errHandler(CL_INVALID_OPERATION,
11175 __COMMAND_COPY_BUFFER_RECT_KHR_ERR);
11178 cl_sync_point_khr tmp_sync_point;
11179 cl_int error = detail::errHandler(
11180 pfn_clCommandCopyBufferRectKHR(object_,
11181 (command_queue !=
nullptr) ? (*command_queue)() : nullptr,
11191 (sync_points_vec != nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11192 (sync_points_vec != nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() : nullptr,
11193 (sync_point != nullptr) ? &tmp_sync_point : nullptr,
11194 (cl_mutable_command_khr*) mutable_handle),
11195 __COMMAND_COPY_BUFFER_RECT_KHR_ERR);
11197 if (sync_point !=
nullptr && error == CL_SUCCESS)
11198 *sync_point = tmp_sync_point;
11203 cl_int commandCopyBufferToImage(
const Buffer& src,
11205 size_type src_offset,
11206 const array<size_type, 3>& dst_origin,
11207 const array<size_type, 3>& region,
11208 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11209 cl_sync_point_khr* sync_point =
nullptr,
11210 MutableCommandKhr* mutable_handle =
nullptr,
11211 const CommandQueue* command_queue =
nullptr)
11213 if (pfn_clCommandCopyBufferToImageKHR ==
nullptr) {
11214 return detail::errHandler(CL_INVALID_OPERATION,
11215 __COMMAND_COPY_BUFFER_TO_IMAGE_KHR_ERR);
11218 cl_sync_point_khr tmp_sync_point;
11219 cl_int error = detail::errHandler(
11220 pfn_clCommandCopyBufferToImageKHR(object_,
11221 (command_queue !=
nullptr) ? (*command_queue)() : nullptr,
11227 (sync_points_vec != nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11228 (sync_points_vec != nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() : nullptr,
11229 (sync_point != nullptr) ? &tmp_sync_point : nullptr,
11230 (cl_mutable_command_khr*) mutable_handle),
11231 __COMMAND_COPY_BUFFER_TO_IMAGE_KHR_ERR);
11233 if (sync_point !=
nullptr && error == CL_SUCCESS)
11234 *sync_point = tmp_sync_point;
11239 cl_int commandCopyImage(
const Image& src,
11241 const array<size_type, 3>& src_origin,
11242 const array<size_type, 3>& dst_origin,
11243 const array<size_type, 3>& region,
11244 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11245 cl_sync_point_khr* sync_point =
nullptr,
11246 MutableCommandKhr* mutable_handle =
nullptr,
11247 const CommandQueue* command_queue =
nullptr)
11249 if (pfn_clCommandCopyImageKHR ==
nullptr) {
11250 return detail::errHandler(CL_INVALID_OPERATION,
11251 __COMMAND_COPY_IMAGE_KHR_ERR);
11254 cl_sync_point_khr tmp_sync_point;
11255 cl_int error = detail::errHandler(
11256 pfn_clCommandCopyImageKHR(object_,
11257 (command_queue !=
nullptr) ? (*command_queue)() : nullptr,
11263 (sync_points_vec != nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11264 (sync_points_vec != nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() : nullptr,
11265 (sync_point != nullptr) ? &tmp_sync_point : nullptr,
11266 (cl_mutable_command_khr*) mutable_handle),
11267 __COMMAND_COPY_IMAGE_KHR_ERR);
11269 if (sync_point !=
nullptr && error == CL_SUCCESS)
11270 *sync_point = tmp_sync_point;
11275 cl_int commandCopyImageToBuffer(
const Image& src,
11277 const array<size_type, 3>& src_origin,
11278 const array<size_type, 3>& region,
11279 size_type dst_offset,
11280 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11281 cl_sync_point_khr* sync_point =
nullptr,
11282 MutableCommandKhr* mutable_handle =
nullptr,
11283 const CommandQueue* command_queue =
nullptr)
11285 if (pfn_clCommandCopyImageToBufferKHR ==
nullptr) {
11286 return detail::errHandler(CL_INVALID_OPERATION,
11287 __COMMAND_COPY_IMAGE_TO_BUFFER_KHR_ERR);
11290 cl_sync_point_khr tmp_sync_point;
11291 cl_int error = detail::errHandler(
11292 pfn_clCommandCopyImageToBufferKHR(object_,
11293 (command_queue !=
nullptr) ? (*command_queue)() : nullptr,
11299 (sync_points_vec != nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11300 (sync_points_vec != nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() : nullptr,
11301 (sync_point != nullptr) ? &tmp_sync_point : nullptr,
11302 (cl_mutable_command_khr*) mutable_handle),
11303 __COMMAND_COPY_IMAGE_TO_BUFFER_KHR_ERR);
11305 if (sync_point !=
nullptr && error == CL_SUCCESS)
11306 *sync_point = tmp_sync_point;
11311 template<
typename PatternType>
11312 cl_int commandFillBuffer(
const Buffer& buffer,
11313 PatternType pattern,
11316 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11317 cl_sync_point_khr* sync_point =
nullptr,
11318 MutableCommandKhr* mutable_handle =
nullptr,
11319 const CommandQueue* command_queue =
nullptr)
11321 if (pfn_clCommandFillBufferKHR ==
nullptr) {
11322 return detail::errHandler(CL_INVALID_OPERATION,
11323 __COMMAND_FILL_BUFFER_KHR_ERR);
11326 cl_sync_point_khr tmp_sync_point;
11327 cl_int error = detail::errHandler(
11328 pfn_clCommandFillBufferKHR(object_,
11329 (command_queue !=
nullptr) ? (*command_queue)() : nullptr,
11331 static_cast<void*>(&pattern),
11332 sizeof(PatternType),
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_FILL_BUFFER_KHR_ERR);
11341 if (sync_point !=
nullptr && error == CL_SUCCESS)
11342 *sync_point = tmp_sync_point;
11347 cl_int commandFillImage(
const Image& image,
11348 cl_float4 fillColor,
11349 const array<size_type, 3>& origin,
11350 const array<size_type, 3>& region,
11351 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11352 cl_sync_point_khr* sync_point =
nullptr,
11353 MutableCommandKhr* mutable_handle =
nullptr,
11354 const CommandQueue* command_queue =
nullptr)
11356 if (pfn_clCommandFillImageKHR ==
nullptr) {
11357 return detail::errHandler(CL_INVALID_OPERATION,
11358 __COMMAND_FILL_IMAGE_KHR_ERR);
11361 cl_sync_point_khr tmp_sync_point;
11362 cl_int error = detail::errHandler(
11363 pfn_clCommandFillImageKHR(object_,
11364 (command_queue !=
nullptr) ? (*command_queue)() : nullptr,
11366 static_cast<void*>(&fillColor),
11369 (sync_points_vec != nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11370 (sync_points_vec != nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() : nullptr,
11371 (sync_point != nullptr) ? &tmp_sync_point : nullptr,
11372 (cl_mutable_command_khr*) mutable_handle),
11373 __COMMAND_FILL_IMAGE_KHR_ERR);
11375 if (sync_point !=
nullptr && error == CL_SUCCESS)
11376 *sync_point = tmp_sync_point;
11381 cl_int commandNDRangeKernel(
const cl::vector<cl_ndrange_kernel_command_properties_khr> &properties,
11382 const Kernel& kernel,
11383 const NDRange& offset,
11384 const NDRange& global,
11385 const NDRange& local = NullRange,
11386 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11387 cl_sync_point_khr* sync_point =
nullptr,
11388 MutableCommandKhr* mutable_handle =
nullptr,
11389 const CommandQueue* command_queue =
nullptr)
11391 if (pfn_clCommandNDRangeKernelKHR ==
nullptr) {
11392 return detail::errHandler(CL_INVALID_OPERATION,
11393 __COMMAND_NDRANGE_KERNEL_KHR_ERR);
11396 cl_sync_point_khr tmp_sync_point;
11397 cl_int error = detail::errHandler(
11398 pfn_clCommandNDRangeKernelKHR(object_,
11399 (command_queue !=
nullptr) ? (*command_queue)() : nullptr,
11402 (cl_uint) global.dimensions(),
11403 offset.dimensions() != 0 ? (const size_type*) offset : nullptr,
11404 (const size_type*) global,
11405 local.dimensions() != 0 ? (const size_type*) local : nullptr,
11406 (sync_points_vec != nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11407 (sync_points_vec != nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() : nullptr,
11408 (sync_point != nullptr) ? &tmp_sync_point : nullptr,
11409 (cl_mutable_command_khr*) mutable_handle),
11410 __COMMAND_NDRANGE_KERNEL_KHR_ERR);
11412 if (sync_point !=
nullptr && error == CL_SUCCESS)
11413 *sync_point = tmp_sync_point;
11418#if defined(cl_khr_command_buffer_mutable_dispatch)
11419 cl_int updateMutableCommands(
const cl_mutable_base_config_khr* mutable_config)
11421 if (pfn_clUpdateMutableCommandsKHR ==
nullptr) {
11422 return detail::errHandler(CL_INVALID_OPERATION,
11423 __UPDATE_MUTABLE_COMMANDS_KHR_ERR);
11425 return detail::errHandler(pfn_clUpdateMutableCommandsKHR(object_, mutable_config),
11426 __UPDATE_MUTABLE_COMMANDS_KHR_ERR);
11431 static std::once_flag ext_init_;
11433 static void initExtensions(
const cl::Device& device)
11435#if CL_HPP_TARGET_OPENCL_VERSION >= 120
11436 cl_platform_id platform = device.
getInfo<CL_DEVICE_PLATFORM>()();
11437 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCreateCommandBufferKHR);
11438 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clFinalizeCommandBufferKHR);
11439 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clRetainCommandBufferKHR);
11440 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clReleaseCommandBufferKHR);
11441 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clGetCommandBufferInfoKHR);
11442 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueCommandBufferKHR);
11443 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandBarrierWithWaitListKHR);
11444 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandCopyBufferKHR);
11445 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandCopyBufferRectKHR);
11446 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandCopyBufferToImageKHR);
11447 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandCopyImageKHR);
11448 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandCopyImageToBufferKHR);
11449 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandFillBufferKHR);
11450 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandFillImageKHR);
11451 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandNDRangeKernelKHR);
11452#if defined(cl_khr_command_buffer_mutable_dispatch)
11453 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clUpdateMutableCommandsKHR);
11454 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clGetMutableCommandInfoKHR);
11456#elif CL_HPP_TARGET_OPENCL_VERSION >= 110
11457 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateCommandBufferKHR);
11458 CL_HPP_INIT_CL_EXT_FCN_PTR_(clFinalizeCommandBufferKHR);
11459 CL_HPP_INIT_CL_EXT_FCN_PTR_(clRetainCommandBufferKHR);
11460 CL_HPP_INIT_CL_EXT_FCN_PTR_(clReleaseCommandBufferKHR);
11461 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetCommandBufferInfoKHR);
11462 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueCommandBufferKHR);
11463 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandBarrierWithWaitListKHR);
11464 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandCopyBufferKHR);
11465 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandCopyBufferRectKHR);
11466 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandCopyBufferToImageKHR);
11467 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandCopyImageKHR);
11468 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandCopyImageToBufferKHR);
11469 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandFillBufferKHR);
11470 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandFillImageKHR);
11471 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandNDRangeKernelKHR);
11472#if defined(cl_khr_command_buffer_mutable_dispatch)
11473 CL_HPP_INIT_CL_EXT_FCN_PTR_(clUpdateMutableCommandsKHR);
11474 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetMutableCommandInfoKHR);
11477 if ((pfn_clCreateCommandBufferKHR ==
nullptr) &&
11478 (pfn_clFinalizeCommandBufferKHR ==
nullptr) &&
11479 (pfn_clRetainCommandBufferKHR ==
nullptr) &&
11480 (pfn_clReleaseCommandBufferKHR ==
nullptr) &&
11481 (pfn_clGetCommandBufferInfoKHR ==
nullptr) &&
11482 (pfn_clEnqueueCommandBufferKHR ==
nullptr) &&
11483 (pfn_clCommandBarrierWithWaitListKHR ==
nullptr) &&
11484 (pfn_clCommandCopyBufferKHR ==
nullptr) &&
11485 (pfn_clCommandCopyBufferRectKHR ==
nullptr) &&
11486 (pfn_clCommandCopyBufferToImageKHR ==
nullptr) &&
11487 (pfn_clCommandCopyImageKHR ==
nullptr) &&
11488 (pfn_clCommandCopyImageToBufferKHR ==
nullptr) &&
11489 (pfn_clCommandFillBufferKHR ==
nullptr) &&
11490 (pfn_clCommandFillImageKHR ==
nullptr) &&
11491 (pfn_clCommandNDRangeKernelKHR ==
nullptr)
11492#
if defined(cl_khr_command_buffer_mutable_dispatch)
11493 && (pfn_clUpdateMutableCommandsKHR ==
nullptr)
11494 && (pfn_clGetMutableCommandInfoKHR ==
nullptr)
11498 detail::errHandler(CL_INVALID_VALUE, __CREATE_COMMAND_BUFFER_KHR_ERR);
11503CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag CommandBufferKhr::ext_init_;
11505#if defined(cl_khr_command_buffer_mutable_dispatch)
11509class MutableCommandKhr :
public detail::Wrapper<cl_mutable_command_khr>
11513 MutableCommandKhr() : detail::Wrapper<cl_type>() { }
11515 explicit MutableCommandKhr(
const cl_mutable_command_khr& mutableCommandKhr,
bool retainObject =
false) :
11516 detail::Wrapper<cl_type>(mutableCommandKhr, retainObject) { }
11518 MutableCommandKhr& operator=(
const cl_mutable_command_khr& rhs)
11520 detail::Wrapper<cl_type>::operator=(rhs);
11524 template <
typename T>
11525 cl_int getInfo(cl_mutable_command_info_khr name, T* param)
const
11527 if (pfn_clGetMutableCommandInfoKHR ==
nullptr) {
11528 return detail::errHandler(CL_INVALID_OPERATION,
11529 __GET_MUTABLE_COMMAND_INFO_KHR_ERR);
11531 return detail::errHandler(
11532 detail::getInfo(pfn_clGetMutableCommandInfoKHR, object_, name, param),
11533 __GET_MUTABLE_COMMAND_INFO_KHR_ERR);
11536 template <cl_mutable_command_info_khr name>
typename
11537 detail::param_traits<detail::cl_mutable_command_info_khr, name>::param_type
11538 getInfo(cl_int* err =
nullptr)
const
11540 typename detail::param_traits<
11541 detail::cl_mutable_command_info_khr, name>::param_type param;
11542 cl_int result = getInfo(name, ¶m);
11543 if (err !=
nullptr) {
11554#undef CL_HPP_ERR_STR_
11555#if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS)
11556#undef __GET_DEVICE_INFO_ERR
11557#undef __GET_PLATFORM_INFO_ERR
11558#undef __GET_DEVICE_IDS_ERR
11559#undef __GET_PLATFORM_IDS_ERR
11560#undef __GET_CONTEXT_INFO_ERR
11561#undef __GET_EVENT_INFO_ERR
11562#undef __GET_EVENT_PROFILE_INFO_ERR
11563#undef __GET_MEM_OBJECT_INFO_ERR
11564#undef __GET_IMAGE_INFO_ERR
11565#undef __GET_SAMPLER_INFO_ERR
11566#undef __GET_KERNEL_INFO_ERR
11567#undef __GET_KERNEL_ARG_INFO_ERR
11568#undef __GET_KERNEL_SUB_GROUP_INFO_ERR
11569#undef __GET_KERNEL_WORK_GROUP_INFO_ERR
11570#undef __GET_PROGRAM_INFO_ERR
11571#undef __GET_PROGRAM_BUILD_INFO_ERR
11572#undef __GET_COMMAND_QUEUE_INFO_ERR
11573#undef __CREATE_CONTEXT_ERR
11574#undef __CREATE_CONTEXT_FROM_TYPE_ERR
11575#undef __CREATE_COMMAND_BUFFER_KHR_ERR
11576#undef __GET_COMMAND_BUFFER_INFO_KHR_ERR
11577#undef __FINALIZE_COMMAND_BUFFER_KHR_ERR
11578#undef __ENQUEUE_COMMAND_BUFFER_KHR_ERR
11579#undef __COMMAND_BARRIER_WITH_WAIT_LIST_KHR_ERR
11580#undef __COMMAND_COPY_BUFFER_KHR_ERR
11581#undef __COMMAND_COPY_BUFFER_RECT_KHR_ERR
11582#undef __COMMAND_COPY_BUFFER_TO_IMAGE_KHR_ERR
11583#undef __COMMAND_COPY_IMAGE_KHR_ERR
11584#undef __COMMAND_COPY_IMAGE_TO_BUFFER_KHR_ERR
11585#undef __COMMAND_FILL_BUFFER_KHR_ERR
11586#undef __COMMAND_FILL_IMAGE_KHR_ERR
11587#undef __COMMAND_NDRANGE_KERNEL_KHR_ERR
11588#undef __UPDATE_MUTABLE_COMMANDS_KHR_ERR
11589#undef __GET_MUTABLE_COMMAND_INFO_KHR_ERR
11590#undef __RETAIN_COMMAND_BUFFER_KHR_ERR
11591#undef __RELEASE_COMMAND_BUFFER_KHR_ERR
11592#undef __GET_SUPPORTED_IMAGE_FORMATS_ERR
11593#undef __SET_CONTEXT_DESCTRUCTOR_CALLBACK_ERR
11594#undef __CREATE_BUFFER_ERR
11596#undef __CREATE_SUBBUFFER_ERR
11597#undef __CREATE_GL_BUFFER_ERR
11598#undef __CREATE_GL_RENDER_BUFFER_ERR
11599#undef __GET_GL_OBJECT_INFO_ERR
11600#undef __CREATE_IMAGE_ERR
11601#undef __CREATE_GL_TEXTURE_ERR
11602#undef __IMAGE_DIMENSION_ERR
11603#undef __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR
11604#undef __CREATE_USER_EVENT_ERR
11605#undef __SET_USER_EVENT_STATUS_ERR
11606#undef __SET_EVENT_CALLBACK_ERR
11607#undef __WAIT_FOR_EVENTS_ERR
11608#undef __CREATE_KERNEL_ERR
11609#undef __SET_KERNEL_ARGS_ERR
11610#undef __CREATE_PROGRAM_WITH_SOURCE_ERR
11611#undef __CREATE_PROGRAM_WITH_BINARY_ERR
11612#undef __CREATE_PROGRAM_WITH_IL_ERR
11613#undef __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR
11614#undef __BUILD_PROGRAM_ERR
11615#undef __COMPILE_PROGRAM_ERR
11616#undef __LINK_PROGRAM_ERR
11617#undef __CREATE_KERNELS_IN_PROGRAM_ERR
11618#undef __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR
11619#undef __CREATE_SAMPLER_WITH_PROPERTIES_ERR
11620#undef __SET_COMMAND_QUEUE_PROPERTY_ERR
11621#undef __ENQUEUE_READ_BUFFER_ERR
11622#undef __ENQUEUE_READ_BUFFER_RECT_ERR
11623#undef __ENQUEUE_WRITE_BUFFER_ERR
11624#undef __ENQUEUE_WRITE_BUFFER_RECT_ERR
11625#undef __ENQEUE_COPY_BUFFER_ERR
11626#undef __ENQEUE_COPY_BUFFER_RECT_ERR
11627#undef __ENQUEUE_FILL_BUFFER_ERR
11628#undef __ENQUEUE_READ_IMAGE_ERR
11629#undef __ENQUEUE_WRITE_IMAGE_ERR
11630#undef __ENQUEUE_COPY_IMAGE_ERR
11631#undef __ENQUEUE_FILL_IMAGE_ERR
11632#undef __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR
11633#undef __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR
11634#undef __ENQUEUE_MAP_BUFFER_ERR
11635#undef __ENQUEUE_MAP_IMAGE_ERR
11636#undef __ENQUEUE_MAP_SVM_ERR
11637#undef __ENQUEUE_FILL_SVM_ERR
11638#undef __ENQUEUE_COPY_SVM_ERR
11639#undef __ENQUEUE_UNMAP_SVM_ERR
11640#undef __ENQUEUE_MAP_IMAGE_ERR
11641#undef __ENQUEUE_UNMAP_MEM_OBJECT_ERR
11642#undef __ENQUEUE_NDRANGE_KERNEL_ERR
11643#undef __ENQUEUE_NATIVE_KERNEL
11644#undef __ENQUEUE_MIGRATE_MEM_OBJECTS_ERR
11645#undef __ENQUEUE_MIGRATE_SVM_ERR
11646#undef __ENQUEUE_ACQUIRE_GL_ERR
11647#undef __ENQUEUE_RELEASE_GL_ERR
11648#undef __CREATE_PIPE_ERR
11649#undef __GET_PIPE_INFO_ERR
11651#undef __RELEASE_ERR
11654#undef __VECTOR_CAPACITY_ERR
11655#undef __CREATE_SUB_DEVICES_ERR
11656#undef __ENQUEUE_ACQUIRE_EXTERNAL_MEMORY_ERR
11657#undef __ENQUEUE_RELEASE_EXTERNAL_MEMORY_ERR
11658#undef __ENQUEUE_MARKER_ERR
11659#undef __ENQUEUE_WAIT_FOR_EVENTS_ERR
11660#undef __ENQUEUE_BARRIER_ERR
11661#undef __UNLOAD_COMPILER_ERR
11662#undef __CREATE_GL_TEXTURE_2D_ERR
11663#undef __CREATE_GL_TEXTURE_3D_ERR
11664#undef __CREATE_IMAGE2D_ERR
11665#undef __CREATE_IMAGE3D_ERR
11666#undef __CREATE_COMMAND_QUEUE_ERR
11667#undef __ENQUEUE_TASK_ERR
11668#undef __CREATE_SAMPLER_ERR
11669#undef __ENQUEUE_MARKER_WAIT_LIST_ERR
11670#undef __ENQUEUE_BARRIER_WAIT_LIST_ERR
11671#undef __CLONE_KERNEL_ERR
11672#undef __GET_HOST_TIMER_ERR
11673#undef __GET_DEVICE_AND_HOST_TIMER_ERR
11674#undef __GET_SEMAPHORE_KHR_INFO_ERR
11675#undef __CREATE_SEMAPHORE_KHR_WITH_PROPERTIES_ERR
11676#undef __GET_IMAGE_REQUIREMENT_INFO_EXT_ERR
11677#undef __ENQUEUE_WAIT_SEMAPHORE_KHR_ERR
11678#undef __ENQUEUE_SIGNAL_SEMAPHORE_KHR_ERR
11679#undef __RETAIN_SEMAPHORE_KHR_ERR
11680#undef __RELEASE_SEMAPHORE_KHR_ERR
11681#undef __GET_SEMAPHORE_HANDLE_FOR_TYPE_KHR_ERR
11686#undef CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_
11687#undef CL_HPP_INIT_CL_EXT_FCN_PTR_
11688#undef CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_
11690#undef CL_HPP_DEFINE_STATIC_MEMBER_
Class interface for GL Buffer Memory Objects.
BufferGL(const Context &context, cl_mem_flags flags, cl_GLuint bufobj, cl_int *err=nullptr)
Constructs a BufferGL in a specified context, from a given GL buffer.
BufferGL & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
BufferGL()
Default constructor - initializes to nullptr.
cl_int getObjectInfo(cl_gl_object_type *type, cl_GLuint *gl_object_name)
Wrapper for clGetGLObjectInfo().
BufferGL(const cl_mem &buffer, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Class interface for Buffer Memory Objects.
Buffer()
Default constructor - initializes to nullptr.
Buffer(const vector< cl_mem_properties > &properties, cl_mem_flags flags, size_type size, void *host_ptr=nullptr, cl_int *err=nullptr)
Constructs a Buffer in the default context and with specified properties.
Buffer createSubBuffer(cl_mem_flags flags, cl_buffer_create_type buffer_create_type, const void *buffer_create_info, cl_int *err=nullptr)
Creates a new buffer object from this.
Buffer(cl_mem_flags flags, size_type size, void *host_ptr=nullptr, cl_int *err=nullptr)
Constructs a Buffer in the default context.
Buffer(const cl_mem &buffer, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Buffer & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
Buffer(const Context &context, cl_mem_flags flags, size_type size, void *host_ptr=nullptr, cl_int *err=nullptr)
Constructs a Buffer in a specified context.
Buffer(const Context &context, const vector< cl_mem_properties > &properties, cl_mem_flags flags, size_type size, void *host_ptr=nullptr, cl_int *err=nullptr)
Constructs a Buffer in a specified context and with specified properties.
Buffer(IteratorType startIterator, IteratorType endIterator, bool readOnly, bool useHostPtr=false, cl_int *err=nullptr)
Construct a Buffer from a host container via iterators. IteratorType must be random access....
Class interface for GL Render Buffer Memory Objects.
cl_int getObjectInfo(cl_gl_object_type *type, cl_GLuint *gl_object_name)
Wrapper for clGetGLObjectInfo().
BufferRenderGL(const cl_mem &buffer, bool retainObject=false)
Constructor from cl_mem - takes ownership.
BufferRenderGL()
Default constructor - initializes to nullptr.
BufferRenderGL(const Context &context, cl_mem_flags flags, cl_GLuint bufobj, cl_int *err=nullptr)
Constructs a BufferRenderGL in a specified context, from a given GL Renderbuffer.
BufferRenderGL & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
CommandQueue interface for cl_command_queue.
cl_int enqueueMemcpySVM(cl::vector< T, Alloc > &dst_container, const cl::vector< T, Alloc > &src_container, cl_bool blocking, const vector< Event > *events=nullptr, Event *event=nullptr) const
cl_int enqueueMigrateSVM(const cl::vector< cl::vector< T, Alloc > > &svmContainers, const cl::vector< size_type > &sizes, cl_mem_migration_flags flags=0, const vector< Event > *events=nullptr, Event *event=nullptr) const
CommandQueue(const cl_command_queue &commandQueue, bool retainObject=false)
Constructor from cl_command_queue - takes ownership.
CommandQueue(const Context &context, const Device &device, cl_command_queue_properties properties=0, cl_int *err=nullptr)
Constructs a CommandQueue for a passed device and context Will return an CL_INVALID_QUEUE_PROPERTIES ...
CommandQueue(QueueProperties properties, cl_int *err=nullptr)
Constructs a CommandQueue based on passed properties. Will return an CL_INVALID_QUEUE_PROPERTIES erro...
cl_int enqueueMemcpySVM(cl::pointer< T, D > &dst_ptr, const cl::pointer< T, D > &src_ptr, cl_bool blocking, size_type size, const vector< Event > *events=nullptr, Event *event=nullptr) const
cl_int enqueueUnmapSVM(T *ptr, const vector< Event > *events=nullptr, Event *event=nullptr) const
cl_int enqueueMigrateSVM(const cl::vector< cl::pointer< T, D > > &svmPointers, const cl::vector< size_type > &sizes, cl_mem_migration_flags flags=0, const vector< Event > *events=nullptr, Event *event=nullptr) const
cl_int enqueueMemFillSVM(cl::pointer< T, D > &ptr, PatternType pattern, size_type size, const vector< Event > *events=nullptr, Event *event=nullptr) const
cl_int enqueueMigrateSVM(const cl::vector< cl::pointer< T, D > > &svmPointers, cl_mem_migration_flags flags=0, const vector< Event > *events=nullptr, Event *event=nullptr) const
CommandQueue(const Context &context, const Device &device, QueueProperties properties, cl_int *err=nullptr)
Constructs a CommandQueue for a passed device and context Will return an CL_INVALID_QUEUE_PROPERTIES ...
CommandQueue(cl_command_queue_properties properties, cl_int *err=nullptr)
Constructs a CommandQueue based on passed properties. Will return an CL_INVALID_QUEUE_PROPERTIES erro...
cl_int 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
std::enable_if< std::is_same< T, cl_float4 >::value||std::is_same< T, cl_int4 >::value||std::is_same< T, cl_uint4 >::value, cl_int >::type enqueueFillImage(const Image &image, T fillColor, const array< size_type, 2 > &origin, const array< size_type, 2 > ®ion, const vector< Event > *events=nullptr, Event *event=nullptr) const
cl_int enqueueMigrateSVM(const cl::vector< T * > &svmRawPointers, cl_mem_migration_flags flags=0, const vector< Event > *events=nullptr, Event *event=nullptr) const
cl_int enqueueUnmapSVM(cl::vector< T, Alloc > &container, const vector< Event > *events=nullptr, Event *event=nullptr) const
CL_API_PREFIX__VERSION_1_1_DEPRECATED cl_int enqueueMarker(Event *event=nullptr) const CL_API_SUFFIX__VERSION_1_1_DEPRECATED
static CommandQueue setDefault(const CommandQueue &default_queue)
std::enable_if< std::is_same< T, cl_float4 >::value||std::is_same< T, cl_int4 >::value||std::is_same< T, cl_uint4 >::value, cl_int >::type enqueueFillImage(const Image &image, T fillColor, const array< size_type, 3 > &origin, const array< size_type, 3 > ®ion, const vector< Event > *events=nullptr, Event *event=nullptr) const
CommandQueue(const Context &context, QueueProperties properties, cl_int *err=nullptr)
Constructs a CommandQueue for an implementation defined device in the given context Will return an CL...
CommandQueue(const Context &context, cl_command_queue_properties properties=0, cl_int *err=nullptr)
Constructs a CommandQueue for an implementation defined device in the given context Will return an CL...
cl_int enqueueMapSVM(T *ptr, cl_bool blocking, cl_map_flags flags, size_type size, const vector< Event > *events=nullptr, Event *event=nullptr) const
cl_int enqueueMigrateSVM(const cl::vector< T * > &svmRawPointers, const cl::vector< size_type > &sizes, cl_mem_migration_flags flags=0, const vector< Event > *events=nullptr, Event *event=nullptr) const
cl_int enqueueMapSVM(cl::vector< T, Alloc > &container, cl_bool blocking, cl_map_flags flags, const vector< Event > *events=nullptr, Event *event=nullptr) const
cl_int enqueueMemFillSVM(cl::vector< T, Alloc > &container, PatternType pattern, 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
cl_int enqueueUnmapSVM(cl::pointer< T, D > &ptr, const vector< Event > *events=nullptr, Event *event=nullptr) const
cl_int enqueueMigrateSVM(const cl::vector< cl::vector< T, Alloc > > &svmContainers, cl_mem_migration_flags flags=0, const vector< Event > *events=nullptr, Event *event=nullptr) const
cl_int enqueueMapSVM(cl::pointer< T, D > &ptr, cl_bool blocking, cl_map_flags flags, size_type size, const vector< Event > *events=nullptr, Event *event=nullptr) const
Class interface for cl_context.
Context(cl_device_type type, const cl_context_properties *properties=nullptr, void(CL_CALLBACK *notifyFptr)(const char *, const void *, size_type, void *)=nullptr, void *data=nullptr, cl_int *err=nullptr)
Constructs a context including all or a subset of devices of a specified type.
Context & operator=(const cl_context &rhs)
Assignment operator from cl_context - takes ownership.
cl_int setDestructorCallback(void(CL_CALLBACK *pfn_notify)(cl_context, void *), void *user_data=nullptr)
Registers a destructor callback function with a context.
static Context setDefault(const Context &default_context)
Context(const cl_context &context, bool retainObject=false)
Constructor from cl_context - takes ownership.
static Context getDefault(cl_int *err=nullptr)
Returns a singleton context including all devices of CL_DEVICE_TYPE_DEFAULT.
cl_int getSupportedImageFormats(cl_mem_flags flags, cl_mem_object_type type, vector< ImageFormat > *formats) const
Gets a list of supported image formats.
Context(const Device &device, const cl_context_properties *properties=nullptr, void(CL_CALLBACK *notifyFptr)(const char *, const void *, size_type, void *)=nullptr, void *data=nullptr, cl_int *err=nullptr)
Constructs a context including a specific device.
Context()
Default constructor - initializes to nullptr.
cl_int getInfo(cl_context_info name, T *param) const
Wrapper for clGetContextInfo().
detail::param_traits< detail::cl_context_info, name >::param_type getInfo(cl_int *err=nullptr) const
Wrapper for clGetContextInfo() that returns by value.
Context(const vector< Device > &devices, const cl_context_properties *properties=nullptr, void(CL_CALLBACK *notifyFptr)(const char *, const void *, size_type, void *)=nullptr, void *data=nullptr, cl_int *err=nullptr)
Constructs a context including a list of specified devices.
DeviceCommandQueue interface for device cl_command_queues.
DeviceCommandQueue(DeviceQueueProperties properties, cl_int *err=nullptr)
static DeviceCommandQueue makeDefault(const Context &context, const Device &device, cl_int *err=nullptr)
static DeviceCommandQueue updateDefault(const Context &context, const Device &device, const DeviceCommandQueue &default_queue, cl_int *err=nullptr)
static DeviceCommandQueue getDefault(const CommandQueue &queue, cl_int *err=nullptr)
static DeviceCommandQueue makeDefault(const Context &context, const Device &device, cl_uint queueSize, cl_int *err=nullptr)
DeviceCommandQueue(const Context &context, const Device &device, DeviceQueueProperties properties=DeviceQueueProperties::None, cl_int *err=nullptr)
DeviceCommandQueue(const cl_command_queue &commandQueue, bool retainObject=false)
Constructor from cl_command_queue - takes ownership.
static DeviceCommandQueue makeDefault(cl_int *err=nullptr)
DeviceCommandQueue(const Context &context, const Device &device, cl_uint queueSize, DeviceQueueProperties properties=DeviceQueueProperties::None, cl_int *err=nullptr)
Class interface for cl_device_id.
detail::param_traits< detail::cl_device_info, name >::param_type getInfo(cl_int *err=nullptr) const
Wrapper for clGetDeviceInfo() that returns by value.
static Device getDefault(cl_int *errResult=nullptr)
Returns the first device on the default context.
Device & operator=(const cl_device_id &rhs)
Assignment operator from cl_device_id.
cl_int getInfo(cl_device_info name, T *param) const
Wrapper for clGetDeviceInfo().
Device()
Default constructor - initializes to nullptr.
cl_ulong getHostTimer(cl_int *error=nullptr)
std::pair< cl_ulong, cl_ulong > getDeviceAndHostTimer(cl_int *error=nullptr)
cl_int createSubDevices(const cl_device_partition_property *properties, vector< Device > *devices)
Wrapper for clCreateSubDevices().
static Device setDefault(const Device &default_device)
Device(const cl_device_id &device, bool retainObject=false)
Constructor from cl_device_id.
Class interface for cl_event.
detail::param_traits< detail::cl_profiling_info, name >::param_type getProfilingInfo(cl_int *err=nullptr) const
Wrapper for clGetEventProfilingInfo() that returns by value.
cl_int setCallback(cl_int type, void(CL_CALLBACK *pfn_notify)(cl_event, cl_int, void *), void *user_data=nullptr)
Registers a user callback function for a specific command execution status.
Event(const cl_event &event, bool retainObject=false)
Constructor from cl_event - takes ownership.
cl_int getProfilingInfo(cl_profiling_info name, T *param) const
Wrapper for clGetEventProfilingInfo().
cl_int getInfo(cl_event_info name, T *param) const
Wrapper for clGetEventInfo().
cl_int wait() const
Blocks the calling thread until this event completes.
Event()
Default constructor - initializes to nullptr.
Event & operator=(const cl_event &rhs)
Assignment operator from cl_event - takes ownership.
detail::param_traits< detail::cl_event_info, name >::param_type getInfo(cl_int *err=nullptr) const
Wrapper for clGetEventInfo() that returns by value.
static cl_int waitForEvents(const vector< Event > &events)
Blocks the calling thread until every event specified is complete.
Image interface for arrays of 1D images.
Image1DArray(const cl_mem &imageArray, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Image interface for 1D buffer images.
Image1DBuffer(const cl_mem &image1D, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Class interface for 1D Image Memory objects.
Image1D()
Default constructor - initializes to nullptr.
Image1D & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
Image1D(const Context &context, cl_mem_flags flags, ImageFormat format, size_type width, void *host_ptr=nullptr, cl_int *err=nullptr)
Constructs a 1D Image in a specified context.
Image1D(const cl_mem &image1D, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Image interface for arrays of 2D images.
Image2DArray(const cl_mem &imageArray, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Class interface for GL 2D Image Memory objects.
Image2DGL()
Default constructor - initializes to nullptr.
Image2DGL(const Context &context, cl_mem_flags flags, cl_GLenum target, cl_GLint miplevel, cl_GLuint texobj, cl_int *err=nullptr)
Constructs an Image2DGL in a specified context, from a given GL Texture.
Image2DGL(const cl_mem &image, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Class interface for 2D Image Memory objects.
Image2D(const cl_mem &image2D, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Image2D(const Context &context, cl_mem_flags flags, ImageFormat format, size_type width, size_type height, size_type row_pitch=0, void *host_ptr=nullptr, cl_int *err=nullptr)
Constructs a 2D Image in a specified context.
Image2D()
Default constructor - initializes to nullptr.
Image2D & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
Image2D(const Context &context, ImageFormat format, const Buffer &sourceBuffer, size_type width, size_type height, size_type row_pitch=0, cl_int *err=nullptr)
Constructs a 2D Image from a buffer.
Image2D(const Context &context, cl_channel_order order, const Image &sourceImage, cl_int *err=nullptr)
Constructs a 2D Image from an image.
Class interface for GL 3D Image Memory objects.
Image3DGL()
Default constructor - initializes to nullptr.
Image3DGL & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
Image3DGL(const Context &context, cl_mem_flags flags, cl_GLenum target, cl_GLint miplevel, cl_GLuint texobj, cl_int *err=nullptr)
Constructs an Image3DGL in a specified context, from a given GL Texture.
Image3DGL(const cl_mem &image, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Class interface for 3D Image Memory objects.
Image3D(const cl_mem &image3D, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Image3D & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
Image3D()
Default constructor - initializes to nullptr.
Image3D(const Context &context, cl_mem_flags flags, ImageFormat format, size_type width, size_type height, size_type depth, size_type row_pitch=0, size_type slice_pitch=0, void *host_ptr=nullptr, cl_int *err=nullptr)
Constructs a 3D Image in a specified context.
general image interface for GL interop. We abstract the 2D and 3D GL images into a single instance he...
ImageGL(const cl_mem &image, bool retainObject=false)
Constructor from cl_mem - takes ownership.
C++ base class for Image Memory objects.
detail::param_traits< detail::cl_image_info, name >::param_type getImageInfo(cl_int *err=nullptr) const
Wrapper for clGetImageInfo() that returns by value.
Image(const cl_mem &image, bool retainObject=false)
Constructor from cl_mem - takes ownership.
cl_int getImageInfo(cl_image_info name, T *param) const
Wrapper for clGetImageInfo().
Image & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
Image()
Default constructor - initializes to nullptr.
Event operator()(const EnqueueArgs &args, Ts... ts)
Event result_type
Return type of the functor.
Class interface for cl_kernel.
Kernel(const cl_kernel &kernel, bool retainObject=false)
Constructor from cl_kernel - takes ownership.
cl_int setSVMPointers(const vector< void * > &pointerList)
cl_int setArg(cl_uint index, const cl::pointer< T, D > &argPtr)
setArg overload taking a shared_ptr type
std::enable_if< std::is_pointer< T >::value, cl_int >::type setArg(cl_uint index, const T argPtr)
setArg overload taking a pointer type
Kernel()
Default constructor - initializes to nullptr.
std::enable_if<!std::is_pointer< T >::value, cl_int >::type setArg(cl_uint index, const T &value)
setArg overload taking a POD type
cl_int setArg(cl_uint index, const cl::vector< T, Alloc > &argPtr)
setArg overload taking a vector type.
Kernel & operator=(const cl_kernel &rhs)
Assignment operator from cl_kernel - takes ownership.
cl_int setSVMPointers(const std::array< void *, ArrayLength > &pointerList)
cl_int enableFineGrainedSystemSVM(bool svmEnabled)
Enable fine-grained system SVM.
Class interface for cl_mem.
Memory(const cl_mem &memory, bool retainObject)
Constructor from cl_mem - takes ownership.
Memory()
Default constructor - initializes to nullptr.
Memory & operator=(const cl_mem &rhs)
Assignment operator from cl_mem - takes ownership.
cl_int getInfo(cl_mem_info name, T *param) const
Wrapper for clGetMemObjectInfo().
cl_int setDestructorCallback(void(CL_CALLBACK *pfn_notify)(cl_mem, void *), void *user_data=nullptr)
Registers a callback function to be called when the memory object is no longer needed.
detail::param_traits< detail::cl_mem_info, name >::param_type getInfo(cl_int *err=nullptr) const
Wrapper for clGetMemObjectInfo() that returns by value.
Class interface for specifying NDRange values.
NDRange(array< size_type, 1 > a)
Constructs one-dimensional range.
size_type dimensions() const
Queries the number of dimensions in the range.
NDRange(size_type size0, size_type size1)
Constructs two-dimensional range.
NDRange(array< size_type, 3 > a)
Constructs three-dimensional range.
NDRange(size_type size0, size_type size1, size_type size2)
Constructs three-dimensional range.
size_type size() const
Returns the size of the object in bytes based on the.
NDRange()
Default constructor - resulting range has zero dimensions.
NDRange(array< size_type, 2 > a)
Constructs two-dimensional range.
NDRange(size_type size0)
Constructs one-dimensional range.
Class interface for Pipe Memory Objects.
detail::param_traits< detail::cl_pipe_info, name >::param_type getInfo(cl_int *err=nullptr) const
Wrapper for clGetMemObjectInfo() that returns by value.
Pipe(cl_uint packet_size, cl_uint max_packets, cl_int *err=nullptr)
Constructs a Pipe in a the default context.
Pipe()
Default constructor - initializes to nullptr.
cl_int getInfo(cl_pipe_info name, T *param) const
Wrapper for clGetMemObjectInfo().
Pipe(const cl_mem &pipe, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Pipe & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
Pipe(const Context &context, cl_uint packet_size, cl_uint max_packets, cl_int *err=nullptr)
Constructs a Pipe in a specified context.
Program interface that implements cl_program.
CL_API_PREFIX__VERSION_2_2_DEPRECATED cl_int setReleaseCallback(void(CL_CALLBACK *pfn_notify)(cl_program program, void *user_data), void *user_data=nullptr) CL_API_SUFFIX__VERSION_2_2_DEPRECATED
Registers a callback function to be called when destructors for program scope global variables are co...
Program(const Sources &sources, cl_int *err=nullptr)
Program(const Context &context, const vector< char > &IL, bool build=false, cl_int *err=nullptr)
vector< std::pair< cl::Device, typename detail::param_traits< detail::cl_program_build_info, name >::param_type > > getBuildInfo(cl_int *err=nullptr) const
Program(const vector< char > &IL, bool build=false, cl_int *err=nullptr)
Program(const Context &context, const vector< Device > &devices, const Binaries &binaries, vector< cl_int > *binaryStatus=nullptr, cl_int *err=nullptr)
cl_int setSpecializationConstant(cl_uint index, size_type size, const void *value)
Sets a SPIR-V specialization constant.
Program(const Context &context, const vector< Device > &devices, const string &kernelNames, cl_int *err=nullptr)
Program(const cl_program &program, bool retainObject=false)
Constructor from cl_program - takes ownership.
std::enable_if<!std::is_pointer< T >::value, cl_int >::type setSpecializationConstant(cl_uint index, const T &value)
Sets a SPIR-V specialization constant.
Program(const Context &context, const Sources &sources, cl_int *err=nullptr)
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.
detail::param_traits< detail::cl_sampler_info, name >::param_type getInfo(cl_int *err=nullptr) const
Wrapper for clGetSamplerInfo() that returns by value.
Sampler()
Default constructor - initializes to nullptr.
Sampler & operator=(const cl_sampler &rhs)
Assignment operator from cl_sampler - takes ownership.
cl_int getInfo(cl_sampler_info name, T *param) const
Wrapper for clGetSamplerInfo().
Sampler(const Context &context, cl_bool normalized_coords, cl_addressing_mode addressing_mode, cl_filter_mode filter_mode, cl_int *err=nullptr)
Constructs a Sampler in a specified context.
Sampler(const cl_sampler &sampler, bool retainObject=false)
Constructor from cl_sampler - takes ownership.
Class interface for user events (a subset of cl_event's).
UserEvent()
Default constructor - initializes to nullptr.
UserEvent(const Context &context, cl_int *err=nullptr)
Constructs a user event on a given context.
cl_int setStatus(cl_int status)
Sets the execution status of a user event object.
The OpenCL C++ bindings are defined within this namespace.
vector< T, cl::SVMAllocator< int, cl::SVMTraitFine<> > > fine_svm_vector
Vector alias to simplify contruction of fine-grained SVM containers.
cl_int copy(IteratorType startIterator, IteratorType endIterator, cl::Buffer &buffer)
LocalSpaceArg Local(size_type size)
Helper function for generating LocalSpaceArg objects.
CL_API_PREFIX__VERSION_1_1_DEPRECATED cl_int UnloadCompiler() CL_API_SUFFIX__VERSION_1_1_DEPRECATED
cl::pointer< T, detail::Deleter< Alloc > > allocate_pointer(const Alloc &alloc_, Args &&... args)
cl_int enqueueUnmapSVM(T *ptr, const vector< Event > *events=nullptr, Event *event=nullptr)
vector< T, cl::SVMAllocator< int, cl::SVMTraitCoarse<> > > coarse_svm_vector
Vector alias to simplify contruction of coarse-grained SVM containers.
cl_int enqueueMapSVM(T *ptr, cl_bool blocking, cl_map_flags flags, size_type size, const vector< Event > *events=nullptr, Event *event=nullptr)
cl_int mapSVM(cl::vector< T, Alloc > &container)
vector< T, cl::SVMAllocator< int, cl::SVMTraitAtomic<> > > atomic_svm_vector
Vector alias to simplify contruction of fine-grained SVM containers that support platform atomics.
cl_int unmapSVM(cl::vector< T, Alloc > &container)
Local address wrapper for use with Kernel::setArg.
Event type_(const EnqueueArgs &, Ts...)
Function signature of kernel functor with no event dependency.
Event result_type
Return type of the functor.
static cl_int release(cl_device_id device)
static cl_int retain(cl_device_id device)