Further consolidation of commrec initialization
authorMark Abraham <mark.j.abraham@gmail.com>
Sat, 28 Sep 2013 23:19:02 +0000 (01:19 +0200)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Fri, 4 Oct 2013 17:28:00 +0000 (19:28 +0200)
* renamed init_par_threads to reinitialize_commrec_for_this_thread,
  because that's what it does.
* minor consolidation of the two commrec construction functions
* removed useless and untrue comments

Change-Id: I109af71e548012b72388d3ce3e5e8353110e43b3

src/gromacs/gmxlib/network.c
src/gromacs/legacyheaders/network.h
src/programs/mdrun/runner.c

index 2fd91342df1ba336f07ae42ed53ef2115562e494..1076d2c001a361835aee79e2449f477c23ca683f 100644 (file)
@@ -69,6 +69,11 @@ void gmx_fill_commrec_from_mpi(t_commrec *cr)
 #ifndef GMX_MPI
     gmx_call("gmx_fill_commrec_from_mpi");
 #else
+    if (!gmx_mpi_initialized())
+    {
+        gmx_comm("MPI has not been initialized properly");
+    }
+
     cr->nnodes           = gmx_node_num();
     cr->nodeid           = gmx_node_rank();
     cr->sim_nodeid       = cr->nodeid;
@@ -85,14 +90,8 @@ t_commrec *init_commrec()
     snew(cr, 1);
 
 #ifdef GMX_LIB_MPI
-    if (!gmx_mpi_initialized())
-    {
-        gmx_comm("MPI has not been initialized properly");
-    }
-
     gmx_fill_commrec_from_mpi(cr);
 #else
-    /* These should never be accessed */
     cr->mpi_comm_mysim   = NULL;
     cr->mpi_comm_mygroup = NULL;
     cr->nnodes           = 1;
@@ -100,7 +99,7 @@ t_commrec *init_commrec()
     cr->nodeid           = cr->sim_nodeid;
 #endif
 
-    // TODO this should be initialized elsewhere
+    // TODO cr->duty should not be initialized here
     cr->duty = (DUTY_PP | DUTY_PME);
 
 #if defined GMX_LIB_MPI && !defined MPI_IN_PLACE_EXISTS
@@ -119,10 +118,9 @@ t_commrec *init_commrec()
     return cr;
 }
 
-t_commrec *init_par_threads(const t_commrec *cro)
+t_commrec *reinitialize_commrec_for_this_thread(const t_commrec *cro)
 {
 #ifdef GMX_THREAD_MPI
-    int        initialized;
     t_commrec *cr;
 
     /* make a thread-specific commrec */
@@ -132,13 +130,6 @@ t_commrec *init_par_threads(const t_commrec *cro)
     *cr = *cro;
 
     /* and we start setting our own thread-specific values for things */
-    MPI_Initialized(&initialized);
-    if (!initialized)
-    {
-        gmx_comm("Initializing threads without comm");
-    }
-
-    /* No need to do MPI_Init() for thread-MPI. */
     gmx_fill_commrec_from_mpi(cr);
 
     // TODO cr->duty should not be initialized here
index 6dc09159f6594a00025d15d3299cab31b6c5be38..c17a718348c215da0db0261005a2429de449fa02 100644 (file)
@@ -56,7 +56,7 @@ extern "C" {
 t_commrec *init_commrec(void);
 /* Allocate, initialize and return the commrec. */
 
-t_commrec *init_par_threads(const t_commrec *cro);
+t_commrec *reinitialize_commrec_for_this_thread(const t_commrec *cro);
 /* Initialize communication records for thread-parallel simulations.
    Must be called on all threads before any communication takes place by
    the individual threads. Copies the original commrec to
index 53117dcd1f45f0d8554ca52bdccf3e04a817dec8..f6b8e299e5c000f9bf3c4fb48fff78e865c72c7c 100644 (file)
@@ -161,7 +161,7 @@ static void mdrunner_start_fn(void *arg)
 
     fnm = dup_tfn(mc.nfile, mc.fnm);
 
-    cr = init_par_threads(mc.cr);
+    cr = reinitialize_commrec_for_this_thread(mc.cr);
 
     if (MASTER(cr))
     {
@@ -256,8 +256,7 @@ static t_commrec *mdrunner_start_threads(gmx_hw_opt_t *hw_opt,
         return NULL;
     }
 
-    /* make a new comm_rec to reflect the new situation */
-    crn = init_par_threads(cr);
+    crn = reinitialize_commrec_for_this_thread(cr);
     return crn;
 }