feature: add L0 API to wait for completion of all submissions to given device

Related-To: NEO-14560
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2025-05-07 13:20:39 +00:00
committed by Compute-Runtime-Automation
parent ba85f7417d
commit 1b42ebf7fb
6 changed files with 136 additions and 0 deletions

View File

@@ -5,6 +5,9 @@
*
*/
#include "shared/source/command_stream/command_stream_receiver.h"
#include "shared/source/device/device.h"
#include "level_zero/core/source/device/device.h"
#include "level_zero/core/source/driver/driver.h"
#include "level_zero/core/source/driver/driver_handle_imp.h"
@@ -27,3 +30,29 @@ ze_device_handle_t ZE_APICALL zerIdentifierTranslateToDeviceHandle(uint32_t iden
}
return driverHandle->devicesToExpose[identifier];
}
ze_result_t ZE_APICALL zeDeviceSynchronize(ze_device_handle_t hDevice) {
auto device = L0::Device::fromHandle(hDevice);
for (auto &engine : device->getNEODevice()->getAllEngines()) {
auto waitStatus = engine.commandStreamReceiver->waitForTaskCountWithKmdNotifyFallback(
engine.commandStreamReceiver->peekTaskCount(),
engine.commandStreamReceiver->obtainCurrentFlushStamp(),
false,
NEO::QueueThrottle::MEDIUM);
if (waitStatus == NEO::WaitStatus::gpuHang) {
return ZE_RESULT_ERROR_DEVICE_LOST;
}
}
for (auto &secondaryCsr : device->getNEODevice()->getSecondaryCsrs()) {
auto waitStatus = secondaryCsr->waitForTaskCountWithKmdNotifyFallback(
secondaryCsr->peekTaskCount(),
secondaryCsr->obtainCurrentFlushStamp(),
false,
NEO::QueueThrottle::MEDIUM);
if (waitStatus == NEO::WaitStatus::gpuHang) {
return ZE_RESULT_ERROR_DEVICE_LOST;
}
}
return ZE_RESULT_SUCCESS;
}