From 2f067487d26dffe1a87c3f191cbfcff7c4096e64 Mon Sep 17 00:00:00 2001 From: Jaydeep Patel Date: Tue, 20 Aug 2024 10:52:08 +0000 Subject: [PATCH] SWDEV-479807 - Skip if peer access is not supported. Change-Id: I2a40976e7e1a4c86c41ea86e87359c7d4b85c6d8 --- catch/performance/memcpy/hipMemcpy.cc | 1 + catch/performance/memcpy/hipMemcpy2D.cc | 1 + catch/performance/memcpy/hipMemcpy2DAsync.cc | 1 + catch/performance/memcpy/hipMemcpy2DFromArray.cc | 1 + catch/performance/memcpy/hipMemcpy2DFromArrayAsync.cc | 3 ++- catch/performance/memcpy/hipMemcpy2DToArray.cc | 1 + catch/performance/memcpy/hipMemcpy2DToArrayAsync.cc | 3 ++- catch/performance/memcpy/hipMemcpy3D.cc | 3 ++- catch/performance/memcpy/hipMemcpy3DAsync.cc | 3 ++- catch/performance/memcpy/hipMemcpyAsync.cc | 3 ++- catch/performance/memcpy/hipMemcpyDtoD.cc | 1 + catch/performance/memcpy/hipMemcpyDtoDAsync.cc | 1 + catch/performance/memcpy/hipMemcpyParam2D.cc | 3 ++- catch/performance/memcpy/hipMemcpyParam2DAsync.cc | 3 ++- catch/performance/memcpy/hipMemcpyWithStream.cc | 3 ++- catch/performance/memcpy/memcpy_performance_common.hh | 6 ++++-- catch/unit/device/hipExtGetLinkTypeAndHopCount.cc | 9 +++++++++ catch/unit/p2p/hipP2pLinkTypeAndHopFunc.cc | 5 +++++ 18 files changed, 41 insertions(+), 10 deletions(-) diff --git a/catch/performance/memcpy/hipMemcpy.cc b/catch/performance/memcpy/hipMemcpy.cc index ab1860df78..fa1c5bbb01 100644 --- a/catch/performance/memcpy/hipMemcpy.cc +++ b/catch/performance/memcpy/hipMemcpy.cc @@ -49,6 +49,7 @@ static void RunBenchmark(LinearAllocs dst_allocation_type, LinearAllocs src_allo } else { int src_device = std::get<0>(GetDeviceIds(enable_peer_access)); int dst_device = std::get<1>(GetDeviceIds(enable_peer_access)); + if (src_device == -1 && dst_device == -1) { return; } LinearAllocGuard src_allocation(src_allocation_type, size); HIP_CHECK(hipSetDevice(dst_device)); diff --git a/catch/performance/memcpy/hipMemcpy2D.cc b/catch/performance/memcpy/hipMemcpy2D.cc index 1253cb038d..2437551480 100644 --- a/catch/performance/memcpy/hipMemcpy2D.cc +++ b/catch/performance/memcpy/hipMemcpy2D.cc @@ -64,6 +64,7 @@ static void RunBenchmark(size_t width, size_t height, hipMemcpyKind kind, bool e // hipMemcpyDeviceToDevice int src_device = std::get<0>(GetDeviceIds(enable_peer_access)); int dst_device = std::get<1>(GetDeviceIds(enable_peer_access)); + if (src_device == -1 && dst_device == -1) { return; } LinearAllocGuard2D src_allocation(width, height); HIP_CHECK(hipSetDevice(dst_device)); diff --git a/catch/performance/memcpy/hipMemcpy2DAsync.cc b/catch/performance/memcpy/hipMemcpy2DAsync.cc index 64d9b1eb84..48742a3d54 100644 --- a/catch/performance/memcpy/hipMemcpy2DAsync.cc +++ b/catch/performance/memcpy/hipMemcpy2DAsync.cc @@ -68,6 +68,7 @@ static void RunBenchmark(size_t width, size_t height, hipMemcpyKind kind, bool e // hipMemcpyDeviceToDevice int src_device = std::get<0>(GetDeviceIds(enable_peer_access)); int dst_device = std::get<1>(GetDeviceIds(enable_peer_access)); + if (src_device == -1 && dst_device == -1) { return; } LinearAllocGuard2D src_allocation(width, height); HIP_CHECK(hipSetDevice(dst_device)); diff --git a/catch/performance/memcpy/hipMemcpy2DFromArray.cc b/catch/performance/memcpy/hipMemcpy2DFromArray.cc index 5227df3430..973ad68d2a 100644 --- a/catch/performance/memcpy/hipMemcpy2DFromArray.cc +++ b/catch/performance/memcpy/hipMemcpy2DFromArray.cc @@ -49,6 +49,7 @@ static void RunBenchmark(size_t width, size_t height, hipMemcpyKind kind, // hipMemcpyDeviceToDevice int src_device = std::get<0>(GetDeviceIds(enable_peer_access)); int dst_device = std::get<1>(GetDeviceIds(enable_peer_access)); + if (src_device == -1 && dst_device == -1) { return; } LinearAllocGuard2D device_allocation(width, height); HIP_CHECK(hipSetDevice(dst_device)); diff --git a/catch/performance/memcpy/hipMemcpy2DFromArrayAsync.cc b/catch/performance/memcpy/hipMemcpy2DFromArrayAsync.cc index cdde049aed..41b56d351c 100644 --- a/catch/performance/memcpy/hipMemcpy2DFromArrayAsync.cc +++ b/catch/performance/memcpy/hipMemcpy2DFromArrayAsync.cc @@ -55,7 +55,8 @@ static void RunBenchmark(size_t width, size_t height, hipMemcpyKind kind, // hipMemcpyDeviceToDevice int src_device = std::get<0>(GetDeviceIds(enable_peer_access)); int dst_device = std::get<1>(GetDeviceIds(enable_peer_access)); - + if (src_device == -1 && dst_device == -1) { return; } + LinearAllocGuard2D device_allocation(width, height); HIP_CHECK(hipSetDevice(dst_device)); ArrayAllocGuard array_allocation(make_hipExtent(width, height, 0), hipArrayDefault); diff --git a/catch/performance/memcpy/hipMemcpy2DToArray.cc b/catch/performance/memcpy/hipMemcpy2DToArray.cc index 5d8e52641a..220b6d665e 100644 --- a/catch/performance/memcpy/hipMemcpy2DToArray.cc +++ b/catch/performance/memcpy/hipMemcpy2DToArray.cc @@ -50,6 +50,7 @@ static void RunBenchmark(size_t width, size_t height, hipMemcpyKind kind, // hipMemcpyDeviceToDevice int src_device = std::get<0>(GetDeviceIds(enable_peer_access)); int dst_device = std::get<1>(GetDeviceIds(enable_peer_access)); + if (src_device == -1 && dst_device == -1) { return; } LinearAllocGuard2D device_allocation(width, height); HIP_CHECK(hipSetDevice(dst_device)); diff --git a/catch/performance/memcpy/hipMemcpy2DToArrayAsync.cc b/catch/performance/memcpy/hipMemcpy2DToArrayAsync.cc index d4ff8f6dab..202e787bc1 100644 --- a/catch/performance/memcpy/hipMemcpy2DToArrayAsync.cc +++ b/catch/performance/memcpy/hipMemcpy2DToArrayAsync.cc @@ -55,7 +55,8 @@ static void RunBenchmark(size_t width, size_t height, hipMemcpyKind kind, // hipMemcpyDeviceToDevice int src_device = std::get<0>(GetDeviceIds(enable_peer_access)); int dst_device = std::get<1>(GetDeviceIds(enable_peer_access)); - + if (src_device == -1 && dst_device == -1) { return; } + LinearAllocGuard2D device_allocation(width, height); HIP_CHECK(hipSetDevice(dst_device)); ArrayAllocGuard array_allocation(make_hipExtent(width, height, 0), hipArrayDefault); diff --git a/catch/performance/memcpy/hipMemcpy3D.cc b/catch/performance/memcpy/hipMemcpy3D.cc index 933282de92..be42fbfc80 100644 --- a/catch/performance/memcpy/hipMemcpy3D.cc +++ b/catch/performance/memcpy/hipMemcpy3D.cc @@ -71,7 +71,8 @@ static void RunBenchmark(const hipExtent extent, hipMemcpyKind kind, bool enable // hipMemcpyDeviceToDevice int src_device = std::get<0>(GetDeviceIds(enable_peer_access)); int dst_device = std::get<1>(GetDeviceIds(enable_peer_access)); - + if (src_device == -1 && dst_device == -1) { return; } + LinearAllocGuard3D src_allocation(extent); HIP_CHECK(hipSetDevice(dst_device)); LinearAllocGuard3D dst_allocation(extent); diff --git a/catch/performance/memcpy/hipMemcpy3DAsync.cc b/catch/performance/memcpy/hipMemcpy3DAsync.cc index afc8257734..2b88cf139d 100644 --- a/catch/performance/memcpy/hipMemcpy3DAsync.cc +++ b/catch/performance/memcpy/hipMemcpy3DAsync.cc @@ -77,7 +77,8 @@ static void RunBenchmark(const hipExtent extent, hipMemcpyKind kind, bool enable // hipMemcpyDeviceToDevice int src_device = std::get<0>(GetDeviceIds(enable_peer_access)); int dst_device = std::get<1>(GetDeviceIds(enable_peer_access)); - + if (src_device == -1 && dst_device == -1) { return; } + LinearAllocGuard3D src_allocation(extent); HIP_CHECK(hipSetDevice(dst_device)); LinearAllocGuard3D dst_allocation(extent); diff --git a/catch/performance/memcpy/hipMemcpyAsync.cc b/catch/performance/memcpy/hipMemcpyAsync.cc index 4e9716a174..96d953902d 100644 --- a/catch/performance/memcpy/hipMemcpyAsync.cc +++ b/catch/performance/memcpy/hipMemcpyAsync.cc @@ -51,7 +51,8 @@ static void RunBenchmark(LinearAllocs dst_allocation_type, LinearAllocs src_allo } else { int src_device = std::get<0>(GetDeviceIds(enable_peer_access)); int dst_device = std::get<1>(GetDeviceIds(enable_peer_access)); - + if (src_device == -1 && dst_device == -1) { return; } + LinearAllocGuard src_allocation(src_allocation_type, size); HIP_CHECK(hipSetDevice(dst_device)); LinearAllocGuard dst_allocation(dst_allocation_type, size); diff --git a/catch/performance/memcpy/hipMemcpyDtoD.cc b/catch/performance/memcpy/hipMemcpyDtoD.cc index eebb2016ba..505a82d628 100644 --- a/catch/performance/memcpy/hipMemcpyDtoD.cc +++ b/catch/performance/memcpy/hipMemcpyDtoD.cc @@ -40,6 +40,7 @@ static void RunBenchmark(size_t size, bool enable_peer_access=false) { int src_device = std::get<0>(GetDeviceIds(enable_peer_access)); int dst_device = std::get<1>(GetDeviceIds(enable_peer_access)); + if (src_device == -1 && dst_device == -1) { return; } LinearAllocGuard src_allocation(LinearAllocs::hipMalloc, size); HIP_CHECK(hipSetDevice(dst_device)); diff --git a/catch/performance/memcpy/hipMemcpyDtoDAsync.cc b/catch/performance/memcpy/hipMemcpyDtoDAsync.cc index d3448d229b..c8c03bf1ca 100644 --- a/catch/performance/memcpy/hipMemcpyDtoDAsync.cc +++ b/catch/performance/memcpy/hipMemcpyDtoDAsync.cc @@ -43,6 +43,7 @@ static void RunBenchmark(size_t size, bool enable_peer_access=false) { const hipStream_t stream = stream_guard.stream(); int src_device = std::get<0>(GetDeviceIds(enable_peer_access)); int dst_device = std::get<1>(GetDeviceIds(enable_peer_access)); + if (src_device == -1 && dst_device == -1) { return; } LinearAllocGuard src_allocation(LinearAllocs::hipMalloc, size); HIP_CHECK(hipSetDevice(dst_device)); diff --git a/catch/performance/memcpy/hipMemcpyParam2D.cc b/catch/performance/memcpy/hipMemcpyParam2D.cc index cd8db7d353..be4bcc2f1b 100644 --- a/catch/performance/memcpy/hipMemcpyParam2D.cc +++ b/catch/performance/memcpy/hipMemcpyParam2D.cc @@ -64,7 +64,8 @@ static void RunBenchmark(size_t width, size_t height, hipMemcpyKind kind, // hipMemcpyDeviceToDevice int src_device = std::get<0>(GetDeviceIds(enable_peer_access)); int dst_device = std::get<1>(GetDeviceIds(enable_peer_access)); - + if (src_device == -1 && dst_device == -1) { return; } + LinearAllocGuard2D src_allocation(width, height); HIP_CHECK(hipSetDevice(dst_device)); LinearAllocGuard2D dst_allocation(width, height); diff --git a/catch/performance/memcpy/hipMemcpyParam2DAsync.cc b/catch/performance/memcpy/hipMemcpyParam2DAsync.cc index 42221fca82..53faf9d2ad 100644 --- a/catch/performance/memcpy/hipMemcpyParam2DAsync.cc +++ b/catch/performance/memcpy/hipMemcpyParam2DAsync.cc @@ -70,7 +70,8 @@ static void RunBenchmark(size_t width, size_t height, hipMemcpyKind kind, // hipMemcpyDeviceToDevice int src_device = std::get<0>(GetDeviceIds(enable_peer_access)); int dst_device = std::get<1>(GetDeviceIds(enable_peer_access)); - + if (src_device == -1 && dst_device == -1) { return; } + LinearAllocGuard2D src_allocation(width, height); HIP_CHECK(hipSetDevice(dst_device)); LinearAllocGuard2D dst_allocation(width, height); diff --git a/catch/performance/memcpy/hipMemcpyWithStream.cc b/catch/performance/memcpy/hipMemcpyWithStream.cc index 97693e72b0..e744fb25b1 100644 --- a/catch/performance/memcpy/hipMemcpyWithStream.cc +++ b/catch/performance/memcpy/hipMemcpyWithStream.cc @@ -51,7 +51,8 @@ static void RunBenchmark(LinearAllocs dst_allocation_type, LinearAllocs src_allo } else { int src_device = std::get<0>(GetDeviceIds(enable_peer_access)); int dst_device = std::get<1>(GetDeviceIds(enable_peer_access)); - + if (src_device == -1 && dst_device == -1) { return; } + LinearAllocGuard src_allocation(LinearAllocs::hipMalloc, size); HIP_CHECK(hipSetDevice(dst_device)); LinearAllocGuard dst_allocation(LinearAllocs::hipMalloc, size); diff --git a/catch/performance/memcpy/memcpy_performance_common.hh b/catch/performance/memcpy/memcpy_performance_common.hh index c70cc95cf9..4abfbe37f6 100644 --- a/catch/performance/memcpy/memcpy_performance_common.hh +++ b/catch/performance/memcpy/memcpy_performance_common.hh @@ -93,8 +93,10 @@ static std::tuple GetDeviceIds(bool enable_peer_access) { int can_access_peer = 0; HIP_CHECK(hipDeviceCanAccessPeer(&can_access_peer, src_device, dst_device)); if (!can_access_peer) { - INFO("Peer access cannot be enabled between devices " << src_device << " and " << dst_device); - REQUIRE(can_access_peer); + std::string msg = "Skipped as peer access cannot be enabled between devices " + + std::to_string(src_device) + " " + std::to_string(dst_device); + HipTest::HIP_SKIP_TEST(msg.c_str()); + return {-1, -1}; } HIP_CHECK(hipDeviceEnablePeerAccess(dst_device, 0)); } else { diff --git a/catch/unit/device/hipExtGetLinkTypeAndHopCount.cc b/catch/unit/device/hipExtGetLinkTypeAndHopCount.cc index 8417759ed0..5f3dd1454e 100644 --- a/catch/unit/device/hipExtGetLinkTypeAndHopCount.cc +++ b/catch/unit/device/hipExtGetLinkTypeAndHopCount.cc @@ -53,6 +53,15 @@ TEST_CASE("Unit_hipExtGetLinkTypeAndHopCount_Positive_Basic") { return; } + int can_access_peer = 0; + HIP_CHECK(hipDeviceCanAccessPeer(&can_access_peer, device1, device2)); + if (!can_access_peer) { + std::string msg = "Skipped as peer access is not supported between devices : " + + std::to_string(device1) + " " + std::to_string(device2); + HipTest::HIP_SKIP_TEST(msg.c_str()); + return; + } + uint32_t link_type1 = -1, hop_count1 = -1; uint32_t link_type2 = -1, hop_count2 = -1; diff --git a/catch/unit/p2p/hipP2pLinkTypeAndHopFunc.cc b/catch/unit/p2p/hipP2pLinkTypeAndHopFunc.cc index 7624cf0507..d97319b2e4 100644 --- a/catch/unit/p2p/hipP2pLinkTypeAndHopFunc.cc +++ b/catch/unit/p2p/hipP2pLinkTypeAndHopFunc.cc @@ -252,6 +252,11 @@ bool testhipLinkTypeHopcountDevice(int numDevices) { } for (auto pos=devicePairList.begin(); pos != devicePairList.end(); pos++) { + int can_access_peer = 0; + HIP_CHECK(hipDeviceCanAccessPeer(&can_access_peer, (*pos).device1, (*pos).device2)); + if (!can_access_peer) { + continue; + } uint32_t linktype1 = 0; uint32_t hopcount1 = 0; RSMI_IO_LINK_TYPE linktype2 = RSMI_IOLINK_TYPE_UNDEFINED;