Unverified Commit c098582d authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

refactor communication cutoff estimator. move it to Comm class. and adjust heuristics.

parent 1d310ad7
Loading
Loading
Loading
Loading
+36 −5
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#include "atom_vec.h"
#include "force.h"
#include "pair.h"
#include "bond.h"
#include "modify.h"
#include "fix.h"
#include "compute.h"
@@ -585,6 +586,41 @@ void Comm::set_proc_grid(int outflag)
  }
}

/* ----------------------------------------------------------------------
   determine suitable communication cutoff.
   it is the maximum of the user specified value and estimates based on
   the maximum neighbor list cutoff and largest bond equilibrium length.
   we use the 1.5x the bond equilibrium distance as cutoff, if only a
   bond style exists or only bond and angle styles exists.  If dihedrals
   or impropers are present we multiply by 2.0. This plus the
   "neighbor list skin" will become the default communication cutoff, if
   no pair style is defined and thus avoids all kinds of unexpected behavior
   for such systems.  If a pair style exists, the result is the maximum of
   the bond based cutoff and the largest pair cutoff and the user
   specified communication cutoff.
------------------------------------------------------------------------- */

double Comm::get_comm_cutoff()
{
  double maxcommcutoff = 0.0;
  if (force->bond) {
    int n = atom->nbondtypes;
    for (int i = 1; i <= n; ++i)
      maxcommcutoff = MAX(maxcommcutoff,force->bond->equilibrium_distance(i));

    if (force->dihedral || force->improper) {
      maxcommcutoff *= 2.0;
    } else {
      maxcommcutoff *=1.5;
    }
    maxcommcutoff += neighbor->skin;
  }
  maxcommcutoff = MAX(maxcommcutoff,neighbor->cutneighmax);
  maxcommcutoff = MAX(maxcommcutoff,cutghostuser);

  return maxcommcutoff;
}

/* ----------------------------------------------------------------------
   determine which proc owns atom with coord x[3] based on current decomp
   x will be in box (orthogonal) or lamda coords (triclinic)
@@ -963,11 +999,6 @@ rendezvous_all2all(int n, char *inbuf, int insize, int inorder, int *procs,
    return 0;    // all nout_rvous are 0, no 2nd irregular
  }






  // create procs and outbuf for All2all if necesary

  if (!outorder) {
+2 −0
Original line number Diff line number Diff line
@@ -70,6 +70,8 @@ class Comm : protected Pointers {
  void set_processors(int, char **);      // set 3d processor grid attributes
  virtual void set_proc_grid(int outflag = 1); // setup 3d grid of procs

  double get_comm_cutoff();     // determine communication cutoff

  virtual void setup() = 0;                      // setup 3d comm pattern
  virtual void forward_comm(int dummy = 0) = 0;  // forward comm of atom coords
  virtual void reverse_comm() = 0;               // reverse comm of forces
+1 −1
Original line number Diff line number Diff line
@@ -175,7 +175,7 @@ void CommBrick::setup()
  int ntypes = atom->ntypes;
  double *prd,*sublo,*subhi;

  double cut = MAX(neighbor->cutneighmax,cutghostuser);
  double cut = get_comm_cutoff();
  if ((cut == 0.0) && (me == 0))
    error->warning(FLERR,"Communication cutoff is 0.0. No ghost atoms "
                   "will be generated. Atoms may get lost.");
+1 −1
Original line number Diff line number Diff line
@@ -157,7 +157,7 @@ void CommTiled::setup()
  // set cutoff for comm forward and comm reverse
  // check that cutoff < any periodic box length

  double cut = MAX(neighbor->cutneighmax,cutghostuser);
  double cut = get_comm_cutoff();
  if ((cut == 0.0) && (me == 0))
    error->warning(FLERR,"Communication cutoff is 0.0. No ghost atoms "
                   "will be generated. Atoms may get lost.");
+1 −1
Original line number Diff line number Diff line
@@ -366,7 +366,7 @@ void Info::command(int narg, char **arg)
    if (comm->mode == 0) {
      fprintf(out,"Communication mode = single\n");
      fprintf(out,"Communication cutoff = %g\n",
              MAX(comm->cutghostuser,neighbor->cutneighmax));
              comm->get_comm_cutoff());
    }

    if (comm->mode == 1) {
Loading