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.

cgemm_ncopy_2_vfp.S 5.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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 I r3
  55. #define J r12
  56. #define A_PRE 256
  57. /**************************************************************************************
  58. * Macro definitions
  59. **************************************************************************************/
  60. .macro COPY2x2
  61. flds s0 , [ AO1, #0 ]
  62. flds s1 , [ AO1, #4 ]
  63. flds s4 , [ AO1, #8 ]
  64. flds s5 , [ AO1, #12 ]
  65. flds s2 , [ AO2, #0 ]
  66. flds s3 , [ AO2, #4 ]
  67. add AO1, AO1, #16
  68. flds s6 , [ AO2, #8 ]
  69. flds s7 , [ AO2, #12 ]
  70. vstmia.f32 BO!, { s0 - s7 }
  71. add AO2, AO2, #16
  72. .endm
  73. .macro COPY1x2
  74. flds s0 , [ AO1, #0 ]
  75. flds s1 , [ AO1, #4 ]
  76. flds s2 , [ AO2, #0 ]
  77. flds s3 , [ AO2, #4 ]
  78. add AO1, AO1, #8
  79. vstmia.f32 BO!, { s0 - s3 }
  80. add AO2, AO2, #8
  81. .endm
  82. .macro COPY2x1
  83. flds s0 , [ AO1, #0 ]
  84. flds s1 , [ AO1, #4 ]
  85. flds s2 , [ AO1, #8 ]
  86. flds s3 , [ AO1, #12 ]
  87. vstmia.f32 BO!, { s0 - s3 }
  88. add AO1, AO1, #16
  89. .endm
  90. .macro COPY1x1
  91. flds s0 , [ AO1, #0 ]
  92. flds s1 , [ AO1, #4 ]
  93. vstmia.f32 BO!, { s0 - s1 }
  94. add AO1, AO1, #8
  95. .endm
  96. /**************************************************************************************
  97. * End of macro definitions
  98. **************************************************************************************/
  99. PROLOGUE
  100. .align 5
  101. push {r4 - r9, fp}
  102. add fp, sp, #24
  103. sub sp, sp, #STACKSIZE // reserve stack
  104. lsl r3, r3, #3 // lda = lda * 4 * 2
  105. str r3, LDA
  106. sub r4, fp, #128
  107. vstm r4, { s8 - s15} // store floating point registers
  108. ldr BO, B
  109. /*********************************************************************************************/
  110. cgemm_ncopy_L2_BEGIN:
  111. asrs J, N, #1 // J = N / 2
  112. ble cgemm_ncopy_L1_BEGIN
  113. cgemm_ncopy_L2_M2_BEGIN:
  114. mov AO1, A // AO1 = A
  115. ldr r4 , LDA
  116. add AO2, AO1, r4
  117. add A , AO2, r4 // A = A + 2 * LDA
  118. asrs I, M, #1 // I = M / 2
  119. ble cgemm_ncopy_L2_M2_40
  120. cgemm_ncopy_L2_M2_20:
  121. pld [ AO1, #A_PRE ]
  122. pld [ AO2, #A_PRE ]
  123. COPY2x2
  124. subs I , I , #1
  125. ble cgemm_ncopy_L2_M2_40
  126. COPY2x2
  127. subs I , I , #1
  128. bne cgemm_ncopy_L2_M2_20
  129. cgemm_ncopy_L2_M2_40:
  130. ands I, M , #1
  131. ble cgemm_ncopy_L2_M2_END
  132. cgemm_ncopy_L2_M2_60:
  133. COPY1x2
  134. subs I , I , #1
  135. bne cgemm_ncopy_L2_M2_60
  136. cgemm_ncopy_L2_M2_END:
  137. subs J , J, #1 // j--
  138. bne cgemm_ncopy_L2_M2_BEGIN
  139. /*********************************************************************************************/
  140. cgemm_ncopy_L1_BEGIN:
  141. tst N, #1
  142. ble cgemm_ncopy_L999
  143. cgemm_ncopy_L1_M2_BEGIN:
  144. mov AO1, A // AO1 = A
  145. ldr r4 , LDA
  146. add A , AO1, r4 // A = A + 1 * LDA
  147. asrs I, M, #1 // I = M / 2
  148. ble cgemm_ncopy_L1_M2_40
  149. cgemm_ncopy_L1_M2_20:
  150. COPY2x1
  151. subs I , I , #1
  152. bne cgemm_ncopy_L1_M2_20
  153. cgemm_ncopy_L1_M2_40:
  154. ands I, M , #1
  155. ble cgemm_ncopy_L1_M2_END
  156. cgemm_ncopy_L1_M2_60:
  157. COPY1x1
  158. subs I , I , #1
  159. bne cgemm_ncopy_L1_M2_60
  160. cgemm_ncopy_L1_M2_END:
  161. cgemm_ncopy_L999:
  162. sub r3, fp, #128
  163. vldm r3, { s8 - s15} // restore floating point registers
  164. movs r0, #0 // set return value
  165. sub sp, fp, #24
  166. pop {r4 - r9, fp}
  167. bx lr
  168. EPILOGUE