3 * This source code is part of
7 * GROningen MAchine for Chemical Simulations
10 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
11 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
12 * Copyright (c) 2001-2004, The GROMACS development team,
13 * check out http://www.gromacs.org for more information.
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * If you want to redistribute modifications, please consider that
21 * scientific software is very special. Version control is crucial -
22 * bugs must be traceable. We will be happy to consider code for
23 * inclusion in the official distribution, but derived work must not
24 * be called official GROMACS. Details are found in the README & COPYING
25 * files - if they are missing, get the official version at www.gromacs.org.
27 * To help us fund GROMACS development, we humbly ask that you cite
28 * the papers on the package - you can find them in the top README file.
30 * For more info, check our website at http://www.gromacs.org
33 * GRoups of Organic Molecules in ACtion for Science
42 #include "../thread_mpi/tmpi.h"
43 #include "../thread_mpi/mpi_bindings.h"
45 typedef void* MPI_Comm;
46 typedef void* MPI_Request;
47 typedef void* MPI_Group;
48 #define MPI_COMM_NULL NULL
62 typedef struct gmx_domdec_master *gmx_domdec_master_p_t;
65 int j0; /* j-cell start */
66 int j1; /* j-cell end */
67 int cg1; /* i-charge-group end */
68 int jcg0; /* j-charge-group start */
69 int jcg1; /* j-charge-group end */
70 ivec shift0; /* Minimum shifts to consider */
71 ivec shift1; /* Maximum shifts to consider */
72 } gmx_domdec_ns_ranges_t;
75 /* The number of zones including the home zone */
77 /* The shift of the zones with respect to the home zone */
78 ivec shift[DD_MAXZONE];
79 /* The charge group boundaries for the zones */
80 int cg_range[DD_MAXZONE+1];
81 /* The number of neighbor search zones with i-particles */
83 /* The neighbor search charge group ranges for each i-zone */
84 gmx_domdec_ns_ranges_t izone[DD_MAXIZONE];
87 typedef struct gmx_ga2la *gmx_ga2la_t;
89 typedef struct gmx_reverse_top *gmx_reverse_top_p_t;
91 typedef struct gmx_domdec_constraints *gmx_domdec_constraints_p_t;
93 typedef struct gmx_domdec_specat_comm *gmx_domdec_specat_comm_p_t;
95 typedef struct gmx_domdec_comm *gmx_domdec_comm_p_t;
97 typedef struct gmx_pme_comm_n_box *gmx_pme_comm_n_box_p_t;
104 /* Tells if the box is skewed for each of the three cartesian directions */
107 /* Orthogonal vectors for triclinic cells, Cartesian index */
109 /* Normal vectors for the cells walls */
115 /* these buffers are used as destination buffers if MPI_IN_PLACE isn't
117 int *ibuf; /* for ints */
120 gmx_large_int_t *libuf;
123 float *fbuf; /* for floats */
126 double *dbuf; /* for doubles */
128 } mpi_in_place_buf_t;
132 /* The DD particle-particle nodes only */
133 /* The communication setup within the communicator all
134 * defined in dd->comm in domdec.c
137 MPI_Comm mpi_comm_all;
138 /* Use MPI_Sendrecv communication instead of non-blocking calls */
140 /* The local DD cell index and rank */
145 /* Communication with the PME only nodes */
147 gmx_bool pme_receive_vir_ener;
148 gmx_pme_comm_n_box_p_t cnb;
150 MPI_Request req_pme[4];
153 /* The communication setup, identical for each cell, cartesian index */
156 ivec dim; /* indexed by 0 to ndim */
159 /* PBC from dim 0 to npbcdim */
165 /* Forward and backward neighboring cells, indexed by 0 to ndim */
166 int neighbor[DIM][2];
168 /* Only available on the master node */
169 gmx_domdec_master_p_t ma;
171 /* Are there inter charge group constraints */
172 gmx_bool bInterCGcons;
174 /* Global atom number to interaction list */
175 gmx_reverse_top_p_t reverse_top;
179 /* The number of inter charge-group exclusions */
184 gmx_domdec_specat_comm_p_t vsite_comm;
186 /* Constraint stuff */
187 gmx_domdec_constraints_p_t constraints;
188 gmx_domdec_specat_comm_p_t constraint_comm;
190 /* The local to gobal charge group index and local cg to local atom index */
196 /* Local atom to local cg index, only for special cases */
200 /* The number of home atoms */
202 /* The total number of atoms: home and received zones */
204 /* Index from the local atoms to the global atoms */
208 /* Global atom number to local atom number list */
211 /* Communication stuff */
212 gmx_domdec_comm_p_t comm;
214 /* The partioning count, to keep track of the state */
215 gmx_large_int_t ddp_count;
218 /* gmx_pme_recv_f buffer */
219 int pme_recv_f_alloc;
220 rvec *pme_recv_f_buf;
224 typedef struct gmx_partdec *gmx_partdec_p_t;
229 MPI_Group mpi_group_masters;
230 MPI_Comm mpi_comm_masters;
231 /* these buffers are used as destination buffers if MPI_IN_PLACE isn't
233 mpi_in_place_buf_t *mpb;
236 #define DUTY_PP (1<<0)
237 #define DUTY_PME (1<<1)
249 } gmx_commrec_thread_t;
252 /* The nodeids in one sim are numbered sequentially from 0.
253 * All communication within some simulation should happen
254 * in mpi_comm_mysim, or its subset mpi_comm_mygroup.
256 int sim_nodeid,nnodes,npmenodes;
258 /* thread numbers: */
259 /* Not used yet: int threadid, nthreads; */
260 /* The nodeid in the PP/PME, PP or PME group */
262 MPI_Comm mpi_comm_mysim;
263 MPI_Comm mpi_comm_mygroup;
265 #ifdef GMX_THREAD_SHM_FDECOMP
266 gmx_commrec_thread_t thread;
271 /* For domain decomposition */
274 /* For particle decomposition */
277 /* The duties of this node, see the defines above */
282 /* these buffers are used as destination buffers if MPI_IN_PLACE isn't
284 mpi_in_place_buf_t *mpb;
287 #define MASTERNODE(cr) (((cr)->nodeid == 0) || !PAR(cr))
288 /* #define MASTERTHREAD(cr) ((cr)->threadid == 0) */
289 /* #define MASTER(cr) (MASTERNODE(cr) && MASTERTHREAD(cr)) */
290 #define MASTER(cr) MASTERNODE(cr)
291 #define SIMMASTER(cr) ((MASTER(cr) && ((cr)->duty & DUTY_PP)) || !PAR(cr))
292 #define NODEPAR(cr) ((cr)->nnodes > 1)
293 /* #define THREADPAR(cr) ((cr)->nthreads > 1) */
294 /* #define PAR(cr) (NODEPAR(cr) || THREADPAR(cr)) */
295 #define PAR(cr) NODEPAR(cr)
296 #define RANK(cr,nodeid) (nodeid)
297 #define MASTERRANK(cr) (0)
299 #define DOMAINDECOMP(cr) (((cr)->dd != NULL) && PAR(cr))
300 #define DDMASTER(dd) ((dd)->rank == (dd)->masterrank)
302 #define PARTDECOMP(cr) ((cr)->pd != NULL)
304 #define MULTISIM(cr) ((cr)->ms)
305 #define MSRANK(ms,nodeid) (nodeid)
306 #define MASTERSIM(ms) ((ms)->sim == 0)
308 /* The master of all (the node that prints the remaining run time etc.) */
309 #define MULTIMASTER(cr) (SIMMASTER(cr) && (!MULTISIM(cr) || MASTERSIM((cr)->ms)))