Repository navigation
Conversation
svcntsw() has no side effects for clang, which if-converted the expression and ran RDSVL before the FEAT_SME2 result was tested. On a CPU without SME that is SIGILL. A noinline function with volatile inline asm keeps RDSVL behind the test. Fixes OpenMathLib#6150
This branch has not been deployed
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.
Fixes #6150.
Before:
s2_usable()computedsme2 && svcntsw() == 16. Clang treatssvcntsw()as free of side effects and if-converts the expression, so RDSVL runs before the FEAT_SME2 result is tested. On a CPU without SME, RDSVL is undefined (SIGILL). This affects a static TARGET=VORTEXM4 build run on such a CPU, on the first call that reaches s2_usable(); DYNAMIC_ARCH builds select VORTEXM4 only with SME. Not tested on M1-M3 hardware.After: the vector length is read by a
noinlinefunction withvolatileinline asm, called only when FEAT_SME2 is present. Disassembly ofsme_sgemm_kernel.o(Apple clang 21):sysctlbyname,cbzon the FEAT_SME2 value, thenbl _s2_svl_lanes; the other RDSVL instructions are aftersmstart sm.@0tomhoyt found this problem and wrote the fix in #6142 (bf16 SBGEMM); this PR takes the same approach, so that the fix can go in on its own, ahead of #6142.
Tested on M4 Pro:
makewith the BLAS/CBLAS tests and utest (144/144, 1564/1564).AI assistance
AI coding tools (Claude Code) helped to prepare this PR. The change was reviewed and tested as described above.