10 #ifndef EIGEN_PARALLELIZER_H
11 #define EIGEN_PARALLELIZER_H
13 #include "../InternalHeaderCheck.h"
22 static int m_maxThreads = -1;
33 #ifdef EIGEN_HAS_OPENMP
37 *
v = omp_get_max_threads();
55 std::ptrdiff_t l1, l2, l3;
77 template<
typename Index>
struct GemmParallelInfo
80 #ifdef EIGEN_HAS_OPENMP
81 GemmParallelInfo() : sync(-1), users(0), lhs_start(0), lhs_length(0) {}
82 std::atomic<Index> sync;
83 std::atomic<int> users;
85 GemmParallelInfo() : lhs_start(0), lhs_length(0) {}
92 template<
bool Condition,
typename Functor,
typename Index>
100 #if (! defined(EIGEN_HAS_OPENMP)) || defined(EIGEN_USE_BLAS)
119 Index pb_max_threads = std::max<Index>(1,
size / Functor::Traits::nr);
122 double work =
static_cast<double>(
rows) *
static_cast<double>(
cols) *
123 static_cast<double>(depth);
124 double kMinTaskSize = 50000;
125 pb_max_threads = std::max<Index>(1, std::min<Index>(pb_max_threads,
static_cast<Index>( work / kMinTaskSize ) ));
133 if((!Condition) || (threads==1) || (omp_get_num_threads()>1))
137 func.initParallelSession(threads);
144 #pragma omp parallel num_threads(threads)
146 Index i = omp_get_thread_num();
148 Index actual_threads = omp_get_num_threads();
151 Index blockRows = (
rows / actual_threads);
152 blockRows = (blockRows/Functor::Traits::mr)*Functor::Traits::mr;
155 Index actualBlockRows = (
i+1==actual_threads) ?
rows-r0 : blockRows;
158 Index actualBlockCols = (
i+1==actual_threads) ?
cols-c0 : blockCols;
160 info[
i].lhs_start = r0;
161 info[
i].lhs_length = actualBlockRows;
163 if(transpose) func(c0, actualBlockCols, 0,
rows, info);
164 else func(0,
rows, c0, actualBlockCols, info);
Array< int, Dynamic, 1 > v
#define eigen_internal_assert(x)
#define EIGEN_UNUSED_VARIABLE(var)
#define ei_declare_aligned_stack_constructed_variable(TYPE, NAME, SIZE, BUFFER)
void parallelize_gemm(const Functor &func, Index rows, Index cols, Index depth, bool transpose)
void manage_multi_threading(Action action, int *v)
void manage_caching_sizes(Action action, std::ptrdiff_t *l1, std::ptrdiff_t *l2, std::ptrdiff_t *l3)
void swap(scoped_array< T > &a, scoped_array< T > &b)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.