Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cap the number of parallel threads for GEMM;GETRF and POTRF to ensure sensible workloads on big systems #4585

Merged
merged 5 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion interface/gemm.c
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,12 @@ void CNAME(enum CBLAS_ORDER order, enum CBLAS_TRANSPOSE TransA, enum CBLAS_TRANS
MNK = (double) args.m * (double) args.n * (double) args.k;
if ( MNK <= (SMP_THRESHOLD_MIN * (double) GEMM_MULTITHREAD_THRESHOLD) )
args.nthreads = 1;
else
else {
args.nthreads = num_cpu_avail(3);
if (MNK/args.nthreads < SMP_THRESHOLD_MIN*(double)GEMM_MULTITHREAD_THRESHOLD)
args.nthreads = MNK/(SMP_THRESHOLD_MIN*(double)GEMM_MULTITHREAD_THRESHOLD);
}

args.common = NULL;

if (args.nthreads == 1) {
Expand Down
17 changes: 11 additions & 6 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)
int nmax = 40000;
#else
int nmax = 10000;
#endif
args.nthreads=1;
else
args.nthreads = num_cpu_avail(4);
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
14 changes: 9 additions & 5 deletions interface/lapack/potrf.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,17 @@ int NAME(char *UPLO, blasint *N, FLOAT *a, blasint *ldA, blasint *Info){
#ifdef SMP
args.common = NULL;
#ifndef DOUBLE
if (args.n <128)
#else
if (args.n <64)
int nmax = 128;
#else
int nmax = 64;
#endif
if (args.n <nmax) {
args.nthreads = 1;
else
args.nthreads = num_cpu_avail(4);
} else {
args.nthreads = num_cpu_avail(4);
if (args.n/args.nthreads <nmax)
args.nthreads = args.n/nmax;
}

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