QMCPACK
SoaDistanceTableAB< T, D, SC > Struct Template Reference

A derived classe from DistacneTableData, specialized for AB using a transposed form. More...

+ Inheritance diagram for SoaDistanceTableAB< T, D, SC >:
+ Collaboration diagram for SoaDistanceTableAB< T, D, SC >:

Public Member Functions

 SoaDistanceTableAB (const ParticleSet &source, ParticleSet &target)
 
void resize ()
 
 SoaDistanceTableAB ()=delete
 
 SoaDistanceTableAB (const SoaDistanceTableAB &)=delete
 
void evaluate (ParticleSet &P) override
 evaluate the full table More...
 
void move (const ParticleSet &P, const PosType &rnew, const IndexType iat, bool prepare_old) override
 evaluate the temporary pair relations More...
 
void update (IndexType iat) override
 update the stripe for jat-th particle More...
 
int get_first_neighbor (IndexType iat, RealType &r, PosType &dr, bool newpos) const override
 find the first nearest neighbor More...
 
- Public Member Functions inherited from DTD_BConds< T, D, SC >
 DTD_BConds (const CrystalLattice< T, D > &lat)
 constructor: doing nothing More...
 
apply_bc (TinyVector< T, D > &displ) const
 apply BC on displ and return |displ|^2 More...
 
void apply_bc (std::vector< TinyVector< T, D >> &dr, std::vector< T > &r, std::vector< T > &rinv) const
 apply BC on dr and evaluate r and rinv More...
 
void apply_bc (std::vector< TinyVector< T, D >> &dr, std::vector< T > &r) const
 
void evaluate_rsquared (TinyVector< T, D > *restrict dr, T *restrict rr, int n)
 
- Public Member Functions inherited from DistanceTableAB
 DistanceTableAB (const ParticleSet &source, const ParticleSet &target, DTModes modes)
 constructor using source and target ParticleSet More...
 
const std::vector< DistRow > & getDistances () const
 return full table distances More...
 
const std::vector< DisplRow > & getDisplacements () const
 return full table displacements More...
 
const DistRowgetDistRow (int iel) const
 return a row of distances for a given target particle More...
 
const DisplRowgetDisplRow (int iel) const
 return a row of displacements for a given target particle More...
 
const DistRowgetTempDists () const
 return the temporary distances when a move is proposed More...
 
const DisplRowgetTempDispls () const
 return the temporary displacements when a move is proposed More...
 
virtual const RealTypegetMultiWalkerDataPtr () const
 return multi-walker full (all pairs) distance table data pointer More...
 
virtual size_t getPerTargetPctlStrideSize () const
 return stride of per target pctl data. full table data = stride * num of target particles More...
 
- Public Member Functions inherited from DistanceTable
 DistanceTable (const ParticleSet &source, const ParticleSet &target, DTModes modes)
 constructor using source and target ParticleSet More...
 
 DistanceTable (const DistanceTable &)=delete
 copy constructor. deleted More...
 
virtual ~DistanceTable ()=default
 virutal destructor More...
 
DTModes getModes () const
 get modes More...
 
void setModes (DTModes modes)
 set modes More...
 
const std::string & getName () const
 return the name of table More...
 
const ParticleSetget_origin () const
 returns the reference the origin particleset More...
 
size_t centers () const
 returns the number of centers More...
 
size_t targets () const
 returns the number of centers More...
 
size_t sources () const
 returns the number of source particles More...
 
virtual void mw_evaluate (const RefVectorWithLeader< DistanceTable > &dt_list, const RefVectorWithLeader< ParticleSet > &p_list) const
 
virtual void mw_recompute (const RefVectorWithLeader< DistanceTable > &dt_list, const RefVectorWithLeader< ParticleSet > &p_list, const std::vector< bool > &recompute) const
 recompute multi walker internal data, recompute More...
 
virtual void mw_move (const RefVectorWithLeader< DistanceTable > &dt_list, const RefVectorWithLeader< ParticleSet > &p_list, const std::vector< PosType > &rnew_list, const IndexType iat, bool prepare_old=true) const
 walker batched version of move. More...
 
virtual void updatePartial (IndexType jat, bool from_temp)
 fill partially the distance table by the pair relations from the temporary or old particle position. More...
 
virtual void mw_updatePartial (const RefVectorWithLeader< DistanceTable > &dt_list, IndexType jat, const std::vector< bool > &from_temp)
 walker batched version of updatePartial. More...
 
virtual void finalizePbyP (const ParticleSet &P)
 finalize distance table calculation after particle-by-particle moves if update() doesn't make the table up-to-date during p-by-p moves finalizePbyP takes action to bring the table up-to-date More...
 
