forked from QMCPACK/qmcpack
-
Notifications
You must be signed in to change notification settings - Fork 2
How to refactor PooledMemory usage
Ye Luo edited this page Apr 30, 2020
·
3 revisions
PooledMemory belongs to a walker.
In the old code TWF is used as slots. N_TWF /= N_w. This pattern is actually unnecessary. When system is big, N_w is typically the same as N_TWF. When system is small, memory is not an issue even TWF needs more memory than N_w. So we can afford N_TWF = N_w.
- registerBuffer reserves size of TWF needed memory in the PM of walkers.
- Before an calculation, copyFromBuffer takes data from PM
- A the end of advanceWalkers, updateBuffer sends data to PM.
The current WFC operates in two modes.
- copyFromBuffer/updateBuffer may copy memory. Very high cost
- copyFromBuffer/updateBuffer may attach, detach memory. Relatively unsafe.
The advantage of PM. It is a single contiguous resident memory and can issue single MPI isend/recv.
No more use PM but use WalkerExchangeMemView. It is restricted to branching step only. WalkerExchangeMemView holds a list of memory regions by address to be exchanged.
Each WFC implements
WFC::contributeView(WalkerExchangeMemView& view)
{
view.add(psiM.first_address(), psiM.last_address()); // vector, matrix....
view.add(&logpsi); // scalar
}
WalkerExchangeMemView
{
add() // add a memory segment in to the view.
operator =() // for copy walkers within an MPI rank.
isend/ircev() // for beyond an MPI rank.
packing/unpacking() // for small memory segment as an optimization.
}