From 018891aa98f52e5bd255ae52236e49a42e060112 Mon Sep 17 00:00:00 2001 From: yuanhecai Date: Fri, 24 Jul 2026 15:12:51 +0800 Subject: [PATCH 1/4] LoongArch64: fix sgemm_ncopy_8_lasx.S segfault for small columns --- kernel/loongarch64/sgemm_ncopy_8_lasx.S | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/loongarch64/sgemm_ncopy_8_lasx.S b/kernel/loongarch64/sgemm_ncopy_8_lasx.S index d8e7350fd4..c71723bb7a 100644 --- a/kernel/loongarch64/sgemm_ncopy_8_lasx.S +++ b/kernel/loongarch64/sgemm_ncopy_8_lasx.S @@ -288,7 +288,10 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .align 5 .L_N1: move S1, TS + andi J, N, 0x01 + beq ZERO, J, .L_N0 beq ZERO, M, .L_N0 + .L_N1_M1: fld.s F0, S1, 0x00 PTR_ADDI S1, S1, 0x04 From 4c78593874c9fc7de98ba83fb43285cbe682b317 Mon Sep 17 00:00:00 2001 From: yuanhecai Date: Fri, 24 Jul 2026 15:13:42 +0800 Subject: [PATCH 2/4] LoongArch64: fix sgemm_ncopy_16_lasx.S segfault for small columns --- kernel/loongarch64/sgemm_ncopy_16_lasx.S | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/loongarch64/sgemm_ncopy_16_lasx.S b/kernel/loongarch64/sgemm_ncopy_16_lasx.S index 0da22897b6..bd2f98cf65 100644 --- a/kernel/loongarch64/sgemm_ncopy_16_lasx.S +++ b/kernel/loongarch64/sgemm_ncopy_16_lasx.S @@ -453,6 +453,8 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .align 5 .L_N1: move S1, TS + andi J, N, 0x01 + beq ZERO, J, .L_N0 beq ZERO, M, .L_N0 .L_N1_M1: fld.s F0, S1, 0x00 From 1b3358b3c5ba335129240f70b6ac1a757b764bfe Mon Sep 17 00:00:00 2001 From: yuanhecai Date: Fri, 24 Jul 2026 15:14:34 +0800 Subject: [PATCH 3/4] LoongArch64: fix dgemm_ncopy_4_lsx.S segfault for small columns --- kernel/loongarch64/dgemm_ncopy_4_lsx.S | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/loongarch64/dgemm_ncopy_4_lsx.S b/kernel/loongarch64/dgemm_ncopy_4_lsx.S index 048a49af61..6e39a470bc 100644 --- a/kernel/loongarch64/dgemm_ncopy_4_lsx.S +++ b/kernel/loongarch64/dgemm_ncopy_4_lsx.S @@ -172,6 +172,8 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. blt ZERO, I, .L_2II1 .L_N1: move S1, TS + andi J, N, 0x01 + beq ZERO, J, .L_N0 beq ZERO, M, .L_N0 .L_M1: fld.d F0, S1, 0x00 From d16316e94264aa64654826fac58a7b5b50b13928 Mon Sep 17 00:00:00 2001 From: yuanhecai Date: Fri, 24 Jul 2026 15:15:09 +0800 Subject: [PATCH 4/4] LoongArch64: adjust dsyrk GEMM_P block size to avoid failure On LoongArch LA464 platform, dsyrk produces incorrect results when processing certain block sizes, which in turn causes dcholesky and dpotrf to fail on positive-definite matrices. The issue manifests with specific block dimension combinations (e.g., 80x16). Adjust GEMM_P from 112 to 96 so that dsyrk's blocking logic avoids generating the problematic size. --- driver/level3/level3_syrk_threaded.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/driver/level3/level3_syrk_threaded.c b/driver/level3/level3_syrk_threaded.c index 88edc7e2a6..b3deaa6ddb 100644 --- a/driver/level3/level3_syrk_threaded.c +++ b/driver/level3/level3_syrk_threaded.c @@ -37,6 +37,11 @@ /* or implied, of The University of Texas at Austin. */ /*********************************************************************/ +#if defined(__loongarch__) && defined(LA464) && defined(DOUBLE) +#undef GEMM_P +#define GEMM_P 96 +#endif + #ifndef CACHE_LINE_SIZE #define CACHE_LINE_SIZE 8 #endif