virtual void mw_finalizePbyP (const RefVectorWithLeader< DistanceTable > &dt_list, const RefVectorWithLeader< ParticleSet > &p_list) const
 walker batched version of finalizePbyP If not DTModes::NEED_TEMP_DATA_ON_HOST, host distance table data is not updated at all during p-by-p Thus, a recompute is necessary to update the whole host distance table for consumers like the Coulomb potential. More...
 
void print (std::ostream &os)
 
virtual void createResource (ResourceCollection &collection) const
 initialize a shared resource and hand it to a collection More...
 
virtual void acquireResource (ResourceCollection &collection, const RefVectorWithLeader< DistanceTable > &dt_list) const
 acquire a shared resource from a collection More...
 
virtual void releaseResource (ResourceCollection &collection, const RefVectorWithLeader< DistanceTable > &dt_list) const
 return a shared resource to a collection More...
 

Private Attributes

NewTimerevaluate_timer_
 timer for evaluate() More...
 
NewTimermove_timer_
 timer for move() More...
 
NewTimerupdate_timer_
 timer for update() More...
 

Additional Inherited Members

- Public Types inherited from DistanceTable
using IndexType = QMCTraits::IndexType
 
using RealType = QMCTraits::RealType
 
using PosType = QMCTraits::PosType
 
using DistRow = Vector< RealType, aligned_allocator< RealType > >
 
using DisplRow = VectorSoaContainer< RealType, DIM >
 
- Static Public Attributes inherited from DistanceTable
static constexpr unsigned DIM = OHMMS_DIM
 
- Protected Attributes inherited from DistanceTableAB
std::vector< DistRowdistances_
 distances_[num_targets_][num_sources_], [i][3][j] = |r_A2[j] - r_A1[i]| Note: Derived classes decide if it is a memory view or the actual storage More...
 
std::vector< DisplRowdisplacements_
 displacements_[num_targets_][3][num_sources_], [i][3][j] = r_A2[j] - r_A1[i] Note: Derived classes decide if it is a memory view or the actual storage More...
 
DistRow temp_r_
 temp_r More...
 
DisplRow temp_dr_
 temp_dr More...
 
- Protected Attributes inherited from DistanceTable
const ParticleSetorigin_
 
const size_t num_sources_
 
const size_t num_targets_
 
const std::string name_
 name of the table More...
 
DTModes modes_
 operation modes defined by DTModes More...
 

Detailed Description

template<typename T, unsigned D, int SC>
struct qmcplusplus::SoaDistanceTableAB< T, D, SC >

A derived classe from DistacneTableData, specialized for AB using a transposed form.

Definition at line 26 of file SoaDistanceTableAB.h.

Constructor & Destructor Documentation

◆ SoaDistanceTableAB() [1/3]

SoaDistanceTableAB ( const ParticleSet source,
ParticleSet target 
)
inline

Definition at line 28 of file SoaDistanceTableAB.h.

References SoaDistanceTableAB< T, D, SC >::resize().

