Skip to content

Commit 4ed8534

Browse files
authored
[SYCL][Graph][OpenCL] Map copy/fill to SVM (#18177)
There is currently no cl_khr_command_buffer or cl_intel_unified_shared_memory entry-point for appending USM copy or fill commands to a command-buffer. This prevents these commands from being added to a graph for the OpenCL backend. The long term solution to this is the OpenCL USVM extension which will align USM and SVM, allowing the existing SVM entry-points to be used. To prepare for this, map the UR entry-points to the cl_khr_command_buffer SVM copy/fill commands. This will work on OpenCL implementations that share an implementation for USM and SVM. Signed-off-by: Ewan Crawford <[email protected]>
1 parent b07a0cf commit 4ed8534

27 files changed

+96
-114
lines changed

sycl/doc/design/CommandGraph.md

+10-8
Original file line numberDiff line numberDiff line change
@@ -626,8 +626,8 @@ adapter where there is matching support for each function in the list.
626626
| urCommandBufferReleaseExp | clReleaseCommandBufferKHR | Yes |
627627
| urCommandBufferFinalizeExp | clFinalizeCommandBufferKHR | Yes |
628628
| urCommandBufferAppendKernelLaunchExp | clCommandNDRangeKernelKHR | Yes |
629-
| urCommandBufferAppendUSMMemcpyExp | | No |
630-
| urCommandBufferAppendUSMFillExp | | No |
629+
| urCommandBufferAppendUSMMemcpyExp | clCommandSVMMemcpyKHR | Partial, [see below](#unsupported-command-types) |
630+
| urCommandBufferAppendUSMFillExp | clCommandSVMMemFillKHR | Partial, [see below](#unsupported-command-types) |
631631
| urCommandBufferAppendMembufferCopyExp | clCommandCopyBufferKHR | Yes |
632632
| urCommandBufferAppendMemBufferWriteExp | | No |
633633
| urCommandBufferAppendMemBufferReadExp | | No |
@@ -643,8 +643,6 @@ adapter where there is matching support for each function in the list.
643643
| | clCommandCopyImageToBufferKHR | No |
644644
| | clCommandFillImageKHR | No |
645645
| | clGetCommandBufferInfoKHR | No |
646-
| | clCommandSVMMemcpyKHR | No |
647-
| | clCommandSVMMemFillKHR | No |
648646
| urCommandBufferUpdateKernelLaunchExp | clUpdateMutableCommandsKHR | Partial [See Update Section](#update-support) |
649647

650648
We are looking to address these gaps in the future so that SYCL-Graph can be
@@ -664,17 +662,21 @@ terminate called after throwing an instance of 'sycl::_V1::exception'
664662
what(): USM copy command not supported by graph backend
665663
```
666664

667-
The types of commands which are unsupported, and lead to this exception are:
665+
The types of commands which are unsupported, and may lead to this exception are:
668666
* `handler::copy(src, dest)` - Where `src` is an accessor and `dest` is a pointer.
669667
This corresponds to a memory buffer read command.
670668
* `handler::copy(src, dest)` - Where `src` is an pointer and `dest` is an accessor.
671669
This corresponds to a memory buffer write command.
672670
* `handler::copy(src, dest)` or `handler::memcpy(dest, src)` - Where both `src` and
673-
`dest` are USM pointers. This corresponds to a USM copy command.
671+
`dest` are USM pointers. This corresponds to a USM copy command that is
672+
mapped to `clCommandSVMMemcpyKHR`, which will only work on OpenCL devices
673+
which don't differentiate between USM and SVM.
674674
* `handler::fill(ptr, pattern, count)` - This corresponds to a USM memory
675-
fill command.
675+
fill command that is mapped to `clCommandSVMMemFillKHR`, which will only work
676+
on OpenCL devices which don't differentiate between USM and SVM.
676677
* `handler::memset(ptr, value, numBytes)` - This corresponds to a USM memory
677-
fill command.
678+
fill command that is mapped to `clCommandSVMMemFillKHR`, which will only work
679+
on OpenCL devices which don't differentiate between USM and SVM.
678680
* `handler::prefetch()`.
679681
* `handler::mem_advise()`.
680682

sycl/source/detail/memory_manager.cpp

+11-3
Original file line numberDiff line numberDiff line change
@@ -1567,9 +1567,17 @@ void MemoryManager::ext_oneapi_fill_usm_cmd_buffer(
15671567
"NULL pointer argument in memory fill operation.");
15681568

15691569
const AdapterPtr &Adapter = Context->getAdapter();
1570-
Adapter->call<UrApiKind::urCommandBufferAppendUSMFillExp>(
1571-
CommandBuffer, DstMem, Pattern.data(), Pattern.size(), Len, Deps.size(),
1572-
Deps.data(), 0, nullptr, OutSyncPoint, nullptr, nullptr);
1570+
ur_result_t Result =
1571+
Adapter->call_nocheck<UrApiKind::urCommandBufferAppendUSMFillExp>(
1572+
CommandBuffer, DstMem, Pattern.data(), Pattern.size(), Len,
1573+
Deps.size(), Deps.data(), 0, nullptr, OutSyncPoint, nullptr, nullptr);
1574+
if (Result == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) {
1575+
throw sycl::exception(
1576+
sycl::make_error_code(sycl::errc::feature_not_supported),
1577+
"USM fill command not supported by graph backend");
1578+
} else {
1579+
Adapter->checkUrResult(Result);
1580+
}
15731581
}
15741582

15751583
void MemoryManager::ext_oneapi_fill_cmd_buffer(

sycl/test-e2e/Graph/Explicit/usm_copy.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
// RUN: %if level_zero %{env SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS=0 %{l0_leak_check} %{run} %t.out 2>&1 | FileCheck %s --implicit-check-not=LEAK %}
55
// Extra run to check for immediate-command-list in Level Zero
66
// RUN: %if level_zero %{env SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS=1 %{l0_leak_check} %{run} %t.out 2>&1 | FileCheck %s --implicit-check-not=LEAK %}
7-
//
8-
//
9-
// Intended - USM copy command not supported for OpenCL
10-
// UNSUPPORTED: opencl
117

128
#define GRAPH_E2E_EXPLICIT
139

sycl/test-e2e/Graph/Explicit/usm_fill.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
// RUN: %if level_zero %{env SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS=0 %{l0_leak_check} %{run} %t.out 2>&1 | FileCheck %s --implicit-check-not=LEAK %}
55
// Extra run to check for immediate-command-list in Level Zero
66
// RUN: %if level_zero %{env SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS=1 %{l0_leak_check} %{run} %t.out 2>&1 | FileCheck %s --implicit-check-not=LEAK %}
7-
//
8-
// Intended - USM fill command not supported for OpenCL
9-
// UNSUPPORTED: opencl
107

118
#define GRAPH_E2E_EXPLICIT
129

sycl/test-e2e/Graph/Explicit/usm_fill_host.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77

88
// REQUIRES: aspect-usm_host_allocations
99

10-
// Intended - USM fill command not supported for OpenCL
11-
// UNSUPPORTED: opencl
12-
1310
#define GRAPH_E2E_EXPLICIT
1411

1512
#include "../Inputs/usm_fill_host.cpp"

sycl/test-e2e/Graph/Explicit/usm_fill_shared.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77

88
// REQUIRES: aspect-usm_shared_allocations
99

10-
// Intended - USM fill command not supported for OpenCL
11-
// UNSUPPORTED: opencl
12-
1310
#define GRAPH_E2E_EXPLICIT
1411

1512
#include "../Inputs/usm_fill_shared.cpp"

sycl/test-e2e/Graph/Explicit/usm_memset.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
// Extra run to check for immediate-command-list in Level Zero
66
// RUN: %if level_zero %{env SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS=1 %{l0_leak_check} %{run} %t.out 2>&1 | FileCheck %s --implicit-check-not=LEAK %}
77

8-
// Intended - USM memset command not supported for OpenCL
9-
// UNSUPPORTED: opencl
10-
118
#define GRAPH_E2E_EXPLICIT
129

1310
#include "../Inputs/usm_memset.cpp"

sycl/test-e2e/Graph/RecordReplay/barrier_multi_graph.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
// RUN: %if level_zero %{env SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS=0 %{l0_leak_check} %{run} %t.out 2>&1 | FileCheck %s --implicit-check-not=LEAK %}
55
// Extra run to check for immediate-command-list in Level Zero
66
// RUN: %if level_zero %{env SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS=1 %{l0_leak_check} %{run} %t.out 2>&1 | FileCheck %s --implicit-check-not=LEAK %}
7-
//
8-
// UNSUPPORTED: opencl
9-
// UNSUPPORTED-INTENDED: USM memcpy command not supported for OpenCL
107

118
#include "../graph_common.hpp"
129

sycl/test-e2e/Graph/RecordReplay/barrier_multi_queue.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
// RUN: %if level_zero %{env SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS=0 %{l0_leak_check} %{run} %t.out 2>&1 | FileCheck %s --implicit-check-not=LEAK %}
55
// Extra run to check for immediate-command-list in Level Zero
66
// RUN: %if level_zero %{env SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS=1 %{l0_leak_check} %{run} %t.out 2>&1 | FileCheck %s --implicit-check-not=LEAK %}
7-
//
8-
// UNSUPPORTED: opencl
9-
// UNSUPPORTED-INTENDED: USM memcpy command not supported for OpenCL
107

118
#include "../graph_common.hpp"
129

sycl/test-e2e/Graph/RecordReplay/ext_oneapi_enqueue_functions.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77

88
// Tests the enqueue free function kernel shortcuts.
99

10-
// UNSUPPORTED: opencl
11-
// UNSUPPORTED-INTENDED: USM memcpy command not supported for OpenCL
12-
1310
#include "../graph_common.hpp"
1411
#include <sycl/ext/oneapi/experimental/enqueue_functions.hpp>
1512
#include <sycl/properties/all_properties.hpp>

sycl/test-e2e/Graph/RecordReplay/ext_oneapi_enqueue_functions_submit_with_event.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
// Tests the enqueue free function using USM and submit_with_event for
99
// dependencies
1010

11-
// UNSUPPORTED: opencl
12-
// UNSUPPORTED-INTENDED: USM memcpy command not supported for OpenCL
13-
1411
#include "../graph_common.hpp"
1512
#include <sycl/ext/oneapi/experimental/enqueue_functions.hpp>
1613

sycl/test-e2e/Graph/RecordReplay/transitive_queue_barrier.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
// event is passed as a dependency to a barrier operation in a different
1010
// in-order queue.
1111

12-
// UNSUPPORTED: opencl
13-
// UNSUPPORTED-INTENDED: USM fill command not supported for OpenCL
14-
1512
#include "../graph_common.hpp"
1613
#include <sycl/properties/all_properties.hpp>
1714

sycl/test-e2e/Graph/RecordReplay/usm_copy.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
// RUN: %if level_zero %{env SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS=0 %{l0_leak_check} %{run} %t.out 2>&1 | FileCheck %s --implicit-check-not=LEAK %}
55
// Extra run to check for immediate-command-list in Level Zero
66
// RUN: %if level_zero %{env SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS=1 %{l0_leak_check} %{run} %t.out 2>&1 | FileCheck %s --implicit-check-not=LEAK %}
7-
//
8-
// Intended - USM copy command not supported for OpenCL
9-
// UNSUPPORTED: opencl
107

118
#define GRAPH_E2E_RECORD_REPLAY
129

sycl/test-e2e/Graph/RecordReplay/usm_copy_in_order.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
// RUN: %if level_zero %{env SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS=0 %{l0_leak_check} %{run} %t.out 2>&1 | FileCheck %s --implicit-check-not=LEAK %}
55
// Extra run to check for immediate-command-list in Level Zero
66
// RUN: %if level_zero %{env SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS=1 %{l0_leak_check} %{run} %t.out 2>&1 | FileCheck %s --implicit-check-not=LEAK %}
7-
//
8-
//
9-
// Intended - USM copy command not supported for OpenCL
10-
// UNSUPPORTED: opencl
117

128
// Tests memcpy operation using device USM and an in-order queue.
139

sycl/test-e2e/Graph/RecordReplay/usm_fill.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
// RUN: %if level_zero %{env SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS=0 %{l0_leak_check} %{run} %t.out 2>&1 | FileCheck %s --implicit-check-not=LEAK %}
55
// Extra run to check for immediate-command-list in Level Zero
66
// RUN: %if level_zero %{env SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS=1 %{l0_leak_check} %{run} %t.out 2>&1 | FileCheck %s --implicit-check-not=LEAK %}
7-
//
8-
// Intended - USM fill command not supported for OpenCL
9-
// UNSUPPORTED: opencl
107

118
#define GRAPH_E2E_RECORD_REPLAY
129

sycl/test-e2e/Graph/RecordReplay/usm_fill_host.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77

88
// REQUIRES: aspect-usm_host_allocations
99

10-
// Intended - USM fill command not supported for OpenCL
11-
// UNSUPPORTED: opencl
12-
1310
#define GRAPH_E2E_RECORD_REPLAY
1411

1512
#include "../Inputs/usm_fill_host.cpp"

sycl/test-e2e/Graph/RecordReplay/usm_fill_shared.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77

88
// REQUIRES: aspect-usm_shared_allocations
99

10-
// Intended - USM fill command not supported for OpenCL
11-
// UNSUPPORTED: opencl
12-
1310
#define GRAPH_E2E_RECORD_REPLAY
1411

1512
#include "../Inputs/usm_fill_shared.cpp"

sycl/test-e2e/Graph/RecordReplay/usm_memset.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
// Extra run to check for immediate-command-list in Level Zero
66
// RUN: %if level_zero %{env SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS=1 %{l0_leak_check} %{run} %t.out 2>&1 | FileCheck %s --implicit-check-not=LEAK %}
77

8-
// Intended - USM memset command not supported for OpenCL
9-
// UNSUPPORTED: opencl
10-
118
#define GRAPH_E2E_RECORD_REPLAY
129

1310
#include "../Inputs/usm_memset.cpp"

sycl/test-e2e/Graph/RecordReplay/usm_memset_shortcut.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
// Extra run to check for leaks in Level Zero using UR_L0_LEAKS_DEBUG
44
// RUN: %if level_zero %{ %{l0_leak_check} %{run} %t.out 2>&1 | FileCheck %s --implicit-check-not=LEAK %}
55
//
6-
// Intended - USM fill command not supported for OpenCL
7-
// UNSUPPORTED: opencl
8-
//
96
// Tests adding a USM memset queue shortcut operation as a graph node.
107

118
#include "../graph_common.hpp"

sycl/test-e2e/Graph/ValidUsage/linear_graph_copy.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
// Tests that the optimization to use the L0 Copy Engine for memory commands
1313
// does not interfere with the linear graph optimization
1414

15-
// UNSUPPORTED: opencl
16-
// UNSUPPORTED-INTENDED: USM memcpy command not supported for OpenCL
17-
1815
#include "../graph_common.hpp"
1916

2017
#include <sycl/properties/queue_properties.hpp>

sycl/test-e2e/Graph/ValidUsage/linear_graph_copy_D2H.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
// does not interfere with the linear graph optimization
1414
//
1515
// REQUIRES: aspect-usm_host_allocations
16-
// UNSUPPORTED: opencl
17-
// UNSUPPORTED-INTENDED: USM memcpy command not supported for OpenCL
1816

1917
#include "../graph_common.hpp"
2018

sycl/test/e2e_test_requirements/no-unsupported-without-info.cpp

+1-13
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
// tests to match the required format and in that case you should just update
5555
// (i.e. reduce) the number and the list below.
5656
//
57-
// NUMBER-OF-UNSUPPORTED-WITHOUT-INFO: 273
57+
// NUMBER-OF-UNSUPPORTED-WITHOUT-INFO: 261
5858
//
5959
// List of improperly UNSUPPORTED tests.
6060
// Remove the CHECK once the test has been properly UNSUPPORTED.
@@ -165,11 +165,6 @@
165165
// CHECK-NEXT: Graph/Explicit/prefetch.cpp
166166
// CHECK-NEXT: Graph/Explicit/spec_constants_handler_api.cpp
167167
// CHECK-NEXT: Graph/Explicit/spec_constants_kernel_bundle_api.cpp
168-
// CHECK-NEXT: Graph/Explicit/usm_copy.cpp
169-
// CHECK-NEXT: Graph/Explicit/usm_fill.cpp
170-
// CHECK-NEXT: Graph/Explicit/usm_fill_host.cpp
171-
// CHECK-NEXT: Graph/Explicit/usm_fill_shared.cpp
172-
// CHECK-NEXT: Graph/Explicit/usm_memset.cpp
173168
// CHECK-NEXT: Graph/Explicit/work_group_size_prop.cpp
174169
// CHECK-NEXT: Graph/RecordReplay/buffer_copy_host2target.cpp
175170
// CHECK-NEXT: Graph/RecordReplay/buffer_copy_host2target_2d.cpp
@@ -185,13 +180,6 @@
185180
// CHECK-NEXT: Graph/RecordReplay/prefetch.cpp
186181
// CHECK-NEXT: Graph/RecordReplay/spec_constants_handler_api.cpp
187182
// CHECK-NEXT: Graph/RecordReplay/spec_constants_kernel_bundle_api.cpp
188-
// CHECK-NEXT: Graph/RecordReplay/usm_copy.cpp
189-
// CHECK-NEXT: Graph/RecordReplay/usm_copy_in_order.cpp
190-
// CHECK-NEXT: Graph/RecordReplay/usm_fill.cpp
191-
// CHECK-NEXT: Graph/RecordReplay/usm_fill_host.cpp
192-
// CHECK-NEXT: Graph/RecordReplay/usm_fill_shared.cpp
193-
// CHECK-NEXT: Graph/RecordReplay/usm_memset.cpp
194-
// CHECK-NEXT: Graph/RecordReplay/usm_memset_shortcut.cpp
195183
// CHECK-NEXT: Graph/RecordReplay/work_group_size_prop.cpp
196184
// CHECK-NEXT: Graph/UnsupportedDevice/device_query.cpp
197185
// CHECK-NEXT: GroupAlgorithm/SYCL2020/reduce_over_group_size.cpp

unified-runtime/source/adapters/opencl/command_buffer.cpp

+50-24
Original file line numberDiff line numberDiff line change
@@ -204,33 +204,59 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendKernelLaunchExp(
204204
}
205205

206206
UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendUSMMemcpyExp(
207-
[[maybe_unused]] ur_exp_command_buffer_handle_t hCommandBuffer,
208-
[[maybe_unused]] void *pDst, [[maybe_unused]] const void *pSrc,
209-
[[maybe_unused]] size_t size,
210-
[[maybe_unused]] uint32_t numSyncPointsInWaitList,
211-
[[maybe_unused]] const ur_exp_command_buffer_sync_point_t
212-
*pSyncPointWaitList,
213-
[[maybe_unused]] uint32_t numEventsInWaitList,
214-
[[maybe_unused]] const ur_event_handle_t *phEventWaitList,
215-
[[maybe_unused]] ur_exp_command_buffer_sync_point_t *pSyncPoint,
216-
[[maybe_unused]] ur_event_handle_t *phEvent,
217-
[[maybe_unused]] ur_exp_command_buffer_command_handle_t *phCommand) {
218-
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
207+
ur_exp_command_buffer_handle_t hCommandBuffer, void *pDst, const void *pSrc,
208+
size_t size, uint32_t numSyncPointsInWaitList,
209+
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, uint32_t,
210+
const ur_event_handle_t *, ur_exp_command_buffer_sync_point_t *pSyncPoint,
211+
ur_event_handle_t *, ur_exp_command_buffer_command_handle_t *) {
212+
// No extension entry-point exists for USM memcpy, use SVM memcpy in
213+
// preparation for USVM.
214+
cl_context CLContext = hCommandBuffer->hContext->CLContext;
215+
cl_ext::clCommandSVMMemcpyKHR_fn clCommandSVMMemcpyKHR = nullptr;
216+
UR_RETURN_ON_FAILURE(
217+
cl_ext::getExtFuncFromContext<decltype(clCommandSVMMemcpyKHR)>(
218+
CLContext, ur::cl::getAdapter()->fnCache.clCommandSVMMemcpyKHRCache,
219+
cl_ext::CommandSVMMemcpyName, &clCommandSVMMemcpyKHR));
220+
221+
const bool IsInOrder = hCommandBuffer->IsInOrder;
222+
cl_sync_point_khr *RetSyncPoint = IsInOrder ? nullptr : pSyncPoint;
223+
const cl_sync_point_khr *SyncPointWaitList =
224+
IsInOrder ? nullptr : pSyncPointWaitList;
225+
uint32_t WaitListSize = IsInOrder ? 0 : numSyncPointsInWaitList;
226+
CL_RETURN_ON_FAILURE(clCommandSVMMemcpyKHR(
227+
hCommandBuffer->CLCommandBuffer, nullptr, nullptr, pDst, pSrc, size,
228+
WaitListSize, SyncPointWaitList, RetSyncPoint, nullptr));
229+
230+
return UR_RESULT_SUCCESS;
219231
}
220232

221233
UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendUSMFillExp(
222-
[[maybe_unused]] ur_exp_command_buffer_handle_t hCommandBuffer,
223-
[[maybe_unused]] void *pMemory, [[maybe_unused]] const void *pPattern,
224-
[[maybe_unused]] size_t patternSize, [[maybe_unused]] size_t size,
225-
[[maybe_unused]] uint32_t numSyncPointsInWaitList,
226-
[[maybe_unused]] const ur_exp_command_buffer_sync_point_t
227-
*pSyncPointWaitList,
228-
[[maybe_unused]] uint32_t numEventsInWaitList,
229-
[[maybe_unused]] const ur_event_handle_t *phEventWaitList,
230-
[[maybe_unused]] ur_exp_command_buffer_sync_point_t *pSyncPoint,
231-
[[maybe_unused]] ur_event_handle_t *phEvent,
232-
[[maybe_unused]] ur_exp_command_buffer_command_handle_t *phCommand) {
233-
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
234+
ur_exp_command_buffer_handle_t hCommandBuffer, void *pMemory,
235+
const void *pPattern, size_t patternSize, size_t size,
236+
uint32_t numSyncPointsInWaitList,
237+
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, uint32_t,
238+
const ur_event_handle_t *, ur_exp_command_buffer_sync_point_t *pSyncPoint,
239+
ur_event_handle_t *, ur_exp_command_buffer_command_handle_t *) {
240+
// No extension entry-point exists for USM fill, use SVM fill in preparation
241+
// for USVM.
242+
cl_context CLContext = hCommandBuffer->hContext->CLContext;
243+
cl_ext::clCommandSVMMemFillKHR_fn clCommandSVMMemFillKHR = nullptr;
244+
UR_RETURN_ON_FAILURE(
245+
cl_ext::getExtFuncFromContext<decltype(clCommandSVMMemFillKHR)>(
246+
CLContext, ur::cl::getAdapter()->fnCache.clCommandSVMMemFillKHRCache,
247+
cl_ext::CommandSVMMemFillName, &clCommandSVMMemFillKHR));
248+
249+
const bool IsInOrder = hCommandBuffer->IsInOrder;
250+
cl_sync_point_khr *RetSyncPoint = IsInOrder ? nullptr : pSyncPoint;
251+
const cl_sync_point_khr *SyncPointWaitList =
252+
IsInOrder ? nullptr : pSyncPointWaitList;
253+
uint32_t WaitListSize = IsInOrder ? 0 : numSyncPointsInWaitList;
254+
CL_RETURN_ON_FAILURE(
255+
clCommandSVMMemFillKHR(hCommandBuffer->CLCommandBuffer, nullptr, nullptr,
256+
pMemory, pPattern, patternSize, size, WaitListSize,
257+
SyncPointWaitList, RetSyncPoint, nullptr));
258+
259+
return UR_RESULT_SUCCESS;
234260
}
235261

236262
UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendMemBufferCopyExp(

0 commit comments

Comments
 (0)