Skip to content

Commit f67a062

Browse files
authored
Merge pull request #3480 from wzgpeter/develop
fix bug in zscal function
2 parents 449fb7d + 92b7b94 commit f67a062

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

kernel/riscv64/zscal_vector.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3535
#define VFMACCVF_FLOAT vfmacc_vf_f32m4
3636
#define VFMULVF_FLOAT vfmul_vf_f32m4
3737
#define VFNMSACVF_FLOAT vfnmsac_vf_f32m4
38+
#define VFMVVF_FLOAT vfmv_v_f_f32m4
3839
#else
3940
#define VSETVL(n) vsetvl_e64m4(n)
4041
#define VSETVL_MAX vsetvlmax_e64m1()
@@ -44,6 +45,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4445
#define VFMACCVF_FLOAT vfmacc_vf_f64m4
4546
#define VFMULVF_FLOAT vfmul_vf_f64m4
4647
#define VFNMSACVF_FLOAT vfnmsac_vf_f64m4
48+
#define VFMVVF_FLOAT vfmv_v_f_f64m4
4749
#endif
4850

4951
int CNAME(BLASLONG n, BLASLONG dummy0, BLASLONG dummy1, FLOAT da_r,FLOAT da_i, FLOAT *x, BLASLONG inc_x, FLOAT *y, BLASLONG inc_y, FLOAT *dummy, BLASLONG dummy2)
@@ -58,7 +60,26 @@ int CNAME(BLASLONG n, BLASLONG dummy0, BLASLONG dummy1, FLOAT da_r,FLOAT da_i, F
5860
unsigned int gvl = 0;
5961
FLOAT_V_T vt, v0, v1;
6062
if(da_r == 0.0 && da_i == 0.0){
61-
memset(&x[0], 0, n * 2 * sizeof(FLOAT));
63+
gvl = VSETVL(n);
64+
BLASLONG stride_x = inc_x * 2 * sizeof(FLOAT);
65+
BLASLONG inc_xv = inc_x * 2 * gvl;
66+
vt = VFMVVF_FLOAT(0.0, gvl);
67+
for(i=0,j=0; i < n/(gvl*2); i++){
68+
VSSEV_FLOAT(&x[ix], stride_x, vt, gvl);
69+
VSSEV_FLOAT(&x[ix+1], stride_x, vt, gvl);
70+
VSSEV_FLOAT(&x[ix+inc_xv], stride_x, vt, gvl);
71+
VSSEV_FLOAT(&x[ix+inc_xv+1], stride_x, vt, gvl);
72+
73+
j += gvl*2;
74+
ix += inc_xv*2;
75+
}
76+
for(; j < n; ){
77+
gvl = VSETVL(n-j);
78+
VSSEV_FLOAT(&x[ix], stride_x, vt, gvl);
79+
VSSEV_FLOAT(&x[ix+1], stride_x, vt, gvl);
80+
j += gvl;
81+
ix += inc_x * 2 * gvl;
82+
}
6283
}else if(da_r == 0.0){
6384
gvl = VSETVL(n);
6485
BLASLONG stride_x = inc_x * 2 * sizeof(FLOAT);

0 commit comments

Comments
 (0)