331 auto anSVMInt = cl::allocate_svm<int, cl::SVMTraitCoarse<>>();
333 cl::SVMAllocator<Foo, cl::SVMTraitCoarse<cl::SVMTraitReadOnly<>>> svmAllocReadOnly;
334 auto fooPointer = cl::allocate_pointer<Foo>(svmAllocReadOnly);
335 fooPointer->bar = anSVMInt.get();
336 cl::SVMAllocator<int, cl::SVMTraitCoarse<>> svmAlloc;
337 std::vector<int, cl::SVMAllocator<int, cl::SVMTraitCoarse<>>> inputA(numElements, 1, svmAlloc);
338 cl::coarse_svm_vector<int> inputB(numElements, 2, svmAlloc);
341 // Traditional cl_mem allocations
343 std::vector<int> output(numElements, 0xdeadbeef);
344 cl::Buffer outputBuffer(output.begin(), output.end(), false);
345 cl::Pipe aPipe(sizeof(cl_int), numElements / 2);
347 // Default command queue, also passed in as a parameter
348 cl::DeviceCommandQueue defaultDeviceQueue = cl::DeviceCommandQueue::makeDefault(
349 cl::Context::getDefault(), cl::Device::getDefault());
351 auto vectorAddKernel =
353 decltype(fooPointer)&,
355 cl::coarse_svm_vector<int>&,
359 cl::DeviceCommandQueue
360 >(vectorAddProgram, "vectorAdd");
362 // Ensure that the additional SVM pointer is available to the kernel
363 // This one was not passed as a parameter
364 vectorAddKernel.setSVMPointers(anSVMInt);
369 cl::NDRange(numElements/2),
370 cl::NDRange(numElements/2)),
381 cl::copy(outputBuffer, output.begin(), output.end());
383 cl::Device d = cl::Device::getDefault();
385 std::cout << "Output:\n";
386 for (int i = 1; i < numElements; ++i) {
387 std::cout << "\t" << output[i] << "\n";
400#ifdef CL_HPP_OPENCL_API_WRAPPER
401#define CL_(name) CL_HPP_OPENCL_API_WRAPPER(name)
403#define CL_(name) ::name
410#if !defined(CL_HPP_USE_DX_INTEROP) && defined(USE_DX_INTEROP)
411# pragma message("opencl.hpp: USE_DX_INTEROP is deprecated. Define CL_HPP_USE_DX_INTEROP instead")
412# define CL_HPP_USE_DX_INTEROP
414#if !defined(CL_HPP_ENABLE_EXCEPTIONS) && defined(__CL_ENABLE_EXCEPTIONS)
415# pragma message("opencl.hpp: __CL_ENABLE_EXCEPTIONS is deprecated. Define CL_HPP_ENABLE_EXCEPTIONS instead")
416# define CL_HPP_ENABLE_EXCEPTIONS
418#if !defined(CL_HPP_NO_STD_VECTOR) && defined(__NO_STD_VECTOR)
419# pragma message("opencl.hpp: __NO_STD_VECTOR is deprecated. Define CL_HPP_NO_STD_VECTOR instead")
420# define CL_HPP_NO_STD_VECTOR
422#if !defined(CL_HPP_NO_STD_STRING) && defined(__NO_STD_STRING)
423# pragma message("opencl.hpp: __NO_STD_STRING is deprecated. Define CL_HPP_NO_STD_STRING instead")
424# define CL_HPP_NO_STD_STRING
426#if defined(VECTOR_CLASS)
427# pragma message("opencl.hpp: VECTOR_CLASS is deprecated. Alias cl::vector instead")
429#if defined(STRING_CLASS)
430# pragma message("opencl.hpp: STRING_CLASS is deprecated. Alias cl::string instead.")
432#if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS) && defined(__CL_USER_OVERRIDE_ERROR_STRINGS)
433# pragma message("opencl.hpp: __CL_USER_OVERRIDE_ERROR_STRINGS is deprecated. Define CL_HPP_USER_OVERRIDE_ERROR_STRINGS instead")
434# define CL_HPP_USER_OVERRIDE_ERROR_STRINGS
439#if defined(__USE_DEV_VECTOR)
440# pragma message("opencl.hpp: __USE_DEV_VECTOR is no longer supported. Expect compilation errors")
442#if defined(__USE_DEV_STRING)
443# pragma message("opencl.hpp: __USE_DEV_STRING is no longer supported. Expect compilation errors")
447#if !defined(CL_HPP_TARGET_OPENCL_VERSION)
448# pragma message("opencl.hpp: CL_HPP_TARGET_OPENCL_VERSION is not defined. It will default to 300 (OpenCL 3.0)")
449# define CL_HPP_TARGET_OPENCL_VERSION 300
451#if CL_HPP_TARGET_OPENCL_VERSION != 100 && \
452 CL_HPP_TARGET_OPENCL_VERSION != 110 && \
453 CL_HPP_TARGET_OPENCL_VERSION != 120 && \
454 CL_HPP_TARGET_OPENCL_VERSION != 200 && \
455 CL_HPP_TARGET_OPENCL_VERSION != 210 && \
456 CL_HPP_TARGET_OPENCL_VERSION != 220 && \
457 CL_HPP_TARGET_OPENCL_VERSION != 300
458# 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).")
459# undef CL_HPP_TARGET_OPENCL_VERSION
460# define CL_HPP_TARGET_OPENCL_VERSION 300
464#if defined(CL_TARGET_OPENCL_VERSION)
467#if CL_TARGET_OPENCL_VERSION < CL_HPP_TARGET_OPENCL_VERSION
468# pragma message("CL_TARGET_OPENCL_VERSION is already defined as is lower than CL_HPP_TARGET_OPENCL_VERSION")
471# define CL_TARGET_OPENCL_VERSION CL_HPP_TARGET_OPENCL_VERSION
474#if !defined(CL_HPP_MINIMUM_OPENCL_VERSION)
475# define CL_HPP_MINIMUM_OPENCL_VERSION 200
477#if CL_HPP_MINIMUM_OPENCL_VERSION != 100 && \
478 CL_HPP_MINIMUM_OPENCL_VERSION != 110 && \
479 CL_HPP_MINIMUM_OPENCL_VERSION != 120 && \
480 CL_HPP_MINIMUM_OPENCL_VERSION != 200 && \
481 CL_HPP_MINIMUM_OPENCL_VERSION != 210 && \
482 CL_HPP_MINIMUM_OPENCL_VERSION != 220 && \
483 CL_HPP_MINIMUM_OPENCL_VERSION != 300
484# 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")
485# undef CL_HPP_MINIMUM_OPENCL_VERSION
486# define CL_HPP_MINIMUM_OPENCL_VERSION 100
488#if CL_HPP_MINIMUM_OPENCL_VERSION > CL_HPP_TARGET_OPENCL_VERSION
489# error "CL_HPP_MINIMUM_OPENCL_VERSION must not be greater than CL_HPP_TARGET_OPENCL_VERSION"
492#if CL_HPP_MINIMUM_OPENCL_VERSION <= 100 && !defined(CL_USE_DEPRECATED_OPENCL_1_0_APIS)
493# define CL_USE_DEPRECATED_OPENCL_1_0_APIS
495#if CL_HPP_MINIMUM_OPENCL_VERSION <= 110 && !defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
496# define CL_USE_DEPRECATED_OPENCL_1_1_APIS
498#if CL_HPP_MINIMUM_OPENCL_VERSION <= 120 && !defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
499# define CL_USE_DEPRECATED_OPENCL_1_2_APIS
501#if CL_HPP_MINIMUM_OPENCL_VERSION <= 200 && !defined(CL_USE_DEPRECATED_OPENCL_2_0_APIS)
502# define CL_USE_DEPRECATED_OPENCL_2_0_APIS
504#if CL_HPP_MINIMUM_OPENCL_VERSION <= 210 && !defined(CL_USE_DEPRECATED_OPENCL_2_1_APIS)
505# define CL_USE_DEPRECATED_OPENCL_2_1_APIS
507#if CL_HPP_MINIMUM_OPENCL_VERSION <= 220 && !defined(CL_USE_DEPRECATED_OPENCL_2_2_APIS)
508# define CL_USE_DEPRECATED_OPENCL_2_2_APIS
515#if defined(CL_HPP_USE_DX_INTEROP)
516#include <CL/cl_d3d10.h>
517#include <CL/cl_dx9_media_sharing.h>
529#if (!defined(_MSC_VER) && __cplusplus < 201103L) || (defined(_MSC_VER) && _MSC_VER < 1700)
530#error Visual studio 2013 or another C++11-supporting compiler required
533#if defined(__APPLE__) || defined(__MACOSX)
534#include <OpenCL/opencl.h>
536#include <CL/opencl.h>
539#if __cplusplus >= 201703L
540# define CL_HPP_DEFINE_STATIC_MEMBER_ inline
541#elif defined(_MSC_VER)
542# define CL_HPP_DEFINE_STATIC_MEMBER_ __declspec(selectany)
543#elif defined(__MINGW32__)
544# define CL_HPP_DEFINE_STATIC_MEMBER_ __attribute__((selectany))
546# define CL_HPP_DEFINE_STATIC_MEMBER_ __attribute__((weak))
551#if !defined(CL_API_PREFIX__VERSION_1_1_DEPRECATED)
552#define CL_API_PREFIX__VERSION_1_1_DEPRECATED
554#if !defined(CL_API_SUFFIX__VERSION_1_1_DEPRECATED)
555#define CL_API_SUFFIX__VERSION_1_1_DEPRECATED
558#if !defined(CL_API_PREFIX__VERSION_1_2_DEPRECATED)
559#define CL_API_PREFIX__VERSION_1_2_DEPRECATED
561#if !defined(CL_API_SUFFIX__VERSION_1_2_DEPRECATED)
562#define CL_API_SUFFIX__VERSION_1_2_DEPRECATED
565#if !defined(CL_API_PREFIX__VERSION_2_2_DEPRECATED)
566#define CL_API_PREFIX__VERSION_2_2_DEPRECATED
568#if !defined(CL_API_SUFFIX__VERSION_2_2_DEPRECATED)
569#define CL_API_SUFFIX__VERSION_2_2_DEPRECATED
572#if !defined(CL_CALLBACK)
585#if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY)
587 using size_type = ::size_t;
591 using size_type = size_t;
596#if defined(CL_HPP_ENABLE_EXCEPTIONS)
600#if !defined(CL_HPP_NO_STD_VECTOR)
603 template <
class T,
class Alloc = std::allocator<T> >
604 using vector = std::vector<T, Alloc>;
608#if !defined(CL_HPP_NO_STD_STRING)
611 using string = std::string;
615#if CL_HPP_TARGET_OPENCL_VERSION >= 200
617#if !defined(CL_HPP_NO_STD_UNIQUE_PTR)
622 template<
class T,
class D>
623 using pointer = std::unique_ptr<T, D>;
627#if !defined(CL_HPP_NO_STD_ARRAY)
630 template <
class T,
size_type N >
631 using array = std::array<T, N>;
637#if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY)
639 namespace compatibility {
654 for (
int i = 0; i < N; ++i) {
659 size_t(
const array<size_type, N> &rhs)
661 for (
int i = 0; i < N; ++i) {
666 size_type& operator[](
int index)
671 const size_type& operator[](
int index)
const
677 operator size_type* () {
return data_; }
680 operator const size_type* ()
const {
return data_; }
682 operator array<size_type, N>()
const
684 array<size_type, N> ret;
686 for (
int i = 0; i < N; ++i) {
695 using size_t = compatibility::size_t<N>;
702 using size_t_array = array<size_type, 3>;
714#define CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(name) \
715 using PFN_##name = name##_fn
717#define CL_HPP_INIT_CL_EXT_FCN_PTR_(name) \
719 pfn_##name = (PFN_##name)CL_(clGetExtensionFunctionAddress)(#name); \
722#define CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, name) \
724 pfn_##name = (PFN_##name) \
725 CL_(clGetExtensionFunctionAddressForPlatform)(platform, #name); \
728#ifdef cl_khr_external_memory
729 enum class ExternalMemoryType : cl_external_memory_handle_type_khr;
742#ifdef cl_khr_semaphore
745#if defined(cl_khr_command_buffer)
746 class CommandBufferKhr;
747 class MutableCommandKhr;
750#if defined(CL_HPP_ENABLE_EXCEPTIONS)
755 class Error :
public std::exception
759 const char * errStr_;
770 Error(cl_int err,
const char * errStr =
nullptr) : err_(err), errStr_(errStr)
777 const char * what() const noexcept
override
779 if (errStr_ ==
nullptr) {
791 cl_int err(
void)
const {
return err_; }
793#define CL_HPP_ERR_STR_(x) #x
795#define CL_HPP_ERR_STR_(x) nullptr
801#if defined(CL_HPP_ENABLE_EXCEPTIONS)
802static inline cl_int errHandler (
804 const char * errStr =
nullptr)
806 if (err != CL_SUCCESS) {
807 throw Error(err, errStr);
812static inline cl_int errHandler (cl_int err,
const char * errStr =
nullptr)
823#if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS)
824#define __GET_DEVICE_INFO_ERR CL_HPP_ERR_STR_(clGetDeviceInfo)
825#define __GET_PLATFORM_INFO_ERR CL_HPP_ERR_STR_(clGetPlatformInfo)
826#define __GET_DEVICE_IDS_ERR CL_HPP_ERR_STR_(clGetDeviceIDs)
827#define __GET_PLATFORM_IDS_ERR CL_HPP_ERR_STR_(clGetPlatformIDs)
828#define __GET_CONTEXT_INFO_ERR CL_HPP_ERR_STR_(clGetContextInfo)
829#define __GET_EVENT_INFO_ERR CL_HPP_ERR_STR_(clGetEventInfo)
830#define __GET_EVENT_PROFILE_INFO_ERR CL_HPP_ERR_STR_(clGetEventProfileInfo)
831#define __GET_MEM_OBJECT_INFO_ERR CL_HPP_ERR_STR_(clGetMemObjectInfo)
832#define __GET_IMAGE_INFO_ERR CL_HPP_ERR_STR_(clGetImageInfo)
833#define __GET_SAMPLER_INFO_ERR CL_HPP_ERR_STR_(clGetSamplerInfo)
834#define __GET_KERNEL_INFO_ERR CL_HPP_ERR_STR_(clGetKernelInfo)
835#if CL_HPP_TARGET_OPENCL_VERSION >= 120
836#define __GET_KERNEL_ARG_INFO_ERR CL_HPP_ERR_STR_(clGetKernelArgInfo)
838#if CL_HPP_TARGET_OPENCL_VERSION >= 210
839#define __GET_KERNEL_SUB_GROUP_INFO_ERR CL_HPP_ERR_STR_(clGetKernelSubGroupInfo)
841#define __GET_KERNEL_SUB_GROUP_INFO_ERR CL_HPP_ERR_STR_(clGetKernelSubGroupInfoKHR)
843#define __GET_KERNEL_WORK_GROUP_INFO_ERR CL_HPP_ERR_STR_(clGetKernelWorkGroupInfo)
844#define __GET_PROGRAM_INFO_ERR CL_HPP_ERR_STR_(clGetProgramInfo)
845#define __GET_PROGRAM_BUILD_INFO_ERR CL_HPP_ERR_STR_(clGetProgramBuildInfo)
846#define __GET_COMMAND_QUEUE_INFO_ERR CL_HPP_ERR_STR_(clGetCommandQueueInfo)
848#define __CREATE_CONTEXT_ERR CL_HPP_ERR_STR_(clCreateContext)
849#define __CREATE_CONTEXT_FROM_TYPE_ERR CL_HPP_ERR_STR_(clCreateContextFromType)
850#define __GET_SUPPORTED_IMAGE_FORMATS_ERR CL_HPP_ERR_STR_(clGetSupportedImageFormats)
851#if CL_HPP_TARGET_OPENCL_VERSION >= 300
852#define __SET_CONTEXT_DESCTRUCTOR_CALLBACK_ERR CL_HPP_ERR_STR_(clSetContextDestructorCallback)
855#define __CREATE_BUFFER_ERR CL_HPP_ERR_STR_(clCreateBuffer)
856#define __COPY_ERR CL_HPP_ERR_STR_(cl::copy)
857#define __CREATE_SUBBUFFER_ERR CL_HPP_ERR_STR_(clCreateSubBuffer)
858#define __CREATE_GL_BUFFER_ERR CL_HPP_ERR_STR_(clCreateFromGLBuffer)
859#define __CREATE_GL_RENDER_BUFFER_ERR CL_HPP_ERR_STR_(clCreateFromGLBuffer)
860#define __GET_GL_OBJECT_INFO_ERR CL_HPP_ERR_STR_(clGetGLObjectInfo)
861#if CL_HPP_TARGET_OPENCL_VERSION >= 120
862#define __CREATE_IMAGE_ERR CL_HPP_ERR_STR_(clCreateImage)
863#define __CREATE_GL_TEXTURE_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture)
864#define __IMAGE_DIMENSION_ERR CL_HPP_ERR_STR_(Incorrect image dimensions)
866#define __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR CL_HPP_ERR_STR_(clSetMemObjectDestructorCallback)
868#define __CREATE_USER_EVENT_ERR CL_HPP_ERR_STR_(clCreateUserEvent)
869#define __SET_USER_EVENT_STATUS_ERR CL_HPP_ERR_STR_(clSetUserEventStatus)
870#define __SET_EVENT_CALLBACK_ERR CL_HPP_ERR_STR_(clSetEventCallback)
871#define __WAIT_FOR_EVENTS_ERR CL_HPP_ERR_STR_(clWaitForEvents)
873#define __CREATE_KERNEL_ERR CL_HPP_ERR_STR_(clCreateKernel)
874#define __SET_KERNEL_ARGS_ERR CL_HPP_ERR_STR_(clSetKernelArg)
875#define __CREATE_PROGRAM_WITH_SOURCE_ERR CL_HPP_ERR_STR_(clCreateProgramWithSource)
876#define __CREATE_PROGRAM_WITH_BINARY_ERR CL_HPP_ERR_STR_(clCreateProgramWithBinary)
877#if CL_HPP_TARGET_OPENCL_VERSION >= 210
878#define __CREATE_PROGRAM_WITH_IL_ERR CL_HPP_ERR_STR_(clCreateProgramWithIL)
880#define __CREATE_PROGRAM_WITH_IL_ERR CL_HPP_ERR_STR_(clCreateProgramWithILKHR)
882#if CL_HPP_TARGET_OPENCL_VERSION >= 120
883#define __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR CL_HPP_ERR_STR_(clCreateProgramWithBuiltInKernels)
885#define __BUILD_PROGRAM_ERR CL_HPP_ERR_STR_(clBuildProgram)
886#if CL_HPP_TARGET_OPENCL_VERSION >= 120
887#define __COMPILE_PROGRAM_ERR CL_HPP_ERR_STR_(clCompileProgram)
888#define __LINK_PROGRAM_ERR CL_HPP_ERR_STR_(clLinkProgram)
890#define __CREATE_KERNELS_IN_PROGRAM_ERR CL_HPP_ERR_STR_(clCreateKernelsInProgram)
892#if CL_HPP_TARGET_OPENCL_VERSION >= 200
893#define __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR CL_HPP_ERR_STR_(clCreateCommandQueueWithProperties)
894#define __CREATE_SAMPLER_WITH_PROPERTIES_ERR CL_HPP_ERR_STR_(clCreateSamplerWithProperties)
896#define __SET_COMMAND_QUEUE_PROPERTY_ERR CL_HPP_ERR_STR_(clSetCommandQueueProperty)
897#define __ENQUEUE_READ_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueReadBuffer)
898#define __ENQUEUE_READ_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueReadBufferRect)
899#define __ENQUEUE_WRITE_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueWriteBuffer)
900#define __ENQUEUE_WRITE_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueWriteBufferRect)
901#define __ENQEUE_COPY_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueCopyBuffer)
902#define __ENQEUE_COPY_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueCopyBufferRect)
903#define __ENQUEUE_FILL_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueFillBuffer)
904#define __ENQUEUE_READ_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueReadImage)
905#define __ENQUEUE_WRITE_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueWriteImage)
906#define __ENQUEUE_COPY_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueCopyImage)
907#define __ENQUEUE_FILL_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueFillImage)
908#define __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueCopyImageToBuffer)
909#define __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueCopyBufferToImage)
910#define __ENQUEUE_MAP_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueMapBuffer)
911#define __ENQUEUE_MAP_SVM_ERR CL_HPP_ERR_STR_(clEnqueueSVMMap)
912#define __ENQUEUE_FILL_SVM_ERR CL_HPP_ERR_STR_(clEnqueueSVMMemFill)
913#define __ENQUEUE_COPY_SVM_ERR CL_HPP_ERR_STR_(clEnqueueSVMMemcpy)
914#define __ENQUEUE_UNMAP_SVM_ERR CL_HPP_ERR_STR_(clEnqueueSVMUnmap)
915#define __ENQUEUE_MAP_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueMapImage)
916#define __ENQUEUE_UNMAP_MEM_OBJECT_ERR CL_HPP_ERR_STR_(clEnqueueUnMapMemObject)
917#define __ENQUEUE_NDRANGE_KERNEL_ERR CL_HPP_ERR_STR_(clEnqueueNDRangeKernel)
918#define __ENQUEUE_NATIVE_KERNEL CL_HPP_ERR_STR_(clEnqueueNativeKernel)
919#if CL_HPP_TARGET_OPENCL_VERSION >= 120
920#define __ENQUEUE_MIGRATE_MEM_OBJECTS_ERR CL_HPP_ERR_STR_(clEnqueueMigrateMemObjects)
922#if CL_HPP_TARGET_OPENCL_VERSION >= 210
923#define __ENQUEUE_MIGRATE_SVM_ERR CL_HPP_ERR_STR_(clEnqueueSVMMigrateMem)
924#define __SET_DEFAULT_DEVICE_COMMAND_QUEUE_ERR CL_HPP_ERR_STR_(clSetDefaultDeviceCommandQueue)
928#define __ENQUEUE_ACQUIRE_GL_ERR CL_HPP_ERR_STR_(clEnqueueAcquireGLObjects)
929#define __ENQUEUE_RELEASE_GL_ERR CL_HPP_ERR_STR_(clEnqueueReleaseGLObjects)
931#define __CREATE_PIPE_ERR CL_HPP_ERR_STR_(clCreatePipe)
932#define __GET_PIPE_INFO_ERR CL_HPP_ERR_STR_(clGetPipeInfo)
934#define __RETAIN_ERR CL_HPP_ERR_STR_(Retain Object)
935#define __RELEASE_ERR CL_HPP_ERR_STR_(Release Object)
936#define __FLUSH_ERR CL_HPP_ERR_STR_(clFlush)
937#define __FINISH_ERR CL_HPP_ERR_STR_(clFinish)
938#define __VECTOR_CAPACITY_ERR CL_HPP_ERR_STR_(Vector capacity error)
940#if CL_HPP_TARGET_OPENCL_VERSION >= 210
941#define __GET_HOST_TIMER_ERR CL_HPP_ERR_STR_(clGetHostTimer)
942#define __GET_DEVICE_AND_HOST_TIMER_ERR CL_HPP_ERR_STR_(clGetDeviceAndHostTimer)
944#if CL_HPP_TARGET_OPENCL_VERSION >= 220
945#define __SET_PROGRAM_RELEASE_CALLBACK_ERR CL_HPP_ERR_STR_(clSetProgramReleaseCallback)
946#define __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR CL_HPP_ERR_STR_(clSetProgramSpecializationConstant)
949#ifdef cl_khr_external_memory
950#define __ENQUEUE_ACQUIRE_EXTERNAL_MEMORY_ERR CL_HPP_ERR_STR_(clEnqueueAcquireExternalMemObjectsKHR)
951#define __ENQUEUE_RELEASE_EXTERNAL_MEMORY_ERR CL_HPP_ERR_STR_(clEnqueueReleaseExternalMemObjectsKHR)
954#ifdef cl_khr_semaphore
955#define __GET_SEMAPHORE_KHR_INFO_ERR CL_HPP_ERR_STR_(clGetSemaphoreInfoKHR)
956#define __CREATE_SEMAPHORE_KHR_WITH_PROPERTIES_ERR CL_HPP_ERR_STR_(clCreateSemaphoreWithPropertiesKHR)
957#define __ENQUEUE_WAIT_SEMAPHORE_KHR_ERR CL_HPP_ERR_STR_(clEnqueueWaitSemaphoresKHR)
958#define __ENQUEUE_SIGNAL_SEMAPHORE_KHR_ERR CL_HPP_ERR_STR_(clEnqueueSignalSemaphoresKHR)
959#define __RETAIN_SEMAPHORE_KHR_ERR CL_HPP_ERR_STR_(clRetainSemaphoreKHR)
960#define __RELEASE_SEMAPHORE_KHR_ERR CL_HPP_ERR_STR_(clReleaseSemaphoreKHR)
963#ifdef cl_khr_external_semaphore
964#define __GET_SEMAPHORE_HANDLE_FOR_TYPE_KHR_ERR CL_HPP_ERR_STR_(clGetSemaphoreHandleForTypeKHR)
967#if defined(cl_khr_command_buffer)
968#define __CREATE_COMMAND_BUFFER_KHR_ERR CL_HPP_ERR_STR_(clCreateCommandBufferKHR)
969#define __GET_COMMAND_BUFFER_INFO_KHR_ERR CL_HPP_ERR_STR_(clGetCommandBufferInfoKHR)
970#define __FINALIZE_COMMAND_BUFFER_KHR_ERR CL_HPP_ERR_STR_(clFinalizeCommandBufferKHR)
971#define __ENQUEUE_COMMAND_BUFFER_KHR_ERR CL_HPP_ERR_STR_(clEnqueueCommandBufferKHR)
972#define __COMMAND_BARRIER_WITH_WAIT_LIST_KHR_ERR CL_HPP_ERR_STR_(clCommandBarrierWithWaitListKHR)
973#define __COMMAND_COPY_BUFFER_KHR_ERR CL_HPP_ERR_STR_(clCommandCopyBufferKHR)
974#define __COMMAND_COPY_BUFFER_RECT_KHR_ERR CL_HPP_ERR_STR_(clCommandCopyBufferRectKHR)
975#define __COMMAND_COPY_BUFFER_TO_IMAGE_KHR_ERR CL_HPP_ERR_STR_(clCommandCopyBufferToImageKHR)
976#define __COMMAND_COPY_IMAGE_KHR_ERR CL_HPP_ERR_STR_(clCommandCopyImageKHR)
977#define __COMMAND_COPY_IMAGE_TO_BUFFER_KHR_ERR CL_HPP_ERR_STR_(clCommandCopyImageToBufferKHR)
978#define __COMMAND_FILL_BUFFER_KHR_ERR CL_HPP_ERR_STR_(clCommandFillBufferKHR)
979#define __COMMAND_FILL_IMAGE_KHR_ERR CL_HPP_ERR_STR_(clCommandFillImageKHR)
980#define __COMMAND_NDRANGE_KERNEL_KHR_ERR CL_HPP_ERR_STR_(clCommandNDRangeKernelKHR)
981#define __UPDATE_MUTABLE_COMMANDS_KHR_ERR CL_HPP_ERR_STR_(clUpdateMutableCommandsKHR)
982#define __GET_MUTABLE_COMMAND_INFO_KHR_ERR CL_HPP_ERR_STR_(clGetMutableCommandInfoKHR)
983#define __RETAIN_COMMAND_BUFFER_KHR_ERR CL_HPP_ERR_STR_(clRetainCommandBufferKHR)
984#define __RELEASE_COMMAND_BUFFER_KHR_ERR CL_HPP_ERR_STR_(clReleaseCommandBufferKHR)
987#if defined(cl_ext_image_requirements_info)
988#define __GET_IMAGE_REQUIREMENT_INFO_EXT_ERR CL_HPP_ERR_STR_(clGetImageRequirementsInfoEXT)
994#if CL_HPP_TARGET_OPENCL_VERSION >= 120
995#define __CREATE_SUB_DEVICES_ERR CL_HPP_ERR_STR_(clCreateSubDevices)
997#define __CREATE_SUB_DEVICES_ERR CL_HPP_ERR_STR_(clCreateSubDevicesEXT)
1003#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
1004#define __ENQUEUE_MARKER_ERR CL_HPP_ERR_STR_(clEnqueueMarker)
1005#define __ENQUEUE_WAIT_FOR_EVENTS_ERR CL_HPP_ERR_STR_(clEnqueueWaitForEvents)
1006#define __ENQUEUE_BARRIER_ERR CL_HPP_ERR_STR_(clEnqueueBarrier)
1007#define __UNLOAD_COMPILER_ERR CL_HPP_ERR_STR_(clUnloadCompiler)
1008#define __CREATE_GL_TEXTURE_2D_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture2D)
1009#define __CREATE_GL_TEXTURE_3D_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture3D)
1010#define __CREATE_IMAGE2D_ERR CL_HPP_ERR_STR_(clCreateImage2D)
1011#define __CREATE_IMAGE3D_ERR CL_HPP_ERR_STR_(clCreateImage3D)
1017#if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
1018#define __CREATE_COMMAND_QUEUE_ERR CL_HPP_ERR_STR_(clCreateCommandQueue)
1019#define __ENQUEUE_TASK_ERR CL_HPP_ERR_STR_(clEnqueueTask)
1020#define __CREATE_SAMPLER_ERR CL_HPP_ERR_STR_(clCreateSampler)
1026#if CL_HPP_TARGET_OPENCL_VERSION >= 120
1027#define __ENQUEUE_MARKER_WAIT_LIST_ERR CL_HPP_ERR_STR_(clEnqueueMarkerWithWaitList)
1028#define __ENQUEUE_BARRIER_WAIT_LIST_ERR CL_HPP_ERR_STR_(clEnqueueBarrierWithWaitList)
1031#if CL_HPP_TARGET_OPENCL_VERSION >= 210
1032#define __CLONE_KERNEL_ERR CL_HPP_ERR_STR_(clCloneKernel)
1038#ifdef cl_khr_external_memory
1039CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clEnqueueAcquireExternalMemObjectsKHR);
1040CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clEnqueueReleaseExternalMemObjectsKHR);
1042CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clEnqueueAcquireExternalMemObjectsKHR pfn_clEnqueueAcquireExternalMemObjectsKHR =
nullptr;
1043CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clEnqueueReleaseExternalMemObjectsKHR pfn_clEnqueueReleaseExternalMemObjectsKHR =
nullptr;
1046#ifdef cl_khr_semaphore
1047CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCreateSemaphoreWithPropertiesKHR);
1048CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clReleaseSemaphoreKHR);
1049CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clRetainSemaphoreKHR);
1050CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clEnqueueWaitSemaphoresKHR);
1051CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clEnqueueSignalSemaphoresKHR);
1052CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clGetSemaphoreInfoKHR);
1054CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCreateSemaphoreWithPropertiesKHR pfn_clCreateSemaphoreWithPropertiesKHR =
nullptr;
1055CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clReleaseSemaphoreKHR pfn_clReleaseSemaphoreKHR =
nullptr;
1056CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clRetainSemaphoreKHR pfn_clRetainSemaphoreKHR =
nullptr;
1057CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clEnqueueWaitSemaphoresKHR pfn_clEnqueueWaitSemaphoresKHR =
nullptr;
1058CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clEnqueueSignalSemaphoresKHR pfn_clEnqueueSignalSemaphoresKHR =
nullptr;
1059CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clGetSemaphoreInfoKHR pfn_clGetSemaphoreInfoKHR =
nullptr;
1062#ifdef cl_khr_external_semaphore
1063CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clGetSemaphoreHandleForTypeKHR);
1064CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clGetSemaphoreHandleForTypeKHR pfn_clGetSemaphoreHandleForTypeKHR =
nullptr;
1067#if defined(cl_khr_command_buffer)
1068CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCreateCommandBufferKHR);
1069CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clFinalizeCommandBufferKHR);
1070CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clRetainCommandBufferKHR);
1071CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clReleaseCommandBufferKHR);
1072CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clGetCommandBufferInfoKHR);
1073CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clEnqueueCommandBufferKHR);
1074CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandBarrierWithWaitListKHR);
1075CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandCopyBufferKHR);
1076CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandCopyBufferRectKHR);
1077CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandCopyBufferToImageKHR);
1078CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandCopyImageKHR);
1079CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandCopyImageToBufferKHR);
1080CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandFillBufferKHR);
1081CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandFillImageKHR);
1082CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandNDRangeKernelKHR);
1084CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCreateCommandBufferKHR pfn_clCreateCommandBufferKHR =
nullptr;
1085CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clFinalizeCommandBufferKHR pfn_clFinalizeCommandBufferKHR =
nullptr;
1086CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clRetainCommandBufferKHR pfn_clRetainCommandBufferKHR =
nullptr;
1087CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clReleaseCommandBufferKHR pfn_clReleaseCommandBufferKHR =
nullptr;
1088CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clGetCommandBufferInfoKHR pfn_clGetCommandBufferInfoKHR =
nullptr;
1089CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clEnqueueCommandBufferKHR pfn_clEnqueueCommandBufferKHR =
nullptr;
1090CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandBarrierWithWaitListKHR pfn_clCommandBarrierWithWaitListKHR =
nullptr;
1091CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandCopyBufferKHR pfn_clCommandCopyBufferKHR =
nullptr;
1092CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandCopyBufferRectKHR pfn_clCommandCopyBufferRectKHR =
nullptr;
1093CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandCopyBufferToImageKHR pfn_clCommandCopyBufferToImageKHR =
nullptr;
1094CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandCopyImageKHR pfn_clCommandCopyImageKHR =
nullptr;
1095CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandCopyImageToBufferKHR pfn_clCommandCopyImageToBufferKHR =
nullptr;
1096CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandFillBufferKHR pfn_clCommandFillBufferKHR =
nullptr;
1097CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandFillImageKHR pfn_clCommandFillImageKHR =
nullptr;
1098CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandNDRangeKernelKHR pfn_clCommandNDRangeKernelKHR =
nullptr;
1101#if defined(cl_khr_command_buffer_mutable_dispatch)
1102CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clUpdateMutableCommandsKHR);
1103CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clGetMutableCommandInfoKHR);
1105CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clUpdateMutableCommandsKHR pfn_clUpdateMutableCommandsKHR =
nullptr;
1106CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clGetMutableCommandInfoKHR pfn_clGetMutableCommandInfoKHR =
nullptr;
1109#if defined(cl_ext_image_requirements_info)
1110CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clGetImageRequirementsInfoEXT);
1111CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clGetImageRequirementsInfoEXT pfn_clGetImageRequirementsInfoEXT =
nullptr;
1114#if defined(cl_ext_device_fission)
1115CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCreateSubDevicesEXT);
1116CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCreateSubDevicesEXT
1117 pfn_clCreateSubDevicesEXT =
nullptr;
1126template<
typename Functor,
typename T>
1127inline cl_int getInfoHelper(Functor f, cl_uint name, T* param,
long)
1129 return f(name,
sizeof(T), param,
nullptr);
1134template <
typename Func>
1135inline cl_int getInfoHelper(Func f, cl_uint name, vector<vector<unsigned char>>* param,
int)
1137 if (name != CL_PROGRAM_BINARIES) {
1138 return CL_INVALID_VALUE;
1142 size_type numBinaries = param->size();
1143 vector<unsigned char*> binariesPointers(numBinaries);
1145 for (size_type i = 0; i < numBinaries; ++i)
1147 binariesPointers[i] = (*param)[i].data();
1150 cl_int err = f(name, numBinaries *
sizeof(
unsigned char*), binariesPointers.data(),
nullptr);
1152 if (err != CL_SUCCESS) {
1161template <
typename Func,
typename T>
1162inline cl_int getInfoHelper(Func f, cl_uint name, vector<T>* param,
long)
1165 cl_int err = f(name, 0,
nullptr, &required);
1166 if (err != CL_SUCCESS) {
1169 const size_type elements = required /
sizeof(T);
1172 vector<T> localData(elements);
1173 err = f(name, required, localData.data(),
nullptr);
1174 if (err != CL_SUCCESS) {
1178 *param = std::move(localData);
1190template <
typename Func,
typename T>
1191inline cl_int getInfoHelper(
1192 Func f, cl_uint name, vector<T>* param,
int,
typename T::cl_type = 0)
1195 cl_int err = f(name, 0,
nullptr, &required);
1196 if (err != CL_SUCCESS) {
1200 const size_type elements = required /
sizeof(
typename T::cl_type);
1202 vector<typename T::cl_type> value(elements);
1203 err = f(name, required, value.data(),
nullptr);
1204 if (err != CL_SUCCESS) {
1210 param->resize(elements);
1214 for (size_type i = 0; i < elements; i++) {
1215 (*param)[i] = T(value[i],
true);
1222template <
typename Func>
1223inline cl_int getInfoHelper(Func f, cl_uint name,
string* param,
long)
1226 cl_int err = f(name, 0,
nullptr, &required);
1227 if (err != CL_SUCCESS) {
1234 vector<char> value(required);
1235 err = f(name, required, value.data(),
nullptr);
1236 if (err != CL_SUCCESS) {
1240 param->assign(value.begin(), value.end() - 1);
1250template <
typename Func,
size_type N>
1251inline cl_int getInfoHelper(Func f, cl_uint name, array<size_type, N>* param,
long)
1254 cl_int err = f(name, 0,
nullptr, &required);
1255 if (err != CL_SUCCESS) {
1259 size_type elements = required /
sizeof(size_type);
1260 vector<size_type> value(elements, 0);
1262 err = f(name, required, value.data(),
nullptr);
1263 if (err != CL_SUCCESS) {
1272 for (size_type i = 0; i < elements; ++i) {
1273 (*param)[i] = value[i];
1287template<
typename Func,
typename T>
1288inline cl_int getInfoHelper(Func f, cl_uint name, T* param,
int,
typename T::cl_type = 0)
1290 typename T::cl_type value;
1291 cl_int err = f(name,
sizeof(value), &value,
nullptr);
1292 if (err != CL_SUCCESS) {
1296 if (value !=
nullptr)
1298 err = param->retain();
1299 if (err != CL_SUCCESS) {
1306#define CL_HPP_PARAM_NAME_INFO_1_0_(F) \
1307 F(cl_platform_info, CL_PLATFORM_PROFILE, string) \
1308 F(cl_platform_info, CL_PLATFORM_VERSION, string) \
1309 F(cl_platform_info, CL_PLATFORM_NAME, string) \
1310 F(cl_platform_info, CL_PLATFORM_VENDOR, string) \
1311 F(cl_platform_info, CL_PLATFORM_EXTENSIONS, string) \
1313 F(cl_device_info, CL_DEVICE_TYPE, cl_device_type) \
1314 F(cl_device_info, CL_DEVICE_VENDOR_ID, cl_uint) \
1315 F(cl_device_info, CL_DEVICE_MAX_COMPUTE_UNITS, cl_uint) \
1316 F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, cl_uint) \
1317 F(cl_device_info, CL_DEVICE_MAX_WORK_GROUP_SIZE, size_type) \
1318 F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_SIZES, cl::vector<size_type>) \
1319 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, cl_uint) \
1320 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT, cl_uint) \
1321 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT, cl_uint) \
1322 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG, cl_uint) \
1323 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT, cl_uint) \
1324 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, cl_uint) \
1325 F(cl_device_info, CL_DEVICE_MAX_CLOCK_FREQUENCY, cl_uint) \
1326 F(cl_device_info, CL_DEVICE_ADDRESS_BITS, cl_uint) \
1327 F(cl_device_info, CL_DEVICE_MAX_READ_IMAGE_ARGS, cl_uint) \
1328 F(cl_device_info, CL_DEVICE_MAX_WRITE_IMAGE_ARGS, cl_uint) \
1329 F(cl_device_info, CL_DEVICE_MAX_MEM_ALLOC_SIZE, cl_ulong) \
1330 F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_WIDTH, size_type) \
1331 F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_HEIGHT, size_type) \
1332 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_WIDTH, size_type) \
1333 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_HEIGHT, size_type) \
1334 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_DEPTH, size_type) \
1335 F(cl_device_info, CL_DEVICE_IMAGE_SUPPORT, cl_bool) \
1336 F(cl_device_info, CL_DEVICE_MAX_PARAMETER_SIZE, size_type) \
1337 F(cl_device_info, CL_DEVICE_MAX_SAMPLERS, cl_uint) \
1338 F(cl_device_info, CL_DEVICE_MEM_BASE_ADDR_ALIGN, cl_uint) \
1339 F(cl_device_info, CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE, cl_uint) \
1340 F(cl_device_info, CL_DEVICE_SINGLE_FP_CONFIG, cl_device_fp_config) \
1341 F(cl_device_info, CL_DEVICE_DOUBLE_FP_CONFIG, cl_device_fp_config) \
1342 F(cl_device_info, CL_DEVICE_HALF_FP_CONFIG, cl_device_fp_config) \
1343 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_TYPE, cl_device_mem_cache_type) \
1344 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE, cl_uint)\
1345 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_SIZE, cl_ulong) \
1346 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_SIZE, cl_ulong) \
1347 F(cl_device_info, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE, cl_ulong) \
1348 F(cl_device_info, CL_DEVICE_MAX_CONSTANT_ARGS, cl_uint) \
1349 F(cl_device_info, CL_DEVICE_LOCAL_MEM_TYPE, cl_device_local_mem_type) \
1350 F(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE, cl_ulong) \
1351 F(cl_device_info, CL_DEVICE_ERROR_CORRECTION_SUPPORT, cl_bool) \
1352 F(cl_device_info, CL_DEVICE_PROFILING_TIMER_RESOLUTION, size_type) \
1353 F(cl_device_info, CL_DEVICE_ENDIAN_LITTLE, cl_bool) \
1354 F(cl_device_info, CL_DEVICE_AVAILABLE, cl_bool) \
1355 F(cl_device_info, CL_DEVICE_COMPILER_AVAILABLE, cl_bool) \
1356 F(cl_device_info, CL_DEVICE_EXECUTION_CAPABILITIES, cl_device_exec_capabilities) \
1357 F(cl_device_info, CL_DEVICE_PLATFORM, cl::Platform) \
1358 F(cl_device_info, CL_DEVICE_NAME, string) \
1359 F(cl_device_info, CL_DEVICE_VENDOR, string) \
1360 F(cl_device_info, CL_DRIVER_VERSION, string) \
1361 F(cl_device_info, CL_DEVICE_PROFILE, string) \
1362 F(cl_device_info, CL_DEVICE_VERSION, string) \
1363 F(cl_device_info, CL_DEVICE_EXTENSIONS, string) \
1365 F(cl_context_info, CL_CONTEXT_REFERENCE_COUNT, cl_uint) \
1366 F(cl_context_info, CL_CONTEXT_DEVICES, cl::vector<Device>) \
1367 F(cl_context_info, CL_CONTEXT_PROPERTIES, cl::vector<cl_context_properties>) \
1369 F(cl_event_info, CL_EVENT_COMMAND_QUEUE, cl::CommandQueue) \
1370 F(cl_event_info, CL_EVENT_COMMAND_TYPE, cl_command_type) \
1371 F(cl_event_info, CL_EVENT_REFERENCE_COUNT, cl_uint) \
1372 F(cl_event_info, CL_EVENT_COMMAND_EXECUTION_STATUS, cl_int) \
1374 F(cl_profiling_info, CL_PROFILING_COMMAND_QUEUED, cl_ulong) \
1375 F(cl_profiling_info, CL_PROFILING_COMMAND_SUBMIT, cl_ulong) \
1376 F(cl_profiling_info, CL_PROFILING_COMMAND_START, cl_ulong) \
1377 F(cl_profiling_info, CL_PROFILING_COMMAND_END, cl_ulong) \
1379 F(cl_mem_info, CL_MEM_TYPE, cl_mem_object_type) \
1380 F(cl_mem_info, CL_MEM_FLAGS, cl_mem_flags) \
1381 F(cl_mem_info, CL_MEM_SIZE, size_type) \
1382 F(cl_mem_info, CL_MEM_HOST_PTR, void*) \
1383 F(cl_mem_info, CL_MEM_MAP_COUNT, cl_uint) \
1384 F(cl_mem_info, CL_MEM_REFERENCE_COUNT, cl_uint) \
1385 F(cl_mem_info, CL_MEM_CONTEXT, cl::Context) \
1387 F(cl_image_info, CL_IMAGE_FORMAT, cl_image_format) \
1388 F(cl_image_info, CL_IMAGE_ELEMENT_SIZE, size_type) \
1389 F(cl_image_info, CL_IMAGE_ROW_PITCH, size_type) \
1390 F(cl_image_info, CL_IMAGE_SLICE_PITCH, size_type) \
1391 F(cl_image_info, CL_IMAGE_WIDTH, size_type) \
1392 F(cl_image_info, CL_IMAGE_HEIGHT, size_type) \
1393 F(cl_image_info, CL_IMAGE_DEPTH, size_type) \
1395 F(cl_sampler_info, CL_SAMPLER_REFERENCE_COUNT, cl_uint) \
1396 F(cl_sampler_info, CL_SAMPLER_CONTEXT, cl::Context) \
1397 F(cl_sampler_info, CL_SAMPLER_NORMALIZED_COORDS, cl_bool) \
1398 F(cl_sampler_info, CL_SAMPLER_ADDRESSING_MODE, cl_addressing_mode) \
1399 F(cl_sampler_info, CL_SAMPLER_FILTER_MODE, cl_filter_mode) \
1401 F(cl_program_info, CL_PROGRAM_REFERENCE_COUNT, cl_uint) \
1402 F(cl_program_info, CL_PROGRAM_CONTEXT, cl::Context) \
1403 F(cl_program_info, CL_PROGRAM_NUM_DEVICES, cl_uint) \
1404 F(cl_program_info, CL_PROGRAM_DEVICES, cl::vector<Device>) \
1405 F(cl_program_info, CL_PROGRAM_SOURCE, string) \
1406 F(cl_program_info, CL_PROGRAM_BINARY_SIZES, cl::vector<size_type>) \
1407 F(cl_program_info, CL_PROGRAM_BINARIES, cl::vector<cl::vector<unsigned char>>) \
1409 F(cl_program_build_info, CL_PROGRAM_BUILD_STATUS, cl_build_status) \
1410 F(cl_program_build_info, CL_PROGRAM_BUILD_OPTIONS, string) \
1411 F(cl_program_build_info, CL_PROGRAM_BUILD_LOG, string) \
1413 F(cl_kernel_info, CL_KERNEL_FUNCTION_NAME, string) \
1414 F(cl_kernel_info, CL_KERNEL_NUM_ARGS, cl_uint) \
1415 F(cl_kernel_info, CL_KERNEL_REFERENCE_COUNT, cl_uint) \
1416 F(cl_kernel_info, CL_KERNEL_CONTEXT, cl::Context) \
1417 F(cl_kernel_info, CL_KERNEL_PROGRAM, cl::Program) \
1419 F(cl_kernel_work_group_info, CL_KERNEL_WORK_GROUP_SIZE, size_type) \
1420 F(cl_kernel_work_group_info, CL_KERNEL_COMPILE_WORK_GROUP_SIZE, cl::detail::size_t_array) \
1421 F(cl_kernel_work_group_info, CL_KERNEL_LOCAL_MEM_SIZE, cl_ulong) \
1423 F(cl_command_queue_info, CL_QUEUE_CONTEXT, cl::Context) \
1424 F(cl_command_queue_info, CL_QUEUE_DEVICE, cl::Device) \
1425 F(cl_command_queue_info, CL_QUEUE_REFERENCE_COUNT, cl_uint) \
1426 F(cl_command_queue_info, CL_QUEUE_PROPERTIES, cl_command_queue_properties)
1429#define CL_HPP_PARAM_NAME_INFO_1_1_(F) \
1430 F(cl_context_info, CL_CONTEXT_NUM_DEVICES, cl_uint)\
1431 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF, cl_uint) \
1432 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR, cl_uint) \
1433 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT, cl_uint) \
1434 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_INT, cl_uint) \
1435 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG, cl_uint) \
1436 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT, cl_uint) \
1437 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE, cl_uint) \
1438 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF, cl_uint) \
1439 F(cl_device_info, CL_DEVICE_OPENCL_C_VERSION, string) \
1441 F(cl_mem_info, CL_MEM_ASSOCIATED_MEMOBJECT, cl::Memory) \
1442 F(cl_mem_info, CL_MEM_OFFSET, size_type) \
1444 F(cl_kernel_work_group_info, CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, size_type) \
1445 F(cl_kernel_work_group_info, CL_KERNEL_PRIVATE_MEM_SIZE, cl_ulong) \
1447 F(cl_event_info, CL_EVENT_CONTEXT, cl::Context)
1449#define CL_HPP_PARAM_NAME_INFO_1_2_(F) \
1450 F(cl_program_info, CL_PROGRAM_NUM_KERNELS, size_type) \
1451 F(cl_program_info, CL_PROGRAM_KERNEL_NAMES, string) \
1453 F(cl_program_build_info, CL_PROGRAM_BINARY_TYPE, cl_program_binary_type) \
1455 F(cl_kernel_info, CL_KERNEL_ATTRIBUTES, string) \
1457 F(cl_kernel_arg_info, CL_KERNEL_ARG_ADDRESS_QUALIFIER, cl_kernel_arg_address_qualifier) \
1458 F(cl_kernel_arg_info, CL_KERNEL_ARG_ACCESS_QUALIFIER, cl_kernel_arg_access_qualifier) \
1459 F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_NAME, string) \
1460 F(cl_kernel_arg_info, CL_KERNEL_ARG_NAME, string) \
1461 F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_QUALIFIER, cl_kernel_arg_type_qualifier) \
1463 F(cl_kernel_work_group_info, CL_KERNEL_GLOBAL_WORK_SIZE, cl::detail::size_t_array) \
1465 F(cl_device_info, CL_DEVICE_LINKER_AVAILABLE, cl_bool) \
1466 F(cl_device_info, CL_DEVICE_IMAGE_MAX_BUFFER_SIZE, size_type) \
1467 F(cl_device_info, CL_DEVICE_IMAGE_MAX_ARRAY_SIZE, size_type) \
1468 F(cl_device_info, CL_DEVICE_PARENT_DEVICE, cl::Device) \
1469 F(cl_device_info, CL_DEVICE_PARTITION_MAX_SUB_DEVICES, cl_uint) \
1470 F(cl_device_info, CL_DEVICE_PARTITION_PROPERTIES, cl::vector<cl_device_partition_property>) \
1471 F(cl_device_info, CL_DEVICE_PARTITION_TYPE, cl::vector<cl_device_partition_property>) \
1472 F(cl_device_info, CL_DEVICE_REFERENCE_COUNT, cl_uint) \
1473 F(cl_device_info, CL_DEVICE_PREFERRED_INTEROP_USER_SYNC, cl_bool) \
1474 F(cl_device_info, CL_DEVICE_PARTITION_AFFINITY_DOMAIN, cl_device_affinity_domain) \
1475 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS, string) \
1476 F(cl_device_info, CL_DEVICE_PRINTF_BUFFER_SIZE, size_type) \
1478 F(cl_image_info, CL_IMAGE_ARRAY_SIZE, size_type) \
1479 F(cl_image_info, CL_IMAGE_NUM_MIP_LEVELS, cl_uint) \
1480 F(cl_image_info, CL_IMAGE_NUM_SAMPLES, cl_uint)
1482#define CL_HPP_PARAM_NAME_INFO_2_0_(F) \
1483 F(cl_device_info, CL_DEVICE_QUEUE_ON_HOST_PROPERTIES, cl_command_queue_properties) \
1484 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES, cl_command_queue_properties) \
1485 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE, cl_uint) \
1486 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE, cl_uint) \
1487 F(cl_device_info, CL_DEVICE_MAX_ON_DEVICE_QUEUES, cl_uint) \
1488 F(cl_device_info, CL_DEVICE_MAX_ON_DEVICE_EVENTS, cl_uint) \
1489 F(cl_device_info, CL_DEVICE_MAX_PIPE_ARGS, cl_uint) \
1490 F(cl_device_info, CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS, cl_uint) \
1491 F(cl_device_info, CL_DEVICE_PIPE_MAX_PACKET_SIZE, cl_uint) \
1492 F(cl_device_info, CL_DEVICE_SVM_CAPABILITIES, cl_device_svm_capabilities) \
1493 F(cl_device_info, CL_DEVICE_PREFERRED_PLATFORM_ATOMIC_ALIGNMENT, cl_uint) \
1494 F(cl_device_info, CL_DEVICE_PREFERRED_GLOBAL_ATOMIC_ALIGNMENT, cl_uint) \
1495 F(cl_device_info, CL_DEVICE_PREFERRED_LOCAL_ATOMIC_ALIGNMENT, cl_uint) \
1496 F(cl_device_info, CL_DEVICE_IMAGE_PITCH_ALIGNMENT, cl_uint) \
1497 F(cl_device_info, CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT, cl_uint) \
1498 F(cl_device_info, CL_DEVICE_MAX_READ_WRITE_IMAGE_ARGS, cl_uint ) \
1499 F(cl_device_info, CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE, size_type ) \
1500 F(cl_device_info, CL_DEVICE_GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE, size_type ) \
1501 F(cl_profiling_info, CL_PROFILING_COMMAND_COMPLETE, cl_ulong) \
1502 F(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM, cl_bool) \
1503 F(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_SVM_PTRS, void**) \
1504 F(cl_command_queue_info, CL_QUEUE_SIZE, cl_uint) \
1505 F(cl_mem_info, CL_MEM_USES_SVM_POINTER, cl_bool) \
1506 F(cl_program_build_info, CL_PROGRAM_BUILD_GLOBAL_VARIABLE_TOTAL_SIZE, size_type) \
1507 F(cl_pipe_info, CL_PIPE_PACKET_SIZE, cl_uint) \
1508 F(cl_pipe_info, CL_PIPE_MAX_PACKETS, cl_uint)
1510#define CL_HPP_PARAM_NAME_INFO_SUBGROUP_KHR_(F) \
1511 F(cl_kernel_sub_group_info, CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE_KHR, size_type) \
1512 F(cl_kernel_sub_group_info, CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE_KHR, size_type)
1514#define CL_HPP_PARAM_NAME_INFO_IL_KHR_(F) \
1515 F(cl_device_info, CL_DEVICE_IL_VERSION_KHR, string) \
1516 F(cl_program_info, CL_PROGRAM_IL_KHR, cl::vector<unsigned char>)
1518#define CL_HPP_PARAM_NAME_INFO_2_1_(F) \
1519 F(cl_platform_info, CL_PLATFORM_HOST_TIMER_RESOLUTION, cl_ulong) \
1520 F(cl_program_info, CL_PROGRAM_IL, cl::vector<unsigned char>) \
1521 F(cl_device_info, CL_DEVICE_MAX_NUM_SUB_GROUPS, cl_uint) \
1522 F(cl_device_info, CL_DEVICE_IL_VERSION, string) \
1523 F(cl_device_info, CL_DEVICE_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS, cl_bool) \
1524 F(cl_command_queue_info, CL_QUEUE_DEVICE_DEFAULT, cl::DeviceCommandQueue) \
1525 F(cl_kernel_sub_group_info, CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE, size_type) \
1526 F(cl_kernel_sub_group_info, CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE, size_type) \
1527 F(cl_kernel_sub_group_info, CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT, cl::detail::size_t_array) \
1528 F(cl_kernel_sub_group_info, CL_KERNEL_MAX_NUM_SUB_GROUPS, size_type) \
1529 F(cl_kernel_sub_group_info, CL_KERNEL_COMPILE_NUM_SUB_GROUPS, size_type)
1531#define CL_HPP_PARAM_NAME_INFO_2_2_(F) \
1532 F(cl_program_info, CL_PROGRAM_SCOPE_GLOBAL_CTORS_PRESENT, cl_bool) \
1533 F(cl_program_info, CL_PROGRAM_SCOPE_GLOBAL_DTORS_PRESENT, cl_bool)
1535#define CL_HPP_PARAM_NAME_DEVICE_FISSION_EXT_(F) \
1536 F(cl_device_info, CL_DEVICE_PARENT_DEVICE_EXT, cl::Device) \
1537 F(cl_device_info, CL_DEVICE_PARTITION_TYPES_EXT, cl::vector<cl_device_partition_property_ext>) \
1538 F(cl_device_info, CL_DEVICE_AFFINITY_DOMAINS_EXT, cl::vector<cl_device_partition_property_ext>) \
1539 F(cl_device_info, CL_DEVICE_REFERENCE_COUNT_EXT , cl_uint) \
1540 F(cl_device_info, CL_DEVICE_PARTITION_STYLE_EXT, cl::vector<cl_device_partition_property_ext>)
1542#define CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_CL3_SHARED_(F) \
1543 F(cl_platform_info, CL_PLATFORM_NUMERIC_VERSION_KHR, cl_version_khr) \
1544 F(cl_platform_info, CL_PLATFORM_EXTENSIONS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>) \
1546 F(cl_device_info, CL_DEVICE_NUMERIC_VERSION_KHR, cl_version_khr) \
1547 F(cl_device_info, CL_DEVICE_EXTENSIONS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>) \
1548 F(cl_device_info, CL_DEVICE_ILS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>) \
1549 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>)
1551#define CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_KHRONLY_(F) \
1552 F(cl_device_info, CL_DEVICE_OPENCL_C_NUMERIC_VERSION_KHR, cl_version_khr)
1555#define CL_HPP_PARAM_NAME_CL_KHR_SEMAPHORE_(F) \
1556 F(cl_semaphore_info_khr, CL_SEMAPHORE_CONTEXT_KHR, cl::Context) \
1557 F(cl_semaphore_info_khr, CL_SEMAPHORE_REFERENCE_COUNT_KHR, cl_uint) \
1558 F(cl_semaphore_info_khr, CL_SEMAPHORE_PROPERTIES_KHR, cl::vector<cl_semaphore_properties_khr>) \
1559 F(cl_semaphore_info_khr, CL_SEMAPHORE_TYPE_KHR, cl_semaphore_type_khr) \
1560 F(cl_semaphore_info_khr, CL_SEMAPHORE_PAYLOAD_KHR, cl_semaphore_payload_khr) \
1561 F(cl_platform_info, CL_PLATFORM_SEMAPHORE_TYPES_KHR, cl::vector<cl_semaphore_type_khr>) \
1562 F(cl_device_info, CL_DEVICE_SEMAPHORE_TYPES_KHR, cl::vector<cl_semaphore_type_khr>) \
1564#define CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_MEMORY_(F) \
1565 F(cl_device_info, CL_DEVICE_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR, cl::vector<cl::ExternalMemoryType>) \
1566 F(cl_platform_info, CL_PLATFORM_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR, cl::vector<cl::ExternalMemoryType>)
1568#define CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_(F) \
1569 F(cl_platform_info, CL_PLATFORM_SEMAPHORE_IMPORT_HANDLE_TYPES_KHR, cl::vector<cl_external_semaphore_handle_type_khr>) \
1570 F(cl_platform_info, CL_PLATFORM_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR, cl::vector<cl_external_semaphore_handle_type_khr>) \
1571 F(cl_device_info, CL_DEVICE_SEMAPHORE_IMPORT_HANDLE_TYPES_KHR, cl::vector<cl_external_semaphore_handle_type_khr>) \
1572 F(cl_device_info, CL_DEVICE_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR, cl::vector<cl_external_semaphore_handle_type_khr>) \
1573 F(cl_semaphore_info_khr, CL_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR, cl::vector<cl_external_semaphore_handle_type_khr>) \
1575#define CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_OPAQUE_FD_EXT(F) \
1576 F(cl_external_semaphore_handle_type_khr, CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR, int) \
1578#define CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_SYNC_FD_EXT(F) \
1579 F(cl_external_semaphore_handle_type_khr, CL_SEMAPHORE_HANDLE_SYNC_FD_KHR, int) \
1581#define CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_WIN32_EXT(F) \
1582 F(cl_external_semaphore_handle_type_khr, CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KHR, void*) \
1583 F(cl_external_semaphore_handle_type_khr, CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KMT_KHR, void*) \
1585#define CL_HPP_PARAM_NAME_INFO_3_0_(F) \
1586 F(cl_platform_info, CL_PLATFORM_NUMERIC_VERSION, cl_version) \
1587 F(cl_platform_info, CL_PLATFORM_EXTENSIONS_WITH_VERSION, cl::vector<cl_name_version>) \
1589 F(cl_device_info, CL_DEVICE_NUMERIC_VERSION, cl_version) \
1590 F(cl_device_info, CL_DEVICE_EXTENSIONS_WITH_VERSION, cl::vector<cl_name_version>) \
1591 F(cl_device_info, CL_DEVICE_ILS_WITH_VERSION, cl::vector<cl_name_version>) \
1592 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS_WITH_VERSION, cl::vector<cl_name_version>) \
1593 F(cl_device_info, CL_DEVICE_ATOMIC_MEMORY_CAPABILITIES, cl_device_atomic_capabilities) \
1594 F(cl_device_info, CL_DEVICE_ATOMIC_FENCE_CAPABILITIES, cl_device_atomic_capabilities) \
1595 F(cl_device_info, CL_DEVICE_NON_UNIFORM_WORK_GROUP_SUPPORT, cl_bool) \
1596 F(cl_device_info, CL_DEVICE_OPENCL_C_ALL_VERSIONS, cl::vector<cl_name_version>) \
1597 F(cl_device_info, CL_DEVICE_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, size_type) \
1598 F(cl_device_info, CL_DEVICE_WORK_GROUP_COLLECTIVE_FUNCTIONS_SUPPORT, cl_bool) \
1599 F(cl_device_info, CL_DEVICE_GENERIC_ADDRESS_SPACE_SUPPORT, cl_bool) \
1600 F(cl_device_info, CL_DEVICE_OPENCL_C_FEATURES, cl::vector<cl_name_version>) \
1601 F(cl_device_info, CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES, cl_device_device_enqueue_capabilities) \
1602 F(cl_device_info, CL_DEVICE_PIPE_SUPPORT, cl_bool) \
1603 F(cl_device_info, CL_DEVICE_LATEST_CONFORMANCE_VERSION_PASSED, string) \
1605 F(cl_command_queue_info, CL_QUEUE_PROPERTIES_ARRAY, cl::vector<cl_queue_properties>) \
1606 F(cl_mem_info, CL_MEM_PROPERTIES, cl::vector<cl_mem_properties>) \
1607 F(cl_pipe_info, CL_PIPE_PROPERTIES, cl::vector<cl_pipe_properties>) \
1608 F(cl_sampler_info, CL_SAMPLER_PROPERTIES, cl::vector<cl_sampler_properties>) \
1610#define CL_HPP_PARAM_NAME_CL_IMAGE_REQUIREMENTS_EXT(F) \
1611 F(cl_image_requirements_info_ext, CL_IMAGE_REQUIREMENTS_ROW_PITCH_ALIGNMENT_EXT, size_type) \
1612 F(cl_image_requirements_info_ext, CL_IMAGE_REQUIREMENTS_BASE_ADDRESS_ALIGNMENT_EXT, size_type) \
1613 F(cl_image_requirements_info_ext, CL_IMAGE_REQUIREMENTS_SIZE_EXT, size_type) \
1614 F(cl_image_requirements_info_ext, CL_IMAGE_REQUIREMENTS_MAX_WIDTH_EXT, cl_uint) \
1615 F(cl_image_requirements_info_ext, CL_IMAGE_REQUIREMENTS_MAX_HEIGHT_EXT, cl_uint) \
1616 F(cl_image_requirements_info_ext, CL_IMAGE_REQUIREMENTS_MAX_DEPTH_EXT, cl_uint) \
1617 F(cl_image_requirements_info_ext, CL_IMAGE_REQUIREMENTS_MAX_ARRAY_SIZE_EXT, cl_uint) \
1619#define CL_HPP_PARAM_NAME_CL_IMAGE_REQUIREMENTS_SLICE_PITCH_ALIGNMENT_EXT(F) \
1620 F(cl_image_requirements_info_ext, CL_IMAGE_REQUIREMENTS_SLICE_PITCH_ALIGNMENT_EXT, size_type) \
1622#define CL_HPP_PARAM_NAME_CL_INTEL_COMMAND_QUEUE_FAMILIES_(F) \
1623 F(cl_device_info, CL_DEVICE_QUEUE_FAMILY_PROPERTIES_INTEL, cl::vector<cl_queue_family_properties_intel>) \
1625 F(cl_command_queue_info, CL_QUEUE_FAMILY_INTEL, cl_uint) \
1626 F(cl_command_queue_info, CL_QUEUE_INDEX_INTEL, cl_uint)
1628#define CL_HPP_PARAM_NAME_CL_INTEL_UNIFIED_SHARED_MEMORY_(F) \
1629 F(cl_device_info, CL_DEVICE_HOST_MEM_CAPABILITIES_INTEL, cl_device_unified_shared_memory_capabilities_intel ) \
1630 F(cl_device_info, CL_DEVICE_DEVICE_MEM_CAPABILITIES_INTEL, cl_device_unified_shared_memory_capabilities_intel ) \
1631 F(cl_device_info, CL_DEVICE_SINGLE_DEVICE_SHARED_MEM_CAPABILITIES_INTEL, cl_device_unified_shared_memory_capabilities_intel ) \
1632 F(cl_device_info, CL_DEVICE_CROSS_DEVICE_SHARED_MEM_CAPABILITIES_INTEL, cl_device_unified_shared_memory_capabilities_intel ) \
1633 F(cl_device_info, CL_DEVICE_SHARED_SYSTEM_MEM_CAPABILITIES_INTEL, cl_device_unified_shared_memory_capabilities_intel )
1635template <
typename enum_type, cl_
int Name>
1638#define CL_HPP_DECLARE_PARAM_TRAITS_(token, param_name, T) \
1641struct param_traits<detail:: token,param_name> \
1643 enum { value = param_name }; \
1644 typedef T param_type; \
1647CL_HPP_PARAM_NAME_INFO_1_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1648#if CL_HPP_TARGET_OPENCL_VERSION >= 110
1649CL_HPP_PARAM_NAME_INFO_1_1_(CL_HPP_DECLARE_PARAM_TRAITS_)
1651#if CL_HPP_TARGET_OPENCL_VERSION >= 120
1652CL_HPP_PARAM_NAME_INFO_1_2_(CL_HPP_DECLARE_PARAM_TRAITS_)
1654#if CL_HPP_TARGET_OPENCL_VERSION >= 200
1655CL_HPP_PARAM_NAME_INFO_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1657#if CL_HPP_TARGET_OPENCL_VERSION >= 210
1658CL_HPP_PARAM_NAME_INFO_2_1_(CL_HPP_DECLARE_PARAM_TRAITS_)
1660#if CL_HPP_TARGET_OPENCL_VERSION >= 220
1661CL_HPP_PARAM_NAME_INFO_2_2_(CL_HPP_DECLARE_PARAM_TRAITS_)
1663#if CL_HPP_TARGET_OPENCL_VERSION >= 300
1664CL_HPP_PARAM_NAME_INFO_3_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1667#if defined(cl_khr_subgroups) && CL_HPP_TARGET_OPENCL_VERSION < 210
1668CL_HPP_PARAM_NAME_INFO_SUBGROUP_KHR_(CL_HPP_DECLARE_PARAM_TRAITS_)
1671#if defined(cl_khr_il_program) && CL_HPP_TARGET_OPENCL_VERSION < 210
1672CL_HPP_PARAM_NAME_INFO_IL_KHR_(CL_HPP_DECLARE_PARAM_TRAITS_)
1677#define CL_HPP_PARAM_NAME_INFO_1_0_DEPRECATED_IN_2_0_(F) \
1678 F(cl_device_info, CL_DEVICE_QUEUE_PROPERTIES, cl_command_queue_properties)
1680#define CL_HPP_PARAM_NAME_INFO_1_1_DEPRECATED_IN_2_0_(F) \
1681 F(cl_device_info, CL_DEVICE_HOST_UNIFIED_MEMORY, cl_bool)
1683#define CL_HPP_PARAM_NAME_INFO_1_2_DEPRECATED_IN_2_0_(F) \
1684 F(cl_image_info, CL_IMAGE_BUFFER, cl::Buffer)
1688#if CL_HPP_TARGET_OPENCL_VERSION > 100 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 && CL_HPP_TARGET_OPENCL_VERSION < 200
1689CL_HPP_PARAM_NAME_INFO_1_0_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1691#if CL_HPP_TARGET_OPENCL_VERSION > 110 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
1692CL_HPP_PARAM_NAME_INFO_1_1_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1694#if CL_HPP_TARGET_OPENCL_VERSION > 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
1695CL_HPP_PARAM_NAME_INFO_1_2_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1698#if defined(cl_ext_device_fission)
1699CL_HPP_PARAM_NAME_DEVICE_FISSION_EXT_(CL_HPP_DECLARE_PARAM_TRAITS_)
1702#if defined(cl_khr_extended_versioning)
1703#if CL_HPP_TARGET_OPENCL_VERSION < 300
1704CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_CL3_SHARED_(CL_HPP_DECLARE_PARAM_TRAITS_)
1706CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_KHRONLY_(CL_HPP_DECLARE_PARAM_TRAITS_)
1709#if defined(cl_khr_semaphore)
1710CL_HPP_PARAM_NAME_CL_KHR_SEMAPHORE_(CL_HPP_DECLARE_PARAM_TRAITS_)
1711#if defined(CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR)
1712CL_HPP_DECLARE_PARAM_TRAITS_(cl_semaphore_info_khr, CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR, cl::vector<cl::Device>)
1716#ifdef cl_khr_external_memory
1717CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_MEMORY_(CL_HPP_DECLARE_PARAM_TRAITS_)
1720#if defined(cl_khr_external_semaphore)
1721CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_(CL_HPP_DECLARE_PARAM_TRAITS_)
1724#if defined(cl_khr_external_semaphore_opaque_fd)
1725CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_OPAQUE_FD_EXT(CL_HPP_DECLARE_PARAM_TRAITS_)
1727#if defined(cl_khr_external_semaphore_sync_fd)
1728CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_SYNC_FD_EXT(CL_HPP_DECLARE_PARAM_TRAITS_)
1730#if defined(cl_khr_external_semaphore_win32)
1731CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_WIN32_EXT(CL_HPP_DECLARE_PARAM_TRAITS_)
1734#if defined(cl_khr_device_uuid)
1735using uuid_array = array<cl_uchar, CL_UUID_SIZE_KHR>;
1736using luid_array = array<cl_uchar, CL_LUID_SIZE_KHR>;
1737CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_UUID_KHR, uuid_array)
1738CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DRIVER_UUID_KHR, uuid_array)
1739CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LUID_VALID_KHR, cl_bool)
1740CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LUID_KHR, luid_array)
1741CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_NODE_MASK_KHR, cl_uint)
1744#if defined(cl_khr_pci_bus_info)
1745CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_PCI_BUS_INFO_KHR, cl_device_pci_bus_info_khr)
1749#if CL_HPP_TARGET_OPENCL_VERSION < 200
1750#if defined(CL_DEVICE_IMAGE_PITCH_ALIGNMENT_KHR)
1751CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_IMAGE_PITCH_ALIGNMENT_KHR, cl_uint)
1753#if defined(CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT_KHR)
1754CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT_KHR, cl_uint)
1758#if defined(cl_khr_integer_dot_product)
1759CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGER_DOT_PRODUCT_CAPABILITIES_KHR, cl_device_integer_dot_product_capabilities_khr)
1760#if defined(CL_DEVICE_INTEGER_DOT_PRODUCT_ACCELERATION_PROPERTIES_8BIT_KHR)
1761CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGER_DOT_PRODUCT_ACCELERATION_PROPERTIES_8BIT_KHR, cl_device_integer_dot_product_acceleration_properties_khr)
1762CL_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)
1766#if defined(cl_ext_image_requirements_info)
1767CL_HPP_PARAM_NAME_CL_IMAGE_REQUIREMENTS_EXT(CL_HPP_DECLARE_PARAM_TRAITS_)
1770#if defined(cl_ext_image_from_buffer)
1771CL_HPP_PARAM_NAME_CL_IMAGE_REQUIREMENTS_SLICE_PITCH_ALIGNMENT_EXT(CL_HPP_DECLARE_PARAM_TRAITS_)
1774#ifdef CL_PLATFORM_ICD_SUFFIX_KHR
1775CL_HPP_DECLARE_PARAM_TRAITS_(cl_platform_info, CL_PLATFORM_ICD_SUFFIX_KHR,
string)
1778#ifdef CL_DEVICE_PROFILING_TIMER_OFFSET_AMD
1779CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_PROFILING_TIMER_OFFSET_AMD, cl_ulong)
1781#ifdef CL_DEVICE_GLOBAL_FREE_MEMORY_AMD
1782CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_FREE_MEMORY_AMD, vector<size_type>)
1784#ifdef CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD
1785CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD, cl_uint)
1787#ifdef CL_DEVICE_SIMD_WIDTH_AMD
1788CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_WIDTH_AMD, cl_uint)
1790#ifdef CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD
1791CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD, cl_uint)
1793#ifdef CL_DEVICE_WAVEFRONT_WIDTH_AMD
1794CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_WAVEFRONT_WIDTH_AMD, cl_uint)
1796#ifdef CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD
1797CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD, cl_uint)
1799#ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD
1800CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD, cl_uint)
1802#ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD
1803CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD, cl_uint)
1805#ifdef CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD
1806CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD, cl_uint)
1808#ifdef CL_DEVICE_LOCAL_MEM_BANKS_AMD
1809CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LOCAL_MEM_BANKS_AMD, cl_uint)
1811#ifdef CL_DEVICE_BOARD_NAME_AMD
1812CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_BOARD_NAME_AMD,
string)
1815#ifdef CL_DEVICE_COMPUTE_UNITS_BITFIELD_ARM
1816CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_UNITS_BITFIELD_ARM, cl_ulong)
1818#ifdef CL_DEVICE_JOB_SLOTS_ARM
1819CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_JOB_SLOTS_ARM, cl_uint)
1821#ifdef CL_DEVICE_SCHEDULING_CONTROLS_CAPABILITIES_ARM
1822CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SCHEDULING_CONTROLS_CAPABILITIES_ARM, cl_bitfield)
1824#ifdef CL_DEVICE_SUPPORTED_REGISTER_ALLOCATIONS_ARM
1825CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SUPPORTED_REGISTER_ALLOCATIONS_ARM, vector<cl_uint>)
1827#ifdef CL_DEVICE_MAX_WARP_COUNT_ARM
1828CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_MAX_WARP_COUNT_ARM, cl_uint)
1830#ifdef CL_KERNEL_MAX_WARP_COUNT_ARM
1831CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_info, CL_KERNEL_MAX_WARP_COUNT_ARM, cl_uint)
1833#ifdef CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_ARM
1834CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_ARM, cl_uint)
1836#ifdef CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_MODIFIER_ARM
1837CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_MODIFIER_ARM, cl_int)
1839#ifdef CL_KERNEL_EXEC_INFO_WARP_COUNT_LIMIT_ARM
1840CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_WARP_COUNT_LIMIT_ARM, cl_uint)
1842#ifdef CL_KERNEL_EXEC_INFO_COMPUTE_UNIT_MAX_QUEUED_BATCHES_ARM
1843CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_COMPUTE_UNIT_MAX_QUEUED_BATCHES_ARM, cl_uint)
1846#ifdef CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV
1847CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV, cl_uint)
1849#ifdef CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV
1850CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV, cl_uint)
1852#ifdef CL_DEVICE_REGISTERS_PER_BLOCK_NV
1853CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_REGISTERS_PER_BLOCK_NV, cl_uint)
1855#ifdef CL_DEVICE_WARP_SIZE_NV
1856CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_WARP_SIZE_NV, cl_uint)
1858#ifdef CL_DEVICE_GPU_OVERLAP_NV
1859CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GPU_OVERLAP_NV, cl_bool)
1861#ifdef CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV
1862CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV, cl_bool)
1864#ifdef CL_DEVICE_INTEGRATED_MEMORY_NV
1865CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGRATED_MEMORY_NV, cl_bool)
1868#if defined(cl_khr_command_buffer)
1869CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMMAND_BUFFER_CAPABILITIES_KHR, cl_device_command_buffer_capabilities_khr)
1870#if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 5)
1871CL_HPP_DECLARE_PARAM_TRAITS_(
1872 cl_device_info, CL_DEVICE_COMMAND_BUFFER_SUPPORTED_QUEUE_PROPERTIES_KHR,
1873 cl_command_queue_properties)
1875CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMMAND_BUFFER_REQUIRED_QUEUE_PROPERTIES_KHR, cl_command_queue_properties)
1876CL_HPP_DECLARE_PARAM_TRAITS_(cl_command_buffer_info_khr, CL_COMMAND_BUFFER_QUEUES_KHR, cl::vector<CommandQueue>)
1877CL_HPP_DECLARE_PARAM_TRAITS_(cl_command_buffer_info_khr, CL_COMMAND_BUFFER_NUM_QUEUES_KHR, cl_uint)
1878CL_HPP_DECLARE_PARAM_TRAITS_(cl_command_buffer_info_khr, CL_COMMAND_BUFFER_REFERENCE_COUNT_KHR, cl_uint)
1879CL_HPP_DECLARE_PARAM_TRAITS_(cl_command_buffer_info_khr, CL_COMMAND_BUFFER_STATE_KHR, cl_command_buffer_state_khr)
1880CL_HPP_DECLARE_PARAM_TRAITS_(cl_command_buffer_info_khr, CL_COMMAND_BUFFER_PROPERTIES_ARRAY_KHR, cl::vector<cl_command_buffer_properties_khr>)
1883#if defined(cl_khr_command_buffer_mutable_dispatch)
1884CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_COMMAND_COMMAND_QUEUE_KHR,
CommandQueue)
1885CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_COMMAND_COMMAND_BUFFER_KHR, CommandBufferKhr)
1886CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_COMMAND_COMMAND_TYPE_KHR, cl_command_type)
1888#if CL_KHR_COMMAND_BUFFER_MUTABLE_DISPATCH_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 2)
1889CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_COMMAND_PROPERTIES_ARRAY_KHR, cl::vector<cl_command_properties_khr>)
1891CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_DISPATCH_PROPERTIES_ARRAY_KHR, cl::vector<cl_ndrange_kernel_command_properties_khr>)
1893CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_DISPATCH_KERNEL_KHR, cl_kernel)
1894CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_DISPATCH_DIMENSIONS_KHR, cl_uint)
1895CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_DISPATCH_GLOBAL_WORK_OFFSET_KHR, cl::vector<size_type>)
1896CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_DISPATCH_GLOBAL_WORK_SIZE_KHR, cl::vector<size_type>)
1897CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_DISPATCH_LOCAL_WORK_SIZE_KHR, cl::vector<size_type>)
1900#if defined(cl_khr_kernel_clock)
1901CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_KERNEL_CLOCK_CAPABILITIES_KHR, cl_device_kernel_clock_capabilities_khr)
1904#if defined(cl_khr_spirv_queries)
1905CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SPIRV_EXTENDED_INSTRUCTION_SETS_KHR, cl::vector<const char*>)
1906CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SPIRV_EXTENSIONS_KHR, cl::vector<const char*>)
1907CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SPIRV_CAPABILITIES_KHR, cl::vector<cl_uint>)
1910#if defined(cl_ext_float_atomics)
1911CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SINGLE_FP_ATOMIC_CAPABILITIES_EXT, cl_device_fp_atomic_capabilities_ext)
1912CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_DOUBLE_FP_ATOMIC_CAPABILITIES_EXT, cl_device_fp_atomic_capabilities_ext)
1913CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_HALF_FP_ATOMIC_CAPABILITIES_EXT, cl_device_fp_atomic_capabilities_ext)
1916#if defined(cl_intel_command_queue_families)
1917CL_HPP_PARAM_NAME_CL_INTEL_COMMAND_QUEUE_FAMILIES_(CL_HPP_DECLARE_PARAM_TRAITS_)
1920#if defined(cl_intel_device_attribute_query)
1921CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_IP_VERSION_INTEL, cl_uint)
1922CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_ID_INTEL, cl_uint)
1923CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_NUM_SLICES_INTEL, cl_uint)
1924CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_NUM_SUB_SLICES_PER_SLICE_INTEL, cl_uint)
1925CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_NUM_EUS_PER_SUB_SLICE_INTEL, cl_uint)
1926CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_NUM_THREADS_PER_EU_INTEL, cl_uint)
1927CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_FEATURE_CAPABILITIES_INTEL, cl_device_feature_capabilities_intel)
1930#if defined(cl_intel_required_subgroup_size)
1931CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SUB_GROUP_SIZES_INTEL, cl::vector<size_type>)
1932CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_work_group_info, CL_KERNEL_SPILL_MEM_SIZE_INTEL, cl_ulong)
1935#if defined(cl_intel_unified_shared_memory)
1936CL_HPP_PARAM_NAME_CL_INTEL_UNIFIED_SHARED_MEMORY_(CL_HPP_DECLARE_PARAM_TRAITS_)
1941template <
typename Func,
typename T>
1943getInfo(Func f, cl_uint name, T* param)
1945 return getInfoHelper(f, name, param, 0);
1948template <
typename Func,
typename Arg0>
1951 Func f_;
const Arg0& arg0_;
1953 cl_uint param, size_type size,
void* value, size_type* size_ret)
1954 {
return f_(arg0_, param, size, value, size_ret); }
1957template <
typename Func,
typename Arg0,
typename Arg1>
1958struct GetInfoFunctor1
1960 Func f_;
const Arg0& arg0_;
const Arg1& arg1_;
1962 cl_uint param, size_type size,
void* value, size_type* size_ret)
1963 {
return f_(arg0_, arg1_, param, size, value, size_ret); }
1966template <
typename Func,
typename Arg0,
typename T>
1968getInfo(Func f,
const Arg0& arg0, cl_uint name, T* param)
1971 return getInfoHelper(f0, name, param, 0);
1974template <
typename Func,
typename Arg0,
typename Arg1,
typename T>
1976getInfo(Func f,
const Arg0& arg0,
const Arg1& arg1, cl_uint name, T* param)
1979 return getInfoHelper(f0, name, param, 0);
1987#if CL_HPP_TARGET_OPENCL_VERSION >= 120
2003 static cl_int
retain(cl_device_id device)
2004 {
return CL_(clRetainDevice)(device); }
2014 static cl_int
release(cl_device_id device)
2015 {
return CL_(clReleaseDevice)(device); }
2022struct ReferenceHandler<cl_device_id>
2025 static cl_int retain(cl_device_id)
2026 {
return CL_SUCCESS; }
2028 static cl_int release(cl_device_id)
2029 {
return CL_SUCCESS; }
2037 static cl_int retain(cl_platform_id)
2038 {
return CL_SUCCESS; }
2040 static cl_int release(cl_platform_id)
2041 {
return CL_SUCCESS; }
2045struct ReferenceHandler<cl_context>
2047 static cl_int retain(cl_context context)
2048 {
return CL_(clRetainContext)(context); }
2049 static cl_int release(cl_context context)
2050 {
return CL_(clReleaseContext)(context); }
2054struct ReferenceHandler<cl_command_queue>
2056 static cl_int retain(cl_command_queue queue)
2057 {
return CL_(clRetainCommandQueue)(queue); }
2058 static cl_int release(cl_command_queue queue)
2059 {
return CL_(clReleaseCommandQueue)(queue); }
2063struct ReferenceHandler<cl_mem>
2065 static cl_int retain(cl_mem memory)
2066 {
return CL_(clRetainMemObject)(memory); }
2067 static cl_int release(cl_mem memory)
2068 {
return CL_(clReleaseMemObject)(memory); }
2072struct ReferenceHandler<cl_sampler>
2074 static cl_int retain(cl_sampler sampler)
2075 {
return CL_(clRetainSampler)(sampler); }
2076 static cl_int release(cl_sampler sampler)
2077 {
return CL_(clReleaseSampler)(sampler); }
2081struct ReferenceHandler<cl_program>
2083 static cl_int retain(cl_program program)
2084 {
return CL_(clRetainProgram)(program); }
2085 static cl_int release(cl_program program)
2086 {
return CL_(clReleaseProgram)(program); }
2090struct ReferenceHandler<cl_kernel>
2092 static cl_int retain(cl_kernel kernel)
2093 {
return CL_(clRetainKernel)(kernel); }
2094 static cl_int release(cl_kernel kernel)
2095 {
return CL_(clReleaseKernel)(kernel); }
2099struct ReferenceHandler<cl_event>
2101 static cl_int retain(cl_event event)
2102 {
return CL_(clRetainEvent)(event); }
2103 static cl_int release(cl_event event)
2104 {
return CL_(clReleaseEvent)(event); }
2107#ifdef cl_khr_semaphore
2111 static cl_int retain(cl_semaphore_khr semaphore)
2113 if (pfn_clRetainSemaphoreKHR !=
nullptr) {
2114 return pfn_clRetainSemaphoreKHR(semaphore);
2117 return CL_INVALID_OPERATION;
2120 static cl_int release(cl_semaphore_khr semaphore)
2122 if (pfn_clReleaseSemaphoreKHR !=
nullptr) {
2123 return pfn_clReleaseSemaphoreKHR(semaphore);
2126 return CL_INVALID_OPERATION;
2130#if defined(cl_khr_command_buffer)
2134 static cl_int retain(cl_command_buffer_khr cmdBufferKhr)
2136 if (pfn_clRetainCommandBufferKHR ==
nullptr) {
2137 return detail::errHandler(CL_INVALID_OPERATION, __RETAIN_COMMAND_BUFFER_KHR_ERR);
2139 return pfn_clRetainCommandBufferKHR(cmdBufferKhr);
2142 static cl_int release(cl_command_buffer_khr cmdBufferKhr)
2144 if (pfn_clReleaseCommandBufferKHR ==
nullptr) {
2145 return detail::errHandler(CL_INVALID_OPERATION, __RELEASE_COMMAND_BUFFER_KHR_ERR);
2147 return pfn_clReleaseCommandBufferKHR(cmdBufferKhr);
2155 static cl_int retain(cl_mutable_command_khr)
2156 {
return CL_SUCCESS; }
2158 static cl_int release(cl_mutable_command_khr)
2159 {
return CL_SUCCESS; }
2164#if (CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120) || \
2165 (CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200)
2167static cl_uint getVersion(
const vector<char> &versionInfo)
2169 int highVersion = 0;
2172 while(versionInfo[index] !=
'.' ) {
2174 highVersion += versionInfo[index]-
'0';
2178 while(versionInfo[index] !=
' ' && versionInfo[index] !=
'\0') {
2180 lowVersion += versionInfo[index]-
'0';
2183 return (highVersion << 16) | lowVersion;
2186static cl_uint getPlatformVersion(cl_platform_id platform)
2189 CL_(clGetPlatformInfo)(platform, CL_PLATFORM_VERSION, 0,
nullptr, &size);
2191 vector<char> versionInfo(size);
2192 CL_(clGetPlatformInfo)(platform, CL_PLATFORM_VERSION, size, versionInfo.data(), &size);
2193 return getVersion(versionInfo);
2196static cl_uint getDevicePlatformVersion(cl_device_id device)
2198 cl_platform_id platform;
2199 CL_(clGetDeviceInfo)(device, CL_DEVICE_PLATFORM,
sizeof(platform), &platform,
nullptr);
2200 return getPlatformVersion(platform);
2203static cl_uint getContextPlatformVersion(cl_context context)
2208 CL_(clGetContextInfo)(context, CL_CONTEXT_DEVICES, 0,
nullptr, &size);
2211 vector<cl_device_id> devices(size/
sizeof(cl_device_id));
2212 CL_(clGetContextInfo)(context, CL_CONTEXT_DEVICES, size, devices.data(),
nullptr);
2213 return getDevicePlatformVersion(devices[0]);
2217template <
typename T>
2227 Wrapper() : object_(
nullptr) { }
2229 Wrapper(
const cl_type &obj,
bool retainObject) : object_(obj)
2232 detail::errHandler(retain(), __RETAIN_ERR);
2238 if (object_ !=
nullptr) { release(); }
2241 Wrapper(
const Wrapper<cl_type>& rhs)
2243 object_ = rhs.object_;
2244 detail::errHandler(retain(), __RETAIN_ERR);
2247 Wrapper(Wrapper<cl_type>&& rhs)
noexcept
2249 object_ = rhs.object_;
2250 rhs.object_ =
nullptr;
2253 Wrapper<cl_type>& operator = (
const Wrapper<cl_type>& rhs)
2256 detail::errHandler(release(), __RELEASE_ERR);
2257 object_ = rhs.object_;
2258 detail::errHandler(retain(), __RETAIN_ERR);
2263 Wrapper<cl_type>& operator = (Wrapper<cl_type>&& rhs)
2266 detail::errHandler(release(), __RELEASE_ERR);
2267 object_ = rhs.object_;
2268 rhs.object_ =
nullptr;
2273 Wrapper<cl_type>& operator = (
const cl_type &rhs)
2275 detail::errHandler(release(), __RELEASE_ERR);
2280 const cl_type& operator ()()
const {
return object_; }
2282 cl_type& operator ()() {
return object_; }
2284 cl_type get()
const {
return object_; }
2287 template<
typename Func,
typename U>
2288 friend inline cl_int getInfoHelper(Func, cl_uint, U*,
int,
typename U::cl_type);
2290 cl_int retain()
const
2292 if (object_ !=
nullptr) {
2293 return ReferenceHandler<cl_type>::retain(object_);
2300 cl_int release()
const
2302 if (object_ !=
nullptr) {
2303 return ReferenceHandler<cl_type>::release(object_);
2312class Wrapper<cl_device_id>
2315 typedef cl_device_id cl_type;
2319 bool referenceCountable_;
2321 static bool isReferenceCountable(cl_device_id device)
2323 bool retVal =
false;
2324#if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
2325 if (device !=
nullptr) {
2326 int version = getDevicePlatformVersion(device);
2327 if(version > ((1 << 16) + 1)) {
2331#elif CL_HPP_TARGET_OPENCL_VERSION >= 120
2339 Wrapper() : object_(nullptr), referenceCountable_(false)
2343 Wrapper(
const cl_type &obj,
bool retainObject) :
2345 referenceCountable_(false)
2347 referenceCountable_ = isReferenceCountable(obj);
2350 detail::errHandler(retain(), __RETAIN_ERR);
2359 Wrapper(
const Wrapper<cl_type>& rhs)
2361 object_ = rhs.object_;
2362 referenceCountable_ = isReferenceCountable(object_);
2363 detail::errHandler(retain(), __RETAIN_ERR);
2366 Wrapper(Wrapper<cl_type>&& rhs)
noexcept
2368 object_ = rhs.object_;
2369 referenceCountable_ = rhs.referenceCountable_;
2370 rhs.object_ =
nullptr;
2371 rhs.referenceCountable_ =
false;
2374 Wrapper<cl_type>& operator = (
const Wrapper<cl_type>& rhs)
2377 detail::errHandler(release(), __RELEASE_ERR);
2378 object_ = rhs.object_;
2379 referenceCountable_ = rhs.referenceCountable_;
2380 detail::errHandler(retain(), __RETAIN_ERR);
2385 Wrapper<cl_type>& operator = (Wrapper<cl_type>&& rhs)
2388 detail::errHandler(release(), __RELEASE_ERR);
2389 object_ = rhs.object_;
2390 referenceCountable_ = rhs.referenceCountable_;
2391 rhs.object_ =
nullptr;
2392 rhs.referenceCountable_ =
false;
2397 Wrapper<cl_type>& operator = (
const cl_type &rhs)
2399 detail::errHandler(release(), __RELEASE_ERR);
2401 referenceCountable_ = isReferenceCountable(object_);
2405 const cl_type& operator ()()
const {
return object_; }
2407 cl_type& operator ()() {
return object_; }
2409 cl_type get()
const {
return object_; }
2412 template<
typename Func,
typename U>
2413 friend inline cl_int getInfoHelper(Func, cl_uint, U*,
int,
typename U::cl_type);
2415 template<
typename Func,
typename U>
2416 friend inline cl_int getInfoHelper(Func, cl_uint, vector<U>*,
int,
typename U::cl_type);
2418 cl_int retain()
const
2420 if( object_ !=
nullptr && referenceCountable_ ) {
2421 return ReferenceHandler<cl_type>::retain(object_);
2428 cl_int release()
const
2430 if (object_ !=
nullptr && referenceCountable_) {
2431 return ReferenceHandler<cl_type>::release(object_);
2439template <
typename T>
2442 return lhs() == rhs();
2445template <
typename T>
2448 return !operator==(lhs, rhs);
2469 ImageFormat(cl_channel_order order, cl_channel_type type)
2471 image_channel_order = order;
2472 image_channel_data_type = type;
2482 this->image_channel_data_type = rhs.image_channel_data_type;
2483 this->image_channel_order = rhs.image_channel_order;
2499 static std::once_flag default_initialized_;
2501 static cl_int default_error_;
2508 static void makeDefault();
2515 static void makeDefaultProvided(
const Device &p) {
2520#ifdef CL_HPP_UNIT_TEST_ENABLE
2527 static void unitTestClearDefault() {
2533 Device() : detail::Wrapper<cl_type>() { }
2539 explicit Device(
const cl_device_id &device,
bool retainObject =
false) :
2540 detail::Wrapper<cl_type>(device, retainObject) { }
2547 cl_int *errResult =
nullptr)
2549 std::call_once(default_initialized_, makeDefault);
2550 detail::errHandler(default_error_);
2551 if (errResult !=
nullptr) {
2552 *errResult = default_error_;
2566 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_device));
2567 detail::errHandler(default_error_);
2577 detail::Wrapper<cl_type>::operator=(rhs);
2583 template <
typename T>
2584 cl_int
getInfo(cl_device_info name, T* param)
const
2586 return detail::errHandler(
2587 detail::getInfo(CL_(clGetDeviceInfo), object_, name, param),
2588 __GET_DEVICE_INFO_ERR);
2592 template <cl_device_info name>
typename
2594 getInfo(cl_int* err =
nullptr)
const
2597 detail::cl_device_info, name>::param_type param;
2598 cl_int result =
getInfo(name, ¶m);
2599 if (err !=
nullptr) {
2605#if CL_HPP_TARGET_OPENCL_VERSION >= 210
2614 cl_ulong retVal = 0;
2616 CL_(clGetHostTimer)(this->get(), &retVal);
2619 __GET_HOST_TIMER_ERR);
2638 std::pair<cl_ulong, cl_ulong> retVal;
2640 CL_(clGetDeviceAndHostTimer)(this->get(), &(retVal.first), &(retVal.second));
2643 __GET_DEVICE_AND_HOST_TIMER_ERR);
2651#if CL_HPP_TARGET_OPENCL_VERSION >= 120
2654 vector<Device>* devices);
2657#if defined(cl_ext_device_fission)
2659 cl_int
createSubDevices(
const cl_device_partition_property_ext* properties,
2660 vector<Device>* devices);
2664using BuildLogType = vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, CL_PROGRAM_BUILD_LOG>::param_type>>;
2665#if defined(CL_HPP_ENABLE_EXCEPTIONS)
2669class BuildError :
public Error
2672 BuildLogType buildLogs;
2674 BuildError(cl_int err,
const char * errStr,
const BuildLogType &vec) : Error(err, errStr), buildLogs(vec)
2678 BuildLogType getBuildLog()
const
2684 static inline cl_int buildErrHandler(
2686 const char * errStr,
2687 const BuildLogType &buildLogs)
2689 if (err != CL_SUCCESS) {
2690 throw BuildError(err, errStr, buildLogs);
2698 static inline cl_int buildErrHandler(
2700 const char * errStr,
2701 const BuildLogType &buildLogs)
2710CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Device::default_initialized_;
2711CL_HPP_DEFINE_STATIC_MEMBER_
Device Device::default_;
2712CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Device::default_error_ = CL_SUCCESS;
2724 static std::once_flag default_initialized_;
2726 static cl_int default_error_;
2733 static void makeDefault() {
2737#if defined(CL_HPP_ENABLE_EXCEPTIONS)
2745 cl_int err = CL_(clGetPlatformIDs)(0,
nullptr, &n);
2746 if (err != CL_SUCCESS) {
2747 default_error_ = err;
2751 default_error_ = CL_INVALID_PLATFORM;
2755 vector<cl_platform_id> ids(n);
2756 err = CL_(clGetPlatformIDs)(n, ids.data(),
nullptr);
2757 if (err != CL_SUCCESS) {
2758 default_error_ = err;
2764#if defined(CL_HPP_ENABLE_EXCEPTIONS)
2765 catch (cl::Error &e) {
2766 default_error_ = e.err();
2776 static void makeDefaultProvided(
const Platform &p) {
2781#ifdef CL_HPP_UNIT_TEST_ENABLE
2788 static void unitTestClearDefault() {
2794 Platform() : detail::Wrapper<cl_type>() { }
2803 explicit Platform(
const cl_platform_id &platform,
bool retainObject =
false) :
2804 detail::Wrapper<cl_type>(platform, retainObject) { }
2812 detail::Wrapper<cl_type>::operator=(rhs);
2817 cl_int *errResult =
nullptr)
2819 std::call_once(default_initialized_, makeDefault);
2820 detail::errHandler(default_error_);
2821 if (errResult !=
nullptr) {
2822 *errResult = default_error_;
2836 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_platform));
2837 detail::errHandler(default_error_);
2842 template <
typename T>
2843 cl_int
getInfo(cl_platform_info name, T* param)
const
2845 return detail::errHandler(
2846 detail::getInfo(CL_(clGetPlatformInfo), object_, name, param),
2847 __GET_PLATFORM_INFO_ERR);
2851 template <cl_platform_info name>
typename
2853 getInfo(cl_int* err =
nullptr)
const
2856 detail::cl_platform_info, name>::param_type param;
2857 cl_int result =
getInfo(name, ¶m);
2858 if (err !=
nullptr) {
2869 cl_device_type type,
2870 vector<Device>* devices)
const
2873 if( devices ==
nullptr ) {
2874 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR);
2876 cl_int err = CL_(clGetDeviceIDs)(object_, type, 0,
nullptr, &n);
2877 if (err != CL_SUCCESS && err != CL_DEVICE_NOT_FOUND) {
2878 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2881 vector<cl_device_id> ids(n);
2883 err = CL_(clGetDeviceIDs)(object_, type, n, ids.data(),
nullptr);
2884 if (err != CL_SUCCESS) {
2885 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2894 devices->resize(ids.size());
2898 for (size_type i = 0; i < ids.size(); i++) {
2899 (*devices)[i] =
Device(ids[i],
true);
2905#if defined(CL_HPP_USE_DX_INTEROP)
2930 cl_d3d10_device_source_khr d3d_device_source,
2932 cl_d3d10_device_set_khr d3d_device_set,
2933 vector<Device>* devices)
const
2935 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clGetDeviceIDsFromD3D10KHR)(
2936 cl_platform_id platform,
2937 cl_d3d10_device_source_khr d3d_device_source,
2939 cl_d3d10_device_set_khr d3d_device_set,
2940 cl_uint num_entries,
2941 cl_device_id * devices,
2942 cl_uint* num_devices);
2944 if( devices ==
nullptr ) {
2945 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR);
2948 static PFN_clGetDeviceIDsFromD3D10KHR pfn_clGetDeviceIDsFromD3D10KHR =
nullptr;
2949#if CL_HPP_TARGET_OPENCL_VERSION >= 120
2950 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(object_, clGetDeviceIDsFromD3D10KHR);
2952#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
2953 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetDeviceIDsFromD3D10KHR);
2957 cl_int err = pfn_clGetDeviceIDsFromD3D10KHR(
2965 if (err != CL_SUCCESS) {
2966 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2969 vector<cl_device_id> ids(n);
2970 err = pfn_clGetDeviceIDsFromD3D10KHR(
2978 if (err != CL_SUCCESS) {
2979 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2987 devices->resize(ids.size());
2991 for (size_type i = 0; i < ids.size(); i++) {
2992 (*devices)[i] = Device(ids[i],
true);
3004 vector<Platform>* platforms)
3008 if( platforms ==
nullptr ) {
3009 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_PLATFORM_IDS_ERR);
3012 cl_int err = CL_(clGetPlatformIDs)(0,
nullptr, &n);
3013 if (err != CL_SUCCESS) {
3014 return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
3017 vector<cl_platform_id> ids(n);
3018 err = CL_(clGetPlatformIDs)(n, ids.data(),
nullptr);
3019 if (err != CL_SUCCESS) {
3020 return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
3024 platforms->resize(ids.size());
3027 for (size_type i = 0; i < ids.size(); i++) {
3028 (*platforms)[i] =
Platform(ids[i]);
3042 Platform default_platform = Platform::getDefault(&err);
3044 *platform = default_platform;
3058 cl_int * errResult =
nullptr)
3061 Platform default_platform = Platform::getDefault(&err);
3065 return default_platform;
3068#if CL_HPP_TARGET_OPENCL_VERSION >= 120
3073 return CL_(clUnloadPlatformCompiler)(object_);
3078#if CL_HPP_TARGET_OPENCL_VERSION >= 120
3081 vector<Device>* devices)
3084 cl_int err = CL_(clCreateSubDevices)(object_, properties, 0,
nullptr, &n);
3085 if (err != CL_SUCCESS)
3087 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
3090 vector<cl_device_id> ids(n);
3091 err = CL_(clCreateSubDevices)(object_, properties, n, ids.data(),
nullptr);
3092 if (err != CL_SUCCESS)
3094 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
3101 devices->resize(ids.size());
3105 for (size_type i = 0; i < ids.size(); i++)
3109 (*devices)[i] =
Device(ids[i],
false);
3117#if defined(cl_ext_device_fission)
3120 vector<Device>* devices)
3122#if CL_HPP_TARGET_OPENCL_VERSION >= 120
3123 cl::Device device(object_);
3124 cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>()();
3125 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCreateSubDevicesEXT);
3127#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
3128 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateSubDevicesEXT);
3132 cl_int err = pfn_clCreateSubDevicesEXT(object_, properties, 0,
nullptr, &n);
3133 if (err != CL_SUCCESS)
3135 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
3138 vector<cl_device_id> ids(n);
3140 pfn_clCreateSubDevicesEXT(object_, properties, n, ids.data(),
nullptr);
3141 if (err != CL_SUCCESS)
3143 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
3149 devices->resize(ids.size());
3153 for (size_type i = 0; i < ids.size(); i++)
3157 (*devices)[i] =
Device(ids[i],
false);
3165CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Platform::default_initialized_;
3166CL_HPP_DEFINE_STATIC_MEMBER_
Platform Platform::default_;
3167CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Platform::default_error_ = CL_SUCCESS;
3173#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
3178inline CL_API_PREFIX__VERSION_1_1_DEPRECATED cl_int
3183 return CL_(clUnloadCompiler)();
3188#if defined(cl_ext_image_requirements_info)
3189enum ImageRequirementsInfoExt : cl_image_requirements_info_ext
3191 RowPitchAlign = CL_IMAGE_REQUIREMENTS_ROW_PITCH_ALIGNMENT_EXT,
3192 BaseAddAlign = CL_IMAGE_REQUIREMENTS_BASE_ADDRESS_ALIGNMENT_EXT,
3193 Size = CL_IMAGE_REQUIREMENTS_SIZE_EXT,
3194 MaxWidth = CL_IMAGE_REQUIREMENTS_MAX_WIDTH_EXT,
3195 MaxHeight = CL_IMAGE_REQUIREMENTS_MAX_HEIGHT_EXT,
3196 MaxDepth = CL_IMAGE_REQUIREMENTS_MAX_DEPTH_EXT,
3197 MaxArraySize = CL_IMAGE_REQUIREMENTS_MAX_ARRAY_SIZE_EXT,
3198#if defined(cl_ext_image_from_buffer)
3199 SlicePitchAlign = CL_IMAGE_REQUIREMENTS_SLICE_PITCH_ALIGNMENT_EXT,
3218 static std::once_flag default_initialized_;
3220 static cl_int default_error_;
3227 static void makeDefault() {
3231#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3235#if !defined(__APPLE__) && !defined(__MACOS)
3236 const Platform &p = Platform::getDefault();
3237 cl_platform_id defaultPlatform = p();
3238 cl_context_properties properties[3] = {
3239 CL_CONTEXT_PLATFORM, (cl_context_properties)defaultPlatform, 0
3242 cl_context_properties *properties =
nullptr;
3246 CL_DEVICE_TYPE_DEFAULT,
3252#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3253 catch (cl::Error &e) {
3254 default_error_ = e.err();
3265 static void makeDefaultProvided(
const Context &c) {
3269#if defined(cl_ext_image_requirements_info)
3270 struct ImageRequirementsInfo {
3272 ImageRequirementsInfo(cl_mem_flags f,
const cl_mem_properties* mem_properties,
const ImageFormat* format,
const cl_image_desc* desc)
3275 properties = mem_properties;
3276 image_format = format;
3280 cl_mem_flags flags = 0;
3281 const cl_mem_properties* properties;
3283 const cl_image_desc* image_desc;
3286 static cl_int getImageRequirementsInfoExtHelper(
const Context &context,
3287 const ImageRequirementsInfo &info,
3288 cl_image_requirements_info_ext param_name,
3289 size_type param_value_size,
3291 size_type* param_value_size_ret)
3294#if CL_HPP_TARGET_OPENCL_VERSION >= 120
3295 Device device = context.
getInfo<CL_CONTEXT_DEVICES>().at(0);
3296 cl_platform_id platform = device.
getInfo<CL_DEVICE_PLATFORM>()();
3297 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clGetImageRequirementsInfoEXT);
3299 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetImageRequirementsInfoEXT);
3302 if (pfn_clGetImageRequirementsInfoEXT ==
nullptr) {
3303 return detail::errHandler(CL_INVALID_OPERATION, __GET_IMAGE_REQUIREMENT_INFO_EXT_ERR);
3306 return detail::errHandler(
3307 pfn_clGetImageRequirementsInfoEXT(context(), info.properties,
3308 info.flags, info.image_format, info.image_desc, param_name,
3309 param_value_size, param_value, param_value_size_ret),
3310 __GET_IMAGE_REQUIREMENT_INFO_EXT_ERR);
3315#ifdef CL_HPP_UNIT_TEST_ENABLE
3322 static void unitTestClearDefault() {
3332 const vector<Device>& devices,
3333 const cl_context_properties* properties =
nullptr,
3334 void (CL_CALLBACK * notifyFptr)(
3339 void* data =
nullptr,
3340 cl_int* err =
nullptr)
3344 size_type numDevices = devices.size();
3345 vector<cl_device_id> deviceIDs(numDevices);
3347 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
3348 deviceIDs[deviceIndex] = (devices[deviceIndex])();
3351 object_ = CL_(clCreateContext)(
3352 properties, (cl_uint) numDevices,
3354 notifyFptr, data, &error);
3356 detail::errHandler(error, __CREATE_CONTEXT_ERR);
3357 if (err !=
nullptr) {
3368 const cl_context_properties* properties =
nullptr,
3369 void (CL_CALLBACK * notifyFptr)(
3374 void* data =
nullptr,
3375 cl_int* err =
nullptr)
3379 cl_device_id deviceID = device();
3381 object_ = CL_(clCreateContext)(
3384 notifyFptr, data, &error);
3386 detail::errHandler(error, __CREATE_CONTEXT_ERR);
3387 if (err !=
nullptr) {
3397 cl_device_type type,
3398 const cl_context_properties* properties =
nullptr,
3399 void (CL_CALLBACK * notifyFptr)(
3404 void* data =
nullptr,
3405 cl_int* err =
nullptr)
3409#if !defined(__APPLE__) && !defined(__MACOS)
3410 cl_context_properties prop[4] = {CL_CONTEXT_PLATFORM, 0, 0, 0 };
3412 if (properties ==
nullptr) {
3414 vector<Platform> platforms;
3416 if (error != CL_SUCCESS) {
3417 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
3418 if (err !=
nullptr) {
3425 cl_context_properties platform_id = 0;
3426 for (
unsigned int i = 0; i < platforms.size(); i++) {
3428 vector<Device> devices;
3430#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3434 error = platforms[i].getDevices(type, &devices);
3436#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3437 }
catch (cl::Error& e) {
3445 if (error != CL_SUCCESS && error != CL_DEVICE_NOT_FOUND) {
3446 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
3447 if (err !=
nullptr) {
3452 if (devices.size() > 0) {
3453 platform_id = (cl_context_properties)platforms[i]();
3458 if (platform_id == 0) {
3459 detail::errHandler(CL_DEVICE_NOT_FOUND, __CREATE_CONTEXT_FROM_TYPE_ERR);
3460 if (err !=
nullptr) {
3461 *err = CL_DEVICE_NOT_FOUND;
3466 prop[1] = platform_id;
3467 properties = &prop[0];
3470 object_ = CL_(clCreateContextFromType)(
3471 properties, type, notifyFptr, data, &error);
3473 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
3474 if (err !=
nullptr) {
3486 std::call_once(default_initialized_, makeDefault);
3487 detail::errHandler(default_error_);
3488 if (err !=
nullptr) {
3489 *err = default_error_;
3503 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_context));
3504 detail::errHandler(default_error_);
3509 Context() : detail::Wrapper<cl_type>() { }
3516 explicit Context(
const cl_context& context,
bool retainObject =
false) :
3517 detail::Wrapper<cl_type>(context, retainObject) { }
3526 detail::Wrapper<cl_type>::operator=(rhs);
3531 template <
typename T>
3532 cl_int
getInfo(cl_context_info name, T* param)
const
3534 return detail::errHandler(
3535 detail::getInfo(CL_(clGetContextInfo), object_, name, param),
3536 __GET_CONTEXT_INFO_ERR);
3540 template <cl_context_info name>
typename
3542 getInfo(cl_int* err =
nullptr)
const
3545 detail::cl_context_info, name>::param_type param;
3546 cl_int result =
getInfo(name, ¶m);
3547 if (err !=
nullptr) {
3559 cl_mem_object_type type,
3560 vector<ImageFormat>* formats)
const
3568 cl_int err = CL_(clGetSupportedImageFormats)(
3575 if (err != CL_SUCCESS) {
3576 return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
3579 if (numEntries > 0) {
3580 vector<ImageFormat> value(numEntries);
3581 err = CL_(clGetSupportedImageFormats)(
3586 (cl_image_format*)value.data(),
3588 if (err != CL_SUCCESS) {
3589 return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
3592 formats->assign(value.begin(), value.end());
3602#if defined(cl_ext_image_requirements_info)
3603 template <
typename T>
3604 cl_int getImageRequirementsInfoExt(cl_image_requirements_info_ext name,
3606 cl_mem_flags flags = 0,
3607 const cl_mem_properties* properties =
nullptr,
3609 const cl_image_desc* image_desc =
nullptr)
const
3611 ImageRequirementsInfo imageInfo = {flags, properties, image_format, image_desc};
3613 return detail::errHandler(
3615 Context::getImageRequirementsInfoExtHelper, *
this, imageInfo, name, param),
3616 __GET_IMAGE_REQUIREMENT_INFO_EXT_ERR);
3619 template <cl_image_requirements_info_ext type>
typename
3620 detail::param_traits<detail::cl_image_requirements_info_ext, type>::param_type
3621 getImageRequirementsInfoExt(cl_mem_flags flags = 0,
3622 const cl_mem_properties* properties =
nullptr,
3623 const ImageFormat* image_format =
nullptr,
3624 const cl_image_desc* image_desc =
nullptr,
3625 cl_int* err =
nullptr)
const
3627 typename detail::param_traits<
3628 detail::cl_image_requirements_info_ext, type>::param_type param;
3629 cl_int result = getImageRequirementsInfoExt(type, ¶m, flags, properties, image_format, image_desc);
3630 if (err !=
nullptr) {
3637#if CL_HPP_TARGET_OPENCL_VERSION >= 300
3649 void (CL_CALLBACK * pfn_notify)(cl_context,
void *),
3650 void * user_data =
nullptr)
3652 return detail::errHandler(
3653 CL_(clSetContextDestructorCallback)(
3657 __SET_CONTEXT_DESCTRUCTOR_CALLBACK_ERR);
3662inline void Device::makeDefault()
3667#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3674 detail::errHandler(error, __CREATE_CONTEXT_ERR);
3676 if (error != CL_SUCCESS) {
3677 default_error_ = error;
3680 default_ = context.getInfo<CL_CONTEXT_DEVICES>()[0];
3681 default_error_ = CL_SUCCESS;
3684#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3685 catch (cl::Error &e) {
3686 default_error_ = e.err();
3691CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Context::default_initialized_;
3692CL_HPP_DEFINE_STATIC_MEMBER_
Context Context::default_;
3693CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Context::default_error_ = CL_SUCCESS;
3717 explicit Event(
const cl_event& event,
bool retainObject =
false) :
3718 detail::Wrapper<cl_type>(event, retainObject) { }
3727 detail::Wrapper<cl_type>::operator=(rhs);
3732 template <
typename T>
3733 cl_int
getInfo(cl_event_info name, T* param)
const
3735 return detail::errHandler(
3736 detail::getInfo(CL_(clGetEventInfo), object_, name, param),
3737 __GET_EVENT_INFO_ERR);
3741 template <cl_event_info name>
typename
3743 getInfo(cl_int* err =
nullptr)
const
3746 detail::cl_event_info, name>::param_type param;
3747 cl_int result =
getInfo(name, ¶m);
3748 if (err !=
nullptr) {
3755 template <
typename T>
3758 return detail::errHandler(detail::getInfo(
3759 CL_(clGetEventProfilingInfo), object_, name, param),
3760 __GET_EVENT_PROFILE_INFO_ERR);
3764 template <cl_profiling_info name>
typename
3769 detail::cl_profiling_info, name>::param_type param;
3771 if (err !=
nullptr) {
3783 return detail::errHandler(
3784 CL_(clWaitForEvents)(1, &object_),
3785 __WAIT_FOR_EVENTS_ERR);
3788#if CL_HPP_TARGET_OPENCL_VERSION >= 110
3795 void (CL_CALLBACK * pfn_notify)(cl_event, cl_int,
void *),
3796 void * user_data =
nullptr)
3798 return detail::errHandler(
3799 CL_(clSetEventCallback)(
3804 __SET_EVENT_CALLBACK_ERR);
3815 static_assert(
sizeof(
cl::Event) ==
sizeof(cl_event),
3816 "Size of cl::Event must be equal to size of cl_event");
3818 return detail::errHandler(
3819 CL_(clWaitForEvents)(
3820 (cl_uint) events.size(), (events.size() > 0) ? (
const cl_event*)&events.front() :
nullptr),
3821 __WAIT_FOR_EVENTS_ERR);
3825#if CL_HPP_TARGET_OPENCL_VERSION >= 110
3839 cl_int * err =
nullptr)
3842 object_ = CL_(clCreateUserEvent)(
3846 detail::errHandler(error, __CREATE_USER_EVENT_ERR);
3847 if (err !=
nullptr) {
3861 return detail::errHandler(
3862 CL_(clSetUserEventStatus)(object_,status),
3863 __SET_USER_EVENT_STATUS_ERR);
3873WaitForEvents(
const vector<Event>& events)
3875 return detail::errHandler(
3876 CL_(clWaitForEvents)(
3877 (cl_uint) events.size(), (events.size() > 0) ? (
const cl_event*)&events.front() :
nullptr),
3878 __WAIT_FOR_EVENTS_ERR);
3906 explicit Memory(
const cl_mem& memory,
bool retainObject) :
3907 detail::Wrapper<cl_type>(memory, retainObject) { }
3916 detail::Wrapper<cl_type>::operator=(rhs);
3921 template <
typename T>
3922 cl_int
getInfo(cl_mem_info name, T* param)
const
3924 return detail::errHandler(
3925 detail::getInfo(CL_(clGetMemObjectInfo), object_, name, param),
3926 __GET_MEM_OBJECT_INFO_ERR);
3930 template <cl_mem_info name>
typename
3932 getInfo(cl_int* err =
nullptr)
const
3935 detail::cl_mem_info, name>::param_type param;
3936 cl_int result =
getInfo(name, ¶m);
3937 if (err !=
nullptr) {
3943#if CL_HPP_TARGET_OPENCL_VERSION >= 110
3958 void (CL_CALLBACK * pfn_notify)(cl_mem,
void *),
3959 void * user_data =
nullptr)
3961 return detail::errHandler(
3962 CL_(clSetMemObjectDestructorCallback)(
3966 __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR);
3974template<
typename IteratorType >
3975cl_int
copy( IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer );
3976template<
typename IteratorType >
3977cl_int
copy(
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator );
3978template<
typename IteratorType >
3979cl_int
copy(
const CommandQueue &queue, IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer );
3980template<
typename IteratorType >
3981cl_int
copy(
const CommandQueue &queue,
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator );
3984#if CL_HPP_TARGET_OPENCL_VERSION >= 200
3990 static cl_svm_mem_flags getSVMMemFlags()
3997template<
class Trait = detail::SVMTraitNull>
3998class SVMTraitReadWrite
4001 static cl_svm_mem_flags getSVMMemFlags()
4003 return CL_MEM_READ_WRITE |
4004 Trait::getSVMMemFlags();
4008template<
class Trait = detail::SVMTraitNull>
4009class SVMTraitReadOnly
4012 static cl_svm_mem_flags getSVMMemFlags()
4014 return CL_MEM_READ_ONLY |
4015 Trait::getSVMMemFlags();
4019template<
class Trait = detail::SVMTraitNull>
4020class SVMTraitWriteOnly
4023 static cl_svm_mem_flags getSVMMemFlags()
4025 return CL_MEM_WRITE_ONLY |
4026 Trait::getSVMMemFlags();
4030template<
class Trait = SVMTraitReadWrite<>>
4034 static cl_svm_mem_flags getSVMMemFlags()
4036 return Trait::getSVMMemFlags();
4040template<
class Trait = SVMTraitReadWrite<>>
4044 static cl_svm_mem_flags getSVMMemFlags()
4046 return CL_MEM_SVM_FINE_GRAIN_BUFFER |
4047 Trait::getSVMMemFlags();
4051template<
class Trait = SVMTraitReadWrite<>>
4055 static cl_svm_mem_flags getSVMMemFlags()
4058 CL_MEM_SVM_FINE_GRAIN_BUFFER |
4059 CL_MEM_SVM_ATOMICS |
4060 Trait::getSVMMemFlags();
4071 const vector<Event>* events =
nullptr,
4072 Event* event =
nullptr);
4085template<
typename T,
class SVMTrait>
4091 typedef T value_type;
4092 typedef value_type* pointer;
4093 typedef const value_type* const_pointer;
4094 typedef value_type& reference;
4095 typedef const value_type& const_reference;
4096 typedef std::size_t size_type;
4097 typedef std::ptrdiff_t difference_type;
4099 template<
typename U>
4102 typedef SVMAllocator<U, SVMTrait> other;
4105 template<
typename U,
typename V>
4106 friend class SVMAllocator;
4109 context_(
Context::getDefault())
4119 SVMAllocator(
const SVMAllocator &other) :
4120 context_(other.context_)
4124 template<
typename U>
4125 SVMAllocator(
const SVMAllocator<U, SVMTrait> &other) :
4126 context_(other.context_)
4134 pointer address(reference r)
noexcept
4136 return std::addressof(r);
4139 const_pointer address(const_reference r)
noexcept
4141 return std::addressof(r);
4152 typename cl::SVMAllocator<void, SVMTrait>::const_pointer = 0,
4159 SVMTrait::getSVMMemFlags(),
4162 pointer retValue =
reinterpret_cast<pointer
>(
4164#if defined(CL_HPP_ENABLE_EXCEPTIONS)
4166 std::bad_alloc excep;
4172 if (map && !(SVMTrait::getSVMMemFlags() & CL_MEM_SVM_FINE_GRAIN_BUFFER)) {
4173 cl_int err =
enqueueMapSVM(retValue, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE, size*
sizeof(T));
4174 if (err != CL_SUCCESS) {
4175 CL_(clSVMFree)(context_(), retValue);
4177#if defined(CL_HPP_ENABLE_EXCEPTIONS)
4178 std::bad_alloc excep;
4188 void deallocate(pointer p, size_type)
4190 CL_(clSVMFree)(context_(), p);
4197 size_type
max_size() const noexcept
4199 size_type maxSize = std::numeric_limits<size_type>::max() /
sizeof(T);
4201 for (
const Device &d : context_.
getInfo<CL_CONTEXT_DEVICES>()) {
4204 static_cast<size_type
>(d.getInfo<CL_DEVICE_MAX_MEM_ALLOC_SIZE>()));
4210 template<
class U,
class... Args >
4211 void construct(U* p, Args&&... args)
4225 inline bool operator==(SVMAllocator
const& rhs)
4227 return (context_==rhs.context_);
4237template<
class SVMTrait>
4240 typedef void value_type;
4241 typedef value_type* pointer;
4242 typedef const value_type* const_pointer;
4244 template<
typename U>
4247 typedef SVMAllocator<U, SVMTrait> other;
4250 template<
typename U,
typename V>
4251 friend class SVMAllocator;
4254#if !defined(CL_HPP_NO_STD_UNIQUE_PTR)
4257 template<
class Alloc>
4264 typedef typename std::allocator_traits<Alloc>::pointer pointer;
4266 Deleter(
const Alloc &alloc, size_type copies) : alloc_{ alloc }, copies_{ copies }
4270 void operator()(pointer ptr)
const {
4271 Alloc tmpAlloc{ alloc_ };
4272 std::allocator_traits<Alloc>::destroy(tmpAlloc, std::addressof(*ptr));
4273 std::allocator_traits<Alloc>::deallocate(tmpAlloc, ptr, copies_);
4284template <
class T,
class Alloc,
class... Args>
4285cl::pointer<T, detail::Deleter<Alloc>>
allocate_pointer(
const Alloc &alloc_, Args&&... args)
4287 Alloc alloc(alloc_);
4288 static const size_type copies = 1;
4293 T* tmp = std::allocator_traits<Alloc>::allocate(alloc, copies);
4295#if defined(CL_HPP_ENABLE_EXCEPTIONS)
4296 std::bad_alloc excep;
4303#if defined(CL_HPP_ENABLE_EXCEPTIONS)
4307 std::allocator_traits<Alloc>::construct(
4309 std::addressof(*tmp),
4310 std::forward<Args>(args)...);
4314#if defined(CL_HPP_ENABLE_EXCEPTIONS)
4315 catch (std::bad_alloc&)
4317 std::allocator_traits<Alloc>::deallocate(alloc, tmp, copies);
4323template<
class T,
class SVMTrait,
class... Args >
4324cl::pointer<T, detail::Deleter<SVMAllocator<T, SVMTrait>>> allocate_svm(Args... args)
4326 SVMAllocator<T, SVMTrait> alloc;
4330template<
class T,
class SVMTrait,
class... Args >
4331cl::pointer<T, detail::Deleter<SVMAllocator<T, SVMTrait>>> allocate_svm(
const cl::Context &c, Args... args)
4342using coarse_svm_vector = vector<T, cl::SVMAllocator<int, cl::SVMTraitCoarse<>>>;
4348using fine_svm_vector = vector<T, cl::SVMAllocator<int, cl::SVMTraitFine<>>>;
4354using atomic_svm_vector = vector<T, cl::SVMAllocator<int, cl::SVMTraitAtomic<>>>;
4380 void* host_ptr =
nullptr,
4381 cl_int* err =
nullptr)
4384 object_ = CL_(clCreateBuffer)(context(), flags, size, host_ptr, &error);
4386 detail::errHandler(error, __CREATE_BUFFER_ERR);
4387 if (err !=
nullptr) {
4392#if CL_HPP_TARGET_OPENCL_VERSION >= 300
4405 const vector<cl_mem_properties>& properties,
4408 void* host_ptr =
nullptr,
4409 cl_int* err =
nullptr)
4413 if (properties.empty()) {
4414 object_ = CL_(clCreateBufferWithProperties)(context(),
nullptr, flags,
4415 size, host_ptr, &error);
4418 object_ = CL_(clCreateBufferWithProperties)(
4419 context(), properties.data(), flags, size, host_ptr, &error);
4422 detail::errHandler(error, __CREATE_BUFFER_ERR);
4423 if (err !=
nullptr) {
4441 void* host_ptr =
nullptr,
4442 cl_int* err =
nullptr) :
Buffer(
Context::getDefault(err), flags, size, host_ptr, err) { }
4444#if CL_HPP_TARGET_OPENCL_VERSION >= 300
4458 const vector<cl_mem_properties>& properties,
4461 void* host_ptr =
nullptr,
4462 cl_int* err =
nullptr) :
Buffer(
Context::getDefault(err), properties, flags, size, host_ptr, err) { }
4470 template<
typename IteratorType >
4472 IteratorType startIterator,
4473 IteratorType endIterator,
4475 bool useHostPtr =
false,
4476 cl_int* err =
nullptr)
4478 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
4481 cl_mem_flags flags = 0;
4483 flags |= CL_MEM_READ_ONLY;
4486 flags |= CL_MEM_READ_WRITE;
4489 flags |= CL_MEM_USE_HOST_PTR;
4492 size_type size =
sizeof(DataType)*(endIterator - startIterator);
4497 object_ = CL_(clCreateBuffer)(context(), flags, size,
const_cast<DataType*
>(&*startIterator), &error);
4499 object_ = CL_(clCreateBuffer)(context(), flags, size, 0, &error);
4502 detail::errHandler(error, __CREATE_BUFFER_ERR);
4503 if (err !=
nullptr) {
4508 error =
cl::copy(startIterator, endIterator, *
this);
4509 detail::errHandler(error, __CREATE_BUFFER_ERR);
4510 if (err !=
nullptr) {
4521 template<
typename IteratorType >
4522 Buffer(
const Context &context, IteratorType startIterator, IteratorType endIterator,
4523 bool readOnly,
bool useHostPtr =
false, cl_int* err =
nullptr);
4529 template<
typename IteratorType >
4531 bool readOnly,
bool useHostPtr =
false, cl_int* err =
nullptr);
4543 explicit Buffer(
const cl_mem& buffer,
bool retainObject =
false) :
4544 Memory(buffer, retainObject) { }
4557#if CL_HPP_TARGET_OPENCL_VERSION >= 110
4564 cl_buffer_create_type buffer_create_type,
4565 const void * buffer_create_info,
4566 cl_int * err =
nullptr)
4570 result.object_ = CL_(clCreateSubBuffer)(
4577 detail::errHandler(error, __CREATE_SUBBUFFER_ERR);
4578 if (err !=
nullptr) {
4587#if defined (CL_HPP_USE_DX_INTEROP)
4596class BufferD3D10 :
public Buffer
4607 const Context& context,
4609 ID3D10Buffer* bufobj,
4610 cl_int * err =
nullptr) : pfn_clCreateFromD3D10BufferKHR(nullptr)
4612 typedef CL_API_ENTRY cl_mem (CL_API_CALL *PFN_clCreateFromD3D10BufferKHR)(
4613 cl_context context, cl_mem_flags flags, ID3D10Buffer* buffer,
4614 cl_int* errcode_ret);
4615 PFN_clCreateFromD3D10BufferKHR pfn_clCreateFromD3D10BufferKHR;
4616#if CL_HPP_TARGET_OPENCL_VERSION >= 120
4617 vector<cl_context_properties> props = context.getInfo<CL_CONTEXT_PROPERTIES>();
4618 cl_platform platform =
nullptr;
4619 for(
int i = 0; i < props.size(); ++i ) {
4620 if( props[i] == CL_CONTEXT_PLATFORM ) {
4621 platform = props[i+1];
4624 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCreateFromD3D10BufferKHR);
4626#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
4627 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateFromD3D10BufferKHR);
4631 object_ = pfn_clCreateFromD3D10BufferKHR(
4638 detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
4639 if (err !=
nullptr) {
4645 BufferD3D10() : Buffer() { }
4654 explicit BufferD3D10(
const cl_mem& buffer,
bool retainObject =
false) :
4655 Buffer(buffer, retainObject) { }
4661 BufferD3D10& operator = (
const cl_mem& rhs)
4663 Buffer::operator=(rhs);
4689 cl_int * err =
nullptr)
4692 object_ = CL_(clCreateFromGLBuffer)(
4698 detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
4699 if (err !=
nullptr) {
4714 explicit BufferGL(
const cl_mem& buffer,
bool retainObject =
false) :
4715 Buffer(buffer, retainObject) { }
4730 cl_gl_object_type *type,
4731 cl_GLuint * gl_object_name)
4733 return detail::errHandler(
4734 CL_(clGetGLObjectInfo)(object_,type,gl_object_name),
4735 __GET_GL_OBJECT_INFO_ERR);
4759 cl_int * err =
nullptr)
4762 object_ = CL_(clCreateFromGLRenderbuffer)(
4768 detail::errHandler(error, __CREATE_GL_RENDER_BUFFER_ERR);
4769 if (err !=
nullptr) {
4784 explicit BufferRenderGL(
const cl_mem& buffer,
bool retainObject =
false) :
4785 Buffer(buffer, retainObject) { }
4800 cl_gl_object_type *type,
4801 cl_GLuint * gl_object_name)
4803 return detail::errHandler(
4804 CL_(clGetGLObjectInfo)(object_,type,gl_object_name),
4805 __GET_GL_OBJECT_INFO_ERR);
4828 explicit Image(
const cl_mem& image,
bool retainObject =
false) :
4829 Memory(image, retainObject) { }
4844 template <
typename T>
4845 cl_int
getImageInfo(cl_image_info name, T* param)
const
4847 return detail::errHandler(
4848 detail::getInfo(CL_(clGetImageInfo), object_, name, param),
4849 __GET_IMAGE_INFO_ERR);
4853 template <cl_image_info name>
typename
4858 detail::cl_image_info, name>::param_type param;
4860 if (err !=
nullptr) {
4867#if CL_HPP_TARGET_OPENCL_VERSION >= 120
4886 void* host_ptr =
nullptr,
4887 cl_int* err =
nullptr)
4891 cl_image_desc desc = {};
4892 desc.image_type = CL_MEM_OBJECT_IMAGE1D;
4893 desc.image_width = width;
4895 object_ = CL_(clCreateImage)(
4903 detail::errHandler(error, __CREATE_IMAGE_ERR);
4904 if (err !=
nullptr) {
4912#if CL_HPP_TARGET_OPENCL_VERSION >= 300
4923 Image1D(
const Context &context,
const vector<cl_mem_properties> &properties,
4924 cl_mem_flags flags,
ImageFormat format, size_type width,
4925 void *host_ptr =
nullptr, cl_int *err =
nullptr) {
4928 cl_image_desc desc = {};
4929 desc.image_type = CL_MEM_OBJECT_IMAGE1D;
4930 desc.image_width = width;
4932 if (properties.empty()) {
4933 object_ = CL_(clCreateImageWithProperties)(
4934 context(),
nullptr, flags, &format, &desc, host_ptr, &error);
4937 CL_(clCreateImageWithProperties)(context(), properties.data(), flags,
4938 &format, &desc, host_ptr, &error);
4941 detail::errHandler(error, __CREATE_IMAGE_ERR);
4942 if (err !=
nullptr) {
4955 explicit Image1D(
const cl_mem& image1D,
bool retainObject =
false) :
4956 Image(image1D, retainObject) { }
4974class Image1DBuffer :
public Image
4983 cl_int* err =
nullptr)
4987 cl_image_desc desc = {};
4988 desc.image_type = CL_MEM_OBJECT_IMAGE1D_BUFFER;
4989 desc.image_width = width;
4990 desc.buffer = buffer();
4992 object_ = CL_(clCreateImage)(
5000 detail::errHandler(error, __CREATE_IMAGE_ERR);
5001 if (err !=
nullptr) {
5008#if CL_HPP_TARGET_OPENCL_VERSION >= 300
5018 Image1DBuffer(
const Context &context,
5019 const vector<cl_mem_properties> &properties,
5020 cl_mem_flags flags,
ImageFormat format, size_type width,
5021 const Buffer &buffer, cl_int *err =
nullptr) {
5024 cl_image_desc desc = {};
5025 desc.image_type = CL_MEM_OBJECT_IMAGE1D_BUFFER;
5026 desc.image_width = width;
5027 desc.buffer = buffer();
5029 if (properties.empty()) {
5030 object_ = CL_(clCreateImageWithProperties)(
5031 context(),
nullptr, flags, &format, &desc,
nullptr, &error);
5034 CL_(clCreateImageWithProperties)(context(), properties.data(), flags,
5035 &format, &desc,
nullptr, &error);
5038 detail::errHandler(error, __CREATE_IMAGE_ERR);
5039 if (err !=
nullptr) {
5052 explicit Image1DBuffer(
const cl_mem& image1D,
bool retainObject =
false) :
5053 Image(image1D, retainObject) { }
5065class Image1DArray :
public Image
5072 size_type arraySize,
5075 void* host_ptr =
nullptr,
5076 cl_int* err =
nullptr)
5080 cl_image_desc desc = {};
5081 desc.image_type = CL_MEM_OBJECT_IMAGE1D_ARRAY;
5082 desc.image_width = width;
5083 desc.image_array_size = arraySize;
5084 desc.image_row_pitch = rowPitch;
5086 object_ = CL_(clCreateImage)(
5094 detail::errHandler(error, __CREATE_IMAGE_ERR);
5095 if (err !=
nullptr) {
5102#if CL_HPP_TARGET_OPENCL_VERSION >= 300
5113 Image1DArray(
const Context &context,
5114 const vector<cl_mem_properties> &properties,
5115 cl_mem_flags flags,
ImageFormat format, size_type arraySize,
5116 size_type width, size_type rowPitch = 0,
5117 void *host_ptr =
nullptr, cl_int *err =
nullptr) {
5120 cl_image_desc desc = {};
5121 desc.image_type = CL_MEM_OBJECT_IMAGE1D_ARRAY;
5122 desc.image_width = width;
5123 desc.image_array_size = arraySize;
5124 desc.image_row_pitch = rowPitch;
5126 if (properties.empty()) {
5127 object_ = CL_(clCreateImageWithProperties)(
5128 context(),
nullptr, flags, &format, &desc, host_ptr, &error);
5131 CL_(clCreateImageWithProperties)(context(), properties.data(), flags,
5132 &format, &desc, host_ptr, &error);
5135 detail::errHandler(error, __CREATE_IMAGE_ERR);
5136 if (err !=
nullptr) {
5149 explicit Image1DArray(
const cl_mem& imageArray,
bool retainObject =
false) :
5150 Image(imageArray, retainObject) { }
5183 size_type row_pitch = 0,
5184 void* host_ptr =
nullptr,
5185 cl_int* err =
nullptr)
5188 bool useCreateImage;
5190#if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
5193 cl_uint version = detail::getContextPlatformVersion(context());
5194 useCreateImage = (version >= 0x10002);
5196#elif CL_HPP_TARGET_OPENCL_VERSION >= 120
5197 useCreateImage =
true;
5199 useCreateImage =
false;
5202#if CL_HPP_TARGET_OPENCL_VERSION >= 120
5205 cl_image_desc desc = {};
5206 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
5207 desc.image_width = width;
5208 desc.image_height = height;
5209 desc.image_row_pitch = row_pitch;
5211 object_ = CL_(clCreateImage)(
5219 detail::errHandler(error, __CREATE_IMAGE_ERR);
5220 if (err !=
nullptr) {
5225#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
5226 if (!useCreateImage)
5228 object_ = CL_(clCreateImage2D)(
5229 context(), flags,&format, width, height, row_pitch, host_ptr, &error);
5231 detail::errHandler(error, __CREATE_IMAGE2D_ERR);
5232 if (err !=
nullptr) {
5239#if CL_HPP_TARGET_OPENCL_VERSION >= 120
5251 const Buffer &sourceBuffer,
5254 size_type row_pitch = 0,
5255 cl_int* err =
nullptr)
5259 cl_image_desc desc = {};
5260 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
5261 desc.image_width = width;
5262 desc.image_height = height;
5263 desc.image_row_pitch = row_pitch;
5264 desc.buffer = sourceBuffer();
5266 object_ = CL_(clCreateImage)(
5274 detail::errHandler(error, __CREATE_IMAGE_ERR);
5275 if (err !=
nullptr) {
5281#if CL_HPP_TARGET_OPENCL_VERSION >= 200
5296 cl_channel_order order,
5297 const Image &sourceImage,
5298 cl_int* err =
nullptr)
5303 size_type sourceWidth =
5305 size_type sourceHeight =
5307 size_type sourceRowPitch =
5309 cl_uint sourceNumMIPLevels =
5311 cl_uint sourceNumSamples =
5313 cl_image_format sourceFormat =
5318 sourceFormat.image_channel_order = order;
5320 cl_image_desc desc = {};
5321 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
5322 desc.image_width = sourceWidth;
5323 desc.image_height = sourceHeight;
5324 desc.image_row_pitch = sourceRowPitch;
5325 desc.num_mip_levels = sourceNumMIPLevels;
5326 desc.num_samples = sourceNumSamples;
5327 desc.buffer = sourceImage();
5329 object_ = CL_(clCreateImage)(
5337 detail::errHandler(error, __CREATE_IMAGE_ERR);
5338 if (err !=
nullptr) {
5344#if CL_HPP_TARGET_OPENCL_VERSION >= 300
5355 Image2D(
const Context &context,
const vector<cl_mem_properties> &properties,
5356 cl_mem_flags flags,
ImageFormat format, size_type width,
5357 size_type height, size_type row_pitch = 0,
void *host_ptr =
nullptr,
5358 cl_int *err =
nullptr) {
5361 cl_image_desc desc = {};
5362 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
5363 desc.image_width = width;
5364 desc.image_height = height;
5365 desc.image_row_pitch = row_pitch;
5367 if (properties.empty()) {
5368 object_ = CL_(clCreateImageWithProperties)(
5369 context(),
nullptr, flags, &format, &desc, host_ptr, &error);
5372 CL_(clCreateImageWithProperties)(context(), properties.data(), flags,
5373 &format, &desc, host_ptr, &error);
5376 detail::errHandler(error, __CREATE_IMAGE_ERR);
5377 if (err !=
nullptr) {
5391 Image2D(
const Context &context,
const vector<cl_mem_properties> &properties,
5393 size_type width, size_type height, size_type row_pitch = 0,
5394 cl_int *err =
nullptr) {
5397 cl_image_desc desc = {};
5398 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
5399 desc.image_width = width;
5400 desc.image_height = height;
5401 desc.image_row_pitch = row_pitch;
5402 desc.buffer = buffer();
5404 if (properties.empty()) {
5405 object_ = CL_(clCreateImageWithProperties)(
5406 context(),
nullptr, flags, &format, &desc,
nullptr, &error);
5409 CL_(clCreateImageWithProperties)(context(), properties.data(), flags,
5410 &format, &desc,
nullptr, &error);
5413 detail::errHandler(error, __CREATE_IMAGE_ERR);
5414 if (err !=
nullptr) {
5431 explicit Image2D(
const cl_mem& image2D,
bool retainObject =
false) :
5432 Image(image2D, retainObject) { }
5446#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
5470 cl_int * err =
nullptr)
5473 object_ = CL_(clCreateFromGLTexture2D)(
5481 detail::errHandler(error, __CREATE_GL_TEXTURE_2D_ERR);
5482 if (err !=
nullptr) {
5498 explicit Image2DGL(
const cl_mem& image,
bool retainObject =
false) :
5499 Image2D(image, retainObject) { }
5505 Image2DGL& operator = (
const cl_mem& rhs)
5513} CL_API_SUFFIX__VERSION_1_1_DEPRECATED;
5516#if CL_HPP_TARGET_OPENCL_VERSION >= 120
5520class Image2DArray :
public Image
5527 size_type arraySize,
5531 size_type slicePitch,
5532 void* host_ptr =
nullptr,
5533 cl_int* err =
nullptr)
5537 cl_image_desc desc = {};
5538 desc.image_type = CL_MEM_OBJECT_IMAGE2D_ARRAY;
5539 desc.image_width = width;
5540 desc.image_height = height;
5541 desc.image_array_size = arraySize;
5542 desc.image_row_pitch = rowPitch;
5543 desc.image_slice_pitch = slicePitch;
5545 object_ = CL_(clCreateImage)(
5553 detail::errHandler(error, __CREATE_IMAGE_ERR);
5554 if (err !=
nullptr) {
5559#if CL_HPP_TARGET_OPENCL_VERSION >= 300
5570 Image2DArray(
const Context &context,
5571 const vector<cl_mem_properties> &properties,
5572 cl_mem_flags flags,
ImageFormat format, size_type arraySize,
5573 size_type width, size_type height, size_type rowPitch = 0,
5574 size_type slicePitch = 0,
void *host_ptr =
nullptr,
5575 cl_int *err =
nullptr) {
5578 cl_image_desc desc = {};
5579 desc.image_type = CL_MEM_OBJECT_IMAGE2D_ARRAY;
5580 desc.image_width = width;
5581 desc.image_height = height;
5582 desc.image_array_size = arraySize;
5583 desc.image_row_pitch = rowPitch;
5584 desc.image_slice_pitch = slicePitch;
5586 if (properties.empty()) {
5587 object_ = CL_(clCreateImageWithProperties)(
5588 context(),
nullptr, flags, &format, &desc, host_ptr, &error);
5591 CL_(clCreateImageWithProperties)(context(), properties.data(), flags,
5592 &format, &desc, host_ptr, &error);
5595 detail::errHandler(error, __CREATE_IMAGE_ERR);
5596 if (err !=
nullptr) {
5611 explicit Image2DArray(
const cl_mem& imageArray,
bool retainObject =
false) :
Image(imageArray, retainObject) { }
5642 size_type row_pitch = 0,
5643 size_type slice_pitch = 0,
5644 void* host_ptr =
nullptr,
5645 cl_int* err =
nullptr)
5648 bool useCreateImage;
5650#if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
5653 cl_uint version = detail::getContextPlatformVersion(context());
5654 useCreateImage = (version >= 0x10002);
5656#elif CL_HPP_TARGET_OPENCL_VERSION >= 120
5657 useCreateImage =
true;
5659 useCreateImage =
false;
5662#if CL_HPP_TARGET_OPENCL_VERSION >= 120
5665 cl_image_desc desc = {};
5666 desc.image_type = CL_MEM_OBJECT_IMAGE3D;
5667 desc.image_width = width;
5668 desc.image_height = height;
5669 desc.image_depth = depth;
5670 desc.image_row_pitch = row_pitch;
5671 desc.image_slice_pitch = slice_pitch;
5673 object_ = CL_(clCreateImage)(
5681 detail::errHandler(error, __CREATE_IMAGE_ERR);
5682 if (err !=
nullptr) {
5687#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
5688 if (!useCreateImage)
5690 object_ = CL_(clCreateImage3D)(
5691 context(), flags, &format, width, height, depth, row_pitch,
5692 slice_pitch, host_ptr, &error);
5694 detail::errHandler(error, __CREATE_IMAGE3D_ERR);
5695 if (err !=
nullptr) {
5702#if CL_HPP_TARGET_OPENCL_VERSION >= 300
5713 Image3D(
const Context &context,
const vector<cl_mem_properties> &properties,
5714 cl_mem_flags flags,
ImageFormat format, size_type width,
5715 size_type height, size_type depth, size_type row_pitch = 0,
5716 size_type slice_pitch = 0,
void *host_ptr =
nullptr,
5717 cl_int *err =
nullptr) {
5720 cl_image_desc desc = {};
5721 desc.image_type = CL_MEM_OBJECT_IMAGE3D;
5722 desc.image_width = width;
5723 desc.image_height = height;
5724 desc.image_depth = depth;
5725 desc.image_row_pitch = row_pitch;
5726 desc.image_slice_pitch = slice_pitch;
5728 if (properties.empty()) {
5729 object_ = CL_(clCreateImageWithProperties)(
5730 context(),
nullptr, flags, &format, &desc, host_ptr, &error);
5733 CL_(clCreateImageWithProperties)(context(), properties.data(), flags,
5734 &format, &desc, host_ptr, &error);
5737 detail::errHandler(error, __CREATE_IMAGE_ERR);
5738 if (err !=
nullptr) {
5754 explicit Image3D(
const cl_mem& image3D,
bool retainObject =
false) :
5755 Image(image3D, retainObject) { }
5769#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
5792 cl_int * err =
nullptr)
5795 object_ = CL_(clCreateFromGLTexture3D)(
5803 detail::errHandler(error, __CREATE_GL_TEXTURE_3D_ERR);
5804 if (err !=
nullptr) {
5819 explicit Image3DGL(
const cl_mem& image,
bool retainObject =
false) :
5820 Image3D(image, retainObject) { }
5835#if CL_HPP_TARGET_OPENCL_VERSION >= 120
5842class ImageGL :
public Image
5851 cl_int * err =
nullptr)
5854 object_ = CL_(clCreateFromGLTexture)(
5862 detail::errHandler(error, __CREATE_GL_TEXTURE_ERR);
5863 if (err !=
nullptr) {
5868 ImageGL() :
Image() { }
5877 explicit ImageGL(
const cl_mem& image,
bool retainObject =
false) :
5878 Image(image, retainObject) { }
5880 ImageGL& operator = (
const cl_mem& rhs)
5891#if CL_HPP_TARGET_OPENCL_VERSION >= 200
5913 cl_uint packet_size,
5914 cl_uint max_packets,
5915 cl_int* err =
nullptr)
5919 cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS;
5920 object_ = CL_(clCreatePipe)(context(), flags, packet_size, max_packets,
nullptr, &error);
5922 detail::errHandler(error, __CREATE_PIPE_ERR);
5923 if (err !=
nullptr) {
5937 cl_uint packet_size,
5938 cl_uint max_packets,
5939 cl_int* err =
nullptr)
5945 cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS;
5946 object_ = CL_(clCreatePipe)(context(), flags, packet_size, max_packets,
nullptr, &error);
5948 detail::errHandler(error, __CREATE_PIPE_ERR);
5949 if (err !=
nullptr) {
5964 explicit Pipe(
const cl_mem& pipe,
bool retainObject =
false) :
5965 Memory(pipe, retainObject) { }
5980 template <
typename T>
5981 cl_int
getInfo(cl_pipe_info name, T* param)
const
5983 return detail::errHandler(
5984 detail::getInfo(CL_(clGetPipeInfo), object_, name, param),
5985 __GET_PIPE_INFO_ERR);
5989 template <cl_pipe_info name>
typename
5991 getInfo(cl_int* err =
nullptr)
const
5994 detail::cl_pipe_info, name>::param_type param;
5995 cl_int result =
getInfo(name, ¶m);
5996 if (err !=
nullptr) {
6025 cl_bool normalized_coords,
6026 cl_addressing_mode addressing_mode,
6027 cl_filter_mode filter_mode,
6028 cl_int* err =
nullptr)
6032#if CL_HPP_TARGET_OPENCL_VERSION >= 200
6033 cl_sampler_properties sampler_properties[] = {
6034 CL_SAMPLER_NORMALIZED_COORDS, normalized_coords,
6035 CL_SAMPLER_ADDRESSING_MODE, addressing_mode,
6036 CL_SAMPLER_FILTER_MODE, filter_mode,
6038 object_ = CL_(clCreateSamplerWithProperties)(
6043 detail::errHandler(error, __CREATE_SAMPLER_WITH_PROPERTIES_ERR);
6044 if (err !=
nullptr) {
6048 object_ = CL_(clCreateSampler)(
6055 detail::errHandler(error, __CREATE_SAMPLER_ERR);
6056 if (err !=
nullptr) {
6070 explicit Sampler(
const cl_sampler& sampler,
bool retainObject =
false) :
6071 detail::Wrapper<cl_type>(sampler, retainObject) { }
6080 detail::Wrapper<cl_type>::operator=(rhs);
6087 template <
typename T>
6088 cl_int
getInfo(cl_sampler_info name, T* param)
const
6090 return detail::errHandler(
6091 detail::getInfo(CL_(clGetSamplerInfo), object_, name, param),
6092 __GET_SAMPLER_INFO_ERR);
6096 template <cl_sampler_info name>
typename
6098 getInfo(cl_int* err =
nullptr)
const
6101 detail::cl_sampler_info, name>::param_type param;
6102 cl_int result =
getInfo(name, ¶m);
6103 if (err !=
nullptr) {
6119 size_type sizes_[3];
6120 cl_uint dimensions_;
6142 NDRange(size_type size0, size_type size1)
6151 NDRange(size_type size0, size_type size1, size_type size2)
6172 operator const size_type*()
const {
6184 size_type
size()
const
6186 return dimensions_*
sizeof(size_type);
6194 const size_type* get()
const
6201static const NDRange NullRange;
6211template <
typename T,
class Enable =
void>
6216template <
typename T>
6217struct KernelArgumentHandler<T, typename std::enable_if<!std::is_base_of<cl::Memory, T>::value>::type>
6219 static size_type size(
const T&) {
return sizeof(T); }
6220 static const T* ptr(
const T& value) {
return &value; }
6225template <
typename T>
6226struct KernelArgumentHandler<T, typename std::enable_if<std::is_base_of<cl::Memory, T>::value>::type>
6228 static size_type size(
const T&) {
return sizeof(cl_mem); }
6229 static const cl_mem* ptr(
const T& value) {
return &(value()); }
6237 static size_type size(
const LocalSpaceArg& value) {
return value.size_; }
6238 static const void* ptr(
const LocalSpaceArg&) {
return nullptr; }
6248Local(size_type size)
6265 inline Kernel(
const Program& program,
const string& name, cl_int* err =
nullptr);
6266 inline Kernel(
const Program& program,
const char* name, cl_int* err =
nullptr);
6279 explicit Kernel(
const cl_kernel& kernel,
bool retainObject =
false) :
6280 detail::Wrapper<cl_type>(kernel, retainObject) { }
6289 detail::Wrapper<cl_type>::operator=(rhs);
6296 template <
typename T>
6297 cl_int getInfo(cl_kernel_info name, T* param)
const
6299 return detail::errHandler(
6300 detail::getInfo(CL_(clGetKernelInfo), object_, name, param),
6301 __GET_KERNEL_INFO_ERR);
6304 template <cl_kernel_info name>
typename
6305 detail::param_traits<detail::cl_kernel_info, name>::param_type
6306 getInfo(cl_int* err =
nullptr)
const
6308 typename detail::param_traits<
6309 detail::cl_kernel_info, name>::param_type param;
6310 cl_int result = getInfo(name, ¶m);
6311 if (err !=
nullptr) {
6317#if CL_HPP_TARGET_OPENCL_VERSION >= 120
6318 template <
typename T>
6319 cl_int getArgInfo(cl_uint argIndex, cl_kernel_arg_info name, T* param)
const
6321 return detail::errHandler(
6322 detail::getInfo(CL_(clGetKernelArgInfo), object_, argIndex, name, param),
6323 __GET_KERNEL_ARG_INFO_ERR);
6326 template <cl_kernel_arg_info name>
typename
6327 detail::param_traits<detail::cl_kernel_arg_info, name>::param_type
6328 getArgInfo(cl_uint argIndex, cl_int* err =
nullptr)
const
6330 typename detail::param_traits<
6331 detail::cl_kernel_arg_info, name>::param_type param;
6332 cl_int result = getArgInfo(argIndex, name, ¶m);
6333 if (err !=
nullptr) {
6340 template <
typename T>
6341 cl_int getWorkGroupInfo(
6342 const Device& device, cl_kernel_work_group_info name, T* param)
const
6344 return detail::errHandler(
6346 CL_(clGetKernelWorkGroupInfo), object_, device(), name, param),
6347 __GET_KERNEL_WORK_GROUP_INFO_ERR);
6350 template <cl_kernel_work_group_info name>
typename
6351 detail::param_traits<detail::cl_kernel_work_group_info, name>::param_type
6352 getWorkGroupInfo(
const Device& device, cl_int* err =
nullptr)
const
6354 typename detail::param_traits<
6355 detail::cl_kernel_work_group_info, name>::param_type param;
6356 cl_int result = getWorkGroupInfo(device, name, ¶m);
6357 if (err !=
nullptr) {
6363#if defined(CL_HPP_USE_CL_SUB_GROUPS_KHR) || CL_HPP_TARGET_OPENCL_VERSION >= 210
6364 cl_int getSubGroupInfo(
const cl::Device &dev, cl_kernel_sub_group_info name,
const cl::NDRange &range, size_type* param)
const
6366#if CL_HPP_TARGET_OPENCL_VERSION >= 210
6368 return detail::errHandler(
6369 CL_(clGetKernelSubGroupInfo)(object_, dev(), name, range.
size(), range.get(),
sizeof(size_type), param,
nullptr),
6370 __GET_KERNEL_SUB_GROUP_INFO_ERR);
6374 typedef clGetKernelSubGroupInfoKHR_fn PFN_clGetKernelSubGroupInfoKHR;
6375 static PFN_clGetKernelSubGroupInfoKHR pfn_clGetKernelSubGroupInfoKHR =
nullptr;
6376 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetKernelSubGroupInfoKHR);
6378 return detail::errHandler(
6379 pfn_clGetKernelSubGroupInfoKHR(object_, dev(), name, range.
size(), range.get(),
sizeof(size_type), param,
nullptr),
6380 __GET_KERNEL_SUB_GROUP_INFO_ERR);
6385 template <cl_kernel_sub_group_info name>
6386 size_type getSubGroupInfo(
const cl::Device &dev,
const cl::NDRange &range, cl_int* err =
nullptr)
const
6389 cl_int result = getSubGroupInfo(dev, name, range, ¶m);
6390 if (err !=
nullptr) {
6397#if CL_HPP_TARGET_OPENCL_VERSION >= 200
6400 template<
typename T,
class D>
6401 cl_int
setArg(cl_uint index,
const cl::pointer<T, D> &argPtr)
6403 return detail::errHandler(
6404 CL_(clSetKernelArgSVMPointer)(object_, index, argPtr.get()),
6405 __SET_KERNEL_ARGS_ERR);
6410 template<
typename T,
class Alloc>
6411 cl_int
setArg(cl_uint index,
const cl::vector<T, Alloc> &argPtr)
6413 return detail::errHandler(
6414 CL_(clSetKernelArgSVMPointer)(object_, index, argPtr.data()),
6415 __SET_KERNEL_ARGS_ERR);
6420 template<
typename T>
6421 typename std::enable_if<std::is_pointer<T>::value, cl_int>::type
6422 setArg(cl_uint index,
const T argPtr)
6424 return detail::errHandler(
6425 CL_(clSetKernelArgSVMPointer)(object_, index, argPtr),
6426 __SET_KERNEL_ARGS_ERR);
6432 template <
typename T>
6433 typename std::enable_if<!std::is_pointer<T>::value, cl_int>::type
6434 setArg(cl_uint index,
const T &value)
6436 return detail::errHandler(
6437 CL_(clSetKernelArg)(
6442 __SET_KERNEL_ARGS_ERR);
6445 cl_int
setArg(cl_uint index, size_type size,
const void* argPtr)
6447 return detail::errHandler(
6448 CL_(clSetKernelArg)(object_, index, size, argPtr),
6449 __SET_KERNEL_ARGS_ERR);
6452#if CL_HPP_TARGET_OPENCL_VERSION >= 200
6459 return detail::errHandler(
6460 CL_(clSetKernelExecInfo)(
6462 CL_KERNEL_EXEC_INFO_SVM_PTRS,
6463 sizeof(
void*)*pointerList.size(),
6464 pointerList.data()));
6471 template<
int ArrayLength>
6472 cl_int
setSVMPointers(
const std::array<void*, ArrayLength> &pointerList)
6474 return detail::errHandler(
6475 CL_(clSetKernelExecInfo)(
6477 CL_KERNEL_EXEC_INFO_SVM_PTRS,
6478 sizeof(
void*)*pointerList.size(),
6479 pointerList.data()));
6495 cl_bool svmEnabled_ = svmEnabled ? CL_TRUE : CL_FALSE;
6496 return detail::errHandler(
6497 CL_(clSetKernelExecInfo)(
6499 CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM,
6506 template<
int index,
int ArrayLength,
class D,
typename T0,
typename T1,
typename... Ts>
6507 void setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList,
const pointer<T0, D> &t0,
const pointer<T1, D> &t1, Ts & ... ts)
6509 pointerList[index] =
static_cast<void*
>(t0.get());
6510 setSVMPointersHelper<index + 1, ArrayLength>(pointerList, t1, ts...);
6513 template<
int index,
int ArrayLength,
typename T0,
typename T1,
typename... Ts>
6514 typename std::enable_if<std::is_pointer<T0>::value,
void>::type
6515 setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList, T0 t0, T1 t1, Ts... ts)
6517 pointerList[index] =
static_cast<void*
>(t0);
6518 setSVMPointersHelper<index + 1, ArrayLength>(pointerList, t1, ts...);
6521 template<
int index,
int ArrayLength,
typename T0,
class D>
6522 void setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList,
const pointer<T0, D> &t0)
6524 pointerList[index] =
static_cast<void*
>(t0.get());
6528 template<
int index,
int ArrayLength,
typename T0>
6529 typename std::enable_if<std::is_pointer<T0>::value,
void>::type
6530 setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList, T0 t0)
6532 pointerList[index] =
static_cast<void*
>(t0);
6535 template<
typename T0,
typename... Ts>
6538 std::array<
void*, 1 +
sizeof...(Ts)> pointerList;
6540 setSVMPointersHelper<0, 1 +
sizeof...(Ts)>(pointerList, t0, ts...);
6541 return detail::errHandler(
6542 CL_(clSetKernelExecInfo)(
6544 CL_KERNEL_EXEC_INFO_SVM_PTRS,
6545 sizeof(
void*)*(1 +
sizeof...(Ts)),
6546 pointerList.data()));
6549 template<
typename T>
6550 cl_int setExecInfo(cl_kernel_exec_info param_name,
const T& val)
6552 return detail::errHandler(
6553 CL_(clSetKernelExecInfo)(
6560 template<cl_kernel_exec_info name>
6561 cl_int setExecInfo(
typename detail::param_traits<detail::cl_kernel_exec_info, name>::param_type& val)
6563 return setExecInfo(name, val);
6567#if CL_HPP_TARGET_OPENCL_VERSION >= 210
6576 Kernel retValue(CL_(clCloneKernel)(this->get(), &error));
6578 detail::errHandler(error, __CLONE_KERNEL_ERR);
6590#if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6591 typedef vector<vector<unsigned char>> Binaries;
6592 typedef vector<string> Sources;
6594 typedef vector<std::pair<const void*, size_type> > Binaries;
6595 typedef vector<std::pair<const char*, size_type> > Sources;
6599 const string& source,
6601 cl_int* err =
nullptr)
6605 const char * strings = source.c_str();
6606 const size_type length = source.size();
6610 object_ = CL_(clCreateProgramWithSource)(
6611 context(), (cl_uint)1, &strings, &length, &error);
6613 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6615 if (error == CL_SUCCESS && build) {
6617 error = CL_(clBuildProgram)(
6621#if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6629 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6632 if (err !=
nullptr) {
6639 const string& source,
6641 cl_int* err =
nullptr)
6645 const char * strings = source.c_str();
6646 const size_type length = source.size();
6648 object_ = CL_(clCreateProgramWithSource)(
6649 context(), (cl_uint)1, &strings, &length, &error);
6651 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6653 if (error == CL_SUCCESS && build) {
6654 error = CL_(clBuildProgram)(
6658#if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6666 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6669 if (err !=
nullptr) {
6679 const Sources& sources,
6680 cl_int* err =
nullptr)
6685 const size_type n = (size_type)sources.size();
6687 vector<size_type> lengths(n);
6688 vector<const char*> strings(n);
6690 for (size_type i = 0; i < n; ++i) {
6691#if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6692 strings[i] = sources[(int)i].data();
6693 lengths[i] = sources[(int)i].length();
6695 strings[i] = sources[(int)i].first;
6696 lengths[i] = sources[(int)i].second;
6700 object_ = CL_(clCreateProgramWithSource)(
6701 context(), (cl_uint)n, strings.data(), lengths.data(), &error);
6703 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6704 if (err !=
nullptr) {
6715 const Sources& sources,
6716 cl_int* err =
nullptr)
6720 const size_type n = (size_type)sources.size();
6722 vector<size_type> lengths(n);
6723 vector<const char*> strings(n);
6725 for (size_type i = 0; i < n; ++i) {
6726#if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6727 strings[i] = sources[(int)i].data();
6728 lengths[i] = sources[(int)i].length();
6730 strings[i] = sources[(int)i].first;
6731 lengths[i] = sources[(int)i].second;
6735 object_ = CL_(clCreateProgramWithSource)(
6736 context(), (cl_uint)n, strings.data(), lengths.data(), &error);
6738 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6739 if (err !=
nullptr) {
6744#if defined(CL_HPP_USE_IL_KHR) || CL_HPP_TARGET_OPENCL_VERSION >= 210
6751 const vector<char>& IL,
6753 cl_int* err =
nullptr)
6759#if CL_HPP_TARGET_OPENCL_VERSION >= 210
6761 object_ = CL_(clCreateProgramWithIL)(
6762 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6766 typedef clCreateProgramWithILKHR_fn PFN_clCreateProgramWithILKHR;
6767 static PFN_clCreateProgramWithILKHR pfn_clCreateProgramWithILKHR =
nullptr;
6768 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateProgramWithILKHR);
6770 object_ = pfn_clCreateProgramWithILKHR(
6771 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6775 detail::errHandler(error, __CREATE_PROGRAM_WITH_IL_ERR);
6777 if (error == CL_SUCCESS && build) {
6779 error = CL_(clBuildProgram)(
6783#if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6791 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6794 if (err !=
nullptr) {
6807 const vector<char>& IL,
6809 cl_int* err =
nullptr)
6813#if CL_HPP_TARGET_OPENCL_VERSION >= 210
6815 object_ = CL_(clCreateProgramWithIL)(
6816 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6820 typedef clCreateProgramWithILKHR_fn PFN_clCreateProgramWithILKHR;
6821 static PFN_clCreateProgramWithILKHR pfn_clCreateProgramWithILKHR =
nullptr;
6822 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateProgramWithILKHR);
6824 object_ = pfn_clCreateProgramWithILKHR(
6825 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6829 detail::errHandler(error, __CREATE_PROGRAM_WITH_IL_ERR);
6831 if (error == CL_SUCCESS && build) {
6832 error = CL_(clBuildProgram)(
6836#if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6844 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6847 if (err !=
nullptr) {
6874 const vector<Device>& devices,
6875 const Binaries& binaries,
6876 vector<cl_int>* binaryStatus =
nullptr,
6877 cl_int* err =
nullptr)
6881 const size_type numDevices = devices.size();
6884 if(binaries.size() != numDevices) {
6885 error = CL_INVALID_VALUE;
6886 detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
6887 if (err !=
nullptr) {
6893 vector<size_type> lengths(numDevices);
6894 vector<const unsigned char*> images(numDevices);
6895#if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6896 for (size_type i = 0; i < numDevices; ++i) {
6897 images[i] = binaries[i].data();
6898 lengths[i] = binaries[(int)i].size();
6901 for (size_type i = 0; i < numDevices; ++i) {
6902 images[i] = (
const unsigned char*)binaries[i].first;
6903 lengths[i] = binaries[(int)i].second;
6907 vector<cl_device_id> deviceIDs(numDevices);
6908 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6909 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6913 binaryStatus->resize(numDevices);
6916 object_ = CL_(clCreateProgramWithBinary)(
6917 context(), (cl_uint) devices.size(),
6919 lengths.data(), images.data(), (binaryStatus !=
nullptr && numDevices > 0)
6920 ? &binaryStatus->front()
6923 detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
6924 if (err !=
nullptr) {
6930#if CL_HPP_TARGET_OPENCL_VERSION >= 120
6937 const vector<Device>& devices,
6938 const string& kernelNames,
6939 cl_int* err =
nullptr)
6944 size_type numDevices = devices.size();
6945 vector<cl_device_id> deviceIDs(numDevices);
6946 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6947 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6950 object_ = CL_(clCreateProgramWithBuiltInKernels)(
6952 (cl_uint) devices.size(),
6954 kernelNames.c_str(),
6957 detail::errHandler(error, __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR);
6958 if (err !=
nullptr) {
6973 explicit Program(
const cl_program& program,
bool retainObject =
false) :
6974 detail::Wrapper<cl_type>(program, retainObject) { }
6976 Program& operator = (
const cl_program& rhs)
6978 detail::Wrapper<cl_type>::operator=(rhs);
6983 const vector<Device>& devices,
6984 const string& options,
6985 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
6986 void* data =
nullptr)
const
6988 return build(devices, options.c_str(), notifyFptr, data);
6992 const vector<Device>& devices,
6993 const char* options =
nullptr,
6994 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
6995 void* data =
nullptr)
const
6997 size_type numDevices = devices.size();
6998 vector<cl_device_id> deviceIDs(numDevices);
7000 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
7001 deviceIDs[deviceIndex] = (devices[deviceIndex])();
7004 cl_int buildError = CL_(clBuildProgram)(
7013 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
7017 const Device& device,
7018 const string& options,
7019 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7020 void* data =
nullptr)
const
7022 return build(device, options.c_str(), notifyFptr, data);
7026 const Device& device,
7027 const char* options =
nullptr,
7028 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7029 void* data =
nullptr)
const
7031 cl_device_id deviceID = device();
7033 cl_int buildError = CL_(clBuildProgram)(
7041 BuildLogType buildLog(0);
7042 buildLog.push_back(std::make_pair(device, getBuildInfo<CL_PROGRAM_BUILD_LOG>(device)));
7043 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, buildLog);
7047 const string& options,
7048 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7049 void* data =
nullptr)
const
7051 return build(options.c_str(), notifyFptr, data);
7055 const char* options =
nullptr,
7056 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7057 void* data =
nullptr)
const
7059 cl_int buildError = CL_(clBuildProgram)(
7067 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
7070#if CL_HPP_TARGET_OPENCL_VERSION >= 120
7072 const string& options,
7073 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7074 void* data =
nullptr)
const
7076 return compile(options.c_str(), notifyFptr, data);
7080 const char* options =
nullptr,
7081 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7082 void* data =
nullptr)
const
7084 cl_int error = CL_(clCompileProgram)(
7094 return detail::buildErrHandler(error, __COMPILE_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
7098 const string& options,
7099 const vector<Program>& inputHeaders,
7100 const vector<string>& headerIncludeNames,
7101 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7102 void* data =
nullptr)
const
7104 return compile(options.c_str(), inputHeaders, headerIncludeNames, notifyFptr, data);
7108 const char* options,
7109 const vector<Program>& inputHeaders,
7110 const vector<string>& headerIncludeNames,
7111 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7112 void* data =
nullptr)
const
7114 static_assert(
sizeof(cl::Program) ==
sizeof(cl_program),
7115 "Size of cl::Program must be equal to size of cl_program");
7116 vector<const char*> headerIncludeNamesCStr;
7117 for(
const string& name: headerIncludeNames) {
7118 headerIncludeNamesCStr.push_back(name.c_str());
7120 cl_int error = CL_(clCompileProgram)(
7125 static_cast<cl_uint
>(inputHeaders.size()),
7126 reinterpret_cast<const cl_program*
>(inputHeaders.data()),
7127 reinterpret_cast<const char**
>(headerIncludeNamesCStr.data()),
7130 return detail::buildErrHandler(error, __COMPILE_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
7134 const string& options,
7135 const vector<Device>& deviceList,
7136 const vector<Program>& inputHeaders = vector<Program>(),
7137 const vector<string>& headerIncludeNames = vector<string>(),
7138 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7139 void* data =
nullptr)
const
7141 return compile(options.c_str(), deviceList, inputHeaders, headerIncludeNames, notifyFptr, data);
7145 const char* options,
7146 const vector<Device>& deviceList,
7147 const vector<Program>& inputHeaders = vector<Program>(),
7148 const vector<string>& headerIncludeNames = vector<string>(),
7149 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7150 void* data =
nullptr)
const
7152 static_assert(
sizeof(cl::Program) ==
sizeof(cl_program),
7153 "Size of cl::Program must be equal to size of cl_program");
7154 vector<const char*> headerIncludeNamesCStr;
7155 for(
const string& name: headerIncludeNames) {
7156 headerIncludeNamesCStr.push_back(name.c_str());
7158 vector<cl_device_id> deviceIDList;
7159 for(
const Device& device: deviceList) {
7160 deviceIDList.push_back(device());
7162 cl_int error = CL_(clCompileProgram)(
7164 static_cast<cl_uint
>(deviceList.size()),
7165 reinterpret_cast<const cl_device_id*
>(deviceIDList.data()),
7167 static_cast<cl_uint
>(inputHeaders.size()),
7168 reinterpret_cast<const cl_program*
>(inputHeaders.data()),
7169 reinterpret_cast<const char**
>(headerIncludeNamesCStr.data()),
7172 return detail::buildErrHandler(error, __COMPILE_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
7176 template <
typename T>
7177 cl_int getInfo(cl_program_info name, T* param)
const
7179 return detail::errHandler(
7180 detail::getInfo(CL_(clGetProgramInfo), object_, name, param),
7181 __GET_PROGRAM_INFO_ERR);
7184 template <cl_program_info name>
typename
7185 detail::param_traits<detail::cl_program_info, name>::param_type
7186 getInfo(cl_int* err =
nullptr)
const
7188 typename detail::param_traits<
7189 detail::cl_program_info, name>::param_type param;
7190 cl_int result = getInfo(name, ¶m);
7191 if (err !=
nullptr) {
7197 template <
typename T>
7198 cl_int getBuildInfo(
7199 const Device& device, cl_program_build_info name, T* param)
const
7201 return detail::errHandler(
7203 CL_(clGetProgramBuildInfo), object_, device(), name, param),
7204 __GET_PROGRAM_BUILD_INFO_ERR);
7207 template <cl_program_build_info name>
typename
7208 detail::param_traits<detail::cl_program_build_info, name>::param_type
7209 getBuildInfo(
const Device& device, cl_int* err =
nullptr)
const
7211 typename detail::param_traits<
7212 detail::cl_program_build_info, name>::param_type param;
7213 cl_int result = getBuildInfo(device, name, ¶m);
7214 if (err !=
nullptr) {
7225 template <cl_program_build_info name>
7226 vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, name>::param_type>>
7227 getBuildInfo(cl_int *err =
nullptr)
const
7229 cl_int result = CL_SUCCESS;
7231 auto devs = getInfo<CL_PROGRAM_DEVICES>(&result);
7232 vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, name>::param_type>>
7236 if (result != CL_SUCCESS) {
7237 if (err !=
nullptr) {
7245 detail::cl_program_build_info, name>::param_type param;
7246 result = getBuildInfo(d, name, ¶m);
7250 if (result != CL_SUCCESS) {
7255 if (err !=
nullptr) {
7258 if (result != CL_SUCCESS) {
7264 cl_int createKernels(vector<Kernel>* kernels)
7267 cl_int err = CL_(clCreateKernelsInProgram)(object_, 0,
nullptr, &numKernels);
7268 if (err != CL_SUCCESS) {
7269 return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
7272 vector<cl_kernel> value(numKernels);
7274 err = CL_(clCreateKernelsInProgram)(
7275 object_, numKernels, value.data(),
nullptr);
7276 if (err != CL_SUCCESS) {
7277 return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
7281 kernels->resize(value.size());
7285 for (size_type i = 0; i < value.size(); i++) {
7288 (*kernels)[i] = Kernel(value[i],
false);
7294#if CL_HPP_TARGET_OPENCL_VERSION >= 220
7295#if defined(CL_USE_DEPRECATED_OPENCL_2_2_APIS)
7307 void (CL_CALLBACK * pfn_notify)(cl_program program,
void * user_data),
7308 void * user_data =
nullptr) CL_API_SUFFIX__VERSION_2_2_DEPRECATED
7310 return detail::errHandler(
7311 CL_(clSetProgramReleaseCallback)(
7315 __SET_PROGRAM_RELEASE_CALLBACK_ERR);
7323 template <
typename T>
7324 typename std::enable_if<!std::is_pointer<T>::value, cl_int>::type
7327 return detail::errHandler(
7328 CL_(clSetProgramSpecializationConstant)(
7333 __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR);
7342 return detail::errHandler(
7343 CL_(clSetProgramSpecializationConstant)(
7348 __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR);
7353#if CL_HPP_TARGET_OPENCL_VERSION >= 120
7354inline Program linkProgram(
7355 const Program& input1,
7356 const Program& input2,
7357 const char* options =
nullptr,
7358 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7359 void* data =
nullptr,
7360 cl_int* err =
nullptr)
7362 cl_int error_local = CL_SUCCESS;
7363 cl_program programs[2] = { input1(), input2() };
7366 if(error_local!=CL_SUCCESS) {
7367 detail::errHandler(error_local, __LINK_PROGRAM_ERR);
7370 cl_program prog = CL_(clLinkProgram)(
7381 detail::errHandler(error_local,__COMPILE_PROGRAM_ERR);
7382 if (err !=
nullptr) {
7392 const string& options,
7393 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7394 void* data =
nullptr,
7395 cl_int* err =
nullptr)
7397 return linkProgram(input1, input2, options.c_str(), notifyFptr, data, err);
7401 const vector<Program>& inputPrograms,
7402 const char* options =
nullptr,
7403 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7404 void* data =
nullptr,
7405 cl_int* err =
nullptr)
7407 cl_int error_local = CL_SUCCESS;
7410 static_assert(
sizeof(cl::Program) ==
sizeof(cl_program),
7411 "Size of cl::Program must be equal to size of cl_program");
7413 if(inputPrograms.size() > 0) {
7414 ctx = inputPrograms[0].getInfo<CL_PROGRAM_CONTEXT>(&error_local);
7415 if(error_local!=CL_SUCCESS) {
7416 detail::errHandler(error_local, __LINK_PROGRAM_ERR);
7420 cl_program prog = CL_(clLinkProgram)(
7425 static_cast<cl_uint
>(inputPrograms.size()),
7426 reinterpret_cast<const cl_program *
>(inputPrograms.data()),
7431 detail::errHandler(error_local,__COMPILE_PROGRAM_ERR);
7432 if (err !=
nullptr) {
7440 const vector<Program>& inputPrograms,
7441 const string& options,
7442 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7443 void* data =
nullptr,
7444 cl_int* err =
nullptr)
7446 return linkProgram(inputPrograms, options.c_str(), notifyFptr, data, err);
7452inline cl_int cl::Program::getInfo(cl_program_info name, vector<vector<unsigned char>>* param)
const
7454 if (name != CL_PROGRAM_BINARIES) {
7455 return CL_INVALID_VALUE;
7461 vector<size_type> sizes = getInfo<CL_PROGRAM_BINARY_SIZES>();
7462 size_type numBinaries = sizes.size();
7465 param->resize(numBinaries);
7466 for (size_type i = 0; i < numBinaries; ++i) {
7467 (*param)[i].resize(sizes[i]);
7470 return detail::errHandler(
7471 detail::getInfo(CL_(clGetProgramInfo), object_, name, param),
7472 __GET_PROGRAM_INFO_ERR);
7479inline vector<vector<unsigned char>> cl::Program::getInfo<CL_PROGRAM_BINARIES>(cl_int* err)
const
7481 vector<vector<unsigned char>> binariesVectors;
7483 cl_int result = getInfo(CL_PROGRAM_BINARIES, &binariesVectors);
7484 if (err !=
nullptr) {
7487 return binariesVectors;
7490#if CL_HPP_TARGET_OPENCL_VERSION >= 220
7495 cl_uchar ucValue = value ? CL_UCHAR_MAX : 0;
7496 return detail::errHandler(
7497 CL_(clSetProgramSpecializationConstant)(
7502 __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR);
7510 object_ = CL_(clCreateKernel)(program(), name.c_str(), &error);
7511 detail::errHandler(error, __CREATE_KERNEL_ERR);
7513 if (err !=
nullptr) {
7522 object_ = CL_(clCreateKernel)(program(), name, &error);
7523 detail::errHandler(error, __CREATE_KERNEL_ERR);
7525 if (err !=
nullptr) {
7530#ifdef cl_khr_external_memory
7531enum class ExternalMemoryType : cl_external_memory_handle_type_khr
7534#ifdef cl_khr_external_memory_opaque_fd
7535 OpaqueFd = CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_FD_KHR,
7537#ifdef cl_khr_external_memory_win32
7538 OpaqueWin32 = CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KHR,
7539 OpaqueWin32Kmt = CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KMT_KHR,
7541#ifdef cl_khr_external_memory_dma_buf
7542 DmaBuf = CL_EXTERNAL_MEMORY_HANDLE_DMA_BUF_KHR,
7547enum class QueueProperties : cl_command_queue_properties
7550 Profiling = CL_QUEUE_PROFILING_ENABLE,
7551 OutOfOrder = CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE,
7554inline QueueProperties operator|(QueueProperties lhs, QueueProperties rhs)
7556 return static_cast<QueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) |
static_cast<cl_command_queue_properties
>(rhs));
7559inline QueueProperties operator&(QueueProperties lhs, QueueProperties rhs)
7561 return static_cast<QueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) &
static_cast<cl_command_queue_properties
>(rhs));
7570 static std::once_flag default_initialized_;
7572 static cl_int default_error_;
7579 static void makeDefault()
7584#if defined(CL_HPP_ENABLE_EXCEPTIONS)
7591 if (error != CL_SUCCESS) {
7592 default_error_ = error;
7596 default_ =
CommandQueue(context, device, 0, &default_error_);
7599#if defined(CL_HPP_ENABLE_EXCEPTIONS)
7600 catch (cl::Error &e) {
7601 default_error_ = e.err();
7611 static void makeDefaultProvided(
const CommandQueue &c) {
7615#ifdef cl_khr_external_memory
7616 static std::once_flag ext_memory_initialized_;
7618 static void initMemoryExtension(
const cl::Device& device)
7620 auto platform = device.
getInfo<CL_DEVICE_PLATFORM>()();
7622 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueAcquireExternalMemObjectsKHR);
7623 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueReleaseExternalMemObjectsKHR);
7625 if ((pfn_clEnqueueAcquireExternalMemObjectsKHR ==
nullptr)
7626 && (pfn_clEnqueueReleaseExternalMemObjectsKHR ==
nullptr))
7628 detail::errHandler(CL_INVALID_VALUE, __ENQUEUE_ACQUIRE_EXTERNAL_MEMORY_ERR);
7634#ifdef CL_HPP_UNIT_TEST_ENABLE
7641 static void unitTestClearDefault() {
7652 cl_command_queue_properties properties,
7653 cl_int* err =
nullptr)
7658 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7660 if (error != CL_SUCCESS) {
7661 if (err !=
nullptr) {
7667 bool useWithProperties;
7669#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7672 cl_uint version = detail::getContextPlatformVersion(context());
7673 useWithProperties = (version >= 0x20000);
7675#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7676 useWithProperties =
true;
7678 useWithProperties =
false;
7681#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7682 if (useWithProperties) {
7683 cl_queue_properties queue_properties[] = {
7684 CL_QUEUE_PROPERTIES, properties, 0 };
7685 if ((properties & CL_QUEUE_ON_DEVICE) == 0) {
7686 object_ = CL_(clCreateCommandQueueWithProperties)(
7687 context(), device(), queue_properties, &error);
7690 error = CL_INVALID_QUEUE_PROPERTIES;
7693 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7694 if (err !=
nullptr) {
7699#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7700 if (!useWithProperties) {
7701 object_ = CL_(clCreateCommandQueue)(
7702 context(), device(), properties, &error);
7704 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7705 if (err !=
nullptr) {
7718 QueueProperties properties,
7719 cl_int* err =
nullptr)
7724 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7726 if (error != CL_SUCCESS) {
7727 if (err !=
nullptr) {
7733 bool useWithProperties;
7735#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7738 cl_uint version = detail::getContextPlatformVersion(context());
7739 useWithProperties = (version >= 0x20000);
7741#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7742 useWithProperties =
true;
7744 useWithProperties =
false;
7747#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7748 if (useWithProperties) {
7749 cl_queue_properties queue_properties[] = {
7750 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
7752 object_ = CL_(clCreateCommandQueueWithProperties)(
7753 context(), device(), queue_properties, &error);
7755 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7756 if (err !=
nullptr) {
7761#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7762 if (!useWithProperties) {
7763 object_ = CL_(clCreateCommandQueue)(
7764 context(), device(),
static_cast<cl_command_queue_properties
>(properties), &error);
7766 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7767 if (err !=
nullptr) {
7782 cl_command_queue_properties properties = 0,
7783 cl_int* err =
nullptr)
7786 bool useWithProperties;
7787 vector<cl::Device> devices;
7788 error = context.
getInfo(CL_CONTEXT_DEVICES, &devices);
7790 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7792 if (error != CL_SUCCESS)
7794 if (err !=
nullptr) {
7800#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7803 cl_uint version = detail::getContextPlatformVersion(context());
7804 useWithProperties = (version >= 0x20000);
7806#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7807 useWithProperties =
true;
7809 useWithProperties =
false;
7812#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7813 if (useWithProperties) {
7814 cl_queue_properties queue_properties[] = {
7815 CL_QUEUE_PROPERTIES, properties, 0 };
7816 if ((properties & CL_QUEUE_ON_DEVICE) == 0) {
7817 object_ = CL_(clCreateCommandQueueWithProperties)(
7818 context(), devices[0](), queue_properties, &error);
7821 error = CL_INVALID_QUEUE_PROPERTIES;
7824 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7825 if (err !=
nullptr) {
7830#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7831 if (!useWithProperties) {
7832 object_ = CL_(clCreateCommandQueue)(
7833 context(), devices[0](), properties, &error);
7835 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7836 if (err !=
nullptr) {
7849 QueueProperties properties,
7850 cl_int* err =
nullptr)
7853 bool useWithProperties;
7854 vector<cl::Device> devices;
7855 error = context.
getInfo(CL_CONTEXT_DEVICES, &devices);
7857 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7859 if (error != CL_SUCCESS)
7861 if (err !=
nullptr) {
7867#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7870 cl_uint version = detail::getContextPlatformVersion(context());
7871 useWithProperties = (version >= 0x20000);
7873#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7874 useWithProperties =
true;
7876 useWithProperties =
false;
7879#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7880 if (useWithProperties) {
7881 cl_queue_properties queue_properties[] = {
7882 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
7883 object_ = CL_(clCreateCommandQueueWithProperties)(
7884 context(), devices[0](), queue_properties, &error);
7886 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7887 if (err !=
nullptr) {
7892#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7893 if (!useWithProperties) {
7894 object_ = CL_(clCreateCommandQueue)(
7895 context(), devices[0](),
static_cast<cl_command_queue_properties
>(properties), &error);
7897 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7898 if (err !=
nullptr) {
7912 cl_command_queue_properties properties = 0,
7913 cl_int* err =
nullptr)
7916 bool useWithProperties;
7918#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7921 cl_uint version = detail::getContextPlatformVersion(context());
7922 useWithProperties = (version >= 0x20000);
7924#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7925 useWithProperties =
true;
7927 useWithProperties =
false;
7930#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7931 if (useWithProperties) {
7932 cl_queue_properties queue_properties[] = {
7933 CL_QUEUE_PROPERTIES, properties, 0 };
7934 object_ = CL_(clCreateCommandQueueWithProperties)(
7935 context(), device(), queue_properties, &error);
7937 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7938 if (err !=
nullptr) {
7943#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7944 if (!useWithProperties) {
7945 object_ = CL_(clCreateCommandQueue)(
7946 context(), device(), properties, &error);
7948 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7949 if (err !=
nullptr) {
7963 QueueProperties properties,
7964 cl_int* err =
nullptr)
7967 bool useWithProperties;
7969#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7972 cl_uint version = detail::getContextPlatformVersion(context());
7973 useWithProperties = (version >= 0x20000);
7975#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7976 useWithProperties =
true;
7978 useWithProperties =
false;
7981#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7982 if (useWithProperties) {
7983 cl_queue_properties queue_properties[] = {
7984 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
7985 object_ = CL_(clCreateCommandQueueWithProperties)(
7986 context(), device(), queue_properties, &error);
7988 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7989 if (err !=
nullptr) {
7994#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7995 if (!useWithProperties) {
7996 object_ = CL_(clCreateCommandQueue)(
7997 context(), device(),
static_cast<cl_command_queue_properties
>(properties), &error);
7999 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
8000 if (err !=
nullptr) {
8009 std::call_once(default_initialized_, makeDefault);
8010#if CL_HPP_TARGET_OPENCL_VERSION >= 200
8011 detail::errHandler(default_error_, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8013 detail::errHandler(default_error_, __CREATE_COMMAND_QUEUE_ERR);
8015 if (err !=
nullptr) {
8016 *err = default_error_;
8030 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_queue));
8031 detail::errHandler(default_error_);
8044 explicit CommandQueue(
const cl_command_queue& commandQueue,
bool retainObject =
false) :
8045 detail::Wrapper<cl_type>(commandQueue, retainObject) { }
8049 detail::Wrapper<cl_type>::operator=(rhs);
8053 template <
typename T>
8054 cl_int getInfo(cl_command_queue_info name, T* param)
const
8056 return detail::errHandler(
8058 CL_(clGetCommandQueueInfo), object_, name, param),
8059 __GET_COMMAND_QUEUE_INFO_ERR);
8062 template <cl_command_queue_info name>
typename
8063 detail::param_traits<detail::cl_command_queue_info, name>::param_type
8064 getInfo(cl_int* err =
nullptr)
const
8066 typename detail::param_traits<
8067 detail::cl_command_queue_info, name>::param_type param;
8068 cl_int result = getInfo(name, ¶m);
8069 if (err !=
nullptr) {
8075 cl_int enqueueReadBuffer(
8076 const Buffer& buffer,
8081 const vector<Event>* events =
nullptr,
8082 Event* event =
nullptr)
const
8085 cl_int err = detail::errHandler(
8086 CL_(clEnqueueReadBuffer)(
8087 object_, buffer(), blocking, offset, size,
8089 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8090 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
8091 (event !=
nullptr) ? &tmp :
nullptr),
8092 __ENQUEUE_READ_BUFFER_ERR);
8094 if (event !=
nullptr && err == CL_SUCCESS)
8100 cl_int enqueueWriteBuffer(
8101 const Buffer& buffer,
8106 const vector<Event>* events =
nullptr,
8107 Event* event =
nullptr)
const
8110 cl_int err = detail::errHandler(
8111 CL_(clEnqueueWriteBuffer)(
8112 object_, buffer(), blocking, offset, size,
8114 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8115 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
8116 (event !=
nullptr) ? &tmp :
nullptr),
8117 __ENQUEUE_WRITE_BUFFER_ERR);
8119 if (event !=
nullptr && err == CL_SUCCESS)
8125 cl_int enqueueCopyBuffer(
8128 size_type src_offset,
8129 size_type dst_offset,
8131 const vector<Event>* events =
nullptr,
8132 Event* event =
nullptr)
const
8135 cl_int err = detail::errHandler(
8136 CL_(clEnqueueCopyBuffer)(
8137 object_, src(), dst(), src_offset, dst_offset, size,
8138 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8139 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
8140 (event !=
nullptr) ? &tmp :
nullptr),
8141 __ENQEUE_COPY_BUFFER_ERR);
8143 if (event !=
nullptr && err == CL_SUCCESS)
8148#if CL_HPP_TARGET_OPENCL_VERSION >= 110
8149 cl_int enqueueReadBufferRect(
8150 const Buffer& buffer,
8152 const array<size_type, 3>& buffer_offset,
8153 const array<size_type, 3>& host_offset,
8154 const array<size_type, 3>& region,
8155 size_type buffer_row_pitch,
8156 size_type buffer_slice_pitch,
8157 size_type host_row_pitch,
8158 size_type host_slice_pitch,
8160 const vector<Event>* events =
nullptr,
8161 Event* event =
nullptr)
const
8164 cl_int err = detail::errHandler(
8165 CL_(clEnqueueReadBufferRect)(
8169 buffer_offset.data(),
8177 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8178 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
8179 (event !=
nullptr) ? &tmp :
nullptr),
8180 __ENQUEUE_READ_BUFFER_RECT_ERR);
8182 if (event !=
nullptr && err == CL_SUCCESS)
8188 cl_int enqueueReadBufferRect(
8189 const Buffer& buffer,
8191 const array<size_type, 2>& buffer_offset,
8192 const array<size_type, 2>& host_offset,
8193 const array<size_type, 2>& region,
8194 size_type buffer_row_pitch,
8195 size_type buffer_slice_pitch,
8196 size_type host_row_pitch,
8197 size_type host_slice_pitch,
8199 const vector<Event>* events =
nullptr,
8200 Event* event =
nullptr)
const
8202 return enqueueReadBufferRect(
8205 { buffer_offset[0], buffer_offset[1], 0 },
8206 { host_offset[0], host_offset[1], 0 },
8207 { region[0], region[1], 1 },
8217 cl_int enqueueWriteBufferRect(
8218 const Buffer& buffer,
8220 const array<size_type, 3>& buffer_offset,
8221 const array<size_type, 3>& host_offset,
8222 const array<size_type, 3>& region,
8223 size_type buffer_row_pitch,
8224 size_type buffer_slice_pitch,
8225 size_type host_row_pitch,
8226 size_type host_slice_pitch,
8228 const vector<Event>* events =
nullptr,
8229 Event* event =
nullptr)
const
8232 cl_int err = detail::errHandler(
8233 CL_(clEnqueueWriteBufferRect)(
8237 buffer_offset.data(),
8245 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8246 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
8247 (event !=
nullptr) ? &tmp :
nullptr),
8248 __ENQUEUE_WRITE_BUFFER_RECT_ERR);
8250 if (event !=
nullptr && err == CL_SUCCESS)
8256 cl_int enqueueWriteBufferRect(
8257 const Buffer& buffer,
8259 const array<size_type, 2>& buffer_offset,
8260 const array<size_type, 2>& host_offset,
8261 const array<size_type, 2>& region,
8262 size_type buffer_row_pitch,
8263 size_type buffer_slice_pitch,
8264 size_type host_row_pitch,
8265 size_type host_slice_pitch,
8267 const vector<Event>* events =
nullptr,
8268 Event* event =
nullptr)
const
8270 return enqueueWriteBufferRect(
8273 { buffer_offset[0], buffer_offset[1], 0 },
8274 { host_offset[0], host_offset[1], 0 },
8275 { region[0], region[1], 1 },
8285 cl_int enqueueCopyBufferRect(
8288 const array<size_type, 3>& src_origin,
8289 const array<size_type, 3>& dst_origin,
8290 const array<size_type, 3>& region,
8291 size_type src_row_pitch,
8292 size_type src_slice_pitch,
8293 size_type dst_row_pitch,
8294 size_type dst_slice_pitch,
8295 const vector<Event>* events =
nullptr,
8296 Event* event =
nullptr)
const
8299 cl_int err = detail::errHandler(
8300 CL_(clEnqueueCopyBufferRect)(
8311 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8312 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
8313 (event !=
nullptr) ? &tmp :
nullptr),
8314 __ENQEUE_COPY_BUFFER_RECT_ERR);
8316 if (event !=
nullptr && err == CL_SUCCESS)
8322 cl_int enqueueCopyBufferRect(
8325 const array<size_type, 2>& src_origin,
8326 const array<size_type, 2>& dst_origin,
8327 const array<size_type, 2>& region,
8328 size_type src_row_pitch,
8329 size_type src_slice_pitch,
8330 size_type dst_row_pitch,
8331 size_type dst_slice_pitch,
8332 const vector<Event>* events =
nullptr,
8333 Event* event =
nullptr)
const
8335 return enqueueCopyBufferRect(
8338 { src_origin[0], src_origin[1], 0 },
8339 { dst_origin[0], dst_origin[1], 0 },
8340 { region[0], region[1], 1 },
8350#if CL_HPP_TARGET_OPENCL_VERSION >= 120
8362 template<
typename PatternType>
8365 PatternType pattern,
8368 const vector<Event>* events =
nullptr,
8369 Event* event =
nullptr)
const
8372 cl_int err = detail::errHandler(
8373 CL_(clEnqueueFillBuffer)(
8376 static_cast<void*
>(&pattern),
8377 sizeof(PatternType),
8380 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8381 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
8382 (event !=
nullptr) ? &tmp :
nullptr),
8383 __ENQUEUE_FILL_BUFFER_ERR);
8385 if (event !=
nullptr && err == CL_SUCCESS)
8392 cl_int enqueueReadImage(
8395 const array<size_type, 3>& origin,
8396 const array<size_type, 3>& region,
8397 size_type row_pitch,
8398 size_type slice_pitch,
8400 const vector<Event>* events =
nullptr,
8401 Event* event =
nullptr)
const
8404 cl_int err = detail::errHandler(
8405 CL_(clEnqueueReadImage)(
8414 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8415 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
8416 (event !=
nullptr) ? &tmp :
nullptr),
8417 __ENQUEUE_READ_IMAGE_ERR);
8419 if (event !=
nullptr && err == CL_SUCCESS)
8425 cl_int enqueueReadImage(
8428 const array<size_type, 2>& origin,
8429 const array<size_type, 2>& region,
8430 size_type row_pitch,
8431 size_type slice_pitch,
8433 const vector<Event>* events =
nullptr,
8434 Event* event =
nullptr)
const
8436 return enqueueReadImage(
8439 { origin[0], origin[1], 0 },
8440 { region[0], region[1], 1 },
8448 cl_int enqueueWriteImage(
8451 const array<size_type, 3>& origin,
8452 const array<size_type, 3>& region,
8453 size_type row_pitch,
8454 size_type slice_pitch,
8456 const vector<Event>* events =
nullptr,
8457 Event* event =
nullptr)
const
8460 cl_int err = detail::errHandler(
8461 CL_(clEnqueueWriteImage)(
8470 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8471 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
8472 (event !=
nullptr) ? &tmp :
nullptr),
8473 __ENQUEUE_WRITE_IMAGE_ERR);
8475 if (event !=
nullptr && err == CL_SUCCESS)
8481 cl_int enqueueWriteImage(
8484 const array<size_type, 2>& origin,
8485 const array<size_type, 2>& region,
8486 size_type row_pitch,
8487 size_type slice_pitch,
8489 const vector<Event>* events =
nullptr,
8490 Event* event =
nullptr)
const
8492 return enqueueWriteImage(
8495 { origin[0], origin[1], 0 },
8496 { region[0], region[1], 1 },
8504 cl_int enqueueCopyImage(
8507 const array<size_type, 3>& src_origin,
8508 const array<size_type, 3>& dst_origin,
8509 const array<size_type, 3>& region,
8510 const vector<Event>* events =
nullptr,
8511 Event* event =
nullptr)
const
8514 cl_int err = detail::errHandler(
8515 CL_(clEnqueueCopyImage)(
8522 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8523 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
8524 (event !=
nullptr) ? &tmp :
nullptr),
8525 __ENQUEUE_COPY_IMAGE_ERR);
8527 if (event !=
nullptr && err == CL_SUCCESS)
8533 cl_int enqueueCopyImage(
8536 const array<size_type, 2>& src_origin,
8537 const array<size_type, 2>& dst_origin,
8538 const array<size_type, 2>& region,
8539 const vector<Event>* events =
nullptr,
8540 Event* event =
nullptr)
const
8542 return enqueueCopyImage(
8545 { src_origin[0], src_origin[1], 0 },
8546 { dst_origin[0], dst_origin[1], 0 },
8547 { region[0], region[1], 1 },
8552#if CL_HPP_TARGET_OPENCL_VERSION >= 120
8560 template <
typename T>
8561 typename std::enable_if<std::is_same<T, cl_float4>::value ||
8562 std::is_same<T, cl_int4 >::value ||
8563 std::is_same<T, cl_uint4 >::value,
8568 const array<size_type, 3>& origin,
8569 const array<size_type, 3>& region,
8570 const vector<Event>* events =
nullptr,
8571 Event* event =
nullptr)
const
8574 cl_int err = detail::errHandler(
8575 CL_(clEnqueueFillImage)(
8578 static_cast<void*
>(&fillColor),
8581 (events !=
nullptr) ? (cl_uint)events->size() : 0,
8582 (events !=
nullptr && events->size() > 0) ? (
const cl_event*)&events->front() : NULL,
8583 (event != NULL) ? &tmp :
nullptr),
8584 __ENQUEUE_FILL_IMAGE_ERR);
8586 if (event !=
nullptr && err == CL_SUCCESS) *
event = tmp;
8598 template <
typename T>
8599 typename std::enable_if<std::is_same<T, cl_float4>::value ||
8600 std::is_same<T, cl_int4 >::value ||
8601 std::is_same<T, cl_uint4 >::value, cl_int>::type
8605 const array<size_type, 2>& origin,
8606 const array<size_type, 2>& region,
8607 const vector<Event>* events =
nullptr,
8608 Event* event =
nullptr)
const
8613 { origin[0], origin[1], 0 },
8614 { region[0], region[1], 1 },
8621 cl_int enqueueCopyImageToBuffer(
8624 const array<size_type, 3>& src_origin,
8625 const array<size_type, 3>& region,
8626 size_type dst_offset,
8627 const vector<Event>* events =
nullptr,
8628 Event* event =
nullptr)
const
8631 cl_int err = detail::errHandler(
8632 CL_(clEnqueueCopyImageToBuffer)(
8639 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8640 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
8641 (event !=
nullptr) ? &tmp :
nullptr),
8642 __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR);
8644 if (event !=
nullptr && err == CL_SUCCESS)
8650 cl_int enqueueCopyImageToBuffer(
8653 const array<size_type, 2>& src_origin,
8654 const array<size_type, 2>& region,
8655 size_type dst_offset,
8656 const vector<Event>* events =
nullptr,
8657 Event* event =
nullptr)
const
8659 return enqueueCopyImageToBuffer(
8662 { src_origin[0], src_origin[1], 0 },
8663 { region[0], region[1], 1 },
8669 cl_int enqueueCopyBufferToImage(
8672 size_type src_offset,
8673 const array<size_type, 3>& dst_origin,
8674 const array<size_type, 3>& region,
8675 const vector<Event>* events =
nullptr,
8676 Event* event =
nullptr)
const
8679 cl_int err = detail::errHandler(
8680 CL_(clEnqueueCopyBufferToImage)(
8687 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8688 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
8689 (event !=
nullptr) ? &tmp :
nullptr),
8690 __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR);
8692 if (event !=
nullptr && err == CL_SUCCESS)
8698 cl_int enqueueCopyBufferToImage(
8701 size_type src_offset,
8702 const array<size_type, 2>& dst_origin,
8703 const array<size_type, 2>& region,
8704 const vector<Event>* events =
nullptr,
8705 Event* event =
nullptr)
const
8707 return enqueueCopyBufferToImage(
8711 { dst_origin[0], dst_origin[1], 0 },
8712 { region[0], region[1], 1 },
8717 void* enqueueMapBuffer(
8718 const Buffer& buffer,
8723 const vector<Event>* events =
nullptr,
8724 Event* event =
nullptr,
8725 cl_int* err =
nullptr)
const
8729 void * result = CL_(clEnqueueMapBuffer)(
8730 object_, buffer(), blocking, flags, offset, size,
8731 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8732 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
8733 (
event !=
nullptr) ? &tmp : nullptr,
8736 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
8737 if (err !=
nullptr) {
8740 if (event !=
nullptr && error == CL_SUCCESS)
8746 void* enqueueMapImage(
8750 const array<size_type, 3>& origin,
8751 const array<size_type, 3>& region,
8752 size_type * row_pitch,
8753 size_type * slice_pitch,
8754 const vector<Event>* events =
nullptr,
8755 Event* event =
nullptr,
8756 cl_int* err =
nullptr)
const
8760 void * result = CL_(clEnqueueMapImage)(
8761 object_, image(), blocking, flags,
8764 row_pitch, slice_pitch,
8765 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8766 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
8767 (
event !=
nullptr) ? &tmp : nullptr,
8770 detail::errHandler(error, __ENQUEUE_MAP_IMAGE_ERR);
8771 if (err !=
nullptr) {
8774 if (event !=
nullptr && error == CL_SUCCESS)
8779 void* enqueueMapImage(
8783 const array<size_type, 2>& origin,
8784 const array<size_type, 2>& region,
8785 size_type* row_pitch,
8786 size_type* slice_pitch,
8787 const vector<Event>* events =
nullptr,
8788 Event* event =
nullptr,
8789 cl_int* err =
nullptr)
const
8791 return enqueueMapImage(image, blocking, flags,
8792 { origin[0], origin[1], 0 },
8793 { region[0], region[1], 1 }, row_pitch,
8794 slice_pitch, events, event, err);
8797#if CL_HPP_TARGET_OPENCL_VERSION >= 200
8803 template<
typename T>
8809 const vector<Event> *events =
nullptr,
8810 Event *event =
nullptr)
const {
8812 cl_int err = detail::errHandler(CL_(clEnqueueSVMMemcpy)(
8813 object_, blocking,
static_cast<void *
>(dst_ptr),
static_cast<const void *
>(src_ptr), size,
8814 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8815 (events !=
nullptr && events->size() > 0) ? (
const cl_event *) &events->front() :
nullptr,
8816 (event !=
nullptr) ? &tmp :
nullptr), __ENQUEUE_COPY_SVM_ERR);
8818 if (event !=
nullptr && err == CL_SUCCESS)
8828 template<
typename T,
class D>
8830 cl::pointer<T, D> &dst_ptr,
8831 const cl::pointer<T, D> &src_ptr,
8834 const vector<Event> *events =
nullptr,
8835 Event *event =
nullptr)
const {
8837 cl_int err = detail::errHandler(CL_(clEnqueueSVMMemcpy)(
8838 object_, blocking,
static_cast<void *
>(dst_ptr.get()),
static_cast<const void *
>(src_ptr.get()),
8840 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8841 (events !=
nullptr && events->size() > 0) ? (
const cl_event *) &events->front() :
nullptr,
8842 (event !=
nullptr) ? &tmp :
nullptr), __ENQUEUE_COPY_SVM_ERR);
8844 if (event !=
nullptr && err == CL_SUCCESS)
8854 template<
typename T,
class Alloc>
8856 cl::vector<T, Alloc> &dst_container,
8857 const cl::vector<T, Alloc> &src_container,
8859 const vector<Event> *events =
nullptr,
8860 Event *event =
nullptr)
const {
8862 if(src_container.size() != dst_container.size()){
8863 return detail::errHandler(CL_INVALID_VALUE,__ENQUEUE_COPY_SVM_ERR);
8865 cl_int err = detail::errHandler(CL_(clEnqueueSVMMemcpy)(
8866 object_, blocking,
static_cast<void *
>(dst_container.data()),
8867 static_cast<const void *
>(src_container.data()),
8868 dst_container.size() *
sizeof(T),
8869 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8870 (events !=
nullptr && events->size() > 0) ? (
const cl_event *) &events->front() :
nullptr,
8871 (event != NULL) ? &tmp :
nullptr), __ENQUEUE_COPY_SVM_ERR);
8873 if (event !=
nullptr && err == CL_SUCCESS)
8883 template<
typename T,
typename PatternType>
8886 PatternType pattern,
8888 const vector<Event> *events =
nullptr,
8889 Event *event =
nullptr)
const {
8891 cl_int err = detail::errHandler(CL_(clEnqueueSVMMemFill)(
8892 object_,
static_cast<void *
>(ptr),
static_cast<void *
>(&pattern),
8893 sizeof(PatternType), size,
8894 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8895 (events !=
nullptr && events->size() > 0) ? (
const cl_event *) &events->front() :
nullptr,
8896 (event !=
nullptr) ? &tmp :
nullptr), __ENQUEUE_FILL_SVM_ERR);
8898 if (event !=
nullptr && err == CL_SUCCESS)
8908 template<
typename T,
class D,
typename PatternType>
8910 cl::pointer<T, D> &ptr,
8911 PatternType pattern,
8913 const vector<Event> *events =
nullptr,
8914 Event *event =
nullptr)
const {
8916 cl_int err = detail::errHandler(CL_(clEnqueueSVMMemFill)(
8917 object_,
static_cast<void *
>(ptr.get()),
static_cast<void *
>(&pattern),
8918 sizeof(PatternType), size,
8919 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8920 (events !=
nullptr && events->size() > 0) ? (
const cl_event *) &events->front() :
nullptr,
8921 (event !=
nullptr) ? &tmp :
nullptr), __ENQUEUE_FILL_SVM_ERR);
8923 if (event !=
nullptr && err == CL_SUCCESS)
8933 template<
typename T,
class Alloc,
typename PatternType>
8935 cl::vector<T, Alloc> &container,
8936 PatternType pattern,
8937 const vector<Event> *events =
nullptr,
8938 Event* event =
nullptr)
const
8941 cl_int err = detail::errHandler(CL_(clEnqueueSVMMemFill)(
8942 object_,
static_cast<void *
>(container.data()),
static_cast<void *
>(&pattern),
8943 sizeof(PatternType), container.size() *
sizeof(T),
8944 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8945 (events !=
nullptr && events->size() > 0) ? (
const cl_event *) &events->front() :
nullptr,
8946 (event !=
nullptr) ? &tmp : NULL), __ENQUEUE_FILL_SVM_ERR);
8948 if (event !=
nullptr && err == CL_SUCCESS)
8958 template<
typename T>
8964 const vector<Event>* events =
nullptr,
8965 Event* event =
nullptr)
const
8968 cl_int err = detail::errHandler(CL_(clEnqueueSVMMap)(
8969 object_, blocking, flags,
static_cast<void*
>(ptr), size,
8970 (events !=
nullptr) ? (cl_uint)events->size() : 0,
8971 (events !=
nullptr && events->size() > 0) ? (
const cl_event*)&events->front() :
nullptr,
8972 (event !=
nullptr) ? &tmp :
nullptr),
8973 __ENQUEUE_MAP_SVM_ERR);
8975 if (event !=
nullptr && err == CL_SUCCESS)
8986 template<
typename T,
class D>
8988 cl::pointer<T, D> &ptr,
8992 const vector<Event>* events =
nullptr,
8993 Event* event =
nullptr)
const
8996 cl_int err = detail::errHandler(CL_(clEnqueueSVMMap)(
8997 object_, blocking, flags,
static_cast<void*
>(ptr.get()), size,
8998 (events !=
nullptr) ? (cl_uint)events->size() : 0,
8999 (events !=
nullptr && events->size() > 0) ? (
const cl_event*)&events->front() :
nullptr,
9000 (event !=
nullptr) ? &tmp :
nullptr),
9001 __ENQUEUE_MAP_SVM_ERR);
9003 if (event !=
nullptr && err == CL_SUCCESS)
9013 template<
typename T,
class Alloc>
9015 cl::vector<T, Alloc> &container,
9018 const vector<Event>* events =
nullptr,
9019 Event* event =
nullptr)
const
9022 cl_int err = detail::errHandler(CL_(clEnqueueSVMMap)(
9023 object_, blocking, flags,
static_cast<void*
>(container.data()), container.size()*
sizeof(T),
9024 (events !=
nullptr) ? (cl_uint)events->size() : 0,
9025 (events !=
nullptr && events->size() > 0) ? (
const cl_event*)&events->front() :
nullptr,
9026 (event !=
nullptr) ? &tmp :
nullptr),
9027 __ENQUEUE_MAP_SVM_ERR);
9029 if (event !=
nullptr && err == CL_SUCCESS)
9036 cl_int enqueueUnmapMemObject(
9039 const vector<Event>* events =
nullptr,
9040 Event* event =
nullptr)
const
9043 cl_int err = detail::errHandler(
9044 CL_(clEnqueueUnmapMemObject)(
9045 object_, memory(), mapped_ptr,
9046 (events !=
nullptr) ? (cl_uint) events->size() : 0,
9047 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
9048 (event !=
nullptr) ? &tmp :
nullptr),
9049 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9051 if (event !=
nullptr && err == CL_SUCCESS)
9058#if CL_HPP_TARGET_OPENCL_VERSION >= 200
9063 template<
typename T>
9066 const vector<Event>* events =
nullptr,
9067 Event* event =
nullptr)
const
9070 cl_int err = detail::errHandler(
9071 CL_(clEnqueueSVMUnmap)(
9072 object_,
static_cast<void*
>(ptr),
9073 (events !=
nullptr) ? (cl_uint)events->size() : 0,
9074 (events !=
nullptr && events->size() > 0) ? (
const cl_event*)&events->front() :
nullptr,
9075 (event !=
nullptr) ? &tmp :
nullptr),
9076 __ENQUEUE_UNMAP_SVM_ERR);
9078 if (event !=
nullptr && err == CL_SUCCESS)
9088 template<
typename T,
class D>
9090 cl::pointer<T, D> &ptr,
9091 const vector<Event>* events =
nullptr,
9092 Event* event =
nullptr)
const
9095 cl_int err = detail::errHandler(
9096 CL_(clEnqueueSVMUnmap)(
9097 object_,
static_cast<void*
>(ptr.get()),
9098 (events !=
nullptr) ? (cl_uint)events->size() : 0,
9099 (events !=
nullptr && events->size() > 0) ? (
const cl_event*)&events->front() :
nullptr,
9100 (event !=
nullptr) ? &tmp :
nullptr),
9101 __ENQUEUE_UNMAP_SVM_ERR);
9103 if (event !=
nullptr && err == CL_SUCCESS)
9113 template<
typename T,
class Alloc>
9115 cl::vector<T, Alloc> &container,
9116 const vector<Event>* events =
nullptr,
9117 Event* event =
nullptr)
const
9120 cl_int err = detail::errHandler(
9121 CL_(clEnqueueSVMUnmap)(
9122 object_,
static_cast<void*
>(container.data()),
9123 (events !=
nullptr) ? (cl_uint)events->size() : 0,
9124 (events !=
nullptr && events->size() > 0) ? (
const cl_event*)&events->front() :
nullptr,
9125 (event !=
nullptr) ? &tmp :
nullptr),
9126 __ENQUEUE_UNMAP_SVM_ERR);
9128 if (event !=
nullptr && err == CL_SUCCESS)
9135#if CL_HPP_TARGET_OPENCL_VERSION >= 120
9148 const vector<Event> *events =
nullptr,
9149 Event *event =
nullptr)
const
9152 cl_int err = detail::errHandler(
9153 CL_(clEnqueueMarkerWithWaitList)(
9155 (events !=
nullptr) ? (cl_uint) events->size() : 0,
9156 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
9157 (event !=
nullptr) ? &tmp :
nullptr),
9158 __ENQUEUE_MARKER_WAIT_LIST_ERR);
9160 if (event !=
nullptr && err == CL_SUCCESS)
9178 const vector<Event> *events =
nullptr,
9179 Event *event =
nullptr)
const
9182 cl_int err = detail::errHandler(
9183 CL_(clEnqueueBarrierWithWaitList)(
9185 (events !=
nullptr) ? (cl_uint) events->size() : 0,
9186 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
9187 (event !=
nullptr) ? &tmp :
nullptr),
9188 __ENQUEUE_BARRIER_WAIT_LIST_ERR);
9190 if (event !=
nullptr && err == CL_SUCCESS)
9201 const vector<Memory> &memObjects,
9202 cl_mem_migration_flags flags,
9203 const vector<Event>* events =
nullptr,
9204 Event* event =
nullptr
9209 vector<cl_mem> localMemObjects(memObjects.size());
9211 for(
int i = 0; i < (int)memObjects.size(); ++i ) {
9212 localMemObjects[i] = memObjects[i]();
9215 cl_int err = detail::errHandler(
9216 CL_(clEnqueueMigrateMemObjects)(
9218 (cl_uint)memObjects.size(),
9219 localMemObjects.data(),
9221 (events !=
nullptr) ? (cl_uint) events->size() : 0,
9222 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
9223 (event !=
nullptr) ? &tmp :
nullptr),
9224 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9226 if (event !=
nullptr && err == CL_SUCCESS)
9234#if CL_HPP_TARGET_OPENCL_VERSION >= 210
9240 template<
typename T>
9242 const cl::vector<T*> &svmRawPointers,
9243 const cl::vector<size_type> &sizes,
9244 cl_mem_migration_flags flags = 0,
9245 const vector<Event>* events =
nullptr,
9246 Event* event =
nullptr)
const
9249 cl_int err = detail::errHandler(CL_(clEnqueueSVMMigrateMem)(
9251 svmRawPointers.size(),
static_cast<void**
>(svmRawPointers.data()),
9254 (events !=
nullptr) ? (cl_uint)events->size() : 0,
9255 (events !=
nullptr && events->size() > 0) ? (
const cl_event*)&events->front() :
nullptr,
9256 (event !=
nullptr) ? &tmp :
nullptr),
9257 __ENQUEUE_MIGRATE_SVM_ERR);
9259 if (event !=
nullptr && err == CL_SUCCESS)
9269 template<
typename T>
9271 const cl::vector<T*> &svmRawPointers,
9272 cl_mem_migration_flags flags = 0,
9273 const vector<Event>* events =
nullptr,
9274 Event* event =
nullptr)
const
9276 return enqueueMigrateSVM(svmRawPointers, cl::vector<size_type>(svmRawPointers.size()), flags, events, event);
9285 template<
typename T,
class D>
9287 const cl::vector<cl::pointer<T, D>> &svmPointers,
9288 const cl::vector<size_type> &sizes,
9289 cl_mem_migration_flags flags = 0,
9290 const vector<Event>* events =
nullptr,
9291 Event* event =
nullptr)
const
9293 cl::vector<void*> svmRawPointers;
9294 svmRawPointers.reserve(svmPointers.size());
9295 for (
auto p : svmPointers) {
9296 svmRawPointers.push_back(
static_cast<void*
>(p.get()));
9307 template<
typename T,
class D>
9309 const cl::vector<cl::pointer<T, D>> &svmPointers,
9310 cl_mem_migration_flags flags = 0,
9311 const vector<Event>* events =
nullptr,
9312 Event* event =
nullptr)
const
9314 return enqueueMigrateSVM(svmPointers, cl::vector<size_type>(svmPointers.size()), flags, events, event);
9322 template<
typename T,
class Alloc>
9324 const cl::vector<cl::vector<T, Alloc>> &svmContainers,
9325 const cl::vector<size_type> &sizes,
9326 cl_mem_migration_flags flags = 0,
9327 const vector<Event>* events =
nullptr,
9328 Event* event =
nullptr)
const
9330 cl::vector<void*> svmRawPointers;
9331 svmRawPointers.reserve(svmContainers.size());
9332 for (
auto p : svmContainers) {
9333 svmRawPointers.push_back(
static_cast<void*
>(p.data()));
9343 template<
typename T,
class Alloc>
9345 const cl::vector<cl::vector<T, Alloc>> &svmContainers,
9346 cl_mem_migration_flags flags = 0,
9347 const vector<Event>* events =
nullptr,
9348 Event* event =
nullptr)
const
9350 return enqueueMigrateSVM(svmContainers, cl::vector<size_type>(svmContainers.size()), flags, events, event);
9355 cl_int enqueueNDRangeKernel(
9359 const NDRange& local = NullRange,
9360 const vector<Event>* events =
nullptr,
9361 Event* event =
nullptr)
const
9364 cl_int err = detail::errHandler(
9365 CL_(clEnqueueNDRangeKernel)(
9366 object_, kernel(), (cl_uint) global.
dimensions(),
9367 offset.
dimensions() != 0 ? (
const size_type*) offset :
nullptr,
9368 (
const size_type*) global,
9369 local.dimensions() != 0 ? (
const size_type*) local :
nullptr,
9370 (events !=
nullptr) ? (cl_uint) events->size() : 0,
9371 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
9372 (event !=
nullptr) ? &tmp :
nullptr),
9373 __ENQUEUE_NDRANGE_KERNEL_ERR);
9375 if (event !=
nullptr && err == CL_SUCCESS)
9381#if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
9382 CL_API_PREFIX__VERSION_1_2_DEPRECATED cl_int enqueueTask(
9383 const Kernel& kernel,
9384 const vector<Event>* events =
nullptr,
9385 Event* event =
nullptr) const CL_API_SUFFIX__VERSION_1_2_DEPRECATED
9388 cl_int err = detail::errHandler(
9391 (events !=
nullptr) ? (cl_uint) events->size() : 0,
9392 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
9393 (event !=
nullptr) ? &tmp :
nullptr),
9394 __ENQUEUE_TASK_ERR);
9396 if (event !=
nullptr && err == CL_SUCCESS)
9403 cl_int enqueueNativeKernel(
9404 void (CL_CALLBACK *userFptr)(
void *),
9405 std::pair<void*, size_type> args,
9406 const vector<Memory>* mem_objects =
nullptr,
9407 const vector<const void*>* mem_locs =
nullptr,
9408 const vector<Event>* events =
nullptr,
9409 Event* event =
nullptr)
const
9412 cl_int err = detail::errHandler(
9413 CL_(clEnqueueNativeKernel)(
9414 object_, userFptr, args.first, args.second,
9415 (mem_objects !=
nullptr) ? (cl_uint) mem_objects->size() : 0,
9416 (mem_objects->size() > 0 ) ?
reinterpret_cast<const cl_mem *
>(mem_objects->data()) :
nullptr,
9417 (mem_locs !=
nullptr && mem_locs->size() > 0) ?
const_cast<const void**
>(&mem_locs->front()) :
nullptr,
9418 (events !=
nullptr) ? (cl_uint) events->size() : 0,
9419 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
9420 (event !=
nullptr) ? &tmp :
nullptr),
9421 __ENQUEUE_NATIVE_KERNEL);
9423 if (event !=
nullptr && err == CL_SUCCESS)
9432#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
9433 CL_API_PREFIX__VERSION_1_1_DEPRECATED
9434 cl_int
enqueueMarker(
Event* event =
nullptr) const CL_API_SUFFIX__VERSION_1_1_DEPRECATED
9437 cl_int err = detail::errHandler(
9438 CL_(clEnqueueMarker)(
9440 (event !=
nullptr) ? &tmp :
nullptr),
9441 __ENQUEUE_MARKER_ERR);
9443 if (event !=
nullptr && err == CL_SUCCESS)
9449 CL_API_PREFIX__VERSION_1_1_DEPRECATED
9450 cl_int enqueueWaitForEvents(
const vector<Event>& events)
const CL_API_SUFFIX__VERSION_1_1_DEPRECATED
9452 return detail::errHandler(
9453 CL_(clEnqueueWaitForEvents)(
9455 (cl_uint) events.size(),
9456 events.size() > 0 ? (
const cl_event*) &events.front() :
nullptr),
9457 __ENQUEUE_WAIT_FOR_EVENTS_ERR);
9461 cl_int enqueueAcquireGLObjects(
9462 const vector<Memory>* mem_objects =
nullptr,
9463 const vector<Event>* events =
nullptr,
9464 Event* event =
nullptr)
const
9467 cl_int err = detail::errHandler(
9468 CL_(clEnqueueAcquireGLObjects)(
9470 (mem_objects !=
nullptr) ? (cl_uint) mem_objects->size() : 0,
9471 (mem_objects !=
nullptr && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front():
nullptr,
9472 (events !=
nullptr) ? (cl_uint) events->size() : 0,
9473 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
9474 (event !=
nullptr) ? &tmp :
nullptr),
9475 __ENQUEUE_ACQUIRE_GL_ERR);
9477 if (event !=
nullptr && err == CL_SUCCESS)
9483 cl_int enqueueReleaseGLObjects(
9484 const vector<Memory>* mem_objects =
nullptr,
9485 const vector<Event>* events =
nullptr,
9486 Event* event =
nullptr)
const
9489 cl_int err = detail::errHandler(
9490 CL_(clEnqueueReleaseGLObjects)(
9492 (mem_objects !=
nullptr) ? (cl_uint) mem_objects->size() : 0,
9493 (mem_objects !=
nullptr && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front():
nullptr,
9494 (events !=
nullptr) ? (cl_uint) events->size() : 0,
9495 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
9496 (event !=
nullptr) ? &tmp :
nullptr),
9497 __ENQUEUE_RELEASE_GL_ERR);
9499 if (event !=
nullptr && err == CL_SUCCESS)
9505#if defined (CL_HPP_USE_DX_INTEROP)
9506typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueAcquireD3D10ObjectsKHR)(
9507 cl_command_queue command_queue, cl_uint num_objects,
9508 const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
9509 const cl_event* event_wait_list, cl_event* event);
9510typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueReleaseD3D10ObjectsKHR)(
9511 cl_command_queue command_queue, cl_uint num_objects,
9512 const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
9513 const cl_event* event_wait_list, cl_event* event);
9515 cl_int enqueueAcquireD3D10Objects(
9516 const vector<Memory>* mem_objects =
nullptr,
9517 const vector<Event>* events =
nullptr,
9518 Event* event =
nullptr)
const
9520 static PFN_clEnqueueAcquireD3D10ObjectsKHR pfn_clEnqueueAcquireD3D10ObjectsKHR =
nullptr;
9521#if CL_HPP_TARGET_OPENCL_VERSION >= 120
9522 cl_context context = getInfo<CL_QUEUE_CONTEXT>();
9523 cl::Device device(getInfo<CL_QUEUE_DEVICE>());
9524 cl_platform_id platform = device.
getInfo<CL_DEVICE_PLATFORM>();
9525 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueAcquireD3D10ObjectsKHR);
9527#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
9528 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueAcquireD3D10ObjectsKHR);
9532 cl_int err = detail::errHandler(
9533 pfn_clEnqueueAcquireD3D10ObjectsKHR(
9535 (mem_objects !=
nullptr) ? (cl_uint) mem_objects->size() : 0,
9536 (mem_objects !=
nullptr && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front():
nullptr,
9537 (events !=
nullptr) ? (cl_uint) events->size() : 0,
9538 (events !=
nullptr) ? (
const cl_event*) &events->front() :
nullptr,
9539 (event !=
nullptr) ? &tmp :
nullptr),
9540 __ENQUEUE_ACQUIRE_GL_ERR);
9542 if (event !=
nullptr && err == CL_SUCCESS)
9548 cl_int enqueueReleaseD3D10Objects(
9549 const vector<Memory>* mem_objects =
nullptr,
9550 const vector<Event>* events =
nullptr,
9551 Event* event =
nullptr)
const
9553 static PFN_clEnqueueReleaseD3D10ObjectsKHR pfn_clEnqueueReleaseD3D10ObjectsKHR =
nullptr;
9554#if CL_HPP_TARGET_OPENCL_VERSION >= 120
9555 cl_context context = getInfo<CL_QUEUE_CONTEXT>();
9556 cl::Device device(getInfo<CL_QUEUE_DEVICE>());
9557 cl_platform_id platform = device.
getInfo<CL_DEVICE_PLATFORM>();
9558 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueReleaseD3D10ObjectsKHR);
9560#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
9561 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueReleaseD3D10ObjectsKHR);
9565 cl_int err = detail::errHandler(
9566 pfn_clEnqueueReleaseD3D10ObjectsKHR(
9568 (mem_objects !=
nullptr) ? (cl_uint) mem_objects->size() : 0,
9569 (mem_objects !=
nullptr && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front():
nullptr,
9570 (events !=
nullptr) ? (cl_uint) events->size() : 0,
9571 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
9572 (event !=
nullptr) ? &tmp :
nullptr),
9573 __ENQUEUE_RELEASE_GL_ERR);
9575 if (event !=
nullptr && err == CL_SUCCESS)
9585#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
9586 CL_API_PREFIX__VERSION_1_1_DEPRECATED
9587 cl_int
enqueueBarrier() const CL_API_SUFFIX__VERSION_1_1_DEPRECATED
9589 return detail::errHandler(
9590 CL_(clEnqueueBarrier)(object_),
9591 __ENQUEUE_BARRIER_ERR);
9595 cl_int flush()
const
9597 return detail::errHandler(CL_(clFlush)(object_), __FLUSH_ERR);
9600 cl_int finish()
const
9602 return detail::errHandler(CL_(clFinish)(object_), __FINISH_ERR);
9605#ifdef cl_khr_external_memory
9606 cl_int enqueueAcquireExternalMemObjects(
9607 const vector<Memory>& mem_objects,
9608 const vector<Event>* events_wait =
nullptr,
9609 Event *event =
nullptr)
9611 cl_int err = CL_INVALID_OPERATION;
9614 std::call_once(ext_memory_initialized_, initMemoryExtension, this->getInfo<CL_QUEUE_DEVICE>());
9616 if (pfn_clEnqueueAcquireExternalMemObjectsKHR)
9618 err = pfn_clEnqueueAcquireExternalMemObjectsKHR(
9620 static_cast<cl_uint
>(mem_objects.size()),
9621 (mem_objects.size() > 0) ?
reinterpret_cast<const cl_mem *
>(mem_objects.data()) :
nullptr,
9622 (events_wait !=
nullptr) ?
static_cast<cl_uint
>(events_wait->size()) : 0,
9623 (events_wait !=
nullptr && events_wait->size() > 0) ?
reinterpret_cast<const cl_event*
>(events_wait->data()) :
nullptr,
9627 detail::errHandler(err, __ENQUEUE_ACQUIRE_EXTERNAL_MEMORY_ERR);
9629 if (event !=
nullptr && err == CL_SUCCESS)
9635 cl_int enqueueReleaseExternalMemObjects(
9636 const vector<Memory>& mem_objects,
9637 const vector<Event>* events_wait =
nullptr,
9638 Event *event =
nullptr)
9640 cl_int err = CL_INVALID_OPERATION;
9643 std::call_once(ext_memory_initialized_, initMemoryExtension, this->getInfo<CL_QUEUE_DEVICE>());
9645 if (pfn_clEnqueueReleaseExternalMemObjectsKHR)
9647 err = pfn_clEnqueueReleaseExternalMemObjectsKHR(
9649 static_cast<cl_uint
>(mem_objects.size()),
9650 (mem_objects.size() > 0) ?
reinterpret_cast<const cl_mem *
>(mem_objects.data()) :
nullptr,
9651 (events_wait !=
nullptr) ?
static_cast<cl_uint
>(events_wait->size()) : 0,
9652 (events_wait !=
nullptr && events_wait->size() > 0) ?
reinterpret_cast<const cl_event*
>(events_wait->data()) :
nullptr,
9656 detail::errHandler(err, __ENQUEUE_RELEASE_EXTERNAL_MEMORY_ERR);
9658 if (event !=
nullptr && err == CL_SUCCESS)
9665#ifdef cl_khr_semaphore
9666 cl_int enqueueWaitSemaphores(
9667 const vector<Semaphore> &sema_objects,
9668 const vector<cl_semaphore_payload_khr> &sema_payloads = {},
9669 const vector<Event>* events_wait_list =
nullptr,
9670 Event *
event =
nullptr)
const;
9672 cl_int enqueueSignalSemaphores(
9673 const vector<Semaphore> &sema_objects,
9674 const vector<cl_semaphore_payload_khr>& sema_payloads = {},
9675 const vector<Event>* events_wait_list =
nullptr,
9676 Event*
event =
nullptr);
9680#ifdef cl_khr_external_memory
9681CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag CommandQueue::ext_memory_initialized_;
9684CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag CommandQueue::default_initialized_;
9685CL_HPP_DEFINE_STATIC_MEMBER_
CommandQueue CommandQueue::default_;
9686CL_HPP_DEFINE_STATIC_MEMBER_ cl_int CommandQueue::default_error_ = CL_SUCCESS;
9689#if CL_HPP_TARGET_OPENCL_VERSION >= 200
9690enum class DeviceQueueProperties : cl_command_queue_properties
9693 Profiling = CL_QUEUE_PROFILING_ENABLE,
9696inline DeviceQueueProperties operator|(DeviceQueueProperties lhs, DeviceQueueProperties rhs)
9698 return static_cast<DeviceQueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) |
static_cast<cl_command_queue_properties
>(rhs));
9722 cl_command_queue_properties mergedProperties =
9723 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
9725 cl_queue_properties queue_properties[] = {
9726 CL_QUEUE_PROPERTIES, mergedProperties, 0 };
9727 object_ = CL_(clCreateCommandQueueWithProperties)(
9728 context(), device(), queue_properties, &error);
9730 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9731 if (err !=
nullptr) {
9742 DeviceQueueProperties properties = DeviceQueueProperties::None,
9743 cl_int* err =
nullptr)
9747 cl_command_queue_properties mergedProperties =
9748 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
9749 cl_queue_properties queue_properties[] = {
9750 CL_QUEUE_PROPERTIES, mergedProperties, 0 };
9751 object_ = CL_(clCreateCommandQueueWithProperties)(
9752 context(), device(), queue_properties, &error);
9754 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9755 if (err !=
nullptr) {
9767 DeviceQueueProperties properties = DeviceQueueProperties::None,
9768 cl_int* err =
nullptr)
9772 cl_command_queue_properties mergedProperties =
9773 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
9774 cl_queue_properties queue_properties[] = {
9775 CL_QUEUE_PROPERTIES, mergedProperties,
9776 CL_QUEUE_SIZE, queueSize,
9778 object_ = CL_(clCreateCommandQueueWithProperties)(
9779 context(), device(), queue_properties, &error);
9781 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9782 if (err !=
nullptr) {
9793 explicit DeviceCommandQueue(
const cl_command_queue& commandQueue,
bool retainObject =
false) :
9794 detail::Wrapper<cl_type>(commandQueue, retainObject) { }
9798 detail::Wrapper<cl_type>::operator=(rhs);
9802 template <
typename T>
9803 cl_int getInfo(cl_command_queue_info name, T* param)
const
9805 return detail::errHandler(
9807 CL_(clGetCommandQueueInfo), object_, name, param),
9808 __GET_COMMAND_QUEUE_INFO_ERR);
9811 template <cl_command_queue_info name>
typename
9812 detail::param_traits<detail::cl_command_queue_info, name>::param_type
9813 getInfo(cl_int* err =
nullptr)
const
9815 typename detail::param_traits<
9816 detail::cl_command_queue_info, name>::param_type param;
9817 cl_int result = getInfo(name, ¶m);
9818 if (err !=
nullptr) {
9831 cl_int *err =
nullptr)
9837 cl_command_queue_properties properties =
9838 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
9839 cl_queue_properties queue_properties[] = {
9840 CL_QUEUE_PROPERTIES, properties,
9843 CL_(clCreateCommandQueueWithProperties)(
9844 context(), device(), queue_properties, &error));
9846 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9847 if (err !=
nullptr) {
9861 const Context &context,
const Device &device, cl_int *err =
nullptr)
9865 cl_command_queue_properties properties =
9866 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
9867 cl_queue_properties queue_properties[] = {
9868 CL_QUEUE_PROPERTIES, properties,
9871 CL_(clCreateCommandQueueWithProperties)(
9872 context(), device(), queue_properties, &error));
9874 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9875 if (err !=
nullptr) {
9889 const Context &context,
const Device &device, cl_uint queueSize, cl_int *err =
nullptr)
9893 cl_command_queue_properties properties =
9894 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
9895 cl_queue_properties queue_properties[] = {
9896 CL_QUEUE_PROPERTIES, properties,
9897 CL_QUEUE_SIZE, queueSize,
9900 CL_(clCreateCommandQueueWithProperties)(
9901 context(), device(), queue_properties, &error));
9903 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9904 if (err !=
nullptr) {
9913#if CL_HPP_TARGET_OPENCL_VERSION >= 210
9923 error = CL_(clSetDefaultDeviceCommandQueue)(context.get(), device.get(), default_queue.get());
9925 detail::errHandler(error, __SET_DEFAULT_DEVICE_COMMAND_QUEUE_ERR);
9926 if (err !=
nullptr) {
9929 return default_queue;
9937 return queue.getInfo<CL_QUEUE_DEVICE_DEFAULT>(err);
9957template<
typename IteratorType >
9960 IteratorType startIterator,
9961 IteratorType endIterator,
9966 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9969 cl_mem_flags flags = 0;
9971 flags |= CL_MEM_READ_ONLY;
9974 flags |= CL_MEM_READ_WRITE;
9977 flags |= CL_MEM_USE_HOST_PTR;
9980 size_type size =
sizeof(DataType)*(endIterator - startIterator);
9983 object_ = CL_(clCreateBuffer)(context(), flags, size,
const_cast<DataType*
>(&*startIterator), &error);
9985 object_ = CL_(clCreateBuffer)(context(), flags, size, 0, &error);
9988 detail::errHandler(error, __CREATE_BUFFER_ERR);
9989 if (err !=
nullptr) {
9995 detail::errHandler(error, __CREATE_BUFFER_ERR);
9996 if (err !=
nullptr) {
10000 error =
cl::copy(queue, startIterator, endIterator, *
this);
10001 detail::errHandler(error, __CREATE_BUFFER_ERR);
10002 if (err !=
nullptr) {
10008template<
typename IteratorType >
10010 const CommandQueue &queue,
10011 IteratorType startIterator,
10012 IteratorType endIterator,
10017 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
10020 cl_mem_flags flags = 0;
10022 flags |= CL_MEM_READ_ONLY;
10025 flags |= CL_MEM_READ_WRITE;
10028 flags |= CL_MEM_USE_HOST_PTR;
10031 size_type size =
sizeof(DataType)*(endIterator - startIterator);
10033 Context context = queue.getInfo<CL_QUEUE_CONTEXT>();
10036 object_ = CL_(clCreateBuffer)(context(), flags, size,
const_cast<DataType*
>(&*startIterator), &error);
10039 object_ = CL_(clCreateBuffer)(context(), flags, size, 0, &error);
10042 detail::errHandler(error, __CREATE_BUFFER_ERR);
10043 if (err !=
nullptr) {
10048 error =
cl::copy(queue, startIterator, endIterator, *
this);
10049 detail::errHandler(error, __CREATE_BUFFER_ERR);
10050 if (err !=
nullptr) {
10056inline cl_int enqueueReadBuffer(
10062 const vector<Event>* events =
nullptr,
10063 Event* event =
nullptr)
10066 CommandQueue queue = CommandQueue::getDefault(&error);
10068 if (error != CL_SUCCESS) {
10072 return queue.enqueueReadBuffer(buffer, blocking, offset, size, ptr, events, event);
10075inline cl_int enqueueWriteBuffer(
10081 const vector<Event>* events =
nullptr,
10082 Event* event =
nullptr)
10085 CommandQueue queue = CommandQueue::getDefault(&error);
10087 if (error != CL_SUCCESS) {
10091 return queue.enqueueWriteBuffer(buffer, blocking, offset, size, ptr, events, event);
10094inline void* enqueueMapBuffer(
10097 cl_map_flags flags,
10100 const vector<Event>* events =
nullptr,
10101 Event* event =
nullptr,
10102 cl_int* err =
nullptr)
10105 CommandQueue queue = CommandQueue::getDefault(&error);
10106 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
10107 if (err !=
nullptr) {
10111 void * result = CL_(clEnqueueMapBuffer)(
10112 queue(), buffer(), blocking, flags, offset, size,
10113 (events !=
nullptr) ? (cl_uint) events->size() : 0,
10114 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
10118 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
10119 if (err !=
nullptr) {
10126#if CL_HPP_TARGET_OPENCL_VERSION >= 200
10132template<
typename T>
10136 cl_map_flags flags,
10138 const vector<Event>* events,
10142 CommandQueue queue = CommandQueue::getDefault(&error);
10143 if (error != CL_SUCCESS) {
10144 return detail::errHandler(error, __ENQUEUE_MAP_SVM_ERR);
10148 ptr, blocking, flags, size, events, event);
10156template<
typename T,
class D>
10158 cl::pointer<T, D> &ptr,
10160 cl_map_flags flags,
10162 const vector<Event>* events =
nullptr,
10163 Event* event =
nullptr)
10166 CommandQueue queue = CommandQueue::getDefault(&error);
10167 if (error != CL_SUCCESS) {
10168 return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
10172 ptr, blocking, flags, size, events, event);
10180template<
typename T,
class Alloc>
10182 cl::vector<T, Alloc> &container,
10184 cl_map_flags flags,
10185 const vector<Event>* events =
nullptr,
10186 Event* event =
nullptr)
10189 CommandQueue queue = CommandQueue::getDefault(&error);
10190 if (error != CL_SUCCESS) {
10191 return detail::errHandler(error, __ENQUEUE_MAP_SVM_ERR);
10195 container, blocking, flags, events, event);
10200inline cl_int enqueueUnmapMemObject(
10201 const Memory& memory,
10203 const vector<Event>* events =
nullptr,
10204 Event* event =
nullptr)
10207 CommandQueue queue = CommandQueue::getDefault(&error);
10208 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
10209 if (error != CL_SUCCESS) {
10214 cl_int err = detail::errHandler(
10215 CL_(clEnqueueUnmapMemObject)(
10216 queue(), memory(), mapped_ptr,
10217 (events !=
nullptr) ? (cl_uint)events->size() : 0,
10218 (events !=
nullptr && events->size() > 0) ? (
const cl_event*)&events->front() :
nullptr,
10219 (event !=
nullptr) ? &tmp :
nullptr),
10220 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
10222 if (event !=
nullptr && err == CL_SUCCESS)
10228#if CL_HPP_TARGET_OPENCL_VERSION >= 200
10234template<
typename T>
10237 const vector<Event>* events =
nullptr,
10238 Event* event =
nullptr)
10241 CommandQueue queue = CommandQueue::getDefault(&error);
10242 if (error != CL_SUCCESS) {
10243 return detail::errHandler(error, __ENQUEUE_UNMAP_SVM_ERR);
10247 __ENQUEUE_UNMAP_SVM_ERR);
10256template<
typename T,
class D>
10258 cl::pointer<T, D> &ptr,
10259 const vector<Event>* events =
nullptr,
10260 Event* event =
nullptr)
10263 CommandQueue queue = CommandQueue::getDefault(&error);
10264 if (error != CL_SUCCESS) {
10265 return detail::errHandler(error, __ENQUEUE_UNMAP_SVM_ERR);
10269 __ENQUEUE_UNMAP_SVM_ERR);
10277template<
typename T,
class Alloc>
10279 cl::vector<T, Alloc> &container,
10280 const vector<Event>* events =
nullptr,
10281 Event* event =
nullptr)
10284 CommandQueue queue = CommandQueue::getDefault(&error);
10285 if (error != CL_SUCCESS) {
10286 return detail::errHandler(error, __ENQUEUE_UNMAP_SVM_ERR);
10289 return detail::errHandler(queue.
enqueueUnmapSVM(container, events, event),
10290 __ENQUEUE_UNMAP_SVM_ERR);
10295inline cl_int enqueueCopyBuffer(
10298 size_type src_offset,
10299 size_type dst_offset,
10301 const vector<Event>* events =
nullptr,
10302 Event* event =
nullptr)
10305 CommandQueue queue = CommandQueue::getDefault(&error);
10307 if (error != CL_SUCCESS) {
10311 return queue.enqueueCopyBuffer(src, dst, src_offset, dst_offset, size, events, event);
10319template<
typename IteratorType >
10320inline cl_int
copy( IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer )
10323 CommandQueue queue = CommandQueue::getDefault(&error);
10324 if (error != CL_SUCCESS)
10327 return cl::copy(queue, startIterator, endIterator, buffer);
10335template<
typename IteratorType >
10336inline cl_int
copy(
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator )
10339 CommandQueue queue = CommandQueue::getDefault(&error);
10340 if (error != CL_SUCCESS)
10343 return cl::copy(queue, buffer, startIterator, endIterator);
10351template<
typename IteratorType >
10354 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
10357 size_type length = endIterator-startIterator;
10358 size_type byteLength = length*
sizeof(DataType);
10360 DataType *pointer =
10361 static_cast<DataType*
>(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_WRITE, 0, byteLength, 0, 0, &error));
10363 if( error != CL_SUCCESS ) {
10366#if defined(_MSC_VER) && _MSC_VER < 1920
10370 stdext::checked_array_iterator<DataType*>(
10373 std::copy(startIterator, endIterator, pointer);
10376 error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
10378 if( error != CL_SUCCESS ) {
10390template<
typename IteratorType >
10391inline cl_int
copy(
const CommandQueue &queue,
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator )
10393 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
10396 size_type length = endIterator-startIterator;
10397 size_type byteLength = length*
sizeof(DataType);
10399 DataType *pointer =
10400 static_cast<DataType*
>(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_READ, 0, byteLength, 0, 0, &error));
10402 if( error != CL_SUCCESS ) {
10405 std::copy(pointer, pointer + length, startIterator);
10407 error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
10409 if( error != CL_SUCCESS ) {
10417#if CL_HPP_TARGET_OPENCL_VERSION >= 200
10421template<
typename T,
class Alloc>
10422inline cl_int
mapSVM(cl::vector<T, Alloc> &container)
10424 return enqueueMapSVM(container, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE);
10430template<
typename T,
class Alloc>
10431inline cl_int
unmapSVM(cl::vector<T, Alloc> &container)
10438#if CL_HPP_TARGET_OPENCL_VERSION >= 110
10439inline cl_int enqueueReadBufferRect(
10440 const Buffer& buffer,
10442 const array<size_type, 3>& buffer_offset,
10443 const array<size_type, 3>& host_offset,
10444 const array<size_type, 3>& region,
10445 size_type buffer_row_pitch,
10446 size_type buffer_slice_pitch,
10447 size_type host_row_pitch,
10448 size_type host_slice_pitch,
10450 const vector<Event>* events =
nullptr,
10451 Event* event =
nullptr)
10454 CommandQueue queue = CommandQueue::getDefault(&error);
10456 if (error != CL_SUCCESS) {
10460 return queue.enqueueReadBufferRect(
10467 buffer_slice_pitch,
10475inline cl_int enqueueReadBufferRect(
10478 const array<size_type, 2>& buffer_offset,
10479 const array<size_type, 2>& host_offset,
10480 const array<size_type, 2>& region,
10481 size_type buffer_row_pitch,
10482 size_type buffer_slice_pitch,
10483 size_type host_row_pitch,
10484 size_type host_slice_pitch,
10486 const vector<Event>* events =
nullptr,
10487 Event* event =
nullptr)
10489 return enqueueReadBufferRect(
10492 { buffer_offset[0], buffer_offset[1], 0 },
10493 { host_offset[0], host_offset[1], 0 },
10494 { region[0], region[1], 1 },
10496 buffer_slice_pitch,
10504inline cl_int enqueueWriteBufferRect(
10507 const array<size_type, 3>& buffer_offset,
10508 const array<size_type, 3>& host_offset,
10509 const array<size_type, 3>& region,
10510 size_type buffer_row_pitch,
10511 size_type buffer_slice_pitch,
10512 size_type host_row_pitch,
10513 size_type host_slice_pitch,
10515 const vector<Event>* events =
nullptr,
10516 Event* event =
nullptr)
10519 CommandQueue queue = CommandQueue::getDefault(&error);
10521 if (error != CL_SUCCESS) {
10525 return queue.enqueueWriteBufferRect(
10532 buffer_slice_pitch,
10540inline cl_int enqueueWriteBufferRect(
10543 const array<size_type, 2>& buffer_offset,
10544 const array<size_type, 2>& host_offset,
10545 const array<size_type, 2>& region,
10546 size_type buffer_row_pitch,
10547 size_type buffer_slice_pitch,
10548 size_type host_row_pitch,
10549 size_type host_slice_pitch,
10551 const vector<Event>* events =
nullptr,
10552 Event* event =
nullptr)
10554 return enqueueWriteBufferRect(
10557 { buffer_offset[0], buffer_offset[1], 0 },
10558 { host_offset[0], host_offset[1], 0 },
10559 { region[0], region[1], 1 },
10561 buffer_slice_pitch,
10569inline cl_int enqueueCopyBufferRect(
10572 const array<size_type, 3>& src_origin,
10573 const array<size_type, 3>& dst_origin,
10574 const array<size_type, 3>& region,
10575 size_type src_row_pitch,
10576 size_type src_slice_pitch,
10577 size_type dst_row_pitch,
10578 size_type dst_slice_pitch,
10579 const vector<Event>* events =
nullptr,
10580 Event* event =
nullptr)
10583 CommandQueue queue = CommandQueue::getDefault(&error);
10585 if (error != CL_SUCCESS) {
10589 return queue.enqueueCopyBufferRect(
10603inline cl_int enqueueCopyBufferRect(
10606 const array<size_type, 2>& src_origin,
10607 const array<size_type, 2>& dst_origin,
10608 const array<size_type, 2>& region,
10609 size_type src_row_pitch,
10610 size_type src_slice_pitch,
10611 size_type dst_row_pitch,
10612 size_type dst_slice_pitch,
10613 const vector<Event>* events =
nullptr,
10614 Event* event =
nullptr)
10616 return enqueueCopyBufferRect(
10619 { src_origin[0], src_origin[1], 0 },
10620 { dst_origin[0], dst_origin[1], 0 },
10621 { region[0], region[1], 1 },
10631inline cl_int enqueueReadImage(
10632 const Image& image,
10634 const array<size_type, 3>& origin,
10635 const array<size_type, 3>& region,
10636 size_type row_pitch,
10637 size_type slice_pitch,
10639 const vector<Event>* events =
nullptr,
10640 Event* event =
nullptr)
10643 CommandQueue queue = CommandQueue::getDefault(&error);
10645 if (error != CL_SUCCESS) {
10649 return queue.enqueueReadImage(
10661inline cl_int enqueueReadImage(
10662 const Image& image,
10664 const array<size_type, 2>& origin,
10665 const array<size_type, 2>& region,
10666 size_type row_pitch,
10667 size_type slice_pitch,
10669 const vector<Event>* events =
nullptr,
10670 Event* event =
nullptr)
10672 return enqueueReadImage(
10675 { origin[0], origin[1], 0 },
10676 { region[0], region[1], 1 },
10684inline cl_int enqueueWriteImage(
10685 const Image& image,
10687 const array<size_type, 3>& origin,
10688 const array<size_type, 3>& region,
10689 size_type row_pitch,
10690 size_type slice_pitch,
10692 const vector<Event>* events =
nullptr,
10693 Event* event =
nullptr)
10696 CommandQueue queue = CommandQueue::getDefault(&error);
10698 if (error != CL_SUCCESS) {
10702 return queue.enqueueWriteImage(
10714inline cl_int enqueueWriteImage(
10715 const Image& image,
10717 const array<size_type, 2>& origin,
10718 const array<size_type, 2>& region,
10719 size_type row_pitch,
10720 size_type slice_pitch,
10722 const vector<Event>* events =
nullptr,
10723 Event* event =
nullptr)
10725 return enqueueWriteImage(
10728 { origin[0], origin[1], 0 },
10729 { region[0], region[1], 1 },
10737inline cl_int enqueueCopyImage(
10740 const array<size_type, 3>& src_origin,
10741 const array<size_type, 3>& dst_origin,
10742 const array<size_type, 3>& region,
10743 const vector<Event>* events =
nullptr,
10744 Event* event =
nullptr)
10747 CommandQueue queue = CommandQueue::getDefault(&error);
10749 if (error != CL_SUCCESS) {
10753 return queue.enqueueCopyImage(
10763inline cl_int enqueueCopyImage(
10766 const array<size_type, 2>& src_origin,
10767 const array<size_type, 2>& dst_origin,
10768 const array<size_type, 2>& region,
10769 const vector<Event>* events =
nullptr,
10770 Event* event =
nullptr)
10772 return enqueueCopyImage(
10775 { src_origin[0], src_origin[1], 0 },
10776 { dst_origin[0], dst_origin[1], 0 },
10777 { region[0], region[1], 1 },
10782inline cl_int enqueueCopyImageToBuffer(
10785 const array<size_type, 3>& src_origin,
10786 const array<size_type, 3>& region,
10787 size_type dst_offset,
10788 const vector<Event>* events =
nullptr,
10789 Event* event =
nullptr)
10792 CommandQueue queue = CommandQueue::getDefault(&error);
10794 if (error != CL_SUCCESS) {
10798 return queue.enqueueCopyImageToBuffer(
10808inline cl_int enqueueCopyImageToBuffer(
10811 const array<size_type, 2>& src_origin,
10812 const array<size_type, 2>& region,
10813 size_type dst_offset,
10814 const vector<Event>* events =
nullptr,
10815 Event* event =
nullptr)
10817 return enqueueCopyImageToBuffer(
10820 { src_origin[0], src_origin[1], 0 },
10821 { region[0], region[1], 1 },
10827inline cl_int enqueueCopyBufferToImage(
10830 size_type src_offset,
10831 const array<size_type, 3>& dst_origin,
10832 const array<size_type, 3>& region,
10833 const vector<Event>* events =
nullptr,
10834 Event* event =
nullptr)
10837 CommandQueue queue = CommandQueue::getDefault(&error);
10839 if (error != CL_SUCCESS) {
10843 return queue.enqueueCopyBufferToImage(
10853inline cl_int enqueueCopyBufferToImage(
10856 size_type src_offset,
10857 const array<size_type, 2>& dst_origin,
10858 const array<size_type, 2>& region,
10859 const vector<Event>* events =
nullptr,
10860 Event* event =
nullptr)
10863 CommandQueue queue = CommandQueue::getDefault(&error);
10865 if (error != CL_SUCCESS) {
10869 return enqueueCopyBufferToImage(
10873 { dst_origin[0], dst_origin[1], 0 },
10874 { region[0], region[1], 1 },
10879inline cl_int flush(
void)
10882 CommandQueue queue = CommandQueue::getDefault(&error);
10884 if (error != CL_SUCCESS) {
10888 return queue.flush();
10891inline cl_int finish(
void)
10894 CommandQueue queue = CommandQueue::getDefault(&error);
10896 if (error != CL_SUCCESS) {
10901 return queue.finish();
10911 vector<Event> events_;
10913 template<
typename... Ts>
10918 queue_(CommandQueue::getDefault()),
10919 offset_(NullRange),
10926 EnqueueArgs(NDRange global, NDRange local) :
10927 queue_(CommandQueue::getDefault()),
10928 offset_(NullRange),
10935 EnqueueArgs(NDRange offset, NDRange global, NDRange local) :
10936 queue_(CommandQueue::getDefault()),
10944 EnqueueArgs(Event e, NDRange global) :
10945 queue_(CommandQueue::getDefault()),
10946 offset_(NullRange),
10950 events_.push_back(e);
10953 EnqueueArgs(Event e, NDRange global, NDRange local) :
10954 queue_(CommandQueue::getDefault()),
10955 offset_(NullRange),
10959 events_.push_back(e);
10962 EnqueueArgs(Event e, NDRange offset, NDRange global, NDRange local) :
10963 queue_(CommandQueue::getDefault()),
10968 events_.push_back(e);
10971 EnqueueArgs(
const vector<Event> &events, NDRange global) :
10972 queue_(CommandQueue::getDefault()),
10973 offset_(NullRange),
10981 EnqueueArgs(
const vector<Event> &events, NDRange global, NDRange local) :
10982 queue_(CommandQueue::getDefault()),
10983 offset_(NullRange),
10991 EnqueueArgs(
const vector<Event> &events, NDRange offset, NDRange global, NDRange local) :
10992 queue_(CommandQueue::getDefault()),
11001 EnqueueArgs(CommandQueue &queue, NDRange global) :
11003 offset_(NullRange),
11010 EnqueueArgs(CommandQueue &queue, NDRange global, NDRange local) :
11012 offset_(NullRange),
11019 EnqueueArgs(CommandQueue &queue, NDRange offset, NDRange global, NDRange local) :
11028 EnqueueArgs(CommandQueue &queue, Event e, NDRange global) :
11030 offset_(NullRange),
11034 events_.push_back(e);
11037 EnqueueArgs(CommandQueue &queue, Event e, NDRange global, NDRange local) :
11039 offset_(NullRange),
11043 events_.push_back(e);
11046 EnqueueArgs(CommandQueue &queue, Event e, NDRange offset, NDRange global, NDRange local) :
11052 events_.push_back(e);
11055 EnqueueArgs(CommandQueue &queue,
const vector<Event> &events, NDRange global) :
11057 offset_(NullRange),
11065 EnqueueArgs(CommandQueue &queue,
const vector<Event> &events, NDRange global, NDRange local) :
11067 offset_(NullRange),
11075 EnqueueArgs(CommandQueue &queue,
const vector<Event> &events, NDRange offset, NDRange global, NDRange local) :
11094template<
typename... Ts>
11100 template<
int index,
typename T0,
typename... T1s>
11101 void setArgs(T0&& t0, T1s&&... t1s)
11103 kernel_.
setArg(index, t0);
11104 setArgs<index + 1, T1s...>(std::forward<T1s>(t1s)...);
11107 template<
int index,
typename T0>
11108 void setArgs(T0&& t0)
11110 kernel_.setArg(index, t0);
11113 template<
int index>
11120 KernelFunctor(
Kernel kernel) : kernel_(kernel)
11126 cl_int * err =
nullptr) :
11127 kernel_(program, name.c_str(), err)
11143 setArgs<0>(std::forward<Ts>(ts)...);
11145 args.queue_.enqueueNDRangeKernel(
11168 setArgs<0>(std::forward<Ts>(ts)...);
11170 error = args.queue_.enqueueNDRangeKernel(
11181#if CL_HPP_TARGET_OPENCL_VERSION >= 200
11182 cl_int setSVMPointers(
const vector<void*> &pointerList)
11187 template<
typename T0,
typename... T1s>
11188 cl_int setSVMPointers(
const T0 &t0, T1s &... ts)
11200namespace compatibility {
11205 template<
typename... Ts>
11210 FunctorType functor_;
11215 cl_int * err =
nullptr) :
11216 functor_(FunctorType(program, name, err))
11221 functor_(FunctorType(kernel))
11237 enqueueArgs, args...);
11242#ifdef cl_khr_semaphore
11244#ifdef cl_khr_external_semaphore
11245enum ExternalSemaphoreType : cl_external_semaphore_handle_type_khr
11248#ifdef cl_khr_external_semaphore_opaque_fd
11249 OpaqueFd = CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR,
11251#ifdef cl_khr_external_semaphore_sync_fd
11252 SyncFd = CL_SEMAPHORE_HANDLE_SYNC_FD_KHR,
11254#ifdef cl_khr_external_semaphore_win32
11255 OpaqueWin32 = CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KHR,
11256 OpaqueWin32Kmt = CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KMT_KHR,
11264 Semaphore() : detail::Wrapper<cl_type>() {}
11266 const Context &context,
11267 const vector<cl_semaphore_properties_khr>& sema_props,
11268 cl_int *err =
nullptr)
11271 std::call_once(ext_init_, initExtensions, context);
11273 cl_int error = CL_INVALID_OPERATION;
11275 if (pfn_clCreateSemaphoreWithPropertiesKHR)
11277 object_ = pfn_clCreateSemaphoreWithPropertiesKHR(
11283 detail::errHandler(error, __CREATE_SEMAPHORE_KHR_WITH_PROPERTIES_ERR);
11285 if (err !=
nullptr) {
11290 const vector<cl_semaphore_properties_khr>& sema_props,
11291 cl_int* err =
nullptr):Semaphore(Context::getDefault(err), sema_props, err) {}
11293 explicit Semaphore(
const cl_semaphore_khr& semaphore,
bool retainObject =
false) :
11294 detail::Wrapper<cl_type>(semaphore, retainObject) {}
11295 Semaphore& operator = (
const cl_semaphore_khr& rhs) {
11296 detail::Wrapper<cl_type>::operator=(rhs);
11299 template <
typename T>
11300 cl_int getInfo(cl_semaphore_info_khr name, T* param)
const
11302 if (pfn_clGetSemaphoreInfoKHR ==
nullptr) {
11303 return detail::errHandler(CL_INVALID_OPERATION,
11304 __GET_SEMAPHORE_KHR_INFO_ERR);
11307 return detail::errHandler(
11308 detail::getInfo(pfn_clGetSemaphoreInfoKHR, object_, name, param),
11309 __GET_SEMAPHORE_KHR_INFO_ERR);
11311 template <cl_semaphore_info_khr name>
typename
11312 detail::param_traits<detail::cl_semaphore_info_khr, name>::param_type
11313 getInfo(cl_int* err =
nullptr)
const
11315 typename detail::param_traits<
11316 detail::cl_semaphore_info_khr, name>::param_type param;
11317 cl_int result = getInfo(name, ¶m);
11318 if (err !=
nullptr) {
11324#ifdef cl_khr_external_semaphore
11325 template <
typename T>
11326 cl_int getHandleForTypeKHR(
11327 const Device& device, cl_external_semaphore_handle_type_khr name, T* param)
const
11329 if (pfn_clGetSemaphoreHandleForTypeKHR ==
nullptr) {
11330 return detail::errHandler(CL_INVALID_OPERATION,
11331 __GET_SEMAPHORE_HANDLE_FOR_TYPE_KHR_ERR);
11334 return detail::errHandler(
11336 pfn_clGetSemaphoreHandleForTypeKHR, object_, device(), name, param),
11337 __GET_SEMAPHORE_HANDLE_FOR_TYPE_KHR_ERR);
11340 template <cl_external_semaphore_handle_type_khr type>
typename
11341 detail::param_traits<detail::cl_external_semaphore_handle_type_khr, type>::param_type
11342 getHandleForTypeKHR(
const Device& device, cl_int* err =
nullptr)
const
11344 typename detail::param_traits<
11345 detail::cl_external_semaphore_handle_type_khr, type>::param_type param;
11346 cl_int result = getHandleForTypeKHR(device, type, ¶m);
11347 if (err !=
nullptr) {
11356 if (pfn_clRetainSemaphoreKHR ==
nullptr) {
11357 return detail::errHandler(CL_INVALID_OPERATION,
11358 __RETAIN_SEMAPHORE_KHR_ERR);
11360 return pfn_clRetainSemaphoreKHR(object_);
11365 if (pfn_clReleaseSemaphoreKHR ==
nullptr) {
11366 return detail::errHandler(CL_INVALID_OPERATION,
11367 __RELEASE_SEMAPHORE_KHR_ERR);
11369 return pfn_clReleaseSemaphoreKHR(object_);
11373 static std::once_flag ext_init_;
11375 static void initExtensions(
const Context& context)
11377#if CL_HPP_TARGET_OPENCL_VERSION >= 120
11378 Device device = context.getInfo<CL_CONTEXT_DEVICES>().at(0);
11379 cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>()();
11380 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCreateSemaphoreWithPropertiesKHR);
11381 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clReleaseSemaphoreKHR);
11382 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clRetainSemaphoreKHR);
11383 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueWaitSemaphoresKHR);
11384 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueSignalSemaphoresKHR);
11385 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clGetSemaphoreInfoKHR);
11386#ifdef cl_khr_external_semaphore
11387 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clGetSemaphoreHandleForTypeKHR);
11391 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateSemaphoreWithPropertiesKHR);
11392 CL_HPP_INIT_CL_EXT_FCN_PTR_(clReleaseSemaphoreKHR);
11393 CL_HPP_INIT_CL_EXT_FCN_PTR_(clRetainSemaphoreKHR);
11394 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueWaitSemaphoresKHR);
11395 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueSignalSemaphoresKHR);
11396 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetSemaphoreInfoKHR);
11397#ifdef cl_khr_external_semaphore
11398 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetSemaphoreHandleForTypeKHR);
11402 if ((pfn_clCreateSemaphoreWithPropertiesKHR ==
nullptr) &&
11403 (pfn_clReleaseSemaphoreKHR ==
nullptr) &&
11404 (pfn_clRetainSemaphoreKHR ==
nullptr) &&
11405 (pfn_clEnqueueWaitSemaphoresKHR ==
nullptr) &&
11406 (pfn_clEnqueueSignalSemaphoresKHR ==
nullptr) &&
11407#ifdef cl_khr_external_semaphore
11408 (pfn_clGetSemaphoreHandleForTypeKHR ==
nullptr) &&
11410 (pfn_clGetSemaphoreInfoKHR ==
nullptr))
11412 detail::errHandler(CL_INVALID_VALUE, __CREATE_SEMAPHORE_KHR_WITH_PROPERTIES_ERR);
11418CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Semaphore::ext_init_;
11420inline cl_int CommandQueue::enqueueWaitSemaphores(
11421 const vector<Semaphore> &sema_objects,
11422 const vector<cl_semaphore_payload_khr> &sema_payloads,
11423 const vector<Event>* events_wait_list,
11424 Event *event)
const
11427 cl_int err = CL_INVALID_OPERATION;
11429 if (pfn_clEnqueueWaitSemaphoresKHR !=
nullptr) {
11430 err = pfn_clEnqueueWaitSemaphoresKHR(
11432 (cl_uint)sema_objects.size(),
11433 (
const cl_semaphore_khr *) &sema_objects.front(),
11434 (sema_payloads.size() > 0) ? &sema_payloads.front() :
nullptr,
11435 (events_wait_list !=
nullptr) ? (cl_uint) events_wait_list->size() : 0,
11436 (events_wait_list !=
nullptr && events_wait_list->size() > 0) ? (
const cl_event*) &events_wait_list->front() :
nullptr,
11437 (event !=
nullptr) ? &tmp :
nullptr);
11440 detail::errHandler(err, __ENQUEUE_WAIT_SEMAPHORE_KHR_ERR);
11442 if (event !=
nullptr && err == CL_SUCCESS)
11448inline cl_int CommandQueue::enqueueSignalSemaphores(
11449 const vector<Semaphore> &sema_objects,
11450 const vector<cl_semaphore_payload_khr>& sema_payloads,
11451 const vector<Event>* events_wait_list,
11455 cl_int err = CL_INVALID_OPERATION;
11457 if (pfn_clEnqueueSignalSemaphoresKHR !=
nullptr) {
11458 err = pfn_clEnqueueSignalSemaphoresKHR(
11460 (cl_uint)sema_objects.size(),
11461 (
const cl_semaphore_khr*) &sema_objects.front(),
11462 (sema_payloads.size() > 0) ? &sema_payloads.front() :
nullptr,
11463 (events_wait_list !=
nullptr) ? (cl_uint) events_wait_list->size() : 0,
11464 (events_wait_list !=
nullptr && events_wait_list->size() > 0) ? (
const cl_event*) &events_wait_list->front() :
nullptr,
11465 (event !=
nullptr) ? &tmp :
nullptr);
11468 detail::errHandler(err, __ENQUEUE_SIGNAL_SEMAPHORE_KHR_ERR);
11470 if (event !=
nullptr && err == CL_SUCCESS)
11478#if defined(cl_khr_command_buffer)
11482class CommandBufferKhr :
public detail::Wrapper<cl_command_buffer_khr>
11486 CommandBufferKhr() : detail::Wrapper<cl_type>() { }
11488 explicit CommandBufferKhr(
const vector<CommandQueue> &queues,
11489 cl_command_buffer_properties_khr properties = 0,
11490 cl_int* errcode_ret =
nullptr)
11492 cl_command_buffer_properties_khr command_buffer_properties[] = {
11493 CL_COMMAND_BUFFER_FLAGS_KHR, properties, 0
11497 std::call_once(ext_init_, [&] { initExtensions(queues[0].getInfo<CL_QUEUE_DEVICE>()); });
11498 cl_int error = CL_INVALID_OPERATION;
11500 static_assert(
sizeof(cl::CommandQueue) ==
sizeof(cl_command_queue),
11501 "Size of cl::CommandQueue must be equal to size of cl_command_queue");
11503 if (pfn_clCreateCommandBufferKHR)
11505 object_ = pfn_clCreateCommandBufferKHR((cl_uint) queues.size(),
11506 (
const cl_command_queue *) &queues.front(),
11507 command_buffer_properties,
11511 detail::errHandler(error, __CREATE_COMMAND_BUFFER_KHR_ERR);
11512 if (errcode_ret !=
nullptr) {
11513 *errcode_ret = error;
11517 explicit CommandBufferKhr(
const cl_command_buffer_khr& commandBufferKhr,
bool retainObject =
false) :
11518 detail::Wrapper<cl_type>(commandBufferKhr, retainObject) { }
11520 CommandBufferKhr& operator=(
const cl_command_buffer_khr& rhs)
11522 detail::Wrapper<cl_type>::operator=(rhs);
11526 template <
typename T>
11527 cl_int getInfo(cl_command_buffer_info_khr name, T* param)
const
11529 if (pfn_clGetCommandBufferInfoKHR ==
nullptr) {
11530 return detail::errHandler(CL_INVALID_OPERATION,
11531 __GET_COMMAND_BUFFER_INFO_KHR_ERR);
11533 return detail::errHandler(
11534 detail::getInfo(pfn_clGetCommandBufferInfoKHR, object_, name, param),
11535 __GET_COMMAND_BUFFER_INFO_KHR_ERR);
11538 template <cl_command_buffer_info_khr name>
typename
11539 detail::param_traits<detail::cl_command_buffer_info_khr, name>::param_type
11540 getInfo(cl_int* err =
nullptr)
const
11542 typename detail::param_traits<
11543 detail::cl_command_buffer_info_khr, name>::param_type param;
11544 cl_int result = getInfo(name, ¶m);
11545 if (err !=
nullptr) {
11551 cl_int finalizeCommandBuffer()
const
11553 if (pfn_clFinalizeCommandBufferKHR ==
nullptr) {
11554 return detail::errHandler(CL_INVALID_OPERATION, __FINALIZE_COMMAND_BUFFER_KHR_ERR);
11556 return detail::errHandler(pfn_clFinalizeCommandBufferKHR(object_), __FINALIZE_COMMAND_BUFFER_KHR_ERR);
11559 cl_int enqueueCommandBuffer(vector<CommandQueue> &queues,
11560 const vector<Event>* events =
nullptr,
11561 Event* event =
nullptr)
11563 if (pfn_clEnqueueCommandBufferKHR ==
nullptr) {
11564 return detail::errHandler(CL_INVALID_OPERATION,
11565 __ENQUEUE_COMMAND_BUFFER_KHR_ERR);
11568 static_assert(
sizeof(cl::CommandQueue) ==
sizeof(cl_command_queue),
11569 "Size of cl::CommandQueue must be equal to size of cl_command_queue");
11571 return detail::errHandler(pfn_clEnqueueCommandBufferKHR((cl_uint) queues.size(),
11572 (cl_command_queue *) &queues.front(),
11574 (events !=
nullptr) ? (cl_uint) events->size() : 0,
11575 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
11576 (cl_event*) event),
11577 __ENQUEUE_COMMAND_BUFFER_KHR_ERR);
11580 cl_int commandBarrierWithWaitList(
const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11581 cl_sync_point_khr* sync_point =
nullptr,
11582 MutableCommandKhr* mutable_handle =
nullptr,
11583 const CommandQueue* command_queue =
nullptr)
11585 if (pfn_clCommandBarrierWithWaitListKHR ==
nullptr) {
11586 return detail::errHandler(CL_INVALID_OPERATION,
11587 __COMMAND_BARRIER_WITH_WAIT_LIST_KHR_ERR);
11590 cl_sync_point_khr tmp_sync_point;
11591 cl_int error = detail::errHandler(
11592 pfn_clCommandBarrierWithWaitListKHR(object_,
11593 (command_queue !=
nullptr) ? (*command_queue)() :
nullptr,
11594#
if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
11597 (sync_points_vec !=
nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11598 (sync_points_vec !=
nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() :
nullptr,
11599 (sync_point !=
nullptr) ? &tmp_sync_point :
nullptr,
11600 (cl_mutable_command_khr*) mutable_handle),
11601 __COMMAND_BARRIER_WITH_WAIT_LIST_KHR_ERR);
11603 if (sync_point !=
nullptr && error == CL_SUCCESS)
11604 *sync_point = tmp_sync_point;
11609 cl_int commandCopyBuffer(
const Buffer& src,
11611 size_type src_offset,
11612 size_type dst_offset,
11614 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11615 cl_sync_point_khr* sync_point =
nullptr,
11616 MutableCommandKhr* mutable_handle =
nullptr,
11617 const CommandQueue* command_queue =
nullptr)
11619 if (pfn_clCommandCopyBufferKHR ==
nullptr) {
11620 return detail::errHandler(CL_INVALID_OPERATION,
11621 __COMMAND_COPY_BUFFER_KHR_ERR);
11624 cl_sync_point_khr tmp_sync_point;
11625 cl_int error = detail::errHandler(
11626 pfn_clCommandCopyBufferKHR(object_,
11627 (command_queue !=
nullptr) ? (*command_queue)() :
nullptr,
11628#
if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
11636 (sync_points_vec !=
nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11637 (sync_points_vec !=
nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() :
nullptr,
11638 (sync_point !=
nullptr) ? &tmp_sync_point :
nullptr,
11639 (cl_mutable_command_khr*) mutable_handle),
11640 __COMMAND_COPY_BUFFER_KHR_ERR);
11642 if (sync_point !=
nullptr && error == CL_SUCCESS)
11643 *sync_point = tmp_sync_point;
11648 cl_int commandCopyBufferRect(
const Buffer& src,
11650 const array<size_type, 3>& src_origin,
11651 const array<size_type, 3>& dst_origin,
11652 const array<size_type, 3>& region,
11653 size_type src_row_pitch,
11654 size_type src_slice_pitch,
11655 size_type dst_row_pitch,
11656 size_type dst_slice_pitch,
11657 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11658 cl_sync_point_khr* sync_point =
nullptr,
11659 MutableCommandKhr* mutable_handle =
nullptr,
11660 const CommandQueue* command_queue =
nullptr)
11662 if (pfn_clCommandCopyBufferRectKHR ==
nullptr) {
11663 return detail::errHandler(CL_INVALID_OPERATION,
11664 __COMMAND_COPY_BUFFER_RECT_KHR_ERR);
11667 cl_sync_point_khr tmp_sync_point;
11668 cl_int error = detail::errHandler(
11669 pfn_clCommandCopyBufferRectKHR(object_,
11670 (command_queue !=
nullptr) ? (*command_queue)() :
nullptr,
11671#
if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
11683 (sync_points_vec !=
nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11684 (sync_points_vec !=
nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() :
nullptr,
11685 (sync_point !=
nullptr) ? &tmp_sync_point :
nullptr,
11686 (cl_mutable_command_khr*) mutable_handle),
11687 __COMMAND_COPY_BUFFER_RECT_KHR_ERR);
11689 if (sync_point !=
nullptr && error == CL_SUCCESS)
11690 *sync_point = tmp_sync_point;
11695 cl_int commandCopyBufferToImage(
const Buffer& src,
11697 size_type src_offset,
11698 const array<size_type, 3>& dst_origin,
11699 const array<size_type, 3>& region,
11700 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11701 cl_sync_point_khr* sync_point =
nullptr,
11702 MutableCommandKhr* mutable_handle =
nullptr,
11703 const CommandQueue* command_queue =
nullptr)
11705 if (pfn_clCommandCopyBufferToImageKHR ==
nullptr) {
11706 return detail::errHandler(CL_INVALID_OPERATION,
11707 __COMMAND_COPY_BUFFER_TO_IMAGE_KHR_ERR);
11710 cl_sync_point_khr tmp_sync_point;
11711 cl_int error = detail::errHandler(
11712 pfn_clCommandCopyBufferToImageKHR(object_,
11713 (command_queue !=
nullptr) ? (*command_queue)() :
nullptr,
11714#
if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
11722 (sync_points_vec !=
nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11723 (sync_points_vec !=
nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() :
nullptr,
11724 (sync_point !=
nullptr) ? &tmp_sync_point :
nullptr,
11725 (cl_mutable_command_khr*) mutable_handle),
11726 __COMMAND_COPY_BUFFER_TO_IMAGE_KHR_ERR);
11728 if (sync_point !=
nullptr && error == CL_SUCCESS)
11729 *sync_point = tmp_sync_point;
11734 cl_int commandCopyImage(
const Image& src,
11736 const array<size_type, 3>& src_origin,
11737 const array<size_type, 3>& dst_origin,
11738 const array<size_type, 3>& region,
11739 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11740 cl_sync_point_khr* sync_point =
nullptr,
11741 MutableCommandKhr* mutable_handle =
nullptr,
11742 const CommandQueue* command_queue =
nullptr)
11744 if (pfn_clCommandCopyImageKHR ==
nullptr) {
11745 return detail::errHandler(CL_INVALID_OPERATION,
11746 __COMMAND_COPY_IMAGE_KHR_ERR);
11749 cl_sync_point_khr tmp_sync_point;
11750 cl_int error = detail::errHandler(
11751 pfn_clCommandCopyImageKHR(object_,
11752 (command_queue !=
nullptr) ? (*command_queue)() :
nullptr,
11753#
if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
11761 (sync_points_vec !=
nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11762 (sync_points_vec !=
nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() :
nullptr,
11763 (sync_point !=
nullptr) ? &tmp_sync_point :
nullptr,
11764 (cl_mutable_command_khr*) mutable_handle),
11765 __COMMAND_COPY_IMAGE_KHR_ERR);
11767 if (sync_point !=
nullptr && error == CL_SUCCESS)
11768 *sync_point = tmp_sync_point;
11773 cl_int commandCopyImageToBuffer(
const Image& src,
11775 const array<size_type, 3>& src_origin,
11776 const array<size_type, 3>& region,
11777 size_type dst_offset,
11778 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11779 cl_sync_point_khr* sync_point =
nullptr,
11780 MutableCommandKhr* mutable_handle =
nullptr,
11781 const CommandQueue* command_queue =
nullptr)
11783 if (pfn_clCommandCopyImageToBufferKHR ==
nullptr) {
11784 return detail::errHandler(CL_INVALID_OPERATION,
11785 __COMMAND_COPY_IMAGE_TO_BUFFER_KHR_ERR);
11788 cl_sync_point_khr tmp_sync_point;
11789 cl_int error = detail::errHandler(
11790 pfn_clCommandCopyImageToBufferKHR(object_,
11791 (command_queue !=
nullptr) ? (*command_queue)() :
nullptr,
11792#
if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
11800 (sync_points_vec !=
nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11801 (sync_points_vec !=
nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() :
nullptr,
11802 (sync_point !=
nullptr) ? &tmp_sync_point :
nullptr,
11803 (cl_mutable_command_khr*) mutable_handle),
11804 __COMMAND_COPY_IMAGE_TO_BUFFER_KHR_ERR);
11806 if (sync_point !=
nullptr && error == CL_SUCCESS)
11807 *sync_point = tmp_sync_point;
11812 template<
typename PatternType>
11813 cl_int commandFillBuffer(
const Buffer& buffer,
11814 PatternType pattern,
11817 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11818 cl_sync_point_khr* sync_point =
nullptr,
11819 MutableCommandKhr* mutable_handle =
nullptr,
11820 const CommandQueue* command_queue =
nullptr)
11822 if (pfn_clCommandFillBufferKHR ==
nullptr) {
11823 return detail::errHandler(CL_INVALID_OPERATION,
11824 __COMMAND_FILL_BUFFER_KHR_ERR);
11827 cl_sync_point_khr tmp_sync_point;
11828 cl_int error = detail::errHandler(
11829 pfn_clCommandFillBufferKHR(object_,
11830 (command_queue !=
nullptr) ? (*command_queue)() :
nullptr,
11831#
if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
11835 static_cast<void*
>(&pattern),
11836 sizeof(PatternType),
11839 (sync_points_vec !=
nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11840 (sync_points_vec !=
nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() :
nullptr,
11841 (sync_point !=
nullptr) ? &tmp_sync_point :
nullptr,
11842 (cl_mutable_command_khr*) mutable_handle),
11843 __COMMAND_FILL_BUFFER_KHR_ERR);
11845 if (sync_point !=
nullptr && error == CL_SUCCESS)
11846 *sync_point = tmp_sync_point;
11851 cl_int commandFillImage(
const Image& image,
11852 cl_float4 fillColor,
11853 const array<size_type, 3>& origin,
11854 const array<size_type, 3>& region,
11855 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11856 cl_sync_point_khr* sync_point =
nullptr,
11857 MutableCommandKhr* mutable_handle =
nullptr,
11858 const CommandQueue* command_queue =
nullptr)
11860 if (pfn_clCommandFillImageKHR ==
nullptr) {
11861 return detail::errHandler(CL_INVALID_OPERATION,
11862 __COMMAND_FILL_IMAGE_KHR_ERR);
11865 cl_sync_point_khr tmp_sync_point;
11866 cl_int error = detail::errHandler(
11867 pfn_clCommandFillImageKHR(object_,
11868 (command_queue !=
nullptr) ? (*command_queue)() :
nullptr,
11869#
if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
11873 static_cast<void*
>(&fillColor),
11876 (sync_points_vec !=
nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11877 (sync_points_vec !=
nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() :
nullptr,
11878 (sync_point !=
nullptr) ? &tmp_sync_point :
nullptr,
11879 (cl_mutable_command_khr*) mutable_handle),
11880 __COMMAND_FILL_IMAGE_KHR_ERR);
11882 if (sync_point !=
nullptr && error == CL_SUCCESS)
11883 *sync_point = tmp_sync_point;
11888 cl_int commandNDRangeKernel(
11889#
if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
11890 const cl::vector<cl_command_properties_khr> &properties,
11892 const cl::vector<cl_ndrange_kernel_command_properties_khr> &properties,
11894 const Kernel& kernel,
11895 const NDRange& offset,
11896 const NDRange& global,
11897 const NDRange& local = NullRange,
11898 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11899 cl_sync_point_khr* sync_point =
nullptr,
11900 MutableCommandKhr* mutable_handle =
nullptr,
11901 const CommandQueue* command_queue =
nullptr)
11903 if (pfn_clCommandNDRangeKernelKHR ==
nullptr) {
11904 return detail::errHandler(CL_INVALID_OPERATION,
11905 __COMMAND_NDRANGE_KERNEL_KHR_ERR);
11908 cl_sync_point_khr tmp_sync_point;
11909 cl_int error = detail::errHandler(
11910 pfn_clCommandNDRangeKernelKHR(object_,
11911 (command_queue !=
nullptr) ? (*command_queue)() :
nullptr,
11914 (cl_uint) global.dimensions(),
11915 offset.dimensions() != 0 ? (
const size_type*) offset :
nullptr,
11916 (
const size_type*) global,
11917 local.dimensions() != 0 ? (
const size_type*) local :
nullptr,
11918 (sync_points_vec !=
nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11919 (sync_points_vec !=
nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() :
nullptr,
11920 (sync_point !=
nullptr) ? &tmp_sync_point :
nullptr,
11921 (cl_mutable_command_khr*) mutable_handle),
11922 __COMMAND_NDRANGE_KERNEL_KHR_ERR);
11924 if (sync_point !=
nullptr && error == CL_SUCCESS)
11925 *sync_point = tmp_sync_point;
11930#if defined(cl_khr_command_buffer_mutable_dispatch)
11931#if CL_KHR_COMMAND_BUFFER_MUTABLE_DISPATCH_EXTENSION_VERSION < \
11932 CL_MAKE_VERSION(0, 9, 2)
11933 cl_int updateMutableCommands(
const cl_mutable_base_config_khr* mutable_config)
11935 if (pfn_clUpdateMutableCommandsKHR ==
nullptr) {
11936 return detail::errHandler(CL_INVALID_OPERATION,
11937 __UPDATE_MUTABLE_COMMANDS_KHR_ERR);
11939 return detail::errHandler(pfn_clUpdateMutableCommandsKHR(object_, mutable_config),
11940 __UPDATE_MUTABLE_COMMANDS_KHR_ERR);
11943 template <
int ArrayLength>
11944 cl_int updateMutableCommands(std::array<cl_command_buffer_update_type_khr,
11945 ArrayLength> &config_types,
11946 std::array<const void *, ArrayLength> &configs) {
11947 if (pfn_clUpdateMutableCommandsKHR ==
nullptr) {
11948 return detail::errHandler(CL_INVALID_OPERATION,
11949 __UPDATE_MUTABLE_COMMANDS_KHR_ERR);
11951 return detail::errHandler(
11952 pfn_clUpdateMutableCommandsKHR(object_,
static_cast<cl_uint
>(configs.size()),
11953 config_types.data(), configs.data()),
11954 __UPDATE_MUTABLE_COMMANDS_KHR_ERR);
11960 static std::once_flag ext_init_;
11962 static void initExtensions(
const cl::Device& device)
11964#if CL_HPP_TARGET_OPENCL_VERSION >= 120
11965 cl_platform_id platform = device.
getInfo<CL_DEVICE_PLATFORM>()();
11966 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCreateCommandBufferKHR);
11967 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clFinalizeCommandBufferKHR);
11968 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clRetainCommandBufferKHR);
11969 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clReleaseCommandBufferKHR);
11970 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clGetCommandBufferInfoKHR);
11971 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueCommandBufferKHR);
11972 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandBarrierWithWaitListKHR);
11973 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandCopyBufferKHR);
11974 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandCopyBufferRectKHR);
11975 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandCopyBufferToImageKHR);
11976 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandCopyImageKHR);
11977 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandCopyImageToBufferKHR);
11978 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandFillBufferKHR);
11979 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandFillImageKHR);
11980 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandNDRangeKernelKHR);
11981#if defined(cl_khr_command_buffer_mutable_dispatch)
11982 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clUpdateMutableCommandsKHR);
11983 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clGetMutableCommandInfoKHR);
11985#elif CL_HPP_TARGET_OPENCL_VERSION >= 110
11986 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateCommandBufferKHR);
11987 CL_HPP_INIT_CL_EXT_FCN_PTR_(clFinalizeCommandBufferKHR);
11988 CL_HPP_INIT_CL_EXT_FCN_PTR_(clRetainCommandBufferKHR);
11989 CL_HPP_INIT_CL_EXT_FCN_PTR_(clReleaseCommandBufferKHR);
11990 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetCommandBufferInfoKHR);
11991 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueCommandBufferKHR);
11992 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandBarrierWithWaitListKHR);
11993 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandCopyBufferKHR);
11994 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandCopyBufferRectKHR);
11995 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandCopyBufferToImageKHR);
11996 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandCopyImageKHR);
11997 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandCopyImageToBufferKHR);
11998 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandFillBufferKHR);
11999 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandFillImageKHR);
12000 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandNDRangeKernelKHR);
12001#if defined(cl_khr_command_buffer_mutable_dispatch)
12002 CL_HPP_INIT_CL_EXT_FCN_PTR_(clUpdateMutableCommandsKHR);
12003 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetMutableCommandInfoKHR);
12006 if ((pfn_clCreateCommandBufferKHR ==
nullptr) &&
12007 (pfn_clFinalizeCommandBufferKHR ==
nullptr) &&
12008 (pfn_clRetainCommandBufferKHR ==
nullptr) &&
12009 (pfn_clReleaseCommandBufferKHR ==
nullptr) &&
12010 (pfn_clGetCommandBufferInfoKHR ==
nullptr) &&
12011 (pfn_clEnqueueCommandBufferKHR ==
nullptr) &&
12012 (pfn_clCommandBarrierWithWaitListKHR ==
nullptr) &&
12013 (pfn_clCommandCopyBufferKHR ==
nullptr) &&
12014 (pfn_clCommandCopyBufferRectKHR ==
nullptr) &&
12015 (pfn_clCommandCopyBufferToImageKHR ==
nullptr) &&
12016 (pfn_clCommandCopyImageKHR ==
nullptr) &&
12017 (pfn_clCommandCopyImageToBufferKHR ==
nullptr) &&
12018 (pfn_clCommandFillBufferKHR ==
nullptr) &&
12019 (pfn_clCommandFillImageKHR ==
nullptr) &&
12020 (pfn_clCommandNDRangeKernelKHR ==
nullptr)
12021#
if defined(cl_khr_command_buffer_mutable_dispatch)
12022 && (pfn_clUpdateMutableCommandsKHR ==
nullptr)
12023 && (pfn_clGetMutableCommandInfoKHR ==
nullptr)
12027 detail::errHandler(CL_INVALID_VALUE, __CREATE_COMMAND_BUFFER_KHR_ERR);
12032CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag CommandBufferKhr::ext_init_;
12034#if defined(cl_khr_command_buffer_mutable_dispatch)
12038class MutableCommandKhr :
public detail::Wrapper<cl_mutable_command_khr>
12042 MutableCommandKhr() : detail::Wrapper<cl_type>() { }
12044 explicit MutableCommandKhr(
const cl_mutable_command_khr& mutableCommandKhr,
bool retainObject =
false) :
12045 detail::Wrapper<cl_type>(mutableCommandKhr, retainObject) { }
12047 MutableCommandKhr& operator=(
const cl_mutable_command_khr& rhs)
12049 detail::Wrapper<cl_type>::operator=(rhs);
12053 template <
typename T>
12054 cl_int getInfo(cl_mutable_command_info_khr name, T* param)
const
12056 if (pfn_clGetMutableCommandInfoKHR ==
nullptr) {
12057 return detail::errHandler(CL_INVALID_OPERATION,
12058 __GET_MUTABLE_COMMAND_INFO_KHR_ERR);
12060 return detail::errHandler(
12061 detail::getInfo(pfn_clGetMutableCommandInfoKHR, object_, name, param),
12062 __GET_MUTABLE_COMMAND_INFO_KHR_ERR);
12065 template <cl_mutable_command_info_khr name>
typename
12066 detail::param_traits<detail::cl_mutable_command_info_khr, name>::param_type
12067 getInfo(cl_int* err =
nullptr)
const
12069 typename detail::param_traits<
12070 detail::cl_mutable_command_info_khr, name>::param_type param;
12071 cl_int result = getInfo(name, ¶m);
12072 if (err !=
nullptr) {
12083#undef CL_HPP_ERR_STR_
12084#if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS)
12085#undef __GET_DEVICE_INFO_ERR
12086#undef __GET_PLATFORM_INFO_ERR
12087#undef __GET_DEVICE_IDS_ERR
12088#undef __GET_PLATFORM_IDS_ERR
12089#undef __GET_CONTEXT_INFO_ERR
12090#undef __GET_EVENT_INFO_ERR
12091#undef __GET_EVENT_PROFILE_INFO_ERR
12092#undef __GET_MEM_OBJECT_INFO_ERR
12093#undef __GET_IMAGE_INFO_ERR
12094#undef __GET_SAMPLER_INFO_ERR
12095#undef __GET_KERNEL_INFO_ERR
12096#undef __GET_KERNEL_ARG_INFO_ERR
12097#undef __GET_KERNEL_SUB_GROUP_INFO_ERR
12098#undef __GET_KERNEL_WORK_GROUP_INFO_ERR
12099#undef __GET_PROGRAM_INFO_ERR
12100#undef __GET_PROGRAM_BUILD_INFO_ERR
12101#undef __GET_COMMAND_QUEUE_INFO_ERR
12102#undef __CREATE_CONTEXT_ERR
12103#undef __CREATE_CONTEXT_FROM_TYPE_ERR
12104#undef __CREATE_COMMAND_BUFFER_KHR_ERR
12105#undef __GET_COMMAND_BUFFER_INFO_KHR_ERR
12106#undef __FINALIZE_COMMAND_BUFFER_KHR_ERR
12107#undef __ENQUEUE_COMMAND_BUFFER_KHR_ERR
12108#undef __COMMAND_BARRIER_WITH_WAIT_LIST_KHR_ERR
12109#undef __COMMAND_COPY_BUFFER_KHR_ERR
12110#undef __COMMAND_COPY_BUFFER_RECT_KHR_ERR
12111#undef __COMMAND_COPY_BUFFER_TO_IMAGE_KHR_ERR
12112#undef __COMMAND_COPY_IMAGE_KHR_ERR
12113#undef __COMMAND_COPY_IMAGE_TO_BUFFER_KHR_ERR
12114#undef __COMMAND_FILL_BUFFER_KHR_ERR
12115#undef __COMMAND_FILL_IMAGE_KHR_ERR
12116#undef __COMMAND_NDRANGE_KERNEL_KHR_ERR
12117#undef __UPDATE_MUTABLE_COMMANDS_KHR_ERR
12118#undef __GET_MUTABLE_COMMAND_INFO_KHR_ERR
12119#undef __RETAIN_COMMAND_BUFFER_KHR_ERR
12120#undef __RELEASE_COMMAND_BUFFER_KHR_ERR
12121#undef __GET_SUPPORTED_IMAGE_FORMATS_ERR
12122#undef __SET_CONTEXT_DESCTRUCTOR_CALLBACK_ERR
12123#undef __CREATE_BUFFER_ERR
12125#undef __CREATE_SUBBUFFER_ERR
12126#undef __CREATE_GL_BUFFER_ERR
12127#undef __CREATE_GL_RENDER_BUFFER_ERR
12128#undef __GET_GL_OBJECT_INFO_ERR
12129#undef __CREATE_IMAGE_ERR
12130#undef __CREATE_GL_TEXTURE_ERR
12131#undef __IMAGE_DIMENSION_ERR
12132#undef __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR
12133#undef __CREATE_USER_EVENT_ERR
12134#undef __SET_USER_EVENT_STATUS_ERR
12135#undef __SET_EVENT_CALLBACK_ERR
12136#undef __WAIT_FOR_EVENTS_ERR
12137#undef __CREATE_KERNEL_ERR
12138#undef __SET_KERNEL_ARGS_ERR
12139#undef __CREATE_PROGRAM_WITH_SOURCE_ERR
12140#undef __CREATE_PROGRAM_WITH_BINARY_ERR
12141#undef __CREATE_PROGRAM_WITH_IL_ERR
12142#undef __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR
12143#undef __BUILD_PROGRAM_ERR
12144#undef __COMPILE_PROGRAM_ERR
12145#undef __LINK_PROGRAM_ERR
12146#undef __CREATE_KERNELS_IN_PROGRAM_ERR
12147#undef __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR
12148#undef __CREATE_SAMPLER_WITH_PROPERTIES_ERR
12149#undef __SET_COMMAND_QUEUE_PROPERTY_ERR
12150#undef __ENQUEUE_READ_BUFFER_ERR
12151#undef __ENQUEUE_READ_BUFFER_RECT_ERR
12152#undef __ENQUEUE_WRITE_BUFFER_ERR
12153#undef __ENQUEUE_WRITE_BUFFER_RECT_ERR
12154#undef __ENQEUE_COPY_BUFFER_ERR
12155#undef __ENQEUE_COPY_BUFFER_RECT_ERR
12156#undef __ENQUEUE_FILL_BUFFER_ERR
12157#undef __ENQUEUE_READ_IMAGE_ERR
12158#undef __ENQUEUE_WRITE_IMAGE_ERR
12159#undef __ENQUEUE_COPY_IMAGE_ERR
12160#undef __ENQUEUE_FILL_IMAGE_ERR
12161#undef __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR
12162#undef __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR
12163#undef __ENQUEUE_MAP_BUFFER_ERR
12164#undef __ENQUEUE_MAP_IMAGE_ERR
12165#undef __ENQUEUE_MAP_SVM_ERR
12166#undef __ENQUEUE_FILL_SVM_ERR
12167#undef __ENQUEUE_COPY_SVM_ERR
12168#undef __ENQUEUE_UNMAP_SVM_ERR
12169#undef __ENQUEUE_MAP_IMAGE_ERR
12170#undef __ENQUEUE_UNMAP_MEM_OBJECT_ERR
12171#undef __ENQUEUE_NDRANGE_KERNEL_ERR
12172#undef __ENQUEUE_NATIVE_KERNEL
12173#undef __ENQUEUE_MIGRATE_MEM_OBJECTS_ERR
12174#undef __ENQUEUE_MIGRATE_SVM_ERR
12175#undef __ENQUEUE_ACQUIRE_GL_ERR
12176#undef __ENQUEUE_RELEASE_GL_ERR
12177#undef __CREATE_PIPE_ERR
12178#undef __GET_PIPE_INFO_ERR
12180#undef __RELEASE_ERR
12183#undef __VECTOR_CAPACITY_ERR
12184#undef __CREATE_SUB_DEVICES_ERR
12185#undef __ENQUEUE_ACQUIRE_EXTERNAL_MEMORY_ERR
12186#undef __ENQUEUE_RELEASE_EXTERNAL_MEMORY_ERR
12187#undef __ENQUEUE_MARKER_ERR
12188#undef __ENQUEUE_WAIT_FOR_EVENTS_ERR
12189#undef __ENQUEUE_BARRIER_ERR
12190#undef __UNLOAD_COMPILER_ERR
12191#undef __CREATE_GL_TEXTURE_2D_ERR
12192#undef __CREATE_GL_TEXTURE_3D_ERR
12193#undef __CREATE_IMAGE2D_ERR
12194#undef __CREATE_IMAGE3D_ERR
12195#undef __CREATE_COMMAND_QUEUE_ERR
12196#undef __ENQUEUE_TASK_ERR
12197#undef __CREATE_SAMPLER_ERR
12198#undef __ENQUEUE_MARKER_WAIT_LIST_ERR
12199#undef __ENQUEUE_BARRIER_WAIT_LIST_ERR
12200#undef __CLONE_KERNEL_ERR
12201#undef __GET_HOST_TIMER_ERR
12202#undef __GET_DEVICE_AND_HOST_TIMER_ERR
12203#undef __GET_SEMAPHORE_KHR_INFO_ERR
12204#undef __CREATE_SEMAPHORE_KHR_WITH_PROPERTIES_ERR
12205#undef __GET_IMAGE_REQUIREMENT_INFO_EXT_ERR
12206#undef __ENQUEUE_WAIT_SEMAPHORE_KHR_ERR
12207#undef __ENQUEUE_SIGNAL_SEMAPHORE_KHR_ERR
12208#undef __RETAIN_SEMAPHORE_KHR_ERR
12209#undef __RELEASE_SEMAPHORE_KHR_ERR
12210#undef __GET_SEMAPHORE_HANDLE_FOR_TYPE_KHR_ERR
12215#undef CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_
12216#undef CL_HPP_INIT_CL_EXT_FCN_PTR_
12217#undef CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_
12219#undef CL_HPP_DEFINE_STATIC_MEMBER_
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().
Class interface for Buffer Memory Objects.
Buffer()
Default constructor - initializes to nullptr.
Buffer createSubBuffer(cl_mem_flags flags, cl_buffer_create_type buffer_create_type, const void *buffer_create_info, cl_int *err=nullptr)
Creates a new buffer object from this.
Buffer & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
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.
cl_int getObjectInfo(cl_gl_object_type *type, cl_GLuint *gl_object_name)
Wrapper for clGetGLObjectInfo().
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 enqueueUnmapSVM(T *ptr, const vector< Event > *events=nullptr, Event *event=nullptr) const
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
CL_API_PREFIX__VERSION_1_1_DEPRECATED cl_int enqueueMarker(Event *event=nullptr) const CL_API_SUFFIX__VERSION_1_1_DEPRECATED
static CommandQueue setDefault(const CommandQueue &default_queue)
std::enable_if< std::is_same< T, cl_float4 >::value||std::is_same< T, cl_int4 >::value||std::is_same< T, cl_uint4 >::value, cl_int >::type enqueueFillImage(const Image &image, T fillColor, const array< size_type, 3 > &origin, const array< size_type, 3 > ®ion, const vector< Event > *events=nullptr, Event *event=nullptr) const
cl_int enqueueMapSVM(T *ptr, cl_bool blocking, cl_map_flags flags, size_type size, const vector< Event > *events=nullptr, Event *event=nullptr) const
cl_int enqueueMigrateSVM(const cl::vector< T * > &svmRawPointers, const cl::vector< size_type > &sizes, cl_mem_migration_flags flags=0, const vector< Event > *events=nullptr, Event *event=nullptr) const
cl_int enqueueMemFillSVM(T *ptr, PatternType pattern, size_type size, const vector< Event > *events=nullptr, Event *event=nullptr) const
CL_API_PREFIX__VERSION_1_1_DEPRECATED cl_int enqueueBarrier() const CL_API_SUFFIX__VERSION_1_1_DEPRECATED
cl_int enqueueBarrierWithWaitList(const vector< Event > *events=nullptr, Event *event=nullptr) const
cl_int enqueueFillBuffer(const Buffer &buffer, PatternType pattern, size_type offset, size_type size, const vector< Event > *events=nullptr, Event *event=nullptr) const
Class interface for cl_context.
Context & operator=(const cl_context &rhs)
Assignment operator from cl_context - takes ownership.
cl_int setDestructorCallback(void(CL_CALLBACK *pfn_notify)(cl_context, void *), void *user_data=nullptr)
Registers a destructor callback function with a context.
static Context setDefault(const Context &default_context)
static Context getDefault(cl_int *err=nullptr)
Returns a singleton context including all devices of CL_DEVICE_TYPE_DEFAULT.
cl_int getSupportedImageFormats(cl_mem_flags flags, cl_mem_object_type type, vector< ImageFormat > *formats) const
Gets a list of supported image formats.
Context()
Default constructor - initializes to nullptr.
cl_int getInfo(cl_context_info name, T *param) const
Wrapper for clGetContextInfo().
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.
static DeviceCommandQueue updateDefault(const Context &context, const Device &device, const DeviceCommandQueue &default_queue, cl_int *err=nullptr)
static DeviceCommandQueue getDefault(const CommandQueue &queue, cl_int *err=nullptr)
static DeviceCommandQueue makeDefault(cl_int *err=nullptr)
Class interface for cl_device_id.
static Device getDefault(cl_int *errResult=nullptr)
Returns the first device on the default context.
Device & operator=(const cl_device_id &rhs)
Assignment operator from cl_device_id.
cl_int getInfo(cl_device_info name, T *param) const
Wrapper for clGetDeviceInfo().
Device()
Default constructor - initializes to nullptr.
cl_ulong getHostTimer(cl_int *error=nullptr)
std::pair< cl_ulong, cl_ulong > getDeviceAndHostTimer(cl_int *error=nullptr)
cl_int createSubDevices(const cl_device_partition_property *properties, vector< Device > *devices)
Wrapper for clCreateSubDevices().
static Device setDefault(const Device &default_device)
Class interface for cl_event.
cl_int setCallback(cl_int type, void(CL_CALLBACK *pfn_notify)(cl_event, cl_int, void *), void *user_data=nullptr)
Registers a user callback function for a specific command execution status.
cl_int getProfilingInfo(cl_profiling_info name, T *param) const
Wrapper for clGetEventProfilingInfo().
cl_int getInfo(cl_event_info name, T *param) const
Wrapper for clGetEventInfo().
cl_int wait() const
Blocks the calling thread until this event completes.
Event()
Default constructor - initializes to nullptr.
Event & operator=(const cl_event &rhs)
Assignment operator from cl_event - takes ownership.
static cl_int waitForEvents(const vector< Event > &events)
Blocks the calling thread until every event specified is complete.
Image interface for arrays of 1D images.
Image interface for 1D buffer images.
Image1D()
Default constructor - initializes to nullptr.
Image1D & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
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.
Image interface for arrays of 2D images.
Class interface for GL 2D Image Memory objects.
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.
Class interface for 2D Image Memory objects.
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.
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.
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...
C++ base class for Image Memory objects.
cl_int getImageInfo(cl_image_info name, T *param) const
Wrapper for clGetImageInfo().
Image & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
Image()
Default constructor - initializes to nullptr.
Event operator()(const EnqueueArgs &args, Ts... ts)
Event result_type
Return type of the functor.
Class interface for cl_kernel.
cl_int setSVMPointers(const vector< void * > &pointerList)
cl_int setArg(cl_uint index, const cl::pointer< T, D > &argPtr)
setArg overload taking a shared_ptr type
Kernel()
Default constructor - initializes to nullptr.
Kernel & operator=(const cl_kernel &rhs)
Assignment operator from cl_kernel - takes ownership.
cl_int enableFineGrainedSystemSVM(bool svmEnabled)
Enable fine-grained system SVM.
Class interface for cl_mem.
Memory()
Default constructor - initializes to nullptr.
Memory & operator=(const cl_mem &rhs)
Assignment operator from cl_mem - takes ownership.
cl_int getInfo(cl_mem_info name, T *param) const
Wrapper for clGetMemObjectInfo().
cl_int setDestructorCallback(void(CL_CALLBACK *pfn_notify)(cl_mem, void *), void *user_data=nullptr)
Registers a callback function to be called when the memory object is no longer needed.
Class interface for specifying NDRange values.
size_type dimensions() const
Queries the number of dimensions in the range.
size_type size() const
Returns the size of the object in bytes based on the.
NDRange()
Default constructor - resulting range has zero dimensions.
Class interface for Pipe Memory Objects.
Pipe()
Default constructor - initializes to nullptr.
cl_int getInfo(cl_pipe_info name, T *param) const
Wrapper for clGetMemObjectInfo().
Pipe & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
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...
std::enable_if<!std::is_pointer< T >::value, cl_int >::type setSpecializationConstant(cl_uint index, const T &value)
Sets a SPIR-V specialization constant.
bool operator==(SVMAllocator const &rhs)
pointer allocate(size_type size, typename cl::SVMAllocator< void, SVMTrait >::const_pointer=0, bool map=true)
size_type max_size() const noexcept
Sampler()
Default constructor - initializes to nullptr.
Sampler & operator=(const cl_sampler &rhs)
Assignment operator from cl_sampler - takes ownership.
cl_int getInfo(cl_sampler_info name, T *param) const
Wrapper for clGetSamplerInfo().
UserEvent()
Default constructor - initializes to nullptr.
UserEvent(const Context &context, cl_int *err=nullptr)
Constructs a user event on a given context.
cl_int setStatus(cl_int status)
Sets the execution status of a user event object.
The OpenCL C++ bindings are defined within this namespace.
cl_int copy(IteratorType startIterator, IteratorType endIterator, cl::Buffer &buffer)
vector< T, cl::SVMAllocator< int, cl::SVMTraitCoarse<> > > coarse_svm_vector
Vector alias to simplify contruction of coarse-grained SVM containers.
LocalSpaceArg Local(size_type size)
Helper function for generating LocalSpaceArg objects.
CL_API_PREFIX__VERSION_1_1_DEPRECATED cl_int UnloadCompiler() CL_API_SUFFIX__VERSION_1_1_DEPRECATED
vector< T, cl::SVMAllocator< int, cl::SVMTraitFine<> > > fine_svm_vector
Vector alias to simplify contruction of fine-grained SVM containers.
vector< T, cl::SVMAllocator< int, cl::SVMTraitAtomic<> > > atomic_svm_vector
Vector alias to simplify contruction of fine-grained SVM containers that support platform atomics.
cl::pointer< T, detail::Deleter< Alloc > > allocate_pointer(const Alloc &alloc_, Args &&... args)
cl_int enqueueUnmapSVM(T *ptr, const vector< Event > *events=nullptr, Event *event=nullptr)
cl_int enqueueMapSVM(T *ptr, cl_bool blocking, cl_map_flags flags, size_type size, const vector< Event > *events=nullptr, Event *event=nullptr)
cl_int mapSVM(cl::vector< T, Alloc > &container)
cl_int unmapSVM(cl::vector< T, Alloc > &container)
Local address wrapper for use with Kernel::setArg.
Event type_(const EnqueueArgs &, Ts...)
Function signature of kernel functor with no event dependency.
Event result_type
Return type of the functor.
static cl_int release(cl_device_id device)
static cl_int retain(cl_device_id device)