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_beta.S 5.6 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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. #ifndef WINDOWS_ABI
  41. #define M ARG1
  42. #define N ARG2
  43. #define C ARG3
  44. #define LDC ARG4
  45. #define C1 ARG5
  46. #define STACK_C 16(%rsp)
  47. #define STACK_LDC 24(%rsp)
  48. #else
  49. #define STACKSIZE 256
  50. #define M ARG1
  51. #define N ARG2
  52. #define C ARG3
  53. #define LDC ARG4
  54. #define C1 %r10
  55. #define STACK_C 72 + STACKSIZE(%rsp)
  56. #define STACK_LDC 80 + STACKSIZE(%rsp)
  57. #endif
  58. #define I %rax
  59. PROLOGUE
  60. PROFCODE
  61. #ifdef WINDOWS_ABI
  62. subq $STACKSIZE, %rsp
  63. movups %xmm6, 0(%rsp)
  64. movups %xmm7, 16(%rsp)
  65. movups %xmm8, 32(%rsp)
  66. movups %xmm9, 48(%rsp)
  67. movups %xmm10, 64(%rsp)
  68. movups %xmm11, 80(%rsp)
  69. movups %xmm12, 96(%rsp)
  70. movups %xmm13, 112(%rsp)
  71. movups %xmm14, 128(%rsp)
  72. movups %xmm15, 144(%rsp)
  73. movaps %xmm3, %xmm0
  74. #endif
  75. movq STACK_C, C
  76. movq STACK_LDC, LDC
  77. pxor %xmm1, %xmm1
  78. test M, M
  79. jle .L999
  80. test N, N
  81. jle .L999
  82. #ifdef DOUBLE
  83. ucomisd %xmm1, %xmm0
  84. #else
  85. ucomiss %xmm1, %xmm0
  86. #endif
  87. jne .L201
  88. ALIGN_4
  89. .L101:
  90. movq C, C1
  91. leaq (C, LDC, SIZE), C
  92. movq M, I
  93. sarq $3, I
  94. jle .L103
  95. ALIGN_4
  96. .L102:
  97. #ifdef OPTERON
  98. prefetchw 32 * SIZE(C1)
  99. #endif
  100. MOVSD %xmm0, 0 * SIZE(C1)
  101. MOVSD %xmm0, 1 * SIZE(C1)
  102. MOVSD %xmm0, 2 * SIZE(C1)
  103. MOVSD %xmm0, 3 * SIZE(C1)
  104. MOVSD %xmm0, 4 * SIZE(C1)
  105. MOVSD %xmm0, 5 * SIZE(C1)
  106. MOVSD %xmm0, 6 * SIZE(C1)
  107. MOVSD %xmm0, 7 * SIZE(C1)
  108. addq $8 * SIZE, C1
  109. decq I
  110. jg .L102
  111. ALIGN_4
  112. .L103:
  113. movq M, I
  114. andq $7, I
  115. jle .L105
  116. ALIGN_4
  117. .L104:
  118. MOVSD %xmm0, 0 * SIZE(C1)
  119. addq $SIZE, C1
  120. decq I
  121. jg .L104
  122. ALIGN_4
  123. .L105:
  124. decq N
  125. jg .L101
  126. jmp .L999
  127. ALIGN_3
  128. .L201:
  129. movq C, C1 # c_offset = c
  130. leaq (C, LDC, SIZE), C # c += ldc
  131. movq M, I
  132. sarq $3, I
  133. jle .L203
  134. ALIGN_4
  135. .L202:
  136. #ifdef OPTERON
  137. prefetchw 32 * SIZE(C1)
  138. #endif
  139. MOVSD 0 * SIZE(C1), %xmm8
  140. MOVSD 1 * SIZE(C1), %xmm9
  141. MOVSD 2 * SIZE(C1), %xmm10
  142. MOVSD 3 * SIZE(C1), %xmm11
  143. MOVSD 4 * SIZE(C1), %xmm12
  144. MOVSD 5 * SIZE(C1), %xmm13
  145. MOVSD 6 * SIZE(C1), %xmm14
  146. MOVSD 7 * SIZE(C1), %xmm15
  147. MULSD %xmm0, %xmm8
  148. MULSD %xmm0, %xmm9
  149. MULSD %xmm0, %xmm10
  150. MULSD %xmm0, %xmm11
  151. MULSD %xmm0, %xmm12
  152. MULSD %xmm0, %xmm13
  153. MULSD %xmm0, %xmm14
  154. MULSD %xmm0, %xmm15
  155. MOVSD %xmm8, 0 * SIZE(C1)
  156. MOVSD %xmm9, 1 * SIZE(C1)
  157. MOVSD %xmm10, 2 * SIZE(C1)
  158. MOVSD %xmm11, 3 * SIZE(C1)
  159. MOVSD %xmm12, 4 * SIZE(C1)
  160. MOVSD %xmm13, 5 * SIZE(C1)
  161. MOVSD %xmm14, 6 * SIZE(C1)
  162. MOVSD %xmm15, 7 * SIZE(C1)
  163. addq $8 * SIZE, C1
  164. decq I
  165. jg .L202
  166. ALIGN_4
  167. .L203:
  168. movq M, I
  169. andq $7, I
  170. jle .L205
  171. ALIGN_4
  172. .L204:
  173. MOVSD 0 * SIZE(C1), %xmm8
  174. MULSD %xmm0, %xmm8
  175. MOVSD %xmm8, 0 * SIZE(C1)
  176. addq $SIZE, C1
  177. decq I
  178. jg .L204
  179. ALIGN_4
  180. .L205:
  181. decq N
  182. jg .L201
  183. ALIGN_3
  184. .L999:
  185. xorq %rax, %rax
  186. #ifdef WINDOWS_ABI
  187. movups 0(%rsp), %xmm6
  188. movups 16(%rsp), %xmm7
  189. movups 32(%rsp), %xmm8
  190. movups 48(%rsp), %xmm9
  191. movups 64(%rsp), %xmm10
  192. movups 80(%rsp), %xmm11
  193. movups 96(%rsp), %xmm12
  194. movups 112(%rsp), %xmm13
  195. movups 128(%rsp), %xmm14
  196. movups 144(%rsp), %xmm15
  197. addq $STACKSIZE, %rsp
  198. #endif
  199. ret
  200. EPILOGUE