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 batching interface in SPOSet
ye-luo committed Jun 5, 2019
commit f6860209572809f3272775f2ee8d85bbdd422fcf
40 changes: 39 additions & 1 deletion src/QMCWaveFunctions/DiracDeterminant.cpp
Original file line number Diff line number Diff line change
@@ -93,12 +93,20 @@ typename DiracDeterminant<DU_TYPE>::ValueType DiracDeterminant<DU_TYPE>::ratioGr
int iat,
GradType& grad_iat)
{
UpdateMode = ORB_PBYP_PARTIAL;
SPOVGLTimer->start();
Phi->evaluate(P, iat, psiV, dpsiV, d2psiV);
SPOVGLTimer->stop();
return ratioGrad_compute(iat, grad_iat);
}

template<typename DU_TYPE>
typename DiracDeterminant<DU_TYPE>::ValueType DiracDeterminant<DU_TYPE>::ratioGrad_compute(int iat,
GradType& grad_iat)
{
RatioTimer->start();
const int WorkingIndex = iat - FirstIndex;
UpdateMode = ORB_PBYP_PARTIAL;
ValueType ratio;
GradType rv;

// This is an optimization.
@@ -273,6 +281,36 @@ void DiracDeterminant<DU_TYPE>::recompute(ParticleSet& P)
}
}

template<typename DU_TYPE>
void DiracDeterminant<DU_TYPE>::multi_ratioGrad(const std::vector<WaveFunctionComponent*>& WFC_list,
const std::vector<ParticleSet*>& P_list,
int iat,
std::vector<ValueType>& ratios,
std::vector<PosType>& grad_new)
{
SPOVGLTimer->start();
std::vector<SPOSet*> phi_list; phi_list.reserve(WFC_list.size());
std::vector<ValueVector_t*> psi_v_list; psi_v_list.reserve(WFC_list.size());
std::vector<GradVector_t*> dpsi_v_list; dpsi_v_list.reserve(WFC_list.size());
std::vector<ValueVector_t*> d2psi_v_list; d2psi_v_list.reserve(WFC_list.size());

for(auto wfc : WFC_list)
{
auto det = static_cast<DiracDeterminant<DU_TYPE>*>(wfc);
phi_list.push_back(det->Phi);
psi_v_list.push_back(&(det->psiV));
dpsi_v_list.push_back(&(det->dpsiV));
d2psi_v_list.push_back(&(det->d2psiV));
}

Phi->multi_evaluate(phi_list, P_list, iat, psi_v_list, dpsi_v_list, d2psi_v_list);
SPOVGLTimer->stop();

//#pragma omp parallel for
for (int iw = 0; iw < P_list.size(); iw++)
ratios[iw] = static_cast<DiracDeterminant<DU_TYPE>*>(WFC_list[iw])->ratioGrad_compute(iat, grad_new[iw]);
}

typedef QMCTraits::ValueType ValueType;
typedef QMCTraits::QTFull::ValueType mValueType;

10 changes: 10 additions & 0 deletions src/QMCWaveFunctions/DiracDeterminant.h
Original file line number Diff line number Diff line change
@@ -74,6 +74,9 @@ class DiracDeterminant : public WaveFunctionComponent
*/

ValueType ratioGrad(ParticleSet& P, int iat, GradType& grad_iat);
//helper function, called by ratioGrad and multi_ratioGrad
ValueType ratioGrad_compute(int iat, GradType& grad_iat);

GradType evalGrad(ParticleSet& P, int iat);