29  : DTD_BConds<T, D, SC>(source.getLattice()),
30  DistanceTableAB(source, target, DTModes::ALL_OFF),
31  evaluate_timer_(createGlobalTimer(std::string("DTAB::evaluate_") + target.getName() + "_" + source.getName(),
33  move_timer_(createGlobalTimer(std::string("DTAB::move_") + target.getName() + "_" + source.getName(),
35  update_timer_(createGlobalTimer(std::string("DTAB::update_") + target.getName() + "_" + source.getName(),
37  {
38  resize();
39  }
NewTimer & move_timer_
timer for move()
NewTimer & update_timer_
timer for update()
NewTimer & createGlobalTimer(const std::string &myname, timer_levels mylevel)
DistanceTableAB(const ParticleSet &source, const ParticleSet &target, DTModes modes)
constructor using source and target ParticleSet
NewTimer & evaluate_timer_
timer for evaluate()

◆ SoaDistanceTableAB() [2/3]

SoaDistanceTableAB ( )
delete

◆ SoaDistanceTableAB() [3/3]

SoaDistanceTableAB ( const SoaDistanceTableAB< T, D, SC > &  )
delete

Member Function Documentation

◆ evaluate()

void evaluate ( ParticleSet P)
inlineoverridevirtual

evaluate the full table

Implements DistanceTable.

Definition at line 66 of file SoaDistanceTableAB.h.

References DistanceTableAB::displacements_, DistanceTableAB::distances_, SoaDistanceTableAB< T, D, SC >::evaluate_timer_, FairDivideAligned(), DynamicCoordinates::getAllParticlePos(), ParticleSet::getCoordinates(), DistanceTable::num_sources_, DistanceTable::num_targets_, omp_get_num_threads(), omp_get_thread_num(), DistanceTable::origin_, and ParticleSet::R.

67  {
68  ScopedTimer local_timer(evaluate_timer_);
69 #pragma omp parallel
70  {
71  int first, last;
72  FairDivideAligned(num_sources_, getAlignment<T>(), omp_get_num_threads(), omp_get_thread_num(), first, last);
73 
74  //be aware of the sign of Displacement
75  for (int iat = 0; iat < num_targets_; ++iat)
76  DTD_BConds<T, D, SC>::computeDistances(P.R[iat], origin_.getCoordinates().getAllParticlePos(),
77  distances_[iat].data(), displacements_[iat], first, last);
78  }
79  }
virtual const PosVectorSoa & getAllParticlePos() const =0
all particle position accessor
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
omp_int_t omp_get_thread_num()
Definition: OpenMP.h:25
void FairDivideAligned(const int ntot, const int base, const int npart, const int me, int &first, int &last)
Partition ntot over npart and the size of each partition is a multiple of base size.
Definition: FairDivide.h:96
omp_int_t omp_get_num_threads()
Definition: OpenMP.h:27
const DynamicCoordinates & getCoordinates() const
Definition: ParticleSet.h:246
std::vector< DisplRow > displacements_
displacements_[num_targets_][3][num_sources_], [i][3][j] = r_A2[j] - r_A1[i] Note: Derived classes de...
const ParticleSet & origin_
Definition: DistanceTable.h:51
NewTimer & evaluate_timer_
timer for evaluate()
std::vector< DistRow > distances_
distances_[num_targets_][num_sources_], [i][3][j] = |r_A2[j] - r_A1[i]| Note: Derived classes decide ...

◆ get_first_neighbor()

int get_first_neighbor ( IndexType  iat,
RealType r,
PosType dr,
bool  newpos 
) const
inlineoverridevirtual

find the first nearest neighbor

Parameters
iatsource particle id
rdistance
drdisplacement
newposif true, use the data in temp_r_ and temp_dr_ for the proposed move. if false, use the data in distance_[iat] and displacements_[iat]
Returns
the id of the nearest particle, -1 not found

Implements DistanceTable.

Definition at line 103 of file SoaDistanceTableAB.h.

References DistanceTableAB::displacements_, DistanceTableAB::distances_, DistanceTable::num_sources_, DistanceTableAB::temp_dr_, and DistanceTableAB::temp_r_.

104  {
105  RealType min_dist = std::numeric_limits<RealType>::max();
106  int index = -1;
107  if (newpos)
108  {
109  for (int jat = 0; jat < num_sources_; ++jat)
110  if (temp_r_[jat] < min_dist)
111  {
112  min_dist = temp_r_[jat];
113  index = jat;
114  }
115  if (index >= 0)
116  {
117  r = min_dist;
118  dr = temp_dr_[index];
119  }
120  }
121  else
122  {
123  for (int jat = 0; jat < num_sources_; ++jat)
124  if (distances_[iat][jat] < min_dist)
125  {
126  min_dist = distances_[iat][jat];
127  index = jat;
128  }
129  if (index >= 0)
130  {
131  r = min_dist;
132  dr = displacements_[iat][index];
133  }
134  }
135  assert(index >= 0 && index < num_sources_);
136  return index;
137  }
QMCTraits::RealType RealType
std::vector< DisplRow > displacements_
displacements_[num_targets_][3][num_sources_], [i][3][j] = r_A2[j] - r_A1[i] Note: Derived classes de...
std::vector< DistRow > distances_
distances_[num_targets_][num_sources_], [i][3][j] = |r_A2[j] - r_A1[i]| Note: Derived classes decide ...

◆ move()

void move ( const ParticleSet P,
const PosType rnew,
const IndexType  iat,
bool  prepare_old 
)
inlineoverridevirtual

evaluate the temporary pair relations

Implements DistanceTable.

Definition at line 82 of file SoaDistanceTableAB.h.

References Vector< T, Alloc >::data(), DistanceTableAB::displacements_, DistanceTableAB::distances_, DynamicCoordinates::getAllParticlePos(), ParticleSet::getCoordinates(), DistanceTable::modes_, SoaDistanceTableAB< T, D, SC >::move_timer_, qmcplusplus::NEED_FULL_TABLE_ANYTIME, DistanceTable::num_sources_, DistanceTable::origin_, ParticleSet::R, DistanceTableAB::temp_dr_, and DistanceTableAB::temp_r_.

83  {
84  ScopedTimer local_timer(move_timer_);
85  DTD_BConds<T, D, SC>::computeDistances(rnew, origin_.getCoordinates().getAllParticlePos(), temp_r_.data(), temp_dr_,
86  0, num_sources_);
87  // If the full table is not ready all the time, overwrite the current value.
88  // If this step is missing, DT values can be undefined in case a move is rejected.
89  if (!(modes_ & DTModes::NEED_FULL_TABLE_ANYTIME) && prepare_old)
90  DTD_BConds<T, D, SC>::computeDistances(P.R[iat], origin_.getCoordinates().getAllParticlePos(),
91  distances_[iat].data(), displacements_[iat], 0, num_sources_);
92  }
NewTimer & move_timer_
timer for move()
virtual const PosVectorSoa & getAllParticlePos() const =0
all particle position accessor
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
const DynamicCoordinates & getCoordinates() const
Definition: ParticleSet.h:246
whether full table needs to be ready at anytime or not during PbyP Optimization can be implemented du...
std::vector< DisplRow > displacements_
displacements_[num_targets_][3][num_sources_], [i][3][j] = r_A2[j] - r_A1[i] Note: Derived classes de...
const ParticleSet & origin_
Definition: DistanceTable.h:51
std::vector< DistRow > distances_
distances_[num_targets_][num_sources_], [i][3][j] = |r_A2[j] - r_A1[i]| Note: Derived classes decide ...
DTModes modes_
operation modes defined by DTModes
Definition: DistanceTable.h:60

◆ resize()

void resize ( )
inline

Definition at line 41 of file SoaDistanceTableAB.h.

References DistanceTableAB::displacements_, DistanceTableAB::distances_, DistanceTable::num_sources_, DistanceTable::num_targets_, VectorSoaContainer< T, D, Alloc >::resize(), Vector< T, Alloc >::resize(), DistanceTableAB::temp_dr_, and DistanceTableAB::temp_r_.

Referenced by SoaDistanceTableAB< T, D, SC >::SoaDistanceTableAB().

42  {
43  if (num_sources_ * num_targets_ == 0)
44  return;
45 
46  // initialize memory containers and views
47  const int num_sources_padded = getAlignedSize<T>(num_sources_);
48  distances_.resize(num_targets_);
50  for (int i = 0; i < num_targets_; ++i)
51  {
52  distances_[i].resize(num_sources_padded);
53  displacements_[i].resize(num_sources_padded);
54  }
55 
56  // The padding of temp_r_ and temp_dr_ is necessary for the memory copy in the update function
57  // temp_r_ is padded explicitly while temp_dr_ is padded internally
58  temp_r_.resize(num_sources_padded);
60  }
void resize(size_type n, Type_t val=Type_t())
Resize the container.
Definition: OhmmsVector.h:166
std::vector< DisplRow > displacements_
displacements_[num_targets_][3][num_sources_], [i][3][j] = r_A2[j] - r_A1[i] Note: Derived classes de...
void resize(size_type n)
resize myData
std::vector< DistRow > distances_
distances_[num_targets_][num_sources_], [i][3][j] = |r_A2[j] - r_A1[i]| Note: Derived classes decide ...

◆ update()

void update ( IndexType  iat)
inlineoverridevirtual

update the stripe for jat-th particle

Implements DistanceTable.

Definition at line 95 of file SoaDistanceTableAB.h.

References qmcplusplus::syclBLAS::copy_n(), Vector< T, Alloc >::data(), VectorSoaContainer< T, D, Alloc >::data(), DistanceTableAB::displacements_, DistanceTableAB::distances_, DistanceTable::num_sources_, DistanceTableAB::temp_dr_, DistanceTableAB::temp_r_, and SoaDistanceTableAB< T, D, SC >::update_timer_.

96  {
97  ScopedTimer local_timer(update_timer_);
99  for (int idim = 0; idim < D; ++idim)
100  std::copy_n(temp_dr_.data(idim), num_sources_, displacements_[iat].data(idim));
101  }
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
NewTimer & update_timer_
timer for update()
sycl::event copy_n(sycl::queue &aq, const T1 *restrict VA, size_t array_size, T2 *restrict VC, const std::vector< sycl::event > &events)
Definition: syclBLAS.cpp:548
std::vector< DisplRow > displacements_
displacements_[num_targets_][3][num_sources_], [i][3][j] = r_A2[j] - r_A1[i] Note: Derived classes de...
std::vector< DistRow > distances_
distances_[num_targets_][num_sources_], [i][3][j] = |r_A2[j] - r_A1[i]| Note: Derived classes decide ...

Member Data Documentation

◆ evaluate_timer_

NewTimer& evaluate_timer_
private

timer for evaluate()

Definition at line 141 of file SoaDistanceTableAB.h.

Referenced by SoaDistanceTableAB< T, D, SC >::evaluate().

◆ move_timer_

NewTimer& move_timer_
private

timer for move()

Definition at line 143 of file SoaDistanceTableAB.h.

Referenced by SoaDistanceTableAB< T, D, SC >::move().

◆ update_timer_

NewTimer& update_timer_
private

timer for update()

Definition at line 145 of file SoaDistanceTableAB.h.

Referenced by SoaDistanceTableAB< T, D, SC >::update().


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