mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-21 09:14:47 +08:00
Don't read event memory if signaled state is true
Related-To: NEO-7302 Signed-off-by: Szymon Morek <szymon.morek@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
410fd7d909
commit
5137b70658
@@ -365,6 +365,7 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendEventReset(ze_event_hand
|
||||
packetsToReset = EventPacketsCount::eventPackets;
|
||||
}
|
||||
event->resetPackets();
|
||||
event->resetCompletion();
|
||||
commandContainer.addToResidencyContainer(&event->getAllocation(this->device));
|
||||
const auto &hwInfo = this->device->getHwInfo();
|
||||
if (isCopyOnly()) {
|
||||
|
||||
@@ -114,6 +114,10 @@ struct Event : _ze_event_handle_t {
|
||||
l3FlushAppliedOnKernel.set(kernelCount - 1);
|
||||
}
|
||||
|
||||
void resetCompletion() {
|
||||
this->isCompleted = false;
|
||||
}
|
||||
|
||||
uint64_t globalStartTS;
|
||||
uint64_t globalEndTS;
|
||||
uint64_t contextStartTS;
|
||||
@@ -143,6 +147,7 @@ struct Event : _ze_event_handle_t {
|
||||
|
||||
bool isTimestampEvent = false;
|
||||
bool usingContextEndOffset = false;
|
||||
std::atomic<bool> isCompleted{false};
|
||||
};
|
||||
|
||||
template <typename TagSizeT>
|
||||
|
||||
@@ -140,6 +140,7 @@ ze_result_t EventImp<TagSizeT>::queryStatusEventPackets() {
|
||||
}
|
||||
}
|
||||
}
|
||||
isCompleted = true;
|
||||
this->csr->getInternalAllocationStorage()->cleanAllocationList(this->csr->peekTaskCount(), NEO::AllocationUsage::TEMPORARY_ALLOCATION);
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
@@ -155,7 +156,11 @@ ze_result_t EventImp<TagSizeT>::queryStatus() {
|
||||
}
|
||||
this->csr->downloadAllocations();
|
||||
this->csr->downloadAllocation(*eventPool->getAllocation().getGraphicsAllocation(device->getNEODevice()->getRootDeviceIndex()));
|
||||
return queryStatusEventPackets();
|
||||
if (isCompleted == true) {
|
||||
return ZE_RESULT_SUCCESS;
|
||||
} else {
|
||||
return queryStatusEventPackets();
|
||||
}
|
||||
}
|
||||
|
||||
template <typename TagSizeT>
|
||||
@@ -275,6 +280,7 @@ ze_result_t EventImp<TagSizeT>::reset() {
|
||||
}
|
||||
hostEventSetValue(Event::STATE_INITIAL);
|
||||
resetPackets();
|
||||
resetCompletion();
|
||||
this->l3FlushAppliedOnKernel.reset();
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -67,6 +67,7 @@ struct Mock<EventPool> : public EventPool {
|
||||
|
||||
class MockEvent : public ::L0::Event {
|
||||
public:
|
||||
using ::L0::Event::isCompleted;
|
||||
using ::L0::Event::l3FlushAppliedOnKernel;
|
||||
MockEvent() {
|
||||
mockAllocation.reset(new NEO::MockGraphicsAllocation(0,
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_cmdlist.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_cmdqueue.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_event.h"
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
@@ -184,6 +185,14 @@ HWTEST_F(CommandListAppendEventReset, givenCmdlistWhenAppendingEventResetThenEve
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST_F(CommandListAppendEventReset, givenCmdlistWhenAppendingEventResetThenIsCompletedResetted) {
|
||||
MockEvent event;
|
||||
event.isCompleted = true;
|
||||
auto result = commandList->appendEventReset(event.toHandle());
|
||||
ASSERT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_FALSE(event.isCompleted);
|
||||
}
|
||||
|
||||
HWTEST2_F(CommandListAppendEventReset, givenImmediateCmdlistWhenAppendingEventResetThenCommandsAreExecuted, IsAtLeastSkl) {
|
||||
const ze_command_queue_desc_t desc = {};
|
||||
bool internalEngine = true;
|
||||
|
||||
@@ -2190,5 +2190,85 @@ HWTEST_F(EventTests,
|
||||
event->destroy();
|
||||
}
|
||||
|
||||
TEST_F(EventTests, WhenQueryingStatusWithoutResetThenCompletionDataNotChanged) {
|
||||
auto event = std::unique_ptr<L0::EventImp<uint32_t>>(static_cast<L0::EventImp<uint32_t> *>(L0::Event::create<uint32_t>(eventPool,
|
||||
&eventDesc,
|
||||
device)));
|
||||
auto result = event->hostSignal();
|
||||
ASSERT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_EQ(event->queryStatus(), ZE_RESULT_SUCCESS);
|
||||
|
||||
for (auto j = 0u; j < event->getKernelCount(); j++) {
|
||||
for (auto i = 0u; i < event->kernelEventCompletionData[j].getPacketsUsed(); i++) {
|
||||
if (event->isUsingContextEndOffset()) {
|
||||
EXPECT_EQ(static_cast<uint64_t>(Event::State::STATE_SIGNALED), event->kernelEventCompletionData[j].getContextEndValue(i));
|
||||
} else {
|
||||
EXPECT_EQ(static_cast<uint64_t>(Event::State::STATE_SIGNALED), event->kernelEventCompletionData[j].getContextStartValue(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
size_t eventCompletionOffset = event->getContextStartOffset();
|
||||
if (event->isUsingContextEndOffset()) {
|
||||
eventCompletionOffset = event->getContextEndOffset();
|
||||
}
|
||||
|
||||
uint32_t *eventAddress = static_cast<uint32_t *>(ptrOffset(event->getHostAddress(), eventCompletionOffset));
|
||||
*eventAddress = Event::STATE_INITIAL;
|
||||
|
||||
EXPECT_EQ(event->queryStatus(), ZE_RESULT_SUCCESS);
|
||||
for (auto j = 0u; j < event->getKernelCount(); j++) {
|
||||
for (auto i = 0u; i < event->kernelEventCompletionData[j].getPacketsUsed(); i++) {
|
||||
if (event->isUsingContextEndOffset()) {
|
||||
EXPECT_EQ(static_cast<uint64_t>(Event::State::STATE_SIGNALED), event->kernelEventCompletionData[j].getContextEndValue(i));
|
||||
} else {
|
||||
EXPECT_EQ(static_cast<uint64_t>(Event::State::STATE_SIGNALED), event->kernelEventCompletionData[j].getContextStartValue(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(EventTests, WhenQueryingStatusAfterResetThenCompletionDataChanged) {
|
||||
auto event = std::unique_ptr<L0::EventImp<uint32_t>>(static_cast<L0::EventImp<uint32_t> *>(L0::Event::create<uint32_t>(eventPool,
|
||||
&eventDesc,
|
||||
device)));
|
||||
auto result = event->hostSignal();
|
||||
ASSERT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_EQ(event->queryStatus(), ZE_RESULT_SUCCESS);
|
||||
|
||||
for (auto j = 0u; j < event->getKernelCount(); j++) {
|
||||
for (auto i = 0u; i < event->kernelEventCompletionData[j].getPacketsUsed(); i++) {
|
||||
if (event->isUsingContextEndOffset()) {
|
||||
EXPECT_EQ(static_cast<uint64_t>(Event::State::STATE_SIGNALED), event->kernelEventCompletionData[j].getContextEndValue(i));
|
||||
} else {
|
||||
EXPECT_EQ(static_cast<uint64_t>(Event::State::STATE_SIGNALED), event->kernelEventCompletionData[j].getContextStartValue(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
event->resetCompletion();
|
||||
result = event->hostSignal();
|
||||
ASSERT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
size_t eventCompletionOffset = event->getContextStartOffset();
|
||||
if (event->isUsingContextEndOffset()) {
|
||||
eventCompletionOffset = event->getContextEndOffset();
|
||||
}
|
||||
|
||||
uint32_t *eventAddress = static_cast<uint32_t *>(ptrOffset(event->getHostAddress(), eventCompletionOffset));
|
||||
*eventAddress = Event::STATE_INITIAL;
|
||||
|
||||
EXPECT_EQ(event->queryStatus(), ZE_RESULT_NOT_READY);
|
||||
for (auto j = 0u; j < event->getKernelCount(); j++) {
|
||||
for (auto i = 0u; i < event->kernelEventCompletionData[j].getPacketsUsed(); i++) {
|
||||
if (event->isUsingContextEndOffset()) {
|
||||
EXPECT_EQ(static_cast<uint64_t>(Event::State::STATE_INITIAL), event->kernelEventCompletionData[j].getContextEndValue(i));
|
||||
} else {
|
||||
EXPECT_EQ(static_cast<uint64_t>(Event::State::STATE_INITIAL), event->kernelEventCompletionData[j].getContextStartValue(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
|
||||
Reference in New Issue
Block a user