Skip to content

[UR][L0] fix external semaphore with updated headers and report device info support #17286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion unified-runtime/cmake/FetchLevelZero.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ if (UR_COMPUTE_RUNTIME_REPO STREQUAL "")
set(UR_COMPUTE_RUNTIME_REPO "https://github.com/intel/compute-runtime.git")
endif()
if (UR_COMPUTE_RUNTIME_TAG STREQUAL "")
set(UR_COMPUTE_RUNTIME_TAG 24.39.31294.12)
set(UR_COMPUTE_RUNTIME_TAG 25.05.32567.17)
endif()
include(FetchContent)
# Sparse fetch only the dir with level zero headers for experimental features to avoid pulling in the entire compute-runtime.
Expand Down
1 change: 0 additions & 1 deletion unified-runtime/source/adapters/level_zero/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "common.hpp"
#include "logger/ur_logger.hpp"
#include "usm.hpp"
#include <level_zero/include/ze_intel_gpu.h>

ur_result_t ze2urResult(ze_result_t ZeResult) {
if (ZeResult == ZE_RESULT_SUCCESS)
Expand Down
74 changes: 1 addition & 73 deletions unified-runtime/source/adapters/level_zero/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <ze_api.h>
#include <zes_api.h>

#include <level_zero/include/level_zero/ze_intel_gpu.h>
#include <umf_pools/disjoint_pool_config_parser.hpp>

#include "logger/ur_logger.hpp"
Expand Down Expand Up @@ -537,76 +538,3 @@ extern thread_local int32_t ErrorAdapterNativeCode;
int32_t AdapterErrorCode);

#define L0_DRIVER_INORDER_MIN_VERSION 29534

// Definitions for the External Semaphore Extension

#ifndef ZE_INTEL_EXTERNAL_SEMAPHORE_EXP_NAME
/// @brief Event sync mode extension name
#define ZE_INTEL_EXTERNAL_SEMAPHORE_EXP_NAME \
"ZE_intel_experimental_external_semaphore"
#endif // ZE_INTEL_EXTERNAL_SEMAPHORE_EXP_NAME

typedef enum _ze_intel_external_semaphore_exp_version_t {
ZE_EXTERNAL_SEMAPHORE_EXP_VERSION_1_0 =
ZE_MAKE_VERSION(1, 0), ///< version 1.0
ZE_EXTERNAL_SEMAPHORE_EXP_VERSION_CURRENT =
ZE_MAKE_VERSION(1, 0), ///< latest known version
ZE_EXTERNAL_SEMAPHORE_EXP_VERSION_FORCE_UINT32 = 0x7fffffff
} ze_intel_external_semaphore_exp_version_t;
typedef enum _ze_intel_external_semaphore_exp_flags_t {
ZE_EXTERNAL_SEMAPHORE_EXP_FLAGS_OPAQUE_FD,
ZE_EXTERNAL_SEMAPHORE_EXP_FLAGS_OPAQUE_WIN32,
ZE_EXTERNAL_SEMAPHORE_EXP_FLAGS_OPAQUE_WIN32_KMT,
ZE_EXTERNAL_SEMAPHORE_EXP_FLAGS_D3D12_FENCE,
ZE_EXTERNAL_SEMAPHORE_EXP_FLAGS_D3D11_FENCE,
ZE_EXTERNAL_SEMAPHORE_EXP_FLAGS_KEYED_MUTEX,
ZE_EXTERNAL_SEMAPHORE_EXP_FLAGS_KEYED_MUTEX_KMT,
ZE_EXTERNAL_SEMAPHORE_EXP_FLAGS_TIMELINE_SEMAPHORE_FD,
ZE_EXTERNAL_SEMAPHORE_EXP_FLAGS_TIMELINE_SEMAPHORE_WIN32
} ze_intel_external_semaphore_exp_flags_t;

typedef struct _ze_intel_external_semaphore_exp_desc_t {
ze_structure_type_t stype;
const void *pNext;
ze_intel_external_semaphore_exp_flags_t flags;
} ze_intel_external_semaphore_exp_desc_t;

typedef struct _ze_intel_external_semaphore_win32_exp_desc_t {
ze_structure_type_t stype;
const void *pNext;
void *handle;
const char *name;
} ze_intel_external_semaphore_win32_exp_desc_t;

typedef struct _ze_intel_external_semaphore_fd_exp_desc_t {
ze_structure_type_t stype;
const void *pNext;
int fd;
} ze_intel_external_semaphore_desc_fd_exp_desc_t;

typedef struct _ze_intel_external_semaphore_signal_exp_params_t {
ze_structure_type_t stype;
const void *pNext;
uint64_t value;
} ze_intel_external_semaphore_signal_exp_params_t;

