QMCPACK
PooledMemory< T_scalar, Alloc > Struct Template Reference
+ Inheritance diagram for PooledMemory< T_scalar, Alloc >:
+ Collaboration diagram for PooledMemory< T_scalar, Alloc >:

Public Types

using T = char
 
using value_type = T
 
using size_type = typename Vector< T, Alloc >::size_type
 

Public Member Functions

 PooledMemory ()
 default constructor More...
 
 PooledMemory (const PooledMemory &in)
 copy constructor More...
 
PooledMemoryoperator= (const PooledMemory &in)
 copy assign operator More...
 
size_type byteSize () const
 return the size of the data More...
 
size_type size () const
 return the size of the data More...
 
size_type current () const
 
size_type current_scalar () const
 
void rewind (size_type cur=0, size_type cur_scalar=0)
 set the cursors More...
 
void clear ()
 clear the data and set Current=0 More...
 
void zero ()
 zero the data More...
 
void allocate ()
 allocate the data More...
 
template<typename T1 >
void add (std::complex< T1 > &x)
 
template<typename T1 >
void add (T1 &x)
 
template<typename T1 >
void add (T1 *first, T1 *last)
 
template<typename T1 >
void get (std::complex< T1 > &x)
 
template<typename T1 >
void get (T1 &x)
 
template<typename T1 >
void get (T1 *first, T1 *last)
 
template<typename T1 >
T1 * lendReference (size_type n)
 
void forward (size_type n)
 
template<typename T1 >
void put (std::complex< T1 > &x)
 
template<typename T1 >
void put (T1 &x)
 
template<typename T1 >
void put (T1 *first, T1 *last)
 
Tdata ()
 return the address of the first element More...
 
size_type scalar_offset () const
 return the address offset of the first scalar element More...
 
template<class Msg >
Msg & putMessage (Msg &m)
 
template<class Msg >
Msg & getMessage (Msg &m)
 
template<typename T1 >
PooledMemoryoperator<< (T1 &x)
 
template<typename T1 >
PooledMemoryoperator>> (T1 &x)
 

Public Attributes

const int scalar_multiplier
 
size_type Current
 
size_type Current_scalar
 
T_scalar * Scalar_ptr
 
Vector< T, Alloc > myData
 

Detailed Description

template<typename T_scalar, typename Alloc = aligned_allocator<char, DEFAULT_PAGE_SIZE>>
struct qmcplusplus::PooledMemory< T_scalar, Alloc >

Definition at line 35 of file PooledMemory.h.

Member Typedef Documentation

◆ size_type

using size_type = typename Vector<T, Alloc>::size_type

Definition at line 39 of file PooledMemory.h.

◆ T

using T = char

Definition at line 37 of file PooledMemory.h.

◆ value_type

using value_type = T

Definition at line 38 of file PooledMemory.h.

Constructor & Destructor Documentation

◆ PooledMemory() [1/2]

PooledMemory ( )
inline

default constructor

Definition at line 47 of file PooledMemory.h.

47 : scalar_multiplier(sizeof(T_scalar)), Current(0), Current_scalar(0), Scalar_ptr(nullptr) {}

◆ PooledMemory() [2/2]

PooledMemory ( const PooledMemory< T_scalar, Alloc > &  in)
inline

copy constructor

Definition at line 50 of file PooledMemory.h.

51  : scalar_multiplier(in.scalar_multiplier),
52  Current(in.Current),
53  Current_scalar(in.Current_scalar),
54  myData(in.myData)
55  {
56  Scalar_ptr = reinterpret_cast<T_scalar*>(myData.data() + in.scalar_offset());
57  }
Vector< T, Alloc > myData
Definition: PooledMemory.h:44

Member Function Documentation

◆ add() [1/3]

◆ add() [2/3]

void add ( T1 &  x)
inline

Definition at line 119 of file PooledMemory.h.

120  {
121  Current_scalar++;
122  }

◆ add() [3/3]

void add ( T1 *  first,
T1 *  last 
)
inline

Definition at line 125 of file PooledMemory.h.

126  {
127  constexpr int multiplier = sizeof(T1);
128  Current += getAlignedSize<T>((last - first) * multiplier);
129  }

◆ allocate()

◆ byteSize()

size_type byteSize ( ) const
inline

return the size of the data

Definition at line 70 of file PooledMemory.h.

Referenced by Walker< qmcplusplus::QMCTraits, qmcplusplus::PtclOnLatticeTraits >::byteSize(), and qmcplusplus::TEST_CASE().

70 { return sizeof(T) * myData.size(); }
Vector< T, Alloc > myData
Definition: PooledMemory.h:44

◆ clear()

void clear ( )
inline

clear the data and set Current=0

Definition at line 92 of file PooledMemory.h.

Referenced by CSUpdateBase::initCSWalkersForPbyP(), RMCUpdatePbyPWithDrift::initWalkersForPbyP(), QMCUpdateBase::initWalkersForPbyP(), and WaveFunctionTester::runCloneTest().

