*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
* the research papers on the package. Check out http://www.gromacs.org.
*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "gmxpre.h"
+#include "config.h"
+#include <math.h>
#include <stdio.h>
#include <string.h>
-#include <math.h>
-#include "typedefs.h"
-#include "smalloc.h"
-#include "gmx_fatal.h"
-#include "vec.h"
-#include "pme.h"
-#include "network.h"
-#include "domdec.h"
-#include "sighandler.h"
+#include "gromacs/legacyheaders/domdec.h"
+#include "gromacs/legacyheaders/network.h"
+#include "gromacs/legacyheaders/pme.h"
+#include "gromacs/legacyheaders/sighandler.h"
+#include "gromacs/legacyheaders/typedefs.h"
+#include "gromacs/legacyheaders/types/commrec.h"
+#include "gromacs/math/vec.h"
+#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/gmxmpi.h"
+#include "gromacs/utility/smalloc.h"
enum {
- eCommType_ChargeA, eCommType_ChargeB, eCommType_C6A, eCommType_C6B,
+ eCommType_ChargeA, eCommType_ChargeB, eCommType_SQRTC6A, eCommType_SQRTC6B,
eCommType_SigmaA, eCommType_SigmaB, eCommType_NR, eCommType_COORD,
eCommType_CNB
};
#define PP_PME_CHARGE (1<<0)
#define PP_PME_CHARGEB (1<<1)
-#define PP_PME_C6 (1<<2)
-#define PP_PME_C6B (1<<3)
+#define PP_PME_SQRTC6 (1<<2)
+#define PP_PME_SQRTC6B (1<<3)
#define PP_PME_SIGMA (1<<4)
#define PP_PME_SIGMAB (1<<5)
#define PP_PME_COORD (1<<6)
int flags_charge; /* The flags sent along with the last charges */
real *chargeA;
real *chargeB;
- real *c6A;
- real *c6B;
+ real *sqrt_c6A;
+ real *sqrt_c6B;
real *sigmaA;
real *sigmaB;
rvec *x;
/* This should be faster with a real non-blocking MPI implementation */
/* #define GMX_PME_DELAYED_WAIT */
-static void gmx_pme_send_params_coords_wait(gmx_domdec_t gmx_unused *dd)
+static void gmx_pme_send_coeffs_coords_wait(gmx_domdec_t gmx_unused *dd)
{
#ifdef GMX_MPI
if (dd->nreq_pme)
#endif
}
-static void gmx_pme_send_params_coords(t_commrec *cr, int flags,
+static void gmx_pme_send_coeffs_coords(t_commrec *cr, int flags,
real gmx_unused *chargeA, real gmx_unused *chargeB,
real gmx_unused *c6A, real gmx_unused *c6B,
real gmx_unused *sigmaA, real gmx_unused *sigmaB,
if (debug)
{
- fprintf(debug, "PP node %d sending to PME node %d: %d%s%s\n",
+ fprintf(debug, "PP rank %d sending to PME rank %d: %d%s%s%s%s\n",
cr->sim_nodeid, dd->pme_nodeid, n,
flags & PP_PME_CHARGE ? " charges" : "",
+ flags & PP_PME_SQRTC6 ? " sqrtC6" : "",
+ flags & PP_PME_SIGMA ? " sigma" : "",
flags & PP_PME_COORD ? " coordinates" : "");
}
#ifdef GMX_PME_DELAYED_WAIT
/* When can not use cnb until pending communication has finished */
- gmx_pme_send_params_coords_wait(dd);
+ gmx_pme_send_coeffs_coords_wait(dd);
#endif
if (dd->pme_receive_vir_ener)
&dd->req_pme[dd->nreq_pme++]);
#endif
}
- else if (flags & (PP_PME_CHARGE | PP_PME_C6 | PP_PME_SIGMA))
+ else if (flags & (PP_PME_CHARGE | PP_PME_SQRTC6 | PP_PME_SIGMA))
{
#ifdef GMX_MPI
/* Communicate only the number of atoms */
dd->pme_nodeid, eCommType_ChargeB, cr->mpi_comm_mysim,
&dd->req_pme[dd->nreq_pme++]);
}
- if (flags & PP_PME_C6)
+ if (flags & PP_PME_SQRTC6)
{
MPI_Isend(c6A, n*sizeof(real), MPI_BYTE,
- dd->pme_nodeid, eCommType_C6A, cr->mpi_comm_mysim,
+ dd->pme_nodeid, eCommType_SQRTC6A, cr->mpi_comm_mysim,
&dd->req_pme[dd->nreq_pme++]);
}
- if (flags & PP_PME_C6B)
+ if (flags & PP_PME_SQRTC6B)
{
MPI_Isend(c6B, n*sizeof(real), MPI_BYTE,
- dd->pme_nodeid, eCommType_C6B, cr->mpi_comm_mysim,
+ dd->pme_nodeid, eCommType_SQRTC6B, cr->mpi_comm_mysim,
&dd->req_pme[dd->nreq_pme++]);
}
if (flags & PP_PME_SIGMA)
/* We can skip this wait as we are sure x and q will not be modified
* before the next call to gmx_pme_send_x_q or gmx_pme_receive_f.
*/
- gmx_pme_send_params_coords_wait(dd);
+ gmx_pme_send_coeffs_coords_wait(dd);
#endif
#endif
}
void gmx_pme_send_parameters(t_commrec *cr,
+ const interaction_const_t *ic,
gmx_bool bFreeEnergy_q, gmx_bool bFreeEnergy_lj,
real *chargeA, real *chargeB,
- real *c6A, real *c6B, real *sigmaA, real *sigmaB,
+ real *sqrt_c6A, real *sqrt_c6B,
+ real *sigmaA, real *sigmaB,
int maxshift_x, int maxshift_y)
{
int flags;
- flags = PP_PME_CHARGE | PP_PME_C6 | PP_PME_SIGMA;
+ flags = 0;
+ if (EEL_PME(ic->eeltype))
+ {
+ flags |= PP_PME_CHARGE;
+ }
+ if (EVDW_PME(ic->vdwtype))
+ {
+ flags |= (PP_PME_SQRTC6 | PP_PME_SIGMA);
+ }
if (bFreeEnergy_q || bFreeEnergy_lj)
{
/* Assumes that the B state flags are in the bits just above
flags |= (flags << 1);
}
- gmx_pme_send_params_coords(cr, flags, chargeA, chargeB, c6A, c6B, sigmaA, sigmaB,
+ gmx_pme_send_coeffs_coords(cr, flags,
+ chargeA, chargeB,
+ sqrt_c6A, sqrt_c6B, sigmaA, sigmaB,
NULL, NULL, 0, 0, maxshift_x, maxshift_y, -1);
}
{
flags |= PP_PME_ENER_VIR;
}
- gmx_pme_send_params_coords(cr, flags, NULL, NULL, NULL, NULL, NULL, NULL,
+ gmx_pme_send_coeffs_coords(cr, flags, NULL, NULL, NULL, NULL, NULL, NULL,
box, x, lambda_q, lambda_lj, 0, 0, step);
}
flags = PP_PME_FINISH;
- gmx_pme_send_params_coords(cr, flags, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0, -1);
+ gmx_pme_send_coeffs_coords(cr, flags, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0, -1);
}
void gmx_pme_send_switchgrid(t_commrec gmx_unused *cr,
#endif
}
-int gmx_pme_recv_params_coords(struct gmx_pme_pp *pme_pp,
+int gmx_pme_recv_coeffs_coords(struct gmx_pme_pp *pme_pp,
int *natoms,
real **chargeA,
real **chargeB,
- real **c6A,
- real **c6B,
+ real **sqrt_c6A,
+ real **sqrt_c6B,
real **sigmaA,
real **sigmaB,
matrix gmx_unused box,
if (debug)
{
- fprintf(debug, "PME only node receiving:%s%s%s%s%s\n",
+ fprintf(debug, "PME only rank receiving:%s%s%s%s%s\n",
(cnb.flags & PP_PME_CHARGE) ? " charges" : "",
(cnb.flags & PP_PME_COORD ) ? " coordinates" : "",
(cnb.flags & PP_PME_FINISH) ? " finish" : "",
return pmerecvqxRESETCOUNTERS;
}
- if (cnb.flags & (PP_PME_CHARGE | PP_PME_C6 | PP_PME_SIGMA))
+ if (cnb.flags & (PP_PME_CHARGE | PP_PME_SQRTC6 | PP_PME_SIGMA))
{
/* Receive the send counts from the other PP nodes */
for (sender = 0; sender < pme_pp->nnode; sender++)
{
srenew(pme_pp->chargeB, pme_pp->nalloc);
}
- if (cnb.flags & PP_PME_C6)
+ if (cnb.flags & PP_PME_SQRTC6)
{
- srenew(pme_pp->c6A, pme_pp->nalloc);
+ srenew(pme_pp->sqrt_c6A, pme_pp->nalloc);
}
- if (cnb.flags & PP_PME_C6B)
+ if (cnb.flags & PP_PME_SQRTC6B)
{
- srenew(pme_pp->c6B, pme_pp->nalloc);
+ srenew(pme_pp->sqrt_c6B, pme_pp->nalloc);
}
if (cnb.flags & PP_PME_SIGMA)
{
}
switch (q)
{
- case eCommType_ChargeA: charge_pp = pme_pp->chargeA; break;
- case eCommType_ChargeB: charge_pp = pme_pp->chargeB; break;
- case eCommType_C6A: charge_pp = pme_pp->c6A; break;
- case eCommType_C6B: charge_pp = pme_pp->c6B; break;
- case eCommType_SigmaA: charge_pp = pme_pp->sigmaA; break;
- case eCommType_SigmaB: charge_pp = pme_pp->sigmaB; break;
+ case eCommType_ChargeA: charge_pp = pme_pp->chargeA; break;
+ case eCommType_ChargeB: charge_pp = pme_pp->chargeB; break;
+ case eCommType_SQRTC6A: charge_pp = pme_pp->sqrt_c6A; break;
+ case eCommType_SQRTC6B: charge_pp = pme_pp->sqrt_c6B; break;
+ case eCommType_SigmaA: charge_pp = pme_pp->sigmaA; break;
+ case eCommType_SigmaB: charge_pp = pme_pp->sigmaB; break;
default: gmx_incons("Wrong eCommType");
}
nat = 0;
nat += pme_pp->nat[sender];
if (debug)
{
- fprintf(debug, "Received from PP node %d: %d "
- "charges\n",
- pme_pp->node[sender], pme_pp->nat[sender]);
+ fprintf(debug, "Received from PP rank %d: %d %s\n",
+ pme_pp->node[sender], pme_pp->nat[sender],
+ (q == eCommType_ChargeA ||
+ q == eCommType_ChargeB) ? "charges" : "params");
}
}
}
if (cnb.flags & PP_PME_COORD)
{
- if (!(pme_pp->flags_charge & (PP_PME_CHARGE | PP_PME_C6)))
+ if (!(pme_pp->flags_charge & (PP_PME_CHARGE | PP_PME_SQRTC6)))
{
- gmx_incons("PME-only node received coordinates before charges and/or C6-values"
+ gmx_incons("PME-only rank received coordinates before charges and/or C6-values"
);
}
/* The box, FE flag and lambda are sent along with the coordinates
* */
copy_mat(cnb.box, box);
- *bFreeEnergy_q = (cnb.flags & PP_PME_FEP_Q);
- *bFreeEnergy_lj = (cnb.flags & PP_PME_FEP_LJ);
+ *bFreeEnergy_q = ((cnb.flags & GMX_PME_DO_COULOMB) &&
+ (cnb.flags & PP_PME_FEP_Q));
+ *bFreeEnergy_lj = ((cnb.flags & GMX_PME_DO_LJ) &&
+ (cnb.flags & PP_PME_FEP_LJ));
*lambda_q = cnb.lambda_q;
*lambda_lj = cnb.lambda_lj;
*bEnerVir = (cnb.flags & PP_PME_ENER_VIR);
if (*bFreeEnergy_q && !(pme_pp->flags_charge & PP_PME_CHARGEB))
{
- gmx_incons("PME-only node received free energy request, but "
+ gmx_incons("PME-only rank received free energy request, but "
"did not receive B-state charges");
}
- if (*bFreeEnergy_lj && !(pme_pp->flags_charge & PP_PME_C6B))
+ if (*bFreeEnergy_lj && !(pme_pp->flags_charge & PP_PME_SQRTC6B))
{
- gmx_incons("PME-only node received free energy request, but "
+ gmx_incons("PME-only rank received free energy request, but "
"did not receive B-state C6-values");
}
nat += pme_pp->nat[sender];
if (debug)
{
- fprintf(debug, "Received from PP node %d: %d "
+ fprintf(debug, "Received from PP rank %d: %d "
"coordinates\n",
pme_pp->node[sender], pme_pp->nat[sender]);
}
*step = cnb.step;
#endif
- *natoms = nat;
- *chargeA = pme_pp->chargeA;
- *chargeB = pme_pp->chargeB;
- *c6A = pme_pp->c6A;
- *c6B = pme_pp->c6B;
- *sigmaA = pme_pp->sigmaA;
- *sigmaB = pme_pp->sigmaB;
- *x = pme_pp->x;
- *f = pme_pp->f;
+ *natoms = nat;
+ *chargeA = pme_pp->chargeA;
+ *chargeB = pme_pp->chargeB;
+ *sqrt_c6A = pme_pp->sqrt_c6A;
+ *sqrt_c6B = pme_pp->sqrt_c6B;
+ *sigmaA = pme_pp->sigmaA;
+ *sigmaB = pme_pp->sigmaB;
+ *x = pme_pp->x;
+ *f = pme_pp->f;
return ((cnb.flags & PP_PME_FINISH) ? pmerecvqxFINISH : pmerecvqxX);
}
if (debug)
{
fprintf(debug,
- "PP node %d receiving from PME node %d: virial and energy\n",
+ "PP rank %d receiving from PME rank %d: virial and energy\n",
cr->sim_nodeid, cr->dd->pme_nodeid);
}
#ifdef GMX_MPI
#ifdef GMX_PME_DELAYED_WAIT
/* Wait for the x request to finish */
- gmx_pme_send_params_coords_wait(cr->dd);
+ gmx_pme_send_coeffs_coords_wait(cr->dd);
#endif
natoms = cr->dd->nat_home;
if (debug)
{
- fprintf(debug, "PME node sending to PP node %d: virial and energy\n",
+ fprintf(debug, "PME rank sending to PP rank %d: virial and energy\n",
pme_pp->node_peer);
}
#ifdef GMX_MPI