Skip to content

Commit ba2ecb4

Browse files
committed
[SYCL] Introduce the Level Zero plugin
Plugin itself consists of the header and the source file plus cmake file to build the plugin. Also the following changes were made to suport the Level Zero plugin in SYCL RT: * New level0 value was added to backend enum * New PI_LEVEL0 value support was added to SYCL_BE config. * Docs were updated. Mentioned Level Zero backend and provided the link to the Level Zero runtime for Intel GPU. * Changes in sycl cmake file to build level0 plugin by default and to install it with sycl toolchain. LIT testing with PI_LEVEL0 backend will be enabled in the following commits. This commits introduces the plugin and makes it buildable. Signed-off-by: Artur Gainullin <[email protected]>
1 parent 249e57b commit ba2ecb4

File tree

11 files changed

+4149
-7
lines changed

11 files changed

+4149
-7
lines changed

sycl/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ set( SYCL_TOOLCHAIN_DEPLOY_COMPONENTS
304304
sycl-headers-extras
305305
sycl
306306
pi_opencl
307+
pi_level0
307308
libsycldevice
308309
)
309310
if(OpenCL_INSTALL_KHRONOS_ICD_LOADER AND TARGET ocl-icd)

sycl/doc/EnvironmentVariables.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ subject to change. Do not rely on these variables in production code.
1212
| Environment variable | Values | Description |
1313
| -------------------- | ------ | ----------- |
1414
| SYCL_PI_TRACE | Described [below](#sycl_pi_trace-options) | Enable specified level of tracing for PI. |
15-
| SYCL_BE | PI_OPENCL, PI_CUDA | Force SYCL RT to consider only devices of the specified backend during the device selection. |
15+
| SYCL_BE | PI_OPENCL, PI_LEVEL0, PI_CUDA | Force SYCL RT to consider only devices of the specified backend during the device selection. |
1616
| SYCL_DEVICE_TYPE | One of: CPU, GPU, ACC, HOST | Force SYCL to use the specified device type. If unset, default selection rules are applied. If set to any unlisted value, this control has no effect. If the requested device type is not found, a `cl::sycl::runtime_error` exception is thrown. If a non-default device selector is used, a device must satisfy both the selector and this control to be chosen. This control only has effect on devices created with a selector. |
1717
| SYCL_PROGRAM_COMPILE_OPTIONS | String of valid OpenCL compile options | Override compile options for all programs. |
1818
| SYCL_PROGRAM_LINK_OPTIONS | String of valid OpenCL link options | Override link options for all programs. |

sycl/doc/GetStartedGuide.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,15 @@ which contains all the symbols required.
164164
To run DPC++ applications on OpenCL devices, OpenCL implementation(s) must be
165165
present in the system.
166166

167+
To run DPC++ applications on Level Zero devices, Level Zero implementation(s)
168+
must be present in the system.
169+
167170
Please, refer to [the Release Notes](../ReleaseNotes.md) for recommended Intel
168171
runtime versions.
169172

170-
The `GPU` runtime that is needed to run DPC++ application on Intel `GPU` devices
171-
can be downloaded from the following web pages:
173+
To run DPC++ application on Intel `GPU` devices the OpenCL `GPU` runtime or the
174+
Level Zero `GPU` runtime is needed. They can be downloaded from the following web
175+
pages:
172176

173177
* Linux: [Intel&reg; Graphics Compute Runtime for
174178
OpenCL&trade;](https://github.com/intel/compute-runtime/releases)

sycl/include/CL/sycl/backend_types.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
__SYCL_INLINE_NAMESPACE(cl) {
1414
namespace sycl {
1515

16-
enum class backend { host, opencl, cuda };
16+
enum class backend { host, opencl, level0, cuda };
1717

1818
template <backend name, typename SYCLObjectT> struct interop;
1919

sycl/include/CL/sycl/detail/pi.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,11 @@ bool trace(TraceLevel level);
5757

5858
#ifdef SYCL_RT_OS_WINDOWS
5959
#define OPENCL_PLUGIN_NAME "pi_opencl.dll"
60+
#define LEVEL0_PLUGIN_NAME "pi_level0.dll"
6061
#define CUDA_PLUGIN_NAME "pi_cuda.dll"
6162
#else
6263
#define OPENCL_PLUGIN_NAME "libpi_opencl.so"
64+
#define LEVEL0_PLUGIN_NAME "libpi_level0.so"
6365
#define CUDA_PLUGIN_NAME "libpi_cuda.so"
6466
#endif
6567

sycl/plugins/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ if(SYCL_BUILD_PI_CUDA)
55
endif()
66

77
add_subdirectory(opencl)
8+
add_subdirectory(Intel_level0)
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# PI Level0 plugin library
2+
3+
message(STATUS "Download Level Zero loader and headers from github.com")
4+
if(MSVC)
5+
set(L0_LIBRARY
6+
"${LLVM_LIBRARY_OUTPUT_INTDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}ze_loader${CMAKE_STATIC_LIBRARY_SUFFIX}")
7+
else()
8+
set(L0_LIBRARY
9+
"${LLVM_LIBRARY_OUTPUT_INTDIR}/${CMAKE_SHARED_LIBRARY_PREFIX}ze_loader${CMAKE_SHARED_LIBRARY_SUFFIX}")
10+
endif()
11+
if (CMAKE_C_COMPILER)
12+
list(APPEND AUX_CMAKE_FLAGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER})
13+
endif()
14+
if (CMAKE_CXX_COMPILER)
15+
list(APPEND AUX_CMAKE_FLAGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER})
16+
endif()
17+
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/l0_loader_build)
18+
ExternalProject_Add(l0-loader
19+
GIT_REPOSITORY https://github.com/oneapi-src/level-zero.git
20+
GIT_TAG origin/master
21+
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/Level0/l0_loader"
22+
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/l0_loader_build"
23+
INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/l0_loader_install"
24+
CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
25+
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
26+
-DOpenCL_INCLUDE_DIR=${OpenCL_INCLUDE_DIRS}
27+
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
28+
-DCMAKE_INSTALL_LIBDIR:PATH=lib${LLVM_LIBDIR_SUFFIX}
29+
${AUX_CMAKE_FLAGS}
30+
STEP_TARGETS configure,build,install
31+
DEPENDS ocl-headers
32+
BUILD_BYPRODUCTS ${L0_LIBRARY}
33+
)
34+
ExternalProject_Add_Step(l0-loader llvminstall
35+
COMMAND ${CMAKE_COMMAND} -E copy_directory <INSTALL_DIR>/ ${LLVM_BINARY_DIR}
36+
COMMENT "Installing l0-loader into the LLVM binary directory"
37+
DEPENDEES install
38+
)
39+
40+
include_directories("${sycl_inc_dir}")
41+
include_directories(${OPENCL_INCLUDE})
42+
43+
add_library(pi_level0 SHARED
44+
"${sycl_inc_dir}/CL/sycl/detail/pi.h"
45+
"${CMAKE_CURRENT_SOURCE_DIR}/pi_level0.cpp"
46+
"${CMAKE_CURRENT_SOURCE_DIR}/pi_level0.hpp"
47+
)
48+
49+
add_dependencies(pi_level0 l0-loader)
50+
add_dependencies(sycl-toolchain pi_level0)
51+
52+
target_link_libraries(pi_level0 PRIVATE "${L0_LIBRARY}")
53+
if (UNIX)
54+
target_link_libraries(pi_level0 PRIVATE pthread)
55+
endif()
56+
57+
add_common_options(pi_level0)
58+
59+
install(TARGETS pi_level0
60+
LIBRARY DESTINATION "lib" COMPONENT pi_level0
61+
RUNTIME DESTINATION "bin" COMPONENT pi_level0)

0 commit comments

Comments
 (0)