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.

iamax.S 3.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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, #2
  58. ld1 {v0.s}[0], [X], INC_X
  59. #else
  60. lsl INC_X, INC_X, #3
  61. ld1 {v0.d}[0], [X], INC_X
  62. #endif
  63. mov Z, #1
  64. mov INDEX, Z
  65. fabs MAXF, MAXF
  66. .endm
  67. .macro KERNEL_S1
  68. ld1 TMPVF, [X], INC_X
  69. add Z, Z, #1
  70. fabs TMPF, TMPF
  71. fcmp MAXF, TMPF
  72. fcsel MAXF, MAXF, TMPF, COND
  73. csel INDEX, INDEX, Z, COND
  74. .endm
  75. /*******************************************************************************
  76. * End of macro definitions
  77. *******************************************************************************/
  78. PROLOGUE
  79. cmp N, xzr
  80. ble iamax_kernel_zero
  81. cmp INC_X, xzr
  82. ble iamax_kernel_zero
  83. INIT_S
  84. subs N, N, #1
  85. ble iamax_kernel_L999
  86. asr I, N, #2
  87. cmp I, xzr
  88. ble iamax_kernel_S1
  89. iamax_kernel_S4:
  90. KERNEL_S1
  91. KERNEL_S1
  92. KERNEL_S1
  93. KERNEL_S1
  94. subs I, I, #1
  95. bne iamax_kernel_S4
  96. iamax_kernel_S1:
  97. ands I, N, #3
  98. ble iamax_kernel_L999
  99. iamax_kernel_S10:
  100. KERNEL_S1
  101. subs I, I, #1
  102. bne iamax_kernel_S10
  103. iamax_kernel_L999:
  104. mov x0, INDEX
  105. ret
  106. iamax_kernel_zero:
  107. mov x0, xzr
  108. ret
  109. EPILOGUE