From 496106642f77c7d319ee9966c067cdf0040462ab Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Wed, 27 Mar 2024 20:32:11 +0100 Subject: [PATCH 1/5] Cap the number of parallel threads --- interface/lapack/potrf.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/interface/lapack/potrf.c b/interface/lapack/potrf.c index 3abc801333..d4a56c94ad 100644 --- a/interface/lapack/potrf.c +++ b/interface/lapack/potrf.c @@ -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) -#endif + int nmax = 128; +#else + int nmax = 64; +endif + if (args.n Date: Wed, 27 Mar 2024 20:34:55 +0100 Subject: [PATCH 2/5] Cap the number of parallel threads --- interface/lapack/getrf.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/interface/lapack/getrf.c b/interface/lapack/getrf.c index 323370ebc6..7d1f6bc705 100644 --- a/interface/lapack/getrf.c +++ b/interface/lapack/getrf.c @@ -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 Date: Wed, 27 Mar 2024 22:00:30 +0100 Subject: [PATCH 3/5] Cap the number of parallel threads --- interface/gemm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/interface/gemm.c b/interface/gemm.c index 4778b641bb..0902bc0249 100644 --- a/interface/gemm.c +++ b/interface/gemm.c @@ -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) { From 19b29b3448239d14c3541699e8543e6f9a2cd7b6 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Wed, 27 Mar 2024 22:09:30 +0100 Subject: [PATCH 4/5] Update getrf.c --- interface/lapack/getrf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/lapack/getrf.c b/interface/lapack/getrf.c index 7d1f6bc705..270604120f 100644 --- a/interface/lapack/getrf.c +++ b/interface/lapack/getrf.c @@ -100,7 +100,7 @@ int NAME(blasint *M, blasint *N, FLOAT *a, blasint *ldA, blasint *ipiv, blasint int nmax = 40000; #else int nmax = 10000; -endif +#endif if (args.m*args.n Date: Wed, 27 Mar 2024 22:10:01 +0100 Subject: [PATCH 5/5] Update potrf.c --- interface/lapack/potrf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/lapack/potrf.c b/interface/lapack/potrf.c index d4a56c94ad..a24e48d95b 100644 --- a/interface/lapack/potrf.c +++ b/interface/lapack/potrf.c @@ -116,7 +116,7 @@ int NAME(char *UPLO, blasint *N, FLOAT *a, blasint *ldA, blasint *Info){ int nmax = 128; #else int nmax = 64; -endif +#endif if (args.n