From eaddf07fd9e1f1f657d8d8817d8d428dff19d0f5 Mon Sep 17 00:00:00 2001 From: Simon Pintarelli <1237199+simonpintarelli@users.noreply.github.com> Date: Mon, 10 Jun 2024 15:54:05 +0200 Subject: [PATCH] qe7.3.1 for gh200 (#92) --- config.yaml | 5 + docs/uenv-linaro-forge.md | 2 +- docs/uenv-qe.md | 154 +++- mkdocs.yml | 1 + .../v7.3.1/gh200/compilers.yaml | 9 + .../quantumespresso/v7.3.1/gh200/config.yaml | 6 + .../v7.3.1/gh200/environments.yaml | 32 + .../quantumespresso/v7.3.1/gh200/modules.yaml | 23 + ...licit-pointer-cast-to-make-libxc-com.patch | 26 + .../0002-Mark-xc_erfcx-a-GPU_FUNCTION.patch | 33 + .../repo/packages/libxc/nvhpc-configure.patch | 75 ++ .../repo/packages/libxc/nvhpc-libtool.patch | 77 ++ .../gh200/repo/packages/libxc/package.py | 136 ++++ .../quantum-espresso/configure_aocc.patch | 72 ++ .../quantum-espresso/dspev_drv_elpa.patch | 42 ++ .../packages/quantum-espresso/fj-fox.patch | 10 + .../quantum-espresso/fj-intent.6.4.1.patch | 11 + .../packages/quantum-espresso/fj.6.5.patch | 23 + .../packages/quantum-espresso/fj.6.6.patch | 23 + .../quantum-espresso/gipaw-eccee44.patch | 8 + .../packages/quantum-espresso/nvhpc.patch | 106 +++ .../repo/packages/quantum-espresso/package.py | 680 ++++++++++++++++++ 22 files changed, 1529 insertions(+), 25 deletions(-) create mode 100644 recipes/quantumespresso/v7.3.1/gh200/compilers.yaml create mode 100644 recipes/quantumespresso/v7.3.1/gh200/config.yaml create mode 100644 recipes/quantumespresso/v7.3.1/gh200/environments.yaml create mode 100644 recipes/quantumespresso/v7.3.1/gh200/modules.yaml create mode 100644 recipes/quantumespresso/v7.3.1/gh200/repo/packages/libxc/0001-Bugfix-avoid-implicit-pointer-cast-to-make-libxc-com.patch create mode 100644 recipes/quantumespresso/v7.3.1/gh200/repo/packages/libxc/0002-Mark-xc_erfcx-a-GPU_FUNCTION.patch create mode 100644 recipes/quantumespresso/v7.3.1/gh200/repo/packages/libxc/nvhpc-configure.patch create mode 100644 recipes/quantumespresso/v7.3.1/gh200/repo/packages/libxc/nvhpc-libtool.patch create mode 100644 recipes/quantumespresso/v7.3.1/gh200/repo/packages/libxc/package.py create mode 100644 recipes/quantumespresso/v7.3.1/gh200/repo/packages/quantum-espresso/configure_aocc.patch create mode 100644 recipes/quantumespresso/v7.3.1/gh200/repo/packages/quantum-espresso/dspev_drv_elpa.patch create mode 100644 recipes/quantumespresso/v7.3.1/gh200/repo/packages/quantum-espresso/fj-fox.patch create mode 100644 recipes/quantumespresso/v7.3.1/gh200/repo/packages/quantum-espresso/fj-intent.6.4.1.patch create mode 100644 recipes/quantumespresso/v7.3.1/gh200/repo/packages/quantum-espresso/fj.6.5.patch create mode 100644 recipes/quantumespresso/v7.3.1/gh200/repo/packages/quantum-espresso/fj.6.6.patch create mode 100644 recipes/quantumespresso/v7.3.1/gh200/repo/packages/quantum-espresso/gipaw-eccee44.patch create mode 100644 recipes/quantumespresso/v7.3.1/gh200/repo/packages/quantum-espresso/nvhpc.patch create mode 100644 recipes/quantumespresso/v7.3.1/gh200/repo/packages/quantum-espresso/package.py diff --git a/config.yaml b/config.yaml index 77159fea..fc3debfd 100644 --- a/config.yaml +++ b/config.yaml @@ -187,6 +187,11 @@ uenvs: a100: v7.1/a100 deploy: eiger: [zen2] + "v7.3.1": + recipes: + gh200: v7.3.1/gh200 + deploy: + santis: [gh200] sirius: "v7.5": recipes: diff --git a/docs/uenv-linaro-forge.md b/docs/uenv-linaro-forge.md index d672cb7a..b422dc90 100644 --- a/docs/uenv-linaro-forge.md +++ b/docs/uenv-linaro-forge.md @@ -135,7 +135,7 @@ Open the *Remote Launch* menu and click on *configure* then *Add*. Examples of t Some notes on the examples above: -* SSH Forwarding via `ela.scscs.ch` is used to access the cluster. +* SSH Forwarding via `ela.cscs.ch` is used to access the cluster. * the replace the username `bsmith` with your CSCS user name that you would normally use to open an SSH connection to CSCS. * the Remote Installation Path is a little bit more complicated than * the private keys should be the ones generated for CSCS MFA, and this field does not need to be set if you have added the key to your SSH agent. diff --git a/docs/uenv-qe.md b/docs/uenv-qe.md index 5f932acf..7d665fc3 100644 --- a/docs/uenv-qe.md +++ b/docs/uenv-qe.md @@ -1,42 +1,148 @@ # Quantum ESPRESSO -https://www.quantum-espresso.org/ +https://www.quantum-espresso.org An environment that provides the latest version of Quantum ESPRESSO, along with the libraries and tools required to build a different or custom version of Quantum ESPRESSO. At the moment a GPU-build environment is provided without a ScaLAPACK. The following environment views are provided: -* default : QuantumESPRESSO/7.1 itself + dependencies -* develop : only dependencies +=== "GH200" -The following modules are provided: + * default : QuantumESPRESSO/7.3.1 itself + dependencies + * develop : only dependencies -* cmake/3.26.3 -* cray-mpich/8.1.25-nvhpc -* cuda/11.8.0 -* fftw/3.3.10 -* gcc/11.3.0 -* libxc/5.2.3 -* nvhpc/22.11 -* openblas/0.3.23 -* patchelf/0.17.2 -* quantum-espresso/7.1 + The following modules are provided: -## Building a custom version + * cmake/3.27.7 + * nvhpc/24.1 + * quantum-espresso/7.3.1 + * cray-mpich/8.1.29 + * fftw/3.3.10 + * git/2.42.0 + * nvpl-lapack/0.2.0 + * gcc/12.3.0 + * libxc/6.2.2 + * nvpl-blas/0.1.0 -### using modules +=== "A100" -To build your version of QE do the following steps: + * default : QuantumESPRESSO/7.1 itself + dependencies + * develop : only dependencies + The following modules are provided: + + * cmake/3.26.3 + * cray-mpich/8.1.25-nvhpc + * cuda/11.8.0 + * fftw/3.3.10 + * gcc/11.3.0 + * libxc/5.2.3 + * nvhpc/22.11 + * openblas/0.3.23 + * patchelf/0.17.2 + * quantum-espresso/7.1 + + +# Building a custom version + +## Using modules + +=== "GH200" + + ```bash + uenv start quantumespresso/v7.3.1 + uenv modules use + module load cmake \ + fftw \ + nvhpc \ + nvpl-lapack \ + nvpl-blas \ + cray-mpich \ + netlib-scalapack \ + libxc + + mkdir build && cd build + FC=mpif90 CXX=mpic++ CC=mpicc cmake .. \ + -DQE_ENABLE_MPI=ON \ + -DQE_ENABLE_OPENMP=ON \ + -DQE_ENABLE_SCALAPACK:BOOL=OFF \ + -DQE_ENABLE_LIBXC=ON \ + -DQE_ENABLE_CUDA=ON \ + -DQE_ENABLE_PROFILE_NVTX=ON \ + -DQE_CLOCK_SECONDS:BOOL=OFF \ + -DQE_ENABLE_MPI_GPU_AWARE:BOOL=OFF \ + -DQE_ENABLE_OPENACC=ON + make -j20 + ``` + +=== "A100" + + ```bash + uenv start quantumespresso/v7.1 + uenv modules use + module load cmake \ + cray-mpich + cuda \ + fftw \ + gcc \ + libxc \ + nvhpc \ + openblas + mkdir build && cd build + FC=mpif90 CXX=mpic++ CC=mpicc cmake .. \ + -DQE_ENABLE_MPI=ON \ + -DQE_ENABLE_OPENMP=ON \ + -DQE_ENABLE_SCALAPACK:BOOL=OFF \ + -DQE_ENABLE_LIBXC=ON \ + -DQE_ENABLE_CUDA=ON \ + -DQE_CLOCK_SECONDS:BOOL=OFF \ + -DQE_ENABLE_MPI_GPU_AWARE:BOOL=OFF \ + -DQE_ENABLE_OPENACC=ON + make -j20 + ``` + +## Using spack + +1. Clone spack using the same version that has been used to build the uenv. ```bash -module load cmake cray-mpich/8.1.25-nvhpc cuda fftw libxc/5.2.3-nvhpc nvhpc openblas -cd qe-71-dev -mkdir build && cd build -cmake .. -DQE_ENABLE_OPENMP=1 -DQE_ENABLE_SCALAPACK=0 -DQE_ENABLE_LIBXC=1 -DQE_ENABLE_CUDA=1 -make -j20 +uenv start quantumespresso/v7.3.1 +# clone the same spack version as has been used to build the uenv +git clone -b $(jq -r .spack.commit /user-environment/meta/configure.json) $(jq -r .spack.repo /user-environment/meta/configure.json) $SCRATCH/spack ``` -### using Spack +2. Activate spack with the uenv configured as upstream +```bash +# ensure spack is using the uenv as upstream repository (always required) +export SPACK_SYSTEM_CONFIG_PATH=/user-environment/config +# active spack (always required) +. $SCRATCH/spack/share/spack/setup-env.sh +``` + +3. Create an anonymous environment for QE +```bash +spack env create -d $SCRATCH/qe-env +spack -e $SCRATCH/qe-env add quantum-espresso%nvhpc +cuda +spack -e $SCRATCH/qe-env config add packages:all:prefer:cuda_arch=90 +spack -e $SCRATCH/qe-env develop -p /path/to/your/QE-src quantum-espresso@=develop +spack -e $SCRATCH/qe-env concretize -f +``` +Check the output of `spack concretize -f`. All dependencies should have been picked up from spack upstream, marked eiter by a green `[^]` or `[e]`. +Next we create a local filesystem view, this instructs spack to create symlinks for binaries and libraries in a local directory `view`. +```bash +spack -e $SCRATCH/qe-env env view enable view +spack -e $SCRATCH/qe-env install +``` +To recompile QE after editing the source code re-run `spack -e $SCRATCH/qe-env install`. + +4. Run `pw.x` using the filesystem view generated in 3. +```bash +uenv start quantumespresso/v7.3.1 +srun [...] $SCRATCH/qe-env/view/bin/pw.x < pw.in +``` +Note: The `pw.x` is linked to the uenv, it won't work without activating the uenv, also it will only work with the exact same version of the uenv. The physical installation path is in `$SCRATCH/spack`, deleting this directory will leave the anonymous spack environment created in 3. with dangling symlinks. + + + + -todo. diff --git a/mkdocs.yml b/mkdocs.yml index 31684808..88fe1ee3 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -8,6 +8,7 @@ nav: - 'linaro-forge': uenv-linaro-forge.md - 'namd': uenv-namd.md - 'quantumespresso': uenv-qe.md + - 'quantumespresso-gh200': uenv-qe-gh200.md - 'vasp': uenv-vasp.md - 'Developers': - 'tutorial: application': pkg-application-tutorial.md diff --git a/recipes/quantumespresso/v7.3.1/gh200/compilers.yaml b/recipes/quantumespresso/v7.3.1/gh200/compilers.yaml new file mode 100644 index 00000000..7f8097eb --- /dev/null +++ b/recipes/quantumespresso/v7.3.1/gh200/compilers.yaml @@ -0,0 +1,9 @@ +bootstrap: + spec: gcc@12 +gcc: + specs: + - gcc@12 +llvm: + requires: gcc@12 + specs: + - nvhpc@24.3 diff --git a/recipes/quantumespresso/v7.3.1/gh200/config.yaml b/recipes/quantumespresso/v7.3.1/gh200/config.yaml new file mode 100644 index 00000000..6e11d990 --- /dev/null +++ b/recipes/quantumespresso/v7.3.1/gh200/config.yaml @@ -0,0 +1,6 @@ +name: quantumespresso +store: /user-environment +description: QuantumESPRESSO 7.3.1 +cuda +spack: + repo: https://github.com/spack/spack.git + commit: v0.21.2 diff --git a/recipes/quantumespresso/v7.3.1/gh200/environments.yaml b/recipes/quantumespresso/v7.3.1/gh200/environments.yaml new file mode 100644 index 00000000..23c9877a --- /dev/null +++ b/recipes/quantumespresso/v7.3.1/gh200/environments.yaml @@ -0,0 +1,32 @@ +nvhpc-env: + compiler: + - toolchain: llvm + spec: nvhpc + - toolchain: gcc + spec: gcc@12 + mpi: + spec: cray-mpich@8.1.29 + gpu: cuda + unify: true + specs: + - quantum-espresso@7.3.1 %nvhpc +libxc +cuda +nvtx +scalapack + - cmake%gcc + - fftw%gcc + - netlib-scalapack%gcc + - nvpl-blas threads=openmp + - nvpl-lapack threads=openmp + - libxc%nvhpc~cuda + - libxml2%gcc + - patchelf%gcc + packages: + - git + variants: + - +mpi + - +cuda + - cuda_arch=90 + views: + default: + link: roots + develop: + exclude: ['quantum-espresso', 'patchelf', 'git'] + link: roots diff --git a/recipes/quantumespresso/v7.3.1/gh200/modules.yaml b/recipes/quantumespresso/v7.3.1/gh200/modules.yaml new file mode 100644 index 00000000..623307b0 --- /dev/null +++ b/recipes/quantumespresso/v7.3.1/gh200/modules.yaml @@ -0,0 +1,23 @@ +modules: + # Paths to check when creating modules for all module sets + prefix_inspections: + bin: + - PATH + lib: + - LD_LIBRARY_PATH + lib64: + - LD_LIBRARY_PATH + + default: + arch_folder: false + # Where to install modules + roots: + tcl: /user-environment/modules + tcl: + all: + autoload: none + hash_length: 0 + exclude_implicits: true + exclude: ['%gcc@7.5.0', 'gcc %gcc@7.5.0'] + projections: + all: '{name}/{version}' diff --git a/recipes/quantumespresso/v7.3.1/gh200/repo/packages/libxc/0001-Bugfix-avoid-implicit-pointer-cast-to-make-libxc-com.patch b/recipes/quantumespresso/v7.3.1/gh200/repo/packages/libxc/0001-Bugfix-avoid-implicit-pointer-cast-to-make-libxc-com.patch new file mode 100644 index 00000000..366f6801 --- /dev/null +++ b/recipes/quantumespresso/v7.3.1/gh200/repo/packages/libxc/0001-Bugfix-avoid-implicit-pointer-cast-to-make-libxc-com.patch @@ -0,0 +1,26 @@ +From 205a08a30ee0d057d173f9eaa6fc6414f6960c22 Mon Sep 17 00:00:00 2001 +From: Xavier Andrade +Date: Wed, 27 May 2020 15:42:32 -0700 +Subject: [PATCH] Bugfix: avoid implicit pointer cast to make libxc compile + with a C++ compiler. + +--- + src/functionals.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/functionals.c b/src/functionals.c +index 3f668292..293f7f9b 100644 +--- a/src/functionals.c ++++ b/src/functionals.c +@@ -324,7 +324,7 @@ xc_func_set_ext_params_name(xc_func_type *p, const char *name, double par) + + assert(p != NULL && p->info->ext_params.n > 0); + +- ext_params = libxc_malloc(p->info->ext_params.n*sizeof(double)); ++ ext_params = (double *) libxc_malloc(p->info->ext_params.n*sizeof(double)); + for(ii=0; iiinfo->ext_params.n; ii++){ + if(strcmp(p->info->ext_params.names[ii], name) == 0) + ext_params[ii] = par; +-- +2.25.1 + diff --git a/recipes/quantumespresso/v7.3.1/gh200/repo/packages/libxc/0002-Mark-xc_erfcx-a-GPU_FUNCTION.patch b/recipes/quantumespresso/v7.3.1/gh200/repo/packages/libxc/0002-Mark-xc_erfcx-a-GPU_FUNCTION.patch new file mode 100644 index 00000000..a4e4f104 --- /dev/null +++ b/recipes/quantumespresso/v7.3.1/gh200/repo/packages/libxc/0002-Mark-xc_erfcx-a-GPU_FUNCTION.patch @@ -0,0 +1,33 @@ +From 11b90a0a477925f19dfeb7e1f672058f25d83387 Mon Sep 17 00:00:00 2001 +From: Harmen Stoppels +Date: Fri, 31 Jul 2020 13:54:39 +0200 +Subject: [PATCH] Mark xc_erfcx a GPU_FUNCTION + +--- + src/faddeeva.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/src/faddeeva.c b/src/faddeeva.c +index ceec4736..03484713 100644 +--- a/src/faddeeva.c ++++ b/src/faddeeva.c +@@ -29,6 +29,8 @@ + + #include "config.h" + ++#include "util.h" ++ + #include + + /* erfcx(x) = exp(x^2) erfc(x) function, for real x, written by +@@ -477,6 +479,7 @@ return 0.97771701335885035464e0 + (0.22000938572830479551e-1 + (0.27951610702682 + return 1.0; + } + ++GPU_FUNCTION + double xc_erfcx(double x) + { + if (x >= 0) { +-- +2.25.1 + diff --git a/recipes/quantumespresso/v7.3.1/gh200/repo/packages/libxc/nvhpc-configure.patch b/recipes/quantumespresso/v7.3.1/gh200/repo/packages/libxc/nvhpc-configure.patch new file mode 100644 index 00000000..47e8f221 --- /dev/null +++ b/recipes/quantumespresso/v7.3.1/gh200/repo/packages/libxc/nvhpc-configure.patch @@ -0,0 +1,75 @@ +--- a/configure 2020-09-24 11:13:16.306629033 -0700 ++++ b/configure 2020-09-24 11:14:16.412221646 -0700 +@@ -8908,7 +8908,7 @@ + lt_prog_compiler_pic='-fPIC' + lt_prog_compiler_static='-static' + ;; +- pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) ++ pgcc* | pgf77* | pgf90* | pgf95* | pgfortran* | nvc | nvfortran*) + # Portland Group compilers (*not* the Pentium gcc compiler, + # which looks to be a dead project) + lt_prog_compiler_wl='-Wl,' +@@ -9547,11 +9547,11 @@ + tmp_addflag=' $pic_flag' + tmp_sharedflag='-shared' + case $cc_basename,$host_cpu in +- pgcc*) # Portland Group C compiler ++ pgcc* | nvc) # Portland Group C compiler + whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + tmp_addflag=' $pic_flag' + ;; +- pgf77* | pgf90* | pgf95* | pgfortran*) ++ pgf77* | pgf90* | pgf95* | pgfortran* | nvfortran*) + # Portland Group f77 and f90 compilers + whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + tmp_addflag=' $pic_flag -Mnomain' ;; +@@ -13810,7 +13810,7 @@ + ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5' + ac_compiler_gnu=$ac_cv_fc_compiler_gnu + if test -n "$ac_tool_prefix"; then +- for ac_prog in xlf90 f90 pgf90 pghpf epcf90 gfortran g95 xlf95 f95 fort ifort ifc efc pgfortran pgf95 lf95 ftn nagfor ++ for ac_prog in xlf90 f90 pgf90 pghpf epcf90 gfortran g95 xlf95 f95 fort ifort ifc efc pgfortran pgf95 nvfortran lf95 ftn nagfor + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. + set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +@@ -13854,7 +13854,7 @@ + fi + if test -z "$FC"; then + ac_ct_FC=$FC +- for ac_prog in xlf90 f90 pgf90 pghpf epcf90 gfortran g95 xlf95 f95 fort ifort ifc efc pgfortran pgf95 lf95 ftn nagfor ++ for ac_prog in xlf90 f90 pgf90 pghpf epcf90 gfortran g95 xlf95 f95 fort ifort ifc efc pgfortran pgf95 nvfortran lf95 ftn nagfor + do + # Extract the first word of "$ac_prog", so it can be a program name with args. + set dummy $ac_prog; ac_word=$2 +@@ -14545,7 +14545,7 @@ + lt_prog_compiler_pic_FC='-fPIC' + lt_prog_compiler_static_FC='-static' + ;; +- pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) ++ pgcc* | pgf77* | pgf90* | pgf95* | pgfortran* | nvc | nvfortran*) + # Portland Group compilers (*not* the Pentium gcc compiler, + # which looks to be a dead project) + lt_prog_compiler_wl_FC='-Wl,' +@@ -14587,7 +14587,7 @@ + lt_prog_compiler_pic_FC='-fPIC' + lt_prog_compiler_static_FC='-static' + ;; +- *Portland\ Group*) ++ *Portland\ Group* | *NVIDIA\ Compilers* | *PGI\ Compilers*) + lt_prog_compiler_wl_FC='-Wl,' + lt_prog_compiler_pic_FC='-fpic' + lt_prog_compiler_static_FC='-Bstatic' +@@ -15169,11 +15169,11 @@ + tmp_addflag=' $pic_flag' + tmp_sharedflag='-shared' + case $cc_basename,$host_cpu in +- pgcc*) # Portland Group C compiler ++ pgcc* | nvc) # Portland Group C compiler + whole_archive_flag_spec_FC='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + tmp_addflag=' $pic_flag' + ;; +- pgf77* | pgf90* | pgf95* | pgfortran*) ++ pgf77* | pgf90* | pgf95* | pgfortran* | nvfortran*) + # Portland Group f77 and f90 compilers + whole_archive_flag_spec_FC='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + tmp_addflag=' $pic_flag -Mnomain' ;; diff --git a/recipes/quantumespresso/v7.3.1/gh200/repo/packages/libxc/nvhpc-libtool.patch b/recipes/quantumespresso/v7.3.1/gh200/repo/packages/libxc/nvhpc-libtool.patch new file mode 100644 index 00000000..18d6b0e1 --- /dev/null +++ b/recipes/quantumespresso/v7.3.1/gh200/repo/packages/libxc/nvhpc-libtool.patch @@ -0,0 +1,77 @@ +From b71206582131f88f6602a40e4c67e3d92b119229 Mon Sep 17 00:00:00 2001 +From: Tin Huynh +Date: Mon, 27 Jul 2020 15:15:47 -0700 +Subject: [PATCH] Recognize new Nvidia compilers. + +With the upcoming release of HPC-SDK, updating Libtool to recognize Nvidia +compilers (nvc, nvc++, nvfortran). +--- + m4/libtool.m4 | 21 ++++++++++----------- + 1 file changed, 10 insertions(+), 11 deletions(-) + +diff --git a/m4/libtool.m4 b/m4/libtool.m4 +index f2d1f39..4eac689 100644 +--- a/m4/libtool.m4 ++++ b/m4/libtool.m4 +@@ -4402,8 +4402,8 @@ m4_if([$1], [CXX], [ + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; +- pgCC* | pgcpp*) +- # Portland Group C++ compiler ++ pgCC* | pgcpp* | pgc\+\+* | nvc\+\+*) ++ # NVIDIA HPC C++ compiler + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' +@@ -4739,9 +4739,8 @@ m4_if([$1], [CXX], [ + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; +- pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) +- # Portland Group compilers (*not* the Pentium gcc compiler, +- # which looks to be a dead project) ++ pgcc* | pgf77* | pgf90* | pgf95* | pgfortran* | nvc | nvfortran*) ++ # NVIDIA HPC Compilers + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' +@@ -4781,7 +4780,7 @@ m4_if([$1], [CXX], [ + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; +- *Portland\ Group*) ++ *Portland\ Group* | *NVIDIA\ Compilers* | *PGI\ Compilers*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' +@@ -5209,12 +5208,12 @@ _LT_EOF + tmp_addflag=' $pic_flag' + tmp_sharedflag='-shared' + case $cc_basename,$host_cpu in +- pgcc*) # Portland Group C compiler ++ pgcc* | nvc) # NVIDIA HPC C++ Compiler + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + tmp_addflag=' $pic_flag' + ;; +- pgf77* | pgf90* | pgf95* | pgfortran*) +- # Portland Group f77 and f90 compilers ++ pgf77* | pgf90* | pgf95* | pgfortran* | nvfortran*) ++ # NVIDIA HPC Fortran Compilers + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + tmp_addflag=' $pic_flag -Mnomain' ;; + ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 +@@ -7004,8 +7003,8 @@ if test yes != "$_lt_caught_CXX_error"; then + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive' + ;; +- pgCC* | pgcpp*) +- # Portland Group C++ compiler ++ pgCC* | pgcpp* | pgc\+\+* | nvc\+\+*) ++ # NVIDIA HPC C++ compiler + case `$CC -V` in + *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*) + _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~ +-- +2.7.4 + diff --git a/recipes/quantumespresso/v7.3.1/gh200/repo/packages/libxc/package.py b/recipes/quantumespresso/v7.3.1/gh200/repo/packages/libxc/package.py new file mode 100644 index 00000000..d3f2d9d4 --- /dev/null +++ b/recipes/quantumespresso/v7.3.1/gh200/repo/packages/libxc/package.py @@ -0,0 +1,136 @@ +# Copyright 2013-2024 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + +from spack.package import * + + +class Libxc(AutotoolsPackage, CudaPackage): + """Libxc is a library of exchange-correlation functionals for + density-functional theory.""" + + homepage = "https://libxc.gitlab.io" + url = "https://gitlab.com/libxc/libxc/-/archive/6.1.0/libxc-6.1.0.tar.gz" + + license("MPL-2.0-no-copyleft-exception") + + version("6.2.2", sha256="d1b65ef74615a1e539d87a0e6662f04baf3a2316706b4e2e686da3193b26b20f") + version("6.2.1", sha256="da96fc4f6e4221734986f49758b410ffe1d406efd3538761062a4af57a2bd272") + version("6.2.0", sha256="31edb72c69157b6c0beaff1f10cbbb6348ce7579ef81d8f286764e5ab61194d1") + version("6.1.0", sha256="9baf23501dca21b05fa22d8e2ffeb56f294abe19ba12584cb3f9b421ae719c5f") + version("6.0.0", sha256="48a5393984d95bf0dd05c5ffc94e77da938b7f321058fe250c3448c7a9392c88") + version("5.2.3", sha256="3e0b36b3b9986a621fd8850133408f6f567bd7db5636a32a68f7637e116e268c") + version("5.1.7", sha256="1d50e1a92e59b5f3c8e7408f8612f0fb0e953d4f159515b7d81485891f3a1bbc") + version("5.1.5", sha256="101d6ea9e013006deae074843f0d02ab2813e16734e47ff7b0551babc4497163") + version("5.1.3", sha256="76b2abd063b692ed7e60fb6dfdf5a54072378710ee91f2b352a4e311d9805e97") + version("5.1.2", sha256="ff13eef8184b6c61dac8933ee74fc05967de4a67489581bdc500f1ec63826aae") + version("5.1.0", sha256="e8d2b6eb2b46b356a27f0367a7665ff276d7f295da7c734e774ee66f82e56297") + version("5.0.0", sha256="6b3be3cf6daf6b3eddf32d4077276eb9169531b42f98c2ca28ac85b9ea408493") + version("4.3.4", sha256="2d5878dd69f0fb68c5e97f46426581eed2226d1d86e3080f9aa99af604c65647") + version("4.3.2", sha256="3bbe01971d0a43fb63b5c17d922388a39a3f0ae3bd37ae5f6fe31bca9ab63f3c") + version("4.2.3", sha256="869ca4967cd255097fd2dc31664f30607e81f5abcf5f9c89bd467dc0bf93e5aa") + version("3.0.0", sha256="df2362351280edaf2233f3b2c8eb8e6dd6c68105f152897a4cc629fa346a7396") + version("2.2.2", sha256="6ffaad40505dbe8f155049448554b54ea31d31babf74ccf6b7935bfe55eeafd8") + version("2.2.1", sha256="c8577ba1ddd5c28fd0aa7c579ae65ab990eb7cb51ecf9f8175f9251f6deb9a06") + + variant("shared", default=True, description="Build shared libraries") + variant("kxc", default=False, when="@5:", description="Build with third derivatives") + variant("lxc", default=False, when="@5:", description="Build with fourth derivatives") + + conflicts("+shared +cuda", msg="Only ~shared supported with +cuda") + conflicts("+cuda", when="@:4", msg="CUDA support only in libxc 5.0.0 and above") + + # Remove this if the release tarballs are available again. + depends_on("autoconf", type="build") + depends_on("automake", type="build") + depends_on("libtool", type="build") + + depends_on("perl", type="build") + + patch("0001-Bugfix-avoid-implicit-pointer-cast-to-make-libxc-com.patch", when="@5.0.0") + patch("0002-Mark-xc_erfcx-a-GPU_FUNCTION.patch", when="@5.0.0") + patch( + "https://raw.githubusercontent.com/cp2k/cp2k/d9e473979eaef93bf16d7abafb9f21845af16eb8/tools/toolchain/scripts/stage3/libxc-6.0.0_mgga_xc_b97mv.patch", + sha256="938113a697ee14988ccff153e1a8287fdb78072adc4f388a0af434261082fee5", + when="@6.0.0", + ) + + @property + def libs(self): + """Libxc can be queried for the following parameters: + + - "static": returns the static library version of libxc + (by default the shared version is returned) + + :return: list of matching libraries + """ + query_parameters = self.spec.last_query.extra_parameters + + libraries = ["libxc"] + + # Libxc installs both shared and static libraries. + # If a client ask for static explicitly then return + # the static libraries + shared = self.spec.variants["shared"].value and "static" not in query_parameters + + # Libxc has a fortran90 interface: give clients the + # possibility to query for it + if "fortran" in query_parameters: + if self.version < Version("4.0.0"): + libraries = ["libxcf90"] + libraries + else: # starting from version 4 there is also a stable f03 iface + libraries = ["libxcf90", "libxcf03"] + libraries + + return find_libraries(libraries, root=self.prefix, shared=shared, recursive=True) + + def setup_build_environment(self, env): + # microarchitecture-specific optimization flags should be controlled + # by Spack, otherwise we may end up with contradictory or invalid flags + # see https://github.com/spack/spack/issues/17794 + + # https://gitlab.com/libxc/libxc/-/issues/430 (configure script does not ensure C99) + # TODO: Switch to cmake since this is better supported + env.append_flags("CFLAGS", self.compiler.c99_flag) + if "%intel" in self.spec: + if which("xiar"): + env.set("AR", "xiar") + + if "%aocc" in self.spec: + env.append_flags("FCFLAGS", "-fPIC") + + if "+cuda" in self.spec: + nvcc = self.spec["cuda"].prefix.bin.nvcc + env.set("CCLD", "{0} -ccbin {1}".format(nvcc, spack_cc)) + env.set("CC", "{0} -x cu -ccbin {1}".format(nvcc, spack_cc)) + + cuda_arch = self.spec.variants["cuda_arch"].value[0] + + if cuda_arch != "none": + env.append_flags("CFLAGS", "-arch=sm_{0}".format(cuda_arch)) + + def configure_args(self): + args = [] + args += self.enable_or_disable("shared") + args += self.enable_or_disable("cuda") + if "+kxc" in self.spec: + args.append("--enable-kxc") + if "+lxc" in self.spec: + args.append("--enable-lxc") + return args + + @run_after("configure") + def patch_libtool(self): + """AOCC support for LIBXC""" + if "%aocc" in self.spec: + filter_file( + r"\$wl-soname \$wl\$soname", + r"-fuse-ld=ld -Wl,-soname,\$soname", + "libtool", + string=True, + ) + + def check(self): + # libxc provides a testsuite, but many tests fail + # http://www.tddft.org/pipermail/libxc/2013-February/000032.html + pass diff --git a/recipes/quantumespresso/v7.3.1/gh200/repo/packages/quantum-espresso/configure_aocc.patch b/recipes/quantumespresso/v7.3.1/gh200/repo/packages/quantum-espresso/configure_aocc.patch new file mode 100644 index 00000000..c7ef8c63 --- /dev/null +++ b/recipes/quantumespresso/v7.3.1/gh200/repo/packages/quantum-espresso/configure_aocc.patch @@ -0,0 +1,72 @@ +diff --git a/install/configure b/install/configure_aocc +index 66337d1..d2c04af 100755 +--- a/install/configure ++++ b/install/configure_aocc +@@ -3199,6 +3199,7 @@ + ifort_version=`$mpif90 -V 2>&1 | grep "Intel(R)"` + pgf_version=`$mpif90 -V 2>&1 | grep "^pgf"` + nvfortran_version=`$mpif90 -V 2>&1 | grep "^nvfortran"` ++ aoccflang_version=`$mpif90 -v 2>&1 | grep "AMD clang version"` + gfortran_version=`$mpif90 -v 2>&1 | grep "gcc version"` + nagfor_version=`$mpif90 -v 2>&1 | grep "NAG Fortran"` + xlf_version=`$mpif90 -v 2>&1 | grep "xlf"` +@@ -3215,6 +3216,12 @@ case "$arch" in + version=`echo $nvfortran_version | cut -d ' ' -f2` + echo "${ECHO_T}nvfortran $version" + f90_in_mpif90="nvfortran" ++ elif test "$aoccflang_version" != "" ++ then ++ version=`echo $aoccflang_version | cut -d" " -f 5` ++ echo "${ECHO_T}mpif90 $version" ++ f90_in_mpif90="mpif90" ++ try_foxflags="-D__PGI" + elif test "$pgf_version" != "" + then + version=`echo $pgf_version | cut -d ' ' -f2` +@@ -3397,6 +3404,9 @@ ppc64-bg*:*xlf90_r ) + ppc64-bg*:*xlf90 ) + try_cc="bgxlc" + ;; ++*:mpif90 ) ++ try_cc="mpicc $try_cc" ++ ;; + ppc64:*xlf* | ppc64le:*xlf* ) + try_cc="xlc_r $try_cc" + ;; +@@ -3779,6 +3789,10 @@ necsx:* ) + ppc64le:* ) + try_cflags="-O3" + ;; ++x86_64:* ) ++ try_cflags=" -Mstack_arrays" ++ try_dflags="-D__OPENMP" ++ ;; + ppc64-bg:* ) + try_cflags="-O3 -q32" + ;; +@@ -3915,6 +3929,16 @@ crayxt*:cray* ) + try_dflags="$try_dflags -D__CRAY" + have_cpp=0 + ;; ++*:*mpif90 ) ++ try_fflags="-Mstack_arrays" ++ try_fflags_openmp="-fopenmp" ++ try_f90flags=" \$(FFLAGS) -cpp -Mpreprocess -Mstack_arrays" ++ try_foxflags="-D__PGI" ++ try_fflags_noopt="-O0" ++ try_ldflags="" ++ try_ldflags_openmp="-fopenmp" ++ try_ldflags_static="-static" ++ ;; + crayxt*:pgf* ) + # see comment above for pgf* + try_fflags_nomain="-Mnomain" +@@ -7815,7 +7839,7 @@ $as_echo "$as_me: WARNING: *** HDF5 version must be 1.8.16 or later" >&2;}; + if test $with_hdf5_libs -eq 1; then + hdf5_libs=$with_hdf5_libline + else +- hdf5_libs=`$with_hdf5_path/bin/h5pfc -show | awk -F'-L' '{$1=""; for (i=2; i<=NF;i++) $i="-L"$i; print $0}'` ++ hdf5_libs=`$with_hdf5_path/bin/h5pfc -show | awk -F'-L' '{$1=""; for (i=2; i<=NF;i++) $i="-L"$i; print $0}' | xargs` + fi + elif command -v h5pfc >/dev/null; then + if test $with_hdf5_libs -eq 1; then diff --git a/recipes/quantumespresso/v7.3.1/gh200/repo/packages/quantum-espresso/dspev_drv_elpa.patch b/recipes/quantumespresso/v7.3.1/gh200/repo/packages/quantum-espresso/dspev_drv_elpa.patch new file mode 100644 index 00000000..153bcf2e --- /dev/null +++ b/recipes/quantumespresso/v7.3.1/gh200/repo/packages/quantum-espresso/dspev_drv_elpa.patch @@ -0,0 +1,42 @@ +diff -ruN LAXlib-orig/dspev_drv.f90 LAXlib/dspev_drv.f90 +--- a/LAXlib/dspev_drv.f90 2017-06-12 15:00:46.157372185 +0200 ++++ b/LAXlib/dspev_drv.f90 2017-06-12 15:01:19.937371580 +0200 +@@ -708,11 +708,11 @@ + + #if defined(__ELPA_2016) + ! -> ELPA 2016.11.001_pre +- ierr = elpa_get_communicators(ortho_comm, my_prow, my_pcol,mpi_comm_rows, mpi_comm_cols) +- success = solve_evp_real_1stage(n, n, s, lds, w, vv, lds,SIZE(s,2),nb ,mpi_comm_rows, mpi_comm_cols, ortho_comm) ++ !ierr = elpa_get_communicators(ortho_comm, my_prow, my_pcol,mpi_comm_rows, mpi_comm_cols) ++ !success = solve_evp_real_1stage(n, n, s, lds, w, vv, lds,SIZE(s,2),nb ,mpi_comm_rows, mpi_comm_cols, ortho_comm) + ! -> ELPA 2016.05.003 +- !ierr = get_elpa_row_col_comms(ortho_comm, my_prow, my_pcol,mpi_comm_rows, mpi_comm_cols) +- !success = solve_evp_real_1stage(n, n, s, lds, w, vv, lds,SIZE(s,2),nb ,mpi_comm_rows, mpi_comm_cols) ++ ierr = get_elpa_row_col_comms(ortho_comm, my_prow, my_pcol,mpi_comm_rows, mpi_comm_cols) ++ success = solve_evp_real_1stage(n, n, s, lds, w, vv, lds,SIZE(s,2),nb ,mpi_comm_rows, mpi_comm_cols) + #elif defined(__ELPA_2015) + ierr = get_elpa_row_col_comms(ortho_comm, my_prow, my_pcol,mpi_comm_rows, mpi_comm_cols) + ierr = solve_evp_real(n, n, s, lds, w, vv, lds,SIZE(s,2),nb ,mpi_comm_rows, mpi_comm_cols) +diff -ruN LAXlib-orig/zhpev_drv.f90 LAXlib/zhpev_drv.f90 +--- a/LAXlib/zhpev_drv.f90 2017-06-12 15:00:46.157372185 +0200 ++++ b/LAXlib/zhpev_drv.f90 2017-06-12 15:02:09.309370696 +0200 +@@ -1519,13 +1519,13 @@ + + #if defined(__ELPA_2016) + ! -> ELPA 2016.11.001_pre +- ierr = elpa_get_communicators(ortho_comm, my_prow, my_pcol,mpi_comm_rows, mpi_comm_cols) +- success = solve_evp_complex_1stage_double(n, n, h, size(h,1), w, v, size(h,1), size(h,2), nb, & +- mpi_comm_rows, mpi_comm_cols, ortho_comm) ++ !ierr = elpa_get_communicators(ortho_comm, my_prow, my_pcol,mpi_comm_rows, mpi_comm_cols) ++ !success = solve_evp_complex_1stage_double(n, n, h, size(h,1), w, v, size(h,1), size(h,2), nb, & ++ ! mpi_comm_rows, mpi_comm_cols, ortho_comm) + ! -> ELPA 2016.05.003 +- !ierr = get_elpa_row_col_comms(ortho_comm, my_prow, my_pcol,mpi_comm_rows, mpi_comm_cols) +- !success = solve_evp_complex(n, n, h, size(h,1), w, v, size(h,1), size(h,2), nb, & +- ! mpi_comm_rows, mpi_comm_cols) ++ ierr = get_elpa_row_col_comms(ortho_comm, my_prow, my_pcol,mpi_comm_rows, mpi_comm_cols) ++ success = solve_evp_complex(n, n, h, size(h,1), w, v, size(h,1), size(h,2), nb, & ++ mpi_comm_rows, mpi_comm_cols) + #elif defined(__ELPA_2015) + ierr = get_elpa_row_col_comms(ortho_comm, my_prow, my_pcol,mpi_comm_rows, mpi_comm_cols) + ierr = solve_evp_complex(n, n, h, size(h,1), w, v, size(h,1), size(h,2), nb, & diff --git a/recipes/quantumespresso/v7.3.1/gh200/repo/packages/quantum-espresso/fj-fox.patch b/recipes/quantumespresso/v7.3.1/gh200/repo/packages/quantum-espresso/fj-fox.patch new file mode 100644 index 00000000..d4fb79ab --- /dev/null +++ b/recipes/quantumespresso/v7.3.1/gh200/repo/packages/quantum-espresso/fj-fox.patch @@ -0,0 +1,10 @@ +--- spack-src/install/extlibs_makefile.org 2021-01-22 10:11:00.527343202 +0900 ++++ spack-src/install/extlibs_makefile 2021-01-22 10:15:24.319956918 +0900 +@@ -89,6 +89,7 @@ + mkdir ../FoX; \ + (gzip -dc ../archive/fox.tgz | (cd ../FoX; tar -xvf -)); \ + cd ../FoX/fox/; export FC=$(F90); export FCFLAGS="$(FOX_FLAGS)"; \ ++ sed -i 's/"-out " "-o "/"-o " "-out "/' configure; \ + ./configure --prefix=$(TOPDIR)/FoX ;\ + $(MAKE) install; cd ../; rm -fr fox;fi + # ELPA diff --git a/recipes/quantumespresso/v7.3.1/gh200/repo/packages/quantum-espresso/fj-intent.6.4.1.patch b/recipes/quantumespresso/v7.3.1/gh200/repo/packages/quantum-espresso/fj-intent.6.4.1.patch new file mode 100644 index 00000000..7266a9b5 --- /dev/null +++ b/recipes/quantumespresso/v7.3.1/gh200/repo/packages/quantum-espresso/fj-intent.6.4.1.patch @@ -0,0 +1,11 @@ +--- spack-src/PHonon/Gamma/dgradcorr.f90.org 2021-01-27 16:41:04.692204340 +0900 ++++ spack-src/PHonon/Gamma/dgradcorr.f90 2021-01-27 16:44:03.877839298 +0900 +@@ -22,7 +22,7 @@ + + REAL(DP), INTENT(IN) :: rho (dfft%nnr, nspin), grho (3, dfft%nnr, nspin), & + g (3, dfft%ngm) +- REAL(DP), INTENT(OUT):: drho (dfft%nnr,nspin),& ++ REAL(DP), INTENT(IN):: drho (dfft%nnr,nspin),& + dvxc_rr(dfft%nnr, nspin, nspin), dvxc_sr (dfft%nnr, nspin, nspin), & + dvxc_ss (dfft%nnr,nspin, nspin), dvxc_s (dfft%nnr, nspin, nspin) + REAL(DP), INTENT(INOUT) :: dvxc (dfft%nnr, nspin) diff --git a/recipes/quantumespresso/v7.3.1/gh200/repo/packages/quantum-espresso/fj.6.5.patch b/recipes/quantumespresso/v7.3.1/gh200/repo/packages/quantum-espresso/fj.6.5.patch new file mode 100644 index 00000000..503a0e9e --- /dev/null +++ b/recipes/quantumespresso/v7.3.1/gh200/repo/packages/quantum-espresso/fj.6.5.patch @@ -0,0 +1,23 @@ +--- spack-src/install/configure.org 2021-01-22 12:21:20.196915072 +0900 ++++ spack-src/install/configure 2021-01-22 12:24:47.562530103 +0900 +@@ -3127,6 +3127,7 @@ + pgf_version=`$mpif90 -V 2>&1 | grep "^pgf"` + gfortran_version=`$mpif90 -v 2>&1 | grep "gcc version"` + nagfor_version=`$mpif90 -v 2>&1 | grep "NAG Fortran"` ++ frt_version=`$mpif90 -v 2>&1 | grep "Fujitsu Fortran Compiler"` + xlf_version=`$mpif90 -v 2>&1 | grep "xlf"` + # + if test "$ifort_version" != "" +@@ -3160,6 +3161,12 @@ + echo "${ECHO_T}xlf (version unknonw)" + f90_in_mpif90="xlf" + try_dflags="-D__XLF" ++ elif test "$frt_version" != "" ++ then ++ version=`echo $frt_version | cut -d" " -f 5` ++ echo "${ECHO_T}frt $version" ++ f90_in_mpif90="frt" ++ try_foxflags="-D__FUJITSU" + else + echo "${ECHO_T}unknown, assuming gfortran" + f90_in_mpif90="gfortran" diff --git a/recipes/quantumespresso/v7.3.1/gh200/repo/packages/quantum-espresso/fj.6.6.patch b/recipes/quantumespresso/v7.3.1/gh200/repo/packages/quantum-espresso/fj.6.6.patch new file mode 100644 index 00000000..7b2db5d8 --- /dev/null +++ b/recipes/quantumespresso/v7.3.1/gh200/repo/packages/quantum-espresso/fj.6.6.patch @@ -0,0 +1,23 @@ +--- spack-src/install/configure.org 2021-01-15 09:27:53.000000000 +0900 ++++ spack-src/install/configure 2021-01-15 09:26:53.000000000 +0900 +@@ -3200,6 +3200,7 @@ + nagfor_version=`$mpif90 -v 2>&1 | grep "NAG Fortran"` + xlf_version=`$mpif90 -v 2>&1 | grep "xlf"` + armflang_version=`$mpif90 -v 2>&1 | grep "Arm C/C++/Fortran Compiler version"` ++ frt_version=`$mpif90 -v 2>&1 | grep "Fujitsu Fortran Compiler"` + # + if test "$ifort_version" != "" + then +@@ -3237,6 +3238,12 @@ + f90_minor_version=`echo $version | cut -d. -f2` + f90_in_mpif90="armflang" + try_foxflags="-D__PGI" ++ elif test "$frt_version" != "" ++ then ++ version=`echo $frt_version | cut -d" " -f 5` ++ echo "${ECHO_T}frt $version" ++ f90_in_mpif90="frt" ++ try_foxflags="-D__FUJITSU" + else + echo "${ECHO_T}unknown, assuming gfortran" + f90_in_mpif90="gfortran" diff --git a/recipes/quantumespresso/v7.3.1/gh200/repo/packages/quantum-espresso/gipaw-eccee44.patch b/recipes/quantumespresso/v7.3.1/gh200/repo/packages/quantum-espresso/gipaw-eccee44.patch new file mode 100644 index 00000000..e2d81790 --- /dev/null +++ b/recipes/quantumespresso/v7.3.1/gh200/repo/packages/quantum-espresso/gipaw-eccee44.patch @@ -0,0 +1,8 @@ +--- spack-src/external/submodule_commit_hash_records.org 2023-11-15 18:38:47.485317449 -0300 ++++ spack-src/external/submodule_commit_hash_records 2023-11-15 18:39:02.661861757 -0300 +@@ -5,4 +5,4 @@ + 82005cbb65bdf5d32ca021848eec8f19da956a77 mbd + f72ab25fa4ea755c1b4b230ae8074b47d5509c70 pw2qmcpack + 1d6b187374a2d50b509e5e79e2cab01a79ff7ce1 wannier90 +-f5823521ad8fdd8b8e9e29197eedb354f9b9146d qe-gipaw ++eccee44d3caf1c930fb72ad9c741fbb743eabf45 qe-gipaw diff --git a/recipes/quantumespresso/v7.3.1/gh200/repo/packages/quantum-espresso/nvhpc.patch b/recipes/quantumespresso/v7.3.1/gh200/repo/packages/quantum-espresso/nvhpc.patch new file mode 100644 index 00000000..9b5714e6 --- /dev/null +++ b/recipes/quantumespresso/v7.3.1/gh200/repo/packages/quantum-espresso/nvhpc.patch @@ -0,0 +1,106 @@ +--- a/install/configure 2020-09-08 07:25:53.088725750 -0700 ++++ b/install/configure 2020-09-08 07:35:22.637773050 -0700 +@@ -2349,7 +2349,7 @@ + ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5' + ac_compiler_gnu=$ac_cv_fc_compiler_gnu + if test -n "$ac_tool_prefix"; then +- for ac_prog in gfortran g95 xlf95 f95 fort ifort ifc efc pgfortran pgf95 lf95 ftn nagfor xlf90 f90 pgf90 pghpf epcf90 g77 xlf f77 frt pgf77 cf77 fort77 fl32 af77 ++ for ac_prog in gfortran g95 xlf95 f95 fort ifort ifc efc nvfortran pgfortran pgf95 lf95 ftn nagfor xlf90 f90 pgf90 pghpf epcf90 g77 xlf f77 frt pgf77 cf77 fort77 fl32 af77 + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. + set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +@@ -2393,7 +2393,7 @@ + fi + if test -z "$FC"; then + ac_ct_FC=$FC +- for ac_prog in gfortran g95 xlf95 f95 fort ifort ifc efc pgfortran pgf95 lf95 ftn nagfor xlf90 f90 pgf90 pghpf epcf90 g77 xlf f77 frt pgf77 cf77 fort77 fl32 af77 ++ for ac_prog in gfortran g95 xlf95 f95 fort ifort ifc efc nvfortran pgfortran pgf95 lf95 ftn nagfor xlf90 f90 pgf90 pghpf epcf90 g77 xlf f77 frt pgf77 cf77 fort77 fl32 af77 + do + # Extract the first word of "$ac_prog", so it can be a program name with args. + set dummy $ac_prog; ac_word=$2 +@@ -2810,7 +2810,7 @@ + # candidate compilers and flags based on architecture + case $arch in + ia32 | ia64 | x86_64 ) +- try_f90="ifort pgf90 nagfor $try_f90" ++ try_f90="ifort nvfortran pgf90 nagfor $try_f90" + ;; + arm ) + try_f90="$try_f90" +@@ -3125,6 +3125,7 @@ + echo $ECHO_N "checking version of $mpif90... $ECHO_C" + ifort_version=`$mpif90 -V 2>&1 | grep "Intel(R)"` + pgf_version=`$mpif90 -V 2>&1 | grep "^pgf"` ++ nvfortran_version=`$mpif90 -V 2>&1 | grep "^nvfortran"` + gfortran_version=`$mpif90 -v 2>&1 | grep "gcc version"` + nagfor_version=`$mpif90 -v 2>&1 | grep "NAG Fortran"` + xlf_version=`$mpif90 -v 2>&1 | grep "xlf"` +@@ -3142,6 +3143,11 @@ + f90_in_mpif90="pgf90" + # flag to test MKL with PGI + MKL_FLAGS="-pgf90libs" ++ elif test "$nvfortran_version" != "" ++ then ++ version=`echo $nvfortran_version | cut -d ' ' -f2` ++ echo "${ECHO_T}nvfortran $version" ++ f90_in_mpif90="nvfortran" + elif test "$gfortran_version" != "" + then + version=`echo $gfortran_version | cut -d ' ' -f3` +@@ -3242,6 +3250,8 @@ + f90_flavor=ifort + elif $f90 -V 2>&1 | grep -q "^pgf" ; then + f90_flavor=pgf ++ elif $f90 -V 2>&1 | grep -q "^nvfortran" ; then ++ f90_flavor=nvfortran + elif $f90 -v 2>&1 | grep -q "gcc version" ; then + f90_flavor=gfortran + elif $f90 -V 2>&1 | grep -q "Cray Fortran" ; then +@@ -3300,6 +3310,9 @@ + *:pgf90 ) + try_cc="pgcc $try_cc" + ;; ++*:nvfortran ) ++ try_cc="nvc $try_cc" ++ ;; + cray*:* ) + try_cc="cc" + ;; +@@ -4166,6 +4179,19 @@ + try_dflags="$try_dflags -D__PGI" + have_cpp=1 + ;; ++*:nvfortran* ) ++ try_fflags_nomain="-Mnomain" ++ try_fflags="-fast" ++ try_fflags_openmp="-mp" ++ try_f90flags="-fast -Mcache_align -Mpreprocess -Mlarge_arrays" ++ try_foxflags="-fast -Mcache_align -Mpreprocess -Mlarge_arrays" ++ try_fflags_noopt="-O0" ++ try_ldflags="" ++ try_ldflags_openmp="-mp" ++ try_ldflags_static="-static" ++ try_dflags="$try_dflags -D__PGI" ++ have_cpp=1 ++ ;; + *:*gfortran ) + try_fflags="-O3 -g" + if test "$use_debug" -eq 1; then +@@ -5044,7 +5070,7 @@ + done + ;; + +- x86_64:pgf* ) ++ x86_64:pgf* | x8_64:nvfortran ) + try_libdirs="/opt/acml*/pathscale64/lib/" + try_libdirs="$ld_library_path $libdirs $try_libdirs" + +@@ -6245,7 +6271,7 @@ + if test "$have_blas" -eq 0 + then + case "$f90" in +- pgf* ) ++ pgf* | nvfortran ) + # check for PGI blas + unset ac_cv_search_dgemm # clear cached value + FFLAGS="$test_fflags" diff --git a/recipes/quantumespresso/v7.3.1/gh200/repo/packages/quantum-espresso/package.py b/recipes/quantumespresso/v7.3.1/gh200/repo/packages/quantum-espresso/package.py new file mode 100644 index 00000000..39e9fa7d --- /dev/null +++ b/recipes/quantumespresso/v7.3.1/gh200/repo/packages/quantum-espresso/package.py @@ -0,0 +1,680 @@ +# Copyright 2013-2024 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) +import spack.build_systems.cmake +import spack.build_systems.generic +from spack.package import * + + +class QuantumEspresso(CMakePackage, Package): + """Quantum ESPRESSO is an integrated suite of Open-Source computer codes + for electronic-structure calculations and materials modeling at the + nanoscale. It is based on density-functional theory, plane waves, and + pseudopotentials. + """ + + homepage = "http://quantum-espresso.org" + url = "https://gitlab.com/QEF/q-e/-/archive/qe-6.6/q-e-qe-6.6.tar.gz" + git = "https://gitlab.com/QEF/q-e.git" + + maintainers("ye-luo", "bellenlau", "tgorni") + + build_system(conditional("cmake", when="@6.8:"), "generic", default="cmake") + + license("GPL-2.0-only") + + version("develop", branch="develop") + version("7.3.1", sha256="2c58b8fadfe4177de5a8b69eba447db5e623420b070dea6fd26c1533b081d844") + version("7.3", sha256="edc2a0f3315c69966df4f82ec86ab9f682187bc9430ef6d2bacad5f27f08972c") + version("7.2", sha256="b348a4a7348b66a73545d9ca317a2645755c98d343c1cfe8def475ad030808c0") + version("7.1", sha256="d56dea096635808843bd5a9be2dee3d1f60407c01dbeeda03f8256a3bcfc4eb6") + version("7.0", sha256="85beceb1aaa1678a49e774c085866d4612d9d64108e0ac49b23152c8622880ee") + version("6.8", sha256="654855c69864de7ece5ef2f2c0dea2d32698fe51192a8646b1555b0c57e033b2") + version( + "6.7", + sha256="fe0ce74ff736b10d2a20c9d59025c01f88f86b00d229c123b1791f1edd7b4315", + url="https://gitlab.com/QEF/q-e/-/archive/qe-6.7MaX-Release/q-e-qe-6.7MaX-Release.tar.gz", + ) + version("6.6", sha256="924656cb083f52e5d2fe71ade05881389dac64b45316f1bdd6dee1c6170a672c") + version("6.5", sha256="258b2a8a6280e86dad779e5c56356d8b35dc96d12ff33dabeee914bc03d6d602") + version("6.4.1", sha256="b0d7e9f617b848753ad923d8c6ca5490d5d82495f82b032b71a0ff2f2e9cfa08") + version("6.4", sha256="781366d03da75516fdcf9100a1caadb26ccdd1dedd942a6f8595ff0edca74bfe") + version("6.3", sha256="4067c8fffa957aabbd5cf2439e2fcb6cf3752325393c67a17d99fd09edf8689c") + version("6.2.1", sha256="11fe24b4a9d85834f8b6d429baebed8b360a685ecfae222887ed451e118a9156") + version("6.2.0", sha256="e204df367c8ea1a50c7534b44481841d835a542a23ae71c3e33ad712fc636c8b") + version("6.1.0", sha256="fd2c2eb346b3ca8f08138df5ef3f69b466c256d2119db40eea1b578b0a42c66e") + version("6.0.0", sha256="bc77d9553bf5a9253ae74058dffb1d6e5fb61093188e78d3b8d8564755136f19") + version("5.4", sha256="e3993fccae9cea04a5c6492e8b961a053a63727051cb5c4eb6008f62cda8f335") + version("5.3", sha256="3b26038efb9e3f8ac7a2b950c31d8c29169a3556c0b68c299eb88a4be8dc9048") + + resource( + name="environ", + git="https://github.com/environ-developers/Environ.git", + tag="v1.1", + when="@6.3:6.4 +environ", + destination=".", + ) + + resource( + name="environ", + git="https://github.com/environ-developers/Environ.git", + tag="v1.0", + when="@6.2.1:6.2 +environ", + destination=".", + ) + + with when("build_system=cmake"): + depends_on("cmake@3.14.0:", type="build") + + variant("libxc", default=False, description="Uses libxc") + depends_on("libxc@5.1.2:", when="+libxc") + + variant("openmp", default=True, description="Enables OpenMP support") + # Need OpenMP threaded FFTW and BLAS libraries when configured + # with OpenMP support + with when("+openmp"): + depends_on("fftw+openmp", when="^[virtuals=fftw-api] fftw") + depends_on("amdfftw+openmp", when="^[virtuals=fftw-api] amdfftw") + depends_on("openblas threads=openmp", when="^[virtuals=blas] openblas") + depends_on("amdblis threads=openmp", when="^[virtuals=blas] amdblis") + depends_on("intel-mkl threads=openmp", when="^[virtuals=blas] intel-mkl") + depends_on("armpl-gcc threads=openmp", when="^[virtuals=blas] armpl-gcc") + depends_on("acfl threads=openmp", when="^[virtuals=blas] acfl") + + # Add Cuda Fortran support + # depends on NVHPC compiler, not directly on CUDA toolkit + with when("%nvhpc"): + variant("cuda", default=False, description="Build with CUDA Fortran") + with when("+cuda"): + # GPUs are enabled since v6.6 + conflicts("@:6.5") + # cuda version >= 10.1 + # conflicts("cuda@:10.0.130") + # bugs with following nvhpcsdk versions and +openmp + with when("+openmp"): + conflicts( + "%nvhpc@21.11:22.3", + msg="bugs with NVHPCSDK from v21.11 to v22.3, OpenMP and GPU", + ) + # only cmake is supported + conflicts("build_system=generic", msg="Only CMake supported for GPU-enabled version") + + # NVTX variant for profiling + # requires linking to CUDA runtime APIs , handled by CMake + variant("nvtx", default=False, description="Enables NVTX markers for profiling") + with when("+nvtx~cuda"): + depends_on("cuda") + + # CLOCK variant to display program time in seconds + variant("clock", default=False, description="Display program time in seconds") + + # Apply upstream patches by default. Variant useful for 3rd party + # patches which are incompatible with upstream patches + desc = "Apply recommended upstream patches. May need to be set " + desc = desc + "to False for third party patches or plugins" + variant("patch", default=True, description=desc) + + variant("mpi", default=True, description="Builds with mpi support") + with when("+mpi"): + depends_on("mpi") + variant("scalapack", default=True, description="Enables scalapack support") + with when("%nvhpc+cuda"): + # add mpi_gpu_aware variant, False by default + variant("mpigpu", default=False, description="Enables GPU-aware MPI operations") + + with when("+scalapack"): + depends_on("scalapack") + variant("elpa", default=False, description="Uses elpa as an eigenvalue solver") + + with when("+elpa"): + # CMake builds only support elpa without openmp + depends_on("elpa~openmp", when="build_system=cmake") + with when("build_system=generic"): + depends_on("elpa", when="+openmp") + depends_on("elpa~openmp", when="~openmp") + # Elpa is formally supported by @:5.4.0, but QE configure searches + # for it in the wrong folders (or tries to download it within + # the build directory). Instead of patching Elpa to provide the + # folder QE expects as a link, we issue a conflict here. + conflicts("@:5.4.0", msg="+elpa requires QE >= 6.0") + + variant("fox", default=False, description="Enables FoX library") + with when("+fox"): + conflicts("@:7.1", msg="+fox variant requires QE >= 7.2") + + # Support for HDF5 has been added starting in version 6.1.0 and is + # still experimental, therefore we default to False for the variant + variant( + "hdf5", + default="none", + description="Orbital and density data I/O with HDF5", + values=("parallel", "serial", "none"), + multi=False, + ) + + # Versions of HDF5 prior to 1.8.16 lead to QE runtime errors + depends_on("hdf5@1.8.16:+fortran+hl+mpi", when="hdf5=parallel") + depends_on("hdf5@1.8.16:+fortran+hl~mpi", when="hdf5=serial") + + # HDF5 support introduced in 6.1.0, but the configure had some limitations. + # In recent tests (Oct 2019), GCC and Intel work with the HDF5 Spack + # package for the default variant. This is only for hdf5=parallel variant. + # Support, for hdf5=serial was introduced in 6.4.1 but required a patch + # for the serial (no MPI) case. This patch was to work around an issue + # that only manifested itself inside the Spack environment. + conflicts( + "hdf5=parallel", when="@:6.0", msg="parallel HDF5 support only in QE 6.1.0 and later" + ) + + conflicts("hdf5=serial", when="@:6.4.0", msg="serial HDF5 support only in QE 6.4.1 and later") + + conflicts("hdf5=parallel", when="~mpi", msg="parallel HDF5 requires MPI support") + + # QMCPACK converter patch + # https://github.com/QMCPACK/qmcpack/tree/develop/external_codes/quantum_espresso + variant("qmcpack", default=False, description="Build QE-to-QMCPACK wave function converter") + + with when("+qmcpack"): + # Some QMCPACK converters are incompatible with upstream patches. + # HDF5 is a hard requirement. Need to do two HDF5 cases explicitly + # since Spack lacks support for expressing NOT operation. + conflicts( + "@6.4+patch", + msg="QE-to-QMCPACK wave function converter requires " + "deactivatation of upstream patches", + ) + conflicts( + "@6.3:6.4.0 hdf5=serial", + msg="QE-to-QMCPACK wave function converter only " "supported with parallel HDF5", + ) + conflicts("@:7.0 hdf5=none", msg="QE-to-QMCPACK wave function converter requires HDF5") + # QE > 7.0, the converter for QMCPACK can be built without hdf5 enabled in QE. + # The converter for QMCPACK itself still needs hdf5 library + with when("@7.0.1:"): + # when QE doesn't use hdf5 library, the converter plugin still needs it + depends_on("hdf5@1.8.16:+hl~mpi", when="hdf5=none") + conflicts( + "build_system=generic", msg="QE-to-QMCPACK wave function converter requires cmake" + ) + + # Enables building Electron-phonon Wannier 'epw.x' executable + # http://epw.org.uk/Main/About + variant("epw", default=True, description="Builds Electron-phonon Wannier executable") + conflicts("~epw", when="build_system=cmake", msg="epw cannot be turned off when using CMake") + + with when("+epw"): + # The first version of Q-E to feature integrated EPW is 6.0.0, + # as per http://epw.org.uk/Main/DownloadAndInstall . + # Complain if trying to install a version older than this. + conflicts("@:5", msg="EPW only available from version 6.0.0 and on") + + # Below goes some constraints as shown in the link above. + # Constraints may be relaxed as successful reports + # of different compiler+mpi combinations arrive + + # TODO: enable building EPW when ~mpi and build_system=generic + conflicts( + "~mpi", when="build_system=generic", msg="EPW needs MPI when build_system=generic" + ) + + # EPW doesn't gets along well with OpenMPI 2.x.x + conflicts("^openmpi@2.0.0:2", msg="OpenMPI version incompatible with EPW") + + # EPW also doesn't gets along well with PGI 17.x + OpenMPI 1.10.7 + conflicts( + "^openmpi@1.10.7%pgi@17.0:17.12", msg="PGI+OpenMPI version combo incompatible with EPW" + ) + + variant( + "environ", + default=False, + when="build_system=generic", + description="Enables support for introducing environment effects " + "into atomistic first-principles simulations." + "See http://quantum-environ.org/about.html", + ) + + variant( + "gipaw", + default=False, + description="Builds Gauge-Including Projector Augmented-Waves executable", + ) + + # Dependencies not affected by variants + depends_on("blas") + depends_on("lapack") + depends_on("fftw-api@3") + depends_on("git@2.13:", type="build") + depends_on("m4", type="build") + + # If the Intel suite is used for Lapack, it must be used for fftw and vice-versa + for _intel_pkg in INTEL_MATH_LIBRARIES: + requires(f"^[virtuals=fftw-api] {_intel_pkg}", when=f"^[virtuals=lapack] {_intel_pkg}") + requires(f"^[virtuals=lapack] {_intel_pkg}", when=f"^[virtuals=fftw-api] {_intel_pkg}") + + # CONFLICTS SECTION + # Omitted for now due to concretizer bug + # MKL with 64-bit integers not supported. + # conflicts( + # '^mkl+ilp64', + # msg='Quantum ESPRESSO does not support MKL 64-bit integer variant' + # ) + + # PATCHES SECTION + # THIRD-PARTY PATCHES + # NOTE: *SOME* third-party patches will require deactivation of + # upstream patches using `~patch` variant + + # gipaw + conflicts( + "@:6.2", + when="+gipaw", + msg="gipaw standard support available for QE 6.3 or greater version only", + ) + conflicts("~fox", when="@7.2: +gipaw", msg="gipaw plugin requires FoX") + conflicts("+gipaw build_system=cmake", when="@:7.1") + + # Only CMake will work for @6.8: %aocc + conflicts( + "build_system=generic", when="@6.8: %aocc", msg="Please use CMake to build with AOCC" + ) + + conflicts("~openmp", when="^amdlibflame", msg="amdlibflame requires OpenMP") + + # QMCPACK converter patches for QE 6.8, 6.7, 6.4.1, 6.4, and 6.3 + conflicts( + "@:6.2,6.5:6.6", + when="+qmcpack", + msg="QMCPACK converter NOT available for this version of QE", + ) + + # Internal compiler error gcc8 and a64fx, I check only 6.5 and 6.6 + conflicts( + "@5.3:", when="%gcc@8 target=a64fx", msg="Internal compiler error with gcc8 and a64fx" + ) + + conflicts("@6.5:", when="+environ", msg="6.4.x is the latest QE series supported by Environ") + + # QE 7.1 fix post-processing install part 1/2 + # see: https://gitlab.com/QEF/q-e/-/merge_requests/2005 + patch_url = "https://gitlab.com/QEF/q-e/-/commit/4ca3afd4c6f27afcf3f42415a85a353a7be1bd37.diff" + patch_checksum = "e54d33e36a2667bd1d7e358db9fa9d4d83085264cdd47e39ce88754452ae7700" + patch(patch_url, sha256=patch_checksum, when="@7.1 build_system=cmake") + + # QE 7.1 fix post-processing install part 2/2 + # see: https://gitlab.com/QEF/q-e/-/merge_requests/2007 + patch_url = "https://gitlab.com/QEF/q-e/-/commit/481a001293de2f9eec8481e02d64f679ffd83ede.diff" + patch_checksum = "5075f2df61ef5ff70f2ec3b52a113f5636fb07f5d3d4c0115931f9b95ed61c3e" + patch(patch_url, sha256=patch_checksum, when="@7.1 build_system=cmake") + + # No patch needed for QMCPACK converter beyond 7.0 + # 7.0 + patch_url = "https://raw.githubusercontent.com/QMCPACK/qmcpack/v3.13.0/external_codes/quantum_espresso/add_pw2qmcpack_to_qe-7.0.diff" + patch_checksum = "ef60641d8b953b4ba21d9c662b172611305bb63786996ad6e81e7609891677ff" + patch(patch_url, sha256=patch_checksum, when="@7.0+qmcpack") + + # 6.8 + patch_url = "https://raw.githubusercontent.com/QMCPACK/qmcpack/v3.13.0/external_codes/quantum_espresso/add_pw2qmcpack_to_qe-6.8.diff" + patch_checksum = "69f7fbd72aba810c35a0b034188e45bea8f9f11d3150c0715e1b3518d5c09248" + patch(patch_url, sha256=patch_checksum, when="@6.8+qmcpack") + + # 6.7 + patch_url = "https://raw.githubusercontent.com/QMCPACK/qmcpack/v3.13.0/external_codes/quantum_espresso/add_pw2qmcpack_to_qe-6.7.0.diff" + patch_checksum = "72564c168231dd4a1279a74e76919af701d47cee9a851db6e205753004fe9bb5" + patch(patch_url, sha256=patch_checksum, when="@6.7+qmcpack") + + # 6.4.1 + patch_url = "https://raw.githubusercontent.com/QMCPACK/qmcpack/v3.13.0/external_codes/quantum_espresso/add_pw2qmcpack_to_qe-6.4.1.diff" + patch_checksum = "57cb1b06ee2653a87c3acc0dd4f09032fcf6ce6b8cbb9677ae9ceeb6a78f85e2" + patch(patch_url, sha256=patch_checksum, when="@6.4.1+qmcpack") + # 6.4 + patch_url = "https://raw.githubusercontent.com/QMCPACK/qmcpack/v3.13.0/external_codes/quantum_espresso/add_pw2qmcpack_to_qe-6.4.diff" + patch_checksum = "ef08f5089951be902f0854a4dbddaa7b01f08924cdb27decfade6bef0e2b8994" + patch(patch_url, sha256=patch_checksum, when="@=6.4+qmcpack") + # 6.3 + patch_url = "https://raw.githubusercontent.com/QMCPACK/qmcpack/v3.13.0/external_codes/quantum_espresso/add_pw2qmcpack_to_qe-6.3.diff" + patch_checksum = "2ee346e24926479f5e96f8dc47812173a8847a58354bbc32cf2114af7a521c13" + patch(patch_url, sha256=patch_checksum, when="@6.3+qmcpack") + + # ELPA + patch("dspev_drv_elpa.patch", when="@6.1.0:+elpa ^elpa@2016.05.004") + patch("dspev_drv_elpa.patch", when="@6.1.0:+elpa ^elpa@2016.05.003") + + # QE UPSTREAM PATCHES + # QE 6.6 fix conpile error when FFT_LIBS is specified. + patch( + "https://gitlab.com/QEF/q-e/-/commit/cf1fedefc20d39f5cd7551ded700ea4c77ad6e8f.diff", + sha256="8f179663a8d031aff9b1820a32449942281195b6e7b1ceaab1f729651b43fa58", + when="+patch@6.6", + ) + # QE 6.5 INTENT(OUT) without settig value in tetra_weights_only(..., ef): + # For Fujitsu compiler + patch( + "https://gitlab.com/QEF/q-e/-/commit/8f096b53e75026701c681c508e2c24a9378c0950.diff", + sha256="f4f1cce4182b57ac797c8f6ec8460fe375ee96385fcd8f6a61e1460bc957eb67", + when="+patch@6.5", + ) + # QE 6.5 Fix INTENT + # For Fujitsu compiler + patch( + "https://gitlab.com/QEF/q-e/-/commit/c2a86201ed72693ffa50cc99b22f5d3365ae2c2b.diff", + sha256="b2dadc0bc008a3ad4b74ae85cc380dd2b63f2ae43a634e6f9d8db8077efcea6c", + when="+patch@6.5", + ) + # QE 6.3 requires multiple patches to fix MKL detection + # There may still be problems on Mac with MKL detection + patch( + "https://gitlab.com/QEF/q-e/commit/0796e1b7c55c9361ecb6515a0979280e78865e36.diff", + sha256="bc8c5b8523156cee002d97dab42a5976dffae20605da485a427b902a236d7e6b", + when="+patch@=6.3", + ) + + # QE 6.3 `make install` broken and a patch must be applied + patch( + "https://gitlab.com/QEF/q-e/commit/88e6558646dbbcfcafa5f3fa758217f6062ab91c.diff", + sha256="b776890d008e16cca28c31299c62f47de0ba606b900b17cbc27c041f45e564ca", + when="+patch@=6.3", + ) + + # QE 6.4.1 patch to work around configure issues that only appear in the + # Spack environment. We now are able to support: + # `spack install qe~mpi~scalapack hdf5=serial` + patch( + "https://gitlab.com/QEF/q-e/commit/5fb1195b0844e1052b7601f18ab5c700f9cbe648.diff", + sha256="b1aa3179ee1c069964fb9c21f3b832aebeae54947ce8d3cc1a74e7b154c3c10f", + when="+patch@6.4.1:6.5.0", + ) + + # QE 6.4.1 Fix intent for Fujitsu compiler + patch("fj-intent.6.4.1.patch", when="+patch@6.4.1") + # QE 6.4.1 Fix intent + patch( + "https://gitlab.com/QEF/q-e/-/commit/c2a86201ed72693ffa50cc99b22f5d3365ae2c2b.diff", + sha256="b2dadc0bc008a3ad4b74ae85cc380dd2b63f2ae43a634e6f9d8db8077efcea6c", + when="+patch@6.4.1", + ) + + # QE 6.4.1 Small fixes for XLF compilation + patch( + "https://gitlab.com/QEF/q-e/-/commit/cf088926d68792cbaea48960c222e336a3965df6.diff", + sha256="bbceba1fb08d01d548d4393bbcaeae966def13f75884268a0f84448457b8eaa3", + when="+patch@6.4.1:6.5.0", + ) + + # Patch automake configure for AOCC compilers + patch("configure_aocc.patch", when="@6.7 %aocc") + + # Configure updated to work with NVIDIA compilers + patch("nvhpc.patch", when="@6.5 %nvhpc") + + # Configure updated to work with Fujitsu compilers + patch("fj.6.5.patch", when="@6.5+patch %fj") + patch("fj.6.6.patch", when="@6.6:6.7+patch %fj") + + # extlibs_makefile updated to work with fujitsu compilers + patch("fj-fox.patch", when="+patch %fj") + + # gipaw.x will only be installed with cmake if the qe-gipaw version is >= 5c4a4ce. + patch("gipaw-eccee44.patch", when="@7.2+gipaw build_system=cmake") + + +class CMakeBuilder(spack.build_systems.cmake.CMakeBuilder): + def cmake_args(self): + spec = self.spec + + cmake_args = [ + self.define_from_variant("QE_ENABLE_MPI", "mpi"), + self.define_from_variant("QE_ENABLE_OPENMP", "openmp"), + self.define_from_variant("QE_ENABLE_SCALAPACK", "scalapack"), + self.define_from_variant("QE_ENABLE_ELPA", "elpa"), + self.define_from_variant("QE_ENABLE_LIBXC", "libxc"), + self.define_from_variant("QE_ENABLE_CUDA", "cuda"), + self.define_from_variant("QE_ENABLE_PROFILE_NVTX", "nvtx"), + self.define_from_variant("QE_CLOCK_SECONDS", "clock"), + self.define_from_variant("QE_ENABLE_MPI_GPU_AWARE", "mpigpu"), + ] + + plugins = [] + + if "+fox" in spec: + cmake_args.append(self.define("QE_ENABLE_FOX", True)) + + if "+gipaw" in spec: + plugins.append("gipaw") + + if "+cuda" in self.spec: + cmake_args.append(self.define("QE_ENABLE_OPENACC", True)) + + # QE prefers taking MPI compiler wrappers as CMake compilers. + if "+mpi" in spec: + cmake_args.append(self.define("CMAKE_C_COMPILER", spec["mpi"].mpicc)) + cmake_args.append(self.define("CMAKE_Fortran_COMPILER", spec["mpi"].mpifc)) + + if not spec.satisfies("hdf5=none"): + cmake_args.append(self.define("QE_ENABLE_HDF5", True)) + + if "+qmcpack" in spec: + if spec.satisfies("@:7.0"): + cmake_args.append(self.define("QE_ENABLE_PW2QMCPACK", True)) + else: + plugins.append("pw2qmcpack") + + if "^armpl-gcc" in spec or "^acfl" in spec: + cmake_args.append(self.define("BLAS_LIBRARIES", spec["blas"].libs.joined(";"))) + cmake_args.append(self.define("LAPACK_LIBRARIES", spec["lapack"].libs.joined(";"))) + # Up to q-e@7.1 set BLA_VENDOR to All to force detection of vanilla scalapack + if spec.satisfies("@:7.1"): + cmake_args.append(self.define("BLA_VENDOR", "All")) + + if plugins: + cmake_args.append(self.define("QE_ENABLE_PLUGINS", plugins)) + return cmake_args + + +class GenericBuilder(spack.build_systems.generic.GenericBuilder): + def install(self, pkg, spec, prefix): + prefix_path = prefix.bin if "@:5.4.0" in spec else prefix + options = ["-prefix={0}".format(prefix_path)] + + # This additional flag is needed anytime the target architecture + # does not match the host architecture, which results in a binary that + # configure cannot execute on the login node. This is how we detect + # cross compilation: If the platform is NOT either Linux or Darwin + # and the target=backend, that we are in the cross-compile scenario + # scenario. This should cover Cray, BG/Q, and other custom platforms. + # The other option is to list out all the platform where you would be + # cross compiling explicitly. + if not (spec.satisfies("platform=linux") or spec.satisfies("platform=darwin")): + if spec.satisfies("target=backend"): + options.append("--host") + + # QE autoconf compiler variables has some limitations: + # 1. There is no explicit MPICC variable so we must re-purpose + # CC for the case of MPI. + # 2. F90 variable is set to be consistent with MPIF90 wrapper + # 3. If an absolute path for F90 is set, the build system breaks. + # + # Thus, due to 2. and 3. the F90 variable is not explictly set + # because it would be mostly pointless and could lead to erroneous + # behaviour. + if "+mpi" in spec: + mpi = spec["mpi"] + options.append("--enable-parallel=yes") + options.append("MPIF90={0}".format(mpi.mpifc)) + options.append("CC={0}".format(mpi.mpicc)) + else: + options.append("--enable-parallel=no") + options.append("CC={0}".format(env["SPACK_CC"])) + + options.append("F77={0}".format(env["SPACK_F77"])) + options.append("F90={0}".format(env["SPACK_FC"])) + + if "+openmp" in spec: + options.append("--enable-openmp") + + # QE external BLAS, FFT, SCALAPACK detection is a bit tricky. + # More predictable to pass in the correct link line to QE. + # If external detection of BLAS, LAPACK and FFT fails, QE + # is supposed to revert to internal versions of these libraries + # instead -- but more likely it will pickup versions of these + # libraries found in its the system path, e.g. Red Hat or + # Ubuntu's FFTW3 package. + + # FFT + # FFT detection gets derailed if you pass into the CPPFLAGS, instead + # you need to pass it in the FFTW_INCLUDE and FFT_LIBS directory. + # QE supports an internal FFTW2, but only an external FFTW3 interface. + + is_using_intel_libraries = spec["lapack"].name in INTEL_MATH_LIBRARIES + if is_using_intel_libraries: + # A seperate FFT library is not needed when linking against MKL + options.append("FFTW_INCLUDE={0}".format(join_path(env["MKLROOT"], "include/fftw"))) + if "^fftw@3:" in spec: + fftw_prefix = spec["fftw"].prefix + options.append("FFTW_INCLUDE={0}".format(fftw_prefix.include)) + if "+openmp" in spec: + fftw_ld_flags = spec["fftw:openmp"].libs.ld_flags + else: + fftw_ld_flags = spec["fftw"].libs.ld_flags + options.append("FFT_LIBS={0}".format(fftw_ld_flags)) + + if "^amdfftw" in spec: + fftw_prefix = spec["amdfftw"].prefix + options.append("FFTW_INCLUDE={0}".format(fftw_prefix.include)) + if "+openmp" in spec: + fftw_ld_flags = spec["amdfftw:openmp"].libs.ld_flags + else: + fftw_ld_flags = spec["amdfftw"].libs.ld_flags + options.append("FFT_LIBS={0}".format(fftw_ld_flags)) + + # External BLAS and LAPACK requires the correct link line into + # BLAS_LIBS, do no use LAPACK_LIBS as the autoconf scripts indicate + # that this variable is largely ignored/obsolete. + + # For many Spack packages, lapack.libs = blas.libs, hence it will + # appear twice in in link line but this is harmless + lapack_blas = spec["lapack"].libs + spec["blas"].libs + + # qe-6.5 fails to detect MKL for FFT if BLAS_LIBS is set due to + # an unfortunate upsteam change in their autoconf/configure: + # - qe-6.5/install/m4/x_ac_qe_blas.m4 only sets 'have_blas' + # but no 'have_mkl' if BLAS_LIBS is set (which seems to be o.k.) + # - however, qe-6.5/install/m4/x_ac_qe_fft.m4 in 6.5 unfortunately + # relies on x_ac_qe_blas.m4 to detect MKL and set 'have_mkl' + # - qe-5.4 up to 6.4.1 had a different logic and worked fine with + # BLAS_LIBS being set + # However, MKL is correctly picked up by qe-6.5 for BLAS and FFT if + # MKLROOT is set (which SPACK does automatically for ^mkl) + if spec.satisfies("@:6.4"): # set even if MKL is selected + options.append("BLAS_LIBS={0}".format(lapack_blas.ld_flags)) + else: # behavior changed at 6.5 and later + if not is_using_intel_libraries: + options.append("BLAS_LIBS={0}".format(lapack_blas.ld_flags)) + + if "+scalapack" in spec: + if is_using_intel_libraries: + if "^openmpi" in spec: + scalapack_option = "yes" + else: # mpich, intel-mpi + scalapack_option = "intel" + else: + scalapack_option = "yes" + options.append("--with-scalapack={0}".format(scalapack_option)) + scalapack_lib = spec["scalapack"].libs + options.append("SCALAPACK_LIBS={0}".format(scalapack_lib.ld_flags)) + + if "+libxc" in spec: + options.append("--with-libxc=yes") + options.append("--with-libxc-prefix={0}".format(spec["libxc"].prefix)) + + if "+elpa" in spec: + # Spec for elpa + elpa = spec["elpa"] + + # Compute the include directory from there: versions + # of espresso prior to 6.1 requires -I in front of the directory + elpa_include = "" if "@6.1:" in spec else "-I" + elpa_include += join_path(elpa.headers.directories[0], "modules") + + options.extend( + [ + "--with-elpa-include={0}".format(elpa_include), + "--with-elpa-version={0}".format(elpa.version.version[0]), + ] + ) + + elpa_suffix = "_openmp" if "+openmp" in elpa else "" + + # Currently AOCC support only static libraries of ELPA + if "%aocc" in spec: + options.extend( + [ + "--with-elpa-lib={0}".format( + join_path( + elpa.prefix.lib, + "libelpa{elpa_suffix}.a".format(elpa_suffix=elpa_suffix), + ) + ) + ] + ) + else: + options.extend(["--with-elpa-lib={0}".format(elpa.libs[0])]) + + if "+fox" in spec: + options.append("--with-fox=yes") + + if spec.variants["hdf5"].value != "none": + options.append("--with-hdf5={0}".format(spec["hdf5"].prefix)) + if spec.satisfies("@6.4.1,6.5"): + options.extend( + [ + "--with-hdf5-include={0}".format(spec["hdf5"].headers.directories[0]), + "--with-hdf5-libs={0}".format(spec["hdf5:hl,fortran"].libs.ld_flags), + ] + ) + + configure(*options) + + # Filter file must be applied after configure executes + # QE 6.1.0 to QE 6.4 have `-L` missing in front of zlib library + # This issue is backported through an internal patch in 6.4.1, but + # can't be applied to the '+qmcpack' variant + if spec.variants["hdf5"].value != "none": + if spec.satisfies("@6.1.0:6.4.0") or (spec.satisfies("@6.4.1") and "+qmcpack" in spec): + make_inc = join_path(self.pkg.stage.source_path, "make.inc") + zlib_libs = spec["zlib-api"].prefix.lib + " -lz" + filter_file(zlib_libs, format(spec["zlib-api"].libs.ld_flags), make_inc) + + # QE 6.8 and later has parallel builds fixed + if spec.satisfies("@:6.7"): + parallel_build_on = False + else: + parallel_build_on = True + + if "+epw" in spec: + make("all", "epw", parallel=parallel_build_on) + else: + make("all", parallel=parallel_build_on) + + if "+gipaw" in spec: + make("gipaw", parallel=False) + + if "+environ" in spec: + addsonpatch = Executable("./install/addsonpatch.sh") + environpatch = Executable("./Environ/patches/environpatch.sh") + makedeps = Executable("./install/makedeps.sh") + + addsonpatch("Environ", "Environ/src", "Modules", "-patch") + + environpatch("-patch") + + makedeps() + + make("pw", parallel=parallel_build_on) + + if "platform=darwin" in spec: + mkdirp(prefix.bin) + install("bin/*.x", prefix.bin) + else: + make("install")