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

Add delayed update #242

Merged
merged 33 commits into from
Jun 12, 2019
Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
aa27277
Add DiracDeterminant from QMCPACK.
ye-luo May 18, 2019
58c0633
Now the code compiles.
ye-luo Jun 4, 2019
a551369
Add unit tests
ye-luo Jun 4, 2019
8078aba
Format codes.
ye-luo Jun 4, 2019
b18e180
Fix SPO size
ye-luo Jun 4, 2019
f4fa4c3
Minor fix. still buggy.
ye-luo Jun 4, 2019
907401f
Make all timers as pointers.
ye-luo Jun 4, 2019
aa0841d
Connect SPO to Det
ye-luo Jun 4, 2019
5a4b0e3
Add delay rank arguments.
ye-luo Jun 4, 2019
eaca306
Fix check_spo
ye-luo Jun 5, 2019
5d0d3e6
Merge branch 'develop' into add-delayed-update
ye-luo Jun 5, 2019
f0ef52b
Add DiracDeterminantRef and add check_wfc
ye-luo Jun 5, 2019
c4f316a
Remove old Determinant
ye-luo Jun 5, 2019
d30ef2e
Remove redundant calculation
ye-luo Jun 5, 2019
2b3d2c2
Add completeUpdates to completeUpdates.
ye-luo Jun 5, 2019
0dd50dc
Add timer.
ye-luo Jun 5, 2019
f686020
Fix batching interface in SPOSet
ye-luo Jun 5, 2019
4639a3e
Fixing timers
ye-luo Jun 5, 2019
87dbf1a
Clean up interface
ye-luo Jun 6, 2019
0534126
Add a few more multi_ function in DiracDeterminant
ye-luo Jun 6, 2019
ecc8035
Use only xx of hess, mimic laplacian.
ye-luo Jun 6, 2019
4d869f6
Replace CI check.
ye-luo Jun 6, 2019
bf65c0d
Merge branch 'develop' into add-delayed-update
ye-luo Jun 6, 2019
bb0a45b
Merge branch 'develop' into add-delayed-update
PDoakORNL Jun 7, 2019
862c4e5
A bit update.
ye-luo Jun 7, 2019
44d2525
Change check_wfc G and L checks to relative errors.
ye-luo Jun 7, 2019
f21e626
Use relative error check on Det only
ye-luo Jun 8, 2019
ce4e53c
Correct script.
ye-luo Jun 10, 2019
b90bab6
Change DU rank option to -k.
ye-luo Jun 10, 2019
43a3da8
Adjust omp runtime calls.
ye-luo Jun 10, 2019
6f81ef3
Merge branch 'develop' into add-delayed-update
PDoakORNL Jun 11, 2019
7a1ae9d
Move LAPACK wrapper to OhmmsBlas.h
ye-luo Jun 12, 2019
9afab34
Minor clean up
ye-luo Jun 12, 2019
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
Prev Previous commit
Next Next commit
Fix check_spo
ye-luo committed Jun 5, 2019
commit eaca306dfabc21d37392dc718913a74340311b74
16 changes: 9 additions & 7 deletions src/Drivers/check_spo.cpp
Original file line number Diff line number Diff line change
@@ -249,9 +249,9 @@ int main(int argc, char** argv)
// VMC
for (int iel = 0; iel < nels; ++iel)
{
PosType pos = els.R[iel] + delta[iel];
spo.evaluate_vgh(pos);
spo_ref.evaluate_vgh(pos);
els.makeMove(iel, delta[iel]);
spo.evaluate_vgh(els, iel);
spo_ref.evaluate_vgh(els, iel);
// accumulate error
for (int ib = 0; ib < spo.nBlocks; ib++)
for (int n = 0; n < spo.nSplinesPerBlock; n++)
@@ -272,7 +272,7 @@ int main(int argc, char** argv)
}
if (ur[iel] < accept)
{
els.R[iel] = pos;
els.acceptMove(iel);
my_accepted++;
}
}
@@ -288,11 +288,13 @@ int main(int argc, char** argv)

