1 /*******************************************************************************
2 Copyright (c) 2016, 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
28 #include "common.h"
29 #include "macros_msa.h"
30
CNAME(BLASLONG n,FLOAT * x,BLASLONG inc_x,FLOAT * y,BLASLONG inc_y)31 int CNAME(BLASLONG n, FLOAT *x, BLASLONG inc_x, FLOAT *y, BLASLONG inc_y)
32 {
33 BLASLONG i;
34 v2f64 x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15;
35 FLOAT f0, f1;
36
37 if (n < 0) return (0);
38
39 if ((1 == inc_x) && (1 == inc_y))
40 {
41 if (n > 15)
42 {
43 FLOAT *x_pref;
44 BLASLONG pref_offset;
45
46 pref_offset = (BLASLONG)x & (L1_DATA_LINESIZE - 1);
47 if (pref_offset > 0)
48 {
49 pref_offset = L1_DATA_LINESIZE - pref_offset;
50 pref_offset = pref_offset / sizeof(FLOAT);
51 }
52 x_pref = x + pref_offset + 64 + 16;
53
54 LD_DP8_INC(x, 2, x0, x1, x2, x3, x4, x5, x6, x7);
55 for (i = (n >> 4) - 1; i--;)
56 {
57 PREF_OFFSET(x_pref, 0);
58 PREF_OFFSET(x_pref, 32);
59 PREF_OFFSET(x_pref, 64);
60 PREF_OFFSET(x_pref, 96);
61 PREF_OFFSET(x_pref, 128);
62 PREF_OFFSET(x_pref, 160);
63 PREF_OFFSET(x_pref, 192);
64 PREF_OFFSET(x_pref, 224);
65 x_pref += 32;
66
67 x8 = LD_DP(x); x += 2;
68 ST_DP(x0, y); y += 2;
69 x9 = LD_DP(x); x += 2;
70 ST_DP(x1, y); y += 2;
71 x10 = LD_DP(x); x += 2;
72 ST_DP(x2, y); y += 2;
73 x11 = LD_DP(x); x += 2;
74 ST_DP(x3, y); y += 2;
75 x12 = LD_DP(x); x += 2;
76 ST_DP(x4, y); y += 2;
77 x13 = LD_DP(x); x += 2;
78 ST_DP(x5, y); y += 2;
79 x14 = LD_DP(x); x += 2;
80 ST_DP(x6, y); y += 2;
81 x15 = LD_DP(x); x += 2;
82 ST_DP(x7, y); y += 2;
83 x0 = LD_DP(x); x += 2;
84 ST_DP(x8, y); y += 2;
85 x1 = LD_DP(x); x += 2;
86 ST_DP(x9, y); y += 2;
87 x2 = LD_DP(x); x += 2;
88 ST_DP(x10, y); y += 2;
89 x3 = LD_DP(x); x += 2;
90 ST_DP(x11, y); y += 2;
91 x4 = LD_DP(x); x += 2;
92 ST_DP(x12, y); y += 2;
93 x5 = LD_DP(x); x += 2;
94 ST_DP(x13, y); y += 2;
95 x6 = LD_DP(x); x += 2;
96 ST_DP(x14, y); y += 2;
97 x7 = LD_DP(x); x += 2;
98 ST_DP(x15, y); y += 2;
99 }
100
101 x8 = LD_DP(x); x += 2;
102 x9 = LD_DP(x); x += 2;
103 ST_DP(x0, y); y += 2;
104 x10 = LD_DP(x); x += 2;
105 ST_DP(x1, y); y += 2;
106 x11 = LD_DP(x); x += 2;
107 ST_DP(x2, y); y += 2;
108 x12 = LD_DP(x); x += 2;
109 ST_DP(x3, y); y += 2;
110 x13 = LD_DP(x); x += 2;
111 ST_DP(x4, y); y += 2;
112 x14 = LD_DP(x); x += 2;
113 ST_DP(x5, y); y += 2;
114 x15 = LD_DP(x); x += 2;
115 ST_DP(x6, y); y += 2;
116 ST_DP(x7, y); y += 2;
117
118 ST_DP8_INC(x8, x9, x10, x11, x12, x13, x14, x15, y, 2);
119 }
120
121 if (n & 15)
122 {
123 if (n & 8)
124 {
125 LD_DP8_INC(x, 2, x0, x1, x2, x3, x4, x5, x6, x7);
126 ST_DP8_INC(x0, x1, x2, x3, x4, x5, x6, x7, y, 2);
127 }
128
129 if (n & 4)
130 {
131 LD_DP4_INC(x, 2, x0, x1, x2, x3);
132 ST_DP4_INC(x0, x1, x2, x3, y, 2);
133 }
134
135 if (n & 2)
136 {
137 LD_DP2_INC(x, 2, x0, x1);
138 ST_DP2_INC(x0, x1, y, 2);
139 }
140
141 if (n & 1)
142 {
143 LD_GP2_INC(x, 1, f0, f1);
144 ST_GP2_INC(f0, f1, y, 1);
145 }
146 }
147 }
148 else
149 {
150 inc_x *= 2;
151 inc_y *= 2;
152
153 for (i = (n >> 4); i--;)
154 {
155 x0 = LD_DP(x); x += inc_x;
156 x1 = LD_DP(x); x += inc_x;
157 x2 = LD_DP(x); x += inc_x;
158 x3 = LD_DP(x); x += inc_x;
159 x4 = LD_DP(x); x += inc_x;
160 x5 = LD_DP(x); x += inc_x;
161 x6 = LD_DP(x); x += inc_x;
162 x7 = LD_DP(x); x += inc_x;
163 x8 = LD_DP(x); x += inc_x;
164 ST_DP(x0, y); y += inc_y;
165 x9 = LD_DP(x); x += inc_x;
166 ST_DP(x1, y); y += inc_y;
167 x10 = LD_DP(x); x += inc_x;
168 ST_DP(x2, y); y += inc_y;
169 x11 = LD_DP(x); x += inc_x;
170 ST_DP(x3, y); y += inc_y;
171 x12 = LD_DP(x); x += inc_x;
172 ST_DP(x4, y); y += inc_y;
173 x13 = LD_DP(x); x += inc_x;
174 ST_DP(x5, y); y += inc_y;
175 x14 = LD_DP(x); x += inc_x;
176 ST_DP(x6, y); y += inc_y;
177 x15 = LD_DP(x); x += inc_x;
178 ST_DP(x7, y); y += inc_y;
179 ST_DP(x8, y); y += inc_y;
180 ST_DP(x9, y); y += inc_y;
181 ST_DP(x10, y); y += inc_y;
182 ST_DP(x11, y); y += inc_y;
183 ST_DP(x12, y); y += inc_y;
184 ST_DP(x13, y); y += inc_y;
185 ST_DP(x14, y); y += inc_y;
186 ST_DP(x15, y); y += inc_y;
187 }
188
189 if (n & 15)
190 {
191 if (n & 8)
192 {
193 LD_DP8_INC(x, inc_x, x0, x1, x2, x3, x4, x5, x6, x7);
194 ST_DP8_INC(x0, x1, x2, x3, x4, x5, x6, x7, y, inc_y);
195 }
196
197 if (n & 4)
198 {
199 LD_DP4_INC(x, inc_x, x0, x1, x2, x3);
200 ST_DP4_INC(x0, x1, x2, x3, y, inc_y);
201 }
202
203 if (n & 2)
204 {
205 LD_DP2_INC(x, inc_x, x0, x1);
206 ST_DP2_INC(x0, x1, y, inc_y);
207 }
208
209 if (n & 1)
210 {
211 LD_GP2_INC(x, 1, f0, f1);
212 ST_GP2_INC(f0, f1, y, 1);
213 }
214 }
215 }
216
217 return (0);
218 }
219