update logic to avoid stall with neighbor list statistic during final summary

This commit is contained in:
Axel Kohlmeyer
2022-03-10 05:21:53 -05:00
parent 06e7bd8144
commit 61f5bbd633
3 changed files with 17 additions and 20 deletions

View File

@ -480,18 +480,17 @@ void Finish::end(int flag)
} }
tmp = neighbor->get_nneigh_half(); tmp = neighbor->get_nneigh_half();
if (tmp > 0) { if (tmp < 0.0) tmp = 0.0;
stats(1,&tmp,&ave,&max,&min,10,histo); stats(1,&tmp,&ave,&max,&min,10,histo);
if (me == 0) { if (me == 0) {
mesg += fmt::format("Neighs: {:11.6} ave {:11.6g} max {:11.6g} min\n",ave,max,min); mesg += fmt::format("Neighs: {:11.6} ave {:11.6g} max {:11.6g} min\n",ave,max,min);
mesg += "Histogram:"; mesg += "Histogram:";
for (i = 0; i < 10; i++) mesg += fmt::format(" {}",histo[i]); for (i = 0; i < 10; i++) mesg += fmt::format(" {}",histo[i]);
mesg += "\n"; mesg += "\n";
}
} }
tmp = neighbor->get_nneigh_full(); tmp = neighbor->get_nneigh_full();
if (tmp > 0) { if (tmp >= 0.0) {
stats(1,&tmp,&ave,&max,&min,10,histo); stats(1,&tmp,&ave,&max,&min,10,histo);
if (me == 0) { if (me == 0) {
mesg += fmt::format("FullNghs: {:11.6} ave {:11.6g} max {:11.6g} min\n",ave,max,min); mesg += fmt::format("FullNghs: {:11.6} ave {:11.6g} max {:11.6g} min\n",ave,max,min);

View File

@ -62,9 +62,9 @@ void ImbalanceNeigh::compute(double *weight)
} }
bigint neighsum = neighbor->get_nneigh_half(); bigint neighsum = neighbor->get_nneigh_half();
if (neighsum == 0) neighsum = neighbor->get_nneigh_full(); if (neighsum < 0) neighsum = neighbor->get_nneigh_full();
if ((neighsum == 0) || (neighbor->ago < 0)) { if ((neighsum < 0) || (neighbor->ago < 0)) {
if (comm->me == 0 && !did_warn) if (comm->me == 0 && !did_warn)
error->warning(FLERR, "Balance weight neigh skipped b/c no suitable list found"); error->warning(FLERR, "Balance weight neigh skipped b/c no suitable list found");
did_warn = 1; did_warn = 1;
@ -78,7 +78,7 @@ void ImbalanceNeigh::compute(double *weight)
const int nlocal = atom->nlocal; const int nlocal = atom->nlocal;
if (nlocal) localwt = 1.0 * neighsum / nlocal; if (nlocal) localwt = 1.0 * neighsum / nlocal;
if (nlocal && localwt <= 0.0) error->one(FLERR, "Balance weight <= 0.0"); if (nlocal && localwt < 0.0) error->one(FLERR, "Balance weight < 0.0");
// apply factor if specified != 1.0 // apply factor if specified != 1.0
// wtlo,wthi = lo/hi values excluding 0.0 due to no atoms on this proc // wtlo,wthi = lo/hi values excluding 0.0 due to no atoms on this proc

View File

@ -2788,7 +2788,7 @@ bigint Neighbor::get_nneigh_full()
for (m = 0; m < old_nrequest; m++) for (m = 0; m < old_nrequest; m++)
if (old_requests[m]->full && !old_requests[m]->skip) break; if (old_requests[m]->full && !old_requests[m]->skip) break;
bigint nneighfull = 0; bigint nneighfull = -1;
if (m < old_nrequest) { if (m < old_nrequest) {
if (!lists[m]->kokkos && lists[m]->numneigh) { if (!lists[m]->kokkos && lists[m]->numneigh) {
int inum = neighbor->lists[m]->inum; int inum = neighbor->lists[m]->inum;
@ -2796,8 +2796,7 @@ bigint Neighbor::get_nneigh_full()
int *numneigh = neighbor->lists[m]->numneigh; int *numneigh = neighbor->lists[m]->numneigh;
for (int i = 0; i < inum; i++) for (int i = 0; i < inum; i++)
nneighfull += numneigh[ilist[i]]; nneighfull += numneigh[ilist[i]];
} else if (lmp->kokkos) } else if (lmp->kokkos) nneighfull = lmp->kokkos->neigh_count(m);
nneighfull = lmp->kokkos->neigh_count(m);
} }
return nneighfull; return nneighfull;
} }
@ -2810,18 +2809,17 @@ bigint Neighbor::get_nneigh_half()
int m; int m;
for (m = 0; m < old_nrequest; m++) for (m = 0; m < old_nrequest; m++)
if (old_requests[m]->half && !old_requests[m]->skip) break; if (old_requests[m]->half && !old_requests[m]->skip && lists[m] && lists[m]->numneigh) break;
bigint nneighhalf = 0; bigint nneighhalf = -1;
if (m < old_nrequest) { if (m < old_nrequest) {
if (!lists[m]->kokkos && lists[m]->numneigh) { if (!lists[m]->kokkos) {
int inum = neighbor->lists[m]->inum; int inum = neighbor->lists[m]->inum;
int *ilist = neighbor->lists[m]->ilist; int *ilist = neighbor->lists[m]->ilist;
int *numneigh = neighbor->lists[m]->numneigh; int *numneigh = neighbor->lists[m]->numneigh;
for (int i = 0; i < inum; i++) for (int i = 0; i < inum; i++)
nneighhalf += numneigh[ilist[i]]; nneighhalf += numneigh[ilist[i]];
} else if (lmp->kokkos) } else if (lmp->kokkos) nneighhalf = lmp->kokkos->neigh_count(m);
nneighhalf = lmp->kokkos->neigh_count(m);
} }
return nneighhalf; return nneighhalf;
} }