Skip to content

Commit 2a5e283

Browse files
hjabirdnormallytangent
authored andcommitted
[DFT][CMake] Check CUDA support with portFFT before using it as a target (#511)
* 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 This solves the issue in PR #495
1 parent 82f393c commit 2a5e283

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

.github/workflows/pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
options: -DTARGET_DOMAINS=blas -DREF_BLAS_ROOT=${PWD}/lapack/install -DENABLE_PORTBLAS_BACKEND=ON -DENABLE_MKLCPU_BACKEND=OFF -DPORTBLAS_TUNING_TARGET=INTEL_CPU
2525
tests: '.*'
2626
- config: portFFT
27-
options: -DENABLE_PORTFFT_BACKEND=ON -DENABLE_MKLCPU_BACKEND=OFF -DTARGET_DOMAINS=dft -DCMAKE_CXX_FLAGS="-fsycl -fsycl-targets=spir64"
27+
options: -DENABLE_PORTFFT_BACKEND=ON -DENABLE_MKLCPU_BACKEND=OFF -DTARGET_DOMAINS=dft
2828
tests: 'DFT/CT/.*ComputeTests_in_place_COMPLEX.COMPLEX_SINGLE_in_place_buffer.sizes_8_batches_1*'
2929
- config: MKL BLAS
3030
options: -DTARGET_DOMAINS=blas -DREF_BLAS_ROOT=${PWD}/lapack/install

cmake/FindCompiler.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ if(is_dpcpp)
3636
if(UNIX)
3737
set(UNIX_INTERFACE_COMPILE_OPTIONS -fsycl)
3838
set(UNIX_INTERFACE_LINK_OPTIONS -fsycl)
39+
# Check if the Nvidia target is supported. PortFFT uses this for choosing default configuration.
40+
check_cxx_compiler_flag("-fsycl -fsycl-targets=nvptx64-nvidia-cuda" dpcpp_supports_nvptx64)
41+
3942
if(ENABLE_CURAND_BACKEND OR ENABLE_CUSOLVER_BACKEND)
4043
list(APPEND UNIX_INTERFACE_COMPILE_OPTIONS
4144
-fsycl-targets=nvptx64-nvidia-cuda -fsycl-unnamed-lambda)

src/dft/backends/portfft/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ if (IS_DPCPP AND UNIX AND NOT FOUND_TARGETS)
3636
set(TARGETS_LINK_OPTIONS -fsycl-unnamed-lambda)
3737

3838
# spir64 must be last in the list due to a bug in dpcpp 2024.0.0
39-
set(TARGETS_TRIPLES "nvptx64-nvidia-cuda,spir64")
39+
set(TARGETS_TRIPLES "spir64")
40+
if(dpcpp_supports_nvptx64)
41+
set(TARGETS_TRIPLES nvptx64-nvidia-cuda,${TARGETS_TRIPLES})
42+
endif()
4043

4144
if (NOT (HIP_TARGETS STREQUAL ""))
4245
set(TARGETS_TRIPLES amdgcn-amd-amdhsa,${TARGETS_TRIPLES})
@@ -45,6 +48,8 @@ if (IS_DPCPP AND UNIX AND NOT FOUND_TARGETS)
4548
else()
4649
message(WARNING "Can't enable hip backend, HIP_TARGETS has not been set.")
4750
endif()
51+
52+
message(STATUS "portFFT target triple set to ${TARGETS_TRIPLES}")
4853

4954
list(APPEND TARGETS_COMPILE_OPTIONS -fsycl-targets=${TARGETS_TRIPLES})
5055
list(APPEND TARGETS_LINK_OPTIONS -fsycl-targets=${TARGETS_TRIPLES})

0 commit comments

Comments
 (0)