From e2fc1763c39e2913884db73c83083178049ed627 Mon Sep 17 00:00:00 2001 From: Ben Ashbaugh Date: Thu, 24 Sep 2026 10:56:05 -0700 Subject: [PATCH] sync with the latest OpenCL C++ bindings include fixes for 0 as a null pointer warnings --- include/CL/opencl.hpp | 624 ++++++++++++++++------------- samples/usm/01_usmmeminfo/main.cpp | 2 +- 2 files changed, 346 insertions(+), 280 deletions(-) diff --git a/include/CL/opencl.hpp b/include/CL/opencl.hpp index f7b63e45..1a8268df 100644 --- a/include/CL/opencl.hpp +++ b/include/CL/opencl.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2008-2024 The Khronos Group Inc. +// Copyright (c) 2008-2026 The Khronos Group Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -81,7 +81,7 @@ * The combination of preprocessor macros CL_HPP_TARGET_OPENCL_VERSION and * CL_HPP_MINIMUM_OPENCL_VERSION control this range. These are three digit * decimal values representing OpenCL runtime versions. The default for - * the target is 300, representing OpenCL 3.0. The minimum is defined as 200. + * the target is 310, representing OpenCL 3.1. The minimum is defined as 200. * These settings would use 2.0 and newer API calls only. * If backward compatibility with a 1.2 runtime is required, the minimum * version may be set to 120. @@ -137,7 +137,7 @@ * - CL_HPP_TARGET_OPENCL_VERSION * * Defines the target OpenCL runtime version to build the header - * against. Defaults to 300, representing OpenCL 3.0. + * against. Defaults to 310, representing OpenCL 3.1. * * - CL_HPP_MINIMUM_OPENCL_VERSION * @@ -450,8 +450,8 @@ /* Detect which version to target */ #if !defined(CL_HPP_TARGET_OPENCL_VERSION) -# pragma message("opencl.hpp: CL_HPP_TARGET_OPENCL_VERSION is not defined. It will default to 300 (OpenCL 3.0)") -# define CL_HPP_TARGET_OPENCL_VERSION 300 +# pragma message("opencl.hpp: CL_HPP_TARGET_OPENCL_VERSION is not defined. It will default to 310 (OpenCL 3.1)") +# define CL_HPP_TARGET_OPENCL_VERSION 310 #endif #if CL_HPP_TARGET_OPENCL_VERSION != 100 && \ CL_HPP_TARGET_OPENCL_VERSION != 110 && \ @@ -459,10 +459,11 @@ CL_HPP_TARGET_OPENCL_VERSION != 200 && \ CL_HPP_TARGET_OPENCL_VERSION != 210 && \ CL_HPP_TARGET_OPENCL_VERSION != 220 && \ - CL_HPP_TARGET_OPENCL_VERSION != 300 -# pragma message("opencl.hpp: CL_HPP_TARGET_OPENCL_VERSION is not a valid value (100, 110, 120, 200, 210, 220 or 300). It will be set to 300 (OpenCL 3.0).") + CL_HPP_TARGET_OPENCL_VERSION != 300 && \ + CL_HPP_TARGET_OPENCL_VERSION != 310 +# pragma message("opencl.hpp: CL_HPP_TARGET_OPENCL_VERSION is not a valid value (100, 110, 120, 200, 210, 220, 300 or 310). It will be set to 310 (OpenCL 3.1).") # undef CL_HPP_TARGET_OPENCL_VERSION -# define CL_HPP_TARGET_OPENCL_VERSION 300 +# define CL_HPP_TARGET_OPENCL_VERSION 310 #endif /* Forward target OpenCL version to C headers if necessary */ @@ -485,8 +486,9 @@ CL_HPP_MINIMUM_OPENCL_VERSION != 200 && \ CL_HPP_MINIMUM_OPENCL_VERSION != 210 && \ CL_HPP_MINIMUM_OPENCL_VERSION != 220 && \ - CL_HPP_MINIMUM_OPENCL_VERSION != 300 -# pragma message("opencl.hpp: CL_HPP_MINIMUM_OPENCL_VERSION is not a valid value (100, 110, 120, 200, 210, 220 or 300). It will be set to 100") + CL_HPP_MINIMUM_OPENCL_VERSION != 300 && \ + CL_HPP_MINIMUM_OPENCL_VERSION != 310 +# pragma message("opencl.hpp: CL_HPP_MINIMUM_OPENCL_VERSION is not a valid value (100, 110, 120, 200, 210, 220, 300 or 310). It will be set to 100") # undef CL_HPP_MINIMUM_OPENCL_VERSION # define CL_HPP_MINIMUM_OPENCL_VERSION 100 #endif @@ -842,6 +844,9 @@ static inline cl_int errHandler (cl_int err, const char * errStr = nullptr) #define __GET_KERNEL_SUB_GROUP_INFO_ERR CL_HPP_ERR_STR_(clGetKernelSubGroupInfoKHR) #endif // CL_HPP_TARGET_OPENCL_VERSION >= 210 #define __GET_KERNEL_WORK_GROUP_INFO_ERR CL_HPP_ERR_STR_(clGetKernelWorkGroupInfo) +#if CL_HPP_TARGET_OPENCL_VERSION >= 310 +#define __GET_KERNEL_SUGGESTED_LWS_ERR CL_HPP_ERR_STR_(clGetKernelSuggestedLocalWorkSize) +#endif // CL_HPP_TARGET_OPENCL_VERSION >= 310 #define __GET_PROGRAM_INFO_ERR CL_HPP_ERR_STR_(clGetProgramInfo) #define __GET_PROGRAM_BUILD_INFO_ERR CL_HPP_ERR_STR_(clGetProgramBuildInfo) #define __GET_COMMAND_QUEUE_INFO_ERR CL_HPP_ERR_STR_(clGetCommandQueueInfo) @@ -850,14 +855,14 @@ static inline cl_int errHandler (cl_int err, const char * errStr = nullptr) #define __CREATE_CONTEXT_FROM_TYPE_ERR CL_HPP_ERR_STR_(clCreateContextFromType) #define __GET_SUPPORTED_IMAGE_FORMATS_ERR CL_HPP_ERR_STR_(clGetSupportedImageFormats) #if CL_HPP_TARGET_OPENCL_VERSION >= 300 -#define __SET_CONTEXT_DESCTRUCTOR_CALLBACK_ERR CL_HPP_ERR_STR_(clSetContextDestructorCallback) +#define __SET_CONTEXT_DESTRUCTOR_CALLBACK_ERR CL_HPP_ERR_STR_(clSetContextDestructorCallback) #endif // CL_HPP_TARGET_OPENCL_VERSION >= 300 #define __CREATE_BUFFER_ERR CL_HPP_ERR_STR_(clCreateBuffer) #define __COPY_ERR CL_HPP_ERR_STR_(cl::copy) #define __CREATE_SUBBUFFER_ERR CL_HPP_ERR_STR_(clCreateSubBuffer) #define __CREATE_GL_BUFFER_ERR CL_HPP_ERR_STR_(clCreateFromGLBuffer) -#define __CREATE_GL_RENDER_BUFFER_ERR CL_HPP_ERR_STR_(clCreateFromGLBuffer) +#define __CREATE_GL_RENDER_BUFFER_ERR CL_HPP_ERR_STR_(clCreateFromGLRenderbuffer) #define __GET_GL_OBJECT_INFO_ERR CL_HPP_ERR_STR_(clGetGLObjectInfo) #if CL_HPP_TARGET_OPENCL_VERSION >= 120 #define __CREATE_IMAGE_ERR CL_HPP_ERR_STR_(clCreateImage) @@ -1127,7 +1132,7 @@ inline cl_int getInfoHelper(Func f, cl_uint name, vector* param, long) */ template inline cl_int getInfoHelper( - Func f, cl_uint name, vector* param, int, typename T::cl_type = 0) + Func f, cl_uint name, vector* param, int, typename T::cl_type = {}) { size_type required; cl_int err = f(name, 0, nullptr, &required); @@ -1223,7 +1228,7 @@ template struct ReferenceHandler; * template will provide a better match. */ template -inline cl_int getInfoHelper(Func f, cl_uint name, T* param, int, typename T::cl_type = 0) +inline cl_int getInfoHelper(Func f, cl_uint name, T* param, int, typename T::cl_type = {}) { typename T::cl_type value; cl_int err = f(name, sizeof(value), &value, nullptr); @@ -1367,6 +1372,7 @@ inline cl_int getInfoHelper(Func f, cl_uint name, T* param, int, typename T::cl_ #define CL_HPP_PARAM_NAME_INFO_1_1_(F) \ F(cl_context_info, CL_CONTEXT_NUM_DEVICES, cl_uint)\ F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF, cl_uint) \ + F(cl_device_info, CL_DEVICE_HOST_UNIFIED_MEMORY, cl_bool) \ F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR, cl_uint) \ F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT, cl_uint) \ F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_INT, cl_uint) \ @@ -1618,9 +1624,6 @@ CL_HPP_PARAM_NAME_INFO_IL_KHR_(CL_HPP_DECLARE_PARAM_TRAITS_) #define CL_HPP_PARAM_NAME_INFO_1_0_DEPRECATED_IN_2_0_(F) \ F(cl_device_info, CL_DEVICE_QUEUE_PROPERTIES, cl_command_queue_properties) -#define CL_HPP_PARAM_NAME_INFO_1_1_DEPRECATED_IN_2_0_(F) \ - F(cl_device_info, CL_DEVICE_HOST_UNIFIED_MEMORY, cl_bool) - #define CL_HPP_PARAM_NAME_INFO_1_2_DEPRECATED_IN_2_0_(F) \ F(cl_image_info, CL_IMAGE_BUFFER, cl::Buffer) @@ -1629,9 +1632,6 @@ CL_HPP_PARAM_NAME_INFO_IL_KHR_(CL_HPP_DECLARE_PARAM_TRAITS_) #if CL_HPP_TARGET_OPENCL_VERSION > 100 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 && CL_HPP_TARGET_OPENCL_VERSION < 200 CL_HPP_PARAM_NAME_INFO_1_0_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_) #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 110 -#if CL_HPP_TARGET_OPENCL_VERSION > 110 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 -CL_HPP_PARAM_NAME_INFO_1_1_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_) -#endif // CL_HPP_MINIMUM_OPENCL_VERSION < 120 #if CL_HPP_TARGET_OPENCL_VERSION > 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 CL_HPP_PARAM_NAME_INFO_1_2_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_) #endif // CL_HPP_MINIMUM_OPENCL_VERSION < 200 @@ -2779,12 +2779,9 @@ class Platform : public detail::Wrapper */ cl_int getDevices( cl_device_type type, - vector* devices) const + vector& devices) const { cl_uint n = 0; - if( devices == nullptr ) { - return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR); - } cl_int err = CL_(clGetDeviceIDs)(object_, type, 0, nullptr, &n); if (err != CL_SUCCESS && err != CL_DEVICE_NOT_FOUND) { return detail::errHandler(err, __GET_DEVICE_IDS_ERR); @@ -2802,18 +2799,31 @@ class Platform : public detail::Wrapper // with safe construction // We must retain things we obtain from the API to avoid releasing // API-owned objects. - if (devices) { - devices->resize(ids.size()); + devices.resize(ids.size()); - // Assign to param, constructing with retain behaviour - // to correctly capture each underlying CL object - for (size_type i = 0; i < ids.size(); i++) { - (*devices)[i] = Device(ids[i], true); - } + // Assign to param, constructing with retain behaviour + // to correctly capture each underlying CL object + for (size_type i = 0; i < ids.size(); i++) { + devices[i] = Device(ids[i], true); } return CL_SUCCESS; } + /*! \brief Gets a list of devices for this platform. + * + * Pointer overload for backwards compatibility. + */ + cl_int getDevices( + cl_device_type type, + vector* devices) const + { + if( devices == nullptr ) { + return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR); + } + + return getDevices(type, *devices); + } + #if defined(CL_HPP_USE_DX_INTEROP) /*! \brief Get the list of available D3D10 devices. * @@ -2842,7 +2852,7 @@ class Platform : public detail::Wrapper cl_d3d10_device_source_khr d3d_device_source, void * d3d_object, cl_d3d10_device_set_khr d3d_device_set, - vector* devices) const + vector& devices) const { typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clGetDeviceIDsFromD3D10KHR)( cl_platform_id platform, @@ -2853,10 +2863,6 @@ class Platform : public detail::Wrapper cl_device_id * devices, cl_uint* num_devices); - if( devices == nullptr ) { - return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR); - } - static PFN_clGetDeviceIDsFromD3D10KHR pfn_clGetDeviceIDsFromD3D10KHR = nullptr; #if CL_HPP_TARGET_OPENCL_VERSION >= 120 CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(object_, clGetDeviceIDsFromD3D10KHR); @@ -2895,17 +2901,32 @@ class Platform : public detail::Wrapper // with safe construction // We must retain things we obtain from the API to avoid releasing // API-owned objects. - if (devices) { - devices->resize(ids.size()); + devices.resize(ids.size()); - // Assign to param, constructing with retain behaviour - // to correctly capture each underlying CL object - for (size_type i = 0; i < ids.size(); i++) { - (*devices)[i] = Device(ids[i], true); - } + // Assign to param, constructing with retain behaviour + // to correctly capture each underlying CL object + for (size_type i = 0; i < ids.size(); i++) { + devices[i] = Device(ids[i], true); } return CL_SUCCESS; } + + /*! \brief Get the list of available D3D10 devices. + * + * Pointer overload for backwards compatibility. + */ + cl_int getDevices( + cl_d3d10_device_source_khr d3d_device_source, + void * d3d_object, + cl_d3d10_device_set_khr d3d_device_set, + vector* devices) const + { + if( devices == nullptr ) { + return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR); + } + + return getDevices(d3d_device_source, d3d_object, d3d_device_set, *devices); + } #endif /*! \brief Gets a list of available platforms. @@ -2913,14 +2934,10 @@ class Platform : public detail::Wrapper * Wraps clGetPlatformIDs(). */ static cl_int get( - vector* platforms) + vector& platforms) { cl_uint n = 0; - if( platforms == nullptr ) { - return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_PLATFORM_IDS_ERR); - } - cl_int err = CL_(clGetPlatformIDs)(0, nullptr, &n); if (err != CL_SUCCESS) { return detail::errHandler(err, __GET_PLATFORM_IDS_ERR); @@ -2932,17 +2949,29 @@ class Platform : public detail::Wrapper return detail::errHandler(err, __GET_PLATFORM_IDS_ERR); } - if (platforms) { - platforms->resize(ids.size()); + platforms.resize(ids.size()); - // Platforms don't reference count - for (size_type i = 0; i < ids.size(); i++) { - (*platforms)[i] = Platform(ids[i]); - } + // Platforms don't reference count + for (size_type i = 0; i < ids.size(); i++) { + platforms[i] = Platform(ids[i]); } return CL_SUCCESS; } + /*! \brief Gets a list of available platforms. + * + * Pointer overload for backwards compatibility. + */ + static cl_int get( + vector* platforms) + { + if( platforms == nullptr ) { + return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_PLATFORM_IDS_ERR); + } + + return get(*platforms); + } + /*! \brief Gets the first available platform. * * Wraps clGetPlatformIDs(), returning the first result. @@ -3202,12 +3231,12 @@ class Context void* param_value, size_type* param_value_size_ret) { - #if CL_HPP_TARGET_OPENCL_VERSION >= 120 Device device = context.getInfo().at(0); cl_platform_id platform = device.getInfo()(); CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clGetImageRequirementsInfoEXT); -#else +#endif +#if CL_HPP_MINIMUM_OPENCL_VERSION < 120 CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetImageRequirementsInfoEXT); #endif @@ -3261,8 +3290,9 @@ class Context } object_ = CL_(clCreateContext)( - properties, (cl_uint) numDevices, - deviceIDs.data(), + properties, + (cl_uint)deviceIDs.size(), + deviceIDs.empty() ? nullptr : deviceIDs.data(), notifyFptr, data, &error); detail::errHandler(error, __CREATE_CONTEXT_ERR); @@ -3469,13 +3499,9 @@ class Context cl_int getSupportedImageFormats( cl_mem_flags flags, cl_mem_object_type type, - vector* formats) const + vector& formats) const { cl_uint numEntries; - - if (!formats) { - return CL_SUCCESS; - } cl_int err = CL_(clGetSupportedImageFormats)( object_, @@ -3501,16 +3527,31 @@ class Context return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR); } - formats->assign(value.begin(), value.end()); + formats.assign(value.begin(), value.end()); } else { // If no values are being returned, ensure an empty vector comes back - formats->clear(); + formats.clear(); } return CL_SUCCESS; } + /*! \brief Gets a list of supported image formats. + * + * Pointer overload for backwards compatibility. + */ + cl_int getSupportedImageFormats( + cl_mem_flags flags, + cl_mem_object_type type, + vector* formats) const + { + if( formats == nullptr ) { + return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_SUPPORTED_IMAGE_FORMATS_ERR); + } + return getSupportedImageFormats(flags, type, *formats); + } + #if defined(cl_ext_image_requirements_info) template cl_int getImageRequirementsInfoExt(cl_image_requirements_info_ext name, @@ -3566,7 +3607,7 @@ class Context object_, pfn_notify, user_data), - __SET_CONTEXT_DESCTRUCTOR_CALLBACK_ERR); + __SET_CONTEXT_DESTRUCTOR_CALLBACK_ERR); } #endif // CL_HPP_TARGET_OPENCL_VERSION >= 300 }; @@ -4061,7 +4102,7 @@ class SVMAllocator { */ pointer allocate( size_type size, - typename cl::SVMAllocator::const_pointer = 0, + typename cl::SVMAllocator::const_pointer = nullptr, bool map = true) { // Allocate memory with default alignment matching the size of the type @@ -4322,21 +4363,17 @@ class Buffer : public Memory { cl_int error; - if (properties.empty()) { - object_ = CL_(clCreateBufferWithProperties)(context(), nullptr, flags, - size, host_ptr, &error); - } - else { - object_ = CL_(clCreateBufferWithProperties)( - context(), properties.data(), flags, size, host_ptr, &error); - } + object_ = CL_(clCreateBufferWithProperties)( + context(), + properties.empty() ? nullptr : properties.data(), + flags, size, host_ptr, &error); detail::errHandler(error, __CREATE_BUFFER_ERR); if (err != nullptr) { *err = error; } } -#endif +#endif // CL_HPP_TARGET_OPENCL_VERSION >= 300 /*! \brief Constructs a Buffer in the default context. * @@ -4372,7 +4409,7 @@ class Buffer : public Memory size_type size, void* host_ptr = nullptr, cl_int* err = nullptr) : Buffer(Context::getDefault(err), properties, flags, size, host_ptr, err) { } -#endif +#endif // CL_HPP_TARGET_OPENCL_VERSION >= 300 /*! * \brief Construct a Buffer from a host container via iterators. @@ -4408,7 +4445,7 @@ class Buffer : public Memory if( useHostPtr ) { object_ = CL_(clCreateBuffer)(context(), flags, size, const_cast(&*startIterator), &error); } else { - object_ = CL_(clCreateBuffer)(context(), flags, size, 0, &error); + object_ = CL_(clCreateBuffer)(context(), flags, size, nullptr, &error); } detail::errHandler(error, __CREATE_BUFFER_ERR); @@ -4834,28 +4871,25 @@ class Image1D : public Image */ Image1D(const Context &context, const vector &properties, cl_mem_flags flags, ImageFormat format, size_type width, - void *host_ptr = nullptr, cl_int *err = nullptr) { - cl_int error; + void *host_ptr = nullptr, cl_int *err = nullptr) + { + cl_int error; - cl_image_desc desc = {}; - desc.image_type = CL_MEM_OBJECT_IMAGE1D; - desc.image_width = width; + cl_image_desc desc = {}; + desc.image_type = CL_MEM_OBJECT_IMAGE1D; + desc.image_width = width; - if (properties.empty()) { object_ = CL_(clCreateImageWithProperties)( - context(), nullptr, flags, &format, &desc, host_ptr, &error); - } else { - object_ = - CL_(clCreateImageWithProperties)(context(), properties.data(), flags, - &format, &desc, host_ptr, &error); - } - - detail::errHandler(error, __CREATE_IMAGE_ERR); - if (err != nullptr) { - *err = error; - } + context(), + properties.empty() ? nullptr : properties.data(), + flags, &format, &desc, host_ptr, &error); + + detail::errHandler(error, __CREATE_IMAGE_ERR); + if (err != nullptr) { + *err = error; + } } -#endif //#if CL_HPP_TARGET_OPENCL_VERSION >= 300 +#endif // CL_HPP_TARGET_OPENCL_VERSION >= 300 /*! \brief Constructor from cl_mem - takes ownership. * @@ -4930,29 +4964,26 @@ class Image1DBuffer : public Image Image1DBuffer(const Context &context, const vector &properties, cl_mem_flags flags, ImageFormat format, size_type width, - const Buffer &buffer, cl_int *err = nullptr) { - cl_int error; + const Buffer &buffer, cl_int *err = nullptr) + { + cl_int error; - cl_image_desc desc = {}; - desc.image_type = CL_MEM_OBJECT_IMAGE1D_BUFFER; - desc.image_width = width; - desc.buffer = buffer(); + cl_image_desc desc = {}; + desc.image_type = CL_MEM_OBJECT_IMAGE1D_BUFFER; + desc.image_width = width; + desc.buffer = buffer(); - if (properties.empty()) { object_ = CL_(clCreateImageWithProperties)( - context(), nullptr, flags, &format, &desc, nullptr, &error); - } else { - object_ = - CL_(clCreateImageWithProperties)(context(), properties.data(), flags, - &format, &desc, nullptr, &error); - } - - detail::errHandler(error, __CREATE_IMAGE_ERR); - if (err != nullptr) { - *err = error; - } + context(), + properties.empty() ? nullptr : properties.data(), + flags, &format, &desc, nullptr, &error); + + detail::errHandler(error, __CREATE_IMAGE_ERR); + if (err != nullptr) { + *err = error; + } } -#endif //#if CL_HPP_TARGET_OPENCL_VERSION >= 300 +#endif // CL_HPP_TARGET_OPENCL_VERSION >= 300 /*! \brief Constructor from cl_mem - takes ownership. * @@ -5026,30 +5057,27 @@ class Image1DArray : public Image const vector &properties, cl_mem_flags flags, ImageFormat format, size_type arraySize, size_type width, size_type rowPitch = 0, - void *host_ptr = nullptr, cl_int *err = nullptr) { - cl_int error; + void *host_ptr = nullptr, cl_int *err = nullptr) + { + cl_int error; - cl_image_desc desc = {}; - desc.image_type = CL_MEM_OBJECT_IMAGE1D_ARRAY; - desc.image_width = width; - desc.image_array_size = arraySize; - desc.image_row_pitch = rowPitch; + cl_image_desc desc = {}; + desc.image_type = CL_MEM_OBJECT_IMAGE1D_ARRAY; + desc.image_width = width; + desc.image_array_size = arraySize; + desc.image_row_pitch = rowPitch; - if (properties.empty()) { object_ = CL_(clCreateImageWithProperties)( - context(), nullptr, flags, &format, &desc, host_ptr, &error); - } else { - object_ = - CL_(clCreateImageWithProperties)(context(), properties.data(), flags, - &format, &desc, host_ptr, &error); - } - - detail::errHandler(error, __CREATE_IMAGE_ERR); - if (err != nullptr) { - *err = error; - } + context(), + properties.empty() ? nullptr : properties.data(), + flags, &format, &desc, host_ptr, &error); + + detail::errHandler(error, __CREATE_IMAGE_ERR); + if (err != nullptr) { + *err = error; + } } -#endif //#if CL_HPP_TARGET_OPENCL_VERSION >= 300 +#endif // CL_HPP_TARGET_OPENCL_VERSION >= 300 /*! \brief Constructor from cl_mem - takes ownership. * @@ -5251,7 +5279,7 @@ class Image2D : public Image *err = error; } } -#endif //#if CL_HPP_TARGET_OPENCL_VERSION >= 200 +#endif // CL_HPP_TARGET_OPENCL_VERSION >= 200 #if CL_HPP_TARGET_OPENCL_VERSION >= 300 /*! \brief Constructs a Image2D with specified properties. @@ -5267,28 +5295,25 @@ class Image2D : public Image Image2D(const Context &context, const vector &properties, cl_mem_flags flags, ImageFormat format, size_type width, size_type height, size_type row_pitch = 0, void *host_ptr = nullptr, - cl_int *err = nullptr) { - cl_int error; + cl_int *err = nullptr) + { + cl_int error; - cl_image_desc desc = {}; - desc.image_type = CL_MEM_OBJECT_IMAGE2D; - desc.image_width = width; - desc.image_height = height; - desc.image_row_pitch = row_pitch; + cl_image_desc desc = {}; + desc.image_type = CL_MEM_OBJECT_IMAGE2D; + desc.image_width = width; + desc.image_height = height; + desc.image_row_pitch = row_pitch; - if (properties.empty()) { object_ = CL_(clCreateImageWithProperties)( - context(), nullptr, flags, &format, &desc, host_ptr, &error); - } else { - object_ = - CL_(clCreateImageWithProperties)(context(), properties.data(), flags, - &format, &desc, host_ptr, &error); - } - - detail::errHandler(error, __CREATE_IMAGE_ERR); - if (err != nullptr) { - *err = error; - } + context(), + properties.empty() ? nullptr : properties.data(), + flags, &format, &desc, host_ptr, &error); + + detail::errHandler(error, __CREATE_IMAGE_ERR); + if (err != nullptr) { + *err = error; + } } /*! \brief Constructs a Image2D with specified properties. @@ -5303,32 +5328,29 @@ class Image2D : public Image Image2D(const Context &context, const vector &properties, cl_mem_flags flags, ImageFormat format, const Buffer &buffer, size_type width, size_type height, size_type row_pitch = 0, - cl_int *err = nullptr) { - cl_int error; + cl_int *err = nullptr) + { + cl_int error; - cl_image_desc desc = {}; - desc.image_type = CL_MEM_OBJECT_IMAGE2D; - desc.image_width = width; - desc.image_height = height; - desc.image_row_pitch = row_pitch; - desc.buffer = buffer(); + cl_image_desc desc = {}; + desc.image_type = CL_MEM_OBJECT_IMAGE2D; + desc.image_width = width; + desc.image_height = height; + desc.image_row_pitch = row_pitch; + desc.buffer = buffer(); - if (properties.empty()) { object_ = CL_(clCreateImageWithProperties)( - context(), nullptr, flags, &format, &desc, nullptr, &error); - } else { - object_ = - CL_(clCreateImageWithProperties)(context(), properties.data(), flags, - &format, &desc, nullptr, &error); - } - - detail::errHandler(error, __CREATE_IMAGE_ERR); - if (err != nullptr) { - *err = error; - } + context(), + properties.empty() ? nullptr : properties.data(), + flags, &format, &desc, nullptr, &error); + + detail::errHandler(error, __CREATE_IMAGE_ERR); + if (err != nullptr) { + *err = error; + } } -#endif //#if CL_HPP_TARGET_OPENCL_VERSION >= 300 +#endif // CL_HPP_TARGET_OPENCL_VERSION >= 300 //! \brief Default constructor - initializes to nullptr. Image2D() { } @@ -5484,32 +5506,29 @@ class Image2DArray : public Image cl_mem_flags flags, ImageFormat format, size_type arraySize, size_type width, size_type height, size_type rowPitch = 0, size_type slicePitch = 0, void *host_ptr = nullptr, - cl_int *err = nullptr) { - cl_int error; - - cl_image_desc desc = {}; - desc.image_type = CL_MEM_OBJECT_IMAGE2D_ARRAY; - desc.image_width = width; - desc.image_height = height; - desc.image_array_size = arraySize; - desc.image_row_pitch = rowPitch; - desc.image_slice_pitch = slicePitch; - - if (properties.empty()) { + cl_int *err = nullptr) + { + cl_int error; + + cl_image_desc desc = {}; + desc.image_type = CL_MEM_OBJECT_IMAGE2D_ARRAY; + desc.image_width = width; + desc.image_height = height; + desc.image_array_size = arraySize; + desc.image_row_pitch = rowPitch; + desc.image_slice_pitch = slicePitch; + object_ = CL_(clCreateImageWithProperties)( - context(), nullptr, flags, &format, &desc, host_ptr, &error); - } else { - object_ = - CL_(clCreateImageWithProperties)(context(), properties.data(), flags, - &format, &desc, host_ptr, &error); - } - - detail::errHandler(error, __CREATE_IMAGE_ERR); - if (err != nullptr) { - *err = error; - } + context(), + properties.empty() ? nullptr : properties.data(), + flags, &format, &desc, host_ptr, &error); + + detail::errHandler(error, __CREATE_IMAGE_ERR); + if (err != nullptr) { + *err = error; + } } -#endif //#if CL_HPP_TARGET_OPENCL_VERSION >= 300 +#endif // CL_HPP_TARGET_OPENCL_VERSION >= 300 Image2DArray() { } @@ -5626,32 +5645,29 @@ class Image3D : public Image 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 = nullptr, - cl_int *err = nullptr) { - cl_int error; - - cl_image_desc desc = {}; - desc.image_type = CL_MEM_OBJECT_IMAGE3D; - desc.image_width = width; - desc.image_height = height; - desc.image_depth = depth; - desc.image_row_pitch = row_pitch; - desc.image_slice_pitch = slice_pitch; - - if (properties.empty()) { + cl_int *err = nullptr) + { + cl_int error; + + cl_image_desc desc = {}; + desc.image_type = CL_MEM_OBJECT_IMAGE3D; + desc.image_width = width; + desc.image_height = height; + desc.image_depth = depth; + desc.image_row_pitch = row_pitch; + desc.image_slice_pitch = slice_pitch; + object_ = CL_(clCreateImageWithProperties)( - context(), nullptr, flags, &format, &desc, host_ptr, &error); - } else { - object_ = - CL_(clCreateImageWithProperties)(context(), properties.data(), flags, - &format, &desc, host_ptr, &error); - } - - detail::errHandler(error, __CREATE_IMAGE_ERR); - if (err != nullptr) { - *err = error; - } + context(), + properties.empty() ? nullptr : properties.data(), + flags, &format, &desc, host_ptr, &error); + + detail::errHandler(error, __CREATE_IMAGE_ERR); + if (err != nullptr) { + *err = error; + } } -#endif //#if CL_HPP_TARGET_OPENCL_VERSION >= 300 +#endif // CL_HPP_TARGET_OPENCL_VERSION >= 300 //! \brief Default constructor - initializes to nullptr. Image3D() : Image() { } @@ -6320,10 +6336,11 @@ class Kernel : public detail::Wrapper /*! \brief setArg overload taking a vector type. */ template - cl_int setArg(cl_uint index, const cl::vector &argPtr) + cl_int setArg(cl_uint index, const cl::vector &arg) { return detail::errHandler( - CL_(clSetKernelArgSVMPointer)(object_, index, argPtr.data()), + CL_(clSetKernelArgSVMPointer)(object_, index, + arg.empty() ? nullptr : arg.data()), __SET_KERNEL_ARGS_ERR); } @@ -6372,8 +6389,8 @@ class Kernel : public detail::Wrapper CL_(clSetKernelExecInfo)( object_, CL_KERNEL_EXEC_INFO_SVM_PTRS, - sizeof(void*)*pointerList.size(), - pointerList.data())); + sizeof(void*) * pointerList.size(), + pointerList.empty() ? nullptr : pointerList.data())); } /*! @@ -6387,8 +6404,8 @@ class Kernel : public detail::Wrapper CL_(clSetKernelExecInfo)( object_, CL_KERNEL_EXEC_INFO_SVM_PTRS, - sizeof(void*)*pointerList.size(), - pointerList.data())); + sizeof(void*) * pointerList.size(), + pointerList.empty() ? nullptr : pointerList.data())); } /*! \brief Enable fine-grained system SVM. @@ -6454,7 +6471,7 @@ class Kernel : public detail::Wrapper CL_(clSetKernelExecInfo)( object_, CL_KERNEL_EXEC_INFO_SVM_PTRS, - sizeof(void*)*(1 + sizeof...(Ts)), + sizeof(void*) * (1 + sizeof...(Ts)), pointerList.data())); } @@ -6610,7 +6627,10 @@ class Program : public detail::Wrapper } object_ = CL_(clCreateProgramWithSource)( - context(), (cl_uint)n, strings.data(), lengths.data(), &error); + context(), (cl_uint)n, + strings.empty() ? nullptr : strings.data(), + lengths.empty() ? nullptr : lengths.data(), + &error); detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR); if (err != nullptr) { @@ -6645,7 +6665,10 @@ class Program : public detail::Wrapper } object_ = CL_(clCreateProgramWithSource)( - context(), (cl_uint)n, strings.data(), lengths.data(), &error); + context(), (cl_uint)n, + strings.empty() ? nullptr : strings.data(), + lengths.empty() ? nullptr : lengths.data(), + &error); detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR); if (err != nullptr) { @@ -6826,11 +6849,15 @@ class Program : public detail::Wrapper } object_ = CL_(clCreateProgramWithBinary)( - context(), (cl_uint) devices.size(), - deviceIDs.data(), - lengths.data(), images.data(), (binaryStatus != nullptr && numDevices > 0) + context(), + (cl_uint)deviceIDs.size(), + deviceIDs.empty() ? nullptr : deviceIDs.data(), + lengths.empty() ? nullptr : lengths.data(), + images.empty() ? nullptr : images.data(), + (binaryStatus != nullptr && numDevices > 0) ? &binaryStatus->front() - : nullptr, &error); + : nullptr, + &error); detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR); if (err != nullptr) { @@ -6852,7 +6879,6 @@ class Program : public detail::Wrapper { cl_int error; - size_type numDevices = devices.size(); vector deviceIDs(numDevices); for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) { @@ -6861,8 +6887,8 @@ class Program : public detail::Wrapper object_ = CL_(clCreateProgramWithBuiltInKernels)( context(), - (cl_uint) devices.size(), - deviceIDs.data(), + (cl_uint)deviceIDs.size(), + deviceIDs.empty() ? nullptr : deviceIDs.data(), kernelNames.c_str(), &error); @@ -6915,9 +6941,8 @@ class Program : public detail::Wrapper cl_int buildError = CL_(clBuildProgram)( object_, - (cl_uint) - devices.size(), - deviceIDs.data(), + (cl_uint)deviceIDs.size(), + deviceIDs.empty() ? nullptr : deviceIDs.data(), options, notifyFptr, data); @@ -7025,18 +7050,20 @@ class Program : public detail::Wrapper { static_assert(sizeof(cl::Program) == sizeof(cl_program), "Size of cl::Program must be equal to size of cl_program"); + vector headerIncludeNamesCStr; for(const string& name: headerIncludeNames) { headerIncludeNamesCStr.push_back(name.c_str()); } + cl_int error = CL_(clCompileProgram)( object_, 0, nullptr, options, static_cast(inputHeaders.size()), - reinterpret_cast(inputHeaders.data()), - reinterpret_cast(headerIncludeNamesCStr.data()), + reinterpret_cast(inputHeaders.empty() ? nullptr : inputHeaders.data()), + reinterpret_cast(headerIncludeNamesCStr.empty() ? nullptr : headerIncludeNamesCStr.data()), notifyFptr, data); return detail::buildErrHandler(error, __COMPILE_PROGRAM_ERR, getBuildInfo()); @@ -7055,7 +7082,7 @@ class Program : public detail::Wrapper cl_int compile( const char* options, - const vector& deviceList, + const vector& devices, const vector& inputHeaders = vector(), const vector& headerIncludeNames = vector(), void (CL_CALLBACK * notifyFptr)(cl_program, void *) = nullptr, @@ -7063,22 +7090,25 @@ class Program : public detail::Wrapper { static_assert(sizeof(cl::Program) == sizeof(cl_program), "Size of cl::Program must be equal to size of cl_program"); + + vector deviceIDs; + for(const Device& device: devices) { + deviceIDs.push_back(device()); + } + vector headerIncludeNamesCStr; for(const string& name: headerIncludeNames) { headerIncludeNamesCStr.push_back(name.c_str()); } - vector deviceIDList; - for(const Device& device: deviceList) { - deviceIDList.push_back(device()); - } + cl_int error = CL_(clCompileProgram)( object_, - static_cast(deviceList.size()), - reinterpret_cast(deviceIDList.data()), + static_cast(deviceIDs.size()), + reinterpret_cast(deviceIDs.empty() ? nullptr : deviceIDs.data()), options, static_cast(inputHeaders.size()), - reinterpret_cast(inputHeaders.data()), - reinterpret_cast(headerIncludeNamesCStr.data()), + reinterpret_cast(inputHeaders.empty() ? nullptr : inputHeaders.data()), + reinterpret_cast(headerIncludeNamesCStr.empty() ? nullptr : headerIncludeNamesCStr.data()), notifyFptr, data); return detail::buildErrHandler(error, __COMPILE_PROGRAM_ERR, getBuildInfo()); @@ -7182,9 +7212,11 @@ class Program : public detail::Wrapper } vector value(numKernels); - err = CL_(clCreateKernelsInProgram)( - object_, numKernels, value.data(), nullptr); + object_, + numKernels, + value.empty() ? nullptr : value.data(), + nullptr); if (err != CL_SUCCESS) { return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR); } @@ -7335,7 +7367,7 @@ inline Program linkProgram( nullptr, options, static_cast(inputPrograms.size()), - reinterpret_cast(inputPrograms.data()), + reinterpret_cast(inputPrograms.empty() ? nullptr : inputPrograms.data()), notifyFptr, data, &error_local); @@ -8456,8 +8488,8 @@ class CommandQueue : public detail::Wrapper origin.data(), region.data(), (events != nullptr) ? (cl_uint)events->size() : 0, - (events != nullptr && events->size() > 0) ? (const cl_event*)&events->front() : NULL, - (event != NULL) ? &tmp : nullptr), + (events != nullptr && events->size() > 0) ? (const cl_event*)&events->front() : nullptr, + (event != nullptr) ? &tmp : nullptr), __ENQUEUE_FILL_IMAGE_ERR); if (event != nullptr && err == CL_SUCCESS) *event = tmp; @@ -8740,12 +8772,13 @@ class CommandQueue : public detail::Wrapper return detail::errHandler(CL_INVALID_VALUE,__ENQUEUE_COPY_SVM_ERR); } cl_int err = detail::errHandler(CL_(clEnqueueSVMMemcpy)( - object_, blocking, static_cast(dst_container.data()), - static_cast(src_container.data()), + object_, blocking, + dst_container.empty() ? nullptr : dst_container.data(), + src_container.empty() ? nullptr : src_container.data(), dst_container.size() * sizeof(T), (events != nullptr) ? (cl_uint) events->size() : 0, (events != nullptr && events->size() > 0) ? (const cl_event *) &events->front() : nullptr, - (event != NULL) ? &tmp : nullptr), __ENQUEUE_COPY_SVM_ERR); + (event != nullptr) ? &tmp : nullptr), __ENQUEUE_COPY_SVM_ERR); if (event != nullptr && err == CL_SUCCESS) *event = tmp; @@ -8816,11 +8849,14 @@ class CommandQueue : public detail::Wrapper { cl_event tmp; cl_int err = detail::errHandler(CL_(clEnqueueSVMMemFill)( - object_, static_cast(container.data()), static_cast(&pattern), - sizeof(PatternType), container.size() * sizeof(T), + object_, + container.empty() ? nullptr : container.data(), + &pattern, + sizeof(PatternType), + container.size() * sizeof(T), (events != nullptr) ? (cl_uint) events->size() : 0, (events != nullptr && events->size() > 0) ? (const cl_event *) &events->front() : nullptr, - (event != nullptr) ? &tmp : NULL), __ENQUEUE_FILL_SVM_ERR); + (event != nullptr) ? &tmp : nullptr), __ENQUEUE_FILL_SVM_ERR); if (event != nullptr && err == CL_SUCCESS) *event = tmp; @@ -8897,7 +8933,9 @@ class CommandQueue : public detail::Wrapper { cl_event tmp; cl_int err = detail::errHandler(CL_(clEnqueueSVMMap)( - object_, blocking, flags, static_cast(container.data()), container.size()*sizeof(T), + object_, blocking, flags, + container.empty() ? nullptr : container.data(), + container.size() * sizeof(T), (events != nullptr) ? (cl_uint)events->size() : 0, (events != nullptr && events->size() > 0) ? (const cl_event*)&events->front() : nullptr, (event != nullptr) ? &tmp : nullptr), @@ -8996,7 +9034,8 @@ class CommandQueue : public detail::Wrapper cl_event tmp; cl_int err = detail::errHandler( CL_(clEnqueueSVMUnmap)( - object_, static_cast(container.data()), + object_, + container.empty() ? nullptr : container.data(), (events != nullptr) ? (cl_uint)events->size() : 0, (events != nullptr && events->size() > 0) ? (const cl_event*)&events->front() : nullptr, (event != nullptr) ? &tmp : nullptr), @@ -9093,7 +9132,7 @@ class CommandQueue : public detail::Wrapper CL_(clEnqueueMigrateMemObjects)( object_, (cl_uint)memObjects.size(), - localMemObjects.data(), + localMemObjects.empty() ? nullptr : localMemObjects.data(), flags, (events != nullptr) ? (cl_uint) events->size() : 0, (events != nullptr && events->size() > 0) ? (const cl_event*) &events->front() : nullptr, @@ -9125,8 +9164,9 @@ class CommandQueue : public detail::Wrapper cl_event tmp; cl_int err = detail::errHandler(CL_(clEnqueueSVMMigrateMem)( object_, - svmRawPointers.size(), static_cast(svmRawPointers.data()), - sizes.data(), // array of sizes not passed + svmRawPointers.size(), + svmRawPointers.empty() ? nullptr : svmRawPointers.data(), + sizes.empty() ? nullptr : sizes.data(), flags, (events != nullptr) ? (cl_uint)events->size() : 0, (events != nullptr && events->size() > 0) ? (const cl_event*)&events->front() : nullptr, @@ -9396,7 +9436,6 @@ typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueReleaseD3D10ObjectsKHR)( { static PFN_clEnqueueAcquireD3D10ObjectsKHR pfn_clEnqueueAcquireD3D10ObjectsKHR = nullptr; #if CL_HPP_TARGET_OPENCL_VERSION >= 120 - cl_context context = getInfo(); cl::Device device(getInfo()); cl_platform_id platform = device.getInfo(); CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueAcquireD3D10ObjectsKHR); @@ -9429,7 +9468,6 @@ typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueReleaseD3D10ObjectsKHR)( { static PFN_clEnqueueReleaseD3D10ObjectsKHR pfn_clEnqueueReleaseD3D10ObjectsKHR = nullptr; #if CL_HPP_TARGET_OPENCL_VERSION >= 120 - cl_context context = getInfo(); cl::Device device(getInfo()); cl_platform_id platform = device.getInfo(); CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueReleaseD3D10ObjectsKHR); @@ -9478,6 +9516,33 @@ typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueReleaseD3D10ObjectsKHR)( { return detail::errHandler(CL_(clFinish)(object_), __FINISH_ERR); } + +#if CL_HPP_TARGET_OPENCL_VERSION >= 310 + NDRange getKernelSuggestedLocalWorkSize( + const Kernel& kernel, + const NDRange& offset, + const NDRange& global, + cl_int* err = nullptr) const + { + // Initialize the local work-group size to the global work size + // so it has the right dimensionality. The contents will be + // overwritten by the call to clGetKernelSuggestedLocalWorkSize. + NDRange local = global; + cl_int error = detail::errHandler( + CL_(clGetKernelSuggestedLocalWorkSize)( + object_, + kernel(), + (cl_uint) global.dimensions(), + offset.dimensions() != 0 ? offset.get() : nullptr, + global.get(), + local.get()), + __GET_KERNEL_SUGGESTED_LWS_ERR); + if (err != nullptr) { + *err = error; + } + return local; + } +#endif // CL_HPP_TARGET_OPENCL_VERSION >= 310 }; // CommandQueue CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag CommandQueue::default_initialized_; @@ -9781,7 +9846,7 @@ Buffer::Buffer( if( useHostPtr ) { object_ = CL_(clCreateBuffer)(context(), flags, size, const_cast(&*startIterator), &error); } else { - object_ = CL_(clCreateBuffer)(context(), flags, size, 0, &error); + object_ = CL_(clCreateBuffer)(context(), flags, size, nullptr, &error); } detail::errHandler(error, __CREATE_BUFFER_ERR); @@ -9835,7 +9900,7 @@ Buffer::Buffer( object_ = CL_(clCreateBuffer)(context(), flags, size, const_cast(&*startIterator), &error); } else { - object_ = CL_(clCreateBuffer)(context(), flags, size, 0, &error); + object_ = CL_(clCreateBuffer)(context(), flags, size, nullptr, &error); } detail::errHandler(error, __CREATE_BUFFER_ERR); @@ -10157,7 +10222,7 @@ inline cl_int copy( const CommandQueue &queue, IteratorType startIterator, Itera size_type byteLength = length*sizeof(DataType); DataType *pointer = - static_cast(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_WRITE, 0, byteLength, 0, 0, &error)); + static_cast(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_WRITE, 0, byteLength, nullptr, nullptr, &error)); // if exceptions enabled, enqueueMapBuffer will throw if( error != CL_SUCCESS ) { return error; @@ -10172,7 +10237,7 @@ inline cl_int copy( const CommandQueue &queue, IteratorType startIterator, Itera std::copy(startIterator, endIterator, pointer); #endif // defined(_MSC_VER) && _MSC_VER < 1920 Event endEvent; - error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent); + error = queue.enqueueUnmapMemObject(buffer, pointer, nullptr, &endEvent); // if exceptions enabled, enqueueUnmapMemObject will throw if( error != CL_SUCCESS ) { return error; @@ -10196,14 +10261,14 @@ inline cl_int copy( const CommandQueue &queue, const cl::Buffer &buffer, Iterato size_type byteLength = length*sizeof(DataType); DataType *pointer = - static_cast(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_READ, 0, byteLength, 0, 0, &error)); + static_cast(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_READ, 0, byteLength, nullptr, nullptr, &error)); // if exceptions enabled, enqueueMapBuffer will throw if( error != CL_SUCCESS ) { return error; } std::copy(pointer, pointer + length, startIterator); Event endEvent; - error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent); + error = queue.enqueueUnmapMemObject(buffer, pointer, nullptr, &endEvent); // if exceptions enabled, enqueueUnmapMemObject will throw if( error != CL_SUCCESS ) { return error; @@ -11107,6 +11172,7 @@ class CommandBuffer : public detail::Wrapper #undef __GET_KERNEL_ARG_INFO_ERR #undef __GET_KERNEL_SUB_GROUP_INFO_ERR #undef __GET_KERNEL_WORK_GROUP_INFO_ERR +#undef __GET_KERNEL_SUGGESTED_LWS_ERR #undef __GET_PROGRAM_INFO_ERR #undef __GET_PROGRAM_BUILD_INFO_ERR #undef __GET_COMMAND_QUEUE_INFO_ERR @@ -11130,7 +11196,7 @@ class CommandBuffer : public detail::Wrapper #undef __RETAIN_COMMAND_BUFFER_KHR_ERR #undef __RELEASE_COMMAND_BUFFER_KHR_ERR #undef __GET_SUPPORTED_IMAGE_FORMATS_ERR -#undef __SET_CONTEXT_DESCTRUCTOR_CALLBACK_ERR +#undef __SET_CONTEXT_DESTRUCTOR_CALLBACK_ERR #undef __CREATE_BUFFER_ERR #undef __COPY_ERR #undef __CREATE_SUBBUFFER_ERR diff --git a/samples/usm/01_usmmeminfo/main.cpp b/samples/usm/01_usmmeminfo/main.cpp index c197dcd4..09a3251d 100644 --- a/samples/usm/01_usmmeminfo/main.cpp +++ b/samples/usm/01_usmmeminfo/main.cpp @@ -57,7 +57,7 @@ getMEM_ALLOC_SIZE_INTEL( cl::Context& context, const void* ptr ) static cl_device_id getMEM_ALLOC_DEVICE_INTEL( cl::Context& context, const void* ptr ) { - cl_device_id device = 0; + cl_device_id device = nullptr; clGetMemAllocInfoINTEL( context(), ptr,