test: add test to waitForTimestamps

Related-To: NEO-8196

Signed-off-by: Andrzej Koska <andrzej.koska@intel.com>
This commit is contained in:
Andrzej Koska 2023-10-26 10:39:53 +00:00 committed by Compute-Runtime-Automation
parent e988fe66e3
commit 4f35bf5282
2 changed files with 55 additions and 1 deletions

View File

@ -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

View File

@ -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<UltHwConfig> backup(&ultHwConfig);
ultHwConfig.useWaitForTimestamps = true;
DebugManager.flags.EnableTimestampWaitForQueues.set(4);
auto pDevice = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(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<CommandQueue> queueOwnership(*pCmdQ);
std::atomic<bool> threadStarted = false;
std::atomic<bool> threadFinished = false;
std::thread t([&]() {
threadStarted = true;
pCmdQ->waitForTimestamps({}, status, const_cast<TimestampPacketContainer *>(pCmdQ->getTimestampPacketContainer()), const_cast<TimestampPacketContainer *>(pCmdQ->getTimestampPacketContainer()));
threadFinished = true;
});
while (!threadStarted)
;
EXPECT_FALSE(threadFinished);
queueOwnership.unlock();
t.join();
EXPECT_TRUE(threadFinished);
delete pCmdQ;
}