Commit Graph

2802 Commits

Author SHA1 Message Date
hmeiland a3620c264a Add U74 target with a 4x4 register-tiled GEMM kernel
The SiFive U74 (RV64GC; e.g. StarFive JH7110 / VisionFive 2) is a scalar,
in-order core with no RVV, so today it falls back to RISCV64_GENERIC whose
S/D GEMM uses the generic 2x2 C micro-kernel.

Per the U74 Core Complex Manual (Table 169) fmadd.d has a 7-cycle latency
at repeat rate 1 (fully pipelined). A 2x2 tile exposes only 4 independent
accumulator chains -- fewer than the FMA latency -- so the FP pipe stalls
on the accumulator dependency, and the 1:1 load:FMA ratio saturates the
single load/store pipe ("only one outstanding line fill", manual 8.2).

This adds a portable 4x4 GEMM micro-kernel and a dedicated U74 target:

- kernel/generic/gemmkernel_4x4.c: 16-accumulator 4x4 register tile. 16
  independent chains exceed the 7-cycle latency, and the load:FMA ratio
  drops to 1:2. 16 acc + 4 A + 4 B fit RV64G's 32 FP registers without
  spilling. Full 4/2/1 edge handling in both M and N.

- U74 target wiring: getarch.c (FORCE_U74, 32 KiB/64 B L1D, 2 MiB L2),
  param.h (S/D UNROLL 4/4; complex stays 2/2), kernel/riscv64/KERNEL.U74
  (S/D GEMM -> gemmkernel_4x4 + gemm_[nt]copy_4; S/D TRMM -> existing
  trmmkernel_4x4), Makefile.prebuild + Makefile.riscv64 (-mtune=sifive-u74),
  TargetList.txt, cpuid_riscv64.c.

The 4x4 kernel was verified numerically against a naive reference GEMM,
driven through the real gemm_tcopy_4 / gemm_ncopy_4 packing routines,
across 27,436 M/N/K x alpha combinations covering every 4/2/1 tail case:
worst absolute error 0.

