From e74738c366f367eaf966117076d630b6dd42e545 Mon Sep 17 00:00:00 2001 From: Hugh Bird Date: Wed, 12 Jun 2024 10:28:42 +0100 Subject: [PATCH 1/2] [DFT][CMake] Check CUDA support with portFFT before using it as a target * 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 --- cmake/FindCompiler.cmake | 3 +++ src/dft/backends/portfft/CMakeLists.txt | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/cmake/FindCompiler.cmake b/cmake/FindCompiler.cmake index 9b1e54a9f..aeb7ad43d 100644 --- a/cmake/FindCompiler.cmake +++ b/cmake/FindCompiler.cmake @@ -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) diff --git a/src/dft/backends/portfft/CMakeLists.txt b/src/dft/backends/portfft/CMakeLists.txt index 6741875f2..7e7119e50 100644 --- a/src/dft/backends/portfft/CMakeLists.txt +++ b/src/dft/backends/portfft/CMakeLists.txt @@ -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}) @@ -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}) From 78a3eb551e7dabc1f49ec62bfb055bb008b6fbde Mon Sep 17 00:00:00 2001 From: Hugh Bird Date: Wed, 12 Jun 2024 12:40:15 +0100 Subject: [PATCH 2/2] RBiessy suggestions --- .github/workflows/pr.yml | 2 +- src/dft/backends/portfft/CMakeLists.txt | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 7c22d384f..5c4e3c08c 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -24,7 +24,7 @@ jobs: options: -DTARGET_DOMAINS=blas -DREF_BLAS_ROOT=${PWD}/lapack/install -DENABLE_PORTBLAS_BACKEND=ON -DENABLE_MKLCPU_BACKEND=OFF -DPORTBLAS_TUNING_TARGET=INTEL_CPU tests: '.*' - config: portFFT - options: -DENABLE_PORTFFT_BACKEND=ON -DENABLE_MKLCPU_BACKEND=OFF -DTARGET_DOMAINS=dft -DCMAKE_CXX_FLAGS="-fsycl -fsycl-targets=spir64" + options: -DENABLE_PORTFFT_BACKEND=ON -DENABLE_MKLCPU_BACKEND=OFF -DTARGET_DOMAINS=dft tests: 'DFT/CT/.*ComputeTests_in_place_COMPLEX.COMPLEX_SINGLE_in_place_buffer.sizes_8_batches_1*' - config: MKL BLAS options: -DTARGET_DOMAINS=blas -DREF_BLAS_ROOT=${PWD}/lapack/install diff --git a/src/dft/backends/portfft/CMakeLists.txt b/src/dft/backends/portfft/CMakeLists.txt index 7e7119e50..fe9f8aeb9 100644 --- a/src/dft/backends/portfft/CMakeLists.txt +++ b/src/dft/backends/portfft/CMakeLists.txt @@ -36,10 +36,9 @@ 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 "spir64") if(dpcpp_supports_nvptx64) - set(TARGETS_TRIPLES "nvptx64-nvidia-cuda,spir64") - else() - set(TARGETS_TRIPLES "spir64") + set(TARGETS_TRIPLES nvptx64-nvidia-cuda,${TARGETS_TRIPLES}) endif() if (NOT (HIP_TARGETS STREQUAL ""))