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.

snrm2.S 6.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. /***************************************************************************
  2. Copyright (c) 2021, 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 $r17
  33. #define TEMP $r18
  34. #define a1 $f12
  35. #define a2 $f13
  36. #define a3 $f14
  37. #define a4 $f15
  38. #define a5 $f16
  39. #define a6 $f17
  40. #define a7 $f0
  41. #define a8 $f1
  42. #define s1 $f22
  43. #define s2 $f8
  44. #define t1 $f23
  45. #define t2 $f9
  46. #define t3 $f10
  47. #define t4 $f11
  48. PROLOGUE
  49. #ifdef F_INTERFACE
  50. LDINT N, 0(N)
  51. LDINT INCX, 0(INCX)
  52. #endif
  53. movgr2fr.d s1, $r0
  54. li.d TEMP, SIZE
  55. fmov.d s2, s1
  56. bge $r0, N, .L999
  57. slli.d INCX, INCX, BASE_SHIFT
  58. bge $r0, INCX, .L999
  59. srai.d I, N, 3
  60. bne INCX, TEMP, .L20
  61. bge $r0, I, .L15
  62. LD a1, X, 0 * SIZE
  63. LD a2, X, 1 * SIZE
  64. LD a3, X, 2 * SIZE
  65. LD a4, X, 3 * SIZE
  66. LD a5, X, 4 * SIZE
  67. addi.d I, I, -1
  68. fcvt.d.s t1, a1
  69. LD a6, X, 5 * SIZE
  70. fcvt.d.s t2, a2
  71. LD a7, X, 6 * SIZE
  72. fcvt.d.s t3, a3
  73. LD a8, X, 7 * SIZE
  74. fcvt.d.s t4, a4
  75. bge $r0, I, .L13
  76. .align 3
  77. .L12:
  78. fmadd.d s1, t1, t1, s1
  79. LD a1, X, 8 * SIZE
  80. fcvt.d.s t1, a5
  81. NOP
  82. fmadd.d s2, t2, t2, s2
  83. LD a2, X, 9 * SIZE
  84. fcvt.d.s t2, a6
  85. NOP
  86. fmadd.d s1, t3, t3, s1
  87. LD a3, X, 10 * SIZE
  88. fcvt.d.s t3, a7
  89. NOP
  90. fmadd.d s2, t4, t4, s2
  91. LD a4, X, 11 * SIZE
  92. fcvt.d.s t4, a8
  93. NOP
  94. fmadd.d s1, t1, t1, s1
  95. LD a5, X, 12 * SIZE
  96. fcvt.d.s t1, a1
  97. NOP
  98. fmadd.d s2, t2, t2, s2
  99. LD a6, X, 13 * SIZE
  100. fcvt.d.s t2, a2
  101. addi.d I, I, -1
  102. fmadd.d s1, t3, t3, s1
  103. LD a7, X, 14 * SIZE
  104. fcvt.d.s t3, a3
  105. addi.d X, X, 8 * SIZE
  106. fmadd.d s2, t4, t4, s2
  107. LD a8, X, 7 * SIZE
  108. fcvt.d.s t4, a4
  109. blt $r0, I, .L12
  110. .align 3
  111. .L13:
  112. fmadd.d s1, t1, t1, s1
  113. fcvt.d.s t1, a5
  114. fmadd.d s2, t2, t2, s2
  115. fcvt.d.s t2, a6
  116. fmadd.d s1, t3, t3, s1
  117. fcvt.d.s t3, a7
  118. fmadd.d s2, t4, t4, s2
  119. fcvt.d.s t4, a8
  120. fmadd.d s1, t1, t1, s1
  121. fmadd.d s2, t2, t2, s2
  122. fmadd.d s1, t3, t3, s1
  123. fmadd.d s2, t4, t4, s2
  124. addi.d X, X, 8 * SIZE
  125. .align 3
  126. .L15:
  127. andi I, N, 7
  128. bge $r0, I, .L999
  129. .align 3
  130. .L16:
  131. LD a1, X, 0 * SIZE
  132. addi.d I, I, -1
  133. fcvt.d.s t1, a1
  134. fmadd.d s1, t1, t1, s1
  135. addi.d X, X, SIZE
  136. blt $r0, I, .L16
  137. b .L999
  138. .align 3
  139. .L20:
  140. bge $r0, I, .L25
  141. LD a1, X, 0 * SIZE
  142. add.d X, X, INCX
  143. LD a2, X, 0 * SIZE
  144. add.d X, X, INCX
  145. LD a3, X, 0 * SIZE
  146. add.d X, X, INCX
  147. LD a4, X, 0 * SIZE
  148. add.d X, X, INCX
  149. LD a5, X, 0 * SIZE
  150. add.d X, X, INCX
  151. LD a6, X, 0 * SIZE
  152. add.d X, X, INCX
  153. LD a7, X, 0 * SIZE
  154. add.d X, X, INCX
  155. LD a8, X, 0 * SIZE
  156. addi.d I, I, -1
  157. fcvt.d.s t1, a1
  158. fcvt.d.s t2, a2
  159. fcvt.d.s t3, a3
  160. fcvt.d.s t4, a4
  161. add.d X, X, INCX
  162. bge $r0, I, .L24
  163. .align 3
  164. .L23:
  165. fmadd.d s1, t1, t1, s1
  166. LD a1, X, 0 * SIZE
  167. fcvt.d.s t1, a5
  168. add.d X, X, INCX
  169. fmadd.d s2, t2, t2, s2
  170. LD a2, X, 0 * SIZE
  171. fcvt.d.s t2, a6
  172. add.d X, X, INCX
  173. fmadd.d s1, t3, t3, s1
  174. LD a3, X, 0 * SIZE
  175. fcvt.d.s t3, a7
  176. add.d X, X, INCX
  177. fmadd.d s2, t4, t4, s2
  178. LD a4, X, 0 * SIZE
  179. fcvt.d.s t4, a8
  180. add.d X, X, INCX
  181. fmadd.d s1, t1, t1, s1
  182. LD a5, X, 0 * SIZE
  183. fcvt.d.s t1, a1
  184. add.d X, X, INCX
  185. fmadd.d s2, t2, t2, s2
  186. LD a6, X, 0 * SIZE
  187. fcvt.d.s t2, a2
  188. add.d X, X, INCX
  189. fmadd.d s1, t3, t3, s1
  190. LD a7, X, 0 * SIZE
  191. fcvt.d.s t3, a3
  192. add.d X, X, INCX
  193. fmadd.d s2, t4, t4, s2
  194. LD a8, X, 0 * SIZE
  195. fcvt.d.s t4, a4
  196. addi.d I, I, -1
  197. add.d X, X, INCX
  198. blt $r0, I, .L23
  199. .align 3
  200. .L24:
  201. fmadd.d s1, t1, t1, s1
  202. fcvt.d.s t1, a5
  203. fmadd.d s2, t2, t2, s2
  204. fcvt.d.s t2, a6
  205. fmadd.d s1, t3, t3, s1
  206. fcvt.d.s t3, a7
  207. fmadd.d s2, t4, t4, s2
  208. fcvt.d.s t4, a8
  209. fmadd.d s1, t1, t1, s1
  210. fmadd.d s2, t2, t2, s2
  211. fmadd.d s1, t3, t3, s1
  212. fmadd.d s2, t4, t4, s2
  213. .align 3
  214. .L25:
  215. andi I, N, 7
  216. bge $r0, I, .L999
  217. .align 3
  218. .L26:
  219. LD a1, X, 0 * SIZE
  220. addi.d I, I, -1
  221. fcvt.d.s t1, a1
  222. add.d X, X, INCX
  223. fmadd.d s1, t1, t1, s1
  224. blt $r0, I, .L26
  225. .align 3
  226. .L999:
  227. fadd.d s1, s1, s2
  228. fsqrt.d s1, s1
  229. move $r4, $r17
  230. fcvt.s.d $f0, s1
  231. jirl $r0, $r1, 0x0
  232. EPILOGUE