Skip to content

Commit

Permalink
Added a test that was failing before the fix in b55a0b6.
Browse files Browse the repository at this point in the history
  • Loading branch information
asrivast28 committed Mar 3, 2020
1 parent b55a0b6 commit 9e184c5
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion test/test_reductions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ TEST(MxxReduce, GlobalReduce) {

TEST(MxxReduce, GlobalScan) {
mxx::comm c;
// test reduce with zero elements for some processes
// test scan with zero elements for some processes
size_t n = 0;
int presize = 0;
if (c.rank() % 2 == 0) {
Expand All @@ -273,6 +273,31 @@ TEST(MxxReduce, GlobalScan) {
}
}

TEST(MxxReduce, GlobalScanMin) {
mxx::comm c;
// test scan with min and an array of positive
// elements sorted in ascending order
size_t n = c.size();
std::vector<int> local(n);
for (size_t i = 0; i < n; ++i) {
local[i] = (c.rank()*n)+i+1;
}
// test inplace scan
std::vector<int> local_cpy(local);
mxx::global_scan_inplace(local_cpy.begin(), local_cpy.end(), mxx::min<int>(), c);
for (size_t i = 0; i < n; ++i) {
// 1 is both the first as well as the minimum element
ASSERT_EQ(1, local_cpy[i]);
}
// test scan
std::vector<int> result = mxx::global_scan(local, mxx::min<int>(), c);
ASSERT_EQ(local.size(), result.size());
for (size_t i = 0; i < n; ++i) {
// 1 is both the first as well as the minimum element
ASSERT_EQ(1, result[i]);
}
}

TEST(MxxReduce, GlobalExScan) {
mxx::comm c;
// test reduce with zero elements for some processes
Expand Down

0 comments on commit 9e184c5

Please sign in to comment.