diff options
author | Gael Guennebaud <g.gael@free.fr> | 2015-10-22 16:30:28 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2015-10-22 16:30:28 +0200 |
commit | 0eb46508e2e653218557e0ba9858926be9da04e9 (patch) | |
tree | 32e6ba339dac5ef4d71a51434f8894a1f6c32d27 /Eigen | |
parent | 6df8e99470d1ecdd89f451c1bd366672d5a27b6b (diff) |
Avoid any openmp calls if multi-threading is explicitely disabled at runtime.
Diffstat (limited to 'Eigen')
-rw-r--r-- | Eigen/src/Core/products/Parallelizer.h | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/Eigen/src/Core/products/Parallelizer.h b/Eigen/src/Core/products/Parallelizer.h index 91d37a123..e0bfcc356 100644 --- a/Eigen/src/Core/products/Parallelizer.h +++ b/Eigen/src/Core/products/Parallelizer.h @@ -102,21 +102,17 @@ void parallelize_gemm(const Functor& func, Index rows, Index cols, bool transpos // - we are not already in a parallel code // - the sizes are large enough - // 1- are we already in a parallel session? - // FIXME omp_get_num_threads()>1 only works for openmp, what if the user does not use openmp? - if((!Condition) || (omp_get_num_threads()>1)) - return func(0,rows, 0,cols); - - Index size = transpose ? rows : cols; - - // 2- compute the maximal number of threads from the size of the product: + // compute the maximal number of threads from the size of the product: // FIXME this has to be fine tuned - Index max_threads = std::max<Index>(1,size / 32); - - // 3 - compute the number of threads we are going to use - Index threads = std::min<Index>(nbThreads(), max_threads); + Index size = transpose ? rows : cols; + Index pb_max_threads = std::max<Index>(1,size / 32); + // compute the number of threads we are going to use + Index threads = std::min<Index>(nbThreads(), pb_max_threads); - if(threads==1) + // if multi-threading is explicitely disabled, not useful, or if we already are in a parallel session, + // then abort multi-threading + // FIXME omp_get_num_threads()>1 only works for openmp, what if the user does not use openmp? + if((!Condition) || (threads==1) || (omp_get_num_threads()>1)) return func(0,rows, 0,cols); Eigen::initParallel(); |