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.

gemm_tcopy_2.S 6.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  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. #if defined(NEHALEM)
  41. #define RPREFETCHSIZE 12
  42. #define WPREFETCHSIZE (RPREFETCHSIZE * 2)
  43. #define PREFETCH prefetcht0
  44. #define PREFETCHW prefetcht0
  45. #endif
  46. #if defined(SANDYBRIDGE)
  47. #define RPREFETCHSIZE 12
  48. #define WPREFETCHSIZE (RPREFETCHSIZE * 2)
  49. #define PREFETCH prefetcht0
  50. #define PREFETCHW prefetcht0
  51. #endif
  52. #ifndef WINDOWS_ABI
  53. #define M ARG1 /* rdi */
  54. #define N ARG2 /* rsi */
  55. #define A ARG3 /* rdx */
  56. #define LDA ARG4 /* rcx */
  57. #define B ARG5 /* r8 */
  58. #define I %r10
  59. #define J %rbp
  60. #define AO1 %r9
  61. #define AO2 %r15
  62. #define AO3 %r11
  63. #define AO4 %r14
  64. #define BO1 %r13
  65. #define M8 %rbx
  66. #define BO %rax
  67. #else
  68. #define STACKSIZE 256
  69. #define M ARG1 /* rcx */
  70. #define N ARG2 /* rdx */
  71. #define A ARG3 /* r8 */
  72. #define LDA ARG4 /* r9 */
  73. #define OLD_B 40 + 64 + STACKSIZE(%rsp)
  74. #define B %rdi
  75. #define I %r10
  76. #define J %r11
  77. #define AO1 %r12
  78. #define AO2 %r13
  79. #define AO3 %r14
  80. #define AO4 %r15
  81. #define BO1 %rsi
  82. #define M8 %rbp
  83. #define BO %rax
  84. #endif
  85. PROLOGUE
  86. PROFCODE
  87. #ifdef WINDOWS_ABI
  88. pushq %rdi
  89. pushq %rsi
  90. #endif
  91. pushq %r15
  92. pushq %r14
  93. pushq %r13
  94. pushq %r12
  95. pushq %rbp
  96. pushq %rbx
  97. #ifdef WINDOWS_ABI
  98. subq $STACKSIZE, %rsp
  99. movups %xmm6, 0(%rsp)
  100. movups %xmm7, 16(%rsp)
  101. movups %xmm8, 32(%rsp)
  102. movups %xmm9, 48(%rsp)
  103. movups %xmm10, 64(%rsp)
  104. movups %xmm11, 80(%rsp)
  105. movups %xmm12, 96(%rsp)
  106. movups %xmm13, 112(%rsp)
  107. movups %xmm14, 128(%rsp)
  108. movups %xmm15, 144(%rsp)
  109. movq OLD_B, B
  110. #endif
  111. movq N, %rax
  112. andq $-2, %rax
  113. imulq M, %rax
  114. leaq (B, %rax, SIZE), BO1
  115. leaq (, LDA, SIZE), LDA
  116. leaq (, M, SIZE), M8
  117. movq M, J
  118. sarq $1, J
  119. jle .L20
  120. ALIGN_4
  121. .L11:
  122. movq A, AO1
  123. leaq (A, LDA ), AO2
  124. leaq (A, LDA, 2), A
  125. movq B, BO
  126. addq $4 * SIZE, B
  127. movq N, I
  128. sarq $1, I
  129. jle .L14
  130. ALIGN_4
  131. .L12:
  132. #ifndef DOUBLE
  133. movlps 0 * SIZE(AO1), %xmm0
  134. movhps 0 * SIZE(AO2), %xmm0
  135. movaps %xmm0, 0 * SIZE(BO)
  136. #else
  137. PREFETCH RPREFETCHSIZE * SIZE(AO1)
  138. movsd 0 * SIZE(AO1), %xmm0
  139. movhpd 1 * SIZE(AO1), %xmm0
  140. PREFETCH RPREFETCHSIZE * SIZE(AO2)
  141. movsd 0 * SIZE(AO2), %xmm1
  142. movhpd 1 * SIZE(AO2), %xmm1
  143. PREFETCHW WPREFETCHSIZE * SIZE(BO)
  144. movapd %xmm0, 0 * SIZE(BO)
  145. movapd %xmm1, 2 * SIZE(BO)
  146. #endif
  147. leaq (BO, M8, 2), BO
  148. addq $2 * SIZE, AO1
  149. addq $2 * SIZE, AO2
  150. decq I
  151. jg .L12
  152. ALIGN_4
  153. .L14:
  154. testq $1, N
  155. jle .L19
  156. #ifndef DOUBLE
  157. movss 0 * SIZE(AO1), %xmm0
  158. movss 0 * SIZE(AO2), %xmm1
  159. movss %xmm0, 0 * SIZE(BO1)
  160. movss %xmm1, 1 * SIZE(BO1)
  161. #else
  162. movsd 0 * SIZE(AO1), %xmm0
  163. movhpd 0 * SIZE(AO2), %xmm0
  164. movapd %xmm0, 0 * SIZE(BO1)
  165. #endif
  166. addq $2 * SIZE, BO1
  167. ALIGN_4
  168. .L19:
  169. decq J
  170. jg .L11
  171. ALIGN_4
  172. .L20:
  173. testq $1, M
  174. jle .L999
  175. ALIGN_4
  176. .L31:
  177. movq A, AO1
  178. movq B, BO
  179. movq N, I
  180. sarq $1, I
  181. jle .L33
  182. ALIGN_4
  183. .L32:
  184. #ifndef DOUBLE
  185. movsd 0 * SIZE(AO1), %xmm0
  186. movsd %xmm0, 0 * SIZE(BO)
  187. #else
  188. movsd 0 * SIZE(AO1), %xmm0
  189. movhpd 1 * SIZE(AO1), %xmm0
  190. movapd %xmm0, 0 * SIZE(BO)
  191. #endif
  192. addq $2 * SIZE, AO1
  193. leaq (BO, M8, 2), BO
  194. decq I
  195. jg .L32
  196. ALIGN_4
  197. .L33:
  198. testq $1, N
  199. jle .L999
  200. #ifndef DOUBLE
  201. movss 0 * SIZE(AO1), %xmm0
  202. movss %xmm0, 0 * SIZE(BO1)
  203. #else
  204. movsd 0 * SIZE(AO1), %xmm0
  205. movsd %xmm0, 0 * SIZE(BO1)
  206. #endif
  207. addq $1 * SIZE, BO1
  208. ALIGN_4
  209. .L999:
  210. #ifdef WINDOWS_ABI
  211. movups 0(%rsp), %xmm6
  212. movups 16(%rsp), %xmm7
  213. movups 32(%rsp), %xmm8
  214. movups 48(%rsp), %xmm9
  215. movups 64(%rsp), %xmm10
  216. movups 80(%rsp), %xmm11
  217. movups 96(%rsp), %xmm12
  218. movups 112(%rsp), %xmm13
  219. movups 128(%rsp), %xmm14
  220. movups 144(%rsp), %xmm15
  221. addq $STACKSIZE, %rsp
  222. #endif
  223. popq %rbx
  224. popq %rbp
  225. popq %r12
  226. popq %r13
  227. popq %r14
  228. popq %r15
  229. #ifdef WINDOWS_ABI
  230. popq %rsi
  231. popq %rdi
  232. #endif
  233. ret
  234. EPILOGUE