Project

General

Profile

Task #2595

Reusable Utilities for Schedules

Added by Prashanth Kanduri about 2 months ago. Updated about 2 months ago.

Status:
New
Priority:
Normal
Category:
core library
Target version:
Difficulty:
uncategorized
Close

Description

Please refer to #2574 (Schedule Abstraction) and #2594 (GMX API)

The current implementation of do_forcecutsVERLET(...) performs many operation sequences that could serve as reusable utilities in other custom schedule as these would always be executed together.

The other benefit of doing so is to greatly improve code readability in the schedule and thereby encapsulate implementation details for developers assembling a customized schedule. It would also help shrink the lines of code.

Some examples can be:

void initShiftVectors()
{
    /* Compute shift vectors every step,
     * because of pressure coupling or box deformation!
     */
    if ((flags & GMX_FORCE_DYNAMICBOX) && bStateChanged)
    {
        calc_shifts(box, fr->shift_vec);
    }

    if (bCalcCGCM)
    {
        put_atoms_in_box_omp(fr->ePBC, box, x.subArray(0, homenr));
        inc_nrnb(nrnb, eNR_SHIFTX, homenr);
    }
    else if (EI_ENERGY_MINIMIZATION(inputrec->eI) && graph)
    {
        unshift_self(graph, box, as_rvec_array(x.data()));
    }

    nbnxn_atomdata_copy_shiftvec(flags & GMX_FORCE_DYNAMICBOX,
                             fr->shift_vec, nbv->nbat);
}

It can make use of objects that are pointed by the members of ForceSchedule class.

void doNSGridding()
{
    if (bNS)
    {
        if (graph && bStateChanged)
        {
 /* Calculate intramolecular shift vectors to make molecules whole */
            mk_mshift(fplog, graph, fr->ePBC, box, as_rvec_array(x.data()));
        }

        clear_rvec(vzero);
        box_diag[XX] = box[XX][XX];
        box_diag[YY] = box[YY][YY];
        box_diag[ZZ] = box[ZZ][ZZ];

        wallcycle_start(wcycle, ewcNS);
        if (!fr->bDomDec)
        {
            wallcycle_sub_start(wcycle, ewcsNBS_GRID_LOCAL);
            nbnxn_put_on_grid(nbv->nbs, fr->ePBC, box,
                              0, vzero, box_diag,
                              0, mdatoms->homenr, -1, fr->cginfo,
                              as_rvec_array(x.data()),
                              0, nullptr,
                              nbv->grp[eintLocal].kernel_type,
                              nbv->nbat);
            wallcycle_sub_stop(wcycle, ewcsNBS_GRID_LOCAL);
        }
        else
        {
            wallcycle_sub_start(wcycle, ewcsNBS_GRID_NONLOCAL);

            nbnxn_put_on_grid_nonlocal(nbv->nbs, domdec_zones(cr->dd), fr->cginfo, as_rvec_array(x.data()), nbv->grp[eintNonlocal].kernel_type, nbv->nbat);

            wallcycle_sub_stop(wcycle, ewcsNBS_GRID_NONLOCAL);
        }

        nbnxn_atomdata_set(nbv->nbat, nbv->nbs, mdatoms, fr->cginfo);
        wallcycle_stop(wcycle, ewcNS);
    }
}

History

#1 Updated by Prashanth Kanduri about 2 months ago

For more details on the Schedule Abstraction:

https://gerrit.gromacs.org/#/c/8088/

Also available in: Atom PDF