Move threading support into listed-forces module
authorMark Abraham <mark.j.abraham@gmail.com>
Sun, 14 Sep 2014 16:30:55 +0000 (18:30 +0200)
committerMark Abraham <mark.j.abraham@gmail.com>
Fri, 5 Dec 2014 18:56:10 +0000 (19:56 +0100)
Added Doxygen, converted a macro to a const int.

Change-Id: I1e5579b1f80aecaf46827704cf5fd3b6d6285d80

src/gromacs/domdec/domdec.cpp
src/gromacs/listed-forces/listed-forces.h
src/gromacs/listed-forces/manage-threading.cpp [moved from src/gromacs/gmxlib/bonded-threading.cpp with 91% similarity]
src/gromacs/listed-forces/manage-threading.h [moved from src/gromacs/legacyheaders/bonded-threading.h with 74% similarity]
src/gromacs/mdlib/minimize.cpp
src/programs/mdrun/md.cpp

index fa932d308f8559693bd6a773d79ef5492562edc6..ba974d348f92b7afff6aa1703fc7e63de343fcb0 100644 (file)
@@ -53,7 +53,6 @@
 #include "gromacs/fileio/gmxfio.h"
 #include "gromacs/fileio/pdbio.h"
 #include "gromacs/imd/imd.h"
-#include "gromacs/legacyheaders/bonded-threading.h"
 #include "gromacs/legacyheaders/chargegroup.h"
 #include "gromacs/legacyheaders/constr.h"
 #include "gromacs/legacyheaders/force.h"
@@ -84,6 +83,7 @@
 #include "gromacs/legacyheaders/types/shellfc.h"
 #include "gromacs/legacyheaders/types/simple.h"
 #include "gromacs/legacyheaders/types/state.h"
+#include "gromacs/listed-forces/manage-threading.h"
 #include "gromacs/math/vec.h"
 #include "gromacs/math/vectypes.h"
 #include "gromacs/mdlib/nb_verlet.h"
index e431eb9cdd1d1fbcd92e5fc8e994c5cded262095..3c40c6961ac478fbff64e8131057e4abb7cb201b 100644 (file)
 /*! \defgroup module_listed-forces Interactions between lists of particles
  * \ingroup group_mdrun
  *
- * \brief Computes energies and forces for interactions between a
- * small number of particles, e.g bonds, position restraints and
- * listed non-bonded interactions (e.g. 1-4).
- *
- * As well as code to compute those quantites, high-level functions
- * for use by mdrun to compute a set of such quantities are also
- * located here.
- *
- * More functionality will move into this module shortly.
+ * \brief Handles computing energies and forces for listed
+ * interactions.
+ *
+ * Located here is the the code for
+ * - computing energies and forces for interactions between a small
+     number of particles, e.g bonds, position restraints and listed
+     non-bonded interactions (e.g. 1-4).
+ * - high-level functions used by mdrun for computing a set of such
+     quantities
+ * - managing thread-wise decomposition, thread-local buffer output,
+     and reduction of output data across threads.
  *
  * \author Mark Abraham <mark.j.abraham@gmail.com>
  *
similarity index 91%
rename from src/gromacs/gmxlib/bonded-threading.cpp
rename to src/gromacs/listed-forces/manage-threading.cpp
index cf9ab16c10cf5a2846027d396c8c6fa2e6d38161..3c10bdef1c7d0b2fe665911f7888c242d380f48a 100644 (file)
  * To help us fund GROMACS development, we humbly ask that you cite
  * the research papers on the package. Check out http://www.gromacs.org.
  */
+/*! \internal \file
+ * \brief This file defines functions for managing threading of listed
+ * interactions.
+ *
+ * \author Mark Abraham <mark.j.abraham@gmail.com>
+ * \ingroup module_listed-forces
+ */
 #include "gmxpre.h"
 
-#include "gromacs/legacyheaders/bonded-threading.h"
+#include "manage-threading.h"
 
 #include <assert.h>
 
@@ -46,6 +53,7 @@
 #include "gromacs/utility/fatalerror.h"
 #include "gromacs/utility/smalloc.h"
 
+//! Divides listed interactions over threads
 static void divide_bondeds_over_threads(t_idef *idef, int nthreads)
 {
     int ftype;
@@ -101,6 +109,7 @@ static void divide_bondeds_over_threads(t_idef *idef, int nthreads)
     }
 }
 
