float dd_pme_f_ratio(gmx_domdec_t *dd)
{
+ /* Should only be called on the DD master rank */
+ assert(DDMASTER(dd));
+
if (dd->comm->load[0].mdf > 0 && dd->comm->cycl_n[ddCyclPME] > 0)
{
return dd->comm->load[0].pme/dd->comm->load[0].mdf;
*/
static void dd_dlb_set_should_check_whether_to_turn_dlb_on(gmx_domdec_t *dd, gmx_bool bValue)
{
- if (dd->comm->eDLB == edlbAUTO && !dd_dlb_is_locked(dd))
+ if (dd->comm->eDLB == edlbAUTO)
{
+ assert(!dd_dlb_is_locked(dd));
+
dd->comm->bCheckWhetherToTurnDlbOn = bValue;
}
}
{
const int nddp_chk_dlb = 100;
- if (dd->comm->eDLB != edlbAUTO)
+ if (dd->comm->eDLB != edlbAUTO || dd_dlb_is_locked(dd))
{
return FALSE;
}
{
pme_lb->bBalance = dd_dlb_is_on(cr->dd);
}
- else
+ /* We should ignore the first timing to avoid timing allocation
+ * overhead. And since the PME load balancing is called just
+ * before DD repartitioning, the ratio returned by dd_pme_f_ratio
+ * is not over the last nstlist steps, but the nstlist steps before
+ * that. So the first useful ratio is available at step_rel=3*nstlist.
+ */
+ else if (step_rel >= 3*ir->nstlist)
{
if (DDMASTER(cr->dd))
{
- /* PME node load is too high, start tuning */
+ /* If PME rank load is too high, start tuning */
pme_lb->bBalance =
(dd_pme_f_ratio(cr->dd) >= loadBalanceTriggerFactor);
}
}
if (!pme_lb->bBalance &&
- (!pme_lb->bSepPMERanks || (step_rel <= pme_lb->step_rel_stop)))
+ (!pme_lb->bSepPMERanks || step_rel > pme_lb->step_rel_stop))
{
/* We have just deactivated the balancing and we're not measuring PP/PME
* imbalance during the first steps of the run: deactivate the tuning.