Build with: make TARGET=U74
2026-07-09 14:00:16 +02:00
moluopro 0e163c9db2 kernel/riscv64: enable RVV TRSM for ZVL256B 2026-07-08 19:42:26 +08:00
moluopro a8b8136114 kernel/riscv64: enable RVV TRSM for ZVL128B 2026-07-08 19:42:17 +08:00
moluopro 0723136260 kernel/riscv64: add RVV RT TRSM kernel 2026-07-08 19:42:09 +08:00
moluopro e4e3ad2430 kernel/riscv64: add RVV RN TRSM kernel 2026-07-08 19:41:58 +08:00
moluopro 945f4352d3 kernel/riscv64: add RVV LT TRSM kernel 2026-07-08 19:41:49 +08:00
moluopro 5282a38239 kernel/riscv64: add RVV LN TRSM kernel 2026-07-08 19:41:42 +08:00
moluopro 09fd1da6fa kernel/riscv64: enable RVV ROTM for ZVL256B
Use the RVV ROTM kernel for single and double precision ROTM on the RISCV64_ZVL256B target.
2026-07-07 15:20:26 +08:00
moluopro a11b444d67 kernel/riscv64: enable RVV ROTM for ZVL128B
Use the RVV ROTM kernel for single and double precision ROTM on the RISCV64_ZVL128B target.
2026-07-07 15:20:26 +08:00
moluopro 395f8b347f fix(riscv64): keep signed strides in RVV ROTM
The general-stride ROTM path already computes kx/ky with the BLAS negative-increment starting offset. Converting negative increments to positive strides and moving dx/dy again double-adjusted the address and could access the wrong elements. Keep the signed byte strides for RVV strided loads and stores.
2026-07-07 15:20:17 +08:00
moluopro f82cf88caa fix(riscv64): handle zero-stride ROTM in RVV kernel
ROTM has loop-carried dependencies when incx or incy is zero because the same element is updated repeatedly across iterations. The RVV strided load/store path would compute lanes from the same old value and write them back in parallel, producing results that do not match BLAS ROTM semantics. Use a scalar path for zero-stride cases.
2026-07-07 15:20:06 +08:00
Martin Kroeker de54968e16
Merge pull request #5890 from martin-frbg/fixup5843
Apply the NEON S/DOMATCOPY kernels from PR 5843 to all arm64 targets
2026-07-07 00:47:11 +02:00
Martin Kroeker a5d477f195
fix omatcopy filenames 2026-07-06 12:28:02 +02:00
Martin Kroeker 36365a602e
Make the OMATCOPY kernels from 5843 universally available 2026-07-06 11:49:27 +02:00
moluopro 130102e661 Clean up SSYR2K SME direct warnings
Mark read-only transpose inputs const and limit sve_cntw and ldb definitions to the variants that use them.
2026-07-06 16:00:21 +08:00
moluopro 3781e2c15d Clean up SSYRK SME direct warnings
Mark the read-only B input const and limit sve_cntw and ldb definitions to the variants that use them.
2026-07-06 15:59:53 +08:00
moluopro edd8ab196d Clean up SSYMM SME preprocessing warnings
Use const source pointers in the symmetric preprocessing helpers and compile only the LU or LL helper needed by each object variant.
2026-07-06 15:59:25 +08:00
moluopro 8cde36c9b8 Use integer round-up in ARM64 SME direct kernels
The padded SME dimensions are integer quantities, so compute them with integer arithmetic and drop the now-unused math.h include.
2026-07-06 15:33:29 +08:00
moluopro d49cd021dd Handle zero alpha/beta in SSYR2K SME direct kernel
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.
2026-07-06 15:30:42 +08:00
moluopro 9925b29db5 Handle zero alpha/beta in SSYRK SME direct kernel
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.
2026-07-06 15:30:37 +08:00
moluopro 35a841fd49 Handle zero alpha in SSYMM SME direct kernel
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.
2026-07-06 15:30:27 +08:00
moluopro ab27636deb Handle zero alpha/beta in SGEMM SME direct kernel
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.
2026-07-06 15:30:22 +08:00
Martin Kroeker e70a7a735f
Merge pull request #5868 from Vasudeva-bit/macTuneZEN4
Optimize Zen 4 GEMM macro block sizes (P, Q, R)
2026-07-05 00:01:20 +02:00
Vasudeva-bit 58846317d9 fix C89 scoping, dynamic R for memory issues, robust zen4/5 check 2026-07-04 11:30:34 +05:30
Julien Schueller 43f0a90e1b Fix ZA tile slice indices in ssyrk SME direct kernel
The kernel_2x2 function uses 4 ZA tiles (0-3) each with svl slices.
Tiles 0/1 handle rows 0..svl-1 with slice indices 0..svl-1.
Tiles 2/3 handle rows svl..2*svl-1, so their slice indices
must start at 0, i.e. (i - svl) instead of i.

Fix all three tile 2/3 access sites:
- C load into ZA (svwrite_hor_za32_f32_m)
- C writeback for UPPER (svst1_hor_za32)
- C writeback for LOWER (svst1_hor_za32)

Fixes #5873
2026-07-02 09:29:32 +02:00
Vasudeva-bit 753604cfe2 Optimize Zen 4 GEMM macro block sizes (P, Q, R) 2026-06-25 19:06:26 +05:30
zhir 46aa158dcc AArch64: NEON omatcopy CT/RT kernels 2026-06-20 22:54:04 +03:00
Martin Kroeker ef20ea1644
Merge pull request #5828 from amritahs-ibm/fix_dcbt_constraints
Fix incorrect inline assembly constraints in dcbt prefetch instructions
2026-06-15 11:22:10 +02:00
Ayappan Perumal faf7ddbbea Fix AIX build with OpenXL (ibm-clang) 2026-06-10 04:22:48 -05:00
Martin Kroeker 94f85eb6b1
Merge pull request #5822 from ErnstPeng/la-dev
optimize zgemm, ic/zamin and sdot lsx kernel for 2k3000 cpu
2026-06-09 18:15:48 +02:00
amritahs-ibm 7e3877f263
Merge branch 'develop' into fix_dcbt_constraints 2026-06-09 14:45:02 +05:30
Martin Kroeker 901c214a9b
Merge pull request #5827 from amritahs-ibm/use_lxvp_builtins
Power10: Replace vector pair loads with __builtin_vsx_lxvp
2026-06-09 09:41:47 +02:00
pengxu 4850f86e3d optimize sdot lsx kernel 2026-06-08 14:26:03 +08:00
pengxu d1df5928ae optimize ic/zamin lsx kernel 2026-06-08 14:25:26 +08:00
Martin Kroeker 16a5ea5b4c
Merge pull request #5829 from martin-frbg/issue5825
Fix OpenMP reentrancy issues in LLVM compilations with gmake on ARM64
2026-06-06 10:55:52 +02:00
Martin Kroeker 1145c75a96
Comment out the libclang_rt.builtins kludge in preparation for removal 2026-06-05 23:06:28 +02:00
Amrita H S 831b822b94 Fix incorrect inline assembly constraints in dcbt prefetch instructions
Corrected the register constraints for the PowerPC dcbt (Data Cache Block
Touch) instruction in Power10 kernel implementations. The dcbt instruction
has special behavior where if the first operand (RA) is r0, it uses the
value 0 instead of the register contents. Therefore, RA must use the "b"
constraint (any GPR except r0), while RB can use "r" (any GPR including r0).