for (int nn = 0; nn < nnF; ++nn)
{
int iel = nn + iat * zval;
for (int k = 0; k < nknots; k++)
{
PosType pos = centerP + r * rOnSphere[k];
spo.evaluate_v(pos);
spo_ref.evaluate_v(pos);
PosType delta_qp = centerP + r * rOnSphere[k] - els.R[iel];
els.makeMove(iel, delta_qp);
spo.evaluate_v(els, iel);
spo_ref.evaluate_v(els, iel);
// accumulate error
for (int ib = 0; ib < spo.nBlocks; ib++)
for (int n = 0; n < spo.nSplinesPerBlock; n++)
22 changes: 11 additions & 11 deletions src/QMCWaveFunctions/SPOSet.h
Original file line number Diff line number Diff line change
@@ -47,9 +47,9 @@ class SPOSet : public QMCTraits

/// operates on a single walker
/// evaluating SPOs
virtual void evaluate_v(const PosType& p) = 0;
virtual void evaluate_vgl(const PosType& p) = 0;
virtual void evaluate_vgh(const PosType& p) = 0;
virtual void evaluate_v(const ParticleSet& P, int iat) = 0;
virtual void evaluate_vgl(const ParticleSet& P, int iat) = 0;
virtual void evaluate_vgh(const ParticleSet& P, int iat) = 0;

/** evaluate the values of this single-particle orbital set
* @param P current ParticleSet
@@ -58,7 +58,7 @@ class SPOSet : public QMCTraits
*/
virtual void evaluate(const ParticleSet& P, int iat, ValueVector_t& psi_v)
{
evaluate_v(P.activeR(iat));
evaluate_v(P, iat);
}

/** evaluate the values, gradients and laplacians of this single-particle orbital set
@@ -70,7 +70,7 @@ class SPOSet : public QMCTraits
*/
virtual void evaluate(const ParticleSet& P, int iat, ValueVector_t& psi_v, GradVector_t& dpsi_v, ValueVector_t& d2psi_v)
{
evaluate_vgh(P.activeR(iat));
evaluate_vgh(P, iat);
}

/** evaluate the values, gradients and laplacians of this single-particle orbital for [first,last) particles
@@ -99,25 +99,25 @@ class SPOSet : public QMCTraits
}

/// operates on multiple walkers
virtual void multi_evaluate_v(const std::vector<SPOSet*>& spo_list, const std::vector<PosType>& pos_list)
virtual void multi_evaluate_v(const std::vector<SPOSet*>& spo_list, const std::vector<ParticleSet*>& P_list, int iat)
{
#pragma omp parallel for
for (int iw = 0; iw < spo_list.size(); iw++)
spo_list[iw]->evaluate_v(pos_list[iw]);
spo_list[iw]->evaluate_v(*P_list[iw], iat);
}

virtual void multi_evaluate_vgl(const std::vector<SPOSet*>& spo_list, const std::vector<PosType>& pos_list)
virtual void multi_evaluate_vgl(const std::vector<SPOSet*>& spo_list, const std::vector<ParticleSet*>& P_list, int iat)
{
#pragma omp parallel for
for (int iw = 0; iw < spo_list.size(); iw++)
spo_list[iw]->evaluate_vgl(pos_list[iw]);
spo_list[iw]->evaluate_vgl(*P_list[iw], iat);
}

virtual void multi_evaluate_vgh(const std::vector<SPOSet*>& spo_list, const std::vector<PosType>& pos_list)
virtual void multi_evaluate_vgh(const std::vector<SPOSet*>& spo_list, const std::vector<ParticleSet*>& P_list, int iat)
{
#pragma omp parallel for
for (int iw = 0; iw < spo_list.size(); iw++)
spo_list[iw]->evaluate_vgh(pos_list[iw]);
spo_list[iw]->evaluate_vgh(*P_list[iw], iat);
}
};

9 changes: 3 additions & 6 deletions src/QMCWaveFunctions/WaveFunction.cpp
Original file line number Diff line number Diff line change
@@ -208,7 +208,7 @@ WaveFunction::posT WaveFunction::evalGrad(ParticleSet& P, int iat)

WaveFunction::valT WaveFunction::ratioGrad(ParticleSet& P, int iat, posT& grad)
{
spo->evaluate_vgh(P.activePos);
spo->evaluate_vgh(P, iat);

timers[Timer_Det]->start();
grad = valT(0);
@@ -226,7 +226,7 @@ WaveFunction::valT WaveFunction::ratioGrad(ParticleSet& P, int iat, posT& grad)

WaveFunction::valT WaveFunction::ratio(ParticleSet& P, int iat)
{
spo->evaluate_v(P.activePos);
spo->evaluate_v(P, iat);

timers[Timer_Det]->start();
valT ratio = (iat < nelup ? Det_up->ratio(P, iat) : Det_dn->ratio(P, iat));
@@ -373,11 +373,8 @@ void WaveFunction::flex_ratioGrad(const std::vector<WaveFunction*>& WF_list,
{
if (P_list.size() > 1)
{
std::vector<posT> pos_list(P_list.size());
for (int iw = 0; iw < P_list.size(); iw++)
pos_list[iw] = P_list[iw]->activePos;
auto spo_list(extract_spo_list(WF_list));
spo->multi_evaluate_vgh(spo_list, pos_list);
spo->multi_evaluate_vgh(spo_list, P_list, iat);

timers[Timer_Det]->start();
std::vector<valT> ratios_det(P_list.size());
28 changes: 20 additions & 8 deletions src/QMCWaveFunctions/einspline_spo.hpp
Original file line number Diff line number Diff line change
@@ -159,41 +159,53 @@ struct einspline_spo : public SPOSet
}

/** evaluate psi */
inline void evaluate_v(const PosType& p) {}
inline void evaluate(const ParticleSet& P, int iat, ValueVector_t& psi_v)
inline void evaluate_v(const ParticleSet& P, int iat)
PDoakORNL marked this conversation as resolved.
Show resolved Hide resolved
{
ScopedTimer local_timer(timer);

auto u = Lattice.toUnit_floor(P.activeR(iat));
for (int i = 0; i < nBlocks; ++i)
{
MultiBsplineEval::evaluate_v(einsplines[i], u[0], u[1], u[2], psi[i].data(), nSplinesPerBlock);
}

inline void evaluate(const ParticleSet& P, int iat, ValueVector_t& psi_v)
{
evaluate_v(P, iat);

for (int i = 0; i < nBlocks; ++i)
{
// in real simulation, phase needs to be applied. Here just fake computation
const int first = i*nBlocks;
std::copy_n(psi[i].data(), std::min((i+1)*nSplinesPerBlock, OrbitalSetSize) - first, psi_v.data()+first);
}
}

/** evaluate psi, grad and lap */
inline void evaluate_vgl(const PosType& p)
inline void evaluate_vgl(const ParticleSet& P, int iat)
{
auto u = Lattice.toUnit_floor(p);
auto u = Lattice.toUnit_floor(P.activeR(iat));
for (int i = 0; i < nBlocks; ++i)
MultiBsplineEval::evaluate_vgl(einsplines[i], u[0], u[1], u[2], psi[i].data(), grad[i].data(), hess[i].data(),
nSplinesPerBlock);
}

/** evaluate psi, grad and hess */
inline void evaluate_vgh(const PosType& p) {}
inline void evaluate(const ParticleSet& P, int iat, ValueVector_t& psi_v, GradVector_t& dpsi_v, ValueVector_t& d2psi_v)
inline void evaluate_vgh(const ParticleSet& P, int iat)
{
ScopedTimer local_timer(timer);

auto u = Lattice.toUnit_floor(P.activeR(iat));
for (int i = 0; i < nBlocks; ++i)
{
MultiBsplineEval::evaluate_vgh(einsplines[i], u[0], u[1], u[2], psi[i].data(), grad[i].data(), hess[i].data(),
nSplinesPerBlock);
}

inline void evaluate(const ParticleSet& P, int iat, ValueVector_t& psi_v, GradVector_t& dpsi_v, ValueVector_t& d2psi_v)
{
evaluate_vgh(P, iat);

for (int i = 0; i < nBlocks; ++i)
{
// in real simulation, phase needs to be applied. Here just fake computation
const int first = i*nBlocks;
for (int j = first; j < std::min((i+1)*nSplinesPerBlock, OrbitalSetSize); j++)
12 changes: 6 additions & 6 deletions src/QMCWaveFunctions/einspline_spo_ref.hpp
Original file line number Diff line number Diff line change
@@ -156,30 +156,30 @@ struct einspline_spo_ref : public SPOSet
}

/** evaluate psi */
inline void evaluate_v(const PosType& p)
inline void evaluate_v(const ParticleSet& P, int iat)
{
ScopedTimer local_timer(timer);

auto u = Lattice.toUnit_floor(p);
auto u = Lattice.toUnit_floor(P.activeR(iat));
for (int i = 0; i < nBlocks; ++i)
MultiBsplineEvalRef::evaluate_v(einsplines[i], u[0], u[1], u[2], psi[i].data(), nSplinesPerBlock);
}

/** evaluate psi, grad and lap */
inline void evaluate_vgl(const PosType& p)
inline void evaluate_vgl(const ParticleSet& P, int iat)
{
auto u = Lattice.toUnit_floor(p);
auto u = Lattice.toUnit_floor(P.activeR(iat));
for (int i = 0; i < nBlocks; ++i)
MultiBsplineEvalRef::evaluate_vgl(einsplines[i], u[0], u[1], u[2], psi[i].data(), grad[i].data(), hess[i].data(),
nSplinesPerBlock);
}

/** evaluate psi, grad and hess */
inline void evaluate_vgh(const PosType& p)
inline void evaluate_vgh(const ParticleSet& P, int iat)
{
ScopedTimer local_timer(timer);

auto u = Lattice.toUnit_floor(p);
auto u = Lattice.toUnit_floor(P.activeR(iat));
for (int i = 0; i < nBlocks; ++i)
MultiBsplineEvalRef::evaluate_vgh(einsplines[i], u[0], u[1], u[2], psi[i].data(), grad[i].data(), hess[i].data(),
nSplinesPerBlock);
6 changes: 3 additions & 3 deletions src/QMCWaveFunctions/tests/test_dirac_det.cpp
Original file line number Diff line number Diff line change
@@ -66,9 +66,9 @@ class FakeSPO : public SPOSet
GradMatrix_t& dlogdet,
ValueMatrix_t& d2logdet);

void evaluate_v(const PosType& p) {};
void evaluate_vgl(const PosType& p) {};
void evaluate_vgh(const PosType& p) {};
void evaluate_v(const ParticleSet& P, int iat) {};
void evaluate_vgl(const ParticleSet& P, int iat) {};
void evaluate_vgh(const ParticleSet& P, int iat) {};
};

FakeSPO::FakeSPO()