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

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