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

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