swap: disable multi-threading for small matrices
authorJerome Robert <jeromerobert@gmx.com>
Mon, 18 Jan 2016 08:12:37 +0000 (09:12 +0100)
committerJerome Robert <jeromerobert@gmx.com>
Tue, 19 Jan 2016 16:14:46 +0000 (17:14 +0100)
Close #731

interface/swap.c

index 3baeb27..23b2e4e 100644 (file)
@@ -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