Skip to content

Commit 131fd29

Browse files
committed
Merge branch 'main' into global-variable-pointer
2 parents 6cc5a73 + 6b5735e commit 131fd29

150 files changed

Lines changed: 862 additions & 318 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
check:
1919
runs-on: ubuntu-latest
2020
steps:
21-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
21+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2222

2323
- name: Check Tabs
2424
run: |
@@ -39,7 +39,7 @@ jobs:
3939
runs-on: ${{matrix.os}}
4040

4141
steps:
42-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
42+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
4343

4444
- name: Get Ubuntu OpenGL Dependencies
4545
if: matrix.os == 'ubuntu-latest'
@@ -48,27 +48,27 @@ jobs:
4848
sudo apt-get install -y libglfw3-dev
4949
5050
- name: Get OpenCL Headers
51-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
51+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
5252
with:
5353
repository: KhronosGroup/OpenCL-Headers
5454
path: external/OpenCL-Headers
5555

5656
- name: Get OpenCL ICD Loader
57-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
57+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
5858
with:
5959
repository: KhronosGroup/OpenCL-ICD-Loader
6060
path: external/opencl-icd-loader
6161

6262
- name: Get OpenCL Extension Loader
6363
if: matrix.ext == 'YES'
64-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
64+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
6565
with:
6666
repository: bashbaug/opencl-extension-loader
6767
path: external/opencl-extension-loader
6868

6969
- name: Get SPIR-V Headers
7070
if: matrix.ext == 'YES'
71-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
71+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
7272
with:
7373
repository: KhronosGroup/SPIRV-Headers
7474
path: external/SPIRV-Headers

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2019-2025 Ben Ashbaugh
1+
# Copyright (c) 2019-2026 Ben Ashbaugh
22
#
33
# SPDX-License-Identifier: MIT
44

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019-2025 Ben Ashbaugh
3+
Copyright (c) 2019-2026 Ben Ashbaugh
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Many samples that use extensions additionally require the OpenCL Extension Loade
3939

4040
git clone https://github.com/bashbaug/opencl-extension-loader external/opencl-extension-loader
4141

42-
Several samples that interact with SPIR-V require the SPIR-V headres:
42+
Several samples that interact with SPIR-V require the SPIR-V headers:
4343

4444
git clone https://github.com/KhronosGroup/SPIRV-Headers external/SPIRV-Headers
4545

@@ -97,4 +97,4 @@ parsing, which is licensed under the MIT License.
9797
---
9898
OpenCL and the OpenCL logo are trademarks of Apple Inc. used by permission by Khronos.
9999

100-
\* Other names and brands may be claimed as the property of others.
100+
\* Other names and brands may be claimed as the property of others.

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_),

include/getenv_util.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
// Copyright (c) 2022-2025 Ben Ashbaugh
2+
// Copyright (c) 2022-2026 Ben Ashbaugh
33
//
44
// SPDX-License-Identifier: MIT
55
*/

include/layer_util.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
// Copyright (c) 2022-2025 Ben Ashbaugh
2+
// Copyright (c) 2022-2026 Ben Ashbaugh
33
//
44
// SPDX-License-Identifier: MIT
55
*/

include/util.hpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
// Copyright (c) 2021-2025 Ben Ashbaugh
2+
// Copyright (c) 2021-2026 Ben Ashbaugh
33
//
44
// SPDX-License-Identifier: MIT
55
*/
@@ -67,3 +67,20 @@ static bool checkDeviceForExtension(
6767

6868
return supported;
6969
}
70+
71+
static bool checkPlatformIndex(
72+
const std::vector<cl::Platform>& platforms,
73+
int platformIndex)
74+
{
75+
if (platforms.size() == 0) {
76+
fprintf(stderr, "Error: No OpenCL platforms found.\n");
77+
return false;
78+
}
79+
if (platformIndex >= (int)platforms.size()) {
80+
fprintf(stderr, "Error: Invalid platform index %d specified (max %d)\n",
81+
platformIndex,
82+
(int)(platforms.size() - 1) );
83+
return false;
84+
}
85+
return true;
86+
}

layers/00_example/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2022-2025 Ben Ashbaugh
1+
# Copyright (c) 2022-2026 Ben Ashbaugh
22
#
33
# SPDX-License-Identifier: MIT
44

layers/00_example/main.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
// Copyright (c) 2022-2025 Ben Ashbaugh
2+
// Copyright (c) 2022-2026 Ben Ashbaugh
33
//
44
// SPDX-License-Identifier: MIT
55
*/
@@ -97,16 +97,17 @@ CL_API_ENTRY cl_int CL_API_CALL clGetLayerInfo(
9797
return CL_SUCCESS;
9898
}
9999

100-
CL_API_ENTRY cl_int CL_API_CALL clInitLayer(
100+
CL_API_ENTRY cl_int CL_API_CALL clInitLayerWithProperties(
101101
cl_uint num_entries,
102102
const struct _cl_icd_dispatch* target_dispatch,
103103
cl_uint* num_entries_out,
104-
const struct _cl_icd_dispatch** layer_dispatch_ret)
104+
const struct _cl_icd_dispatch** layer_dispatch_ret,
105+
const cl_layer_properties* properties)
105106
{
106107
const size_t dispatchTableSize =
107108
sizeof(dispatch) / sizeof(dispatch.clGetPlatformIDs);
108109

109-
if (target_dispatch == nullptr ||
110+
if (target_dispatch == nullptr ||
110111
num_entries_out == nullptr ||
111112
layer_dispatch_ret == nullptr) {
112113
return CL_INVALID_VALUE;
@@ -126,3 +127,16 @@ CL_API_ENTRY cl_int CL_API_CALL clInitLayer(
126127
return CL_SUCCESS;
127128
}
128129

130+
CL_API_ENTRY cl_int CL_API_CALL clInitLayer(
131+
cl_uint num_entries,
132+
const struct _cl_icd_dispatch* target_dispatch,
133+
cl_uint* num_entries_out,
134+
const struct _cl_icd_dispatch** layer_dispatch_ret)
135+
{
136+
return clInitLayerWithProperties(
137+
num_entries,
138+
target_dispatch,
139+
num_entries_out,
140+
layer_dispatch_ret,
141+
nullptr);
142+
}

0 commit comments

Comments
 (0)