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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  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 8
  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. addl $4 * SIZE, 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 1 * SIZE(A1) , %xmm0
  84. movsd 2 * SIZE(A1) , %xmm1
  85. movhps 3 * SIZE(A1) , %xmm1
  86. PREFETCH RPREFETCHSIZE * SIZE(A1, LDA)
  87. movsd 0 * SIZE(A1, LDA), %xmm2
  88. movhps 1 * SIZE(A1, LDA), %xmm2
  89. movsd 2 * SIZE(A1, LDA), %xmm3
  90. movhps 3 * SIZE(A1, LDA), %xmm3
  91. PREFETCH RPREFETCHSIZE * SIZE(A2)
  92. movsd 0 * SIZE(A2) , %xmm4
  93. movhps 1 * SIZE(A2) , %xmm4
  94. movsd 2 * SIZE(A2) , %xmm5
  95. movhps 3 * SIZE(A2) , %xmm5
  96. PREFETCH RPREFETCHSIZE * SIZE(A2, LDA)
  97. movsd 0 * SIZE(A2, LDA), %xmm6
  98. movhps 1 * SIZE(A2, LDA), %xmm6
  99. movsd 2 * SIZE(A2, LDA), %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. leal (A1, LDA, 4), A1
  112. leal (A2, LDA, 4), 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 1 * SIZE(A1) , %xmm0
  122. movsd 2 * SIZE(A1) , %xmm1
  123. movhps 3 * SIZE(A1) , %xmm1
  124. movsd 0 * SIZE(A1, LDA), %xmm2
  125. movhps 1 * SIZE(A1, LDA), %xmm2
  126. movsd 2 * SIZE(A1, LDA), %xmm3
  127. movhps 3 * SIZE(A1, 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. leal (A1, LDA, 2), A1
  133. subl $-8 * SIZE, B
  134. ALIGN_4
  135. .L16:
  136. testl $1, M
  137. jle .L19
  138. movsd 0 * SIZE(A1) , %xmm0
  139. movhps 1 * SIZE(A1) , %xmm0
  140. movsd 2 * SIZE(A1) , %xmm1
  141. movhps 3 * SIZE(A1) , %xmm1
  142. movaps %xmm0, 0 * SIZE(B)
  143. movaps %xmm1, 2 * SIZE(B)
  144. subl $-4 * SIZE, B
  145. ALIGN_4
  146. .L19:
  147. decl J
  148. jne .L10
  149. ALIGN_3
  150. .L20:
  151. testl $2, N
  152. jle .L30
  153. movl A, A1
  154. leal (A, LDA, 2), A2
  155. addl $2 * SIZE, A
  156. movl M, I
  157. sarl $2, I
  158. je .L25
  159. ALIGN_3
  160. .L22:
  161. movsd 0 * SIZE(A1) , %xmm0
  162. movhps 1 * SIZE(A1) , %xmm0
  163. movsd 0 * SIZE(A1, LDA), %xmm1
  164. movhps 1 * SIZE(A1, LDA), %xmm1
  165. movsd 0 * SIZE(A2) , %xmm2
  166. movhps 1 * SIZE(A2) , %xmm2
  167. movsd 0 * SIZE(A2, LDA), %xmm3
  168. movhps 1 * SIZE(A2, LDA), %xmm3
  169. movaps %xmm0, 0 * SIZE(B)
  170. movaps %xmm1, 2 * SIZE(B)
  171. movaps %xmm2, 4 * SIZE(B)
  172. movaps %xmm3, 6 * SIZE(B)
  173. leal (A1, LDA, 4), A1
  174. leal (A2, LDA, 4), A2
  175. subl $-8 * SIZE, B
  176. decl I
  177. jne .L22
  178. ALIGN_3
  179. .L25:
  180. testl $2, M
  181. jle .L26
  182. movsd 0 * SIZE(A1) , %xmm0
  183. movhps 1 * SIZE(A1) , %xmm0
  184. movsd 0 * SIZE(A1, LDA), %xmm1
  185. movhps 1 * SIZE(A1, LDA), %xmm1
  186. movaps %xmm0, 0 * SIZE(B)
  187. movaps %xmm1, 2 * SIZE(B)
  188. leal (A1, LDA, 2), A1
  189. subl $-4 * SIZE, B
  190. ALIGN_4
  191. .L26:
  192. testl $1, M
  193. jle .L30
  194. movsd 0 * SIZE(A1) , %xmm0
  195. movhps 1 * SIZE(A1) , %xmm0
  196. movaps %xmm0, 0 * SIZE(B)
  197. subl $-2 * SIZE, B
  198. ALIGN_4
  199. .L30:
  200. testl $1, N
  201. jle .L999
  202. movl A, A1
  203. leal (A, LDA, 2), A2
  204. movl M, I
  205. sarl $2, I
  206. je .L35
  207. ALIGN_3
  208. .L32:
  209. movsd 0 * SIZE(A1) , %xmm0
  210. movhps 0 * SIZE(A1, LDA), %xmm0
  211. movsd 0 * SIZE(A2) , %xmm1
  212. movhps 0 * SIZE(A2, LDA), %xmm1
  213. movaps %xmm0, 0 * SIZE(B)
  214. movaps %xmm1, 2 * SIZE(B)
  215. leal (A1, LDA, 4), A1
  216. leal (A2, LDA, 4), A2
  217. subl $-4 * SIZE, B
  218. decl I
  219. jne .L32
  220. ALIGN_3
  221. .L35:
  222. testl $2, M
  223. jle .L36
  224. movsd 0 * SIZE(A1) , %xmm0
  225. movhps 0 * SIZE(A1, LDA), %xmm0
  226. movaps %xmm0, 0 * SIZE(B)
  227. leal (A1, LDA, 2), A1
  228. subl $-2 * SIZE, B
  229. ALIGN_4
  230. .L36:
  231. testl $1, M
  232. jle .L999
  233. movsd 0 * SIZE(A1) , %xmm0
  234. movsd %xmm0, 0 * SIZE(B)
  235. ALIGN_4
  236. .L999:
  237. popl %ebx
  238. popl %esi
  239. popl %edi
  240. popl %ebp
  241. ret
  242. EPILOGUE