Skip to content

Commit 2085917

Browse files
committed
Relax assumptions about allocation addresses in runtime lookahead test
1 parent 23b4e47 commit 2085917

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

test/runtime_tests.cc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,19 +1000,25 @@ namespace detail {
10001000
queue q;
10011001
experimental::set_lookahead(q, lookahead);
10021002

1003+
// We access two distinct buffers in a growing pattern, which means if any of them are reallocated we can be pretty sure that adjacent elements do not
1004+
// end up at consecutive memory addresses (SimSYCL does not page-align allocations, so we get an alternating <buf1><buf2><buf1>... pattern).
10031005
constexpr size_t n_timesteps = 20;
10041006
buffer<const void*> pointer_buf(n_timesteps);
1007+
buffer<const void*> dummy_buf(n_timesteps);
10051008
for(size_t i = 0; i < n_timesteps; ++i) {
10061009
q.submit([&, i](handler& cgh) {
1007-
accessor acc(pointer_buf, cgh, fixed<1>({i, 1}), write_only, no_init);
1008-
cgh.parallel_for(1, [=](item<1> item) { acc[i] = &acc[i]; });
1010+
accessor pointers(pointer_buf, cgh, fixed<1>({i, 1}), write_only, no_init);
1011+
accessor dummy(dummy_buf, cgh, fixed<1>({i, 1}), write_only, no_init);
1012+
cgh.parallel_for(1, [=](item<1> item) {
1013+
pointers[i] = &pointers[i];
1014+
(void)dummy[i];
1015+
});
10091016
});
10101017
}
10111018

10121019
const auto pointers = q.fence(pointer_buf).get();
10131020
bool is_single_allocation = pointers[0] != nullptr;
10141021
for(size_t i = 1; i < n_timesteps; ++i) {
1015-
// assuming that allocations are page-aligned, they cannot end up on consecutive memory addresses
10161022
is_single_allocation &= (pointers[i] == utils::offset(pointers[i - 1], sizeof(const void*)));
10171023
}
10181024
CHECK(is_single_allocation == (lookahead != experimental::lookahead::none));

0 commit comments

Comments
 (0)