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.

ztrmm_ltcopy_rvv_v1.c 5.5 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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 <stdio.h>
  28. #include "common.h"
  29. #if !defined(DOUBLE)
  30. #define VSETVL(n) __riscv_vsetvl_e32m2(n)
  31. #define FLOAT_V_T vfloat32m2_t
  32. #define FLOAT_VX2_T vfloat32m2x2_t
  33. #define VGET_VX2 __riscv_vget_v_f32m2x2_f32m2
  34. #define VSET_VX2 __riscv_vset_v_f32m2_f32m2x2
  35. #define VLEV_FLOAT __riscv_vle32_v_f32m2
  36. #define VSEV_FLOAT __riscv_vse32_v_f32m2
  37. #define VLSEG2_FLOAT __riscv_vlseg2e32_v_f32m2x2
  38. #define VSSEG2_FLOAT __riscv_vsseg2e32_v_f32m2x2
  39. #define VBOOL_T vbool16_t
  40. #define UINT_V_T vuint32m2_t
  41. #define VID_V_UINT __riscv_vid_v_u32m2
  42. #define VMSLTU_VX_UINT __riscv_vmsltu_vx_u32m2_b16
  43. #define VMSEQ_VX_UINT __riscv_vmseq_vx_u32m2_b16
  44. #define VFMERGE_VFM_FLOAT __riscv_vfmerge_vfm_f32m2
  45. #else
  46. #define VSETVL(n) __riscv_vsetvl_e64m2(n)
  47. #define FLOAT_V_T vfloat64m2_t
  48. #define FLOAT_VX2_T vfloat64m2x2_t
  49. #define VGET_VX2 __riscv_vget_v_f64m2x2_f64m2
  50. #define VSET_VX2 __riscv_vset_v_f64m2_f64m2x2
  51. #define VLEV_FLOAT __riscv_vle64_v_f64m2
  52. #define VSEV_FLOAT __riscv_vse64_v_f64m2
  53. #define VLSEG2_FLOAT __riscv_vlseg2e64_v_f64m2x2
  54. #define VSSEG2_FLOAT __riscv_vsseg2e64_v_f64m2x2
  55. #define VBOOL_T vbool32_t
  56. #define UINT_V_T vuint64m2_t
  57. #define VID_V_UINT __riscv_vid_v_u64m2
  58. #define VMSLTU_VX_UINT __riscv_vmsltu_vx_u64m2_b32
  59. #define VMSEQ_VX_UINT __riscv_vmseq_vx_u64m2_b32
  60. #define VFMERGE_VFM_FLOAT __riscv_vfmerge_vfm_f64m2
  61. #endif
  62. int CNAME(BLASLONG m, BLASLONG n, FLOAT *a, BLASLONG lda, BLASLONG posX, BLASLONG posY, FLOAT *b){
  63. BLASLONG i, js, X;
  64. FLOAT *ao;
  65. FLOAT_VX2_T vax2;
  66. FLOAT_V_T va0, va1;
  67. size_t vl;
  68. #ifdef UNIT
  69. VBOOL_T vbool_eq;
  70. #endif
  71. VBOOL_T vbool_cmp;
  72. UINT_V_T vindex;
  73. for (js = n; js > 0; js -= vl)
  74. {
  75. vl = VSETVL(js);
  76. X = posX;
  77. if (posX <= posY)
  78. {
  79. ao = a + posY * 2 + posX * lda * 2;
  80. }
  81. else
  82. {
  83. ao = a + posX * 2 + posY * lda * 2;
  84. }
  85. i = 0;
  86. do
  87. {
  88. if (X > posY)
  89. {
  90. ao += 2;
  91. b += vl * 2;
  92. X++;
  93. i++;
  94. }
  95. else if (X < posY)
  96. {
  97. //va1 = VLEV_FLOAT(ao, vl);
  98. vax2 = VLSEG2_FLOAT(ao, vl);
  99. VSSEG2_FLOAT(b, vax2, vl);
  100. ao += lda * 2;
  101. b += vl * 2;
  102. X ++;
  103. i ++;
  104. }
  105. else
  106. {
  107. vindex = VID_V_UINT(vl);
  108. for (unsigned int j = 0; j < vl; j++)
  109. {
  110. //va1 = VLEV_FLOAT(ao, vl);
  111. vax2 = VLSEG2_FLOAT(ao, vl);
  112. va0 = VGET_VX2(vax2, 0);
  113. va1 = VGET_VX2(vax2, 1);
  114. vbool_cmp = VMSLTU_VX_UINT(vindex, j, vl);
  115. va0 = VFMERGE_VFM_FLOAT(va0, ZERO, vbool_cmp, vl);
  116. va1 = VFMERGE_VFM_FLOAT(va1, ZERO, vbool_cmp, vl);
  117. #ifdef UNIT
  118. vbool_eq = VMSEQ_VX_UINT(vindex, j, vl);
  119. va0 = VFMERGE_VFM_FLOAT(va0, ONE, vbool_eq, vl);
  120. va1 = VFMERGE_VFM_FLOAT(va1, ZERO, vbool_eq, vl);
  121. #endif
  122. vax2 = VSET_VX2(vax2, 0, va0);
  123. vax2 = VSET_VX2(vax2, 1, va1);
  124. VSSEG2_FLOAT(b, vax2, vl);
  125. ao += lda * 2;
  126. b += vl * 2;
  127. }
  128. X += vl;
  129. i += vl;
  130. }
  131. } while (i < m);
  132. posY += vl;
  133. }
  134. return 0;
  135. }