Commit f1afa45b authored by Stan Moore's avatar Stan Moore
Browse files

Merge branch 'gridcomm-tiled' of ssh://github.com/lammps/lammps into gridcomm-tiled

parents 40e55af8 6225a7d4
Loading
Loading
Loading
Loading
+15 −14
Original line number Diff line number Diff line
@@ -45,20 +45,21 @@ enum{FORWARD_RHO,FORWARD_AD,FORWARD_AD_PERATOM};

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

MSM::MSM(LAMMPS *lmp) : KSpace(lmp),
MSM::MSM(LAMMPS *lmp)
  : KSpace(lmp),
    factors(NULL), delxinv(NULL), delyinv(NULL), delzinv(NULL), nx_msm(NULL),
    ny_msm(NULL), nz_msm(NULL), nxlo_in(NULL), nylo_in(NULL), nzlo_in(NULL),
    nxhi_in(NULL), nyhi_in(NULL), nzhi_in(NULL), nxlo_out(NULL), nylo_out(NULL),
    nzlo_out(NULL), nxhi_out(NULL), nyhi_out(NULL), nzhi_out(NULL), ngrid(NULL),
    active_flag(NULL), alpha(NULL), betax(NULL), betay(NULL), betaz(NULL),
  peratom_allocate_flag(0),
  levels(0), world_levels(NULL), qgrid(NULL), egrid(NULL), v0grid(NULL), v1grid(NULL),
  v2grid(NULL), v3grid(NULL), v4grid(NULL), v5grid(NULL), g_direct(NULL),
  v0_direct(NULL), v1_direct(NULL), v2_direct(NULL), v3_direct(NULL), v4_direct(NULL),
  v5_direct(NULL), g_direct_top(NULL), v0_direct_top(NULL), v1_direct_top(NULL),
  v2_direct_top(NULL), v3_direct_top(NULL), v4_direct_top(NULL), v5_direct_top(NULL),
  phi1d(NULL), dphi1d(NULL), procneigh_levels(NULL), gc(NULL),
  gcall(NULL), part2grid(NULL), boxlo(NULL)
    peratom_allocate_flag(0),levels(0),world_levels(NULL),qgrid(NULL),egrid(NULL),
    v0grid(NULL), v1grid(NULL),v2grid(NULL),v3grid(NULL),v4grid(NULL),v5grid(NULL),
    g_direct(NULL),v0_direct(NULL),v1_direct(NULL),v2_direct(NULL),v3_direct(NULL),
    v4_direct(NULL),v5_direct(NULL),g_direct_top(NULL),v0_direct_top(NULL),
    v1_direct_top(NULL),v2_direct_top(NULL),v3_direct_top(NULL),v4_direct_top(NULL),
    v5_direct_top(NULL),phi1d(NULL),dphi1d(NULL),procneigh_levels(NULL),gcall(NULL),
    gc(NULL),gcall_buf1(NULL),gcall_buf2(NULL),gc_buf1(NULL),gc_buf2(NULL),
    ngc_buf1(NULL),ngc_buf2(NULL),part2grid(NULL),boxlo(NULL)
{
  msmflag = 1;

+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()
{