diff --git a/sycl/test-e2e/bindless_images/dx12_interop/external_semaphore_regular_cl.cpp b/sycl/test-e2e/bindless_images/dx12_interop/external_semaphore_regular_cl.cpp index 8aff5b5e34f17..257f5bcb2d5be 100644 --- a/sycl/test-e2e/bindless_images/dx12_interop/external_semaphore_regular_cl.cpp +++ b/sycl/test-e2e/bindless_images/dx12_interop/external_semaphore_regular_cl.cpp @@ -1,4 +1,4 @@ -// REQUIRES: aspect-ext_oneapi_external_semaphore_import, aspect-usm_shared_allocations +// REQUIRES: aspect-ext_oneapi_external_semaphore_import // REQUIRES: aspect-ext_intel_device_info_luid // REQUIRES: windows, level_zero @@ -10,10 +10,20 @@ // XFAIL-TRACKER: https://github.com/intel/llvm/issues/23249 // RUN: %{build} %link-directx -o %t.exe %if target-spir %{ -Wno-ignored-attributes %} -// RUN: env UR_L0_BATCH_SIZE=8 %{run} %t.exe +// RUN: env UR_L0_BATCH_SIZE=8 SYCL_UR_TRACE=2 UR_L0_DEBUG=1 %{run} %t.exe \ +// RUN: 2>&1 | FileCheck --check-prefixes=CHECK%if level_zero_v2_adapter %{,CHECK-V2%} %else %{,CHECK-V1%} %s +// +// CHECK-LABEL: SUBMISSION TRACE BEGIN +// CHECK-V1: zeCommandQueueExecuteCommandLists +// CHECK-V1: zeCommandQueueExecuteCommandLists +// CHECK-V2: zeCommandListImmediateAppendCommandListsExp +// CHECK-V2: zeCommandListImmediateAppendCommandListsExp +// CHECK-LABEL: SUBMISSION TRACE END // Verify that external semaphore wait and signal operations work on an -// in-order queue backed by regular (non-immediate) command lists. +// in-order queue backed by regular (non-immediate) command lists. The trace +// window ends before status queries so they cannot hide a wait left in the +// batch. #include "d3d12_setup.hpp" #include @@ -22,12 +32,10 @@ #include #include #include -#include #include #include #include #include -#include #include #define WIN32_LEAN_AND_MEAN @@ -56,22 +64,6 @@ D3D12Context createSyclD3D12Context(const sycl::device &device) { std::_Exit(EXIT_FAILURE); } -using MarkerAtomicRef = - sycl::atomic_ref; - -bool waitForMarker(int *marker) { - const auto deadline = - std::chrono::steady_clock::now() + std::chrono::seconds(5); - while (MarkerAtomicRef(*marker).load() == 0) { - if (std::chrono::steady_clock::now() >= deadline) - return false; - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - } - return true; -} - bool remainsIncomplete(const sycl::event &event) { const auto deadline = std::chrono::steady_clock::now() + std::chrono::milliseconds(100); @@ -112,18 +104,18 @@ int main() { syclexp::external_semaphore_handle_type::win32_nt_dx12_fence}; syclexp::external_semaphore syclSem = syclexp::import_external_semaphore(semDesc, device, context); - int *marker = sycl::malloc_shared(1, q); - MarkerAtomicRef(*marker).store(0); try { const uint64_t D3DSignalValue = extFence.fenceValue + 1; - q.single_task([=]() { MarkerAtomicRef(*marker).store(1); }); + std::cerr << "SUBMISSION TRACE BEGIN" << std::endl; + sycl::event precedingEvent = q.single_task([]() {}); sycl::event waitEvent = q.ext_oneapi_wait_external_semaphore(syclSem, D3DSignalValue); + std::cerr << "SUBMISSION TRACE END" << std::endl; - if (!waitForMarker(marker)) + if (!waitForCompletion(precedingEvent)) failWithoutCleanup( - "The external semaphore wait did not submit the preceding batch."); + "Work preceding the external semaphore wait did not complete."); if (!remainsIncomplete(waitEvent)) failWithoutCleanup( "The external semaphore wait completed before D3D12 signaled it."); @@ -155,7 +147,6 @@ int main() { failWithoutCleanup(e.what()); } - sycl::free(marker, q); syclexp::release_external_semaphore(syclSem, device, context); cleanupExportableFence(extFence); if (d3dCtx.fenceEvent) diff --git a/sycl/test-e2e/bindless_images/vulkan_interop/external_semaphore_regular_cl.cpp b/sycl/test-e2e/bindless_images/vulkan_interop/external_semaphore_regular_cl.cpp index 81e83137c418e..e24da1e255f1d 100644 --- a/sycl/test-e2e/bindless_images/vulkan_interop/external_semaphore_regular_cl.cpp +++ b/sycl/test-e2e/bindless_images/vulkan_interop/external_semaphore_regular_cl.cpp @@ -1,5 +1,4 @@ // REQUIRES: aspect-ext_oneapi_external_semaphore_import -// REQUIRES: aspect-usm_shared_allocations // REQUIRES: vulkan && level_zero // Regular command-list external semaphore support requires these driver @@ -10,12 +9,21 @@ // XFAIL-TRACKER: https://github.com/intel/llvm/issues/23249 // RUN: %{build} %link-vulkan -o %t.out %if target-spir %{ -Wno-ignored-attributes %} -// RUN: env UR_L0_BATCH_SIZE=8 %{run} %t.out +// RUN: env UR_L0_BATCH_SIZE=8 SYCL_UR_TRACE=2 UR_L0_DEBUG=1 %{run} %t.out \ +// RUN: 2>&1 | FileCheck --check-prefixes=CHECK%if level_zero_v2_adapter %{,CHECK-V2%} %else %{,CHECK-V1%} %s +// +// CHECK-LABEL: SUBMISSION TRACE BEGIN +// CHECK-V1: zeCommandQueueExecuteCommandLists +// CHECK-V1: zeCommandQueueExecuteCommandLists +// CHECK-V2: zeCommandListImmediateAppendCommandListsExp +// CHECK-V2: zeCommandListImmediateAppendCommandListsExp +// CHECK-LABEL: SUBMISSION TRACE END // Verify that external semaphore wait and signal operations work on an // in-order queue backed by regular (non-immediate) command lists. A timeline -// semaphore provides equivalent coverage on both platforms while avoiding -// Linux binary semaphore sharing issue CMPLRLLVM-78008. +// semaphore provides equivalent coverage on both platforms while avoiding a +// known Linux binary semaphore sharing issue. The trace window ends before +// status queries so they cannot hide a wait left in the batch. #include "sycl_vulkan_setup.hpp" #include @@ -23,11 +31,9 @@ #include #include #include -#include #include #include #include -#include #include namespace syclexp = sycl::ext::oneapi::experimental; @@ -37,22 +43,6 @@ namespace syclexp = sycl::ext::oneapi::experimental; std::_Exit(EXIT_FAILURE); } -using MarkerAtomicRef = - sycl::atomic_ref; - -bool waitForMarker(int *marker) { - const auto deadline = - std::chrono::steady_clock::now() + std::chrono::seconds(5); - while (MarkerAtomicRef(*marker).load() == 0) { - if (std::chrono::steady_clock::now() >= deadline) - return false; - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - } - return true; -} - bool remainsIncomplete(const sycl::event &event) { const auto deadline = std::chrono::steady_clock::now() + std::chrono::milliseconds(100); @@ -101,17 +91,17 @@ int main() { #endif syclexp::external_semaphore syclSem = syclexp::import_external_semaphore(desc, device, context); - int *marker = sycl::malloc_shared(1, q); - MarkerAtomicRef(*marker).store(0); try { - q.single_task([=]() { MarkerAtomicRef(*marker).store(1); }); + std::cerr << "SUBMISSION TRACE BEGIN" << std::endl; + sycl::event precedingEvent = q.single_task([]() {}); sycl::event waitEvent = q.ext_oneapi_wait_external_semaphore(syclSem, VulkanSignalValue); + std::cerr << "SUBMISSION TRACE END" << std::endl; - if (!waitForMarker(marker)) + if (!waitForCompletion(precedingEvent)) failWithoutCleanup( - "The external semaphore wait did not submit the preceding batch."); + "Work preceding the external semaphore wait did not complete."); if (!remainsIncomplete(waitEvent)) failWithoutCleanup( "The external semaphore wait completed before Vulkan signaled it."); @@ -150,7 +140,6 @@ int main() { failWithoutCleanup(e.what()); } - sycl::free(marker, q); syclexp::release_external_semaphore(syclSem, device, context); vkDestroySemaphore(vkCtx.device, vkSem, nullptr); cleanupVulkanContext(vkCtx);