From 9bc8db5ffdb179c69585167cdb9658f2deb5c7b7 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-tests commit: ed9c22eee8e62333d0cc9e7af403015a0b7d4bd5] --- .../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