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.

csum.S 3.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /*******************************************************************************
  2. Copyright (c) 2019, 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 x1 /* X vector address */
  31. #define INC_X x2 /* X stride */
  32. #define I x5 /* loop variable */
  33. /*******************************************************************************
  34. * Macro definitions
  35. *******************************************************************************/
  36. #define REG0 wzr
  37. #define SUMF s0
  38. #define TMPF s1
  39. #define TMPVF {v1.s}[0]
  40. #define SZ 4
  41. /******************************************************************************/
  42. .macro KERNEL_F1
  43. ld1 {v1.2s}, [X], #8
  44. ext v2.8b, v1.8b, v1.8b, #4
  45. fadd TMPF, TMPF, s2
  46. fadd SUMF, SUMF, TMPF
  47. .endm
  48. .macro KERNEL_F8
  49. ld1 {v1.4s, v2.4s, v3.4s, v4.4s}, [X]
  50. add X, X, #64
  51. PRFM PLDL1KEEP, [X, #1024]
  52. fadd v1.4s, v1.4s, v2.4s
  53. fadd v3.4s, v3.4s, v4.4s
  54. fadd v0.4s, v0.4s, v1.4s
  55. fadd v0.4s, v0.4s, v3.4s
  56. .endm
  57. .macro KERNEL_F8_FINALIZE
  58. ext v1.16b, v0.16b, v0.16b, #8
  59. fadd v0.2s, v0.2s, v1.2s
  60. faddp SUMF, v0.2s
  61. .endm
  62. .macro INIT_S
  63. lsl INC_X, INC_X, #3
  64. .endm
  65. .macro KERNEL_S1
  66. ld1 {v1.2s}, [X], INC_X
  67. ext v2.8b, v1.8b, v1.8b, #4
  68. fadd TMPF, TMPF, s2
  69. fadd SUMF, SUMF, TMPF
  70. .endm
  71. /*******************************************************************************
  72. * End of macro definitions
  73. *******************************************************************************/
  74. PROLOGUE
  75. fmov SUMF, REG0
  76. fmov s1, SUMF
  77. cmp N, xzr
  78. ble .Lcsum_kernel_L999
  79. cmp INC_X, xzr
  80. ble .Lcsum_kernel_L999
  81. cmp INC_X, #1
  82. bne .Lcsum_kernel_S_BEGIN
  83. .Lcsum_kernel_F_BEGIN:
  84. asr I, N, #3
  85. cmp I, xzr
  86. beq .Lcsum_kernel_F1
  87. .Lcsum_kernel_F8:
  88. KERNEL_F8
  89. subs I, I, #1
  90. bne .Lcsum_kernel_F8
  91. KERNEL_F8_FINALIZE
  92. .Lcsum_kernel_F1:
  93. ands I, N, #7
  94. ble .Lcsum_kernel_L999
  95. .Lcsum_kernel_F10:
  96. KERNEL_F1
  97. subs I, I, #1
  98. bne .Lcsum_kernel_F10
  99. .Lcsum_kernel_L999:
  100. ret
  101. .Lcsum_kernel_S_BEGIN:
  102. INIT_S
  103. asr I, N, #2
  104. cmp I, xzr
  105. ble .Lcsum_kernel_S1
  106. .Lcsum_kernel_S4:
  107. KERNEL_S1
  108. KERNEL_S1
  109. KERNEL_S1
  110. KERNEL_S1
  111. subs I, I, #1
  112. bne .Lcsum_kernel_S4
  113. .Lcsum_kernel_S1:
  114. ands I, N, #3
  115. ble .Lcsum_kernel_L999
  116. .Lcsum_kernel_S10:
  117. KERNEL_S1
  118. subs I, I, #1
  119. bne .Lcsum_kernel_S10
  120. ret
  121. EPILOGUE