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.

xgemv_n.S 7.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  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. #ifdef PENTIUM
  41. #define P 32
  42. #endif
  43. #if defined(PENTIUM4) || defined(ATHLON)
  44. #define P (DTB_DEFAULT_ENTRIES / 2)
  45. #endif
  46. #ifndef P
  47. #define P DTB_DEFAULT_ENTRIES
  48. #endif
  49. #define STACK 16
  50. #define ARGS 16
  51. #define PLDA_M 0 + STACK(%esp)
  52. #define XP 4 + STACK(%esp)
  53. #define MIN_N 8 + STACK(%esp)
  54. #define IS 12 + STACK(%esp)
  55. #define M 4 + STACK + ARGS(%esp)
  56. #define N 8 + STACK + ARGS(%esp)
  57. #define K 12 + STACK + ARGS(%esp)
  58. #define ALPHA_R 16 + STACK + ARGS(%esp)
  59. #define ALPHA_I 32 + STACK + ARGS(%esp)
  60. #define A 48 + STACK + ARGS(%esp)
  61. #define LDA 52 + STACK + ARGS(%esp)
  62. #define X 56 + STACK + ARGS(%esp)
  63. #define INCX 60 + STACK + ARGS(%esp)
  64. #define Y 64 + STACK + ARGS(%esp)
  65. #define INCY 68 + STACK + ARGS(%esp)
  66. #define BUFFER 72 + STACK + ARGS(%esp)
  67. PROLOGUE
  68. subl $ARGS, %esp
  69. pushl %ebp
  70. pushl %edi
  71. pushl %esi
  72. pushl %ebx
  73. PROFCODE
  74. FLD ALPHA_I
  75. FLD ALPHA_R
  76. movl X, %edi
  77. movl LDA, %ebx
  78. sall $ZBASE_SHIFT, %ebx
  79. movl $0, IS
  80. movl M, %ecx
  81. movl N, %esi
  82. test %ecx, %ecx
  83. jle .L79 # goto END
  84. test %esi, %esi
  85. jle .L79 # goto END
  86. movl INCY, %eax
  87. sall $ZBASE_SHIFT, %eax
  88. movl %eax, INCY
  89. movl LDA, %eax
  90. imull $P, %eax # P * lda
  91. subl M ,%eax # P * lda - m
  92. sall $ZBASE_SHIFT, %eax
  93. movl %eax, PLDA_M
  94. ALIGN_2
  95. .L32:
  96. movl IS, %esi
  97. movl $P, %edx
  98. movl N, %eax
  99. subl %esi,%eax # n - is
  100. cmpl %edx, %eax
  101. #ifdef PENTIUM
  102. jle .L33
  103. movl %edx, %eax
  104. .L33:
  105. #else
  106. cmovg %edx, %eax
  107. #endif
  108. movl %eax, MIN_N
  109. sall $ZBASE_SHIFT, %esi
  110. leal (%edi, %esi, 1), %esi
  111. movl %esi, XP
  112. movl INCX, %edx
  113. cmpl $1, %edx
  114. je .L34 # if incx == 1 goto L34
  115. movl BUFFER, %esi
  116. movl %esi, XP # xp = buffer
  117. sall $ZBASE_SHIFT, %edx
  118. sarl $1,%eax
  119. jle .L35
  120. ALIGN_2
  121. .L36:
  122. FLD 0 * SIZE(%edi)
  123. FLD 1 * SIZE(%edi)
  124. addl %edx,%edi # x += incx
  125. FLD 0 * SIZE(%edi)
  126. FLD 1 * SIZE(%edi)
  127. addl %edx,%edi # x += incx
  128. FST 3 * SIZE(%esi)
  129. FST 2 * SIZE(%esi)
  130. FST 1 * SIZE(%esi)
  131. FST 0 * SIZE(%esi)
  132. addl $4 * SIZE, %esi # xp += 4
  133. decl %eax
  134. jg .L36
  135. ALIGN_3
  136. .L35:
  137. movl MIN_N, %eax
  138. andl $1, %eax
  139. jle .L34
  140. FLD 0 * SIZE(%edi)
  141. FLD 1 * SIZE(%edi)
  142. addl %edx,%edi # x += incx
  143. FST 1 * SIZE(%esi)
  144. FST 0 * SIZE(%esi)
  145. ALIGN_3
  146. /* Main Routine */
  147. .L34:
  148. movl Y, %ecx # c_offset
  149. movl M, %ebp # j = m
  150. ALIGN_3
  151. .L61:
  152. movl A, %edx # a_offset = a
  153. fldz
  154. addl $2 * SIZE, A # a++
  155. fldz
  156. movl XP,%esi
  157. fldz
  158. movl MIN_N,%eax
  159. fldz
  160. FLD (%esi) # bt1 = *(b_offset + 0)
  161. sarl $1, %eax
  162. jle .L64
  163. ALIGN_3
  164. .L65:
  165. #ifdef PENTIUM4
  166. prefetchnta 16 * SIZE(%esi)
  167. #endif
  168. FLD 0 * SIZE(%edx) # at1 = *(a_offset + 0)
  169. fmul %st(1) # at1 *= bt1
  170. faddp %st, %st(2) # ct1 += at1
  171. FLD 1 * SIZE(%edx) # bt1 *= *(a_offset + 1)
  172. fmulp %st, %st(1)
  173. #ifndef CONJ
  174. faddp %st, %st(2) # ct2 += bt1
  175. #else
  176. fsubrp %st, %st(2) # ct2 -= bt1
  177. #endif
  178. FLD 1 * SIZE(%esi) # bt1 = *(b_offset + 1)
  179. FLD 0 * SIZE(%edx) # at1 = *(a_offset + 0)
  180. fmul %st(1) # at1 *= bt1
  181. faddp %st, %st(4) # ct3 += at1
  182. FLD 1 * SIZE(%edx) # bt1 *= *(a_offset + 1)
  183. fmulp %st, %st(1)
  184. faddp %st, %st(4) # ct4 += bt1
  185. FLD 2 * SIZE(%esi) # bt1 = *(b_offset + 2)
  186. addl $2 * SIZE, %esi # b_offset += 2
  187. addl %ebx, %edx # a_offset += lda
  188. FLD 0 * SIZE(%edx) # at1 = *(a_offset + 0)
  189. fmul %st(1) # at1 *= bt1
  190. faddp %st, %st(2) # ct1 += at1
  191. FLD 1 * SIZE(%edx) # bt1 *= *(a_offset + 1)
  192. fmulp %st, %st(1)
  193. #ifndef CONJ
  194. faddp %st, %st(2) # ct2 += bt1
  195. #else
  196. fsubrp %st, %st(2) # ct2 -= bt1
  197. #endif
  198. FLD 1 * SIZE(%esi) # bt1 = *(b_offset + 1)
  199. FLD 0 * SIZE(%edx) # at1 = *(a_offset + 0)
  200. fmul %st(1) # at1 *= bt1
  201. faddp %st, %st(4) # ct3 += at1
  202. FLD 1 * SIZE(%edx) # bt1 *= *(a_offset + 1)
  203. fmulp %st, %st(1)
  204. faddp %st, %st(4) # ct4 += bt1
  205. FLD 2 * SIZE(%esi) # bt1 = *(b_offset + 2)
  206. addl $2 * SIZE, %esi # b_offset += 2
  207. addl %ebx, %edx # a_offset += lda
  208. decl %eax
  209. jg .L65
  210. .L64:
  211. movl MIN_N, %eax
  212. andl $1, %eax
  213. jle .L70
  214. ALIGN_2
  215. .L71:
  216. FLD 0 * SIZE(%edx) # at1 = *(a_offset + 0)
  217. fmul %st(1) # at1 *= bt1
  218. faddp %st, %st(2) # ct1 += at1
  219. FLD 1 * SIZE(%edx) # bt1 *= *(a_offset + 1)
  220. fmulp %st, %st(1)
  221. #ifndef CONJ
  222. faddp %st, %st(2) # ct2 += bt1
  223. #else
  224. fsubrp %st, %st(2) # ct2 -= bt1
  225. #endif
  226. FLD 1 * SIZE(%esi) # bt1 = *(b_offset + 1)
  227. FLD 0 * SIZE(%edx) # at1 = *(a_offset + 0)
  228. fmul %st(1) # at1 *= bt1
  229. faddp %st, %st(4) # ct3 += at1
  230. FLD 1 * SIZE(%edx) # bt1 *= *(a_offset + 1)
  231. fmulp %st, %st(1)
  232. faddp %st, %st(4) # ct4 += bt1
  233. fldz
  234. ALIGN_2
  235. .L70:
  236. ffreep %st(0)
  237. #ifndef XCONJ
  238. #ifndef CONJ
  239. fsubp %st, %st(3)
  240. faddp %st, %st(1)
  241. #else
  242. faddp %st, %st(3)
  243. faddp %st, %st(1)
  244. #endif
  245. #else
  246. #ifndef CONJ
  247. faddp %st, %st(3)
  248. fsubp %st, %st(1)
  249. #else
  250. fsubp %st, %st(3)
  251. fsubp %st, %st(1)
  252. #endif
  253. #endif
  254. fld %st(0) # ct4 = ct2
  255. fmul %st(4)
  256. fld %st(2)
  257. fmul %st(4)
  258. fsubp %st, %st(1)
  259. movl INCY, %eax
  260. FLD 0 * SIZE(%ecx)
  261. faddp %st, %st(1)
  262. FST 0 * SIZE(%ecx)
  263. fmul %st(2)
  264. fxch %st(1)
  265. fmul %st(3)
  266. faddp %st, %st(1)
  267. FLD 1 * SIZE(%ecx)
  268. faddp %st, %st(1)
  269. FST 1 * SIZE(%ecx)
  270. addl %eax, %ecx
  271. decl %ebp
  272. jg .L61
  273. .L60:
  274. movl PLDA_M, %esi
  275. addl %esi, A # a += P * lda - m
  276. addl $P, IS
  277. movl N, %esi
  278. cmpl %esi,IS
  279. jl .L32
  280. .L79:
  281. ffreep %st(0)
  282. ffreep %st(0)
  283. popl %ebx
  284. popl %esi
  285. popl %edi
  286. popl %ebp
  287. addl $ARGS, %esp
  288. ret
  289. EPILOGUE

OpenBLAS is an optimized BLAS library based on GotoBLAS2 1.13 BSD version.