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.

xgemv_t.S 7.5 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. /*********************************************************************/
  2. /* Copyright 2009, 2010 The University of Texas at Austin. */
  3. /* All rights reserved. */
  4. /* */
  5. /* Redistribution and use in source and binary forms, with or */
  6. /* without modification, are permitted provided that the following */
  7. /* conditions are met: */
  8. /* */
  9. /* 1. Redistributions of source code must retain the above */
  10. /* copyright notice, this list of conditions and the following */
  11. /* disclaimer. */
  12. /* */
  13. /* 2. Redistributions in binary form must reproduce the above */
  14. /* copyright notice, this list of conditions and the following */
  15. /* disclaimer in the documentation and/or other materials */
  16. /* provided with the distribution. */
  17. /* */
  18. /* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF TEXAS AT */
  19. /* AUSTIN ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, */
  20. /* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
  21. /* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
  22. /* DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF TEXAS AT */
  23. /* AUSTIN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
  24. /* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
  25. /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE */
  26. /* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR */
  27. /* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
  28. /* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
  29. /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
  30. /* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
  31. /* POSSIBILITY OF SUCH DAMAGE. */
  32. /* */
  33. /* The views and conclusions contained in the software and */
  34. /* documentation are those of the authors and should not be */
  35. /* interpreted as representing official policies, either expressed */
  36. /* or implied, of The University of Texas at Austin. */
  37. /*********************************************************************/
  38. #define ASSEMBLER
  39. #include "common.h"
  40. #include "l2param.h"
  41. #define STACKSIZE 80
  42. #define P 4096
  43. #define ALPHA_R 8 + STACKSIZE(%rsp)
  44. #define ALPHA_I 24 + STACKSIZE(%rsp)
  45. #define OLD_INCX 40 + STACKSIZE(%rsp)
  46. #define OLD_Y 48 + STACKSIZE(%rsp)
  47. #define OLD_INCY 56 + STACKSIZE(%rsp)
  48. #define BUFFER 64 + STACKSIZE(%rsp)
  49. #define NLDA 56 (%rsp)
  50. #define IS 64 (%rsp)
  51. #define M %rdi
  52. #define N %rsi
  53. #define A %rcx
  54. #define LDA %r8
  55. #define X %r9
  56. #define INCX %rdx
  57. #define Y %rbp
  58. #define INCY %r10
  59. #define TEMP %rax
  60. #define I %rax
  61. #define J %r11
  62. #define A1 %r12
  63. #define XP %r15
  64. #define X1 %r13
  65. #define Y1 %r14
  66. #define MIN_M %rbx
  67. PROLOGUE
  68. PROFCODE
  69. subq $STACKSIZE, %rsp
  70. movq %rbx, 0(%rsp)
  71. movq %rbp, 8(%rsp)
  72. movq %r12, 16(%rsp)
  73. movq %r13, 24(%rsp)
  74. movq %r14, 32(%rsp)
  75. movq %r15, 40(%rsp)
  76. movq OLD_INCX, INCX
  77. movq OLD_Y, Y
  78. movq OLD_INCY, INCY
  79. FLD ALPHA_I
  80. FLD ALPHA_R
  81. salq $ZBASE_SHIFT, INCX
  82. salq $ZBASE_SHIFT, INCY
  83. movq $0, IS
  84. test M, M
  85. jle .L79 # goto END
  86. test N, N
  87. jle .L79 # goto END
  88. movq N, %rax
  89. imulq LDA, %rax
  90. movq $P, NLDA
  91. subq %rax, NLDA
  92. salq $ZBASE_SHIFT, NLDA
  93. salq $ZBASE_SHIFT, LDA
  94. ALIGN_2
  95. .L32:
  96. movq $P, %rax
  97. movq M, MIN_M
  98. subq IS , MIN_M
  99. cmpq %rax, MIN_M
  100. cmovg %rax, MIN_M
  101. movq IS, X1
  102. salq $ZBASE_SHIFT, X1
  103. leaq (X,X1, 1), X1
  104. movq X1, XP
  105. cmpq $2 * SIZE, INCX
  106. je .L34
  107. movq BUFFER, X1
  108. movq X1, XP
  109. movq MIN_M, I
  110. sarq $1, I
  111. jle .L35
  112. ALIGN_3
  113. .L36:
  114. FLD 0 * SIZE(X)
  115. FLD 1 * SIZE(X)
  116. addq INCX,X # x += incx
  117. FLD 0 * SIZE(X)
  118. FLD 1 * SIZE(X)
  119. addq INCX,X # x += incx
  120. FST 3 * SIZE(X1)
  121. FST 2 * SIZE(X1)
  122. FST 1 * SIZE(X1)
  123. FST 0 * SIZE(X1)
  124. addq $4 * SIZE, X1 # xp += 4
  125. decq I
  126. jg .L36
  127. ALIGN_3
  128. .L35:
  129. movq MIN_M, I
  130. andq $1,I
  131. jle .L34
  132. FLD 0 * SIZE(X)
  133. FLD 1 * SIZE(X)
  134. addq INCX,X # x += incx
  135. FST 1 * SIZE(X1)
  136. FST 0 * SIZE(X1)
  137. ALIGN_3
  138. /* Main Routine */
  139. .L34:
  140. movq Y, Y1 # coffset = y
  141. movq N, J
  142. ALIGN_2
  143. .L61:
  144. movq A, A1 # a_offset = a
  145. fldz # ct1 = ZERO
  146. fldz # ct1 = ZERO
  147. addq LDA, A
  148. fldz # ct1 = ZERO
  149. fldz # ct1 = ZERO
  150. movq XP, X1
  151. FLD (X1) # bt1 = *(b_offset + 0)
  152. movq MIN_M, I
  153. sarq $1, I
  154. jle .L64
  155. ALIGN_3
  156. .L65:
  157. FLD 0 * SIZE(A1) # at1 = *(a_offset + 0)
  158. fmul %st(1) # at1 *= bt1
  159. faddp %st, %st(2) # ct1 += at1
  160. FLD 1 * SIZE(A1) # bt1 *= *(a_offset + 1)
  161. fmulp %st, %st(1)
  162. #ifndef CONJ
  163. faddp %st, %st(2) # ct2 += bt1
  164. #else
  165. fsubrp %st, %st(2) # ct2 -= bt1
  166. #endif
  167. FLD 1 * SIZE(X1) # bt1 = *(b_offset + 1)
  168. FLD 0 * SIZE(A1) # at1 = *(a_offset + 0)
  169. fmul %st(1) # at1 *= bt1
  170. faddp %st, %st(4) # ct3 += at1
  171. FLD 1 * SIZE(A1) # bt1 *= *(a_offset + 1)
  172. fmulp %st, %st(1)
  173. faddp %st, %st(4) # ct4 += bt1
  174. FLD 2 * SIZE(X1) # bt1 = *(b_offset + 1)
  175. FLD 2 * SIZE(A1) # at1 = *(a_offset + 0)
  176. fmul %st(1) # at1 *= bt1
  177. faddp %st, %st(2) # ct1 += at1
  178. FLD 3 * SIZE(A1) # bt1 *= *(a_offset + 1)
  179. fmulp %st, %st(1)
  180. #ifndef CONJ
  181. faddp %st, %st(2) # ct2 += bt1
  182. #else
  183. fsubrp %st, %st(2) # ct2 -= bt1
  184. #endif
  185. FLD 3 * SIZE(X1) # bt1 = *(b_offset + 1)
  186. FLD 2 * SIZE(A1) # at1 = *(a_offset + 0)
  187. fmul %st(1) # at1 *= bt1
  188. faddp %st, %st(4) # ct3 += at1
  189. FLD 3 * SIZE(A1) # bt1 *= *(a_offset + 1)
  190. fmulp %st, %st(1)
  191. faddp %st, %st(4) # ct4 += bt1
  192. FLD 4 * SIZE(X1) # bt1 = *(b_offset + 1)
  193. addq $4 * SIZE, X1
  194. addq $4 * SIZE, A1
  195. decq I
  196. jg .L65
  197. ALIGN_3
  198. .L64:
  199. movq MIN_M, I
  200. andq $1, I
  201. jle .L70
  202. ALIGN_3
  203. .L71:
  204. FLD 0 * SIZE(A1) # at1 = *(a_offset + 0)
  205. fmul %st(1) # at1 *= bt1
  206. faddp %st, %st(2) # ct1 += at1
  207. FLD 1 * SIZE(A1) # bt1 *= *(a_offset + 1)
  208. fmulp %st, %st(1)
  209. #ifndef CONJ
  210. faddp %st, %st(2) # ct2 += bt1
  211. #else
  212. fsubrp %st, %st(2) # ct2 -= bt1
  213. #endif
  214. FLD 1 * SIZE(X1) # bt1 = *(b_offset + 1)
  215. FLD 0 * SIZE(A1) # at1 = *(a_offset + 0)
  216. fmul %st(1) # at1 *= bt1
  217. faddp %st, %st(4) # ct3 += at1
  218. FLD 1 * SIZE(A1) # bt1 *= *(a_offset + 1)
  219. fmulp %st, %st(1)
  220. faddp %st, %st(4) # ct4 += bt1
  221. fldz
  222. ALIGN_3
  223. .L70:
  224. ffreep %st(0)
  225. #ifndef XCONJ
  226. #ifndef CONJ
  227. fsubp %st, %st(3)
  228. faddp %st, %st(1)
  229. #else
  230. faddp %st, %st(3)
  231. faddp %st, %st(1)
  232. #endif
  233. #else
  234. #ifndef CONJ
  235. faddp %st, %st(3)
  236. fsubp %st, %st(1)
  237. #else
  238. fsubp %st, %st(3)
  239. fsubp %st, %st(1)
  240. #endif
  241. #endif
  242. fld %st(0) # ct4 = ct2
  243. fmul %st(4)
  244. fld %st(2)
  245. fmul %st(4)
  246. fsubp %st, %st(1)
  247. FLD 0 * SIZE(Y1)
  248. faddp %st, %st(1)
  249. FST 0 * SIZE(Y1)
  250. fmul %st(2)
  251. fxch %st(1)
  252. fmul %st(3)
  253. faddp %st, %st(1)
  254. FLD 1 * SIZE(Y1)
  255. faddp %st, %st(1)
  256. FST 1 * SIZE(Y1)
  257. addq INCY, Y1
  258. decq J
  259. jg .L61
  260. ALIGN_3
  261. .L60:
  262. addq NLDA, A
  263. addq $P, IS
  264. cmpq M, IS
  265. jl .L32
  266. ALIGN_3
  267. .L79:
  268. ffreep %st
  269. ffreep %st
  270. movq 0(%rsp), %rbx
  271. movq 8(%rsp), %rbp
  272. movq 16(%rsp), %r12
  273. movq 24(%rsp), %r13
  274. movq 32(%rsp), %r14
  275. movq 40(%rsp), %r15
  276. addq $STACKSIZE, %rsp
  277. ret
  278. EPILOGUE