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_ncopy_2.S 6.8 kB

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