1 /* -*- c++ -*- ---------------------------------------------------------- 2 LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator 3 https://www.lammps.org/, Sandia National Laboratories 4 Steve Plimpton, sjplimp@sandia.gov 5 6 Copyright (2003) Sandia Corporation. Under the terms of Contract 7 DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains 8 certain rights in this software. This software is distributed under 9 the GNU General Public License. 10 11 See the README file in the top-level LAMMPS directory. 12 ------------------------------------------------------------------------- */ 13 14 #ifndef LMP_COMM_TILED_H 15 #define LMP_COMM_TILED_H 16 17 #include "comm.h" 18 19 namespace LAMMPS_NS { 20 21 class CommTiled : public Comm { 22 public: 23 CommTiled(class LAMMPS *); 24 CommTiled(class LAMMPS *, class Comm *); 25 virtual ~CommTiled(); 26 27 void init(); 28 void setup(); // setup comm pattern 29 virtual void forward_comm(int dummy = 0); // forward comm of atom coords 30 virtual void reverse_comm(); // reverse comm of forces 31 virtual void exchange(); // move atoms to new procs 32 virtual void borders(); // setup list of atoms to comm 33 34 virtual void forward_comm_pair(class Pair *); // forward comm from a Pair 35 virtual void reverse_comm_pair(class Pair *); // reverse comm from a Pair 36 virtual void forward_comm_fix(class Fix *, int size = 0); 37 // forward comm from a Fix 38 virtual void reverse_comm_fix(class Fix *, int size = 0); 39 // reverse comm from a Fix 40 virtual void reverse_comm_fix_variable(class Fix *); 41 // variable size reverse comm from a Fix 42 virtual void forward_comm_compute(class Compute *); // forward from a Compute 43 virtual void reverse_comm_compute(class Compute *); // reverse from a Compute 44 virtual void forward_comm_dump(class Dump *); // forward comm from a Dump 45 virtual void reverse_comm_dump(class Dump *); // reverse comm from a Dump 46 47 virtual void forward_comm_array(int, double **); // forward comm of array 48 virtual int exchange_variable(int, double *, double *&); // exchange on neigh stencil 49 50 void coord2proc_setup(); 51 int coord2proc(double *, int &, int &, int &); 52 53 double memory_usage(); 54 55 private: 56 int nswap; // # of swaps to perform = 2*dim 57 int maxswap; // largest nswap can be = 6 58 59 // forward/reverse comm info, proc lists include self 60 61 int *nsendproc, *nrecvproc; // # of procs to send/recv to/from per swap 62 int *sendother, *recvother; // 1 if send/recv to/from other proc per swap 63 int *sendself; // 1 if send to self per swap 64 int *nprocmax; // current max # of send procs per swap 65 int **sendproc, **recvproc; // procs to send/recv to/from per swap 66 int **sendnum, **recvnum; // # of atoms to send/recv per swap/proc 67 int **size_forward_recv; // # of values to recv in each forward swap/proc 68 int **firstrecv; // where to put 1st recv atom per swap/proc 69 int **size_reverse_send; // # of values to send in each reverse swap/proc 70 int **size_reverse_recv; // # of values to recv in each reverse swap/proc 71 int **forward_recv_offset; // forward comm offsets in buf_recv per swap/proc 72 int **reverse_recv_offset; // reverse comm offsets in buf_recv per swap/proc 73 int ***sendlist; // list of atoms to send per swap/proc 74 int **maxsendlist; // max size of send list per swap/proc 75 int **pbc_flag; // general flag for sending atoms thru PBC 76 int ***pbc; // dimension flags for PBC adjustments 77 78 double ***sendbox; // bounding box of atoms to send per swap/proc 79 80 double **cutghostmulti; // cutghost on a per-collection basis 81 double **cutghostmultiold; // cutghost on a per-type basis 82 double ****sendbox_multi; // bounding box of atoms to send 83 // per swap/proc for multi comm 84 double ****sendbox_multiold; // bounding box of atoms to send 85 // per swap/proc for multi/old comm 86 87 // exchange comm info, proc lists do not include self 88 89 int *nexchproc; // # of procs to send/recv to/from in each dim 90 int *nexchprocmax; // current max # of exch procs for each dim 91 int **exchproc; // procs to exchange with per dim 92 int **exchnum; // # of values received per dim/proc 93 94 double *buf_send; // send buffer for all comm 95 double *buf_recv; // recv buffer for all comm 96 int maxsend, maxrecv; // current size of send/recv buffer 97 int smaxone, rmaxone; // max size in atoms of single borders send/recv 98 int smaxall, rmaxall; // max size in atoms of any borders send/recv 99 // for comm to all procs in one swap 100 101 int maxrequest; // max size of Request vector 102 MPI_Request *requests; 103 104 struct RCBinfo { 105 double mysplit[3][2]; // fractional RCB bounding box for one proc 106 double cutfrac; // fractional position of cut this proc owns 107 int dim; // dimension = 0/1/2 of cut 108 }; 109 110 RCBinfo *rcbinfo; // list of RCB info for all procs 111 112 int noverlap; // # of overlapping procs 113 int maxoverlap; // current max length of overlap 114 int *overlap; // list of overlapping procs 115 116 double *prd; // local ptrs to Domain attributes 117 double *boxlo, *boxhi; 118 double *sublo, *subhi; 119 int dimension; 120 121 // NOTE: init_buffers is called from a constructor and must not be made virtual 122 void init_buffers(); 123 124 // box drop and other functions 125 126 typedef void (CommTiled::*BoxDropPtr)(int, double *, double *, int &); 127 BoxDropPtr box_drop; 128 void box_drop_brick(int, double *, double *, int &); 129 void box_drop_tiled(int, double *, double *, int &); 130 void box_drop_tiled_recurse(double *, double *, int, int, int &); 131 132 typedef void (CommTiled::*BoxOtherPtr)(int, int, int, double *, double *); 133 BoxOtherPtr box_other; 134 void box_other_brick(int, int, int, double *, double *); 135 void box_other_tiled(int, int, int, double *, double *); 136 137 typedef int (CommTiled::*BoxTouchPtr)(int, int, int); 138 BoxTouchPtr box_touch; 139 int box_touch_brick(int, int, int); 140 int box_touch_tiled(int, int, int); 141 142 typedef int (CommTiled::*PointDropPtr)(int, double *); 143 PointDropPtr point_drop; 144 int point_drop_brick(int, double *); 145 int point_drop_tiled(int, double *); 146 int point_drop_tiled_recurse(double *, int, int); 147 int closer_subbox_edge(int, double *); 148 149 void grow_send(int, int); // reallocate send buffer 150 void grow_recv(int); // free/allocate recv buffer 151 void grow_list(int, int, int); // reallocate sendlist for one swap/proc 152 void allocate_swap(int); // allocate swap arrays 153 void grow_swap_send(int, int, int); // grow swap arrays for send and recv 154 void grow_swap_send_multi(int, int); // grow multi swap arrays for send and recv 155 void grow_swap_recv(int, int); 156 void deallocate_swap(int); // deallocate swap arrays 157 }; 158 159 } // namespace LAMMPS_NS 160 161 #endif 162 163 /* ERROR/WARNING messages: 164 165 E: Cannot yet use comm_style tiled with triclinic box 166 167 Self-explanatory. 168 169 E: Communication cutoff for comm_style tiled cannot exceed periodic box length 170 171 Self-explanatory. 172 173 E: Reverse comm fix variable not yet supported by CommTiled 174 175 UNDOCUMENTED 176 177 E: Comm tiled mis-match in box drop brick 178 179 Internal error check in comm_style tiled which should not occur. 180 Contact the developers. 181 182 E: Comm tiled invalid index in box drop brick 183 184 Internal error check in comm_style tiled which should not occur. 185 Contact the developers. 186 187 U: KOKKOS package does not yet support comm_style tiled 188 189 Self-explanatory. 190 191 */ 192