10#ifndef EIGEN_PARALLELIZER_H
11#define EIGEN_PARALLELIZER_H
13#if EIGEN_HAS_CXX11_ATOMIC
22inline void manage_multi_threading(Action action,
int* v)
24 static int m_maxThreads = -1;
25 EIGEN_UNUSED_VARIABLE(m_maxThreads)
29 eigen_internal_assert(v!=0);
32 else if(action==GetAction)
34 eigen_internal_assert(v!=0);
35 #ifdef EIGEN_HAS_OPENMP
39 *v = omp_get_max_threads();
46 eigen_internal_assert(
false);
56 internal::manage_multi_threading(GetAction, &
nbt);
58 internal::manage_caching_sizes(GetAction, &
l1, &
l2, &
l3);
66 internal::manage_multi_threading(GetAction, &ret);
74 internal::manage_multi_threading(SetAction, &v);
87#if EIGEN_HAS_CXX11_ATOMIC
88 std::atomic<Index> sync;
89 std::atomic<int> users;
99template<
bool Condition,
typename Functor,
typename Index>
100void parallelize_gemm(
const Functor& func,
Index rows,
Index cols,
Index depth,
bool transpose)
107#if (! defined(EIGEN_HAS_OPENMP)) || defined(EIGEN_USE_BLAS) || ((!EIGEN_HAS_CXX11_ATOMIC) && !(EIGEN_ARCH_i386_OR_x86_64))
112 EIGEN_UNUSED_VARIABLE(depth);
113 EIGEN_UNUSED_VARIABLE(transpose);
114 func(0,rows, 0,cols);
125 Index size = transpose ? rows : cols;
129 double work =
static_cast<double>(rows) *
static_cast<double>(cols) *
130 static_cast<double>(depth);
140 if((!
Condition) || (threads==1) || (omp_get_num_threads()>1))
141 return func(0,rows, 0,cols);
144 func.initParallelSession(threads);
151 #pragma omp parallel num_threads(threads)
153 Index i = omp_get_thread_num();
159 blockRows = (blockRows/Functor::Traits::mr)*Functor::Traits::mr;
167 info[i].lhs_start =
r0;
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:50
Namespace containing all symbols from the Eigen library.
Definition LDLT.h:16
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:74
void initParallel()
Must be call first when calling Eigen from multiple threads.
Definition Parallelizer.h:53
int nbThreads()
Definition Parallelizer.h:63
void setNbThreads(int v)
Sets the max number of threads reserved for Eigen.
Definition Parallelizer.h:72
NLOHMANN_BASIC_JSON_TPL_DECLARATION void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL &j1, nlohmann::NLOHMANN_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name, cert-dcl58-cpp) is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
Definition json.hpp:24418
Definition Parallelizer.h:80