From 8e7e14b6aa4b51c65b5d2f916bc2b0f8bf7b5a4b Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Tue, 11 Jun 2024 15:17:20 +0200 Subject: [PATCH] avoid setting nthreads higher than available --- kernel/x86_64/tobf16.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/x86_64/tobf16.c b/kernel/x86_64/tobf16.c index a88fdcc2e..6547f2522 100644 --- a/kernel/x86_64/tobf16.c +++ b/kernel/x86_64/tobf16.c @@ -135,7 +135,7 @@ void CNAME(BLASLONG n, FLOAT_TYPE * in, BLASLONG inc_in, bfloat16 * out, BLASLON if (n <= 0) return; #if defined(SMP) - int nthreads; + int nthreads = blas_cpu_number(1); FLOAT_TYPE dummy_alpha; FLOAT_TYPE dummy_c; #endif @@ -145,9 +145,9 @@ void CNAME(BLASLONG n, FLOAT_TYPE * in, BLASLONG inc_in, bfloat16 * out, BLASLON nthreads = 1; } else { if (n/100000 < 100) { - nthreads = 4; + nthreads = MAX(nthreads,4); } else { - nthreads = 16; + nthreads = MAX(nthreads,16); } }