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.

daxpy_thunderx2t99.S 5.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. /*******************************************************************************
  2. Copyright (c) 2017, 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. #define ASSEMBLER
  28. #include "common.h"
  29. #define N x0 /* vector length */
  30. #define X x3 /* X vector address */
  31. #define INC_X x4 /* X stride */
  32. #define Y x5 /* Y vector address */
  33. #define INC_Y x6 /* Y stride */
  34. #define I x1 /* loop variable */
  35. /*******************************************************************************
  36. * Macro definitions
  37. *******************************************************************************/
  38. #define DA d0 /* scale input value */
  39. #define TMPX d1
  40. #define TMPVX {v1.d}[0]
  41. #define TMPY d2
  42. #define TMPVY {v2.d}[0]
  43. #define SZ 8
  44. /******************************************************************************/
  45. .macro KERNEL_F1
  46. ldr TMPX, [X], #SZ
  47. ldr TMPY, [Y]
  48. fmadd TMPY, TMPX, DA, TMPY
  49. str TMPY, [Y], #SZ
  50. .endm
  51. .macro KERNEL_F16
  52. ldp q4, q5, [X]
  53. ldp q16, q17, [Y]
  54. ldp q6, q7, [X, #32]
  55. ldp q18, q19, [Y, #32]
  56. fmla v16.2d, v4.2d, v0.d[0]
  57. fmla v17.2d, v5.2d, v0.d[0]
  58. PRFM PLDL1KEEP, [X, #896]
  59. PRFM PLDL1KEEP, [Y, #896]
  60. stp q16, q17, [Y]
  61. ldp q20, q21, [X, #64]
  62. ldp q24, q25, [Y, #64]
  63. fmla v18.2d, v6.2d, v0.d[0]
  64. fmla v19.2d, v7.2d, v0.d[0]
  65. PRFM PLDL1KEEP, [X, #896+64]
  66. PRFM PLDL1KEEP, [Y, #896+64]
  67. stp q18, q19, [Y, #32]
  68. ldp q22, q23, [X, #96]
  69. ldp q26, q27, [Y, #96]
  70. fmla v24.2d, v20.2d, v0.d[0]
  71. fmla v25.2d, v21.2d, v0.d[0]
  72. stp q24, q25, [Y, #64]
  73. fmla v26.2d, v22.2d, v0.d[0]
  74. fmla v27.2d, v23.2d, v0.d[0]
  75. stp q26, q27, [Y, #96]
  76. add Y, Y, #128
  77. add X, X, #128
  78. .endm
  79. /*
  80. * No need to do software prefetches if the vector fits
  81. * into L1 cache
  82. */
  83. .macro KERNEL_F16_L1CACHE
  84. ldp q4, q5, [X]
  85. ldp q16, q17, [Y]
  86. ldp q6, q7, [X, #32]
  87. ldp q18, q19, [Y, #32]
  88. fmla v16.2d, v4.2d, v0.d[0]
  89. fmla v17.2d, v5.2d, v0.d[0]
  90. stp q16, q17, [Y]
  91. ldp q20, q21, [X, #64]
  92. ldp q24, q25, [Y, #64]
  93. fmla v18.2d, v6.2d, v0.d[0]
  94. fmla v19.2d, v7.2d, v0.d[0]
  95. stp q18, q19, [Y, #32]
  96. ldp q22, q23, [X, #96]
  97. ldp q26, q27, [Y, #96]
  98. fmla v24.2d, v20.2d, v0.d[0]
  99. fmla v25.2d, v21.2d, v0.d[0]
  100. stp q24, q25, [Y, #64]
  101. fmla v26.2d, v22.2d, v0.d[0]
  102. fmla v27.2d, v23.2d, v0.d[0]
  103. stp q26, q27, [Y, #96]
  104. add Y, Y, #128
  105. add X, X, #128
  106. .endm
  107. .macro KERNEL_F32
  108. KERNEL_F16
  109. KERNEL_F16
  110. .endm
  111. .macro KERNEL_F32_L1CACHE
  112. KERNEL_F16_L1CACHE
  113. KERNEL_F16_L1CACHE
  114. .endm
  115. .macro INIT_S
  116. lsl INC_X, INC_X, #3
  117. lsl INC_Y, INC_Y, #3
  118. .endm
  119. .macro KERNEL_S1
  120. ld1 TMPVX, [X], INC_X
  121. ldr TMPY, [Y]
  122. fmadd TMPY, TMPX, DA, TMPY
  123. st1 TMPVY, [Y], INC_Y
  124. .endm
  125. /*******************************************************************************
  126. * End of macro definitions
  127. *******************************************************************************/
  128. PROLOGUE
  129. cmp N, xzr
  130. ble .Ldaxpy_kernel_L999
  131. fcmp DA, #0.0
  132. beq .Ldaxpy_kernel_L999
  133. cmp INC_X, #1
  134. bne .Ldaxpy_kernel_S_BEGIN
  135. cmp INC_Y, #1
  136. bne .Ldaxpy_kernel_S_BEGIN
  137. .Ldaxpy_kernel_F_BEGIN:
  138. asr I, N, #5
  139. cmp I, xzr
  140. beq .Ldaxpy_kernel_F1
  141. cmp N, #2048
  142. ble .Ldaxpy_kernel_F32_L1CACHE
  143. .align 5
  144. .Ldaxpy_kernel_F32:
  145. KERNEL_F32
  146. subs I, I, #1
  147. bne .Ldaxpy_kernel_F32
  148. b .Ldaxpy_kernel_F1
  149. .align 5
  150. .Ldaxpy_kernel_F32_L1CACHE:
  151. KERNEL_F32_L1CACHE
  152. subs I, I, #1
  153. bne .Ldaxpy_kernel_F32_L1CACHE
  154. .Ldaxpy_kernel_F1:
  155. ands I, N, #31
  156. ble .Ldaxpy_kernel_L999
  157. .Ldaxpy_kernel_F10:
  158. KERNEL_F1
  159. subs I, I, #1
  160. bne .Ldaxpy_kernel_F10
  161. b .Ldaxpy_kernel_L999
  162. .Ldaxpy_kernel_S_BEGIN:
  163. INIT_S
  164. asr I, N, #2
  165. cmp I, xzr
  166. ble .Ldaxpy_kernel_S1
  167. .Ldaxpy_kernel_S4:
  168. KERNEL_S1
  169. KERNEL_S1
  170. KERNEL_S1
  171. KERNEL_S1
  172. subs I, I, #1
  173. bne .Ldaxpy_kernel_S4
  174. .Ldaxpy_kernel_S1:
  175. ands I, N, #3
  176. ble .Ldaxpy_kernel_L999
  177. .Ldaxpy_kernel_S10:
  178. KERNEL_S1
  179. subs I, I, #1
  180. bne .Ldaxpy_kernel_S10
  181. .Ldaxpy_kernel_L999:
  182. mov w0, wzr
  183. ret