gmx_add_nvcc_flag_if_supported rejects all cuda target architectures
**Summary** CMakes new Nvcc detection in `cmake/gmxManageNvccConfig.cmake` causes all cuda target architectures to be rejected. **GROMACS version** ``` $ ~/.local/gromacs-2022.2-gpu/bin/gmx -version -quiet :-) GROMACS - gmx, 2022.2 (-: Executable: /home/stuekero/.local/gromacs-2022.2-gpu/bin/gmx Data prefix: /home/stuekero/.local/gromacs-2022.2-gpu Working dir: /home/stuekero/easybuild-easyconfigs/easybuild/easyconfigs/g/GROMACS/GMX_2022.2_gpu/gromacs-2022.2/cmake Command line: gmx -version -quiet GROMACS version: 2022.2 Precision: mixed Memory model: 64 bit MPI library: thread_mpi OpenMP support: enabled (GMX_OPENMP_MAX_THREADS = 128) GPU support: CUDA SIMD instructions: AVX2_256 CPU FFT library: fftw-3.3.8-sse2-avx-avx2-avx2_128 GPU FFT library: cuFFT RDTSCP usage: enabled TNG support: enabled Hwloc support: disabled Tracing support: disabled C compiler: /cvmfs/soft.computecanada.ca/easybuild/software/2020/Core/gcccore/9.3.0/bin/cc GNU 9.3.0 C compiler flags: -mavx2 -mfma -Wno-missing-field-initializers -fexcess-precision=fast -funroll-all-loops -O3 -DNDEBUG C++ compiler: /cvmfs/soft.computecanada.ca/easybuild/software/2020/Core/gcccore/9.3.0/bin/c++ GNU 9.3.0 C++ compiler flags: -mavx2 -mfma -Wno-missing-field-initializers -fexcess-precision=fast -funroll-all-loops -fopenmp -O3 -DNDEBUG CUDA compiler: /cvmfs/soft.computecanada.ca/easybuild/software/2020/Core/cudacore/11.4.2/bin/nvcc nvcc: NVIDIA (R) Cuda compiler driver;Copyright (c) 2005-2021 NVIDIA Corporation;Built on Sun_Aug_15_21:14:11_PDT_2021;Cuda compilation tools, release 11.4, V11.4.120;Build cuda_11.4.r11.4/compiler.30300941_0 CUDA compiler flags:-std=c++17;;-D_FORCE_INLINES;-mavx2 -mfma -Wno-missing-field-initializers -fexcess-precision=fast -funroll-all-loops -fopenmp -O3 -DNDEBUG CUDA driver: 11.40 CUDA runtime: N/A ``` **Steps to reproduce** ```shell $ export GMX_VERSION=2022.2 $ mkdir GMX_${GMX_VERSION}_gpu $ cd GMX_${GMX_VERSION}_gpu $ tar -xzf ~/.local/easybuild/sources/g/GROMACS/gromacs-${GMX_VERSION}.tar.gz $ module load gcc/9.3.0 openmpi/4.0.3 cuda/11.4.2 cmake/3.23.1 fftw/3.3.8 flexiblas/3.0.4 $ module unload imkl $ module list Currently Loaded Modules: 1) CCconfig 5) gcccore/.9.3.0 (H) 9) libfabric/1.10.1 13) cmake/3.23.1 (t) 2) gentoo/2020 (S) 6) cudacore/.11.4.2 (H,t) 10) gcc/9.3.0 (t) 14) fftw/3.3.8 (math) 3) StdEnv/2020 (S) 7) gdrcopy/2.1 11) cuda/11.4 (t) 15) flexiblas/3.0.4 4) pmix/3.1.5 8) ucx/1.8.0 12) openmpi/4.0.3 (m) $ mkdir build $ cd build/ $ cmake \ -DCMAKE_INSTALL_PREFIX=${HOME}/.local/gromacs-${GMX_VERSION}-gpu \ -DGMX_MPI=OFF \ -DGMX_THREAD_MPI=ON \ -DGMX_SIMD=AVX2_256 \ -DGMX_GPU=CUDA \ -DCUDA_TOOLKIT_ROOT=${EBROOTCUDA} ../gromacs-${GMX_VERSION}/ |& tee ../gromacs-${GMX_VERSION}-gpu_cmake.log ``` **What is the current bug behavior?** cmake will reject `-gencode` architectures. Abridged output: ``` -- Found CUDA: /cvmfs/soft.computecanada.ca/easybuild/software/2020/Core/cudacore/11.4.2 (found suitable version "11.4", minimum required is "11.0") -- Adding work-around for issue compiling CUDA code with glibc 2.23 string.h -- Check for working NVCC/C++ compiler combination with nvcc '/cvmfs/soft.computecanada.ca/easybuild/software/2020/Core/cudacore/11.4.2/bin/nvcc' -- Check for working NVCC/C++ compiler combination - works -- Checking if nvcc accepts flags -gencode;arch=compute_35,code=sm_35 -- Checking if nvcc accepts flags -gencode;arch=compute_35,code=sm_35 - Failed -- Checking if nvcc accepts flags -gencode;arch=compute_37,code=sm_37 -- Checking if nvcc accepts flags -gencode;arch=compute_37,code=sm_37 - Failed -- Checking if nvcc accepts flags -gencode;arch=compute_50,code=sm_50 -- Checking if nvcc accepts flags -gencode;arch=compute_50,code=sm_50 - Failed -- Checking if nvcc accepts flags -gencode;arch=compute_52,code=sm_52 -- Checking if nvcc accepts flags -gencode;arch=compute_52,code=sm_52 - Failed -- Checking if nvcc accepts flags -gencode;arch=compute_60,code=sm_60 -- Checking if nvcc accepts flags -gencode;arch=compute_60,code=sm_60 - Failed -- Checking if nvcc accepts flags -gencode;arch=compute_61,code=sm_61 -- Checking if nvcc accepts flags -gencode;arch=compute_61,code=sm_61 - Failed -- Checking if nvcc accepts flags -gencode;arch=compute_70,code=sm_70 -- Checking if nvcc accepts flags -gencode;arch=compute_70,code=sm_70 - Failed -- Checking if nvcc accepts flags -gencode;arch=compute_75,code=sm_75 -- Checking if nvcc accepts flags -gencode;arch=compute_75,code=sm_75 - Failed -- Checking if nvcc accepts flags -gencode;arch=compute_80,code=sm_80 -- Checking if nvcc accepts flags -gencode;arch=compute_80,code=sm_80 - Failed -- Checking if nvcc accepts flags -Wno-deprecated-gpu-targets -- Checking if nvcc accepts flags -Wno-deprecated-gpu-targets - Failed -- Checking if nvcc accepts flags -gencode;arch=compute_53,code=sm_53 -- Checking if nvcc accepts flags -gencode;arch=compute_53,code=sm_53 - Failed -- Checking if nvcc accepts flags -gencode;arch=compute_80,code=sm_80 -- Checking if nvcc accepts flags -gencode;arch=compute_80,code=sm_80 - Failed -- Checking if nvcc accepts flags -use_fast_math -- Checking if nvcc accepts flags -use_fast_math - Failed ``` Full CMake Log attached. I'm able to compile the `TestCUDA.cu` by hand within the environment: ``` [stuekero@build-node:~/easybuild-easyconfigs/easybuild/easyconfigs/g/GROMACS/GMX_2022.2_gpu/build2] $ nvcc -gencode arch=compute_70,code=sm_70 -ccbin $(which gcc) ../gromacs-2022.2/cmake/TestCUDA.cu && echo OK OK ``` **What did you expect the correct behavior to be?** cmake should accept at least a few cuda architectures. **Possible fixes** I'm not 100% sure, ~~but to me is seems that the `;` in `-gencode;arch=compute_70,code=sm_70` could be interpreted by the shell as the end of the command therefore it should probably be replaced by a space.~~ No, that wasn't it. **Attachments** Full log: [gromacs-2022.2-gpu_cmake.log](/uploads/089627ba5afe8e7076473e857092f486/gromacs-2022.2-gpu_cmake.log).
issue