Move functionality to mdrunutility
authorMark Abraham <mark.j.abraham@gmail.com>
Thu, 9 May 2019 21:05:55 +0000 (23:05 +0200)
committerMark Abraham <mark.j.abraham@gmail.com>
Wed, 22 May 2019 09:33:52 +0000 (11:33 +0200)
This lower-level module needs to acquire more content from mdrun as we
evolve a more levelised design. This change premptively resolves
several cycles that would be introduced by consolidating restarting
handling into mdrunutility/handlerestart.cpp.

Moved multi-sim related bools to its header, rather than commrec.h.
Several functions did not need to be inlined, as they were only
used during set up and tear down.

Made a few routines in even lower-level modules be passed the
boolean parameter computed from cr and ms, rather than being
passed it themselves.

Change-Id: I4a1721eaf7cbe08155110782a6680785091504db

29 files changed:
src/api/cpp/context.cpp
src/api/cpp/createsession.h
src/api/cpp/session.cpp
src/api/cpp/session_impl.h
src/gromacs/awh/awh.cpp
src/gromacs/hardware/printhardware.cpp
src/gromacs/hardware/printhardware.h
src/gromacs/imd/imd.cpp
src/gromacs/listed_forces/orires.cpp
src/gromacs/mdlib/lincs.cpp
src/gromacs/mdlib/simulationsignal.cpp
src/gromacs/mdrun/CMakeLists.txt
src/gromacs/mdrun/legacymdrunoptions.cpp
src/gromacs/mdrun/legacymdrunoptions.h
src/gromacs/mdrun/md.cpp
src/gromacs/mdrun/mimic.cpp
src/gromacs/mdrun/replicaexchange.cpp
src/gromacs/mdrun/rerun.cpp
src/gromacs/mdrun/runner.cpp
src/gromacs/mdrunutility/CMakeLists.txt
src/gromacs/mdrunutility/handlerestart.cpp
src/gromacs/mdrunutility/logging.cpp [moved from src/gromacs/mdrun/logging.cpp with 97% similarity]
src/gromacs/mdrunutility/logging.h [moved from src/gromacs/mdrun/logging.h with 93% similarity]
src/gromacs/mdrunutility/multisim.cpp [moved from src/gromacs/mdrun/multisim.cpp with 94% similarity]
src/gromacs/mdrunutility/multisim.h [moved from src/gromacs/mdrun/multisim.h with 77% similarity]
src/gromacs/mdtypes/commrec.h
src/gromacs/taskassignment/resourcedivision.cpp
src/gromacs/taskassignment/taskassignment.cpp
src/programs/mdrun/mdrun.cpp

index b73b88a00970a8efe0bdb72586fa7e0e1a748838..f5d1272113da4f1ec8da0aa2ad1887188c24caf6 100644 (file)
@@ -56,8 +56,8 @@
 #include "gromacs/commandline/pargs.h"
 #include "gromacs/gmxlib/network.h"
 #include "gromacs/mdlib/stophandler.h"
-#include "gromacs/mdrun/logging.h"
-#include "gromacs/mdrun/multisim.h"
+#include "gromacs/mdrunutility/logging.h"
+#include "gromacs/mdrunutility/multisim.h"
 #include "gromacs/mdrun/runner.h"
 #include "gromacs/mdrunutility/handlerestart.h"
 #include "gromacs/mdtypes/commrec.h"
index 01536a63f0f1a7285887c1714fb92fd7d1942143..3cc5022bc143fd73bb5abc3ef33318275bbf4e30 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2018, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019, 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.
@@ -41,7 +41,7 @@
  * \ingroup gmxapi
  */
 
-#include "gromacs/mdrun/logging.h"
+#include "gromacs/mdrunutility/logging.h"
 
 #include "gmxapi/context.h"
 #include "gmxapi/session.h"
index d1abc69eb1096d4dc3415f5b1568f05ea931a183..b4d219304311b8480fa8c519e478699fbf6699dc 100644 (file)
@@ -42,8 +42,8 @@
 #include <memory>
 #include "gromacs/gmxlib/network.h"
 #include "gromacs/mdlib/sighandler.h"
-#include "gromacs/mdrun/logging.h"
-#include "gromacs/mdrun/multisim.h"
+#include "gromacs/mdrunutility/logging.h"
+#include "gromacs/mdrunutility/multisim.h"
 #include "gromacs/restraint/restraintpotential.h"
 #include "gromacs/utility/gmxassert.h"
 #include "gromacs/utility/basenetwork.h"
