398 #if !defined(CL_HPP_USE_DX_INTEROP) && defined(USE_DX_INTEROP) 399 # pragma message("cl2.hpp: USE_DX_INTEROP is deprecated. Define CL_HPP_USE_DX_INTEROP instead") 400 # define CL_HPP_USE_DX_INTEROP 402 #if !defined(CL_HPP_USE_CL_DEVICE_FISSION) && defined(USE_CL_DEVICE_FISSION) 403 # pragma message("cl2.hpp: USE_CL_DEVICE_FISSION is deprecated. Define CL_HPP_USE_CL_DEVICE_FISSION instead") 404 # define CL_HPP_USE_CL_DEVICE_FISSION 406 #if !defined(CL_HPP_ENABLE_EXCEPTIONS) && defined(__CL_ENABLE_EXCEPTIONS) 407 # pragma message("cl2.hpp: __CL_ENABLE_EXCEPTIONS is deprecated. Define CL_HPP_ENABLE_EXCEPTIONS instead") 408 # define CL_HPP_ENABLE_EXCEPTIONS 410 #if !defined(CL_HPP_NO_STD_VECTOR) && defined(__NO_STD_VECTOR) 411 # pragma message("cl2.hpp: __NO_STD_VECTOR is deprecated. Define CL_HPP_NO_STD_VECTOR instead") 412 # define CL_HPP_NO_STD_VECTOR 414 #if !defined(CL_HPP_NO_STD_STRING) && defined(__NO_STD_STRING) 415 # pragma message("cl2.hpp: __NO_STD_STRING is deprecated. Define CL_HPP_NO_STD_STRING instead") 416 # define CL_HPP_NO_STD_STRING 418 #if defined(VECTOR_CLASS) 419 # pragma message("cl2.hpp: VECTOR_CLASS is deprecated. Alias cl::vector instead") 421 #if defined(STRING_CLASS) 422 # pragma message("cl2.hpp: STRING_CLASS is deprecated. Alias cl::string instead.") 424 #if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS) && defined(__CL_USER_OVERRIDE_ERROR_STRINGS) 425 # pragma message("cl2.hpp: __CL_USER_OVERRIDE_ERROR_STRINGS is deprecated. Define CL_HPP_USER_OVERRIDE_ERROR_STRINGS instead") 426 # define CL_HPP_USER_OVERRIDE_ERROR_STRINGS 431 #if defined(__USE_DEV_VECTOR) 432 # pragma message("cl2.hpp: __USE_DEV_VECTOR is no longer supported. Expect compilation errors") 434 #if defined(__USE_DEV_STRING) 435 # pragma message("cl2.hpp: __USE_DEV_STRING is no longer supported. Expect compilation errors") 439 #if !defined(CL_HPP_TARGET_OPENCL_VERSION) 440 # pragma message("cl2.hpp: CL_HPP_TARGET_OPENCL_VERSION is not defined. It will default to 200 (OpenCL 2.0)") 441 # define CL_HPP_TARGET_OPENCL_VERSION 200 443 #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 444 # 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") 445 # undef CL_HPP_TARGET_OPENCL_VERSION 446 # define CL_HPP_TARGET_OPENCL_VERSION 200 449 #if !defined(CL_HPP_MINIMUM_OPENCL_VERSION) 450 # define CL_HPP_MINIMUM_OPENCL_VERSION 200 452 #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 453 # 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") 454 # undef CL_HPP_MINIMUM_OPENCL_VERSION 455 # define CL_HPP_MINIMUM_OPENCL_VERSION 100 457 #if CL_HPP_MINIMUM_OPENCL_VERSION > CL_HPP_TARGET_OPENCL_VERSION 458 # error "CL_HPP_MINIMUM_OPENCL_VERSION must not be greater than CL_HPP_TARGET_OPENCL_VERSION" 461 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 100 && !defined(CL_USE_DEPRECATED_OPENCL_1_0_APIS) 462 # define CL_USE_DEPRECATED_OPENCL_1_0_APIS 464 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 110 && !defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 465 # define CL_USE_DEPRECATED_OPENCL_1_1_APIS 467 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 120 && !defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS) 468 # define CL_USE_DEPRECATED_OPENCL_1_2_APIS 470 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 200 && !defined(CL_USE_DEPRECATED_OPENCL_2_0_APIS) 471 # define CL_USE_DEPRECATED_OPENCL_2_0_APIS 478 #if defined(CL_HPP_USE_DX_INTEROP) 479 #include <CL/cl_d3d10.h> 480 #include <CL/cl_dx9_media_sharing.h> 484 #if defined(_MSC_VER) 492 #if (!defined(_MSC_VER) && __cplusplus < 201103L) || (defined(_MSC_VER) && _MSC_VER < 1700) 493 #error Visual studio 2013 or another C++11-supporting compiler required 497 #if defined(CL_HPP_USE_CL_DEVICE_FISSION) || defined(CL_HPP_USE_CL_SUB_GROUPS_KHR) 498 #include <CL/cl_ext.h> 501 #if defined(__APPLE__) || defined(__MACOSX) 502 #include <OpenCL/opencl.h> 504 #include <CL/opencl.h> 507 #if (__cplusplus >= 201103L) 508 #define CL_HPP_NOEXCEPT_ noexcept 510 #define CL_HPP_NOEXCEPT_ 513 #if defined(_MSC_VER) 514 # define CL_HPP_DEFINE_STATIC_MEMBER_ __declspec(selectany) 516 # define CL_HPP_DEFINE_STATIC_MEMBER_ __attribute__((weak)) 521 #if !defined(CL_EXT_PREFIX__VERSION_1_1_DEPRECATED) 522 #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED 523 #endif // #if !defined(CL_EXT_PREFIX__VERSION_1_1_DEPRECATED) 524 #if !defined(CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED) 525 #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED 526 #endif // #if !defined(CL_EXT_PREFIX__VERSION_1_1_DEPRECATED) 528 #if !defined(CL_EXT_PREFIX__VERSION_1_2_DEPRECATED) 529 #define CL_EXT_PREFIX__VERSION_1_2_DEPRECATED 530 #endif // #if !defined(CL_EXT_PREFIX__VERSION_1_2_DEPRECATED) 531 #if !defined(CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED) 532 #define CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED 533 #endif // #if !defined(CL_EXT_PREFIX__VERSION_1_2_DEPRECATED) 535 #if !defined(CL_CALLBACK) 544 #include <functional> 548 #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY) 550 using size_type = ::size_t;
552 #else // #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY) 554 using size_type = size_t;
556 #endif // #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY) 559 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 561 #endif // #if defined(CL_HPP_ENABLE_EXCEPTIONS) 563 #if !defined(CL_HPP_NO_STD_VECTOR) 566 template <
class T,
class Alloc = std::allocator<T> >
567 using vector = std::vector<T, Alloc>;
569 #endif // #if !defined(CL_HPP_NO_STD_VECTOR) 571 #if !defined(CL_HPP_NO_STD_STRING) 574 using string = std::string;
576 #endif // #if !defined(CL_HPP_NO_STD_STRING) 578 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 580 #if !defined(CL_HPP_NO_STD_UNIQUE_PTR) 585 template<
class T,
class D>
586 using pointer = std::unique_ptr<T, D>;
589 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 590 #if !defined(CL_HPP_NO_STD_ARRAY) 593 template <
class T,
size_type N >
594 using array = std::array<T, N>;
596 #endif // #if !defined(CL_HPP_NO_STD_ARRAY) 600 #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY) 602 namespace compatibility {
617 for (
int i = 0; i < N; ++i) {
622 size_t(
const array<size_type, N> &rhs)
624 for (
int i = 0; i < N; ++i) {
629 size_type& operator[](
int index)
634 const size_type& operator[](
int index)
const 640 operator size_type* () {
return data_; }
643 operator const size_type* ()
const {
return data_; }
645 operator array<size_type, N>()
const 647 array<size_type, N> ret;
649 for (
int i = 0; i < N; ++i) {
658 using size_t = compatibility::size_t<N>;
660 #endif // #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY) 665 using size_t_array = array<size_type, 3>;
678 #define CL_HPP_INIT_CL_EXT_FCN_PTR_(name) \ 680 pfn_##name = (PFN_##name) \ 681 clGetExtensionFunctionAddress(#name); \ 686 #define CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, name) \ 688 pfn_##name = (PFN_##name) \ 689 clGetExtensionFunctionAddressForPlatform(platform, #name); \ 703 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 708 class Error :
public std::exception
712 const char * errStr_;
723 Error(cl_int err,
const char * errStr = NULL) : err_(err), errStr_(errStr)
732 virtual const char * what()
const throw ()
734 if (errStr_ == NULL) {
746 cl_int err(
void)
const {
return err_; }
748 #define CL_HPP_ERR_STR_(x) #x 750 #define CL_HPP_ERR_STR_(x) NULL 751 #endif // CL_HPP_ENABLE_EXCEPTIONS 756 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 757 static inline cl_int errHandler (
759 const char * errStr = NULL)
761 if (err != CL_SUCCESS) {
762 throw Error(err, errStr);
767 static inline cl_int errHandler (cl_int err,
const char * errStr = NULL)
772 #endif // CL_HPP_ENABLE_EXCEPTIONS 778 #if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS) 779 #define __GET_DEVICE_INFO_ERR CL_HPP_ERR_STR_(clGetDeviceInfo) 780 #define __GET_PLATFORM_INFO_ERR CL_HPP_ERR_STR_(clGetPlatformInfo) 781 #define __GET_DEVICE_IDS_ERR CL_HPP_ERR_STR_(clGetDeviceIDs) 782 #define __GET_PLATFORM_IDS_ERR CL_HPP_ERR_STR_(clGetPlatformIDs) 783 #define __GET_CONTEXT_INFO_ERR CL_HPP_ERR_STR_(clGetContextInfo) 784 #define __GET_EVENT_INFO_ERR CL_HPP_ERR_STR_(clGetEventInfo) 785 #define __GET_EVENT_PROFILE_INFO_ERR CL_HPP_ERR_STR_(clGetEventProfileInfo) 786 #define __GET_MEM_OBJECT_INFO_ERR CL_HPP_ERR_STR_(clGetMemObjectInfo) 787 #define __GET_IMAGE_INFO_ERR CL_HPP_ERR_STR_(clGetImageInfo) 788 #define __GET_SAMPLER_INFO_ERR CL_HPP_ERR_STR_(clGetSamplerInfo) 789 #define __GET_KERNEL_INFO_ERR CL_HPP_ERR_STR_(clGetKernelInfo) 790 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 791 #define __GET_KERNEL_ARG_INFO_ERR CL_HPP_ERR_STR_(clGetKernelArgInfo) 792 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 793 #define __GET_KERNEL_WORK_GROUP_INFO_ERR CL_HPP_ERR_STR_(clGetKernelWorkGroupInfo) 794 #define __GET_PROGRAM_INFO_ERR CL_HPP_ERR_STR_(clGetProgramInfo) 795 #define __GET_PROGRAM_BUILD_INFO_ERR CL_HPP_ERR_STR_(clGetProgramBuildInfo) 796 #define __GET_COMMAND_QUEUE_INFO_ERR CL_HPP_ERR_STR_(clGetCommandQueueInfo) 798 #define __CREATE_CONTEXT_ERR CL_HPP_ERR_STR_(clCreateContext) 799 #define __CREATE_CONTEXT_FROM_TYPE_ERR CL_HPP_ERR_STR_(clCreateContextFromType) 800 #define __GET_SUPPORTED_IMAGE_FORMATS_ERR CL_HPP_ERR_STR_(clGetSupportedImageFormats) 802 #define __CREATE_BUFFER_ERR CL_HPP_ERR_STR_(clCreateBuffer) 803 #define __COPY_ERR CL_HPP_ERR_STR_(cl::copy) 804 #define __CREATE_SUBBUFFER_ERR CL_HPP_ERR_STR_(clCreateSubBuffer) 805 #define __CREATE_GL_BUFFER_ERR CL_HPP_ERR_STR_(clCreateFromGLBuffer) 806 #define __CREATE_GL_RENDER_BUFFER_ERR CL_HPP_ERR_STR_(clCreateFromGLBuffer) 807 #define __GET_GL_OBJECT_INFO_ERR CL_HPP_ERR_STR_(clGetGLObjectInfo) 808 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 809 #define __CREATE_IMAGE_ERR CL_HPP_ERR_STR_(clCreateImage) 810 #define __CREATE_GL_TEXTURE_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture) 811 #define __IMAGE_DIMENSION_ERR CL_HPP_ERR_STR_(Incorrect image dimensions) 812 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 813 #define __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR CL_HPP_ERR_STR_(clSetMemObjectDestructorCallback) 815 #define __CREATE_USER_EVENT_ERR CL_HPP_ERR_STR_(clCreateUserEvent) 816 #define __SET_USER_EVENT_STATUS_ERR CL_HPP_ERR_STR_(clSetUserEventStatus) 817 #define __SET_EVENT_CALLBACK_ERR CL_HPP_ERR_STR_(clSetEventCallback) 818 #define __WAIT_FOR_EVENTS_ERR CL_HPP_ERR_STR_(clWaitForEvents) 820 #define __CREATE_KERNEL_ERR CL_HPP_ERR_STR_(clCreateKernel) 821 #define __SET_KERNEL_ARGS_ERR CL_HPP_ERR_STR_(clSetKernelArg) 822 #define __CREATE_PROGRAM_WITH_SOURCE_ERR CL_HPP_ERR_STR_(clCreateProgramWithSource) 823 #define __CREATE_PROGRAM_WITH_BINARY_ERR CL_HPP_ERR_STR_(clCreateProgramWithBinary) 824 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 825 #define __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR CL_HPP_ERR_STR_(clCreateProgramWithBuiltInKernels) 826 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 827 #define __BUILD_PROGRAM_ERR CL_HPP_ERR_STR_(clBuildProgram) 828 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 829 #define __COMPILE_PROGRAM_ERR CL_HPP_ERR_STR_(clCompileProgram) 830 #define __LINK_PROGRAM_ERR CL_HPP_ERR_STR_(clLinkProgram) 831 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 832 #define __CREATE_KERNELS_IN_PROGRAM_ERR CL_HPP_ERR_STR_(clCreateKernelsInProgram) 834 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 835 #define __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR CL_HPP_ERR_STR_(clCreateCommandQueueWithProperties) 836 #define __CREATE_SAMPLER_WITH_PROPERTIES_ERR CL_HPP_ERR_STR_(clCreateSamplerWithProperties) 837 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200 838 #define __SET_COMMAND_QUEUE_PROPERTY_ERR CL_HPP_ERR_STR_(clSetCommandQueueProperty) 839 #define __ENQUEUE_READ_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueReadBuffer) 840 #define __ENQUEUE_READ_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueReadBufferRect) 841 #define __ENQUEUE_WRITE_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueWriteBuffer) 842 #define __ENQUEUE_WRITE_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueWriteBufferRect) 843 #define __ENQEUE_COPY_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueCopyBuffer) 844 #define __ENQEUE_COPY_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueCopyBufferRect) 845 #define __ENQUEUE_FILL_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueFillBuffer) 846 #define __ENQUEUE_READ_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueReadImage) 847 #define __ENQUEUE_WRITE_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueWriteImage) 848 #define __ENQUEUE_COPY_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueCopyImage) 849 #define __ENQUEUE_FILL_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueFillImage) 850 #define __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueCopyImageToBuffer) 851 #define __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueCopyBufferToImage) 852 #define __ENQUEUE_MAP_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueMapBuffer) 853 #define __ENQUEUE_MAP_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueMapImage) 854 #define __ENQUEUE_UNMAP_MEM_OBJECT_ERR CL_HPP_ERR_STR_(clEnqueueUnMapMemObject) 855 #define __ENQUEUE_NDRANGE_KERNEL_ERR CL_HPP_ERR_STR_(clEnqueueNDRangeKernel) 856 #define __ENQUEUE_NATIVE_KERNEL CL_HPP_ERR_STR_(clEnqueueNativeKernel) 857 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 858 #define __ENQUEUE_MIGRATE_MEM_OBJECTS_ERR CL_HPP_ERR_STR_(clEnqueueMigrateMemObjects) 859 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 861 #define __ENQUEUE_ACQUIRE_GL_ERR CL_HPP_ERR_STR_(clEnqueueAcquireGLObjects) 862 #define __ENQUEUE_RELEASE_GL_ERR CL_HPP_ERR_STR_(clEnqueueReleaseGLObjects) 864 #define __CREATE_PIPE_ERR CL_HPP_ERR_STR_(clCreatePipe) 865 #define __GET_PIPE_INFO_ERR CL_HPP_ERR_STR_(clGetPipeInfo) 868 #define __RETAIN_ERR CL_HPP_ERR_STR_(Retain Object) 869 #define __RELEASE_ERR CL_HPP_ERR_STR_(Release Object) 870 #define __FLUSH_ERR CL_HPP_ERR_STR_(clFlush) 871 #define __FINISH_ERR CL_HPP_ERR_STR_(clFinish) 872 #define __VECTOR_CAPACITY_ERR CL_HPP_ERR_STR_(Vector capacity error) 877 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 878 #define __CREATE_SUB_DEVICES_ERR CL_HPP_ERR_STR_(clCreateSubDevices) 880 #define __CREATE_SUB_DEVICES_ERR CL_HPP_ERR_STR_(clCreateSubDevicesEXT) 881 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 886 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 887 #define __ENQUEUE_MARKER_ERR CL_HPP_ERR_STR_(clEnqueueMarker) 888 #define __ENQUEUE_WAIT_FOR_EVENTS_ERR CL_HPP_ERR_STR_(clEnqueueWaitForEvents) 889 #define __ENQUEUE_BARRIER_ERR CL_HPP_ERR_STR_(clEnqueueBarrier) 890 #define __UNLOAD_COMPILER_ERR CL_HPP_ERR_STR_(clUnloadCompiler) 891 #define __CREATE_GL_TEXTURE_2D_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture2D) 892 #define __CREATE_GL_TEXTURE_3D_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture3D) 893 #define __CREATE_IMAGE2D_ERR CL_HPP_ERR_STR_(clCreateImage2D) 894 #define __CREATE_IMAGE3D_ERR CL_HPP_ERR_STR_(clCreateImage3D) 895 #endif // #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 900 #if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS) 901 #define __CREATE_COMMAND_QUEUE_ERR CL_HPP_ERR_STR_(clCreateCommandQueue) 902 #define __ENQUEUE_TASK_ERR CL_HPP_ERR_STR_(clEnqueueTask) 903 #define __CREATE_SAMPLER_ERR CL_HPP_ERR_STR_(clCreateSampler) 904 #endif // #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 909 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 910 #define __ENQUEUE_MARKER_WAIT_LIST_ERR CL_HPP_ERR_STR_(clEnqueueMarkerWithWaitList) 911 #define __ENQUEUE_BARRIER_WAIT_LIST_ERR CL_HPP_ERR_STR_(clEnqueueBarrierWithWaitList) 912 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 914 #endif // CL_HPP_USER_OVERRIDE_ERROR_STRINGS 924 template<
typename Functor,
typename T>
925 inline cl_int getInfoHelper(Functor f, cl_uint name, T* param,
long)
927 return f(name,
sizeof(T), param, NULL);
932 template <
typename Func>
933 inline cl_int getInfoHelper(Func f, cl_uint name, vector<vector<unsigned char>>* param,
int)
935 if (name != CL_PROGRAM_BINARIES) {
936 return CL_INVALID_VALUE;
940 size_type numBinaries = param->size();
941 vector<unsigned char*> binariesPointers(numBinaries);
943 for (size_type i = 0; i < numBinaries; ++i)
945 binariesPointers[i] = (*param)[i].data();
948 cl_int err = f(name, numBinaries *
sizeof(
unsigned char*), binariesPointers.data(), NULL);
950 if (err != CL_SUCCESS) {
960 template <
typename Func,
typename T>
961 inline cl_int getInfoHelper(Func f, cl_uint name, vector<T>* param,
long)
964 cl_int err = f(name, 0, NULL, &required);
965 if (err != CL_SUCCESS) {
968 const size_type elements = required /
sizeof(T);
971 vector<T> localData(elements);
972 err = f(name, required, localData.data(), NULL);
973 if (err != CL_SUCCESS) {
977 *param = std::move(localData);
989 template <
typename Func,
typename T>
990 inline cl_int getInfoHelper(
991 Func f, cl_uint name, vector<T>* param,
int,
typename T::cl_type = 0)
994 cl_int err = f(name, 0, NULL, &required);
995 if (err != CL_SUCCESS) {
999 const size_type elements = required /
sizeof(
typename T::cl_type);
1001 vector<typename T::cl_type> value(elements);
1002 err = f(name, required, value.data(), NULL);
1003 if (err != CL_SUCCESS) {
1009 param->resize(elements);
1013 for (size_type i = 0; i < elements; i++) {
1014 (*param)[i] = T(value[i],
true);
1021 template <
typename Func>
1022 inline cl_int getInfoHelper(Func f, cl_uint name,
string* param,
long)
1025 cl_int err = f(name, 0, NULL, &required);
1026 if (err != CL_SUCCESS) {
1033 vector<char> value(required);
1034 err = f(name, required, value.data(), NULL);
1035 if (err != CL_SUCCESS) {
1039 param->assign(begin(value), prev(end(value)));
1049 template <
typename Func,
size_type N>
1050 inline cl_int getInfoHelper(Func f, cl_uint name, array<size_type, N>* param,
long)
1053 cl_int err = f(name, 0, NULL, &required);
1054 if (err != CL_SUCCESS) {
1058 size_type elements = required /
sizeof(size_type);
1059 vector<size_type> value(elements, 0);
1061 err = f(name, required, value.data(), NULL);
1062 if (err != CL_SUCCESS) {
1071 for (size_type i = 0; i < elements; ++i) {
1072 (*param)[i] = value[i];
1086 template<
typename Func,
typename T>
1087 inline cl_int getInfoHelper(Func f, cl_uint name, T* param,
int,
typename T::cl_type = 0)
1089 typename T::cl_type value;
1090 cl_int err = f(name,
sizeof(value), &value, NULL);
1091 if (err != CL_SUCCESS) {
1097 err = param->retain();
1098 if (err != CL_SUCCESS) {
1105 #define CL_HPP_PARAM_NAME_INFO_1_0_(F) \ 1106 F(cl_platform_info, CL_PLATFORM_PROFILE, string) \ 1107 F(cl_platform_info, CL_PLATFORM_VERSION, string) \ 1108 F(cl_platform_info, CL_PLATFORM_NAME, string) \ 1109 F(cl_platform_info, CL_PLATFORM_VENDOR, string) \ 1110 F(cl_platform_info, CL_PLATFORM_EXTENSIONS, string) \ 1112 F(cl_device_info, CL_DEVICE_TYPE, cl_device_type) \ 1113 F(cl_device_info, CL_DEVICE_VENDOR_ID, cl_uint) \ 1114 F(cl_device_info, CL_DEVICE_MAX_COMPUTE_UNITS, cl_uint) \ 1115 F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, cl_uint) \ 1116 F(cl_device_info, CL_DEVICE_MAX_WORK_GROUP_SIZE, size_type) \ 1117 F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_SIZES, cl::vector<size_type>) \ 1118 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, cl_uint) \ 1119 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT, cl_uint) \ 1120 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT, cl_uint) \ 1121 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG, cl_uint) \ 1122 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT, cl_uint) \ 1123 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, cl_uint) \ 1124 F(cl_device_info, CL_DEVICE_MAX_CLOCK_FREQUENCY, cl_uint) \ 1125 F(cl_device_info, CL_DEVICE_ADDRESS_BITS, cl_uint) \ 1126 F(cl_device_info, CL_DEVICE_MAX_READ_IMAGE_ARGS, cl_uint) \ 1127 F(cl_device_info, CL_DEVICE_MAX_WRITE_IMAGE_ARGS, cl_uint) \ 1128 F(cl_device_info, CL_DEVICE_MAX_MEM_ALLOC_SIZE, cl_ulong) \ 1129 F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_WIDTH, size_type) \ 1130 F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_HEIGHT, size_type) \ 1131 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_WIDTH, size_type) \ 1132 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_HEIGHT, size_type) \ 1133 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_DEPTH, size_type) \ 1134 F(cl_device_info, CL_DEVICE_IMAGE_SUPPORT, cl_bool) \ 1135 F(cl_device_info, CL_DEVICE_MAX_PARAMETER_SIZE, size_type) \ 1136 F(cl_device_info, CL_DEVICE_MAX_SAMPLERS, cl_uint) \ 1137 F(cl_device_info, CL_DEVICE_MEM_BASE_ADDR_ALIGN, cl_uint) \ 1138 F(cl_device_info, CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE, cl_uint) \ 1139 F(cl_device_info, CL_DEVICE_SINGLE_FP_CONFIG, cl_device_fp_config) \ 1140 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_TYPE, cl_device_mem_cache_type) \ 1141 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE, cl_uint)\ 1142 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_SIZE, cl_ulong) \ 1143 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_SIZE, cl_ulong) \ 1144 F(cl_device_info, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE, cl_ulong) \ 1145 F(cl_device_info, CL_DEVICE_MAX_CONSTANT_ARGS, cl_uint) \ 1146 F(cl_device_info, CL_DEVICE_LOCAL_MEM_TYPE, cl_device_local_mem_type) \ 1147 F(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE, cl_ulong) \ 1148 F(cl_device_info, CL_DEVICE_ERROR_CORRECTION_SUPPORT, cl_bool) \ 1149 F(cl_device_info, CL_DEVICE_PROFILING_TIMER_RESOLUTION, size_type) \ 1150 F(cl_device_info, CL_DEVICE_ENDIAN_LITTLE, cl_bool) \ 1151 F(cl_device_info, CL_DEVICE_AVAILABLE, cl_bool) \ 1152 F(cl_device_info, CL_DEVICE_COMPILER_AVAILABLE, cl_bool) \ 1153 F(cl_device_info, CL_DEVICE_EXECUTION_CAPABILITIES, cl_device_exec_capabilities) \ 1154 F(cl_device_info, CL_DEVICE_PLATFORM, cl_platform_id) \ 1155 F(cl_device_info, CL_DEVICE_NAME, string) \ 1156 F(cl_device_info, CL_DEVICE_VENDOR, string) \ 1157 F(cl_device_info, CL_DRIVER_VERSION, string) \ 1158 F(cl_device_info, CL_DEVICE_PROFILE, string) \ 1159 F(cl_device_info, CL_DEVICE_VERSION, string) \ 1160 F(cl_device_info, CL_DEVICE_EXTENSIONS, string) \ 1162 F(cl_context_info, CL_CONTEXT_REFERENCE_COUNT, cl_uint) \ 1163 F(cl_context_info, CL_CONTEXT_DEVICES, cl::vector<Device>) \ 1164 F(cl_context_info, CL_CONTEXT_PROPERTIES, cl::vector<cl_context_properties>) \ 1166 F(cl_event_info, CL_EVENT_COMMAND_QUEUE, cl::CommandQueue) \ 1167 F(cl_event_info, CL_EVENT_COMMAND_TYPE, cl_command_type) \ 1168 F(cl_event_info, CL_EVENT_REFERENCE_COUNT, cl_uint) \ 1169 F(cl_event_info, CL_EVENT_COMMAND_EXECUTION_STATUS, cl_int) \ 1171 F(cl_profiling_info, CL_PROFILING_COMMAND_QUEUED, cl_ulong) \ 1172 F(cl_profiling_info, CL_PROFILING_COMMAND_SUBMIT, cl_ulong) \ 1173 F(cl_profiling_info, CL_PROFILING_COMMAND_START, cl_ulong) \ 1174 F(cl_profiling_info, CL_PROFILING_COMMAND_END, cl_ulong) \ 1176 F(cl_mem_info, CL_MEM_TYPE, cl_mem_object_type) \ 1177 F(cl_mem_info, CL_MEM_FLAGS, cl_mem_flags) \ 1178 F(cl_mem_info, CL_MEM_SIZE, size_type) \ 1179 F(cl_mem_info, CL_MEM_HOST_PTR, void*) \ 1180 F(cl_mem_info, CL_MEM_MAP_COUNT, cl_uint) \ 1181 F(cl_mem_info, CL_MEM_REFERENCE_COUNT, cl_uint) \ 1182 F(cl_mem_info, CL_MEM_CONTEXT, cl::Context) \ 1184 F(cl_image_info, CL_IMAGE_FORMAT, cl_image_format) \ 1185 F(cl_image_info, CL_IMAGE_ELEMENT_SIZE, size_type) \ 1186 F(cl_image_info, CL_IMAGE_ROW_PITCH, size_type) \ 1187 F(cl_image_info, CL_IMAGE_SLICE_PITCH, size_type) \ 1188 F(cl_image_info, CL_IMAGE_WIDTH, size_type) \ 1189 F(cl_image_info, CL_IMAGE_HEIGHT, size_type) \ 1190 F(cl_image_info, CL_IMAGE_DEPTH, size_type) \ 1192 F(cl_sampler_info, CL_SAMPLER_REFERENCE_COUNT, cl_uint) \ 1193 F(cl_sampler_info, CL_SAMPLER_CONTEXT, cl::Context) \ 1194 F(cl_sampler_info, CL_SAMPLER_NORMALIZED_COORDS, cl_bool) \ 1195 F(cl_sampler_info, CL_SAMPLER_ADDRESSING_MODE, cl_addressing_mode) \ 1196 F(cl_sampler_info, CL_SAMPLER_FILTER_MODE, cl_filter_mode) \ 1198 F(cl_program_info, CL_PROGRAM_REFERENCE_COUNT, cl_uint) \ 1199 F(cl_program_info, CL_PROGRAM_CONTEXT, cl::Context) \ 1200 F(cl_program_info, CL_PROGRAM_NUM_DEVICES, cl_uint) \ 1201 F(cl_program_info, CL_PROGRAM_DEVICES, cl::vector<Device>) \ 1202 F(cl_program_info, CL_PROGRAM_SOURCE, string) \ 1203 F(cl_program_info, CL_PROGRAM_BINARY_SIZES, cl::vector<size_type>) \ 1204 F(cl_program_info, CL_PROGRAM_BINARIES, cl::vector<cl::vector<unsigned char>>) \ 1206 F(cl_program_build_info, CL_PROGRAM_BUILD_STATUS, cl_build_status) \ 1207 F(cl_program_build_info, CL_PROGRAM_BUILD_OPTIONS, string) \ 1208 F(cl_program_build_info, CL_PROGRAM_BUILD_LOG, string) \ 1210 F(cl_kernel_info, CL_KERNEL_FUNCTION_NAME, string) \ 1211 F(cl_kernel_info, CL_KERNEL_NUM_ARGS, cl_uint) \ 1212 F(cl_kernel_info, CL_KERNEL_REFERENCE_COUNT, cl_uint) \ 1213 F(cl_kernel_info, CL_KERNEL_CONTEXT, cl::Context) \ 1214 F(cl_kernel_info, CL_KERNEL_PROGRAM, cl::Program) \ 1216 F(cl_kernel_work_group_info, CL_KERNEL_WORK_GROUP_SIZE, size_type) \ 1217 F(cl_kernel_work_group_info, CL_KERNEL_COMPILE_WORK_GROUP_SIZE, cl::detail::size_t_array) \ 1218 F(cl_kernel_work_group_info, CL_KERNEL_LOCAL_MEM_SIZE, cl_ulong) \ 1220 F(cl_command_queue_info, CL_QUEUE_CONTEXT, cl::Context) \ 1221 F(cl_command_queue_info, CL_QUEUE_DEVICE, cl::Device) \ 1222 F(cl_command_queue_info, CL_QUEUE_REFERENCE_COUNT, cl_uint) \ 1223 F(cl_command_queue_info, CL_QUEUE_PROPERTIES, cl_command_queue_properties) 1226 #define CL_HPP_PARAM_NAME_INFO_1_1_(F) \ 1227 F(cl_context_info, CL_CONTEXT_NUM_DEVICES, cl_uint)\ 1228 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF, cl_uint) \ 1229 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR, cl_uint) \ 1230 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT, cl_uint) \ 1231 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_INT, cl_uint) \ 1232 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG, cl_uint) \ 1233 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT, cl_uint) \ 1234 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE, cl_uint) \ 1235 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF, cl_uint) \ 1236 F(cl_device_info, CL_DEVICE_DOUBLE_FP_CONFIG, cl_device_fp_config) \ 1237 F(cl_device_info, CL_DEVICE_HALF_FP_CONFIG, cl_device_fp_config) \ 1238 F(cl_device_info, CL_DEVICE_OPENCL_C_VERSION, string) \ 1240 F(cl_mem_info, CL_MEM_ASSOCIATED_MEMOBJECT, cl::Memory) \ 1241 F(cl_mem_info, CL_MEM_OFFSET, size_type) \ 1243 F(cl_kernel_work_group_info, CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, size_type) \ 1244 F(cl_kernel_work_group_info, CL_KERNEL_PRIVATE_MEM_SIZE, cl_ulong) \ 1246 F(cl_event_info, CL_EVENT_CONTEXT, cl::Context) 1248 #define CL_HPP_PARAM_NAME_INFO_1_2_(F) \ 1249 F(cl_program_info, CL_PROGRAM_NUM_KERNELS, size_type) \ 1250 F(cl_program_info, CL_PROGRAM_KERNEL_NAMES, string) \ 1252 F(cl_program_build_info, CL_PROGRAM_BINARY_TYPE, cl_program_binary_type) \ 1254 F(cl_kernel_info, CL_KERNEL_ATTRIBUTES, string) \ 1256 F(cl_kernel_arg_info, CL_KERNEL_ARG_ADDRESS_QUALIFIER, cl_kernel_arg_address_qualifier) \ 1257 F(cl_kernel_arg_info, CL_KERNEL_ARG_ACCESS_QUALIFIER, cl_kernel_arg_access_qualifier) \ 1258 F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_NAME, string) \ 1259 F(cl_kernel_arg_info, CL_KERNEL_ARG_NAME, string) \ 1260 F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_QUALIFIER, cl_kernel_arg_type_qualifier) \ 1262 F(cl_device_info, CL_DEVICE_PARENT_DEVICE, cl::Device) \ 1263 F(cl_device_info, CL_DEVICE_PARTITION_PROPERTIES, cl::vector<cl_device_partition_property>) \ 1264 F(cl_device_info, CL_DEVICE_PARTITION_TYPE, cl::vector<cl_device_partition_property>) \ 1265 F(cl_device_info, CL_DEVICE_REFERENCE_COUNT, cl_uint) \ 1266 F(cl_device_info, CL_DEVICE_PREFERRED_INTEROP_USER_SYNC, size_type) \ 1267 F(cl_device_info, CL_DEVICE_PARTITION_AFFINITY_DOMAIN, cl_device_affinity_domain) \ 1268 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS, string) \ 1270 F(cl_image_info, CL_IMAGE_ARRAY_SIZE, size_type) \ 1271 F(cl_image_info, CL_IMAGE_NUM_MIP_LEVELS, cl_uint) \ 1272 F(cl_image_info, CL_IMAGE_NUM_SAMPLES, cl_uint) 1274 #define CL_HPP_PARAM_NAME_INFO_2_0_(F) \ 1275 F(cl_device_info, CL_DEVICE_QUEUE_ON_HOST_PROPERTIES, cl_command_queue_properties) \ 1276 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES, cl_command_queue_properties) \ 1277 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE, cl_uint) \ 1278 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE, cl_uint) \ 1279 F(cl_device_info, CL_DEVICE_MAX_ON_DEVICE_QUEUES, cl_uint) \ 1280 F(cl_device_info, CL_DEVICE_MAX_ON_DEVICE_EVENTS, cl_uint) \ 1281 F(cl_device_info, CL_DEVICE_MAX_PIPE_ARGS, cl_uint) \ 1282 F(cl_device_info, CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS, cl_uint) \ 1283 F(cl_device_info, CL_DEVICE_PIPE_MAX_PACKET_SIZE, cl_uint) \ 1284 F(cl_device_info, CL_DEVICE_SVM_CAPABILITIES, cl_device_svm_capabilities) \ 1285 F(cl_device_info, CL_DEVICE_PREFERRED_PLATFORM_ATOMIC_ALIGNMENT, cl_uint) \ 1286 F(cl_device_info, CL_DEVICE_PREFERRED_GLOBAL_ATOMIC_ALIGNMENT, cl_uint) \ 1287 F(cl_device_info, CL_DEVICE_PREFERRED_LOCAL_ATOMIC_ALIGNMENT, cl_uint) \ 1288 F(cl_command_queue_info, CL_QUEUE_SIZE, cl_uint) \ 1289 F(cl_mem_info, CL_MEM_USES_SVM_POINTER, cl_bool) \ 1290 F(cl_program_build_info, CL_PROGRAM_BUILD_GLOBAL_VARIABLE_TOTAL_SIZE, size_type) \ 1291 F(cl_pipe_info, CL_PIPE_PACKET_SIZE, cl_uint) \ 1292 F(cl_pipe_info, CL_PIPE_MAX_PACKETS, cl_uint) 1294 #define CL_HPP_PARAM_NAME_DEVICE_FISSION_(F) \ 1295 F(cl_device_info, CL_DEVICE_PARENT_DEVICE_EXT, cl_device_id) \ 1296 F(cl_device_info, CL_DEVICE_PARTITION_TYPES_EXT, cl::vector<cl_device_partition_property_ext>) \ 1297 F(cl_device_info, CL_DEVICE_AFFINITY_DOMAINS_EXT, cl::vector<cl_device_partition_property_ext>) \ 1298 F(cl_device_info, CL_DEVICE_REFERENCE_COUNT_EXT , cl_uint) \ 1299 F(cl_device_info, CL_DEVICE_PARTITION_STYLE_EXT, cl::vector<cl_device_partition_property_ext>) 1301 template <
typename enum_type, cl_
int Name>
1304 #define CL_HPP_DECLARE_PARAM_TRAITS_(token, param_name, T) \ 1307 struct param_traits<detail:: token,param_name> \ 1309 enum { value = param_name }; \ 1310 typedef T param_type; \ 1313 CL_HPP_PARAM_NAME_INFO_1_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1314 #if CL_HPP_TARGET_OPENCL_VERSION >= 110 1315 CL_HPP_PARAM_NAME_INFO_1_1_(CL_HPP_DECLARE_PARAM_TRAITS_)
1316 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110 1317 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 1318 CL_HPP_PARAM_NAME_INFO_1_2_(CL_HPP_DECLARE_PARAM_TRAITS_)
1319 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110 1320 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 1321 CL_HPP_PARAM_NAME_INFO_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1322 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110 1326 #define CL_HPP_PARAM_NAME_INFO_1_0_DEPRECATED_IN_2_0_(F) \ 1327 F(cl_device_info, CL_DEVICE_QUEUE_PROPERTIES, cl_command_queue_properties) 1329 #define CL_HPP_PARAM_NAME_INFO_1_1_DEPRECATED_IN_2_0_(F) \ 1330 F(cl_device_info, CL_DEVICE_HOST_UNIFIED_MEMORY, cl_bool) 1332 #define CL_HPP_PARAM_NAME_INFO_1_2_DEPRECATED_IN_2_0_(F) \ 1333 F(cl_image_info, CL_IMAGE_BUFFER, cl::Buffer) 1337 #if CL_HPP_TARGET_OPENCL_VERSION > 100 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 && CL_HPP_TARGET_OPENCL_VERSION < 200 1338 CL_HPP_PARAM_NAME_INFO_1_0_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1339 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 110 1340 #if CL_HPP_TARGET_OPENCL_VERSION > 110 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 1341 CL_HPP_PARAM_NAME_INFO_1_1_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1342 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 120 1343 #if CL_HPP_TARGET_OPENCL_VERSION > 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 1344 CL_HPP_PARAM_NAME_INFO_1_2_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1345 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 200 1347 #if defined(CL_HPP_USE_CL_DEVICE_FISSION) 1348 CL_HPP_PARAM_NAME_DEVICE_FISSION_(CL_HPP_DECLARE_PARAM_TRAITS_);
1349 #endif // CL_HPP_USE_CL_DEVICE_FISSION 1351 #ifdef CL_PLATFORM_ICD_SUFFIX_KHR 1352 CL_HPP_DECLARE_PARAM_TRAITS_(cl_platform_info, CL_PLATFORM_ICD_SUFFIX_KHR,
string)
1355 #ifdef CL_DEVICE_PROFILING_TIMER_OFFSET_AMD 1356 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_PROFILING_TIMER_OFFSET_AMD, cl_ulong)
1359 #ifdef CL_DEVICE_GLOBAL_FREE_MEMORY_AMD 1360 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_FREE_MEMORY_AMD, vector<size_type>)
1362 #ifdef CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD 1363 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD, cl_uint)
1365 #ifdef CL_DEVICE_SIMD_WIDTH_AMD 1366 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_WIDTH_AMD, cl_uint)
1368 #ifdef CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD 1369 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD, cl_uint)
1371 #ifdef CL_DEVICE_WAVEFRONT_WIDTH_AMD 1372 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_WAVEFRONT_WIDTH_AMD, cl_uint)
1374 #ifdef CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD 1375 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD, cl_uint)
1377 #ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD 1378 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD, cl_uint)
1380 #ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD 1381 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD, cl_uint)
1383 #ifdef CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD 1384 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD, cl_uint)
1386 #ifdef CL_DEVICE_LOCAL_MEM_BANKS_AMD 1387 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LOCAL_MEM_BANKS_AMD, cl_uint)
1390 #ifdef CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV 1391 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV, cl_uint)
1393 #ifdef CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV 1394 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV, cl_uint)
1396 #ifdef CL_DEVICE_REGISTERS_PER_BLOCK_NV 1397 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_REGISTERS_PER_BLOCK_NV, cl_uint)
1399 #ifdef CL_DEVICE_WARP_SIZE_NV 1400 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_WARP_SIZE_NV, cl_uint)
1402 #ifdef CL_DEVICE_GPU_OVERLAP_NV 1403 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GPU_OVERLAP_NV, cl_bool)
1405 #ifdef CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV 1406 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV, cl_bool)
1408 #ifdef CL_DEVICE_INTEGRATED_MEMORY_NV 1409 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGRATED_MEMORY_NV, cl_bool)
1414 template <
typename Func,
typename T>
1416 getInfo(Func f, cl_uint name, T* param)
1418 return getInfoHelper(f, name, param, 0);
1421 template <
typename Func,
typename Arg0>
1424 Func f_;
const Arg0& arg0_;
1426 cl_uint param, size_type size,
void* value, size_type* size_ret)
1427 {
return f_(arg0_, param, size, value, size_ret); }
1430 template <
typename Func,
typename Arg0,
typename Arg1>
1433 Func f_;
const Arg0& arg0_;
const Arg1& arg1_;
1435 cl_uint param, size_type size,
void* value, size_type* size_ret)
1436 {
return f_(arg0_, arg1_, param, size, value, size_ret); }
1439 template <
typename Func,
typename Arg0,
typename T>
1441 getInfo(Func f,
const Arg0& arg0, cl_uint name, T* param)
1444 return getInfoHelper(f0, name, param, 0);
1447 template <
typename Func,
typename Arg0,
typename Arg1,
typename T>
1449 getInfo(Func f,
const Arg0& arg0,
const Arg1& arg1, cl_uint name, T* param)
1452 return getInfoHelper(f0, name, param, 0);
1456 template<
typename T>
1460 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 1477 { return ::clRetainDevice(device); }
1488 { return ::clReleaseDevice(device); }
1490 #else // CL_HPP_TARGET_OPENCL_VERSION >= 120 1498 static cl_int retain(cl_device_id)
1499 {
return CL_SUCCESS; }
1501 static cl_int release(cl_device_id)
1502 {
return CL_SUCCESS; }
1504 #endif // ! (CL_HPP_TARGET_OPENCL_VERSION >= 120) 1510 static cl_int retain(cl_platform_id)
1511 {
return CL_SUCCESS; }
1513 static cl_int release(cl_platform_id)
1514 {
return CL_SUCCESS; }
1520 static cl_int retain(cl_context context)
1521 { return ::clRetainContext(context); }
1522 static cl_int release(cl_context context)
1523 { return ::clReleaseContext(context); }
1529 static cl_int retain(cl_command_queue queue)
1530 { return ::clRetainCommandQueue(queue); }
1531 static cl_int release(cl_command_queue queue)
1532 { return ::clReleaseCommandQueue(queue); }
1538 static cl_int retain(cl_mem memory)
1539 { return ::clRetainMemObject(memory); }
1540 static cl_int release(cl_mem memory)
1541 { return ::clReleaseMemObject(memory); }
1547 static cl_int retain(cl_sampler sampler)
1548 { return ::clRetainSampler(sampler); }
1549 static cl_int release(cl_sampler sampler)
1550 { return ::clReleaseSampler(sampler); }
1556 static cl_int retain(cl_program program)
1557 { return ::clRetainProgram(program); }
1558 static cl_int release(cl_program program)
1559 { return ::clReleaseProgram(program); }
1565 static cl_int retain(cl_kernel kernel)
1566 { return ::clRetainKernel(kernel); }
1567 static cl_int release(cl_kernel kernel)
1568 { return ::clReleaseKernel(kernel); }
1574 static cl_int retain(cl_event event)
1575 { return ::clRetainEvent(event); }
1576 static cl_int release(cl_event event)
1577 { return ::clReleaseEvent(event); }
1581 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120 1583 static cl_uint getVersion(
const vector<char> &versionInfo)
1585 int highVersion = 0;
1588 while(versionInfo[index] !=
'.' ) {
1590 highVersion += versionInfo[index]-
'0';
1594 while(versionInfo[index] !=
' ' && versionInfo[index] !=
'\0') {
1596 lowVersion += versionInfo[index]-
'0';
1599 return (highVersion << 16) | lowVersion;
1602 static cl_uint getPlatformVersion(cl_platform_id platform)
1605 clGetPlatformInfo(platform, CL_PLATFORM_VERSION, 0, NULL, &size);
1607 vector<char> versionInfo(size);
1608 clGetPlatformInfo(platform, CL_PLATFORM_VERSION, size, versionInfo.data(), &size);
1609 return getVersion(versionInfo);
1612 static cl_uint getDevicePlatformVersion(cl_device_id device)
1614 cl_platform_id platform;
1615 clGetDeviceInfo(device, CL_DEVICE_PLATFORM,
sizeof(platform), &platform, NULL);
1616 return getPlatformVersion(platform);
1619 static cl_uint getContextPlatformVersion(cl_context context)
1624 clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, NULL, &size);
1627 vector<cl_device_id> devices(size/
sizeof(cl_device_id));
1628 clGetContextInfo(context, CL_CONTEXT_DEVICES, size, devices.data(), NULL);
1629 return getDevicePlatformVersion(devices[0]);
1631 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120 1633 template <
typename T>
1645 Wrapper(
const cl_type &obj,
bool retainObject) : object_(obj)
1648 detail::errHandler(retain(), __RETAIN_ERR);
1654 if (object_ != NULL) { release(); }
1659 object_ = rhs.object_;
1660 detail::errHandler(retain(), __RETAIN_ERR);
1665 object_ = rhs.object_;
1672 detail::errHandler(release(), __RELEASE_ERR);
1673 object_ = rhs.object_;
1674 detail::errHandler(retain(), __RETAIN_ERR);
1682 detail::errHandler(release(), __RELEASE_ERR);
1683 object_ = rhs.object_;
1691 detail::errHandler(release(), __RELEASE_ERR);
1696 const cl_type& operator ()()
const {
return object_; }
1698 cl_type& operator ()() {
return object_; }
1700 const cl_type
get()
const {
return object_; }
1702 cl_type
get() {
return object_; }
1706 template<
typename Func,
typename U>
1707 friend inline cl_int getInfoHelper(Func, cl_uint, U*,
int,
typename U::cl_type);
1709 cl_int retain()
const 1711 if (object_ !=
nullptr) {
1719 cl_int release()
const 1721 if (object_ !=
nullptr) {
1734 typedef cl_device_id cl_type;
1738 bool referenceCountable_;
1740 static bool isReferenceCountable(cl_device_id device)
1742 bool retVal =
false;
1743 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 1744 #if CL_HPP_MINIMUM_OPENCL_VERSION < 120 1745 if (device != NULL) {
1746 int version = getDevicePlatformVersion(device);
1747 if(version > ((1 << 16) + 1)) {
1751 #else // CL_HPP_MINIMUM_OPENCL_VERSION < 120 1753 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 120 1754 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 1759 Wrapper() : object_(NULL), referenceCountable_(
false)
1763 Wrapper(
const cl_type &obj,
bool retainObject) :
1765 referenceCountable_(
false)
1767 referenceCountable_ = isReferenceCountable(obj);
1770 detail::errHandler(retain(), __RETAIN_ERR);
1781 object_ = rhs.object_;
1782 referenceCountable_ = isReferenceCountable(object_);
1783 detail::errHandler(retain(), __RETAIN_ERR);
1788 object_ = rhs.object_;
1789 referenceCountable_ = rhs.referenceCountable_;
1791 rhs.referenceCountable_ =
false;
1797 detail::errHandler(release(), __RELEASE_ERR);
1798 object_ = rhs.object_;
1799 referenceCountable_ = rhs.referenceCountable_;
1800 detail::errHandler(retain(), __RETAIN_ERR);
1808 detail::errHandler(release(), __RELEASE_ERR);
1809 object_ = rhs.object_;
1810 referenceCountable_ = rhs.referenceCountable_;
1812 rhs.referenceCountable_ =
false;
1819 detail::errHandler(release(), __RELEASE_ERR);
1821 referenceCountable_ = isReferenceCountable(object_);
1825 const cl_type& operator ()()
const {
return object_; }
1827 cl_type& operator ()() {
return object_; }
1829 const cl_type
get()
const {
return object_; }
1831 cl_type
get() {
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_);
2061 Device(
Device&& dev) CL_HPP_NOEXCEPT_ : detail::Wrapper<cl_type>(std::move(dev)) {}
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);
2802 Context(
Context&& ctx) CL_HPP_NOEXCEPT_ : detail::Wrapper<cl_type>(std::move(ctx)) {}
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) { }
3209 Memory(
Memory&& mem) CL_HPP_NOEXCEPT_ : detail::Wrapper<cl_type>(std::move(mem)) {}
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);
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 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 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) { }
5490 Sampler(
Sampler&& sam) CL_HPP_NOEXCEPT_ : detail::Wrapper<cl_type>(std::move(sam)) {}
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) { }
5715 Kernel(
Kernel&& kernel) CL_HPP_NOEXCEPT_ : detail::Wrapper<cl_type>(std::move(kernel)) {}
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... Ts>
5929 void setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList,
const pointer<T0, D> &t0, Ts... ts)
5931 pointerList[index] =
static_cast<void*
>(t0.get());
5932 setSVMPointersHelper<index + 1, Ts...>(ts...);
5935 template<
int index,
int ArrayLength,
typename T0,
typename... Ts>
5936 typename std::enable_if<std::is_pointer<T0>::value,
void>::type
5937 setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList, T0 t0, Ts... ts)
5939 pointerList[index] =
static_cast<void*
>(t0);
5940 setSVMPointersHelper<index + 1, Ts...>(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());
5949 template<
int index,
int ArrayLength,
typename T0>
5950 typename std::enable_if<std::is_pointer<T0>::value,
void>::type
5951 setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList, T0 t0)
5953 pointerList[index] =
static_cast<void*
>(t0);
5956 template<
typename T0,
typename... Ts>
5957 cl_int setSVMPointers(
const T0 &t0, Ts... ts)
5959 std::array<
void*, 1 +
sizeof...(Ts)> pointerList;
5961 setSVMPointersHelper<0, 1 +
sizeof...(Ts)>(pointerList, t0, ts...);
5962 return detail::errHandler(
5963 ::clSetKernelExecInfo(
5965 CL_KERNEL_EXEC_INFO_SVM_PTRS,
5966 sizeof(
void*)*(1 +
sizeof...(Ts)),
5967 pointerList.data()));
5969 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 5978 #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 5979 typedef vector<vector<unsigned char>> Binaries;
5980 typedef vector<string> Sources;
5981 #else // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 5982 typedef vector<std::pair<const void*, size_type> > Binaries;
5983 typedef vector<std::pair<const char*, size_type> > Sources;
5984 #endif // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 5987 const string& source,
5993 const char * strings = source.c_str();
5994 const size_type length = source.size();
5998 object_ = ::clCreateProgramWithSource(
5999 context(), (cl_uint)1, &strings, &length, &error);
6001 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6003 if (error == CL_SUCCESS && build) {
6005 error = ::clBuildProgram(
6009 #
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6017 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6027 const string& source,
6033 const char * strings = source.c_str();
6034 const size_type length = source.size();
6036 object_ = ::clCreateProgramWithSource(
6037 context(), (cl_uint)1, &strings, &length, &error);
6039 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6041 if (error == CL_SUCCESS && build) {
6042 error = ::clBuildProgram(
6046 #
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6054 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6067 const Sources& sources,
6073 const size_type n = (size_type)sources.size();
6075 vector<size_type> lengths(n);
6076 vector<const char*> strings(n);
6078 for (size_type i = 0; i < n; ++i) {
6079 #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 6080 strings[i] = sources[(int)i].data();
6081 lengths[i] = sources[(int)i].length();
6082 #else // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 6083 strings[i] = sources[(int)i].first;
6084 lengths[i] = sources[(int)i].second;
6085 #endif // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 6088 object_ = ::clCreateProgramWithSource(
6089 context(), (cl_uint)n, strings.data(), lengths.data(), &error);
6091 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6103 const Sources& sources,
6108 const size_type n = (size_type)sources.size();
6110 vector<size_type> lengths(n);
6111 vector<const char*> strings(n);
6113 for (size_type i = 0; i < n; ++i) {
6114 #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 6115 strings[i] = sources[(int)i].data();
6116 lengths[i] = sources[(int)i].length();
6117 #else // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 6118 strings[i] = sources[(int)i].first;
6119 lengths[i] = sources[(int)i].second;
6120 #endif // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 6123 object_ = ::clCreateProgramWithSource(
6124 context(), (cl_uint)n, strings.data(), lengths.data(), &error);
6126 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6153 const vector<Device>& devices,
6154 const Binaries& binaries,
6155 vector<cl_int>* binaryStatus = NULL,
6160 const size_type numDevices = devices.size();
6163 if(binaries.size() != numDevices) {
6164 error = CL_INVALID_VALUE;
6165 detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
6173 vector<size_type> lengths(numDevices);
6174 vector<const unsigned char*> images(numDevices);
6175 #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 6176 for (size_type i = 0; i < numDevices; ++i) {
6177 images[i] = binaries[i].data();
6178 lengths[i] = binaries[(int)i].size();
6180 #else // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 6181 for (size_type i = 0; i < numDevices; ++i) {
6182 images[i] = (
const unsigned char*)binaries[i].first;
6183 lengths[i] = binaries[(int)i].second;
6185 #endif // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 6187 vector<cl_device_id> deviceIDs(numDevices);
6188 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6189 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6193 binaryStatus->resize(numDevices);
6196 object_ = ::clCreateProgramWithBinary(
6197 context(), (cl_uint) devices.size(),
6199 lengths.data(), images.data(), (binaryStatus != NULL && numDevices > 0)
6200 ? &binaryStatus->front()
6203 detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
6210 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 6217 const vector<Device>& devices,
6218 const string& kernelNames,
6224 size_type numDevices = devices.size();
6225 vector<cl_device_id> deviceIDs(numDevices);
6226 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6227 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6230 object_ = ::clCreateProgramWithBuiltInKernels(
6232 (cl_uint) devices.size(),
6234 kernelNames.c_str(),
6237 detail::errHandler(error, __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR);
6242 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 6253 explicit Program(
const cl_program& program,
bool retainObject =
false) :
6254 detail::Wrapper<cl_type>(program, retainObject) { }
6256 Program& operator = (
const cl_program& rhs)
6279 Program(
Program&& program) CL_HPP_NOEXCEPT_ : detail::Wrapper<cl_type>(std::move(program)) {}
6291 const vector<Device>& devices,
6292 const char* options = NULL,
6293 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6294 void* data = NULL)
const 6296 size_type numDevices = devices.size();
6297 vector<cl_device_id> deviceIDs(numDevices);
6299 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6300 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6303 cl_int buildError = ::clBuildProgram(
6312 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6316 const char* options = NULL,
6317 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6318 void* data = NULL)
const 6320 cl_int buildError = ::clBuildProgram(
6329 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6332 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 6334 const char* options = NULL,
6335 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6336 void* data = NULL)
const 6338 cl_int error = ::clCompileProgram(
6348 return detail::buildErrHandler(error, __COMPILE_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6350 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 6352 template <
typename T>
6353 cl_int getInfo(cl_program_info name, T* param)
const 6355 return detail::errHandler(
6356 detail::getInfo(&::clGetProgramInfo, object_, name, param),
6357 __GET_PROGRAM_INFO_ERR);
6360 template <cl_
int name>
typename 6362 getInfo(cl_int* err = NULL)
const 6365 detail::cl_program_info, name>::param_type param;
6366 cl_int result = getInfo(name, ¶m);
6373 template <
typename T>
6374 cl_int getBuildInfo(
6375 const Device& device, cl_program_build_info name, T* param)
const 6377 return detail::errHandler(
6379 &::clGetProgramBuildInfo, object_, device(), name, param),
6380 __GET_PROGRAM_BUILD_INFO_ERR);
6383 template <cl_
int name>
typename 6385 getBuildInfo(
const Device& device, cl_int* err = NULL)
const 6388 detail::cl_program_build_info, name>::param_type param;
6389 cl_int result = getBuildInfo(device, name, ¶m);
6401 template <cl_
int name>
6402 vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, name>::param_type>>
6405 cl_int result = CL_SUCCESS;
6407 auto devs = getInfo<CL_PROGRAM_DEVICES>(&result);
6408 vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, name>::param_type>>
6412 if (result != CL_SUCCESS) {
6421 detail::cl_program_build_info, name>::param_type param;
6422 result = getBuildInfo(d, name, ¶m);
6426 if (result != CL_SUCCESS) {
6434 if (result != CL_SUCCESS) {
6440 cl_int createKernels(vector<Kernel>* kernels)
6443 cl_int err = ::clCreateKernelsInProgram(object_, 0, NULL, &numKernels);
6444 if (err != CL_SUCCESS) {
6445 return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
6448 vector<cl_kernel> value(numKernels);
6450 err = ::clCreateKernelsInProgram(
6451 object_, numKernels, value.data(), NULL);
6452 if (err != CL_SUCCESS) {
6453 return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
6457 kernels->resize(value.size());
6461 for (size_type i = 0; i < value.size(); i++) {
6464 (*kernels)[i] =
Kernel(value[i],
false);
6471 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 6475 const char* options = NULL,
6476 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6480 cl_int error_local = CL_SUCCESS;
6482 cl_program programs[2] = { input1(), input2() };
6484 Context ctx = input1.getInfo<CL_PROGRAM_CONTEXT>(&error_local);
6485 if(error_local!=CL_SUCCESS) {
6486 detail::errHandler(error_local, __LINK_PROGRAM_ERR);
6489 cl_program prog = ::clLinkProgram(
6500 detail::errHandler(error_local,__COMPILE_PROGRAM_ERR);
6509 vector<Program> inputPrograms,
6510 const char* options = NULL,
6511 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6515 cl_int error_local = CL_SUCCESS;
6517 vector<cl_program> programs(inputPrograms.size());
6519 for (
unsigned int i = 0; i < inputPrograms.size(); i++) {
6520 programs[i] = inputPrograms[i]();
6524 if(inputPrograms.size() > 0) {
6525 ctx = inputPrograms[0].
getInfo<CL_PROGRAM_CONTEXT>(&error_local);
6526 if(error_local!=CL_SUCCESS) {
6527 detail::errHandler(error_local, __LINK_PROGRAM_ERR);
6530 cl_program prog = ::clLinkProgram(
6535 (cl_uint)inputPrograms.size(),
6541 detail::errHandler(error_local,__COMPILE_PROGRAM_ERR);
6548 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 6552 inline cl_int cl::Program::getInfo(cl_program_info name, vector<vector<unsigned char>>* param)
const 6554 if (name != CL_PROGRAM_BINARIES) {
6555 return CL_INVALID_VALUE;
6561 vector<size_type> sizes = getInfo<CL_PROGRAM_BINARY_SIZES>();
6562 size_type numBinaries = sizes.size();
6565 param->resize(numBinaries);
6566 for (size_type i = 0; i < numBinaries; ++i) {
6567 (*param)[i].resize(sizes[i]);
6570 return detail::errHandler(
6571 detail::getInfo(&::clGetProgramInfo, object_, name, param),
6572 __GET_PROGRAM_INFO_ERR);
6579 inline vector<vector<unsigned char>> cl::Program::getInfo<CL_PROGRAM_BINARIES>(cl_int* err)
const 6581 vector<vector<unsigned char>> binariesVectors;
6583 cl_int result = getInfo(CL_PROGRAM_BINARIES, &binariesVectors);
6587 return binariesVectors;
6594 object_ = ::clCreateKernel(program(), name, &error);
6595 detail::errHandler(error, __CREATE_KERNEL_ERR);
6603 enum class QueueProperties : cl_command_queue_properties
6606 Profiling = CL_QUEUE_PROFILING_ENABLE,
6607 OutOfOrder = CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE,
6610 inline QueueProperties operator|(QueueProperties lhs, QueueProperties rhs)
6612 return static_cast<QueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) | static_cast<cl_command_queue_properties>(rhs));
6621 static std::once_flag default_initialized_;
6623 static cl_int default_error_;
6630 static void makeDefault()
6635 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 6642 if (error != CL_SUCCESS) {
6643 default_error_ = error;
6647 default_ =
CommandQueue(context, device, 0, &default_error_);
6650 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 6651 catch (cl::Error &e) {
6652 default_error_ = e.err();
6662 static void makeDefaultProvided(
const CommandQueue &c) {
6667 #ifdef CL_HPP_UNIT_TEST_ENABLE 6674 static void unitTestClearDefault() {
6677 #endif // #ifdef CL_HPP_UNIT_TEST_ENABLE 6685 cl_command_queue_properties properties,
6691 detail::errHandler(error, __CREATE_CONTEXT_ERR);
6693 if (error != CL_SUCCESS) {
6701 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 6702 cl_queue_properties queue_properties[] = {
6703 CL_QUEUE_PROPERTIES, properties, 0 };
6704 if ((properties & CL_QUEUE_ON_DEVICE) == 0) {
6705 object_ = ::clCreateCommandQueueWithProperties(
6706 context(), device(), queue_properties, &error);
6709 error = CL_INVALID_QUEUE_PROPERTIES;
6712 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
6717 object_ = ::clCreateCommandQueue(
6718 context(), device(), properties, &error);
6720 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
6733 QueueProperties properties,
6739 detail::errHandler(error, __CREATE_CONTEXT_ERR);
6741 if (error != CL_SUCCESS) {
6749 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 6750 cl_queue_properties queue_properties[] = {
6751 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
6753 object_ = ::clCreateCommandQueueWithProperties(
6754 context(), device(), queue_properties, &error);
6757 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
6762 object_ = ::clCreateCommandQueue(
6763 context(), device(), static_cast<cl_command_queue_properties>(properties), &error);
6765 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
6779 cl_command_queue_properties properties = 0,
6783 vector<cl::Device> devices;
6784 error = context.
getInfo(CL_CONTEXT_DEVICES, &devices);
6786 detail::errHandler(error, __CREATE_CONTEXT_ERR);
6788 if (error != CL_SUCCESS)
6796 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 6797 cl_queue_properties queue_properties[] = {
6798 CL_QUEUE_PROPERTIES, properties, 0 };
6799 if ((properties & CL_QUEUE_ON_DEVICE) == 0) {
6800 object_ = ::clCreateCommandQueueWithProperties(
6801 context(), devices[0](), queue_properties, &error);
6804 error = CL_INVALID_QUEUE_PROPERTIES;
6807 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
6812 object_ = ::clCreateCommandQueue(
6813 context(), devices[0](), properties, &error);
6815 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
6829 QueueProperties properties,
6833 vector<cl::Device> devices;
6834 error = context.
getInfo(CL_CONTEXT_DEVICES, &devices);
6836 detail::errHandler(error, __CREATE_CONTEXT_ERR);
6838 if (error != CL_SUCCESS)
6846 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 6847 cl_queue_properties queue_properties[] = {
6848 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
6849 object_ = ::clCreateCommandQueueWithProperties(
6850 context(), devices[0](), queue_properties, &error);
6852 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
6857 object_ = ::clCreateCommandQueue(
6858 context(), devices[0](), static_cast<cl_command_queue_properties>(properties), &error);
6860 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
6875 cl_command_queue_properties properties = 0,
6880 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 6881 cl_queue_properties queue_properties[] = {
6882 CL_QUEUE_PROPERTIES, properties, 0 };
6883 object_ = ::clCreateCommandQueueWithProperties(
6884 context(), device(), queue_properties, &error);
6886 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
6891 object_ = ::clCreateCommandQueue(
6892 context(), device(), properties, &error);
6894 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
6908 QueueProperties properties,
6913 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 6914 cl_queue_properties queue_properties[] = {
6915 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
6916 object_ = ::clCreateCommandQueueWithProperties(
6917 context(), device(), queue_properties, &error);
6919 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
6924 object_ = ::clCreateCommandQueue(
6925 context(), device(), static_cast<cl_command_queue_properties>(properties), &error);
6927 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
6936 std::call_once(default_initialized_, makeDefault);
6937 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 6938 detail::errHandler(default_error_, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
6939 #else // CL_HPP_TARGET_OPENCL_VERSION >= 200 6940 detail::errHandler(default_error_, __CREATE_COMMAND_QUEUE_ERR);
6941 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200 6943 *err = default_error_;
6957 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_queue));
6958 detail::errHandler(default_error_);
6971 explicit CommandQueue(
const cl_command_queue& commandQueue,
bool retainObject =
false) :
6972 detail::Wrapper<cl_type>(commandQueue, retainObject) { }
7008 template <
typename T>
7009 cl_int getInfo(cl_command_queue_info name, T* param)
const 7011 return detail::errHandler(
7013 &::clGetCommandQueueInfo, object_, name, param),
7014 __GET_COMMAND_QUEUE_INFO_ERR);
7017 template <cl_
int name>
typename 7019 getInfo(cl_int* err = NULL)
const 7022 detail::cl_command_queue_info, name>::param_type param;
7023 cl_int result = getInfo(name, ¶m);
7030 cl_int enqueueReadBuffer(
7036 const vector<Event>* events = NULL,
7037 Event* event = NULL)
const 7040 cl_int err = detail::errHandler(
7041 ::clEnqueueReadBuffer(
7042 object_, buffer(), blocking, offset, size,
7044 (events != NULL) ? (cl_uint) events->size() : 0,
7045 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7046 (
event != NULL) ? &tmp : NULL),
7047 __ENQUEUE_READ_BUFFER_ERR);
7049 if (event != NULL && err == CL_SUCCESS)
7055 cl_int enqueueWriteBuffer(
7061 const vector<Event>* events = NULL,
7062 Event* event = NULL)
const 7065 cl_int err = detail::errHandler(
7066 ::clEnqueueWriteBuffer(
7067 object_, buffer(), blocking, offset, size,
7069 (events != NULL) ? (cl_uint) events->size() : 0,
7070 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7071 (
event != NULL) ? &tmp : NULL),
7072 __ENQUEUE_WRITE_BUFFER_ERR);
7074 if (event != NULL && err == CL_SUCCESS)
7080 cl_int enqueueCopyBuffer(
7083 size_type src_offset,
7084 size_type dst_offset,
7086 const vector<Event>* events = NULL,
7087 Event* event = NULL)
const 7090 cl_int err = detail::errHandler(
7091 ::clEnqueueCopyBuffer(
7092 object_, src(), dst(), src_offset, dst_offset, size,
7093 (events != NULL) ? (cl_uint) events->size() : 0,
7094 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7095 (
event != NULL) ? &tmp : NULL),
7096 __ENQEUE_COPY_BUFFER_ERR);
7098 if (event != NULL && err == CL_SUCCESS)
7104 cl_int enqueueReadBufferRect(
7107 const array<size_type, 3>& buffer_offset,
7108 const array<size_type, 3>& host_offset,
7109 const array<size_type, 3>& region,
7110 size_type buffer_row_pitch,
7111 size_type buffer_slice_pitch,
7112 size_type host_row_pitch,
7113 size_type host_slice_pitch,
7115 const vector<Event>* events = NULL,
7116 Event* event = NULL)
const 7119 cl_int err = detail::errHandler(
7120 ::clEnqueueReadBufferRect(
7124 buffer_offset.data(),
7132 (events != NULL) ? (cl_uint) events->size() : 0,
7133 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7134 (
event != NULL) ? &tmp : NULL),
7135 __ENQUEUE_READ_BUFFER_RECT_ERR);
7137 if (event != NULL && err == CL_SUCCESS)
7143 cl_int enqueueWriteBufferRect(
7146 const array<size_type, 3>& buffer_offset,
7147 const array<size_type, 3>& host_offset,
7148 const array<size_type, 3>& region,
7149 size_type buffer_row_pitch,
7150 size_type buffer_slice_pitch,
7151 size_type host_row_pitch,
7152 size_type host_slice_pitch,
7154 const vector<Event>* events = NULL,
7155 Event* event = NULL)
const 7158 cl_int err = detail::errHandler(
7159 ::clEnqueueWriteBufferRect(
7163 buffer_offset.data(),
7171 (events != NULL) ? (cl_uint) events->size() : 0,
7172 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7173 (
event != NULL) ? &tmp : NULL),
7174 __ENQUEUE_WRITE_BUFFER_RECT_ERR);
7176 if (event != NULL && err == CL_SUCCESS)
7182 cl_int enqueueCopyBufferRect(
7185 const array<size_type, 3>& src_origin,
7186 const array<size_type, 3>& dst_origin,
7187 const array<size_type, 3>& region,
7188 size_type src_row_pitch,
7189 size_type src_slice_pitch,
7190 size_type dst_row_pitch,
7191 size_type dst_slice_pitch,
7192 const vector<Event>* events = NULL,
7193 Event* event = NULL)
const 7196 cl_int err = detail::errHandler(
7197 ::clEnqueueCopyBufferRect(
7208 (events != NULL) ? (cl_uint) events->size() : 0,
7209 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7210 (
event != NULL) ? &tmp : NULL),
7211 __ENQEUE_COPY_BUFFER_RECT_ERR);
7213 if (event != NULL && err == CL_SUCCESS)
7219 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 7231 template<
typename PatternType>
7234 PatternType pattern,
7237 const vector<Event>* events = NULL,
7238 Event* event = NULL)
const 7241 cl_int err = detail::errHandler(
7242 ::clEnqueueFillBuffer(
7245 static_cast<void*>(&pattern),
7246 sizeof(PatternType),
7249 (events != NULL) ? (cl_uint) events->size() : 0,
7250 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7251 (
event != NULL) ? &tmp : NULL),
7252 __ENQUEUE_FILL_BUFFER_ERR);
7254 if (event != NULL && err == CL_SUCCESS)
7259 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 7261 cl_int enqueueReadImage(
7264 const array<size_type, 3>& origin,
7265 const array<size_type, 3>& region,
7266 size_type row_pitch,
7267 size_type slice_pitch,
7269 const vector<Event>* events = NULL,
7270 Event* event = NULL)
const 7273 cl_int err = detail::errHandler(
7274 ::clEnqueueReadImage(
7283 (events != NULL) ? (cl_uint) events->size() : 0,
7284 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7285 (
event != NULL) ? &tmp : NULL),
7286 __ENQUEUE_READ_IMAGE_ERR);
7288 if (event != NULL && err == CL_SUCCESS)
7294 cl_int enqueueWriteImage(
7297 const array<size_type, 3>& origin,
7298 const array<size_type, 3>& region,
7299 size_type row_pitch,
7300 size_type slice_pitch,
7302 const vector<Event>* events = NULL,
7303 Event* event = NULL)
const 7306 cl_int err = detail::errHandler(
7307 ::clEnqueueWriteImage(
7316 (events != NULL) ? (cl_uint) events->size() : 0,
7317 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7318 (
event != NULL) ? &tmp : NULL),
7319 __ENQUEUE_WRITE_IMAGE_ERR);
7321 if (event != NULL && err == CL_SUCCESS)
7327 cl_int enqueueCopyImage(
7330 const array<size_type, 3>& src_origin,
7331 const array<size_type, 3>& dst_origin,
7332 const array<size_type, 3>& region,
7333 const vector<Event>* events = NULL,
7334 Event* event = NULL)
const 7337 cl_int err = detail::errHandler(
7338 ::clEnqueueCopyImage(
7345 (events != NULL) ? (cl_uint) events->size() : 0,
7346 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7347 (
event != NULL) ? &tmp : NULL),
7348 __ENQUEUE_COPY_IMAGE_ERR);
7350 if (event != NULL && err == CL_SUCCESS)
7356 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 7366 cl_float4 fillColor,
7367 const array<size_type, 3>& origin,
7368 const array<size_type, 3>& region,
7369 const vector<Event>* events = NULL,
7370 Event* event = NULL)
const 7373 cl_int err = detail::errHandler(
7374 ::clEnqueueFillImage(
7377 static_cast<void*>(&fillColor),
7380 (events != NULL) ? (cl_uint) events->size() : 0,
7381 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7382 (
event != NULL) ? &tmp : NULL),
7383 __ENQUEUE_FILL_IMAGE_ERR);
7385 if (event != NULL && err == CL_SUCCESS)
7401 const array<size_type, 3>& origin,
7402 const array<size_type, 3>& region,
7403 const vector<Event>* events = NULL,
7404 Event* event = NULL)
const 7407 cl_int err = detail::errHandler(
7408 ::clEnqueueFillImage(
7411 static_cast<void*>(&fillColor),
7414 (events != NULL) ? (cl_uint) events->size() : 0,
7415 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7416 (
event != NULL) ? &tmp : NULL),
7417 __ENQUEUE_FILL_IMAGE_ERR);
7419 if (event != NULL && err == CL_SUCCESS)
7435 const array<size_type, 3>& origin,
7436 const array<size_type, 3>& region,
7437 const vector<Event>* events = NULL,
7438 Event* event = NULL)
const 7441 cl_int err = detail::errHandler(
7442 ::clEnqueueFillImage(
7445 static_cast<void*>(&fillColor),
7448 (events != NULL) ? (cl_uint) events->size() : 0,
7449 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7450 (
event != NULL) ? &tmp : NULL),
7451 __ENQUEUE_FILL_IMAGE_ERR);
7453 if (event != NULL && err == CL_SUCCESS)
7458 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 7460 cl_int enqueueCopyImageToBuffer(
7463 const array<size_type, 3>& src_origin,
7464 const array<size_type, 3>& region,
7465 size_type dst_offset,
7466 const vector<Event>* events = NULL,
7467 Event* event = NULL)
const 7470 cl_int err = detail::errHandler(
7471 ::clEnqueueCopyImageToBuffer(
7478 (events != NULL) ? (cl_uint) events->size() : 0,
7479 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7480 (
event != NULL) ? &tmp : NULL),
7481 __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR);
7483 if (event != NULL && err == CL_SUCCESS)
7489 cl_int enqueueCopyBufferToImage(
7492 size_type src_offset,
7493 const array<size_type, 3>& dst_origin,
7494 const array<size_type, 3>& region,
7495 const vector<Event>* events = NULL,
7496 Event* event = NULL)
const 7499 cl_int err = detail::errHandler(
7500 ::clEnqueueCopyBufferToImage(
7507 (events != NULL) ? (cl_uint) events->size() : 0,
7508 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7509 (
event != NULL) ? &tmp : NULL),
7510 __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR);
7512 if (event != NULL && err == CL_SUCCESS)
7518 void* enqueueMapBuffer(
7524 const vector<Event>* events = NULL,
7525 Event* event = NULL,
7526 cl_int* err = NULL)
const 7530 void * result = ::clEnqueueMapBuffer(
7531 object_, buffer(), blocking, flags, offset, size,
7532 (events != NULL) ? (cl_uint) events->size() : 0,
7533 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7534 (
event != NULL) ? &tmp : NULL,
7537 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
7541 if (event != NULL && error == CL_SUCCESS)
7547 void* enqueueMapImage(
7548 const Image& buffer,
7551 const array<size_type, 3>& origin,
7552 const array<size_type, 3>& region,
7553 size_type * row_pitch,
7554 size_type * slice_pitch,
7555 const vector<Event>* events = NULL,
7556 Event* event = NULL,
7557 cl_int* err = NULL)
const 7561 void * result = ::clEnqueueMapImage(
7562 object_, buffer(), blocking, flags,
7565 row_pitch, slice_pitch,
7566 (events != NULL) ? (cl_uint) events->size() : 0,
7567 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7568 (
event != NULL) ? &tmp : NULL,
7571 detail::errHandler(error, __ENQUEUE_MAP_IMAGE_ERR);
7575 if (event != NULL && error == CL_SUCCESS)
7580 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 7585 template<
typename T>
7591 const vector<Event>* events = NULL,
7592 Event* event = NULL)
const 7595 cl_int err = detail::errHandler(::clEnqueueSVMMap(
7596 object_, blocking, flags, static_cast<void*>(ptr), size,
7597 (events != NULL) ? (cl_uint)events->size() : 0,
7598 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
7599 (
event != NULL) ? &tmp : NULL),
7600 __ENQUEUE_MAP_BUFFER_ERR);
7602 if (event != NULL && err == CL_SUCCESS)
7613 template<
typename T,
class D>
7615 cl::pointer<T, D> &ptr,
7619 const vector<Event>* events = NULL,
7620 Event* event = NULL)
const 7623 cl_int err = detail::errHandler(::clEnqueueSVMMap(
7624 object_, blocking, flags, static_cast<void*>(ptr.get()), size,
7625 (events != NULL) ? (cl_uint)events->size() : 0,
7626 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
7627 (
event != NULL) ? &tmp : NULL),
7628 __ENQUEUE_MAP_BUFFER_ERR);
7630 if (event != NULL && err == CL_SUCCESS)
7640 template<
typename T,
class Alloc>
7642 cl::vector<T, Alloc> &container,
7645 const vector<Event>* events = NULL,
7646 Event* event = NULL)
const 7649 cl_int err = detail::errHandler(::clEnqueueSVMMap(
7650 object_, blocking, flags, static_cast<void*>(container.data()), container.size(),
7651 (events != NULL) ? (cl_uint)events->size() : 0,
7652 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
7653 (
event != NULL) ? &tmp : NULL),
7654 __ENQUEUE_MAP_BUFFER_ERR);
7656 if (event != NULL && err == CL_SUCCESS)
7661 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 7663 cl_int enqueueUnmapMemObject(
7666 const vector<Event>* events = NULL,
7667 Event* event = NULL)
const 7670 cl_int err = detail::errHandler(
7671 ::clEnqueueUnmapMemObject(
7672 object_, memory(), mapped_ptr,
7673 (events != NULL) ? (cl_uint) events->size() : 0,
7674 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7675 (
event != NULL) ? &tmp : NULL),
7676 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
7678 if (event != NULL && err == CL_SUCCESS)
7685 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 7690 template<
typename T>
7693 const vector<Event>* events = NULL,
7694 Event* event = NULL)
const 7697 cl_int err = detail::errHandler(
7698 ::clEnqueueSVMUnmap(
7699 object_, static_cast<void*>(ptr),
7700 (events != NULL) ? (cl_uint)events->size() : 0,
7701 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
7702 (
event != NULL) ? &tmp : NULL),
7703 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
7705 if (event != NULL && err == CL_SUCCESS)
7715 template<
typename T,
class D>
7717 cl::pointer<T, D> &ptr,
7718 const vector<Event>* events = NULL,
7719 Event* event = NULL)
const 7722 cl_int err = detail::errHandler(
7723 ::clEnqueueSVMUnmap(
7724 object_, static_cast<void*>(ptr.get()),
7725 (events != NULL) ? (cl_uint)events->size() : 0,
7726 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
7727 (
event != NULL) ? &tmp : NULL),
7728 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
7730 if (event != NULL && err == CL_SUCCESS)
7740 template<
typename T,
class Alloc>
7742 cl::vector<T, Alloc> &container,
7743 const vector<Event>* events = NULL,
7744 Event* event = NULL)
const 7747 cl_int err = detail::errHandler(
7748 ::clEnqueueSVMUnmap(
7749 object_, static_cast<void*>(container.data()),
7750 (events != NULL) ? (cl_uint)events->size() : 0,
7751 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
7752 (
event != NULL) ? &tmp : NULL),
7753 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
7755 if (event != NULL && err == CL_SUCCESS)
7760 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 7762 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 7775 const vector<Event> *events = 0,
7779 cl_int err = detail::errHandler(
7780 ::clEnqueueMarkerWithWaitList(
7782 (events != NULL) ? (cl_uint) events->size() : 0,
7783 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7784 (
event != NULL) ? &tmp : NULL),
7785 __ENQUEUE_MARKER_WAIT_LIST_ERR);
7787 if (event != NULL && err == CL_SUCCESS)
7805 const vector<Event> *events = 0,
7809 cl_int err = detail::errHandler(
7810 ::clEnqueueBarrierWithWaitList(
7812 (events != NULL) ? (cl_uint) events->size() : 0,
7813 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7814 (
event != NULL) ? &tmp : NULL),
7815 __ENQUEUE_BARRIER_WAIT_LIST_ERR);
7817 if (event != NULL && err == CL_SUCCESS)
7828 const vector<Memory> &memObjects,
7829 cl_mem_migration_flags flags,
7830 const vector<Event>* events = NULL,
7836 vector<cl_mem> localMemObjects(memObjects.size());
7838 for(
int i = 0; i < (int)memObjects.size(); ++i ) {
7839 localMemObjects[i] = memObjects[i]();
7843 cl_int err = detail::errHandler(
7844 ::clEnqueueMigrateMemObjects(
7846 (cl_uint)memObjects.size(),
7847 localMemObjects.data(),
7849 (events != NULL) ? (cl_uint) events->size() : 0,
7850 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7851 (
event != NULL) ? &tmp : NULL),
7852 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
7854 if (event != NULL && err == CL_SUCCESS)
7859 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 7861 cl_int enqueueNDRangeKernel(
7865 const NDRange& local = NullRange,
7866 const vector<Event>* events = NULL,
7867 Event* event = NULL)
const 7870 cl_int err = detail::errHandler(
7871 ::clEnqueueNDRangeKernel(
7872 object_, kernel(), (cl_uint) global.
dimensions(),
7873 offset.
dimensions() != 0 ? (
const size_type*) offset : NULL,
7874 (
const size_type*) global,
7875 local.
dimensions() != 0 ? (
const size_type*) local : NULL,
7876 (events != NULL) ? (cl_uint) events->size() : 0,
7877 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7878 (
event != NULL) ? &tmp : NULL),
7879 __ENQUEUE_NDRANGE_KERNEL_ERR);
7881 if (event != NULL && err == CL_SUCCESS)
7887 #if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS) 7888 CL_EXT_PREFIX__VERSION_1_2_DEPRECATED cl_int enqueueTask(
7890 const vector<Event>* events = NULL,
7891 Event* event = NULL)
const CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED
7894 cl_int err = detail::errHandler(
7897 (events != NULL) ? (cl_uint) events->size() : 0,
7898 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7899 (
event != NULL) ? &tmp : NULL),
7900 __ENQUEUE_TASK_ERR);
7902 if (event != NULL && err == CL_SUCCESS)
7907 #endif // #if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS) 7909 cl_int enqueueNativeKernel(
7910 void (CL_CALLBACK *userFptr)(
void *),
7911 std::pair<void*, size_type> args,
7912 const vector<Memory>* mem_objects = NULL,
7913 const vector<const void*>* mem_locs = NULL,
7914 const vector<Event>* events = NULL,
7915 Event* event = NULL)
const 7917 size_type elements = 0;
7918 if (mem_objects != NULL) {
7919 elements = mem_objects->size();
7921 vector<cl_mem> mems(elements);
7922 for (
unsigned int i = 0; i < elements; i++) {
7923 mems[i] = ((*mem_objects)[i])();
7927 cl_int err = detail::errHandler(
7928 ::clEnqueueNativeKernel(
7929 object_, userFptr, args.first, args.second,
7930 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
7932 (mem_locs != NULL && mem_locs->size() > 0) ? (
const void **) &mem_locs->front() : NULL,
7933 (events != NULL) ? (cl_uint) events->size() : 0,
7934 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7935 (
event != NULL) ? &tmp : NULL),
7936 __ENQUEUE_NATIVE_KERNEL);
7938 if (event != NULL && err == CL_SUCCESS)
7947 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 7948 CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
7952 cl_int err = detail::errHandler(
7955 (event != NULL) ? &tmp : NULL),
7956 __ENQUEUE_MARKER_ERR);
7958 if (event != NULL && err == CL_SUCCESS)
7964 CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
7965 cl_int enqueueWaitForEvents(
const vector<Event>& events)
const CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
7967 return detail::errHandler(
7968 ::clEnqueueWaitForEvents(
7970 (cl_uint) events.size(),
7971 events.size() > 0 ? (
const cl_event*) &events.front() : NULL),
7972 __ENQUEUE_WAIT_FOR_EVENTS_ERR);
7974 #endif // defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 7976 cl_int enqueueAcquireGLObjects(
7977 const vector<Memory>* mem_objects = NULL,
7978 const vector<Event>* events = NULL,
7979 Event* event = NULL)
const 7982 cl_int err = detail::errHandler(
7983 ::clEnqueueAcquireGLObjects(
7985 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
7986 (mem_objects != NULL && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front(): NULL,
7987 (events != NULL) ? (cl_uint) events->size() : 0,
7988 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7989 (
event != NULL) ? &tmp : NULL),
7990 __ENQUEUE_ACQUIRE_GL_ERR);
7992 if (event != NULL && err == CL_SUCCESS)
7998 cl_int enqueueReleaseGLObjects(
7999 const vector<Memory>* mem_objects = NULL,
8000 const vector<Event>* events = NULL,
8001 Event* event = NULL)
const 8004 cl_int err = detail::errHandler(
8005 ::clEnqueueReleaseGLObjects(
8007 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8008 (mem_objects != NULL && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front(): NULL,
8009 (events != NULL) ? (cl_uint) events->size() : 0,
8010 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8011 (
event != NULL) ? &tmp : NULL),
8012 __ENQUEUE_RELEASE_GL_ERR);
8014 if (event != NULL && err == CL_SUCCESS)
8020 #if defined (CL_HPP_USE_DX_INTEROP) 8021 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueAcquireD3D10ObjectsKHR)(
8022 cl_command_queue command_queue, cl_uint num_objects,
8023 const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
8024 const cl_event* event_wait_list, cl_event* event);
8025 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueReleaseD3D10ObjectsKHR)(
8026 cl_command_queue command_queue, cl_uint num_objects,
8027 const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
8028 const cl_event* event_wait_list, cl_event* event);
8030 cl_int enqueueAcquireD3D10Objects(
8031 const vector<Memory>* mem_objects = NULL,
8032 const vector<Event>* events = NULL,
8033 Event* event = NULL)
const 8035 static PFN_clEnqueueAcquireD3D10ObjectsKHR pfn_clEnqueueAcquireD3D10ObjectsKHR = NULL;
8036 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 8037 cl_context context = getInfo<CL_QUEUE_CONTEXT>();
8038 cl::Device device(getInfo<CL_QUEUE_DEVICE>());
8039 cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>();
8040 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueAcquireD3D10ObjectsKHR);
8042 #if CL_HPP_TARGET_OPENCL_VERSION >= 110 8043 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueAcquireD3D10ObjectsKHR);
8047 cl_int err = detail::errHandler(
8048 pfn_clEnqueueAcquireD3D10ObjectsKHR(
8050 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8051 (mem_objects != NULL && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front(): NULL,
8052 (events != NULL) ? (cl_uint) events->size() : 0,
8053 (events != NULL) ? (cl_event*) &events->front() : NULL,
8054 (
event != NULL) ? &tmp : NULL),
8055 __ENQUEUE_ACQUIRE_GL_ERR);
8057 if (event != NULL && err == CL_SUCCESS)
8063 cl_int enqueueReleaseD3D10Objects(
8064 const vector<Memory>* mem_objects = NULL,
8065 const vector<Event>* events = NULL,
8066 Event* event = NULL)
const 8068 static PFN_clEnqueueReleaseD3D10ObjectsKHR pfn_clEnqueueReleaseD3D10ObjectsKHR = NULL;
8069 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 8070 cl_context context = getInfo<CL_QUEUE_CONTEXT>();
8071 cl::Device device(getInfo<CL_QUEUE_DEVICE>());
8072 cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>();
8073 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueReleaseD3D10ObjectsKHR);
8074 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 8075 #if CL_HPP_TARGET_OPENCL_VERSION >= 110 8076 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueReleaseD3D10ObjectsKHR);
8077 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110 8080 cl_int err = detail::errHandler(
8081 pfn_clEnqueueReleaseD3D10ObjectsKHR(
8083 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8084 (mem_objects != NULL && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front(): NULL,
8085 (events != NULL) ? (cl_uint) events->size() : 0,
8086 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8087 (
event != NULL) ? &tmp : NULL),
8088 __ENQUEUE_RELEASE_GL_ERR);
8090 if (event != NULL && err == CL_SUCCESS)
8100 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 8101 CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
8104 return detail::errHandler(
8105 ::clEnqueueBarrier(object_),
8106 __ENQUEUE_BARRIER_ERR);
8108 #endif // CL_USE_DEPRECATED_OPENCL_1_1_APIS 8110 cl_int flush()
const 8112 return detail::errHandler(::clFlush(object_), __FLUSH_ERR);
8115 cl_int finish()
const 8117 return detail::errHandler(::clFinish(object_), __FINISH_ERR);
8121 CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag CommandQueue::default_initialized_;
8122 CL_HPP_DEFINE_STATIC_MEMBER_
CommandQueue CommandQueue::default_;
8123 CL_HPP_DEFINE_STATIC_MEMBER_ cl_int CommandQueue::default_error_ = CL_SUCCESS;
8126 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 8127 enum class DeviceQueueProperties : cl_command_queue_properties
8130 Profiling = CL_QUEUE_PROFILING_ENABLE,
8133 inline DeviceQueueProperties operator|(DeviceQueueProperties lhs, DeviceQueueProperties rhs)
8135 return static_cast<DeviceQueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) | static_cast<cl_command_queue_properties>(rhs));
8159 cl_command_queue_properties mergedProperties =
8160 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
8162 cl_queue_properties queue_properties[] = {
8163 CL_QUEUE_PROPERTIES, mergedProperties, 0 };
8164 object_ = ::clCreateCommandQueueWithProperties(
8165 context(), device(), queue_properties, &error);
8167 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8179 DeviceQueueProperties properties = DeviceQueueProperties::None,
8184 cl_command_queue_properties mergedProperties =
8185 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
8186 cl_queue_properties queue_properties[] = {
8187 CL_QUEUE_PROPERTIES, mergedProperties, 0 };
8188 object_ = ::clCreateCommandQueueWithProperties(
8189 context(), device(), queue_properties, &error);
8191 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8204 DeviceQueueProperties properties = DeviceQueueProperties::None,
8209 cl_command_queue_properties mergedProperties =
8210 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
8211 cl_queue_properties queue_properties[] = {
8212 CL_QUEUE_PROPERTIES, mergedProperties,
8213 CL_QUEUE_SIZE, queueSize,
8215 object_ = ::clCreateCommandQueueWithProperties(
8216 context(), device(), queue_properties, &error);
8218 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8231 detail::Wrapper<cl_type>(commandQueue, retainObject) { }
8267 template <
typename T>
8268 cl_int getInfo(cl_command_queue_info name, T* param)
const 8270 return detail::errHandler(
8272 &::clGetCommandQueueInfo, object_, name, param),
8273 __GET_COMMAND_QUEUE_INFO_ERR);
8276 template <cl_
int name>
typename 8278 getInfo(cl_int* err = NULL)
const 8281 detail::cl_command_queue_info, name>::param_type param;
8282 cl_int result = getInfo(name, ¶m);
8296 cl_int *err =
nullptr)
8302 cl_command_queue_properties properties =
8303 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
8304 cl_queue_properties queue_properties[] = {
8305 CL_QUEUE_PROPERTIES, properties,
8308 ::clCreateCommandQueueWithProperties(
8309 context(), device(), queue_properties, &error));
8311 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8326 const Context &context,
const Device &device, cl_int *err =
nullptr)
8330 cl_command_queue_properties properties =
8331 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
8332 cl_queue_properties queue_properties[] = {
8333 CL_QUEUE_PROPERTIES, properties,
8336 ::clCreateCommandQueueWithProperties(
8337 context(), device(), queue_properties, &error));
8339 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8354 const Context &context,
const Device &device, cl_uint queueSize, cl_int *err =
nullptr)
8358 cl_command_queue_properties properties =
8359 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
8360 cl_queue_properties queue_properties[] = {
8361 CL_QUEUE_PROPERTIES, properties,
8362 CL_QUEUE_SIZE, queueSize,
8365 ::clCreateCommandQueueWithProperties(
8366 context(), device(), queue_properties, &error));
8368 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8388 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 8391 template<
typename IteratorType >
8394 IteratorType startIterator,
8395 IteratorType endIterator,
8400 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
8403 cl_mem_flags flags = 0;
8405 flags |= CL_MEM_READ_ONLY;
8408 flags |= CL_MEM_READ_WRITE;
8411 flags |= CL_MEM_USE_HOST_PTR;
8414 size_type size =
sizeof(DataType)*(endIterator - startIterator);
8417 object_ = ::clCreateBuffer(context(), flags, size, static_cast<DataType*>(&*startIterator), &error);
8419 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
8422 detail::errHandler(error, __CREATE_BUFFER_ERR);
8429 detail::errHandler(error, __CREATE_BUFFER_ERR);
8434 error =
cl::copy(queue, startIterator, endIterator, *
this);
8435 detail::errHandler(error, __CREATE_BUFFER_ERR);
8442 template<
typename IteratorType >
8445 IteratorType startIterator,
8446 IteratorType endIterator,
8451 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
8454 cl_mem_flags flags = 0;
8456 flags |= CL_MEM_READ_ONLY;
8459 flags |= CL_MEM_READ_WRITE;
8462 flags |= CL_MEM_USE_HOST_PTR;
8465 size_type size =
sizeof(DataType)*(endIterator - startIterator);
8467 Context context = queue.getInfo<CL_QUEUE_CONTEXT>();
8470 object_ = ::clCreateBuffer(context(), flags, size, static_cast<DataType*>(&*startIterator), &error);
8473 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
8476 detail::errHandler(error, __CREATE_BUFFER_ERR);
8482 error =
cl::copy(queue, startIterator, endIterator, *
this);
8483 detail::errHandler(error, __CREATE_BUFFER_ERR);
8490 inline cl_int enqueueReadBuffer(
8496 const vector<Event>* events = NULL,
8497 Event* event = NULL)
8502 if (error != CL_SUCCESS) {
8506 return queue.enqueueReadBuffer(buffer, blocking, offset, size, ptr, events, event);
8509 inline cl_int enqueueWriteBuffer(
8515 const vector<Event>* events = NULL,
8516 Event* event = NULL)
8521 if (error != CL_SUCCESS) {
8525 return queue.enqueueWriteBuffer(buffer, blocking, offset, size, ptr, events, event);
8528 inline void* enqueueMapBuffer(
8534 const vector<Event>* events = NULL,
8535 Event* event = NULL,
8540 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
8545 void * result = ::clEnqueueMapBuffer(
8546 queue(), buffer(), blocking, flags, offset, size,
8547 (events != NULL) ? (cl_uint) events->size() : 0,
8548 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8552 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
8560 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 8566 template<
typename T>
8572 const vector<Event>* events,
8577 if (error != CL_SUCCESS) {
8578 return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
8582 ptr, blocking, flags, size, events, event);
8590 template<
typename T,
class D>
8592 cl::pointer<T, D> ptr,
8596 const vector<Event>* events = NULL,
8597 Event* event = NULL)
8601 if (error != CL_SUCCESS) {
8602 return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
8606 ptr, blocking, flags, size, events, event);
8614 template<
typename T,
class Alloc>
8616 cl::vector<T, Alloc> container,
8619 const vector<Event>* events = NULL,
8620 Event* event = NULL)
8624 if (error != CL_SUCCESS) {
8625 return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
8629 container, blocking, flags, events, event);
8632 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 8634 inline cl_int enqueueUnmapMemObject(
8637 const vector<Event>* events = NULL,
8638 Event* event = NULL)
8642 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
8643 if (error != CL_SUCCESS) {
8648 cl_int err = detail::errHandler(
8649 ::clEnqueueUnmapMemObject(
8650 queue(), memory(), mapped_ptr,
8651 (events != NULL) ? (cl_uint)events->size() : 0,
8652 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8653 (
event != NULL) ? &tmp : NULL),
8654 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8656 if (event != NULL && err == CL_SUCCESS)
8662 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 8668 template<
typename T>
8671 const vector<Event>* events = NULL,
8672 Event* event = NULL)
8676 if (error != CL_SUCCESS) {
8677 return detail::errHandler(error, __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8681 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8690 template<
typename T,
class D>
8692 cl::pointer<T, D> &ptr,
8693 const vector<Event>* events = NULL,
8694 Event* event = NULL)
8698 if (error != CL_SUCCESS) {
8699 return detail::errHandler(error, __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8703 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8711 template<
typename T,
class Alloc>
8713 cl::vector<T, Alloc> &container,
8714 const vector<Event>* events = NULL,
8715 Event* event = NULL)
8719 if (error != CL_SUCCESS) {
8720 return detail::errHandler(error, __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8723 return detail::errHandler(queue.
enqueueUnmapSVM(container, events, event),
8724 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8727 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 8729 inline cl_int enqueueCopyBuffer(
8732 size_type src_offset,
8733 size_type dst_offset,
8735 const vector<Event>* events = NULL,
8736 Event* event = NULL)
8741 if (error != CL_SUCCESS) {
8745 return queue.enqueueCopyBuffer(src, dst, src_offset, dst_offset, size, events, event);
8753 template<
typename IteratorType >
8754 inline cl_int
copy( IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer )
8758 if (error != CL_SUCCESS)
8761 return cl::copy(queue, startIterator, endIterator, buffer);
8769 template<
typename IteratorType >
8770 inline cl_int
copy(
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator )
8774 if (error != CL_SUCCESS)
8777 return cl::copy(queue, buffer, startIterator, endIterator);
8785 template<
typename IteratorType >
8788 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
8791 size_type length = endIterator-startIterator;
8792 size_type byteLength = length*
sizeof(DataType);
8795 static_cast<DataType*
>(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_WRITE, 0, byteLength, 0, 0, &error));
8797 if( error != CL_SUCCESS ) {
8800 #if defined(_MSC_VER) 8804 stdext::checked_array_iterator<DataType*>(
8807 std::copy(startIterator, endIterator, pointer);
8810 error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
8812 if( error != CL_SUCCESS ) {
8824 template<
typename IteratorType >
8827 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
8830 size_type length = endIterator-startIterator;
8831 size_type byteLength = length*
sizeof(DataType);
8834 static_cast<DataType*
>(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_READ, 0, byteLength, 0, 0, &error));
8836 if( error != CL_SUCCESS ) {
8839 std::copy(pointer, pointer + length, startIterator);
8841 error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
8843 if( error != CL_SUCCESS ) {
8851 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 8855 template<
typename T,
class Alloc>
8856 inline cl_int
mapSVM(cl::vector<T, Alloc> &container)
8858 return enqueueMapSVM(container, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE);
8864 template<
typename T,
class Alloc>
8865 inline cl_int
unmapSVM(cl::vector<T, Alloc> &container)
8870 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 8872 #if CL_HPP_TARGET_OPENCL_VERSION >= 110 8873 inline cl_int enqueueReadBufferRect(
8876 const array<size_type, 3>& buffer_offset,
8877 const array<size_type, 3>& host_offset,
8878 const array<size_type, 3>& region,
8879 size_type buffer_row_pitch,
8880 size_type buffer_slice_pitch,
8881 size_type host_row_pitch,
8882 size_type host_slice_pitch,
8884 const vector<Event>* events = NULL,
8885 Event* event = NULL)
8890 if (error != CL_SUCCESS) {
8894 return queue.enqueueReadBufferRect(
8909 inline cl_int enqueueWriteBufferRect(
8912 const array<size_type, 3>& buffer_offset,
8913 const array<size_type, 3>& host_offset,
8914 const array<size_type, 3>& region,
8915 size_type buffer_row_pitch,
8916 size_type buffer_slice_pitch,
8917 size_type host_row_pitch,
8918 size_type host_slice_pitch,
8920 const vector<Event>* events = NULL,
8921 Event* event = NULL)
8926 if (error != CL_SUCCESS) {
8930 return queue.enqueueWriteBufferRect(
8945 inline cl_int enqueueCopyBufferRect(
8948 const array<size_type, 3>& src_origin,
8949 const array<size_type, 3>& dst_origin,
8950 const array<size_type, 3>& region,
8951 size_type src_row_pitch,
8952 size_type src_slice_pitch,
8953 size_type dst_row_pitch,
8954 size_type dst_slice_pitch,
8955 const vector<Event>* events = NULL,
8956 Event* event = NULL)
8961 if (error != CL_SUCCESS) {
8965 return queue.enqueueCopyBufferRect(
8978 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110 8980 inline cl_int enqueueReadImage(
8983 const array<size_type, 3>& origin,
8984 const array<size_type, 3>& region,
8985 size_type row_pitch,
8986 size_type slice_pitch,
8988 const vector<Event>* events = NULL,
8989 Event* event = NULL)
8994 if (error != CL_SUCCESS) {
8998 return queue.enqueueReadImage(
9010 inline cl_int enqueueWriteImage(
9013 const array<size_type, 3>& origin,
9014 const array<size_type, 3>& region,
9015 size_type row_pitch,
9016 size_type slice_pitch,
9018 const vector<Event>* events = NULL,
9019 Event* event = NULL)
9024 if (error != CL_SUCCESS) {
9028 return queue.enqueueWriteImage(
9040 inline cl_int enqueueCopyImage(
9043 const array<size_type, 3>& src_origin,
9044 const array<size_type, 3>& dst_origin,
9045 const array<size_type, 3>& region,
9046 const vector<Event>* events = NULL,
9047 Event* event = NULL)
9052 if (error != CL_SUCCESS) {
9056 return queue.enqueueCopyImage(
9066 inline cl_int enqueueCopyImageToBuffer(
9069 const array<size_type, 3>& src_origin,
9070 const array<size_type, 3>& region,
9071 size_type dst_offset,
9072 const vector<Event>* events = NULL,
9073 Event* event = NULL)
9078 if (error != CL_SUCCESS) {
9082 return queue.enqueueCopyImageToBuffer(
9092 inline cl_int enqueueCopyBufferToImage(
9095 size_type src_offset,
9096 const array<size_type, 3>& dst_origin,
9097 const array<size_type, 3>& region,
9098 const vector<Event>* events = NULL,
9099 Event* event = NULL)
9104 if (error != CL_SUCCESS) {
9108 return queue.enqueueCopyBufferToImage(
9119 inline cl_int flush(
void)
9124 if (error != CL_SUCCESS) {
9128 return queue.flush();
9131 inline cl_int finish(
void)
9136 if (error != CL_SUCCESS) {
9141 return queue.finish();
9151 vector<Event> events_;
9153 template<
typename... Ts>
9158 queue_(CommandQueue::getDefault()),
9167 queue_(CommandQueue::getDefault()),
9176 queue_(CommandQueue::getDefault()),
9185 queue_(CommandQueue::getDefault()),
9190 events_.push_back(e);
9194 queue_(CommandQueue::getDefault()),
9199 events_.push_back(e);
9203 queue_(CommandQueue::getDefault()),
9208 events_.push_back(e);
9212 queue_(CommandQueue::getDefault()),
9222 queue_(CommandQueue::getDefault()),
9232 queue_(CommandQueue::getDefault()),
9274 events_.push_back(e);
9283 events_.push_back(e);
9292 events_.push_back(e);
9334 template<
typename... Ts>
9340 template<
int index,
typename T0,
typename... T1s>
9341 void setArgs(T0&& t0, T1s&&... t1s)
9343 kernel_.
setArg(index, t0);
9344 setArgs<index + 1, T1s...>(std::forward<T1s>(t1s)...);
9347 template<
int index,
typename T0>
9348 void setArgs(T0&& t0)
9350 kernel_.
setArg(index, t0);
9366 cl_int * err = NULL) :
9367 kernel_(program, name.c_str(), err)
9383 setArgs<0>(std::forward<Ts>(ts)...);
9385 args.queue_.enqueueNDRangeKernel(
9408 setArgs<0>(std::forward<Ts>(ts)...);
9410 error = args.queue_.enqueueNDRangeKernel(
9421 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 9422 cl_int setSVMPointers(
const vector<void*> &pointerList)
9427 template<
typename T0,
typename... T1s>
9428 cl_int setSVMPointers(
const T0 &t0, T1s... ts)
9432 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 9440 namespace compatibility {
9445 template<
typename... Ts>
9455 cl_int * err = NULL) :
9477 enqueueArgs, args...);
9485 #undef CL_HPP_ERR_STR_ 9486 #if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS) 9487 #undef __GET_DEVICE_INFO_ERR 9488 #undef __GET_PLATFORM_INFO_ERR 9489 #undef __GET_DEVICE_IDS_ERR 9490 #undef __GET_CONTEXT_INFO_ERR 9491 #undef __GET_EVENT_INFO_ERR 9492 #undef __GET_EVENT_PROFILE_INFO_ERR 9493 #undef __GET_MEM_OBJECT_INFO_ERR 9494 #undef __GET_IMAGE_INFO_ERR 9495 #undef __GET_SAMPLER_INFO_ERR 9496 #undef __GET_KERNEL_INFO_ERR 9497 #undef __GET_KERNEL_ARG_INFO_ERR 9498 #undef __GET_KERNEL_WORK_GROUP_INFO_ERR 9499 #undef __GET_PROGRAM_INFO_ERR 9500 #undef __GET_PROGRAM_BUILD_INFO_ERR 9501 #undef __GET_COMMAND_QUEUE_INFO_ERR 9503 #undef __CREATE_CONTEXT_ERR 9504 #undef __CREATE_CONTEXT_FROM_TYPE_ERR 9505 #undef __GET_SUPPORTED_IMAGE_FORMATS_ERR 9507 #undef __CREATE_BUFFER_ERR 9508 #undef __CREATE_SUBBUFFER_ERR 9509 #undef __CREATE_IMAGE2D_ERR 9510 #undef __CREATE_IMAGE3D_ERR 9511 #undef __CREATE_SAMPLER_ERR 9512 #undef __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR 9514 #undef __CREATE_USER_EVENT_ERR 9515 #undef __SET_USER_EVENT_STATUS_ERR 9516 #undef __SET_EVENT_CALLBACK_ERR 9517 #undef __SET_PRINTF_CALLBACK_ERR 9519 #undef __WAIT_FOR_EVENTS_ERR 9521 #undef __CREATE_KERNEL_ERR 9522 #undef __SET_KERNEL_ARGS_ERR 9523 #undef __CREATE_PROGRAM_WITH_SOURCE_ERR 9524 #undef __CREATE_PROGRAM_WITH_BINARY_ERR 9525 #undef __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR 9526 #undef __BUILD_PROGRAM_ERR 9527 #undef __CREATE_KERNELS_IN_PROGRAM_ERR 9529 #undef __CREATE_COMMAND_QUEUE_ERR 9530 #undef __SET_COMMAND_QUEUE_PROPERTY_ERR 9531 #undef __ENQUEUE_READ_BUFFER_ERR 9532 #undef __ENQUEUE_WRITE_BUFFER_ERR 9533 #undef __ENQUEUE_READ_BUFFER_RECT_ERR 9534 #undef __ENQUEUE_WRITE_BUFFER_RECT_ERR 9535 #undef __ENQEUE_COPY_BUFFER_ERR 9536 #undef __ENQEUE_COPY_BUFFER_RECT_ERR 9537 #undef __ENQUEUE_READ_IMAGE_ERR 9538 #undef __ENQUEUE_WRITE_IMAGE_ERR 9539 #undef __ENQUEUE_COPY_IMAGE_ERR 9540 #undef __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR 9541 #undef __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR 9542 #undef __ENQUEUE_MAP_BUFFER_ERR 9543 #undef __ENQUEUE_MAP_IMAGE_ERR 9544 #undef __ENQUEUE_UNMAP_MEM_OBJECT_ERR 9545 #undef __ENQUEUE_NDRANGE_KERNEL_ERR 9546 #undef __ENQUEUE_TASK_ERR 9547 #undef __ENQUEUE_NATIVE_KERNEL 9549 #undef __UNLOAD_COMPILER_ERR 9550 #undef __CREATE_SUB_DEVICES_ERR 9552 #undef __CREATE_PIPE_ERR 9553 #undef __GET_PIPE_INFO_ERR 9555 #endif //CL_HPP_USER_OVERRIDE_ERROR_STRINGS 9558 #undef CL_HPP_INIT_CL_EXT_FCN_PTR_ 9559 #undef CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_ 9561 #if defined(CL_HPP_USE_CL_DEVICE_FISSION) 9562 #undef CL_HPP_PARAM_NAME_DEVICE_FISSION_ 9563 #endif // CL_HPP_USE_CL_DEVICE_FISSION 9565 #undef CL_HPP_NOEXCEPT_ 9566 #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.
vector< T, cl::SVMAllocator< int, cl::SVMTraitCoarse<>>> coarse_svm_vector
Vector alias to simplify contruction of coarse-grained SVM containers.
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.
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.
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.
Buffer(Buffer &&buf) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
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.
cl_int enqueueBarrierWithWaitList(const vector< Event > *events=0, Event *event=0)
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().
cl_int enqueueMigrateMemObjects(const vector< Memory > &memObjects, cl_mem_migration_flags flags, const vector< Event > *events=NULL, Event *event=NULL)
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.
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)
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.
vector< T, cl::SVMAllocator< int, cl::SVMTraitAtomic<>>> atomic_svm_vector
Vector alias to simplify contruction of fine-grained SVM containers that support platform atomics...
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.
vector< T, cl::SVMAllocator< int, cl::SVMTraitFine<>>> fine_svm_vector
Vector alias to simplify contruction of fine-grained SVM containers.
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 enqueueMarkerWithWaitList(const vector< Event > *events=0, Event *event=0)
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().