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.

max_lasx.S 5.4 kB

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