-
Notifications
You must be signed in to change notification settings - Fork 800
[SYCL] Introduce the Level Zero plugin #1718
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
Changes from 13 commits
ba2ecb4
b0fabec
e59ed9a
a4b5c7c
120ee9c
5ff2e4d
8866e2c
097c595
4e56b22
8c655b8
0fd2f79
e8722f5
0a0aabf
9db2a3b
d76ea58
a1f740d
3d70ee3
8c75284
6b02205
aebdfe0
88559cf
3a92906
77e8a78
d2164f7
5cc9836
6a85a39
41ea7e2
a303cad
b792fce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,3 +5,4 @@ if(SYCL_BUILD_PI_CUDA) | |
| endif() | ||
|
|
||
| add_subdirectory(opencl) | ||
| add_subdirectory(level_zero) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| # PI Level0 plugin library | ||
|
|
||
| message(STATUS "Download Level Zero loader and headers from github.com") | ||
|
||
| if(MSVC) | ||
| set(L0_LIBRARY | ||
| "${LLVM_LIBRARY_OUTPUT_INTDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}ze_loader${CMAKE_STATIC_LIBRARY_SUFFIX}") | ||
| else() | ||
| set(L0_LIBRARY | ||
| "${LLVM_LIBRARY_OUTPUT_INTDIR}/${CMAKE_SHARED_LIBRARY_PREFIX}ze_loader${CMAKE_SHARED_LIBRARY_SUFFIX}") | ||
| endif() | ||
| 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}/l0_loader_build) | ||
| ExternalProject_Add(l0-loader | ||
| GIT_REPOSITORY https://github.com/oneapi-src/level-zero.git | ||
| GIT_TAG origin/master | ||
| SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/Level0/l0_loader" | ||
| BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/l0_loader_build" | ||
| INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/l0_loader_install" | ||
| CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} | ||
| -DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM} | ||
| -DOpenCL_INCLUDE_DIR=${OpenCL_INCLUDE_DIRS} | ||
| -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> | ||
| -DCMAKE_INSTALL_LIBDIR:PATH=lib${LLVM_LIBDIR_SUFFIX} | ||
| ${AUX_CMAKE_FLAGS} | ||
| STEP_TARGETS configure,build,install | ||
| DEPENDS ocl-headers | ||
| BUILD_BYPRODUCTS ${L0_LIBRARY} | ||
| ) | ||
| ExternalProject_Add_Step(l0-loader llvminstall | ||
|
||
| COMMAND ${CMAKE_COMMAND} -E copy_directory <INSTALL_DIR>/ ${LLVM_BINARY_DIR} | ||
| COMMENT "Installing l0-loader into the LLVM binary directory" | ||
| DEPENDEES install | ||
| ) | ||
|
|
||
| include_directories("${sycl_inc_dir}") | ||
| include_directories(${OPENCL_INCLUDE}) | ||
|
|
||
| add_library(pi_level0 SHARED | ||
| "${sycl_inc_dir}/CL/sycl/detail/pi.h" | ||
| "${CMAKE_CURRENT_SOURCE_DIR}/pi_level0.cpp" | ||
| "${CMAKE_CURRENT_SOURCE_DIR}/pi_level0.hpp" | ||
| ) | ||
|
|
||
| if (MSVC) | ||
| # by defining __SYCL_BUILD_SYCL_DLL, we can use __declspec(dllexport) | ||
| # which are individually tagged for all pi* symbols in pi.h | ||
| target_compile_definitions(pi_level0 PRIVATE __SYCL_BUILD_SYCL_DLL) | ||
| else() | ||
| # we set the visibility of all symbols 'hidden' by default. | ||
| # In pi.h file, we set exported symbols with visibility==default individually | ||
| target_compile_options(pi_level0 PUBLIC -fvisibility=hidden) | ||
|
|
||
| # This script file is used to allow exporting pi* symbols only. | ||
| # All other symbols are regarded as local (hidden) | ||
| set(linker_script "${CMAKE_CURRENT_SOURCE_DIR}/../ld-version-script.txt") | ||
|
|
||
| # Filter symbols based on the scope defined in the script file, | ||
| # and export pi* function symbols in the library. | ||
| target_link_libraries( pi_level0 | ||
| PRIVATE "-Wl,--version-script=${linker_script}" | ||
| ) | ||
| endif() | ||
|
|
||
| add_dependencies(pi_level0 l0-loader) | ||
| add_dependencies(sycl-toolchain pi_level0) | ||
|
|
||
| target_link_libraries(pi_level0 PRIVATE "${L0_LIBRARY}") | ||
| if (UNIX) | ||
| target_link_libraries(pi_level0 PRIVATE pthread) | ||
| endif() | ||
|
|
||
| add_common_options(pi_level0) | ||
|
|
||
| install(TARGETS pi_level0 | ||
| LIBRARY DESTINATION "lib" COMPONENT pi_level0 | ||
| RUNTIME DESTINATION "bin" COMPONENT pi_level0) | ||
Uh oh!
There was an error while loading. Please reload this page.