Commit f511c177 authored by sjplimp's avatar sjplimp
Browse files

git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@15670 f3b2605a-c512-4ea7-a41b-209d697bcdaa
parent 1ec3987b
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -142,7 +142,7 @@ void FixNEB::init()
  if (count > MAXSMALLINT) error->all(FLERR,"Too many active NEB atoms");
  nebatoms = count;

  // comm style for inter-replica exchange of coords
  // comm mode for inter-replica exchange of coords

  if (nreplica == nprocs_universe &&
      nebatoms == atom->natoms && atom->sortfreq == 0) 
@@ -392,7 +392,7 @@ void FixNEB::inter_replica_comm()
  // -----------------------------------------------------

  // single proc per replica
  // all atoms are NEB atoms and no atom sorting is enabled
  // all atoms are NEB atoms and no atom sorting
  // direct comm of x -> xprev and x -> xnext

  if (cmode == SINGLE_PROC_DIRECT) {
@@ -414,7 +414,7 @@ void FixNEB::inter_replica_comm()
  // single proc per replica
  // but only some atoms are NEB atoms or atom sorting is enabled
  // send atom IDs and coords of only NEB atoms to prev/next proc
  // recv proc uses atom->map() to match received coords to owned atoms
  // recv procs use atom->map() to match received coords to owned atoms

  if (cmode == SINGLE_PROC_MAP) {
    m = 0;
+102 −54
Original line number Diff line number Diff line
@@ -52,6 +52,8 @@

using namespace LAMMPS_NS;

enum{SINGLE_PROC_DIRECT,SINGLE_PROC_MAP,MULTI_PROC};

/* ---------------------------------------------------------------------- */

PRD::PRD(LAMMPS *lmp) : Pointers(lmp) {}
@@ -114,30 +116,35 @@ void PRD::command(int narg, char **arg)
  int color = me;
  MPI_Comm_split(universe->uworld,color,0,&comm_replica);

  // equal_size_replicas = 1 if all replicas have same # of procs
  // no longer used
  // comm mode for inter-replica exchange of coords

  //flag = 0;
  //if (nreplica*nprocs == nprocs_universe) flag = 1;
  //MPI_Allreduce(&flag,&equal_size_replicas,1,MPI_INT,MPI_MIN,
  //              universe->uworld);
  if (nreplica == nprocs_universe && atom->sortfreq == 0) 
    cmode = SINGLE_PROC_DIRECT;
  else if (nreplica == nprocs_universe) cmode = SINGLE_PROC_MAP;
  else cmode = MULTI_PROC;

  // workspace for inter-replica communication via gathers
  // workspace for inter-replica communication

  natoms = atom->natoms;

  displacements = NULL;
  tagall = NULL;
  xall = NULL;
  imageall = NULL;

  if (nreplica != nprocs_universe) {
    displacements = new int[nprocs];
  if (cmode != SINGLE_PROC_DIRECT) {
    memory->create(tagall,natoms,"prd:tagall");
    memory->create(xall,natoms,3,"prd:xall");
    memory->create(imageall,natoms,"prd:imageall");
  }

  counts = NULL;
  displacements = NULL;

  if (cmode == MULTI_PROC) {
    memory->create(counts,nprocs,"prd:counts");
    memory->create(displacements,nprocs,"prd:displacements");
  }

  // random_select = same RNG for each replica, for multiple event selection
  // random_clock = same RNG for each replica, for clock updates
  // random_dephase = unique RNG for each replica, for dephasing
@@ -238,7 +245,7 @@ void PRD::command(int narg, char **arg)
  if (domain->box_change)
    error->all(FLERR,"Cannot use PRD with a changing box");

  // cannot use PRD with time-dependent fixes or regions or atom sorting
  // cannot use PRD with time-dependent fixes or regions

  for (int i = 0; i < modify->nfix; i++)
    if (modify->fix[i]->time_depend)
@@ -248,9 +255,6 @@ void PRD::command(int narg, char **arg)
    if (domain->regions[i]->dynamic_check())
      error->all(FLERR,"Cannot use PRD with a time-dependent region defined");

  if (atom->sortfreq > 0)
    error->all(FLERR,"Cannot use PRD with atom_modify sort enabled");

  // perform PRD simulation

  if (me_universe == 0 && universe->uscreen)
@@ -433,12 +437,14 @@ void PRD::command(int narg, char **arg)
      fprintf(universe->uscreen,
              "Loop time of %g on %d procs for %d steps with " BIGINT_FORMAT
              " atoms\n",
              timer->get_wall(Timer::TOTAL),nprocs_universe,nsteps,atom->natoms);
              timer->get_wall(Timer::TOTAL),nprocs_universe,
              nsteps,atom->natoms);
    if (universe->ulogfile)
      fprintf(universe->ulogfile,
              "Loop time of %g on %d procs for %d steps with " BIGINT_FORMAT
              " atoms\n",
              timer->get_wall(Timer::TOTAL),nprocs_universe,nsteps,atom->natoms);
              timer->get_wall(Timer::TOTAL),nprocs_universe,
              nsteps,atom->natoms);
  }

  if (me == 0) {
@@ -461,10 +467,11 @@ void PRD::command(int narg, char **arg)

  // clean up

  delete [] displacements;
  memory->destroy(tagall);
  memory->destroy(xall);
  memory->destroy(imageall);
  memory->destroy(counts);
  memory->destroy(displacements);

  delete [] id_compute;
  MPI_Comm_free(&comm_replica);
@@ -780,12 +787,57 @@ void PRD::replicate(int ireplica)
  int nprocs_universe = universe->nprocs;
  int i,m;

  if (nreplica == nprocs_universe) {
    MPI_Bcast(atom->image,atom->nlocal,MPI_INT,ireplica,comm_replica);
  // -----------------------------------------------------
  // 3 cases: two for single proc per replica
  //          one for multiple procs per replica
  // -----------------------------------------------------

  // single proc per replica, no atom sorting
  // direct bcast of image and x

  if (cmode == SINGLE_PROC_DIRECT) {
    MPI_Bcast(atom->x[0],3*atom->nlocal,MPI_DOUBLE,ireplica,comm_replica);
    MPI_Bcast(atom->image,atom->nlocal,MPI_INT,ireplica,comm_replica);
    return;
  }

  } else {
    int *counts = new int[nprocs];
  // single proc per replica, atom sorting is enabled
  // bcast atom IDs, x, image via tagall, xall, imageall
  // recv procs use atom->map() to match received info to owned atoms

  if (cmode == SINGLE_PROC_MAP) {
    double **x = atom->x;
    tagint *tag = atom->tag;
    imageint *image = atom->image;
    int nlocal = atom->nlocal;

    if (universe->iworld == ireplica) {
      memcpy(tagall,tag,nlocal*sizeof(tagint));
      memcpy(xall[0],x[0],3*nlocal*sizeof(double));
      memcpy(imageall,image,nlocal*sizeof(imageint));
    }

    MPI_Bcast(tagall,natoms,MPI_INT,ireplica,comm_replica);
    MPI_Bcast(xall[0],3*natoms,MPI_DOUBLE,ireplica,comm_replica);
    MPI_Bcast(imageall,natoms,MPI_INT,ireplica,comm_replica);

    for (i = 0; i < nlocal; i++) {
      m = atom->map(tagall[i]);
      x[m][0] = xall[i][0];
      x[m][1] = xall[i][1];
      x[m][2] = xall[i][2];
      atom->image[m] = imageall[i];
    }

    return;
  }

  // multiple procs per replica
  // MPI_Gather all atom IDs, x, image to root proc of ireplica
  // bcast to root of other replicas
  // bcast within each replica
  // each proc extracts info for atoms it owns via atom->map()
  // NOTE: assumes imagint and tagint are always the same size

  if (universe->iworld == ireplica) {
    MPI_Gather(&atom->nlocal,1,MPI_INT,counts,1,MPI_INT,0,world);
@@ -794,8 +846,8 @@ void PRD::replicate(int ireplica)
      displacements[i+1] = displacements[i] + counts[i];
    MPI_Gatherv(atom->tag,atom->nlocal,MPI_LMP_TAGINT,
                tagall,counts,displacements,MPI_LMP_TAGINT,0,world);
      MPI_Gatherv(atom->image,atom->nlocal,MPI_INT,
                        imageall,counts,displacements,MPI_INT,0,world);
    MPI_Gatherv(atom->image,atom->nlocal,MPI_LMP_TAGINT,
                imageall,counts,displacements,MPI_LMP_TAGINT,0,world);
    for (i = 0; i < nprocs; i++) counts[i] *= 3;
    for (i = 0; i < nprocs-1; i++)
      displacements[i+1] = displacements[i] + counts[i];
@@ -818,7 +870,7 @@ void PRD::replicate(int ireplica)
  
  for (i = 0; i < natoms; i++) {
    m = atom->map(tagall[i]);
      if (m >= 0 && m < nlocal) {
    if (m < 0 || m >= nlocal) continue;
    x[m][0] = xall[i][0];
    x[m][1] = xall[i][1];
    x[m][2] = xall[i][2];
@@ -826,10 +878,6 @@ void PRD::replicate(int ireplica)
  }
}

    delete [] counts;
  }
}

/* ----------------------------------------------------------------------
   parse optional parameters at end of PRD input line
------------------------------------------------------------------------- */
+3 −2
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ class PRD : protected Pointers {
  int me,nprocs;
  int t_event,n_dephase,t_dephase,t_corr;
  double etol,ftol,temp_dephase;
  int maxiter,maxeval,temp_flag,stepmode;
  int maxiter,maxeval,temp_flag,stepmode,cmode;
  char *loop_setting,*dist_setting;

  int equal_size_replicas,natoms;
@@ -46,9 +46,10 @@ class PRD : protected Pointers {
  double time_start;

  MPI_Comm comm_replica;
  int *counts,*displacements;
  tagint *tagall;
  int *displacements,*imageall;
  double **xall;
  imageint *imageall;

  int ncoincident;

+2 −2
Original line number Diff line number Diff line
@@ -874,7 +874,7 @@ void TAD::revert_state()
}

/* ----------------------------------------------------------------------
   Initialize list of possible events
   initialize list of possible events
------------------------------------------------------------------------- */

void TAD::initialize_event_list() {
@@ -890,7 +890,7 @@ void TAD::initialize_event_list() {
}

/* ----------------------------------------------------------------------
   Delete list of possible events
   delete list of possible events
------------------------------------------------------------------------- */

void TAD::delete_event_list() {