diff options
author | AMD Toolchain Support <73240730+amd-toolchain-support@users.noreply.github.com> | 2023-09-13 17:48:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-13 09:48:45 -0700 |
commit | 845973273af04023a5c874fd0ae9432db318b686 (patch) | |
tree | c6c65bd9a6711cd76e2df2916ad343665615d180 /var | |
parent | 0696497ffa4137cb2460ef5d7c6c84121dcdafee (diff) | |
download | spack-845973273af04023a5c874fd0ae9432db318b686.tar.gz spack-845973273af04023a5c874fd0ae9432db318b686.tar.bz2 spack-845973273af04023a5c874fd0ae9432db318b686.tar.xz spack-845973273af04023a5c874fd0ae9432db318b686.zip |
CP2K package: various AOCC compatibility fixes (#39773)
* cp2k: patch several old versions to help newer compilers
* cp2k: use -O2 optimization for AOCC compiler
* cp2k: do not support old AOCC compilers
* cp2k: simplify when clause due to conflicting out old compilers
* cp2k: give a more meaningful message for confilcts
Co-authored-by: Ning Li <ning.li@amd.com>
Co-authored-by: Phil Tooley <phil.tooley@amd.com>
Diffstat (limited to 'var')
3 files changed, 75 insertions, 2 deletions
diff --git a/var/spack/repos/builtin/packages/cp2k/backport_avoid_null_2022.x.patch b/var/spack/repos/builtin/packages/cp2k/backport_avoid_null_2022.x.patch new file mode 100644 index 0000000000..ecd3db979c --- /dev/null +++ b/var/spack/repos/builtin/packages/cp2k/backport_avoid_null_2022.x.patch @@ -0,0 +1,21 @@ +diff -Naru a/src/qs_kpp1_env_methods.F b/src/qs_kpp1_env_methods.F +--- a/src/qs_kpp1_env_methods.F 2022-10-03 01:14:25.720416300 +0530 ++++ b/src/qs_kpp1_env_methods.F 2023-06-14 02:33:05.205287205 +0530 +@@ -214,7 +214,6 @@ + output_unit + LOGICAL :: gapw, gapw_xc, lsd, my_calc_forces + REAL(KIND=dp) :: alpha, energy_hartree, energy_hartree_1c +- REAL(KIND=dp), DIMENSION(:, :, :, :), POINTER :: vxg + TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set + TYPE(cp_logger_type), POINTER :: logger + TYPE(cp_para_env_type), POINTER :: para_env +@@ -373,7 +372,8 @@ + + CALL xc_calc_2nd_deriv(v_xc, v_xc_tau, p_env%kpp1_env%deriv_set, p_env%kpp1_env%rho_set, & + rho1_r_pw, rho1_g_pw, tau1_r_pw, auxbas_pw_pool, xc_section, .FALSE., & +- NULL(vxg), lsd_singlets, do_excitations, do_triplet, do_tddft, & ++ lsd_singlets=lsd_singlets, do_excitations=do_excitations, & ++ do_triplet=do_triplet, do_tddft=do_tddft, & + compute_virial=calc_virial, virial_xc=virial) + + DO ispin = 1, nspins diff --git a/var/spack/repos/builtin/packages/cp2k/backport_avoid_null_9.1.patch b/var/spack/repos/builtin/packages/cp2k/backport_avoid_null_9.1.patch new file mode 100644 index 0000000000..7f580a043c --- /dev/null +++ b/var/spack/repos/builtin/packages/cp2k/backport_avoid_null_9.1.patch @@ -0,0 +1,21 @@ +diff -Naru a/src/qs_kpp1_env_methods.F b/src/qs_kpp1_env_methods.F +--- a/src/qs_kpp1_env_methods.F 2021-11-20 14:35:36.103103400 +0530 ++++ b/src/qs_kpp1_env_methods.F 2023-06-14 12:00:52.350584708 +0530 +@@ -220,7 +220,6 @@ + output_unit + LOGICAL :: gapw, gapw_xc, lsd, my_calc_forces + REAL(KIND=dp) :: alpha, energy_hartree, energy_hartree_1c +- REAL(KIND=dp), DIMENSION(:, :, :, :), POINTER :: vxg + TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set + TYPE(cp_logger_type), POINTER :: logger + TYPE(cp_para_env_type), POINTER :: para_env +@@ -361,7 +360,8 @@ + + CALL xc_calc_2nd_deriv(v_xc, p_env%kpp1_env%deriv_set, p_env%kpp1_env%rho_set, & + rho1_r_pw, rho1_g_pw, auxbas_pw_pool, xc_section, .FALSE., & +- NULL(vxg), lsd_singlets, do_excitations, do_triplet, do_tddft, & ++ lsd_singlets=lsd_singlets, do_excitations=do_excitations, & ++ do_triplet=do_triplet, do_tddft=do_tddft, & + compute_virial=calc_virial, virial_xc=virial) + + DO ispin = 1, nspins diff --git a/var/spack/repos/builtin/packages/cp2k/package.py b/var/spack/repos/builtin/packages/cp2k/package.py index d18fa1fe42..a493b906cb 100644 --- a/var/spack/repos/builtin/packages/cp2k/package.py +++ b/var/spack/repos/builtin/packages/cp2k/package.py @@ -282,6 +282,10 @@ class Cp2k(MakefilePackage, CudaPackage, CMakePackage, ROCmPackage): conflicts("%apple-clang") conflicts("%clang") conflicts("%nag") + conflicts( + "%aocc@:3.2", + msg="Please use AOCC 4.0+ that better support modern Fortran features CP2K requires", + ) conflicts("~openmp", when="@8:", msg="Building without OpenMP is not supported in CP2K 8+") @@ -327,7 +331,32 @@ class Cp2k(MakefilePackage, CudaPackage, CMakePackage, ROCmPackage): sha256="3617abb877812c4b933f601438c70f95e21c6161bea177277b1d4125fd1c0bf9", when="@8.2", ) - patch("posix_c_source.patch", when="%aocc") + + # Patch for compilers with stricter C99 checks + patch("posix_c_source.patch", when="@7.1%aocc@4.0:") + patch("posix_c_source.patch", when="@7.1%gcc@13:") + + # Fix missing variable in OpenMP private clause + patch( + "https://github.com/cp2k/cp2k/commit/be86bd7f6cd6af7d68f8957dcdb67e7c3d586741.patch?full_index=1", + sha256="1bb5a8e80603684a743e7821d24d41b31b60ccbb7d4257df1d2da53a3630e5bf", + when="@2022.1:2022.2", + ) + + # Avoid using NULL() as subroutine argument as doing so breaks some versions of AOCC compiler + # These patches backport 2023.x fixes to previous versions + patch("backport_avoid_null_2022.x.patch", when="@2022.1:2022.2 %aocc@:4.0") + patch("backport_avoid_null_9.1.patch", when="@9.1 %aocc@:4.0") + + # Patch for an undefined constant due to incompatible changes in ELPA + @when("@9.1:2022.2 +elpa") + def patch(self): + if self.spec["elpa"].satisfies("@2022.05.001:"): + filter_file( + r"ELPA_2STAGE_REAL_INTEL_GPU", + "ELPA_2STAGE_REAL_INTEL_GPU_SYCL", + "src/fm/cp_fm_elpa.F", + ) def url_for_version(self, version): url = "https://github.com/cp2k/cp2k/releases/download/v{0}/cp2k-{0}.tar.bz2" @@ -372,7 +401,7 @@ class Cp2k(MakefilePackage, CudaPackage, CMakePackage, ROCmPackage): "nvhpc": ["-fast"], "cce": ["-O2"], "xl": ["-O3"], - "aocc": ["-O1"], + "aocc": ["-O2"], } dflags = ["-DNDEBUG"] @@ -421,6 +450,8 @@ class Cp2k(MakefilePackage, CudaPackage, CMakePackage, ROCmPackage): fcflags += [ "-fallow-argument-mismatch" ] # https://github.com/pmodels/mpich/issues/4300 + if spec.satisfies("@7.1%gcc@13:"): + fcflags.append("-fallow-argument-mismatch") if "+openmp" in spec: cflags.append(self.compiler.openmp_flag) |