Skip to content

Commit 6355c25

Browse files
committed
Avoid taking root of negative number in symv_thread.c
This is similar to fixes in gh-1929, but there was one remaining occurance of this type of pattern in the driver/level2/*_thread.c files.
1 parent 5e244d8 commit 6355c25

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

driver/level2/symv_thread.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,11 @@ int CNAME(BLASLONG m, FLOAT *alpha, FLOAT *a, BLASLONG lda, FLOAT *x, BLASLONG i
166166
if (nthreads - num_cpu > 1) {
167167

168168
double di = (double)i;
169-
width = ((BLASLONG)(sqrt(di * di + dnum) - di) + mask) & ~mask;
169+
if (di * di - dnum > 0) {
170+
width = ((BLASLONG)(-sqrt(di * di - dnum) + di) + mask) & ~mask;
171+
} else {
172+
width = m - i;
173+
}
170174

171175
if (width < 4) width = 4;
172176
if (width > m - i) width = m - i;
@@ -212,9 +216,9 @@ int CNAME(BLASLONG m, FLOAT *alpha, FLOAT *a, BLASLONG lda, FLOAT *x, BLASLONG i
212216

213217
double di = (double)(m - i);
214218
if (di * di - dnum > 0) {
215-
width = ((BLASLONG)(-sqrt(di * di - dnum) + di) + mask) & ~mask;
219+
width = ((BLASLONG)(-sqrt(di * di - dnum) + di) + mask) & ~mask;
216220
} else {
217-
width = m - i;
221+
width = m - i;
218222
}
219223

220224
if (width < 4) width = 4;

0 commit comments

Comments
 (0)