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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. /*******************************************************************************
  2. Copyright (c) 2015, 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 X_COPY x5 /* X vector address */
  32. #define INC_X x4 /* X stride */
  33. #define I x1 /* loop variable */
  34. #define FLAG x9
  35. /*******************************************************************************
  36. * Macro definitions
  37. *******************************************************************************/
  38. #if !defined(DOUBLE)
  39. #define DA s0 /* scale input value */
  40. #define DAV {v0.s}[0]
  41. #define TMPF s1
  42. #define TMPVF {v1.s}[0]
  43. #define SZ 4
  44. #else
  45. #define DA d0 /* scale input value */
  46. #define DAV {v0.d}[0]
  47. #define TMPF d1
  48. #define TMPVF {v1.d}[0]
  49. #define SZ 8
  50. #endif
  51. /******************************************************************************/
  52. .macro KERNEL_F1
  53. ldr TMPF, [X]
  54. fmul TMPF, TMPF, DA
  55. str TMPF, [X], #SZ
  56. .endm
  57. .macro KERNEL_INIT_F8
  58. #if !defined(DOUBLE)
  59. ins v0.s[1], v0.s[0]
  60. ins v0.s[2], v0.s[0]
  61. ins v0.s[3], v0.s[0]
  62. #else
  63. ins v0.d[1], v0.d[0]
  64. #endif
  65. .endm
  66. .macro KERNEL_F8
  67. #if !defined(DOUBLE)
  68. ld1 {v1.4s, v2.4s}, [X]
  69. fmul v1.4s, v1.4s, v0.4s
  70. fmul v2.4s, v2.4s, v0.4s
  71. st1 {v1.4s, v2.4s}, [X], #32
  72. #else // DOUBLE
  73. ld1 {v1.2d, v2.2d, v3.2d, v4.2d}, [X]
  74. fmul v1.2d, v1.2d, v0.2d
  75. fmul v2.2d, v2.2d, v0.2d
  76. fmul v3.2d, v3.2d, v0.2d
  77. fmul v4.2d, v4.2d, v0.2d
  78. st1 {v1.2d, v2.2d, v3.2d, v4.2d}, [X], #64
  79. #endif
  80. PRFM PLDL1KEEP, [X, #1024]
  81. .endm
  82. .macro INIT_S
  83. #if !defined(DOUBLE)
  84. lsl INC_X, INC_X, #2
  85. #else
  86. lsl INC_X, INC_X, #3
  87. #endif
  88. .endm
  89. .macro KERNEL_S1
  90. ldr TMPF, [X]
  91. fmul TMPF, TMPF, DA
  92. st1 TMPVF, [X], INC_X
  93. .endm
  94. .macro KERNEL_S4
  95. #if !defined(DOUBLE)
  96. ldr s1, [X]
  97. add X, X, INC_X
  98. fmul s1, s1, s0
  99. str s1, [X_COPY]
  100. add X_COPY, X_COPY, INC_X
  101. ldr s2, [X]
  102. add X, X, INC_X
  103. fmul s2, s2, s0
  104. str s2, [X_COPY]
  105. add X_COPY, X_COPY, INC_X
  106. ldr s3, [X]
  107. add X, X, INC_X
  108. fmul s3, s3, s0
  109. str s3, [X_COPY]
  110. add X_COPY, X_COPY, INC_X
  111. ldr s4, [X]
  112. add X, X, INC_X
  113. fmul s4, s4, s0
  114. str s4, [X_COPY]
  115. add X_COPY, X_COPY, INC_X
  116. #else
  117. ldr d1, [X]
  118. add X, X, INC_X
  119. fmul d1, d1, d0
  120. str d1, [X_COPY]
  121. add X_COPY, X_COPY, INC_X
  122. ldr d2, [X]
  123. add X, X, INC_X
  124. fmul d2, d2, d0
  125. str d2, [X_COPY]
  126. add X_COPY, X_COPY, INC_X
  127. ldr d3, [X]
  128. add X, X, INC_X
  129. fmul d3, d3, d0
  130. str d3, [X_COPY]
  131. add X_COPY, X_COPY, INC_X
  132. ldr d4, [X]
  133. add X, X, INC_X
  134. fmul d4, d4, d0
  135. str d4, [X_COPY]
  136. add X_COPY, X_COPY, INC_X
  137. #endif
  138. .endm
  139. /*******************************************************************************
  140. * End of macro definitions
  141. *******************************************************************************/
  142. PROLOGUE
  143. cmp N, xzr
  144. ble .Lscal_kernel_L999
  145. ldr FLAG, [sp]
  146. cmp FLAG, #1
  147. beq .Lscal_kernel_nansafe
  148. fcmp DA, #0.0
  149. beq .Lscal_kernel_zero
  150. .Lscal_kernel_nansafe:
  151. cmp INC_X, #1
  152. bne .Lscal_kernel_S_BEGIN
  153. .Lscal_kernel_F_BEGIN:
  154. asr I, N, #3
  155. cmp I, xzr
  156. beq .Lscal_kernel_F1
  157. KERNEL_INIT_F8
  158. .Lscal_kernel_F8:
  159. KERNEL_F8
  160. subs I, I, #1
  161. bne .Lscal_kernel_F8
  162. .Lscal_kernel_F1:
  163. ands I, N, #7
  164. ble .Lscal_kernel_L999
  165. .Lscal_kernel_F10:
  166. KERNEL_F1
  167. subs I, I, #1
  168. bne .Lscal_kernel_F10
  169. mov w0, wzr
  170. ret
  171. .Lscal_kernel_S_BEGIN:
  172. INIT_S
  173. mov X_COPY, X
  174. asr I, N, #2
  175. cmp I, xzr
  176. ble .Lscal_kernel_S1
  177. .Lscal_kernel_S4:
  178. KERNEL_S4
  179. subs I, I, #1
  180. bne .Lscal_kernel_S4
  181. .Lscal_kernel_S1:
  182. ands I, N, #3
  183. ble .Lscal_kernel_L999
  184. .Lscal_kernel_S10:
  185. KERNEL_S1
  186. subs I, I, #1
  187. bne .Lscal_kernel_S10
  188. .Lscal_kernel_L999:
  189. mov w0, wzr
  190. ret
  191. .Lscal_kernel_zero:
  192. INIT_S
  193. .Lscal_kernel_Z1:
  194. st1 DAV, [X], INC_X
  195. subs N, N, #1
  196. bne .Lscal_kernel_Z1
  197. mov w0, wzr
  198. ret
  199. EPILOGUE