Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions sycl/source/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,12 @@ void device::ext_oneapi_disable_peer_access(const device &peer) {

bool device::ext_oneapi_can_access_peer(const device &peer,
ext::oneapi::peer_access attr) {
// Peer access cannot be granted across platforms, but the handles could
// potentially mimic device handles from other adapters, so we need to avoid
// calling the adapters with handles from other platforms.
if (peer.get_platform() != get_platform())
return false;

ur_device_handle_t Device = impl->getHandleRef();
ur_device_handle_t Peer = peer.impl->getHandleRef();

Expand Down
28 changes: 28 additions & 0 deletions sycl/test-e2e/USM/P2P/p2p_access_across_platforms.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out

// Tests that P2P access is not reported as possible across platforms.

#include <cassert>
#include <sycl/detail/core.hpp>
#include <sycl/platform.hpp>

int main() {
sycl::device D1;
sycl::device D2 = D1;
for (sycl::platform P : sycl::platform::get_platforms()) {
if (P != D1.get_platform() && !P.get_devices().empty()) {
D2 = P.get_devices()[0];
break;
}
}

if (D1 == D2) {
std::cout << "There are no devices from different platforms. Skipping."
<< std::endl;
return 0;
}

assert(!D1.ext_oneapi_can_access_peer(D2));
return 0;
}