396 #if !defined(CL_HPP_USE_DX_INTEROP) && defined(USE_DX_INTEROP)
397 # pragma message("opencl.hpp: USE_DX_INTEROP is deprecated. Define CL_HPP_USE_DX_INTEROP instead")
398 # define CL_HPP_USE_DX_INTEROP
400 #if !defined(CL_HPP_USE_CL_DEVICE_FISSION) && defined(USE_CL_DEVICE_FISSION)
401 # pragma message("opencl.hpp: USE_CL_DEVICE_FISSION is deprecated. Define CL_HPP_USE_CL_DEVICE_FISSION instead")
402 # define CL_HPP_USE_CL_DEVICE_FISSION
404 #if !defined(CL_HPP_ENABLE_EXCEPTIONS) && defined(__CL_ENABLE_EXCEPTIONS)
405 # pragma message("opencl.hpp: __CL_ENABLE_EXCEPTIONS is deprecated. Define CL_HPP_ENABLE_EXCEPTIONS instead")
406 # define CL_HPP_ENABLE_EXCEPTIONS
408 #if !defined(CL_HPP_NO_STD_VECTOR) && defined(__NO_STD_VECTOR)
409 # pragma message("opencl.hpp: __NO_STD_VECTOR is deprecated. Define CL_HPP_NO_STD_VECTOR instead")
410 # define CL_HPP_NO_STD_VECTOR
412 #if !defined(CL_HPP_NO_STD_STRING) && defined(__NO_STD_STRING)
413 # pragma message("opencl.hpp: __NO_STD_STRING is deprecated. Define CL_HPP_NO_STD_STRING instead")
414 # define CL_HPP_NO_STD_STRING
416 #if defined(VECTOR_CLASS)
417 # pragma message("opencl.hpp: VECTOR_CLASS is deprecated. Alias cl::vector instead")
419 #if defined(STRING_CLASS)
420 # pragma message("opencl.hpp: STRING_CLASS is deprecated. Alias cl::string instead.")
422 #if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS) && defined(__CL_USER_OVERRIDE_ERROR_STRINGS)
423 # pragma message("opencl.hpp: __CL_USER_OVERRIDE_ERROR_STRINGS is deprecated. Define CL_HPP_USER_OVERRIDE_ERROR_STRINGS instead")
424 # define CL_HPP_USER_OVERRIDE_ERROR_STRINGS
429 #if defined(__USE_DEV_VECTOR)
430 # pragma message("opencl.hpp: __USE_DEV_VECTOR is no longer supported. Expect compilation errors")
432 #if defined(__USE_DEV_STRING)
433 # pragma message("opencl.hpp: __USE_DEV_STRING is no longer supported. Expect compilation errors")
437 #if !defined(CL_HPP_TARGET_OPENCL_VERSION)
438 # pragma message("opencl.hpp: CL_HPP_TARGET_OPENCL_VERSION is not defined. It will default to 220 (OpenCL 2.2)")
439 # define CL_HPP_TARGET_OPENCL_VERSION 220
441 #if CL_HPP_TARGET_OPENCL_VERSION != 100 && \
442 CL_HPP_TARGET_OPENCL_VERSION != 110 && \
443 CL_HPP_TARGET_OPENCL_VERSION != 120 && \
444 CL_HPP_TARGET_OPENCL_VERSION != 200 && \
445 CL_HPP_TARGET_OPENCL_VERSION != 210 && \
446 CL_HPP_TARGET_OPENCL_VERSION != 220 && \
447 CL_HPP_TARGET_OPENCL_VERSION != 300
448 # pragma message("opencl.hpp: CL_HPP_TARGET_OPENCL_VERSION is not a valid value (100, 110, 120, 200, 210, 220 or 300). It will be set to 220")
449 # undef CL_HPP_TARGET_OPENCL_VERSION
450 # define CL_HPP_TARGET_OPENCL_VERSION 220
454 #if defined(CL_TARGET_OPENCL_VERSION)
457 #if CL_TARGET_OPENCL_VERSION < CL_HPP_TARGET_OPENCL_VERSION
458 # pragma message("CL_TARGET_OPENCL_VERSION is already defined as is lower than CL_HPP_TARGET_OPENCL_VERSION")
461 # define CL_TARGET_OPENCL_VERSION CL_HPP_TARGET_OPENCL_VERSION
464 #if !defined(CL_HPP_MINIMUM_OPENCL_VERSION)
465 # define CL_HPP_MINIMUM_OPENCL_VERSION 200
467 #if CL_HPP_MINIMUM_OPENCL_VERSION != 100 && \
468 CL_HPP_MINIMUM_OPENCL_VERSION != 110 && \
469 CL_HPP_MINIMUM_OPENCL_VERSION != 120 && \
470 CL_HPP_MINIMUM_OPENCL_VERSION != 200 && \
471 CL_HPP_MINIMUM_OPENCL_VERSION != 210 && \
472 CL_HPP_MINIMUM_OPENCL_VERSION != 220 && \
473 CL_HPP_MINIMUM_OPENCL_VERSION != 300
474 # pragma message("opencl.hpp: CL_HPP_MINIMUM_OPENCL_VERSION is not a valid value (100, 110, 120, 200, 210, 220 or 300). It will be set to 100")
475 # undef CL_HPP_MINIMUM_OPENCL_VERSION
476 # define CL_HPP_MINIMUM_OPENCL_VERSION 100
478 #if CL_HPP_MINIMUM_OPENCL_VERSION > CL_HPP_TARGET_OPENCL_VERSION
479 # error "CL_HPP_MINIMUM_OPENCL_VERSION must not be greater than CL_HPP_TARGET_OPENCL_VERSION"
482 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 100 && !defined(CL_USE_DEPRECATED_OPENCL_1_0_APIS)
483 # define CL_USE_DEPRECATED_OPENCL_1_0_APIS
485 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 110 && !defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
486 # define CL_USE_DEPRECATED_OPENCL_1_1_APIS
488 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 120 && !defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
489 # define CL_USE_DEPRECATED_OPENCL_1_2_APIS
491 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 200 && !defined(CL_USE_DEPRECATED_OPENCL_2_0_APIS)
492 # define CL_USE_DEPRECATED_OPENCL_2_0_APIS
494 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 210 && !defined(CL_USE_DEPRECATED_OPENCL_2_1_APIS)
495 # define CL_USE_DEPRECATED_OPENCL_2_1_APIS
497 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 220 && !defined(CL_USE_DEPRECATED_OPENCL_2_2_APIS)
498 # define CL_USE_DEPRECATED_OPENCL_2_2_APIS
505 #if defined(CL_HPP_USE_DX_INTEROP)
506 #include <CL/cl_d3d10.h>
507 #include <CL/cl_dx9_media_sharing.h>
511 #if defined(_MSC_VER)
519 #if (!defined(_MSC_VER) && __cplusplus < 201103L) || (defined(_MSC_VER) && _MSC_VER < 1700)
520 #error Visual studio 2013 or another C++11-supporting compiler required
524 #if defined(CL_HPP_USE_CL_DEVICE_FISSION) || defined(CL_HPP_USE_CL_SUB_GROUPS_KHR)
525 #include <CL/cl_ext.h>
528 #if defined(__APPLE__) || defined(__MACOSX)
529 #include <OpenCL/opencl.h>
531 #include <CL/opencl.h>
534 #if (__cplusplus >= 201103L || _MSVC_LANG >= 201103L )
535 #define CL_HPP_NOEXCEPT_ noexcept
537 #define CL_HPP_NOEXCEPT_
540 #if __cplusplus >= 201703L
541 # define CL_HPP_DEFINE_STATIC_MEMBER_ inline
542 #elif defined(_MSC_VER)
543 # define CL_HPP_DEFINE_STATIC_MEMBER_ __declspec(selectany)
544 #elif defined(__MINGW32__)
545 # define CL_HPP_DEFINE_STATIC_MEMBER_ __attribute__((selectany))
547 # define CL_HPP_DEFINE_STATIC_MEMBER_ __attribute__((weak))
552 #if !defined(CL_EXT_PREFIX__VERSION_1_1_DEPRECATED)
553 #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
554 #endif // #if !defined(CL_EXT_PREFIX__VERSION_1_1_DEPRECATED)
555 #if !defined(CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED)
556 #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
557 #endif // #if !defined(CL_EXT_PREFIX__VERSION_1_1_DEPRECATED)
559 #if !defined(CL_EXT_PREFIX__VERSION_1_2_DEPRECATED)
560 #define CL_EXT_PREFIX__VERSION_1_2_DEPRECATED
561 #endif // #if !defined(CL_EXT_PREFIX__VERSION_1_2_DEPRECATED)
562 #if !defined(CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED)
563 #define CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED
564 #endif // #if !defined(CL_EXT_PREFIX__VERSION_1_2_DEPRECATED)
566 #if !defined(CL_CALLBACK)
575 #include <functional>
579 #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY)
581 using size_type = ::size_t;
583 #else // #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY)
585 using size_type = size_t;
587 #endif // #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY)
590 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
592 #endif // #if defined(CL_HPP_ENABLE_EXCEPTIONS)
594 #if !defined(CL_HPP_NO_STD_VECTOR)
597 template <
class T,
class Alloc = std::allocator<T> >
598 using vector = std::vector<T, Alloc>;
600 #endif // #if !defined(CL_HPP_NO_STD_VECTOR)
602 #if !defined(CL_HPP_NO_STD_STRING)
605 using string = std::string;
607 #endif // #if !defined(CL_HPP_NO_STD_STRING)
609 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
611 #if !defined(CL_HPP_NO_STD_UNIQUE_PTR)
616 template<
class T,
class D>
617 using pointer = std::unique_ptr<T, D>;
620 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200
621 #if !defined(CL_HPP_NO_STD_ARRAY)
624 template <
class T,
size_type N >
625 using array = std::array<T, N>;
627 #endif // #if !defined(CL_HPP_NO_STD_ARRAY)
631 #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY)
633 namespace compatibility {
648 for (
int i = 0; i < N; ++i) {
653 size_t(
const array<size_type, N> &rhs)
655 for (
int i = 0; i < N; ++i) {
660 size_type& operator[](
int index)
665 const size_type& operator[](
int index)
const
671 operator size_type* () {
return data_; }
674 operator const size_type* ()
const {
return data_; }
676 operator array<size_type, N>()
const
678 array<size_type, N> ret;
680 for (
int i = 0; i < N; ++i) {
689 using size_t = compatibility::size_t<N>;
691 #endif // #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY)
696 using size_t_array = array<size_type, 3>;
709 #define CL_HPP_INIT_CL_EXT_FCN_PTR_(name) \
711 pfn_##name = (PFN_##name) \
712 clGetExtensionFunctionAddress(#name); \
717 #define CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, name) \
719 pfn_##name = (PFN_##name) \
720 clGetExtensionFunctionAddressForPlatform(platform, #name); \
729 class DeviceCommandQueue;
734 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
739 class Error :
public std::exception
743 const char * errStr_;
754 Error(cl_int err,
const char * errStr = NULL) : err_(err), errStr_(errStr)
763 virtual const char * what()
const throw ()
765 if (errStr_ == NULL) {
777 cl_int err(
void)
const {
return err_; }
779 #define CL_HPP_ERR_STR_(x) #x
781 #define CL_HPP_ERR_STR_(x) NULL
782 #endif // CL_HPP_ENABLE_EXCEPTIONS
787 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
788 static inline cl_int errHandler (
790 const char * errStr = NULL)
792 if (err != CL_SUCCESS) {
793 throw Error(err, errStr);
798 static inline cl_int errHandler (cl_int err,
const char * errStr = NULL)
803 #endif // CL_HPP_ENABLE_EXCEPTIONS
809 #if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS)
810 #define __GET_DEVICE_INFO_ERR CL_HPP_ERR_STR_(clGetDeviceInfo)
811 #define __GET_PLATFORM_INFO_ERR CL_HPP_ERR_STR_(clGetPlatformInfo)
812 #define __GET_DEVICE_IDS_ERR CL_HPP_ERR_STR_(clGetDeviceIDs)
813 #define __GET_PLATFORM_IDS_ERR CL_HPP_ERR_STR_(clGetPlatformIDs)
814 #define __GET_CONTEXT_INFO_ERR CL_HPP_ERR_STR_(clGetContextInfo)
815 #define __GET_EVENT_INFO_ERR CL_HPP_ERR_STR_(clGetEventInfo)
816 #define __GET_EVENT_PROFILE_INFO_ERR CL_HPP_ERR_STR_(clGetEventProfileInfo)
817 #define __GET_MEM_OBJECT_INFO_ERR CL_HPP_ERR_STR_(clGetMemObjectInfo)
818 #define __GET_IMAGE_INFO_ERR CL_HPP_ERR_STR_(clGetImageInfo)
819 #define __GET_SAMPLER_INFO_ERR CL_HPP_ERR_STR_(clGetSamplerInfo)
820 #define __GET_KERNEL_INFO_ERR CL_HPP_ERR_STR_(clGetKernelInfo)
821 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
822 #define __GET_KERNEL_ARG_INFO_ERR CL_HPP_ERR_STR_(clGetKernelArgInfo)
823 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
824 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
825 #define __GET_KERNEL_SUB_GROUP_INFO_ERR CL_HPP_ERR_STR_(clGetKernelSubGroupInfo)
826 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200
827 #define __GET_KERNEL_WORK_GROUP_INFO_ERR CL_HPP_ERR_STR_(clGetKernelWorkGroupInfo)
828 #define __GET_PROGRAM_INFO_ERR CL_HPP_ERR_STR_(clGetProgramInfo)
829 #define __GET_PROGRAM_BUILD_INFO_ERR CL_HPP_ERR_STR_(clGetProgramBuildInfo)
830 #define __GET_COMMAND_QUEUE_INFO_ERR CL_HPP_ERR_STR_(clGetCommandQueueInfo)
832 #define __CREATE_CONTEXT_ERR CL_HPP_ERR_STR_(clCreateContext)
833 #define __CREATE_CONTEXT_FROM_TYPE_ERR CL_HPP_ERR_STR_(clCreateContextFromType)
834 #define __GET_SUPPORTED_IMAGE_FORMATS_ERR CL_HPP_ERR_STR_(clGetSupportedImageFormats)
836 #define __CREATE_BUFFER_ERR CL_HPP_ERR_STR_(clCreateBuffer)
837 #define __COPY_ERR CL_HPP_ERR_STR_(cl::copy)
838 #define __CREATE_SUBBUFFER_ERR CL_HPP_ERR_STR_(clCreateSubBuffer)
839 #define __CREATE_GL_BUFFER_ERR CL_HPP_ERR_STR_(clCreateFromGLBuffer)
840 #define __CREATE_GL_RENDER_BUFFER_ERR CL_HPP_ERR_STR_(clCreateFromGLBuffer)
841 #define __GET_GL_OBJECT_INFO_ERR CL_HPP_ERR_STR_(clGetGLObjectInfo)
842 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
843 #define __CREATE_IMAGE_ERR CL_HPP_ERR_STR_(clCreateImage)
844 #define __CREATE_GL_TEXTURE_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture)
845 #define __IMAGE_DIMENSION_ERR CL_HPP_ERR_STR_(Incorrect image dimensions)
846 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
847 #define __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR CL_HPP_ERR_STR_(clSetMemObjectDestructorCallback)
849 #define __CREATE_USER_EVENT_ERR CL_HPP_ERR_STR_(clCreateUserEvent)
850 #define __SET_USER_EVENT_STATUS_ERR CL_HPP_ERR_STR_(clSetUserEventStatus)
851 #define __SET_EVENT_CALLBACK_ERR CL_HPP_ERR_STR_(clSetEventCallback)
852 #define __WAIT_FOR_EVENTS_ERR CL_HPP_ERR_STR_(clWaitForEvents)
854 #define __CREATE_KERNEL_ERR CL_HPP_ERR_STR_(clCreateKernel)
855 #define __SET_KERNEL_ARGS_ERR CL_HPP_ERR_STR_(clSetKernelArg)
856 #define __CREATE_PROGRAM_WITH_SOURCE_ERR CL_HPP_ERR_STR_(clCreateProgramWithSource)
857 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
858 #define __CREATE_PROGRAM_WITH_IL_ERR CL_HPP_ERR_STR_(clCreateProgramWithIL)
859 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200
860 #define __CREATE_PROGRAM_WITH_BINARY_ERR CL_HPP_ERR_STR_(clCreateProgramWithBinary)
861 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
862 #define __CREATE_PROGRAM_WITH_IL_ERR CL_HPP_ERR_STR_(clCreateProgramWithIL)
863 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 210
864 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
865 #define __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR CL_HPP_ERR_STR_(clCreateProgramWithBuiltInKernels)
866 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
867 #define __BUILD_PROGRAM_ERR CL_HPP_ERR_STR_(clBuildProgram)
868 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
869 #define __COMPILE_PROGRAM_ERR CL_HPP_ERR_STR_(clCompileProgram)
870 #define __LINK_PROGRAM_ERR CL_HPP_ERR_STR_(clLinkProgram)
871 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
872 #define __CREATE_KERNELS_IN_PROGRAM_ERR CL_HPP_ERR_STR_(clCreateKernelsInProgram)
874 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
875 #define __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR CL_HPP_ERR_STR_(clCreateCommandQueueWithProperties)
876 #define __CREATE_SAMPLER_WITH_PROPERTIES_ERR CL_HPP_ERR_STR_(clCreateSamplerWithProperties)
877 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200
878 #define __SET_COMMAND_QUEUE_PROPERTY_ERR CL_HPP_ERR_STR_(clSetCommandQueueProperty)
879 #define __ENQUEUE_READ_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueReadBuffer)
880 #define __ENQUEUE_READ_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueReadBufferRect)
881 #define __ENQUEUE_WRITE_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueWriteBuffer)
882 #define __ENQUEUE_WRITE_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueWriteBufferRect)
883 #define __ENQEUE_COPY_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueCopyBuffer)
884 #define __ENQEUE_COPY_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueCopyBufferRect)
885 #define __ENQUEUE_FILL_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueFillBuffer)
886 #define __ENQUEUE_READ_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueReadImage)
887 #define __ENQUEUE_WRITE_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueWriteImage)
888 #define __ENQUEUE_COPY_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueCopyImage)
889 #define __ENQUEUE_FILL_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueFillImage)
890 #define __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueCopyImageToBuffer)
891 #define __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueCopyBufferToImage)
892 #define __ENQUEUE_MAP_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueMapBuffer)
893 #define __ENQUEUE_MAP_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueMapImage)
894 #define __ENQUEUE_UNMAP_MEM_OBJECT_ERR CL_HPP_ERR_STR_(clEnqueueUnMapMemObject)
895 #define __ENQUEUE_NDRANGE_KERNEL_ERR CL_HPP_ERR_STR_(clEnqueueNDRangeKernel)
896 #define __ENQUEUE_NATIVE_KERNEL CL_HPP_ERR_STR_(clEnqueueNativeKernel)
897 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
898 #define __ENQUEUE_MIGRATE_MEM_OBJECTS_ERR CL_HPP_ERR_STR_(clEnqueueMigrateMemObjects)
899 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
900 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
901 #define __ENQUEUE_MIGRATE_SVM_ERR CL_HPP_ERR_STR_(clEnqueueSVMMigrateMem)
902 #define __SET_DEFAULT_DEVICE_COMMAND_QUEUE_ERR CL_HPP_ERR_STR_(clSetDefaultDeviceCommandQueue)
903 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 210
906 #define __ENQUEUE_ACQUIRE_GL_ERR CL_HPP_ERR_STR_(clEnqueueAcquireGLObjects)
907 #define __ENQUEUE_RELEASE_GL_ERR CL_HPP_ERR_STR_(clEnqueueReleaseGLObjects)
909 #define __CREATE_PIPE_ERR CL_HPP_ERR_STR_(clCreatePipe)
910 #define __GET_PIPE_INFO_ERR CL_HPP_ERR_STR_(clGetPipeInfo)
913 #define __RETAIN_ERR CL_HPP_ERR_STR_(Retain Object)
914 #define __RELEASE_ERR CL_HPP_ERR_STR_(Release Object)
915 #define __FLUSH_ERR CL_HPP_ERR_STR_(clFlush)
916 #define __FINISH_ERR CL_HPP_ERR_STR_(clFinish)
917 #define __VECTOR_CAPACITY_ERR CL_HPP_ERR_STR_(Vector capacity error)
919 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
920 #define __GET_HOST_TIMER_ERR CL_HPP_ERR_STR_(clGetHostTimer)
921 #define __GET_DEVICE_AND_HOST_TIMER_ERR CL_HPP_ERR_STR_(clGetDeviceAndHostTimer)
923 #if CL_HPP_TARGET_OPENCL_VERSION >= 220
924 #define __SET_PROGRAM_RELEASE_CALLBACK_ERR CL_HPP_ERR_STR_(clSetProgramReleaseCallback)
925 #define __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR CL_HPP_ERR_STR_(clSetProgramSpecializationConstant)
932 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
933 #define __CREATE_SUB_DEVICES_ERR CL_HPP_ERR_STR_(clCreateSubDevices)
935 #define __CREATE_SUB_DEVICES_ERR CL_HPP_ERR_STR_(clCreateSubDevicesEXT)
936 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
941 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
942 #define __ENQUEUE_MARKER_ERR CL_HPP_ERR_STR_(clEnqueueMarker)
943 #define __ENQUEUE_WAIT_FOR_EVENTS_ERR CL_HPP_ERR_STR_(clEnqueueWaitForEvents)
944 #define __ENQUEUE_BARRIER_ERR CL_HPP_ERR_STR_(clEnqueueBarrier)
945 #define __UNLOAD_COMPILER_ERR CL_HPP_ERR_STR_(clUnloadCompiler)
946 #define __CREATE_GL_TEXTURE_2D_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture2D)
947 #define __CREATE_GL_TEXTURE_3D_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture3D)
948 #define __CREATE_IMAGE2D_ERR CL_HPP_ERR_STR_(clCreateImage2D)
949 #define __CREATE_IMAGE3D_ERR CL_HPP_ERR_STR_(clCreateImage3D)
950 #endif // #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
955 #if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
956 #define __CREATE_COMMAND_QUEUE_ERR CL_HPP_ERR_STR_(clCreateCommandQueue)
957 #define __ENQUEUE_TASK_ERR CL_HPP_ERR_STR_(clEnqueueTask)
958 #define __CREATE_SAMPLER_ERR CL_HPP_ERR_STR_(clCreateSampler)
959 #endif // #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
964 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
965 #define __ENQUEUE_MARKER_WAIT_LIST_ERR CL_HPP_ERR_STR_(clEnqueueMarkerWithWaitList)
966 #define __ENQUEUE_BARRIER_WAIT_LIST_ERR CL_HPP_ERR_STR_(clEnqueueBarrierWithWaitList)
967 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
969 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
970 #define __CLONE_KERNEL_ERR CL_HPP_ERR_STR_(clCloneKernel)
971 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 210
973 #endif // CL_HPP_USER_OVERRIDE_ERROR_STRINGS
983 template<
typename Functor,
typename T>
984 inline cl_int getInfoHelper(Functor f, cl_uint name, T* param,
long)
986 return f(name,
sizeof(T), param, NULL);
991 template <
typename Func>
992 inline cl_int getInfoHelper(Func f, cl_uint name, vector<vector<unsigned char>>* param,
int)
994 if (name != CL_PROGRAM_BINARIES) {
995 return CL_INVALID_VALUE;
999 size_type numBinaries = param->size();
1000 vector<unsigned char*> binariesPointers(numBinaries);
1002 for (size_type i = 0; i < numBinaries; ++i)
1004 binariesPointers[i] = (*param)[i].data();
1007 cl_int err = f(name, numBinaries *
sizeof(
unsigned char*), binariesPointers.data(), NULL);
1009 if (err != CL_SUCCESS) {
1019 template <
typename Func,
typename T>
1020 inline cl_int getInfoHelper(Func f, cl_uint name, vector<T>* param,
long)
1023 cl_int err = f(name, 0, NULL, &required);
1024 if (err != CL_SUCCESS) {
1027 const size_type elements = required /
sizeof(T);
1030 vector<T> localData(elements);
1031 err = f(name, required, localData.data(), NULL);
1032 if (err != CL_SUCCESS) {
1036 *param = std::move(localData);
1048 template <
typename Func,
typename T>
1049 inline cl_int getInfoHelper(
1050 Func f, cl_uint name, vector<T>* param,
int,
typename T::cl_type = 0)
1053 cl_int err = f(name, 0, NULL, &required);
1054 if (err != CL_SUCCESS) {
1058 const size_type elements = required /
sizeof(
typename T::cl_type);
1060 vector<typename T::cl_type> value(elements);
1061 err = f(name, required, value.data(), NULL);
1062 if (err != CL_SUCCESS) {
1068 param->resize(elements);
1072 for (size_type i = 0; i < elements; i++) {
1073 (*param)[i] = T(value[i],
true);
1080 template <
typename Func>
1081 inline cl_int getInfoHelper(Func f, cl_uint name,
string* param,
long)
1084 cl_int err = f(name, 0, NULL, &required);
1085 if (err != CL_SUCCESS) {
1092 vector<char> value(required);
1093 err = f(name, required, value.data(), NULL);
1094 if (err != CL_SUCCESS) {
1098 param->assign(begin(value), prev(end(value)));
1108 template <
typename Func,
size_type N>
1109 inline cl_int getInfoHelper(Func f, cl_uint name, array<size_type, N>* param,
long)
1112 cl_int err = f(name, 0, NULL, &required);
1113 if (err != CL_SUCCESS) {
1117 size_type elements = required /
sizeof(size_type);
1118 vector<size_type> value(elements, 0);
1120 err = f(name, required, value.data(), NULL);
1121 if (err != CL_SUCCESS) {
1130 for (size_type i = 0; i < elements; ++i) {
1131 (*param)[i] = value[i];
1137 template<
typename T>
struct ReferenceHandler;
1145 template<
typename Func,
typename T>
1146 inline cl_int getInfoHelper(Func f, cl_uint name, T* param,
int,
typename T::cl_type = 0)
1148 typename T::cl_type value;
1149 cl_int err = f(name,
sizeof(value), &value, NULL);
1150 if (err != CL_SUCCESS) {
1156 err = param->retain();
1157 if (err != CL_SUCCESS) {
1164 #define CL_HPP_PARAM_NAME_INFO_1_0_(F) \
1165 F(cl_platform_info, CL_PLATFORM_PROFILE, string) \
1166 F(cl_platform_info, CL_PLATFORM_VERSION, string) \
1167 F(cl_platform_info, CL_PLATFORM_NAME, string) \
1168 F(cl_platform_info, CL_PLATFORM_VENDOR, string) \
1169 F(cl_platform_info, CL_PLATFORM_EXTENSIONS, string) \
1171 F(cl_device_info, CL_DEVICE_TYPE, cl_device_type) \
1172 F(cl_device_info, CL_DEVICE_VENDOR_ID, cl_uint) \
1173 F(cl_device_info, CL_DEVICE_MAX_COMPUTE_UNITS, cl_uint) \
1174 F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, cl_uint) \
1175 F(cl_device_info, CL_DEVICE_MAX_WORK_GROUP_SIZE, size_type) \
1176 F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_SIZES, cl::vector<size_type>) \
1177 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, cl_uint) \
1178 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT, cl_uint) \
1179 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT, cl_uint) \
1180 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG, cl_uint) \
1181 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT, cl_uint) \
1182 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, cl_uint) \
1183 F(cl_device_info, CL_DEVICE_MAX_CLOCK_FREQUENCY, cl_uint) \
1184 F(cl_device_info, CL_DEVICE_ADDRESS_BITS, cl_uint) \
1185 F(cl_device_info, CL_DEVICE_MAX_READ_IMAGE_ARGS, cl_uint) \
1186 F(cl_device_info, CL_DEVICE_MAX_WRITE_IMAGE_ARGS, cl_uint) \
1187 F(cl_device_info, CL_DEVICE_MAX_MEM_ALLOC_SIZE, cl_ulong) \
1188 F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_WIDTH, size_type) \
1189 F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_HEIGHT, size_type) \
1190 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_WIDTH, size_type) \
1191 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_HEIGHT, size_type) \
1192 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_DEPTH, size_type) \
1193 F(cl_device_info, CL_DEVICE_IMAGE_SUPPORT, cl_bool) \
1194 F(cl_device_info, CL_DEVICE_MAX_PARAMETER_SIZE, size_type) \
1195 F(cl_device_info, CL_DEVICE_MAX_SAMPLERS, cl_uint) \
1196 F(cl_device_info, CL_DEVICE_MEM_BASE_ADDR_ALIGN, cl_uint) \
1197 F(cl_device_info, CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE, cl_uint) \
1198 F(cl_device_info, CL_DEVICE_SINGLE_FP_CONFIG, cl_device_fp_config) \
1199 F(cl_device_info, CL_DEVICE_DOUBLE_FP_CONFIG, cl_device_fp_config) \
1200 F(cl_device_info, CL_DEVICE_HALF_FP_CONFIG, cl_device_fp_config) \
1201 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_TYPE, cl_device_mem_cache_type) \
1202 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE, cl_uint)\
1203 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_SIZE, cl_ulong) \
1204 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_SIZE, cl_ulong) \
1205 F(cl_device_info, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE, cl_ulong) \
1206 F(cl_device_info, CL_DEVICE_MAX_CONSTANT_ARGS, cl_uint) \
1207 F(cl_device_info, CL_DEVICE_LOCAL_MEM_TYPE, cl_device_local_mem_type) \
1208 F(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE, cl_ulong) \
1209 F(cl_device_info, CL_DEVICE_ERROR_CORRECTION_SUPPORT, cl_bool) \
1210 F(cl_device_info, CL_DEVICE_PROFILING_TIMER_RESOLUTION, size_type) \
1211 F(cl_device_info, CL_DEVICE_ENDIAN_LITTLE, cl_bool) \
1212 F(cl_device_info, CL_DEVICE_AVAILABLE, cl_bool) \
1213 F(cl_device_info, CL_DEVICE_COMPILER_AVAILABLE, cl_bool) \
1214 F(cl_device_info, CL_DEVICE_EXECUTION_CAPABILITIES, cl_device_exec_capabilities) \
1215 F(cl_device_info, CL_DEVICE_PLATFORM, cl_platform_id) \
1216 F(cl_device_info, CL_DEVICE_NAME, string) \
1217 F(cl_device_info, CL_DEVICE_VENDOR, string) \
1218 F(cl_device_info, CL_DRIVER_VERSION, string) \
1219 F(cl_device_info, CL_DEVICE_PROFILE, string) \
1220 F(cl_device_info, CL_DEVICE_VERSION, string) \
1221 F(cl_device_info, CL_DEVICE_EXTENSIONS, string) \
1223 F(cl_context_info, CL_CONTEXT_REFERENCE_COUNT, cl_uint) \
1224 F(cl_context_info, CL_CONTEXT_DEVICES, cl::vector<Device>) \
1225 F(cl_context_info, CL_CONTEXT_PROPERTIES, cl::vector<cl_context_properties>) \
1227 F(cl_event_info, CL_EVENT_COMMAND_QUEUE, cl::CommandQueue) \
1228 F(cl_event_info, CL_EVENT_COMMAND_TYPE, cl_command_type) \
1229 F(cl_event_info, CL_EVENT_REFERENCE_COUNT, cl_uint) \
1230 F(cl_event_info, CL_EVENT_COMMAND_EXECUTION_STATUS, cl_int) \
1232 F(cl_profiling_info, CL_PROFILING_COMMAND_QUEUED, cl_ulong) \
1233 F(cl_profiling_info, CL_PROFILING_COMMAND_SUBMIT, cl_ulong) \
1234 F(cl_profiling_info, CL_PROFILING_COMMAND_START, cl_ulong) \
1235 F(cl_profiling_info, CL_PROFILING_COMMAND_END, cl_ulong) \
1237 F(cl_mem_info, CL_MEM_TYPE, cl_mem_object_type) \
1238 F(cl_mem_info, CL_MEM_FLAGS, cl_mem_flags) \
1239 F(cl_mem_info, CL_MEM_SIZE, size_type) \
1240 F(cl_mem_info, CL_MEM_HOST_PTR, void*) \
1241 F(cl_mem_info, CL_MEM_MAP_COUNT, cl_uint) \
1242 F(cl_mem_info, CL_MEM_REFERENCE_COUNT, cl_uint) \
1243 F(cl_mem_info, CL_MEM_CONTEXT, cl::Context) \
1245 F(cl_image_info, CL_IMAGE_FORMAT, cl_image_format) \
1246 F(cl_image_info, CL_IMAGE_ELEMENT_SIZE, size_type) \
1247 F(cl_image_info, CL_IMAGE_ROW_PITCH, size_type) \
1248 F(cl_image_info, CL_IMAGE_SLICE_PITCH, size_type) \
1249 F(cl_image_info, CL_IMAGE_WIDTH, size_type) \
1250 F(cl_image_info, CL_IMAGE_HEIGHT, size_type) \
1251 F(cl_image_info, CL_IMAGE_DEPTH, size_type) \
1253 F(cl_sampler_info, CL_SAMPLER_REFERENCE_COUNT, cl_uint) \
1254 F(cl_sampler_info, CL_SAMPLER_CONTEXT, cl::Context) \
1255 F(cl_sampler_info, CL_SAMPLER_NORMALIZED_COORDS, cl_bool) \
1256 F(cl_sampler_info, CL_SAMPLER_ADDRESSING_MODE, cl_addressing_mode) \
1257 F(cl_sampler_info, CL_SAMPLER_FILTER_MODE, cl_filter_mode) \
1259 F(cl_program_info, CL_PROGRAM_REFERENCE_COUNT, cl_uint) \
1260 F(cl_program_info, CL_PROGRAM_CONTEXT, cl::Context) \
1261 F(cl_program_info, CL_PROGRAM_NUM_DEVICES, cl_uint) \
1262 F(cl_program_info, CL_PROGRAM_DEVICES, cl::vector<Device>) \
1263 F(cl_program_info, CL_PROGRAM_SOURCE, string) \
1264 F(cl_program_info, CL_PROGRAM_BINARY_SIZES, cl::vector<size_type>) \
1265 F(cl_program_info, CL_PROGRAM_BINARIES, cl::vector<cl::vector<unsigned char>>) \
1267 F(cl_program_build_info, CL_PROGRAM_BUILD_STATUS, cl_build_status) \
1268 F(cl_program_build_info, CL_PROGRAM_BUILD_OPTIONS, string) \
1269 F(cl_program_build_info, CL_PROGRAM_BUILD_LOG, string) \
1271 F(cl_kernel_info, CL_KERNEL_FUNCTION_NAME, string) \
1272 F(cl_kernel_info, CL_KERNEL_NUM_ARGS, cl_uint) \
1273 F(cl_kernel_info, CL_KERNEL_REFERENCE_COUNT, cl_uint) \
1274 F(cl_kernel_info, CL_KERNEL_CONTEXT, cl::Context) \
1275 F(cl_kernel_info, CL_KERNEL_PROGRAM, cl::Program) \
1277 F(cl_kernel_work_group_info, CL_KERNEL_WORK_GROUP_SIZE, size_type) \
1278 F(cl_kernel_work_group_info, CL_KERNEL_COMPILE_WORK_GROUP_SIZE, cl::detail::size_t_array) \
1279 F(cl_kernel_work_group_info, CL_KERNEL_LOCAL_MEM_SIZE, cl_ulong) \
1281 F(cl_command_queue_info, CL_QUEUE_CONTEXT, cl::Context) \
1282 F(cl_command_queue_info, CL_QUEUE_DEVICE, cl::Device) \
1283 F(cl_command_queue_info, CL_QUEUE_REFERENCE_COUNT, cl_uint) \
1284 F(cl_command_queue_info, CL_QUEUE_PROPERTIES, cl_command_queue_properties)
1287 #define CL_HPP_PARAM_NAME_INFO_1_1_(F) \
1288 F(cl_context_info, CL_CONTEXT_NUM_DEVICES, cl_uint)\
1289 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF, cl_uint) \
1290 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR, cl_uint) \
1291 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT, cl_uint) \
1292 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_INT, cl_uint) \
1293 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG, cl_uint) \
1294 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT, cl_uint) \
1295 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE, cl_uint) \
1296 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF, cl_uint) \
1297 F(cl_device_info, CL_DEVICE_OPENCL_C_VERSION, string) \
1299 F(cl_mem_info, CL_MEM_ASSOCIATED_MEMOBJECT, cl::Memory) \
1300 F(cl_mem_info, CL_MEM_OFFSET, size_type) \
1302 F(cl_kernel_work_group_info, CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, size_type) \
1303 F(cl_kernel_work_group_info, CL_KERNEL_PRIVATE_MEM_SIZE, cl_ulong) \
1305 F(cl_event_info, CL_EVENT_CONTEXT, cl::Context)
1307 #define CL_HPP_PARAM_NAME_INFO_1_2_(F) \
1308 F(cl_program_info, CL_PROGRAM_NUM_KERNELS, size_type) \
1309 F(cl_program_info, CL_PROGRAM_KERNEL_NAMES, string) \
1311 F(cl_program_build_info, CL_PROGRAM_BINARY_TYPE, cl_program_binary_type) \
1313 F(cl_kernel_info, CL_KERNEL_ATTRIBUTES, string) \
1315 F(cl_kernel_arg_info, CL_KERNEL_ARG_ADDRESS_QUALIFIER, cl_kernel_arg_address_qualifier) \
1316 F(cl_kernel_arg_info, CL_KERNEL_ARG_ACCESS_QUALIFIER, cl_kernel_arg_access_qualifier) \
1317 F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_NAME, string) \
1318 F(cl_kernel_arg_info, CL_KERNEL_ARG_NAME, string) \
1319 F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_QUALIFIER, cl_kernel_arg_type_qualifier) \
1321 F(cl_device_info, CL_DEVICE_PARENT_DEVICE, cl::Device) \
1322 F(cl_device_info, CL_DEVICE_PARTITION_MAX_SUB_DEVICES, cl_uint) \
1323 F(cl_device_info, CL_DEVICE_PARTITION_PROPERTIES, cl::vector<cl_device_partition_property>) \
1324 F(cl_device_info, CL_DEVICE_PARTITION_TYPE, cl::vector<cl_device_partition_property>) \
1325 F(cl_device_info, CL_DEVICE_REFERENCE_COUNT, cl_uint) \
1326 F(cl_device_info, CL_DEVICE_PREFERRED_INTEROP_USER_SYNC, size_type) \
1327 F(cl_device_info, CL_DEVICE_PARTITION_AFFINITY_DOMAIN, cl_device_affinity_domain) \
1328 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS, string) \
1330 F(cl_image_info, CL_IMAGE_ARRAY_SIZE, size_type) \
1331 F(cl_image_info, CL_IMAGE_NUM_MIP_LEVELS, cl_uint) \
1332 F(cl_image_info, CL_IMAGE_NUM_SAMPLES, cl_uint)
1334 #define CL_HPP_PARAM_NAME_INFO_2_0_(F) \
1335 F(cl_device_info, CL_DEVICE_QUEUE_ON_HOST_PROPERTIES, cl_command_queue_properties) \
1336 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES, cl_command_queue_properties) \
1337 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE, cl_uint) \
1338 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE, cl_uint) \
1339 F(cl_device_info, CL_DEVICE_MAX_ON_DEVICE_QUEUES, cl_uint) \
1340 F(cl_device_info, CL_DEVICE_MAX_ON_DEVICE_EVENTS, cl_uint) \
1341 F(cl_device_info, CL_DEVICE_MAX_PIPE_ARGS, cl_uint) \
1342 F(cl_device_info, CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS, cl_uint) \
1343 F(cl_device_info, CL_DEVICE_PIPE_MAX_PACKET_SIZE, cl_uint) \
1344 F(cl_device_info, CL_DEVICE_SVM_CAPABILITIES, cl_device_svm_capabilities) \
1345 F(cl_device_info, CL_DEVICE_PREFERRED_PLATFORM_ATOMIC_ALIGNMENT, cl_uint) \
1346 F(cl_device_info, CL_DEVICE_PREFERRED_GLOBAL_ATOMIC_ALIGNMENT, cl_uint) \
1347 F(cl_device_info, CL_DEVICE_PREFERRED_LOCAL_ATOMIC_ALIGNMENT, cl_uint) \
1348 F(cl_profiling_info, CL_PROFILING_COMMAND_COMPLETE, cl_ulong) \
1349 F(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM, cl_bool) \
1350 F(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_SVM_PTRS, void**) \
1351 F(cl_command_queue_info, CL_QUEUE_SIZE, cl_uint) \
1352 F(cl_mem_info, CL_MEM_USES_SVM_POINTER, cl_bool) \
1353 F(cl_program_build_info, CL_PROGRAM_BUILD_GLOBAL_VARIABLE_TOTAL_SIZE, size_type) \
1354 F(cl_pipe_info, CL_PIPE_PACKET_SIZE, cl_uint) \
1355 F(cl_pipe_info, CL_PIPE_MAX_PACKETS, cl_uint)
1357 #define CL_HPP_PARAM_NAME_INFO_SUBGROUP_KHR_(F) \
1358 F(cl_kernel_sub_group_info, CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE_KHR, size_type) \
1359 F(cl_kernel_sub_group_info, CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE_KHR, size_type)
1361 #define CL_HPP_PARAM_NAME_INFO_IL_KHR_(F) \
1362 F(cl_device_info, CL_DEVICE_IL_VERSION_KHR, string) \
1363 F(cl_program_info, CL_PROGRAM_IL_KHR, cl::vector<unsigned char>)
1365 #define CL_HPP_PARAM_NAME_INFO_2_1_(F) \
1366 F(cl_platform_info, CL_PLATFORM_HOST_TIMER_RESOLUTION, size_type) \
1367 F(cl_program_info, CL_PROGRAM_IL, cl::vector<unsigned char>) \
1368 F(cl_kernel_info, CL_KERNEL_MAX_NUM_SUB_GROUPS, size_type) \
1369 F(cl_kernel_info, CL_KERNEL_COMPILE_NUM_SUB_GROUPS, size_type) \
1370 F(cl_device_info, CL_DEVICE_MAX_NUM_SUB_GROUPS, cl_uint) \
1371 F(cl_device_info, CL_DEVICE_IL_VERSION, string) \
1372 F(cl_device_info, CL_DEVICE_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS, cl_bool) \
1373 F(cl_command_queue_info, CL_QUEUE_DEVICE_DEFAULT, cl::DeviceCommandQueue) \
1374 F(cl_kernel_sub_group_info, CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE, size_type) \
1375 F(cl_kernel_sub_group_info, CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE, size_type) \
1376 F(cl_kernel_sub_group_info, CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT, cl::detail::size_t_array)
1378 #define CL_HPP_PARAM_NAME_INFO_2_2_(F) \
1379 F(cl_program_info, CL_PROGRAM_SCOPE_GLOBAL_CTORS_PRESENT, cl_bool) \
1380 F(cl_program_info, CL_PROGRAM_SCOPE_GLOBAL_DTORS_PRESENT, cl_bool)
1382 #define CL_HPP_PARAM_NAME_DEVICE_FISSION_(F) \
1383 F(cl_device_info, CL_DEVICE_PARENT_DEVICE_EXT, cl_device_id) \
1384 F(cl_device_info, CL_DEVICE_PARTITION_TYPES_EXT, cl::vector<cl_device_partition_property_ext>) \
1385 F(cl_device_info, CL_DEVICE_AFFINITY_DOMAINS_EXT, cl::vector<cl_device_partition_property_ext>) \
1386 F(cl_device_info, CL_DEVICE_REFERENCE_COUNT_EXT , cl_uint) \
1387 F(cl_device_info, CL_DEVICE_PARTITION_STYLE_EXT, cl::vector<cl_device_partition_property_ext>)
1389 #define CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_(F) \
1390 F(cl_platform_info, CL_PLATFORM_NUMERIC_VERSION_KHR, cl_version_khr) \
1391 F(cl_platform_info, CL_PLATFORM_EXTENSIONS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>) \
1393 F(cl_device_info, CL_DEVICE_NUMERIC_VERSION_KHR, cl_version_khr) \
1394 F(cl_device_info, CL_DEVICE_OPENCL_C_NUMERIC_VERSION_KHR, cl_version_khr) \
1395 F(cl_device_info, CL_DEVICE_EXTENSIONS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>) \
1396 F(cl_device_info, CL_DEVICE_ILS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>) \
1397 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS_WITH_VERSION_KHR, cl::vector<cl_name_version_khr>)
1399 template <
typename enum_type, cl_
int Name>
1402 #define CL_HPP_DECLARE_PARAM_TRAITS_(token, param_name, T) \
1405 struct param_traits<detail:: token,param_name> \
1407 enum { value = param_name }; \
1408 typedef T param_type; \
1411 CL_HPP_PARAM_NAME_INFO_1_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1412 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
1413 CL_HPP_PARAM_NAME_INFO_1_1_(CL_HPP_DECLARE_PARAM_TRAITS_)
1414 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110
1415 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
1416 CL_HPP_PARAM_NAME_INFO_1_2_(CL_HPP_DECLARE_PARAM_TRAITS_)
1417 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
1418 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
1419 CL_HPP_PARAM_NAME_INFO_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1420 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200
1421 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
1422 CL_HPP_PARAM_NAME_INFO_2_1_(CL_HPP_DECLARE_PARAM_TRAITS_)
1423 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 210
1424 #if CL_HPP_TARGET_OPENCL_VERSION >= 220
1425 CL_HPP_PARAM_NAME_INFO_2_2_(CL_HPP_DECLARE_PARAM_TRAITS_)
1426 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 220
1428 #if defined(CL_HPP_USE_CL_SUB_GROUPS_KHR) && CL_HPP_TARGET_OPENCL_VERSION < 210
1429 CL_HPP_PARAM_NAME_INFO_SUBGROUP_KHR_(CL_HPP_DECLARE_PARAM_TRAITS_)
1430 #endif // #if defined(CL_HPP_USE_CL_SUB_GROUPS_KHR) && CL_HPP_TARGET_OPENCL_VERSION < 210
1432 #if defined(CL_HPP_USE_IL_KHR)
1433 CL_HPP_PARAM_NAME_INFO_IL_KHR_(CL_HPP_DECLARE_PARAM_TRAITS_)
1434 #endif // #if defined(CL_HPP_USE_IL_KHR)
1438 #define CL_HPP_PARAM_NAME_INFO_1_0_DEPRECATED_IN_2_0_(F) \
1439 F(cl_device_info, CL_DEVICE_QUEUE_PROPERTIES, cl_command_queue_properties)
1441 #define CL_HPP_PARAM_NAME_INFO_1_1_DEPRECATED_IN_2_0_(F) \
1442 F(cl_device_info, CL_DEVICE_HOST_UNIFIED_MEMORY, cl_bool)
1444 #define CL_HPP_PARAM_NAME_INFO_1_2_DEPRECATED_IN_2_0_(F) \
1445 F(cl_image_info, CL_IMAGE_BUFFER, cl::Buffer)
1449 #if CL_HPP_TARGET_OPENCL_VERSION > 100 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 && CL_HPP_TARGET_OPENCL_VERSION < 200
1450 CL_HPP_PARAM_NAME_INFO_1_0_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1451 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 110
1452 #if CL_HPP_TARGET_OPENCL_VERSION > 110 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
1453 CL_HPP_PARAM_NAME_INFO_1_1_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1454 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 120
1455 #if CL_HPP_TARGET_OPENCL_VERSION > 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
1456 CL_HPP_PARAM_NAME_INFO_1_2_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1457 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 200
1459 #if defined(CL_HPP_USE_CL_DEVICE_FISSION)
1460 CL_HPP_PARAM_NAME_DEVICE_FISSION_(CL_HPP_DECLARE_PARAM_TRAITS_);
1461 #endif // CL_HPP_USE_CL_DEVICE_FISSION
1463 #if defined(cl_khr_extended_versioning)
1464 CL_HPP_PARAM_NAME_CL_KHR_EXTENDED_VERSIONING_(CL_HPP_DECLARE_PARAM_TRAITS_);
1465 #endif // cl_khr_extended_versioning
1467 #ifdef CL_PLATFORM_ICD_SUFFIX_KHR
1468 CL_HPP_DECLARE_PARAM_TRAITS_(cl_platform_info, CL_PLATFORM_ICD_SUFFIX_KHR,
string)
1471 #ifdef CL_DEVICE_PROFILING_TIMER_OFFSET_AMD
1472 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_PROFILING_TIMER_OFFSET_AMD, cl_ulong)
1475 #ifdef CL_DEVICE_GLOBAL_FREE_MEMORY_AMD
1476 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_FREE_MEMORY_AMD, vector<size_type>)
1478 #ifdef CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD
1479 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD, cl_uint)
1481 #ifdef CL_DEVICE_SIMD_WIDTH_AMD
1482 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_WIDTH_AMD, cl_uint)
1484 #ifdef CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD
1485 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD, cl_uint)
1487 #ifdef CL_DEVICE_WAVEFRONT_WIDTH_AMD
1488 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_WAVEFRONT_WIDTH_AMD, cl_uint)
1490 #ifdef CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD
1491 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD, cl_uint)
1493 #ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD
1494 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD, cl_uint)
1496 #ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD
1497 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD, cl_uint)
1499 #ifdef CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD
1500 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD, cl_uint)
1502 #ifdef CL_DEVICE_LOCAL_MEM_BANKS_AMD
1503 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LOCAL_MEM_BANKS_AMD, cl_uint)
1506 #ifdef CL_DEVICE_COMPUTE_UNITS_BITFIELD_ARM
1507 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_UNITS_BITFIELD_ARM, cl_ulong)
1509 #ifdef CL_DEVICE_JOB_SLOTS_ARM
1510 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_JOB_SLOTS_ARM, cl_uint)
1512 #ifdef CL_DEVICE_SCHEDULING_CONTROLS_CAPABILITIES_ARM
1513 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SCHEDULING_CONTROLS_CAPABILITIES_ARM, cl_bitfield)
1515 #ifdef CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_ARM
1516 CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_ARM, cl_uint)
1518 #ifdef CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_MODIFIER_ARM
1519 CL_HPP_DECLARE_PARAM_TRAITS_(cl_kernel_exec_info, CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_MODIFIER_ARM, cl_int)
1522 #ifdef CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV
1523 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV, cl_uint)
1525 #ifdef CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV
1526 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV, cl_uint)
1528 #ifdef CL_DEVICE_REGISTERS_PER_BLOCK_NV
1529 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_REGISTERS_PER_BLOCK_NV, cl_uint)
1531 #ifdef CL_DEVICE_WARP_SIZE_NV
1532 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_WARP_SIZE_NV, cl_uint)
1534 #ifdef CL_DEVICE_GPU_OVERLAP_NV
1535 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GPU_OVERLAP_NV, cl_bool)
1537 #ifdef CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV
1538 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV, cl_bool)
1540 #ifdef CL_DEVICE_INTEGRATED_MEMORY_NV
1541 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGRATED_MEMORY_NV, cl_bool)
1546 template <
typename Func,
typename T>
1548 getInfo(Func f, cl_uint name, T* param)
1550 return getInfoHelper(f, name, param, 0);
1553 template <
typename Func,
typename Arg0>
1556 Func f_;
const Arg0& arg0_;
1558 cl_uint param, size_type size,
void* value, size_type* size_ret)
1559 {
return f_(arg0_, param, size, value, size_ret); }
1562 template <
typename Func,
typename Arg0,
typename Arg1>
1565 Func f_;
const Arg0& arg0_;
const Arg1& arg1_;
1567 cl_uint param, size_type size,
void* value, size_type* size_ret)
1568 {
return f_(arg0_, arg1_, param, size, value, size_ret); }
1571 template <
typename Func,
typename Arg0,
typename T>
1573 getInfo(Func f,
const Arg0& arg0, cl_uint name, T* param)
1576 return getInfoHelper(f0, name, param, 0);
1579 template <
typename Func,
typename Arg0,
typename Arg1,
typename T>
1581 getInfo(Func f,
const Arg0& arg0,
const Arg1& arg1, cl_uint name, T* param)
1583 GetInfoFunctor1<Func, Arg0, Arg1> f0 = { f, arg0, arg1 };
1584 return getInfoHelper(f0, name, param, 0);
1588 template<
typename T>
1592 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
1609 { return ::clRetainDevice(device); }
1620 { return ::clReleaseDevice(device); }
1622 #else // CL_HPP_TARGET_OPENCL_VERSION >= 120
1627 struct ReferenceHandler<cl_device_id>
1630 static cl_int retain(cl_device_id)
1631 {
return CL_SUCCESS; }
1633 static cl_int release(cl_device_id)
1634 {
return CL_SUCCESS; }
1636 #endif // ! (CL_HPP_TARGET_OPENCL_VERSION >= 120)
1642 static cl_int retain(cl_platform_id)
1643 {
return CL_SUCCESS; }
1645 static cl_int release(cl_platform_id)
1646 {
return CL_SUCCESS; }
1652 static cl_int retain(cl_context context)
1653 { return ::clRetainContext(context); }
1654 static cl_int release(cl_context context)
1655 { return ::clReleaseContext(context); }
1661 static cl_int retain(cl_command_queue queue)
1662 { return ::clRetainCommandQueue(queue); }
1663 static cl_int release(cl_command_queue queue)
1664 { return ::clReleaseCommandQueue(queue); }
1670 static cl_int retain(cl_mem memory)
1671 { return ::clRetainMemObject(memory); }
1672 static cl_int release(cl_mem memory)
1673 { return ::clReleaseMemObject(memory); }
1679 static cl_int retain(cl_sampler sampler)
1680 { return ::clRetainSampler(sampler); }
1681 static cl_int release(cl_sampler sampler)
1682 { return ::clReleaseSampler(sampler); }
1688 static cl_int retain(cl_program program)
1689 { return ::clRetainProgram(program); }
1690 static cl_int release(cl_program program)
1691 { return ::clReleaseProgram(program); }
1697 static cl_int retain(cl_kernel kernel)
1698 { return ::clRetainKernel(kernel); }
1699 static cl_int release(cl_kernel kernel)
1700 { return ::clReleaseKernel(kernel); }
1706 static cl_int retain(cl_event event)
1707 { return ::clRetainEvent(event); }
1708 static cl_int release(cl_event event)
1709 { return ::clReleaseEvent(event); }
1713 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
1715 static cl_uint getVersion(
const vector<char> &versionInfo)
1717 int highVersion = 0;
1720 while(versionInfo[index] !=
'.' ) {
1722 highVersion += versionInfo[index]-
'0';
1726 while(versionInfo[index] !=
' ' && versionInfo[index] !=
'\0') {
1728 lowVersion += versionInfo[index]-
'0';
1731 return (highVersion << 16) | lowVersion;
1734 static cl_uint getPlatformVersion(cl_platform_id platform)
1737 clGetPlatformInfo(platform, CL_PLATFORM_VERSION, 0, NULL, &size);
1739 vector<char> versionInfo(size);
1740 clGetPlatformInfo(platform, CL_PLATFORM_VERSION, size, versionInfo.data(), &size);
1741 return getVersion(versionInfo);
1744 static cl_uint getDevicePlatformVersion(cl_device_id device)
1746 cl_platform_id platform;
1747 clGetDeviceInfo(device, CL_DEVICE_PLATFORM,
sizeof(platform), &platform, NULL);
1748 return getPlatformVersion(platform);
1751 static cl_uint getContextPlatformVersion(cl_context context)
1756 clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, NULL, &size);
1759 vector<cl_device_id> devices(size/
sizeof(cl_device_id));
1760 clGetContextInfo(context, CL_CONTEXT_DEVICES, size, devices.data(), NULL);
1761 return getDevicePlatformVersion(devices[0]);
1763 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
1765 template <
typename T>
1777 Wrapper(
const cl_type &obj,
bool retainObject) : object_(obj)
1780 detail::errHandler(retain(), __RETAIN_ERR);
1786 if (object_ != NULL) { release(); }
1791 object_ = rhs.object_;
1792 detail::errHandler(retain(), __RETAIN_ERR);
1797 object_ = rhs.object_;
1804 detail::errHandler(release(), __RELEASE_ERR);
1805 object_ = rhs.object_;
1806 detail::errHandler(retain(), __RETAIN_ERR);
1814 detail::errHandler(release(), __RELEASE_ERR);
1815 object_ = rhs.object_;
1823 detail::errHandler(release(), __RELEASE_ERR);
1828 const cl_type& operator ()()
const {
return object_; }
1830 cl_type& operator ()() {
return object_; }
1832 cl_type get()
const {
return object_; }
1835 template<
typename Func,
typename U>
1836 friend inline cl_int getInfoHelper(Func, cl_uint, U*,
int,
typename U::cl_type);
1838 cl_int retain()
const
1840 if (object_ !=
nullptr) {
1848 cl_int release()
const
1850 if (object_ !=
nullptr) {
1863 typedef cl_device_id cl_type;
1867 bool referenceCountable_;
1869 static bool isReferenceCountable(cl_device_id device)
1871 bool retVal =
false;
1872 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
1873 #if CL_HPP_MINIMUM_OPENCL_VERSION < 120
1874 if (device != NULL) {
1875 int version = getDevicePlatformVersion(device);
1876 if(version > ((1 << 16) + 1)) {
1880 #else // CL_HPP_MINIMUM_OPENCL_VERSION < 120
1882 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 120
1883 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
1888 Wrapper() : object_(NULL), referenceCountable_(
false)
1892 Wrapper(
const cl_type &obj,
bool retainObject) :
1894 referenceCountable_(
false)
1896 referenceCountable_ = isReferenceCountable(obj);
1899 detail::errHandler(retain(), __RETAIN_ERR);
1910 object_ = rhs.object_;
1911 referenceCountable_ = isReferenceCountable(object_);
1912 detail::errHandler(retain(), __RETAIN_ERR);
1917 object_ = rhs.object_;
1918 referenceCountable_ = rhs.referenceCountable_;
1920 rhs.referenceCountable_ =
false;
1926 detail::errHandler(release(), __RELEASE_ERR);
1927 object_ = rhs.object_;
1928 referenceCountable_ = rhs.referenceCountable_;
1929 detail::errHandler(retain(), __RETAIN_ERR);
1937 detail::errHandler(release(), __RELEASE_ERR);
1938 object_ = rhs.object_;
1939 referenceCountable_ = rhs.referenceCountable_;
1941 rhs.referenceCountable_ =
false;
1948 detail::errHandler(release(), __RELEASE_ERR);
1950 referenceCountable_ = isReferenceCountable(object_);
1954 const cl_type& operator ()()
const {
return object_; }
1956 cl_type& operator ()() {
return object_; }
1958 cl_type get()
const {
return object_; }
1961 template<
typename Func,
typename U>
1962 friend inline cl_int getInfoHelper(Func, cl_uint, U*,
int,
typename U::cl_type);
1964 template<
typename Func,
typename U>
1965 friend inline cl_int getInfoHelper(Func, cl_uint, vector<U>*,
int,
typename U::cl_type);
1967 cl_int retain()
const
1969 if( object_ !=
nullptr && referenceCountable_ ) {
1977 cl_int release()
const
1979 if (object_ !=
nullptr && referenceCountable_) {
1988 template <
typename T>
1991 return lhs() == rhs();
1994 template <
typename T>
1995 inline bool operator!=(
const Wrapper<T> &lhs,
const Wrapper<T> &rhs)
1997 return !operator==(lhs, rhs);
2004 using BuildLogType = vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, CL_PROGRAM_BUILD_LOG>::param_type>>;
2005 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
2009 class BuildError :
public Error
2012 BuildLogType buildLogs;
2014 BuildError(cl_int err,
const char * errStr,
const BuildLogType &vec) : Error(err, errStr), buildLogs(vec)
2018 BuildLogType getBuildLog()
const
2024 static inline cl_int buildErrHandler(
2026 const char * errStr,
2027 const BuildLogType &buildLogs)
2029 if (err != CL_SUCCESS) {
2030 throw BuildError(err, errStr, buildLogs);
2038 static inline cl_int buildErrHandler(
2040 const char * errStr,
2041 const BuildLogType &buildLogs)
2048 #endif // #if defined(CL_HPP_ENABLE_EXCEPTIONS)
2064 image_channel_order = order;
2065 image_channel_data_type = type;
2072 this->image_channel_data_type = rhs.image_channel_data_type;
2073 this->image_channel_order = rhs.image_channel_order;
2089 static std::once_flag default_initialized_;
2091 static cl_int default_error_;
2098 static void makeDefault();
2105 static void makeDefaultProvided(
const Device &p) {
2110 #ifdef CL_HPP_UNIT_TEST_ENABLE
2117 static void unitTestClearDefault() {
2120 #endif // #ifdef CL_HPP_UNIT_TEST_ENABLE
2129 explicit Device(
const cl_device_id &device,
bool retainObject =
false) :
2130 detail::Wrapper<cl_type>(device, retainObject) { }
2137 cl_int *errResult = NULL)
2139 std::call_once(default_initialized_, makeDefault);
2140 detail::errHandler(default_error_);
2141 if (errResult != NULL) {
2142 *errResult = default_error_;
2156 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_device));
2157 detail::errHandler(default_error_);
2200 template <
typename T>
2201 cl_int
getInfo(cl_device_info name, T* param)
const
2203 return detail::errHandler(
2204 detail::getInfo(&::clGetDeviceInfo, object_, name, param),
2205 __GET_DEVICE_INFO_ERR);
2209 template <cl_device_info name>
typename
2214 detail::cl_device_info, name>::param_type param;
2215 cl_int result =
getInfo(name, ¶m);
2223 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
2232 cl_ulong retVal = 0;
2234 clGetHostTimer(this->get(), &retVal);
2237 __GET_HOST_TIMER_ERR);
2256 std::pair<cl_ulong, cl_ulong> retVal;
2258 clGetDeviceAndHostTimer(this->get(), &(retVal.first), &(retVal.second));
2261 __GET_DEVICE_AND_HOST_TIMER_ERR);
2267 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 210
2272 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
2275 const cl_device_partition_property * properties,
2276 vector<Device>* devices)
2279 cl_int err = clCreateSubDevices(object_, properties, 0, NULL, &n);
2280 if (err != CL_SUCCESS) {
2281 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2284 vector<cl_device_id> ids(n);
2285 err = clCreateSubDevices(object_, properties, n, ids.data(), NULL);
2286 if (err != CL_SUCCESS) {
2287 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2293 devices->resize(ids.size());
2297 for (size_type i = 0; i < ids.size(); i++) {
2300 (*devices)[i] =
Device(ids[i],
false);
2306 #elif defined(CL_HPP_USE_CL_DEVICE_FISSION)
2312 const cl_device_partition_property_ext * properties,
2313 vector<Device>* devices)
2315 typedef CL_API_ENTRY cl_int
2316 ( CL_API_CALL * PFN_clCreateSubDevicesEXT)(
2318 const cl_device_partition_property_ext * ,
2321 cl_uint * ) CL_EXT_SUFFIX__VERSION_1_1;
2323 static PFN_clCreateSubDevicesEXT pfn_clCreateSubDevicesEXT = NULL;
2324 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateSubDevicesEXT);
2327 cl_int err = pfn_clCreateSubDevicesEXT(object_, properties, 0, NULL, &n);
2328 if (err != CL_SUCCESS) {
2329 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2332 vector<cl_device_id> ids(n);
2333 err = pfn_clCreateSubDevicesEXT(object_, properties, n, ids.data(), NULL);
2334 if (err != CL_SUCCESS) {
2335 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2340 devices->resize(ids.size());
2344 for (size_type i = 0; i < ids.size(); i++) {
2347 (*devices)[i] =
Device(ids[i],
false);
2352 #endif // defined(CL_HPP_USE_CL_DEVICE_FISSION)
2355 CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Device::default_initialized_;
2356 CL_HPP_DEFINE_STATIC_MEMBER_ Device Device::default_;
2357 CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Device::default_error_ = CL_SUCCESS;
2369 static std::once_flag default_initialized_;
2371 static cl_int default_error_;
2378 static void makeDefault() {
2382 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
2390 cl_int err = ::clGetPlatformIDs(0, NULL, &n);
2391 if (err != CL_SUCCESS) {
2392 default_error_ = err;
2396 default_error_ = CL_INVALID_PLATFORM;
2400 vector<cl_platform_id> ids(n);
2401 err = ::clGetPlatformIDs(n, ids.data(), NULL);
2402 if (err != CL_SUCCESS) {
2403 default_error_ = err;
2409 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
2410 catch (cl::Error &e) {
2411 default_error_ = e.err();
2421 static void makeDefaultProvided(
const Platform &p) {
2426 #ifdef CL_HPP_UNIT_TEST_ENABLE
2433 static void unitTestClearDefault() {
2436 #endif // #ifdef CL_HPP_UNIT_TEST_ENABLE
2448 explicit Platform(
const cl_platform_id &platform,
bool retainObject =
false) :
2449 detail::Wrapper<cl_type>(platform, retainObject) { }
2462 cl_int *errResult = NULL)
2464 std::call_once(default_initialized_, makeDefault);
2465 detail::errHandler(default_error_);
2466 if (errResult != NULL) {
2467 *errResult = default_error_;
2481 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_platform));
2482 detail::errHandler(default_error_);
2487 template <
typename T>
2488 cl_int
getInfo(cl_platform_info name, T* param)
const
2490 return detail::errHandler(
2491 detail::getInfo(&::clGetPlatformInfo, object_, name, param),
2492 __GET_PLATFORM_INFO_ERR);
2496 template <cl_platform_info name>
typename
2501 detail::cl_platform_info, name>::param_type param;
2502 cl_int result =
getInfo(name, ¶m);
2514 cl_device_type type,
2515 vector<Device>* devices)
const
2518 if( devices == NULL ) {
2519 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR);
2521 cl_int err = ::clGetDeviceIDs(object_, type, 0, NULL, &n);
2522 if (err != CL_SUCCESS && err != CL_DEVICE_NOT_FOUND) {
2523 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2526 vector<cl_device_id> ids(n);
2528 err = ::clGetDeviceIDs(object_, type, n, ids.data(), NULL);
2529 if (err != CL_SUCCESS) {
2530 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2539 devices->resize(ids.size());
2543 for (size_type i = 0; i < ids.size(); i++) {
2544 (*devices)[i] =
Device(ids[i],
true);
2550 #if defined(CL_HPP_USE_DX_INTEROP)
2575 cl_d3d10_device_source_khr d3d_device_source,
2577 cl_d3d10_device_set_khr d3d_device_set,
2578 vector<Device>* devices)
const
2580 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clGetDeviceIDsFromD3D10KHR)(
2581 cl_platform_id platform,
2582 cl_d3d10_device_source_khr d3d_device_source,
2584 cl_d3d10_device_set_khr d3d_device_set,
2585 cl_uint num_entries,
2586 cl_device_id * devices,
2587 cl_uint* num_devices);
2589 if( devices == NULL ) {
2590 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR);
2593 static PFN_clGetDeviceIDsFromD3D10KHR pfn_clGetDeviceIDsFromD3D10KHR = NULL;
2594 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(object_, clGetDeviceIDsFromD3D10KHR);
2597 cl_int err = pfn_clGetDeviceIDsFromD3D10KHR(
2605 if (err != CL_SUCCESS) {
2606 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2609 vector<cl_device_id> ids(n);
2610 err = pfn_clGetDeviceIDsFromD3D10KHR(
2618 if (err != CL_SUCCESS) {
2619 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2627 devices->resize(ids.size());
2631 for (size_type i = 0; i < ids.size(); i++) {
2632 (*devices)[i] = Device(ids[i],
true);
2644 vector<Platform>* platforms)
2648 if( platforms == NULL ) {
2649 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_PLATFORM_IDS_ERR);
2652 cl_int err = ::clGetPlatformIDs(0, NULL, &n);
2653 if (err != CL_SUCCESS) {
2654 return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
2657 vector<cl_platform_id> ids(n);
2658 err = ::clGetPlatformIDs(n, ids.data(), NULL);
2659 if (err != CL_SUCCESS) {
2660 return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
2664 platforms->resize(ids.size());
2667 for (size_type i = 0; i < ids.size(); i++) {
2668 (*platforms)[i] =
Platform(ids[i]);
2682 Platform default_platform = Platform::getDefault(&err);
2684 *platform = default_platform;
2698 cl_int * errResult = NULL)
2701 Platform default_platform = Platform::getDefault(&err);
2705 return default_platform;
2708 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
2713 return ::clUnloadPlatformCompiler(object_);
2715 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
2718 CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Platform::default_initialized_;
2719 CL_HPP_DEFINE_STATIC_MEMBER_ Platform Platform::default_;
2720 CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Platform::default_error_ = CL_SUCCESS;
2726 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
2731 inline CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_int
2736 return ::clUnloadCompiler();
2738 #endif // #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
2752 static std::once_flag default_initialized_;
2754 static cl_int default_error_;
2761 static void makeDefault() {
2765 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
2769 #if !defined(__APPLE__) && !defined(__MACOS)
2770 const Platform &p = Platform::getDefault();
2771 cl_platform_id defaultPlatform = p();
2772 cl_context_properties properties[3] = {
2773 CL_CONTEXT_PLATFORM, (cl_context_properties)defaultPlatform, 0
2775 #else // #if !defined(__APPLE__) && !defined(__MACOS)
2776 cl_context_properties *properties =
nullptr;
2777 #endif // #if !defined(__APPLE__) && !defined(__MACOS)
2780 CL_DEVICE_TYPE_DEFAULT,
2786 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
2787 catch (cl::Error &e) {
2788 default_error_ = e.err();
2799 static void makeDefaultProvided(
const Context &c) {
2804 #ifdef CL_HPP_UNIT_TEST_ENABLE
2811 static void unitTestClearDefault() {
2814 #endif // #ifdef CL_HPP_UNIT_TEST_ENABLE
2821 const vector<Device>& devices,
2822 cl_context_properties* properties = NULL,
2823 void (CL_CALLBACK * notifyFptr)(
2833 size_type numDevices = devices.size();
2834 vector<cl_device_id> deviceIDs(numDevices);
2836 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
2837 deviceIDs[deviceIndex] = (devices[deviceIndex])();
2840 object_ = ::clCreateContext(
2841 properties, (cl_uint) numDevices,
2843 notifyFptr, data, &error);
2845 detail::errHandler(error, __CREATE_CONTEXT_ERR);
2857 cl_context_properties* properties = NULL,
2858 void (CL_CALLBACK * notifyFptr)(
2868 cl_device_id deviceID = device();
2870 object_ = ::clCreateContext(
2873 notifyFptr, data, &error);
2875 detail::errHandler(error, __CREATE_CONTEXT_ERR);
2886 cl_device_type type,
2887 cl_context_properties* properties = NULL,
2888 void (CL_CALLBACK * notifyFptr)(
2898 #if !defined(__APPLE__) && !defined(__MACOS)
2899 cl_context_properties prop[4] = {CL_CONTEXT_PLATFORM, 0, 0, 0 };
2901 if (properties == NULL) {
2903 vector<Platform> platforms;
2904 error = Platform::get(&platforms);
2905 if (error != CL_SUCCESS) {
2906 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
2914 cl_context_properties platform_id = 0;
2915 for (
unsigned int i = 0; i < platforms.size(); i++) {
2917 vector<Device> devices;
2919 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
2923 error = platforms[i].getDevices(type, &devices);
2925 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
2926 }
catch (cl::Error& e) {
2934 if (error != CL_SUCCESS && error != CL_DEVICE_NOT_FOUND) {
2935 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
2941 if (devices.size() > 0) {
2942 platform_id = (cl_context_properties)platforms[i]();
2947 if (platform_id == 0) {
2948 detail::errHandler(CL_DEVICE_NOT_FOUND, __CREATE_CONTEXT_FROM_TYPE_ERR);
2950 *err = CL_DEVICE_NOT_FOUND;
2955 prop[1] = platform_id;
2956 properties = &prop[0];
2959 object_ = ::clCreateContextFromType(
2960 properties, type, notifyFptr, data, &error);
2962 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
3003 std::call_once(default_initialized_, makeDefault);
3004 detail::errHandler(default_error_);
3006 *err = default_error_;
3020 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_context));
3021 detail::errHandler(default_error_);
3033 explicit Context(
const cl_context& context,
bool retainObject =
false) :
3034 detail::Wrapper<cl_type>(context, retainObject) { }
3048 template <
typename T>
3049 cl_int
getInfo(cl_context_info name, T* param)
const
3051 return detail::errHandler(
3052 detail::getInfo(&::clGetContextInfo, object_, name, param),
3053 __GET_CONTEXT_INFO_ERR);
3057 template <cl_context_info name>
typename
3062 detail::cl_context_info, name>::param_type param;
3063 cl_int result =
getInfo(name, ¶m);
3076 cl_mem_object_type type,
3077 vector<ImageFormat>* formats)
const
3085 cl_int err = ::clGetSupportedImageFormats(
3092 if (err != CL_SUCCESS) {
3093 return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
3096 if (numEntries > 0) {
3097 vector<ImageFormat> value(numEntries);
3098 err = ::clGetSupportedImageFormats(
3103 (cl_image_format*)value.data(),
3105 if (err != CL_SUCCESS) {
3106 return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
3109 formats->assign(begin(value), end(value));
3120 inline void Device::makeDefault()
3125 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
3132 detail::errHandler(error, __CREATE_CONTEXT_ERR);
3134 if (error != CL_SUCCESS) {
3135 default_error_ = error;
3138 default_ = context.
getInfo<CL_CONTEXT_DEVICES>()[0];
3139 default_error_ = CL_SUCCESS;
3142 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
3143 catch (cl::Error &e) {
3144 default_error_ = e.err();
3149 CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Context::default_initialized_;
3150 CL_HPP_DEFINE_STATIC_MEMBER_ Context Context::default_;
3151 CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Context::default_error_ = CL_SUCCESS;
3165 Event() : detail::Wrapper<cl_type>() { }
3175 explicit Event(
const cl_event& event,
bool retainObject =
false) :
3176 detail::Wrapper<cl_type>(event, retainObject) { }
3190 template <
typename T>
3191 cl_int
getInfo(cl_event_info name, T* param)
const
3193 return detail::errHandler(
3194 detail::getInfo(&::clGetEventInfo, object_, name, param),
3195 __GET_EVENT_INFO_ERR);
3199 template <cl_event_info name>
typename
3204 detail::cl_event_info, name>::param_type param;
3205 cl_int result =
getInfo(name, ¶m);
3213 template <
typename T>
3216 return detail::errHandler(detail::getInfo(
3217 &::clGetEventProfilingInfo, object_, name, param),
3218 __GET_EVENT_PROFILE_INFO_ERR);
3222 template <cl_profiling_info name>
typename
3227 detail::cl_profiling_info, name>::param_type param;
3241 return detail::errHandler(
3242 ::clWaitForEvents(1, &object_),
3243 __WAIT_FOR_EVENTS_ERR);
3246 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
3253 void (CL_CALLBACK * pfn_notify)(cl_event, cl_int,
void *),
3254 void * user_data = NULL)
3256 return detail::errHandler(
3257 ::clSetEventCallback(
3262 __SET_EVENT_CALLBACK_ERR);
3264 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110
3273 return detail::errHandler(
3275 (cl_uint) events.size(), (events.size() > 0) ? (cl_event*)&events.front() : NULL),
3276 __WAIT_FOR_EVENTS_ERR);
3280 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
3294 cl_int * err = NULL)
3297 object_ = ::clCreateUserEvent(
3301 detail::errHandler(error, __CREATE_USER_EVENT_ERR);
3316 return detail::errHandler(
3317 ::clSetUserEventStatus(object_,status),
3318 __SET_USER_EVENT_STATUS_ERR);
3321 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110
3327 inline static cl_int
3328 WaitForEvents(
const vector<Event>& events)
3330 return detail::errHandler(
3332 (cl_uint) events.size(), (events.size() > 0) ? (cl_event*)&events.front() : NULL),
3333 __WAIT_FOR_EVENTS_ERR);
3361 explicit Memory(
const cl_mem& memory,
bool retainObject) :
3362 detail::Wrapper<cl_type>(memory, retainObject) { }
3405 template <
typename T>
3408 return detail::errHandler(
3409 detail::getInfo(&::clGetMemObjectInfo, object_, name, param),
3410 __GET_MEM_OBJECT_INFO_ERR);
3414 template <cl_mem_info name>
typename
3419 detail::cl_mem_info, name>::param_type param;
3420 cl_int result =
getInfo(name, ¶m);
3427 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
3442 void (CL_CALLBACK * pfn_notify)(cl_mem,
void *),
3443 void * user_data = NULL)
3445 return detail::errHandler(
3446 ::clSetMemObjectDestructorCallback(
3450 __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR);
3452 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110
3458 template<
typename IteratorType >
3459 cl_int
copy( IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer );
3460 template<
typename IteratorType >
3461 cl_int
copy(
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator );
3462 template<
typename IteratorType >
3463 cl_int
copy(
const CommandQueue &queue, IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer );
3464 template<
typename IteratorType >
3465 cl_int
copy(
const CommandQueue &queue,
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator );
3468 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
3474 static cl_svm_mem_flags getSVMMemFlags()
3481 template<
class Trait = detail::SVMTraitNull>
3485 static cl_svm_mem_flags getSVMMemFlags()
3487 return CL_MEM_READ_WRITE |
3488 Trait::getSVMMemFlags();
3492 template<
class Trait = detail::SVMTraitNull>
3496 static cl_svm_mem_flags getSVMMemFlags()
3498 return CL_MEM_READ_ONLY |
3499 Trait::getSVMMemFlags();
3503 template<
class Trait = detail::SVMTraitNull>
3507 static cl_svm_mem_flags getSVMMemFlags()
3509 return CL_MEM_WRITE_ONLY |
3510 Trait::getSVMMemFlags();
3514 template<
class Trait = SVMTraitReadWrite<>>
3518 static cl_svm_mem_flags getSVMMemFlags()
3520 return Trait::getSVMMemFlags();
3524 template<
class Trait = SVMTraitReadWrite<>>
3528 static cl_svm_mem_flags getSVMMemFlags()
3530 return CL_MEM_SVM_FINE_GRAIN_BUFFER |
3531 Trait::getSVMMemFlags();
3535 template<
class Trait = SVMTraitReadWrite<>>
3539 static cl_svm_mem_flags getSVMMemFlags()
3542 CL_MEM_SVM_FINE_GRAIN_BUFFER |
3543 CL_MEM_SVM_ATOMICS |
3544 Trait::getSVMMemFlags();
3549 template<
typename T>
3555 const vector<Event>* events = NULL,
3556 Event* event = NULL);
3569 template<
typename T,
class SVMTrait>
3575 typedef T value_type;
3576 typedef value_type* pointer;
3577 typedef const value_type* const_pointer;
3578 typedef value_type& reference;
3579 typedef const value_type& const_reference;
3580 typedef std::size_t size_type;
3581 typedef std::ptrdiff_t difference_type;
3583 template<
typename U>
3589 template<
typename U,
typename V>
3593 context_(
Context::getDefault())
3603 SVMAllocator(
const SVMAllocator &other) :
3604 context_(other.context_)
3608 template<
typename U>
3609 SVMAllocator(
const SVMAllocator<U, SVMTrait> &other) :
3610 context_(other.context_)
3618 pointer address(reference r) CL_HPP_NOEXCEPT_
3620 return std::addressof(r);
3623 const_pointer address(const_reference r) CL_HPP_NOEXCEPT_
3625 return std::addressof(r);
3642 SVMTrait::getSVMMemFlags(),
3645 pointer retValue =
reinterpret_cast<pointer
>(
3647 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
3649 std::bad_alloc excep;
3652 #endif // #if defined(CL_HPP_ENABLE_EXCEPTIONS)
3655 if (!(SVMTrait::getSVMMemFlags() & CL_MEM_SVM_FINE_GRAIN_BUFFER)) {
3656 cl_int err =
enqueueMapSVM(retValue, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE, size*
sizeof(T));
3657 if (err != CL_SUCCESS) {
3658 std::bad_alloc excep;
3667 void deallocate(pointer p, size_type)
3669 clSVMFree(context_(), p);
3678 size_type maxSize = std::numeric_limits<size_type>::max() /
sizeof(T);
3680 for (
const Device &d : context_.
getInfo<CL_CONTEXT_DEVICES>()) {
3683 static_cast<size_type
>(d.getInfo<CL_DEVICE_MAX_MEM_ALLOC_SIZE>()));
3689 template<
class U,
class... Args >
3690 void construct(U* p, Args&&... args)
3706 return (context_==rhs.context_);
3716 template<
class SVMTrait>
3719 typedef void value_type;
3720 typedef value_type* pointer;
3721 typedef const value_type* const_pointer;
3723 template<
typename U>
3729 template<
typename U,
typename V>
3733 #if !defined(CL_HPP_NO_STD_UNIQUE_PTR)
3736 template<
class Alloc>
3743 typedef typename std::allocator_traits<Alloc>::pointer pointer;
3745 Deleter(
const Alloc &alloc, size_type copies) : alloc_{ alloc }, copies_{ copies }
3749 void operator()(pointer ptr)
const {
3750 Alloc tmpAlloc{ alloc_ };
3751 std::allocator_traits<Alloc>::destroy(tmpAlloc, std::addressof(*ptr));
3752 std::allocator_traits<Alloc>::deallocate(tmpAlloc, ptr, copies_);
3763 template <
class T,
class Alloc,
class... Args>
3766 Alloc alloc(alloc_);
3767 static const size_type copies = 1;
3772 T* tmp = std::allocator_traits<Alloc>::allocate(alloc, copies);
3774 std::bad_alloc excep;
3778 std::allocator_traits<Alloc>::construct(
3780 std::addressof(*tmp),
3781 std::forward<Args>(args)...);
3785 catch (std::bad_alloc& b)
3787 std::allocator_traits<Alloc>::deallocate(alloc, tmp, copies);
3792 template<
class T,
class SVMTrait,
class... Args >
3793 cl::pointer<T, detail::Deleter<SVMAllocator<T, SVMTrait>>> allocate_svm(Args... args)
3795 SVMAllocator<T, SVMTrait> alloc;
3796 return cl::allocate_pointer<T>(alloc, args...);
3799 template<
class T,
class SVMTrait,
class... Args >
3800 cl::pointer<T, detail::Deleter<SVMAllocator<T, SVMTrait>>> allocate_svm(
const cl::Context &c, Args... args)
3802 SVMAllocator<T, SVMTrait> alloc(c);
3803 return cl::allocate_pointer<T>(alloc, args...);
3805 #endif // #if !defined(CL_HPP_NO_STD_UNIQUE_PTR)
3810 template <
class T >
3816 template <
class T >
3822 template <
class T >
3825 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200
3849 void* host_ptr = NULL,
3853 object_ = ::clCreateBuffer(context(), flags, size, host_ptr, &error);
3855 detail::errHandler(error, __CREATE_BUFFER_ERR);
3873 void* host_ptr = NULL,
3880 object_ = ::clCreateBuffer(context(), flags, size, host_ptr, &error);
3882 detail::errHandler(error, __CREATE_BUFFER_ERR);
3893 template<
typename IteratorType >
3895 IteratorType startIterator,
3896 IteratorType endIterator,
3898 bool useHostPtr =
false,
3901 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
3904 cl_mem_flags flags = 0;
3906 flags |= CL_MEM_READ_ONLY;
3909 flags |= CL_MEM_READ_WRITE;
3912 flags |= CL_MEM_USE_HOST_PTR;
3915 size_type size =
sizeof(DataType)*(endIterator - startIterator);
3920 object_ = ::clCreateBuffer(context(), flags, size,
static_cast<DataType*
>(&*startIterator), &error);
3922 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
3925 detail::errHandler(error, __CREATE_BUFFER_ERR);
3931 error =
cl::copy(startIterator, endIterator, *
this);
3932 detail::errHandler(error, __CREATE_BUFFER_ERR);
3944 template<
typename IteratorType >
3945 Buffer(
const Context &context, IteratorType startIterator, IteratorType endIterator,
3946 bool readOnly,
bool useHostPtr =
false, cl_int* err = NULL);
3952 template<
typename IteratorType >
3953 Buffer(
const CommandQueue &queue, IteratorType startIterator, IteratorType endIterator,
3954 bool readOnly,
bool useHostPtr =
false, cl_int* err = NULL);
3966 explicit Buffer(
const cl_mem& buffer,
bool retainObject =
false) :
3967 Memory(buffer, retainObject) { }
4007 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
4014 cl_buffer_create_type buffer_create_type,
4015 const void * buffer_create_info,
4016 cl_int * err = NULL)
4020 result.object_ = ::clCreateSubBuffer(
4027 detail::errHandler(error, __CREATE_SUBBUFFER_ERR);
4034 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110
4037 #if defined (CL_HPP_USE_DX_INTEROP)
4046 class BufferD3D10 :
public Buffer
4057 const Context& context,
4059 ID3D10Buffer* bufobj,
4060 cl_int * err = NULL) : pfn_clCreateFromD3D10BufferKHR(nullptr)
4062 typedef CL_API_ENTRY cl_mem (CL_API_CALL *PFN_clCreateFromD3D10BufferKHR)(
4063 cl_context context, cl_mem_flags flags, ID3D10Buffer* buffer,
4064 cl_int* errcode_ret);
4065 PFN_clCreateFromD3D10BufferKHR pfn_clCreateFromD3D10BufferKHR;
4066 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
4067 vector<cl_context_properties> props = context.getInfo<CL_CONTEXT_PROPERTIES>();
4068 cl_platform platform = -1;
4069 for(
int i = 0; i < props.size(); ++i ) {
4070 if( props[i] == CL_CONTEXT_PLATFORM ) {
4071 platform = props[i+1];
4074 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCreateFromD3D10BufferKHR);
4075 #elif CL_HPP_TARGET_OPENCL_VERSION >= 110
4076 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateFromD3D10BufferKHR);
4080 object_ = pfn_clCreateFromD3D10BufferKHR(
4086 detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
4093 BufferD3D10() : Buffer() { }
4102 explicit BufferD3D10(
const cl_mem& buffer,
bool retainObject =
false) :
4103 Buffer(buffer, retainObject) { }
4109 BufferD3D10& operator = (
const cl_mem& rhs)
4118 BufferD3D10(
const BufferD3D10& buf) :
4124 BufferD3D10& operator = (
const BufferD3D10 &buf)
4133 BufferD3D10(BufferD3D10&& buf) CL_HPP_NOEXCEPT_ : Buffer(std::move(buf)) {}
4138 BufferD3D10& operator = (BufferD3D10 &&buf)
4166 cl_int * err = NULL)
4169 object_ = ::clCreateFromGLBuffer(
4175 detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
4191 explicit BufferGL(
const cl_mem& buffer,
bool retainObject =
false) :
4192 Buffer(buffer, retainObject) { }
4234 cl_gl_object_type *type,
4235 cl_GLuint * gl_object_name)
4237 return detail::errHandler(
4238 ::clGetGLObjectInfo(object_,type,gl_object_name),
4239 __GET_GL_OBJECT_INFO_ERR);
4263 cl_int * err = NULL)
4266 object_ = ::clCreateFromGLRenderbuffer(
4272 detail::errHandler(error, __CREATE_GL_RENDER_BUFFER_ERR);
4289 Buffer(buffer, retainObject) { }
4331 cl_gl_object_type *type,
4332 cl_GLuint * gl_object_name)
4334 return detail::errHandler(
4335 ::clGetGLObjectInfo(object_,type,gl_object_name),
4336 __GET_GL_OBJECT_INFO_ERR);
4359 explicit Image(
const cl_mem& image,
bool retainObject =
false) :
4360 Memory(image, retainObject) { }
4403 template <
typename T>
4406 return detail::errHandler(
4407 detail::getInfo(&::clGetImageInfo, object_, name, param),
4408 __GET_IMAGE_INFO_ERR);
4412 template <cl_image_info name>
typename
4417 detail::cl_image_info, name>::param_type param;
4426 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
4445 void* host_ptr = NULL,
4449 cl_image_desc desc =
4451 CL_MEM_OBJECT_IMAGE1D,
4453 0, 0, 0, 0, 0, 0, 0, 0
4455 object_ = ::clCreateImage(
4463 detail::errHandler(error, __CREATE_IMAGE_ERR);
4479 explicit Image1D(
const cl_mem& image1D,
bool retainObject =
false) :
4480 Image(image1D, retainObject) { }
4537 cl_image_desc desc =
4539 CL_MEM_OBJECT_IMAGE1D_BUFFER,
4541 0, 0, 0, 0, 0, 0, 0,
4544 object_ = ::clCreateImage(
4552 detail::errHandler(error, __CREATE_IMAGE_ERR);
4568 Image(image1D, retainObject) { }
4616 size_type arraySize,
4619 void* host_ptr = NULL,
4623 cl_image_desc desc =
4625 CL_MEM_OBJECT_IMAGE1D_ARRAY,
4632 object_ = ::clCreateImage(
4640 detail::errHandler(error, __CREATE_IMAGE_ERR);
4655 explicit Image1DArray(
const cl_mem& imageArray,
bool retainObject =
false) :
4656 Image(imageArray, retainObject) { }
4694 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 120
4716 size_type row_pitch = 0,
4717 void* host_ptr = NULL,
4721 bool useCreateImage;
4723 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
4726 cl_uint version = detail::getContextPlatformVersion(context());
4727 useCreateImage = (version >= 0x10002);
4729 #elif CL_HPP_TARGET_OPENCL_VERSION >= 120
4730 useCreateImage =
true;
4732 useCreateImage =
false;
4735 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
4738 cl_image_desc desc =
4740 CL_MEM_OBJECT_IMAGE2D,
4747 object_ = ::clCreateImage(
4755 detail::errHandler(error, __CREATE_IMAGE_ERR);
4760 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
4761 #if CL_HPP_MINIMUM_OPENCL_VERSION < 120
4762 if (!useCreateImage)
4764 object_ = ::clCreateImage2D(
4765 context(), flags,&format, width, height, row_pitch, host_ptr, &error);
4767 detail::errHandler(error, __CREATE_IMAGE2D_ERR);
4772 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 120
4775 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 || defined(CL_HPP_USE_CL_IMAGE2D_FROM_BUFFER_KHR)
4784 const Buffer &sourceBuffer,
4787 size_type row_pitch = 0,
4788 cl_int* err =
nullptr)
4792 cl_image_desc desc =
4794 CL_MEM_OBJECT_IMAGE2D,
4803 object_ = ::clCreateImage(
4811 detail::errHandler(error, __CREATE_IMAGE_ERR);
4812 if (err !=
nullptr) {
4816 #endif //#if CL_HPP_TARGET_OPENCL_VERSION >= 200 || defined(CL_HPP_USE_CL_IMAGE2D_FROM_BUFFER_KHR)
4818 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
4833 cl_channel_order order,
4834 const Image &sourceImage,
4835 cl_int* err =
nullptr)
4840 size_type sourceWidth =
4842 size_type sourceHeight =
4844 size_type sourceRowPitch =
4846 cl_uint sourceNumMIPLevels =
4848 cl_uint sourceNumSamples =
4850 cl_image_format sourceFormat =
4855 sourceFormat.image_channel_order = order;
4856 cl_image_desc desc =
4858 CL_MEM_OBJECT_IMAGE2D,
4869 object_ = ::clCreateImage(
4877 detail::errHandler(error, __CREATE_IMAGE_ERR);
4878 if (err !=
nullptr) {
4882 #endif //#if CL_HPP_TARGET_OPENCL_VERSION >= 200
4894 explicit Image2D(
const cl_mem& image2D,
bool retainObject =
false) :
4895 Image(image2D, retainObject) { }
4938 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
4962 cl_int * err = NULL)
4965 object_ = ::clCreateFromGLTexture2D(
4973 detail::errHandler(error, __CREATE_GL_TEXTURE_2D_ERR);
4990 explicit Image2DGL(
const cl_mem& image,
bool retainObject =
false) :
4991 Image2D(image, retainObject) { }
5031 } CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
5032 #endif // CL_USE_DEPRECATED_OPENCL_1_1_APIS
5034 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
5045 size_type arraySize,
5049 size_type slicePitch,
5050 void* host_ptr = NULL,
5054 cl_image_desc desc =
5056 CL_MEM_OBJECT_IMAGE2D_ARRAY,
5065 object_ = ::clCreateImage(
5073 detail::errHandler(error, __CREATE_IMAGE_ERR);
5088 explicit Image2DArray(
const cl_mem& imageArray,
bool retainObject =
false) :
Image(imageArray, retainObject) { }
5124 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 120
5146 size_type row_pitch = 0,
5147 size_type slice_pitch = 0,
5148 void* host_ptr = NULL,
5152 bool useCreateImage;
5154 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
5157 cl_uint version = detail::getContextPlatformVersion(context());
5158 useCreateImage = (version >= 0x10002);
5160 #elif CL_HPP_TARGET_OPENCL_VERSION >= 120
5161 useCreateImage =
true;
5163 useCreateImage =
false;
5166 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
5169 cl_image_desc desc =
5171 CL_MEM_OBJECT_IMAGE3D,
5180 object_ = ::clCreateImage(
5188 detail::errHandler(error, __CREATE_IMAGE_ERR);
5193 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
5194 #if CL_HPP_MINIMUM_OPENCL_VERSION < 120
5195 if (!useCreateImage)
5197 object_ = ::clCreateImage3D(
5198 context(), flags, &format, width, height, depth, row_pitch,
5199 slice_pitch, host_ptr, &error);
5201 detail::errHandler(error, __CREATE_IMAGE3D_ERR);
5206 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 120
5219 explicit Image3D(
const cl_mem& image3D,
bool retainObject =
false) :
5220 Image(image3D, retainObject) { }
5261 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
5284 cl_int * err = NULL)
5287 object_ = ::clCreateFromGLTexture3D(
5295 detail::errHandler(error, __CREATE_GL_TEXTURE_3D_ERR);
5311 explicit Image3DGL(
const cl_mem& image,
bool retainObject =
false) :
5312 Image3D(image, retainObject) { }
5352 #endif // CL_USE_DEPRECATED_OPENCL_1_1_APIS
5354 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
5370 cl_int * err = NULL)
5373 object_ = ::clCreateFromGLTexture(
5381 detail::errHandler(error, __CREATE_GL_TEXTURE_ERR);
5396 explicit ImageGL(
const cl_mem& image,
bool retainObject =
false) :
5397 Image(image, retainObject) { }
5399 ImageGL& operator = (
const cl_mem& rhs)
5433 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
5437 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
5459 cl_uint packet_size,
5460 cl_uint max_packets,
5465 cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS;
5466 object_ = ::clCreatePipe(context(), flags, packet_size, max_packets,
nullptr, &error);
5468 detail::errHandler(error, __CREATE_PIPE_ERR);
5483 cl_uint packet_size,
5484 cl_uint max_packets,
5491 cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS;
5492 object_ = ::clCreatePipe(context(), flags, packet_size, max_packets,
nullptr, &error);
5494 detail::errHandler(error, __CREATE_PIPE_ERR);
5510 explicit Pipe(
const cl_mem& pipe,
bool retainObject =
false) :
5511 Memory(pipe, retainObject) { }
5552 template <
typename T>
5555 return detail::errHandler(
5556 detail::getInfo(&::clGetPipeInfo, object_, name, param),
5557 __GET_PIPE_INFO_ERR);
5561 template <cl_pipe_info name>
typename
5566 detail::cl_pipe_info, name>::param_type param;
5567 cl_int result =
getInfo(name, ¶m);
5574 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200
5597 cl_bool normalized_coords,
5598 cl_addressing_mode addressing_mode,
5599 cl_filter_mode filter_mode,
5604 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
5605 cl_sampler_properties sampler_properties[] = {
5606 CL_SAMPLER_NORMALIZED_COORDS, normalized_coords,
5607 CL_SAMPLER_ADDRESSING_MODE, addressing_mode,
5608 CL_SAMPLER_FILTER_MODE, filter_mode,
5610 object_ = ::clCreateSamplerWithProperties(
5615 detail::errHandler(error, __CREATE_SAMPLER_WITH_PROPERTIES_ERR);
5620 object_ = ::clCreateSampler(
5627 detail::errHandler(error, __CREATE_SAMPLER_ERR);
5642 explicit Sampler(
const cl_sampler& sampler,
bool retainObject =
false) :
5643 detail::Wrapper<cl_type>(sampler, retainObject) { }
5685 template <
typename T>
5686 cl_int
getInfo(cl_sampler_info name, T* param)
const
5688 return detail::errHandler(
5689 detail::getInfo(&::clGetSamplerInfo, object_, name, param),
5690 __GET_SAMPLER_INFO_ERR);
5694 template <cl_sampler_info name>
typename
5699 detail::cl_sampler_info, name>::param_type param;
5700 cl_int result =
getInfo(name, ¶m);
5710 class DeviceCommandQueue;
5717 size_type sizes_[3];
5718 cl_uint dimensions_;
5749 NDRange(size_type size0, size_type size1, size_type size2)
5761 operator const size_type*()
const {
5775 return dimensions_*
sizeof(size_type);
5783 const size_type* get()
const
5790 static const NDRange NullRange;
5800 template <
typename T,
class Enable =
void>
5805 template <
typename T>
5808 static size_type size(
const T&) {
return sizeof(T); }
5809 static const T* ptr(
const T& value) {
return &value; }
5814 template <
typename T>
5817 static size_type size(
const T&) {
return sizeof(cl_mem); }
5818 static const cl_mem* ptr(
const T& value) {
return &(value()); }
5826 static size_type size(
const LocalSpaceArg& value) {
return value.size_; }
5827 static const void* ptr(
const LocalSpaceArg&) {
return NULL; }
5854 inline Kernel(
const Program& program,
const char* name, cl_int* err = NULL);
5867 explicit Kernel(
const cl_kernel& kernel,
bool retainObject =
false) :
5868 detail::Wrapper<cl_type>(kernel, retainObject) { }
5909 template <
typename T>
5910 cl_int getInfo(cl_kernel_info name, T* param)
const
5912 return detail::errHandler(
5913 detail::getInfo(&::clGetKernelInfo, object_, name, param),
5914 __GET_KERNEL_INFO_ERR);
5917 template <cl_kernel_info name>
typename
5918 detail::param_traits<detail::cl_kernel_info, name>::param_type
5919 getInfo(cl_int* err = NULL)
const
5921 typename detail::param_traits<
5922 detail::cl_kernel_info, name>::param_type param;
5923 cl_int result = getInfo(name, ¶m);
5930 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
5931 template <
typename T>
5932 cl_int getArgInfo(cl_uint argIndex, cl_kernel_arg_info name, T* param)
const
5934 return detail::errHandler(
5935 detail::getInfo(&::clGetKernelArgInfo, object_, argIndex, name, param),
5936 __GET_KERNEL_ARG_INFO_ERR);
5939 template <cl_kernel_arg_info name>
typename
5940 detail::param_traits<detail::cl_kernel_arg_info, name>::param_type
5941 getArgInfo(cl_uint argIndex, cl_int* err = NULL)
const
5943 typename detail::param_traits<
5944 detail::cl_kernel_arg_info, name>::param_type param;
5945 cl_int result = getArgInfo(argIndex, name, ¶m);
5951 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
5953 template <
typename T>
5954 cl_int getWorkGroupInfo(
5955 const Device& device, cl_kernel_work_group_info name, T* param)
const
5957 return detail::errHandler(
5959 &::clGetKernelWorkGroupInfo, object_, device(), name, param),
5960 __GET_KERNEL_WORK_GROUP_INFO_ERR);
5963 template <cl_kernel_work_group_info name>
typename
5964 detail::param_traits<detail::cl_kernel_work_group_info, name>::param_type
5965 getWorkGroupInfo(
const Device& device, cl_int* err = NULL)
const
5967 typename detail::param_traits<
5968 detail::cl_kernel_work_group_info, name>::param_type param;
5969 cl_int result = getWorkGroupInfo(device, name, ¶m);
5976 #if (CL_HPP_TARGET_OPENCL_VERSION >= 200 && defined(CL_HPP_USE_CL_SUB_GROUPS_KHR)) || CL_HPP_TARGET_OPENCL_VERSION >= 210
5977 cl_int getSubGroupInfo(
const cl::Device &dev, cl_kernel_sub_group_info name,
const cl::NDRange &range, size_type* param)
const
5979 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
5981 return detail::errHandler(
5982 clGetKernelSubGroupInfo(object_, dev(), name, range.
size(), range.get(),
sizeof(size_type), param,
nullptr),
5983 __GET_KERNEL_SUB_GROUP_INFO_ERR);
5985 #else // #if CL_HPP_TARGET_OPENCL_VERSION >= 210
5987 typedef clGetKernelSubGroupInfoKHR_fn PFN_clGetKernelSubGroupInfoKHR;
5988 static PFN_clGetKernelSubGroupInfoKHR pfn_clGetKernelSubGroupInfoKHR = NULL;
5989 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetKernelSubGroupInfoKHR);
5991 return detail::errHandler(
5992 pfn_clGetKernelSubGroupInfoKHR(object_, dev(), name, range.
size(), range.get(),
sizeof(size_type), param,
nullptr),
5993 __GET_KERNEL_SUB_GROUP_INFO_ERR);
5995 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 210
5998 template <cl_kernel_sub_group_info name>
5999 size_type getSubGroupInfo(
const cl::Device &dev,
const cl::NDRange &range, cl_int* err = NULL)
const
6002 cl_int result = getSubGroupInfo(dev, name, range, ¶m);
6008 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200
6010 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
6013 template<
typename T,
class D>
6014 cl_int
setArg(cl_uint index,
const cl::pointer<T, D> &argPtr)
6016 return detail::errHandler(
6017 ::clSetKernelArgSVMPointer(object_, index, argPtr.get()),
6018 __SET_KERNEL_ARGS_ERR);
6023 template<
typename T,
class Alloc>
6024 cl_int
setArg(cl_uint index,
const cl::vector<T, Alloc> &argPtr)
6026 return detail::errHandler(
6027 ::clSetKernelArgSVMPointer(object_, index, argPtr.data()),
6028 __SET_KERNEL_ARGS_ERR);
6033 template<
typename T>
6034 typename std::enable_if<std::is_pointer<T>::value, cl_int>::type
6037 return detail::errHandler(
6038 ::clSetKernelArgSVMPointer(object_, index, argPtr),
6039 __SET_KERNEL_ARGS_ERR);
6041 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200
6045 template <
typename T>
6046 typename std::enable_if<!std::is_pointer<T>::value, cl_int>::type
6049 return detail::errHandler(
6055 __SET_KERNEL_ARGS_ERR);
6058 cl_int
setArg(cl_uint index, size_type size,
const void* argPtr)
6060 return detail::errHandler(
6061 ::clSetKernelArg(object_, index, size, argPtr),
6062 __SET_KERNEL_ARGS_ERR);
6065 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
6072 return detail::errHandler(
6073 ::clSetKernelExecInfo(
6075 CL_KERNEL_EXEC_INFO_SVM_PTRS,
6076 sizeof(
void*)*pointerList.size(),
6077 pointerList.data()));
6084 template<
int ArrayLength>
6087 return detail::errHandler(
6088 ::clSetKernelExecInfo(
6090 CL_KERNEL_EXEC_INFO_SVM_PTRS,
6091 sizeof(
void*)*pointerList.size(),
6092 pointerList.data()));
6108 cl_bool svmEnabled_ = svmEnabled ? CL_TRUE : CL_FALSE;
6109 return detail::errHandler(
6110 ::clSetKernelExecInfo(
6112 CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM,
6119 template<
int index,
int ArrayLength,
class D,
typename T0,
typename T1,
typename... Ts>
6120 void setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList,
const pointer<T0, D> &t0,
const pointer<T1, D> &t1, Ts & ... ts)
6122 pointerList[index] =
static_cast<void*
>(t0.get());
6123 setSVMPointersHelper<index + 1, ArrayLength>(pointerList, t1, ts...);
6126 template<
int index,
int ArrayLength,
typename T0,
typename T1,
typename... Ts>
6127 typename std::enable_if<std::is_pointer<T0>::value,
void>::type
6128 setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList, T0 t0, T1 t1, Ts... ts)
6130 pointerList[index] =
static_cast<void*
>(t0);
6131 setSVMPointersHelper<index + 1, ArrayLength>(pointerList, t1, ts...);
6134 template<
int index,
int ArrayLength,
typename T0,
class D>
6135 void setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList,
const pointer<T0, D> &t0)
6137 pointerList[index] =
static_cast<void*
>(t0.get());
6141 template<
int index,
int ArrayLength,
typename T0>
6142 typename std::enable_if<std::is_pointer<T0>::value,
void>::type
6143 setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList, T0 t0)
6145 pointerList[index] =
static_cast<void*
>(t0);
6148 template<
typename T0,
typename... Ts>
6151 std::array<
void*, 1 +
sizeof...(Ts)> pointerList;
6153 setSVMPointersHelper<0, 1 +
sizeof...(Ts)>(pointerList, t0, ts...);
6154 return detail::errHandler(
6155 ::clSetKernelExecInfo(
6157 CL_KERNEL_EXEC_INFO_SVM_PTRS,
6158 sizeof(
void*)*(1 +
sizeof...(Ts)),
6159 pointerList.data()));
6162 template<
typename T>
6163 cl_int setExecInfo(cl_kernel_exec_info param_name,
const T& val)
6165 return detail::errHandler(
6166 ::clSetKernelExecInfo(
6173 template<cl_kernel_exec_info name>
6174 cl_int setExecInfo(
typename detail::param_traits<detail::cl_kernel_exec_info, name>::param_type& val)
6176 return setExecInfo(name, val);
6178 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200
6180 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
6189 Kernel retValue(clCloneKernel(this->get(), &error));
6191 detail::errHandler(error, __CLONE_KERNEL_ERR);
6194 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 210
6203 #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6204 typedef vector<vector<unsigned char>> Binaries;
6205 typedef vector<string> Sources;
6206 #else // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6207 typedef vector<std::pair<const void*, size_type> > Binaries;
6208 typedef vector<std::pair<const char*, size_type> > Sources;
6209 #endif // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6212 const string& source,
6218 const char * strings = source.c_str();
6219 const size_type length = source.size();
6223 object_ = ::clCreateProgramWithSource(
6224 context(), (cl_uint)1, &strings, &length, &error);
6226 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6228 if (error == CL_SUCCESS && build) {
6230 error = ::clBuildProgram(
6234 #
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6242 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6252 const string& source,
6258 const char * strings = source.c_str();
6259 const size_type length = source.size();
6261 object_ = ::clCreateProgramWithSource(
6262 context(), (cl_uint)1, &strings, &length, &error);
6264 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6266 if (error == CL_SUCCESS && build) {
6267 error = ::clBuildProgram(
6271 #
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6279 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6292 const Sources& sources,
6298 const size_type n = (size_type)sources.size();
6300 vector<size_type> lengths(n);
6301 vector<const char*> strings(n);
6303 for (size_type i = 0; i < n; ++i) {
6304 #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6305 strings[i] = sources[(int)i].data();
6306 lengths[i] = sources[(int)i].length();
6307 #else // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6308 strings[i] = sources[(int)i].first;
6309 lengths[i] = sources[(int)i].second;
6310 #endif // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6313 object_ = ::clCreateProgramWithSource(
6314 context(), (cl_uint)n, strings.data(), lengths.data(), &error);
6316 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6328 const Sources& sources,
6333 const size_type n = (size_type)sources.size();
6335 vector<size_type> lengths(n);
6336 vector<const char*> strings(n);
6338 for (size_type i = 0; i < n; ++i) {
6339 #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6340 strings[i] = sources[(int)i].data();
6341 lengths[i] = sources[(int)i].length();
6342 #else // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6343 strings[i] = sources[(int)i].first;
6344 lengths[i] = sources[(int)i].second;
6345 #endif // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6348 object_ = ::clCreateProgramWithSource(
6349 context(), (cl_uint)n, strings.data(), lengths.data(), &error);
6351 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6358 #if CL_HPP_TARGET_OPENCL_VERSION >= 210 || (CL_HPP_TARGET_OPENCL_VERSION==200 && defined(CL_HPP_USE_IL_KHR))
6364 const vector<char>& IL,
6372 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
6374 object_ = ::clCreateProgramWithIL(
6375 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6377 #else // #if CL_HPP_TARGET_OPENCL_VERSION >= 210
6379 typedef clCreateProgramWithILKHR_fn PFN_clCreateProgramWithILKHR;
6380 static PFN_clCreateProgramWithILKHR pfn_clCreateProgramWithILKHR = NULL;
6381 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateProgramWithILKHR);
6383 return detail::errHandler(
6384 pfn_clCreateProgramWithILKHR(
6385 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6389 detail::errHandler(error, __CREATE_PROGRAM_WITH_IL_ERR);
6391 if (error == CL_SUCCESS && build) {
6393 error = ::clBuildProgram(
6397 #
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6405 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6420 const vector<char>& IL,
6426 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
6428 object_ = ::clCreateProgramWithIL(
6429 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6431 #else // #if CL_HPP_TARGET_OPENCL_VERSION >= 210
6433 typedef clCreateProgramWithILKHR_fn PFN_clCreateProgramWithILKHR;
6434 static PFN_clCreateProgramWithILKHR pfn_clCreateProgramWithILKHR = NULL;
6435 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateProgramWithILKHR);
6437 return detail::errHandler(
6438 pfn_clCreateProgramWithILKHR(
6439 context(),
static_cast<const void*
>(IL.data()), IL.size(), &error);
6443 detail::errHandler(error, __CREATE_PROGRAM_WITH_IL_ERR);
6445 if (error == CL_SUCCESS && build) {
6446 error = ::clBuildProgram(
6450 #
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6458 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6465 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 210
6488 const vector<Device>& devices,
6489 const Binaries& binaries,
6490 vector<cl_int>* binaryStatus = NULL,
6495 const size_type numDevices = devices.size();
6498 if(binaries.size() != numDevices) {
6499 error = CL_INVALID_VALUE;
6500 detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
6508 vector<size_type> lengths(numDevices);
6509 vector<const unsigned char*> images(numDevices);
6510 #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6511 for (size_type i = 0; i < numDevices; ++i) {
6512 images[i] = binaries[i].data();
6513 lengths[i] = binaries[(int)i].size();
6515 #else // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6516 for (size_type i = 0; i < numDevices; ++i) {
6517 images[i] = (
const unsigned char*)binaries[i].first;
6518 lengths[i] = binaries[(int)i].second;
6520 #endif // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
6522 vector<cl_device_id> deviceIDs(numDevices);
6523 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6524 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6528 binaryStatus->resize(numDevices);
6531 object_ = ::clCreateProgramWithBinary(
6532 context(), (cl_uint) devices.size(),
6534 lengths.data(), images.data(), (binaryStatus != NULL && numDevices > 0)
6535 ? &binaryStatus->front()
6538 detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
6545 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
6552 const vector<Device>& devices,
6553 const string& kernelNames,
6559 size_type numDevices = devices.size();
6560 vector<cl_device_id> deviceIDs(numDevices);
6561 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6562 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6565 object_ = ::clCreateProgramWithBuiltInKernels(
6567 (cl_uint) devices.size(),
6569 kernelNames.c_str(),
6572 detail::errHandler(error, __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR);
6577 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
6588 explicit Program(
const cl_program& program,
bool retainObject =
false) :
6589 detail::Wrapper<cl_type>(program, retainObject) { }
6591 Program& operator = (
const cl_program& rhs)
6626 const vector<Device>& devices,
6627 const char* options = NULL,
6628 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6629 void* data = NULL)
const
6631 size_type numDevices = devices.size();
6632 vector<cl_device_id> deviceIDs(numDevices);
6634 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6635 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6638 cl_int buildError = ::clBuildProgram(
6647 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6651 const Device& device,
6652 const char* options = NULL,
6653 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6654 void* data = NULL)
const
6656 cl_device_id deviceID = device();
6658 cl_int buildError = ::clBuildProgram(
6666 BuildLogType buildLog(1);
6667 buildLog.push_back(std::make_pair(device, getBuildInfo<CL_PROGRAM_BUILD_LOG>(device)));
6668 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, buildLog);
6672 const char* options = NULL,
6673 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6674 void* data = NULL)
const
6676 cl_int buildError = ::clBuildProgram(
6684 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6687 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
6689 const char* options = NULL,
6690 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6691 void* data = NULL)
const
6693 cl_int error = ::clCompileProgram(
6703 return detail::buildErrHandler(error, __COMPILE_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6705 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
6707 template <
typename T>
6708 cl_int getInfo(cl_program_info name, T* param)
const
6710 return detail::errHandler(
6711 detail::getInfo(&::clGetProgramInfo, object_, name, param),
6712 __GET_PROGRAM_INFO_ERR);
6715 template <cl_program_info name>
typename
6716 detail::param_traits<detail::cl_program_info, name>::param_type
6717 getInfo(cl_int* err = NULL)
const
6719 typename detail::param_traits<
6720 detail::cl_program_info, name>::param_type param;
6721 cl_int result = getInfo(name, ¶m);
6728 template <
typename T>
6729 cl_int getBuildInfo(
6730 const Device& device, cl_program_build_info name, T* param)
const
6732 return detail::errHandler(
6734 &::clGetProgramBuildInfo, object_, device(), name, param),
6735 __GET_PROGRAM_BUILD_INFO_ERR);
6738 template <cl_program_build_info name>
typename
6739 detail::param_traits<detail::cl_program_build_info, name>::param_type
6740 getBuildInfo(
const Device& device, cl_int* err = NULL)
const
6742 typename detail::param_traits<
6743 detail::cl_program_build_info, name>::param_type param;
6744 cl_int result = getBuildInfo(device, name, ¶m);
6756 template <cl_program_build_info name>
6757 vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, name>::param_type>>
6760 cl_int result = CL_SUCCESS;
6762 auto devs = getInfo<CL_PROGRAM_DEVICES>(&result);
6763 vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, name>::param_type>>
6767 if (result != CL_SUCCESS) {
6776 detail::cl_program_build_info, name>::param_type param;
6777 result = getBuildInfo(d, name, ¶m);
6781 if (result != CL_SUCCESS) {
6789 if (result != CL_SUCCESS) {
6795 cl_int createKernels(vector<Kernel>* kernels)
6798 cl_int err = ::clCreateKernelsInProgram(object_, 0, NULL, &numKernels);
6799 if (err != CL_SUCCESS) {
6800 return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
6803 vector<cl_kernel> value(numKernels);
6805 err = ::clCreateKernelsInProgram(
6806 object_, numKernels, value.data(), NULL);
6807 if (err != CL_SUCCESS) {
6808 return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
6812 kernels->resize(value.size());
6816 for (size_type i = 0; i < value.size(); i++) {
6819 (*kernels)[i] = Kernel(value[i],
false);
6825 #if CL_HPP_TARGET_OPENCL_VERSION >= 220
6826 #if defined(CL_USE_DEPRECATED_OPENCL_2_2_APIS)
6838 void (CL_CALLBACK * pfn_notify)(cl_program program,
void * user_data),
6839 void * user_data = NULL) CL_EXT_SUFFIX__VERSION_2_2_DEPRECATED
6841 return detail::errHandler(
6842 ::clSetProgramReleaseCallback(
6846 __SET_PROGRAM_RELEASE_CALLBACK_ERR);
6848 #endif // #if defined(CL_USE_DEPRECATED_OPENCL_2_2_APIS)
6854 template <
typename T>
6855 typename std::enable_if<!std::is_pointer<T>::value, cl_int>::type
6858 return detail::errHandler(
6859 ::clSetProgramSpecializationConstant(
6864 __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR);
6873 return detail::errHandler(
6874 ::clSetProgramSpecializationConstant(
6879 __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR);
6881 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 220
6884 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
6885 inline Program linkProgram(
6888 const char* options = NULL,
6889 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6893 cl_int error_local = CL_SUCCESS;
6895 cl_program programs[2] = { input1(), input2() };
6897 Context ctx = input1.getInfo<CL_PROGRAM_CONTEXT>(&error_local);
6898 if(error_local!=CL_SUCCESS) {
6899 detail::errHandler(error_local, __LINK_PROGRAM_ERR);
6902 cl_program prog = ::clLinkProgram(
6913 detail::errHandler(error_local,__COMPILE_PROGRAM_ERR);
6918 return Program(prog);
6921 inline Program linkProgram(
6922 vector<Program> inputPrograms,
6923 const char* options = NULL,
6924 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6928 cl_int error_local = CL_SUCCESS;
6930 vector<cl_program> programs(inputPrograms.size());
6932 for (
unsigned int i = 0; i < inputPrograms.size(); i++) {
6933 programs[i] = inputPrograms[i]();
6937 if(inputPrograms.size() > 0) {
6938 ctx = inputPrograms[0].getInfo<CL_PROGRAM_CONTEXT>(&error_local);
6939 if(error_local!=CL_SUCCESS) {
6940 detail::errHandler(error_local, __LINK_PROGRAM_ERR);
6943 cl_program prog = ::clLinkProgram(
6948 (cl_uint)inputPrograms.size(),
6954 detail::errHandler(error_local,__COMPILE_PROGRAM_ERR);
6959 return Program(prog,
false);
6961 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
6965 inline cl_int cl::Program::getInfo(cl_program_info name, vector<vector<unsigned char>>* param)
const
6967 if (name != CL_PROGRAM_BINARIES) {
6968 return CL_INVALID_VALUE;
6974 vector<size_type> sizes = getInfo<CL_PROGRAM_BINARY_SIZES>();
6975 size_type numBinaries = sizes.size();
6978 param->resize(numBinaries);
6979 for (size_type i = 0; i < numBinaries; ++i) {
6980 (*param)[i].resize(sizes[i]);
6983 return detail::errHandler(
6984 detail::getInfo(&::clGetProgramInfo, object_, name, param),
6985 __GET_PROGRAM_INFO_ERR);
6992 inline vector<vector<unsigned char>> cl::Program::getInfo<CL_PROGRAM_BINARIES>(cl_int* err)
const
6994 vector<vector<unsigned char>> binariesVectors;
6996 cl_int result = getInfo(CL_PROGRAM_BINARIES, &binariesVectors);
7000 return binariesVectors;
7003 #if CL_HPP_TARGET_OPENCL_VERSION >= 220
7008 cl_uchar ucValue = value ? CL_UCHAR_MAX : 0;
7009 return detail::errHandler(
7010 ::clSetProgramSpecializationConstant(
7015 __SET_PROGRAM_SPECIALIZATION_CONSTANT_ERR);
7017 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 220
7019 inline Kernel::Kernel(
const Program& program,
const char* name, cl_int* err)
7023 object_ = ::clCreateKernel(program(), name, &error);
7024 detail::errHandler(error, __CREATE_KERNEL_ERR);
7032 enum class QueueProperties : cl_command_queue_properties
7035 Profiling = CL_QUEUE_PROFILING_ENABLE,
7036 OutOfOrder = CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE,
7039 inline QueueProperties operator|(QueueProperties lhs, QueueProperties rhs)
7041 return static_cast<QueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) |
static_cast<cl_command_queue_properties
>(rhs));
7050 static std::once_flag default_initialized_;
7052 static cl_int default_error_;
7059 static void makeDefault()
7064 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
7071 if (error != CL_SUCCESS) {
7072 default_error_ = error;
7076 default_ =
CommandQueue(context, device, 0, &default_error_);
7079 #if defined(CL_HPP_ENABLE_EXCEPTIONS)
7080 catch (cl::Error &e) {
7081 default_error_ = e.err();
7091 static void makeDefaultProvided(
const CommandQueue &c) {
7096 #ifdef CL_HPP_UNIT_TEST_ENABLE
7103 static void unitTestClearDefault() {
7106 #endif // #ifdef CL_HPP_UNIT_TEST_ENABLE
7114 cl_command_queue_properties properties,
7120 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7122 if (error != CL_SUCCESS) {
7129 bool useWithProperties;
7131 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7134 cl_uint version = detail::getContextPlatformVersion(context());
7135 useWithProperties = (version >= 0x20000);
7137 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7138 useWithProperties =
true;
7140 useWithProperties =
false;
7143 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
7144 if (useWithProperties) {
7145 cl_queue_properties queue_properties[] = {
7146 CL_QUEUE_PROPERTIES, properties, 0 };
7147 if ((properties & CL_QUEUE_ON_DEVICE) == 0) {
7148 object_ = ::clCreateCommandQueueWithProperties(
7149 context(), device(), queue_properties, &error);
7152 error = CL_INVALID_QUEUE_PROPERTIES;
7155 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7160 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200
7161 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7162 if (!useWithProperties) {
7163 object_ = ::clCreateCommandQueue(
7164 context(), device(), properties, &error);
7166 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7171 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 200
7180 QueueProperties properties,
7186 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7188 if (error != CL_SUCCESS) {
7195 bool useWithProperties;
7197 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7200 cl_uint version = detail::getContextPlatformVersion(context());
7201 useWithProperties = (version >= 0x20000);
7203 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7204 useWithProperties =
true;
7206 useWithProperties =
false;
7209 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
7210 if (useWithProperties) {
7211 cl_queue_properties queue_properties[] = {
7212 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
7214 object_ = ::clCreateCommandQueueWithProperties(
7215 context(), device(), queue_properties, &error);
7217 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7222 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200
7223 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7224 if (!useWithProperties) {
7225 object_ = ::clCreateCommandQueue(
7226 context(), device(),
static_cast<cl_command_queue_properties
>(properties), &error);
7228 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7233 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 200
7244 cl_command_queue_properties properties = 0,
7248 bool useWithProperties;
7249 vector<cl::Device> devices;
7250 error = context.
getInfo(CL_CONTEXT_DEVICES, &devices);
7252 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7254 if (error != CL_SUCCESS)
7262 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7265 cl_uint version = detail::getContextPlatformVersion(context());
7266 useWithProperties = (version >= 0x20000);
7268 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7269 useWithProperties =
true;
7271 useWithProperties =
false;
7274 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
7275 if (useWithProperties) {
7276 cl_queue_properties queue_properties[] = {
7277 CL_QUEUE_PROPERTIES, properties, 0 };
7278 if ((properties & CL_QUEUE_ON_DEVICE) == 0) {
7279 object_ = ::clCreateCommandQueueWithProperties(
7280 context(), devices[0](), queue_properties, &error);
7283 error = CL_INVALID_QUEUE_PROPERTIES;
7286 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7291 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200
7292 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7293 if (!useWithProperties) {
7294 object_ = ::clCreateCommandQueue(
7295 context(), devices[0](), properties, &error);
7297 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7302 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 200
7311 QueueProperties properties,
7315 bool useWithProperties;
7316 vector<cl::Device> devices;
7317 error = context.
getInfo(CL_CONTEXT_DEVICES, &devices);
7319 detail::errHandler(error, __CREATE_CONTEXT_ERR);
7321 if (error != CL_SUCCESS)
7329 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7332 cl_uint version = detail::getContextPlatformVersion(context());
7333 useWithProperties = (version >= 0x20000);
7335 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7336 useWithProperties =
true;
7338 useWithProperties =
false;
7341 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
7342 if (useWithProperties) {
7343 cl_queue_properties queue_properties[] = {
7344 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
7345 object_ = ::clCreateCommandQueueWithProperties(
7346 context(), devices[0](), queue_properties, &error);
7348 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7353 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200
7354 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7355 if (!useWithProperties) {
7356 object_ = ::clCreateCommandQueue(
7357 context(), devices[0](),
static_cast<cl_command_queue_properties
>(properties), &error);
7359 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7364 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 200
7374 cl_command_queue_properties properties = 0,
7378 bool useWithProperties;
7380 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7383 cl_uint version = detail::getContextPlatformVersion(context());
7384 useWithProperties = (version >= 0x20000);
7386 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7387 useWithProperties =
true;
7389 useWithProperties =
false;
7392 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
7393 if (useWithProperties) {
7394 cl_queue_properties queue_properties[] = {
7395 CL_QUEUE_PROPERTIES, properties, 0 };
7396 object_ = ::clCreateCommandQueueWithProperties(
7397 context(), device(), queue_properties, &error);
7399 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7404 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200
7405 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7406 if (!useWithProperties) {
7407 object_ = ::clCreateCommandQueue(
7408 context(), device(), properties, &error);
7410 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7415 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 200
7425 QueueProperties properties,
7429 bool useWithProperties;
7431 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
7434 cl_uint version = detail::getContextPlatformVersion(context());
7435 useWithProperties = (version >= 0x20000);
7437 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200
7438 useWithProperties =
true;
7440 useWithProperties =
false;
7443 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
7444 if (useWithProperties) {
7445 cl_queue_properties queue_properties[] = {
7446 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
7447 object_ = ::clCreateCommandQueueWithProperties(
7448 context(), device(), queue_properties, &error);
7450 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7455 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200
7456 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200
7457 if (!useWithProperties) {
7458 object_ = ::clCreateCommandQueue(
7459 context(), device(),
static_cast<cl_command_queue_properties
>(properties), &error);
7461 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7466 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 200
7471 std::call_once(default_initialized_, makeDefault);
7472 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
7473 detail::errHandler(default_error_, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7474 #else // CL_HPP_TARGET_OPENCL_VERSION >= 200
7475 detail::errHandler(default_error_, __CREATE_COMMAND_QUEUE_ERR);
7476 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200
7478 *err = default_error_;
7492 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_queue));
7493 detail::errHandler(default_error_);
7506 explicit CommandQueue(
const cl_command_queue& commandQueue,
bool retainObject =
false) :
7507 detail::Wrapper<cl_type>(commandQueue, retainObject) { }
7543 template <
typename T>
7544 cl_int getInfo(cl_command_queue_info name, T* param)
const
7546 return detail::errHandler(
7548 &::clGetCommandQueueInfo, object_, name, param),
7549 __GET_COMMAND_QUEUE_INFO_ERR);
7552 template <cl_command_queue_info name>
typename
7553 detail::param_traits<detail::cl_command_queue_info, name>::param_type
7554 getInfo(cl_int* err = NULL)
const
7556 typename detail::param_traits<
7557 detail::cl_command_queue_info, name>::param_type param;
7558 cl_int result = getInfo(name, ¶m);
7565 cl_int enqueueReadBuffer(
7566 const Buffer& buffer,
7571 const vector<Event>* events = NULL,
7572 Event* event = NULL)
const
7575 cl_int err = detail::errHandler(
7576 ::clEnqueueReadBuffer(
7577 object_, buffer(), blocking, offset, size,
7579 (events != NULL) ? (cl_uint) events->size() : 0,
7580 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7581 (event != NULL) ? &tmp : NULL),
7582 __ENQUEUE_READ_BUFFER_ERR);
7584 if (event != NULL && err == CL_SUCCESS)
7590 cl_int enqueueWriteBuffer(
7591 const Buffer& buffer,
7596 const vector<Event>* events = NULL,
7597 Event* event = NULL)
const
7600 cl_int err = detail::errHandler(
7601 ::clEnqueueWriteBuffer(
7602 object_, buffer(), blocking, offset, size,
7604 (events != NULL) ? (cl_uint) events->size() : 0,
7605 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7606 (event != NULL) ? &tmp : NULL),
7607 __ENQUEUE_WRITE_BUFFER_ERR);
7609 if (event != NULL && err == CL_SUCCESS)
7615 cl_int enqueueCopyBuffer(
7618 size_type src_offset,
7619 size_type dst_offset,
7621 const vector<Event>* events = NULL,
7622 Event* event = NULL)
const
7625 cl_int err = detail::errHandler(
7626 ::clEnqueueCopyBuffer(
7627 object_, src(), dst(), src_offset, dst_offset, size,
7628 (events != NULL) ? (cl_uint) events->size() : 0,
7629 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7630 (event != NULL) ? &tmp : NULL),
7631 __ENQEUE_COPY_BUFFER_ERR);
7633 if (event != NULL && err == CL_SUCCESS)
7638 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
7639 cl_int enqueueReadBufferRect(
7640 const Buffer& buffer,
7642 const array<size_type, 3>& buffer_offset,
7643 const array<size_type, 3>& host_offset,
7644 const array<size_type, 3>& region,
7645 size_type buffer_row_pitch,
7646 size_type buffer_slice_pitch,
7647 size_type host_row_pitch,
7648 size_type host_slice_pitch,
7650 const vector<Event>* events = NULL,
7651 Event* event = NULL)
const
7654 cl_int err = detail::errHandler(
7655 ::clEnqueueReadBufferRect(
7659 buffer_offset.data(),
7667 (events != NULL) ? (cl_uint) events->size() : 0,
7668 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7669 (event != NULL) ? &tmp : NULL),
7670 __ENQUEUE_READ_BUFFER_RECT_ERR);
7672 if (event != NULL && err == CL_SUCCESS)
7678 cl_int enqueueWriteBufferRect(
7679 const Buffer& buffer,
7681 const array<size_type, 3>& buffer_offset,
7682 const array<size_type, 3>& host_offset,
7683 const array<size_type, 3>& region,
7684 size_type buffer_row_pitch,
7685 size_type buffer_slice_pitch,
7686 size_type host_row_pitch,
7687 size_type host_slice_pitch,
7689 const vector<Event>* events = NULL,
7690 Event* event = NULL)
const
7693 cl_int err = detail::errHandler(
7694 ::clEnqueueWriteBufferRect(
7698 buffer_offset.data(),
7706 (events != NULL) ? (cl_uint) events->size() : 0,
7707 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7708 (event != NULL) ? &tmp : NULL),
7709 __ENQUEUE_WRITE_BUFFER_RECT_ERR);
7711 if (event != NULL && err == CL_SUCCESS)
7717 cl_int enqueueCopyBufferRect(
7720 const array<size_type, 3>& src_origin,
7721 const array<size_type, 3>& dst_origin,
7722 const array<size_type, 3>& region,
7723 size_type src_row_pitch,
7724 size_type src_slice_pitch,
7725 size_type dst_row_pitch,
7726 size_type dst_slice_pitch,
7727 const vector<Event>* events = NULL,
7728 Event* event = NULL)
const
7731 cl_int err = detail::errHandler(
7732 ::clEnqueueCopyBufferRect(
7743 (events != NULL) ? (cl_uint) events->size() : 0,
7744 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7745 (event != NULL) ? &tmp : NULL),
7746 __ENQEUE_COPY_BUFFER_RECT_ERR);
7748 if (event != NULL && err == CL_SUCCESS)
7753 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110
7754 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
7766 template<
typename PatternType>
7769 PatternType pattern,
7772 const vector<Event>* events = NULL,
7773 Event* event = NULL)
const
7776 cl_int err = detail::errHandler(
7777 ::clEnqueueFillBuffer(
7780 static_cast<void*
>(&pattern),
7781 sizeof(PatternType),
7784 (events != NULL) ? (cl_uint) events->size() : 0,
7785 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7786 (event != NULL) ? &tmp : NULL),
7787 __ENQUEUE_FILL_BUFFER_ERR);
7789 if (event != NULL && err == CL_SUCCESS)
7794 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
7796 cl_int enqueueReadImage(
7799 const array<size_type, 3>& origin,
7800 const array<size_type, 3>& region,
7801 size_type row_pitch,
7802 size_type slice_pitch,
7804 const vector<Event>* events = NULL,
7805 Event* event = NULL)
const
7808 cl_int err = detail::errHandler(
7809 ::clEnqueueReadImage(
7818 (events != NULL) ? (cl_uint) events->size() : 0,
7819 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7820 (event != NULL) ? &tmp : NULL),
7821 __ENQUEUE_READ_IMAGE_ERR);
7823 if (event != NULL && err == CL_SUCCESS)
7829 cl_int enqueueWriteImage(
7832 const array<size_type, 3>& origin,
7833 const array<size_type, 3>& region,
7834 size_type row_pitch,
7835 size_type slice_pitch,
7837 const vector<Event>* events = NULL,
7838 Event* event = NULL)
const
7841 cl_int err = detail::errHandler(
7842 ::clEnqueueWriteImage(
7851 (events != NULL) ? (cl_uint) events->size() : 0,
7852 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7853 (event != NULL) ? &tmp : NULL),
7854 __ENQUEUE_WRITE_IMAGE_ERR);
7856 if (event != NULL && err == CL_SUCCESS)
7862 cl_int enqueueCopyImage(
7865 const array<size_type, 3>& src_origin,
7866 const array<size_type, 3>& dst_origin,
7867 const array<size_type, 3>& region,
7868 const vector<Event>* events = NULL,
7869 Event* event = NULL)
const
7872 cl_int err = detail::errHandler(
7873 ::clEnqueueCopyImage(
7880 (events != NULL) ? (cl_uint) events->size() : 0,
7881 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7882 (event != NULL) ? &tmp : NULL),
7883 __ENQUEUE_COPY_IMAGE_ERR);
7885 if (event != NULL && err == CL_SUCCESS)
7891 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
7901 cl_float4 fillColor,
7902 const array<size_type, 3>& origin,
7903 const array<size_type, 3>& region,
7904 const vector<Event>* events = NULL,
7905 Event* event = NULL)
const
7908 cl_int err = detail::errHandler(
7909 ::clEnqueueFillImage(
7912 static_cast<void*
>(&fillColor),
7915 (events != NULL) ? (cl_uint) events->size() : 0,
7916 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7917 (event != NULL) ? &tmp : NULL),
7918 __ENQUEUE_FILL_IMAGE_ERR);
7920 if (event != NULL && err == CL_SUCCESS)
7936 const array<size_type, 3>& origin,
7937 const array<size_type, 3>& region,
7938 const vector<Event>* events = NULL,
7939 Event* event = NULL)
const
7942 cl_int err = detail::errHandler(
7943 ::clEnqueueFillImage(
7946 static_cast<void*
>(&fillColor),
7949 (events != NULL) ? (cl_uint) events->size() : 0,
7950 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7951 (event != NULL) ? &tmp : NULL),
7952 __ENQUEUE_FILL_IMAGE_ERR);
7954 if (event != NULL && err == CL_SUCCESS)
7970 const array<size_type, 3>& origin,
7971 const array<size_type, 3>& region,
7972 const vector<Event>* events = NULL,
7973 Event* event = NULL)
const
7976 cl_int err = detail::errHandler(
7977 ::clEnqueueFillImage(
7980 static_cast<void*
>(&fillColor),
7983 (events != NULL) ? (cl_uint) events->size() : 0,
7984 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7985 (event != NULL) ? &tmp : NULL),
7986 __ENQUEUE_FILL_IMAGE_ERR);
7988 if (event != NULL && err == CL_SUCCESS)
7993 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
7995 cl_int enqueueCopyImageToBuffer(
7998 const array<size_type, 3>& src_origin,
7999 const array<size_type, 3>& region,
8000 size_type dst_offset,
8001 const vector<Event>* events = NULL,
8002 Event* event = NULL)
const
8005 cl_int err = detail::errHandler(
8006 ::clEnqueueCopyImageToBuffer(
8013 (events != NULL) ? (cl_uint) events->size() : 0,
8014 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8015 (event != NULL) ? &tmp : NULL),
8016 __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR);
8018 if (event != NULL && err == CL_SUCCESS)
8024 cl_int enqueueCopyBufferToImage(
8027 size_type src_offset,
8028 const array<size_type, 3>& dst_origin,
8029 const array<size_type, 3>& region,
8030 const vector<Event>* events = NULL,
8031 Event* event = NULL)
const
8034 cl_int err = detail::errHandler(
8035 ::clEnqueueCopyBufferToImage(
8042 (events != NULL) ? (cl_uint) events->size() : 0,
8043 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8044 (event != NULL) ? &tmp : NULL),
8045 __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR);
8047 if (event != NULL && err == CL_SUCCESS)
8053 void* enqueueMapBuffer(
8054 const Buffer& buffer,
8059 const vector<Event>* events = NULL,
8060 Event* event = NULL,
8061 cl_int* err = NULL)
const
8065 void * result = ::clEnqueueMapBuffer(
8066 object_, buffer(), blocking, flags, offset, size,
8067 (events != NULL) ? (cl_uint) events->size() : 0,
8068 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8069 (event != NULL) ? &tmp : NULL,
8072 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
8076 if (event != NULL && error == CL_SUCCESS)
8082 void* enqueueMapImage(
8083 const Image& buffer,
8086 const array<size_type, 3>& origin,
8087 const array<size_type, 3>& region,
8088 size_type * row_pitch,
8089 size_type * slice_pitch,
8090 const vector<Event>* events = NULL,
8091 Event* event = NULL,
8092 cl_int* err = NULL)
const
8096 void * result = ::clEnqueueMapImage(
8097 object_, buffer(), blocking, flags,
8100 row_pitch, slice_pitch,
8101 (events != NULL) ? (cl_uint) events->size() : 0,
8102 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8103 (event != NULL) ? &tmp : NULL,
8106 detail::errHandler(error, __ENQUEUE_MAP_IMAGE_ERR);
8110 if (event != NULL && error == CL_SUCCESS)
8115 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
8120 template<
typename T>
8126 const vector<Event>* events = NULL,
8127 Event* event = NULL)
const
8130 cl_int err = detail::errHandler(::clEnqueueSVMMap(
8131 object_, blocking, flags,
static_cast<void*
>(ptr), size,
8132 (events != NULL) ? (cl_uint)events->size() : 0,
8133 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8134 (event != NULL) ? &tmp : NULL),
8135 __ENQUEUE_MAP_BUFFER_ERR);
8137 if (event != NULL && err == CL_SUCCESS)
8148 template<
typename T,
class D>
8150 cl::pointer<T, D> &ptr,
8154 const vector<Event>* events = NULL,
8155 Event* event = NULL)
const
8158 cl_int err = detail::errHandler(::clEnqueueSVMMap(
8159 object_, blocking, flags,
static_cast<void*
>(ptr.get()), size,
8160 (events != NULL) ? (cl_uint)events->size() : 0,
8161 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8162 (event != NULL) ? &tmp : NULL),
8163 __ENQUEUE_MAP_BUFFER_ERR);
8165 if (event != NULL && err == CL_SUCCESS)
8175 template<
typename T,
class Alloc>
8177 cl::vector<T, Alloc> &container,
8180 const vector<Event>* events = NULL,
8181 Event* event = NULL)
const
8184 cl_int err = detail::errHandler(::clEnqueueSVMMap(
8185 object_, blocking, flags,
static_cast<void*
>(container.data()), container.size()*
sizeof(T),
8186 (events != NULL) ? (cl_uint)events->size() : 0,
8187 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8188 (event != NULL) ? &tmp : NULL),
8189 __ENQUEUE_MAP_BUFFER_ERR);
8191 if (event != NULL && err == CL_SUCCESS)
8196 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200
8198 cl_int enqueueUnmapMemObject(
8201 const vector<Event>* events = NULL,
8202 Event* event = NULL)
const
8205 cl_int err = detail::errHandler(
8206 ::clEnqueueUnmapMemObject(
8207 object_, memory(), mapped_ptr,
8208 (events != NULL) ? (cl_uint) events->size() : 0,
8209 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8210 (event != NULL) ? &tmp : NULL),
8211 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8213 if (event != NULL && err == CL_SUCCESS)
8220 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
8225 template<
typename T>
8228 const vector<Event>* events = NULL,
8229 Event* event = NULL)
const
8232 cl_int err = detail::errHandler(
8233 ::clEnqueueSVMUnmap(
8234 object_,
static_cast<void*
>(ptr),
8235 (events != NULL) ? (cl_uint)events->size() : 0,
8236 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8237 (event != NULL) ? &tmp : NULL),
8238 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8240 if (event != NULL && err == CL_SUCCESS)
8250 template<
typename T,
class D>
8252 cl::pointer<T, D> &ptr,
8253 const vector<Event>* events = NULL,
8254 Event* event = NULL)
const
8257 cl_int err = detail::errHandler(
8258 ::clEnqueueSVMUnmap(
8259 object_,
static_cast<void*
>(ptr.get()),
8260 (events != NULL) ? (cl_uint)events->size() : 0,
8261 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8262 (event != NULL) ? &tmp : NULL),
8263 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8265 if (event != NULL && err == CL_SUCCESS)
8275 template<
typename T,
class Alloc>
8277 cl::vector<T, Alloc> &container,
8278 const vector<Event>* events = NULL,
8279 Event* event = NULL)
const
8282 cl_int err = detail::errHandler(
8283 ::clEnqueueSVMUnmap(
8284 object_,
static_cast<void*
>(container.data()),
8285 (events != NULL) ? (cl_uint)events->size() : 0,
8286 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8287 (event != NULL) ? &tmp : NULL),
8288 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8290 if (event != NULL && err == CL_SUCCESS)
8295 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200
8297 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
8310 const vector<Event> *events = 0,
8311 Event *event = 0)
const
8314 cl_int err = detail::errHandler(
8315 ::clEnqueueMarkerWithWaitList(
8317 (events != NULL) ? (cl_uint) events->size() : 0,
8318 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8319 (event != NULL) ? &tmp : NULL),
8320 __ENQUEUE_MARKER_WAIT_LIST_ERR);
8322 if (event != NULL && err == CL_SUCCESS)
8340 const vector<Event> *events = 0,
8341 Event *event = 0)
const
8344 cl_int err = detail::errHandler(
8345 ::clEnqueueBarrierWithWaitList(
8347 (events != NULL) ? (cl_uint) events->size() : 0,
8348 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8349 (event != NULL) ? &tmp : NULL),
8350 __ENQUEUE_BARRIER_WAIT_LIST_ERR);
8352 if (event != NULL && err == CL_SUCCESS)
8363 const vector<Memory> &memObjects,
8364 cl_mem_migration_flags flags,
8365 const vector<Event>* events = NULL,
8371 vector<cl_mem> localMemObjects(memObjects.size());
8373 for(
int i = 0; i < (int)memObjects.size(); ++i ) {
8374 localMemObjects[i] = memObjects[i]();
8377 cl_int err = detail::errHandler(
8378 ::clEnqueueMigrateMemObjects(
8380 (cl_uint)memObjects.size(),
8381 localMemObjects.data(),
8383 (events != NULL) ? (cl_uint) events->size() : 0,
8384 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8385 (event != NULL) ? &tmp : NULL),
8386 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8388 if (event != NULL && err == CL_SUCCESS)
8393 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
8396 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
8402 template<
typename T>
8404 const cl::vector<T*> &svmRawPointers,
8405 const cl::vector<size_type> &sizes,
8406 cl_mem_migration_flags flags = 0,
8407 const vector<Event>* events = NULL,
8408 Event* event = NULL)
const
8411 cl_int err = detail::errHandler(::clEnqueueSVMMigrateMem(
8413 svmRawPointers.size(),
static_cast<void**
>(svmRawPointers.data()),
8416 (events != NULL) ? (cl_uint)events->size() : 0,
8417 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8418 (event != NULL) ? &tmp : NULL),
8419 __ENQUEUE_MIGRATE_SVM_ERR);
8421 if (event != NULL && err == CL_SUCCESS)
8431 template<
typename T>
8433 const cl::vector<T*> &svmRawPointers,
8434 cl_mem_migration_flags flags = 0,
8435 const vector<Event>* events = NULL,
8436 Event* event = NULL)
const
8438 return enqueueMigrateSVM(svmRawPointers, cl::vector<size_type>(svmRawPointers.size()), flags, events, event);
8447 template<
typename T,
class D>
8449 const cl::vector<cl::pointer<T, D>> &svmPointers,
8450 const cl::vector<size_type> &sizes,
8451 cl_mem_migration_flags flags = 0,
8452 const vector<Event>* events = NULL,
8453 Event* event = NULL)
const
8455 cl::vector<void*> svmRawPointers;
8456 svmRawPointers.reserve(svmPointers.size());
8457 for (
auto p : svmPointers) {
8458 svmRawPointers.push_back(
static_cast<void*
>(p.get()));
8469 template<
typename T,
class D>
8471 const cl::vector<cl::pointer<T, D>> &svmPointers,
8472 cl_mem_migration_flags flags = 0,
8473 const vector<Event>* events = NULL,
8474 Event* event = NULL)
const
8476 return enqueueMigrateSVM(svmPointers, cl::vector<size_type>(svmPointers.size()), flags, events, event);
8484 template<
typename T,
class Alloc>
8486 const cl::vector<cl::vector<T, Alloc>> &svmContainers,
8487 const cl::vector<size_type> &sizes,
8488 cl_mem_migration_flags flags = 0,
8489 const vector<Event>* events = NULL,
8490 Event* event = NULL)
const
8492 cl::vector<void*> svmRawPointers;
8493 svmRawPointers.reserve(svmContainers.size());
8494 for (
auto p : svmContainers) {
8495 svmRawPointers.push_back(
static_cast<void*
>(p.data()));
8505 template<
typename T,
class Alloc>
8507 const cl::vector<cl::vector<T, Alloc>> &svmContainers,
8508 cl_mem_migration_flags flags = 0,
8509 const vector<Event>* events = NULL,
8510 Event* event = NULL)
const
8512 return enqueueMigrateSVM(svmContainers, cl::vector<size_type>(svmContainers.size()), flags, events, event);
8515 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 210
8517 cl_int enqueueNDRangeKernel(
8521 const NDRange& local = NullRange,
8522 const vector<Event>* events = NULL,
8523 Event* event = NULL)
const
8526 cl_int err = detail::errHandler(
8527 ::clEnqueueNDRangeKernel(
8528 object_, kernel(), (cl_uint) global.
dimensions(),
8529 offset.
dimensions() != 0 ? (
const size_type*) offset : NULL,
8530 (
const size_type*) global,
8531 local.dimensions() != 0 ? (
const size_type*) local : NULL,
8532 (events != NULL) ? (cl_uint) events->size() : 0,
8533 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8534 (event != NULL) ? &tmp : NULL),
8535 __ENQUEUE_NDRANGE_KERNEL_ERR);
8537 if (event != NULL && err == CL_SUCCESS)
8543 #if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
8544 CL_EXT_PREFIX__VERSION_1_2_DEPRECATED cl_int enqueueTask(
8545 const Kernel& kernel,
8546 const vector<Event>* events = NULL,
8547 Event* event = NULL)
const CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED
8550 cl_int err = detail::errHandler(
8553 (events != NULL) ? (cl_uint) events->size() : 0,
8554 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8555 (event != NULL) ? &tmp : NULL),
8556 __ENQUEUE_TASK_ERR);
8558 if (event != NULL && err == CL_SUCCESS)
8563 #endif // #if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
8565 cl_int enqueueNativeKernel(
8566 void (CL_CALLBACK *userFptr)(
void *),
8567 std::pair<void*, size_type> args,
8568 const vector<Memory>* mem_objects = NULL,
8569 const vector<const void*>* mem_locs = NULL,
8570 const vector<Event>* events = NULL,
8571 Event* event = NULL)
const
8573 size_type elements = 0;
8574 if (mem_objects != NULL) {
8575 elements = mem_objects->size();
8577 vector<cl_mem> mems(elements);
8578 for (
unsigned int i = 0; i < elements; i++) {
8579 mems[i] = ((*mem_objects)[i])();
8583 cl_int err = detail::errHandler(
8584 ::clEnqueueNativeKernel(
8585 object_, userFptr, args.first, args.second,
8586 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8588 (mem_locs != NULL && mem_locs->size() > 0) ? (
const void **) &mem_locs->front() : NULL,
8589 (events != NULL) ? (cl_uint) events->size() : 0,
8590 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8591 (event != NULL) ? &tmp : NULL),
8592 __ENQUEUE_NATIVE_KERNEL);
8594 if (event != NULL && err == CL_SUCCESS)
8603 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
8604 CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
8608 cl_int err = detail::errHandler(
8611 (event != NULL) ? &tmp : NULL),
8612 __ENQUEUE_MARKER_ERR);
8614 if (event != NULL && err == CL_SUCCESS)
8620 CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
8621 cl_int enqueueWaitForEvents(
const vector<Event>& events)
const CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
8623 return detail::errHandler(
8624 ::clEnqueueWaitForEvents(
8626 (cl_uint) events.size(),
8627 events.size() > 0 ? (
const cl_event*) &events.front() : NULL),
8628 __ENQUEUE_WAIT_FOR_EVENTS_ERR);
8630 #endif // defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
8632 cl_int enqueueAcquireGLObjects(
8633 const vector<Memory>* mem_objects = NULL,
8634 const vector<Event>* events = NULL,
8635 Event* event = NULL)
const
8638 cl_int err = detail::errHandler(
8639 ::clEnqueueAcquireGLObjects(
8641 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8642 (mem_objects != NULL && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front(): NULL,
8643 (events != NULL) ? (cl_uint) events->size() : 0,
8644 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8645 (event != NULL) ? &tmp : NULL),
8646 __ENQUEUE_ACQUIRE_GL_ERR);
8648 if (event != NULL && err == CL_SUCCESS)
8654 cl_int enqueueReleaseGLObjects(
8655 const vector<Memory>* mem_objects = NULL,
8656 const vector<Event>* events = NULL,
8657 Event* event = NULL)
const
8660 cl_int err = detail::errHandler(
8661 ::clEnqueueReleaseGLObjects(
8663 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8664 (mem_objects != NULL && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front(): NULL,
8665 (events != NULL) ? (cl_uint) events->size() : 0,
8666 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8667 (event != NULL) ? &tmp : NULL),
8668 __ENQUEUE_RELEASE_GL_ERR);
8670 if (event != NULL && err == CL_SUCCESS)
8676 #if defined (CL_HPP_USE_DX_INTEROP)
8677 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueAcquireD3D10ObjectsKHR)(
8678 cl_command_queue command_queue, cl_uint num_objects,
8679 const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
8680 const cl_event* event_wait_list, cl_event* event);
8681 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueReleaseD3D10ObjectsKHR)(
8682 cl_command_queue command_queue, cl_uint num_objects,
8683 const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
8684 const cl_event* event_wait_list, cl_event* event);
8686 cl_int enqueueAcquireD3D10Objects(
8687 const vector<Memory>* mem_objects = NULL,
8688 const vector<Event>* events = NULL,
8689 Event* event = NULL)
const
8691 static PFN_clEnqueueAcquireD3D10ObjectsKHR pfn_clEnqueueAcquireD3D10ObjectsKHR = NULL;
8692 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
8693 cl_context context = getInfo<CL_QUEUE_CONTEXT>();
8694 cl::Device device(getInfo<CL_QUEUE_DEVICE>());
8695 cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>();
8696 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueAcquireD3D10ObjectsKHR);
8698 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
8699 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueAcquireD3D10ObjectsKHR);
8703 cl_int err = detail::errHandler(
8704 pfn_clEnqueueAcquireD3D10ObjectsKHR(
8706 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8707 (mem_objects != NULL && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front(): NULL,
8708 (events != NULL) ? (cl_uint) events->size() : 0,
8709 (events != NULL) ? (cl_event*) &events->front() : NULL,
8710 (event != NULL) ? &tmp : NULL),
8711 __ENQUEUE_ACQUIRE_GL_ERR);
8713 if (event != NULL && err == CL_SUCCESS)
8719 cl_int enqueueReleaseD3D10Objects(
8720 const vector<Memory>* mem_objects = NULL,
8721 const vector<Event>* events = NULL,
8722 Event* event = NULL)
const
8724 static PFN_clEnqueueReleaseD3D10ObjectsKHR pfn_clEnqueueReleaseD3D10ObjectsKHR = NULL;
8725 #if CL_HPP_TARGET_OPENCL_VERSION >= 120
8726 cl_context context = getInfo<CL_QUEUE_CONTEXT>();
8727 cl::Device device(getInfo<CL_QUEUE_DEVICE>());
8728 cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>();
8729 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueReleaseD3D10ObjectsKHR);
8730 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
8731 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
8732 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueReleaseD3D10ObjectsKHR);
8733 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110
8736 cl_int err = detail::errHandler(
8737 pfn_clEnqueueReleaseD3D10ObjectsKHR(
8739 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8740 (mem_objects != NULL && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front(): NULL,
8741 (events != NULL) ? (cl_uint) events->size() : 0,
8742 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8743 (event != NULL) ? &tmp : NULL),
8744 __ENQUEUE_RELEASE_GL_ERR);
8746 if (event != NULL && err == CL_SUCCESS)
8756 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
8757 CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
8760 return detail::errHandler(
8761 ::clEnqueueBarrier(object_),
8762 __ENQUEUE_BARRIER_ERR);
8764 #endif // CL_USE_DEPRECATED_OPENCL_1_1_APIS
8766 cl_int flush()
const
8768 return detail::errHandler(::clFlush(object_), __FLUSH_ERR);
8771 cl_int finish()
const
8773 return detail::errHandler(::clFinish(object_), __FINISH_ERR);
8777 CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag CommandQueue::default_initialized_;
8778 CL_HPP_DEFINE_STATIC_MEMBER_ CommandQueue CommandQueue::default_;
8779 CL_HPP_DEFINE_STATIC_MEMBER_ cl_int CommandQueue::default_error_ = CL_SUCCESS;
8782 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
8783 enum class DeviceQueueProperties : cl_command_queue_properties
8786 Profiling = CL_QUEUE_PROFILING_ENABLE,
8789 inline DeviceQueueProperties operator|(DeviceQueueProperties lhs, DeviceQueueProperties rhs)
8791 return static_cast<DeviceQueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) |
static_cast<cl_command_queue_properties
>(rhs));
8815 cl_command_queue_properties mergedProperties =
8816 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
8818 cl_queue_properties queue_properties[] = {
8819 CL_QUEUE_PROPERTIES, mergedProperties, 0 };
8820 object_ = ::clCreateCommandQueueWithProperties(
8821 context(), device(), queue_properties, &error);
8823 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8835 DeviceQueueProperties properties = DeviceQueueProperties::None,
8840 cl_command_queue_properties mergedProperties =
8841 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
8842 cl_queue_properties queue_properties[] = {
8843 CL_QUEUE_PROPERTIES, mergedProperties, 0 };
8844 object_ = ::clCreateCommandQueueWithProperties(
8845 context(), device(), queue_properties, &error);
8847 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8860 DeviceQueueProperties properties = DeviceQueueProperties::None,
8865 cl_command_queue_properties mergedProperties =
8866 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
8867 cl_queue_properties queue_properties[] = {
8868 CL_QUEUE_PROPERTIES, mergedProperties,
8869 CL_QUEUE_SIZE, queueSize,
8871 object_ = ::clCreateCommandQueueWithProperties(
8872 context(), device(), queue_properties, &error);
8874 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8887 detail::Wrapper<cl_type>(commandQueue, retainObject) { }
8923 template <
typename T>
8924 cl_int getInfo(cl_command_queue_info name, T* param)
const
8926 return detail::errHandler(
8928 &::clGetCommandQueueInfo, object_, name, param),
8929 __GET_COMMAND_QUEUE_INFO_ERR);
8932 template <cl_command_queue_info name>
typename
8933 detail::param_traits<detail::cl_command_queue_info, name>::param_type
8934 getInfo(cl_int* err = NULL)
const
8936 typename detail::param_traits<
8937 detail::cl_command_queue_info, name>::param_type param;
8938 cl_int result = getInfo(name, ¶m);
8952 cl_int *err =
nullptr)
8958 cl_command_queue_properties properties =
8959 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
8960 cl_queue_properties queue_properties[] = {
8961 CL_QUEUE_PROPERTIES, properties,
8964 ::clCreateCommandQueueWithProperties(
8965 context(), device(), queue_properties, &error));
8967 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8982 const Context &context,
const Device &device, cl_int *err =
nullptr)
8986 cl_command_queue_properties properties =
8987 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
8988 cl_queue_properties queue_properties[] = {
8989 CL_QUEUE_PROPERTIES, properties,
8992 ::clCreateCommandQueueWithProperties(
8993 context(), device(), queue_properties, &error));
8995 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9010 const Context &context,
const Device &device, cl_uint queueSize, cl_int *err =
nullptr)
9014 cl_command_queue_properties properties =
9015 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
9016 cl_queue_properties queue_properties[] = {
9017 CL_QUEUE_PROPERTIES, properties,
9018 CL_QUEUE_SIZE, queueSize,
9021 ::clCreateCommandQueueWithProperties(
9022 context(), device(), queue_properties, &error));
9024 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
9034 #if CL_HPP_TARGET_OPENCL_VERSION >= 210
9044 error = clSetDefaultDeviceCommandQueue(context.get(), device.get(), default_queue.get());
9046 detail::errHandler(error, __SET_DEFAULT_DEVICE_COMMAND_QUEUE_ERR);
9050 return default_queue;
9058 return queue.getInfo<CL_QUEUE_DEVICE_DEFAULT>(err);
9061 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 210
9075 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200
9078 template<
typename IteratorType >
9081 IteratorType startIterator,
9082 IteratorType endIterator,
9087 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9090 cl_mem_flags flags = 0;
9092 flags |= CL_MEM_READ_ONLY;
9095 flags |= CL_MEM_READ_WRITE;
9098 flags |= CL_MEM_USE_HOST_PTR;
9101 size_type size =
sizeof(DataType)*(endIterator - startIterator);
9104 object_ = ::clCreateBuffer(context(), flags, size,
static_cast<DataType*
>(&*startIterator), &error);
9106 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
9109 detail::errHandler(error, __CREATE_BUFFER_ERR);
9116 detail::errHandler(error, __CREATE_BUFFER_ERR);
9121 error =
cl::copy(queue, startIterator, endIterator, *
this);
9122 detail::errHandler(error, __CREATE_BUFFER_ERR);
9129 template<
typename IteratorType >
9132 IteratorType startIterator,
9133 IteratorType endIterator,
9138 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9141 cl_mem_flags flags = 0;
9143 flags |= CL_MEM_READ_ONLY;
9146 flags |= CL_MEM_READ_WRITE;
9149 flags |= CL_MEM_USE_HOST_PTR;
9152 size_type size =
sizeof(DataType)*(endIterator - startIterator);
9154 Context context = queue.getInfo<CL_QUEUE_CONTEXT>();
9157 object_ = ::clCreateBuffer(context(), flags, size,
static_cast<DataType*
>(&*startIterator), &error);
9160 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
9163 detail::errHandler(error, __CREATE_BUFFER_ERR);
9169 error =
cl::copy(queue, startIterator, endIterator, *
this);
9170 detail::errHandler(error, __CREATE_BUFFER_ERR);
9177 inline cl_int enqueueReadBuffer(
9183 const vector<Event>* events = NULL,
9184 Event* event = NULL)
9189 if (error != CL_SUCCESS) {
9193 return queue.enqueueReadBuffer(buffer, blocking, offset, size, ptr, events, event);
9196 inline cl_int enqueueWriteBuffer(
9197 const Buffer& buffer,
9202 const vector<Event>* events = NULL,
9203 Event* event = NULL)
9206 CommandQueue queue = CommandQueue::getDefault(&error);
9208 if (error != CL_SUCCESS) {
9212 return queue.enqueueWriteBuffer(buffer, blocking, offset, size, ptr, events, event);
9215 inline void* enqueueMapBuffer(
9216 const Buffer& buffer,
9221 const vector<Event>* events = NULL,
9222 Event* event = NULL,
9226 CommandQueue queue = CommandQueue::getDefault(&error);
9227 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9232 void * result = ::clEnqueueMapBuffer(
9233 queue(), buffer(), blocking, flags, offset, size,
9234 (events != NULL) ? (cl_uint) events->size() : 0,
9235 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
9239 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9247 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
9253 template<
typename T>
9259 const vector<Event>* events,
9264 if (error != CL_SUCCESS) {
9265 return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9269 ptr, blocking, flags, size, events, event);
9277 template<
typename T,
class D>
9279 cl::pointer<T, D> ptr,
9283 const vector<Event>* events = NULL,
9284 Event* event = NULL)
9288 if (error != CL_SUCCESS) {
9289 return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9293 ptr, blocking, flags, size, events, event);
9301 template<
typename T,
class Alloc>
9303 cl::vector<T, Alloc> container,
9306 const vector<Event>* events = NULL,
9307 Event* event = NULL)
9311 if (error != CL_SUCCESS) {
9312 return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9316 container, blocking, flags, events, event);
9319 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200
9321 inline cl_int enqueueUnmapMemObject(
9322 const Memory& memory,
9324 const vector<Event>* events = NULL,
9325 Event* event = NULL)
9328 CommandQueue queue = CommandQueue::getDefault(&error);
9329 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
9330 if (error != CL_SUCCESS) {
9335 cl_int err = detail::errHandler(
9336 ::clEnqueueUnmapMemObject(
9337 queue(), memory(), mapped_ptr,
9338 (events != NULL) ? (cl_uint)events->size() : 0,
9339 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
9340 (event != NULL) ? &tmp : NULL),
9341 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9343 if (event != NULL && err == CL_SUCCESS)
9349 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
9355 template<
typename T>
9358 const vector<Event>* events = NULL,
9359 Event* event = NULL)
9363 if (error != CL_SUCCESS) {
9364 return detail::errHandler(error, __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9368 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9377 template<
typename T,
class D>
9379 cl::pointer<T, D> &ptr,
9380 const vector<Event>* events = NULL,
9381 Event* event = NULL)
9385 if (error != CL_SUCCESS) {
9386 return detail::errHandler(error, __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9390 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9398 template<
typename T,
class Alloc>
9400 cl::vector<T, Alloc> &container,
9401 const vector<Event>* events = NULL,
9402 Event* event = NULL)
9406 if (error != CL_SUCCESS) {
9407 return detail::errHandler(error, __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9410 return detail::errHandler(queue.
enqueueUnmapSVM(container, events, event),
9411 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
9414 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200
9416 inline cl_int enqueueCopyBuffer(
9419 size_type src_offset,
9420 size_type dst_offset,
9422 const vector<Event>* events = NULL,
9423 Event* event = NULL)
9426 CommandQueue queue = CommandQueue::getDefault(&error);
9428 if (error != CL_SUCCESS) {
9432 return queue.enqueueCopyBuffer(src, dst, src_offset, dst_offset, size, events, event);
9440 template<
typename IteratorType >
9441 inline cl_int
copy( IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer )
9445 if (error != CL_SUCCESS)
9448 return cl::copy(queue, startIterator, endIterator, buffer);
9456 template<
typename IteratorType >
9457 inline cl_int
copy(
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator )
9461 if (error != CL_SUCCESS)
9464 return cl::copy(queue, buffer, startIterator, endIterator);
9472 template<
typename IteratorType >
9475 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9478 size_type length = endIterator-startIterator;
9479 size_type byteLength = length*
sizeof(DataType);
9482 static_cast<DataType*
>(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_WRITE, 0, byteLength, 0, 0, &error));
9484 if( error != CL_SUCCESS ) {
9487 #if defined(_MSC_VER)
9491 stdext::checked_array_iterator<DataType*>(
9494 std::copy(startIterator, endIterator, pointer);
9497 error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
9499 if( error != CL_SUCCESS ) {
9511 template<
typename IteratorType >
9514 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9517 size_type length = endIterator-startIterator;
9518 size_type byteLength = length*
sizeof(DataType);
9521 static_cast<DataType*
>(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_READ, 0, byteLength, 0, 0, &error));
9523 if( error != CL_SUCCESS ) {
9526 std::copy(pointer, pointer + length, startIterator);
9528 error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
9530 if( error != CL_SUCCESS ) {
9538 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
9542 template<
typename T,
class Alloc>
9543 inline cl_int
mapSVM(cl::vector<T, Alloc> &container)
9545 return enqueueMapSVM(container, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE);
9551 template<
typename T,
class Alloc>
9552 inline cl_int
unmapSVM(cl::vector<T, Alloc> &container)
9557 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200
9559 #if CL_HPP_TARGET_OPENCL_VERSION >= 110
9560 inline cl_int enqueueReadBufferRect(
9561 const Buffer& buffer,
9563 const array<size_type, 3>& buffer_offset,
9564 const array<size_type, 3>& host_offset,
9565 const array<size_type, 3>& region,
9566 size_type buffer_row_pitch,
9567 size_type buffer_slice_pitch,
9568 size_type host_row_pitch,
9569 size_type host_slice_pitch,
9571 const vector<Event>* events = NULL,
9572 Event* event = NULL)
9575 CommandQueue queue = CommandQueue::getDefault(&error);
9577 if (error != CL_SUCCESS) {
9581 return queue.enqueueReadBufferRect(
9596 inline cl_int enqueueWriteBufferRect(
9597 const Buffer& buffer,
9599 const array<size_type, 3>& buffer_offset,
9600 const array<size_type, 3>& host_offset,
9601 const array<size_type, 3>& region,
9602 size_type buffer_row_pitch,
9603 size_type buffer_slice_pitch,
9604 size_type host_row_pitch,
9605 size_type host_slice_pitch,
9607 const vector<Event>* events = NULL,
9608 Event* event = NULL)
9611 CommandQueue queue = CommandQueue::getDefault(&error);
9613 if (error != CL_SUCCESS) {
9617 return queue.enqueueWriteBufferRect(
9632 inline cl_int enqueueCopyBufferRect(
9635 const array<size_type, 3>& src_origin,
9636 const array<size_type, 3>& dst_origin,
9637 const array<size_type, 3>& region,
9638 size_type src_row_pitch,
9639 size_type src_slice_pitch,
9640 size_type dst_row_pitch,
9641 size_type dst_slice_pitch,
9642 const vector<Event>* events = NULL,
9643 Event* event = NULL)
9646 CommandQueue queue = CommandQueue::getDefault(&error);
9648 if (error != CL_SUCCESS) {
9652 return queue.enqueueCopyBufferRect(
9665 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110
9667 inline cl_int enqueueReadImage(
9670 const array<size_type, 3>& origin,
9671 const array<size_type, 3>& region,
9672 size_type row_pitch,
9673 size_type slice_pitch,
9675 const vector<Event>* events = NULL,
9676 Event* event = NULL)
9679 CommandQueue queue = CommandQueue::getDefault(&error);
9681 if (error != CL_SUCCESS) {
9685 return queue.enqueueReadImage(
9697 inline cl_int enqueueWriteImage(
9700 const array<size_type, 3>& origin,
9701 const array<size_type, 3>& region,
9702 size_type row_pitch,
9703 size_type slice_pitch,
9705 const vector<Event>* events = NULL,
9706 Event* event = NULL)
9709 CommandQueue queue = CommandQueue::getDefault(&error);
9711 if (error != CL_SUCCESS) {
9715 return queue.enqueueWriteImage(
9727 inline cl_int enqueueCopyImage(
9730 const array<size_type, 3>& src_origin,
9731 const array<size_type, 3>& dst_origin,
9732 const array<size_type, 3>& region,
9733 const vector<Event>* events = NULL,
9734 Event* event = NULL)
9737 CommandQueue queue = CommandQueue::getDefault(&error);
9739 if (error != CL_SUCCESS) {
9743 return queue.enqueueCopyImage(
9753 inline cl_int enqueueCopyImageToBuffer(
9756 const array<size_type, 3>& src_origin,
9757 const array<size_type, 3>& region,
9758 size_type dst_offset,
9759 const vector<Event>* events = NULL,
9760 Event* event = NULL)
9763 CommandQueue queue = CommandQueue::getDefault(&error);
9765 if (error != CL_SUCCESS) {
9769 return queue.enqueueCopyImageToBuffer(
9779 inline cl_int enqueueCopyBufferToImage(
9782 size_type src_offset,
9783 const array<size_type, 3>& dst_origin,
9784 const array<size_type, 3>& region,
9785 const vector<Event>* events = NULL,
9786 Event* event = NULL)
9789 CommandQueue queue = CommandQueue::getDefault(&error);
9791 if (error != CL_SUCCESS) {
9795 return queue.enqueueCopyBufferToImage(
9806 inline cl_int flush(
void)
9809 CommandQueue queue = CommandQueue::getDefault(&error);
9811 if (error != CL_SUCCESS) {
9815 return queue.flush();
9818 inline cl_int finish(
void)
9821 CommandQueue queue = CommandQueue::getDefault(&error);
9823 if (error != CL_SUCCESS) {
9828 return queue.finish();
9838 vector<Event> events_;
9840 template<
typename... Ts>
9845 queue_(CommandQueue::getDefault()),
9854 queue_(CommandQueue::getDefault()),
9863 queue_(CommandQueue::getDefault()),
9872 queue_(CommandQueue::getDefault()),
9877 events_.push_back(e);
9881 queue_(CommandQueue::getDefault()),
9886 events_.push_back(e);
9890 queue_(CommandQueue::getDefault()),
9895 events_.push_back(e);
9899 queue_(CommandQueue::getDefault()),
9909 queue_(CommandQueue::getDefault()),
9919 queue_(CommandQueue::getDefault()),
9961 events_.push_back(e);
9970 events_.push_back(e);
9979 events_.push_back(e);
10021 template<
typename... Ts>
10027 template<
int index,
typename T0,
typename... T1s>
10028 void setArgs(T0&& t0, T1s&&... t1s)
10030 kernel_.
setArg(index, t0);
10031 setArgs<index + 1, T1s...>(std::forward<T1s>(t1s)...);
10034 template<
int index,
typename T0>
10035 void setArgs(T0&& t0)
10037 kernel_.
setArg(index, t0);
10040 template<
int index>
10053 cl_int * err = NULL) :
10054 kernel_(program, name.c_str(), err)
10070 setArgs<0>(std::forward<Ts>(ts)...);
10072 args.queue_.enqueueNDRangeKernel(
10095 setArgs<0>(std::forward<Ts>(ts)...);
10097 error = args.queue_.enqueueNDRangeKernel(
10108 #if CL_HPP_TARGET_OPENCL_VERSION >= 200
10109 cl_int setSVMPointers(
const vector<void*> &pointerList)
10114 template<
typename T0,
typename... T1s>
10115 cl_int setSVMPointers(
const T0 &t0, T1s &... ts)
10119 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200
10127 namespace compatibility {
10132 template<
typename... Ts>
10142 cl_int * err = NULL) :
10164 enqueueArgs, args...);
10172 #undef CL_HPP_ERR_STR_
10173 #if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS)
10174 #undef __GET_DEVICE_INFO_ERR
10175 #undef __GET_PLATFORM_INFO_ERR
10176 #undef __GET_DEVICE_IDS_ERR
10177 #undef __GET_PLATFORM_IDS_ERR
10178 #undef __GET_CONTEXT_INFO_ERR
10179 #undef __GET_EVENT_INFO_ERR
10180 #undef __GET_EVENT_PROFILE_INFO_ERR
10181 #undef __GET_MEM_OBJECT_INFO_ERR
10182 #undef __GET_IMAGE_INFO_ERR
10183 #undef __GET_SAMPLER_INFO_ERR
10184 #undef __GET_KERNEL_INFO_ERR
10185 #undef __GET_KERNEL_ARG_INFO_ERR
10186 #undef __GET_KERNEL_SUB_GROUP_INFO_ERR
10187 #undef __GET_KERNEL_WORK_GROUP_INFO_ERR
10188 #undef __GET_PROGRAM_INFO_ERR
10189 #undef __GET_PROGRAM_BUILD_INFO_ERR
10190 #undef __GET_COMMAND_QUEUE_INFO_ERR
10191 #undef __CREATE_CONTEXT_ERR
10192 #undef __CREATE_CONTEXT_FROM_TYPE_ERR
10193 #undef __GET_SUPPORTED_IMAGE_FORMATS_ERR
10194 #undef __CREATE_BUFFER_ERR
10196 #undef __CREATE_SUBBUFFER_ERR
10197 #undef __CREATE_GL_BUFFER_ERR
10198 #undef __CREATE_GL_RENDER_BUFFER_ERR
10199 #undef __GET_GL_OBJECT_INFO_ERR
10200 #undef __CREATE_IMAGE_ERR
10201 #undef __CREATE_GL_TEXTURE_ERR
10202 #undef __IMAGE_DIMENSION_ERR
10203 #undef __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR
10204 #undef __CREATE_USER_EVENT_ERR
10205 #undef __SET_USER_EVENT_STATUS_ERR
10206 #undef __SET_EVENT_CALLBACK_ERR
10207 #undef __WAIT_FOR_EVENTS_ERR
10208 #undef __CREATE_KERNEL_ERR
10209 #undef __SET_KERNEL_ARGS_ERR
10210 #undef __CREATE_PROGRAM_WITH_SOURCE_ERR
10211 #undef __CREATE_PROGRAM_WITH_IL_ERR
10212 #undef __CREATE_PROGRAM_WITH_BINARY_ERR
10213 #undef __CREATE_PROGRAM_WITH_IL_ERR
10214 #undef __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR
10215 #undef __BUILD_PROGRAM_ERR
10216 #undef __COMPILE_PROGRAM_ERR
10217 #undef __LINK_PROGRAM_ERR
10218 #undef __CREATE_KERNELS_IN_PROGRAM_ERR
10219 #undef __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR
10220 #undef __CREATE_SAMPLER_WITH_PROPERTIES_ERR
10221 #undef __SET_COMMAND_QUEUE_PROPERTY_ERR
10222 #undef __ENQUEUE_READ_BUFFER_ERR
10223 #undef __ENQUEUE_READ_BUFFER_RECT_ERR
10224 #undef __ENQUEUE_WRITE_BUFFER_ERR
10225 #undef __ENQUEUE_WRITE_BUFFER_RECT_ERR
10226 #undef __ENQEUE_COPY_BUFFER_ERR
10227 #undef __ENQEUE_COPY_BUFFER_RECT_ERR
10228 #undef __ENQUEUE_FILL_BUFFER_ERR
10229 #undef __ENQUEUE_READ_IMAGE_ERR
10230 #undef __ENQUEUE_WRITE_IMAGE_ERR
10231 #undef __ENQUEUE_COPY_IMAGE_ERR
10232 #undef __ENQUEUE_FILL_IMAGE_ERR
10233 #undef __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR
10234 #undef __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR
10235 #undef __ENQUEUE_MAP_BUFFER_ERR
10236 #undef __ENQUEUE_MAP_IMAGE_ERR
10237 #undef __ENQUEUE_UNMAP_MEM_OBJECT_ERR
10238 #undef __ENQUEUE_NDRANGE_KERNEL_ERR
10239 #undef __ENQUEUE_NATIVE_KERNEL
10240 #undef __ENQUEUE_MIGRATE_MEM_OBJECTS_ERR
10241 #undef __ENQUEUE_MIGRATE_SVM_ERR
10242 #undef __ENQUEUE_ACQUIRE_GL_ERR
10243 #undef __ENQUEUE_RELEASE_GL_ERR
10244 #undef __CREATE_PIPE_ERR
10245 #undef __GET_PIPE_INFO_ERR
10246 #undef __RETAIN_ERR
10247 #undef __RELEASE_ERR
10249 #undef __FINISH_ERR
10250 #undef __VECTOR_CAPACITY_ERR
10251 #undef __CREATE_SUB_DEVICES_ERR
10252 #undef __CREATE_SUB_DEVICES_ERR
10253 #undef __ENQUEUE_MARKER_ERR
10254 #undef __ENQUEUE_WAIT_FOR_EVENTS_ERR
10255 #undef __ENQUEUE_BARRIER_ERR
10256 #undef __UNLOAD_COMPILER_ERR
10257 #undef __CREATE_GL_TEXTURE_2D_ERR
10258 #undef __CREATE_GL_TEXTURE_3D_ERR
10259 #undef __CREATE_IMAGE2D_ERR
10260 #undef __CREATE_IMAGE3D_ERR
10261 #undef __CREATE_COMMAND_QUEUE_ERR
10262 #undef __ENQUEUE_TASK_ERR
10263 #undef __CREATE_SAMPLER_ERR
10264 #undef __ENQUEUE_MARKER_WAIT_LIST_ERR
10265 #undef __ENQUEUE_BARRIER_WAIT_LIST_ERR
10266 #undef __CLONE_KERNEL_ERR
10267 #undef __GET_HOST_TIMER_ERR
10268 #undef __GET_DEVICE_AND_HOST_TIMER_ERR
10270 #endif //CL_HPP_USER_OVERRIDE_ERROR_STRINGS
10273 #undef CL_HPP_INIT_CL_EXT_FCN_PTR_
10274 #undef CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_
10276 #if defined(CL_HPP_USE_CL_DEVICE_FISSION)
10277 #undef CL_HPP_PARAM_NAME_DEVICE_FISSION_
10278 #endif // CL_HPP_USE_CL_DEVICE_FISSION
10280 #undef CL_HPP_NOEXCEPT_
10281 #undef CL_HPP_DEFINE_STATIC_MEMBER_