-/* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*-
+/*
+ * This file is part of the GROMACS molecular simulation package.
*
- * This source code is part of
- *
- * G R O M A C S
- *
- * GROningen MAchine for Chemical Simulations
- *
- * VERSION 3.2.0
- * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2004, The GROMACS development team,
- * check out http://www.gromacs.org for more information.
-
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
+ * Copyright (c) 2001-2004, The GROMACS development team.
+ * 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.
+ *
+ * GROMACS is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
- * If you want to redistribute modifications, please consider that
- * scientific software is very special. Version control is crucial -
- * bugs must be traceable. We will be happy to consider code for
- * inclusion in the official distribution, but derived work must not
- * be called official GROMACS. Details are found in the README & COPYING
- * files - if they are missing, get the official version at www.gromacs.org.
+ * GROMACS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * To help us fund GROMACS development, we humbly ask that you cite
- * the papers on the package - you can find them in the top README file.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GROMACS; if not, see
+ * http://www.gnu.org/licenses, or write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * For more info, check our website at http://www.gromacs.org
+ * If you want to redistribute modifications to GROMACS, please
+ * consider that scientific software is very special. Version
+ * control is crucial - bugs must be traceable. We will be happy to
+ * consider code for inclusion in the official distribution, but
+ * derived work must not be called official GROMACS. Details are found
+ * in the README & COPYING files - if they are missing, get the
+ * official version at http://www.gromacs.org.
*
- * And Hey:
- * GROwing Monsters And Cloning Shrimps
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the research papers on the package. Check out http://www.gromacs.org.
*/
/* This file is completely threadsafe - keep it that way! */
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "gmxpre.h"
+#include "gromacs/legacyheaders/tgroup.h"
#include <math.h>
-#include "macros.h"
-#include "main.h"
-#include "smalloc.h"
-#include "futil.h"
-#include "tgroup.h"
-#include "vec.h"
-#include "network.h"
-#include "smalloc.h"
-#include "update.h"
-#include "rbin.h"
-#include "mtop_util.h"
-#include "gmx_omp_nthreads.h"
+
+#include "gromacs/legacyheaders/gmx_omp_nthreads.h"
+#include "gromacs/legacyheaders/macros.h"
+#include "gromacs/legacyheaders/network.h"
+#include "gromacs/legacyheaders/rbin.h"
+#include "gromacs/legacyheaders/update.h"
+#include "gromacs/math/vec.h"
+#include "gromacs/topology/mtop_util.h"
+#include "gromacs/utility/futil.h"
+#include "gromacs/utility/smalloc.h"
static void init_grptcstat(int ngtc, t_grp_tcstat tcstat[])
{
}
}
-static void init_grpstat(FILE *log,
- gmx_mtop_t *mtop, int ngacc, t_grp_acc gstat[])
+static void init_grpstat(gmx_mtop_t *mtop, int ngacc, t_grp_acc gstat[])
{
gmx_groups_t *groups;
gmx_mtop_atomloop_all_t aloop;
}
}
-void init_ekindata(FILE *log, gmx_mtop_t *mtop, t_grpopts *opts,
+void init_ekindata(FILE gmx_unused *log, gmx_mtop_t *mtop, t_grpopts *opts,
gmx_ekindata_t *ekind)
{
int i;
snew(ekind->ekin_work_alloc, nthread);
snew(ekind->ekin_work, nthread);
+ snew(ekind->dekindl_work, nthread);
#pragma omp parallel for num_threads(nthread) schedule(static)
for (thread = 0; thread < nthread; thread++)
{
- /* Allocate 2 elements extra on both sides,
- * so in single precision we have 2*3*3*4=72 bytes buffer
- * on both sides to avoid cache pollution.
+#define EKIN_WORK_BUFFER_SIZE 2
+ /* Allocate 2 extra elements on both sides, so in single
+ * precision we have
+ * EKIN_WORK_BUFFER_SIZE*DIM*DIM*sizeof(real) = 72/144 bytes
+ * buffer on both sides to avoid cache pollution.
*/
- snew(ekind->ekin_work_alloc[thread], ekind->ngtc+4);
- ekind->ekin_work[thread] = ekind->ekin_work_alloc[thread] + 2;
+ snew(ekind->ekin_work_alloc[thread], ekind->ngtc+2*EKIN_WORK_BUFFER_SIZE);
+ ekind->ekin_work[thread] = ekind->ekin_work_alloc[thread] + EKIN_WORK_BUFFER_SIZE;
+ /* Nasty hack so we can have the per-thread accumulation
+ * variable for dekindl in the same thread-local cache lines
+ * as the per-thread accumulation tensors for ekin[fh],
+ * because they are accumulated in the same loop. */
+ ekind->dekindl_work[thread] = &(ekind->ekin_work[thread][ekind->ngtc][0][0]);
+#undef EKIN_WORK_BUFFER_SIZE
}
ekind->ngacc = opts->ngacc;
snew(ekind->grpstat, opts->ngacc);
- init_grpstat(log, mtop, opts->ngacc, ekind->grpstat);
+ init_grpstat(mtop, opts->ngacc, ekind->grpstat);
}
void accumulate_u(t_commrec *cr, t_grpopts *opts, gmx_ekindata_t *ekind)
}
real sum_ekin(t_grpopts *opts, gmx_ekindata_t *ekind, real *dekindlambda,
- gmx_bool bEkinAveVel, gmx_bool bSaveEkinOld, gmx_bool bScaleEkin)
+ gmx_bool bEkinAveVel, gmx_bool bScaleEkin)
{
int i, j, m, ngtc;
real T, ek;
}
}
else
-
{
/* Calculate the full step Ekin as the average of the half steps */
for (j = 0; (j < DIM); j++)
}
if (dekindlambda)
{
- *dekindlambda = 0.5*(ekind->dekindl + ekind->dekindl_old);
+ if (bEkinAveVel)
+ {
+ *dekindlambda = ekind->dekindl;
+ }
+ else
+ {
+ *dekindlambda = 0.5*(ekind->dekindl + ekind->dekindl_old);
+ }
}
return T;
}