93  {
94  myData.clear();
95  Current = 0;
96  Scalar_ptr = nullptr;
97  Current_scalar = 0;
98  }
Vector< T, Alloc > myData
Definition: PooledMemory.h:44

◆ current()

◆ current_scalar()

◆ data()

T* data ( )
inline

◆ forward()

◆ get() [1/3]

◆ get() [2/3]

void get ( T1 &  x)
inline

Definition at line 139 of file PooledMemory.h.

140  {
141  x = static_cast<T1>(Scalar_ptr[Current_scalar++]);
142  }

◆ get() [3/3]

void get ( T1 *  first,
T1 *  last 
)
inline

Definition at line 145 of file PooledMemory.h.

146  {
147  // for backward compatibility
148  const size_t nbytes = (last - first) * sizeof(T1);
149  std::memcpy(first, myData.data() + Current, nbytes);
150  Current += getAlignedSize<T>(nbytes);
151  }
Vector< T, Alloc > myData
Definition: PooledMemory.h:44

◆ getMessage()

Msg& getMessage ( Msg &  m)
inline

Definition at line 200 of file PooledMemory.h.

201  {
202  m.Unpack(myData.data(), myData.size());
203  return m;
204  }
Vector< T, Alloc > myData
Definition: PooledMemory.h:44

◆ lendReference()

T1* lendReference ( size_type  n)
inline

Definition at line 154 of file PooledMemory.h.

Referenced by DiracDeterminant< DU_TYPE >::copyFromBuffer(), TwoBodyJastrow< FT >::copyFromBuffer(), J1OrbitalSoA< FT >::copyFromBuffer(), J1Spin< FT >::copyFromBuffer(), and JeeIOrbitalSoA< FT >::copyFromBuffer().

155  {
156  constexpr int multiplier = sizeof(T1);
157  T1* ptr = reinterpret_cast<T1*>(myData.data() + Current);
158  Current += getAlignedSize<T>(n * multiplier);
159  return ptr;
160  }
Vector< T, Alloc > myData
Definition: PooledMemory.h:44

◆ operator<<()

PooledMemory& operator<< ( T1 &  x)
inline

Definition at line 207 of file PooledMemory.h.

208  {
209  put(x);
210  return *this;
211  }
void put(std::complex< T1 > &x)
Definition: PooledMemory.h:165

◆ operator=()

PooledMemory& operator= ( const PooledMemory< T_scalar, Alloc > &  in)
inline

copy assign operator

Definition at line 60 of file PooledMemory.h.

61  {
62  myData = in.myData;
63  Current = in.Current;
64  Current_scalar = in.Current_scalar;
65  Scalar_ptr = reinterpret_cast<T_scalar*>(myData.data() + in.scalar_offset());
66  return *this;
67  }
Vector< T, Alloc > myData
Definition: PooledMemory.h:44

◆ operator>>()

PooledMemory& operator>> ( T1 &  x)
inline

Definition at line 214 of file PooledMemory.h.

215  {
216  get(x);
217  return *this;
218  }

◆ put() [1/3]

◆ put() [2/3]

void put ( T1 &  x)
inline

Definition at line 172 of file PooledMemory.h.

173  {
174  Scalar_ptr[Current_scalar++] = static_cast<T_scalar>(x);
175  }

◆ put() [3/3]

void put ( T1 *  first,
T1 *  last 
)
inline

Definition at line 178 of file PooledMemory.h.

179  {
180  // for backward compatibility
181  const size_t nbytes = (last - first) * sizeof(T1);
182  std::memcpy(myData.data() + Current, first, nbytes);
183  Current += getAlignedSize<T>(nbytes);
184  }
Vector< T, Alloc > myData
Definition: PooledMemory.h:44

◆ putMessage()

Msg& putMessage ( Msg &  m)
inline

Definition at line 193 of file PooledMemory.h.

194  {
195  m.Pack(myData.data(), myData.size());
196  return m;
197  }
Vector< T, Alloc > myData
Definition: PooledMemory.h:44

◆ rewind()

◆ scalar_offset()

size_type scalar_offset ( ) const
inline

return the address offset of the first scalar element

Definition at line 190 of file PooledMemory.h.

Referenced by PooledMemory< FullPrecRealType >::operator=(), and PooledMemory< FullPrecRealType >::PooledMemory().

190 { return reinterpret_cast<T*>(Scalar_ptr) - myData.data(); }
Vector< T, Alloc > myData
Definition: PooledMemory.h:44

◆ size()

◆ zero()

void zero ( )
inline

zero the data

Definition at line 101 of file PooledMemory.h.

101 { myData.zero(); }
Vector< T, Alloc > myData
Definition: PooledMemory.h:44

Member Data Documentation

◆ Current

◆ Current_scalar

◆ myData

◆ scalar_multiplier

const int scalar_multiplier

Definition at line 41 of file PooledMemory.h.

Referenced by PooledMemory< FullPrecRealType >::allocate().

◆ Scalar_ptr


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