400 #if !defined(CL_HPP_USE_DX_INTEROP) && defined(USE_DX_INTEROP) 401 # pragma message("cl2.hpp: USE_DX_INTEROP is deprecated. Define CL_HPP_USE_DX_INTEROP instead") 402 # define CL_HPP_USE_DX_INTEROP 404 #if !defined(CL_HPP_USE_CL_DEVICE_FISSION) && defined(USE_CL_DEVICE_FISSION) 405 # pragma message("cl2.hpp: USE_CL_DEVICE_FISSION is deprecated. Define CL_HPP_USE_CL_DEVICE_FISSION instead") 406 # define CL_HPP_USE_CL_DEVICE_FISSION 408 #if !defined(CL_HPP_ENABLE_EXCEPTIONS) && defined(__CL_ENABLE_EXCEPTIONS) 409 # pragma message("cl2.hpp: __CL_ENABLE_EXCEPTIONS is deprecated. Define CL_HPP_ENABLE_EXCEPTIONS instead") 410 # define CL_HPP_ENABLE_EXCEPTIONS 412 #if !defined(CL_HPP_NO_STD_VECTOR) && defined(__NO_STD_VECTOR) 413 # pragma message("cl2.hpp: __NO_STD_VECTOR is deprecated. Define CL_HPP_NO_STD_VECTOR instead") 414 # define CL_HPP_NO_STD_VECTOR 416 #if !defined(CL_HPP_NO_STD_STRING) && defined(__NO_STD_STRING) 417 # pragma message("cl2.hpp: __NO_STD_STRING is deprecated. Define CL_HPP_NO_STD_STRING instead") 418 # define CL_HPP_NO_STD_STRING 420 #if defined(VECTOR_CLASS) 421 # pragma message("cl2.hpp: VECTOR_CLASS is deprecated. Alias cl::vector instead") 423 #if defined(STRING_CLASS) 424 # pragma message("cl2.hpp: STRING_CLASS is deprecated. Alias cl::string instead.") 426 #if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS) && defined(__CL_USER_OVERRIDE_ERROR_STRINGS) 427 # pragma message("cl2.hpp: __CL_USER_OVERRIDE_ERROR_STRINGS is deprecated. Define CL_HPP_USER_OVERRIDE_ERROR_STRINGS instead") 428 # define CL_HPP_USER_OVERRIDE_ERROR_STRINGS 433 #if defined(__USE_DEV_VECTOR) 434 # pragma message("cl2.hpp: __USE_DEV_VECTOR is no longer supported. Expect compilation errors") 436 #if defined(__USE_DEV_STRING) 437 # pragma message("cl2.hpp: __USE_DEV_STRING is no longer supported. Expect compilation errors") 441 #if !defined(CL_HPP_TARGET_OPENCL_VERSION) 442 # pragma message("cl2.hpp: CL_HPP_TARGET_OPENCL_VERSION is not defined. It will default to 200 (OpenCL 2.0)") 443 # define CL_HPP_TARGET_OPENCL_VERSION 200 445 #if CL_HPP_TARGET_OPENCL_VERSION != 100 && CL_HPP_TARGET_OPENCL_VERSION != 110 && CL_HPP_TARGET_OPENCL_VERSION != 120 && CL_HPP_TARGET_OPENCL_VERSION != 200 446 # pragma message("cl2.hpp: CL_HPP_TARGET_OPENCL_VERSION is not a valid value (100, 110, 120 or 200). It will be set to 200") 447 # undef CL_HPP_TARGET_OPENCL_VERSION 448 # define CL_HPP_TARGET_OPENCL_VERSION 200 451 #if !defined(CL_HPP_MINIMUM_OPENCL_VERSION) 452 # define CL_HPP_MINIMUM_OPENCL_VERSION 200 454 #if CL_HPP_MINIMUM_OPENCL_VERSION != 100 && CL_HPP_MINIMUM_OPENCL_VERSION != 110 && CL_HPP_MINIMUM_OPENCL_VERSION != 120 && CL_HPP_MINIMUM_OPENCL_VERSION != 200 455 # pragma message("cl2.hpp: CL_HPP_MINIMUM_OPENCL_VERSION is not a valid value (100, 110, 120 or 200). It will be set to 100") 456 # undef CL_HPP_MINIMUM_OPENCL_VERSION 457 # define CL_HPP_MINIMUM_OPENCL_VERSION 100 459 #if CL_HPP_MINIMUM_OPENCL_VERSION > CL_HPP_TARGET_OPENCL_VERSION 460 # error "CL_HPP_MINIMUM_OPENCL_VERSION must not be greater than CL_HPP_TARGET_OPENCL_VERSION" 463 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 100 && !defined(CL_USE_DEPRECATED_OPENCL_1_0_APIS) 464 # define CL_USE_DEPRECATED_OPENCL_1_0_APIS 466 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 110 && !defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 467 # define CL_USE_DEPRECATED_OPENCL_1_1_APIS 469 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 120 && !defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS) 470 # define CL_USE_DEPRECATED_OPENCL_1_2_APIS 472 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 200 && !defined(CL_USE_DEPRECATED_OPENCL_2_0_APIS) 473 # define CL_USE_DEPRECATED_OPENCL_2_0_APIS 480 #if defined(CL_HPP_USE_DX_INTEROP) 481 #include <CL/cl_d3d10.h> 482 #include <CL/cl_dx9_media_sharing.h> 486 #if defined(_MSC_VER) 494 #if (!defined(_MSC_VER) && __cplusplus < 201103L) || (defined(_MSC_VER) && _MSC_VER < 1700) 495 #error Visual studio 2013 or another C++11-supporting compiler required 499 #if defined(CL_HPP_USE_CL_DEVICE_FISSION) || defined(CL_HPP_USE_CL_SUB_GROUPS_KHR) 500 #include <CL/cl_ext.h> 503 #if defined(__APPLE__) || defined(__MACOSX) 504 #include <OpenCL/opencl.h> 506 #include <CL/opencl.h> 509 #if (__cplusplus >= 201103L) 510 #define CL_HPP_NOEXCEPT_ noexcept 512 #define CL_HPP_NOEXCEPT_ 515 #if defined(_MSC_VER) 516 # define CL_HPP_DEFINE_STATIC_MEMBER_ __declspec(selectany) 518 # define CL_HPP_DEFINE_STATIC_MEMBER_ __attribute__((weak)) 523 #if !defined(CL_EXT_PREFIX__VERSION_1_1_DEPRECATED) 524 #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED 525 #endif // #if !defined(CL_EXT_PREFIX__VERSION_1_1_DEPRECATED) 526 #if !defined(CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED) 527 #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED 528 #endif // #if !defined(CL_EXT_PREFIX__VERSION_1_1_DEPRECATED) 530 #if !defined(CL_EXT_PREFIX__VERSION_1_2_DEPRECATED) 531 #define CL_EXT_PREFIX__VERSION_1_2_DEPRECATED 532 #endif // #if !defined(CL_EXT_PREFIX__VERSION_1_2_DEPRECATED) 533 #if !defined(CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED) 534 #define CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED 535 #endif // #if !defined(CL_EXT_PREFIX__VERSION_1_2_DEPRECATED) 537 #if !defined(CL_CALLBACK) 546 #include <functional> 550 #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY) 552 using size_type = ::size_t;
554 #else // #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY) 556 using size_type = size_t;
558 #endif // #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY) 561 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 563 #endif // #if defined(CL_HPP_ENABLE_EXCEPTIONS) 565 #if !defined(CL_HPP_NO_STD_VECTOR) 568 template <
class T,
class Alloc = std::allocator<T> >
569 using vector = std::vector<T, Alloc>;
571 #endif // #if !defined(CL_HPP_NO_STD_VECTOR) 573 #if !defined(CL_HPP_NO_STD_STRING) 576 using string = std::string;
578 #endif // #if !defined(CL_HPP_NO_STD_STRING) 580 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 582 #if !defined(CL_HPP_NO_STD_UNIQUE_PTR) 587 template<
class T,
class D>
588 using pointer = std::unique_ptr<T, D>;
591 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 592 #if !defined(CL_HPP_NO_STD_ARRAY) 595 template <
class T,
size_type N >
596 using array = std::array<T, N>;
598 #endif // #if !defined(CL_HPP_NO_STD_ARRAY) 602 #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY) 604 namespace compatibility {
619 for (
int i = 0; i < N; ++i) {
624 size_t(
const array<size_type, N> &rhs)
626 for (
int i = 0; i < N; ++i) {
631 size_type& operator[](
int index)
636 const size_type& operator[](
int index)
const 642 operator size_type* () {
return data_; }
645 operator const size_type* ()
const {
return data_; }
647 operator array<size_type, N>()
const 649 array<size_type, N> ret;
651 for (
int i = 0; i < N; ++i) {
660 using size_t = compatibility::size_t<N>;
662 #endif // #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY) 667 using size_t_array = array<size_type, 3>;
680 #define CL_HPP_INIT_CL_EXT_FCN_PTR_(name) \ 682 pfn_##name = (PFN_##name) \ 683 clGetExtensionFunctionAddress(#name); \ 688 #define CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, name) \ 690 pfn_##name = (PFN_##name) \ 691 clGetExtensionFunctionAddressForPlatform(platform, #name); \ 705 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 710 class Error :
public std::exception
714 const char * errStr_;
725 Error(cl_int err,
const char * errStr = NULL) : err_(err), errStr_(errStr)
734 virtual const char * what()
const throw ()
736 if (errStr_ == NULL) {
748 cl_int err(
void)
const {
return err_; }
750 #define CL_HPP_ERR_STR_(x) #x 752 #define CL_HPP_ERR_STR_(x) NULL 753 #endif // CL_HPP_ENABLE_EXCEPTIONS 758 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 759 static inline cl_int errHandler (
761 const char * errStr = NULL)
763 if (err != CL_SUCCESS) {
764 throw Error(err, errStr);
769 static inline cl_int errHandler (cl_int err,
const char * errStr = NULL)
774 #endif // CL_HPP_ENABLE_EXCEPTIONS 780 #if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS) 781 #define __GET_DEVICE_INFO_ERR CL_HPP_ERR_STR_(clGetDeviceInfo) 782 #define __GET_PLATFORM_INFO_ERR CL_HPP_ERR_STR_(clGetPlatformInfo) 783 #define __GET_DEVICE_IDS_ERR CL_HPP_ERR_STR_(clGetDeviceIDs) 784 #define __GET_PLATFORM_IDS_ERR CL_HPP_ERR_STR_(clGetPlatformIDs) 785 #define __GET_CONTEXT_INFO_ERR CL_HPP_ERR_STR_(clGetContextInfo) 786 #define __GET_EVENT_INFO_ERR CL_HPP_ERR_STR_(clGetEventInfo) 787 #define __GET_EVENT_PROFILE_INFO_ERR CL_HPP_ERR_STR_(clGetEventProfileInfo) 788 #define __GET_MEM_OBJECT_INFO_ERR CL_HPP_ERR_STR_(clGetMemObjectInfo) 789 #define __GET_IMAGE_INFO_ERR CL_HPP_ERR_STR_(clGetImageInfo) 790 #define __GET_SAMPLER_INFO_ERR CL_HPP_ERR_STR_(clGetSamplerInfo) 791 #define __GET_KERNEL_INFO_ERR CL_HPP_ERR_STR_(clGetKernelInfo) 792 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 793 #define __GET_KERNEL_ARG_INFO_ERR CL_HPP_ERR_STR_(clGetKernelArgInfo) 794 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 795 #define __GET_KERNEL_WORK_GROUP_INFO_ERR CL_HPP_ERR_STR_(clGetKernelWorkGroupInfo) 796 #define __GET_PROGRAM_INFO_ERR CL_HPP_ERR_STR_(clGetProgramInfo) 797 #define __GET_PROGRAM_BUILD_INFO_ERR CL_HPP_ERR_STR_(clGetProgramBuildInfo) 798 #define __GET_COMMAND_QUEUE_INFO_ERR CL_HPP_ERR_STR_(clGetCommandQueueInfo) 800 #define __CREATE_CONTEXT_ERR CL_HPP_ERR_STR_(clCreateContext) 801 #define __CREATE_CONTEXT_FROM_TYPE_ERR CL_HPP_ERR_STR_(clCreateContextFromType) 802 #define __GET_SUPPORTED_IMAGE_FORMATS_ERR CL_HPP_ERR_STR_(clGetSupportedImageFormats) 804 #define __CREATE_BUFFER_ERR CL_HPP_ERR_STR_(clCreateBuffer) 805 #define __COPY_ERR CL_HPP_ERR_STR_(cl::copy) 806 #define __CREATE_SUBBUFFER_ERR CL_HPP_ERR_STR_(clCreateSubBuffer) 807 #define __CREATE_GL_BUFFER_ERR CL_HPP_ERR_STR_(clCreateFromGLBuffer) 808 #define __CREATE_GL_RENDER_BUFFER_ERR CL_HPP_ERR_STR_(clCreateFromGLBuffer) 809 #define __GET_GL_OBJECT_INFO_ERR CL_HPP_ERR_STR_(clGetGLObjectInfo) 810 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 811 #define __CREATE_IMAGE_ERR CL_HPP_ERR_STR_(clCreateImage) 812 #define __CREATE_GL_TEXTURE_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture) 813 #define __IMAGE_DIMENSION_ERR CL_HPP_ERR_STR_(Incorrect image dimensions) 814 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 815 #define __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR CL_HPP_ERR_STR_(clSetMemObjectDestructorCallback) 817 #define __CREATE_USER_EVENT_ERR CL_HPP_ERR_STR_(clCreateUserEvent) 818 #define __SET_USER_EVENT_STATUS_ERR CL_HPP_ERR_STR_(clSetUserEventStatus) 819 #define __SET_EVENT_CALLBACK_ERR CL_HPP_ERR_STR_(clSetEventCallback) 820 #define __WAIT_FOR_EVENTS_ERR CL_HPP_ERR_STR_(clWaitForEvents) 822 #define __CREATE_KERNEL_ERR CL_HPP_ERR_STR_(clCreateKernel) 823 #define __SET_KERNEL_ARGS_ERR CL_HPP_ERR_STR_(clSetKernelArg) 824 #define __CREATE_PROGRAM_WITH_SOURCE_ERR CL_HPP_ERR_STR_(clCreateProgramWithSource) 825 #define __CREATE_PROGRAM_WITH_BINARY_ERR CL_HPP_ERR_STR_(clCreateProgramWithBinary) 826 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 827 #define __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR CL_HPP_ERR_STR_(clCreateProgramWithBuiltInKernels) 828 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 829 #define __BUILD_PROGRAM_ERR CL_HPP_ERR_STR_(clBuildProgram) 830 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 831 #define __COMPILE_PROGRAM_ERR CL_HPP_ERR_STR_(clCompileProgram) 832 #define __LINK_PROGRAM_ERR CL_HPP_ERR_STR_(clLinkProgram) 833 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 834 #define __CREATE_KERNELS_IN_PROGRAM_ERR CL_HPP_ERR_STR_(clCreateKernelsInProgram) 836 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 837 #define __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR CL_HPP_ERR_STR_(clCreateCommandQueueWithProperties) 838 #define __CREATE_SAMPLER_WITH_PROPERTIES_ERR CL_HPP_ERR_STR_(clCreateSamplerWithProperties) 839 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200 840 #define __SET_COMMAND_QUEUE_PROPERTY_ERR CL_HPP_ERR_STR_(clSetCommandQueueProperty) 841 #define __ENQUEUE_READ_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueReadBuffer) 842 #define __ENQUEUE_READ_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueReadBufferRect) 843 #define __ENQUEUE_WRITE_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueWriteBuffer) 844 #define __ENQUEUE_WRITE_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueWriteBufferRect) 845 #define __ENQEUE_COPY_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueCopyBuffer) 846 #define __ENQEUE_COPY_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueCopyBufferRect) 847 #define __ENQUEUE_FILL_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueFillBuffer) 848 #define __ENQUEUE_READ_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueReadImage) 849 #define __ENQUEUE_WRITE_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueWriteImage) 850 #define __ENQUEUE_COPY_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueCopyImage) 851 #define __ENQUEUE_FILL_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueFillImage) 852 #define __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueCopyImageToBuffer) 853 #define __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueCopyBufferToImage) 854 #define __ENQUEUE_MAP_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueMapBuffer) 855 #define __ENQUEUE_MAP_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueMapImage) 856 #define __ENQUEUE_UNMAP_MEM_OBJECT_ERR CL_HPP_ERR_STR_(clEnqueueUnMapMemObject) 857 #define __ENQUEUE_NDRANGE_KERNEL_ERR CL_HPP_ERR_STR_(clEnqueueNDRangeKernel) 858 #define __ENQUEUE_NATIVE_KERNEL CL_HPP_ERR_STR_(clEnqueueNativeKernel) 859 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 860 #define __ENQUEUE_MIGRATE_MEM_OBJECTS_ERR CL_HPP_ERR_STR_(clEnqueueMigrateMemObjects) 861 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 863 #define __ENQUEUE_ACQUIRE_GL_ERR CL_HPP_ERR_STR_(clEnqueueAcquireGLObjects) 864 #define __ENQUEUE_RELEASE_GL_ERR CL_HPP_ERR_STR_(clEnqueueReleaseGLObjects) 866 #define __CREATE_PIPE_ERR CL_HPP_ERR_STR_(clCreatePipe) 867 #define __GET_PIPE_INFO_ERR CL_HPP_ERR_STR_(clGetPipeInfo) 870 #define __RETAIN_ERR CL_HPP_ERR_STR_(Retain Object) 871 #define __RELEASE_ERR CL_HPP_ERR_STR_(Release Object) 872 #define __FLUSH_ERR CL_HPP_ERR_STR_(clFlush) 873 #define __FINISH_ERR CL_HPP_ERR_STR_(clFinish) 874 #define __VECTOR_CAPACITY_ERR CL_HPP_ERR_STR_(Vector capacity error) 879 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 880 #define __CREATE_SUB_DEVICES_ERR CL_HPP_ERR_STR_(clCreateSubDevices) 882 #define __CREATE_SUB_DEVICES_ERR CL_HPP_ERR_STR_(clCreateSubDevicesEXT) 883 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 888 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 889 #define __ENQUEUE_MARKER_ERR CL_HPP_ERR_STR_(clEnqueueMarker) 890 #define __ENQUEUE_WAIT_FOR_EVENTS_ERR CL_HPP_ERR_STR_(clEnqueueWaitForEvents) 891 #define __ENQUEUE_BARRIER_ERR CL_HPP_ERR_STR_(clEnqueueBarrier) 892 #define __UNLOAD_COMPILER_ERR CL_HPP_ERR_STR_(clUnloadCompiler) 893 #define __CREATE_GL_TEXTURE_2D_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture2D) 894 #define __CREATE_GL_TEXTURE_3D_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture3D) 895 #define __CREATE_IMAGE2D_ERR CL_HPP_ERR_STR_(clCreateImage2D) 896 #define __CREATE_IMAGE3D_ERR CL_HPP_ERR_STR_(clCreateImage3D) 897 #endif // #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 902 #if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS) 903 #define __CREATE_COMMAND_QUEUE_ERR CL_HPP_ERR_STR_(clCreateCommandQueue) 904 #define __ENQUEUE_TASK_ERR CL_HPP_ERR_STR_(clEnqueueTask) 905 #define __CREATE_SAMPLER_ERR CL_HPP_ERR_STR_(clCreateSampler) 906 #endif // #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 911 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 912 #define __ENQUEUE_MARKER_WAIT_LIST_ERR CL_HPP_ERR_STR_(clEnqueueMarkerWithWaitList) 913 #define __ENQUEUE_BARRIER_WAIT_LIST_ERR CL_HPP_ERR_STR_(clEnqueueBarrierWithWaitList) 914 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 916 #endif // CL_HPP_USER_OVERRIDE_ERROR_STRINGS 926 template<
typename Functor,
typename T>
927 inline cl_int getInfoHelper(Functor f, cl_uint name, T* param,
long)
929 return f(name,
sizeof(T), param, NULL);
934 template <
typename Func>
935 inline cl_int getInfoHelper(Func f, cl_uint name, vector<vector<unsigned char>>* param,
int)
937 if (name != CL_PROGRAM_BINARIES) {
938 return CL_INVALID_VALUE;
942 size_type numBinaries = param->size();
943 vector<unsigned char*> binariesPointers(numBinaries);
945 for (size_type i = 0; i < numBinaries; ++i)
947 binariesPointers[i] = (*param)[i].data();
950 cl_int err = f(name, numBinaries *
sizeof(
unsigned char*), binariesPointers.data(), NULL);
952 if (err != CL_SUCCESS) {
962 template <
typename Func,
typename T>
963 inline cl_int getInfoHelper(Func f, cl_uint name, vector<T>* param,
long)
966 cl_int err = f(name, 0, NULL, &required);
967 if (err != CL_SUCCESS) {
970 const size_type elements = required /
sizeof(T);
973 vector<T> localData(elements);
974 err = f(name, required, localData.data(), NULL);
975 if (err != CL_SUCCESS) {
979 *param = std::move(localData);
991 template <
typename Func,
typename T>
992 inline cl_int getInfoHelper(
993 Func f, cl_uint name, vector<T>* param,
int,
typename T::cl_type = 0)
996 cl_int err = f(name, 0, NULL, &required);
997 if (err != CL_SUCCESS) {
1001 const size_type elements = required /
sizeof(
typename T::cl_type);
1003 vector<typename T::cl_type> value(elements);
1004 err = f(name, required, value.data(), NULL);
1005 if (err != CL_SUCCESS) {
1011 param->resize(elements);
1015 for (size_type i = 0; i < elements; i++) {
1016 (*param)[i] = T(value[i],
true);
1023 template <
typename Func>
1024 inline cl_int getInfoHelper(Func f, cl_uint name,
string* param,
long)
1027 cl_int err = f(name, 0, NULL, &required);
1028 if (err != CL_SUCCESS) {
1035 vector<char> value(required);
1036 err = f(name, required, value.data(), NULL);
1037 if (err != CL_SUCCESS) {
1041 param->assign(begin(value), prev(end(value)));
1051 template <
typename Func,
size_type N>
1052 inline cl_int getInfoHelper(Func f, cl_uint name, array<size_type, N>* param,
long)
1055 cl_int err = f(name, 0, NULL, &required);
1056 if (err != CL_SUCCESS) {
1060 size_type elements = required /
sizeof(size_type);
1061 vector<size_type> value(elements, 0);
1063 err = f(name, required, value.data(), NULL);
1064 if (err != CL_SUCCESS) {
1073 for (size_type i = 0; i < elements; ++i) {
1074 (*param)[i] = value[i];
1088 template<
typename Func,
typename T>
1089 inline cl_int getInfoHelper(Func f, cl_uint name, T* param,
int,
typename T::cl_type = 0)
1091 typename T::cl_type value;
1092 cl_int err = f(name,
sizeof(value), &value, NULL);
1093 if (err != CL_SUCCESS) {
1099 err = param->retain();
1100 if (err != CL_SUCCESS) {
1107 #define CL_HPP_PARAM_NAME_INFO_1_0_(F) \ 1108 F(cl_platform_info, CL_PLATFORM_PROFILE, string) \ 1109 F(cl_platform_info, CL_PLATFORM_VERSION, string) \ 1110 F(cl_platform_info, CL_PLATFORM_NAME, string) \ 1111 F(cl_platform_info, CL_PLATFORM_VENDOR, string) \ 1112 F(cl_platform_info, CL_PLATFORM_EXTENSIONS, string) \ 1114 F(cl_device_info, CL_DEVICE_TYPE, cl_device_type) \ 1115 F(cl_device_info, CL_DEVICE_VENDOR_ID, cl_uint) \ 1116 F(cl_device_info, CL_DEVICE_MAX_COMPUTE_UNITS, cl_uint) \ 1117 F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, cl_uint) \ 1118 F(cl_device_info, CL_DEVICE_MAX_WORK_GROUP_SIZE, size_type) \ 1119 F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_SIZES, cl::vector<size_type>) \ 1120 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, cl_uint) \ 1121 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT, cl_uint) \ 1122 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT, cl_uint) \ 1123 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG, cl_uint) \ 1124 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT, cl_uint) \ 1125 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, cl_uint) \ 1126 F(cl_device_info, CL_DEVICE_MAX_CLOCK_FREQUENCY, cl_uint) \ 1127 F(cl_device_info, CL_DEVICE_ADDRESS_BITS, cl_uint) \ 1128 F(cl_device_info, CL_DEVICE_MAX_READ_IMAGE_ARGS, cl_uint) \ 1129 F(cl_device_info, CL_DEVICE_MAX_WRITE_IMAGE_ARGS, cl_uint) \ 1130 F(cl_device_info, CL_DEVICE_MAX_MEM_ALLOC_SIZE, cl_ulong) \ 1131 F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_WIDTH, size_type) \ 1132 F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_HEIGHT, size_type) \ 1133 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_WIDTH, size_type) \ 1134 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_HEIGHT, size_type) \ 1135 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_DEPTH, size_type) \ 1136 F(cl_device_info, CL_DEVICE_IMAGE_SUPPORT, cl_bool) \ 1137 F(cl_device_info, CL_DEVICE_MAX_PARAMETER_SIZE, size_type) \ 1138 F(cl_device_info, CL_DEVICE_MAX_SAMPLERS, cl_uint) \ 1139 F(cl_device_info, CL_DEVICE_MEM_BASE_ADDR_ALIGN, cl_uint) \ 1140 F(cl_device_info, CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE, cl_uint) \ 1141 F(cl_device_info, CL_DEVICE_SINGLE_FP_CONFIG, cl_device_fp_config) \ 1142 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_TYPE, cl_device_mem_cache_type) \ 1143 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE, cl_uint)\ 1144 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_SIZE, cl_ulong) \ 1145 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_SIZE, cl_ulong) \ 1146 F(cl_device_info, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE, cl_ulong) \ 1147 F(cl_device_info, CL_DEVICE_MAX_CONSTANT_ARGS, cl_uint) \ 1148 F(cl_device_info, CL_DEVICE_LOCAL_MEM_TYPE, cl_device_local_mem_type) \ 1149 F(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE, cl_ulong) \ 1150 F(cl_device_info, CL_DEVICE_ERROR_CORRECTION_SUPPORT, cl_bool) \ 1151 F(cl_device_info, CL_DEVICE_PROFILING_TIMER_RESOLUTION, size_type) \ 1152 F(cl_device_info, CL_DEVICE_ENDIAN_LITTLE, cl_bool) \ 1153 F(cl_device_info, CL_DEVICE_AVAILABLE, cl_bool) \ 1154 F(cl_device_info, CL_DEVICE_COMPILER_AVAILABLE, cl_bool) \ 1155 F(cl_device_info, CL_DEVICE_EXECUTION_CAPABILITIES, cl_device_exec_capabilities) \ 1156 F(cl_device_info, CL_DEVICE_PLATFORM, cl_platform_id) \ 1157 F(cl_device_info, CL_DEVICE_NAME, string) \ 1158 F(cl_device_info, CL_DEVICE_VENDOR, string) \ 1159 F(cl_device_info, CL_DRIVER_VERSION, string) \ 1160 F(cl_device_info, CL_DEVICE_PROFILE, string) \ 1161 F(cl_device_info, CL_DEVICE_VERSION, string) \ 1162 F(cl_device_info, CL_DEVICE_EXTENSIONS, string) \ 1164 F(cl_context_info, CL_CONTEXT_REFERENCE_COUNT, cl_uint) \ 1165 F(cl_context_info, CL_CONTEXT_DEVICES, cl::vector<Device>) \ 1166 F(cl_context_info, CL_CONTEXT_PROPERTIES, cl::vector<cl_context_properties>) \ 1168 F(cl_event_info, CL_EVENT_COMMAND_QUEUE, cl::CommandQueue) \ 1169 F(cl_event_info, CL_EVENT_COMMAND_TYPE, cl_command_type) \ 1170 F(cl_event_info, CL_EVENT_REFERENCE_COUNT, cl_uint) \ 1171 F(cl_event_info, CL_EVENT_COMMAND_EXECUTION_STATUS, cl_int) \ 1173 F(cl_profiling_info, CL_PROFILING_COMMAND_QUEUED, cl_ulong) \ 1174 F(cl_profiling_info, CL_PROFILING_COMMAND_SUBMIT, cl_ulong) \ 1175 F(cl_profiling_info, CL_PROFILING_COMMAND_START, cl_ulong) \ 1176 F(cl_profiling_info, CL_PROFILING_COMMAND_END, cl_ulong) \ 1178 F(cl_mem_info, CL_MEM_TYPE, cl_mem_object_type) \ 1179 F(cl_mem_info, CL_MEM_FLAGS, cl_mem_flags) \ 1180 F(cl_mem_info, CL_MEM_SIZE, size_type) \ 1181 F(cl_mem_info, CL_MEM_HOST_PTR, void*) \ 1182 F(cl_mem_info, CL_MEM_MAP_COUNT, cl_uint) \ 1183 F(cl_mem_info, CL_MEM_REFERENCE_COUNT, cl_uint) \ 1184 F(cl_mem_info, CL_MEM_CONTEXT, cl::Context) \ 1186 F(cl_image_info, CL_IMAGE_FORMAT, cl_image_format) \ 1187 F(cl_image_info, CL_IMAGE_ELEMENT_SIZE, size_type) \ 1188 F(cl_image_info, CL_IMAGE_ROW_PITCH, size_type) \ 1189 F(cl_image_info, CL_IMAGE_SLICE_PITCH, size_type) \ 1190 F(cl_image_info, CL_IMAGE_WIDTH, size_type) \ 1191 F(cl_image_info, CL_IMAGE_HEIGHT, size_type) \ 1192 F(cl_image_info, CL_IMAGE_DEPTH, size_type) \ 1194 F(cl_sampler_info, CL_SAMPLER_REFERENCE_COUNT, cl_uint) \ 1195 F(cl_sampler_info, CL_SAMPLER_CONTEXT, cl::Context) \ 1196 F(cl_sampler_info, CL_SAMPLER_NORMALIZED_COORDS, cl_bool) \ 1197 F(cl_sampler_info, CL_SAMPLER_ADDRESSING_MODE, cl_addressing_mode) \ 1198 F(cl_sampler_info, CL_SAMPLER_FILTER_MODE, cl_filter_mode) \ 1200 F(cl_program_info, CL_PROGRAM_REFERENCE_COUNT, cl_uint) \ 1201 F(cl_program_info, CL_PROGRAM_CONTEXT, cl::Context) \ 1202 F(cl_program_info, CL_PROGRAM_NUM_DEVICES, cl_uint) \ 1203 F(cl_program_info, CL_PROGRAM_DEVICES, cl::vector<Device>) \ 1204 F(cl_program_info, CL_PROGRAM_SOURCE, string) \ 1205 F(cl_program_info, CL_PROGRAM_BINARY_SIZES, cl::vector<size_type>) \ 1206 F(cl_program_info, CL_PROGRAM_BINARIES, cl::vector<cl::vector<unsigned char>>) \ 1208 F(cl_program_build_info, CL_PROGRAM_BUILD_STATUS, cl_build_status) \ 1209 F(cl_program_build_info, CL_PROGRAM_BUILD_OPTIONS, string) \ 1210 F(cl_program_build_info, CL_PROGRAM_BUILD_LOG, string) \ 1212 F(cl_kernel_info, CL_KERNEL_FUNCTION_NAME, string) \ 1213 F(cl_kernel_info, CL_KERNEL_NUM_ARGS, cl_uint) \ 1214 F(cl_kernel_info, CL_KERNEL_REFERENCE_COUNT, cl_uint) \ 1215 F(cl_kernel_info, CL_KERNEL_CONTEXT, cl::Context) \ 1216 F(cl_kernel_info, CL_KERNEL_PROGRAM, cl::Program) \ 1218 F(cl_kernel_work_group_info, CL_KERNEL_WORK_GROUP_SIZE, size_type) \ 1219 F(cl_kernel_work_group_info, CL_KERNEL_COMPILE_WORK_GROUP_SIZE, cl::detail::size_t_array) \ 1220 F(cl_kernel_work_group_info, CL_KERNEL_LOCAL_MEM_SIZE, cl_ulong) \ 1222 F(cl_command_queue_info, CL_QUEUE_CONTEXT, cl::Context) \ 1223 F(cl_command_queue_info, CL_QUEUE_DEVICE, cl::Device) \ 1224 F(cl_command_queue_info, CL_QUEUE_REFERENCE_COUNT, cl_uint) \ 1225 F(cl_command_queue_info, CL_QUEUE_PROPERTIES, cl_command_queue_properties) 1228 #define CL_HPP_PARAM_NAME_INFO_1_1_(F) \ 1229 F(cl_context_info, CL_CONTEXT_NUM_DEVICES, cl_uint)\ 1230 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF, cl_uint) \ 1231 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR, cl_uint) \ 1232 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT, cl_uint) \ 1233 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_INT, cl_uint) \ 1234 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG, cl_uint) \ 1235 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT, cl_uint) \ 1236 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE, cl_uint) \ 1237 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF, cl_uint) \ 1238 F(cl_device_info, CL_DEVICE_DOUBLE_FP_CONFIG, cl_device_fp_config) \ 1239 F(cl_device_info, CL_DEVICE_HALF_FP_CONFIG, cl_device_fp_config) \ 1240 F(cl_device_info, CL_DEVICE_OPENCL_C_VERSION, string) \ 1242 F(cl_mem_info, CL_MEM_ASSOCIATED_MEMOBJECT, cl::Memory) \ 1243 F(cl_mem_info, CL_MEM_OFFSET, size_type) \ 1245 F(cl_kernel_work_group_info, CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, size_type) \ 1246 F(cl_kernel_work_group_info, CL_KERNEL_PRIVATE_MEM_SIZE, cl_ulong) \ 1248 F(cl_event_info, CL_EVENT_CONTEXT, cl::Context) 1250 #define CL_HPP_PARAM_NAME_INFO_1_2_(F) \ 1251 F(cl_program_info, CL_PROGRAM_NUM_KERNELS, size_type) \ 1252 F(cl_program_info, CL_PROGRAM_KERNEL_NAMES, string) \ 1254 F(cl_program_build_info, CL_PROGRAM_BINARY_TYPE, cl_program_binary_type) \ 1256 F(cl_kernel_info, CL_KERNEL_ATTRIBUTES, string) \ 1258 F(cl_kernel_arg_info, CL_KERNEL_ARG_ADDRESS_QUALIFIER, cl_kernel_arg_address_qualifier) \ 1259 F(cl_kernel_arg_info, CL_KERNEL_ARG_ACCESS_QUALIFIER, cl_kernel_arg_access_qualifier) \ 1260 F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_NAME, string) \ 1261 F(cl_kernel_arg_info, CL_KERNEL_ARG_NAME, string) \ 1262 F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_QUALIFIER, cl_kernel_arg_type_qualifier) \ 1264 F(cl_device_info, CL_DEVICE_PARENT_DEVICE, cl::Device) \ 1265 F(cl_device_info, CL_DEVICE_PARTITION_PROPERTIES, cl::vector<cl_device_partition_property>) \ 1266 F(cl_device_info, CL_DEVICE_PARTITION_TYPE, cl::vector<cl_device_partition_property>) \ 1267 F(cl_device_info, CL_DEVICE_REFERENCE_COUNT, cl_uint) \ 1268 F(cl_device_info, CL_DEVICE_PREFERRED_INTEROP_USER_SYNC, size_type) \ 1269 F(cl_device_info, CL_DEVICE_PARTITION_AFFINITY_DOMAIN, cl_device_affinity_domain) \ 1270 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS, string) \ 1272 F(cl_image_info, CL_IMAGE_ARRAY_SIZE, size_type) \ 1273 F(cl_image_info, CL_IMAGE_NUM_MIP_LEVELS, cl_uint) \ 1274 F(cl_image_info, CL_IMAGE_NUM_SAMPLES, cl_uint) 1276 #define CL_HPP_PARAM_NAME_INFO_2_0_(F) \ 1277 F(cl_device_info, CL_DEVICE_QUEUE_ON_HOST_PROPERTIES, cl_command_queue_properties) \ 1278 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES, cl_command_queue_properties) \ 1279 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE, cl_uint) \ 1280 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE, cl_uint) \ 1281 F(cl_device_info, CL_DEVICE_MAX_ON_DEVICE_QUEUES, cl_uint) \ 1282 F(cl_device_info, CL_DEVICE_MAX_ON_DEVICE_EVENTS, cl_uint) \ 1283 F(cl_device_info, CL_DEVICE_MAX_PIPE_ARGS, cl_uint) \ 1284 F(cl_device_info, CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS, cl_uint) \ 1285 F(cl_device_info, CL_DEVICE_PIPE_MAX_PACKET_SIZE, cl_uint) \ 1286 F(cl_device_info, CL_DEVICE_SVM_CAPABILITIES, cl_device_svm_capabilities) \ 1287 F(cl_device_info, CL_DEVICE_PREFERRED_PLATFORM_ATOMIC_ALIGNMENT, cl_uint) \ 1288 F(cl_device_info, CL_DEVICE_PREFERRED_GLOBAL_ATOMIC_ALIGNMENT, cl_uint) \ 1289 F(cl_device_info, CL_DEVICE_PREFERRED_LOCAL_ATOMIC_ALIGNMENT, cl_uint) \ 1290 F(cl_command_queue_info, CL_QUEUE_SIZE, cl_uint) \ 1291 F(cl_mem_info, CL_MEM_USES_SVM_POINTER, cl_bool) \ 1292 F(cl_program_build_info, CL_PROGRAM_BUILD_GLOBAL_VARIABLE_TOTAL_SIZE, size_type) \ 1293 F(cl_pipe_info, CL_PIPE_PACKET_SIZE, cl_uint) \ 1294 F(cl_pipe_info, CL_PIPE_MAX_PACKETS, cl_uint) 1296 #define CL_HPP_PARAM_NAME_DEVICE_FISSION_(F) \ 1297 F(cl_device_info, CL_DEVICE_PARENT_DEVICE_EXT, cl_device_id) \ 1298 F(cl_device_info, CL_DEVICE_PARTITION_TYPES_EXT, cl::vector<cl_device_partition_property_ext>) \ 1299 F(cl_device_info, CL_DEVICE_AFFINITY_DOMAINS_EXT, cl::vector<cl_device_partition_property_ext>) \ 1300 F(cl_device_info, CL_DEVICE_REFERENCE_COUNT_EXT , cl_uint) \ 1301 F(cl_device_info, CL_DEVICE_PARTITION_STYLE_EXT, cl::vector<cl_device_partition_property_ext>) 1303 template <
typename enum_type, cl_
int Name>
1306 #define CL_HPP_DECLARE_PARAM_TRAITS_(token, param_name, T) \ 1309 struct param_traits<detail:: token,param_name> \ 1311 enum { value = param_name }; \ 1312 typedef T param_type; \ 1315 CL_HPP_PARAM_NAME_INFO_1_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1316 #if CL_HPP_TARGET_OPENCL_VERSION >= 110 1317 CL_HPP_PARAM_NAME_INFO_1_1_(CL_HPP_DECLARE_PARAM_TRAITS_)
1318 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110 1319 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 1320 CL_HPP_PARAM_NAME_INFO_1_2_(CL_HPP_DECLARE_PARAM_TRAITS_)
1321 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110 1322 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 1323 CL_HPP_PARAM_NAME_INFO_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1324 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110 1328 #define CL_HPP_PARAM_NAME_INFO_1_0_DEPRECATED_IN_2_0_(F) \ 1329 F(cl_device_info, CL_DEVICE_QUEUE_PROPERTIES, cl_command_queue_properties) 1331 #define CL_HPP_PARAM_NAME_INFO_1_1_DEPRECATED_IN_2_0_(F) \ 1332 F(cl_device_info, CL_DEVICE_HOST_UNIFIED_MEMORY, cl_bool) 1334 #define CL_HPP_PARAM_NAME_INFO_1_2_DEPRECATED_IN_2_0_(F) \ 1335 F(cl_image_info, CL_IMAGE_BUFFER, cl::Buffer) 1339 #if CL_HPP_TARGET_OPENCL_VERSION > 100 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 && CL_HPP_TARGET_OPENCL_VERSION < 200 1340 CL_HPP_PARAM_NAME_INFO_1_0_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1341 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 110 1342 #if CL_HPP_TARGET_OPENCL_VERSION > 110 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 1343 CL_HPP_PARAM_NAME_INFO_1_1_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1344 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 120 1345 #if CL_HPP_TARGET_OPENCL_VERSION > 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 1346 CL_HPP_PARAM_NAME_INFO_1_2_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1347 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 200 1349 #if defined(CL_HPP_USE_CL_DEVICE_FISSION) 1350 CL_HPP_PARAM_NAME_DEVICE_FISSION_(CL_HPP_DECLARE_PARAM_TRAITS_);
1351 #endif // CL_HPP_USE_CL_DEVICE_FISSION 1353 #ifdef CL_PLATFORM_ICD_SUFFIX_KHR 1354 CL_HPP_DECLARE_PARAM_TRAITS_(cl_platform_info, CL_PLATFORM_ICD_SUFFIX_KHR,
string)
1357 #ifdef CL_DEVICE_PROFILING_TIMER_OFFSET_AMD 1358 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_PROFILING_TIMER_OFFSET_AMD, cl_ulong)
1361 #ifdef CL_DEVICE_GLOBAL_FREE_MEMORY_AMD 1362 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_FREE_MEMORY_AMD, vector<size_type>)
1364 #ifdef CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD 1365 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD, cl_uint)
1367 #ifdef CL_DEVICE_SIMD_WIDTH_AMD 1368 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_WIDTH_AMD, cl_uint)
1370 #ifdef CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD 1371 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD, cl_uint)
1373 #ifdef CL_DEVICE_WAVEFRONT_WIDTH_AMD 1374 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_WAVEFRONT_WIDTH_AMD, cl_uint)
1376 #ifdef CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD 1377 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD, cl_uint)
1379 #ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD 1380 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD, cl_uint)
1382 #ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD 1383 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD, cl_uint)
1385 #ifdef CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD 1386 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD, cl_uint)
1388 #ifdef CL_DEVICE_LOCAL_MEM_BANKS_AMD 1389 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LOCAL_MEM_BANKS_AMD, cl_uint)
1392 #ifdef CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV 1393 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV, cl_uint)
1395 #ifdef CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV 1396 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV, cl_uint)
1398 #ifdef CL_DEVICE_REGISTERS_PER_BLOCK_NV 1399 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_REGISTERS_PER_BLOCK_NV, cl_uint)
1401 #ifdef CL_DEVICE_WARP_SIZE_NV 1402 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_WARP_SIZE_NV, cl_uint)
1404 #ifdef CL_DEVICE_GPU_OVERLAP_NV 1405 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GPU_OVERLAP_NV, cl_bool)
1407 #ifdef CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV 1408 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV, cl_bool)
1410 #ifdef CL_DEVICE_INTEGRATED_MEMORY_NV 1411 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGRATED_MEMORY_NV, cl_bool)
1416 template <
typename Func,
typename T>
1418 getInfo(Func f, cl_uint name, T* param)
1420 return getInfoHelper(f, name, param, 0);
1423 template <
typename Func,
typename Arg0>
1426 Func f_;
const Arg0& arg0_;
1428 cl_uint param, size_type size,
void* value, size_type* size_ret)
1429 {
return f_(arg0_, param, size, value, size_ret); }
1432 template <
typename Func,
typename Arg0,
typename Arg1>
1435 Func f_;
const Arg0& arg0_;
const Arg1& arg1_;
1437 cl_uint param, size_type size,
void* value, size_type* size_ret)
1438 {
return f_(arg0_, arg1_, param, size, value, size_ret); }
1441 template <
typename Func,
typename Arg0,
typename T>
1443 getInfo(Func f,
const Arg0& arg0, cl_uint name, T* param)
1446 return getInfoHelper(f0, name, param, 0);
1449 template <
typename Func,
typename Arg0,
typename Arg1,
typename T>
1451 getInfo(Func f,
const Arg0& arg0,
const Arg1& arg1, cl_uint name, T* param)
1454 return getInfoHelper(f0, name, param, 0);
1458 template<
typename T>
1462 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 1479 { return ::clRetainDevice(device); }
1490 { return ::clReleaseDevice(device); }
1492 #else // CL_HPP_TARGET_OPENCL_VERSION >= 120 1500 static cl_int retain(cl_device_id)
1501 {
return CL_SUCCESS; }
1503 static cl_int release(cl_device_id)
1504 {
return CL_SUCCESS; }
1506 #endif // ! (CL_HPP_TARGET_OPENCL_VERSION >= 120) 1512 static cl_int retain(cl_platform_id)
1513 {
return CL_SUCCESS; }
1515 static cl_int release(cl_platform_id)
1516 {
return CL_SUCCESS; }
1522 static cl_int retain(cl_context context)
1523 { return ::clRetainContext(context); }
1524 static cl_int release(cl_context context)
1525 { return ::clReleaseContext(context); }
1531 static cl_int retain(cl_command_queue queue)
1532 { return ::clRetainCommandQueue(queue); }
1533 static cl_int release(cl_command_queue queue)
1534 { return ::clReleaseCommandQueue(queue); }
1540 static cl_int retain(cl_mem memory)
1541 { return ::clRetainMemObject(memory); }
1542 static cl_int release(cl_mem memory)
1543 { return ::clReleaseMemObject(memory); }
1549 static cl_int retain(cl_sampler sampler)
1550 { return ::clRetainSampler(sampler); }
1551 static cl_int release(cl_sampler sampler)
1552 { return ::clReleaseSampler(sampler); }
1558 static cl_int retain(cl_program program)
1559 { return ::clRetainProgram(program); }
1560 static cl_int release(cl_program program)
1561 { return ::clReleaseProgram(program); }
1567 static cl_int retain(cl_kernel kernel)
1568 { return ::clRetainKernel(kernel); }
1569 static cl_int release(cl_kernel kernel)
1570 { return ::clReleaseKernel(kernel); }
1576 static cl_int retain(cl_event event)
1577 { return ::clRetainEvent(event); }
1578 static cl_int release(cl_event event)
1579 { return ::clReleaseEvent(event); }
1583 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120 1585 static cl_uint getVersion(
const vector<char> &versionInfo)
1587 int highVersion = 0;
1590 while(versionInfo[index] !=
'.' ) {
1592 highVersion += versionInfo[index]-
'0';
1596 while(versionInfo[index] !=
' ' && versionInfo[index] !=
'\0') {
1598 lowVersion += versionInfo[index]-
'0';
1601 return (highVersion << 16) | lowVersion;
1604 static cl_uint getPlatformVersion(cl_platform_id platform)
1607 clGetPlatformInfo(platform, CL_PLATFORM_VERSION, 0, NULL, &size);
1609 vector<char> versionInfo(size);
1610 clGetPlatformInfo(platform, CL_PLATFORM_VERSION, size, versionInfo.data(), &size);
1611 return getVersion(versionInfo);
1614 static cl_uint getDevicePlatformVersion(cl_device_id device)
1616 cl_platform_id platform;
1617 clGetDeviceInfo(device, CL_DEVICE_PLATFORM,
sizeof(platform), &platform, NULL);
1618 return getPlatformVersion(platform);
1621 static cl_uint getContextPlatformVersion(cl_context context)
1626 clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, NULL, &size);
1629 vector<cl_device_id> devices(size/
sizeof(cl_device_id));
1630 clGetContextInfo(context, CL_CONTEXT_DEVICES, size, devices.data(), NULL);
1631 return getDevicePlatformVersion(devices[0]);
1633 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120 1635 template <
typename T>
1647 Wrapper(
const cl_type &obj,
bool retainObject) : object_(obj)
1650 detail::errHandler(retain(), __RETAIN_ERR);
1656 if (object_ != NULL) { release(); }
1661 object_ = rhs.object_;
1662 detail::errHandler(retain(), __RETAIN_ERR);
1667 object_ = rhs.object_;
1674 detail::errHandler(release(), __RELEASE_ERR);
1675 object_ = rhs.object_;
1676 detail::errHandler(retain(), __RETAIN_ERR);
1684 detail::errHandler(release(), __RELEASE_ERR);
1685 object_ = rhs.object_;
1693 detail::errHandler(release(), __RELEASE_ERR);
1698 const cl_type& operator ()()
const {
return object_; }
1700 cl_type& operator ()() {
return object_; }
1702 const cl_type
get()
const {
return object_; }
1704 cl_type
get() {
return object_; }
1708 template<
typename Func,
typename U>
1709 friend inline cl_int getInfoHelper(Func, cl_uint, U*,
int,
typename U::cl_type);
1711 cl_int retain()
const 1713 if (object_ !=
nullptr) {
1721 cl_int release()
const 1723 if (object_ !=
nullptr) {
1736 typedef cl_device_id cl_type;
1740 bool referenceCountable_;
1742 static bool isReferenceCountable(cl_device_id device)
1744 bool retVal =
false;
1745 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 1746 #if CL_HPP_MINIMUM_OPENCL_VERSION < 120 1747 if (device != NULL) {
1748 int version = getDevicePlatformVersion(device);
1749 if(version > ((1 << 16) + 1)) {
1753 #else // CL_HPP_MINIMUM_OPENCL_VERSION < 120 1755 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 120 1756 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 1761 Wrapper() : object_(NULL), referenceCountable_(
false)
1765 Wrapper(
const cl_type &obj,
bool retainObject) :
1767 referenceCountable_(
false)
1769 referenceCountable_ = isReferenceCountable(obj);
1772 detail::errHandler(retain(), __RETAIN_ERR);
1783 object_ = rhs.object_;
1784 referenceCountable_ = isReferenceCountable(object_);
1785 detail::errHandler(retain(), __RETAIN_ERR);
1790 object_ = rhs.object_;
1791 referenceCountable_ = rhs.referenceCountable_;
1793 rhs.referenceCountable_ =
false;
1799 detail::errHandler(release(), __RELEASE_ERR);
1800 object_ = rhs.object_;
1801 referenceCountable_ = rhs.referenceCountable_;
1802 detail::errHandler(retain(), __RETAIN_ERR);
1810 detail::errHandler(release(), __RELEASE_ERR);
1811 object_ = rhs.object_;
1812 referenceCountable_ = rhs.referenceCountable_;
1814 rhs.referenceCountable_ =
false;
1821 detail::errHandler(release(), __RELEASE_ERR);
1823 referenceCountable_ = isReferenceCountable(object_);
1827 const cl_type& operator ()()
const {
return object_; }
1829 cl_type& operator ()() {
return object_; }
1831 cl_type
get()
const {
return object_; }
1834 template<
typename Func,
typename U>
1835 friend inline cl_int getInfoHelper(Func, cl_uint, U*,
int,
typename U::cl_type);
1837 template<
typename Func,
typename U>
1838 friend inline cl_int getInfoHelper(Func, cl_uint, vector<U>*,
int,
typename U::cl_type);
1840 cl_int retain()
const 1842 if( object_ !=
nullptr && referenceCountable_ ) {
1850 cl_int release()
const 1852 if (object_ !=
nullptr && referenceCountable_) {
1861 template <
typename T>
1864 return lhs() == rhs();
1867 template <
typename T>
1870 return !operator==(lhs, rhs);
1877 using BuildLogType = vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, CL_PROGRAM_BUILD_LOG>::param_type>>;
1878 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 1882 class BuildError :
public Error
1885 BuildLogType buildLogs;
1887 BuildError(cl_int err,
const char * errStr,
const BuildLogType &vec) : Error(err, errStr), buildLogs(vec)
1891 BuildLogType getBuildLog()
const 1897 static inline cl_int buildErrHandler(
1899 const char * errStr,
1900 const BuildLogType &buildLogs)
1902 if (err != CL_SUCCESS) {
1903 throw BuildError(err, errStr, buildLogs);
1911 static inline cl_int buildErrHandler(
1913 const char * errStr,
1914 const BuildLogType &buildLogs)
1921 #endif // #if defined(CL_HPP_ENABLE_EXCEPTIONS) 1937 image_channel_order = order;
1938 image_channel_data_type = type;
1945 this->image_channel_data_type = rhs.image_channel_data_type;
1946 this->image_channel_order = rhs.image_channel_order;
1962 static std::once_flag default_initialized_;
1964 static cl_int default_error_;
1971 static void makeDefault();
1978 static void makeDefaultProvided(
const Device &p) {
1983 #ifdef CL_HPP_UNIT_TEST_ENABLE 1990 static void unitTestClearDefault() {
1993 #endif // #ifdef CL_HPP_UNIT_TEST_ENABLE 2002 explicit Device(
const cl_device_id &device,
bool retainObject =
false) :
2003 detail::Wrapper<cl_type>(device, retainObject) { }
2010 cl_int *errResult = NULL)
2012 std::call_once(default_initialized_, makeDefault);
2013 detail::errHandler(default_error_);
2014 if (errResult != NULL) {
2015 *errResult = default_error_;
2029 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_device));
2030 detail::errHandler(default_error_);
2073 template <
typename T>
2074 cl_int
getInfo(cl_device_info name, T* param)
const 2076 return detail::errHandler(
2077 detail::getInfo(&::clGetDeviceInfo, object_, name, param),
2078 __GET_DEVICE_INFO_ERR);
2082 template <cl_
int name>
typename 2087 detail::cl_device_info, name>::param_type param;
2088 cl_int result = getInfo(name, ¶m);
2098 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 2099 cl_int createSubDevices(
2101 const cl_device_partition_property * properties,
2102 vector<Device>* devices)
2105 cl_int err = clCreateSubDevices(object_, properties, 0, NULL, &n);
2106 if (err != CL_SUCCESS) {
2107 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2110 vector<cl_device_id> ids(n);
2111 err = clCreateSubDevices(object_, properties, n, ids.data(), NULL);
2112 if (err != CL_SUCCESS) {
2113 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2119 devices->resize(ids.size());
2123 for (size_type i = 0; i < ids.size(); i++) {
2126 (*devices)[i] =
Device(ids[i],
false);
2132 #elif defined(CL_HPP_USE_CL_DEVICE_FISSION) 2137 cl_int createSubDevices(
2138 const cl_device_partition_property_ext * properties,
2139 vector<Device>* devices)
2141 typedef CL_API_ENTRY cl_int
2142 ( CL_API_CALL * PFN_clCreateSubDevicesEXT)(
2144 const cl_device_partition_property_ext * ,
2147 cl_uint * ) CL_EXT_SUFFIX__VERSION_1_1;
2149 static PFN_clCreateSubDevicesEXT pfn_clCreateSubDevicesEXT = NULL;
2150 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateSubDevicesEXT);
2153 cl_int err = pfn_clCreateSubDevicesEXT(object_, properties, 0, NULL, &n);
2154 if (err != CL_SUCCESS) {
2155 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2158 vector<cl_device_id> ids(n);
2159 err = pfn_clCreateSubDevicesEXT(object_, properties, n, ids.data(), NULL);
2160 if (err != CL_SUCCESS) {
2161 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2166 devices->resize(ids.size());
2170 for (size_type i = 0; i < ids.size(); i++) {
2173 (*devices)[i] =
Device(ids[i],
false);
2178 #endif // defined(CL_HPP_USE_CL_DEVICE_FISSION) 2181 CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Device::default_initialized_;
2182 CL_HPP_DEFINE_STATIC_MEMBER_
Device Device::default_;
2183 CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Device::default_error_ = CL_SUCCESS;
2195 static std::once_flag default_initialized_;
2197 static cl_int default_error_;
2204 static void makeDefault() {
2208 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 2216 cl_int err = ::clGetPlatformIDs(0, NULL, &n);
2217 if (err != CL_SUCCESS) {
2218 default_error_ = err;
2222 default_error_ = CL_INVALID_PLATFORM;
2226 vector<cl_platform_id> ids(n);
2227 err = ::clGetPlatformIDs(n, ids.data(), NULL);
2228 if (err != CL_SUCCESS) {
2229 default_error_ = err;
2235 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 2236 catch (cl::Error &e) {
2237 default_error_ = e.err();
2247 static void makeDefaultProvided(
const Platform &p) {
2252 #ifdef CL_HPP_UNIT_TEST_ENABLE 2259 static void unitTestClearDefault() {
2262 #endif // #ifdef CL_HPP_UNIT_TEST_ENABLE 2274 explicit Platform(
const cl_platform_id &platform,
bool retainObject =
false) :
2275 detail::Wrapper<cl_type>(platform, retainObject) { }
2288 cl_int *errResult = NULL)
2290 std::call_once(default_initialized_, makeDefault);
2291 detail::errHandler(default_error_);
2292 if (errResult != NULL) {
2293 *errResult = default_error_;
2307 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_platform));
2308 detail::errHandler(default_error_);
2313 cl_int
getInfo(cl_platform_info name,
string* param)
const 2315 return detail::errHandler(
2316 detail::getInfo(&::clGetPlatformInfo, object_, name, param),
2317 __GET_PLATFORM_INFO_ERR);
2321 template <cl_
int name>
typename 2326 detail::cl_platform_info, name>::param_type param;
2327 cl_int result = getInfo(name, ¶m);
2339 cl_device_type type,
2340 vector<Device>* devices)
const 2343 if( devices == NULL ) {
2344 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR);
2346 cl_int err = ::clGetDeviceIDs(object_, type, 0, NULL, &n);
2347 if (err != CL_SUCCESS) {
2348 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2351 vector<cl_device_id> ids(n);
2352 err = ::clGetDeviceIDs(object_, type, n, ids.data(), NULL);
2353 if (err != CL_SUCCESS) {
2354 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2362 devices->resize(ids.size());
2366 for (size_type i = 0; i < ids.size(); i++) {
2367 (*devices)[i] =
Device(ids[i],
true);
2373 #if defined(CL_HPP_USE_DX_INTEROP) 2398 cl_d3d10_device_source_khr d3d_device_source,
2400 cl_d3d10_device_set_khr d3d_device_set,
2401 vector<Device>* devices)
const 2403 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clGetDeviceIDsFromD3D10KHR)(
2404 cl_platform_id platform,
2405 cl_d3d10_device_source_khr d3d_device_source,
2407 cl_d3d10_device_set_khr d3d_device_set,
2408 cl_uint num_entries,
2409 cl_device_id * devices,
2410 cl_uint* num_devices);
2412 if( devices == NULL ) {
2413 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR);
2416 static PFN_clGetDeviceIDsFromD3D10KHR pfn_clGetDeviceIDsFromD3D10KHR = NULL;
2417 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(object_, clGetDeviceIDsFromD3D10KHR);
2420 cl_int err = pfn_clGetDeviceIDsFromD3D10KHR(
2428 if (err != CL_SUCCESS) {
2429 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2432 vector<cl_device_id> ids(n);
2433 err = pfn_clGetDeviceIDsFromD3D10KHR(
2441 if (err != CL_SUCCESS) {
2442 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2450 devices->resize(ids.size());
2454 for (size_type i = 0; i < ids.size(); i++) {
2455 (*devices)[i] =
Device(ids[i],
true);
2467 vector<Platform>* platforms)
2471 if( platforms == NULL ) {
2472 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_PLATFORM_IDS_ERR);
2475 cl_int err = ::clGetPlatformIDs(0, NULL, &n);
2476 if (err != CL_SUCCESS) {
2477 return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
2480 vector<cl_platform_id> ids(n);
2481 err = ::clGetPlatformIDs(n, ids.data(), NULL);
2482 if (err != CL_SUCCESS) {
2483 return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
2487 platforms->resize(ids.size());
2490 for (size_type i = 0; i < ids.size(); i++) {
2491 (*platforms)[i] =
Platform(ids[i]);
2505 Platform default_platform = Platform::getDefault(&err);
2507 *platform = default_platform;
2521 cl_int * errResult = NULL)
2524 Platform default_platform = Platform::getDefault(&err);
2528 return default_platform;
2531 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 2536 return ::clUnloadPlatformCompiler(object_);
2538 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 2541 CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Platform::default_initialized_;
2542 CL_HPP_DEFINE_STATIC_MEMBER_
Platform Platform::default_;
2543 CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Platform::default_error_ = CL_SUCCESS;
2549 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 2554 inline CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_int
2559 return ::clUnloadCompiler();
2561 #endif // #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 2575 static std::once_flag default_initialized_;
2577 static cl_int default_error_;
2584 static void makeDefault() {
2588 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 2592 #if !defined(__APPLE__) && !defined(__MACOS) 2593 const Platform &p = Platform::getDefault();
2594 cl_platform_id defaultPlatform = p();
2595 cl_context_properties properties[3] = {
2596 CL_CONTEXT_PLATFORM, (cl_context_properties)defaultPlatform, 0
2598 #else // #if !defined(__APPLE__) && !defined(__MACOS) 2599 cl_context_properties *properties =
nullptr;
2600 #endif // #if !defined(__APPLE__) && !defined(__MACOS) 2603 CL_DEVICE_TYPE_DEFAULT,
2609 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 2610 catch (cl::Error &e) {
2611 default_error_ = e.err();
2622 static void makeDefaultProvided(
const Context &c) {
2627 #ifdef CL_HPP_UNIT_TEST_ENABLE 2634 static void unitTestClearDefault() {
2637 #endif // #ifdef CL_HPP_UNIT_TEST_ENABLE 2644 const vector<Device>& devices,
2645 cl_context_properties* properties = NULL,
2646 void (CL_CALLBACK * notifyFptr)(
2656 size_type numDevices = devices.size();
2657 vector<cl_device_id> deviceIDs(numDevices);
2659 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
2660 deviceIDs[deviceIndex] = (devices[deviceIndex])();
2663 object_ = ::clCreateContext(
2664 properties, (cl_uint) numDevices,
2666 notifyFptr, data, &error);
2668 detail::errHandler(error, __CREATE_CONTEXT_ERR);
2676 cl_context_properties* properties = NULL,
2677 void (CL_CALLBACK * notifyFptr)(
2687 cl_device_id deviceID = device();
2689 object_ = ::clCreateContext(
2692 notifyFptr, data, &error);
2694 detail::errHandler(error, __CREATE_CONTEXT_ERR);
2705 cl_device_type type,
2706 cl_context_properties* properties = NULL,
2707 void (CL_CALLBACK * notifyFptr)(
2717 #if !defined(__APPLE__) && !defined(__MACOS) 2718 cl_context_properties prop[4] = {CL_CONTEXT_PLATFORM, 0, 0, 0 };
2720 if (properties == NULL) {
2722 vector<Platform> platforms;
2723 error = Platform::get(&platforms);
2724 if (error != CL_SUCCESS) {
2725 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
2733 cl_context_properties platform_id = 0;
2734 for (
unsigned int i = 0; i < platforms.size(); i++) {
2736 vector<Device> devices;
2738 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 2742 error = platforms[i].getDevices(type, &devices);
2744 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 2751 if (error != CL_SUCCESS && error != CL_DEVICE_NOT_FOUND) {
2752 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
2758 if (devices.size() > 0) {
2759 platform_id = (cl_context_properties)platforms[i]();
2764 if (platform_id == 0) {
2765 detail::errHandler(CL_DEVICE_NOT_FOUND, __CREATE_CONTEXT_FROM_TYPE_ERR);
2767 *err = CL_DEVICE_NOT_FOUND;
2772 prop[1] = platform_id;
2773 properties = &prop[0];
2776 object_ = ::clCreateContextFromType(
2777 properties, type, notifyFptr, data, &error);
2779 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
2820 std::call_once(default_initialized_, makeDefault);
2821 detail::errHandler(default_error_);
2823 *err = default_error_;
2837 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_context));
2838 detail::errHandler(default_error_);
2850 explicit Context(
const cl_context& context,
bool retainObject =
false) :
2851 detail::Wrapper<cl_type>(context, retainObject) { }
2865 template <
typename T>
2866 cl_int
getInfo(cl_context_info name, T* param)
const 2868 return detail::errHandler(
2869 detail::getInfo(&::clGetContextInfo, object_, name, param),
2870 __GET_CONTEXT_INFO_ERR);
2874 template <cl_
int name>
typename 2879 detail::cl_context_info, name>::param_type param;
2880 cl_int result = getInfo(name, ¶m);
2893 cl_mem_object_type type,
2894 vector<ImageFormat>* formats)
const 2902 cl_int err = ::clGetSupportedImageFormats(
2909 if (err != CL_SUCCESS) {
2910 return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
2913 if (numEntries > 0) {
2914 vector<ImageFormat> value(numEntries);
2915 err = ::clGetSupportedImageFormats(
2920 (cl_image_format*)value.data(),
2922 if (err != CL_SUCCESS) {
2923 return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
2926 formats->assign(begin(value), end(value));
2937 inline void Device::makeDefault()
2942 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 2949 detail::errHandler(error, __CREATE_CONTEXT_ERR);
2951 if (error != CL_SUCCESS) {
2952 default_error_ = error;
2955 default_ = context.
getInfo<CL_CONTEXT_DEVICES>()[0];
2956 default_error_ = CL_SUCCESS;
2959 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 2960 catch (cl::Error &e) {
2961 default_error_ = e.err();
2966 CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Context::default_initialized_;
2967 CL_HPP_DEFINE_STATIC_MEMBER_
Context Context::default_;
2968 CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Context::default_error_ = CL_SUCCESS;
2982 Event() : detail::Wrapper<cl_type>() { }
2992 explicit Event(
const cl_event& event,
bool retainObject =
false) :
2993 detail::Wrapper<cl_type>(event, retainObject) { }
3007 template <
typename T>
3008 cl_int
getInfo(cl_event_info name, T* param)
const 3010 return detail::errHandler(
3011 detail::getInfo(&::clGetEventInfo, object_, name, param),
3012 __GET_EVENT_INFO_ERR);
3016 template <cl_
int name>
typename 3021 detail::cl_event_info, name>::param_type param;
3022 cl_int result = getInfo(name, ¶m);
3030 template <
typename T>
3033 return detail::errHandler(detail::getInfo(
3034 &::clGetEventProfilingInfo, object_, name, param),
3035 __GET_EVENT_PROFILE_INFO_ERR);
3039 template <cl_
int name>
typename 3044 detail::cl_profiling_info, name>::param_type param;
3045 cl_int result = getProfilingInfo(name, ¶m);
3058 return detail::errHandler(
3059 ::clWaitForEvents(1, &object_),
3060 __WAIT_FOR_EVENTS_ERR);
3063 #if CL_HPP_TARGET_OPENCL_VERSION >= 110 3070 void (CL_CALLBACK * pfn_notify)(cl_event, cl_int,
void *),
3071 void * user_data = NULL)
3073 return detail::errHandler(
3074 ::clSetEventCallback(
3079 __SET_EVENT_CALLBACK_ERR);
3081 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110 3090 return detail::errHandler(
3092 (cl_uint) events.size(), (events.size() > 0) ? (cl_event*)&events.front() : NULL),
3093 __WAIT_FOR_EVENTS_ERR);
3097 #if CL_HPP_TARGET_OPENCL_VERSION >= 110 3111 cl_int * err = NULL)
3114 object_ = ::clCreateUserEvent(
3118 detail::errHandler(error, __CREATE_USER_EVENT_ERR);
3133 return detail::errHandler(
3134 ::clSetUserEventStatus(object_,status),
3135 __SET_USER_EVENT_STATUS_ERR);
3138 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110 3144 inline static cl_int
3145 WaitForEvents(
const vector<Event>& events)
3147 return detail::errHandler(
3149 (cl_uint) events.size(), (events.size() > 0) ? (cl_event*)&events.front() : NULL),
3150 __WAIT_FOR_EVENTS_ERR);
3178 explicit Memory(
const cl_mem& memory,
bool retainObject) :
3179 detail::Wrapper<cl_type>(memory, retainObject) { }
3222 template <
typename T>
3225 return detail::errHandler(
3226 detail::getInfo(&::clGetMemObjectInfo, object_, name, param),
3227 __GET_MEM_OBJECT_INFO_ERR);
3231 template <cl_
int name>
typename 3236 detail::cl_mem_info, name>::param_type param;
3237 cl_int result = getInfo(name, ¶m);
3244 #if CL_HPP_TARGET_OPENCL_VERSION >= 110 3259 void (CL_CALLBACK * pfn_notify)(cl_mem,
void *),
3260 void * user_data = NULL)
3262 return detail::errHandler(
3263 ::clSetMemObjectDestructorCallback(
3267 __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR);
3269 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110 3275 template<
typename IteratorType >
3276 cl_int
copy( IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer );
3277 template<
typename IteratorType >
3278 cl_int
copy(
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator );
3279 template<
typename IteratorType >
3281 template<
typename IteratorType >
3285 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 3291 static cl_svm_mem_flags getSVMMemFlags()
3298 template<
class Trait = detail::SVMTraitNull>
3302 static cl_svm_mem_flags getSVMMemFlags()
3304 return CL_MEM_READ_WRITE |
3305 Trait::getSVMMemFlags();
3309 template<
class Trait = detail::SVMTraitNull>
3313 static cl_svm_mem_flags getSVMMemFlags()
3315 return CL_MEM_READ_ONLY |
3316 Trait::getSVMMemFlags();
3320 template<
class Trait = detail::SVMTraitNull>
3324 static cl_svm_mem_flags getSVMMemFlags()
3326 return CL_MEM_WRITE_ONLY |
3327 Trait::getSVMMemFlags();
3331 template<
class Trait = SVMTraitReadWrite<>>
3335 static cl_svm_mem_flags getSVMMemFlags()
3337 return Trait::getSVMMemFlags();
3341 template<
class Trait = SVMTraitReadWrite<>>
3345 static cl_svm_mem_flags getSVMMemFlags()
3347 return CL_MEM_SVM_FINE_GRAIN_BUFFER |
3348 Trait::getSVMMemFlags();
3352 template<
class Trait = SVMTraitReadWrite<>>
3356 static cl_svm_mem_flags getSVMMemFlags()
3359 CL_MEM_SVM_FINE_GRAIN_BUFFER |
3360 CL_MEM_SVM_ATOMICS |
3361 Trait::getSVMMemFlags();
3366 template<
typename T>
3372 const vector<Event>* events = NULL,
3373 Event* event = NULL);
3386 template<
typename T,
class SVMTrait>
3392 typedef T value_type;
3393 typedef value_type* pointer;
3394 typedef const value_type* const_pointer;
3395 typedef value_type& reference;
3396 typedef const value_type& const_reference;
3397 typedef std::size_t size_type;
3398 typedef std::ptrdiff_t difference_type;
3400 template<
typename U>
3406 template<
typename U,
typename V>
3421 context_(other.context_)
3425 template<
typename U>
3427 context_(other.context_)
3435 pointer address(reference r) CL_HPP_NOEXCEPT_
3437 return std::addressof(r);
3440 const_pointer address(const_reference r) CL_HPP_NOEXCEPT_
3442 return std::addressof(r);
3459 SVMTrait::getSVMMemFlags(),
3462 pointer retValue =
reinterpret_cast<pointer
>(
3464 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 3466 std::bad_alloc excep;
3469 #endif // #if defined(CL_HPP_ENABLE_EXCEPTIONS) 3472 if (!(SVMTrait::getSVMMemFlags() & CL_MEM_SVM_FINE_GRAIN_BUFFER)) {
3473 cl_int err =
enqueueMapSVM(retValue, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE, size*
sizeof(T));
3474 if (err != CL_SUCCESS) {
3475 std::bad_alloc excep;
3484 void deallocate(pointer p, size_type)
3486 clSVMFree(context_(), p);
3495 size_type maxSize = std::numeric_limits<size_type>::max() /
sizeof(T);
3497 for (
const Device &d : context_.
getInfo<CL_CONTEXT_DEVICES>()) {
3500 static_cast<size_type>(d.getInfo<CL_DEVICE_MAX_MEM_ALLOC_SIZE>()));
3506 template<
class U,
class... Args >
3507 void construct(U* p, Args&&... args)
3523 return (context_==rhs.context_);
3528 return !operator==(a);
3533 template<
class SVMTrait>
3536 typedef void value_type;
3537 typedef value_type* pointer;
3538 typedef const value_type* const_pointer;
3540 template<
typename U>
3546 template<
typename U,
typename V>
3550 #if !defined(CL_HPP_NO_STD_UNIQUE_PTR) 3553 template<
class Alloc>
3560 typedef typename std::allocator_traits<Alloc>::pointer pointer;
3562 Deleter(
const Alloc &alloc, size_type copies) : alloc_{ alloc }, copies_{ copies }
3566 void operator()(pointer ptr)
const {
3567 Alloc tmpAlloc{ alloc_ };
3568 std::allocator_traits<Alloc>::destroy(tmpAlloc, std::addressof(*ptr));
3569 std::allocator_traits<Alloc>::deallocate(tmpAlloc, ptr, copies_);
3580 template <
class T,
class Alloc,
class... Args>
3583 Alloc alloc(alloc_);
3584 static const size_type copies = 1;
3589 T* tmp = std::allocator_traits<Alloc>::allocate(alloc, copies);
3591 std::bad_alloc excep;
3595 std::allocator_traits<Alloc>::construct(
3597 std::addressof(*tmp),
3598 std::forward<Args>(args)...);
3602 catch (std::bad_alloc b)
3604 std::allocator_traits<Alloc>::deallocate(alloc, tmp, copies);
3609 template<
class T,
class SVMTrait,
class... Args >
3610 cl::pointer<T, detail::Deleter<SVMAllocator<T, SVMTrait>>> allocate_svm(Args... args)
3613 return cl::allocate_pointer<T>(alloc, args...);
3616 template<
class T,
class SVMTrait,
class... Args >
3617 cl::pointer<T, detail::Deleter<SVMAllocator<T, SVMTrait>>> allocate_svm(
const cl::Context &c, Args... args)
3620 return cl::allocate_pointer<T>(alloc, args...);
3622 #endif // #if !defined(CL_HPP_NO_STD_UNIQUE_PTR) 3627 template <
class T >
3633 template <
class T >
3639 template <
class T >
3642 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 3666 void* host_ptr = NULL,
3670 object_ = ::clCreateBuffer(context(), flags, size, host_ptr, &error);
3672 detail::errHandler(error, __CREATE_BUFFER_ERR);
3690 void* host_ptr = NULL,
3697 object_ = ::clCreateBuffer(context(), flags, size, host_ptr, &error);
3699 detail::errHandler(error, __CREATE_BUFFER_ERR);
3710 template<
typename IteratorType >
3712 IteratorType startIterator,
3713 IteratorType endIterator,
3715 bool useHostPtr =
false,
3718 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
3721 cl_mem_flags flags = 0;
3723 flags |= CL_MEM_READ_ONLY;
3726 flags |= CL_MEM_READ_WRITE;
3729 flags |= CL_MEM_USE_HOST_PTR;
3732 size_type size =
sizeof(DataType)*(endIterator - startIterator);
3737 object_ = ::clCreateBuffer(context(), flags, size, static_cast<DataType*>(&*startIterator), &error);
3739 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
3742 detail::errHandler(error, __CREATE_BUFFER_ERR);
3748 error =
cl::copy(startIterator, endIterator, *
this);
3749 detail::errHandler(error, __CREATE_BUFFER_ERR);
3761 template<
typename IteratorType >
3762 Buffer(
const Context &context, IteratorType startIterator, IteratorType endIterator,
3763 bool readOnly,
bool useHostPtr =
false, cl_int* err = NULL);
3769 template<
typename IteratorType >
3770 Buffer(
const CommandQueue &queue, IteratorType startIterator, IteratorType endIterator,
3771 bool readOnly,
bool useHostPtr =
false, cl_int* err = NULL);
3783 explicit Buffer(
const cl_mem& buffer,
bool retainObject =
false) :
3784 Memory(buffer, retainObject) { }
3824 #if CL_HPP_TARGET_OPENCL_VERSION >= 110 3831 cl_buffer_create_type buffer_create_type,
3832 const void * buffer_create_info,
3833 cl_int * err = NULL)
3837 result.object_ = ::clCreateSubBuffer(
3844 detail::errHandler(error, __CREATE_SUBBUFFER_ERR);
3851 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110 3854 #if defined (CL_HPP_USE_DX_INTEROP) 3863 class BufferD3D10 :
public Buffer 3876 ID3D10Buffer* bufobj,
3877 cl_int * err = NULL) : pfn_clCreateFromD3D10BufferKHR(
nullptr)
3879 typedef CL_API_ENTRY cl_mem (CL_API_CALL *PFN_clCreateFromD3D10BufferKHR)(
3880 cl_context context, cl_mem_flags flags, ID3D10Buffer* buffer,
3881 cl_int* errcode_ret);
3882 PFN_clCreateFromD3D10BufferKHR pfn_clCreateFromD3D10BufferKHR;
3883 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 3884 vector<cl_context_properties> props = context.getInfo<CL_CONTEXT_PROPERTIES>();
3885 cl_platform platform = -1;
3886 for(
int i = 0; i < props.size(); ++i ) {
3887 if( props[i] == CL_CONTEXT_PLATFORM ) {
3888 platform = props[i+1];
3891 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCreateFromD3D10BufferKHR);
3892 #elif CL_HPP_TARGET_OPENCL_VERSION >= 110 3893 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateFromD3D10BufferKHR);
3897 object_ = pfn_clCreateFromD3D10BufferKHR(
3903 detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
3910 BufferD3D10() :
Buffer() { }
3919 explicit BufferD3D10(
const cl_mem& buffer,
bool retainObject =
false) :
3920 Buffer(buffer, retainObject) { }
3926 BufferD3D10& operator = (
const cl_mem& rhs)
3935 BufferD3D10(
const BufferD3D10& buf) :
3941 BufferD3D10& operator = (
const BufferD3D10 &buf)
3950 BufferD3D10(BufferD3D10&& buf) CL_HPP_NOEXCEPT_ :
Buffer(std::move(buf)) {}
3955 BufferD3D10& operator = (BufferD3D10 &&buf)
3983 cl_int * err = NULL)
3986 object_ = ::clCreateFromGLBuffer(
3992 detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
4008 explicit BufferGL(
const cl_mem& buffer,
bool retainObject =
false) :
4009 Buffer(buffer, retainObject) { }
4051 cl_gl_object_type *type,
4052 cl_GLuint * gl_object_name)
4054 return detail::errHandler(
4055 ::clGetGLObjectInfo(object_,type,gl_object_name),
4056 __GET_GL_OBJECT_INFO_ERR);
4080 cl_int * err = NULL)
4083 object_ = ::clCreateFromGLRenderbuffer(
4089 detail::errHandler(error, __CREATE_GL_RENDER_BUFFER_ERR);
4106 Buffer(buffer, retainObject) { }
4148 cl_gl_object_type *type,
4149 cl_GLuint * gl_object_name)
4151 return detail::errHandler(
4152 ::clGetGLObjectInfo(object_,type,gl_object_name),
4153 __GET_GL_OBJECT_INFO_ERR);
4176 explicit Image(
const cl_mem& image,
bool retainObject =
false) :
4177 Memory(image, retainObject) { }
4220 template <
typename T>
4223 return detail::errHandler(
4224 detail::getInfo(&::clGetImageInfo, object_, name, param),
4225 __GET_IMAGE_INFO_ERR);
4229 template <cl_
int name>
typename 4234 detail::cl_image_info, name>::param_type param;
4235 cl_int result = getImageInfo(name, ¶m);
4243 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 4262 void* host_ptr = NULL,
4266 cl_image_desc desc =
4268 CL_MEM_OBJECT_IMAGE1D,
4270 0, 0, 0, 0, 0, 0, 0, 0
4272 object_ = ::clCreateImage(
4280 detail::errHandler(error, __CREATE_IMAGE_ERR);
4296 explicit Image1D(
const cl_mem& image1D,
bool retainObject =
false) :
4297 Image(image1D, retainObject) { }
4354 cl_image_desc desc =
4356 CL_MEM_OBJECT_IMAGE1D_BUFFER,
4358 0, 0, 0, 0, 0, 0, 0,
4361 object_ = ::clCreateImage(
4369 detail::errHandler(error, __CREATE_IMAGE_ERR);
4385 Image(image1D, retainObject) { }
4433 size_type arraySize,
4436 void* host_ptr = NULL,
4440 cl_image_desc desc =
4442 CL_MEM_OBJECT_IMAGE1D_ARRAY,
4449 object_ = ::clCreateImage(
4457 detail::errHandler(error, __CREATE_IMAGE_ERR);
4472 explicit Image1DArray(
const cl_mem& imageArray,
bool retainObject =
false) :
4473 Image(imageArray, retainObject) { }
4511 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 120 4533 size_type row_pitch = 0,
4534 void* host_ptr = NULL,
4538 bool useCreateImage;
4540 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120 4543 cl_uint version = detail::getContextPlatformVersion(context());
4544 useCreateImage = (version >= 0x10002);
4546 #elif CL_HPP_TARGET_OPENCL_VERSION >= 120 4547 useCreateImage =
true;
4549 useCreateImage =
false;
4552 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 4555 cl_image_desc desc =
4557 CL_MEM_OBJECT_IMAGE2D,
4564 object_ = ::clCreateImage(
4572 detail::errHandler(error, __CREATE_IMAGE_ERR);
4577 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 4578 #if CL_HPP_MINIMUM_OPENCL_VERSION < 120 4579 if (!useCreateImage)
4581 object_ = ::clCreateImage2D(
4582 context(), flags,&format, width, height, row_pitch, host_ptr, &error);
4584 detail::errHandler(error, __CREATE_IMAGE2D_ERR);
4589 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 120 4592 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 || defined(CL_HPP_USE_CL_IMAGE2D_FROM_BUFFER_KHR) 4601 const Buffer &sourceBuffer,
4604 size_type row_pitch = 0,
4605 cl_int* err =
nullptr)
4609 cl_image_desc desc =
4611 CL_MEM_OBJECT_IMAGE2D,
4620 object_ = ::clCreateImage(
4628 detail::errHandler(error, __CREATE_IMAGE_ERR);
4629 if (err !=
nullptr) {
4633 #endif //#if CL_HPP_TARGET_OPENCL_VERSION >= 200 || defined(CL_HPP_USE_CL_IMAGE2D_FROM_BUFFER_KHR) 4635 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 4650 cl_channel_order order,
4651 const Image &sourceImage,
4652 cl_int* err =
nullptr)
4657 size_type sourceWidth =
4659 size_type sourceHeight =
4661 size_type sourceRowPitch =
4663 cl_uint sourceNumMIPLevels =
4665 cl_uint sourceNumSamples =
4667 cl_image_format sourceFormat =
4672 sourceFormat.image_channel_order = order;
4673 cl_image_desc desc =
4675 CL_MEM_OBJECT_IMAGE2D,
4686 object_ = ::clCreateImage(
4694 detail::errHandler(error, __CREATE_IMAGE_ERR);
4695 if (err !=
nullptr) {
4699 #endif //#if CL_HPP_TARGET_OPENCL_VERSION >= 200 4711 explicit Image2D(
const cl_mem& image2D,
bool retainObject =
false) :
4712 Image(image2D, retainObject) { }
4755 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 4779 cl_int * err = NULL)
4782 object_ = ::clCreateFromGLTexture2D(
4790 detail::errHandler(error, __CREATE_GL_TEXTURE_2D_ERR);
4807 explicit Image2DGL(
const cl_mem& image,
bool retainObject =
false) :
4808 Image2D(image, retainObject) { }
4848 } CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
4849 #endif // CL_USE_DEPRECATED_OPENCL_1_1_APIS 4851 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 4862 size_type arraySize,
4866 size_type slicePitch,
4867 void* host_ptr = NULL,
4871 cl_image_desc desc =
4873 CL_MEM_OBJECT_IMAGE2D_ARRAY,
4882 object_ = ::clCreateImage(
4890 detail::errHandler(error, __CREATE_IMAGE_ERR);
4905 explicit Image2DArray(
const cl_mem& imageArray,
bool retainObject =
false) :
Image(imageArray, retainObject) { }
4941 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 120 4963 size_type row_pitch = 0,
4964 size_type slice_pitch = 0,
4965 void* host_ptr = NULL,
4969 bool useCreateImage;
4971 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120 4974 cl_uint version = detail::getContextPlatformVersion(context());
4975 useCreateImage = (version >= 0x10002);
4977 #elif CL_HPP_TARGET_OPENCL_VERSION >= 120 4978 useCreateImage =
true;
4980 useCreateImage =
false;
4983 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 4986 cl_image_desc desc =
4988 CL_MEM_OBJECT_IMAGE3D,
4997 object_ = ::clCreateImage(
5005 detail::errHandler(error, __CREATE_IMAGE_ERR);
5010 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 5011 #if CL_HPP_MINIMUM_OPENCL_VERSION < 120 5012 if (!useCreateImage)
5014 object_ = ::clCreateImage3D(
5015 context(), flags, &format, width, height, depth, row_pitch,
5016 slice_pitch, host_ptr, &error);
5018 detail::errHandler(error, __CREATE_IMAGE3D_ERR);
5023 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 120 5036 explicit Image3D(
const cl_mem& image3D,
bool retainObject =
false) :
5037 Image(image3D, retainObject) { }
5078 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 5101 cl_int * err = NULL)
5104 object_ = ::clCreateFromGLTexture3D(
5112 detail::errHandler(error, __CREATE_GL_TEXTURE_3D_ERR);
5128 explicit Image3DGL(
const cl_mem& image,
bool retainObject =
false) :
5129 Image3D(image, retainObject) { }
5169 #endif // CL_USE_DEPRECATED_OPENCL_1_1_APIS 5171 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 5187 cl_int * err = NULL)
5190 object_ = ::clCreateFromGLTexture(
5198 detail::errHandler(error, __CREATE_GL_TEXTURE_ERR);
5213 explicit ImageGL(
const cl_mem& image,
bool retainObject =
false) :
5214 Image(image, retainObject) { }
5216 ImageGL& operator = (
const cl_mem& rhs)
5250 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 5254 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 5276 cl_uint packet_size,
5277 cl_uint max_packets,
5282 cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS;
5283 object_ = ::clCreatePipe(context(), flags, packet_size, max_packets,
nullptr, &error);
5285 detail::errHandler(error, __CREATE_PIPE_ERR);
5300 cl_uint packet_size,
5301 cl_uint max_packets,
5308 cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS;
5309 object_ = ::clCreatePipe(context(), flags, packet_size, max_packets,
nullptr, &error);
5311 detail::errHandler(error, __CREATE_PIPE_ERR);
5327 explicit Pipe(
const cl_mem& pipe,
bool retainObject =
false) :
5328 Memory(pipe, retainObject) { }
5334 Pipe& operator = (
const cl_mem& rhs)
5369 template <
typename T>
5372 return detail::errHandler(
5373 detail::getInfo(&::clGetPipeInfo, object_, name, param),
5374 __GET_PIPE_INFO_ERR);
5378 template <cl_
int name>
typename 5383 detail::cl_pipe_info, name>::param_type param;
5384 cl_int result = getInfo(name, ¶m);
5391 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200 5414 cl_bool normalized_coords,
5415 cl_addressing_mode addressing_mode,
5416 cl_filter_mode filter_mode,
5421 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 5422 cl_sampler_properties sampler_properties[] = {
5423 CL_SAMPLER_NORMALIZED_COORDS, normalized_coords,
5424 CL_SAMPLER_ADDRESSING_MODE, addressing_mode,
5425 CL_SAMPLER_FILTER_MODE, filter_mode,
5427 object_ = ::clCreateSamplerWithProperties(
5432 detail::errHandler(error, __CREATE_SAMPLER_WITH_PROPERTIES_ERR);
5437 object_ = ::clCreateSampler(
5444 detail::errHandler(error, __CREATE_SAMPLER_ERR);
5459 explicit Sampler(
const cl_sampler& sampler,
bool retainObject =
false) :
5460 detail::Wrapper<cl_type>(sampler, retainObject) { }
5502 template <
typename T>
5503 cl_int
getInfo(cl_sampler_info name, T* param)
const 5505 return detail::errHandler(
5506 detail::getInfo(&::clGetSamplerInfo, object_, name, param),
5507 __GET_SAMPLER_INFO_ERR);
5511 template <cl_
int name>
typename 5516 detail::cl_sampler_info, name>::param_type param;
5517 cl_int result = getInfo(name, ¶m);
5534 size_type sizes_[3];
5535 cl_uint dimensions_;
5566 NDRange(size_type size0, size_type size1, size_type size2)
5578 operator const size_type*()
const {
5592 return dimensions_*
sizeof(size_type);
5600 const size_type*
get()
const 5607 static const NDRange NullRange;
5617 template <
typename T,
class Enable =
void>
5622 template <
typename T>
5625 static size_type size(
const T&) {
return sizeof(T); }
5626 static const T* ptr(
const T& value) {
return &value; }
5631 template <
typename T>
5634 static size_type size(
const T&) {
return sizeof(cl_mem); }
5635 static const cl_mem* ptr(
const T& value) {
return &(value()); }
5643 static size_type size(
const LocalSpaceArg& value) {
return value.size_; }
5644 static const void* ptr(
const LocalSpaceArg&) {
return NULL; }
5671 inline Kernel(
const Program& program,
const char* name, cl_int* err = NULL);
5684 explicit Kernel(
const cl_kernel& kernel,
bool retainObject =
false) :
5685 detail::Wrapper<cl_type>(kernel, retainObject) { }
5726 template <
typename T>
5727 cl_int getInfo(cl_kernel_info name, T* param)
const 5729 return detail::errHandler(
5730 detail::getInfo(&::clGetKernelInfo, object_, name, param),
5731 __GET_KERNEL_INFO_ERR);
5734 template <cl_
int name>
typename 5736 getInfo(cl_int* err = NULL)
const 5739 detail::cl_kernel_info, name>::param_type param;
5740 cl_int result = getInfo(name, ¶m);
5747 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 5748 template <
typename T>
5749 cl_int getArgInfo(cl_uint argIndex, cl_kernel_arg_info name, T* param)
const 5751 return detail::errHandler(
5752 detail::getInfo(&::clGetKernelArgInfo, object_, argIndex, name, param),
5753 __GET_KERNEL_ARG_INFO_ERR);
5756 template <cl_
int name>
typename 5758 getArgInfo(cl_uint argIndex, cl_int* err = NULL)
const 5761 detail::cl_kernel_arg_info, name>::param_type param;
5762 cl_int result = getArgInfo(argIndex, name, ¶m);
5768 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 5770 template <
typename T>
5771 cl_int getWorkGroupInfo(
5772 const Device& device, cl_kernel_work_group_info name, T* param)
const 5774 return detail::errHandler(
5776 &::clGetKernelWorkGroupInfo, object_, device(), name, param),
5777 __GET_KERNEL_WORK_GROUP_INFO_ERR);
5780 template <cl_
int name>
typename 5782 getWorkGroupInfo(
const Device& device, cl_int* err = NULL)
const 5785 detail::cl_kernel_work_group_info, name>::param_type param;
5786 cl_int result = getWorkGroupInfo(device, name, ¶m);
5793 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 5794 #if defined(CL_HPP_USE_CL_SUB_GROUPS_KHR) 5795 cl_int getSubGroupInfo(
const cl::Device &dev, cl_kernel_sub_group_info name,
const cl::NDRange &range, size_type* param)
const 5797 typedef clGetKernelSubGroupInfoKHR_fn PFN_clGetKernelSubGroupInfoKHR;
5798 static PFN_clGetKernelSubGroupInfoKHR pfn_clGetKernelSubGroupInfoKHR = NULL;
5799 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetKernelSubGroupInfoKHR);
5801 return detail::errHandler(
5802 pfn_clGetKernelSubGroupInfoKHR(object_, dev(), name, range.
size(), range.get(),
sizeof(size_type), param,
nullptr),
5803 __GET_KERNEL_ARG_INFO_ERR);
5806 template <cl_
int name>
5807 size_type getSubGroupInfo(
const cl::Device &dev,
const cl::NDRange &range, cl_int* err = NULL)
const 5810 cl_int result = getSubGroupInfo(dev, name, range, ¶m);
5816 #endif // #if defined(CL_HPP_USE_CL_SUB_GROUPS_KHR) 5817 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 5819 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 5822 template<
typename T,
class D>
5823 cl_int
setArg(cl_uint index,
const cl::pointer<T, D> &argPtr)
5825 return detail::errHandler(
5826 ::clSetKernelArgSVMPointer(object_, index, argPtr.get()),
5827 __SET_KERNEL_ARGS_ERR);
5832 template<
typename T,
class Alloc>
5833 cl_int
setArg(cl_uint index,
const cl::vector<T, Alloc> &argPtr)
5835 return detail::errHandler(
5836 ::clSetKernelArgSVMPointer(object_, index, argPtr.data()),
5837 __SET_KERNEL_ARGS_ERR);
5842 template<
typename T>
5843 typename std::enable_if<std::is_pointer<T>::value, cl_int>::type
5846 return detail::errHandler(
5847 ::clSetKernelArgSVMPointer(object_, index, argPtr),
5848 __SET_KERNEL_ARGS_ERR);
5850 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 5854 template <
typename T>
5855 typename std::enable_if<!std::is_pointer<T>::value, cl_int>::type
5858 return detail::errHandler(
5864 __SET_KERNEL_ARGS_ERR);
5867 cl_int setArg(cl_uint index, size_type size,
const void* argPtr)
5869 return detail::errHandler(
5870 ::clSetKernelArg(object_, index, size, argPtr),
5871 __SET_KERNEL_ARGS_ERR);
5874 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 5881 return detail::errHandler(
5882 ::clSetKernelExecInfo(
5884 CL_KERNEL_EXEC_INFO_SVM_PTRS,
5885 sizeof(
void*)*pointerList.size(),
5886 pointerList.data()));
5893 template<
int ArrayLength>
5896 return detail::errHandler(
5897 ::clSetKernelExecInfo(
5899 CL_KERNEL_EXEC_INFO_SVM_PTRS,
5900 sizeof(
void*)*pointerList.size(),
5901 pointerList.data()));
5917 cl_bool svmEnabled_ = svmEnabled ? CL_TRUE : CL_FALSE;
5918 return detail::errHandler(
5919 ::clSetKernelExecInfo(
5921 CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM,
5928 template<
int index,
int ArrayLength,
class D,
typename T0,
typename T1,
typename... Ts>
5929 void setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList,
const pointer<T0, D> &t0,
const pointer<T1, D> &t1, Ts & ... ts)
5931 pointerList[index] =
static_cast<void*
>(t0.get());
5932 setSVMPointersHelper<index + 1, ArrayLength>(pointerList, t1, ts...);
5935 template<
int index,
int ArrayLength,
typename T0,
typename T1,
typename... Ts>
5936 typename std::enable_if<std::is_pointer<T0>::value,
void>::type
5937 setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList, T0 t0, T1 t1, Ts... ts)
5939 pointerList[index] =
static_cast<void*
>(t0);
5940 setSVMPointersHelper<index + 1, ArrayLength>(pointerList, t1, ts...);
5943 template<
int index,
int ArrayLength,
typename T0,
class D>
5944 void setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList,
const pointer<T0, D> &t0)
5946 pointerList[index] =
static_cast<void*
>(t0.get());
5950 template<
int index,
int ArrayLength,
typename T0>
5951 typename std::enable_if<std::is_pointer<T0>::value,
void>::type
5952 setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList, T0 t0)
5954 pointerList[index] =
static_cast<void*
>(t0);
5957 template<
typename T0,
typename... Ts>
5958 cl_int setSVMPointers(
const T0 &t0, Ts & ... ts)
5960 std::array<
void*, 1 +
sizeof...(Ts)> pointerList;
5962 setSVMPointersHelper<0, 1 +
sizeof...(Ts)>(pointerList, t0, ts...);
5963 return detail::errHandler(
5964 ::clSetKernelExecInfo(
5966 CL_KERNEL_EXEC_INFO_SVM_PTRS,
5967 sizeof(
void*)*(1 +
sizeof...(Ts)),
5968 pointerList.data()));
5970 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 5979 #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 5980 typedef vector<vector<unsigned char>> Binaries;
5981 typedef vector<string> Sources;
5982 #else // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 5983 typedef vector<std::pair<const void*, size_type> > Binaries;
5984 typedef vector<std::pair<const char*, size_type> > Sources;
5985 #endif // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 5988 const string& source,
5994 const char * strings = source.c_str();
5995 const size_type length = source.size();
5999 object_ = ::clCreateProgramWithSource(
6000 context(), (cl_uint)1, &strings, &length, &error);
6002 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6004 if (error == CL_SUCCESS && build) {
6006 error = ::clBuildProgram(
6010 #
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6018 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6028 const string& source,
6034 const char * strings = source.c_str();
6035 const size_type length = source.size();
6037 object_ = ::clCreateProgramWithSource(
6038 context(), (cl_uint)1, &strings, &length, &error);
6040 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6042 if (error == CL_SUCCESS && build) {
6043 error = ::clBuildProgram(
6047 #
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6055 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6068 const Sources& sources,
6074 const size_type n = (size_type)sources.size();
6076 vector<size_type> lengths(n);
6077 vector<const char*> strings(n);
6079 for (size_type i = 0; i < n; ++i) {
6080 #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 6081 strings[i] = sources[(int)i].data();
6082 lengths[i] = sources[(int)i].length();
6083 #else // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 6084 strings[i] = sources[(int)i].first;
6085 lengths[i] = sources[(int)i].second;
6086 #endif // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 6089 object_ = ::clCreateProgramWithSource(
6090 context(), (cl_uint)n, strings.data(), lengths.data(), &error);
6092 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6104 const Sources& sources,
6109 const size_type n = (size_type)sources.size();
6111 vector<size_type> lengths(n);
6112 vector<const char*> strings(n);
6114 for (size_type i = 0; i < n; ++i) {
6115 #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 6116 strings[i] = sources[(int)i].data();
6117 lengths[i] = sources[(int)i].length();
6118 #else // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 6119 strings[i] = sources[(int)i].first;
6120 lengths[i] = sources[(int)i].second;
6121 #endif // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 6124 object_ = ::clCreateProgramWithSource(
6125 context(), (cl_uint)n, strings.data(), lengths.data(), &error);
6127 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6154 const vector<Device>& devices,
6155 const Binaries& binaries,
6156 vector<cl_int>* binaryStatus = NULL,
6161 const size_type numDevices = devices.size();
6164 if(binaries.size() != numDevices) {
6165 error = CL_INVALID_VALUE;
6166 detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
6174 vector<size_type> lengths(numDevices);
6175 vector<const unsigned char*> images(numDevices);
6176 #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 6177 for (size_type i = 0; i < numDevices; ++i) {
6178 images[i] = binaries[i].data();
6179 lengths[i] = binaries[(int)i].size();
6181 #else // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 6182 for (size_type i = 0; i < numDevices; ++i) {
6183 images[i] = (
const unsigned char*)binaries[i].first;
6184 lengths[i] = binaries[(int)i].second;
6186 #endif // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 6188 vector<cl_device_id> deviceIDs(numDevices);
6189 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6190 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6194 binaryStatus->resize(numDevices);
6197 object_ = ::clCreateProgramWithBinary(
6198 context(), (cl_uint) devices.size(),
6200 lengths.data(), images.data(), (binaryStatus != NULL && numDevices > 0)
6201 ? &binaryStatus->front()
6204 detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
6211 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 6218 const vector<Device>& devices,
6219 const string& kernelNames,
6225 size_type numDevices = devices.size();
6226 vector<cl_device_id> deviceIDs(numDevices);
6227 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6228 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6231 object_ = ::clCreateProgramWithBuiltInKernels(
6233 (cl_uint) devices.size(),
6235 kernelNames.c_str(),
6238 detail::errHandler(error, __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR);
6243 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 6254 explicit Program(
const cl_program& program,
bool retainObject =
false) :
6255 detail::Wrapper<cl_type>(program, retainObject) { }
6257 Program& operator = (
const cl_program& rhs)
6292 const vector<Device>& devices,
6293 const char* options = NULL,
6294 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6295 void* data = NULL)
const 6297 size_type numDevices = devices.size();
6298 vector<cl_device_id> deviceIDs(numDevices);
6300 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6301 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6304 cl_int buildError = ::clBuildProgram(
6313 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6317 const char* options = NULL,
6318 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6319 void* data = NULL)
const 6321 cl_int buildError = ::clBuildProgram(
6330 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6333 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 6335 const char* options = NULL,
6336 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6337 void* data = NULL)
const 6339 cl_int error = ::clCompileProgram(
6349 return detail::buildErrHandler(error, __COMPILE_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6351 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 6353 template <
typename T>
6354 cl_int getInfo(cl_program_info name, T* param)
const 6356 return detail::errHandler(
6357 detail::getInfo(&::clGetProgramInfo, object_, name, param),
6358 __GET_PROGRAM_INFO_ERR);
6361 template <cl_
int name>
typename 6363 getInfo(cl_int* err = NULL)
const 6366 detail::cl_program_info, name>::param_type param;
6367 cl_int result = getInfo(name, ¶m);
6374 template <
typename T>
6375 cl_int getBuildInfo(
6376 const Device& device, cl_program_build_info name, T* param)
const 6378 return detail::errHandler(
6380 &::clGetProgramBuildInfo, object_, device(), name, param),
6381 __GET_PROGRAM_BUILD_INFO_ERR);
6384 template <cl_
int name>
typename 6386 getBuildInfo(
const Device& device, cl_int* err = NULL)
const 6389 detail::cl_program_build_info, name>::param_type param;
6390 cl_int result = getBuildInfo(device, name, ¶m);
6402 template <cl_
int name>
6403 vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, name>::param_type>>
6406 cl_int result = CL_SUCCESS;
6408 auto devs = getInfo<CL_PROGRAM_DEVICES>(&result);
6409 vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, name>::param_type>>
6413 if (result != CL_SUCCESS) {
6422 detail::cl_program_build_info, name>::param_type param;
6423 result = getBuildInfo(d, name, ¶m);
6427 if (result != CL_SUCCESS) {
6435 if (result != CL_SUCCESS) {
6441 cl_int createKernels(vector<Kernel>* kernels)
6444 cl_int err = ::clCreateKernelsInProgram(object_, 0, NULL, &numKernels);
6445 if (err != CL_SUCCESS) {
6446 return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
6449 vector<cl_kernel> value(numKernels);
6451 err = ::clCreateKernelsInProgram(
6452 object_, numKernels, value.data(), NULL);
6453 if (err != CL_SUCCESS) {
6454 return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
6458 kernels->resize(value.size());
6462 for (size_type i = 0; i < value.size(); i++) {
6465 (*kernels)[i] =
Kernel(value[i],
false);
6472 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 6476 const char* options = NULL,
6477 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6481 cl_int error_local = CL_SUCCESS;
6483 cl_program programs[2] = { input1(), input2() };
6485 Context ctx = input1.getInfo<CL_PROGRAM_CONTEXT>(&error_local);
6486 if(error_local!=CL_SUCCESS) {
6487 detail::errHandler(error_local, __LINK_PROGRAM_ERR);
6490 cl_program prog = ::clLinkProgram(
6501 detail::errHandler(error_local,__COMPILE_PROGRAM_ERR);
6510 vector<Program> inputPrograms,
6511 const char* options = NULL,
6512 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6516 cl_int error_local = CL_SUCCESS;
6518 vector<cl_program> programs(inputPrograms.size());
6520 for (
unsigned int i = 0; i < inputPrograms.size(); i++) {
6521 programs[i] = inputPrograms[i]();
6525 if(inputPrograms.size() > 0) {
6526 ctx = inputPrograms[0].
getInfo<CL_PROGRAM_CONTEXT>(&error_local);
6527 if(error_local!=CL_SUCCESS) {
6528 detail::errHandler(error_local, __LINK_PROGRAM_ERR);
6531 cl_program prog = ::clLinkProgram(
6536 (cl_uint)inputPrograms.size(),
6542 detail::errHandler(error_local,__COMPILE_PROGRAM_ERR);
6549 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 6553 inline cl_int cl::Program::getInfo(cl_program_info name, vector<vector<unsigned char>>* param)
const 6555 if (name != CL_PROGRAM_BINARIES) {
6556 return CL_INVALID_VALUE;
6562 vector<size_type> sizes = getInfo<CL_PROGRAM_BINARY_SIZES>();
6563 size_type numBinaries = sizes.size();
6566 param->resize(numBinaries);
6567 for (size_type i = 0; i < numBinaries; ++i) {
6568 (*param)[i].resize(sizes[i]);
6571 return detail::errHandler(
6572 detail::getInfo(&::clGetProgramInfo, object_, name, param),
6573 __GET_PROGRAM_INFO_ERR);
6580 inline vector<vector<unsigned char>> cl::Program::getInfo<CL_PROGRAM_BINARIES>(cl_int* err)
const 6582 vector<vector<unsigned char>> binariesVectors;
6584 cl_int result = getInfo(CL_PROGRAM_BINARIES, &binariesVectors);
6588 return binariesVectors;
6595 object_ = ::clCreateKernel(program(), name, &error);
6596 detail::errHandler(error, __CREATE_KERNEL_ERR);
6604 enum class QueueProperties : cl_command_queue_properties
6607 Profiling = CL_QUEUE_PROFILING_ENABLE,
6608 OutOfOrder = CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE,
6611 inline QueueProperties operator|(QueueProperties lhs, QueueProperties rhs)
6613 return static_cast<QueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) | static_cast<cl_command_queue_properties>(rhs));
6622 static std::once_flag default_initialized_;
6624 static cl_int default_error_;
6631 static void makeDefault()
6636 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 6643 if (error != CL_SUCCESS) {
6644 default_error_ = error;
6648 default_ =
CommandQueue(context, device, 0, &default_error_);
6651 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 6652 catch (cl::Error &e) {
6653 default_error_ = e.err();
6663 static void makeDefaultProvided(
const CommandQueue &c) {
6668 #ifdef CL_HPP_UNIT_TEST_ENABLE 6675 static void unitTestClearDefault() {
6678 #endif // #ifdef CL_HPP_UNIT_TEST_ENABLE 6686 cl_command_queue_properties properties,
6692 detail::errHandler(error, __CREATE_CONTEXT_ERR);
6694 if (error != CL_SUCCESS) {
6701 bool useWithProperties;
6703 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 6706 cl_uint version = detail::getContextPlatformVersion(context());
6707 useWithProperties = (version >= 0x20000);
6709 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200 6710 useWithProperties =
true;
6712 useWithProperties =
false;
6715 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 6716 if (useWithProperties) {
6717 cl_queue_properties queue_properties[] = {
6718 CL_QUEUE_PROPERTIES, properties, 0 };
6719 if ((properties & CL_QUEUE_ON_DEVICE) == 0) {
6720 object_ = ::clCreateCommandQueueWithProperties(
6721 context(), device(), queue_properties, &error);
6724 error = CL_INVALID_QUEUE_PROPERTIES;
6727 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
6732 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200 6733 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200 6734 if (!useWithProperties) {
6735 object_ = ::clCreateCommandQueue(
6736 context(), device(), properties, &error);
6738 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
6743 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 200 6752 QueueProperties properties,
6758 detail::errHandler(error, __CREATE_CONTEXT_ERR);
6760 if (error != CL_SUCCESS) {
6767 bool useWithProperties;
6769 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 6772 cl_uint version = detail::getContextPlatformVersion(context());
6773 useWithProperties = (version >= 0x20000);
6775 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200 6776 useWithProperties =
true;
6778 useWithProperties =
false;
6781 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 6782 if (useWithProperties) {
6783 cl_queue_properties queue_properties[] = {
6784 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
6786 object_ = ::clCreateCommandQueueWithProperties(
6787 context(), device(), queue_properties, &error);
6789 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
6794 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200 6795 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200 6796 if (!useWithProperties) {
6797 object_ = ::clCreateCommandQueue(
6798 context(), device(), static_cast<cl_command_queue_properties>(properties), &error);
6800 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
6805 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 200 6816 cl_command_queue_properties properties = 0,
6820 bool useWithProperties;
6821 vector<cl::Device> devices;
6822 error = context.
getInfo(CL_CONTEXT_DEVICES, &devices);
6824 detail::errHandler(error, __CREATE_CONTEXT_ERR);
6826 if (error != CL_SUCCESS)
6834 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 6837 cl_uint version = detail::getContextPlatformVersion(context());
6838 useWithProperties = (version >= 0x20000);
6840 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200 6841 useWithProperties =
true;
6843 useWithProperties =
false;
6846 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 6847 if (useWithProperties) {
6848 cl_queue_properties queue_properties[] = {
6849 CL_QUEUE_PROPERTIES, properties, 0 };
6850 if ((properties & CL_QUEUE_ON_DEVICE) == 0) {
6851 object_ = ::clCreateCommandQueueWithProperties(
6852 context(), devices[0](), queue_properties, &error);
6855 error = CL_INVALID_QUEUE_PROPERTIES;
6858 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
6863 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200 6864 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200 6865 if (!useWithProperties) {
6866 object_ = ::clCreateCommandQueue(
6867 context(), devices[0](), properties, &error);
6869 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
6874 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 200 6883 QueueProperties properties,
6887 bool useWithProperties;
6888 vector<cl::Device> devices;
6889 error = context.
getInfo(CL_CONTEXT_DEVICES, &devices);
6891 detail::errHandler(error, __CREATE_CONTEXT_ERR);
6893 if (error != CL_SUCCESS)
6901 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 6904 cl_uint version = detail::getContextPlatformVersion(context());
6905 useWithProperties = (version >= 0x20000);
6907 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200 6908 useWithProperties =
true;
6910 useWithProperties =
false;
6913 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 6914 if (useWithProperties) {
6915 cl_queue_properties queue_properties[] = {
6916 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
6917 object_ = ::clCreateCommandQueueWithProperties(
6918 context(), devices[0](), queue_properties, &error);
6920 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
6925 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200 6926 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200 6927 if (!useWithProperties) {
6928 object_ = ::clCreateCommandQueue(
6929 context(), devices[0](), static_cast<cl_command_queue_properties>(properties), &error);
6931 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
6936 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 200 6946 cl_command_queue_properties properties = 0,
6950 bool useWithProperties;
6952 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 6955 cl_uint version = detail::getContextPlatformVersion(context());
6956 useWithProperties = (version >= 0x20000);
6958 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200 6959 useWithProperties =
true;
6961 useWithProperties =
false;
6964 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 6965 if (useWithProperties) {
6966 cl_queue_properties queue_properties[] = {
6967 CL_QUEUE_PROPERTIES, properties, 0 };
6968 object_ = ::clCreateCommandQueueWithProperties(
6969 context(), device(), queue_properties, &error);
6971 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
6976 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200 6977 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200 6978 if (!useWithProperties) {
6979 object_ = ::clCreateCommandQueue(
6980 context(), device(), properties, &error);
6982 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
6987 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 200 6997 QueueProperties properties,
7001 bool useWithProperties;
7003 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 7006 cl_uint version = detail::getContextPlatformVersion(context());
7007 useWithProperties = (version >= 0x20000);
7009 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200 7010 useWithProperties =
true;
7012 useWithProperties =
false;
7015 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 7016 if (useWithProperties) {
7017 cl_queue_properties queue_properties[] = {
7018 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
7019 object_ = ::clCreateCommandQueueWithProperties(
7020 context(), device(), queue_properties, &error);
7022 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7027 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200 7028 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200 7029 if (!useWithProperties) {
7030 object_ = ::clCreateCommandQueue(
7031 context(), device(), static_cast<cl_command_queue_properties>(properties), &error);
7033 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7038 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 200 7043 std::call_once(default_initialized_, makeDefault);
7044 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 7045 detail::errHandler(default_error_, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7046 #else // CL_HPP_TARGET_OPENCL_VERSION >= 200 7047 detail::errHandler(default_error_, __CREATE_COMMAND_QUEUE_ERR);
7048 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200 7050 *err = default_error_;
7064 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_queue));
7065 detail::errHandler(default_error_);
7078 explicit CommandQueue(
const cl_command_queue& commandQueue,
bool retainObject =
false) :
7079 detail::Wrapper<cl_type>(commandQueue, retainObject) { }
7115 template <
typename T>
7116 cl_int getInfo(cl_command_queue_info name, T* param)
const 7118 return detail::errHandler(
7120 &::clGetCommandQueueInfo, object_, name, param),
7121 __GET_COMMAND_QUEUE_INFO_ERR);
7124 template <cl_
int name>
typename 7126 getInfo(cl_int* err = NULL)
const 7129 detail::cl_command_queue_info, name>::param_type param;
7130 cl_int result = getInfo(name, ¶m);
7137 cl_int enqueueReadBuffer(
7143 const vector<Event>* events = NULL,
7144 Event* event = NULL)
const 7147 cl_int err = detail::errHandler(
7148 ::clEnqueueReadBuffer(
7149 object_, buffer(), blocking, offset, size,
7151 (events != NULL) ? (cl_uint) events->size() : 0,
7152 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7153 (
event != NULL) ? &tmp : NULL),
7154 __ENQUEUE_READ_BUFFER_ERR);
7156 if (event != NULL && err == CL_SUCCESS)
7162 cl_int enqueueWriteBuffer(
7168 const vector<Event>* events = NULL,
7169 Event* event = NULL)
const 7172 cl_int err = detail::errHandler(
7173 ::clEnqueueWriteBuffer(
7174 object_, buffer(), blocking, offset, size,
7176 (events != NULL) ? (cl_uint) events->size() : 0,
7177 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7178 (
event != NULL) ? &tmp : NULL),
7179 __ENQUEUE_WRITE_BUFFER_ERR);
7181 if (event != NULL && err == CL_SUCCESS)
7187 cl_int enqueueCopyBuffer(
7190 size_type src_offset,
7191 size_type dst_offset,
7193 const vector<Event>* events = NULL,
7194 Event* event = NULL)
const 7197 cl_int err = detail::errHandler(
7198 ::clEnqueueCopyBuffer(
7199 object_, src(), dst(), src_offset, dst_offset, size,
7200 (events != NULL) ? (cl_uint) events->size() : 0,
7201 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7202 (
event != NULL) ? &tmp : NULL),
7203 __ENQEUE_COPY_BUFFER_ERR);
7205 if (event != NULL && err == CL_SUCCESS)
7211 cl_int enqueueReadBufferRect(
7214 const array<size_type, 3>& buffer_offset,
7215 const array<size_type, 3>& host_offset,
7216 const array<size_type, 3>& region,
7217 size_type buffer_row_pitch,
7218 size_type buffer_slice_pitch,
7219 size_type host_row_pitch,
7220 size_type host_slice_pitch,
7222 const vector<Event>* events = NULL,
7223 Event* event = NULL)
const 7226 cl_int err = detail::errHandler(
7227 ::clEnqueueReadBufferRect(
7231 buffer_offset.data(),
7239 (events != NULL) ? (cl_uint) events->size() : 0,
7240 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7241 (
event != NULL) ? &tmp : NULL),
7242 __ENQUEUE_READ_BUFFER_RECT_ERR);
7244 if (event != NULL && err == CL_SUCCESS)
7250 cl_int enqueueWriteBufferRect(
7253 const array<size_type, 3>& buffer_offset,
7254 const array<size_type, 3>& host_offset,
7255 const array<size_type, 3>& region,
7256 size_type buffer_row_pitch,
7257 size_type buffer_slice_pitch,
7258 size_type host_row_pitch,
7259 size_type host_slice_pitch,
7261 const vector<Event>* events = NULL,
7262 Event* event = NULL)
const 7265 cl_int err = detail::errHandler(
7266 ::clEnqueueWriteBufferRect(
7270 buffer_offset.data(),
7278 (events != NULL) ? (cl_uint) events->size() : 0,
7279 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7280 (
event != NULL) ? &tmp : NULL),
7281 __ENQUEUE_WRITE_BUFFER_RECT_ERR);
7283 if (event != NULL && err == CL_SUCCESS)
7289 cl_int enqueueCopyBufferRect(
7292 const array<size_type, 3>& src_origin,
7293 const array<size_type, 3>& dst_origin,
7294 const array<size_type, 3>& region,
7295 size_type src_row_pitch,
7296 size_type src_slice_pitch,
7297 size_type dst_row_pitch,
7298 size_type dst_slice_pitch,
7299 const vector<Event>* events = NULL,
7300 Event* event = NULL)
const 7303 cl_int err = detail::errHandler(
7304 ::clEnqueueCopyBufferRect(
7315 (events != NULL) ? (cl_uint) events->size() : 0,
7316 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7317 (
event != NULL) ? &tmp : NULL),
7318 __ENQEUE_COPY_BUFFER_RECT_ERR);
7320 if (event != NULL && err == CL_SUCCESS)
7326 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 7338 template<
typename PatternType>
7341 PatternType pattern,
7344 const vector<Event>* events = NULL,
7345 Event* event = NULL)
const 7348 cl_int err = detail::errHandler(
7349 ::clEnqueueFillBuffer(
7352 static_cast<void*>(&pattern),
7353 sizeof(PatternType),
7356 (events != NULL) ? (cl_uint) events->size() : 0,
7357 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7358 (
event != NULL) ? &tmp : NULL),
7359 __ENQUEUE_FILL_BUFFER_ERR);
7361 if (event != NULL && err == CL_SUCCESS)
7366 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 7368 cl_int enqueueReadImage(
7371 const array<size_type, 3>& origin,
7372 const array<size_type, 3>& region,
7373 size_type row_pitch,
7374 size_type slice_pitch,
7376 const vector<Event>* events = NULL,
7377 Event* event = NULL)
const 7380 cl_int err = detail::errHandler(
7381 ::clEnqueueReadImage(
7390 (events != NULL) ? (cl_uint) events->size() : 0,
7391 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7392 (
event != NULL) ? &tmp : NULL),
7393 __ENQUEUE_READ_IMAGE_ERR);
7395 if (event != NULL && err == CL_SUCCESS)
7401 cl_int enqueueWriteImage(
7404 const array<size_type, 3>& origin,
7405 const array<size_type, 3>& region,
7406 size_type row_pitch,
7407 size_type slice_pitch,
7409 const vector<Event>* events = NULL,
7410 Event* event = NULL)
const 7413 cl_int err = detail::errHandler(
7414 ::clEnqueueWriteImage(
7423 (events != NULL) ? (cl_uint) events->size() : 0,
7424 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7425 (
event != NULL) ? &tmp : NULL),
7426 __ENQUEUE_WRITE_IMAGE_ERR);
7428 if (event != NULL && err == CL_SUCCESS)
7434 cl_int enqueueCopyImage(
7437 const array<size_type, 3>& src_origin,
7438 const array<size_type, 3>& dst_origin,
7439 const array<size_type, 3>& region,
7440 const vector<Event>* events = NULL,
7441 Event* event = NULL)
const 7444 cl_int err = detail::errHandler(
7445 ::clEnqueueCopyImage(
7452 (events != NULL) ? (cl_uint) events->size() : 0,
7453 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7454 (
event != NULL) ? &tmp : NULL),
7455 __ENQUEUE_COPY_IMAGE_ERR);
7457 if (event != NULL && err == CL_SUCCESS)
7463 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 7473 cl_float4 fillColor,
7474 const array<size_type, 3>& origin,
7475 const array<size_type, 3>& region,
7476 const vector<Event>* events = NULL,
7477 Event* event = NULL)
const 7480 cl_int err = detail::errHandler(
7481 ::clEnqueueFillImage(
7484 static_cast<void*>(&fillColor),
7487 (events != NULL) ? (cl_uint) events->size() : 0,
7488 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7489 (
event != NULL) ? &tmp : NULL),
7490 __ENQUEUE_FILL_IMAGE_ERR);
7492 if (event != NULL && err == CL_SUCCESS)
7508 const array<size_type, 3>& origin,
7509 const array<size_type, 3>& region,
7510 const vector<Event>* events = NULL,
7511 Event* event = NULL)
const 7514 cl_int err = detail::errHandler(
7515 ::clEnqueueFillImage(
7518 static_cast<void*>(&fillColor),
7521 (events != NULL) ? (cl_uint) events->size() : 0,
7522 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7523 (
event != NULL) ? &tmp : NULL),
7524 __ENQUEUE_FILL_IMAGE_ERR);
7526 if (event != NULL && err == CL_SUCCESS)
7542 const array<size_type, 3>& origin,
7543 const array<size_type, 3>& region,
7544 const vector<Event>* events = NULL,
7545 Event* event = NULL)
const 7548 cl_int err = detail::errHandler(
7549 ::clEnqueueFillImage(
7552 static_cast<void*>(&fillColor),
7555 (events != NULL) ? (cl_uint) events->size() : 0,
7556 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7557 (
event != NULL) ? &tmp : NULL),
7558 __ENQUEUE_FILL_IMAGE_ERR);
7560 if (event != NULL && err == CL_SUCCESS)
7565 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 7567 cl_int enqueueCopyImageToBuffer(
7570 const array<size_type, 3>& src_origin,
7571 const array<size_type, 3>& region,
7572 size_type dst_offset,
7573 const vector<Event>* events = NULL,
7574 Event* event = NULL)
const 7577 cl_int err = detail::errHandler(
7578 ::clEnqueueCopyImageToBuffer(
7585 (events != NULL) ? (cl_uint) events->size() : 0,
7586 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7587 (
event != NULL) ? &tmp : NULL),
7588 __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR);
7590 if (event != NULL && err == CL_SUCCESS)
7596 cl_int enqueueCopyBufferToImage(
7599 size_type src_offset,
7600 const array<size_type, 3>& dst_origin,
7601 const array<size_type, 3>& region,
7602 const vector<Event>* events = NULL,
7603 Event* event = NULL)
const 7606 cl_int err = detail::errHandler(
7607 ::clEnqueueCopyBufferToImage(
7614 (events != NULL) ? (cl_uint) events->size() : 0,
7615 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7616 (
event != NULL) ? &tmp : NULL),
7617 __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR);
7619 if (event != NULL && err == CL_SUCCESS)
7625 void* enqueueMapBuffer(
7631 const vector<Event>* events = NULL,
7632 Event* event = NULL,
7633 cl_int* err = NULL)
const 7637 void * result = ::clEnqueueMapBuffer(
7638 object_, buffer(), blocking, flags, offset, size,
7639 (events != NULL) ? (cl_uint) events->size() : 0,
7640 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7641 (
event != NULL) ? &tmp : NULL,
7644 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
7648 if (event != NULL && error == CL_SUCCESS)
7654 void* enqueueMapImage(
7655 const Image& buffer,
7658 const array<size_type, 3>& origin,
7659 const array<size_type, 3>& region,
7660 size_type * row_pitch,
7661 size_type * slice_pitch,
7662 const vector<Event>* events = NULL,
7663 Event* event = NULL,
7664 cl_int* err = NULL)
const 7668 void * result = ::clEnqueueMapImage(
7669 object_, buffer(), blocking, flags,
7672 row_pitch, slice_pitch,
7673 (events != NULL) ? (cl_uint) events->size() : 0,
7674 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7675 (
event != NULL) ? &tmp : NULL,
7678 detail::errHandler(error, __ENQUEUE_MAP_IMAGE_ERR);
7682 if (event != NULL && error == CL_SUCCESS)
7687 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 7692 template<
typename T>
7698 const vector<Event>* events = NULL,
7699 Event* event = NULL)
const 7702 cl_int err = detail::errHandler(::clEnqueueSVMMap(
7703 object_, blocking, flags, static_cast<void*>(ptr), size,
7704 (events != NULL) ? (cl_uint)events->size() : 0,
7705 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
7706 (
event != NULL) ? &tmp : NULL),
7707 __ENQUEUE_MAP_BUFFER_ERR);
7709 if (event != NULL && err == CL_SUCCESS)
7720 template<
typename T,
class D>
7722 cl::pointer<T, D> &ptr,
7726 const vector<Event>* events = NULL,
7727 Event* event = NULL)
const 7730 cl_int err = detail::errHandler(::clEnqueueSVMMap(
7731 object_, blocking, flags, static_cast<void*>(ptr.get()), size,
7732 (events != NULL) ? (cl_uint)events->size() : 0,
7733 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
7734 (
event != NULL) ? &tmp : NULL),
7735 __ENQUEUE_MAP_BUFFER_ERR);
7737 if (event != NULL && err == CL_SUCCESS)
7747 template<
typename T,
class Alloc>
7749 cl::vector<T, Alloc> &container,
7752 const vector<Event>* events = NULL,
7753 Event* event = NULL)
const 7756 cl_int err = detail::errHandler(::clEnqueueSVMMap(
7757 object_, blocking, flags, static_cast<void*>(container.data()), container.size(),
7758 (events != NULL) ? (cl_uint)events->size() : 0,
7759 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
7760 (
event != NULL) ? &tmp : NULL),
7761 __ENQUEUE_MAP_BUFFER_ERR);
7763 if (event != NULL && err == CL_SUCCESS)
7768 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 7770 cl_int enqueueUnmapMemObject(
7773 const vector<Event>* events = NULL,
7774 Event* event = NULL)
const 7777 cl_int err = detail::errHandler(
7778 ::clEnqueueUnmapMemObject(
7779 object_, memory(), mapped_ptr,
7780 (events != NULL) ? (cl_uint) events->size() : 0,
7781 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7782 (
event != NULL) ? &tmp : NULL),
7783 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
7785 if (event != NULL && err == CL_SUCCESS)
7792 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 7797 template<
typename T>
7800 const vector<Event>* events = NULL,
7801 Event* event = NULL)
const 7804 cl_int err = detail::errHandler(
7805 ::clEnqueueSVMUnmap(
7806 object_, static_cast<void*>(ptr),
7807 (events != NULL) ? (cl_uint)events->size() : 0,
7808 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
7809 (
event != NULL) ? &tmp : NULL),
7810 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
7812 if (event != NULL && err == CL_SUCCESS)
7822 template<
typename T,
class D>
7824 cl::pointer<T, D> &ptr,
7825 const vector<Event>* events = NULL,
7826 Event* event = NULL)
const 7829 cl_int err = detail::errHandler(
7830 ::clEnqueueSVMUnmap(
7831 object_, static_cast<void*>(ptr.get()),
7832 (events != NULL) ? (cl_uint)events->size() : 0,
7833 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
7834 (
event != NULL) ? &tmp : NULL),
7835 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
7837 if (event != NULL && err == CL_SUCCESS)
7847 template<
typename T,
class Alloc>
7849 cl::vector<T, Alloc> &container,
7850 const vector<Event>* events = NULL,
7851 Event* event = NULL)
const 7854 cl_int err = detail::errHandler(
7855 ::clEnqueueSVMUnmap(
7856 object_, static_cast<void*>(container.data()),
7857 (events != NULL) ? (cl_uint)events->size() : 0,
7858 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
7859 (
event != NULL) ? &tmp : NULL),
7860 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
7862 if (event != NULL && err == CL_SUCCESS)
7867 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 7869 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 7882 const vector<Event> *events = 0,
7883 Event *event = 0)
const 7886 cl_int err = detail::errHandler(
7887 ::clEnqueueMarkerWithWaitList(
7889 (events != NULL) ? (cl_uint) events->size() : 0,
7890 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7891 (
event != NULL) ? &tmp : NULL),
7892 __ENQUEUE_MARKER_WAIT_LIST_ERR);
7894 if (event != NULL && err == CL_SUCCESS)
7912 const vector<Event> *events = 0,
7913 Event *event = 0)
const 7916 cl_int err = detail::errHandler(
7917 ::clEnqueueBarrierWithWaitList(
7919 (events != NULL) ? (cl_uint) events->size() : 0,
7920 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7921 (
event != NULL) ? &tmp : NULL),
7922 __ENQUEUE_BARRIER_WAIT_LIST_ERR);
7924 if (event != NULL && err == CL_SUCCESS)
7935 const vector<Memory> &memObjects,
7936 cl_mem_migration_flags flags,
7937 const vector<Event>* events = NULL,
7943 vector<cl_mem> localMemObjects(memObjects.size());
7945 for(
int i = 0; i < (int)memObjects.size(); ++i ) {
7946 localMemObjects[i] = memObjects[i]();
7950 cl_int err = detail::errHandler(
7951 ::clEnqueueMigrateMemObjects(
7953 (cl_uint)memObjects.size(),
7954 localMemObjects.data(),
7956 (events != NULL) ? (cl_uint) events->size() : 0,
7957 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7958 (
event != NULL) ? &tmp : NULL),
7959 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
7961 if (event != NULL && err == CL_SUCCESS)
7966 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 7968 cl_int enqueueNDRangeKernel(
7972 const NDRange& local = NullRange,
7973 const vector<Event>* events = NULL,
7974 Event* event = NULL)
const 7977 cl_int err = detail::errHandler(
7978 ::clEnqueueNDRangeKernel(
7979 object_, kernel(), (cl_uint) global.
dimensions(),
7980 offset.
dimensions() != 0 ? (
const size_type*) offset : NULL,
7981 (
const size_type*) global,
7982 local.
dimensions() != 0 ? (
const size_type*) local : NULL,
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_NDRANGE_KERNEL_ERR);
7988 if (event != NULL && err == CL_SUCCESS)
7994 #if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS) 7995 CL_EXT_PREFIX__VERSION_1_2_DEPRECATED cl_int enqueueTask(
7997 const vector<Event>* events = NULL,
7998 Event* event = NULL)
const CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED
8001 cl_int err = detail::errHandler(
8004 (events != NULL) ? (cl_uint) events->size() : 0,
8005 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8006 (
event != NULL) ? &tmp : NULL),
8007 __ENQUEUE_TASK_ERR);
8009 if (event != NULL && err == CL_SUCCESS)
8014 #endif // #if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS) 8016 cl_int enqueueNativeKernel(
8017 void (CL_CALLBACK *userFptr)(
void *),
8018 std::pair<void*, size_type> args,
8019 const vector<Memory>* mem_objects = NULL,
8020 const vector<const void*>* mem_locs = NULL,
8021 const vector<Event>* events = NULL,
8022 Event* event = NULL)
const 8024 size_type elements = 0;
8025 if (mem_objects != NULL) {
8026 elements = mem_objects->size();
8028 vector<cl_mem> mems(elements);
8029 for (
unsigned int i = 0; i < elements; i++) {
8030 mems[i] = ((*mem_objects)[i])();
8034 cl_int err = detail::errHandler(
8035 ::clEnqueueNativeKernel(
8036 object_, userFptr, args.first, args.second,
8037 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8039 (mem_locs != NULL && mem_locs->size() > 0) ? (
const void **) &mem_locs->front() : NULL,
8040 (events != NULL) ? (cl_uint) events->size() : 0,
8041 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8042 (
event != NULL) ? &tmp : NULL),
8043 __ENQUEUE_NATIVE_KERNEL);
8045 if (event != NULL && err == CL_SUCCESS)
8054 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 8055 CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
8059 cl_int err = detail::errHandler(
8062 (event != NULL) ? &tmp : NULL),
8063 __ENQUEUE_MARKER_ERR);
8065 if (event != NULL && err == CL_SUCCESS)
8071 CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
8072 cl_int enqueueWaitForEvents(
const vector<Event>& events)
const CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
8074 return detail::errHandler(
8075 ::clEnqueueWaitForEvents(
8077 (cl_uint) events.size(),
8078 events.size() > 0 ? (
const cl_event*) &events.front() : NULL),
8079 __ENQUEUE_WAIT_FOR_EVENTS_ERR);
8081 #endif // defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 8083 cl_int enqueueAcquireGLObjects(
8084 const vector<Memory>* mem_objects = NULL,
8085 const vector<Event>* events = NULL,
8086 Event* event = NULL)
const 8089 cl_int err = detail::errHandler(
8090 ::clEnqueueAcquireGLObjects(
8092 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8093 (mem_objects != NULL && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front(): NULL,
8094 (events != NULL) ? (cl_uint) events->size() : 0,
8095 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8096 (
event != NULL) ? &tmp : NULL),
8097 __ENQUEUE_ACQUIRE_GL_ERR);
8099 if (event != NULL && err == CL_SUCCESS)
8105 cl_int enqueueReleaseGLObjects(
8106 const vector<Memory>* mem_objects = NULL,
8107 const vector<Event>* events = NULL,
8108 Event* event = NULL)
const 8111 cl_int err = detail::errHandler(
8112 ::clEnqueueReleaseGLObjects(
8114 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8115 (mem_objects != NULL && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front(): NULL,
8116 (events != NULL) ? (cl_uint) events->size() : 0,
8117 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8118 (
event != NULL) ? &tmp : NULL),
8119 __ENQUEUE_RELEASE_GL_ERR);
8121 if (event != NULL && err == CL_SUCCESS)
8127 #if defined (CL_HPP_USE_DX_INTEROP) 8128 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueAcquireD3D10ObjectsKHR)(
8129 cl_command_queue command_queue, cl_uint num_objects,
8130 const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
8131 const cl_event* event_wait_list, cl_event* event);
8132 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueReleaseD3D10ObjectsKHR)(
8133 cl_command_queue command_queue, cl_uint num_objects,
8134 const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
8135 const cl_event* event_wait_list, cl_event* event);
8137 cl_int enqueueAcquireD3D10Objects(
8138 const vector<Memory>* mem_objects = NULL,
8139 const vector<Event>* events = NULL,
8140 Event* event = NULL)
const 8142 static PFN_clEnqueueAcquireD3D10ObjectsKHR pfn_clEnqueueAcquireD3D10ObjectsKHR = NULL;
8143 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 8144 cl_context context = getInfo<CL_QUEUE_CONTEXT>();
8145 cl::Device device(getInfo<CL_QUEUE_DEVICE>());
8146 cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>();
8147 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueAcquireD3D10ObjectsKHR);
8149 #if CL_HPP_TARGET_OPENCL_VERSION >= 110 8150 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueAcquireD3D10ObjectsKHR);
8154 cl_int err = detail::errHandler(
8155 pfn_clEnqueueAcquireD3D10ObjectsKHR(
8157 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8158 (mem_objects != NULL && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front(): NULL,
8159 (events != NULL) ? (cl_uint) events->size() : 0,
8160 (events != NULL) ? (cl_event*) &events->front() : NULL,
8161 (
event != NULL) ? &tmp : NULL),
8162 __ENQUEUE_ACQUIRE_GL_ERR);
8164 if (event != NULL && err == CL_SUCCESS)
8170 cl_int enqueueReleaseD3D10Objects(
8171 const vector<Memory>* mem_objects = NULL,
8172 const vector<Event>* events = NULL,
8173 Event* event = NULL)
const 8175 static PFN_clEnqueueReleaseD3D10ObjectsKHR pfn_clEnqueueReleaseD3D10ObjectsKHR = NULL;
8176 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 8177 cl_context context = getInfo<CL_QUEUE_CONTEXT>();
8178 cl::Device device(getInfo<CL_QUEUE_DEVICE>());
8179 cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>();
8180 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueReleaseD3D10ObjectsKHR);
8181 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 8182 #if CL_HPP_TARGET_OPENCL_VERSION >= 110 8183 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueReleaseD3D10ObjectsKHR);
8184 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110 8187 cl_int err = detail::errHandler(
8188 pfn_clEnqueueReleaseD3D10ObjectsKHR(
8190 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8191 (mem_objects != NULL && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front(): NULL,
8192 (events != NULL) ? (cl_uint) events->size() : 0,
8193 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8194 (
event != NULL) ? &tmp : NULL),
8195 __ENQUEUE_RELEASE_GL_ERR);
8197 if (event != NULL && err == CL_SUCCESS)
8207 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 8208 CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
8211 return detail::errHandler(
8212 ::clEnqueueBarrier(object_),
8213 __ENQUEUE_BARRIER_ERR);
8215 #endif // CL_USE_DEPRECATED_OPENCL_1_1_APIS 8217 cl_int flush()
const 8219 return detail::errHandler(::clFlush(object_), __FLUSH_ERR);
8222 cl_int finish()
const 8224 return detail::errHandler(::clFinish(object_), __FINISH_ERR);
8228 CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag CommandQueue::default_initialized_;
8229 CL_HPP_DEFINE_STATIC_MEMBER_
CommandQueue CommandQueue::default_;
8230 CL_HPP_DEFINE_STATIC_MEMBER_ cl_int CommandQueue::default_error_ = CL_SUCCESS;
8233 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 8234 enum class DeviceQueueProperties : cl_command_queue_properties
8237 Profiling = CL_QUEUE_PROFILING_ENABLE,
8240 inline DeviceQueueProperties operator|(DeviceQueueProperties lhs, DeviceQueueProperties rhs)
8242 return static_cast<DeviceQueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) | static_cast<cl_command_queue_properties>(rhs));
8266 cl_command_queue_properties mergedProperties =
8267 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
8269 cl_queue_properties queue_properties[] = {
8270 CL_QUEUE_PROPERTIES, mergedProperties, 0 };
8271 object_ = ::clCreateCommandQueueWithProperties(
8272 context(), device(), queue_properties, &error);
8274 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8286 DeviceQueueProperties properties = DeviceQueueProperties::None,
8291 cl_command_queue_properties mergedProperties =
8292 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
8293 cl_queue_properties queue_properties[] = {
8294 CL_QUEUE_PROPERTIES, mergedProperties, 0 };
8295 object_ = ::clCreateCommandQueueWithProperties(
8296 context(), device(), queue_properties, &error);
8298 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8311 DeviceQueueProperties properties = DeviceQueueProperties::None,
8316 cl_command_queue_properties mergedProperties =
8317 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
8318 cl_queue_properties queue_properties[] = {
8319 CL_QUEUE_PROPERTIES, mergedProperties,
8320 CL_QUEUE_SIZE, queueSize,
8322 object_ = ::clCreateCommandQueueWithProperties(
8323 context(), device(), queue_properties, &error);
8325 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8338 detail::Wrapper<cl_type>(commandQueue, retainObject) { }
8374 template <
typename T>
8375 cl_int getInfo(cl_command_queue_info name, T* param)
const 8377 return detail::errHandler(
8379 &::clGetCommandQueueInfo, object_, name, param),
8380 __GET_COMMAND_QUEUE_INFO_ERR);
8383 template <cl_
int name>
typename 8385 getInfo(cl_int* err = NULL)
const 8388 detail::cl_command_queue_info, name>::param_type param;
8389 cl_int result = getInfo(name, ¶m);
8403 cl_int *err =
nullptr)
8409 cl_command_queue_properties properties =
8410 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
8411 cl_queue_properties queue_properties[] = {
8412 CL_QUEUE_PROPERTIES, properties,
8415 ::clCreateCommandQueueWithProperties(
8416 context(), device(), queue_properties, &error));
8418 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8433 const Context &context,
const Device &device, cl_int *err =
nullptr)
8437 cl_command_queue_properties properties =
8438 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
8439 cl_queue_properties queue_properties[] = {
8440 CL_QUEUE_PROPERTIES, properties,
8443 ::clCreateCommandQueueWithProperties(
8444 context(), device(), queue_properties, &error));
8446 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8461 const Context &context,
const Device &device, cl_uint queueSize, cl_int *err =
nullptr)
8465 cl_command_queue_properties properties =
8466 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
8467 cl_queue_properties queue_properties[] = {
8468 CL_QUEUE_PROPERTIES, properties,
8469 CL_QUEUE_SIZE, queueSize,
8472 ::clCreateCommandQueueWithProperties(
8473 context(), device(), queue_properties, &error));
8475 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8495 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 8498 template<
typename IteratorType >
8501 IteratorType startIterator,
8502 IteratorType endIterator,
8507 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
8510 cl_mem_flags flags = 0;
8512 flags |= CL_MEM_READ_ONLY;
8515 flags |= CL_MEM_READ_WRITE;
8518 flags |= CL_MEM_USE_HOST_PTR;
8521 size_type size =
sizeof(DataType)*(endIterator - startIterator);
8524 object_ = ::clCreateBuffer(context(), flags, size, static_cast<DataType*>(&*startIterator), &error);
8526 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
8529 detail::errHandler(error, __CREATE_BUFFER_ERR);
8536 detail::errHandler(error, __CREATE_BUFFER_ERR);
8541 error =
cl::copy(queue, startIterator, endIterator, *
this);
8542 detail::errHandler(error, __CREATE_BUFFER_ERR);
8549 template<
typename IteratorType >
8552 IteratorType startIterator,
8553 IteratorType endIterator,
8558 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
8561 cl_mem_flags flags = 0;
8563 flags |= CL_MEM_READ_ONLY;
8566 flags |= CL_MEM_READ_WRITE;
8569 flags |= CL_MEM_USE_HOST_PTR;
8572 size_type size =
sizeof(DataType)*(endIterator - startIterator);
8574 Context context = queue.getInfo<CL_QUEUE_CONTEXT>();
8577 object_ = ::clCreateBuffer(context(), flags, size, static_cast<DataType*>(&*startIterator), &error);
8580 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
8583 detail::errHandler(error, __CREATE_BUFFER_ERR);
8589 error =
cl::copy(queue, startIterator, endIterator, *
this);
8590 detail::errHandler(error, __CREATE_BUFFER_ERR);
8597 inline cl_int enqueueReadBuffer(
8603 const vector<Event>* events = NULL,
8604 Event* event = NULL)
8609 if (error != CL_SUCCESS) {
8613 return queue.enqueueReadBuffer(buffer, blocking, offset, size, ptr, events, event);
8616 inline cl_int enqueueWriteBuffer(
8622 const vector<Event>* events = NULL,
8623 Event* event = NULL)
8628 if (error != CL_SUCCESS) {
8632 return queue.enqueueWriteBuffer(buffer, blocking, offset, size, ptr, events, event);
8635 inline void* enqueueMapBuffer(
8641 const vector<Event>* events = NULL,
8642 Event* event = NULL,
8647 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
8652 void * result = ::clEnqueueMapBuffer(
8653 queue(), buffer(), blocking, flags, offset, size,
8654 (events != NULL) ? (cl_uint) events->size() : 0,
8655 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8659 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
8667 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 8673 template<
typename T>
8679 const vector<Event>* events,
8684 if (error != CL_SUCCESS) {
8685 return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
8689 ptr, blocking, flags, size, events, event);
8697 template<
typename T,
class D>
8699 cl::pointer<T, D> ptr,
8703 const vector<Event>* events = NULL,
8704 Event* event = NULL)
8708 if (error != CL_SUCCESS) {
8709 return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
8713 ptr, blocking, flags, size, events, event);
8721 template<
typename T,
class Alloc>
8723 cl::vector<T, Alloc> container,
8726 const vector<Event>* events = NULL,
8727 Event* event = NULL)
8731 if (error != CL_SUCCESS) {
8732 return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
8736 container, blocking, flags, events, event);
8739 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 8741 inline cl_int enqueueUnmapMemObject(
8744 const vector<Event>* events = NULL,
8745 Event* event = NULL)
8749 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
8750 if (error != CL_SUCCESS) {
8755 cl_int err = detail::errHandler(
8756 ::clEnqueueUnmapMemObject(
8757 queue(), memory(), mapped_ptr,
8758 (events != NULL) ? (cl_uint)events->size() : 0,
8759 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8760 (
event != NULL) ? &tmp : NULL),
8761 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8763 if (event != NULL && err == CL_SUCCESS)
8769 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 8775 template<
typename T>
8778 const vector<Event>* events = NULL,
8779 Event* event = NULL)
8783 if (error != CL_SUCCESS) {
8784 return detail::errHandler(error, __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8788 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8797 template<
typename T,
class D>
8799 cl::pointer<T, D> &ptr,
8800 const vector<Event>* events = NULL,
8801 Event* event = NULL)
8805 if (error != CL_SUCCESS) {
8806 return detail::errHandler(error, __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8810 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8818 template<
typename T,
class Alloc>
8820 cl::vector<T, Alloc> &container,
8821 const vector<Event>* events = NULL,
8822 Event* event = NULL)
8826 if (error != CL_SUCCESS) {
8827 return detail::errHandler(error, __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8830 return detail::errHandler(queue.
enqueueUnmapSVM(container, events, event),
8831 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8834 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 8836 inline cl_int enqueueCopyBuffer(
8839 size_type src_offset,
8840 size_type dst_offset,
8842 const vector<Event>* events = NULL,
8843 Event* event = NULL)
8848 if (error != CL_SUCCESS) {
8852 return queue.enqueueCopyBuffer(src, dst, src_offset, dst_offset, size, events, event);
8860 template<
typename IteratorType >
8861 inline cl_int
copy( IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer )
8865 if (error != CL_SUCCESS)
8868 return cl::copy(queue, startIterator, endIterator, buffer);
8876 template<
typename IteratorType >
8877 inline cl_int
copy(
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator )
8881 if (error != CL_SUCCESS)
8884 return cl::copy(queue, buffer, startIterator, endIterator);
8892 template<
typename IteratorType >
8895 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
8898 size_type length = endIterator-startIterator;
8899 size_type byteLength = length*
sizeof(DataType);
8902 static_cast<DataType*
>(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_WRITE, 0, byteLength, 0, 0, &error));
8904 if( error != CL_SUCCESS ) {
8907 #if defined(_MSC_VER) 8911 stdext::checked_array_iterator<DataType*>(
8914 std::copy(startIterator, endIterator, pointer);
8917 error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
8919 if( error != CL_SUCCESS ) {
8931 template<
typename IteratorType >
8934 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
8937 size_type length = endIterator-startIterator;
8938 size_type byteLength = length*
sizeof(DataType);
8941 static_cast<DataType*
>(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_READ, 0, byteLength, 0, 0, &error));
8943 if( error != CL_SUCCESS ) {
8946 std::copy(pointer, pointer + length, startIterator);
8948 error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
8950 if( error != CL_SUCCESS ) {
8958 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 8962 template<
typename T,
class Alloc>
8963 inline cl_int
mapSVM(cl::vector<T, Alloc> &container)
8965 return enqueueMapSVM(container, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE);
8971 template<
typename T,
class Alloc>
8972 inline cl_int
unmapSVM(cl::vector<T, Alloc> &container)
8977 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 8979 #if CL_HPP_TARGET_OPENCL_VERSION >= 110 8980 inline cl_int enqueueReadBufferRect(
8983 const array<size_type, 3>& buffer_offset,
8984 const array<size_type, 3>& host_offset,
8985 const array<size_type, 3>& region,
8986 size_type buffer_row_pitch,
8987 size_type buffer_slice_pitch,
8988 size_type host_row_pitch,
8989 size_type host_slice_pitch,
8991 const vector<Event>* events = NULL,
8992 Event* event = NULL)
8997 if (error != CL_SUCCESS) {
9001 return queue.enqueueReadBufferRect(
9016 inline cl_int enqueueWriteBufferRect(
9019 const array<size_type, 3>& buffer_offset,
9020 const array<size_type, 3>& host_offset,
9021 const array<size_type, 3>& region,
9022 size_type buffer_row_pitch,
9023 size_type buffer_slice_pitch,
9024 size_type host_row_pitch,
9025 size_type host_slice_pitch,
9027 const vector<Event>* events = NULL,
9028 Event* event = NULL)
9033 if (error != CL_SUCCESS) {
9037 return queue.enqueueWriteBufferRect(
9052 inline cl_int enqueueCopyBufferRect(
9055 const array<size_type, 3>& src_origin,
9056 const array<size_type, 3>& dst_origin,
9057 const array<size_type, 3>& region,
9058 size_type src_row_pitch,
9059 size_type src_slice_pitch,
9060 size_type dst_row_pitch,
9061 size_type dst_slice_pitch,
9062 const vector<Event>* events = NULL,
9063 Event* event = NULL)
9068 if (error != CL_SUCCESS) {
9072 return queue.enqueueCopyBufferRect(
9085 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110 9087 inline cl_int enqueueReadImage(
9090 const array<size_type, 3>& origin,
9091 const array<size_type, 3>& region,
9092 size_type row_pitch,
9093 size_type slice_pitch,
9095 const vector<Event>* events = NULL,
9096 Event* event = NULL)
9101 if (error != CL_SUCCESS) {
9105 return queue.enqueueReadImage(
9117 inline cl_int enqueueWriteImage(
9120 const array<size_type, 3>& origin,
9121 const array<size_type, 3>& region,
9122 size_type row_pitch,
9123 size_type slice_pitch,
9125 const vector<Event>* events = NULL,
9126 Event* event = NULL)
9131 if (error != CL_SUCCESS) {
9135 return queue.enqueueWriteImage(
9147 inline cl_int enqueueCopyImage(
9150 const array<size_type, 3>& src_origin,
9151 const array<size_type, 3>& dst_origin,
9152 const array<size_type, 3>& region,
9153 const vector<Event>* events = NULL,
9154 Event* event = NULL)
9159 if (error != CL_SUCCESS) {
9163 return queue.enqueueCopyImage(
9173 inline cl_int enqueueCopyImageToBuffer(
9176 const array<size_type, 3>& src_origin,
9177 const array<size_type, 3>& region,
9178 size_type dst_offset,
9179 const vector<Event>* events = NULL,
9180 Event* event = NULL)
9185 if (error != CL_SUCCESS) {
9189 return queue.enqueueCopyImageToBuffer(
9199 inline cl_int enqueueCopyBufferToImage(
9202 size_type src_offset,
9203 const array<size_type, 3>& dst_origin,
9204 const array<size_type, 3>& region,
9205 const vector<Event>* events = NULL,
9206 Event* event = NULL)
9211 if (error != CL_SUCCESS) {
9215 return queue.enqueueCopyBufferToImage(
9226 inline cl_int flush(
void)
9231 if (error != CL_SUCCESS) {
9235 return queue.flush();
9238 inline cl_int finish(
void)
9243 if (error != CL_SUCCESS) {
9248 return queue.finish();
9258 vector<Event> events_;
9260 template<
typename... Ts>
9265 queue_(CommandQueue::getDefault()),
9274 queue_(CommandQueue::getDefault()),
9283 queue_(CommandQueue::getDefault()),
9292 queue_(CommandQueue::getDefault()),
9297 events_.push_back(e);
9301 queue_(CommandQueue::getDefault()),
9306 events_.push_back(e);
9310 queue_(CommandQueue::getDefault()),
9315 events_.push_back(e);
9319 queue_(CommandQueue::getDefault()),
9329 queue_(CommandQueue::getDefault()),
9339 queue_(CommandQueue::getDefault()),
9381 events_.push_back(e);
9390 events_.push_back(e);
9399 events_.push_back(e);
9441 template<
typename... Ts>
9447 template<
int index,
typename T0,
typename... T1s>
9448 void setArgs(T0&& t0, T1s&&... t1s)
9450 kernel_.
setArg(index, t0);
9451 setArgs<index + 1, T1s...>(std::forward<T1s>(t1s)...);
9454 template<
int index,
typename T0>
9455 void setArgs(T0&& t0)
9457 kernel_.
setArg(index, t0);
9473 cl_int * err = NULL) :
9474 kernel_(program, name.c_str(), err)
9490 setArgs<0>(std::forward<Ts>(ts)...);
9492 args.queue_.enqueueNDRangeKernel(
9515 setArgs<0>(std::forward<Ts>(ts)...);
9517 error = args.queue_.enqueueNDRangeKernel(
9528 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 9529 cl_int setSVMPointers(
const vector<void*> &pointerList)
9534 template<
typename T0,
typename... T1s>
9535 cl_int setSVMPointers(
const T0 &t0, T1s &... ts)
9539 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 9547 namespace compatibility {
9552 template<
typename... Ts>
9562 cl_int * err = NULL) :
9584 enqueueArgs, args...);
9592 #undef CL_HPP_ERR_STR_ 9593 #if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS) 9594 #undef __GET_DEVICE_INFO_ERR 9595 #undef __GET_PLATFORM_INFO_ERR 9596 #undef __GET_DEVICE_IDS_ERR 9597 #undef __GET_CONTEXT_INFO_ERR 9598 #undef __GET_EVENT_INFO_ERR 9599 #undef __GET_EVENT_PROFILE_INFO_ERR 9600 #undef __GET_MEM_OBJECT_INFO_ERR 9601 #undef __GET_IMAGE_INFO_ERR 9602 #undef __GET_SAMPLER_INFO_ERR 9603 #undef __GET_KERNEL_INFO_ERR 9604 #undef __GET_KERNEL_ARG_INFO_ERR 9605 #undef __GET_KERNEL_WORK_GROUP_INFO_ERR 9606 #undef __GET_PROGRAM_INFO_ERR 9607 #undef __GET_PROGRAM_BUILD_INFO_ERR 9608 #undef __GET_COMMAND_QUEUE_INFO_ERR 9610 #undef __CREATE_CONTEXT_ERR 9611 #undef __CREATE_CONTEXT_FROM_TYPE_ERR 9612 #undef __GET_SUPPORTED_IMAGE_FORMATS_ERR 9614 #undef __CREATE_BUFFER_ERR 9615 #undef __CREATE_SUBBUFFER_ERR 9616 #undef __CREATE_IMAGE2D_ERR 9617 #undef __CREATE_IMAGE3D_ERR 9618 #undef __CREATE_SAMPLER_ERR 9619 #undef __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR 9621 #undef __CREATE_USER_EVENT_ERR 9622 #undef __SET_USER_EVENT_STATUS_ERR 9623 #undef __SET_EVENT_CALLBACK_ERR 9624 #undef __SET_PRINTF_CALLBACK_ERR 9626 #undef __WAIT_FOR_EVENTS_ERR 9628 #undef __CREATE_KERNEL_ERR 9629 #undef __SET_KERNEL_ARGS_ERR 9630 #undef __CREATE_PROGRAM_WITH_SOURCE_ERR 9631 #undef __CREATE_PROGRAM_WITH_BINARY_ERR 9632 #undef __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR 9633 #undef __BUILD_PROGRAM_ERR 9634 #undef __CREATE_KERNELS_IN_PROGRAM_ERR 9636 #undef __CREATE_COMMAND_QUEUE_ERR 9637 #undef __SET_COMMAND_QUEUE_PROPERTY_ERR 9638 #undef __ENQUEUE_READ_BUFFER_ERR 9639 #undef __ENQUEUE_WRITE_BUFFER_ERR 9640 #undef __ENQUEUE_READ_BUFFER_RECT_ERR 9641 #undef __ENQUEUE_WRITE_BUFFER_RECT_ERR 9642 #undef __ENQEUE_COPY_BUFFER_ERR 9643 #undef __ENQEUE_COPY_BUFFER_RECT_ERR 9644 #undef __ENQUEUE_READ_IMAGE_ERR 9645 #undef __ENQUEUE_WRITE_IMAGE_ERR 9646 #undef __ENQUEUE_COPY_IMAGE_ERR 9647 #undef __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR 9648 #undef __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR 9649 #undef __ENQUEUE_MAP_BUFFER_ERR 9650 #undef __ENQUEUE_MAP_IMAGE_ERR 9651 #undef __ENQUEUE_UNMAP_MEM_OBJECT_ERR 9652 #undef __ENQUEUE_NDRANGE_KERNEL_ERR 9653 #undef __ENQUEUE_TASK_ERR 9654 #undef __ENQUEUE_NATIVE_KERNEL 9656 #undef __UNLOAD_COMPILER_ERR 9657 #undef __CREATE_SUB_DEVICES_ERR 9659 #undef __CREATE_PIPE_ERR 9660 #undef __GET_PIPE_INFO_ERR 9662 #endif //CL_HPP_USER_OVERRIDE_ERROR_STRINGS 9665 #undef CL_HPP_INIT_CL_EXT_FCN_PTR_ 9666 #undef CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_ 9668 #if defined(CL_HPP_USE_CL_DEVICE_FISSION) 9669 #undef CL_HPP_PARAM_NAME_DEVICE_FISSION_ 9670 #endif // CL_HPP_USE_CL_DEVICE_FISSION 9672 #undef CL_HPP_NOEXCEPT_ 9673 #undef CL_HPP_DEFINE_STATIC_MEMBER_ Memory()
Default constructor - initializes to NULL.
Event type_(const EnqueueArgs &, Ts...)
Function signature of kernel functor with no event dependency.
BufferRenderGL(const cl_mem &buffer, bool retainObject=false)
Constructor from cl_mem - takes ownership.
CommandQueue(CommandQueue &&queue) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Image interface for arrays of 2D images.
Image1DBuffer(const cl_mem &image1D, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Image interface for arrays of 1D images.
Image2DGL()
Default constructor - initializes to NULL.
cl_int getInfo(cl_context_info name, T *param) const
Wrapper for clGetContextInfo().
Context(const cl_context &context, bool retainObject=false)
Constructor from cl_context - takes ownership.
Image & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
Image3D(const Image3D &img)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
static DeviceCommandQueue makeDefault(const Context &context, const Device &device, cl_uint queueSize, cl_int *err=nullptr)
Image2DGL(const Image2DGL &img)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
std::enable_if< std::is_pointer< T >::value, cl_int >::type setArg(cl_uint index, const T argPtr)
setArg overload taking a pointer type
Image1DBuffer(const Image1DBuffer &img)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Image2D(const Context &context, cl_mem_flags flags, ImageFormat format, size_type width, size_type height, size_type row_pitch=0, void *host_ptr=NULL, cl_int *err=NULL)
Constructs a 2D Image in a specified context.
Image1D(const Context &context, cl_mem_flags flags, ImageFormat format, size_type width, void *host_ptr=NULL, cl_int *err=NULL)
Constructs a 1D Image in a specified context.
Image2D & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
cl_int setSVMPointers(const vector< void *> &pointerList)
The OpenCL C++ bindings are defined within this namespace.
CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_int enqueueBarrier() const CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
Image(Image &&img) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
detail::param_traits< detail::cl_device_info, name >::param_type getInfo(cl_int *err=NULL) const
Wrapper for clGetDeviceInfo() that returns by value.
cl_int unmapSVM(cl::vector< T, Alloc > &container)
Context(const Context &ctx)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Local address wrapper for use with Kernel::setArg.
detail::param_traits< detail::cl_pipe_info, name >::param_type getInfo(cl_int *err=NULL) const
Wrapper for clGetMemObjectInfo() that returns by value.
cl_int enqueueMapSVM(cl::vector< T, Alloc > &container, cl_bool blocking, cl_map_flags flags, const vector< Event > *events=NULL, Event *event=NULL) const
Class interface for GL 3D Image Memory objects.
CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_int enqueueMarker(Event *event=NULL) const CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
CommandQueue(const Context &context, const Device &device, QueueProperties properties, cl_int *err=NULL)
Constructs a CommandQueue for a passed device and context Will return an CL_INVALID_QUEUE_PROPERTIES ...
CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_int UnloadCompiler() CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
static DeviceCommandQueue makeDefault(const Context &context, const Device &device, cl_int *err=nullptr)
Program(const Context &context, const vector< Device > &devices, const Binaries &binaries, vector< cl_int > *binaryStatus=NULL, cl_int *err=NULL)
Buffer(IteratorType startIterator, IteratorType endIterator, bool readOnly, bool useHostPtr=false, cl_int *err=NULL)
Construct a Buffer from a host container via iterators. IteratorType must be random access...
Class interface for cl_mem.
Pipe(cl_uint packet_size, cl_uint max_packets, cl_int *err=NULL)
Constructs a Pipe in a the default context.
cl_int enqueueMigrateMemObjects(const vector< Memory > &memObjects, cl_mem_migration_flags flags, const vector< Event > *events=NULL, Event *event=NULL) const
Device(const Device &dev)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
BufferRenderGL(BufferRenderGL &&buf) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Image2DArray(Image2DArray &&img) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
detail::param_traits< detail::cl_image_info, name >::param_type getImageInfo(cl_int *err=NULL) const
Wrapper for clGetImageInfo() that returns by value.
Memory(Memory &&mem) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
cl_int enqueueMarkerWithWaitList(const vector< Event > *events=0, Event *event=0) const
Image3D(Image3D &&img) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
cl_int getSupportedImageFormats(cl_mem_flags flags, cl_mem_object_type type, vector< ImageFormat > *formats) const
Gets a list of supported image formats.
BufferRenderGL()
Default constructor - initializes to NULL.
Image(const Image &img)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
cl_int enqueueFillBuffer(const Buffer &buffer, PatternType pattern, size_type offset, size_type size, const vector< Event > *events=NULL, Event *event=NULL) const
Image1DArray(const Image1DArray &img)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Kernel(const Kernel &kernel)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
CommandQueue(const Context &context, cl_command_queue_properties properties=0, cl_int *err=NULL)
Constructs a CommandQueue for an implementation defined device in the given context Will return an CL...
Buffer createSubBuffer(cl_mem_flags flags, cl_buffer_create_type buffer_create_type, const void *buffer_create_info, cl_int *err=NULL)
Creates a new buffer object from this.
cl_int enqueueBarrierWithWaitList(const vector< Event > *events=0, Event *event=0) const
Buffer(Buffer &&buf) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
vector< T, cl::SVMAllocator< int, cl::SVMTraitCoarse<> >> coarse_svm_vector
Vector alias to simplify contruction of coarse-grained SVM containers.
static Device getDefault(cl_int *errResult=NULL)
Returns the first device on the default context.
cl_int enqueueUnmapSVM(T *ptr, const vector< Event > *events=NULL, Event *event=NULL)
Sampler(const Sampler &sam)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
cl_int setCallback(cl_int type, void(CL_CALLBACK *pfn_notify)(cl_event, cl_int, void *), void *user_data=NULL)
Registers a user callback function for a specific command execution status.
size_type dimensions() const
Queries the number of dimensions in the range.
Event()
Default constructor - initializes to NULL.
ImageGL(const cl_mem &image, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Image3D(const Context &context, cl_mem_flags flags, ImageFormat format, size_type width, size_type height, size_type depth, size_type row_pitch=0, size_type slice_pitch=0, void *host_ptr=NULL, cl_int *err=NULL)
Constructs a 3D Image in a specified context.
cl_int setArg(cl_uint index, const cl::vector< T, Alloc > &argPtr)
setArg overload taking a vector type.
detail::param_traits< detail::cl_profiling_info, name >::param_type getProfilingInfo(cl_int *err=NULL) const
Wrapper for clGetEventProfilingInfo() that returns by value.
Image1D(const Image1D &img)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
BufferRenderGL(const BufferRenderGL &buf)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
DeviceCommandQueue(DeviceQueueProperties properties, cl_int *err=NULL)
Pipe(const Context &context, cl_uint packet_size, cl_uint max_packets, cl_int *err=NULL)
Constructs a Pipe in a specified context.
Image3D()
Default constructor - initializes to NULL.
CommandQueue(const Context &context, const Device &device, cl_command_queue_properties properties=0, cl_int *err=NULL)
Constructs a CommandQueue for a passed device and context Will return an CL_INVALID_QUEUE_PROPERTIES ...
Image2DGL(Image2DGL &&img) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
cl_int getInfo(cl_sampler_info name, T *param) const
Wrapper for clGetSamplerInfo().
Kernel()
Default constructor - initializes to NULL.
Image2DGL(const Context &context, cl_mem_flags flags, cl_GLenum target, cl_GLint miplevel, cl_GLuint texobj, cl_int *err=NULL)
Constructs an Image2DGL in a specified context, from a given GL Texture.
Sampler()
Default constructor - initializes to NULL.
Image1D(Image1D &&img) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Program(Program &&program) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
cl_int getObjectInfo(cl_gl_object_type *type, cl_GLuint *gl_object_name)
Wrapper for clGetGLObjectInfo().
std::enable_if<!std::is_pointer< T >::value, cl_int >::type setArg(cl_uint index, const T &value)
setArg overload taking a POD type
size_type max_size() const CL_HPP_NOEXCEPT_
Image1DArray(const cl_mem &imageArray, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Class interface for cl_event.
vector< T, cl::SVMAllocator< int, cl::SVMTraitFine<> >> fine_svm_vector
Vector alias to simplify contruction of fine-grained SVM containers.
Image2DGL(const cl_mem &image, bool retainObject=false)
Constructor from cl_mem - takes ownership.
NDRange(size_type size0)
Constructs one-dimensional range.
Program(const Context &context, const Sources &sources, cl_int *err=NULL)
vector< T, cl::SVMAllocator< int, cl::SVMTraitAtomic<> >> atomic_svm_vector
Vector alias to simplify contruction of fine-grained SVM containers that support platform atomics...
Buffer & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
detail::param_traits< detail::cl_event_info, name >::param_type getInfo(cl_int *err=NULL) const
Wrapper for clGetEventInfo() that returns by value.
Class interface for Pipe Memory Objects.
cl_int enqueueUnmapSVM(cl::pointer< T, D > &ptr, const vector< Event > *events=NULL, Event *event=NULL) const
Image2D(const Image2D &img)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Buffer()
Default constructor - initializes to NULL.
DeviceCommandQueue(const Context &context, const Device &device, DeviceQueueProperties properties=DeviceQueueProperties::None, cl_int *err=NULL)
cl_int setArg(cl_uint index, const cl::pointer< T, D > &argPtr)
setArg overload taking a shared_ptr type
Image3DGL(const Image3DGL &img)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
cl_int copy(IteratorType startIterator, IteratorType endIterator, cl::Buffer &buffer)
Context(const vector< Device > &devices, cl_context_properties *properties=NULL, void(CL_CALLBACK *notifyFptr)(const char *, const void *, size_type, void *)=NULL, void *data=NULL, cl_int *err=NULL)
Constructs a context including a list of specified devices.
DeviceCommandQueue(const DeviceCommandQueue &queue)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Sampler(const cl_sampler &sampler, bool retainObject=false)
Constructor from cl_sampler - takes ownership.
Image()
Default constructor - initializes to NULL.
static cl_int release(cl_device_id device)
cl_int getInfo(cl_device_info name, T *param) const
Wrapper for clGetDeviceInfo().
Event(const cl_event &event, bool retainObject=false)
Constructor from cl_event - takes ownership.
DeviceCommandQueue(const Context &context, const Device &device, cl_uint queueSize, DeviceQueueProperties properties=DeviceQueueProperties::None, cl_int *err=NULL)
NDRange(size_type size0, size_type size1)
Constructs two-dimensional range.
Image3DGL(const Context &context, cl_mem_flags flags, cl_GLenum target, cl_GLint miplevel, cl_GLuint texobj, cl_int *err=NULL)
Constructs an Image3DGL in a specified context, from a given GL Texture.
Image2D()
Default constructor - initializes to NULL.
Image3D(const cl_mem &image3D, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Image2D(Image2D &&img) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
DeviceCommandQueue interface for device cl_command_queues.
Image1DArray(Image1DArray &&img) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Pipe()
Default constructor - initializes to NULL.
CommandQueue(const cl_command_queue &commandQueue, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Pipe(const Pipe &pipe)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
cl_int getInfo(cl_event_info name, T *param) const
Wrapper for clGetEventInfo().
Image1D()
Default constructor - initializes to NULL.
Buffer(const cl_mem &buffer, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Sampler(Sampler &&sam) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
static CommandQueue setDefault(const CommandQueue &default_queue)
Program(const Context &context, const vector< Device > &devices, const string &kernelNames, cl_int *err=NULL)
CommandQueue(const CommandQueue &queue)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
cl_int enqueueMapSVM(T *ptr, cl_bool blocking, cl_map_flags flags, size_type size, const vector< Event > *events=NULL, Event *event=NULL) const
Kernel(Kernel &&kernel) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
cl_int enqueueFillImage(const Image &image, cl_uint4 fillColor, const array< size_type, 3 > &origin, const array< size_type, 3 > ®ion, const vector< Event > *events=NULL, Event *event=NULL) const
Image2D(const Context &context, ImageFormat format, const Buffer &sourceBuffer, size_type width, size_type height, size_type row_pitch=0, cl_int *err=nullptr)
Constructs a 2D Image from a buffer.
Program(const Sources &sources, cl_int *err=NULL)
Device(const cl_device_id &device, bool retainObject=false)
Constructor from cl_device_id.
NDRange()
Default constructor - resulting range has zero dimensions.
BufferGL(const BufferGL &buf)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Image3D & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
CommandQueue(const Context &context, QueueProperties properties, cl_int *err=NULL)
Constructs a CommandQueue for an implementation defined device in the given context Will return an CL...
cl_int setDestructorCallback(void(CL_CALLBACK *pfn_notify)(cl_mem, void *), void *user_data=NULL)
Registers a callback function to be called when the memory object is no longer needed.
CommandQueue(cl_command_queue_properties properties, cl_int *err=NULL)
Constructs a CommandQueue based on passed properties. Will return an CL_INVALID_QUEUE_PROPERTIES erro...
Buffer(const Context &context, cl_mem_flags flags, size_type size, void *host_ptr=NULL, cl_int *err=NULL)
Constructs a Buffer in a specified context.
cl_int wait() const
Blocks the calling thread until this event completes.
Event result_type
Return type of the functor.
cl_int setSVMPointers(const std::array< void *, ArrayLength > &pointerList)
Image2DArray(const cl_mem &imageArray, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Buffer(const Buffer &buf)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Image(const cl_mem &image, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Memory(const Memory &mem)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Program(const Program &program)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
cl_int getObjectInfo(cl_gl_object_type *type, cl_GLuint *gl_object_name)
Wrapper for clGetGLObjectInfo().
static cl_int retain(cl_device_id device)
Image3DGL()
Default constructor - initializes to NULL.
Image2D(const Context &context, cl_channel_order order, const Image &sourceImage, cl_int *err=nullptr)
Constructs a 2D Image from an image.
CommandQueue interface for cl_command_queue.
Image2D(const cl_mem &image2D, bool retainObject=false)
Constructor from cl_mem - takes ownership.
cl_int enqueueUnmapSVM(cl::vector< T, Alloc > &container, const vector< Event > *events=NULL, Event *event=NULL) const
Sampler(const Context &context, cl_bool normalized_coords, cl_addressing_mode addressing_mode, cl_filter_mode filter_mode, cl_int *err=NULL)
Constructs a Sampler in a specified context.
Image1D(const cl_mem &image1D, bool retainObject=false)
Constructor from cl_mem - takes ownership.
pointer allocate(size_type size, typename cl::SVMAllocator< void, SVMTrait >::const_pointer=0)
static DeviceCommandQueue makeDefault(cl_int *err=nullptr)
UserEvent()
Default constructor - initializes to NULL.
DeviceCommandQueue(const cl_command_queue &commandQueue, bool retainObject=false)
Constructor from cl_command_queue - takes ownership.
cl_int enableFineGrainedSystemSVM(bool svmEnabled)
Enable fine-grained system SVM.
Pipe(const cl_mem &pipe, bool retainObject=false)
Constructor from cl_mem - takes ownership.
detail::param_traits< detail::cl_context_info, name >::param_type getInfo(cl_int *err=NULL) const
Wrapper for clGetContextInfo() that returns by value.
Pipe(Pipe &&pipe) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
cl_int mapSVM(cl::vector< T, Alloc > &container)
cl::pointer< T, detail::Deleter< Alloc > > allocate_pointer(const Alloc &alloc_, Args &&... args)
Class interface for user events (a subset of cl_event's).
bool operator==(SVMAllocator const &rhs)
cl_int enqueueFillImage(const Image &image, cl_int4 fillColor, const array< size_type, 3 > &origin, const array< size_type, 3 > ®ion, const vector< Event > *events=NULL, Event *event=NULL) const
Program(const cl_program &program, bool retainObject=false)
Constructor from cl_mem - takes ownership.
cl_int enqueueUnmapSVM(T *ptr, const vector< Event > *events=NULL, Event *event=NULL) const
Kernel(const cl_kernel &kernel, bool retainObject=false)
Constructor from cl_kernel - takes ownership.
vector< std::pair< cl::Device, typename detail::param_traits< detail::cl_program_build_info, name >::param_type > > getBuildInfo(cl_int *err=NULL) const
cl_int getProfilingInfo(cl_profiling_info name, T *param) const
Wrapper for clGetEventProfilingInfo().
Class interface for cl_sampler.
ImageGL(const ImageGL &img)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
LocalSpaceArg Local(size_type size)
Helper function for generating LocalSpaceArg objects.
Event result_type
Return type of the functor.
detail::param_traits< detail::cl_mem_info, name >::param_type getInfo(cl_int *err=NULL) const
Wrapper for clGetMemObjectInfo() that returns by value.
C++ base class for Image Memory objects.
cl_int enqueueMapSVM(T *ptr, cl_bool blocking, cl_map_flags flags, size_type size, const vector< Event > *events=NULL, Event *event=NULL)
Buffer(cl_mem_flags flags, size_type size, void *host_ptr=NULL, cl_int *err=NULL)
Constructs a Buffer in the default context.
static Context setDefault(const Context &default_context)
cl_int enqueueMapSVM(cl::pointer< T, D > &ptr, cl_bool blocking, cl_map_flags flags, size_type size, const vector< Event > *events=NULL, Event *event=NULL) const
BufferGL(BufferGL &&buf) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Class interface for Buffer Memory Objects.
detail::param_traits< detail::cl_sampler_info, name >::param_type getInfo(cl_int *err=NULL) const
Wrapper for clGetSamplerInfo() that returns by value.
static Device setDefault(const Device &default_device)
Image1DBuffer(Image1DBuffer &&img) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Class interface for specifying NDRange values.
Class interface for 2D Image Memory objects.
ImageGL(ImageGL &&img) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Class interface for 1D Image Memory objects.
Class interface for cl_kernel.
NDRange(size_type size0, size_type size1, size_type size2)
Constructs three-dimensional range.
static cl_int waitForEvents(const vector< Event > &events)
Blocks the calling thread until every event specified is complete.
Class interface for 3D Image Memory objects.
Class interface for GL Render Buffer Memory Objects.
general image interface for GL interop. We abstract the 2D and 3D GL images into a single instance he...
cl_int setStatus(cl_int status)
Sets the execution status of a user event object.
Device()
Default constructor - initializes to NULL.
Context()
Default constructor - initializes to NULL.
Image2DArray(const Image2DArray &img)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Class interface for cl_device_id.
Context(Context &&ctx) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
static Context getDefault(cl_int *err=NULL)
Returns a singleton context including all devices of CL_DEVICE_TYPE_DEFAULT.
Context(cl_device_type type, cl_context_properties *properties=NULL, void(CL_CALLBACK *notifyFptr)(const char *, const void *, size_type, void *)=NULL, void *data=NULL, cl_int *err=NULL)
Constructs a context including all or a subset of devices of a specified type.
Memory(const cl_mem &memory, bool retainObject)
Constructor from cl_mem - takes ownership.
Device(Device &&dev) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
BufferRenderGL(const Context &context, cl_mem_flags flags, cl_GLuint bufobj, cl_int *err=NULL)
Constructs a BufferRenderGL in a specified context, from a given GL Renderbuffer. ...
cl_int getImageInfo(cl_image_info name, T *param) const
Wrapper for clGetImageInfo().
BufferGL()
Default constructor - initializes to NULL.
UserEvent(const Context &context, cl_int *err=NULL)
Constructs a user event on a given context.
cl_int enqueueFillImage(const Image &image, cl_float4 fillColor, const array< size_type, 3 > &origin, const array< size_type, 3 > ®ion, const vector< Event > *events=NULL, Event *event=NULL) const
CommandQueue(QueueProperties properties, cl_int *err=NULL)
Constructs a CommandQueue based on passed properties. Will return an CL_INVALID_QUEUE_PROPERTIES erro...
cl_int getInfo(cl_pipe_info name, T *param) const
Wrapper for clGetMemObjectInfo().
Image interface for 1D buffer images.
Program interface that implements cl_program.
Image3DGL(const cl_mem &image, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Image3DGL(Image3DGL &&img) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Class interface for GL Buffer Memory Objects.
DeviceCommandQueue(DeviceCommandQueue &&queue) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
cl_int copy(const CommandQueue &queue, const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator)
Class interface for GL 2D Image Memory objects.
Class interface for cl_context.
BufferGL(const Context &context, cl_mem_flags flags, cl_GLuint bufobj, cl_int *err=NULL)
Constructs a BufferGL in a specified context, from a given GL buffer.
Memory & operator=(const cl_mem &rhs)
Assignment operator from cl_mem - takes ownership.
size_type size() const
Returns the size of the object in bytes based on the.
BufferGL(const cl_mem &buffer, bool retainObject=false)
Constructor from cl_mem - takes ownership.
cl_int getInfo(cl_mem_info name, T *param) const
Wrapper for clGetMemObjectInfo().