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_n.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 P 32
  42. #define STACKSIZE 80
  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 PLDA_M 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 X1 %r13
  64. #define Y1 %r14
  65. #define XP %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_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
  89. test N, N
  90. jle .L79
  91. movq LDA, %rax
  92. imulq $P, %rax # P * lda
  93. subq M ,%rax # P * lda - m
  94. salq $ZBASE_SHIFT, %rax
  95. movq %rax, PLDA_M
  96. salq $ZBASE_SHIFT, LDA
  97. ALIGN_2
  98. .L32:
  99. movq $P, %rax
  100. movq N, MIN_N
  101. subq IS, MIN_N
  102. cmpq %rax, MIN_N
  103. cmovg %rax, MIN_N
  104. movq IS, XP
  105. salq $ZBASE_SHIFT, XP
  106. leaq (X,XP, 1), XP
  107. cmpq $2 * SIZE, INCX
  108. je .L34
  109. movq BUFFER, XP
  110. movq XP, X1
  111. movq MIN_N, I
  112. sarq $1, I
  113. jle .L35
  114. ALIGN_2
  115. .L36:
  116. FLD 0 * SIZE(X)
  117. FLD 1 * SIZE(X)
  118. addq INCX,X # x += incx
  119. FLD 0 * SIZE(X)
  120. FLD 1 * SIZE(X)
  121. addq INCX,X # x += incx
  122. FST 3 * SIZE(X1)
  123. FST 2 * SIZE(X1)
  124. FST 1 * SIZE(X1)
  125. FST 0 * SIZE(X1)
  126. addq $4 * SIZE, X1 # xp += 4
  127. decq I
  128. jg .L36
  129. ALIGN_3
  130. .L35:
  131. movq MIN_N, I
  132. andq $1, I
  133. jle .L34
  134. FLD 0 * SIZE(X)
  135. FLD 1 * SIZE(X)
  136. addq INCX,X # x += incx
  137. FST 1 * SIZE(X1)
  138. FST 0 * SIZE(X1)
  139. ALIGN_3
  140. /* Main Routine */
  141. .L34:
  142. movq Y, Y1 # c_offset
  143. movq M, J # j = m
  144. ALIGN_3
  145. .L61:
  146. movq A, A1 # a_offset = a
  147. addq $2 * SIZE, A # a++
  148. fldz
  149. fldz
  150. fldz
  151. fldz
  152. movq XP, X1
  153. FLD (X1) # bt1 = *(b_offset + 0)
  154. movq MIN_N, I
  155. sarq $1, I
  156. jle .L64
  157. ALIGN_3
  158. .L65:
  159. FLD 0 * SIZE(A1) # at1 = *(a_offset + 0)
  160. fmul %st(1) # at1 *= bt1
  161. faddp %st, %st(2) # ct1 += at1
  162. FLD 1 * SIZE(A1) # bt1 *= *(a_offset + 1)
  163. fmulp %st, %st(1)
  164. #ifndef CONJ
  165. faddp %st, %st(2) # ct2 += bt1
  166. #else
  167. fsubrp %st, %st(2) # ct2 -= bt1
  168. #endif
  169. FLD 1 * SIZE(X1) # bt1 = *(b_offset + 1)
  170. FLD 0 * SIZE(A1) # at1 = *(a_offset + 0)
  171. fmul %st(1) # at1 *= bt1
  172. faddp %st, %st(4) # ct3 += at1
  173. FLD 1 * SIZE(A1) # bt1 *= *(a_offset + 1)
  174. fmulp %st, %st(1)
  175. faddp %st, %st(4) # ct4 += bt1
  176. FLD 2 * SIZE(X1) # bt1 = *(b_offset + 2)
  177. addq $2 * SIZE, X1 # b_offset += 2
  178. addq LDA, A1 # a_offset += lda
  179. FLD 0 * SIZE(A1) # at1 = *(a_offset + 0)
  180. fmul %st(1) # at1 *= bt1
  181. faddp %st, %st(2) # ct1 += at1
  182. FLD 1 * SIZE(A1) # bt1 *= *(a_offset + 1)
  183. fmulp %st, %st(1)
  184. #ifndef CONJ
  185. faddp %st, %st(2) # ct2 += bt1
  186. #else
  187. fsubrp %st, %st(2) # ct2 -= bt1
  188. #endif
  189. FLD 1 * SIZE(X1) # bt1 = *(b_offset + 1)
  190. FLD 0 * SIZE(A1) # at1 = *(a_offset + 0)
  191. fmul %st(1) # at1 *= bt1
  192. faddp %st, %st(4) # ct3 += at1
  193. FLD 1 * SIZE(A1) # bt1 *= *(a_offset + 1)
  194. fmulp %st, %st(1)
  195. faddp %st, %st(4) # ct4 += bt1
  196. FLD 2 * SIZE(X1) # bt1 = *(b_offset + 2)
  197. addq $2 * SIZE, X1 # b_offset += 2
  198. addq LDA, A1 # a_offset += lda
  199. decq I
  200. jg .L65
  201. .L64:
  202. movq MIN_N, I
  203. andq $1, I
  204. jle .L70
  205. ALIGN_2
  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_2
  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. .L60:
  264. addq PLDA_M, A
  265. addq $P, IS
  266. cmpq N, IS
  267. jl .L32
  268. .L79:
  269. ffreep %st
  270. ffreep %st
  271. movq 0(%rsp), %rbx
  272. movq 8(%rsp), %rbp
  273. movq 16(%rsp), %r12
  274. movq 24(%rsp), %r13
  275. movq 32(%rsp), %r14
  276. movq 40(%rsp), %r15
  277. addq $STACKSIZE, %rsp
  278. ret
  279. EPILOGUE