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_lsx.S 5.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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 $vr12
  40. #define VX1 $vr13
  41. #define VX2 $vr14
  42. #define VX3 $vr15
  43. #define res1 $vr16
  44. #define res2 $vr17
  45. PROLOGUE
  46. vxor.v res1, res1, res1
  47. vxor.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. vld VX0, X, 0
  58. vld VX1, X, 16
  59. VFADD res2, VX0, VX1
  60. VFADD res1, res1, res2
  61. #ifdef DOUBLE
  62. vld VX0, X, 32
  63. vld VX1, X, 48
  64. VFADD res2, VX0, VX1
  65. VFADD res1, res1, res2
  66. #endif
  67. addi.d X, X, 8 * SIZE
  68. addi.d I, I, -1
  69. blt $r0, I, .L11
  70. .align 3
  71. .L12:
  72. #ifdef DOUBLE
  73. vreplvei.d VX1, res1, 1
  74. vfadd.d res1, res1, VX1
  75. #else
  76. vreplvei.w VX1, res1, 1
  77. vreplvei.w VX2, res1, 2
  78. vreplvei.w VX3, res1, 3
  79. vfadd.s res1, VX1, res1
  80. vfadd.s res1, VX2, res1
  81. vfadd.s res1, VX3, res1
  82. #endif
  83. .align 3
  84. .L13:
  85. andi I, N, 7
  86. bge $r0, I, .L999
  87. .align 3
  88. .L14:
  89. LD $f12, X, 0
  90. ADD $f16, $f12, $f16
  91. addi.d I, I, -1
  92. addi.d X, X, SIZE
  93. blt $r0, I, .L14
  94. b .L999
  95. .align 3
  96. .L20:
  97. bge $r0, I, .L23
  98. .align 3
  99. .L21:
  100. #ifdef DOUBLE
  101. ld.d t1, X, 0
  102. add.d X, X, INCX
  103. ld.d t2, X, 0
  104. add.d X, X, INCX
  105. vinsgr2vr.d VX0, t1, 0
  106. vinsgr2vr.d VX0, t2, 1
  107. ld.d t1, X, 0
  108. add.d X, X, INCX
  109. ld.d t2, X, 0
  110. add.d X, X, INCX
  111. vinsgr2vr.d VX1, t1, 0
  112. vinsgr2vr.d VX1, t2, 1
  113. vfadd.d res2, VX0, VX1
  114. vfadd.d res1, res1, res2
  115. ld.d t3, X, 0
  116. add.d X, X, INCX
  117. ld.d t4, X, 0
  118. add.d X, X, INCX
  119. vinsgr2vr.d VX0, t3, 0
  120. vinsgr2vr.d VX0, t4, 1
  121. ld.d t3, X, 0
  122. add.d X, X, INCX
  123. ld.d t4, X, 0
  124. add.d X, X, INCX
  125. vinsgr2vr.d VX1, t3, 0
  126. vinsgr2vr.d VX1, t4, 1
  127. vfadd.d res2, VX0, VX1
  128. vfadd.d res1, res1, res2
  129. #else
  130. ld.w t1, X, 0
  131. add.d X, X, INCX
  132. ld.w t2, X, 0
  133. add.d X, X, INCX
  134. ld.w t3, X, 0
  135. add.d X, X, INCX
  136. ld.w t4, X, 0
  137. add.d X, X, INCX
  138. vinsgr2vr.w VX0, t1, 0
  139. vinsgr2vr.w VX0, t2, 1
  140. vinsgr2vr.w VX0, t3, 2
  141. vinsgr2vr.w VX0, t4, 3
  142. ld.w t1, X, 0
  143. add.d X, X, INCX
  144. ld.w t2, X, 0
  145. add.d X, X, INCX
  146. ld.w t3, X, 0
  147. add.d X, X, INCX
  148. ld.w t4, X, 0
  149. add.d X, X, INCX
  150. vinsgr2vr.w VX1, t1, 0
  151. vinsgr2vr.w VX1, t2, 1
  152. vinsgr2vr.w VX1, t3, 2
  153. vinsgr2vr.w VX1, t4, 3
  154. vfadd.s res2, VX0, VX1
  155. vfadd.s res1, res1, res2
  156. #endif
  157. addi.d I, I, -1
  158. blt $r0, I, .L21
  159. .align 3
  160. .L22:
  161. #ifdef DOUBLE
  162. vreplvei.d VX1, res1, 1
  163. vfadd.d res1, VX1, res1
  164. #else
  165. vreplvei.w VX1, res1, 1
  166. vreplvei.w VX2, res1, 2
  167. vreplvei.w VX3, res1, 3
  168. vfadd.s res1, VX1, res1
  169. vfadd.s res1, VX2, res1
  170. vfadd.s res1, VX3, res1
  171. #endif
  172. .align 3
  173. .L23:
  174. andi I, N, 7
  175. bge $r0, I, .L999
  176. .align 3
  177. .L24:
  178. LD $f12, X, 0
  179. ADD $f16, $f12, $f16
  180. addi.d I, I, -1
  181. add.d X, X, INCX
  182. blt $r0, I, .L24
  183. .align 3
  184. .L999:
  185. fmov.s $f0, $f16
  186. jirl $r0, $r1, 0x0
  187. .align 3
  188. EPILOGUE