From 901da47ebd90c9dd46564ff50b7d01745a34433b Mon Sep 17 00:00:00 2001 From: ROCm CI Service Account <66695075+rocm-ci@users.noreply.github.com> Date: Wed, 29 Jun 2022 02:06:26 +0530 Subject: [PATCH] SWDEV-339742 - Check can access before set device to 1. (#2758) Change-Id: I5b06f98b0061ee162488e288c3bfac09ff4f94cf [ROCm/hip commit: 60b60f78e6b8ed3fb2e64388b5f27771a16673e8] --- .../tests/catch/unit/memory/hipPtrGetAttribute.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/projects/hip/tests/catch/unit/memory/hipPtrGetAttribute.cc b/projects/hip/tests/catch/unit/memory/hipPtrGetAttribute.cc index 99dbc5ab8d..eaf4c8b153 100644 --- a/projects/hip/tests/catch/unit/memory/hipPtrGetAttribute.cc +++ b/projects/hip/tests/catch/unit/memory/hipPtrGetAttribute.cc @@ -122,10 +122,14 @@ TEST_CASE("Unit_hipPtrGetAttribute_Simple") { // HIP_POINTER_ATTRIBUTE_DEVICE_ORDINAL if (numDevices > 1) { - HIP_CHECK(hipSetDevice(1)); - HIP_CHECK(hipPointerGetAttribute(&datatype, HIP_POINTER_ATTRIBUTE_DEVICE_ORDINAL, - reinterpret_cast(A_d))); - REQUIRE(datatype == 0); + int canAccess = -1; + HIP_CHECK(hipDeviceCanAccessPeer(&canAccess, 1, 0)); + if (canAccess == 1) { + HIP_CHECK(hipSetDevice(1)); + HIP_CHECK(hipPointerGetAttribute(&datatype, HIP_POINTER_ATTRIBUTE_DEVICE_ORDINAL, + reinterpret_cast(A_d))); + REQUIRE(datatype == 0); + } } // HIP_POINTER_ATTRIBUTE_MAPPED