mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Revert async Event destruction
This revertsf9a5f8a86e
andf89c731a11
Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
268393d776
commit
83a9037640
@ -2159,7 +2159,6 @@ cl_int CL_API_CALL clReleaseEvent(cl_event event) {
|
||||
DBG_LOG_INPUTS("cl_event", event, "Event", pEvent);
|
||||
|
||||
if (pEvent) {
|
||||
pEvent->handleCompletionBeforeDestruction();
|
||||
pEvent->release();
|
||||
TRACING_EXIT(clReleaseEvent, &retVal);
|
||||
return retVal;
|
||||
|
@ -44,11 +44,7 @@ Event *AsyncEventsHandler::processList() {
|
||||
|
||||
for (auto event : list) {
|
||||
event->updateExecutionStatus();
|
||||
|
||||
bool eventNotReady = (event->peekExecutionStatus() > CL_COMPLETE);
|
||||
bool trackDeferredDeletion = event->isDeletionDeferred() && eventNotReady;
|
||||
|
||||
if (event->peekHasCallbacks() || (event->isExternallySynchronized() && eventNotReady) || trackDeferredDeletion) {
|
||||
if (event->peekHasCallbacks() || (event->isExternallySynchronized() && (event->peekExecutionStatus() > CL_COMPLETE))) {
|
||||
pendingList.push_back(event);
|
||||
if (event->peekTaskCount() < lowestTaskCount) {
|
||||
sleepCandidate = event;
|
||||
|
@ -144,16 +144,6 @@ Event::~Event() {
|
||||
unblockEventsBlockedByThis(executionStatus);
|
||||
}
|
||||
|
||||
void Event::handleCompletionBeforeDestruction() {
|
||||
if (!cmdQueue || isCompleted() || peekExecutionStatus() < 0 || (getRefInternalCount() > 1)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this->deletionDeferredToAsyncThread = true;
|
||||
cmdQueue->flush();
|
||||
ctx->getAsyncEventsHandler().registerEvent(this);
|
||||
}
|
||||
|
||||
cl_int Event::getEventProfilingInfo(cl_profiling_info paramName,
|
||||
size_t paramValueSize,
|
||||
void *paramValue,
|
||||
|
@ -301,16 +301,12 @@ class Event : public BaseObject<_cl_event>, public IDNode<Event> {
|
||||
this->cmdType = cmdType;
|
||||
}
|
||||
|
||||
void handleCompletionBeforeDestruction();
|
||||
|
||||
std::vector<Event *> &getParentEvents() { return this->parentEvents; }
|
||||
|
||||
virtual bool isExternallySynchronized() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isDeletionDeferred() const { return deletionDeferredToAsyncThread; }
|
||||
|
||||
static bool checkUserEventDependencies(cl_uint numEventsInWaitList, const cl_event *eventWaitList);
|
||||
|
||||
static void getBoundaryTimestampValues(TimestampPacketContainer *timestampContainer, uint64_t &globalStartTS, uint64_t &globalEndTS);
|
||||
@ -383,7 +379,6 @@ class Event : public BaseObject<_cl_event>, public IDNode<Event> {
|
||||
bool profilingEnabled;
|
||||
bool profilingCpuPath;
|
||||
bool dataCalculated;
|
||||
bool deletionDeferredToAsyncThread = false;
|
||||
TimeStampData queueTimeStamp;
|
||||
TimeStampData submitTimeStamp;
|
||||
uint64_t startTimeStamp;
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
#include "opencl/source/context/context.h"
|
||||
#include "opencl/source/event/event.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_event.h"
|
||||
|
||||
#include "cl_api_tests.h"
|
||||
|
||||
@ -36,7 +35,7 @@ TEST_F(clEventTests, GivenNullEventWhenReleasingEventThenClInvalidEventErrorIsRe
|
||||
}
|
||||
|
||||
TEST_F(clEventTests, GivenValidEventWhenReleasingEventThenSuccessIsReturned) {
|
||||
auto *pEvent = new MockEvent<Event>(pContext, pCommandQueue, CL_COMMAND_NDRANGE_KERNEL, 0, 0);
|
||||
auto *pEvent = new Event(nullptr, 0, 0, 0);
|
||||
ASSERT_NE(nullptr, pEvent);
|
||||
|
||||
cl_event event = (cl_event)pEvent;
|
||||
@ -46,7 +45,7 @@ TEST_F(clEventTests, GivenValidEventWhenReleasingEventThenSuccessIsReturned) {
|
||||
}
|
||||
|
||||
TEST_F(clEventTests, GivenValidEventWhenRetainedAndReleasedThenReferenceCountIsUpdated) {
|
||||
auto *pEvent = new MockEvent<Event>(pContext, pCommandQueue, CL_COMMAND_NDRANGE_KERNEL, 0, 0);
|
||||
auto *pEvent = new Event(nullptr, 0, 0, 0);
|
||||
ASSERT_NE(nullptr, pEvent);
|
||||
|
||||
cl_event event = (cl_event)pEvent;
|
||||
@ -62,7 +61,7 @@ TEST_F(clEventTests, GivenValidEventWhenRetainedAndReleasedThenReferenceCountIsU
|
||||
}
|
||||
|
||||
TEST_F(clEventTests, GivenValidEventWhenRetainedAndReleasedTwiceThenClSuccessIsReturned) {
|
||||
auto *pEvent = new MockEvent<Event>(pContext, pCommandQueue, CL_COMMAND_NDRANGE_KERNEL, 0, 0);
|
||||
auto *pEvent = new Event(nullptr, 0, 0, 0);
|
||||
ASSERT_NE(nullptr, pEvent);
|
||||
|
||||
cl_event event = (cl_event)pEvent;
|
||||
|
@ -861,12 +861,7 @@ HWTEST_F(CommandQueueHwTest, givenCommandQueueThatIsBlockedAndUsesCpuCopyWhenEve
|
||||
EventsRequest eventsRequest(0, nullptr, &returnEvent);
|
||||
cmdQHw->cpuDataTransferHandler(transferProperties, eventsRequest, retVal);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
auto neoEvent = castToObject<Event>(returnEvent);
|
||||
|
||||
EXPECT_EQ(CompletionStamp::notReady, neoEvent->peekTaskCount());
|
||||
|
||||
neoEvent->updateTaskCount(1, 1);
|
||||
EXPECT_EQ(CompletionStamp::notReady, castToObject<Event>(returnEvent)->peekTaskCount());
|
||||
clReleaseEvent(returnEvent);
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include "opencl/test/unit_test/mocks/mock_async_event_handler.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_command_queue.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_context.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_event.h"
|
||||
|
||||
using namespace NEO;
|
||||
using namespace ::testing;
|
||||
@ -55,10 +54,6 @@ class AsyncEventsHandlerTests : public ::testing::Test {
|
||||
++(*(int *)data);
|
||||
}
|
||||
|
||||
void setTagValue(uint32_t newValue) {
|
||||
*(commandQueue->getGpgpuCommandStreamReceiver().getTagAddress()) = newValue;
|
||||
}
|
||||
|
||||
void SetUp() override {
|
||||
dbgRestore.reset(new DebugManagerStateRestore());
|
||||
DebugManager.flags.EnableAsyncEventsHandler.set(false);
|
||||
@ -67,7 +62,7 @@ class AsyncEventsHandlerTests : public ::testing::Test {
|
||||
|
||||
commandQueue = make_releaseable<MockCommandQueue>(context.get(), context->getDevice(0), nullptr, false);
|
||||
|
||||
setTagValue(0);
|
||||
*(commandQueue->getGpgpuCommandStreamReceiver().getTagAddress()) = 0;
|
||||
|
||||
event1 = make_releaseable<MyEvent>(context.get(), commandQueue.get(), CL_COMMAND_BARRIER, CompletionStamp::notReady, CompletionStamp::notReady);
|
||||
event2 = make_releaseable<MyEvent>(context.get(), commandQueue.get(), CL_COMMAND_BARRIER, CompletionStamp::notReady, CompletionStamp::notReady);
|
||||
@ -316,75 +311,6 @@ TEST_F(AsyncEventsHandlerTests, givenUserEventWhenCallbackIsAddedThenDontRegiste
|
||||
userEvent.decRefInternal();
|
||||
}
|
||||
|
||||
TEST_F(AsyncEventsHandlerTests, givenNotReadyEventWhenReleasingThenRegisterAndTrackUntilCompleted) {
|
||||
DebugManager.flags.EnableAsyncEventsHandler.set(true);
|
||||
auto myHandler = new MockHandler(false);
|
||||
context->getAsyncEventsHandlerUniquePtr().reset(myHandler);
|
||||
|
||||
constexpr uint32_t eventTaskCount = 1;
|
||||
setTagValue(0);
|
||||
|
||||
auto mockEvent = new MockEvent<Event>(context.get(), commandQueue.get(), CL_COMMAND_NDRANGE_KERNEL, 0, eventTaskCount);
|
||||
|
||||
EXPECT_TRUE(myHandler->peekIsRegisterListEmpty());
|
||||
clReleaseEvent(mockEvent);
|
||||
EXPECT_FALSE(myHandler->peekIsRegisterListEmpty());
|
||||
|
||||
EXPECT_TRUE(myHandler->peekIsListEmpty());
|
||||
myHandler->process();
|
||||
EXPECT_FALSE(myHandler->peekIsListEmpty());
|
||||
|
||||
setTagValue(eventTaskCount);
|
||||
myHandler->process();
|
||||
EXPECT_TRUE(myHandler->peekIsRegisterListEmpty());
|
||||
EXPECT_TRUE(myHandler->peekIsListEmpty());
|
||||
}
|
||||
|
||||
TEST_F(AsyncEventsHandlerTests, givenTerminatedEventWhenReleasingThenDontRegister) {
|
||||
DebugManager.flags.EnableAsyncEventsHandler.set(true);
|
||||
auto myHandler = new MockHandler(false);
|
||||
context->getAsyncEventsHandlerUniquePtr().reset(myHandler);
|
||||
|
||||
constexpr uint32_t eventTaskCount = 1;
|
||||
setTagValue(0);
|
||||
|
||||
auto mockEvent = new MockEvent<Event>(context.get(), commandQueue.get(), CL_COMMAND_NDRANGE_KERNEL, 0, eventTaskCount);
|
||||
mockEvent->setStatus(-1);
|
||||
|
||||
clReleaseEvent(mockEvent);
|
||||
EXPECT_TRUE(myHandler->peekIsRegisterListEmpty());
|
||||
}
|
||||
|
||||
TEST_F(AsyncEventsHandlerTests, givenNotReadyEventWithRefCountWhenReleasingThenDontRegister) {
|
||||
DebugManager.flags.EnableAsyncEventsHandler.set(true);
|
||||
auto myHandler = new MockHandler(false);
|
||||
context->getAsyncEventsHandlerUniquePtr().reset(myHandler);
|
||||
|
||||
constexpr uint32_t eventTaskCount = 1;
|
||||
setTagValue(0);
|
||||
|
||||
auto mockEvent = new MockEvent<Event>(context.get(), commandQueue.get(), CL_COMMAND_NDRANGE_KERNEL, 0, eventTaskCount);
|
||||
mockEvent->incRefInternal();
|
||||
|
||||
clReleaseEvent(mockEvent);
|
||||
EXPECT_TRUE(myHandler->peekIsRegisterListEmpty());
|
||||
|
||||
setTagValue(eventTaskCount);
|
||||
mockEvent->decRefInternal();
|
||||
}
|
||||
|
||||
TEST_F(AsyncEventsHandlerTests, givenEventWithoutCommandQueueWhenReleasingThenDontRegister) {
|
||||
DebugManager.flags.EnableAsyncEventsHandler.set(true);
|
||||
auto myHandler = new MockHandler(false);
|
||||
context->getAsyncEventsHandlerUniquePtr().reset(myHandler);
|
||||
|
||||
auto userEvent = new UserEvent(context.get());
|
||||
userEvent->setStatus(CL_QUEUED);
|
||||
|
||||
clReleaseEvent(userEvent);
|
||||
EXPECT_TRUE(myHandler->peekIsRegisterListEmpty());
|
||||
}
|
||||
|
||||
TEST_F(AsyncEventsHandlerTests, givenRegistredEventsWhenProcessIsCalledThenReturnCandidateWithLowestTaskCount) {
|
||||
int event1Counter(0), event2Counter(0), event3Counter(0);
|
||||
|
||||
|
Reference in New Issue
Block a user