326 auto anSVMInt = cl::allocate_svm<int, cl::SVMTraitCoarse<>>();
328 cl::SVMAllocator<Foo, cl::SVMTraitCoarse<cl::SVMTraitReadOnly<>>> svmAllocReadOnly;
329 auto fooPointer = cl::allocate_pointer<Foo>(svmAllocReadOnly);
330 fooPointer->bar = anSVMInt.get();
331 cl::SVMAllocator<int, cl::SVMTraitCoarse<>> svmAlloc;
332 std::vector<int, cl::SVMAllocator<int, cl::SVMTraitCoarse<>>> inputA(numElements, 1, svmAlloc);
333 cl::coarse_svm_vector<int> inputB(numElements, 2, svmAlloc);
336 // Traditional cl_mem allocations
338 std::vector<int> output(numElements, 0xdeadbeef);
339 cl::Buffer outputBuffer(output.begin(), output.end(), false);
340 cl::Pipe aPipe(sizeof(cl_int), numElements / 2);
342 // Default command queue, also passed in as a parameter
343 cl::DeviceCommandQueue defaultDeviceQueue = cl::DeviceCommandQueue::makeDefault(
344 cl::Context::getDefault(), cl::Device::getDefault());
346 auto vectorAddKernel =
348 decltype(fooPointer)&,
350 cl::coarse_svm_vector<int>&,
354 cl::DeviceCommandQueue
355 >(vectorAddProgram, "vectorAdd");
357 // Ensure that the additional SVM pointer is available to the kernel
358 // This one was not passed as a parameter
359 vectorAddKernel.setSVMPointers(anSVMInt);
364 cl::NDRange(numElements/2),
365 cl::NDRange(numElements/2)),
376 cl::copy(outputBuffer, output.begin(), output.end());
378 cl::Device d = cl::Device::getDefault();
380 std::cout << "Output:\n";
381 for (int i = 1; i < numElements; ++i) {
382 std::cout << "\t" << output[i] << "\n";
399#if !defined(CL_HPP_USE_DX_INTEROP) && defined(USE_DX_INTEROP)
400# pragma message("opencl.hpp: USE_DX_INTEROP is deprecated. Define CL_HPP_USE_DX_INTEROP instead")
401# define CL_HPP_USE_DX_INTEROP
403#if !defined(CL_HPP_ENABLE_EXCEPTIONS) && defined(__CL_ENABLE_EXCEPTIONS)
404# pragma message("opencl.hpp: __CL_ENABLE_EXCEPTIONS is deprecated. Define CL_HPP_ENABLE_EXCEPTIONS instead")
405# define CL_HPP_ENABLE_EXCEPTIONS
407#if !defined(CL_HPP_NO_STD_VECTOR) && defined(__NO_STD_VECTOR)
408# pragma message("opencl.hpp: __NO_STD_VECTOR is deprecated. Define CL_HPP_NO_STD_VECTOR instead")
409# define CL_HPP_NO_STD_VECTOR
411#if !defined(CL_HPP_NO_STD_STRING) && defined(__NO_STD_STRING)
412# pragma message("opencl.hpp: __NO_STD_STRING is deprecated. Define CL_HPP_NO_STD_STRING instead")
413# define CL_HPP_NO_STD_STRING
415#if defined(VECTOR_CLASS)
416# pragma message("opencl.hpp: VECTOR_CLASS is deprecated. Alias cl::vector instead")
418#if defined(STRING_CLASS)
419# pragma message("opencl.hpp: STRING_CLASS is deprecated. Alias cl::string instead.")
421#if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS) && defined(__CL_USER_OVERRIDE_ERROR_STRINGS)
422# pragma message("opencl.hpp: __CL_USER_OVERRIDE_ERROR_STRINGS is deprecated. Define CL_HPP_USER_OVERRIDE_ERROR_STRINGS instead")
423# define CL_HPP_USER_OVERRIDE_ERROR_STRINGS
428#if defined(__USE_DEV_VECTOR)
429# pragma message("opencl.hpp: __USE_DEV_VECTOR is no longer supported. Expect compilation errors")
431#if defined(__USE_DEV_STRING)
432# pragma message("opencl.hpp: __USE_DEV_STRING is no longer supported. Expect compilation errors")
436#if !defined(CL_HPP_TARGET_OPENCL_VERSION)
437# pragma message("opencl.hpp: CL_HPP_TARGET_OPENCL_VERSION is not defined. It will default to 300 (OpenCL 3.0)")
438# define CL_HPP_TARGET_OPENCL_VERSION 300
440#if CL_HPP_TARGET_OPENCL_VERSION != 100 && \
441 CL_HPP_TARGET_OPENCL_VERSION != 110 && \
442 CL_HPP_TARGET_OPENCL_VERSION != 120 && \
443 CL_HPP_TARGET_OPENCL_VERSION != 200 && \
444 CL_HPP_TARGET_OPENCL_VERSION != 210 && \
445 CL_HPP_TARGET_OPENCL_VERSION != 220 && \
446 CL_HPP_TARGET_OPENCL_VERSION != 300
447# pragma message("opencl.hpp: CL_HPP_TARGET_OPENCL_VERSION is not a valid value (100, 110, 120, 200, 210, 220 or 300). It will be set to 300 (OpenCL 3.0).")
448# undef CL_HPP_TARGET_OPENCL_VERSION
449# define CL_HPP_TARGET_OPENCL_VERSION 300
453#if defined(CL_TARGET_OPENCL_VERSION)
456#if CL_TARGET_OPENCL_VERSION < CL_HPP_TARGET_OPENCL_VERSION
457# pragma message("CL_TARGET_OPENCL_VERSION is already defined as is lower than CL_HPP_TARGET_OPENCL_VERSION")
460# define CL_TARGET_OPENCL_VERSION CL_HPP_TARGET_OPENCL_VERSION
463#if !defined(CL_HPP_MINIMUM_OPENCL_VERSION)
464# define CL_HPP_MINIMUM_OPENCL_VERSION 200
466#if CL_HPP_MINIMUM_OPENCL_VERSION != 100 && \
467 CL_HPP_MINIMUM_OPENCL_VERSION != 110 && \
468 CL_HPP_MINIMUM_OPENCL_VERSION != 120 && \
469 CL_HPP_MINIMUM_OPENCL_VERSION != 200 && \
470 CL_HPP_MINIMUM_OPENCL_VERSION != 210 && \
471 CL_HPP_MINIMUM_OPENCL_VERSION != 220 && \
472 CL_HPP_MINIMUM_OPENCL_VERSION != 300
473# pragma message("opencl.hpp: CL_HPP_MINIMUM_OPENCL_VERSION is not a valid value (100, 110, 120, 200, 210, 220 or 300). It will be set to 100")
474# undef CL_HPP_MINIMUM_OPENCL_VERSION
475# define CL_HPP_MINIMUM_OPENCL_VERSION 100
477#if CL_HPP_MINIMUM_OPENCL_VERSION > CL_HPP_TARGET_OPENCL_VERSION
478# error "CL_HPP_MINIMUM_OPENCL_VERSION must not be greater than CL_HPP_TARGET_OPENCL_VERSION"
481#if CL_HPP_MINIMUM_OPENCL_VERSION <= 100 && !defined(CL_USE_DEPRECATED_OPENCL_1_0_APIS)
482# define CL_USE_DEPRECATED_OPENCL_1_0_APIS
484#if CL_HPP_MINIMUM_OPENCL_VERSION <= 110 && !defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
485# define CL_USE_DEPRECATED_OPENCL_1_1_APIS
487#if CL_HPP_MINIMUM_OPENCL_VERSION <= 120 && !defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
488# define CL_USE_DEPRECATED_OPENCL_1_2_APIS
490#if CL_HPP_MINIMUM_OPENCL_VERSION <= 200 && !defined(CL_USE_DEPRECATED_OPENCL_2_0_APIS)
491# define CL_USE_DEPRECATED_OPENCL_2_0_APIS
493#if CL_HPP_MINIMUM_OPENCL_VERSION <= 210 && !defined(CL_USE_DEPRECATED_OPENCL_2_1_APIS)
494# define CL_USE_DEPRECATED_OPENCL_2_1_APIS
496#if CL_HPP_MINIMUM_OPENCL_VERSION <= 220 && !defined(CL_USE_DEPRECATED_OPENCL_2_2_APIS)
497# define CL_USE_DEPRECATED_OPENCL_2_2_APIS
504#if defined(CL_HPP_USE_DX_INTEROP)
505#include <CL/cl_d3d10.h>
506#include <CL/cl_dx9_media_sharing.h>
518#if (!defined(_MSC_VER) && __cplusplus < 201103L) || (defined(_MSC_VER) && _MSC_VER < 1700)
519#error Visual studio 2013 or another C++11-supporting compiler required
522#if defined(__APPLE__) || defined(__MACOSX)
523#include <OpenCL/opencl.h>
525#include <CL/opencl.h>
528#if __cplusplus >= 201703L
529# define CL_HPP_DEFINE_STATIC_MEMBER_ inline
530#elif defined(_MSC_VER)
531# define CL_HPP_DEFINE_STATIC_MEMBER_ __declspec(selectany)
532#elif defined(__MINGW32__)
533# define CL_HPP_DEFINE_STATIC_MEMBER_ __attribute__((selectany))
535# define CL_HPP_DEFINE_STATIC_MEMBER_ __attribute__((weak))
540#if !defined(CL_API_PREFIX__VERSION_1_1_DEPRECATED)
541#define CL_API_PREFIX__VERSION_1_1_DEPRECATED
543#if !defined(CL_API_SUFFIX__VERSION_1_1_DEPRECATED)
544#define CL_API_SUFFIX__VERSION_1_1_DEPRECATED
547#if !defined(CL_API_PREFIX__VERSION_1_2_DEPRECATED)
548#define CL_API_PREFIX__VERSION_1_2_DEPRECATED
550#if !defined(CL_API_SUFFIX__VERSION_1_2_DEPRECATED)
551#define CL_API_SUFFIX__VERSION_1_2_DEPRECATED
554#if !defined(CL_API_PREFIX__VERSION_2_2_DEPRECATED)
555#define CL_API_PREFIX__VERSION_2_2_DEPRECATED
557#if !defined(CL_API_SUFFIX__VERSION_2_2_DEPRECATED)
558#define CL_API_SUFFIX__VERSION_2_2_DEPRECATED
561#if !defined(CL_CALLBACK)
574#if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY)
576 using size_type = ::size_t;
580 using size_type = size_t;
585#if defined(CL_HPP_ENABLE_EXCEPTIONS)
589#if !defined(CL_HPP_NO_STD_VECTOR)
592 template <
class T,
class Alloc = std::allocator<T> >
593 using vector = std::vector<T, Alloc>;
597#if !defined(CL_HPP_NO_STD_STRING)
600 using string = std::string;
604#if CL_HPP_TARGET_OPENCL_VERSION >= 200
606#if !defined(CL_HPP_NO_STD_UNIQUE_PTR)
611 template<
class T,
class D>
612 using pointer = std::unique_ptr<T, D>;
616#if !defined(CL_HPP_NO_STD_ARRAY)
619 template <
class T,
size_type N >
620 using array = std::array<T, N>;
626#if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY)
628 namespace compatibility {
643 for (
int i = 0; i < N; ++i) {
648 size_t(
const array<size_type, N> &rhs)
650 for (
int i = 0; i < N; ++i) {
655 size_type& operator[](
int index)
660 const size_type& operator[](
int index)
const
666 operator size_type* () {
return data_; }
669 operator const size_type* ()
const {
return data_; }
671 operator array<size_type, N>()
const
673 array<size_type, N> ret;
675 for (
int i = 0; i < N; ++i) {
684 using size_t = compatibility::size_t<N>;
691 using size_t_array = array<size_type, 3>;
703#define CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(name) \
704 using PFN_##name = name##_fn
706#define CL_HPP_INIT_CL_EXT_FCN_PTR_(name) \
708 pfn_##name = (PFN_##name)clGetExtensionFunctionAddress(#name); \
711#define CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, name) \
713 pfn_##name = (PFN_##name) \
714 clGetExtensionFunctionAddressForPlatform(platform, #name); \
717#ifdef cl_khr_external_memory
718 enum class ExternalMemoryType : cl_external_memory_handle_type_khr;
731#ifdef cl_khr_semaphore
734#if defined(cl_khr_command_buffer)
735 class CommandBufferKhr;
736 class MutableCommandKhr;
739#if defined(CL_HPP_ENABLE_EXCEPTIONS)
744 class Error :
public std::exception
748 const char * errStr_;
759 Error(cl_int err,
const char * errStr =
nullptr) : err_(err), errStr_(errStr)
766 const char * what() const noexcept
override
768 if (errStr_ ==
nullptr) {
780 cl_int err(
void)
const {
return err_; }
782#define CL_HPP_ERR_STR_(x) #x
784#define CL_HPP_ERR_STR_(x) nullptr
790#if defined(CL_HPP_ENABLE_EXCEPTIONS)
791static inline cl_int errHandler (
793 const char * errStr =
nullptr)
795 if (err != CL_SUCCESS) {
796 throw Error(err, errStr);
801static inline cl_int errHandler (cl_int err,
const char * errStr =
nullptr)
812#if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS)
813#define __GET_DEVICE_INFO_ERR CL_HPP_ERR_STR_(clGetDeviceInfo)
814#define __GET_PLATFORM_INFO_ERR CL_HPP_ERR_STR_(clGetPlatformInfo)
815#define __GET_DEVICE_IDS_ERR CL_HPP_ERR_STR_(clGetDeviceIDs)
816#define __GET_PLATFORM_IDS_ERR CL_HPP_ERR_STR_(clGetPlatformIDs)
817#define __GET_CONTEXT_INFO_ERR CL_HPP_ERR_STR_(clGetContextInfo)
818#define __GET_EVENT_INFO_ERR CL_HPP_ERR_STR_(clGetEventInfo)
819#define __GET_EVENT_PROFILE_INFO_ERR CL_HPP_ERR_STR_(clGetEventProfileInfo)
820#define __GET_MEM_OBJECT_INFO_ERR CL_HPP_ERR_STR_(clGetMemObjectInfo)
821#define __GET_IMAGE_INFO_ERR CL_HPP_ERR_STR_(clGetImageInfo)
822#define __GET_SAMPLER_INFO_ERR CL_HPP_ERR_STR_(clGetSamplerInfo)
823#define __GET_KERNEL_INFO_ERR CL_HPP_ERR_STR_(clGetKernelInfo)
824#if CL_HPP_TARGET_OPENCL_VERSION >= 120
825#define __GET_KERNEL_ARG_INFO_ERR CL_HPP_ERR_STR_(clGetKernelArgInfo)
827#if CL_HPP_TARGET_OPENCL_VERSION >= 210
828#define __GET_KERNEL_SUB_GROUP_INFO_ERR CL_HPP_ERR_STR_(clGetKernelSubGroupInfo)
830#define __GET_KERNEL_SUB_GROUP_INFO_ERR CL_HPP_ERR_STR_(clGetKernelSubGroupInfoKHR)
832#define __GET_KERNEL_WORK_GROUP_INFO_ERR CL_HPP_ERR_STR_(clGetKernelWorkGroupInfo)
833#define __GET_PROGRAM_INFO_ERR CL_HPP_ERR_STR_(clGetProgramInfo)
834#define __GET_PROGRAM_BUILD_INFO_ERR CL_HPP_ERR_STR_(clGetProgramBuildInfo)
835#define __GET_COMMAND_QUEUE_INFO_ERR CL_HPP_ERR_STR_(clGetCommandQueueInfo)
837#define __CREATE_CONTEXT_ERR CL_HPP_ERR_STR_(clCreateContext)
838#define __CREATE_CONTEXT_FROM_TYPE_ERR CL_HPP_ERR_STR_(clCreateContextFromType)
839#define __GET_SUPPORTED_IMAGE_FORMATS_ERR CL_HPP_ERR_STR_(clGetSupportedImageFormats)
840#if CL_HPP_TARGET_OPENCL_VERSION >= 300
841#define __SET_CONTEXT_DESCTRUCTOR_CALLBACK_ERR CL_HPP_ERR_STR_(clSetContextDestructorCallback)
844#define __CREATE_BUFFER_ERR CL_HPP_ERR_STR_(clCreateBuffer)
845#define __COPY_ERR CL_HPP_ERR_STR_(cl::copy)
846#define __CREATE_SUBBUFFER_ERR CL_HPP_ERR_STR_(clCreateSubBuffer)
847#define __CREATE_GL_BUFFER_ERR CL_HPP_ERR_STR_(clCreateFromGLBuffer)
848#define __CREATE_GL_RENDER_BUFFER_ERR CL_HPP_ERR_STR_(clCreateFromGLBuffer)
849#define __GET_GL_OBJECT_INFO_ERR CL_HPP_ERR_STR_(clGetGLObjectInfo)
850#if CL_HPP_TARGET_OPENCL_VERSION >= 120
851#define __CREATE_IMAGE_ERR CL_HPP_ERR_STR_(clCreateImage)
852#define __CREATE_GL_TEXTURE_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture)
853#define __IMAGE_DIMENSION_ERR CL_HPP_ERR_STR_(Incorrect image dimensions)
855#define __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR CL_HPP_ERR_STR_(clSetMemObjectDestructorCallback)
857#define __CREATE_USER_EVENT_ERR CL_HPP_ERR_STR_(clCreateUserEvent)
858#define __SET_USER_EVENT_STATUS_ERR CL_HPP_ERR_STR_(clSetUserEventStatus)
859#define __SET_EVENT_CALLBACK_ERR CL_HPP_ERR_STR_(clSetEventCallback)
860#define __WAIT_FOR_EVENTS_ERR CL_HPP_ERR_STR_(clWaitForEvents)
862#define __CREATE_KERNEL_ERR CL_HPP_ERR_STR_(clCreateKernel)
863#define __SET_KERNEL_ARGS_ERR CL_HPP_ERR_STR_(clSetKernelArg)
864#define __CREATE_PROGRAM_WITH_SOURCE_ERR CL_HPP_ERR_STR_(clCreateProgramWithSource)
865#define __CREATE_PROGRAM_WITH_BINARY_ERR CL_HPP_ERR_STR_(clCreateProgramWithBinary)
866#if CL_HPP_TARGET_OPENCL_VERSION >= 210
867#define __CREATE_PROGRAM_WITH_IL_ERR CL_HPP_ERR_STR_(clCreateProgramWithIL)
869#define __CREATE_PROGRAM_WITH_IL_ERR CL_HPP_ERR_STR_(clCreateProgramWithILKHR)
871#if CL_HPP_TARGET_OPENCL_VERSION >= 120
872#define __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR CL_HPP_ERR_STR_(clCreateProgramWithBuiltInKernels)
874#define __BUILD_PROGRAM_ERR CL_HPP_ERR_STR_(clBuildProgram)
875#if CL_HPP_TARGET_OPENCL_VERSION >= 120
876#define __COMPILE_PROGRAM_ERR CL_HPP_ERR_STR_(clCompileProgram)
877#define __LINK_PROGRAM_ERR CL_HPP_ERR_STR_(clLinkProgram)
879#define __CREATE_KERNELS_IN_PROGRAM_ERR CL_HPP_ERR_STR_(clCreateKernelsInProgram)
881#if CL_HPP_TARGET_OPENCL_VERSION >= 200
882#define __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR CL_HPP_ERR_STR_(clCreateCommandQueueWithProperties)
883#define __CREATE_SAMPLER_WITH_PROPERTIES_ERR CL_HPP_ERR_STR_(clCreateSamplerWithProperties)
885#define __SET_COMMAND_QUEUE_PROPERTY_ERR CL_HPP_ERR_STR_(clSetCommandQueueProperty)
886#define __ENQUEUE_READ_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueReadBuffer)
887#define __ENQUEUE_READ_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueReadBufferRect)
888#define __ENQUEUE_WRITE_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueWriteBuffer)
889#define __ENQUEUE_WRITE_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueWriteBufferRect)
890#define __ENQEUE_COPY_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueCopyBuffer)
891#define __ENQEUE_COPY_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueCopyBufferRect)
892#define __ENQUEUE_FILL_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueFillBuffer)
893#define __ENQUEUE_READ_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueReadImage)
894#define __ENQUEUE_WRITE_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueWriteImage)
895#define __ENQUEUE_COPY_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueCopyImage)
896#define __ENQUEUE_FILL_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueFillImage)
897#define __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueCopyImageToBuffer)
898#define __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueCopyBufferToImage)
899#define __ENQUEUE_MAP_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueMapBuffer)
900#define __ENQUEUE_MAP_SVM_ERR CL_HPP_ERR_STR_(clEnqueueSVMMap)
901#define __ENQUEUE_FILL_SVM_ERR CL_HPP_ERR_STR_(clEnqueueSVMMemFill)
902#define __ENQUEUE_COPY_SVM_ERR CL_HPP_ERR_STR_(clEnqueueSVMMemcpy)
903#define __ENQUEUE_UNMAP_SVM_ERR CL_HPP_ERR_STR_(clEnqueueSVMUnmap)
904#define __ENQUEUE_MAP_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueMapImage)
905#define __ENQUEUE_UNMAP_MEM_OBJECT_ERR CL_HPP_ERR_STR_(clEnqueueUnMapMemObject)
906#define __ENQUEUE_NDRANGE_KERNEL_ERR CL_HPP_ERR_STR_(clEnqueueNDRangeKernel)
907#define __ENQUEUE_NATIVE_KERNEL CL_HPP_ERR_STR_(clEnqueueNativeKernel)
908#if CL_HPP_TARGET_OPENCL_VERSION >= 120
909#define __ENQUEUE_MIGRATE_MEM_OBJECTS_ERR CL_HPP_ERR_STR_(clEnqueueMigrateMemObjects)
911#if CL_HPP_TARGET_OPENCL_VERSION >= 210
912#define __ENQUEUE_MIGRATE_SVM_ERR CL_HPP_ERR_STR_(clEnqueueSVMMigrateMem)
913#define __SET_DEFAULT_DEVICE_COMMAND_QUEUE_ERR CL_HPP_ERR_STR_(clSetDefaultDeviceCommandQueue)
917#define __ENQUEUE_ACQUIRE_GL_ERR CL_HPP_ERR_STR_(clEnqueueAcquireGLObjects)
918#define __ENQUEUE_RELEASE_GL_ERR CL_HPP_ERR_STR_(clEnqueueReleaseGLObjects)
920#define __CREATE_PIPE_ERR CL_HPP_ERR_STR_(clCreatePipe)
921#define __GET_PIPE_INFO_ERR CL_HPP_ERR_STR_(clGetPipeInfo)
923#define __RETAIN_ERR CL_HPP_ERR_STR_(Retain Object)
924#define __RELEASE_ERR CL_HPP_ERR_STR_(Release Object)
925#define __FLUSH_ERR CL_HPP_ERR_STR_(clFlush)
926#define __FINISH_ERR CL_HPP_ERR_STR_(clFinish)
927#define __VECTOR_CAPACITY_ERR CL_HPP_ERR_STR_(Vector capacity error)
929#if CL_HPP_TARGET_OPENCL_VERSION >= 210
930#define __GET_HOST_TIMER_ERR CL_HPP_ERR_STR_(clGetHostTimer)
931#define __GET_DEVICE_AND_HOST_TIMER_ERR CL_HPP_ERR_STR_(clGetDeviceAndHostTimer)
933#if CL_HPP_TARGET_OPENCL_VERSION >= 220
934#define __SET_PROGRAM_RELEASE_CALLBACK_ERR CL_HPP_ERR_STR_(clSetProgramReleaseCallback)
935#define __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR CL_HPP_ERR_STR_(clSetProgramSpecializationConstant)
938#ifdef cl_khr_external_memory
939#define __ENQUEUE_ACQUIRE_EXTERNAL_MEMORY_ERR CL_HPP_ERR_STR_(clEnqueueAcquireExternalMemObjectsKHR)
940#define __ENQUEUE_RELEASE_EXTERNAL_MEMORY_ERR CL_HPP_ERR_STR_(clEnqueueReleaseExternalMemObjectsKHR)
943#ifdef cl_khr_semaphore
944#define __GET_SEMAPHORE_KHR_INFO_ERR CL_HPP_ERR_STR_(clGetSemaphoreInfoKHR)
945#define __CREATE_SEMAPHORE_KHR_WITH_PROPERTIES_ERR CL_HPP_ERR_STR_(clCreateSemaphoreWithPropertiesKHR)
946#define __ENQUEUE_WAIT_SEMAPHORE_KHR_ERR CL_HPP_ERR_STR_(clEnqueueWaitSemaphoresKHR)
947#define __ENQUEUE_SIGNAL_SEMAPHORE_KHR_ERR CL_HPP_ERR_STR_(clEnqueueSignalSemaphoresKHR)
948#define __RETAIN_SEMAPHORE_KHR_ERR CL_HPP_ERR_STR_(clRetainSemaphoreKHR)
949#define __RELEASE_SEMAPHORE_KHR_ERR CL_HPP_ERR_STR_(clReleaseSemaphoreKHR)
952#ifdef cl_khr_external_semaphore
953#define __GET_SEMAPHORE_HANDLE_FOR_TYPE_KHR_ERR CL_HPP_ERR_STR_(clGetSemaphoreHandleForTypeKHR)
956#if defined(cl_khr_command_buffer)
957#define __CREATE_COMMAND_BUFFER_KHR_ERR CL_HPP_ERR_STR_(clCreateCommandBufferKHR)
958#define __GET_COMMAND_BUFFER_INFO_KHR_ERR CL_HPP_ERR_STR_(clGetCommandBufferInfoKHR)
959#define __FINALIZE_COMMAND_BUFFER_KHR_ERR CL_HPP_ERR_STR_(clFinalizeCommandBufferKHR)
960#define __ENQUEUE_COMMAND_BUFFER_KHR_ERR CL_HPP_ERR_STR_(clEnqueueCommandBufferKHR)
961#define __COMMAND_BARRIER_WITH_WAIT_LIST_KHR_ERR CL_HPP_ERR_STR_(clCommandBarrierWithWaitListKHR)
962#define __COMMAND_COPY_BUFFER_KHR_ERR CL_HPP_ERR_STR_(clCommandCopyBufferKHR)
963#define __COMMAND_COPY_BUFFER_RECT_KHR_ERR CL_HPP_ERR_STR_(clCommandCopyBufferRectKHR)
964#define __COMMAND_COPY_BUFFER_TO_IMAGE_KHR_ERR CL_HPP_ERR_STR_(clCommandCopyBufferToImageKHR)
965#define __COMMAND_COPY_IMAGE_KHR_ERR CL_HPP_ERR_STR_(clCommandCopyImageKHR)
966#define __COMMAND_COPY_IMAGE_TO_BUFFER_KHR_ERR CL_HPP_ERR_STR_(clCommandCopyImageToBufferKHR)
967#define __COMMAND_FILL_BUFFER_KHR_ERR CL_HPP_ERR_STR_(clCommandFillBufferKHR)
968#define __COMMAND_FILL_IMAGE_KHR_ERR CL_HPP_ERR_STR_(clCommandFillImageKHR)
969#define __COMMAND_NDRANGE_KERNEL_KHR_ERR CL_HPP_ERR_STR_(clCommandNDRangeKernelKHR)
970#define __UPDATE_MUTABLE_COMMANDS_KHR_ERR CL_HPP_ERR_STR_(clUpdateMutableCommandsKHR)
971#define __GET_MUTABLE_COMMAND_INFO_KHR_ERR CL_HPP_ERR_STR_(clGetMutableCommandInfoKHR)
972#define __RETAIN_COMMAND_BUFFER_KHR_ERR CL_HPP_ERR_STR_(clRetainCommandBufferKHR)
973#define __RELEASE_COMMAND_BUFFER_KHR_ERR CL_HPP_ERR_STR_(clReleaseCommandBufferKHR)
976#if defined(cl_ext_image_requirements_info)
977#define __GET_IMAGE_REQUIREMENT_INFO_EXT_ERR CL_HPP_ERR_STR_(clGetImageRequirementsInfoEXT)
983#if CL_HPP_TARGET_OPENCL_VERSION >= 120
984#define __CREATE_SUB_DEVICES_ERR CL_HPP_ERR_STR_(clCreateSubDevices)
986#define __CREATE_SUB_DEVICES_ERR CL_HPP_ERR_STR_(clCreateSubDevicesEXT)
992#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
993#define __ENQUEUE_MARKER_ERR CL_HPP_ERR_STR_(clEnqueueMarker)
994#define __ENQUEUE_WAIT_FOR_EVENTS_ERR CL_HPP_ERR_STR_(clEnqueueWaitForEvents)
995#define __ENQUEUE_BARRIER_ERR CL_HPP_ERR_STR_(clEnqueueBarrier)
996#define __UNLOAD_COMPILER_ERR CL_HPP_ERR_STR_(clUnloadCompiler)
997#define __CREATE_GL_TEXTURE_2D_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture2D)
998#define __CREATE_GL_TEXTURE_3D_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture3D)
999#define __CREATE_IMAGE2D_ERR CL_HPP_ERR_STR_(clCreateImage2D)
1000#define __CREATE_IMAGE3D_ERR CL_HPP_ERR_STR_(clCreateImage3D)
1006#if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
1007#define __CREATE_COMMAND_QUEUE_ERR CL_HPP_ERR_STR_(clCreateCommandQueue)
1008#define __ENQUEUE_TASK_ERR CL_HPP_ERR_STR_(clEnqueueTask)
1009#define __CREATE_SAMPLER_ERR CL_HPP_ERR_STR_(clCreateSampler)
1015#if CL_HPP_TARGET_OPENCL_VERSION >= 120
1016#define __ENQUEUE_MARKER_WAIT_LIST_ERR CL_HPP_ERR_STR_(clEnqueueMarkerWithWaitList)
1017#define __ENQUEUE_BARRIER_WAIT_LIST_ERR CL_HPP_ERR_STR_(clEnqueueBarrierWithWaitList)
1020#if CL_HPP_TARGET_OPENCL_VERSION >= 210
1021#define __CLONE_KERNEL_ERR CL_HPP_ERR_STR_(clCloneKernel)
1027#ifdef cl_khr_external_memory
1028CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clEnqueueAcquireExternalMemObjectsKHR);
1029CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clEnqueueReleaseExternalMemObjectsKHR);
1031CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clEnqueueAcquireExternalMemObjectsKHR pfn_clEnqueueAcquireExternalMemObjectsKHR =
nullptr;
1032CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clEnqueueReleaseExternalMemObjectsKHR pfn_clEnqueueReleaseExternalMemObjectsKHR =
nullptr;
1035#ifdef cl_khr_semaphore
1036CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCreateSemaphoreWithPropertiesKHR);
1037CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clReleaseSemaphoreKHR);
1038CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clRetainSemaphoreKHR);
1039CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clEnqueueWaitSemaphoresKHR);
1040CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clEnqueueSignalSemaphoresKHR);
1041CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clGetSemaphoreInfoKHR);
1043CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCreateSemaphoreWithPropertiesKHR pfn_clCreateSemaphoreWithPropertiesKHR =
nullptr;
1044CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clReleaseSemaphoreKHR pfn_clReleaseSemaphoreKHR =
nullptr;
1045CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clRetainSemaphoreKHR pfn_clRetainSemaphoreKHR =
nullptr;
1046CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clEnqueueWaitSemaphoresKHR pfn_clEnqueueWaitSemaphoresKHR =
nullptr;
1047CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clEnqueueSignalSemaphoresKHR pfn_clEnqueueSignalSemaphoresKHR =
nullptr;
1048CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clGetSemaphoreInfoKHR pfn_clGetSemaphoreInfoKHR =
nullptr;
1051#ifdef cl_khr_external_semaphore
1052CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clGetSemaphoreHandleForTypeKHR);
1053CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clGetSemaphoreHandleForTypeKHR pfn_clGetSemaphoreHandleForTypeKHR =
nullptr;
1056#if defined(cl_khr_command_buffer)
1057CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCreateCommandBufferKHR);
1058CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clFinalizeCommandBufferKHR);
1059CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clRetainCommandBufferKHR);
1060CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clReleaseCommandBufferKHR);
1061CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clGetCommandBufferInfoKHR);
1062CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clEnqueueCommandBufferKHR);
1063CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandBarrierWithWaitListKHR);
1064CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandCopyBufferKHR);
1065CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandCopyBufferRectKHR);
1066CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandCopyBufferToImageKHR);
1067CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandCopyImageKHR);
1068CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandCopyImageToBufferKHR);
1069CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandFillBufferKHR);
1070CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandFillImageKHR);
1071CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandNDRangeKernelKHR);
1073CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCreateCommandBufferKHR pfn_clCreateCommandBufferKHR =
nullptr;
1074CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clFinalizeCommandBufferKHR pfn_clFinalizeCommandBufferKHR =
nullptr;
1075CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clRetainCommandBufferKHR pfn_clRetainCommandBufferKHR =
nullptr;
1076CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clReleaseCommandBufferKHR pfn_clReleaseCommandBufferKHR =
nullptr;
1077CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clGetCommandBufferInfoKHR pfn_clGetCommandBufferInfoKHR =
nullptr;
1078CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clEnqueueCommandBufferKHR pfn_clEnqueueCommandBufferKHR =
nullptr;
1079CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandBarrierWithWaitListKHR pfn_clCommandBarrierWithWaitListKHR =
nullptr;
1080CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandCopyBufferKHR pfn_clCommandCopyBufferKHR =
nullptr;
1081CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandCopyBufferRectKHR pfn_clCommandCopyBufferRectKHR =
nullptr;
1082CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandCopyBufferToImageKHR pfn_clCommandCopyBufferToImageKHR =
nullptr;
1083CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandCopyImageKHR pfn_clCommandCopyImageKHR =
nullptr;
1084CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandCopyImageToBufferKHR pfn_clCommandCopyImageToBufferKHR =
nullptr;
1085CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandFillBufferKHR pfn_clCommandFillBufferKHR =
nullptr;
1086CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandFillImageKHR pfn_clCommandFillImageKHR =
nullptr;
1087CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandNDRangeKernelKHR pfn_clCommandNDRangeKernelKHR =
nullptr;
1090#if defined(cl_khr_command_buffer_mutable_dispatch)
1091CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clUpdateMutableCommandsKHR);
1092CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clGetMutableCommandInfoKHR);
1094CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clUpdateMutableCommandsKHR pfn_clUpdateMutableCommandsKHR =
nullptr;
1095CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clGetMutableCommandInfoKHR pfn_clGetMutableCommandInfoKHR =
nullptr;
1098#if defined(cl_ext_image_requirements_info)
1099CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clGetImageRequirementsInfoEXT);
1100CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clGetImageRequirementsInfoEXT pfn_clGetImageRequirementsInfoEXT =
nullptr;
1103#if defined(cl_ext_device_fission)
1104CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCreateSubDevicesEXT);
1105CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCreateSubDevicesEXT
1106 pfn_clCreateSubDevicesEXT =
nullptr;
1115template<
typename Functor,
typename T>
1116inline cl_int getInfoHelper(Functor f, cl_uint name, T* param,
long)
1118 return f(name,
sizeof(T), param,
nullptr);
1123template <
typename Func>
1124inline cl_int getInfoHelper(Func f, cl_uint name, vector<vector<unsigned char>>* param,
int)
1126 if (name != CL_PROGRAM_BINARIES) {
1127 return CL_INVALID_VALUE;
1131 size_type numBinaries = param->size();
1132 vector<unsigned char*> binariesPointers(numBinaries);
1134 for (size_type i = 0; i < numBinaries; ++i)
1136 binariesPointers[i] = (*param)[i].data();
1139 cl_int err = f(name, numBinaries *
sizeof(
unsigned char*), binariesPointers.data(),
nullptr);
1141 if (err != CL_SUCCESS) {
1150template <
typename Func,
typename T>
1151inline cl_int getInfoHelper(Func f, cl_uint name, vector<T>* param,
long)
1154 cl_int err = f(name, 0,
nullptr, &required);
1155 if (err != CL_SUCCESS) {
1158 const size_type elements = required /
sizeof(T);
1161 vector<T> localData(elements);
1162 err = f(name, required, localData.data(),
nullptr);
1163 if (err != CL_SUCCESS) {
1167 *param = std::move(localData);
1179template <
typename Func,
typename T>
1180inline cl_int getInfoHelper(
1181 Func f, cl_uint name, vector<T>* param,
int,
typename T::cl_type = 0)
1184 cl_int err = f(name, 0,
nullptr, &required);
1185 if (err != CL_SUCCESS) {
1189 const size_type elements = required /
sizeof(
typename T::cl_type);
1191 vector<typename T::cl_type> value(elements);
1192 err = f(name, required, value.data(),
nullptr);
1193 if (err != CL_SUCCESS) {
1199 param->resize(elements);
1203 for (size_type i = 0; i < elements; i++) {
1204 (*param)[i] = T(value[i],
true);
1211template <
typename Func>
1212inline cl_int getInfoHelper(Func f, cl_uint name,
string* param,
long)
1215 cl_int err = f(name, 0,
nullptr, &required);
1216 if (err != CL_SUCCESS) {
1223 vector<char> value(required);
1224 err = f(name, required, value.data(),
nullptr);
1225 if (err != CL_SUCCESS) {
1229 param->assign(value.begin(), value.end() - 1);
1239template <
typename Func,
size_type N>
1240inline cl_int getInfoHelper(Func f, cl_uint name, array<size_type, N>* param,
long)
1243 cl_int err = f(name, 0,
nullptr, &required);
1244 if (err != CL_SUCCESS) {
1248 size_type elements = required /
sizeof(size_type);
1249 vector<size_type> value(elements, 0);
1251 err = f(name, required, value.data(),
nullptr);
1252 if (err != CL_SUCCESS) {
1261 for (size_type i = 0; i < elements; ++i) {
1262 (*param)[i] = value[i];
1276template<
typename Func,
typename T>
1277inline cl_int getInfoHelper(Func f, cl_uint name, T* param,
int,
typename T::cl_type = 0)
1279 typename T::cl_type value;
1280 cl_int err = f(name,
sizeof(value), &value,
nullptr);
1281 if (err != CL_SUCCESS) {
1285 if (value !=
nullptr)
1287 err = param->retain();
1288 if (err != CL_SUCCESS) {
1295#define CL_HPP_PARAM_NAME_INFO_1_0_(F) \
1296 F(cl_platform_info, CL_PLATFORM_PROFILE, string) \
1297 F(cl_platform_info, CL_PLATFORM_VERSION, string) \
1298 F(cl_platform_info, CL_PLATFORM_NAME, string) \
1299 F(cl_platform_info, CL_PLATFORM_VENDOR, string) \
1300 F(cl_platform_info, CL_PLATFORM_EXTENSIONS, string) \
1302 F(cl_device_info, CL_DEVICE_TYPE, cl_device_type) \
1303 F(cl_device_info, CL_DEVICE_VENDOR_ID, cl_uint) \
1304 F(cl_device_info, CL_DEVICE_MAX_COMPUTE_UNITS, cl_uint) \
1305 F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, cl_uint) \
1306 F(cl_device_info, CL_DEVICE_MAX_WORK_GROUP_SIZE, size_type) \
1307 F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_SIZES, cl::vector<size_type>) \
1308 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, cl_uint) \
1309 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT, cl_uint) \
1310 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT, cl_uint) \
1311 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG, cl_uint) \
1312 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT, cl_uint) \
1313 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, cl_uint) \
1314 F(cl_device_info, CL_DEVICE_MAX_CLOCK_FREQUENCY, cl_uint) \
1315 F(cl_device_info, CL_DEVICE_ADDRESS_BITS, cl_uint) \
1316 F(cl_device_info, CL_DEVICE_MAX_READ_IMAGE_ARGS, cl_uint) \
1317 F(cl_device_info, CL_DEVICE_MAX_WRITE_IMAGE_ARGS, cl_uint) \
1318 F(cl_device_info, CL_DEVICE_MAX_MEM_ALLOC_SIZE, cl_ulong) \
1319 F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_WIDTH, size_type) \
1320 F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_HEIGHT, size_type) \
1321 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_WIDTH, size_type) \
1322 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_HEIGHT, size_type) \
1323 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_DEPTH, size_type) \
1324 F(cl_device_info, CL_DEVICE_IMAGE_SUPPORT, cl_bool) \
1325 F(cl_device_info, CL_DEVICE_MAX_PARAMETER_SIZE, size_type) \
1326 F(cl_device_info, CL_DEVICE_MAX_SAMPLERS, cl_uint) \
1327 F(cl_device_info, CL_DEVICE_MEM_BASE_ADDR_ALIGN, cl_uint) \
1328 F(cl_device_info, CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE, cl_uint) \
1329 F(cl_device_info, CL_DEVICE_SINGLE_FP_CONFIG, cl_device_fp_config) \
1330 F(cl_device_info, CL_DEVICE_DOUBLE_FP_CONFIG, cl_device_fp_config) \
1331 F(cl_device_info, CL_DEVICE_HALF_FP_CONFIG, cl_device_fp_config) \
1332 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_TYPE, cl_device_mem_cache_type) \
1333 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE, cl_uint)\
1334 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_SIZE, cl_ulong) \
1335 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_SIZE, cl_ulong) \
1336 F(cl_device_info, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE, cl_ulong) \
1337 F(cl_device_info, CL_DEVICE_MAX_CONSTANT_ARGS, cl_uint) \
1338 F(cl_device_info, CL_DEVICE_LOCAL_MEM_TYPE, cl_device_local_mem_type) \
1339 F(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE, cl_ulong) \
1340 F(cl_device_info, CL_DEVICE_ERROR_CORRECTION_SUPPORT, cl_bool) \
1341 F(cl_device_info, CL_DEVICE_PROFILING_TIMER_RESOLUTION, size_type) \
1342 F(cl_device_info, CL_DEVICE_ENDIAN_LITTLE, cl_bool) \
1343 F(cl_device_info, CL_DEVICE_AVAILABLE, cl_bool) \
1344 F(cl_device_info, CL_DEVICE_COMPILER_AVAILABLE, cl_bool) \
1345 F(cl_device_info, CL_DEVICE_EXECUTION_CAPABILITIES, cl_device_exec_capabilities) \
1346 F(cl_device_info, CL_DEVICE_PLATFORM, cl::Platform) \
1347 F(cl_device_info, CL_DEVICE_NAME, string) \
1348 F(cl_device_info, CL_DEVICE_VENDOR, string) \
1349 F(cl_device_info, CL_DRIVER_VERSION, string) \
1350 F(cl_device_info, CL_DEVICE_PROFILE, string) \
1351 F(cl_device_info, CL_DEVICE_VERSION, string) \
1352 F(cl_device_info, CL_DEVICE_EXTENSIONS, string) \
1354 F(cl_context_info, CL_CONTEXT_REFERENCE_COUNT, cl_uint) \
1355 F(cl_context_info, CL_CONTEXT_DEVICES, cl::vector<Device>) \
1356 F(cl_context_info, CL_CONTEXT_PROPERTIES, cl::vector<cl_context_properties>) \
1358 F(cl_event_info, CL_EVENT_COMMAND_QUEUE, cl::CommandQueue) \
1359 F(cl_event_info, CL_EVENT_COMMAND_TYPE, cl_command_type) \
1360 F(cl_event_info, CL_EVENT_REFERENCE_COUNT, cl_uint) \
1361 F(cl_event_info, CL_EVENT_COMMAND_EXECUTION_STATUS, cl_int) \
1363 F(cl_profiling_info, CL_PROFILING_COMMAND_QUEUED, cl_ulong) \
1364 F(cl_profiling_info, CL_PROFILING_COMMAND_SUBMIT, cl_ulong) \
1365 F(cl_profiling_info, CL_PROFILING_COMMAND_START, cl_ulong) \
1366 F(cl_profiling_info, CL_PROFILING_COMMAND_END, cl_ulong) \
1368 F(cl_mem_info, CL_MEM_TYPE, cl_mem_object_type) \
1369 F(cl_mem_info, CL_MEM_FLAGS, cl_mem_flags) \
1370 F(cl_mem_info, CL_MEM_SIZE, size_type) \
1371 F(cl_mem_info, CL_MEM_HOST_PTR, void*) \
1372 F(cl_mem_info, CL_MEM_MAP_COUNT, cl_uint) \
1373 F(cl_mem_info, CL_MEM_REFERENCE_COUNT, cl_uint) \
1374 F(cl_mem_info, CL_MEM_CONTEXT, cl::Context) \
1376 F(cl_image_info, CL_IMAGE_FORMAT, cl_image_format) \
1377 F(cl_image_info, CL_IMAGE_ELEMENT_SIZE, size_type) \
1378 F(cl_image_info, CL_IMAGE_ROW_PITCH, size_type) \
1379 F(cl_image_info, CL_IMAGE_SLICE_PITCH, size_type) \
1380 F(cl_image_info, CL_IMAGE_WIDTH, size_type) \
1381 F(cl_image_info, CL_IMAGE_HEIGHT, size_type) \
1382 F(cl_image_info, CL_IMAGE_DEPTH, size_type) \
1384 F(cl_sampler_info, CL_SAMPLER_REFERENCE_COUNT, cl_uint) \
1385 F(cl_sampler_info, CL_SAMPLER_CONTEXT, cl::Context) \
1386 F(cl_sampler_info, CL_SAMPLER_NORMALIZED_COORDS, cl_bool) \
1387 F(cl_sampler_info, CL_SAMPLER_ADDRESSING_MODE, cl_addressing_mode) \
1388 F(cl_sampler_info, CL_SAMPLER_FILTER_MODE, cl_filter_mode) \
1390 F(cl_program_info, CL_PROGRAM_REFERENCE_COUNT, cl_uint) \
1391 F(cl_program_info, CL_PROGRAM_CONTEXT, cl::Context) \
1392 F(cl_program_info, CL_PROGRAM_NUM_DEVICES, cl_uint) \
1393 F(cl_program_info, CL_PROGRAM_DEVICES, cl::vector<Device>) \
1394 F(cl_program_info, CL_PROGRAM_SOURCE, string) \
1395 F(cl_program_info, CL_PROGRAM_BINARY_SIZES, cl::vector<size_type>) \
1396 F(cl_program_info, CL_PROGRAM_BINARIES, cl::vector<cl::vector<unsigned char>>) \
1398 F(cl_program_build_info, CL_PROGRAM_BUILD_STATUS, cl_build_status) \
1399 F(cl_program_build_info, CL_PROGRAM_BUILD_OPTIONS, string) \
1400 F(cl_program_build_info, CL_PROGRAM_BUILD_LOG, string) \
1402 F(cl_kernel_info, CL_KERNEL_FUNCTION_NAME, string) \
1403 F(cl_kernel_info, CL_KERNEL_NUM_ARGS, cl_uint) \
1404 F(cl_kernel_info, CL_KERNEL_REFERENCE_COUNT, cl_uint) \
1405 F(cl_kernel_info, CL_KERNEL_CONTEXT, cl::Context) \
1406 F(cl_kernel_info, CL_KERNEL_PROGRAM, cl::Program) \
1408 F(cl_kernel_work_group_info, CL_KERNEL_WORK_GROUP_SIZE, size_type) \
1409 F(cl_kernel_work_group_info, CL_KERNEL_COMPILE_WORK_GROUP_SIZE, cl::detail::size_t_array) \
1410 F(cl_kernel_work_group_info, CL_KERNEL_LOCAL_MEM_SIZE, cl_ulong) \
1412 F(cl_command_queue_info, CL_QUEUE_CONTEXT, cl::Context) \
1413 F(cl_command_queue_info, CL_QUEUE_DEVICE, cl::Device) \
1414 F(cl_command_queue_info, CL_QUEUE_REFERENCE_COUNT, cl_uint) \
1415 F(cl_command_queue_info, CL_QUEUE_PROPERTIES, cl_command_queue_properties)
1418#define CL_HPP_PARAM_NAME_INFO_1_1_(F) \
1419 F(cl_context_info, CL_CONTEXT_NUM_DEVICES, cl_uint)\
1420 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF, cl_uint) \
1421 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR, cl_uint) \
1422 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT, cl_uint) \
1423 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_INT, cl_uint) \
1424 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG, cl_uint) \
1425 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT, cl_uint) \
1426 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE, cl_uint) \
1427 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF, cl_uint) \
1428 F(cl_device_info, CL_DEVICE_OPENCL_C_VERSION, string) \
1430 F(cl_mem_info, CL_MEM_ASSOCIATED_MEMOBJECT, cl::Memory) \
1431 F(cl_mem_info, CL_MEM_OFFSET, size_type) \
1433 F(cl_kernel_work_group_info, CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, size_type) \
1434 F(cl_kernel_work_group_info, CL_KERNEL_PRIVATE_MEM_SIZE, cl_ulong) \
1436 F(cl_event_info, CL_EVENT_CONTEXT, cl::Context)
1438#define CL_HPP_PARAM_NAME_INFO_1_2_(F) \
1439 F(cl_program_info, CL_PROGRAM_NUM_KERNELS, size_type) \
1440 F(cl_program_info, CL_PROGRAM_KERNEL_NAMES, string) \
1442 F(cl_program_build_info, CL_PROGRAM_BINARY_TYPE, cl_program_binary_type) \
1444 F(cl_kernel_info, CL_KERNEL_ATTRIBUTES, string) \
1446 F(cl_kernel_arg_info, CL_KERNEL_ARG_ADDRESS_QUALIFIER, cl_kernel_arg_address_qualifier) \
1447 F(cl_kernel_arg_info, CL_KERNEL_ARG_ACCESS_QUALIFIER, cl_kernel_arg_access_qualifier) \
1448 F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_NAME, string) \
1449 F(cl_kernel_arg_info, CL_KERNEL_ARG_NAME, string) \
1450 F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_QUALIFIER, cl_kernel_arg_type_qualifier) \
1452 F(cl_kernel_work_group_info, CL_KERNEL_GLOBAL_WORK_SIZE, cl::detail::size_t_array) \
1454 F(cl_device_info, CL_DEVICE_LINKER_AVAILABLE, cl_bool) \
1455 F(cl_device_info, CL_DEVICE_IMAGE_MAX_BUFFER_SIZE, size_type) \
1456 F(cl_device_info, CL_DEVICE_IMAGE_MAX_ARRAY_SIZE, size_type) \
1457 F(cl_device_info, CL_DEVICE_PARENT_DEVICE, cl::Device) \
1458 F(cl_device_info, CL_DEVICE_PARTITION_MAX_SUB_DEVICES, cl_uint) \
1459 F(cl_device_info, CL_DEVICE_PARTITION_PROPERTIES, cl::vector<cl_device_partition_property>) \
1460 F(cl_device_info, CL_DEVICE_PARTITION_TYPE, cl::vector<cl_device_partition_property>) \
1461 F(cl_device_info, CL_DEVICE_REFERENCE_COUNT, cl_uint) \
1462 F(cl_device_info, CL_DEVICE_PREFERRED_INTEROP_USER_SYNC, cl_bool) \
1463 F(cl_device_info, CL_DEVICE_PARTITION_AFFINITY_DOMAIN, cl_device_affinity_domain) \
1464 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS, string) \
1465 F(cl_device_info, CL_DEVICE_PRINTF_BUFFER_SIZE, size_type) \
1467 F(cl_image_info, CL_IMAGE_ARRAY_SIZE, size_type) \
1468 F(cl_image_info, CL_IMAGE_NUM_MIP_LEVELS, cl_uint) \
1469 F(cl_image_info, CL_IMAGE_NUM_SAMPLES, cl_uint)
1471#define CL_HPP_PARAM_NAME_INFO_2_0_(F) \
1472 F(cl_device_info, CL_DEVICE_QUEUE_ON_HOST_PROPERTIES, cl_command_queue_properties) \
1473 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES, cl_command_queue_properties) \
1474 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE, cl_uint) \
1475 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE, cl_uint) \
1476 F(cl_device_info, CL_DEVICE_MAX_ON_DEVICE_QUEUES, cl_uint) \
1477 F(cl_device_info, CL_DEVICE_MAX_ON_DEVICE_EVENTS, cl_uint) \
1478 F(cl_device_info, CL_DEVICE_MAX_PIPE_ARGS, cl_uint) \
1479 F(cl_device_info, CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS, cl_uint) \
1480 F(cl_device_info, CL_DEVICE_PIPE_MAX_PACKET_SIZE, cl_uint) \
1481 F(cl_device_info, CL_DEVICE_SVM_CAPABILITIES, cl_device_svm_capabilities) \
1482 F(cl_device_info, CL_DEVICE_PREFERRED_PLATFORM_ATOMIC_ALIGNMENT, cl_uint) \
1483 F(cl_device_info, CL_DEVICE_PREFERRED_GLOBAL_ATOMIC_ALIGNMENT, cl_uint) \
1484 F(cl_device_info, CL_DEVICE_PREFERRED_LOCAL_ATOMIC_ALIGNMENT, cl_uint) \
1485 F(cl_device_info, CL_DEVICE_IMAGE_PITCH_ALIGNMENT, cl_uint) \
1486 F(cl_device_info, CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT, cl_uint) \
1487 F(cl_device_info, CL_DEVICE_MAX_READ_WRITE_IMAGE_ARGS, cl_uint ) \
1488 F(cl_device_info, CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE, size_type ) \
1489 F(cl_device_info, CL_DEVICE_GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE, size_type ) \
1490 F(cl_profiling_info, CL_PROFILING_COMMAND_COMPLETE, cl_ulong) \
1491 F(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM, cl_bool) \
1492 F(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_SVM_PTRS, void**) \
1493 F(cl_command_queue_info, CL_QUEUE_SIZE, cl_uint) \
1494 F(cl_mem_info, CL_MEM_USES_SVM_POINTER, cl_bool) \
1495 F(cl_program_build_info, CL_PROGRAM_BUILD_GLOBAL_VARIABLE_TOTAL_SIZE, size_type) \
1496 F(cl_pipe_info, CL_PIPE_PACKET_SIZE, cl_uint) \
1497 F(cl_pipe_info, CL_PIPE_MAX_PACKETS, cl_uint)
1499#define CL_HPP_PARAM_NAME_INFO_SUBGROUP_KHR_(F) \
1500 F(cl_kernel_sub_group_info, CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE_KHR, size_type) \
1501 F(cl_kernel_sub_group_info, CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE_KHR, size_type)
1503#define CL_HPP_PARAM_NAME_INFO_IL_KHR_(F) \
1504 F(cl_device_info, CL_DEVICE_IL_VERSION_KHR, string) \
1505 F(cl_program_info, CL_PROGRAM_IL_KHR, cl::vector<unsigned char>)
1507#define CL_HPP_PARAM_NAME_INFO_2_1_(F) \
1508 F(cl_platform_info, CL_PLATFORM_HOST_TIMER_RESOLUTION, cl_ulong) \
1509 F(cl_program_info, CL_PROGRAM_IL, cl::vector<unsigned char>) \
1510 F(cl_device_info, CL_DEVICE_MAX_NUM_SUB_GROUPS, cl_uint) \
1511 F(cl_device_info, CL_DEVICE_IL_VERSION, string) \
1512 F(cl_device_info, CL_DEVICE_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS, cl_bool) \
1513 F(cl_command_queue_info, CL_QUEUE_DEVICE_DEFAULT, cl::DeviceCommandQueue) \
1514 F(cl_kernel_sub_group_info, CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE, size_type) \
1515 F(cl_kernel_sub_group_info, CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE, size_type) \
1516 F(cl_kernel_sub_group_info, CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT, cl::detail::size_t_array) \
1517 F(cl_kernel_sub_group_info, CL_KERNEL_MAX_NUM_SUB_GROUPS, size_type) \
1518 F(cl_kernel_sub_group_info, CL_KERNEL_COMPILE_NUM_SUB_GROUPS, size_type)
1520#define CL_HPP_PARAM_NAME_INFO_2_2_(F) \
1521 F(cl_program_info, CL_PROGRAM_SCOPE_GLOBAL_CTORS_PRESENT, cl_bool) \
1522 F(cl_program_info, CL_PROGRAM_SCOPE_GLOBAL_DTORS_PRESENT, cl_bool)
1524#define CL_HPP_PARAM_NAME_DEVICE_FISSION_EXT_(F) \
1525 F(cl_device_info, CL_DEVICE_PARENT_DEVICE_EXT, cl::Device) \
1526 F(cl_device_info, CL_DEVICE_PARTITION_TYPES_EXT, cl::vector<cl_device_partition_property_ext>) \
1527 F(cl_device_info, CL_DEVICE_AFFINITY_DOMAINS_EXT, cl::vector<cl_device_partition_property_ext>) \
1528 F(cl_device_info, CL_DEVICE_REFERENCE_COUNT_EXT , cl_uint) \
1529 F(cl_device_info, CL_DEVICE_PARTITION_STYLE_EXT, cl::vector<cl_device_partition_property_ext>)
1531#define CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_CL3_SHARED_(F) \
1532 F(cl_platform_info, CL_PLATFORM_NUMERIC_VERSION_KHR, cl_version_khr) \
1533 F(cl_platform_info, CL_PLATFORM_EXTENSIONS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>) \
1535 F(cl_device_info, CL_DEVICE_NUMERIC_VERSION_KHR, cl_version_khr) \
1536 F(cl_device_info, CL_DEVICE_EXTENSIONS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>) \
1537 F(cl_device_info, CL_DEVICE_ILS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>) \
1538 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>)
1540#define CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_KHRONLY_(F) \
1541 F(cl_device_info, CL_DEVICE_OPENCL_C_NUMERIC_VERSION_KHR, cl_version_khr)
1544#define CL_HPP_PARAM_NAME_CL_KHR_SEMAPHORE_(F) \
1545 F(cl_semaphore_info_khr, CL_SEMAPHORE_CONTEXT_KHR, cl::Context) \
1546 F(cl_semaphore_info_khr, CL_SEMAPHORE_REFERENCE_COUNT_KHR, cl_uint) \
1547 F(cl_semaphore_info_khr, CL_SEMAPHORE_PROPERTIES_KHR, cl::vector<cl_semaphore_properties_khr>) \
1548 F(cl_semaphore_info_khr, CL_SEMAPHORE_TYPE_KHR, cl_semaphore_type_khr) \
1549 F(cl_semaphore_info_khr, CL_SEMAPHORE_PAYLOAD_KHR, cl_semaphore_payload_khr) \
1550 F(cl_platform_info, CL_PLATFORM_SEMAPHORE_TYPES_KHR, cl::vector<cl_semaphore_type_khr>) \
1551 F(cl_device_info, CL_DEVICE_SEMAPHORE_TYPES_KHR, cl::vector<cl_semaphore_type_khr>) \
1553#define CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_MEMORY_(F) \
1554 F(cl_device_info, CL_DEVICE_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR, cl::vector<cl::ExternalMemoryType>) \
1555 F(cl_platform_info, CL_PLATFORM_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR, cl::vector<cl::ExternalMemoryType>)
1557#define CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_(F) \
1558 F(cl_platform_info, CL_PLATFORM_SEMAPHORE_IMPORT_HANDLE_TYPES_KHR, cl::vector<cl_external_semaphore_handle_type_khr>) \
1559 F(cl_platform_info, CL_PLATFORM_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR, cl::vector<cl_external_semaphore_handle_type_khr>) \
1560 F(cl_device_info, CL_DEVICE_SEMAPHORE_IMPORT_HANDLE_TYPES_KHR, cl::vector<cl_external_semaphore_handle_type_khr>) \
1561 F(cl_device_info, CL_DEVICE_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR, cl::vector<cl_external_semaphore_handle_type_khr>) \
1562 F(cl_semaphore_info_khr, CL_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR, cl::vector<cl_external_semaphore_handle_type_khr>) \
1564#define CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_OPAQUE_FD_EXT(F) \
1565 F(cl_external_semaphore_handle_type_khr, CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR, int) \
1567#define CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_SYNC_FD_EXT(F) \
1568 F(cl_external_semaphore_handle_type_khr, CL_SEMAPHORE_HANDLE_SYNC_FD_KHR, int) \
1570#define CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_WIN32_EXT(F) \
1571 F(cl_external_semaphore_handle_type_khr, CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KHR, void*) \
1572 F(cl_external_semaphore_handle_type_khr, CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KMT_KHR, void*) \
1574#define CL_HPP_PARAM_NAME_INFO_3_0_(F) \
1575 F(cl_platform_info, CL_PLATFORM_NUMERIC_VERSION, cl_version) \
1576 F(cl_platform_info, CL_PLATFORM_EXTENSIONS_WITH_VERSION, cl::vector<cl_name_version>) \
1578 F(cl_device_info, CL_DEVICE_NUMERIC_VERSION, cl_version) \
1579 F(cl_device_info, CL_DEVICE_EXTENSIONS_WITH_VERSION, cl::vector<cl_name_version>) \
1580 F(cl_device_info, CL_DEVICE_ILS_WITH_VERSION, cl::vector<cl_name_version>) \
1581 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS_WITH_VERSION, cl::vector<cl_name_version>) \
1582 F(cl_device_info, CL_DEVICE_ATOMIC_MEMORY_CAPABILITIES, cl_device_atomic_capabilities) \
1583 F(cl_device_info, CL_DEVICE_ATOMIC_FENCE_CAPABILITIES, cl_device_atomic_capabilities) \
1584 F(cl_device_info, CL_DEVICE_NON_UNIFORM_WORK_GROUP_SUPPORT, cl_bool) \
1585 F(cl_device_info, CL_DEVICE_OPENCL_C_ALL_VERSIONS, cl::vector<cl_name_version>) \
1586 F(cl_device_info, CL_DEVICE_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, size_type) \
1587 F(cl_device_info, CL_DEVICE_WORK_GROUP_COLLECTIVE_FUNCTIONS_SUPPORT, cl_bool) \
1588 F(cl_device_info, CL_DEVICE_GENERIC_ADDRESS_SPACE_SUPPORT, cl_bool) \
1589 F(cl_device_info, CL_DEVICE_OPENCL_C_FEATURES, cl::vector<cl_name_version>) \
1590 F(cl_device_info, CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES, cl_device_device_enqueue_capabilities) \
1591 F(cl_device_info, CL_DEVICE_PIPE_SUPPORT, cl_bool) \
1592 F(cl_device_info, CL_DEVICE_LATEST_CONFORMANCE_VERSION_PASSED, string) \
1594 F(cl_command_queue_info, CL_QUEUE_PROPERTIES_ARRAY, cl::vector<cl_queue_properties>) \
1595 F(cl_mem_info, CL_MEM_PROPERTIES, cl::vector<cl_mem_properties>) \
1596 F(cl_pipe_info, CL_PIPE_PROPERTIES, cl::vector<cl_pipe_properties>) \
1597 F(cl_sampler_info, CL_SAMPLER_PROPERTIES, cl::vector<cl_sampler_properties>) \
1599#define CL_HPP_PARAM_NAME_CL_IMAGE_REQUIREMENTS_EXT(F) \
1600 F(cl_image_requirements_info_ext, CL_IMAGE_REQUIREMENTS_ROW_PITCH_ALIGNMENT_EXT, size_type) \
1601 F(cl_image_requirements_info_ext, CL_IMAGE_REQUIREMENTS_BASE_ADDRESS_ALIGNMENT_EXT, size_type) \
1602 F(cl_image_requirements_info_ext, CL_IMAGE_REQUIREMENTS_SIZE_EXT, size_type) \
1603 F(cl_image_requirements_info_ext, CL_IMAGE_REQUIREMENTS_MAX_WIDTH_EXT, cl_uint) \
1604 F(cl_image_requirements_info_ext, CL_IMAGE_REQUIREMENTS_MAX_HEIGHT_EXT, cl_uint) \
1605 F(cl_image_requirements_info_ext, CL_IMAGE_REQUIREMENTS_MAX_DEPTH_EXT, cl_uint) \
1606 F(cl_image_requirements_info_ext, CL_IMAGE_REQUIREMENTS_MAX_ARRAY_SIZE_EXT, cl_uint) \
1608#define CL_HPP_PARAM_NAME_CL_IMAGE_REQUIREMENTS_SLICE_PITCH_ALIGNMENT_EXT(F) \
1609 F(cl_image_requirements_info_ext, CL_IMAGE_REQUIREMENTS_SLICE_PITCH_ALIGNMENT_EXT, size_type) \
1611#define CL_HPP_PARAM_NAME_CL_INTEL_COMMAND_QUEUE_FAMILIES_(F) \
1612 F(cl_device_info, CL_DEVICE_QUEUE_FAMILY_PROPERTIES_INTEL, cl::vector<cl_queue_family_properties_intel>) \
1614 F(cl_command_queue_info, CL_QUEUE_FAMILY_INTEL, cl_uint) \
1615 F(cl_command_queue_info, CL_QUEUE_INDEX_INTEL, cl_uint)
1617#define CL_HPP_PARAM_NAME_CL_INTEL_UNIFIED_SHARED_MEMORY_(F) \
1618 F(cl_device_info, CL_DEVICE_HOST_MEM_CAPABILITIES_INTEL, cl_device_unified_shared_memory_capabilities_intel ) \
1619 F(cl_device_info, CL_DEVICE_DEVICE_MEM_CAPABILITIES_INTEL, cl_device_unified_shared_memory_capabilities_intel ) \
1620 F(cl_device_info, CL_DEVICE_SINGLE_DEVICE_SHARED_MEM_CAPABILITIES_INTEL, cl_device_unified_shared_memory_capabilities_intel ) \
1621 F(cl_device_info, CL_DEVICE_CROSS_DEVICE_SHARED_MEM_CAPABILITIES_INTEL, cl_device_unified_shared_memory_capabilities_intel ) \
1622 F(cl_device_info, CL_DEVICE_SHARED_SYSTEM_MEM_CAPABILITIES_INTEL, cl_device_unified_shared_memory_capabilities_intel )
1624template <
typename enum_type, cl_
int Name>
1627#define CL_HPP_DECLARE_PARAM_TRAITS_(token, param_name, T) \
1630struct param_traits<detail:: token,param_name> \
1632 enum { value = param_name }; \
1633 typedef T param_type; \
1636CL_HPP_PARAM_NAME_INFO_1_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1637#if CL_HPP_TARGET_OPENCL_VERSION >= 110
1638CL_HPP_PARAM_NAME_INFO_1_1_(CL_HPP_DECLARE_PARAM_TRAITS_)
1640#if CL_HPP_TARGET_OPENCL_VERSION >= 120
1641CL_HPP_PARAM_NAME_INFO_1_2_(CL_HPP_DECLARE_PARAM_TRAITS_)
1643#if CL_HPP_TARGET_OPENCL_VERSION >= 200
1644CL_HPP_PARAM_NAME_INFO_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1646#if CL_HPP_TARGET_OPENCL_VERSION >= 210
1647CL_HPP_PARAM_NAME_INFO_2_1_(CL_HPP_DECLARE_PARAM_TRAITS_)
1649#if CL_HPP_TARGET_OPENCL_VERSION >= 220
1650CL_HPP_PARAM_NAME_INFO_2_2_(CL_HPP_DECLARE_PARAM_TRAITS_)
1652#if CL_HPP_TARGET_OPENCL_VERSION >= 300
1653CL_HPP_PARAM_NAME_INFO_3_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1656#if defined(cl_khr_subgroups) && CL_HPP_TARGET_OPENCL_VERSION < 210
1657CL_HPP_PARAM_NAME_INFO_SUBGROUP_KHR_(CL_HPP_DECLARE_PARAM_TRAITS_)
1660#if defined(cl_khr_il_program) && CL_HPP_TARGET_OPENCL_VERSION < 210
1661CL_HPP_PARAM_NAME_INFO_IL_KHR_(CL_HPP_DECLARE_PARAM_TRAITS_)
1666#define CL_HPP_PARAM_NAME_INFO_1_0_DEPRECATED_IN_2_0_(F) \
1667 F(cl_device_info, CL_DEVICE_QUEUE_PROPERTIES, cl_command_queue_properties)
1669#define CL_HPP_PARAM_NAME_INFO_1_1_DEPRECATED_IN_2_0_(F) \
1670 F(cl_device_info, CL_DEVICE_HOST_UNIFIED_MEMORY, cl_bool)
1672#define CL_HPP_PARAM_NAME_INFO_1_2_DEPRECATED_IN_2_0_(F) \
1673 F(cl_image_info, CL_IMAGE_BUFFER, cl::Buffer)
1677#if CL_HPP_TARGET_OPENCL_VERSION > 100 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 && CL_HPP_TARGET_OPENCL_VERSION < 200
1678CL_HPP_PARAM_NAME_INFO_1_0_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1680#if CL_HPP_TARGET_OPENCL_VERSION > 110 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
1681CL_HPP_PARAM_NAME_INFO_1_1_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1683#if CL_HPP_TARGET_OPENCL_VERSION > 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
1684CL_HPP_PARAM_NAME_INFO_1_2_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1687#if defined(cl_ext_device_fission)
1688CL_HPP_PARAM_NAME_DEVICE_FISSION_EXT_(CL_HPP_DECLARE_PARAM_TRAITS_)
1691#if defined(cl_khr_extended_versioning)
1692#if CL_HPP_TARGET_OPENCL_VERSION < 300
1693CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_CL3_SHARED_(CL_HPP_DECLARE_PARAM_TRAITS_)
1695CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_KHRONLY_(CL_HPP_DECLARE_PARAM_TRAITS_)
1698#if defined(cl_khr_semaphore)
1699CL_HPP_PARAM_NAME_CL_KHR_SEMAPHORE_(CL_HPP_DECLARE_PARAM_TRAITS_)
1700#if defined(CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR)
1701CL_HPP_DECLARE_PARAM_TRAITS_(cl_semaphore_info_khr, CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR, cl::vector<cl::Device>)
1705#ifdef cl_khr_external_memory
1706CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_MEMORY_(CL_HPP_DECLARE_PARAM_TRAITS_)
1709#if defined(cl_khr_external_semaphore)
1710CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_(CL_HPP_DECLARE_PARAM_TRAITS_)
1713#if defined(cl_khr_external_semaphore_opaque_fd)
1714CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_OPAQUE_FD_EXT(CL_HPP_DECLARE_PARAM_TRAITS_)
1716#if defined(cl_khr_external_semaphore_sync_fd)
1717CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_SYNC_FD_EXT(CL_HPP_DECLARE_PARAM_TRAITS_)
1719#if defined(cl_khr_external_semaphore_win32)
1720CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_WIN32_EXT(CL_HPP_DECLARE_PARAM_TRAITS_)
1723#if defined(cl_khr_device_uuid)
1724using uuid_array = array<cl_uchar, CL_UUID_SIZE_KHR>;
1725using luid_array = array<cl_uchar, CL_LUID_SIZE_KHR>;
1726CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_UUID_KHR, uuid_array)
1727CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DRIVER_UUID_KHR, uuid_array)
1728CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LUID_VALID_KHR, cl_bool)
1729CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LUID_KHR, luid_array)
1730CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_NODE_MASK_KHR, cl_uint)
1733#if defined(cl_khr_pci_bus_info)
1734CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_PCI_BUS_INFO_KHR, cl_device_pci_bus_info_khr)
1738#if CL_HPP_TARGET_OPENCL_VERSION < 200
1739#if defined(CL_DEVICE_IMAGE_PITCH_ALIGNMENT_KHR)
1740CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_IMAGE_PITCH_ALIGNMENT_KHR, cl_uint)
1742#if defined(CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT_KHR)
1743CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT_KHR, cl_uint)
1747#if defined(cl_khr_integer_dot_product)
1748CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGER_DOT_PRODUCT_CAPABILITIES_KHR, cl_device_integer_dot_product_capabilities_khr)
1749#if defined(CL_DEVICE_INTEGER_DOT_PRODUCT_ACCELERATION_PROPERTIES_8BIT_KHR)
1750CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGER_DOT_PRODUCT_ACCELERATION_PROPERTIES_8BIT_KHR, cl_device_integer_dot_product_acceleration_properties_khr)
1751CL_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)
1755#if defined(cl_ext_image_requirements_info)
1756CL_HPP_PARAM_NAME_CL_IMAGE_REQUIREMENTS_EXT(CL_HPP_DECLARE_PARAM_TRAITS_)
1759#if defined(cl_ext_image_from_buffer)
1760CL_HPP_PARAM_NAME_CL_IMAGE_REQUIREMENTS_SLICE_PITCH_ALIGNMENT_EXT(CL_HPP_DECLARE_PARAM_TRAITS_)
1763#ifdef CL_PLATFORM_ICD_SUFFIX_KHR
1764CL_HPP_DECLARE_PARAM_TRAITS_(cl_platform_info, CL_PLATFORM_ICD_SUFFIX_KHR,
string)
1767#ifdef CL_DEVICE_PROFILING_TIMER_OFFSET_AMD
1768CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_PROFILING_TIMER_OFFSET_AMD, cl_ulong)
1770#ifdef CL_DEVICE_GLOBAL_FREE_MEMORY_AMD
1771CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_FREE_MEMORY_AMD, vector<size_type>)
1773#ifdef CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD
1774CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD, cl_uint)
1776#ifdef CL_DEVICE_SIMD_WIDTH_AMD
1777CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_WIDTH_AMD, cl_uint)
1779#ifdef CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD
1780CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD, cl_uint)
1782#ifdef CL_DEVICE_WAVEFRONT_WIDTH_AMD
1783CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_WAVEFRONT_WIDTH_AMD, cl_uint)
1785#ifdef CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD
1786CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD, cl_uint)
1788#ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD
1789CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD, cl_uint)
1791#ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD
1792CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD, cl_uint)
1794#ifdef CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD
1795CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD, cl_uint)
1797#ifdef CL_DEVICE_LOCAL_MEM_BANKS_AMD
1798CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LOCAL_MEM_BANKS_AMD, cl_uint)
1800#ifdef CL_DEVICE_BOARD_NAME_AMD
1801CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_BOARD_NAME_AMD,
string)
1804#ifdef CL_DEVICE_COMPUTE_UNITS_BITFIELD_ARM
1805CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_UNITS_BITFIELD_ARM, cl_ulong)
1807#ifdef CL_DEVICE_JOB_SLOTS_ARM
1808CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_JOB_SLOTS_ARM, cl_uint)
1810#ifdef CL_DEVICE_SCHEDULING_CONTROLS_CAPABILITIES_ARM
1811CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SCHEDULING_CONTROLS_CAPABILITIES_ARM, cl_bitfield)
1813#ifdef CL_DEVICE_SUPPORTED_REGISTER_ALLOCATIONS_ARM
1814CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SUPPORTED_REGISTER_ALLOCATIONS_ARM, vector<cl_uint>)
1816#ifdef CL_DEVICE_MAX_WARP_COUNT_ARM
1817CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_MAX_WARP_COUNT_ARM, cl_uint)
1819#ifdef CL_KERNEL_MAX_WARP_COUNT_ARM
1820CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_info, CL_KERNEL_MAX_WARP_COUNT_ARM, cl_uint)
1822#ifdef CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_ARM
1823CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_ARM, cl_uint)
1825#ifdef CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_MODIFIER_ARM
1826CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_MODIFIER_ARM, cl_int)
1828#ifdef CL_KERNEL_EXEC_INFO_WARP_COUNT_LIMIT_ARM
1829CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_WARP_COUNT_LIMIT_ARM, cl_uint)
1831#ifdef CL_KERNEL_EXEC_INFO_COMPUTE_UNIT_MAX_QUEUED_BATCHES_ARM
1832CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_COMPUTE_UNIT_MAX_QUEUED_BATCHES_ARM, cl_uint)
1835#ifdef CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV
1836CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV, cl_uint)
1838#ifdef CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV
1839CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV, cl_uint)
1841#ifdef CL_DEVICE_REGISTERS_PER_BLOCK_NV
1842CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_REGISTERS_PER_BLOCK_NV, cl_uint)
1844#ifdef CL_DEVICE_WARP_SIZE_NV
1845CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_WARP_SIZE_NV, cl_uint)
1847#ifdef CL_DEVICE_GPU_OVERLAP_NV
1848CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GPU_OVERLAP_NV, cl_bool)
1850#ifdef CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV
1851CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV, cl_bool)
1853#ifdef CL_DEVICE_INTEGRATED_MEMORY_NV
1854CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGRATED_MEMORY_NV, cl_bool)
1857#if defined(cl_khr_command_buffer)
1858CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMMAND_BUFFER_CAPABILITIES_KHR, cl_device_command_buffer_capabilities_khr)
1859CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMMAND_BUFFER_REQUIRED_QUEUE_PROPERTIES_KHR, cl_command_queue_properties)
1860CL_HPP_DECLARE_PARAM_TRAITS_(cl_command_buffer_info_khr, CL_COMMAND_BUFFER_QUEUES_KHR, cl::vector<CommandQueue>)
1861CL_HPP_DECLARE_PARAM_TRAITS_(cl_command_buffer_info_khr, CL_COMMAND_BUFFER_NUM_QUEUES_KHR, cl_uint)
1862CL_HPP_DECLARE_PARAM_TRAITS_(cl_command_buffer_info_khr, CL_COMMAND_BUFFER_REFERENCE_COUNT_KHR, cl_uint)
1863CL_HPP_DECLARE_PARAM_TRAITS_(cl_command_buffer_info_khr, CL_COMMAND_BUFFER_STATE_KHR, cl_command_buffer_state_khr)
1864CL_HPP_DECLARE_PARAM_TRAITS_(cl_command_buffer_info_khr, CL_COMMAND_BUFFER_PROPERTIES_ARRAY_KHR, cl::vector<cl_command_buffer_properties_khr>)
1867#if defined(cl_khr_command_buffer_mutable_dispatch)
1868CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_COMMAND_COMMAND_QUEUE_KHR,
CommandQueue)
1869CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_COMMAND_COMMAND_BUFFER_KHR, CommandBufferKhr)
1870CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_COMMAND_COMMAND_TYPE_KHR, cl_command_type)
1872#if CL_KHR_COMMAND_BUFFER_MUTABLE_DISPATCH_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 2)
1873CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_COMMAND_PROPERTIES_ARRAY_KHR, cl::vector<cl_command_properties_khr>)
1875CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_DISPATCH_PROPERTIES_ARRAY_KHR, cl::vector<cl_ndrange_kernel_command_properties_khr>)
1877CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_DISPATCH_KERNEL_KHR, cl_kernel)
1878CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_DISPATCH_DIMENSIONS_KHR, cl_uint)
1879CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_DISPATCH_GLOBAL_WORK_OFFSET_KHR, cl::vector<size_type>)
1880CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_DISPATCH_GLOBAL_WORK_SIZE_KHR, cl::vector<size_type>)
1881CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_DISPATCH_LOCAL_WORK_SIZE_KHR, cl::vector<size_type>)
1884#if defined(cl_khr_kernel_clock)
1885CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_KERNEL_CLOCK_CAPABILITIES_KHR, cl_device_kernel_clock_capabilities_khr)
1888#if defined(cl_ext_float_atomics)
1889CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SINGLE_FP_ATOMIC_CAPABILITIES_EXT, cl_device_fp_atomic_capabilities_ext)
1890CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_DOUBLE_FP_ATOMIC_CAPABILITIES_EXT, cl_device_fp_atomic_capabilities_ext)
1891CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_HALF_FP_ATOMIC_CAPABILITIES_EXT, cl_device_fp_atomic_capabilities_ext)
1894#if defined(cl_intel_command_queue_families)
1895CL_HPP_PARAM_NAME_CL_INTEL_COMMAND_QUEUE_FAMILIES_(CL_HPP_DECLARE_PARAM_TRAITS_)
1898#if defined(cl_intel_device_attribute_query)
1899CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_IP_VERSION_INTEL, cl_uint)
1900CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_ID_INTEL, cl_uint)
1901CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_NUM_SLICES_INTEL, cl_uint)
1902CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_NUM_SUB_SLICES_PER_SLICE_INTEL, cl_uint)
1903CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_NUM_EUS_PER_SUB_SLICE_INTEL, cl_uint)
1904CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_NUM_THREADS_PER_EU_INTEL, cl_uint)
1905CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_FEATURE_CAPABILITIES_INTEL, cl_device_feature_capabilities_intel)
1908#if defined(cl_intel_required_subgroup_size)
1909CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SUB_GROUP_SIZES_INTEL, cl::vector<size_type>)
1910CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_work_group_info, CL_KERNEL_SPILL_MEM_SIZE_INTEL, cl_ulong)
1913#if defined(cl_intel_unified_shared_memory)
1914CL_HPP_PARAM_NAME_CL_INTEL_UNIFIED_SHARED_MEMORY_(CL_HPP_DECLARE_PARAM_TRAITS_)
1919template <
typename Func,
typename T>
1921getInfo(Func f, cl_uint name, T* param)
1923 return getInfoHelper(f, name, param, 0);
1926template <
typename Func,
typename Arg0>
1929 Func f_;
const Arg0& arg0_;
1931 cl_uint param, size_type size,
void* value, size_type* size_ret)
1932 {
return f_(arg0_, param, size, value, size_ret); }
1935template <
typename Func,
typename Arg0,
typename Arg1>
1936struct GetInfoFunctor1
1938 Func f_;
const Arg0& arg0_;
const Arg1& arg1_;
1940 cl_uint param, size_type size,
void* value, size_type* size_ret)
1941 {
return f_(arg0_, arg1_, param, size, value, size_ret); }
1944template <
typename Func,
typename Arg0,
typename T>
1946getInfo(Func f,
const Arg0& arg0, cl_uint name, T* param)
1949 return getInfoHelper(f0, name, param, 0);
1952template <
typename Func,
typename Arg0,
typename Arg1,
typename T>
1954getInfo(Func f,
const Arg0& arg0,
const Arg1& arg1, cl_uint name, T* param)
1957 return getInfoHelper(f0, name, param, 0);
1965#if CL_HPP_TARGET_OPENCL_VERSION >= 120
1981 static cl_int
retain(cl_device_id device)
1982 { return ::clRetainDevice(device); }
1992 static cl_int
release(cl_device_id device)
1993 { return ::clReleaseDevice(device); }
2000struct ReferenceHandler<cl_device_id>
2003 static cl_int retain(cl_device_id)
2004 {
return CL_SUCCESS; }
2006 static cl_int release(cl_device_id)
2007 {
return CL_SUCCESS; }
2015 static cl_int retain(cl_platform_id)
2016 {
return CL_SUCCESS; }
2018 static cl_int release(cl_platform_id)
2019 {
return CL_SUCCESS; }
2023struct ReferenceHandler<cl_context>
2025 static cl_int retain(cl_context context)
2026 { return ::clRetainContext(context); }
2027 static cl_int release(cl_context context)
2028 { return ::clReleaseContext(context); }
2032struct ReferenceHandler<cl_command_queue>
2034 static cl_int retain(cl_command_queue queue)
2035 { return ::clRetainCommandQueue(queue); }
2036 static cl_int release(cl_command_queue queue)
2037 { return ::clReleaseCommandQueue(queue); }
2041struct ReferenceHandler<cl_mem>
2043 static cl_int retain(cl_mem memory)
2044 { return ::clRetainMemObject(memory); }
2045 static cl_int release(cl_mem memory)
2046 { return ::clReleaseMemObject(memory); }
2050struct ReferenceHandler<cl_sampler>
2052 static cl_int retain(cl_sampler sampler)
2053 { return ::clRetainSampler(sampler); }
2054 static cl_int release(cl_sampler sampler)
2055 { return ::clReleaseSampler(sampler); }
2059struct ReferenceHandler<cl_program>
2061 static cl_int retain(cl_program program)
2062 { return ::clRetainProgram(program); }
2063 static cl_int release(cl_program program)
2064 { return ::clReleaseProgram(program); }
2068struct ReferenceHandler<cl_kernel>
2070 static cl_int retain(cl_kernel kernel)
2071 { return ::clRetainKernel(kernel); }
2072 static cl_int release(cl_kernel kernel)
2073 { return ::clReleaseKernel(kernel); }
2077struct ReferenceHandler<cl_event>
2079 static cl_int retain(cl_event event)
2080 { return ::clRetainEvent(event); }
2081 static cl_int release(cl_event event)
2082 { return ::clReleaseEvent(event); }
2085#ifdef cl_khr_semaphore
2089 static cl_int retain(cl_semaphore_khr semaphore)
2091 if (pfn_clRetainSemaphoreKHR !=
nullptr) {
2092 return pfn_clRetainSemaphoreKHR(semaphore);
2095 return CL_INVALID_OPERATION;
2098 static cl_int release(cl_semaphore_khr semaphore)
2100 if (pfn_clReleaseSemaphoreKHR !=
nullptr) {
2101 return pfn_clReleaseSemaphoreKHR(semaphore);
2104 return CL_INVALID_OPERATION;
2108#if defined(cl_khr_command_buffer)
2112 static cl_int retain(cl_command_buffer_khr cmdBufferKhr)
2114 if (pfn_clRetainCommandBufferKHR ==
nullptr) {
2115 return detail::errHandler(CL_INVALID_OPERATION, __RETAIN_COMMAND_BUFFER_KHR_ERR);
2117 return pfn_clRetainCommandBufferKHR(cmdBufferKhr);
2120 static cl_int release(cl_command_buffer_khr cmdBufferKhr)
2122 if (pfn_clReleaseCommandBufferKHR ==
nullptr) {
2123 return detail::errHandler(CL_INVALID_OPERATION, __RELEASE_COMMAND_BUFFER_KHR_ERR);
2125 return pfn_clReleaseCommandBufferKHR(cmdBufferKhr);
2133 static cl_int retain(cl_mutable_command_khr)
2134 {
return CL_SUCCESS; }
2136 static cl_int release(cl_mutable_command_khr)
2137 {
return CL_SUCCESS; }
2142#if (CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120) || \
2143 (CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200)
2145static cl_uint getVersion(
const vector<char> &versionInfo)
2147 int highVersion = 0;
2150 while(versionInfo[index] !=
'.' ) {
2152 highVersion += versionInfo[index]-
'0';
2156 while(versionInfo[index] !=
' ' && versionInfo[index] !=
'\0') {
2158 lowVersion += versionInfo[index]-
'0';
2161 return (highVersion << 16) | lowVersion;
2164static cl_uint getPlatformVersion(cl_platform_id platform)
2167 clGetPlatformInfo(platform, CL_PLATFORM_VERSION, 0,
nullptr, &size);
2169 vector<char> versionInfo(size);
2170 clGetPlatformInfo(platform, CL_PLATFORM_VERSION, size, versionInfo.data(), &size);
2171 return getVersion(versionInfo);
2174static cl_uint getDevicePlatformVersion(cl_device_id device)
2176 cl_platform_id platform;
2177 clGetDeviceInfo(device, CL_DEVICE_PLATFORM,
sizeof(platform), &platform,
nullptr);
2178 return getPlatformVersion(platform);
2181static cl_uint getContextPlatformVersion(cl_context context)
2186 clGetContextInfo(context, CL_CONTEXT_DEVICES, 0,
nullptr, &size);
2189 vector<cl_device_id> devices(size/
sizeof(cl_device_id));
2190 clGetContextInfo(context, CL_CONTEXT_DEVICES, size, devices.data(),
nullptr);
2191 return getDevicePlatformVersion(devices[0]);
2195template <
typename T>
2205 Wrapper() : object_(
nullptr) { }
2207 Wrapper(
const cl_type &obj,
bool retainObject) : object_(obj)
2210 detail::errHandler(retain(), __RETAIN_ERR);
2216 if (object_ !=
nullptr) { release(); }
2219 Wrapper(
const Wrapper<cl_type>& rhs)
2221 object_ = rhs.object_;
2222 detail::errHandler(retain(), __RETAIN_ERR);
2225 Wrapper(Wrapper<cl_type>&& rhs)
noexcept
2227 object_ = rhs.object_;
2228 rhs.object_ =
nullptr;
2231 Wrapper<cl_type>& operator = (
const Wrapper<cl_type>& rhs)
2234 detail::errHandler(release(), __RELEASE_ERR);
2235 object_ = rhs.object_;
2236 detail::errHandler(retain(), __RETAIN_ERR);
2241 Wrapper<cl_type>& operator = (Wrapper<cl_type>&& rhs)
2244 detail::errHandler(release(), __RELEASE_ERR);
2245 object_ = rhs.object_;
2246 rhs.object_ =
nullptr;
2251 Wrapper<cl_type>& operator = (
const cl_type &rhs)
2253 detail::errHandler(release(), __RELEASE_ERR);
2258 const cl_type& operator ()()
const {
return object_; }
2260 cl_type& operator ()() {
return object_; }
2262 cl_type get()
const {
return object_; }
2265 template<
typename Func,
typename U>
2266 friend inline cl_int getInfoHelper(Func, cl_uint, U*,
int,
typename U::cl_type);
2268 cl_int retain()
const
2270 if (object_ !=
nullptr) {
2271 return ReferenceHandler<cl_type>::retain(object_);
2278 cl_int release()
const
2280 if (object_ !=
nullptr) {
2281 return ReferenceHandler<cl_type>::release(object_);
2290class Wrapper<cl_device_id>
2293 typedef cl_device_id cl_type;
2297 bool referenceCountable_;
2299 static bool isReferenceCountable(cl_device_id device)
2301 bool retVal =
false;
2302#if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
2303 if (device !=
nullptr) {
2304 int version = getDevicePlatformVersion(device);
2305 if(version > ((1 << 16) + 1)) {
2309#elif CL_HPP_TARGET_OPENCL_VERSION >= 120
2317 Wrapper() : object_(nullptr), referenceCountable_(false)
2321 Wrapper(
const cl_type &obj,
bool retainObject) :
2323 referenceCountable_(false)
2325 referenceCountable_ = isReferenceCountable(obj);
2328 detail::errHandler(retain(), __RETAIN_ERR);
2337 Wrapper(
const Wrapper<cl_type>& rhs)
2339 object_ = rhs.object_;
2340 referenceCountable_ = isReferenceCountable(object_);
2341 detail::errHandler(retain(), __RETAIN_ERR);
2344 Wrapper(Wrapper<cl_type>&& rhs)
noexcept
2346 object_ = rhs.object_;
2347 referenceCountable_ = rhs.referenceCountable_;
2348 rhs.object_ =
nullptr;
2349 rhs.referenceCountable_ =
false;
2352 Wrapper<cl_type>& operator = (
const Wrapper<cl_type>& rhs)
2355 detail::errHandler(release(), __RELEASE_ERR);
2356 object_ = rhs.object_;
2357 referenceCountable_ = rhs.referenceCountable_;
2358 detail::errHandler(retain(), __RETAIN_ERR);
2363 Wrapper<cl_type>& operator = (Wrapper<cl_type>&& rhs)
2366 detail::errHandler(release(), __RELEASE_ERR);
2367 object_ = rhs.object_;
2368 referenceCountable_ = rhs.referenceCountable_;
2369 rhs.object_ =
nullptr;
2370 rhs.referenceCountable_ =
false;
2375 Wrapper<cl_type>& operator = (
const cl_type &rhs)
2377 detail::errHandler(release(), __RELEASE_ERR);
2379 referenceCountable_ = isReferenceCountable(object_);
2383 const cl_type& operator ()()
const {
return object_; }
2385 cl_type& operator ()() {
return object_; }
2387 cl_type get()
const {
return object_; }
2390 template<
typename Func,
typename U>
2391 friend inline cl_int getInfoHelper(Func, cl_uint, U*,
int,
typename U::cl_type);
2393 template<
typename Func,
typename U>
2394 friend inline cl_int getInfoHelper(Func, cl_uint, vector<U>*,
int,
typename U::cl_type);
2396 cl_int retain()
const
2398 if( object_ !=
nullptr && referenceCountable_ ) {
2399 return ReferenceHandler<cl_type>::retain(object_);
2406 cl_int release()
const
2408 if (object_ !=
nullptr && referenceCountable_) {
2409 return ReferenceHandler<cl_type>::release(object_);
2417template <
typename T>
2420 return lhs() == rhs();
2423template <
typename T>
2426 return !operator==(lhs, rhs);
2447 ImageFormat(cl_channel_order order, cl_channel_type type)
2449 image_channel_order = order;
2450 image_channel_data_type = type;
2460 this->image_channel_data_type = rhs.image_channel_data_type;
2461 this->image_channel_order = rhs.image_channel_order;
2477 static std::once_flag default_initialized_;
2479 static cl_int default_error_;
2486 static void makeDefault();
2493 static void makeDefaultProvided(
const Device &p) {
2498#ifdef CL_HPP_UNIT_TEST_ENABLE
2505 static void unitTestClearDefault() {
2511 Device() : detail::Wrapper<cl_type>() { }
2517 explicit Device(
const cl_device_id &device,
bool retainObject =
false) :
2518 detail::Wrapper<cl_type>(device, retainObject) { }
2525 cl_int *errResult =
nullptr)
2527 std::call_once(default_initialized_, makeDefault);
2528 detail::errHandler(default_error_);
2529 if (errResult !=
nullptr) {
2530 *errResult = default_error_;
2544 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_device));
2545 detail::errHandler(default_error_);
2555 detail::Wrapper<cl_type>::operator=(rhs);
2561 template <
typename T>
2562 cl_int
getInfo(cl_device_info name, T* param)
const
2564 return detail::errHandler(
2565 detail::getInfo(&::clGetDeviceInfo, object_, name, param),
2566 __GET_DEVICE_INFO_ERR);
2570 template <cl_device_info name>
typename
2572 getInfo(cl_int* err =
nullptr)
const
2575 detail::cl_device_info, name>::param_type param;
2576 cl_int result =
getInfo(name, ¶m);
2577 if (err !=
nullptr) {
2583#if CL_HPP_TARGET_OPENCL_VERSION >= 210
2592 cl_ulong retVal = 0;
2594 clGetHostTimer(this->get(), &retVal);
2597 __GET_HOST_TIMER_ERR);
2616 std::pair<cl_ulong, cl_ulong> retVal;
2618 clGetDeviceAndHostTimer(this->get(), &(retVal.first), &(retVal.second));
2621 __GET_DEVICE_AND_HOST_TIMER_ERR);
2629#if CL_HPP_TARGET_OPENCL_VERSION >= 120
2632 vector<Device>* devices);
2635#if defined(cl_ext_device_fission)
2637 cl_int
createSubDevices(
const cl_device_partition_property_ext* properties,
2638 vector<Device>* devices);
2642using BuildLogType = vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, CL_PROGRAM_BUILD_LOG>::param_type>>;
2643#if defined(CL_HPP_ENABLE_EXCEPTIONS)
2647class BuildError :
public Error
2650 BuildLogType buildLogs;
2652 BuildError(cl_int err,
const char * errStr,
const BuildLogType &vec) : Error(err, errStr), buildLogs(vec)
2656 BuildLogType getBuildLog()
const
2662 static inline cl_int buildErrHandler(
2664 const char * errStr,
2665 const BuildLogType &buildLogs)
2667 if (err != CL_SUCCESS) {
2668 throw BuildError(err, errStr, buildLogs);
2676 static inline cl_int buildErrHandler(
2678 const char * errStr,
2679 const BuildLogType &buildLogs)
2688CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Device::default_initialized_;
2689CL_HPP_DEFINE_STATIC_MEMBER_
Device Device::default_;
2690CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Device::default_error_ = CL_SUCCESS;
2702 static std::once_flag default_initialized_;
2704 static cl_int default_error_;
2711 static void makeDefault() {
2715#if defined(CL_HPP_ENABLE_EXCEPTIONS)
2723 cl_int err = ::clGetPlatformIDs(0,
nullptr, &n);
2724 if (err != CL_SUCCESS) {
2725 default_error_ = err;
2729 default_error_ = CL_INVALID_PLATFORM;
2733 vector<cl_platform_id> ids(n);
2734 err = ::clGetPlatformIDs(n, ids.data(),
nullptr);
2735 if (err != CL_SUCCESS) {
2736 default_error_ = err;
2742#if defined(CL_HPP_ENABLE_EXCEPTIONS)
2743 catch (cl::Error &e) {
2744 default_error_ = e.err();
2754 static void makeDefaultProvided(
const Platform &p) {
2759#ifdef CL_HPP_UNIT_TEST_ENABLE
2766 static void unitTestClearDefault() {
2772 Platform() : detail::Wrapper<cl_type>() { }
2781 explicit Platform(
const cl_platform_id &platform,
bool retainObject =
false) :
2782 detail::Wrapper<cl_type>(platform, retainObject) { }
2790 detail::Wrapper<cl_type>::operator=(rhs);
2795 cl_int *errResult =
nullptr)
2797 std::call_once(default_initialized_, makeDefault);
2798 detail::errHandler(default_error_);
2799 if (errResult !=
nullptr) {
2800 *errResult = default_error_;
2814 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_platform));
2815 detail::errHandler(default_error_);
2820 template <
typename T>
2821 cl_int
getInfo(cl_platform_info name, T* param)
const
2823 return detail::errHandler(
2824 detail::getInfo(&::clGetPlatformInfo, object_, name, param),
2825 __GET_PLATFORM_INFO_ERR);
2829 template <cl_platform_info name>
typename
2831 getInfo(cl_int* err =
nullptr)
const
2834 detail::cl_platform_info, name>::param_type param;
2835 cl_int result =
getInfo(name, ¶m);
2836 if (err !=
nullptr) {
2847 cl_device_type type,
2848 vector<Device>* devices)
const
2851 if( devices ==
nullptr ) {
2852 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR);
2854 cl_int err = ::clGetDeviceIDs(object_, type, 0,
nullptr, &n);
2855 if (err != CL_SUCCESS && err != CL_DEVICE_NOT_FOUND) {
2856 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2859 vector<cl_device_id> ids(n);
2861 err = ::clGetDeviceIDs(object_, type, n, ids.data(),
nullptr);
2862 if (err != CL_SUCCESS) {
2863 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2872 devices->resize(ids.size());
2876 for (size_type i = 0; i < ids.size(); i++) {
2877 (*devices)[i] =
Device(ids[i],
true);
2883#if defined(CL_HPP_USE_DX_INTEROP)
2908 cl_d3d10_device_source_khr d3d_device_source,
2910 cl_d3d10_device_set_khr d3d_device_set,
2911 vector<Device>* devices)
const
2913 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clGetDeviceIDsFromD3D10KHR)(
2914 cl_platform_id platform,
2915 cl_d3d10_device_source_khr d3d_device_source,
2917 cl_d3d10_device_set_khr d3d_device_set,
2918 cl_uint num_entries,
2919 cl_device_id * devices,
2920 cl_uint* num_devices);
2922 if( devices ==
nullptr ) {
2923 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR);
2926 static PFN_clGetDeviceIDsFromD3D10KHR pfn_clGetDeviceIDsFromD3D10KHR =
nullptr;
2927#if CL_HPP_TARGET_OPENCL_VERSION >= 120
2928 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(object_, clGetDeviceIDsFromD3D10KHR);
2930#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
2931 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetDeviceIDsFromD3D10KHR);
2935 cl_int err = pfn_clGetDeviceIDsFromD3D10KHR(
2943 if (err != CL_SUCCESS) {
2944 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2947 vector<cl_device_id> ids(n);
2948 err = pfn_clGetDeviceIDsFromD3D10KHR(
2956 if (err != CL_SUCCESS) {
2957 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2965 devices->resize(ids.size());
2969 for (size_type i = 0; i < ids.size(); i++) {
2970 (*devices)[i] = Device(ids[i],
true);
2982 vector<Platform>* platforms)
2986 if( platforms ==
nullptr ) {
2987 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_PLATFORM_IDS_ERR);
2990 cl_int err = ::clGetPlatformIDs(0,
nullptr, &n);
2991 if (err != CL_SUCCESS) {
2992 return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
2995 vector<cl_platform_id> ids(n);
2996 err = ::clGetPlatformIDs(n, ids.data(),
nullptr);
2997 if (err != CL_SUCCESS) {
2998 return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
3002 platforms->resize(ids.size());
3005 for (size_type i = 0; i < ids.size(); i++) {
3006 (*platforms)[i] =
Platform(ids[i]);
3020 Platform default_platform = Platform::getDefault(&err);
3022 *platform = default_platform;
3036 cl_int * errResult =
nullptr)
3039 Platform default_platform = Platform::getDefault(&err);
3043 return default_platform;
3046#if CL_HPP_TARGET_OPENCL_VERSION >= 120
3051 return ::clUnloadPlatformCompiler(object_);
3056#if CL_HPP_TARGET_OPENCL_VERSION >= 120
3059 vector<Device>* devices)
3062 cl_int err = clCreateSubDevices(object_, properties, 0,
nullptr, &n);
3063 if (err != CL_SUCCESS)
3065 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
3068 vector<cl_device_id> ids(n);
3069 err = clCreateSubDevices(object_, properties, n, ids.data(),
nullptr);
3070 if (err != CL_SUCCESS)
3072 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
3079 devices->resize(ids.size());
3083 for (size_type i = 0; i < ids.size(); i++)
3087 (*devices)[i] =
Device(ids[i],
false);
3095#if defined(cl_ext_device_fission)
3098 vector<Device>* devices)
3100#if CL_HPP_TARGET_OPENCL_VERSION >= 120
3101 cl::Device device(object_);
3102 cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>()();
3103 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCreateSubDevicesEXT);
3105#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
3106 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateSubDevicesEXT);
3110 cl_int err = pfn_clCreateSubDevicesEXT(object_, properties, 0,
nullptr, &n);
3111 if (err != CL_SUCCESS)
3113 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
3116 vector<cl_device_id> ids(n);
3118 pfn_clCreateSubDevicesEXT(object_, properties, n, ids.data(),
nullptr);
3119 if (err != CL_SUCCESS)
3121 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
3127 devices->resize(ids.size());
3131 for (size_type i = 0; i < ids.size(); i++)
3135 (*devices)[i] =
Device(ids[i],
false);
3143CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Platform::default_initialized_;
3144CL_HPP_DEFINE_STATIC_MEMBER_
Platform Platform::default_;
3145CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Platform::default_error_ = CL_SUCCESS;
3151#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
3156inline CL_API_PREFIX__VERSION_1_1_DEPRECATED cl_int
3161 return ::clUnloadCompiler();
3166#if defined(cl_ext_image_requirements_info)
3167enum ImageRequirementsInfoExt : cl_image_requirements_info_ext
3169 RowPitchAlign = CL_IMAGE_REQUIREMENTS_ROW_PITCH_ALIGNMENT_EXT,
3170 BaseAddAlign = CL_IMAGE_REQUIREMENTS_BASE_ADDRESS_ALIGNMENT_EXT,
3171 Size = CL_IMAGE_REQUIREMENTS_SIZE_EXT,
3172 MaxWidth = CL_IMAGE_REQUIREMENTS_MAX_WIDTH_EXT,
3173 MaxHeight = CL_IMAGE_REQUIREMENTS_MAX_HEIGHT_EXT,
3174 MaxDepth = CL_IMAGE_REQUIREMENTS_MAX_DEPTH_EXT,
3175 MaxArraySize = CL_IMAGE_REQUIREMENTS_MAX_ARRAY_SIZE_EXT,
3176#if defined(cl_ext_image_from_buffer)
3177 SlicePitchAlign = CL_IMAGE_REQUIREMENTS_SLICE_PITCH_ALIGNMENT_EXT,
3196 static std::once_flag default_initialized_;
3198 static cl_int default_error_;
3205 static void makeDefault() {
3209#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3213#if !defined(__APPLE__) && !defined(__MACOS)
3214 const Platform &p = Platform::getDefault();
3215 cl_platform_id defaultPlatform = p();
3216 cl_context_properties properties[3] = {
3217 CL_CONTEXT_PLATFORM, (cl_context_properties)defaultPlatform, 0
3220 cl_context_properties *properties =
nullptr;
3224 CL_DEVICE_TYPE_DEFAULT,
3230#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3231 catch (cl::Error &e) {
3232 default_error_ = e.err();
3243 static void makeDefaultProvided(
const Context &c) {
3247#if defined(cl_ext_image_requirements_info)
3248 struct ImageRequirementsInfo {
3250 ImageRequirementsInfo(cl_mem_flags f,
const cl_mem_properties* mem_properties,
const ImageFormat* format,
const cl_image_desc* desc)
3253 properties = mem_properties;
3254 image_format = format;
3258 cl_mem_flags flags = 0;
3259 const cl_mem_properties* properties;
3261 const cl_image_desc* image_desc;
3264 static cl_int getImageRequirementsInfoExtHelper(
const Context &context,
3265 const ImageRequirementsInfo &info,
3266 cl_image_requirements_info_ext param_name,
3267 size_type param_value_size,
3269 size_type* param_value_size_ret)
3272#if CL_HPP_TARGET_OPENCL_VERSION >= 120
3273 Device device = context.
getInfo<CL_CONTEXT_DEVICES>().at(0);
3274 cl_platform_id platform = device.
getInfo<CL_DEVICE_PLATFORM>()();
3275 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clGetImageRequirementsInfoEXT);
3277 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetImageRequirementsInfoEXT);
3280 if (pfn_clGetImageRequirementsInfoEXT ==
nullptr) {
3281 return detail::errHandler(CL_INVALID_OPERATION, __GET_IMAGE_REQUIREMENT_INFO_EXT_ERR);
3284 return detail::errHandler(
3285 pfn_clGetImageRequirementsInfoEXT(context(), info.properties,
3286 info.flags, info.image_format, info.image_desc, param_name,
3287 param_value_size, param_value, param_value_size_ret),
3288 __GET_IMAGE_REQUIREMENT_INFO_EXT_ERR);
3293#ifdef CL_HPP_UNIT_TEST_ENABLE
3300 static void unitTestClearDefault() {
3310 const vector<Device>& devices,
3311 const cl_context_properties* properties =
nullptr,
3312 void (CL_CALLBACK * notifyFptr)(
3317 void* data =
nullptr,
3318 cl_int* err =
nullptr)
3322 size_type numDevices = devices.size();
3323 vector<cl_device_id> deviceIDs(numDevices);
3325 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
3326 deviceIDs[deviceIndex] = (devices[deviceIndex])();
3329 object_ = ::clCreateContext(
3330 properties, (cl_uint) numDevices,
3332 notifyFptr, data, &error);
3334 detail::errHandler(error, __CREATE_CONTEXT_ERR);
3335 if (err !=
nullptr) {
3346 const cl_context_properties* properties =
nullptr,
3347 void (CL_CALLBACK * notifyFptr)(
3352 void* data =
nullptr,
3353 cl_int* err =
nullptr)
3357 cl_device_id deviceID = device();
3359 object_ = ::clCreateContext(
3362 notifyFptr, data, &error);
3364 detail::errHandler(error, __CREATE_CONTEXT_ERR);
3365 if (err !=
nullptr) {
3375 cl_device_type type,
3376 const cl_context_properties* properties =
nullptr,
3377 void (CL_CALLBACK * notifyFptr)(
3382 void* data =
nullptr,
3383 cl_int* err =
nullptr)
3387#if !defined(__APPLE__) && !defined(__MACOS)
3388 cl_context_properties prop[4] = {CL_CONTEXT_PLATFORM, 0, 0, 0 };
3390 if (properties ==
nullptr) {
3392 vector<Platform> platforms;
3394 if (error != CL_SUCCESS) {
3395 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
3396 if (err !=
nullptr) {
3403 cl_context_properties platform_id = 0;
3404 for (
unsigned int i = 0; i < platforms.size(); i++) {
3406 vector<Device> devices;
3408#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3412 error = platforms[i].getDevices(type, &devices);
3414#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3415 }
catch (cl::Error& e) {
3423 if (error != CL_SUCCESS && error != CL_DEVICE_NOT_FOUND) {
3424 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
3425 if (err !=
nullptr) {
3430 if (devices.size() > 0) {
3431 platform_id = (cl_context_properties)platforms[i]();
3436 if (platform_id == 0) {
3437 detail::errHandler(CL_DEVICE_NOT_FOUND, __CREATE_CONTEXT_FROM_TYPE_ERR);
3438 if (err !=
nullptr) {
3439 *err = CL_DEVICE_NOT_FOUND;
3444 prop[1] = platform_id;
3445 properties = &prop[0];
3448 object_ = ::clCreateContextFromType(
3449 properties, type, notifyFptr, data, &error);
3451 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
3452 if (err !=
nullptr) {
3464 std::call_once(default_initialized_, makeDefault);
3465 detail::errHandler(default_error_);
3466 if (err !=
nullptr) {
3467 *err = default_error_;
3481 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_context));
3482 detail::errHandler(default_error_);
3487 Context() : detail::Wrapper<cl_type>() { }
3494 explicit Context(
const cl_context& context,
bool retainObject =
false) :
3495 detail::Wrapper<cl_type>(context, retainObject) { }
3504 detail::Wrapper<cl_type>::operator=(rhs);
3509 template <
typename T>
3510 cl_int
getInfo(cl_context_info name, T* param)
const
3512 return detail::errHandler(
3513 detail::getInfo(&::clGetContextInfo, object_, name, param),
3514 __GET_CONTEXT_INFO_ERR);
3518 template <cl_context_info name>
typename
3520 getInfo(cl_int* err =
nullptr)
const
3523 detail::cl_context_info, name>::param_type param;
3524 cl_int result =
getInfo(name, ¶m);
3525 if (err !=
nullptr) {
3537 cl_mem_object_type type,
3538 vector<ImageFormat>* formats)
const
3546 cl_int err = ::clGetSupportedImageFormats(
3553 if (err != CL_SUCCESS) {
3554 return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
3557 if (numEntries > 0) {
3558 vector<ImageFormat> value(numEntries);
3559 err = ::clGetSupportedImageFormats(
3564 (cl_image_format*)value.data(),
3566 if (err != CL_SUCCESS) {
3567 return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
3570 formats->assign(value.begin(), value.end());
3580#if defined(cl_ext_image_requirements_info)
3581 template <
typename T>
3582 cl_int getImageRequirementsInfoExt(cl_image_requirements_info_ext name,
3584 cl_mem_flags flags = 0,
3585 const cl_mem_properties* properties =
nullptr,
3587 const cl_image_desc* image_desc =
nullptr)
const
3589 ImageRequirementsInfo imageInfo = {flags, properties, image_format, image_desc};
3591 return detail::errHandler(
3593 Context::getImageRequirementsInfoExtHelper, *
this, imageInfo, name, param),
3594 __GET_IMAGE_REQUIREMENT_INFO_EXT_ERR);
3597 template <cl_image_requirements_info_ext type>
typename
3598 detail::param_traits<detail::cl_image_requirements_info_ext, type>::param_type
3599 getImageRequirementsInfoExt(cl_mem_flags flags = 0,
3600 const cl_mem_properties* properties =
nullptr,
3601 const ImageFormat* image_format =
nullptr,
3602 const cl_image_desc* image_desc =
nullptr,
3603 cl_int* err =
nullptr)
const
3605 typename detail::param_traits<
3606 detail::cl_image_requirements_info_ext, type>::param_type param;
3607 cl_int result = getImageRequirementsInfoExt(type, ¶m, flags, properties, image_format, image_desc);
3608 if (err !=
nullptr) {
3615#if CL_HPP_TARGET_OPENCL_VERSION >= 300
3627 void (CL_CALLBACK * pfn_notify)(cl_context,
void *),
3628 void * user_data =
nullptr)
3630 return detail::errHandler(
3631 ::clSetContextDestructorCallback(
3635 __SET_CONTEXT_DESCTRUCTOR_CALLBACK_ERR);
3640inline void Device::makeDefault()
3645#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3652 detail::errHandler(error, __CREATE_CONTEXT_ERR);
3654 if (error != CL_SUCCESS) {
3655 default_error_ = error;
3658 default_ = context.getInfo<CL_CONTEXT_DEVICES>()[0];
3659 default_error_ = CL_SUCCESS;
3662#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3663 catch (cl::Error &e) {
3664 default_error_ = e.err();
3669CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Context::default_initialized_;
3670CL_HPP_DEFINE_STATIC_MEMBER_
Context Context::default_;
3671CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Context::default_error_ = CL_SUCCESS;
3695 explicit Event(
const cl_event& event,
bool retainObject =
false) :
3696 detail::Wrapper<cl_type>(event, retainObject) { }
3705 detail::Wrapper<cl_type>::operator=(rhs);
3710 template <
typename T>
3711 cl_int
getInfo(cl_event_info name, T* param)
const
3713 return detail::errHandler(
3714 detail::getInfo(&::clGetEventInfo, object_, name, param),
3715 __GET_EVENT_INFO_ERR);
3719 template <cl_event_info name>
typename
3721 getInfo(cl_int* err =
nullptr)
const
3724 detail::cl_event_info, name>::param_type param;
3725 cl_int result =
getInfo(name, ¶m);
3726 if (err !=
nullptr) {
3733 template <
typename T>
3736 return detail::errHandler(detail::getInfo(
3737 &::clGetEventProfilingInfo, object_, name, param),
3738 __GET_EVENT_PROFILE_INFO_ERR);
3742 template <cl_profiling_info name>
typename
3747 detail::cl_profiling_info, name>::param_type param;
3749 if (err !=
nullptr) {
3761 return detail::errHandler(
3762 ::clWaitForEvents(1, &object_),
3763 __WAIT_FOR_EVENTS_ERR);
3766#if CL_HPP_TARGET_OPENCL_VERSION >= 110
3773 void (CL_CALLBACK * pfn_notify)(cl_event, cl_int,
void *),
3774 void * user_data =
nullptr)
3776 return detail::errHandler(
3777 ::clSetEventCallback(
3782 __SET_EVENT_CALLBACK_ERR);
3793 static_assert(
sizeof(
cl::Event) ==
sizeof(cl_event),
3794 "Size of cl::Event must be equal to size of cl_event");
3796 return detail::errHandler(
3798 (cl_uint) events.size(), (events.size() > 0) ? (cl_event*)&events.front() :
nullptr),
3799 __WAIT_FOR_EVENTS_ERR);
3803#if CL_HPP_TARGET_OPENCL_VERSION >= 110
3817 cl_int * err =
nullptr)
3820 object_ = ::clCreateUserEvent(
3824 detail::errHandler(error, __CREATE_USER_EVENT_ERR);
3825 if (err !=
nullptr) {
3839 return detail::errHandler(
3840 ::clSetUserEventStatus(object_,status),
3841 __SET_USER_EVENT_STATUS_ERR);
3851WaitForEvents(
const vector<Event>& events)
3853 return detail::errHandler(
3855 (cl_uint) events.size(), (events.size() > 0) ? (cl_event*)&events.front() :
nullptr),
3856 __WAIT_FOR_EVENTS_ERR);
3884 explicit Memory(
const cl_mem& memory,
bool retainObject) :
3885 detail::Wrapper<cl_type>(memory, retainObject) { }
3894 detail::Wrapper<cl_type>::operator=(rhs);
3899 template <
typename T>
3900 cl_int
getInfo(cl_mem_info name, T* param)
const
3902 return detail::errHandler(
3903 detail::getInfo(&::clGetMemObjectInfo, object_, name, param),
3904 __GET_MEM_OBJECT_INFO_ERR);
3908 template <cl_mem_info name>
typename
3910 getInfo(cl_int* err =
nullptr)
const
3913 detail::cl_mem_info, name>::param_type param;
3914 cl_int result =
getInfo(name, ¶m);
3915 if (err !=
nullptr) {
3921#if CL_HPP_TARGET_OPENCL_VERSION >= 110
3936 void (CL_CALLBACK * pfn_notify)(cl_mem,
void *),
3937 void * user_data =
nullptr)
3939 return detail::errHandler(
3940 ::clSetMemObjectDestructorCallback(
3944 __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR);
3952template<
typename IteratorType >
3953cl_int
copy( IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer );
3954template<
typename IteratorType >
3955cl_int
copy(
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator );
3956template<
typename IteratorType >
3957cl_int
copy(
const CommandQueue &queue, IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer );
3958template<
typename IteratorType >
3959cl_int
copy(
const CommandQueue &queue,
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator );
3962#if CL_HPP_TARGET_OPENCL_VERSION >= 200
3968 static cl_svm_mem_flags getSVMMemFlags()
3975template<
class Trait = detail::SVMTraitNull>
3976class SVMTraitReadWrite
3979 static cl_svm_mem_flags getSVMMemFlags()
3981 return CL_MEM_READ_WRITE |
3982 Trait::getSVMMemFlags();
3986template<
class Trait = detail::SVMTraitNull>
3987class SVMTraitReadOnly
3990 static cl_svm_mem_flags getSVMMemFlags()
3992 return CL_MEM_READ_ONLY |
3993 Trait::getSVMMemFlags();
3997template<
class Trait = detail::SVMTraitNull>
3998class SVMTraitWriteOnly
4001 static cl_svm_mem_flags getSVMMemFlags()
4003 return CL_MEM_WRITE_ONLY |
4004 Trait::getSVMMemFlags();
4008template<
class Trait = SVMTraitReadWrite<>>
4012 static cl_svm_mem_flags getSVMMemFlags()
4014 return Trait::getSVMMemFlags();
4018template<
class Trait = SVMTraitReadWrite<>>
4022 static cl_svm_mem_flags getSVMMemFlags()
4024 return CL_MEM_SVM_FINE_GRAIN_BUFFER |
4025 Trait::getSVMMemFlags();
4029template<
class Trait = SVMTraitReadWrite<>>
4033 static cl_svm_mem_flags getSVMMemFlags()
4036 CL_MEM_SVM_FINE_GRAIN_BUFFER |
4037 CL_MEM_SVM_ATOMICS |
4038 Trait::getSVMMemFlags();
4049 const vector<Event>* events =
nullptr,
4050 Event* event =
nullptr);
4063template<
typename T,
class SVMTrait>
4069 typedef T value_type;
4070 typedef value_type* pointer;
4071 typedef const value_type* const_pointer;
4072 typedef value_type& reference;
4073 typedef const value_type& const_reference;
4074 typedef std::size_t size_type;
4075 typedef std::ptrdiff_t difference_type;
4077 template<
typename U>
4080 typedef SVMAllocator<U, SVMTrait> other;
4083 template<
typename U,
typename V>
4084 friend class SVMAllocator;
4087 context_(
Context::getDefault())
4097 SVMAllocator(
const SVMAllocator &other) :
4098 context_(other.context_)
4102 template<
typename U>
4103 SVMAllocator(
const SVMAllocator<U, SVMTrait> &other) :
4104 context_(other.context_)
4112 pointer address(reference r)
noexcept
4114 return std::addressof(r);
4117 const_pointer address(const_reference r)
noexcept
4119 return std::addressof(r);
4130 typename cl::SVMAllocator<void, SVMTrait>::const_pointer = 0,
4137 SVMTrait::getSVMMemFlags(),
4140 pointer retValue =
reinterpret_cast<pointer
>(
4142#if defined(CL_HPP_ENABLE_EXCEPTIONS)
4144 std::bad_alloc excep;
4150 if (map && !(SVMTrait::getSVMMemFlags() & CL_MEM_SVM_FINE_GRAIN_BUFFER)) {
4151 cl_int err =
enqueueMapSVM(retValue, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE, size*
sizeof(T));
4152 if (err != CL_SUCCESS) {
4153 clSVMFree(context_(), retValue);
4155#if defined(CL_HPP_ENABLE_EXCEPTIONS)
4156 std::bad_alloc excep;
4166 void deallocate(pointer p, size_type)
4168 clSVMFree(context_(), p);
4175 size_type
max_size() const noexcept
4177 size_type maxSize = std::numeric_limits<size_type>::max() /
sizeof(T);
4179 for (
const Device &d : context_.
getInfo<CL_CONTEXT_DEVICES>()) {
4182 static_cast<size_type
>(d.getInfo<CL_DEVICE_MAX_MEM_ALLOC_SIZE>()));
4188 template<
class U,
class... Args >
4189 void construct(U* p, Args&&... args)
4203 inline bool operator==(SVMAllocator
const& rhs)
4205 return (context_==rhs.context_);
4215template<
class SVMTrait>
4218 typedef void value_type;
4219 typedef value_type* pointer;
4220 typedef const value_type* const_pointer;
4222 template<
typename U>
4225 typedef SVMAllocator<U, SVMTrait> other;
4228 template<
typename U,
typename V>
4229 friend class SVMAllocator;
4232#if !defined(CL_HPP_NO_STD_UNIQUE_PTR)
4235 template<
class Alloc>
4242 typedef typename std::allocator_traits<Alloc>::pointer pointer;
4244 Deleter(
const Alloc &alloc, size_type copies) : alloc_{ alloc }, copies_{ copies }
4248 void operator()(pointer ptr)
const {
4249 Alloc tmpAlloc{ alloc_ };
4250 std::allocator_traits<Alloc>::destroy(tmpAlloc, std::addressof(*ptr));
4251 std::allocator_traits<Alloc>::deallocate(tmpAlloc, ptr, copies_);
4262template <
class T,
class Alloc,
class... Args>
4263cl::pointer<T, detail::Deleter<Alloc>>
allocate_pointer(
const Alloc &alloc_, Args&&... args)
4265 Alloc alloc(alloc_);
4266 static const size_type copies = 1;
4271 T* tmp = std::allocator_traits<Alloc>::allocate(alloc, copies);
4273#if defined(CL_HPP_ENABLE_EXCEPTIONS)
4274 std::bad_alloc excep;
4281#if defined(CL_HPP_ENABLE_EXCEPTIONS)
4285 std::allocator_traits<Alloc>::construct(
4287 std::addressof(*tmp),
4288 std::forward<Args>(args)...);
4292#if defined(CL_HPP_ENABLE_EXCEPTIONS)
4293 catch (std::bad_alloc&)
4295 std::allocator_traits<Alloc>::deallocate(alloc, tmp, copies);
4301template<
class T,
class SVMTrait,
class... Args >
4302cl::pointer<T, detail::Deleter<SVMAllocator<T, SVMTrait>>> allocate_svm(Args... args)
4304 SVMAllocator<T, SVMTrait> alloc;
4308template<
class T,
class SVMTrait,
class... Args >
4309cl::pointer<T, detail::Deleter<SVMAllocator<T, SVMTrait>>> allocate_svm(
const cl::Context &c, Args... args)
4320using coarse_svm_vector = vector<T, cl::SVMAllocator<int, cl::SVMTraitCoarse<>>>;
4326using fine_svm_vector = vector<T, cl::SVMAllocator<int, cl::SVMTraitFine<>>>;
4332using atomic_svm_vector = vector<T, cl::SVMAllocator<int, cl::SVMTraitAtomic<>>>;
4358 void* host_ptr =
nullptr,
4359 cl_int* err =
nullptr)
4362 object_ = ::clCreateBuffer(context(), flags, size, host_ptr, &error);
4364 detail::errHandler(error, __CREATE_BUFFER_ERR);
4365 if (err !=
nullptr) {
4370#if CL_HPP_TARGET_OPENCL_VERSION >= 300
4383 const vector<cl_mem_properties>& properties,
4386 void* host_ptr =
nullptr,
4387 cl_int* err =
nullptr)
4391 if (properties.empty()) {
4392 object_ = ::clCreateBufferWithProperties(context(),
nullptr, flags,
4393 size, host_ptr, &error);
4396 object_ = ::clCreateBufferWithProperties(
4397 context(), properties.data(), flags, size, host_ptr, &error);
4400 detail::errHandler(error, __CREATE_BUFFER_ERR);
4401 if (err !=
nullptr) {
4419 void* host_ptr =
nullptr,
4420 cl_int* err =
nullptr) :
Buffer(
Context::getDefault(err), flags, size, host_ptr, err) { }
4422#if CL_HPP_TARGET_OPENCL_VERSION >= 300
4436 const vector<cl_mem_properties>& properties,
4439 void* host_ptr =
nullptr,
4440 cl_int* err =
nullptr) :
Buffer(
Context::getDefault(err), properties, flags, size, host_ptr, err) { }
4448 template<
typename IteratorType >
4450 IteratorType startIterator,
4451 IteratorType endIterator,
4453 bool useHostPtr =
false,
4454 cl_int* err =
nullptr)
4456 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
4459 cl_mem_flags flags = 0;
4461 flags |= CL_MEM_READ_ONLY;
4464 flags |= CL_MEM_READ_WRITE;
4467 flags |= CL_MEM_USE_HOST_PTR;
4470 size_type size =
sizeof(DataType)*(endIterator - startIterator);
4475 object_ = ::clCreateBuffer(context(), flags, size,
const_cast<DataType*
>(&*startIterator), &error);
4477 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
4480 detail::errHandler(error, __CREATE_BUFFER_ERR);
4481 if (err !=
nullptr) {
4486 error =
cl::copy(startIterator, endIterator, *
this);
4487 detail::errHandler(error, __CREATE_BUFFER_ERR);
4488 if (err !=
nullptr) {
4499 template<
typename IteratorType >
4500 Buffer(
const Context &context, IteratorType startIterator, IteratorType endIterator,
4501 bool readOnly,
bool useHostPtr =
false, cl_int* err =
nullptr);
4507 template<
typename IteratorType >
4509 bool readOnly,
bool useHostPtr =
false, cl_int* err =
nullptr);
4521 explicit Buffer(
const cl_mem& buffer,
bool retainObject =
false) :
4522 Memory(buffer, retainObject) { }
4535#if CL_HPP_TARGET_OPENCL_VERSION >= 110
4542 cl_buffer_create_type buffer_create_type,
4543 const void * buffer_create_info,
4544 cl_int * err =
nullptr)
4548 result.object_ = ::clCreateSubBuffer(
4555 detail::errHandler(error, __CREATE_SUBBUFFER_ERR);
4556 if (err !=
nullptr) {
4565#if defined (CL_HPP_USE_DX_INTEROP)
4574class BufferD3D10 :
public Buffer
4585 const Context& context,
4587 ID3D10Buffer* bufobj,
4588 cl_int * err =
nullptr) : pfn_clCreateFromD3D10BufferKHR(nullptr)
4590 typedef CL_API_ENTRY cl_mem (CL_API_CALL *PFN_clCreateFromD3D10BufferKHR)(
4591 cl_context context, cl_mem_flags flags, ID3D10Buffer* buffer,
4592 cl_int* errcode_ret);
4593 PFN_clCreateFromD3D10BufferKHR pfn_clCreateFromD3D10BufferKHR;
4594#if CL_HPP_TARGET_OPENCL_VERSION >= 120
4595 vector<cl_context_properties> props = context.getInfo<CL_CONTEXT_PROPERTIES>();
4596 cl_platform platform =
nullptr;
4597 for(
int i = 0; i < props.size(); ++i ) {
4598 if( props[i] == CL_CONTEXT_PLATFORM ) {
4599 platform = props[i+1];
4602 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCreateFromD3D10BufferKHR);
4604#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
4605 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateFromD3D10BufferKHR);
4609 object_ = pfn_clCreateFromD3D10BufferKHR(
4616 detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
4617 if (err !=
nullptr) {
4623 BufferD3D10() : Buffer() { }
4632 explicit BufferD3D10(
const cl_mem& buffer,
bool retainObject =
false) :
4633 Buffer(buffer, retainObject) { }
4639 BufferD3D10& operator = (
const cl_mem& rhs)
4641 Buffer::operator=(rhs);
4667 cl_int * err =
nullptr)
4670 object_ = ::clCreateFromGLBuffer(
4676 detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
4677 if (err !=
nullptr) {
4692 explicit BufferGL(
const cl_mem& buffer,
bool retainObject =
false) :
4693 Buffer(buffer, retainObject) { }
4708 cl_gl_object_type *type,
4709 cl_GLuint * gl_object_name)
4711 return detail::errHandler(
4712 ::clGetGLObjectInfo(object_,type,gl_object_name),
4713 __GET_GL_OBJECT_INFO_ERR);
4737 cl_int * err =
nullptr)
4740 object_ = ::clCreateFromGLRenderbuffer(
4746 detail::errHandler(error, __CREATE_GL_RENDER_BUFFER_ERR);
4747 if (err !=
nullptr) {
4762 explicit BufferRenderGL(
const cl_mem& buffer,
bool retainObject =
false) :
4763 Buffer(buffer, retainObject) { }
4778 cl_gl_object_type *type,
4779 cl_GLuint * gl_object_name)
4781 return detail::errHandler(
4782 ::clGetGLObjectInfo(object_,type,gl_object_name),
4783 __GET_GL_OBJECT_INFO_ERR);
4806 explicit Image(
const cl_mem& image,
bool retainObject =
false) :
4807 Memory(image, retainObject) { }
4822 template <
typename T>
4823 cl_int
getImageInfo(cl_image_info name, T* param)
const
4825 return detail::errHandler(
4826 detail::getInfo(&::clGetImageInfo, object_, name, param),
4827 __GET_IMAGE_INFO_ERR);
4831 template <cl_image_info name>
typename
4836 detail::cl_image_info, name>::param_type param;
4838 if (err !=
nullptr) {
4845#if CL_HPP_TARGET_OPENCL_VERSION >= 120
4864 void* host_ptr =
nullptr,
4865 cl_int* err =
nullptr)
4869 cl_image_desc desc = {};
4870 desc.image_type = CL_MEM_OBJECT_IMAGE1D;
4871 desc.image_width = width;
4873 object_ = ::clCreateImage(
4881 detail::errHandler(error, __CREATE_IMAGE_ERR);
4882 if (err !=
nullptr) {
4890#if CL_HPP_TARGET_OPENCL_VERSION >= 300
4901 Image1D(
const Context &context,
const vector<cl_mem_properties> &properties,
4902 cl_mem_flags flags,
ImageFormat format, size_type width,
4903 void *host_ptr =
nullptr, cl_int *err =
nullptr) {
4906 cl_image_desc desc = {};
4907 desc.image_type = CL_MEM_OBJECT_IMAGE1D;
4908 desc.image_width = width;
4910 if (properties.empty()) {
4911 object_ = ::clCreateImageWithProperties(
4912 context(),
nullptr, flags, &format, &desc, host_ptr, &error);
4915 ::clCreateImageWithProperties(context(), properties.data(), flags,
4916 &format, &desc, host_ptr, &error);
4919 detail::errHandler(error, __CREATE_IMAGE_ERR);
4920 if (err !=
nullptr) {
4933 explicit Image1D(
const cl_mem& image1D,
bool retainObject =
false) :
4934 Image(image1D, retainObject) { }
4952class Image1DBuffer :
public Image
4961 cl_int* err =
nullptr)
4965 cl_image_desc desc = {};
4966 desc.image_type = CL_MEM_OBJECT_IMAGE1D_BUFFER;
4967 desc.image_width = width;
4968 desc.buffer = buffer();
4970 object_ = ::clCreateImage(
4978 detail::errHandler(error, __CREATE_IMAGE_ERR);
4979 if (err !=
nullptr) {
4986#if CL_HPP_TARGET_OPENCL_VERSION >= 300
4996 Image1DBuffer(
const Context &context,
4997 const vector<cl_mem_properties> &properties,
4998 cl_mem_flags flags,
ImageFormat format, size_type width,
4999 const Buffer &buffer, cl_int *err =
nullptr) {
5002 cl_image_desc desc = {};
5003 desc.image_type = CL_MEM_OBJECT_IMAGE1D_BUFFER;
5004 desc.image_width = width;
5005 desc.buffer = buffer();
5007 if (properties.empty()) {
5008 object_ = ::clCreateImageWithProperties(
5009 context(),
nullptr, flags, &format, &desc,
nullptr, &error);
5012 ::clCreateImageWithProperties(context(), properties.data(), flags,
5013 &format, &desc,
nullptr, &error);
5016 detail::errHandler(error, __CREATE_IMAGE_ERR);
5017 if (err !=
nullptr) {
5030 explicit Image1DBuffer(
const cl_mem& image1D,
bool retainObject =
false) :
5031 Image(image1D, retainObject) { }
5043class Image1DArray :
public Image
5050 size_type arraySize,
5053 void* host_ptr =
nullptr,
5054 cl_int* err =
nullptr)
5058 cl_image_desc desc = {};
5059 desc.image_type = CL_MEM_OBJECT_IMAGE1D_ARRAY;
5060 desc.image_width = width;
5061 desc.image_array_size = arraySize;
5062 desc.image_row_pitch = rowPitch;
5064 object_ = ::clCreateImage(
5072 detail::errHandler(error, __CREATE_IMAGE_ERR);
5073 if (err !=
nullptr) {
5080#if CL_HPP_TARGET_OPENCL_VERSION >= 300
5091 Image1DArray(
const Context &context,
5092 const vector<cl_mem_properties> &properties,
5093 cl_mem_flags flags,
ImageFormat format, size_type arraySize,
5094 size_type width, size_type rowPitch = 0,
5095 void *host_ptr =
nullptr, cl_int *err =
nullptr) {
5098 cl_image_desc desc = {};
5099 desc.image_type = CL_MEM_OBJECT_IMAGE1D_ARRAY;
5100 desc.image_width = width;
5101 desc.image_array_size = arraySize;
5102 desc.image_row_pitch = rowPitch;
5104 if (properties.empty()) {
5105 object_ = ::clCreateImageWithProperties(
5106 context(),
nullptr, flags, &format, &desc, host_ptr, &error);
5109 ::clCreateImageWithProperties(context(), properties.data(), flags,
5110 &format, &desc, host_ptr, &error);
5113 detail::errHandler(error, __CREATE_IMAGE_ERR);
5114 if (err !=
nullptr) {
5127 explicit Image1DArray(
const cl_mem& imageArray,
bool retainObject =
false) :
5128 Image(imageArray, retainObject) { }
5161 size_type row_pitch = 0,
5162 void* host_ptr =
nullptr,
5163 cl_int* err =
nullptr)
5166 bool useCreateImage;
5168#if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
5171 cl_uint version = detail::getContextPlatformVersion(context());
5172 useCreateImage = (version >= 0x10002);
5174#elif CL_HPP_TARGET_OPENCL_VERSION >= 120
5175 useCreateImage =
true;
5177 useCreateImage =
false;
5180#if CL_HPP_TARGET_OPENCL_VERSION >= 120
5183 cl_image_desc desc = {};
5184 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
5185 desc.image_width = width;
5186 desc.image_height = height;
5187 desc.image_row_pitch = row_pitch;
5189 object_ = ::clCreateImage(
5197 detail::errHandler(error, __CREATE_IMAGE_ERR);
5198 if (err !=
nullptr) {
5203#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
5204 if (!useCreateImage)
5206 object_ = ::clCreateImage2D(
5207 context(), flags,&format, width, height, row_pitch, host_ptr, &error);
5209 detail::errHandler(error, __CREATE_IMAGE2D_ERR);
5210 if (err !=
nullptr) {
5217#if CL_HPP_TARGET_OPENCL_VERSION >= 120
5229 const Buffer &sourceBuffer,
5232 size_type row_pitch = 0,
5233 cl_int* err =
nullptr)
5237 cl_image_desc desc = {};
5238 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
5239 desc.image_width = width;
5240 desc.image_height = height;
5241 desc.image_row_pitch = row_pitch;
5242 desc.buffer = sourceBuffer();
5244 object_ = ::clCreateImage(
5252 detail::errHandler(error, __CREATE_IMAGE_ERR);
5253 if (err !=
nullptr) {
5259#if CL_HPP_TARGET_OPENCL_VERSION >= 200
5274 cl_channel_order order,
5275 const Image &sourceImage,
5276 cl_int* err =
nullptr)
5281 size_type sourceWidth =
5283 size_type sourceHeight =
5285 size_type sourceRowPitch =
5287 cl_uint sourceNumMIPLevels =
5289 cl_uint sourceNumSamples =
5291 cl_image_format sourceFormat =
5296 sourceFormat.image_channel_order = order;
5298 cl_image_desc desc = {};
5299 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
5300 desc.image_width = sourceWidth;
5301 desc.image_height = sourceHeight;
5302 desc.image_row_pitch = sourceRowPitch;
5303 desc.num_mip_levels = sourceNumMIPLevels;
5304 desc.num_samples = sourceNumSamples;
5305 desc.buffer = sourceImage();
5307 object_ = ::clCreateImage(
5315 detail::errHandler(error, __CREATE_IMAGE_ERR);
5316 if (err !=
nullptr) {
5322#if CL_HPP_TARGET_OPENCL_VERSION >= 300
5333 Image2D(
const Context &context,
const vector<cl_mem_properties> &properties,
5334 cl_mem_flags flags,
ImageFormat format, size_type width,
5335 size_type height, size_type row_pitch = 0,
void *host_ptr =
nullptr,
5336 cl_int *err =
nullptr) {
5339 cl_image_desc desc = {};
5340 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
5341 desc.image_width = width;
5342 desc.image_height = height;
5343 desc.image_row_pitch = row_pitch;
5345 if (properties.empty()) {
5346 object_ = ::clCreateImageWithProperties(
5347 context(),
nullptr, flags, &format, &desc, host_ptr, &error);
5350 ::clCreateImageWithProperties(context(), properties.data(), flags,
5351 &format, &desc, host_ptr, &error);
5354 detail::errHandler(error, __CREATE_IMAGE_ERR);
5355 if (err !=
nullptr) {
5369 Image2D(
const Context &context,
const vector<cl_mem_properties> &properties,
5371 size_type width, size_type height, size_type row_pitch = 0,
5372 cl_int *err =
nullptr) {
5375 cl_image_desc desc = {};
5376 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
5377 desc.image_width = width;
5378 desc.image_height = height;
5379 desc.image_row_pitch = row_pitch;
5380 desc.buffer = buffer();
5382 if (properties.empty()) {
5383 object_ = ::clCreateImageWithProperties(
5384 context(),
nullptr, flags, &format, &desc,
nullptr, &error);
5387 ::clCreateImageWithProperties(context(), properties.data(), flags,
5388 &format, &desc,
nullptr, &error);
5391 detail::errHandler(error, __CREATE_IMAGE_ERR);
5392 if (err !=
nullptr) {
5409 explicit Image2D(
const cl_mem& image2D,
bool retainObject =
false) :
5410 Image(image2D, retainObject) { }
5424#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
5448 cl_int * err =
nullptr)
5451 object_ = ::clCreateFromGLTexture2D(
5459 detail::errHandler(error, __CREATE_GL_TEXTURE_2D_ERR);
5460 if (err !=
nullptr) {
5476 explicit Image2DGL(
const cl_mem& image,
bool retainObject =
false) :
5477 Image2D(image, retainObject) { }
5483 Image2DGL& operator = (
const cl_mem& rhs)
5491} CL_API_SUFFIX__VERSION_1_1_DEPRECATED;
5494#if CL_HPP_TARGET_OPENCL_VERSION >= 120
5498class Image2DArray :
public Image
5505 size_type arraySize,
5509 size_type slicePitch,
5510 void* host_ptr =
nullptr,
5511 cl_int* err =
nullptr)
5515 cl_image_desc desc = {};
5516 desc.image_type = CL_MEM_OBJECT_IMAGE2D_ARRAY;
5517 desc.image_width = width;
5518 desc.image_height = height;
5519 desc.image_array_size = arraySize;
5520 desc.image_row_pitch = rowPitch;
5521 desc.image_slice_pitch = slicePitch;
5523 object_ = ::clCreateImage(
5531 detail::errHandler(error, __CREATE_IMAGE_ERR);
5532 if (err !=
nullptr) {
5537#if CL_HPP_TARGET_OPENCL_VERSION >= 300
5548 Image2DArray(
const Context &context,
5549 const vector<cl_mem_properties> &properties,
5550 cl_mem_flags flags,
ImageFormat format, size_type arraySize,
5551 size_type width, size_type height, size_type rowPitch = 0,
5552 size_type slicePitch = 0,
void *host_ptr =
nullptr,
5553 cl_int *err =
nullptr) {
5556 cl_image_desc desc = {};
5557 desc.image_type = CL_MEM_OBJECT_IMAGE2D_ARRAY;
5558 desc.image_width = width;
5559 desc.image_height = height;
5560 desc.image_array_size = arraySize;
5561 desc.image_row_pitch = rowPitch;
5562 desc.image_slice_pitch = slicePitch;
5564 if (properties.empty()) {
5565 object_ = ::clCreateImageWithProperties(
5566 context(),
nullptr, flags, &format, &desc, host_ptr, &error);
5569 ::clCreateImageWithProperties(context(), properties.data(), flags,
5570 &format, &desc, host_ptr, &error);
5573 detail::errHandler(error, __CREATE_IMAGE_ERR);
5574 if (err !=
nullptr) {
5589 explicit Image2DArray(
const cl_mem& imageArray,
bool retainObject =
false) :
Image(imageArray, retainObject) { }
5620 size_type row_pitch = 0,
5621 size_type slice_pitch = 0,
5622 void* host_ptr =
nullptr,
5623 cl_int* err =
nullptr)
5626 bool useCreateImage;
5628#if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
5631 cl_uint version = detail::getContextPlatformVersion(context());
5632 useCreateImage = (version >= 0x10002);
5634#elif CL_HPP_TARGET_OPENCL_VERSION >= 120
5635 useCreateImage =
true;
5637 useCreateImage =
false;
5640#if CL_HPP_TARGET_OPENCL_VERSION >= 120
5643 cl_image_desc desc = {};
5644 desc.image_type = CL_MEM_OBJECT_IMAGE3D;
5645 desc.image_width = width;
5646 desc.image_height = height;
5647 desc.image_depth = depth;
5648 desc.image_row_pitch = row_pitch;
5649 desc.image_slice_pitch = slice_pitch;
5651 object_ = ::clCreateImage(
5659 detail::errHandler(error, __CREATE_IMAGE_ERR);
5660 if (err !=
nullptr) {
5665#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
5666 if (!useCreateImage)
5668 object_ = ::clCreateImage3D(
5669 context(), flags, &format, width, height, depth, row_pitch,
5670 slice_pitch, host_ptr, &error);
5672 detail::errHandler(error, __CREATE_IMAGE3D_ERR);
5673 if (err !=
nullptr) {
5680#if CL_HPP_TARGET_OPENCL_VERSION >= 300
5691 Image3D(
const Context &context,
const vector<cl_mem_properties> &properties,
5692 cl_mem_flags flags,
ImageFormat format, size_type width,
5693 size_type height, size_type depth, size_type row_pitch = 0,
5694 size_type slice_pitch = 0,
void *host_ptr =
nullptr,
5695 cl_int *err =
nullptr) {
5698 cl_image_desc desc = {};
5699 desc.image_type = CL_MEM_OBJECT_IMAGE3D;
5700 desc.image_width = width;
5701 desc.image_height = height;
5702 desc.image_depth = depth;
5703 desc.image_row_pitch = row_pitch;
5704 desc.image_slice_pitch = slice_pitch;
5706 if (properties.empty()) {
5707 object_ = ::clCreateImageWithProperties(
5708 context(),
nullptr, flags, &format, &desc, host_ptr, &error);
5711 ::clCreateImageWithProperties(context(), properties.data(), flags,
5712 &format, &desc, host_ptr, &error);
5715 detail::errHandler(error, __CREATE_IMAGE_ERR);
5716 if (err !=
nullptr) {
5732 explicit Image3D(
const cl_mem& image3D,
bool retainObject =
false) :
5733 Image(image3D, retainObject) { }
5747#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
5770 cl_int * err =
nullptr)
5773 object_ = ::clCreateFromGLTexture3D(
5781 detail::errHandler(error, __CREATE_GL_TEXTURE_3D_ERR);
5782 if (err !=
nullptr) {
5797 explicit Image3DGL(
const cl_mem& image,
bool retainObject =
false) :
5798 Image3D(image, retainObject) { }
5813#if CL_HPP_TARGET_OPENCL_VERSION >= 120
5820class ImageGL :
public Image
5829 cl_int * err =
nullptr)
5832 object_ = ::clCreateFromGLTexture(
5840 detail::errHandler(error, __CREATE_GL_TEXTURE_ERR);
5841 if (err !=
nullptr) {
5846 ImageGL() :
Image() { }
5855 explicit ImageGL(
const cl_mem& image,
bool retainObject =
false) :
5856 Image(image, retainObject) { }
5858 ImageGL& operator = (
const cl_mem& rhs)
5869#if CL_HPP_TARGET_OPENCL_VERSION >= 200
5891 cl_uint packet_size,
5892 cl_uint max_packets,
5893 cl_int* err =
nullptr)
5897 cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS;
5898 object_ = ::clCreatePipe(context(), flags, packet_size, max_packets,
nullptr, &error);
5900 detail::errHandler(error, __CREATE_PIPE_ERR);
5901 if (err !=
nullptr) {
5915 cl_uint packet_size,
5916 cl_uint max_packets,
5917 cl_int* err =
nullptr)
5923 cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS;
5924 object_ = ::clCreatePipe(context(), flags, packet_size, max_packets,
nullptr, &error);
5926 detail::errHandler(error, __CREATE_PIPE_ERR);
5927 if (err !=
nullptr) {
5942 explicit Pipe(
const cl_mem& pipe,
bool retainObject =
false) :
5943 Memory(pipe, retainObject) { }
5958 template <
typename T>
5959 cl_int
getInfo(cl_pipe_info name, T* param)
const
5961 return detail::errHandler(
5962 detail::getInfo(&::clGetPipeInfo, object_, name, param),
5963 __GET_PIPE_INFO_ERR);
5967 template <cl_pipe_info name>
typename
5969 getInfo(cl_int* err =
nullptr)
const
5972 detail::cl_pipe_info, name>::param_type param;
5973 cl_int result =
getInfo(name, ¶m);
5974 if (err !=
nullptr) {
6003 cl_bool normalized_coords,
6004 cl_addressing_mode addressing_mode,
6005 cl_filter_mode filter_mode,
6006 cl_int* err =
nullptr)
6010#if CL_HPP_TARGET_OPENCL_VERSION >= 200
6011 cl_sampler_properties sampler_properties[] = {
6012 CL_SAMPLER_NORMALIZED_COORDS, normalized_coords,
6013 CL_SAMPLER_ADDRESSING_MODE, addressing_mode,
6014 CL_SAMPLER_FILTER_MODE, filter_mode,
6016 object_ = ::clCreateSamplerWithProperties(
6021 detail::errHandler(error, __CREATE_SAMPLER_WITH_PROPERTIES_ERR);
6022 if (err !=
nullptr) {
6026 object_ = ::clCreateSampler(
6033 detail::errHandler(error, __CREATE_SAMPLER_ERR);
6034 if (err !=
nullptr) {
6048 explicit Sampler(
const cl_sampler& sampler,
bool retainObject =
false) :
6049 detail::Wrapper<cl_type>(sampler, retainObject) { }
6058 detail::Wrapper<cl_type>::operator=(rhs);
6065 template <
typename T>
6066 cl_int
getInfo(cl_sampler_info name, T* param)
const
6068 return detail::errHandler(
6069 detail::getInfo(&::clGetSamplerInfo, object_, name, param),
6070 __GET_SAMPLER_INFO_ERR);
6074 template <cl_sampler_info name>
typename
6076 getInfo(cl_int* err =
nullptr)
const
6079 detail::cl_sampler_info, name>::param_type param;
6080 cl_int result =
getInfo(name, ¶m);
6081 if (err !=
nullptr) {
6097 size_type sizes_[3];
6098 cl_uint dimensions_;
6120 NDRange(size_type size0, size_type size1)
6129 NDRange(size_type size0, size_type size1, size_type size2)
6150 operator const size_type*()
const {
6162 size_type
size()
const
6164 return dimensions_*
sizeof(size_type);
6172 const size_type* get()
const
6179static const NDRange NullRange;
6189template <
typename T,
class Enable =
void>
6194template <
typename T>
6195struct KernelArgumentHandler<T, typename std::enable_if<!std::is_base_of<cl::Memory, T>::value>::type>
6197 static size_type size(
const T&) {
return sizeof(T); }
6198 static const T* ptr(
const T& value) {
return &value; }
6203template <
typename T>
6204struct KernelArgumentHandler<T, typename std::enable_if<std::is_base_of<cl::Memory, T>::value>::type>
6206 static size_type size(
const T&) {
return sizeof(cl_mem); }
6207 static const cl_mem* ptr(
const T& value) {
return &(value()); }
6215 static size_type size(
const LocalSpaceArg& value) {
return value.size_; }
6216 static const void* ptr(
const LocalSpaceArg&) {
return nullptr; }
6226Local(size_type size)
6243 inline Kernel(
const Program& program,
const string& name, cl_int* err =
nullptr);
6244 inline Kernel(
const Program& program,
const char* name, cl_int* err =
nullptr);
6257 explicit Kernel(
const cl_kernel& kernel,
bool retainObject =
false) :
6258 detail::Wrapper<cl_type>(kernel, retainObject) { }
6267 detail::Wrapper<cl_type>::operator=(rhs);
6274 template <
typename T>
6275 cl_int getInfo(cl_kernel_info name, T* param)
const
6277 return detail::errHandler(
6278 detail::getInfo(&::clGetKernelInfo, object_, name, param),
6279 __GET_KERNEL_INFO_ERR);
6282 template <cl_kernel_info name>
typename
6283 detail::param_traits<detail::cl_kernel_info, name>::param_type
6284 getInfo(cl_int* err =
nullptr)
const
6286 typename detail::param_traits<
6287 detail::cl_kernel_info, name>::param_type param;
6288 cl_int result = getInfo(name, ¶m);
6289 if (err !=
nullptr) {
6295#if CL_HPP_TARGET_OPENCL_VERSION >= 120
6296 template <
typename T>
6297 cl_int getArgInfo(cl_uint argIndex, cl_kernel_arg_info name, T* param)
const
6299 return detail::errHandler(
6300 detail::getInfo(&::clGetKernelArgInfo, object_, argIndex, name, param),
6301 __GET_KERNEL_ARG_INFO_ERR);
6304 template <cl_kernel_arg_info name>
typename
6305 detail::param_traits<detail::cl_kernel_arg_info, name>::param_type
6306 getArgInfo(cl_uint argIndex, cl_int* err =
nullptr)
const
6308 typename detail::param_traits<
6309 detail::cl_kernel_arg_info, name>::param_type param;
6310 cl_int result = getArgInfo(argIndex, name, ¶m);
6311 if (err !=
nullptr) {
6318 template <
typename T>
6319 cl_int getWorkGroupInfo(
6320 const Device& device, cl_kernel_work_group_info name, T* param)
const
6322 return detail::errHandler(
6324 &::clGetKernelWorkGroupInfo, object_, device(), name, param),
6325 __GET_KERNEL_WORK_GROUP_INFO_ERR);
6328 template <cl_kernel_work_group_info name>
typename
6329 detail::param_traits<detail::cl_kernel_work_group_info, name>::param_type
6330 getWorkGroupInfo(
const Device& device, cl_int* err =
nullptr)
const
6332 typename detail::param_traits<
6333 detail::cl_kernel_work_group_info, name>::param_type param;
6334 cl_int result = getWorkGroupInfo(device, name, ¶m);
6335 if (err !=
nullptr) {
6341#if defined(CL_HPP_USE_CL_SUB_GROUPS_KHR) || CL_HPP_TARGET_OPENCL_VERSION >= 210
6342 cl_int getSubGroupInfo(
const cl::Device &dev, cl_kernel_sub_group_info name,
const cl::NDRange &range, size_type* param)
const
6344#if CL_HPP_TARGET_OPENCL_VERSION >= 210
6346 return detail::errHandler(
6347 clGetKernelSubGroupInfo(object_, dev(), name, range.
size(), range.get(),
sizeof(size_type), param,
nullptr),
6348 __GET_KERNEL_SUB_GROUP_INFO_ERR);
6352 typedef clGetKernelSubGroupInfoKHR_fn PFN_clGetKernelSubGroupInfoKHR;
6353 static PFN_clGetKernelSubGroupInfoKHR pfn_clGetKernelSubGroupInfoKHR =
nullptr;
6354 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetKernelSubGroupInfoKHR);
6356 return detail::errHandler(
6357 pfn_clGetKernelSubGroupInfoKHR(object_, dev(), name, range.
size(), range.get(),
sizeof(size_type), param,
nullptr),
6358 __GET_KERNEL_SUB_GROUP_INFO_ERR);
6363 template <cl_kernel_sub_group_info name>
6364 size_type getSubGroupInfo(
const cl::Device &dev,
const cl::NDRange &range, cl_int* err =
nullptr)
const
6367 cl_int result = getSubGroupInfo(dev, name, range, ¶m);
6368 if (err !=
nullptr) {
6375#if CL_HPP_TARGET_OPENCL_VERSION >= 200
6378 template<
typename T,
class D>
6379 cl_int
setArg(cl_uint index,
const cl::pointer<T, D> &argPtr)
6381 return detail::errHandler(
6382 ::clSetKernelArgSVMPointer(object_, index, argPtr.get()),
6383 __SET_KERNEL_ARGS_ERR);
6388 template<
typename T,
class Alloc>
6389 cl_int
setArg(cl_uint index,
const cl::vector<T, Alloc> &argPtr)
6391 return detail::errHandler(
6392 ::clSetKernelArgSVMPointer(object_, index, argPtr.data()),
6393 __SET_KERNEL_ARGS_ERR);
6398 template<
typename T>
6399 typename std::enable_if<std::is_pointer<T>::value, cl_int>::type
6400 setArg(cl_uint index,
const T argPtr)
6402 return detail::errHandler(
6403 ::clSetKernelArgSVMPointer(object_, index, argPtr),
6404 __SET_KERNEL_ARGS_ERR);
6410 template <
typename T>
6411 typename std::enable_if<!std::is_pointer<T>::value, cl_int>::type
6412 setArg(cl_uint index,
const T &value)
6414 return detail::errHandler(
6420 __SET_KERNEL_ARGS_ERR);
6423 cl_int
setArg(cl_uint index, size_type size,
const void* argPtr)
6425 return detail::errHandler(
6426 ::clSetKernelArg(object_, index, size, argPtr),
6427 __SET_KERNEL_ARGS_ERR);
6430#if CL_HPP_TARGET_OPENCL_VERSION >= 200
6437 return detail::errHandler(
6438 ::clSetKernelExecInfo(
6440 CL_KERNEL_EXEC_INFO_SVM_PTRS,
6441 sizeof(
void*)*pointerList.size(),
6442 pointerList.data()));
6449 template<
int ArrayLength>
6450 cl_int
setSVMPointers(
const std::array<void*, ArrayLength> &pointerList)
6452 return detail::errHandler(
6453 ::clSetKernelExecInfo(
6455 CL_KERNEL_EXEC_INFO_SVM_PTRS,
6456 sizeof(
void*)*pointerList.size(),
6457 pointerList.data()));
6473 cl_bool svmEnabled_ = svmEnabled ? CL_TRUE : CL_FALSE;
6474 return detail::errHandler(
6475 ::clSetKernelExecInfo(
6477 CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM,
6484 template<
int index,
int ArrayLength,
class D,
typename T0,
typename T1,
typename... Ts>
6485 void setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList,
const pointer<T0, D> &t0,
const pointer<T1, D> &t1, Ts & ... ts)
6487 pointerList[index] =
static_cast<void*
>(t0.get());
6488 setSVMPointersHelper<index + 1, ArrayLength>(pointerList, t1, ts...);
6491 template<
int index,
int ArrayLength,
typename T0,
typename T1,
typename... Ts>
6492 typename std::enable_if<std::is_pointer<T0>::value,
void>::type
6493 setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList, T0 t0, T1 t1, Ts... ts)
6495 pointerList[index] =
static_cast<void*
>(t0);
6496 setSVMPointersHelper<index + 1, ArrayLength>(pointerList, t1, ts...);
6499 template<
int index,
int ArrayLength,
typename T0,
class D>
6500 void setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList,
const pointer<T0, D> &t0)
6502 pointerList[index] =
static_cast<void*
>(t0.get());
6506 template<
int index,
int ArrayLength,
typename T0>
6507 typename std::enable_if<std::is_pointer<T0>::value,
void>::type
6508 setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList, T0 t0)
6510 pointerList[index] =
static_cast<void*
>(t0);
6513 template<
typename T0,
typename... Ts>
6516 std::array<
void*, 1 +
sizeof...(Ts)> pointerList;
6518 setSVMPointersHelper<0, 1 +
sizeof...(Ts)>(pointerList, t0, ts...);
6519 return detail::errHandler(
6520 ::clSetKernelExecInfo(
6522 CL_KERNEL_EXEC_INFO_SVM_PTRS,
6523 sizeof(
void*)*(1 +
sizeof...(Ts)),
6524 pointerList.data()));
6527 template<
typename T>
6528 cl_int setExecInfo(cl_kernel_exec_info param_name,
const T& val)
6530 return detail::errHandler(
6531 ::clSetKernelExecInfo(
6538 template<cl_kernel_exec_info name>
6539 cl_int setExecInfo(
typename detail::param_traits<detail::cl_kernel_exec_info, name>::param_type& val)
6541 return setExecInfo(name, val);
6545#if CL_HPP_TARGET_OPENCL_VERSION >= 210
6554 Kernel retValue(clCloneKernel(this->get(), &error));
6556 detail::errHandler(error, __CLONE_KERNEL_ERR);
6568#if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6569 typedef vector<vector<unsigned char>> Binaries;
6570 typedef vector<string> Sources;
6572 typedef vector<std::pair<const void*, size_type> > Binaries;
6573 typedef vector<std::pair<const char*, size_type> > Sources;
6577 const string& source,
6579 cl_int* err =
nullptr)
6583 const char * strings = source.c_str();
6584 const size_type length = source.size();
6588 object_ = ::clCreateProgramWithSource(
6589 context(), (cl_uint)1, &strings, &length, &error);
6591 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6593 if (error == CL_SUCCESS && build) {
6595 error = ::clBuildProgram(
6599#
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6607 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6610 if (err !=
nullptr) {
6617 const string& source,
6619 cl_int* err =
nullptr)
6623 const char * strings = source.c_str();
6624 const size_type length = source.size();
6626 object_ = ::clCreateProgramWithSource(
6627 context(), (cl_uint)1, &strings, &length, &error);
6629 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6631 if (error == CL_SUCCESS && build) {
6632 error = ::clBuildProgram(
6636#
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6644 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6647 if (err !=
nullptr) {
6657 const Sources& sources,
6658 cl_int* err =
nullptr)
6663 const size_type n = (size_type)sources.size();
6665 vector<size_type> lengths(n);
6666 vector<const char*> strings(n);
6668 for (size_type i = 0; i < n; ++i) {
6669#if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6670 strings[i] = sources[(int)i].data();
6671 lengths[i] = sources[(int)i].length();
6673 strings[i] = sources[(int)i].first;
6674 lengths[i] = sources[(int)i].second;
6678 object_ = ::clCreateProgramWithSource(
6679 context(), (cl_uint)n, strings.data(), lengths.data(), &error);
6681 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6682 if (err !=
nullptr) {
6693 const Sources& sources,
6694 cl_int* err =
nullptr)
6698 const size_type n = (size_type)sources.size();
6700 vector<size_type> lengths(n);
6701 vector<const char*> strings(n);
6703 for (size_type i = 0; i < n; ++i) {
6704#if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6705 strings[i] = sources[(int)i].data();
6706 lengths[i] = sources[(int)i].length();
6708 strings[i] = sources[(int)i].first;
6709 lengths[i] = sources[(int)i].second;
6713 object_ = ::clCreateProgramWithSource(
6714 context(), (cl_uint)n, strings.data(), lengths.data(), &error);
6716 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6717 if (err !=
nullptr) {
6722#if defined(CL_HPP_USE_IL_KHR) || CL_HPP_TARGET_OPENCL_VERSION >= 210
6729 const vector<char>& IL,
6731 cl_int* err =
nullptr)
6737#if CL_HPP_TARGET_OPENCL_VERSION >= 210
6739 object_ = ::clCreateProgramWithIL(
6740 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6744 typedef clCreateProgramWithILKHR_fn PFN_clCreateProgramWithILKHR;
6745 static PFN_clCreateProgramWithILKHR pfn_clCreateProgramWithILKHR =
nullptr;
6746 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateProgramWithILKHR);
6748 object_ = pfn_clCreateProgramWithILKHR(
6749 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6753 detail::errHandler(error, __CREATE_PROGRAM_WITH_IL_ERR);
6755 if (error == CL_SUCCESS && build) {
6757 error = ::clBuildProgram(
6761#
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6769 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6772 if (err !=
nullptr) {
6785 const vector<char>& IL,
6787 cl_int* err =
nullptr)
6791#if CL_HPP_TARGET_OPENCL_VERSION >= 210
6793 object_ = ::clCreateProgramWithIL(
6794 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6798 typedef clCreateProgramWithILKHR_fn PFN_clCreateProgramWithILKHR;
6799 static PFN_clCreateProgramWithILKHR pfn_clCreateProgramWithILKHR =
nullptr;
6800 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateProgramWithILKHR);
6802 object_ = pfn_clCreateProgramWithILKHR(
6803 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6807 detail::errHandler(error, __CREATE_PROGRAM_WITH_IL_ERR);
6809 if (error == CL_SUCCESS && build) {
6810 error = ::clBuildProgram(
6814#
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6822 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6825 if (err !=
nullptr) {
6852 const vector<Device>& devices,
6853 const Binaries& binaries,
6854 vector<cl_int>* binaryStatus =
nullptr,
6855 cl_int* err =
nullptr)
6859 const size_type numDevices = devices.size();
6862 if(binaries.size() != numDevices) {
6863 error = CL_INVALID_VALUE;
6864 detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
6865 if (err !=
nullptr) {
6871 vector<size_type> lengths(numDevices);
6872 vector<const unsigned char*> images(numDevices);
6873#if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6874 for (size_type i = 0; i < numDevices; ++i) {
6875 images[i] = binaries[i].data();
6876 lengths[i] = binaries[(int)i].size();
6879 for (size_type i = 0; i < numDevices; ++i) {
6880 images[i] = (
const unsigned char*)binaries[i].first;
6881 lengths[i] = binaries[(int)i].second;
6885 vector<cl_device_id> deviceIDs(numDevices);
6886 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6887 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6891 binaryStatus->resize(numDevices);
6894 object_ = ::clCreateProgramWithBinary(
6895 context(), (cl_uint) devices.size(),
6897 lengths.data(), images.data(), (binaryStatus !=
nullptr && numDevices > 0)
6898 ? &binaryStatus->front()
6901 detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
6902 if (err !=
nullptr) {
6908#if CL_HPP_TARGET_OPENCL_VERSION >= 120
6915 const vector<Device>& devices,
6916 const string& kernelNames,
6917 cl_int* err =
nullptr)
6922 size_type numDevices = devices.size();
6923 vector<cl_device_id> deviceIDs(numDevices);
6924 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6925 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6928 object_ = ::clCreateProgramWithBuiltInKernels(
6930 (cl_uint) devices.size(),
6932 kernelNames.c_str(),
6935 detail::errHandler(error, __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR);
6936 if (err !=
nullptr) {
6951 explicit Program(
const cl_program& program,
bool retainObject =
false) :
6952 detail::Wrapper<cl_type>(program, retainObject) { }
6954 Program& operator = (
const cl_program& rhs)
6956 detail::Wrapper<cl_type>::operator=(rhs);
6961 const vector<Device>& devices,
6962 const string& options,
6963 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
6964 void* data =
nullptr)
const
6966 return build(devices, options.c_str(), notifyFptr, data);
6970 const vector<Device>& devices,
6971 const char* options =
nullptr,
6972 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
6973 void* data =
nullptr)
const
6975 size_type numDevices = devices.size();
6976 vector<cl_device_id> deviceIDs(numDevices);
6978 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6979 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6982 cl_int buildError = ::clBuildProgram(
6991 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6995 const Device& device,
6996 const string& options,
6997 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
6998 void* data =
nullptr)
const
7000 return build(device, options.c_str(), notifyFptr, data);
7004 const Device& device,
7005 const char* options =
nullptr,
7006 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7007 void* data =
nullptr)
const
7009 cl_device_id deviceID = device();
7011 cl_int buildError = ::clBuildProgram(
7019 BuildLogType buildLog(0);
7020 buildLog.push_back(std::make_pair(device, getBuildInfo<CL_PROGRAM_BUILD_LOG>(device)));
7021 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, buildLog);
7025 const string& options,
7026 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7027 void* data =
nullptr)
const
7029 return build(options.c_str(), notifyFptr, data);
7033 const char* options =
nullptr,
7034 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7035 void* data =
nullptr)
const
7037 cl_int buildError = ::clBuildProgram(
7045 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
7048#if CL_HPP_TARGET_OPENCL_VERSION >= 120
7050 const string& options,
7051 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7052 void* data =
nullptr)
const
7054 return compile(options.c_str(), notifyFptr, data);
7058 const char* options =
nullptr,
7059 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7060 void* data =
nullptr)
const
7062 cl_int error = ::clCompileProgram(
7072 return detail::buildErrHandler(error, __COMPILE_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
7076 const string& options,
7077 const vector<Program>& inputHeaders,
7078 const vector<string>& headerIncludeNames,
7079 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7080 void* data =
nullptr)
const
7082 return compile(options.c_str(), inputHeaders, headerIncludeNames, notifyFptr, data);
7086 const char* options,
7087 const vector<Program>& inputHeaders,
7088 const vector<string>& headerIncludeNames,
7089 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7090 void* data =
nullptr)
const
7092 static_assert(
sizeof(cl::Program) ==
sizeof(cl_program),
7093 "Size of cl::Program must be equal to size of cl_program");
7094 vector<const char*> headerIncludeNamesCStr;
7095 for(
const string& name: headerIncludeNames) {
7096 headerIncludeNamesCStr.push_back(name.c_str());
7098 cl_int error = ::clCompileProgram(
7103 static_cast<cl_uint
>(inputHeaders.size()),
7104 reinterpret_cast<const cl_program*
>(inputHeaders.data()),
7105 reinterpret_cast<const char**
>(headerIncludeNamesCStr.data()),
7108 return detail::buildErrHandler(error, __COMPILE_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
7112 const string& options,
7113 const vector<Device>& deviceList,
7114 const vector<Program>& inputHeaders = vector<Program>(),
7115 const vector<string>& headerIncludeNames = vector<string>(),
7116 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7117 void* data =
nullptr)
const
7119 return compile(options.c_str(), deviceList, inputHeaders, headerIncludeNames, notifyFptr, data);
7123 const char* options,
7124 const vector<Device>& deviceList,
7125 const vector<Program>& inputHeaders = vector<Program>(),
7126 const vector<string>& headerIncludeNames = vector<string>(),
7127 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7128 void* data =
nullptr)
const
7130 static_assert(
sizeof(cl::Program) ==
sizeof(cl_program),
7131 "Size of cl::Program must be equal to size of cl_program");
7132 vector<const char*> headerIncludeNamesCStr;
7133 for(
const string& name: headerIncludeNames) {
7134 headerIncludeNamesCStr.push_back(name.c_str());
7136 vector<cl_device_id> deviceIDList;
7137 for(
const Device& device: deviceList) {
7138 deviceIDList.push_back(device());
7140 cl_int error = ::clCompileProgram(
7142 static_cast<cl_uint
>(deviceList.size()),
7143 reinterpret_cast<const cl_device_id*
>(deviceIDList.data()),
7145 static_cast<cl_uint
>(inputHeaders.size()),
7146 reinterpret_cast<const cl_program*
>(inputHeaders.data()),
7147 reinterpret_cast<const char**
>(headerIncludeNamesCStr.data()),
7150 return detail::buildErrHandler(error, __COMPILE_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
7154 template <
typename T>
7155 cl_int getInfo(cl_program_info name, T* param)
const
7157 return detail::errHandler(
7158 detail::getInfo(&::clGetProgramInfo, object_, name, param),
7159 __GET_PROGRAM_INFO_ERR);
7162 template <cl_program_info name>
typename
7163 detail::param_traits<detail::cl_program_info, name>::param_type
7164 getInfo(cl_int* err =
nullptr)
const
7166 typename detail::param_traits<
7167 detail::cl_program_info, name>::param_type param;
7168 cl_int result = getInfo(name, ¶m);
7169 if (err !=
nullptr) {
7175 template <
typename T>
7176 cl_int getBuildInfo(
7177 const Device& device, cl_program_build_info name, T* param)
const
7179 return detail::errHandler(
7181 &::clGetProgramBuildInfo, object_, device(), name, param),
7182 __GET_PROGRAM_BUILD_INFO_ERR);
7185 template <cl_program_build_info name>
typename
7186 detail::param_traits<detail::cl_program_build_info, name>::param_type
7187 getBuildInfo(
const Device& device, cl_int* err =
nullptr)
const
7189 typename detail::param_traits<
7190 detail::cl_program_build_info, name>::param_type param;
7191 cl_int result = getBuildInfo(device, name, ¶m);
7192 if (err !=
nullptr) {
7203 template <cl_program_build_info name>
7204 vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, name>::param_type>>
7205 getBuildInfo(cl_int *err =
nullptr)
const
7207 cl_int result = CL_SUCCESS;
7209 auto devs = getInfo<CL_PROGRAM_DEVICES>(&result);
7210 vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, name>::param_type>>
7214 if (result != CL_SUCCESS) {
7215 if (err !=
nullptr) {
7223 detail::cl_program_build_info, name>::param_type param;
7224 result = getBuildInfo(d, name, ¶m);
7228 if (result != CL_SUCCESS) {
7233 if (err !=
nullptr) {
7236 if (result != CL_SUCCESS) {
7242 cl_int createKernels(vector<Kernel>* kernels)
7245 cl_int err = ::clCreateKernelsInProgram(object_, 0,
nullptr, &numKernels);
7246 if (err != CL_SUCCESS) {
7247 return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
7250 vector<cl_kernel> value(numKernels);
7252 err = ::clCreateKernelsInProgram(
7253 object_, numKernels, value.data(),
nullptr);
7254 if (err != CL_SUCCESS) {
7255 return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
7259 kernels->resize(value.size());
7263 for (size_type i = 0; i < value.size(); i++) {
7266 (*kernels)[i] = Kernel(value[i],
false);
7272#if CL_HPP_TARGET_OPENCL_VERSION >= 220
7273#if defined(CL_USE_DEPRECATED_OPENCL_2_2_APIS)
7285 void (CL_CALLBACK * pfn_notify)(cl_program program,
void * user_data),
7286 void * user_data =
nullptr) CL_API_SUFFIX__VERSION_2_2_DEPRECATED
7288 return detail::errHandler(
7289 ::clSetProgramReleaseCallback(
7293 __SET_PROGRAM_RELEASE_CALLBACK_ERR);
7301 template <
typename T>
7302 typename std::enable_if<!std::is_pointer<T>::value, cl_int>::type
7305 return detail::errHandler(
7306 ::clSetProgramSpecializationConstant(
7311 __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR);
7320 return detail::errHandler(
7321 ::clSetProgramSpecializationConstant(
7326 __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR);
7331#if CL_HPP_TARGET_OPENCL_VERSION >= 120
7332inline Program linkProgram(
7333 const Program& input1,
7334 const Program& input2,
7335 const char* options =
nullptr,
7336 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7337 void* data =
nullptr,
7338 cl_int* err =
nullptr)
7340 cl_int error_local = CL_SUCCESS;
7341 cl_program programs[2] = { input1(), input2() };
7344 if(error_local!=CL_SUCCESS) {
7345 detail::errHandler(error_local, __LINK_PROGRAM_ERR);
7348 cl_program prog = ::clLinkProgram(
7359 detail::errHandler(error_local,__COMPILE_PROGRAM_ERR);
7360 if (err !=
nullptr) {
7370 const string& options,
7371 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7372 void* data =
nullptr,
7373 cl_int* err =
nullptr)
7375 return linkProgram(input1, input2, options.c_str(), notifyFptr, data, err);
7379 const vector<Program>& inputPrograms,
7380 const char* options =
nullptr,
7381 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7382 void* data =
nullptr,
7383 cl_int* err =
nullptr)
7385 cl_int error_local = CL_SUCCESS;
7388 static_assert(
sizeof(cl::Program) ==
sizeof(cl_program),
7389 "Size of cl::Program must be equal to size of cl_program");
7391 if(inputPrograms.size() > 0) {
7392 ctx = inputPrograms[0].getInfo<CL_PROGRAM_CONTEXT>(&error_local);
7393 if(error_local!=CL_SUCCESS) {
7394 detail::errHandler(error_local, __LINK_PROGRAM_ERR);
7398 cl_program prog = ::clLinkProgram(
7403 static_cast<cl_uint
>(inputPrograms.size()),
7404 reinterpret_cast<const cl_program *
>(inputPrograms.data()),
7409 detail::errHandler(error_local,__COMPILE_PROGRAM_ERR);
7410 if (err !=
nullptr) {
7418 const vector<Program>& inputPrograms,
7419 const string& options,
7420 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7421 void* data =
nullptr,
7422 cl_int* err =
nullptr)
7424 return linkProgram(inputPrograms, options.c_str(), notifyFptr, data, err);
7430inline cl_int cl::Program::getInfo(cl_program_info name, vector<vector<unsigned char>>* param)
const
7432 if (name != CL_PROGRAM_BINARIES) {
7433 return CL_INVALID_VALUE;
7439 vector<size_type> sizes = getInfo<CL_PROGRAM_BINARY_SIZES>();
7440 size_type numBinaries = sizes.size();
7443 param->resize(numBinaries);
7444 for (size_type i = 0; i < numBinaries; ++i) {
7445 (*param)[i].resize(sizes[i]);
7448 return detail::errHandler(
7449 detail::getInfo(&::clGetProgramInfo, object_, name, param),
7450 __GET_PROGRAM_INFO_ERR);
7457inline vector<vector<unsigned char>> cl::Program::getInfo<CL_PROGRAM_BINARIES>(cl_int* err)
const
7459 vector<vector<unsigned char>> binariesVectors;
7461 cl_int result = getInfo(CL_PROGRAM_BINARIES, &binariesVectors);
7462 if (err !=
nullptr) {
7465 return binariesVectors;
7468#if CL_HPP_TARGET_OPENCL_VERSION >= 220
7473 cl_uchar ucValue = value ? CL_UCHAR_MAX : 0;
7474 return detail::errHandler(
7475 ::clSetProgramSpecializationConstant(
7480 __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR);
7488 object_ = ::clCreateKernel(program(), name.c_str(), &error);
7489 detail::errHandler(error, __CREATE_KERNEL_ERR);
7491 if (err !=
nullptr) {
7500 object_ = ::clCreateKernel(program(), name, &error);
7501 detail::errHandler(error, __CREATE_KERNEL_ERR);
7503 if (err !=
nullptr) {
7508#ifdef cl_khr_external_memory
7509enum class ExternalMemoryType : cl_external_memory_handle_type_khr
7512#ifdef cl_khr_external_memory_opaque_fd
7513 OpaqueFd = CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_FD_KHR,
7515#ifdef cl_khr_external_memory_win32
7516 OpaqueWin32 = CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KHR,
7517 OpaqueWin32Kmt = CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KMT_KHR,
7519#ifdef cl_khr_external_memory_dma_buf
7520 DmaBuf = CL_EXTERNAL_MEMORY_HANDLE_DMA_BUF_KHR,
7525enum class QueueProperties : cl_command_queue_properties
7528 Profiling = CL_QUEUE_PROFILING_ENABLE,
7529 OutOfOrder = CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE,
7532inline QueueProperties operator|(QueueProperties lhs, QueueProperties rhs)
7534 return static_cast<QueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) |
static_cast<cl_command_queue_properties
>(rhs));
7537inline QueueProperties operator&(QueueProperties lhs, QueueProperties rhs)
7539 return static_cast<QueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) &
static_cast<cl_command_queue_properties
>(rhs));
7548 static std::once_flag default_initialized_;
7550 static cl_int default_error_;
7557 static void makeDefault()
7562#if defined(CL_HPP_ENABLE_EXCEPTIONS)
7569 if (error != CL_SUCCESS) {
7570 default_error_ = error;
7574 default_ =
CommandQueue(context, device, 0, &default_error_);
7577#if defined(CL_HPP_ENABLE_EXCEPTIONS)
7578 catch (cl::Error &e) {
7579 default_error_ = e.err();
7589 static void makeDefaultProvided(
const CommandQueue &c) {
7593#ifdef cl_khr_external_memory
7594 static std::once_flag ext_memory_initialized_;
7596 static void initMemoryExtension(
const cl::Device& device)
7598 auto platform = device.
getInfo<CL_DEVICE_PLATFORM>()();
7600 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueAcquireExternalMemObjectsKHR);
7601 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueReleaseExternalMemObjectsKHR);
7603 if ((pfn_clEnqueueAcquireExternalMemObjectsKHR ==
nullptr)
7604 && (pfn_clEnqueueReleaseExternalMemObjectsKHR ==
nullptr))
7606 detail::errHandler(CL_INVALID_VALUE, __ENQUEUE_ACQUIRE_EXTERNAL_MEMORY_ERR);
7612#ifdef CL_HPP_UNIT_TEST_ENABLE
7619 static void unitTestClearDefault() {
7630 cl_command_queue_properties properties,
7631 cl_int* err =
nullptr)
7636 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7638 if (error != CL_SUCCESS) {
7639 if (err !=
nullptr) {
7645 bool useWithProperties;
7647#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7650 cl_uint version = detail::getContextPlatformVersion(context());
7651 useWithProperties = (version >= 0x20000);
7653#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7654 useWithProperties =
true;
7656 useWithProperties =
false;
7659#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7660 if (useWithProperties) {
7661 cl_queue_properties queue_properties[] = {
7662 CL_QUEUE_PROPERTIES, properties, 0 };
7663 if ((properties & CL_QUEUE_ON_DEVICE) == 0) {
7664 object_ = ::clCreateCommandQueueWithProperties(
7665 context(), device(), queue_properties, &error);
7668 error = CL_INVALID_QUEUE_PROPERTIES;
7671 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7672 if (err !=
nullptr) {
7677#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7678 if (!useWithProperties) {
7679 object_ = ::clCreateCommandQueue(
7680 context(), device(), properties, &error);
7682 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7683 if (err !=
nullptr) {
7696 QueueProperties properties,
7697 cl_int* err =
nullptr)
7702 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7704 if (error != CL_SUCCESS) {
7705 if (err !=
nullptr) {
7711 bool useWithProperties;
7713#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7716 cl_uint version = detail::getContextPlatformVersion(context());
7717 useWithProperties = (version >= 0x20000);
7719#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7720 useWithProperties =
true;
7722 useWithProperties =
false;
7725#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7726 if (useWithProperties) {
7727 cl_queue_properties queue_properties[] = {
7728 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
7730 object_ = ::clCreateCommandQueueWithProperties(
7731 context(), device(), queue_properties, &error);
7733 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7734 if (err !=
nullptr) {
7739#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7740 if (!useWithProperties) {
7741 object_ = ::clCreateCommandQueue(
7742 context(), device(),
static_cast<cl_command_queue_properties
>(properties), &error);
7744 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7745 if (err !=
nullptr) {
7760 cl_command_queue_properties properties = 0,
7761 cl_int* err =
nullptr)
7764 bool useWithProperties;
7765 vector<cl::Device> devices;
7766 error = context.
getInfo(CL_CONTEXT_DEVICES, &devices);
7768 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7770 if (error != CL_SUCCESS)
7772 if (err !=
nullptr) {
7778#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7781 cl_uint version = detail::getContextPlatformVersion(context());
7782 useWithProperties = (version >= 0x20000);
7784#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7785 useWithProperties =
true;
7787 useWithProperties =
false;
7790#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7791 if (useWithProperties) {
7792 cl_queue_properties queue_properties[] = {
7793 CL_QUEUE_PROPERTIES, properties, 0 };
7794 if ((properties & CL_QUEUE_ON_DEVICE) == 0) {
7795 object_ = ::clCreateCommandQueueWithProperties(
7796 context(), devices[0](), queue_properties, &error);
7799 error = CL_INVALID_QUEUE_PROPERTIES;
7802 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7803 if (err !=
nullptr) {
7808#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7809 if (!useWithProperties) {
7810 object_ = ::clCreateCommandQueue(
7811 context(), devices[0](), properties, &error);
7813 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7814 if (err !=
nullptr) {
7827 QueueProperties properties,
7828 cl_int* err =
nullptr)
7831 bool useWithProperties;
7832 vector<cl::Device> devices;
7833 error = context.
getInfo(CL_CONTEXT_DEVICES, &devices);
7835 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7837 if (error != CL_SUCCESS)
7839 if (err !=
nullptr) {
7845#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7848 cl_uint version = detail::getContextPlatformVersion(context());
7849 useWithProperties = (version >= 0x20000);
7851#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7852 useWithProperties =
true;
7854 useWithProperties =
false;
7857#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7858 if (useWithProperties) {
7859 cl_queue_properties queue_properties[] = {
7860 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
7861 object_ = ::clCreateCommandQueueWithProperties(
7862 context(), devices[0](), queue_properties, &error);
7864 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7865 if (err !=
nullptr) {
7870#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7871 if (!useWithProperties) {
7872 object_ = ::clCreateCommandQueue(
7873 context(), devices[0](),
static_cast<cl_command_queue_properties
>(properties), &error);
7875 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7876 if (err !=
nullptr) {
7890 cl_command_queue_properties properties = 0,
7891 cl_int* err =
nullptr)
7894 bool useWithProperties;
7896#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7899 cl_uint version = detail::getContextPlatformVersion(context());
7900 useWithProperties = (version >= 0x20000);
7902#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7903 useWithProperties =
true;
7905 useWithProperties =
false;
7908#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7909 if (useWithProperties) {
7910 cl_queue_properties queue_properties[] = {
7911 CL_QUEUE_PROPERTIES, properties, 0 };
7912 object_ = ::clCreateCommandQueueWithProperties(
7913 context(), device(), queue_properties, &error);
7915 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7916 if (err !=
nullptr) {
7921#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7922 if (!useWithProperties) {
7923 object_ = ::clCreateCommandQueue(
7924 context(), device(), properties, &error);
7926 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7927 if (err !=
nullptr) {
7941 QueueProperties properties,
7942 cl_int* err =
nullptr)
7945 bool useWithProperties;
7947#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7950 cl_uint version = detail::getContextPlatformVersion(context());
7951 useWithProperties = (version >= 0x20000);
7953#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7954 useWithProperties =
true;
7956 useWithProperties =
false;
7959#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7960 if (useWithProperties) {
7961 cl_queue_properties queue_properties[] = {
7962 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
7963 object_ = ::clCreateCommandQueueWithProperties(
7964 context(), device(), queue_properties, &error);
7966 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7967 if (err !=
nullptr) {
7972#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7973 if (!useWithProperties) {
7974 object_ = ::clCreateCommandQueue(
7975 context(), device(),
static_cast<cl_command_queue_properties
>(properties), &error);
7977 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7978 if (err !=
nullptr) {
7987 std::call_once(default_initialized_, makeDefault);
7988#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7989 detail::errHandler(default_error_, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7991 detail::errHandler(default_error_, __CREATE_COMMAND_QUEUE_ERR);
7993 if (err !=
nullptr) {
7994 *err = default_error_;
8008 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_queue));
8009 detail::errHandler(default_error_);
8022 explicit CommandQueue(
const cl_command_queue& commandQueue,
bool retainObject =
false) :
8023 detail::Wrapper<cl_type>(commandQueue, retainObject) { }
8027 detail::Wrapper<cl_type>::operator=(rhs);
8031 template <
typename T>
8032 cl_int getInfo(cl_command_queue_info name, T* param)
const
8034 return detail::errHandler(
8036 &::clGetCommandQueueInfo, object_, name, param),
8037 __GET_COMMAND_QUEUE_INFO_ERR);
8040 template <cl_command_queue_info name>
typename
8041 detail::param_traits<detail::cl_command_queue_info, name>::param_type
8042 getInfo(cl_int* err =
nullptr)
const
8044 typename detail::param_traits<
8045 detail::cl_command_queue_info, name>::param_type param;
8046 cl_int result = getInfo(name, ¶m);
8047 if (err !=
nullptr) {
8053 cl_int enqueueReadBuffer(
8054 const Buffer& buffer,
8059 const vector<Event>* events =
nullptr,
8060 Event* event =
nullptr)
const
8063 cl_int err = detail::errHandler(
8064 ::clEnqueueReadBuffer(
8065 object_, buffer(), blocking, offset, size,
8067 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8068 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
8069 (event !=
nullptr) ? &tmp :
nullptr),
8070 __ENQUEUE_READ_BUFFER_ERR);
8072 if (event !=
nullptr && err == CL_SUCCESS)
8078 cl_int enqueueWriteBuffer(
8079 const Buffer& buffer,
8084 const vector<Event>* events =
nullptr,
8085 Event* event =
nullptr)
const
8088 cl_int err = detail::errHandler(
8089 ::clEnqueueWriteBuffer(
8090 object_, buffer(), blocking, offset, size,
8092 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8093 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
8094 (event !=
nullptr) ? &tmp :
nullptr),
8095 __ENQUEUE_WRITE_BUFFER_ERR);
8097 if (event !=
nullptr && err == CL_SUCCESS)
8103 cl_int enqueueCopyBuffer(
8106 size_type src_offset,
8107 size_type dst_offset,
8109 const vector<Event>* events =
nullptr,
8110 Event* event =
nullptr)
const
8113 cl_int err = detail::errHandler(
8114 ::clEnqueueCopyBuffer(
8115 object_, src(), dst(), src_offset, dst_offset, size,
8116 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8117 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
8118 (event !=
nullptr) ? &tmp :
nullptr),
8119 __ENQEUE_COPY_BUFFER_ERR);
8121 if (event !=
nullptr && err == CL_SUCCESS)
8126#if CL_HPP_TARGET_OPENCL_VERSION >= 110
8127 cl_int enqueueReadBufferRect(
8128 const Buffer& buffer,
8130 const array<size_type, 3>& buffer_offset,
8131 const array<size_type, 3>& host_offset,
8132 const array<size_type, 3>& region,
8133 size_type buffer_row_pitch,
8134 size_type buffer_slice_pitch,
8135 size_type host_row_pitch,
8136 size_type host_slice_pitch,
8138 const vector<Event>* events =
nullptr,
8139 Event* event =
nullptr)
const
8142 cl_int err = detail::errHandler(
8143 ::clEnqueueReadBufferRect(
8147 buffer_offset.data(),
8155 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8156 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
8157 (event !=
nullptr) ? &tmp :
nullptr),
8158 __ENQUEUE_READ_BUFFER_RECT_ERR);
8160 if (event !=
nullptr && err == CL_SUCCESS)
8166 cl_int enqueueReadBufferRect(
8167 const Buffer& buffer,
8169 const array<size_type, 2>& buffer_offset,
8170 const array<size_type, 2>& host_offset,
8171 const array<size_type, 2>& region,
8172 size_type buffer_row_pitch,
8173 size_type buffer_slice_pitch,
8174 size_type host_row_pitch,
8175 size_type host_slice_pitch,
8177 const vector<Event>* events =
nullptr,
8178 Event* event =
nullptr)
const
8180 return enqueueReadBufferRect(
8183 { buffer_offset[0], buffer_offset[1], 0 },
8184 { host_offset[0], host_offset[1], 0 },
8185 { region[0], region[1], 1 },
8195 cl_int enqueueWriteBufferRect(
8196 const Buffer& buffer,
8198 const array<size_type, 3>& buffer_offset,
8199 const array<size_type, 3>& host_offset,
8200 const array<size_type, 3>& region,
8201 size_type buffer_row_pitch,
8202 size_type buffer_slice_pitch,
8203 size_type host_row_pitch,
8204 size_type host_slice_pitch,
8206 const vector<Event>* events =
nullptr,
8207 Event* event =
nullptr)
const
8210 cl_int err = detail::errHandler(
8211 ::clEnqueueWriteBufferRect(
8215 buffer_offset.data(),
8223 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8224 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
8225 (event !=
nullptr) ? &tmp :
nullptr),
8226 __ENQUEUE_WRITE_BUFFER_RECT_ERR);
8228 if (event !=
nullptr && err == CL_SUCCESS)
8234 cl_int enqueueWriteBufferRect(
8235 const Buffer& buffer,
8237 const array<size_type, 2>& buffer_offset,
8238 const array<size_type, 2>& host_offset,
8239 const array<size_type, 2>& region,
8240 size_type buffer_row_pitch,
8241 size_type buffer_slice_pitch,
8242 size_type host_row_pitch,
8243 size_type host_slice_pitch,
8245 const vector<Event>* events =
nullptr,
8246 Event* event =
nullptr)
const
8248 return enqueueWriteBufferRect(
8251 { buffer_offset[0], buffer_offset[1], 0 },
8252 { host_offset[0], host_offset[1], 0 },
8253 { region[0], region[1], 1 },
8263 cl_int enqueueCopyBufferRect(
8266 const array<size_type, 3>& src_origin,
8267 const array<size_type, 3>& dst_origin,
8268 const array<size_type, 3>& region,
8269 size_type src_row_pitch,
8270 size_type src_slice_pitch,
8271 size_type dst_row_pitch,
8272 size_type dst_slice_pitch,
8273 const vector<Event>* events =
nullptr,
8274 Event* event =
nullptr)
const
8277 cl_int err = detail::errHandler(
8278 ::clEnqueueCopyBufferRect(
8289 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8290 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
8291 (event !=
nullptr) ? &tmp :
nullptr),
8292 __ENQEUE_COPY_BUFFER_RECT_ERR);
8294 if (event !=
nullptr && err == CL_SUCCESS)
8300 cl_int enqueueCopyBufferRect(
8303 const array<size_type, 2>& src_origin,
8304 const array<size_type, 2>& dst_origin,
8305 const array<size_type, 2>& region,
8306 size_type src_row_pitch,
8307 size_type src_slice_pitch,
8308 size_type dst_row_pitch,
8309 size_type dst_slice_pitch,
8310 const vector<Event>* events =
nullptr,
8311 Event* event =
nullptr)
const
8313 return enqueueCopyBufferRect(
8316 { src_origin[0], src_origin[1], 0 },
8317 { dst_origin[0], dst_origin[1], 0 },
8318 { region[0], region[1], 1 },
8328#if CL_HPP_TARGET_OPENCL_VERSION >= 120
8340 template<
typename PatternType>
8343 PatternType pattern,
8346 const vector<Event>* events =
nullptr,
8347 Event* event =
nullptr)
const
8350 cl_int err = detail::errHandler(
8351 ::clEnqueueFillBuffer(
8354 static_cast<void*
>(&pattern),
8355 sizeof(PatternType),
8358 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8359 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
8360 (event !=
nullptr) ? &tmp :
nullptr),
8361 __ENQUEUE_FILL_BUFFER_ERR);
8363 if (event !=
nullptr && err == CL_SUCCESS)
8370 cl_int enqueueReadImage(
8373 const array<size_type, 3>& origin,
8374 const array<size_type, 3>& region,
8375 size_type row_pitch,
8376 size_type slice_pitch,
8378 const vector<Event>* events =
nullptr,
8379 Event* event =
nullptr)
const
8382 cl_int err = detail::errHandler(
8383 ::clEnqueueReadImage(
8392 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8393 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
8394 (event !=
nullptr) ? &tmp :
nullptr),
8395 __ENQUEUE_READ_IMAGE_ERR);
8397 if (event !=
nullptr && err == CL_SUCCESS)
8403 cl_int enqueueReadImage(
8406 const array<size_type, 2>& origin,
8407 const array<size_type, 2>& region,
8408 size_type row_pitch,
8409 size_type slice_pitch,
8411 const vector<Event>* events =
nullptr,
8412 Event* event =
nullptr)
const
8414 return enqueueReadImage(
8417 { origin[0], origin[1], 0 },
8418 { region[0], region[1], 1 },
8426 cl_int enqueueWriteImage(
8429 const array<size_type, 3>& origin,
8430 const array<size_type, 3>& region,
8431 size_type row_pitch,
8432 size_type slice_pitch,
8434 const vector<Event>* events =
nullptr,
8435 Event* event =
nullptr)
const
8438 cl_int err = detail::errHandler(
8439 ::clEnqueueWriteImage(
8448 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8449 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
8450 (event !=
nullptr) ? &tmp :
nullptr),
8451 __ENQUEUE_WRITE_IMAGE_ERR);
8453 if (event !=
nullptr && err == CL_SUCCESS)
8459 cl_int enqueueWriteImage(
8462 const array<size_type, 2>& origin,
8463 const array<size_type, 2>& region,
8464 size_type row_pitch,
8465 size_type slice_pitch,
8467 const vector<Event>* events =
nullptr,
8468 Event* event =
nullptr)
const
8470 return enqueueWriteImage(
8473 { origin[0], origin[1], 0 },
8474 { region[0], region[1], 1 },
8482 cl_int enqueueCopyImage(
8485 const array<size_type, 3>& src_origin,
8486 const array<size_type, 3>& dst_origin,
8487 const array<size_type, 3>& region,
8488 const vector<Event>* events =
nullptr,
8489 Event* event =
nullptr)
const
8492 cl_int err = detail::errHandler(
8493 ::clEnqueueCopyImage(
8500 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8501 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
8502 (event !=
nullptr) ? &tmp :
nullptr),
8503 __ENQUEUE_COPY_IMAGE_ERR);
8505 if (event !=
nullptr && err == CL_SUCCESS)
8511 cl_int enqueueCopyImage(
8514 const array<size_type, 2>& src_origin,
8515 const array<size_type, 2>& dst_origin,
8516 const array<size_type, 2>& region,
8517 const vector<Event>* events =
nullptr,
8518 Event* event =
nullptr)
const
8520 return enqueueCopyImage(
8523 { src_origin[0], src_origin[1], 0 },
8524 { dst_origin[0], dst_origin[1], 0 },
8525 { region[0], region[1], 1 },
8530#if CL_HPP_TARGET_OPENCL_VERSION >= 120
8538 template <
typename T>
8539 typename std::enable_if<std::is_same<T, cl_float4>::value ||
8540 std::is_same<T, cl_int4 >::value ||
8541 std::is_same<T, cl_uint4 >::value,
8546 const array<size_type, 3>& origin,
8547 const array<size_type, 3>& region,
8548 const vector<Event>* events =
nullptr,
8549 Event* event =
nullptr)
const
8552 cl_int err = detail::errHandler(
8553 ::clEnqueueFillImage(
8556 static_cast<void*
>(&fillColor),
8559 (events !=
nullptr) ? (cl_uint)events->size() : 0,
8560 (events !=
nullptr && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8561 (event != NULL) ? &tmp :
nullptr),
8562 __ENQUEUE_FILL_IMAGE_ERR);
8564 if (event !=
nullptr && err == CL_SUCCESS) *
event = tmp;
8576 template <
typename T>
8577 typename std::enable_if<std::is_same<T, cl_float4>::value ||
8578 std::is_same<T, cl_int4 >::value ||
8579 std::is_same<T, cl_uint4 >::value, cl_int>::type
8583 const array<size_type, 2>& origin,
8584 const array<size_type, 2>& region,
8585 const vector<Event>* events =
nullptr,
8586 Event* event =
nullptr)
const
8591 { origin[0], origin[1], 0 },
8592 { region[0], region[1], 1 },
8599 cl_int enqueueCopyImageToBuffer(
8602 const array<size_type, 3>& src_origin,
8603 const array<size_type, 3>& region,
8604 size_type dst_offset,
8605 const vector<Event>* events =
nullptr,
8606 Event* event =
nullptr)
const
8609 cl_int err = detail::errHandler(
8610 ::clEnqueueCopyImageToBuffer(
8617 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8618 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
8619 (event !=
nullptr) ? &tmp :
nullptr),
8620 __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR);
8622 if (event !=
nullptr && err == CL_SUCCESS)
8628 cl_int enqueueCopyImageToBuffer(
8631 const array<size_type, 2>& src_origin,
8632 const array<size_type, 2>& region,
8633 size_type dst_offset,
8634 const vector<Event>* events =
nullptr,
8635 Event* event =
nullptr)
const
8637 return enqueueCopyImageToBuffer(
8640 { src_origin[0], src_origin[1], 0 },
8641 { region[0], region[1], 1 },
8647 cl_int enqueueCopyBufferToImage(
8650 size_type src_offset,
8651 const array<size_type, 3>& dst_origin,
8652 const array<size_type, 3>& region,
8653 const vector<Event>* events =
nullptr,
8654 Event* event =
nullptr)
const
8657 cl_int err = detail::errHandler(
8658 ::clEnqueueCopyBufferToImage(
8665 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8666 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
8667 (event !=
nullptr) ? &tmp :
nullptr),
8668 __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR);
8670 if (event !=
nullptr && err == CL_SUCCESS)
8676 cl_int enqueueCopyBufferToImage(
8679 size_type src_offset,
8680 const array<size_type, 2>& dst_origin,
8681 const array<size_type, 2>& region,
8682 const vector<Event>* events =
nullptr,
8683 Event* event =
nullptr)
const
8685 return enqueueCopyBufferToImage(
8689 { dst_origin[0], dst_origin[1], 0 },
8690 { region[0], region[1], 1 },
8695 void* enqueueMapBuffer(
8696 const Buffer& buffer,
8701 const vector<Event>* events =
nullptr,
8702 Event* event =
nullptr,
8703 cl_int* err =
nullptr)
const
8707 void * result = ::clEnqueueMapBuffer(
8708 object_, buffer(), blocking, flags, offset, size,
8709 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8710 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
8711 (event !=
nullptr) ? &tmp :
nullptr,
8714 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
8715 if (err !=
nullptr) {
8718 if (event !=
nullptr && error == CL_SUCCESS)
8724 void* enqueueMapImage(
8728 const array<size_type, 3>& origin,
8729 const array<size_type, 3>& region,
8730 size_type * row_pitch,
8731 size_type * slice_pitch,
8732 const vector<Event>* events =
nullptr,
8733 Event* event =
nullptr,
8734 cl_int* err =
nullptr)
const
8738 void * result = ::clEnqueueMapImage(
8739 object_, image(), blocking, flags,
8742 row_pitch, slice_pitch,
8743 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8744 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
8745 (event !=
nullptr) ? &tmp :
nullptr,
8748 detail::errHandler(error, __ENQUEUE_MAP_IMAGE_ERR);
8749 if (err !=
nullptr) {
8752 if (event !=
nullptr && error == CL_SUCCESS)
8757 void* enqueueMapImage(
8761 const array<size_type, 2>& origin,
8762 const array<size_type, 2>& region,
8763 size_type* row_pitch,
8764 size_type* slice_pitch,
8765 const vector<Event>* events =
nullptr,
8766 Event* event =
nullptr,
8767 cl_int* err =
nullptr)
const
8769 return enqueueMapImage(image, blocking, flags,
8770 { origin[0], origin[1], 0 },
8771 { region[0], region[1], 1 }, row_pitch,
8772 slice_pitch, events, event, err);
8775#if CL_HPP_TARGET_OPENCL_VERSION >= 200
8781 template<
typename T>
8787 const vector<Event> *events =
nullptr,
8788 Event *event =
nullptr)
const {
8790 cl_int err = detail::errHandler(::clEnqueueSVMMemcpy(
8791 object_, blocking,
static_cast<void *
>(dst_ptr),
static_cast<const void *
>(src_ptr), size,
8792 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8793 (events !=
nullptr && events->size() > 0) ? (cl_event *) &events->front() :
nullptr,
8794 (event !=
nullptr) ? &tmp :
nullptr), __ENQUEUE_COPY_SVM_ERR);
8796 if (event !=
nullptr && err == CL_SUCCESS)
8806 template<
typename T,
class D>
8808 cl::pointer<T, D> &dst_ptr,
8809 const cl::pointer<T, D> &src_ptr,
8812 const vector<Event> *events =
nullptr,
8813 Event *event =
nullptr)
const {
8815 cl_int err = detail::errHandler(::clEnqueueSVMMemcpy(
8816 object_, blocking,
static_cast<void *
>(dst_ptr.get()),
static_cast<const void *
>(src_ptr.get()),
8818 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8819 (events !=
nullptr && events->size() > 0) ? (cl_event *) &events->front() :
nullptr,
8820 (event !=
nullptr) ? &tmp :
nullptr), __ENQUEUE_COPY_SVM_ERR);
8822 if (event !=
nullptr && err == CL_SUCCESS)
8832 template<
typename T,
class Alloc>
8834 cl::vector<T, Alloc> &dst_container,
8835 const cl::vector<T, Alloc> &src_container,
8837 const vector<Event> *events =
nullptr,
8838 Event *event =
nullptr)
const {
8840 if(src_container.size() != dst_container.size()){
8841 return detail::errHandler(CL_INVALID_VALUE,__ENQUEUE_COPY_SVM_ERR);
8843 cl_int err = detail::errHandler(::clEnqueueSVMMemcpy(
8844 object_, blocking,
static_cast<void *
>(dst_container.data()),
8845 static_cast<const void *
>(src_container.data()),
8846 dst_container.size() *
sizeof(T),
8847 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8848 (events !=
nullptr && events->size() > 0) ? (cl_event *) &events->front() :
nullptr,
8849 (event != NULL) ? &tmp :
nullptr), __ENQUEUE_COPY_SVM_ERR);
8851 if (event !=
nullptr && err == CL_SUCCESS)
8861 template<
typename T,
typename PatternType>
8864 PatternType pattern,
8866 const vector<Event> *events =
nullptr,
8867 Event *event =
nullptr)
const {
8869 cl_int err = detail::errHandler(::clEnqueueSVMMemFill(
8870 object_,
static_cast<void *
>(ptr),
static_cast<void *
>(&pattern),
8871 sizeof(PatternType), size,
8872 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8873 (events !=
nullptr && events->size() > 0) ? (cl_event *) &events->front() :
nullptr,
8874 (event !=
nullptr) ? &tmp :
nullptr), __ENQUEUE_FILL_SVM_ERR);
8876 if (event !=
nullptr && err == CL_SUCCESS)
8886 template<
typename T,
class D,
typename PatternType>
8888 cl::pointer<T, D> &ptr,
8889 PatternType pattern,
8891 const vector<Event> *events =
nullptr,
8892 Event *event =
nullptr)
const {
8894 cl_int err = detail::errHandler(::clEnqueueSVMMemFill(
8895 object_,
static_cast<void *
>(ptr.get()),
static_cast<void *
>(&pattern),
8896 sizeof(PatternType), size,
8897 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8898 (events !=
nullptr && events->size() > 0) ? (cl_event *) &events->front() :
nullptr,
8899 (event !=
nullptr) ? &tmp :
nullptr), __ENQUEUE_FILL_SVM_ERR);
8901 if (event !=
nullptr && err == CL_SUCCESS)
8911 template<
typename T,
class Alloc,
typename PatternType>
8913 cl::vector<T, Alloc> &container,
8914 PatternType pattern,
8915 const vector<Event> *events =
nullptr,
8916 Event* event =
nullptr)
const
8919 cl_int err = detail::errHandler(::clEnqueueSVMMemFill(
8920 object_,
static_cast<void *
>(container.data()),
static_cast<void *
>(&pattern),
8921 sizeof(PatternType), container.size() *
sizeof(T),
8922 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8923 (events !=
nullptr && events->size() > 0) ? (cl_event *) &events->front() :
nullptr,
8924 (event !=
nullptr) ? &tmp : NULL), __ENQUEUE_FILL_SVM_ERR);
8926 if (event !=
nullptr && err == CL_SUCCESS)
8936 template<
typename T>
8942 const vector<Event>* events =
nullptr,
8943 Event* event =
nullptr)
const
8946 cl_int err = detail::errHandler(::clEnqueueSVMMap(
8947 object_, blocking, flags,
static_cast<void*
>(ptr), size,
8948 (events !=
nullptr) ? (cl_uint)events->size() : 0,
8949 (events !=
nullptr && events->size() > 0) ? (cl_event*)&events->front() :
nullptr,
8950 (event !=
nullptr) ? &tmp :
nullptr),
8951 __ENQUEUE_MAP_SVM_ERR);
8953 if (event !=
nullptr && err == CL_SUCCESS)
8964 template<
typename T,
class D>
8966 cl::pointer<T, D> &ptr,
8970 const vector<Event>* events =
nullptr,
8971 Event* event =
nullptr)
const
8974 cl_int err = detail::errHandler(::clEnqueueSVMMap(
8975 object_, blocking, flags,
static_cast<void*
>(ptr.get()), size,
8976 (events !=
nullptr) ? (cl_uint)events->size() : 0,
8977 (events !=
nullptr && events->size() > 0) ? (cl_event*)&events->front() :
nullptr,
8978 (event !=
nullptr) ? &tmp :
nullptr),
8979 __ENQUEUE_MAP_SVM_ERR);
8981 if (event !=
nullptr && err == CL_SUCCESS)
8991 template<
typename T,
class Alloc>
8993 cl::vector<T, Alloc> &container,
8996 const vector<Event>* events =
nullptr,
8997 Event* event =
nullptr)
const
9000 cl_int err = detail::errHandler(::clEnqueueSVMMap(
9001 object_, blocking, flags,
static_cast<void*
>(container.data()), container.size()*
sizeof(T),
9002 (events !=
nullptr) ? (cl_uint)events->size() : 0,
9003 (events !=
nullptr && events->size() > 0) ? (cl_event*)&events->front() :
nullptr,
9004 (event !=
nullptr) ? &tmp :
nullptr),
9005 __ENQUEUE_MAP_SVM_ERR);
9007 if (event !=
nullptr && err == CL_SUCCESS)
9014 cl_int enqueueUnmapMemObject(
9017 const vector<Event>* events =
nullptr,
9018 Event* event =
nullptr)
const
9021 cl_int err = detail::errHandler(
9022 ::clEnqueueUnmapMemObject(
9023 object_, memory(), mapped_ptr,
9024 (events !=
nullptr) ? (cl_uint) events->size() : 0,
9025 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
9026 (event !=
nullptr) ? &tmp :
nullptr),
9027 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9029 if (event !=
nullptr && err == CL_SUCCESS)
9036#if CL_HPP_TARGET_OPENCL_VERSION >= 200
9041 template<
typename T>
9044 const vector<Event>* events =
nullptr,
9045 Event* event =
nullptr)
const
9048 cl_int err = detail::errHandler(
9049 ::clEnqueueSVMUnmap(
9050 object_,
static_cast<void*
>(ptr),
9051 (events !=
nullptr) ? (cl_uint)events->size() : 0,
9052 (events !=
nullptr && events->size() > 0) ? (cl_event*)&events->front() :
nullptr,
9053 (event !=
nullptr) ? &tmp :
nullptr),
9054 __ENQUEUE_UNMAP_SVM_ERR);
9056 if (event !=
nullptr && err == CL_SUCCESS)
9066 template<
typename T,
class D>
9068 cl::pointer<T, D> &ptr,
9069 const vector<Event>* events =
nullptr,
9070 Event* event =
nullptr)
const
9073 cl_int err = detail::errHandler(
9074 ::clEnqueueSVMUnmap(
9075 object_,
static_cast<void*
>(ptr.get()),
9076 (events !=
nullptr) ? (cl_uint)events->size() : 0,
9077 (events !=
nullptr && events->size() > 0) ? (cl_event*)&events->front() :
nullptr,
9078 (event !=
nullptr) ? &tmp :
nullptr),
9079 __ENQUEUE_UNMAP_SVM_ERR);
9081 if (event !=
nullptr && err == CL_SUCCESS)
9091 template<
typename T,
class Alloc>
9093 cl::vector<T, Alloc> &container,
9094 const vector<Event>* events =
nullptr,
9095 Event* event =
nullptr)
const
9098 cl_int err = detail::errHandler(
9099 ::clEnqueueSVMUnmap(
9100 object_,
static_cast<void*
>(container.data()),
9101 (events !=
nullptr) ? (cl_uint)events->size() : 0,
9102 (events !=
nullptr && events->size() > 0) ? (cl_event*)&events->front() :
nullptr,
9103 (event !=
nullptr) ? &tmp :
nullptr),
9104 __ENQUEUE_UNMAP_SVM_ERR);
9106 if (event !=
nullptr && err == CL_SUCCESS)
9113#if CL_HPP_TARGET_OPENCL_VERSION >= 120
9126 const vector<Event> *events =
nullptr,
9127 Event *event =
nullptr)
const
9130 cl_int err = detail::errHandler(
9131 ::clEnqueueMarkerWithWaitList(
9133 (events !=
nullptr) ? (cl_uint) events->size() : 0,
9134 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
9135 (event !=
nullptr) ? &tmp :
nullptr),
9136 __ENQUEUE_MARKER_WAIT_LIST_ERR);
9138 if (event !=
nullptr && err == CL_SUCCESS)
9156 const vector<Event> *events =
nullptr,
9157 Event *event =
nullptr)
const
9160 cl_int err = detail::errHandler(
9161 ::clEnqueueBarrierWithWaitList(
9163 (events !=
nullptr) ? (cl_uint) events->size() : 0,
9164 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
9165 (event !=
nullptr) ? &tmp :
nullptr),
9166 __ENQUEUE_BARRIER_WAIT_LIST_ERR);
9168 if (event !=
nullptr && err == CL_SUCCESS)
9179 const vector<Memory> &memObjects,
9180 cl_mem_migration_flags flags,
9181 const vector<Event>* events =
nullptr,
9182 Event* event =
nullptr
9187 vector<cl_mem> localMemObjects(memObjects.size());
9189 for(
int i = 0; i < (int)memObjects.size(); ++i ) {
9190 localMemObjects[i] = memObjects[i]();
9193 cl_int err = detail::errHandler(
9194 ::clEnqueueMigrateMemObjects(
9196 (cl_uint)memObjects.size(),
9197 localMemObjects.data(),
9199 (events !=
nullptr) ? (cl_uint) events->size() : 0,
9200 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
9201 (event !=
nullptr) ? &tmp :
nullptr),
9202 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9204 if (event !=
nullptr && err == CL_SUCCESS)
9212#if CL_HPP_TARGET_OPENCL_VERSION >= 210
9218 template<
typename T>
9220 const cl::vector<T*> &svmRawPointers,
9221 const cl::vector<size_type> &sizes,
9222 cl_mem_migration_flags flags = 0,
9223 const vector<Event>* events =
nullptr,
9224 Event* event =
nullptr)
const
9227 cl_int err = detail::errHandler(::clEnqueueSVMMigrateMem(
9229 svmRawPointers.size(),
static_cast<void**
>(svmRawPointers.data()),
9232 (events !=
nullptr) ? (cl_uint)events->size() : 0,
9233 (events !=
nullptr && events->size() > 0) ? (cl_event*)&events->front() :
nullptr,
9234 (event !=
nullptr) ? &tmp :
nullptr),
9235 __ENQUEUE_MIGRATE_SVM_ERR);
9237 if (event !=
nullptr && err == CL_SUCCESS)
9247 template<
typename T>
9249 const cl::vector<T*> &svmRawPointers,
9250 cl_mem_migration_flags flags = 0,
9251 const vector<Event>* events =
nullptr,
9252 Event* event =
nullptr)
const
9254 return enqueueMigrateSVM(svmRawPointers, cl::vector<size_type>(svmRawPointers.size()), flags, events, event);
9263 template<
typename T,
class D>
9265 const cl::vector<cl::pointer<T, D>> &svmPointers,
9266 const cl::vector<size_type> &sizes,
9267 cl_mem_migration_flags flags = 0,
9268 const vector<Event>* events =
nullptr,
9269 Event* event =
nullptr)
const
9271 cl::vector<void*> svmRawPointers;
9272 svmRawPointers.reserve(svmPointers.size());
9273 for (
auto p : svmPointers) {
9274 svmRawPointers.push_back(
static_cast<void*
>(p.get()));
9285 template<
typename T,
class D>
9287 const cl::vector<cl::pointer<T, D>> &svmPointers,
9288 cl_mem_migration_flags flags = 0,
9289 const vector<Event>* events =
nullptr,
9290 Event* event =
nullptr)
const
9292 return enqueueMigrateSVM(svmPointers, cl::vector<size_type>(svmPointers.size()), flags, events, event);
9300 template<
typename T,
class Alloc>
9302 const cl::vector<cl::vector<T, Alloc>> &svmContainers,
9303 const cl::vector<size_type> &sizes,
9304 cl_mem_migration_flags flags = 0,
9305 const vector<Event>* events =
nullptr,
9306 Event* event =
nullptr)
const
9308 cl::vector<void*> svmRawPointers;
9309 svmRawPointers.reserve(svmContainers.size());
9310 for (
auto p : svmContainers) {
9311 svmRawPointers.push_back(
static_cast<void*
>(p.data()));
9321 template<
typename T,
class Alloc>
9323 const cl::vector<cl::vector<T, Alloc>> &svmContainers,
9324 cl_mem_migration_flags flags = 0,
9325 const vector<Event>* events =
nullptr,
9326 Event* event =
nullptr)
const
9328 return enqueueMigrateSVM(svmContainers, cl::vector<size_type>(svmContainers.size()), flags, events, event);
9333 cl_int enqueueNDRangeKernel(
9337 const NDRange& local = NullRange,
9338 const vector<Event>* events =
nullptr,
9339 Event* event =
nullptr)
const
9342 cl_int err = detail::errHandler(
9343 ::clEnqueueNDRangeKernel(
9344 object_, kernel(), (cl_uint) global.
dimensions(),
9345 offset.
dimensions() != 0 ? (
const size_type*) offset :
nullptr,
9346 (
const size_type*) global,
9347 local.dimensions() != 0 ? (
const size_type*) local :
nullptr,
9348 (events !=
nullptr) ? (cl_uint) events->size() : 0,
9349 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
9350 (event !=
nullptr) ? &tmp :
nullptr),
9351 __ENQUEUE_NDRANGE_KERNEL_ERR);
9353 if (event !=
nullptr && err == CL_SUCCESS)
9359#if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
9360 CL_API_PREFIX__VERSION_1_2_DEPRECATED cl_int enqueueTask(
9361 const Kernel& kernel,
9362 const vector<Event>* events =
nullptr,
9363 Event* event =
nullptr) const CL_API_SUFFIX__VERSION_1_2_DEPRECATED
9366 cl_int err = detail::errHandler(
9369 (events !=
nullptr) ? (cl_uint) events->size() : 0,
9370 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
9371 (event !=
nullptr) ? &tmp :
nullptr),
9372 __ENQUEUE_TASK_ERR);
9374 if (event !=
nullptr && err == CL_SUCCESS)
9381 cl_int enqueueNativeKernel(
9382 void (CL_CALLBACK *userFptr)(
void *),
9383 std::pair<void*, size_type> args,
9384 const vector<Memory>* mem_objects =
nullptr,
9385 const vector<const void*>* mem_locs =
nullptr,
9386 const vector<Event>* events =
nullptr,
9387 Event* event =
nullptr)
const
9390 cl_int err = detail::errHandler(
9391 ::clEnqueueNativeKernel(
9392 object_, userFptr, args.first, args.second,
9393 (mem_objects !=
nullptr) ? (cl_uint) mem_objects->size() : 0,
9394 (mem_objects->size() > 0 ) ?
reinterpret_cast<const cl_mem *
>(mem_objects->data()) :
nullptr,
9395 (mem_locs !=
nullptr && mem_locs->size() > 0) ? (
const void **) &mem_locs->front() :
nullptr,
9396 (events !=
nullptr) ? (cl_uint) events->size() : 0,
9397 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
9398 (event !=
nullptr) ? &tmp :
nullptr),
9399 __ENQUEUE_NATIVE_KERNEL);
9401 if (event !=
nullptr && err == CL_SUCCESS)
9410#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
9411 CL_API_PREFIX__VERSION_1_1_DEPRECATED
9412 cl_int
enqueueMarker(
Event* event =
nullptr) const CL_API_SUFFIX__VERSION_1_1_DEPRECATED
9415 cl_int err = detail::errHandler(
9418 (event !=
nullptr) ? &tmp :
nullptr),
9419 __ENQUEUE_MARKER_ERR);
9421 if (event !=
nullptr && err == CL_SUCCESS)
9427 CL_API_PREFIX__VERSION_1_1_DEPRECATED
9428 cl_int enqueueWaitForEvents(
const vector<Event>& events)
const CL_API_SUFFIX__VERSION_1_1_DEPRECATED
9430 return detail::errHandler(
9431 ::clEnqueueWaitForEvents(
9433 (cl_uint) events.size(),
9434 events.size() > 0 ? (
const cl_event*) &events.front() :
nullptr),
9435 __ENQUEUE_WAIT_FOR_EVENTS_ERR);
9439 cl_int enqueueAcquireGLObjects(
9440 const vector<Memory>* mem_objects =
nullptr,
9441 const vector<Event>* events =
nullptr,
9442 Event* event =
nullptr)
const
9445 cl_int err = detail::errHandler(
9446 ::clEnqueueAcquireGLObjects(
9448 (mem_objects !=
nullptr) ? (cl_uint) mem_objects->size() : 0,
9449 (mem_objects !=
nullptr && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front():
nullptr,
9450 (events !=
nullptr) ? (cl_uint) events->size() : 0,
9451 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
9452 (event !=
nullptr) ? &tmp :
nullptr),
9453 __ENQUEUE_ACQUIRE_GL_ERR);
9455 if (event !=
nullptr && err == CL_SUCCESS)
9461 cl_int enqueueReleaseGLObjects(
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 ::clEnqueueReleaseGLObjects(
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) ? (cl_event*) &events->front() :
nullptr,
9474 (event !=
nullptr) ? &tmp :
nullptr),
9475 __ENQUEUE_RELEASE_GL_ERR);
9477 if (event !=
nullptr && err == CL_SUCCESS)
9483#if defined (CL_HPP_USE_DX_INTEROP)
9484typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueAcquireD3D10ObjectsKHR)(
9485 cl_command_queue command_queue, cl_uint num_objects,
9486 const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
9487 const cl_event* event_wait_list, cl_event* event);
9488typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueReleaseD3D10ObjectsKHR)(
9489 cl_command_queue command_queue, cl_uint num_objects,
9490 const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
9491 const cl_event* event_wait_list, cl_event* event);
9493 cl_int enqueueAcquireD3D10Objects(
9494 const vector<Memory>* mem_objects =
nullptr,
9495 const vector<Event>* events =
nullptr,
9496 Event* event =
nullptr)
const
9498 static PFN_clEnqueueAcquireD3D10ObjectsKHR pfn_clEnqueueAcquireD3D10ObjectsKHR =
nullptr;
9499#if CL_HPP_TARGET_OPENCL_VERSION >= 120
9500 cl_context context = getInfo<CL_QUEUE_CONTEXT>();
9501 cl::Device device(getInfo<CL_QUEUE_DEVICE>());
9502 cl_platform_id platform = device.
getInfo<CL_DEVICE_PLATFORM>();
9503 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueAcquireD3D10ObjectsKHR);
9505#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
9506 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueAcquireD3D10ObjectsKHR);
9510 cl_int err = detail::errHandler(
9511 pfn_clEnqueueAcquireD3D10ObjectsKHR(
9513 (mem_objects !=
nullptr) ? (cl_uint) mem_objects->size() : 0,
9514 (mem_objects !=
nullptr && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front():
nullptr,
9515 (events !=
nullptr) ? (cl_uint) events->size() : 0,
9516 (events !=
nullptr) ? (cl_event*) &events->front() :
nullptr,
9517 (event !=
nullptr) ? &tmp :
nullptr),
9518 __ENQUEUE_ACQUIRE_GL_ERR);
9520 if (event !=
nullptr && err == CL_SUCCESS)
9526 cl_int enqueueReleaseD3D10Objects(
9527 const vector<Memory>* mem_objects =
nullptr,
9528 const vector<Event>* events =
nullptr,
9529 Event* event =
nullptr)
const
9531 static PFN_clEnqueueReleaseD3D10ObjectsKHR pfn_clEnqueueReleaseD3D10ObjectsKHR =
nullptr;
9532#if CL_HPP_TARGET_OPENCL_VERSION >= 120
9533 cl_context context = getInfo<CL_QUEUE_CONTEXT>();
9534 cl::Device device(getInfo<CL_QUEUE_DEVICE>());
9535 cl_platform_id platform = device.
getInfo<CL_DEVICE_PLATFORM>();
9536 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueReleaseD3D10ObjectsKHR);
9538#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
9539 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueReleaseD3D10ObjectsKHR);
9543 cl_int err = detail::errHandler(
9544 pfn_clEnqueueReleaseD3D10ObjectsKHR(
9546 (mem_objects !=
nullptr) ? (cl_uint) mem_objects->size() : 0,
9547 (mem_objects !=
nullptr && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front():
nullptr,
9548 (events !=
nullptr) ? (cl_uint) events->size() : 0,
9549 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
9550 (event !=
nullptr) ? &tmp :
nullptr),
9551 __ENQUEUE_RELEASE_GL_ERR);
9553 if (event !=
nullptr && err == CL_SUCCESS)
9563#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
9564 CL_API_PREFIX__VERSION_1_1_DEPRECATED
9565 cl_int
enqueueBarrier() const CL_API_SUFFIX__VERSION_1_1_DEPRECATED
9567 return detail::errHandler(
9568 ::clEnqueueBarrier(object_),
9569 __ENQUEUE_BARRIER_ERR);
9573 cl_int flush()
const
9575 return detail::errHandler(::clFlush(object_), __FLUSH_ERR);
9578 cl_int finish()
const
9580 return detail::errHandler(::clFinish(object_), __FINISH_ERR);
9583#ifdef cl_khr_external_memory
9584 cl_int enqueueAcquireExternalMemObjects(
9585 const vector<Memory>& mem_objects,
9586 const vector<Event>* events_wait =
nullptr,
9587 Event *event =
nullptr)
9589 cl_int err = CL_INVALID_OPERATION;
9592 std::call_once(ext_memory_initialized_, initMemoryExtension, this->getInfo<CL_QUEUE_DEVICE>());
9594 if (pfn_clEnqueueAcquireExternalMemObjectsKHR)
9596 err = pfn_clEnqueueAcquireExternalMemObjectsKHR(
9598 static_cast<cl_uint
>(mem_objects.size()),
9599 (mem_objects.size() > 0) ?
reinterpret_cast<const cl_mem *
>(mem_objects.data()) :
nullptr,
9600 (events_wait !=
nullptr) ?
static_cast<cl_uint
>(events_wait->size()) : 0,
9601 (events_wait !=
nullptr && events_wait->size() > 0) ?
reinterpret_cast<const cl_event*
>(events_wait->data()) :
nullptr,
9605 detail::errHandler(err, __ENQUEUE_ACQUIRE_EXTERNAL_MEMORY_ERR);
9607 if (event !=
nullptr && err == CL_SUCCESS)
9613 cl_int enqueueReleaseExternalMemObjects(
9614 const vector<Memory>& mem_objects,
9615 const vector<Event>* events_wait =
nullptr,
9616 Event *event =
nullptr)
9618 cl_int err = CL_INVALID_OPERATION;
9621 std::call_once(ext_memory_initialized_, initMemoryExtension, this->getInfo<CL_QUEUE_DEVICE>());
9623 if (pfn_clEnqueueReleaseExternalMemObjectsKHR)
9625 err = pfn_clEnqueueReleaseExternalMemObjectsKHR(
9627 static_cast<cl_uint
>(mem_objects.size()),
9628 (mem_objects.size() > 0) ?
reinterpret_cast<const cl_mem *
>(mem_objects.data()) :
nullptr,
9629 (events_wait !=
nullptr) ?
static_cast<cl_uint
>(events_wait->size()) : 0,
9630 (events_wait !=
nullptr && events_wait->size() > 0) ?
reinterpret_cast<const cl_event*
>(events_wait->data()) :
nullptr,
9634 detail::errHandler(err, __ENQUEUE_RELEASE_EXTERNAL_MEMORY_ERR);
9636 if (event !=
nullptr && err == CL_SUCCESS)
9643#ifdef cl_khr_semaphore
9644 cl_int enqueueWaitSemaphores(
9645 const vector<Semaphore> &sema_objects,
9646 const vector<cl_semaphore_payload_khr> &sema_payloads = {},
9647 const vector<Event>* events_wait_list =
nullptr,
9648 Event *
event =
nullptr)
const;
9650 cl_int enqueueSignalSemaphores(
9651 const vector<Semaphore> &sema_objects,
9652 const vector<cl_semaphore_payload_khr>& sema_payloads = {},
9653 const vector<Event>* events_wait_list =
nullptr,
9654 Event*
event =
nullptr);
9658#ifdef cl_khr_external_memory
9659CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag CommandQueue::ext_memory_initialized_;
9662CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag CommandQueue::default_initialized_;
9663CL_HPP_DEFINE_STATIC_MEMBER_
CommandQueue CommandQueue::default_;
9664CL_HPP_DEFINE_STATIC_MEMBER_ cl_int CommandQueue::default_error_ = CL_SUCCESS;
9667#if CL_HPP_TARGET_OPENCL_VERSION >= 200
9668enum class DeviceQueueProperties : cl_command_queue_properties
9671 Profiling = CL_QUEUE_PROFILING_ENABLE,
9674inline DeviceQueueProperties operator|(DeviceQueueProperties lhs, DeviceQueueProperties rhs)
9676 return static_cast<DeviceQueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) |
static_cast<cl_command_queue_properties
>(rhs));
9700 cl_command_queue_properties mergedProperties =
9701 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
9703 cl_queue_properties queue_properties[] = {
9704 CL_QUEUE_PROPERTIES, mergedProperties, 0 };
9705 object_ = ::clCreateCommandQueueWithProperties(
9706 context(), device(), queue_properties, &error);
9708 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9709 if (err !=
nullptr) {
9720 DeviceQueueProperties properties = DeviceQueueProperties::None,
9721 cl_int* err =
nullptr)
9725 cl_command_queue_properties mergedProperties =
9726 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
9727 cl_queue_properties queue_properties[] = {
9728 CL_QUEUE_PROPERTIES, mergedProperties, 0 };
9729 object_ = ::clCreateCommandQueueWithProperties(
9730 context(), device(), queue_properties, &error);
9732 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9733 if (err !=
nullptr) {
9745 DeviceQueueProperties properties = DeviceQueueProperties::None,
9746 cl_int* err =
nullptr)
9750 cl_command_queue_properties mergedProperties =
9751 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
9752 cl_queue_properties queue_properties[] = {
9753 CL_QUEUE_PROPERTIES, mergedProperties,
9754 CL_QUEUE_SIZE, queueSize,
9756 object_ = ::clCreateCommandQueueWithProperties(
9757 context(), device(), queue_properties, &error);
9759 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9760 if (err !=
nullptr) {
9771 explicit DeviceCommandQueue(
const cl_command_queue& commandQueue,
bool retainObject =
false) :
9772 detail::Wrapper<cl_type>(commandQueue, retainObject) { }
9776 detail::Wrapper<cl_type>::operator=(rhs);
9780 template <
typename T>
9781 cl_int getInfo(cl_command_queue_info name, T* param)
const
9783 return detail::errHandler(
9785 &::clGetCommandQueueInfo, object_, name, param),
9786 __GET_COMMAND_QUEUE_INFO_ERR);
9789 template <cl_command_queue_info name>
typename
9790 detail::param_traits<detail::cl_command_queue_info, name>::param_type
9791 getInfo(cl_int* err =
nullptr)
const
9793 typename detail::param_traits<
9794 detail::cl_command_queue_info, name>::param_type param;
9795 cl_int result = getInfo(name, ¶m);
9796 if (err !=
nullptr) {
9809 cl_int *err =
nullptr)
9815 cl_command_queue_properties properties =
9816 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
9817 cl_queue_properties queue_properties[] = {
9818 CL_QUEUE_PROPERTIES, properties,
9821 ::clCreateCommandQueueWithProperties(
9822 context(), device(), queue_properties, &error));
9824 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9825 if (err !=
nullptr) {
9839 const Context &context,
const Device &device, cl_int *err =
nullptr)
9843 cl_command_queue_properties properties =
9844 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
9845 cl_queue_properties queue_properties[] = {
9846 CL_QUEUE_PROPERTIES, properties,
9849 ::clCreateCommandQueueWithProperties(
9850 context(), device(), queue_properties, &error));
9852 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9853 if (err !=
nullptr) {
9867 const Context &context,
const Device &device, cl_uint queueSize, cl_int *err =
nullptr)
9871 cl_command_queue_properties properties =
9872 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
9873 cl_queue_properties queue_properties[] = {
9874 CL_QUEUE_PROPERTIES, properties,
9875 CL_QUEUE_SIZE, queueSize,
9878 ::clCreateCommandQueueWithProperties(
9879 context(), device(), queue_properties, &error));
9881 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9882 if (err !=
nullptr) {
9891#if CL_HPP_TARGET_OPENCL_VERSION >= 210
9901 error = clSetDefaultDeviceCommandQueue(context.get(), device.get(), default_queue.get());
9903 detail::errHandler(error, __SET_DEFAULT_DEVICE_COMMAND_QUEUE_ERR);
9904 if (err !=
nullptr) {
9907 return default_queue;
9915 return queue.getInfo<CL_QUEUE_DEVICE_DEFAULT>(err);
9935template<
typename IteratorType >
9938 IteratorType startIterator,
9939 IteratorType endIterator,
9944 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9947 cl_mem_flags flags = 0;
9949 flags |= CL_MEM_READ_ONLY;
9952 flags |= CL_MEM_READ_WRITE;
9955 flags |= CL_MEM_USE_HOST_PTR;
9958 size_type size =
sizeof(DataType)*(endIterator - startIterator);
9961 object_ = ::clCreateBuffer(context(), flags, size,
const_cast<DataType*
>(&*startIterator), &error);
9963 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
9966 detail::errHandler(error, __CREATE_BUFFER_ERR);
9967 if (err !=
nullptr) {
9973 detail::errHandler(error, __CREATE_BUFFER_ERR);
9974 if (err !=
nullptr) {
9978 error =
cl::copy(queue, startIterator, endIterator, *
this);
9979 detail::errHandler(error, __CREATE_BUFFER_ERR);
9980 if (err !=
nullptr) {
9986template<
typename IteratorType >
9988 const CommandQueue &queue,
9989 IteratorType startIterator,
9990 IteratorType endIterator,
9995 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9998 cl_mem_flags flags = 0;
10000 flags |= CL_MEM_READ_ONLY;
10003 flags |= CL_MEM_READ_WRITE;
10006 flags |= CL_MEM_USE_HOST_PTR;
10009 size_type size =
sizeof(DataType)*(endIterator - startIterator);
10011 Context context = queue.getInfo<CL_QUEUE_CONTEXT>();
10014 object_ = ::clCreateBuffer(context(), flags, size,
const_cast<DataType*
>(&*startIterator), &error);
10017 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
10020 detail::errHandler(error, __CREATE_BUFFER_ERR);
10021 if (err !=
nullptr) {
10026 error =
cl::copy(queue, startIterator, endIterator, *
this);
10027 detail::errHandler(error, __CREATE_BUFFER_ERR);
10028 if (err !=
nullptr) {
10034inline cl_int enqueueReadBuffer(
10040 const vector<Event>* events =
nullptr,
10041 Event* event =
nullptr)
10044 CommandQueue queue = CommandQueue::getDefault(&error);
10046 if (error != CL_SUCCESS) {
10050 return queue.enqueueReadBuffer(buffer, blocking, offset, size, ptr, events, event);
10053inline cl_int enqueueWriteBuffer(
10059 const vector<Event>* events =
nullptr,
10060 Event* event =
nullptr)
10063 CommandQueue queue = CommandQueue::getDefault(&error);
10065 if (error != CL_SUCCESS) {
10069 return queue.enqueueWriteBuffer(buffer, blocking, offset, size, ptr, events, event);
10072inline void* enqueueMapBuffer(
10075 cl_map_flags flags,
10078 const vector<Event>* events =
nullptr,
10079 Event* event =
nullptr,
10080 cl_int* err =
nullptr)
10083 CommandQueue queue = CommandQueue::getDefault(&error);
10084 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
10085 if (err !=
nullptr) {
10089 void * result = ::clEnqueueMapBuffer(
10090 queue(), buffer(), blocking, flags, offset, size,
10091 (events !=
nullptr) ? (cl_uint) events->size() : 0,
10092 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
10096 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
10097 if (err !=
nullptr) {
10104#if CL_HPP_TARGET_OPENCL_VERSION >= 200
10110template<
typename T>
10114 cl_map_flags flags,
10116 const vector<Event>* events,
10120 CommandQueue queue = CommandQueue::getDefault(&error);
10121 if (error != CL_SUCCESS) {
10122 return detail::errHandler(error, __ENQUEUE_MAP_SVM_ERR);
10126 ptr, blocking, flags, size, events, event);
10134template<
typename T,
class D>
10136 cl::pointer<T, D> &ptr,
10138 cl_map_flags flags,
10140 const vector<Event>* events =
nullptr,
10141 Event* event =
nullptr)
10144 CommandQueue queue = CommandQueue::getDefault(&error);
10145 if (error != CL_SUCCESS) {
10146 return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
10150 ptr, blocking, flags, size, events, event);
10158template<
typename T,
class Alloc>
10160 cl::vector<T, Alloc> &container,
10162 cl_map_flags flags,
10163 const vector<Event>* events =
nullptr,
10164 Event* event =
nullptr)
10167 CommandQueue queue = CommandQueue::getDefault(&error);
10168 if (error != CL_SUCCESS) {
10169 return detail::errHandler(error, __ENQUEUE_MAP_SVM_ERR);
10173 container, blocking, flags, events, event);
10178inline cl_int enqueueUnmapMemObject(
10179 const Memory& memory,
10181 const vector<Event>* events =
nullptr,
10182 Event* event =
nullptr)
10185 CommandQueue queue = CommandQueue::getDefault(&error);
10186 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
10187 if (error != CL_SUCCESS) {
10192 cl_int err = detail::errHandler(
10193 ::clEnqueueUnmapMemObject(
10194 queue(), memory(), mapped_ptr,
10195 (events !=
nullptr) ? (cl_uint)events->size() : 0,
10196 (events !=
nullptr && events->size() > 0) ? (cl_event*)&events->front() :
nullptr,
10197 (event !=
nullptr) ? &tmp :
nullptr),
10198 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
10200 if (event !=
nullptr && err == CL_SUCCESS)
10206#if CL_HPP_TARGET_OPENCL_VERSION >= 200
10212template<
typename T>
10215 const vector<Event>* events =
nullptr,
10216 Event* event =
nullptr)
10219 CommandQueue queue = CommandQueue::getDefault(&error);
10220 if (error != CL_SUCCESS) {
10221 return detail::errHandler(error, __ENQUEUE_UNMAP_SVM_ERR);
10225 __ENQUEUE_UNMAP_SVM_ERR);
10234template<
typename T,
class D>
10236 cl::pointer<T, D> &ptr,
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);
10255template<
typename T,
class Alloc>
10257 cl::vector<T, Alloc> &container,
10258 const vector<Event>* events =
nullptr,
10259 Event* event =
nullptr)
10262 CommandQueue queue = CommandQueue::getDefault(&error);
10263 if (error != CL_SUCCESS) {
10264 return detail::errHandler(error, __ENQUEUE_UNMAP_SVM_ERR);
10267 return detail::errHandler(queue.
enqueueUnmapSVM(container, events, event),
10268 __ENQUEUE_UNMAP_SVM_ERR);
10273inline cl_int enqueueCopyBuffer(
10276 size_type src_offset,
10277 size_type dst_offset,
10279 const vector<Event>* events =
nullptr,
10280 Event* event =
nullptr)
10283 CommandQueue queue = CommandQueue::getDefault(&error);
10285 if (error != CL_SUCCESS) {
10289 return queue.enqueueCopyBuffer(src, dst, src_offset, dst_offset, size, events, event);
10297template<
typename IteratorType >
10298inline cl_int
copy( IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer )
10301 CommandQueue queue = CommandQueue::getDefault(&error);
10302 if (error != CL_SUCCESS)
10305 return cl::copy(queue, startIterator, endIterator, buffer);
10313template<
typename IteratorType >
10314inline cl_int
copy(
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator )
10317 CommandQueue queue = CommandQueue::getDefault(&error);
10318 if (error != CL_SUCCESS)
10321 return cl::copy(queue, buffer, startIterator, endIterator);
10329template<
typename IteratorType >
10332 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
10335 size_type length = endIterator-startIterator;
10336 size_type byteLength = length*
sizeof(DataType);
10338 DataType *pointer =
10339 static_cast<DataType*
>(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_WRITE, 0, byteLength, 0, 0, &error));
10341 if( error != CL_SUCCESS ) {
10344#if defined(_MSC_VER) && _MSC_VER < 1920
10348 stdext::checked_array_iterator<DataType*>(
10351 std::copy(startIterator, endIterator, pointer);
10354 error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
10356 if( error != CL_SUCCESS ) {
10368template<
typename IteratorType >
10369inline cl_int
copy(
const CommandQueue &queue,
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator )
10371 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
10374 size_type length = endIterator-startIterator;
10375 size_type byteLength = length*
sizeof(DataType);
10377 DataType *pointer =
10378 static_cast<DataType*
>(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_READ, 0, byteLength, 0, 0, &error));
10380 if( error != CL_SUCCESS ) {
10383 std::copy(pointer, pointer + length, startIterator);
10385 error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
10387 if( error != CL_SUCCESS ) {
10395#if CL_HPP_TARGET_OPENCL_VERSION >= 200
10399template<
typename T,
class Alloc>
10400inline cl_int
mapSVM(cl::vector<T, Alloc> &container)
10402 return enqueueMapSVM(container, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE);
10408template<
typename T,
class Alloc>
10409inline cl_int
unmapSVM(cl::vector<T, Alloc> &container)
10416#if CL_HPP_TARGET_OPENCL_VERSION >= 110
10417inline cl_int enqueueReadBufferRect(
10418 const Buffer& buffer,
10420 const array<size_type, 3>& buffer_offset,
10421 const array<size_type, 3>& host_offset,
10422 const array<size_type, 3>& region,
10423 size_type buffer_row_pitch,
10424 size_type buffer_slice_pitch,
10425 size_type host_row_pitch,
10426 size_type host_slice_pitch,
10428 const vector<Event>* events =
nullptr,
10429 Event* event =
nullptr)
10432 CommandQueue queue = CommandQueue::getDefault(&error);
10434 if (error != CL_SUCCESS) {
10438 return queue.enqueueReadBufferRect(
10445 buffer_slice_pitch,
10453inline cl_int enqueueReadBufferRect(
10456 const array<size_type, 2>& buffer_offset,
10457 const array<size_type, 2>& host_offset,
10458 const array<size_type, 2>& region,
10459 size_type buffer_row_pitch,
10460 size_type buffer_slice_pitch,
10461 size_type host_row_pitch,
10462 size_type host_slice_pitch,
10464 const vector<Event>* events =
nullptr,
10465 Event* event =
nullptr)
10467 return enqueueReadBufferRect(
10470 { buffer_offset[0], buffer_offset[1], 0 },
10471 { host_offset[0], host_offset[1], 0 },
10472 { region[0], region[1], 1 },
10474 buffer_slice_pitch,
10482inline cl_int enqueueWriteBufferRect(
10485 const array<size_type, 3>& buffer_offset,
10486 const array<size_type, 3>& host_offset,
10487 const array<size_type, 3>& region,
10488 size_type buffer_row_pitch,
10489 size_type buffer_slice_pitch,
10490 size_type host_row_pitch,
10491 size_type host_slice_pitch,
10493 const vector<Event>* events =
nullptr,
10494 Event* event =
nullptr)
10497 CommandQueue queue = CommandQueue::getDefault(&error);
10499 if (error != CL_SUCCESS) {
10503 return queue.enqueueWriteBufferRect(
10510 buffer_slice_pitch,
10518inline cl_int enqueueWriteBufferRect(
10521 const array<size_type, 2>& buffer_offset,
10522 const array<size_type, 2>& host_offset,
10523 const array<size_type, 2>& region,
10524 size_type buffer_row_pitch,
10525 size_type buffer_slice_pitch,
10526 size_type host_row_pitch,
10527 size_type host_slice_pitch,
10529 const vector<Event>* events =
nullptr,
10530 Event* event =
nullptr)
10532 return enqueueWriteBufferRect(
10535 { buffer_offset[0], buffer_offset[1], 0 },
10536 { host_offset[0], host_offset[1], 0 },
10537 { region[0], region[1], 1 },
10539 buffer_slice_pitch,
10547inline cl_int enqueueCopyBufferRect(
10550 const array<size_type, 3>& src_origin,
10551 const array<size_type, 3>& dst_origin,
10552 const array<size_type, 3>& region,
10553 size_type src_row_pitch,
10554 size_type src_slice_pitch,
10555 size_type dst_row_pitch,
10556 size_type dst_slice_pitch,
10557 const vector<Event>* events =
nullptr,
10558 Event* event =
nullptr)
10561 CommandQueue queue = CommandQueue::getDefault(&error);
10563 if (error != CL_SUCCESS) {
10567 return queue.enqueueCopyBufferRect(
10581inline cl_int enqueueCopyBufferRect(
10584 const array<size_type, 2>& src_origin,
10585 const array<size_type, 2>& dst_origin,
10586 const array<size_type, 2>& region,
10587 size_type src_row_pitch,
10588 size_type src_slice_pitch,
10589 size_type dst_row_pitch,
10590 size_type dst_slice_pitch,
10591 const vector<Event>* events =
nullptr,
10592 Event* event =
nullptr)
10594 return enqueueCopyBufferRect(
10597 { src_origin[0], src_origin[1], 0 },
10598 { dst_origin[0], dst_origin[1], 0 },
10599 { region[0], region[1], 1 },
10609inline cl_int enqueueReadImage(
10610 const Image& image,
10612 const array<size_type, 3>& origin,
10613 const array<size_type, 3>& region,
10614 size_type row_pitch,
10615 size_type slice_pitch,
10617 const vector<Event>* events =
nullptr,
10618 Event* event =
nullptr)
10621 CommandQueue queue = CommandQueue::getDefault(&error);
10623 if (error != CL_SUCCESS) {
10627 return queue.enqueueReadImage(
10639inline cl_int enqueueReadImage(
10640 const Image& image,
10642 const array<size_type, 2>& origin,
10643 const array<size_type, 2>& region,
10644 size_type row_pitch,
10645 size_type slice_pitch,
10647 const vector<Event>* events =
nullptr,
10648 Event* event =
nullptr)
10650 return enqueueReadImage(
10653 { origin[0], origin[1], 0 },
10654 { region[0], region[1], 1 },
10662inline cl_int enqueueWriteImage(
10663 const Image& image,
10665 const array<size_type, 3>& origin,
10666 const array<size_type, 3>& region,
10667 size_type row_pitch,
10668 size_type slice_pitch,
10670 const vector<Event>* events =
nullptr,
10671 Event* event =
nullptr)
10674 CommandQueue queue = CommandQueue::getDefault(&error);
10676 if (error != CL_SUCCESS) {
10680 return queue.enqueueWriteImage(
10692inline cl_int enqueueWriteImage(
10693 const Image& image,
10695 const array<size_type, 2>& origin,
10696 const array<size_type, 2>& region,
10697 size_type row_pitch,
10698 size_type slice_pitch,
10700 const vector<Event>* events =
nullptr,
10701 Event* event =
nullptr)
10703 return enqueueWriteImage(
10706 { origin[0], origin[1], 0 },
10707 { region[0], region[1], 1 },
10715inline cl_int enqueueCopyImage(
10718 const array<size_type, 3>& src_origin,
10719 const array<size_type, 3>& dst_origin,
10720 const array<size_type, 3>& region,
10721 const vector<Event>* events =
nullptr,
10722 Event* event =
nullptr)
10725 CommandQueue queue = CommandQueue::getDefault(&error);
10727 if (error != CL_SUCCESS) {
10731 return queue.enqueueCopyImage(
10741inline cl_int enqueueCopyImage(
10744 const array<size_type, 2>& src_origin,
10745 const array<size_type, 2>& dst_origin,
10746 const array<size_type, 2>& region,
10747 const vector<Event>* events =
nullptr,
10748 Event* event =
nullptr)
10750 return enqueueCopyImage(
10753 { src_origin[0], src_origin[1], 0 },
10754 { dst_origin[0], dst_origin[1], 0 },
10755 { region[0], region[1], 1 },
10760inline cl_int enqueueCopyImageToBuffer(
10763 const array<size_type, 3>& src_origin,
10764 const array<size_type, 3>& region,
10765 size_type dst_offset,
10766 const vector<Event>* events =
nullptr,
10767 Event* event =
nullptr)
10770 CommandQueue queue = CommandQueue::getDefault(&error);
10772 if (error != CL_SUCCESS) {
10776 return queue.enqueueCopyImageToBuffer(
10786inline cl_int enqueueCopyImageToBuffer(
10789 const array<size_type, 2>& src_origin,
10790 const array<size_type, 2>& region,
10791 size_type dst_offset,
10792 const vector<Event>* events =
nullptr,
10793 Event* event =
nullptr)
10795 return enqueueCopyImageToBuffer(
10798 { src_origin[0], src_origin[1], 0 },
10799 { region[0], region[1], 1 },
10805inline cl_int enqueueCopyBufferToImage(
10808 size_type src_offset,
10809 const array<size_type, 3>& dst_origin,
10810 const array<size_type, 3>& region,
10811 const vector<Event>* events =
nullptr,
10812 Event* event =
nullptr)
10815 CommandQueue queue = CommandQueue::getDefault(&error);
10817 if (error != CL_SUCCESS) {
10821 return queue.enqueueCopyBufferToImage(
10831inline cl_int enqueueCopyBufferToImage(
10834 size_type src_offset,
10835 const array<size_type, 2>& dst_origin,
10836 const array<size_type, 2>& region,
10837 const vector<Event>* events =
nullptr,
10838 Event* event =
nullptr)
10841 CommandQueue queue = CommandQueue::getDefault(&error);
10843 if (error != CL_SUCCESS) {
10847 return enqueueCopyBufferToImage(
10851 { dst_origin[0], dst_origin[1], 0 },
10852 { region[0], region[1], 1 },
10857inline cl_int flush(
void)
10860 CommandQueue queue = CommandQueue::getDefault(&error);
10862 if (error != CL_SUCCESS) {
10866 return queue.flush();
10869inline cl_int finish(
void)
10872 CommandQueue queue = CommandQueue::getDefault(&error);
10874 if (error != CL_SUCCESS) {
10879 return queue.finish();
10889 vector<Event> events_;
10891 template<
typename... Ts>
10896 queue_(CommandQueue::getDefault()),
10897 offset_(NullRange),
10904 EnqueueArgs(NDRange global, NDRange local) :
10905 queue_(CommandQueue::getDefault()),
10906 offset_(NullRange),
10913 EnqueueArgs(NDRange offset, NDRange global, NDRange local) :
10914 queue_(CommandQueue::getDefault()),
10922 EnqueueArgs(Event e, NDRange global) :
10923 queue_(CommandQueue::getDefault()),
10924 offset_(NullRange),
10928 events_.push_back(e);
10931 EnqueueArgs(Event e, NDRange global, NDRange local) :
10932 queue_(CommandQueue::getDefault()),
10933 offset_(NullRange),
10937 events_.push_back(e);
10940 EnqueueArgs(Event e, NDRange offset, NDRange global, NDRange local) :
10941 queue_(CommandQueue::getDefault()),
10946 events_.push_back(e);
10949 EnqueueArgs(
const vector<Event> &events, NDRange global) :
10950 queue_(CommandQueue::getDefault()),
10951 offset_(NullRange),
10959 EnqueueArgs(
const vector<Event> &events, NDRange global, NDRange local) :
10960 queue_(CommandQueue::getDefault()),
10961 offset_(NullRange),
10969 EnqueueArgs(
const vector<Event> &events, NDRange offset, NDRange global, NDRange local) :
10970 queue_(CommandQueue::getDefault()),
10979 EnqueueArgs(CommandQueue &queue, NDRange global) :
10981 offset_(NullRange),
10988 EnqueueArgs(CommandQueue &queue, NDRange global, NDRange local) :
10990 offset_(NullRange),
10997 EnqueueArgs(CommandQueue &queue, NDRange offset, NDRange global, NDRange local) :
11006 EnqueueArgs(CommandQueue &queue, Event e, NDRange global) :
11008 offset_(NullRange),
11012 events_.push_back(e);
11015 EnqueueArgs(CommandQueue &queue, Event e, NDRange global, NDRange local) :
11017 offset_(NullRange),
11021 events_.push_back(e);
11024 EnqueueArgs(CommandQueue &queue, Event e, NDRange offset, NDRange global, NDRange local) :
11030 events_.push_back(e);
11033 EnqueueArgs(CommandQueue &queue,
const vector<Event> &events, NDRange global) :
11035 offset_(NullRange),
11043 EnqueueArgs(CommandQueue &queue,
const vector<Event> &events, NDRange global, NDRange local) :
11045 offset_(NullRange),
11053 EnqueueArgs(CommandQueue &queue,
const vector<Event> &events, NDRange offset, NDRange global, NDRange local) :
11072template<
typename... Ts>
11078 template<
int index,
typename T0,
typename... T1s>
11079 void setArgs(T0&& t0, T1s&&... t1s)
11081 kernel_.
setArg(index, t0);
11082 setArgs<index + 1, T1s...>(std::forward<T1s>(t1s)...);
11085 template<
int index,
typename T0>
11086 void setArgs(T0&& t0)
11088 kernel_.setArg(index, t0);
11091 template<
int index>
11098 KernelFunctor(
Kernel kernel) : kernel_(kernel)
11104 cl_int * err =
nullptr) :
11105 kernel_(program, name.c_str(), err)
11121 setArgs<0>(std::forward<Ts>(ts)...);
11123 args.queue_.enqueueNDRangeKernel(
11146 setArgs<0>(std::forward<Ts>(ts)...);
11148 error = args.queue_.enqueueNDRangeKernel(
11159#if CL_HPP_TARGET_OPENCL_VERSION >= 200
11160 cl_int setSVMPointers(
const vector<void*> &pointerList)
11165 template<
typename T0,
typename... T1s>
11166 cl_int setSVMPointers(
const T0 &t0, T1s &... ts)
11178namespace compatibility {
11183 template<
typename... Ts>
11188 FunctorType functor_;
11193 cl_int * err =
nullptr) :
11194 functor_(FunctorType(program, name, err))
11199 functor_(FunctorType(kernel))
11215 enqueueArgs, args...);
11220#ifdef cl_khr_semaphore
11222#ifdef cl_khr_external_semaphore
11223enum ExternalSemaphoreType : cl_external_semaphore_handle_type_khr
11226#ifdef cl_khr_external_semaphore_opaque_fd
11227 OpaqueFd = CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR,
11229#ifdef cl_khr_external_semaphore_sync_fd
11230 SyncFd = CL_SEMAPHORE_HANDLE_SYNC_FD_KHR,
11232#ifdef cl_khr_external_semaphore_win32
11233 OpaqueWin32 = CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KHR,
11234 OpaqueWin32Kmt = CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KMT_KHR,
11242 Semaphore() : detail::Wrapper<cl_type>() {}
11244 const Context &context,
11245 const vector<cl_semaphore_properties_khr>& sema_props,
11246 cl_int *err =
nullptr)
11249 std::call_once(ext_init_, initExtensions, context);
11251 cl_int error = CL_INVALID_OPERATION;
11253 if (pfn_clCreateSemaphoreWithPropertiesKHR)
11255 object_ = pfn_clCreateSemaphoreWithPropertiesKHR(
11261 detail::errHandler(error, __CREATE_SEMAPHORE_KHR_WITH_PROPERTIES_ERR);
11263 if (err !=
nullptr) {
11268 const vector<cl_semaphore_properties_khr>& sema_props,
11269 cl_int* err =
nullptr):Semaphore(Context::getDefault(err), sema_props, err) {}
11271 explicit Semaphore(
const cl_semaphore_khr& semaphore,
bool retainObject =
false) :
11272 detail::Wrapper<cl_type>(semaphore, retainObject) {}
11273 Semaphore& operator = (
const cl_semaphore_khr& rhs) {
11274 detail::Wrapper<cl_type>::operator=(rhs);
11277 template <
typename T>
11278 cl_int getInfo(cl_semaphore_info_khr name, T* param)
const
11280 if (pfn_clGetSemaphoreInfoKHR ==
nullptr) {
11281 return detail::errHandler(CL_INVALID_OPERATION,
11282 __GET_SEMAPHORE_KHR_INFO_ERR);
11285 return detail::errHandler(
11286 detail::getInfo(pfn_clGetSemaphoreInfoKHR, object_, name, param),
11287 __GET_SEMAPHORE_KHR_INFO_ERR);
11289 template <cl_semaphore_info_khr name>
typename
11290 detail::param_traits<detail::cl_semaphore_info_khr, name>::param_type
11291 getInfo(cl_int* err =
nullptr)
const
11293 typename detail::param_traits<
11294 detail::cl_semaphore_info_khr, name>::param_type param;
11295 cl_int result = getInfo(name, ¶m);
11296 if (err !=
nullptr) {
11302#ifdef cl_khr_external_semaphore
11303 template <
typename T>
11304 cl_int getHandleForTypeKHR(
11305 const Device& device, cl_external_semaphore_handle_type_khr name, T* param)
const
11307 if (pfn_clGetSemaphoreHandleForTypeKHR ==
nullptr) {
11308 return detail::errHandler(CL_INVALID_OPERATION,
11309 __GET_SEMAPHORE_HANDLE_FOR_TYPE_KHR_ERR);
11312 return detail::errHandler(
11314 pfn_clGetSemaphoreHandleForTypeKHR, object_, device(), name, param),
11315 __GET_SEMAPHORE_HANDLE_FOR_TYPE_KHR_ERR);
11318 template <cl_external_semaphore_handle_type_khr type>
typename
11319 detail::param_traits<detail::cl_external_semaphore_handle_type_khr, type>::param_type
11320 getHandleForTypeKHR(
const Device& device, cl_int* err =
nullptr)
const
11322 typename detail::param_traits<
11323 detail::cl_external_semaphore_handle_type_khr, type>::param_type param;
11324 cl_int result = getHandleForTypeKHR(device, type, ¶m);
11325 if (err !=
nullptr) {
11334 if (pfn_clRetainSemaphoreKHR ==
nullptr) {
11335 return detail::errHandler(CL_INVALID_OPERATION,
11336 __RETAIN_SEMAPHORE_KHR_ERR);
11338 return pfn_clRetainSemaphoreKHR(object_);
11343 if (pfn_clReleaseSemaphoreKHR ==
nullptr) {
11344 return detail::errHandler(CL_INVALID_OPERATION,
11345 __RELEASE_SEMAPHORE_KHR_ERR);
11347 return pfn_clReleaseSemaphoreKHR(object_);
11351 static std::once_flag ext_init_;
11353 static void initExtensions(
const Context& context)
11355#if CL_HPP_TARGET_OPENCL_VERSION >= 120
11356 Device device = context.getInfo<CL_CONTEXT_DEVICES>().at(0);
11357 cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>()();
11358 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCreateSemaphoreWithPropertiesKHR);
11359 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clReleaseSemaphoreKHR);
11360 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clRetainSemaphoreKHR);
11361 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueWaitSemaphoresKHR);
11362 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueSignalSemaphoresKHR);
11363 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clGetSemaphoreInfoKHR);
11364#ifdef cl_khr_external_semaphore
11365 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clGetSemaphoreHandleForTypeKHR);
11369 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateSemaphoreWithPropertiesKHR);
11370 CL_HPP_INIT_CL_EXT_FCN_PTR_(clReleaseSemaphoreKHR);
11371 CL_HPP_INIT_CL_EXT_FCN_PTR_(clRetainSemaphoreKHR);
11372 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueWaitSemaphoresKHR);
11373 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueSignalSemaphoresKHR);
11374 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetSemaphoreInfoKHR);
11375#ifdef cl_khr_external_semaphore
11376 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetSemaphoreHandleForTypeKHR);
11380 if ((pfn_clCreateSemaphoreWithPropertiesKHR ==
nullptr) &&
11381 (pfn_clReleaseSemaphoreKHR ==
nullptr) &&
11382 (pfn_clRetainSemaphoreKHR ==
nullptr) &&
11383 (pfn_clEnqueueWaitSemaphoresKHR ==
nullptr) &&
11384 (pfn_clEnqueueSignalSemaphoresKHR ==
nullptr) &&
11385#ifdef cl_khr_external_semaphore
11386 (pfn_clGetSemaphoreHandleForTypeKHR ==
nullptr) &&
11388 (pfn_clGetSemaphoreInfoKHR ==
nullptr))
11390 detail::errHandler(CL_INVALID_VALUE, __CREATE_SEMAPHORE_KHR_WITH_PROPERTIES_ERR);
11396CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Semaphore::ext_init_;
11398inline cl_int CommandQueue::enqueueWaitSemaphores(
11399 const vector<Semaphore> &sema_objects,
11400 const vector<cl_semaphore_payload_khr> &sema_payloads,
11401 const vector<Event>* events_wait_list,
11402 Event *event)
const
11405 cl_int err = CL_INVALID_OPERATION;
11407 if (pfn_clEnqueueWaitSemaphoresKHR !=
nullptr) {
11408 err = pfn_clEnqueueWaitSemaphoresKHR(
11410 (cl_uint)sema_objects.size(),
11411 (
const cl_semaphore_khr *) &sema_objects.front(),
11412 (sema_payloads.size() > 0) ? &sema_payloads.front() :
nullptr,
11413 (events_wait_list !=
nullptr) ? (cl_uint) events_wait_list->size() : 0,
11414 (events_wait_list !=
nullptr && events_wait_list->size() > 0) ? (cl_event*) &events_wait_list->front() :
nullptr,
11415 (event !=
nullptr) ? &tmp :
nullptr);
11418 detail::errHandler(err, __ENQUEUE_WAIT_SEMAPHORE_KHR_ERR);
11420 if (event !=
nullptr && err == CL_SUCCESS)
11426inline cl_int CommandQueue::enqueueSignalSemaphores(
11427 const vector<Semaphore> &sema_objects,
11428 const vector<cl_semaphore_payload_khr>& sema_payloads,
11429 const vector<Event>* events_wait_list,
11433 cl_int err = CL_INVALID_OPERATION;
11435 if (pfn_clEnqueueSignalSemaphoresKHR !=
nullptr) {
11436 err = pfn_clEnqueueSignalSemaphoresKHR(
11438 (cl_uint)sema_objects.size(),
11439 (
const cl_semaphore_khr*) &sema_objects.front(),
11440 (sema_payloads.size() > 0) ? &sema_payloads.front() :
nullptr,
11441 (events_wait_list !=
nullptr) ? (cl_uint) events_wait_list->size() : 0,
11442 (events_wait_list !=
nullptr && events_wait_list->size() > 0) ? (cl_event*) &events_wait_list->front() :
nullptr,
11443 (event !=
nullptr) ? &tmp :
nullptr);
11446 detail::errHandler(err, __ENQUEUE_SIGNAL_SEMAPHORE_KHR_ERR);
11448 if (event !=
nullptr && err == CL_SUCCESS)
11456#if defined(cl_khr_command_buffer)
11460class CommandBufferKhr :
public detail::Wrapper<cl_command_buffer_khr>
11464 CommandBufferKhr() : detail::Wrapper<cl_type>() { }
11466 explicit CommandBufferKhr(
const vector<CommandQueue> &queues,
11467 cl_command_buffer_properties_khr properties = 0,
11468 cl_int* errcode_ret =
nullptr)
11470 cl_command_buffer_properties_khr command_buffer_properties[] = {
11471 CL_COMMAND_BUFFER_FLAGS_KHR, properties, 0
11475 std::call_once(ext_init_, [&] { initExtensions(queues[0].getInfo<CL_QUEUE_DEVICE>()); });
11476 cl_int error = CL_INVALID_OPERATION;
11478 static_assert(
sizeof(cl::CommandQueue) ==
sizeof(cl_command_queue),
11479 "Size of cl::CommandQueue must be equal to size of cl_command_queue");
11481 if (pfn_clCreateCommandBufferKHR)
11483 object_ = pfn_clCreateCommandBufferKHR((cl_uint) queues.size(),
11484 (cl_command_queue *) &queues.front(),
11485 command_buffer_properties,
11489 detail::errHandler(error, __CREATE_COMMAND_BUFFER_KHR_ERR);
11490 if (errcode_ret !=
nullptr) {
11491 *errcode_ret = error;
11495 explicit CommandBufferKhr(
const cl_command_buffer_khr& commandBufferKhr,
bool retainObject =
false) :
11496 detail::Wrapper<cl_type>(commandBufferKhr, retainObject) { }
11498 CommandBufferKhr& operator=(
const cl_command_buffer_khr& rhs)
11500 detail::Wrapper<cl_type>::operator=(rhs);
11504 template <
typename T>
11505 cl_int getInfo(cl_command_buffer_info_khr name, T* param)
const
11507 if (pfn_clGetCommandBufferInfoKHR ==
nullptr) {
11508 return detail::errHandler(CL_INVALID_OPERATION,
11509 __GET_COMMAND_BUFFER_INFO_KHR_ERR);
11511 return detail::errHandler(
11512 detail::getInfo(pfn_clGetCommandBufferInfoKHR, object_, name, param),
11513 __GET_COMMAND_BUFFER_INFO_KHR_ERR);
11516 template <cl_command_buffer_info_khr name>
typename
11517 detail::param_traits<detail::cl_command_buffer_info_khr, name>::param_type
11518 getInfo(cl_int* err =
nullptr)
const
11520 typename detail::param_traits<
11521 detail::cl_command_buffer_info_khr, name>::param_type param;
11522 cl_int result = getInfo(name, ¶m);
11523 if (err !=
nullptr) {
11529 cl_int finalizeCommandBuffer()
const
11531 return detail::errHandler(::clFinalizeCommandBufferKHR(object_), __FINALIZE_COMMAND_BUFFER_KHR_ERR);
11534 cl_int enqueueCommandBuffer(vector<CommandQueue> &queues,
11535 const vector<Event>* events =
nullptr,
11536 Event* event =
nullptr)
11538 if (pfn_clEnqueueCommandBufferKHR ==
nullptr) {
11539 return detail::errHandler(CL_INVALID_OPERATION,
11540 __ENQUEUE_COMMAND_BUFFER_KHR_ERR);
11543 static_assert(
sizeof(cl::CommandQueue) ==
sizeof(cl_command_queue),
11544 "Size of cl::CommandQueue must be equal to size of cl_command_queue");
11546 return detail::errHandler(pfn_clEnqueueCommandBufferKHR((cl_uint) queues.size(),
11547 (cl_command_queue *) &queues.front(),
11549 (events !=
nullptr) ? (cl_uint) events->size() : 0,
11550 (events !=
nullptr && events->size() > 0) ? (cl_event*) &events->front() :
nullptr,
11551 (cl_event*) event),
11552 __ENQUEUE_COMMAND_BUFFER_KHR_ERR);
11555 cl_int commandBarrierWithWaitList(
const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11556 cl_sync_point_khr* sync_point =
nullptr,
11557 MutableCommandKhr* mutable_handle =
nullptr,
11558 const CommandQueue* command_queue =
nullptr)
11560 if (pfn_clCommandBarrierWithWaitListKHR ==
nullptr) {
11561 return detail::errHandler(CL_INVALID_OPERATION,
11562 __COMMAND_BARRIER_WITH_WAIT_LIST_KHR_ERR);
11565 cl_sync_point_khr tmp_sync_point;
11566 cl_int error = detail::errHandler(
11567 pfn_clCommandBarrierWithWaitListKHR(object_,
11568 (command_queue !=
nullptr) ? (*command_queue)() :
nullptr,
11569#
if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
11572 (sync_points_vec !=
nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11573 (sync_points_vec !=
nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() :
nullptr,
11574 (sync_point !=
nullptr) ? &tmp_sync_point :
nullptr,
11575 (cl_mutable_command_khr*) mutable_handle),
11576 __COMMAND_BARRIER_WITH_WAIT_LIST_KHR_ERR);
11578 if (sync_point !=
nullptr && error == CL_SUCCESS)
11579 *sync_point = tmp_sync_point;
11584 cl_int commandCopyBuffer(
const Buffer& src,
11586 size_type src_offset,
11587 size_type dst_offset,
11589 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11590 cl_sync_point_khr* sync_point =
nullptr,
11591 MutableCommandKhr* mutable_handle =
nullptr,
11592 const CommandQueue* command_queue =
nullptr)
11594 if (pfn_clCommandCopyBufferKHR ==
nullptr) {
11595 return detail::errHandler(CL_INVALID_OPERATION,
11596 __COMMAND_COPY_BUFFER_KHR_ERR);
11599 cl_sync_point_khr tmp_sync_point;
11600 cl_int error = detail::errHandler(
11601 pfn_clCommandCopyBufferKHR(object_,
11602 (command_queue !=
nullptr) ? (*command_queue)() :
nullptr,
11603#
if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
11611 (sync_points_vec !=
nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11612 (sync_points_vec !=
nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() :
nullptr,
11613 (sync_point !=
nullptr) ? &tmp_sync_point :
nullptr,
11614 (cl_mutable_command_khr*) mutable_handle),
11615 __COMMAND_COPY_BUFFER_KHR_ERR);
11617 if (sync_point !=
nullptr && error == CL_SUCCESS)
11618 *sync_point = tmp_sync_point;
11623 cl_int commandCopyBufferRect(
const Buffer& src,
11625 const array<size_type, 3>& src_origin,
11626 const array<size_type, 3>& dst_origin,
11627 const array<size_type, 3>& region,
11628 size_type src_row_pitch,
11629 size_type src_slice_pitch,
11630 size_type dst_row_pitch,
11631 size_type dst_slice_pitch,
11632 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11633 cl_sync_point_khr* sync_point =
nullptr,
11634 MutableCommandKhr* mutable_handle =
nullptr,
11635 const CommandQueue* command_queue =
nullptr)
11637 if (pfn_clCommandCopyBufferRectKHR ==
nullptr) {
11638 return detail::errHandler(CL_INVALID_OPERATION,
11639 __COMMAND_COPY_BUFFER_RECT_KHR_ERR);
11642 cl_sync_point_khr tmp_sync_point;
11643 cl_int error = detail::errHandler(
11644 pfn_clCommandCopyBufferRectKHR(object_,
11645 (command_queue !=
nullptr) ? (*command_queue)() :
nullptr,
11646#
if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
11658 (sync_points_vec !=
nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11659 (sync_points_vec !=
nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() :
nullptr,
11660 (sync_point !=
nullptr) ? &tmp_sync_point :
nullptr,
11661 (cl_mutable_command_khr*) mutable_handle),
11662 __COMMAND_COPY_BUFFER_RECT_KHR_ERR);
11664 if (sync_point !=
nullptr && error == CL_SUCCESS)
11665 *sync_point = tmp_sync_point;
11670 cl_int commandCopyBufferToImage(
const Buffer& src,
11672 size_type src_offset,
11673 const array<size_type, 3>& dst_origin,
11674 const array<size_type, 3>& region,
11675 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11676 cl_sync_point_khr* sync_point =
nullptr,
11677 MutableCommandKhr* mutable_handle =
nullptr,
11678 const CommandQueue* command_queue =
nullptr)
11680 if (pfn_clCommandCopyBufferToImageKHR ==
nullptr) {
11681 return detail::errHandler(CL_INVALID_OPERATION,
11682 __COMMAND_COPY_BUFFER_TO_IMAGE_KHR_ERR);
11685 cl_sync_point_khr tmp_sync_point;
11686 cl_int error = detail::errHandler(
11687 pfn_clCommandCopyBufferToImageKHR(object_,
11688 (command_queue !=
nullptr) ? (*command_queue)() :
nullptr,
11689#
if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
11697 (sync_points_vec !=
nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11698 (sync_points_vec !=
nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() :
nullptr,
11699 (sync_point !=
nullptr) ? &tmp_sync_point :
nullptr,
11700 (cl_mutable_command_khr*) mutable_handle),
11701 __COMMAND_COPY_BUFFER_TO_IMAGE_KHR_ERR);
11703 if (sync_point !=
nullptr && error == CL_SUCCESS)
11704 *sync_point = tmp_sync_point;
11709 cl_int commandCopyImage(
const Image& src,
11711 const array<size_type, 3>& src_origin,
11712 const array<size_type, 3>& dst_origin,
11713 const array<size_type, 3>& region,
11714 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11715 cl_sync_point_khr* sync_point =
nullptr,
11716 MutableCommandKhr* mutable_handle =
nullptr,
11717 const CommandQueue* command_queue =
nullptr)
11719 if (pfn_clCommandCopyImageKHR ==
nullptr) {
11720 return detail::errHandler(CL_INVALID_OPERATION,
11721 __COMMAND_COPY_IMAGE_KHR_ERR);
11724 cl_sync_point_khr tmp_sync_point;
11725 cl_int error = detail::errHandler(
11726 pfn_clCommandCopyImageKHR(object_,
11727 (command_queue !=
nullptr) ? (*command_queue)() :
nullptr,
11728#
if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
11736 (sync_points_vec !=
nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11737 (sync_points_vec !=
nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() :
nullptr,
11738 (sync_point !=
nullptr) ? &tmp_sync_point :
nullptr,
11739 (cl_mutable_command_khr*) mutable_handle),
11740 __COMMAND_COPY_IMAGE_KHR_ERR);
11742 if (sync_point !=
nullptr && error == CL_SUCCESS)
11743 *sync_point = tmp_sync_point;
11748 cl_int commandCopyImageToBuffer(
const Image& src,
11750 const array<size_type, 3>& src_origin,
11751 const array<size_type, 3>& region,
11752 size_type dst_offset,
11753 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11754 cl_sync_point_khr* sync_point =
nullptr,
11755 MutableCommandKhr* mutable_handle =
nullptr,
11756 const CommandQueue* command_queue =
nullptr)
11758 if (pfn_clCommandCopyImageToBufferKHR ==
nullptr) {
11759 return detail::errHandler(CL_INVALID_OPERATION,
11760 __COMMAND_COPY_IMAGE_TO_BUFFER_KHR_ERR);
11763 cl_sync_point_khr tmp_sync_point;
11764 cl_int error = detail::errHandler(
11765 pfn_clCommandCopyImageToBufferKHR(object_,
11766 (command_queue !=
nullptr) ? (*command_queue)() :
nullptr,
11767#
if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
11775 (sync_points_vec !=
nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11776 (sync_points_vec !=
nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() :
nullptr,
11777 (sync_point !=
nullptr) ? &tmp_sync_point :
nullptr,
11778 (cl_mutable_command_khr*) mutable_handle),
11779 __COMMAND_COPY_IMAGE_TO_BUFFER_KHR_ERR);
11781 if (sync_point !=
nullptr && error == CL_SUCCESS)
11782 *sync_point = tmp_sync_point;
11787 template<
typename PatternType>
11788 cl_int commandFillBuffer(
const Buffer& buffer,
11789 PatternType pattern,
11792 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11793 cl_sync_point_khr* sync_point =
nullptr,
11794 MutableCommandKhr* mutable_handle =
nullptr,
11795 const CommandQueue* command_queue =
nullptr)
11797 if (pfn_clCommandFillBufferKHR ==
nullptr) {
11798 return detail::errHandler(CL_INVALID_OPERATION,
11799 __COMMAND_FILL_BUFFER_KHR_ERR);
11802 cl_sync_point_khr tmp_sync_point;
11803 cl_int error = detail::errHandler(
11804 pfn_clCommandFillBufferKHR(object_,
11805 (command_queue !=
nullptr) ? (*command_queue)() :
nullptr,
11806#
if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
11810 static_cast<void*
>(&pattern),
11811 sizeof(PatternType),
11814 (sync_points_vec !=
nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11815 (sync_points_vec !=
nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() :
nullptr,
11816 (sync_point !=
nullptr) ? &tmp_sync_point :
nullptr,
11817 (cl_mutable_command_khr*) mutable_handle),
11818 __COMMAND_FILL_BUFFER_KHR_ERR);
11820 if (sync_point !=
nullptr && error == CL_SUCCESS)
11821 *sync_point = tmp_sync_point;
11826 cl_int commandFillImage(
const Image& image,
11827 cl_float4 fillColor,
11828 const array<size_type, 3>& origin,
11829 const array<size_type, 3>& region,
11830 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11831 cl_sync_point_khr* sync_point =
nullptr,
11832 MutableCommandKhr* mutable_handle =
nullptr,
11833 const CommandQueue* command_queue =
nullptr)
11835 if (pfn_clCommandFillImageKHR ==
nullptr) {
11836 return detail::errHandler(CL_INVALID_OPERATION,
11837 __COMMAND_FILL_IMAGE_KHR_ERR);
11840 cl_sync_point_khr tmp_sync_point;
11841 cl_int error = detail::errHandler(
11842 pfn_clCommandFillImageKHR(object_,
11843 (command_queue !=
nullptr) ? (*command_queue)() :
nullptr,
11844#
if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
11848 static_cast<void*
>(&fillColor),
11851 (sync_points_vec !=
nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11852 (sync_points_vec !=
nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() :
nullptr,
11853 (sync_point !=
nullptr) ? &tmp_sync_point :
nullptr,
11854 (cl_mutable_command_khr*) mutable_handle),
11855 __COMMAND_FILL_IMAGE_KHR_ERR);
11857 if (sync_point !=
nullptr && error == CL_SUCCESS)
11858 *sync_point = tmp_sync_point;
11863 cl_int commandNDRangeKernel(
11864#
if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
11865 const cl::vector<cl_command_properties_khr> &properties,
11867 const cl::vector<cl_ndrange_kernel_command_properties_khr> &properties,
11869 const Kernel& kernel,
11870 const NDRange& offset,
11871 const NDRange& global,
11872 const NDRange& local = NullRange,
11873 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11874 cl_sync_point_khr* sync_point =
nullptr,
11875 MutableCommandKhr* mutable_handle =
nullptr,
11876 const CommandQueue* command_queue =
nullptr)
11878 if (pfn_clCommandNDRangeKernelKHR ==
nullptr) {
11879 return detail::errHandler(CL_INVALID_OPERATION,
11880 __COMMAND_NDRANGE_KERNEL_KHR_ERR);
11883 cl_sync_point_khr tmp_sync_point;
11884 cl_int error = detail::errHandler(
11885 pfn_clCommandNDRangeKernelKHR(object_,
11886 (command_queue !=
nullptr) ? (*command_queue)() :
nullptr,
11889 (cl_uint) global.dimensions(),
11890 offset.dimensions() != 0 ? (
const size_type*) offset :
nullptr,
11891 (
const size_type*) global,
11892 local.dimensions() != 0 ? (
const size_type*) local :
nullptr,
11893 (sync_points_vec !=
nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11894 (sync_points_vec !=
nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() :
nullptr,
11895 (sync_point !=
nullptr) ? &tmp_sync_point :
nullptr,
11896 (cl_mutable_command_khr*) mutable_handle),
11897 __COMMAND_NDRANGE_KERNEL_KHR_ERR);
11899 if (sync_point !=
nullptr && error == CL_SUCCESS)
11900 *sync_point = tmp_sync_point;
11905#if defined(cl_khr_command_buffer_mutable_dispatch)
11906#if CL_KHR_COMMAND_BUFFER_MUTABLE_DISPATCH_EXTENSION_VERSION < \
11907 CL_MAKE_VERSION(0, 9, 2)
11908 cl_int updateMutableCommands(
const cl_mutable_base_config_khr* mutable_config)
11910 if (pfn_clUpdateMutableCommandsKHR ==
nullptr) {
11911 return detail::errHandler(CL_INVALID_OPERATION,
11912 __UPDATE_MUTABLE_COMMANDS_KHR_ERR);
11914 return detail::errHandler(pfn_clUpdateMutableCommandsKHR(object_, mutable_config),
11915 __UPDATE_MUTABLE_COMMANDS_KHR_ERR);
11918 template <
int ArrayLength>
11919 cl_int updateMutableCommands(std::array<cl_command_buffer_update_type_khr,
11920 ArrayLength> &config_types,
11921 std::array<const void *, ArrayLength> &configs) {
11922 if (pfn_clUpdateMutableCommandsKHR ==
nullptr) {
11923 return detail::errHandler(CL_INVALID_OPERATION,
11924 __UPDATE_MUTABLE_COMMANDS_KHR_ERR);
11926 return detail::errHandler(
11927 pfn_clUpdateMutableCommandsKHR(object_,
static_cast<cl_uint
>(configs.size()),
11928 config_types.data(), configs.data()),
11929 __UPDATE_MUTABLE_COMMANDS_KHR_ERR);
11935 static std::once_flag ext_init_;
11937 static void initExtensions(
const cl::Device& device)
11939#if CL_HPP_TARGET_OPENCL_VERSION >= 120
11940 cl_platform_id platform = device.
getInfo<CL_DEVICE_PLATFORM>()();
11941 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCreateCommandBufferKHR);
11942 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clFinalizeCommandBufferKHR);
11943 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clRetainCommandBufferKHR);
11944 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clReleaseCommandBufferKHR);
11945 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clGetCommandBufferInfoKHR);
11946 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueCommandBufferKHR);
11947 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandBarrierWithWaitListKHR);
11948 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandCopyBufferKHR);
11949 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandCopyBufferRectKHR);
11950 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandCopyBufferToImageKHR);
11951 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandCopyImageKHR);
11952 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandCopyImageToBufferKHR);
11953 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandFillBufferKHR);
11954 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandFillImageKHR);
11955 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandNDRangeKernelKHR);
11956#if defined(cl_khr_command_buffer_mutable_dispatch)
11957 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clUpdateMutableCommandsKHR);
11958 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clGetMutableCommandInfoKHR);
11960#elif CL_HPP_TARGET_OPENCL_VERSION >= 110
11961 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateCommandBufferKHR);
11962 CL_HPP_INIT_CL_EXT_FCN_PTR_(clFinalizeCommandBufferKHR);
11963 CL_HPP_INIT_CL_EXT_FCN_PTR_(clRetainCommandBufferKHR);
11964 CL_HPP_INIT_CL_EXT_FCN_PTR_(clReleaseCommandBufferKHR);
11965 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetCommandBufferInfoKHR);
11966 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueCommandBufferKHR);
11967 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandBarrierWithWaitListKHR);
11968 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandCopyBufferKHR);
11969 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandCopyBufferRectKHR);
11970 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandCopyBufferToImageKHR);
11971 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandCopyImageKHR);
11972 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandCopyImageToBufferKHR);
11973 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandFillBufferKHR);
11974 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandFillImageKHR);
11975 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandNDRangeKernelKHR);
11976#if defined(cl_khr_command_buffer_mutable_dispatch)
11977 CL_HPP_INIT_CL_EXT_FCN_PTR_(clUpdateMutableCommandsKHR);
11978 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetMutableCommandInfoKHR);
11981 if ((pfn_clCreateCommandBufferKHR ==
nullptr) &&
11982 (pfn_clFinalizeCommandBufferKHR ==
nullptr) &&
11983 (pfn_clRetainCommandBufferKHR ==
nullptr) &&
11984 (pfn_clReleaseCommandBufferKHR ==
nullptr) &&
11985 (pfn_clGetCommandBufferInfoKHR ==
nullptr) &&
11986 (pfn_clEnqueueCommandBufferKHR ==
nullptr) &&
11987 (pfn_clCommandBarrierWithWaitListKHR ==
nullptr) &&
11988 (pfn_clCommandCopyBufferKHR ==
nullptr) &&
11989 (pfn_clCommandCopyBufferRectKHR ==
nullptr) &&
11990 (pfn_clCommandCopyBufferToImageKHR ==
nullptr) &&
11991 (pfn_clCommandCopyImageKHR ==
nullptr) &&
11992 (pfn_clCommandCopyImageToBufferKHR ==
nullptr) &&
11993 (pfn_clCommandFillBufferKHR ==
nullptr) &&
11994 (pfn_clCommandFillImageKHR ==
nullptr) &&
11995 (pfn_clCommandNDRangeKernelKHR ==
nullptr)
11996#
if defined(cl_khr_command_buffer_mutable_dispatch)
11997 && (pfn_clUpdateMutableCommandsKHR ==
nullptr)
11998 && (pfn_clGetMutableCommandInfoKHR ==
nullptr)
12002 detail::errHandler(CL_INVALID_VALUE, __CREATE_COMMAND_BUFFER_KHR_ERR);
12007CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag CommandBufferKhr::ext_init_;
12009#if defined(cl_khr_command_buffer_mutable_dispatch)
12013class MutableCommandKhr :
public detail::Wrapper<cl_mutable_command_khr>
12017 MutableCommandKhr() : detail::Wrapper<cl_type>() { }
12019 explicit MutableCommandKhr(
const cl_mutable_command_khr& mutableCommandKhr,
bool retainObject =
false) :
12020 detail::Wrapper<cl_type>(mutableCommandKhr, retainObject) { }
12022 MutableCommandKhr& operator=(
const cl_mutable_command_khr& rhs)
12024 detail::Wrapper<cl_type>::operator=(rhs);
12028 template <
typename T>
12029 cl_int getInfo(cl_mutable_command_info_khr name, T* param)
const
12031 if (pfn_clGetMutableCommandInfoKHR ==
nullptr) {
12032 return detail::errHandler(CL_INVALID_OPERATION,
12033 __GET_MUTABLE_COMMAND_INFO_KHR_ERR);
12035 return detail::errHandler(
12036 detail::getInfo(pfn_clGetMutableCommandInfoKHR, object_, name, param),
12037 __GET_MUTABLE_COMMAND_INFO_KHR_ERR);
12040 template <cl_mutable_command_info_khr name>
typename
12041 detail::param_traits<detail::cl_mutable_command_info_khr, name>::param_type
12042 getInfo(cl_int* err =
nullptr)
const
12044 typename detail::param_traits<
12045 detail::cl_mutable_command_info_khr, name>::param_type param;
12046 cl_int result = getInfo(name, ¶m);
12047 if (err !=
nullptr) {
12058#undef CL_HPP_ERR_STR_
12059#if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS)
12060#undef __GET_DEVICE_INFO_ERR
12061#undef __GET_PLATFORM_INFO_ERR
12062#undef __GET_DEVICE_IDS_ERR
12063#undef __GET_PLATFORM_IDS_ERR
12064#undef __GET_CONTEXT_INFO_ERR
12065#undef __GET_EVENT_INFO_ERR
12066#undef __GET_EVENT_PROFILE_INFO_ERR
12067#undef __GET_MEM_OBJECT_INFO_ERR
12068#undef __GET_IMAGE_INFO_ERR
12069#undef __GET_SAMPLER_INFO_ERR
12070#undef __GET_KERNEL_INFO_ERR
12071#undef __GET_KERNEL_ARG_INFO_ERR
12072#undef __GET_KERNEL_SUB_GROUP_INFO_ERR
12073#undef __GET_KERNEL_WORK_GROUP_INFO_ERR
12074#undef __GET_PROGRAM_INFO_ERR
12075#undef __GET_PROGRAM_BUILD_INFO_ERR
12076#undef __GET_COMMAND_QUEUE_INFO_ERR
12077#undef __CREATE_CONTEXT_ERR
12078#undef __CREATE_CONTEXT_FROM_TYPE_ERR
12079#undef __CREATE_COMMAND_BUFFER_KHR_ERR
12080#undef __GET_COMMAND_BUFFER_INFO_KHR_ERR
12081#undef __FINALIZE_COMMAND_BUFFER_KHR_ERR
12082#undef __ENQUEUE_COMMAND_BUFFER_KHR_ERR
12083#undef __COMMAND_BARRIER_WITH_WAIT_LIST_KHR_ERR
12084#undef __COMMAND_COPY_BUFFER_KHR_ERR
12085#undef __COMMAND_COPY_BUFFER_RECT_KHR_ERR
12086#undef __COMMAND_COPY_BUFFER_TO_IMAGE_KHR_ERR
12087#undef __COMMAND_COPY_IMAGE_KHR_ERR
12088#undef __COMMAND_COPY_IMAGE_TO_BUFFER_KHR_ERR
12089#undef __COMMAND_FILL_BUFFER_KHR_ERR
12090#undef __COMMAND_FILL_IMAGE_KHR_ERR
12091#undef __COMMAND_NDRANGE_KERNEL_KHR_ERR
12092#undef __UPDATE_MUTABLE_COMMANDS_KHR_ERR
12093#undef __GET_MUTABLE_COMMAND_INFO_KHR_ERR
12094#undef __RETAIN_COMMAND_BUFFER_KHR_ERR
12095#undef __RELEASE_COMMAND_BUFFER_KHR_ERR
12096#undef __GET_SUPPORTED_IMAGE_FORMATS_ERR
12097#undef __SET_CONTEXT_DESCTRUCTOR_CALLBACK_ERR
12098#undef __CREATE_BUFFER_ERR
12100#undef __CREATE_SUBBUFFER_ERR
12101#undef __CREATE_GL_BUFFER_ERR
12102#undef __CREATE_GL_RENDER_BUFFER_ERR
12103#undef __GET_GL_OBJECT_INFO_ERR
12104#undef __CREATE_IMAGE_ERR
12105#undef __CREATE_GL_TEXTURE_ERR
12106#undef __IMAGE_DIMENSION_ERR
12107#undef __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR
12108#undef __CREATE_USER_EVENT_ERR
12109#undef __SET_USER_EVENT_STATUS_ERR
12110#undef __SET_EVENT_CALLBACK_ERR
12111#undef __WAIT_FOR_EVENTS_ERR
12112#undef __CREATE_KERNEL_ERR
12113#undef __SET_KERNEL_ARGS_ERR
12114#undef __CREATE_PROGRAM_WITH_SOURCE_ERR
12115#undef __CREATE_PROGRAM_WITH_BINARY_ERR
12116#undef __CREATE_PROGRAM_WITH_IL_ERR
12117#undef __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR
12118#undef __BUILD_PROGRAM_ERR
12119#undef __COMPILE_PROGRAM_ERR
12120#undef __LINK_PROGRAM_ERR
12121#undef __CREATE_KERNELS_IN_PROGRAM_ERR
12122#undef __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR
12123#undef __CREATE_SAMPLER_WITH_PROPERTIES_ERR
12124#undef __SET_COMMAND_QUEUE_PROPERTY_ERR
12125#undef __ENQUEUE_READ_BUFFER_ERR
12126#undef __ENQUEUE_READ_BUFFER_RECT_ERR
12127#undef __ENQUEUE_WRITE_BUFFER_ERR
12128#undef __ENQUEUE_WRITE_BUFFER_RECT_ERR
12129#undef __ENQEUE_COPY_BUFFER_ERR
12130#undef __ENQEUE_COPY_BUFFER_RECT_ERR
12131#undef __ENQUEUE_FILL_BUFFER_ERR
12132#undef __ENQUEUE_READ_IMAGE_ERR
12133#undef __ENQUEUE_WRITE_IMAGE_ERR
12134#undef __ENQUEUE_COPY_IMAGE_ERR
12135#undef __ENQUEUE_FILL_IMAGE_ERR
12136#undef __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR
12137#undef __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR
12138#undef __ENQUEUE_MAP_BUFFER_ERR
12139#undef __ENQUEUE_MAP_IMAGE_ERR
12140#undef __ENQUEUE_MAP_SVM_ERR
12141#undef __ENQUEUE_FILL_SVM_ERR
12142#undef __ENQUEUE_COPY_SVM_ERR
12143#undef __ENQUEUE_UNMAP_SVM_ERR
12144#undef __ENQUEUE_MAP_IMAGE_ERR
12145#undef __ENQUEUE_UNMAP_MEM_OBJECT_ERR
12146#undef __ENQUEUE_NDRANGE_KERNEL_ERR
12147#undef __ENQUEUE_NATIVE_KERNEL
12148#undef __ENQUEUE_MIGRATE_MEM_OBJECTS_ERR
12149#undef __ENQUEUE_MIGRATE_SVM_ERR
12150#undef __ENQUEUE_ACQUIRE_GL_ERR
12151#undef __ENQUEUE_RELEASE_GL_ERR
12152#undef __CREATE_PIPE_ERR
12153#undef __GET_PIPE_INFO_ERR
12155#undef __RELEASE_ERR
12158#undef __VECTOR_CAPACITY_ERR
12159#undef __CREATE_SUB_DEVICES_ERR
12160#undef __ENQUEUE_ACQUIRE_EXTERNAL_MEMORY_ERR
12161#undef __ENQUEUE_RELEASE_EXTERNAL_MEMORY_ERR
12162#undef __ENQUEUE_MARKER_ERR
12163#undef __ENQUEUE_WAIT_FOR_EVENTS_ERR
12164#undef __ENQUEUE_BARRIER_ERR
12165#undef __UNLOAD_COMPILER_ERR
12166#undef __CREATE_GL_TEXTURE_2D_ERR
12167#undef __CREATE_GL_TEXTURE_3D_ERR
12168#undef __CREATE_IMAGE2D_ERR
12169#undef __CREATE_IMAGE3D_ERR
12170#undef __CREATE_COMMAND_QUEUE_ERR
12171#undef __ENQUEUE_TASK_ERR
12172#undef __CREATE_SAMPLER_ERR
12173#undef __ENQUEUE_MARKER_WAIT_LIST_ERR
12174#undef __ENQUEUE_BARRIER_WAIT_LIST_ERR
12175#undef __CLONE_KERNEL_ERR
12176#undef __GET_HOST_TIMER_ERR
12177#undef __GET_DEVICE_AND_HOST_TIMER_ERR
12178#undef __GET_SEMAPHORE_KHR_INFO_ERR
12179#undef __CREATE_SEMAPHORE_KHR_WITH_PROPERTIES_ERR
12180#undef __GET_IMAGE_REQUIREMENT_INFO_EXT_ERR
12181#undef __ENQUEUE_WAIT_SEMAPHORE_KHR_ERR
12182#undef __ENQUEUE_SIGNAL_SEMAPHORE_KHR_ERR
12183#undef __RETAIN_SEMAPHORE_KHR_ERR
12184#undef __RELEASE_SEMAPHORE_KHR_ERR
12185#undef __GET_SEMAPHORE_HANDLE_FOR_TYPE_KHR_ERR
12190#undef CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_
12191#undef CL_HPP_INIT_CL_EXT_FCN_PTR_
12192#undef CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_
12194#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)