Skip to content

arch: Detect all Apple-silicon chips as AppleArm - #3048

Open
ggorman wants to merge 1 commit into
mainfrom
fix-apple-silicon-detection
Open

ggorman wants to merge 1 commit into
mainfrom
fix-apple-silicon-detection

Conversation

@ggorman

@ggorman ggorman commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Problem

get_platform() recognises Apple silicon only via 'm1' in brand (devito/arch/archinfo.py). A brand string such as "Apple M2 Pro" or "Apple M4 Max" falls through to ANYCPU, so @skipif('cpu64-arm') does not fire. tests/test_autotuner.py::test_nested_nthreads then runs with platform='knl7210', the generated code includes xmmintrin.h/pmmintrin.h, and Homebrew clang on arm64 rejects it:

xmmintrin.h:14:2: error: "This header is only meant to be used on x86 and x64 architecture"

Seen on #3047: that run had zero Arm doesn't support x86-specific instructions skips across the suite, while the main run the day before (same image, same LLVM 23.1.0) skipped the test.

macOS CI misses this bears on

The pytest-osx-py312-clang-omp-base job prints the detected platform in its header. On the same macos-26-arm64 image (20261013.0424):

Run Header Outcome
#3074, 2026-10-20 (run 39457547592) platform: m1 green, 50 skipped
#3075 (run 39303223750) platform: cpu64 test_nested_nthreads CompileError
#3074, 2026-10-21 (run 39622887638) platform: cpu64 test_nested_nthreads CompileError and test_gradient.py::TestGradient::test_gradient_equivalence[...float64-1e-13...] (also skipif('cpu64-arm')) fails allclose

Each miss costs a 35-40 minute osx job plus a full rerun of the workflow. The job does not print the brand string, so the cause of these particular misses is unconfirmed: a host chip newer than M1 is fixed here; a brand missing because py-cpuinfo's helper subprocess failed is not, and still falls through to cpu64.

Fix

Map any apple m<N> brand to the registered AppleArm of that generation, falling back to the newest registered one for chips not yet listed; AppleArm.march derives the actual -mcpu at runtime from sysctl. The lookup is a small pure function, get_apple_platform, so it can be tested without stubbing get_cpu_info; tests/test_arch.py::test_apple_platform covers M1 to M5 brand strings, as asked in review.

Check

Besides the test, calling get_platform with get_cpu_info stubbed to "Apple M1 (Virtual)", "Apple M2 Pro", "Apple M3 Max", "Apple M4 Max" and "Apple M5" yields m1, m2, m3, m3, m3, all AppleArm; Xeon, EPYC and Neoverse brands are unchanged. Before the change only the M1 string resolves to AppleArm.

🤖 Generated with Claude Code

@codecov

codecov Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.27%. Comparing base (a9e3f31) to head (2bc1bb6).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3048   +/-   ##
=======================================
  Coverage   84.27%   84.27%           
=======================================
  Files         258      258           
  Lines       57421    57430    +9     
  Branches     4911     4911           
=======================================
+ Hits        48392    48401    +9     
  Misses       8205     8205           
  Partials      824      824           
Flag Coverage Δ
pytest-gpu-aomp-amdgpuX 68.49% <20.00%> (+<0.01%) ⬆️
pytest-gpu-gcc- 78.89% <81.81%> (-0.01%) ⬇️
pytest-gpu-icx- 78.85% <81.81%> (+0.04%) ⬆️
pytest-gpu-nvc-nvidiaX 69.20% <20.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@EdCaunt EdCaunt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not unreasonable, but lots of noise in here.

Comment thread devito/arch/archinfo.py Outdated
Comment thread tests/test_arch.py Outdated
Comment thread tests/test_arch.py Outdated
Comment thread tests/test_arch.py Outdated
Comment thread tests/test_arch.py Outdated
@ggorman
ggorman force-pushed the fix-apple-silicon-detection branch 2 times, most recently from bc74301 to 6ec05f7 Compare October 21, 2026 16:21
@ggorman

ggorman commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main and squashed to the one archinfo.py change. Since your review the same miss hit #3075 and #3074 (runs 39303223750 and 39622887638, header platform: cpu64 on the same image that read m1 the day before); the PR description now has the table. Each hit costs the osx job plus a full rerun.

`get_platform` only recognised Apple silicon through `'m1' in brand`, so
an "Apple M2/M3/M4 ..." brand string fell through to ANYCPU. On such a
machine `skipif('cpu64-arm')` does not fire and tests that force an x86
platform (e.g. `test_nested_nthreads` with `knl7210`) emit x86 intrinsics
headers that clang rejects on arm64. The macOS CI job has detected both
`m1` and `cpu64` on the same runner image; it does not print the brand,
so this hole is one confirmed cause of such misses, not necessarily the
only one.

Map any "apple m<N>" brand to the registered AppleArm of that generation,
falling back to the newest registered one for chips not yet listed (the
actual `march` is derived at runtime by `AppleArm.march`). The lookup is a
pure function so it is tested without stubbing `get_cpu_info`.
@ggorman
ggorman force-pushed the fix-apple-silicon-detection branch from 6ce643e to 2bc1bb6 Compare October 22, 2026 16:27

@FabioLuporini FabioLuporini left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch jitting, archinfo, ...

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants