Skip to content

Mirror intel/llvm commits #2778

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 3 commits into from
Jun 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 .github/intel-llvm-mirror-base-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
571454167c03e22a43cba257d7937b188a681de6
093fcb0d5171566ff5218962b841256412a329a8
34 changes: 15 additions & 19 deletions source/adapters/level_zero/v2/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
namespace v2 {
namespace raii {

template <typename ZeHandleT, ze_result_t (*destroy)(ZeHandleT)>
template <typename ZeHandleT, ze_result_t (*destroy)(ZeHandleT),
const char *destroyName>
struct ze_handle_wrapper {
ze_handle_wrapper(bool ownZeHandle = true)
: handle(nullptr), ownZeHandle(ownZeHandle) {}
Expand Down Expand Up @@ -64,7 +65,8 @@ struct ze_handle_wrapper {
}

if (ownZeHandle && checkL0LoaderTeardown()) {
auto zeResult = destroy(handle);
ze_result_t zeResult =
ZE_CALL_NOCHECK_NAME(destroy, (handle), destroyName);
// Gracefully handle the case that L0 was already unloaded.
if (zeResult && (zeResult != ZE_RESULT_ERROR_UNINITIALIZED &&
zeResult != ZE_RESULT_ERROR_UNKNOWN))
Expand Down Expand Up @@ -92,23 +94,17 @@ struct ze_handle_wrapper {
bool ownZeHandle;
};

using ze_kernel_handle_t =
ze_handle_wrapper<::ze_kernel_handle_t, zeKernelDestroy>;

using ze_event_handle_t =
ze_handle_wrapper<::ze_event_handle_t, zeEventDestroy>;

using ze_event_pool_handle_t =
ze_handle_wrapper<::ze_event_pool_handle_t, zeEventPoolDestroy>;

using ze_context_handle_t =
ze_handle_wrapper<::ze_context_handle_t, zeContextDestroy>;

using ze_command_list_handle_t =
ze_handle_wrapper<::ze_command_list_handle_t, zeCommandListDestroy>;

using ze_image_handle_t =
ze_handle_wrapper<::ze_image_handle_t, zeImageDestroy>;
#define HANDLE_WRAPPER_TYPE(ZeHandleT, DestroyFunc) \
inline constexpr char ZeHandleT##_destroyName[] = #DestroyFunc; \
using ZeHandleT = \
ze_handle_wrapper<::ZeHandleT, DestroyFunc, ZeHandleT##_destroyName>;

HANDLE_WRAPPER_TYPE(ze_kernel_handle_t, zeKernelDestroy)
HANDLE_WRAPPER_TYPE(ze_event_handle_t, zeEventDestroy)
HANDLE_WRAPPER_TYPE(ze_event_pool_handle_t, zeEventPoolDestroy)
HANDLE_WRAPPER_TYPE(ze_context_handle_t, zeContextDestroy)
HANDLE_WRAPPER_TYPE(ze_command_list_handle_t, zeCommandListDestroy)
HANDLE_WRAPPER_TYPE(ze_image_handle_t, zeImageDestroy)

} // namespace raii
} // namespace v2
17 changes: 17 additions & 0 deletions source/adapters/offload/adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,20 @@ UR_APIEXPORT ur_result_t UR_APICALL urAdapterGetLastError(ur_adapter_handle_t,
// "ADAPTER_SPECIFIC", which we never do
return UR_RESULT_SUCCESS;
}

UR_APIEXPORT ur_result_t UR_APICALL urAdapterSetLoggerCallback(
ur_adapter_handle_t, ur_logger_callback_t pfnLoggerCallback,
void *pUserData, ur_logger_level_t level = UR_LOGGER_LEVEL_QUIET) {

Adapter.Logger.setCallbackSink(pfnLoggerCallback, pUserData, level);

return UR_RESULT_SUCCESS;
}

UR_APIEXPORT ur_result_t UR_APICALL
urAdapterSetLoggerCallbackLevel(ur_adapter_handle_t, ur_logger_level_t level) {

Adapter.Logger.setCallbackLevel(level);

return UR_RESULT_SUCCESS;
}
4 changes: 2 additions & 2 deletions source/adapters/offload/ur_interface_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetAdapterProcAddrTable(
pDdiTable->pfnRelease = urAdapterRelease;
pDdiTable->pfnRetain = urAdapterRetain;
pDdiTable->pfnGetLastError = urAdapterGetLastError;
pDdiTable->pfnSetLoggerCallback = nullptr;
pDdiTable->pfnSetLoggerCallbackLevel = nullptr;
pDdiTable->pfnSetLoggerCallback = urAdapterSetLoggerCallback;
pDdiTable->pfnSetLoggerCallbackLevel = urAdapterSetLoggerCallbackLevel;
return UR_RESULT_SUCCESS;
}

Expand Down