Skip to content

Commit 57b17ed

Browse files
committed
gromacs et al: fix ^mkl pattern
fixes #40983 fixes #40985 The ^mkl pattern was used to refer to three packages even though none of software using it was depending on "mkl". This pattern, which follows Hyrum's law, is now being removed in favor of a more explicit one. In this PR gromacs, abinit, lammps, and quantum-espresso are modified. Intel packages are also modified to provide "lapack" and "blas" together.
1 parent 2e45edf commit 57b17ed

File tree

10 files changed

+36
-18
lines changed

10 files changed

+36
-18
lines changed

lib/spack/spack/build_systems/oneapi.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@
99
import shutil
1010
from os.path import basename, dirname, isdir
1111

12-
from llnl.util.filesystem import find_headers, find_libraries, join_path
12+
from llnl.util.filesystem import find_headers, find_libraries, join_path, mkdirp
1313
from llnl.util.link_tree import LinkTree
1414

1515
from spack.directives import conflicts, variant
16-
from spack.package import mkdirp
1716
from spack.util.environment import EnvironmentModifications
1817
from spack.util.executable import Executable
1918

@@ -212,3 +211,7 @@ def link_flags(self):
212211
@property
213212
def ld_flags(self):
214213
return "{0} {1}".format(self.search_flags, self.link_flags)
214+
215+
216+
#: Tuple of Intel math libraries, exported to packages
217+
INTEL_MATH_LIBRARIES = ("intel-mkl", "intel-oneapi-mkl", "intel-parallel-studio")

lib/spack/spack/package.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
from spack.build_systems.nmake import NMakePackage
5151
from spack.build_systems.octave import OctavePackage
5252
from spack.build_systems.oneapi import (
53+
INTEL_MATH_LIBRARIES,
5354
IntelOneApiLibraryPackage,
5455
IntelOneApiPackage,
5556
IntelOneApiStaticLibraryList,

var/spack/repos/builtin/packages/abinit/package.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ class Abinit(AutotoolsPackage):
8787
# libxml2
8888
depends_on("libxml2", when="@9:+libxml2")
8989

90+
# If the Intel suite is used for Lapack, it must be used for fftw and vice-versa
91+
for _intel_pkg in INTEL_MATH_LIBRARIES:
92+
requires(f"^[virtuals=fftw-api] {_intel_pkg}", when=f"^[virtuals=lapack] {_intel_pkg}")
93+
requires(f"^[virtuals=lapack] {_intel_pkg}", when=f"^[virtuals=fftw-api] {_intel_pkg}")
94+
9095
# Cannot ask for +scalapack if it does not depend on MPI
9196
conflicts("+scalapack", when="~mpi")
9297

@@ -199,7 +204,8 @@ def configure_args(self):
199204

200205
# BLAS/LAPACK/SCALAPACK-ELPA
201206
linalg = spec["lapack"].libs + spec["blas"].libs
202-
if "^mkl" in spec:
207+
is_using_intel_libraries = spec["lapack"].name in INTEL_MATH_LIBRARIES
208+
if is_using_intel_libraries:
203209
linalg_flavor = "mkl"
204210
elif "@9:" in spec and "^openblas" in spec:
205211
linalg_flavor = "openblas"
@@ -220,7 +226,7 @@ def configure_args(self):
220226

221227
oapp(f"--with-linalg-flavor={linalg_flavor}")
222228

223-
if "^mkl" in spec:
229+
if is_using_intel_libraries:
224230
fftflavor = "dfti"
225231
else:
226232
if "+openmp" in spec:
@@ -231,7 +237,7 @@ def configure_args(self):
231237
oapp(f"--with-fft-flavor={fftflavor}")
232238

233239
if "@:8" in spec:
234-
if "^mkl" in spec:
240+
if is_using_intel_libraries:
235241
oapp(f"--with-fft-incs={spec['fftw-api'].headers.cpp_flags}")
236242
oapp(f"--with-fft-libs={spec['fftw-api'].libs.ld_flags}")
237243
else:
@@ -242,7 +248,7 @@ def configure_args(self):
242248
]
243249
)
244250
else:
245-
if "^mkl" in spec:
251+
if is_using_intel_libraries:
246252
options.extend(
247253
[
248254
f"FFT_CPPFLAGS={spec['fftw-api'].headers.cpp_flags}",

var/spack/repos/builtin/packages/gromacs/package.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,11 @@ class Gromacs(CMakePackage, CudaPackage):
263263
msg="Only attempt to find gcc libs for Intel compiler if Intel compiler is used.",
264264
)
265265

266+
# If the Intel suite is used for Lapack, it must be used for fftw and vice-versa
267+
for _intel_pkg in INTEL_MATH_LIBRARIES:
268+
requires(f"^[virtuals=fftw-api] {_intel_pkg}", when=f"^[virtuals=lapack] {_intel_pkg}")
269+
requires(f"^[virtuals=lapack] {_intel_pkg}", when=f"^[virtuals=fftw-api] {_intel_pkg}")
270+
266271
patch("gmxDetectCpu-cmake-3.14.patch", when="@2018:2019.3^[email protected]:")
267272
patch("gmxDetectSimd-cmake-3.14.patch", when="@5.0:2017^[email protected]:")
268273
# 2021.2 will always try to build tests (see https://gromacs.bioexcel.eu/t/compilation-failure-for-gromacs-2021-1-and-2021-2-with-cmake-3-20-2/2129)
@@ -594,7 +599,7 @@ def cmake_args(self):
594599
"-DGMX_OPENMP_MAX_THREADS=%s" % self.spec.variants["openmp_max_threads"].value
595600
)
596601

