Skip to content

Commit 4074770

Browse files
authored
Merge pull request #2797 from martin-frbg/relafixes1
ReLAPACK fixes
2 parents f42e84d + de63675 commit 4074770

33 files changed

+163
-59
lines changed

relapack/src/cgbtrf.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ void RELAPACK_cgbtrf(
3636
return;
3737
}
3838

39+
if (*m == 0 || *n == 0) return;
3940
// Constant
4041
const float ZERO[] = { 0., 0. };
4142

@@ -56,10 +57,10 @@ void RELAPACK_cgbtrf(
5657

5758
// Allocate work space
5859
const blasint n1 = CREC_SPLIT(*n);
59-
const blasint mWorkl = (kv > n1) ? MAX(1, *m - *kl) : kv;
60-
const blasint nWorkl = (kv > n1) ? n1 : kv;
61-
const blasint mWorku = (*kl > n1) ? n1 : *kl;
62-
const blasint nWorku = (*kl > n1) ? MAX(0, *n - *kl) : *kl;
60+
const blasint mWorkl = abs ( (kv > n1) ? MAX(1, *m - *kl) : kv);
61+
const blasint nWorkl = abs ( (kv > n1) ? n1 : kv);
62+
const blasint mWorku = abs ((*kl > n1) ? n1 : *kl);
63+
const blasint nWorku = abs ((*kl > n1) ? MAX(0, *n - *kl) : *kl);
6364
float *Workl = malloc(mWorkl * nWorkl * 2 * sizeof(float));
6465
float *Worku = malloc(mWorku * nWorku * 2 * sizeof(float));
6566
LAPACK(claset)("L", &mWorkl, &nWorkl, ZERO, ZERO, Workl, &mWorkl);
@@ -82,7 +83,7 @@ static void RELAPACK_cgbtrf_rec(
8283
blasint *info
8384
) {
8485

85-
if (*n <= MAX(CROSSOVER_CGBTRF, 1)) {
86+
if (*n <= MAX(CROSSOVER_CGBTRF, 1)|| *n > *kl || *ldAb == 1) {
8687
// Unblocked
8788
LAPACK(cgbtf2)(m, n, kl, ku, Ab, ldAb, ipiv, info);
8889
return;

relapack/src/cgetrf.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ void RELAPACK_cgetrf(
3030
return;
3131
}
3232

33+
if (*m == 0 || *n == 0) return;
34+
3335
const blasint sn = MIN(*m, *n);
3436

3537
RELAPACK_cgetrf_rec(m, &sn, A, ldA, ipiv, info);
@@ -62,9 +64,11 @@ static void RELAPACK_cgetrf_rec(
6264
blasint *info
6365
) {
6466

65-
if (*n <= MAX(CROSSOVER_CGETRF, 1)) {
67+
if (*m == 0 || *n == 0) return;
68+
69+
if ( *n <= MAX(CROSSOVER_CGETRF, 1)) {
6670
// Unblocked
67-
LAPACK(cgetf2)(m, n, A, ldA, ipiv, info);
71+
LAPACK(cgetrf2)(m, n, A, ldA, ipiv, info);
6872
return;
6973
}
7074

@@ -96,6 +100,7 @@ static void RELAPACK_cgetrf_rec(
96100

97101
// recursion(A_L, ipiv_T)
98102
RELAPACK_cgetrf_rec(m, &n1, A_L, ldA, ipiv_T, info);
103+
if (*info) return;
99104
// apply pivots to A_R
100105
LAPACK(claswp)(&n2, A_R, ldA, iONE, &n1, ipiv_T, iONE);
101106

relapack/src/chegst.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ void RELAPACK_chegst(
4040
return;
4141
}
4242

43+
if (*n == 0) return;
44+
4345
// Clean char * arguments
4446
const char cleanuplo = lower ? 'L' : 'U';
4547

relapack/src/chetrf_rook.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void RELAPACK_chetrf_rook(
3636
*info = -2;
3737
else if (*ldA < MAX(1, *n))
3838
*info = -4;
39-
else if (*lWork < minlWork && *lWork != -1)
39+
else if ((*lWork < 1 || *lWork < minlWork) && *lWork != -1)
4040
*info = -7;
4141
else if (*lWork == -1) {
4242
// Work size query
@@ -56,7 +56,7 @@ void RELAPACK_chetrf_rook(
5656

5757
if (*info) {
5858
const blasint minfo = -*info;
59-
LAPACK(xerbla)("CHETRF", &minfo, strlen("CHETRF"));
59+
LAPACK(xerbla)("CHETRF_ROOK", &minfo, strlen("CHETRF_ROOK"));
6060
return;
6161
}
6262

relapack/src/clauum.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ void RELAPACK_clauum(
3232
return;
3333
}
3434

35+
if (*n == 0) return;
36+
3537
// Clean char * arguments
3638
const char cleanuplo = lower ? 'L' : 'U';
3739

relapack/src/cpbtrf.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ void RELAPACK_cpbtrf(
3535
return;
3636
}
3737

38+
if (*n == 0) return;
39+
3840
// Clean char * arguments
3941
const char cleanuplo = lower ? 'L' : 'U';
4042

@@ -43,8 +45,8 @@ void RELAPACK_cpbtrf(
4345

4446
// Allocate work space
4547
const blasint n1 = CREC_SPLIT(*n);
46-
const blasint mWork = (*kd > n1) ? (lower ? *n - *kd : n1) : *kd;
47-
const blasint nWork = (*kd > n1) ? (lower ? n1 : *n - *kd) : *kd;
48+
const blasint mWork = abs((*kd > n1) ? (lower ? *n - *kd : n1) : *kd);
49+
const blasint nWork = abs((*kd > n1) ? (lower ? n1 : *n - *kd) : *kd);
4850
float *Work = malloc(mWork * nWork * 2 * sizeof(float));
4951
LAPACK(claset)(uplo, &mWork, &nWork, ZERO, ZERO, Work, &mWork);
5052

@@ -64,7 +66,7 @@ static void RELAPACK_cpbtrf_rec(
6466
blasint *info
6567
){
6668

67-
if (*n <= MAX(CROSSOVER_CPBTRF, 1)) {
69+
if (*n <= MAX(CROSSOVER_CPBTRF, 1) || *ldAb==1) {
6870
// Unblocked
6971
LAPACK(cpbtf2)(uplo, n, kd, Ab, ldAb, info);
7072
return;
@@ -148,7 +150,7 @@ static void RELAPACK_cpbtrf_rec(
148150
}
149151

150152
// recursion(A_BR)
151-
if (*kd > n1)
153+
if (*kd > n1 && ldA != 0)
152154
RELAPACK_cpotrf(uplo, &n2, A_BR, ldA, info);
153155
else
154156
RELAPACK_cpbtrf_rec(uplo, &n2, kd, Ab_BR, ldAb, Work, ldWork, info);

relapack/src/cpotrf.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ void RELAPACK_cpotrf(
3232
return;
3333
}
3434

35+
if (*n == 0) return;
36+
3537
// Clean char * arguments
3638
const char cleanuplo = lower ? 'L' : 'U';
3739

@@ -46,6 +48,7 @@ static void RELAPACK_cpotrf_rec(
4648
float *A, const blasint *ldA,
4749
blasint *info
4850
){
51+
if (*n == 0) return;
4952

5053
if (*n <= MAX(CROSSOVER_CPOTRF, 1)) {
5154
// Unblocked

relapack/src/csytrf.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void RELAPACK_csytrf(
3636
*info = -2;
3737
else if (*ldA < MAX(1, *n))
3838
*info = -4;
39-
else if (*lWork < minlWork && *lWork != -1)
39+
else if ((*lWork < 1 || *lWork < minlWork) && *lWork != -1)
4040
*info = -7;
4141
else if (*lWork == -1) {
4242
// Work size query
@@ -67,6 +67,7 @@ void RELAPACK_csytrf(
6767
blasint nout;
6868

6969
// Recursive kernel
70+
if (*n != 0)
7071
RELAPACK_csytrf_rec(&cleanuplo, n, n, &nout, A, ldA, ipiv, cleanWork, n, info);
7172

7273
#if XSYTRF_ALLOW_MALLOC

relapack/src/csytrf_rook.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void RELAPACK_csytrf_rook(
3636
*info = -2;
3737
else if (*ldA < MAX(1, *n))
3838
*info = -4;
39-
else if (*lWork < minlWork && *lWork != -1)
39+
else if ((*lWork < 1 || *lWork < minlWork) && *lWork != -1)
4040
*info = -7;
4141
else if (*lWork == -1) {
4242
// Work size query
@@ -56,7 +56,7 @@ void RELAPACK_csytrf_rook(
5656

5757
if (*info) {
5858
const blasint minfo = -*info;
59-
LAPACK(xerbla)("CSYTRF", &minfo, strlen("CSYTRF"));
59+
LAPACK(xerbla)("CSYTRF_ROOK", &minfo, strlen("CSYTRF_ROOK"));
6060
return;
6161
}
6262

relapack/src/ctgsyl.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ void RELAPACK_ctgsyl(
6868
return;
6969
}
7070

71+
if ( *m == 0 || *n == 0) {
72+
*scale = 1.;
73+
if (notran && (*ijob != 0))
74+
*dif = 0.;
75+
return;
76+
}
77+
7178
// Clean char * arguments
7279
const char cleantrans = notran ? 'N' : 'C';
7380

0 commit comments

Comments
 (0)