Skip to content

Commit a3354a7

Browse files
authored
Cap the number of parallel threads
1 parent 5da4c93 commit a3354a7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

interface/gemm.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,12 @@ void CNAME(enum CBLAS_ORDER order, enum CBLAS_TRANSPOSE TransA, enum CBLAS_TRANS
533533
MNK = (double) args.m * (double) args.n * (double) args.k;
534534
if ( MNK <= (SMP_THRESHOLD_MIN * (double) GEMM_MULTITHREAD_THRESHOLD) )
535535
args.nthreads = 1;
536-
else
536+
else {
537537
args.nthreads = num_cpu_avail(3);
538+
if (MNK/args.nthreads < SMP_THRESHOLD_MIN*(double)GEMM_MULTITHREAD_THRESHOLD)
539+
args.nthreads = MNK/(SMP_THRESHOLD_MIN*(double)GEMM_MULTITHREAD_THRESHOLD);
540+
}
541+
538542
args.common = NULL;
539543

540544
if (args.nthreads == 1) {

0 commit comments

Comments
 (0)