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.

axpy_sve.c 3.0 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /***************************************************************************
  2. Copyright (c) 2025, 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
  16. permission.
  17. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  18. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20. ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  21. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  23. SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  24. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  25. OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
  26. USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. *****************************************************************************/
  28. #include <arm_sve.h>
  29. #include "common.h"
  30. #ifdef DOUBLE
  31. #define SV_TYPE svfloat64_t
  32. #define SV_COUNT svcntd
  33. #define SV_DUP svdup_f64
  34. #define SV_WHILE svwhilelt_b64_s64
  35. #define SV_TRUE svptrue_b64
  36. #else
  37. #define SV_TYPE svfloat32_t
  38. #define SV_COUNT svcntw
  39. #define SV_DUP svdup_f32
  40. #define SV_WHILE svwhilelt_b32_s64
  41. #define SV_TRUE svptrue_b32
  42. #endif
  43. int CNAME(BLASLONG n, BLASLONG dummy0, BLASLONG dummy1, FLOAT da, FLOAT *x, BLASLONG inc_x, FLOAT *y, BLASLONG inc_y, FLOAT *dummy, BLASLONG dummy2) {
  44. BLASLONG i = 0;
  45. BLASLONG ix = 0, iy = 0;
  46. BLASLONG sve_size = SV_COUNT();
  47. if (n < 0) return (0);
  48. if (da == 0.0) return (0);
  49. if (inc_x == 1 && inc_y == 1) {
  50. SV_TYPE da_vec = SV_DUP(da);
  51. for (i = 0; i + sve_size - 1 < n; i += sve_size) {
  52. SV_TYPE x_vec = svld1(SV_TRUE(), &x[i]);
  53. SV_TYPE y_vec = svld1(SV_TRUE(), &y[i]);
  54. y_vec = svmla_x(SV_TRUE(), y_vec, da_vec, x_vec);
  55. svst1(SV_TRUE(), &y[i], y_vec);
  56. }
  57. if (i < n) {
  58. svbool_t pg = SV_WHILE(i, n);
  59. SV_TYPE x_vec = svld1(pg, &x[i]);
  60. SV_TYPE y_vec = svld1(pg, &y[i]);
  61. y_vec = svmla_x(pg, y_vec, da_vec, x_vec);
  62. svst1(pg, &y[i], y_vec);
  63. }
  64. return (0);
  65. }
  66. while (i < n) {
  67. y[iy] += da * x[ix];
  68. ix += inc_x;
  69. iy += inc_y;
  70. i++;
  71. }
  72. return (0);
  73. }