Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions sycl/test-e2e/USM/P2P/p2p_atomics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ int main() {
h_sum += value;
}

int *d_sum = malloc_shared<int>(1, Queues[0]);
int *d_sum = malloc_device<int>(1, Queues[0]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we first check if malloc_device is even supported on the device? Like:

if (dev.get_info<info::device::usm_device_allocations>())
...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be a separate change - we're already using it on the next line.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JackAKirk Please update this test (and other P2P tests, if applicable) to also check if device allocations are supported on the device(s).

int *d_in = malloc_device<int>(N, Queues[0]);

Queues[0].single_task([=]() { *d_sum = 0; });
Queues[0].memcpy(d_in, &input[0], N * sizeof(int));
Queues[0].wait();

range global_range{N};

*d_sum = 0.;
Queues[1].submit([&](handler &h) {
h.parallel_for<class peer_atomic>(global_range, [=](id<1> i) {
sycl::atomic_ref<int, sycl::memory_order::relaxed,
Expand All @@ -68,7 +68,10 @@ int main() {
});
Queues[1].wait();

assert(*d_sum == h_sum);
int result = 0;
Queues[0].memcpy(&result, d_sum, sizeof(int)).wait();

assert(result == h_sum);

free(d_sum, Queues[0]);
free(d_in, Queues[0]);
Expand Down