Skip to content

Commit a1c10ba

Browse files
committed
[UR][L0] Enable support for using L0 spec External Semaphores
Signed-off-by: Neil R. Spruit <[email protected]>
1 parent ba85a4c commit a1c10ba

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

unified-runtime/source/adapters/level_zero/platform.cpp

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ ur_result_t ur_platform_handle_t_::initialize() {
227227

228228
bool MutableCommandListSpecExtensionSupported = false;
229229
bool ZeIntelExternalSemaphoreExtensionSupported = false;
230+
bool ZeExternalSemaphoreExtensionSupported = false;
230231
bool ZeImmediateCommandListAppendExtensionFound = false;
231232
for (auto &extension : ZeExtensions) {
232233
// Check if global offset extension is available
@@ -267,13 +268,20 @@ ur_result_t ur_platform_handle_t_::initialize() {
267268
MutableCommandListSpecExtensionSupported = true;
268269
}
269270
}
270-
// Check if extension is available for External Sempahores
271+
// Check if extension is available for Exp External Sempahores
271272
if (strncmp(extension.name, ZE_INTEL_EXTERNAL_SEMAPHORE_EXP_NAME,
272273
strlen(ZE_INTEL_EXTERNAL_SEMAPHORE_EXP_NAME) + 1) == 0) {
273274
if (extension.version == ZE_EXTERNAL_SEMAPHORE_EXP_VERSION_1_0) {
274275
ZeIntelExternalSemaphoreExtensionSupported = true;
275276
}
276277
}
278+
// Check if extension is available for Spec External Sempahores
279+
if (strncmp(extension.name, ZE_EXTERNAL_SEMAPHORES_EXTENSION_NAME,
280+
strlen(ZE_EXTERNAL_SEMAPHORES_EXTENSION_NAME) + 1) == 0) {
281+
if (extension.version == ZE_EXTERNAL_SEMAPHORE_EXT_VERSION_1_0) {
282+
ZeExternalSemaphoreExtensionSupported = true;
283+
}
284+
}
277285
if (strncmp(extension.name, ZE_EU_COUNT_EXT_NAME,
278286
strlen(ZE_EU_COUNT_EXT_NAME) + 1) == 0) {
279287
if (extension.version == ZE_EU_COUNT_EXT_VERSION_1_0) {
@@ -323,7 +331,37 @@ ur_result_t ur_platform_handle_t_::initialize() {
323331
// If yes, then set up L0 API pointers if the platform supports it.
324332
ZeUSMImport.setZeUSMImport(this);
325333

326-
if (ZeIntelExternalSemaphoreExtensionSupported) {
334+
if (ZeExternalSemaphoreExtensionSupported) {
335+
ZeExternalSemaphoreExt.Supported |=
336+
(ZE_CALL_NOCHECK(
337+
zeDriverGetExtensionFunctionAddress,
338+
(ZeDriver, "zeDeviceImportExternalSemaphoreExt",
339+
reinterpret_cast<void **>(
340+
&ZeExternalSemaphoreExt.zexImportExternalSemaphoreExp))) ==
341+
0);
342+
ZeExternalSemaphoreExt.Supported |=
343+
(ZE_CALL_NOCHECK(
344+
zeDriverGetExtensionFunctionAddress,
345+
(ZeDriver, "zeCommandListAppendWaitExternalSemaphoreExt",
346+
reinterpret_cast<void **>(
347+
&ZeExternalSemaphoreExt
348+
.zexCommandListAppendWaitExternalSemaphoresExp))) == 0);
349+
ZeExternalSemaphoreExt.Supported |=
350+
(ZE_CALL_NOCHECK(
351+
zeDriverGetExtensionFunctionAddress,
352+
(ZeDriver, "zeCommandListAppendSignalExternalSemaphoreExt",
353+
reinterpret_cast<void **>(
354+
&ZeExternalSemaphoreExt
355+
.zexCommandListAppendSignalExternalSemaphoresExp))) ==
356+
0);
357+
ZeExternalSemaphoreExt.Supported |=
358+
(ZE_CALL_NOCHECK(zeDriverGetExtensionFunctionAddress,
359+
(ZeDriver, "zeDeviceReleaseExternalSemaphoreExt",
360+
reinterpret_cast<void **>(
361+
&ZeExternalSemaphoreExt
362+
.zexDeviceReleaseExternalSemaphoreExp))) ==
363+
0);
364+
} else if (ZeIntelExternalSemaphoreExtensionSupported) {
327365
ZeExternalSemaphoreExt.Supported |=
328366
(ZE_CALL_NOCHECK(
329367
zeDriverGetExtensionFunctionAddress,

0 commit comments

Comments
 (0)