feature: experimental Counter Based Event support

Related-To: NEO-8145

Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
Dunajski, Bartosz
2023-10-31 17:56:27 +00:00
committed by Compute-Runtime-Automation
parent c9376c9829
commit a8c79e0ba1
10 changed files with 80 additions and 48 deletions

View File

@@ -194,6 +194,20 @@ EventPool *EventPool::create(DriverHandle *driver, Context *context, uint32_t nu
return eventPool.release();
}
void EventPool::setupDescriptorFlags(const ze_event_pool_desc_t *desc) {
eventPoolFlags = desc->flags;
if (eventPoolFlags & ZE_EVENT_POOL_FLAG_KERNEL_MAPPED_TIMESTAMP) {
eventPoolFlags |= ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP;
}
auto pNext = reinterpret_cast<const ze_base_desc_t *>(desc->pNext);
if (pNext && pNext->stype == ZE_STRUCTURE_TYPE_COUNTER_BASED_EVENT_POOL_EXP_DESC) {
counterBased = true;
}
}
bool EventPool::isEventPoolTimestampFlagSet() const {
if (NEO::DebugManager.flags.OverrideTimestampEvents.get() != -1) {
auto timestampOverride = !!NEO::DebugManager.flags.OverrideTimestampEvents.get();

View File

@@ -217,8 +217,8 @@ struct Event : _ze_event_handle_t {
this->metricStreamer = metricStreamer;
}
void updateInOrderExecState(std::shared_ptr<InOrderExecInfo> &newInOrderExecInfo, uint64_t signalValue, uint32_t allocationOffset);
bool isInOrderExecEvent() const { return inOrderExecEvent; }
void enableInOrderMode() { this->inOrderExecEvent = true; }
bool isCounterBased() const { return counterBased; }
void enableCounterBasedMode() { this->counterBased = true; }
NEO::GraphicsAllocation *getInOrderExecDataAllocation() const;
uint64_t getInOrderExecSignalValueWithSubmissionCounter() const;
uint64_t getInOrderExecBaseSignalValue() const { return inOrderExecSignalValue; }
@@ -287,7 +287,7 @@ struct Event : _ze_event_handle_t {
bool usingContextEndOffset = false;
bool signalAllEventPackets = false;
bool isFromIpcPool = false;
bool inOrderExecEvent = false;
bool counterBased = false;
uint64_t timestampRefreshIntervalInNanoSec = 0;
};
@@ -296,10 +296,7 @@ struct EventPool : _ze_event_pool_handle_t {
static ze_result_t openEventPoolIpcHandle(const ze_ipc_event_pool_handle_t &ipcEventPoolHandle, ze_event_pool_handle_t *eventPoolHandle,
DriverHandleImp *driver, ContextImp *context, uint32_t numDevices, ze_device_handle_t *deviceHandles);
EventPool(const ze_event_pool_desc_t *desc) : EventPool(desc->count) {
eventPoolFlags = desc->flags;
if (eventPoolFlags & ZE_EVENT_POOL_FLAG_KERNEL_MAPPED_TIMESTAMP) {
eventPoolFlags |= ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP;
}
setupDescriptorFlags(desc);
}
virtual ~EventPool();
MOCKABLE_VIRTUAL ze_result_t destroy();
@@ -356,9 +353,12 @@ struct EventPool : _ze_event_pool_handle_t {
return isImplicitScalingCapable;
}
bool isCounterBased() const { return counterBased; }
protected:
EventPool() = default;
EventPool(size_t numEvents) : numEvents(numEvents) {}
void setupDescriptorFlags(const ze_event_pool_desc_t *desc);
std::vector<Device *> devices;
@@ -381,6 +381,7 @@ struct EventPool : _ze_event_pool_handle_t {
bool isImportedIpcPool = false;
bool isShareableEventMemory = false;
bool isImplicitScalingCapable = false;
bool counterBased = false;
};
} // namespace L0

View File

@@ -73,7 +73,7 @@ struct EventImp : public Event {
ze_result_t calculateProfilingData();
ze_result_t queryStatusEventPackets();
ze_result_t queryInOrderEventStatus();
ze_result_t queryCounterBasedEventStatus();
void handleSuccessfulHostSynchronization();
MOCKABLE_VIRTUAL ze_result_t hostEventSetValue(TagSizeT eventValue);
ze_result_t hostEventSetValueTimestamps(TagSizeT eventVal);

View File

@@ -80,8 +80,8 @@ Event *Event::create(EventPool *eventPool, const ze_event_desc_t *desc, Device *
event->timestampRefreshIntervalInNanoSec = refreshTime * milliSecondsToNanoSeconds;
}
if (NEO::DebugManager.flags.ForceInOrderEvents.get() == 1) {
event->enableInOrderMode();
if (eventPool->isCounterBased() || NEO::DebugManager.flags.ForceInOrderEvents.get() == 1) {
event->enableCounterBasedMode();
}
return event;
@@ -150,7 +150,7 @@ void EventImp<TagSizeT>::assignKernelEventCompletionData(void *address) {
}
template <typename TagSizeT>
ze_result_t EventImp<TagSizeT>::queryInOrderEventStatus() {
ze_result_t EventImp<TagSizeT>::queryCounterBasedEventStatus() {
if (!this->inOrderExecInfo.get()) {
return ZE_RESULT_NOT_READY;
}
@@ -281,8 +281,8 @@ ze_result_t EventImp<TagSizeT>::queryStatus() {
return ZE_RESULT_SUCCESS;
}
if (this->inOrderExecEvent) {
return queryInOrderEventStatus();
if (this->counterBased) {
return queryCounterBasedEventStatus();
} else {
return queryStatusEventPackets();
}
@@ -396,7 +396,7 @@ ze_result_t EventImp<TagSizeT>::hostEventSetValue(TagSizeT eventVal) {
template <typename TagSizeT>
ze_result_t EventImp<TagSizeT>::hostSignal() {
if (this->isInOrderExecEvent()) {
if (this->isCounterBased()) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
@@ -447,7 +447,7 @@ ze_result_t EventImp<TagSizeT>::hostSynchronize(uint64_t timeout) {
waitStartTime = std::chrono::high_resolution_clock::now();
lastHangCheckTime = waitStartTime;
do {
if (NEO::DebugManager.flags.WaitForUserFenceOnEventHostSynchronize.get() == 1 && this->inOrderExecEvent) {
if (NEO::DebugManager.flags.WaitForUserFenceOnEventHostSynchronize.get() == 1 && this->counterBased) {
ret = waitForUserFence(timeout);
} else {
ret = queryStatus();
@@ -494,7 +494,7 @@ ze_result_t EventImp<TagSizeT>::hostSynchronize(uint64_t timeout) {
template <typename TagSizeT>
ze_result_t EventImp<TagSizeT>::reset() {
if (this->isInOrderExecEvent()) {
if (this->isCounterBased()) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}