From e6ee2e4913c9194418b45c1d08ae6a670225a46e Mon Sep 17 00:00:00 2001 From: agunashe <86270081+agunashe@users.noreply.github.com> Date: Sun, 13 Nov 2022 22:57:11 -0800 Subject: [PATCH 1/2] SWDEV-327563 - skip graph and spt failing tests (#3068) * SWDEV-327563 - skip Unit_hipStreamSynchronize_NullStreamAndStreamPerThread. Since the StreamPerThread is still not fixed * SWDEV-327563 - skip graph and spt failing tests [ROCm/hip commit: ae8f2d35575681d4ec0500c6205cc5f48eb53308] --- .../hipTestMain/config/config_amd_windows_common.json | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/projects/hip/tests/catch/hipTestMain/config/config_amd_windows_common.json b/projects/hip/tests/catch/hipTestMain/config/config_amd_windows_common.json index 17ae9eb145..43cfb816fb 100644 --- a/projects/hip/tests/catch/hipTestMain/config/config_amd_windows_common.json +++ b/projects/hip/tests/catch/hipTestMain/config/config_amd_windows_common.json @@ -79,6 +79,12 @@ "Unit_hipIpcOpenMemHandle_Negative_Open_In_Creating_Process", "Unit_hipDeviceGetPCIBusId_Negative_PartialFill", "Unit_hipDeviceGetSharedMemConfig_Positive_Basic", - "Unit_hipDeviceGetSharedMemConfig_Positive_Threaded" + "Unit_hipDeviceGetSharedMemConfig_Positive_Threaded", + "Unit_hipGraphMemcpyNodeSetParams_Functional", + "Unit_hipGraphNodeGetDependentNodes_Functional", + "Unit_hipGraphNodeGetDependencies_Functional", + "Unit_hipGraphExecChildGraphNodeSetParams_ChildTopology", + "Note: needs to be enabled when streamPerThread issues are fixed", + "Unit_hipStreamSynchronize_NullStreamAndStreamPerThread" ] } From 7a9617e9f61137f388ff4d00554856c32b046824 Mon Sep 17 00:00:00 2001 From: nives-vukovic <110852104+nives-vukovic@users.noreply.github.com> Date: Mon, 14 Nov 2022 10:35:14 +0100 Subject: [PATCH 2/2] EXSWHTEC-64 - Implement tests for hipInit and hipDriverGetVersion (#2971) - Add simple positive and negative test for hipInit api - Add simple positive and negative test for hipDriverGetVersion api - Disable hipInit negative test on AMD [ROCm/hip commit: 1f06f33d7d0d4a3d2563d92ac8320240e5af779a] --- .../config/config_amd_linux_MI2xx.json | 3 +- .../config/config_amd_linux_common.json | 3 +- .../config/config_amd_windows_MI2xx.json | 3 +- .../config/config_amd_windows_common.json | 3 +- .../tests/catch/unit/device/CMakeLists.txt | 2 + .../catch/unit/device/hipDriverGetVersion.cc | 40 ++++++++++++++++++ .../hip/tests/catch/unit/device/hipInit.cc | 42 +++++++++++++++++++ 7 files changed, 92 insertions(+), 4 deletions(-) create mode 100644 projects/hip/tests/catch/unit/device/hipDriverGetVersion.cc create mode 100644 projects/hip/tests/catch/unit/device/hipInit.cc diff --git a/projects/hip/tests/catch/hipTestMain/config/config_amd_linux_MI2xx.json b/projects/hip/tests/catch/hipTestMain/config/config_amd_linux_MI2xx.json index da05aeb2e7..5fa1d23228 100644 --- a/projects/hip/tests/catch/hipTestMain/config/config_amd_linux_MI2xx.json +++ b/projects/hip/tests/catch/hipTestMain/config/config_amd_linux_MI2xx.json @@ -3,7 +3,8 @@ [ "Unit_hipStreamPerThread_DeviceReset_1", "Unit_hipMallocManaged_OverSubscription", - "Unit_hipDeviceGetPCIBusId_Negative_PartialFill" + "Unit_hipDeviceGetPCIBusId_Negative_PartialFill", + "Unit_hipInit_Negative" ] } diff --git a/projects/hip/tests/catch/hipTestMain/config/config_amd_linux_common.json b/projects/hip/tests/catch/hipTestMain/config/config_amd_linux_common.json index b3a7503222..e0fd000420 100644 --- a/projects/hip/tests/catch/hipTestMain/config/config_amd_linux_common.json +++ b/projects/hip/tests/catch/hipTestMain/config/config_amd_linux_common.json @@ -10,6 +10,7 @@ "Unit_hipGetDeviceFlags_Positive_Context", "Unit_hipIpcCloseMemHandle_Negative_Close_In_Originating_Process", "Unit_hipIpcOpenMemHandle_Negative_Open_In_Creating_Process", - "Unit_hipDeviceGetPCIBusId_Negative_PartialFill" + "Unit_hipDeviceGetPCIBusId_Negative_PartialFill", + "Unit_hipInit_Negative" ] } diff --git a/projects/hip/tests/catch/hipTestMain/config/config_amd_windows_MI2xx.json b/projects/hip/tests/catch/hipTestMain/config/config_amd_windows_MI2xx.json index 317bef4a9a..2843587cf2 100644 --- a/projects/hip/tests/catch/hipTestMain/config/config_amd_windows_MI2xx.json +++ b/projects/hip/tests/catch/hipTestMain/config/config_amd_windows_MI2xx.json @@ -89,6 +89,7 @@ "Unit_hipStreamValue_Wait64_Blocking_NoMask_Eq", "Unit_hipStreamValue_Wait64_Blocking_NoMask_And", "Unit_hipStreamValue_Wait64_Blocking_NoMask_Nor", - "Unit_hipDeviceGetPCIBusId_Negative_PartialFill" + "Unit_hipDeviceGetPCIBusId_Negative_PartialFill", + "Unit_hipInit_Negative" ] } diff --git a/projects/hip/tests/catch/hipTestMain/config/config_amd_windows_common.json b/projects/hip/tests/catch/hipTestMain/config/config_amd_windows_common.json index 43cfb816fb..f9d644675e 100644 --- a/projects/hip/tests/catch/hipTestMain/config/config_amd_windows_common.json +++ b/projects/hip/tests/catch/hipTestMain/config/config_amd_windows_common.json @@ -55,7 +55,7 @@ "Unit_hipGraphMemcpyNodeSetParamsToSymbol_Functional", "Unit_hipStreamWaitEvent_DifferentStreams", "Unit_hipStreamQuery_WithFinishedWork", - "Unit_hipDeviceGetCacheConfig_Positive_Basic", + "Unit_hipDeviceGetCacheConfig_Positive_Basic", "Unit_hipDeviceGetCacheConfig_Positive_Threaded", "Unit_hipStreamValue_Wait32_Blocking_Mask_Gte", "Unit_hipStreamValue_Wait32_Blocking_Mask_Eq_1", @@ -80,6 +80,7 @@ "Unit_hipDeviceGetPCIBusId_Negative_PartialFill", "Unit_hipDeviceGetSharedMemConfig_Positive_Basic", "Unit_hipDeviceGetSharedMemConfig_Positive_Threaded", + "Unit_hipInit_Negative", "Unit_hipGraphMemcpyNodeSetParams_Functional", "Unit_hipGraphNodeGetDependentNodes_Functional", "Unit_hipGraphNodeGetDependencies_Functional", diff --git a/projects/hip/tests/catch/unit/device/CMakeLists.txt b/projects/hip/tests/catch/unit/device/CMakeLists.txt index e8a738c56e..9f11be6877 100644 --- a/projects/hip/tests/catch/unit/device/CMakeLists.txt +++ b/projects/hip/tests/catch/unit/device/CMakeLists.txt @@ -24,6 +24,8 @@ set(TEST_SRC hipDeviceSetLimit.cc hipDeviceSetGetSharedMemConfig.cc hipDeviceSetGetMemPool.cc + hipInit.cc + hipDriverGetVersion.cc ) if(UNIX) diff --git a/projects/hip/tests/catch/unit/device/hipDriverGetVersion.cc b/projects/hip/tests/catch/unit/device/hipDriverGetVersion.cc new file mode 100644 index 0000000000..66f6d8e7e4 --- /dev/null +++ b/projects/hip/tests/catch/unit/device/hipDriverGetVersion.cc @@ -0,0 +1,40 @@ +/* +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 WARRANNTY OF ANY KIND, EXPRESS OR +IMPLIED, INNCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANNY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ +/* +Testcase Scenarios : +Unit_hipDriverGetVersion_Positive - Test simple reading of HIP driver version with hipDriverGetVersion api +Unit_hipDriverGetVersion_Negative - Test unsuccessful execution of hipDriverGetVersion when nullptr is set as input parameter +*/ +#include + +TEST_CASE("Unit_hipDriverGetVersion_Positive") { + + int driverVersion = -1; + HIP_CHECK(hipDriverGetVersion(&driverVersion)); + REQUIRE(driverVersion > 0); + INFO("Driver version " << driverVersion); +} + +TEST_CASE("Unit_hipDriverGetVersion_Negative") { + // If initialization is attempted with nullptr, error shall be reported + HIP_CHECK_ERROR(hipDriverGetVersion(nullptr), hipErrorInvalidValue); +} + diff --git a/projects/hip/tests/catch/unit/device/hipInit.cc b/projects/hip/tests/catch/unit/device/hipInit.cc new file mode 100644 index 0000000000..f206af5756 --- /dev/null +++ b/projects/hip/tests/catch/unit/device/hipInit.cc @@ -0,0 +1,42 @@ +/* +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 WARRANNTY OF ANY KIND, EXPRESS OR +IMPLIED, INNCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANNY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ +/* +Testcase Scenarios : +Unit_hipInit_Positive - Test explicit HIP initalization with hipInit api +Unit_hipInit_Negative_InvalidFlag - Test unsuccessful HIP initalization with hipInit api when flag is invalid +*/ +#include + +TEST_CASE("Unit_hipInit_Positive") { + HIP_CHECK(hipInit(0)); + + // Verify that HIP runtime is successfully initialized by calling a HIP API + int count = -1; + HIP_CHECK(hipGetDeviceCount(&count)); + REQUIRE(count >= 0); +} + +TEST_CASE("Unit_hipInit_Negative") { + // If initialization is attempted with invalid flag, error shall be reported + unsigned int invalid_flag = 1; + HIP_CHECK_ERROR(hipInit(invalid_flag), hipErrorInvalidValue); +} +