index 2f9373882661bb8d0df94e6c857b2429d6ea5fc4..a7377528fccbcf3f26c480d75a08d96630926589 100644 (file)
@@ -43,7 +43,7 @@
 
 #include <map>
 
-#include "gromacs/mdrun/logging.h"
+#include "gromacs/mdrunutility/logging.h"
 #include "gromacs/mdrun/runner.h"
 #include "gromacs/mdrun/simulationcontext.h"
 
index 87bc0812a2917fd7cfaf21b10ddef682be012742..cf3a1576793ec2d810a92bd29274a0ee93e27c03 100644 (file)
@@ -57,6 +57,7 @@
 #include "gromacs/fileio/enxio.h"
 #include "gromacs/gmxlib/network.h"
 #include "gromacs/math/units.h"
+#include "gromacs/mdrunutility/multisim.h"
 #include "gromacs/mdtypes/awh_history.h"
 #include "gromacs/mdtypes/awh_params.h"
 #include "gromacs/mdtypes/commrec.h"
index dc58b6025b8d72c535219fe6c2f3ccded1795f2a..432778a025b677c6c3fdfd1c4090dd726af27103 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2012,2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013,2014,2015,2016,2017,2018,2019, 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.
 #include "gromacs/hardware/hardwaretopology.h"
 #include "gromacs/hardware/hw_info.h"
 #include "gromacs/hardware/identifyavx512fmaunits.h"
-#include "gromacs/mdtypes/commrec.h"
 #include "gromacs/simd/support.h"
 #include "gromacs/utility/basedefinitions.h"
 #include "gromacs/utility/basenetwork.h"
 #include "gromacs/utility/cstringutil.h"
 #include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/gmxmpi.h"
 #include "gromacs/utility/logger.h"
 #include "gromacs/utility/programcontext.h"
 #include "gromacs/utility/stringutil.h"
@@ -354,8 +354,8 @@ static std::string detected_hardware_string(const gmx_hw_info_t *hwinfo,
     return s;
 }
 
