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;
99template<
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);
#define eigen_internal_assert(x)
Definition: Macros.h:1053
#define EIGEN_UNUSED_VARIABLE(var)
Definition: Macros.h:1086
#define ei_declare_aligned_stack_constructed_variable(TYPE, NAME, SIZE, BUFFER)
Definition: Memory.h:768
and restrictions which apply to each piece of software is included later in this file and or inside of the individual applicable source files The disclaimer of warranty in the WPILib license above applies to all code in and nothing in any of the other licenses gives permission to use the names of FIRST nor the names of the WPILib contributors to endorse or promote products derived from this software The following pieces of software have additional or alternate and or Google Inc All rights reserved Redistribution and use in source and binary with or without are permitted provided that the following conditions are this list of conditions and the following disclaimer *Redistributions in binary form must reproduce the above copyright this list of conditions and the following disclaimer in the documentation and or other materials provided with the distribution *Neither the name of Google Inc nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS OR IMPLIED BUT NOT LIMITED THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY OR CONSEQUENTIAL WHETHER IN STRICT OR EVEN IF ADVISED OF THE POSSIBILITY OF SUCH January AND DISTRIBUTION Definitions License shall mean the terms and conditions for and distribution as defined by Sections through of this document Licensor shall mean the copyright owner or entity authorized by the copyright owner that is granting the License Legal Entity shall mean the union of the acting entity and all other entities that control are controlled by or are under common control with that entity For the purposes of this definition control direct or to cause the direction or management of such whether by contract or including but not limited to software source documentation and configuration files Object form shall mean any form resulting from mechanical transformation or translation of a Source including but not limited to compiled object generated and conversions to other media types Work shall mean the work of whether in Source or Object made available under the as indicated by a copyright notice that is included in or attached to the work(an example is provided in the Appendix below). "Derivative Works" shall mean any work
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: Core:141
Action
Definition: Constants.h:504
@ 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()
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
Definition: Eigen_Colamd.h:50
void swap(wpi::SmallPtrSet< T, N > &LHS, wpi::SmallPtrSet< T, N > &RHS)
Implement std::swap in terms of SmallPtrSet swap.
Definition: SmallPtrSet.h:512
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