From 5ab2dfa1ff5e4ade0808ad2ca05dba8fa2e1f8dd Mon Sep 17 00:00:00 2001 From: emdant <30555419+emdant@users.noreply.github.com> Date: Fri, 26 May 2023 23:41:40 +0200 Subject: [PATCH] Level Zero support with OpenSYCL --- CMakeLists.txt | 17 +++++++++++++---- README.md | 10 +++++----- include/runtime.hpp | 3 ++- samples/CMakeLists.txt | 8 ++++++-- 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 97d0fa6..fd2dc23 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/README.md b/README.md index 122b74d..6c81552 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/include/runtime.hpp b/include/runtime.hpp index f6b0cbe..d5268cf 100644 --- a/include/runtime.hpp +++ b/include/runtime.hpp @@ -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>(j); diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index e1097c3..107dbcd 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -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) @@ -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() @@ -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)