Skip to content

[SYCL][UR] Update unified-runtime #8315

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
Mar 9, 2023
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
8 changes: 4 additions & 4 deletions sycl/plugins/level_zero/pi_level_zero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ pi_result _pi_context::initialize() {
// Prefer to use copy engine for initialization copies,
// if available and allowed (main copy engine with index 0).
ZeStruct<ze_command_queue_desc_t> ZeCommandQueueDesc;
const auto &Range = getRangeOfAllowedCopyEngines((zer_device_handle_t)Device);
const auto &Range = getRangeOfAllowedCopyEngines((ur_device_handle_t)Device);
ZeCommandQueueDesc.ordinal =
Device->QueueGroup[_pi_device::queue_group_info_t::Compute].ZeOrdinal;
if (Range.first >= 0 &&
Expand Down Expand Up @@ -910,7 +910,7 @@ _pi_queue::_pi_queue(std::vector<ze_command_queue_handle_t> &ComputeQueues,

// Copy group initialization.
pi_queue_group_t CopyQueueGroup{this, queue_type::MainCopy};
const auto &Range = getRangeOfAllowedCopyEngines((zer_device_handle_t)Device);
const auto &Range = getRangeOfAllowedCopyEngines((ur_device_handle_t)Device);
if (Range.first < 0 || Range.second < 0) {
// We are asked not to use copy engines, just do nothing.
// Leave CopyQueueGroup.ZeQueues empty, and it won't be used.
Expand Down Expand Up @@ -7851,7 +7851,7 @@ pi_result piextEnqueueDeviceGlobalVariableWrite(
(Program->ZeModule, Name, &GlobalVarSize, &GlobalVarPtr));
if (GlobalVarSize < Offset + Count) {
setErrorMessage("Write device global variable is out of range.",
ZER_RESULT_INVALID_VALUE);
UR_RESULT_ERROR_INVALID_VALUE);
return PI_ERROR_PLUGIN_SPECIFIC_ERROR;
}

Expand Down Expand Up @@ -7896,7 +7896,7 @@ pi_result piextEnqueueDeviceGlobalVariableRead(
(Program->ZeModule, Name, &GlobalVarSize, &GlobalVarPtr));
if (GlobalVarSize < Offset + Count) {
setErrorMessage("Read from device global variable is out of range.",
ZER_RESULT_INVALID_VALUE);
UR_RESULT_ERROR_INVALID_VALUE);
return PI_ERROR_PLUGIN_SPECIFIC_ERROR;
}

Expand Down
6 changes: 3 additions & 3 deletions sycl/plugins/level_zero/ur_bindings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
#pragma once

#include "pi_level_zero.hpp"
#include <zer_api.h>
#include <ur_api.h>

// Make the Unified Runtime handles definition complete.
// This is used in various "create" API where new handles are allocated.
struct _zer_platform_handle_t : public _pi_platform {
struct ur_platform_handle_t_ : public _pi_platform {
using _pi_platform::_pi_platform;
};

struct _zer_device_handle_t : public _pi_device {
struct ur_device_handle_t_ : public _pi_device {
using _pi_device::_pi_device;
};
23 changes: 20 additions & 3 deletions sycl/plugins/unified_runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@
# PI Unified Runtime plugin library
#
if (NOT DEFINED UNIFIED_RUNTIME_INCLUDE_DIR)
if (NOT DEFINED UNIFIED_RUNTIME_LIBRARY OR NOT DEFINED UNIFIED_RUNTIME_INCLUDE_DIR)
include(FetchContent)

set(UNIFIED_RUNTIME_REPO "https://github.com/oneapi-src/unified-runtime.git")
set(UNIFIED_RUNTIME_TAG fd711c920acc4434cb52ff18b078c082d9d7f44d)
set(UNIFIED_RUNTIME_TAG 6fb8e2620f1474428a539ef46d6dd47043c7d59b)

message(STATUS "Will fetch Unified Runtime from ${UNIFIED_RUNTIME_REPO}")
FetchContent_Declare(unified-runtime
GIT_REPOSITORY ${UNIFIED_RUNTIME_REPO}
GIT_TAG ${UNIFIED_RUNTIME_TAG}
)

FetchContent_MakeAvailable(unified-runtime)
# Disable some compilation options to avoid errors while building the UR
if (UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-but-set-variable")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-pedantic")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-stringop-truncation")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-suggest-override")
endif()

FetchContent_GetProperties(unified-runtime)
FetchContent_MakeAvailable(unified-runtime)

add_library(${PROJECT_NAME}::ur_loader ALIAS loader)

set(UNIFIED_RUNTIME_LIBRARY ${PROJECT_NAME}::ur_loader)

set(UNIFIED_RUNTIME_SOURCE_DIR
${unified-runtime_SOURCE_DIR} CACHE PATH "Path to Unified Runtime Headers")
Expand Down Expand Up @@ -58,3 +71,7 @@ add_sycl_plugin(unified_runtime
LevelZeroLoader-Headers
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should link only with the UnifiedRuntimeLoader here. And the L0 adapter should be build as a standalone SHARED library that links with LevelZero loader.

Something like this:

add_sycl_plugin(unified_runtime
  SOURCES
    "pi_unified_runtime.hpp"
    "pi_unified_runtime.cpp"
    LIBRARIES
    Threads::Threads
    UnifiedRuntimeLoader
    UnifiedRuntime-Headers
)

and:

add_library(ur_level_zero
    SHARED
        ${CMAKE_CURRENT_SOURCE_DIR}/ur_level_zero.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/ur_level_zero.hpp
        "../../../ur_bindings.hpp"
        "../../../pi2ur.hpp"
        "../../../pi2ur.cpp"
        "../../ur.hpp"
        "../../ur.cpp"
)

target_include_directories(ur_level_zero
  PRIVATE "${LEVEL_ZERO_INCLUDE_DIR}"
)

target_link_libraries(ur_level_zero
  PRIVATE
    LevelZeroLoader-Headers
    LevelZeroLoader
)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ur_loader work to continue in #8423

LevelZeroLoader
)

if (TARGET ${PROJECT_NAME}::ur_loader)
set_target_properties(hello_world PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1)
endif()
Loading