From 1fe96f8da788fe58351c482625d55e058db61974 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Sun, 25 Jun 2023 22:36:57 +0200 Subject: [PATCH 1/2] Fix failures to handle increments of zero --- kernel/riscv64/rot_vector.c | 1 + kernel/riscv64/swap_vector.c | 1 + kernel/riscv64/zrot_vector.c | 1 + kernel/riscv64/zswap_vector.c | 1 + 4 files changed, 4 insertions(+) diff --git a/kernel/riscv64/rot_vector.c b/kernel/riscv64/rot_vector.c index 43a65e552..f3786e1d0 100644 --- a/kernel/riscv64/rot_vector.c +++ b/kernel/riscv64/rot_vector.c @@ -155,6 +155,7 @@ int CNAME(BLASLONG n, FLOAT *x, BLASLONG inc_x, FLOAT *y, BLASLONG inc_y, FLOAT } }else{ gvl = VSETVL(n); + if (inc_x == 0 && inc_y == 0) gvl = VSETVL(1); BLASLONG stride_x = inc_x * sizeof(FLOAT); BLASLONG stride_y = inc_y * sizeof(FLOAT); BLASLONG inc_xv = inc_x * gvl; diff --git a/kernel/riscv64/swap_vector.c b/kernel/riscv64/swap_vector.c index b16592808..82fa5ce31 100644 --- a/kernel/riscv64/swap_vector.c +++ b/kernel/riscv64/swap_vector.c @@ -136,6 +136,7 @@ int CNAME(BLASLONG n, BLASLONG dummy0, BLASLONG dummy1, FLOAT dummy3, FLOAT *x, } }else{ gvl = VSETVL(n); + if (inc_x == 0 && inc_y == 0) gvl = VSETVL(1); stride_x = inc_x * sizeof(FLOAT); stride_y = inc_y * sizeof(FLOAT); if(gvl <= n/2){ diff --git a/kernel/riscv64/zrot_vector.c b/kernel/riscv64/zrot_vector.c index 858dfd173..727d13a87 100644 --- a/kernel/riscv64/zrot_vector.c +++ b/kernel/riscv64/zrot_vector.c @@ -112,6 +112,7 @@ int CNAME(BLASLONG n, FLOAT *x, BLASLONG inc_x, FLOAT *y, BLASLONG inc_y, FLOAT } }else{ + if (inc_x == 0 && inc_y == 0) gvl = VSETVL(1); for(i=0,j=0; i < n/gvl; i++){ vx0 = VLSEV_FLOAT(&x[ix], stride_x, gvl); vx1 = VLSEV_FLOAT(&x[ix+1], stride_x, gvl); diff --git a/kernel/riscv64/zswap_vector.c b/kernel/riscv64/zswap_vector.c index c1dcaccab..09cc8992a 100644 --- a/kernel/riscv64/zswap_vector.c +++ b/kernel/riscv64/zswap_vector.c @@ -81,6 +81,7 @@ int CNAME(BLASLONG n, BLASLONG dummy0, BLASLONG dummy1, FLOAT dummy3, FLOAT dumm } }else{ gvl = VSETVL(n); + if (inc_x == 0 && inc_y == 0) gvl = VSETVL(1); stride_x = inc_x * 2 * sizeof(FLOAT); stride_y = inc_y * 2 * sizeof(FLOAT); BLASLONG inc_xv = inc_x * gvl * 2; From b13787971e108d4a267feae478eb253ad7781c9e Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Sun, 25 Jun 2023 22:37:56 +0200 Subject: [PATCH 2/2] Enforce -O1 to work around miscompilation by the vendor gcc --- Makefile.riscv64 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.riscv64 b/Makefile.riscv64 index ce91e03ec..0246c0f7d 100644 --- a/Makefile.riscv64 +++ b/Makefile.riscv64 @@ -1,4 +1,4 @@ ifeq ($(CORE), C910V) -CCOMMON_OPT += -march=rv64imafdcv0p7_zfh_xtheadc -mabi=lp64d -mtune=c920 +CCOMMON_OPT += -march=rv64imafdcv0p7_zfh_xtheadc -mabi=lp64d -mtune=c920 -O1 FCOMMON_OPT += -march=rv64imafdcv0p7_zfh_xtheadc -mabi=lp64d -mtune=c920 -static endif