Skip to content

Commit

Permalink
Level Zero support with OpenSYCL
Browse files Browse the repository at this point in the history
  • Loading branch information
emdant committed May 26, 2023
1 parent a4f0f03 commit 5ab2dfa
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
17 changes: 13 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,19 @@ option(SYNERGY_CUDA_SUPPORT "Enable CUDA support" OFF)
option(SYNERGY_ROCM_SUPPORT "Enable ROCm support" OFF)
option(SYNERGY_LZ_SUPPORT "Enable Level Zero Support" OFF)

set(SYNERGY_SYCL_BACKEND "" CACHE STRING "Select SYCL backend [hipSYCL | dpcpp]")

if(SYNERGY_SYCL_BACKEND STREQUAL hipSYCL)
find_package(hipSYCL REQUIRED)
set(SYNERGY_SYCL_IMPL "" CACHE STRING "Select SYCL implementation [OpenSYCL | DPC++]")
set_property(CACHE SYNERGY_SYCL_IMPL PROPERTY STRINGS "OpenSYCL" "DPC++")

if(SYNERGY_SYCL_IMPL STREQUAL "OpenSYCL")
find_package(OpenSYCL)

if(NOT OpenSYCL_FOUND)
find_package(hipSYCL)
endif()

if(NOT OpenSYCL_FOUND AND NOT hipSYCL_FOUND)
message(SEND_ERROR "OpenSYCL or hipSYCL package were not found. Specify OpenSYCL_DIR or hipSYCL_DIR.")
endif()
endif()

if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ Currently supported target architectures:
- cmake (3.17 or newer)
- C++17 or newer compiler
- A supported SYCL implementation:
- hipSYCL
- DPC++
- OpenSYCL
- A supported target architecture
- CUDA with NVML
- ROCm with ROCm SMI
- LevelZero with Sysman
- Level Zero with Sysman

To build SYnergy samples, type:
```bash
cd SYnergy
mkdir build && cd build/
cmake .. -DSYNERGY_BUILD_SAMPLES=ON -DSYNERGY_SYCL_BACKEND=[hipSYCL | dpcpp] -DSYNERGY_CUDA_SUPPORT=[ON | OFF] -DSYNERGY_ROCM_SUPPORT=[ON | OFF]
cd SYnergy
mkdir build && cd build/
cmake .. -DSYNERGY_BUILD_SAMPLES=ON -DSYNERGY_SYCL_BACKEND=[OpenSYCL | DPC++] -DSYNERGY_CUDA_SUPPORT=[ON | OFF] -DSYNERGY_ROCM_SUPPORT=[ON | OFF]
```

## Usage
Expand Down
3 changes: 2 additions & 1 deletion include/runtime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ class runtime {
#endif

#ifdef SYNERGY_LZ_SUPPORT
if (platform_name.find("level-zero") != std::string::npos) {
if (platform_name.find("level-zero") != std::string::npos ||
platform_name.find("level zero") != std::string::npos) {
auto devs = platforms[i].get_devices(info::device_type::gpu);
for (int j = 0; j < devs.size(); j++) {
auto ptr = std::make_shared<vendor_device<management::lz>>(j);
Expand Down
8 changes: 6 additions & 2 deletions samples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ link_libraries(synergy)

option(SYNERGY_SAMPLES_ALL_WARNINGS "Enable all warnings during SYnergy samples compilation" OFF)

if(SYNERGY_SYCL_IMPL STREQUAL "OpenSYCL" AND SYNERGY_LZ_SUPPORT)
message(STATUS "The supported OpenSYCL target for Level Zero is \"sscp\"")
endif()

add_executable(matrix_mul matrix_mul/matrix_mul.cpp)
add_executable(query_freq query_freq/query_freq.cpp)
add_executable(saxpy saxpy/saxpy.cpp)
Expand All @@ -10,7 +14,7 @@ add_executable(concurrent_matmul concurrent_matmul/concurrent_matmul.cpp)
get_directory_property(all_targets BUILDSYSTEM_TARGETS)

foreach(target IN LISTS all_targets)
if(SYNERGY_SYCL_BACKEND STREQUAL hipSYCL)
if(SYNERGY_SYCL_IMPL STREQUAL "OpenSYCL")
add_sycl_to_target(TARGET ${target})
endif()

Expand All @@ -23,7 +27,7 @@ foreach(target IN LISTS all_targets)
)
endif()

if(SYNERGY_SYCL_BACKEND STREQUAL "dpcpp") # CMAKE_CXX_COMPILER must be set to clang++
if(SYNERGY_SYCL_IMPL STREQUAL "DPC++") # CMAKE_CXX_COMPILER must be set to clang++
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsycl")

if(SYNERGY_CUDA_SUPPORT)
Expand Down

0 comments on commit 5ab2dfa

Please sign in to comment.