Skip to content

Commit

Permalink
Cap the number of parallel threads
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-frbg authored Mar 27, 2024
1 parent 4961066 commit 5da4c93
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions interface/lapack/getrf.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,19 @@ int NAME(blasint *M, blasint *N, FLOAT *a, blasint *ldA, blasint *ipiv, blasint

#ifdef SMP
args.common = NULL;

#ifndef DOUBLE
if (args.m*args.n < 40000)
#else
if (args.m*args.n < 10000)
#endif
args.nthreads=1;
else
args.nthreads = num_cpu_avail(4);
int nmax = 40000;
#else
int nmax = 10000;
endif
if (args.m*args.n <nmax) {
args.nthreads = 1;
} else {
args.nthreads = num_cpu_avail(4);
if ((args.m*args.n)/args.nthreads <nmax)
args.nthreads = (args.m*args.n)/nmax;
}

if (args.nthreads == 1) {
#endif
Expand Down

0 comments on commit 5da4c93

Please sign in to comment.