|
| 1 | +/*************************************************************************** |
| 2 | +Copyright (c) 2024, The OpenBLAS Project |
| 3 | +All rights reserved. |
| 4 | +
|
| 5 | +Redistribution and use in source and binary forms, with or without |
| 6 | +modification, are permitted provided that the following conditions are |
| 7 | +met: |
| 8 | +
|
| 9 | + 1. Redistributions of source code must retain the above copyright |
| 10 | + notice, this list of conditions and the following disclaimer. |
| 11 | +
|
| 12 | + 2. Redistributions in binary form must reproduce the above copyright |
| 13 | + notice, this list of conditions and the following disclaimer in |
| 14 | + the documentation and/or other materials provided with the |
| 15 | + distribution. |
| 16 | + 3. Neither the name of the OpenBLAS project nor the names of |
| 17 | + its contributors may be used to endorse or promote products |
| 18 | + derived from this software without specific prior written |
| 19 | + permission. |
| 20 | +
|
| 21 | +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 22 | +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 23 | +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 24 | +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
| 25 | +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 26 | +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 27 | +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 28 | +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 29 | +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE |
| 30 | +USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 31 | +*****************************************************************************/ |
| 32 | + |
| 33 | +#include <arm_sve.h> |
| 34 | +#include "common.h" |
| 35 | + |
| 36 | +#ifdef DOUBLE |
| 37 | +#define SV_COUNT svcntd |
| 38 | +#define SV_TYPE svfloat64_t |
| 39 | +#define SV_TRUE svptrue_b64 |
| 40 | +#define SV_WHILE svwhilelt_b64 |
| 41 | +#define SV_DUP svdup_f64 |
| 42 | +#else |
| 43 | +#define SV_COUNT svcntw |
| 44 | +#define SV_TYPE svfloat32_t |
| 45 | +#define SV_TRUE svptrue_b32 |
| 46 | +#define SV_WHILE svwhilelt_b32 |
| 47 | +#define SV_DUP svdup_f32 |
| 48 | +#endif |
| 49 | + |
| 50 | +int CNAME(BLASLONG m, BLASLONG n, BLASLONG dummy1, FLOAT alpha, FLOAT *a, BLASLONG lda, FLOAT *x, BLASLONG inc_x, FLOAT *y, BLASLONG inc_y, FLOAT *buffer) |
| 51 | +{ |
| 52 | + BLASLONG i; |
| 53 | + BLASLONG ix,iy; |
| 54 | + BLASLONG j; |
| 55 | + FLOAT *a_ptr; |
| 56 | + FLOAT temp; |
| 57 | + |
| 58 | + ix = 0; |
| 59 | + a_ptr = a; |
| 60 | + |
| 61 | + if (inc_y == 1) { |
| 62 | + uint64_t sve_size = SV_COUNT(); |
| 63 | + for (j = 0; j < n; j++) { |
| 64 | + SV_TYPE temp_vec = SV_DUP(alpha * x[ix]); |
| 65 | + i = 0; |
| 66 | + svbool_t pg = SV_WHILE(i, m); |
| 67 | + while (svptest_any(SV_TRUE(), pg)) { |
| 68 | + SV_TYPE a_vec = svld1(pg, a_ptr + i); |
| 69 | + SV_TYPE y_vec = svld1(pg, y + i); |
| 70 | + y_vec = svmla_x(pg, y_vec, temp_vec, a_vec); |
| 71 | + svst1(pg, y + i, y_vec); |
| 72 | + i += sve_size; |
| 73 | + pg = SV_WHILE(i, m); |
| 74 | + } |
| 75 | + a_ptr += lda; |
| 76 | + ix += inc_x; |
| 77 | + } |
| 78 | + return(0); |
| 79 | + } |
| 80 | + |
| 81 | + for (j = 0; j < n; j++) { |
| 82 | + temp = alpha * x[ix]; |
| 83 | + iy = 0; |
| 84 | + for (i = 0; i < m; i++) { |
| 85 | + y[iy] += temp * a_ptr[i]; |
| 86 | + iy += inc_y; |
| 87 | + } |
| 88 | + a_ptr += lda; |
| 89 | + ix += inc_x; |
| 90 | + } |
| 91 | + return (0); |
| 92 | +} |
0 commit comments