Eigen::internal::TensorContractionBlockMemAllocator< LhsScalar, RhsScalar > Struct Template Reference

#include <TensorContraction.h>

Classes

struct  BlockSizes
 

Public Types

typedef void * BlockMemHandle
 

Static Public Member Functions

template<typename Device >
static EIGEN_DEVICE_FUNC BlockMemHandle allocate (Device &d, const Index bm, const Index bk, const Index bn, LhsScalar **lhs_block, RhsScalar **rhs_block)
 
template<typename Device >
static EIGEN_DEVICE_FUNC BlockMemHandle allocateSlices (Device &d, const Index bm, const Index bk, const Index bn, const Index num_lhs, const Index num_rhs, const Index num_slices, std::vector< LhsScalar * > *lhs_blocks, std::vector< RhsScalar * > *rhs_blocks)
 
template<typename Device >
static EIGEN_DEVICE_FUNC void deallocate (Device &d, BlockMemHandle handle)
 

Static Private Member Functions

static EIGEN_DEVICE_FUNC BlockSizes ComputeLhsRhsBlockSizes (const Index bm, const Index bk, const Index bn)
 

Member Typedef Documentation

◆ BlockMemHandle

template<typename LhsScalar , typename RhsScalar >
typedef void* Eigen::internal::TensorContractionBlockMemAllocator< LhsScalar, RhsScalar >::BlockMemHandle

Member Function Documentation

◆ allocate()

template<typename LhsScalar , typename RhsScalar >
template<typename Device >
static EIGEN_DEVICE_FUNC BlockMemHandle Eigen::internal::TensorContractionBlockMemAllocator< LhsScalar, RhsScalar >::allocate ( Device &  d,
const Index  bm,
const Index  bk,
const Index  bn,
LhsScalar **  lhs_block,
RhsScalar **  rhs_block 
)
inlinestatic
86  {
87  eigen_assert(lhs_block);
88  eigen_assert(rhs_block);
89  BlockSizes sz = ComputeLhsRhsBlockSizes(bm, bk, bn);
90  char* block_mem = static_cast<char*>(d.allocate(sz.lhs_size + sz.rhs_size));
91  *lhs_block = static_cast<LhsScalar*>(static_cast<void*>(block_mem));
92  *rhs_block = static_cast<RhsScalar*>(static_cast<void*>(block_mem + sz.lhs_size));
93  return block_mem;
94  }
#define eigen_assert(x)
Definition: Macros.h:910
static EIGEN_DEVICE_FUNC BlockSizes ComputeLhsRhsBlockSizes(const Index bm, const Index bk, const Index bn)
Definition: TensorContraction.h:136

References Eigen::internal::TensorContractionBlockMemAllocator< LhsScalar, RhsScalar >::ComputeLhsRhsBlockSizes(), eigen_assert, Eigen::internal::TensorContractionBlockMemAllocator< LhsScalar, RhsScalar >::BlockSizes::lhs_size, and Eigen::internal::TensorContractionBlockMemAllocator< LhsScalar, RhsScalar >::BlockSizes::rhs_size.

Referenced by Eigen::internal::TensorContractionKernel< ResScalar, LhsScalar, RhsScalar, StorageIndex, OutputMapper, LhsMapper, RhsMapper >::allocate().

◆ allocateSlices()

