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.

zrot_vector.c 5.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /***************************************************************************
  2. Copyright (c) 2020, 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) vsetvl_e32m4(n)
  30. #define VSETVL_MAX vsetvlmax_e32m1()
  31. #define FLOAT_V_T vfloat32m4_t
  32. #define VLEV_FLOAT vle_v_f32m4
  33. #define VLSEV_FLOAT vlse_v_f32m4
  34. #define VSEV_FLOAT vse_v_f32m4
  35. #define VSSEV_FLOAT vsse_v_f32m4
  36. #define VFMACCVF_FLOAT vfmacc_vf_f32m4
  37. #define VFMULVF_FLOAT vfmul_vf_f32m4
  38. #define VFNMSACVF_FLOAT vfnmsac_vf_f32m4
  39. #else
  40. #define VSETVL(n) vsetvl_e64m4(n)
  41. #define VSETVL_MAX vsetvlmax_e64m1()
  42. #define FLOAT_V_T vfloat64m4_t
  43. #define VLEV_FLOAT vle_v_f64m4
  44. #define VLSEV_FLOAT vlse_v_f64m4
  45. #define VSEV_FLOAT vse_v_f64m4
  46. #define VSSEV_FLOAT vsse_v_f64m4
  47. #define VFMACCVF_FLOAT vfmacc_vf_f64m4
  48. #define VFMULVF_FLOAT vfmul_vf_f64m4
  49. #define VFNMSACVF_FLOAT vfnmsac_vf_f64m4
  50. #endif
  51. int CNAME(BLASLONG n, FLOAT *x, BLASLONG inc_x, FLOAT *y, BLASLONG inc_y, FLOAT c, FLOAT s)
  52. {
  53. BLASLONG i=0, j=0;
  54. BLASLONG ix=0,iy=0;
  55. if (n < 1) return(0);
  56. unsigned int gvl = 0;
  57. FLOAT_V_T vt0, vt1, vx0, vx1, vy0, vy1;
  58. gvl = VSETVL(n);
  59. BLASLONG stride_x = inc_x * 2 * sizeof(FLOAT);
  60. BLASLONG stride_y = inc_y * 2 * sizeof(FLOAT);
  61. BLASLONG inc_xv = inc_x * 2 * gvl;
  62. BLASLONG inc_yv = inc_y * 2 * gvl;
  63. if(inc_x==1 && inc_y==1){
  64. for(i=0,j=0; i < n/gvl; i++){
  65. vx0 = VLEV_FLOAT(&x[ix], gvl);
  66. vx1 = VLEV_FLOAT(&x[ix+gvl], gvl);
  67. vy0 = VLEV_FLOAT(&y[ix], gvl);
  68. vy1 = VLEV_FLOAT(&y[ix+gvl], gvl);
  69. vt0 = VFMULVF_FLOAT(vx0, c, gvl);
  70. vt0 = VFMACCVF_FLOAT(vt0, s, vy0, gvl);
  71. vt1 = VFMULVF_FLOAT(vx1, c, gvl);
  72. vt1 = VFMACCVF_FLOAT(vt1, s, vy1, gvl);
  73. vy0 = VFMULVF_FLOAT(vy0, c, gvl);
  74. vy0 = VFNMSACVF_FLOAT(vy0, s, vx0, gvl);
  75. vy1 = VFMULVF_FLOAT(vy1, c, gvl);
  76. vy1 = VFNMSACVF_FLOAT(vy1, s, vx1, gvl);
  77. VSEV_FLOAT(&x[ix], vt0, gvl);
  78. VSEV_FLOAT(&x[ix+gvl], vt1, gvl);
  79. VSEV_FLOAT(&y[ix], vy0, gvl);
  80. VSEV_FLOAT(&y[ix+gvl], vy1, gvl);
  81. j += gvl;
  82. ix += 2*gvl;
  83. }
  84. if(j < n){
  85. gvl = VSETVL(n-j);
  86. vx0 = VLEV_FLOAT(&x[ix], gvl);
  87. vx1 = VLEV_FLOAT(&x[ix+gvl], gvl);
  88. vy0 = VLEV_FLOAT(&y[ix], gvl);
  89. vy1 = VLEV_FLOAT(&y[ix+gvl], gvl);
  90. vt0 = VFMULVF_FLOAT(vx0, c, gvl);
  91. vt0 = VFMACCVF_FLOAT(vt0, s, vy0, gvl);
  92. vt1 = VFMULVF_FLOAT(vx1, c, gvl);
  93. vt1 = VFMACCVF_FLOAT(vt1, s, vy1, gvl);
  94. vy0 = VFMULVF_FLOAT(vy0, c, gvl);
  95. vy0 = VFNMSACVF_FLOAT(vy0, s, vx0, gvl);
  96. vy1 = VFMULVF_FLOAT(vy1, c, gvl);
  97. vy1 = VFNMSACVF_FLOAT(vy1, s, vx1, gvl);
  98. VSEV_FLOAT(&x[ix], vt0, gvl);
  99. VSEV_FLOAT(&x[ix+gvl], vt1, gvl);
  100. VSEV_FLOAT(&y[ix], vy0, gvl);
  101. VSEV_FLOAT(&y[ix+gvl], vy1, gvl);
  102. }
  103. }else{
  104. for(i=0,j=0; i < n/gvl; i++){
  105. vx0 = VLSEV_FLOAT(&x[ix], stride_x, gvl);
  106. vx1 = VLSEV_FLOAT(&x[ix+1], stride_x, gvl);
  107. vy0 = VLSEV_FLOAT(&y[iy], stride_y, gvl);
  108. vy1 = VLSEV_FLOAT(&y[iy+1], stride_y, gvl);
  109. vt0 = VFMULVF_FLOAT(vx0, c, gvl);
  110. vt0 = VFMACCVF_FLOAT(vt0, s, vy0, gvl);
  111. vt1 = VFMULVF_FLOAT(vx1, c, gvl);
  112. vt1 = VFMACCVF_FLOAT(vt1, s, vy1, gvl);
  113. vy0 = VFMULVF_FLOAT(vy0, c, gvl);
  114. vy0 = VFNMSACVF_FLOAT(vy0, s, vx0, gvl);
  115. vy1 = VFMULVF_FLOAT(vy1, c, gvl);
  116. vy1 = VFNMSACVF_FLOAT(vy1, s, vx1, gvl);
  117. VSSEV_FLOAT(&x[ix], stride_x, vt0, gvl);
  118. VSSEV_FLOAT(&x[ix+1], stride_x, vt1, gvl);
  119. VSSEV_FLOAT(&y[iy], stride_y, vy0, gvl);
  120. VSSEV_FLOAT(&y[iy+1], stride_y, vy1, gvl);
  121. j += gvl;
  122. ix += inc_xv;
  123. iy += inc_yv;
  124. }
  125. if(j < n){
  126. gvl = VSETVL(n-j);
  127. vx0 = VLSEV_FLOAT(&x[ix], stride_x, gvl);
  128. vx1 = VLSEV_FLOAT(&x[ix+1], stride_x, gvl);
  129. vy0 = VLSEV_FLOAT(&y[iy], stride_y, gvl);
  130. vy1 = VLSEV_FLOAT(&y[iy+1], stride_y, gvl);
  131. vt0 = VFMULVF_FLOAT(vx0, c, gvl);
  132. vt0 = VFMACCVF_FLOAT(vt0, s, vy0, gvl);
  133. vt1 = VFMULVF_FLOAT(vx1, c, gvl);
  134. vt1 = VFMACCVF_FLOAT(vt1, s, vy1, gvl);
  135. vy0 = VFMULVF_FLOAT(vy0, c, gvl);
  136. vy0 = VFNMSACVF_FLOAT(vy0, s, vx0, gvl);
  137. vy1 = VFMULVF_FLOAT(vy1, c, gvl);
  138. vy1 = VFNMSACVF_FLOAT(vy1, s, vx1, gvl);
  139. VSSEV_FLOAT(&x[ix], stride_x, vt0, gvl);
  140. VSSEV_FLOAT(&x[ix+1], stride_x, vt1, gvl);
  141. VSSEV_FLOAT(&y[iy], stride_y, vy0, gvl);
  142. VSSEV_FLOAT(&y[iy+1], stride_y, vy1, gvl);
  143. }
  144. }
  145. return(0);
  146. }