Add missing MPI_Barrier to MpiTest
[alexxy/gromacs.git] / src / testutils / tests / mpitest.cpp
index f3d8c0f4eca09bef4bea9c4eaa7090aec062614b..8d3b9521fc081002087296ad7a74b2acefc0034f 100644 (file)
@@ -74,6 +74,9 @@ TEST_F(MpiSelfTest, Runs)
     {
         reached_.resize(getNumberOfTestMpiRanks(), 0);
     }
+    // Needed for thread-MPI so that we resize the buffer before we
+    // fill it on non-master ranks.
+    MPI_Barrier(MPI_COMM_WORLD);
     int value = 1;
     MPI_Gather(&value, 1, MPI_INT, reached_.data(), 1, MPI_INT, 0, MPI_COMM_WORLD);
     if (gmx_node_rank() == 0)