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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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 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. #if !defined(DOUBLE)
  39. #define DA s0 /* scale input value */
  40. #define TMPX s1
  41. #define TMPVX {v1.s}[0]
  42. #define TMPY s2
  43. #define TMPVY {v2.s}[0]
  44. #define SZ 4
  45. #else
  46. #define DA d0 /* scale input value */
  47. #define TMPX d1
  48. #define TMPVX {v1.d}[0]
  49. #define TMPY d2
  50. #define TMPVY {v2.d}[0]
  51. #define SZ 8
  52. #endif
  53. /******************************************************************************/
  54. .macro KERNEL_F1
  55. ldr TMPX, [X], #SZ
  56. ldr TMPY, [Y]
  57. fmadd TMPY, TMPX, DA, TMPY
  58. str TMPY, [Y], #SZ
  59. .endm
  60. .macro KERNEL_F4
  61. #if !defined(DOUBLE)
  62. ld1 {v1.4s}, [X], #16
  63. ld1 {v2.4s}, [Y]
  64. fmla v2.4s, v1.4s, v0.s[0]
  65. st1 {v2.4s}, [Y], #16
  66. #else // DOUBLE
  67. ld1 {v1.2d, v2.2d}, [X], #32
  68. ld1 {v3.2d, v4.2d}, [Y]
  69. fmla v3.2d, v1.2d, v0.d[0]
  70. fmla v4.2d, v2.2d, v0.d[0]
  71. st1 {v3.2d, v4.2d}, [Y], #32
  72. #endif
  73. .endm
  74. .macro KERNEL_F8
  75. #if !defined(DOUBLE)
  76. ld1 {v1.4s, v2.4s}, [X], #32
  77. ld1 {v3.4s, v4.4s}, [Y]
  78. fmla v3.4s, v1.4s, v0.s[0]
  79. fmla v4.4s, v2.4s, v0.s[0]
  80. st1 {v3.4s, v4.4s}, [Y], #32
  81. #else // DOUBLE
  82. ld1 {v1.2d, v2.2d, v3.2d, v4.2d}, [X], #64
  83. ld1 {v16.2d, v17.2d, v18.2d, v19.2d}, [Y]
  84. fmla v16.2d, v1.2d, v0.d[0]
  85. fmla v17.2d, v2.2d, v0.d[0]
  86. fmla v18.2d, v3.2d, v0.d[0]
  87. fmla v19.2d, v4.2d, v0.d[0]
  88. st1 {v16.2d, v17.2d, v18.2d, v19.2d}, [Y], #64
  89. #endif
  90. PRFM PLDL1KEEP, [X, #512]
  91. PRFM PLDL1KEEP, [Y, #512]
  92. .endm
  93. .macro INIT_S
  94. #if !defined(DOUBLE)
  95. lsl INC_X, INC_X, #2
  96. lsl INC_Y, INC_Y, #2
  97. #else
  98. lsl INC_X, INC_X, #3
  99. lsl INC_Y, INC_Y, #3
  100. #endif
  101. .endm
  102. .macro KERNEL_S1
  103. ld1 TMPVX, [X], INC_X
  104. ldr TMPY, [Y]
  105. fmadd TMPY, TMPX, DA, TMPY
  106. st1 TMPVY, [Y], INC_Y
  107. .endm
  108. /*******************************************************************************
  109. * End of macro definitions
  110. *******************************************************************************/
  111. PROLOGUE
  112. cmp N, xzr
  113. ble axpy_kernel_L999
  114. fcmp DA, #0.0
  115. beq axpy_kernel_L999
  116. cmp INC_X, #1
  117. bne axpy_kernel_S_BEGIN
  118. cmp INC_Y, #1
  119. bne axpy_kernel_S_BEGIN
  120. axpy_kernel_F_BEGIN:
  121. asr I, N, #3
  122. cmp I, xzr
  123. beq axpy_kernel_F1
  124. axpy_kernel_F8:
  125. KERNEL_F8
  126. subs I, I, #1
  127. bne axpy_kernel_F8
  128. axpy_kernel_F1:
  129. ands I, N, #7
  130. ble axpy_kernel_L999
  131. axpy_kernel_F10:
  132. KERNEL_F1
  133. subs I, I, #1
  134. bne axpy_kernel_F10
  135. mov w0, wzr
  136. ret
  137. axpy_kernel_S_BEGIN:
  138. INIT_S
  139. asr I, N, #2
  140. cmp I, xzr
  141. ble axpy_kernel_S1
  142. axpy_kernel_S4:
  143. KERNEL_S1
  144. KERNEL_S1
  145. KERNEL_S1
  146. KERNEL_S1
  147. subs I, I, #1
  148. bne axpy_kernel_S4
  149. axpy_kernel_S1:
  150. ands I, N, #3
  151. ble axpy_kernel_L999
  152. axpy_kernel_S10:
  153. KERNEL_S1
  154. subs I, I, #1
  155. bne axpy_kernel_S10
  156. axpy_kernel_L999:
  157. mov w0, wzr
  158. ret