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.

amax_lasx.S 5.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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 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. #define ASSEMBLER
  28. #include "common.h"
  29. #define N $r4
  30. #define X $r5
  31. #define INCX $r6
  32. #define I $r12
  33. #define TEMP $r13
  34. #define VM0 $xr0
  35. #define VM1 $xr1
  36. #define VM2 $xr2
  37. #define VX0 $xr3
  38. #define VX1 $xr4
  39. #define VX2 $xr5
  40. #define VX3 $xr6
  41. #define t1 $r14
  42. #define t2 $r15
  43. #define t3 $r16
  44. #define t4 $r17
  45. PROLOGUE
  46. #ifdef F_INTERFACE
  47. LDINT N, 0(N)
  48. LDINT INCX, 0(INCX)
  49. #endif
  50. xvxor.v VM0, VM0, VM0
  51. bge $r0, N, .L999
  52. bge $r0, INCX, .L999
  53. li.d TEMP, 1
  54. slli.d TEMP, TEMP, BASE_SHIFT
  55. slli.d INCX, INCX, BASE_SHIFT
  56. bne INCX, TEMP, .L20
  57. srai.d I, N, 4
  58. bge $r0, I, .L11
  59. .align 3
  60. .L10:
  61. #ifdef DOUBLE
  62. xvld VX0, X, 0
  63. xvld VX1, X, 32
  64. xvld VX2, X, 64
  65. xvld VX3, X, 96
  66. addi.d I, I, -1
  67. addi.d X, X, 128
  68. XVFMAXA VM1, VX0, VX1
  69. XVFMAXA VM2, VX2, VX3
  70. XVFMAXA VM0, VM0, VM1
  71. XVFMAXA VM0, VM0, VM2
  72. #else
  73. xvld VX0, X, 0
  74. xvld VX1, X, 32
  75. addi.d I, I, -1
  76. addi.d X, X, 64
  77. XVFMAXA VM1, VX0, VX1
  78. XVFMAXA VM0, VM0, VM1
  79. #endif
  80. blt $r0, I, .L10
  81. #ifdef DOUBLE
  82. xvrepl128vei.d VX0, VM0, 0
  83. xvrepl128vei.d VX1, VM0, 1
  84. XVFMAXA VM0, VX0, VX1
  85. #else
  86. xvrepl128vei.w VX0, VM0, 0
  87. xvrepl128vei.w VX1, VM0, 1
  88. xvrepl128vei.w VX2, VM0, 2
  89. xvrepl128vei.w VX3, VM0, 3
  90. XVFMAXA VM1, VX0, VX1
  91. XVFMAXA VM2, VX2, VX3
  92. XVFMAXA VM0, VM1, VM2
  93. #endif
  94. xvpermi.q VM1, VM0, 0x1
  95. XVFMAXA VM0, VM0, VM1
  96. .align 3
  97. .L11:
  98. andi I, N, 0x0f
  99. bge $r0, I, .L13
  100. .align 3
  101. .L12: /* 0 < N < 16 */
  102. LD $f1, X, 0
  103. addi.d I, I, -1
  104. addi.d X, X, SIZE
  105. FMAXA $f0, $f0, $f1
  106. bnez I, .L12
  107. .align 3
  108. .L13:
  109. FABS $f0, $f0
  110. jirl $r0, $r1, 0x0
  111. .align 3
  112. .L20: // INCX!=1
  113. srai.d I, N, 3
  114. bge $r0, I, .L23
  115. .align 3
  116. .L21:
  117. #ifdef DOUBLE
  118. ld.d t1, X, 0
  119. add.d X, X, INCX
  120. ld.d t2, X, 0
  121. add.d X, X, INCX
  122. ld.d t3, X, 0
  123. add.d X, X, INCX
  124. ld.d t4, X, 0
  125. add.d X, X, INCX
  126. xvinsgr2vr.d VX0, t1, 0
  127. xvinsgr2vr.d VX0, t2, 1
  128. xvinsgr2vr.d VX0, t3, 2
  129. xvinsgr2vr.d VX0, t4, 3
  130. ld.d t1, X, 0
  131. add.d X, X, INCX
  132. ld.d t2, X, 0
  133. add.d X, X, INCX
  134. ld.d t3, X, 0 * SIZE
  135. add.d X, X, INCX
  136. ld.d t4, X, 0 * SIZE
  137. add.d X, X, INCX
  138. xvinsgr2vr.d VX1, t1, 0
  139. xvinsgr2vr.d VX1, t2, 1
  140. xvinsgr2vr.d VX1, t3, 2
  141. xvinsgr2vr.d VX1, t4, 3
  142. xvfmaxa.d VM1, VX0, VX1
  143. xvfmaxa.d VM0, VM0, VM1
  144. #else
  145. ld.w t1, X, 0
  146. add.d X, X, INCX
  147. ld.w t2, X, 0
  148. add.d X, X, INCX
  149. ld.w t3, X, 0
  150. add.d X, X, INCX
  151. ld.w t4, X, 0
  152. add.d X, X, INCX
  153. xvinsgr2vr.w VM1, t1, 0
  154. xvinsgr2vr.w VM1, t2, 1
  155. xvinsgr2vr.w VM1, t3, 2
  156. xvinsgr2vr.w VM1, t4, 3
  157. ld.w t1, X, 0
  158. add.d X, X, INCX
  159. ld.w t2, X, 0
  160. add.d X, X, INCX
  161. ld.w t3, X, 0
  162. add.d X, X, INCX
  163. ld.w t4, X, 0
  164. add.d X, X, INCX
  165. xvinsgr2vr.w VM1, t1, 4
  166. xvinsgr2vr.w VM1, t2, 5
  167. xvinsgr2vr.w VM1, t3, 6
  168. xvinsgr2vr.w VM1, t4, 7
  169. xvfmaxa.s VM0, VM0, VM1
  170. #endif
  171. addi.d I, I, -1
  172. blt $r0, I, .L21
  173. .align 3
  174. .L22:
  175. #ifdef DOUBLE
  176. xvrepl128vei.d VX0, VM0, 0
  177. xvrepl128vei.d VX1, VM0, 1
  178. XVFMAXA VM0, VX0, VX1
  179. #else
  180. xvrepl128vei.w VX0, VM0, 0
  181. xvrepl128vei.w VX1, VM0, 1
  182. xvrepl128vei.w VX2, VM0, 2
  183. xvrepl128vei.w VX3, VM0, 3
  184. XVFMAXA VM1, VX0, VX1
  185. XVFMAXA VM2, VX2, VX3
  186. XVFMAXA VM0, VM1, VM2
  187. #endif
  188. xvpermi.q VM1, VM0, 1
  189. XVFMAXA VM0, VM0, VM1
  190. .align 3
  191. .L23: //INCX!=1 and N<8
  192. andi I, N, 7
  193. bge $r0, I, .L999
  194. .align 3
  195. .L24: /* 0 < N < 8 */
  196. LD $f1, X, 0
  197. addi.d I, I, -1
  198. add.d X, X, INCX
  199. FMAXA $f0, $f0, $f1
  200. bnez I, .L24
  201. .align 3
  202. .L999:
  203. FABS $f0, $f0
  204. jirl $r0, $r1, 0x0
  205. EPILOGUE