Skip to content

Commit 4600310

Browse files
committed
#2281: add perf tests for MPI_Allreduce
1 parent eee5e69 commit 4600310

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/perf/allreduce.cc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,17 @@ struct NodeObj {
112112
bool allreduce_done_ = false;
113113
};
114114

115+
VT_PERF_TEST(MyTest, test_mpi_allreduce) {
116+
for (auto payload_size : payloadSizes) {
117+
data.resize(payload_size, theContext()->getNode() + 1);
118+
std::vector<int> result(payload_size);
119+
MPI_Barrier(MPI_COMM_WORLD);
120+
StartTimer("MPI_Allreduce vector " + std::to_string(payload_size));
121+
MPI_Allreduce(data.data(), result.data(), payload_size, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
122+
StopTimer("MPI_Allreduce vector " + std::to_string(payload_size));
123+
}
124+
}
125+
115126
VT_PERF_TEST(MyTest, test_reduce) {
116127
auto grp_proxy = vt::theObjGroup()->makeCollective<NodeObj<MyTest>>(
117128
"test_allreduce", this, "Reduce -> Bcast vector");
@@ -138,6 +149,17 @@ struct MyTestKokkos : PerfTestHarness {
138149
Kokkos::View<float*, Kokkos::HostSpace> view;
139150
};
140151

152+
VT_PERF_TEST(MyTestKokkos, test_mpi_allreduce_kokkos) {
153+
for (auto payload_size : payloadSizes) {
154+
view = Kokkos::View<float*, Kokkos::HostSpace>("view", payload_size);
155+
auto result = Kokkos::View<float*, Kokkos::HostSpace>("result", payload_size);
156+
MPI_Barrier(MPI_COMM_WORLD);
157+
StartTimer("MPI_Allreduce view " + std::to_string(payload_size));
158+
MPI_Allreduce(view.data(), result.data(), payload_size, MPI_FLOAT, MPI_SUM, MPI_COMM_WORLD);
159+
StopTimer("MPI_Allreduce view " + std::to_string(payload_size));
160+
}
161+
}
162+
141163
VT_PERF_TEST(MyTestKokkos, test_reduce_kokkos) {
142164
auto grp_proxy = vt::theObjGroup()->makeCollective<NodeObj<MyTestKokkos>>(
143165
"test_allreduce", this, "Reduce -> Bcast view");

0 commit comments

Comments
 (0)