mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Externally synchronized event
Adding support for externally synchronized events inside async events handler Change-Id: Iddc5d3ae25577b792d197aa5b5857618201a3449
This commit is contained in:

committed by
sys_ocldev

parent
c996bad881
commit
1e422813b8
@ -60,7 +60,7 @@ Event *AsyncEventsHandler::processList() {
|
||||
|
||||
for (auto event : list) {
|
||||
event->updateExecutionStatus();
|
||||
if (event->peekHasCallbacks()) {
|
||||
if (event->peekHasCallbacks() || (event->isExternallySynchronized() && (event->peekExecutionStatus() > CL_COMPLETE))) {
|
||||
pendingList.push_back(event);
|
||||
if (event->peekTaskCount() < lowestTaskCount) {
|
||||
sleepCandidate = event;
|
||||
|
@ -308,6 +308,10 @@ class Event : public BaseObject<_cl_event>, public IDNode<Event> {
|
||||
|
||||
std::vector<Event *> &getParentEvents() { return this->parentEvents; }
|
||||
|
||||
virtual bool isExternallySynchronized() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected:
|
||||
Event(Context *ctx, CommandQueue *cmdQueue, cl_command_type cmdType,
|
||||
uint32_t taskLevel, uint32_t taskCount);
|
||||
|
@ -133,6 +133,41 @@ TEST_F(AsyncEventsHandlerTests, givenNotCalledCallbacksWhenListIsProcessedThenDo
|
||||
expect(CL_COMPLETE, 1, 1, true);
|
||||
}
|
||||
|
||||
TEST_F(AsyncEventsHandlerTests, givenExternallSynchronizedEventWhenListIsProcessedAndEventIsNotInCompleteStateThenDontUnregister) {
|
||||
struct ExternallySynchronizedEvent : Event {
|
||||
ExternallySynchronizedEvent(int numUpdatesBeforeCompletion)
|
||||
: Event(nullptr, 0, 0, 0), numUpdatesBeforeCompletion(numUpdatesBeforeCompletion) {
|
||||
}
|
||||
|
||||
void updateExecutionStatus() override {
|
||||
++updateCount;
|
||||
if (updateCount == numUpdatesBeforeCompletion) {
|
||||
transitionExecutionStatus(CL_COMPLETE);
|
||||
}
|
||||
}
|
||||
|
||||
bool isExternallySynchronized() const override {
|
||||
return true;
|
||||
}
|
||||
|
||||
int updateCount = 0;
|
||||
int numUpdatesBeforeCompletion = 1;
|
||||
};
|
||||
|
||||
constexpr int numUpdatesBeforeCompletion = 5;
|
||||
auto *event = new ExternallySynchronizedEvent(numUpdatesBeforeCompletion);
|
||||
|
||||
handler->registerEvent(event);
|
||||
for (int i = 0; i < numUpdatesBeforeCompletion * 2; ++i) {
|
||||
handler->process();
|
||||
}
|
||||
|
||||
EXPECT_EQ(CL_COMPLETE, event->peekExecutionStatus());
|
||||
EXPECT_EQ(numUpdatesBeforeCompletion, event->updateCount);
|
||||
|
||||
event->release();
|
||||
}
|
||||
|
||||
TEST_F(AsyncEventsHandlerTests, givenDoubleRegisteredEventWhenListIsProcessedAndNoCallbacksToProcessThenUnregister) {
|
||||
event1->setTaskStamp(Event::eventNotReady - 1, 0);
|
||||
event1->addCallback(&this->callbackFcn, CL_SUBMITTED, &counter);
|
||||
|
@ -1355,6 +1355,20 @@ TEST_F(EventTest, addChildForEventUncompleted) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Event, whenCreatingRegularEventsThenExternalSynchronizationIsNotRequired) {
|
||||
Event *event = new Event(nullptr, 0, 0, 0);
|
||||
EXPECT_FALSE(event->isExternallySynchronized());
|
||||
event->release();
|
||||
|
||||
UserEvent *userEvent = new UserEvent();
|
||||
EXPECT_FALSE(userEvent->isExternallySynchronized());
|
||||
userEvent->release();
|
||||
|
||||
VirtualEvent *virtualEvent = new VirtualEvent();
|
||||
EXPECT_FALSE(virtualEvent->isExternallySynchronized());
|
||||
virtualEvent->release();
|
||||
}
|
||||
|
||||
TEST_F(EventTest, addChildForEventCompleted) {
|
||||
VirtualEvent virtualEvent;
|
||||
{
|
||||
|
Reference in New Issue
Block a user