Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust one body Jastrow SoA algorithm #752

Merged
merged 4 commits into from
Apr 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions src/Particle/ParticleSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,6 @@ void ParticleSet::update(bool skipSK)
if (!skipSK && SK)
SK->UpdateAllPart(*this);

Ready4Measure=true;
activePtcl=-1;
}

Expand All @@ -471,7 +470,6 @@ void ParticleSet::update(const ParticlePos_t& pos)
if (SK && !SK->DoUpdate)
SK->UpdateAllPart(*this);

Ready4Measure=true;
activePtcl=-1;
}

Expand Down Expand Up @@ -590,7 +588,6 @@ bool ParticleSet::makeMove(const Walker_t& awalker
bool ParticleSet::makeMove(const Walker_t& awalker
, const ParticlePos_t& deltaR, const std::vector<RealType>& dt)
{
Ready4Measure=false;
activePtcl=-1;
if (UseBoundBox)
{
Expand Down Expand Up @@ -632,7 +629,6 @@ bool ParticleSet::makeMoveWithDrift(const Walker_t& awalker
, const ParticlePos_t& drift , const ParticlePos_t& deltaR
, RealType dt)
{
Ready4Measure=false;
activePtcl=-1;
if (UseBoundBox)
{
Expand Down Expand Up @@ -669,7 +665,6 @@ bool ParticleSet::makeMoveWithDrift(const Walker_t& awalker
, const ParticlePos_t& drift , const ParticlePos_t& deltaR
, const std::vector<RealType>& dt)
{
Ready4Measure=false;
activePtcl=-1;
if (UseBoundBox)
{
Expand Down Expand Up @@ -765,7 +760,6 @@ void ParticleSet::donePbyP(bool skipSK)
DistTables[i]->donePbyP();
if (!skipSK && SK && !SK->DoUpdate)
SK->UpdateAllPart(*this);
Ready4Measure=true;
activePtcl=-1;
myTimers[2]->stop();
}
Expand Down Expand Up @@ -799,7 +793,6 @@ void ParticleSet::loadWalker(Walker_t& awalker, bool pbyp)
SK->UpdateAllPart(*this);
}

Ready4Measure=false;
activePtcl=-1;
}

Expand Down
2 changes: 0 additions & 2 deletions src/Particle/ParticleSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,6 @@ class ParticleSet
bool IsGrouped;
///true if the particles have the same mass
bool SameMass;
/// true if all the internal state is ready for estimators
bool Ready4Measure;
///threa id
Index_t ThreadID;
///the index of the active particle for particle-by-particle moves
Expand Down
41 changes: 27 additions & 14 deletions src/QMCWaveFunctions/Jastrow/J1OrbitalSoA.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct J1OrbitalSoA : public OrbitalBase
posT curGrad;

///\f$Vat[i] = sum_(j) u_{i,j}\f$
aligned_vector<RealType> Vat;
Vector<valT> Vat;
aligned_vector<valT> U, dU, d2U;
aligned_vector<valT> DistCompressed;
aligned_vector<int> DistIndice;
Expand Down Expand Up @@ -136,14 +136,6 @@ struct J1OrbitalSoA : public OrbitalBase
{
UpdateMode=ORB_PBYP_RATIO;
curAt = computeU(P.DistTables[myTableID]->Temp_r.data());

if(!P.Ready4Measure)
{//need to compute per atom
computeU3(P,iat,P.DistTables[myTableID]->Distances[iat]);
Lap[iat]=accumulateGL(dU.data(),d2U.data(),P.DistTables[myTableID]->Displacements[iat],Grad[iat]);
Vat[iat]=simd::accumulate_n(U.data(),Nions,valT());
}

return std::exp(Vat[iat]-curAt);
}

Expand Down Expand Up @@ -276,9 +268,6 @@ struct J1OrbitalSoA : public OrbitalBase
*/
GradType evalGrad(ParticleSet& P, int iat)
{
computeU3(P,iat,P.DistTables[myTableID]->Distances[iat]);
Lap[iat]=accumulateGL(dU.data(),d2U.data(),P.DistTables[myTableID]->Displacements[iat],Grad[iat]);
Vat[iat]=simd::accumulate_n(U.data(),Nions,valT());
return GradType(Grad[iat]);
}

Expand Down Expand Up @@ -319,15 +308,39 @@ struct J1OrbitalSoA : public OrbitalBase
}


inline void registerData(ParticleSet& P, WFBufferType& buf) { }
inline void registerData(ParticleSet& P, WFBufferType& buf)
{
if ( Bytes_in_WFBuffer == 0 )
{
Bytes_in_WFBuffer = buf.current();
buf.add(Vat.begin(), Vat.end());
buf.add(Grad.begin(), Grad.end());
buf.add(Lap.begin(), Lap.end());
Bytes_in_WFBuffer = buf.current()-Bytes_in_WFBuffer;
// free local space
Vat.free();
Grad.free();
Lap.free();
}
else
{
buf.forward(Bytes_in_WFBuffer);
}
}

inline RealType updateBuffer(ParticleSet& P, WFBufferType& buf, bool fromscratch=false)
{
evaluateGL(P, P.G, P.L, false);
buf.forward(Bytes_in_WFBuffer);
return LogValue;
}

inline void copyFromBuffer(ParticleSet& P, WFBufferType& buf) { }
inline void copyFromBuffer(ParticleSet& P, WFBufferType& buf)
{
Vat.attachReference(buf.lendReference<valT>(Nelec), Nelec);
Grad.attachReference(buf.lendReference<posT>(Nelec), Nelec);
Lap.attachReference(buf.lendReference<valT>(Nelec), Nelec);
}

OrbitalBasePtr makeClone(ParticleSet& tqp) const
{
Expand Down
2 changes: 0 additions & 2 deletions src/Sandbox/diff_j1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,6 @@ int main(int argc, char** argv)
double r_ratio=0.0;
double g_ratio=0.0;

els.Ready4Measure=false;

int naccepted=0;
for(int iel=0; iel<nels; ++iel)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Sandbox/diff_wfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ int main(int argc, char** argv)

{
ParticleSet ions, els;
ions.setName("ion");
els.setName("e");
OHMMS_PRECISION scale=1.0;

int np=omp_get_num_threads();
Expand Down Expand Up @@ -177,8 +179,6 @@ int main(int argc, char** argv)
double r_ratio=0.0;
double g_ratio=0.0;

els.Ready4Measure=false;

int naccepted=0;
for(int iel=0; iel<nels; ++iel)
{
Expand Down
2 changes: 2 additions & 0 deletions src/Sandbox/miniqmc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ int main(int argc, char** argv)
clock.restart();

ParticleSet ions, els;
ions.setName("ion");
els.setName("e");
const OHMMS_PRECISION scale=1.0;

const int np=omp_get_num_threads();
Expand Down
14 changes: 7 additions & 7 deletions src/simd/algorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ namespace qmcplusplus {
return res;
}

///inner product
template<typename T1, typename T2, typename T3>
inline T3 inner_product_n(const T1* restrict a, const T2* restrict b, int n, T3 res)
{
for(int i=0; i<n; ++i) res += a[i]*b[i];
return res;
}
///inner product
template<typename T1, typename T2, typename T3>
inline T3 inner_product_n(const T1* restrict a, const T2* restrict b, int n, T3 res)
{
for(int i=0; i<n; ++i) res += a[i]*b[i];
return res;
}

} //simd namepsace
}
Expand Down