Skip to content

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

Open
ggorman wants to merge 3 commits into
mainfrom
fix-apple-silicon-detection
Open

ggorman wants to merge 3 commits 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"

Which chip a macos-26-arm64 runner gets is a lottery, so the same code is green on one run and red on the next. 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.

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. One branch replaced in get_platform.

Test

tests/test_arch.py::test_detect_apple_silicon, parametrised over "Apple M1", "Apple M2 Pro", "Apple M3 Max", "Apple M4 Max": monkeypatches get_cpu_info and asserts get_platform yields an AppleArm.

  • Negative control: with archinfo.py reverted, the M2/M3/M4 cases fail and only M1 passes; with the change all four pass.

🤖 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.23%. Comparing base (2707ac9) to head (bc74301).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3048      +/-   ##
==========================================
- Coverage   84.23%   84.23%   -0.01%     
==========================================
  Files         258      258              
  Lines       57070    57071       +1     
  Branches     4874     4874              
==========================================
- Hits        48072    48071       -1     
- Misses       8170     8172       +2     
  Partials      828      828              
Flag Coverage Δ
pytest-gpu-aomp-amdgpuX 68.51% <0.00%> (+<0.01%) ⬆️
pytest-gpu-gcc- 78.99% <0.00%> (-0.01%) ⬇️
pytest-gpu-icx- 78.91% <0.00%> (-0.01%) ⬇️
pytest-gpu-nvc-nvidiaX 69.08% <0.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
Gerard Gorman and others added 3 commits October 15, 2026 11:41
`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; which chip a macOS CI runner gets is
a lottery, so the same PR can be green or red on different runs.

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`). Add a test
that fails for M2/M3/M4 brand strings without this change.
@ggorman
ggorman force-pushed the fix-apple-silicon-detection branch from 1657dfb to bc74301 Compare October 15, 2026 11:41

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.

3 participants