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_atom.S 9.1 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  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 M 4 + STACK + ARGS(%esp)
  43. #define N 8 + STACK + ARGS(%esp)
  44. #define K 12 + STACK + ARGS(%esp)
  45. #define ALPHA_R 16 + STACK + ARGS(%esp)
  46. #define ALPHA_I 24 + STACK + ARGS(%esp)
  47. #define A 32 + STACK + ARGS(%esp)
  48. #define ARG_B 36 + STACK + ARGS(%esp)
  49. #define C 40 + STACK + ARGS(%esp)
  50. #define ARG_LDC 44 + STACK + ARGS(%esp)
  51. #define OFFSET 48 + STACK + ARGS(%esp)
  52. #define J 0 + STACK(%esp)
  53. #define KK 4 + STACK(%esp)
  54. #define KKK 8 + STACK(%esp)
  55. #define AORIG 12 + STACK(%esp)
  56. #define PREFETCH prefetcht0
  57. #define PREFETCHSIZE (8 * 8 + 3)
  58. #ifndef CONJ
  59. #define ADDSD1 addsd
  60. #define ADDSD2 addsd
  61. #define ADDSD3 addsd
  62. #define ADDSD4 subsd
  63. #elif defined(LN) || defined(LT)
  64. #define ADDSD1 addsd
  65. #define ADDSD2 addsd
  66. #define ADDSD3 subsd
  67. #define ADDSD4 addsd
  68. #else
  69. #define ADDSD1 addsd
  70. #define ADDSD2 subsd
  71. #define ADDSD3 addsd
  72. #define ADDSD4 addsd
  73. #endif
  74. #define AA %edx
  75. #define BB %ecx
  76. #define LDC %ebp
  77. #define B %edi
  78. #define CO1 %esi
  79. PROLOGUE
  80. subl $ARGS, %esp
  81. pushl %ebp
  82. pushl %edi
  83. pushl %esi
  84. pushl %ebx
  85. PROFCODE
  86. movl ARG_B, B
  87. movl ARG_LDC, LDC
  88. movl OFFSET, %eax
  89. #ifdef RN
  90. negl %eax
  91. #endif
  92. movl %eax, KK
  93. sall $ZBASE_SHIFT, LDC
  94. #ifdef LN
  95. movl M, %eax
  96. sall $ZBASE_SHIFT, %eax
  97. addl %eax, C
  98. imull K, %eax
  99. addl %eax, A
  100. #endif
  101. #ifdef RT
  102. movl N, %eax
  103. sall $ZBASE_SHIFT, %eax
  104. imull K, %eax
  105. addl %eax, B
  106. movl N, %eax
  107. imull LDC, %eax
  108. addl %eax, C
  109. #endif
  110. #ifdef RT
  111. movl N, %eax
  112. subl OFFSET, %eax
  113. movl %eax, KK
  114. #endif
  115. movl N, %eax
  116. testl %eax, %eax
  117. movl %eax, J # j = n
  118. jle .L999
  119. ALIGN_4
  120. .L01:
  121. #if defined(LT) || defined(RN)
  122. movl A, AA
  123. #else
  124. movl A, %eax
  125. movl %eax, AORIG
  126. #endif
  127. #ifdef RT
  128. movl K, %eax
  129. sall $ZBASE_SHIFT, %eax
  130. subl %eax, B
  131. #endif
  132. #ifdef RT
  133. subl LDC, C
  134. #endif
  135. movl C, CO1
  136. #ifndef RT
  137. addl LDC, C
  138. #endif
  139. #ifdef LN
  140. movl OFFSET, %eax
  141. addl M, %eax
  142. movl %eax, KK
  143. #endif
  144. #ifdef LT
  145. movl OFFSET, %eax
  146. movl %eax, KK
  147. #endif
  148. movl M, %ebx
  149. testl %ebx, %ebx
  150. jle .L99
  151. ALIGN_4
  152. .L10:
  153. #ifdef LN
  154. movl K, %eax
  155. sall $ZBASE_SHIFT, %eax
  156. subl %eax, AORIG
  157. #endif
  158. #if defined(LN) || defined(RT)
  159. movl KK, %eax
  160. movl AORIG, AA
  161. sall $ZBASE_SHIFT, %eax
  162. addl %eax, AA
  163. #endif
  164. movl B, BB
  165. #if defined(LN) || defined(RT)
  166. movl KK, %eax
  167. sall $ZBASE_SHIFT, %eax
  168. addl %eax, BB
  169. #endif
  170. movsd 0 * SIZE(AA), %xmm0
  171. xorps %xmm2, %xmm2
  172. xorps %xmm3, %xmm3
  173. xorps %xmm4, %xmm4
  174. prefetcht0 1 * SIZE(CO1)
  175. xorps %xmm5, %xmm5
  176. xorps %xmm6, %xmm6
  177. xorps %xmm7, %xmm7
  178. #if defined(LT) || defined(RN)
  179. movl KK, %eax
  180. #else
  181. movl K, %eax
  182. subl KK, %eax
  183. #endif
  184. sarl $2, %eax
  185. je .L15
  186. ALIGN_4
  187. .L12:
  188. PREFETCH (PREFETCHSIZE + 0) * SIZE(AA)
  189. ADDSD3 %xmm2, %xmm6
  190. movsd 1 * SIZE(AA), %xmm2
  191. movaps %xmm0, %xmm1
  192. mulsd 0 * SIZE(BB), %xmm0
  193. ADDSD4 %xmm3, %xmm7
  194. mulsd 1 * SIZE(BB), %xmm1
  195. ADDSD1 %xmm0, %xmm4
  196. movsd 2 * SIZE(AA), %xmm0
  197. movaps %xmm2, %xmm3
  198. mulsd 0 * SIZE(BB), %xmm2
  199. ADDSD2 %xmm1, %xmm5
  200. mulsd 1 * SIZE(BB), %xmm3
  201. ADDSD3 %xmm2, %xmm6
  202. movsd 3 * SIZE(AA), %xmm2
  203. movaps %xmm0, %xmm1
  204. mulsd 2 * SIZE(BB), %xmm0
  205. ADDSD4 %xmm3, %xmm7
  206. mulsd 3 * SIZE(BB), %xmm1
  207. ADDSD1 %xmm0, %xmm4
  208. movsd 4 * SIZE(AA), %xmm0
  209. movaps %xmm2, %xmm3
  210. mulsd 2 * SIZE(BB), %xmm2
  211. ADDSD2 %xmm1, %xmm5
  212. mulsd 3 * SIZE(BB), %xmm3
  213. ADDSD3 %xmm2, %xmm6
  214. movsd 5 * SIZE(AA), %xmm2
  215. movaps %xmm0, %xmm1
  216. mulsd 4 * SIZE(BB), %xmm0
  217. ADDSD4 %xmm3, %xmm7
  218. mulsd 5 * SIZE(BB), %xmm1
  219. ADDSD1 %xmm0, %xmm4
  220. movsd 6 * SIZE(AA), %xmm0
  221. movaps %xmm2, %xmm3
  222. mulsd 4 * SIZE(BB), %xmm2
  223. ADDSD2 %xmm1, %xmm5
  224. mulsd 5 * SIZE(BB), %xmm3
  225. ADDSD3 %xmm2, %xmm6
  226. movsd 7 * SIZE(AA), %xmm2
  227. movaps %xmm0, %xmm1
  228. mulsd 6 * SIZE(BB), %xmm0
  229. ADDSD4 %xmm3, %xmm7
  230. mulsd 7 * SIZE(BB), %xmm1
  231. ADDSD1 %xmm0, %xmm4
  232. movsd 8 * SIZE(AA), %xmm0
  233. movaps %xmm2, %xmm3
  234. mulsd 6 * SIZE(BB), %xmm2
  235. ADDSD2 %xmm1, %xmm5
  236. mulsd 7 * SIZE(BB), %xmm3
  237. addl $8 * SIZE, BB
  238. addl $8 * SIZE, AA
  239. decl %eax
  240. jne .L12
  241. ALIGN_4
  242. .L15:
  243. #if defined(LT) || defined(RN)
  244. movl KK, %eax
  245. #else
  246. movl K, %eax
  247. subl KK, %eax
  248. #endif
  249. andl $3, %eax # if (k & 1)
  250. BRANCH
  251. je .L18
  252. ALIGN_3
  253. .L16:
  254. ADDSD3 %xmm2, %xmm6
  255. movsd 1 * SIZE(AA), %xmm2
  256. movaps %xmm0, %xmm1
  257. mulsd 0 * SIZE(BB), %xmm0
  258. ADDSD4 %xmm3, %xmm7
  259. mulsd 1 * SIZE(BB), %xmm1
  260. ADDSD1 %xmm0, %xmm4
  261. movsd 2 * SIZE(AA), %xmm0
  262. movaps %xmm2, %xmm3
  263. mulsd 0 * SIZE(BB), %xmm2
  264. ADDSD2 %xmm1, %xmm5
  265. mulsd 1 * SIZE(BB), %xmm3
  266. addl $2 * SIZE, AA
  267. addl $2 * SIZE, BB
  268. decl %eax
  269. jg .L16
  270. ALIGN_4
  271. .L18:
  272. ADDSD3 %xmm2, %xmm6
  273. ADDSD4 %xmm3, %xmm7
  274. addsd %xmm7, %xmm4
  275. addsd %xmm5, %xmm6
  276. #if defined(LN) || defined(RT)
  277. movl KK, %eax
  278. subl $1, %eax
  279. movl AORIG, AA
  280. sall $ZBASE_SHIFT, %eax
  281. leal (AA, %eax, 1), AA
  282. leal (B, %eax, 1), BB
  283. #endif
  284. #if defined(LN) || defined(LT)
  285. movsd 0 * SIZE(BB), %xmm0
  286. movsd 1 * SIZE(BB), %xmm1
  287. #else
  288. movsd 0 * SIZE(AA), %xmm0
  289. movsd 1 * SIZE(AA), %xmm1
  290. #endif
  291. subsd %xmm4, %xmm0
  292. subsd %xmm6, %xmm1
  293. #if defined(LN) || defined(LT)
  294. movsd 0 * SIZE(AA), %xmm6
  295. movaps %xmm0, %xmm5
  296. movsd 1 * SIZE(AA), %xmm7
  297. movaps %xmm1, %xmm4
  298. mulsd %xmm6, %xmm0
  299. mulsd %xmm6, %xmm1
  300. mulsd %xmm7, %xmm5
  301. mulsd %xmm7, %xmm4
  302. ADDSD4 %xmm4, %xmm0
  303. ADDSD3 %xmm5, %xmm1
  304. #endif
  305. #if defined(RN) || defined(RT)
  306. movsd 0 * SIZE(BB), %xmm6
  307. movaps %xmm0, %xmm5
  308. movsd 1 * SIZE(BB), %xmm7
  309. movaps %xmm1, %xmm4
  310. mulsd %xmm6, %xmm0
  311. mulsd %xmm6, %xmm1
  312. mulsd %xmm7, %xmm5
  313. mulsd %xmm7, %xmm4
  314. ADDSD4 %xmm4, %xmm0
  315. ADDSD2 %xmm5, %xmm1
  316. #endif
  317. #ifdef LN
  318. subl $2 * SIZE, CO1
  319. #endif
  320. movsd %xmm0, 0 * SIZE(CO1)
  321. movsd %xmm1, 1 * SIZE(CO1)
  322. #if defined(LN) || defined(LT)
  323. movsd %xmm0, 0 * SIZE(BB)
  324. movsd %xmm1, 1 * SIZE(BB)
  325. #else
  326. movsd %xmm0, 0 * SIZE(AA)
  327. movsd %xmm1, 1 * SIZE(AA)
  328. #endif
  329. #ifndef LN
  330. addl $2 * SIZE, CO1
  331. #endif
  332. #if defined(LT) || defined(RN)
  333. movl K, %eax
  334. subl KK, %eax
  335. sall $ZBASE_SHIFT, %eax
  336. addl %eax, AA
  337. addl %eax, BB
  338. #endif
  339. #ifdef LN
  340. subl $1, KK
  341. #endif
  342. #ifdef LT
  343. addl $1, KK
  344. #endif
  345. #ifdef RT
  346. movl K, %eax
  347. sall $ZBASE_SHIFT, %eax
  348. addl %eax, AORIG
  349. #endif
  350. decl %ebx # i --
  351. jg .L10
  352. ALIGN_4
  353. .L99:
  354. #ifdef LN
  355. movl K, %eax
  356. sall $ZBASE_SHIFT, %eax
  357. addl %eax, B
  358. #endif
  359. #if defined(LT) || defined(RN)
  360. movl BB, B
  361. #endif
  362. #ifdef RN
  363. addl $1, KK
  364. #endif
  365. #ifdef RT
  366. subl $1, KK
  367. #endif
  368. decl J # j --
  369. jg .L01
  370. ALIGN_4
  371. .L999:
  372. popl %ebx
  373. popl %esi
  374. popl %edi
  375. popl %ebp
  376. addl $ARGS, %esp
  377. ret
  378. EPILOGUE