Repository navigation
Intersect cpu_target specs when freezing features for image builds - #28
Open
ChrisRackauckas-Claude wants to merge 1 commit into
Open
ChrisRackauckas-Claude wants to merge 1 commit into
ChrisRackauckas-Claude wants to merge 1 commit into
Conversation
HostCPUFeatures froze reported CPU features using only the first `;`-separated cpu_target spec, with whole-string `occursin` tier checks. For a target like "skylake-avx512;generic" — or any target whose first spec is more capable than a later clone — has_feature reports features that a clone cannot instruction-select, so downstream packages emitting target-specific LLVM IR (e.g. VectorizationBase's inv_approx, which emits llvm.x86.avx512.rcp14) abort image builds with `LLVM ERROR: Cannot select` (JuliaSIMD/VectorizationBase.jl#131). Parse each `;`-separated spec ("cpu,+feat,-feat,clone_all,base(n)") into a conservative per-CPU set of LLVM feature names, then report only features present on the host AND in every spec: `native` resolves to the host set, `clone_all`/`base(n)` marker specs carry no CPU name and do not constrain features, and unknown CPU names fall back to conservative tiers. The CPU table now also covers x86-64-v3/v4, znver4/5, cooperlake, and recent Intel parts. Separately, load-time target application no longer goes through the `allow_runtime_invalidation` gate: initial build-time feature setup uses set_feature directly, while runtime retargeting in __init__ keeps the runtime=true path. Previously a non-native build could not enable features at all (allow_eval defaults to false), emitting warnings and silently freezing every feature to false. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Agent-Harness: Devin CLI 3000.10.31 Agent-Model: SWE-2 Max Agent-Session: /home/crackauc/.local/share/devin/cli/transcripts/sumptuous-fontina.json (local transcript)
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #28 +/- ##
===========================================
+ Coverage 31.45% 46.54% +15.08%
===========================================
Files 6 6
Lines 213 217 +4
===========================================
+ Hits 67 101 +34
+ Misses 146 116 -30 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
make_genericcurrently derives the frozen feature set from only the first;-separated spec ofcpu_target, using whole-stringoccursintier checks. When a target lists a more capable spec first — e.g.skylake-avx512;generic—has_featurereports features that thegenericclone cannot instruction-select. Downstream packages that emit target-specific LLVM IR gated onhas_feature(e.g. VectorizationBase'sinv_approx, which emitsllvm.x86.avx512.rcp14) then abort image builds withLLVM ERROR: Cannot select: X86ISD::RCP14— the root cause of JuliaSIMD/VectorizationBase.jl#131.This PR:
;-separated spec (cpu,+feat,-feat,clone_all,base(n)) into a conservative per-CPU set of LLVM feature names, and reports only features present on the host and in every spec, so generated IR can be selected for every clone of a multiversioned image and still run in the current session.native(resolves to the host feature set),clone_all/base(n)marker specs (no CPU name → do not constrain features), and±featuremodifiers. Unknown CPU names fall back to conservative tiers rather than whole-string matching.x86-64-v3/v4,znver4/znver5,cooperlake, Sapphire/Emerald/Granite/Diamond Rapids, recent client parts.allow_runtime_invalidation(defaultfalse): initial build-time setup now usesset_featuredirectly, while runtime retargeting in__init__keeps theruntime=truepath throughsetfeaturetrue/setfeaturefalse. Previously a non-nativecpu_targetcould not enable features at all — it printed a "Runtime invalidation was disabled" warning per feature and silently froze everything toFalse().Falsefor non-native targets; aarch64 et al. have no feature table here).Test plan
julia --project=. -e 'using Pkg; Pkg.test()'— 68/68 pass (Julia 1.12, linux x86_64 znver2 host), including new unit tests forspec_features/target_featuresand a subprocess--output-oimage-build regression test.julia --output-o -C "skylake-avx512;generic"that emitsllvm.x86.avx512.rcp14iffhas_feature(Val(:x86_64_avx512f)) === True(). Onmain(bf62321, withallow_runtime_invalidation = true) the child aborts withLLVM ERROR: Do not know how to split the result of this operator!— the intrinsic leaked through and hit a target that cannot select it (on an AVX-512 host the same leak produces the reportedCannot select: X86ISD::RCP14at the generic clone). On this branch the child succeeds and the object file is emitted.using VectorizationBaseunder PackageCompiler-style--output-owith-C "skylake-avx512;generic"builds cleanly on this branch (avx512freportedFalse()), and reproducesLLVM ERROR: Cannot select: X86ISD::RCP14injulia_inv_approx_*onmain.Sys.ARCH === :x86_64-gated; on other arches only the unit tests are skipped.Fixes the remaining gap for JuliaSIMD/VectorizationBase.jl#131 on the HostCPUFeatures side (the first-spec-only case was already handled by 0.1.18; this makes multi-spec targets order-independent).
🤖 Generated with Devin CLI 3000.10.31 (model: SWE-2 Max)
Session transcript (local): /home/crackauc/.local/share/devin/cli/transcripts/sumptuous-fontina.json
Investigation thread: JuliaSIMD/VectorizationBase.jl#131