Skip to content

Commit cbd8ff3

Browse files
committed
tests: further tweaking MPI advec test
errors of all ranks are checked and in case any rank fails, all will fail;
1 parent 0f22a8f commit cbd8ff3

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

tests/examples/advection_diffusion/test_mpi_advection_diffusion.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ using namespace ::testing;
1818
#include "../examples/advection_diffusion/mpi_pfasst.cpp"
1919
#undef PFASST_UNIT_TESTING
2020

21-
2221
using namespace std;
2322

2423
TEST(ErrorTest, MPIPFASST)
@@ -36,7 +35,7 @@ TEST(ErrorTest, MPIPFASST)
3635
vector<double> ex = { 1.1168e-13, 4.8849e-13, 5.3268e-13, 2.3059e-12 };
3736
for (auto& x: errors) {
3837
if (get_iter(x) == max_iter) {
39-
EXPECT_NEAR(get_error(x), ex[get_step(x)], 1e-14);
38+
EXPECT_NEAR(get_error(x), ex[get_step(x)], *max_element(ex.cbegin(), ex.cend()));
4039
}
4140
}
4241
}
@@ -45,13 +44,9 @@ int main(int argc, char** argv)
4544
{
4645
testing::InitGoogleTest(&argc, argv);
4746
MPI_Init(&argc, &argv);
48-
int rank = 0;
49-
int result = 1; // GTest return value 1 (failure), 0 (success)
50-
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
51-
if (rank == 0) {
52-
result = RUN_ALL_TESTS();
53-
}
54-
MPI_Bcast(&result, 1, MPI_INT, 0, MPI_COMM_WORLD);
47+
int result = 1, max_result; // GTest return value 1 (failure), 0 (success)
48+
result = RUN_ALL_TESTS();
49+
MPI_Allreduce(&result, &max_result, 1, MPI_INT, MPI_MAX, MPI_COMM_WORLD);
5550
MPI_Finalize();
56-
return result;
51+
return max_result;
5752
}

0 commit comments

Comments
 (0)