Skip to content

Commit 42c588c

Browse files
authored
mhp::halo tests working on device memory and on ishmem backend (#724)
1 parent 15d3c89 commit 42c588c

File tree

5 files changed

+40
-23
lines changed

5 files changed

+40
-23
lines changed

CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ function(add_mhp_ctest_impl)
198198
endif()
199199

200200
if(AMC_DRLOGS)
201+
set(AMC_TEST_NAME "${AMC_TEST_NAME}-log")
201202
set(drlogs_param --log --logprefix=${AMC_TEST_NAME})
202203
endif()
203204

@@ -219,7 +220,7 @@ function(add_mhp_ctest_impl)
219220
${MPIEXEC_PREFLAGS} ${extra_mpiflags} ${wrapper_script} ./${AMC_NAME}
220221
${drlogs_param} ${sycl_param} ${AMC_TARGS} COMMAND_EXPAND_LISTS)
221222

222-
if(NOT AMC_GDB)
223+
if(NOT AMC_GDB AND NOT AMC_DRLOGS)
223224
set_property(TEST ${AMC_TEST_NAME} PROPERTY LABELS TESTLABEL MHP)
224225
endif()
225226
add_dependencies(mhp-all-tests ${AMC_NAME})
@@ -228,6 +229,8 @@ endfunction()
228229
function(add_mhp_ctest)
229230
add_mhp_ctest_impl(${ARGN})
230231
add_mhp_ctest_impl(${ARGN} GDB)
232+
add_mhp_ctest_impl(${ARGN} GDB DRLOGS)
233+
add_mhp_ctest_impl(${ARGN} DRLOGS)
231234
endfunction()
232235

233236
if(ENABLE_ISHMEM)

