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.

sum_lasx.S 5.6 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. /*****************************************************************************
  2. Copyright (c) 2023, 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
  16. permission.
  17. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  18. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20. ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  21. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  23. SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  24. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  25. OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
  26. USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. **********************************************************************************/
  28. #define ASSEMBLER
  29. #include "common.h"
  30. #define N $r4
  31. #define X $r5
  32. #define INCX $r6
  33. #define I $r17
  34. #define TEMP $r18
  35. #define t1 $r15
  36. #define t2 $r12
  37. #define t3 $r13
  38. #define t4 $r14
  39. #define VX0 $xr12
  40. #define VX1 $xr13
  41. #define VX2 $xr14
  42. #define VX3 $xr15
  43. #define res1 $xr16
  44. #define res2 $xr17
  45. PROLOGUE
  46. xvxor.v res1, res1, res1
  47. xvxor.v res2, res2, res2
  48. bge $r0, N, .L999
  49. bge $r0, INCX, .L999
  50. li.d TEMP, SIZE
  51. slli.d INCX, INCX, BASE_SHIFT
  52. srai.d I, N, 3
  53. bne INCX, TEMP, .L20
  54. bge $r0, I, .L13
  55. .align 3
  56. .L11:
  57. xvld VX0, X, 0
  58. xvfadd.s res1, res1, VX0
  59. #ifdef DOUBLE
  60. xvld VX1, X, 32
  61. xvfadd.s res1, res1, VX1
  62. #endif
  63. addi.d X, X, 8 * SIZE
  64. addi.d I, I, -1
  65. blt $r0, I, .L11
  66. .align 3
  67. .L12:
  68. #ifdef DOUBLE
  69. xvpickve.d VX1, res1, 1
  70. xvpickve.d VX2, res1, 2
  71. xvpickve.d VX3, res1, 3
  72. xvfadd.d res1, VX1, res1
  73. xvfadd.d res1, VX2, res1
  74. xvfadd.d res1, VX3, res1
  75. #else
  76. xvfadd.s res2, res1, res2
  77. xvpickve.w VX1, res1, 1
  78. xvpickve.w VX2, res1, 2
  79. xvpickve.w VX3, res1, 3
  80. xvfadd.s res1, VX1, res1
  81. xvfadd.s res1, VX2, res1
  82. xvfadd.s res1, VX3, res1
  83. xvpickve.w VX0, res2, 4
  84. xvpickve.w VX1, res2, 5
  85. xvpickve.w VX2, res2, 6
  86. xvpickve.w VX3, res2, 7
  87. xvfadd.s res1, VX0, res1
  88. xvfadd.s res1, VX1, res1
  89. xvfadd.s res1, VX2, res1
  90. xvfadd.s res1, VX3, res1
  91. #endif
  92. .align 3
  93. .L13:
  94. andi I, N, 7
  95. bge $r0, I, .L999
  96. .align 3
  97. .L14:
  98. LD $f12, X, 0
  99. ADD $f16, $f12, $f16
  100. addi.d I, I, -1
  101. addi.d X, X, SIZE
  102. blt $r0, I, .L14
  103. b .L999
  104. .align 3
  105. .L20:
  106. bge $r0, I, .L23
  107. .align 3
  108. .L21:
  109. #ifdef DOUBLE
  110. ld.d t1, X, 0
  111. add.d X, X, INCX
  112. ld.d t2, X, 0
  113. add.d X, X, INCX
  114. ld.d t3, X, 0
  115. add.d X, X, INCX
  116. ld.d t4, X, 0
  117. add.d X, X, INCX
  118. xvinsgr2vr.d VX0, t1, 0
  119. xvinsgr2vr.d VX0, t2, 1
  120. xvinsgr2vr.d VX0, t3, 2
  121. xvinsgr2vr.d VX0, t4, 3
  122. ld.d t1, X, 0
  123. add.d X, X, INCX
  124. ld.d t2, X, 0
  125. add.d X, X, INCX
  126. ld.d t3, X, 0
  127. add.d X, X, INCX
  128. ld.d t4, X, 0
  129. add.d X, X, INCX
  130. xvinsgr2vr.d VX1, t1, 0
  131. xvinsgr2vr.d VX1, t2, 1
  132. xvinsgr2vr.d VX1, t3, 2
  133. xvinsgr2vr.d VX1, t4, 3
  134. xvfadd.d res2, VX0, VX1
  135. xvfadd.d res1, res1, res2
  136. #else
  137. ld.w t1, X, 0
  138. add.d X, X, INCX
  139. ld.w t2, X, 0
  140. add.d X, X, INCX
  141. ld.w t3, X, 0
  142. add.d X, X, INCX
  143. ld.w t4, X, 0
  144. add.d X, X, INCX
  145. xvinsgr2vr.w VX0, t1, 0
  146. xvinsgr2vr.w VX0, t2, 1
  147. xvinsgr2vr.w VX0, t3, 2
  148. xvinsgr2vr.w VX0, t4, 3
  149. ld.w t1, X, 0
  150. add.d X, X, INCX
  151. ld.w t2, X, 0
  152. add.d X, X, INCX
  153. ld.w t3, X, 0
  154. add.d X, X, INCX
  155. ld.w t4, X, 0
  156. add.d X, X, INCX
  157. xvinsgr2vr.w VX0, t1, 4
  158. xvinsgr2vr.w VX0, t2, 5
  159. xvinsgr2vr.w VX0, t3, 6
  160. xvinsgr2vr.w VX0, t4, 7
  161. xvfadd.s res1, VX0, res1
  162. #endif
  163. addi.d I, I, -1
  164. blt $r0, I, .L21
  165. .align 3
  166. .L22:
  167. #ifdef DOUBLE
  168. xvpickve.d VX1, res1, 1
  169. xvpickve.d VX2, res1, 2
  170. xvpickve.d VX3, res1, 3
  171. xvfadd.d res1, VX1, res1
  172. xvfadd.d res1, VX2, res1
  173. xvfadd.d res1, VX3, res1
  174. #else
  175. xvfadd.s res2, res1, res2
  176. xvpickve.w VX1, res1, 1
  177. xvpickve.w VX2, res1, 2
  178. xvpickve.w VX3, res1, 3
  179. xvfadd.s res1, VX1, res1
  180. xvfadd.s res1, VX2, res1
  181. xvfadd.s res1, VX3, res1
  182. xvpickve.w VX0, res2, 4
  183. xvpickve.w VX1, res2, 5
  184. xvpickve.w VX2, res2, 6
  185. xvpickve.w VX3, res2, 7
  186. xvfadd.s res1, VX0, res1
  187. xvfadd.s res1, VX1, res1
  188. xvfadd.s res1, VX2, res1
  189. xvfadd.s res1, VX3, res1
  190. #endif
  191. .align 3
  192. .L23:
  193. andi I, N, 7
  194. bge $r0, I, .L999
  195. .align 3
  196. .L24:
  197. LD $f12, X, 0
  198. ADD $f16, $f12, $f16
  199. addi.d I, I, -1
  200. add.d X, X, INCX
  201. blt $r0, I, .L24
  202. .align 3
  203. .L999:
  204. fmov.s $f0, $f16
  205. jirl $r0, $r1, 0x0
  206. .align 3
  207. EPILOGUE