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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  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. #ifdef WINDOWS_ABI
  70. emms
  71. #endif
  72. subq $STACKSIZE, %rsp
  73. movq %rbx, 0(%rsp)
  74. movq %rbp, 8(%rsp)
  75. movq %r12, 16(%rsp)
  76. movq %r13, 24(%rsp)
  77. movq %r14, 32(%rsp)
  78. movq %r15, 40(%rsp)
  79. movq OLD_INCX, INCX
  80. movq OLD_Y, Y
  81. movq OLD_INCY, INCY
  82. FLD ALPHA_I
  83. FLD ALPHA_R
  84. salq $ZBASE_SHIFT, INCX
  85. salq $ZBASE_SHIFT, INCY
  86. movq $0, IS
  87. test M, M
  88. jle .L79 # goto END
  89. test N, N
  90. jle .L79 # goto END
  91. movq N, %rax
  92. imulq LDA, %rax
  93. movq $P, NLDA
  94. subq %rax, NLDA
  95. salq $ZBASE_SHIFT, NLDA
  96. salq $ZBASE_SHIFT, LDA
  97. ALIGN_2
  98. .L32:
  99. movq $P, %rax
  100. movq M, MIN_M
  101. subq IS , MIN_M
  102. cmpq %rax, MIN_M
  103. cmovg %rax, MIN_M
  104. movq IS, X1
  105. salq $ZBASE_SHIFT, X1
  106. leaq (X,X1, 1), X1
  107. movq X1, XP
  108. cmpq $2 * SIZE, INCX
  109. je .L34
  110. movq BUFFER, X1
  111. movq X1, XP
  112. movq MIN_M, I
  113. sarq $1, I
  114. jle .L35
  115. ALIGN_3
  116. .L36:
  117. FLD 0 * SIZE(X)
  118. FLD 1 * SIZE(X)
  119. addq INCX,X # x += incx
  120. FLD 0 * SIZE(X)
  121. FLD 1 * SIZE(X)
  122. addq INCX,X # x += incx
  123. FST 3 * SIZE(X1)
  124. FST 2 * SIZE(X1)
  125. FST 1 * SIZE(X1)
  126. FST 0 * SIZE(X1)
  127. addq $4 * SIZE, X1 # xp += 4
  128. decq I
  129. jg .L36
  130. ALIGN_3
  131. .L35:
  132. movq MIN_M, I
  133. andq $1,I
  134. jle .L34
  135. FLD 0 * SIZE(X)
  136. FLD 1 * SIZE(X)
  137. addq INCX,X # x += incx
  138. FST 1 * SIZE(X1)
  139. FST 0 * SIZE(X1)
  140. ALIGN_3
  141. /* Main Routine */
  142. .L34:
  143. movq Y, Y1 # coffset = y
  144. movq N, J
  145. ALIGN_2
  146. .L61:
  147. movq A, A1 # a_offset = a
  148. fldz # ct1 = ZERO
  149. fldz # ct1 = ZERO
  150. addq LDA, A
  151. fldz # ct1 = ZERO
  152. fldz # ct1 = ZERO
  153. movq XP, X1
  154. FLD (X1) # bt1 = *(b_offset + 0)
  155. movq MIN_M, I
  156. sarq $1, I
  157. jle .L64
  158. ALIGN_3
  159. .L65:
  160. FLD 0 * SIZE(A1) # at1 = *(a_offset + 0)
  161. fmul %st(1) # at1 *= bt1
  162. faddp %st, %st(2) # ct1 += at1
  163. FLD 1 * SIZE(A1) # bt1 *= *(a_offset + 1)
  164. fmulp %st, %st(1)
  165. #ifndef CONJ
  166. faddp %st, %st(2) # ct2 += bt1
  167. #else
  168. fsubrp %st, %st(2) # ct2 -= bt1
  169. #endif
  170. FLD 1 * SIZE(X1) # bt1 = *(b_offset + 1)
  171. FLD 0 * SIZE(A1) # at1 = *(a_offset + 0)
  172. fmul %st(1) # at1 *= bt1
  173. faddp %st, %st(4) # ct3 += at1
  174. FLD 1 * SIZE(A1) # bt1 *= *(a_offset + 1)
  175. fmulp %st, %st(1)
  176. faddp %st, %st(4) # ct4 += bt1
  177. FLD 2 * SIZE(X1) # bt1 = *(b_offset + 1)
  178. FLD 2 * SIZE(A1) # at1 = *(a_offset + 0)
  179. fmul %st(1) # at1 *= bt1
  180. faddp %st, %st(2) # ct1 += at1
  181. FLD 3 * SIZE(A1) # bt1 *= *(a_offset + 1)
  182. fmulp %st, %st(1)
  183. #ifndef CONJ
  184. faddp %st, %st(2) # ct2 += bt1
  185. #else
  186. fsubrp %st, %st(2) # ct2 -= bt1
  187. #endif
  188. FLD 3 * SIZE(X1) # bt1 = *(b_offset + 1)
  189. FLD 2 * SIZE(A1) # at1 = *(a_offset + 0)
  190. fmul %st(1) # at1 *= bt1
  191. faddp %st, %st(4) # ct3 += at1
  192. FLD 3 * SIZE(A1) # bt1 *= *(a_offset + 1)
  193. fmulp %st, %st(1)
  194. faddp %st, %st(4) # ct4 += bt1
  195. FLD 4 * SIZE(X1) # bt1 = *(b_offset + 1)
  196. addq $4 * SIZE, X1
  197. addq $4 * SIZE, A1
  198. decq I
  199. jg .L65
  200. ALIGN_3
  201. .L64:
  202. movq MIN_M, I
  203. andq $1, I
  204. jle .L70
  205. ALIGN_3
  206. .L71:
  207. FLD 0 * SIZE(A1) # at1 = *(a_offset + 0)
  208. fmul %st(1) # at1 *= bt1
  209. faddp %st, %st(2) # ct1 += at1
  210. FLD 1 * SIZE(A1) # bt1 *= *(a_offset + 1)
  211. fmulp %st, %st(1)
  212. #ifndef CONJ
  213. faddp %st, %st(2) # ct2 += bt1
  214. #else
  215. fsubrp %st, %st(2) # ct2 -= bt1
  216. #endif
  217. FLD 1 * SIZE(X1) # bt1 = *(b_offset + 1)
  218. FLD 0 * SIZE(A1) # at1 = *(a_offset + 0)
  219. fmul %st(1) # at1 *= bt1
  220. faddp %st, %st(4) # ct3 += at1
  221. FLD 1 * SIZE(A1) # bt1 *= *(a_offset + 1)
  222. fmulp %st, %st(1)
  223. faddp %st, %st(4) # ct4 += bt1
  224. fldz
  225. ALIGN_3
  226. .L70:
  227. ffreep %st(0)
  228. #ifndef XCONJ
  229. #ifndef CONJ
  230. fsubp %st, %st(3)
  231. faddp %st, %st(1)
  232. #else
  233. faddp %st, %st(3)
  234. faddp %st, %st(1)
  235. #endif
  236. #else
  237. #ifndef CONJ
  238. faddp %st, %st(3)
  239. fsubp %st, %st(1)
  240. #else
  241. fsubp %st, %st(3)
  242. fsubp %st, %st(1)
  243. #endif
  244. #endif
  245. fld %st(0) # ct4 = ct2
  246. fmul %st(4)
  247. fld %st(2)
  248. fmul %st(4)
  249. fsubp %st, %st(1)
  250. FLD 0 * SIZE(Y1)
  251. faddp %st, %st(1)
  252. FST 0 * SIZE(Y1)
  253. fmul %st(2)
  254. fxch %st(1)
  255. fmul %st(3)
  256. faddp %st, %st(1)
  257. FLD 1 * SIZE(Y1)
  258. faddp %st, %st(1)
  259. FST 1 * SIZE(Y1)
  260. addq INCY, Y1
  261. decq J
  262. jg .L61
  263. ALIGN_3
  264. .L60:
  265. addq NLDA, A
  266. addq $P, IS
  267. cmpq M, IS
  268. jl .L32
  269. ALIGN_3
  270. .L79:
  271. ffreep %st
  272. ffreep %st
  273. movq 0(%rsp), %rbx
  274. movq 8(%rsp), %rbp
  275. movq 16(%rsp), %r12
  276. movq 24(%rsp), %r13
  277. movq 32(%rsp), %r14
  278. movq 40(%rsp), %r15
  279. addq $STACKSIZE, %rsp
  280. ret
  281. EPILOGUE