From 69d96d9e0ae2994ec10543b3aa07102570e43f21 Mon Sep 17 00:00:00 2001 From: "systems-assistant[bot]" <221163467+systems-assistant[bot]@users.noreply.github.com> Date: Sun, 21 Sep 2025 15:13:30 -0700 Subject: [PATCH] SWDEV-491267 - add stream capture test for Semaphore APIs (#572) Co-authored-by: Li, Todd tiantuo --- .../hipDestroyExternalSemaphore.cc | 28 ++++++++++++++++++- .../hipImportExternalSemaphore.cc | 23 +++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/projects/hip-tests/catch/unit/vulkan_interop/hipDestroyExternalSemaphore.cc b/projects/hip-tests/catch/unit/vulkan_interop/hipDestroyExternalSemaphore.cc index cf870d8918..6a95927e02 100644 --- a/projects/hip-tests/catch/unit/vulkan_interop/hipDestroyExternalSemaphore.cc +++ b/projects/hip-tests/catch/unit/vulkan_interop/hipDestroyExternalSemaphore.cc @@ -21,6 +21,8 @@ THE SOFTWARE. #include "vulkan_test.hh" +constexpr bool enable_validation = false; + TEST_CASE("Unit_hipDestroyExternalSemaphore_Vulkan_Negative_Parameters") { SECTION("extSem == nullptr") { HIP_CHECK_ERROR(hipDestroyExternalSemaphore(nullptr), hipErrorInvalidValue); @@ -28,7 +30,6 @@ TEST_CASE("Unit_hipDestroyExternalSemaphore_Vulkan_Negative_Parameters") { // Segfaults in Nvidia and Amd #if 0 - constexpr bool enable_validation = false; SECTION("Double free") { VulkanTest vkt(enable_validation); const auto ext_semaphore = ImportBinarySemaphore(vkt); @@ -37,3 +38,28 @@ TEST_CASE("Unit_hipDestroyExternalSemaphore_Vulkan_Negative_Parameters") { } #endif } + +/** + * Test Description + * ------------------------ + * - Test hipDestroyExternalSemaphore while stream is capturing. + * Test source + * ------------------------ + * - unit/vulkan_interop/hipDestroyExternalSemaphore.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 6.0 + */ +TEST_CASE("Unit_hipDestroyExternalSemaphore_Vulkan_Capture") { + VulkanTest vkt(enable_validation); + const auto semaphore = vkt.CreateExternalSemaphore(VK_SEMAPHORE_TYPE_BINARY); + auto handle_desc = vkt.BuildSemaphoreDescriptor(semaphore, VK_SEMAPHORE_TYPE_BINARY); + hipExternalSemaphore_t ext_semaphore; + + hipError_t memcpy_err = hipSuccess; + HIP_CHECK_ERROR(hipImportExternalSemaphore(&ext_semaphore, &handle_desc), memcpy_err); + + BEGIN_CAPTURE_SYNC(memcpy_err, true); + HIP_CHECK_ERROR(hipDestroyExternalSemaphore(ext_semaphore), memcpy_err); + END_CAPTURE_SYNC(memcpy_err); +} \ No newline at end of file diff --git a/projects/hip-tests/catch/unit/vulkan_interop/hipImportExternalSemaphore.cc b/projects/hip-tests/catch/unit/vulkan_interop/hipImportExternalSemaphore.cc index 06c8560238..b3f9d704f5 100644 --- a/projects/hip-tests/catch/unit/vulkan_interop/hipImportExternalSemaphore.cc +++ b/projects/hip-tests/catch/unit/vulkan_interop/hipImportExternalSemaphore.cc @@ -55,4 +55,27 @@ TEST_CASE("Unit_hipImportExternalSemaphore_Vulkan_Negative_Parameters") { HIP_CHECK_ERROR(hipImportExternalSemaphore(&ext_semaphore, &handle_desc), hipErrorInvalidValue); } #endif +} + +/** + * Test Description + * ------------------------ + * - Test hipImportExternalSemaphore while stream is capturing. + * Test source + * ------------------------ + * - unit/vulkan_interop/hipImportExternalSemaphore.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 6.0 + */ +TEST_CASE("Unit_hipImportExternalSemaphore_Vulkan_Capture") { + VulkanTest vkt(enable_validation); + const auto semaphore = vkt.CreateExternalSemaphore(VK_SEMAPHORE_TYPE_BINARY); + auto handle_desc = vkt.BuildSemaphoreDescriptor(semaphore, VK_SEMAPHORE_TYPE_BINARY); + hipExternalSemaphore_t ext_semaphore; + + hipError_t memcpy_err = hipSuccess; + BEGIN_CAPTURE_SYNC(memcpy_err, true); + HIP_CHECK_ERROR(hipImportExternalSemaphore(&ext_semaphore, &handle_desc), memcpy_err); + END_CAPTURE_SYNC(memcpy_err); } \ No newline at end of file