CP2K: fix .mod file incompatibility on ROCm by using USE, INTRINSIC d… (#45848)
Co-authored-by: U-PALLAS\boudaoud <boudaoud@pc44.pallas.cines.fr>
This commit is contained in:
parent
62abcfb05f
commit
13feee8364
@ -374,15 +374,31 @@ class Cp2k(MakefilePackage, CMakePackage, CudaPackage, ROCmPackage):
|
||||
# https://github.com/cp2k/cp2k/issues/3688
|
||||
patch("d4-dispersion-bugfix-2024.3.patch", when="@2024.3")
|
||||
|
||||
# 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",
|
||||
)
|
||||
# Patch for an undefined constant due to incompatible changes in ELPA
|
||||
if self.spec.satisfies("@9.1:2022.2 +elpa"):
|
||||
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",
|
||||
)
|
||||
|
||||
# Patch for resolving .mod file conflicts in ROCm by implementing 'USE, INTRINSIC'
|
||||
if self.spec.satisfies("+rocm"):
|
||||
for directory, subdirectory, files in os.walk(os.getcwd()):
|
||||
for i in files:
|
||||
file_path = os.path.join(directory, i)
|
||||
filter_file("USE ISO_C_BINDING", "USE,INTRINSIC :: ISO_C_BINDING", file_path)
|
||||
filter_file(
|
||||
"USE ISO_FORTRAN_ENV", "USE,INTRINSIC :: ISO_FORTRAN_ENV", file_path
|
||||
)
|
||||
filter_file("USE omp_lib", "USE,INTRINSIC :: omp_lib", file_path)
|
||||
filter_file("USE OMP_LIB", "USE,INTRINSIC :: OMP_LIB", file_path)
|
||||
filter_file("USE iso_c_binding", "USE,INTRINSIC :: iso_c_binding", file_path)
|
||||
filter_file(
|
||||
"USE iso_fortran_env", "USE,INTRINSIC :: iso_fortran_env", file_path
|
||||
)
|
||||
|
||||
def url_for_version(self, version):
|
||||
url = "https://github.com/cp2k/cp2k/releases/download/v{0}/cp2k-{0}.tar.bz2"
|
||||
@ -410,6 +426,7 @@ def edit(self, pkg, spec, prefix):
|
||||
"cce": ["-O2"],
|
||||
"xl": ["-O3"],
|
||||
"aocc": ["-O2"],
|
||||
"rocmcc": ["-O1"],
|
||||
}
|
||||
|
||||
dflags = ["-DNDEBUG"] if spec.satisfies("@:2023.2") else []
|
||||
@ -451,7 +468,7 @@ def edit(self, pkg, spec, prefix):
|
||||
"-ffree-line-length-none",
|
||||
"-ggdb", # make sure we get proper Fortran backtraces
|
||||
]
|
||||
elif spec.satisfies("%aocc"):
|
||||
elif spec.satisfies("%aocc") or spec.satisfies("%rocmcc"):
|
||||
fcflags += ["-ffree-form", "-Mbackslash"]
|
||||
elif spec.satisfies("%pgi") or spec.satisfies("%nvhpc"):
|
||||
fcflags += ["-Mfreeform", "-Mextend"]
|
||||
@ -556,16 +573,7 @@ def edit(self, pkg, spec, prefix):
|
||||
)
|
||||
)
|
||||
else:
|
||||
libs.append(
|
||||
join_path(
|
||||
elpa.libs.directories[0],
|
||||
(
|
||||
"libelpa{elpa_suffix}.{dso_suffix}".format(
|
||||
elpa_suffix=elpa_suffix, dso_suffix=dso_suffix
|
||||
)
|
||||
),
|
||||
)
|
||||
)
|
||||
libs.append(elpa.libs.ld_flags)
|
||||
|
||||
if spec.satisfies("@:4"):
|
||||
if elpa.satisfies("@:2014.5"):
|
||||
@ -598,14 +606,14 @@ def edit(self, pkg, spec, prefix):
|
||||
cppflags += ["-D__LIBVORI"]
|
||||
libvori = spec["libvori"].libs
|
||||
ldflags += [libvori.search_flags]
|
||||
libs += libvori
|
||||
libs.append(libvori.ld_flags)
|
||||
libs += ["-lstdc++"]
|
||||
|
||||
if spec.satisfies("+spglib"):
|
||||
cppflags += ["-D__SPGLIB"]
|
||||
spglib = spec["spglib"].libs
|
||||
ldflags += [spglib.search_flags]
|
||||
libs += spglib
|
||||
libs.append(spglib.ld_flags)
|
||||
|
||||
cc = spack_cc if "~mpi" in spec else spec["mpi"].mpicc
|
||||
cxx = spack_cxx if "~mpi" in spec else spec["mpi"].mpicxx
|
||||
@ -723,18 +731,20 @@ def edit(self, pkg, spec, prefix):
|
||||
|
||||
if spec.satisfies("@2022: +rocm"):
|
||||
libs += [
|
||||
"-L{}".format(spec["rocm"].libs.directories[0]),
|
||||
"-L{}/stubs".format(spec["rocm"].libs.directories[0]),
|
||||
"-L{}".format(spec["hip"].prefix.lib),
|
||||
"-lamdhip64",
|
||||
"-lhipblas",
|
||||
"-lhipfft",
|
||||
"-lstdc++",
|
||||
]
|
||||
|
||||
cppflags += ["-D__OFFLOAD_HIP"]
|
||||
acc_compiler_var = "hipcc"
|
||||
acc_flags_var = "NVFLAGS"
|
||||
cppflags += ["-D__ACC"]
|
||||
cppflags += ["-D__DBCSR_ACC"]
|
||||
cppflags += ["-D__HIP_PLATFORM_AMD__"]
|
||||
cppflags += ["-D__GRID_HIP"]
|
||||
|
||||
gpuver = GPU_MAP[spec.variants["amdgpu_target"].value[0]]
|
||||
|
||||
if spec.satisfies("smm=libsmm"):
|
||||
@ -812,6 +822,9 @@ def fflags(var, lst):
|
||||
mkf.write(fflags("CXXFLAGS", cxxflags))
|
||||
if spec.satisfies("+cuda"):
|
||||
mkf.write(fflags(acc_flags_var, nvflags))
|
||||
if "+rocm" in spec:
|
||||
mkf.write("OFFLOAD_TARGET = hip\n")
|
||||
|
||||
mkf.write(fflags("FCFLAGS", fcflags))
|
||||
mkf.write(fflags("LDFLAGS", ldflags))
|
||||
mkf.write(fflags("LIBS", libs))
|
||||
@ -918,7 +931,7 @@ def fix_package_config(self):
|
||||
content += " " + self.spec["fftw-api"].libs.ld_flags
|
||||
|
||||
fftw = self.spec["fftw-api"]
|
||||
if fftw.name in ["fftw", "amdfftw"] and fftw.satisfies("+openmp"):
|
||||
if fftw.name in ["fftw", "amdfftw", "cray-fftw"] and fftw.satisfies("+openmp"):
|
||||
content += " -lfftw3_omp"
|
||||
|
||||
content += "\n"
|
||||
|
Loading…
Reference in New Issue
Block a user