Disable isCompleted state if event reset on GPU

Signed-off-by: Szymon Morek <szymon.morek@intel.com>
This commit is contained in:
Szymon Morek
2022-11-22 15:12:44 +00:00
committed by Compute-Runtime-Automation
parent 0e5b0b1173
commit 5d2ed42275
6 changed files with 43 additions and 17 deletions

View File

@ -400,7 +400,7 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendEventReset(ze_event_hand
packetsToReset = event->getMaxPacketsCount();
}
event->resetPackets(false);
event->resetCompletionStatus();
event->resetCompletionStatus(true);
commandContainer.addToResidencyContainer(&event->getAllocation(this->device));
const auto &hwInfo = this->device->getHwInfo();
if (isCopyOnly()) {

View File

@ -45,6 +45,7 @@ struct Event : _ze_event_handle_t {
virtual ze_result_t queryTimestampsExp(Device *device, uint32_t *pCount, ze_kernel_timestamp_result_t *pTimestamps) = 0;
enum State : uint32_t {
STATE_SIGNALED = 0u,
HOST_CACHING_DISABLED = std::numeric_limits<uint32_t>::max() - 1,
STATE_CLEARED = std::numeric_limits<uint32_t>::max(),
STATE_INITIAL = STATE_CLEARED
};
@ -121,8 +122,18 @@ struct Event : _ze_event_handle_t {
l3FlushAppliedOnKernel.set(kernelCount - 1);
}
void resetCompletionStatus() {
this->isCompleted = false;
void resetCompletionStatus(bool disableHostSideStatusCaching) {
this->isCompleted.store(disableHostSideStatusCaching ? HOST_CACHING_DISABLED : STATE_CLEARED);
}
void setIsCompleted() {
if (this->isCompleted.load() != HOST_CACHING_DISABLED) {
this->isCompleted = STATE_SIGNALED;
}
}
bool isAlreadyCompleted() {
return this->isCompleted == STATE_SIGNALED;
}
uint32_t getMaxPacketsCount() const {
@ -172,7 +183,7 @@ struct Event : _ze_event_handle_t {
bool isTimestampEvent = false;
bool usingContextEndOffset = false;
bool signalAllEventPackets = false;
std::atomic<bool> isCompleted{false};
std::atomic<State> isCompleted{STATE_INITIAL};
};
template <typename TagSizeT>

View File

@ -172,7 +172,7 @@ ze_result_t EventImp<TagSizeT>::queryStatusEventPackets() {
remainingPacketSyncAddress = ptrOffset(remainingPacketSyncAddress, this->singlePacketSize);
}
}
isCompleted = true;
this->setIsCompleted();
this->csr->getInternalAllocationStorage()->cleanAllocationList(this->csr->peekTaskCount(), NEO::AllocationUsage::TEMPORARY_ALLOCATION);
return ZE_RESULT_SUCCESS;
}
@ -184,7 +184,7 @@ ze_result_t EventImp<TagSizeT>::queryStatus() {
}
this->csr->downloadAllocations();
this->csr->downloadAllocation(*eventPool->getAllocation().getGraphicsAllocation(device->getNEODevice()->getRootDeviceIndex()));
if (isCompleted == true) {
if (isAlreadyCompleted()) {
return ZE_RESULT_SUCCESS;
} else {
return queryStatusEventPackets();
@ -273,7 +273,7 @@ template <typename TagSizeT>
ze_result_t EventImp<TagSizeT>::hostSignal() {
auto status = hostEventSetValue(Event::STATE_SIGNALED);
if (status == ZE_RESULT_SUCCESS) {
isCompleted = true;
this->setIsCompleted();
}
return status;
}
@ -328,7 +328,7 @@ ze_result_t EventImp<TagSizeT>::hostSynchronize(uint64_t timeout) {
template <typename TagSizeT>
ze_result_t EventImp<TagSizeT>::reset() {
this->resetCompletionStatus();
this->resetCompletionStatus(false);
this->resetDeviceCompletionData(false);
this->l3FlushAppliedOnKernel.reset();
return ZE_RESULT_SUCCESS;

View File

@ -632,12 +632,12 @@ HWTEST2_F(CmdlistAppendLaunchKernelTests,
ze_group_count_t groupCount = {3, 2, 1};
CmdListKernelLaunchParams launchParams = {};
ze_event_handle_t eventHandles[1] = {event->toHandle()};
EXPECT_FALSE(static_cast<MockEvent *>(event.get())->isCompleted);
EXPECT_EQ(MockEvent::STATE_CLEARED, static_cast<MockEvent *>(event.get())->isCompleted);
result = CommandList::fromHandle(cmdListHandle)->appendLaunchKernel(kernel->toHandle(), &groupCount, nullptr, 1, eventHandles, launchParams);
EXPECT_EQ(result, ZE_RESULT_SUCCESS);
EXPECT_TRUE(static_cast<MockEvent *>(event.get())->isCompleted);
EXPECT_EQ(MockEvent::STATE_SIGNALED, static_cast<MockEvent *>(event.get())->isCompleted);
CommandList::fromHandle(cmdListHandle)->destroy();
}

View File

@ -200,12 +200,27 @@ HWTEST_F(CommandListAppendEventReset, givenCmdlistWhenAppendingEventResetThenEve
}
}
HWTEST_F(CommandListAppendEventReset, givenCmdlistWhenAppendingEventResetThenIsCompletedResetted) {
HWTEST_F(CommandListAppendEventReset, givenCmdlistWhenAppendingEventResetThenIsCompletedFlagDisabled) {
MockEvent event;
event.isCompleted = true;
event.isCompleted = MockEvent::STATE_SIGNALED;
auto result = commandList->appendEventReset(event.toHandle());
ASSERT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_FALSE(event.isCompleted);
ASSERT_EQ(MockEvent::HOST_CACHING_DISABLED, event.isCompleted);
}
HWTEST_F(CommandListAppendEventReset, WhenIsCompletedClearedThenSetStateSignaledWhenSignalAgain) {
event->reset();
EXPECT_FALSE(event->isAlreadyCompleted());
event->hostSignal();
EXPECT_TRUE(event->isAlreadyCompleted());
}
HWTEST_F(CommandListAppendEventReset, WhenIsCompletedDisabledThenDontSetStateSignaledWhenSignalAgain) {
auto result = commandList->appendEventReset(event->toHandle());
ASSERT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_FALSE(event->isAlreadyCompleted());
event->hostSignal();
EXPECT_FALSE(event->isAlreadyCompleted());
}
HWTEST2_F(CommandListAppendEventReset, givenImmediateCmdlistWhenAppendingEventResetThenCommandsAreExecuted, IsAtLeastSkl) {

View File

@ -2455,7 +2455,7 @@ struct EventDynamicPacketUseFixture : public DeviceFixture {
result = event->queryStatus();
EXPECT_EQ(ZE_RESULT_NOT_READY, result);
event->resetCompletionStatus();
event->resetCompletionStatus(false);
event->hostSignal();
@ -2472,7 +2472,7 @@ struct EventDynamicPacketUseFixture : public DeviceFixture {
result = event->queryStatus();
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
event->resetCompletionStatus();
event->resetCompletionStatus(false);
remainingPacketsAddress = ptrOffset(eventHostAddress, (usedPackets * packetSize));
if (event->isUsingContextEndOffset()) {
@ -2485,13 +2485,13 @@ struct EventDynamicPacketUseFixture : public DeviceFixture {
result = event->queryStatus();
EXPECT_EQ(queryRetAfterPartialReset, result);
event->resetCompletionStatus();
event->resetCompletionStatus(false);
*completionField = Event::STATE_SIGNALED;
result = event->queryStatus();
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
event->resetCompletionStatus();
event->resetCompletionStatus(false);
}
event->reset();