Skip to content

Commit

Permalink
Refuse to reduce if global array is empty (send_counts all 0) (#726)
Browse files Browse the repository at this point in the history
  • Loading branch information
stelzch authored Apr 9, 2024
1 parent 68d04b1 commit 2986904
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions include/kamping/plugin/reproducible_reduce.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,8 @@ class ReproducibleReducePlugin
);
}

KASSERT(global_array_length > 0, "The array must not be empty");

// Construct index map which maps global array indices to PEs
std::map<size_t, size_t> start_indices;
for (size_t p = 0; p < comm.size(); ++p) {
Expand Down
12 changes: 11 additions & 1 deletion tests/plugins/reproducible_reduce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ TEST(ReproducibleReduceTest, Fuzzing) {
}
comm.bcast_single(kamping::send_recv_buf(seed));

std::uniform_int_distribution<size_t> array_length_distribution(0, 20);
std::uniform_int_distribution<size_t> array_length_distribution(1, 20);
std::uniform_int_distribution<size_t> rank_distribution(1, comm.size());
std::mt19937 rng(seed); // RNG for distribution & rank number
std::mt19937 rng_root(rng()); // RNG for data generation (out-of-sync with other ranks)
Expand All @@ -340,6 +340,7 @@ TEST(ReproducibleReduceTest, Fuzzing) {
for (auto i = 0U; i < NUM_ARRAYS; ++i) {
std::vector<double> data_array;
size_t const data_array_size = array_length_distribution(rng);
ASSERT_NE(0, data_array_size);
if (comm.is_root()) {
data_array = generate_test_vector(data_array_size, rng_root());
}
Expand Down Expand Up @@ -513,6 +514,15 @@ TEST(ReproducibleReduceTest, ErrorChecking) {
),
""
);

// Empty array, send_counts all zero
EXPECT_KASSERT_FAILS(
sub_comm.template make_reproducible_comm<double>(
kamping::send_counts({0, 0, 0}),
kamping::recv_displs({0, 0, 0})
),
""
);
});
}
#endif
Expand Down

0 comments on commit 2986904

Please sign in to comment.