10 #ifndef EIGEN_PARALLELIZER_H 11 #define EIGEN_PARALLELIZER_H 18 inline void manage_multi_threading(Action action,
int* v)
20 static EIGEN_UNUSED
int m_maxThreads = -1;
24 eigen_internal_assert(v!=0);
27 else if(action==GetAction)
29 eigen_internal_assert(v!=0);
30 #ifdef EIGEN_HAS_OPENMP 34 *v = omp_get_max_threads();
41 eigen_internal_assert(
false);
51 internal::manage_multi_threading(GetAction, &nbt);
52 std::ptrdiff_t l1, l2;
53 internal::manage_caching_sizes(GetAction, &l1, &l2);
61 internal::manage_multi_threading(GetAction, &ret);
69 internal::manage_multi_threading(SetAction, &v);
85 template<
bool Condition,
typename Functor,
typename Index>
86 void parallelize_gemm(
const Functor&
func, Index rows, Index cols,
bool transpose)
90 #if !(defined (EIGEN_HAS_OPENMP)) || defined (EIGEN_USE_BLAS) 95 EIGEN_UNUSED_VARIABLE(transpose);
107 if((!Condition) || (omp_get_num_threads()>1))
108 return func(0,rows, 0,cols);
110 Index
size = transpose ? cols : rows;
114 Index max_threads = std::max<Index>(1,size / 32);
117 Index threads = std::min<Index>(
nbThreads(), max_threads);
120 return func(0,rows, 0,cols);
123 func.initParallelSession();
126 std::swap(rows,cols);
130 #pragma omp parallel num_threads(threads) 132 Index i = omp_get_thread_num();
134 Index actual_threads = omp_get_num_threads();
136 Index blockCols = (cols / actual_threads) & ~Index(0x3);
137 Index blockRows = (rows / actual_threads) & ~Index(0x7);
139 Index r0 = i*blockRows;
140 Index actualBlockRows = (i+1==actual_threads) ? rows-r0 : blockRows;
142 Index c0 = i*blockCols;
143 Index actualBlockCols = (i+1==actual_threads) ? cols-c0 : blockCols;
145 info[i].rhs_start = c0;
146 info[i].rhs_length = actualBlockCols;
149 func(0, cols, r0, actualBlockRows, info);
151 func(r0, actualBlockRows, 0,cols, info);
162 #endif // EIGEN_PARALLELIZER_H Definition: NonLinearOptimization.cpp:107
void initParallel()
Must be call first when calling Eigen from multiple threads.
Definition: Parallelizer.h:48
iterative scaling algorithm to equilibrate rows and column norms in matrices
Definition: TestIMU_Common.h:87
int nbThreads()
Definition: Parallelizer.h:58
detail::size< coerce_list< Ts... >> size
Get the size of a list (number of elements.)
Definition: Size.h:56
Definition: benchGeometry.cpp:23
Definition: BandTriangularSolver.h:13
void setNbThreads(int v)
Sets the max number of threads reserved for Eigen.
Definition: Parallelizer.h:67
Definition: Parallelizer.h:74