From f0ae9fd151015292287f63b4937eebda1d68a51f Mon Sep 17 00:00:00 2001 From: David Huber <69919478+DavidHuber-NOAA@users.noreply.github.com> Date: Fri, 3 Jan 2025 18:27:59 +0000 Subject: [PATCH] Disable py-numpy AVX512 instructions when compiled with Intel (#47941) * Disable numpy AVX512 when compiled with Intel classic * Add py-numpy v1.26.5 * Add patch to handle AVX512 conversions * Remove unneeded patch. * Remove unnecessary tag * Move blas_config_settings to config_settings * Cleaned up blas settings --- .../builtin/packages/py-numpy/package.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/var/spack/repos/builtin/packages/py-numpy/package.py b/var/spack/repos/builtin/packages/py-numpy/package.py index 0497a133c3cade..41217573d248f1 100644 --- a/var/spack/repos/builtin/packages/py-numpy/package.py +++ b/var/spack/repos/builtin/packages/py-numpy/package.py @@ -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": { @@ -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