You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

zomatcopy_cn_vector.c 4.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. #include "common.h"
  28. #if !defined(DOUBLE)
  29. #define VSETVL(n) RISCV_RVV(vsetvl_e32m4)(n)
  30. #define FLOAT_V_T vfloat32m4_t
  31. #define VLEV_FLOAT RISCV_RVV(vle32_v_f32m4)
  32. #define VLSEV_FLOAT RISCV_RVV(vlse32_v_f32m4)
  33. #define VSEV_FLOAT RISCV_RVV(vse32_v_f32m4)
  34. #define VSSEV_FLOAT RISCV_RVV(vsse32_v_f32m4)
  35. #define VFMACCVF_FLOAT RISCV_RVV(vfmacc_vf_f32m4)
  36. #define VFNMSACVF_FLOAT RISCV_RVV(vfnmsac_vf_f32m4)
  37. #define VFMUL_VF_FLOAT RISCV_RVV(vfmul_vf_f32m4)
  38. #define VSEV_FLOAT RISCV_RVV(vse32_v_f32m4)
  39. #define VLSEG2_FLOAT RISCV_RVV(vlseg2e32_v_f32m4x2)
  40. #define VSSEG2_FLOAT RISCV_RVV(vsseg2e32_v_f32m4x2)
  41. #define FLOAT_VX2_T vfloat32m4x2_t
  42. #define VGET_VX2 RISCV_RVV(vget_v_f32m4x2_f32m4)
  43. #define VSET_VX2 RISCV_RVV(vset_v_f32m4_f32m4x2)
  44. #else
  45. #define VSETVL(n) RISCV_RVV(vsetvl_e64m4)(n)
  46. #define FLOAT_V_T vfloat64m4_t
  47. #define VLEV_FLOAT RISCV_RVV(vle64_v_f64m4)
  48. #define VLSEV_FLOAT RISCV_RVV(vlse64_v_f64m4)
  49. #define VSEV_FLOAT RISCV_RVV(vse64_v_f64m4)
  50. #define VSSEV_FLOAT RISCV_RVV(vsse64_v_f64m4)
  51. #define VFMACCVF_FLOAT RISCV_RVV(vfmacc_vf_f64m4)
  52. #define VFNMSACVF_FLOAT RISCV_RVV(vfnmsac_vf_f64m4)
  53. #define VFMUL_VF_FLOAT RISCV_RVV(vfmul_vf_f64m4)
  54. #define VSEV_FLOAT RISCV_RVV(vse64_v_f64m4)
  55. #define VLSEG2_FLOAT RISCV_RVV(vlseg2e64_v_f64m4x2)
  56. #define VSSEG2_FLOAT RISCV_RVV(vsseg2e64_v_f64m4x2)
  57. #define FLOAT_VX2_T vfloat64m4x2_t
  58. #define VGET_VX2 RISCV_RVV(vget_v_f64m4x2_f64m4)
  59. #define VSET_VX2 RISCV_RVV(vset_v_f64m4_f64m4x2)
  60. #endif
  61. int CNAME(BLASLONG rows, BLASLONG cols, FLOAT alpha_r, FLOAT alpha_i, FLOAT *a, BLASLONG lda, FLOAT *b, BLASLONG ldb)
  62. {
  63. BLASLONG i,j,ia;
  64. FLOAT *aptr,*bptr;
  65. FLOAT_V_T bptr_v0 , bptr_v1 , aptr_v0 ,aptr_v1;
  66. FLOAT_VX2_T va, vb;
  67. unsigned int gvl = 0;
  68. if ( rows <= 0 ) return(0);
  69. if ( cols <= 0 ) return(0);
  70. aptr = a;
  71. bptr = b;
  72. lda *= 2;
  73. ldb *= 2;
  74. for ( i=0; i<cols ; i++ )
  75. {
  76. ia = 0;
  77. for(j=0; j<rows ; j+=gvl)
  78. {
  79. gvl = VSETVL(rows - j);
  80. va = VLSEG2_FLOAT(aptr + ia, gvl);
  81. aptr_v0 = VGET_VX2(va, 0);
  82. aptr_v1 = VGET_VX2(va, 1);
  83. bptr_v1 = VFMUL_VF_FLOAT( aptr_v1, alpha_r,gvl);
  84. bptr_v1 = VFMACCVF_FLOAT(bptr_v1, alpha_i, aptr_v0, gvl);
  85. bptr_v0 = VFMUL_VF_FLOAT( aptr_v0,alpha_r, gvl);
  86. bptr_v0 = VFNMSACVF_FLOAT(bptr_v0, alpha_i, aptr_v1, gvl);
  87. vb = VSET_VX2(vb, 0, bptr_v0);
  88. vb = VSET_VX2(vb, 1, bptr_v1);
  89. VSSEG2_FLOAT(&bptr[ia], vb, gvl);
  90. ia += gvl * 2 ;
  91. }
  92. aptr += lda;
  93. bptr += ldb;
  94. }
  95. return(0);
  96. }