10 #ifndef EIGEN_PARALLELIZER_H
11 #define EIGEN_PARALLELIZER_H
13 #if EIGEN_HAS_CXX11_ATOMIC
24 static int m_maxThreads = -1;
35 #ifdef EIGEN_HAS_OPENMP
39 *v = omp_get_max_threads();
57 std::ptrdiff_t l1, l2, l3;
87 #if EIGEN_HAS_CXX11_ATOMIC
88 std::atomic<Index>
sync;
89 std::atomic<int>
users;
99 template<
bool Condition,
typename Functor,
typename Index>
107 #if (! defined(EIGEN_HAS_OPENMP)) || defined(EIGEN_USE_BLAS) || ((!EIGEN_HAS_CXX11_ATOMIC) && !(EIGEN_ARCH_i386_OR_x86_64))
114 func(0,rows, 0,cols);
126 Index pb_max_threads = std::max<Index>(1,
size / Functor::Traits::nr);
129 double work =
static_cast<double>(rows) *
static_cast<double>(cols) *
130 static_cast<double>(depth);
131 double kMinTaskSize = 50000;
132 pb_max_threads = std::max<Index>(1, std::min<Index>(pb_max_threads,
static_cast<Index>( work / kMinTaskSize ) ));
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();
155 Index actual_threads = omp_get_num_threads();
157 Index blockCols = (cols / actual_threads) & ~
Index(0x3);
158 Index blockRows = (rows / actual_threads);
159 blockRows = (blockRows/Functor::Traits::mr)*Functor::Traits::mr;
161 Index r0 = i*blockRows;
162 Index actualBlockRows = (i+1==actual_threads) ? rows-r0 : blockRows;
164 Index c0 = i*blockCols;
165 Index actualBlockCols = (i+1==actual_threads) ? cols-c0 : blockCols;
167 info[i].lhs_start = r0;
168 info[i].lhs_length = actualBlockRows;
170 if(transpose) func(c0, actualBlockCols, 0, rows, info);
171 else func(0, rows, c0, actualBlockCols, info);
boost::random::uniform_int_distribution action(0, 100)
#define eigen_internal_assert(x)
Definition: Macros.h:1043
#define EIGEN_UNUSED_VARIABLE(var)
Definition: Macros.h:1076
#define ei_declare_aligned_stack_constructed_variable(TYPE, NAME, SIZE, BUFFER)
Definition: Memory.h:768
Handle force and torque contact information.
Definition: ContactList.h:19
void parallelize_gemm(const Functor &func, Index rows, Index cols, Index depth, bool transpose)
Definition: Parallelizer.h:100
void manage_multi_threading(Action action, int *v)
Definition: Parallelizer.h:22
void manage_caching_sizes(Action action, std::ptrdiff_t *l1, std::ptrdiff_t *l2, std::ptrdiff_t *l3)
Definition: GeneralBlockPanelKernel.h:86
EIGEN_CONSTEXPR Index size(const T &x)
Definition: Meta.h:479
Namespace containing all symbols from the Eigen library.
Definition: LDLT.h:16
@ GetAction
Definition: Constants.h:504
@ SetAction
Definition: Constants.h:504
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74
void initParallel()
Definition: Parallelizer.h:53
int nbThreads()
Definition: Parallelizer.h:63
void setNbThreads(int v)
Definition: Parallelizer.h:72
Definition: document.h:416
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, cppcoreguidelines-noexcept-swap, performance-noexcept-swap) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
Definition: json.hpp:25399
Definition: Parallelizer.h:80
GemmParallelInfo()
Definition: Parallelizer.h:81
Index lhs_length
Definition: Parallelizer.h:96
Index lhs_start
Definition: Parallelizer.h:95
Index volatile sync
Definition: Parallelizer.h:91
int volatile users
Definition: Parallelizer.h:92