597-
if "^mkl" in self.spec:
602+
if self.spec["lapack"].name in INTEL_MATH_LIBRARIES:
598603
# fftw-api@3 is provided by intel-mkl or intel-parllel-studio
599604
# we use the mkl interface of gromacs
600605
options.append("-DGMX_FFT_LIBRARY=mkl")

var/spack/repos/builtin/packages/intel-mkl/package.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,7 @@ class IntelMkl(IntelPackage):
153153
multi=False,
154154
)
155155

156-
provides("blas")
157-
provides("lapack")
156+
provides("blas", "lapack")
158157
provides("[email protected]", when="@2020.4")
159158
provides("[email protected]", when="@11.3")
160159
provides("scalapack")

var/spack/repos/builtin/packages/intel-oneapi-mkl/package.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,7 @@ class IntelOneapiMkl(IntelOneApiLibraryPackage):
126126
provides("fftw-api@3")
127127
provides("scalapack", when="+cluster")
128128
provides("mkl")
129-
provides("lapack")
130-
provides("blas")
129+
provides("lapack", "blas")
131130

132131
@property
133132
def component_dir(self):

var/spack/repos/builtin/packages/intel-parallel-studio/package.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,8 +536,7 @@ class IntelParallelStudio(IntelPackage):
536536
provides("ipp", when="+ipp")
537537

538538
provides("mkl", when="+mkl")
539-
provides("blas", when="+mkl")
540-
provides("lapack", when="+mkl")
539+
provides("blas", "lapack", when="+mkl")
541540
provides("scalapack", when="+mkl")
542541

543542
provides("fftw-api@3", when="[email protected]:")

var/spack/repos/builtin/packages/lammps/package.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ def cmake_args(self):
791791
# FFTW libraries are available and enable them by default.
792792
if "^fftw" in spec or "^cray-fftw" in spec or "^amdfftw" in spec:
793793
args.append(self.define("FFT", "FFTW3"))
794-
elif "^mkl" in spec:
794+
elif spec["fftw-api"].name in INTEL_MATH_LIBRARIES:
795795
args.append(self.define("FFT", "MKL"))
796796
elif "^armpl-gcc" in spec or "^acfl" in spec:
797797
args.append(self.define("FFT", "FFTW3"))

var/spack/repos/builtin/packages/quantum-espresso/package.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,11 @@ class QuantumEspresso(CMakePackage, Package):
242242
depends_on("[email protected]:", type="build")
243243
depends_on("m4", type="build")
244244

245+
# If the Intel suite is used for Lapack, it must be used for fftw and vice-versa
246+
for _intel_pkg in INTEL_MATH_LIBRARIES:
247+
requires(f"^[virtuals=fftw-api] {_intel_pkg}", when=f"^[virtuals=lapack] {_intel_pkg}")
248+
requires(f"^[virtuals=lapack] {_intel_pkg}", when=f"^[virtuals=fftw-api] {_intel_pkg}")
249+
245250
# CONFLICTS SECTION
246251
# Omitted for now due to concretizer bug
247252
# MKL with 64-bit integers not supported.
@@ -489,7 +494,8 @@ def install(self, pkg, spec, prefix):
489494
# you need to pass it in the FFTW_INCLUDE and FFT_LIBS directory.
490495
# QE supports an internal FFTW2, but only an external FFTW3 interface.
491496

492-
if "^mkl" in spec:
497+
is_using_intel_libraries = spec["lapack"].name in INTEL_MATH_LIBRARIES
498+
if is_using_intel_libraries:
493499
# A seperate FFT library is not needed when linking against MKL
494500
options.append("FFTW_INCLUDE={0}".format(join_path(env["MKLROOT"], "include/fftw")))
495501
if "^fftw@3:" in spec:
@@ -531,11 +537,11 @@ def install(self, pkg, spec, prefix):
531537
if spec.satisfies("@:6.4"): # set even if MKL is selected
532538
options.append("BLAS_LIBS={0}".format(lapack_blas.ld_flags))
533539
else: # behavior changed at 6.5 and later
534-
if not spec.satisfies("^mkl"):
540+
if not is_using_intel_libraries:
535541
options.append("BLAS_LIBS={0}".format(lapack_blas.ld_flags))
536542

537543
if "+scalapack" in spec:
538-
if "^mkl" in spec:
544+
if is_using_intel_libraries:
539545
if "^openmpi" in spec:
540546
scalapack_option = "yes"
541547
else: # mpich, intel-mpi

var/spack/repos/builtin/packages/r/package.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def configure_args(self):
137137
]
138138

139139
if "+external-lapack" in spec:
140-
if "^mkl" in spec and "gfortran" in self.compiler.fc:
140+
if spec["lapack"].name in INTEL_MATH_LIBRARIES and "gfortran" in self.compiler.fc:
141141
mkl_re = re.compile(r"(mkl_)intel(_i?lp64\b)")
142142
config_args.extend(
143143
[

0 commit comments

Comments
 (0)