Skip to content

Commit 7a96da0

Browse files
authored
add support for cl_khr_command_buffer_multi_device (#23)
1 parent 020deef commit 7a96da0

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

src/openclext.cpp

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,22 @@ typedef cl_int (CL_API_CALL* clGetCommandBufferInfoKHR_clextfn)(
315315
#pragma message("Define for cl_khr_command_buffer was not found! Please update your headers.")
316316
#endif // defined(cl_khr_command_buffer)
317317

318+
#if defined(cl_khr_command_buffer_multi_device)
319+
320+
typedef cl_command_buffer_khr (CL_API_CALL* clRemapCommandBufferKHR_clextfn)(
321+
cl_command_buffer_khr command_buffer,
322+
cl_bool automatic,
323+
cl_uint num_queues,
324+
const cl_command_queue* queues,
325+
cl_uint num_handles,
326+
const cl_mutable_command_khr* handles,
327+
cl_mutable_command_khr* handles_ret,
328+
cl_int* errcode_ret);
329+
330+
#else
331+
#pragma message("Define for cl_khr_command_buffer_multi_device was not found! Please update your headers.")
332+
#endif // defined(cl_khr_command_buffer_multi_device)
333+
318334
#if defined(cl_khr_command_buffer_mutable_dispatch)
319335

320336
typedef cl_int (CL_API_CALL* clUpdateMutableCommandsKHR_clextfn)(
@@ -1255,6 +1271,10 @@ struct openclext_dispatch_table {
12551271
clGetCommandBufferInfoKHR_clextfn clGetCommandBufferInfoKHR;
12561272
#endif // defined(cl_khr_command_buffer)
12571273

1274+
#if defined(cl_khr_command_buffer_multi_device)
1275+
clRemapCommandBufferKHR_clextfn clRemapCommandBufferKHR;
1276+
#endif // defined(cl_khr_command_buffer_multi_device)
1277+
12581278
#if defined(cl_khr_command_buffer_mutable_dispatch)
12591279
clUpdateMutableCommandsKHR_clextfn clUpdateMutableCommandsKHR;
12601280
clGetMutableCommandInfoKHR_clextfn clGetMutableCommandInfoKHR;
@@ -1517,6 +1537,10 @@ static void _init(cl_platform_id platform, openclext_dispatch_table* dispatch_pt
15171537
CLEXT_GET_EXTENSION(clGetCommandBufferInfoKHR);
15181538
#endif // defined(cl_khr_command_buffer)
15191539

1540+
#if defined(cl_khr_command_buffer_multi_device)
1541+
CLEXT_GET_EXTENSION(clRemapCommandBufferKHR);
1542+
#endif // defined(cl_khr_command_buffer_multi_device)
1543+
15201544
#if defined(cl_khr_command_buffer_mutable_dispatch)
15211545
CLEXT_GET_EXTENSION(clUpdateMutableCommandsKHR);
15221546
CLEXT_GET_EXTENSION(clGetMutableCommandInfoKHR);
@@ -2369,6 +2393,36 @@ cl_int CL_API_CALL clGetCommandBufferInfoKHR(
23692393

23702394
#endif // defined(cl_khr_command_buffer)
23712395

2396+
#if defined(cl_khr_command_buffer_multi_device)
2397+
2398+
cl_command_buffer_khr CL_API_CALL clRemapCommandBufferKHR(
2399+
cl_command_buffer_khr command_buffer,
2400+
cl_bool automatic,
2401+
cl_uint num_queues,
2402+
const cl_command_queue* queues,
2403+
cl_uint num_handles,
2404+
const cl_mutable_command_khr* handles,
2405+
cl_mutable_command_khr* handles_ret,
2406+
cl_int* errcode_ret)
2407+
{
2408+
struct openclext_dispatch_table* dispatch_ptr = _get_dispatch(command_buffer);
2409+
if (dispatch_ptr == nullptr || dispatch_ptr->clRemapCommandBufferKHR == nullptr) {
2410+
if (errcode_ret) *errcode_ret = CL_INVALID_OPERATION;
2411+
return nullptr;
2412+
}
2413+
return dispatch_ptr->clRemapCommandBufferKHR(
2414+
command_buffer,
2415+
automatic,
2416+
num_queues,
2417+
queues,
2418+
num_handles,
2419+
handles,
2420+
handles_ret,
2421+
errcode_ret);
2422+
}
2423+
2424+
#endif // defined(cl_khr_command_buffer_multi_device)
2425+
23722426
#if defined(cl_khr_command_buffer_mutable_dispatch)
23732427

23742428
cl_int CL_API_CALL clUpdateMutableCommandsKHR(

tests/call_all.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ void call_all(void)
6666
clGetCommandBufferInfoKHR(NULL, CL_COMMAND_BUFFER_REFERENCE_COUNT_KHR, 0, NULL, NULL);
6767
#endif // cl_khr_command_buffer
6868

69+
#ifdef cl_khr_command_buffer_multi_device
70+
clRemapCommandBufferKHR(NULL, CL_FALSE, 0, NULL, 0, NULL, NULL, NULL);
71+
#endif // cl_khr_command_buffer_multi_device
72+
6973
#ifdef cl_khr_command_buffer_mutable_dispatch
7074
clUpdateMutableCommandsKHR(NULL, NULL);
7175
clGetMutableCommandInfoKHR(NULL, CL_MUTABLE_COMMAND_COMMAND_BUFFER_KHR, 0, NULL, NULL);

0 commit comments

Comments
 (0)