Skip to content

ARM64 SME: fix zero-scalar handling and clean up direct kernels#5889

Merged
martin-frbg merged 8 commits into
OpenMathLib:developfrom
moluopro:develop
Jul 6, 2026
Merged

ARM64 SME: fix zero-scalar handling and clean up direct kernels#5889
martin-frbg merged 8 commits into
OpenMathLib:developfrom
moluopro:develop

Conversation

@moluopro

@moluopro moluopro commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

1. Fix zero alpha/beta semantics

The concrete issues are:

  • By BLAS semantics, the input matrix C must not be referenced when beta == 0.
  • When alpha == 0 or K == 0, only the beta*C update is required; A and B should not be read.
  • The current SME direct path bypasses the generic Level-3 handling, so NaNs in C or A/B can pollute the output through 0 * NaN.

2. Use integer round-up for padded SME dimensions

ceil((double)M / (double)vl_elms) * vl_elms

is replaced with integer arithmetic:

(((uint64_t)M + vl_elms - 1) / vl_elms) * vl_elms

3. Clean up const and unused warnings

  • Change the read-only source pointer in the SSYMM preprocess helper to const float *restrict.
  • For SSYMM, compile only the preprocess helper actually used by the current UPPER / LOWER object variant.
  • Change the read-only B parameter in SSYRK kernel_2x2() to const float *.
  • Change the read-only B_T and A_T parameters in SSYR2K kernel_2x2() to const float *.
  • Compile sve_cntw() and ldb only in the TRANSA / !TRANSA variants that actually use them.

moluopro added 8 commits July 6, 2026 15:30
Avoid loading C when beta is zero; ZA has already been initialized to zero.

For alpha == 0 or K == 0, skip A preprocessing and reuse the direct kernel with k = 0 to perform only the beta update.
When alpha is zero, avoid preprocessing the symmetric matrix and reuse the SGEMM alpha/beta direct kernel with k = 0 for the beta-only update.
Avoid loading C when beta is zero, and skip A preprocessing for alpha == 0 or K == 0 by reusing the triangular direct kernel with k = 0.
Avoid loading C when beta is zero, and skip A/B preprocessing for alpha == 0 or K == 0 by reusing the triangular direct kernel with k = 0.
The padded SME dimensions are integer quantities, so compute them with integer arithmetic and drop the now-unused math.h include.
Use const source pointers in the symmetric preprocessing helpers and compile only the LU or LL helper needed by each object variant.
Mark the read-only B input const and limit sve_cntw and ldb definitions to the variants that use them.
Mark read-only transpose inputs const and limit sve_cntw and ldb definitions to the variants that use them.
@martin-frbg martin-frbg added this to the 0.3.34 milestone Jul 6, 2026
@martin-frbg martin-frbg merged commit 6468bcb into OpenMathLib:develop Jul 6, 2026
105 of 106 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants