Skip to content

Commit 4c058de

Browse files
[SYCL][UR][L0 v2] Implement missing bindless images functionality (intel#19881)
This is a cherry-pick of intel#19808 Implement urBindlessImagesSignalExternalSemaphoreExp and urBindlessImagesWaitExternalSemaphoreExp. The implementation is the same as in the legace adapter, except that we don't to a fallback in case old loader is used (v2 is supposed to be used with a new enough L0 loader version). Patch-by: Igor Chorążewicz <[email protected]>
1 parent f7db283 commit 4c058de

File tree

1 file changed

+57
-10
lines changed

1 file changed

+57
-10
lines changed

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

Lines changed: 57 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -893,19 +893,66 @@ ur_result_t ur_command_list_manager::bindlessImagesImageCopyExp(
893893
}
894894

895895
ur_result_t ur_command_list_manager::bindlessImagesWaitExternalSemaphoreExp(
896-
ur_exp_external_semaphore_handle_t /*hSemaphore*/, bool /*hasWaitValue*/,
897-
uint64_t /*waitValue*/, uint32_t /*numEventsInWaitList*/,
898-
const ur_event_handle_t * /*phEventWaitList*/,
899-
ur_event_handle_t /*phEvent*/) {
900-
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
896+
ur_exp_external_semaphore_handle_t hSemaphore, bool hasWaitValue,
897+
uint64_t waitValue, uint32_t numEventsInWaitList,
898+
const ur_event_handle_t *phEventWaitList, ur_event_handle_t phEvent) {
899+
auto hPlatform = hContext->getPlatform();
900+
if (!hPlatform->ZeExternalSemaphoreExt.Supported == false ||
901+
!hPlatform->ZeExternalSemaphoreExt.LoaderExtension) {
902+
UR_LOG_LEGACY(ERR,
903+
logger::LegacyMessage("[UR][L0] {} function not supported!"),
904+
"{} function not supported!", __FUNCTION__);
905+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
906+
}
907+
908+
auto zeSignalEvent =
909+
getSignalEvent(phEvent, UR_COMMAND_EXTERNAL_SEMAPHORE_WAIT_EXP);
910+
auto [pWaitEvents, numWaitEvents] =
911+
getWaitListView(phEventWaitList, numEventsInWaitList);
912+
913+
ze_external_semaphore_wait_params_ext_t waitParams = {
914+
ZE_STRUCTURE_TYPE_EXTERNAL_SEMAPHORE_WAIT_PARAMS_EXT, nullptr, 0};
915+
waitParams.value = hasWaitValue ? waitValue : 0;
916+
ze_external_semaphore_ext_handle_t hExtSemaphore =
917+
reinterpret_cast<ze_external_semaphore_ext_handle_t>(hSemaphore);
918+
ZE2UR_CALL(hPlatform->ZeExternalSemaphoreExt
919+
.zexCommandListAppendWaitExternalSemaphoresExp,
920+
(zeCommandList.get(), 1, &hExtSemaphore, &waitParams,
921+
zeSignalEvent, numWaitEvents, pWaitEvents));
922+
923+
return UR_RESULT_SUCCESS;
901924
}
902925

903926
ur_result_t ur_command_list_manager::bindlessImagesSignalExternalSemaphoreExp(
904-
ur_exp_external_semaphore_handle_t /*hSemaphore*/, bool /*hasSignalValue*/,
905-
uint64_t /*signalValue*/, uint32_t /*numEventsInWaitList*/,
906-
const ur_event_handle_t * /*phEventWaitList*/,
907-
ur_event_handle_t /*phEvent*/) {
908-
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
927+
ur_exp_external_semaphore_handle_t hSemaphore, bool hasSignalValue,
928+
uint64_t signalValue, uint32_t numEventsInWaitList,
929+
const ur_event_handle_t *phEventWaitList, ur_event_handle_t phEvent) {
930+
auto hPlatform = hContext->getPlatform();
931+
if (!hPlatform->ZeExternalSemaphoreExt.Supported == false ||
932+
!hPlatform->ZeExternalSemaphoreExt.LoaderExtension) {
933+
UR_LOG_LEGACY(ERR,
934+
logger::LegacyMessage("[UR][L0] {} function not supported!"),
935+
"{} function not supported!", __FUNCTION__);
936+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
937+
}
938+
939+
auto zeSignalEvent =
940+
getSignalEvent(phEvent, UR_COMMAND_EXTERNAL_SEMAPHORE_SIGNAL_EXP);
941+
auto [pWaitEvents, numWaitEvents] =
942+
getWaitListView(phEventWaitList, numEventsInWaitList);
943+
944+
ze_external_semaphore_signal_params_ext_t signalParams = {
945+
ZE_STRUCTURE_TYPE_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS_EXT, nullptr, 0};
946+
signalParams.value = hasSignalValue ? signalValue : 0;
947+
ze_external_semaphore_ext_handle_t hExtSemaphore =
948+
reinterpret_cast<ze_external_semaphore_ext_handle_t>(hSemaphore);
949+
950+
ZE2UR_CALL(hPlatform->ZeExternalSemaphoreExt
951+
.zexCommandListAppendSignalExternalSemaphoresExp,
952+
(zeCommandList.get(), 1, &hExtSemaphore, &signalParams,
953+
zeSignalEvent, numWaitEvents, pWaitEvents));
954+
955+
return UR_RESULT_SUCCESS;
909956
}
910957

911958
ur_result_t ur_command_list_manager::appendNativeCommandExp(

0 commit comments

Comments
 (0)