From 03e871aea5ff43fe3aec6cc803f417a572aa53b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mirza=20Halil=C4=8Devi=C4=87?= <109971222+mirza-halilcevic@users.noreply.github.com> Date: Fri, 4 Nov 2022 14:54:58 +0100 Subject: [PATCH] EXSWHTEC-8 - Implement additional test for hipGetDeviceFlags (#2877) - Validate that hipGetDeviceFlags returns flags with which the current context was created. - Disable Unit_hipGetDeviceFlags_Positive_Context on AMD [ROCm/hip-tests commit: a6bbefbd95fc39d5c7259b3060042f120bf60533] --- .../config/config_amd_linux_common.json | 3 ++- .../config/config_amd_windows_MI2xx.json | 2 +- .../config/config_amd_windows_common.json | 3 ++- .../catch/unit/device/hipGetSetDeviceFlags.cc | 19 +++++++++++++++++++ 4 files changed, 24 insertions(+), 3 deletions(-) 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 8b8c42fcd4..d7440af317 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 @@ -4,6 +4,7 @@ "Unit_hipStreamPerThread_DeviceReset_1", "Unit_hipMallocManaged_OverSubscription", "Unit_hipDeviceGetCacheConfig_Positive_Basic", - "Unit_hipDeviceGetCacheConfig_Positive_Threaded" + "Unit_hipDeviceGetCacheConfig_Positive_Threaded", + "Unit_hipGetDeviceFlags_Positive_Context" ] } 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 013f7c67d8..6ee5669f0b 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 @@ -88,6 +88,6 @@ "Unit_hipStreamValue_Wait64_Blocking_NoMask_Gte", "Unit_hipStreamValue_Wait64_Blocking_NoMask_Eq", "Unit_hipStreamValue_Wait64_Blocking_NoMask_And", - "Unit_hipStreamValue_Wait64_Blocking_NoMask_Nor" + "Unit_hipStreamValue_Wait64_Blocking_NoMask_Nor" ] } 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 2094761dc2..bd3105a537 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 @@ -97,6 +97,7 @@ "Unit_hipStreamValue_Wait64_Blocking_NoMask_Gte", "Unit_hipStreamValue_Wait64_Blocking_NoMask_Eq", "Unit_hipStreamValue_Wait64_Blocking_NoMask_And", - "Unit_hipStreamValue_Wait64_Blocking_NoMask_Nor" + "Unit_hipStreamValue_Wait64_Blocking_NoMask_Nor", + "Unit_hipGetDeviceFlags_Positive_Context" ] } diff --git a/projects/hip-tests/catch/unit/device/hipGetSetDeviceFlags.cc b/projects/hip-tests/catch/unit/device/hipGetSetDeviceFlags.cc index c134a21ad0..c661f4e7ba 100644 --- a/projects/hip-tests/catch/unit/device/hipGetSetDeviceFlags.cc +++ b/projects/hip-tests/catch/unit/device/hipGetSetDeviceFlags.cc @@ -145,3 +145,22 @@ TEST_CASE("Unit_hipGetSetDeviceFlags_Threaded") { test_thread.join(); HIP_CHECK_THREAD_FINALIZE(); } + +TEST_CASE("Unit_hipGetDeviceFlags_Positive_Context") { + auto validFlags = getValidFlags(); + const unsigned int flags = + GENERATE_COPY(from_range(std::begin(validFlags), std::end(validFlags))); + + HIP_CHECK(hipInit(0)); + + hipCtx_t ctx; + HIP_CHECK(hipCtxCreate(&ctx, flags, 0)); + + unsigned int actual_flags; + HIP_CHECK(hipGetDeviceFlags(&actual_flags)); + + REQUIRE(actual_flags == flags); + + HIP_CHECK(hipCtxPopCurrent(&ctx)); + HIP_CHECK(hipCtxDestroy(ctx)); +} \ No newline at end of file