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_4_sse.S 7.1 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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 12
  41. #define WPREFETCHSIZE (RPREFETCHSIZE * 4)
  42. #define PREFETCH prefetcht0
  43. #define PREFETCHW prefetcht2
  44. #define STACK 16
  45. #define ARGS 0
  46. #define M 4 + STACK + ARGS(%esp)
  47. #define N 8 + STACK + ARGS(%esp)
  48. #define ARG_A 12 + STACK + ARGS(%esp)
  49. #define ARG_LDA 16 + STACK + ARGS(%esp)
  50. #define ARG_B 20 + STACK + ARGS(%esp)
  51. #define A %eax
  52. #define B %ebx
  53. #define LDA %ebp
  54. #define A1 %ecx
  55. #define A2 %edx
  56. #define I %esi
  57. #define J %edi
  58. PROLOGUE
  59. pushl %ebp
  60. pushl %edi
  61. pushl %esi
  62. pushl %ebx
  63. PROFCODE
  64. movl ARG_A, A
  65. movl ARG_B, B
  66. movl ARG_LDA, LDA
  67. sall $BASE_SHIFT, LDA
  68. movl N, J
  69. sarl $2, J
  70. je .L20
  71. ALIGN_3
  72. .L10:
  73. movl A, A1
  74. leal (A, LDA, 2), A2
  75. leal (A, LDA, 4), A
  76. movl M, I
  77. sarl $2, I
  78. je .L15
  79. ALIGN_3
  80. .L12:
  81. PREFETCH RPREFETCHSIZE * SIZE(A1)
  82. movsd 0 * SIZE(A1) , %xmm0
  83. movhps 0 * SIZE(A1, LDA), %xmm0
  84. movsd 0 * SIZE(A2) , %xmm1
  85. movhps 0 * SIZE(A2, LDA), %xmm1
  86. PREFETCH RPREFETCHSIZE * SIZE(A1, LDA)
  87. movsd 1 * SIZE(A1) , %xmm2
  88. movhps 1 * SIZE(A1, LDA), %xmm2
  89. movsd 1 * SIZE(A2) , %xmm3
  90. movhps 1 * SIZE(A2, LDA), %xmm3
  91. PREFETCH RPREFETCHSIZE * SIZE(A2)
  92. movsd 2 * SIZE(A1) , %xmm4
  93. movhps 2 * SIZE(A1, LDA), %xmm4
  94. movsd 2 * SIZE(A2) , %xmm5
  95. movhps 2 * SIZE(A2, LDA), %xmm5
  96. PREFETCH RPREFETCHSIZE * SIZE(A2, LDA)
  97. movsd 3 * SIZE(A1) , %xmm6
  98. movhps 3 * SIZE(A1, LDA), %xmm6
  99. movsd 3 * SIZE(A2) , %xmm7
  100. movhps 3 * SIZE(A2, LDA), %xmm7
  101. PREFETCHW (RPREFETCHSIZE + 0) * SIZE(B)
  102. movaps %xmm0, 0 * SIZE(B)
  103. movaps %xmm1, 2 * SIZE(B)
  104. movaps %xmm2, 4 * SIZE(B)
  105. movaps %xmm3, 6 * SIZE(B)
  106. PREFETCHW (RPREFETCHSIZE + 8) * SIZE(B)
  107. movaps %xmm4, 8 * SIZE(B)
  108. movaps %xmm5, 10 * SIZE(B)
  109. movaps %xmm6, 12 * SIZE(B)
  110. movaps %xmm7, 14 * SIZE(B)
  111. addl $ 4 * SIZE, A1
  112. addl $ 4 * SIZE, A2
  113. subl $-16 * SIZE, B
  114. decl I
  115. jne .L12
  116. ALIGN_3
  117. .L15:
  118. testl $2, M
  119. jle .L16
  120. movsd 0 * SIZE(A1) , %xmm0
  121. movhps 0 * SIZE(A1, LDA), %xmm0
  122. movsd 0 * SIZE(A2) , %xmm1
  123. movhps 0 * SIZE(A2, LDA), %xmm1
  124. movsd 1 * SIZE(A1) , %xmm2
  125. movhps 1 * SIZE(A1, LDA), %xmm2
  126. movsd 1 * SIZE(A2) , %xmm3
  127. movhps 1 * SIZE(A2, LDA), %xmm3
  128. movaps %xmm0, 0 * SIZE(B)
  129. movaps %xmm1, 2 * SIZE(B)
  130. movaps %xmm2, 4 * SIZE(B)
  131. movaps %xmm3, 6 * SIZE(B)
  132. addl $ 2 * SIZE, A1
  133. addl $ 2 * SIZE, A2
  134. subl $-8 * SIZE, B
  135. ALIGN_4
  136. .L16:
  137. testl $1, M
  138. jle .L19
  139. movsd 0 * SIZE(A1) , %xmm0
  140. movhps 0 * SIZE(A1, LDA), %xmm0
  141. movsd 0 * SIZE(A2) , %xmm1
  142. movhps 0 * SIZE(A2, LDA), %xmm1
  143. movaps %xmm0, 0 * SIZE(B)
  144. movaps %xmm1, 2 * SIZE(B)
  145. subl $-4 * SIZE, B
  146. ALIGN_4
  147. .L19:
  148. decl J
  149. jne .L10
  150. ALIGN_3
  151. .L20:
  152. testl $2, N
  153. jle .L30
  154. movl A, A1
  155. leal (A, LDA, 2), A
  156. movl M, I
  157. sarl $2, I
  158. je .L25
  159. ALIGN_3
  160. .L22:
  161. PREFETCH RPREFETCHSIZE * SIZE(A1)
  162. movsd 0 * SIZE(A1) , %xmm0
  163. movhps 0 * SIZE(A1, LDA), %xmm0
  164. movsd 1 * SIZE(A1) , %xmm1
  165. movhps 1 * SIZE(A1, LDA), %xmm1
  166. PREFETCH RPREFETCHSIZE * SIZE(A1, LDA)
  167. movsd 2 * SIZE(A1) , %xmm2
  168. movhps 2 * SIZE(A1, LDA), %xmm2
  169. movsd 3 * SIZE(A1) , %xmm3
  170. movhps 3 * SIZE(A1, LDA), %xmm3
  171. PREFETCHW (RPREFETCHSIZE + 0) * SIZE(B)
  172. movaps %xmm0, 0 * SIZE(B)
  173. movaps %xmm1, 2 * SIZE(B)
  174. movaps %xmm2, 4 * SIZE(B)
  175. movaps %xmm3, 6 * SIZE(B)
  176. addl $ 4 * SIZE, A1
  177. subl $-8 * SIZE, B
  178. decl I
  179. jne .L22
  180. ALIGN_3
  181. .L25:
  182. testl $2, M
  183. jle .L26
  184. movsd 0 * SIZE(A1) , %xmm0
  185. movhps 0 * SIZE(A1, LDA), %xmm0
  186. movsd 1 * SIZE(A1) , %xmm1
  187. movhps 1 * SIZE(A1, LDA), %xmm1
  188. movaps %xmm0, 0 * SIZE(B)
  189. movaps %xmm1, 2 * SIZE(B)
  190. addl $ 2 * SIZE, A1
  191. addl $ 2 * SIZE, A2
  192. subl $-4 * SIZE, B
  193. ALIGN_4
  194. .L26:
  195. testl $1, M
  196. jle .L30
  197. movsd 0 * SIZE(A1) , %xmm0
  198. movhps 0 * SIZE(A1, LDA), %xmm0
  199. movaps %xmm0, 0 * SIZE(B)
  200. subl $-2 * SIZE, B
  201. ALIGN_4
  202. .L30:
  203. testl $1, N
  204. jle .L999
  205. movl A, A1
  206. movl M, I
  207. sarl $2, I
  208. je .L35
  209. ALIGN_3
  210. .L32:
  211. PREFETCH RPREFETCHSIZE * SIZE(A1)
  212. movsd 0 * SIZE(A1), %xmm0
  213. movhps 1 * SIZE(A1), %xmm0
  214. movsd 2 * SIZE(A1), %xmm1
  215. movhps 3 * SIZE(A1), %xmm1
  216. PREFETCHW (RPREFETCHSIZE + 0) * SIZE(B)
  217. movaps %xmm0, 0 * SIZE(B)
  218. movaps %xmm1, 2 * SIZE(B)
  219. addl $ 4 * SIZE, A1
  220. subl $-4 * SIZE, B
  221. decl I
  222. jne .L32
  223. ALIGN_3
  224. .L35:
  225. testl $2, M
  226. jle .L36
  227. movsd 0 * SIZE(A1), %xmm0
  228. movhps 1 * SIZE(A1), %xmm0
  229. movaps %xmm0, 0 * SIZE(B)
  230. addl $ 2 * SIZE, A1
  231. subl $-2 * SIZE, B
  232. ALIGN_4
  233. .L36:
  234. testl $1, M
  235. jle .L999
  236. movsd 0 * SIZE(A1), %xmm0
  237. movsd %xmm0, 0 * SIZE(B)
  238. ALIGN_4
  239. .L999:
  240. popl %ebx
  241. popl %esi
  242. popl %edi
  243. popl %ebp
  244. ret
  245. EPILOGUE