Skip to content

Commit

Permalink
Merge pull request #498 from DavidHuber-NOAA/fix/numpy
Browse files Browse the repository at this point in the history
Disable py-numpy AVX512 instructions when compiled with Intel
  • Loading branch information
climbfuji authored Jan 14, 2025
2 parents ffeffba + 7c8de55 commit afa5072
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion var/spack/repos/builtin/packages/py-numpy/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,8 @@ def blas_lapack_pkg_config(self) -> Tuple[str, str]:
@when("@1.26:")
def config_settings(self, spec, prefix):
blas, lapack = self.blas_lapack_pkg_config()
return {

settings = {
"builddir": "build",
"compile-args": f"-j{make_jobs}",
"setup-args": {
Expand All @@ -298,6 +299,22 @@ def config_settings(self, spec, prefix):
},
}

# Disable AVX512 features for Intel Classic compilers
# https://numpy.org/doc/stable/reference/simd/build-options.html
# https://github.com/numpy/numpy/issues/27840
# https://github.com/matplotlib/matplotlib/issues/28762
archs = ("x86_64_v4:", "cannonlake:", "mic_knl")
if any([self.spec.satisfies(f"target={arch} %intel") for arch in archs]):
intel_setup_args = {
"-Dcpu-dispatch": (
"MAX -AVX512F -AVX512CD -AVX512_KNL -AVX512_KNM -AVX512_SKX "
+ "-AVX512_CLX -AVX512_CNL -AVX512_ICL -AVX512_SPR"
)
}
settings["setup-args"].update(intel_setup_args)

return settings

def blas_lapack_site_cfg(self) -> None:
"""Write a site.cfg file to configure BLAS/LAPACK."""
spec = self.spec
Expand Down

0 comments on commit afa5072

Please sign in to comment.