@@ -1000,19 +1000,25 @@ namespace detail {
1000
1000
queue q;
1001
1001
experimental::set_lookahead (q, lookahead);
1002
1002
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).
1003
1005
constexpr size_t n_timesteps = 20 ;
1004
1006
buffer<const void *> pointer_buf (n_timesteps);
1007
+ buffer<const void *> dummy_buf (n_timesteps);
1005
1008
for (size_t i = 0 ; i < n_timesteps; ++i) {
1006
1009
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
+ });
1009
1016
});
1010
1017
}
1011
1018
1012
1019
const auto pointers = q.fence (pointer_buf).get ();
1013
1020
bool is_single_allocation = pointers[0 ] != nullptr ;
1014
1021
for (size_t i = 1 ; i < n_timesteps; ++i) {
1015
- // assuming that allocations are page-aligned, they cannot end up on consecutive memory addresses
1016
1022
is_single_allocation &= (pointers[i] == utils::offset (pointers[i - 1 ], sizeof (const void *)));
1017
1023
}
1018
1024
CHECK (is_single_allocation == (lookahead != experimental::lookahead::none));
0 commit comments