Skip to content

Commit dc8b16c

Browse files
authored
Move the early exit for NRHS=0 after the GETRF call
1 parent 3166fff commit dc8b16c

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

interface/lapack/gesv.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ int NAME(blasint *N, blasint *NRHS, FLOAT *a, blasint *ldA, blasint *ipiv,
9999

100100
*Info = 0;
101101

102-
if (args.m == 0 || args.n == 0) return 0;
102+
if (args.m == 0) return 0;
103103

104104
IDEBUG_START;
105105

@@ -117,20 +117,20 @@ int NAME(blasint *N, blasint *NRHS, FLOAT *a, blasint *ldA, blasint *ipiv,
117117

118118
#if defined(_WIN64) && defined(_M_ARM64)
119119
#ifdef COMPLEX
120-
if (args.m * args.n <= 300)
120+
if (args.m * args.m <= 300)
121121
#else
122-
if (args.m * args.n <= 500)
122+
if (args.m * args.m <= 500)
123123
#endif
124124
args.nthreads = 1;
125-
else if (args.m * args.n <= 1000)
125+
else if (args.m * args.m <= 1000)
126126
args.nthreads = 4;
127127
else
128128
args.nthreads = num_cpu_avail(4);
129129
#else
130130
#ifndef DOUBLE
131-
if (args.m * args.n < 40000)
131+
if (args.m * args.m < 40000)
132132
#else
133-
if (args.m * args.n < 10000)
133+
if (args.m * args.m < 10000)
134134
#endif
135135
args.nthreads = 1;
136136
else
@@ -143,7 +143,7 @@ int NAME(blasint *N, blasint *NRHS, FLOAT *a, blasint *ldA, blasint *ipiv,
143143
args.n = *N;
144144
info = GETRF_SINGLE(&args, NULL, NULL, sa, sb, 0);
145145

146-
if (info == 0){
146+
if (info == 0 && *NRHS >0){
147147
args.n = *NRHS;
148148
GETRS_N_SINGLE(&args, NULL, NULL, sa, sb, 0);
149149
}
@@ -154,7 +154,7 @@ int NAME(blasint *N, blasint *NRHS, FLOAT *a, blasint *ldA, blasint *ipiv,
154154
args.n = *N;
155155
info = GETRF_PARALLEL(&args, NULL, NULL, sa, sb, 0);
156156

157-
if (info == 0){
157+
if (info == 0 && *NRHS > 0){
158158
args.n = *NRHS;
159159
GETRS_N_PARALLEL(&args, NULL, NULL, sa, sb, 0);
160160
}

0 commit comments

Comments
 (0)