+//! Construct a reduction mask for which interaction was computed on which thread
 static unsigned
 calc_bonded_reduction_mask(const t_idef *idef,
                            int shift,
@@ -140,9 +149,14 @@ calc_bonded_reduction_mask(const t_idef *idef,
     return mask;
 }
 
+
+/*! \brief We divide the force array in a maximum of 32 blocks.
+ * Minimum force block reduction size is thus 2^6=64.
+ */
+const int maxBlockBits = 32;
+
 void setup_bonded_threading(t_forcerec   *fr, t_idef *idef)
 {
-#define MAX_BLOCK_BITS 32
     int t;
     int ctot, c, b;
 
@@ -158,11 +172,8 @@ void setup_bonded_threading(t_forcerec   *fr, t_idef *idef)
         return;
     }
 
-    /* We divide the force array in a maximum of 32 blocks.
-     * Minimum force block reduction size is 2^6=64.
-     */
     fr->red_ashift = 6;
-    while (fr->natoms_force > (int)(MAX_BLOCK_BITS*(1U<<fr->red_ashift)))
+    while (fr->natoms_force > (int)(maxBlockBits*(1U<<fr->red_ashift)))
     {
         fr->red_ashift++;
     }
@@ -188,7 +199,7 @@ void setup_bonded_threading(t_forcerec   *fr, t_idef *idef)
     for (t = 0; t < fr->nthreads; t++)
     {
         c = 0;
-        for (b = 0; b < MAX_BLOCK_BITS; b++)
+        for (b = 0; b < maxBlockBits; b++)
         {
             if (fr->f_t[t].red_mask & (1U<<b))
             {
similarity index 74%
rename from src/gromacs/legacyheaders/bonded-threading.h
rename to src/gromacs/listed-forces/manage-threading.h
index e08765fa1f3077eefaf6de831a5930c4b518c04b..1cf0844ce27050db4a33d5a1d8243b0977f1213a 100644 (file)
  * To help us fund GROMACS development, we humbly ask that you cite
  * the research papers on the package. Check out http://www.gromacs.org.
  */
+/*! \libinternal \file
+ * \brief Declares functions for managing threading of listed forces
+ *
+ * \author Mark Abraham <mark.j.abraham@gmail.com>
+ * \inlibraryapi
+ * \ingroup module_listed-forces
+ */
+#ifndef GMX_LISTED_FORCES_MANAGE_THREADING_H
+#define GMX_LISTED_FORCES_MANAGE_THREADING_H
 
-#ifndef GMX_LEGACYHEADERS_BONDED_THREADING_H
-#define GMX_LEGACYHEADERS_BONDED_THREADING_H
-
-#include "gromacs/legacyheaders/typedefs.h"
+#include "gromacs/legacyheaders/types/forcerec.h"
+#include "gromacs/topology/idef.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-/* Divided the bonded interactions over the threads, count=fr->nthreads
- * and set up the bonded thread-force buffer reduction.
- * This should be called each time the bonded setup changes;
- * i.e. at start-up without domain decomposition and at DD.
+/*! \brief Divide the listed interactions over the threads
+ *
+ * Uses fr->nthreads for the number of threads, and sets up the
+ * thread-force buffer reduction. This should be called each time the
+ * bonded setup changes; i.e. at start-up without domain decomposition
+ * and at DD.
  */
 void setup_bonded_threading(t_forcerec *fr, t_idef *idef);
 
index bf9a6bd9109d4b758481d70f631d8e50ab5a66c1..3fa62638f5a634328d757f8c14c0fdf1f3083a70 100644 (file)
@@ -50,7 +50,6 @@
 #include "gromacs/fileio/mtxio.h"
 #include "gromacs/fileio/trajectory_writing.h"
 #include "gromacs/imd/imd.h"
-#include "gromacs/legacyheaders/bonded-threading.h"
 #include "gromacs/legacyheaders/constr.h"
 #include "gromacs/legacyheaders/force.h"
 #include "gromacs/legacyheaders/gmx_omp_nthreads.h"
@@ -72,6 +71,7 @@
 #include "gromacs/legacyheaders/vsite.h"
 #include "gromacs/legacyheaders/types/commrec.h"
 #include "gromacs/linearalgebra/sparsematrix.h"
+#include "gromacs/listed-forces/manage-threading.h"
 #include "gromacs/math/vec.h"
 #include "gromacs/pbcutil/mshift.h"
 #include "gromacs/pbcutil/pbc.h"
index dc086105ac521a41ec021cba112def5b1b19a51d..d84661072be3369a6b243cc757c2c3f766241305 100644 (file)
@@ -55,7 +55,6 @@
 #include "gromacs/fileio/trxio.h"
 #include "gromacs/gmxpreprocess/compute_io.h"
 #include "gromacs/imd/imd.h"
-#include "gromacs/legacyheaders/bonded-threading.h"
 #include "gromacs/legacyheaders/constr.h"
 #include "gromacs/legacyheaders/ebin.h"
 #include "gromacs/legacyheaders/force.h"
@@ -93,6 +92,7 @@
 #include "gromacs/legacyheaders/types/oenv.h"
 #include "gromacs/legacyheaders/types/shellfc.h"
 #include "gromacs/legacyheaders/types/state.h"
+#include "gromacs/listed-forces/manage-threading.h"
 #include "gromacs/math/utilities.h"
 #include "gromacs/math/vec.h"
 #include "gromacs/math/vectypes.h"