From 88f4bb19883f04524c32564792bb411a7050b440 Mon Sep 17 00:00:00 2001 From: Julia Jiang <56359287+jujiang-del@users.noreply.github.com> Date: Mon, 5 Jan 2026 12:36:31 -0500 Subject: [PATCH] SWDEV-564412 - fix test failure on hipSetValidDevices_with_hipMemcpyPeer (#2150) --- .../catch/unit/device/hipSetValidDevices.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/projects/hip-tests/catch/unit/device/hipSetValidDevices.cc b/projects/hip-tests/catch/unit/device/hipSetValidDevices.cc index 25eb63b648..5990e059fa 100644 --- a/projects/hip-tests/catch/unit/device/hipSetValidDevices.cc +++ b/projects/hip-tests/catch/unit/device/hipSetValidDevices.cc @@ -430,7 +430,15 @@ TEST_CASE("Unit_hipSetValidDevices_with_hipMemcpyPeer") { HipTest::HIP_SKIP_TEST("Skipping, as this test requires more than 2 GPUs"); return; } - + int canAccessPeer = -1; + HIP_CHECK(hipDeviceCanAccessPeer(&canAccessPeer, 1, 0)); + if (!canAccessPeer) { + std::string msg = "Device is not capable of directly accessing memory from peerDevice. Skipping the test."; + HipTest::HIP_SKIP_TEST(msg.c_str()); + return; + } + REQUIRE(canAccessPeer == 1); + HIP_CHECK(hipDeviceEnablePeerAccess(1, 0)); REQUIRE(getCurrentDevice() == 0); int* dev0_Arr = nullptr; @@ -453,10 +461,6 @@ TEST_CASE("Unit_hipSetValidDevices_with_hipMemcpyPeer") { HIP_CHECK(hipMalloc(&dev1_Arr, NBYTES)); REQUIRE(dev1_Arr != nullptr); - int canAccessPeer = -1; - HIP_CHECK(hipDeviceCanAccessPeer(&canAccessPeer, 1, 0)); - REQUIRE(canAccessPeer == 1); - HIP_CHECK(hipMemcpyPeer(dev1_Arr, 1, dev0_Arr, 0, N * sizeof(int))); int dstHostMem[N]; @@ -468,4 +472,6 @@ TEST_CASE("Unit_hipSetValidDevices_with_hipMemcpyPeer") { for (int i = 0; i < N; i++) { REQUIRE(dstHostMem[i] == 5); } + HIP_CHECK(hipFree(dev0_Arr)); + HIP_CHECK(hipFree(dev1_Arr)); }