From 8145d533ddb1705c5e4cdbd566f2e74d6295f3cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20L=C3=BCbke?= Date: Fri, 6 Oct 2023 15:31:40 +0200 Subject: [PATCH] adapt CMake and Readme --- CMakeLists.txt | 27 ++++++++++++++++++++++++++- README.org | 25 ++++++++++++++++++++++++- src/CMakeLists.txt | 4 +++- 3 files changed, 53 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 93a0b06..b2b8704 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,8 +4,33 @@ set(CMAKE_CXX_STANDARD 17) project(sycl_example) -find_package(AdaptiveCpp REQUIRED) +option(USE_INTELSYCL "Use Intel oneAPI compiler" OFF) +option(USE_ACPP "Use AdaptiveCpp compiler" OFF) + +if(USE_INTELSYCL AND USE_ACPP) + message(FATAL_ERROR "Only one SYCL compiler can be selected.") +endif() + +if(USE_INTELSYCL) + find_package(IntelSYCL REQUIRED) +elseif(USE_ACPP) + find_package(AdaptiveCpp REQUIRED) +else() + message(FATAL_ERROR "Set either -DUSE_INTELSYCL or -DUSE_ACPP.") +endif() + + find_library(LIB_XXHASH xxhash) +message(STATUS "${IntelSYCL_FOUND}") + +if ((NOT(AdaptiveCpp_FOUND)) AND (NOT(IntelSYCL_FOUND))) + message(FATAL_ERROR + "Could not find either AdaptiveCpp or IntelDPCPP. + Install one of them and provide -D_DIR=/path/to/cmake/config. + Configuration not possible.") +endif() + + add_subdirectory(src) diff --git a/README.org b/README.org index 4662904..29dcd7d 100644 --- a/README.org +++ b/README.org @@ -35,6 +35,28 @@ To use the project, you'll need the following prerequisites: * Compilation +** Using Intel oneAPI + +Finally, I've made to code run with Intel's oneAPI and adapated the CMake +generation process. + +#+BEGIN_SRC bash +# Make sure to source Intels vars together with the inbuild llvm! +. /opt/intel/oneapi/setvars.sh --include-intel-llvm + +# Create a build directory and navigate to it +mkdir build && cd build + +# Adjust the path to AdaptiveCpp and your target devices according to your system +CXX=$(which clang++) cmake .. -DUSE_INTELSYCL=ON \ + -DCMAKE_BUILD_TYPE="Release" + +# Compile the executable +make +#+END_SRC + +** Using AdaptiveCpp + Regrettably, integrating Intel's oneAPI with the AMD GPU plugin proves to be quite challenging on Arch Linux, primarily due to the plugin's dependency on an older version of ROCm than what's available in the official repositories. While @@ -59,7 +81,8 @@ To generate Makefiles for AdaptiveCpp, you can follow these steps: mkdir build && cd build # Adjust the path to AdaptiveCpp and your target devices according to your system -cmake .. -DAdaptiveCpp_DIR=/opt/AdaptiveCpp/ROCm/lib/cmake/AdaptiveCpp \ +cmake .. -DUSE_ACPP=ON \ + -DAdaptiveCpp_DIR=/opt/AdaptiveCpp/ROCm/lib/cmake/AdaptiveCpp \ -DACPP_TARGETS="omp.accelerated;hip.integrated-multipass;gfx90c" \ -DCMAKE_BUILD_TYPE="Release" #+END_SRC diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2b37423..341ea59 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,7 @@ add_executable(sycl_comp sycl_comp.cpp) -add_sycl_to_target(TARGET sycl_comp) + +add_sycl_to_target(TARGET sycl_comp SOURCES sycl_comp.cpp) + target_link_libraries(sycl_comp PRIVATE ${LIB_XXHASH}) option(SYCL_EX_COMPILE_SEQUENTIAL_BENCH