15 #ifndef QMCPLUSPLUS_REALSPACE_POSITIONS_OMPTARGET_H    16 #define QMCPLUSPLUS_REALSPACE_POSITIONS_OMPTARGET_H    42   std::unique_ptr<DynamicCoordinates> 
makeClone()
 override    44     return std::make_unique<RealSpacePositionsOMPTarget>(*this);
    88                         const std::vector<PosType>& new_positions)
 const override    93     const auto nw    = coords_list.size();
    94     auto& mw_new_pos = coords_leader.mw_mem_handle_.getResource().mw_new_pos;
    95     mw_new_pos.resize(nw);
    97     for (
int iw = 0; iw < nw; iw++)
    98       mw_new_pos(iw) = new_positions[iw];
   100     auto* mw_pos_ptr = mw_new_pos.data();
   101     PRAGMA_OFFLOAD(
"omp target update to(mw_pos_ptr[:QMCTraits::DIM * mw_new_pos.capacity()])")
   103     coords_leader.is_nw_new_pos_prepared = 
true;
   108                             const std::vector<PosType>& new_positions,
   109                             const std::vector<bool>& isAccepted)
 const override   111     assert(
this == &coords_list.
getLeader());
   112     const size_t nw         = coords_list.size();
   116     auto& mw_rsoa_ptrs      = mw_mem.mw_rsoa_ptrs;
   117     auto& mw_accept_indices = mw_mem.mw_accept_indices;
   122       app_warning() << 
"This message only appear in unit tests. Report a bug if seen in production code." << std::endl;
   125     coords_leader.is_nw_new_pos_prepared = 
false;
   127     mw_accept_indices.resize(nw);
   128     auto* restrict id_array = mw_accept_indices.data();
   130     size_t num_accepted = 0;
   131     for (
int iw = 0; iw < nw; iw++)
   135         id_array[num_accepted] = iw;
   142     if (num_accepted == 0)
   146     auto* restrict mw_pos_ptr  = mw_new_pos.
data();
   147     auto* restrict mw_rosa_ptr = mw_rsoa_ptrs.data();
   148     const size_t rsoa_stride   = 
RSoA.capacity();
   149     const size_t mw_pos_stride = mw_new_pos.capacity();
   151     PRAGMA_OFFLOAD(
"omp target teams distribute parallel for \   152                     map(always, to : id_array[:num_accepted])")
   153     for (
int i = 0; i < num_accepted; i++)
   155       const int iw           = id_array[i];
   156       RealType* RSoA_dev_ptr = mw_rosa_ptr[iw];
   158         RSoA_dev_ptr[iat + rsoa_stride * 
id] = mw_pos_ptr[iw + mw_pos_stride * 
id];
   181     auto resource_index = collection.
addResource(std::make_unique<MultiWalkerMem>());
   191     const auto nw = coords_list.size();
   192     mw_rsoa_ptrs.resize(nw);
   193     for (
int iw = 0; iw < nw; iw++)
   196       mw_rsoa_ptrs[iw] = coords.
RSoA.device_data();
   198     mw_rsoa_ptrs.updateTo();
   229     std::unique_ptr<Resource> 
makeClone()
 const override { 
return std::make_unique<MultiWalkerMem>(*this); }
   246     PRAGMA_OFFLOAD(
"omp target update to(data[0:RSoA.capacity()*QMCTraits::DIM])")
 DynamicCoordinateKind
enumerator for DynamicCoordinates kinds 
const RealType * getDevicePtr() const
size_t addResource(std::unique_ptr< Resource > &&res, bool noprint=false)
std::ostream & app_warning()
void takebackResource(ResourceHandle< RS > &res_handle)
helper functions for EinsplineSetBuilder 
VectorSoaContainer< RealType, QMCTraits::DIM, OMPallocator< RealType, PinnedAlignedAllocator< RealType > > > RSoA
particle positions in SoA layout 
quantum variables of all the particles 
ResourceHandle manages the temporary resource referenced from a collection. 
void setAllParticlePos(const ParticlePos &R) override
overwrite the positions of all the particles. 
multi walker shared memory buffer 
Soa Container for D-dim vectors. 
SoA adaptor class for Vector<TinyVector<T,D> > 
void createResource(ResourceCollection &collection) const override
initialize a shared resource and hand it to a collection 
bool is_host_position_changed_
if true, host position has been changed while the device copy has not been updated. 
const auto & getMultiWalkerRSoADevicePtrs() const
Attaches a unit to a Vector for IO. 
std::unique_ptr< Resource > makeClone() const override
std::unique_ptr< DynamicCoordinates > makeClone() override
MultiWalkerMem(const MultiWalkerMem &)
size_type size() const
return the current size 
Vector< RealType *, OMPallocator< RealType *, PinnedAlignedAllocator< RealType * > > > mw_rsoa_ptrs
RSoA device ptr list. 
const PosVectorSoa & getAllParticlePos() const override
all particle position accessor 
void setOneParticlePos(const PosType &pos, size_t iat) override
overwrite the position of one the particle. 
Introduced to handle virtual moves and ratio computations, e.g. 
CASTTYPE & getCastedElement(size_t i) const
bool is_nw_new_pos_prepared
if true, mw_new_pos has been updated with active positions. 
void copyIn(const Vector< TinyVector< T, D >> &in)
AoS to SoA : copy from Vector<TinyVector<>> 
T * data()
return the base 
Vector< int, OMPallocator< int, PinnedAlignedAllocator< int > > > mw_accept_indices
accept list 
CASTTYPE & getCastedLeader() const
void acquireResource(ResourceCollection &collection, const RefVectorWithLeader< DynamicCoordinates > &coords_list) const override
acquire a shared resource from a collection 
const auto & getFusedNewPosBuffer() const
void mw_acceptParticlePos(const RefVectorWithLeader< DynamicCoordinates > &coords_list, size_t iat, const std::vector< PosType > &new_positions, const std::vector< bool > &isAccepted) const override
overwrite the positions of particles with a uniform id in all the walkers upon acceptance. 
void resize(size_t n) override
resize internal storages based on the number of particles 
VectorSoaContainer< RealType, QMCTraits::DIM, OMPallocator< RealType, PinnedAlignedAllocator< RealType > > > mw_new_pos
one particle new/old positions in SoA layout 
RealSpacePositionsOMPTarget(const RealSpacePositionsOMPTarget &in)
void donePbyP() override
secure internal data consistency after p-by-p moves 
ResourceHandle< RS > lendResource()
void releaseResource(ResourceCollection &collection, const RefVectorWithLeader< DynamicCoordinates > &coords_list) const override
return a shared resource to a collection 
PosVectorSoa RSoA_hostview
host view of RSoA 
size_type size() const
return the physical size 
void attachReference(size_type n, size_type n_padded, T *ptr)
attach to pre-allocated data 
RealSpacePositionsOMPTarget()
ResourceHandle< MultiWalkerMem > mw_mem_handle_
size_t size() const override
return the number of particles 
PosType getOneParticlePos(size_t iat) const override
one particle position accessor 
void mw_copyActivePos(const RefVectorWithLeader< DynamicCoordinates > &coords_list, size_t iat, const std::vector< PosType > &new_positions) const override
copy the active positions of particles with a uniform id in all the walkers to a single internal buff...