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.

sgemm_ncopy_4_vfp.S 6.7 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. /***************************************************************************
  2. Copyright (c) 2013, The OpenBLAS Project
  3. All rights reserved.
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions are
  6. met:
  7. 1. Redistributions of source code must retain the above copyright
  8. notice, this list of conditions and the following disclaimer.
  9. 2. Redistributions in binary form must reproduce the above copyright
  10. notice, this list of conditions and the following disclaimer in
  11. the documentation and/or other materials provided with the
  12. distribution.
  13. 3. Neither the name of the OpenBLAS project nor the names of
  14. its contributors may be used to endorse or promote products
  15. derived from this software without specific prior written permission.
  16. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  17. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  18. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  19. ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE
  20. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  21. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  22. SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  23. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  24. OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
  25. USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. *****************************************************************************/
  27. /**************************************************************************************
  28. * 2013/11/05 Saar
  29. * BLASTEST : OK
  30. * CTEST : OK
  31. * TEST : OK
  32. *
  33. **************************************************************************************/
  34. #define ASSEMBLER
  35. #include "common.h"
  36. #define STACKSIZE 256
  37. #define OLD_M r0
  38. #define OLD_N r1
  39. #define OLD_A r2
  40. #define OLD_LDA r3
  41. /******************************************************
  42. * [fp, #-128] - [fp, #-64] is reserved
  43. * for store and restore of floating point
  44. * registers
  45. *******************************************************/
  46. #define LDA [fp, #-260 ]
  47. #define B [fp, #4 ]
  48. #define M r0
  49. #define N r1
  50. #define A r2
  51. #define BO r5
  52. #define AO1 r6
  53. #define AO2 r7
  54. #define AO3 r8
  55. #define AO4 r9
  56. #define I r3
  57. #define J r12
  58. #define A_PRE 192
  59. /**************************************************************************************
  60. * Macro definitions
  61. **************************************************************************************/
  62. .macro COPY4x4
  63. flds s0 , [ AO1, #0 ]
  64. flds s1 , [ AO2, #0 ]
  65. flds s2 , [ AO3, #0 ]
  66. flds s3 , [ AO4, #0 ]
  67. flds s4 , [ AO1, #4 ]
  68. flds s8 , [ AO1, #8 ]
  69. flds s12, [ AO1, #12 ]
  70. flds s5 , [ AO2, #4 ]
  71. add AO1, AO1, #16
  72. flds s9 , [ AO2, #8 ]
  73. flds s13, [ AO2, #12 ]
  74. flds s6 , [ AO3, #4 ]
  75. add AO2, AO2, #16
  76. flds s10, [ AO3, #8 ]
  77. flds s14, [ AO3, #12 ]
  78. flds s7 , [ AO4, #4 ]
  79. add AO3, AO3, #16
  80. flds s11, [ AO4, #8 ]
  81. flds s15, [ AO4, #12 ]
  82. vstmia.f32 BO!, { s0 - s3 }
  83. add AO4, AO4, #16
  84. vstmia.f32 BO!, { s4 - s7 }
  85. vstmia.f32 BO!, { s8 - s15 }
  86. .endm
  87. .macro COPY1x4
  88. flds s0 , [ AO1, #0 ]
  89. flds s1 , [ AO2, #0 ]
  90. add AO1, AO1, #4
  91. flds s2 , [ AO3, #0 ]
  92. add AO2, AO2, #4
  93. flds s3 , [ AO4, #0 ]
  94. add AO3, AO3, #4
  95. vstmia.f32 BO!, { s0 - s3 }
  96. add AO4, AO4, #4
  97. .endm
  98. .macro COPY4x2
  99. flds s0 , [ AO1, #0 ]
  100. flds s2 , [ AO1, #4 ]
  101. flds s4 , [ AO1, #8 ]
  102. flds s6 , [ AO1, #12 ]
  103. flds s1 , [ AO2, #0 ]
  104. flds s3 , [ AO2, #4 ]
  105. add AO1, AO1, #16
  106. flds s5 , [ AO2, #8 ]
  107. flds s7 , [ AO2, #12 ]
  108. vstmia.f32 BO!, { s0 - s7 }
  109. add AO2, AO2, #16
  110. .endm
  111. .macro COPY1x2
  112. flds s0 , [ AO1, #0 ]
  113. flds s1 , [ AO2, #0 ]
  114. add AO1, AO1, #4
  115. vstmia.f32 BO!, { s0 - s1 }
  116. add AO2, AO2, #4
  117. .endm
  118. .macro COPY4x1
  119. flds s0 , [ AO1, #0 ]
  120. flds s1 , [ AO1, #4 ]
  121. flds s2 , [ AO1, #8 ]
  122. flds s3 , [ AO1, #12 ]
  123. vstmia.f32 BO!, { s0 - s3 }
  124. add AO1, AO1, #16
  125. .endm
  126. .macro COPY1x1
  127. flds s0 , [ AO1, #0 ]
  128. vstmia.f32 BO!, { s0 }
  129. add AO1, AO1, #4
  130. .endm
  131. /**************************************************************************************
  132. * End of macro definitions
  133. **************************************************************************************/
  134. PROLOGUE
  135. .align 5
  136. push {r4 - r9, fp}
  137. add fp, sp, #24
  138. sub sp, sp, #STACKSIZE // reserve stack
  139. lsl r3, r3, #2 // lda = lda * 4
  140. str r3, LDA
  141. sub r4, fp, #128
  142. vstm r4, { s8 - s15} // store floating point registers
  143. ldr BO, B
  144. sgemm_ncopy_L4_BEGIN:
  145. asrs J, N, #2 // J = N / 4
  146. ble sgemm_ncopy_L2_BEGIN
  147. sgemm_ncopy_L4_M4_BEGIN:
  148. mov AO1, A // AO1 = A
  149. ldr r4 , LDA
  150. add AO2, AO1, r4
  151. add AO3, AO2, r4
  152. add AO4, AO3, r4
  153. add A , AO4, r4 // A = A + 4 * LDA
  154. asrs I, M, #2 // I = M / 4
  155. ble sgemm_ncopy_L4_M4_40
  156. sgemm_ncopy_L4_M4_20:
  157. pld [ AO1, #A_PRE ]
  158. pld [ AO2, #A_PRE ]
  159. pld [ AO3, #A_PRE ]
  160. pld [ AO4, #A_PRE ]
  161. COPY4x4
  162. subs I , I , #1
  163. ble sgemm_ncopy_L4_M4_40
  164. COPY4x4
  165. subs I , I , #1
  166. bne sgemm_ncopy_L4_M4_20
  167. sgemm_ncopy_L4_M4_40:
  168. ands I, M , #3
  169. ble sgemm_ncopy_L4_M4_END
  170. sgemm_ncopy_L4_M4_60:
  171. COPY1x4
  172. subs I , I , #1
  173. bne sgemm_ncopy_L4_M4_60
  174. sgemm_ncopy_L4_M4_END:
  175. subs J , J, #1 // j--
  176. bne sgemm_ncopy_L4_M4_BEGIN
  177. /*********************************************************************************************/
  178. sgemm_ncopy_L2_BEGIN:
  179. tst N, #3
  180. ble sgemm_ncopy_L999
  181. tst N, #2
  182. ble sgemm_ncopy_L1_BEGIN
  183. sgemm_ncopy_L2_M4_BEGIN:
  184. mov AO1, A // AO1 = A
  185. ldr r4 , LDA
  186. add AO2, AO1, r4
  187. add A , AO2, r4 // A = A + 2 * LDA
  188. asrs I, M, #2 // I = M / 4
  189. ble sgemm_ncopy_L2_M4_40
  190. sgemm_ncopy_L2_M4_20:
  191. COPY4x2
  192. subs I , I , #1
  193. bne sgemm_ncopy_L2_M4_20
  194. sgemm_ncopy_L2_M4_40:
  195. ands I, M , #3
  196. ble sgemm_ncopy_L2_M4_END
  197. sgemm_ncopy_L2_M4_60:
  198. COPY1x2
  199. subs I , I , #1
  200. bne sgemm_ncopy_L2_M4_60
  201. sgemm_ncopy_L2_M4_END:
  202. /*********************************************************************************************/
  203. sgemm_ncopy_L1_BEGIN:
  204. tst N, #1
  205. ble sgemm_ncopy_L999
  206. sgemm_ncopy_L1_M4_BEGIN:
  207. mov AO1, A // AO1 = A
  208. ldr r4 , LDA
  209. add A , AO1, r4 // A = A + 1 * LDA
  210. asrs I, M, #2 // I = M / 4
  211. ble sgemm_ncopy_L1_M4_40
  212. sgemm_ncopy_L1_M4_20:
  213. COPY4x1
  214. subs I , I , #1
  215. bne sgemm_ncopy_L1_M4_20
  216. sgemm_ncopy_L1_M4_40:
  217. ands I, M , #3
  218. ble sgemm_ncopy_L1_M4_END
  219. sgemm_ncopy_L1_M4_60:
  220. COPY1x1
  221. subs I , I , #1
  222. bne sgemm_ncopy_L1_M4_60
  223. sgemm_ncopy_L1_M4_END:
  224. sgemm_ncopy_L999:
  225. sub r3, fp, #128
  226. vldm r3, { s8 - s15} // restore floating point registers
  227. movs r0, #0 // set return value
  228. sub sp, fp, #24
  229. pop {r4 - r9, fp}
  230. bx lr
  231. EPILOGUE