Skip to content

Commit 762eb9f

Browse files
committed
Reflect upstream OpenCL command-buffer API changes
Update OpenCL adapter code to reflect the 2 API breaking changes to the command-buffer family of extensions that have been made upstream: * [Add properties parameter to all command-buffer commands](KhronosGroup/OpenCL-Headers#260) * [Use array for clUpdateMutableCommandsKHR](KhronosGroup/OpenCL-Headers#245)
1 parent ad43e28 commit 762eb9f

File tree

3 files changed

+32
-28
lines changed

3 files changed

+32
-28
lines changed

source/adapters/opencl/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ if(UR_OPENCL_INCLUDE_DIR)
5454
else()
5555
FetchContent_Declare(OpenCL-Headers
5656
GIT_REPOSITORY "https://github.com/KhronosGroup/OpenCL-Headers.git"
57-
GIT_TAG 1e193332d02e27e15812d24ff2a3a7a908eb92a3
57+
GIT_TAG 542d7a8f65ecfd88b38de35d8b10aa67b36b33b2
5858
)
5959
FetchContent_MakeAvailable(OpenCL-Headers)
6060
FetchContent_GetProperties(OpenCL-Headers

source/adapters/opencl/command_buffer.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,15 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendKernelLaunchExp(
156156
cl_mutable_command_khr *OutCommandHandle =
157157
hCommandBuffer->IsUpdatable ? &CommandHandle : nullptr;
158158

159-
cl_ndrange_kernel_command_properties_khr UpdateProperties[] = {
159+
cl_command_properties_khr UpdateProperties[] = {
160160
CL_MUTABLE_DISPATCH_UPDATABLE_FIELDS_KHR,
161161
CL_MUTABLE_DISPATCH_GLOBAL_OFFSET_KHR |
162162
CL_MUTABLE_DISPATCH_GLOBAL_SIZE_KHR |
163163
CL_MUTABLE_DISPATCH_LOCAL_SIZE_KHR |
164164
CL_MUTABLE_DISPATCH_ARGUMENTS_KHR | CL_MUTABLE_DISPATCH_EXEC_INFO_KHR,
165165
0};
166166

167-
cl_ndrange_kernel_command_properties_khr *Properties =
167+
cl_command_properties_khr *Properties =
168168
hCommandBuffer->IsUpdatable ? UpdateProperties : nullptr;
169169
CL_RETURN_ON_FAILURE(clCommandNDRangeKernelKHR(
170170
hCommandBuffer->CLCommandBuffer, nullptr, Properties,
@@ -176,8 +176,11 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendKernelLaunchExp(
176176
auto URCommandHandle =
177177
std::make_unique<ur_exp_command_buffer_command_handle_t_>(
178178
hCommandBuffer, CommandHandle, workDim, pLocalWorkSize != nullptr);
179-
*phCommandHandle = URCommandHandle.release();
180-
hCommandBuffer->CommandHandles.push_back(*phCommandHandle);
179+
ur_exp_command_buffer_command_handle_t Handle = URCommandHandle.release();
180+
hCommandBuffer->CommandHandles.push_back(Handle);
181+
if (phCommandHandle) {
182+
*phCommandHandle = Handle;
183+
}
181184
} catch (...) {
182185
return UR_RESULT_ERROR_OUT_OF_RESOURCES;
183186
}
@@ -222,7 +225,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendMemBufferCopyExp(
222225
cl_ext::CommandCopyBufferName, &clCommandCopyBufferKHR));
223226

224227
CL_RETURN_ON_FAILURE(clCommandCopyBufferKHR(
225-
hCommandBuffer->CLCommandBuffer, nullptr,
228+
hCommandBuffer->CLCommandBuffer, nullptr, nullptr,
226229
cl_adapter::cast<cl_mem>(hSrcMem), cl_adapter::cast<cl_mem>(hDstMem),
227230
srcOffset, dstOffset, size, numSyncPointsInWaitList, pSyncPointWaitList,
228231
pSyncPoint, nullptr));
@@ -256,7 +259,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendMemBufferCopyRectExp(
256259
cl_ext::CommandCopyBufferRectName, &clCommandCopyBufferRectKHR));
257260

258261
CL_RETURN_ON_FAILURE(clCommandCopyBufferRectKHR(
259-
hCommandBuffer->CLCommandBuffer, nullptr,
262+
hCommandBuffer->CLCommandBuffer, nullptr, nullptr,
260263
cl_adapter::cast<cl_mem>(hSrcMem), cl_adapter::cast<cl_mem>(hDstMem),
261264
OpenCLOriginRect, OpenCLDstRect, OpenCLRegion, srcRowPitch, srcSlicePitch,
262265
dstRowPitch, dstSlicePitch, numSyncPointsInWaitList, pSyncPointWaitList,
@@ -274,9 +277,6 @@ ur_result_t UR_APICALL urCommandBufferAppendMemBufferWriteExp(
274277
[[maybe_unused]] const ur_exp_command_buffer_sync_point_t
275278
*pSyncPointWaitList,
276279
[[maybe_unused]] ur_exp_command_buffer_sync_point_t *pSyncPoint) {
277-
278-
cl_adapter::die("Experimental Command-buffer feature is not "
279-
"implemented for OpenCL adapter.");
280280
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
281281
}
282282

@@ -343,7 +343,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendMemBufferFillExp(
343343
cl_ext::CommandFillBufferName, &clCommandFillBufferKHR));
344344

345345
CL_RETURN_ON_FAILURE(clCommandFillBufferKHR(
346-
hCommandBuffer->CLCommandBuffer, nullptr,
346+
hCommandBuffer->CLCommandBuffer, nullptr, nullptr,
347347
cl_adapter::cast<cl_mem>(hBuffer), pPattern, patternSize, offset, size,
348348
numSyncPointsInWaitList, pSyncPointWaitList, pSyncPoint, nullptr));
349349

@@ -556,8 +556,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferUpdateKernelLaunchExp(
556556
cl_mutable_command_khr command =
557557
cl_adapter::cast<cl_mutable_command_khr>(hCommand->CLMutableCommand);
558558
cl_mutable_dispatch_config_khr dispatch_config = {
559-
CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR,
560-
nullptr,
561559
command,
562560
static_cast<cl_uint>(CLArgs.size()), // num_args
563561
static_cast<cl_uint>(CLUSMArgs.size()), // num_svm_args
@@ -570,10 +568,12 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferUpdateKernelLaunchExp(
570568
CLGlobalWorkSize.data(), // global_work_size
571569
CLLocalWorkSize.data(), // local_work_size
572570
};
573-
cl_mutable_base_config_khr config = {
574-
CL_STRUCTURE_TYPE_MUTABLE_BASE_CONFIG_KHR, nullptr, 1, &dispatch_config};
575-
CL_RETURN_ON_FAILURE(
576-
clUpdateMutableCommandsKHR(hCommandBuffer->CLCommandBuffer, &config));
571+
cl_uint num_configs = 1;
572+
cl_command_buffer_update_type_khr config_types[1] = {
573+
CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR};
574+
const void *configs[1] = {&dispatch_config};
575+
CL_RETURN_ON_FAILURE(clUpdateMutableCommandsKHR(
576+
hCommandBuffer->CLCommandBuffer, num_configs, config_types, configs));
577577

578578
return UR_RESULT_SUCCESS;
579579
}

source/adapters/opencl/common.hpp

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -272,33 +272,36 @@ cl_int(CL_API_CALL *)(cl_command_buffer_khr command_buffer);
272272

273273
using clCommandNDRangeKernelKHR_fn = CL_API_ENTRY cl_int(CL_API_CALL *)(
274274
cl_command_buffer_khr command_buffer, cl_command_queue command_queue,
275-
const cl_ndrange_kernel_command_properties_khr *properties,
276-
cl_kernel kernel, cl_uint work_dim, const size_t *global_work_offset,
275+
const cl_command_properties_khr *properties, cl_kernel kernel,
276+
cl_uint work_dim, const size_t *global_work_offset,
277277
const size_t *global_work_size, const size_t *local_work_size,
278278
cl_uint num_sync_points_in_wait_list,
279279
const cl_sync_point_khr *sync_point_wait_list,
280280
cl_sync_point_khr *sync_point, cl_mutable_command_khr *mutable_handle);
281281

282282
using clCommandCopyBufferKHR_fn = CL_API_ENTRY cl_int(CL_API_CALL *)(
283283
cl_command_buffer_khr command_buffer, cl_command_queue command_queue,
284-
cl_mem src_buffer, cl_mem dst_buffer, size_t src_offset, size_t dst_offset,
285-
size_t size, cl_uint num_sync_points_in_wait_list,
284+
const cl_command_properties_khr *properties, cl_mem src_buffer,
285+
cl_mem dst_buffer, size_t src_offset, size_t dst_offset, size_t size,
286+
cl_uint num_sync_points_in_wait_list,
286287
const cl_sync_point_khr *sync_point_wait_list,
287288
cl_sync_point_khr *sync_point, cl_mutable_command_khr *mutable_handle);
288289

289290
using clCommandCopyBufferRectKHR_fn = CL_API_ENTRY cl_int(CL_API_CALL *)(
290291
cl_command_buffer_khr command_buffer, cl_command_queue command_queue,
291-
cl_mem src_buffer, cl_mem dst_buffer, const size_t *src_origin,
292-
const size_t *dst_origin, const size_t *region, size_t src_row_pitch,
293-
size_t src_slice_pitch, size_t dst_row_pitch, size_t dst_slice_pitch,
292+
const cl_command_properties_khr *properties, cl_mem src_buffer,
293+
cl_mem dst_buffer, const size_t *src_origin, const size_t *dst_origin,
294+
const size_t *region, size_t src_row_pitch, size_t src_slice_pitch,
295+
size_t dst_row_pitch, size_t dst_slice_pitch,
294296
cl_uint num_sync_points_in_wait_list,
295297
const cl_sync_point_khr *sync_point_wait_list,
296298
cl_sync_point_khr *sync_point, cl_mutable_command_khr *mutable_handle);
297299

298300
using clCommandFillBufferKHR_fn = CL_API_ENTRY cl_int(CL_API_CALL *)(
299301
cl_command_buffer_khr command_buffer, cl_command_queue command_queue,
300-
cl_mem buffer, const void *pattern, size_t pattern_size, size_t offset,
301-
size_t size, cl_uint num_sync_points_in_wait_list,
302+
const cl_command_properties_khr *properties, cl_mem buffer,
303+
const void *pattern, size_t pattern_size, size_t offset, size_t size,
304+
cl_uint num_sync_points_in_wait_list,
302305
const cl_sync_point_khr *sync_point_wait_list,
303306
cl_sync_point_khr *sync_point, cl_mutable_command_khr *mutable_handle);
304307

@@ -313,8 +316,9 @@ using clGetCommandBufferInfoKHR_fn = CL_API_ENTRY cl_int(CL_API_CALL *)(
313316
size_t param_value_size, void *param_value, size_t *param_value_size_ret);
314317

315318
using clUpdateMutableCommandsKHR_fn = CL_API_ENTRY
316-
cl_int(CL_API_CALL *)(cl_command_buffer_khr command_buffer,
317-
const cl_mutable_base_config_khr *mutable_config);
319+
cl_int(CL_API_CALL *)(cl_command_buffer_khr command_buffer, cl_uint num_configs,
320+
const cl_command_buffer_update_type_khr *config_types,
321+
const void **configs);
318322

319323
template <typename T> struct FuncPtrCache {
320324
std::map<cl_context, T> Map;

0 commit comments

Comments
 (0)