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.

qgemv_t.S 9.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  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 8 + STACKSIZE(%rsp)
  44. #define OLD_INCX 24 + STACKSIZE(%rsp)
  45. #define OLD_Y 32 + STACKSIZE(%rsp)
  46. #define OLD_INCY 40 + STACKSIZE(%rsp)
  47. #define BUFFER 48 + STACKSIZE(%rsp)
  48. #define NLDA 56 (%rsp)
  49. #define IS 64 (%rsp)
  50. #define XP 72 (%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 A2 %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
  83. salq $BASE_SHIFT, INCX
  84. salq $BASE_SHIFT, INCY
  85. movq $0, IS
  86. test M, M
  87. jle .L79 # goto END
  88. test N, N
  89. jle .L79 # goto END
  90. movq N, %rax
  91. imulq LDA, %rax
  92. movq $P, NLDA
  93. subq %rax, NLDA
  94. salq $BASE_SHIFT, NLDA
  95. salq $BASE_SHIFT, LDA
  96. ALIGN_2
  97. .L32:
  98. movq $P, %rax
  99. movq M, MIN_M
  100. subq IS , MIN_M
  101. cmpq %rax, MIN_M
  102. cmovg %rax, MIN_M
  103. movq IS, X1
  104. salq $BASE_SHIFT, X1
  105. leaq (X,X1, 1), X1
  106. movq X1, XP
  107. cmpq $SIZE, INCX
  108. je .L34
  109. movq BUFFER, X1
  110. movq X1, XP
  111. movq MIN_M, I
  112. sarq $2, I
  113. jle .L35
  114. ALIGN_3
  115. .L36:
  116. FLD (X)
  117. addq INCX, X
  118. FST 0 * SIZE(X1)
  119. FLD (X)
  120. addq INCX, X
  121. FST 1 * SIZE(X1)
  122. FLD (X)
  123. addq INCX, X
  124. FST 2 * SIZE(X1)
  125. FLD (X)
  126. addq INCX, X
  127. FST 3 * SIZE(X1)
  128. addq $4 * SIZE, X1
  129. decq I
  130. jg .L36
  131. ALIGN_3
  132. .L35:
  133. movq MIN_M, I
  134. andq $3,I
  135. jle .L34
  136. ALIGN_2
  137. .L42:
  138. FLD (X)
  139. addq INCX, X
  140. FST (X1)
  141. addq $SIZE, X1
  142. decq I
  143. jg .L42
  144. ALIGN_3
  145. /* Main Routine */
  146. .L34:
  147. movq Y, Y1 # coffset = y
  148. movq N, J
  149. sarq $2, J
  150. jle .L47
  151. ALIGN_3
  152. .L48:
  153. movq A, A1
  154. leaq (A, LDA), A2
  155. leaq (A, LDA, 4), A
  156. fldz
  157. fldz
  158. fldz
  159. fldz
  160. movq XP, X1
  161. FLD (X1)
  162. movq MIN_M, I
  163. sarq $2,I
  164. jle .L51
  165. ALIGN_3
  166. .L80:
  167. FLD 0 * SIZE(A1) # at = *(a_offset + 0 * lda)
  168. fmul %st(1),%st # at1 *= bt1
  169. faddp %st,%st(2) # ct1 += at1
  170. FLD 0 * SIZE(A2) # at1 = *(a_offset2 + 0 * lda)
  171. fmul %st(1),%st # at1 *= bt1
  172. faddp %st,%st(3) # ct2 += at1
  173. FLD 0 * SIZE(A1, LDA, 2) # at = *(a_offset + 2 * lda)
  174. fmul %st(1),%st
  175. faddp %st,%st(4)
  176. FLD 0 * SIZE(A2, LDA, 2) # at1 = *(a_offset2 + 2 * lda)
  177. fmulp %st, %st(1)
  178. faddp %st,%st(4)
  179. FLD 1 * SIZE(X1)
  180. FLD 1 * SIZE(A1) # at = *(a_offset + 0 * lda)
  181. fmul %st(1),%st # at1 *= bt1
  182. faddp %st,%st(2) # ct1 += at1
  183. FLD 1 * SIZE(A2) # at1 = *(a_offset2 + 0 * lda)
  184. fmul %st(1),%st # at1 *= bt1
  185. faddp %st,%st(3) # ct2 += at1
  186. FLD 1 * SIZE(A1, LDA, 2) # at = *(a_offset + 2 * lda)
  187. fmul %st(1),%st
  188. faddp %st,%st(4)
  189. FLD 1 * SIZE(A2, LDA, 2) # at1 = *(a_offset2 + 2 * lda)
  190. fmulp %st, %st(1)
  191. faddp %st,%st(4)
  192. FLD 2 * SIZE(X1)
  193. FLD 2 * SIZE(A1) # at = *(a_offset + 0 * lda)
  194. fmul %st(1),%st # at1 *= bt1
  195. faddp %st,%st(2) # ct1 += at1
  196. FLD 2 * SIZE(A2) # at1 = *(a_offset2 + 0 * lda)
  197. fmul %st(1),%st # at1 *= bt1
  198. faddp %st,%st(3) # ct2 += at1
  199. FLD 2 * SIZE(A1, LDA, 2) # at = *(a_offset + 2 * lda)
  200. fmul %st(1),%st
  201. faddp %st,%st(4)
  202. FLD 2 * SIZE(A2, LDA, 2) # at1 = *(a_offset2 + 2 * lda)
  203. fmulp %st, %st(1)
  204. faddp %st,%st(4)
  205. FLD 3 * SIZE(X1)
  206. FLD 3 * SIZE(A1) # at = *(a_offset + 0 * lda)
  207. fmul %st(1),%st # at1 *= bt1
  208. faddp %st,%st(2) # ct1 += at1
  209. FLD 3 * SIZE(A2) # at1 = *(a_offset2 + 0 * lda)
  210. fmul %st(1),%st # at1 *= bt1
  211. faddp %st,%st(3) # ct2 += at1
  212. FLD 3 * SIZE(A1, LDA, 2) # at = *(a_offset + 2 * lda)
  213. fmul %st(1),%st
  214. faddp %st,%st(4)
  215. FLD 3 * SIZE(A2, LDA, 2) # at1 = *(a_offset2 + 2 * lda)
  216. fmulp %st, %st(1)
  217. addq $4 * SIZE, A1
  218. faddp %st,%st(4)
  219. addq $4 * SIZE, A2
  220. FLD 4 * SIZE(X1)
  221. addq $4 * SIZE, X1
  222. decq I
  223. jg .L80
  224. ALIGN_3
  225. .L51:
  226. movq MIN_M, I
  227. andq $3, I
  228. je .L81
  229. ALIGN_3
  230. .L52:
  231. FLD (A1) # at = *(a_offset + 0 * lda)
  232. fmul %st(1),%st # at1 *= bt1
  233. faddp %st,%st(2) # ct1 += at1
  234. FLD (A2) # at1 = *(a_offset2 + 0 * lda)
  235. fmul %st(1),%st # at1 *= bt1
  236. faddp %st,%st(3) # ct2 += at1
  237. FLD (A1, LDA, 2) # at = *(a_offset + 2 * lda)
  238. fmul %st(1),%st
  239. faddp %st,%st(4)
  240. FLD (A2, LDA, 2) # at1 = *(a_offset2 + 2 * lda)
  241. fmulp %st, %st(1)
  242. faddp %st,%st(4)
  243. FLD 1 * SIZE(X1)
  244. addq $SIZE, A1
  245. addq $SIZE, A2
  246. addq $SIZE, X1
  247. decq I
  248. jg .L52
  249. ALIGN_3
  250. .L81:
  251. ffreep %st(0)
  252. fxch %st(4)
  253. fmul %st, %st(4)
  254. fmul %st, %st(1)
  255. fmul %st, %st(2)
  256. fmul %st, %st(3)
  257. fxch %st(4)
  258. FLD (Y1)
  259. faddp %st, %st(1)
  260. FST (Y1)
  261. addq INCY, Y1
  262. FLD (Y1)
  263. faddp %st, %st(1)
  264. FST (Y1)
  265. addq INCY, Y1
  266. FLD (Y1)
  267. faddp %st, %st(1)
  268. FST (Y1)
  269. addq INCY, Y1
  270. FLD (Y1)
  271. faddp %st, %st(1)
  272. FST (Y1)
  273. addq INCY, Y1
  274. decq J
  275. jg .L48
  276. ALIGN_3
  277. .L47:
  278. movq N, J
  279. andq $3, J
  280. jle .L60
  281. ALIGN_2
  282. .L61:
  283. movq A, A1 # a_offset = a
  284. fldz # ct1 = ZERO
  285. fldz # ct1 = ZERO
  286. addq LDA, A
  287. fldz # ct1 = ZERO
  288. fldz # ct1 = ZERO
  289. movq XP, X1
  290. movq MIN_M, I
  291. sarq $3,I
  292. jle .L64
  293. ALIGN_3
  294. .L65:
  295. FLD 0 * SIZE(X1)
  296. FLD 0 * SIZE(A1)
  297. fmulp %st, %st(1)
  298. faddp %st,%st(1)
  299. FLD 1 * SIZE(X1)
  300. FLD 1 * SIZE(A1)
  301. fmulp %st, %st(1)
  302. faddp %st,%st(2)
  303. FLD 2 * SIZE(X1)
  304. FLD 2 * SIZE(A1)
  305. fmulp %st, %st(1)
  306. faddp %st,%st(3)
  307. FLD 3 * SIZE(X1)
  308. FLD 3 * SIZE(A1)
  309. fmulp %st, %st(1)
  310. faddp %st,%st(4)
  311. FLD 4 * SIZE(X1)
  312. FLD 4 * SIZE(A1)
  313. fmulp %st, %st(1)
  314. faddp %st,%st(1)
  315. FLD 5 * SIZE(X1)
  316. FLD 5 * SIZE(A1)
  317. fmulp %st, %st(1)
  318. faddp %st,%st(2)
  319. FLD 6 * SIZE(X1)
  320. FLD 6 * SIZE(A1)
  321. fmulp %st, %st(1)
  322. faddp %st,%st(3)
  323. FLD 7 * SIZE(X1)
  324. FLD 7 * SIZE(A1)
  325. fmulp %st, %st(1)
  326. faddp %st,%st(4)
  327. addq $8 * SIZE, X1
  328. addq $8 * SIZE, A1
  329. decq I
  330. jg .L65
  331. ALIGN_3
  332. .L64:
  333. movq MIN_M, I
  334. andq $7, I
  335. jle .L70
  336. ALIGN_3
  337. .L71:
  338. FLD (X1)
  339. FLD (A1)
  340. fmulp %st, %st(1)
  341. faddp %st,%st(1)
  342. addq $SIZE, X1
  343. addq $SIZE, A1
  344. decq I
  345. jg .L71
  346. ALIGN_3
  347. .L70:
  348. faddp %st, %st(1)
  349. faddp %st, %st(1)
  350. faddp %st, %st(1)
  351. fmul %st(1),%st
  352. FLD (Y1)
  353. faddp %st, %st(1)
  354. FST (Y1)
  355. addq INCY, Y1
  356. decq J
  357. jg .L61
  358. ALIGN_3
  359. .L60:
  360. addq NLDA, A
  361. addq $P, IS
  362. cmpq M, IS
  363. jl .L32
  364. ALIGN_3
  365. .L79:
  366. EMMS
  367. movq 0(%rsp), %rbx
  368. movq 8(%rsp), %rbp
  369. movq 16(%rsp), %r12
  370. movq 24(%rsp), %r13
  371. movq 32(%rsp), %r14
  372. movq 40(%rsp), %r15
  373. addq $STACKSIZE, %rsp
  374. ret
  375. EPILOGUE