Skip to content

Commit

Permalink
[SYCL] Changed sycl::backend::level0 to sycl::backend::level_zero (in…
Browse files Browse the repository at this point in the history
…tel#2025)

PI_LEVEL0 -> PI_LEVEL_ZERO. 
PI_LEVEL0 is still accepted and handled correctly.

Signed-off-by: Gail Lyons <[email protected]>
  • Loading branch information
glyons-intel authored Jul 30, 2020
1 parent 0bc2441 commit 215f591
Show file tree
Hide file tree
Showing 41 changed files with 267 additions and 260 deletions.
4 changes: 2 additions & 2 deletions sycl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ include(AddSYCLExecutable)
set(SYCL_MAJOR_VERSION 2)
set(SYCL_MINOR_VERSION 1)
set(SYCL_PATCH_VERSION 0)
set(SYCL_DEV_ABI_VERSION 3)
set(SYCL_DEV_ABI_VERSION 4)
if (SYCL_ADD_DEV_VERSION_POSTFIX)
set(SYCL_VERSION_POSTFIX "-${SYCL_DEV_ABI_VERSION}")
endif()
Expand Down Expand Up @@ -326,7 +326,7 @@ set( SYCL_TOOLCHAIN_DEPLOY_COMPONENTS
sycl-headers-extras
sycl
pi_opencl
pi_level0
pi_level_zero
libsycldevice
)
if(OpenCL_INSTALL_KHRONOS_ICD_LOADER AND TARGET ocl-icd)
Expand Down
2 changes: 1 addition & 1 deletion sycl/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Release notes for the commit range ba404be..24726df
- Added a cache for PI plugins, so subsequent calls for `sycl::device`
creation should be cheaper [03dd60d]
- A SYCL program will be aborted now if program linking is requested when
using L0 plugin. This is done because L0 doesn't support program linking
using Level Zero plugin. This is done because L0 doesn't support program linking
[d4a5b71]
- Added a diagnostic on attempt to use `sycl::program::set_spec_constant` when
the program is already in compiled or linked state [e2e3d3d]
Expand Down
4 changes: 2 additions & 2 deletions sycl/doc/EnvironmentVariables.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Environment Variables

This document describes environment variables that are having effect on DPC++
This document describes environment variables that are having effect on DPC++
compiler and runtime.

## Controlling DPC++ RT
Expand All @@ -12,7 +12,7 @@ subject to change. Do not rely on these variables in production code.
| Environment variable | Values | Description |
| -------------------- | ------ | ----------- |
| SYCL_PI_TRACE | Described [below](#sycl_pi_trace-options) | Enable specified level of tracing for PI. |
| SYCL_BE | PI_OPENCL, PI_LEVEL0, PI_CUDA | Force SYCL RT to consider only devices of the specified backend during the device selection. |
| SYCL_BE | PI_OPENCL, PI_LEVEL_ZERO, PI_CUDA | Force SYCL RT to consider only devices of the specified backend during the device selection. |
| 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. |
| SYCL_PROGRAM_COMPILE_OPTIONS | String of valid OpenCL compile options | Override compile options for all programs. |
| SYCL_PROGRAM_LINK_OPTIONS | String of valid OpenCL link options | Override link options for all programs. |
Expand Down
32 changes: 16 additions & 16 deletions sycl/include/CL/sycl/backend/level_zero.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,37 @@
__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {

template <> struct interop<backend::level0, platform> {
template <> struct interop<backend::level_zero, platform> {
using type = ze_driver_handle_t;
};

template <> struct interop<backend::level0, device> {
template <> struct interop<backend::level_zero, device> {
using type = ze_device_handle_t;
};

template <> struct interop<backend::level0, queue> {
template <> struct interop<backend::level_zero, queue> {
using type = ze_command_queue_handle_t;
};

template <> struct interop<backend::level0, program> {
template <> struct interop<backend::level_zero, program> {
using type = ze_module_handle_t;
};

template <typename DataT, int Dimensions, access::mode AccessMode>
struct interop<backend::level0, accessor<DataT, Dimensions, AccessMode,
access::target::global_buffer,
access::placeholder::false_t>> {
struct interop<backend::level_zero, accessor<DataT, Dimensions, AccessMode,
access::target::global_buffer,
access::placeholder::false_t>> {
using type = char *;
};

template <typename DataT, int Dimensions, access::mode AccessMode>
struct interop<backend::level0, accessor<DataT, Dimensions, AccessMode,
access::target::constant_buffer,
access::placeholder::false_t>> {
struct interop<backend::level_zero, accessor<DataT, Dimensions, AccessMode,
access::target::constant_buffer,
access::placeholder::false_t>> {
using type = char *;
};

namespace level0 {
namespace level_zero {

// Implementation of various "make" functions resides in libsycl.so
platform make_platform(pi_native_handle NativeHandle);
Expand All @@ -55,34 +55,34 @@ queue make_queue(const context &Context, pi_native_handle InteropHandle);
// Construction of SYCL platform.
template <typename T, typename std::enable_if<
std::is_same<T, platform>::value>::type * = nullptr>
T make(typename interop<backend::level0, T>::type Interop) {
T make(typename interop<backend::level_zero, T>::type Interop) {
return make_platform(reinterpret_cast<pi_native_handle>(Interop));
}

// Construction of SYCL device.
template <typename T, typename std::enable_if<
std::is_same<T, device>::value>::type * = nullptr>
T make(const platform &Platform,
typename interop<backend::level0, T>::type Interop) {
typename interop<backend::level_zero, T>::type Interop) {
return make_device(Platform, reinterpret_cast<pi_native_handle>(Interop));
}

// Construction of SYCL program.
template <typename T, typename std::enable_if<
std::is_same<T, program>::value>::type * = nullptr>
T make(const context &Context,
typename interop<backend::level0, T>::type Interop) {
typename interop<backend::level_zero, T>::type Interop) {
return make_program(Context, reinterpret_cast<pi_native_handle>(Interop));
}

// Construction of SYCL queue.
template <typename T, typename std::enable_if<
std::is_same<T, queue>::value>::type * = nullptr>
T make(const context &Context,
typename interop<backend::level0, T>::type Interop) {
typename interop<backend::level_zero, T>::type Interop) {
return make_queue(Context, reinterpret_cast<pi_native_handle>(Interop));
}

} // namespace level0
} // namespace level_zero
} // namespace sycl
} // __SYCL_INLINE_NAMESPACE(cl)
4 changes: 2 additions & 2 deletions sycl/include/CL/sycl/backend_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {

enum class backend : char { host, opencl, level0, cuda };
enum class backend : char { host, opencl, level_zero, cuda };

template <backend name, typename SYCLObjectT> struct interop;

Expand All @@ -30,7 +30,7 @@ inline std::ostream &operator<<(std::ostream &Out, backend be) {
case backend::opencl:
Out << std::string("opencl");
break;
case backend::level0:
case backend::level_zero:
Out << std::string("level-zero");
break;
case backend::cuda:
Expand Down
4 changes: 2 additions & 2 deletions sycl/include/CL/sycl/detail/pi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ bool trace(TraceLevel level);

#ifdef SYCL_RT_OS_WINDOWS
#define OPENCL_PLUGIN_NAME "pi_opencl.dll"
#define LEVEL0_PLUGIN_NAME "pi_level0.dll"
#define LEVEL_ZERO_PLUGIN_NAME "pi_level_zero.dll"
#define CUDA_PLUGIN_NAME "pi_cuda.dll"
#else
#define OPENCL_PLUGIN_NAME "libpi_opencl.so"
#define LEVEL0_PLUGIN_NAME "libpi_level0.so"
#define LEVEL_ZERO_PLUGIN_NAME "libpi_level_zero.so"
#define CUDA_PLUGIN_NAME "libpi_cuda.so"
#endif

Expand Down
84 changes: 42 additions & 42 deletions sycl/plugins/level_zero/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
# PI Level0 plugin library
# PI Level Zero plugin library

if(MSVC)
set(L0_LOADER
set(LEVEL_ZERO_LOADER
"${LLVM_LIBRARY_OUTPUT_INTDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}ze_loader${CMAKE_STATIC_LIBRARY_SUFFIX}")
else()
set(L0_LOADER
set(LEVEL_ZERO_LOADER
"${LLVM_LIBRARY_OUTPUT_INTDIR}/${CMAKE_SHARED_LIBRARY_PREFIX}ze_loader${CMAKE_SHARED_LIBRARY_SUFFIX}")
endif()

if (NOT DEFINED L0_LIBRARY OR NOT DEFINED L0_INCLUDE_DIR)
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}/l0_loader_build)
set(L0_LOADER_SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/Level0/l0_loader")
if (NOT DEFINED SYCL_EP_L0_LOADER_SKIP_AUTO_UPDATE)
set(SYCL_EP_L0_LOADER_SKIP_AUTO_UPDATE ${SYCL_EXTERNAL_PROJECTS_SKIP_AUTO_UPDATE})
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()
ExternalProject_Add(l0-loader
ExternalProject_Add(level-zero-loader
GIT_REPOSITORY https://github.com/oneapi-src/level-zero.git
GIT_TAG v0.91.21
UPDATE_DISCONNECTED ${SYCL_EP_L0_LOADER_SKIP_AUTO_UPDATE}
SOURCE_DIR ${L0_LOADER_SOURCE_DIR}
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/l0_loader_build"
INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/l0_loader_install"
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}
-DOpenCL_INCLUDE_DIR=${OpenCL_INCLUDE_DIRS}
Expand All @@ -36,74 +36,74 @@ if (NOT DEFINED L0_LIBRARY OR NOT DEFINED L0_INCLUDE_DIR)
${AUX_CMAKE_FLAGS}
STEP_TARGETS configure,build,install
DEPENDS ocl-headers
BUILD_BYPRODUCTS ${L0_LOADER}
BUILD_BYPRODUCTS ${LEVEL_ZERO_LOADER}
)
ExternalProject_Add_Step(l0-loader llvminstall
ExternalProject_Add_Step(level-zero-loader llvminstall
COMMAND ${CMAKE_COMMAND} -E copy_directory <INSTALL_DIR>/ ${LLVM_BINARY_DIR}
COMMENT "Installing l0-loader into the LLVM binary directory"
COMMENT "Installing level-zero-loader into the LLVM binary directory"
DEPENDEES install
)

install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/l0_loader_install/"
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/level_zero_loader_install/"
DESTINATION "."
COMPONENT l0-loader
COMPONENT level-zero-loader
)

list(APPEND SYCL_TOOLCHAIN_DEPLOY_COMPONENTS l0-loader)
list(APPEND SYCL_TOOLCHAIN_DEPLOY_COMPONENTS level-zero-loader)
else()
include_directories("${L0_INCLUDE_DIR}")
file(GLOB L0_LIBRARY_SRC "${L0_LIBRARY}*")
file(COPY ${L0_LIBRARY_SRC} DESTINATION ${LLVM_LIBRARY_OUTPUT_INTDIR})
add_custom_target(l0-loader DEPENDS ${L0_LIBRARY} COMMENT "Copying Level Zero Loader ...")
include_directories("${LEVEL_ZERO_INCLUDE_DIR}")
file(GLOB LEVEL_ZERO_LIBRARY_SRC "${LEVEL_ZERO_LIBRARY}*")
file(COPY ${LEVEL_ZERO_LIBRARY_SRC} DESTINATION ${LLVM_LIBRARY_OUTPUT_INTDIR})
add_custom_target(level-zero-loader DEPENDS ${LEVEL_ZERO_LIBRARY} COMMENT "Copying Level Zero Loader ...")
endif()

add_library (L0Loader-Headers INTERFACE)
add_library (L0Loader::Headers ALIAS L0Loader-Headers)
target_include_directories(L0Loader-Headers
INTERFACE "${L0_INCLUDE_DIR}"
add_library (LevelZeroLoader-Headers INTERFACE)
add_library (LevelZeroLoader::Headers ALIAS LevelZeroLoader-Headers)
target_include_directories(LevelZeroLoader-Headers
INTERFACE "${LEVEL_ZERO_INCLUDE_DIR}"
)

include_directories("${sycl_inc_dir}")
include_directories(${OPENCL_INCLUDE})

add_library(pi_level0 SHARED
add_library(pi_level_zero SHARED
"${sycl_inc_dir}/CL/sycl/detail/pi.h"
"${CMAKE_CURRENT_SOURCE_DIR}/pi_level0.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/pi_level0.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/pi_level_zero.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/pi_level_zero.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)
target_compile_definitions(pi_level_zero 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)
target_compile_options(pi_level_zero 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
target_link_libraries( pi_level_zero
PRIVATE "-Wl,--version-script=${linker_script}"
)
endif()

if (TARGET l0-loader)
add_dependencies(pi_level0 l0-loader)
if (TARGET level-zero-loader)
add_dependencies(pi_level_zero level-zero-loader)
endif()
add_dependencies(sycl-toolchain pi_level0)
add_dependencies(sycl-toolchain pi_level_zero)

target_link_libraries(pi_level0 PRIVATE "${L0_LOADER}")
target_link_libraries(pi_level_zero PRIVATE "${LEVEL_ZERO_LOADER}")
if (UNIX)
target_link_libraries(pi_level0 PRIVATE pthread)
target_link_libraries(pi_level_zero PRIVATE pthread)
endif()

add_common_options(pi_level0)
add_common_options(pi_level_zero)

install(TARGETS pi_level0
LIBRARY DESTINATION "lib" COMPONENT pi_level0
RUNTIME DESTINATION "bin" COMPONENT pi_level0)
install(TARGETS pi_level_zero
LIBRARY DESTINATION "lib" COMPONENT pi_level_zero
RUNTIME DESTINATION "bin" COMPONENT pi_level_zero)
Loading

0 comments on commit 215f591

Please sign in to comment.