template<typename LhsScalar , typename RhsScalar >
template<typename Device >
static EIGEN_DEVICE_FUNC BlockMemHandle Eigen::internal::TensorContractionBlockMemAllocator< LhsScalar, RhsScalar >::allocateSlices ( Device &  d,
const Index  bm,
const Index  bk,
const Index  bn,
const Index  num_lhs,
const Index  num_rhs,
const Index  num_slices,
std::vector< LhsScalar * > *  lhs_blocks,
std::vector< RhsScalar * > *  rhs_blocks 
)
inlinestatic
100  {
101  eigen_assert(num_slices > 0);
102  eigen_assert(num_lhs >= 0 && num_rhs >= 0);
103  eigen_assert(num_lhs == 0 || lhs_blocks);
104  eigen_assert(num_rhs == 0 || rhs_blocks);
105  BlockSizes sz = ComputeLhsRhsBlockSizes(bm, bk, bn);
106  void* block_mem = d.allocate((num_lhs * sz.lhs_size + num_rhs * sz.rhs_size) * num_slices);
107  eigen_assert(block_mem);
108  char* mem = static_cast<char*>(block_mem);
109 
110  for (Index x = 0; x < num_slices; x++) {
111  if (num_lhs > 0) lhs_blocks[x].resize(num_lhs);
112  for (Index m = 0; m < num_lhs; m++) {
113  lhs_blocks[x][m] = static_cast<LhsScalar*>(static_cast<void*>(mem));
114  mem += sz.lhs_size;
115  }
116  if (num_rhs > 0) rhs_blocks[x].resize(num_rhs);
117  for (Index n = 0; n < num_rhs; n++) {
118  rhs_blocks[x][n] = static_cast<RhsScalar*>(static_cast<void*>(mem));
119  mem += sz.rhs_size;
120  }
121  }
122 
123  return block_mem;
124  }
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
int * m
Definition: level2_cplx_impl.h:294
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
list x
Definition: plotDoE.py:28

References Eigen::internal::TensorContractionBlockMemAllocator< LhsScalar, RhsScalar >::ComputeLhsRhsBlockSizes(), eigen_assert, Eigen::internal::TensorContractionBlockMemAllocator< LhsScalar, RhsScalar >::BlockSizes::lhs_size, m, n, Eigen::internal::TensorContractionBlockMemAllocator< LhsScalar, RhsScalar >::BlockSizes::rhs_size, and plotDoE::x.

Referenced by Eigen::internal::TensorContractionKernel< ResScalar, LhsScalar, RhsScalar, StorageIndex, OutputMapper, LhsMapper, RhsMapper >::allocateSlices().

◆ ComputeLhsRhsBlockSizes()

template<typename LhsScalar , typename RhsScalar >
static EIGEN_DEVICE_FUNC BlockSizes Eigen::internal::TensorContractionBlockMemAllocator< LhsScalar, RhsScalar >::ComputeLhsRhsBlockSizes ( const Index  bm,
const Index  bk,
const Index  bn 
)
inlinestaticprivate
136  {
138  BlockSizes sz;
139  sz.lhs_size = numext::div_ceil<Index>(bm * bk * sizeof(LhsScalar), align) * align;
140  sz.rhs_size = numext::div_ceil<Index>(bn * bk * sizeof(RhsScalar), align) * align;
141  return sz;
142  }
#define EIGEN_MAX_ALIGN_BYTES
Definition: ConfigureVectorization.h:163
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T maxi(const T &x, const T &y)
Definition: MathFunctions.h:926

References EIGEN_MAX_ALIGN_BYTES, Eigen::internal::TensorContractionBlockMemAllocator< LhsScalar, RhsScalar >::BlockSizes::lhs_size, Eigen::numext::maxi(), and Eigen::internal::TensorContractionBlockMemAllocator< LhsScalar, RhsScalar >::BlockSizes::rhs_size.

Referenced by Eigen::internal::TensorContractionBlockMemAllocator< LhsScalar, RhsScalar >::allocate(), and Eigen::internal::TensorContractionBlockMemAllocator< LhsScalar, RhsScalar >::allocateSlices().

◆ deallocate()

template<typename LhsScalar , typename RhsScalar >
template<typename Device >
static EIGEN_DEVICE_FUNC void Eigen::internal::TensorContractionBlockMemAllocator< LhsScalar, RhsScalar >::deallocate ( Device &  d,
BlockMemHandle  handle 
)
inlinestatic

The documentation for this struct was generated from the following file: