Skip to content

Commit

Permalink
[DFT][CMake] Check CUDA support with portFFT before using it as a target
Browse files Browse the repository at this point in the history
* The portFFT backends targets Nvidia by default
* In some situations, this causes a failure whilst compiling (CUDA might not be installed)
* This checks the target is supported before use
  • Loading branch information
hjabird committed Jun 12, 2024
1 parent 91a9120 commit e74738c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions cmake/FindCompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ if(is_dpcpp)
if(UNIX)
set(UNIX_INTERFACE_COMPILE_OPTIONS -fsycl)
set(UNIX_INTERFACE_LINK_OPTIONS -fsycl)
# Check if the Nvidia target is supported. PortFFT uses this for choosing default configuration.
check_cxx_compiler_flag("-fsycl -fsycl-targets=nvptx64-nvidia-cuda" dpcpp_supports_nvptx64)

if(ENABLE_CURAND_BACKEND OR ENABLE_CUSOLVER_BACKEND)
list(APPEND UNIX_INTERFACE_COMPILE_OPTIONS
-fsycl-targets=nvptx64-nvidia-cuda -fsycl-unnamed-lambda)
Expand Down
8 changes: 7 additions & 1 deletion src/dft/backends/portfft/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ if (IS_DPCPP AND UNIX AND NOT FOUND_TARGETS)
set(TARGETS_LINK_OPTIONS -fsycl-unnamed-lambda)

# spir64 must be last in the list due to a bug in dpcpp 2024.0.0
set(TARGETS_TRIPLES "nvptx64-nvidia-cuda,spir64")
if(dpcpp_supports_nvptx64)
set(TARGETS_TRIPLES "nvptx64-nvidia-cuda,spir64")
else()
set(TARGETS_TRIPLES "spir64")
endif()

if (NOT (HIP_TARGETS STREQUAL ""))
set(TARGETS_TRIPLES amdgcn-amd-amdhsa,${TARGETS_TRIPLES})
Expand All @@ -45,6 +49,8 @@ if (IS_DPCPP AND UNIX AND NOT FOUND_TARGETS)
else()
message(WARNING "Can't enable hip backend, HIP_TARGETS has not been set.")
endif()

message(STATUS "portFFT target triple set to ${TARGETS_TRIPLES}")

list(APPEND TARGETS_COMPILE_OPTIONS -fsycl-targets=${TARGETS_TRIPLES})
list(APPEND TARGETS_LINK_OPTIONS -fsycl-targets=${TARGETS_TRIPLES})
Expand Down

0 comments on commit e74738c

Please sign in to comment.