Unverified Commit b29a5558 authored by Axel Kohlmeyer's avatar Axel Kohlmeyer Committed by GitHub
Browse files

Merge pull request #717 from cjknight/comm-nprocs-opt

added comm duplicate hint for final remap of pppm
parents 23f6f5ea 4161202e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -839,7 +839,7 @@ void PPPM::allocate()
  remap = new Remap(lmp,world,
                    nxlo_in,nxhi_in,nylo_in,nyhi_in,nzlo_in,nzhi_in,
                    nxlo_fft,nxhi_fft,nylo_fft,nyhi_fft,nzlo_fft,nzhi_fft,
                    1,0,0,FFT_PRECISION,collective_flag);
                    1,0,0,FFT_PRECISION,collective_flag,1);

  // create ghost grid object for rho and electric field communication

+143 −125
Original line number Diff line number Diff line
@@ -234,7 +234,8 @@ struct remap_plan_3d *remap_3d_create_plan(
  int in_klo, int in_khi,
  int out_ilo, int out_ihi, int out_jlo, int out_jhi,
  int out_klo, int out_khi,
  int nqty, int permute, int memory, int precision, int usecollective)
  int nqty, int permute, int memory, int precision, int usecollective,
  int hint_comm_dup)

{

@@ -455,6 +456,17 @@ struct remap_plan_3d *remap_3d_create_plan(
  // create sub-comm rank list

  if (plan->usecollective) {

    if (hint_comm_dup) {

      int *commringlist = (int *) malloc(nprocs*sizeof(int));
      for (int i=0; i<nprocs; ++i) commringlist[i] = i;
      
      plan->commringlen  = nprocs;
      plan->commringlist = commringlist;

    } else {

      plan->commringlist = NULL;

      // merge recv and send rank lists
@@ -586,6 +598,8 @@ struct remap_plan_3d *remap_3d_create_plan(
      plan->commringlist = commringlist;
    }
    
  }

  // plan->nrecv = # of recvs not including self
  // for collectives include self in the nsend list

@@ -638,12 +652,16 @@ struct remap_plan_3d *remap_3d_create_plan(
  // ranks from the commringlist

  if ((plan->usecollective && (plan->commringlen > 0))) {

    if (hint_comm_dup) MPI_Comm_dup(comm, &plan->comm);
    else {
      MPI_Group orig_group, new_group;
      MPI_Comm_group(comm, &orig_group);
      MPI_Group_incl(orig_group, plan->commringlen,
		     plan->commringlist, &new_group);
      MPI_Comm_create(comm, new_group, &plan->comm);
    }
  }

  // if using collective and the comm ring list is empty create
  // a communicator for the plan with an empty group
+2 −1
Original line number Diff line number Diff line
@@ -64,7 +64,8 @@ void remap_3d(FFT_SCALAR *, FFT_SCALAR *, FFT_SCALAR *, struct remap_plan_3d *);
struct remap_plan_3d *remap_3d_create_plan(MPI_Comm,
                                           int, int, int, int, int, int,
                                           int, int, int, int, int, int,
                                           int, int, int, int, int);
                                           int, int, int, int, int, 
					   int hint_comm_dup = 0);
void remap_3d_destroy_plan(struct remap_plan_3d *);
int remap_3d_collide(struct extent_3d *,
                     struct extent_3d *, struct extent_3d *);
+4 −2
Original line number Diff line number Diff line
@@ -25,12 +25,14 @@ Remap::Remap(LAMMPS *lmp, MPI_Comm comm,
             int out_ilo, int out_ihi, int out_jlo, int out_jhi,
             int out_klo, int out_khi,
             int nqty, int permute, int memory,
             int precision, int usecollective) : Pointers(lmp)
             int precision, int usecollective,
	     int hint_comm_dup) : Pointers(lmp)
{
  plan = remap_3d_create_plan(comm,
                              in_ilo,in_ihi,in_jlo,in_jhi,in_klo,in_khi,
                              out_ilo,out_ihi,out_jlo,out_jhi,out_klo,out_khi,
                              nqty,permute,memory,precision,usecollective);
                              nqty,permute,memory,precision,usecollective,
			      hint_comm_dup);
  if (plan == NULL) error->one(FLERR,"Could not create 3d remap plan");
}

+2 −1
Original line number Diff line number Diff line
@@ -22,7 +22,8 @@ namespace LAMMPS_NS {
class Remap : protected Pointers {
 public:
  Remap(class LAMMPS *, MPI_Comm,int,int,int,int,int,int,
        int,int,int,int,int,int,int,int,int,int,int);
        int,int,int,int,int,int,int,int,int,int,int,
	int hint_comm_dup = 0);
  ~Remap();
  void perform(FFT_SCALAR *, FFT_SCALAR *, FFT_SCALAR *);