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.

zgemv_n.S 8.4 kB

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