Add early returns

This commit is contained in:
Martin Kroeker 2020-08-27 11:20:31 +02:00 committed by GitHub
parent 6797a3a1e0
commit c9b67141f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 36 additions and 18 deletions

View File

@ -29,15 +29,16 @@ void RELAPACK_dgetrf(
return;
}
const blasint sn = MIN(*m, *n);
if (*m == 0 || *n == 0) return;
const blasint sn = MIN(*m, *n);
RELAPACK_dgetrf_rec(m, &sn, A, ldA, ipiv, info);
// Right remainder
if (*m < *n) {
// Constants
const double ONE[] = { 1. };
const blasint iONE[] = { 1. };
const blasint iONE[] = { 1 };
// Splitting
const blasint rn = *n - *m;
@ -60,13 +61,11 @@ static void RELAPACK_dgetrf_rec(
double *A, const blasint *ldA, blasint *ipiv,
blasint *info
) {
if (*n <= MAX(CROSSOVER_DGETRF, 1)) {
if ( *n <= MAX(CROSSOVER_DGETRF, 1)) {
// Unblocked
LAPACK(dgetf2)(m, n, A, ldA, ipiv, info);
LAPACK(dgetrf2)(m, n, A, ldA, ipiv, info);
return;
}
// Constants
const double ONE[] = { 1. };
const double MONE[] = { -1. };
@ -95,6 +94,7 @@ static void RELAPACK_dgetrf_rec(
// recursion(A_L, ipiv_T)
RELAPACK_dgetrf_rec(m, &n1, A_L, ldA, ipiv_T, info);
if (*info) return;
// apply pivots to A_R
LAPACK(dlaswp)(&n2, A_R, ldA, iONE, &n1, ipiv_T, iONE);

View File

@ -36,7 +36,7 @@ void RELAPACK_dsytrf(
*info = -2;
else if (*ldA < MAX(1, *n))
*info = -4;
else if (*lWork < minlWork && *lWork != -1)
else if ((*lWork < 1 || *lWork < minlWork) && *lWork != -1)
*info = -7;
else if (*lWork == -1) {
// Work size query
@ -67,6 +67,7 @@ void RELAPACK_dsytrf(
blasint nout;
// Recursive kernel
if (*n != 0)
RELAPACK_dsytrf_rec(&cleanuplo, n, n, &nout, A, ldA, ipiv, cleanWork, n, info);
#if XSYTRF_ALLOW_MALLOC

View File

@ -36,7 +36,7 @@ void RELAPACK_dsytrf_rook(
*info = -2;
else if (*ldA < MAX(1, *n))
*info = -4;
else if (*lWork < minlWork && *lWork != -1)
else if ((*lWork <1 || *lWork < minlWork) && *lWork != -1)
*info = -7;
else if (*lWork == -1) {
// Work size query
@ -56,7 +56,7 @@ void RELAPACK_dsytrf_rook(
if (*info) {
const blasint minfo = -*info;
LAPACK(xerbla)("DSYTRF", &minfo, strlen("DSYTRF"));
LAPACK(xerbla)("DSYTRF_ROOK", &minfo, strlen("DSYTRF_ROOK"));
return;
}

View File

@ -49,6 +49,11 @@ void RELAPACK_dtrsyl(
return;
}
if (*m == 0 || *n == 0) {
*scale = 1.;
return;
}
// Clean char * arguments
const char cleantranA = notransA ? 'N' : (transA ? 'T' : 'C');
const char cleantranB = notransB ? 'N' : (transB ? 'T' : 'C');

View File

@ -30,6 +30,7 @@ void RELAPACK_zgetrf(
return;
}
if (*m == 0 || *n == 0) return;
const blasint sn = MIN(*m, *n);
RELAPACK_zgetrf_rec(m, &sn, A, ldA, ipiv, info);
@ -62,9 +63,11 @@ static void RELAPACK_zgetrf_rec(
blasint *info
) {
if (*n <= MAX(CROSSOVER_ZGETRF, 1)) {
if (*m == 0 || *n == 0) return;
if ( *n <= MAX(CROSSOVER_ZGETRF, 1)) {
// Unblocked
LAPACK(zgetf2)(m, n, A, ldA, ipiv, info);
LAPACK(zgetrf2)(m, n, A, ldA, ipiv, info);
return;
}
@ -96,6 +99,8 @@ static void RELAPACK_zgetrf_rec(
// recursion(A_L, ipiv_T)
RELAPACK_zgetrf_rec(m, &n1, A_L, ldA, ipiv_T, info);
if (*info) return;
// apply pivots to A_R
LAPACK(zlaswp)(&n2, A_R, ldA, iONE, &n1, ipiv_T, iONE);

View File

@ -36,7 +36,7 @@ void RELAPACK_zhetrf_rook(
*info = -2;
else if (*ldA < MAX(1, *n))
*info = -4;
else if (*lWork < minlWork && *lWork != -1)
else if ((*lWork < 1 || *lWork < minlWork) && *lWork != -1)
*info = -7;
else if (*lWork == -1) {
// Work size query
@ -56,7 +56,7 @@ void RELAPACK_zhetrf_rook(
if (*info) {
const blasint minfo = -*info;
LAPACK(xerbla)("ZHETRF", &minfo, strlen("ZHETRF"));
LAPACK(xerbla)("ZHETRF_ROOK", &minfo, strlen("ZHETRF_ROOK"));
return;
}

View File

@ -36,7 +36,7 @@ void RELAPACK_zsytrf(
*info = -2;
else if (*ldA < MAX(1, *n))
*info = -4;
else if (*lWork < minlWork && *lWork != -1)
else if ((*lWork < 1 || *lWork < minlWork) && *lWork != -1)
*info = -7;
else if (*lWork == -1) {
// Work size query
@ -67,6 +67,7 @@ void RELAPACK_zsytrf(
blasint nout;
// Recursive kernel
if (*n != 0)
RELAPACK_zsytrf_rec(&cleanuplo, n, n, &nout, A, ldA, ipiv, cleanWork, n, info);
#if XSYTRF_ALLOW_MALLOC

View File

@ -36,7 +36,7 @@ void RELAPACK_zsytrf_rook(
*info = -2;
else if (*ldA < MAX(1, *n))
*info = -4;
else if (*lWork < minlWork && *lWork != -1)
else if ((*lWork < 1 || *lWork < minlWork) && *lWork != -1)
*info = -7;
else if (*lWork == -1) {
// Work size query
@ -56,7 +56,7 @@ void RELAPACK_zsytrf_rook(
if (*info) {
const blasint minfo = -*info;
LAPACK(xerbla)("ZSYTRF", &minfo, strlen("ZSYTRF"));
LAPACK(xerbla)("ZSYTRF_ROOK", &minfo, strlen("ZSYTRF_ROOK"));
return;
}
@ -67,6 +67,7 @@ void RELAPACK_zsytrf_rook(
blasint nout;
// Recursive kernel
if (*n != 0)
RELAPACK_zsytrf_rook_rec(&cleanuplo, n, n, &nout, A, ldA, ipiv, cleanWork, n, info);
#if XSYTRF_ALLOW_MALLOC

View File

@ -47,6 +47,11 @@ void RELAPACK_ztrsyl(
return;
}
if (*m == 0 || *n == 0) {
*scale = 1.;
return;
}
// Clean char * arguments
const char cleantranA = notransA ? 'N' : 'C';
const char cleantranB = notransB ? 'N' : 'C';

View File

@ -69,8 +69,8 @@ static void RELAPACK_ztrtri_rec(
}
// Constants
const double ONE[] = { 1. };
const double MONE[] = { -1. };
const double ONE[] = { 1., 0. };
const double MONE[] = { -1. , 0. };
// Splitting
const blasint n1 = ZREC_SPLIT(*n);