summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Sachs <stesachs@amazon.com>2023-06-09 15:17:49 +0200
committerGitHub <noreply@github.com>2023-06-09 09:17:49 -0400
commitd91ec8500f7f8265c023b217bce0c0ca34a81a24 (patch)
tree0f1229ec9c9c1043603ea85324275b30ad81e666
parentc354cc51d0a35f09a7d67ace71115e56154a160e (diff)
downloadspack-d91ec8500f7f8265c023b217bce0c0ca34a81a24.tar.gz
spack-d91ec8500f7f8265c023b217bce0c0ca34a81a24.tar.bz2
spack-d91ec8500f7f8265c023b217bce0c0ca34a81a24.tar.xz
spack-d91ec8500f7f8265c023b217bce0c0ca34a81a24.zip
[gromacs] Fix intel (classic) libstdc++ path (#37822)
* [gromacs] Fix intel (classic) libstdc++ path Gromacs's `cmake` run will look for `--gcc-toolchain` (e.g. LLVM, icpx) or `--gcc-name` (e.g. icpc) in `CMAKE_CXX_FLAGS`. Only if it does not find a good g++ candidate there it will look for `GMX_GPLUSPLUS_PATH`: https://github.com/gromacs/gromacs/blob/cb6b311c39fc726a72170c4593b754c8d0a492ac/cmake/FindLibStdCpp.cmake#L97 Spack installed intel compilers already define a g++ for std libs. But in `icp{c,x}.cfg` instead of the compile line. If we use the pre-defined g++ we not only have less chance of mixing g++ versions, but also don't need to explicitly add `gcc` as dependency to `gromacs`. * Fix format * Use a variant As there is no way to check if a file exists at depends_on stage * Fix format * New name and fail if variant is used with other compiler * Line too long.
-rw-r--r--var/spack/repos/builtin/packages/gromacs/package.py30
1 files changed, 27 insertions, 3 deletions
diff --git a/var/spack/repos/builtin/packages/gromacs/package.py b/var/spack/repos/builtin/packages/gromacs/package.py
index d255bdff68..e6989f5bbd 100644
--- a/var/spack/repos/builtin/packages/gromacs/package.py
+++ b/var/spack/repos/builtin/packages/gromacs/package.py
@@ -232,6 +232,13 @@ class Gromacs(CMakePackage, CudaPackage):
for gmx_ver, plumed_vers in plumed_patches.items():
depends_on("plumed@{0}".format(plumed_vers), when="@{0}+plumed".format(gmx_ver))
+ variant(
+ "intel_provided_gcc",
+ default=False,
+ description="Use this if Intel compiler is installed through spack."
+ + "The g++ location is written to icp{c,x}.cfg",
+ )
+
depends_on("fftw-api@3")
depends_on("cmake@2.8.8:3", type="build")
depends_on("cmake@3.4.3:3", type="build", when="@2018:")
@@ -244,7 +251,8 @@ class Gromacs(CMakePackage, CudaPackage):
depends_on("sycl", when="+sycl")
depends_on("lapack", when="+lapack")
depends_on("blas", when="+blas")
- depends_on("gcc", when="%oneapi")
+ depends_on("gcc", when="%oneapi ~intel_provided_gcc")
+ depends_on("gcc", when="%intel ~intel_provided_gcc")
depends_on("hwloc@1.0:1", when="+hwloc@2016:2018")
depends_on("hwloc", when="+hwloc@2019:")
@@ -254,6 +262,14 @@ class Gromacs(CMakePackage, CudaPackage):
depends_on("nvhpc", when="+cufftmp")
+ requires(
+ "%intel",
+ "%oneapi",
+ policy="one_of",
+ when="+intel_provided_gcc",
+ msg="Only attempt to find gcc libs for Intel compiler if Intel compiler is used.",
+ )
+
patch("gmxDetectCpu-cmake-3.14.patch", when="@2018:2019.3^cmake@3.14.0:")
patch("gmxDetectSimd-cmake-3.14.patch", when="@5.0:2017^cmake@3.14.0:")
@@ -431,8 +447,16 @@ class CMakeBuilder(spack.build_systems.cmake.CMakeBuilder):
if self.spec.satisfies("@2020:"):
options.append("-DGMX_INSTALL_LEGACY_API=ON")
- if self.spec.satisfies("%oneapi"):
- options.append("-DGMX_GPLUSPLUS_PATH=%s/g++" % self.spec["gcc"].prefix.bin)
+ if self.spec.satisfies("%oneapi") or self.spec.satisfies("%intel"):
+ # If intel-oneapi-compilers was installed through spack the gcc is added to the
+ # configuration file.
+ if self.spec.satisfies("+intel_provided_gcc") and os.path.exists(
+ ".".join([os.environ["SPACK_CXX"], "cfg"])
+ ):
+ with open(".".join([os.environ["SPACK_CXX"], "cfg"]), "r") as f:
+ options.append("-DCMAKE_CXX_FLAGS={}".format(f.read()))
+ else:
+ options.append("-DGMX_GPLUSPLUS_PATH=%s/g++" % self.spec["gcc"].prefix.bin)
if "+double" in self.spec:
options.append("-DGMX_DOUBLE:BOOL=ON")