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 452 #if defined(CL_TARGET_OPENCL_VERSION) 455 #if CL_TARGET_OPENCL_VERSION < CL_HPP_TARGET_OPENCL_VERSION 456 # pragma message("CL_TARGET_OPENCL_VERSION is already defined as is lower than CL_HPP_TARGET_OPENCL_VERSION") 459 # define CL_TARGET_OPENCL_VERSION CL_HPP_TARGET_OPENCL_VERSION 462 #if !defined(CL_HPP_MINIMUM_OPENCL_VERSION) 463 # define CL_HPP_MINIMUM_OPENCL_VERSION 200 465 #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 466 # 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") 467 # undef CL_HPP_MINIMUM_OPENCL_VERSION 468 # define CL_HPP_MINIMUM_OPENCL_VERSION 100 470 #if CL_HPP_MINIMUM_OPENCL_VERSION > CL_HPP_TARGET_OPENCL_VERSION 471 # error "CL_HPP_MINIMUM_OPENCL_VERSION must not be greater than CL_HPP_TARGET_OPENCL_VERSION" 474 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 100 && !defined(CL_USE_DEPRECATED_OPENCL_1_0_APIS) 475 # define CL_USE_DEPRECATED_OPENCL_1_0_APIS 477 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 110 && !defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 478 # define CL_USE_DEPRECATED_OPENCL_1_1_APIS 480 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 120 && !defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS) 481 # define CL_USE_DEPRECATED_OPENCL_1_2_APIS 483 #if CL_HPP_MINIMUM_OPENCL_VERSION <= 200 && !defined(CL_USE_DEPRECATED_OPENCL_2_0_APIS) 484 # define CL_USE_DEPRECATED_OPENCL_2_0_APIS 491 #if defined(CL_HPP_USE_DX_INTEROP) 492 #include <CL/cl_d3d10.h> 493 #include <CL/cl_dx9_media_sharing.h> 497 #if defined(_MSC_VER) 505 #if (!defined(_MSC_VER) && __cplusplus < 201103L) || (defined(_MSC_VER) && _MSC_VER < 1700) 506 #error Visual studio 2013 or another C++11-supporting compiler required 510 #if defined(CL_HPP_USE_CL_DEVICE_FISSION) || defined(CL_HPP_USE_CL_SUB_GROUPS_KHR) 511 #include <CL/cl_ext.h> 514 #if defined(__APPLE__) || defined(__MACOSX) 515 #include <OpenCL/opencl.h> 517 #include <CL/opencl.h> 520 #if (__cplusplus >= 201103L) 521 #define CL_HPP_NOEXCEPT_ noexcept 523 #define CL_HPP_NOEXCEPT_ 526 #if defined(_MSC_VER) 527 # define CL_HPP_DEFINE_STATIC_MEMBER_ __declspec(selectany) 529 # define CL_HPP_DEFINE_STATIC_MEMBER_ __attribute__((weak)) 534 #if !defined(CL_EXT_PREFIX__VERSION_1_1_DEPRECATED) 535 #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED 536 #endif // #if !defined(CL_EXT_PREFIX__VERSION_1_1_DEPRECATED) 537 #if !defined(CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED) 538 #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED 539 #endif // #if !defined(CL_EXT_PREFIX__VERSION_1_1_DEPRECATED) 541 #if !defined(CL_EXT_PREFIX__VERSION_1_2_DEPRECATED) 542 #define CL_EXT_PREFIX__VERSION_1_2_DEPRECATED 543 #endif // #if !defined(CL_EXT_PREFIX__VERSION_1_2_DEPRECATED) 544 #if !defined(CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED) 545 #define CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED 546 #endif // #if !defined(CL_EXT_PREFIX__VERSION_1_2_DEPRECATED) 548 #if !defined(CL_CALLBACK) 557 #include <functional> 561 #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY) 563 using size_type = ::size_t;
565 #else // #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY) 567 using size_type = size_t;
569 #endif // #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY) 572 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 574 #endif // #if defined(CL_HPP_ENABLE_EXCEPTIONS) 576 #if !defined(CL_HPP_NO_STD_VECTOR) 579 template <
class T,
class Alloc = std::allocator<T> >
580 using vector = std::vector<T, Alloc>;
582 #endif // #if !defined(CL_HPP_NO_STD_VECTOR) 584 #if !defined(CL_HPP_NO_STD_STRING) 587 using string = std::string;
589 #endif // #if !defined(CL_HPP_NO_STD_STRING) 591 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 593 #if !defined(CL_HPP_NO_STD_UNIQUE_PTR) 598 template<
class T,
class D>
599 using pointer = std::unique_ptr<T, D>;
602 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 603 #if !defined(CL_HPP_NO_STD_ARRAY) 606 template <
class T,
size_type N >
607 using array = std::array<T, N>;
609 #endif // #if !defined(CL_HPP_NO_STD_ARRAY) 613 #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY) 615 namespace compatibility {
630 for (
int i = 0; i < N; ++i) {
635 size_t(
const array<size_type, N> &rhs)
637 for (
int i = 0; i < N; ++i) {
642 size_type& operator[](
int index)
647 const size_type& operator[](
int index)
const 653 operator size_type* () {
return data_; }
656 operator const size_type* ()
const {
return data_; }
658 operator array<size_type, N>()
const 660 array<size_type, N> ret;
662 for (
int i = 0; i < N; ++i) {
671 using size_t = compatibility::size_t<N>;
673 #endif // #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY) 678 using size_t_array = array<size_type, 3>;
691 #define CL_HPP_INIT_CL_EXT_FCN_PTR_(name) \ 693 pfn_##name = (PFN_##name) \ 694 clGetExtensionFunctionAddress(#name); \ 699 #define CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, name) \ 701 pfn_##name = (PFN_##name) \ 702 clGetExtensionFunctionAddressForPlatform(platform, #name); \ 716 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 721 class Error :
public std::exception
725 const char * errStr_;
736 Error(cl_int err,
const char * errStr = NULL) : err_(err), errStr_(errStr)
745 virtual const char * what()
const throw ()
747 if (errStr_ == NULL) {
759 cl_int err(
void)
const {
return err_; }
761 #define CL_HPP_ERR_STR_(x) #x 763 #define CL_HPP_ERR_STR_(x) NULL 764 #endif // CL_HPP_ENABLE_EXCEPTIONS 769 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 770 static inline cl_int errHandler (
772 const char * errStr = NULL)
774 if (err != CL_SUCCESS) {
775 throw Error(err, errStr);
780 static inline cl_int errHandler (cl_int err,
const char * errStr = NULL)
785 #endif // CL_HPP_ENABLE_EXCEPTIONS 791 #if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS) 792 #define __GET_DEVICE_INFO_ERR CL_HPP_ERR_STR_(clGetDeviceInfo) 793 #define __GET_PLATFORM_INFO_ERR CL_HPP_ERR_STR_(clGetPlatformInfo) 794 #define __GET_DEVICE_IDS_ERR CL_HPP_ERR_STR_(clGetDeviceIDs) 795 #define __GET_PLATFORM_IDS_ERR CL_HPP_ERR_STR_(clGetPlatformIDs) 796 #define __GET_CONTEXT_INFO_ERR CL_HPP_ERR_STR_(clGetContextInfo) 797 #define __GET_EVENT_INFO_ERR CL_HPP_ERR_STR_(clGetEventInfo) 798 #define __GET_EVENT_PROFILE_INFO_ERR CL_HPP_ERR_STR_(clGetEventProfileInfo) 799 #define __GET_MEM_OBJECT_INFO_ERR CL_HPP_ERR_STR_(clGetMemObjectInfo) 800 #define __GET_IMAGE_INFO_ERR CL_HPP_ERR_STR_(clGetImageInfo) 801 #define __GET_SAMPLER_INFO_ERR CL_HPP_ERR_STR_(clGetSamplerInfo) 802 #define __GET_KERNEL_INFO_ERR CL_HPP_ERR_STR_(clGetKernelInfo) 803 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 804 #define __GET_KERNEL_ARG_INFO_ERR CL_HPP_ERR_STR_(clGetKernelArgInfo) 805 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 806 #define __GET_KERNEL_WORK_GROUP_INFO_ERR CL_HPP_ERR_STR_(clGetKernelWorkGroupInfo) 807 #define __GET_PROGRAM_INFO_ERR CL_HPP_ERR_STR_(clGetProgramInfo) 808 #define __GET_PROGRAM_BUILD_INFO_ERR CL_HPP_ERR_STR_(clGetProgramBuildInfo) 809 #define __GET_COMMAND_QUEUE_INFO_ERR CL_HPP_ERR_STR_(clGetCommandQueueInfo) 811 #define __CREATE_CONTEXT_ERR CL_HPP_ERR_STR_(clCreateContext) 812 #define __CREATE_CONTEXT_FROM_TYPE_ERR CL_HPP_ERR_STR_(clCreateContextFromType) 813 #define __GET_SUPPORTED_IMAGE_FORMATS_ERR CL_HPP_ERR_STR_(clGetSupportedImageFormats) 815 #define __CREATE_BUFFER_ERR CL_HPP_ERR_STR_(clCreateBuffer) 816 #define __COPY_ERR CL_HPP_ERR_STR_(cl::copy) 817 #define __CREATE_SUBBUFFER_ERR CL_HPP_ERR_STR_(clCreateSubBuffer) 818 #define __CREATE_GL_BUFFER_ERR CL_HPP_ERR_STR_(clCreateFromGLBuffer) 819 #define __CREATE_GL_RENDER_BUFFER_ERR CL_HPP_ERR_STR_(clCreateFromGLBuffer) 820 #define __GET_GL_OBJECT_INFO_ERR CL_HPP_ERR_STR_(clGetGLObjectInfo) 821 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 822 #define __CREATE_IMAGE_ERR CL_HPP_ERR_STR_(clCreateImage) 823 #define __CREATE_GL_TEXTURE_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture) 824 #define __IMAGE_DIMENSION_ERR CL_HPP_ERR_STR_(Incorrect image dimensions) 825 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 826 #define __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR CL_HPP_ERR_STR_(clSetMemObjectDestructorCallback) 828 #define __CREATE_USER_EVENT_ERR CL_HPP_ERR_STR_(clCreateUserEvent) 829 #define __SET_USER_EVENT_STATUS_ERR CL_HPP_ERR_STR_(clSetUserEventStatus) 830 #define __SET_EVENT_CALLBACK_ERR CL_HPP_ERR_STR_(clSetEventCallback) 831 #define __WAIT_FOR_EVENTS_ERR CL_HPP_ERR_STR_(clWaitForEvents) 833 #define __CREATE_KERNEL_ERR CL_HPP_ERR_STR_(clCreateKernel) 834 #define __SET_KERNEL_ARGS_ERR CL_HPP_ERR_STR_(clSetKernelArg) 835 #define __CREATE_PROGRAM_WITH_SOURCE_ERR CL_HPP_ERR_STR_(clCreateProgramWithSource) 836 #define __CREATE_PROGRAM_WITH_BINARY_ERR CL_HPP_ERR_STR_(clCreateProgramWithBinary) 837 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 838 #define __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR CL_HPP_ERR_STR_(clCreateProgramWithBuiltInKernels) 839 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 840 #define __BUILD_PROGRAM_ERR CL_HPP_ERR_STR_(clBuildProgram) 841 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 842 #define __COMPILE_PROGRAM_ERR CL_HPP_ERR_STR_(clCompileProgram) 843 #define __LINK_PROGRAM_ERR CL_HPP_ERR_STR_(clLinkProgram) 844 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 845 #define __CREATE_KERNELS_IN_PROGRAM_ERR CL_HPP_ERR_STR_(clCreateKernelsInProgram) 847 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 848 #define __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR CL_HPP_ERR_STR_(clCreateCommandQueueWithProperties) 849 #define __CREATE_SAMPLER_WITH_PROPERTIES_ERR CL_HPP_ERR_STR_(clCreateSamplerWithProperties) 850 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200 851 #define __SET_COMMAND_QUEUE_PROPERTY_ERR CL_HPP_ERR_STR_(clSetCommandQueueProperty) 852 #define __ENQUEUE_READ_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueReadBuffer) 853 #define __ENQUEUE_READ_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueReadBufferRect) 854 #define __ENQUEUE_WRITE_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueWriteBuffer) 855 #define __ENQUEUE_WRITE_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueWriteBufferRect) 856 #define __ENQEUE_COPY_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueCopyBuffer) 857 #define __ENQEUE_COPY_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueCopyBufferRect) 858 #define __ENQUEUE_FILL_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueFillBuffer) 859 #define __ENQUEUE_READ_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueReadImage) 860 #define __ENQUEUE_WRITE_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueWriteImage) 861 #define __ENQUEUE_COPY_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueCopyImage) 862 #define __ENQUEUE_FILL_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueFillImage) 863 #define __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueCopyImageToBuffer) 864 #define __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueCopyBufferToImage) 865 #define __ENQUEUE_MAP_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueMapBuffer) 866 #define __ENQUEUE_MAP_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueMapImage) 867 #define __ENQUEUE_UNMAP_MEM_OBJECT_ERR CL_HPP_ERR_STR_(clEnqueueUnMapMemObject) 868 #define __ENQUEUE_NDRANGE_KERNEL_ERR CL_HPP_ERR_STR_(clEnqueueNDRangeKernel) 869 #define __ENQUEUE_NATIVE_KERNEL CL_HPP_ERR_STR_(clEnqueueNativeKernel) 870 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 871 #define __ENQUEUE_MIGRATE_MEM_OBJECTS_ERR CL_HPP_ERR_STR_(clEnqueueMigrateMemObjects) 872 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 874 #define __ENQUEUE_ACQUIRE_GL_ERR CL_HPP_ERR_STR_(clEnqueueAcquireGLObjects) 875 #define __ENQUEUE_RELEASE_GL_ERR CL_HPP_ERR_STR_(clEnqueueReleaseGLObjects) 877 #define __CREATE_PIPE_ERR CL_HPP_ERR_STR_(clCreatePipe) 878 #define __GET_PIPE_INFO_ERR CL_HPP_ERR_STR_(clGetPipeInfo) 881 #define __RETAIN_ERR CL_HPP_ERR_STR_(Retain Object) 882 #define __RELEASE_ERR CL_HPP_ERR_STR_(Release Object) 883 #define __FLUSH_ERR CL_HPP_ERR_STR_(clFlush) 884 #define __FINISH_ERR CL_HPP_ERR_STR_(clFinish) 885 #define __VECTOR_CAPACITY_ERR CL_HPP_ERR_STR_(Vector capacity error) 890 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 891 #define __CREATE_SUB_DEVICES_ERR CL_HPP_ERR_STR_(clCreateSubDevices) 893 #define __CREATE_SUB_DEVICES_ERR CL_HPP_ERR_STR_(clCreateSubDevicesEXT) 894 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 899 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 900 #define __ENQUEUE_MARKER_ERR CL_HPP_ERR_STR_(clEnqueueMarker) 901 #define __ENQUEUE_WAIT_FOR_EVENTS_ERR CL_HPP_ERR_STR_(clEnqueueWaitForEvents) 902 #define __ENQUEUE_BARRIER_ERR CL_HPP_ERR_STR_(clEnqueueBarrier) 903 #define __UNLOAD_COMPILER_ERR CL_HPP_ERR_STR_(clUnloadCompiler) 904 #define __CREATE_GL_TEXTURE_2D_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture2D) 905 #define __CREATE_GL_TEXTURE_3D_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture3D) 906 #define __CREATE_IMAGE2D_ERR CL_HPP_ERR_STR_(clCreateImage2D) 907 #define __CREATE_IMAGE3D_ERR CL_HPP_ERR_STR_(clCreateImage3D) 908 #endif // #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 913 #if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS) 914 #define __CREATE_COMMAND_QUEUE_ERR CL_HPP_ERR_STR_(clCreateCommandQueue) 915 #define __ENQUEUE_TASK_ERR CL_HPP_ERR_STR_(clEnqueueTask) 916 #define __CREATE_SAMPLER_ERR CL_HPP_ERR_STR_(clCreateSampler) 917 #endif // #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 922 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 923 #define __ENQUEUE_MARKER_WAIT_LIST_ERR CL_HPP_ERR_STR_(clEnqueueMarkerWithWaitList) 924 #define __ENQUEUE_BARRIER_WAIT_LIST_ERR CL_HPP_ERR_STR_(clEnqueueBarrierWithWaitList) 925 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 927 #endif // CL_HPP_USER_OVERRIDE_ERROR_STRINGS 937 template<
typename Functor,
typename T>
938 inline cl_int getInfoHelper(Functor f, cl_uint name, T* param,
long)
940 return f(name,
sizeof(T), param, NULL);
945 template <
typename Func>
946 inline cl_int getInfoHelper(Func f, cl_uint name, vector<vector<unsigned char>>* param,
int)
948 if (name != CL_PROGRAM_BINARIES) {
949 return CL_INVALID_VALUE;
953 size_type numBinaries = param->size();
954 vector<unsigned char*> binariesPointers(numBinaries);
956 for (size_type i = 0; i < numBinaries; ++i)
958 binariesPointers[i] = (*param)[i].data();
961 cl_int err = f(name, numBinaries *
sizeof(
unsigned char*), binariesPointers.data(), NULL);
963 if (err != CL_SUCCESS) {
973 template <
typename Func,
typename T>
974 inline cl_int getInfoHelper(Func f, cl_uint name, vector<T>* param,
long)
977 cl_int err = f(name, 0, NULL, &required);
978 if (err != CL_SUCCESS) {
981 const size_type elements = required /
sizeof(T);
984 vector<T> localData(elements);
985 err = f(name, required, localData.data(), NULL);
986 if (err != CL_SUCCESS) {
990 *param = std::move(localData);
1002 template <
typename Func,
typename T>
1003 inline cl_int getInfoHelper(
1004 Func f, cl_uint name, vector<T>* param,
int,
typename T::cl_type = 0)
1007 cl_int err = f(name, 0, NULL, &required);
1008 if (err != CL_SUCCESS) {
1012 const size_type elements = required /
sizeof(
typename T::cl_type);
1014 vector<typename T::cl_type> value(elements);
1015 err = f(name, required, value.data(), NULL);
1016 if (err != CL_SUCCESS) {
1022 param->resize(elements);
1026 for (size_type i = 0; i < elements; i++) {
1027 (*param)[i] = T(value[i],
true);
1034 template <
typename Func>
1035 inline cl_int getInfoHelper(Func f, cl_uint name,
string* param,
long)
1038 cl_int err = f(name, 0, NULL, &required);
1039 if (err != CL_SUCCESS) {
1046 vector<char> value(required);
1047 err = f(name, required, value.data(), NULL);
1048 if (err != CL_SUCCESS) {
1052 param->assign(begin(value), prev(end(value)));
1062 template <
typename Func,
size_type N>
1063 inline cl_int getInfoHelper(Func f, cl_uint name, array<size_type, N>* param,
long)
1066 cl_int err = f(name, 0, NULL, &required);
1067 if (err != CL_SUCCESS) {
1071 size_type elements = required /
sizeof(size_type);
1072 vector<size_type> value(elements, 0);
1074 err = f(name, required, value.data(), NULL);
1075 if (err != CL_SUCCESS) {
1084 for (size_type i = 0; i < elements; ++i) {
1085 (*param)[i] = value[i];
1099 template<
typename Func,
typename T>
1100 inline cl_int getInfoHelper(Func f, cl_uint name, T* param,
int,
typename T::cl_type = 0)
1102 typename T::cl_type value;
1103 cl_int err = f(name,
sizeof(value), &value, NULL);
1104 if (err != CL_SUCCESS) {
1110 err = param->retain();
1111 if (err != CL_SUCCESS) {
1118 #define CL_HPP_PARAM_NAME_INFO_1_0_(F) \ 1119 F(cl_platform_info, CL_PLATFORM_PROFILE, string) \ 1120 F(cl_platform_info, CL_PLATFORM_VERSION, string) \ 1121 F(cl_platform_info, CL_PLATFORM_NAME, string) \ 1122 F(cl_platform_info, CL_PLATFORM_VENDOR, string) \ 1123 F(cl_platform_info, CL_PLATFORM_EXTENSIONS, string) \ 1125 F(cl_device_info, CL_DEVICE_TYPE, cl_device_type) \ 1126 F(cl_device_info, CL_DEVICE_VENDOR_ID, cl_uint) \ 1127 F(cl_device_info, CL_DEVICE_MAX_COMPUTE_UNITS, cl_uint) \ 1128 F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, cl_uint) \ 1129 F(cl_device_info, CL_DEVICE_MAX_WORK_GROUP_SIZE, size_type) \ 1130 F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_SIZES, cl::vector<size_type>) \ 1131 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, cl_uint) \ 1132 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT, cl_uint) \ 1133 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT, cl_uint) \ 1134 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG, cl_uint) \ 1135 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT, cl_uint) \ 1136 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, cl_uint) \ 1137 F(cl_device_info, CL_DEVICE_MAX_CLOCK_FREQUENCY, cl_uint) \ 1138 F(cl_device_info, CL_DEVICE_ADDRESS_BITS, cl_uint) \ 1139 F(cl_device_info, CL_DEVICE_MAX_READ_IMAGE_ARGS, cl_uint) \ 1140 F(cl_device_info, CL_DEVICE_MAX_WRITE_IMAGE_ARGS, cl_uint) \ 1141 F(cl_device_info, CL_DEVICE_MAX_MEM_ALLOC_SIZE, cl_ulong) \ 1142 F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_WIDTH, size_type) \ 1143 F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_HEIGHT, size_type) \ 1144 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_WIDTH, size_type) \ 1145 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_HEIGHT, size_type) \ 1146 F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_DEPTH, size_type) \ 1147 F(cl_device_info, CL_DEVICE_IMAGE_SUPPORT, cl_bool) \ 1148 F(cl_device_info, CL_DEVICE_MAX_PARAMETER_SIZE, size_type) \ 1149 F(cl_device_info, CL_DEVICE_MAX_SAMPLERS, cl_uint) \ 1150 F(cl_device_info, CL_DEVICE_MEM_BASE_ADDR_ALIGN, cl_uint) \ 1151 F(cl_device_info, CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE, cl_uint) \ 1152 F(cl_device_info, CL_DEVICE_SINGLE_FP_CONFIG, cl_device_fp_config) \ 1153 F(cl_device_info, CL_DEVICE_DOUBLE_FP_CONFIG, cl_device_fp_config) \ 1154 F(cl_device_info, CL_DEVICE_HALF_FP_CONFIG, cl_device_fp_config) \ 1155 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_TYPE, cl_device_mem_cache_type) \ 1156 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE, cl_uint)\ 1157 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_SIZE, cl_ulong) \ 1158 F(cl_device_info, CL_DEVICE_GLOBAL_MEM_SIZE, cl_ulong) \ 1159 F(cl_device_info, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE, cl_ulong) \ 1160 F(cl_device_info, CL_DEVICE_MAX_CONSTANT_ARGS, cl_uint) \ 1161 F(cl_device_info, CL_DEVICE_LOCAL_MEM_TYPE, cl_device_local_mem_type) \ 1162 F(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE, cl_ulong) \ 1163 F(cl_device_info, CL_DEVICE_ERROR_CORRECTION_SUPPORT, cl_bool) \ 1164 F(cl_device_info, CL_DEVICE_PROFILING_TIMER_RESOLUTION, size_type) \ 1165 F(cl_device_info, CL_DEVICE_ENDIAN_LITTLE, cl_bool) \ 1166 F(cl_device_info, CL_DEVICE_AVAILABLE, cl_bool) \ 1167 F(cl_device_info, CL_DEVICE_COMPILER_AVAILABLE, cl_bool) \ 1168 F(cl_device_info, CL_DEVICE_EXECUTION_CAPABILITIES, cl_device_exec_capabilities) \ 1169 F(cl_device_info, CL_DEVICE_PLATFORM, cl_platform_id) \ 1170 F(cl_device_info, CL_DEVICE_NAME, string) \ 1171 F(cl_device_info, CL_DEVICE_VENDOR, string) \ 1172 F(cl_device_info, CL_DRIVER_VERSION, string) \ 1173 F(cl_device_info, CL_DEVICE_PROFILE, string) \ 1174 F(cl_device_info, CL_DEVICE_VERSION, string) \ 1175 F(cl_device_info, CL_DEVICE_EXTENSIONS, string) \ 1177 F(cl_context_info, CL_CONTEXT_REFERENCE_COUNT, cl_uint) \ 1178 F(cl_context_info, CL_CONTEXT_DEVICES, cl::vector<Device>) \ 1179 F(cl_context_info, CL_CONTEXT_PROPERTIES, cl::vector<cl_context_properties>) \ 1181 F(cl_event_info, CL_EVENT_COMMAND_QUEUE, cl::CommandQueue) \ 1182 F(cl_event_info, CL_EVENT_COMMAND_TYPE, cl_command_type) \ 1183 F(cl_event_info, CL_EVENT_REFERENCE_COUNT, cl_uint) \ 1184 F(cl_event_info, CL_EVENT_COMMAND_EXECUTION_STATUS, cl_int) \ 1186 F(cl_profiling_info, CL_PROFILING_COMMAND_QUEUED, cl_ulong) \ 1187 F(cl_profiling_info, CL_PROFILING_COMMAND_SUBMIT, cl_ulong) \ 1188 F(cl_profiling_info, CL_PROFILING_COMMAND_START, cl_ulong) \ 1189 F(cl_profiling_info, CL_PROFILING_COMMAND_END, cl_ulong) \ 1191 F(cl_mem_info, CL_MEM_TYPE, cl_mem_object_type) \ 1192 F(cl_mem_info, CL_MEM_FLAGS, cl_mem_flags) \ 1193 F(cl_mem_info, CL_MEM_SIZE, size_type) \ 1194 F(cl_mem_info, CL_MEM_HOST_PTR, void*) \ 1195 F(cl_mem_info, CL_MEM_MAP_COUNT, cl_uint) \ 1196 F(cl_mem_info, CL_MEM_REFERENCE_COUNT, cl_uint) \ 1197 F(cl_mem_info, CL_MEM_CONTEXT, cl::Context) \ 1199 F(cl_image_info, CL_IMAGE_FORMAT, cl_image_format) \ 1200 F(cl_image_info, CL_IMAGE_ELEMENT_SIZE, size_type) \ 1201 F(cl_image_info, CL_IMAGE_ROW_PITCH, size_type) \ 1202 F(cl_image_info, CL_IMAGE_SLICE_PITCH, size_type) \ 1203 F(cl_image_info, CL_IMAGE_WIDTH, size_type) \ 1204 F(cl_image_info, CL_IMAGE_HEIGHT, size_type) \ 1205 F(cl_image_info, CL_IMAGE_DEPTH, size_type) \ 1207 F(cl_sampler_info, CL_SAMPLER_REFERENCE_COUNT, cl_uint) \ 1208 F(cl_sampler_info, CL_SAMPLER_CONTEXT, cl::Context) \ 1209 F(cl_sampler_info, CL_SAMPLER_NORMALIZED_COORDS, cl_bool) \ 1210 F(cl_sampler_info, CL_SAMPLER_ADDRESSING_MODE, cl_addressing_mode) \ 1211 F(cl_sampler_info, CL_SAMPLER_FILTER_MODE, cl_filter_mode) \ 1213 F(cl_program_info, CL_PROGRAM_REFERENCE_COUNT, cl_uint) \ 1214 F(cl_program_info, CL_PROGRAM_CONTEXT, cl::Context) \ 1215 F(cl_program_info, CL_PROGRAM_NUM_DEVICES, cl_uint) \ 1216 F(cl_program_info, CL_PROGRAM_DEVICES, cl::vector<Device>) \ 1217 F(cl_program_info, CL_PROGRAM_SOURCE, string) \ 1218 F(cl_program_info, CL_PROGRAM_BINARY_SIZES, cl::vector<size_type>) \ 1219 F(cl_program_info, CL_PROGRAM_BINARIES, cl::vector<cl::vector<unsigned char>>) \ 1221 F(cl_program_build_info, CL_PROGRAM_BUILD_STATUS, cl_build_status) \ 1222 F(cl_program_build_info, CL_PROGRAM_BUILD_OPTIONS, string) \ 1223 F(cl_program_build_info, CL_PROGRAM_BUILD_LOG, string) \ 1225 F(cl_kernel_info, CL_KERNEL_FUNCTION_NAME, string) \ 1226 F(cl_kernel_info, CL_KERNEL_NUM_ARGS, cl_uint) \ 1227 F(cl_kernel_info, CL_KERNEL_REFERENCE_COUNT, cl_uint) \ 1228 F(cl_kernel_info, CL_KERNEL_CONTEXT, cl::Context) \ 1229 F(cl_kernel_info, CL_KERNEL_PROGRAM, cl::Program) \ 1231 F(cl_kernel_work_group_info, CL_KERNEL_WORK_GROUP_SIZE, size_type) \ 1232 F(cl_kernel_work_group_info, CL_KERNEL_COMPILE_WORK_GROUP_SIZE, cl::detail::size_t_array) \ 1233 F(cl_kernel_work_group_info, CL_KERNEL_LOCAL_MEM_SIZE, cl_ulong) \ 1235 F(cl_command_queue_info, CL_QUEUE_CONTEXT, cl::Context) \ 1236 F(cl_command_queue_info, CL_QUEUE_DEVICE, cl::Device) \ 1237 F(cl_command_queue_info, CL_QUEUE_REFERENCE_COUNT, cl_uint) \ 1238 F(cl_command_queue_info, CL_QUEUE_PROPERTIES, cl_command_queue_properties) 1241 #define CL_HPP_PARAM_NAME_INFO_1_1_(F) \ 1242 F(cl_context_info, CL_CONTEXT_NUM_DEVICES, cl_uint)\ 1243 F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF, cl_uint) \ 1244 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR, cl_uint) \ 1245 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT, cl_uint) \ 1246 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_INT, cl_uint) \ 1247 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG, cl_uint) \ 1248 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT, cl_uint) \ 1249 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE, cl_uint) \ 1250 F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF, cl_uint) \ 1251 F(cl_device_info, CL_DEVICE_OPENCL_C_VERSION, string) \ 1253 F(cl_mem_info, CL_MEM_ASSOCIATED_MEMOBJECT, cl::Memory) \ 1254 F(cl_mem_info, CL_MEM_OFFSET, size_type) \ 1256 F(cl_kernel_work_group_info, CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, size_type) \ 1257 F(cl_kernel_work_group_info, CL_KERNEL_PRIVATE_MEM_SIZE, cl_ulong) \ 1259 F(cl_event_info, CL_EVENT_CONTEXT, cl::Context) 1261 #define CL_HPP_PARAM_NAME_INFO_1_2_(F) \ 1262 F(cl_program_info, CL_PROGRAM_NUM_KERNELS, size_type) \ 1263 F(cl_program_info, CL_PROGRAM_KERNEL_NAMES, string) \ 1265 F(cl_program_build_info, CL_PROGRAM_BINARY_TYPE, cl_program_binary_type) \ 1267 F(cl_kernel_info, CL_KERNEL_ATTRIBUTES, string) \ 1269 F(cl_kernel_arg_info, CL_KERNEL_ARG_ADDRESS_QUALIFIER, cl_kernel_arg_address_qualifier) \ 1270 F(cl_kernel_arg_info, CL_KERNEL_ARG_ACCESS_QUALIFIER, cl_kernel_arg_access_qualifier) \ 1271 F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_NAME, string) \ 1272 F(cl_kernel_arg_info, CL_KERNEL_ARG_NAME, string) \ 1273 F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_QUALIFIER, cl_kernel_arg_type_qualifier) \ 1275 F(cl_device_info, CL_DEVICE_PARENT_DEVICE, cl::Device) \ 1276 F(cl_device_info, CL_DEVICE_PARTITION_PROPERTIES, cl::vector<cl_device_partition_property>) \ 1277 F(cl_device_info, CL_DEVICE_PARTITION_TYPE, cl::vector<cl_device_partition_property>) \ 1278 F(cl_device_info, CL_DEVICE_REFERENCE_COUNT, cl_uint) \ 1279 F(cl_device_info, CL_DEVICE_PREFERRED_INTEROP_USER_SYNC, size_type) \ 1280 F(cl_device_info, CL_DEVICE_PARTITION_AFFINITY_DOMAIN, cl_device_affinity_domain) \ 1281 F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS, string) \ 1283 F(cl_image_info, CL_IMAGE_ARRAY_SIZE, size_type) \ 1284 F(cl_image_info, CL_IMAGE_NUM_MIP_LEVELS, cl_uint) \ 1285 F(cl_image_info, CL_IMAGE_NUM_SAMPLES, cl_uint) 1287 #define CL_HPP_PARAM_NAME_INFO_2_0_(F) \ 1288 F(cl_device_info, CL_DEVICE_QUEUE_ON_HOST_PROPERTIES, cl_command_queue_properties) \ 1289 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES, cl_command_queue_properties) \ 1290 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE, cl_uint) \ 1291 F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE, cl_uint) \ 1292 F(cl_device_info, CL_DEVICE_MAX_ON_DEVICE_QUEUES, cl_uint) \ 1293 F(cl_device_info, CL_DEVICE_MAX_ON_DEVICE_EVENTS, cl_uint) \ 1294 F(cl_device_info, CL_DEVICE_MAX_PIPE_ARGS, cl_uint) \ 1295 F(cl_device_info, CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS, cl_uint) \ 1296 F(cl_device_info, CL_DEVICE_PIPE_MAX_PACKET_SIZE, cl_uint) \ 1297 F(cl_device_info, CL_DEVICE_SVM_CAPABILITIES, cl_device_svm_capabilities) \ 1298 F(cl_device_info, CL_DEVICE_PREFERRED_PLATFORM_ATOMIC_ALIGNMENT, cl_uint) \ 1299 F(cl_device_info, CL_DEVICE_PREFERRED_GLOBAL_ATOMIC_ALIGNMENT, cl_uint) \ 1300 F(cl_device_info, CL_DEVICE_PREFERRED_LOCAL_ATOMIC_ALIGNMENT, cl_uint) \ 1301 F(cl_command_queue_info, CL_QUEUE_SIZE, cl_uint) \ 1302 F(cl_mem_info, CL_MEM_USES_SVM_POINTER, cl_bool) \ 1303 F(cl_program_build_info, CL_PROGRAM_BUILD_GLOBAL_VARIABLE_TOTAL_SIZE, size_type) \ 1304 F(cl_pipe_info, CL_PIPE_PACKET_SIZE, cl_uint) \ 1305 F(cl_pipe_info, CL_PIPE_MAX_PACKETS, cl_uint) 1307 #define CL_HPP_PARAM_NAME_DEVICE_FISSION_(F) \ 1308 F(cl_device_info, CL_DEVICE_PARENT_DEVICE_EXT, cl_device_id) \ 1309 F(cl_device_info, CL_DEVICE_PARTITION_TYPES_EXT, cl::vector<cl_device_partition_property_ext>) \ 1310 F(cl_device_info, CL_DEVICE_AFFINITY_DOMAINS_EXT, cl::vector<cl_device_partition_property_ext>) \ 1311 F(cl_device_info, CL_DEVICE_REFERENCE_COUNT_EXT , cl_uint) \ 1312 F(cl_device_info, CL_DEVICE_PARTITION_STYLE_EXT, cl::vector<cl_device_partition_property_ext>) 1314 template <
typename enum_type, cl_
int Name>
1317 #define CL_HPP_DECLARE_PARAM_TRAITS_(token, param_name, T) \ 1320 struct param_traits<detail:: token,param_name> \ 1322 enum { value = param_name }; \ 1323 typedef T param_type; \ 1326 CL_HPP_PARAM_NAME_INFO_1_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1327 #if CL_HPP_TARGET_OPENCL_VERSION >= 110 1328 CL_HPP_PARAM_NAME_INFO_1_1_(CL_HPP_DECLARE_PARAM_TRAITS_)
1329 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110 1330 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 1331 CL_HPP_PARAM_NAME_INFO_1_2_(CL_HPP_DECLARE_PARAM_TRAITS_)
1332 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110 1333 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 1334 CL_HPP_PARAM_NAME_INFO_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1335 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110 1339 #define CL_HPP_PARAM_NAME_INFO_1_0_DEPRECATED_IN_2_0_(F) \ 1340 F(cl_device_info, CL_DEVICE_QUEUE_PROPERTIES, cl_command_queue_properties) 1342 #define CL_HPP_PARAM_NAME_INFO_1_1_DEPRECATED_IN_2_0_(F) \ 1343 F(cl_device_info, CL_DEVICE_HOST_UNIFIED_MEMORY, cl_bool) 1345 #define CL_HPP_PARAM_NAME_INFO_1_2_DEPRECATED_IN_2_0_(F) \ 1346 F(cl_image_info, CL_IMAGE_BUFFER, cl::Buffer) 1350 #if CL_HPP_TARGET_OPENCL_VERSION > 100 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 && CL_HPP_TARGET_OPENCL_VERSION < 200 1351 CL_HPP_PARAM_NAME_INFO_1_0_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1352 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 110 1353 #if CL_HPP_TARGET_OPENCL_VERSION > 110 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 1354 CL_HPP_PARAM_NAME_INFO_1_1_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1355 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 120 1356 #if CL_HPP_TARGET_OPENCL_VERSION > 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 1357 CL_HPP_PARAM_NAME_INFO_1_2_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
1358 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 200 1360 #if defined(CL_HPP_USE_CL_DEVICE_FISSION) 1361 CL_HPP_PARAM_NAME_DEVICE_FISSION_(CL_HPP_DECLARE_PARAM_TRAITS_);
1362 #endif // CL_HPP_USE_CL_DEVICE_FISSION 1364 #ifdef CL_PLATFORM_ICD_SUFFIX_KHR 1365 CL_HPP_DECLARE_PARAM_TRAITS_(cl_platform_info, CL_PLATFORM_ICD_SUFFIX_KHR,
string)
1368 #ifdef CL_DEVICE_PROFILING_TIMER_OFFSET_AMD 1369 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_PROFILING_TIMER_OFFSET_AMD, cl_ulong)
1372 #ifdef CL_DEVICE_GLOBAL_FREE_MEMORY_AMD 1373 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_FREE_MEMORY_AMD, vector<size_type>)
1375 #ifdef CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD 1376 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD, cl_uint)
1378 #ifdef CL_DEVICE_SIMD_WIDTH_AMD 1379 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_WIDTH_AMD, cl_uint)
1381 #ifdef CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD 1382 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD, cl_uint)
1384 #ifdef CL_DEVICE_WAVEFRONT_WIDTH_AMD 1385 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_WAVEFRONT_WIDTH_AMD, cl_uint)
1387 #ifdef CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD 1388 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD, cl_uint)
1390 #ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD 1391 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD, cl_uint)
1393 #ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD 1394 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD, cl_uint)
1396 #ifdef CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD 1397 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD, cl_uint)
1399 #ifdef CL_DEVICE_LOCAL_MEM_BANKS_AMD 1400 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LOCAL_MEM_BANKS_AMD, cl_uint)
1403 #ifdef CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV 1404 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV, cl_uint)
1406 #ifdef CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV 1407 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV, cl_uint)
1409 #ifdef CL_DEVICE_REGISTERS_PER_BLOCK_NV 1410 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_REGISTERS_PER_BLOCK_NV, cl_uint)
1412 #ifdef CL_DEVICE_WARP_SIZE_NV 1413 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_WARP_SIZE_NV, cl_uint)
1415 #ifdef CL_DEVICE_GPU_OVERLAP_NV 1416 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GPU_OVERLAP_NV, cl_bool)
1418 #ifdef CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV 1419 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV, cl_bool)
1421 #ifdef CL_DEVICE_INTEGRATED_MEMORY_NV 1422 CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGRATED_MEMORY_NV, cl_bool)
1427 template <
typename Func,
typename T>
1429 getInfo(Func f, cl_uint name, T* param)
1431 return getInfoHelper(f, name, param, 0);
1434 template <
typename Func,
typename Arg0>
1437 Func f_;
const Arg0& arg0_;
1439 cl_uint param, size_type size,
void* value, size_type* size_ret)
1440 {
return f_(arg0_, param, size, value, size_ret); }
1443 template <
typename Func,
typename Arg0,
typename Arg1>
1446 Func f_;
const Arg0& arg0_;
const Arg1& arg1_;
1448 cl_uint param, size_type size,
void* value, size_type* size_ret)
1449 {
return f_(arg0_, arg1_, param, size, value, size_ret); }
1452 template <
typename Func,
typename Arg0,
typename T>
1454 getInfo(Func f,
const Arg0& arg0, cl_uint name, T* param)
1457 return getInfoHelper(f0, name, param, 0);
1460 template <
typename Func,
typename Arg0,
typename Arg1,
typename T>
1462 getInfo(Func f,
const Arg0& arg0,
const Arg1& arg1, cl_uint name, T* param)
1465 return getInfoHelper(f0, name, param, 0);
1469 template<
typename T>
1473 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 1490 { return ::clRetainDevice(device); }
1501 { return ::clReleaseDevice(device); }
1503 #else // CL_HPP_TARGET_OPENCL_VERSION >= 120 1511 static cl_int retain(cl_device_id)
1512 {
return CL_SUCCESS; }
1514 static cl_int release(cl_device_id)
1515 {
return CL_SUCCESS; }
1517 #endif // ! (CL_HPP_TARGET_OPENCL_VERSION >= 120) 1523 static cl_int retain(cl_platform_id)
1524 {
return CL_SUCCESS; }
1526 static cl_int release(cl_platform_id)
1527 {
return CL_SUCCESS; }
1533 static cl_int retain(cl_context context)
1534 { return ::clRetainContext(context); }
1535 static cl_int release(cl_context context)
1536 { return ::clReleaseContext(context); }
1542 static cl_int retain(cl_command_queue queue)
1543 { return ::clRetainCommandQueue(queue); }
1544 static cl_int release(cl_command_queue queue)
1545 { return ::clReleaseCommandQueue(queue); }
1551 static cl_int retain(cl_mem memory)
1552 { return ::clRetainMemObject(memory); }
1553 static cl_int release(cl_mem memory)
1554 { return ::clReleaseMemObject(memory); }
1560 static cl_int retain(cl_sampler sampler)
1561 { return ::clRetainSampler(sampler); }
1562 static cl_int release(cl_sampler sampler)
1563 { return ::clReleaseSampler(sampler); }
1569 static cl_int retain(cl_program program)
1570 { return ::clRetainProgram(program); }
1571 static cl_int release(cl_program program)
1572 { return ::clReleaseProgram(program); }
1578 static cl_int retain(cl_kernel kernel)
1579 { return ::clRetainKernel(kernel); }
1580 static cl_int release(cl_kernel kernel)
1581 { return ::clReleaseKernel(kernel); }
1587 static cl_int retain(cl_event event)
1588 { return ::clRetainEvent(event); }
1589 static cl_int release(cl_event event)
1590 { return ::clReleaseEvent(event); }
1594 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120 1596 static cl_uint getVersion(
const vector<char> &versionInfo)
1598 int highVersion = 0;
1601 while(versionInfo[index] !=
'.' ) {
1603 highVersion += versionInfo[index]-
'0';
1607 while(versionInfo[index] !=
' ' && versionInfo[index] !=
'\0') {
1609 lowVersion += versionInfo[index]-
'0';
1612 return (highVersion << 16) | lowVersion;
1615 static cl_uint getPlatformVersion(cl_platform_id platform)
1618 clGetPlatformInfo(platform, CL_PLATFORM_VERSION, 0, NULL, &size);
1620 vector<char> versionInfo(size);
1621 clGetPlatformInfo(platform, CL_PLATFORM_VERSION, size, versionInfo.data(), &size);
1622 return getVersion(versionInfo);
1625 static cl_uint getDevicePlatformVersion(cl_device_id device)
1627 cl_platform_id platform;
1628 clGetDeviceInfo(device, CL_DEVICE_PLATFORM,
sizeof(platform), &platform, NULL);
1629 return getPlatformVersion(platform);
1632 static cl_uint getContextPlatformVersion(cl_context context)
1637 clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, NULL, &size);
1640 vector<cl_device_id> devices(size/
sizeof(cl_device_id));
1641 clGetContextInfo(context, CL_CONTEXT_DEVICES, size, devices.data(), NULL);
1642 return getDevicePlatformVersion(devices[0]);
1644 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120 1646 template <
typename T>
1658 Wrapper(
const cl_type &obj,
bool retainObject) : object_(obj)
1661 detail::errHandler(retain(), __RETAIN_ERR);
1667 if (object_ != NULL) { release(); }
1672 object_ = rhs.object_;
1673 detail::errHandler(retain(), __RETAIN_ERR);
1678 object_ = rhs.object_;
1685 detail::errHandler(release(), __RELEASE_ERR);
1686 object_ = rhs.object_;
1687 detail::errHandler(retain(), __RETAIN_ERR);
1695 detail::errHandler(release(), __RELEASE_ERR);
1696 object_ = rhs.object_;
1704 detail::errHandler(release(), __RELEASE_ERR);
1709 const cl_type& operator ()()
const {
return object_; }
1711 cl_type& operator ()() {
return object_; }
1713 const cl_type
get()
const {
return object_; }
1715 cl_type
get() {
return object_; }
1719 template<
typename Func,
typename U>
1720 friend inline cl_int getInfoHelper(Func, cl_uint, U*,
int,
typename U::cl_type);
1722 cl_int retain()
const 1724 if (object_ !=
nullptr) {
1732 cl_int release()
const 1734 if (object_ !=
nullptr) {
1747 typedef cl_device_id cl_type;
1751 bool referenceCountable_;
1753 static bool isReferenceCountable(cl_device_id device)
1755 bool retVal =
false;
1756 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 1757 #if CL_HPP_MINIMUM_OPENCL_VERSION < 120 1758 if (device != NULL) {
1759 int version = getDevicePlatformVersion(device);
1760 if(version > ((1 << 16) + 1)) {
1764 #else // CL_HPP_MINIMUM_OPENCL_VERSION < 120 1766 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 120 1767 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 1772 Wrapper() : object_(NULL), referenceCountable_(
false)
1776 Wrapper(
const cl_type &obj,
bool retainObject) :
1778 referenceCountable_(
false)
1780 referenceCountable_ = isReferenceCountable(obj);
1783 detail::errHandler(retain(), __RETAIN_ERR);
1794 object_ = rhs.object_;
1795 referenceCountable_ = isReferenceCountable(object_);
1796 detail::errHandler(retain(), __RETAIN_ERR);
1801 object_ = rhs.object_;
1802 referenceCountable_ = rhs.referenceCountable_;
1804 rhs.referenceCountable_ =
false;
1810 detail::errHandler(release(), __RELEASE_ERR);
1811 object_ = rhs.object_;
1812 referenceCountable_ = rhs.referenceCountable_;
1813 detail::errHandler(retain(), __RETAIN_ERR);
1821 detail::errHandler(release(), __RELEASE_ERR);
1822 object_ = rhs.object_;
1823 referenceCountable_ = rhs.referenceCountable_;
1825 rhs.referenceCountable_ =
false;
1832 detail::errHandler(release(), __RELEASE_ERR);
1834 referenceCountable_ = isReferenceCountable(object_);
1838 const cl_type& operator ()()
const {
return object_; }
1840 cl_type& operator ()() {
return object_; }
1842 cl_type
get()
const {
return object_; }
1845 template<
typename Func,
typename U>
1846 friend inline cl_int getInfoHelper(Func, cl_uint, U*,
int,
typename U::cl_type);
1848 template<
typename Func,
typename U>
1849 friend inline cl_int getInfoHelper(Func, cl_uint, vector<U>*,
int,
typename U::cl_type);
1851 cl_int retain()
const 1853 if( object_ !=
nullptr && referenceCountable_ ) {
1861 cl_int release()
const 1863 if (object_ !=
nullptr && referenceCountable_) {
1872 template <
typename T>
1875 return lhs() == rhs();
1878 template <
typename T>
1881 return !operator==(lhs, rhs);
1888 using BuildLogType = vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, CL_PROGRAM_BUILD_LOG>::param_type>>;
1889 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 1893 class BuildError :
public Error
1896 BuildLogType buildLogs;
1898 BuildError(cl_int err,
const char * errStr,
const BuildLogType &vec) : Error(err, errStr), buildLogs(vec)
1902 BuildLogType getBuildLog()
const 1908 static inline cl_int buildErrHandler(
1910 const char * errStr,
1911 const BuildLogType &buildLogs)
1913 if (err != CL_SUCCESS) {
1914 throw BuildError(err, errStr, buildLogs);
1922 static inline cl_int buildErrHandler(
1924 const char * errStr,
1925 const BuildLogType &buildLogs)
1932 #endif // #if defined(CL_HPP_ENABLE_EXCEPTIONS) 1948 image_channel_order = order;
1949 image_channel_data_type = type;
1956 this->image_channel_data_type = rhs.image_channel_data_type;
1957 this->image_channel_order = rhs.image_channel_order;
1973 static std::once_flag default_initialized_;
1975 static cl_int default_error_;
1982 static void makeDefault();
1989 static void makeDefaultProvided(
const Device &p) {
1994 #ifdef CL_HPP_UNIT_TEST_ENABLE 2001 static void unitTestClearDefault() {
2004 #endif // #ifdef CL_HPP_UNIT_TEST_ENABLE 2013 explicit Device(
const cl_device_id &device,
bool retainObject =
false) :
2014 detail::Wrapper<cl_type>(device, retainObject) { }
2021 cl_int *errResult = NULL)
2023 std::call_once(default_initialized_, makeDefault);
2024 detail::errHandler(default_error_);
2025 if (errResult != NULL) {
2026 *errResult = default_error_;
2040 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_device));
2041 detail::errHandler(default_error_);
2084 template <
typename T>
2085 cl_int
getInfo(cl_device_info name, T* param)
const 2087 return detail::errHandler(
2088 detail::getInfo(&::clGetDeviceInfo, object_, name, param),
2089 __GET_DEVICE_INFO_ERR);
2093 template <cl_
int name>
typename 2098 detail::cl_device_info, name>::param_type param;
2099 cl_int result = getInfo(name, ¶m);
2109 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 2110 cl_int createSubDevices(
2112 const cl_device_partition_property * properties,
2113 vector<Device>* devices)
2116 cl_int err = clCreateSubDevices(object_, properties, 0, NULL, &n);
2117 if (err != CL_SUCCESS) {
2118 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2121 vector<cl_device_id> ids(n);
2122 err = clCreateSubDevices(object_, properties, n, ids.data(), NULL);
2123 if (err != CL_SUCCESS) {
2124 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2130 devices->resize(ids.size());
2134 for (size_type i = 0; i < ids.size(); i++) {
2137 (*devices)[i] =
Device(ids[i],
false);
2143 #elif defined(CL_HPP_USE_CL_DEVICE_FISSION) 2148 cl_int createSubDevices(
2149 const cl_device_partition_property_ext * properties,
2150 vector<Device>* devices)
2152 typedef CL_API_ENTRY cl_int
2153 ( CL_API_CALL * PFN_clCreateSubDevicesEXT)(
2155 const cl_device_partition_property_ext * ,
2158 cl_uint * ) CL_EXT_SUFFIX__VERSION_1_1;
2160 static PFN_clCreateSubDevicesEXT pfn_clCreateSubDevicesEXT = NULL;
2161 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateSubDevicesEXT);
2164 cl_int err = pfn_clCreateSubDevicesEXT(object_, properties, 0, NULL, &n);
2165 if (err != CL_SUCCESS) {
2166 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2169 vector<cl_device_id> ids(n);
2170 err = pfn_clCreateSubDevicesEXT(object_, properties, n, ids.data(), NULL);
2171 if (err != CL_SUCCESS) {
2172 return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
2177 devices->resize(ids.size());
2181 for (size_type i = 0; i < ids.size(); i++) {
2184 (*devices)[i] =
Device(ids[i],
false);
2189 #endif // defined(CL_HPP_USE_CL_DEVICE_FISSION) 2192 CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Device::default_initialized_;
2193 CL_HPP_DEFINE_STATIC_MEMBER_
Device Device::default_;
2194 CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Device::default_error_ = CL_SUCCESS;
2206 static std::once_flag default_initialized_;
2208 static cl_int default_error_;
2215 static void makeDefault() {
2219 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 2227 cl_int err = ::clGetPlatformIDs(0, NULL, &n);
2228 if (err != CL_SUCCESS) {
2229 default_error_ = err;
2233 default_error_ = CL_INVALID_PLATFORM;
2237 vector<cl_platform_id> ids(n);
2238 err = ::clGetPlatformIDs(n, ids.data(), NULL);
2239 if (err != CL_SUCCESS) {
2240 default_error_ = err;
2246 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 2247 catch (cl::Error &e) {
2248 default_error_ = e.err();
2258 static void makeDefaultProvided(
const Platform &p) {
2263 #ifdef CL_HPP_UNIT_TEST_ENABLE 2270 static void unitTestClearDefault() {
2273 #endif // #ifdef CL_HPP_UNIT_TEST_ENABLE 2285 explicit Platform(
const cl_platform_id &platform,
bool retainObject =
false) :
2286 detail::Wrapper<cl_type>(platform, retainObject) { }
2299 cl_int *errResult = NULL)
2301 std::call_once(default_initialized_, makeDefault);
2302 detail::errHandler(default_error_);
2303 if (errResult != NULL) {
2304 *errResult = default_error_;
2318 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_platform));
2319 detail::errHandler(default_error_);
2324 cl_int
getInfo(cl_platform_info name,
string* param)
const 2326 return detail::errHandler(
2327 detail::getInfo(&::clGetPlatformInfo, object_, name, param),
2328 __GET_PLATFORM_INFO_ERR);
2332 template <cl_
int name>
typename 2337 detail::cl_platform_info, name>::param_type param;
2338 cl_int result = getInfo(name, ¶m);
2350 cl_device_type type,
2351 vector<Device>* devices)
const 2354 if( devices == NULL ) {
2355 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR);
2357 cl_int err = ::clGetDeviceIDs(object_, type, 0, NULL, &n);
2358 if (err != CL_SUCCESS) {
2359 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2362 vector<cl_device_id> ids(n);
2363 err = ::clGetDeviceIDs(object_, type, n, ids.data(), NULL);
2364 if (err != CL_SUCCESS) {
2365 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2373 devices->resize(ids.size());
2377 for (size_type i = 0; i < ids.size(); i++) {
2378 (*devices)[i] =
Device(ids[i],
true);
2384 #if defined(CL_HPP_USE_DX_INTEROP) 2409 cl_d3d10_device_source_khr d3d_device_source,
2411 cl_d3d10_device_set_khr d3d_device_set,
2412 vector<Device>* devices)
const 2414 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clGetDeviceIDsFromD3D10KHR)(
2415 cl_platform_id platform,
2416 cl_d3d10_device_source_khr d3d_device_source,
2418 cl_d3d10_device_set_khr d3d_device_set,
2419 cl_uint num_entries,
2420 cl_device_id * devices,
2421 cl_uint* num_devices);
2423 if( devices == NULL ) {
2424 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR);
2427 static PFN_clGetDeviceIDsFromD3D10KHR pfn_clGetDeviceIDsFromD3D10KHR = NULL;
2428 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(object_, clGetDeviceIDsFromD3D10KHR);
2431 cl_int err = pfn_clGetDeviceIDsFromD3D10KHR(
2439 if (err != CL_SUCCESS) {
2440 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2443 vector<cl_device_id> ids(n);
2444 err = pfn_clGetDeviceIDsFromD3D10KHR(
2452 if (err != CL_SUCCESS) {
2453 return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
2461 devices->resize(ids.size());
2465 for (size_type i = 0; i < ids.size(); i++) {
2466 (*devices)[i] =
Device(ids[i],
true);
2478 vector<Platform>* platforms)
2482 if( platforms == NULL ) {
2483 return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_PLATFORM_IDS_ERR);
2486 cl_int err = ::clGetPlatformIDs(0, NULL, &n);
2487 if (err != CL_SUCCESS) {
2488 return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
2491 vector<cl_platform_id> ids(n);
2492 err = ::clGetPlatformIDs(n, ids.data(), NULL);
2493 if (err != CL_SUCCESS) {
2494 return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
2498 platforms->resize(ids.size());
2501 for (size_type i = 0; i < ids.size(); i++) {
2502 (*platforms)[i] =
Platform(ids[i]);
2516 Platform default_platform = Platform::getDefault(&err);
2518 *platform = default_platform;
2532 cl_int * errResult = NULL)
2535 Platform default_platform = Platform::getDefault(&err);
2539 return default_platform;
2542 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 2547 return ::clUnloadPlatformCompiler(object_);
2549 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 2552 CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Platform::default_initialized_;
2553 CL_HPP_DEFINE_STATIC_MEMBER_
Platform Platform::default_;
2554 CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Platform::default_error_ = CL_SUCCESS;
2560 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 2565 inline CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_int
2570 return ::clUnloadCompiler();
2572 #endif // #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 2586 static std::once_flag default_initialized_;
2588 static cl_int default_error_;
2595 static void makeDefault() {
2599 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 2603 #if !defined(__APPLE__) && !defined(__MACOS) 2604 const Platform &p = Platform::getDefault();
2605 cl_platform_id defaultPlatform = p();
2606 cl_context_properties properties[3] = {
2607 CL_CONTEXT_PLATFORM, (cl_context_properties)defaultPlatform, 0
2609 #else // #if !defined(__APPLE__) && !defined(__MACOS) 2610 cl_context_properties *properties =
nullptr;
2611 #endif // #if !defined(__APPLE__) && !defined(__MACOS) 2614 CL_DEVICE_TYPE_DEFAULT,
2620 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 2621 catch (cl::Error &e) {
2622 default_error_ = e.err();
2633 static void makeDefaultProvided(
const Context &c) {
2638 #ifdef CL_HPP_UNIT_TEST_ENABLE 2645 static void unitTestClearDefault() {
2648 #endif // #ifdef CL_HPP_UNIT_TEST_ENABLE 2655 const vector<Device>& devices,
2656 cl_context_properties* properties = NULL,
2657 void (CL_CALLBACK * notifyFptr)(
2667 size_type numDevices = devices.size();
2668 vector<cl_device_id> deviceIDs(numDevices);
2670 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
2671 deviceIDs[deviceIndex] = (devices[deviceIndex])();
2674 object_ = ::clCreateContext(
2675 properties, (cl_uint) numDevices,
2677 notifyFptr, data, &error);
2679 detail::errHandler(error, __CREATE_CONTEXT_ERR);
2687 cl_context_properties* properties = NULL,
2688 void (CL_CALLBACK * notifyFptr)(
2698 cl_device_id deviceID = device();
2700 object_ = ::clCreateContext(
2703 notifyFptr, data, &error);
2705 detail::errHandler(error, __CREATE_CONTEXT_ERR);
2716 cl_device_type type,
2717 cl_context_properties* properties = NULL,
2718 void (CL_CALLBACK * notifyFptr)(
2728 #if !defined(__APPLE__) && !defined(__MACOS) 2729 cl_context_properties prop[4] = {CL_CONTEXT_PLATFORM, 0, 0, 0 };
2731 if (properties == NULL) {
2733 vector<Platform> platforms;
2734 error = Platform::get(&platforms);
2735 if (error != CL_SUCCESS) {
2736 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
2744 cl_context_properties platform_id = 0;
2745 for (
unsigned int i = 0; i < platforms.size(); i++) {
2747 vector<Device> devices;
2749 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 2753 error = platforms[i].getDevices(type, &devices);
2755 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 2756 }
catch (cl::Error& e) {
2764 if (error != CL_SUCCESS && error != CL_DEVICE_NOT_FOUND) {
2765 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
2771 if (devices.size() > 0) {
2772 platform_id = (cl_context_properties)platforms[i]();
2777 if (platform_id == 0) {
2778 detail::errHandler(CL_DEVICE_NOT_FOUND, __CREATE_CONTEXT_FROM_TYPE_ERR);
2780 *err = CL_DEVICE_NOT_FOUND;
2785 prop[1] = platform_id;
2786 properties = &prop[0];
2789 object_ = ::clCreateContextFromType(
2790 properties, type, notifyFptr, data, &error);
2792 detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
2833 std::call_once(default_initialized_, makeDefault);
2834 detail::errHandler(default_error_);
2836 *err = default_error_;
2850 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_context));
2851 detail::errHandler(default_error_);
2863 explicit Context(
const cl_context& context,
bool retainObject =
false) :
2864 detail::Wrapper<cl_type>(context, retainObject) { }
2878 template <
typename T>
2879 cl_int
getInfo(cl_context_info name, T* param)
const 2881 return detail::errHandler(
2882 detail::getInfo(&::clGetContextInfo, object_, name, param),
2883 __GET_CONTEXT_INFO_ERR);
2887 template <cl_
int name>
typename 2892 detail::cl_context_info, name>::param_type param;
2893 cl_int result = getInfo(name, ¶m);
2906 cl_mem_object_type type,
2907 vector<ImageFormat>* formats)
const 2915 cl_int err = ::clGetSupportedImageFormats(
2922 if (err != CL_SUCCESS) {
2923 return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
2926 if (numEntries > 0) {
2927 vector<ImageFormat> value(numEntries);
2928 err = ::clGetSupportedImageFormats(
2933 (cl_image_format*)value.data(),
2935 if (err != CL_SUCCESS) {
2936 return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
2939 formats->assign(begin(value), end(value));
2950 inline void Device::makeDefault()
2955 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 2962 detail::errHandler(error, __CREATE_CONTEXT_ERR);
2964 if (error != CL_SUCCESS) {
2965 default_error_ = error;
2968 default_ = context.
getInfo<CL_CONTEXT_DEVICES>()[0];
2969 default_error_ = CL_SUCCESS;
2972 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 2973 catch (cl::Error &e) {
2974 default_error_ = e.err();
2979 CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Context::default_initialized_;
2980 CL_HPP_DEFINE_STATIC_MEMBER_
Context Context::default_;
2981 CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Context::default_error_ = CL_SUCCESS;
2995 Event() : detail::Wrapper<cl_type>() { }
3005 explicit Event(
const cl_event& event,
bool retainObject =
false) :
3006 detail::Wrapper<cl_type>(event, retainObject) { }
3020 template <
typename T>
3021 cl_int
getInfo(cl_event_info name, T* param)
const 3023 return detail::errHandler(
3024 detail::getInfo(&::clGetEventInfo, object_, name, param),
3025 __GET_EVENT_INFO_ERR);
3029 template <cl_
int name>
typename 3034 detail::cl_event_info, name>::param_type param;
3035 cl_int result = getInfo(name, ¶m);
3043 template <
typename T>
3046 return detail::errHandler(detail::getInfo(
3047 &::clGetEventProfilingInfo, object_, name, param),
3048 __GET_EVENT_PROFILE_INFO_ERR);
3052 template <cl_
int name>
typename 3057 detail::cl_profiling_info, name>::param_type param;
3058 cl_int result = getProfilingInfo(name, ¶m);
3071 return detail::errHandler(
3072 ::clWaitForEvents(1, &object_),
3073 __WAIT_FOR_EVENTS_ERR);
3076 #if CL_HPP_TARGET_OPENCL_VERSION >= 110 3083 void (CL_CALLBACK * pfn_notify)(cl_event, cl_int,
void *),
3084 void * user_data = NULL)
3086 return detail::errHandler(
3087 ::clSetEventCallback(
3092 __SET_EVENT_CALLBACK_ERR);
3094 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110 3103 return detail::errHandler(
3105 (cl_uint) events.size(), (events.size() > 0) ? (cl_event*)&events.front() : NULL),
3106 __WAIT_FOR_EVENTS_ERR);
3110 #if CL_HPP_TARGET_OPENCL_VERSION >= 110 3124 cl_int * err = NULL)
3127 object_ = ::clCreateUserEvent(
3131 detail::errHandler(error, __CREATE_USER_EVENT_ERR);
3146 return detail::errHandler(
3147 ::clSetUserEventStatus(object_,status),
3148 __SET_USER_EVENT_STATUS_ERR);
3151 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110 3157 inline static cl_int
3158 WaitForEvents(
const vector<Event>& events)
3160 return detail::errHandler(
3162 (cl_uint) events.size(), (events.size() > 0) ? (cl_event*)&events.front() : NULL),
3163 __WAIT_FOR_EVENTS_ERR);
3191 explicit Memory(
const cl_mem& memory,
bool retainObject) :
3192 detail::Wrapper<cl_type>(memory, retainObject) { }
3235 template <
typename T>
3238 return detail::errHandler(
3239 detail::getInfo(&::clGetMemObjectInfo, object_, name, param),
3240 __GET_MEM_OBJECT_INFO_ERR);
3244 template <cl_
int name>
typename 3249 detail::cl_mem_info, name>::param_type param;
3250 cl_int result = getInfo(name, ¶m);
3257 #if CL_HPP_TARGET_OPENCL_VERSION >= 110 3272 void (CL_CALLBACK * pfn_notify)(cl_mem,
void *),
3273 void * user_data = NULL)
3275 return detail::errHandler(
3276 ::clSetMemObjectDestructorCallback(
3280 __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR);
3282 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110 3288 template<
typename IteratorType >
3289 cl_int
copy( IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer );
3290 template<
typename IteratorType >
3291 cl_int
copy(
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator );
3292 template<
typename IteratorType >
3294 template<
typename IteratorType >
3298 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 3304 static cl_svm_mem_flags getSVMMemFlags()
3311 template<
class Trait = detail::SVMTraitNull>
3315 static cl_svm_mem_flags getSVMMemFlags()
3317 return CL_MEM_READ_WRITE |
3318 Trait::getSVMMemFlags();
3322 template<
class Trait = detail::SVMTraitNull>
3326 static cl_svm_mem_flags getSVMMemFlags()
3328 return CL_MEM_READ_ONLY |
3329 Trait::getSVMMemFlags();
3333 template<
class Trait = detail::SVMTraitNull>
3337 static cl_svm_mem_flags getSVMMemFlags()
3339 return CL_MEM_WRITE_ONLY |
3340 Trait::getSVMMemFlags();
3344 template<
class Trait = SVMTraitReadWrite<>>
3348 static cl_svm_mem_flags getSVMMemFlags()
3350 return Trait::getSVMMemFlags();
3354 template<
class Trait = SVMTraitReadWrite<>>
3358 static cl_svm_mem_flags getSVMMemFlags()
3360 return CL_MEM_SVM_FINE_GRAIN_BUFFER |
3361 Trait::getSVMMemFlags();
3365 template<
class Trait = SVMTraitReadWrite<>>
3369 static cl_svm_mem_flags getSVMMemFlags()
3372 CL_MEM_SVM_FINE_GRAIN_BUFFER |
3373 CL_MEM_SVM_ATOMICS |
3374 Trait::getSVMMemFlags();
3379 template<
typename T>
3385 const vector<Event>* events = NULL,
3386 Event* event = NULL);
3399 template<
typename T,
class SVMTrait>
3405 typedef T value_type;
3406 typedef value_type* pointer;
3407 typedef const value_type* const_pointer;
3408 typedef value_type& reference;
3409 typedef const value_type& const_reference;
3410 typedef std::size_t size_type;
3411 typedef std::ptrdiff_t difference_type;
3413 template<
typename U>
3419 template<
typename U,
typename V>
3434 context_(other.context_)
3438 template<
typename U>
3440 context_(other.context_)
3448 pointer address(reference r) CL_HPP_NOEXCEPT_
3450 return std::addressof(r);
3453 const_pointer address(const_reference r) CL_HPP_NOEXCEPT_
3455 return std::addressof(r);
3472 SVMTrait::getSVMMemFlags(),
3475 pointer retValue =
reinterpret_cast<pointer
>(
3477 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 3479 std::bad_alloc excep;
3482 #endif // #if defined(CL_HPP_ENABLE_EXCEPTIONS) 3485 if (!(SVMTrait::getSVMMemFlags() & CL_MEM_SVM_FINE_GRAIN_BUFFER)) {
3486 cl_int err =
enqueueMapSVM(retValue, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE, size*
sizeof(T));
3487 if (err != CL_SUCCESS) {
3488 std::bad_alloc excep;
3497 void deallocate(pointer p, size_type)
3499 clSVMFree(context_(), p);
3508 size_type maxSize = std::numeric_limits<size_type>::max() /
sizeof(T);
3510 for (
const Device &d : context_.
getInfo<CL_CONTEXT_DEVICES>()) {
3513 static_cast<size_type>(d.getInfo<CL_DEVICE_MAX_MEM_ALLOC_SIZE>()));
3519 template<
class U,
class... Args >
3520 void construct(U* p, Args&&... args)
3536 return (context_==rhs.context_);
3541 return !operator==(a);
3546 template<
class SVMTrait>
3549 typedef void value_type;
3550 typedef value_type* pointer;
3551 typedef const value_type* const_pointer;
3553 template<
typename U>
3559 template<
typename U,
typename V>
3563 #if !defined(CL_HPP_NO_STD_UNIQUE_PTR) 3566 template<
class Alloc>
3573 typedef typename std::allocator_traits<Alloc>::pointer pointer;
3575 Deleter(
const Alloc &alloc, size_type copies) : alloc_{ alloc }, copies_{ copies }
3579 void operator()(pointer ptr)
const {
3580 Alloc tmpAlloc{ alloc_ };
3581 std::allocator_traits<Alloc>::destroy(tmpAlloc, std::addressof(*ptr));
3582 std::allocator_traits<Alloc>::deallocate(tmpAlloc, ptr, copies_);
3593 template <
class T,
class Alloc,
class... Args>
3596 Alloc alloc(alloc_);
3597 static const size_type copies = 1;
3602 T* tmp = std::allocator_traits<Alloc>::allocate(alloc, copies);
3604 std::bad_alloc excep;
3608 std::allocator_traits<Alloc>::construct(
3610 std::addressof(*tmp),
3611 std::forward<Args>(args)...);
3615 catch (std::bad_alloc b)
3617 std::allocator_traits<Alloc>::deallocate(alloc, tmp, copies);
3622 template<
class T,
class SVMTrait,
class... Args >
3623 cl::pointer<T, detail::Deleter<SVMAllocator<T, SVMTrait>>> allocate_svm(Args... args)
3626 return cl::allocate_pointer<T>(alloc, args...);
3629 template<
class T,
class SVMTrait,
class... Args >
3630 cl::pointer<T, detail::Deleter<SVMAllocator<T, SVMTrait>>> allocate_svm(
const cl::Context &c, Args... args)
3633 return cl::allocate_pointer<T>(alloc, args...);
3635 #endif // #if !defined(CL_HPP_NO_STD_UNIQUE_PTR) 3640 template <
class T >
3646 template <
class T >
3652 template <
class T >
3655 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 3679 void* host_ptr = NULL,
3683 object_ = ::clCreateBuffer(context(), flags, size, host_ptr, &error);
3685 detail::errHandler(error, __CREATE_BUFFER_ERR);
3703 void* host_ptr = NULL,
3710 object_ = ::clCreateBuffer(context(), flags, size, host_ptr, &error);
3712 detail::errHandler(error, __CREATE_BUFFER_ERR);
3723 template<
typename IteratorType >
3725 IteratorType startIterator,
3726 IteratorType endIterator,
3728 bool useHostPtr =
false,
3731 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
3734 cl_mem_flags flags = 0;
3736 flags |= CL_MEM_READ_ONLY;
3739 flags |= CL_MEM_READ_WRITE;
3742 flags |= CL_MEM_USE_HOST_PTR;
3745 size_type size =
sizeof(DataType)*(endIterator - startIterator);
3750 object_ = ::clCreateBuffer(context(), flags, size, static_cast<DataType*>(&*startIterator), &error);
3752 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
3755 detail::errHandler(error, __CREATE_BUFFER_ERR);
3761 error =
cl::copy(startIterator, endIterator, *
this);
3762 detail::errHandler(error, __CREATE_BUFFER_ERR);
3774 template<
typename IteratorType >
3775 Buffer(
const Context &context, IteratorType startIterator, IteratorType endIterator,
3776 bool readOnly,
bool useHostPtr =
false, cl_int* err = NULL);
3782 template<
typename IteratorType >
3783 Buffer(
const CommandQueue &queue, IteratorType startIterator, IteratorType endIterator,
3784 bool readOnly,
bool useHostPtr =
false, cl_int* err = NULL);
3796 explicit Buffer(
const cl_mem& buffer,
bool retainObject =
false) :
3797 Memory(buffer, retainObject) { }
3837 #if CL_HPP_TARGET_OPENCL_VERSION >= 110 3844 cl_buffer_create_type buffer_create_type,
3845 const void * buffer_create_info,
3846 cl_int * err = NULL)
3850 result.object_ = ::clCreateSubBuffer(
3857 detail::errHandler(error, __CREATE_SUBBUFFER_ERR);
3864 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110 3867 #if defined (CL_HPP_USE_DX_INTEROP) 3876 class BufferD3D10 :
public Buffer 3889 ID3D10Buffer* bufobj,
3890 cl_int * err = NULL) : pfn_clCreateFromD3D10BufferKHR(
nullptr)
3892 typedef CL_API_ENTRY cl_mem (CL_API_CALL *PFN_clCreateFromD3D10BufferKHR)(
3893 cl_context context, cl_mem_flags flags, ID3D10Buffer* buffer,
3894 cl_int* errcode_ret);
3895 PFN_clCreateFromD3D10BufferKHR pfn_clCreateFromD3D10BufferKHR;
3896 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 3897 vector<cl_context_properties> props = context.getInfo<CL_CONTEXT_PROPERTIES>();
3898 cl_platform platform = -1;
3899 for(
int i = 0; i < props.size(); ++i ) {
3900 if( props[i] == CL_CONTEXT_PLATFORM ) {
3901 platform = props[i+1];
3904 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCreateFromD3D10BufferKHR);
3905 #elif CL_HPP_TARGET_OPENCL_VERSION >= 110 3906 CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateFromD3D10BufferKHR);
3910 object_ = pfn_clCreateFromD3D10BufferKHR(
3916 detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
3923 BufferD3D10() :
Buffer() { }
3932 explicit BufferD3D10(
const cl_mem& buffer,
bool retainObject =
false) :
3933 Buffer(buffer, retainObject) { }
3939 BufferD3D10& operator = (
const cl_mem& rhs)
3948 BufferD3D10(
const BufferD3D10& buf) :
3954 BufferD3D10& operator = (
const BufferD3D10 &buf)
3963 BufferD3D10(BufferD3D10&& buf) CL_HPP_NOEXCEPT_ :
Buffer(std::move(buf)) {}
3968 BufferD3D10& operator = (BufferD3D10 &&buf)
3996 cl_int * err = NULL)
3999 object_ = ::clCreateFromGLBuffer(
4005 detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
4021 explicit BufferGL(
const cl_mem& buffer,
bool retainObject =
false) :
4022 Buffer(buffer, retainObject) { }
4064 cl_gl_object_type *type,
4065 cl_GLuint * gl_object_name)
4067 return detail::errHandler(
4068 ::clGetGLObjectInfo(object_,type,gl_object_name),
4069 __GET_GL_OBJECT_INFO_ERR);
4093 cl_int * err = NULL)
4096 object_ = ::clCreateFromGLRenderbuffer(
4102 detail::errHandler(error, __CREATE_GL_RENDER_BUFFER_ERR);
4119 Buffer(buffer, retainObject) { }
4161 cl_gl_object_type *type,
4162 cl_GLuint * gl_object_name)
4164 return detail::errHandler(
4165 ::clGetGLObjectInfo(object_,type,gl_object_name),
4166 __GET_GL_OBJECT_INFO_ERR);
4189 explicit Image(
const cl_mem& image,
bool retainObject =
false) :
4190 Memory(image, retainObject) { }
4233 template <
typename T>
4236 return detail::errHandler(
4237 detail::getInfo(&::clGetImageInfo, object_, name, param),
4238 __GET_IMAGE_INFO_ERR);
4242 template <cl_
int name>
typename 4247 detail::cl_image_info, name>::param_type param;
4248 cl_int result = getImageInfo(name, ¶m);
4256 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 4275 void* host_ptr = NULL,
4279 cl_image_desc desc =
4281 CL_MEM_OBJECT_IMAGE1D,
4283 0, 0, 0, 0, 0, 0, 0, 0
4285 object_ = ::clCreateImage(
4293 detail::errHandler(error, __CREATE_IMAGE_ERR);
4309 explicit Image1D(
const cl_mem& image1D,
bool retainObject =
false) :
4310 Image(image1D, retainObject) { }
4367 cl_image_desc desc =
4369 CL_MEM_OBJECT_IMAGE1D_BUFFER,
4371 0, 0, 0, 0, 0, 0, 0,
4374 object_ = ::clCreateImage(
4382 detail::errHandler(error, __CREATE_IMAGE_ERR);
4398 Image(image1D, retainObject) { }
4446 size_type arraySize,
4449 void* host_ptr = NULL,
4453 cl_image_desc desc =
4455 CL_MEM_OBJECT_IMAGE1D_ARRAY,
4462 object_ = ::clCreateImage(
4470 detail::errHandler(error, __CREATE_IMAGE_ERR);
4485 explicit Image1DArray(
const cl_mem& imageArray,
bool retainObject =
false) :
4486 Image(imageArray, retainObject) { }
4524 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 120 4546 size_type row_pitch = 0,
4547 void* host_ptr = NULL,
4551 bool useCreateImage;
4553 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120 4556 cl_uint version = detail::getContextPlatformVersion(context());
4557 useCreateImage = (version >= 0x10002);
4559 #elif CL_HPP_TARGET_OPENCL_VERSION >= 120 4560 useCreateImage =
true;
4562 useCreateImage =
false;
4565 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 4568 cl_image_desc desc =
4570 CL_MEM_OBJECT_IMAGE2D,
4577 object_ = ::clCreateImage(
4585 detail::errHandler(error, __CREATE_IMAGE_ERR);
4590 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 4591 #if CL_HPP_MINIMUM_OPENCL_VERSION < 120 4592 if (!useCreateImage)
4594 object_ = ::clCreateImage2D(
4595 context(), flags,&format, width, height, row_pitch, host_ptr, &error);
4597 detail::errHandler(error, __CREATE_IMAGE2D_ERR);
4602 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 120 4605 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 || defined(CL_HPP_USE_CL_IMAGE2D_FROM_BUFFER_KHR) 4614 const Buffer &sourceBuffer,
4617 size_type row_pitch = 0,
4618 cl_int* err =
nullptr)
4622 cl_image_desc desc =
4624 CL_MEM_OBJECT_IMAGE2D,
4633 object_ = ::clCreateImage(
4641 detail::errHandler(error, __CREATE_IMAGE_ERR);
4642 if (err !=
nullptr) {
4646 #endif //#if CL_HPP_TARGET_OPENCL_VERSION >= 200 || defined(CL_HPP_USE_CL_IMAGE2D_FROM_BUFFER_KHR) 4648 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 4663 cl_channel_order order,
4664 const Image &sourceImage,
4665 cl_int* err =
nullptr)
4670 size_type sourceWidth =
4672 size_type sourceHeight =
4674 size_type sourceRowPitch =
4676 cl_uint sourceNumMIPLevels =
4678 cl_uint sourceNumSamples =
4680 cl_image_format sourceFormat =
4685 sourceFormat.image_channel_order = order;
4686 cl_image_desc desc =
4688 CL_MEM_OBJECT_IMAGE2D,
4699 object_ = ::clCreateImage(
4707 detail::errHandler(error, __CREATE_IMAGE_ERR);
4708 if (err !=
nullptr) {
4712 #endif //#if CL_HPP_TARGET_OPENCL_VERSION >= 200 4724 explicit Image2D(
const cl_mem& image2D,
bool retainObject =
false) :
4725 Image(image2D, retainObject) { }
4768 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 4792 cl_int * err = NULL)
4795 object_ = ::clCreateFromGLTexture2D(
4803 detail::errHandler(error, __CREATE_GL_TEXTURE_2D_ERR);
4820 explicit Image2DGL(
const cl_mem& image,
bool retainObject =
false) :
4821 Image2D(image, retainObject) { }
4861 } CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
4862 #endif // CL_USE_DEPRECATED_OPENCL_1_1_APIS 4864 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 4875 size_type arraySize,
4879 size_type slicePitch,
4880 void* host_ptr = NULL,
4884 cl_image_desc desc =
4886 CL_MEM_OBJECT_IMAGE2D_ARRAY,
4895 object_ = ::clCreateImage(
4903 detail::errHandler(error, __CREATE_IMAGE_ERR);
4918 explicit Image2DArray(
const cl_mem& imageArray,
bool retainObject =
false) :
Image(imageArray, retainObject) { }
4954 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 120 4976 size_type row_pitch = 0,
4977 size_type slice_pitch = 0,
4978 void* host_ptr = NULL,
4982 bool useCreateImage;
4984 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120 4987 cl_uint version = detail::getContextPlatformVersion(context());
4988 useCreateImage = (version >= 0x10002);
4990 #elif CL_HPP_TARGET_OPENCL_VERSION >= 120 4991 useCreateImage =
true;
4993 useCreateImage =
false;
4996 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 4999 cl_image_desc desc =
5001 CL_MEM_OBJECT_IMAGE3D,
5010 object_ = ::clCreateImage(
5018 detail::errHandler(error, __CREATE_IMAGE_ERR);
5023 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 5024 #if CL_HPP_MINIMUM_OPENCL_VERSION < 120 5025 if (!useCreateImage)
5027 object_ = ::clCreateImage3D(
5028 context(), flags, &format, width, height, depth, row_pitch,
5029 slice_pitch, host_ptr, &error);
5031 detail::errHandler(error, __CREATE_IMAGE3D_ERR);
5036 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 120 5049 explicit Image3D(
const cl_mem& image3D,
bool retainObject =
false) :
5050 Image(image3D, retainObject) { }
5091 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 5114 cl_int * err = NULL)
5117 object_ = ::clCreateFromGLTexture3D(
5125 detail::errHandler(error, __CREATE_GL_TEXTURE_3D_ERR);
5141 explicit Image3DGL(
const cl_mem& image,
bool retainObject =
false) :
5142 Image3D(image, retainObject) { }
5182 #endif // CL_USE_DEPRECATED_OPENCL_1_1_APIS 5184 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 5200 cl_int * err = NULL)
5203 object_ = ::clCreateFromGLTexture(
5211 detail::errHandler(error, __CREATE_GL_TEXTURE_ERR);
5226 explicit ImageGL(
const cl_mem& image,
bool retainObject =
false) :
5227 Image(image, retainObject) { }
5229 ImageGL& operator = (
const cl_mem& rhs)
5263 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 5267 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 5289 cl_uint packet_size,
5290 cl_uint max_packets,
5295 cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS;
5296 object_ = ::clCreatePipe(context(), flags, packet_size, max_packets,
nullptr, &error);
5298 detail::errHandler(error, __CREATE_PIPE_ERR);
5313 cl_uint packet_size,
5314 cl_uint max_packets,
5321 cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS;
5322 object_ = ::clCreatePipe(context(), flags, packet_size, max_packets,
nullptr, &error);
5324 detail::errHandler(error, __CREATE_PIPE_ERR);
5340 explicit Pipe(
const cl_mem& pipe,
bool retainObject =
false) :
5341 Memory(pipe, retainObject) { }
5347 Pipe& operator = (
const cl_mem& rhs)
5382 template <
typename T>
5385 return detail::errHandler(
5386 detail::getInfo(&::clGetPipeInfo, object_, name, param),
5387 __GET_PIPE_INFO_ERR);
5391 template <cl_
int name>
typename 5396 detail::cl_pipe_info, name>::param_type param;
5397 cl_int result = getInfo(name, ¶m);
5404 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200 5427 cl_bool normalized_coords,
5428 cl_addressing_mode addressing_mode,
5429 cl_filter_mode filter_mode,
5434 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 5435 cl_sampler_properties sampler_properties[] = {
5436 CL_SAMPLER_NORMALIZED_COORDS, normalized_coords,
5437 CL_SAMPLER_ADDRESSING_MODE, addressing_mode,
5438 CL_SAMPLER_FILTER_MODE, filter_mode,
5440 object_ = ::clCreateSamplerWithProperties(
5445 detail::errHandler(error, __CREATE_SAMPLER_WITH_PROPERTIES_ERR);
5450 object_ = ::clCreateSampler(
5457 detail::errHandler(error, __CREATE_SAMPLER_ERR);
5472 explicit Sampler(
const cl_sampler& sampler,
bool retainObject =
false) :
5473 detail::Wrapper<cl_type>(sampler, retainObject) { }
5515 template <
typename T>
5516 cl_int
getInfo(cl_sampler_info name, T* param)
const 5518 return detail::errHandler(
5519 detail::getInfo(&::clGetSamplerInfo, object_, name, param),
5520 __GET_SAMPLER_INFO_ERR);
5524 template <cl_
int name>
typename 5529 detail::cl_sampler_info, name>::param_type param;
5530 cl_int result = getInfo(name, ¶m);
5547 size_type sizes_[3];
5548 cl_uint dimensions_;
5579 NDRange(size_type size0, size_type size1, size_type size2)
5591 operator const size_type*()
const {
5605 return dimensions_*
sizeof(size_type);
5613 const size_type*
get()
const 5620 static const NDRange NullRange;
5630 template <
typename T,
class Enable =
void>
5635 template <
typename T>
5638 static size_type size(
const T&) {
return sizeof(T); }
5639 static const T* ptr(
const T& value) {
return &value; }
5644 template <
typename T>
5647 static size_type size(
const T&) {
return sizeof(cl_mem); }
5648 static const cl_mem* ptr(
const T& value) {
return &(value()); }
5656 static size_type size(
const LocalSpaceArg& value) {
return value.size_; }
5657 static const void* ptr(
const LocalSpaceArg&) {
return NULL; }
5684 inline Kernel(
const Program& program,
const char* name, cl_int* err = NULL);
5697 explicit Kernel(
const cl_kernel& kernel,
bool retainObject =
false) :
5698 detail::Wrapper<cl_type>(kernel, retainObject) { }
5739 template <
typename T>
5740 cl_int getInfo(cl_kernel_info name, T* param)
const 5742 return detail::errHandler(
5743 detail::getInfo(&::clGetKernelInfo, object_, name, param),
5744 __GET_KERNEL_INFO_ERR);
5747 template <cl_
int name>
typename 5749 getInfo(cl_int* err = NULL)
const 5752 detail::cl_kernel_info, name>::param_type param;
5753 cl_int result = getInfo(name, ¶m);
5760 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 5761 template <
typename T>
5762 cl_int getArgInfo(cl_uint argIndex, cl_kernel_arg_info name, T* param)
const 5764 return detail::errHandler(
5765 detail::getInfo(&::clGetKernelArgInfo, object_, argIndex, name, param),
5766 __GET_KERNEL_ARG_INFO_ERR);
5769 template <cl_
int name>
typename 5771 getArgInfo(cl_uint argIndex, cl_int* err = NULL)
const 5774 detail::cl_kernel_arg_info, name>::param_type param;
5775 cl_int result = getArgInfo(argIndex, name, ¶m);
5781 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 5783 template <
typename T>
5784 cl_int getWorkGroupInfo(
5785 const Device& device, cl_kernel_work_group_info name, T* param)
const 5787 return detail::errHandler(
5789 &::clGetKernelWorkGroupInfo, object_, device(), name, param),
5790 __GET_KERNEL_WORK_GROUP_INFO_ERR);
5793 template <cl_
int name>
typename 5795 getWorkGroupInfo(
const Device& device, cl_int* err = NULL)
const 5798 detail::cl_kernel_work_group_info, name>::param_type param;
5799 cl_int result = getWorkGroupInfo(device, name, ¶m);
5806 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 5807 #if defined(CL_HPP_USE_CL_SUB_GROUPS_KHR) 5808 cl_int getSubGroupInfo(
const cl::Device &dev, cl_kernel_sub_group_info name,
const cl::NDRange &range, size_type* param)
const 5810 typedef clGetKernelSubGroupInfoKHR_fn PFN_clGetKernelSubGroupInfoKHR;
5811 static PFN_clGetKernelSubGroupInfoKHR pfn_clGetKernelSubGroupInfoKHR = NULL;
5812 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetKernelSubGroupInfoKHR);
5814 return detail::errHandler(
5815 pfn_clGetKernelSubGroupInfoKHR(object_, dev(), name, range.
size(), range.get(),
sizeof(size_type), param,
nullptr),
5816 __GET_KERNEL_ARG_INFO_ERR);
5819 template <cl_
int name>
5820 size_type getSubGroupInfo(
const cl::Device &dev,
const cl::NDRange &range, cl_int* err = NULL)
const 5823 cl_int result = getSubGroupInfo(dev, name, range, ¶m);
5829 #endif // #if defined(CL_HPP_USE_CL_SUB_GROUPS_KHR) 5830 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 5832 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 5835 template<
typename T,
class D>
5836 cl_int
setArg(cl_uint index,
const cl::pointer<T, D> &argPtr)
5838 return detail::errHandler(
5839 ::clSetKernelArgSVMPointer(object_, index, argPtr.get()),
5840 __SET_KERNEL_ARGS_ERR);
5845 template<
typename T,
class Alloc>
5846 cl_int
setArg(cl_uint index,
const cl::vector<T, Alloc> &argPtr)
5848 return detail::errHandler(
5849 ::clSetKernelArgSVMPointer(object_, index, argPtr.data()),
5850 __SET_KERNEL_ARGS_ERR);
5855 template<
typename T>
5856 typename std::enable_if<std::is_pointer<T>::value, cl_int>::type
5859 return detail::errHandler(
5860 ::clSetKernelArgSVMPointer(object_, index, argPtr),
5861 __SET_KERNEL_ARGS_ERR);
5863 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 5867 template <
typename T>
5868 typename std::enable_if<!std::is_pointer<T>::value, cl_int>::type
5871 return detail::errHandler(
5877 __SET_KERNEL_ARGS_ERR);
5880 cl_int setArg(cl_uint index, size_type size,
const void* argPtr)
5882 return detail::errHandler(
5883 ::clSetKernelArg(object_, index, size, argPtr),
5884 __SET_KERNEL_ARGS_ERR);
5887 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 5894 return detail::errHandler(
5895 ::clSetKernelExecInfo(
5897 CL_KERNEL_EXEC_INFO_SVM_PTRS,
5898 sizeof(
void*)*pointerList.size(),
5899 pointerList.data()));
5906 template<
int ArrayLength>
5909 return detail::errHandler(
5910 ::clSetKernelExecInfo(
5912 CL_KERNEL_EXEC_INFO_SVM_PTRS,
5913 sizeof(
void*)*pointerList.size(),
5914 pointerList.data()));
5930 cl_bool svmEnabled_ = svmEnabled ? CL_TRUE : CL_FALSE;
5931 return detail::errHandler(
5932 ::clSetKernelExecInfo(
5934 CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM,
5941 template<
int index,
int ArrayLength,
class D,
typename T0,
typename T1,
typename... Ts>
5942 void setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList,
const pointer<T0, D> &t0,
const pointer<T1, D> &t1, Ts & ... ts)
5944 pointerList[index] =
static_cast<void*
>(t0.get());
5945 setSVMPointersHelper<index + 1, ArrayLength>(pointerList, t1, ts...);
5948 template<
int index,
int ArrayLength,
typename T0,
typename T1,
typename... Ts>
5949 typename std::enable_if<std::is_pointer<T0>::value,
void>::type
5950 setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList, T0 t0, T1 t1, Ts... ts)
5952 pointerList[index] =
static_cast<void*
>(t0);
5953 setSVMPointersHelper<index + 1, ArrayLength>(pointerList, t1, ts...);
5956 template<
int index,
int ArrayLength,
typename T0,
class D>
5957 void setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList,
const pointer<T0, D> &t0)
5959 pointerList[index] =
static_cast<void*
>(t0.get());
5963 template<
int index,
int ArrayLength,
typename T0>
5964 typename std::enable_if<std::is_pointer<T0>::value,
void>::type
5965 setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList, T0 t0)
5967 pointerList[index] =
static_cast<void*
>(t0);
5970 template<
typename T0,
typename... Ts>
5971 cl_int setSVMPointers(
const T0 &t0, Ts & ... ts)
5973 std::array<
void*, 1 +
sizeof...(Ts)> pointerList;
5975 setSVMPointersHelper<0, 1 +
sizeof...(Ts)>(pointerList, t0, ts...);
5976 return detail::errHandler(
5977 ::clSetKernelExecInfo(
5979 CL_KERNEL_EXEC_INFO_SVM_PTRS,
5980 sizeof(
void*)*(1 +
sizeof...(Ts)),
5981 pointerList.data()));
5983 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 5992 #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 5993 typedef vector<vector<unsigned char>> Binaries;
5994 typedef vector<string> Sources;
5995 #else // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 5996 typedef vector<std::pair<const void*, size_type> > Binaries;
5997 typedef vector<std::pair<const char*, size_type> > Sources;
5998 #endif // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 6001 const string& source,
6007 const char * strings = source.c_str();
6008 const size_type length = source.size();
6012 object_ = ::clCreateProgramWithSource(
6013 context(), (cl_uint)1, &strings, &length, &error);
6015 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6017 if (error == CL_SUCCESS && build) {
6019 error = ::clBuildProgram(
6023 #
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6031 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6041 const string& source,
6047 const char * strings = source.c_str();
6048 const size_type length = source.size();
6050 object_ = ::clCreateProgramWithSource(
6051 context(), (cl_uint)1, &strings, &length, &error);
6053 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6055 if (error == CL_SUCCESS && build) {
6056 error = ::clBuildProgram(
6060 #
if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
6068 detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6081 const Sources& sources,
6087 const size_type n = (size_type)sources.size();
6089 vector<size_type> lengths(n);
6090 vector<const char*> strings(n);
6092 for (size_type i = 0; i < n; ++i) {
6093 #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 6094 strings[i] = sources[(int)i].data();
6095 lengths[i] = sources[(int)i].length();
6096 #else // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 6097 strings[i] = sources[(int)i].first;
6098 lengths[i] = sources[(int)i].second;
6099 #endif // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 6102 object_ = ::clCreateProgramWithSource(
6103 context(), (cl_uint)n, strings.data(), lengths.data(), &error);
6105 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6117 const Sources& sources,
6122 const size_type n = (size_type)sources.size();
6124 vector<size_type> lengths(n);
6125 vector<const char*> strings(n);
6127 for (size_type i = 0; i < n; ++i) {
6128 #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 6129 strings[i] = sources[(int)i].data();
6130 lengths[i] = sources[(int)i].length();
6131 #else // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 6132 strings[i] = sources[(int)i].first;
6133 lengths[i] = sources[(int)i].second;
6134 #endif // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 6137 object_ = ::clCreateProgramWithSource(
6138 context(), (cl_uint)n, strings.data(), lengths.data(), &error);
6140 detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
6167 const vector<Device>& devices,
6168 const Binaries& binaries,
6169 vector<cl_int>* binaryStatus = NULL,
6174 const size_type numDevices = devices.size();
6177 if(binaries.size() != numDevices) {
6178 error = CL_INVALID_VALUE;
6179 detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
6187 vector<size_type> lengths(numDevices);
6188 vector<const unsigned char*> images(numDevices);
6189 #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 6190 for (size_type i = 0; i < numDevices; ++i) {
6191 images[i] = binaries[i].data();
6192 lengths[i] = binaries[(int)i].size();
6194 #else // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 6195 for (size_type i = 0; i < numDevices; ++i) {
6196 images[i] = (
const unsigned char*)binaries[i].first;
6197 lengths[i] = binaries[(int)i].second;
6199 #endif // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY) 6201 vector<cl_device_id> deviceIDs(numDevices);
6202 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6203 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6207 binaryStatus->resize(numDevices);
6210 object_ = ::clCreateProgramWithBinary(
6211 context(), (cl_uint) devices.size(),
6213 lengths.data(), images.data(), (binaryStatus != NULL && numDevices > 0)
6214 ? &binaryStatus->front()
6217 detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
6224 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 6231 const vector<Device>& devices,
6232 const string& kernelNames,
6238 size_type numDevices = devices.size();
6239 vector<cl_device_id> deviceIDs(numDevices);
6240 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6241 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6244 object_ = ::clCreateProgramWithBuiltInKernels(
6246 (cl_uint) devices.size(),
6248 kernelNames.c_str(),
6251 detail::errHandler(error, __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR);
6256 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 6267 explicit Program(
const cl_program& program,
bool retainObject =
false) :
6268 detail::Wrapper<cl_type>(program, retainObject) { }
6270 Program& operator = (
const cl_program& rhs)
6305 const vector<Device>& devices,
6306 const char* options = NULL,
6307 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6308 void* data = NULL)
const 6310 size_type numDevices = devices.size();
6311 vector<cl_device_id> deviceIDs(numDevices);
6313 for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
6314 deviceIDs[deviceIndex] = (devices[deviceIndex])();
6317 cl_int buildError = ::clBuildProgram(
6326 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6330 const char* options = NULL,
6331 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6332 void* data = NULL)
const 6334 cl_int buildError = ::clBuildProgram(
6343 return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6346 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 6348 const char* options = NULL,
6349 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6350 void* data = NULL)
const 6352 cl_int error = ::clCompileProgram(
6362 return detail::buildErrHandler(error, __COMPILE_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
6364 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 6366 template <
typename T>
6367 cl_int getInfo(cl_program_info name, T* param)
const 6369 return detail::errHandler(
6370 detail::getInfo(&::clGetProgramInfo, object_, name, param),
6371 __GET_PROGRAM_INFO_ERR);
6374 template <cl_
int name>
typename 6376 getInfo(cl_int* err = NULL)
const 6379 detail::cl_program_info, name>::param_type param;
6380 cl_int result = getInfo(name, ¶m);
6387 template <
typename T>
6388 cl_int getBuildInfo(
6389 const Device& device, cl_program_build_info name, T* param)
const 6391 return detail::errHandler(
6393 &::clGetProgramBuildInfo, object_, device(), name, param),
6394 __GET_PROGRAM_BUILD_INFO_ERR);
6397 template <cl_
int name>
typename 6399 getBuildInfo(
const Device& device, cl_int* err = NULL)
const 6402 detail::cl_program_build_info, name>::param_type param;
6403 cl_int result = getBuildInfo(device, name, ¶m);
6415 template <cl_
int name>
6416 vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, name>::param_type>>
6419 cl_int result = CL_SUCCESS;
6421 auto devs = getInfo<CL_PROGRAM_DEVICES>(&result);
6422 vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, name>::param_type>>
6426 if (result != CL_SUCCESS) {
6435 detail::cl_program_build_info, name>::param_type param;
6436 result = getBuildInfo(d, name, ¶m);
6440 if (result != CL_SUCCESS) {
6448 if (result != CL_SUCCESS) {
6454 cl_int createKernels(vector<Kernel>* kernels)
6457 cl_int err = ::clCreateKernelsInProgram(object_, 0, NULL, &numKernels);
6458 if (err != CL_SUCCESS) {
6459 return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
6462 vector<cl_kernel> value(numKernels);
6464 err = ::clCreateKernelsInProgram(
6465 object_, numKernels, value.data(), NULL);
6466 if (err != CL_SUCCESS) {
6467 return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
6471 kernels->resize(value.size());
6475 for (size_type i = 0; i < value.size(); i++) {
6478 (*kernels)[i] =
Kernel(value[i],
false);
6485 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 6489 const char* options = NULL,
6490 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6494 cl_int error_local = CL_SUCCESS;
6496 cl_program programs[2] = { input1(), input2() };
6498 Context ctx = input1.getInfo<CL_PROGRAM_CONTEXT>(&error_local);
6499 if(error_local!=CL_SUCCESS) {
6500 detail::errHandler(error_local, __LINK_PROGRAM_ERR);
6503 cl_program prog = ::clLinkProgram(
6514 detail::errHandler(error_local,__COMPILE_PROGRAM_ERR);
6523 vector<Program> inputPrograms,
6524 const char* options = NULL,
6525 void (CL_CALLBACK * notifyFptr)(cl_program,
void *) = NULL,
6529 cl_int error_local = CL_SUCCESS;
6531 vector<cl_program> programs(inputPrograms.size());
6533 for (
unsigned int i = 0; i < inputPrograms.size(); i++) {
6534 programs[i] = inputPrograms[i]();
6538 if(inputPrograms.size() > 0) {
6539 ctx = inputPrograms[0].
getInfo<CL_PROGRAM_CONTEXT>(&error_local);
6540 if(error_local!=CL_SUCCESS) {
6541 detail::errHandler(error_local, __LINK_PROGRAM_ERR);
6544 cl_program prog = ::clLinkProgram(
6549 (cl_uint)inputPrograms.size(),
6555 detail::errHandler(error_local,__COMPILE_PROGRAM_ERR);
6562 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 6566 inline cl_int cl::Program::getInfo(cl_program_info name, vector<vector<unsigned char>>* param)
const 6568 if (name != CL_PROGRAM_BINARIES) {
6569 return CL_INVALID_VALUE;
6575 vector<size_type> sizes = getInfo<CL_PROGRAM_BINARY_SIZES>();
6576 size_type numBinaries = sizes.size();
6579 param->resize(numBinaries);
6580 for (size_type i = 0; i < numBinaries; ++i) {
6581 (*param)[i].resize(sizes[i]);
6584 return detail::errHandler(
6585 detail::getInfo(&::clGetProgramInfo, object_, name, param),
6586 __GET_PROGRAM_INFO_ERR);
6593 inline vector<vector<unsigned char>> cl::Program::getInfo<CL_PROGRAM_BINARIES>(cl_int* err)
const 6595 vector<vector<unsigned char>> binariesVectors;
6597 cl_int result = getInfo(CL_PROGRAM_BINARIES, &binariesVectors);
6601 return binariesVectors;
6608 object_ = ::clCreateKernel(program(), name, &error);
6609 detail::errHandler(error, __CREATE_KERNEL_ERR);
6617 enum class QueueProperties : cl_command_queue_properties
6620 Profiling = CL_QUEUE_PROFILING_ENABLE,
6621 OutOfOrder = CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE,
6624 inline QueueProperties operator|(QueueProperties lhs, QueueProperties rhs)
6626 return static_cast<QueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) | static_cast<cl_command_queue_properties>(rhs));
6635 static std::once_flag default_initialized_;
6637 static cl_int default_error_;
6644 static void makeDefault()
6649 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 6656 if (error != CL_SUCCESS) {
6657 default_error_ = error;
6661 default_ =
CommandQueue(context, device, 0, &default_error_);
6664 #if defined(CL_HPP_ENABLE_EXCEPTIONS) 6665 catch (cl::Error &e) {
6666 default_error_ = e.err();
6676 static void makeDefaultProvided(
const CommandQueue &c) {
6681 #ifdef CL_HPP_UNIT_TEST_ENABLE 6688 static void unitTestClearDefault() {
6691 #endif // #ifdef CL_HPP_UNIT_TEST_ENABLE 6699 cl_command_queue_properties properties,
6705 detail::errHandler(error, __CREATE_CONTEXT_ERR);
6707 if (error != CL_SUCCESS) {
6714 bool useWithProperties;
6716 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 6719 cl_uint version = detail::getContextPlatformVersion(context());
6720 useWithProperties = (version >= 0x20000);
6722 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200 6723 useWithProperties =
true;
6725 useWithProperties =
false;
6728 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 6729 if (useWithProperties) {
6730 cl_queue_properties queue_properties[] = {
6731 CL_QUEUE_PROPERTIES, properties, 0 };
6732 if ((properties & CL_QUEUE_ON_DEVICE) == 0) {
6733 object_ = ::clCreateCommandQueueWithProperties(
6734 context(), device(), queue_properties, &error);
6737 error = CL_INVALID_QUEUE_PROPERTIES;
6740 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
6745 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200 6746 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200 6747 if (!useWithProperties) {
6748 object_ = ::clCreateCommandQueue(
6749 context(), device(), properties, &error);
6751 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
6756 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 200 6765 QueueProperties properties,
6771 detail::errHandler(error, __CREATE_CONTEXT_ERR);
6773 if (error != CL_SUCCESS) {
6780 bool useWithProperties;
6782 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 6785 cl_uint version = detail::getContextPlatformVersion(context());
6786 useWithProperties = (version >= 0x20000);
6788 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200 6789 useWithProperties =
true;
6791 useWithProperties =
false;
6794 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 6795 if (useWithProperties) {
6796 cl_queue_properties queue_properties[] = {
6797 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
6799 object_ = ::clCreateCommandQueueWithProperties(
6800 context(), device(), queue_properties, &error);
6802 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
6807 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200 6808 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200 6809 if (!useWithProperties) {
6810 object_ = ::clCreateCommandQueue(
6811 context(), device(), static_cast<cl_command_queue_properties>(properties), &error);
6813 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
6818 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 200 6829 cl_command_queue_properties properties = 0,
6833 bool useWithProperties;
6834 vector<cl::Device> devices;
6835 error = context.
getInfo(CL_CONTEXT_DEVICES, &devices);
6837 detail::errHandler(error, __CREATE_CONTEXT_ERR);
6839 if (error != CL_SUCCESS)
6847 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 6850 cl_uint version = detail::getContextPlatformVersion(context());
6851 useWithProperties = (version >= 0x20000);
6853 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200 6854 useWithProperties =
true;
6856 useWithProperties =
false;
6859 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 6860 if (useWithProperties) {
6861 cl_queue_properties queue_properties[] = {
6862 CL_QUEUE_PROPERTIES, properties, 0 };
6863 if ((properties & CL_QUEUE_ON_DEVICE) == 0) {
6864 object_ = ::clCreateCommandQueueWithProperties(
6865 context(), devices[0](), queue_properties, &error);
6868 error = CL_INVALID_QUEUE_PROPERTIES;
6871 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
6876 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200 6877 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200 6878 if (!useWithProperties) {
6879 object_ = ::clCreateCommandQueue(
6880 context(), devices[0](), properties, &error);
6882 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
6887 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 200 6896 QueueProperties properties,
6900 bool useWithProperties;
6901 vector<cl::Device> devices;
6902 error = context.
getInfo(CL_CONTEXT_DEVICES, &devices);
6904 detail::errHandler(error, __CREATE_CONTEXT_ERR);
6906 if (error != CL_SUCCESS)
6914 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 6917 cl_uint version = detail::getContextPlatformVersion(context());
6918 useWithProperties = (version >= 0x20000);
6920 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200 6921 useWithProperties =
true;
6923 useWithProperties =
false;
6926 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 6927 if (useWithProperties) {
6928 cl_queue_properties queue_properties[] = {
6929 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
6930 object_ = ::clCreateCommandQueueWithProperties(
6931 context(), devices[0](), queue_properties, &error);
6933 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
6938 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200 6939 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200 6940 if (!useWithProperties) {
6941 object_ = ::clCreateCommandQueue(
6942 context(), devices[0](), static_cast<cl_command_queue_properties>(properties), &error);
6944 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
6949 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 200 6959 cl_command_queue_properties properties = 0,
6963 bool useWithProperties;
6965 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 6968 cl_uint version = detail::getContextPlatformVersion(context());
6969 useWithProperties = (version >= 0x20000);
6971 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200 6972 useWithProperties =
true;
6974 useWithProperties =
false;
6977 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 6978 if (useWithProperties) {
6979 cl_queue_properties queue_properties[] = {
6980 CL_QUEUE_PROPERTIES, properties, 0 };
6981 object_ = ::clCreateCommandQueueWithProperties(
6982 context(), device(), queue_properties, &error);
6984 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
6989 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200 6990 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200 6991 if (!useWithProperties) {
6992 object_ = ::clCreateCommandQueue(
6993 context(), device(), properties, &error);
6995 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7000 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 200 7010 QueueProperties properties,
7014 bool useWithProperties;
7016 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 7019 cl_uint version = detail::getContextPlatformVersion(context());
7020 useWithProperties = (version >= 0x20000);
7022 #elif CL_HPP_TARGET_OPENCL_VERSION >= 200 7023 useWithProperties =
true;
7025 useWithProperties =
false;
7028 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 7029 if (useWithProperties) {
7030 cl_queue_properties queue_properties[] = {
7031 CL_QUEUE_PROPERTIES,
static_cast<cl_queue_properties
>(properties), 0 };
7032 object_ = ::clCreateCommandQueueWithProperties(
7033 context(), device(), queue_properties, &error);
7035 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7040 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200 7041 #if CL_HPP_MINIMUM_OPENCL_VERSION < 200 7042 if (!useWithProperties) {
7043 object_ = ::clCreateCommandQueue(
7044 context(), device(), static_cast<cl_command_queue_properties>(properties), &error);
7046 detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
7051 #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 200 7056 std::call_once(default_initialized_, makeDefault);
7057 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 7058 detail::errHandler(default_error_, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
7059 #else // CL_HPP_TARGET_OPENCL_VERSION >= 200 7060 detail::errHandler(default_error_, __CREATE_COMMAND_QUEUE_ERR);
7061 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 200 7063 *err = default_error_;
7077 std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_queue));
7078 detail::errHandler(default_error_);
7091 explicit CommandQueue(
const cl_command_queue& commandQueue,
bool retainObject =
false) :
7092 detail::Wrapper<cl_type>(commandQueue, retainObject) { }
7128 template <
typename T>
7129 cl_int getInfo(cl_command_queue_info name, T* param)
const 7131 return detail::errHandler(
7133 &::clGetCommandQueueInfo, object_, name, param),
7134 __GET_COMMAND_QUEUE_INFO_ERR);
7137 template <cl_
int name>
typename 7139 getInfo(cl_int* err = NULL)
const 7142 detail::cl_command_queue_info, name>::param_type param;
7143 cl_int result = getInfo(name, ¶m);
7150 cl_int enqueueReadBuffer(
7156 const vector<Event>* events = NULL,
7157 Event* event = NULL)
const 7160 cl_int err = detail::errHandler(
7161 ::clEnqueueReadBuffer(
7162 object_, buffer(), blocking, offset, size,
7164 (events != NULL) ? (cl_uint) events->size() : 0,
7165 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7166 (
event != NULL) ? &tmp : NULL),
7167 __ENQUEUE_READ_BUFFER_ERR);
7169 if (event != NULL && err == CL_SUCCESS)
7175 cl_int enqueueWriteBuffer(
7181 const vector<Event>* events = NULL,
7182 Event* event = NULL)
const 7185 cl_int err = detail::errHandler(
7186 ::clEnqueueWriteBuffer(
7187 object_, buffer(), blocking, offset, size,
7189 (events != NULL) ? (cl_uint) events->size() : 0,
7190 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7191 (
event != NULL) ? &tmp : NULL),
7192 __ENQUEUE_WRITE_BUFFER_ERR);
7194 if (event != NULL && err == CL_SUCCESS)
7200 cl_int enqueueCopyBuffer(
7203 size_type src_offset,
7204 size_type dst_offset,
7206 const vector<Event>* events = NULL,
7207 Event* event = NULL)
const 7210 cl_int err = detail::errHandler(
7211 ::clEnqueueCopyBuffer(
7212 object_, src(), dst(), src_offset, dst_offset, size,
7213 (events != NULL) ? (cl_uint) events->size() : 0,
7214 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7215 (
event != NULL) ? &tmp : NULL),
7216 __ENQEUE_COPY_BUFFER_ERR);
7218 if (event != NULL && err == CL_SUCCESS)
7223 #if CL_HPP_TARGET_OPENCL_VERSION >= 110 7224 cl_int enqueueReadBufferRect(
7227 const array<size_type, 3>& buffer_offset,
7228 const array<size_type, 3>& host_offset,
7229 const array<size_type, 3>& region,
7230 size_type buffer_row_pitch,
7231 size_type buffer_slice_pitch,
7232 size_type host_row_pitch,
7233 size_type host_slice_pitch,
7235 const vector<Event>* events = NULL,
7236 Event* event = NULL)
const 7239 cl_int err = detail::errHandler(
7240 ::clEnqueueReadBufferRect(
7244 buffer_offset.data(),
7252 (events != NULL) ? (cl_uint) events->size() : 0,
7253 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7254 (
event != NULL) ? &tmp : NULL),
7255 __ENQUEUE_READ_BUFFER_RECT_ERR);
7257 if (event != NULL && err == CL_SUCCESS)
7263 cl_int enqueueWriteBufferRect(
7266 const array<size_type, 3>& buffer_offset,
7267 const array<size_type, 3>& host_offset,
7268 const array<size_type, 3>& region,
7269 size_type buffer_row_pitch,
7270 size_type buffer_slice_pitch,
7271 size_type host_row_pitch,
7272 size_type host_slice_pitch,
7274 const vector<Event>* events = NULL,
7275 Event* event = NULL)
const 7278 cl_int err = detail::errHandler(
7279 ::clEnqueueWriteBufferRect(
7283 buffer_offset.data(),
7291 (events != NULL) ? (cl_uint) events->size() : 0,
7292 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7293 (
event != NULL) ? &tmp : NULL),
7294 __ENQUEUE_WRITE_BUFFER_RECT_ERR);
7296 if (event != NULL && err == CL_SUCCESS)
7302 cl_int enqueueCopyBufferRect(
7305 const array<size_type, 3>& src_origin,
7306 const array<size_type, 3>& dst_origin,
7307 const array<size_type, 3>& region,
7308 size_type src_row_pitch,
7309 size_type src_slice_pitch,
7310 size_type dst_row_pitch,
7311 size_type dst_slice_pitch,
7312 const vector<Event>* events = NULL,
7313 Event* event = NULL)
const 7316 cl_int err = detail::errHandler(
7317 ::clEnqueueCopyBufferRect(
7328 (events != NULL) ? (cl_uint) events->size() : 0,
7329 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7330 (
event != NULL) ? &tmp : NULL),
7331 __ENQEUE_COPY_BUFFER_RECT_ERR);
7333 if (event != NULL && err == CL_SUCCESS)
7338 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110 7339 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 7351 template<
typename PatternType>
7354 PatternType pattern,
7357 const vector<Event>* events = NULL,
7358 Event* event = NULL)
const 7361 cl_int err = detail::errHandler(
7362 ::clEnqueueFillBuffer(
7365 static_cast<void*>(&pattern),
7366 sizeof(PatternType),
7369 (events != NULL) ? (cl_uint) events->size() : 0,
7370 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7371 (
event != NULL) ? &tmp : NULL),
7372 __ENQUEUE_FILL_BUFFER_ERR);
7374 if (event != NULL && err == CL_SUCCESS)
7379 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 7381 cl_int enqueueReadImage(
7384 const array<size_type, 3>& origin,
7385 const array<size_type, 3>& region,
7386 size_type row_pitch,
7387 size_type slice_pitch,
7389 const vector<Event>* events = NULL,
7390 Event* event = NULL)
const 7393 cl_int err = detail::errHandler(
7394 ::clEnqueueReadImage(
7403 (events != NULL) ? (cl_uint) events->size() : 0,
7404 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7405 (
event != NULL) ? &tmp : NULL),
7406 __ENQUEUE_READ_IMAGE_ERR);
7408 if (event != NULL && err == CL_SUCCESS)
7414 cl_int enqueueWriteImage(
7417 const array<size_type, 3>& origin,
7418 const array<size_type, 3>& region,
7419 size_type row_pitch,
7420 size_type slice_pitch,
7422 const vector<Event>* events = NULL,
7423 Event* event = NULL)
const 7426 cl_int err = detail::errHandler(
7427 ::clEnqueueWriteImage(
7436 (events != NULL) ? (cl_uint) events->size() : 0,
7437 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7438 (
event != NULL) ? &tmp : NULL),
7439 __ENQUEUE_WRITE_IMAGE_ERR);
7441 if (event != NULL && err == CL_SUCCESS)
7447 cl_int enqueueCopyImage(
7450 const array<size_type, 3>& src_origin,
7451 const array<size_type, 3>& dst_origin,
7452 const array<size_type, 3>& region,
7453 const vector<Event>* events = NULL,
7454 Event* event = NULL)
const 7457 cl_int err = detail::errHandler(
7458 ::clEnqueueCopyImage(
7465 (events != NULL) ? (cl_uint) events->size() : 0,
7466 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7467 (
event != NULL) ? &tmp : NULL),
7468 __ENQUEUE_COPY_IMAGE_ERR);
7470 if (event != NULL && err == CL_SUCCESS)
7476 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 7486 cl_float4 fillColor,
7487 const array<size_type, 3>& origin,
7488 const array<size_type, 3>& region,
7489 const vector<Event>* events = NULL,
7490 Event* event = NULL)
const 7493 cl_int err = detail::errHandler(
7494 ::clEnqueueFillImage(
7497 static_cast<void*>(&fillColor),
7500 (events != NULL) ? (cl_uint) events->size() : 0,
7501 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7502 (
event != NULL) ? &tmp : NULL),
7503 __ENQUEUE_FILL_IMAGE_ERR);
7505 if (event != NULL && err == CL_SUCCESS)
7521 const array<size_type, 3>& origin,
7522 const array<size_type, 3>& region,
7523 const vector<Event>* events = NULL,
7524 Event* event = NULL)
const 7527 cl_int err = detail::errHandler(
7528 ::clEnqueueFillImage(
7531 static_cast<void*>(&fillColor),
7534 (events != NULL) ? (cl_uint) events->size() : 0,
7535 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7536 (
event != NULL) ? &tmp : NULL),
7537 __ENQUEUE_FILL_IMAGE_ERR);
7539 if (event != NULL && err == CL_SUCCESS)
7555 const array<size_type, 3>& origin,
7556 const array<size_type, 3>& region,
7557 const vector<Event>* events = NULL,
7558 Event* event = NULL)
const 7561 cl_int err = detail::errHandler(
7562 ::clEnqueueFillImage(
7565 static_cast<void*>(&fillColor),
7568 (events != NULL) ? (cl_uint) events->size() : 0,
7569 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7570 (
event != NULL) ? &tmp : NULL),
7571 __ENQUEUE_FILL_IMAGE_ERR);
7573 if (event != NULL && err == CL_SUCCESS)
7578 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 7580 cl_int enqueueCopyImageToBuffer(
7583 const array<size_type, 3>& src_origin,
7584 const array<size_type, 3>& region,
7585 size_type dst_offset,
7586 const vector<Event>* events = NULL,
7587 Event* event = NULL)
const 7590 cl_int err = detail::errHandler(
7591 ::clEnqueueCopyImageToBuffer(
7598 (events != NULL) ? (cl_uint) events->size() : 0,
7599 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7600 (
event != NULL) ? &tmp : NULL),
7601 __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR);
7603 if (event != NULL && err == CL_SUCCESS)
7609 cl_int enqueueCopyBufferToImage(
7612 size_type src_offset,
7613 const array<size_type, 3>& dst_origin,
7614 const array<size_type, 3>& region,
7615 const vector<Event>* events = NULL,
7616 Event* event = NULL)
const 7619 cl_int err = detail::errHandler(
7620 ::clEnqueueCopyBufferToImage(
7627 (events != NULL) ? (cl_uint) events->size() : 0,
7628 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7629 (
event != NULL) ? &tmp : NULL),
7630 __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR);
7632 if (event != NULL && err == CL_SUCCESS)
7638 void* enqueueMapBuffer(
7644 const vector<Event>* events = NULL,
7645 Event* event = NULL,
7646 cl_int* err = NULL)
const 7650 void * result = ::clEnqueueMapBuffer(
7651 object_, buffer(), blocking, flags, offset, size,
7652 (events != NULL) ? (cl_uint) events->size() : 0,
7653 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7654 (
event != NULL) ? &tmp : NULL,
7657 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
7661 if (event != NULL && error == CL_SUCCESS)
7667 void* enqueueMapImage(
7668 const Image& buffer,
7671 const array<size_type, 3>& origin,
7672 const array<size_type, 3>& region,
7673 size_type * row_pitch,
7674 size_type * slice_pitch,
7675 const vector<Event>* events = NULL,
7676 Event* event = NULL,
7677 cl_int* err = NULL)
const 7681 void * result = ::clEnqueueMapImage(
7682 object_, buffer(), blocking, flags,
7685 row_pitch, slice_pitch,
7686 (events != NULL) ? (cl_uint) events->size() : 0,
7687 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7688 (
event != NULL) ? &tmp : NULL,
7691 detail::errHandler(error, __ENQUEUE_MAP_IMAGE_ERR);
7695 if (event != NULL && error == CL_SUCCESS)
7700 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 7705 template<
typename T>
7711 const vector<Event>* events = NULL,
7712 Event* event = NULL)
const 7715 cl_int err = detail::errHandler(::clEnqueueSVMMap(
7716 object_, blocking, flags, static_cast<void*>(ptr), size,
7717 (events != NULL) ? (cl_uint)events->size() : 0,
7718 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
7719 (
event != NULL) ? &tmp : NULL),
7720 __ENQUEUE_MAP_BUFFER_ERR);
7722 if (event != NULL && err == CL_SUCCESS)
7733 template<
typename T,
class D>
7735 cl::pointer<T, D> &ptr,
7739 const vector<Event>* events = NULL,
7740 Event* event = NULL)
const 7743 cl_int err = detail::errHandler(::clEnqueueSVMMap(
7744 object_, blocking, flags, static_cast<void*>(ptr.get()), size,
7745 (events != NULL) ? (cl_uint)events->size() : 0,
7746 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
7747 (
event != NULL) ? &tmp : NULL),
7748 __ENQUEUE_MAP_BUFFER_ERR);
7750 if (event != NULL && err == CL_SUCCESS)
7760 template<
typename T,
class Alloc>
7762 cl::vector<T, Alloc> &container,
7765 const vector<Event>* events = NULL,
7766 Event* event = NULL)
const 7769 cl_int err = detail::errHandler(::clEnqueueSVMMap(
7770 object_, blocking, flags, static_cast<void*>(container.data()), container.size(),
7771 (events != NULL) ? (cl_uint)events->size() : 0,
7772 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
7773 (
event != NULL) ? &tmp : NULL),
7774 __ENQUEUE_MAP_BUFFER_ERR);
7776 if (event != NULL && err == CL_SUCCESS)
7781 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 7783 cl_int enqueueUnmapMemObject(
7786 const vector<Event>* events = NULL,
7787 Event* event = NULL)
const 7790 cl_int err = detail::errHandler(
7791 ::clEnqueueUnmapMemObject(
7792 object_, memory(), mapped_ptr,
7793 (events != NULL) ? (cl_uint) events->size() : 0,
7794 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7795 (
event != NULL) ? &tmp : NULL),
7796 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
7798 if (event != NULL && err == CL_SUCCESS)
7805 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 7810 template<
typename T>
7813 const vector<Event>* events = NULL,
7814 Event* event = NULL)
const 7817 cl_int err = detail::errHandler(
7818 ::clEnqueueSVMUnmap(
7819 object_, static_cast<void*>(ptr),
7820 (events != NULL) ? (cl_uint)events->size() : 0,
7821 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
7822 (
event != NULL) ? &tmp : NULL),
7823 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
7825 if (event != NULL && err == CL_SUCCESS)
7835 template<
typename T,
class D>
7837 cl::pointer<T, D> &ptr,
7838 const vector<Event>* events = NULL,
7839 Event* event = NULL)
const 7842 cl_int err = detail::errHandler(
7843 ::clEnqueueSVMUnmap(
7844 object_, static_cast<void*>(ptr.get()),
7845 (events != NULL) ? (cl_uint)events->size() : 0,
7846 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
7847 (
event != NULL) ? &tmp : NULL),
7848 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
7850 if (event != NULL && err == CL_SUCCESS)
7860 template<
typename T,
class Alloc>
7862 cl::vector<T, Alloc> &container,
7863 const vector<Event>* events = NULL,
7864 Event* event = NULL)
const 7867 cl_int err = detail::errHandler(
7868 ::clEnqueueSVMUnmap(
7869 object_, static_cast<void*>(container.data()),
7870 (events != NULL) ? (cl_uint)events->size() : 0,
7871 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
7872 (
event != NULL) ? &tmp : NULL),
7873 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
7875 if (event != NULL && err == CL_SUCCESS)
7880 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 7882 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 7895 const vector<Event> *events = 0,
7896 Event *event = 0)
const 7899 cl_int err = detail::errHandler(
7900 ::clEnqueueMarkerWithWaitList(
7902 (events != NULL) ? (cl_uint) events->size() : 0,
7903 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7904 (
event != NULL) ? &tmp : NULL),
7905 __ENQUEUE_MARKER_WAIT_LIST_ERR);
7907 if (event != NULL && err == CL_SUCCESS)
7925 const vector<Event> *events = 0,
7926 Event *event = 0)
const 7929 cl_int err = detail::errHandler(
7930 ::clEnqueueBarrierWithWaitList(
7932 (events != NULL) ? (cl_uint) events->size() : 0,
7933 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7934 (
event != NULL) ? &tmp : NULL),
7935 __ENQUEUE_BARRIER_WAIT_LIST_ERR);
7937 if (event != NULL && err == CL_SUCCESS)
7948 const vector<Memory> &memObjects,
7949 cl_mem_migration_flags flags,
7950 const vector<Event>* events = NULL,
7956 vector<cl_mem> localMemObjects(memObjects.size());
7958 for(
int i = 0; i < (int)memObjects.size(); ++i ) {
7959 localMemObjects[i] = memObjects[i]();
7963 cl_int err = detail::errHandler(
7964 ::clEnqueueMigrateMemObjects(
7966 (cl_uint)memObjects.size(),
7967 localMemObjects.data(),
7969 (events != NULL) ? (cl_uint) events->size() : 0,
7970 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7971 (
event != NULL) ? &tmp : NULL),
7972 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
7974 if (event != NULL && err == CL_SUCCESS)
7979 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 7981 cl_int enqueueNDRangeKernel(
7985 const NDRange& local = NullRange,
7986 const vector<Event>* events = NULL,
7987 Event* event = NULL)
const 7990 cl_int err = detail::errHandler(
7991 ::clEnqueueNDRangeKernel(
7992 object_, kernel(), (cl_uint) global.
dimensions(),
7993 offset.
dimensions() != 0 ? (
const size_type*) offset : NULL,
7994 (
const size_type*) global,
7995 local.
dimensions() != 0 ? (
const size_type*) local : NULL,
7996 (events != NULL) ? (cl_uint) events->size() : 0,
7997 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
7998 (
event != NULL) ? &tmp : NULL),
7999 __ENQUEUE_NDRANGE_KERNEL_ERR);
8001 if (event != NULL && err == CL_SUCCESS)
8007 #if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS) 8008 CL_EXT_PREFIX__VERSION_1_2_DEPRECATED cl_int enqueueTask(
8010 const vector<Event>* events = NULL,
8011 Event* event = NULL)
const CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED
8014 cl_int err = detail::errHandler(
8017 (events != NULL) ? (cl_uint) events->size() : 0,
8018 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8019 (
event != NULL) ? &tmp : NULL),
8020 __ENQUEUE_TASK_ERR);
8022 if (event != NULL && err == CL_SUCCESS)
8027 #endif // #if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS) 8029 cl_int enqueueNativeKernel(
8030 void (CL_CALLBACK *userFptr)(
void *),
8031 std::pair<void*, size_type> args,
8032 const vector<Memory>* mem_objects = NULL,
8033 const vector<const void*>* mem_locs = NULL,
8034 const vector<Event>* events = NULL,
8035 Event* event = NULL)
const 8037 size_type elements = 0;
8038 if (mem_objects != NULL) {
8039 elements = mem_objects->size();
8041 vector<cl_mem> mems(elements);
8042 for (
unsigned int i = 0; i < elements; i++) {
8043 mems[i] = ((*mem_objects)[i])();
8047 cl_int err = detail::errHandler(
8048 ::clEnqueueNativeKernel(
8049 object_, userFptr, args.first, args.second,
8050 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8052 (mem_locs != NULL && mem_locs->size() > 0) ? (
const void **) &mem_locs->front() : NULL,
8053 (events != NULL) ? (cl_uint) events->size() : 0,
8054 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8055 (
event != NULL) ? &tmp : NULL),
8056 __ENQUEUE_NATIVE_KERNEL);
8058 if (event != NULL && err == CL_SUCCESS)
8067 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 8068 CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
8072 cl_int err = detail::errHandler(
8075 (event != NULL) ? &tmp : NULL),
8076 __ENQUEUE_MARKER_ERR);
8078 if (event != NULL && err == CL_SUCCESS)
8084 CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
8085 cl_int enqueueWaitForEvents(
const vector<Event>& events)
const CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
8087 return detail::errHandler(
8088 ::clEnqueueWaitForEvents(
8090 (cl_uint) events.size(),
8091 events.size() > 0 ? (
const cl_event*) &events.front() : NULL),
8092 __ENQUEUE_WAIT_FOR_EVENTS_ERR);
8094 #endif // defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 8096 cl_int enqueueAcquireGLObjects(
8097 const vector<Memory>* mem_objects = NULL,
8098 const vector<Event>* events = NULL,
8099 Event* event = NULL)
const 8102 cl_int err = detail::errHandler(
8103 ::clEnqueueAcquireGLObjects(
8105 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8106 (mem_objects != NULL && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front(): NULL,
8107 (events != NULL) ? (cl_uint) events->size() : 0,
8108 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8109 (
event != NULL) ? &tmp : NULL),
8110 __ENQUEUE_ACQUIRE_GL_ERR);
8112 if (event != NULL && err == CL_SUCCESS)
8118 cl_int enqueueReleaseGLObjects(
8119 const vector<Memory>* mem_objects = NULL,
8120 const vector<Event>* events = NULL,
8121 Event* event = NULL)
const 8124 cl_int err = detail::errHandler(
8125 ::clEnqueueReleaseGLObjects(
8127 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8128 (mem_objects != NULL && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front(): NULL,
8129 (events != NULL) ? (cl_uint) events->size() : 0,
8130 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8131 (
event != NULL) ? &tmp : NULL),
8132 __ENQUEUE_RELEASE_GL_ERR);
8134 if (event != NULL && err == CL_SUCCESS)
8140 #if defined (CL_HPP_USE_DX_INTEROP) 8141 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueAcquireD3D10ObjectsKHR)(
8142 cl_command_queue command_queue, cl_uint num_objects,
8143 const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
8144 const cl_event* event_wait_list, cl_event* event);
8145 typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueReleaseD3D10ObjectsKHR)(
8146 cl_command_queue command_queue, cl_uint num_objects,
8147 const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
8148 const cl_event* event_wait_list, cl_event* event);
8150 cl_int enqueueAcquireD3D10Objects(
8151 const vector<Memory>* mem_objects = NULL,
8152 const vector<Event>* events = NULL,
8153 Event* event = NULL)
const 8155 static PFN_clEnqueueAcquireD3D10ObjectsKHR pfn_clEnqueueAcquireD3D10ObjectsKHR = NULL;
8156 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 8157 cl_context context = getInfo<CL_QUEUE_CONTEXT>();
8158 cl::Device device(getInfo<CL_QUEUE_DEVICE>());
8159 cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>();
8160 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueAcquireD3D10ObjectsKHR);
8162 #if CL_HPP_TARGET_OPENCL_VERSION >= 110 8163 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueAcquireD3D10ObjectsKHR);
8167 cl_int err = detail::errHandler(
8168 pfn_clEnqueueAcquireD3D10ObjectsKHR(
8170 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8171 (mem_objects != NULL && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front(): NULL,
8172 (events != NULL) ? (cl_uint) events->size() : 0,
8173 (events != NULL) ? (cl_event*) &events->front() : NULL,
8174 (
event != NULL) ? &tmp : NULL),
8175 __ENQUEUE_ACQUIRE_GL_ERR);
8177 if (event != NULL && err == CL_SUCCESS)
8183 cl_int enqueueReleaseD3D10Objects(
8184 const vector<Memory>* mem_objects = NULL,
8185 const vector<Event>* events = NULL,
8186 Event* event = NULL)
const 8188 static PFN_clEnqueueReleaseD3D10ObjectsKHR pfn_clEnqueueReleaseD3D10ObjectsKHR = NULL;
8189 #if CL_HPP_TARGET_OPENCL_VERSION >= 120 8190 cl_context context = getInfo<CL_QUEUE_CONTEXT>();
8191 cl::Device device(getInfo<CL_QUEUE_DEVICE>());
8192 cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>();
8193 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueReleaseD3D10ObjectsKHR);
8194 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 8195 #if CL_HPP_TARGET_OPENCL_VERSION >= 110 8196 CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueReleaseD3D10ObjectsKHR);
8197 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110 8200 cl_int err = detail::errHandler(
8201 pfn_clEnqueueReleaseD3D10ObjectsKHR(
8203 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
8204 (mem_objects != NULL && mem_objects->size() > 0) ? (
const cl_mem *) &mem_objects->front(): NULL,
8205 (events != NULL) ? (cl_uint) events->size() : 0,
8206 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8207 (
event != NULL) ? &tmp : NULL),
8208 __ENQUEUE_RELEASE_GL_ERR);
8210 if (event != NULL && err == CL_SUCCESS)
8220 #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 8221 CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
8224 return detail::errHandler(
8225 ::clEnqueueBarrier(object_),
8226 __ENQUEUE_BARRIER_ERR);
8228 #endif // CL_USE_DEPRECATED_OPENCL_1_1_APIS 8230 cl_int flush()
const 8232 return detail::errHandler(::clFlush(object_), __FLUSH_ERR);
8235 cl_int finish()
const 8237 return detail::errHandler(::clFinish(object_), __FINISH_ERR);
8241 CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag CommandQueue::default_initialized_;
8242 CL_HPP_DEFINE_STATIC_MEMBER_
CommandQueue CommandQueue::default_;
8243 CL_HPP_DEFINE_STATIC_MEMBER_ cl_int CommandQueue::default_error_ = CL_SUCCESS;
8246 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 8247 enum class DeviceQueueProperties : cl_command_queue_properties
8250 Profiling = CL_QUEUE_PROFILING_ENABLE,
8253 inline DeviceQueueProperties operator|(DeviceQueueProperties lhs, DeviceQueueProperties rhs)
8255 return static_cast<DeviceQueueProperties
>(
static_cast<cl_command_queue_properties
>(lhs) | static_cast<cl_command_queue_properties>(rhs));
8279 cl_command_queue_properties mergedProperties =
8280 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
8282 cl_queue_properties queue_properties[] = {
8283 CL_QUEUE_PROPERTIES, mergedProperties, 0 };
8284 object_ = ::clCreateCommandQueueWithProperties(
8285 context(), device(), queue_properties, &error);
8287 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8299 DeviceQueueProperties properties = DeviceQueueProperties::None,
8304 cl_command_queue_properties mergedProperties =
8305 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
8306 cl_queue_properties queue_properties[] = {
8307 CL_QUEUE_PROPERTIES, mergedProperties, 0 };
8308 object_ = ::clCreateCommandQueueWithProperties(
8309 context(), device(), queue_properties, &error);
8311 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8324 DeviceQueueProperties properties = DeviceQueueProperties::None,
8329 cl_command_queue_properties mergedProperties =
8330 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
static_cast<cl_command_queue_properties
>(properties);
8331 cl_queue_properties queue_properties[] = {
8332 CL_QUEUE_PROPERTIES, mergedProperties,
8333 CL_QUEUE_SIZE, queueSize,
8335 object_ = ::clCreateCommandQueueWithProperties(
8336 context(), device(), queue_properties, &error);
8338 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8351 detail::Wrapper<cl_type>(commandQueue, retainObject) { }
8387 template <
typename T>
8388 cl_int getInfo(cl_command_queue_info name, T* param)
const 8390 return detail::errHandler(
8392 &::clGetCommandQueueInfo, object_, name, param),
8393 __GET_COMMAND_QUEUE_INFO_ERR);
8396 template <cl_
int name>
typename 8398 getInfo(cl_int* err = NULL)
const 8401 detail::cl_command_queue_info, name>::param_type param;
8402 cl_int result = getInfo(name, ¶m);
8416 cl_int *err =
nullptr)
8422 cl_command_queue_properties properties =
8423 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
8424 cl_queue_properties queue_properties[] = {
8425 CL_QUEUE_PROPERTIES, properties,
8428 ::clCreateCommandQueueWithProperties(
8429 context(), device(), queue_properties, &error));
8431 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8446 const Context &context,
const Device &device, cl_int *err =
nullptr)
8450 cl_command_queue_properties properties =
8451 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
8452 cl_queue_properties queue_properties[] = {
8453 CL_QUEUE_PROPERTIES, properties,
8456 ::clCreateCommandQueueWithProperties(
8457 context(), device(), queue_properties, &error));
8459 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8474 const Context &context,
const Device &device, cl_uint queueSize, cl_int *err =
nullptr)
8478 cl_command_queue_properties properties =
8479 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
8480 cl_queue_properties queue_properties[] = {
8481 CL_QUEUE_PROPERTIES, properties,
8482 CL_QUEUE_SIZE, queueSize,
8485 ::clCreateCommandQueueWithProperties(
8486 context(), device(), queue_properties, &error));
8488 detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
8508 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 8511 template<
typename IteratorType >
8514 IteratorType startIterator,
8515 IteratorType endIterator,
8520 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
8523 cl_mem_flags flags = 0;
8525 flags |= CL_MEM_READ_ONLY;
8528 flags |= CL_MEM_READ_WRITE;
8531 flags |= CL_MEM_USE_HOST_PTR;
8534 size_type size =
sizeof(DataType)*(endIterator - startIterator);
8537 object_ = ::clCreateBuffer(context(), flags, size, static_cast<DataType*>(&*startIterator), &error);
8539 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
8542 detail::errHandler(error, __CREATE_BUFFER_ERR);
8549 detail::errHandler(error, __CREATE_BUFFER_ERR);
8554 error =
cl::copy(queue, startIterator, endIterator, *
this);
8555 detail::errHandler(error, __CREATE_BUFFER_ERR);
8562 template<
typename IteratorType >
8565 IteratorType startIterator,
8566 IteratorType endIterator,
8571 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
8574 cl_mem_flags flags = 0;
8576 flags |= CL_MEM_READ_ONLY;
8579 flags |= CL_MEM_READ_WRITE;
8582 flags |= CL_MEM_USE_HOST_PTR;
8585 size_type size =
sizeof(DataType)*(endIterator - startIterator);
8587 Context context = queue.getInfo<CL_QUEUE_CONTEXT>();
8590 object_ = ::clCreateBuffer(context(), flags, size, static_cast<DataType*>(&*startIterator), &error);
8593 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
8596 detail::errHandler(error, __CREATE_BUFFER_ERR);
8602 error =
cl::copy(queue, startIterator, endIterator, *
this);
8603 detail::errHandler(error, __CREATE_BUFFER_ERR);
8610 inline cl_int enqueueReadBuffer(
8616 const vector<Event>* events = NULL,
8617 Event* event = NULL)
8622 if (error != CL_SUCCESS) {
8626 return queue.enqueueReadBuffer(buffer, blocking, offset, size, ptr, events, event);
8629 inline cl_int enqueueWriteBuffer(
8635 const vector<Event>* events = NULL,
8636 Event* event = NULL)
8641 if (error != CL_SUCCESS) {
8645 return queue.enqueueWriteBuffer(buffer, blocking, offset, size, ptr, events, event);
8648 inline void* enqueueMapBuffer(
8654 const vector<Event>* events = NULL,
8655 Event* event = NULL,
8660 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
8665 void * result = ::clEnqueueMapBuffer(
8666 queue(), buffer(), blocking, flags, offset, size,
8667 (events != NULL) ? (cl_uint) events->size() : 0,
8668 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
8672 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
8680 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 8686 template<
typename T>
8692 const vector<Event>* events,
8697 if (error != CL_SUCCESS) {
8698 return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
8702 ptr, blocking, flags, size, events, event);
8710 template<
typename T,
class D>
8712 cl::pointer<T, D> ptr,
8716 const vector<Event>* events = NULL,
8717 Event* event = NULL)
8721 if (error != CL_SUCCESS) {
8722 return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
8726 ptr, blocking, flags, size, events, event);
8734 template<
typename T,
class Alloc>
8736 cl::vector<T, Alloc> container,
8739 const vector<Event>* events = NULL,
8740 Event* event = NULL)
8744 if (error != CL_SUCCESS) {
8745 return detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
8749 container, blocking, flags, events, event);
8752 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 8754 inline cl_int enqueueUnmapMemObject(
8757 const vector<Event>* events = NULL,
8758 Event* event = NULL)
8762 detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
8763 if (error != CL_SUCCESS) {
8768 cl_int err = detail::errHandler(
8769 ::clEnqueueUnmapMemObject(
8770 queue(), memory(), mapped_ptr,
8771 (events != NULL) ? (cl_uint)events->size() : 0,
8772 (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
8773 (
event != NULL) ? &tmp : NULL),
8774 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8776 if (event != NULL && err == CL_SUCCESS)
8782 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 8788 template<
typename T>
8791 const vector<Event>* events = NULL,
8792 Event* event = NULL)
8796 if (error != CL_SUCCESS) {
8797 return detail::errHandler(error, __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8801 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8810 template<
typename T,
class D>
8812 cl::pointer<T, D> &ptr,
8813 const vector<Event>* events = NULL,
8814 Event* event = NULL)
8818 if (error != CL_SUCCESS) {
8819 return detail::errHandler(error, __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8823 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8831 template<
typename T,
class Alloc>
8833 cl::vector<T, Alloc> &container,
8834 const vector<Event>* events = NULL,
8835 Event* event = NULL)
8839 if (error != CL_SUCCESS) {
8840 return detail::errHandler(error, __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8843 return detail::errHandler(queue.
enqueueUnmapSVM(container, events, event),
8844 __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
8847 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 8849 inline cl_int enqueueCopyBuffer(
8852 size_type src_offset,
8853 size_type dst_offset,
8855 const vector<Event>* events = NULL,
8856 Event* event = NULL)
8861 if (error != CL_SUCCESS) {
8865 return queue.enqueueCopyBuffer(src, dst, src_offset, dst_offset, size, events, event);
8873 template<
typename IteratorType >
8874 inline cl_int
copy( IteratorType startIterator, IteratorType endIterator,
cl::Buffer &buffer )
8878 if (error != CL_SUCCESS)
8881 return cl::copy(queue, startIterator, endIterator, buffer);
8889 template<
typename IteratorType >
8890 inline cl_int
copy(
const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator )
8894 if (error != CL_SUCCESS)
8897 return cl::copy(queue, buffer, startIterator, endIterator);
8905 template<
typename IteratorType >
8908 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
8911 size_type length = endIterator-startIterator;
8912 size_type byteLength = length*
sizeof(DataType);
8915 static_cast<DataType*
>(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_WRITE, 0, byteLength, 0, 0, &error));
8917 if( error != CL_SUCCESS ) {
8920 #if defined(_MSC_VER) 8924 stdext::checked_array_iterator<DataType*>(
8927 std::copy(startIterator, endIterator, pointer);
8930 error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
8932 if( error != CL_SUCCESS ) {
8944 template<
typename IteratorType >
8947 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
8950 size_type length = endIterator-startIterator;
8951 size_type byteLength = length*
sizeof(DataType);
8954 static_cast<DataType*
>(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_READ, 0, byteLength, 0, 0, &error));
8956 if( error != CL_SUCCESS ) {
8959 std::copy(pointer, pointer + length, startIterator);
8961 error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
8963 if( error != CL_SUCCESS ) {
8971 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 8975 template<
typename T,
class Alloc>
8976 inline cl_int
mapSVM(cl::vector<T, Alloc> &container)
8978 return enqueueMapSVM(container, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE);
8984 template<
typename T,
class Alloc>
8985 inline cl_int
unmapSVM(cl::vector<T, Alloc> &container)
8990 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 8992 #if CL_HPP_TARGET_OPENCL_VERSION >= 110 8993 inline cl_int enqueueReadBufferRect(
8996 const array<size_type, 3>& buffer_offset,
8997 const array<size_type, 3>& host_offset,
8998 const array<size_type, 3>& region,
8999 size_type buffer_row_pitch,
9000 size_type buffer_slice_pitch,
9001 size_type host_row_pitch,
9002 size_type host_slice_pitch,
9004 const vector<Event>* events = NULL,
9005 Event* event = NULL)
9010 if (error != CL_SUCCESS) {
9014 return queue.enqueueReadBufferRect(
9029 inline cl_int enqueueWriteBufferRect(
9032 const array<size_type, 3>& buffer_offset,
9033 const array<size_type, 3>& host_offset,
9034 const array<size_type, 3>& region,
9035 size_type buffer_row_pitch,
9036 size_type buffer_slice_pitch,
9037 size_type host_row_pitch,
9038 size_type host_slice_pitch,
9040 const vector<Event>* events = NULL,
9041 Event* event = NULL)
9046 if (error != CL_SUCCESS) {
9050 return queue.enqueueWriteBufferRect(
9065 inline cl_int enqueueCopyBufferRect(
9068 const array<size_type, 3>& src_origin,
9069 const array<size_type, 3>& dst_origin,
9070 const array<size_type, 3>& region,
9071 size_type src_row_pitch,
9072 size_type src_slice_pitch,
9073 size_type dst_row_pitch,
9074 size_type dst_slice_pitch,
9075 const vector<Event>* events = NULL,
9076 Event* event = NULL)
9081 if (error != CL_SUCCESS) {
9085 return queue.enqueueCopyBufferRect(
9098 #endif // CL_HPP_TARGET_OPENCL_VERSION >= 110 9100 inline cl_int enqueueReadImage(
9103 const array<size_type, 3>& origin,
9104 const array<size_type, 3>& region,
9105 size_type row_pitch,
9106 size_type slice_pitch,
9108 const vector<Event>* events = NULL,
9109 Event* event = NULL)
9114 if (error != CL_SUCCESS) {
9118 return queue.enqueueReadImage(
9130 inline cl_int enqueueWriteImage(
9133 const array<size_type, 3>& origin,
9134 const array<size_type, 3>& region,
9135 size_type row_pitch,
9136 size_type slice_pitch,
9138 const vector<Event>* events = NULL,
9139 Event* event = NULL)
9144 if (error != CL_SUCCESS) {
9148 return queue.enqueueWriteImage(
9160 inline cl_int enqueueCopyImage(
9163 const array<size_type, 3>& src_origin,
9164 const array<size_type, 3>& dst_origin,
9165 const array<size_type, 3>& region,
9166 const vector<Event>* events = NULL,
9167 Event* event = NULL)
9172 if (error != CL_SUCCESS) {
9176 return queue.enqueueCopyImage(
9186 inline cl_int enqueueCopyImageToBuffer(
9189 const array<size_type, 3>& src_origin,
9190 const array<size_type, 3>& region,
9191 size_type dst_offset,
9192 const vector<Event>* events = NULL,
9193 Event* event = NULL)
9198 if (error != CL_SUCCESS) {
9202 return queue.enqueueCopyImageToBuffer(
9212 inline cl_int enqueueCopyBufferToImage(
9215 size_type src_offset,
9216 const array<size_type, 3>& dst_origin,
9217 const array<size_type, 3>& region,
9218 const vector<Event>* events = NULL,
9219 Event* event = NULL)
9224 if (error != CL_SUCCESS) {
9228 return queue.enqueueCopyBufferToImage(
9239 inline cl_int flush(
void)
9244 if (error != CL_SUCCESS) {
9248 return queue.flush();
9251 inline cl_int finish(
void)
9256 if (error != CL_SUCCESS) {
9261 return queue.finish();
9271 vector<Event> events_;
9273 template<
typename... Ts>
9278 queue_(CommandQueue::getDefault()),
9287 queue_(CommandQueue::getDefault()),
9296 queue_(CommandQueue::getDefault()),
9305 queue_(CommandQueue::getDefault()),
9310 events_.push_back(e);
9314 queue_(CommandQueue::getDefault()),
9319 events_.push_back(e);
9323 queue_(CommandQueue::getDefault()),
9328 events_.push_back(e);
9332 queue_(CommandQueue::getDefault()),
9342 queue_(CommandQueue::getDefault()),
9352 queue_(CommandQueue::getDefault()),
9394 events_.push_back(e);
9403 events_.push_back(e);
9412 events_.push_back(e);
9454 template<
typename... Ts>
9460 template<
int index,
typename T0,
typename... T1s>
9461 void setArgs(T0&& t0, T1s&&... t1s)
9463 kernel_.
setArg(index, t0);
9464 setArgs<index + 1, T1s...>(std::forward<T1s>(t1s)...);
9467 template<
int index,
typename T0>
9468 void setArgs(T0&& t0)
9470 kernel_.
setArg(index, t0);
9486 cl_int * err = NULL) :
9487 kernel_(program, name.c_str(), err)
9503 setArgs<0>(std::forward<Ts>(ts)...);
9505 args.queue_.enqueueNDRangeKernel(
9528 setArgs<0>(std::forward<Ts>(ts)...);
9530 error = args.queue_.enqueueNDRangeKernel(
9541 #if CL_HPP_TARGET_OPENCL_VERSION >= 200 9542 cl_int setSVMPointers(
const vector<void*> &pointerList)
9547 template<
typename T0,
typename... T1s>
9548 cl_int setSVMPointers(
const T0 &t0, T1s &... ts)
9552 #endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200 9560 namespace compatibility {
9565 template<
typename... Ts>
9575 cl_int * err = NULL) :
9597 enqueueArgs, args...);
9605 #undef CL_HPP_ERR_STR_ 9606 #if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS) 9607 #undef __GET_DEVICE_INFO_ERR 9608 #undef __GET_PLATFORM_INFO_ERR 9609 #undef __GET_DEVICE_IDS_ERR 9610 #undef __GET_CONTEXT_INFO_ERR 9611 #undef __GET_EVENT_INFO_ERR 9612 #undef __GET_EVENT_PROFILE_INFO_ERR 9613 #undef __GET_MEM_OBJECT_INFO_ERR 9614 #undef __GET_IMAGE_INFO_ERR 9615 #undef __GET_SAMPLER_INFO_ERR 9616 #undef __GET_KERNEL_INFO_ERR 9617 #undef __GET_KERNEL_ARG_INFO_ERR 9618 #undef __GET_KERNEL_WORK_GROUP_INFO_ERR 9619 #undef __GET_PROGRAM_INFO_ERR 9620 #undef __GET_PROGRAM_BUILD_INFO_ERR 9621 #undef __GET_COMMAND_QUEUE_INFO_ERR 9623 #undef __CREATE_CONTEXT_ERR 9624 #undef __CREATE_CONTEXT_FROM_TYPE_ERR 9625 #undef __GET_SUPPORTED_IMAGE_FORMATS_ERR 9627 #undef __CREATE_BUFFER_ERR 9628 #undef __CREATE_SUBBUFFER_ERR 9629 #undef __CREATE_IMAGE2D_ERR 9630 #undef __CREATE_IMAGE3D_ERR 9631 #undef __CREATE_SAMPLER_ERR 9632 #undef __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR 9634 #undef __CREATE_USER_EVENT_ERR 9635 #undef __SET_USER_EVENT_STATUS_ERR 9636 #undef __SET_EVENT_CALLBACK_ERR 9637 #undef __SET_PRINTF_CALLBACK_ERR 9639 #undef __WAIT_FOR_EVENTS_ERR 9641 #undef __CREATE_KERNEL_ERR 9642 #undef __SET_KERNEL_ARGS_ERR 9643 #undef __CREATE_PROGRAM_WITH_SOURCE_ERR 9644 #undef __CREATE_PROGRAM_WITH_BINARY_ERR 9645 #undef __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR 9646 #undef __BUILD_PROGRAM_ERR 9647 #undef __CREATE_KERNELS_IN_PROGRAM_ERR 9649 #undef __CREATE_COMMAND_QUEUE_ERR 9650 #undef __SET_COMMAND_QUEUE_PROPERTY_ERR 9651 #undef __ENQUEUE_READ_BUFFER_ERR 9652 #undef __ENQUEUE_WRITE_BUFFER_ERR 9653 #undef __ENQUEUE_READ_BUFFER_RECT_ERR 9654 #undef __ENQUEUE_WRITE_BUFFER_RECT_ERR 9655 #undef __ENQEUE_COPY_BUFFER_ERR 9656 #undef __ENQEUE_COPY_BUFFER_RECT_ERR 9657 #undef __ENQUEUE_READ_IMAGE_ERR 9658 #undef __ENQUEUE_WRITE_IMAGE_ERR 9659 #undef __ENQUEUE_COPY_IMAGE_ERR 9660 #undef __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR 9661 #undef __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR 9662 #undef __ENQUEUE_MAP_BUFFER_ERR 9663 #undef __ENQUEUE_MAP_IMAGE_ERR 9664 #undef __ENQUEUE_UNMAP_MEM_OBJECT_ERR 9665 #undef __ENQUEUE_NDRANGE_KERNEL_ERR 9666 #undef __ENQUEUE_TASK_ERR 9667 #undef __ENQUEUE_NATIVE_KERNEL 9669 #undef __UNLOAD_COMPILER_ERR 9670 #undef __CREATE_SUB_DEVICES_ERR 9672 #undef __CREATE_PIPE_ERR 9673 #undef __GET_PIPE_INFO_ERR 9675 #endif //CL_HPP_USER_OVERRIDE_ERROR_STRINGS 9678 #undef CL_HPP_INIT_CL_EXT_FCN_PTR_ 9679 #undef CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_ 9681 #if defined(CL_HPP_USE_CL_DEVICE_FISSION) 9682 #undef CL_HPP_PARAM_NAME_DEVICE_FISSION_ 9683 #endif // CL_HPP_USE_CL_DEVICE_FISSION 9685 #undef CL_HPP_NOEXCEPT_ 9686 #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().