-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL] Add Unified Runtime Plugin #7521
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
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
01461f6
update build system to add pi_unified_runtime
smaslov-intel 6001819
[SYCL] Next redesign step
53d0c61
Few build fixes
f6aa055
move more stuff and build true pi_unified_runtime plugin
smaslov-intel 644d84d
repair incorrect merge
smaslov-intel dd57e12
Fix remaining build issues
b42cd50
Makefiles cleanup
cbb978b
further re-org
smaslov-intel befef2c
clang-format
smaslov-intel 7a4029e
suppress warnign for L0 build
smaslov-intel be148e0
disable some warnings
smaslov-intel df78664
spell
smaslov-intel 4631e00
more warnings
smaslov-intel d0349b5
more warnings
smaslov-intel 292d911
update l0 includes
smaslov-intel d3c8134
add L0 includes
smaslov-intel 90b6099
chmod
smaslov-intel 22cd993
Update sycl/plugins/unified_runtime/pi2ur.hpp
smaslov-intel e27f2ab
Update sycl/plugins/unified_runtime/pi_unified_runtime.cpp
smaslov-intel 98a95ab
Update sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_z…
smaslov-intel 20b7f15
Update sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_z…
smaslov-intel 9994815
test
smaslov-intel 60fad1f
suppress unknown option
smaslov-intel a5ecb71
allow custom L0 and UR
smaslov-intel f8be700
add proper L0 loader lib
smaslov-intel 727268a
fix wrong logic
smaslov-intel 6e4d7d4
restore flags
smaslov-intel b441158
suppress warn
smaslov-intel a267d98
restart testing
smaslov-intel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,143 +1,106 @@ | ||
# PI Level Zero plugin library | ||
|
||
if(MSVC) | ||
set(LEVEL_ZERO_LOADER | ||
"${LLVM_LIBRARY_OUTPUT_INTDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}ze_loader${CMAKE_STATIC_LIBRARY_SUFFIX}") | ||
else() | ||
set(LEVEL_ZERO_LOADER | ||
"${LLVM_LIBRARY_OUTPUT_INTDIR}/${CMAKE_SHARED_LIBRARY_PREFIX}ze_loader${CMAKE_SHARED_LIBRARY_SUFFIX}") | ||
endif() | ||
|
||
if (NOT DEFINED LEVEL_ZERO_LIBRARY OR NOT DEFINED LEVEL_ZERO_INCLUDE_DIR) | ||
message(STATUS "Download Level Zero loader and headers from github.com") | ||
if (CMAKE_C_COMPILER) | ||
list(APPEND AUX_CMAKE_FLAGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}) | ||
endif() | ||
if (CMAKE_CXX_COMPILER) | ||
list(APPEND AUX_CMAKE_FLAGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}) | ||
endif() | ||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/level_zero_loader_build) | ||
set(LEVEL_ZERO_LOADER_SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/level_zero/level_zero_loader") | ||
if (NOT DEFINED SYCL_EP_LEVEL_ZERO_LOADER_SKIP_AUTO_UPDATE) | ||
set(SYCL_EP_LEVEL_ZERO_LOADER_SKIP_AUTO_UPDATE ${SYCL_EXTERNAL_PROJECTS_SKIP_AUTO_UPDATE}) | ||
endif() | ||
set(LEVEL_ZERO_LOADER_SOURCE_VERSION v1.8.8) | ||
|
||
#TODO: Replace ExternalProject with FetchContent for better maintainance and | ||
# cmake files simplification | ||
include(ExternalProject) | ||
ExternalProject_Add(level-zero-loader | ||
GIT_REPOSITORY https://github.com/oneapi-src/level-zero.git | ||
GIT_TAG ${LEVEL_ZERO_LOADER_SOURCE_VERSION} | ||
UPDATE_DISCONNECTED ${SYCL_EP_LEVEL_ZERO_LOADER_SKIP_AUTO_UPDATE} | ||
SOURCE_DIR ${LEVEL_ZERO_LOADER_SOURCE_DIR} | ||
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/level_zero_loader_build" | ||
INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/level_zero_loader_install" | ||
CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} | ||
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM} | ||
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> | ||
-DCMAKE_INSTALL_LIBDIR:PATH=lib${LLVM_LIBDIR_SUFFIX} | ||
${AUX_CMAKE_FLAGS} | ||
LOG_DOWNLOAD 1 | ||
LOG_UPDATE 1 | ||
LOG_CONFIGURE 1 | ||
LOG_BUILD 1 | ||
LOG_INSTALL 1 | ||
STEP_TARGETS configure,build,install | ||
DEPENDS OpenCL-Headers | ||
BUILD_BYPRODUCTS ${LEVEL_ZERO_LOADER} | ||
) | ||
ExternalProject_Add_Step(level-zero-loader llvminstall | ||
COMMAND ${CMAKE_COMMAND} -E copy_directory <INSTALL_DIR>/lib/ ${LLVM_BINARY_DIR}/lib | ||
COMMAND ${CMAKE_COMMAND} -E copy_directory <INSTALL_DIR>/include/ ${LLVM_BINARY_DIR}/include/sycl | ||
COMMENT "Installing level-zero-loader into the LLVM binary directory" | ||
DEPENDEES install | ||
) | ||
|
||
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/level_zero_loader_install/" | ||
DESTINATION "." | ||
COMPONENT level-zero-loader | ||
) | ||
set(LEVEL_ZERO_LOADER_REPO "https://github.com/oneapi-src/level-zero.git") | ||
set(LEVEL_ZERO_LOADER_TAG v1.8.8) | ||
|
||
set(LEVEL_ZERO_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/level_zero_loader_install/include/ | ||
CACHE INTERNAL "Path containing Level_Zero header files.") | ||
else() | ||
file(GLOB LEVEL_ZERO_LIBRARY_SRC "${LEVEL_ZERO_LIBRARY}*") | ||
get_filename_component(LEVEL_ZERO_LIB_NAME ${LEVEL_ZERO_LIBRARY} NAME) | ||
add_custom_target(level-zero-loader | ||
DEPENDS | ||
${LLVM_LIBRARY_OUTPUT_INTDIR}/${LEVEL_ZERO_LIB_NAME} | ||
${LLVM_BINARY_DIR}/include/sycl/level_zero | ||
) | ||
add_custom_command( | ||
OUTPUT | ||
${LLVM_LIBRARY_OUTPUT_INTDIR}/${LEVEL_ZERO_LIB_NAME} | ||
${LLVM_BINARY_DIR}/include/sycl/level_zero | ||
COMMENT | ||
"Copying Level Zero loader and headers" | ||
COMMAND | ||
${CMAKE_COMMAND} -E copy ${LEVEL_ZERO_LIBRARY_SRC} ${LLVM_LIBRARY_OUTPUT_INTDIR} | ||
COMMAND | ||
${CMAKE_COMMAND} -E copy_directory ${LEVEL_ZERO_INCLUDE_DIR} ${LLVM_BINARY_DIR}/include/sycl | ||
DEPENDS | ||
${LEVEL_ZERO_LIBRARY} | ||
${LEVEL_ZERO_INCLUDE_DIR} | ||
# Disable due to a bug https://github.com/oneapi-src/level-zero/issues/104 | ||
set(CMAKE_INCLUDE_CURRENT_DIR OFF) | ||
|
||
message(STATUS "Will fetch Level Zero Loader from ${LEVEL_ZERO_LOADER_REPO}") | ||
include(FetchContent) | ||
FetchContent_Declare(level-zero-loader | ||
GIT_REPOSITORY ${LEVEL_ZERO_LOADER_REPO} | ||
GIT_TAG ${LEVEL_ZERO_LOADER_TAG} | ||
) | ||
endif() | ||
|
||
list(APPEND SYCL_TOOLCHAIN_DEPLOY_COMPONENTS level-zero-loader level-zero-headers) | ||
# Suppress some pedantic warnings for Level Zero build | ||
set(CMAKE_CXX_FLAGS_BAK "${CMAKE_CXX_FLAGS}") | ||
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-unknown-warning-option") | ||
|
||
include_directories("${LEVEL_ZERO_INCLUDE_DIR}") | ||
FetchContent_MakeAvailable(level-zero-loader) | ||
FetchContent_GetProperties(level-zero-loader) | ||
|
||
# Restore original flags | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_BAK}") | ||
|
||
set(LEVEL_ZERO_LIBRARY ze_loader) | ||
set(LEVEL_ZERO_INCLUDE_DIR | ||
${level-zero-loader_SOURCE_DIR}/include CACHE PATH "Path to Level Zero Headers") | ||
endif() | ||
|
||
add_library (LevelZeroLoader INTERFACE) | ||
target_link_libraries(LevelZeroLoader | ||
INTERFACE "${LEVEL_ZERO_LIBRARY}" | ||
) | ||
|
||
add_library (LevelZeroLoader-Headers INTERFACE) | ||
add_library (LevelZeroLoader::Headers ALIAS LevelZeroLoader-Headers) | ||
target_include_directories(LevelZeroLoader-Headers | ||
INTERFACE "${LEVEL_ZERO_INCLUDE_DIR}" | ||
) | ||
|
||
if (SYCL_ENABLE_XPTI_TRACING) | ||
set(XPTI_PROXY_SRC "${CMAKE_SOURCE_DIR}/../xpti/src/xpti_proxy.cpp") | ||
set(XPTI_INCLUDE "${CMAKE_SOURCE_DIR}/../xpti/include") | ||
set(XPTI_LIBS "${CMAKE_DL_LIBS}") | ||
endif() | ||
|
||
find_package(Python3 REQUIRED) | ||
|
||
add_custom_target(ze-api | ||
COMMAND ${Python3_EXECUTABLE} | ||
${CMAKE_CURRENT_SOURCE_DIR}/ze_api_generator.py | ||
${LEVEL_ZERO_INCLUDE_DIR}/ze_api.h | ||
BYPRODUCTS | ||
${CMAKE_CURRENT_BINARY_DIR}/ze_api.def | ||
) | ||
|
||
find_package(Threads REQUIRED) | ||
|
||
add_sycl_plugin(level_zero | ||
SOURCES | ||
"${sycl_inc_dir}/sycl/detail/pi.h" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/pi_level_zero.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/pi_level_zero.hpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/usm_allocator.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/usm_allocator.hpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/tracing.cpp" | ||
# These are short-term shared with Unified Runtime | ||
# The two plugins define a few things differrently so must | ||
# be built separately. This difference is spelled in | ||
# their "ur_bindings.hpp" files. | ||
# | ||
"ur_bindings.hpp" | ||
"../unified_runtime/pi2ur.hpp" | ||
"../unified_runtime/pi2ur.cpp" | ||
"../unified_runtime/ur/ur.hpp" | ||
"../unified_runtime/ur/ur.cpp" | ||
"../unified_runtime/ur/adapters/level_zero/ur_level_zero.hpp" | ||
"../unified_runtime/ur/adapters/level_zero/ur_level_zero.cpp" | ||
# Following are the PI Level-Zero Plugin only codes. | ||
"pi_level_zero.cpp" | ||
"pi_level_zero.hpp" | ||
"usm_allocator.cpp" | ||
"usm_allocator.hpp" | ||
"tracing.cpp" | ||
${XPTI_PROXY_SRC} | ||
INCLUDE_DIRS | ||
${CMAKE_CURRENT_BINARY_DIR} # for ze_api.def | ||
${CMAKE_CURRENT_SOURCE_DIR} # for Level-Zero Plugin "ur_bindings.hpp" | ||
${CMAKE_CURRENT_SOURCE_DIR}/../unified_runtime # for Unified Runtime | ||
${XPTI_INCLUDE} | ||
LIBRARIES | ||
"${LEVEL_ZERO_LOADER}" | ||
LevelZeroLoader-Headers | ||
UnifiedRuntime-Headers | ||
LevelZeroLoader | ||
Threads::Threads | ||
unified_runtime | ||
${XPTI_LIBS} | ||
) | ||
|
||
find_package(Python3 REQUIRED) | ||
|
||
add_custom_target(ze-api | ||
COMMAND ${Python3_EXECUTABLE} | ||
${CMAKE_CURRENT_SOURCE_DIR}/ze_api_generator.py | ||
${LEVEL_ZERO_INCLUDE_DIR}/level_zero/ze_api.h | ||
BYPRODUCTS | ||
${CMAKE_CURRENT_BINARY_DIR}/ze_api.def | ||
) | ||
target_include_directories(pi_level_zero PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) | ||
add_dependencies(pi_level_zero ze-api) | ||
|
||
if (SYCL_ENABLE_XPTI_TRACING) | ||
target_compile_definitions(pi_level_zero PRIVATE | ||
XPTI_ENABLE_INSTRUMENTATION | ||
XPTI_STATIC_LIBRARY | ||
) | ||
target_include_directories(pi_level_zero PRIVATE "${CMAKE_SOURCE_DIR}/../xpti/include") | ||
target_link_libraries(pi_level_zero PRIVATE ${CMAKE_DL_LIBS}) | ||
endif() | ||
|
||
if (TARGET level-zero-loader) | ||
add_dependencies(ze-api level-zero-loader) | ||
add_dependencies(pi_level_zero level-zero-loader) | ||
endif() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only tricky change I would say. Basically some functions in "Unified Runtime", those that allocate new handles, act as a factory. The Level-Zero PI Plugin handle inherits from the Unified Runtime extending it with more functionality (still gradually all moving to Unified Runtime). Since this is a short-living solution think these "bindings" appeared to be good enough.