Skip to content

Commit 542a00b

Browse files
igchorPennycook
andauthored
[SYCL][UR][L0 v2] Add a note about make_queue support (#19644)
and return an error if urQueueCreateWithNativeHandle is called with `ze_command_queue_handle_t`. V2 adapter does not support non-immediate or out-of-order command lists. Document this in the extension doc. Currently, there is no way to check whether a command-list is in order or not programatically. --------- Co-authored-by: John Pennycook <[email protected]>
1 parent 76da17b commit 542a00b

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

sycl/doc/extensions/supported/sycl_ext_oneapi_backend_level_zero.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,8 @@ If the deprecated variant of <code>backend_input_t<backend::ext_oneapi_level_zer
388388

389389
Starting in version 4 of this specification, ```make_queue()``` can be called by passing either a Level Zero ```ze_command_queue_handle_t``` or a Level Zero ```ze_command_list_handle_t```. Queues created from a Level Zero immediate command list (```ze_command_list_handle_t```) generally perform better than queues created from a standard Level Zero ```ze_command_queue_handle_t```. See the Level Zero documentation of these native handles for more details. Also starting in version 4 the ```make_queue()``` function accepts a ```Properties``` member variable. This can contain any of the SYCL properties that are accepted by the SYCL queue constructor, except
390390
the ```compute_index``` property which is built into the command queue or command list.
391+
392+
**Warning:** <span style="color:red"> When using the L0 v2 adapter, ```make_queue()``` only accepts ```ze_command_list_handle_t```. The command list has to be in-order. Passing an out-of-order command list is undefined behavior. The L0 v2 adapter is always used when running on platforms with GPUs based on the Xe2 architecture or later, such as Battlemage, Lunar Lake, and Arrow Lake. Applications may also opt-in to the L0 v2 adapter using the `SYCL_UR_USE_LEVEL_ZERO_V2` environment variable. </span>
391393
</td>
392394
</tr><tr>
393395
<td>

unified-runtime/source/adapters/level_zero/v2/queue_create.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ ur_result_t urQueueCreateWithNativeHandle(
9494

9595
bool ownNativeHandle = pProperties ? pProperties->isNativeHandleOwned : false;
9696
ur_queue_flags_t flags = 0;
97+
bool isNativeHandleImmediate = true;
9798

9899
if (pProperties) {
99100
void *pNext = pProperties->pNext;
@@ -104,11 +105,30 @@ ur_result_t urQueueCreateWithNativeHandle(
104105
const ur_queue_properties_t *pUrProperties =
105106
reinterpret_cast<const ur_queue_properties_t *>(extendedProperties);
106107
flags = pUrProperties->flags;
108+
} else if (extendedProperties->stype ==
109+
UR_STRUCTURE_TYPE_QUEUE_NATIVE_DESC) {
110+
const ur_queue_native_desc_t *pUrNativeDesc =
111+
reinterpret_cast<const ur_queue_native_desc_t *>(
112+
extendedProperties);
113+
if (pUrNativeDesc->pNativeData) {
114+
// The pNativeData has value if if the native handle is an immediate
115+
// command list.
116+
isNativeHandleImmediate =
117+
*(reinterpret_cast<int32_t *>((pUrNativeDesc->pNativeData))) == 1;
118+
}
107119
}
108120
pNext = extendedProperties->pNext;
109121
}
110122
}
111123

124+
if (!isNativeHandleImmediate) {
125+
UR_LOG(ERR, "urQueueCreateWithNativeHandle: "
126+
"Native handle is not an immediate command "
127+
"list; only immediate command lists are "
128+
"supported.");
129+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
130+
}
131+
112132
ze_bool_t isImmediate = false;
113133
ZE2UR_CALL(
114134
zeCommandListIsImmediate,

0 commit comments

Comments
 (0)