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
56 typedef struct gmx_domdec_master
*gmx_domdec_master_p_t
;
59 int j0
; /* j-cell start */
60 int j1
; /* j-cell end */
61 int cg1
; /* i-charge-group end */
62 int jcg0
; /* j-charge-group start */
63 int jcg1
; /* j-charge-group end */
64 ivec shift0
; /* Minimum shifts to consider */
65 ivec shift1
; /* Maximum shifts to consider */
66 } gmx_domdec_ns_ranges_t
;
69 /* The number of zones including the home zone */
71 /* The shift of the zones with respect to the home zone */
72 ivec shift
[DD_MAXZONE
];
73 /* The charge group boundaries for the zones */
74 int cg_range
[DD_MAXZONE
+1];
75 /* The number of neighbor search zones with i-particles */
77 /* The neighbor search charge group ranges for each i-zone */
78 gmx_domdec_ns_ranges_t izone
[DD_MAXIZONE
];
81 typedef struct gmx_ga2la
*gmx_ga2la_t
;
83 typedef struct gmx_reverse_top
*gmx_reverse_top_p_t
;
85 typedef struct gmx_domdec_constraints
*gmx_domdec_constraints_p_t
;
87 typedef struct gmx_domdec_specat_comm
*gmx_domdec_specat_comm_p_t
;
89 typedef struct gmx_domdec_comm
*gmx_domdec_comm_p_t
;
91 typedef struct gmx_pme_comm_n_box
*gmx_pme_comm_n_box_p_t
;
98 /* Tells if the box is skewed for each of the three cartesian directions */
101 /* Orthogonal vectors for triclinic cells, Cartesian index */
103 /* Normal vectors for the cells walls */
108 #if defined(GMX_MPI) && !defined(GMX_THREADS) && !defined(MPI_IN_PLACE_EXISTS)
110 /* these buffers are used as destination buffers if MPI_IN_PLACE isn't
112 float *ibuf
; /* for ints */
115 float *fbuf
; /* for floats */
118 double *dbuf
; /* for doubles */
120 } mpi_in_place_buf_t
;
125 /* The DD particle-particle nodes only */
126 /* The communication setup within the communicator all
127 * defined in dd->comm in domdec.c
131 MPI_Comm mpi_comm_all
;
133 /* Use MPI_Sendrecv communication instead of non-blocking calls */
135 /* The local DD cell index and rank */
140 /* Communication with the PME only nodes */
142 bool pme_receive_vir_ener
;
143 gmx_pme_comm_n_box_p_t cnb
;
146 MPI_Request req_pme
[4];
150 /* The communication setup, identical for each cell, cartesian index */
153 ivec dim
; /* indexed by 0 to ndim */
156 /* PBC from dim 0 to npbcdim */
162 /* Forward and backward neighboring cells, indexed by 0 to ndim */
163 int neighbor
[DIM
][2];
165 /* Only available on the master node */
166 gmx_domdec_master_p_t ma
;
168 /* Are there inter charge group constraints */
171 /* Global atom number to interaction list */
172 gmx_reverse_top_p_t reverse_top
;
176 /* The number of inter charge-group exclusions */
181 gmx_domdec_specat_comm_p_t vsite_comm
;
183 /* Constraint stuff */
184 gmx_domdec_constraints_p_t constraints
;
185 gmx_domdec_specat_comm_p_t constraint_comm
;
187 /* The local to gobal charge group index and local cg to local atom index */
193 /* Local atom to local cg index, only for special cases */
197 /* The number of home atoms */
199 /* The total number of atoms: home and received zones */
201 /* Index from the local atoms to the global atoms */
205 /* Global atom number to local atom number list */
208 /* Communication stuff */
209 gmx_domdec_comm_p_t comm
;
211 /* The partioning count, to keep track of the state */
212 gmx_large_int_t ddp_count
;
215 /* gmx_pme_recv_f buffer */
216 int pme_recv_f_alloc
;
217 rvec
*pme_recv_f_buf
;
221 typedef struct gmx_partdec
*gmx_partdec_p_t
;
227 MPI_Group mpi_group_masters
;
228 MPI_Comm mpi_comm_masters
;
229 #if !defined(GMX_THREADS) && !defined(MPI_IN_PLACE_EXISTS)
230 /* these buffers are used as destination buffers if MPI_IN_PLACE isn't
232 mpi_in_place_buf_t
*mpb
;
237 #define DUTY_PP (1<<0)
238 #define DUTY_PME (1<<1)
252 } gmx_commrec_thread_t
;
255 /* The nodids in one sim are numbered sequentially from 0.
256 * All communication within some simulation should happen
257 * in mpi_comm_mysim, or its subset mpi_comm_mygroup.
259 int sim_nodeid
,nnodes
,npmenodes
;
260 int threadid
,nthreads
;
261 /* The nodeid in the PP/PME, PP or PME group */
264 MPI_Comm mpi_comm_mysim
;
265 MPI_Comm mpi_comm_mygroup
;
268 #ifdef GMX_THREAD_SHM_FDECOMP
269 gmx_commrec_thread_t thread
;
274 /* For domain decomposition */
277 /* For particle decomposition */
280 /* The duties of this node, see the defines above */
285 #if defined(GMX_MPI) && !defined(GMX_THREADS) && !defined(MPI_IN_PLACE_EXISTS)
286 /* these buffers are used as destination buffers if MPI_IN_PLACE isn't
288 mpi_in_place_buf_t
*mpb
;
292 #define MASTERNODE(cr) ((cr)->nodeid == 0)
293 #define MASTERTHREAD(cr) ((cr)->threadid == 0)
294 #define MASTER(cr) (MASTERNODE(cr) && MASTERTHREAD(cr))
295 #define SIMMASTER(cr) (MASTER(cr) && ((cr)->duty & DUTY_PP))
296 #define NODEPAR(cr) ((cr)->nnodes > 1)
297 #define THREADPAR(cr) ((cr)->nthreads > 1)
298 #define PAR(cr) (NODEPAR(cr) || THREADPAR(cr))
299 #define RANK(cr,nodeid) (nodeid)
300 #define MASTERRANK(cr) (0)
302 #define DOMAINDECOMP(cr) ((cr)->dd != NULL)
303 #define DDMASTER(dd) ((dd)->rank == (dd)->masterrank)
305 #define PARTDECOMP(cr) ((cr)->pd != NULL)
307 #define MULTISIM(cr) ((cr)->ms)
308 #define MSRANK(ms,nodeid) (nodeid)
309 #define MASTERSIM(ms) ((ms)->sim == 0)
311 /* The master of all (the node that prints the remaining run time etc.) */
312 #define MULTIMASTER(cr) (SIMMASTER(cr) && (!MULTISIM(cr) || MASTERSIM((cr)->ms)))