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 * Copyright (c) 2013, by the GROMACS development team, led by
7 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
8 * and including many others, as listed in the AUTHORS file in the
9 * top-level source directory and at http://www.gromacs.org.
11 * GROMACS is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public License
13 * as published by the Free Software Foundation; either version 2.1
14 * of the License, or (at your option) any later version.
16 * GROMACS is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with GROMACS; if not, see
23 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
24 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 * If you want to redistribute modifications to GROMACS, please
27 * consider that scientific software is very special. Version
28 * control is crucial - bugs must be traceable. We will be happy to
29 * consider code for inclusion in the official distribution, but
30 * derived work must not be called official GROMACS. Details are found
31 * in the README & COPYING files - if they are missing, get the
32 * official version at http://www.gromacs.org.
34 * To help us fund GROMACS development, we humbly ask that you cite
35 * the research papers on the package. Check out http://www.gromacs.org.
37 /* This file is completely threadsafe - keep it that way! */
49 #include "gmx_fatal.h"
58 void move_rvecs(const t_commrec *cr, gmx_bool bForward, gmx_bool bSum,
59 rvec vecs[], rvec buf[],
60 int shift, t_nrnb *nrnb)
62 int i, j, j0 = 137, j1 = 391;
65 #define next ((cur + 1) % cr->nnodes)
66 #define prev ((cur - 1 + cr->nnodes) % cr->nnodes)
68 #define HOMENRI(ind, i) ((ind)[(i)+1] - (ind)[(i)])
74 cur = (cr->nodeid + pd_shift(cr)) % cr->nnodes;
82 for (i = 0; (i < shift); i++)
96 for (j = j0; (j < j1); j++)
101 /* Forward pulse around the ring, to increasing NODE number */
107 GMX_RIGHT, vecs[index[cur ]], HOMENRI(index, cur )*DIM,
108 GMX_LEFT, buf [index[prev]], HOMENRI(index, prev)*DIM);
113 GMX_RIGHT, vecs[index[cur ]], HOMENRI(index, cur )*DIM,
114 GMX_LEFT, vecs[index[prev]], HOMENRI(index, prev)*DIM);
116 /* Wait for communication to end */
120 /* Backward pulse around the ring, to decreasing NODE number */
126 GMX_LEFT, vecs[index[cur ]], HOMENRI(index, cur )*DIM,
127 GMX_RIGHT, buf [index[next]], HOMENRI(index, next)*DIM);
132 GMX_LEFT, vecs[index[cur ]], HOMENRI(index, cur )*DIM,
133 GMX_RIGHT, vecs[index[next]], HOMENRI(index, next)*DIM);
135 /* Wait for communication to end */
139 /* Actual summation */
142 for (j = j0; (j < j1); j++)
144 rvec_inc(vecs[j], buf[j]);
159 inc_nrnb(nrnb, eNR_FSUM, nsum);
166 void move_x(const t_commrec *cr,
167 rvec x[], t_nrnb *nrnb)
169 move_rvecs(cr, FALSE, FALSE, x, NULL, pd_shift(cr), nrnb);
170 move_rvecs(cr, TRUE, FALSE, x, NULL, pd_bshift(cr), nrnb);
176 void move_f(const t_commrec *cr,
177 rvec f[], rvec fadd[],
180 move_rvecs(cr, TRUE, TRUE, f, fadd, pd_shift(cr), nrnb);
181 move_rvecs(cr, FALSE, TRUE, f, fadd, pd_bshift(cr), nrnb);
186 void move_cgcm(FILE gmx_unused *log, const t_commrec *cr, rvec cg_cm[])
189 int cur = cr->nodeid;
192 #define next ((cur+1) % cr->nnodes)
194 cgindex = pd_cgindex(cr);
196 for (i = 0; (i < cr->nnodes-1); i++)
198 start = cgindex[cur];
199 nr = cgindex[cur+1] - start;
201 gmx_tx(cr, GMX_LEFT, cg_cm[start], nr*sizeof(cg_cm[0]));
203 fprintf(log, "move_cgcm: TX start=%d, nr=%d\n", start, nr);
205 start = cgindex[next];
206 nr = cgindex[next+1] - start;
208 gmx_rx(cr, GMX_RIGHT, cg_cm[start], nr*sizeof(cg_cm[0]));
210 fprintf(log, "move_cgcm: RX start=%d, nr=%d\n", start, nr);
217 fprintf(debug, "cgcm[0][XX] %f\n", cg_cm[0][XX]);