Skip to content

Commit 3028382

Browse files
committed
sync with the upstream opencl.hpp
1 parent fc6d593 commit 3028382

File tree

1 file changed

+52
-41
lines changed

1 file changed

+52
-41
lines changed

include/CL/opencl.hpp

Lines changed: 52 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@
173173
* Enable exceptions for use in the C++ bindings header. This is the
174174
* preferred error handling mechanism but is not required.
175175
*
176+
* - CL_HPP_CUSTOM_EXCEPTION_TYPE
177+
*
178+
* Specify the type which should be used for exceptions. This type
179+
* must have a constructor accepting an int and a const char*.
180+
*
176181
* - CL_HPP_ENABLE_SIZE_T_COMPATIBILITY
177182
*
178183
* Backward compatibility option to support cl.hpp-style size_t
@@ -740,6 +745,7 @@ namespace cl {
740745
#endif // cl_khr_command_buffer
741746

742747
#if defined(CL_HPP_ENABLE_EXCEPTIONS)
748+
#if !defined(CL_HPP_CUSTOM_EXCEPTION_TYPE)
743749
/*! \brief Exception class
744750
*
745751
* This may be thrown by API functions when CL_HPP_ENABLE_EXCEPTIONS is defined.
@@ -782,6 +788,9 @@ namespace cl {
782788
*/
783789
cl_int err(void) const { return err_; }
784790
};
791+
#else
792+
using Error = CL_HPP_CUSTOM_EXCEPTION_TYPE;
793+
#endif
785794
#define CL_HPP_ERR_STR_(x) #x
786795
#else
787796
#define CL_HPP_ERR_STR_(x) nullptr
@@ -1501,6 +1510,9 @@ inline cl_int getInfoHelper(Func f, cl_uint name, T* param, int, typename T::cl_
15011510
F(cl_device_info, CL_DEVICE_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR, cl::vector<cl_external_semaphore_handle_type_khr>) \
15021511
F(cl_semaphore_info_khr, CL_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR, cl::vector<cl_external_semaphore_handle_type_khr>) \
15031512

1513+
#define CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_DX_FENCE_EXT(F) \
1514+
F(cl_external_semaphore_handle_type_khr, CL_SEMAPHORE_HANDLE_D3D12_FENCE_KHR, void*) \
1515+
15041516
#define CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_OPAQUE_FD_EXT(F) \
15051517
F(cl_external_semaphore_handle_type_khr, CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR, int) \
15061518

@@ -1650,6 +1662,19 @@ CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_MEMORY_(CL_HPP_DECLARE_PARAM_TRAITS_)
16501662
CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_(CL_HPP_DECLARE_PARAM_TRAITS_)
16511663
#endif // cl_khr_external_semaphore
16521664

1665+
#if defined(cl_khr_external_semaphore_dx_fence)
1666+
CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_DX_FENCE_EXT(CL_HPP_DECLARE_PARAM_TRAITS_)
1667+
#endif // cl_khr_external_semaphore_dx_fence
1668+
#if defined(cl_khr_external_semaphore_opaque_fd)
1669+
CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_OPAQUE_FD_EXT(CL_HPP_DECLARE_PARAM_TRAITS_)
1670+
#endif // cl_khr_external_semaphore_opaque_fd
1671+
#if defined(cl_khr_external_semaphore_sync_fd)
1672+
CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_SYNC_FD_EXT(CL_HPP_DECLARE_PARAM_TRAITS_)
1673+
#endif // cl_khr_external_semaphore_sync_fd
1674+
#if defined(cl_khr_external_semaphore_win32)
1675+
CL_HPP_PARAM_NAME_CL_KHR_EXTERNAL_SEMAPHORE_WIN32_EXT(CL_HPP_DECLARE_PARAM_TRAITS_)
1676+
#endif // cl_khr_external_semaphore_win32
1677+
16531678
#if defined(cl_khr_device_uuid)
16541679
using uuid_array = array<cl_uchar, CL_UUID_SIZE_KHR>;
16551680
using luid_array = array<cl_uchar, CL_LUID_SIZE_KHR>;
@@ -2014,6 +2039,17 @@ struct ReferenceHandler<cl_event>
20142039
{ return CL_(clReleaseEvent)(event); }
20152040
};
20162041

