336 auto anSVMInt = cl::allocate_svm<int, cl::SVMTraitCoarse<>>();
338 cl::SVMAllocator<Foo, cl::SVMTraitCoarse<cl::SVMTraitReadOnly<>>> svmAllocReadOnly;
339 auto fooPointer = cl::allocate_pointer<Foo>(svmAllocReadOnly);
340 fooPointer->bar = anSVMInt.get();
341 cl::SVMAllocator<int, cl::SVMTraitCoarse<>> svmAlloc;
342 std::vector<int, cl::SVMAllocator<int, cl::SVMTraitCoarse<>>> inputA(numElements, 1, svmAlloc);
343 cl::coarse_svm_vector<int> inputB(numElements, 2, svmAlloc);
346 // Traditional cl_mem allocations
348 std::vector<int> output(numElements, 0xdeadbeef);
349 cl::Buffer outputBuffer(output.begin(), output.end(), false);
350 cl::Pipe aPipe(sizeof(cl_int), numElements / 2);
352 // Default command queue, also passed in as a parameter
353 cl::DeviceCommandQueue defaultDeviceQueue = cl::DeviceCommandQueue::makeDefault(
354 cl::Context::getDefault(), cl::Device::getDefault());
356 auto vectorAddKernel =
358 decltype(fooPointer)&,
360 cl::coarse_svm_vector<int>&,
364 cl::DeviceCommandQueue
365 >(vectorAddProgram, "vectorAdd");
367 // Ensure that the additional SVM pointer is available to the kernel
368 // This one was not passed as a parameter
369 vectorAddKernel.setSVMPointers(anSVMInt);
374 cl::NDRange(numElements/2),
375 cl::NDRange(numElements/2)),
386 cl::copy(outputBuffer, output.begin(), output.end());
388 cl::Device d = cl::Device::getDefault();
390 std::cout << "Output:\n";
391 for (int i = 1; i < numElements; ++i) {
392 std::cout << "\t" << output[i] << "\n";
405#ifdef CL_HPP_OPENCL_API_WRAPPER
406#define CL_(name) CL_HPP_OPENCL_API_WRAPPER(name)
408#define CL_(name) ::name
415#if !defined(CL_HPP_USE_DX_INTEROP) && defined(USE_DX_INTEROP)
416# pragma message("opencl.hpp: USE_DX_INTEROP is deprecated. Define CL_HPP_USE_DX_INTEROP instead")
417# define CL_HPP_USE_DX_INTEROP
419#if !defined(CL_HPP_ENABLE_EXCEPTIONS) && defined(__CL_ENABLE_EXCEPTIONS)
420# pragma message("opencl.hpp: __CL_ENABLE_EXCEPTIONS is deprecated. Define CL_HPP_ENABLE_EXCEPTIONS instead")
421# define CL_HPP_ENABLE_EXCEPTIONS
423#if !defined(CL_HPP_NO_STD_VECTOR) && defined(__NO_STD_VECTOR)
424# pragma message("opencl.hpp: __NO_STD_VECTOR is deprecated. Define CL_HPP_NO_STD_VECTOR instead")
425# define CL_HPP_NO_STD_VECTOR
427#if !defined(CL_HPP_NO_STD_STRING) && defined(__NO_STD_STRING)
428# pragma message("opencl.hpp: __NO_STD_STRING is deprecated. Define CL_HPP_NO_STD_STRING instead")
429# define CL_HPP_NO_STD_STRING
431#if defined(VECTOR_CLASS)
432# pragma message("opencl.hpp: VECTOR_CLASS is deprecated. Alias cl::vector instead")
434#if defined(STRING_CLASS)
435# pragma message("opencl.hpp: STRING_CLASS is deprecated. Alias cl::string instead.")
437#if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS) && defined(__CL_USER_OVERRIDE_ERROR_STRINGS)
438# pragma message("opencl.hpp: __CL_USER_OVERRIDE_ERROR_STRINGS is deprecated. Define CL_HPP_USER_OVERRIDE_ERROR_STRINGS instead")
439# define CL_HPP_USER_OVERRIDE_ERROR_STRINGS
444#if defined(__USE_DEV_VECTOR)
445# pragma message("opencl.hpp: __USE_DEV_VECTOR is no longer supported. Expect compilation errors")
447#if defined(__USE_DEV_STRING)
448# pragma message("opencl.hpp: __USE_DEV_STRING is no longer supported. Expect compilation errors")
452#if !defined(CL_HPP_TARGET_OPENCL_VERSION)
453# pragma message("opencl.hpp: CL_HPP_TARGET_OPENCL_VERSION is not defined. It will default to 310 (OpenCL 3.1)")
454# define CL_HPP_TARGET_OPENCL_VERSION 310
456#if CL_HPP_TARGET_OPENCL_VERSION != 100 && \
457 CL_HPP_TARGET_OPENCL_VERSION != 110 && \
458 CL_HPP_TARGET_OPENCL_VERSION != 120 && \
459 CL_HPP_TARGET_OPENCL_VERSION != 200 && \
460 CL_HPP_TARGET_OPENCL_VERSION != 210 && \
461 CL_HPP_TARGET_OPENCL_VERSION != 220 && \
462 CL_HPP_TARGET_OPENCL_VERSION != 300 && \
463 CL_HPP_TARGET_OPENCL_VERSION != 310
464# pragma message("opencl.hpp: CL_HPP_TARGET_OPENCL_VERSION is not a valid value (100, 110, 120, 200, 210, 220, 300 or 310). It will be set to 310 (OpenCL 3.1).")
465# undef CL_HPP_TARGET_OPENCL_VERSION
466# define CL_HPP_TARGET_OPENCL_VERSION 310
470#if defined(CL_TARGET_OPENCL_VERSION)
473#if CL_TARGET_OPENCL_VERSION < CL_HPP_TARGET_OPENCL_VERSION
474# pragma message("CL_TARGET_OPENCL_VERSION is already defined as is lower than CL_HPP_TARGET_OPENCL_VERSION")
477# define CL_TARGET_OPENCL_VERSION CL_HPP_TARGET_OPENCL_VERSION
480#if !defined(CL_HPP_MINIMUM_OPENCL_VERSION)
481# define CL_HPP_MINIMUM_OPENCL_VERSION 200
483#if CL_HPP_MINIMUM_OPENCL_VERSION != 100 && \
484 CL_HPP_MINIMUM_OPENCL_VERSION != 110 && \
485 CL_HPP_MINIMUM_OPENCL_VERSION != 120 && \
486 CL_HPP_MINIMUM_OPENCL_VERSION != 200 && \
487 CL_HPP_MINIMUM_OPENCL_VERSION != 210 && \
488 CL_HPP_MINIMUM_OPENCL_VERSION != 220 && \
489 CL_HPP_MINIMUM_OPENCL_VERSION != 300 && \
490 CL_HPP_MINIMUM_OPENCL_VERSION != 310
491# pragma message("opencl.hpp: CL_HPP_MINIMUM_OPENCL_VERSION is not a valid value (100, 110, 120, 200, 210, 220, 300 or 310). It will be set to 100")
492# undef CL_HPP_MINIMUM_OPENCL_VERSION
493# define CL_HPP_MINIMUM_OPENCL_VERSION 100
495#if CL_HPP_MINIMUM_OPENCL_VERSION > CL_HPP_TARGET_OPENCL_VERSION
496# error "CL_HPP_MINIMUM_OPENCL_VERSION must not be greater than CL_HPP_TARGET_OPENCL_VERSION"
499#if CL_HPP_MINIMUM_OPENCL_VERSION <= 100 && !defined(CL_USE_DEPRECATED_OPENCL_1_0_APIS)
500# define CL_USE_DEPRECATED_OPENCL_1_0_APIS
502#if CL_HPP_MINIMUM_OPENCL_VERSION <= 110 && !defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
503# define CL_USE_DEPRECATED_OPENCL_1_1_APIS
505#if CL_HPP_MINIMUM_OPENCL_VERSION <= 120 && !defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
506# define CL_USE_DEPRECATED_OPENCL_1_2_APIS
508#if CL_HPP_MINIMUM_OPENCL_VERSION <= 200 && !defined(CL_USE_DEPRECATED_OPENCL_2_0_APIS)
509# define CL_USE_DEPRECATED_OPENCL_2_0_APIS
511#if CL_HPP_MINIMUM_OPENCL_VERSION <= 210 && !defined(CL_USE_DEPRECATED_OPENCL_2_1_APIS)
512# define CL_USE_DEPRECATED_OPENCL_2_1_APIS
514#if CL_HPP_MINIMUM_OPENCL_VERSION <= 220 && !defined(CL_USE_DEPRECATED_OPENCL_2_2_APIS)
515# define CL_USE_DEPRECATED_OPENCL_2_2_APIS
522#if defined(CL_HPP_USE_DX_INTEROP)
523#include <CL/cl_d3d10.h>
524#include <CL/cl_dx9_media_sharing.h>
536#if (!defined(_MSC_VER) && __cplusplus < 201103L) || (defined(_MSC_VER) && _MSC_VER < 1700)
537#error Visual studio 2013 or another C++11-supporting compiler required
540#if defined(__APPLE__) || defined(__MACOSX)
541#include <OpenCL/opencl.h>
543#include <CL/opencl.h>
546#if __cplusplus >= 201703L
547# define CL_HPP_DEFINE_STATIC_MEMBER_ inline
548#elif defined(_MSC_VER)
549# define CL_HPP_DEFINE_STATIC_MEMBER_ __declspec(selectany)
550#elif defined(__MINGW32__)
551# define CL_HPP_DEFINE_STATIC_MEMBER_ __attribute__((selectany))
553# define CL_HPP_DEFINE_STATIC_MEMBER_ __attribute__((weak))
558#if !defined(CL_API_PREFIX__VERSION_1_1_DEPRECATED)
559#define CL_API_PREFIX__VERSION_1_1_DEPRECATED
561#if !defined(CL_API_SUFFIX__VERSION_1_1_DEPRECATED)
562#define CL_API_SUFFIX__VERSION_1_1_DEPRECATED
565#if !defined(CL_API_PREFIX__VERSION_1_2_DEPRECATED)
566#define CL_API_PREFIX__VERSION_1_2_DEPRECATED
568#if !defined(CL_API_SUFFIX__VERSION_1_2_DEPRECATED)
569#define CL_API_SUFFIX__VERSION_1_2_DEPRECATED
572#if !defined(CL_API_PREFIX__VERSION_2_2_DEPRECATED)
573#define CL_API_PREFIX__VERSION_2_2_DEPRECATED
575#if !defined(CL_API_SUFFIX__VERSION_2_2_DEPRECATED)
576#define CL_API_SUFFIX__VERSION_2_2_DEPRECATED
579#if !defined(CL_CALLBACK)
592#if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY)
594 using size_type = ::size_t;
598 using size_type = size_t;
603#if defined(CL_HPP_ENABLE_EXCEPTIONS)
607#if !defined(CL_HPP_NO_STD_VECTOR)
610 template <
class T,
class Alloc = std::allocator<T> >
611 using vector = std::vector<T, Alloc>;
615#if !defined(CL_HPP_NO_STD_STRING)
618 using string = std::string;
622#if CL_HPP_TARGET_OPENCL_VERSION >= 200
624#if !defined(CL_HPP_NO_STD_UNIQUE_PTR)
629 template<
class T,
class D>
630 using pointer = std::unique_ptr<T, D>;
634#if !defined(CL_HPP_NO_STD_ARRAY)
637 template <
class T,
size_type N >
638 using array = std::array<T, N>;
644#if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY)
646 namespace compatibility {
661 for (
int i = 0; i < N; ++i) {
666 size_t(
const array<size_type, N> &rhs)
668 for (
int i = 0; i < N; ++i) {
673 size_type& operator[](
int index)
678 const size_type& operator[](
int index)
const
684 operator size_type* () {
return data_; }
687 operator const size_type* ()
const {
return data_; }
689 operator array<size_type, N>()
const
691 array<size_type, N> ret;
693 for (
int i = 0; i < N; ++i) {
702 using size_t = compatibility::size_t<N>;
709 using size_t_array = array<size_type, 3>;
721#define CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(name) \
722 using PFN_##name = name##_fn
724#define CL_HPP_INIT_CL_EXT_FCN_PTR_(name) \
726 pfn_##name = (PFN_##name)CL_(clGetExtensionFunctionAddress)(#name); \
729#define CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, name) \
731 pfn_##name = (PFN_##name) \
732 CL_(clGetExtensionFunctionAddressForPlatform)(platform, #name); \
735#ifdef cl_khr_external_memory
736 enum class ExternalMemoryType : cl_external_memory_handle_type_khr;
749#ifdef cl_khr_semaphore
752#if defined(cl_khr_command_buffer)
753 class CommandBufferKhr;
754 class MutableCommandKhr;
757#if defined(CL_HPP_ENABLE_EXCEPTIONS)
758#if !defined(CL_HPP_CUSTOM_EXCEPTION_TYPE)
763 class Error :
public std::exception
767 const char * errStr_;
778 Error(cl_int err,
const char * errStr =
nullptr) : err_(err), errStr_(errStr)
785 const char * what() const noexcept
override
787 if (errStr_ ==
nullptr) {
799 cl_int err(
void)
const {
return err_; }
802 using Error = CL_HPP_CUSTOM_EXCEPTION_TYPE;
804#define CL_HPP_ERR_STR_(x) #x
806#define CL_HPP_ERR_STR_(x) nullptr
812#if defined(CL_HPP_ENABLE_EXCEPTIONS)
813static inline cl_int errHandler (
815 const char * errStr =
nullptr)
817 if (err != CL_SUCCESS) {
818 throw Error(err, errStr);
823static inline cl_int errHandler (cl_int err,
const char * errStr =
nullptr)
834#if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS)
835#define __GET_DEVICE_INFO_ERR CL_HPP_ERR_STR_(clGetDeviceInfo)
836#define __GET_PLATFORM_INFO_ERR CL_HPP_ERR_STR_(clGetPlatformInfo)
837#define __GET_DEVICE_IDS_ERR CL_HPP_ERR_STR_(clGetDeviceIDs)
838#define __GET_PLATFORM_IDS_ERR CL_HPP_ERR_STR_(clGetPlatformIDs)
839#define __GET_CONTEXT_INFO_ERR CL_HPP_ERR_STR_(clGetContextInfo)
840#define __GET_EVENT_INFO_ERR CL_HPP_ERR_STR_(clGetEventInfo)
841#define __GET_EVENT_PROFILE_INFO_ERR CL_HPP_ERR_STR_(clGetEventProfileInfo)
842#define __GET_MEM_OBJECT_INFO_ERR CL_HPP_ERR_STR_(clGetMemObjectInfo)
843#define __GET_IMAGE_INFO_ERR CL_HPP_ERR_STR_(clGetImageInfo)
844#define __GET_SAMPLER_INFO_ERR CL_HPP_ERR_STR_(clGetSamplerInfo)
845#define __GET_KERNEL_INFO_ERR CL_HPP_ERR_STR_(clGetKernelInfo)
846#if CL_HPP_TARGET_OPENCL_VERSION >= 120
847#define __GET_KERNEL_ARG_INFO_ERR CL_HPP_ERR_STR_(clGetKernelArgInfo)
849#if CL_HPP_TARGET_OPENCL_VERSION >= 210
850#define __GET_KERNEL_SUB_GROUP_INFO_ERR CL_HPP_ERR_STR_(clGetKernelSubGroupInfo)
852#define __GET_KERNEL_SUB_GROUP_INFO_ERR CL_HPP_ERR_STR_(clGetKernelSubGroupInfoKHR)
854#define __GET_KERNEL_WORK_GROUP_INFO_ERR CL_HPP_ERR_STR_(clGetKernelWorkGroupInfo)
855#if CL_HPP_TARGET_OPENCL_VERSION >= 310
856#define __GET_KERNEL_SUGGESTED_LWS_ERR CL_HPP_ERR_STR_(clGetKernelSuggestedLocalWorkSize)
858#define __GET_PROGRAM_INFO_ERR CL_HPP_ERR_STR_(clGetProgramInfo)
859#define __GET_PROGRAM_BUILD_INFO_ERR CL_HPP_ERR_STR_(clGetProgramBuildInfo)
860#define __GET_COMMAND_QUEUE_INFO_ERR CL_HPP_ERR_STR_(clGetCommandQueueInfo)
862#define __CREATE_CONTEXT_ERR CL_HPP_ERR_STR_(clCreateContext)
863#define __CREATE_CONTEXT_FROM_TYPE_ERR CL_HPP_ERR_STR_(clCreateContextFromType)
864#define __GET_SUPPORTED_IMAGE_FORMATS_ERR CL_HPP_ERR_STR_(clGetSupportedImageFormats)
865#if CL_HPP_TARGET_OPENCL_VERSION >= 300
866#define __SET_CONTEXT_DESTRUCTOR_CALLBACK_ERR CL_HPP_ERR_STR_(clSetContextDestructorCallback)
869#define __CREATE_BUFFER_ERR CL_HPP_ERR_STR_(clCreateBuffer)
870#define __COPY_ERR CL_HPP_ERR_STR_(cl::copy)
871#define __CREATE_SUBBUFFER_ERR CL_HPP_ERR_STR_(clCreateSubBuffer)
872#define __CREATE_GL_BUFFER_ERR CL_HPP_ERR_STR_(clCreateFromGLBuffer)
873#define __CREATE_GL_RENDER_BUFFER_ERR CL_HPP_ERR_STR_(clCreateFromGLRenderbuffer)
874#define __GET_GL_OBJECT_INFO_ERR CL_HPP_ERR_STR_(clGetGLObjectInfo)
875#if CL_HPP_TARGET_OPENCL_VERSION >= 120
876#define __CREATE_IMAGE_ERR CL_HPP_ERR_STR_(clCreateImage)
877#define __CREATE_GL_TEXTURE_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture)
878#define __IMAGE_DIMENSION_ERR CL_HPP_ERR_STR_(Incorrect image dimensions)
880#define __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR CL_HPP_ERR_STR_(clSetMemObjectDestructorCallback)
882#define __CREATE_USER_EVENT_ERR CL_HPP_ERR_STR_(clCreateUserEvent)
883#define __SET_USER_EVENT_STATUS_ERR CL_HPP_ERR_STR_(clSetUserEventStatus)
884#define __SET_EVENT_CALLBACK_ERR CL_HPP_ERR_STR_(clSetEventCallback)
885#define __WAIT_FOR_EVENTS_ERR CL_HPP_ERR_STR_(clWaitForEvents)
887#define __CREATE_KERNEL_ERR CL_HPP_ERR_STR_(clCreateKernel)
888#define __SET_KERNEL_ARGS_ERR CL_HPP_ERR_STR_(clSetKernelArg)
889#define __CREATE_PROGRAM_WITH_SOURCE_ERR CL_HPP_ERR_STR_(clCreateProgramWithSource)
890#define __CREATE_PROGRAM_WITH_BINARY_ERR CL_HPP_ERR_STR_(clCreateProgramWithBinary)
891#if CL_HPP_TARGET_OPENCL_VERSION >= 210
892#define __CREATE_PROGRAM_WITH_IL_ERR CL_HPP_ERR_STR_(clCreateProgramWithIL)
894#define __CREATE_PROGRAM_WITH_IL_ERR CL_HPP_ERR_STR_(clCreateProgramWithILKHR)
896#if CL_HPP_TARGET_OPENCL_VERSION >= 120
897#define __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR CL_HPP_ERR_STR_(clCreateProgramWithBuiltInKernels)
899#define __BUILD_PROGRAM_ERR CL_HPP_ERR_STR_(clBuildProgram)
900#if CL_HPP_TARGET_OPENCL_VERSION >= 120
901#define __COMPILE_PROGRAM_ERR CL_HPP_ERR_STR_(clCompileProgram)
902#define __LINK_PROGRAM_ERR CL_HPP_ERR_STR_(clLinkProgram)
904#define __CREATE_KERNELS_IN_PROGRAM_ERR CL_HPP_ERR_STR_(clCreateKernelsInProgram)
906#if CL_HPP_TARGET_OPENCL_VERSION >= 200
907#define __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR CL_HPP_ERR_STR_(clCreateCommandQueueWithProperties)
908#define __CREATE_SAMPLER_WITH_PROPERTIES_ERR CL_HPP_ERR_STR_(clCreateSamplerWithProperties)
910#define __SET_COMMAND_QUEUE_PROPERTY_ERR CL_HPP_ERR_STR_(clSetCommandQueueProperty)
911#define __ENQUEUE_READ_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueReadBuffer)
912#define __ENQUEUE_READ_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueReadBufferRect)
913#define __ENQUEUE_WRITE_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueWriteBuffer)
914#define __ENQUEUE_WRITE_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueWriteBufferRect)
915#define __ENQEUE_COPY_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueCopyBuffer)
916#define __ENQEUE_COPY_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueCopyBufferRect)
917#define __ENQUEUE_FILL_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueFillBuffer)
918#define __ENQUEUE_READ_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueReadImage)
919#define __ENQUEUE_WRITE_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueWriteImage)
920#define __ENQUEUE_COPY_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueCopyImage)
921#define __ENQUEUE_FILL_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueFillImage)
922#define __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueCopyImageToBuffer)
923#define __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueCopyBufferToImage)
924#define __ENQUEUE_MAP_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueMapBuffer)
925#define __ENQUEUE_MAP_SVM_ERR CL_HPP_ERR_STR_(clEnqueueSVMMap)
926#define __ENQUEUE_FILL_SVM_ERR CL_HPP_ERR_STR_(clEnqueueSVMMemFill)
927#define __ENQUEUE_COPY_SVM_ERR CL_HPP_ERR_STR_(clEnqueueSVMMemcpy)
928#define __ENQUEUE_UNMAP_SVM_ERR CL_HPP_ERR_STR_(clEnqueueSVMUnmap)
929#define __ENQUEUE_MAP_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueMapImage)
930#define __ENQUEUE_UNMAP_MEM_OBJECT_ERR CL_HPP_ERR_STR_(clEnqueueUnMapMemObject)
931#define __ENQUEUE_NDRANGE_KERNEL_ERR CL_HPP_ERR_STR_(clEnqueueNDRangeKernel)
932#define __ENQUEUE_NATIVE_KERNEL CL_HPP_ERR_STR_(clEnqueueNativeKernel)
933#if CL_HPP_TARGET_OPENCL_VERSION >= 120
934#define __ENQUEUE_MIGRATE_MEM_OBJECTS_ERR CL_HPP_ERR_STR_(clEnqueueMigrateMemObjects)
936#if CL_HPP_TARGET_OPENCL_VERSION >= 210
937#define __ENQUEUE_MIGRATE_SVM_ERR CL_HPP_ERR_STR_(clEnqueueSVMMigrateMem)
938#define __SET_DEFAULT_DEVICE_COMMAND_QUEUE_ERR CL_HPP_ERR_STR_(clSetDefaultDeviceCommandQueue)
942#define __ENQUEUE_ACQUIRE_GL_ERR CL_HPP_ERR_STR_(clEnqueueAcquireGLObjects)
943#define __ENQUEUE_RELEASE_GL_ERR CL_HPP_ERR_STR_(clEnqueueReleaseGLObjects)
945#define __CREATE_PIPE_ERR CL_HPP_ERR_STR_(clCreatePipe)
946#define __GET_PIPE_INFO_ERR CL_HPP_ERR_STR_(clGetPipeInfo)
948#define __RETAIN_ERR CL_HPP_ERR_STR_(Retain Object)
949#define __RELEASE_ERR CL_HPP_ERR_STR_(Release Object)
950#define __FLUSH_ERR CL_HPP_ERR_STR_(clFlush)
951#define __FINISH_ERR CL_HPP_ERR_STR_(clFinish)
952#define __VECTOR_CAPACITY_ERR CL_HPP_ERR_STR_(Vector capacity error)
954#if CL_HPP_TARGET_OPENCL_VERSION >= 210
955#define __GET_HOST_TIMER_ERR CL_HPP_ERR_STR_(clGetHostTimer)
956#define __GET_DEVICE_AND_HOST_TIMER_ERR CL_HPP_ERR_STR_(clGetDeviceAndHostTimer)
958#if CL_HPP_TARGET_OPENCL_VERSION >= 220
959#define __SET_PROGRAM_RELEASE_CALLBACK_ERR CL_HPP_ERR_STR_(clSetProgramReleaseCallback)
960#define __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR CL_HPP_ERR_STR_(clSetProgramSpecializationConstant)
963#ifdef cl_khr_external_memory
964#define __ENQUEUE_ACQUIRE_EXTERNAL_MEMORY_ERR CL_HPP_ERR_STR_(clEnqueueAcquireExternalMemObjectsKHR)
965#define __ENQUEUE_RELEASE_EXTERNAL_MEMORY_ERR CL_HPP_ERR_STR_(clEnqueueReleaseExternalMemObjectsKHR)
968#ifdef cl_khr_semaphore
969#define __GET_SEMAPHORE_KHR_INFO_ERR CL_HPP_ERR_STR_(clGetSemaphoreInfoKHR)
970#define __CREATE_SEMAPHORE_KHR_WITH_PROPERTIES_ERR CL_HPP_ERR_STR_(clCreateSemaphoreWithPropertiesKHR)
971#define __ENQUEUE_WAIT_SEMAPHORE_KHR_ERR CL_HPP_ERR_STR_(clEnqueueWaitSemaphoresKHR)
972#define __ENQUEUE_SIGNAL_SEMAPHORE_KHR_ERR CL_HPP_ERR_STR_(clEnqueueSignalSemaphoresKHR)
973#define __RETAIN_SEMAPHORE_KHR_ERR CL_HPP_ERR_STR_(clRetainSemaphoreKHR)
974#define __RELEASE_SEMAPHORE_KHR_ERR CL_HPP_ERR_STR_(clReleaseSemaphoreKHR)
977#ifdef cl_khr_external_semaphore
978#define __GET_SEMAPHORE_HANDLE_FOR_TYPE_KHR_ERR CL_HPP_ERR_STR_(clGetSemaphoreHandleForTypeKHR)
981#if defined(cl_khr_command_buffer)
982#define __CREATE_COMMAND_BUFFER_KHR_ERR CL_HPP_ERR_STR_(clCreateCommandBufferKHR)
983#define __GET_COMMAND_BUFFER_INFO_KHR_ERR CL_HPP_ERR_STR_(clGetCommandBufferInfoKHR)
984#define __FINALIZE_COMMAND_BUFFER_KHR_ERR CL_HPP_ERR_STR_(clFinalizeCommandBufferKHR)
985#define __ENQUEUE_COMMAND_BUFFER_KHR_ERR CL_HPP_ERR_STR_(clEnqueueCommandBufferKHR)
986#define __COMMAND_BARRIER_WITH_WAIT_LIST_KHR_ERR CL_HPP_ERR_STR_(clCommandBarrierWithWaitListKHR)
987#define __COMMAND_COPY_BUFFER_KHR_ERR CL_HPP_ERR_STR_(clCommandCopyBufferKHR)
988#define __COMMAND_COPY_BUFFER_RECT_KHR_ERR CL_HPP_ERR_STR_(clCommandCopyBufferRectKHR)
989#define __COMMAND_COPY_BUFFER_TO_IMAGE_KHR_ERR CL_HPP_ERR_STR_(clCommandCopyBufferToImageKHR)
990#define __COMMAND_COPY_IMAGE_KHR_ERR CL_HPP_ERR_STR_(clCommandCopyImageKHR)
991#define __COMMAND_COPY_IMAGE_TO_BUFFER_KHR_ERR CL_HPP_ERR_STR_(clCommandCopyImageToBufferKHR)
992#define __COMMAND_FILL_BUFFER_KHR_ERR CL_HPP_ERR_STR_(clCommandFillBufferKHR)
993#define __COMMAND_FILL_IMAGE_KHR_ERR CL_HPP_ERR_STR_(clCommandFillImageKHR)
994#define __COMMAND_NDRANGE_KERNEL_KHR_ERR CL_HPP_ERR_STR_(clCommandNDRangeKernelKHR)
995#define __UPDATE_MUTABLE_COMMANDS_KHR_ERR CL_HPP_ERR_STR_(clUpdateMutableCommandsKHR)
996#define __GET_MUTABLE_COMMAND_INFO_KHR_ERR CL_HPP_ERR_STR_(clGetMutableCommandInfoKHR)
997#define __RETAIN_COMMAND_BUFFER_KHR_ERR CL_HPP_ERR_STR_(clRetainCommandBufferKHR)
998#define __RELEASE_COMMAND_BUFFER_KHR_ERR CL_HPP_ERR_STR_(clReleaseCommandBufferKHR)
1001#if defined(cl_ext_image_requirements_info)
1002#define __GET_IMAGE_REQUIREMENT_INFO_EXT_ERR CL_HPP_ERR_STR_(clGetImageRequirementsInfoEXT)
1008#if CL_HPP_TARGET_OPENCL_VERSION >= 120
1009#define __CREATE_SUB_DEVICES_ERR CL_HPP_ERR_STR_(clCreateSubDevices)
1011#define __CREATE_SUB_DEVICES_ERR CL_HPP_ERR_STR_(clCreateSubDevicesEXT)
1017#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
1018#define __ENQUEUE_MARKER_ERR CL_HPP_ERR_STR_(clEnqueueMarker)
1019#define __ENQUEUE_WAIT_FOR_EVENTS_ERR CL_HPP_ERR_STR_(clEnqueueWaitForEvents)
1020#define __ENQUEUE_BARRIER_ERR CL_HPP_ERR_STR_(clEnqueueBarrier)
1021#define __UNLOAD_COMPILER_ERR CL_HPP_ERR_STR_(clUnloadCompiler)
1022#define __CREATE_GL_TEXTURE_2D_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture2D)
1023#define __CREATE_GL_TEXTURE_3D_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture3D)
1024#define __CREATE_IMAGE2D_ERR CL_HPP_ERR_STR_(clCreateImage2D)
1025#define __CREATE_IMAGE3D_ERR CL_HPP_ERR_STR_(clCreateImage3D)
1031#if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
1032#define __CREATE_COMMAND_QUEUE_ERR CL_HPP_ERR_STR_(clCreateCommandQueue)
1033#define __ENQUEUE_TASK_ERR CL_HPP_ERR_STR_(clEnqueueTask)
1034#define __CREATE_SAMPLER_ERR CL_HPP_ERR_STR_(clCreateSampler)
1040#if CL_HPP_TARGET_OPENCL_VERSION >= 120
1041#define __ENQUEUE_MARKER_WAIT_LIST_ERR CL_HPP_ERR_STR_(clEnqueueMarkerWithWaitList)
1042#define __ENQUEUE_BARRIER_WAIT_LIST_ERR CL_HPP_ERR_STR_(clEnqueueBarrierWithWaitList)
1045#if CL_HPP_TARGET_OPENCL_VERSION >= 210
1046#define __CLONE_KERNEL_ERR CL_HPP_ERR_STR_(clCloneKernel)
1052#ifdef cl_khr_external_memory
1053CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clEnqueueAcquireExternalMemObjectsKHR);
1054CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clEnqueueReleaseExternalMemObjectsKHR);
1056CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clEnqueueAcquireExternalMemObjectsKHR pfn_clEnqueueAcquireExternalMemObjectsKHR =
nullptr;
1057CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clEnqueueReleaseExternalMemObjectsKHR pfn_clEnqueueReleaseExternalMemObjectsKHR =
nullptr;
1060#ifdef cl_khr_semaphore
1061CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCreateSemaphoreWithPropertiesKHR);
1062CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clReleaseSemaphoreKHR);
1063CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clRetainSemaphoreKHR);
1064CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clEnqueueWaitSemaphoresKHR);
1065CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clEnqueueSignalSemaphoresKHR);
1066CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clGetSemaphoreInfoKHR);
1068CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCreateSemaphoreWithPropertiesKHR pfn_clCreateSemaphoreWithPropertiesKHR =
nullptr;
1069CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clReleaseSemaphoreKHR pfn_clReleaseSemaphoreKHR =
nullptr;
1070CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clRetainSemaphoreKHR pfn_clRetainSemaphoreKHR =
nullptr;
1071CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clEnqueueWaitSemaphoresKHR pfn_clEnqueueWaitSemaphoresKHR =
nullptr;
1072CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clEnqueueSignalSemaphoresKHR pfn_clEnqueueSignalSemaphoresKHR =
nullptr;
1073CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clGetSemaphoreInfoKHR pfn_clGetSemaphoreInfoKHR =
nullptr;
1076#ifdef cl_khr_external_semaphore
1077CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clGetSemaphoreHandleForTypeKHR);
1078CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clGetSemaphoreHandleForTypeKHR pfn_clGetSemaphoreHandleForTypeKHR =
nullptr;
1081#if defined(cl_khr_command_buffer)
1082CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCreateCommandBufferKHR);
1083CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clFinalizeCommandBufferKHR);
1084CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clRetainCommandBufferKHR);
1085CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clReleaseCommandBufferKHR);
1086CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clGetCommandBufferInfoKHR);
1087CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clEnqueueCommandBufferKHR);
1088CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandBarrierWithWaitListKHR);
1089CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandCopyBufferKHR);
1090CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandCopyBufferRectKHR);
1091CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandCopyBufferToImageKHR);
1092CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandCopyImageKHR);
1093CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandCopyImageToBufferKHR);
1094CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandFillBufferKHR);
1095CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandFillImageKHR);
1096CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCommandNDRangeKernelKHR);
1098CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCreateCommandBufferKHR pfn_clCreateCommandBufferKHR =
nullptr;
1099CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clFinalizeCommandBufferKHR pfn_clFinalizeCommandBufferKHR =
nullptr;
1100CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clRetainCommandBufferKHR pfn_clRetainCommandBufferKHR =
nullptr;
1101CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clReleaseCommandBufferKHR pfn_clReleaseCommandBufferKHR =
nullptr;
1102CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clGetCommandBufferInfoKHR pfn_clGetCommandBufferInfoKHR =
nullptr;
1103CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clEnqueueCommandBufferKHR pfn_clEnqueueCommandBufferKHR =
nullptr;
1104CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandBarrierWithWaitListKHR pfn_clCommandBarrierWithWaitListKHR =
nullptr;
1105CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandCopyBufferKHR pfn_clCommandCopyBufferKHR =
nullptr;
1106CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandCopyBufferRectKHR pfn_clCommandCopyBufferRectKHR =
nullptr;
1107CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandCopyBufferToImageKHR pfn_clCommandCopyBufferToImageKHR =
nullptr;
1108CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandCopyImageKHR pfn_clCommandCopyImageKHR =
nullptr;
1109CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandCopyImageToBufferKHR pfn_clCommandCopyImageToBufferKHR =
nullptr;
1110CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandFillBufferKHR pfn_clCommandFillBufferKHR =
nullptr;
1111CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandFillImageKHR pfn_clCommandFillImageKHR =
nullptr;
1112CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCommandNDRangeKernelKHR pfn_clCommandNDRangeKernelKHR =
nullptr;
1115#if defined(cl_khr_command_buffer_mutable_dispatch)
1116CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clUpdateMutableCommandsKHR);
1117CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clGetMutableCommandInfoKHR);
1119CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clUpdateMutableCommandsKHR pfn_clUpdateMutableCommandsKHR =
nullptr;
1120CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clGetMutableCommandInfoKHR pfn_clGetMutableCommandInfoKHR =
nullptr;
1123#if defined(cl_ext_image_requirements_info)
1124CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clGetImageRequirementsInfoEXT);
1125CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clGetImageRequirementsInfoEXT pfn_clGetImageRequirementsInfoEXT =
nullptr;
1128#if defined(cl_ext_device_fission)
1129CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_(clCreateSubDevicesEXT);
1130CL_HPP_DEFINE_STATIC_MEMBER_ PFN_clCreateSubDevicesEXT
1131 pfn_clCreateSubDevicesEXT =
nullptr;
1140template<
typename Functor,
typename T>
1141inline cl_int getInfoHelper(Functor f, cl_uint name, T* param,
long)
1143 return f(name,
sizeof(T), param,
nullptr);
1148template <
typename Func>
1149inline cl_int getInfoHelper(Func f, cl_uint name, vector<vector<unsigned char>>* param,
int)
1151 if (name != CL_PROGRAM_BINARIES) {
1152 return CL_INVALID_VALUE;
1156 size_type numBinaries = param->size();
1157 vector<unsigned char*> binariesPointers(numBinaries);
1159 for (size_type i = 0; i < numBinaries; ++i)
1161 binariesPointers[i] = (*param)[i].data();
1164 cl_int err = f(name, numBinaries *
sizeof(
unsigned char*), binariesPointers.data(),
nullptr);
1166 if (err != CL_SUCCESS) {
1175template <
typename Func,
typename T>
1176inline cl_int getInfoHelper(Func f, cl_uint name, vector<T>* param,
long)
1179 cl_int err = f(name, 0,
nullptr, &required);
1180 if (err != CL_SUCCESS) {
1183 const size_type elements = required /
sizeof(T);
1186 vector<T> localData(elements);
1187 err = f(name, required, localData.data(),
nullptr);
1188 if (err != CL_SUCCESS) {
1192 *param = std::move(localData);
1204template <
typename Func,
typename T>
1205inline cl_int getInfoHelper(
1206 Func f, cl_uint name, vector<T>* param,
int,
typename T::cl_type = 0)
1209 cl_int err = f(name, 0,
nullptr, &required);
1210 if (err != CL_SUCCESS) {
1214 const size_type elements = required /
sizeof(
typename T::cl_type);
1216 vector<typename T::cl_type> value(elements);
1217 err = f(name, required, value.data(),
nullptr);
1218 if (err != CL_SUCCESS) {
1224 param->resize(elements);
1228 for (size_type i = 0; i < elements; i++) {
1229 (*param)[i] = T(value[i],
true);
1236template <
typename Func>
1237inline cl_int getInfoHelper(Func f, cl_uint name,
string* param,
long)
1240 cl_int err = f(name, 0,
nullptr, &required);
1241 if (err != CL_SUCCESS) {
1248 vector<char> value(required);
1249 err = f(name, required, value.data(),
nullptr);
1250 if (err != CL_SUCCESS) {
1254 param->assign(value.begin(), value.end() - 1);
1264template <
typename Func,
size_type N>
1265inline cl_int getInfoHelper(Func f, cl_uint name, array<size_type, N>* param,
long)
1268 cl_int err = f(name, 0,
nullptr, &required);
1269 if (err != CL_SUCCESS) {
1273 size_type elements = required /
sizeof(size_type);
1274 vector<size_type> value(elements, 0);
1276 err = f(name, required, value.data(),
nullptr);
1277 if (err != CL_SUCCESS) {
1286 for (size_type i = 0; i < elements; ++i) {
1287 (*param)[i] = value[i];
1301template<
typename Func,
typename T>
1302inline cl_int getInfoHelper(Func f, cl_uint name, T* param,
int,
typename T::cl_type = 0)
1304 typename T::cl_type value;
1305 cl_int err = f(name,
sizeof(value), &value,
nullptr);
1306 if (err != CL_SUCCESS) {
1310 if (value !=
nullptr)
1312 err = param->retain();
1313 if (err != CL_SUCCESS) {
1320#define CL_HPP_PARAM_NAME_INFO_1_0_(F) \
1321 F(cl_platform_info, CL_PLATFORM_PROFILE, string) \
1322 F(cl_platform_info, CL_PLATFORM_VERSION, string) \
1323 F(cl_platform_info, CL_PLATFORM_NAME, string) \
1324 F(cl_platform_info, CL_PLATFORM_VENDOR, string) \
1325 F(cl_platform_info, CL_PLATFORM_EXTENSIONS, string) \
1327 F(cl_device_info, CL_DEVICE_TYPE, cl_device_type) \
1328 F(cl_device_info, CL_DEVICE_VENDOR_ID, cl_uint) \
1329 F(cl_device_info, CL_DEVICE_MAX_COMPUTE_UNITS, cl_uint) \
1330 F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, cl_uint) \
1331 F(cl_device_info, CL_DEVICE_MAX_WORK_GROUP_SIZE, size_type) \
1332 F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_SIZES, cl::vector<size_type>) \
1333 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, cl_uint) \
1334 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT, cl_uint) \
1335 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT, cl_uint) \
1336 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG, cl_uint) \
1337 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT, cl_uint) \
1338 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, cl_uint) \
1339 F(cl_device_info, CL_DEVICE_MAX_CLOCK_FREQUENCY, cl_uint) \
1340 F(cl_device_info, CL_DEVICE_ADDRESS_BITS, cl_uint) \
1341 F(cl_device_info, CL_DEVICE_MAX_READ_IMAGE_ARGS, cl_uint) \
1342 F(cl_device_info, CL_DEVICE_MAX_WRITE_IMAGE_ARGS, cl_uint) \
1343 F(cl_device_info, CL_DEVICE_MAX_MEM_ALLOC_SIZE, cl_ulong) \
1344 F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_WIDTH, size_type) \
1345 F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_HEIGHT, size_type) \
1346 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_WIDTH, size_type) \
1347 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_HEIGHT, size_type) \
1348 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_DEPTH, size_type) \
1349 F(cl_device_info, CL_DEVICE_IMAGE_SUPPORT, cl_bool) \
1350 F(cl_device_info, CL_DEVICE_MAX_PARAMETER_SIZE, size_type) \
1351 F(cl_device_info, CL_DEVICE_MAX_SAMPLERS, cl_uint) \
1352 F(cl_device_info, CL_DEVICE_MEM_BASE_ADDR_ALIGN, cl_uint) \
1353 F(cl_device_info, CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE, cl_uint) \
1354 F(cl_device_info, CL_DEVICE_SINGLE_FP_CONFIG, cl_device_fp_config) \
1355 F(cl_device_info, CL_DEVICE_DOUBLE_FP_CONFIG, cl_device_fp_config) \
1356 F(cl_device_info, CL_DEVICE_HALF_FP_CONFIG, cl_device_fp_config) \
1357 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_TYPE, cl_device_mem_cache_type) \
1358 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE, cl_uint)\
1359 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_SIZE, cl_ulong) \
1360 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_SIZE, cl_ulong) \
1361 F(cl_device_info, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE, cl_ulong) \
1362 F(cl_device_info, CL_DEVICE_MAX_CONSTANT_ARGS, cl_uint) \
1363 F(cl_device_info, CL_DEVICE_LOCAL_MEM_TYPE, cl_device_local_mem_type) \
1364 F(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE, cl_ulong) \
1365 F(cl_device_info, CL_DEVICE_ERROR_CORRECTION_SUPPORT, cl_bool) \
1366 F(cl_device_info, CL_DEVICE_PROFILING_TIMER_RESOLUTION, size_type) \
1367 F(cl_device_info, CL_DEVICE_ENDIAN_LITTLE, cl_bool) \
1368 F(cl_device_info, CL_DEVICE_AVAILABLE, cl_bool) \
1369 F(cl_device_info, CL_DEVICE_COMPILER_AVAILABLE, cl_bool) \
1370 F(cl_device_info, CL_DEVICE_EXECUTION_CAPABILITIES, cl_device_exec_capabilities) \
1371 F(cl_device_info, CL_DEVICE_PLATFORM, cl::Platform) \
1372 F(cl_device_info, CL_DEVICE_NAME, string) \
1373 F(cl_device_info, CL_DEVICE_VENDOR, string) \
1374 F(cl_device_info, CL_DRIVER_VERSION, string) \
1375 F(cl_device_info, CL_DEVICE_PROFILE, string) \
1376 F(cl_device_info, CL_DEVICE_VERSION, string) \
1377 F(cl_device_info, CL_DEVICE_EXTENSIONS, string) \
1379 F(cl_context_info, CL_CONTEXT_REFERENCE_COUNT, cl_uint) \
1380 F(cl_context_info, CL_CONTEXT_DEVICES, cl::vector<Device>) \
1381 F(cl_context_info, CL_CONTEXT_PROPERTIES, cl::vector<cl_context_properties>) \
1383 F(cl_event_info, CL_EVENT_COMMAND_QUEUE, cl::CommandQueue) \
1384 F(cl_event_info, CL_EVENT_COMMAND_TYPE, cl_command_type) \
1385 F(cl_event_info, CL_EVENT_REFERENCE_COUNT, cl_uint) \
1386 F(cl_event_info, CL_EVENT_COMMAND_EXECUTION_STATUS, cl_int) \
1388 F(cl_profiling_info, CL_PROFILING_COMMAND_QUEUED, cl_ulong) \
1389 F(cl_profiling_info, CL_PROFILING_COMMAND_SUBMIT, cl_ulong) \
1390 F(cl_profiling_info, CL_PROFILING_COMMAND_START, cl_ulong) \
1391 F(cl_profiling_info, CL_PROFILING_COMMAND_END, cl_ulong) \
1393 F(cl_mem_info, CL_MEM_TYPE, cl_mem_object_type) \
1394 F(cl_mem_info, CL_MEM_FLAGS, cl_mem_flags) \
1395 F(cl_mem_info, CL_MEM_SIZE, size_type) \
1396 F(cl_mem_info, CL_MEM_HOST_PTR, void*) \
1397 F(cl_mem_info, CL_MEM_MAP_COUNT, cl_uint) \
1398 F(cl_mem_info, CL_MEM_REFERENCE_COUNT, cl_uint) \
1399 F(cl_mem_info, CL_MEM_CONTEXT, cl::Context) \
1401 F(cl_image_info, CL_IMAGE_FORMAT, cl_image_format) \
1402 F(cl_image_info, CL_IMAGE_ELEMENT_SIZE, size_type) \
1403 F(cl_image_info, CL_IMAGE_ROW_PITCH, size_type) \
1404 F(cl_image_info, CL_IMAGE_SLICE_PITCH, size_type) \
1405 F(cl_image_info, CL_IMAGE_WIDTH, size_type) \
1406 F(cl_image_info, CL_IMAGE_HEIGHT, size_type) \
1407 F(cl_image_info, CL_IMAGE_DEPTH, size_type) \
1409 F(cl_sampler_info, CL_SAMPLER_REFERENCE_COUNT, cl_uint) \
1410 F(cl_sampler_info, CL_SAMPLER_CONTEXT, cl::Context) \
1411 F(cl_sampler_info, CL_SAMPLER_NORMALIZED_COORDS, cl_bool) \
1412 F(cl_sampler_info, CL_SAMPLER_ADDRESSING_MODE, cl_addressing_mode) \
1413 F(cl_sampler_info, CL_SAMPLER_FILTER_MODE, cl_filter_mode) \
1415 F(cl_program_info, CL_PROGRAM_REFERENCE_COUNT, cl_uint) \
1416 F(cl_program_info, CL_PROGRAM_CONTEXT, cl::Context) \
1417 F(cl_program_info, CL_PROGRAM_NUM_DEVICES, cl_uint) \
1418 F(cl_program_info, CL_PROGRAM_DEVICES, cl::vector<Device>) \
1419 F(cl_program_info, CL_PROGRAM_SOURCE, string) \
1420 F(cl_program_info, CL_PROGRAM_BINARY_SIZES, cl::vector<size_type>) \
1421 F(cl_program_info, CL_PROGRAM_BINARIES, cl::vector<cl::vector<unsigned char>>) \
1423 F(cl_program_build_info, CL_PROGRAM_BUILD_STATUS, cl_build_status) \
1424 F(cl_program_build_info, CL_PROGRAM_BUILD_OPTIONS, string) \
1425 F(cl_program_build_info, CL_PROGRAM_BUILD_LOG, string) \
1427 F(cl_kernel_info, CL_KERNEL_FUNCTION_NAME, string) \
1428 F(cl_kernel_info, CL_KERNEL_NUM_ARGS, cl_uint) \
1429 F(cl_kernel_info, CL_KERNEL_REFERENCE_COUNT, cl_uint) \
1430 F(cl_kernel_info, CL_KERNEL_CONTEXT, cl::Context) \
1431 F(cl_kernel_info, CL_KERNEL_PROGRAM, cl::Program) \
1433 F(cl_kernel_work_group_info, CL_KERNEL_WORK_GROUP_SIZE, size_type) \
1434 F(cl_kernel_work_group_info, CL_KERNEL_COMPILE_WORK_GROUP_SIZE, cl::detail::size_t_array) \
1435 F(cl_kernel_work_group_info, CL_KERNEL_LOCAL_MEM_SIZE, cl_ulong) \
1437 F(cl_command_queue_info, CL_QUEUE_CONTEXT, cl::Context) \
1438 F(cl_command_queue_info, CL_QUEUE_DEVICE, cl::Device) \
1439 F(cl_command_queue_info, CL_QUEUE_REFERENCE_COUNT, cl_uint) \
1440 F(cl_command_queue_info, CL_QUEUE_PROPERTIES, cl_command_queue_properties)
1443#define CL_HPP_PARAM_NAME_INFO_1_1_(F) \
1444 F(cl_context_info, CL_CONTEXT_NUM_DEVICES, cl_uint)\
1445 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF, cl_uint) \
1446 F(cl_device_info, CL_DEVICE_HOST_UNIFIED_MEMORY, cl_bool) \
1447 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR, cl_uint) \
1448 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT, cl_uint) \
1449 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_INT, cl_uint) \
1450 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG, cl_uint) \
1451 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT, cl_uint) \
1452 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE, cl_uint) \
1453 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF, cl_uint) \
1454 F(cl_device_info, CL_DEVICE_OPENCL_C_VERSION, string) \
1456 F(cl_mem_info, CL_MEM_ASSOCIATED_MEMOBJECT, cl::Memory) \
1457 F(cl_mem_info, CL_MEM_OFFSET, size_type) \
1459 F(cl_kernel_work_group_info, CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, size_type) \
1460 F(cl_kernel_work_group_info, CL_KERNEL_PRIVATE_MEM_SIZE, cl_ulong) \
1462 F(cl_event_info, CL_EVENT_CONTEXT, cl::Context)
1464#define CL_HPP_PARAM_NAME_INFO_1_2_(F) \
1465 F(cl_program_info, CL_PROGRAM_NUM_KERNELS, size_type) \
1466 F(cl_program_info, CL_PROGRAM_KERNEL_NAMES, string) \
1468 F(cl_program_build_info, CL_PROGRAM_BINARY_TYPE, cl_program_binary_type) \
1470 F(cl_kernel_info, CL_KERNEL_ATTRIBUTES, string) \
1472 F(cl_kernel_arg_info, CL_KERNEL_ARG_ADDRESS_QUALIFIER, cl_kernel_arg_address_qualifier) \
1473 F(cl_kernel_arg_info, CL_KERNEL_ARG_ACCESS_QUALIFIER, cl_kernel_arg_access_qualifier) \
1474 F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_NAME, string) \
1475 F(cl_kernel_arg_info, CL_KERNEL_ARG_NAME, string) \
1476 F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_QUALIFIER, cl_kernel_arg_type_qualifier) \
1478 F(cl_kernel_work_group_info, CL_KERNEL_GLOBAL_WORK_SIZE, cl::detail::size_t_array) \
1480 F(cl_device_info, CL_DEVICE_LINKER_AVAILABLE, cl_bool) \
1481 F(cl_device_info, CL_DEVICE_IMAGE_MAX_BUFFER_SIZE, size_type) \
1482 F(cl_device_info, CL_DEVICE_IMAGE_MAX_ARRAY_SIZE, size_type) \
1483 F(cl_device_info, CL_DEVICE_PARENT_DEVICE, cl::Device) \
1484 F(cl_device_info, CL_DEVICE_PARTITION_MAX_SUB_DEVICES, cl_uint) \
1485 F(cl_device_info, CL_DEVICE_PARTITION_PROPERTIES, cl::vector<cl_device_partition_property>) \
1486 F(cl_device_info, CL_DEVICE_PARTITION_TYPE, cl::vector<cl_device_partition_property>) \
1487 F(cl_device_info, CL_DEVICE_REFERENCE_COUNT, cl_uint) \
1488 F(cl_device_info, CL_DEVICE_PREFERRED_INTEROP_USER_SYNC, cl_bool) \
1489 F(cl_device_info, CL_DEVICE_PARTITION_AFFINITY_DOMAIN, cl_device_affinity_domain) \
1490 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS, string) \
1491 F(cl_device_info, CL_DEVICE_PRINTF_BUFFER_SIZE, size_type) \
1493 F(cl_image_info, CL_IMAGE_ARRAY_SIZE, size_type) \
1494 F(cl_image_info, CL_IMAGE_NUM_MIP_LEVELS, cl_uint) \
1495 F(cl_image_info, CL_IMAGE_NUM_SAMPLES, cl_uint)
1497#define CL_HPP_PARAM_NAME_INFO_2_0_(F) \
1498 F(cl_device_info, CL_DEVICE_QUEUE_ON_HOST_PROPERTIES, cl_command_queue_properties) \
1499 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES, cl_command_queue_properties) \
1500 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE, cl_uint) \
1501 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE, cl_uint) \
1502 F(cl_device_info, CL_DEVICE_MAX_ON_DEVICE_QUEUES, cl_uint) \
1503 F(cl_device_info, CL_DEVICE_MAX_ON_DEVICE_EVENTS, cl_uint) \
1504 F(cl_device_info, CL_DEVICE_MAX_PIPE_ARGS, cl_uint) \
1505 F(cl_device_info, CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS, cl_uint) \
1506 F(cl_device_info, CL_DEVICE_PIPE_MAX_PACKET_SIZE, cl_uint) \
1507 F(cl_device_info, CL_DEVICE_SVM_CAPABILITIES, cl_device_svm_capabilities) \
1508 F(cl_device_info, CL_DEVICE_PREFERRED_PLATFORM_ATOMIC_ALIGNMENT, cl_uint) \
1509 F(cl_device_info, CL_DEVICE_PREFERRED_GLOBAL_ATOMIC_ALIGNMENT, cl_uint) \
1510 F(cl_device_info, CL_DEVICE_PREFERRED_LOCAL_ATOMIC_ALIGNMENT, cl_uint) \
1511 F(cl_device_info, CL_DEVICE_IMAGE_PITCH_ALIGNMENT, cl_uint) \
1512 F(cl_device_info, CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT, cl_uint) \
1513 F(cl_device_info, CL_DEVICE_MAX_READ_WRITE_IMAGE_ARGS, cl_uint ) \
1514 F(cl_device_info, CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE, size_type ) \
1515 F(cl_device_info, CL_DEVICE_GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE, size_type ) \
1516 F(cl_profiling_info, CL_PROFILING_COMMAND_COMPLETE, cl_ulong) \
1517 F(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM, cl_bool) \
1518 F(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_SVM_PTRS, void**) \
1519 F(cl_command_queue_info, CL_QUEUE_SIZE, cl_uint) \
1520 F(cl_mem_info, CL_MEM_USES_SVM_POINTER, cl_bool) \
1521 F(cl_program_build_info, CL_PROGRAM_BUILD_GLOBAL_VARIABLE_TOTAL_SIZE, size_type) \
1522 F(cl_pipe_info, CL_PIPE_PACKET_SIZE, cl_uint) \
1523 F(cl_pipe_info, CL_PIPE_MAX_PACKETS, cl_uint)
1525#define CL_HPP_PARAM_NAME_INFO_SUBGROUP_KHR_(F) \
1526 F(cl_kernel_sub_group_info, CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE_KHR, size_type) \
1527 F(cl_kernel_sub_group_info, CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE_KHR, size_type)
1529#define CL_HPP_PARAM_NAME_INFO_IL_KHR_(F) \
1530 F(cl_device_info, CL_DEVICE_IL_VERSION_KHR, string) \
1531 F(cl_program_info, CL_PROGRAM_IL_KHR, cl::vector<unsigned char>)
1533#define CL_HPP_PARAM_NAME_INFO_2_1_(F) \
1534 F(cl_platform_info, CL_PLATFORM_HOST_TIMER_RESOLUTION, cl_ulong) \
1535 F(cl_program_info, CL_PROGRAM_IL, cl::vector<unsigned char>) \
1536 F(cl_device_info, CL_DEVICE_MAX_NUM_SUB_GROUPS, cl_uint) \
1537 F(cl_device_info, CL_DEVICE_IL_VERSION, string) \
1538 F(cl_device_info, CL_DEVICE_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS, cl_bool) \
1539 F(cl_command_queue_info, CL_QUEUE_DEVICE_DEFAULT, cl::DeviceCommandQueue) \
1540 F(cl_kernel_sub_group_info, CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE, size_type) \
1541 F(cl_kernel_sub_group_info, CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE, size_type) \
1542 F(cl_kernel_sub_group_info, CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT, cl::detail::size_t_array) \
1543 F(cl_kernel_sub_group_info, CL_KERNEL_MAX_NUM_SUB_GROUPS, size_type) \
1544 F(cl_kernel_sub_group_info, CL_KERNEL_COMPILE_NUM_SUB_GROUPS, size_type)
1546#define CL_HPP_PARAM_NAME_INFO_2_2_(F) \
1547 F(cl_program_info, CL_PROGRAM_SCOPE_GLOBAL_CTORS_PRESENT, cl_bool) \
1548 F(cl_program_info, CL_PROGRAM_SCOPE_GLOBAL_DTORS_PRESENT, cl_bool)
1550#define CL_HPP_PARAM_NAME_DEVICE_FISSION_EXT_(F) \
1551 F(cl_device_info, CL_DEVICE_PARENT_DEVICE_EXT, cl::Device) \
1552 F(cl_device_info, CL_DEVICE_PARTITION_TYPES_EXT, cl::vector<cl_device_partition_property_ext>) \
1553 F(cl_device_info, CL_DEVICE_AFFINITY_DOMAINS_EXT, cl::vector<cl_device_partition_property_ext>) \
1554 F(cl_device_info, CL_DEVICE_REFERENCE_COUNT_EXT , cl_uint) \
1555 F(cl_device_info, CL_DEVICE_PARTITION_STYLE_EXT, cl::vector<cl_device_partition_property_ext>)
1557#define CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_CL3_SHARED_(F) \
1558 F(cl_platform_info, CL_PLATFORM_NUMERIC_VERSION_KHR, cl_version_khr) \
1559 F(cl_platform_info, CL_PLATFORM_EXTENSIONS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>) \
1561 F(cl_device_info, CL_DEVICE_NUMERIC_VERSION_KHR, cl_version_khr) \
1562 F(cl_device_info, CL_DEVICE_EXTENSIONS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>) \
1563 F(cl_device_info, CL_DEVICE_ILS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>) \
1564 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>)
1566#define CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_KHRONLY_(F) \
1567 F(cl_device_info, CL_DEVICE_OPENCL_C_NUMERIC_VERSION_KHR, cl_version_khr)
1570#define CL_HPP_PARAM_NAME_CL_KHR_SEMAPHORE_(F) \
1571 F(cl_semaphore_info_khr, CL_SEMAPHORE_CONTEXT_KHR, cl::Context) \
1572 F(cl_semaphore_info_khr, CL_SEMAPHORE_REFERENCE_COUNT_KHR, cl_uint) \
1573 F(cl_semaphore_info_khr, CL_SEMAPHORE_PROPERTIES_KHR, cl::vector<cl_semaphore_properties_khr>) \
1574 F(cl_semaphore_info_khr, CL_SEMAPHORE_TYPE_KHR, cl_semaphore_type_khr) \
1575 F(cl_semaphore_info_khr, CL_SEMAPHORE_PAYLOAD_KHR, cl_semaphore_payload_khr) \
1576 F(cl_platform_info, CL_PLATFORM_SEMAPHORE_TYPES_KHR, cl::vector<cl_semaphore_type_khr>) \
1577 F(cl_device_info, CL_DEVICE_SEMAPHORE_TYPES_KHR, cl::vector<cl_semaphore_type_khr>) \
1579#define CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_MEMORY_(F) \
1580 F(cl_device_info, CL_DEVICE_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR, cl::vector<cl::ExternalMemoryType>) \
1581 F(cl_platform_info, CL_PLATFORM_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR, cl::vector<cl::ExternalMemoryType>)
1583#define CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_(F) \
1584 F(cl_platform_info, CL_PLATFORM_SEMAPHORE_IMPORT_HANDLE_TYPES_KHR, cl::vector<cl_external_semaphore_handle_type_khr>) \
1585 F(cl_platform_info, CL_PLATFORM_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR, cl::vector<cl_external_semaphore_handle_type_khr>) \
1586 F(cl_device_info, CL_DEVICE_SEMAPHORE_IMPORT_HANDLE_TYPES_KHR, cl::vector<cl_external_semaphore_handle_type_khr>) \
1587 F(cl_device_info, CL_DEVICE_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR, cl::vector<cl_external_semaphore_handle_type_khr>) \
1588 F(cl_semaphore_info_khr, CL_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR, cl::vector<cl_external_semaphore_handle_type_khr>) \
1590#define CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_DX_FENCE_EXT(F) \
1591 F(cl_external_semaphore_handle_type_khr, CL_SEMAPHORE_HANDLE_D3D12_FENCE_KHR, void*) \
1593#define CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_OPAQUE_FD_EXT(F) \
1594 F(cl_external_semaphore_handle_type_khr, CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR, int) \
1596#define CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_SYNC_FD_EXT(F) \
1597 F(cl_external_semaphore_handle_type_khr, CL_SEMAPHORE_HANDLE_SYNC_FD_KHR, int) \
1599#define CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_WIN32_EXT(F) \
1600 F(cl_external_semaphore_handle_type_khr, CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KHR, void*) \
1601 F(cl_external_semaphore_handle_type_khr, CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KMT_KHR, void*) \
1603#define CL_HPP_PARAM_NAME_INFO_3_0_(F) \
1604 F(cl_platform_info, CL_PLATFORM_NUMERIC_VERSION, cl_version) \
1605 F(cl_platform_info, CL_PLATFORM_EXTENSIONS_WITH_VERSION, cl::vector<cl_name_version>) \
1607 F(cl_device_info, CL_DEVICE_NUMERIC_VERSION, cl_version) \
1608 F(cl_device_info, CL_DEVICE_EXTENSIONS_WITH_VERSION, cl::vector<cl_name_version>) \
1609 F(cl_device_info, CL_DEVICE_ILS_WITH_VERSION, cl::vector<cl_name_version>) \
1610 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS_WITH_VERSION, cl::vector<cl_name_version>) \
1611 F(cl_device_info, CL_DEVICE_ATOMIC_MEMORY_CAPABILITIES, cl_device_atomic_capabilities) \
1612 F(cl_device_info, CL_DEVICE_ATOMIC_FENCE_CAPABILITIES, cl_device_atomic_capabilities) \
1613 F(cl_device_info, CL_DEVICE_NON_UNIFORM_WORK_GROUP_SUPPORT, cl_bool) \
1614 F(cl_device_info, CL_DEVICE_OPENCL_C_ALL_VERSIONS, cl::vector<cl_name_version>) \
1615 F(cl_device_info, CL_DEVICE_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, size_type) \
1616 F(cl_device_info, CL_DEVICE_WORK_GROUP_COLLECTIVE_FUNCTIONS_SUPPORT, cl_bool) \
1617 F(cl_device_info, CL_DEVICE_GENERIC_ADDRESS_SPACE_SUPPORT, cl_bool) \
1618 F(cl_device_info, CL_DEVICE_OPENCL_C_FEATURES, cl::vector<cl_name_version>) \
1619 F(cl_device_info, CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES, cl_device_device_enqueue_capabilities) \
1620 F(cl_device_info, CL_DEVICE_PIPE_SUPPORT, cl_bool) \
1621 F(cl_device_info, CL_DEVICE_LATEST_CONFORMANCE_VERSION_PASSED, string) \
1623 F(cl_command_queue_info, CL_QUEUE_PROPERTIES_ARRAY, cl::vector<cl_queue_properties>) \
1624 F(cl_mem_info, CL_MEM_PROPERTIES, cl::vector<cl_mem_properties>) \
1625 F(cl_pipe_info, CL_PIPE_PROPERTIES, cl::vector<cl_pipe_properties>) \
1626 F(cl_sampler_info, CL_SAMPLER_PROPERTIES, cl::vector<cl_sampler_properties>) \
1628#define CL_HPP_PARAM_NAME_CL_IMAGE_REQUIREMENTS_EXT(F) \
1629 F(cl_image_requirements_info_ext, CL_IMAGE_REQUIREMENTS_ROW_PITCH_ALIGNMENT_EXT, size_type) \
1630 F(cl_image_requirements_info_ext, CL_IMAGE_REQUIREMENTS_BASE_ADDRESS_ALIGNMENT_EXT, size_type) \
1631 F(cl_image_requirements_info_ext, CL_IMAGE_REQUIREMENTS_SIZE_EXT, size_type) \
1632 F(cl_image_requirements_info_ext, CL_IMAGE_REQUIREMENTS_MAX_WIDTH_EXT, cl_uint) \
1633 F(cl_image_requirements_info_ext, CL_IMAGE_REQUIREMENTS_MAX_HEIGHT_EXT, cl_uint) \
1634 F(cl_image_requirements_info_ext, CL_IMAGE_REQUIREMENTS_MAX_DEPTH_EXT, cl_uint) \
1635 F(cl_image_requirements_info_ext, CL_IMAGE_REQUIREMENTS_MAX_ARRAY_SIZE_EXT, cl_uint) \
1637#define CL_HPP_PARAM_NAME_CL_IMAGE_REQUIREMENTS_SLICE_PITCH_ALIGNMENT_EXT(F) \
1638 F(cl_image_requirements_info_ext, CL_IMAGE_REQUIREMENTS_SLICE_PITCH_ALIGNMENT_EXT, size_type) \
1640#define CL_HPP_PARAM_NAME_CL_INTEL_COMMAND_QUEUE_FAMILIES_(F) \
1641 F(cl_device_info, CL_DEVICE_QUEUE_FAMILY_PROPERTIES_INTEL, cl::vector<cl_queue_family_properties_intel>) \
1643 F(cl_command_queue_info, CL_QUEUE_FAMILY_INTEL, cl_uint) \
1644 F(cl_command_queue_info, CL_QUEUE_INDEX_INTEL, cl_uint)
1646#define CL_HPP_PARAM_NAME_CL_INTEL_UNIFIED_SHARED_MEMORY_(F) \
1647 F(cl_device_info, CL_DEVICE_HOST_MEM_CAPABILITIES_INTEL, cl_device_unified_shared_memory_capabilities_intel ) \
1648 F(cl_device_info, CL_DEVICE_DEVICE_MEM_CAPABILITIES_INTEL, cl_device_unified_shared_memory_capabilities_intel ) \
1649 F(cl_device_info, CL_DEVICE_SINGLE_DEVICE_SHARED_MEM_CAPABILITIES_INTEL, cl_device_unified_shared_memory_capabilities_intel ) \
1650 F(cl_device_info, CL_DEVICE_CROSS_DEVICE_SHARED_MEM_CAPABILITIES_INTEL, cl_device_unified_shared_memory_capabilities_intel ) \
1651 F(cl_device_info, CL_DEVICE_SHARED_SYSTEM_MEM_CAPABILITIES_INTEL, cl_device_unified_shared_memory_capabilities_intel )
1653template <
typename enum_type, cl_
int Name>
1656#define CL_HPP_DECLARE_PARAM_TRAITS_(token, param_name, T) \
1659struct param_traits<detail:: token,param_name> \
1661 enum { value = param_name }; \
1662 typedef T param_type; \
1665CL_HPP_PARAM_NAME_INFO_1_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1666#if CL_HPP_TARGET_OPENCL_VERSION >= 110
1667CL_HPP_PARAM_NAME_INFO_1_1_(CL_HPP_DECLARE_PARAM_TRAITS_)
1669#if CL_HPP_TARGET_OPENCL_VERSION >= 120
1670CL_HPP_PARAM_NAME_INFO_1_2_(CL_HPP_DECLARE_PARAM_TRAITS_)
1672#if CL_HPP_TARGET_OPENCL_VERSION >= 200
1673CL_HPP_PARAM_NAME_INFO_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1675#if CL_HPP_TARGET_OPENCL_VERSION >= 210
1676CL_HPP_PARAM_NAME_INFO_2_1_(CL_HPP_DECLARE_PARAM_TRAITS_)
1678#if CL_HPP_TARGET_OPENCL_VERSION >= 220
1679CL_HPP_PARAM_NAME_INFO_2_2_(CL_HPP_DECLARE_PARAM_TRAITS_)
1681#if CL_HPP_TARGET_OPENCL_VERSION >= 300
1682CL_HPP_PARAM_NAME_INFO_3_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1685#if defined(cl_khr_subgroups) && CL_HPP_TARGET_OPENCL_VERSION < 210
1686CL_HPP_PARAM_NAME_INFO_SUBGROUP_KHR_(CL_HPP_DECLARE_PARAM_TRAITS_)
1689#if defined(cl_khr_il_program) && CL_HPP_TARGET_OPENCL_VERSION < 210
1690CL_HPP_PARAM_NAME_INFO_IL_KHR_(CL_HPP_DECLARE_PARAM_TRAITS_)
1695#define CL_HPP_PARAM_NAME_INFO_1_0_DEPRECATED_IN_2_0_(F) \
1696 F(cl_device_info, CL_DEVICE_QUEUE_PROPERTIES, cl_command_queue_properties)
1698#define CL_HPP_PARAM_NAME_INFO_1_2_DEPRECATED_IN_2_0_(F) \
1699 F(cl_image_info, CL_IMAGE_BUFFER, cl::Buffer)
1703#if CL_HPP_TARGET_OPENCL_VERSION > 100 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 && CL_HPP_TARGET_OPENCL_VERSION < 200
1704CL_HPP_PARAM_NAME_INFO_1_0_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1706#if CL_HPP_TARGET_OPENCL_VERSION > 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
1707CL_HPP_PARAM_NAME_INFO_1_2_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1710#if defined(cl_ext_device_fission)
1711CL_HPP_PARAM_NAME_DEVICE_FISSION_EXT_(CL_HPP_DECLARE_PARAM_TRAITS_)
1714#if defined(cl_khr_extended_versioning)
1715#if CL_HPP_TARGET_OPENCL_VERSION < 300
1716CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_CL3_SHARED_(CL_HPP_DECLARE_PARAM_TRAITS_)
1718CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_KHRONLY_(CL_HPP_DECLARE_PARAM_TRAITS_)
1721#if defined(cl_khr_semaphore)
1722CL_HPP_PARAM_NAME_CL_KHR_SEMAPHORE_(CL_HPP_DECLARE_PARAM_TRAITS_)
1723#if defined(CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR)
1724CL_HPP_DECLARE_PARAM_TRAITS_(cl_semaphore_info_khr, CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR, cl::vector<cl::Device>)
1728#ifdef cl_khr_external_memory
1729CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_MEMORY_(CL_HPP_DECLARE_PARAM_TRAITS_)
1732#if defined(cl_khr_external_semaphore)
1733CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_(CL_HPP_DECLARE_PARAM_TRAITS_)
1736#if defined(cl_khr_external_semaphore_dx_fence)
1737CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_DX_FENCE_EXT(CL_HPP_DECLARE_PARAM_TRAITS_)
1739#if defined(cl_khr_external_semaphore_opaque_fd)
1740CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_OPAQUE_FD_EXT(CL_HPP_DECLARE_PARAM_TRAITS_)
1742#if defined(cl_khr_external_semaphore_sync_fd)
1743CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_SYNC_FD_EXT(CL_HPP_DECLARE_PARAM_TRAITS_)
1745#if defined(cl_khr_external_semaphore_win32)
1746CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_WIN32_EXT(CL_HPP_DECLARE_PARAM_TRAITS_)
1749#if defined(cl_khr_device_uuid)
1750using uuid_array = array<cl_uchar, CL_UUID_SIZE_KHR>;
1751using luid_array = array<cl_uchar, CL_LUID_SIZE_KHR>;
1752CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_UUID_KHR, uuid_array)
1753CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DRIVER_UUID_KHR, uuid_array)
1754CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LUID_VALID_KHR, cl_bool)
1755CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LUID_KHR, luid_array)
1756CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_NODE_MASK_KHR, cl_uint)
1759#if defined(cl_khr_pci_bus_info)
1760CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_PCI_BUS_INFO_KHR, cl_device_pci_bus_info_khr)
1764#if CL_HPP_TARGET_OPENCL_VERSION < 200
1765#if defined(CL_DEVICE_IMAGE_PITCH_ALIGNMENT_KHR)
1766CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_IMAGE_PITCH_ALIGNMENT_KHR, cl_uint)
1768#if defined(CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT_KHR)
1769CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT_KHR, cl_uint)
1773#if defined(cl_khr_integer_dot_product)
1774CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGER_DOT_PRODUCT_CAPABILITIES_KHR, cl_device_integer_dot_product_capabilities_khr)
1775#if defined(CL_DEVICE_INTEGER_DOT_PRODUCT_ACCELERATION_PROPERTIES_8BIT_KHR)
1776CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGER_DOT_PRODUCT_ACCELERATION_PROPERTIES_8BIT_KHR, cl_device_integer_dot_product_acceleration_properties_khr)
1777CL_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)
1781#if defined(cl_ext_image_requirements_info)
1782CL_HPP_PARAM_NAME_CL_IMAGE_REQUIREMENTS_EXT(CL_HPP_DECLARE_PARAM_TRAITS_)
1785#if defined(cl_ext_image_from_buffer)
1786CL_HPP_PARAM_NAME_CL_IMAGE_REQUIREMENTS_SLICE_PITCH_ALIGNMENT_EXT(CL_HPP_DECLARE_PARAM_TRAITS_)
1789#ifdef CL_PLATFORM_ICD_SUFFIX_KHR
1790CL_HPP_DECLARE_PARAM_TRAITS_(cl_platform_info, CL_PLATFORM_ICD_SUFFIX_KHR,
string)
1793#ifdef CL_DEVICE_PROFILING_TIMER_OFFSET_AMD
1794CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_PROFILING_TIMER_OFFSET_AMD, cl_ulong)
1796#ifdef CL_DEVICE_GLOBAL_FREE_MEMORY_AMD
1797CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_FREE_MEMORY_AMD, vector<size_type>)
1799#ifdef CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD
1800CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD, cl_uint)
1802#ifdef CL_DEVICE_SIMD_WIDTH_AMD
1803CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_WIDTH_AMD, cl_uint)
1805#ifdef CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD
1806CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD, cl_uint)
1808#ifdef CL_DEVICE_WAVEFRONT_WIDTH_AMD
1809CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_WAVEFRONT_WIDTH_AMD, cl_uint)
1811#ifdef CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD
1812CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD, cl_uint)
1814#ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD
1815CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD, cl_uint)
1817#ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD
1818CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD, cl_uint)
1820#ifdef CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD
1821CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD, cl_uint)
1823#ifdef CL_DEVICE_LOCAL_MEM_BANKS_AMD
1824CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LOCAL_MEM_BANKS_AMD, cl_uint)
1826#ifdef CL_DEVICE_BOARD_NAME_AMD
1827CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_BOARD_NAME_AMD,
string)
1830#ifdef CL_DEVICE_COMPUTE_UNITS_BITFIELD_ARM
1831CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_UNITS_BITFIELD_ARM, cl_ulong)
1833#ifdef CL_DEVICE_JOB_SLOTS_ARM
1834CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_JOB_SLOTS_ARM, cl_uint)
1836#ifdef CL_DEVICE_SCHEDULING_CONTROLS_CAPABILITIES_ARM
1837CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SCHEDULING_CONTROLS_CAPABILITIES_ARM, cl_bitfield)
1839#ifdef CL_DEVICE_SUPPORTED_REGISTER_ALLOCATIONS_ARM
1840CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SUPPORTED_REGISTER_ALLOCATIONS_ARM, vector<cl_uint>)
1842#ifdef CL_DEVICE_MAX_WARP_COUNT_ARM
1843CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_MAX_WARP_COUNT_ARM, cl_uint)
1845#ifdef CL_KERNEL_MAX_WARP_COUNT_ARM
1846CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_info, CL_KERNEL_MAX_WARP_COUNT_ARM, cl_uint)
1848#ifdef CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_ARM
1849CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_ARM, cl_uint)
1851#ifdef CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_MODIFIER_ARM
1852CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_MODIFIER_ARM, cl_int)
1854#ifdef CL_KERNEL_EXEC_INFO_WARP_COUNT_LIMIT_ARM
1855CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_WARP_COUNT_LIMIT_ARM, cl_uint)
1857#ifdef CL_KERNEL_EXEC_INFO_COMPUTE_UNIT_MAX_QUEUED_BATCHES_ARM
1858CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_COMPUTE_UNIT_MAX_QUEUED_BATCHES_ARM, cl_uint)
1861#ifdef CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV
1862CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV, cl_uint)
1864#ifdef CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV
1865CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV, cl_uint)
1867#ifdef CL_DEVICE_REGISTERS_PER_BLOCK_NV
1868CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_REGISTERS_PER_BLOCK_NV, cl_uint)
1870#ifdef CL_DEVICE_WARP_SIZE_NV
1871CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_WARP_SIZE_NV, cl_uint)
1873#ifdef CL_DEVICE_GPU_OVERLAP_NV
1874CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GPU_OVERLAP_NV, cl_bool)
1876#ifdef CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV
1877CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV, cl_bool)
1879#ifdef CL_DEVICE_INTEGRATED_MEMORY_NV
1880CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGRATED_MEMORY_NV, cl_bool)
1883#if defined(cl_khr_command_buffer)
1884CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMMAND_BUFFER_CAPABILITIES_KHR, cl_device_command_buffer_capabilities_khr)
1885#if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 5)
1886CL_HPP_DECLARE_PARAM_TRAITS_(
1887 cl_device_info, CL_DEVICE_COMMAND_BUFFER_SUPPORTED_QUEUE_PROPERTIES_KHR,
1888 cl_command_queue_properties)
1890CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMMAND_BUFFER_REQUIRED_QUEUE_PROPERTIES_KHR, cl_command_queue_properties)
1891CL_HPP_DECLARE_PARAM_TRAITS_(cl_command_buffer_info_khr, CL_COMMAND_BUFFER_QUEUES_KHR, cl::vector<CommandQueue>)
1892CL_HPP_DECLARE_PARAM_TRAITS_(cl_command_buffer_info_khr, CL_COMMAND_BUFFER_NUM_QUEUES_KHR, cl_uint)
1893CL_HPP_DECLARE_PARAM_TRAITS_(cl_command_buffer_info_khr, CL_COMMAND_BUFFER_REFERENCE_COUNT_KHR, cl_uint)
1894CL_HPP_DECLARE_PARAM_TRAITS_(cl_command_buffer_info_khr, CL_COMMAND_BUFFER_STATE_KHR, cl_command_buffer_state_khr)
1895CL_HPP_DECLARE_PARAM_TRAITS_(cl_command_buffer_info_khr, CL_COMMAND_BUFFER_PROPERTIES_ARRAY_KHR, cl::vector<cl_command_buffer_properties_khr>)
1898#if defined(cl_khr_command_buffer_mutable_dispatch)
1899CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_COMMAND_COMMAND_QUEUE_KHR,
CommandQueue)
1900CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_COMMAND_COMMAND_BUFFER_KHR, CommandBufferKhr)
1901CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_COMMAND_COMMAND_TYPE_KHR, cl_command_type)
1903#if CL_KHR_COMMAND_BUFFER_MUTABLE_DISPATCH_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 2)
1904CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_COMMAND_PROPERTIES_ARRAY_KHR, cl::vector<cl_command_properties_khr>)
1906CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_DISPATCH_PROPERTIES_ARRAY_KHR, cl::vector<cl_ndrange_kernel_command_properties_khr>)
1908CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_DISPATCH_KERNEL_KHR, cl_kernel)
1909CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_DISPATCH_DIMENSIONS_KHR, cl_uint)
1910CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_DISPATCH_GLOBAL_WORK_OFFSET_KHR, cl::vector<size_type>)
1911CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_DISPATCH_GLOBAL_WORK_SIZE_KHR, cl::vector<size_type>)
1912CL_HPP_DECLARE_PARAM_TRAITS_(cl_mutable_command_info_khr, CL_MUTABLE_DISPATCH_LOCAL_WORK_SIZE_KHR, cl::vector<size_type>)
1915#if defined(cl_khr_kernel_clock)
1916CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_KERNEL_CLOCK_CAPABILITIES_KHR, cl_device_kernel_clock_capabilities_khr)
1919#if defined(cl_khr_spirv_queries)
1920CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SPIRV_EXTENDED_INSTRUCTION_SETS_KHR, cl::vector<const char*>)
1921CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SPIRV_EXTENSIONS_KHR, cl::vector<const char*>)
1922CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SPIRV_CAPABILITIES_KHR, cl::vector<cl_uint>)
1925#if defined(cl_ext_float_atomics)
1926CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SINGLE_FP_ATOMIC_CAPABILITIES_EXT, cl_device_fp_atomic_capabilities_ext)
1927CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_DOUBLE_FP_ATOMIC_CAPABILITIES_EXT, cl_device_fp_atomic_capabilities_ext)
1928CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_HALF_FP_ATOMIC_CAPABILITIES_EXT, cl_device_fp_atomic_capabilities_ext)
1931#if defined(cl_intel_command_queue_families)
1932CL_HPP_PARAM_NAME_CL_INTEL_COMMAND_QUEUE_FAMILIES_(CL_HPP_DECLARE_PARAM_TRAITS_)
1935#if defined(cl_intel_device_attribute_query)
1936CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_IP_VERSION_INTEL, cl_uint)
1937CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_ID_INTEL, cl_uint)
1938CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_NUM_SLICES_INTEL, cl_uint)
1939CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_NUM_SUB_SLICES_PER_SLICE_INTEL, cl_uint)
1940CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_NUM_EUS_PER_SUB_SLICE_INTEL, cl_uint)
1941CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_NUM_THREADS_PER_EU_INTEL, cl_uint)
1942CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_FEATURE_CAPABILITIES_INTEL, cl_device_feature_capabilities_intel)
1945#if defined(cl_intel_required_subgroup_size)
1946CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SUB_GROUP_SIZES_INTEL, cl::vector<size_type>)
1947CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_work_group_info, CL_KERNEL_SPILL_MEM_SIZE_INTEL, cl_ulong)
1950#if defined(cl_intel_unified_shared_memory)
1951CL_HPP_PARAM_NAME_CL_INTEL_UNIFIED_SHARED_MEMORY_(CL_HPP_DECLARE_PARAM_TRAITS_)
1956template <
typename Func,
typename T>
1958getInfo(Func f, cl_uint name, T* param)
1960 return getInfoHelper(f, name, param, 0);
1963template <
typename Func,
typename Arg0>
1966 Func f_;
const Arg0& arg0_;
1968 cl_uint param, size_type size,
void* value, size_type* size_ret)
1969 {
return f_(arg0_, param, size, value, size_ret); }
1972template <
typename Func,
typename Arg0,
typename Arg1>
1973struct GetInfoFunctor1
1975 Func f_;
const Arg0& arg0_;
const Arg1& arg1_;
1977 cl_uint param, size_type size,
void* value, size_type* size_ret)
1978 {
return f_(arg0_, arg1_, param, size, value, size_ret); }
1981template <
typename Func,
typename Arg0,
typename T>
1983getInfo(Func f,
const Arg0& arg0, cl_uint name, T* param)
1986 return getInfoHelper(f0, name, param, 0);
1989template <
typename Func,
typename Arg0,
typename Arg1,
typename T>
1991getInfo(Func f,
const Arg0& arg0,
const Arg1& arg1, cl_uint name, T* param)
1994 return getInfoHelper(f0, name, param, 0);
2002#if CL_HPP_TARGET_OPENCL_VERSION >= 120
2018 static cl_int
retain(cl_device_id device)
2019 {
return CL_(clRetainDevice)(device); }
2029 static cl_int
release(cl_device_id device)
2030 {
return CL_(clReleaseDevice)(device); }
2037struct ReferenceHandler<cl_device_id>
2040 static cl_int retain(cl_device_id)
2041 {
return CL_SUCCESS; }
2043 static cl_int release(cl_device_id)
2044 {
return CL_SUCCESS; }
2052 static cl_int retain(cl_platform_id)
2053 {
return CL_SUCCESS; }
2055 static cl_int release(cl_platform_id)
2056 {
return CL_SUCCESS; }
2060struct ReferenceHandler<cl_context>
2062 static cl_int retain(cl_context context)
2063 {
return CL_(clRetainContext)(context); }
2064 static cl_int release(cl_context context)
2065 {
return CL_(clReleaseContext)(context); }
2069struct ReferenceHandler<cl_command_queue>
2071 static cl_int retain(cl_command_queue queue)
2072 {
return CL_(clRetainCommandQueue)(queue); }
2073 static cl_int release(cl_command_queue queue)
2074 {
return CL_(clReleaseCommandQueue)(queue); }
2078struct ReferenceHandler<cl_mem>
2080 static cl_int retain(cl_mem memory)
2081 {
return CL_(clRetainMemObject)(memory); }
2082 static cl_int release(cl_mem memory)
2083 {
return CL_(clReleaseMemObject)(memory); }
2087struct ReferenceHandler<cl_sampler>
2089 static cl_int retain(cl_sampler sampler)
2090 {
return CL_(clRetainSampler)(sampler); }
2091 static cl_int release(cl_sampler sampler)
2092 {
return CL_(clReleaseSampler)(sampler); }
2096struct ReferenceHandler<cl_program>
2098 static cl_int retain(cl_program program)
2099 {
return CL_(clRetainProgram)(program); }
2100 static cl_int release(cl_program program)
2101 {
return CL_(clReleaseProgram)(program); }
2105struct ReferenceHandler<cl_kernel>
2107 static cl_int retain(cl_kernel kernel)
2108 {
return CL_(clRetainKernel)(kernel); }
2109 static cl_int release(cl_kernel kernel)
2110 {
return CL_(clReleaseKernel)(kernel); }
2114struct ReferenceHandler<cl_event>
2116 static cl_int retain(cl_event event)
2117 {
return CL_(clRetainEvent)(event); }
2118 static cl_int release(cl_event event)
2119 {
return CL_(clReleaseEvent)(event); }
2122#ifdef cl_khr_semaphore
2126 static cl_int retain(cl_semaphore_khr semaphore)
2128 if (pfn_clRetainSemaphoreKHR !=
nullptr) {
2129 return pfn_clRetainSemaphoreKHR(semaphore);
2132 return CL_INVALID_OPERATION;
2135 static cl_int release(cl_semaphore_khr semaphore)
2137 if (pfn_clReleaseSemaphoreKHR !=
nullptr) {
2138 return pfn_clReleaseSemaphoreKHR(semaphore);
2141 return CL_INVALID_OPERATION;
2145#if defined(cl_khr_command_buffer)
2149 static cl_int retain(cl_command_buffer_khr cmdBufferKhr)
2151 if (pfn_clRetainCommandBufferKHR ==
nullptr) {
2152 return detail::errHandler(CL_INVALID_OPERATION, __RETAIN_COMMAND_BUFFER_KHR_ERR);
2154 return pfn_clRetainCommandBufferKHR(cmdBufferKhr);
2157 static cl_int release(cl_command_buffer_khr cmdBufferKhr)
2159 if (pfn_clReleaseCommandBufferKHR ==
nullptr) {
2160 return detail::errHandler(CL_INVALID_OPERATION, __RELEASE_COMMAND_BUFFER_KHR_ERR);
2162 return pfn_clReleaseCommandBufferKHR(cmdBufferKhr);
2170 static cl_int retain(cl_mutable_command_khr)
2171 {
return CL_SUCCESS; }
2173 static cl_int release(cl_mutable_command_khr)
2174 {
return CL_SUCCESS; }
2179#if (CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120) || \
2180 (CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200)
2182static cl_uint getVersion(
const vector<char> &versionInfo)
2184 int highVersion = 0;
2187 while(versionInfo[index] !=
'.' ) {
2189 highVersion += versionInfo[index]-
'0';
2193 while(versionInfo[index] !=
' ' && versionInfo[index] !=
'\0') {
2195 lowVersion += versionInfo[index]-
'0';
2198 return (highVersion << 16) | lowVersion;
2201static cl_uint getPlatformVersion(cl_platform_id platform)
2204 CL_(clGetPlatformInfo)(platform, CL_PLATFORM_VERSION, 0,
nullptr, &size);
2206 vector<char> versionInfo(size);
2207 CL_(clGetPlatformInfo)(platform, CL_PLATFORM_VERSION, size, versionInfo.data(), &size);
2208 return getVersion(versionInfo);
2211static cl_uint getDevicePlatformVersion(cl_device_id device)
2213 cl_platform_id platform;
2214 CL_(clGetDeviceInfo)(device, CL_DEVICE_PLATFORM,
sizeof(platform), &platform,
nullptr);
2215 return getPlatformVersion(platform);
2218static cl_uint getContextPlatformVersion(cl_context context)
2223 CL_(clGetContextInfo)(context, CL_CONTEXT_DEVICES, 0,
nullptr, &size);
2226 vector<cl_device_id> devices(size/
sizeof(cl_device_id));
2227 CL_(clGetContextInfo)(context, CL_CONTEXT_DEVICES, size, devices.data(),
nullptr);
2228 return getDevicePlatformVersion(devices[0]);
2232template <
typename T>
2242 Wrapper() : object_(
nullptr) { }
2244 Wrapper(
const cl_type &obj,
bool retainObject) : object_(obj)
2247 detail::errHandler(retain(), __RETAIN_ERR);
2253 if (object_ !=
nullptr) { release(); }
2256 Wrapper(
const Wrapper<cl_type>& rhs)
2258 object_ = rhs.object_;
2259 detail::errHandler(retain(), __RETAIN_ERR);
2262 Wrapper(Wrapper<cl_type>&& rhs)
noexcept
2264 object_ = rhs.object_;
2265 rhs.object_ =
nullptr;
2268 Wrapper<cl_type>& operator = (
const Wrapper<cl_type>& rhs)
2271 detail::errHandler(release(), __RELEASE_ERR);
2272 object_ = rhs.object_;
2273 detail::errHandler(retain(), __RETAIN_ERR);
2278 Wrapper<cl_type>& operator = (Wrapper<cl_type>&& rhs)
2281 detail::errHandler(release(), __RELEASE_ERR);
2282 object_ = rhs.object_;
2283 rhs.object_ =
nullptr;
2288 Wrapper<cl_type>& operator = (
const cl_type &rhs)
2290 detail::errHandler(release(), __RELEASE_ERR);
2295 const cl_type& operator ()()
const {
return object_; }
2297 cl_type& operator ()() {
return object_; }
2299 cl_type get()
const {
return object_; }
2302 template<
typename Func,
typename U>
2303 friend inline cl_int getInfoHelper(Func, cl_uint, U*,
int,
typename U::cl_type);
2305 cl_int retain()
const
2307 if (object_ !=
nullptr) {
2308 return ReferenceHandler<cl_type>::retain(object_);
2315 cl_int release()
const
2317 if (object_ !=
nullptr) {
2318 return ReferenceHandler<cl_type>::release(object_);
2327class Wrapper<cl_device_id>
2330 typedef cl_device_id cl_type;
2334 bool referenceCountable_;
2336 static bool isReferenceCountable(cl_device_id device)
2338 bool retVal =
false;
2339#if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
2340 if (device !=
nullptr) {
2341 int version = getDevicePlatformVersion(device);
2342 if(version > ((1 << 16) + 1)) {
2346#elif CL_HPP_TARGET_OPENCL_VERSION >= 120
2354 Wrapper() : object_(nullptr), referenceCountable_(false)
2358 Wrapper(
const cl_type &obj,
bool retainObject) :
2360 referenceCountable_(false)
2362 referenceCountable_ = isReferenceCountable(obj);
2365 detail::errHandler(retain(), __RETAIN_ERR);
2374 Wrapper(
const Wrapper<cl_type>& rhs)
2376 object_ = rhs.object_;
2377 referenceCountable_ = isReferenceCountable(object_);
2378 detail::errHandler(retain(), __RETAIN_ERR);
2381 Wrapper(Wrapper<cl_type>&& rhs)
noexcept
2383 object_ = rhs.object_;
2384 referenceCountable_ = rhs.referenceCountable_;
2385 rhs.object_ =
nullptr;
2386 rhs.referenceCountable_ =
false;
2389 Wrapper<cl_type>& operator = (
const Wrapper<cl_type>& rhs)
2392 detail::errHandler(release(), __RELEASE_ERR);
2393 object_ = rhs.object_;
2394 referenceCountable_ = rhs.referenceCountable_;
2395 detail::errHandler(retain(), __RETAIN_ERR);
2400 Wrapper<cl_type>& operator = (Wrapper<cl_type>&& rhs)
2403 detail::errHandler(release(), __RELEASE_ERR);
2404 object_ = rhs.object_;
2405 referenceCountable_ = rhs.referenceCountable_;
2406 rhs.object_ =
nullptr;
2407 rhs.referenceCountable_ =
false;
2412 Wrapper<cl_type>& operator = (
const cl_type &rhs)
2414 detail::errHandler(release(), __RELEASE_ERR);
2416 referenceCountable_ = isReferenceCountable(object_);
2420 const cl_type& operator ()()
const {
return object_; }
2422 cl_type& operator ()() {
return object_; }
2424 cl_type get()
const {
return object_; }
2427 template<
typename Func,
typename U>
2428 friend inline cl_int getInfoHelper(Func, cl_uint, U*,
int,
typename U::cl_type);
2430 template<
typename Func,
typename U>
2431 friend inline cl_int getInfoHelper(Func, cl_uint, vector<U>*,
int,
typename U::cl_type);
2433 cl_int retain()
const
2435 if( object_ !=
nullptr && referenceCountable_ ) {
2436 return ReferenceHandler<cl_type>::retain(object_);
2443 cl_int release()
const
2445 if (object_ !=
nullptr && referenceCountable_) {
2446 return ReferenceHandler<cl_type>::release(object_);
2454template <
typename T>
2457 return lhs() == rhs();
2460template <
typename T>
2463 return !operator==(lhs, rhs);
2484 ImageFormat(cl_channel_order order, cl_channel_type type)
2486 image_channel_order = order;
2487 image_channel_data_type = type;
2497 this->image_channel_data_type = rhs.image_channel_data_type;
2498 this->image_channel_order = rhs.image_channel_order;
2514 static std::once_flag default_initialized_;
2516 static cl_int default_error_;
2523 static void makeDefault();
2530 static void makeDefaultProvided(
const Device &p) {
2535#ifdef CL_HPP_UNIT_TEST_ENABLE
2542 static void unitTestClearDefault() {
2548 Device() : detail::Wrapper<cl_type>() { }
2554 explicit Device(
const cl_device_id &device,
bool retainObject =
false) :
2555 detail::Wrapper<cl_type>(device, retainObject) { }
2562 cl_int *errResult =
nullptr)
2564 std::call_once(default_initialized_, makeDefault);
2565 detail::errHandler(default_error_);
2566 if (errResult !=
nullptr) {
2567 *errResult = default_error_;
2581 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_device));
2582 detail::errHandler(default_error_);
2592 detail::Wrapper<cl_type>::operator=(rhs);
2598 template <
typename T>
2599 cl_int
getInfo(cl_device_info name, T* param)
const
2601 return detail::errHandler(
2602 detail::getInfo(CL_(clGetDeviceInfo), object_, name, param),
2603 __GET_DEVICE_INFO_ERR);
2607 template <cl_device_info name>
typename
2609 getInfo(cl_int* err =
nullptr)
const
2612 detail::cl_device_info, name>::param_type param{};
2613 cl_int result =
getInfo(name, ¶m);
2614 if (err !=
nullptr) {
2620#if CL_HPP_TARGET_OPENCL_VERSION >= 210
2629 cl_ulong retVal = 0;
2631 CL_(clGetHostTimer)(this->get(), &retVal);
2634 __GET_HOST_TIMER_ERR);
2653 std::pair<cl_ulong, cl_ulong> retVal;
2655 CL_(clGetDeviceAndHostTimer)(this->get(), &(retVal.first), &(retVal.second));
2658 __GET_DEVICE_AND_HOST_TIMER_ERR);
2666#if CL_HPP_TARGET_OPENCL_VERSION >= 120
2669 vector<Device>* devices);
2672#if defined(cl_ext_device_fission)
2674 cl_int
createSubDevices(
const cl_device_partition_property_ext* properties,
2675 vector<Device>* devices);
2679using BuildLogType = vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, CL_PROGRAM_BUILD_LOG>::param_type>>;
2680#if defined(CL_HPP_ENABLE_EXCEPTIONS)
2684class BuildError :
public Error
2687 BuildLogType buildLogs;
2689 BuildError(cl_int err,
const char * errStr,
const BuildLogType &vec) : Error(err, errStr), buildLogs(vec)
2693 BuildLogType getBuildLog()
const
2699 static inline cl_int buildErrHandler(
2701 const char * errStr,
2702 const BuildLogType &buildLogs)
2704 if (err != CL_SUCCESS) {
2705 throw BuildError(err, errStr, buildLogs);
2713 static inline cl_int buildErrHandler(
2715 const char * errStr,
2716 const BuildLogType &buildLogs)
2725CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Device::default_initialized_;
2726CL_HPP_DEFINE_STATIC_MEMBER_
Device Device::default_;
2727CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Device::default_error_ = CL_SUCCESS;
2739 static std::once_flag default_initialized_;
2741 static cl_int default_error_;
2748 static void makeDefault() {
2752#if defined(CL_HPP_ENABLE_EXCEPTIONS)
2760 cl_int err = CL_(clGetPlatformIDs)(0,
nullptr, &n);
2761 if (err != CL_SUCCESS) {
2762 default_error_ = err;
2766 default_error_ = CL_INVALID_PLATFORM;
2770 vector<cl_platform_id> ids(n);
2771 err = CL_(clGetPlatformIDs)(n, ids.data(),
nullptr);
2772 if (err != CL_SUCCESS) {
2773 default_error_ = err;
2779#if defined(CL_HPP_ENABLE_EXCEPTIONS)
2780 catch (cl::Error &e) {
2781 default_error_ = e.err();
2791 static void makeDefaultProvided(
const Platform &p) {
2796#ifdef CL_HPP_UNIT_TEST_ENABLE
2803 static void unitTestClearDefault() {
2809 Platform() : detail::Wrapper<cl_type>() { }
2818 explicit Platform(
const cl_platform_id &platform,
bool retainObject =
false) :
2819 detail::Wrapper<cl_type>(platform, retainObject) { }
2827 detail::Wrapper<cl_type>::operator=(rhs);
2832 cl_int *errResult =
nullptr)
2834 std::call_once(default_initialized_, makeDefault);
2835 detail::errHandler(default_error_);
2836 if (errResult !=
nullptr) {
2837 *errResult = default_error_;
2851 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_platform));
2852 detail::errHandler(default_error_);
2857 template <
typename T>
2858 cl_int
getInfo(cl_platform_info name, T* param)
const
2860 return detail::errHandler(
2861 detail::getInfo(CL_(clGetPlatformInfo), object_, name, param),
2862 __GET_PLATFORM_INFO_ERR);
2866 template <cl_platform_info name>
typename
2868 getInfo(cl_int* err =
nullptr)
const
2871 detail::cl_platform_info, name>::param_type param{};
2872 cl_int result =
getInfo(name, ¶m);
2873 if (err !=
nullptr) {
2884 cl_device_type type,
2885 vector<Device>& devices)
const
2888 cl_int err = CL_(clGetDeviceIDs)(object_, type, 0,
nullptr, &n);
2889 if (err != CL_SUCCESS && err != CL_DEVICE_NOT_FOUND) {
2890 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2893 vector<cl_device_id> ids(n);
2895 err = CL_(clGetDeviceIDs)(object_, type, n, ids.data(),
nullptr);
2896 if (err != CL_SUCCESS) {
2897 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2905 devices.resize(ids.size());
2909 for (size_type i = 0; i < ids.size(); i++) {
2910 devices[i] =
Device(ids[i],
true);
2920 cl_device_type type,
2921 vector<Device>* devices)
const
2923 if( devices ==
nullptr ) {
2924 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR);
2930#if defined(CL_HPP_USE_DX_INTEROP)
2955 cl_d3d10_device_source_khr d3d_device_source,
2957 cl_d3d10_device_set_khr d3d_device_set,
2958 vector<Device>& devices)
const
2960 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clGetDeviceIDsFromD3D10KHR)(
2961 cl_platform_id platform,
2962 cl_d3d10_device_source_khr d3d_device_source,
2964 cl_d3d10_device_set_khr d3d_device_set,
2965 cl_uint num_entries,
2966 cl_device_id * devices,
2967 cl_uint* num_devices);
2969 static PFN_clGetDeviceIDsFromD3D10KHR pfn_clGetDeviceIDsFromD3D10KHR =
nullptr;
2970#if CL_HPP_TARGET_OPENCL_VERSION >= 120
2971 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(object_, clGetDeviceIDsFromD3D10KHR);
2973#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
2974 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetDeviceIDsFromD3D10KHR);
2978 cl_int err = pfn_clGetDeviceIDsFromD3D10KHR(
2986 if (err != CL_SUCCESS) {
2987 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2990 vector<cl_device_id> ids(n);
2991 err = pfn_clGetDeviceIDsFromD3D10KHR(
2999 if (err != CL_SUCCESS) {
3000 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
3007 devices.resize(ids.size());
3011 for (size_type i = 0; i < ids.size(); i++) {
3012 devices[i] = Device(ids[i],
true);
3022 cl_d3d10_device_source_khr d3d_device_source,
3024 cl_d3d10_device_set_khr d3d_device_set,
3025 vector<Device>* devices)
const
3027 if( devices ==
nullptr ) {
3028 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR);
3031 return getDevices(d3d_device_source, d3d_object, d3d_device_set, *devices);
3040 vector<Platform>& platforms)
3044 cl_int err = CL_(clGetPlatformIDs)(0,
nullptr, &n);
3045 if (err != CL_SUCCESS) {
3046 return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
3049 vector<cl_platform_id> ids(n);
3050 err = CL_(clGetPlatformIDs)(n, ids.data(),
nullptr);
3051 if (err != CL_SUCCESS) {
3052 return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
3055 platforms.resize(ids.size());
3058 for (size_type i = 0; i < ids.size(); i++) {
3069 vector<Platform>* platforms)
3071 if( platforms ==
nullptr ) {
3072 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_PLATFORM_IDS_ERR);
3075 return get(*platforms);
3086 Platform default_platform = Platform::getDefault(&err);
3088 *platform = default_platform;
3102 cl_int * errResult =
nullptr)
3105 Platform default_platform = Platform::getDefault(&err);
3109 return default_platform;
3112#if CL_HPP_TARGET_OPENCL_VERSION >= 120
3117 return CL_(clUnloadPlatformCompiler)(object_);
3122#if CL_HPP_TARGET_OPENCL_VERSION >= 120
3125 vector<Device>* devices)
3128 cl_int err = CL_(clCreateSubDevices)(object_, properties, 0,
nullptr, &n);
3129 if (err != CL_SUCCESS)
3131 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
3134 vector<cl_device_id> ids(n);
3135 err = CL_(clCreateSubDevices)(object_, properties, n, ids.data(),
nullptr);
3136 if (err != CL_SUCCESS)
3138 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
3145 devices->resize(ids.size());
3149 for (size_type i = 0; i < ids.size(); i++)
3153 (*devices)[i] =
Device(ids[i],
false);
3161#if defined(cl_ext_device_fission)
3164 vector<Device>* devices)
3166#if CL_HPP_TARGET_OPENCL_VERSION >= 120
3167 cl::Device device(object_);
3168 cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>()();
3169 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCreateSubDevicesEXT);
3171#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
3172 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateSubDevicesEXT);
3176 cl_int err = pfn_clCreateSubDevicesEXT(object_, properties, 0,
nullptr, &n);
3177 if (err != CL_SUCCESS)
3179 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
3182 vector<cl_device_id> ids(n);
3184 pfn_clCreateSubDevicesEXT(object_, properties, n, ids.data(),
nullptr);
3185 if (err != CL_SUCCESS)
3187 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
3193 devices->resize(ids.size());
3197 for (size_type i = 0; i < ids.size(); i++)
3201 (*devices)[i] =
Device(ids[i],
false);
3209CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Platform::default_initialized_;
3210CL_HPP_DEFINE_STATIC_MEMBER_
Platform Platform::default_;
3211CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Platform::default_error_ = CL_SUCCESS;
3217#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
3222inline CL_API_PREFIX__VERSION_1_1_DEPRECATED cl_int
3227 return CL_(clUnloadCompiler)();
3232#if defined(cl_ext_image_requirements_info)
3233enum ImageRequirementsInfoExt : cl_image_requirements_info_ext
3235 RowPitchAlign = CL_IMAGE_REQUIREMENTS_ROW_PITCH_ALIGNMENT_EXT,
3236 BaseAddAlign = CL_IMAGE_REQUIREMENTS_BASE_ADDRESS_ALIGNMENT_EXT,
3237 Size = CL_IMAGE_REQUIREMENTS_SIZE_EXT,
3238 MaxWidth = CL_IMAGE_REQUIREMENTS_MAX_WIDTH_EXT,
3239 MaxHeight = CL_IMAGE_REQUIREMENTS_MAX_HEIGHT_EXT,
3240 MaxDepth = CL_IMAGE_REQUIREMENTS_MAX_DEPTH_EXT,
3241 MaxArraySize = CL_IMAGE_REQUIREMENTS_MAX_ARRAY_SIZE_EXT,
3242#if defined(cl_ext_image_from_buffer)
3243 SlicePitchAlign = CL_IMAGE_REQUIREMENTS_SLICE_PITCH_ALIGNMENT_EXT,
3262 static std::once_flag default_initialized_;
3264 static cl_int default_error_;
3271 static void makeDefault() {
3275#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3279#if !defined(__APPLE__) && !defined(__MACOS)
3280 const Platform &p = Platform::getDefault();
3281 cl_platform_id defaultPlatform = p();
3282 cl_context_properties properties[3] = {
3283 CL_CONTEXT_PLATFORM, (cl_context_properties)defaultPlatform, 0
3286 cl_context_properties *properties =
nullptr;
3290 CL_DEVICE_TYPE_DEFAULT,
3296#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3297 catch (cl::Error &e) {
3298 default_error_ = e.err();
3309 static void makeDefaultProvided(
const Context &c) {
3313#if defined(cl_ext_image_requirements_info)
3314 struct ImageRequirementsInfo {
3316 ImageRequirementsInfo(cl_mem_flags f,
const cl_mem_properties* mem_properties,
const ImageFormat* format,
const cl_image_desc* desc)
3319 properties = mem_properties;
3320 image_format = format;
3324 cl_mem_flags flags = 0;
3325 const cl_mem_properties* properties;
3327 const cl_image_desc* image_desc;
3330 static cl_int getImageRequirementsInfoExtHelper(
const Context &context,
3331 const ImageRequirementsInfo &info,
3332 cl_image_requirements_info_ext param_name,
3333 size_type param_value_size,
3335 size_type* param_value_size_ret)
3338#if CL_HPP_TARGET_OPENCL_VERSION >= 120
3339 Device device = context.
getInfo<CL_CONTEXT_DEVICES>().at(0);
3340 cl_platform_id platform = device.
getInfo<CL_DEVICE_PLATFORM>()();
3341 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clGetImageRequirementsInfoEXT);
3343 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetImageRequirementsInfoEXT);
3346 if (pfn_clGetImageRequirementsInfoEXT ==
nullptr) {
3347 return detail::errHandler(CL_INVALID_OPERATION, __GET_IMAGE_REQUIREMENT_INFO_EXT_ERR);
3350 return detail::errHandler(
3351 pfn_clGetImageRequirementsInfoEXT(context(), info.properties,
3352 info.flags, info.image_format, info.image_desc, param_name,
3353 param_value_size, param_value, param_value_size_ret),
3354 __GET_IMAGE_REQUIREMENT_INFO_EXT_ERR);
3359#ifdef CL_HPP_UNIT_TEST_ENABLE
3366 static void unitTestClearDefault() {
3376 const vector<Device>& devices,
3377 const cl_context_properties* properties =
nullptr,
3378 void (CL_CALLBACK * notifyFptr)(
3383 void* data =
nullptr,
3384 cl_int* err =
nullptr)
3388 size_type numDevices = devices.size();
3389 vector<cl_device_id> deviceIDs(numDevices);
3391 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
3392 deviceIDs[deviceIndex] = (devices[deviceIndex])();
3395 object_ = CL_(clCreateContext)(
3397 (cl_uint)deviceIDs.size(),
3398 deviceIDs.empty() ?
nullptr : deviceIDs.data(),
3399 notifyFptr, data, &error);
3401 detail::errHandler(error, __CREATE_CONTEXT_ERR);
3402 if (err !=
nullptr) {
3413 const cl_context_properties* properties =
nullptr,
3414 void (CL_CALLBACK * notifyFptr)(
3419 void* data =
nullptr,
3420 cl_int* err =
nullptr)
3424 cl_device_id deviceID = device();
3426 object_ = CL_(clCreateContext)(
3429 notifyFptr, data, &error);
3431 detail::errHandler(error, __CREATE_CONTEXT_ERR);
3432 if (err !=
nullptr) {
3442 cl_device_type type,
3443 const cl_context_properties* properties =
nullptr,
3444 void (CL_CALLBACK * notifyFptr)(
3449 void* data =
nullptr,
3450 cl_int* err =
nullptr)
3454#if !defined(__APPLE__) && !defined(__MACOS)
3455 cl_context_properties prop[4] = {CL_CONTEXT_PLATFORM, 0, 0, 0 };
3457 if (properties ==
nullptr) {
3459 vector<Platform> platforms;
3461 if (error != CL_SUCCESS) {
3462 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
3463 if (err !=
nullptr) {
3470 cl_context_properties platform_id = 0;
3471 for (
unsigned int i = 0; i < platforms.size(); i++) {
3473 vector<Device> devices;
3475#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3479 error = platforms[i].getDevices(type, &devices);
3481#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3482 }
catch (cl::Error& e) {
3490 if (error != CL_SUCCESS && error != CL_DEVICE_NOT_FOUND) {
3491 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
3492 if (err !=
nullptr) {
3497 if (devices.size() > 0) {
3498 platform_id = (cl_context_properties)platforms[i]();
3503 if (platform_id == 0) {
3504 detail::errHandler(CL_DEVICE_NOT_FOUND, __CREATE_CONTEXT_FROM_TYPE_ERR);
3505 if (err !=
nullptr) {
3506 *err = CL_DEVICE_NOT_FOUND;
3511 prop[1] = platform_id;
3512 properties = &prop[0];
3515 object_ = CL_(clCreateContextFromType)(
3516 properties, type, notifyFptr, data, &error);
3518 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
3519 if (err !=
nullptr) {
3531 std::call_once(default_initialized_, makeDefault);
3532 detail::errHandler(default_error_);
3533 if (err !=
nullptr) {
3534 *err = default_error_;
3548 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_context));
3549 detail::errHandler(default_error_);
3554 Context() : detail::Wrapper<cl_type>() { }
3561 explicit Context(
const cl_context& context,
bool retainObject =
false) :
3562 detail::Wrapper<cl_type>(context, retainObject) { }
3571 detail::Wrapper<cl_type>::operator=(rhs);
3576 template <
typename T>
3577 cl_int
getInfo(cl_context_info name, T* param)
const
3579 return detail::errHandler(
3580 detail::getInfo(CL_(clGetContextInfo), object_, name, param),
3581 __GET_CONTEXT_INFO_ERR);
3585 template <cl_context_info name>
typename
3587 getInfo(cl_int* err =
nullptr)
const
3590 detail::cl_context_info, name>::param_type param{};
3591 cl_int result =
getInfo(name, ¶m);
3592 if (err !=
nullptr) {
3604 cl_mem_object_type type,
3605 vector<ImageFormat>& formats)
const
3609 cl_int err = CL_(clGetSupportedImageFormats)(
3616 if (err != CL_SUCCESS) {
3617 return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
3620 if (numEntries > 0) {
3621 vector<ImageFormat> value(numEntries);
3622 err = CL_(clGetSupportedImageFormats)(
3627 (cl_image_format*)value.data(),
3629 if (err != CL_SUCCESS) {
3630 return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
3633 formats.assign(value.begin(), value.end());
3649 cl_mem_object_type type,
3650 vector<ImageFormat>* formats)
const
3652 if( formats ==
nullptr ) {
3653 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
3658#if defined(cl_ext_image_requirements_info)
3659 template <
typename T>
3660 cl_int getImageRequirementsInfoExt(cl_image_requirements_info_ext name,
3662 cl_mem_flags flags = 0,
3663 const cl_mem_properties* properties =
nullptr,
3665 const cl_image_desc* image_desc =
nullptr)
const
3667 ImageRequirementsInfo imageInfo = {flags, properties, image_format, image_desc};
3669 return detail::errHandler(
3671 Context::getImageRequirementsInfoExtHelper, *
this, imageInfo, name, param),
3672 __GET_IMAGE_REQUIREMENT_INFO_EXT_ERR);
3675 template <cl_image_requirements_info_ext type>
typename
3676 detail::param_traits<detail::cl_image_requirements_info_ext, type>::param_type
3677 getImageRequirementsInfoExt(cl_mem_flags flags = 0,
3678 const cl_mem_properties* properties =
nullptr,
3679 const ImageFormat* image_format =
nullptr,
3680 const cl_image_desc* image_desc =
nullptr,
3681 cl_int* err =
nullptr)
const
3683 typename detail::param_traits<
3684 detail::cl_image_requirements_info_ext, type>::param_type param{};
3685 cl_int result = getImageRequirementsInfoExt(type, ¶m, flags, properties, image_format, image_desc);
3686 if (err !=
nullptr) {
3693#if CL_HPP_TARGET_OPENCL_VERSION >= 300
3705 void (CL_CALLBACK * pfn_notify)(cl_context,
void *),
3706 void * user_data =
nullptr)
3708 return detail::errHandler(
3709 CL_(clSetContextDestructorCallback)(
3713 __SET_CONTEXT_DESTRUCTOR_CALLBACK_ERR);
3718inline void Device::makeDefault()
3723#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3730 detail::errHandler(error, __CREATE_CONTEXT_ERR);
3732 if (error != CL_SUCCESS) {
3733 default_error_ = error;
3736 default_ = context.getInfo<CL_CONTEXT_DEVICES>()[0];
3737 default_error_ = CL_SUCCESS;
3740#if defined(CL_HPP_ENABLE_EXCEPTIONS)
3741 catch (cl::Error &e) {
3742 default_error_ = e.err();
3747CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Context::default_initialized_;
3748CL_HPP_DEFINE_STATIC_MEMBER_
Context Context::default_;
3749CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Context::default_error_ = CL_SUCCESS;
3773 explicit Event(
const cl_event& event,
bool retainObject =
false) :
3774 detail::Wrapper<cl_type>(event, retainObject) { }
3783 detail::Wrapper<cl_type>::operator=(rhs);
3788 template <
typename T>
3789 cl_int
getInfo(cl_event_info name, T* param)
const
3791 return detail::errHandler(
3792 detail::getInfo(CL_(clGetEventInfo), object_, name, param),
3793 __GET_EVENT_INFO_ERR);
3797 template <cl_event_info name>
typename
3799 getInfo(cl_int* err =
nullptr)
const
3802 detail::cl_event_info, name>::param_type param{};
3803 cl_int result =
getInfo(name, ¶m);
3804 if (err !=
nullptr) {
3811 template <
typename T>
3814 return detail::errHandler(detail::getInfo(
3815 CL_(clGetEventProfilingInfo), object_, name, param),
3816 __GET_EVENT_PROFILE_INFO_ERR);
3820 template <cl_profiling_info name>
typename
3825 detail::cl_profiling_info, name>::param_type param{};
3827 if (err !=
nullptr) {
3839 return detail::errHandler(
3840 CL_(clWaitForEvents)(1, &object_),
3841 __WAIT_FOR_EVENTS_ERR);
3844#if CL_HPP_TARGET_OPENCL_VERSION >= 110
3851 void (CL_CALLBACK * pfn_notify)(cl_event, cl_int,
void *),
3852 void * user_data =
nullptr)
3854 return detail::errHandler(
3855 CL_(clSetEventCallback)(
3860 __SET_EVENT_CALLBACK_ERR);
3871 static_assert(
sizeof(
cl::Event) ==
sizeof(cl_event),
3872 "Size of cl::Event must be equal to size of cl_event");
3874 return detail::errHandler(
3875 CL_(clWaitForEvents)(
3876 (cl_uint) events.size(), (events.size() > 0) ? (
const cl_event*)&events.front() :
nullptr),
3877 __WAIT_FOR_EVENTS_ERR);
3881#if CL_HPP_TARGET_OPENCL_VERSION >= 110
3895 cl_int * err =
nullptr)
3898 object_ = CL_(clCreateUserEvent)(
3902 detail::errHandler(error, __CREATE_USER_EVENT_ERR);
3903 if (err !=
nullptr) {
3917 return detail::errHandler(
3918 CL_(clSetUserEventStatus)(object_,status),
3919 __SET_USER_EVENT_STATUS_ERR);
3929WaitForEvents(
const vector<Event>& events)
3931 return detail::errHandler(
3932 CL_(clWaitForEvents)(
3933 (cl_uint) events.size(), (events.size() > 0) ? (
const cl_event*)&events.front() :
nullptr),
3934 __WAIT_FOR_EVENTS_ERR);
3962 explicit Memory(
const cl_mem& memory,
bool retainObject) :
3963 detail::Wrapper<cl_type>(memory, retainObject) { }
3972 detail::Wrapper<cl_type>::operator=(rhs);
3977 template <
typename T>
3978 cl_int
getInfo(cl_mem_info name, T* param)
const
3980 return detail::errHandler(
3981 detail::getInfo(CL_(clGetMemObjectInfo), object_, name, param),
3982 __GET_MEM_OBJECT_INFO_ERR);
3986 template <cl_mem_info name>
typename
3988 getInfo(cl_int* err =
nullptr)
const
3991 detail::cl_mem_info, name>::param_type param{};
3992 cl_int result =
getInfo(name, ¶m);
3993 if (err !=
nullptr) {
3999#if CL_HPP_TARGET_OPENCL_VERSION >= 110
4014 void (CL_CALLBACK * pfn_notify)(cl_mem,
void *),
4015 void * user_data =
nullptr)
4017 return detail::errHandler(
4018 CL_(clSetMemObjectDestructorCallback)(
4022 __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR);
4030template<
typename IteratorType >
4031cl_int
copy( IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer );
4032template<
typename IteratorType >
4033cl_int
copy(
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator );
4034template<
typename IteratorType >
4035cl_int
copy(
const CommandQueue &queue, IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer );
4036template<
typename IteratorType >
4037cl_int
copy(
const CommandQueue &queue,
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator );
4040#if CL_HPP_TARGET_OPENCL_VERSION >= 200
4046 static cl_svm_mem_flags getSVMMemFlags()
4053template<
class Trait = detail::SVMTraitNull>
4054class SVMTraitReadWrite
4057 static cl_svm_mem_flags getSVMMemFlags()
4059 return CL_MEM_READ_WRITE |
4060 Trait::getSVMMemFlags();
4064template<
class Trait = detail::SVMTraitNull>
4065class SVMTraitReadOnly
4068 static cl_svm_mem_flags getSVMMemFlags()
4070 return CL_MEM_READ_ONLY |
4071 Trait::getSVMMemFlags();
4075template<
class Trait = detail::SVMTraitNull>
4076class SVMTraitWriteOnly
4079 static cl_svm_mem_flags getSVMMemFlags()
4081 return CL_MEM_WRITE_ONLY |
4082 Trait::getSVMMemFlags();
4086template<
class Trait = SVMTraitReadWrite<>>
4090 static cl_svm_mem_flags getSVMMemFlags()
4092 return Trait::getSVMMemFlags();
4096template<
class Trait = SVMTraitReadWrite<>>
4100 static cl_svm_mem_flags getSVMMemFlags()
4102 return CL_MEM_SVM_FINE_GRAIN_BUFFER |
4103 Trait::getSVMMemFlags();
4107template<
class Trait = SVMTraitReadWrite<>>
4111 static cl_svm_mem_flags getSVMMemFlags()
4114 CL_MEM_SVM_FINE_GRAIN_BUFFER |
4115 CL_MEM_SVM_ATOMICS |
4116 Trait::getSVMMemFlags();
4127 const vector<Event>* events =
nullptr,
4128 Event* event =
nullptr);
4141template<
typename T,
class SVMTrait>
4147 typedef T value_type;
4148 typedef value_type* pointer;
4149 typedef const value_type* const_pointer;
4150 typedef value_type& reference;
4151 typedef const value_type& const_reference;
4152 typedef std::size_t size_type;
4153 typedef std::ptrdiff_t difference_type;
4155 template<
typename U>
4158 typedef SVMAllocator<U, SVMTrait> other;
4161 template<
typename U,
typename V>
4162 friend class SVMAllocator;
4165 context_(
Context::getDefault())
4175 SVMAllocator(
const SVMAllocator &other) :
4176 context_(other.context_)
4180 template<
typename U>
4181 SVMAllocator(
const SVMAllocator<U, SVMTrait> &other) :
4182 context_(other.context_)
4190 pointer address(reference r)
noexcept
4192 return std::addressof(r);
4195 const_pointer address(const_reference r)
noexcept
4197 return std::addressof(r);
4208 typename cl::SVMAllocator<void, SVMTrait>::const_pointer = 0,
4215 SVMTrait::getSVMMemFlags(),
4218 pointer retValue =
reinterpret_cast<pointer
>(
4220#if defined(CL_HPP_ENABLE_EXCEPTIONS)
4222 std::bad_alloc excep;
4228 if (map && !(SVMTrait::getSVMMemFlags() & CL_MEM_SVM_FINE_GRAIN_BUFFER)) {
4229 cl_int err =
enqueueMapSVM(retValue, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE, size*
sizeof(T));
4230 if (err != CL_SUCCESS) {
4231 CL_(clSVMFree)(context_(), retValue);
4233#if defined(CL_HPP_ENABLE_EXCEPTIONS)
4234 std::bad_alloc excep;
4244 void deallocate(pointer p, size_type)
4246 CL_(clSVMFree)(context_(), p);
4253 size_type
max_size() const noexcept
4255 size_type maxSize = std::numeric_limits<size_type>::max() /
sizeof(T);
4257 for (
const Device &d : context_.
getInfo<CL_CONTEXT_DEVICES>()) {
4260 static_cast<size_type
>(d.getInfo<CL_DEVICE_MAX_MEM_ALLOC_SIZE>()));
4266 template<
class U,
class... Args >
4267 void construct(U* p, Args&&... args)
4281 inline bool operator==(SVMAllocator
const& rhs)
4283 return (context_==rhs.context_);
4293template<
class SVMTrait>
4296 typedef void value_type;
4297 typedef value_type* pointer;
4298 typedef const value_type* const_pointer;
4300 template<
typename U>
4303 typedef SVMAllocator<U, SVMTrait> other;
4306 template<
typename U,
typename V>
4307 friend class SVMAllocator;
4310#if !defined(CL_HPP_NO_STD_UNIQUE_PTR)
4313 template<
class Alloc>
4320 typedef typename std::allocator_traits<Alloc>::pointer pointer;
4322 Deleter(
const Alloc &alloc, size_type copies) : alloc_{ alloc }, copies_{ copies }
4326 void operator()(pointer ptr)
const {
4327 Alloc tmpAlloc{ alloc_ };
4328 std::allocator_traits<Alloc>::destroy(tmpAlloc, std::addressof(*ptr));
4329 std::allocator_traits<Alloc>::deallocate(tmpAlloc, ptr, copies_);
4340template <
class T,
class Alloc,
class... Args>
4341cl::pointer<T, detail::Deleter<Alloc>>
allocate_pointer(
const Alloc &alloc_, Args&&... args)
4343 Alloc alloc(alloc_);
4344 static const size_type copies = 1;
4349 T* tmp = std::allocator_traits<Alloc>::allocate(alloc, copies);
4351#if defined(CL_HPP_ENABLE_EXCEPTIONS)
4352 std::bad_alloc excep;
4359#if defined(CL_HPP_ENABLE_EXCEPTIONS)
4363 std::allocator_traits<Alloc>::construct(
4365 std::addressof(*tmp),
4366 std::forward<Args>(args)...);
4370#if defined(CL_HPP_ENABLE_EXCEPTIONS)
4371 catch (std::bad_alloc&)
4373 std::allocator_traits<Alloc>::deallocate(alloc, tmp, copies);
4379template<
class T,
class SVMTrait,
class... Args >
4380cl::pointer<T, detail::Deleter<SVMAllocator<T, SVMTrait>>> allocate_svm(Args... args)
4382 SVMAllocator<T, SVMTrait> alloc;
4386template<
class T,
class SVMTrait,
class... Args >
4387cl::pointer<T, detail::Deleter<SVMAllocator<T, SVMTrait>>> allocate_svm(
const cl::Context &c, Args... args)
4398using coarse_svm_vector = vector<T, cl::SVMAllocator<int, cl::SVMTraitCoarse<>>>;
4404using fine_svm_vector = vector<T, cl::SVMAllocator<int, cl::SVMTraitFine<>>>;
4410using atomic_svm_vector = vector<T, cl::SVMAllocator<int, cl::SVMTraitAtomic<>>>;
4436 void* host_ptr =
nullptr,
4437 cl_int* err =
nullptr)
4440 object_ = CL_(clCreateBuffer)(context(), flags, size, host_ptr, &error);
4442 detail::errHandler(error, __CREATE_BUFFER_ERR);
4443 if (err !=
nullptr) {
4448#if CL_HPP_TARGET_OPENCL_VERSION >= 300
4461 const vector<cl_mem_properties>& properties,
4464 void* host_ptr =
nullptr,
4465 cl_int* err =
nullptr)
4469 object_ = CL_(clCreateBufferWithProperties)(
4471 properties.empty() ? nullptr : properties.data(),
4472 flags, size, host_ptr, &error);
4474 detail::errHandler(error, __CREATE_BUFFER_ERR);
4475 if (err !=
nullptr) {
4493 void* host_ptr =
nullptr,
4494 cl_int* err =
nullptr) :
Buffer(
Context::getDefault(err), flags, size, host_ptr, err) { }
4496#if CL_HPP_TARGET_OPENCL_VERSION >= 300
4510 const vector<cl_mem_properties>& properties,
4513 void* host_ptr =
nullptr,
4514 cl_int* err =
nullptr) :
Buffer(
Context::getDefault(err), properties, flags, size, host_ptr, err) { }
4522 template<
typename IteratorType >
4524 IteratorType startIterator,
4525 IteratorType endIterator,
4527 bool useHostPtr =
false,
4528 cl_int* err =
nullptr)
4530 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
4533 cl_mem_flags flags = 0;
4535 flags |= CL_MEM_READ_ONLY;
4538 flags |= CL_MEM_READ_WRITE;
4541 flags |= CL_MEM_USE_HOST_PTR;
4544 size_type size =
sizeof(DataType)*(endIterator - startIterator);
4549 object_ = CL_(clCreateBuffer)(context(), flags, size,
const_cast<DataType*
>(&*startIterator), &error);
4551 object_ = CL_(clCreateBuffer)(context(), flags, size, 0, &error);
4554 detail::errHandler(error, __CREATE_BUFFER_ERR);
4555 if (err !=
nullptr) {
4560 error =
cl::copy(startIterator, endIterator, *
this);
4561 detail::errHandler(error, __CREATE_BUFFER_ERR);
4562 if (err !=
nullptr) {
4573 template<
typename IteratorType >
4574 Buffer(
const Context &context, IteratorType startIterator, IteratorType endIterator,
4575 bool readOnly,
bool useHostPtr =
false, cl_int* err =
nullptr);
4581 template<
typename IteratorType >
4583 bool readOnly,
bool useHostPtr =
false, cl_int* err =
nullptr);
4595 explicit Buffer(
const cl_mem& buffer,
bool retainObject =
false) :
4596 Memory(buffer, retainObject) { }
4609#if CL_HPP_TARGET_OPENCL_VERSION >= 110
4616 cl_buffer_create_type buffer_create_type,
4617 const void * buffer_create_info,
4618 cl_int * err =
nullptr)
4622 result.object_ = CL_(clCreateSubBuffer)(
4629 detail::errHandler(error, __CREATE_SUBBUFFER_ERR);
4630 if (err !=
nullptr) {
4639#if defined (CL_HPP_USE_DX_INTEROP)
4648class BufferD3D10 :
public Buffer
4659 const Context& context,
4661 ID3D10Buffer* bufobj,
4662 cl_int * err =
nullptr) : pfn_clCreateFromD3D10BufferKHR(nullptr)
4664 typedef CL_API_ENTRY cl_mem (CL_API_CALL *PFN_clCreateFromD3D10BufferKHR)(
4665 cl_context context, cl_mem_flags flags, ID3D10Buffer* buffer,
4666 cl_int* errcode_ret);
4667 PFN_clCreateFromD3D10BufferKHR pfn_clCreateFromD3D10BufferKHR;
4668#if CL_HPP_TARGET_OPENCL_VERSION >= 120
4669 vector<cl_context_properties> props = context.getInfo<CL_CONTEXT_PROPERTIES>();
4670 cl_platform platform =
nullptr;
4671 for(
int i = 0; i < props.size(); ++i ) {
4672 if( props[i] == CL_CONTEXT_PLATFORM ) {
4673 platform = props[i+1];
4676 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCreateFromD3D10BufferKHR);
4678#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
4679 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateFromD3D10BufferKHR);
4683 object_ = pfn_clCreateFromD3D10BufferKHR(
4690 detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
4691 if (err !=
nullptr) {
4697 BufferD3D10() : Buffer() { }
4706 explicit BufferD3D10(
const cl_mem& buffer,
bool retainObject =
false) :
4707 Buffer(buffer, retainObject) { }
4713 BufferD3D10& operator = (
const cl_mem& rhs)
4715 Buffer::operator=(rhs);
4741 cl_int * err =
nullptr)
4744 object_ = CL_(clCreateFromGLBuffer)(
4750 detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
4751 if (err !=
nullptr) {
4766 explicit BufferGL(
const cl_mem& buffer,
bool retainObject =
false) :
4767 Buffer(buffer, retainObject) { }
4782 cl_gl_object_type *type,
4783 cl_GLuint * gl_object_name)
4785 return detail::errHandler(
4786 CL_(clGetGLObjectInfo)(object_,type,gl_object_name),
4787 __GET_GL_OBJECT_INFO_ERR);
4811 cl_int * err =
nullptr)
4814 object_ = CL_(clCreateFromGLRenderbuffer)(
4820 detail::errHandler(error, __CREATE_GL_RENDER_BUFFER_ERR);
4821 if (err !=
nullptr) {
4836 explicit BufferRenderGL(
const cl_mem& buffer,
bool retainObject =
false) :
4837 Buffer(buffer, retainObject) { }
4852 cl_gl_object_type *type,
4853 cl_GLuint * gl_object_name)
4855 return detail::errHandler(
4856 CL_(clGetGLObjectInfo)(object_,type,gl_object_name),
4857 __GET_GL_OBJECT_INFO_ERR);
4880 explicit Image(
const cl_mem& image,
bool retainObject =
false) :
4881 Memory(image, retainObject) { }
4896 template <
typename T>
4897 cl_int
getImageInfo(cl_image_info name, T* param)
const
4899 return detail::errHandler(
4900 detail::getInfo(CL_(clGetImageInfo), object_, name, param),
4901 __GET_IMAGE_INFO_ERR);
4905 template <cl_image_info name>
typename
4910 detail::cl_image_info, name>::param_type param{};
4912 if (err !=
nullptr) {
4919#if CL_HPP_TARGET_OPENCL_VERSION >= 120
4938 void* host_ptr =
nullptr,
4939 cl_int* err =
nullptr)
4943 cl_image_desc desc = {};
4944 desc.image_type = CL_MEM_OBJECT_IMAGE1D;
4945 desc.image_width = width;
4947 object_ = CL_(clCreateImage)(
4955 detail::errHandler(error, __CREATE_IMAGE_ERR);
4956 if (err !=
nullptr) {
4964#if CL_HPP_TARGET_OPENCL_VERSION >= 300
4975 Image1D(
const Context &context,
const vector<cl_mem_properties> &properties,
4976 cl_mem_flags flags,
ImageFormat format, size_type width,
4977 void *host_ptr =
nullptr, cl_int *err =
nullptr)
4981 cl_image_desc desc = {};
4982 desc.image_type = CL_MEM_OBJECT_IMAGE1D;
4983 desc.image_width = width;
4985 object_ = CL_(clCreateImageWithProperties)(
4987 properties.empty() ? nullptr : properties.data(),
4988 flags, &format, &desc, host_ptr, &error);
4990 detail::errHandler(error, __CREATE_IMAGE_ERR);
4991 if (err !=
nullptr) {
5004 explicit Image1D(
const cl_mem& image1D,
bool retainObject =
false) :
5005 Image(image1D, retainObject) { }
5023class Image1DBuffer :
public Image
5032 cl_int* err =
nullptr)
5036 cl_image_desc desc = {};
5037 desc.image_type = CL_MEM_OBJECT_IMAGE1D_BUFFER;
5038 desc.image_width = width;
5039 desc.buffer = buffer();
5041 object_ = CL_(clCreateImage)(
5049 detail::errHandler(error, __CREATE_IMAGE_ERR);
5050 if (err !=
nullptr) {
5057#if CL_HPP_TARGET_OPENCL_VERSION >= 300
5067 Image1DBuffer(
const Context &context,
5068 const vector<cl_mem_properties> &properties,
5069 cl_mem_flags flags,
ImageFormat format, size_type width,
5070 const Buffer &buffer, cl_int *err =
nullptr)
5074 cl_image_desc desc = {};
5075 desc.image_type = CL_MEM_OBJECT_IMAGE1D_BUFFER;
5076 desc.image_width = width;
5077 desc.buffer = buffer();
5079 object_ = CL_(clCreateImageWithProperties)(
5081 properties.empty() ? nullptr : properties.data(),
5082 flags, &format, &desc,
nullptr, &error);
5084 detail::errHandler(error, __CREATE_IMAGE_ERR);
5085 if (err !=
nullptr) {
5098 explicit Image1DBuffer(
const cl_mem& image1D,
bool retainObject =
false) :
5099 Image(image1D, retainObject) { }
5111class Image1DArray :
public Image
5118 size_type arraySize,
5121 void* host_ptr =
nullptr,
5122 cl_int* err =
nullptr)
5126 cl_image_desc desc = {};
5127 desc.image_type = CL_MEM_OBJECT_IMAGE1D_ARRAY;
5128 desc.image_width = width;
5129 desc.image_array_size = arraySize;
5130 desc.image_row_pitch = rowPitch;
5132 object_ = CL_(clCreateImage)(
5140 detail::errHandler(error, __CREATE_IMAGE_ERR);
5141 if (err !=
nullptr) {
5148#if CL_HPP_TARGET_OPENCL_VERSION >= 300
5159 Image1DArray(
const Context &context,
5160 const vector<cl_mem_properties> &properties,
5161 cl_mem_flags flags,
ImageFormat format, size_type arraySize,
5162 size_type width, size_type rowPitch = 0,
5163 void *host_ptr =
nullptr, cl_int *err =
nullptr)
5167 cl_image_desc desc = {};
5168 desc.image_type = CL_MEM_OBJECT_IMAGE1D_ARRAY;
5169 desc.image_width = width;
5170 desc.image_array_size = arraySize;
5171 desc.image_row_pitch = rowPitch;
5173 object_ = CL_(clCreateImageWithProperties)(
5175 properties.empty() ? nullptr : properties.data(),
5176 flags, &format, &desc, host_ptr, &error);
5178 detail::errHandler(error, __CREATE_IMAGE_ERR);
5179 if (err !=
nullptr) {
5192 explicit Image1DArray(
const cl_mem& imageArray,
bool retainObject =
false) :
5193 Image(imageArray, retainObject) { }
5226 size_type row_pitch = 0,
5227 void* host_ptr =
nullptr,
5228 cl_int* err =
nullptr)
5231 bool useCreateImage;
5233#if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
5236 cl_uint version = detail::getContextPlatformVersion(context());
5237 useCreateImage = (version >= 0x10002);
5239#elif CL_HPP_TARGET_OPENCL_VERSION >= 120
5240 useCreateImage =
true;
5242 useCreateImage =
false;
5245#if CL_HPP_TARGET_OPENCL_VERSION >= 120
5248 cl_image_desc desc = {};
5249 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
5250 desc.image_width = width;
5251 desc.image_height = height;
5252 desc.image_row_pitch = row_pitch;
5254 object_ = CL_(clCreateImage)(
5262 detail::errHandler(error, __CREATE_IMAGE_ERR);
5263 if (err !=
nullptr) {
5268#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
5269 if (!useCreateImage)
5271 object_ = CL_(clCreateImage2D)(
5272 context(), flags,&format, width, height, row_pitch, host_ptr, &error);
5274 detail::errHandler(error, __CREATE_IMAGE2D_ERR);
5275 if (err !=
nullptr) {
5282#if CL_HPP_TARGET_OPENCL_VERSION >= 120
5294 const Buffer &sourceBuffer,
5297 size_type row_pitch = 0,
5298 cl_int* err =
nullptr)
5302 cl_image_desc desc = {};
5303 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
5304 desc.image_width = width;
5305 desc.image_height = height;
5306 desc.image_row_pitch = row_pitch;
5307 desc.buffer = sourceBuffer();
5309 object_ = CL_(clCreateImage)(
5317 detail::errHandler(error, __CREATE_IMAGE_ERR);
5318 if (err !=
nullptr) {
5324#if CL_HPP_TARGET_OPENCL_VERSION >= 200
5339 cl_channel_order order,
5340 const Image &sourceImage,
5341 cl_int* err =
nullptr)
5346 size_type sourceWidth =
5348 size_type sourceHeight =
5350 size_type sourceRowPitch =
5352 cl_uint sourceNumMIPLevels =
5354 cl_uint sourceNumSamples =
5356 cl_image_format sourceFormat =
5361 sourceFormat.image_channel_order = order;
5363 cl_image_desc desc = {};
5364 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
5365 desc.image_width = sourceWidth;
5366 desc.image_height = sourceHeight;
5367 desc.image_row_pitch = sourceRowPitch;
5368 desc.num_mip_levels = sourceNumMIPLevels;
5369 desc.num_samples = sourceNumSamples;
5370 desc.buffer = sourceImage();
5372 object_ = CL_(clCreateImage)(
5380 detail::errHandler(error, __CREATE_IMAGE_ERR);
5381 if (err !=
nullptr) {
5387#if CL_HPP_TARGET_OPENCL_VERSION >= 300
5398 Image2D(
const Context &context,
const vector<cl_mem_properties> &properties,
5399 cl_mem_flags flags,
ImageFormat format, size_type width,
5400 size_type height, size_type row_pitch = 0,
void *host_ptr =
nullptr,
5401 cl_int *err =
nullptr)
5405 cl_image_desc desc = {};
5406 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
5407 desc.image_width = width;
5408 desc.image_height = height;
5409 desc.image_row_pitch = row_pitch;
5411 object_ = CL_(clCreateImageWithProperties)(
5413 properties.empty() ? nullptr : properties.data(),
5414 flags, &format, &desc, host_ptr, &error);
5416 detail::errHandler(error, __CREATE_IMAGE_ERR);
5417 if (err !=
nullptr) {
5431 Image2D(
const Context &context,
const vector<cl_mem_properties> &properties,
5433 size_type width, size_type height, size_type row_pitch = 0,
5434 cl_int *err =
nullptr)
5438 cl_image_desc desc = {};
5439 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
5440 desc.image_width = width;
5441 desc.image_height = height;
5442 desc.image_row_pitch = row_pitch;
5443 desc.buffer = buffer();
5445 object_ = CL_(clCreateImageWithProperties)(
5447 properties.empty() ? nullptr : properties.data(),
5448 flags, &format, &desc,
nullptr, &error);
5450 detail::errHandler(error, __CREATE_IMAGE_ERR);
5451 if (err !=
nullptr) {
5468 explicit Image2D(
const cl_mem& image2D,
bool retainObject =
false) :
5469 Image(image2D, retainObject) { }
5483#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
5507 cl_int * err =
nullptr)
5510 object_ = CL_(clCreateFromGLTexture2D)(
5518 detail::errHandler(error, __CREATE_GL_TEXTURE_2D_ERR);
5519 if (err !=
nullptr) {
5535 explicit Image2DGL(
const cl_mem& image,
bool retainObject =
false) :
5536 Image2D(image, retainObject) { }
5542 Image2DGL& operator = (
const cl_mem& rhs)
5550} CL_API_SUFFIX__VERSION_1_1_DEPRECATED;
5553#if CL_HPP_TARGET_OPENCL_VERSION >= 120
5557class Image2DArray :
public Image
5564 size_type arraySize,
5568 size_type slicePitch,
5569 void* host_ptr =
nullptr,
5570 cl_int* err =
nullptr)
5574 cl_image_desc desc = {};
5575 desc.image_type = CL_MEM_OBJECT_IMAGE2D_ARRAY;
5576 desc.image_width = width;
5577 desc.image_height = height;
5578 desc.image_array_size = arraySize;
5579 desc.image_row_pitch = rowPitch;
5580 desc.image_slice_pitch = slicePitch;
5582 object_ = CL_(clCreateImage)(
5590 detail::errHandler(error, __CREATE_IMAGE_ERR);
5591 if (err !=
nullptr) {
5596#if CL_HPP_TARGET_OPENCL_VERSION >= 300
5607 Image2DArray(
const Context &context,
5608 const vector<cl_mem_properties> &properties,
5609 cl_mem_flags flags,
ImageFormat format, size_type arraySize,
5610 size_type width, size_type height, size_type rowPitch = 0,
5611 size_type slicePitch = 0,
void *host_ptr =
nullptr,
5612 cl_int *err =
nullptr)
5616 cl_image_desc desc = {};
5617 desc.image_type = CL_MEM_OBJECT_IMAGE2D_ARRAY;
5618 desc.image_width = width;
5619 desc.image_height = height;
5620 desc.image_array_size = arraySize;
5621 desc.image_row_pitch = rowPitch;
5622 desc.image_slice_pitch = slicePitch;
5624 object_ = CL_(clCreateImageWithProperties)(
5626 properties.empty() ? nullptr : properties.data(),
5627 flags, &format, &desc, host_ptr, &error);
5629 detail::errHandler(error, __CREATE_IMAGE_ERR);
5630 if (err !=
nullptr) {
5645 explicit Image2DArray(
const cl_mem& imageArray,
bool retainObject =
false) :
Image(imageArray, retainObject) { }
5676 size_type row_pitch = 0,
5677 size_type slice_pitch = 0,
5678 void* host_ptr =
nullptr,
5679 cl_int* err =
nullptr)
5682 bool useCreateImage;
5684#if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
5687 cl_uint version = detail::getContextPlatformVersion(context());
5688 useCreateImage = (version >= 0x10002);
5690#elif CL_HPP_TARGET_OPENCL_VERSION >= 120
5691 useCreateImage =
true;
5693 useCreateImage =
false;
5696#if CL_HPP_TARGET_OPENCL_VERSION >= 120
5699 cl_image_desc desc = {};
5700 desc.image_type = CL_MEM_OBJECT_IMAGE3D;
5701 desc.image_width = width;
5702 desc.image_height = height;
5703 desc.image_depth = depth;
5704 desc.image_row_pitch = row_pitch;
5705 desc.image_slice_pitch = slice_pitch;
5707 object_ = CL_(clCreateImage)(
5715 detail::errHandler(error, __CREATE_IMAGE_ERR);
5716 if (err !=
nullptr) {
5721#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
5722 if (!useCreateImage)
5724 object_ = CL_(clCreateImage3D)(
5725 context(), flags, &format, width, height, depth, row_pitch,
5726 slice_pitch, host_ptr, &error);
5728 detail::errHandler(error, __CREATE_IMAGE3D_ERR);
5729 if (err !=
nullptr) {
5736#if CL_HPP_TARGET_OPENCL_VERSION >= 300
5747 Image3D(
const Context &context,
const vector<cl_mem_properties> &properties,
5748 cl_mem_flags flags,
ImageFormat format, size_type width,
5749 size_type height, size_type depth, size_type row_pitch = 0,
5750 size_type slice_pitch = 0,
void *host_ptr =
nullptr,
5751 cl_int *err =
nullptr)
5755 cl_image_desc desc = {};
5756 desc.image_type = CL_MEM_OBJECT_IMAGE3D;
5757 desc.image_width = width;
5758 desc.image_height = height;
5759 desc.image_depth = depth;
5760 desc.image_row_pitch = row_pitch;
5761 desc.image_slice_pitch = slice_pitch;
5763 object_ = CL_(clCreateImageWithProperties)(
5765 properties.empty() ? nullptr : properties.data(),
5766 flags, &format, &desc, host_ptr, &error);
5768 detail::errHandler(error, __CREATE_IMAGE_ERR);
5769 if (err !=
nullptr) {
5785 explicit Image3D(
const cl_mem& image3D,
bool retainObject =
false) :
5786 Image(image3D, retainObject) { }
5800#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
5823 cl_int * err =
nullptr)
5826 object_ = CL_(clCreateFromGLTexture3D)(
5834 detail::errHandler(error, __CREATE_GL_TEXTURE_3D_ERR);
5835 if (err !=
nullptr) {
5850 explicit Image3DGL(
const cl_mem& image,
bool retainObject =
false) :
5851 Image3D(image, retainObject) { }
5866#if CL_HPP_TARGET_OPENCL_VERSION >= 120
5873class ImageGL :
public Image
5882 cl_int * err =
nullptr)
5885 object_ = CL_(clCreateFromGLTexture)(
5893 detail::errHandler(error, __CREATE_GL_TEXTURE_ERR);
5894 if (err !=
nullptr) {
5899 ImageGL() :
Image() { }
5908 explicit ImageGL(
const cl_mem& image,
bool retainObject =
false) :
5909 Image(image, retainObject) { }
5911 ImageGL& operator = (
const cl_mem& rhs)
5922#if CL_HPP_TARGET_OPENCL_VERSION >= 200
5944 cl_uint packet_size,
5945 cl_uint max_packets,
5946 cl_int* err =
nullptr)
5950 cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS;
5951 object_ = CL_(clCreatePipe)(context(), flags, packet_size, max_packets,
nullptr, &error);
5953 detail::errHandler(error, __CREATE_PIPE_ERR);
5954 if (err !=
nullptr) {
5968 cl_uint packet_size,
5969 cl_uint max_packets,
5970 cl_int* err =
nullptr)
5976 cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS;
5977 object_ = CL_(clCreatePipe)(context(), flags, packet_size, max_packets,
nullptr, &error);
5979 detail::errHandler(error, __CREATE_PIPE_ERR);
5980 if (err !=
nullptr) {
5995 explicit Pipe(
const cl_mem& pipe,
bool retainObject =
false) :
5996 Memory(pipe, retainObject) { }
6011 template <
typename T>
6012 cl_int
getInfo(cl_pipe_info name, T* param)
const
6014 return detail::errHandler(
6015 detail::getInfo(CL_(clGetPipeInfo), object_, name, param),
6016 __GET_PIPE_INFO_ERR);
6020 template <cl_pipe_info name>
typename
6022 getInfo(cl_int* err =
nullptr)
const
6025 detail::cl_pipe_info, name>::param_type param{};
6026 cl_int result =
getInfo(name, ¶m);
6027 if (err !=
nullptr) {
6056 cl_bool normalized_coords,
6057 cl_addressing_mode addressing_mode,
6058 cl_filter_mode filter_mode,
6059 cl_int* err =
nullptr)
6063#if CL_HPP_TARGET_OPENCL_VERSION >= 200
6064 cl_sampler_properties sampler_properties[] = {
6065 CL_SAMPLER_NORMALIZED_COORDS, normalized_coords,
6066 CL_SAMPLER_ADDRESSING_MODE, addressing_mode,
6067 CL_SAMPLER_FILTER_MODE, filter_mode,
6069 object_ = CL_(clCreateSamplerWithProperties)(
6074 detail::errHandler(error, __CREATE_SAMPLER_WITH_PROPERTIES_ERR);
6075 if (err !=
nullptr) {
6079 object_ = CL_(clCreateSampler)(
6086 detail::errHandler(error, __CREATE_SAMPLER_ERR);
6087 if (err !=
nullptr) {
6101 explicit Sampler(
const cl_sampler& sampler,
bool retainObject =
false) :
6102 detail::Wrapper<cl_type>(sampler, retainObject) { }
6111 detail::Wrapper<cl_type>::operator=(rhs);
6118 template <
typename T>
6119 cl_int
getInfo(cl_sampler_info name, T* param)
const
6121 return detail::errHandler(
6122 detail::getInfo(CL_(clGetSamplerInfo), object_, name, param),
6123 __GET_SAMPLER_INFO_ERR);
6127 template <cl_sampler_info name>
typename
6129 getInfo(cl_int* err =
nullptr)
const
6132 detail::cl_sampler_info, name>::param_type param{};
6133 cl_int result =
getInfo(name, ¶m);
6134 if (err !=
nullptr) {
6150 size_type sizes_[3];
6151 cl_uint dimensions_;
6173 NDRange(size_type size0, size_type size1)
6182 NDRange(size_type size0, size_type size1, size_type size2)
6203 operator const size_type*()
const {
6215 size_type
size()
const
6217 return dimensions_*
sizeof(size_type);
6225 const size_type* get()
const
6232static const NDRange NullRange;
6242template <
typename T,
class Enable =
void>
6247template <
typename T>
6248struct KernelArgumentHandler<T, typename std::enable_if<!std::is_base_of<cl::Memory, T>::value>::type>
6250 static size_type size(
const T&) {
return sizeof(T); }
6251 static const T* ptr(
const T& value) {
return &value; }
6256template <
typename T>
6257struct KernelArgumentHandler<T, typename std::enable_if<std::is_base_of<cl::Memory, T>::value>::type>
6259 static size_type size(
const T&) {
return sizeof(cl_mem); }
6260 static const cl_mem* ptr(
const T& value) {
return &(value()); }
6268 static size_type size(
const LocalSpaceArg& value) {
return value.size_; }
6269 static const void* ptr(
const LocalSpaceArg&) {
return nullptr; }
6279Local(size_type size)
6296 inline Kernel(
const Program& program,
const string& name, cl_int* err =
nullptr);
6297 inline Kernel(
const Program& program,
const char* name, cl_int* err =
nullptr);
6310 explicit Kernel(
const cl_kernel& kernel,
bool retainObject =
false) :
6311 detail::Wrapper<cl_type>(kernel, retainObject) { }
6320 detail::Wrapper<cl_type>::operator=(rhs);
6327 template <
typename T>
6328 cl_int getInfo(cl_kernel_info name, T* param)
const
6330 return detail::errHandler(
6331 detail::getInfo(CL_(clGetKernelInfo), object_, name, param),
6332 __GET_KERNEL_INFO_ERR);
6335 template <cl_kernel_info name>
typename
6336 detail::param_traits<detail::cl_kernel_info, name>::param_type
6337 getInfo(cl_int* err =
nullptr)
const
6339 typename detail::param_traits<
6340 detail::cl_kernel_info, name>::param_type param{};
6341 cl_int result = getInfo(name, ¶m);
6342 if (err !=
nullptr) {
6348#if CL_HPP_TARGET_OPENCL_VERSION >= 120
6349 template <
typename T>
6350 cl_int getArgInfo(cl_uint argIndex, cl_kernel_arg_info name, T* param)
const
6352 return detail::errHandler(
6353 detail::getInfo(CL_(clGetKernelArgInfo), object_, argIndex, name, param),
6354 __GET_KERNEL_ARG_INFO_ERR);
6357 template <cl_kernel_arg_info name>
typename
6358 detail::param_traits<detail::cl_kernel_arg_info, name>::param_type
6359 getArgInfo(cl_uint argIndex, cl_int* err =
nullptr)
const
6361 typename detail::param_traits<
6362 detail::cl_kernel_arg_info, name>::param_type param{};
6363 cl_int result = getArgInfo(argIndex, name, ¶m);
6364 if (err !=
nullptr) {
6371 template <
typename T>
6372 cl_int getWorkGroupInfo(
6373 const Device& device, cl_kernel_work_group_info name, T* param)
const
6375 return detail::errHandler(
6377 CL_(clGetKernelWorkGroupInfo), object_, device(), name, param),
6378 __GET_KERNEL_WORK_GROUP_INFO_ERR);
6381 template <cl_kernel_work_group_info name>
typename
6382 detail::param_traits<detail::cl_kernel_work_group_info, name>::param_type
6383 getWorkGroupInfo(
const Device& device, cl_int* err =
nullptr)
const
6385 typename detail::param_traits<
6386 detail::cl_kernel_work_group_info, name>::param_type param{};
6387 cl_int result = getWorkGroupInfo(device, name, ¶m);
6388 if (err !=
nullptr) {
6394#if defined(CL_HPP_USE_CL_SUB_GROUPS_KHR) || CL_HPP_TARGET_OPENCL_VERSION >= 210
6395 cl_int getSubGroupInfo(
const cl::Device &dev, cl_kernel_sub_group_info name,
const cl::NDRange &range, size_type* param)
const
6397#if CL_HPP_TARGET_OPENCL_VERSION >= 210
6399 return detail::errHandler(
6400 CL_(clGetKernelSubGroupInfo)(object_, dev(), name, range.
size(), range.get(),
sizeof(size_type), param,
nullptr),
6401 __GET_KERNEL_SUB_GROUP_INFO_ERR);
6405 typedef clGetKernelSubGroupInfoKHR_fn PFN_clGetKernelSubGroupInfoKHR;
6406 static PFN_clGetKernelSubGroupInfoKHR pfn_clGetKernelSubGroupInfoKHR =
nullptr;
6407 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetKernelSubGroupInfoKHR);
6409 return detail::errHandler(
6410 pfn_clGetKernelSubGroupInfoKHR(object_, dev(), name, range.
size(), range.get(),
sizeof(size_type), param,
nullptr),
6411 __GET_KERNEL_SUB_GROUP_INFO_ERR);
6416 template <cl_kernel_sub_group_info name>
6417 size_type getSubGroupInfo(
const cl::Device &dev,
const cl::NDRange &range, cl_int* err =
nullptr)
const
6420 cl_int result = getSubGroupInfo(dev, name, range, ¶m);
6421 if (err !=
nullptr) {
6428#if CL_HPP_TARGET_OPENCL_VERSION >= 200
6431 template<
typename T,
class D>
6432 cl_int
setArg(cl_uint index,
const cl::pointer<T, D> &argPtr)
6434 return detail::errHandler(
6435 CL_(clSetKernelArgSVMPointer)(object_, index, argPtr.get()),
6436 __SET_KERNEL_ARGS_ERR);
6441 template<
typename T,
class Alloc>
6442 cl_int
setArg(cl_uint index,
const cl::vector<T, Alloc> &arg)
6444 return detail::errHandler(
6445 CL_(clSetKernelArgSVMPointer)(object_, index,
6446 arg.empty() ?
nullptr : arg.data()),
6447 __SET_KERNEL_ARGS_ERR);
6452 template<
typename T>
6453 typename std::enable_if<std::is_pointer<T>::value, cl_int>::type
6454 setArg(cl_uint index,
const T argPtr)
6456 return detail::errHandler(
6457 CL_(clSetKernelArgSVMPointer)(object_, index, argPtr),
6458 __SET_KERNEL_ARGS_ERR);
6464 template <
typename T>
6465 typename std::enable_if<!std::is_pointer<T>::value, cl_int>::type
6466 setArg(cl_uint index,
const T &value)
6468 return detail::errHandler(
6469 CL_(clSetKernelArg)(
6474 __SET_KERNEL_ARGS_ERR);
6477 cl_int
setArg(cl_uint index, size_type size,
const void* argPtr)
6479 return detail::errHandler(
6480 CL_(clSetKernelArg)(object_, index, size, argPtr),
6481 __SET_KERNEL_ARGS_ERR);
6484#if CL_HPP_TARGET_OPENCL_VERSION >= 200
6491 return detail::errHandler(
6492 CL_(clSetKernelExecInfo)(
6494 CL_KERNEL_EXEC_INFO_SVM_PTRS,
6495 sizeof(
void*) * pointerList.size(),
6496 pointerList.empty() ?
nullptr : pointerList.data()));
6503 template<
int ArrayLength>
6504 cl_int
setSVMPointers(
const std::array<void*, ArrayLength> &pointerList)
6506 return detail::errHandler(
6507 CL_(clSetKernelExecInfo)(
6509 CL_KERNEL_EXEC_INFO_SVM_PTRS,
6510 sizeof(
void*) * pointerList.size(),
6511 pointerList.empty() ?
nullptr : pointerList.data()));
6527 cl_bool svmEnabled_ = svmEnabled ? CL_TRUE : CL_FALSE;
6528 return detail::errHandler(
6529 CL_(clSetKernelExecInfo)(
6531 CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM,
6538 template<
int index,
int ArrayLength,
class D,
typename T0,
typename T1,
typename... Ts>
6539 void setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList,
const pointer<T0, D> &t0,
const pointer<T1, D> &t1, Ts & ... ts)
6541 pointerList[index] =
static_cast<void*
>(t0.get());
6542 setSVMPointersHelper<index + 1, ArrayLength>(pointerList, t1, ts...);
6545 template<
int index,
int ArrayLength,
typename T0,
typename T1,
typename... Ts>
6546 typename std::enable_if<std::is_pointer<T0>::value,
void>::type
6547 setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList, T0 t0, T1 t1, Ts... ts)
6549 pointerList[index] =
static_cast<void*
>(t0);
6550 setSVMPointersHelper<index + 1, ArrayLength>(pointerList, t1, ts...);
6553 template<
int index,
int ArrayLength,
typename T0,
class D>
6554 void setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList,
const pointer<T0, D> &t0)
6556 pointerList[index] =
static_cast<void*
>(t0.get());
6560 template<
int index,
int ArrayLength,
typename T0>
6561 typename std::enable_if<std::is_pointer<T0>::value,
void>::type
6562 setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList, T0 t0)
6564 pointerList[index] =
static_cast<void*
>(t0);
6567 template<
typename T0,
typename... Ts>
6570 std::array<
void*, 1 +
sizeof...(Ts)> pointerList;
6572 setSVMPointersHelper<0, 1 +
sizeof...(Ts)>(pointerList, t0, ts...);
6573 return detail::errHandler(
6574 CL_(clSetKernelExecInfo)(
6576 CL_KERNEL_EXEC_INFO_SVM_PTRS,
6577 sizeof(
void*) * (1 +
sizeof...(Ts)),
6578 pointerList.data()));
6581 template<
typename T>
6582 cl_int setExecInfo(cl_kernel_exec_info param_name,
const T& val)
6584 return detail::errHandler(
6585 CL_(clSetKernelExecInfo)(
6592 template<cl_kernel_exec_info name>
6593 cl_int setExecInfo(
typename detail::param_traits<detail::cl_kernel_exec_info, name>::param_type& val)
6595 return setExecInfo(name, val);
6599#if CL_HPP_TARGET_OPENCL_VERSION >= 210
6608 Kernel retValue(CL_(clCloneKernel)(this->get(), &error));
6610 detail::errHandler(error, __CLONE_KERNEL_ERR);
6622#if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6623 typedef vector<vector<unsigned char>> Binaries;
6624 typedef vector<string> Sources;
6626 typedef vector<std::pair<const void*, size_type> > Binaries;
6627 typedef vector<std::pair<const char*, size_type> > Sources;
6631 const string& source,
6633 cl_int* err =
nullptr)
6637 const char * strings = source.c_str();
6638 const size_type length = source.size();
6642 object_ = CL_(clCreateProgramWithSource)(
6643 context(), (cl_uint)1, &strings, &length, &error);
6645 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6647 if (error == CL_SUCCESS && build) {
6649 error = CL_(clBuildProgram)(
6653#if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6661 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6664 if (err !=
nullptr) {
6671 const string& source,
6673 cl_int* err =
nullptr)
6677 const char * strings = source.c_str();
6678 const size_type length = source.size();
6680 object_ = CL_(clCreateProgramWithSource)(
6681 context(), (cl_uint)1, &strings, &length, &error);
6683 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6685 if (error == CL_SUCCESS && build) {
6686 error = CL_(clBuildProgram)(
6690#if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6698 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6701 if (err !=
nullptr) {
6711 const Sources& sources,
6712 cl_int* err =
nullptr)
6717 const size_type n = (size_type)sources.size();
6719 vector<size_type> lengths(n);
6720 vector<const char*> strings(n);
6722 for (size_type i = 0; i < n; ++i) {
6723#if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6724 strings[i] = sources[(int)i].data();
6725 lengths[i] = sources[(int)i].length();
6727 strings[i] = sources[(int)i].first;
6728 lengths[i] = sources[(int)i].second;
6732 object_ = CL_(clCreateProgramWithSource)(
6733 context(), (cl_uint)n,
6734 strings.empty() ? nullptr : strings.data(),
6735 lengths.empty() ? nullptr : lengths.data(),
6738 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6739 if (err !=
nullptr) {
6750 const Sources& sources,
6751 cl_int* err =
nullptr)
6755 const size_type n = (size_type)sources.size();
6757 vector<size_type> lengths(n);
6758 vector<const char*> strings(n);
6760 for (size_type i = 0; i < n; ++i) {
6761#if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6762 strings[i] = sources[(int)i].data();
6763 lengths[i] = sources[(int)i].length();
6765 strings[i] = sources[(int)i].first;
6766 lengths[i] = sources[(int)i].second;
6770 object_ = CL_(clCreateProgramWithSource)(
6771 context(), (cl_uint)n,
6772 strings.empty() ? nullptr : strings.data(),
6773 lengths.empty() ? nullptr : lengths.data(),
6776 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6777 if (err !=
nullptr) {
6782#if defined(CL_HPP_USE_IL_KHR) || CL_HPP_TARGET_OPENCL_VERSION >= 210
6789 const vector<char>& IL,
6791 cl_int* err =
nullptr)
6797#if CL_HPP_TARGET_OPENCL_VERSION >= 210
6799 object_ = CL_(clCreateProgramWithIL)(
6800 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6804 typedef clCreateProgramWithILKHR_fn PFN_clCreateProgramWithILKHR;
6805 static PFN_clCreateProgramWithILKHR pfn_clCreateProgramWithILKHR =
nullptr;
6806 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateProgramWithILKHR);
6808 object_ = pfn_clCreateProgramWithILKHR(
6809 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6813 detail::errHandler(error, __CREATE_PROGRAM_WITH_IL_ERR);
6815 if (error == CL_SUCCESS && build) {
6817 error = CL_(clBuildProgram)(
6821#if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6829 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6832 if (err !=
nullptr) {
6845 const vector<char>& IL,
6847 cl_int* err =
nullptr)
6851#if CL_HPP_TARGET_OPENCL_VERSION >= 210
6853 object_ = CL_(clCreateProgramWithIL)(
6854 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6858 typedef clCreateProgramWithILKHR_fn PFN_clCreateProgramWithILKHR;
6859 static PFN_clCreateProgramWithILKHR pfn_clCreateProgramWithILKHR =
nullptr;
6860 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateProgramWithILKHR);
6862 object_ = pfn_clCreateProgramWithILKHR(
6863 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6867 detail::errHandler(error, __CREATE_PROGRAM_WITH_IL_ERR);
6869 if (error == CL_SUCCESS && build) {
6870 error = CL_(clBuildProgram)(
6874#if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6882 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6885 if (err !=
nullptr) {
6912 const vector<Device>& devices,
6913 const Binaries& binaries,
6914 vector<cl_int>* binaryStatus =
nullptr,
6915 cl_int* err =
nullptr)
6919 const size_type numDevices = devices.size();
6922 if(binaries.size() != numDevices) {
6923 error = CL_INVALID_VALUE;
6924 detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
6925 if (err !=
nullptr) {
6931 vector<size_type> lengths(numDevices);
6932 vector<const unsigned char*> images(numDevices);
6933#if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6934 for (size_type i = 0; i < numDevices; ++i) {
6935 images[i] = binaries[i].data();
6936 lengths[i] = binaries[(int)i].size();
6939 for (size_type i = 0; i < numDevices; ++i) {
6940 images[i] = (
const unsigned char*)binaries[i].first;
6941 lengths[i] = binaries[(int)i].second;
6945 vector<cl_device_id> deviceIDs(numDevices);
6946 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6947 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6951 binaryStatus->resize(numDevices);
6954 object_ = CL_(clCreateProgramWithBinary)(
6956 (cl_uint)deviceIDs.size(),
6957 deviceIDs.empty() ? nullptr : deviceIDs.data(),
6958 lengths.empty() ? nullptr : lengths.data(),
6959 images.empty() ? nullptr : images.data(),
6960 (binaryStatus !=
nullptr && numDevices > 0)
6961 ? &binaryStatus->front()
6965 detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
6966 if (err !=
nullptr) {
6972#if CL_HPP_TARGET_OPENCL_VERSION >= 120
6979 const vector<Device>& devices,
6980 const string& kernelNames,
6981 cl_int* err =
nullptr)
6985 size_type numDevices = devices.size();
6986 vector<cl_device_id> deviceIDs(numDevices);
6987 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6988 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6991 object_ = CL_(clCreateProgramWithBuiltInKernels)(
6993 (cl_uint)deviceIDs.size(),
6994 deviceIDs.empty() ? nullptr : deviceIDs.data(),
6995 kernelNames.c_str(),
6998 detail::errHandler(error, __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR);
6999 if (err !=
nullptr) {
7014 explicit Program(
const cl_program& program,
bool retainObject =
false) :
7015 detail::Wrapper<cl_type>(program, retainObject) { }
7017 Program& operator = (
const cl_program& rhs)
7019 detail::Wrapper<cl_type>::operator=(rhs);
7024 const vector<Device>& devices,
7025 const string& options,
7026 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7027 void* data =
nullptr)
const
7029 return build(devices, options.c_str(), notifyFptr, data);
7033 const vector<Device>& devices,
7034 const char* options =
nullptr,
7035 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7036 void* data =
nullptr)
const
7038 size_type numDevices = devices.size();
7039 vector<cl_device_id> deviceIDs(numDevices);
7041 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
7042 deviceIDs[deviceIndex] = (devices[deviceIndex])();
7045 cl_int buildError = CL_(clBuildProgram)(
7047 (cl_uint)deviceIDs.size(),
7048 deviceIDs.empty() ?
nullptr : deviceIDs.data(),
7053 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
7057 const Device& device,
7058 const string& options,
7059 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7060 void* data =
nullptr)
const
7062 return build(device, options.c_str(), notifyFptr, data);
7066 const Device& device,
7067 const char* options =
nullptr,
7068 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7069 void* data =
nullptr)
const
7071 cl_device_id deviceID = device();
7073 cl_int buildError = CL_(clBuildProgram)(
7081 BuildLogType buildLog(0);
7082 buildLog.push_back(std::make_pair(device, getBuildInfo<CL_PROGRAM_BUILD_LOG>(device)));
7083 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, buildLog);
7087 const string& options,
7088 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7089 void* data =
nullptr)
const
7091 return build(options.c_str(), notifyFptr, data);
7095 const char* options =
nullptr,
7096 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7097 void* data =
nullptr)
const
7099 cl_int buildError = CL_(clBuildProgram)(
7107 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
7110#if CL_HPP_TARGET_OPENCL_VERSION >= 120
7112 const string& options,
7113 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7114 void* data =
nullptr)
const
7116 return compile(options.c_str(), notifyFptr, data);
7120 const char* options =
nullptr,
7121 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7122 void* data =
nullptr)
const
7124 cl_int error = CL_(clCompileProgram)(
7134 return detail::buildErrHandler(error, __COMPILE_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
7138 const string& options,
7139 const vector<Program>& inputHeaders,
7140 const vector<string>& headerIncludeNames,
7141 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7142 void* data =
nullptr)
const
7144 return compile(options.c_str(), inputHeaders, headerIncludeNames, notifyFptr, data);
7148 const char* options,
7149 const vector<Program>& inputHeaders,
7150 const vector<string>& headerIncludeNames,
7151 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7152 void* data =
nullptr)
const
7154 static_assert(
sizeof(cl::Program) ==
sizeof(cl_program),
7155 "Size of cl::Program must be equal to size of cl_program");
7157 vector<const char*> headerIncludeNamesCStr;
7158 for(
const string& name: headerIncludeNames) {
7159 headerIncludeNamesCStr.push_back(name.c_str());
7162 cl_int error = CL_(clCompileProgram)(
7167 static_cast<cl_uint
>(inputHeaders.size()),
7168 reinterpret_cast<const cl_program*
>(inputHeaders.empty() ?
nullptr : inputHeaders.data()),
7169 reinterpret_cast<const char**
>(headerIncludeNamesCStr.empty() ?
nullptr : headerIncludeNamesCStr.data()),
7172 return detail::buildErrHandler(error, __COMPILE_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
7176 const string& options,
7177 const vector<Device>& deviceList,
7178 const vector<Program>& inputHeaders = vector<Program>(),
7179 const vector<string>& headerIncludeNames = vector<string>(),
7180 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7181 void* data =
nullptr)
const
7183 return compile(options.c_str(), deviceList, inputHeaders, headerIncludeNames, notifyFptr, data);
7187 const char* options,
7188 const vector<Device>& devices,
7189 const vector<Program>& inputHeaders = vector<Program>(),
7190 const vector<string>& headerIncludeNames = vector<string>(),
7191 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7192 void* data =
nullptr)
const
7194 static_assert(
sizeof(cl::Program) ==
sizeof(cl_program),
7195 "Size of cl::Program must be equal to size of cl_program");
7197 vector<cl_device_id> deviceIDs;
7198 for(
const Device& device: devices) {
7199 deviceIDs.push_back(device());
7202 vector<const char*> headerIncludeNamesCStr;
7203 for(
const string& name: headerIncludeNames) {
7204 headerIncludeNamesCStr.push_back(name.c_str());
7207 cl_int error = CL_(clCompileProgram)(
7209 static_cast<cl_uint
>(deviceIDs.size()),
7210 reinterpret_cast<const cl_device_id*
>(deviceIDs.empty() ?
nullptr : deviceIDs.data()),
7212 static_cast<cl_uint
>(inputHeaders.size()),
7213 reinterpret_cast<const cl_program*
>(inputHeaders.empty() ?
nullptr : inputHeaders.data()),
7214 reinterpret_cast<const char**
>(headerIncludeNamesCStr.empty() ?
nullptr : headerIncludeNamesCStr.data()),
7217 return detail::buildErrHandler(error, __COMPILE_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
7221 template <
typename T>
7222 cl_int getInfo(cl_program_info name, T* param)
const
7224 return detail::errHandler(
7225 detail::getInfo(CL_(clGetProgramInfo), object_, name, param),
7226 __GET_PROGRAM_INFO_ERR);
7229 template <cl_program_info name>
typename
7230 detail::param_traits<detail::cl_program_info, name>::param_type
7231 getInfo(cl_int* err =
nullptr)
const
7233 typename detail::param_traits<
7234 detail::cl_program_info, name>::param_type param{};
7235 cl_int result = getInfo(name, ¶m);
7236 if (err !=
nullptr) {
7242 template <
typename T>
7243 cl_int getBuildInfo(
7244 const Device& device, cl_program_build_info name, T* param)
const
7246 return detail::errHandler(
7248 CL_(clGetProgramBuildInfo), object_, device(), name, param),
7249 __GET_PROGRAM_BUILD_INFO_ERR);
7252 template <cl_program_build_info name>
typename
7253 detail::param_traits<detail::cl_program_build_info, name>::param_type
7254 getBuildInfo(
const Device& device, cl_int* err =
nullptr)
const
7256 typename detail::param_traits<
7257 detail::cl_program_build_info, name>::param_type param{};
7258 cl_int result = getBuildInfo(device, name, ¶m);
7259 if (err !=
nullptr) {
7270 template <cl_program_build_info name>
7271 vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, name>::param_type>>
7272 getBuildInfo(cl_int *err =
nullptr)
const
7274 cl_int result = CL_SUCCESS;
7276 auto devs = getInfo<CL_PROGRAM_DEVICES>(&result);
7277 vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, name>::param_type>>
7281 if (result != CL_SUCCESS) {
7282 if (err !=
nullptr) {
7290 detail::cl_program_build_info, name>::param_type param{};
7291 result = getBuildInfo(d, name, ¶m);
7295 if (result != CL_SUCCESS) {
7300 if (err !=
nullptr) {
7303 if (result != CL_SUCCESS) {
7309 cl_int createKernels(vector<Kernel>* kernels)
7312 cl_int err = CL_(clCreateKernelsInProgram)(object_, 0,
nullptr, &numKernels);
7313 if (err != CL_SUCCESS) {
7314 return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
7317 vector<cl_kernel> value(numKernels);
7318 err = CL_(clCreateKernelsInProgram)(
7321 value.empty() ?
nullptr : value.data(),
7323 if (err != CL_SUCCESS) {
7324 return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
7328 kernels->resize(value.size());
7332 for (size_type i = 0; i < value.size(); i++) {
7335 (*kernels)[i] = Kernel(value[i],
false);
7341#if CL_HPP_TARGET_OPENCL_VERSION >= 220
7342#if defined(CL_USE_DEPRECATED_OPENCL_2_2_APIS)
7354 void (CL_CALLBACK * pfn_notify)(cl_program program,
void * user_data),
7355 void * user_data =
nullptr) CL_API_SUFFIX__VERSION_2_2_DEPRECATED
7357 return detail::errHandler(
7358 CL_(clSetProgramReleaseCallback)(
7362 __SET_PROGRAM_RELEASE_CALLBACK_ERR);
7370 template <
typename T>
7371 typename std::enable_if<!std::is_pointer<T>::value, cl_int>::type
7374 return detail::errHandler(
7375 CL_(clSetProgramSpecializationConstant)(
7380 __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR);
7389 return detail::errHandler(
7390 CL_(clSetProgramSpecializationConstant)(
7395 __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR);
7400#if CL_HPP_TARGET_OPENCL_VERSION >= 120
7401inline Program linkProgram(
7402 const Program& input1,
7403 const Program& input2,
7404 const char* options =
nullptr,
7405 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7406 void* data =
nullptr,
7407 cl_int* err =
nullptr)
7409 cl_int error_local = CL_SUCCESS;
7410 cl_program programs[2] = { input1(), input2() };
7413 if(error_local!=CL_SUCCESS) {
7414 detail::errHandler(error_local, __LINK_PROGRAM_ERR);
7417 cl_program prog = CL_(clLinkProgram)(
7428 detail::errHandler(error_local,__COMPILE_PROGRAM_ERR);
7429 if (err !=
nullptr) {
7439 const string& options,
7440 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7441 void* data =
nullptr,
7442 cl_int* err =
nullptr)
7444 return linkProgram(input1, input2, options.c_str(), notifyFptr, data, err);
7448 const vector<Program>& inputPrograms,
7449 const char* options =
nullptr,
7450 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7451 void* data =
nullptr,
7452 cl_int* err =
nullptr)
7454 cl_int error_local = CL_SUCCESS;
7457 static_assert(
sizeof(cl::Program) ==
sizeof(cl_program),
7458 "Size of cl::Program must be equal to size of cl_program");
7460 if(inputPrograms.size() > 0) {
7461 ctx = inputPrograms[0].getInfo<CL_PROGRAM_CONTEXT>(&error_local);
7462 if(error_local!=CL_SUCCESS) {
7463 detail::errHandler(error_local, __LINK_PROGRAM_ERR);
7467 cl_program prog = CL_(clLinkProgram)(
7472 static_cast<cl_uint
>(inputPrograms.size()),
7473 reinterpret_cast<const cl_program *
>(inputPrograms.empty() ?
nullptr : inputPrograms.data()),
7478 detail::errHandler(error_local,__COMPILE_PROGRAM_ERR);
7479 if (err !=
nullptr) {
7487 const vector<Program>& inputPrograms,
7488 const string& options,
7489 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) =
nullptr,
7490 void* data =
nullptr,
7491 cl_int* err =
nullptr)
7493 return linkProgram(inputPrograms, options.c_str(), notifyFptr, data, err);
7499inline cl_int cl::Program::getInfo(cl_program_info name, vector<vector<unsigned char>>* param)
const
7501 if (name != CL_PROGRAM_BINARIES) {
7502 return CL_INVALID_VALUE;
7508 vector<size_type> sizes = getInfo<CL_PROGRAM_BINARY_SIZES>();
7509 size_type numBinaries = sizes.size();
7512 param->resize(numBinaries);
7513 for (size_type i = 0; i < numBinaries; ++i) {
7514 (*param)[i].resize(sizes[i]);
7517 return detail::errHandler(
7518 detail::getInfo(CL_(clGetProgramInfo), object_, name, param),
7519 __GET_PROGRAM_INFO_ERR);
7526inline vector<vector<unsigned char>> cl::Program::getInfo<CL_PROGRAM_BINARIES>(cl_int* err)
const
7528 vector<vector<unsigned char>> binariesVectors;
7530 cl_int result = getInfo(CL_PROGRAM_BINARIES, &binariesVectors);
7531 if (err !=
nullptr) {
7534 return binariesVectors;
7537#if CL_HPP_TARGET_OPENCL_VERSION >= 220
7542 cl_uchar ucValue = value ? CL_UCHAR_MAX : 0;
7543 return detail::errHandler(
7544 CL_(clSetProgramSpecializationConstant)(
7549 __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR);
7557 object_ = CL_(clCreateKernel)(program(), name.c_str(), &error);
7558 detail::errHandler(error, __CREATE_KERNEL_ERR);
7560 if (err !=
nullptr) {
7569 object_ = CL_(clCreateKernel)(program(), name, &error);
7570 detail::errHandler(error, __CREATE_KERNEL_ERR);
7572 if (err !=
nullptr) {
7577#ifdef cl_khr_external_memory
7578enum class ExternalMemoryType : cl_external_memory_handle_type_khr
7581#ifdef cl_khr_external_memory_android_hardware_buffer
7582 AndroidHardwareBuffer = CL_EXTERNAL_MEMORY_HANDLE_ANDROID_HARDWARE_BUFFER_KHR,
7584#ifdef cl_khr_external_memory_opaque_fd
7585 OpaqueFd = CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_FD_KHR,
7587#ifdef cl_khr_external_memory_win32
7588 OpaqueWin32 = CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KHR,
7589 OpaqueWin32Kmt = CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KMT_KHR,
7591#ifdef cl_khr_external_memory_dma_buf
7592 DmaBuf = CL_EXTERNAL_MEMORY_HANDLE_DMA_BUF_KHR,
7597enum class QueueProperties : cl_command_queue_properties
7600 Profiling = CL_QUEUE_PROFILING_ENABLE,
7601 OutOfOrder = CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE,
7604inline QueueProperties operator|(QueueProperties lhs, QueueProperties rhs)
7606 return static_cast<QueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) |
static_cast<cl_command_queue_properties
>(rhs));
7609inline QueueProperties operator&(QueueProperties lhs, QueueProperties rhs)
7611 return static_cast<QueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) &
static_cast<cl_command_queue_properties
>(rhs));
7620 static std::once_flag default_initialized_;
7622 static cl_int default_error_;
7629 static void makeDefault()
7634#if defined(CL_HPP_ENABLE_EXCEPTIONS)
7641 if (error != CL_SUCCESS) {
7642 default_error_ = error;
7646 default_ =
CommandQueue(context, device, 0, &default_error_);
7649#if defined(CL_HPP_ENABLE_EXCEPTIONS)
7650 catch (cl::Error &e) {
7651 default_error_ = e.err();
7661 static void makeDefaultProvided(
const CommandQueue &c) {
7665#ifdef cl_khr_external_memory
7666 static std::once_flag ext_memory_initialized_;
7668 static void initMemoryExtension(
const cl::Device& device)
7670 auto platform = device.
getInfo<CL_DEVICE_PLATFORM>()();
7672 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueAcquireExternalMemObjectsKHR);
7673 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueReleaseExternalMemObjectsKHR);
7675 if ((pfn_clEnqueueAcquireExternalMemObjectsKHR ==
nullptr)
7676 && (pfn_clEnqueueReleaseExternalMemObjectsKHR ==
nullptr))
7678 detail::errHandler(CL_INVALID_VALUE, __ENQUEUE_ACQUIRE_EXTERNAL_MEMORY_ERR);
7684#ifdef CL_HPP_UNIT_TEST_ENABLE
7691 static void unitTestClearDefault() {
7702 cl_command_queue_properties properties,
7703 cl_int* err =
nullptr)
7708 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7710 if (error != CL_SUCCESS) {
7711 if (err !=
nullptr) {
7717 bool useWithProperties;
7719#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7722 cl_uint version = detail::getContextPlatformVersion(context());
7723 useWithProperties = (version >= 0x20000);
7725#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7726 useWithProperties =
true;
7728 useWithProperties =
false;
7731#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7732 if (useWithProperties) {
7733 cl_queue_properties queue_properties[] = {
7734 CL_QUEUE_PROPERTIES, properties, 0 };
7735 if ((properties & CL_QUEUE_ON_DEVICE) == 0) {
7736 object_ = CL_(clCreateCommandQueueWithProperties)(
7737 context(), device(), queue_properties, &error);
7740 error = CL_INVALID_QUEUE_PROPERTIES;
7743 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7744 if (err !=
nullptr) {
7749#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7750 if (!useWithProperties) {
7751 object_ = CL_(clCreateCommandQueue)(
7752 context(), device(), properties, &error);
7754 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7755 if (err !=
nullptr) {
7768 QueueProperties properties,
7769 cl_int* err =
nullptr)
7774 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7776 if (error != CL_SUCCESS) {
7777 if (err !=
nullptr) {
7783 bool useWithProperties;
7785#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7788 cl_uint version = detail::getContextPlatformVersion(context());
7789 useWithProperties = (version >= 0x20000);
7791#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7792 useWithProperties =
true;
7794 useWithProperties =
false;
7797#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7798 if (useWithProperties) {
7799 cl_queue_properties queue_properties[] = {
7800 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
7802 object_ = CL_(clCreateCommandQueueWithProperties)(
7803 context(), device(), queue_properties, &error);
7805 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7806 if (err !=
nullptr) {
7811#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7812 if (!useWithProperties) {
7813 object_ = CL_(clCreateCommandQueue)(
7814 context(), device(),
static_cast<cl_command_queue_properties
>(properties), &error);
7816 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7817 if (err !=
nullptr) {
7832 cl_command_queue_properties properties = 0,
7833 cl_int* err =
nullptr)
7836 bool useWithProperties;
7837 vector<cl::Device> devices;
7838 error = context.
getInfo(CL_CONTEXT_DEVICES, &devices);
7840 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7842 if (error != CL_SUCCESS)
7844 if (err !=
nullptr) {
7850#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7853 cl_uint version = detail::getContextPlatformVersion(context());
7854 useWithProperties = (version >= 0x20000);
7856#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7857 useWithProperties =
true;
7859 useWithProperties =
false;
7862#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7863 if (useWithProperties) {
7864 cl_queue_properties queue_properties[] = {
7865 CL_QUEUE_PROPERTIES, properties, 0 };
7866 if ((properties & CL_QUEUE_ON_DEVICE) == 0) {
7867 object_ = CL_(clCreateCommandQueueWithProperties)(
7868 context(), devices[0](), queue_properties, &error);
7871 error = CL_INVALID_QUEUE_PROPERTIES;
7874 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7875 if (err !=
nullptr) {
7880#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7881 if (!useWithProperties) {
7882 object_ = CL_(clCreateCommandQueue)(
7883 context(), devices[0](), properties, &error);
7885 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7886 if (err !=
nullptr) {
7899 QueueProperties properties,
7900 cl_int* err =
nullptr)
7903 bool useWithProperties;
7904 vector<cl::Device> devices;
7905 error = context.
getInfo(CL_CONTEXT_DEVICES, &devices);
7907 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7909 if (error != CL_SUCCESS)
7911 if (err !=
nullptr) {
7917#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7920 cl_uint version = detail::getContextPlatformVersion(context());
7921 useWithProperties = (version >= 0x20000);
7923#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7924 useWithProperties =
true;
7926 useWithProperties =
false;
7929#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7930 if (useWithProperties) {
7931 cl_queue_properties queue_properties[] = {
7932 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
7933 object_ = CL_(clCreateCommandQueueWithProperties)(
7934 context(), devices[0](), queue_properties, &error);
7936 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7937 if (err !=
nullptr) {
7942#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7943 if (!useWithProperties) {
7944 object_ = CL_(clCreateCommandQueue)(
7945 context(), devices[0](),
static_cast<cl_command_queue_properties
>(properties), &error);
7947 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7948 if (err !=
nullptr) {
7962 cl_command_queue_properties properties = 0,
7963 cl_int* err =
nullptr)
7966 bool useWithProperties;
7968#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7971 cl_uint version = detail::getContextPlatformVersion(context());
7972 useWithProperties = (version >= 0x20000);
7974#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7975 useWithProperties =
true;
7977 useWithProperties =
false;
7980#if CL_HPP_TARGET_OPENCL_VERSION >= 200
7981 if (useWithProperties) {
7982 cl_queue_properties queue_properties[] = {
7983 CL_QUEUE_PROPERTIES, properties, 0 };
7984 object_ = CL_(clCreateCommandQueueWithProperties)(
7985 context(), device(), queue_properties, &error);
7987 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7988 if (err !=
nullptr) {
7993#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7994 if (!useWithProperties) {
7995 object_ = CL_(clCreateCommandQueue)(
7996 context(), device(), properties, &error);
7998 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7999 if (err !=
nullptr) {
8013 QueueProperties properties,
8014 cl_int* err =
nullptr)
8017 bool useWithProperties;
8019#if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
8022 cl_uint version = detail::getContextPlatformVersion(context());
8023 useWithProperties = (version >= 0x20000);
8025#elif CL_HPP_TARGET_OPENCL_VERSION >= 200
8026 useWithProperties =
true;
8028 useWithProperties =
false;
8031#if CL_HPP_TARGET_OPENCL_VERSION >= 200
8032 if (useWithProperties) {
8033 cl_queue_properties queue_properties[] = {
8034 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
8035 object_ = CL_(clCreateCommandQueueWithProperties)(
8036 context(), device(), queue_properties, &error);
8038 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8039 if (err !=
nullptr) {
8044#if CL_HPP_MINIMUM_OPENCL_VERSION < 200
8045 if (!useWithProperties) {
8046 object_ = CL_(clCreateCommandQueue)(
8047 context(), device(),
static_cast<cl_command_queue_properties
>(properties), &error);
8049 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
8050 if (err !=
nullptr) {
8059 std::call_once(default_initialized_, makeDefault);
8060#if CL_HPP_TARGET_OPENCL_VERSION >= 200
8061 detail::errHandler(default_error_, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8063 detail::errHandler(default_error_, __CREATE_COMMAND_QUEUE_ERR);
8065 if (err !=
nullptr) {
8066 *err = default_error_;
8080 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_queue));
8081 detail::errHandler(default_error_);
8094 explicit CommandQueue(
const cl_command_queue& commandQueue,
bool retainObject =
false) :
8095 detail::Wrapper<cl_type>(commandQueue, retainObject) { }
8099 detail::Wrapper<cl_type>::operator=(rhs);
8103 template <
typename T>
8104 cl_int getInfo(cl_command_queue_info name, T* param)
const
8106 return detail::errHandler(
8108 CL_(clGetCommandQueueInfo), object_, name, param),
8109 __GET_COMMAND_QUEUE_INFO_ERR);
8112 template <cl_command_queue_info name>
typename
8113 detail::param_traits<detail::cl_command_queue_info, name>::param_type
8114 getInfo(cl_int* err =
nullptr)
const
8116 typename detail::param_traits<
8117 detail::cl_command_queue_info, name>::param_type param{};
8118 cl_int result = getInfo(name, ¶m);
8119 if (err !=
nullptr) {
8125 cl_int enqueueReadBuffer(
8126 const Buffer& buffer,
8131 const vector<Event>* events =
nullptr,
8132 Event* event =
nullptr)
const
8135 cl_int err = detail::errHandler(
8136 CL_(clEnqueueReadBuffer)(
8137 object_, buffer(), blocking, offset, size,
8139 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8140 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
8141 (event !=
nullptr) ? &tmp :
nullptr),
8142 __ENQUEUE_READ_BUFFER_ERR);
8144 if (event !=
nullptr && err == CL_SUCCESS)
8150 cl_int enqueueWriteBuffer(
8151 const Buffer& buffer,
8156 const vector<Event>* events =
nullptr,
8157 Event* event =
nullptr)
const
8160 cl_int err = detail::errHandler(
8161 CL_(clEnqueueWriteBuffer)(
8162 object_, buffer(), blocking, offset, size,
8164 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8165 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
8166 (event !=
nullptr) ? &tmp :
nullptr),
8167 __ENQUEUE_WRITE_BUFFER_ERR);
8169 if (event !=
nullptr && err == CL_SUCCESS)
8175 cl_int enqueueCopyBuffer(
8178 size_type src_offset,
8179 size_type dst_offset,
8181 const vector<Event>* events =
nullptr,
8182 Event* event =
nullptr)
const
8185 cl_int err = detail::errHandler(
8186 CL_(clEnqueueCopyBuffer)(
8187 object_, src(), dst(), src_offset, dst_offset, size,
8188 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8189 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
8190 (event !=
nullptr) ? &tmp :
nullptr),
8191 __ENQEUE_COPY_BUFFER_ERR);
8193 if (event !=
nullptr && err == CL_SUCCESS)
8198#if CL_HPP_TARGET_OPENCL_VERSION >= 110
8199 cl_int enqueueReadBufferRect(
8200 const Buffer& buffer,
8202 const array<size_type, 3>& buffer_offset,
8203 const array<size_type, 3>& host_offset,
8204 const array<size_type, 3>& region,
8205 size_type buffer_row_pitch,
8206 size_type buffer_slice_pitch,
8207 size_type host_row_pitch,
8208 size_type host_slice_pitch,
8210 const vector<Event>* events =
nullptr,
8211 Event* event =
nullptr)
const
8214 cl_int err = detail::errHandler(
8215 CL_(clEnqueueReadBufferRect)(
8219 buffer_offset.data(),
8227 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8228 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
8229 (event !=
nullptr) ? &tmp :
nullptr),
8230 __ENQUEUE_READ_BUFFER_RECT_ERR);
8232 if (event !=
nullptr && err == CL_SUCCESS)
8238 cl_int enqueueReadBufferRect(
8239 const Buffer& buffer,
8241 const array<size_type, 2>& buffer_offset,
8242 const array<size_type, 2>& host_offset,
8243 const array<size_type, 2>& region,
8244 size_type buffer_row_pitch,
8245 size_type buffer_slice_pitch,
8246 size_type host_row_pitch,
8247 size_type host_slice_pitch,
8249 const vector<Event>* events =
nullptr,
8250 Event* event =
nullptr)
const
8252 return enqueueReadBufferRect(
8255 { buffer_offset[0], buffer_offset[1], 0 },
8256 { host_offset[0], host_offset[1], 0 },
8257 { region[0], region[1], 1 },
8267 cl_int enqueueWriteBufferRect(
8268 const Buffer& buffer,
8270 const array<size_type, 3>& buffer_offset,
8271 const array<size_type, 3>& host_offset,
8272 const array<size_type, 3>& region,
8273 size_type buffer_row_pitch,
8274 size_type buffer_slice_pitch,
8275 size_type host_row_pitch,
8276 size_type host_slice_pitch,
8278 const vector<Event>* events =
nullptr,
8279 Event* event =
nullptr)
const
8282 cl_int err = detail::errHandler(
8283 CL_(clEnqueueWriteBufferRect)(
8287 buffer_offset.data(),
8295 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8296 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
8297 (event !=
nullptr) ? &tmp :
nullptr),
8298 __ENQUEUE_WRITE_BUFFER_RECT_ERR);
8300 if (event !=
nullptr && err == CL_SUCCESS)
8306 cl_int enqueueWriteBufferRect(
8307 const Buffer& buffer,
8309 const array<size_type, 2>& buffer_offset,
8310 const array<size_type, 2>& host_offset,
8311 const array<size_type, 2>& region,
8312 size_type buffer_row_pitch,
8313 size_type buffer_slice_pitch,
8314 size_type host_row_pitch,
8315 size_type host_slice_pitch,
8317 const vector<Event>* events =
nullptr,
8318 Event* event =
nullptr)
const
8320 return enqueueWriteBufferRect(
8323 { buffer_offset[0], buffer_offset[1], 0 },
8324 { host_offset[0], host_offset[1], 0 },
8325 { region[0], region[1], 1 },
8335 cl_int enqueueCopyBufferRect(
8338 const array<size_type, 3>& src_origin,
8339 const array<size_type, 3>& dst_origin,
8340 const array<size_type, 3>& region,
8341 size_type src_row_pitch,
8342 size_type src_slice_pitch,
8343 size_type dst_row_pitch,
8344 size_type dst_slice_pitch,
8345 const vector<Event>* events =
nullptr,
8346 Event* event =
nullptr)
const
8349 cl_int err = detail::errHandler(
8350 CL_(clEnqueueCopyBufferRect)(
8361 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8362 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
8363 (event !=
nullptr) ? &tmp :
nullptr),
8364 __ENQEUE_COPY_BUFFER_RECT_ERR);
8366 if (event !=
nullptr && err == CL_SUCCESS)
8372 cl_int enqueueCopyBufferRect(
8375 const array<size_type, 2>& src_origin,
8376 const array<size_type, 2>& dst_origin,
8377 const array<size_type, 2>& region,
8378 size_type src_row_pitch,
8379 size_type src_slice_pitch,
8380 size_type dst_row_pitch,
8381 size_type dst_slice_pitch,
8382 const vector<Event>* events =
nullptr,
8383 Event* event =
nullptr)
const
8385 return enqueueCopyBufferRect(
8388 { src_origin[0], src_origin[1], 0 },
8389 { dst_origin[0], dst_origin[1], 0 },
8390 { region[0], region[1], 1 },
8400#if CL_HPP_TARGET_OPENCL_VERSION >= 120
8412 template<
typename PatternType>
8415 PatternType pattern,
8418 const vector<Event>* events =
nullptr,
8419 Event* event =
nullptr)
const
8422 cl_int err = detail::errHandler(
8423 CL_(clEnqueueFillBuffer)(
8426 static_cast<void*
>(&pattern),
8427 sizeof(PatternType),
8430 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8431 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
8432 (event !=
nullptr) ? &tmp :
nullptr),
8433 __ENQUEUE_FILL_BUFFER_ERR);
8435 if (event !=
nullptr && err == CL_SUCCESS)
8442 cl_int enqueueReadImage(
8445 const array<size_type, 3>& origin,
8446 const array<size_type, 3>& region,
8447 size_type row_pitch,
8448 size_type slice_pitch,
8450 const vector<Event>* events =
nullptr,
8451 Event* event =
nullptr)
const
8454 cl_int err = detail::errHandler(
8455 CL_(clEnqueueReadImage)(
8464 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8465 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
8466 (event !=
nullptr) ? &tmp :
nullptr),
8467 __ENQUEUE_READ_IMAGE_ERR);
8469 if (event !=
nullptr && err == CL_SUCCESS)
8475 cl_int enqueueReadImage(
8478 const array<size_type, 2>& origin,
8479 const array<size_type, 2>& region,
8480 size_type row_pitch,
8481 size_type slice_pitch,
8483 const vector<Event>* events =
nullptr,
8484 Event* event =
nullptr)
const
8486 return enqueueReadImage(
8489 { origin[0], origin[1], 0 },
8490 { region[0], region[1], 1 },
8498 cl_int enqueueWriteImage(
8501 const array<size_type, 3>& origin,
8502 const array<size_type, 3>& region,
8503 size_type row_pitch,
8504 size_type slice_pitch,
8506 const vector<Event>* events =
nullptr,
8507 Event* event =
nullptr)
const
8510 cl_int err = detail::errHandler(
8511 CL_(clEnqueueWriteImage)(
8520 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8521 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
8522 (event !=
nullptr) ? &tmp :
nullptr),
8523 __ENQUEUE_WRITE_IMAGE_ERR);
8525 if (event !=
nullptr && err == CL_SUCCESS)
8531 cl_int enqueueWriteImage(
8534 const array<size_type, 2>& origin,
8535 const array<size_type, 2>& region,
8536 size_type row_pitch,
8537 size_type slice_pitch,
8539 const vector<Event>* events =
nullptr,
8540 Event* event =
nullptr)
const
8542 return enqueueWriteImage(
8545 { origin[0], origin[1], 0 },
8546 { region[0], region[1], 1 },
8554 cl_int enqueueCopyImage(
8557 const array<size_type, 3>& src_origin,
8558 const array<size_type, 3>& dst_origin,
8559 const array<size_type, 3>& region,
8560 const vector<Event>* events =
nullptr,
8561 Event* event =
nullptr)
const
8564 cl_int err = detail::errHandler(
8565 CL_(clEnqueueCopyImage)(
8572 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8573 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
8574 (event !=
nullptr) ? &tmp :
nullptr),
8575 __ENQUEUE_COPY_IMAGE_ERR);
8577 if (event !=
nullptr && err == CL_SUCCESS)
8583 cl_int enqueueCopyImage(
8586 const array<size_type, 2>& src_origin,
8587 const array<size_type, 2>& dst_origin,
8588 const array<size_type, 2>& region,
8589 const vector<Event>* events =
nullptr,
8590 Event* event =
nullptr)
const
8592 return enqueueCopyImage(
8595 { src_origin[0], src_origin[1], 0 },
8596 { dst_origin[0], dst_origin[1], 0 },
8597 { region[0], region[1], 1 },
8602#if CL_HPP_TARGET_OPENCL_VERSION >= 120
8610 template <
typename T>
8611 typename std::enable_if<std::is_same<T, cl_float4>::value ||
8612 std::is_same<T, cl_int4 >::value ||
8613 std::is_same<T, cl_uint4 >::value,
8618 const array<size_type, 3>& origin,
8619 const array<size_type, 3>& region,
8620 const vector<Event>* events =
nullptr,
8621 Event* event =
nullptr)
const
8624 cl_int err = detail::errHandler(
8625 CL_(clEnqueueFillImage)(
8628 static_cast<void*
>(&fillColor),
8631 (events !=
nullptr) ? (cl_uint)events->size() : 0,
8632 (events !=
nullptr && events->size() > 0) ? (
const cl_event*)&events->front() : NULL,
8633 (event != NULL) ? &tmp :
nullptr),
8634 __ENQUEUE_FILL_IMAGE_ERR);
8636 if (event !=
nullptr && err == CL_SUCCESS) *
event = tmp;
8648 template <
typename T>
8649 typename std::enable_if<std::is_same<T, cl_float4>::value ||
8650 std::is_same<T, cl_int4 >::value ||
8651 std::is_same<T, cl_uint4 >::value, cl_int>::type
8655 const array<size_type, 2>& origin,
8656 const array<size_type, 2>& region,
8657 const vector<Event>* events =
nullptr,
8658 Event* event =
nullptr)
const
8663 { origin[0], origin[1], 0 },
8664 { region[0], region[1], 1 },
8671 cl_int enqueueCopyImageToBuffer(
8674 const array<size_type, 3>& src_origin,
8675 const array<size_type, 3>& region,
8676 size_type dst_offset,
8677 const vector<Event>* events =
nullptr,
8678 Event* event =
nullptr)
const
8681 cl_int err = detail::errHandler(
8682 CL_(clEnqueueCopyImageToBuffer)(
8689 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8690 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
8691 (event !=
nullptr) ? &tmp :
nullptr),
8692 __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR);
8694 if (event !=
nullptr && err == CL_SUCCESS)
8700 cl_int enqueueCopyImageToBuffer(
8703 const array<size_type, 2>& src_origin,
8704 const array<size_type, 2>& region,
8705 size_type dst_offset,
8706 const vector<Event>* events =
nullptr,
8707 Event* event =
nullptr)
const
8709 return enqueueCopyImageToBuffer(
8712 { src_origin[0], src_origin[1], 0 },
8713 { region[0], region[1], 1 },
8719 cl_int enqueueCopyBufferToImage(
8722 size_type src_offset,
8723 const array<size_type, 3>& dst_origin,
8724 const array<size_type, 3>& region,
8725 const vector<Event>* events =
nullptr,
8726 Event* event =
nullptr)
const
8729 cl_int err = detail::errHandler(
8730 CL_(clEnqueueCopyBufferToImage)(
8737 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8738 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
8739 (event !=
nullptr) ? &tmp :
nullptr),
8740 __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR);
8742 if (event !=
nullptr && err == CL_SUCCESS)
8748 cl_int enqueueCopyBufferToImage(
8751 size_type src_offset,
8752 const array<size_type, 2>& dst_origin,
8753 const array<size_type, 2>& region,
8754 const vector<Event>* events =
nullptr,
8755 Event* event =
nullptr)
const
8757 return enqueueCopyBufferToImage(
8761 { dst_origin[0], dst_origin[1], 0 },
8762 { region[0], region[1], 1 },
8767 void* enqueueMapBuffer(
8768 const Buffer& buffer,
8773 const vector<Event>* events =
nullptr,
8774 Event* event =
nullptr,
8775 cl_int* err =
nullptr)
const
8779 void * result = CL_(clEnqueueMapBuffer)(
8780 object_, buffer(), blocking, flags, offset, size,
8781 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8782 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
8783 (
event !=
nullptr) ? &tmp : nullptr,
8786 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
8787 if (err !=
nullptr) {
8790 if (event !=
nullptr && error == CL_SUCCESS)
8796 void* enqueueMapImage(
8800 const array<size_type, 3>& origin,
8801 const array<size_type, 3>& region,
8802 size_type * row_pitch,
8803 size_type * slice_pitch,
8804 const vector<Event>* events =
nullptr,
8805 Event* event =
nullptr,
8806 cl_int* err =
nullptr)
const
8810 void * result = CL_(clEnqueueMapImage)(
8811 object_, image(), blocking, flags,
8814 row_pitch, slice_pitch,
8815 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8816 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
8817 (
event !=
nullptr) ? &tmp : nullptr,
8820 detail::errHandler(error, __ENQUEUE_MAP_IMAGE_ERR);
8821 if (err !=
nullptr) {
8824 if (event !=
nullptr && error == CL_SUCCESS)
8829 void* enqueueMapImage(
8833 const array<size_type, 2>& origin,
8834 const array<size_type, 2>& region,
8835 size_type* row_pitch,
8836 size_type* slice_pitch,
8837 const vector<Event>* events =
nullptr,
8838 Event* event =
nullptr,
8839 cl_int* err =
nullptr)
const
8841 return enqueueMapImage(image, blocking, flags,
8842 { origin[0], origin[1], 0 },
8843 { region[0], region[1], 1 }, row_pitch,
8844 slice_pitch, events, event, err);
8847#if CL_HPP_TARGET_OPENCL_VERSION >= 200
8853 template<
typename T>
8859 const vector<Event> *events =
nullptr,
8860 Event *event =
nullptr)
const {
8862 cl_int err = detail::errHandler(CL_(clEnqueueSVMMemcpy)(
8863 object_, blocking,
static_cast<void *
>(dst_ptr),
static_cast<const void *
>(src_ptr), size,
8864 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8865 (events !=
nullptr && events->size() > 0) ? (
const cl_event *) &events->front() :
nullptr,
8866 (event !=
nullptr) ? &tmp :
nullptr), __ENQUEUE_COPY_SVM_ERR);
8868 if (event !=
nullptr && err == CL_SUCCESS)
8878 template<
typename T,
class D>
8880 cl::pointer<T, D> &dst_ptr,
8881 const cl::pointer<T, D> &src_ptr,
8884 const vector<Event> *events =
nullptr,
8885 Event *event =
nullptr)
const {
8887 cl_int err = detail::errHandler(CL_(clEnqueueSVMMemcpy)(
8888 object_, blocking,
static_cast<void *
>(dst_ptr.get()),
static_cast<const void *
>(src_ptr.get()),
8890 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8891 (events !=
nullptr && events->size() > 0) ? (
const cl_event *) &events->front() :
nullptr,
8892 (event !=
nullptr) ? &tmp :
nullptr), __ENQUEUE_COPY_SVM_ERR);
8894 if (event !=
nullptr && err == CL_SUCCESS)
8904 template<
typename T,
class Alloc>
8906 cl::vector<T, Alloc> &dst_container,
8907 const cl::vector<T, Alloc> &src_container,
8909 const vector<Event> *events =
nullptr,
8910 Event *event =
nullptr)
const {
8912 if(src_container.size() != dst_container.size()){
8913 return detail::errHandler(CL_INVALID_VALUE,__ENQUEUE_COPY_SVM_ERR);
8915 cl_int err = detail::errHandler(CL_(clEnqueueSVMMemcpy)(
8917 dst_container.empty() ?
nullptr : dst_container.data(),
8918 src_container.empty() ?
nullptr : src_container.data(),
8919 dst_container.size() *
sizeof(T),
8920 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8921 (events !=
nullptr && events->size() > 0) ? (
const cl_event *) &events->front() :
nullptr,
8922 (event !=
nullptr) ? &tmp :
nullptr), __ENQUEUE_COPY_SVM_ERR);
8924 if (event !=
nullptr && err == CL_SUCCESS)
8934 template<
typename T,
typename PatternType>
8937 PatternType pattern,
8939 const vector<Event> *events =
nullptr,
8940 Event *event =
nullptr)
const {
8942 cl_int err = detail::errHandler(CL_(clEnqueueSVMMemFill)(
8943 object_,
static_cast<void *
>(ptr),
static_cast<void *
>(&pattern),
8944 sizeof(PatternType), size,
8945 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8946 (events !=
nullptr && events->size() > 0) ? (
const cl_event *) &events->front() :
nullptr,
8947 (event !=
nullptr) ? &tmp :
nullptr), __ENQUEUE_FILL_SVM_ERR);
8949 if (event !=
nullptr && err == CL_SUCCESS)
8959 template<
typename T,
class D,
typename PatternType>
8961 cl::pointer<T, D> &ptr,
8962 PatternType pattern,
8964 const vector<Event> *events =
nullptr,
8965 Event *event =
nullptr)
const {
8967 cl_int err = detail::errHandler(CL_(clEnqueueSVMMemFill)(
8968 object_,
static_cast<void *
>(ptr.get()),
static_cast<void *
>(&pattern),
8969 sizeof(PatternType), size,
8970 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8971 (events !=
nullptr && events->size() > 0) ? (
const cl_event *) &events->front() :
nullptr,
8972 (event !=
nullptr) ? &tmp :
nullptr), __ENQUEUE_FILL_SVM_ERR);
8974 if (event !=
nullptr && err == CL_SUCCESS)
8984 template<
typename T,
class Alloc,
typename PatternType>
8986 cl::vector<T, Alloc> &container,
8987 PatternType pattern,
8988 const vector<Event> *events =
nullptr,
8989 Event* event =
nullptr)
const
8992 cl_int err = detail::errHandler(CL_(clEnqueueSVMMemFill)(
8994 container.empty() ?
nullptr : container.data(),
8996 sizeof(PatternType),
8997 container.size() *
sizeof(T),
8998 (events !=
nullptr) ? (cl_uint) events->size() : 0,
8999 (events !=
nullptr && events->size() > 0) ? (
const cl_event *) &events->front() :
nullptr,
9000 (event !=
nullptr) ? &tmp : NULL), __ENQUEUE_FILL_SVM_ERR);
9002 if (event !=
nullptr && err == CL_SUCCESS)
9012 template<
typename T>
9018 const vector<Event>* events =
nullptr,
9019 Event* event =
nullptr)
const
9022 cl_int err = detail::errHandler(CL_(clEnqueueSVMMap)(
9023 object_, blocking, flags,
static_cast<void*
>(ptr), size,
9024 (events !=
nullptr) ? (cl_uint)events->size() : 0,
9025 (events !=
nullptr && events->size() > 0) ? (
const cl_event*)&events->front() :
nullptr,
9026 (event !=
nullptr) ? &tmp :
nullptr),
9027 __ENQUEUE_MAP_SVM_ERR);
9029 if (event !=
nullptr && err == CL_SUCCESS)
9040 template<
typename T,
class D>
9042 cl::pointer<T, D> &ptr,
9046 const vector<Event>* events =
nullptr,
9047 Event* event =
nullptr)
const
9050 cl_int err = detail::errHandler(CL_(clEnqueueSVMMap)(
9051 object_, blocking, flags,
static_cast<void*
>(ptr.get()), size,
9052 (events !=
nullptr) ? (cl_uint)events->size() : 0,
9053 (events !=
nullptr && events->size() > 0) ? (
const cl_event*)&events->front() :
nullptr,
9054 (event !=
nullptr) ? &tmp :
nullptr),
9055 __ENQUEUE_MAP_SVM_ERR);
9057 if (event !=
nullptr && err == CL_SUCCESS)
9067 template<
typename T,
class Alloc>
9069 cl::vector<T, Alloc> &container,
9072 const vector<Event>* events =
nullptr,
9073 Event* event =
nullptr)
const
9076 cl_int err = detail::errHandler(CL_(clEnqueueSVMMap)(
9077 object_, blocking, flags,
9078 container.empty() ?
nullptr : container.data(),
9079 container.size() *
sizeof(T),
9080 (events !=
nullptr) ? (cl_uint)events->size() : 0,
9081 (events !=
nullptr && events->size() > 0) ? (
const cl_event*)&events->front() :
nullptr,
9082 (event !=
nullptr) ? &tmp :
nullptr),
9083 __ENQUEUE_MAP_SVM_ERR);
9085 if (event !=
nullptr && err == CL_SUCCESS)
9092 cl_int enqueueUnmapMemObject(
9095 const vector<Event>* events =
nullptr,
9096 Event* event =
nullptr)
const
9099 cl_int err = detail::errHandler(
9100 CL_(clEnqueueUnmapMemObject)(
9101 object_, memory(), mapped_ptr,
9102 (events !=
nullptr) ? (cl_uint) events->size() : 0,
9103 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
9104 (event !=
nullptr) ? &tmp :
nullptr),
9105 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9107 if (event !=
nullptr && err == CL_SUCCESS)
9114#if CL_HPP_TARGET_OPENCL_VERSION >= 200
9119 template<
typename T>
9122 const vector<Event>* events =
nullptr,
9123 Event* event =
nullptr)
const
9126 cl_int err = detail::errHandler(
9127 CL_(clEnqueueSVMUnmap)(
9128 object_,
static_cast<void*
>(ptr),
9129 (events !=
nullptr) ? (cl_uint)events->size() : 0,
9130 (events !=
nullptr && events->size() > 0) ? (
const cl_event*)&events->front() :
nullptr,
9131 (event !=
nullptr) ? &tmp :
nullptr),
9132 __ENQUEUE_UNMAP_SVM_ERR);
9134 if (event !=
nullptr && err == CL_SUCCESS)
9144 template<
typename T,
class D>
9146 cl::pointer<T, D> &ptr,
9147 const vector<Event>* events =
nullptr,
9148 Event* event =
nullptr)
const
9151 cl_int err = detail::errHandler(
9152 CL_(clEnqueueSVMUnmap)(
9153 object_,
static_cast<void*
>(ptr.get()),
9154 (events !=
nullptr) ? (cl_uint)events->size() : 0,
9155 (events !=
nullptr && events->size() > 0) ? (
const cl_event*)&events->front() :
nullptr,
9156 (event !=
nullptr) ? &tmp :
nullptr),
9157 __ENQUEUE_UNMAP_SVM_ERR);
9159 if (event !=
nullptr && err == CL_SUCCESS)
9169 template<
typename T,
class Alloc>
9171 cl::vector<T, Alloc> &container,
9172 const vector<Event>* events =
nullptr,
9173 Event* event =
nullptr)
const
9176 cl_int err = detail::errHandler(
9177 CL_(clEnqueueSVMUnmap)(
9179 container.empty() ?
nullptr : container.data(),
9180 (events !=
nullptr) ? (cl_uint)events->size() : 0,
9181 (events !=
nullptr && events->size() > 0) ? (
const cl_event*)&events->front() :
nullptr,
9182 (event !=
nullptr) ? &tmp :
nullptr),
9183 __ENQUEUE_UNMAP_SVM_ERR);
9185 if (event !=
nullptr && err == CL_SUCCESS)
9192#if CL_HPP_TARGET_OPENCL_VERSION >= 120
9205 const vector<Event> *events =
nullptr,
9206 Event *event =
nullptr)
const
9209 cl_int err = detail::errHandler(
9210 CL_(clEnqueueMarkerWithWaitList)(
9212 (events !=
nullptr) ? (cl_uint) events->size() : 0,
9213 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
9214 (event !=
nullptr) ? &tmp :
nullptr),
9215 __ENQUEUE_MARKER_WAIT_LIST_ERR);
9217 if (event !=
nullptr && err == CL_SUCCESS)
9235 const vector<Event> *events =
nullptr,
9236 Event *event =
nullptr)
const
9239 cl_int err = detail::errHandler(
9240 CL_(clEnqueueBarrierWithWaitList)(
9242 (events !=
nullptr) ? (cl_uint) events->size() : 0,
9243 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
9244 (event !=
nullptr) ? &tmp :
nullptr),
9245 __ENQUEUE_BARRIER_WAIT_LIST_ERR);
9247 if (event !=
nullptr && err == CL_SUCCESS)
9258 const vector<Memory> &memObjects,
9259 cl_mem_migration_flags flags,
9260 const vector<Event>* events =
nullptr,
9261 Event* event =
nullptr
9266 vector<cl_mem> localMemObjects(memObjects.size());
9268 for(
int i = 0; i < (int)memObjects.size(); ++i ) {
9269 localMemObjects[i] = memObjects[i]();
9272 cl_int err = detail::errHandler(
9273 CL_(clEnqueueMigrateMemObjects)(
9275 (cl_uint)memObjects.size(),
9276 localMemObjects.empty() ?
nullptr : localMemObjects.data(),
9278 (events !=
nullptr) ? (cl_uint) events->size() : 0,
9279 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
9280 (event !=
nullptr) ? &tmp :
nullptr),
9281 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9283 if (event !=
nullptr && err == CL_SUCCESS)
9291#if CL_HPP_TARGET_OPENCL_VERSION >= 210
9297 template<
typename T>
9299 const cl::vector<T*> &svmRawPointers,
9300 const cl::vector<size_type> &sizes,
9301 cl_mem_migration_flags flags = 0,
9302 const vector<Event>* events =
nullptr,
9303 Event* event =
nullptr)
const
9306 cl_int err = detail::errHandler(CL_(clEnqueueSVMMigrateMem)(
9308 svmRawPointers.size(),
9309 svmRawPointers.empty() ?
nullptr : svmRawPointers.data(),
9310 sizes.empty() ?
nullptr : sizes.data(),
9312 (events !=
nullptr) ? (cl_uint)events->size() : 0,
9313 (events !=
nullptr && events->size() > 0) ? (
const cl_event*)&events->front() :
nullptr,
9314 (event !=
nullptr) ? &tmp :
nullptr),
9315 __ENQUEUE_MIGRATE_SVM_ERR);
9317 if (event !=
nullptr && err == CL_SUCCESS)
9327 template<
typename T>
9329 const cl::vector<T*> &svmRawPointers,
9330 cl_mem_migration_flags flags = 0,
9331 const vector<Event>* events =
nullptr,
9332 Event* event =
nullptr)
const
9334 return enqueueMigrateSVM(svmRawPointers, cl::vector<size_type>(svmRawPointers.size()), flags, events, event);
9343 template<
typename T,
class D>
9345 const cl::vector<cl::pointer<T, D>> &svmPointers,
9346 const cl::vector<size_type> &sizes,
9347 cl_mem_migration_flags flags = 0,
9348 const vector<Event>* events =
nullptr,
9349 Event* event =
nullptr)
const
9351 cl::vector<void*> svmRawPointers;
9352 svmRawPointers.reserve(svmPointers.size());
9353 for (
auto p : svmPointers) {
9354 svmRawPointers.push_back(
static_cast<void*
>(p.get()));
9365 template<
typename T,
class D>
9367 const cl::vector<cl::pointer<T, D>> &svmPointers,
9368 cl_mem_migration_flags flags = 0,
9369 const vector<Event>* events =
nullptr,
9370 Event* event =
nullptr)
const
9372 return enqueueMigrateSVM(svmPointers, cl::vector<size_type>(svmPointers.size()), flags, events, event);
9380 template<
typename T,
class Alloc>
9382 const cl::vector<cl::vector<T, Alloc>> &svmContainers,
9383 const cl::vector<size_type> &sizes,
9384 cl_mem_migration_flags flags = 0,
9385 const vector<Event>* events =
nullptr,
9386 Event* event =
nullptr)
const
9388 cl::vector<void*> svmRawPointers;
9389 svmRawPointers.reserve(svmContainers.size());
9390 for (
auto p : svmContainers) {
9391 svmRawPointers.push_back(
static_cast<void*
>(p.data()));
9401 template<
typename T,
class Alloc>
9403 const cl::vector<cl::vector<T, Alloc>> &svmContainers,
9404 cl_mem_migration_flags flags = 0,
9405 const vector<Event>* events =
nullptr,
9406 Event* event =
nullptr)
const
9408 return enqueueMigrateSVM(svmContainers, cl::vector<size_type>(svmContainers.size()), flags, events, event);
9413 cl_int enqueueNDRangeKernel(
9417 const NDRange& local = NullRange,
9418 const vector<Event>* events =
nullptr,
9419 Event* event =
nullptr)
const
9422 cl_int err = detail::errHandler(
9423 CL_(clEnqueueNDRangeKernel)(
9424 object_, kernel(), (cl_uint) global.
dimensions(),
9425 offset.
dimensions() != 0 ? (
const size_type*) offset :
nullptr,
9426 (
const size_type*) global,
9427 local.dimensions() != 0 ? (
const size_type*) local :
nullptr,
9428 (events !=
nullptr) ? (cl_uint) events->size() : 0,
9429 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
9430 (event !=
nullptr) ? &tmp :
nullptr),
9431 __ENQUEUE_NDRANGE_KERNEL_ERR);
9433 if (event !=
nullptr && err == CL_SUCCESS)
9439#if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
9440 CL_API_PREFIX__VERSION_1_2_DEPRECATED cl_int enqueueTask(
9441 const Kernel& kernel,
9442 const vector<Event>* events =
nullptr,
9443 Event* event =
nullptr) const CL_API_SUFFIX__VERSION_1_2_DEPRECATED
9446 cl_int err = detail::errHandler(
9449 (events !=
nullptr) ? (cl_uint) events->size() : 0,
9450 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
9451 (event !=
nullptr) ? &tmp :
nullptr),
9452 __ENQUEUE_TASK_ERR);
9454 if (event !=
nullptr && err == CL_SUCCESS)
9461 cl_int enqueueNativeKernel(
9462 void (CL_CALLBACK *userFptr)(
void *),
9463 std::pair<void*, size_type> args,
9464 const vector<Memory>* mem_objects =
nullptr,
9465 const vector<const void*>* mem_locs =
nullptr,
9466 const vector<Event>* events =
nullptr,
9467 Event* event =
nullptr)
const
9470 cl_int err = detail::errHandler(
9471 CL_(clEnqueueNativeKernel)(
9472 object_, userFptr, args.first, args.second,
9473 (mem_objects !=
nullptr) ? (cl_uint) mem_objects->size() : 0,
9474 (mem_objects->size() > 0 ) ?
reinterpret_cast<const cl_mem *
>(mem_objects->data()) :
nullptr,
9475 (mem_locs !=
nullptr && mem_locs->size() > 0) ?
const_cast<const void**
>(&mem_locs->front()) :
nullptr,
9476 (events !=
nullptr) ? (cl_uint) events->size() : 0,
9477 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
9478 (event !=
nullptr) ? &tmp :
nullptr),
9479 __ENQUEUE_NATIVE_KERNEL);
9481 if (event !=
nullptr && err == CL_SUCCESS)
9490#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
9491 CL_API_PREFIX__VERSION_1_1_DEPRECATED
9492 cl_int
enqueueMarker(
Event* event =
nullptr) const CL_API_SUFFIX__VERSION_1_1_DEPRECATED
9495 cl_int err = detail::errHandler(
9496 CL_(clEnqueueMarker)(
9498 (event !=
nullptr) ? &tmp :
nullptr),
9499 __ENQUEUE_MARKER_ERR);
9501 if (event !=
nullptr && err == CL_SUCCESS)
9507 CL_API_PREFIX__VERSION_1_1_DEPRECATED
9508 cl_int enqueueWaitForEvents(
const vector<Event>& events)
const CL_API_SUFFIX__VERSION_1_1_DEPRECATED
9510 return detail::errHandler(
9511 CL_(clEnqueueWaitForEvents)(
9513 (cl_uint) events.size(),
9514 events.size() > 0 ? (
const cl_event*) &events.front() :
nullptr),
9515 __ENQUEUE_WAIT_FOR_EVENTS_ERR);
9519 cl_int enqueueAcquireGLObjects(
9520 const vector<Memory>* mem_objects =
nullptr,
9521 const vector<Event>* events =
nullptr,
9522 Event* event =
nullptr)
const
9525 cl_int err = detail::errHandler(
9526 CL_(clEnqueueAcquireGLObjects)(
9528 (mem_objects !=
nullptr) ? (cl_uint) mem_objects->size() : 0,
9529 (mem_objects !=
nullptr && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front():
nullptr,
9530 (events !=
nullptr) ? (cl_uint) events->size() : 0,
9531 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
9532 (event !=
nullptr) ? &tmp :
nullptr),
9533 __ENQUEUE_ACQUIRE_GL_ERR);
9535 if (event !=
nullptr && err == CL_SUCCESS)
9541 cl_int enqueueReleaseGLObjects(
9542 const vector<Memory>* mem_objects =
nullptr,
9543 const vector<Event>* events =
nullptr,
9544 Event* event =
nullptr)
const
9547 cl_int err = detail::errHandler(
9548 CL_(clEnqueueReleaseGLObjects)(
9550 (mem_objects !=
nullptr) ? (cl_uint) mem_objects->size() : 0,
9551 (mem_objects !=
nullptr && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front():
nullptr,
9552 (events !=
nullptr) ? (cl_uint) events->size() : 0,
9553 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
9554 (event !=
nullptr) ? &tmp :
nullptr),
9555 __ENQUEUE_RELEASE_GL_ERR);
9557 if (event !=
nullptr && err == CL_SUCCESS)
9563#if defined (CL_HPP_USE_DX_INTEROP)
9564typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueAcquireD3D10ObjectsKHR)(
9565 cl_command_queue command_queue, cl_uint num_objects,
9566 const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
9567 const cl_event* event_wait_list, cl_event* event);
9568typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueReleaseD3D10ObjectsKHR)(
9569 cl_command_queue command_queue, cl_uint num_objects,
9570 const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
9571 const cl_event* event_wait_list, cl_event* event);
9573 cl_int enqueueAcquireD3D10Objects(
9574 const vector<Memory>* mem_objects =
nullptr,
9575 const vector<Event>* events =
nullptr,
9576 Event* event =
nullptr)
const
9578 static PFN_clEnqueueAcquireD3D10ObjectsKHR pfn_clEnqueueAcquireD3D10ObjectsKHR =
nullptr;
9579#if CL_HPP_TARGET_OPENCL_VERSION >= 120
9580 cl_context context = getInfo<CL_QUEUE_CONTEXT>();
9581 cl::Device device(getInfo<CL_QUEUE_DEVICE>());
9582 cl_platform_id platform = device.
getInfo<CL_DEVICE_PLATFORM>();
9583 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueAcquireD3D10ObjectsKHR);
9585#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
9586 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueAcquireD3D10ObjectsKHR);
9590 cl_int err = detail::errHandler(
9591 pfn_clEnqueueAcquireD3D10ObjectsKHR(
9593 (mem_objects !=
nullptr) ? (cl_uint) mem_objects->size() : 0,
9594 (mem_objects !=
nullptr && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front():
nullptr,
9595 (events !=
nullptr) ? (cl_uint) events->size() : 0,
9596 (events !=
nullptr) ? (
const cl_event*) &events->front() :
nullptr,
9597 (event !=
nullptr) ? &tmp :
nullptr),
9598 __ENQUEUE_ACQUIRE_GL_ERR);
9600 if (event !=
nullptr && err == CL_SUCCESS)
9606 cl_int enqueueReleaseD3D10Objects(
9607 const vector<Memory>* mem_objects =
nullptr,
9608 const vector<Event>* events =
nullptr,
9609 Event* event =
nullptr)
const
9611 static PFN_clEnqueueReleaseD3D10ObjectsKHR pfn_clEnqueueReleaseD3D10ObjectsKHR =
nullptr;
9612#if CL_HPP_TARGET_OPENCL_VERSION >= 120
9613 cl_context context = getInfo<CL_QUEUE_CONTEXT>();
9614 cl::Device device(getInfo<CL_QUEUE_DEVICE>());
9615 cl_platform_id platform = device.
getInfo<CL_DEVICE_PLATFORM>();
9616 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueReleaseD3D10ObjectsKHR);
9618#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
9619 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueReleaseD3D10ObjectsKHR);
9623 cl_int err = detail::errHandler(
9624 pfn_clEnqueueReleaseD3D10ObjectsKHR(
9626 (mem_objects !=
nullptr) ? (cl_uint) mem_objects->size() : 0,
9627 (mem_objects !=
nullptr && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front():
nullptr,
9628 (events !=
nullptr) ? (cl_uint) events->size() : 0,
9629 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
9630 (event !=
nullptr) ? &tmp :
nullptr),
9631 __ENQUEUE_RELEASE_GL_ERR);
9633 if (event !=
nullptr && err == CL_SUCCESS)
9643#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
9644 CL_API_PREFIX__VERSION_1_1_DEPRECATED
9645 cl_int
enqueueBarrier() const CL_API_SUFFIX__VERSION_1_1_DEPRECATED
9647 return detail::errHandler(
9648 CL_(clEnqueueBarrier)(object_),
9649 __ENQUEUE_BARRIER_ERR);
9653 cl_int flush()
const
9655 return detail::errHandler(CL_(clFlush)(object_), __FLUSH_ERR);
9658 cl_int finish()
const
9660 return detail::errHandler(CL_(clFinish)(object_), __FINISH_ERR);
9663#ifdef cl_khr_external_memory
9664 cl_int enqueueAcquireExternalMemObjects(
9665 const vector<Memory>& mem_objects,
9666 const vector<Event>* events_wait =
nullptr,
9667 Event *event =
nullptr)
9669 cl_int err = CL_INVALID_OPERATION;
9672 std::call_once(ext_memory_initialized_, initMemoryExtension, this->getInfo<CL_QUEUE_DEVICE>());
9674 if (pfn_clEnqueueAcquireExternalMemObjectsKHR)
9676 err = pfn_clEnqueueAcquireExternalMemObjectsKHR(
9678 static_cast<cl_uint
>(mem_objects.size()),
9679 reinterpret_cast<const cl_mem *
>(mem_objects.empty() ?
nullptr : mem_objects.data()),
9680 (events_wait !=
nullptr) ?
static_cast<cl_uint
>(events_wait->size()) : 0,
9681 (events_wait !=
nullptr && events_wait->size() > 0) ?
reinterpret_cast<const cl_event*
>(events_wait->data()) :
nullptr,
9685 detail::errHandler(err, __ENQUEUE_ACQUIRE_EXTERNAL_MEMORY_ERR);
9687 if (event !=
nullptr && err == CL_SUCCESS)
9693 cl_int enqueueReleaseExternalMemObjects(
9694 const vector<Memory>& mem_objects,
9695 const vector<Event>* events_wait =
nullptr,
9696 Event *event =
nullptr)
9698 cl_int err = CL_INVALID_OPERATION;
9701 std::call_once(ext_memory_initialized_, initMemoryExtension, this->getInfo<CL_QUEUE_DEVICE>());
9703 if (pfn_clEnqueueReleaseExternalMemObjectsKHR)
9705 err = pfn_clEnqueueReleaseExternalMemObjectsKHR(
9707 static_cast<cl_uint
>(mem_objects.size()),
9708 reinterpret_cast<const cl_mem *
>(mem_objects.empty() ?
nullptr : mem_objects.data()),
9709 (events_wait !=
nullptr) ?
static_cast<cl_uint
>(events_wait->size()) : 0,
9710 (events_wait !=
nullptr && events_wait->size() > 0) ?
reinterpret_cast<const cl_event*
>(events_wait->data()) :
nullptr,
9714 detail::errHandler(err, __ENQUEUE_RELEASE_EXTERNAL_MEMORY_ERR);
9716 if (event !=
nullptr && err == CL_SUCCESS)
9723#ifdef cl_khr_semaphore
9724 cl_int enqueueWaitSemaphores(
9725 const vector<Semaphore> &sema_objects,
9726 const vector<cl_semaphore_payload_khr> &sema_payloads = {},
9727 const vector<Event>* events_wait_list =
nullptr,
9728 Event *
event =
nullptr)
const;
9730 cl_int enqueueSignalSemaphores(
9731 const vector<Semaphore> &sema_objects,
9732 const vector<cl_semaphore_payload_khr>& sema_payloads = {},
9733 const vector<Event>* events_wait_list =
nullptr,
9734 Event*
event =
nullptr);
9737#if CL_HPP_TARGET_OPENCL_VERSION >= 310
9738 NDRange getKernelSuggestedLocalWorkSize(
9739 const Kernel& kernel,
9740 const NDRange& offset,
9741 const NDRange& global,
9742 cl_int* err =
nullptr)
const
9747 NDRange local = global;
9748 cl_int error = detail::errHandler(
9749 CL_(clGetKernelSuggestedLocalWorkSize)(
9752 (cl_uint) global.dimensions(),
9753 offset.dimensions() != 0 ? offset.get() :
nullptr,
9756 __GET_KERNEL_SUGGESTED_LWS_ERR);
9757 if (err !=
nullptr) {
9765#ifdef cl_khr_external_memory
9766CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag CommandQueue::ext_memory_initialized_;
9769CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag CommandQueue::default_initialized_;
9770CL_HPP_DEFINE_STATIC_MEMBER_
CommandQueue CommandQueue::default_;
9771CL_HPP_DEFINE_STATIC_MEMBER_ cl_int CommandQueue::default_error_ = CL_SUCCESS;
9774#if CL_HPP_TARGET_OPENCL_VERSION >= 200
9775enum class DeviceQueueProperties : cl_command_queue_properties
9778 Profiling = CL_QUEUE_PROFILING_ENABLE,
9781inline DeviceQueueProperties operator|(DeviceQueueProperties lhs, DeviceQueueProperties rhs)
9783 return static_cast<DeviceQueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) |
static_cast<cl_command_queue_properties
>(rhs));
9807 cl_command_queue_properties mergedProperties =
9808 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
9810 cl_queue_properties queue_properties[] = {
9811 CL_QUEUE_PROPERTIES, mergedProperties, 0 };
9812 object_ = CL_(clCreateCommandQueueWithProperties)(
9813 context(), device(), queue_properties, &error);
9815 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9816 if (err !=
nullptr) {
9827 DeviceQueueProperties properties = DeviceQueueProperties::None,
9828 cl_int* err =
nullptr)
9832 cl_command_queue_properties mergedProperties =
9833 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
9834 cl_queue_properties queue_properties[] = {
9835 CL_QUEUE_PROPERTIES, mergedProperties, 0 };
9836 object_ = CL_(clCreateCommandQueueWithProperties)(
9837 context(), device(), queue_properties, &error);
9839 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9840 if (err !=
nullptr) {
9852 DeviceQueueProperties properties = DeviceQueueProperties::None,
9853 cl_int* err =
nullptr)
9857 cl_command_queue_properties mergedProperties =
9858 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
9859 cl_queue_properties queue_properties[] = {
9860 CL_QUEUE_PROPERTIES, mergedProperties,
9861 CL_QUEUE_SIZE, queueSize,
9863 object_ = CL_(clCreateCommandQueueWithProperties)(
9864 context(), device(), queue_properties, &error);
9866 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9867 if (err !=
nullptr) {
9878 explicit DeviceCommandQueue(
const cl_command_queue& commandQueue,
bool retainObject =
false) :
9879 detail::Wrapper<cl_type>(commandQueue, retainObject) { }
9883 detail::Wrapper<cl_type>::operator=(rhs);
9887 template <
typename T>
9888 cl_int getInfo(cl_command_queue_info name, T* param)
const
9890 return detail::errHandler(
9892 CL_(clGetCommandQueueInfo), object_, name, param),
9893 __GET_COMMAND_QUEUE_INFO_ERR);
9896 template <cl_command_queue_info name>
typename
9897 detail::param_traits<detail::cl_command_queue_info, name>::param_type
9898 getInfo(cl_int* err =
nullptr)
const
9900 typename detail::param_traits<
9901 detail::cl_command_queue_info, name>::param_type param{};
9902 cl_int result = getInfo(name, ¶m);
9903 if (err !=
nullptr) {
9916 cl_int *err =
nullptr)
9922 cl_command_queue_properties properties =
9923 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
9924 cl_queue_properties queue_properties[] = {
9925 CL_QUEUE_PROPERTIES, properties,
9928 CL_(clCreateCommandQueueWithProperties)(
9929 context(), device(), queue_properties, &error));
9931 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9932 if (err !=
nullptr) {
9946 const Context &context,
const Device &device, cl_int *err =
nullptr)
9950 cl_command_queue_properties properties =
9951 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
9952 cl_queue_properties queue_properties[] = {
9953 CL_QUEUE_PROPERTIES, properties,
9956 CL_(clCreateCommandQueueWithProperties)(
9957 context(), device(), queue_properties, &error));
9959 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9960 if (err !=
nullptr) {
9974 const Context &context,
const Device &device, cl_uint queueSize, cl_int *err =
nullptr)
9978 cl_command_queue_properties properties =
9979 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
9980 cl_queue_properties queue_properties[] = {
9981 CL_QUEUE_PROPERTIES, properties,
9982 CL_QUEUE_SIZE, queueSize,
9985 CL_(clCreateCommandQueueWithProperties)(
9986 context(), device(), queue_properties, &error));
9988 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9989 if (err !=
nullptr) {
9998#if CL_HPP_TARGET_OPENCL_VERSION >= 210
10008 error = CL_(clSetDefaultDeviceCommandQueue)(context.get(), device.get(), default_queue.get());
10010 detail::errHandler(error, __SET_DEFAULT_DEVICE_COMMAND_QUEUE_ERR);
10011 if (err !=
nullptr) {
10014 return default_queue;
10022 return queue.getInfo<CL_QUEUE_DEVICE_DEFAULT>(err);
10042template<
typename IteratorType >
10045 IteratorType startIterator,
10046 IteratorType endIterator,
10051 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
10054 cl_mem_flags flags = 0;
10056 flags |= CL_MEM_READ_ONLY;
10059 flags |= CL_MEM_READ_WRITE;
10062 flags |= CL_MEM_USE_HOST_PTR;
10065 size_type size =
sizeof(DataType)*(endIterator - startIterator);
10068 object_ = CL_(clCreateBuffer)(context(), flags, size,
const_cast<DataType*
>(&*startIterator), &error);
10070 object_ = CL_(clCreateBuffer)(context(), flags, size, 0, &error);
10073 detail::errHandler(error, __CREATE_BUFFER_ERR);
10074 if (err !=
nullptr) {
10078 if( !useHostPtr ) {
10080 detail::errHandler(error, __CREATE_BUFFER_ERR);
10081 if (err !=
nullptr) {
10085 error =
cl::copy(queue, startIterator, endIterator, *
this);
10086 detail::errHandler(error, __CREATE_BUFFER_ERR);
10087 if (err !=
nullptr) {
10093template<
typename IteratorType >
10095 const CommandQueue &queue,
10096 IteratorType startIterator,
10097 IteratorType endIterator,
10102 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
10105 cl_mem_flags flags = 0;
10107 flags |= CL_MEM_READ_ONLY;
10110 flags |= CL_MEM_READ_WRITE;
10113 flags |= CL_MEM_USE_HOST_PTR;
10116 size_type size =
sizeof(DataType)*(endIterator - startIterator);
10118 Context context = queue.getInfo<CL_QUEUE_CONTEXT>();
10121 object_ = CL_(clCreateBuffer)(context(), flags, size,
const_cast<DataType*
>(&*startIterator), &error);
10124 object_ = CL_(clCreateBuffer)(context(), flags, size, 0, &error);
10127 detail::errHandler(error, __CREATE_BUFFER_ERR);
10128 if (err !=
nullptr) {
10133 error =
cl::copy(queue, startIterator, endIterator, *
this);
10134 detail::errHandler(error, __CREATE_BUFFER_ERR);
10135 if (err !=
nullptr) {
10141inline cl_int enqueueReadBuffer(
10147 const vector<Event>* events =
nullptr,
10148 Event* event =
nullptr)
10151 CommandQueue queue = CommandQueue::getDefault(&error);
10153 if (error != CL_SUCCESS) {
10157 return queue.enqueueReadBuffer(buffer, blocking, offset, size, ptr, events, event);
10160inline cl_int enqueueWriteBuffer(
10166 const vector<Event>* events =
nullptr,
10167 Event* event =
nullptr)
10170 CommandQueue queue = CommandQueue::getDefault(&error);
10172 if (error != CL_SUCCESS) {
10176 return queue.enqueueWriteBuffer(buffer, blocking, offset, size, ptr, events, event);
10179inline void* enqueueMapBuffer(
10182 cl_map_flags flags,
10185 const vector<Event>* events =
nullptr,
10186 Event* event =
nullptr,
10187 cl_int* err =
nullptr)
10190 CommandQueue queue = CommandQueue::getDefault(&error);
10191 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
10192 if (err !=
nullptr) {
10196 void * result = CL_(clEnqueueMapBuffer)(
10197 queue(), buffer(), blocking, flags, offset, size,
10198 (events !=
nullptr) ? (cl_uint) events->size() : 0,
10199 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
10203 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
10204 if (err !=
nullptr) {
10211#if CL_HPP_TARGET_OPENCL_VERSION >= 200
10217template<
typename T>
10221 cl_map_flags flags,
10223 const vector<Event>* events,
10227 CommandQueue queue = CommandQueue::getDefault(&error);
10228 if (error != CL_SUCCESS) {
10229 return detail::errHandler(error, __ENQUEUE_MAP_SVM_ERR);
10233 ptr, blocking, flags, size, events, event);
10241template<
typename T,
class D>
10243 cl::pointer<T, D> &ptr,
10245 cl_map_flags flags,
10247 const vector<Event>* events =
nullptr,
10248 Event* event =
nullptr)
10251 CommandQueue queue = CommandQueue::getDefault(&error);
10252 if (error != CL_SUCCESS) {
10253 return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
10257 ptr, blocking, flags, size, events, event);
10265template<
typename T,
class Alloc>
10267 cl::vector<T, Alloc> &container,
10269 cl_map_flags flags,
10270 const vector<Event>* events =
nullptr,
10271 Event* event =
nullptr)
10274 CommandQueue queue = CommandQueue::getDefault(&error);
10275 if (error != CL_SUCCESS) {
10276 return detail::errHandler(error, __ENQUEUE_MAP_SVM_ERR);
10280 container, blocking, flags, events, event);
10285inline cl_int enqueueUnmapMemObject(
10286 const Memory& memory,
10288 const vector<Event>* events =
nullptr,
10289 Event* event =
nullptr)
10292 CommandQueue queue = CommandQueue::getDefault(&error);
10293 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
10294 if (error != CL_SUCCESS) {
10299 cl_int err = detail::errHandler(
10300 CL_(clEnqueueUnmapMemObject)(
10301 queue(), memory(), mapped_ptr,
10302 (events !=
nullptr) ? (cl_uint)events->size() : 0,
10303 (events !=
nullptr && events->size() > 0) ? (
const cl_event*)&events->front() :
nullptr,
10304 (event !=
nullptr) ? &tmp :
nullptr),
10305 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
10307 if (event !=
nullptr && err == CL_SUCCESS)
10313#if CL_HPP_TARGET_OPENCL_VERSION >= 200
10319template<
typename T>
10322 const vector<Event>* events =
nullptr,
10323 Event* event =
nullptr)
10326 CommandQueue queue = CommandQueue::getDefault(&error);
10327 if (error != CL_SUCCESS) {
10328 return detail::errHandler(error, __ENQUEUE_UNMAP_SVM_ERR);
10332 __ENQUEUE_UNMAP_SVM_ERR);
10341template<
typename T,
class D>
10343 cl::pointer<T, D> &ptr,
10344 const vector<Event>* events =
nullptr,
10345 Event* event =
nullptr)
10348 CommandQueue queue = CommandQueue::getDefault(&error);
10349 if (error != CL_SUCCESS) {
10350 return detail::errHandler(error, __ENQUEUE_UNMAP_SVM_ERR);
10354 __ENQUEUE_UNMAP_SVM_ERR);
10362template<
typename T,
class Alloc>
10364 cl::vector<T, Alloc> &container,
10365 const vector<Event>* events =
nullptr,
10366 Event* event =
nullptr)
10369 CommandQueue queue = CommandQueue::getDefault(&error);
10370 if (error != CL_SUCCESS) {
10371 return detail::errHandler(error, __ENQUEUE_UNMAP_SVM_ERR);
10374 return detail::errHandler(queue.
enqueueUnmapSVM(container, events, event),
10375 __ENQUEUE_UNMAP_SVM_ERR);
10380inline cl_int enqueueCopyBuffer(
10383 size_type src_offset,
10384 size_type dst_offset,
10386 const vector<Event>* events =
nullptr,
10387 Event* event =
nullptr)
10390 CommandQueue queue = CommandQueue::getDefault(&error);
10392 if (error != CL_SUCCESS) {
10396 return queue.enqueueCopyBuffer(src, dst, src_offset, dst_offset, size, events, event);
10404template<
typename IteratorType >
10405inline cl_int
copy( IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer )
10408 CommandQueue queue = CommandQueue::getDefault(&error);
10409 if (error != CL_SUCCESS)
10412 return cl::copy(queue, startIterator, endIterator, buffer);
10420template<
typename IteratorType >
10421inline cl_int
copy(
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator )
10424 CommandQueue queue = CommandQueue::getDefault(&error);
10425 if (error != CL_SUCCESS)
10428 return cl::copy(queue, buffer, startIterator, endIterator);
10436template<
typename IteratorType >
10439 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
10442 size_type length = endIterator-startIterator;
10443 size_type byteLength = length*
sizeof(DataType);
10445 DataType *pointer =
10446 static_cast<DataType*
>(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_WRITE, 0, byteLength, 0, 0, &error));
10448 if( error != CL_SUCCESS ) {
10451#if defined(_MSC_VER) && _MSC_VER < 1920
10455 stdext::checked_array_iterator<DataType*>(
10458 std::copy(startIterator, endIterator, pointer);
10461 error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
10463 if( error != CL_SUCCESS ) {
10475template<
typename IteratorType >
10476inline cl_int
copy(
const CommandQueue &queue,
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator )
10478 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
10481 size_type length = endIterator-startIterator;
10482 size_type byteLength = length*
sizeof(DataType);
10484 DataType *pointer =
10485 static_cast<DataType*
>(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_READ, 0, byteLength, 0, 0, &error));
10487 if( error != CL_SUCCESS ) {
10490 std::copy(pointer, pointer + length, startIterator);
10492 error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
10494 if( error != CL_SUCCESS ) {
10502#if CL_HPP_TARGET_OPENCL_VERSION >= 200
10506template<
typename T,
class Alloc>
10507inline cl_int
mapSVM(cl::vector<T, Alloc> &container)
10509 return enqueueMapSVM(container, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE);
10515template<
typename T,
class Alloc>
10516inline cl_int
unmapSVM(cl::vector<T, Alloc> &container)
10523#if CL_HPP_TARGET_OPENCL_VERSION >= 110
10524inline cl_int enqueueReadBufferRect(
10525 const Buffer& buffer,
10527 const array<size_type, 3>& buffer_offset,
10528 const array<size_type, 3>& host_offset,
10529 const array<size_type, 3>& region,
10530 size_type buffer_row_pitch,
10531 size_type buffer_slice_pitch,
10532 size_type host_row_pitch,
10533 size_type host_slice_pitch,
10535 const vector<Event>* events =
nullptr,
10536 Event* event =
nullptr)
10539 CommandQueue queue = CommandQueue::getDefault(&error);
10541 if (error != CL_SUCCESS) {
10545 return queue.enqueueReadBufferRect(
10552 buffer_slice_pitch,
10560inline cl_int enqueueReadBufferRect(
10563 const array<size_type, 2>& buffer_offset,
10564 const array<size_type, 2>& host_offset,
10565 const array<size_type, 2>& region,
10566 size_type buffer_row_pitch,
10567 size_type buffer_slice_pitch,
10568 size_type host_row_pitch,
10569 size_type host_slice_pitch,
10571 const vector<Event>* events =
nullptr,
10572 Event* event =
nullptr)
10574 return enqueueReadBufferRect(
10577 { buffer_offset[0], buffer_offset[1], 0 },
10578 { host_offset[0], host_offset[1], 0 },
10579 { region[0], region[1], 1 },
10581 buffer_slice_pitch,
10589inline cl_int enqueueWriteBufferRect(
10592 const array<size_type, 3>& buffer_offset,
10593 const array<size_type, 3>& host_offset,
10594 const array<size_type, 3>& region,
10595 size_type buffer_row_pitch,
10596 size_type buffer_slice_pitch,
10597 size_type host_row_pitch,
10598 size_type host_slice_pitch,
10600 const vector<Event>* events =
nullptr,
10601 Event* event =
nullptr)
10604 CommandQueue queue = CommandQueue::getDefault(&error);
10606 if (error != CL_SUCCESS) {
10610 return queue.enqueueWriteBufferRect(
10617 buffer_slice_pitch,
10625inline cl_int enqueueWriteBufferRect(
10628 const array<size_type, 2>& buffer_offset,
10629 const array<size_type, 2>& host_offset,
10630 const array<size_type, 2>& region,
10631 size_type buffer_row_pitch,
10632 size_type buffer_slice_pitch,
10633 size_type host_row_pitch,
10634 size_type host_slice_pitch,
10636 const vector<Event>* events =
nullptr,
10637 Event* event =
nullptr)
10639 return enqueueWriteBufferRect(
10642 { buffer_offset[0], buffer_offset[1], 0 },
10643 { host_offset[0], host_offset[1], 0 },
10644 { region[0], region[1], 1 },
10646 buffer_slice_pitch,
10654inline cl_int enqueueCopyBufferRect(
10657 const array<size_type, 3>& src_origin,
10658 const array<size_type, 3>& dst_origin,
10659 const array<size_type, 3>& region,
10660 size_type src_row_pitch,
10661 size_type src_slice_pitch,
10662 size_type dst_row_pitch,
10663 size_type dst_slice_pitch,
10664 const vector<Event>* events =
nullptr,
10665 Event* event =
nullptr)
10668 CommandQueue queue = CommandQueue::getDefault(&error);
10670 if (error != CL_SUCCESS) {
10674 return queue.enqueueCopyBufferRect(
10688inline cl_int enqueueCopyBufferRect(
10691 const array<size_type, 2>& src_origin,
10692 const array<size_type, 2>& dst_origin,
10693 const array<size_type, 2>& region,
10694 size_type src_row_pitch,
10695 size_type src_slice_pitch,
10696 size_type dst_row_pitch,
10697 size_type dst_slice_pitch,
10698 const vector<Event>* events =
nullptr,
10699 Event* event =
nullptr)
10701 return enqueueCopyBufferRect(
10704 { src_origin[0], src_origin[1], 0 },
10705 { dst_origin[0], dst_origin[1], 0 },
10706 { region[0], region[1], 1 },
10716inline cl_int enqueueReadImage(
10717 const Image& image,
10719 const array<size_type, 3>& origin,
10720 const array<size_type, 3>& region,
10721 size_type row_pitch,
10722 size_type slice_pitch,
10724 const vector<Event>* events =
nullptr,
10725 Event* event =
nullptr)
10728 CommandQueue queue = CommandQueue::getDefault(&error);
10730 if (error != CL_SUCCESS) {
10734 return queue.enqueueReadImage(
10746inline cl_int enqueueReadImage(
10747 const Image& image,
10749 const array<size_type, 2>& origin,
10750 const array<size_type, 2>& region,
10751 size_type row_pitch,
10752 size_type slice_pitch,
10754 const vector<Event>* events =
nullptr,
10755 Event* event =
nullptr)
10757 return enqueueReadImage(
10760 { origin[0], origin[1], 0 },
10761 { region[0], region[1], 1 },
10769inline cl_int enqueueWriteImage(
10770 const Image& image,
10772 const array<size_type, 3>& origin,
10773 const array<size_type, 3>& region,
10774 size_type row_pitch,
10775 size_type slice_pitch,
10777 const vector<Event>* events =
nullptr,
10778 Event* event =
nullptr)
10781 CommandQueue queue = CommandQueue::getDefault(&error);
10783 if (error != CL_SUCCESS) {
10787 return queue.enqueueWriteImage(
10799inline cl_int enqueueWriteImage(
10800 const Image& image,
10802 const array<size_type, 2>& origin,
10803 const array<size_type, 2>& region,
10804 size_type row_pitch,
10805 size_type slice_pitch,
10807 const vector<Event>* events =
nullptr,
10808 Event* event =
nullptr)
10810 return enqueueWriteImage(
10813 { origin[0], origin[1], 0 },
10814 { region[0], region[1], 1 },
10822inline cl_int enqueueCopyImage(
10825 const array<size_type, 3>& src_origin,
10826 const array<size_type, 3>& dst_origin,
10827 const array<size_type, 3>& region,
10828 const vector<Event>* events =
nullptr,
10829 Event* event =
nullptr)
10832 CommandQueue queue = CommandQueue::getDefault(&error);
10834 if (error != CL_SUCCESS) {
10838 return queue.enqueueCopyImage(
10848inline cl_int enqueueCopyImage(
10851 const array<size_type, 2>& src_origin,
10852 const array<size_type, 2>& dst_origin,
10853 const array<size_type, 2>& region,
10854 const vector<Event>* events =
nullptr,
10855 Event* event =
nullptr)
10857 return enqueueCopyImage(
10860 { src_origin[0], src_origin[1], 0 },
10861 { dst_origin[0], dst_origin[1], 0 },
10862 { region[0], region[1], 1 },
10867inline cl_int enqueueCopyImageToBuffer(
10870 const array<size_type, 3>& src_origin,
10871 const array<size_type, 3>& region,
10872 size_type dst_offset,
10873 const vector<Event>* events =
nullptr,
10874 Event* event =
nullptr)
10877 CommandQueue queue = CommandQueue::getDefault(&error);
10879 if (error != CL_SUCCESS) {
10883 return queue.enqueueCopyImageToBuffer(
10893inline cl_int enqueueCopyImageToBuffer(
10896 const array<size_type, 2>& src_origin,
10897 const array<size_type, 2>& region,
10898 size_type dst_offset,
10899 const vector<Event>* events =
nullptr,
10900 Event* event =
nullptr)
10902 return enqueueCopyImageToBuffer(
10905 { src_origin[0], src_origin[1], 0 },
10906 { region[0], region[1], 1 },
10912inline cl_int enqueueCopyBufferToImage(
10915 size_type src_offset,
10916 const array<size_type, 3>& dst_origin,
10917 const array<size_type, 3>& region,
10918 const vector<Event>* events =
nullptr,
10919 Event* event =
nullptr)
10922 CommandQueue queue = CommandQueue::getDefault(&error);
10924 if (error != CL_SUCCESS) {
10928 return queue.enqueueCopyBufferToImage(
10938inline cl_int enqueueCopyBufferToImage(
10941 size_type src_offset,
10942 const array<size_type, 2>& dst_origin,
10943 const array<size_type, 2>& region,
10944 const vector<Event>* events =
nullptr,
10945 Event* event =
nullptr)
10948 CommandQueue queue = CommandQueue::getDefault(&error);
10950 if (error != CL_SUCCESS) {
10954 return enqueueCopyBufferToImage(
10958 { dst_origin[0], dst_origin[1], 0 },
10959 { region[0], region[1], 1 },
10964inline cl_int flush(
void)
10967 CommandQueue queue = CommandQueue::getDefault(&error);
10969 if (error != CL_SUCCESS) {
10973 return queue.flush();
10976inline cl_int finish(
void)
10979 CommandQueue queue = CommandQueue::getDefault(&error);
10981 if (error != CL_SUCCESS) {
10986 return queue.finish();
10996 vector<Event> events_;
10998 template<
typename... Ts>
11003 queue_(CommandQueue::getDefault()),
11004 offset_(NullRange),
11011 EnqueueArgs(NDRange global, NDRange local) :
11012 queue_(CommandQueue::getDefault()),
11013 offset_(NullRange),
11020 EnqueueArgs(NDRange offset, NDRange global, NDRange local) :
11021 queue_(CommandQueue::getDefault()),
11029 EnqueueArgs(Event e, NDRange global) :
11030 queue_(CommandQueue::getDefault()),
11031 offset_(NullRange),
11035 events_.push_back(e);
11038 EnqueueArgs(Event e, NDRange global, NDRange local) :
11039 queue_(CommandQueue::getDefault()),
11040 offset_(NullRange),
11044 events_.push_back(e);
11047 EnqueueArgs(Event e, NDRange offset, NDRange global, NDRange local) :
11048 queue_(CommandQueue::getDefault()),
11053 events_.push_back(e);
11056 EnqueueArgs(
const vector<Event> &events, NDRange global) :
11057 queue_(CommandQueue::getDefault()),
11058 offset_(NullRange),
11066 EnqueueArgs(
const vector<Event> &events, NDRange global, NDRange local) :
11067 queue_(CommandQueue::getDefault()),
11068 offset_(NullRange),
11076 EnqueueArgs(
const vector<Event> &events, NDRange offset, NDRange global, NDRange local) :
11077 queue_(CommandQueue::getDefault()),
11086 EnqueueArgs(CommandQueue &queue, NDRange global) :
11088 offset_(NullRange),
11095 EnqueueArgs(CommandQueue &queue, NDRange global, NDRange local) :
11097 offset_(NullRange),
11104 EnqueueArgs(CommandQueue &queue, NDRange offset, NDRange global, NDRange local) :
11113 EnqueueArgs(CommandQueue &queue, Event e, NDRange global) :
11115 offset_(NullRange),
11119 events_.push_back(e);
11122 EnqueueArgs(CommandQueue &queue, Event e, NDRange global, NDRange local) :
11124 offset_(NullRange),
11128 events_.push_back(e);
11131 EnqueueArgs(CommandQueue &queue, Event e, NDRange offset, NDRange global, NDRange local) :
11137 events_.push_back(e);
11140 EnqueueArgs(CommandQueue &queue,
const vector<Event> &events, NDRange global) :
11142 offset_(NullRange),
11150 EnqueueArgs(CommandQueue &queue,
const vector<Event> &events, NDRange global, NDRange local) :
11152 offset_(NullRange),
11160 EnqueueArgs(CommandQueue &queue,
const vector<Event> &events, NDRange offset, NDRange global, NDRange local) :
11179template<
typename... Ts>
11185 template<
int index,
typename T0,
typename... T1s>
11186 void setArgs(T0&& t0, T1s&&... t1s)
11188 kernel_.
setArg(index, t0);
11189 setArgs<index + 1, T1s...>(std::forward<T1s>(t1s)...);
11192 template<
int index,
typename T0>
11193 void setArgs(T0&& t0)
11195 kernel_.setArg(index, t0);
11198 template<
int index>
11205 KernelFunctor(
Kernel kernel) : kernel_(kernel)
11211 cl_int * err =
nullptr) :
11212 kernel_(program, name.c_str(), err)
11228 setArgs<0>(std::forward<Ts>(ts)...);
11230 args.queue_.enqueueNDRangeKernel(
11253 setArgs<0>(std::forward<Ts>(ts)...);
11255 error = args.queue_.enqueueNDRangeKernel(
11266#if CL_HPP_TARGET_OPENCL_VERSION >= 200
11267 cl_int setSVMPointers(
const vector<void*> &pointerList)
11272 template<
typename T0,
typename... T1s>
11273 cl_int setSVMPointers(
const T0 &t0, T1s &... ts)
11285namespace compatibility {
11290 template<
typename... Ts>
11295 FunctorType functor_;
11300 cl_int * err =
nullptr) :
11301 functor_(FunctorType(program, name, err))
11306 functor_(FunctorType(kernel))
11322 enqueueArgs, args...);
11327#ifdef cl_khr_semaphore
11329#ifdef cl_khr_external_semaphore
11330enum ExternalSemaphoreType : cl_external_semaphore_handle_type_khr
11333#ifdef cl_khr_external_semaphore_dx_fence
11334 D3D12Fence = CL_SEMAPHORE_HANDLE_D3D12_FENCE_KHR,
11336#ifdef cl_khr_external_semaphore_opaque_fd
11337 OpaqueFd = CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR,
11339#ifdef cl_khr_external_semaphore_sync_fd
11340 SyncFd = CL_SEMAPHORE_HANDLE_SYNC_FD_KHR,
11342#ifdef cl_khr_external_semaphore_win32
11343 OpaqueWin32 = CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KHR,
11344 OpaqueWin32Kmt = CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KMT_KHR,
11352 Semaphore() : detail::Wrapper<cl_type>() {}
11354 const Context &context,
11355 const vector<cl_semaphore_properties_khr>& sema_props,
11356 cl_int *err =
nullptr)
11359 std::call_once(ext_init_, initExtensions, context);
11361 cl_int error = CL_INVALID_OPERATION;
11363 if (pfn_clCreateSemaphoreWithPropertiesKHR)
11365 object_ = pfn_clCreateSemaphoreWithPropertiesKHR(
11367 sema_props.empty() ?
nullptr : sema_props.data(),
11371 detail::errHandler(error, __CREATE_SEMAPHORE_KHR_WITH_PROPERTIES_ERR);
11373 if (err !=
nullptr) {
11378 const vector<cl_semaphore_properties_khr>& sema_props,
11379 cl_int* err =
nullptr):Semaphore(Context::getDefault(err), sema_props, err) {}
11381 explicit Semaphore(
const cl_semaphore_khr& semaphore,
bool retainObject =
false) :
11382 detail::Wrapper<cl_type>(semaphore, retainObject) {}
11383 Semaphore& operator = (
const cl_semaphore_khr& rhs) {
11384 detail::Wrapper<cl_type>::operator=(rhs);
11387 template <
typename T>
11388 cl_int getInfo(cl_semaphore_info_khr name, T* param)
const
11390 if (pfn_clGetSemaphoreInfoKHR ==
nullptr) {
11391 return detail::errHandler(CL_INVALID_OPERATION,
11392 __GET_SEMAPHORE_KHR_INFO_ERR);
11395 return detail::errHandler(
11396 detail::getInfo(pfn_clGetSemaphoreInfoKHR, object_, name, param),
11397 __GET_SEMAPHORE_KHR_INFO_ERR);
11399 template <cl_semaphore_info_khr name>
typename
11400 detail::param_traits<detail::cl_semaphore_info_khr, name>::param_type
11401 getInfo(cl_int* err =
nullptr)
const
11403 typename detail::param_traits<
11404 detail::cl_semaphore_info_khr, name>::param_type param{};
11405 cl_int result = getInfo(name, ¶m);
11406 if (err !=
nullptr) {
11412#ifdef cl_khr_external_semaphore
11413 template <
typename T>
11414 cl_int getHandleForTypeKHR(
11415 const Device& device, cl_external_semaphore_handle_type_khr name, T* param)
const
11417 if (pfn_clGetSemaphoreHandleForTypeKHR ==
nullptr) {
11418 return detail::errHandler(CL_INVALID_OPERATION,
11419 __GET_SEMAPHORE_HANDLE_FOR_TYPE_KHR_ERR);
11422 return detail::errHandler(
11424 pfn_clGetSemaphoreHandleForTypeKHR, object_, device(), name, param),
11425 __GET_SEMAPHORE_HANDLE_FOR_TYPE_KHR_ERR);
11428 template <cl_external_semaphore_handle_type_khr type>
typename
11429 detail::param_traits<detail::cl_external_semaphore_handle_type_khr, type>::param_type
11430 getHandleForTypeKHR(
const Device& device, cl_int* err =
nullptr)
const
11432 typename detail::param_traits<
11433 detail::cl_external_semaphore_handle_type_khr, type>::param_type param;
11434 cl_int result = getHandleForTypeKHR(device, type, ¶m);
11435 if (err !=
nullptr) {
11444 if (pfn_clRetainSemaphoreKHR ==
nullptr) {
11445 return detail::errHandler(CL_INVALID_OPERATION,
11446 __RETAIN_SEMAPHORE_KHR_ERR);
11448 return pfn_clRetainSemaphoreKHR(object_);
11453 if (pfn_clReleaseSemaphoreKHR ==
nullptr) {
11454 return detail::errHandler(CL_INVALID_OPERATION,
11455 __RELEASE_SEMAPHORE_KHR_ERR);
11457 return pfn_clReleaseSemaphoreKHR(object_);
11461 static std::once_flag ext_init_;
11463 static void initExtensions(
const Context& context)
11465#if CL_HPP_TARGET_OPENCL_VERSION >= 120
11466 Device device = context.getInfo<CL_CONTEXT_DEVICES>().at(0);
11467 cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>()();
11468 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCreateSemaphoreWithPropertiesKHR);
11469 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clReleaseSemaphoreKHR);
11470 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clRetainSemaphoreKHR);
11471 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueWaitSemaphoresKHR);
11472 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueSignalSemaphoresKHR);
11473 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clGetSemaphoreInfoKHR);
11474#ifdef cl_khr_external_semaphore
11475 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clGetSemaphoreHandleForTypeKHR);
11479 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateSemaphoreWithPropertiesKHR);
11480 CL_HPP_INIT_CL_EXT_FCN_PTR_(clReleaseSemaphoreKHR);
11481 CL_HPP_INIT_CL_EXT_FCN_PTR_(clRetainSemaphoreKHR);
11482 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueWaitSemaphoresKHR);
11483 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueSignalSemaphoresKHR);
11484 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetSemaphoreInfoKHR);
11485#ifdef cl_khr_external_semaphore
11486 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetSemaphoreHandleForTypeKHR);
11490 if ((pfn_clCreateSemaphoreWithPropertiesKHR ==
nullptr) &&
11491 (pfn_clReleaseSemaphoreKHR ==
nullptr) &&
11492 (pfn_clRetainSemaphoreKHR ==
nullptr) &&
11493 (pfn_clEnqueueWaitSemaphoresKHR ==
nullptr) &&
11494 (pfn_clEnqueueSignalSemaphoresKHR ==
nullptr) &&
11495#ifdef cl_khr_external_semaphore
11496 (pfn_clGetSemaphoreHandleForTypeKHR ==
nullptr) &&
11498 (pfn_clGetSemaphoreInfoKHR ==
nullptr))
11500 detail::errHandler(CL_INVALID_VALUE, __CREATE_SEMAPHORE_KHR_WITH_PROPERTIES_ERR);
11506CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Semaphore::ext_init_;
11508inline cl_int CommandQueue::enqueueWaitSemaphores(
11509 const vector<Semaphore> &sema_objects,
11510 const vector<cl_semaphore_payload_khr> &sema_payloads,
11511 const vector<Event>* events_wait_list,
11512 Event *event)
const
11515 cl_int err = CL_INVALID_OPERATION;
11517 if (pfn_clEnqueueWaitSemaphoresKHR !=
nullptr) {
11518 err = pfn_clEnqueueWaitSemaphoresKHR(
11520 (cl_uint)sema_objects.size(),
11521 (
const cl_semaphore_khr *) &sema_objects.front(),
11522 (sema_payloads.size() > 0) ? &sema_payloads.front() :
nullptr,
11523 (events_wait_list !=
nullptr) ? (cl_uint) events_wait_list->size() : 0,
11524 (events_wait_list !=
nullptr && events_wait_list->size() > 0) ? (
const cl_event*) &events_wait_list->front() :
nullptr,
11525 (event !=
nullptr) ? &tmp :
nullptr);
11528 detail::errHandler(err, __ENQUEUE_WAIT_SEMAPHORE_KHR_ERR);
11530 if (event !=
nullptr && err == CL_SUCCESS)
11536inline cl_int CommandQueue::enqueueSignalSemaphores(
11537 const vector<Semaphore> &sema_objects,
11538 const vector<cl_semaphore_payload_khr>& sema_payloads,
11539 const vector<Event>* events_wait_list,
11543 cl_int err = CL_INVALID_OPERATION;
11545 if (pfn_clEnqueueSignalSemaphoresKHR !=
nullptr) {
11546 err = pfn_clEnqueueSignalSemaphoresKHR(
11548 (cl_uint)sema_objects.size(),
11549 (
const cl_semaphore_khr*) &sema_objects.front(),
11550 (sema_payloads.size() > 0) ? &sema_payloads.front() :
nullptr,
11551 (events_wait_list !=
nullptr) ? (cl_uint) events_wait_list->size() : 0,
11552 (events_wait_list !=
nullptr && events_wait_list->size() > 0) ? (
const cl_event*) &events_wait_list->front() :
nullptr,
11553 (event !=
nullptr) ? &tmp :
nullptr);
11556 detail::errHandler(err, __ENQUEUE_SIGNAL_SEMAPHORE_KHR_ERR);
11558 if (event !=
nullptr && err == CL_SUCCESS)
11566#if defined(cl_khr_command_buffer)
11570class CommandBufferKhr :
public detail::Wrapper<cl_command_buffer_khr>
11574 CommandBufferKhr() : detail::Wrapper<cl_type>() { }
11576 explicit CommandBufferKhr(
const vector<CommandQueue> &queues,
11577 cl_command_buffer_properties_khr properties = 0,
11578 cl_int* errcode_ret =
nullptr)
11580 cl_command_buffer_properties_khr command_buffer_properties[] = {
11581 CL_COMMAND_BUFFER_FLAGS_KHR, properties, 0
11585 std::call_once(ext_init_, [&] { initExtensions(queues[0].getInfo<CL_QUEUE_DEVICE>()); });
11586 cl_int error = CL_INVALID_OPERATION;
11588 static_assert(
sizeof(cl::CommandQueue) ==
sizeof(cl_command_queue),
11589 "Size of cl::CommandQueue must be equal to size of cl_command_queue");
11591 if (pfn_clCreateCommandBufferKHR)
11593 object_ = pfn_clCreateCommandBufferKHR((cl_uint) queues.size(),
11594 (
const cl_command_queue *) &queues.front(),
11595 command_buffer_properties,
11599 detail::errHandler(error, __CREATE_COMMAND_BUFFER_KHR_ERR);
11600 if (errcode_ret !=
nullptr) {
11601 *errcode_ret = error;
11605 explicit CommandBufferKhr(
const cl_command_buffer_khr& commandBufferKhr,
bool retainObject =
false) :
11606 detail::Wrapper<cl_type>(commandBufferKhr, retainObject) { }
11608 CommandBufferKhr& operator=(
const cl_command_buffer_khr& rhs)
11610 detail::Wrapper<cl_type>::operator=(rhs);
11614 template <
typename T>
11615 cl_int getInfo(cl_command_buffer_info_khr name, T* param)
const
11617 if (pfn_clGetCommandBufferInfoKHR ==
nullptr) {
11618 return detail::errHandler(CL_INVALID_OPERATION,
11619 __GET_COMMAND_BUFFER_INFO_KHR_ERR);
11621 return detail::errHandler(
11622 detail::getInfo(pfn_clGetCommandBufferInfoKHR, object_, name, param),
11623 __GET_COMMAND_BUFFER_INFO_KHR_ERR);
11626 template <cl_command_buffer_info_khr name>
typename
11627 detail::param_traits<detail::cl_command_buffer_info_khr, name>::param_type
11628 getInfo(cl_int* err =
nullptr)
const
11630 typename detail::param_traits<
11631 detail::cl_command_buffer_info_khr, name>::param_type param{};
11632 cl_int result = getInfo(name, ¶m);
11633 if (err !=
nullptr) {
11639 cl_int finalizeCommandBuffer()
const
11641 if (pfn_clFinalizeCommandBufferKHR ==
nullptr) {
11642 return detail::errHandler(CL_INVALID_OPERATION, __FINALIZE_COMMAND_BUFFER_KHR_ERR);
11644 return detail::errHandler(pfn_clFinalizeCommandBufferKHR(object_), __FINALIZE_COMMAND_BUFFER_KHR_ERR);
11647 cl_int enqueueCommandBuffer(vector<CommandQueue> &queues,
11648 const vector<Event>* events =
nullptr,
11649 Event* event =
nullptr)
11651 if (pfn_clEnqueueCommandBufferKHR ==
nullptr) {
11652 return detail::errHandler(CL_INVALID_OPERATION,
11653 __ENQUEUE_COMMAND_BUFFER_KHR_ERR);
11656 static_assert(
sizeof(cl::CommandQueue) ==
sizeof(cl_command_queue),
11657 "Size of cl::CommandQueue must be equal to size of cl_command_queue");
11659 return detail::errHandler(pfn_clEnqueueCommandBufferKHR((cl_uint) queues.size(),
11660 (cl_command_queue *) &queues.front(),
11662 (events !=
nullptr) ? (cl_uint) events->size() : 0,
11663 (events !=
nullptr && events->size() > 0) ? (
const cl_event*) &events->front() :
nullptr,
11664 (cl_event*) event),
11665 __ENQUEUE_COMMAND_BUFFER_KHR_ERR);
11668 cl_int commandBarrierWithWaitList(
const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11669 cl_sync_point_khr* sync_point =
nullptr,
11670 MutableCommandKhr* mutable_handle =
nullptr,
11671 const CommandQueue* command_queue =
nullptr)
11673 if (pfn_clCommandBarrierWithWaitListKHR ==
nullptr) {
11674 return detail::errHandler(CL_INVALID_OPERATION,
11675 __COMMAND_BARRIER_WITH_WAIT_LIST_KHR_ERR);
11678 cl_sync_point_khr tmp_sync_point;
11679 cl_int error = detail::errHandler(
11680 pfn_clCommandBarrierWithWaitListKHR(object_,
11681 (command_queue !=
nullptr) ? (*command_queue)() :
nullptr,
11682#
if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
11685 (sync_points_vec !=
nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11686 (sync_points_vec !=
nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() :
nullptr,
11687 (sync_point !=
nullptr) ? &tmp_sync_point :
nullptr,
11688 (cl_mutable_command_khr*) mutable_handle),
11689 __COMMAND_BARRIER_WITH_WAIT_LIST_KHR_ERR);
11691 if (sync_point !=
nullptr && error == CL_SUCCESS)
11692 *sync_point = tmp_sync_point;
11697 cl_int commandCopyBuffer(
const Buffer& src,
11699 size_type src_offset,
11700 size_type dst_offset,
11702 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11703 cl_sync_point_khr* sync_point =
nullptr,
11704 MutableCommandKhr* mutable_handle =
nullptr,
11705 const CommandQueue* command_queue =
nullptr)
11707 if (pfn_clCommandCopyBufferKHR ==
nullptr) {
11708 return detail::errHandler(CL_INVALID_OPERATION,
11709 __COMMAND_COPY_BUFFER_KHR_ERR);
11712 cl_sync_point_khr tmp_sync_point;
11713 cl_int error = detail::errHandler(
11714 pfn_clCommandCopyBufferKHR(object_,
11715 (command_queue !=
nullptr) ? (*command_queue)() :
nullptr,
11716#
if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
11724 (sync_points_vec !=
nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11725 (sync_points_vec !=
nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() :
nullptr,
11726 (sync_point !=
nullptr) ? &tmp_sync_point :
nullptr,
11727 (cl_mutable_command_khr*) mutable_handle),
11728 __COMMAND_COPY_BUFFER_KHR_ERR);
11730 if (sync_point !=
nullptr && error == CL_SUCCESS)
11731 *sync_point = tmp_sync_point;
11736 cl_int commandCopyBufferRect(
const Buffer& src,
11738 const array<size_type, 3>& src_origin,
11739 const array<size_type, 3>& dst_origin,
11740 const array<size_type, 3>& region,
11741 size_type src_row_pitch,
11742 size_type src_slice_pitch,
11743 size_type dst_row_pitch,
11744 size_type dst_slice_pitch,
11745 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11746 cl_sync_point_khr* sync_point =
nullptr,
11747 MutableCommandKhr* mutable_handle =
nullptr,
11748 const CommandQueue* command_queue =
nullptr)
11750 if (pfn_clCommandCopyBufferRectKHR ==
nullptr) {
11751 return detail::errHandler(CL_INVALID_OPERATION,
11752 __COMMAND_COPY_BUFFER_RECT_KHR_ERR);
11755 cl_sync_point_khr tmp_sync_point;
11756 cl_int error = detail::errHandler(
11757 pfn_clCommandCopyBufferRectKHR(object_,
11758 (command_queue !=
nullptr) ? (*command_queue)() :
nullptr,
11759#
if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
11771 (sync_points_vec !=
nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11772 (sync_points_vec !=
nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() :
nullptr,
11773 (sync_point !=
nullptr) ? &tmp_sync_point :
nullptr,
11774 (cl_mutable_command_khr*) mutable_handle),
11775 __COMMAND_COPY_BUFFER_RECT_KHR_ERR);
11777 if (sync_point !=
nullptr && error == CL_SUCCESS)
11778 *sync_point = tmp_sync_point;
11783 cl_int commandCopyBufferToImage(
const Buffer& src,
11785 size_type src_offset,
11786 const array<size_type, 3>& dst_origin,
11787 const array<size_type, 3>& region,
11788 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11789 cl_sync_point_khr* sync_point =
nullptr,
11790 MutableCommandKhr* mutable_handle =
nullptr,
11791 const CommandQueue* command_queue =
nullptr)
11793 if (pfn_clCommandCopyBufferToImageKHR ==
nullptr) {
11794 return detail::errHandler(CL_INVALID_OPERATION,
11795 __COMMAND_COPY_BUFFER_TO_IMAGE_KHR_ERR);
11798 cl_sync_point_khr tmp_sync_point;
11799 cl_int error = detail::errHandler(
11800 pfn_clCommandCopyBufferToImageKHR(object_,
11801 (command_queue !=
nullptr) ? (*command_queue)() :
nullptr,
11802#
if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
11810 (sync_points_vec !=
nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11811 (sync_points_vec !=
nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() :
nullptr,
11812 (sync_point !=
nullptr) ? &tmp_sync_point :
nullptr,
11813 (cl_mutable_command_khr*) mutable_handle),
11814 __COMMAND_COPY_BUFFER_TO_IMAGE_KHR_ERR);
11816 if (sync_point !=
nullptr && error == CL_SUCCESS)
11817 *sync_point = tmp_sync_point;
11822 cl_int commandCopyImage(
const Image& src,
11824 const array<size_type, 3>& src_origin,
11825 const array<size_type, 3>& dst_origin,
11826 const array<size_type, 3>& region,
11827 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11828 cl_sync_point_khr* sync_point =
nullptr,
11829 MutableCommandKhr* mutable_handle =
nullptr,
11830 const CommandQueue* command_queue =
nullptr)
11832 if (pfn_clCommandCopyImageKHR ==
nullptr) {
11833 return detail::errHandler(CL_INVALID_OPERATION,
11834 __COMMAND_COPY_IMAGE_KHR_ERR);
11837 cl_sync_point_khr tmp_sync_point;
11838 cl_int error = detail::errHandler(
11839 pfn_clCommandCopyImageKHR(object_,
11840 (command_queue !=
nullptr) ? (*command_queue)() :
nullptr,
11841#
if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
11849 (sync_points_vec !=
nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11850 (sync_points_vec !=
nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() :
nullptr,
11851 (sync_point !=
nullptr) ? &tmp_sync_point :
nullptr,
11852 (cl_mutable_command_khr*) mutable_handle),
11853 __COMMAND_COPY_IMAGE_KHR_ERR);
11855 if (sync_point !=
nullptr && error == CL_SUCCESS)
11856 *sync_point = tmp_sync_point;
11861 cl_int commandCopyImageToBuffer(
const Image& src,
11863 const array<size_type, 3>& src_origin,
11864 const array<size_type, 3>& region,
11865 size_type dst_offset,
11866 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11867 cl_sync_point_khr* sync_point =
nullptr,
11868 MutableCommandKhr* mutable_handle =
nullptr,
11869 const CommandQueue* command_queue =
nullptr)
11871 if (pfn_clCommandCopyImageToBufferKHR ==
nullptr) {
11872 return detail::errHandler(CL_INVALID_OPERATION,
11873 __COMMAND_COPY_IMAGE_TO_BUFFER_KHR_ERR);
11876 cl_sync_point_khr tmp_sync_point;
11877 cl_int error = detail::errHandler(
11878 pfn_clCommandCopyImageToBufferKHR(object_,
11879 (command_queue !=
nullptr) ? (*command_queue)() :
nullptr,
11880#
if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
11888 (sync_points_vec !=
nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11889 (sync_points_vec !=
nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() :
nullptr,
11890 (sync_point !=
nullptr) ? &tmp_sync_point :
nullptr,
11891 (cl_mutable_command_khr*) mutable_handle),
11892 __COMMAND_COPY_IMAGE_TO_BUFFER_KHR_ERR);
11894 if (sync_point !=
nullptr && error == CL_SUCCESS)
11895 *sync_point = tmp_sync_point;
11900 template<
typename PatternType>
11901 cl_int commandFillBuffer(
const Buffer& buffer,
11902 PatternType pattern,
11905 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11906 cl_sync_point_khr* sync_point =
nullptr,
11907 MutableCommandKhr* mutable_handle =
nullptr,
11908 const CommandQueue* command_queue =
nullptr)
11910 if (pfn_clCommandFillBufferKHR ==
nullptr) {
11911 return detail::errHandler(CL_INVALID_OPERATION,
11912 __COMMAND_FILL_BUFFER_KHR_ERR);
11915 cl_sync_point_khr tmp_sync_point;
11916 cl_int error = detail::errHandler(
11917 pfn_clCommandFillBufferKHR(object_,
11918 (command_queue !=
nullptr) ? (*command_queue)() :
nullptr,
11919#
if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
11923 static_cast<void*
>(&pattern),
11924 sizeof(PatternType),
11927 (sync_points_vec !=
nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11928 (sync_points_vec !=
nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() :
nullptr,
11929 (sync_point !=
nullptr) ? &tmp_sync_point :
nullptr,
11930 (cl_mutable_command_khr*) mutable_handle),
11931 __COMMAND_FILL_BUFFER_KHR_ERR);
11933 if (sync_point !=
nullptr && error == CL_SUCCESS)
11934 *sync_point = tmp_sync_point;
11939 cl_int commandFillImage(
const Image& image,
11940 cl_float4 fillColor,
11941 const array<size_type, 3>& origin,
11942 const array<size_type, 3>& region,
11943 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11944 cl_sync_point_khr* sync_point =
nullptr,
11945 MutableCommandKhr* mutable_handle =
nullptr,
11946 const CommandQueue* command_queue =
nullptr)
11948 if (pfn_clCommandFillImageKHR ==
nullptr) {
11949 return detail::errHandler(CL_INVALID_OPERATION,
11950 __COMMAND_FILL_IMAGE_KHR_ERR);
11953 cl_sync_point_khr tmp_sync_point;
11954 cl_int error = detail::errHandler(
11955 pfn_clCommandFillImageKHR(object_,
11956 (command_queue !=
nullptr) ? (*command_queue)() :
nullptr,
11957#
if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
11964 (sync_points_vec !=
nullptr) ? (cl_uint) sync_points_vec->size() : 0,
11965 (sync_points_vec !=
nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() :
nullptr,
11966 (sync_point !=
nullptr) ? &tmp_sync_point :
nullptr,
11967 (cl_mutable_command_khr*) mutable_handle),
11968 __COMMAND_FILL_IMAGE_KHR_ERR);
11970 if (sync_point !=
nullptr && error == CL_SUCCESS)
11971 *sync_point = tmp_sync_point;
11976 cl_int commandNDRangeKernel(
11977#
if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
11978 const cl::vector<cl_command_properties_khr> &properties,
11980 const cl::vector<cl_ndrange_kernel_command_properties_khr> &properties,
11982 const Kernel& kernel,
11983 const NDRange& offset,
11984 const NDRange& global,
11985 const NDRange& local = NullRange,
11986 const vector<cl_sync_point_khr>* sync_points_vec =
nullptr,
11987 cl_sync_point_khr* sync_point =
nullptr,
11988 MutableCommandKhr* mutable_handle =
nullptr,
11989 const CommandQueue* command_queue =
nullptr)
11991 if (pfn_clCommandNDRangeKernelKHR ==
nullptr) {
11992 return detail::errHandler(CL_INVALID_OPERATION,
11993 __COMMAND_NDRANGE_KERNEL_KHR_ERR);
11996 cl_sync_point_khr tmp_sync_point;
11997 cl_int error = detail::errHandler(
11998 pfn_clCommandNDRangeKernelKHR(object_,
11999 (command_queue !=
nullptr) ? (*command_queue)() :
nullptr,
12000 properties.empty() ?
nullptr : properties.data(),
12002 (cl_uint) global.dimensions(),
12003 offset.dimensions() != 0 ? (
const size_type*) offset :
nullptr,
12004 (
const size_type*) global,
12005 local.dimensions() != 0 ? (
const size_type*) local :
nullptr,
12006 (sync_points_vec !=
nullptr) ? (cl_uint) sync_points_vec->size() : 0,
12007 (sync_points_vec !=
nullptr && sync_points_vec->size() > 0) ? &sync_points_vec->front() :
nullptr,
12008 (sync_point !=
nullptr) ? &tmp_sync_point :
nullptr,
12009 (cl_mutable_command_khr*) mutable_handle),
12010 __COMMAND_NDRANGE_KERNEL_KHR_ERR);
12012 if (sync_point !=
nullptr && error == CL_SUCCESS)
12013 *sync_point = tmp_sync_point;
12018#if defined(cl_khr_command_buffer_mutable_dispatch)
12019#if CL_KHR_COMMAND_BUFFER_MUTABLE_DISPATCH_EXTENSION_VERSION < \
12020 CL_MAKE_VERSION(0, 9, 2)
12021 cl_int updateMutableCommands(
const cl_mutable_base_config_khr* mutable_config)
12023 if (pfn_clUpdateMutableCommandsKHR ==
nullptr) {
12024 return detail::errHandler(CL_INVALID_OPERATION,
12025 __UPDATE_MUTABLE_COMMANDS_KHR_ERR);
12027 return detail::errHandler(pfn_clUpdateMutableCommandsKHR(object_, mutable_config),
12028 __UPDATE_MUTABLE_COMMANDS_KHR_ERR);
12031 template <
int ArrayLength>
12032 cl_int updateMutableCommands(std::array<cl_command_buffer_update_type_khr,
12033 ArrayLength> &config_types,
12034 std::array<const void *, ArrayLength> &configs) {
12035 if (pfn_clUpdateMutableCommandsKHR ==
nullptr) {
12036 return detail::errHandler(CL_INVALID_OPERATION,
12037 __UPDATE_MUTABLE_COMMANDS_KHR_ERR);
12039 return detail::errHandler(
12040 pfn_clUpdateMutableCommandsKHR(
12042 static_cast<cl_uint
>(configs.size()),
12043 config_types.empty() ?
nullptr : config_types.data(),
12044 configs.empty() ?
nullptr : configs.data()),
12045 __UPDATE_MUTABLE_COMMANDS_KHR_ERR);
12051 static std::once_flag ext_init_;
12053 static void initExtensions(
const cl::Device& device)
12055#if CL_HPP_TARGET_OPENCL_VERSION >= 120
12056 cl_platform_id platform = device.
getInfo<CL_DEVICE_PLATFORM>()();
12057 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCreateCommandBufferKHR);
12058 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clFinalizeCommandBufferKHR);
12059 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clRetainCommandBufferKHR);
12060 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clReleaseCommandBufferKHR);
12061 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clGetCommandBufferInfoKHR);
12062 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueCommandBufferKHR);
12063 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandBarrierWithWaitListKHR);
12064 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandCopyBufferKHR);
12065 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandCopyBufferRectKHR);
12066 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandCopyBufferToImageKHR);
12067 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandCopyImageKHR);
12068 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandCopyImageToBufferKHR);
12069 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandFillBufferKHR);
12070 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandFillImageKHR);
12071 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCommandNDRangeKernelKHR);
12072#if defined(cl_khr_command_buffer_mutable_dispatch)
12073 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clUpdateMutableCommandsKHR);
12074 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clGetMutableCommandInfoKHR);
12076#elif CL_HPP_TARGET_OPENCL_VERSION >= 110
12077 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateCommandBufferKHR);
12078 CL_HPP_INIT_CL_EXT_FCN_PTR_(clFinalizeCommandBufferKHR);
12079 CL_HPP_INIT_CL_EXT_FCN_PTR_(clRetainCommandBufferKHR);
12080 CL_HPP_INIT_CL_EXT_FCN_PTR_(clReleaseCommandBufferKHR);
12081 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetCommandBufferInfoKHR);
12082 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueCommandBufferKHR);
12083 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandBarrierWithWaitListKHR);
12084 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandCopyBufferKHR);
12085 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandCopyBufferRectKHR);
12086 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandCopyBufferToImageKHR);
12087 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandCopyImageKHR);
12088 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandCopyImageToBufferKHR);
12089 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandFillBufferKHR);
12090 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandFillImageKHR);
12091 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCommandNDRangeKernelKHR);
12092#if defined(cl_khr_command_buffer_mutable_dispatch)
12093 CL_HPP_INIT_CL_EXT_FCN_PTR_(clUpdateMutableCommandsKHR);
12094 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetMutableCommandInfoKHR);
12097 if ((pfn_clCreateCommandBufferKHR ==
nullptr) &&
12098 (pfn_clFinalizeCommandBufferKHR ==
nullptr) &&
12099 (pfn_clRetainCommandBufferKHR ==
nullptr) &&
12100 (pfn_clReleaseCommandBufferKHR ==
nullptr) &&
12101 (pfn_clGetCommandBufferInfoKHR ==
nullptr) &&
12102 (pfn_clEnqueueCommandBufferKHR ==
nullptr) &&
12103 (pfn_clCommandBarrierWithWaitListKHR ==
nullptr) &&
12104 (pfn_clCommandCopyBufferKHR ==
nullptr) &&
12105 (pfn_clCommandCopyBufferRectKHR ==
nullptr) &&
12106 (pfn_clCommandCopyBufferToImageKHR ==
nullptr) &&
12107 (pfn_clCommandCopyImageKHR ==
nullptr) &&
12108 (pfn_clCommandCopyImageToBufferKHR ==
nullptr) &&
12109 (pfn_clCommandFillBufferKHR ==
nullptr) &&
12110 (pfn_clCommandFillImageKHR ==
nullptr) &&
12111 (pfn_clCommandNDRangeKernelKHR ==
nullptr)
12112#
if defined(cl_khr_command_buffer_mutable_dispatch)
12113 && (pfn_clUpdateMutableCommandsKHR ==
nullptr)
12114 && (pfn_clGetMutableCommandInfoKHR ==
nullptr)
12118 detail::errHandler(CL_INVALID_VALUE, __CREATE_COMMAND_BUFFER_KHR_ERR);
12123CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag CommandBufferKhr::ext_init_;
12125#if defined(cl_khr_command_buffer_mutable_dispatch)
12129class MutableCommandKhr :
public detail::Wrapper<cl_mutable_command_khr>
12133 MutableCommandKhr() : detail::Wrapper<cl_type>() { }
12135 explicit MutableCommandKhr(
const cl_mutable_command_khr& mutableCommandKhr,
bool retainObject =
false) :
12136 detail::Wrapper<cl_type>(mutableCommandKhr, retainObject) { }
12138 MutableCommandKhr& operator=(
const cl_mutable_command_khr& rhs)
12140 detail::Wrapper<cl_type>::operator=(rhs);
12144 template <
typename T>
12145 cl_int getInfo(cl_mutable_command_info_khr name, T* param)
const
12147 if (pfn_clGetMutableCommandInfoKHR ==
nullptr) {
12148 return detail::errHandler(CL_INVALID_OPERATION,
12149 __GET_MUTABLE_COMMAND_INFO_KHR_ERR);
12151 return detail::errHandler(
12152 detail::getInfo(pfn_clGetMutableCommandInfoKHR, object_, name, param),
12153 __GET_MUTABLE_COMMAND_INFO_KHR_ERR);
12156 template <cl_mutable_command_info_khr name>
typename
12157 detail::param_traits<detail::cl_mutable_command_info_khr, name>::param_type
12158 getInfo(cl_int* err =
nullptr)
const
12160 typename detail::param_traits<
12161 detail::cl_mutable_command_info_khr, name>::param_type param{};
12162 cl_int result = getInfo(name, ¶m);
12163 if (err !=
nullptr) {
12174#undef CL_HPP_ERR_STR_
12175#if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS)
12176#undef __GET_DEVICE_INFO_ERR
12177#undef __GET_PLATFORM_INFO_ERR
12178#undef __GET_DEVICE_IDS_ERR
12179#undef __GET_PLATFORM_IDS_ERR
12180#undef __GET_CONTEXT_INFO_ERR
12181#undef __GET_EVENT_INFO_ERR
12182#undef __GET_EVENT_PROFILE_INFO_ERR
12183#undef __GET_MEM_OBJECT_INFO_ERR
12184#undef __GET_IMAGE_INFO_ERR
12185#undef __GET_SAMPLER_INFO_ERR
12186#undef __GET_KERNEL_INFO_ERR
12187#undef __GET_KERNEL_ARG_INFO_ERR
12188#undef __GET_KERNEL_SUB_GROUP_INFO_ERR
12189#undef __GET_KERNEL_WORK_GROUP_INFO_ERR
12190#undef __GET_KERNEL_SUGGESTED_LWS_ERR
12191#undef __GET_PROGRAM_INFO_ERR
12192#undef __GET_PROGRAM_BUILD_INFO_ERR
12193#undef __GET_COMMAND_QUEUE_INFO_ERR
12194#undef __CREATE_CONTEXT_ERR
12195#undef __CREATE_CONTEXT_FROM_TYPE_ERR
12196#undef __CREATE_COMMAND_BUFFER_KHR_ERR
12197#undef __GET_COMMAND_BUFFER_INFO_KHR_ERR
12198#undef __FINALIZE_COMMAND_BUFFER_KHR_ERR
12199#undef __ENQUEUE_COMMAND_BUFFER_KHR_ERR
12200#undef __COMMAND_BARRIER_WITH_WAIT_LIST_KHR_ERR
12201#undef __COMMAND_COPY_BUFFER_KHR_ERR
12202#undef __COMMAND_COPY_BUFFER_RECT_KHR_ERR
12203#undef __COMMAND_COPY_BUFFER_TO_IMAGE_KHR_ERR
12204#undef __COMMAND_COPY_IMAGE_KHR_ERR
12205#undef __COMMAND_COPY_IMAGE_TO_BUFFER_KHR_ERR
12206#undef __COMMAND_FILL_BUFFER_KHR_ERR
12207#undef __COMMAND_FILL_IMAGE_KHR_ERR
12208#undef __COMMAND_NDRANGE_KERNEL_KHR_ERR
12209#undef __UPDATE_MUTABLE_COMMANDS_KHR_ERR
12210#undef __GET_MUTABLE_COMMAND_INFO_KHR_ERR
12211#undef __RETAIN_COMMAND_BUFFER_KHR_ERR
12212#undef __RELEASE_COMMAND_BUFFER_KHR_ERR
12213#undef __GET_SUPPORTED_IMAGE_FORMATS_ERR
12214#undef __SET_CONTEXT_DESTRUCTOR_CALLBACK_ERR
12215#undef __CREATE_BUFFER_ERR
12217#undef __CREATE_SUBBUFFER_ERR
12218#undef __CREATE_GL_BUFFER_ERR
12219#undef __CREATE_GL_RENDER_BUFFER_ERR
12220#undef __GET_GL_OBJECT_INFO_ERR
12221#undef __CREATE_IMAGE_ERR
12222#undef __CREATE_GL_TEXTURE_ERR
12223#undef __IMAGE_DIMENSION_ERR
12224#undef __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR
12225#undef __CREATE_USER_EVENT_ERR
12226#undef __SET_USER_EVENT_STATUS_ERR
12227#undef __SET_EVENT_CALLBACK_ERR
12228#undef __WAIT_FOR_EVENTS_ERR
12229#undef __CREATE_KERNEL_ERR
12230#undef __SET_KERNEL_ARGS_ERR
12231#undef __CREATE_PROGRAM_WITH_SOURCE_ERR
12232#undef __CREATE_PROGRAM_WITH_BINARY_ERR
12233#undef __CREATE_PROGRAM_WITH_IL_ERR
12234#undef __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR
12235#undef __BUILD_PROGRAM_ERR
12236#undef __COMPILE_PROGRAM_ERR
12237#undef __LINK_PROGRAM_ERR
12238#undef __CREATE_KERNELS_IN_PROGRAM_ERR
12239#undef __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR
12240#undef __CREATE_SAMPLER_WITH_PROPERTIES_ERR
12241#undef __SET_COMMAND_QUEUE_PROPERTY_ERR
12242#undef __ENQUEUE_READ_BUFFER_ERR
12243#undef __ENQUEUE_READ_BUFFER_RECT_ERR
12244#undef __ENQUEUE_WRITE_BUFFER_ERR
12245#undef __ENQUEUE_WRITE_BUFFER_RECT_ERR
12246#undef __ENQEUE_COPY_BUFFER_ERR
12247#undef __ENQEUE_COPY_BUFFER_RECT_ERR
12248#undef __ENQUEUE_FILL_BUFFER_ERR
12249#undef __ENQUEUE_READ_IMAGE_ERR
12250#undef __ENQUEUE_WRITE_IMAGE_ERR
12251#undef __ENQUEUE_COPY_IMAGE_ERR
12252#undef __ENQUEUE_FILL_IMAGE_ERR
12253#undef __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR
12254#undef __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR
12255#undef __ENQUEUE_MAP_BUFFER_ERR
12256#undef __ENQUEUE_MAP_IMAGE_ERR
12257#undef __ENQUEUE_MAP_SVM_ERR
12258#undef __ENQUEUE_FILL_SVM_ERR
12259#undef __ENQUEUE_COPY_SVM_ERR
12260#undef __ENQUEUE_UNMAP_SVM_ERR
12261#undef __ENQUEUE_MAP_IMAGE_ERR
12262#undef __ENQUEUE_UNMAP_MEM_OBJECT_ERR
12263#undef __ENQUEUE_NDRANGE_KERNEL_ERR
12264#undef __ENQUEUE_NATIVE_KERNEL
12265#undef __ENQUEUE_MIGRATE_MEM_OBJECTS_ERR
12266#undef __ENQUEUE_MIGRATE_SVM_ERR
12267#undef __ENQUEUE_ACQUIRE_GL_ERR
12268#undef __ENQUEUE_RELEASE_GL_ERR
12269#undef __CREATE_PIPE_ERR
12270#undef __GET_PIPE_INFO_ERR
12272#undef __RELEASE_ERR
12275#undef __VECTOR_CAPACITY_ERR
12276#undef __CREATE_SUB_DEVICES_ERR
12277#undef __ENQUEUE_ACQUIRE_EXTERNAL_MEMORY_ERR
12278#undef __ENQUEUE_RELEASE_EXTERNAL_MEMORY_ERR
12279#undef __ENQUEUE_MARKER_ERR
12280#undef __ENQUEUE_WAIT_FOR_EVENTS_ERR
12281#undef __ENQUEUE_BARRIER_ERR
12282#undef __UNLOAD_COMPILER_ERR
12283#undef __CREATE_GL_TEXTURE_2D_ERR
12284#undef __CREATE_GL_TEXTURE_3D_ERR
12285#undef __CREATE_IMAGE2D_ERR
12286#undef __CREATE_IMAGE3D_ERR
12287#undef __CREATE_COMMAND_QUEUE_ERR
12288#undef __ENQUEUE_TASK_ERR
12289#undef __CREATE_SAMPLER_ERR
12290#undef __ENQUEUE_MARKER_WAIT_LIST_ERR
12291#undef __ENQUEUE_BARRIER_WAIT_LIST_ERR
12292#undef __CLONE_KERNEL_ERR
12293#undef __GET_HOST_TIMER_ERR
12294#undef __GET_DEVICE_AND_HOST_TIMER_ERR
12295#undef __GET_SEMAPHORE_KHR_INFO_ERR
12296#undef __CREATE_SEMAPHORE_KHR_WITH_PROPERTIES_ERR
12297#undef __GET_IMAGE_REQUIREMENT_INFO_EXT_ERR
12298#undef __ENQUEUE_WAIT_SEMAPHORE_KHR_ERR
12299#undef __ENQUEUE_SIGNAL_SEMAPHORE_KHR_ERR
12300#undef __RETAIN_SEMAPHORE_KHR_ERR
12301#undef __RELEASE_SEMAPHORE_KHR_ERR
12302#undef __GET_SEMAPHORE_HANDLE_FOR_TYPE_KHR_ERR
12307#undef CL_HPP_CREATE_CL_EXT_FCN_PTR_ALIAS_
12308#undef CL_HPP_INIT_CL_EXT_FCN_PTR_
12309#undef CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_
12311#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)