10#ifndef EIGEN_GENERAL_MATRIX_MATRIX_H
11#define EIGEN_GENERAL_MATRIX_MATRIX_H
17template<
typename _LhsScalar,
typename _RhsScalar>
class level3_blocking;
22 typename LhsScalar,
int LhsStorageOrder,
bool ConjugateLhs,
23 typename RhsScalar,
int RhsStorageOrder,
bool ConjugateRhs,
44 ::run(
cols,
rows,
depth,rhs,
rhsStride,lhs,
lhsStride,
res,
resIncr,
resStride,
alpha,
blocking,
info);
52 typename LhsScalar,
int LhsStorageOrder,
bool ConjugateLhs,
53 typename RhsScalar,
int RhsStorageOrder,
bool ConjugateRhs,
84#ifdef EIGEN_HAS_OPENMP
91 LhsScalar* blockA =
blocking.blockA();
94 std::size_t
sizeB = kc*nc;
121 for(
int shift=0; shift<threads; ++shift)
123 int i = (
tid+shift)%threads;
129 while(
info[
i].sync!=k) {
163 std::size_t
sizeA = kc*mc;
164 std::size_t
sizeB = kc*nc;
212template<
typename Scalar,
typename Index,
typename Gemm,
typename Lhs,
typename Rhs,
typename Dest,
typename BlockingType>
247template<
int StorageOrder,
typename LhsScalar,
typename RhsScalar,
int MaxRows,
int MaxCols,
int MaxDepth,
int KcFactor=1,
250template<
typename _LhsScalar,
typename _RhsScalar>
278template<
int StorageOrder,
typename _LhsScalar,
typename _RhsScalar,
int MaxRows,
int MaxCols,
int MaxDepth,
int KcFactor>
281 typename conditional<StorageOrder==RowMajor,_RhsScalar,_LhsScalar>::type,
282 typename conditional<StorageOrder==RowMajor,_LhsScalar,_RhsScalar>::type>
286 ActualRows =
Transpose ? MaxCols : MaxRows,
287 ActualCols =
Transpose ? MaxRows : MaxCols
293 SizeA = ActualRows * MaxDepth,
294 SizeB = ActualCols * MaxDepth
297#if EIGEN_MAX_STATIC_ALIGN_BYTES >= EIGEN_DEFAULT_ALIGN_BYTES
309 this->m_mc = ActualRows;
310 this->m_nc = ActualCols;
311 this->m_kc = MaxDepth;
312#if EIGEN_MAX_STATIC_ALIGN_BYTES >= EIGEN_DEFAULT_ALIGN_BYTES
313 this->m_blockA = m_staticA;
314 this->m_blockB = m_staticB;
329template<
int StorageOrder,
typename _LhsScalar,
typename _RhsScalar,
int MaxRows,
int MaxCols,
int MaxDepth,
int KcFactor>
332 typename conditional<StorageOrder==RowMajor,_RhsScalar,_LhsScalar>::type,
333 typename conditional<StorageOrder==RowMajor,_LhsScalar,_RhsScalar>::type>
363 m_sizeA = this->m_mc * this->m_kc;
364 m_sizeB = this->m_kc * this->m_nc;
376 m_sizeA = this->m_mc * this->m_kc;
377 m_sizeB = this->m_kc * this->m_nc;
382 if(this->m_blockA==0)
388 if(this->m_blockB==0)
409template<
typename Lhs,
typename Rhs>
411 : generic_product_impl_base<Lhs,Rhs,generic_product_impl<Lhs,Rhs,DenseShape,DenseShape,GemmProduct> >
413 typedef typename Product<Lhs,Rhs>::Scalar
Scalar;
414 typedef typename Lhs::Scalar LhsScalar;
415 typedef typename Rhs::Scalar RhsScalar;
417 typedef internal::blas_traits<Lhs> LhsBlasTraits;
418 typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhsType;
421 typedef internal::blas_traits<Rhs> RhsBlasTraits;
422 typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhsType;
429 typedef generic_product_impl<Lhs,Rhs,DenseShape,DenseShape,CoeffBasedProductMode> lazyproduct;
431 template<
typename Dst>
432 static void evalTo(Dst& dst,
const Lhs& lhs,
const Rhs& rhs)
441 lazyproduct::eval_dynamic(dst, lhs, rhs, internal::assign_op<typename Dst::Scalar,Scalar>());
445 scaleAndAddTo(dst, lhs, rhs,
Scalar(1));
449 template<
typename Dst>
450 static void addTo(Dst& dst,
const Lhs& lhs,
const Rhs& rhs)
453 lazyproduct::eval_dynamic(dst, lhs, rhs, internal::add_assign_op<typename Dst::Scalar,Scalar>());
455 scaleAndAddTo(dst,lhs, rhs,
Scalar(1));
458 template<
typename Dst>
459 static void subTo(Dst& dst,
const Lhs& lhs,
const Rhs& rhs)
462 lazyproduct::eval_dynamic(dst, lhs, rhs, internal::sub_assign_op<typename Dst::Scalar,Scalar>());
464 scaleAndAddTo(dst, lhs, rhs,
Scalar(-1));
467 template<
typename Dest>
468 static void scaleAndAddTo(Dest& dst,
const Lhs& a_lhs,
const Rhs& a_rhs,
const Scalar&
alpha)
470 eigen_assert(dst.rows()==a_lhs.rows() && dst.cols()==a_rhs.cols());
471 if(a_lhs.cols()==0 || a_lhs.rows()==0 || a_rhs.cols()==0)
477 typename Dest::ColXpr dst_vec(dst.col(0));
478 return internal::generic_product_impl<Lhs,typename Rhs::ConstColXpr,DenseShape,DenseShape,GemvProduct>
479 ::scaleAndAddTo(dst_vec, a_lhs, a_rhs.col(0),
alpha);
481 else if (dst.rows() == 1)
484 typename Dest::RowXpr dst_vec(dst.row(0));
485 return internal::generic_product_impl<typename Lhs::ConstRowXpr,Rhs,DenseShape,DenseShape,GemvProduct>
486 ::scaleAndAddTo(dst_vec, a_lhs.row(0), a_rhs,
alpha);
495 Dest::MaxRowsAtCompileTime,Dest::MaxColsAtCompileTime,MaxDepthAtCompileTime> BlockingType;
497 typedef internal::gemm_functor<
499 internal::general_matrix_matrix_product<
504 Dest::InnerStrideAtCompileTime>,
505 ActualLhsTypeCleaned, ActualRhsTypeCleaned, Dest, BlockingType> GemmFunctor;
507 BlockingType blocking(dst.rows(), dst.cols(), lhs.cols(), 1,
true);
509 (GemmFunctor(lhs, rhs, dst, actualAlpha, blocking), a_lhs.rows(), a_rhs.cols(), a_lhs.cols(), Dest::Flags&
RowMajorBit);
Matrix3f m
Definition AngleAxis_mimic_euler.cpp:1
int n
Definition BiCGSTAB_simple.cpp:1
int i
Definition BiCGSTAB_step_by_step.cpp:9
#define EIGEN_GEMM_TO_COEFFBASED_THRESHOLD
Definition GeneralProduct.h:28
#define eigen_internal_assert(x)
Definition Macros.h:1043
#define EIGEN_UNUSED_VARIABLE(var)
Definition Macros.h:1076
#define EIGEN_HAS_CXX11_ATOMIC
Definition Macros.h:831
#define eigen_assert(x)
Definition Macros.h:1037
#define EIGEN_STRONG_INLINE
Definition Macros.h:917
#define EIGEN_SIZE_MIN_PREFER_FIXED(a, b)
Definition Macros.h:1302
#define ei_declare_aligned_stack_constructed_variable(TYPE, NAME, SIZE, BUFFER)
Definition Memory.h:768
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
Definition PartialRedux_count.cpp:3
int rows
Definition Tutorial_commainit_02.cpp:1
int cols
Definition Tutorial_commainit_02.cpp:1
SCALAR Scalar
Definition bench_gemm.cpp:46
Expression of the transpose of a matrix.
Definition Transpose.h:54
Definition TensorRef.h:81
gemm_blocking_space(Index rows, Index cols, Index depth, Index num_threads, bool l3_blocking)
Definition GeneralMatrixMatrix.h:347
void allocateB()
Definition GeneralMatrixMatrix.h:386
void allocateAll()
Definition GeneralMatrixMatrix.h:392
~gemm_blocking_space()
Definition GeneralMatrixMatrix.h:398
void allocateA()
Definition GeneralMatrixMatrix.h:380
void initParallel(Index rows, Index cols, Index depth, Index num_threads)
Definition GeneralMatrixMatrix.h:367
gemm_blocking_space(Index, Index, Index, Index, bool)
Definition GeneralMatrixMatrix.h:307
void allocateA()
Definition GeneralMatrixMatrix.h:324
void allocateAll()
Definition GeneralMatrixMatrix.h:326
void initParallel(Index, Index, Index, Index)
Definition GeneralMatrixMatrix.h:321
void allocateB()
Definition GeneralMatrixMatrix.h:325
Definition GeneralMatrixMatrix.h:248
Definition GeneralMatrixMatrix.h:252
RhsScalar * blockB()
Definition GeneralMatrixMatrix.h:275
Index kc() const
Definition GeneralMatrixMatrix.h:272
Index mc() const
Definition GeneralMatrixMatrix.h:270
Index m_mc
Definition GeneralMatrixMatrix.h:260
level3_blocking()
Definition GeneralMatrixMatrix.h:266
RhsScalar * m_blockB
Definition GeneralMatrixMatrix.h:258
Index nc() const
Definition GeneralMatrixMatrix.h:271
Index m_kc
Definition GeneralMatrixMatrix.h:262
LhsScalar * blockA()
Definition GeneralMatrixMatrix.h:274
Index m_nc
Definition GeneralMatrixMatrix.h:261
LhsScalar * m_blockA
Definition GeneralMatrixMatrix.h:257
@ ColMajor
Definition Constants.h:319
@ RowMajor
Definition Constants.h:321
const unsigned int RowMajorBit
Definition Constants.h:66
else if n * info
Definition cholesky.cpp:18
RealScalar alpha
Definition level1_cplx_impl.h:147
std::size_t UIntPtr
Definition Meta.h:92
EIGEN_DEVICE_FUNC void aligned_delete(T *ptr, std::size_t size)
Definition Memory.h:361
void parallelize_gemm(const Functor &func, Index rows, Index cols, Index depth, bool transpose)
Definition Parallelizer.h:100
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE ResScalar combine_scalar_factors(const ResScalar &alpha, const Lhs &lhs, const Rhs &rhs)
Definition BlasUtil.h:568
@ Lhs
Definition TensorContractionMapper.h:19
@ Rhs
Definition TensorContractionMapper.h:18
Namespace containing all symbols from the Eigen library.
Definition bench_norm.cpp:85
@ GemmProduct
Definition Constants.h:500
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:74
const int Dynamic
Definition Constants.h:22
Definition BandTriangularSolver.h:13
Determines whether the given binary operation of two numeric types is allowed and what the scalar ret...
Definition XprHelper.h:806
const T type
Definition Meta.h:214
Definition GeneralMatrixMatrix.h:214
Dest & m_dest
Definition GeneralMatrixMatrix.h:242
void initParallelSession(Index num_threads) const
Definition GeneralMatrixMatrix.h:219
const Rhs & m_rhs
Definition GeneralMatrixMatrix.h:241
Gemm::Traits Traits
Definition GeneralMatrixMatrix.h:237
Scalar m_actualAlpha
Definition GeneralMatrixMatrix.h:243
BlockingType & m_blocking
Definition GeneralMatrixMatrix.h:244
gemm_functor(const Lhs &lhs, const Rhs &rhs, Dest &dest, const Scalar &actualAlpha, BlockingType &blocking)
Definition GeneralMatrixMatrix.h:215
const Lhs & m_lhs
Definition GeneralMatrixMatrix.h:240
void operator()(Index row, Index rows, Index col=0, Index cols=-1, GemmParallelInfo< Index > *info=0) const
Definition GeneralMatrixMatrix.h:225
gebp_traits< LhsScalar, RhsScalar > Traits
Definition GeneralMatrixMatrix.h:58
static void run(Index rows, Index cols, Index depth, const LhsScalar *_lhs, Index lhsStride, const RhsScalar *_rhs, Index rhsStride, ResScalar *_res, Index resIncr, Index resStride, ResScalar alpha, level3_blocking< LhsScalar, RhsScalar > &blocking, GemmParallelInfo< Index > *info=0)
Definition GeneralMatrixMatrix.h:61
ScalarBinaryOpTraits< LhsScalar, RhsScalar >::ReturnType ResScalar
Definition GeneralMatrixMatrix.h:60
static EIGEN_STRONG_INLINE void run(Index rows, Index cols, Index depth, const LhsScalar *lhs, Index lhsStride, const RhsScalar *rhs, Index rhsStride, ResScalar *res, Index resIncr, Index resStride, ResScalar alpha, level3_blocking< RhsScalar, LhsScalar > &blocking, GemmParallelInfo< Index > *info=0)
Definition GeneralMatrixMatrix.h:30
ScalarBinaryOpTraits< LhsScalar, RhsScalar >::ReturnType ResScalar
Definition GeneralMatrixMatrix.h:29
gebp_traits< RhsScalar, LhsScalar > Traits
Definition GeneralMatrixMatrix.h:27
T type
Definition Meta.h:126
Definition ForwardDeclarations.h:17
std::ptrdiff_t j
Definition tut_arithmetic_redux_minmax.cpp:2