Made gromacs work again without MPI
[alexxy/gromacs.git] / src / gromacs / gmxlib / network.cpp
index c5edd4eb51eea884d5dc6f9ff190f4a0a5abae60..5bac7f1e0f973059cea997da96fd6d7232f429f9 100644 (file)
@@ -235,23 +235,21 @@ void gmx_barrier(MPI_Comm gmx_unused communicator)
 
 void gmx_bcast(int gmx_unused nbytes, void gmx_unused* b, MPI_Comm gmx_unused communicator)
 {
-#if !GMX_MPI
-    GMX_RELEASE_ASSERT(false, "Invalid call to gmx_bcast");
-#else
+    // Without MPI we have a single rank, so bcast is a no-op
+#if GMX_MPI
     MPI_Bcast(b, nbytes, MPI_BYTE, 0, communicator);
 #endif
 }
 
 void gmx_sumd(int gmx_unused nr, double gmx_unused r[], const t_commrec gmx_unused* cr)
 {
+    // Without MPI we have a single rank, so sum is a no-op
+#if GMX_MPI
     if (cr->sizeOfMyGroupCommunicator == 1)
     {
         return;
     }
 
-#if !GMX_MPI
-    GMX_RELEASE_ASSERT(false, "Invalid call to gmx_sumd");
-#else
     if (cr->nc.bUse)
     {
         if (cr->nc.rank_intra == 0)
@@ -278,14 +276,13 @@ void gmx_sumd(int gmx_unused nr, double gmx_unused r[], const t_commrec gmx_unus
 
 void gmx_sumf(int gmx_unused nr, float gmx_unused r[], const t_commrec gmx_unused* cr)
 {
+    // Without MPI we have a single rank, so sum is a no-op
+#if GMX_MPI
     if (cr->sizeOfMyGroupCommunicator == 1)
     {
         return;
     }
 
-#if !GMX_MPI
-    GMX_RELEASE_ASSERT(false, "Invalid call to gmx_sumf");
-#else
     if (cr->nc.bUse)
     {
         /* Use two step summing.  */
@@ -312,14 +309,13 @@ void gmx_sumf(int gmx_unused nr, float gmx_unused r[], const t_commrec gmx_unuse
 
 void gmx_sumi(int gmx_unused nr, int gmx_unused r[], const t_commrec gmx_unused* cr)
 {
+    // Without MPI we have a single rank, so sum is a no-op
+#if GMX_MPI
     if (cr->sizeOfMyGroupCommunicator == 1)
     {
         return;
     }
 
-#if !GMX_MPI
-    GMX_RELEASE_ASSERT(false, "Invalid call to gmx_sumi");
-#else
     if (cr->nc.bUse)
     {
         /* Use two step summing */
@@ -344,35 +340,6 @@ void gmx_sumi(int gmx_unused nr, int gmx_unused r[], const t_commrec gmx_unused*
 #endif
 }
 
-void gmx_sumli(int gmx_unused nr, int64_t gmx_unused r[], const t_commrec gmx_unused* cr)
-{
-#if !GMX_MPI
-    GMX_RELEASE_ASSERT(false, "Invalid call to gmx_sumli");
-#else
-    if (cr->nc.bUse)
-    {
-        /* Use two step summing */
-        if (cr->nc.rank_intra == 0)
-        {
-            MPI_Reduce(MPI_IN_PLACE, r, nr, MPI_INT64_T, MPI_SUM, 0, cr->nc.comm_intra);
-            /* Sum with the buffers reversed */
-            MPI_Allreduce(MPI_IN_PLACE, r, nr, MPI_INT64_T, MPI_SUM, cr->nc.comm_inter);
-        }
-        else
-        {
-            /* This is here because of the silly MPI specification
-                that MPI_IN_PLACE should be put in sendbuf instead of recvbuf */
-            MPI_Reduce(r, nullptr, nr, MPI_INT64_T, MPI_SUM, 0, cr->nc.comm_intra);
-        }
-        MPI_Bcast(r, nr, MPI_INT64_T, 0, cr->nc.comm_intra);
-    }
-    else
-    {
-        MPI_Allreduce(MPI_IN_PLACE, r, nr, MPI_INT64_T, MPI_SUM, cr->mpi_comm_mygroup);
-    }
-#endif
-}
-
 const char* opt2fn_master(const char* opt, int nfile, const t_filenm fnm[], t_commrec* cr)
 {
     return SIMMASTER(cr) ? opt2fn(opt, nfile, fnm) : nullptr;