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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  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(ATHLON) || defined(OPTERON)
  44. #define P 32
  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. #define ALPHA 16 + STACK + ARGS(%esp)
  59. #define A 32 + STACK + ARGS(%esp)
  60. #define LDA 36 + STACK + ARGS(%esp)
  61. #define X 40 + STACK + ARGS(%esp)
  62. #define INCX 44 + STACK + ARGS(%esp)
  63. #define Y 48 + STACK + ARGS(%esp)
  64. #define INCY 52 + STACK + ARGS(%esp)
  65. #define BUFFER 56 + STACK + ARGS(%esp)
  66. PROLOGUE
  67. subl $ARGS, %esp
  68. pushl %ebp
  69. pushl %edi
  70. pushl %esi
  71. pushl %ebx
  72. PROFCODE
  73. FLD ALPHA
  74. movl X, %edi
  75. movl LDA, %ebx
  76. sall $BASE_SHIFT, %ebx
  77. movl $0, IS
  78. movl M, %edx
  79. movl N, %esi
  80. test %esi, %esi
  81. jle .L79 # goto END
  82. test %edx, %edx
  83. jle .L79 # goto END
  84. movl INCY, %eax
  85. sall $BASE_SHIFT, %eax
  86. movl %eax, INCY
  87. movl LDA, %eax
  88. imull $P, %eax # P * lda
  89. subl M ,%eax # P * lda - m
  90. sall $BASE_SHIFT, %eax
  91. movl %eax, PLDA_M
  92. ALIGN_2
  93. .L32:
  94. movl IS, %esi
  95. movl $P, %edx
  96. movl N, %eax
  97. subl %esi,%eax # n - is
  98. cmpl %edx, %eax
  99. #ifdef PENTIUM
  100. jle .L33
  101. movl %edx, %eax
  102. .L33:
  103. #else
  104. cmovg %edx, %eax
  105. #endif
  106. movl %eax, MIN_N
  107. movl INCX, %edx
  108. sall $BASE_SHIFT, %esi
  109. leal (%edi, %esi, 1), %esi
  110. movl %esi, XP
  111. cmpl $1, %edx
  112. je .L34 # if incx == 1 goto L34
  113. movl BUFFER, %esi
  114. sall $BASE_SHIFT, %edx
  115. movl %esi, XP # xp = buffer
  116. sarl $2,%eax
  117. jle .L35
  118. ALIGN_2
  119. .L36:
  120. FLD (%edi)
  121. addl %edx,%edi # x += incx
  122. FLD (%edi)
  123. addl %edx,%edi # x += incx
  124. FLD (%edi)
  125. addl %edx,%edi # x += incx
  126. FLD (%edi)
  127. addl %edx,%edi # x += incx
  128. FST 3 * SIZE(%esi)
  129. FST 2 * SIZE(%esi)
  130. FST 1 * SIZE(%esi)
  131. FST 0 * SIZE(%esi)
  132. addl $4 * SIZE, %esi # xp += 4
  133. decl %eax
  134. jg .L36
  135. ALIGN_3
  136. .L35:
  137. movl MIN_N, %eax
  138. andl $3, %eax
  139. jle .L34
  140. ALIGN_2
  141. .L42:
  142. FLD (%edi)
  143. addl %edx, %edi
  144. FST (%esi)
  145. addl $SIZE, %esi
  146. decl %eax
  147. jg .L42
  148. ALIGN_3
  149. /* Main Routine */
  150. .L34:
  151. movl Y, %ecx # c_offset
  152. movl M, %ebp
  153. sarl $2, %ebp # j = (m >> 2)
  154. jle .L47
  155. ALIGN_2
  156. .L48:
  157. movl A, %edx # a_offset = a
  158. fldz
  159. addl $4 * SIZE, A # a += 4
  160. fldz
  161. movl XP, %esi # b_offset = xp
  162. fldz
  163. movl MIN_N, %eax # i = min_n
  164. fldz
  165. FLD (%esi) # bt1 = b_offset
  166. sarl $1, %eax
  167. jle .L51
  168. ALIGN_2
  169. #ifdef PENTIUM3
  170. #define PRESIZE 8
  171. #else
  172. #define PRESIZE 24
  173. #endif
  174. .L80:
  175. #ifdef PENTIUM3
  176. prefetcht1 PRESIZE * SIZE(%edx, %ebx, 1)
  177. FLD 0 * SIZE(%edx) # at1 = *(a_offset + 0)
  178. fmul %st(1), %st # at1 *= bt1
  179. prefetcht1 PRESIZE * SIZE(%esi)
  180. faddp %st, %st(2) # ct1 += at1
  181. FLD 1 * SIZE(%edx) # at1 = *(a_offset + 1)
  182. fmul %st(1), %st # at1 *= bt1
  183. faddp %st, %st(3) # ct2 += at1
  184. FLD 2 * SIZE(%edx) # at1 = *(a_offset + 2)
  185. fmul %st(1), %st # at1 *= bt1
  186. faddp %st, %st(4) # ct3 += at1
  187. FLD 3 * SIZE(%edx) # bt1 *= *(a_offset + 3)
  188. fmulp %st, %st(1)
  189. faddp %st, %st(4) # ct4 += at1
  190. FLD 1 * SIZE(%esi) # bt1 = b_offset
  191. prefetcht1 PRESIZE * SIZE(%edx, %ebx, 2)
  192. addl %ebx, %edx # a_offset += lda
  193. FLD 0 * SIZE(%edx) # at1 = *(a_offset + 0)
  194. fmul %st(1), %st # at1 *= bt1
  195. faddp %st, %st(2) # ct1 += at1
  196. FLD 1 * SIZE(%edx) # at1 = *(a_offset + 1)
  197. fmul %st(1), %st # at1 *= bt1
  198. faddp %st, %st(3) # ct2 += at1
  199. FLD 2 * SIZE(%edx) # at1 = *(a_offset + 2)
  200. fmul %st(1), %st # at1 *= bt1
  201. faddp %st, %st(4) # ct3 += at1
  202. FLD 3 * SIZE(%edx) # bt1 *= *(a_offset + 3)
  203. fmulp %st, %st(1)
  204. addl %ebx, %edx
  205. faddp %st, %st(4) # ct4 += at1
  206. FLD 2 * SIZE(%esi) # bt1 = b_offset
  207. addl $2 * SIZE, %esi # b_offset += 2
  208. #else
  209. #ifdef PENTIUM4
  210. prefetchnta 8 * SIZE(%esi)
  211. #endif
  212. FLD 0 * SIZE(%edx) # at1 = *(a_offset + 0)
  213. fmul %st(1), %st # at1 *= bt1
  214. faddp %st, %st(2) # ct1 += at1
  215. FLD 1 * SIZE(%edx) # at1 = *(a_offset + 1)
  216. fmul %st(1), %st # at1 *= bt1
  217. faddp %st, %st(3) # ct2 += at1
  218. FLD 2 * SIZE(%edx) # at1 = *(a_offset + 2)
  219. fmul %st(1), %st # at1 *= bt1
  220. faddp %st, %st(4) # ct3 += at1
  221. FLD 3 * SIZE(%edx) # bt1 *= *(a_offset + 3)
  222. fmulp %st, %st(1)
  223. faddp %st, %st(4) # ct4 += at1
  224. FLD 1 * SIZE(%esi) # bt1 = b_offset
  225. addl %ebx, %edx # a_offset += lda
  226. FLD 0 * SIZE(%edx) # at1 = *(a_offset + 0)
  227. fmul %st(1), %st # at1 *= bt1
  228. faddp %st, %st(2) # ct1 += at1
  229. FLD 1 * SIZE(%edx) # at1 = *(a_offset + 1)
  230. fmul %st(1), %st # at1 *= bt1
  231. faddp %st, %st(3) # ct2 += at1
  232. FLD 2 * SIZE(%edx) # at1 = *(a_offset + 2)
  233. fmul %st(1), %st # at1 *= bt1
  234. faddp %st, %st(4) # ct3 += at1
  235. FLD 3 * SIZE(%edx) # bt1 *= *(a_offset + 3)
  236. fmulp %st, %st(1)
  237. faddp %st, %st(4) # ct4 += at1
  238. FLD 2 * SIZE(%esi) # bt1 = b_offset
  239. addl %ebx, %edx
  240. addl $2 * SIZE, %esi # b_offset += 2
  241. #endif
  242. decl %eax
  243. jg .L80
  244. .L51:
  245. movl MIN_N,%eax
  246. andl $1, %eax
  247. je .L57
  248. FLD 0 * SIZE(%edx) # at1 = *(a_offset + 0)
  249. fmul %st(1), %st # at1 *= bt1
  250. faddp %st, %st(2) # ct1 += at1
  251. FLD 1 * SIZE(%edx) # at1 = *(a_offset + 1)
  252. fmul %st(1), %st # at1 *= bt1
  253. faddp %st, %st(3) # ct2 += at1
  254. FLD 2 * SIZE(%edx) # at1 = *(a_offset + 2)
  255. fmul %st(1), %st # at1 *= bt1
  256. faddp %st, %st(4) # ct3 += at1
  257. FLD 3 * SIZE(%edx) # bt1 *= *(a_offset + 3)
  258. fmulp %st, %st(1)
  259. faddp %st, %st(4) # ct4 += at1
  260. fldz
  261. ALIGN_2
  262. .L57:
  263. ffreep %st(0)
  264. fxch %st(4)
  265. fmul %st, %st(4)
  266. fmul %st, %st(1)
  267. fmul %st, %st(2)
  268. fmul %st, %st(3)
  269. fxch %st(4)
  270. movl INCY, %eax
  271. FLD (%ecx)
  272. faddp %st, %st(1)
  273. FST (%ecx)
  274. addl %eax, %ecx
  275. FLD (%ecx)
  276. faddp %st, %st(1)
  277. FST (%ecx)
  278. addl %eax, %ecx
  279. FLD (%ecx)
  280. faddp %st, %st(1)
  281. FST (%ecx)
  282. addl %eax, %ecx
  283. FLD (%ecx)
  284. faddp %st, %st(1)
  285. FST (%ecx)
  286. addl %eax, %ecx
  287. decl %ebp # j --
  288. jg .L48
  289. ALIGN_3
  290. .L47:
  291. movl M, %ebp
  292. andl $3, %ebp # j = (m & 3)
  293. jle .L60
  294. ALIGN_2
  295. .L61:
  296. movl A, %edx # a_offset = a
  297. fldz
  298. addl $SIZE, A # a++
  299. fldz
  300. movl XP,%esi
  301. fldz
  302. movl MIN_N,%eax
  303. fldz
  304. sarl $3,%eax
  305. jle .L64
  306. ALIGN_2
  307. .L65:
  308. FLD 0 * SIZE(%esi)
  309. FLD (%edx)
  310. fmulp %st, %st(1)
  311. faddp %st, %st(1)
  312. addl %ebx, %edx
  313. FLD 1 * SIZE(%esi)
  314. FLD (%edx)
  315. fmulp %st, %st(1)
  316. faddp %st, %st(2)
  317. addl %ebx ,%edx
  318. FLD 2 * SIZE(%esi)
  319. FLD (%edx)
  320. fmulp %st, %st(1)
  321. faddp %st, %st(3)
  322. addl %ebx, %edx
  323. FLD 3 * SIZE(%esi)
  324. FLD (%edx)
  325. fmulp %st, %st(1)
  326. faddp %st, %st(4)
  327. addl %ebx, %edx
  328. FLD 4 * SIZE(%esi)
  329. FLD (%edx)
  330. fmulp %st, %st(1)
  331. faddp %st,%st(1)
  332. addl %ebx, %edx
  333. FLD 5 * SIZE(%esi)
  334. FLD (%edx)
  335. fmulp %st, %st(1)
  336. faddp %st, %st(2)
  337. addl %ebx, %edx
  338. FLD 6 * SIZE(%esi)
  339. FLD (%edx)
  340. fmulp %st, %st(1)
  341. faddp %st,%st(3)
  342. addl %ebx, %edx
  343. FLD 7 * SIZE(%esi)
  344. FLD (%edx)
  345. fmulp %st, %st(1)
  346. faddp %st,%st(4)
  347. addl %ebx, %edx
  348. addl $8 * SIZE, %esi
  349. decl %eax
  350. jg .L65
  351. .L64:
  352. movl MIN_N,%eax
  353. andl $7, %eax
  354. jle .L70
  355. ALIGN_2
  356. .L71:
  357. FLD (%esi)
  358. addl $SIZE, %esi # b_offset ++
  359. FLD (%edx)
  360. fmulp %st, %st(1)
  361. addl %ebx, %edx # a_offset += lda
  362. faddp %st, %st(1)
  363. decl %eax
  364. jg .L71
  365. ALIGN_2
  366. .L70:
  367. faddp %st, %st(1)
  368. faddp %st, %st(1)
  369. faddp %st, %st(1)
  370. fmul %st(1), %st
  371. movl INCY, %eax
  372. FLD (%ecx)
  373. faddp %st, %st(1)
  374. FST (%ecx)
  375. addl %eax, %ecx
  376. decl %ebp
  377. jg .L61
  378. .L60:
  379. movl PLDA_M, %esi
  380. addl %esi, A # a += P * lda - m
  381. addl $P, IS
  382. movl N, %esi
  383. cmpl %esi,IS
  384. jl .L32
  385. .L79:
  386. ffreep %st(0)
  387. popl %ebx
  388. popl %esi
  389. popl %edi
  390. popl %ebp
  391. addl $ARGS, %esp
  392. ret
  393. EPILOGUE