1 //////////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source License.
3 // See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2021 QMCPACK developers.
6 //
7 // File developed by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory
8 //
9 // File created by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory
10 //////////////////////////////////////////////////////////////////////////////////////
11
12
13 #include "PSdispatcher.h"
14
15 namespace qmcplusplus
16 {
PSdispatcher(bool use_batch)17 PSdispatcher::PSdispatcher(bool use_batch) : use_batch_(use_batch) {}
18
flex_loadWalker(const RefVectorWithLeader<ParticleSet> & p_list,const RefVector<Walker_t> & walkers,const std::vector<bool> & recompute,bool pbyp) const19 void PSdispatcher::flex_loadWalker(const RefVectorWithLeader<ParticleSet>& p_list,
20 const RefVector<Walker_t>& walkers,
21 const std::vector<bool>& recompute,
22 bool pbyp) const
23 {
24 if (use_batch_)
25 ParticleSet::mw_loadWalker(p_list, walkers, recompute, pbyp);
26 else
27 for (size_t iw = 0; iw < p_list.size(); iw++)
28 if (recompute[iw])
29 {
30 p_list[iw].loadWalker(walkers[iw], false);
31 // loadWalker and mw_loadWalker doesn't have the same behavior. Need the following update call.
32 p_list[iw].update(true);
33 }
34 }
35
flex_update(const RefVectorWithLeader<ParticleSet> & p_list,bool skipSK) const36 void PSdispatcher::flex_update(const RefVectorWithLeader<ParticleSet>& p_list, bool skipSK) const
37 {
38 if (use_batch_)
39 ParticleSet::mw_update(p_list, skipSK);
40 else
41 for (ParticleSet& pset : p_list)
42 pset.update(skipSK);
43 }
44
flex_makeMove(const RefVectorWithLeader<ParticleSet> & p_list,int iat,const std::vector<SingleParticlePos_t> & displs) const45 void PSdispatcher::flex_makeMove(const RefVectorWithLeader<ParticleSet>& p_list,
46 int iat,
47 const std::vector<SingleParticlePos_t>& displs) const
48 {
49 if (use_batch_)
50 ParticleSet::mw_makeMove(p_list, iat, displs);
51 else
52 for (size_t iw = 0; iw < p_list.size(); iw++)
53 p_list[iw].makeMove(iat, displs[iw]);
54 }
55
flex_accept_rejectMove(const RefVectorWithLeader<ParticleSet> & p_list,int iat,const std::vector<bool> & isAccepted,bool forward_mode) const56 void PSdispatcher::flex_accept_rejectMove(const RefVectorWithLeader<ParticleSet>& p_list,
57 int iat,
58 const std::vector<bool>& isAccepted,
59 bool forward_mode) const
60 {
61 if (use_batch_)
62 ParticleSet::mw_accept_rejectMove(p_list, iat, isAccepted, forward_mode);
63 else
64 for (size_t iw = 0; iw < p_list.size(); iw++)
65 p_list[iw].accept_rejectMove(iat, isAccepted[iw], forward_mode);
66 }
67
flex_donePbyP(const RefVectorWithLeader<ParticleSet> & p_list) const68 void PSdispatcher::flex_donePbyP(const RefVectorWithLeader<ParticleSet>& p_list) const
69 {
70 if (use_batch_)
71 ParticleSet::mw_donePbyP(p_list);
72 else
73 for (ParticleSet& pset : p_list)
74 pset.donePbyP();
75 }
76
flex_saveWalker(const RefVectorWithLeader<ParticleSet> & p_list,const RefVector<Walker_t> & walkers) const77 void PSdispatcher::flex_saveWalker(const RefVectorWithLeader<ParticleSet>& p_list,
78 const RefVector<Walker_t>& walkers) const
79 {
80 if (use_batch_)
81 ParticleSet::mw_saveWalker(p_list, walkers);
82 else
83 for (size_t iw = 0; iw < p_list.size(); iw++)
84 p_list[iw].saveWalker(walkers[iw]);
85 }
86
87 } // namespace qmcplusplus
88