include/dr/mhp/halo.hpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,18 @@ template <typename Group> class halo_impl {
6464

6565
/// Begin a halo exchange
6666
void exchange_begin() {
67-
drlog.debug("Halo exchange begin\n");
67+
DRLOG("Halo exchange receiving");
6868
receive(halo_groups_);
69+
DRLOG("Halo exchange sending");
6970
send(owned_groups_);
71+
DRLOG("Halo exchange begin finished");
7072
}
7173

7274
/// Complete a halo exchange
7375
void exchange_finalize() {
76+
DRLOG("Halo exchange finalize started");
7477
reduce_finalize();
75-
drlog.debug("Halo exchange finalize\n");
78+
DRLOG("Halo exchange finalize finished");
7679
}
7780

7881
void exchange() {
@@ -92,7 +95,7 @@ template <typename Group> class halo_impl {
9295
int completed;
9396
MPI_Waitany(rng::size(requests_), requests_.data(), &completed,
9497
MPI_STATUS_IGNORE);
95-
drlog.debug("Completed: {}\n", completed);
98+
DRLOG("reduce_finalize(op) waitany completed: {}", completed);
9699
auto &g = *map_[completed];
97100
if (g.receive && g.buffered) {
98101
g.unpack(op);
@@ -106,7 +109,7 @@ template <typename Group> class halo_impl {
106109
int completed;
107110
MPI_Waitany(rng::size(requests_), requests_.data(), &completed,
108111
MPI_STATUS_IGNORE);
109-
drlog.debug("Completed: {}\n", completed);
112+
DRLOG("reduce_finalize() waitany completed: {}", completed);
110113
auto &g = *map_[completed];
111114
if (g.receive && g.buffered) {
112115
g.unpack();
@@ -146,7 +149,7 @@ template <typename Group> class halo_impl {
146149
for (auto &g : sends) {
147150
g.pack();
148151
g.receive = false;
149-
drlog.debug("Sending: {}\n", g.request_index);
152+
DRLOG("sending: {}", g.request_index);
150153
comm_.isend(g.data_pointer(), g.data_size(), g.rank(), g.tag(),
151154
&requests_[g.request_index]);
152155
}
@@ -155,7 +158,7 @@ template <typename Group> class halo_impl {
155158
void receive(std::vector<Group> &receives) {
156159
for (auto &g : receives) {
157160
g.receive = true;
158-
drlog.debug("Receiving: {}\n", g.request_index);
161+
DRLOG("receiving: {}", g.request_index);
159162
comm_.irecv(g.data_pointer(), g.data_size(), g.rank(), g.tag(),
160163
&requests_[g.request_index]);
161164
}

test/gtest/mhp/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ add_executable(
5656

5757
add_executable(mhp-quick-test
5858
mhp-tests.cpp
59-
../common/exclusive_scan.cpp
60-
../common/inclusive_scan.cpp
59+
halo.cpp
6160
)
6261
# cmake-format: on
6362

@@ -101,6 +100,10 @@ if(ENABLE_SYCL)
101100

102101
add_mhp_ctest(NAME mhp-quick-test NPROC 1 SYCL)
103102
add_mhp_ctest(NAME mhp-quick-test NPROC 2 SYCL)
103+
add_mhp_ctest(
104+
NAME mhp-quick-test NPROC 1 OFFLOAD SYCL TARGS --device-memory)
105+
add_mhp_ctest(
106+
NAME mhp-quick-test NPROC 2 OFFLOAD SYCL TARGS --device-memory)
104107

105108
add_mhp_ctest(
106109
NAME mhp-tests NPROC 2 OFFLOAD SYCL TARGS --device-memory

test/gtest/mhp/halo.cpp

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66

77
template <typename T> class Halo : public testing::Test {};
88

9-
// segfault with ISHMEM
10-
TYPED_TEST_SUITE(Halo, AllTypesWithoutIshmem);
9+
TYPED_TEST_SUITE(Halo, AllTypes);
1110

1211
template <typename DV>
1312
void local_is_accessible_in_halo_region(const int halo_prev,
1413
const int halo_next) {
15-
if (options.count("device-memory")) {
16-
return;
17-
}
14+
1815
DV dv(6, dr::mhp::distribution().halo(halo_prev, halo_next));
16+
DRLOG("local_is_accessible_in_halo_region TEST START, prev:{}, next:{}",
17+
halo_prev, halo_next);
1918
iota(dv, 0);
19+
DRLOG("exchange start");
2020
dv.halo().exchange();
2121

2222
// arrays below is function depending on size of communicator-1
@@ -58,16 +58,24 @@ void local_is_accessible_in_halo_region(const int halo_prev,
5858
auto first_legal_idx = std::max(0, first_local_index___[c] - halo_prev);
5959
auto first_illegal_idx = std::min(6, first_nonlocal_index[c] + halo_next);
6060

61-
dr::drlog.debug(
62-
"checking access to idx between first legal {} and first illegal {}\n",
63-
first_legal_idx, first_illegal_idx);
61+
DRLOG("checking access to idx between first legal {} and first illegal {}, "
62+
"c:{}",
63+
first_legal_idx, first_illegal_idx, c);
6464

6565
for (int idx = first_legal_idx; idx < first_illegal_idx; ++idx) {
66-
dr::drlog.debug("checking idx:{}\n", idx);
67-
EXPECT_TRUE((dv.begin() + idx).local() != nullptr);
68-
EXPECT_EQ(*(dv.begin() + idx).local(), idx);
66+
typename DV::value_type *local_ptr = (dv.begin() + idx).local();
67+
EXPECT_TRUE(local_ptr != nullptr);
68+
typename DV::value_type value_on_host;
69+
70+
if (dr::mhp::use_sycl())
71+
dr::mhp::__detail::sycl_copy(local_ptr, &value_on_host);
72+
else
73+
value_on_host = *local_ptr;
74+
75+
DRLOG("checking idx:{}", idx);
76+
EXPECT_EQ(value_on_host, idx);
6977
}
70-
dr::drlog.debug("checks ok\n");
78+
DRLOG("checks ok");
7179

7280
// although assertions indeed happen, but they are not caught by EXPECT_DEATH
7381
// if (first_illegal_idx < 6) {

test/gtest/mhp/xhp-tests.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ inline void fence_on(auto &&obj) { obj.fence(); }
3939
// minimal testing for quick builds
4040
#ifdef DRISHMEM
4141
using AllTypes =
42-
::testing::Types<dr::mhp::distributed_vector<int>,
43-
dr::mhp::distributed_vector<int, dr::mhp::IshmemBackend>>;
42+
::testing::Types<dr::mhp::distributed_vector<int, dr::mhp::IshmemBackend>,
43+
dr::mhp::distributed_vector<int>>;
4444
using IshmemTypes =
4545
::testing::Types<dr::mhp::distributed_vector<int, dr::mhp::IshmemBackend>>;
4646
#else

0 commit comments

Comments
 (0)