mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Correct values in queue synchronize
Change-Id: I645d1ae50d6e17d2d330ba9d21ef1a8cf7b955b8 Signed-off-by: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
This commit is contained in:

committed by
sys_ocldev

parent
62b0efd122
commit
398ad44404
@ -68,8 +68,14 @@ ze_result_t CommandQueueImp::synchronizeByPollingForTaskCount(uint64_t timeout)
|
||||
UNRECOVERABLE_IF(csr == nullptr);
|
||||
|
||||
auto taskCountToWait = this->taskCount;
|
||||
bool enableTimeout = (timeout != std::numeric_limits<uint64_t>::max());
|
||||
csr->waitForCompletionWithTimeout(enableTimeout, timeout, this->taskCount);
|
||||
bool enableTimeout = true;
|
||||
int64_t timeoutMicroseconds = static_cast<int64_t>(timeout);
|
||||
if (timeout == std::numeric_limits<uint64_t>::max()) {
|
||||
enableTimeout = false;
|
||||
timeoutMicroseconds = NEO::TimeoutControls::maxTimeout;
|
||||
}
|
||||
|
||||
csr->waitForCompletionWithTimeout(enableTimeout, timeoutMicroseconds, this->taskCount);
|
||||
|
||||
if (*csr->getTagAddress() < taskCountToWait) {
|
||||
return ZE_RESULT_NOT_READY;
|
||||
|
@ -111,7 +111,7 @@ int main(int argc, char *argv[]) {
|
||||
VALIDATECALL(zeCommandListClose(cmdList));
|
||||
VALIDATECALL(zeCommandQueueExecuteCommandLists(cmdQueue, 1, &cmdList, nullptr));
|
||||
|
||||
VALIDATECALL(zeCommandQueueSynchronize(cmdQueue, std::numeric_limits<uint32_t>::max()));
|
||||
VALIDATECALL(zeCommandQueueSynchronize(cmdQueue, std::numeric_limits<uint64_t>::max()));
|
||||
|
||||
// Validate
|
||||
bool outputValidationSuccessful = true;
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "shared/test/unit_test/helpers/default_hw_info.h"
|
||||
#include "shared/test/unit_test/mocks/mock_command_stream_receiver.h"
|
||||
|
||||
#include "opencl/test/unit_test/libult/ult_command_stream_receiver.h"
|
||||
#include "test.h"
|
||||
|
||||
#include "level_zero/core/source/context/context.h"
|
||||
@ -270,5 +271,59 @@ TEST_F(ContextCreateCommandQueueTest, givenCallToContextCreateCommandQueueThenCa
|
||||
L0::CommandQueue::fromHandle(commandQueue)->destroy();
|
||||
}
|
||||
|
||||
using CommandQueueSynchronizeTest = Test<ContextFixture>;
|
||||
|
||||
HWTEST_F(CommandQueueSynchronizeTest, givenCallToSynchronizeThenCorrectEnableTimeoutAndTimeoutValuesAreUsed) {
|
||||
struct SynchronizeCsr : public NEO::UltCommandStreamReceiver<FamilyType> {
|
||||
~SynchronizeCsr() {
|
||||
delete tagAddress;
|
||||
}
|
||||
SynchronizeCsr(const NEO::ExecutionEnvironment &executionEnvironment) : NEO::UltCommandStreamReceiver<FamilyType>(const_cast<NEO::ExecutionEnvironment &>(executionEnvironment), 0) {
|
||||
tagAddress = new uint32_t;
|
||||
}
|
||||
MOCK_METHOD3(waitForCompletionWithTimeout, bool(bool enableTimeout, int64_t timeoutMs, uint32_t taskCountToWait));
|
||||
|
||||
volatile uint32_t *getTagAddress() const {
|
||||
return tagAddress;
|
||||
}
|
||||
uint32_t *tagAddress;
|
||||
};
|
||||
|
||||
auto csr = new ::testing::NiceMock<SynchronizeCsr>(*device->getNEODevice()->getExecutionEnvironment());
|
||||
ze_command_queue_desc_t desc = {};
|
||||
ze_command_queue_handle_t commandQueue = {};
|
||||
ze_result_t res = context->createCommandQueue(device, &desc, &commandQueue);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
EXPECT_NE(nullptr, commandQueue);
|
||||
|
||||
CommandQueue *queue = reinterpret_cast<CommandQueue *>(L0::CommandQueue::fromHandle(commandQueue));
|
||||
queue->csr = csr;
|
||||
|
||||
uint64_t timeout = 10;
|
||||
bool enableTimeoutExpected = true;
|
||||
int64_t timeoutMicrosecondsExpected = timeout;
|
||||
|
||||
EXPECT_CALL(*csr, waitForCompletionWithTimeout(enableTimeoutExpected,
|
||||
timeoutMicrosecondsExpected,
|
||||
::testing::_))
|
||||
.Times(1)
|
||||
.WillOnce(::testing::Return(true));
|
||||
queue->synchronize(timeout);
|
||||
|
||||
timeout = std::numeric_limits<uint64_t>::max();
|
||||
enableTimeoutExpected = false;
|
||||
timeoutMicrosecondsExpected = NEO::TimeoutControls::maxTimeout;
|
||||
|
||||
EXPECT_CALL(*csr, waitForCompletionWithTimeout(enableTimeoutExpected,
|
||||
timeoutMicrosecondsExpected,
|
||||
::testing::_))
|
||||
.Times(1)
|
||||
.WillOnce(::testing::Return(true));
|
||||
queue->synchronize(timeout);
|
||||
|
||||
delete csr;
|
||||
L0::CommandQueue::fromHandle(commandQueue)->destroy();
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
|
@ -121,7 +121,7 @@ void CommandStreamReceiver::makeResidentHostPtrAllocation(GraphicsAllocation *gf
|
||||
}
|
||||
|
||||
void CommandStreamReceiver::waitForTaskCountAndCleanAllocationList(uint32_t requiredTaskCount, uint32_t allocationUsage) {
|
||||
auto address = getTagAddress();
|
||||
auto address = tagAddress;
|
||||
if (address) {
|
||||
while (*address < requiredTaskCount)
|
||||
;
|
||||
|
@ -104,7 +104,7 @@ class CommandStreamReceiver {
|
||||
GraphicsAllocation *getTagAllocation() const {
|
||||
return tagAllocation;
|
||||
}
|
||||
volatile uint32_t *getTagAddress() const { return tagAddress; }
|
||||
MOCKABLE_VIRTUAL volatile uint32_t *getTagAddress() const { return tagAddress; }
|
||||
uint64_t getDebugPauseStateGPUAddress() const { return tagAllocation->getGpuAddress() + debugPauseStateAddressOffset; }
|
||||
|
||||
virtual bool waitForFlushStamp(FlushStamp &flushStampToWait) { return true; };
|
||||
|
Reference in New Issue
Block a user