Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/test-eb-hooks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,44 @@ jobs:
# echo "$OUT" | grep -qiF 'add_property("arch","gpu")'
# echo "$OUT" | grep -qiF 'setenv("EESSIROCMVERSION","6.4.1")'
# echo "rompi toolchain handled"

check_numpy_generic_cpu_baseline:
runs-on: ubuntu-24.04
strategy:
matrix:
include:
- EESSI_VERSION: '2025.06'
EASYCONFIG: 'SciPy-bundle-2025.07-gfbf-2025b.eb'

steps:
- name: Check out software-layer repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Mount EESSI CernVM-FS repository
uses: eessi/github-action-eessi@v3
with:
eessi_stack_version: ${{matrix.EESSI_VERSION}}
use_eessi_module: true

- name: Test that numpy uses cpu-baseline=none for x86_64/generic
if: ${{ github.event_name == 'pull_request' }}
run: |
module load EESSI-extend/${{matrix.EESSI_VERSION}}-easybuild

# the hook prints a message when it adds the option to the numpy installopts
baseline_msg() {
eb --hooks=$PWD/eb_hooks.py --extended-dry-run "$@" ${{matrix.EASYCONFIG}} 2>&1 \
| grep -c 'Using cpu-baseline=none for numpy'
}

[ "$(baseline_msg)" = 0 ]
echo "Native target keeps the default numpy cpu-baseline"

[ "$(EESSI_SOFTWARE_SUBDIR=aarch64/generic baseline_msg)" = 0 ]
echo "aarch64/generic keeps the default numpy cpu-baseline"

[ "$(EESSI_SOFTWARE_SUBDIR=x86_64/generic baseline_msg)" = 1 ]
echo "x86_64/generic uses cpu-baseline=none"

[ "$(baseline_msg --optarch=GENERIC)" = 1 ]
echo "--optarch=GENERIC uses cpu-baseline=none"
14 changes: 14 additions & 0 deletions eb_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2105,8 +2105,22 @@ def pre_single_extension_numpy(ext, *args, **kwargs):
Pre-extension hook for numpy:
- change -march=native to -march=armv8.4-a for numpy 1.24.2 when building for aarch64/neoverse_v1 CPU target
- change -march=native to -march=armv8.2-a for numpy 1.24.2 when building for aarch64/a64fx CPU target
- use cpu-baseline=none for numpy >= 1.26 (built with meson) when building for x86_64/generic;
the default baseline ('min') is SSE3 in numpy 1.26-2.3 and x86-64-v2 in numpy >= 2.4,
while x86_64/generic should only need x86-64 (SSE2); the dispatched code paths for newer
CPU features are unaffected and are still selected at runtime, see
https://numpy.org/doc/stable/reference/simd/build-options.html
"""
cpu_target = get_eessi_envvar('EESSI_SOFTWARE_SUBDIR')
x86_64_generic = cpu_target == CPU_TARGET_X86_64_GENERIC or (
get_cpu_architecture() == X86_64 and build_option('optarch') == OPTARCH_GENERIC)
if ext.name == 'numpy' and x86_64_generic and LooseVersion(ext.version) >= LooseVersion('1.26'):
baseline_opt = "-Csetup-args=-Dcpu-baseline=none"
installopts = ext.cfg.get('installopts', '') or ''
if baseline_opt not in installopts:
ext.cfg['installopts'] = (installopts + ' ' + baseline_opt).strip()
print_msg("Using cpu-baseline=none for %s %s on x86_64/generic: %s",
ext.name, ext.version, ext.cfg['installopts'])
if ext.name == 'numpy' and ext.version == '1.24.2':
# note: this hook is called before build environment is set up (by calling toolchain.prepare()),
# so environment variables like $CFLAGS are not defined yet
Expand Down