From e8d72344bcf20fc7b6bb8d54b5f839edb95ab097 Mon Sep 17 00:00:00 2001
From: foreman
Date: Wed, 28 Oct 2015 13:49:51 -0400
Subject: [PATCH] P4 to Git Change 1204938 by lmoriche@lmoriche_opencl_dev on
2015/10/28 13:41:08
SWDEV-1 - Khronos GIT import (10/23/2015)
Affected files ...
... //depot/stg/opencl/drivers/opencl/api/opencl/khronos/headers/opencl2.0/CL/cl.h#22 integrate
... //depot/stg/opencl/drivers/opencl/api/opencl/khronos/headers/opencl2.0/CL/cl.hpp#4 integrate
... //depot/stg/opencl/drivers/opencl/api/opencl/khronos/headers/opencl2.0/CL/cl2.hpp#1 branch
... //depot/stg/opencl/drivers/opencl/api/opencl/khronos/headers/opencl2.0/CL/cl_dx9_media_sharing.h#4 integrate
... //depot/stg/opencl/drivers/opencl/api/opencl/khronos/headers/opencl2.0/CL/cl_ext.h#20 integrate
... //depot/stg/opencl/drivers/opencl/api/opencl/khronos/headers/opencl2.0/CL/cl_platform.h#6 integrate
... //depot/stg/opencl/drivers/opencl/api/opencl/khronos/icd/Makefile#10 integrate
... //depot/stg/opencl/drivers/opencl/api/opencl/khronos/icd/OpenCL.rc#17 integrate
... //depot/stg/opencl/drivers/opencl/api/opencl/khronos/icd/icd.c#8 integrate
... //depot/stg/opencl/drivers/opencl/api/opencl/khronos/icd/icd.h#8 integrate
... //depot/stg/opencl/drivers/opencl/api/opencl/khronos/icd/icd_dispatch.c#29 integrate
... //depot/stg/opencl/drivers/opencl/api/opencl/khronos/icd/icd_dispatch.h#24 integrate
... //depot/stg/opencl/drivers/opencl/api/opencl/khronos/icd/icd_linux.c#9 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/khronos/icd/icd_windows.c#7 edit
... //depot/stg/opencl/drivers/opencl/tests/ocltst/complibtestdefs#11 edit
... //depot/stg/opencl/drivers/opencl/tests/ocltst/env/build/Makefile.ocltst#28 edit
... //depot/stg/opencl/drivers/opencl/tests/ocltst/module/regression/OCLBug3774.cpp#2 edit
... //depot/stg/opencl/drivers/opencl/tests/ocltst/module/runtime/OCLMemObjs.cpp#2 edit
... //depot/stg/opencl/drivers/opencl/tests/ocltst/testdefs#27 edit
... //depot/stg/opencl/drivers/opencl/tools/clinfo/build/Makefile.clinfo#5 edit
---
.../opencl/khronos/headers/opencl2.0/CL/cl.h | 12 +-
.../khronos/headers/opencl2.0/CL/cl.hpp | 1981 ++--
.../khronos/headers/opencl2.0/CL/cl2.hpp | 9520 +++++++++++++++++
.../opencl2.0/CL/cl_dx9_media_sharing.h | 2 +-
.../headers/opencl2.0/CL/cl_platform.h | 32 +-
opencl/api/opencl/khronos/icd/OpenCL.rc | 6 +-
opencl/api/opencl/khronos/icd/icd.c | 17 +-
opencl/api/opencl/khronos/icd/icd.h | 39 +-
opencl/api/opencl/khronos/icd/icd_dispatch.c | 6 +-
opencl/api/opencl/khronos/icd/icd_dispatch.h | 4 +
opencl/api/opencl/khronos/icd/icd_linux.c | 16 +-
opencl/api/opencl/khronos/icd/icd_windows.c | 21 +-
12 files changed, 10905 insertions(+), 751 deletions(-)
create mode 100644 opencl/api/opencl/khronos/headers/opencl2.0/CL/cl2.hpp
diff --git a/opencl/api/opencl/khronos/headers/opencl2.0/CL/cl.h b/opencl/api/opencl/khronos/headers/opencl2.0/CL/cl.h
index 87fd6d7781..84d8a0a71d 100644
--- a/opencl/api/opencl/khronos/headers/opencl2.0/CL/cl.h
+++ b/opencl/api/opencl/khronos/headers/opencl2.0/CL/cl.h
@@ -1355,26 +1355,26 @@ extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED void * CL_API_CALL
clGetExtensionFunctionAddress(const char * /* func_name */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
/* Deprecated OpenCL 2.0 APIs */
-extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_2_0_DEPRECATED cl_command_queue CL_API_CALL
+extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_2_DEPRECATED cl_command_queue CL_API_CALL
clCreateCommandQueue(cl_context /* context */,
cl_device_id /* device */,
cl_command_queue_properties /* properties */,
- cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED;
+ cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED;
-extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_2_0_DEPRECATED cl_sampler CL_API_CALL
+extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_2_DEPRECATED cl_sampler CL_API_CALL
clCreateSampler(cl_context /* context */,
cl_bool /* normalized_coords */,
cl_addressing_mode /* addressing_mode */,
cl_filter_mode /* filter_mode */,
- cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED;
+ cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED;
-extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_2_0_DEPRECATED cl_int CL_API_CALL
+extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_2_DEPRECATED cl_int CL_API_CALL
clEnqueueTask(cl_command_queue /* command_queue */,
cl_kernel /* kernel */,
cl_uint /* num_events_in_wait_list */,
const cl_event * /* event_wait_list */,
- cl_event * /* event */) CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED;
+ cl_event * /* event */) CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED;
#ifdef __cplusplus
}
diff --git a/opencl/api/opencl/khronos/headers/opencl2.0/CL/cl.hpp b/opencl/api/opencl/khronos/headers/opencl2.0/CL/cl.hpp
index 667526e341..f81a6c4881 100644
--- a/opencl/api/opencl/khronos/headers/opencl2.0/CL/cl.hpp
+++ b/opencl/api/opencl/khronos/headers/opencl2.0/CL/cl.hpp
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008-2013 The Khronos Group Inc.
+ * Copyright (c) 2008-2015 The Khronos Group Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and/or associated documentation files (the
@@ -31,9 +31,10 @@
* Brian Cole, March 3rd 2010 and April 2012
* Matt Gruenke, April 2012.
* Bruce Merry, February 2013.
+ * Tom Deakin and Simon McIntosh-Smith, July 2013
*
- * \version 1.2.5
- * \date June 2013
+ * \version 1.2.8
+ * \date October 2015
*
* Optional extension support
*
@@ -146,37 +147,42 @@
#ifdef _WIN32
-#include
#include
-#include
-#include
-#if defined(__CL_ENABLE_EXCEPTIONS)
-#include
-#endif // #if defined(__CL_ENABLE_EXCEPTIONS)
-
-#pragma push_macro("max")
-#undef max
#if defined(USE_DX_INTEROP)
#include
#include
#endif
#endif // _WIN32
+#if defined(_MSC_VER)
+#include
+#endif // _MSC_VER
+
//
#if defined(USE_CL_DEVICE_FISSION)
#include
#endif
#if defined(__APPLE__) || defined(__MACOSX)
-#include
#include
-#include
#else
-#include
#include
#endif // !__APPLE__
+#if (_MSC_VER >= 1700) || (__cplusplus >= 201103L)
+#define CL_HPP_RVALUE_REFERENCES_SUPPORTED
+#define CL_HPP_CPP11_ATOMICS_SUPPORTED
+#include
+#endif
+
+#if (__cplusplus >= 201103L)
+#define CL_HPP_NOEXCEPT noexcept
+#else
+#define CL_HPP_NOEXCEPT
+#endif
+
+
// To avoid accidentally taking ownership of core OpenCL types
// such as cl_kernel constructors are made explicit
// under OpenCL 1.2
@@ -201,6 +207,11 @@
#include
#include
+#include
+
+#if defined(__CL_ENABLE_EXCEPTIONS)
+#include
+#endif // #if defined(__CL_ENABLE_EXCEPTIONS)
#if !defined(__NO_STD_VECTOR)
#include
@@ -210,11 +221,8 @@
#include
#endif
-#if defined(__linux__) || defined(__APPLE__) || defined(__MACOSX)
+#if defined(__ANDROID__) || defined(__linux__) || defined(__APPLE__) || defined(__MACOSX)
#include
-
-#include
-#include
#endif // __linux__
#include
@@ -388,7 +396,7 @@ static inline cl_int errHandler (cl_int err, const char * errStr = NULL)
#define __BUILD_PROGRAM_ERR __ERR_STR(clBuildProgram)
#if defined(CL_VERSION_1_2)
#define __COMPILE_PROGRAM_ERR __ERR_STR(clCompileProgram)
-
+#define __LINK_PROGRAM_ERR __ERR_STR(clLinkProgram)
#endif // #if defined(CL_VERSION_1_2)
#define __CREATE_KERNELS_IN_PROGRAM_ERR __ERR_STR(clCreateKernelsInProgram)
@@ -545,7 +553,7 @@ public:
}
else {
char *newString = new char[n + 1];
- int copySize = n;
+ ::size_t copySize = n;
if( size_ < n ) {
copySize = size_;
}
@@ -675,7 +683,7 @@ typedef cl::string STRING_CLASS;
* \param N maximum size of the vector.
*/
template
-class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
+class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector
{
private:
T data_[N];
@@ -829,6 +837,28 @@ public:
return N;
}
+ //! \brief Resizes the vector to the given size
+ void resize(unsigned int newSize, T fill = T())
+ {
+ if (newSize > N)
+ {
+ detail::errHandler(CL_MEM_OBJECT_ALLOCATION_FAILURE, __VECTOR_CAPACITY_ERR);
+ }
+ else
+ {
+ while (size_ < newSize)
+ {
+ new (&data_[size_]) T(fill);
+ size_++;
+ }
+ while (size_ > newSize)
+ {
+ --size_;
+ data_[size_].~T();
+ }
+ }
+ }
+
/*! \brief Returns a reference to a given element.
*
* \param index which element to access. *
@@ -1005,7 +1035,7 @@ public:
{
return data_[size_-1];
}
-};
+} CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
#endif // #if !defined(__USE_DEV_VECTOR) && !defined(__NO_STD_VECTOR)
@@ -1020,25 +1050,39 @@ namespace detail {
/*
* Compare and exchange primitives are needed for handling of defaults
*/
+
+#ifdef CL_HPP_CPP11_ATOMICS_SUPPORTED
+ inline int compare_exchange(std::atomic * dest, int exchange, int comparand)
+#else // !CL_HPP_CPP11_ATOMICS_SUPPORTED
inline int compare_exchange(volatile int * dest, int exchange, int comparand)
+#endif // !CL_HPP_CPP11_ATOMICS_SUPPORTED
{
-#ifdef _WIN32
- return (int)(InterlockedCompareExchange(
+#ifdef CL_HPP_CPP11_ATOMICS_SUPPORTED
+ std::atomic_compare_exchange_strong(dest, &comparand, exchange);
+ return comparand;
+#elif _MSC_VER
+ return (int)(_InterlockedCompareExchange(
(volatile long*)dest,
(long)exchange,
(long)comparand));
-#elif defined(__APPLE__) || defined(__MACOSX)
- return OSAtomicOr32Orig((uint32_t)exchange, (volatile uint32_t*)dest);
-#else // !_WIN32 || defined(__APPLE__) || defined(__MACOSX)
+#else // !_MSC_VER && !CL_HPP_CPP11_ATOMICS_SUPPORTED
return (__sync_val_compare_and_swap(
dest,
comparand,
exchange));
-#endif // !_WIN32
+#endif // !CL_HPP_CPP11_ATOMICS_SUPPORTED
}
- inline void fence() { _mm_mfence(); }
-}; // namespace detail
+ inline void fence() {
+#ifdef CL_HPP_CPP11_ATOMICS_SUPPORTED
+ std::atomic_thread_fence(std::memory_order_seq_cst);
+#elif _MSC_VER // !CL_HPP_CPP11_ATOMICS_SUPPORTED
+ _ReadWriteBarrier();
+#else // !_MSC_VER && !CL_HPP_CPP11_ATOMICS_SUPPORTED
+ __sync_synchronize();
+#endif // !CL_HPP_CPP11_ATOMICS_SUPPORTED
+ }
+} // namespace detail
/*! \brief class used to interface between C++ and
@@ -1162,6 +1206,7 @@ inline cl_int getInfoHelper(Func f, cl_uint name, VECTOR_CLASS* param, i
template
inline cl_int getInfoHelper(Func f, cl_uint name, STRING_CLASS* param, long)
{
+#if defined(__NO_STD_VECTOR) || defined(__NO_STD_STRING)
::size_t required;
cl_int err = f(name, 0, NULL, &required);
if (err != CL_SUCCESS) {
@@ -1176,6 +1221,25 @@ inline cl_int getInfoHelper(Func f, cl_uint name, STRING_CLASS* param, long)
*param = value;
return CL_SUCCESS;
+#else
+ ::size_t required;
+ cl_int err = f(name, 0, NULL, &required);
+ if (err != CL_SUCCESS) {
+ return err;
+}
+
+ // std::string has a constant data member
+ // a char vector does not
+ VECTOR_CLASS value(required);
+ err = f(name, required, value.data(), NULL);
+ if (err != CL_SUCCESS) {
+ return err;
+ }
+ if (param) {
+ param->assign(value.begin(), value.end());
+ }
+#endif
+ return CL_SUCCESS;
}
// Specialized GetInfoHelper for cl::size_t params
@@ -1293,7 +1357,7 @@ inline cl_int getInfoHelper(Func f, cl_uint name, T* param, int, typename T::cl_
F(cl_event_info, CL_EVENT_COMMAND_QUEUE, cl::CommandQueue) \
F(cl_event_info, CL_EVENT_COMMAND_TYPE, cl_command_type) \
F(cl_event_info, CL_EVENT_REFERENCE_COUNT, cl_uint) \
- F(cl_event_info, CL_EVENT_COMMAND_EXECUTION_STATUS, cl_uint) \
+ F(cl_event_info, CL_EVENT_COMMAND_EXECUTION_STATUS, cl_int) \
\
F(cl_profiling_info, CL_PROFILING_COMMAND_QUEUED, cl_ulong) \
F(cl_profiling_info, CL_PROFILING_COMMAND_SUBMIT, cl_ulong) \
@@ -1318,9 +1382,9 @@ inline cl_int getInfoHelper(Func f, cl_uint name, T* param, int, typename T::cl_
\
F(cl_sampler_info, CL_SAMPLER_REFERENCE_COUNT, cl_uint) \
F(cl_sampler_info, CL_SAMPLER_CONTEXT, cl::Context) \
- F(cl_sampler_info, CL_SAMPLER_NORMALIZED_COORDS, cl_addressing_mode) \
- F(cl_sampler_info, CL_SAMPLER_ADDRESSING_MODE, cl_filter_mode) \
- F(cl_sampler_info, CL_SAMPLER_FILTER_MODE, cl_bool) \
+ F(cl_sampler_info, CL_SAMPLER_NORMALIZED_COORDS, cl_bool) \
+ F(cl_sampler_info, CL_SAMPLER_ADDRESSING_MODE, cl_addressing_mode) \
+ F(cl_sampler_info, CL_SAMPLER_FILTER_MODE, cl_filter_mode) \
\
F(cl_program_info, CL_PROGRAM_REFERENCE_COUNT, cl_uint) \
F(cl_program_info, CL_PROGRAM_CONTEXT, cl::Context) \
@@ -1390,6 +1454,7 @@ inline cl_int getInfoHelper(Func f, cl_uint name, T* param, int, typename T::cl_
F(cl_kernel_arg_info, CL_KERNEL_ARG_ACCESS_QUALIFIER, cl_kernel_arg_access_qualifier) \
F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_NAME, STRING_CLASS) \
F(cl_kernel_arg_info, CL_KERNEL_ARG_NAME, STRING_CLASS) \
+ F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_QUALIFIER, cl_kernel_arg_type_qualifier) \
\
F(cl_device_info, CL_DEVICE_PARENT_DEVICE, cl_device_id) \
F(cl_device_info, CL_DEVICE_PARTITION_PROPERTIES, VECTOR_CLASS) \
@@ -1674,7 +1739,7 @@ static cl_uint getVersion(const char *versionInfo)
++index;
}
++index;
- while(versionInfo[index] != ' ' ) {
+ while(versionInfo[index] != ' ' && versionInfo[index] != '\0') {
lowVersion *= 10;
lowVersion += versionInfo[index]-'0';
++index;
@@ -1738,14 +1803,36 @@ public:
if (object_ != NULL) { detail::errHandler(retain(), __RETAIN_ERR); }
}
+#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
+ Wrapper(Wrapper&& rhs) CL_HPP_NOEXCEPT
+ {
+ object_ = rhs.object_;
+ rhs.object_ = NULL;
+ }
+#endif
+
Wrapper& operator = (const Wrapper& rhs)
{
+ if (this != &rhs) {
if (object_ != NULL) { detail::errHandler(release(), __RELEASE_ERR); }
object_ = rhs.object_;
if (object_ != NULL) { detail::errHandler(retain(), __RETAIN_ERR); }
+ }
return *this;
}
+#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
+ Wrapper& operator = (Wrapper&& rhs)
+ {
+ if (this != &rhs) {
+ if (object_ != NULL) { detail::errHandler(release(), __RELEASE_ERR); }
+ object_ = rhs.object_;
+ rhs.object_ = NULL;
+ }
+ return *this;
+ }
+#endif
+
Wrapper& operator = (const cl_type &rhs)
{
if (object_ != NULL) { detail::errHandler(release(), __RELEASE_ERR); }
@@ -1816,15 +1903,41 @@ public:
if (object_ != NULL) { detail::errHandler(retain(), __RETAIN_ERR); }
}
+#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
+ Wrapper(Wrapper&& rhs) CL_HPP_NOEXCEPT
+ {
+ object_ = rhs.object_;
+ referenceCountable_ = rhs.referenceCountable_;
+ rhs.object_ = NULL;
+ rhs.referenceCountable_ = false;
+ }
+#endif
+
Wrapper& operator = (const Wrapper& rhs)
{
+ if (this != &rhs) {
if (object_ != NULL) { detail::errHandler(release(), __RELEASE_ERR); }
object_ = rhs.object_;
referenceCountable_ = rhs.referenceCountable_;
if (object_ != NULL) { detail::errHandler(retain(), __RETAIN_ERR); }
+ }
return *this;
}
+#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
+ Wrapper& operator = (Wrapper&& rhs)
+ {
+ if (this != &rhs) {
+ if (object_ != NULL) { detail::errHandler(release(), __RELEASE_ERR); }
+ object_ = rhs.object_;
+ referenceCountable_ = rhs.referenceCountable_;
+ rhs.object_ = NULL;
+ rhs.referenceCountable_ = false;
+ }
+ return *this;
+ }
+#endif
+
Wrapper& operator = (const cl_type &rhs)
{
if (object_ != NULL) { detail::errHandler(release(), __RELEASE_ERR); }
@@ -1909,17 +2022,11 @@ public:
//! \brief Default constructor - initializes to NULL.
Device() : detail::Wrapper() { }
- /*! \brief Copy constructor.
- *
- * This simply copies the device ID value, which is an inexpensive operation.
- */
- Device(const Device& device) : detail::Wrapper(device) { }
-
/*! \brief Constructor from cl_device_id.
*
* This simply copies the device ID value, which is an inexpensive operation.
*/
- Device(const cl_device_id &device) : detail::Wrapper(device) { }
+ __CL_EXPLICIT_CONSTRUCTORS Device(const cl_device_id &device) : detail::Wrapper(device) { }
/*! \brief Returns the first device on the default context.
*
@@ -1927,28 +2034,46 @@ public:
*/
static Device getDefault(cl_int * err = NULL);
- /*! \brief Assignment operator from Device.
- *
- * This simply copies the device ID value, which is an inexpensive operation.
- */
- Device& operator = (const Device& rhs)
- {
- if (this != &rhs) {
- detail::Wrapper::operator=(rhs);
- }
- return *this;
- }
-
/*! \brief Assignment operator from cl_device_id.
*
* This simply copies the device ID value, which is an inexpensive operation.
*/
Device& operator = (const cl_device_id& rhs)
{
- detail::Wrapper::operator=(rhs);
+ detail::Wrapper::operator=(rhs);
+ return *this;
+ }
+
+ /*! \brief Copy constructor to forward copy to the superclass correctly.
+ * Required for MSVC.
+ */
+ Device(const Device& dev) : detail::Wrapper(dev) {}
+
+ /*! \brief Copy assignment to forward copy to the superclass correctly.
+ * Required for MSVC.
+ */
+ Device& operator = (const Device &dev)
+ {
+ detail::Wrapper::operator=(dev);
return *this;
}
+#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
+ /*! \brief Move constructor to forward move to the superclass correctly.
+ * Required for MSVC.
+ */
+ Device(Device&& dev) CL_HPP_NOEXCEPT : detail::Wrapper(std::move(dev)) {}
+
+ /*! \brief Move assignment to forward move to the superclass correctly.
+ * Required for MSVC.
+ */
+ Device& operator = (Device &&dev)
+ {
+ detail::Wrapper::operator=(std::move(dev));
+ return *this;
+ }
+#endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
+
//! \brief Wrapper for clGetDeviceInfo().
template
cl_int getInfo(cl_device_info name, T* param) const
@@ -2050,29 +2175,11 @@ public:
//! \brief Default constructor - initializes to NULL.
Platform() : detail::Wrapper() { }
- /*! \brief Copy constructor.
- *
- * This simply copies the platform ID value, which is an inexpensive operation.
- */
- Platform(const Platform& platform) : detail::Wrapper(platform) { }
-
/*! \brief Constructor from cl_platform_id.
*
* This simply copies the platform ID value, which is an inexpensive operation.
*/
- Platform(const cl_platform_id &platform) : detail::Wrapper(platform) { }
-
- /*! \brief Assignment operator from Platform.
- *
- * This simply copies the platform ID value, which is an inexpensive operation.
- */
- Platform& operator = (const Platform& rhs)
- {
- if (this != &rhs) {
- detail::Wrapper::operator=(rhs);
- }
- return *this;
- }
+ __CL_EXPLICIT_CONSTRUCTORS Platform(const cl_platform_id &platform) : detail::Wrapper(platform) { }
/*! \brief Assignment operator from cl_platform_id.
*
@@ -2283,6 +2390,7 @@ public:
if (errResult != NULL) {
*errResult = err;
}
+ return Platform();
}
cl_platform_id* ids = (cl_platform_id*) alloca(
@@ -2291,13 +2399,14 @@ public:
if (err != CL_SUCCESS) {
detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
- }
-
if (errResult != NULL) {
*errResult = err;
}
+ return Platform();
+ }
- return ids[0];
+
+ return Platform(ids[0]);
}
static Platform getDefault(
@@ -2346,16 +2455,15 @@ class Context
: public detail::Wrapper
{
private:
+
+#ifdef CL_HPP_CPP11_ATOMICS_SUPPORTED
+ static std::atomic default_initialized_;
+#else // !CL_HPP_CPP11_ATOMICS_SUPPORTED
static volatile int default_initialized_;
+#endif // !CL_HPP_CPP11_ATOMICS_SUPPORTED
static Context default_;
static volatile cl_int default_error_;
public:
- /*! \brief Destructor.
- *
- * This calls clReleaseContext() on the value held by this instance.
- */
- ~Context() { }
-
/*! \brief Constructs a context including a list of specified devices.
*
* Wraps clCreateContext().
@@ -2416,7 +2524,7 @@ public:
}
}
- /*! \brief Constructs a context including all devices of a specified type.
+ /*! \brief Constructs a context including all or a subset of devices of a specified type.
*
* Wraps clCreateContextFromType().
*/
@@ -2433,18 +2541,62 @@ public:
{
cl_int error;
-#if !defined(__APPLE__) || !defined(__MACOS)
+#if !defined(__APPLE__) && !defined(__MACOS)
cl_context_properties prop[4] = {CL_CONTEXT_PLATFORM, 0, 0, 0 };
+
if (properties == NULL) {
- prop[1] = (cl_context_properties)Platform::get(&error)();
+ // Get a valid platform ID as we cannot send in a blank one
+ VECTOR_CLASS platforms;
+ error = Platform::get(&platforms);
if (error != CL_SUCCESS) {
detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
if (err != NULL) {
*err = error;
+ }
return;
}
+
+ // Check the platforms we found for a device of our specified type
+ cl_context_properties platform_id = 0;
+ for (unsigned int i = 0; i < platforms.size(); i++) {
+
+ VECTOR_CLASS devices;
+
+#if defined(__CL_ENABLE_EXCEPTIONS)
+ try {
+#endif
+
+ error = platforms[i].getDevices(type, &devices);
+
+#if defined(__CL_ENABLE_EXCEPTIONS)
+ } catch (Error) {}
+ // Catch if exceptions are enabled as we don't want to exit if first platform has no devices of type
+ // We do error checking next anyway, and can throw there if needed
+#endif
+
+ // Only squash CL_SUCCESS and CL_DEVICE_NOT_FOUND
+ if (error != CL_SUCCESS && error != CL_DEVICE_NOT_FOUND) {
+ detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
+ if (err != NULL) {
+ *err = error;
+ }
+ }
+
+ if (devices.size() > 0) {
+ platform_id = (cl_context_properties)platforms[i]();
+ break;
+ }
}
+ if (platform_id == 0) {
+ detail::errHandler(CL_DEVICE_NOT_FOUND, __CREATE_CONTEXT_FROM_TYPE_ERR);
+ if (err != NULL) {
+ *err = CL_DEVICE_NOT_FOUND;
+ }
+ return;
+ }
+
+ prop[1] = platform_id;
properties = &prop[0];
}
#endif
@@ -2457,6 +2609,36 @@ public:
}
}
+ /*! \brief Copy constructor to forward copy to the superclass correctly.
+ * Required for MSVC.
+ */
+ Context(const Context& ctx) : detail::Wrapper(ctx) {}
+
+ /*! \brief Copy assignment to forward copy to the superclass correctly.
+ * Required for MSVC.
+ */
+ Context& operator = (const Context &ctx)
+ {
+ detail::Wrapper::operator=(ctx);
+ return *this;
+ }
+
+#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
+ /*! \brief Move constructor to forward move to the superclass correctly.
+ * Required for MSVC.
+ */
+ Context(Context&& ctx) CL_HPP_NOEXCEPT : detail::Wrapper(std::move(ctx)) {}
+
+ /*! \brief Move assignment to forward move to the superclass correctly.
+ * Required for MSVC.
+ */
+ Context& operator = (Context &&ctx)
+ {
+ detail::Wrapper::operator=(std::move(ctx));
+ return *this;
+ }
+#endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
+
/*! \brief Returns a singleton context including all devices of CL_DEVICE_TYPE_DEFAULT.
*
* \note All calls to this function return the same cl_context as the first.
@@ -2512,12 +2694,6 @@ public:
//! \brief Default constructor - initializes to NULL.
Context() : detail::Wrapper() { }
- /*! \brief Copy constructor.
- *
- * This calls clRetainContext() on the parameter's cl_context.
- */
- Context(const Context& context) : detail::Wrapper(context) { }
-
/*! \brief Constructor from cl_context - takes ownership.
*
* This effectively transfers ownership of a refcount on the cl_context
@@ -2525,19 +2701,6 @@ public:
*/
__CL_EXPLICIT_CONSTRUCTORS Context(const cl_context& context) : detail::Wrapper(context) { }
- /*! \brief Assignment operator from Context.
- *
- * This calls clRetainContext() on the parameter and clReleaseContext() on
- * the previous value held by this instance.
- */
- Context& operator = (const Context& rhs)
- {
- if (this != &rhs) {
- detail::Wrapper::operator=(rhs);
- }
- return *this;
- }
-
/*! \brief Assignment operator from cl_context - takes ownership.
*
* This effectively transfers ownership of a refcount on the rhs and calls
@@ -2582,6 +2745,11 @@ public:
VECTOR_CLASS* formats) const
{
cl_uint numEntries;
+
+ if (!formats) {
+ return CL_SUCCESS;
+ }
+
cl_int err = ::clGetSupportedImageFormats(
object_,
flags,
@@ -2593,6 +2761,7 @@ public:
return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
}
+ if (numEntries > 0) {
ImageFormat* value = (ImageFormat*)
alloca(numEntries * sizeof(ImageFormat));
err = ::clGetSupportedImageFormats(
@@ -2607,6 +2776,10 @@ public:
}
formats->assign(&value[0], &value[numEntries]);
+ }
+ else {
+ formats->clear();
+ }
return CL_SUCCESS;
}
};
@@ -2617,7 +2790,7 @@ inline Device Device::getDefault(cl_int * err)
Device device;
Context context = Context::getDefault(&error);
- detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
+ detail::errHandler(error, __CREATE_CONTEXT_ERR);
if (error != CL_SUCCESS) {
if (err != NULL) {
@@ -2636,14 +2809,22 @@ inline Device Device::getDefault(cl_int * err)
#ifdef _WIN32
+#ifdef CL_HPP_CPP11_ATOMICS_SUPPORTED
+__declspec(selectany) std::atomic Context::default_initialized_;
+#else // !CL_HPP_CPP11_ATOMICS_SUPPORTED
__declspec(selectany) volatile int Context::default_initialized_ = __DEFAULT_NOT_INITIALIZED;
+#endif // !CL_HPP_CPP11_ATOMICS_SUPPORTED
__declspec(selectany) Context Context::default_;
__declspec(selectany) volatile cl_int Context::default_error_ = CL_SUCCESS;
-#else
+#else // !_WIN32
+#ifdef CL_HPP_CPP11_ATOMICS_SUPPORTED
+__attribute__((weak)) std::atomic Context::default_initialized_;
+#else // !CL_HPP_CPP11_ATOMICS_SUPPORTED
__attribute__((weak)) volatile int Context::default_initialized_ = __DEFAULT_NOT_INITIALIZED;
+#endif // !CL_HPP_CPP11_ATOMICS_SUPPORTED
__attribute__((weak)) Context Context::default_;
__attribute__((weak)) volatile cl_int Context::default_error_ = CL_SUCCESS;
-#endif
+#endif // !_WIN32
/*! \brief Class interface for cl_event.
*
@@ -2656,46 +2837,21 @@ __attribute__((weak)) volatile cl_int Context::default_error_ = CL_SUCCESS;
class Event : public detail::Wrapper
{
public:
- /*! \brief Destructor.
- *
- * This calls clReleaseEvent() on the value held by this instance.
- */
- ~Event() { }
-
//! \brief Default constructor - initializes to NULL.
Event() : detail::Wrapper() { }
- /*! \brief Copy constructor.
- *
- * This calls clRetainEvent() on the parameter's cl_event.
- */
- Event(const Event& event) : detail::Wrapper(event) { }
-
/*! \brief Constructor from cl_event - takes ownership.
*
* This effectively transfers ownership of a refcount on the cl_event
* into the new Event object.
*/
- Event(const cl_event& event) : detail::Wrapper(event) { }
+ __CL_EXPLICIT_CONSTRUCTORS Event(const cl_event& event) : detail::Wrapper(event) { }
/*! \brief Assignment operator from cl_event - takes ownership.
*
* This effectively transfers ownership of a refcount on the rhs and calls
* clReleaseEvent() on the value previously held by this instance.
*/
- Event& operator = (const Event& rhs)
- {
- if (this != &rhs) {
- detail::Wrapper::operator=(rhs);
- }
- return *this;
- }
-
- /*! \brief Assignment operator from cl_event.
- *
- * This calls clRetainEvent() on the parameter and clReleaseEvent() on
- * the previous value held by this instance.
- */
Event& operator = (const cl_event& rhs)
{
detail::Wrapper::operator=(rhs);
@@ -2788,7 +2944,7 @@ public:
{
return detail::errHandler(
::clWaitForEvents(
- (cl_uint) events.size(), (cl_event*)&events.front()),
+ (cl_uint) events.size(), (events.size() > 0) ? (cl_event*)&events.front() : NULL),
__WAIT_FOR_EVENTS_ERR);
}
};
@@ -2823,18 +2979,6 @@ public:
//! \brief Default constructor - initializes to NULL.
UserEvent() : Event() { }
- //! \brief Copy constructor - performs shallow copy.
- UserEvent(const UserEvent& event) : Event(event) { }
-
- //! \brief Assignment Operator - performs shallow copy.
- UserEvent& operator = (const UserEvent& rhs)
- {
- if (this != &rhs) {
- Event::operator=(rhs);
- }
- return *this;
- }
-
/*! \brief Sets the execution status of a user event object.
*
* Wraps clSetUserEventStatus().
@@ -2857,7 +3001,7 @@ WaitForEvents(const VECTOR_CLASS& events)
{
return detail::errHandler(
::clWaitForEvents(
- (cl_uint) events.size(), (cl_event*)&events.front()),
+ (cl_uint) events.size(), (events.size() > 0) ? (cl_event*)&events.front() : NULL),
__WAIT_FOR_EVENTS_ERR);
}
@@ -2872,22 +3016,9 @@ WaitForEvents(const VECTOR_CLASS& events)
class Memory : public detail::Wrapper
{
public:
-
- /*! \brief Destructor.
- *
- * This calls clReleaseMemObject() on the value held by this instance.
- */
- ~Memory() {}
-
//! \brief Default constructor - initializes to NULL.
Memory() : detail::Wrapper() { }
- /*! \brief Copy constructor - performs shallow copy.
- *
- * This calls clRetainMemObject() on the parameter's cl_mem.
- */
- Memory(const Memory& memory) : detail::Wrapper(memory) { }
-
/*! \brief Constructor from cl_mem - takes ownership.
*
* This effectively transfers ownership of a refcount on the cl_mem
@@ -2895,30 +3026,47 @@ public:
*/
__CL_EXPLICIT_CONSTRUCTORS Memory(const cl_mem& memory) : detail::Wrapper(memory) { }
- /*! \brief Assignment operator from Memory.
- *
- * This calls clRetainMemObject() on the parameter and clReleaseMemObject()
- * on the previous value held by this instance.
- */
- Memory& operator = (const Memory& rhs)
- {
- if (this != &rhs) {
- detail::Wrapper::operator=(rhs);
- }
- return *this;
- }
-
/*! \brief Assignment operator from cl_mem - takes ownership.
- *
+ *
* This effectively transfers ownership of a refcount on the rhs and calls
* clReleaseMemObject() on the value previously held by this instance.
*/
Memory& operator = (const cl_mem& rhs)
{
- detail::Wrapper::operator=(rhs);
+ detail::Wrapper::operator=(rhs);
+ return *this;
+ }
+
+ /*! \brief Copy constructor to forward copy to the superclass correctly.
+ * Required for MSVC.
+ */
+ Memory(const Memory& mem) : detail::Wrapper(mem) {}
+
+ /*! \brief Copy assignment to forward copy to the superclass correctly.
+ * Required for MSVC.
+ */
+ Memory& operator = (const Memory &mem)
+ {
+ detail::Wrapper::operator=(mem);
return *this;
}
+#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
+ /*! \brief Move constructor to forward move to the superclass correctly.
+ * Required for MSVC.
+ */
+ Memory(Memory&& mem) CL_HPP_NOEXCEPT : detail::Wrapper(std::move(mem)) {}
+
+ /*! \brief Move assignment to forward move to the superclass correctly.
+ * Required for MSVC.
+ */
+ Memory& operator = (Memory &&mem)
+ {
+ detail::Wrapper::operator=(std::move(mem));
+ return *this;
+ }
+#endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
+
//! \brief Wrapper for clGetMemObjectInfo().
template
cl_int getInfo(cl_mem_info name, T* param) const
@@ -2977,6 +3125,11 @@ template< typename IteratorType >
cl_int copy( IteratorType startIterator, IteratorType endIterator, cl::Buffer &buffer );
template< typename IteratorType >
cl_int copy( const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator );
+template< typename IteratorType >
+cl_int copy( const CommandQueue &queue, IteratorType startIterator, IteratorType endIterator, cl::Buffer &buffer );
+template< typename IteratorType >
+cl_int copy( const CommandQueue &queue, const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator );
+
/*! \brief Class interface for Buffer Memory Objects.
*
@@ -3040,7 +3193,8 @@ public:
/*!
* \brief Construct a Buffer from a host container via iterators.
- * If useHostPtr is specified iterators must be random access.
+ * IteratorType must be random access.
+ * If useHostPtr is specified iterators must represent contiguous data.
*/
template< typename IteratorType >
Buffer(
@@ -3088,43 +3242,72 @@ public:
}
}
+ /*!
+ * \brief Construct a Buffer from a host container via iterators using a specified context.
+ * IteratorType must be random access.
+ * If useHostPtr is specified iterators must represent contiguous data.
+ */
+ template< typename IteratorType >
+ Buffer(const Context &context, IteratorType startIterator, IteratorType endIterator,
+ bool readOnly, bool useHostPtr = false, cl_int* err = NULL);
+
+ /*!
+ * \brief Construct a Buffer from a host container via iterators using a specified queue.
+ * If useHostPtr is specified iterators must represent contiguous data.
+ */
+ template< typename IteratorType >
+ Buffer(const CommandQueue &queue, IteratorType startIterator, IteratorType endIterator,
+ bool readOnly, bool useHostPtr = false, cl_int* err = NULL);
+
//! \brief Default constructor - initializes to NULL.
Buffer() : Memory() { }
- /*! \brief Copy constructor - performs shallow copy.
- *
- * See Memory for further details.
- */
- Buffer(const Buffer& buffer) : Memory(buffer) { }
-
/*! \brief Constructor from cl_mem - takes ownership.
*
* See Memory for further details.
*/
__CL_EXPLICIT_CONSTRUCTORS Buffer(const cl_mem& buffer) : Memory(buffer) { }
- /*! \brief Assignment from Buffer - performs shallow copy.
- *
- * See Memory for further details.
- */
- Buffer& operator = (const Buffer& rhs)
- {
- if (this != &rhs) {
- Memory::operator=(rhs);
- }
- return *this;
- }
-
/*! \brief Assignment from cl_mem - performs shallow copy.
*
* See Memory for further details.
*/
Buffer& operator = (const cl_mem& rhs)
{
- Memory::operator=(rhs);
+ Memory::operator=(rhs);
+ return *this;
+ }
+
+ /*! \brief Copy constructor to forward copy to the superclass correctly.
+ * Required for MSVC.
+ */
+ Buffer(const Buffer& buf) : Memory(buf) {}
+
+ /*! \brief Copy assignment to forward copy to the superclass correctly.
+ * Required for MSVC.
+ */
+ Buffer& operator = (const Buffer &buf)
+ {
+ Memory::operator=(buf);
return *this;
}
+#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
+ /*! \brief Move constructor to forward move to the superclass correctly.
+ * Required for MSVC.
+ */
+ Buffer(Buffer&& buf) CL_HPP_NOEXCEPT : Memory(std::move(buf)) {}
+
+ /*! \brief Move assignment to forward move to the superclass correctly.
+ * Required for MSVC.
+ */
+ Buffer& operator = (Buffer &&buf)
+ {
+ Memory::operator=(std::move(buf));
+ return *this;
+ }
+#endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
+
#if defined(CL_VERSION_1_1)
/*! \brief Creates a new buffer object from this.
*
@@ -3214,39 +3397,51 @@ public:
//! \brief Default constructor - initializes to NULL.
BufferD3D10() : Buffer() { }
- /*! \brief Copy constructor - performs shallow copy.
- *
- * See Memory for further details.
- */
- BufferD3D10(const BufferD3D10& buffer) : Buffer(buffer) { }
-
/*! \brief Constructor from cl_mem - takes ownership.
*
* See Memory for further details.
*/
__CL_EXPLICIT_CONSTRUCTORS BufferD3D10(const cl_mem& buffer) : Buffer(buffer) { }
- /*! \brief Assignment from BufferD3D10 - performs shallow copy.
- *
- * See Memory for further details.
- */
- BufferD3D10& operator = (const BufferD3D10& rhs)
- {
- if (this != &rhs) {
- Buffer::operator=(rhs);
- }
- return *this;
- }
-
/*! \brief Assignment from cl_mem - performs shallow copy.
*
* See Memory for further details.
*/
BufferD3D10& operator = (const cl_mem& rhs)
{
- Buffer::operator=(rhs);
+ Buffer::operator=(rhs);
+ return *this;
+ }
+
+ /*! \brief Copy constructor to forward copy to the superclass correctly.
+ * Required for MSVC.
+ */
+ BufferD3D10(const BufferD3D10& buf) : Buffer(buf) {}
+
+ /*! \brief Copy assignment to forward copy to the superclass correctly.
+ * Required for MSVC.
+ */
+ BufferD3D10& operator = (const BufferD3D10 &buf)
+ {
+ Buffer::operator=(buf);
return *this;
}
+
+#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
+ /*! \brief Move constructor to forward move to the superclass correctly.
+ * Required for MSVC.
+ */
+ BufferD3D10(BufferD3D10&& buf) CL_HPP_NOEXCEPT : Buffer(std::move(buf)) {}
+
+ /*! \brief Move assignment to forward move to the superclass correctly.
+ * Required for MSVC.
+ */
+ BufferD3D10& operator = (BufferD3D10 &&buf)
+ {
+ Buffer::operator=(std::move(buf));
+ return *this;
+ }
+#endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
};
#endif
@@ -3269,7 +3464,7 @@ public:
BufferGL(
const Context& context,
cl_mem_flags flags,
- GLuint bufobj,
+ cl_GLuint bufobj,
cl_int * err = NULL)
{
cl_int error;
@@ -3288,30 +3483,12 @@ public:
//! \brief Default constructor - initializes to NULL.
BufferGL() : Buffer() { }
- /*! \brief Copy constructor - performs shallow copy.
- *
- * See Memory for further details.
- */
- BufferGL(const BufferGL& buffer) : Buffer(buffer) { }
-
/*! \brief Constructor from cl_mem - takes ownership.
*
* See Memory for further details.
*/
__CL_EXPLICIT_CONSTRUCTORS BufferGL(const cl_mem& buffer) : Buffer(buffer) { }
- /*! \brief Assignment from BufferGL - performs shallow copy.
- *
- * See Memory for further details.
- */
- BufferGL& operator = (const BufferGL& rhs)
- {
- if (this != &rhs) {
- Buffer::operator=(rhs);
- }
- return *this;
- }
-
/*! \brief Assignment from cl_mem - performs shallow copy.
*
* See Memory for further details.
@@ -3322,93 +3499,40 @@ public:
return *this;
}
- //! \brief Wrapper for clGetGLObjectInfo().
- cl_int getObjectInfo(
- cl_gl_object_type *type,
- GLuint * gl_object_name)
- {
- return detail::errHandler(
- ::clGetGLObjectInfo(object_,type,gl_object_name),
- __GET_GL_OBJECT_INFO_ERR);
- }
-};
+ /*! \brief Copy constructor to forward copy to the superclass correctly.
+ * Required for MSVC.
+ */
+ BufferGL(const BufferGL& buf) : Buffer(buf) {}
-/*! \brief Class interface for GL Render Buffer Memory Objects.
- *
- * This is provided to facilitate interoperability with OpenGL.
- *
- * See Memory for details about copy semantics, etc.
- *
- * \see Memory
+ /*! \brief Copy assignment to forward copy to the superclass correctly.
+ * Required for MSVC.
*/
-class BufferRenderGL : public Buffer
+ BufferGL& operator = (const BufferGL &buf)
{
-public:
- /*! \brief Constructs a BufferRenderGL in a specified context, from a given
- * GL Renderbuffer.
- *
- * Wraps clCreateFromGLRenderbuffer().
- */
- BufferRenderGL(
- const Context& context,
- cl_mem_flags flags,
- GLuint bufobj,
- cl_int * err = NULL)
- {
- cl_int error;
- object_ = ::clCreateFromGLRenderbuffer(
- context(),
- flags,
- bufobj,
- &error);
-
- detail::errHandler(error, __CREATE_GL_RENDER_BUFFER_ERR);
- if (err != NULL) {
- *err = error;
- }
- }
-
- //! \brief Default constructor - initializes to NULL.
- BufferRenderGL() : Buffer() { }
-
- /*! \brief Copy constructor - performs shallow copy.
- *
- * See Memory for further details.
- */
- BufferRenderGL(const BufferGL& buffer) : Buffer(buffer) { }
-
- /*! \brief Constructor from cl_mem - takes ownership.
- *
- * See Memory for further details.
- */
- __CL_EXPLICIT_CONSTRUCTORS BufferRenderGL(const cl_mem& buffer) : Buffer(buffer) { }
-
- /*! \brief Assignment from BufferGL - performs shallow copy.
- *
- * See Memory for further details.
- */
- BufferRenderGL& operator = (const BufferRenderGL& rhs)
- {
- if (this != &rhs) {
- Buffer::operator=(rhs);
- }
+ Buffer::operator=(buf);
return *this;
}
- /*! \brief Assignment from cl_mem - performs shallow copy.
- *
- * See Memory for further details.
+#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
+ /*! \brief Move constructor to forward move to the superclass correctly.
+ * Required for MSVC.
*/
- BufferRenderGL& operator = (const cl_mem& rhs)
+ BufferGL(BufferGL&& buf) CL_HPP_NOEXCEPT : Buffer(std::move(buf)) {}
+
+ /*! \brief Move assignment to forward move to the superclass correctly.
+ * Required for MSVC.
+ */
+ BufferGL& operator = (BufferGL &&buf)
{
- Buffer::operator=(rhs);
+ Buffer::operator=(std::move(buf));
return *this;
}
+#endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
//! \brief Wrapper for clGetGLObjectInfo().
cl_int getObjectInfo(
cl_gl_object_type *type,
- GLuint * gl_object_name)
+ cl_GLuint * gl_object_name)
{
return detail::errHandler(
::clGetGLObjectInfo(object_,type,gl_object_name),
@@ -3428,40 +3552,52 @@ protected:
//! \brief Default constructor - initializes to NULL.
Image() : Memory() { }
- /*! \brief Copy constructor - performs shallow copy.
- *
- * See Memory for further details.
- */
- Image(const Image& image) : Memory(image) { }
-
/*! \brief Constructor from cl_mem - takes ownership.
*
* See Memory for further details.
*/
__CL_EXPLICIT_CONSTRUCTORS Image(const cl_mem& image) : Memory(image) { }
- /*! \brief Assignment from Image - performs shallow copy.
- *
- * See Memory for further details.
- */
- Image& operator = (const Image& rhs)
- {
- if (this != &rhs) {
- Memory::operator=(rhs);
- }
- return *this;
- }
-
/*! \brief Assignment from cl_mem - performs shallow copy.
*
* See Memory for further details.
*/
Image& operator = (const cl_mem& rhs)
{
- Memory::operator=(rhs);
+ Memory::operator=(rhs);
+ return *this;
+ }
+
+ /*! \brief Copy constructor to forward copy to the superclass correctly.
+ * Required for MSVC.
+ */
+ Image(const Image& img) : Memory(img) {}
+
+ /*! \brief Copy assignment to forward copy to the superclass correctly.
+ * Required for MSVC.
+ */
+ Image& operator = (const Image &img)
+ {
+ Memory::operator=(img);
return *this;
}
+#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
+ /*! \brief Move constructor to forward move to the superclass correctly.
+ * Required for MSVC.
+ */
+ Image(Image&& img) CL_HPP_NOEXCEPT : Memory(std::move(img)) {}
+
+ /*! \brief Move assignment to forward move to the superclass correctly.
+ * Required for MSVC.
+ */
+ Image& operator = (Image &&img)
+ {
+ Memory::operator=(std::move(img));
+ return *this;
+ }
+#endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
+
public:
//! \brief Wrapper for clGetImageInfo().
template
@@ -3510,13 +3646,12 @@ public:
cl_int* err = NULL)
{
cl_int error;
- cl_image_desc desc;
- desc.image_type = CL_MEM_OBJECT_IMAGE1D;
- desc.image_width = width;
- desc.image_row_pitch = 0;
- desc.num_mip_levels = 0;
- desc.num_samples = 0;
- desc.buffer = 0;
+ cl_image_desc desc =
+ {
+ CL_MEM_OBJECT_IMAGE1D,
+ width,
+ 0, 0, 0, 0, 0, 0, 0, 0
+ };
object_ = ::clCreateImage(
context(),
flags,
@@ -3534,39 +3669,51 @@ public:
//! \brief Default constructor - initializes to NULL.
Image1D() { }
- /*! \brief Copy constructor - performs shallow copy.
- *
- * See Memory for further details.
- */
- Image1D(const Image1D& image1D) : Image(image1D) { }
-
/*! \brief Constructor from cl_mem - takes ownership.
*
* See Memory for further details.
*/
__CL_EXPLICIT_CONSTRUCTORS Image1D(const cl_mem& image1D) : Image(image1D) { }
- /*! \brief Assignment from Image1D - performs shallow copy.
- *
- * See Memory for further details.
- */
- Image1D& operator = (const Image1D& rhs)
- {
- if (this != &rhs) {
- Image::operator=(rhs);
- }
- return *this;
- }
-
/*! \brief Assignment from cl_mem - performs shallow copy.
*
* See Memory for further details.
*/
Image1D& operator = (const cl_mem& rhs)
{
- Image::operator=(rhs);
+ Image::operator=(rhs);
+ return *this;
+ }
+
+ /*! \brief Copy constructor to forward copy to the superclass correctly.
+ * Required for MSVC.
+ */
+ Image1D(const Image1D& img) : Image(img) {}
+
+ /*! \brief Copy assignment to forward copy to the superclass correctly.
+ * Required for MSVC.
+ */
+ Image1D& operator = (const Image1D &img)
+ {
+ Image::operator=(img);
return *this;
}
+
+#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
+ /*! \brief Move constructor to forward move to the superclass correctly.
+ * Required for MSVC.
+ */
+ Image1D(Image1D&& img) CL_HPP_NOEXCEPT : Image(std::move(img)) {}
+
+ /*! \brief Move assignment to forward move to the superclass correctly.
+ * Required for MSVC.
+ */
+ Image1D& operator = (Image1D &&img)
+ {
+ Image::operator=(std::move(img));
+ return *this;
+ }
+#endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
};
/*! \class Image1DBuffer
@@ -3584,13 +3731,13 @@ public:
cl_int* err = NULL)
{
cl_int error;
- cl_image_desc desc;
- desc.image_type = CL_MEM_OBJECT_IMAGE1D_BUFFER;
- desc.image_width = width;
- desc.image_row_pitch = 0;
- desc.num_mip_levels = 0;
- desc.num_samples = 0;
- desc.buffer = buffer();
+ cl_image_desc desc =
+ {
+ CL_MEM_OBJECT_IMAGE1D_BUFFER,
+ width,
+ 0, 0, 0, 0, 0, 0, 0,
+ buffer()
+ };
object_ = ::clCreateImage(
context(),
flags,
@@ -3607,23 +3754,43 @@ public:
Image1DBuffer() { }
- Image1DBuffer(const Image1DBuffer& image1D) : Image(image1D) { }
-
__CL_EXPLICIT_CONSTRUCTORS Image1DBuffer(const cl_mem& image1D) : Image(image1D) { }
- Image1DBuffer& operator = (const Image1DBuffer& rhs)
- {
- if (this != &rhs) {
- Image::operator=(rhs);
- }
- return *this;
- }
-
Image1DBuffer& operator = (const cl_mem& rhs)
{
- Image::operator=(rhs);
+ Image::operator=(rhs);
+ return *this;
+ }
+
+ /*! \brief Copy constructor to forward copy to the superclass correctly.
+ * Required for MSVC.
+ */
+ Image1DBuffer(const Image1DBuffer& img) : Image(img) {}
+
+ /*! \brief Copy assignment to forward copy to the superclass correctly.
+ * Required for MSVC.
+ */
+ Image1DBuffer& operator = (const Image1DBuffer &img)
+ {
+ Image::operator=(img);
return *this;
}
+
+#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
+ /*! \brief Move constructor to forward move to the superclass correctly.
+ * Required for MSVC.
+ */
+ Image1DBuffer(Image1DBuffer&& img) CL_HPP_NOEXCEPT : Image(std::move(img)) {}
+
+ /*! \brief Move assignment to forward move to the superclass correctly.
+ * Required for MSVC.
+ */
+ Image1DBuffer& operator = (Image1DBuffer &&img)
+ {
+ Image::operator=(std::move(img));
+ return *this;
+ }
+#endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
};
/*! \class Image1DArray
@@ -3643,14 +3810,15 @@ public:
cl_int* err = NULL)
{
cl_int error;
- cl_image_desc desc;
- desc.image_type = CL_MEM_OBJECT_IMAGE1D_ARRAY;
- desc.image_array_size = arraySize;
- desc.image_width = width;
- desc.image_row_pitch = rowPitch;
- desc.num_mip_levels = 0;
- desc.num_samples = 0;
- desc.buffer = 0;
+ cl_image_desc desc =
+ {
+ CL_MEM_OBJECT_IMAGE1D_ARRAY,
+ width,
+ 0, 0, // height, depth (unused)
+ arraySize,
+ rowPitch,
+ 0, 0, 0, 0
+ };
object_ = ::clCreateImage(
context(),
flags,
@@ -3667,23 +3835,43 @@ public:
Image1DArray() { }
- Image1DArray(const Image1DArray& imageArray) : Image(imageArray) { }
-
__CL_EXPLICIT_CONSTRUCTORS Image1DArray(const cl_mem& imageArray) : Image(imageArray) { }
- Image1DArray& operator = (const Image1DArray& rhs)
- {
- if (this != &rhs) {
- Image::operator=(rhs);
- }
- return *this;
- }
-
Image1DArray& operator = (const cl_mem& rhs)
{
- Image::operator=(rhs);
+ Image::operator=(rhs);
+ return *this;
+ }
+
+ /*! \brief Copy constructor to forward copy to the superclass correctly.
+ * Required for MSVC.
+ */
+ Image1DArray(const Image1DArray& img) : Image(img) {}
+
+ /*! \brief Copy assignment to forward copy to the superclass correctly.
+ * Required for MSVC.
+ */
+ Image1DArray& operator = (const Image1DArray &img)
+ {
+ Image::operator=(img);
return *this;
}
+
+#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
+ /*! \brief Move constructor to forward move to the superclass correctly.
+ * Required for MSVC.
+ */
+ Image1DArray(Image1DArray&& img) CL_HPP_NOEXCEPT : Image(std::move(img)) {}
+
+ /*! \brief Move assignment to forward move to the superclass correctly.
+ * Required for MSVC.
+ */
+ Image1DArray& operator = (Image1DArray &&img)
+ {
+ Image::operator=(std::move(img));
+ return *this;
+ }
+#endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
};
#endif // #if defined(CL_VERSION_1_2)
@@ -3729,14 +3917,15 @@ public:
#if defined(CL_VERSION_1_2)
if (useCreateImage)
{
- 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.num_mip_levels = 0;
- desc.num_samples = 0;
- desc.buffer = 0;
+ cl_image_desc desc =
+ {
+ CL_MEM_OBJECT_IMAGE2D,
+ width,
+ height,
+ 0, 0, // depth, array size (unused)
+ row_pitch,
+ 0, 0, 0, 0
+ };
object_ = ::clCreateImage(
context(),
flags,
@@ -3768,39 +3957,51 @@ public:
//! \brief Default constructor - initializes to NULL.
Image2D() { }
- /*! \brief Copy constructor - performs shallow copy.
- *
- * See Memory for further details.
- */
- Image2D(const Image2D& image2D) : Image(image2D) { }
-
/*! \brief Constructor from cl_mem - takes ownership.
*
* See Memory for further details.
*/
__CL_EXPLICIT_CONSTRUCTORS Image2D(const cl_mem& image2D) : Image(image2D) { }
- /*! \brief Assignment from Image2D - performs shallow copy.
- *
- * See Memory for further details.
- */
- Image2D& operator = (const Image2D& rhs)
- {
- if (this != &rhs) {
- Image::operator=(rhs);
- }
- return *this;
- }
-
/*! \brief Assignment from cl_mem - performs shallow copy.
*
* See Memory for further details.
*/
Image2D& operator = (const cl_mem& rhs)
{
- Image::operator=(rhs);
+ Image::operator=(rhs);
+ return *this;
+ }
+
+ /*! \brief Copy constructor to forward copy to the superclass correctly.
+ * Required for MSVC.
+ */
+ Image2D(const Image2D& img) : Image(img) {}
+
+ /*! \brief Copy assignment to forward copy to the superclass correctly.
+ * Required for MSVC.
+ */
+ Image2D& operator = (const Image2D &img)
+ {
+ Image::operator=(img);
return *this;
}
+
+#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
+ /*! \brief Move constructor to forward move to the superclass correctly.
+ * Required for MSVC.
+ */
+ Image2D(Image2D&& img) CL_HPP_NOEXCEPT : Image(std::move(img)) {}
+
+ /*! \brief Move assignment to forward move to the superclass correctly.
+ * Required for MSVC.
+ */
+ Image2D& operator = (Image2D &&img)
+ {
+ Image::operator=(std::move(img));
+ return *this;
+ }
+#endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
};
@@ -3825,9 +4026,9 @@ public:
Image2DGL(
const Context& context,
cl_mem_flags flags,
- GLenum target,
- GLint miplevel,
- GLuint texobj,
+ cl_GLenum target,
+ cl_GLint miplevel,
+ cl_GLuint texobj,
cl_int * err = NULL)
{
cl_int error;
@@ -3849,39 +4050,51 @@ public:
//! \brief Default constructor - initializes to NULL.
Image2DGL() : Image2D() { }
- /*! \brief Copy constructor - performs shallow copy.
- *
- * See Memory for further details.
- */
- Image2DGL(const Image2DGL& image) : Image2D(image) { }
-
/*! \brief Constructor from cl_mem - takes ownership.
*
* See Memory for further details.
*/
__CL_EXPLICIT_CONSTRUCTORS Image2DGL(const cl_mem& image) : Image2D(image) { }
- /*! \brief Assignment from Image2DGL - performs shallow copy.
- *
- * See Memory for further details.
- */
- Image2DGL& operator = (const Image2DGL& rhs)
- {
- if (this != &rhs) {
- Image2D::operator=(rhs);
- }
- return *this;
- }
-
/*! \brief Assignment from cl_mem - performs shallow copy.
*
* See Memory for further details.
*/
Image2DGL& operator = (const cl_mem& rhs)
{
- Image2D::operator=(rhs);
+ Image2D::operator=(rhs);
+ return *this;
+ }
+
+ /*! \brief Copy constructor to forward copy to the superclass correctly.
+ * Required for MSVC.
+ */
+ Image2DGL(const Image2DGL& img) : Image2D(img) {}
+
+ /*! \brief Copy assignment to forward copy to the superclass correctly.
+ * Required for MSVC.
+ */
+ Image2DGL& operator = (const Image2DGL &img)
+ {
+ Image2D::operator=(img);
return *this;
}
+
+#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
+ /*! \brief Move constructor to forward move to the superclass correctly.
+ * Required for MSVC.
+ */
+ Image2DGL(Image2DGL&& img) CL_HPP_NOEXCEPT : Image2D(std::move(img)) {}
+
+ /*! \brief Move assignment to forward move to the superclass correctly.
+ * Required for MSVC.
+ */
+ Image2DGL& operator = (Image2DGL &&img)
+ {
+ Image2D::operator=(std::move(img));
+ return *this;
+ }
+#endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
};
#endif // #if !defined(CL_VERSION_1_2)
@@ -3905,16 +4118,17 @@ public:
cl_int* err = NULL)
{
cl_int error;
- cl_image_desc desc;
- desc.image_type = CL_MEM_OBJECT_IMAGE2D_ARRAY;
- desc.image_array_size = arraySize;
- desc.image_width = width;
- desc.image_height = height;
- desc.image_row_pitch = rowPitch;
- desc.image_slice_pitch = slicePitch;
- desc.num_mip_levels = 0;
- desc.num_samples = 0;
- desc.buffer = 0;
+ cl_image_desc desc =
+ {
+ CL_MEM_OBJECT_IMAGE2D_ARRAY,
+ width,
+ height,
+ 0, // depth (unused)
+ arraySize,
+ rowPitch,
+ slicePitch,
+ 0, 0, 0
+ };
object_ = ::clCreateImage(
context(),
flags,
@@ -3931,23 +4145,43 @@ public:
Image2DArray() { }
- Image2DArray(const Image2DArray& imageArray) : Image(imageArray) { }
-
__CL_EXPLICIT_CONSTRUCTORS Image2DArray(const cl_mem& imageArray) : Image(imageArray) { }
- Image2DArray& operator = (const Image2DArray& rhs)
- {
- if (this != &rhs) {
- Image::operator=(rhs);
- }
- return *this;
- }
-
Image2DArray& operator = (const cl_mem& rhs)
{
- Image::operator=(rhs);
+ Image::operator=(rhs);
+ return *this;
+ }
+
+ /*! \brief Copy constructor to forward copy to the superclass correctly.
+ * Required for MSVC.
+ */
+ Image2DArray(const Image2DArray& img) : Image(img) {}
+
+ /*! \brief Copy assignment to forward copy to the superclass correctly.
+ * Required for MSVC.
+ */
+ Image2DArray& operator = (const Image2DArray &img)
+ {
+ Image::operator=(img);
return *this;
}
+
+#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
+ /*! \brief Move constructor to forward move to the superclass correctly.
+ * Required for MSVC.
+ */
+ Image2DArray(Image2DArray&& img) CL_HPP_NOEXCEPT : Image(std::move(img)) {}
+
+ /*! \brief Move assignment to forward move to the superclass correctly.
+ * Required for MSVC.
+ */
+ Image2DArray& operator = (Image2DArray &&img)
+ {
+ Image::operator=(std::move(img));
+ return *this;
+ }
+#endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
};
#endif // #if defined(CL_VERSION_1_2)
@@ -3994,16 +4228,17 @@ public:
#if defined(CL_VERSION_1_2)
if (useCreateImage)
{
- 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;
- desc.num_mip_levels = 0;
- desc.num_samples = 0;
- desc.buffer = 0;
+ cl_image_desc desc =
+ {
+ CL_MEM_OBJECT_IMAGE3D,
+ width,
+ height,
+ depth,
+ 0, // array size (unused)
+ row_pitch,
+ slice_pitch,
+ 0, 0, 0
+ };
object_ = ::clCreateImage(
context(),
flags,
@@ -4034,13 +4269,7 @@ public:
}
//! \brief Default constructor - initializes to NULL.
- Image3D() { }
-
- /*! \brief Copy constructor - performs shallow copy.
- *
- * See Memory for further details.
- */
- Image3D(const Image3D& image3D) : Image(image3D) { }
+ Image3D() : Image() { }
/*! \brief Constructor from cl_mem - takes ownership.
*
@@ -4048,27 +4277,45 @@ public:
*/
__CL_EXPLICIT_CONSTRUCTORS Image3D(const cl_mem& image3D) : Image(image3D) { }
- /*! \brief Assignment from Image3D - performs shallow copy.
- *
- * See Memory for further details.
- */
- Image3D& operator = (const Image3D& rhs)
- {
- if (this != &rhs) {
- Image::operator=(rhs);
- }
- return *this;
- }
-
/*! \brief Assignment from cl_mem - performs shallow copy.
*
* See Memory for further details.
*/
Image3D& operator = (const cl_mem& rhs)
{
- Image::operator=(rhs);
+ Image::operator=(rhs);
+ return *this;
+ }
+
+ /*! \brief Copy constructor to forward copy to the superclass correctly.
+ * Required for MSVC.
+ */
+ Image3D(const Image3D& img) : Image(img) {}
+
+ /*! \brief Copy assignment to forward copy to the superclass correctly.
+ * Required for MSVC.
+ */
+ Image3D& operator = (const Image3D &img)
+ {
+ Image::operator=(img);
return *this;
}
+
+#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
+ /*! \brief Move constructor to forward move to the superclass correctly.
+ * Required for MSVC.
+ */
+ Image3D(Image3D&& img) CL_HPP_NOEXCEPT : Image(std::move(img)) {}
+
+ /*! \brief Move assignment to forward move to the superclass correctly.
+ * Required for MSVC.
+ */
+ Image3D& operator = (Image3D &&img)
+ {
+ Image::operator=(std::move(img));
+ return *this;
+ }
+#endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
};
#if !defined(CL_VERSION_1_2)
@@ -4091,9 +4338,9 @@ public:
Image3DGL(
const Context& context,
cl_mem_flags flags,
- GLenum target,
- GLint miplevel,
- GLuint texobj,
+ cl_GLenum target,
+ cl_GLint miplevel,
+ cl_GLuint texobj,
cl_int * err = NULL)
{
cl_int error;
@@ -4114,39 +4361,51 @@ public:
//! \brief Default constructor - initializes to NULL.
Image3DGL() : Image3D() { }
- /*! \brief Copy constructor - performs shallow copy.
- *
- * See Memory for further details.
- */
- Image3DGL(const Image3DGL& image) : Image3D(image) { }
-
/*! \brief Constructor from cl_mem - takes ownership.
*
* See Memory for further details.
*/
__CL_EXPLICIT_CONSTRUCTORS Image3DGL(const cl_mem& image) : Image3D(image) { }
- /*! \brief Assignment from Image3DGL - performs shallow copy.
- *
- * See Memory for further details.
- */
- Image3DGL& operator = (const Image3DGL& rhs)
- {
- if (this != &rhs) {
- Image3D::operator=(rhs);
- }
- return *this;
- }
-
/*! \brief Assignment from cl_mem - performs shallow copy.
*
* See Memory for further details.
*/
Image3DGL& operator = (const cl_mem& rhs)
{
- Image3D::operator=(rhs);
+ Image3D::operator=(rhs);
+ return *this;
+ }
+
+ /*! \brief Copy constructor to forward copy to the superclass correctly.
+ * Required for MSVC.
+ */
+ Image3DGL(const Image3DGL& img) : Image3D(img) {}
+
+ /*! \brief Copy assignment to forward copy to the superclass correctly.
+ * Required for MSVC.
+ */
+ Image3DGL& operator = (const Image3DGL &img)
+ {
+ Image3D::operator=(img);
return *this;
}
+
+#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
+ /*! \brief Move constructor to forward move to the superclass correctly.
+ * Required for MSVC.
+ */
+ Image3DGL(Image3DGL&& img) CL_HPP_NOEXCEPT : Image3D(std::move(img)) {}
+
+ /*! \brief Move assignment to forward move to the superclass correctly.
+ * Required for MSVC.
+ */
+ Image3DGL& operator = (Image3DGL &&img)
+ {
+ Image3D::operator=(std::move(img));
+ return *this;
+ }
+#endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
};
#endif // #if !defined(CL_VERSION_1_2)
@@ -4163,9 +4422,9 @@ public:
ImageGL(
const Context& context,
cl_mem_flags flags,
- GLenum target,
- GLint miplevel,
- GLuint texobj,
+ cl_GLenum target,
+ cl_GLint miplevel,
+ cl_GLuint texobj,
cl_int * err = NULL)
{
cl_int error;
@@ -4185,26 +4444,178 @@ public:
ImageGL() : Image() { }
- ImageGL(const ImageGL& image) : Image(image) { }
-
__CL_EXPLICIT_CONSTRUCTORS ImageGL(const cl_mem& image) : Image(image) { }
- ImageGL& operator = (const ImageGL& rhs)
- {
- if (this != &rhs) {
- Image::operator=(rhs);
- }
- return *this;
- }
-
ImageGL& operator = (const cl_mem& rhs)
{
- Image::operator=(rhs);
+ Image::operator=(rhs);
+ return *this;
+ }
+
+ /*! \brief Copy constructor to forward copy to the superclass correctly.
+ * Required for MSVC.
+ */
+ ImageGL(const ImageGL& img) : Image(img) {}
+
+ /*! \brief Copy assignment to forward copy to the superclass correctly.
+ * Required for MSVC.
+ */
+ ImageGL& operator = (const ImageGL &img)
+ {
+ Image::operator=(img);
return *this;
}
+
+#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
+ /*! \brief Move constructor to forward move to the superclass correctly.
+ * Required for MSVC.
+ */
+ ImageGL(ImageGL&& img) CL_HPP_NOEXCEPT : Image(std::move(img)) {}
+
+ /*! \brief Move assignment to forward move to the superclass correctly.
+ * Required for MSVC.
+ */
+ ImageGL& operator = (ImageGL &&img)
+ {
+ Image::operator=(std::move(img));
+ return *this;
+ }
+#endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
};
#endif // #if defined(CL_VERSION_1_2)
+/*! \brief Class interface for GL Render Buffer Memory Objects.
+*
+* This is provided to facilitate interoperability with OpenGL.
+*
+* See Memory for details about copy semantics, etc.
+*
+* \see Memory
+*/
+class BufferRenderGL :
+#if defined(CL_VERSION_1_2)
+ public ImageGL
+#else // #if defined(CL_VERSION_1_2)
+ public Image2DGL
+#endif //#if defined(CL_VERSION_1_2)
+{
+public:
+ /*! \brief Constructs a BufferRenderGL in a specified context, from a given
+ * GL Renderbuffer.
+ *
+ * Wraps clCreateFromGLRenderbuffer().
+ */
+ BufferRenderGL(
+ const Context& context,
+ cl_mem_flags flags,
+ cl_GLuint bufobj,
+ cl_int * err = NULL)
+ {
+ cl_int error;
+ object_ = ::clCreateFromGLRenderbuffer(
+ context(),
+ flags,
+ bufobj,
+ &error);
+
+ detail::errHandler(error, __CREATE_GL_RENDER_BUFFER_ERR);
+ if (err != NULL) {
+ *err = error;
+ }
+ }
+
+ //! \brief Default constructor - initializes to NULL.
+#if defined(CL_VERSION_1_2)
+ BufferRenderGL() : ImageGL() {};
+#else // #if defined(CL_VERSION_1_2)
+ BufferRenderGL() : Image2DGL() {};
+#endif //#if defined(CL_VERSION_1_2)
+
+ /*! \brief Constructor from cl_mem - takes ownership.
+ *
+ * See Memory for further details.
+ */
+#if defined(CL_VERSION_1_2)
+ __CL_EXPLICIT_CONSTRUCTORS BufferRenderGL(const cl_mem& buffer) : ImageGL(buffer) { }
+#else // #if defined(CL_VERSION_1_2)
+ __CL_EXPLICIT_CONSTRUCTORS BufferRenderGL(const cl_mem& buffer) : Image2DGL(buffer) { }
+#endif //#if defined(CL_VERSION_1_2)
+
+
+ /*! \brief Assignment from cl_mem - performs shallow copy.
+ *
+ * See Memory for further details.
+ */
+ BufferRenderGL& operator = (const cl_mem& rhs)
+ {
+#if defined(CL_VERSION_1_2)
+ ImageGL::operator=(rhs);
+#else // #if defined(CL_VERSION_1_2)
+ Image2DGL::operator=(rhs);
+#endif //#if defined(CL_VERSION_1_2)
+
+ return *this;
+ }
+
+ /*! \brief Copy constructor to forward copy to the superclass correctly.
+ * Required for MSVC.
+ */
+#if defined(CL_VERSION_1_2)
+ BufferRenderGL(const BufferRenderGL& buf) : ImageGL(buf) {}
+#else // #if defined(CL_VERSION_1_2)
+ BufferRenderGL(const BufferRenderGL& buf) : Image2DGL(buf) {}
+#endif //#if defined(CL_VERSION_1_2)
+
+ /*! \brief Copy assignment to forward copy to the superclass correctly.
+ * Required for MSVC.
+ */
+ BufferRenderGL& operator = (const BufferRenderGL &rhs)
+ {
+#if defined(CL_VERSION_1_2)
+ ImageGL::operator=(rhs);
+#else // #if defined(CL_VERSION_1_2)
+ Image2DGL::operator=(rhs);
+#endif //#if defined(CL_VERSION_1_2)
+ return *this;
+ }
+
+#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
+ /*! \brief Move constructor to forward move to the superclass correctly.
+ * Required for MSVC.
+ */
+#if defined(CL_VERSION_1_2)
+ BufferRenderGL(BufferRenderGL&& buf) CL_HPP_NOEXCEPT : ImageGL(std::move(buf)) {}
+#else // #if defined(CL_VERSION_1_2)
+ BufferRenderGL(BufferRenderGL&& buf) CL_HPP_NOEXCEPT : Image2DGL(std::move(buf)) {}
+#endif //#if defined(CL_VERSION_1_2)
+
+
+ /*! \brief Move assignment to forward move to the superclass correctly.
+ * Required for MSVC.
+ */
+ BufferRenderGL& operator = (BufferRenderGL &&buf)
+ {
+#if defined(CL_VERSION_1_2)
+ ImageGL::operator=(std::move(buf));
+#else // #if defined(CL_VERSION_1_2)
+ Image2DGL::operator=(std::move(buf));
+#endif //#if defined(CL_VERSION_1_2)
+
+ return *this;
+ }
+#endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
+
+ //! \brief Wrapper for clGetGLObjectInfo().
+ cl_int getObjectInfo(
+ cl_gl_object_type *type,
+ cl_GLuint * gl_object_name)
+ {
+ return detail::errHandler(
+ ::clGetGLObjectInfo(object_, type, gl_object_name),
+ __GET_GL_OBJECT_INFO_ERR);
+ }
+};
+
/*! \brief Class interface for cl_sampler.
*
* \note Copies of these objects are shallow, meaning that the copy will refer
@@ -4216,12 +4627,6 @@ public:
class Sampler : public detail::Wrapper
{
public:
- /*! \brief Destructor.
- *
- * This calls clReleaseSampler() on the value held by this instance.
- */
- ~Sampler() { }
-
//! \brief Default constructor - initializes to NULL.
Sampler() { }
@@ -4250,43 +4655,54 @@ public:
}
}
- /*! \brief Copy constructor - performs shallow copy.
- *
- * This calls clRetainSampler() on the parameter's cl_sampler.
- */
- Sampler(const Sampler& sampler) : detail::Wrapper(sampler) { }
-
/*! \brief Constructor from cl_sampler - takes ownership.
*
* This effectively transfers ownership of a refcount on the cl_sampler
* into the new Sampler object.
*/
- Sampler(const cl_sampler& sampler) : detail::Wrapper(sampler) { }
-
- /*! \brief Assignment operator from Sampler.
- *
- * This calls clRetainSampler() on the parameter and clReleaseSampler()
- * on the previous value held by this instance.
- */
- Sampler& operator = (const Sampler& rhs)
- {
- if (this != &rhs) {
- detail::Wrapper::operator=(rhs);
- }
- return *this;
- }
+ __CL_EXPLICIT_CONSTRUCTORS Sampler(const cl_sampler& sampler) : detail::Wrapper(sampler) { }
/*! \brief Assignment operator from cl_sampler - takes ownership.
- *
+ *
* This effectively transfers ownership of a refcount on the rhs and calls
* clReleaseSampler() on the value previously held by this instance.
*/
Sampler& operator = (const cl_sampler& rhs)
{
- detail::Wrapper::operator=(rhs);
+ detail::Wrapper::operator=(rhs);
+ return *this;
+ }
+
+ /*! \brief Copy constructor to forward copy to the superclass correctly.
+ * Required for MSVC.
+ */
+ Sampler(const Sampler& sam) : detail::Wrapper(sam) {}
+
+ /*! \brief Copy assignment to forward copy to the superclass correctly.
+ * Required for MSVC.
+ */
+ Sampler& operator = (const Sampler &sam)
+ {
+ detail::Wrapper::operator=(sam);
return *this;
}
+#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
+ /*! \brief Move constructor to forward move to the superclass correctly.
+ * Required for MSVC.
+ */
+ Sampler(Sampler&& sam) CL_HPP_NOEXCEPT : detail::Wrapper(std::move(sam)) {}
+
+ /*! \brief Move assignment to forward move to the superclass correctly.
+ * Required for MSVC.
+ */
+ Sampler& operator = (Sampler &&sam)
+ {
+ detail::Wrapper::operator=(std::move(sam));
+ return *this;
+ }
+#endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
+
//! \brief Wrapper for clGetSamplerInfo().
template
cl_int getInfo(cl_sampler_info name, T* param) const
@@ -4379,14 +4795,14 @@ template
struct KernelArgumentHandler
{
static ::size_t size(const T&) { return sizeof(T); }
- static T* ptr(T& value) { return &value; }
+ static const T* ptr(const T& value) { return &value; }
};
template <>
struct KernelArgumentHandler
{
static ::size_t size(const LocalSpaceArg& value) { return value.size_; }
- static void* ptr(LocalSpaceArg&) { return NULL; }
+ static const void* ptr(const LocalSpaceArg&) { return NULL; }
};
}
@@ -4430,21 +4846,9 @@ class Kernel : public detail::Wrapper
public:
inline Kernel(const Program& program, const char* name, cl_int* err = NULL);
- /*! \brief Destructor.
- *
- * This calls clReleaseKernel() on the value held by this instance.
- */
- ~Kernel() { }
-
//! \brief Default constructor - initializes to NULL.
Kernel() { }
- /*! \brief Copy constructor - performs shallow copy.
- *
- * This calls clRetainKernel() on the parameter's cl_kernel.
- */
- Kernel(const Kernel& kernel) : detail::Wrapper(kernel) { }
-
/*! \brief Constructor from cl_kernel - takes ownership.
*
* This effectively transfers ownership of a refcount on the cl_kernel
@@ -4452,30 +4856,47 @@ public:
*/
__CL_EXPLICIT_CONSTRUCTORS Kernel(const cl_kernel& kernel) : detail::Wrapper(kernel) { }
- /*! \brief Assignment operator from Kernel.
- *
- * This calls clRetainKernel() on the parameter and clReleaseKernel()
- * on the previous value held by this instance.
- */
- Kernel& operator = (const Kernel& rhs)
- {
- if (this != &rhs) {
- detail::Wrapper::operator=(rhs);
- }
- return *this;
- }
-
/*! \brief Assignment operator from cl_kernel - takes ownership.
- *
+ *
* This effectively transfers ownership of a refcount on the rhs and calls
* clReleaseKernel() on the value previously held by this instance.
*/
Kernel& operator = (const cl_kernel& rhs)
{
- detail::Wrapper::operator=(rhs);
+ detail::Wrapper::operator=(rhs);
+ return *this;
+ }
+
+ /*! \brief Copy constructor to forward copy to the superclass correctly.
+ * Required for MSVC.
+ */
+ Kernel(const Kernel& kernel) : detail::Wrapper(kernel) {}
+
+ /*! \brief Copy assignment to forward copy to the superclass correctly.
+ * Required for MSVC.
+ */
+ Kernel& operator = (const Kernel &kernel)
+ {
+ detail::Wrapper::operator=(kernel);
return *this;
}
+#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
+ /*! \brief Move constructor to forward move to the superclass correctly.
+ * Required for MSVC.
+ */
+ Kernel(Kernel&& kernel) CL_HPP_NOEXCEPT : detail::Wrapper(std::move(kernel)) {}
+
+ /*! \brief Move assignment to forward move to the superclass correctly.
+ * Required for MSVC.
+ */
+ Kernel& operator = (Kernel &&kernel)
+ {
+ detail::Wrapper::operator=(std::move(kernel));
+ return *this;
+ }
+#endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
+
template
cl_int getInfo(cl_kernel_info name, T* param) const
{
@@ -4544,7 +4965,7 @@ public:
}
template
- cl_int setArg(cl_uint index, T value)
+ cl_int setArg(cl_uint index, const T &value)
{
return detail::errHandler(
::clSetKernelArg(
@@ -4555,7 +4976,7 @@ public:
__SET_KERNEL_ARGS_ERR);
}
- cl_int setArg(cl_uint index, ::size_t size, void* argPtr)
+ cl_int setArg(cl_uint index, ::size_t size, const void* argPtr)
{
return detail::errHandler(
::clSetKernelArg(object_, index, size, argPtr),
@@ -4574,41 +4995,7 @@ public:
Program(
const STRING_CLASS& source,
- cl_int* err = NULL)
- {
- cl_int error;
-
- const char * strings = source.c_str();
- const ::size_t length = source.size();
-
- Context context = Context::getDefault(err);
-
- object_ = ::clCreateProgramWithSource(
- context(), (cl_uint)1, &strings, &length, &error);
-
- detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
-
- if (error == CL_SUCCESS) {
-
- error = ::clBuildProgram(
- object_,
- 0,
- NULL,
- "",
- NULL,
- NULL);
-
- detail::errHandler(error, __BUILD_PROGRAM_ERR);
- }
-
- if (err != NULL) {
- *err = error;
- }
- }
-
- Program(
- const STRING_CLASS& source,
- bool build,
+ bool build = false,
cl_int* err = NULL)
{
cl_int error;
@@ -4760,7 +5147,7 @@ public:
object_ = ::clCreateProgramWithBinary(
context(), (cl_uint) devices.size(),
deviceIDs,
- lengths, images, binaryStatus != NULL
+ lengths, images, (binaryStatus != NULL && numDevices > 0)
? &binaryStatus->front()
: NULL, &error);
@@ -4807,24 +5194,44 @@ public:
Program() { }
- Program(const Program& program) : detail::Wrapper(program) { }
-
__CL_EXPLICIT_CONSTRUCTORS Program(const cl_program& program) : detail::Wrapper(program) { }
- Program& operator = (const Program& rhs)
- {
- if (this != &rhs) {
- detail::Wrapper::operator=(rhs);
- }
- return *this;
- }
-
Program& operator = (const cl_program& rhs)
{
- detail::Wrapper::operator=(rhs);
+ detail::Wrapper::operator=(rhs);
+ return *this;
+ }
+
+ /*! \brief Copy constructor to forward copy to the superclass correctly.
+ * Required for MSVC.
+ */
+ Program(const Program& program) : detail::Wrapper(program) {}
+
+ /*! \brief Copy assignment to forward copy to the superclass correctly.
+ * Required for MSVC.
+ */
+ Program& operator = (const Program &program)
+ {
+ detail::Wrapper::operator=(program);
return *this;
}
+#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
+ /*! \brief Move constructor to forward move to the superclass correctly.
+ * Required for MSVC.
+ */
+ Program(Program&& program) CL_HPP_NOEXCEPT : detail::Wrapper(std::move(program)) {}
+
+ /*! \brief Move assignment to forward move to the superclass correctly.
+ * Required for MSVC.
+ */
+ Program& operator = (Program &&program)
+ {
+ detail::Wrapper::operator=(std::move(program));
+ return *this;
+ }
+#endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
+
cl_int build(
const VECTOR_CLASS& devices,
const char* options = NULL,
@@ -4959,11 +5366,14 @@ inline Program linkProgram(
void* data = NULL,
cl_int* err = NULL)
{
- cl_int err_local = CL_SUCCESS;
+ cl_int error_local = CL_SUCCESS;
cl_program programs[2] = { input1(), input2() };
- Context ctx = input1.getInfo();
+ Context ctx = input1.getInfo(&error_local);
+ if(error_local!=CL_SUCCESS) {
+ detail::errHandler(error_local, __LINK_PROGRAM_ERR);
+ }
cl_program prog = ::clLinkProgram(
ctx(),
@@ -4974,11 +5384,11 @@ inline Program linkProgram(
programs,
notifyFptr,
data,
- &err_local);
+ &error_local);
- detail::errHandler(err_local,__COMPILE_PROGRAM_ERR);
+ detail::errHandler(error_local,__COMPILE_PROGRAM_ERR);
if (err != NULL) {
- *err = err_local;
+ *err = error_local;
}
return Program(prog);
@@ -4991,7 +5401,7 @@ inline Program linkProgram(
void* data = NULL,
cl_int* err = NULL)
{
- cl_int err_local = CL_SUCCESS;
+ cl_int error_local = CL_SUCCESS;
cl_program * programs = (cl_program*) alloca(inputPrograms.size() * sizeof(cl_program));
@@ -5001,8 +5411,15 @@ inline Program linkProgram(
}
}
+ Context ctx;
+ if(inputPrograms.size() > 0) {
+ ctx = inputPrograms[0].getInfo(&error_local);
+ if(error_local!=CL_SUCCESS) {
+ detail::errHandler(error_local, __LINK_PROGRAM_ERR);
+ }
+ }
cl_program prog = ::clLinkProgram(
- Context::getDefault()(),
+ ctx(),
0,
NULL,
options,
@@ -5010,11 +5427,11 @@ inline Program linkProgram(
programs,
notifyFptr,
data,
- &err_local);
+ &error_local);
- detail::errHandler(err_local,__COMPILE_PROGRAM_ERR);
+ detail::errHandler(error_local,__COMPILE_PROGRAM_ERR);
if (err != NULL) {
- *err = err_local;
+ *err = error_local;
}
return Program(prog);
@@ -5060,7 +5477,11 @@ inline Kernel::Kernel(const Program& program, const char* name, cl_int* err)
class CommandQueue : public detail::Wrapper
{
private:
+#ifdef CL_HPP_CPP11_ATOMICS_SUPPORTED
+ static std::atomic default_initialized_;
+#else // !CL_HPP_CPP11_ATOMICS_SUPPORTED
static volatile int default_initialized_;
+#endif // !CL_HPP_CPP11_ATOMICS_SUPPORTED
static CommandQueue default_;
static volatile cl_int default_error_;
public:
@@ -5071,7 +5492,7 @@ public:
cl_int error;
Context context = Context::getDefault(&error);
- detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
+ detail::errHandler(error, __CREATE_CONTEXT_ERR);
if (error != CL_SUCCESS) {
if (err != NULL) {
@@ -5090,6 +5511,37 @@ public:
}
}
}
+ /*!
+ * \brief Constructs a CommandQueue for an implementation defined device in the given context
+ */
+ explicit CommandQueue(
+ const Context& context,
+ cl_command_queue_properties properties = 0,
+ cl_int* err = NULL)
+ {
+ cl_int error;
+ VECTOR_CLASS devices;
+ error = context.getInfo(CL_CONTEXT_DEVICES, &devices);
+
+ detail::errHandler(error, __CREATE_CONTEXT_ERR);
+
+ if (error != CL_SUCCESS)
+ {
+ if (err != NULL) {
+ *err = error;
+ }
+ return;
+ }
+
+ object_ = ::clCreateCommandQueue(context(), devices[0](), properties, &error);
+
+ detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
+
+ if (err != NULL) {
+ *err = error;
+ }
+
+ }
CommandQueue(
const Context& context,
@@ -5107,6 +5559,36 @@ public:
}
}
+ /*! \brief Copy constructor to forward copy to the superclass correctly.
+ * Required for MSVC.
+ */
+ CommandQueue(const CommandQueue& queue) : detail::Wrapper(queue) {}
+
+ /*! \brief Copy assignment to forward copy to the superclass correctly.
+ * Required for MSVC.
+ */
+ CommandQueue& operator = (const CommandQueue &queue)
+ {
+ detail::Wrapper::operator=(queue);
+ return *this;
+ }
+
+#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
+ /*! \brief Move constructor to forward move to the superclass correctly.
+ * Required for MSVC.
+ */
+ CommandQueue(CommandQueue&& queue) CL_HPP_NOEXCEPT : detail::Wrapper(std::move(queue)) {}
+
+ /*! \brief Move assignment to forward move to the superclass correctly.
+ * Required for MSVC.
+ */
+ CommandQueue& operator = (CommandQueue &&queue)
+ {
+ detail::Wrapper::operator=(std::move(queue));
+ return *this;
+ }
+#endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED)
+
static CommandQueue getDefault(cl_int * err = NULL)
{
int state = detail::compare_exchange(
@@ -5170,17 +5652,7 @@ public:
CommandQueue() { }
- CommandQueue(const CommandQueue& commandQueue) : detail::Wrapper(commandQueue) { }
-
- CommandQueue(const cl_command_queue& commandQueue) : detail::Wrapper(commandQueue) { }
-
- CommandQueue& operator = (const CommandQueue& rhs)
- {
- if (this != &rhs) {
- detail::Wrapper::operator=(rhs);
- }
- return *this;
- }
+ __CL_EXPLICIT_CONSTRUCTORS CommandQueue(const cl_command_queue& commandQueue) : detail::Wrapper(commandQueue) { }
CommandQueue& operator = (const cl_command_queue& rhs)
{
@@ -5679,18 +6151,22 @@ public:
Event* event = NULL,
cl_int* err = NULL) const
{
+ cl_event tmp;
cl_int error;
void * result = ::clEnqueueMapBuffer(
object_, buffer(), blocking, flags, offset, size,
(events != NULL) ? (cl_uint) events->size() : 0,
(events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
- (cl_event*) event,
+ (event != NULL) ? &tmp : NULL,
&error);
detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
if (err != NULL) {
*err = error;
}
+ if (event != NULL && error == CL_SUCCESS)
+ *event = tmp;
+
return result;
}
@@ -5706,6 +6182,7 @@ public:
Event* event = NULL,
cl_int* err = NULL) const
{
+ cl_event tmp;
cl_int error;
void * result = ::clEnqueueMapImage(
object_, buffer(), blocking, flags,
@@ -5713,13 +6190,15 @@ public:
row_pitch, slice_pitch,
(events != NULL) ? (cl_uint) events->size() : 0,
(events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
- (cl_event*) event,
+ (event != NULL) ? &tmp : NULL,
&error);
detail::errHandler(error, __ENQUEUE_MAP_IMAGE_ERR);
if (err != NULL) {
*err = error;
}
+ if (event != NULL && error == CL_SUCCESS)
+ *event = tmp;
return result;
}
@@ -5912,7 +6391,7 @@ public:
object_, userFptr, args.first, args.second,
(mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
mems,
- (mem_locs != NULL) ? (const void **) &mem_locs->front() : NULL,
+ (mem_locs != NULL && mem_locs->size() > 0) ? (const void **) &mem_locs->front() : NULL,
(events != NULL) ? (cl_uint) events->size() : 0,
(events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
(event != NULL) ? &tmp : NULL),
@@ -5931,9 +6410,17 @@ public:
CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
cl_int enqueueMarker(Event* event = NULL) const CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
{
- return detail::errHandler(
- ::clEnqueueMarker(object_, (cl_event*) event),
+ cl_event tmp;
+ cl_int err = detail::errHandler(
+ ::clEnqueueMarker(
+ object_,
+ (event != NULL) ? &tmp : NULL),
__ENQUEUE_MARKER_ERR);
+
+ if (event != NULL && err == CL_SUCCESS)
+ *event = tmp;
+
+ return err;
}
CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
@@ -5943,7 +6430,7 @@ public:
::clEnqueueWaitForEvents(
object_,
(cl_uint) events.size(),
- (const cl_event*) &events.front()),
+ events.size() > 0 ? (const cl_event*) &events.front() : NULL),
__ENQUEUE_WAIT_FOR_EVENTS_ERR);
}
#endif // #if defined(CL_VERSION_1_1)
@@ -5958,7 +6445,7 @@ public:
::clEnqueueAcquireGLObjects(
object_,
(mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
- (mem_objects != NULL) ? (const cl_mem *) &mem_objects->front(): NULL,
+ (mem_objects != NULL && mem_objects->size() > 0) ? (const cl_mem *) &mem_objects->front(): NULL,
(events != NULL) ? (cl_uint) events->size() : 0,
(events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
(event != NULL) ? &tmp : NULL),
@@ -5980,7 +6467,7 @@ public:
::clEnqueueReleaseGLObjects(
object_,
(mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
- (mem_objects != NULL) ? (const cl_mem *) &mem_objects->front(): NULL,
+ (mem_objects != NULL && mem_objects->size() > 0) ? (const cl_mem *) &mem_objects->front(): NULL,
(events != NULL) ? (cl_uint) events->size() : 0,
(events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
(event != NULL) ? &tmp : NULL),
@@ -6023,7 +6510,7 @@ typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueReleaseD3D10ObjectsKHR)(
pfn_clEnqueueAcquireD3D10ObjectsKHR(
object_,
(mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
- (mem_objects != NULL) ? (const cl_mem *) &mem_objects->front(): NULL,
+ (mem_objects != NULL && mem_objects->size() > 0) ? (const cl_mem *) &mem_objects->front(): NULL,
(events != NULL) ? (cl_uint) events->size() : 0,
(events != NULL) ? (cl_event*) &events->front() : NULL,
(event != NULL) ? &tmp : NULL),
@@ -6056,9 +6543,9 @@ typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueReleaseD3D10ObjectsKHR)(
pfn_clEnqueueReleaseD3D10ObjectsKHR(
object_,
(mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
- (mem_objects != NULL) ? (const cl_mem *) &mem_objects->front(): NULL,
+ (mem_objects != NULL && mem_objects->size() > 0) ? (const cl_mem *) &mem_objects->front(): NULL,
(events != NULL) ? (cl_uint) events->size() : 0,
- (events != NULL) ? (cl_event*) &events->front() : NULL,
+ (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
(event != NULL) ? &tmp : NULL),
__ENQUEUE_RELEASE_GL_ERR);
@@ -6094,14 +6581,121 @@ typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueReleaseD3D10ObjectsKHR)(
};
#ifdef _WIN32
+#ifdef CL_HPP_CPP11_ATOMICS_SUPPORTED
+__declspec(selectany) std::atomic CommandQueue::default_initialized_;
+#else // !CL_HPP_CPP11_ATOMICS_SUPPORTED
__declspec(selectany) volatile int CommandQueue::default_initialized_ = __DEFAULT_NOT_INITIALIZED;
+#endif // !CL_HPP_CPP11_ATOMICS_SUPPORTED
__declspec(selectany) CommandQueue CommandQueue::default_;
__declspec(selectany) volatile cl_int CommandQueue::default_error_ = CL_SUCCESS;
-#else
+#else // !_WIN32
+#ifdef CL_HPP_CPP11_ATOMICS_SUPPORTED
+__attribute__((weak)) std::atomic CommandQueue::default_initialized_;
+#else // !CL_HPP_CPP11_ATOMICS_SUPPORTED
__attribute__((weak)) volatile int CommandQueue::default_initialized_ = __DEFAULT_NOT_INITIALIZED;
+#endif // !CL_HPP_CPP11_ATOMICS_SUPPORTED
__attribute__((weak)) CommandQueue CommandQueue::default_;
__attribute__((weak)) volatile cl_int CommandQueue::default_error_ = CL_SUCCESS;
-#endif
+#endif // !_WIN32
+
+template< typename IteratorType >
+Buffer::Buffer(
+ const Context &context,
+ IteratorType startIterator,
+ IteratorType endIterator,
+ bool readOnly,
+ bool useHostPtr,
+ cl_int* err)
+{
+ typedef typename std::iterator_traits::value_type DataType;
+ cl_int error;
+
+ cl_mem_flags flags = 0;
+ if( readOnly ) {
+ flags |= CL_MEM_READ_ONLY;
+ }
+ else {
+ flags |= CL_MEM_READ_WRITE;
+ }
+ if( useHostPtr ) {
+ flags |= CL_MEM_USE_HOST_PTR;
+ }
+
+ ::size_t size = sizeof(DataType)*(endIterator - startIterator);
+
+ if( useHostPtr ) {
+ object_ = ::clCreateBuffer(context(), flags, size, static_cast(&*startIterator), &error);
+ } else {
+ object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
+ }
+
+ detail::errHandler(error, __CREATE_BUFFER_ERR);
+ if (err != NULL) {
+ *err = error;
+ }
+
+ if( !useHostPtr ) {
+ CommandQueue queue(context, 0, &error);
+ detail::errHandler(error, __CREATE_BUFFER_ERR);
+ if (err != NULL) {
+ *err = error;
+ }
+
+ error = cl::copy(queue, startIterator, endIterator, *this);
+ detail::errHandler(error, __CREATE_BUFFER_ERR);
+ if (err != NULL) {
+ *err = error;
+ }
+ }
+}
+
+template< typename IteratorType >
+Buffer::Buffer(
+ const CommandQueue &queue,
+ IteratorType startIterator,
+ IteratorType endIterator,
+ bool readOnly,
+ bool useHostPtr,
+ cl_int* err)
+{
+ typedef typename std::iterator_traits::value_type DataType;
+ cl_int error;
+
+ cl_mem_flags flags = 0;
+ if (readOnly) {
+ flags |= CL_MEM_READ_ONLY;
+ }
+ else {
+ flags |= CL_MEM_READ_WRITE;
+ }
+ if (useHostPtr) {
+ flags |= CL_MEM_USE_HOST_PTR;
+ }
+
+ ::size_t size = sizeof(DataType)*(endIterator - startIterator);
+
+ Context context = queue.getInfo();
+
+ if (useHostPtr) {
+ object_ = ::clCreateBuffer(context(), flags, size, static_cast(&*startIterator), &error);
+ }
+ else {
+ object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
+ }
+
+ detail::errHandler(error, __CREATE_BUFFER_ERR);
+ if (err != NULL) {
+ *err = error;
+ }
+
+ if (!useHostPtr) {
+ error = cl::copy(queue, startIterator, endIterator, *this);
+ detail::errHandler(error, __CREATE_BUFFER_ERR);
+ if (err != NULL) {
+ *err = error;
+ }
+ }
+}
inline cl_int enqueueReadBuffer(
const Buffer& buffer,
@@ -6221,9 +6815,43 @@ inline cl_int enqueueCopyBuffer(
/**
* Blocking copy operation between iterators and a buffer.
+ * Host to Device.
+ * Uses default command queue.
*/
template< typename IteratorType >
inline cl_int copy( IteratorType startIterator, IteratorType endIterator, cl::Buffer &buffer )
+{
+ cl_int error;
+ CommandQueue queue = CommandQueue::getDefault(&error);
+ if (error != CL_SUCCESS)
+ return error;
+
+ return cl::copy(queue, startIterator, endIterator, buffer);
+}
+
+/**
+ * Blocking copy operation between iterators and a buffer.
+ * Device to Host.
+ * Uses default command queue.
+ */
+template< typename IteratorType >
+inline cl_int copy( const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator )
+{
+ cl_int error;
+ CommandQueue queue = CommandQueue::getDefault(&error);
+ if (error != CL_SUCCESS)
+ return error;
+
+ return cl::copy(queue, buffer, startIterator, endIterator);
+}
+
+/**
+ * Blocking copy operation between iterators and a buffer.
+ * Host to Device.
+ * Uses specified queue.
+ */
+template< typename IteratorType >
+inline cl_int copy( const CommandQueue &queue, IteratorType startIterator, IteratorType endIterator, cl::Buffer &buffer )
{
typedef typename std::iterator_traits::value_type DataType;
cl_int error;
@@ -6232,7 +6860,7 @@ inline cl_int copy( IteratorType startIterator, IteratorType endIterator, cl::Bu
::size_t byteLength = length*sizeof(DataType);
DataType *pointer =
- static_cast(enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_WRITE, 0, byteLength, 0, 0, &error));
+ static_cast(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_WRITE, 0, byteLength, 0, 0, &error));
// if exceptions enabled, enqueueMapBuffer will throw
if( error != CL_SUCCESS ) {
return error;
@@ -6247,7 +6875,7 @@ inline cl_int copy( IteratorType startIterator, IteratorType endIterator, cl::Bu
std::copy(startIterator, endIterator, pointer);
#endif
Event endEvent;
- error = enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
+ error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
// if exceptions enabled, enqueueUnmapMemObject will throw
if( error != CL_SUCCESS ) {
return error;
@@ -6258,9 +6886,11 @@ inline cl_int copy( IteratorType startIterator, IteratorType endIterator, cl::Bu
/**
* Blocking copy operation between iterators and a buffer.
+ * Device to Host.
+ * Uses specified queue.
*/
template< typename IteratorType >
-inline cl_int copy( const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator )
+inline cl_int copy( const CommandQueue &queue, const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator )
{
typedef typename std::iterator_traits::value_type DataType;
cl_int error;
@@ -6269,14 +6899,14 @@ inline cl_int copy( const cl::Buffer &buffer, IteratorType startIterator, Iterat
::size_t byteLength = length*sizeof(DataType);
DataType *pointer =
- static_cast(enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_READ, 0, byteLength, 0, 0, &error));
+ static_cast(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_READ, 0, byteLength, 0, 0, &error));
// if exceptions enabled, enqueueMapBuffer will throw
if( error != CL_SUCCESS ) {
return error;
}
std::copy(pointer, pointer + length, startIterator);
Event endEvent;
- error = enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
+ error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
// if exceptions enabled, enqueueUnmapMemObject will throw
if( error != CL_SUCCESS ) {
return error;
@@ -12296,10 +12926,9 @@ public:
#undef __DEFAULT_BEING_INITIALIZED
#undef __DEFAULT_INITIALIZED
+#undef CL_HPP_RVALUE_REFERENCES_SUPPORTED
+#undef CL_HPP_NOEXCEPT
+
} // namespace cl
-#ifdef _WIN32
-#pragma pop_macro("max")
-#endif // _WIN32
-
#endif // CL_HPP_
diff --git a/opencl/api/opencl/khronos/headers/opencl2.0/CL/cl2.hpp b/opencl/api/opencl/khronos/headers/opencl2.0/CL/cl2.hpp
new file mode 100644
index 0000000000..534c486988
--- /dev/null
+++ b/opencl/api/opencl/khronos/headers/opencl2.0/CL/cl2.hpp
@@ -0,0 +1,9520 @@
+/*******************************************************************************
+ * Copyright (c) 2008-2015 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and/or associated documentation files (the
+ * "Materials"), to deal in the Materials without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Materials, and to
+ * permit persons to whom the Materials are furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Materials.
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ ******************************************************************************/
+
+/*! \file
+ *
+ * \brief C++ bindings for OpenCL 1.0 (rev 48), OpenCL 1.1 (rev 33),
+ * OpenCL 1.2 (rev 15) and OpenCL 2.0 (rev 29)
+ * \author Lee Howes and Bruce Merry
+ *
+ * Derived from the OpenCL 1.x C++ bindings written by
+ * Benedict R. Gaster, Laurent Morichetti and Lee Howes
+ * With additions and fixes from:
+ * Brian Cole, March 3rd 2010 and April 2012
+ * Matt Gruenke, April 2012.
+ * Bruce Merry, February 2013.
+ * Tom Deakin and Simon McIntosh-Smith, July 2013
+ *
+ * \version 2.0.7
+ * \date 2015-10-05
+ *
+ * Optional extension support
+ *
+ * cl_ext_device_fission
+ * #define CL_HPP_USE_CL_DEVICE_FISSION
+ * cl_khr_d3d10_sharing
+ * #define CL_HPP_USE_DX_INTEROP
+ * cl_khr_sub_groups
+ * #define CL_HPP_USE_CL_SUB_GROUPS_KHR
+ */
+
+/*! \mainpage
+ * \section intro Introduction
+ * For many large applications C++ is the language of choice and so it seems
+ * reasonable to define C++ bindings for OpenCL.
+ *
+ * The interface is contained with a single C++ header file \em cl2.hpp and all
+ * definitions are contained within the namespace \em cl. There is no additional
+ * requirement to include \em cl.h and to use either the C++ or original C
+ * bindings; it is enough to simply include \em cl.hpp.
+ *
+ * The bindings themselves are lightweight and correspond closely to the
+ * underlying C API. Using the C++ bindings introduces no additional execution
+ * overhead.
+ *
+ * There are numerous compatibility, portability and memory management
+ * fixes in the new header as well as additional OpenCL 2.0 features.
+ * As a result the header is not directly backward compatible and for this
+ * reason we release it as cl2.hpp rather than a new version of cl.hpp.
+ *
+ *
+ * \section compatibility Compatibility
+ * Due to the evolution of the underlying OpenCL API the 2.0 C++ bindings
+ * include an updated approach to defining supported feature versions
+ * and the range of valid underlying OpenCL runtime versions supported.
+ *
+ * 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 runime versions. The default for
+ * the target is 200, representing OpenCL 2.0 and the minimum is also
+ * defined as 200. These settings would use 2.0 API calls only.
+ * If backward compatibility with a 1.2 runtime is required, the minimum
+ * version may be set to 120.
+ *
+ * Note that this is a compile-time setting, and so affects linking against
+ * a particular SDK version rather than the versioning of the loaded runtime.
+ *
+ * The earlier versions of the header included basic vector and string
+ * classes based loosely on STL versions. These were difficult to
+ * maintain and very rarely used. For the 2.0 header we now assume
+ * the presence of the standard library unless requested otherwise.
+ * We use std::array, std::vector, std::shared_ptr and std::string
+ * throughout to safely manage memory and reduce the chance of a
+ * recurrance of earlier memory management bugs.
+ *
+ * These classes are used through typedefs in the cl namespace:
+ * cl::array, cl::vector, cl::pointer and cl::string.
+ * In addition cl::allocate_pointer forwards to std::allocate_shared
+ * by default.
+ * In all cases these standard library classes can be replaced with
+ * custom interface-compatible versions using the CL_HPP_NO_STD_ARRAY,
+ * CL_HPP_NO_STD_VECTOR, CL_HPP_NO_STD_UNIQUE_PTR and
+ * CL_HPP_NO_STD_STRING macros.
+ *
+ * The OpenCL 1.x versions of the C++ bindings included a size_t wrapper
+ * class to interface with kernel enqueue. This caused unpleasant interactions
+ * with the standard size_t declaration and led to namespacing bugs.
+ * In the 2.0 version we have replaced this with a std::array-based interface.
+ * However, the old behaviour can be regained for backward compatibility
+ * using the CL_HPP_ENABLE_SIZE_T_COMPATIBILITY macro.
+ *
+ * Finally, the program construction interface used a clumsy vector-of-pairs
+ * design in the earlier versions. We have replaced that with a cleaner
+ * vector-of-vectors and vector-of-strings design. However, for backward
+ * compatibility old behaviour can be regained with the
+ * CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY macro.
+ *
+ * In OpenCL 2.0 OpenCL C is not entirely backward compatibility with
+ * earlier versions. As a result a flag must be passed to the OpenCL C
+ * compiled to request OpenCL 2.0 compilation of kernels with 1.2 as
+ * the default in the absence of the flag.
+ * In some cases the C++ bindings automatically compile code for ease.
+ * For those cases the compilation defaults to OpenCL C 2.0.
+ * If this is not wanted, the CL_HPP_CL_1_2_DEFAULT_BUILD macro may
+ * be specified to assume 1.2 compilation.
+ * If more fine-grained decisions on a per-kernel bases are required
+ * then explicit build operations that take the flag should be used.
+ *
+ *
+ * \section parameterization Parameters
+ * This header may be parameterized by a set of preprocessor macros.
+ * CL_HPP_TARGET_OPENCL_VERSION
+ * - Defines the target OpenCL runtime version to build the header against.
+ * Defaults to 200, representing OpenCL 2.0.
+ * CL_HPP_NO_STD_STRING
+ * - Do not use the standard library string class.
+ * cl::string is not defined and may be defined by the user before
+ * cl2.hpp is included.
+ * CL_HPP_NO_STD_VECTOR
+ * - Do not use the standard library vector class.
+ * cl::vector is not defined and may be defined by the user before
+ * cl2.hpp is included.
+ * CL_HPP_NO_STD_ARRAY
+ * - Do not use the standard library array class.
+ * cl::array is not defined and may be defined by the user before
+ * cl2.hpp is included.
+ * CL_HPP_NO_STD_UNIQUE_PTR
+ * - Do not use the standard library unique_ptr class.
+ * cl::pointer and the cl::allocate_pointer function are not defined
+ * and may be defined by the user before cl2.hpp is included.
+ * CL_HPP_ENABLE_DEVICE_FISSION
+ * - Enables device fission for OpenCL 1.2 platforms
+ * CL_HPP_ENABLE_EXCEPTIONS
+ * - Enable exceptions for use in the C++ bindings header.
+ * This is the preferred error handling mechanism but is not required.
+ * CL_HPP_ENABLE_SIZE_T_COMPATIBILITY
+ * - Backward compatibility option to support cl.hpp-style size_t class.
+ * Replaces the updated std::array derived version and removal of size_t
+ * from the namespace. Note that in this case the new size_t class
+ * is placed in the cl::compatibility namespace and thus requires
+ * an additional using declaration for direct backward compatibility.
+ * CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY
+ * - Enable older vector of pairs interface for construction of programs.
+ * CL_HPP_CL_1_2_DEFAULT_BUILD
+ * - Default to OpenCL C 1.2 compilation rather than OpenCL C 2.0
+ * - applies to use of cl::Program construction and other program build variants.
+ *
+ *
+ * \section example Example
+ *
+ * The following example shows a general use case for the C++
+ * bindings, including support for the optional exception feature and
+ * also the supplied vector and string classes, see following sections for
+ * decriptions of these features.
+ *
+ * \code
+ #define CL_HPP_ENABLE_EXCEPTIONS
+ #define CL_HPP_TARGET_OPENCL_VERSION 200
+
+ #include
+ #include
+ #include
+ #include
+ #include
+
+ const int numElements = 32;
+
+ int main(void)
+ {
+ // Filter for a 2.0 platform and set it as the default
+ std::vector platforms;
+ cl::Platform::get(&platforms);
+ cl::Platform plat;
+ for (auto &p : platforms) {
+ std::string platver = p.getInfo();
+ if (platver.find("OpenCL 2.") != std::string::npos) {
+ plat = p;
+ }
+ }
+ if (plat() == 0) {
+ std::cout << "No OpenCL 2.0 platform found.";
+ return -1;
+ }
+
+ cl::Platform newP = cl::Platform::setDefault(plat);
+ if (newP != plat) {
+ std::cout << "Error setting default platform.";
+ return -1;
+ }
+
+ std::string kernel1{
+ "global int globalA;"
+ "kernel void updateGlobal(){"
+ " globalA = 75;"
+ "}"};
+ std::string kernel2{
+ "typedef struct { global int *bar; } Foo; kernel void vectorAdd(global const Foo* aNum, global const int *inputA, global const int *inputB, global int *output, int val, write_only pipe int outPipe, queue_t childQueue){"
+ " output[get_global_id(0)] = inputA[get_global_id(0)] + inputB[get_global_id(0)] + val + *(aNum->bar);"
+ " write_pipe(outPipe, &val);"
+ " queue_t default_queue = get_default_queue(); "
+ " ndrange_t ndrange = ndrange_1D(get_global_size(0)/2, get_global_size(0)/2); "
+ // Have a child kernel write into third quarter of output
+ " enqueue_kernel(default_queue, CLK_ENQUEUE_FLAGS_WAIT_KERNEL, ndrange, "
+ " ^{"
+ " output[get_global_size(0)*2 + get_global_id(0)] = inputA[get_global_size(0)*2+get_global_id(0)] + inputB[get_global_size(0)*2+get_global_id(0)] + globalA;"
+ " });"
+ // Have a child kernel write into last quarter of output
+ " enqueue_kernel(childQueue, CLK_ENQUEUE_FLAGS_WAIT_KERNEL, ndrange, "
+ " ^{"
+ " output[get_global_size(0)*3 + get_global_id(0)] = inputA[get_global_size(0)*3 + get_global_id(0)] + inputB[get_global_size(0)*3 + get_global_id(0)] + globalA + 2;"
+ " });"
+ "}" };
+
+ // New simpler string interface style
+ std::vector programStrings {kernel1, kernel2};
+
+ cl::Program vectorAddProgram(
+ programStrings);
+ try {
+ vectorAddProgram.build("-cl-std=CL2.0");
+ }
+ catch (...) {
+ // Print build info for all devices
+ cl_int buildErr = CL_SUCCESS;
+ auto buildInfo = vectorAddProgram.getBuildInfo(&buildErr);
+ for (auto &pair : buildInfo) {
+ std::cerr << pair.second << std::endl << std::endl;
+ }
+
+ return 1;
+ }
+
+ typedef struct { int *bar; } Foo;
+
+ // Get and run kernel that initializes the program-scope global
+ // A test for kernels that take no arguments
+ auto program2Kernel =
+ cl::KernelFunctor<>(vectorAddProgram, "updateGlobal");
+ program2Kernel(
+ cl::EnqueueArgs(
+ cl::NDRange(1)));
+
+ //////////////////
+ // SVM allocations
+
+ cl::pointer anSVMInt = cl::allocate_svm>();
+ *anSVMInt = 5;
+ cl::SVMAllocator>> svmAllocReadOnly;
+ auto fooPointer = cl::allocate_pointer(svmAllocReadOnly);
+ fooPointer->bar = anSVMInt.get();
+ cl::SVMAllocator> svmAlloc;
+ std::vector>> inputA(numElements, 1, svmAlloc);
+ cl::coarse_svm_vector inputB(numElements, 2, svmAlloc);
+
+ //
+ //////////////
+
+ // Traditional cl_mem allocations
+ std::vector output(numElements, 0xdeadbeef);
+ cl::Buffer outputBuffer(begin(output), end(output), false);
+ cl::Pipe aPipe(sizeof(cl_int), numElements / 2);
+
+ // Default command queue, also passed in as a parameter
+ cl::DeviceCommandQueue defaultDeviceQueue = cl::DeviceCommandQueue::makeDefault(
+ cl::Context::getDefault(), cl::Device::getDefault());
+
+ auto vectorAddKernel =
+ cl::KernelFunctor<
+ decltype(fooPointer)&,
+ int*,
+ cl::coarse_svm_vector&,
+ cl::Buffer,
+ int,
+ cl::Pipe&,
+ cl::DeviceCommandQueue
+ >(vectorAddProgram, "vectorAdd");
+
+ // Ensure that the additional SVM pointer is available to the kernel
+ // This one was not passed as a parameter
+ vectorAddKernel.setSVMPointers(anSVMInt);
+
+ // Hand control of coarse allocations to runtime
+ cl::enqueueUnmapSVM(anSVMInt);
+ cl::enqueueUnmapSVM(fooPointer);
+ cl::unmapSVM(inputB);
+ cl::unmapSVM(output2);
+
+ cl_int error;
+ vectorAddKernel(
+ cl::EnqueueArgs(
+ cl::NDRange(numElements/2),
+ cl::NDRange(numElements/2)),
+ fooPointer,
+ inputA.data(),
+ inputB,
+ outputBuffer,
+ 3,
+ aPipe,
+ defaultDeviceQueue,
+ error
+ );
+
+ cl::copy(outputBuffer, begin(output), end(output));
+ // Grab the SVM output vector using a map
+ cl::mapSVM(output2);
+
+ cl::Device d = cl::Device::getDefault();
+
+ std::cout << "Output:\n";
+ for (int i = 1; i < numElements; ++i) {
+ std::cout << "\t" << output[i] << "\n";
+ }
+ std::cout << "\n\n";
+
+ return 0;
+ }
+ *
+ * \endcode
+ *
+ */
+#ifndef CL_HPP_
+#define CL_HPP_
+
+/* Handle deprecated preprocessor definitions. In each case, we only check for
+ * the old name if the new name is not defined, so that user code can define
+ * both and hence work with either version of the bindings.
+ */
+#if !defined(CL_HPP_USE_DX_INTEROP) && defined(USE_DX_INTEROP)
+# pragma message("cl2.hpp: USE_DX_INTEROP is deprecated. Define CL_HPP_USE_DX_INTEROP instead")
+# define CL_HPP_USE_DX_INTEROP
+#endif
+#if !defined(CL_HPP_USE_CL_DEVICE_FISSION) && defined(USE_CL_DEVICE_FISSION)
+# pragma message("cl2.hpp: USE_CL_DEVICE_FISSION is deprecated. Define CL_HPP_USE_CL_DEVICE_FISSION instead")
+# define CL_HPP_USE_CL_DEVICE_FISSION
+#endif
+#if !defined(CL_HPP_ENABLE_EXCEPTIONS) && defined(__CL_ENABLE_EXCEPTIONS)
+# pragma message("cl2.hpp: __CL_ENABLE_EXCEPTIONS is deprecated. Define CL_HPP_ENABLE_EXCEPTIONS instead")
+# define CL_HPP_ENABLE_EXCEPTIONS
+#endif
+#if !defined(CL_HPP_NO_STD_VECTOR) && defined(__NO_STD_VECTOR)
+# pragma message("cl2.hpp: __NO_STD_VECTOR is deprecated. Define CL_HPP_NO_STD_VECTOR instead")
+# define CL_HPP_NO_STD_VECTOR
+#endif
+#if !defined(CL_HPP_NO_STD_STRING) && defined(__NO_STD_STRING)
+# pragma message("cl2.hpp: __NO_STD_STRING is deprecated. Define CL_HPP_NO_STD_STRING instead")
+# define CL_HPP_NO_STD_STRING
+#endif
+#if defined(VECTOR_CLASS)
+# pragma message("cl2.hpp: VECTOR_CLASS is deprecated. Alias cl::vector instead")
+#endif
+#if defined(STRING_CLASS)
+# pragma message("cl2.hpp: STRING_CLASS is deprecated. Alias cl::string instead.")
+#endif
+#if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS) && defined(__CL_USER_OVERRIDE_ERROR_STRINGS)
+# pragma message("cl2.hpp: __CL_USER_OVERRIDE_ERROR_STRINGS is deprecated. Define CL_HPP_USER_OVERRIDE_ERROR_STRINGS instead")
+# define CL_HPP_USER_OVERRIDE_ERROR_STRINGS
+#endif
+
+/* Warn about features that are no longer supported
+ */
+#if defined(__USE_DEV_VECTOR)
+# pragma message("cl2.hpp: __USE_DEV_VECTOR is no longer supported. Expect compilation errors")
+#endif
+#if defined(__USE_DEV_STRING)
+# pragma message("cl2.hpp: __USE_DEV_STRING is no longer supported. Expect compilation errors")
+#endif
+
+/* Detect which version to target */
+#if !defined(CL_HPP_TARGET_OPENCL_VERSION)
+# pragma message("cl2.hpp: CL_HPP_TARGET_OPENCL_VERSION is not defined. It will default to 200 (OpenCL 2.0)")
+# define CL_HPP_TARGET_OPENCL_VERSION 200
+#endif
+#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
+# 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")
+# undef CL_HPP_TARGET_OPENCL_VERSION
+# define CL_HPP_TARGET_OPENCL_VERSION 200
+#endif
+
+#if !defined(CL_HPP_MINIMUM_OPENCL_VERSION)
+# define CL_HPP_MINIMUM_OPENCL_VERSION 200
+#endif
+#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
+# 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")
+# undef CL_HPP_MINIMUM_OPENCL_VERSION
+# define CL_HPP_MINIMUM_OPENCL_VERSION 100
+#endif
+#if CL_HPP_MINIMUM_OPENCL_VERSION > CL_HPP_TARGET_OPENCL_VERSION
+# error "CL_HPP_MINIMUM_OPENCL_VERSION must not be greater than CL_HPP_TARGET_OPENCL_VERSION"
+#endif
+
+#if CL_HPP_MINIMUM_OPENCL_VERSION <= 100 && !defined(CL_USE_DEPRECATED_OPENCL_1_0_APIS)
+# define CL_USE_DEPRECATED_OPENCL_1_0_APIS
+#endif
+#if CL_HPP_MINIMUM_OPENCL_VERSION <= 110 && !defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
+# define CL_USE_DEPRECATED_OPENCL_1_1_APIS
+#endif
+#if CL_HPP_MINIMUM_OPENCL_VERSION <= 120 && !defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
+# define CL_USE_DEPRECATED_OPENCL_1_2_APIS
+#endif
+#if CL_HPP_MINIMUM_OPENCL_VERSION <= 200 && !defined(CL_USE_DEPRECATED_OPENCL_2_0_APIS)
+# define CL_USE_DEPRECATED_OPENCL_2_0_APIS
+#endif
+
+#ifdef _WIN32
+
+#include
+
+#if defined(CL_HPP_USE_DX_INTEROP)
+#include
+#include
+#endif
+#endif // _WIN32
+
+#if defined(_MSC_VER)
+#include
+#endif // _MSC_VER
+
+ // Check for a valid C++ version
+
+// Need to do both tests here because for some reason __cplusplus is not
+// updated in visual studio
+#if (!defined(_MSC_VER) && __cplusplus < 201103L) || (defined(_MSC_VER) && _MSC_VER < 1700)
+#error Visual studio 2013 or another C++11-supporting compiler required
+#endif
+
+//
+#if defined(CL_HPP_USE_CL_DEVICE_FISSION) || defined(CL_HPP_USE_CL_SUB_GROUPS_KHR)
+#include
+#endif
+
+#if defined(__APPLE__) || defined(__MACOSX)
+#include
+#else
+#include
+#endif // !__APPLE__
+
+#if (__cplusplus >= 201103L)
+#define CL_HPP_NOEXCEPT_ noexcept
+#else
+#define CL_HPP_NOEXCEPT_
+#endif
+
+#if defined(_MSC_VER)
+# define CL_HPP_DEFINE_STATIC_MEMBER_ __declspec(selectany)
+#else
+# define CL_HPP_DEFINE_STATIC_MEMBER_ __attribute__((weak))
+#endif // !_MSC_VER
+
+// Define deprecated prefixes and suffixes to ensure compilation
+// in case they are not pre-defined
+#if !defined(CL_EXT_PREFIX__VERSION_1_1_DEPRECATED)
+#define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
+#endif // #if !defined(CL_EXT_PREFIX__VERSION_1_1_DEPRECATED)
+#if !defined(CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED)
+#define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
+#endif // #if !defined(CL_EXT_PREFIX__VERSION_1_1_DEPRECATED)
+
+#if !defined(CL_EXT_PREFIX__VERSION_1_2_DEPRECATED)
+#define CL_EXT_PREFIX__VERSION_1_2_DEPRECATED
+#endif // #if !defined(CL_EXT_PREFIX__VERSION_1_2_DEPRECATED)
+#if !defined(CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED)
+#define CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED
+#endif // #if !defined(CL_EXT_PREFIX__VERSION_1_2_DEPRECATED)
+
+#if !defined(CL_CALLBACK)
+#define CL_CALLBACK
+#endif //CL_CALLBACK
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+
+// Define a size_type to represent a correctly resolved size_t
+#if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY)
+namespace cl {
+ using size_type = ::size_t;
+} // namespace cl
+#else // #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY)
+namespace cl {
+ using size_type = size_t;
+} // namespace cl
+#endif // #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY)
+
+
+#if defined(CL_HPP_ENABLE_EXCEPTIONS)
+#include
+#endif // #if defined(CL_HPP_ENABLE_EXCEPTIONS)
+
+#if !defined(CL_HPP_NO_STD_VECTOR)
+#include
+namespace cl {
+ template < class T, class Alloc = std::allocator >
+ using vector = std::vector;
+} // namespace cl
+#endif // #if !defined(CL_HPP_NO_STD_VECTOR)
+
+#if !defined(CL_HPP_NO_STD_STRING)
+#include
+namespace cl {
+ using string = std::string;
+} // namespace cl
+#endif // #if !defined(CL_HPP_NO_STD_STRING)
+
+#if CL_HPP_TARGET_OPENCL_VERSION >= 200
+
+#if !defined(CL_HPP_NO_STD_UNIQUE_PTR)
+#include
+namespace cl {
+ // Replace unique_ptr and allocate_pointer for internal use
+ // to allow user to replace them
+ template
+ using pointer = std::unique_ptr;
+} // namespace cl
+#endif
+#endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200
+#if !defined(CL_HPP_NO_STD_ARRAY)
+#include
+namespace cl {
+ template < class T, size_type N >
+ using array = std::array;
+} // namespace cl
+#endif // #if !defined(CL_HPP_NO_STD_ARRAY)
+
+// Define size_type appropriately to allow backward-compatibility
+// use of the old size_t interface class
+#if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY)
+namespace cl {
+ namespace compatibility {
+ /*! \brief class used to interface between C++ and
+ * OpenCL C calls that require arrays of size_t values, whose
+ * size is known statically.
+ */
+ template
+ class size_t
+ {
+ private:
+ size_type data_[N];
+
+ public:
+ //! \brief Initialize size_t to all 0s
+ size_t()
+ {
+ for (int i = 0; i < N; ++i) {
+ data_[i] = 0;
+ }
+ }
+
+ size_t(const array &rhs)
+ {
+ for (int i = 0; i < N; ++i) {
+ data_[i] = rhs[i];
+ }
+ }
+
+ size_type& operator[](int index)
+ {
+ return data_[index];
+ }
+
+ const size_type& operator[](int index) const
+ {
+ return data_[index];
+ }
+
+ //! \brief Conversion operator to T*.
+ operator size_type* () { return data_; }
+
+ //! \brief Conversion operator to const T*.
+ operator const size_type* () const { return data_; }
+
+ operator array() const
+ {
+ array ret;
+
+ for (int i = 0; i < N; ++i) {
+ ret[i] = data_[i];
+ }
+ return ret;
+ }
+ };
+ } // namespace compatibility
+
+ template
+ using size_t = compatibility::size_t;
+} // namespace cl
+#endif // #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY)
+
+// Helper alias to avoid confusing the macros
+namespace cl {
+ namespace detail {
+ using size_t_array = array;
+ } // namespace detail
+} // namespace cl
+
+
+/*! \namespace cl
+ *
+ * \brief The OpenCL C++ bindings are defined within this namespace.
+ *
+ */
+namespace cl {
+ class Memory;
+
+#define CL_HPP_INIT_CL_EXT_FCN_PTR_(name) \
+ if (!pfn_##name) { \
+ pfn_##name = (PFN_##name) \
+ clGetExtensionFunctionAddress(#name); \
+ if (!pfn_##name) { \
+ } \
+ }
+
+#define CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, name) \
+ if (!pfn_##name) { \
+ pfn_##name = (PFN_##name) \
+ clGetExtensionFunctionAddressForPlatform(platform, #name); \
+ if (!pfn_##name) { \
+ } \
+ }
+
+ class Program;
+ class Device;
+ class Context;
+ class CommandQueue;
+ class DeviceCommandQueue;
+ class Memory;
+ class Buffer;
+ class Pipe;
+
+#if defined(CL_HPP_ENABLE_EXCEPTIONS)
+ /*! \brief Exception class
+ *
+ * This may be thrown by API functions when CL_HPP_ENABLE_EXCEPTIONS is defined.
+ */
+ class Error : public std::exception
+ {
+ private:
+ cl_int err_;
+ const char * errStr_;
+ public:
+ /*! \brief Create a new CL error exception for a given error code
+ * and corresponding message.
+ *
+ * \param err error code value.
+ *
+ * \param errStr a descriptive string that must remain in scope until
+ * handling of the exception has concluded. If set, it
+ * will be returned by what().
+ */
+ Error(cl_int err, const char * errStr = NULL) : err_(err), errStr_(errStr)
+ {}
+
+ ~Error() throw() {}
+
+ /*! \brief Get error string associated with exception
+ *
+ * \return A memory pointer to the error message string.
+ */
+ virtual const char * what() const throw ()
+ {
+ if (errStr_ == NULL) {
+ return "empty";
+ }
+ else {
+ return errStr_;
+ }
+ }
+
+ /*! \brief Get error code associated with exception
+ *
+ * \return The error code.
+ */
+ cl_int err(void) const { return err_; }
+ };
+#define CL_HPP_ERR_STR_(x) #x
+#else
+#define CL_HPP_ERR_STR_(x) NULL
+#endif // CL_HPP_ENABLE_EXCEPTIONS
+
+
+namespace detail
+{
+#if defined(CL_HPP_ENABLE_EXCEPTIONS)
+static inline cl_int errHandler (
+ cl_int err,
+ const char * errStr = NULL)
+{
+ if (err != CL_SUCCESS) {
+ throw Error(err, errStr);
+ }
+ return err;
+}
+#else
+static inline cl_int errHandler (cl_int err, const char * errStr = NULL)
+{
+ (void) errStr; // suppress unused variable warning
+ return err;
+}
+#endif // CL_HPP_ENABLE_EXCEPTIONS
+}
+
+
+
+//! \cond DOXYGEN_DETAIL
+#if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS)
+#define __GET_DEVICE_INFO_ERR CL_HPP_ERR_STR_(clGetDeviceInfo)
+#define __GET_PLATFORM_INFO_ERR CL_HPP_ERR_STR_(clGetPlatformInfo)
+#define __GET_DEVICE_IDS_ERR CL_HPP_ERR_STR_(clGetDeviceIDs)
+#define __GET_PLATFORM_IDS_ERR CL_HPP_ERR_STR_(clGetPlatformIDs)
+#define __GET_CONTEXT_INFO_ERR CL_HPP_ERR_STR_(clGetContextInfo)
+#define __GET_EVENT_INFO_ERR CL_HPP_ERR_STR_(clGetEventInfo)
+#define __GET_EVENT_PROFILE_INFO_ERR CL_HPP_ERR_STR_(clGetEventProfileInfo)
+#define __GET_MEM_OBJECT_INFO_ERR CL_HPP_ERR_STR_(clGetMemObjectInfo)
+#define __GET_IMAGE_INFO_ERR CL_HPP_ERR_STR_(clGetImageInfo)
+#define __GET_SAMPLER_INFO_ERR CL_HPP_ERR_STR_(clGetSamplerInfo)
+#define __GET_KERNEL_INFO_ERR CL_HPP_ERR_STR_(clGetKernelInfo)
+#if CL_HPP_TARGET_OPENCL_VERSION >= 120
+#define __GET_KERNEL_ARG_INFO_ERR CL_HPP_ERR_STR_(clGetKernelArgInfo)
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
+#define __GET_KERNEL_WORK_GROUP_INFO_ERR CL_HPP_ERR_STR_(clGetKernelWorkGroupInfo)
+#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)
+
+#define __CREATE_CONTEXT_ERR CL_HPP_ERR_STR_(clCreateContext)
+#define __CREATE_CONTEXT_FROM_TYPE_ERR CL_HPP_ERR_STR_(clCreateContextFromType)
+#define __GET_SUPPORTED_IMAGE_FORMATS_ERR CL_HPP_ERR_STR_(clGetSupportedImageFormats)
+
+#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 __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)
+#define __CREATE_GL_TEXTURE_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture)
+#define __IMAGE_DIMENSION_ERR CL_HPP_ERR_STR_(Incorrect image dimensions)
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
+#define __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR CL_HPP_ERR_STR_(clSetMemObjectDestructorCallback)
+
+#define __CREATE_USER_EVENT_ERR CL_HPP_ERR_STR_(clCreateUserEvent)
+#define __SET_USER_EVENT_STATUS_ERR CL_HPP_ERR_STR_(clSetUserEventStatus)
+#define __SET_EVENT_CALLBACK_ERR CL_HPP_ERR_STR_(clSetEventCallback)
+#define __WAIT_FOR_EVENTS_ERR CL_HPP_ERR_STR_(clWaitForEvents)
+
+#define __CREATE_KERNEL_ERR CL_HPP_ERR_STR_(clCreateKernel)
+#define __SET_KERNEL_ARGS_ERR CL_HPP_ERR_STR_(clSetKernelArg)
+#define __CREATE_PROGRAM_WITH_SOURCE_ERR CL_HPP_ERR_STR_(clCreateProgramWithSource)
+#define __CREATE_PROGRAM_WITH_BINARY_ERR CL_HPP_ERR_STR_(clCreateProgramWithBinary)
+#if CL_HPP_TARGET_OPENCL_VERSION >= 120
+#define __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR CL_HPP_ERR_STR_(clCreateProgramWithBuiltInKernels)
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
+#define __BUILD_PROGRAM_ERR CL_HPP_ERR_STR_(clBuildProgram)
+#if CL_HPP_TARGET_OPENCL_VERSION >= 120
+#define __COMPILE_PROGRAM_ERR CL_HPP_ERR_STR_(clCompileProgram)
+#define __LINK_PROGRAM_ERR CL_HPP_ERR_STR_(clLinkProgram)
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
+#define __CREATE_KERNELS_IN_PROGRAM_ERR CL_HPP_ERR_STR_(clCreateKernelsInProgram)
+
+#if CL_HPP_TARGET_OPENCL_VERSION >= 200
+#define __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR CL_HPP_ERR_STR_(clCreateCommandQueueWithProperties)
+#define __CREATE_SAMPLER_WITH_PROPERTIES_ERR CL_HPP_ERR_STR_(clCreateSamplerWithProperties)
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 200
+#define __SET_COMMAND_QUEUE_PROPERTY_ERR CL_HPP_ERR_STR_(clSetCommandQueueProperty)
+#define __ENQUEUE_READ_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueReadBuffer)
+#define __ENQUEUE_READ_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueReadBufferRect)
+#define __ENQUEUE_WRITE_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueWriteBuffer)
+#define __ENQUEUE_WRITE_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueWriteBufferRect)
+#define __ENQEUE_COPY_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueCopyBuffer)
+#define __ENQEUE_COPY_BUFFER_RECT_ERR CL_HPP_ERR_STR_(clEnqueueCopyBufferRect)
+#define __ENQUEUE_FILL_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueFillBuffer)
+#define __ENQUEUE_READ_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueReadImage)
+#define __ENQUEUE_WRITE_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueWriteImage)
+#define __ENQUEUE_COPY_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueCopyImage)
+#define __ENQUEUE_FILL_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueFillImage)
+#define __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueCopyImageToBuffer)
+#define __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueCopyBufferToImage)
+#define __ENQUEUE_MAP_BUFFER_ERR CL_HPP_ERR_STR_(clEnqueueMapBuffer)
+#define __ENQUEUE_MAP_IMAGE_ERR CL_HPP_ERR_STR_(clEnqueueMapImage)
+#define __ENQUEUE_UNMAP_MEM_OBJECT_ERR CL_HPP_ERR_STR_(clEnqueueUnMapMemObject)
+#define __ENQUEUE_NDRANGE_KERNEL_ERR CL_HPP_ERR_STR_(clEnqueueNDRangeKernel)
+#define __ENQUEUE_NATIVE_KERNEL CL_HPP_ERR_STR_(clEnqueueNativeKernel)
+#if CL_HPP_TARGET_OPENCL_VERSION >= 120
+#define __ENQUEUE_MIGRATE_MEM_OBJECTS_ERR CL_HPP_ERR_STR_(clEnqueueMigrateMemObjects)
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
+
+#define __ENQUEUE_ACQUIRE_GL_ERR CL_HPP_ERR_STR_(clEnqueueAcquireGLObjects)
+#define __ENQUEUE_RELEASE_GL_ERR CL_HPP_ERR_STR_(clEnqueueReleaseGLObjects)
+
+#define __CREATE_PIPE_ERR CL_HPP_ERR_STR_(clCreatePipe)
+#define __GET_PIPE_INFO_ERR CL_HPP_ERR_STR_(clGetPipeInfo)
+
+
+#define __RETAIN_ERR CL_HPP_ERR_STR_(Retain Object)
+#define __RELEASE_ERR CL_HPP_ERR_STR_(Release Object)
+#define __FLUSH_ERR CL_HPP_ERR_STR_(clFlush)
+#define __FINISH_ERR CL_HPP_ERR_STR_(clFinish)
+#define __VECTOR_CAPACITY_ERR CL_HPP_ERR_STR_(Vector capacity error)
+
+/**
+ * CL 1.2 version that uses device fission.
+ */
+#if CL_HPP_TARGET_OPENCL_VERSION >= 120
+#define __CREATE_SUB_DEVICES_ERR CL_HPP_ERR_STR_(clCreateSubDevices)
+#else
+#define __CREATE_SUB_DEVICES_ERR CL_HPP_ERR_STR_(clCreateSubDevicesEXT)
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
+
+/**
+ * Deprecated APIs for 1.2
+ */
+#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
+#define __ENQUEUE_MARKER_ERR CL_HPP_ERR_STR_(clEnqueueMarker)
+#define __ENQUEUE_WAIT_FOR_EVENTS_ERR CL_HPP_ERR_STR_(clEnqueueWaitForEvents)
+#define __ENQUEUE_BARRIER_ERR CL_HPP_ERR_STR_(clEnqueueBarrier)
+#define __UNLOAD_COMPILER_ERR CL_HPP_ERR_STR_(clUnloadCompiler)
+#define __CREATE_GL_TEXTURE_2D_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture2D)
+#define __CREATE_GL_TEXTURE_3D_ERR CL_HPP_ERR_STR_(clCreateFromGLTexture3D)
+#define __CREATE_IMAGE2D_ERR CL_HPP_ERR_STR_(clCreateImage2D)
+#define __CREATE_IMAGE3D_ERR CL_HPP_ERR_STR_(clCreateImage3D)
+#endif // #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
+
+/**
+ * Deprecated APIs for 2.0
+ */
+#if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
+#define __CREATE_COMMAND_QUEUE_ERR CL_HPP_ERR_STR_(clCreateCommandQueue)
+#define __ENQUEUE_TASK_ERR CL_HPP_ERR_STR_(clEnqueueTask)
+#define __CREATE_SAMPLER_ERR CL_HPP_ERR_STR_(clCreateSampler)
+#endif // #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
+
+/**
+ * CL 1.2 marker and barrier commands
+ */
+#if CL_HPP_TARGET_OPENCL_VERSION >= 120
+#define __ENQUEUE_MARKER_WAIT_LIST_ERR CL_HPP_ERR_STR_(clEnqueueMarkerWithWaitList)
+#define __ENQUEUE_BARRIER_WAIT_LIST_ERR CL_HPP_ERR_STR_(clEnqueueBarrierWithWaitList)
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
+
+#endif // CL_HPP_USER_OVERRIDE_ERROR_STRINGS
+//! \endcond
+
+
+namespace detail {
+
+// Generic getInfoHelper. The final parameter is used to guide overload
+// resolution: the actual parameter passed is an int, which makes this
+// a worse conversion sequence than a specialization that declares the
+// parameter as an int.
+template
+inline cl_int getInfoHelper(Functor f, cl_uint name, T* param, long)
+{
+ return f(name, sizeof(T), param, NULL);
+}
+
+// Specialized for getInfo
+// Assumes that the output vector was correctly resized on the way in
+template
+inline cl_int getInfoHelper(Func f, cl_uint name, vector>* param, int)
+{
+ if (name != CL_PROGRAM_BINARIES) {
+ return CL_INVALID_VALUE;
+ }
+ if (param) {
+ // Create array of pointers, calculate total size and pass pointer array in
+ size_type numBinaries = param->size();
+ vector binariesPointers(numBinaries);
+
+ size_type totalSize = 0;
+ for (size_type i = 0; i < numBinaries; ++i)
+ {
+ binariesPointers[i] = (*param)[i].data();
+ totalSize += (*param)[i].size();
+ }
+
+ cl_int err = f(name, totalSize, binariesPointers.data(), NULL);
+
+ if (err != CL_SUCCESS) {
+ return err;
+ }
+ }
+
+
+ return CL_SUCCESS;
+}
+
+// Specialized getInfoHelper for vector params
+template
+inline cl_int getInfoHelper(Func f, cl_uint name, vector* param, long)
+{
+ size_type required;
+ cl_int err = f(name, 0, NULL, &required);
+ if (err != CL_SUCCESS) {
+ return err;
+ }
+ const size_type elements = required / sizeof(T);
+
+ // Temporary to avoid changing param on an error
+ vector localData(elements);
+ err = f(name, required, localData.data(), NULL);
+ if (err != CL_SUCCESS) {
+ return err;
+ }
+ if (param) {
+ *param = std::move(localData);
+ }
+
+ return CL_SUCCESS;
+}
+
+/* Specialization for reference-counted types. This depends on the
+ * existence of Wrapper::cl_type, and none of the other types having the
+ * cl_type member. Note that simplify specifying the parameter as Wrapper
+ * does not work, because when using a derived type (e.g. Context) the generic
+ * template will provide a better match.
+ */
+template
+inline cl_int getInfoHelper(
+ Func f, cl_uint name, vector* param, int, typename T::cl_type = 0)
+{
+ size_type required;
+ cl_int err = f(name, 0, NULL, &required);
+ if (err != CL_SUCCESS) {
+ return err;
+ }
+
+ const size_type elements = required / sizeof(typename T::cl_type);
+
+ vector value(elements);
+ err = f(name, required, value.data(), NULL);
+ if (err != CL_SUCCESS) {
+ return err;
+ }
+
+ if (param) {
+ // Assign to convert CL type to T for each element
+ param->resize(elements);
+
+ // Assign to param, constructing with retain behaviour
+ // to correctly capture each underlying CL object
+ for (size_type i = 0; i < elements; i++) {
+ (*param)[i] = T(value[i], true);
+ }
+ }
+ return CL_SUCCESS;
+}
+
+// Specialized GetInfoHelper for string params
+template
+inline cl_int getInfoHelper(Func f, cl_uint name, string* param, long)
+{
+ size_type required;
+ cl_int err = f(name, 0, NULL, &required);
+ if (err != CL_SUCCESS) {
+ return err;
+ }
+
+ // std::string has a constant data member
+ // a char vector does not
+ if (required > 0) {
+ vector value(required);
+ err = f(name, required, value.data(), NULL);
+ if (err != CL_SUCCESS) {
+ return err;
+ }
+ if (param) {
+ param->assign(begin(value), prev(end(value)));
+ }
+ }
+ else if (param) {
+ param->assign("");
+ }
+ return CL_SUCCESS;
+}
+
+// Specialized GetInfoHelper for clsize_t params
+template
+inline cl_int getInfoHelper(Func f, cl_uint name, array* param, long)
+{
+ size_type required;
+ cl_int err = f(name, 0, NULL, &required);
+ if (err != CL_SUCCESS) {
+ return err;
+ }
+
+ size_type elements = required / sizeof(size_type);
+ vector value(elements, 0);
+
+ err = f(name, required, value.data(), NULL);
+ if (err != CL_SUCCESS) {
+ return err;
+ }
+
+ // Bound the copy with N to prevent overruns
+ // if passed N > than the amount copied
+ if (elements > N) {
+ elements = N;
+ }
+ for (size_type i = 0; i < elements; ++i) {
+ (*param)[i] = value[i];
+ }
+
+ return CL_SUCCESS;
+}
+
+template struct ReferenceHandler;
+
+/* Specialization for reference-counted types. This depends on the
+ * existence of Wrapper::cl_type, and none of the other types having the
+ * cl_type member. Note that simplify specifying the parameter as Wrapper
+ * does not work, because when using a derived type (e.g. Context) the generic
+ * template will provide a better match.
+ */
+template
+inline cl_int getInfoHelper(Func f, cl_uint name, T* param, int, typename T::cl_type = 0)
+{
+ typename T::cl_type value;
+ cl_int err = f(name, sizeof(value), &value, NULL);
+ if (err != CL_SUCCESS) {
+ return err;
+ }
+ *param = value;
+ if (value != NULL)
+ {
+ err = param->retain();
+ if (err != CL_SUCCESS) {
+ return err;
+ }
+ }
+ return CL_SUCCESS;
+}
+
+#define CL_HPP_PARAM_NAME_INFO_1_0_(F) \
+ F(cl_platform_info, CL_PLATFORM_PROFILE, string) \
+ F(cl_platform_info, CL_PLATFORM_VERSION, string) \
+ F(cl_platform_info, CL_PLATFORM_NAME, string) \
+ F(cl_platform_info, CL_PLATFORM_VENDOR, string) \
+ F(cl_platform_info, CL_PLATFORM_EXTENSIONS, string) \
+ \
+ F(cl_device_info, CL_DEVICE_TYPE, cl_device_type) \
+ F(cl_device_info, CL_DEVICE_VENDOR_ID, cl_uint) \
+ F(cl_device_info, CL_DEVICE_MAX_COMPUTE_UNITS, cl_uint) \
+ F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, cl_uint) \
+ F(cl_device_info, CL_DEVICE_MAX_WORK_GROUP_SIZE, size_type) \
+ F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_SIZES, cl::vector) \
+ F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, cl_uint) \
+ F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT, cl_uint) \
+ F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT, cl_uint) \
+ F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG, cl_uint) \
+ F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT, cl_uint) \
+ F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, cl_uint) \
+ F(cl_device_info, CL_DEVICE_MAX_CLOCK_FREQUENCY, cl_uint) \
+ F(cl_device_info, CL_DEVICE_ADDRESS_BITS, cl_uint) \
+ F(cl_device_info, CL_DEVICE_MAX_READ_IMAGE_ARGS, cl_uint) \
+ F(cl_device_info, CL_DEVICE_MAX_WRITE_IMAGE_ARGS, cl_uint) \
+ F(cl_device_info, CL_DEVICE_MAX_MEM_ALLOC_SIZE, cl_ulong) \
+ F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_WIDTH, size_type) \
+ F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_HEIGHT, size_type) \
+ F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_WIDTH, size_type) \
+ F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_HEIGHT, size_type) \
+ F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_DEPTH, size_type) \
+ F(cl_device_info, CL_DEVICE_IMAGE_SUPPORT, cl_bool) \
+ F(cl_device_info, CL_DEVICE_MAX_PARAMETER_SIZE, size_type) \
+ F(cl_device_info, CL_DEVICE_MAX_SAMPLERS, cl_uint) \
+ F(cl_device_info, CL_DEVICE_MEM_BASE_ADDR_ALIGN, cl_uint) \
+ F(cl_device_info, CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE, cl_uint) \
+ F(cl_device_info, CL_DEVICE_SINGLE_FP_CONFIG, cl_device_fp_config) \
+ F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_TYPE, cl_device_mem_cache_type) \
+ F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE, cl_uint)\
+ F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_SIZE, cl_ulong) \
+ F(cl_device_info, CL_DEVICE_GLOBAL_MEM_SIZE, cl_ulong) \
+ F(cl_device_info, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE, cl_ulong) \
+ F(cl_device_info, CL_DEVICE_MAX_CONSTANT_ARGS, cl_uint) \
+ F(cl_device_info, CL_DEVICE_LOCAL_MEM_TYPE, cl_device_local_mem_type) \
+ F(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE, cl_ulong) \
+ F(cl_device_info, CL_DEVICE_ERROR_CORRECTION_SUPPORT, cl_bool) \
+ F(cl_device_info, CL_DEVICE_PROFILING_TIMER_RESOLUTION, size_type) \
+ F(cl_device_info, CL_DEVICE_ENDIAN_LITTLE, cl_bool) \
+ F(cl_device_info, CL_DEVICE_AVAILABLE, cl_bool) \
+ F(cl_device_info, CL_DEVICE_COMPILER_AVAILABLE, cl_bool) \
+ F(cl_device_info, CL_DEVICE_EXECUTION_CAPABILITIES, cl_device_exec_capabilities) \
+ F(cl_device_info, CL_DEVICE_PLATFORM, cl_platform_id) \
+ F(cl_device_info, CL_DEVICE_NAME, string) \
+ F(cl_device_info, CL_DEVICE_VENDOR, string) \
+ F(cl_device_info, CL_DRIVER_VERSION, string) \
+ F(cl_device_info, CL_DEVICE_PROFILE, string) \
+ F(cl_device_info, CL_DEVICE_VERSION, string) \
+ F(cl_device_info, CL_DEVICE_EXTENSIONS, string) \
+ \
+ F(cl_context_info, CL_CONTEXT_REFERENCE_COUNT, cl_uint) \
+ F(cl_context_info, CL_CONTEXT_DEVICES, cl::vector) \
+ F(cl_context_info, CL_CONTEXT_PROPERTIES, cl::vector) \
+ \
+ F(cl_event_info, CL_EVENT_COMMAND_QUEUE, cl::CommandQueue) \
+ F(cl_event_info, CL_EVENT_COMMAND_TYPE, cl_command_type) \
+ F(cl_event_info, CL_EVENT_REFERENCE_COUNT, cl_uint) \
+ F(cl_event_info, CL_EVENT_COMMAND_EXECUTION_STATUS, cl_int) \
+ \
+ F(cl_profiling_info, CL_PROFILING_COMMAND_QUEUED, cl_ulong) \
+ F(cl_profiling_info, CL_PROFILING_COMMAND_SUBMIT, cl_ulong) \
+ F(cl_profiling_info, CL_PROFILING_COMMAND_START, cl_ulong) \
+ F(cl_profiling_info, CL_PROFILING_COMMAND_END, cl_ulong) \
+ \
+ F(cl_mem_info, CL_MEM_TYPE, cl_mem_object_type) \
+ F(cl_mem_info, CL_MEM_FLAGS, cl_mem_flags) \
+ F(cl_mem_info, CL_MEM_SIZE, size_type) \
+ F(cl_mem_info, CL_MEM_HOST_PTR, void*) \
+ F(cl_mem_info, CL_MEM_MAP_COUNT, cl_uint) \
+ F(cl_mem_info, CL_MEM_REFERENCE_COUNT, cl_uint) \
+ F(cl_mem_info, CL_MEM_CONTEXT, cl::Context) \
+ \
+ F(cl_image_info, CL_IMAGE_FORMAT, cl_image_format) \
+ F(cl_image_info, CL_IMAGE_ELEMENT_SIZE, size_type) \
+ F(cl_image_info, CL_IMAGE_ROW_PITCH, size_type) \
+ F(cl_image_info, CL_IMAGE_SLICE_PITCH, size_type) \
+ F(cl_image_info, CL_IMAGE_WIDTH, size_type) \
+ F(cl_image_info, CL_IMAGE_HEIGHT, size_type) \
+ F(cl_image_info, CL_IMAGE_DEPTH, size_type) \
+ F(cl_image_info, CL_IMAGE_ARRAY_SIZE, size_type) \
+ F(cl_image_info, CL_IMAGE_NUM_MIP_LEVELS, cl_uint) \
+ F(cl_image_info, CL_IMAGE_NUM_SAMPLES, cl_uint) \
+ \
+ F(cl_sampler_info, CL_SAMPLER_REFERENCE_COUNT, cl_uint) \
+ F(cl_sampler_info, CL_SAMPLER_CONTEXT, cl::Context) \
+ F(cl_sampler_info, CL_SAMPLER_NORMALIZED_COORDS, cl_bool) \
+ F(cl_sampler_info, CL_SAMPLER_ADDRESSING_MODE, cl_addressing_mode) \
+ F(cl_sampler_info, CL_SAMPLER_FILTER_MODE, cl_filter_mode) \
+ \
+ F(cl_program_info, CL_PROGRAM_REFERENCE_COUNT, cl_uint) \
+ F(cl_program_info, CL_PROGRAM_CONTEXT, cl::Context) \
+ F(cl_program_info, CL_PROGRAM_NUM_DEVICES, cl_uint) \
+ F(cl_program_info, CL_PROGRAM_DEVICES, cl::vector) \
+ F(cl_program_info, CL_PROGRAM_SOURCE, string) \
+ F(cl_program_info, CL_PROGRAM_BINARY_SIZES, cl::vector) \
+ F(cl_program_info, CL_PROGRAM_BINARIES, cl::vector>) \
+ \
+ F(cl_program_build_info, CL_PROGRAM_BUILD_STATUS, cl_build_status) \
+ F(cl_program_build_info, CL_PROGRAM_BUILD_OPTIONS, string) \
+ F(cl_program_build_info, CL_PROGRAM_BUILD_LOG, string) \
+ \
+ F(cl_kernel_info, CL_KERNEL_FUNCTION_NAME, string) \
+ F(cl_kernel_info, CL_KERNEL_NUM_ARGS, cl_uint) \
+ F(cl_kernel_info, CL_KERNEL_REFERENCE_COUNT, cl_uint) \
+ F(cl_kernel_info, CL_KERNEL_CONTEXT, cl::Context) \
+ F(cl_kernel_info, CL_KERNEL_PROGRAM, cl::Program) \
+ \
+ F(cl_kernel_work_group_info, CL_KERNEL_WORK_GROUP_SIZE, size_type) \
+ F(cl_kernel_work_group_info, CL_KERNEL_COMPILE_WORK_GROUP_SIZE, cl::detail::size_t_array) \
+ F(cl_kernel_work_group_info, CL_KERNEL_LOCAL_MEM_SIZE, cl_ulong) \
+ \
+ F(cl_command_queue_info, CL_QUEUE_CONTEXT, cl::Context) \
+ F(cl_command_queue_info, CL_QUEUE_DEVICE, cl::Device) \
+ F(cl_command_queue_info, CL_QUEUE_REFERENCE_COUNT, cl_uint) \
+ F(cl_command_queue_info, CL_QUEUE_PROPERTIES, cl_command_queue_properties)
+
+
+#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_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) \
+ F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG, cl_uint) \
+ F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT, cl_uint) \
+ F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE, cl_uint) \
+ F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF, cl_uint) \
+ F(cl_device_info, CL_DEVICE_DOUBLE_FP_CONFIG, cl_device_fp_config) \
+ F(cl_device_info, CL_DEVICE_HALF_FP_CONFIG, cl_device_fp_config) \
+ F(cl_device_info, CL_DEVICE_OPENCL_C_VERSION, string) \
+ \
+ F(cl_mem_info, CL_MEM_ASSOCIATED_MEMOBJECT, cl::Memory) \
+ F(cl_mem_info, CL_MEM_OFFSET, size_type) \
+ \
+ F(cl_kernel_work_group_info, CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, size_type) \
+ F(cl_kernel_work_group_info, CL_KERNEL_PRIVATE_MEM_SIZE, cl_ulong) \
+ \
+ F(cl_event_info, CL_EVENT_CONTEXT, cl::Context)
+
+#define CL_HPP_PARAM_NAME_INFO_1_2_(F) \
+ F(cl_program_info, CL_PROGRAM_NUM_KERNELS, size_type) \
+ F(cl_program_info, CL_PROGRAM_KERNEL_NAMES, string) \
+ \
+ F(cl_program_build_info, CL_PROGRAM_BINARY_TYPE, cl_program_binary_type) \
+ \
+ F(cl_kernel_info, CL_KERNEL_ATTRIBUTES, string) \
+ \
+ F(cl_kernel_arg_info, CL_KERNEL_ARG_ADDRESS_QUALIFIER, cl_kernel_arg_address_qualifier) \
+ F(cl_kernel_arg_info, CL_KERNEL_ARG_ACCESS_QUALIFIER, cl_kernel_arg_access_qualifier) \
+ F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_NAME, string) \
+ F(cl_kernel_arg_info, CL_KERNEL_ARG_NAME, string) \
+ F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_QUALIFIER, cl_kernel_arg_type_qualifier) \
+ \
+ F(cl_device_info, CL_DEVICE_PARENT_DEVICE, cl::Device) \
+ F(cl_device_info, CL_DEVICE_PARTITION_PROPERTIES, cl::vector) \
+ F(cl_device_info, CL_DEVICE_PARTITION_TYPE, cl::vector) \
+ F(cl_device_info, CL_DEVICE_REFERENCE_COUNT, cl_uint) \
+ F(cl_device_info, CL_DEVICE_PREFERRED_INTEROP_USER_SYNC, size_type) \
+ F(cl_device_info, CL_DEVICE_PARTITION_AFFINITY_DOMAIN, cl_device_affinity_domain) \
+ F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS, string)
+
+#define CL_HPP_PARAM_NAME_INFO_2_0_(F) \
+ F(cl_device_info, CL_DEVICE_QUEUE_ON_HOST_PROPERTIES, cl_command_queue_properties) \
+ F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES, cl_command_queue_properties) \
+ F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE, cl_uint) \
+ F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE, cl_uint) \
+ F(cl_device_info, CL_DEVICE_MAX_ON_DEVICE_QUEUES, cl_uint) \
+ F(cl_device_info, CL_DEVICE_MAX_ON_DEVICE_EVENTS, cl_uint) \
+ F(cl_device_info, CL_DEVICE_MAX_PIPE_ARGS, cl_uint) \
+ F(cl_device_info, CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS, cl_uint) \
+ F(cl_device_info, CL_DEVICE_PIPE_MAX_PACKET_SIZE, cl_uint) \
+ F(cl_device_info, CL_DEVICE_SVM_CAPABILITIES, cl_device_svm_capabilities) \
+ F(cl_device_info, CL_DEVICE_PREFERRED_PLATFORM_ATOMIC_ALIGNMENT, cl_uint) \
+ F(cl_device_info, CL_DEVICE_PREFERRED_GLOBAL_ATOMIC_ALIGNMENT, cl_uint) \
+ F(cl_device_info, CL_DEVICE_PREFERRED_LOCAL_ATOMIC_ALIGNMENT, cl_uint) \
+ F(cl_command_queue_info, CL_QUEUE_SIZE, cl_uint) \
+ F(cl_mem_info, CL_MEM_USES_SVM_POINTER, cl_bool) \
+ F(cl_program_build_info, CL_PROGRAM_BUILD_GLOBAL_VARIABLE_TOTAL_SIZE, size_type) \
+ F(cl_pipe_info, CL_PIPE_PACKET_SIZE, cl_uint) \
+ F(cl_pipe_info, CL_PIPE_MAX_PACKETS, cl_uint)
+
+#define CL_HPP_PARAM_NAME_DEVICE_FISSION_(F) \
+ F(cl_device_info, CL_DEVICE_PARENT_DEVICE_EXT, cl_device_id) \
+ F(cl_device_info, CL_DEVICE_PARTITION_TYPES_EXT, cl::vector) \
+ F(cl_device_info, CL_DEVICE_AFFINITY_DOMAINS_EXT, cl::vector) \
+ F(cl_device_info, CL_DEVICE_REFERENCE_COUNT_EXT , cl_uint) \
+ F(cl_device_info, CL_DEVICE_PARTITION_STYLE_EXT, cl::vector)
+
+template
+struct param_traits {};
+
+#define CL_HPP_DECLARE_PARAM_TRAITS_(token, param_name, T) \
+struct token; \
+template<> \
+struct param_traits \
+{ \
+ enum { value = param_name }; \
+ typedef T param_type; \
+};
+
+CL_HPP_PARAM_NAME_INFO_1_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
+#if CL_HPP_TARGET_OPENCL_VERSION >= 110
+CL_HPP_PARAM_NAME_INFO_1_1_(CL_HPP_DECLARE_PARAM_TRAITS_)
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 110
+#if CL_HPP_TARGET_OPENCL_VERSION >= 120
+CL_HPP_PARAM_NAME_INFO_1_2_(CL_HPP_DECLARE_PARAM_TRAITS_)
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 110
+#if CL_HPP_TARGET_OPENCL_VERSION >= 200
+CL_HPP_PARAM_NAME_INFO_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 110
+
+
+// Flags deprecated in OpenCL 2.0
+#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)
+
+// Include deprecated query flags based on versions
+// Only include deprecated 1.0 flags if 2.0 not active as there is an enum clash
+#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
+
+#if defined(CL_HPP_USE_CL_DEVICE_FISSION)
+CL_HPP_PARAM_NAME_DEVICE_FISSION_(CL_HPP_DECLARE_PARAM_TRAITS_);
+#endif // CL_HPP_USE_CL_DEVICE_FISSION
+
+#ifdef CL_PLATFORM_ICD_SUFFIX_KHR
+CL_HPP_DECLARE_PARAM_TRAITS_(cl_platform_info, CL_PLATFORM_ICD_SUFFIX_KHR, string)
+#endif
+
+#ifdef CL_DEVICE_PROFILING_TIMER_OFFSET_AMD
+CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_PROFILING_TIMER_OFFSET_AMD, cl_ulong)
+#endif
+
+#ifdef CL_DEVICE_GLOBAL_FREE_MEMORY_AMD
+CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_FREE_MEMORY_AMD, vector)
+#endif
+#ifdef CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD
+CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD, cl_uint)
+#endif
+#ifdef CL_DEVICE_SIMD_WIDTH_AMD
+CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_WIDTH_AMD, cl_uint)
+#endif
+#ifdef CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD
+CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD, cl_uint)
+#endif
+#ifdef CL_DEVICE_WAVEFRONT_WIDTH_AMD
+CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_WAVEFRONT_WIDTH_AMD, cl_uint)
+#endif
+#ifdef CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD
+CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD, cl_uint)
+#endif
+#ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD
+CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD, cl_uint)
+#endif
+#ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD
+CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD, cl_uint)
+#endif
+#ifdef CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD
+CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD, cl_uint)
+#endif
+#ifdef CL_DEVICE_LOCAL_MEM_BANKS_AMD
+CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LOCAL_MEM_BANKS_AMD, cl_uint)
+#endif
+
+#ifdef CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV
+CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV, cl_uint)
+#endif
+#ifdef CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV
+CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV, cl_uint)
+#endif
+#ifdef CL_DEVICE_REGISTERS_PER_BLOCK_NV
+CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_REGISTERS_PER_BLOCK_NV, cl_uint)
+#endif
+#ifdef CL_DEVICE_WARP_SIZE_NV
+CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_WARP_SIZE_NV, cl_uint)
+#endif
+#ifdef CL_DEVICE_GPU_OVERLAP_NV
+CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GPU_OVERLAP_NV, cl_bool)
+#endif
+#ifdef CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV
+CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV, cl_bool)
+#endif
+#ifdef CL_DEVICE_INTEGRATED_MEMORY_NV
+CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGRATED_MEMORY_NV, cl_bool)
+#endif
+
+// Convenience functions
+
+template
+inline cl_int
+getInfo(Func f, cl_uint name, T* param)
+{
+ return getInfoHelper(f, name, param, 0);
+}
+
+template
+struct GetInfoFunctor0
+{
+ Func f_; const Arg0& arg0_;
+ cl_int operator ()(
+ cl_uint param, size_type size, void* value, size_type* size_ret)
+ { return f_(arg0_, param, size, value, size_ret); }
+};
+
+template
+struct GetInfoFunctor1
+{
+ Func f_; const Arg0& arg0_; const Arg1& arg1_;
+ cl_int operator ()(
+ cl_uint param, size_type size, void* value, size_type* size_ret)
+ { return f_(arg0_, arg1_, param, size, value, size_ret); }
+};
+
+template
+inline cl_int
+getInfo(Func f, const Arg0& arg0, cl_uint name, T* param)
+{
+ GetInfoFunctor0 f0 = { f, arg0 };
+ return getInfoHelper(f0, name, param, 0);
+}
+
+template
+inline cl_int
+getInfo(Func f, const Arg0& arg0, const Arg1& arg1, cl_uint name, T* param)
+{
+ GetInfoFunctor1 f0 = { f, arg0, arg1 };
+ return getInfoHelper(f0, name, param, 0);
+}
+
+
+template
+struct ReferenceHandler
+{ };
+
+#if CL_HPP_TARGET_OPENCL_VERSION >= 120
+/**
+ * OpenCL 1.2 devices do have retain/release.
+ */
+template <>
+struct ReferenceHandler