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.

gemm_tcopy_8_rvv.c 3.7 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /***************************************************************************
  2. Copyright (c) 2022, 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 FLOAT_V_T vfloat32m2_t
  30. #define FLOAT_V_T_HALF vfloat32m1_t
  31. #define VLEV_FLOAT __riscv_vle32_v_f32m2
  32. #define VLEV_FLOAT_HALF __riscv_vle32_v_f32m1
  33. #define VSEV_FLOAT __riscv_vse32_v_f32m2
  34. #define VSEV_FLOAT_HALF __riscv_vse32_v_f32m1
  35. #else
  36. #define FLOAT_V_T vfloat64m4_t
  37. #define FLOAT_V_T_HALF vfloat64m2_t
  38. #define VLEV_FLOAT __riscv_vle64_v_f64m4
  39. #define VLEV_FLOAT_HALF __riscv_vle64_v_f64m2
  40. #define VSEV_FLOAT __riscv_vse64_v_f64m4
  41. #define VSEV_FLOAT_HALF __riscv_vse64_v_f64m2
  42. #endif
  43. int CNAME(BLASLONG m, BLASLONG n, IFLOAT *a, BLASLONG lda, IFLOAT *b)
  44. {
  45. BLASLONG i, j;
  46. IFLOAT *aoffset;
  47. IFLOAT *aoffset1;
  48. IFLOAT *boffset, *boffset1, *boffset2, *boffset3, *boffset4;
  49. FLOAT_V_T v0;
  50. FLOAT_V_T_HALF v1;
  51. // fprintf(stderr, "gemm_tcopy_8 m=%ld n=%ld lda=%ld\n", m, n, lda);
  52. aoffset = a;
  53. boffset = b;
  54. boffset2 = b + m * (n & ~7);
  55. boffset3 = b + m * (n & ~3);
  56. boffset4 = b + m * (n & ~1);
  57. for(j = m; j > 0; j--) {
  58. aoffset1 = aoffset;
  59. boffset1 = boffset;
  60. aoffset += lda;
  61. boffset += 8;
  62. for(i = (n >> 3); i > 0; i--) {
  63. size_t vl = 8;
  64. v0 = VLEV_FLOAT(aoffset1, vl);
  65. VSEV_FLOAT(boffset1, v0, vl);
  66. aoffset1 += 8;
  67. boffset1 += 8 * m;
  68. }
  69. if (n & 4) {
  70. size_t vl = 4;
  71. v1 = VLEV_FLOAT_HALF(aoffset1, vl);
  72. VSEV_FLOAT_HALF(boffset2, v1, vl);
  73. aoffset1 += 4;
  74. boffset2 += 4;
  75. }
  76. if (n & 2) {
  77. *(boffset3) = *(aoffset1);
  78. *(boffset3 + 1) = *(aoffset1 + 1);
  79. aoffset1 += 2;
  80. boffset3 += 2;
  81. }
  82. if (n & 1) {
  83. *(boffset4) = *(aoffset1);
  84. aoffset1 ++;
  85. boffset4 ++;
  86. }
  87. }
  88. return 0;
  89. }