diff --git a/bin/hipvars.pm b/bin/hipvars.pm index 19656a11f3..57ad73b834 100644 --- a/bin/hipvars.pm +++ b/bin/hipvars.pm @@ -26,7 +26,7 @@ use Cwd; use File::Basename; $HIP_BASE_VERSION_MAJOR = "5"; -$HIP_BASE_VERSION_MINOR = "4"; +$HIP_BASE_VERSION_MINOR = "5"; $HIP_BASE_VERSION_PATCH = "0"; #--- diff --git a/tests/catch/unit/device/CMakeLists.txt b/tests/catch/unit/device/CMakeLists.txt index 2bc7ea2498..ce00c290e5 100644 --- a/tests/catch/unit/device/CMakeLists.txt +++ b/tests/catch/unit/device/CMakeLists.txt @@ -18,6 +18,8 @@ set(TEST_SRC hipDeviceGetUuid.cc hipDeviceGetP2PAttribute.cc hipDeviceGetDefaultMemPool.cc + hipDeviceCanAccessPeer.cc + hipDeviceEnableDisablePeerAccess.cc hipExtGetLinkTypeAndHopCount.cc hipDeviceSetLimit.cc hipDeviceSetGetMemPool.cc diff --git a/tests/catch/unit/device/hipDeviceCanAccessPeer.cc b/tests/catch/unit/device/hipDeviceCanAccessPeer.cc new file mode 100644 index 0000000000..5945d51224 --- /dev/null +++ b/tests/catch/unit/device/hipDeviceCanAccessPeer.cc @@ -0,0 +1,79 @@ +/* +Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include +#include + +/* + Positive tests: + - for each peer check other peer access + + Negative tests: + - canAccessPeer pointer is nullptr + - deviceId is invalid + - peerDeviceId is invalid +*/ + +TEST_CASE("Unit_hipDeviceCanAccessPeer_positive") { + int canAccessPeer = 0; + int deviceCount = HipTest::getGeviceCount(); + if (deviceCount < 2) { + HipTest::HIP_SKIP_TEST("Skipping because devices < 2"); + return; + } + + int dev = GENERATE(range(0, HipTest::getGeviceCount())); + int peerDev = GENERATE(range(0, HipTest::getGeviceCount())); + + HIP_CHECK(hipDeviceCanAccessPeer(&canAccessPeer, dev, peerDev)); + if (dev != peerDev) { + REQUIRE(canAccessPeer >= 0); + } + else + { + REQUIRE(canAccessPeer == 0); + } +} + + +TEST_CASE("Unit_hipDeviceCanAccessPeer_negative") { + int canAccessPeer = 0; + int deviceCount = HipTest::getGeviceCount(); + if (deviceCount < 2) { + HipTest::HIP_SKIP_TEST("Skipping because devices < 2"); + return; + } + + SECTION("canAccessPeer is nullptr") { + HIP_CHECK_ERROR(hipDeviceCanAccessPeer(nullptr, 0, 1), hipErrorInvalidValue); + } + + SECTION("deviceId is invalid") { + HIP_CHECK_ERROR(hipDeviceCanAccessPeer(&canAccessPeer, -1, 1), hipErrorInvalidDevice); + HIP_CHECK_ERROR(hipDeviceCanAccessPeer(&canAccessPeer, deviceCount, 1), hipErrorInvalidDevice); + } + + SECTION("peerDeviceId is invalid") { + HIP_CHECK_ERROR(hipDeviceCanAccessPeer(&canAccessPeer, 0, -1), hipErrorInvalidDevice); + HIP_CHECK_ERROR(hipDeviceCanAccessPeer(&canAccessPeer, 0, deviceCount), hipErrorInvalidDevice); + } +} diff --git a/tests/catch/unit/device/hipDeviceEnableDisablePeerAccess.cc b/tests/catch/unit/device/hipDeviceEnableDisablePeerAccess.cc new file mode 100644 index 0000000000..491515163f --- /dev/null +++ b/tests/catch/unit/device/hipDeviceEnableDisablePeerAccess.cc @@ -0,0 +1,104 @@ +/* +Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include +#include + +/* + Positive tests: + - for each peer change and check other peer access + + Negative tests: + - peerDeviceId is invalid + - flag value is invalid + - peer access is enabled/disabled twice + - peer access is disabled before being enabled +*/ +TEST_CASE("Unit_hipDeviceEnableDisablePeerAccess_positive") { + int canAccessPeer = 0; + int deviceCount = HipTest::getGeviceCount(); + if (deviceCount < 2) { + HipTest::HIP_SKIP_TEST("Skipping because devices < 2"); + return; + } + + int dev = GENERATE(range(0, HipTest::getGeviceCount())); + int peerDev = GENERATE(range(0, HipTest::getGeviceCount())); + + if (dev != peerDev) { + HIP_CHECK(hipSetDevice(dev)); + HIP_CHECK(hipDeviceCanAccessPeer(&canAccessPeer, dev, peerDev)); + if (canAccessPeer == 0) { + HipTest::HIP_SKIP_TEST("Skipping because no P2P support"); + return; + } + HIP_CHECK(hipDeviceEnablePeerAccess(peerDev, 0)); + HIP_CHECK(hipDeviceDisablePeerAccess(peerDev)); + } +} + + +TEST_CASE("Unit_hipDeviceEnablePeerAccess_negative") { + int deviceCount = HipTest::getGeviceCount(); + if (deviceCount < 2) { + HipTest::HIP_SKIP_TEST("Skipping because devices < 2"); + return; + } + + SECTION("peerDeviceId is invalid") { + HIP_CHECK_ERROR(hipDeviceEnablePeerAccess(-1, 0), hipErrorInvalidDevice); + HIP_CHECK_ERROR(hipDeviceEnablePeerAccess(deviceCount, 0), hipErrorInvalidDevice); + } + SECTION("Flag is invalid") { + HIP_CHECK(hipSetDevice(0)); + HIP_CHECK_ERROR(hipDeviceEnablePeerAccess(0, -1), hipErrorInvalidValue); + } + SECTION("Peer Access already enabled") { + HIP_CHECK(hipSetDevice(0)); + HIP_CHECK(hipDeviceEnablePeerAccess(1, 0)); + HIP_CHECK_ERROR(hipDeviceEnablePeerAccess(1, 0), hipErrorPeerAccessAlreadyEnabled); + HIP_CHECK(hipDeviceDisablePeerAccess(1)); + } +} + +TEST_CASE("Unit_hipDeviceDisablePeerAccess_negative") { + int deviceCount = HipTest::getGeviceCount(); + if (deviceCount < 2) { + HipTest::HIP_SKIP_TEST("Skipping because devices < 2"); + return; + } + + SECTION("peerDeviceId is invalid") { + HIP_CHECK_ERROR(hipDeviceDisablePeerAccess(-1), hipErrorInvalidDevice); + HIP_CHECK_ERROR(hipDeviceDisablePeerAccess(deviceCount), hipErrorInvalidDevice); + } + SECTION("Peer Access not enabled") { + HIP_CHECK(hipSetDevice(0)); + HIP_CHECK_ERROR(hipDeviceDisablePeerAccess(1), hipErrorPeerAccessNotEnabled); + } + SECTION("Peer Access disabled twice") { + HIP_CHECK(hipSetDevice(0)); + HIP_CHECK(hipDeviceEnablePeerAccess(1, 0)); + HIP_CHECK(hipDeviceDisablePeerAccess(1)); + HIP_CHECK_ERROR(hipDeviceDisablePeerAccess(1), hipErrorPeerAccessNotEnabled); + } +}