Add early returns

This commit is contained in:
Martin Kroeker 2020-08-27 11:22:50 +02:00 committed by GitHub
parent c9b67141f0
commit d64cc2be81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 7 deletions

View File

@ -14,7 +14,6 @@ void RELAPACK_sgetrf(
float *A, const blasint *ldA, blasint *ipiv, float *A, const blasint *ldA, blasint *ipiv,
blasint *info blasint *info
) { ) {
// Check arguments // Check arguments
*info = 0; *info = 0;
if (*m < 0) if (*m < 0)
@ -28,6 +27,9 @@ void RELAPACK_sgetrf(
LAPACK(xerbla)("SGETRF", &minfo, strlen("SGETRF")); LAPACK(xerbla)("SGETRF", &minfo, strlen("SGETRF"));
return; return;
} }
if (*m == 0 || *n == 0) return;
const blasint sn = MIN(*m, *n); const blasint sn = MIN(*m, *n);
RELAPACK_sgetrf_rec(m, &sn, A, ldA, ipiv, info); RELAPACK_sgetrf_rec(m, &sn, A, ldA, ipiv, info);
@ -35,7 +37,7 @@ void RELAPACK_sgetrf(
if (*m < *n) { if (*m < *n) {
// Constants // Constants
const float ONE[] = { 1. }; const float ONE[] = { 1. };
const blasint iONE[] = { 1. }; const blasint iONE[] = { 1 };
// Splitting // Splitting
const blasint rn = *n - *m; const blasint rn = *n - *m;
@ -58,9 +60,12 @@ static void RELAPACK_sgetrf_rec(
float *A, const blasint *ldA, blasint *ipiv, float *A, const blasint *ldA, blasint *ipiv,
blasint *info blasint *info
) { ) {
if (*n <= MAX(CROSSOVER_SGETRF, 1)) {
if (*m == 0 || *n == 0) return;
if ( *n <= MAX(CROSSOVER_SGETRF, 1)) {
// Unblocked // Unblocked
LAPACK(sgetf2)(m, n, A, ldA, ipiv, info); LAPACK(sgetrf2)(m, n, A, ldA, ipiv, info);
return; return;
} }
@ -91,6 +96,8 @@ static void RELAPACK_sgetrf_rec(
// recursion(A_L, ipiv_T) // recursion(A_L, ipiv_T)
RELAPACK_sgetrf_rec(m, &n1, A_L, ldA, ipiv_T, info); RELAPACK_sgetrf_rec(m, &n1, A_L, ldA, ipiv_T, info);
if (*info)
return;
// apply pivots to A_R // apply pivots to A_R
LAPACK(slaswp)(&n2, A_R, ldA, iONE, &n1, ipiv_T, iONE); LAPACK(slaswp)(&n2, A_R, ldA, iONE, &n1, ipiv_T, iONE);

View File

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

View File

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

View File

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