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.

xtrsm_kernel_LT_1x1.S 8.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  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 M ARG1
  41. #define N ARG2
  42. #define K ARG3
  43. #define A ARG4
  44. #define B ARG5
  45. #define C ARG6
  46. #define LDC %r10
  47. #define I %r12
  48. #define J %r13
  49. #define AO %r14
  50. #define BO %r15
  51. #define CO %rbp
  52. #define OFFSET 48 + STACKSIZE(%rsp)
  53. #define STACKSIZE 64
  54. #define KK %r11
  55. #define AORIG 48(%rsp)
  56. #ifdef OPTERON
  57. #define PREFETCH prefetch
  58. #define PREFETCHW prefetchw
  59. #else
  60. #define PREFETCH prefetcht0
  61. #define PREFETCHW prefetcht0
  62. #endif
  63. #define PREFETCHSIZE (5 + 4 * 10)
  64. #ifndef CONJ
  65. #define ADD1 faddp
  66. #define ADD2 fsubrp
  67. #define ADD3 faddp
  68. #define ADD4 faddp
  69. #elif defined(LN) || defined(LT)
  70. #define ADD1 faddp
  71. #define ADD2 faddp
  72. #define ADD3 fsubrp
  73. #define ADD4 faddp
  74. #else
  75. #define ADD1 faddp
  76. #define ADD2 faddp
  77. #define ADD3 faddp
  78. #define ADD4 fsubrp
  79. #endif
  80. PROLOGUE
  81. PROFCODE
  82. subq $STACKSIZE, %rsp
  83. movq %rbx, 0(%rsp)
  84. movq %rbp, 8(%rsp)
  85. movq %r12, 16(%rsp)
  86. movq %r13, 24(%rsp)
  87. movq %r14, 32(%rsp)
  88. movq %r15, 40(%rsp)
  89. movq 40 + STACKSIZE(%rsp), LDC
  90. salq $ZBASE_SHIFT, LDC
  91. addq $8 * SIZE, A
  92. addq $8 * SIZE, B
  93. #ifdef LN
  94. movq M, %rax
  95. salq $ZBASE_SHIFT, %rax
  96. addq %rax, C
  97. imulq K, %rax
  98. addq %rax, A
  99. #endif
  100. #ifdef RT
  101. movq N, %rax
  102. salq $ZBASE_SHIFT, %rax
  103. imulq K, %rax
  104. addq %rax, B
  105. movq N, %rax
  106. imulq LDC, %rax
  107. addq %rax, C
  108. #endif
  109. #ifdef RN
  110. movq OFFSET, %rax
  111. negq %rax
  112. movq %rax, KK
  113. #endif
  114. #ifdef RT
  115. movq N, %rax
  116. subq OFFSET, %rax
  117. movq %rax, KK
  118. #endif
  119. cmpq $0, M
  120. jle .L999
  121. movq N, %rax
  122. movq %rax, J
  123. testq %rax, %rax
  124. jle .L999
  125. ALIGN_4
  126. .L01:
  127. #if defined(LT) || defined(RN)
  128. movq A, AO
  129. #else
  130. movq A, AORIG
  131. #endif
  132. #ifdef RT
  133. movq K, %rax
  134. salq $ZBASE_SHIFT, %rax
  135. subq %rax, B
  136. #endif
  137. #ifdef RT
  138. subq LDC, C
  139. #endif
  140. movq C, CO
  141. #ifndef RT
  142. addq LDC, C
  143. #endif
  144. #ifdef LN
  145. movq OFFSET, %rax
  146. addq M, %rax
  147. movq %rax, KK
  148. #endif
  149. #ifdef LT
  150. movq OFFSET, %rax
  151. movq %rax, KK
  152. #endif
  153. movq M, I
  154. ALIGN_4
  155. .L11:
  156. #ifdef LN
  157. movq K, %rax
  158. salq $ZBASE_SHIFT, %rax
  159. subq %rax, AORIG
  160. #endif
  161. #if defined(LN) || defined(RT)
  162. movq KK, %rax
  163. salq $ZBASE_SHIFT, %rax
  164. movq AORIG, AO
  165. leaq (AO, %rax, 1), AO
  166. leaq (B, %rax, 1), BO
  167. #else
  168. movq B, BO
  169. #endif
  170. fldz
  171. fldz
  172. fldz
  173. fldz
  174. #if defined(HAVE_3DNOW)
  175. prefetchw 2 * SIZE(CO)
  176. #elif defined(HAVE_SSE)
  177. prefetchnta 2 * SIZE(CO)
  178. #endif
  179. #if defined(LT) || defined(RN)
  180. movq KK, %rax
  181. #else
  182. movq K, %rax
  183. subq KK, %rax
  184. #endif
  185. sarq $2, %rax
  186. je .L15
  187. ALIGN_4
  188. .L12:
  189. PREFETCH (PREFETCHSIZE + 0) * SIZE(AO)
  190. FLD -8 * SIZE(AO)
  191. FLD -8 * SIZE(BO)
  192. fld %st(1)
  193. fmul %st(1), %st
  194. ADD1 %st, %st(3)
  195. FLD -7 * SIZE(BO)
  196. fmul %st, %st(2)
  197. FLD -7 * SIZE(AO)
  198. fmul %st, %st(2)
  199. fmulp %st, %st(1)
  200. ADD2 %st, %st(6)
  201. ADD3 %st, %st(3)
  202. ADD4 %st, %st(3)
  203. FLD -6 * SIZE(AO)
  204. FLD -6 * SIZE(BO)
  205. fld %st(1)
  206. fmul %st(1), %st
  207. ADD1 %st, %st(3)
  208. FLD -5 * SIZE(BO)
  209. fmul %st, %st(2)
  210. FLD -5 * SIZE(AO)
  211. fmul %st, %st(2)
  212. fmulp %st, %st(1)
  213. ADD2 %st, %st(6)
  214. ADD3 %st, %st(3)
  215. ADD4 %st, %st(3)
  216. PREFETCH (PREFETCHSIZE + 4) * SIZE(AO)
  217. FLD -4 * SIZE(AO)
  218. FLD -4 * SIZE(BO)
  219. fld %st(1)
  220. fmul %st(1), %st
  221. ADD1 %st, %st(3)
  222. FLD -3 * SIZE(BO)
  223. fmul %st, %st(2)
  224. FLD -3 * SIZE(AO)
  225. fmul %st, %st(2)
  226. fmulp %st, %st(1)
  227. ADD2 %st, %st(6)
  228. ADD3 %st, %st(3)
  229. ADD4 %st, %st(3)
  230. FLD -2 * SIZE(AO)
  231. FLD -2 * SIZE(BO)
  232. fld %st(1)
  233. fmul %st(1), %st
  234. ADD1 %st, %st(3)
  235. FLD -1 * SIZE(BO)
  236. fmul %st, %st(2)
  237. FLD -1 * SIZE(AO)
  238. fmul %st, %st(2)
  239. fmulp %st, %st(1)
  240. ADD2 %st, %st(6)
  241. ADD3 %st, %st(3)
  242. ADD4 %st, %st(3)
  243. addq $8 * SIZE,AO
  244. addq $8 * SIZE,BO
  245. decq %rax
  246. jne .L12
  247. ALIGN_4
  248. .L15:
  249. #if defined(LT) || defined(RN)
  250. movq KK, %rax
  251. #else
  252. movq K, %rax
  253. subq KK, %rax
  254. #endif
  255. and $3, %rax
  256. je .L18
  257. ALIGN_4
  258. .L16:
  259. FLD -8 * SIZE(AO)
  260. FLD -8 * SIZE(BO)
  261. fld %st(1)
  262. fmul %st(1), %st
  263. ADD1 %st, %st(3)
  264. FLD -7 * SIZE(BO)
  265. fmul %st, %st(2)
  266. FLD -7 * SIZE(AO)
  267. fmul %st, %st(2)
  268. fmulp %st, %st(1)
  269. ADD2 %st, %st(6)
  270. ADD3 %st, %st(3)
  271. ADD4 %st, %st(3)
  272. addq $2 * SIZE,AO
  273. addq $2 * SIZE,BO
  274. decq %rax
  275. jne .L16
  276. ALIGN_4
  277. .L18:
  278. faddp %st, %st(3)
  279. faddp %st, %st(1)
  280. fxch %st(1)
  281. #if defined(LN) || defined(RT)
  282. movq KK, %rax
  283. #ifdef LN
  284. subq $1, %rax
  285. #else
  286. subq $1, %rax
  287. #endif
  288. salq $ZBASE_SHIFT, %rax
  289. movq AORIG, AO
  290. leaq (AO, %rax, 1), AO
  291. leaq (B, %rax, 1), BO
  292. #endif
  293. #if defined(LN) || defined(LT)
  294. FLD -8 * SIZE(BO)
  295. fsubp %st, %st(1)
  296. FLD -7 * SIZE(BO)
  297. fsubp %st, %st(2)
  298. #else
  299. FLD -8 * SIZE(AO)
  300. fsubp %st, %st(1)
  301. FLD -7 * SIZE(AO)
  302. fsubp %st, %st(2)
  303. #endif
  304. #if defined(LN) || defined(LT)
  305. FLD -8 * SIZE(AO)
  306. fmul %st(1), %st
  307. FLD -8 * SIZE(AO)
  308. fmul %st(3), %st
  309. FLD -7 * SIZE(AO)
  310. fmulp %st, %st(3)
  311. FLD -7 * SIZE(AO)
  312. fmulp %st, %st(4)
  313. #endif
  314. #if defined(RN) || defined(RT)
  315. FLD -8 * SIZE(BO)
  316. fmul %st(1), %st
  317. FLD -8 * SIZE(BO)
  318. fmul %st(3), %st
  319. FLD -7 * SIZE(BO)
  320. fmulp %st, %st(3)
  321. FLD -7 * SIZE(BO)
  322. fmulp %st, %st(4)
  323. #endif
  324. #ifndef CONJ
  325. faddp %st, %st(2)
  326. fsubp %st, %st(2)
  327. #else
  328. fsubp %st, %st(2)
  329. faddp %st, %st(2)
  330. #endif
  331. #if defined(LN) || defined(LT)
  332. fld %st
  333. FST -7 * SIZE(BO)
  334. fxch %st(1)
  335. fld %st
  336. FST -8 * SIZE(BO)
  337. #else
  338. fld %st
  339. FST -7 * SIZE(AO)
  340. fxch %st(1)
  341. fld %st
  342. FST -8 * SIZE(AO)
  343. #endif
  344. #ifdef LN
  345. subq $2 * SIZE, CO
  346. #endif
  347. FST 0 * SIZE(CO)
  348. FST 1 * SIZE(CO)
  349. #ifndef LN
  350. addq $2 * SIZE, CO
  351. #endif
  352. #if defined(LT) || defined(RN)
  353. movq K, %rax
  354. subq KK, %rax
  355. salq $ZBASE_SHIFT, %rax
  356. leaq (AO, %rax, 1), AO
  357. leaq (BO, %rax, 1), BO
  358. #endif
  359. #ifdef LN
  360. subq $1, KK
  361. #endif
  362. #ifdef LT
  363. addq $1, KK
  364. #endif
  365. #ifdef RT
  366. movq K, %rax
  367. salq $ZBASE_SHIFT, %rax
  368. addq %rax, AORIG
  369. #endif
  370. decq I
  371. jne .L11
  372. #ifdef LN
  373. movq K, %rax
  374. salq $ZBASE_SHIFT, %rax
  375. leaq (B, %rax, 1), B
  376. #endif
  377. #if defined(LT) || defined(RN)
  378. movq BO, B
  379. #endif
  380. #ifdef RN
  381. addq $1, KK
  382. #endif
  383. #ifdef RT
  384. subq $1, KK
  385. #endif
  386. decq J
  387. jne .L01
  388. ALIGN_4
  389. .L999:
  390. movq 0(%rsp), %rbx
  391. movq 8(%rsp), %rbp
  392. movq 16(%rsp), %r12
  393. movq 24(%rsp), %r13
  394. movq 32(%rsp), %r14
  395. movq 40(%rsp), %r15
  396. addq $STACKSIZE, %rsp
  397. ret
  398. EPILOGUE