From 66eafb16cfaf7e119afff96ff3e44663134141fa Mon Sep 17 00:00:00 2001 From: Jerome Robert Date: Mon, 18 Jan 2016 09:12:37 +0100 Subject: [PATCH] swap: disable multi-threading for small matrices Close #731 --- interface/swap.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/interface/swap.c b/interface/swap.c index 3baeb27..23b2e4e 100644 --- a/interface/swap.c +++ b/interface/swap.c @@ -77,12 +77,13 @@ void CNAME(blasint n, FLOAT *x, blasint incx, FLOAT *y, blasint incy){ if (incy < 0) y -= (n - 1) * incy; #ifdef SMP - nthreads = num_cpu_avail(1); //disable multi-thread when incx==0 or incy==0 //In that case, the threads would be dependent. - if (incx == 0 || incy == 0) - nthreads = 1; + if (incx == 0 || incy == 0 || n < 2097152 * GEMM_MULTITHREAD_THRESHOLD / sizeof(FLOAT)) + nthreads = 1; + else + nthreads = num_cpu_avail(1); if (nthreads == 1) { #endif -- 2.7.4