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.

ztrsm_kernel_LT_1x1.S 9.5 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  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. #define STACK 16
  41. #define ARGS 16
  42. #define KK 0 + STACK(%esp)
  43. #define KKK 4 + STACK(%esp)
  44. #define AORIG 8 + STACK(%esp)
  45. #define STACK_M 4 + STACK + ARGS(%esp)
  46. #define STACK_N 8 + STACK + ARGS(%esp)
  47. #define STACK_K 12 + STACK + ARGS(%esp)
  48. #ifdef DOUBLE
  49. #define ALPHA_R 16 + STACK + ARGS(%esp)
  50. #define ALPHA_I 24 + STACK + ARGS(%esp)
  51. #define STACK_A 32 + STACK + ARGS(%esp)
  52. #define STACK_B 36 + STACK + ARGS(%esp)
  53. #define STACK_C 40 + STACK + ARGS(%esp)
  54. #define STACK_LDC 44 + STACK + ARGS(%esp)
  55. #define OFFSET 48 + STACK + ARGS(%esp)
  56. #else
  57. #define ALPHA_R 16 + STACK + ARGS(%esp)
  58. #define ALPHA_I 20 + STACK + ARGS(%esp)
  59. #define STACK_A 24 + STACK + ARGS(%esp)
  60. #define STACK_B 28 + STACK + ARGS(%esp)
  61. #define STACK_C 32 + STACK + ARGS(%esp)
  62. #define STACK_LDC 36 + STACK + ARGS(%esp)
  63. #define OFFSET 40 + STACK + ARGS(%esp)
  64. #endif
  65. PROLOGUE
  66. subl $ARGS, %esp
  67. pushl %ebp
  68. pushl %edi
  69. pushl %esi
  70. pushl %ebx
  71. PROFCODE
  72. #define M %esi
  73. #define K %edi
  74. #define A %ebx
  75. #define B %ecx
  76. #define C %edx
  77. #define LDC %ebp
  78. movl STACK_K, K
  79. movl STACK_LDC, LDC
  80. sall $ZBASE_SHIFT, LDC
  81. #ifdef LN
  82. movl STACK_M, %eax
  83. sall $ZBASE_SHIFT, %eax
  84. addl %eax, STACK_C
  85. imull K, %eax
  86. addl %eax, STACK_A
  87. #endif
  88. #ifdef RT
  89. movl STACK_N, %eax
  90. sall $ZBASE_SHIFT, %eax
  91. imull K, %eax
  92. addl %eax, STACK_B
  93. movl STACK_N, %eax
  94. imull LDC, %eax
  95. addl %eax, STACK_C
  96. #endif
  97. #ifdef RN
  98. movl OFFSET, %eax
  99. negl %eax
  100. movl %eax, KK
  101. #endif
  102. #ifdef RT
  103. movl STACK_N, %eax
  104. subl OFFSET, %eax
  105. movl %eax, KK
  106. #endif
  107. cmpl $0, STACK_N
  108. jle .L29
  109. cmpl $0, STACK_M
  110. jle .L29
  111. ALIGN_4
  112. .L30:
  113. #if defined(LT) || defined(RN)
  114. movl STACK_A, A
  115. #else
  116. movl STACK_A, %eax
  117. movl %eax, AORIG
  118. #endif
  119. #ifdef RT
  120. movl K, %eax
  121. sall $ZBASE_SHIFT, %eax
  122. subl %eax, STACK_B
  123. #endif
  124. #ifdef RT
  125. subl LDC, STACK_C
  126. #endif
  127. movl STACK_C, C
  128. #ifndef RT
  129. addl LDC, STACK_C
  130. #endif
  131. movl STACK_M, M
  132. #ifdef LN
  133. movl OFFSET, %eax
  134. addl M, %eax
  135. movl %eax, KK
  136. #endif
  137. #ifdef LT
  138. movl OFFSET, %eax
  139. movl %eax, KK
  140. #endif
  141. ALIGN_4
  142. .L34:
  143. #ifdef LN
  144. movl K, %eax
  145. sall $ZBASE_SHIFT, %eax
  146. subl %eax, AORIG
  147. #endif
  148. #if defined(LN) || defined(RT)
  149. movl KK, %eax
  150. sall $ZBASE_SHIFT, %eax
  151. movl AORIG, A
  152. movl STACK_B, B
  153. addl %eax, A
  154. addl %eax, B
  155. #else
  156. movl STACK_B, B
  157. #endif
  158. fldz
  159. fldz
  160. fldz
  161. fldz
  162. FLD 4 * SIZE(B) # B5
  163. FLD 4 * SIZE(A) # A5
  164. FLD 0 * SIZE(B) # B0
  165. FLD 0 * SIZE(A) # A0
  166. #ifdef HAVE_SSE
  167. prefetcht2 2 * SIZE(C)
  168. #endif
  169. #if defined(LT) || defined(RN)
  170. movl KK, %eax
  171. #else
  172. movl K, %eax
  173. subl KK, %eax
  174. #endif
  175. sarl $2, %eax
  176. je .L37
  177. ALIGN_4
  178. #define PREFETCH_OFFSET 40
  179. .L38:
  180. #ifdef HAVE_SSE
  181. prefetchnta (PREFETCH_OFFSET) * SIZE(B)
  182. #if (L2_SIZE == 524288)
  183. prefetcht0 (PREFETCH_OFFSET) * SIZE(A)
  184. #endif
  185. #endif
  186. fmul %st, %st(1)
  187. FMUL 1 * SIZE(B)
  188. fxch %st(1)
  189. faddp %st, %st(5)
  190. FLD 0 * SIZE(B)
  191. fxch %st(1)
  192. faddp %st, %st(4)
  193. FLD 1 * SIZE(A)
  194. fmul %st, %st(1)
  195. FMUL 1 * SIZE(B)
  196. fxch %st(1)
  197. faddp %st, %st(7)
  198. FLD 2 * SIZE(B)
  199. fxch %st(1)
  200. faddp %st, %st(6)
  201. FLD 2 * SIZE(A)
  202. fmul %st, %st(1)
  203. FMUL 3 * SIZE(B)
  204. fxch %st(1)
  205. faddp %st, %st(5)
  206. FLD 2 * SIZE(B)
  207. fxch %st(1)
  208. faddp %st, %st(4)
  209. FLD 3 * SIZE(A)
  210. fmul %st, %st(1)
  211. FMUL 3 * SIZE(B)
  212. fxch %st(1)
  213. faddp %st, %st(7)
  214. FLD 8 * SIZE(B)
  215. fxch %st(1)
  216. faddp %st, %st(6)
  217. FLD 8 * SIZE(A)
  218. fxch %st(2)
  219. #ifdef HAVE_SSE
  220. #ifdef DOUBLE
  221. prefetchnta (PREFETCH_OFFSET + 4) * SIZE(B)
  222. #if (L2_SIZE == 524288)
  223. prefetcht0 (PREFETCH_OFFSET + 4) * SIZE(A)
  224. #endif
  225. #endif
  226. #endif
  227. fmul %st, %st(3)
  228. FMUL 5 * SIZE(B)
  229. fxch %st(3)
  230. faddp %st, %st(5)
  231. FLD 4 * SIZE(B)
  232. fxch %st(3)
  233. faddp %st, %st(4)
  234. FLD 5 * SIZE(A)
  235. fmul %st, %st(3)
  236. FMUL 5 * SIZE(B)
  237. fxch %st(3)
  238. faddp %st, %st(7)
  239. FLD 6 * SIZE(B)
  240. fxch %st(3)
  241. faddp %st, %st(6)
  242. FLD 6 * SIZE(A)
  243. fmul %st, %st(3)
  244. FMUL 7 * SIZE(B)
  245. fxch %st(3)
  246. faddp %st, %st(5)
  247. FLD 6 * SIZE(B)
  248. fxch %st(3)
  249. faddp %st, %st(4)
  250. FLD 7 * SIZE(A)
  251. fmul %st, %st(3)
  252. FMUL 7 * SIZE(B)
  253. fxch %st(3)
  254. faddp %st, %st(7)
  255. FLD 12 * SIZE(B)
  256. fxch %st(3)
  257. faddp %st, %st(6)
  258. FLD 12 * SIZE(A)
  259. fxch %st(2)
  260. subl $-8 * SIZE, B
  261. subl $-8 * SIZE, A
  262. decl %eax
  263. jg .L38
  264. ALIGN_4
  265. .L37:
  266. #if defined(LT) || defined(RN)
  267. movl KK, %eax
  268. #else
  269. movl K, %eax
  270. subl KK, %eax
  271. #endif
  272. andl $3, %eax
  273. jle .L43
  274. ALIGN_2
  275. .L54:
  276. fmul %st, %st(1)
  277. FMUL 1 * SIZE(B)
  278. fxch %st(1)
  279. faddp %st, %st(5)
  280. FLD 0 * SIZE(B)
  281. fxch %st(1)
  282. faddp %st, %st(4)
  283. FLD 1 * SIZE(A)
  284. fmul %st, %st(1)
  285. FMUL 1 * SIZE(B)
  286. fxch %st(1)
  287. faddp %st, %st(7)
  288. FLD 2 * SIZE(B)
  289. fxch %st(1)
  290. faddp %st, %st(6)
  291. FLD 2 * SIZE(A)
  292. addl $2 * SIZE, A
  293. addl $2 * SIZE, B
  294. decl %eax
  295. jg .L54
  296. ALIGN_3
  297. .L43:
  298. ffreep %st(0)
  299. ffreep %st(0)
  300. ffreep %st(0)
  301. ffreep %st(0)
  302. #if defined(LN) || defined(LT)
  303. #ifndef CONJ
  304. faddp %st, %st(3) # ctemp3 += ctemp4
  305. fsubp %st, %st(1) # ctemp1 += ctemp2
  306. #else
  307. fsubp %st, %st(3) # ctemp1 += ctemp2
  308. faddp %st, %st(1) # ctemp3 += ctemp4
  309. #endif
  310. #endif
  311. #if defined(RN) || defined(RT)
  312. #ifndef CONJ
  313. faddp %st, %st(3) # ctemp3 += ctemp4
  314. fsubp %st, %st(1) # ctemp1 += ctemp2
  315. #else
  316. fsubrp %st, %st(3) # ctemp1 += ctemp2
  317. faddp %st, %st(1) # ctemp3 += ctemp4
  318. #endif
  319. #endif
  320. #if defined(LN) || defined(RT)
  321. movl KK, %eax
  322. subl $1, %eax
  323. sall $ZBASE_SHIFT, %eax
  324. movl AORIG, A
  325. movl STACK_B, B
  326. addl %eax, A
  327. addl %eax, B
  328. #endif
  329. #if defined(LN) || defined(LT)
  330. FLD 0 * SIZE(B)
  331. fsubp %st, %st(1)
  332. FLD 1 * SIZE(B)
  333. fsubp %st, %st(2)
  334. #else
  335. FLD 0 * SIZE(A)
  336. fsubp %st, %st(1)
  337. FLD 1 * SIZE(A)
  338. fsubp %st, %st(2)
  339. #endif
  340. #if defined(LN) || defined(LT)
  341. FLD 0 * SIZE(A)
  342. fmul %st(1), %st
  343. FLD 0 * SIZE(A)
  344. fmul %st(3), %st
  345. FLD 1 * SIZE(A)
  346. fmulp %st, %st(3)
  347. FLD 1 * SIZE(A)
  348. fmulp %st, %st(4)
  349. #endif
  350. #if defined(RN) || defined(RT)
  351. FLD 0 * SIZE(B)
  352. fmul %st(1), %st
  353. FLD 0 * SIZE(B)
  354. fmul %st(3), %st
  355. FLD 1 * SIZE(B)
  356. fmulp %st, %st(3)
  357. FLD 1 * SIZE(B)
  358. fmulp %st, %st(4)
  359. #endif
  360. #ifndef CONJ
  361. faddp %st, %st(2)
  362. fsubp %st, %st(2)
  363. #else
  364. fsubp %st, %st(2)
  365. faddp %st, %st(2)
  366. #endif
  367. #ifdef LN
  368. subl $2 * SIZE, C
  369. #endif
  370. #if defined(LN) || defined(LT)
  371. FSTU 1 * SIZE(B)
  372. fxch %st(1)
  373. FSTU 0 * SIZE(B)
  374. #else
  375. FSTU 1 * SIZE(A)
  376. fxch %st(1)
  377. FSTU 0 * SIZE(A)
  378. #endif
  379. FST 0 * SIZE(C)
  380. FST 1 * SIZE(C)
  381. #ifndef LN
  382. addl $2 * SIZE, C
  383. #endif
  384. #if defined(LT) || defined(RN)
  385. movl K, %eax
  386. subl KK, %eax
  387. sall $ZBASE_SHIFT, %eax
  388. addl %eax, A
  389. addl %eax, B
  390. #endif
  391. #ifdef LN
  392. subl $1, KK
  393. #endif
  394. #ifdef LT
  395. addl $1, KK
  396. #endif
  397. #ifdef RT
  398. movl K, %eax
  399. sall $ZBASE_SHIFT, %eax
  400. addl %eax, AORIG
  401. #endif
  402. decl M
  403. jg .L34
  404. ALIGN_2
  405. .L33:
  406. #ifdef LN
  407. movl K, %eax
  408. sall $ZBASE_SHIFT, %eax
  409. addl %eax, STACK_B
  410. #endif
  411. #if defined(LT) || defined(RN)
  412. movl B, STACK_B
  413. #endif
  414. #ifdef RN
  415. addl $1, KK
  416. #endif
  417. #ifdef RT
  418. subl $1, KK
  419. #endif
  420. decl STACK_N
  421. jg .L30
  422. ALIGN_2
  423. .L29:
  424. popl %ebx
  425. popl %esi
  426. popl %edi
  427. popl %ebp
  428. addl $ARGS, %esp
  429. ret
  430. EPILOGUE