Skip to content

How to handle asynchronous computation #245

Description

@ye-luo

My rough ideas for incorporating asynchronous computation but hide the detail at the lowest possible level. Since we have limited confidence in applying a tasking programming model to the whole code, the follow code may achieve hopefully sufficient asynchronous behaviour and performance.

When we compute the trial wavefunction, the call sequence is
TrialWF->ratioGrad()
{
TrialWF->WFC[0]->ratioGrad(iel) //determinant
{
SPO->evaluate(iel);
getInvRow(psi_inv);
dot(spo_v, psi_inv);
}
TrialWF->WFC[1]->ratioGrad(iel); //Jastrow
}

Instead, we separate ratioGrad into two parts. The async launching part and the wait
TrialWF->ratioGrad()
{
TrialWF->WFC[0]->ratioGradLaunchAsync(iel) //determinant
{
SPO->evaluateLaunchAsync(iel);
getInvRowLaunchAsync(psi_inv);
}
TrialWF->WFC[1]->ratioGradLaunchAsync(iel); //Jastrow
/// finish launching async calls of all the WFCs
TrialWF->WFC[0]->ratioGrad(iel) //determinant
{
SPO->evaluate(iel); // wait completion inside
getInvRow(psi_inv); // wait completion inside
dot(spo_v, psiM[iel]);
}
TrialWF->WFC[1]->ratioGrad(iel); //Jastrow
}

This is similar to what we have in the CUDA code but I'm expanding it to allows working through levels if necessary. CUDA or OpenMP offload can be hidden beneath. In the case of CUDA, delayed update engine and SPO can use different streams to maximize asynchronous concurrent execution. The QMCPACK CUDA code relies on a single stream to enforce synchronization. SPO can also be OpenMP offload and the asynchronous control is self contained. If necessary, the TrialWF->ratioGrad can also split into ratioGradLaunchAsync and ratioGrad which can be called by the driver.

Any piece not needing async remains unchanged.

Pros: we explicitly control dependency.
Cons: we explicitly control wait instead of the runtime.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions