diff --git a/catch/include/hip_test_common.hh b/catch/include/hip_test_common.hh index d2cd7ec4e1..cb04ec0790 100644 --- a/catch/include/hip_test_common.hh +++ b/catch/include/hip_test_common.hh @@ -323,6 +323,26 @@ inline bool isPcieAtomicsSupported() { return pcieAtomics != 0; } +inline bool isP2PSupported(int& d1, int& d2) { + int num_devices = HipTest::getDeviceCount(); + int supported = 1; + for (auto i = 0u; i < num_devices; ++i) { + int canAccess = 0; + for (auto j = 0u; j < num_devices; ++j) { + if (i != j) { + HIP_CHECK(hipDeviceCanAccessPeer(&canAccess, i, j)); + if (!canAccess) { + supported = 0; + d1 = i; + d2 = j; + break; + } + } + } + } + return supported; +} + inline bool areWarpMatchFunctionsSupported() { int matchFunctionsSupported = 1; #if HT_NVIDIA @@ -516,6 +536,14 @@ class BlockingContext { return; \ } +#define CHECK_P2P_SUPPORT \ + int d1, d2; \ + if (!HipTest::isP2PSupported(d1,d2)) { \ + std::string msg = "P2P access check failed between dev1:" + std::to_string(d1) + ",dev2:" + \ + std::to_string(d2); \ + HipTest::HIP_SKIP_TEST(msg.c_str()); \ + return; \ + } \ // This must be called in the beginning of warp test app's main() to indicate warp match functions // are supported. #define CHECK_WARP_MATCH_FUNCTIONS_SUPPORT \ diff --git a/catch/unit/atomics/arithmetic_common.hh b/catch/unit/atomics/arithmetic_common.hh index 3ff5bb4d7d..85f4e25ab0 100644 --- a/catch/unit/atomics/arithmetic_common.hh +++ b/catch/unit/atomics/arithmetic_common.hh @@ -580,6 +580,8 @@ void MultipleDeviceMultipleKernelAndHostTest(const unsigned int num_devices, } } + CHECK_P2P_SUPPORT + if (kernel_count > 1) { for (auto i = 0u; i < num_devices; ++i) { int canAccess = 0; diff --git a/catch/unit/atomics/atomicExch_common.hh b/catch/unit/atomics/atomicExch_common.hh index 29e3605a47..ba3105de63 100644 --- a/catch/unit/atomics/atomicExch_common.hh +++ b/catch/unit/atomics/atomicExch_common.hh @@ -395,6 +395,8 @@ void AtomicExchMultipleDeviceMultipleKernelAndHostTest(const unsigned int num_de } } + CHECK_P2P_SUPPORT + if (kernel_count > 1) { for (auto i = 0u; i < num_devices; ++i) { int canAccess = 0; diff --git a/catch/unit/atomics/min_max_common.hh b/catch/unit/atomics/min_max_common.hh index 5ca88d4f25..f6a075680e 100644 --- a/catch/unit/atomics/min_max_common.hh +++ b/catch/unit/atomics/min_max_common.hh @@ -422,6 +422,8 @@ void MultipleDeviceMultipleKernelTest(const unsigned int num_devices, } } + CHECK_P2P_SUPPORT + if (kernel_count > 1) { for (auto i = 0u; i < num_devices; ++i) { int canAccess = 0;