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.

izamax.S 3.7 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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 INDEX x3 /* index of max/min value */
  33. #define Z x4 /* vector index */
  34. #define I x5 /* loop variable */
  35. /*******************************************************************************
  36. * Macro definitions
  37. *******************************************************************************/
  38. #if defined(USE_MIN)
  39. #define COND le
  40. #else
  41. #define COND ge
  42. #endif
  43. #if !defined(DOUBLE)
  44. #define MAXF s0
  45. #define TMPF s1
  46. #define TMPVF {v1.s}[0]
  47. #define SZ 4
  48. #else
  49. #define MAXF d0
  50. #define TMPF d1
  51. #define TMPVF {v1.d}[0]
  52. #define SZ 8
  53. #endif
  54. /******************************************************************************/
  55. .macro INIT_S
  56. #if !defined(DOUBLE)
  57. lsl INC_X, INC_X, #3
  58. ld1 {v0.2s}, [X], INC_X
  59. mov Z, #1
  60. mov INDEX, Z
  61. fabs v0.2s, v0.2s
  62. ext v1.8b, v0.8b, v0.8b, #4
  63. fadd MAXF, s0, s1
  64. #else
  65. lsl INC_X, INC_X, #4
  66. ld1 {v0.2d}, [X], INC_X
  67. mov Z, #1
  68. mov INDEX, Z
  69. fabs v0.2d, v0.2d
  70. faddp MAXF, v0.2d
  71. #endif
  72. .endm
  73. .macro KERNEL_S1
  74. #if !defined(DOUBLE)
  75. ld1 {v1.2s}, [X], INC_X
  76. add Z, Z, #1
  77. fabs v1.2s, v1.2s
  78. ext v2.8b, v1.8b, v1.8b, #4
  79. fadd TMPF, s1, s2
  80. #else
  81. ld1 {v1.2d}, [X], INC_X
  82. add Z, Z, #1
  83. fabs v1.2d, v1.2d
  84. faddp TMPF, v1.2d
  85. #endif
  86. fcmp MAXF, TMPF
  87. fcsel MAXF, MAXF, TMPF, COND
  88. csel INDEX, INDEX, Z, COND
  89. .endm
  90. /*******************************************************************************
  91. * End of macro definitions
  92. *******************************************************************************/
  93. PROLOGUE
  94. cmp N, xzr
  95. ble iamax_kernel_zero
  96. cmp INC_X, xzr
  97. ble iamax_kernel_zero
  98. INIT_S
  99. subs N, N, #1
  100. ble iamax_kernel_L999
  101. asr I, N, #2
  102. cmp I, xzr
  103. ble iamax_kernel_S1
  104. iamax_kernel_S4:
  105. KERNEL_S1
  106. KERNEL_S1
  107. KERNEL_S1
  108. KERNEL_S1
  109. subs I, I, #1
  110. bne iamax_kernel_S4
  111. iamax_kernel_S1:
  112. ands I, N, #3
  113. ble iamax_kernel_L999
  114. iamax_kernel_S10:
  115. KERNEL_S1
  116. subs I, I, #1
  117. bne iamax_kernel_S10
  118. iamax_kernel_L999:
  119. mov x0, INDEX
  120. ret
  121. iamax_kernel_zero:
  122. mov x0, xzr
  123. ret
  124. EPILOGUE