From f5eee3a4bbd0bb309a26c1bd14db02fbce1bf077 Mon Sep 17 00:00:00 2001 From: Ye Luo Date: Fri, 6 Apr 2018 23:20:30 -0500 Subject: [PATCH 1/4] Align the way of using buf in SoA J1 as other Jas. --- src/QMCWaveFunctions/Jastrow/J1OrbitalSoA.h | 41 ++++++++++++++------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/src/QMCWaveFunctions/Jastrow/J1OrbitalSoA.h b/src/QMCWaveFunctions/Jastrow/J1OrbitalSoA.h index 7489d48086..d0aa32cfb5 100644 --- a/src/QMCWaveFunctions/Jastrow/J1OrbitalSoA.h +++ b/src/QMCWaveFunctions/Jastrow/J1OrbitalSoA.h @@ -54,7 +54,7 @@ struct J1OrbitalSoA : public OrbitalBase posT curGrad; ///\f$Vat[i] = sum_(j) u_{i,j}\f$ - aligned_vector Vat; + Vector Vat; aligned_vector U, dU, d2U; aligned_vector DistCompressed; aligned_vector DistIndice; @@ -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); } @@ -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]); } @@ -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(Nelec), Nelec); + Grad.attachReference(buf.lendReference(Nelec), Nelec); + Lap.attachReference(buf.lendReference(Nelec), Nelec); + } OrbitalBasePtr makeClone(ParticleSet& tqp) const { From 7a8a81f26aa5c0b459836e31060cfb8aaae0f104 Mon Sep 17 00:00:00 2001 From: Ye Luo Date: Fri, 6 Apr 2018 23:22:10 -0500 Subject: [PATCH 2/4] No more need of Ready4Measure state flag. --- src/Particle/ParticleSet.cpp | 7 ------- src/Particle/ParticleSet.h | 2 -- src/Sandbox/diff_j1.cpp | 2 -- src/Sandbox/diff_wfs.cpp | 2 -- 4 files changed, 13 deletions(-) diff --git a/src/Particle/ParticleSet.cpp b/src/Particle/ParticleSet.cpp index d37e8f5f48..470b0b8ac2 100644 --- a/src/Particle/ParticleSet.cpp +++ b/src/Particle/ParticleSet.cpp @@ -456,7 +456,6 @@ void ParticleSet::update(bool skipSK) if (!skipSK && SK) SK->UpdateAllPart(*this); - Ready4Measure=true; activePtcl=-1; } @@ -471,7 +470,6 @@ void ParticleSet::update(const ParticlePos_t& pos) if (SK && !SK->DoUpdate) SK->UpdateAllPart(*this); - Ready4Measure=true; activePtcl=-1; } @@ -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& dt) { - Ready4Measure=false; activePtcl=-1; if (UseBoundBox) { @@ -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) { @@ -669,7 +665,6 @@ bool ParticleSet::makeMoveWithDrift(const Walker_t& awalker , const ParticlePos_t& drift , const ParticlePos_t& deltaR , const std::vector& dt) { - Ready4Measure=false; activePtcl=-1; if (UseBoundBox) { @@ -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(); } @@ -799,7 +793,6 @@ void ParticleSet::loadWalker(Walker_t& awalker, bool pbyp) SK->UpdateAllPart(*this); } - Ready4Measure=false; activePtcl=-1; } diff --git a/src/Particle/ParticleSet.h b/src/Particle/ParticleSet.h index 49dd399c15..7025ad2c20 100644 --- a/src/Particle/ParticleSet.h +++ b/src/Particle/ParticleSet.h @@ -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 diff --git a/src/Sandbox/diff_j1.cpp b/src/Sandbox/diff_j1.cpp index 3eb773b620..65461000fc 100644 --- a/src/Sandbox/diff_j1.cpp +++ b/src/Sandbox/diff_j1.cpp @@ -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 Date: Fri, 6 Apr 2018 23:36:53 -0500 Subject: [PATCH 3/4] align indentation. --- src/simd/algorithm.hpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/simd/algorithm.hpp b/src/simd/algorithm.hpp index 95db384053..c46d4b363a 100644 --- a/src/simd/algorithm.hpp +++ b/src/simd/algorithm.hpp @@ -44,13 +44,13 @@ namespace qmcplusplus { return res; } - ///inner product - template - inline T3 inner_product_n(const T1* restrict a, const T2* restrict b, int n, T3 res) - { - for(int i=0; i + inline T3 inner_product_n(const T1* restrict a, const T2* restrict b, int n, T3 res) + { + for(int i=0; i Date: Sat, 7 Apr 2018 11:57:50 -0500 Subject: [PATCH 4/4] Fix ParticleSet name. --- src/Sandbox/diff_wfs.cpp | 2 ++ src/Sandbox/miniqmc.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/Sandbox/diff_wfs.cpp b/src/Sandbox/diff_wfs.cpp index 94c5e9091e..8cc976d40a 100644 --- a/src/Sandbox/diff_wfs.cpp +++ b/src/Sandbox/diff_wfs.cpp @@ -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(); diff --git a/src/Sandbox/miniqmc.cpp b/src/Sandbox/miniqmc.cpp index 1593506ee6..fb75186001 100644 --- a/src/Sandbox/miniqmc.cpp +++ b/src/Sandbox/miniqmc.cpp @@ -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();