400 #if !defined(CL_HPP_USE_DX_INTEROP) && defined(USE_DX_INTEROP) 401 # pragma message("cl2.hpp: USE_DX_INTEROP is deprecated. Define CL_HPP_USE_DX_INTEROP instead") 402 # define CL_HPP_USE_DX_INTEROP 404 #if !defined(CL_HPP_USE_CL_DEVICE_FISSION) && defined(USE_CL_DEVICE_FISSION) 405 # pragma message("cl2.hpp: USE_CL_DEVICE_FISSION is deprecated. Define CL_HPP_USE_CL_DEVICE_FISSION instead") 406 # define CL_HPP_USE_CL_DEVICE_FISSION 408 #if !defined(CL_HPP_ENABLE_EXCEPTIONS) && defined(__CL_ENABLE_EXCEPTIONS) 409 # pragma message("cl2.hpp: __CL_ENABLE_EXCEPTIONS is deprecated. Define CL_HPP_ENABLE_EXCEPTIONS instead") 410 # define CL_HPP_ENABLE_EXCEPTIONS 412 #if !defined(CL_HPP_NO_STD_VECTOR) && defined(__NO_STD_VECTOR) 413 # pragma message("cl2.hpp: __NO_STD_VECTOR is deprecated. Define CL_HPP_NO_STD_VECTOR instead") 414 # define CL_HPP_NO_STD_VECTOR 416 #if !defined(CL_HPP_NO_STD_STRING) && defined(__NO_STD_STRING) 417 # pragma message("cl2.hpp: __NO_STD_STRING is deprecated. Define CL_HPP_NO_STD_STRING instead") 418 # define CL_HPP_NO_STD_STRING 420 #if defined(VECTOR_CLASS) 421 # pragma message("cl2.hpp: VECTOR_CLASS is deprecated. Alias cl::vector instead") 423 #if defined(STRING_CLASS) 424 # pragma message("cl2.hpp: STRING_CLASS is deprecated. Alias cl::string instead.") 426 #if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS) && defined(__CL_USER_OVERRIDE_ERROR_STRINGS) 427 # pragma message("cl2.hpp: __CL_USER_OVERRIDE_ERROR_STRINGS is deprecated. Define CL_HPP_USER_OVERRIDE_ERROR_STRINGS instead") 428 # define CL_HPP_USER_OVERRIDE_ERROR_STRINGS 433 #if defined(__USE_DEV_VECTOR) 434 # pragma message("cl2.hpp: __USE_DEV_VECTOR is no longer supported. Expect compilation errors") 436 #if defined(__USE_DEV_STRING) 437 # pragma message("cl2.hpp: __USE_DEV_STRING is no longer supported. Expect compilation errors") 441 #if !defined(CL_HPP_TARGET_OPENCL_VERSION) 442 # pragma message("cl2.hpp: CL_HPP_TARGET_OPENCL_VERSION is not defined. It will default to 200 (OpenCL 2.0)") 443 # define CL_HPP_TARGET_OPENCL_VERSION 200 445 #if CL_HPP_TARGET_OPENCL_VERSION != 100 && CL_HPP_TARGET_OPENCL_VERSION != 110 && CL_HPP_TARGET_OPENCL_VERSION != 120 && CL_HPP_TARGET_OPENCL_VERSION != 200 446 # pragma message("cl2.hpp: CL_HPP_TARGET_OPENCL_VERSION is not a valid value (100, 110, 120 or 200). It will be set to 200") 447 # undef CL_HPP_TARGET_OPENCL_VERSION 448 # define CL_HPP_TARGET_OPENCL_VERSION 200 451 #define CL_TARGET_OPENCL_VERSION CL_HPP_TARGET_OPENCL_VERSION 453 #if !defined(CL_HPP_MINIMUM_OPENCL_VERSION) 454 # define CL_HPP_MINIMUM_OPENCL_VERSION 200 456 #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 457 # 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") 458 # undef CL_HPP_MINIMUM_OPENCL_VERSION 459 # define CL_HPP_MINIMUM_OPENCL_VERSION 100 461 #if CL_HPP_MINIMUM_OPENCL_VERSION > CL_HPP_TARGET_OPENCL_VERSION 462 # error "CL_HPP_MINIMUM_OPENCL_VERSION must not be greater than CL_HPP_TARGET_OPENCL_VERSION" 465 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 100 && !defined(CL_USE_DEPRECATED_OPENCL_1_0_APIS) 466 # define CL_USE_DEPRECATED_OPENCL_1_0_APIS 468 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 110 && !defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 469 # define CL_USE_DEPRECATED_OPENCL_1_1_APIS 471 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 120 && !defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS) 472 # define CL_USE_DEPRECATED_OPENCL_1_2_APIS 474 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 200 && !defined(CL_USE_DEPRECATED_OPENCL_2_0_APIS) 475 # define CL_USE_DEPRECATED_OPENCL_2_0_APIS 482 #if defined(CL_HPP_USE_DX_INTEROP) 483 #include <CL/cl_d3d10.h> 484 #include <CL/cl_dx9_media_sharing.h> 488 #if defined(_MSC_VER) 496 #if (!defined(_MSC_VER) && __cplusplus < 201103L) || (defined(_MSC_VER) && _MSC_VER < 1700) 497 #error Visual studio 2013 or another C++11-supporting compiler required 501 #if defined(CL_HPP_USE_CL_DEVICE_FISSION) || defined(CL_HPP_USE_CL_SUB_GROUPS_KHR) 502 #include <CL/cl_ext.h> 505 #if defined(__APPLE__) || defined(__MACOSX) 506 #include <OpenCL/opencl.h> 508 #include <CL/opencl.h> 511 #if (__cplusplus >= 201103L) 512 #define CL_HPP_NOEXCEPT_ noexcept 514 #define CL_HPP_NOEXCEPT_ 517 #if defined(_MSC_VER) 518 # define CL_HPP_DEFINE_STATIC_MEMBER_ __declspec(selectany) 520 # define CL_HPP_DEFINE_STATIC_MEMBER_ __attribute__((weak)) 525 #if !defined(CL_EXT_PREFIX__VERSION_1_1_DEPRECATED) 526 #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED 527 #endif // #if !defined(CL_EXT_PREFIX__VERSION_1_1_DEPRECATED) 528 #if !defined(CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED) 529 #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED 530 #endif // #if !defined(CL_EXT_PREFIX__VERSION_1_1_DEPRECATED) 532 #if !defined(CL_EXT_PREFIX__VERSION_1_2_DEPRECATED) 533 #define CL_EXT_PREFIX__VERSION_1_2_DEPRECATED 534 #endif // #if !defined(CL_EXT_PREFIX__VERSION_1_2_DEPRECATED) 535 #if !defined(CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED) 536 #define CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED 537 #endif // #if !defined(CL_EXT_PREFIX__VERSION_1_2_DEPRECATED) 539 #if !defined(CL_CALLBACK) 548 #include <functional> 552 #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY) 554 using size_type = ::size_t;
556 #else // #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY) 558 using size_type = size_t;
560 #endif // #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY) 563 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 565 #endif // #if defined(CL_HPP_ENABLE_EXCEPTIONS) 567 #if !defined(CL_HPP_NO_STD_VECTOR) 570 template <
class T,
class Alloc = std::allocator<T> >
571 using vector = std::vector<T, Alloc>;
573 #endif // #if !defined(CL_HPP_NO_STD_VECTOR) 575 #if !defined(CL_HPP_NO_STD_STRING) 578 using string = std::string;
580 #endif // #if !defined(CL_HPP_NO_STD_STRING) 582 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 584 #if !defined(CL_HPP_NO_STD_UNIQUE_PTR) 589 template<
class T,
class D>
590 using pointer = std::unique_ptr<T, D>;
593 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 594 #if !defined(CL_HPP_NO_STD_ARRAY) 597 template <
class T,
size_type N >
598 using array = std::array<T, N>;
600 #endif // #if !defined(CL_HPP_NO_STD_ARRAY) 604 #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY) 606 namespace compatibility {
621 for (
int i = 0; i < N; ++i) {
626 size_t(
const array<size_type, N> &rhs)
628 for (
int i = 0; i < N; ++i) {
633 size_type& operator[](
int index)
638 const size_type& operator[](
int index)
const 644 operator size_type* () {
return data_; }
647 operator const size_type* ()
const {
return data_; }
649 operator array<size_type, N>()
const 651 array<size_type, N> ret;
653 for (
int i = 0; i < N; ++i) {
662 using size_t = compatibility::size_t<N>;
664 #endif // #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY) 669 using size_t_array = array<size_type, 3>;
682 #define CL_HPP_INIT_CL_EXT_FCN_PTR_(name) \ 684 pfn_##name = (PFN_##name) \ 685 clGetExtensionFunctionAddress(#name); \ 690 #define CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, name) \ 692 pfn_##name = (PFN_##name) \ 693 clGetExtensionFunctionAddressForPlatform(platform, #name); \ 707 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 712 class Error :
public std::exception
716 const char * errStr_;
727 Error(cl_int err,
const char * errStr = NULL) : err_(err), errStr_(errStr)
736 virtual const char * what()
const throw ()
738 if (errStr_ == NULL) {
750 cl_int err(
void)
const {
return err_; }
752 #define CL_HPP_ERR_STR_(x) #x 754 #define CL_HPP_ERR_STR_(x) NULL 755 #endif // CL_HPP_ENABLE_EXCEPTIONS 760 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 761 static inline cl_int errHandler (
763 const char * errStr = NULL)
765 if (err != CL_SUCCESS) {
766 throw Error(err, errStr);
771 static inline cl_int errHandler (cl_int err,
const char * errStr = NULL)
776 #endif // CL_HPP_ENABLE_EXCEPTIONS 782 #if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS) 783 #define __GET_DEVICE_INFO_ERR CL_HPP_ERR_STR_(clGetDeviceInfo) 784 #define __GET_PLATFORM_INFO_ERR CL_HPP_ERR_STR_(clGetPlatformInfo) 785 #define __GET_DEVICE_IDS_ERR CL_HPP_ERR_STR_(clGetDeviceIDs) 786 #define __GET_PLATFORM_IDS_ERR CL_HPP_ERR_STR_(clGetPlatformIDs) 787 #define __GET_CONTEXT_INFO_ERR CL_HPP_ERR_STR_(clGetContextInfo) 788 #define __GET_EVENT_INFO_ERR CL_HPP_ERR_STR_(clGetEventInfo) 789 #define __GET_EVENT_PROFILE_INFO_ERR CL_HPP_ERR_STR_(clGetEventProfileInfo) 790 #define __GET_MEM_OBJECT_INFO_ERR CL_HPP_ERR_STR_(clGetMemObjectInfo) 791 #define __GET_IMAGE_INFO_ERR CL_HPP_ERR_STR_(clGetImageInfo) 792 #define __GET_SAMPLER_INFO_ERR CL_HPP_ERR_STR_(clGetSamplerInfo) 793 #define __GET_KERNEL_INFO_ERR CL_HPP_ERR_STR_(clGetKernelInfo) 794 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 795 #define __GET_KERNEL_ARG_INFO_ERR CL_HPP_ERR_STR_(clGetKernelArgInfo) 796 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 797 #define __GET_KERNEL_WORK_GROUP_INFO_ERR CL_HPP_ERR_STR_(clGetKernelWorkGroupInfo) 798 #define __GET_PROGRAM_INFO_ERR CL_HPP_ERR_STR_(clGetProgramInfo) 799 #define __GET_PROGRAM_BUILD_INFO_ERR CL_HPP_ERR_STR_(clGetProgramBuildInfo) 800 #define __GET_COMMAND_QUEUE_INFO_ERR CL_HPP_ERR_STR_(clGetCommandQueueInfo) 802 #define __CREATE_CONTEXT_ERR CL_HPP_ERR_STR_(clCreateContext) 803 #define __CREATE_CONTEXT_FROM_TYPE_ERR CL_HPP_ERR_STR_(clCreateContextFromType) 804 #define __GET_SUPPORTED_IMAGE_FORMATS_ERR CL_HPP_ERR_STR_(clGetSupportedImageFormats) 806 #define __CREATE_BUFFER_ERR CL_HPP_ERR_STR_(clCreateBuffer) 807 #define __COPY_ERR CL_HPP_ERR_STR_(cl::copy) 808 #define __CREATE_SUBBUFFER_ERR CL_HPP_ERR_STR_(clCreateSubBuffer) 809 #define __CREATE_GL_BUFFER_ERR CL_HPP_ERR_STR_(clCreateFromGLBuffer) 810 #define __CREATE_GL_RENDER_BUFFER_ERR CL_HPP_ERR_STR_(clCreateFromGLBuffer) 811 #define __GET_GL_OBJECT_INFO_ERR CL_HPP_ERR_STR_(clGetGLObjectInfo) 812 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 813 #define __CREATE_IMAGE_ERR CL_HPP_ERR_STR_(clCreateImage) 814 #define __CREATE_GL_TEXTURE_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture) 815 #define __IMAGE_DIMENSION_ERR CL_HPP_ERR_STR_(Incorrect image dimensions) 816 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 817 #define __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR CL_HPP_ERR_STR_(clSetMemObjectDestructorCallback) 819 #define __CREATE_USER_EVENT_ERR CL_HPP_ERR_STR_(clCreateUserEvent) 820 #define __SET_USER_EVENT_STATUS_ERR CL_HPP_ERR_STR_(clSetUserEventStatus) 821 #define __SET_EVENT_CALLBACK_ERR CL_HPP_ERR_STR_(clSetEventCallback) 822 #define __WAIT_FOR_EVENTS_ERR CL_HPP_ERR_STR_(clWaitForEvents) 824 #define __CREATE_KERNEL_ERR CL_HPP_ERR_STR_(clCreateKernel) 825 #define __SET_KERNEL_ARGS_ERR CL_HPP_ERR_STR_(clSetKernelArg) 826 #define __CREATE_PROGRAM_WITH_SOURCE_ERR CL_HPP_ERR_STR_(clCreateProgramWithSource) 827 #define __CREATE_PROGRAM_WITH_BINARY_ERR CL_HPP_ERR_STR_(clCreateProgramWithBinary) 828 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 829 #define __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR CL_HPP_ERR_STR_(clCreateProgramWithBuiltInKernels) 830 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 831 #define __BUILD_PROGRAM_ERR CL_HPP_ERR_STR_(clBuildProgram) 832 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 833 #define __COMPILE_PROGRAM_ERR CL_HPP_ERR_STR_(clCompileProgram) 834 #define __LINK_PROGRAM_ERR CL_HPP_ERR_STR_(clLinkProgram) 835 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 836 #define __CREATE_KERNELS_IN_PROGRAM_ERR CL_HPP_ERR_STR_(clCreateKernelsInProgram) 838 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 839 #define __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR CL_HPP_ERR_STR_(clCreateCommandQueueWithProperties) 840 #define __CREATE_SAMPLER_WITH_PROPERTIES_ERR CL_HPP_ERR_STR_(clCreateSamplerWithProperties) 841 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200 842 #define __SET_COMMAND_QUEUE_PROPERTY_ERR CL_HPP_ERR_STR_(clSetCommandQueueProperty) 843 #define __ENQUEUE_READ_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueReadBuffer) 844 #define __ENQUEUE_READ_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueReadBufferRect) 845 #define __ENQUEUE_WRITE_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueWriteBuffer) 846 #define __ENQUEUE_WRITE_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueWriteBufferRect) 847 #define __ENQEUE_COPY_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueCopyBuffer) 848 #define __ENQEUE_COPY_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueCopyBufferRect) 849 #define __ENQUEUE_FILL_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueFillBuffer) 850 #define __ENQUEUE_READ_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueReadImage) 851 #define __ENQUEUE_WRITE_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueWriteImage) 852 #define __ENQUEUE_COPY_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueCopyImage) 853 #define __ENQUEUE_FILL_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueFillImage) 854 #define __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueCopyImageToBuffer) 855 #define __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueCopyBufferToImage) 856 #define __ENQUEUE_MAP_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueMapBuffer) 857 #define __ENQUEUE_MAP_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueMapImage) 858 #define __ENQUEUE_UNMAP_MEM_OBJECT_ERR CL_HPP_ERR_STR_(clEnqueueUnMapMemObject) 859 #define __ENQUEUE_NDRANGE_KERNEL_ERR CL_HPP_ERR_STR_(clEnqueueNDRangeKernel) 860 #define __ENQUEUE_NATIVE_KERNEL CL_HPP_ERR_STR_(clEnqueueNativeKernel) 861 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 862 #define __ENQUEUE_MIGRATE_MEM_OBJECTS_ERR CL_HPP_ERR_STR_(clEnqueueMigrateMemObjects) 863 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 865 #define __ENQUEUE_ACQUIRE_GL_ERR CL_HPP_ERR_STR_(clEnqueueAcquireGLObjects) 866 #define __ENQUEUE_RELEASE_GL_ERR CL_HPP_ERR_STR_(clEnqueueReleaseGLObjects) 868 #define __CREATE_PIPE_ERR CL_HPP_ERR_STR_(clCreatePipe) 869 #define __GET_PIPE_INFO_ERR CL_HPP_ERR_STR_(clGetPipeInfo) 872 #define __RETAIN_ERR CL_HPP_ERR_STR_(Retain Object) 873 #define __RELEASE_ERR CL_HPP_ERR_STR_(Release Object) 874 #define __FLUSH_ERR CL_HPP_ERR_STR_(clFlush) 875 #define __FINISH_ERR CL_HPP_ERR_STR_(clFinish) 876 #define __VECTOR_CAPACITY_ERR CL_HPP_ERR_STR_(Vector capacity error) 881 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 882 #define __CREATE_SUB_DEVICES_ERR CL_HPP_ERR_STR_(clCreateSubDevices) 884 #define __CREATE_SUB_DEVICES_ERR CL_HPP_ERR_STR_(clCreateSubDevicesEXT) 885 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 890 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 891 #define __ENQUEUE_MARKER_ERR CL_HPP_ERR_STR_(clEnqueueMarker) 892 #define __ENQUEUE_WAIT_FOR_EVENTS_ERR CL_HPP_ERR_STR_(clEnqueueWaitForEvents) 893 #define __ENQUEUE_BARRIER_ERR CL_HPP_ERR_STR_(clEnqueueBarrier) 894 #define __UNLOAD_COMPILER_ERR CL_HPP_ERR_STR_(clUnloadCompiler) 895 #define __CREATE_GL_TEXTURE_2D_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture2D) 896 #define __CREATE_GL_TEXTURE_3D_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture3D) 897 #define __CREATE_IMAGE2D_ERR CL_HPP_ERR_STR_(clCreateImage2D) 898 #define __CREATE_IMAGE3D_ERR CL_HPP_ERR_STR_(clCreateImage3D) 899 #endif // #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 904 #if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS) 905 #define __CREATE_COMMAND_QUEUE_ERR CL_HPP_ERR_STR_(clCreateCommandQueue) 906 #define __ENQUEUE_TASK_ERR CL_HPP_ERR_STR_(clEnqueueTask) 907 #define __CREATE_SAMPLER_ERR CL_HPP_ERR_STR_(clCreateSampler) 908 #endif // #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 913 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 914 #define __ENQUEUE_MARKER_WAIT_LIST_ERR CL_HPP_ERR_STR_(clEnqueueMarkerWithWaitList) 915 #define __ENQUEUE_BARRIER_WAIT_LIST_ERR CL_HPP_ERR_STR_(clEnqueueBarrierWithWaitList) 916 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 918 #endif // CL_HPP_USER_OVERRIDE_ERROR_STRINGS 928 template<
typename Functor,
typename T>
929 inline cl_int getInfoHelper(Functor f, cl_uint name, T* param,
long)
931 return f(name,
sizeof(T), param, NULL);
936 template <
typename Func>
937 inline cl_int getInfoHelper(Func f, cl_uint name, vector<vector<unsigned char>>* param,
int)
939 if (name != CL_PROGRAM_BINARIES) {
940 return CL_INVALID_VALUE;
944 size_type numBinaries = param->size();
945 vector<unsigned char*> binariesPointers(numBinaries);
947 for (size_type i = 0; i < numBinaries; ++i)
949 binariesPointers[i] = (*param)[i].data();
952 cl_int err = f(name, numBinaries *
sizeof(
unsigned char*), binariesPointers.data(), NULL);
954 if (err != CL_SUCCESS) {
964 template <
typename Func,
typename T>
965 inline cl_int getInfoHelper(Func f, cl_uint name, vector<T>* param,
long)
968 cl_int err = f(name, 0, NULL, &required);
969 if (err != CL_SUCCESS) {
972 const size_type elements = required /
sizeof(T);
975 vector<T> localData(elements);
976 err = f(name, required, localData.data(), NULL);
977 if (err != CL_SUCCESS) {
981 *param = std::move(localData);
993 template <
typename Func,
typename T>
994 inline cl_int getInfoHelper(
995 Func f, cl_uint name, vector<T>* param,
int,
typename T::cl_type = 0)
998 cl_int err = f(name, 0, NULL, &required);
999 if (err != CL_SUCCESS) {
1003 const size_type elements = required /
sizeof(
typename T::cl_type);
1005 vector<typename T::cl_type> value(elements);
1006 err = f(name, required, value.data(), NULL);
1007 if (err != CL_SUCCESS) {
1013 param->resize(elements);
1017 for (size_type i = 0; i < elements; i++) {
1018 (*param)[i] = T(value[i],
true);
1025 template <
typename Func>
1026 inline cl_int getInfoHelper(Func f, cl_uint name,
string* param,
long)
1029 cl_int err = f(name, 0, NULL, &required);
1030 if (err != CL_SUCCESS) {
1037 vector<char> value(required);
1038 err = f(name, required, value.data(), NULL);
1039 if (err != CL_SUCCESS) {
1043 param->assign(begin(value), prev(end(value)));
1053 template <
typename Func,
size_type N>
1054 inline cl_int getInfoHelper(Func f, cl_uint name, array<size_type, N>* param,
long)
1057 cl_int err = f(name, 0, NULL, &required);
1058 if (err != CL_SUCCESS) {
1062 size_type elements = required /
sizeof(size_type);
1063 vector<size_type> value(elements, 0);
1065 err = f(name, required, value.data(), NULL);
1066 if (err != CL_SUCCESS) {
1075 for (size_type i = 0; i < elements; ++i) {
1076 (*param)[i] = value[i];
1090 template<
typename Func,
typename T>
1091 inline cl_int getInfoHelper(Func f, cl_uint name, T* param,
int,
typename T::cl_type = 0)
1093 typename T::cl_type value;
1094 cl_int err = f(name,
sizeof(value), &value, NULL);
1095 if (err != CL_SUCCESS) {
1101 err = param->retain();
1102 if (err != CL_SUCCESS) {
1109 #define CL_HPP_PARAM_NAME_INFO_1_0_(F) \ 1110 F(cl_platform_info, CL_PLATFORM_PROFILE, string) \ 1111 F(cl_platform_info, CL_PLATFORM_VERSION, string) \ 1112 F(cl_platform_info, CL_PLATFORM_NAME, string) \ 1113 F(cl_platform_info, CL_PLATFORM_VENDOR, string) \ 1114 F(cl_platform_info, CL_PLATFORM_EXTENSIONS, string) \ 1116 F(cl_device_info, CL_DEVICE_TYPE, cl_device_type) \ 1117 F(cl_device_info, CL_DEVICE_VENDOR_ID, cl_uint) \ 1118 F(cl_device_info, CL_DEVICE_MAX_COMPUTE_UNITS, cl_uint) \ 1119 F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, cl_uint) \ 1120 F(cl_device_info, CL_DEVICE_MAX_WORK_GROUP_SIZE, size_type) \ 1121 F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_SIZES, cl::vector<size_type>) \ 1122 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, cl_uint) \ 1123 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT, cl_uint) \ 1124 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT, cl_uint) \ 1125 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG, cl_uint) \ 1126 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT, cl_uint) \ 1127 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, cl_uint) \ 1128 F(cl_device_info, CL_DEVICE_MAX_CLOCK_FREQUENCY, cl_uint) \ 1129 F(cl_device_info, CL_DEVICE_ADDRESS_BITS, cl_uint) \ 1130 F(cl_device_info, CL_DEVICE_MAX_READ_IMAGE_ARGS, cl_uint) \ 1131 F(cl_device_info, CL_DEVICE_MAX_WRITE_IMAGE_ARGS, cl_uint) \ 1132 F(cl_device_info, CL_DEVICE_MAX_MEM_ALLOC_SIZE, cl_ulong) \ 1133 F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_WIDTH, size_type) \ 1134 F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_HEIGHT, size_type) \ 1135 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_WIDTH, size_type) \ 1136 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_HEIGHT, size_type) \ 1137 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_DEPTH, size_type) \ 1138 F(cl_device_info, CL_DEVICE_IMAGE_SUPPORT, cl_bool) \ 1139 F(cl_device_info, CL_DEVICE_MAX_PARAMETER_SIZE, size_type) \ 1140 F(cl_device_info, CL_DEVICE_MAX_SAMPLERS, cl_uint) \ 1141 F(cl_device_info, CL_DEVICE_MEM_BASE_ADDR_ALIGN, cl_uint) \ 1142 F(cl_device_info, CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE, cl_uint) \ 1143 F(cl_device_info, CL_DEVICE_SINGLE_FP_CONFIG, cl_device_fp_config) \ 1144 F(cl_device_info, CL_DEVICE_DOUBLE_FP_CONFIG, cl_device_fp_config) \ 1145 F(cl_device_info, CL_DEVICE_HALF_FP_CONFIG, cl_device_fp_config) \ 1146 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_TYPE, cl_device_mem_cache_type) \ 1147 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE, cl_uint)\ 1148 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_SIZE, cl_ulong) \ 1149 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_SIZE, cl_ulong) \ 1150 F(cl_device_info, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE, cl_ulong) \ 1151 F(cl_device_info, CL_DEVICE_MAX_CONSTANT_ARGS, cl_uint) \ 1152 F(cl_device_info, CL_DEVICE_LOCAL_MEM_TYPE, cl_device_local_mem_type) \ 1153 F(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE, cl_ulong) \ 1154 F(cl_device_info, CL_DEVICE_ERROR_CORRECTION_SUPPORT, cl_bool) \ 1155 F(cl_device_info, CL_DEVICE_PROFILING_TIMER_RESOLUTION, size_type) \ 1156 F(cl_device_info, CL_DEVICE_ENDIAN_LITTLE, cl_bool) \ 1157 F(cl_device_info, CL_DEVICE_AVAILABLE, cl_bool) \ 1158 F(cl_device_info, CL_DEVICE_COMPILER_AVAILABLE, cl_bool) \ 1159 F(cl_device_info, CL_DEVICE_EXECUTION_CAPABILITIES, cl_device_exec_capabilities) \ 1160 F(cl_device_info, CL_DEVICE_PLATFORM, cl_platform_id) \ 1161 F(cl_device_info, CL_DEVICE_NAME, string) \ 1162 F(cl_device_info, CL_DEVICE_VENDOR, string) \ 1163 F(cl_device_info, CL_DRIVER_VERSION, string) \ 1164 F(cl_device_info, CL_DEVICE_PROFILE, string) \ 1165 F(cl_device_info, CL_DEVICE_VERSION, string) \ 1166 F(cl_device_info, CL_DEVICE_EXTENSIONS, string) \ 1168 F(cl_context_info, CL_CONTEXT_REFERENCE_COUNT, cl_uint) \ 1169 F(cl_context_info, CL_CONTEXT_DEVICES, cl::vector<Device>) \ 1170 F(cl_context_info, CL_CONTEXT_PROPERTIES, cl::vector<cl_context_properties>) \ 1172 F(cl_event_info, CL_EVENT_COMMAND_QUEUE, cl::CommandQueue) \ 1173 F(cl_event_info, CL_EVENT_COMMAND_TYPE, cl_command_type) \ 1174 F(cl_event_info, CL_EVENT_REFERENCE_COUNT, cl_uint) \ 1175 F(cl_event_info, CL_EVENT_COMMAND_EXECUTION_STATUS, cl_int) \ 1177 F(cl_profiling_info, CL_PROFILING_COMMAND_QUEUED, cl_ulong) \ 1178 F(cl_profiling_info, CL_PROFILING_COMMAND_SUBMIT, cl_ulong) \ 1179 F(cl_profiling_info, CL_PROFILING_COMMAND_START, cl_ulong) \ 1180 F(cl_profiling_info, CL_PROFILING_COMMAND_END, cl_ulong) \ 1182 F(cl_mem_info, CL_MEM_TYPE, cl_mem_object_type) \ 1183 F(cl_mem_info, CL_MEM_FLAGS, cl_mem_flags) \ 1184 F(cl_mem_info, CL_MEM_SIZE, size_type) \ 1185 F(cl_mem_info, CL_MEM_HOST_PTR, void*) \ 1186 F(cl_mem_info, CL_MEM_MAP_COUNT, cl_uint) \ 1187 F(cl_mem_info, CL_MEM_REFERENCE_COUNT, cl_uint) \ 1188 F(cl_mem_info, CL_MEM_CONTEXT, cl::Context) \ 1190 F(cl_image_info, CL_IMAGE_FORMAT, cl_image_format) \ 1191 F(cl_image_info, CL_IMAGE_ELEMENT_SIZE, size_type) \ 1192 F(cl_image_info, CL_IMAGE_ROW_PITCH, size_type) \ 1193 F(cl_image_info, CL_IMAGE_SLICE_PITCH, size_type) \ 1194 F(cl_image_info, CL_IMAGE_WIDTH, size_type) \ 1195 F(cl_image_info, CL_IMAGE_HEIGHT, size_type) \ 1196 F(cl_image_info, CL_IMAGE_DEPTH, size_type) \ 1198 F(cl_sampler_info, CL_SAMPLER_REFERENCE_COUNT, cl_uint) \ 1199 F(cl_sampler_info, CL_SAMPLER_CONTEXT, cl::Context) \ 1200 F(cl_sampler_info, CL_SAMPLER_NORMALIZED_COORDS, cl_bool) \ 1201 F(cl_sampler_info, CL_SAMPLER_ADDRESSING_MODE, cl_addressing_mode) \ 1202 F(cl_sampler_info, CL_SAMPLER_FILTER_MODE, cl_filter_mode) \ 1204 F(cl_program_info, CL_PROGRAM_REFERENCE_COUNT, cl_uint) \ 1205 F(cl_program_info, CL_PROGRAM_CONTEXT, cl::Context) \ 1206 F(cl_program_info, CL_PROGRAM_NUM_DEVICES, cl_uint) \ 1207 F(cl_program_info, CL_PROGRAM_DEVICES, cl::vector<Device>) \ 1208 F(cl_program_info, CL_PROGRAM_SOURCE, string) \ 1209 F(cl_program_info, CL_PROGRAM_BINARY_SIZES, cl::vector<size_type>) \ 1210 F(cl_program_info, CL_PROGRAM_BINARIES, cl::vector<cl::vector<unsigned char>>) \ 1212 F(cl_program_build_info, CL_PROGRAM_BUILD_STATUS, cl_build_status) \ 1213 F(cl_program_build_info, CL_PROGRAM_BUILD_OPTIONS, string) \ 1214 F(cl_program_build_info, CL_PROGRAM_BUILD_LOG, string) \ 1216 F(cl_kernel_info, CL_KERNEL_FUNCTION_NAME, string) \ 1217 F(cl_kernel_info, CL_KERNEL_NUM_ARGS, cl_uint) \ 1218 F(cl_kernel_info, CL_KERNEL_REFERENCE_COUNT, cl_uint) \ 1219 F(cl_kernel_info, CL_KERNEL_CONTEXT, cl::Context) \ 1220 F(cl_kernel_info, CL_KERNEL_PROGRAM, cl::Program) \ 1222 F(cl_kernel_work_group_info, CL_KERNEL_WORK_GROUP_SIZE, size_type) \ 1223 F(cl_kernel_work_group_info, CL_KERNEL_COMPILE_WORK_GROUP_SIZE, cl::detail::size_t_array) \ 1224 F(cl_kernel_work_group_info, CL_KERNEL_LOCAL_MEM_SIZE, cl_ulong) \ 1226 F(cl_command_queue_info, CL_QUEUE_CONTEXT, cl::Context) \ 1227 F(cl_command_queue_info, CL_QUEUE_DEVICE, cl::Device) \ 1228 F(cl_command_queue_info, CL_QUEUE_REFERENCE_COUNT, cl_uint) \ 1229 F(cl_command_queue_info, CL_QUEUE_PROPERTIES, cl_command_queue_properties) 1232 #define CL_HPP_PARAM_NAME_INFO_1_1_(F) \ 1233 F(cl_context_info, CL_CONTEXT_NUM_DEVICES, cl_uint)\ 1234 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF, cl_uint) \ 1235 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR, cl_uint) \ 1236 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT, cl_uint) \ 1237 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_INT, cl_uint) \ 1238 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG, cl_uint) \ 1239 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT, cl_uint) \ 1240 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE, cl_uint) \ 1241 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF, cl_uint) \ 1242 F(cl_device_info, CL_DEVICE_OPENCL_C_VERSION, string) \ 1244 F(cl_mem_info, CL_MEM_ASSOCIATED_MEMOBJECT, cl::Memory) \ 1245 F(cl_mem_info, CL_MEM_OFFSET, size_type) \ 1247 F(cl_kernel_work_group_info, CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, size_type) \ 1248 F(cl_kernel_work_group_info, CL_KERNEL_PRIVATE_MEM_SIZE, cl_ulong) \ 1250 F(cl_event_info, CL_EVENT_CONTEXT, cl::Context) 1252 #define CL_HPP_PARAM_NAME_INFO_1_2_(F) \ 1253 F(cl_program_info, CL_PROGRAM_NUM_KERNELS, size_type) \ 1254 F(cl_program_info, CL_PROGRAM_KERNEL_NAMES, string) \ 1256 F(cl_program_build_info, CL_PROGRAM_BINARY_TYPE, cl_program_binary_type) \ 1258 F(cl_kernel_info, CL_KERNEL_ATTRIBUTES, string) \ 1260 F(cl_kernel_arg_info, CL_KERNEL_ARG_ADDRESS_QUALIFIER, cl_kernel_arg_address_qualifier) \ 1261 F(cl_kernel_arg_info, CL_KERNEL_ARG_ACCESS_QUALIFIER, cl_kernel_arg_access_qualifier) \ 1262 F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_NAME, string) \ 1263 F(cl_kernel_arg_info, CL_KERNEL_ARG_NAME, string) \ 1264 F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_QUALIFIER, cl_kernel_arg_type_qualifier) \ 1266 F(cl_device_info, CL_DEVICE_PARENT_DEVICE, cl::Device) \ 1267 F(cl_device_info, CL_DEVICE_PARTITION_PROPERTIES, cl::vector<cl_device_partition_property>) \ 1268 F(cl_device_info, CL_DEVICE_PARTITION_TYPE, cl::vector<cl_device_partition_property>) \ 1269 F(cl_device_info, CL_DEVICE_REFERENCE_COUNT, cl_uint) \ 1270 F(cl_device_info, CL_DEVICE_PREFERRED_INTEROP_USER_SYNC, size_type) \ 1271 F(cl_device_info, CL_DEVICE_PARTITION_AFFINITY_DOMAIN, cl_device_affinity_domain) \ 1272 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS, string) \ 1274 F(cl_image_info, CL_IMAGE_ARRAY_SIZE, size_type) \ 1275 F(cl_image_info, CL_IMAGE_NUM_MIP_LEVELS, cl_uint) \ 1276 F(cl_image_info, CL_IMAGE_NUM_SAMPLES, cl_uint) 1278 #define CL_HPP_PARAM_NAME_INFO_2_0_(F) \ 1279 F(cl_device_info, CL_DEVICE_QUEUE_ON_HOST_PROPERTIES, cl_command_queue_properties) \ 1280 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES, cl_command_queue_properties) \ 1281 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE, cl_uint) \ 1282 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE, cl_uint) \ 1283 F(cl_device_info, CL_DEVICE_MAX_ON_DEVICE_QUEUES, cl_uint) \ 1284 F(cl_device_info, CL_DEVICE_MAX_ON_DEVICE_EVENTS, cl_uint) \ 1285 F(cl_device_info, CL_DEVICE_MAX_PIPE_ARGS, cl_uint) \ 1286 F(cl_device_info, CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS, cl_uint) \ 1287 F(cl_device_info, CL_DEVICE_PIPE_MAX_PACKET_SIZE, cl_uint) \ 1288 F(cl_device_info, CL_DEVICE_SVM_CAPABILITIES, cl_device_svm_capabilities) \ 1289 F(cl_device_info, CL_DEVICE_PREFERRED_PLATFORM_ATOMIC_ALIGNMENT, cl_uint) \ 1290 F(cl_device_info, CL_DEVICE_PREFERRED_GLOBAL_ATOMIC_ALIGNMENT, cl_uint) \ 1291 F(cl_device_info, CL_DEVICE_PREFERRED_LOCAL_ATOMIC_ALIGNMENT, cl_uint) \ 1292 F(cl_command_queue_info, CL_QUEUE_SIZE, cl_uint) \ 1293 F(cl_mem_info, CL_MEM_USES_SVM_POINTER, cl_bool) \ 1294 F(cl_program_build_info, CL_PROGRAM_BUILD_GLOBAL_VARIABLE_TOTAL_SIZE, size_type) \ 1295 F(cl_pipe_info, CL_PIPE_PACKET_SIZE, cl_uint) \ 1296 F(cl_pipe_info, CL_PIPE_MAX_PACKETS, cl_uint) 1298 #define CL_HPP_PARAM_NAME_DEVICE_FISSION_(F) \ 1299 F(cl_device_info, CL_DEVICE_PARENT_DEVICE_EXT, cl_device_id) \ 1300 F(cl_device_info, CL_DEVICE_PARTITION_TYPES_EXT, cl::vector<cl_device_partition_property_ext>) \ 1301 F(cl_device_info, CL_DEVICE_AFFINITY_DOMAINS_EXT, cl::vector<cl_device_partition_property_ext>) \ 1302 F(cl_device_info, CL_DEVICE_REFERENCE_COUNT_EXT , cl_uint) \ 1303 F(cl_device_info, CL_DEVICE_PARTITION_STYLE_EXT, cl::vector<cl_device_partition_property_ext>) 1305 template <
typename enum_type, cl_
int Name>
1308 #define CL_HPP_DECLARE_PARAM_TRAITS_(token, param_name, T) \ 1311 struct param_traits<detail:: token,param_name> \ 1313 enum { value = param_name }; \ 1314 typedef T param_type; \ 1317 CL_HPP_PARAM_NAME_INFO_1_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1318 #if CL_HPP_TARGET_OPENCL_VERSION >= 110 1319 CL_HPP_PARAM_NAME_INFO_1_1_(CL_HPP_DECLARE_PARAM_TRAITS_)
1320 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110 1321 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 1322 CL_HPP_PARAM_NAME_INFO_1_2_(CL_HPP_DECLARE_PARAM_TRAITS_)
1323 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110 1324 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 1325 CL_HPP_PARAM_NAME_INFO_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1326 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110 1330 #define CL_HPP_PARAM_NAME_INFO_1_0_DEPRECATED_IN_2_0_(F) \ 1331 F(cl_device_info, CL_DEVICE_QUEUE_PROPERTIES, cl_command_queue_properties) 1333 #define CL_HPP_PARAM_NAME_INFO_1_1_DEPRECATED_IN_2_0_(F) \ 1334 F(cl_device_info, CL_DEVICE_HOST_UNIFIED_MEMORY, cl_bool) 1336 #define CL_HPP_PARAM_NAME_INFO_1_2_DEPRECATED_IN_2_0_(F) \ 1337 F(cl_image_info, CL_IMAGE_BUFFER, cl::Buffer) 1341 #if CL_HPP_TARGET_OPENCL_VERSION > 100 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 && CL_HPP_TARGET_OPENCL_VERSION < 200 1342 CL_HPP_PARAM_NAME_INFO_1_0_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1343 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 110 1344 #if CL_HPP_TARGET_OPENCL_VERSION > 110 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 1345 CL_HPP_PARAM_NAME_INFO_1_1_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1346 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 120 1347 #if CL_HPP_TARGET_OPENCL_VERSION > 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 1348 CL_HPP_PARAM_NAME_INFO_1_2_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1349 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 200 1351 #if defined(CL_HPP_USE_CL_DEVICE_FISSION) 1352 CL_HPP_PARAM_NAME_DEVICE_FISSION_(CL_HPP_DECLARE_PARAM_TRAITS_);
1353 #endif // CL_HPP_USE_CL_DEVICE_FISSION 1355 #ifdef CL_PLATFORM_ICD_SUFFIX_KHR 1356 CL_HPP_DECLARE_PARAM_TRAITS_(cl_platform_info, CL_PLATFORM_ICD_SUFFIX_KHR,
string)
1359 #ifdef CL_DEVICE_PROFILING_TIMER_OFFSET_AMD 1360 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_PROFILING_TIMER_OFFSET_AMD, cl_ulong)
1363 #ifdef CL_DEVICE_GLOBAL_FREE_MEMORY_AMD 1364 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_FREE_MEMORY_AMD, vector<size_type>)
1366 #ifdef CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD 1367 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD, cl_uint)
1369 #ifdef CL_DEVICE_SIMD_WIDTH_AMD 1370 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_WIDTH_AMD, cl_uint)
1372 #ifdef CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD 1373 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD, cl_uint)
1375 #ifdef CL_DEVICE_WAVEFRONT_WIDTH_AMD 1376 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_WAVEFRONT_WIDTH_AMD, cl_uint)
1378 #ifdef CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD 1379 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD, cl_uint)
1381 #ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD 1382 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD, cl_uint)
1384 #ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD 1385 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD, cl_uint)
1387 #ifdef CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD 1388 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD, cl_uint)
1390 #ifdef CL_DEVICE_LOCAL_MEM_BANKS_AMD 1391 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LOCAL_MEM_BANKS_AMD, cl_uint)
1394 #ifdef CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV 1395 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV, cl_uint)
1397 #ifdef CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV 1398 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV, cl_uint)
1400 #ifdef CL_DEVICE_REGISTERS_PER_BLOCK_NV 1401 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_REGISTERS_PER_BLOCK_NV, cl_uint)
1403 #ifdef CL_DEVICE_WARP_SIZE_NV 1404 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_WARP_SIZE_NV, cl_uint)
1406 #ifdef CL_DEVICE_GPU_OVERLAP_NV 1407 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GPU_OVERLAP_NV, cl_bool)
1409 #ifdef CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV 1410 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV, cl_bool)
1412 #ifdef CL_DEVICE_INTEGRATED_MEMORY_NV 1413 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGRATED_MEMORY_NV, cl_bool)
1418 template <
typename Func,
typename T>
1420 getInfo(Func f, cl_uint name, T* param)
1422 return getInfoHelper(f, name, param, 0);
1425 template <
typename Func,
typename Arg0>
1428 Func f_;
const Arg0& arg0_;
1430 cl_uint param, size_type size,
void* value, size_type* size_ret)
1431 {
return f_(arg0_, param, size, value, size_ret); }
1434 template <
typename Func,
typename Arg0,
typename Arg1>
1437 Func f_;
const Arg0& arg0_;
const Arg1& arg1_;
1439 cl_uint param, size_type size,
void* value, size_type* size_ret)
1440 {
return f_(arg0_, arg1_, param, size, value, size_ret); }
1443 template <
typename Func,
typename Arg0,
typename T>
1445 getInfo(Func f,
const Arg0& arg0, cl_uint name, T* param)
1448 return getInfoHelper(f0, name, param, 0);
1451 template <
typename Func,
typename Arg0,
typename Arg1,
typename T>
1453 getInfo(Func f,
const Arg0& arg0,
const Arg1& arg1, cl_uint name, T* param)
1456 return getInfoHelper(f0, name, param, 0);
1460 template<
typename T>
1464 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 1481 { return ::clRetainDevice(device); }
1492 { return ::clReleaseDevice(device); }
1494 #else // CL_HPP_TARGET_OPENCL_VERSION >= 120 1502 static cl_int retain(cl_device_id)
1503 {
return CL_SUCCESS; }
1505 static cl_int release(cl_device_id)
1506 {
return CL_SUCCESS; }
1508 #endif // ! (CL_HPP_TARGET_OPENCL_VERSION >= 120) 1514 static cl_int retain(cl_platform_id)
1515 {
return CL_SUCCESS; }
1517 static cl_int release(cl_platform_id)
1518 {
return CL_SUCCESS; }
1524 static cl_int retain(cl_context context)
1525 { return ::clRetainContext(context); }
1526 static cl_int release(cl_context context)
1527 { return ::clReleaseContext(context); }
1533 static cl_int retain(cl_command_queue queue)
1534 { return ::clRetainCommandQueue(queue); }
1535 static cl_int release(cl_command_queue queue)
1536 { return ::clReleaseCommandQueue(queue); }
1542 static cl_int retain(cl_mem memory)
1543 { return ::clRetainMemObject(memory); }
1544 static cl_int release(cl_mem memory)
1545 { return ::clReleaseMemObject(memory); }
1551 static cl_int retain(cl_sampler sampler)
1552 { return ::clRetainSampler(sampler); }
1553 static cl_int release(cl_sampler sampler)
1554 { return ::clReleaseSampler(sampler); }
1560 static cl_int retain(cl_program program)
1561 { return ::clRetainProgram(program); }
1562 static cl_int release(cl_program program)
1563 { return ::clReleaseProgram(program); }
1569 static cl_int retain(cl_kernel kernel)
1570 { return ::clRetainKernel(kernel); }
1571 static cl_int release(cl_kernel kernel)
1572 { return ::clReleaseKernel(kernel); }
1578 static cl_int retain(cl_event event)
1579 { return ::clRetainEvent(event); }
1580 static cl_int release(cl_event event)
1581 { return ::clReleaseEvent(event); }
1585 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120 1587 static cl_uint getVersion(
const vector<char> &versionInfo)
1589 int highVersion = 0;
1592 while(versionInfo[index] !=
'.' ) {
1594 highVersion += versionInfo[index]-
'0';
1598 while(versionInfo[index] !=
' ' && versionInfo[index] !=
'\0') {
1600 lowVersion += versionInfo[index]-
'0';
1603 return (highVersion << 16) | lowVersion;
1606 static cl_uint getPlatformVersion(cl_platform_id platform)
1609 clGetPlatformInfo(platform, CL_PLATFORM_VERSION, 0, NULL, &size);
1611 vector<char> versionInfo(size);
1612 clGetPlatformInfo(platform, CL_PLATFORM_VERSION, size, versionInfo.data(), &size);
1613 return getVersion(versionInfo);
1616 static cl_uint getDevicePlatformVersion(cl_device_id device)
1618 cl_platform_id platform;
1619 clGetDeviceInfo(device, CL_DEVICE_PLATFORM,
sizeof(platform), &platform, NULL);
1620 return getPlatformVersion(platform);
1623 static cl_uint getContextPlatformVersion(cl_context context)
1628 clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, NULL, &size);
1631 vector<cl_device_id> devices(size/
sizeof(cl_device_id));
1632 clGetContextInfo(context, CL_CONTEXT_DEVICES, size, devices.data(), NULL);
1633 return getDevicePlatformVersion(devices[0]);
1635 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120 1637 template <
typename T>
1649 Wrapper(
const cl_type &obj,
bool retainObject) : object_(obj)
1652 detail::errHandler(retain(), __RETAIN_ERR);
1658 if (object_ != NULL) { release(); }
1663 object_ = rhs.object_;
1664 detail::errHandler(retain(), __RETAIN_ERR);
1669 object_ = rhs.object_;
1676 detail::errHandler(release(), __RELEASE_ERR);
1677 object_ = rhs.object_;
1678 detail::errHandler(retain(), __RETAIN_ERR);
1686 detail::errHandler(release(), __RELEASE_ERR);
1687 object_ = rhs.object_;
1695 detail::errHandler(release(), __RELEASE_ERR);
1700 const cl_type& operator ()()
const {
return object_; }
1702 cl_type& operator ()() {
return object_; }
1704 const cl_type
get()
const {
return object_; }
1706 cl_type
get() {
return object_; }
1710 template<
typename Func,
typename U>
1711 friend inline cl_int getInfoHelper(Func, cl_uint, U*,
int,
typename U::cl_type);
1713 cl_int retain()
const 1715 if (object_ !=
nullptr) {
1723 cl_int release()
const 1725 if (object_ !=
nullptr) {
1738 typedef cl_device_id cl_type;
1742 bool referenceCountable_;
1744 static bool isReferenceCountable(cl_device_id device)
1746 bool retVal =
false;
1747 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 1748 #if CL_HPP_MINIMUM_OPENCL_VERSION < 120 1749 if (device != NULL) {
1750 int version = getDevicePlatformVersion(device);
1751 if(version > ((1 << 16) + 1)) {
1755 #else // CL_HPP_MINIMUM_OPENCL_VERSION < 120 1757 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 120 1758 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 1763 Wrapper() : object_(NULL), referenceCountable_(
false)
1767 Wrapper(
const cl_type &obj,
bool retainObject) :
1769 referenceCountable_(
false)
1771 referenceCountable_ = isReferenceCountable(obj);
1774 detail::errHandler(retain(), __RETAIN_ERR);
1785 object_ = rhs.object_;
1786 referenceCountable_ = isReferenceCountable(object_);
1787 detail::errHandler(retain(), __RETAIN_ERR);
1792 object_ = rhs.object_;
1793 referenceCountable_ = rhs.referenceCountable_;
1795 rhs.referenceCountable_ =
false;
1801 detail::errHandler(release(), __RELEASE_ERR);
1802 object_ = rhs.object_;
1803 referenceCountable_ = rhs.referenceCountable_;
1804 detail::errHandler(retain(), __RETAIN_ERR);
1812 detail::errHandler(release(), __RELEASE_ERR);
1813 object_ = rhs.object_;
1814 referenceCountable_ = rhs.referenceCountable_;
1816 rhs.referenceCountable_ =
false;
1823 detail::errHandler(release(), __RELEASE_ERR);
1825 referenceCountable_ = isReferenceCountable(object_);
1829 const cl_type& operator ()()
const {
return object_; }
1831 cl_type& operator ()() {
return object_; }
1833 cl_type
get()
const {
return object_; }
1836 template<
typename Func,
typename U>
1837 friend inline cl_int getInfoHelper(Func, cl_uint, U*,
int,
typename U::cl_type);
1839 template<
typename Func,
typename U>
1840 friend inline cl_int getInfoHelper(Func, cl_uint, vector<U>*,
int,
typename U::cl_type);
1842 cl_int retain()
const 1844 if( object_ !=
nullptr && referenceCountable_ ) {
1852 cl_int release()
const 1854 if (object_ !=
nullptr && referenceCountable_) {
1863 template <
typename T>
1866 return lhs() == rhs();
1869 template <
typename T>
1872 return !operator==(lhs, rhs);
1879 using BuildLogType = vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, CL_PROGRAM_BUILD_LOG>::param_type>>;
1880 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 1884 class BuildError :
public Error
1887 BuildLogType buildLogs;
1889 BuildError(cl_int err,
const char * errStr,
const BuildLogType &vec) : Error(err, errStr), buildLogs(vec)
1893 BuildLogType getBuildLog()
const 1899 static inline cl_int buildErrHandler(
1901 const char * errStr,
1902 const BuildLogType &buildLogs)
1904 if (err != CL_SUCCESS) {
1905 throw BuildError(err, errStr, buildLogs);
1913 static inline cl_int buildErrHandler(
1915 const char * errStr,
1916 const BuildLogType &buildLogs)
1923 #endif // #if defined(CL_HPP_ENABLE_EXCEPTIONS) 1939 image_channel_order = order;
1940 image_channel_data_type = type;
1947 this->image_channel_data_type = rhs.image_channel_data_type;
1948 this->image_channel_order = rhs.image_channel_order;
1964 static std::once_flag default_initialized_;
1966 static cl_int default_error_;
1973 static void makeDefault();
1980 static void makeDefaultProvided(
const Device &p) {
1985 #ifdef CL_HPP_UNIT_TEST_ENABLE 1992 static void unitTestClearDefault() {
1995 #endif // #ifdef CL_HPP_UNIT_TEST_ENABLE 2004 explicit Device(
const cl_device_id &device,
bool retainObject =
false) :
2005 detail::Wrapper<cl_type>(device, retainObject) { }
2012 cl_int *errResult = NULL)
2014 std::call_once(default_initialized_, makeDefault);
2015 detail::errHandler(default_error_);
2016 if (errResult != NULL) {
2017 *errResult = default_error_;
2031 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_device));
2032 detail::errHandler(default_error_);
2075 template <
typename T>
2076 cl_int
getInfo(cl_device_info name, T* param)
const 2078 return detail::errHandler(
2079 detail::getInfo(&::clGetDeviceInfo, object_, name, param),
2080 __GET_DEVICE_INFO_ERR);
2084 template <cl_
int name>
typename 2089 detail::cl_device_info, name>::param_type param;
2090 cl_int result = getInfo(name, ¶m);
2100 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 2101 cl_int createSubDevices(
2103 const cl_device_partition_property * properties,
2104 vector<Device>* devices)
2107 cl_int err = clCreateSubDevices(object_, properties, 0, NULL, &n);
2108 if (err != CL_SUCCESS) {
2109 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2112 vector<cl_device_id> ids(n);
2113 err = clCreateSubDevices(object_, properties, n, ids.data(), NULL);
2114 if (err != CL_SUCCESS) {
2115 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2121 devices->resize(ids.size());
2125 for (size_type i = 0; i < ids.size(); i++) {
2128 (*devices)[i] =
Device(ids[i],
false);
2134 #elif defined(CL_HPP_USE_CL_DEVICE_FISSION) 2139 cl_int createSubDevices(
2140 const cl_device_partition_property_ext * properties,
2141 vector<Device>* devices)
2143 typedef CL_API_ENTRY cl_int
2144 ( CL_API_CALL * PFN_clCreateSubDevicesEXT)(
2146 const cl_device_partition_property_ext * ,
2149 cl_uint * ) CL_EXT_SUFFIX__VERSION_1_1;
2151 static PFN_clCreateSubDevicesEXT pfn_clCreateSubDevicesEXT = NULL;
2152 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateSubDevicesEXT);
2155 cl_int err = pfn_clCreateSubDevicesEXT(object_, properties, 0, NULL, &n);
2156 if (err != CL_SUCCESS) {
2157 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2160 vector<cl_device_id> ids(n);
2161 err = pfn_clCreateSubDevicesEXT(object_, properties, n, ids.data(), NULL);
2162 if (err != CL_SUCCESS) {
2163 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2168 devices->resize(ids.size());
2172 for (size_type i = 0; i < ids.size(); i++) {
2175 (*devices)[i] =
Device(ids[i],
false);
2180 #endif // defined(CL_HPP_USE_CL_DEVICE_FISSION) 2183 CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Device::default_initialized_;
2184 CL_HPP_DEFINE_STATIC_MEMBER_
Device Device::default_;
2185 CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Device::default_error_ = CL_SUCCESS;
2197 static std::once_flag default_initialized_;
2199 static cl_int default_error_;
2206 static void makeDefault() {
2210 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 2218 cl_int err = ::clGetPlatformIDs(0, NULL, &n);
2219 if (err != CL_SUCCESS) {
2220 default_error_ = err;
2224 default_error_ = CL_INVALID_PLATFORM;
2228 vector<cl_platform_id> ids(n);
2229 err = ::clGetPlatformIDs(n, ids.data(), NULL);
2230 if (err != CL_SUCCESS) {
2231 default_error_ = err;
2237 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 2238 catch (cl::Error &e) {
2239 default_error_ = e.err();
2249 static void makeDefaultProvided(
const Platform &p) {
2254 #ifdef CL_HPP_UNIT_TEST_ENABLE 2261 static void unitTestClearDefault() {
2264 #endif // #ifdef CL_HPP_UNIT_TEST_ENABLE 2276 explicit Platform(
const cl_platform_id &platform,
bool retainObject =
false) :
2277 detail::Wrapper<cl_type>(platform, retainObject) { }
2290 cl_int *errResult = NULL)
2292 std::call_once(default_initialized_, makeDefault);
2293 detail::errHandler(default_error_);
2294 if (errResult != NULL) {
2295 *errResult = default_error_;
2309 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_platform));
2310 detail::errHandler(default_error_);
2315 cl_int
getInfo(cl_platform_info name,
string* param)
const 2317 return detail::errHandler(
2318 detail::getInfo(&::clGetPlatformInfo, object_, name, param),
2319 __GET_PLATFORM_INFO_ERR);
2323 template <cl_
int name>
typename 2328 detail::cl_platform_info, name>::param_type param;
2329 cl_int result = getInfo(name, ¶m);
2341 cl_device_type type,
2342 vector<Device>* devices)
const 2345 if( devices == NULL ) {
2346 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR);
2348 cl_int err = ::clGetDeviceIDs(object_, type, 0, NULL, &n);
2349 if (err != CL_SUCCESS) {
2350 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2353 vector<cl_device_id> ids(n);
2354 err = ::clGetDeviceIDs(object_, type, n, ids.data(), NULL);
2355 if (err != CL_SUCCESS) {
2356 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2364 devices->resize(ids.size());
2368 for (size_type i = 0; i < ids.size(); i++) {
2369 (*devices)[i] =
Device(ids[i],
true);
2375 #if defined(CL_HPP_USE_DX_INTEROP) 2400 cl_d3d10_device_source_khr d3d_device_source,
2402 cl_d3d10_device_set_khr d3d_device_set,
2403 vector<Device>* devices)
const 2405 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clGetDeviceIDsFromD3D10KHR)(
2406 cl_platform_id platform,
2407 cl_d3d10_device_source_khr d3d_device_source,
2409 cl_d3d10_device_set_khr d3d_device_set,
2410 cl_uint num_entries,
2411 cl_device_id * devices,
2412 cl_uint* num_devices);
2414 if( devices == NULL ) {
2415 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR);
2418 static PFN_clGetDeviceIDsFromD3D10KHR pfn_clGetDeviceIDsFromD3D10KHR = NULL;
2419 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(object_, clGetDeviceIDsFromD3D10KHR);
2422 cl_int err = pfn_clGetDeviceIDsFromD3D10KHR(
2430 if (err != CL_SUCCESS) {
2431 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2434 vector<cl_device_id> ids(n);
2435 err = pfn_clGetDeviceIDsFromD3D10KHR(
2443 if (err != CL_SUCCESS) {
2444 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2452 devices->resize(ids.size());
2456 for (size_type i = 0; i < ids.size(); i++) {
2457 (*devices)[i] =
Device(ids[i],
true);
2469 vector<Platform>* platforms)
2473 if( platforms == NULL ) {
2474 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_PLATFORM_IDS_ERR);
2477 cl_int err = ::clGetPlatformIDs(0, NULL, &n);
2478 if (err != CL_SUCCESS) {
2479 return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
2482 vector<cl_platform_id> ids(n);
2483 err = ::clGetPlatformIDs(n, ids.data(), NULL);
2484 if (err != CL_SUCCESS) {
2485 return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
2489 platforms->resize(ids.size());
2492 for (size_type i = 0; i < ids.size(); i++) {
2493 (*platforms)[i] =
Platform(ids[i]);
2507 Platform default_platform = Platform::getDefault(&err);
2509 *platform = default_platform;
2523 cl_int * errResult = NULL)
2526 Platform default_platform = Platform::getDefault(&err);
2530 return default_platform;
2533 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 2538 return ::clUnloadPlatformCompiler(object_);
2540 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 2543 CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Platform::default_initialized_;
2544 CL_HPP_DEFINE_STATIC_MEMBER_
Platform Platform::default_;
2545 CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Platform::default_error_ = CL_SUCCESS;
2551 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 2556 inline CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_int
2561 return ::clUnloadCompiler();
2563 #endif // #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 2577 static std::once_flag default_initialized_;
2579 static cl_int default_error_;
2586 static void makeDefault() {
2590 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 2594 #if !defined(__APPLE__) && !defined(__MACOS) 2595 const Platform &p = Platform::getDefault();
2596 cl_platform_id defaultPlatform = p();
2597 cl_context_properties properties[3] = {
2598 CL_CONTEXT_PLATFORM, (cl_context_properties)defaultPlatform, 0
2600 #else // #if !defined(__APPLE__) && !defined(__MACOS) 2601 cl_context_properties *properties =
nullptr;
2602 #endif // #if !defined(__APPLE__) && !defined(__MACOS) 2605 CL_DEVICE_TYPE_DEFAULT,
2611 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 2612 catch (cl::Error &e) {
2613 default_error_ = e.err();
2624 static void makeDefaultProvided(
const Context &c) {
2629 #ifdef CL_HPP_UNIT_TEST_ENABLE 2636 static void unitTestClearDefault() {
2639 #endif // #ifdef CL_HPP_UNIT_TEST_ENABLE 2646 const vector<Device>& devices,
2647 cl_context_properties* properties = NULL,
2648 void (CL_CALLBACK * notifyFptr)(
2658 size_type numDevices = devices.size();
2659 vector<cl_device_id> deviceIDs(numDevices);
2661 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
2662 deviceIDs[deviceIndex] = (devices[deviceIndex])();
2665 object_ = ::clCreateContext(
2666 properties, (cl_uint) numDevices,
2668 notifyFptr, data, &error);
2670 detail::errHandler(error, __CREATE_CONTEXT_ERR);
2678 cl_context_properties* properties = NULL,
2679 void (CL_CALLBACK * notifyFptr)(
2689 cl_device_id deviceID = device();
2691 object_ = ::clCreateContext(
2694 notifyFptr, data, &error);
2696 detail::errHandler(error, __CREATE_CONTEXT_ERR);
2707 cl_device_type type,
2708 cl_context_properties* properties = NULL,
2709 void (CL_CALLBACK * notifyFptr)(
2719 #if !defined(__APPLE__) && !defined(__MACOS) 2720 cl_context_properties prop[4] = {CL_CONTEXT_PLATFORM, 0, 0, 0 };
2722 if (properties == NULL) {
2724 vector<Platform> platforms;
2725 error = Platform::get(&platforms);
2726 if (error != CL_SUCCESS) {
2727 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
2735 cl_context_properties platform_id = 0;
2736 for (
unsigned int i = 0; i < platforms.size(); i++) {
2738 vector<Device> devices;
2740 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 2744 error = platforms[i].getDevices(type, &devices);
2746 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 2747 }
catch (cl::Error& e) {
2755 if (error != CL_SUCCESS && error != CL_DEVICE_NOT_FOUND) {
2756 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
2762 if (devices.size() > 0) {
2763 platform_id = (cl_context_properties)platforms[i]();
2768 if (platform_id == 0) {
2769 detail::errHandler(CL_DEVICE_NOT_FOUND, __CREATE_CONTEXT_FROM_TYPE_ERR);
2771 *err = CL_DEVICE_NOT_FOUND;
2776 prop[1] = platform_id;
2777 properties = &prop[0];
2780 object_ = ::clCreateContextFromType(
2781 properties, type, notifyFptr, data, &error);
2783 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
2824 std::call_once(default_initialized_, makeDefault);
2825 detail::errHandler(default_error_);
2827 *err = default_error_;
2841 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_context));
2842 detail::errHandler(default_error_);
2854 explicit Context(
const cl_context& context,
bool retainObject =
false) :
2855 detail::Wrapper<cl_type>(context, retainObject) { }
2869 template <
typename T>
2870 cl_int
getInfo(cl_context_info name, T* param)
const 2872 return detail::errHandler(
2873 detail::getInfo(&::clGetContextInfo, object_, name, param),
2874 __GET_CONTEXT_INFO_ERR);
2878 template <cl_
int name>
typename 2883 detail::cl_context_info, name>::param_type param;
2884 cl_int result = getInfo(name, ¶m);
2897 cl_mem_object_type type,
2898 vector<ImageFormat>* formats)
const 2906 cl_int err = ::clGetSupportedImageFormats(
2913 if (err != CL_SUCCESS) {
2914 return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
2917 if (numEntries > 0) {
2918 vector<ImageFormat> value(numEntries);
2919 err = ::clGetSupportedImageFormats(
2924 (cl_image_format*)value.data(),
2926 if (err != CL_SUCCESS) {
2927 return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
2930 formats->assign(begin(value), end(value));
2941 inline void Device::makeDefault()
2946 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 2953 detail::errHandler(error, __CREATE_CONTEXT_ERR);
2955 if (error != CL_SUCCESS) {
2956 default_error_ = error;
2959 default_ = context.
getInfo<CL_CONTEXT_DEVICES>()[0];
2960 default_error_ = CL_SUCCESS;
2963 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 2964 catch (cl::Error &e) {
2965 default_error_ = e.err();
2970 CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Context::default_initialized_;
2971 CL_HPP_DEFINE_STATIC_MEMBER_
Context Context::default_;
2972 CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Context::default_error_ = CL_SUCCESS;
2986 Event() : detail::Wrapper<cl_type>() { }
2996 explicit Event(
const cl_event& event,
bool retainObject =
false) :
2997 detail::Wrapper<cl_type>(event, retainObject) { }
3011 template <
typename T>
3012 cl_int
getInfo(cl_event_info name, T* param)
const 3014 return detail::errHandler(
3015 detail::getInfo(&::clGetEventInfo, object_, name, param),
3016 __GET_EVENT_INFO_ERR);
3020 template <cl_
int name>
typename 3025 detail::cl_event_info, name>::param_type param;
3026 cl_int result = getInfo(name, ¶m);
3034 template <
typename T>
3037 return detail::errHandler(detail::getInfo(
3038 &::clGetEventProfilingInfo, object_, name, param),
3039 __GET_EVENT_PROFILE_INFO_ERR);
3043 template <cl_
int name>
typename 3048 detail::cl_profiling_info, name>::param_type param;
3049 cl_int result = getProfilingInfo(name, ¶m);
3062 return detail::errHandler(
3063 ::clWaitForEvents(1, &object_),
3064 __WAIT_FOR_EVENTS_ERR);
3067 #if CL_HPP_TARGET_OPENCL_VERSION >= 110 3074 void (CL_CALLBACK * pfn_notify)(cl_event, cl_int,
void *),
3075 void * user_data = NULL)
3077 return detail::errHandler(
3078 ::clSetEventCallback(
3083 __SET_EVENT_CALLBACK_ERR);
3085 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110 3094 return detail::errHandler(
3096 (cl_uint) events.size(), (events.size() > 0) ? (cl_event*)&events.front() : NULL),
3097 __WAIT_FOR_EVENTS_ERR);
3101 #if CL_HPP_TARGET_OPENCL_VERSION >= 110 3115 cl_int * err = NULL)
3118 object_ = ::clCreateUserEvent(
3122 detail::errHandler(error, __CREATE_USER_EVENT_ERR);
3137 return detail::errHandler(
3138 ::clSetUserEventStatus(object_,status),
3139 __SET_USER_EVENT_STATUS_ERR);
3142 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110 3148 inline static cl_int
3149 WaitForEvents(
const vector<Event>& events)
3151 return detail::errHandler(
3153 (cl_uint) events.size(), (events.size() > 0) ? (cl_event*)&events.front() : NULL),
3154 __WAIT_FOR_EVENTS_ERR);
3182 explicit Memory(
const cl_mem& memory,
bool retainObject) :
3183 detail::Wrapper<cl_type>(memory, retainObject) { }
3226 template <
typename T>
3229 return detail::errHandler(
3230 detail::getInfo(&::clGetMemObjectInfo, object_, name, param),
3231 __GET_MEM_OBJECT_INFO_ERR);
3235 template <cl_
int name>
typename 3240 detail::cl_mem_info, name>::param_type param;
3241 cl_int result = getInfo(name, ¶m);
3248 #if CL_HPP_TARGET_OPENCL_VERSION >= 110 3263 void (CL_CALLBACK * pfn_notify)(cl_mem,
void *),
3264 void * user_data = NULL)
3266 return detail::errHandler(
3267 ::clSetMemObjectDestructorCallback(
3271 __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR);
3273 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110 3279 template<
typename IteratorType >
3280 cl_int
copy( IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer );
3281 template<
typename IteratorType >
3282 cl_int
copy(
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator );
3283 template<
typename IteratorType >
3285 template<
typename IteratorType >
3289 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 3295 static cl_svm_mem_flags getSVMMemFlags()
3302 template<
class Trait = detail::SVMTraitNull>
3306 static cl_svm_mem_flags getSVMMemFlags()
3308 return CL_MEM_READ_WRITE |
3309 Trait::getSVMMemFlags();
3313 template<
class Trait = detail::SVMTraitNull>
3317 static cl_svm_mem_flags getSVMMemFlags()
3319 return CL_MEM_READ_ONLY |
3320 Trait::getSVMMemFlags();
3324 template<
class Trait = detail::SVMTraitNull>
3328 static cl_svm_mem_flags getSVMMemFlags()
3330 return CL_MEM_WRITE_ONLY |
3331 Trait::getSVMMemFlags();
3335 template<
class Trait = SVMTraitReadWrite<>>
3339 static cl_svm_mem_flags getSVMMemFlags()
3341 return Trait::getSVMMemFlags();
3345 template<
class Trait = SVMTraitReadWrite<>>
3349 static cl_svm_mem_flags getSVMMemFlags()
3351 return CL_MEM_SVM_FINE_GRAIN_BUFFER |
3352 Trait::getSVMMemFlags();
3356 template<
class Trait = SVMTraitReadWrite<>>
3360 static cl_svm_mem_flags getSVMMemFlags()
3363 CL_MEM_SVM_FINE_GRAIN_BUFFER |
3364 CL_MEM_SVM_ATOMICS |
3365 Trait::getSVMMemFlags();
3370 template<
typename T>
3376 const vector<Event>* events = NULL,
3377 Event* event = NULL);
3390 template<
typename T,
class SVMTrait>
3396 typedef T value_type;
3397 typedef value_type* pointer;
3398 typedef const value_type* const_pointer;
3399 typedef value_type& reference;
3400 typedef const value_type& const_reference;
3401 typedef std::size_t size_type;
3402 typedef std::ptrdiff_t difference_type;
3404 template<
typename U>
3410 template<
typename U,
typename V>
3425 context_(other.context_)
3429 template<
typename U>
3431 context_(other.context_)
3439 pointer address(reference r) CL_HPP_NOEXCEPT_
3441 return std::addressof(r);
3444 const_pointer address(const_reference r) CL_HPP_NOEXCEPT_
3446 return std::addressof(r);
3463 SVMTrait::getSVMMemFlags(),
3466 pointer retValue =
reinterpret_cast<pointer
>(
3468 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 3470 std::bad_alloc excep;
3473 #endif // #if defined(CL_HPP_ENABLE_EXCEPTIONS) 3476 if (!(SVMTrait::getSVMMemFlags() & CL_MEM_SVM_FINE_GRAIN_BUFFER)) {
3477 cl_int err =
enqueueMapSVM(retValue, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE, size*
sizeof(T));
3478 if (err != CL_SUCCESS) {
3479 std::bad_alloc excep;
3488 void deallocate(pointer p, size_type)
3490 clSVMFree(context_(), p);
3499 size_type maxSize = std::numeric_limits<size_type>::max() /
sizeof(T);
3501 for (
const Device &d : context_.
getInfo<CL_CONTEXT_DEVICES>()) {
3504 static_cast<size_type>(d.getInfo<CL_DEVICE_MAX_MEM_ALLOC_SIZE>()));
3510 template<
class U,
class... Args >
3511 void construct(U* p, Args&&... args)
3527 return (context_==rhs.context_);
3532 return !operator==(a);
3537 template<
class SVMTrait>
3540 typedef void value_type;
3541 typedef value_type* pointer;
3542 typedef const value_type* const_pointer;
3544 template<
typename U>
3550 template<
typename U,
typename V>
3554 #if !defined(CL_HPP_NO_STD_UNIQUE_PTR) 3557 template<
class Alloc>
3564 typedef typename std::allocator_traits<Alloc>::pointer pointer;
3566 Deleter(
const Alloc &alloc, size_type copies) : alloc_{ alloc }, copies_{ copies }
3570 void operator()(pointer ptr)
const {
3571 Alloc tmpAlloc{ alloc_ };
3572 std::allocator_traits<Alloc>::destroy(tmpAlloc, std::addressof(*ptr));
3573 std::allocator_traits<Alloc>::deallocate(tmpAlloc, ptr, copies_);
3584 template <
class T,
class Alloc,
class... Args>
3587 Alloc alloc(alloc_);
3588 static const size_type copies = 1;
3593 T* tmp = std::allocator_traits<Alloc>::allocate(alloc, copies);
3595 std::bad_alloc excep;
3599 std::allocator_traits<Alloc>::construct(
3601 std::addressof(*tmp),
3602 std::forward<Args>(args)...);
3606 catch (std::bad_alloc b)
3608 std::allocator_traits<Alloc>::deallocate(alloc, tmp, copies);
3613 template<
class T,
class SVMTrait,
class... Args >
3614 cl::pointer<T, detail::Deleter<SVMAllocator<T, SVMTrait>>> allocate_svm(Args... args)
3617 return cl::allocate_pointer<T>(alloc, args...);
3620 template<
class T,
class SVMTrait,
class... Args >
3621 cl::pointer<T, detail::Deleter<SVMAllocator<T, SVMTrait>>> allocate_svm(
const cl::Context &c, Args... args)
3624 return cl::allocate_pointer<T>(alloc, args...);
3626 #endif // #if !defined(CL_HPP_NO_STD_UNIQUE_PTR) 3631 template <
class T >
3637 template <
class T >
3643 template <
class T >
3646 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 3670 void* host_ptr = NULL,
3674 object_ = ::clCreateBuffer(context(), flags, size, host_ptr, &error);
3676 detail::errHandler(error, __CREATE_BUFFER_ERR);
3694 void* host_ptr = NULL,
3701 object_ = ::clCreateBuffer(context(), flags, size, host_ptr, &error);
3703 detail::errHandler(error, __CREATE_BUFFER_ERR);
3714 template<
typename IteratorType >
3716 IteratorType startIterator,
3717 IteratorType endIterator,
3719 bool useHostPtr =
false,
3722 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
3725 cl_mem_flags flags = 0;
3727 flags |= CL_MEM_READ_ONLY;
3730 flags |= CL_MEM_READ_WRITE;
3733 flags |= CL_MEM_USE_HOST_PTR;
3736 size_type size =
sizeof(DataType)*(endIterator - startIterator);
3741 object_ = ::clCreateBuffer(context(), flags, size, static_cast<DataType*>(&*startIterator), &error);
3743 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
3746 detail::errHandler(error, __CREATE_BUFFER_ERR);
3752 error =
cl::copy(startIterator, endIterator, *
this);
3753 detail::errHandler(error, __CREATE_BUFFER_ERR);
3765 template<
typename IteratorType >
3766 Buffer(
const Context &context, IteratorType startIterator, IteratorType endIterator,
3767 bool readOnly,
bool useHostPtr =
false, cl_int* err = NULL);
3773 template<
typename IteratorType >
3774 Buffer(
const CommandQueue &queue, IteratorType startIterator, IteratorType endIterator,
3775 bool readOnly,
bool useHostPtr =
false, cl_int* err = NULL);
3787 explicit Buffer(
const cl_mem& buffer,
bool retainObject =
false) :
3788 Memory(buffer, retainObject) { }
3828 #if CL_HPP_TARGET_OPENCL_VERSION >= 110 3835 cl_buffer_create_type buffer_create_type,
3836 const void * buffer_create_info,
3837 cl_int * err = NULL)
3841 result.object_ = ::clCreateSubBuffer(
3848 detail::errHandler(error, __CREATE_SUBBUFFER_ERR);
3855 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110 3858 #if defined (CL_HPP_USE_DX_INTEROP) 3867 class BufferD3D10 :
public Buffer 3880 ID3D10Buffer* bufobj,
3881 cl_int * err = NULL) : pfn_clCreateFromD3D10BufferKHR(
nullptr)
3883 typedef CL_API_ENTRY cl_mem (CL_API_CALL *PFN_clCreateFromD3D10BufferKHR)(
3884 cl_context context, cl_mem_flags flags, ID3D10Buffer* buffer,
3885 cl_int* errcode_ret);
3886 PFN_clCreateFromD3D10BufferKHR pfn_clCreateFromD3D10BufferKHR;
3887 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 3888 vector<cl_context_properties> props = context.getInfo<CL_CONTEXT_PROPERTIES>();
3889 cl_platform platform = -1;
3890 for(
int i = 0; i < props.size(); ++i ) {
3891 if( props[i] == CL_CONTEXT_PLATFORM ) {
3892 platform = props[i+1];
3895 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCreateFromD3D10BufferKHR);
3896 #elif CL_HPP_TARGET_OPENCL_VERSION >= 110 3897 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateFromD3D10BufferKHR);
3901 object_ = pfn_clCreateFromD3D10BufferKHR(
3907 detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
3914 BufferD3D10() :
Buffer() { }
3923 explicit BufferD3D10(
const cl_mem& buffer,
bool retainObject =
false) :
3924 Buffer(buffer, retainObject) { }
3930 BufferD3D10& operator = (
const cl_mem& rhs)
3939 BufferD3D10(
const BufferD3D10& buf) :
3945 BufferD3D10& operator = (
const BufferD3D10 &buf)
3954 BufferD3D10(BufferD3D10&& buf) CL_HPP_NOEXCEPT_ :
Buffer(std::move(buf)) {}
3959 BufferD3D10& operator = (BufferD3D10 &&buf)
3987 cl_int * err = NULL)
3990 object_ = ::clCreateFromGLBuffer(
3996 detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
4012 explicit BufferGL(
const cl_mem& buffer,
bool retainObject =
false) :
4013 Buffer(buffer, retainObject) { }
4055 cl_gl_object_type *type,
4056 cl_GLuint * gl_object_name)
4058 return detail::errHandler(
4059 ::clGetGLObjectInfo(object_,type,gl_object_name),
4060 __GET_GL_OBJECT_INFO_ERR);
4084 cl_int * err = NULL)
4087 object_ = ::clCreateFromGLRenderbuffer(
4093 detail::errHandler(error, __CREATE_GL_RENDER_BUFFER_ERR);
4110 Buffer(buffer, retainObject) { }
4152 cl_gl_object_type *type,
4153 cl_GLuint * gl_object_name)
4155 return detail::errHandler(
4156 ::clGetGLObjectInfo(object_,type,gl_object_name),
4157 __GET_GL_OBJECT_INFO_ERR);
4180 explicit Image(
const cl_mem& image,
bool retainObject =
false) :
4181 Memory(image, retainObject) { }
4224 template <
typename T>
4227 return detail::errHandler(
4228 detail::getInfo(&::clGetImageInfo, object_, name, param),
4229 __GET_IMAGE_INFO_ERR);
4233 template <cl_
int name>
typename 4238 detail::cl_image_info, name>::param_type param;
4239 cl_int result = getImageInfo(name, ¶m);
4247 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 4266 void* host_ptr = NULL,
4270 cl_image_desc desc =
4272 CL_MEM_OBJECT_IMAGE1D,
4274 0, 0, 0, 0, 0, 0, 0, 0
4276 object_ = ::clCreateImage(
4284 detail::errHandler(error, __CREATE_IMAGE_ERR);
4300 explicit Image1D(
const cl_mem& image1D,
bool retainObject =
false) :
4301 Image(image1D, retainObject) { }
4358 cl_image_desc desc =
4360 CL_MEM_OBJECT_IMAGE1D_BUFFER,
4362 0, 0, 0, 0, 0, 0, 0,
4365 object_ = ::clCreateImage(
4373 detail::errHandler(error, __CREATE_IMAGE_ERR);
4389 Image(image1D, retainObject) { }
4437 size_type arraySize,
4440 void* host_ptr = NULL,
4444 cl_image_desc desc =
4446 CL_MEM_OBJECT_IMAGE1D_ARRAY,
4453 object_ = ::clCreateImage(
4461 detail::errHandler(error, __CREATE_IMAGE_ERR);
4476 explicit Image1DArray(
const cl_mem& imageArray,
bool retainObject =
false) :
4477 Image(imageArray, retainObject) { }
4515 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 120 4537 size_type row_pitch = 0,
4538 void* host_ptr = NULL,
4542 bool useCreateImage;
4544 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120 4547 cl_uint version = detail::getContextPlatformVersion(context());
4548 useCreateImage = (version >= 0x10002);
4550 #elif CL_HPP_TARGET_OPENCL_VERSION >= 120 4551 useCreateImage =
true;
4553 useCreateImage =
false;
4556 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 4559 cl_image_desc desc =
4561 CL_MEM_OBJECT_IMAGE2D,
4568 object_ = ::clCreateImage(
4576 detail::errHandler(error, __CREATE_IMAGE_ERR);
4581 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 4582 #if CL_HPP_MINIMUM_OPENCL_VERSION < 120 4583 if (!useCreateImage)
4585 object_ = ::clCreateImage2D(
4586 context(), flags,&format, width, height, row_pitch, host_ptr, &error);
4588 detail::errHandler(error, __CREATE_IMAGE2D_ERR);
4593 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 120 4596 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 || defined(CL_HPP_USE_CL_IMAGE2D_FROM_BUFFER_KHR) 4605 const Buffer &sourceBuffer,
4608 size_type row_pitch = 0,
4609 cl_int* err =
nullptr)
4613 cl_image_desc desc =
4615 CL_MEM_OBJECT_IMAGE2D,
4624 object_ = ::clCreateImage(
4632 detail::errHandler(error, __CREATE_IMAGE_ERR);
4633 if (err !=
nullptr) {
4637 #endif //#if CL_HPP_TARGET_OPENCL_VERSION >= 200 || defined(CL_HPP_USE_CL_IMAGE2D_FROM_BUFFER_KHR) 4639 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 4654 cl_channel_order order,
4655 const Image &sourceImage,
4656 cl_int* err =
nullptr)
4661 size_type sourceWidth =
4663 size_type sourceHeight =
4665 size_type sourceRowPitch =
4667 cl_uint sourceNumMIPLevels =
4669 cl_uint sourceNumSamples =
4671 cl_image_format sourceFormat =
4676 sourceFormat.image_channel_order = order;
4677 cl_image_desc desc =
4679 CL_MEM_OBJECT_IMAGE2D,
4690 object_ = ::clCreateImage(
4698 detail::errHandler(error, __CREATE_IMAGE_ERR);
4699 if (err !=
nullptr) {
4703 #endif //#if CL_HPP_TARGET_OPENCL_VERSION >= 200 4715 explicit Image2D(
const cl_mem& image2D,
bool retainObject =
false) :
4716 Image(image2D, retainObject) { }
4759 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 4783 cl_int * err = NULL)
4786 object_ = ::clCreateFromGLTexture2D(
4794 detail::errHandler(error, __CREATE_GL_TEXTURE_2D_ERR);
4811 explicit Image2DGL(
const cl_mem& image,
bool retainObject =
false) :
4812 Image2D(image, retainObject) { }
4852 } CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
4853 #endif // CL_USE_DEPRECATED_OPENCL_1_1_APIS 4855 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 4866 size_type arraySize,
4870 size_type slicePitch,
4871 void* host_ptr = NULL,
4875 cl_image_desc desc =
4877 CL_MEM_OBJECT_IMAGE2D_ARRAY,
4886 object_ = ::clCreateImage(
4894 detail::errHandler(error, __CREATE_IMAGE_ERR);
4909 explicit Image2DArray(
const cl_mem& imageArray,
bool retainObject =
false) :
Image(imageArray, retainObject) { }
4945 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 120 4967 size_type row_pitch = 0,
4968 size_type slice_pitch = 0,
4969 void* host_ptr = NULL,
4973 bool useCreateImage;
4975 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120 4978 cl_uint version = detail::getContextPlatformVersion(context());
4979 useCreateImage = (version >= 0x10002);
4981 #elif CL_HPP_TARGET_OPENCL_VERSION >= 120 4982 useCreateImage =
true;
4984 useCreateImage =
false;
4987 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 4990 cl_image_desc desc =
4992 CL_MEM_OBJECT_IMAGE3D,
5001 object_ = ::clCreateImage(
5009 detail::errHandler(error, __CREATE_IMAGE_ERR);
5014 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 5015 #if CL_HPP_MINIMUM_OPENCL_VERSION < 120 5016 if (!useCreateImage)
5018 object_ = ::clCreateImage3D(
5019 context(), flags, &format, width, height, depth, row_pitch,
5020 slice_pitch, host_ptr, &error);
5022 detail::errHandler(error, __CREATE_IMAGE3D_ERR);
5027 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 120 5040 explicit Image3D(
const cl_mem& image3D,
bool retainObject =
false) :
5041 Image(image3D, retainObject) { }
5082 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 5105 cl_int * err = NULL)
5108 object_ = ::clCreateFromGLTexture3D(
5116 detail::errHandler(error, __CREATE_GL_TEXTURE_3D_ERR);
5132 explicit Image3DGL(
const cl_mem& image,
bool retainObject =
false) :
5133 Image3D(image, retainObject) { }
5173 #endif // CL_USE_DEPRECATED_OPENCL_1_1_APIS 5175 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 5191 cl_int * err = NULL)
5194 object_ = ::clCreateFromGLTexture(
5202 detail::errHandler(error, __CREATE_GL_TEXTURE_ERR);
5217 explicit ImageGL(
const cl_mem& image,
bool retainObject =
false) :
5218 Image(image, retainObject) { }
5220 ImageGL& operator = (
const cl_mem& rhs)
5254 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 5258 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 5280 cl_uint packet_size,
5281 cl_uint max_packets,
5286 cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS;
5287 object_ = ::clCreatePipe(context(), flags, packet_size, max_packets,
nullptr, &error);
5289 detail::errHandler(error, __CREATE_PIPE_ERR);
5304 cl_uint packet_size,
5305 cl_uint max_packets,
5312 cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS;
5313 object_ = ::clCreatePipe(context(), flags, packet_size, max_packets,
nullptr, &error);
5315 detail::errHandler(error, __CREATE_PIPE_ERR);
5331 explicit Pipe(
const cl_mem& pipe,
bool retainObject =
false) :
5332 Memory(pipe, retainObject) { }
5338 Pipe& operator = (
const cl_mem& rhs)
5373 template <
typename T>
5376 return detail::errHandler(
5377 detail::getInfo(&::clGetPipeInfo, object_, name, param),
5378 __GET_PIPE_INFO_ERR);
5382 template <cl_
int name>
typename 5387 detail::cl_pipe_info, name>::param_type param;
5388 cl_int result = getInfo(name, ¶m);
5395 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200 5418 cl_bool normalized_coords,
5419 cl_addressing_mode addressing_mode,
5420 cl_filter_mode filter_mode,
5425 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 5426 cl_sampler_properties sampler_properties[] = {
5427 CL_SAMPLER_NORMALIZED_COORDS, normalized_coords,
5428 CL_SAMPLER_ADDRESSING_MODE, addressing_mode,
5429 CL_SAMPLER_FILTER_MODE, filter_mode,
5431 object_ = ::clCreateSamplerWithProperties(
5436 detail::errHandler(error, __CREATE_SAMPLER_WITH_PROPERTIES_ERR);
5441 object_ = ::clCreateSampler(
5448 detail::errHandler(error, __CREATE_SAMPLER_ERR);
5463 explicit Sampler(
const cl_sampler& sampler,
bool retainObject =
false) :
5464 detail::Wrapper<cl_type>(sampler, retainObject) { }
5506 template <
typename T>
5507 cl_int
getInfo(cl_sampler_info name, T* param)
const 5509 return detail::errHandler(
5510 detail::getInfo(&::clGetSamplerInfo, object_, name, param),
5511 __GET_SAMPLER_INFO_ERR);
5515 template <cl_
int name>
typename 5520 detail::cl_sampler_info, name>::param_type param;
5521 cl_int result = getInfo(name, ¶m);
5538 size_type sizes_[3];
5539 cl_uint dimensions_;
5570 NDRange(size_type size0, size_type size1, size_type size2)
5582 operator const size_type*()
const {
5596 return dimensions_*
sizeof(size_type);
5604 const size_type*
get()
const 5611 static const NDRange NullRange;
5621 template <
typename T,
class Enable =
void>
5626 template <
typename T>
5629 static size_type size(
const T&) {
return sizeof(T); }
5630 static const T* ptr(
const T& value) {
return &value; }
5635 template <
typename T>
5638 static size_type size(
const T&) {
return sizeof(cl_mem); }
5639 static const cl_mem* ptr(
const T& value) {
return &(value()); }
5647 static size_type size(
const LocalSpaceArg& value) {
return value.size_; }
5648 static const void* ptr(
const LocalSpaceArg&) {
return NULL; }
5675 inline Kernel(
const Program& program,
const char* name, cl_int* err = NULL);
5688 explicit Kernel(
const cl_kernel& kernel,
bool retainObject =
false) :
5689 detail::Wrapper<cl_type>(kernel, retainObject) { }
5730 template <
typename T>
5731 cl_int getInfo(cl_kernel_info name, T* param)
const 5733 return detail::errHandler(
5734 detail::getInfo(&::clGetKernelInfo, object_, name, param),
5735 __GET_KERNEL_INFO_ERR);
5738 template <cl_
int name>
typename 5740 getInfo(cl_int* err = NULL)
const 5743 detail::cl_kernel_info, name>::param_type param;
5744 cl_int result = getInfo(name, ¶m);
5751 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 5752 template <
typename T>
5753 cl_int getArgInfo(cl_uint argIndex, cl_kernel_arg_info name, T* param)
const 5755 return detail::errHandler(
5756 detail::getInfo(&::clGetKernelArgInfo, object_, argIndex, name, param),
5757 __GET_KERNEL_ARG_INFO_ERR);
5760 template <cl_
int name>
typename 5762 getArgInfo(cl_uint argIndex, cl_int* err = NULL)
const 5765 detail::cl_kernel_arg_info, name>::param_type param;
5766 cl_int result = getArgInfo(argIndex, name, ¶m);
5772 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 5774 template <
typename T>
5775 cl_int getWorkGroupInfo(
5776 const Device& device, cl_kernel_work_group_info name, T* param)
const 5778 return detail::errHandler(
5780 &::clGetKernelWorkGroupInfo, object_, device(), name, param),
5781 __GET_KERNEL_WORK_GROUP_INFO_ERR);
5784 template <cl_
int name>
typename 5786 getWorkGroupInfo(
const Device& device, cl_int* err = NULL)
const 5789 detail::cl_kernel_work_group_info, name>::param_type param;
5790 cl_int result = getWorkGroupInfo(device, name, ¶m);
5797 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 5798 #if defined(CL_HPP_USE_CL_SUB_GROUPS_KHR) 5799 cl_int getSubGroupInfo(
const cl::Device &dev, cl_kernel_sub_group_info name,
const cl::NDRange &range, size_type* param)
const 5801 typedef clGetKernelSubGroupInfoKHR_fn PFN_clGetKernelSubGroupInfoKHR;
5802 static PFN_clGetKernelSubGroupInfoKHR pfn_clGetKernelSubGroupInfoKHR = NULL;
5803 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetKernelSubGroupInfoKHR);
5805 return detail::errHandler(
5806 pfn_clGetKernelSubGroupInfoKHR(object_, dev(), name, range.
size(), range.get(),
sizeof(size_type), param,
nullptr),
5807 __GET_KERNEL_ARG_INFO_ERR);
5810 template <cl_
int name>
5811 size_type getSubGroupInfo(
const cl::Device &dev,
const cl::NDRange &range, cl_int* err = NULL)
const 5814 cl_int result = getSubGroupInfo(dev, name, range, ¶m);
5820 #endif // #if defined(CL_HPP_USE_CL_SUB_GROUPS_KHR) 5821 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 5823 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 5826 template<
typename T,
class D>
5827 cl_int
setArg(cl_uint index,
const cl::pointer<T, D> &argPtr)
5829 return detail::errHandler(
5830 ::clSetKernelArgSVMPointer(object_, index, argPtr.get()),
5831 __SET_KERNEL_ARGS_ERR);
5836 template<
typename T,
class Alloc>
5837 cl_int
setArg(cl_uint index,
const cl::vector<T, Alloc> &argPtr)
5839 return detail::errHandler(
5840 ::clSetKernelArgSVMPointer(object_, index, argPtr.data()),
5841 __SET_KERNEL_ARGS_ERR);
5846 template<
typename T>
5847 typename std::enable_if<std::is_pointer<T>::value, cl_int>::type
5850 return detail::errHandler(
5851 ::clSetKernelArgSVMPointer(object_, index, argPtr),
5852 __SET_KERNEL_ARGS_ERR);
5854 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 5858 template <
typename T>
5859 typename std::enable_if<!std::is_pointer<T>::value, cl_int>::type
5862 return detail::errHandler(
5868 __SET_KERNEL_ARGS_ERR);
5871 cl_int setArg(cl_uint index, size_type size,
const void* argPtr)
5873 return detail::errHandler(
5874 ::clSetKernelArg(object_, index, size, argPtr),
5875 __SET_KERNEL_ARGS_ERR);
5878 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 5885 return detail::errHandler(
5886 ::clSetKernelExecInfo(
5888 CL_KERNEL_EXEC_INFO_SVM_PTRS,
5889 sizeof(
void*)*pointerList.size(),
5890 pointerList.data()));
5897 template<
int ArrayLength>
5900 return detail::errHandler(
5901 ::clSetKernelExecInfo(
5903 CL_KERNEL_EXEC_INFO_SVM_PTRS,
5904 sizeof(
void*)*pointerList.size(),
5905 pointerList.data()));
5921 cl_bool svmEnabled_ = svmEnabled ? CL_TRUE : CL_FALSE;
5922 return detail::errHandler(
5923 ::clSetKernelExecInfo(
5925 CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM,
5932 template<
int index,
int ArrayLength,
class D,
typename T0,
typename T1,
typename... Ts>
5933 void setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList,
const pointer<T0, D> &t0,
const pointer<T1, D> &t1, Ts & ... ts)
5935 pointerList[index] =
static_cast<void*
>(t0.get());
5936 setSVMPointersHelper<index + 1, ArrayLength>(pointerList, t1, ts...);
5939 template<
int index,
int ArrayLength,
typename T0,
typename T1,
typename... Ts>
5940 typename std::enable_if<std::is_pointer<T0>::value,
void>::type
5941 setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList, T0 t0, T1 t1, Ts... ts)
5943 pointerList[index] =
static_cast<void*
>(t0);
5944 setSVMPointersHelper<index + 1, ArrayLength>(pointerList, t1, ts...);
5947 template<
int index,
int ArrayLength,
typename T0,
class D>
5948 void setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList,
const pointer<T0, D> &t0)
5950 pointerList[index] =
static_cast<void*
>(t0.get());
5954 template<
int index,
int ArrayLength,
typename T0>
5955 typename std::enable_if<std::is_pointer<T0>::value,
void>::type
5956 setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList, T0 t0)
5958 pointerList[index] =
static_cast<void*
>(t0);
5961 template<
typename T0,
typename... Ts>
5962 cl_int setSVMPointers(
const T0 &t0, Ts & ... ts)
5964 std::array<
void*, 1 +
sizeof...(Ts)> pointerList;
5966 setSVMPointersHelper<0, 1 +
sizeof...(Ts)>(pointerList, t0, ts...);
5967 return detail::errHandler(
5968 ::clSetKernelExecInfo(
5970 CL_KERNEL_EXEC_INFO_SVM_PTRS,
5971 sizeof(
void*)*(1 +
sizeof...(Ts)),
5972 pointerList.data()));
5974 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 5983 #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 5984 typedef vector<vector<unsigned char>> Binaries;
5985 typedef vector<string> Sources;
5986 #else // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 5987 typedef vector<std::pair<const void*, size_type> > Binaries;
5988 typedef vector<std::pair<const char*, size_type> > Sources;
5989 #endif // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 5992 const string& source,
5998 const char * strings = source.c_str();
5999 const size_type length = source.size();
6003 object_ = ::clCreateProgramWithSource(
6004 context(), (cl_uint)1, &strings, &length, &error);
6006 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6008 if (error == CL_SUCCESS && build) {
6010 error = ::clBuildProgram(
6014 #
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6022 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6032 const string& source,
6038 const char * strings = source.c_str();
6039 const size_type length = source.size();
6041 object_ = ::clCreateProgramWithSource(
6042 context(), (cl_uint)1, &strings, &length, &error);
6044 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6046 if (error == CL_SUCCESS && build) {
6047 error = ::clBuildProgram(
6051 #
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6059 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6072 const Sources& sources,
6078 const size_type n = (size_type)sources.size();
6080 vector<size_type> lengths(n);
6081 vector<const char*> strings(n);
6083 for (size_type i = 0; i < n; ++i) {
6084 #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 6085 strings[i] = sources[(int)i].data();
6086 lengths[i] = sources[(int)i].length();
6087 #else // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 6088 strings[i] = sources[(int)i].first;
6089 lengths[i] = sources[(int)i].second;
6090 #endif // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 6093 object_ = ::clCreateProgramWithSource(
6094 context(), (cl_uint)n, strings.data(), lengths.data(), &error);
6096 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6108 const Sources& sources,
6113 const size_type n = (size_type)sources.size();
6115 vector<size_type> lengths(n);
6116 vector<const char*> strings(n);
6118 for (size_type i = 0; i < n; ++i) {
6119 #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 6120 strings[i] = sources[(int)i].data();
6121 lengths[i] = sources[(int)i].length();
6122 #else // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 6123 strings[i] = sources[(int)i].first;
6124 lengths[i] = sources[(int)i].second;
6125 #endif // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 6128 object_ = ::clCreateProgramWithSource(
6129 context(), (cl_uint)n, strings.data(), lengths.data(), &error);
6131 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6158 const vector<Device>& devices,
6159 const Binaries& binaries,
6160 vector<cl_int>* binaryStatus = NULL,
6165 const size_type numDevices = devices.size();
6168 if(binaries.size() != numDevices) {
6169 error = CL_INVALID_VALUE;
6170 detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
6178 vector<size_type> lengths(numDevices);
6179 vector<const unsigned char*> images(numDevices);
6180 #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 6181 for (size_type i = 0; i < numDevices; ++i) {
6182 images[i] = binaries[i].data();
6183 lengths[i] = binaries[(int)i].size();
6185 #else // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 6186 for (size_type i = 0; i < numDevices; ++i) {
6187 images[i] = (
const unsigned char*)binaries[i].first;
6188 lengths[i] = binaries[(int)i].second;
6190 #endif // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 6192 vector<cl_device_id> deviceIDs(numDevices);
6193 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6194 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6198 binaryStatus->resize(numDevices);
6201 object_ = ::clCreateProgramWithBinary(
6202 context(), (cl_uint) devices.size(),
6204 lengths.data(), images.data(), (binaryStatus != NULL && numDevices > 0)
6205 ? &binaryStatus->front()
6208 detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
6215 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 6222 const vector<Device>& devices,
6223 const string& kernelNames,
6229 size_type numDevices = devices.size();
6230 vector<cl_device_id> deviceIDs(numDevices);
6231 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6232 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6235 object_ = ::clCreateProgramWithBuiltInKernels(
6237 (cl_uint) devices.size(),
6239 kernelNames.c_str(),
6242 detail::errHandler(error, __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR);
6247 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 6258 explicit Program(
const cl_program& program,
bool retainObject =
false) :
6259 detail::Wrapper<cl_type>(program, retainObject) { }
6261 Program& operator = (
const cl_program& rhs)
6296 const vector<Device>& devices,
6297 const char* options = NULL,
6298 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6299 void* data = NULL)
const 6301 size_type numDevices = devices.size();
6302 vector<cl_device_id> deviceIDs(numDevices);
6304 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6305 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6308 cl_int buildError = ::clBuildProgram(
6317 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6321 const char* options = NULL,
6322 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6323 void* data = NULL)
const 6325 cl_int buildError = ::clBuildProgram(
6334 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6337 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 6339 const char* options = NULL,
6340 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6341 void* data = NULL)
const 6343 cl_int error = ::clCompileProgram(
6353 return detail::buildErrHandler(error, __COMPILE_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6355 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 6357 template <
typename T>
6358 cl_int getInfo(cl_program_info name, T* param)
const 6360 return detail::errHandler(
6361 detail::getInfo(&::clGetProgramInfo, object_, name, param),
6362 __GET_PROGRAM_INFO_ERR);
6365 template <cl_
int name>
typename 6367 getInfo(cl_int* err = NULL)
const 6370 detail::cl_program_info, name>::param_type param;
6371 cl_int result = getInfo(name, ¶m);
6378 template <
typename T>
6379 cl_int getBuildInfo(
6380 const Device& device, cl_program_build_info name, T* param)
const 6382 return detail::errHandler(
6384 &::clGetProgramBuildInfo, object_, device(), name, param),
6385 __GET_PROGRAM_BUILD_INFO_ERR);
6388 template <cl_
int name>
typename 6390 getBuildInfo(
const Device& device, cl_int* err = NULL)
const 6393 detail::cl_program_build_info, name>::param_type param;
6394 cl_int result = getBuildInfo(device, name, ¶m);
6406 template <cl_
int name>
6407 vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, name>::param_type>>
6410 cl_int result = CL_SUCCESS;
6412 auto devs = getInfo<CL_PROGRAM_DEVICES>(&result);
6413 vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, name>::param_type>>
6417 if (result != CL_SUCCESS) {
6426 detail::cl_program_build_info, name>::param_type param;
6427 result = getBuildInfo(d, name, ¶m);
6431 if (result != CL_SUCCESS) {
6439 if (result != CL_SUCCESS) {
6445 cl_int createKernels(vector<Kernel>* kernels)
6448 cl_int err = ::clCreateKernelsInProgram(object_, 0, NULL, &numKernels);
6449 if (err != CL_SUCCESS) {
6450 return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
6453 vector<cl_kernel> value(numKernels);
6455 err = ::clCreateKernelsInProgram(
6456 object_, numKernels, value.data(), NULL);
6457 if (err != CL_SUCCESS) {
6458 return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
6462 kernels->resize(value.size());
6466 for (size_type i = 0; i < value.size(); i++) {
6469 (*kernels)[i] =
Kernel(value[i],
false);
6476 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 6480 const char* options = NULL,
6481 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6485 cl_int error_local = CL_SUCCESS;
6487 cl_program programs[2] = { input1(), input2() };
6489 Context ctx = input1.getInfo<CL_PROGRAM_CONTEXT>(&error_local);
6490 if(error_local!=CL_SUCCESS) {
6491 detail::errHandler(error_local, __LINK_PROGRAM_ERR);
6494 cl_program prog = ::clLinkProgram(
6505 detail::errHandler(error_local,__COMPILE_PROGRAM_ERR);
6514 vector<Program> inputPrograms,
6515 const char* options = NULL,
6516 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6520 cl_int error_local = CL_SUCCESS;
6522 vector<cl_program> programs(inputPrograms.size());
6524 for (
unsigned int i = 0; i < inputPrograms.size(); i++) {
6525 programs[i] = inputPrograms[i]();
6529 if(inputPrograms.size() > 0) {
6530 ctx = inputPrograms[0].
getInfo<CL_PROGRAM_CONTEXT>(&error_local);
6531 if(error_local!=CL_SUCCESS) {
6532 detail::errHandler(error_local, __LINK_PROGRAM_ERR);
6535 cl_program prog = ::clLinkProgram(
6540 (cl_uint)inputPrograms.size(),
6546 detail::errHandler(error_local,__COMPILE_PROGRAM_ERR);
6553 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 6557 inline cl_int cl::Program::getInfo(cl_program_info name, vector<vector<unsigned char>>* param)
const 6559 if (name != CL_PROGRAM_BINARIES) {
6560 return CL_INVALID_VALUE;
6566 vector<size_type> sizes = getInfo<CL_PROGRAM_BINARY_SIZES>();
6567 size_type numBinaries = sizes.size();
6570 param->resize(numBinaries);
6571 for (size_type i = 0; i < numBinaries; ++i) {
6572 (*param)[i].resize(sizes[i]);
6575 return detail::errHandler(
6576 detail::getInfo(&::clGetProgramInfo, object_, name, param),
6577 __GET_PROGRAM_INFO_ERR);
6584 inline vector<vector<unsigned char>> cl::Program::getInfo<CL_PROGRAM_BINARIES>(cl_int* err)
const 6586 vector<vector<unsigned char>> binariesVectors;
6588 cl_int result = getInfo(CL_PROGRAM_BINARIES, &binariesVectors);
6592 return binariesVectors;
6599 object_ = ::clCreateKernel(program(), name, &error);
6600 detail::errHandler(error, __CREATE_KERNEL_ERR);
6608 enum class QueueProperties : cl_command_queue_properties
6611 Profiling = CL_QUEUE_PROFILING_ENABLE,
6612 OutOfOrder = CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE,
6615 inline QueueProperties operator|(QueueProperties lhs, QueueProperties rhs)
6617 return static_cast<QueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) | static_cast<cl_command_queue_properties>(rhs));
6626 static std::once_flag default_initialized_;
6628 static cl_int default_error_;
6635 static void makeDefault()
6640 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 6647 if (error != CL_SUCCESS) {
6648 default_error_ = error;
6652 default_ =
CommandQueue(context, device, 0, &default_error_);
6655 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 6656 catch (cl::Error &e) {
6657 default_error_ = e.err();
6667 static void makeDefaultProvided(
const CommandQueue &c) {
6672 #ifdef CL_HPP_UNIT_TEST_ENABLE 6679 static void unitTestClearDefault() {
6682 #endif // #ifdef CL_HPP_UNIT_TEST_ENABLE 6690 cl_command_queue_properties properties,
6696 detail::errHandler(error, __CREATE_CONTEXT_ERR);
6698 if (error != CL_SUCCESS) {
6705 bool useWithProperties;
6707 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 6710 cl_uint version = detail::getContextPlatformVersion(context());
6711 useWithProperties = (version >= 0x20000);
6713 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200 6714 useWithProperties =
true;
6716 useWithProperties =
false;
6719 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 6720 if (useWithProperties) {
6721 cl_queue_properties queue_properties[] = {
6722 CL_QUEUE_PROPERTIES, properties, 0 };
6723 if ((properties & CL_QUEUE_ON_DEVICE) == 0) {
6724 object_ = ::clCreateCommandQueueWithProperties(
6725 context(), device(), queue_properties, &error);
6728 error = CL_INVALID_QUEUE_PROPERTIES;
6731 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
6736 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200 6737 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200 6738 if (!useWithProperties) {
6739 object_ = ::clCreateCommandQueue(
6740 context(), device(), properties, &error);
6742 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
6747 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 200 6756 QueueProperties properties,
6762 detail::errHandler(error, __CREATE_CONTEXT_ERR);
6764 if (error != CL_SUCCESS) {
6771 bool useWithProperties;
6773 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 6776 cl_uint version = detail::getContextPlatformVersion(context());
6777 useWithProperties = (version >= 0x20000);
6779 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200 6780 useWithProperties =
true;
6782 useWithProperties =
false;
6785 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 6786 if (useWithProperties) {
6787 cl_queue_properties queue_properties[] = {
6788 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
6790 object_ = ::clCreateCommandQueueWithProperties(
6791 context(), device(), queue_properties, &error);
6793 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
6798 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200 6799 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200 6800 if (!useWithProperties) {
6801 object_ = ::clCreateCommandQueue(
6802 context(), device(), static_cast<cl_command_queue_properties>(properties), &error);
6804 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
6809 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 200 6820 cl_command_queue_properties properties = 0,
6824 bool useWithProperties;
6825 vector<cl::Device> devices;
6826 error = context.
getInfo(CL_CONTEXT_DEVICES, &devices);
6828 detail::errHandler(error, __CREATE_CONTEXT_ERR);
6830 if (error != CL_SUCCESS)
6838 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 6841 cl_uint version = detail::getContextPlatformVersion(context());
6842 useWithProperties = (version >= 0x20000);
6844 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200 6845 useWithProperties =
true;
6847 useWithProperties =
false;
6850 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 6851 if (useWithProperties) {
6852 cl_queue_properties queue_properties[] = {
6853 CL_QUEUE_PROPERTIES, properties, 0 };
6854 if ((properties & CL_QUEUE_ON_DEVICE) == 0) {
6855 object_ = ::clCreateCommandQueueWithProperties(
6856 context(), devices[0](), queue_properties, &error);
6859 error = CL_INVALID_QUEUE_PROPERTIES;
6862 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
6867 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200 6868 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200 6869 if (!useWithProperties) {
6870 object_ = ::clCreateCommandQueue(
6871 context(), devices[0](), properties, &error);
6873 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
6878 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 200 6887 QueueProperties properties,
6891 bool useWithProperties;
6892 vector<cl::Device> devices;
6893 error = context.
getInfo(CL_CONTEXT_DEVICES, &devices);
6895 detail::errHandler(error, __CREATE_CONTEXT_ERR);
6897 if (error != CL_SUCCESS)
6905 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 6908 cl_uint version = detail::getContextPlatformVersion(context());
6909 useWithProperties = (version >= 0x20000);
6911 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200 6912 useWithProperties =
true;
6914 useWithProperties =
false;
6917 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 6918 if (useWithProperties) {
6919 cl_queue_properties queue_properties[] = {
6920 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
6921 object_ = ::clCreateCommandQueueWithProperties(
6922 context(), devices[0](), queue_properties, &error);
6924 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
6929 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200 6930 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200 6931 if (!useWithProperties) {
6932 object_ = ::clCreateCommandQueue(
6933 context(), devices[0](), static_cast<cl_command_queue_properties>(properties), &error);
6935 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
6940 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 200 6950 cl_command_queue_properties properties = 0,
6954 bool useWithProperties;
6956 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 6959 cl_uint version = detail::getContextPlatformVersion(context());
6960 useWithProperties = (version >= 0x20000);
6962 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200 6963 useWithProperties =
true;
6965 useWithProperties =
false;
6968 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 6969 if (useWithProperties) {
6970 cl_queue_properties queue_properties[] = {
6971 CL_QUEUE_PROPERTIES, properties, 0 };
6972 object_ = ::clCreateCommandQueueWithProperties(
6973 context(), device(), queue_properties, &error);
6975 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
6980 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200 6981 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200 6982 if (!useWithProperties) {
6983 object_ = ::clCreateCommandQueue(
6984 context(), device(), properties, &error);
6986 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
6991 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 200 7001 QueueProperties properties,
7005 bool useWithProperties;
7007 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 7010 cl_uint version = detail::getContextPlatformVersion(context());
7011 useWithProperties = (version >= 0x20000);
7013 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200 7014 useWithProperties =
true;
7016 useWithProperties =
false;
7019 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 7020 if (useWithProperties) {
7021 cl_queue_properties queue_properties[] = {
7022 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
7023 object_ = ::clCreateCommandQueueWithProperties(
7024 context(), device(), queue_properties, &error);
7026 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7031 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200 7032 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200 7033 if (!useWithProperties) {
7034 object_ = ::clCreateCommandQueue(
7035 context(), device(), static_cast<cl_command_queue_properties>(properties), &error);
7037 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7042 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 200 7047 std::call_once(default_initialized_, makeDefault);
7048 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 7049 detail::errHandler(default_error_, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7050 #else // CL_HPP_TARGET_OPENCL_VERSION >= 200 7051 detail::errHandler(default_error_, __CREATE_COMMAND_QUEUE_ERR);
7052 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200 7054 *err = default_error_;
7068 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_queue));
7069 detail::errHandler(default_error_);
7082 explicit CommandQueue(
const cl_command_queue& commandQueue,
bool retainObject =
false) :
7083 detail::Wrapper<cl_type>(commandQueue, retainObject) { }
7119 template <
typename T>
7120 cl_int getInfo(cl_command_queue_info name, T* param)
const 7122 return detail::errHandler(
7124 &::clGetCommandQueueInfo, object_, name, param),
7125 __GET_COMMAND_QUEUE_INFO_ERR);
7128 template <cl_
int name>
typename 7130 getInfo(cl_int* err = NULL)
const 7133 detail::cl_command_queue_info, name>::param_type param;
7134 cl_int result = getInfo(name, ¶m);
7141 cl_int enqueueReadBuffer(
7147 const vector<Event>* events = NULL,
7148 Event* event = NULL)
const 7151 cl_int err = detail::errHandler(
7152 ::clEnqueueReadBuffer(
7153 object_, buffer(), blocking, offset, size,
7155 (events != NULL) ? (cl_uint) events->size() : 0,
7156 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7157 (
event != NULL) ? &tmp : NULL),
7158 __ENQUEUE_READ_BUFFER_ERR);
7160 if (event != NULL && err == CL_SUCCESS)
7166 cl_int enqueueWriteBuffer(
7172 const vector<Event>* events = NULL,
7173 Event* event = NULL)
const 7176 cl_int err = detail::errHandler(
7177 ::clEnqueueWriteBuffer(
7178 object_, buffer(), blocking, offset, size,
7180 (events != NULL) ? (cl_uint) events->size() : 0,
7181 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7182 (
event != NULL) ? &tmp : NULL),
7183 __ENQUEUE_WRITE_BUFFER_ERR);
7185 if (event != NULL && err == CL_SUCCESS)
7191 cl_int enqueueCopyBuffer(
7194 size_type src_offset,
7195 size_type dst_offset,
7197 const vector<Event>* events = NULL,
7198 Event* event = NULL)
const 7201 cl_int err = detail::errHandler(
7202 ::clEnqueueCopyBuffer(
7203 object_, src(), dst(), src_offset, dst_offset, size,
7204 (events != NULL) ? (cl_uint) events->size() : 0,
7205 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7206 (
event != NULL) ? &tmp : NULL),
7207 __ENQEUE_COPY_BUFFER_ERR);
7209 if (event != NULL && err == CL_SUCCESS)
7214 #if CL_HPP_TARGET_OPENCL_VERSION >= 110 7215 cl_int enqueueReadBufferRect(
7218 const array<size_type, 3>& buffer_offset,
7219 const array<size_type, 3>& host_offset,
7220 const array<size_type, 3>& region,
7221 size_type buffer_row_pitch,
7222 size_type buffer_slice_pitch,
7223 size_type host_row_pitch,
7224 size_type host_slice_pitch,
7226 const vector<Event>* events = NULL,
7227 Event* event = NULL)
const 7230 cl_int err = detail::errHandler(
7231 ::clEnqueueReadBufferRect(
7235 buffer_offset.data(),
7243 (events != NULL) ? (cl_uint) events->size() : 0,
7244 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7245 (
event != NULL) ? &tmp : NULL),
7246 __ENQUEUE_READ_BUFFER_RECT_ERR);
7248 if (event != NULL && err == CL_SUCCESS)
7254 cl_int enqueueWriteBufferRect(
7257 const array<size_type, 3>& buffer_offset,
7258 const array<size_type, 3>& host_offset,
7259 const array<size_type, 3>& region,
7260 size_type buffer_row_pitch,
7261 size_type buffer_slice_pitch,
7262 size_type host_row_pitch,
7263 size_type host_slice_pitch,
7265 const vector<Event>* events = NULL,
7266 Event* event = NULL)
const 7269 cl_int err = detail::errHandler(
7270 ::clEnqueueWriteBufferRect(
7274 buffer_offset.data(),
7282 (events != NULL) ? (cl_uint) events->size() : 0,
7283 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7284 (
event != NULL) ? &tmp : NULL),
7285 __ENQUEUE_WRITE_BUFFER_RECT_ERR);
7287 if (event != NULL && err == CL_SUCCESS)
7293 cl_int enqueueCopyBufferRect(
7296 const array<size_type, 3>& src_origin,
7297 const array<size_type, 3>& dst_origin,
7298 const array<size_type, 3>& region,
7299 size_type src_row_pitch,
7300 size_type src_slice_pitch,
7301 size_type dst_row_pitch,
7302 size_type dst_slice_pitch,
7303 const vector<Event>* events = NULL,
7304 Event* event = NULL)
const 7307 cl_int err = detail::errHandler(
7308 ::clEnqueueCopyBufferRect(
7319 (events != NULL) ? (cl_uint) events->size() : 0,
7320 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7321 (
event != NULL) ? &tmp : NULL),
7322 __ENQEUE_COPY_BUFFER_RECT_ERR);
7324 if (event != NULL && err == CL_SUCCESS)
7329 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110 7330 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 7342 template<
typename PatternType>
7345 PatternType pattern,
7348 const vector<Event>* events = NULL,
7349 Event* event = NULL)
const 7352 cl_int err = detail::errHandler(
7353 ::clEnqueueFillBuffer(
7356 static_cast<void*>(&pattern),
7357 sizeof(PatternType),
7360 (events != NULL) ? (cl_uint) events->size() : 0,
7361 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7362 (
event != NULL) ? &tmp : NULL),
7363 __ENQUEUE_FILL_BUFFER_ERR);
7365 if (event != NULL && err == CL_SUCCESS)
7370 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 7372 cl_int enqueueReadImage(
7375 const array<size_type, 3>& origin,
7376 const array<size_type, 3>& region,
7377 size_type row_pitch,
7378 size_type slice_pitch,
7380 const vector<Event>* events = NULL,
7381 Event* event = NULL)
const 7384 cl_int err = detail::errHandler(
7385 ::clEnqueueReadImage(
7394 (events != NULL) ? (cl_uint) events->size() : 0,
7395 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7396 (
event != NULL) ? &tmp : NULL),
7397 __ENQUEUE_READ_IMAGE_ERR);
7399 if (event != NULL && err == CL_SUCCESS)
7405 cl_int enqueueWriteImage(
7408 const array<size_type, 3>& origin,
7409 const array<size_type, 3>& region,
7410 size_type row_pitch,
7411 size_type slice_pitch,
7413 const vector<Event>* events = NULL,
7414 Event* event = NULL)
const 7417 cl_int err = detail::errHandler(
7418 ::clEnqueueWriteImage(
7427 (events != NULL) ? (cl_uint) events->size() : 0,
7428 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7429 (
event != NULL) ? &tmp : NULL),
7430 __ENQUEUE_WRITE_IMAGE_ERR);
7432 if (event != NULL && err == CL_SUCCESS)
7438 cl_int enqueueCopyImage(
7441 const array<size_type, 3>& src_origin,
7442 const array<size_type, 3>& dst_origin,
7443 const array<size_type, 3>& region,
7444 const vector<Event>* events = NULL,
7445 Event* event = NULL)
const 7448 cl_int err = detail::errHandler(
7449 ::clEnqueueCopyImage(
7456 (events != NULL) ? (cl_uint) events->size() : 0,
7457 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7458 (
event != NULL) ? &tmp : NULL),
7459 __ENQUEUE_COPY_IMAGE_ERR);
7461 if (event != NULL && err == CL_SUCCESS)
7467 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 7477 cl_float4 fillColor,
7478 const array<size_type, 3>& origin,
7479 const array<size_type, 3>& region,
7480 const vector<Event>* events = NULL,
7481 Event* event = NULL)
const 7484 cl_int err = detail::errHandler(
7485 ::clEnqueueFillImage(
7488 static_cast<void*>(&fillColor),
7491 (events != NULL) ? (cl_uint) events->size() : 0,
7492 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7493 (
event != NULL) ? &tmp : NULL),
7494 __ENQUEUE_FILL_IMAGE_ERR);
7496 if (event != NULL && err == CL_SUCCESS)
7512 const array<size_type, 3>& origin,
7513 const array<size_type, 3>& region,
7514 const vector<Event>* events = NULL,
7515 Event* event = NULL)
const 7518 cl_int err = detail::errHandler(
7519 ::clEnqueueFillImage(
7522 static_cast<void*>(&fillColor),
7525 (events != NULL) ? (cl_uint) events->size() : 0,
7526 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7527 (
event != NULL) ? &tmp : NULL),
7528 __ENQUEUE_FILL_IMAGE_ERR);
7530 if (event != NULL && err == CL_SUCCESS)
7546 const array<size_type, 3>& origin,
7547 const array<size_type, 3>& region,
7548 const vector<Event>* events = NULL,
7549 Event* event = NULL)
const 7552 cl_int err = detail::errHandler(
7553 ::clEnqueueFillImage(
7556 static_cast<void*>(&fillColor),
7559 (events != NULL) ? (cl_uint) events->size() : 0,
7560 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7561 (
event != NULL) ? &tmp : NULL),
7562 __ENQUEUE_FILL_IMAGE_ERR);
7564 if (event != NULL && err == CL_SUCCESS)
7569 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 7571 cl_int enqueueCopyImageToBuffer(
7574 const array<size_type, 3>& src_origin,
7575 const array<size_type, 3>& region,
7576 size_type dst_offset,
7577 const vector<Event>* events = NULL,
7578 Event* event = NULL)
const 7581 cl_int err = detail::errHandler(
7582 ::clEnqueueCopyImageToBuffer(
7589 (events != NULL) ? (cl_uint) events->size() : 0,
7590 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7591 (
event != NULL) ? &tmp : NULL),
7592 __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR);
7594 if (event != NULL && err == CL_SUCCESS)
7600 cl_int enqueueCopyBufferToImage(
7603 size_type src_offset,
7604 const array<size_type, 3>& dst_origin,
7605 const array<size_type, 3>& region,
7606 const vector<Event>* events = NULL,
7607 Event* event = NULL)
const 7610 cl_int err = detail::errHandler(
7611 ::clEnqueueCopyBufferToImage(
7618 (events != NULL) ? (cl_uint) events->size() : 0,
7619 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7620 (
event != NULL) ? &tmp : NULL),
7621 __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR);
7623 if (event != NULL && err == CL_SUCCESS)
7629 void* enqueueMapBuffer(
7635 const vector<Event>* events = NULL,
7636 Event* event = NULL,
7637 cl_int* err = NULL)
const 7641 void * result = ::clEnqueueMapBuffer(
7642 object_, buffer(), blocking, flags, offset, size,
7643 (events != NULL) ? (cl_uint) events->size() : 0,
7644 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7645 (
event != NULL) ? &tmp : NULL,
7648 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
7652 if (event != NULL && error == CL_SUCCESS)
7658 void* enqueueMapImage(
7659 const Image& buffer,
7662 const array<size_type, 3>& origin,
7663 const array<size_type, 3>& region,
7664 size_type * row_pitch,
7665 size_type * slice_pitch,
7666 const vector<Event>* events = NULL,
7667 Event* event = NULL,
7668 cl_int* err = NULL)
const 7672 void * result = ::clEnqueueMapImage(
7673 object_, buffer(), blocking, flags,
7676 row_pitch, slice_pitch,
7677 (events != NULL) ? (cl_uint) events->size() : 0,
7678 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7679 (
event != NULL) ? &tmp : NULL,
7682 detail::errHandler(error, __ENQUEUE_MAP_IMAGE_ERR);
7686 if (event != NULL && error == CL_SUCCESS)
7691 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 7696 template<
typename T>
7702 const vector<Event>* events = NULL,
7703 Event* event = NULL)
const 7706 cl_int err = detail::errHandler(::clEnqueueSVMMap(
7707 object_, blocking, flags, static_cast<void*>(ptr), size,
7708 (events != NULL) ? (cl_uint)events->size() : 0,
7709 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
7710 (
event != NULL) ? &tmp : NULL),
7711 __ENQUEUE_MAP_BUFFER_ERR);
7713 if (event != NULL && err == CL_SUCCESS)
7724 template<
typename T,
class D>
7726 cl::pointer<T, D> &ptr,
7730 const vector<Event>* events = NULL,
7731 Event* event = NULL)
const 7734 cl_int err = detail::errHandler(::clEnqueueSVMMap(
7735 object_, blocking, flags, static_cast<void*>(ptr.get()), size,
7736 (events != NULL) ? (cl_uint)events->size() : 0,
7737 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
7738 (
event != NULL) ? &tmp : NULL),
7739 __ENQUEUE_MAP_BUFFER_ERR);
7741 if (event != NULL && err == CL_SUCCESS)
7751 template<
typename T,
class Alloc>
7753 cl::vector<T, Alloc> &container,
7756 const vector<Event>* events = NULL,
7757 Event* event = NULL)
const 7760 cl_int err = detail::errHandler(::clEnqueueSVMMap(
7761 object_, blocking, flags, static_cast<void*>(container.data()), container.size(),
7762 (events != NULL) ? (cl_uint)events->size() : 0,
7763 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
7764 (
event != NULL) ? &tmp : NULL),
7765 __ENQUEUE_MAP_BUFFER_ERR);
7767 if (event != NULL && err == CL_SUCCESS)
7772 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 7774 cl_int enqueueUnmapMemObject(
7777 const vector<Event>* events = NULL,
7778 Event* event = NULL)
const 7781 cl_int err = detail::errHandler(
7782 ::clEnqueueUnmapMemObject(
7783 object_, memory(), mapped_ptr,
7784 (events != NULL) ? (cl_uint) events->size() : 0,
7785 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7786 (
event != NULL) ? &tmp : NULL),
7787 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
7789 if (event != NULL && err == CL_SUCCESS)
7796 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 7801 template<
typename T>
7804 const vector<Event>* events = NULL,
7805 Event* event = NULL)
const 7808 cl_int err = detail::errHandler(
7809 ::clEnqueueSVMUnmap(
7810 object_, static_cast<void*>(ptr),
7811 (events != NULL) ? (cl_uint)events->size() : 0,
7812 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
7813 (
event != NULL) ? &tmp : NULL),
7814 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
7816 if (event != NULL && err == CL_SUCCESS)
7826 template<
typename T,
class D>
7828 cl::pointer<T, D> &ptr,
7829 const vector<Event>* events = NULL,
7830 Event* event = NULL)
const 7833 cl_int err = detail::errHandler(
7834 ::clEnqueueSVMUnmap(
7835 object_, static_cast<void*>(ptr.get()),
7836 (events != NULL) ? (cl_uint)events->size() : 0,
7837 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
7838 (
event != NULL) ? &tmp : NULL),
7839 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
7841 if (event != NULL && err == CL_SUCCESS)
7851 template<
typename T,
class Alloc>
7853 cl::vector<T, Alloc> &container,
7854 const vector<Event>* events = NULL,
7855 Event* event = NULL)
const 7858 cl_int err = detail::errHandler(
7859 ::clEnqueueSVMUnmap(
7860 object_, static_cast<void*>(container.data()),
7861 (events != NULL) ? (cl_uint)events->size() : 0,
7862 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
7863 (
event != NULL) ? &tmp : NULL),
7864 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
7866 if (event != NULL && err == CL_SUCCESS)
7871 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 7873 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 7886 const vector<Event> *events = 0,
7887 Event *event = 0)
const 7890 cl_int err = detail::errHandler(
7891 ::clEnqueueMarkerWithWaitList(
7893 (events != NULL) ? (cl_uint) events->size() : 0,
7894 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7895 (
event != NULL) ? &tmp : NULL),
7896 __ENQUEUE_MARKER_WAIT_LIST_ERR);
7898 if (event != NULL && err == CL_SUCCESS)
7916 const vector<Event> *events = 0,
7917 Event *event = 0)
const 7920 cl_int err = detail::errHandler(
7921 ::clEnqueueBarrierWithWaitList(
7923 (events != NULL) ? (cl_uint) events->size() : 0,
7924 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7925 (
event != NULL) ? &tmp : NULL),
7926 __ENQUEUE_BARRIER_WAIT_LIST_ERR);
7928 if (event != NULL && err == CL_SUCCESS)
7939 const vector<Memory> &memObjects,
7940 cl_mem_migration_flags flags,
7941 const vector<Event>* events = NULL,
7947 vector<cl_mem> localMemObjects(memObjects.size());
7949 for(
int i = 0; i < (int)memObjects.size(); ++i ) {
7950 localMemObjects[i] = memObjects[i]();
7954 cl_int err = detail::errHandler(
7955 ::clEnqueueMigrateMemObjects(
7957 (cl_uint)memObjects.size(),
7958 localMemObjects.data(),
7960 (events != NULL) ? (cl_uint) events->size() : 0,
7961 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7962 (
event != NULL) ? &tmp : NULL),
7963 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
7965 if (event != NULL && err == CL_SUCCESS)
7970 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 7972 cl_int enqueueNDRangeKernel(
7976 const NDRange& local = NullRange,
7977 const vector<Event>* events = NULL,
7978 Event* event = NULL)
const 7981 cl_int err = detail::errHandler(
7982 ::clEnqueueNDRangeKernel(
7983 object_, kernel(), (cl_uint) global.
dimensions(),
7984 offset.
dimensions() != 0 ? (
const size_type*) offset : NULL,
7985 (
const size_type*) global,
7986 local.
dimensions() != 0 ? (
const size_type*) local : 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_NDRANGE_KERNEL_ERR);
7992 if (event != NULL && err == CL_SUCCESS)
7998 #if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS) 7999 CL_EXT_PREFIX__VERSION_1_2_DEPRECATED cl_int enqueueTask(
8001 const vector<Event>* events = NULL,
8002 Event* event = NULL)
const CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED
8005 cl_int err = detail::errHandler(
8008 (events != NULL) ? (cl_uint) events->size() : 0,
8009 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8010 (
event != NULL) ? &tmp : NULL),
8011 __ENQUEUE_TASK_ERR);
8013 if (event != NULL && err == CL_SUCCESS)
8018 #endif // #if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS) 8020 cl_int enqueueNativeKernel(
8021 void (CL_CALLBACK *userFptr)(
void *),
8022 std::pair<void*, size_type> args,
8023 const vector<Memory>* mem_objects = NULL,
8024 const vector<const void*>* mem_locs = NULL,
8025 const vector<Event>* events = NULL,
8026 Event* event = NULL)
const 8028 size_type elements = 0;
8029 if (mem_objects != NULL) {
8030 elements = mem_objects->size();
8032 vector<cl_mem> mems(elements);
8033 for (
unsigned int i = 0; i < elements; i++) {
8034 mems[i] = ((*mem_objects)[i])();
8038 cl_int err = detail::errHandler(
8039 ::clEnqueueNativeKernel(
8040 object_, userFptr, args.first, args.second,
8041 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8043 (mem_locs != NULL && mem_locs->size() > 0) ? (
const void **) &mem_locs->front() : NULL,
8044 (events != NULL) ? (cl_uint) events->size() : 0,
8045 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8046 (
event != NULL) ? &tmp : NULL),
8047 __ENQUEUE_NATIVE_KERNEL);
8049 if (event != NULL && err == CL_SUCCESS)
8058 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 8059 CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
8063 cl_int err = detail::errHandler(
8066 (event != NULL) ? &tmp : NULL),
8067 __ENQUEUE_MARKER_ERR);
8069 if (event != NULL && err == CL_SUCCESS)
8075 CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
8076 cl_int enqueueWaitForEvents(
const vector<Event>& events)
const CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
8078 return detail::errHandler(
8079 ::clEnqueueWaitForEvents(
8081 (cl_uint) events.size(),
8082 events.size() > 0 ? (
const cl_event*) &events.front() : NULL),
8083 __ENQUEUE_WAIT_FOR_EVENTS_ERR);
8085 #endif // defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 8087 cl_int enqueueAcquireGLObjects(
8088 const vector<Memory>* mem_objects = NULL,
8089 const vector<Event>* events = NULL,
8090 Event* event = NULL)
const 8093 cl_int err = detail::errHandler(
8094 ::clEnqueueAcquireGLObjects(
8096 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8097 (mem_objects != NULL && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front(): NULL,
8098 (events != NULL) ? (cl_uint) events->size() : 0,
8099 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8100 (
event != NULL) ? &tmp : NULL),
8101 __ENQUEUE_ACQUIRE_GL_ERR);
8103 if (event != NULL && err == CL_SUCCESS)
8109 cl_int enqueueReleaseGLObjects(
8110 const vector<Memory>* mem_objects = NULL,
8111 const vector<Event>* events = NULL,
8112 Event* event = NULL)
const 8115 cl_int err = detail::errHandler(
8116 ::clEnqueueReleaseGLObjects(
8118 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8119 (mem_objects != NULL && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front(): NULL,
8120 (events != NULL) ? (cl_uint) events->size() : 0,
8121 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8122 (
event != NULL) ? &tmp : NULL),
8123 __ENQUEUE_RELEASE_GL_ERR);
8125 if (event != NULL && err == CL_SUCCESS)
8131 #if defined (CL_HPP_USE_DX_INTEROP) 8132 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueAcquireD3D10ObjectsKHR)(
8133 cl_command_queue command_queue, cl_uint num_objects,
8134 const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
8135 const cl_event* event_wait_list, cl_event* event);
8136 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueReleaseD3D10ObjectsKHR)(
8137 cl_command_queue command_queue, cl_uint num_objects,
8138 const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
8139 const cl_event* event_wait_list, cl_event* event);
8141 cl_int enqueueAcquireD3D10Objects(
8142 const vector<Memory>* mem_objects = NULL,
8143 const vector<Event>* events = NULL,
8144 Event* event = NULL)
const 8146 static PFN_clEnqueueAcquireD3D10ObjectsKHR pfn_clEnqueueAcquireD3D10ObjectsKHR = NULL;
8147 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 8148 cl_context context = getInfo<CL_QUEUE_CONTEXT>();
8149 cl::Device device(getInfo<CL_QUEUE_DEVICE>());
8150 cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>();
8151 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueAcquireD3D10ObjectsKHR);
8153 #if CL_HPP_TARGET_OPENCL_VERSION >= 110 8154 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueAcquireD3D10ObjectsKHR);
8158 cl_int err = detail::errHandler(
8159 pfn_clEnqueueAcquireD3D10ObjectsKHR(
8161 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8162 (mem_objects != NULL && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front(): NULL,
8163 (events != NULL) ? (cl_uint) events->size() : 0,
8164 (events != NULL) ? (cl_event*) &events->front() : NULL,
8165 (
event != NULL) ? &tmp : NULL),
8166 __ENQUEUE_ACQUIRE_GL_ERR);
8168 if (event != NULL && err == CL_SUCCESS)
8174 cl_int enqueueReleaseD3D10Objects(
8175 const vector<Memory>* mem_objects = NULL,
8176 const vector<Event>* events = NULL,
8177 Event* event = NULL)
const 8179 static PFN_clEnqueueReleaseD3D10ObjectsKHR pfn_clEnqueueReleaseD3D10ObjectsKHR = NULL;
8180 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 8181 cl_context context = getInfo<CL_QUEUE_CONTEXT>();
8182 cl::Device device(getInfo<CL_QUEUE_DEVICE>());
8183 cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>();
8184 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueReleaseD3D10ObjectsKHR);
8185 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 8186 #if CL_HPP_TARGET_OPENCL_VERSION >= 110 8187 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueReleaseD3D10ObjectsKHR);
8188 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110 8191 cl_int err = detail::errHandler(
8192 pfn_clEnqueueReleaseD3D10ObjectsKHR(
8194 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8195 (mem_objects != NULL && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front(): NULL,
8196 (events != NULL) ? (cl_uint) events->size() : 0,
8197 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8198 (
event != NULL) ? &tmp : NULL),
8199 __ENQUEUE_RELEASE_GL_ERR);
8201 if (event != NULL && err == CL_SUCCESS)
8211 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 8212 CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
8215 return detail::errHandler(
8216 ::clEnqueueBarrier(object_),
8217 __ENQUEUE_BARRIER_ERR);
8219 #endif // CL_USE_DEPRECATED_OPENCL_1_1_APIS 8221 cl_int flush()
const 8223 return detail::errHandler(::clFlush(object_), __FLUSH_ERR);
8226 cl_int finish()
const 8228 return detail::errHandler(::clFinish(object_), __FINISH_ERR);
8232 CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag CommandQueue::default_initialized_;
8233 CL_HPP_DEFINE_STATIC_MEMBER_
CommandQueue CommandQueue::default_;
8234 CL_HPP_DEFINE_STATIC_MEMBER_ cl_int CommandQueue::default_error_ = CL_SUCCESS;
8237 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 8238 enum class DeviceQueueProperties : cl_command_queue_properties
8241 Profiling = CL_QUEUE_PROFILING_ENABLE,
8244 inline DeviceQueueProperties operator|(DeviceQueueProperties lhs, DeviceQueueProperties rhs)
8246 return static_cast<DeviceQueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) | static_cast<cl_command_queue_properties>(rhs));
8270 cl_command_queue_properties mergedProperties =
8271 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
8273 cl_queue_properties queue_properties[] = {
8274 CL_QUEUE_PROPERTIES, mergedProperties, 0 };
8275 object_ = ::clCreateCommandQueueWithProperties(
8276 context(), device(), queue_properties, &error);
8278 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8290 DeviceQueueProperties properties = DeviceQueueProperties::None,
8295 cl_command_queue_properties mergedProperties =
8296 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
8297 cl_queue_properties queue_properties[] = {
8298 CL_QUEUE_PROPERTIES, mergedProperties, 0 };
8299 object_ = ::clCreateCommandQueueWithProperties(
8300 context(), device(), queue_properties, &error);
8302 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8315 DeviceQueueProperties properties = DeviceQueueProperties::None,
8320 cl_command_queue_properties mergedProperties =
8321 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
8322 cl_queue_properties queue_properties[] = {
8323 CL_QUEUE_PROPERTIES, mergedProperties,
8324 CL_QUEUE_SIZE, queueSize,
8326 object_ = ::clCreateCommandQueueWithProperties(
8327 context(), device(), queue_properties, &error);
8329 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8342 detail::Wrapper<cl_type>(commandQueue, retainObject) { }
8378 template <
typename T>
8379 cl_int getInfo(cl_command_queue_info name, T* param)
const 8381 return detail::errHandler(
8383 &::clGetCommandQueueInfo, object_, name, param),
8384 __GET_COMMAND_QUEUE_INFO_ERR);
8387 template <cl_
int name>
typename 8389 getInfo(cl_int* err = NULL)
const 8392 detail::cl_command_queue_info, name>::param_type param;
8393 cl_int result = getInfo(name, ¶m);
8407 cl_int *err =
nullptr)
8413 cl_command_queue_properties properties =
8414 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
8415 cl_queue_properties queue_properties[] = {
8416 CL_QUEUE_PROPERTIES, properties,
8419 ::clCreateCommandQueueWithProperties(
8420 context(), device(), queue_properties, &error));
8422 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8437 const Context &context,
const Device &device, cl_int *err =
nullptr)
8441 cl_command_queue_properties properties =
8442 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
8443 cl_queue_properties queue_properties[] = {
8444 CL_QUEUE_PROPERTIES, properties,
8447 ::clCreateCommandQueueWithProperties(
8448 context(), device(), queue_properties, &error));
8450 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8465 const Context &context,
const Device &device, cl_uint queueSize, cl_int *err =
nullptr)
8469 cl_command_queue_properties properties =
8470 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
8471 cl_queue_properties queue_properties[] = {
8472 CL_QUEUE_PROPERTIES, properties,
8473 CL_QUEUE_SIZE, queueSize,
8476 ::clCreateCommandQueueWithProperties(
8477 context(), device(), queue_properties, &error));
8479 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8499 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 8502 template<
typename IteratorType >
8505 IteratorType startIterator,
8506 IteratorType endIterator,
8511 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
8514 cl_mem_flags flags = 0;
8516 flags |= CL_MEM_READ_ONLY;
8519 flags |= CL_MEM_READ_WRITE;
8522 flags |= CL_MEM_USE_HOST_PTR;
8525 size_type size =
sizeof(DataType)*(endIterator - startIterator);
8528 object_ = ::clCreateBuffer(context(), flags, size, static_cast<DataType*>(&*startIterator), &error);
8530 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
8533 detail::errHandler(error, __CREATE_BUFFER_ERR);
8540 detail::errHandler(error, __CREATE_BUFFER_ERR);
8545 error =
cl::copy(queue, startIterator, endIterator, *
this);
8546 detail::errHandler(error, __CREATE_BUFFER_ERR);
8553 template<
typename IteratorType >
8556 IteratorType startIterator,
8557 IteratorType endIterator,
8562 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
8565 cl_mem_flags flags = 0;
8567 flags |= CL_MEM_READ_ONLY;
8570 flags |= CL_MEM_READ_WRITE;
8573 flags |= CL_MEM_USE_HOST_PTR;
8576 size_type size =
sizeof(DataType)*(endIterator - startIterator);
8578 Context context = queue.getInfo<CL_QUEUE_CONTEXT>();
8581 object_ = ::clCreateBuffer(context(), flags, size, static_cast<DataType*>(&*startIterator), &error);
8584 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
8587 detail::errHandler(error, __CREATE_BUFFER_ERR);
8593 error =
cl::copy(queue, startIterator, endIterator, *
this);
8594 detail::errHandler(error, __CREATE_BUFFER_ERR);
8601 inline cl_int enqueueReadBuffer(
8607 const vector<Event>* events = NULL,
8608 Event* event = NULL)
8613 if (error != CL_SUCCESS) {
8617 return queue.enqueueReadBuffer(buffer, blocking, offset, size, ptr, events, event);
8620 inline cl_int enqueueWriteBuffer(
8626 const vector<Event>* events = NULL,
8627 Event* event = NULL)
8632 if (error != CL_SUCCESS) {
8636 return queue.enqueueWriteBuffer(buffer, blocking, offset, size, ptr, events, event);
8639 inline void* enqueueMapBuffer(
8645 const vector<Event>* events = NULL,
8646 Event* event = NULL,
8651 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
8656 void * result = ::clEnqueueMapBuffer(
8657 queue(), buffer(), blocking, flags, offset, size,
8658 (events != NULL) ? (cl_uint) events->size() : 0,
8659 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8663 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
8671 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 8677 template<
typename T>
8683 const vector<Event>* events,
8688 if (error != CL_SUCCESS) {
8689 return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
8693 ptr, blocking, flags, size, events, event);
8701 template<
typename T,
class D>
8703 cl::pointer<T, D> ptr,
8707 const vector<Event>* events = NULL,
8708 Event* event = NULL)
8712 if (error != CL_SUCCESS) {
8713 return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
8717 ptr, blocking, flags, size, events, event);
8725 template<
typename T,
class Alloc>
8727 cl::vector<T, Alloc> container,
8730 const vector<Event>* events = NULL,
8731 Event* event = NULL)
8735 if (error != CL_SUCCESS) {
8736 return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
8740 container, blocking, flags, events, event);
8743 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 8745 inline cl_int enqueueUnmapMemObject(
8748 const vector<Event>* events = NULL,
8749 Event* event = NULL)
8753 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
8754 if (error != CL_SUCCESS) {
8759 cl_int err = detail::errHandler(
8760 ::clEnqueueUnmapMemObject(
8761 queue(), memory(), mapped_ptr,
8762 (events != NULL) ? (cl_uint)events->size() : 0,
8763 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8764 (
event != NULL) ? &tmp : NULL),
8765 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8767 if (event != NULL && err == CL_SUCCESS)
8773 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 8779 template<
typename T>
8782 const vector<Event>* events = NULL,
8783 Event* event = NULL)
8787 if (error != CL_SUCCESS) {
8788 return detail::errHandler(error, __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8792 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8801 template<
typename T,
class D>
8803 cl::pointer<T, D> &ptr,
8804 const vector<Event>* events = NULL,
8805 Event* event = NULL)
8809 if (error != CL_SUCCESS) {
8810 return detail::errHandler(error, __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8814 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8822 template<
typename T,
class Alloc>
8824 cl::vector<T, Alloc> &container,
8825 const vector<Event>* events = NULL,
8826 Event* event = NULL)
8830 if (error != CL_SUCCESS) {
8831 return detail::errHandler(error, __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8834 return detail::errHandler(queue.
enqueueUnmapSVM(container, events, event),
8835 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8838 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 8840 inline cl_int enqueueCopyBuffer(
8843 size_type src_offset,
8844 size_type dst_offset,
8846 const vector<Event>* events = NULL,
8847 Event* event = NULL)
8852 if (error != CL_SUCCESS) {
8856 return queue.enqueueCopyBuffer(src, dst, src_offset, dst_offset, size, events, event);
8864 template<
typename IteratorType >
8865 inline cl_int
copy( IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer )
8869 if (error != CL_SUCCESS)
8872 return cl::copy(queue, startIterator, endIterator, buffer);
8880 template<
typename IteratorType >
8881 inline cl_int
copy(
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator )
8885 if (error != CL_SUCCESS)
8888 return cl::copy(queue, buffer, startIterator, endIterator);
8896 template<
typename IteratorType >
8899 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
8902 size_type length = endIterator-startIterator;
8903 size_type byteLength = length*
sizeof(DataType);
8906 static_cast<DataType*
>(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_WRITE, 0, byteLength, 0, 0, &error));
8908 if( error != CL_SUCCESS ) {
8911 #if defined(_MSC_VER) 8915 stdext::checked_array_iterator<DataType*>(
8918 std::copy(startIterator, endIterator, pointer);
8921 error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
8923 if( error != CL_SUCCESS ) {
8935 template<
typename IteratorType >
8938 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
8941 size_type length = endIterator-startIterator;
8942 size_type byteLength = length*
sizeof(DataType);
8945 static_cast<DataType*
>(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_READ, 0, byteLength, 0, 0, &error));
8947 if( error != CL_SUCCESS ) {
8950 std::copy(pointer, pointer + length, startIterator);
8952 error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
8954 if( error != CL_SUCCESS ) {
8962 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 8966 template<
typename T,
class Alloc>
8967 inline cl_int
mapSVM(cl::vector<T, Alloc> &container)
8969 return enqueueMapSVM(container, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE);
8975 template<
typename T,
class Alloc>
8976 inline cl_int
unmapSVM(cl::vector<T, Alloc> &container)
8981 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 8983 #if CL_HPP_TARGET_OPENCL_VERSION >= 110 8984 inline cl_int enqueueReadBufferRect(
8987 const array<size_type, 3>& buffer_offset,
8988 const array<size_type, 3>& host_offset,
8989 const array<size_type, 3>& region,
8990 size_type buffer_row_pitch,
8991 size_type buffer_slice_pitch,
8992 size_type host_row_pitch,
8993 size_type host_slice_pitch,
8995 const vector<Event>* events = NULL,
8996 Event* event = NULL)
9001 if (error != CL_SUCCESS) {
9005 return queue.enqueueReadBufferRect(
9020 inline cl_int enqueueWriteBufferRect(
9023 const array<size_type, 3>& buffer_offset,
9024 const array<size_type, 3>& host_offset,
9025 const array<size_type, 3>& region,
9026 size_type buffer_row_pitch,
9027 size_type buffer_slice_pitch,
9028 size_type host_row_pitch,
9029 size_type host_slice_pitch,
9031 const vector<Event>* events = NULL,
9032 Event* event = NULL)
9037 if (error != CL_SUCCESS) {
9041 return queue.enqueueWriteBufferRect(
9056 inline cl_int enqueueCopyBufferRect(
9059 const array<size_type, 3>& src_origin,
9060 const array<size_type, 3>& dst_origin,
9061 const array<size_type, 3>& region,
9062 size_type src_row_pitch,
9063 size_type src_slice_pitch,
9064 size_type dst_row_pitch,
9065 size_type dst_slice_pitch,
9066 const vector<Event>* events = NULL,
9067 Event* event = NULL)
9072 if (error != CL_SUCCESS) {
9076 return queue.enqueueCopyBufferRect(
9089 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110 9091 inline cl_int enqueueReadImage(
9094 const array<size_type, 3>& origin,
9095 const array<size_type, 3>& region,
9096 size_type row_pitch,
9097 size_type slice_pitch,
9099 const vector<Event>* events = NULL,
9100 Event* event = NULL)
9105 if (error != CL_SUCCESS) {
9109 return queue.enqueueReadImage(
9121 inline cl_int enqueueWriteImage(
9124 const array<size_type, 3>& origin,
9125 const array<size_type, 3>& region,
9126 size_type row_pitch,
9127 size_type slice_pitch,
9129 const vector<Event>* events = NULL,
9130 Event* event = NULL)
9135 if (error != CL_SUCCESS) {
9139 return queue.enqueueWriteImage(
9151 inline cl_int enqueueCopyImage(
9154 const array<size_type, 3>& src_origin,
9155 const array<size_type, 3>& dst_origin,
9156 const array<size_type, 3>& region,
9157 const vector<Event>* events = NULL,
9158 Event* event = NULL)
9163 if (error != CL_SUCCESS) {
9167 return queue.enqueueCopyImage(
9177 inline cl_int enqueueCopyImageToBuffer(
9180 const array<size_type, 3>& src_origin,
9181 const array<size_type, 3>& region,
9182 size_type dst_offset,
9183 const vector<Event>* events = NULL,
9184 Event* event = NULL)
9189 if (error != CL_SUCCESS) {
9193 return queue.enqueueCopyImageToBuffer(
9203 inline cl_int enqueueCopyBufferToImage(
9206 size_type src_offset,
9207 const array<size_type, 3>& dst_origin,
9208 const array<size_type, 3>& region,
9209 const vector<Event>* events = NULL,
9210 Event* event = NULL)
9215 if (error != CL_SUCCESS) {
9219 return queue.enqueueCopyBufferToImage(
9230 inline cl_int flush(
void)
9235 if (error != CL_SUCCESS) {
9239 return queue.flush();
9242 inline cl_int finish(
void)
9247 if (error != CL_SUCCESS) {
9252 return queue.finish();
9262 vector<Event> events_;
9264 template<
typename... Ts>
9269 queue_(CommandQueue::getDefault()),
9278 queue_(CommandQueue::getDefault()),
9287 queue_(CommandQueue::getDefault()),
9296 queue_(CommandQueue::getDefault()),
9301 events_.push_back(e);
9305 queue_(CommandQueue::getDefault()),
9310 events_.push_back(e);
9314 queue_(CommandQueue::getDefault()),
9319 events_.push_back(e);
9323 queue_(CommandQueue::getDefault()),
9333 queue_(CommandQueue::getDefault()),
9343 queue_(CommandQueue::getDefault()),
9385 events_.push_back(e);
9394 events_.push_back(e);
9403 events_.push_back(e);
9445 template<
typename... Ts>
9451 template<
int index,
typename T0,
typename... T1s>
9452 void setArgs(T0&& t0, T1s&&... t1s)
9454 kernel_.
setArg(index, t0);
9455 setArgs<index + 1, T1s...>(std::forward<T1s>(t1s)...);
9458 template<
int index,
typename T0>
9459 void setArgs(T0&& t0)
9461 kernel_.
setArg(index, t0);
9477 cl_int * err = NULL) :
9478 kernel_(program, name.c_str(), err)
9494 setArgs<0>(std::forward<Ts>(ts)...);
9496 args.queue_.enqueueNDRangeKernel(
9519 setArgs<0>(std::forward<Ts>(ts)...);
9521 error = args.queue_.enqueueNDRangeKernel(
9532 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 9533 cl_int setSVMPointers(
const vector<void*> &pointerList)
9538 template<
typename T0,
typename... T1s>
9539 cl_int setSVMPointers(
const T0 &t0, T1s &... ts)
9543 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 9551 namespace compatibility {
9556 template<
typename... Ts>
9566 cl_int * err = NULL) :
9588 enqueueArgs, args...);
9596 #undef CL_HPP_ERR_STR_ 9597 #if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS) 9598 #undef __GET_DEVICE_INFO_ERR 9599 #undef __GET_PLATFORM_INFO_ERR 9600 #undef __GET_DEVICE_IDS_ERR 9601 #undef __GET_CONTEXT_INFO_ERR 9602 #undef __GET_EVENT_INFO_ERR 9603 #undef __GET_EVENT_PROFILE_INFO_ERR 9604 #undef __GET_MEM_OBJECT_INFO_ERR 9605 #undef __GET_IMAGE_INFO_ERR 9606 #undef __GET_SAMPLER_INFO_ERR 9607 #undef __GET_KERNEL_INFO_ERR 9608 #undef __GET_KERNEL_ARG_INFO_ERR 9609 #undef __GET_KERNEL_WORK_GROUP_INFO_ERR 9610 #undef __GET_PROGRAM_INFO_ERR 9611 #undef __GET_PROGRAM_BUILD_INFO_ERR 9612 #undef __GET_COMMAND_QUEUE_INFO_ERR 9614 #undef __CREATE_CONTEXT_ERR 9615 #undef __CREATE_CONTEXT_FROM_TYPE_ERR 9616 #undef __GET_SUPPORTED_IMAGE_FORMATS_ERR 9618 #undef __CREATE_BUFFER_ERR 9619 #undef __CREATE_SUBBUFFER_ERR 9620 #undef __CREATE_IMAGE2D_ERR 9621 #undef __CREATE_IMAGE3D_ERR 9622 #undef __CREATE_SAMPLER_ERR 9623 #undef __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR 9625 #undef __CREATE_USER_EVENT_ERR 9626 #undef __SET_USER_EVENT_STATUS_ERR 9627 #undef __SET_EVENT_CALLBACK_ERR 9628 #undef __SET_PRINTF_CALLBACK_ERR 9630 #undef __WAIT_FOR_EVENTS_ERR 9632 #undef __CREATE_KERNEL_ERR 9633 #undef __SET_KERNEL_ARGS_ERR 9634 #undef __CREATE_PROGRAM_WITH_SOURCE_ERR 9635 #undef __CREATE_PROGRAM_WITH_BINARY_ERR 9636 #undef __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR 9637 #undef __BUILD_PROGRAM_ERR 9638 #undef __CREATE_KERNELS_IN_PROGRAM_ERR 9640 #undef __CREATE_COMMAND_QUEUE_ERR 9641 #undef __SET_COMMAND_QUEUE_PROPERTY_ERR 9642 #undef __ENQUEUE_READ_BUFFER_ERR 9643 #undef __ENQUEUE_WRITE_BUFFER_ERR 9644 #undef __ENQUEUE_READ_BUFFER_RECT_ERR 9645 #undef __ENQUEUE_WRITE_BUFFER_RECT_ERR 9646 #undef __ENQEUE_COPY_BUFFER_ERR 9647 #undef __ENQEUE_COPY_BUFFER_RECT_ERR 9648 #undef __ENQUEUE_READ_IMAGE_ERR 9649 #undef __ENQUEUE_WRITE_IMAGE_ERR 9650 #undef __ENQUEUE_COPY_IMAGE_ERR 9651 #undef __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR 9652 #undef __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR 9653 #undef __ENQUEUE_MAP_BUFFER_ERR 9654 #undef __ENQUEUE_MAP_IMAGE_ERR 9655 #undef __ENQUEUE_UNMAP_MEM_OBJECT_ERR 9656 #undef __ENQUEUE_NDRANGE_KERNEL_ERR 9657 #undef __ENQUEUE_TASK_ERR 9658 #undef __ENQUEUE_NATIVE_KERNEL 9660 #undef __UNLOAD_COMPILER_ERR 9661 #undef __CREATE_SUB_DEVICES_ERR 9663 #undef __CREATE_PIPE_ERR 9664 #undef __GET_PIPE_INFO_ERR 9666 #endif //CL_HPP_USER_OVERRIDE_ERROR_STRINGS 9669 #undef CL_HPP_INIT_CL_EXT_FCN_PTR_ 9670 #undef CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_ 9672 #if defined(CL_HPP_USE_CL_DEVICE_FISSION) 9673 #undef CL_HPP_PARAM_NAME_DEVICE_FISSION_ 9674 #endif // CL_HPP_USE_CL_DEVICE_FISSION 9676 #undef CL_HPP_NOEXCEPT_ 9677 #undef CL_HPP_DEFINE_STATIC_MEMBER_ Memory()
Default constructor - initializes to NULL.
Event type_(const EnqueueArgs &, Ts...)
Function signature of kernel functor with no event dependency.
BufferRenderGL(const cl_mem &buffer, bool retainObject=false)
Constructor from cl_mem - takes ownership.
CommandQueue(CommandQueue &&queue) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Image interface for arrays of 2D images.
Image1DBuffer(const cl_mem &image1D, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Image interface for arrays of 1D images.
Image2DGL()
Default constructor - initializes to NULL.
cl_int getInfo(cl_context_info name, T *param) const
Wrapper for clGetContextInfo().
Context(const cl_context &context, bool retainObject=false)
Constructor from cl_context - takes ownership.
Image & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
Image3D(const Image3D &img)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
static DeviceCommandQueue makeDefault(const Context &context, const Device &device, cl_uint queueSize, cl_int *err=nullptr)
Image2DGL(const Image2DGL &img)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
std::enable_if< std::is_pointer< T >::value, cl_int >::type setArg(cl_uint index, const T argPtr)
setArg overload taking a pointer type
Image1DBuffer(const Image1DBuffer &img)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Image2D(const Context &context, cl_mem_flags flags, ImageFormat format, size_type width, size_type height, size_type row_pitch=0, void *host_ptr=NULL, cl_int *err=NULL)
Constructs a 2D Image in a specified context.
Image1D(const Context &context, cl_mem_flags flags, ImageFormat format, size_type width, void *host_ptr=NULL, cl_int *err=NULL)
Constructs a 1D Image in a specified context.
Image2D & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
cl_int setSVMPointers(const vector< void *> &pointerList)
The OpenCL C++ bindings are defined within this namespace.
CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_int enqueueBarrier() const CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
Image(Image &&img) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
detail::param_traits< detail::cl_device_info, name >::param_type getInfo(cl_int *err=NULL) const
Wrapper for clGetDeviceInfo() that returns by value.
cl_int unmapSVM(cl::vector< T, Alloc > &container)
Context(const Context &ctx)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Local address wrapper for use with Kernel::setArg.
detail::param_traits< detail::cl_pipe_info, name >::param_type getInfo(cl_int *err=NULL) const
Wrapper for clGetMemObjectInfo() that returns by value.
cl_int enqueueMapSVM(cl::vector< T, Alloc > &container, cl_bool blocking, cl_map_flags flags, const vector< Event > *events=NULL, Event *event=NULL) const
Class interface for GL 3D Image Memory objects.
CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_int enqueueMarker(Event *event=NULL) const CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
CommandQueue(const Context &context, const Device &device, QueueProperties properties, cl_int *err=NULL)
Constructs a CommandQueue for a passed device and context Will return an CL_INVALID_QUEUE_PROPERTIES ...
CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_int UnloadCompiler() CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
static DeviceCommandQueue makeDefault(const Context &context, const Device &device, cl_int *err=nullptr)
Program(const Context &context, const vector< Device > &devices, const Binaries &binaries, vector< cl_int > *binaryStatus=NULL, cl_int *err=NULL)
Buffer(IteratorType startIterator, IteratorType endIterator, bool readOnly, bool useHostPtr=false, cl_int *err=NULL)
Construct a Buffer from a host container via iterators. IteratorType must be random access...
Class interface for cl_mem.
Pipe(cl_uint packet_size, cl_uint max_packets, cl_int *err=NULL)
Constructs a Pipe in a the default context.
cl_int enqueueMigrateMemObjects(const vector< Memory > &memObjects, cl_mem_migration_flags flags, const vector< Event > *events=NULL, Event *event=NULL) const
Device(const Device &dev)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
BufferRenderGL(BufferRenderGL &&buf) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Image2DArray(Image2DArray &&img) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
detail::param_traits< detail::cl_image_info, name >::param_type getImageInfo(cl_int *err=NULL) const
Wrapper for clGetImageInfo() that returns by value.
Memory(Memory &&mem) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
cl_int enqueueMarkerWithWaitList(const vector< Event > *events=0, Event *event=0) const
Image3D(Image3D &&img) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
cl_int getSupportedImageFormats(cl_mem_flags flags, cl_mem_object_type type, vector< ImageFormat > *formats) const
Gets a list of supported image formats.
BufferRenderGL()
Default constructor - initializes to NULL.
Image(const Image &img)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
cl_int enqueueFillBuffer(const Buffer &buffer, PatternType pattern, size_type offset, size_type size, const vector< Event > *events=NULL, Event *event=NULL) const
Image1DArray(const Image1DArray &img)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Kernel(const Kernel &kernel)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
CommandQueue(const Context &context, cl_command_queue_properties properties=0, cl_int *err=NULL)
Constructs a CommandQueue for an implementation defined device in the given context Will return an CL...
Buffer createSubBuffer(cl_mem_flags flags, cl_buffer_create_type buffer_create_type, const void *buffer_create_info, cl_int *err=NULL)
Creates a new buffer object from this.
cl_int enqueueBarrierWithWaitList(const vector< Event > *events=0, Event *event=0) const
Buffer(Buffer &&buf) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
vector< T, cl::SVMAllocator< int, cl::SVMTraitCoarse<> >> coarse_svm_vector
Vector alias to simplify contruction of coarse-grained SVM containers.
static Device getDefault(cl_int *errResult=NULL)
Returns the first device on the default context.
cl_int enqueueUnmapSVM(T *ptr, const vector< Event > *events=NULL, Event *event=NULL)
Sampler(const Sampler &sam)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
cl_int setCallback(cl_int type, void(CL_CALLBACK *pfn_notify)(cl_event, cl_int, void *), void *user_data=NULL)
Registers a user callback function for a specific command execution status.
size_type dimensions() const
Queries the number of dimensions in the range.
Event()
Default constructor - initializes to NULL.
ImageGL(const cl_mem &image, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Image3D(const Context &context, cl_mem_flags flags, ImageFormat format, size_type width, size_type height, size_type depth, size_type row_pitch=0, size_type slice_pitch=0, void *host_ptr=NULL, cl_int *err=NULL)
Constructs a 3D Image in a specified context.
cl_int setArg(cl_uint index, const cl::vector< T, Alloc > &argPtr)
setArg overload taking a vector type.
detail::param_traits< detail::cl_profiling_info, name >::param_type getProfilingInfo(cl_int *err=NULL) const
Wrapper for clGetEventProfilingInfo() that returns by value.
Image1D(const Image1D &img)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
BufferRenderGL(const BufferRenderGL &buf)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
DeviceCommandQueue(DeviceQueueProperties properties, cl_int *err=NULL)
Pipe(const Context &context, cl_uint packet_size, cl_uint max_packets, cl_int *err=NULL)
Constructs a Pipe in a specified context.
Image3D()
Default constructor - initializes to NULL.
CommandQueue(const Context &context, const Device &device, cl_command_queue_properties properties=0, cl_int *err=NULL)
Constructs a CommandQueue for a passed device and context Will return an CL_INVALID_QUEUE_PROPERTIES ...
Image2DGL(Image2DGL &&img) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
cl_int getInfo(cl_sampler_info name, T *param) const
Wrapper for clGetSamplerInfo().
Kernel()
Default constructor - initializes to NULL.
Image2DGL(const Context &context, cl_mem_flags flags, cl_GLenum target, cl_GLint miplevel, cl_GLuint texobj, cl_int *err=NULL)
Constructs an Image2DGL in a specified context, from a given GL Texture.
Sampler()
Default constructor - initializes to NULL.
Image1D(Image1D &&img) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Program(Program &&program) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
cl_int getObjectInfo(cl_gl_object_type *type, cl_GLuint *gl_object_name)
Wrapper for clGetGLObjectInfo().
std::enable_if<!std::is_pointer< T >::value, cl_int >::type setArg(cl_uint index, const T &value)
setArg overload taking a POD type
size_type max_size() const CL_HPP_NOEXCEPT_
Image1DArray(const cl_mem &imageArray, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Class interface for cl_event.
vector< T, cl::SVMAllocator< int, cl::SVMTraitFine<> >> fine_svm_vector
Vector alias to simplify contruction of fine-grained SVM containers.
Image2DGL(const cl_mem &image, bool retainObject=false)
Constructor from cl_mem - takes ownership.
NDRange(size_type size0)
Constructs one-dimensional range.
Program(const Context &context, const Sources &sources, cl_int *err=NULL)
vector< T, cl::SVMAllocator< int, cl::SVMTraitAtomic<> >> atomic_svm_vector
Vector alias to simplify contruction of fine-grained SVM containers that support platform atomics...
Buffer & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
detail::param_traits< detail::cl_event_info, name >::param_type getInfo(cl_int *err=NULL) const
Wrapper for clGetEventInfo() that returns by value.
Class interface for Pipe Memory Objects.
cl_int enqueueUnmapSVM(cl::pointer< T, D > &ptr, const vector< Event > *events=NULL, Event *event=NULL) const
Image2D(const Image2D &img)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Buffer()
Default constructor - initializes to NULL.
DeviceCommandQueue(const Context &context, const Device &device, DeviceQueueProperties properties=DeviceQueueProperties::None, cl_int *err=NULL)
cl_int setArg(cl_uint index, const cl::pointer< T, D > &argPtr)
setArg overload taking a shared_ptr type
Image3DGL(const Image3DGL &img)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
cl_int copy(IteratorType startIterator, IteratorType endIterator, cl::Buffer &buffer)
Context(const vector< Device > &devices, cl_context_properties *properties=NULL, void(CL_CALLBACK *notifyFptr)(const char *, const void *, size_type, void *)=NULL, void *data=NULL, cl_int *err=NULL)
Constructs a context including a list of specified devices.
DeviceCommandQueue(const DeviceCommandQueue &queue)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Sampler(const cl_sampler &sampler, bool retainObject=false)
Constructor from cl_sampler - takes ownership.
Image()
Default constructor - initializes to NULL.
static cl_int release(cl_device_id device)
cl_int getInfo(cl_device_info name, T *param) const
Wrapper for clGetDeviceInfo().
Event(const cl_event &event, bool retainObject=false)
Constructor from cl_event - takes ownership.
DeviceCommandQueue(const Context &context, const Device &device, cl_uint queueSize, DeviceQueueProperties properties=DeviceQueueProperties::None, cl_int *err=NULL)
NDRange(size_type size0, size_type size1)
Constructs two-dimensional range.
Image3DGL(const Context &context, cl_mem_flags flags, cl_GLenum target, cl_GLint miplevel, cl_GLuint texobj, cl_int *err=NULL)
Constructs an Image3DGL in a specified context, from a given GL Texture.
Image2D()
Default constructor - initializes to NULL.
Image3D(const cl_mem &image3D, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Image2D(Image2D &&img) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
DeviceCommandQueue interface for device cl_command_queues.
Image1DArray(Image1DArray &&img) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Pipe()
Default constructor - initializes to NULL.
CommandQueue(const cl_command_queue &commandQueue, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Pipe(const Pipe &pipe)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
cl_int getInfo(cl_event_info name, T *param) const
Wrapper for clGetEventInfo().
Image1D()
Default constructor - initializes to NULL.
Buffer(const cl_mem &buffer, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Sampler(Sampler &&sam) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
static CommandQueue setDefault(const CommandQueue &default_queue)
Program(const Context &context, const vector< Device > &devices, const string &kernelNames, cl_int *err=NULL)
CommandQueue(const CommandQueue &queue)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
cl_int enqueueMapSVM(T *ptr, cl_bool blocking, cl_map_flags flags, size_type size, const vector< Event > *events=NULL, Event *event=NULL) const
Kernel(Kernel &&kernel) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
cl_int enqueueFillImage(const Image &image, cl_uint4 fillColor, const array< size_type, 3 > &origin, const array< size_type, 3 > ®ion, const vector< Event > *events=NULL, Event *event=NULL) const
Image2D(const Context &context, ImageFormat format, const Buffer &sourceBuffer, size_type width, size_type height, size_type row_pitch=0, cl_int *err=nullptr)
Constructs a 2D Image from a buffer.
Program(const Sources &sources, cl_int *err=NULL)
Device(const cl_device_id &device, bool retainObject=false)
Constructor from cl_device_id.
NDRange()
Default constructor - resulting range has zero dimensions.
BufferGL(const BufferGL &buf)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Image3D & operator=(const cl_mem &rhs)
Assignment from cl_mem - performs shallow copy.
CommandQueue(const Context &context, QueueProperties properties, cl_int *err=NULL)
Constructs a CommandQueue for an implementation defined device in the given context Will return an CL...
cl_int setDestructorCallback(void(CL_CALLBACK *pfn_notify)(cl_mem, void *), void *user_data=NULL)
Registers a callback function to be called when the memory object is no longer needed.
CommandQueue(cl_command_queue_properties properties, cl_int *err=NULL)
Constructs a CommandQueue based on passed properties. Will return an CL_INVALID_QUEUE_PROPERTIES erro...
Buffer(const Context &context, cl_mem_flags flags, size_type size, void *host_ptr=NULL, cl_int *err=NULL)
Constructs a Buffer in a specified context.
cl_int wait() const
Blocks the calling thread until this event completes.
Event result_type
Return type of the functor.
cl_int setSVMPointers(const std::array< void *, ArrayLength > &pointerList)
Image2DArray(const cl_mem &imageArray, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Buffer(const Buffer &buf)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Image(const cl_mem &image, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Memory(const Memory &mem)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Program(const Program &program)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
cl_int getObjectInfo(cl_gl_object_type *type, cl_GLuint *gl_object_name)
Wrapper for clGetGLObjectInfo().
static cl_int retain(cl_device_id device)
Image3DGL()
Default constructor - initializes to NULL.
Image2D(const Context &context, cl_channel_order order, const Image &sourceImage, cl_int *err=nullptr)
Constructs a 2D Image from an image.
CommandQueue interface for cl_command_queue.
Image2D(const cl_mem &image2D, bool retainObject=false)
Constructor from cl_mem - takes ownership.
cl_int enqueueUnmapSVM(cl::vector< T, Alloc > &container, const vector< Event > *events=NULL, Event *event=NULL) const
Sampler(const Context &context, cl_bool normalized_coords, cl_addressing_mode addressing_mode, cl_filter_mode filter_mode, cl_int *err=NULL)
Constructs a Sampler in a specified context.
Image1D(const cl_mem &image1D, bool retainObject=false)
Constructor from cl_mem - takes ownership.
pointer allocate(size_type size, typename cl::SVMAllocator< void, SVMTrait >::const_pointer=0)
static DeviceCommandQueue makeDefault(cl_int *err=nullptr)
UserEvent()
Default constructor - initializes to NULL.
DeviceCommandQueue(const cl_command_queue &commandQueue, bool retainObject=false)
Constructor from cl_command_queue - takes ownership.
cl_int enableFineGrainedSystemSVM(bool svmEnabled)
Enable fine-grained system SVM.
Pipe(const cl_mem &pipe, bool retainObject=false)
Constructor from cl_mem - takes ownership.
detail::param_traits< detail::cl_context_info, name >::param_type getInfo(cl_int *err=NULL) const
Wrapper for clGetContextInfo() that returns by value.
Pipe(Pipe &&pipe) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
cl_int mapSVM(cl::vector< T, Alloc > &container)
cl::pointer< T, detail::Deleter< Alloc > > allocate_pointer(const Alloc &alloc_, Args &&... args)
Class interface for user events (a subset of cl_event's).
bool operator==(SVMAllocator const &rhs)
cl_int enqueueFillImage(const Image &image, cl_int4 fillColor, const array< size_type, 3 > &origin, const array< size_type, 3 > ®ion, const vector< Event > *events=NULL, Event *event=NULL) const
Program(const cl_program &program, bool retainObject=false)
Constructor from cl_mem - takes ownership.
cl_int enqueueUnmapSVM(T *ptr, const vector< Event > *events=NULL, Event *event=NULL) const
Kernel(const cl_kernel &kernel, bool retainObject=false)
Constructor from cl_kernel - takes ownership.
vector< std::pair< cl::Device, typename detail::param_traits< detail::cl_program_build_info, name >::param_type > > getBuildInfo(cl_int *err=NULL) const
cl_int getProfilingInfo(cl_profiling_info name, T *param) const
Wrapper for clGetEventProfilingInfo().
Class interface for cl_sampler.
ImageGL(const ImageGL &img)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
LocalSpaceArg Local(size_type size)
Helper function for generating LocalSpaceArg objects.
Event result_type
Return type of the functor.
detail::param_traits< detail::cl_mem_info, name >::param_type getInfo(cl_int *err=NULL) const
Wrapper for clGetMemObjectInfo() that returns by value.
C++ base class for Image Memory objects.
cl_int enqueueMapSVM(T *ptr, cl_bool blocking, cl_map_flags flags, size_type size, const vector< Event > *events=NULL, Event *event=NULL)
Buffer(cl_mem_flags flags, size_type size, void *host_ptr=NULL, cl_int *err=NULL)
Constructs a Buffer in the default context.
static Context setDefault(const Context &default_context)
cl_int enqueueMapSVM(cl::pointer< T, D > &ptr, cl_bool blocking, cl_map_flags flags, size_type size, const vector< Event > *events=NULL, Event *event=NULL) const
BufferGL(BufferGL &&buf) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Class interface for Buffer Memory Objects.
detail::param_traits< detail::cl_sampler_info, name >::param_type getInfo(cl_int *err=NULL) const
Wrapper for clGetSamplerInfo() that returns by value.
static Device setDefault(const Device &default_device)
Image1DBuffer(Image1DBuffer &&img) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Class interface for specifying NDRange values.
Class interface for 2D Image Memory objects.
ImageGL(ImageGL &&img) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Class interface for 1D Image Memory objects.
Class interface for cl_kernel.
NDRange(size_type size0, size_type size1, size_type size2)
Constructs three-dimensional range.
static cl_int waitForEvents(const vector< Event > &events)
Blocks the calling thread until every event specified is complete.
Class interface for 3D Image Memory objects.
Class interface for GL Render Buffer Memory Objects.
general image interface for GL interop. We abstract the 2D and 3D GL images into a single instance he...
cl_int setStatus(cl_int status)
Sets the execution status of a user event object.
Device()
Default constructor - initializes to NULL.
Context()
Default constructor - initializes to NULL.
Image2DArray(const Image2DArray &img)
Copy constructor to forward copy to the superclass correctly. Required for MSVC.
Class interface for cl_device_id.
Context(Context &&ctx) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
static Context getDefault(cl_int *err=NULL)
Returns a singleton context including all devices of CL_DEVICE_TYPE_DEFAULT.
Context(cl_device_type type, cl_context_properties *properties=NULL, void(CL_CALLBACK *notifyFptr)(const char *, const void *, size_type, void *)=NULL, void *data=NULL, cl_int *err=NULL)
Constructs a context including all or a subset of devices of a specified type.
Memory(const cl_mem &memory, bool retainObject)
Constructor from cl_mem - takes ownership.
Device(Device &&dev) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
BufferRenderGL(const Context &context, cl_mem_flags flags, cl_GLuint bufobj, cl_int *err=NULL)
Constructs a BufferRenderGL in a specified context, from a given GL Renderbuffer. ...
cl_int getImageInfo(cl_image_info name, T *param) const
Wrapper for clGetImageInfo().
BufferGL()
Default constructor - initializes to NULL.
UserEvent(const Context &context, cl_int *err=NULL)
Constructs a user event on a given context.
cl_int enqueueFillImage(const Image &image, cl_float4 fillColor, const array< size_type, 3 > &origin, const array< size_type, 3 > ®ion, const vector< Event > *events=NULL, Event *event=NULL) const
CommandQueue(QueueProperties properties, cl_int *err=NULL)
Constructs a CommandQueue based on passed properties. Will return an CL_INVALID_QUEUE_PROPERTIES erro...
cl_int getInfo(cl_pipe_info name, T *param) const
Wrapper for clGetMemObjectInfo().
Image interface for 1D buffer images.
Program interface that implements cl_program.
Image3DGL(const cl_mem &image, bool retainObject=false)
Constructor from cl_mem - takes ownership.
Image3DGL(Image3DGL &&img) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
Class interface for GL Buffer Memory Objects.
DeviceCommandQueue(DeviceCommandQueue &&queue) CL_HPP_NOEXCEPT_
Move constructor to forward move to the superclass correctly. Required for MSVC.
cl_int copy(const CommandQueue &queue, const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator)
Class interface for GL 2D Image Memory objects.
Class interface for cl_context.
BufferGL(const Context &context, cl_mem_flags flags, cl_GLuint bufobj, cl_int *err=NULL)
Constructs a BufferGL in a specified context, from a given GL buffer.
Memory & operator=(const cl_mem &rhs)
Assignment operator from cl_mem - takes ownership.
size_type size() const
Returns the size of the object in bytes based on the.
BufferGL(const cl_mem &buffer, bool retainObject=false)
Constructor from cl_mem - takes ownership.
cl_int getInfo(cl_mem_info name, T *param) const
Wrapper for clGetMemObjectInfo().