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
|
# https://github.com/cp2k/cp2k/issues/3688
|
||||||
patch("d4-dispersion-bugfix-2024.3.patch", when="@2024.3")
|
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):
|
def patch(self):
|
||||||
if self.spec["elpa"].satisfies("@2022.05.001:"):
|
# Patch for an undefined constant due to incompatible changes in ELPA
|
||||||
filter_file(
|
if self.spec.satisfies("@9.1:2022.2 +elpa"):
|
||||||
r"ELPA_2STAGE_REAL_INTEL_GPU",
|
if self.spec["elpa"].satisfies("@2022.05.001:"):
|
||||||
"ELPA_2STAGE_REAL_INTEL_GPU_SYCL",
|
filter_file(
|
||||||
"src/fm/cp_fm_elpa.F",
|
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):
|
def url_for_version(self, version):
|
||||||
url = "https://github.com/cp2k/cp2k/releases/download/v{0}/cp2k-{0}.tar.bz2"
|
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"],
|
"cce": ["-O2"],
|
||||||
"xl": ["-O3"],
|
"xl": ["-O3"],
|
||||||
"aocc": ["-O2"],
|
"aocc": ["-O2"],
|
||||||
|
"rocmcc": ["-O1"],
|
||||||
}
|
}
|
||||||
|
|
||||||
dflags = ["-DNDEBUG"] if spec.satisfies("@:2023.2") else []
|
dflags = ["-DNDEBUG"] if spec.satisfies("@:2023.2") else []
|
||||||
@ -451,7 +468,7 @@ def edit(self, pkg, spec, prefix):
|
|||||||
"-ffree-line-length-none",
|
"-ffree-line-length-none",
|
||||||
"-ggdb", # make sure we get proper Fortran backtraces
|
"-ggdb", # make sure we get proper Fortran backtraces
|
||||||
]
|
]
|
||||||
elif spec.satisfies("%aocc"):
|
elif spec.satisfies("%aocc") or spec.satisfies("%rocmcc"):
|
||||||
fcflags += ["-ffree-form", "-Mbackslash"]
|
fcflags += ["-ffree-form", "-Mbackslash"]
|
||||||
elif spec.satisfies("%pgi") or spec.satisfies("%nvhpc"):
|
elif spec.satisfies("%pgi") or spec.satisfies("%nvhpc"):
|
||||||
fcflags += ["-Mfreeform", "-Mextend"]
|
fcflags += ["-Mfreeform", "-Mextend"]
|
||||||
@ -556,16 +573,7 @@ def edit(self, pkg, spec, prefix):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
libs.append(
|
libs.append(elpa.libs.ld_flags)
|
||||||
join_path(
|
|
||||||
elpa.libs.directories[0],
|
|
||||||
(
|
|
||||||
"libelpa{elpa_suffix}.{dso_suffix}".format(
|
|
||||||
elpa_suffix=elpa_suffix, dso_suffix=dso_suffix
|
|
||||||
)
|
|
||||||
),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
if spec.satisfies("@:4"):
|
if spec.satisfies("@:4"):
|
||||||
if elpa.satisfies("@:2014.5"):
|
if elpa.satisfies("@:2014.5"):
|
||||||
@ -598,14 +606,14 @@ def edit(self, pkg, spec, prefix):
|
|||||||
cppflags += ["-D__LIBVORI"]
|
cppflags += ["-D__LIBVORI"]
|
||||||
libvori = spec["libvori"].libs
|
libvori = spec["libvori"].libs
|
||||||
ldflags += [libvori.search_flags]
|
ldflags += [libvori.search_flags]
|
||||||
libs += libvori
|
libs.append(libvori.ld_flags)
|
||||||
libs += ["-lstdc++"]
|
libs += ["-lstdc++"]
|
||||||
|
|
||||||
if spec.satisfies("+spglib"):
|
if spec.satisfies("+spglib"):
|
||||||
cppflags += ["-D__SPGLIB"]
|
cppflags += ["-D__SPGLIB"]
|
||||||
spglib = spec["spglib"].libs
|
spglib = spec["spglib"].libs
|
||||||
ldflags += [spglib.search_flags]
|
ldflags += [spglib.search_flags]
|
||||||
libs += spglib
|
libs.append(spglib.ld_flags)
|
||||||
|
|
||||||
cc = spack_cc if "~mpi" in spec else spec["mpi"].mpicc
|
cc = spack_cc if "~mpi" in spec else spec["mpi"].mpicc
|
||||||
cxx = spack_cxx if "~mpi" in spec else spec["mpi"].mpicxx
|
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"):
|
if spec.satisfies("@2022: +rocm"):
|
||||||
libs += [
|
libs += [
|
||||||
"-L{}".format(spec["rocm"].libs.directories[0]),
|
"-L{}".format(spec["hip"].prefix.lib),
|
||||||
"-L{}/stubs".format(spec["rocm"].libs.directories[0]),
|
"-lamdhip64",
|
||||||
"-lhipblas",
|
"-lhipblas",
|
||||||
"-lhipfft",
|
"-lhipfft",
|
||||||
"-lstdc++",
|
"-lstdc++",
|
||||||
]
|
]
|
||||||
|
|
||||||
cppflags += ["-D__OFFLOAD_HIP"]
|
|
||||||
acc_compiler_var = "hipcc"
|
acc_compiler_var = "hipcc"
|
||||||
acc_flags_var = "NVFLAGS"
|
acc_flags_var = "NVFLAGS"
|
||||||
cppflags += ["-D__ACC"]
|
cppflags += ["-D__ACC"]
|
||||||
cppflags += ["-D__DBCSR_ACC"]
|
cppflags += ["-D__DBCSR_ACC"]
|
||||||
|
cppflags += ["-D__HIP_PLATFORM_AMD__"]
|
||||||
|
cppflags += ["-D__GRID_HIP"]
|
||||||
|
|
||||||
gpuver = GPU_MAP[spec.variants["amdgpu_target"].value[0]]
|
gpuver = GPU_MAP[spec.variants["amdgpu_target"].value[0]]
|
||||||
|
|
||||||
if spec.satisfies("smm=libsmm"):
|
if spec.satisfies("smm=libsmm"):
|
||||||
@ -812,6 +822,9 @@ def fflags(var, lst):
|
|||||||
mkf.write(fflags("CXXFLAGS", cxxflags))
|
mkf.write(fflags("CXXFLAGS", cxxflags))
|
||||||
if spec.satisfies("+cuda"):
|
if spec.satisfies("+cuda"):
|
||||||
mkf.write(fflags(acc_flags_var, nvflags))
|
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("FCFLAGS", fcflags))
|
||||||
mkf.write(fflags("LDFLAGS", ldflags))
|
mkf.write(fflags("LDFLAGS", ldflags))
|
||||||
mkf.write(fflags("LIBS", libs))
|
mkf.write(fflags("LIBS", libs))
|
||||||
@ -918,7 +931,7 @@ def fix_package_config(self):
|
|||||||
content += " " + self.spec["fftw-api"].libs.ld_flags
|
content += " " + self.spec["fftw-api"].libs.ld_flags
|
||||||
|
|
||||||
fftw = self.spec["fftw-api"]
|
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 += " -lfftw3_omp"
|
||||||
|
|
||||||
content += "\n"
|
content += "\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user