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 8.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  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. #ifdef PENTIUM
  41. #define P 88
  42. #endif
  43. #ifndef P
  44. #define P 400
  45. #endif
  46. #define STACK 16
  47. #define ARGS 24
  48. #define NLDA 0 + STACK(%esp)
  49. #define XP 4 + STACK(%esp)
  50. #define MIN_M 8 + STACK(%esp)
  51. #define J 12 + STACK(%esp)
  52. #define IS 16 + STACK(%esp)
  53. #define M 4 + STACK + ARGS(%esp)
  54. #define N 8 + STACK + ARGS(%esp)
  55. #define K 12 + STACK + ARGS(%esp)
  56. #define ALPHA_R 16 + STACK + ARGS(%esp)
  57. #define ALPHA_I 32 + STACK + ARGS(%esp)
  58. #define A 48 + STACK + ARGS(%esp)
  59. #define LDA 52 + STACK + ARGS(%esp)
  60. #define X 56 + STACK + ARGS(%esp)
  61. #define INCX 60 + STACK + ARGS(%esp)
  62. #define Y 64 + STACK + ARGS(%esp)
  63. #define INCY 68 + STACK + ARGS(%esp)
  64. #define BUFFER 72 + STACK + ARGS(%esp)
  65. PROLOGUE
  66. subl $ARGS, %esp
  67. pushl %ebp
  68. pushl %edi
  69. pushl %esi
  70. pushl %ebx
  71. PROFCODE
  72. FLD ALPHA_I
  73. FLD ALPHA_R
  74. movl X, %edi # X
  75. movl $0, IS
  76. movl M, %ebx
  77. movl N, %ecx
  78. testl %ebx, %ebx
  79. jle .L79
  80. testl %ecx, %ecx
  81. jle .L79
  82. movl INCX, %esi
  83. sall $ZBASE_SHIFT, %esi
  84. movl %esi, INCX
  85. movl INCY, %esi
  86. sall $ZBASE_SHIFT, %esi
  87. movl %esi, INCY
  88. movl LDA, %ebx
  89. movl N, %eax
  90. imull %ebx, %eax
  91. movl $P, %esi
  92. subl %eax, %esi
  93. sall $ZBASE_SHIFT, %esi
  94. movl %esi, NLDA
  95. movl %ebx, %esi
  96. sall $ZBASE_SHIFT, %esi
  97. movl %esi, LDA
  98. ALIGN_2
  99. .L32:
  100. movl IS, %esi
  101. movl $P, %edx
  102. movl M, %eax
  103. subl %esi, %eax
  104. cmpl %edx, %eax
  105. #ifdef PENTIUM
  106. jle .L33
  107. movl %edx, %eax
  108. .L33:
  109. #else
  110. cmovg %edx, %eax
  111. #endif
  112. movl %eax, MIN_M
  113. movl IS, %ecx
  114. sall $ZBASE_SHIFT, %ecx
  115. leal (%edi, %ecx, 1), %ecx # xp = x + is
  116. movl INCX, %ebx
  117. movl %ecx, XP
  118. cmpl $2 * SIZE, %ebx
  119. je .L34
  120. movl BUFFER, %esi
  121. movl MIN_M, %eax
  122. movl %esi, XP
  123. sarl $1, %eax
  124. jle .L35
  125. ALIGN_3
  126. .L36:
  127. FLD 0 * SIZE(%edi)
  128. FLD 1 * SIZE(%edi)
  129. addl %ebx,%edi # x += incx
  130. FLD 0 * SIZE(%edi)
  131. FLD 1 * SIZE(%edi)
  132. addl %ebx,%edi # x += incx
  133. FST 3 * SIZE(%esi)
  134. FST 2 * SIZE(%esi)
  135. FST 1 * SIZE(%esi)
  136. FST 0 * SIZE(%esi)
  137. addl $4 * SIZE, %esi # xp += 4
  138. decl %eax
  139. jg .L36
  140. ALIGN_3
  141. .L35:
  142. movl MIN_M, %eax
  143. andl $1,%eax
  144. jle .L34
  145. FLD 0 * SIZE(%edi)
  146. FLD 1 * SIZE(%edi)
  147. addl %ebx,%edi # x += incx
  148. FST 1 * SIZE(%esi)
  149. FST 0 * SIZE(%esi)
  150. ALIGN_3
  151. /* Main Routine */
  152. .L34:
  153. movl Y, %ebp # coffset = y
  154. movl N, %ecx
  155. testl %ecx, %ecx
  156. jle .L60
  157. ALIGN_2
  158. .L61:
  159. movl A, %ebx # a_offset = a
  160. fldz # ct1 = ZERO
  161. movl LDA, %edx
  162. fldz # ct1 = ZERO
  163. addl %ebx, %edx
  164. fldz # ct1 = ZERO
  165. movl %edx, A
  166. fldz # ct1 = ZERO
  167. movl XP, %esi
  168. FLD (%esi) # bt1 = *(b_offset + 0)
  169. movl MIN_M, %eax
  170. sarl $1, %eax
  171. jle .L64
  172. ALIGN_3
  173. #define PRESIZE 8
  174. .L65:
  175. #ifdef HAS_PREFETCH
  176. prefetcht0 PRESIZE * SIZE(%ebx)
  177. prefetcht0 PRESIZE * SIZE(%esi)
  178. #endif
  179. FLD 0 * SIZE(%ebx) # at1 = *(a_offset + 0)
  180. fmul %st(1) # at1 *= bt1
  181. faddp %st, %st(2) # ct1 += at1
  182. FLD 1 * SIZE(%ebx) # 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(%esi) # bt1 = *(b_offset + 1)
  190. FLD 0 * SIZE(%ebx) # at1 = *(a_offset + 0)
  191. fmul %st(1) # at1 *= bt1
  192. faddp %st, %st(4) # ct3 += at1
  193. FLD 1 * SIZE(%ebx) # bt1 *= *(a_offset + 1)
  194. fmulp %st, %st(1)
  195. faddp %st, %st(4) # ct4 += bt1
  196. FLD 2 * SIZE(%esi) # bt1 = *(b_offset + 1)
  197. FLD 2 * SIZE(%ebx) # at1 = *(a_offset + 0)
  198. fmul %st(1) # at1 *= bt1
  199. faddp %st, %st(2) # ct1 += at1
  200. FLD 3 * SIZE(%ebx) # bt1 *= *(a_offset + 1)
  201. fmulp %st, %st(1)
  202. #ifndef CONJ
  203. faddp %st, %st(2) # ct2 += bt1
  204. #else
  205. fsubrp %st, %st(2) # ct2 -= bt1
  206. #endif
  207. FLD 3 * SIZE(%esi) # bt1 = *(b_offset + 1)
  208. FLD 2 * SIZE(%ebx) # at1 = *(a_offset + 0)
  209. fmul %st(1) # at1 *= bt1
  210. faddp %st, %st(4) # ct3 += at1
  211. FLD 3 * SIZE(%ebx) # bt1 *= *(a_offset + 1)
  212. fmulp %st, %st(1)
  213. faddp %st, %st(4) # ct4 += bt1
  214. FLD 4 * SIZE(%esi) # bt1 = *(b_offset + 1)
  215. addl $4 * SIZE, %esi
  216. addl $4 * SIZE, %ebx
  217. decl %eax
  218. jg .L65
  219. ALIGN_3
  220. .L64:
  221. movl MIN_M, %eax
  222. andl $1, %eax
  223. jle .L70
  224. ALIGN_3
  225. .L71:
  226. FLD 0 * SIZE(%ebx) # at1 = *(a_offset + 0)
  227. fmul %st(1) # at1 *= bt1
  228. faddp %st, %st(2) # ct1 += at1
  229. FLD 1 * SIZE(%ebx) # bt1 *= *(a_offset + 1)
  230. fmulp %st, %st(1)
  231. #ifndef CONJ
  232. faddp %st, %st(2) # ct2 += bt1
  233. #else
  234. fsubrp %st, %st(2) # ct2 -= bt1
  235. #endif
  236. FLD 1 * SIZE(%esi) # bt1 = *(b_offset + 1)
  237. FLD 0 * SIZE(%ebx) # at1 = *(a_offset + 0)
  238. fmul %st(1) # at1 *= bt1
  239. faddp %st, %st(4) # ct3 += at1
  240. FLD 1 * SIZE(%ebx) # bt1 *= *(a_offset + 1)
  241. fmulp %st, %st(1)
  242. faddp %st, %st(4) # ct4 += bt1
  243. fldz
  244. ALIGN_3
  245. .L70:
  246. ffreep %st(0)
  247. #ifndef XCONJ
  248. #ifndef CONJ
  249. fsubp %st, %st(3)
  250. faddp %st, %st(1)
  251. #else
  252. faddp %st, %st(3)
  253. faddp %st, %st(1)
  254. #endif
  255. #else
  256. #ifndef CONJ
  257. faddp %st, %st(3)
  258. fsubp %st, %st(1)
  259. #else
  260. fsubp %st, %st(3)
  261. fsubp %st, %st(1)
  262. #endif
  263. #endif
  264. fld %st(0) # ct4 = ct2
  265. fmul %st(4)
  266. fld %st(2)
  267. fmul %st(4)
  268. fsubp %st, %st(1)
  269. FLD 0 * SIZE(%ebp)
  270. faddp %st, %st(1)
  271. FST 0 * SIZE(%ebp)
  272. fmul %st(2)
  273. fxch %st(1)
  274. fmul %st(3)
  275. faddp %st, %st(1)
  276. FLD 1 * SIZE(%ebp)
  277. faddp %st, %st(1)
  278. FST 1 * SIZE(%ebp)
  279. addl INCY, %ebp
  280. decl %ecx
  281. jg .L61
  282. ALIGN_3
  283. .L60:
  284. movl A, %ebx
  285. addl NLDA, %ebx
  286. movl %ebx, A
  287. addl $P, IS
  288. movl M, %esi
  289. cmpl %esi, IS
  290. jl .L32
  291. ALIGN_3
  292. .L79:
  293. ffreep %st(0)
  294. ffreep %st(0)
  295. popl %ebx
  296. popl %esi
  297. popl %edi
  298. popl %ebp
  299. addl $ARGS, %esp
  300. ret
  301. EPILOGUE