Skip to content

Commit 4961066

Browse files
authored
Cap the number of parallel threads
1 parent 9af2a9d commit 4961066

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

interface/lapack/potrf.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,17 @@ int NAME(char *UPLO, blasint *N, FLOAT *a, blasint *ldA, blasint *Info){
113113
#ifdef SMP
114114
args.common = NULL;
115115
#ifndef DOUBLE
116-
if (args.n <128)
117-
#else
118-
if (args.n <64)
119-
#endif
116+
int nmax = 128;
117+
#else
118+
int nmax = 64;
119+
endif
120+
if (args.n <nmax) {
120121
args.nthreads = 1;
121-
else
122-
args.nthreads = num_cpu_avail(4);
122+
} else {
123+
args.nthreads = num_cpu_avail(4);
124+
if (args.n/args.nthreads <nmax)
125+
args.nthreads = args.n/nmax;
126+
}
123127

124128
if (args.nthreads == 1) {
125129
#endif

0 commit comments

Comments
 (0)