Changes:
- Changed first operand constraint from "r" to "b" to exclude r0
- Changed second operand constraint from "b" to "r" for flexibility

This ensures correct prefetch behavior and compliance with PowerPC ISA
specifications, preventing potential issues where r0 might be incorrectly
used as the base address register.

Signed-off-by: Amrita H S <amritahs@linux.vnet.ibm.com>
2026-06-04 01:49:08 -05:00
Amrita H S 3863a7778d Power10: Replace vector pair loads with __builtin_vsx_lxvp
Replace normal vector pair pointer dereferences with the optimized
__builtin_vsx_lxvp builtin across DGEMM, ZGEMM, and DGEMV kernels.

Also done some identation corrections in dgemm_kernel_power10.c.
This is done as part of POWER code cleanup and may not have any
performance impact.

Signed-off-by: Amrita H S <amritahs@linux.vnet.ibm.com>
2026-06-03 02:34:53 -05:00
Chip Kerchner 6a23c36313 Unroll inner loop - 2 rows at a time. Up to 1.5X faster. 2026-06-02 16:39:16 +00:00
pengxu 6731dac68b optimize zgemm lsx kernel for 2k3000 cpu 2026-05-29 10:05:39 +08:00
Martin Kroeker 70a5a53747
Fix contiguous memory check for SGEMM and DGEMM. (#5815) 2026-05-19 22:58:22 +02:00
Martin Kroeker fda55ad259
Fix gmake build of ARM64 DYNAMIC_ARCH on hosts lacking SVE (#5816)
* Add march=armv8.4-a+sve(+bf16) to non-PGI options for SVE-capable ARM64 targets
2026-05-19 22:46:13 +02:00
Chip Kerchner f3f718b228 Fix contiguous memory check for SGEMM and DGEMM. 2026-05-18 18:56:29 +00:00
Gražvydas Ignotas fc9d7c7fe3 rename arm32 sgemm_kernel to indicate neon support 2026-05-05 23:09:52 +03:00
Gražvydas Ignotas 9d58b8d64e provide a NEON version of arm/sgemm
benchmark/sgemm.goto before:
 M= 200, N= 200, K= 200 :     9262.97 MFlops   0.001727 sec
after:
 M= 200, N= 200, K= 200 :    30223.64 MFlops   0.000529 sec

Conveniently the registers are already allocated suitably for vector
operation, so the conversion from vfpv3 was rather straightforward.

Prefetching was left out because it doesn't help Cortex-A76,
only hurts it slightly.
2026-05-05 23:09:01 +03:00
Gražvydas Ignotas cd276c2c09 only save the required registers for arm/sgemm
According to ARM AAPCS (Procedure Call Standard) 5.1.2.1, only registers
s16-s31 must be preserved across subroutine calls; registers s0-s15
do not need to be preserved.
2026-05-05 22:36:08 +03:00
Gražvydas Ignotas d7aeae8933 convert labels to local labels for arm/sgemm
Non-local labels interfere with profiling. Same thing was done for arm64 in
commit a0128aa489.
2026-05-05 22:36:08 +03:00
Martin Kroeker 33c14c66c7
spell out ifdefined 2026-04-30 17:31:01 +02:00
Martin Kroeker 703710763d
Correct stack offset of FLAG on FreeBSD 2026-04-30 17:29:31 +02:00
Martin Kroeker 54efe8ae71
Correct stack offset of FLAG on FreeBSD 2026-04-30 17:28:10 +02:00