move calculation of number of neighbors to Neighbor class
this allows reusing the code in the ImbalanceNeigh class
This commit is contained in:
@ -479,62 +479,25 @@ void Finish::end(int flag)
|
|||||||
mesg += "\n";
|
mesg += "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// find a non-skip neighbor list containing half pairwise interactions
|
tmp = neighbor->get_nneigh_half();
|
||||||
// count neighbors in that list for stats purposes
|
if (tmp > 0) {
|
||||||
// allow it to be Kokkos neigh list as well
|
stats(1,&tmp,&ave,&max,&min,10,histo);
|
||||||
|
if (me == 0) {
|
||||||
for (m = 0; m < neighbor->old_nrequest; m++)
|
mesg += fmt::format("Neighs: {:11.6} ave {:11.6g} max {:11.6g} min\n",ave,max,min);
|
||||||
if (neighbor->old_requests[m]->half &&
|
mesg += "Histogram:";
|
||||||
neighbor->old_requests[m]->skip == 0 &&
|
for (i = 0; i < 10; i++) mesg += fmt::format(" {}",histo[i]);
|
||||||
neighbor->lists[m] && neighbor->lists[m]->numneigh) break;
|
mesg += "\n";
|
||||||
|
}
|
||||||
nneigh = 0;
|
|
||||||
if (m < neighbor->old_nrequest) {
|
|
||||||
if (!neighbor->lists[m]->kokkos) {
|
|
||||||
int inum = neighbor->lists[m]->inum;
|
|
||||||
int *ilist = neighbor->lists[m]->ilist;
|
|
||||||
int *numneigh = neighbor->lists[m]->numneigh;
|
|
||||||
for (i = 0; i < inum; i++)
|
|
||||||
nneigh += numneigh[ilist[i]];
|
|
||||||
} else if (lmp->kokkos) nneigh = lmp->kokkos->neigh_count(m);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp = nneigh;
|
tmp = neighbor->get_nneigh_full();
|
||||||
stats(1,&tmp,&ave,&max,&min,10,histo);
|
if (tmp > 0) {
|
||||||
if (me == 0) {
|
|
||||||
mesg += fmt::format("Neighs: {:11.6} ave {:11.6g} max {:11.6g} min\n",ave,max,min);
|
|
||||||
mesg += "Histogram:";
|
|
||||||
for (i = 0; i < 10; i++) mesg += fmt::format(" {}",histo[i]);
|
|
||||||
mesg += "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
// find a non-skip neighbor list containing full pairwise interactions
|
|
||||||
// count neighbors in that list for stats purposes
|
|
||||||
// allow it to be Kokkos neigh list as well
|
|
||||||
|
|
||||||
for (m = 0; m < neighbor->old_nrequest; m++)
|
|
||||||
if (neighbor->old_requests[m]->full &&
|
|
||||||
neighbor->old_requests[m]->skip == 0) break;
|
|
||||||
|
|
||||||
nneighfull = 0;
|
|
||||||
if (m < neighbor->old_nrequest) {
|
|
||||||
if (!neighbor->lists[m]->kokkos && neighbor->lists[m]->numneigh) {
|
|
||||||
int inum = neighbor->lists[m]->inum;
|
|
||||||
int *ilist = neighbor->lists[m]->ilist;
|
|
||||||
int *numneigh = neighbor->lists[m]->numneigh;
|
|
||||||
for (i = 0; i < inum; i++)
|
|
||||||
nneighfull += numneigh[ilist[i]];
|
|
||||||
} else if (lmp->kokkos)
|
|
||||||
nneighfull = lmp->kokkos->neigh_count(m);
|
|
||||||
|
|
||||||
tmp = nneighfull;
|
|
||||||
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);
|
||||||
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";
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (me == 0) utils::logmesg(lmp,mesg);
|
if (me == 0) utils::logmesg(lmp,mesg);
|
||||||
@ -594,7 +557,7 @@ void Finish::end(int flag)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
// FIXME: should use bigint here.
|
||||||
void Finish::stats(int n, double *data,
|
void Finish::stats(int n, double *data,
|
||||||
double *pave, double *pmax, double *pmin,
|
double *pave, double *pmax, double *pmin,
|
||||||
int nhisto, int *histo)
|
int nhisto, int *histo)
|
||||||
|
|||||||
@ -61,19 +61,12 @@ void ImbalanceNeigh::compute(double *weight)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// find suitable neighbor list
|
bigint neighsum = neighbor->get_nneigh_half();
|
||||||
// can only use certain conventional neighbor lists
|
if (neighsum == 0) neighsum = neighbor->get_nneigh_full();
|
||||||
// NOTE: why not full list, if half does not exist?
|
|
||||||
|
|
||||||
for (req = 0; req < neighbor->old_nrequest; ++req) {
|
if ((neighsum == 0) || (neighbor->ago < 0)) {
|
||||||
if (neighbor->old_requests[req]->half && neighbor->old_requests[req]->skip == 0 &&
|
|
||||||
neighbor->lists[req] && neighbor->lists[req]->numneigh)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (req >= neighbor->old_nrequest || 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 list found");
|
error->warning(FLERR, "Balance weight neigh skipped b/c no suitable list found");
|
||||||
did_warn = 1;
|
did_warn = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -81,15 +74,8 @@ void ImbalanceNeigh::compute(double *weight)
|
|||||||
// neighsum = total neigh count for atoms on this proc
|
// neighsum = total neigh count for atoms on this proc
|
||||||
// localwt = weight assigned to each owned atom
|
// localwt = weight assigned to each owned atom
|
||||||
|
|
||||||
NeighList *list = neighbor->lists[req];
|
|
||||||
const int inum = list->inum;
|
|
||||||
const int *const ilist = list->ilist;
|
|
||||||
const int *const numneigh = list->numneigh;
|
|
||||||
int nlocal = atom->nlocal;
|
|
||||||
|
|
||||||
bigint neighsum = 0;
|
|
||||||
for (int i = 0; i < inum; ++i) neighsum += numneigh[ilist[i]];
|
|
||||||
double localwt = 0.0;
|
double localwt = 0.0;
|
||||||
|
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");
|
||||||
|
|||||||
@ -29,6 +29,7 @@
|
|||||||
#include "fix.h"
|
#include "fix.h"
|
||||||
#include "force.h"
|
#include "force.h"
|
||||||
#include "group.h"
|
#include "group.h"
|
||||||
|
#include "kokkos.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "modify.h"
|
#include "modify.h"
|
||||||
#include "nbin.h"
|
#include "nbin.h"
|
||||||
@ -2772,6 +2773,59 @@ void Neighbor::build_collection(int istart)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
for neighbor list statistics in Finish class
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
bigint Neighbor::get_nneigh_full()
|
||||||
|
{
|
||||||
|
// find a non-skip neighbor list containing full pairwise interactions
|
||||||
|
// count neighbors in that list for stats purposes
|
||||||
|
// allow it to be Kokkos neigh list as well
|
||||||
|
|
||||||
|
int m;
|
||||||
|
for (m = 0; m < old_nrequest; m++)
|
||||||
|
if (old_requests[m]->full && !old_requests[m]->skip) break;
|
||||||
|
|
||||||
|
bigint nneighfull = 0;
|
||||||
|
if (m < old_nrequest) {
|
||||||
|
if (!lists[m]->kokkos && lists[m]->numneigh) {
|
||||||
|
int inum = neighbor->lists[m]->inum;
|
||||||
|
int *ilist = neighbor->lists[m]->ilist;
|
||||||
|
int *numneigh = neighbor->lists[m]->numneigh;
|
||||||
|
for (int i = 0; i < inum; i++)
|
||||||
|
nneighfull += numneigh[ilist[i]];
|
||||||
|
} else if (lmp->kokkos)
|
||||||
|
nneighfull = lmp->kokkos->neigh_count(m);
|
||||||
|
}
|
||||||
|
return nneighfull;
|
||||||
|
}
|
||||||
|
|
||||||
|
bigint Neighbor::get_nneigh_half()
|
||||||
|
{
|
||||||
|
// find a non-skip neighbor list containing half pairwise interactions
|
||||||
|
// count neighbors in that list for stats purposes
|
||||||
|
// allow it to be Kokkos neigh list as well
|
||||||
|
|
||||||
|
int m;
|
||||||
|
for (m = 0; m < old_nrequest; m++)
|
||||||
|
if (old_requests[m]->half && !old_requests[m]->skip) break;
|
||||||
|
|
||||||
|
bigint nneighhalf = 0;
|
||||||
|
if (m < old_nrequest) {
|
||||||
|
if (!lists[m]->kokkos && lists[m]->numneigh) {
|
||||||
|
int inum = neighbor->lists[m]->inum;
|
||||||
|
int *ilist = neighbor->lists[m]->ilist;
|
||||||
|
int *numneigh = neighbor->lists[m]->numneigh;
|
||||||
|
for (int i = 0; i < inum; i++)
|
||||||
|
nneighhalf += numneigh[ilist[i]];
|
||||||
|
} else if (lmp->kokkos)
|
||||||
|
nneighhalf = lmp->kokkos->neigh_count(m);
|
||||||
|
}
|
||||||
|
return nneighhalf;
|
||||||
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
return # of bytes of allocated memory
|
return # of bytes of allocated memory
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|||||||
@ -159,6 +159,8 @@ class Neighbor : protected Pointers {
|
|||||||
int any_full(); // Check if any old requests had full neighbor lists
|
int any_full(); // Check if any old requests had full neighbor lists
|
||||||
void build_collection(int); // build peratom collection array starting at the given index
|
void build_collection(int); // build peratom collection array starting at the given index
|
||||||
|
|
||||||
|
bigint get_nneigh_full(); // return number of neighbors in a regular full neighbor list
|
||||||
|
bigint get_nneigh_half(); // return number of neighbors in a regular half neighbor list
|
||||||
double memory_usage();
|
double memory_usage();
|
||||||
|
|
||||||
bigint last_setup_bins; // step of last neighbor::setup_bins() call
|
bigint last_setup_bins; // step of last neighbor::setup_bins() call
|
||||||
|
|||||||
Reference in New Issue
Block a user