Commit a1ca4ecb authored by Steve Plimpton's avatar Steve Plimpton
Browse files

add GridComm API changes to msm/cg/omp

parent 3a1b88c5
Loading
Loading
Loading
Loading
+27 −23
Original line number Diff line number Diff line
@@ -95,17 +95,7 @@ void MSMCGOMP::compute(int eflag, int vflag)

  // invoke allocate_peratom() if needed for first time

  if (vflag_atom && !peratom_allocate_flag) {
    allocate_peratom();
    cg_peratom_all->ghost_notify();
    cg_peratom_all->setup();
    for (int n=0; n<levels; n++) {
      if (!active_flag[n]) continue;
      cg_peratom[n]->ghost_notify();
      cg_peratom[n]->setup();
    }
    peratom_allocate_flag = 1;
  }
  if (vflag_atom && !peratom_allocate_flag) allocate_peratom();

  // extend size of per-atom arrays if necessary

@@ -175,7 +165,8 @@ void MSMCGOMP::compute(int eflag, int vflag)
  //   to fully sum contribution in their 3d grid

  current_level = 0;
  cg_all->reverse_comm(this,REVERSE_RHO);
  gcall->reverse_comm_kspace(this,1,sizeof(double),REVERSE_RHO,
			     gcall_buf1,gcall_buf2,MPI_DOUBLE);

  // forward communicate charge density values to fill ghost grid points
  // compute direct sum interaction and then restrict to coarser grid
@@ -183,24 +174,30 @@ void MSMCGOMP::compute(int eflag, int vflag)
  for (int n=0; n<=levels-2; n++) {
    if (!active_flag[n]) continue;
    current_level = n;
    cg[n]->forward_comm(this,FORWARD_RHO);

    gc[n]->forward_comm_kspace(this,1,sizeof(double),FORWARD_RHO,
			       gc_buf1[n],gc_buf2[n],MPI_DOUBLE);
    direct(n);
    restriction(n);
  }


  // compute direct interaction for top grid level for non-periodic
  //   and for second from top grid level for periodic

  if (active_flag[levels-1]) {
    if (domain->nonperiodic) {
      current_level = levels-1;
      cg[levels-1]->forward_comm(this,FORWARD_RHO);
      gc[levels-1]->
	forward_comm_kspace(this,1,sizeof(double),FORWARD_RHO,
			    gc_buf1[levels-1],gc_buf2[levels-1],MPI_DOUBLE);
      direct_top(levels-1);
      cg[levels-1]->reverse_comm(this,REVERSE_AD);
      gc[levels-1]->
	reverse_comm_kspace(this,1,sizeof(double),REVERSE_AD,
			    gc_buf1[levels-1],gc_buf2[levels-1],MPI_DOUBLE);
      if (vflag_atom)
        cg_peratom[levels-1]->reverse_comm(this,REVERSE_AD_PERATOM);
	gc[levels-1]->
	  reverse_comm_kspace(this,6,sizeof(double),REVERSE_AD_PERATOM,
			      gc_buf1[levels-1],gc_buf2[levels-1],MPI_DOUBLE);

    } else {
      // Here using MPI_Allreduce is cheaper than using commgrid
      grid_swap_forward(levels-1,qgrid[levels-1]);
@@ -208,7 +205,9 @@ void MSMCGOMP::compute(int eflag, int vflag)
      grid_swap_reverse(levels-1,egrid[levels-1]);
      current_level = levels-1;
      if (vflag_atom)
        cg_peratom[levels-1]->reverse_comm(this,REVERSE_AD_PERATOM);
	gc[levels-1]->
	  reverse_comm_kspace(this,6,sizeof(double),REVERSE_AD_PERATOM,
			      gc_buf1[levels-1],gc_buf2[levels-1],MPI_DOUBLE);
    }
  }

@@ -220,24 +219,28 @@ void MSMCGOMP::compute(int eflag, int vflag)
    prolongation(n);

    current_level = n;
    cg[n]->reverse_comm(this,REVERSE_AD);
    gc[n]->reverse_comm_kspace(this,1,sizeof(double),REVERSE_AD,
			       gc_buf1[n],gc_buf2[n],MPI_DOUBLE);

    // extra per-atom virial communication

    if (vflag_atom)
      cg_peratom[n]->reverse_comm(this,REVERSE_AD_PERATOM);
      gc[n]->reverse_comm_kspace(this,6,sizeof(double),REVERSE_AD_PERATOM,
				 gc_buf1[n],gc_buf2[n],MPI_DOUBLE);
  }

  // all procs communicate E-field values
  // to fill ghost cells surrounding their 3d bricks

  current_level = 0;
  cg_all->forward_comm(this,FORWARD_AD);
  gcall->forward_comm_kspace(this,1,sizeof(double),FORWARD_AD,
			     gcall_buf1,gcall_buf2,MPI_DOUBLE);

  // extra per-atom energy/virial communication

  if (vflag_atom)
    cg_peratom_all->forward_comm(this,FORWARD_AD_PERATOM);
    gcall->forward_comm_kspace(this,6,sizeof(double),FORWARD_AD_PERATOM,
			       gcall_buf1,gcall_buf2,MPI_DOUBLE);

  // calculate the force on my particles (interpolation)

@@ -556,6 +559,7 @@ void MSMCGOMP::fieldforce_peratom()
  }
}

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

double MSMCGOMP::memory_usage()
{