10 #ifndef EIGEN_PARALLELIZER_H 11 #define EIGEN_PARALLELIZER_H 30 #ifdef EIGEN_HAS_OPENMP 34 *v = omp_get_max_threads();
52 std::ptrdiff_t l1, l2, l3;
85 template<
bool Condition,
typename Functor,
typename Index>
90 #if !(defined (EIGEN_HAS_OPENMP)) || defined (EIGEN_USE_BLAS) 109 Index pb_max_threads = std::max<Index>(1,size / Functor::Traits::nr);
112 double work =
static_cast<double>(rows) * static_cast<double>(cols) *
113 static_cast<double>(depth);
114 double kMinTaskSize = 50000;
115 pb_max_threads = std::max<Index>(1, std::min<Index>(pb_max_threads, work / kMinTaskSize));
123 if((!Condition) || (threads==1) || (omp_get_num_threads()>1))
124 return func(0,rows, 0,cols);
127 func.initParallelSession(threads);
134 #pragma omp parallel num_threads(threads) 136 Index i = omp_get_thread_num();
138 Index actual_threads = omp_get_num_threads();
140 Index blockCols = (cols / actual_threads) & ~
Index(0x3);
141 Index blockRows = (rows / actual_threads);
142 blockRows = (blockRows/Functor::Traits::mr)*Functor::Traits::mr;
144 Index r0 = i*blockRows;
145 Index actualBlockRows = (i+1==actual_threads) ? rows-r0 : blockRows;
147 Index c0 = i*blockCols;
148 Index actualBlockCols = (i+1==actual_threads) ? cols-c0 : blockCols;
150 info[i].lhs_start = r0;
151 info[i].lhs_length = actualBlockRows;
153 if(transpose) func(c0, actualBlockCols, 0, rows, info);
154 else func(0, rows, c0, actualBlockCols, info);
163 #endif // EIGEN_PARALLELIZER_H
static constexpr size_t size(Tuple< Args... > &)
Provides access to the number of elements in a tuple as a compile-time constant expression.
void manage_caching_sizes(Action action, std::ptrdiff_t *l1, std::ptrdiff_t *l2, std::ptrdiff_t *l3)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
#define ei_declare_aligned_stack_constructed_variable(TYPE, NAME, SIZE, BUFFER)
#define eigen_internal_assert(x)
void parallelize_gemm(const Functor &func, Index rows, Index cols, Index depth, bool transpose)
void manage_multi_threading(Action action, int *v)
void swap(mpfr::mpreal &x, mpfr::mpreal &y)
#define EIGEN_UNUSED_VARIABLE(var)