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_n.S 8.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  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 P 32
  42. #define STACKSIZE 80
  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 PLDA_M 56 (%rsp)
  49. #define IS 64 (%rsp)
  50. #define M %rdi
  51. #define N %rsi
  52. #define A %rcx
  53. #define LDA %r8
  54. #define X %r9
  55. #define INCX %rdx
  56. #define Y %rbp
  57. #define INCY %r10
  58. #define TEMP %rax
  59. #define I %rax
  60. #define J %r11
  61. #define A1 %r12
  62. #define X1 %r13
  63. #define Y1 %r14
  64. #define XP %r15
  65. /* #define BUFFER %r15 */
  66. #define MIN_N %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 LDA, %rax
  91. imulq $P, %rax # P * lda
  92. subq M ,%rax # P * lda - m
  93. salq $BASE_SHIFT, %rax
  94. movq %rax, PLDA_M
  95. salq $BASE_SHIFT, LDA
  96. ALIGN_2
  97. .L32:
  98. movq $P, %rax
  99. movq N, MIN_N
  100. subq IS, MIN_N
  101. cmpq %rax, MIN_N
  102. cmovg %rax, MIN_N
  103. movq IS, XP
  104. salq $BASE_SHIFT, XP
  105. leaq (X,XP, 1), XP
  106. cmpq $SIZE, INCX
  107. je .L34 # if incx == 1 goto L34
  108. movq BUFFER, XP
  109. movq XP, X1
  110. movq MIN_N, I
  111. sarq $2,I
  112. jle .L35
  113. ALIGN_2
  114. .L36:
  115. FLD (X)
  116. addq INCX,X
  117. FLD (X)
  118. addq INCX,X
  119. FLD (X)
  120. addq INCX,X
  121. FLD (X)
  122. addq INCX,X
  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
  128. decq I
  129. jg .L36
  130. ALIGN_3
  131. .L35:
  132. movq MIN_N, I
  133. andq $3, I
  134. jle .L34
  135. ALIGN_2
  136. .L42:
  137. FLD (X)
  138. addq INCX, X
  139. FST (X1)
  140. addq $SIZE, X1
  141. decq I
  142. jg .L42
  143. ALIGN_3
  144. /* Main Routine */
  145. .L34:
  146. movq Y, Y1
  147. movq M, J
  148. sarq $2, J
  149. jle .L47
  150. ALIGN_2
  151. .L48:
  152. movq A, A1 # a_offset = a
  153. fldz
  154. addq $4 * SIZE, A # a += 4
  155. fldz
  156. movq XP, X1 # b_offset = xp
  157. fldz
  158. movq MIN_N, I # i = min_n
  159. fldz
  160. FLD (X1) # bt1 = b_offset
  161. sarq $1, I
  162. jle .L51
  163. ALIGN_2
  164. .L80:
  165. FLD 0 * SIZE(A1) # at1 = *(a_offset + 0)
  166. fmul %st(1), %st # at1 *= bt1
  167. faddp %st, %st(2) # ct1 += at1
  168. FLD 1 * SIZE(A1) # at1 = *(a_offset + 1)
  169. fmul %st(1), %st # at1 *= bt1
  170. faddp %st, %st(3) # ct2 += at1
  171. FLD 2 * SIZE(A1) # at1 = *(a_offset + 2)
  172. fmul %st(1), %st # at1 *= bt1
  173. faddp %st, %st(4) # ct3 += at1
  174. FLD 3 * SIZE(A1) # bt1 *= *(a_offset + 3)
  175. fmulp %st, %st(1)
  176. faddp %st, %st(4) # ct4 += at1
  177. FLD 1 * SIZE(X1) # bt1 = b_offset
  178. addq LDA, A1 # a_offset += lda
  179. FLD 0 * SIZE(A1) # at1 = *(a_offset + 0)
  180. fmul %st(1), %st # at1 *= bt1
  181. faddp %st, %st(2) # ct1 += at1
  182. FLD 1 * SIZE(A1) # at1 = *(a_offset + 1)
  183. fmul %st(1), %st # at1 *= bt1
  184. faddp %st, %st(3) # ct2 += at1
  185. FLD 2 * SIZE(A1) # at1 = *(a_offset + 2)
  186. fmul %st(1), %st # at1 *= bt1
  187. faddp %st, %st(4) # ct3 += at1
  188. FLD 3 * SIZE(A1) # bt1 *= *(a_offset + 3)
  189. fmulp %st, %st(1)
  190. addq LDA, A1
  191. faddp %st, %st(4) # ct4 += at1
  192. FLD 2 * SIZE(X1) # bt1 = b_offset
  193. addq $2 * SIZE, X1 # b_offset += 2
  194. decq I
  195. jg .L80
  196. .L51:
  197. movq MIN_N, I
  198. andq $1, I
  199. je .L57
  200. FLD 0 * SIZE(A1) # at1 = *(a_offset + 0)
  201. fmul %st(1), %st # at1 *= bt1
  202. faddp %st, %st(2) # ct1 += at1
  203. FLD 1 * SIZE(A1) # at1 = *(a_offset + 1)
  204. fmul %st(1), %st # at1 *= bt1
  205. faddp %st, %st(3) # ct2 += at1
  206. FLD 2 * SIZE(A1) # at1 = *(a_offset + 2)
  207. fmul %st(1), %st # at1 *= bt1
  208. faddp %st, %st(4) # ct3 += at1
  209. FLD 3 * SIZE(A1) # bt1 *= *(a_offset + 3)
  210. fmulp %st, %st(1)
  211. faddp %st, %st(4) # ct4 += at1
  212. fldz
  213. ALIGN_2
  214. .L57:
  215. ffreep %st(0)
  216. fxch %st(4)
  217. fmul %st, %st(4)
  218. fmul %st, %st(1)
  219. fmul %st, %st(2)
  220. fmul %st, %st(3)
  221. fxch %st(4)
  222. FLD (Y1)
  223. faddp %st, %st(1)
  224. FST (Y1)
  225. addq INCY, Y1
  226. FLD (Y1)
  227. faddp %st, %st(1)
  228. FST (Y1)
  229. addq INCY, Y1
  230. FLD (Y1)
  231. faddp %st, %st(1)
  232. FST (Y1)
  233. addq INCY, Y1
  234. FLD (Y1)
  235. faddp %st, %st(1)
  236. FST (Y1)
  237. addq INCY, Y1
  238. decq J # j --
  239. jg .L48
  240. ALIGN_3
  241. .L47:
  242. movq M, J
  243. andq $3, J # j = (m & 3)
  244. jle .L60
  245. ALIGN_2
  246. .L61:
  247. movq A, A1 # a_offset = a
  248. fldz
  249. addq $SIZE, A # a++
  250. fldz
  251. movq XP, X1
  252. fldz
  253. fldz
  254. movq MIN_N, I
  255. sarq $3, I
  256. jle .L64
  257. ALIGN_2
  258. .L65:
  259. FLD 0 * SIZE(X1)
  260. FLD (A1)
  261. fmulp %st, %st(1)
  262. faddp %st, %st(1)
  263. addq LDA, A1
  264. FLD 1 * SIZE(X1)
  265. FLD (A1)
  266. fmulp %st, %st(1)
  267. faddp %st, %st(2)
  268. addq LDA ,A1
  269. FLD 2 * SIZE(X1)
  270. FLD (A1)
  271. fmulp %st, %st(1)
  272. faddp %st, %st(3)
  273. addq LDA, A1
  274. FLD 3 * SIZE(X1)
  275. FLD (A1)
  276. fmulp %st, %st(1)
  277. faddp %st, %st(4)
  278. addq LDA, A1
  279. FLD 4 * SIZE(X1)
  280. FLD (A1)
  281. fmulp %st, %st(1)
  282. faddp %st,%st(1)
  283. addq LDA, A1
  284. FLD 5 * SIZE(X1)
  285. FLD (A1)
  286. fmulp %st, %st(1)
  287. faddp %st, %st(2)
  288. addq LDA, A1
  289. FLD 6 * SIZE(X1)
  290. FLD (A1)
  291. fmulp %st, %st(1)
  292. faddp %st,%st(3)
  293. addq LDA, A1
  294. FLD 7 * SIZE(X1)
  295. FLD (A1)
  296. fmulp %st, %st(1)
  297. faddp %st,%st(4)
  298. addq LDA, A1
  299. addq $8 * SIZE, X1
  300. decq I
  301. jg .L65
  302. .L64:
  303. movq MIN_N,I
  304. andq $7, I
  305. jle .L70
  306. ALIGN_2
  307. .L71:
  308. FLD (X1)
  309. addq $SIZE, X1
  310. FLD (A1)
  311. fmulp %st, %st(1)
  312. addq LDA, A1 # a_offset += lda
  313. faddp %st, %st(1)
  314. decq I
  315. jg .L71
  316. ALIGN_2
  317. .L70:
  318. faddp %st, %st(1)
  319. faddp %st, %st(1)
  320. faddp %st, %st(1)
  321. fmul %st(1), %st
  322. FLD (Y1)
  323. faddp %st, %st(1)
  324. FST (Y1)
  325. addq INCY, Y1
  326. decq J
  327. jg .L61
  328. .L60:
  329. addq PLDA_M, A
  330. addq $P, IS
  331. cmpq N, IS
  332. jl .L32
  333. .L79:
  334. EMMS
  335. movq 0(%rsp), %rbx
  336. movq 8(%rsp), %rbp
  337. movq 16(%rsp), %r12
  338. movq 24(%rsp), %r13
  339. movq 32(%rsp), %r14
  340. movq 40(%rsp), %r15
  341. addq $STACKSIZE, %rsp
  342. ret
  343. EPILOGUE