|
| 1 | +/*************************************************************************** |
| 2 | +Copyright (c) 2013, The OpenBLAS Project |
| 3 | +All rights reserved. |
| 4 | +Redistribution and use in source and binary forms, with or without |
| 5 | +modification, are permitted provided that the following conditions are |
| 6 | +met: |
| 7 | +1. Redistributions of source code must retain the above copyright |
| 8 | +notice, this list of conditions and the following disclaimer. |
| 9 | +2. Redistributions in binary form must reproduce the above copyright |
| 10 | +notice, this list of conditions and the following disclaimer in |
| 11 | +the documentation and/or other materials provided with the |
| 12 | +distribution. |
| 13 | +3. Neither the name of the OpenBLAS project nor the names of |
| 14 | +its contributors may be used to endorse or promote products |
| 15 | +derived from this software without specific prior written permission. |
| 16 | +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 17 | +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 18 | +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 19 | +ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE |
| 20 | +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 21 | +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 22 | +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 23 | +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 24 | +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE |
| 25 | +USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 | +*****************************************************************************/ |
| 27 | + |
| 28 | +#include "common.h" |
| 29 | + |
| 30 | + |
| 31 | +#if !defined(DOUBLE) |
| 32 | +#define VSETVL(n) RISCV_RVV(vsetvl_e32m4)(n) |
| 33 | +#define FLOAT_V_T vfloat32m4_t |
| 34 | +#define VLEV_FLOAT RISCV_RVV(vle32_v_f32m4) |
| 35 | +#define VLSEV_FLOAT RISCV_RVV(vlse32_v_f32m4) |
| 36 | +#define VSEV_FLOAT RISCV_RVV(vse32_v_f32m4) |
| 37 | +#define VSSEV_FLOAT RISCV_RVV(vsse32_v_f32m4) |
| 38 | +#define VFMACCVF_FLOAT RISCV_RVV(vfmacc_vf_f32m4) |
| 39 | +#define VFNMSACVF_FLOAT RISCV_RVV(vfnmsac_vf_f32m4) |
| 40 | +#define VFMUL_VF_FLOAT RISCV_RVV(vfmul_vf_f32m4) |
| 41 | +#define VSEV_FLOAT RISCV_RVV(vse32_v_f32m4) |
| 42 | +#define VLSEG2_FLOAT RISCV_RVV(vlseg2e32_v_f32m4x2) |
| 43 | +#define VSSEG2_FLOAT RISCV_RVV(vsseg2e32_v_f32m4x2) |
| 44 | +#define FLOAT_VX2_T vfloat32m4x2_t |
| 45 | +#define VGET_VX2 RISCV_RVV(vget_v_f32m4x2_f32m4) |
| 46 | +#define VSET_VX2 RISCV_RVV(vset_v_f32m4_f32m4x2) |
| 47 | +#else |
| 48 | +#define VSETVL(n) RISCV_RVV(vsetvl_e64m4)(n) |
| 49 | +#define FLOAT_V_T vfloat64m4_t |
| 50 | +#define VLEV_FLOAT RISCV_RVV(vle64_v_f64m4) |
| 51 | +#define VLSEV_FLOAT RISCV_RVV(vlse64_v_f64m4) |
| 52 | +#define VSEV_FLOAT RISCV_RVV(vse64_v_f64m4) |
| 53 | +#define VSSEV_FLOAT RISCV_RVV(vsse64_v_f64m4) |
| 54 | +#define VFMACCVF_FLOAT RISCV_RVV(vfmacc_vf_f64m4) |
| 55 | +#define VFNMSACVF_FLOAT RISCV_RVV(vfnmsac_vf_f64m4) |
| 56 | +#define VFMUL_VF_FLOAT RISCV_RVV(vfmul_vf_f64m4) |
| 57 | +#define VSEV_FLOAT RISCV_RVV(vse64_v_f64m4) |
| 58 | +#define VLSEG2_FLOAT RISCV_RVV(vlseg2e64_v_f64m4x2) |
| 59 | +#define VSSEG2_FLOAT RISCV_RVV(vsseg2e64_v_f64m4x2) |
| 60 | +#define FLOAT_VX2_T vfloat64m4x2_t |
| 61 | +#define VGET_VX2 RISCV_RVV(vget_v_f64m4x2_f64m4) |
| 62 | +#define VSET_VX2 RISCV_RVV(vset_v_f64m4_f64m4x2) |
| 63 | +#endif |
| 64 | + |
| 65 | +int CNAME(BLASLONG rows, BLASLONG cols, FLOAT alpha_r, FLOAT alpha_i, FLOAT *a, BLASLONG lda, FLOAT *b, BLASLONG ldb) |
| 66 | +{ |
| 67 | + BLASLONG i,j,ia; |
| 68 | + FLOAT *aptr,*bptr; |
| 69 | + FLOAT_V_T bptr_v0 , bptr_v1 , aptr_v0 ,aptr_v1; |
| 70 | + FLOAT_VX2_T va, vb; |
| 71 | + unsigned int gvl = 0; |
| 72 | + |
| 73 | + if ( rows <= 0 ) return(0); |
| 74 | + if ( cols <= 0 ) return(0); |
| 75 | + |
| 76 | + aptr = a; |
| 77 | + bptr = b; |
| 78 | + |
| 79 | + lda *= 2; |
| 80 | + ldb *= 2; |
| 81 | + for ( i=0; i<cols ; i++ ) |
| 82 | + { |
| 83 | + ia = 0; |
| 84 | + for(j=0; j<rows ; j+=gvl) |
| 85 | + { |
| 86 | + gvl = VSETVL(rows - j); |
| 87 | + va = VLSEG2_FLOAT(aptr + ia, gvl); |
| 88 | + aptr_v0 = VGET_VX2(va, 0); |
| 89 | + aptr_v1 = VGET_VX2(va, 1); |
| 90 | + bptr_v1 = VFMUL_VF_FLOAT( aptr_v1, alpha_r,gvl); |
| 91 | + bptr_v1 = VFMACCVF_FLOAT(bptr_v1, alpha_i, aptr_v0, gvl); |
| 92 | + bptr_v0 = VFMUL_VF_FLOAT( aptr_v0,alpha_r, gvl); |
| 93 | + bptr_v0 = VFNMSACVF_FLOAT(bptr_v0, alpha_i, aptr_v1, gvl); |
| 94 | + vb = VSET_VX2(vb, 0, bptr_v0); |
| 95 | + vb = VSET_VX2(vb, 1, bptr_v1); |
| 96 | + VSSEG2_FLOAT(&bptr[ia], vb, gvl); |
| 97 | + ia += gvl * 2 ; |
| 98 | + |
| 99 | + } |
| 100 | + aptr += lda; |
| 101 | + bptr += ldb; |
| 102 | + } |
| 103 | + |
| 104 | + return(0); |
| 105 | + |
| 106 | +} |
0 commit comments