Repository: spack/spack

Issue:
Installation issue: amrex+cuda~fortran+openmp+particles @20.12
<!-- Thanks for taking the time to report this build failure. To proceed with the report please:

1. Title the issue "Installation issue: <name-of-the-package>".
2. Provide the information required below.

We encourage you to try, as much as possible, to reduce your problem to the minimal example that still reproduces the issue. That would help us a lot in fixing it quickly and effectively! -->

### Steps to reproduce the issue

<!-- Fill in the exact spec you are trying to build and the relevant part of the error message -->
```console
$ spack install amrex+cuda~fortran+openmp+particles
...
     99     cd /tmp/root/spack-stage/spack-stage-amrex-20.12-jqne5t32rxkzodklwo
            eqfefn44ldtwkw/spack-build-jqne5t3/Src && /opt/software/linux-ubunt
            u20.04-haswell/gcc-9.3.0/cuda-11.1.0-n5wch2ga6sejvwicpkxlx26y4vxj77
            22/bin/nvcc -ccbin=/usr/bin/g++ -DAMREX_GIT_VERSION=\"20.12.0\" -DA
            MREX_GPU_MAX_THREADS=256 -DAMREX_Linux -DAMREX_PARTICLES -DAMREX_SP
            ACEDIM=3 -DAMREX_USE_CUDA -DAMREX_USE_GPU -DAMREX_USE_MPI -DAMREX_U
            SE_NVML -DAMREX_USE_OMP -DAMREX_XSDK -DBL_COALESCE_FABS -DBL_Linux
            -DBL_NO_FORT -DBL_SPACEDIM=3 -DBL_USE_MPI -DBL_USE_OMP -I/tmp/root/
            spack-stage/spack-stage-amrex-20.12-jqne5t32rxkzodklwoeqfefn44ldtwk
            w/spack-src/Src/Base -I/tmp/root/spack-stage/spack-stage-amrex-20.1
            2-jqne5t32rxkzodklwoeqfefn44ldtwkw/spack-src/Src/Boundary -I/tmp/ro
            ot/spack-stage/spack-stage-amrex-20.12-jqne5t32rxkzodklwoeqfefn44ld
            twkw/spack-src/Src/AmrCore -I/tmp/root/spack-stage/spack-stage-amre
            x-20.12-jqne5t32rxkzodklwoeqfefn44ldtwkw/spack-src/Src/Amr -I/tmp/r
            oot/spack-stage/spack-stage-amrex-20.12-jqne5t32rxkzodklwoeqfefn44l
            dtwkw/spack-src/Src/LinearSolvers/MLMG -I/tmp/root/spack-stage/spac
            k-stage-amrex-20.12-jqne5t32rxkzodklwoeqfefn44ldtwkw/spack-src/Src/
            LinearSolvers/Projections -I/tmp/root/spack-stage/spack-stage-amrex
            -20.12-jqne5t32rxkzodklwoeqfefn44ldtwkw/spack-src/Src/Particle -isy
            stem=/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi -isystem=/us
            r/lib/x86_64-linux-gnu/openmpi/include  -m64 --expt-relaxed-constex
            pr --expt-extended-lambda -Wno-deprecated-gpu-targets -gencode=arch
            =compute_30,code=sm_30 -gencode=arch=compute_35,code=sm_35 -gencode
            =arch=compute_50,code=sm_50 -gencode=arch=compute_52,code=sm_52 -ge
            ncode=arch=compute_60,code=sm_60 -gencode=arch=compute_61,code=sm_6
            1 -gencode=arch=compute_70,code=sm_70 -gencode=arch=compute_75,code
            =sm_75 -gencode=arch=compute_70,code=compute_70 -gencode=arch=compu
            te_75,code=compute_75 -maxrregcount=255 -Xcudafe --diag_suppress=es
            a_on_defaulted_function_ignored --use_fast_math -Xcudafe --display_
            error_number --Wext-lambda-captures-this --forward-unknown-to-host-
            compiler -O3 -DNDEBUG   -Xcompiler=-fopenmp -Xcompiler=-Werror=retu
            rn-type -Xcompiler -pthread -std=c++11 -x cu -dc /tmp/root/spack-st
            age/spack-stage-amrex-20.12-jqne5t32rxkzodklwoeqfefn44ldtwkw/spack-
            src/Src/Base/AMReX_Utility.cpp -o CMakeFiles/amrex.dir/Base/AMReX_U
            tility.cpp.o
     100    nvcc fatal   : Unsupported gpu architecture 'compute_30'
...
```

### Information on your system

I built this inside a Docker container based on Ubuntu 20.04. The root of the problem seems to be (as the web tells me) that CUDA 11 (installed by Spack) doesn't support `compute_30` any more. I've looked in the source code of AMReX and of Spack to see who decides that `compute_30` should be used (see line 99 of the error messages), but I found no clue. Any pointer would be appreciated.

The complete error message is available at <https://gist.github.com/eschnett/d2fbff0fa94a8861b98c496f0432cf1a>.


Discussion:

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/amrex/package.py b/var/spack/repos/builtin/packages/amrex/package.py
--- a/var/spack/repos/builtin/packages/amrex/package.py
+++ b/var/spack/repos/builtin/packages/amrex/package.py
@@ -80,6 +80,8 @@ class Amrex(CMakePackage):
     depends_on('cmake@3.5:',  type='build', when='@:18.10.99')
     depends_on('cmake@3.13:', type='build', when='@18.11:')
     depends_on('cmake@3.14:', type='build', when='@19.04:')
+    # cmake @3.17: is necessary to handle cuda @11: correctly
+    depends_on('cmake@3.17:', type='build', when='^cuda @11:')
     conflicts('%apple-clang')
     conflicts('%clang')
 


Test patch: