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.

ztrsm_uncopy_rvv_v1.c 4.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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_VX2_T vfloat32m2x2_t
  32. #define VLSSEG2_FLOAT __riscv_vlsseg2e32_v_f32m2x2
  33. #define VSSEG2_FLOAT __riscv_vsseg2e32_v_f32m2x2
  34. #define VSSEG2_FLOAT_M __riscv_vsseg2e32_v_f32m2x2_m
  35. #define VBOOL_T vbool16_t
  36. #define UINT_V_T vuint32m2_t
  37. #define VID_V_UINT __riscv_vid_v_u32m2
  38. #define VMSGTU_VX_UINT __riscv_vmsgtu_vx_u32m2_b16
  39. #else
  40. #define VSETVL(n) __riscv_vsetvl_e64m2(n)
  41. #define FLOAT_VX2_T vfloat64m2x2_t
  42. #define VLSSEG2_FLOAT __riscv_vlsseg2e64_v_f64m2x2
  43. #define VSSEG2_FLOAT __riscv_vsseg2e64_v_f64m2x2
  44. #define VSSEG2_FLOAT_M __riscv_vsseg2e64_v_f64m2x2_m
  45. #define VBOOL_T vbool32_t
  46. #define UINT_V_T vuint64m2_t
  47. #define VID_V_UINT __riscv_vid_v_u64m2
  48. #define VMSGTU_VX_UINT __riscv_vmsgtu_vx_u64m2_b32
  49. #endif
  50. int CNAME(BLASLONG m, BLASLONG n, FLOAT *a, BLASLONG lda, BLASLONG offset, FLOAT *b){
  51. //fprintf(stderr, "%s , %s, m = %4ld n = %4ld lda = %4ld offset = %4ld\n", __FILE__, __FUNCTION__, m, n, lda, offset); // Debug
  52. BLASLONG i, ii, jj, js;
  53. BLASLONG stride_lda = sizeof(FLOAT)*lda*2;
  54. FLOAT *ao;
  55. jj = offset;
  56. FLOAT_VX2_T vax2;
  57. VBOOL_T vbool_cmp;
  58. UINT_V_T vindex;
  59. size_t vl;
  60. for (js = n; js > 0; js -= vl)
  61. {
  62. vl = VSETVL(js);
  63. ao = a;
  64. i = 0;
  65. ii = 0;
  66. for (i = 0; i < m;)
  67. {
  68. if (ii == jj)
  69. {
  70. vindex = VID_V_UINT(vl);
  71. for (unsigned int j = 0; j < vl; j++)
  72. {
  73. compinv((b + j * 2), *(ao + j * lda * 2), *(ao + j * lda * 2 + 1));
  74. vax2 = VLSSEG2_FLOAT(ao, stride_lda, vl);
  75. vbool_cmp = VMSGTU_VX_UINT(vindex, j, vl);
  76. VSSEG2_FLOAT_M(vbool_cmp, b, vax2, vl);
  77. ao += 2;
  78. b += vl * 2;
  79. }
  80. i += vl;
  81. ii += vl;
  82. }
  83. else
  84. {
  85. if (ii < jj)
  86. {
  87. vax2 = VLSSEG2_FLOAT(ao, stride_lda, vl);
  88. VSSEG2_FLOAT(b, vax2, vl);
  89. }
  90. ao += 2;
  91. b += vl * 2;
  92. i++;
  93. ii++;
  94. }
  95. }
  96. a += vl * lda * 2;
  97. jj += vl;
  98. }
  99. return 0;
  100. }