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 17ae9eb145..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", @@ -79,6 +79,13 @@ "Unit_hipIpcOpenMemHandle_Negative_Open_In_Creating_Process", "Unit_hipDeviceGetPCIBusId_Negative_PartialFill", "Unit_hipDeviceGetSharedMemConfig_Positive_Basic", - "Unit_hipDeviceGetSharedMemConfig_Positive_Threaded" + "Unit_hipDeviceGetSharedMemConfig_Positive_Threaded", + "Unit_hipInit_Negative", + "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" ] } 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); +} +