-void gmx_print_detected_hardware(FILE *fplog, const t_commrec *cr,
-                                 const gmx_multisim_t *ms,
+void gmx_print_detected_hardware(FILE                *fplog,
+                                 const bool           warnToStdErr,
                                  const gmx::MDLogger &mdlog,
                                  const gmx_hw_info_t *hwinfo)
 {
@@ -379,7 +379,7 @@ void gmx_print_detected_hardware(FILE *fplog, const t_commrec *cr,
      */
     if (cpuInfo.supportLevel() >= gmx::CpuInfo::SupportLevel::Features)
     {
-        gmx::simdCheck(static_cast<gmx::SimdType>(hwinfo->simd_suggest_min), fplog, isMasterSimMasterRank(ms, cr));
+        gmx::simdCheck(static_cast<gmx::SimdType>(hwinfo->simd_suggest_min), fplog, warnToStdErr);
     }
 
     /* For RDTSCP we only check on our local node and skip the MPI reduction */
index c70a3b7e68fe4aff1df3d01d0d2fb61facdc28d2..a525c75ae9212f944abd4ee382e1a0ec2e1a8513 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2012,2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013,2014,2015,2016,2017,2018,2019, 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.
@@ -38,8 +38,6 @@
 #include <cstdio>
 
 struct gmx_hw_info_t;
-struct gmx_multisim_t;
-struct t_commrec;
 
 namespace gmx
 {
@@ -49,8 +47,8 @@ class MDLogger;
 /* Print information about the detected hardware to fplog (if != NULL)
  * and to stderr the master rank.
  */
-void gmx_print_detected_hardware(FILE *fplog, const t_commrec *cr,
-                                 const gmx_multisim_t *ms,
+void gmx_print_detected_hardware(FILE                *fplog,
+                                 bool                 warnToStdErr,
                                  const gmx::MDLogger &mdlog,
                                  const gmx_hw_info_t *hwinfo);
 
index 5f0f8193363244899feea33cdaeb06bb85f89f8d..fa50c1a0ad762fbc443755a7bbb5977a544489da 100644 (file)
@@ -68,6 +68,7 @@
 #include "gromacs/mdlib/groupcoord.h"
 #include "gromacs/mdlib/sighandler.h"
 #include "gromacs/mdlib/stat.h"
+#include "gromacs/mdrunutility/multisim.h"
 #include "gromacs/mdtypes/enerdata.h"
 #include "gromacs/mdtypes/imdmodule.h"
 #include "gromacs/mdtypes/inputrec.h"
index e86c01d1f65ade156f4cee74485b2fa211a3e46a..9b345246376cf4daaaf80cbc862f8349a564d980 100644 (file)
@@ -46,6 +46,7 @@
 #include "gromacs/math/do_fit.h"
 #include "gromacs/math/functions.h"
 #include "gromacs/math/vec.h"
+#include "gromacs/mdrunutility/multisim.h"
 #include "gromacs/mdtypes/commrec.h"
 #include "gromacs/mdtypes/fcdata.h"
 #include "gromacs/mdtypes/inputrec.h"
index 169591e0e8c9ffc7b57eb331ee7621c4410c1107..a9b65cdf8f803f7873b9df24a65ee262148a450c 100644 (file)
@@ -63,6 +63,7 @@
 #include "gromacs/math/vec.h"
 #include "gromacs/mdlib/constr.h"
 #include "gromacs/mdlib/gmx_omp_nthreads.h"
+#include "gromacs/mdrunutility/multisim.h"
 #include "gromacs/mdtypes/commrec.h"
 #include "gromacs/mdtypes/inputrec.h"
 #include "gromacs/mdtypes/md_enums.h"
index f3c3ef0688ee0cd6ec0ed4abf7bd35d6788e96c1..3959555f64e7d77765796ff8a84f52152a91dd67 100644 (file)
@@ -57,6 +57,7 @@
 #include <algorithm>
 
 #include "gromacs/gmxlib/network.h"
+#include "gromacs/mdrunutility/multisim.h"
 #include "gromacs/mdtypes/commrec.h"
 #include "gromacs/utility/arrayref.h"
 #include "gromacs/utility/gmxassert.h"
index 11d361592d8c7e30ed0314673b670b576307243b..9db38170f0be47c0557ac6a57ffaced133e262c8 100644 (file)
 gmx_add_libgromacs_sources(
     integrator.cpp
     legacymdrunoptions.cpp
-    logging.cpp
     shellfc.cpp
     md.cpp
     mdmodules.cpp
     minimize.cpp
-    multisim.cpp
     replicaexchange.cpp
     rerun.cpp
     mimic.cpp
index 9d02e982d433465c71172c05aa4dcff83a849339..ae0f4e3ad64406daf9d9ef420ad6ffaf1663c8a1 100644 (file)
@@ -55,8 +55,8 @@
 
 #include "gromacs/gmxlib/network.h"
 #include "gromacs/math/functions.h"
-#include "gromacs/mdrun/multisim.h"
 #include "gromacs/mdrunutility/handlerestart.h"
+#include "gromacs/mdrunutility/multisim.h"
 #include "gromacs/mdtypes/commrec.h"
 #include "gromacs/utility/arraysize.h"
 #include "gromacs/utility/fatalerror.h"
index dca811f926e45419cab797abea4e3bce714b4bb1..323a85a1269fe9ba55a2f776b21739fa29cf0da3 100644 (file)
@@ -53,7 +53,7 @@
 #include "gromacs/commandline/pargs.h"
 #include "gromacs/domdec/options.h"
 #include "gromacs/hardware/hw_info.h"
-#include "gromacs/mdrun/logging.h"
+#include "gromacs/mdrunutility/logging.h"
 #include "gromacs/mdtypes/mdrunoptions.h"
 
 #include "replicaexchange.h"
index fb4ee760533db383bdf3fab13bd7f580222ffc8c..76ad256caef2a90a8483e4485a10fdb93a4cff82 100644 (file)
@@ -98,6 +98,7 @@
 #include "gromacs/mdlib/update.h"
 #include "gromacs/mdlib/vcm.h"
 #include "gromacs/mdlib/vsite.h"
+#include "gromacs/mdrunutility/multisim.h"
 #include "gromacs/mdrunutility/printtime.h"
 #include "gromacs/mdtypes/awh_history.h"
 #include "gromacs/mdtypes/awh_params.h"
@@ -1405,7 +1406,7 @@ void gmx::Integrator::do_md()
             state->fep_state = lamnew;
         }
         /* Print the remaining wall clock time for the run */
-        if (isMasterSimMasterRank(ms, cr) &&
+        if (isMasterSimMasterRank(ms, MASTER(cr)) &&
             (do_verbose || gmx_got_usr_signal()) &&
             !bPMETunePrinting)
         {
index 050fe9177734736b1321c600580c07305022e468..7a2c05ee54adfda5de8b78f8eeb9f5f4db8e6eb2 100644 (file)
@@ -95,6 +95,7 @@
 #include "gromacs/mdlib/update.h"
 #include "gromacs/mdlib/vcm.h"
 #include "gromacs/mdlib/vsite.h"
+#include "gromacs/mdrunutility/multisim.h"
 #include "gromacs/mdrunutility/printtime.h"
 #include "gromacs/mdtypes/awh_history.h"
 #include "gromacs/mdtypes/awh_params.h"
@@ -586,7 +587,7 @@ void gmx::Integrator::do_mimic()
         }
 
         /* Print the remaining wall clock time for the run */
-        if (isMasterSimMasterRank(ms, cr) &&
+        if (isMasterSimMasterRank(ms, MASTER(cr)) &&
             (mdrunOptions.verbose || gmx_got_usr_signal()))
         {
             if (shellfc)
index a633d688c67c1755effb063557635296875bc876..b80d59e44c4405f40b209d213463034af1c303ef 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2011,2012,2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2011,2012,2013,2014,2015,2016,2017,2018,2019, 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.
@@ -57,7 +57,7 @@
 #include "gromacs/gmxlib/network.h"
 #include "gromacs/math/units.h"
 #include "gromacs/math/vec.h"
-#include "gromacs/mdrun/multisim.h"
+#include "gromacs/mdrunutility/multisim.h"
 #include "gromacs/mdtypes/commrec.h"
 #include "gromacs/mdtypes/enerdata.h"
 #include "gromacs/mdtypes/inputrec.h"
index f04e70228b0fc7928926de6cf80440f496046ef3..92566ef2b3fa14e0a2033f0c1989cdeaa0cbdee7 100644 (file)
@@ -96,6 +96,7 @@
 #include "gromacs/mdlib/update.h"
 #include "gromacs/mdlib/vcm.h"
 #include "gromacs/mdlib/vsite.h"
+#include "gromacs/mdrunutility/multisim.h"
 #include "gromacs/mdrunutility/printtime.h"
 #include "gromacs/mdtypes/awh_history.h"
 #include "gromacs/mdtypes/awh_params.h"
@@ -685,7 +686,7 @@ void gmx::Integrator::do_rerun()
         }
 
         /* Print the remaining wall clock time for the run */
-        if (isMasterSimMasterRank(ms, cr) &&
+        if (isMasterSimMasterRank(ms, MASTER(cr)) &&
             (mdrunOptions.verbose || gmx_got_usr_signal()))
         {
             if (shellfc)
index 5fc025198c2e9853544717910bc62e0d1205191c..8dfaa5dbe669c9e8f44f3743057637241da9d40b 100644 (file)
 #include "gromacs/mdlib/qmmm.h"
 #include "gromacs/mdlib/sighandler.h"
 #include "gromacs/mdlib/stophandler.h"
-#include "gromacs/mdrun/logging.h"
 #include "gromacs/mdrun/mdmodules.h"
-#include "gromacs/mdrun/multisim.h"
 #include "gromacs/mdrun/simulationcontext.h"
+#include "gromacs/mdrunutility/logging.h"
+#include "gromacs/mdrunutility/multisim.h"
 #include "gromacs/mdrunutility/printtime.h"
 #include "gromacs/mdrunutility/threadaffinity.h"
 #include "gromacs/mdtypes/commrec.h"
@@ -632,7 +632,7 @@ int Mdrunner::mdrunner()
     PhysicalNodeCommunicator physicalNodeComm(MPI_COMM_WORLD, gmx_physicalnode_id_hash());
     hwinfo = gmx_detect_hardware(mdlog, physicalNodeComm);
 
-    gmx_print_detected_hardware(fplog, cr, ms, mdlog, hwinfo);
+    gmx_print_detected_hardware(fplog, isMasterSimMasterRank(ms, MASTER(cr)), mdlog, hwinfo);
 
     std::vector<int> gpuIdsToUse;
     auto             compatibleGpus = getCompatibleGpus(hwinfo->gpu_info);
index 14dc4b0de9514268c68e6477362cb813fce96d8d..b1d76c52792e4a3fd635c99a483e0425e2f8fc4b 100644 (file)
@@ -34,6 +34,8 @@
 
 gmx_add_libgromacs_sources(
     handlerestart.cpp
+    logging.cpp
+    multisim.cpp
     printtime.cpp
     threadaffinity.cpp
     )
index 4dc32ba506fd62898e3fcb2bc16e176e60f117b5..2e6de9335463f898740770465b6ee1b219fef110 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2015,2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016,2017,2018,2019, 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.
@@ -57,6 +57,7 @@
 #include "gromacs/fileio/checkpoint.h"
 #include "gromacs/fileio/gmxfio.h"
 #include "gromacs/gmxlib/network.h"
+#include "gromacs/mdrunutility/multisim.h"
 #include "gromacs/mdtypes/commrec.h"
 #include "gromacs/utility/basedefinitions.h"
 #include "gromacs/utility/fatalerror.h"
@@ -250,7 +251,7 @@ handleRestart(t_commrec            *cr,
                              &sim_part_fn, cr,
                              bTryToAppendFiles, NFILE, fnm,
                              part_suffix, &bAddPart, bDoAppendFiles);
-        if (sim_part_fn == 0 && isMasterSimMasterRank(ms, cr))
+        if (sim_part_fn == 0 && isMasterSimMasterRank(ms, MASTER(cr)))
         {
             fprintf(stdout, "No previous checkpoint file present with -cpi option, assuming this is a new run.\n");
         }
@@ -265,7 +266,7 @@ handleRestart(t_commrec            *cr,
         if (isMultiSim(ms) && MASTER(cr))
         {
             // Only the master simulation should report on problems.
-            if (isMasterSimMasterRank(ms, cr))
+            if (isMasterSimMasterRank(ms, MASTER(cr)))
             {
                 /* Log file is not yet available, so if there's a
                  * problem we can only write to stderr. */
@@ -300,7 +301,7 @@ handleRestart(t_commrec            *cr,
         sprintf(suffix, "%s%04d", part_suffix, sim_part_fn);
 
         add_suffix_to_output_names(fnm, NFILE, suffix);
-        if (isMasterSimMasterRank(ms, cr))
+        if (isMasterSimMasterRank(ms, MASTER(cr)))
         {
             fprintf(stdout, "Checkpoint file is from part %d, new output files will be suffixed '%s'.\n", sim_part-1, suffix);
         }
similarity index 97%
rename from src/gromacs/mdrun/logging.cpp
rename to src/gromacs/mdrunutility/logging.cpp
index be837250e49920d120f94bf0b3151452d211d0c3..612559e6163366068681283e2b501336187b53c8 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2018, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019, 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.
@@ -37,7 +37,7 @@
  * \brief Implements the MD log file handling routines.
  *
  * \author Mark Abraham <mark.j.abraham@gmail.com>
- * \ingroup module_mdrun
+ * \ingroup module_mdrunutility
  */
 #include "gmxpre.h"
 
similarity index 93%
rename from src/gromacs/mdrun/logging.h
rename to src/gromacs/mdrunutility/logging.h
index 39557d09a2780704b49e4bef25d0bb57c050fe44..4535fd9a93c11280af45e7c60a26d46c0e409d03 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2018, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019, 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.
  *
  * \author Mark Abraham <mark.j.abraham@gmail.com>
  * \inlibraryapi
- * \ingroup module_mdrun
+ * \ingroup module_mdrunutility
  */
-#ifndef GMX_MDRUN_LOGGING_H
-#define GMX_MDRUN_LOGGING_H
+#ifndef GMX_MDRUNUTILITY_LOGGING_H
+#define GMX_MDRUNUTILITY_LOGGING_H
 
 #include <memory>
 
similarity index 94%
rename from src/gromacs/mdrun/multisim.cpp
rename to src/gromacs/mdrunutility/multisim.cpp
index 6d0cfd9de279c64211ec115cfe48b6601d5e8ff3..a74dfc0c1b22739258e27fca5f958afecbdd4739 100644 (file)
@@ -37,7 +37,7 @@
  * \brief Implements the multi-simulation support routines.
  *
  * \author Mark Abraham <mark.j.abraham@gmail.com>
- * \ingroup module_mdrun
+ * \ingroup module_mdrunutility
  */
 #include "gmxpre.h"
 
@@ -141,3 +141,14 @@ void done_multisim(gmx_multisim_t *ms)
         delete ms;
     }
 }
+
+bool isMasterSim(const gmx_multisim_t *ms)
+{
+    return !isMultiSim(ms) || ms->sim == 0;
+}
+
+bool isMasterSimMasterRank(const gmx_multisim_t *ms,
+                           const bool            isMaster)
+{
+    return (isMaster && isMasterSim(ms));
+}
similarity index 77%
rename from src/gromacs/mdrun/multisim.h
rename to src/gromacs/mdrunutility/multisim.h
index 41b51459dff9351ae38e5edac8606eadf3b6095e..ad8ba7731b3b6072f5250391e7e40fe56092f429 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2018, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019, 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.
  *
  * \author Mark Abraham <mark.j.abraham@gmail.com>
  * \inlibraryapi
- * \ingroup module_mdrun
+ * \ingroup module_mdrunutility
  */
-#ifndef GMX_MDRUN_MULTISIM_H
-#define GMX_MDRUN_MULTISIM_H
+#ifndef GMX_MDRUNUTILITY_MULTISIM_H
+#define GMX_MDRUNUTILITY_MULTISIM_H
 
 #include <string>
 
@@ -61,4 +61,19 @@ gmx_multisim_t *init_multisystem(MPI_Comm                         comm,
 //! Cleans up multi-system handler.
 void done_multisim(gmx_multisim_t *ms);
 
+//! Are we doing multiple independent simulations?
+static bool inline isMultiSim(const gmx_multisim_t *ms)
+{
+    return ms != nullptr;
+}
+
+//! Are we the master simulation of a possible multi-simulation?
+bool isMasterSim(const gmx_multisim_t *ms);
+
+/*! \brief Are we the master rank (of the master simulation, for a multi-sim).
+ *
+ * This rank prints the remaining run time etc. */
+bool isMasterSimMasterRank(const gmx_multisim_t *ms,
+                           bool                  isMaster);
+
 #endif
index e85805a26ac99e7f19d34d0606a0d2152010017b..247355168c8640735d431857675d67e1bc51ae70 100644 (file)
@@ -185,25 +185,4 @@ static bool inline havePPDomainDecomposition(const t_commrec *cr)
             cr->nnodes - cr->npmenodes > 1);
 }
 
-//! Are we doing multiple independent simulations?
-static bool inline isMultiSim(const gmx_multisim_t *ms)
-{
-    return ms != nullptr;
-}
-
-//! Are we the master simulation of a possible multi-simulation?
-static bool inline isMasterSim(const gmx_multisim_t *ms)
-{
-    return !isMultiSim(ms) || ms->sim == 0;
-}
-
-/*! \brief Are we the master rank (of the master simulation, for a multi-sim).
- *
- * This rank prints the remaining run time etc. */
-static bool inline isMasterSimMasterRank(const gmx_multisim_t *ms,
-                                         const t_commrec      *cr)
-{
-    return (SIMMASTER(cr) && isMasterSim(ms));
-}
-
 #endif
index 05e3912797ddb62d9bee0abfc3f9aa66e919faae..9c83a9b9b3c9b62b9c9c8ca952347f6c56ad67f0 100644 (file)
@@ -58,6 +58,7 @@
 #include "gromacs/hardware/hw_info.h"
 #include "gromacs/math/functions.h"
 #include "gromacs/mdlib/gmx_omp_nthreads.h"
+#include "gromacs/mdrunutility/multisim.h"
 #include "gromacs/mdtypes/commrec.h"
 #include "gromacs/mdtypes/inputrec.h"
 #include "gromacs/mdtypes/md_enums.h"
index 5a62bfb136633bf58ba42ba7a7f340bab44b715c..5b77152fd3642c656ceb5a09bca1282c8a0345df 100644 (file)
@@ -57,6 +57,7 @@
 #include <vector>
 
 #include "gromacs/hardware/hw_info.h"
+#include "gromacs/mdrunutility/multisim.h"
 #include "gromacs/mdtypes/commrec.h"
 #include "gromacs/taskassignment/usergpuids.h"
 #include "gromacs/utility/cstringutil.h"
index 846df4933db75186d0cd42577469913093368842..4de4f0c34edf6af683d6a1cdd5d4476276993c0c 100644 (file)
@@ -60,9 +60,9 @@
 #include "gromacs/fileio/gmxfio.h"
 #include "gromacs/gmxlib/network.h"
 #include "gromacs/mdrun/legacymdrunoptions.h"
-#include "gromacs/mdrun/logging.h"
 #include "gromacs/mdrun/runner.h"
 #include "gromacs/mdrun/simulationcontext.h"
+#include "gromacs/mdrunutility/logging.h"
 #include "gromacs/mdtypes/commrec.h"
 #include "gromacs/utility/arrayref.h"
 #include "gromacs/utility/smalloc.h"