/** move was accepted, update the real container
@@ -86,6 +89,12 @@ class DiracDeterminant : public WaveFunctionComponent

void recompute(ParticleSet& P);

void multi_ratioGrad(const std::vector<WaveFunctionComponent*>& WFC_list,
const std::vector<ParticleSet*>& P_list,
int iat,
std::vector<ValueType>& ratios,
std::vector<PosType>& grad_new);

/// psiM(j,i) \f$= \psi_j({\bf r}_i)\f$
ValueMatrix_t psiM_temp;

@@ -119,6 +128,7 @@ class DiracDeterminant : public WaveFunctionComponent
ValueType curRatio;

private:

/// Timers
NewTimer* UpdateTimer;
NewTimer* RatioTimer;
18 changes: 8 additions & 10 deletions src/QMCWaveFunctions/SPOSet.h
Original file line number Diff line number Diff line change
@@ -99,26 +99,24 @@ class SPOSet : public QMCTraits
}

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

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

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(*P_list[iw], iat);
}
};

} // namespace qmcplusplus
23 changes: 5 additions & 18 deletions src/QMCWaveFunctions/WaveFunction.cpp
Original file line number Diff line number Diff line change
@@ -59,7 +59,7 @@ void build_WaveFunction(bool useRef,
}

// create a spo view
WF.spo = build_SPOSet_view(useRef, spo_main, 1, 0);
auto spo = build_SPOSet_view(useRef, spo_main, 1, 0);

const int nelup = els.getTotalNum() / 2;

@@ -79,8 +79,8 @@ void build_WaveFunction(bool useRef,

// determinant component
WF.nelup = nelup;
WF.Det_up = new DetType(WF.spo, 0, delay_rank);
WF.Det_dn = new DetType(WF.spo, nelup, delay_rank);
WF.Det_up = new DetType(spo, 0, delay_rank);
WF.Det_dn = new DetType(spo, nelup, delay_rank);

// J1 component
J1OrbType* J1 = new J1OrbType(ions, els);
@@ -116,8 +116,8 @@ void build_WaveFunction(bool useRef,

// determinant component
WF.nelup = nelup;
WF.Det_up = new DetType(WF.spo, 0, delay_rank);
WF.Det_dn = new DetType(WF.spo, nelup, delay_rank);
WF.Det_up = new DetType(spo, 0, delay_rank);
WF.Det_dn = new DetType(spo, nelup, delay_rank);

// J1 component
J1OrbType* J1 = new J1OrbType(ions, els);
@@ -148,7 +148,6 @@ WaveFunction::WaveFunction()
Is_built(false),
nelup(0),
ei_TableID(1),
spo(nullptr),
Det_up(nullptr),
Det_dn(nullptr),
LogValue(0.0)
@@ -158,7 +157,6 @@ WaveFunction::~WaveFunction()
{
if (Is_built)
{
delete spo;
delete Det_up;
delete Det_dn;
for (size_t i = 0; i < Jastrows.size(); i++)
@@ -371,9 +369,6 @@ void WaveFunction::flex_ratioGrad(const std::vector<WaveFunction*>& WF_list,
{
if (P_list.size() > 1)
{
auto spo_list(extract_spo_list(WF_list));
spo->multi_evaluate_vgh(spo_list, P_list, iat);

timers[Timer_Det]->start();
std::vector<valT> ratios_det(P_list.size());
for (int iw = 0; iw < P_list.size(); iw++)
@@ -475,14 +470,6 @@ void WaveFunction::flex_evaluateGL(const std::vector<WaveFunction*>& WF_list,
WF_list[0]->evaluateGL(*P_list[0]);
}

const std::vector<SPOSet*> WaveFunction::extract_spo_list(const std::vector<WaveFunction*>& WF_list) const
{
std::vector<SPOSet*> spo_list;
for (auto it = WF_list.begin(); it != WF_list.end(); it++)
spo_list.push_back((*it)->spo);
return spo_list;
}

const std::vector<WaveFunctionComponent*> WaveFunction::extract_up_list(const std::vector<WaveFunction*>& WF_list) const
{
std::vector<WaveFunctionComponent*> up_list;
4 changes: 1 addition & 3 deletions src/QMCWaveFunctions/WaveFunction.h
Original file line number Diff line number Diff line change
@@ -41,8 +41,7 @@ class WaveFunction
using posT = TinyVector<valT, OHMMS_DIM>;

private:
/// single particle orbitals
SPOSet* spo;
/// Slater determinants
WaveFunctionComponent* Det_up;
WaveFunctionComponent* Det_dn;
/// Jastrow factors
@@ -103,7 +102,6 @@ class WaveFunction
const RandomGenerator<QMCTraits::RealType>& RNG,
int delay_rank,
bool enableJ3);
const std::vector<SPOSet*> extract_spo_list(const std::vector<WaveFunction*>& WF_list) const;
const std::vector<WaveFunctionComponent*>
extract_up_list(const std::vector<WaveFunction*>& WF_list) const;
const std::vector<WaveFunctionComponent*>