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.

zgemm_tcopy_2.S 9.5 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  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 RPREFETCHSIZE 32
  41. #define WPREFETCHSIZE 16
  42. #ifndef WINDOWS_ABI
  43. #define M ARG1 /* rdi */
  44. #define N ARG2 /* rsi */
  45. #define A ARG3 /* rdx */
  46. #define LDA ARG4 /* rcx */
  47. #define B ARG5 /* r8 */
  48. #define I %r9
  49. #define J %r10
  50. #define AO1 %r11
  51. #define AO2 %r12
  52. #define BO1 %r13
  53. #define M8 %r14
  54. #define BO %rax
  55. #else
  56. #define STACKSIZE 256
  57. #define M ARG1 /* rcx */
  58. #define N ARG2 /* rdx */
  59. #define A ARG3 /* r8 */
  60. #define LDA ARG4 /* r9 */
  61. #define OLD_B 40 + 48 + STACKSIZE(%rsp)
  62. #define B %r10
  63. #define I %r11
  64. #define J %r12
  65. #define AO1 %r13
  66. #define AO2 %r14
  67. #define BO1 %rdi
  68. #define M8 %rsi
  69. #define BO %rax
  70. #endif
  71. PROLOGUE
  72. PROFCODE
  73. #ifdef WINDOWS_ABI
  74. pushq %rdi
  75. pushq %rsi
  76. #endif
  77. pushq %r14
  78. pushq %r13
  79. pushq %r12
  80. pushq %r11
  81. #ifdef WINDOWS_ABI
  82. subq $STACKSIZE, %rsp
  83. movups %xmm6, 0(%rsp)
  84. movups %xmm7, 16(%rsp)
  85. movups %xmm8, 32(%rsp)
  86. movups %xmm9, 48(%rsp)
  87. movups %xmm10, 64(%rsp)
  88. movups %xmm11, 80(%rsp)
  89. movups %xmm12, 96(%rsp)
  90. movups %xmm13, 112(%rsp)
  91. movups %xmm14, 128(%rsp)
  92. movups %xmm15, 144(%rsp)
  93. movq OLD_B, B
  94. #endif
  95. movq N, %rax
  96. andq $-2, %rax
  97. imulq M, %rax
  98. salq $ZBASE_SHIFT, %rax
  99. leaq (B, %rax, 1), BO1
  100. salq $ZBASE_SHIFT, LDA
  101. leaq (, M, SIZE), M8
  102. movq M, J
  103. sarq $1, J
  104. jle .L20
  105. ALIGN_4
  106. .L11:
  107. movq A, AO1
  108. leaq (A, LDA ), AO2
  109. leaq (A, LDA, 2), A
  110. movq B, BO
  111. addq $8 * SIZE, B
  112. movq N, I
  113. sarq $2, I
  114. jle .L13
  115. ALIGN_4
  116. .L12:
  117. #ifndef DOUBLE
  118. movlps 0 * SIZE(AO1), %xmm0
  119. movhps 2 * SIZE(AO1), %xmm0
  120. movlps 4 * SIZE(AO1), %xmm1
  121. movhps 6 * SIZE(AO1), %xmm1
  122. movlps 0 * SIZE(AO2), %xmm2
  123. movhps 2 * SIZE(AO2), %xmm2
  124. movlps 4 * SIZE(AO2), %xmm3
  125. movhps 6 * SIZE(AO2), %xmm3
  126. #if defined(PENTIUM4) || defined(GENERIC) || defined(NANO)
  127. prefetcht0 RPREFETCHSIZE * SIZE(AO1)
  128. prefetcht0 RPREFETCHSIZE * SIZE(AO2)
  129. prefetcht0 WPREFETCHSIZE * SIZE(BO)
  130. #endif
  131. #ifdef HAVE_3DNOW
  132. prefetchw (WPREFETCHSIZE + 0) * SIZE(BO)
  133. #endif
  134. movaps %xmm0, 0 * SIZE(BO)
  135. movaps %xmm2, 4 * SIZE(BO)
  136. leaq (BO, M8, 4), BO
  137. movaps %xmm1, 0 * SIZE(BO)
  138. movaps %xmm3, 4 * SIZE(BO)
  139. #else
  140. movsd 0 * SIZE(AO1), %xmm0
  141. movhpd 1 * SIZE(AO1), %xmm0
  142. movsd 2 * SIZE(AO1), %xmm1
  143. movhpd 3 * SIZE(AO1), %xmm1
  144. #if defined(CORE2) || defined(PENRYN) || defined(DUNNINGTON)
  145. prefetcht2 RPREFETCHSIZE * SIZE(AO1)
  146. #endif
  147. movsd 4 * SIZE(AO1), %xmm2
  148. movhpd 5 * SIZE(AO1), %xmm2
  149. movsd 6 * SIZE(AO1), %xmm3
  150. movhpd 7 * SIZE(AO1), %xmm3
  151. movsd 0 * SIZE(AO2), %xmm4
  152. movhpd 1 * SIZE(AO2), %xmm4
  153. movsd 2 * SIZE(AO2), %xmm5
  154. movhpd 3 * SIZE(AO2), %xmm5
  155. #if defined(CORE2) || defined(PENRYN) || defined(DUNNINGTON)
  156. prefetcht2 RPREFETCHSIZE * SIZE(AO2)
  157. #endif
  158. movsd 4 * SIZE(AO2), %xmm6
  159. movhpd 5 * SIZE(AO2), %xmm6
  160. movsd 6 * SIZE(AO2), %xmm7
  161. movhpd 7 * SIZE(AO2), %xmm7
  162. #if defined(PENTIUM4) || defined(GENERIC) || defined(NANO)
  163. prefetcht0 RPREFETCHSIZE * SIZE(AO1)
  164. prefetcht0 RPREFETCHSIZE * SIZE(AO2)
  165. prefetcht0 WPREFETCHSIZE * SIZE(BO)
  166. #endif
  167. #ifdef HAVE_3DNOW
  168. prefetchw (WPREFETCHSIZE + 0) * SIZE(BO)
  169. prefetchw (WPREFETCHSIZE + 8) * SIZE(BO)
  170. #endif
  171. movapd %xmm0, 0 * SIZE(BO)
  172. movapd %xmm1, 2 * SIZE(BO)
  173. movapd %xmm4, 4 * SIZE(BO)
  174. movapd %xmm5, 6 * SIZE(BO)
  175. #if defined(CORE2) || defined(PENRYN) || defined(DUNNINGTON)
  176. prefetcht2 WPREFETCHSIZE * SIZE(BO)
  177. #endif
  178. leaq (BO, M8, 4), BO
  179. movapd %xmm2, 0 * SIZE(BO)
  180. movapd %xmm3, 2 * SIZE(BO)
  181. movapd %xmm6, 4 * SIZE(BO)
  182. movapd %xmm7, 6 * SIZE(BO)
  183. #endif
  184. addq $8 * SIZE, AO1
  185. addq $8 * SIZE, AO2
  186. leaq (BO, M8, 4), BO
  187. decq I
  188. jg .L12
  189. ALIGN_4
  190. .L13:
  191. testq $2, N
  192. jle .L14
  193. #ifndef DOUBLE
  194. movlps 0 * SIZE(AO1), %xmm0
  195. movhps 2 * SIZE(AO1), %xmm0
  196. movlps 0 * SIZE(AO2), %xmm1
  197. movhps 2 * SIZE(AO2), %xmm1
  198. movaps %xmm0, 0 * SIZE(BO)
  199. movaps %xmm1, 4 * SIZE(BO)
  200. #else
  201. movsd 0 * SIZE(AO1), %xmm0
  202. movhpd 1 * SIZE(AO1), %xmm0
  203. movsd 2 * SIZE(AO1), %xmm1
  204. movhpd 3 * SIZE(AO1), %xmm1
  205. movsd 0 * SIZE(AO2), %xmm2
  206. movhpd 1 * SIZE(AO2), %xmm2
  207. movsd 2 * SIZE(AO2), %xmm3
  208. movhpd 3 * SIZE(AO2), %xmm3
  209. movapd %xmm0, 0 * SIZE(BO)
  210. movapd %xmm1, 2 * SIZE(BO)
  211. movapd %xmm2, 4 * SIZE(BO)
  212. movapd %xmm3, 6 * SIZE(BO)
  213. #endif
  214. addq $4 * SIZE, AO1
  215. addq $4 * SIZE, AO2
  216. leaq (BO, M8, 4), BO
  217. ALIGN_4
  218. .L14:
  219. testq $1, N
  220. jle .L19
  221. #ifndef DOUBLE
  222. movlps 0 * SIZE(AO1), %xmm0
  223. movhps 0 * SIZE(AO2), %xmm0
  224. movaps %xmm0, 0 * SIZE(BO1)
  225. #else
  226. movsd 0 * SIZE(AO1), %xmm0
  227. movhpd 1 * SIZE(AO1), %xmm0
  228. movsd 0 * SIZE(AO2), %xmm1
  229. movhpd 1 * SIZE(AO2), %xmm1
  230. movapd %xmm0, 0 * SIZE(BO1)
  231. movapd %xmm1, 2 * SIZE(BO1)
  232. #endif
  233. addq $4 * SIZE, BO1
  234. ALIGN_4
  235. .L19:
  236. decq J
  237. jg .L11
  238. ALIGN_4
  239. .L20:
  240. testq $1, M
  241. jle .L999
  242. ALIGN_4
  243. .L21:
  244. movq A, AO1
  245. movq B, BO
  246. movq N, I
  247. sarq $2, I
  248. jle .L23
  249. ALIGN_4
  250. .L22:
  251. #ifndef DOUBLE
  252. movlps 0 * SIZE(AO1), %xmm0
  253. movhps 2 * SIZE(AO1), %xmm0
  254. movlps 4 * SIZE(AO1), %xmm1
  255. movhps 6 * SIZE(AO1), %xmm1
  256. #if defined(PENTIUM4) || defined(GENERIC) || defined(NANO)
  257. prefetcht0 RPREFETCHSIZE * SIZE(AO1)
  258. prefetcht0 WPREFETCHSIZE * SIZE(BO)
  259. #endif
  260. #ifdef HAVE_3DNOW
  261. prefetchw (WPREFETCHSIZE + 0) * SIZE(BO)
  262. #endif
  263. movaps %xmm0, 0 * SIZE(BO)
  264. leaq (BO, M8, 4), BO
  265. movaps %xmm1, 0 * SIZE(BO)
  266. #else
  267. movsd 0 * SIZE(AO1), %xmm0
  268. movhpd 1 * SIZE(AO1), %xmm0
  269. movsd 2 * SIZE(AO1), %xmm1
  270. movhpd 3 * SIZE(AO1), %xmm1
  271. movsd 4 * SIZE(AO1), %xmm2
  272. movhpd 5 * SIZE(AO1), %xmm2
  273. movsd 6 * SIZE(AO1), %xmm3
  274. movhpd 7 * SIZE(AO1), %xmm3
  275. #if defined(PENTIUM4) || defined(GENERIC) || defined(NANO)
  276. prefetcht0 RPREFETCHSIZE * SIZE(AO1)
  277. prefetcht0 WPREFETCHSIZE * SIZE(BO)
  278. #endif
  279. #ifdef HAVE_3DNOW
  280. prefetchw (WPREFETCHSIZE + 0) * SIZE(BO)
  281. #endif
  282. movapd %xmm0, 0 * SIZE(BO)
  283. movapd %xmm1, 2 * SIZE(BO)
  284. leaq (BO, M8, 4), BO
  285. movapd %xmm2, 0 * SIZE(BO)
  286. movapd %xmm3, 2 * SIZE(BO)
  287. #endif
  288. addq $8 * SIZE, AO1
  289. leaq (BO, M8, 4), BO
  290. decq I
  291. jg .L22
  292. ALIGN_4
  293. .L23:
  294. testq $2, N
  295. jle .L24
  296. #ifndef DOUBLE
  297. movlps 0 * SIZE(AO1), %xmm0
  298. movhps 2 * SIZE(AO1), %xmm0
  299. movaps %xmm0, 0 * SIZE(BO)
  300. #else
  301. movsd 0 * SIZE(AO1), %xmm0
  302. movhpd 1 * SIZE(AO1), %xmm0
  303. movsd 2 * SIZE(AO1), %xmm1
  304. movhpd 3 * SIZE(AO1), %xmm1
  305. movapd %xmm0, 0 * SIZE(BO)
  306. movapd %xmm1, 2 * SIZE(BO)
  307. #endif
  308. addq $4 * SIZE, AO1
  309. leaq (BO, M8, 4), BO
  310. ALIGN_4
  311. .L24:
  312. testq $1, N
  313. jle .L999
  314. #ifndef DOUBLE
  315. movlps 0 * SIZE(AO1), %xmm0
  316. movlps %xmm0, 0 * SIZE(BO1)
  317. #else
  318. movsd 0 * SIZE(AO1), %xmm0
  319. movhpd 1 * SIZE(AO1), %xmm0
  320. movapd %xmm0, 0 * SIZE(BO1)
  321. #endif
  322. ALIGN_4
  323. .L999:
  324. #ifdef WINDOWS_ABI
  325. movups 0(%rsp), %xmm6
  326. movups 16(%rsp), %xmm7
  327. movups 32(%rsp), %xmm8
  328. movups 48(%rsp), %xmm9
  329. movups 64(%rsp), %xmm10
  330. movups 80(%rsp), %xmm11
  331. movups 96(%rsp), %xmm12
  332. movups 112(%rsp), %xmm13
  333. movups 128(%rsp), %xmm14
  334. movups 144(%rsp), %xmm15
  335. addq $STACKSIZE, %rsp
  336. #endif
  337. popq %r11
  338. popq %r12
  339. popq %r13
  340. popq %r14
  341. #ifdef WINDOWS_ABI
  342. popq %rsi
  343. popq %rdi
  344. #endif
  345. ret
  346. EPILOGUE