Skip to content

Commit 47b639c

Browse files
committed
Fix failed sswap and dswap case by using msa optimization
The swap test case will call sswap_msa.c and dswap_msa.c files in MIPS environmnet. When inc_x or inc_y is equal to zero, the calculation result of the two functions will be wrong. This patch adds the processing of inc_x or inc_y equal to zero, and the swap test case has passed.
1 parent 8fef587 commit 47b639c

File tree

2 files changed

+56
-3
lines changed

2 files changed

+56
-3
lines changed

kernel/mips/dswap_msa.c

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ int CNAME(BLASLONG n, BLASLONG dummy0, BLASLONG dummy1, FLOAT dummy3,
184184
}
185185
}
186186
}
187-
else
187+
else if ((inc_x != 0) && (inc_y != 0))
188188
{
189189
for (i = (n >> 3); i--;)
190190
{
@@ -248,6 +248,32 @@ int CNAME(BLASLONG n, BLASLONG dummy0, BLASLONG dummy1, FLOAT dummy3,
248248
}
249249
}
250250
}
251-
251+
else
252+
{
253+
if (inc_x == inc_y)
254+
{
255+
if (n & 1)
256+
{
257+
x0 = *srcx;
258+
*srcx = *srcy;
259+
*srcy = x0;
260+
}
261+
else
262+
return (0);
263+
}
264+
else
265+
{
266+
BLASLONG ix = 0, iy = 0;
267+
while (i < n)
268+
{
269+
x0 = srcx[ix];
270+
srcx[ix] = srcy[iy];
271+
srcy[iy] = x0;
272+
ix += inc_x;
273+
iy += inc_y;
274+
i++;
275+
}
276+
}
277+
}
252278
return (0);
253279
}

kernel/mips/sswap_msa.c

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ int CNAME(BLASLONG n, BLASLONG dummy0, BLASLONG dummy1, FLOAT dummy3,
198198
}
199199
}
200200
}
201-
else
201+
else if ((inc_x != 0) && (inc_y != 0))
202202
{
203203
for (i = (n >> 3); i--;)
204204
{
@@ -262,6 +262,33 @@ int CNAME(BLASLONG n, BLASLONG dummy0, BLASLONG dummy1, FLOAT dummy3,
262262
}
263263
}
264264
}
265+
else
266+
{
267+
if (inc_x == inc_y)
268+
{
269+
if (n & 1)
270+
{
271+
x0 = *srcx;
272+
*srcx = *srcy;
273+
*srcy = x0;
274+
}
275+
else
276+
return (0);
277+
}
278+
else
279+
{
280+
BLASLONG ix = 0, iy = 0;
281+
while (i < n)
282+
{
283+
x0 = srcx[ix];
284+
srcx[ix] = srcy[iy];
285+
srcy[iy] = x0;
286+
ix += inc_x;
287+
iy += inc_y;
288+
i++;
289+
}
290+
}
291+
}
265292

266293
return (0);
267294
}

0 commit comments

Comments
 (0)