Skip to content

Commit

Permalink
Cleanup CMake options
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiashienzsch committed Sep 17, 2024
1 parent 4e83ec6 commit 7becc18
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
10 changes: 6 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# SPDX-FileCopyrightText: 2024 Tobias Hienzsch
cmake_minimum_required(VERSION 3.24)

option(PFFDTD_ENABLE_ACPP_SYCL "Build with AdaptiveCpp SYCL" OFF)
option(PFFDTD_ENABLE_INTEL_SYCL "Build with Intel SYCL" OFF)
option(PFFDTD_ENABLE_CUDA "Build with CUDA" OFF)
option(PFFDTD_ENABLE_SYCL_ACPP "Build with AdaptiveCpp SYCL" OFF)
option(PFFDTD_ENABLE_SYCL_ONEAPI "Build with Intel SYCL" OFF)

find_program(CCACHE ccache)
if (CCACHE)
Expand Down Expand Up @@ -36,12 +36,14 @@ find_package(fmt REQUIRED)
find_package(HDF5 REQUIRED)
find_package(OpenMP REQUIRED)

if(PFFDTD_ENABLE_ACPP_SYCL)
if(PFFDTD_ENABLE_SYCL_ACPP)
find_package(AdaptiveCpp REQUIRED)
set(PFFDTD_HAS_SYCL TRUE)
endif()

if(PFFDTD_ENABLE_INTEL_SYCL)
if(PFFDTD_ENABLE_SYCL_ONEAPI)
find_package(IntelSYCL REQUIRED)
set(PFFDTD_HAS_SYCL TRUE)
endif()

add_subdirectory(src/cpp)
Expand Down
6 changes: 3 additions & 3 deletions doc/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ cmake -S . -B build -G Ninja -D CMAKE_BUILD_TYPE=Release -D CMAKE_PROJECT_TOP_LE
Assumes that `AdaptiveCPP` was build with `clang++`:

```shell
cmake -S . -B build -G Ninja -D CMAKE_BUILD_TYPE=Release -D CMAKE_C_COMPILER=clang -D CMAKE_CXX_COMPILER=clang++ -D PFFDTD_ENABLE_ACPP_SYCL=ON -D AdaptiveCpp_DIR=/usr/local/lib/cmake/AdaptiveCpp -D ACPP_TARGETS="generic" -D CMAKE_PROJECT_TOP_LEVEL_INCLUDES=external/cmake-conan/conan_provider.cmake
cmake -S . -B build -G Ninja -D CMAKE_BUILD_TYPE=Release -D CMAKE_C_COMPILER=clang -D CMAKE_CXX_COMPILER=clang++ -D PFFDTD_ENABLE_SYCL_ACPP=ON -D AdaptiveCpp_DIR=/usr/local/lib/cmake/AdaptiveCpp -D ACPP_TARGETS="generic" -D CMAKE_PROJECT_TOP_LEVEL_INCLUDES=external/cmake-conan/conan_provider.cmake
```

### Intel oneAPI
Expand All @@ -51,7 +51,7 @@ cmake -S . -B build -G Ninja -D CMAKE_BUILD_TYPE=Release -D CMAKE_C_COMPILER=cla
```shell
source /opt/intel/oneapi/setvars.sh

cmake -S. -B build -G Ninja -D CMAKE_BUILD_TYPE=Release -D CMAKE_C_COMPILER=icx -D CMAKE_CXX_COMPILER=icpx -D PFFDTD_ENABLE_INTEL_SYCL=ON -D CMAKE_PROJECT_TOP_LEVEL_INCLUDES=external/cmake-conan/conan_provider.cmake -D CONAN_HOST_PROFILE=../cmake/profile/linux_sycl
cmake -S. -B build -G Ninja -D CMAKE_BUILD_TYPE=Release -D CMAKE_C_COMPILER=icx -D CMAKE_CXX_COMPILER=icpx -D PFFDTD_ENABLE_SYCL_ONEAPI=ON -D CMAKE_PROJECT_TOP_LEVEL_INCLUDES=external/cmake-conan/conan_provider.cmake -D CONAN_HOST_PROFILE=../cmake/profile/linux_sycl
cmake --build build

# Using hyper-threads is usally a slow down. Use the number of physical cores.
Expand Down Expand Up @@ -92,5 +92,5 @@ Currently not supported. Has issues building HDF5 from source via conan.
# Or: Set environment variables
. 'C:\Program Files (x86)\Intel\oneAPI\setvars.bat'

cmake -S . -B build -G Ninja -D PFFDTD_ENABLE_INTEL_SYCL=ON -D CMAKE_BUILD_TYPE=Release -D CMAKE_C_COMPILER=icx -D CMAKE_CXX_COMPILER=icx -D CMAKE_PROJECT_TOP_LEVEL_INCLUDES=external/cmake-conan/conan_provider.cmake -D CONAN_HOST_PROFILE=../cmake/profile/windows_sycl
cmake -S . -B build -G Ninja -D PFFDTD_ENABLE_SYCL_ONEAPI=ON -D CMAKE_BUILD_TYPE=Release -D CMAKE_C_COMPILER=icx -D CMAKE_CXX_COMPILER=icx -D CMAKE_PROJECT_TOP_LEVEL_INCLUDES=external/cmake-conan/conan_provider.cmake -D CONAN_HOST_PROFILE=../cmake/profile/windows_sycl
```
2 changes: 1 addition & 1 deletion src/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ target_sources(pffdtd

target_compile_definitions(pffdtd PUBLIC _CRT_SECURE_NO_WARNINGS=1)

if(PFFDTD_ENABLE_ACPP_SYCL OR PFFDTD_ENABLE_INTEL_SYCL)
if(PFFDTD_HAS_SYCL)
target_compile_definitions(pffdtd PUBLIC PFFDTD_HAS_SYCL=1)
endif()

Expand Down
5 changes: 4 additions & 1 deletion src/cpp/main_2d/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ project(pffdtd_2d)
add_executable(pffdtd_2d main.cpp engine_native.cpp)
target_link_libraries(pffdtd_2d PRIVATE CLI11::CLI11 pffdtd::pffdtd)

if(PFFDTD_ENABLE_ACPP_SYCL OR PFFDTD_ENABLE_INTEL_SYCL)
if(PFFDTD_HAS_SYCL)
target_sources(pffdtd_2d PRIVATE engine_sycl.cpp)
add_sycl_to_target(TARGET pffdtd_2d SOURCES engine_sycl.cpp)
endif()

if(PFFDTD_ENABLE_SYCL_ONEAPI)
set_source_files_properties(engine_sycl.cpp PROPERTIES COMPILE_FLAGS "-fsycl-targets=nvptx64-nvidia-cuda")
target_link_libraries(pffdtd_2d PRIVATE "-fsycl-targets=nvptx64-nvidia-cuda")
endif()

0 comments on commit 7becc18

Please sign in to comment.