Use GEMM_MULTITHREAD_THRESHOLD as a number of ops
authorJerome Robert <jeromerobert@gmx.com>
Sun, 24 Jan 2016 09:30:50 +0000 (10:30 +0100)
committerJerome Robert <jeromerobert@gmx.com>
Sun, 24 Jan 2016 10:31:40 +0000 (11:31 +0100)
...not a matrix size. For GEMM_MULTITHREAD_THRESHOLD=4
(the default value) this does not change anything but
for other values it make the GEMM and GEMV thresholds
changing in the same way.

Close #742

interface/gemv.c
interface/zgemv.c

index 8e0bdcc..30709e3 100644 (file)
@@ -82,9 +82,6 @@ void NAME(char *TRANS, blasint *M, blasint *N,
   int buffer_size;
 #ifdef SMP
   int nthreads;
-  int nthreads_max;
-  int nthreads_avail;
-  double MNK;
 #endif
 
   int (*gemv[])(BLASLONG, BLASLONG, BLASLONG, FLOAT, FLOAT *, BLASLONG,  FLOAT * , BLASLONG, FLOAT *, BLASLONG, FLOAT *) = {
@@ -139,9 +136,6 @@ void CNAME(enum CBLAS_ORDER order,
   blasint info, t;
 #ifdef SMP
   int nthreads;
-  int nthreads_max;
-  int nthreads_avail;
-  double MNK;
 #endif
 
   int (*gemv[])(BLASLONG, BLASLONG, BLASLONG, FLOAT, FLOAT *, BLASLONG,  FLOAT * , BLASLONG, FLOAT *, BLASLONG, FLOAT *) = {
@@ -226,17 +220,10 @@ void CNAME(enum CBLAS_ORDER order,
 
 #ifdef SMP
 
-  nthreads_max = num_cpu_avail(2);
-  nthreads_avail = nthreads_max;
-
-  MNK = (double) m * (double) n;
-  if ( MNK <= (24.0 * 24.0  * (double) (GEMM_MULTITHREAD_THRESHOLD*GEMM_MULTITHREAD_THRESHOLD) )  )
-        nthreads_max = 1;
-
-  if ( nthreads_max > nthreads_avail )
-        nthreads = nthreads_avail;
+  if ( 1L * m * n < 2304L * GEMM_MULTITHREAD_THRESHOLD )
+    nthreads = 1;
   else
-        nthreads = nthreads_max;
+    nthreads = num_cpu_avail(2);
 
   if (nthreads == 1) {
 #endif
index 520136b..584080d 100644 (file)
@@ -79,9 +79,6 @@ void NAME(char *TRANS, blasint *M, blasint *N,
   FLOAT *buffer;
 #ifdef SMP
   int nthreads;
-  int nthreads_max;
-  int nthreads_avail;
-  double MNK;
 #endif
 
   int (*gemv[])(BLASLONG, BLASLONG, BLASLONG, FLOAT, FLOAT, FLOAT *, BLASLONG,
@@ -148,9 +145,6 @@ void CNAME(enum CBLAS_ORDER order,
   blasint info, t;
 #ifdef SMP
   int nthreads;
-  int nthreads_max;
-  int nthreads_avail;
-  double MNK;
 #endif
 
   int (*gemv[])(BLASLONG, BLASLONG, BLASLONG, FLOAT, FLOAT, FLOAT *, BLASLONG,
@@ -240,18 +234,10 @@ void CNAME(enum CBLAS_ORDER order,
 
 #ifdef SMP
 
-  nthreads_max = num_cpu_avail(2);
-  nthreads_avail = nthreads_max;
-
-  MNK = (double) m * (double) n;
-  if ( MNK <= ( 256.0  * (double) (GEMM_MULTITHREAD_THRESHOLD * GEMM_MULTITHREAD_THRESHOLD)  ))
-        nthreads_max = 1;
-
-  if ( nthreads_max > nthreads_avail )
-        nthreads = nthreads_avail;
+  if ( 1L * m * n < 1024L * GEMM_MULTITHREAD_THRESHOLD )
+    nthreads = 1;
   else
-        nthreads = nthreads_max;
-
+    nthreads = num_cpu_avail(2);
 
   if (nthreads == 1) {
 #endif