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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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 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 xzr
  37. #define SUMF d0
  38. #define TMPF d1
  39. #define TMPVF {v1.d}[0]
  40. #define SZ 8
  41. /******************************************************************************/
  42. .macro KERNEL_F1
  43. ld1 {v1.2d}, [X], #16
  44. faddp TMPF, v1.2d
  45. fadd SUMF, SUMF, TMPF
  46. .endm
  47. .macro KERNEL_F4
  48. ld1 {v1.2d, v2.2d, v3.2d, v4.2d}, [X], #64
  49. fadd v1.2d, v1.2d, v2.2d
  50. fadd v3.2d, v3.2d, v4.2d
  51. fadd v0.2d, v0.2d, v1.2d
  52. fadd v0.2d, v0.2d, v3.2d
  53. PRFM PLDL1KEEP, [X, #1024]
  54. .endm
  55. .macro KERNEL_F4_FINALIZE
  56. faddp SUMF, v0.2d
  57. .endm
  58. .macro INIT_S
  59. lsl INC_X, INC_X, #4
  60. .endm
  61. .macro KERNEL_S1
  62. ld1 {v1.2d}, [X], INC_X
  63. faddp TMPF, v1.2d
  64. fadd SUMF, SUMF, TMPF
  65. .endm
  66. /*******************************************************************************
  67. * End of macro definitions
  68. *******************************************************************************/
  69. PROLOGUE
  70. fmov SUMF, REG0
  71. cmp N, xzr
  72. ble .Lzsum_kernel_L999
  73. cmp INC_X, xzr
  74. ble .Lzsum_kernel_L999
  75. cmp INC_X, #1
  76. bne .Lzsum_kernel_S_BEGIN
  77. .Lzsum_kernel_F_BEGIN:
  78. asr I, N, #2
  79. cmp I, xzr
  80. beq .Lzsum_kernel_F1
  81. .Lzsum_kernel_F4:
  82. KERNEL_F4
  83. subs I, I, #1
  84. bne .Lzsum_kernel_F4
  85. KERNEL_F4_FINALIZE
  86. .Lzsum_kernel_F1:
  87. ands I, N, #3
  88. ble .Lzsum_kernel_L999
  89. .Lzsum_kernel_F10:
  90. KERNEL_F1
  91. subs I, I, #1
  92. bne .Lzsum_kernel_F10
  93. .Lzsum_kernel_L999:
  94. ret
  95. .Lzsum_kernel_S_BEGIN:
  96. INIT_S
  97. asr I, N, #2
  98. cmp I, xzr
  99. ble .Lzsum_kernel_S1
  100. .Lzsum_kernel_S4:
  101. KERNEL_S1
  102. KERNEL_S1
  103. KERNEL_S1
  104. KERNEL_S1
  105. subs I, I, #1
  106. bne .Lzsum_kernel_S4
  107. .Lzsum_kernel_S1:
  108. ands I, N, #3
  109. ble .Lzsum_kernel_L999
  110. .Lzsum_kernel_S10:
  111. KERNEL_S1
  112. subs I, I, #1
  113. bne .Lzsum_kernel_S10
  114. ret
  115. EPILOGUE