2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5 * Copyright (c) 2001-2004, The GROMACS development team,
6 * check out http://www.gromacs.org for more information.
7 * Copyright (c) 2012,2013, by the GROMACS development team, led by
8 * David van der Spoel, Berk Hess, Erik Lindahl, and including many
9 * others, as listed in the AUTHORS file in the top-level source
10 * directory and at http://www.gromacs.org.
12 * GROMACS is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public License
14 * as published by the Free Software Foundation; either version 2.1
15 * of the License, or (at your option) any later version.
17 * GROMACS is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with GROMACS; if not, see
24 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
25 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 * If you want to redistribute modifications to GROMACS, please
28 * consider that scientific software is very special. Version
29 * control is crucial - bugs must be traceable. We will be happy to
30 * consider code for inclusion in the official distribution, but
31 * derived work must not be called official GROMACS. Details are found
32 * in the README & COPYING files - if they are missing, get the
33 * official version at http://www.gromacs.org.
35 * To help us fund GROMACS development, we humbly ask that you cite
36 * the research papers on the package. Check out http://www.gromacs.org.
45 #include "../thread_mpi/tmpi.h"
46 #include "../thread_mpi/mpi_bindings.h"
48 typedef void* MPI_Comm
;
49 typedef void* MPI_Request
;
50 typedef void* MPI_Group
;
64 typedef struct gmx_domdec_master
*gmx_domdec_master_p_t
;
67 int j0
; /* j-zone start */
68 int j1
; /* j-zone end */
69 int cg1
; /* i-charge-group end */
70 int jcg0
; /* j-charge-group start */
71 int jcg1
; /* j-charge-group end */
72 ivec shift0
; /* Minimum shifts to consider */
73 ivec shift1
; /* Maximum shifts to consider */
74 } gmx_domdec_ns_ranges_t
;
77 rvec x0
; /* Zone lower corner in triclinic coordinates */
78 rvec x1
; /* Zone upper corner in triclinic coordinates */
79 rvec bb_x0
; /* Zone bounding box lower corner in Cartesian coords */
80 rvec bb_x1
; /* Zone bounding box upper corner in Cartesian coords */
81 } gmx_domdec_zone_size_t
;
84 /* The number of zones including the home zone */
86 /* The shift of the zones with respect to the home zone */
87 ivec shift
[DD_MAXZONE
];
88 /* The charge group boundaries for the zones */
89 int cg_range
[DD_MAXZONE
+1];
90 /* The number of neighbor search zones with i-particles */
92 /* The neighbor search charge group ranges for each i-zone */
93 gmx_domdec_ns_ranges_t izone
[DD_MAXIZONE
];
94 /* Boundaries of the zones */
95 gmx_domdec_zone_size_t size
[DD_MAXZONE
];
96 /* The cg density of the home zone */
100 typedef struct gmx_ga2la
*gmx_ga2la_t
;
102 typedef struct gmx_hash
*gmx_hash_t
;
104 typedef struct gmx_reverse_top
*gmx_reverse_top_p_t
;
106 typedef struct gmx_domdec_constraints
*gmx_domdec_constraints_p_t
;
108 typedef struct gmx_domdec_specat_comm
*gmx_domdec_specat_comm_p_t
;
110 typedef struct gmx_domdec_comm
*gmx_domdec_comm_p_t
;
112 typedef struct gmx_pme_comm_n_box
*gmx_pme_comm_n_box_p_t
;
119 /* Tells if the box is skewed for each of the three cartesian directions */
122 /* Orthogonal vectors for triclinic cells, Cartesian index */
124 /* Normal vectors for the cells walls */
130 /* these buffers are used as destination buffers if MPI_IN_PLACE isn't
132 int *ibuf
; /* for ints */
135 gmx_large_int_t
*libuf
;
138 float *fbuf
; /* for floats */
141 double *dbuf
; /* for doubles */
143 } mpi_in_place_buf_t
;
147 /* The DD particle-particle nodes only */
148 /* The communication setup within the communicator all
149 * defined in dd->comm in domdec.c
152 MPI_Comm mpi_comm_all
;
153 /* Use MPI_Sendrecv communication instead of non-blocking calls */
155 /* The local DD cell index and rank */
160 /* Communication with the PME only nodes */
162 gmx_bool pme_receive_vir_ener
;
163 gmx_pme_comm_n_box_p_t cnb
;
165 MPI_Request req_pme
[4];
168 /* The communication setup, identical for each cell, cartesian index */
171 ivec dim
; /* indexed by 0 to ndim */
174 /* PBC from dim 0 to npbcdim */
180 /* Forward and backward neighboring cells, indexed by 0 to ndim */
181 int neighbor
[DIM
][2];
183 /* Only available on the master node */
184 gmx_domdec_master_p_t ma
;
186 /* Are there inter charge group constraints */
187 gmx_bool bInterCGcons
;
188 gmx_bool bInterCGsettles
;
190 /* Global atom number to interaction list */
191 gmx_reverse_top_p_t reverse_top
;
195 /* The number of inter charge-group exclusions */
199 gmx_hash_t ga2la_vsite
;
200 gmx_domdec_specat_comm_p_t vsite_comm
;
202 /* Constraint stuff */
203 gmx_domdec_constraints_p_t constraints
;
204 gmx_domdec_specat_comm_p_t constraint_comm
;
206 /* The local to gobal charge group index and local cg to local atom index */
212 /* Local atom to local cg index, only for special cases */
216 /* The number of home atoms */
218 /* The total number of atoms: home and received zones */
220 /* Index from the local atoms to the global atoms */
224 /* Global atom number to local atom number list */
227 /* Communication stuff */
228 gmx_domdec_comm_p_t comm
;
230 /* The partioning count, to keep track of the state */
231 gmx_large_int_t ddp_count
;
234 /* gmx_pme_recv_f buffer */
235 int pme_recv_f_alloc
;
236 rvec
*pme_recv_f_buf
;
240 typedef struct gmx_partdec
*gmx_partdec_p_t
;
245 MPI_Group mpi_group_masters
;
246 MPI_Comm mpi_comm_masters
;
247 /* these buffers are used as destination buffers if MPI_IN_PLACE isn't
249 mpi_in_place_buf_t
*mpb
;
252 #define DUTY_PP (1<<0)
253 #define DUTY_PME (1<<1)
264 /* The nodeids in one sim are numbered sequentially from 0.
265 * All communication within some simulation should happen
266 * in mpi_comm_mysim, or its subset mpi_comm_mygroup.
268 int sim_nodeid
, nnodes
, npmenodes
;
270 /* thread numbers: */
271 /* Not used yet: int threadid, nthreads; */
272 /* The nodeid in the PP/PME, PP or PME group */
274 MPI_Comm mpi_comm_mysim
;
275 MPI_Comm mpi_comm_mygroup
;
277 /* MPI ranks within a physical node for hardware access */
278 int nrank_intranode
; /* nr of ranks on this physical node */
279 int rank_intranode
; /* our rank on this physical node */
280 int nrank_pp_intranode
; /* as nrank_intranode, for particle-particle only */
281 int rank_pp_intranode
; /* as rank_intranode, for particle-particle only */
285 /* For domain decomposition */
288 /* For particle decomposition */
291 /* The duties of this node, see the defines above */
296 /* these buffers are used as destination buffers if MPI_IN_PLACE isn't
298 mpi_in_place_buf_t
*mpb
;
301 #define MASTERNODE(cr) (((cr)->nodeid == 0) || !PAR(cr))
302 /* #define MASTERTHREAD(cr) ((cr)->threadid == 0) */
303 /* #define MASTER(cr) (MASTERNODE(cr) && MASTERTHREAD(cr)) */
304 #define MASTER(cr) MASTERNODE(cr)
305 #define SIMMASTER(cr) ((MASTER(cr) && ((cr)->duty & DUTY_PP)) || !PAR(cr))
306 #define NODEPAR(cr) ((cr)->nnodes > 1)
307 /* #define THREADPAR(cr) ((cr)->nthreads > 1) */
308 /* #define PAR(cr) (NODEPAR(cr) || THREADPAR(cr)) */
309 #define PAR(cr) NODEPAR(cr)
310 #define RANK(cr, nodeid) (nodeid)
311 #define MASTERRANK(cr) (0)
313 #define DOMAINDECOMP(cr) (((cr)->dd != NULL) && PAR(cr))
314 #define DDMASTER(dd) ((dd)->rank == (dd)->masterrank)
316 #define PARTDECOMP(cr) ((cr)->pd != NULL)
318 #define MULTISIM(cr) ((cr)->ms)
319 #define MSRANK(ms, nodeid) (nodeid)
320 #define MASTERSIM(ms) ((ms)->sim == 0)
322 /* The master of all (the node that prints the remaining run time etc.) */
323 #define MULTIMASTER(cr) (SIMMASTER(cr) && (!MULTISIM(cr) || MASTERSIM((cr)->ms)))