Repository navigation
perf: LASX kernels on loong64 (sum, dot, sqrt, elementwise, 8x8 GEMM) - #22
Merged
Merged
Conversation
Go's loong64 assembler has LASX float64 add/sub/mul/div, sqrt and 256-bit loads, but no fused multiply-add and no broadcast load; go-asmgen v0.14.0 encodes xvfmadd.d and xvldrepl.d (transitionally, until cmd/asm names them). This uses them for sum, dot, sqrt, add/sub/mul/div and an 8x8 GEMM micro-kernel (sum_loong64.s, generated). LASX is not on every LoongArch CPU: the kernels run only when AT_HWCAP reports it, read from /proc/self/auxv by a pure function (hwcap.go) that is tested on every target; otherwise the scalar code runs, including a scalar 8x8 tile. Loongson 3C5000L (cfarm401; its load average of ~146 is processes stuck in uninterruptible sleep, the CPUs measured 100% idle), against the scalar code, best of 3 interleaved runs: micro-kernel 7.0 -> 27.5 GFLOP/s; serial GEMM 512^2 5.3 -> 20.0 MatMul x1.1-1.9 (32 threads); Sum one core x10.2 at 256 Ki, x2.5 at 4 Mi Sqrt x3.8 below 16 Ki; MatVec x1.6; memory-bound 4 Mi cases at parity Tests: the whole suite passes on the 3C5000L, and again with LASX forced off. A wrong scalar-FMA operand order in the dot tail (Go's FMADDD is Fa, Fk, Fj, Fd) failed the dot tests there before the fix; broadcasting the wrong A rows fails the GEMM tests. CI regenerates sum_loong64.s and fails if it is stale. Docs and comments that said loong64 has no SIMD kernel are updated, and a comment claiming the scalar targets beat NumPy (never measured) is removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 4, 2026
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.
Go's loong64 assembler has LASX float64 add/sub/mul/div, sqrt and 256-bit
loads, but no fused multiply-add and no broadcast load; go-asmgen v0.14.0
encodes xvfmadd.d and xvldrepl.d (transitionally, until cmd/asm names
them). This uses them for sum, dot, sqrt, add/sub/mul/div and an 8x8 GEMM
micro-kernel (sum_loong64.s, generated). LASX is not on every LoongArch
CPU: the kernels run only when AT_HWCAP reports it, read from
/proc/self/auxv by a pure function (hwcap.go) that is tested on every
target; otherwise the scalar code runs, including a scalar 8x8 tile.
Loongson 3C5000L (cfarm401; its load average of ~146 is processes stuck
in uninterruptible sleep, the CPUs measured 100% idle), against the scalar
code, best of 3 interleaved runs:
micro-kernel 7.0 -> 27.5 GFLOP/s; serial GEMM 512^2 5.3 -> 20.0
MatMul x1.1-1.9 (32 threads); Sum one core x10.2 at 256 Ki, x2.5 at 4 Mi
Sqrt x3.8 below 16 Ki; MatVec x1.6; memory-bound 4 Mi cases at parity
Tests: the whole suite passes on the 3C5000L, and again with LASX forced
off. A wrong scalar-FMA operand order in the dot tail (Go's FMADDD is Fa,
Fk, Fj, Fd) failed the dot tests there before the fix; broadcasting the
wrong A rows fails the GEMM tests. CI regenerates sum_loong64.s and fails
if it is stale. Docs and comments that said loong64 has no SIMD kernel are
updated, and a comment claiming the scalar targets beat NumPy (never
measured) is removed.
🤖 Generated with Claude Code