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_tcopy_2_vfp.S 5.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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/07 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 B [fp, #4 ]
  47. #define A [fp, #-248 ]
  48. #define M r0
  49. #define N r1
  50. #define M4 r2
  51. #define LDA r5
  52. #define AO1 r6
  53. #define BO1 r7
  54. #define BO2 r8
  55. #define I r4
  56. #define J r12
  57. #define A_PRE 256
  58. /**************************************************************************************
  59. * Macro definitions
  60. **************************************************************************************/
  61. .macro COPY2x2
  62. vldmia.f32 AO1, { s0 - s3 }
  63. add r3, AO1, LDA
  64. vldmia.f32 r3, { s4 - s7 }
  65. vstmia.f32 BO1, { s0 - s7 }
  66. add AO1, AO1, #16
  67. add BO1, BO1, M4
  68. .endm
  69. .macro COPY1x2
  70. vldmia.f32 AO1, { s0 -s1 }
  71. add r3, AO1, LDA
  72. vldmia.f32 r3, { s2 - s3 }
  73. vstmia.f32 BO2, { s0 - s3 }
  74. add AO1, AO1, #8
  75. add BO2, BO2, #16
  76. .endm
  77. /*************************************************************************************************************************/
  78. .macro COPY2x1
  79. vldmia.f32 AO1, { s0 - s3 }
  80. vstmia.f32 BO1, { s0 - s3 }
  81. add AO1, AO1, #16
  82. add BO1, BO1, M4
  83. .endm
  84. .macro COPY1x1
  85. vldmia.f32 AO1, { s0 - s1 }
  86. vstmia.f32 BO2, { s0 - s1 }
  87. add AO1, AO1, #8
  88. add BO2, BO2, #8
  89. .endm
  90. /**************************************************************************************
  91. * End of macro definitions
  92. **************************************************************************************/
  93. PROLOGUE
  94. .align 5
  95. push {r4 - r9, fp}
  96. add fp, sp, #24
  97. sub sp, sp, #STACKSIZE // reserve stack
  98. str OLD_A, A // store A
  99. lsl LDA, OLD_LDA, #3 // lda = lda * SIZE * 2
  100. sub r4, fp, #128
  101. vstm r4, { s8 - s15} // store floating point registers
  102. lsl r4 , M, #3 // M * SIZE * 2
  103. ldr r3, B
  104. and BO2 , N , #-2
  105. mul BO2, BO2, r4
  106. add BO2 , BO2, r3
  107. lsl M4, M, #4 // M4 = M * 2 * SIZE * 2
  108. cgemm_tcopy_L2_BEGIN:
  109. asrs J, M, #1 // J = N / 2
  110. ble cgemm_tcopy_L1_BEGIN
  111. cgemm_tcopy_L2_M2_BEGIN:
  112. ldr AO1, A // AO1 = A
  113. lsl r3, LDA, #1 // r3 = 2 * LDA
  114. add r3, r3 , AO1 // A = A + 2 * LDA
  115. str r3, A // store A
  116. ldr BO1, B
  117. add r3, BO1, #32 // B = B + 4 * SIZE *2
  118. str r3, B
  119. asrs I, N, #1 // I = M / 2
  120. ble cgemm_tcopy_L2_M2_60
  121. cgemm_tcopy_L2_M2_40:
  122. COPY2x2
  123. subs I, I, #1
  124. bne cgemm_tcopy_L2_M2_40
  125. cgemm_tcopy_L2_M2_60:
  126. tst N , #1
  127. ble cgemm_tcopy_L2_M2_END
  128. COPY1x2
  129. cgemm_tcopy_L2_M2_END:
  130. subs J , J, #1 // j--
  131. bne cgemm_tcopy_L2_M2_BEGIN
  132. /*********************************************************************************************/
  133. cgemm_tcopy_L1_BEGIN:
  134. tst M, #1
  135. ble cgemm_tcopy_L999
  136. cgemm_tcopy_L1_M2_BEGIN:
  137. ldr AO1, A // AO1 = A
  138. add r3, LDA , AO1 // A = A + 1 * LDA
  139. str r3, A // store A
  140. ldr BO1, B
  141. add r3, BO1, #16 // B = B + 2 * SIZE *2
  142. str r3, B
  143. asrs I, N, #1 // I = M / 2
  144. ble cgemm_tcopy_L1_M2_60
  145. cgemm_tcopy_L1_M2_40:
  146. COPY2x1
  147. subs I, I, #1
  148. bne cgemm_tcopy_L1_M2_40
  149. cgemm_tcopy_L1_M2_60:
  150. tst N , #1
  151. ble cgemm_tcopy_L1_M2_END
  152. COPY1x1
  153. cgemm_tcopy_L1_M2_END:
  154. cgemm_tcopy_L999:
  155. sub r3, fp, #128
  156. vldm r3, { s8 - s15} // restore floating point registers
  157. mov r0, #0 // set return value
  158. sub sp, fp, #24
  159. pop {r4 - r9, fp}
  160. bx lr
  161. EPILOGUE