From 4f35bf5282ac1bda5e86d1459675262662b03e51 Mon Sep 17 00:00:00 2001 From: Andrzej Koska Date: Thu, 26 Oct 2023 10:39:53 +0000 Subject: [PATCH] test: add test to waitForTimestamps Related-To: NEO-8196 Signed-off-by: Andrzej Koska --- .../mt_tests/command_queue/CMakeLists.txt | 3 +- .../command_queue/command_queue_test_mt.cpp | 53 +++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 opencl/test/unit_test/mt_tests/command_queue/command_queue_test_mt.cpp diff --git a/opencl/test/unit_test/mt_tests/command_queue/CMakeLists.txt b/opencl/test/unit_test/mt_tests/command_queue/CMakeLists.txt index 59958e113b..8e00a75713 100644 --- a/opencl/test/unit_test/mt_tests/command_queue/CMakeLists.txt +++ b/opencl/test/unit_test/mt_tests/command_queue/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2018-2021 Intel Corporation +# Copyright (C) 2018-2023 Intel Corporation # # SPDX-License-Identifier: MIT # @@ -7,6 +7,7 @@ set(IGDRCL_SRCS_mt_tests_command_queue # local files ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}/command_queue_test_mt.cpp ${CMAKE_CURRENT_SOURCE_DIR}/ioq_task_tests_mt.cpp ${CMAKE_CURRENT_SOURCE_DIR}/ooq_task_tests_mt.cpp diff --git a/opencl/test/unit_test/mt_tests/command_queue/command_queue_test_mt.cpp b/opencl/test/unit_test/mt_tests/command_queue/command_queue_test_mt.cpp new file mode 100644 index 0000000000..e54d99c8d0 --- /dev/null +++ b/opencl/test/unit_test/mt_tests/command_queue/command_queue_test_mt.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2023 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/test/common/helpers/debug_manager_state_restore.h" +#include "shared/test/common/mocks/mock_device.h" + +#include "opencl/test/unit_test/command_queue/enqueue_fixture.h" +#include "opencl/test/unit_test/mocks/mock_cl_device.h" +#include "opencl/test/unit_test/mocks/mock_command_queue.h" + +using namespace NEO; + +TEST(CommandQueue, givenCommandQueueWhenTakeOwnershipWrapperForCommandQueueThenWaitForTimestampsWaitsToBeUnlocked) { + DebugManagerStateRestore restorer; + VariableBackup backup(&ultHwConfig); + ultHwConfig.useWaitForTimestamps = true; + DebugManager.flags.EnableTimestampWaitForQueues.set(4); + + auto pDevice = std::make_unique(MockDevice::createWithNewExecutionEnvironment(defaultHwInfo.get())); + MockContext context(pDevice.get()); + cl_int retVal = CL_SUCCESS; + cl_queue_properties propertiesQueue[5] = {}; + + auto pCmdQ = CommandQueue::create( + &context, + pDevice.get(), + propertiesQueue, + false, + retVal); + + auto status = WaitStatus::NotReady; + + TakeOwnershipWrapper queueOwnership(*pCmdQ); + std::atomic threadStarted = false; + std::atomic threadFinished = false; + + std::thread t([&]() { + threadStarted = true; + pCmdQ->waitForTimestamps({}, status, const_cast(pCmdQ->getTimestampPacketContainer()), const_cast(pCmdQ->getTimestampPacketContainer())); + threadFinished = true; + }); + while (!threadStarted) + ; + EXPECT_FALSE(threadFinished); + queueOwnership.unlock(); + t.join(); + EXPECT_TRUE(threadFinished); + delete pCmdQ; +}