Implement zesDriverEventListenEx

Signed-off-by: Mayank Raghuwanshi <mayank.raghuwanshi@intel.com>
This commit is contained in:
Mayank Raghuwanshi
2021-04-05 09:38:22 +05:30
committed by Compute-Runtime-Automation
parent ebb1474210
commit 61c08c052f
18 changed files with 146 additions and 19 deletions

View File

@@ -43,7 +43,7 @@ ze_result_t DriverHandleImp::sysmanEventsListen(
zes_event_type_flags_t *pEvents) {
bool gotSysmanEvent = false;
memset(pEvents, 0, count * sizeof(zes_event_type_flags_t));
auto timeToExitLoop = std::chrono::steady_clock::now() + std::chrono::milliseconds(timeout);
auto timeToExitLoop = L0::steadyClock::now() + std::chrono::milliseconds(timeout);
do {
for (uint32_t devIndex = 0; devIndex < count; devIndex++) {
gotSysmanEvent = L0::SysmanDevice::fromHandle(phDevices[devIndex])->deviceEventListen(pEvents[devIndex], timeout);
@@ -56,7 +56,33 @@ ze_result_t DriverHandleImp::sysmanEventsListen(
break;
}
std::this_thread::sleep_for(std::chrono::milliseconds(10)); // Sleep for 10 milliseconds before next check of events
} while ((std::chrono::steady_clock::now() <= timeToExitLoop));
} while ((L0::steadyClock::now() <= timeToExitLoop));
return ZE_RESULT_SUCCESS;
}
ze_result_t DriverHandleImp::sysmanEventsListenEx(
uint64_t timeout,
uint32_t count,
zes_device_handle_t *phDevices,
uint32_t *pNumDeviceEvents,
zes_event_type_flags_t *pEvents) {
bool gotSysmanEvent = false;
memset(pEvents, 0, count * sizeof(zes_event_type_flags_t));
auto timeToExitLoop = L0::steadyClock::now() + std::chrono::duration<uint64_t, std::milli>(timeout);
do {
for (uint32_t devIndex = 0; devIndex < count; devIndex++) {
gotSysmanEvent = L0::SysmanDevice::fromHandle(phDevices[devIndex])->deviceEventListen(pEvents[devIndex], timeout);
if (gotSysmanEvent) {
*pNumDeviceEvents = 1;
break;
}
}
if (gotSysmanEvent) {
break;
}
std::this_thread::sleep_for(std::chrono::milliseconds(10)); // Sleep for 10 milliseconds before next check of events
} while ((L0::steadyClock::now() <= timeToExitLoop));
return ZE_RESULT_SUCCESS;
}