int CommandLineModuleManager::run(int argc, char *argv[])
{
CommandLineModuleInterface *module;
- // TODO: With thread-MPI, gmx_node_rank() returns random stuff here, so we
- // need the first check.
- const bool bMaster = (!gmx_mpi_initialized() || gmx_node_rank() == 0);
+ const bool bMaster = (gmx_node_rank() == 0);
bool bQuiet = impl_->bQuiet_ || !bMaster;
CommandLineCommonOptionsHolder optionsHolder;
try
gmx::GlobalCommandLineHelpContext::get();
if (context != NULL)
{
- // TODO: The first check should not be necessary, but with
- // thread-MPI it is...
- GMX_RELEASE_ASSERT(!gmx_mpi_initialized() || gmx_node_rank() == 0,
+ GMX_RELEASE_ASSERT(gmx_node_rank() == 0,
"Help output should be handled higher up and "
"only get called only on the master rank");
gmx::CommandLineHelpWriter(options)
#ifndef GMX_MPI
return 1;
#else
+#ifdef GMX_THREAD_MPI
+ if (!gmx_mpi_initialized())
+ {
+ return 1;
+ }
+#endif
int i;
(void) MPI_Comm_size(MPI_COMM_WORLD, &i);
return i;
#ifndef GMX_MPI
return 0;
#else
+#ifdef GMX_THREAD_MPI
+ if (!gmx_mpi_initialized())
+ {
+ return 0;
+ }
+#endif
int i;
(void) MPI_Comm_rank(MPI_COMM_WORLD, &i);
return i;
*
* The return value is `FALSE` if MPI_Init() has not been called, or if
* \Gromacs has been compiled without MPI support.
- * For thread-MPI, always returns `TRUE`.
+ * For thread-MPI, returns `TRUE` when the threads have been started.
+ *
+ * Note that there is a lot of code in between MPI_Init() and the thread-MPI
+ * thread start where the return value is different depending on compilation
+ * options.
*/
gmx_bool gmx_mpi_initialized(void);
-/** Returns the number of nodes. */
+/*! \brief
+ * Returns the number of nodes.
+ *
+ * For thread-MPI, returns one before the threads have been started.
+ * This allows code between the real MPI_Init() and the thread-MPI "init" to
+ * still use this function to check for serial/parallel status and work as
+ * expected: for thread-MPI, at that point they should behave as if the run was
+ * serial.
+ */
int gmx_node_num(void);
-/** Returns the rank of the node. */
+/*! \brief
+ * Returns the rank of the node.
+ *
+ * For thread-MPI, returns zero before the threads have been started.
+ * This allows code between the real MPI_Init() and the thread-MPI "init" to
+ * still use this function to check for master node work as expected:
+ * for thread-MPI, at that point the only thread of execution should behave as
+ * if it the master node.
+ */
int gmx_node_rank(void);
/*! \brief