typedef struct _ze_intel_external_semaphore_wait_exp_params_t {
ze_structure_type_t stype;
const void *pNext;

uint64_t value;
} ze_intel_external_semaphore_wait_exp_params_t;

typedef struct _ze_intel_external_semaphore_exp_handle_t
*ze_intel_external_semaphore_exp_handle_t;

#define ZE_INTEL_STRUCTURE_TYPE_EXTERNAL_SEMAPHORE_EXP_DESC \
(ze_structure_type_t)0x0003001E
#define ZE_INTEL_STRUCTURE_TYPE_EXTERNAL_SEMAPHORE_WIN32_EXP_DESC \
(ze_structure_type_t)0x0003001F
#define ZE_INTEL_STRUCTURE_TYPE_EXTERNAL_SEMAPHORE_FD_EXP_DESC \
(ze_structure_type_t)0x00030023
#define ZE_INTEL_STRUCTURE_TYPE_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS_EXP \
(ze_structure_type_t)0x00030024
#define ZE_INTEL_STRUCTURE_TYPE_EXTERNAL_SEMAPHORE_WAIT_PARAMS_EXP \
(ze_structure_type_t)0x00030025
3 changes: 1 addition & 2 deletions unified-runtime/source/adapters/level_zero/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1127,8 +1127,7 @@ ur_result_t urDeviceGetInfo(
return ReturnValue(false);
}
case UR_DEVICE_INFO_EXTERNAL_SEMAPHORE_IMPORT_SUPPORT_EXP: {
// L0 does not support importing external semaphores.
return ReturnValue(false);
return ReturnValue(Device->Platform->ZeExternalSemaphoreExt.Supported);
}
case UR_DEVICE_INFO_CUBEMAP_SUPPORT_EXP: {
// L0 does not support cubemaps.
Expand Down
1 change: 0 additions & 1 deletion unified-runtime/source/adapters/level_zero/device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

#include "adapters/level_zero/platform.hpp"
#include "common.hpp"
#include <level_zero/include/ze_intel_gpu.h>
#include <ur/ur.hpp>
#include <ur_ddi.h>
#include <ze_api.h>
Expand Down
4 changes: 2 additions & 2 deletions unified-runtime/source/adapters/level_zero/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ ur_result_t urBindlessImagesWaitExternalSemaphoreExp(
const auto &ZeCommandList = CommandList->first;
const auto &WaitList = (*Event)->WaitList;

ze_intel_external_semaphore_wait_exp_params_t WaitParams = {
ze_intel_external_semaphore_wait_params_exp_t WaitParams = {
ZE_INTEL_STRUCTURE_TYPE_EXTERNAL_SEMAPHORE_WAIT_PARAMS_EXP, nullptr, 0};
WaitParams.value = hasValue ? waitValue : 0;
const ze_intel_external_semaphore_exp_handle_t hExtSemaphore =
Expand Down Expand Up @@ -950,7 +950,7 @@ ur_result_t urBindlessImagesSignalExternalSemaphoreExp(
const auto &ZeCommandList = CommandList->first;
const auto &WaitList = (*Event)->WaitList;

ze_intel_external_semaphore_signal_exp_params_t SignalParams = {
ze_intel_external_semaphore_signal_params_exp_t SignalParams = {
ZE_INTEL_STRUCTURE_TYPE_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS_EXP, nullptr, 0};
SignalParams.value = hasValue ? signalValue : 0;
const ze_intel_external_semaphore_exp_handle_t hExtSemaphore =
Expand Down
4 changes: 2 additions & 2 deletions unified-runtime/source/adapters/level_zero/platform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,12 @@ struct ur_platform_handle_t_ : public _ur_platform {
ze_result_t (*zexCommandListAppendWaitExternalSemaphoresExp)(
ze_command_list_handle_t, unsigned int,
const ze_intel_external_semaphore_exp_handle_t *,
const ze_intel_external_semaphore_wait_exp_params_t *,
const ze_intel_external_semaphore_wait_params_exp_t *,
ze_event_handle_t, uint32_t, ze_event_handle_t *);
ze_result_t (*zexCommandListAppendSignalExternalSemaphoresExp)(
ze_command_list_handle_t, size_t,
const ze_intel_external_semaphore_exp_handle_t *,
const ze_intel_external_semaphore_signal_exp_params_t *,
const ze_intel_external_semaphore_signal_params_exp_t *,
ze_event_handle_t, uint32_t, ze_event_handle_t *);
ze_result_t (*zexDeviceReleaseExternalSemaphoreExp)(
ze_intel_external_semaphore_exp_handle_t);
Expand Down