2042+
#ifdef cl_khr_semaphore
2043+
template <>
2044+
struct ReferenceHandler<cl_semaphore_khr>
2045+
{
2046+
static cl_int retain(cl_semaphore_khr semaphore)
2047+
{ return CL_(clRetainSemaphoreKHR)(semaphore); }
2048+
2049+
static cl_int release(cl_semaphore_khr semaphore)
2050+
{ return CL_(clReleaseSemaphoreKHR)(semaphore); }
2051+
};
2052+
#endif // cl_khr_semaphore
20172053
#if defined(cl_khr_command_buffer)
20182054
template <>
20192055
struct ReferenceHandler<cl_command_buffer_khr>
@@ -2023,6 +2059,17 @@ struct ReferenceHandler<cl_command_buffer_khr>
20232059
static cl_int release(cl_command_buffer_khr cmdbuf)
20242060
{ return CL_(clReleaseCommandBufferKHR)(cmdbuf); }
20252061
};
2062+
2063+
template <>
2064+
struct ReferenceHandler<cl_mutable_command_khr>
2065+
{
2066+
// cl_mutable_command_khr does not have retain().
2067+
static cl_int retain(cl_mutable_command_khr)
2068+
{ return CL_SUCCESS; }
2069+
// cl_mutable_command_khr does not have release().
2070+
static cl_int release(cl_mutable_command_khr)
2071+
{ return CL_SUCCESS; }
2072+
};
20262073
#endif // cl_khr_command_buffer
20272074

20282075

@@ -10993,60 +11040,24 @@ namespace compatibility {
1099311040

1099411041

1099511042
#if defined(cl_khr_command_buffer)
10996-
1099711043
/*! \class CommandBuffer
1099811044
* \brief CommandBuffer interface for cl_command_buffer_khr.
1099911045
*/
1100011046
class CommandBuffer : public detail::Wrapper<cl_command_buffer_khr>
1100111047
{
1100211048
public:
11003-
CommandBuffer() {}
11049+
//! \brief Default constructor - initializes to nullptr.
11050+
CommandBuffer() : detail::Wrapper<cl_type>() { }
1100411051

11005-
/*! \brief Constructor from cl_command_queue - takes ownership.
11006-
*
11007-
* \param retainObject will cause the constructor to retain its cl object.
11008-
* Defaults to false to maintain compatibility with
11009-
* earlier versions.
11010-
*/
1101111052
explicit CommandBuffer(cl_command_buffer_khr cmdbuf, bool retainObject = false) :
1101211053
detail::Wrapper<cl_type>(cmdbuf, retainObject) { }
1101311054

11014-
// TODO: other overloads!
11015-
1101611055
CommandBuffer& operator = (const cl_command_buffer_khr& rhs)
1101711056
{
1101811057
detail::Wrapper<cl_type>::operator=(rhs);
1101911058
return *this;
1102011059
}
1102111060

11022-
/*! \brief Copy constructor to forward copy to the superclass correctly.
11023-
* Required for MSVC.
11024-
*/
11025-
CommandBuffer(const CommandBuffer& cmdbuf) : detail::Wrapper<cl_type>(cmdbuf) {}
11026-
11027-
/*! \brief Copy assignment to forward copy to the superclass correctly.
11028-
* Required for MSVC.
11029-
*/
11030-
CommandBuffer& operator = (const CommandBuffer& cmdbuf)
11031-
{
11032-
detail::Wrapper<cl_type>::operator=(cmdbuf);
11033-
return *this;
11034-
}
11035-
11036-
/*! \brief Move constructor to forward move to the superclass correctly.
11037-
* Required for MSVC.
11038-
*/
11039-
CommandBuffer(CommandBuffer&& cmdbuf) noexcept : detail::Wrapper<cl_type>(std::move(cmdbuf)) {}
11040-
11041-
/*! \brief Move assignment to forward move to the superclass correctly.
11042-
* Required for MSVC.
11043-
*/
11044-
CommandBuffer& operator = (CommandBuffer &&cmdbuf)
11045-
{
11046-
detail::Wrapper<cl_type>::operator=(std::move(cmdbuf));
11047-
return *this;
11048-
}
11049-
1105011061
template <typename T>
1105111062
cl_int getInfo(cl_command_buffer_info_khr name, T* param) const
1105211063
{
@@ -11057,8 +11068,8 @@ class CommandBuffer : public detail::Wrapper<cl_command_buffer_khr>
1105711068
}
1105811069

1105911070
template <cl_command_buffer_info_khr name> typename
11060-
detail::param_traits<detail::cl_command_buffer_info_khr, name>::param_type
11061-
getInfo(cl_int* err = nullptr) const
11071+
detail::param_traits<detail::cl_command_buffer_info_khr, name>::param_type
11072+
getInfo(cl_int* err = nullptr) const
1106211073
{
1106311074
typename detail::param_traits<
1106411075
detail::cl_command_buffer_info_khr, name>::param_type param{};
@@ -11069,7 +11080,7 @@ class CommandBuffer : public detail::Wrapper<cl_command_buffer_khr>
1106911080
return param;
1107011081
}
1107111082

11072-
cl_int finalize(void)
11083+
cl_int finalize() const
1107311084
{
1107411085
return detail::errHandler(
1107511086
CL_(clFinalizeCommandBufferKHR)(object_),

0 commit comments

Comments
 (0)