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_IRREGULAR_H
15 #define LMP_IRREGULAR_H
16 
17 #include "pointers.h"
18 
19 namespace LAMMPS_NS {
20 
21 class Irregular : protected Pointers {
22  public:
23 #if defined(LMP_QSORT)
24   // static variable across all Irregular objects, for qsort callback
25 
26   static int *proc_recv_copy;
27 #endif
28 
29   Irregular(class LAMMPS *);
30   ~Irregular();
31   void migrate_atoms(int sortflag = 0, int preassign = 0, int *procassign = nullptr);
32   int migrate_check();
33   int create_data(int, int *, int sortflag = 0);
34   int create_data_grouped(int, int *, int sortflag = 0);
35   void exchange_data(char *, int, char *);
36   void destroy_data();
37   double memory_usage();
38 
39  private:
40   int me, nprocs;
41   int triclinic;
42   int map_style;
43 
44   int bufextra;                   // augment send buf size for a migrating atom
45   int maxsend, maxrecv;           // size of buf send/recv in # of doubles
46   double *buf_send, *buf_recv;    // bufs used in migrate_atoms
47   int maxdbuf;                    // size of double buf in bytes
48   double *dbuf;                   // double buf for largest single atom send
49   int maxbuf;                     // size of char buf in bytes
50   char *buf;                      // char buf for largest single data send
51   int maxindex;                   // combined size of index_send + index_self
52 
53   int *mproclist, *msizes;    // persistent vectors in migrate_atoms
54   int maxlocal;               // allocated size of mproclist and msizes
55 
56   int *work1, *work2;    // work vectors
57 
58   // plan params for irregular communication of atoms or datums
59   // no params refer to atoms/data copied to self
60 
61   int nsend_proc;          // # of messages to send
62   int nrecv_proc;          // # of messages to recv
63   int sendmax_proc;        // # of doubles/datums in largest send message
64   int *proc_send;          // list of procs to send to
65   int *num_send;           // # of atoms/datums to send to each proc
66   int *index_send;         // list of which atoms/datums to send to each proc
67   int *proc_recv;          // list of procs to recv from
68   MPI_Request *request;    // MPI requests for posted recvs
69   MPI_Status *status;      // MPI statuses for WaitAll
70 
71   // extra plan params plan for irregular communication of atoms
72   // no params refer to atoms copied to self
73 
74   int *length_send;    // # of doubles to send to each proc
75   int *length_recv;    // # of doubles to recv from each proc
76   int *offset_send;    // where each atom starts in send buffer
77 
78   // extra plan params plan for irregular communication of datums
79   // 2 self params refer to data copied to self
80 
81   int *num_recv;      // # of datums to recv from each proc
82   int num_self;       // # of datums to copy to self
83   int *index_self;    // list of which datums to copy to self
84 
85   // private methods
86 
87   int create_atom(int, int *, int *, int);
88   void exchange_atom(double *, int *, double *);
89   void destroy_atom();
90 
91   int binary(double, int, double *);
92 
93   void init_exchange();        // reset bufxtra
94   void grow_send(int, int);    // reallocate send buffer
95   void grow_recv(int);         // free/allocate recv buffer
96 };
97 
98 }    // namespace LAMMPS_NS
99 
100 #endif
101 
102 /* ERROR/WARNING messages:
103 
104 */
105