Skip to content

Commit 265ab3f

Browse files
committed
check if driver supports cb events
1 parent 9bb91df commit 265ab3f

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

unified-runtime/source/adapters/level_zero/device.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1665,6 +1665,8 @@ ur_result_t urDeviceCreateWithNativeHandle(
16651665
ur_device_handle_t Dev = nullptr;
16661666
for (const auto &p : GlobalAdapter->Platforms) {
16671667
Dev = p->getDeviceFromNativeHandle(ZeDevice);
1668+
if (Dev)
1669+
break;
16681670
}
16691671

16701672
if (Dev == nullptr)

unified-runtime/source/adapters/level_zero/v2/context.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,14 @@ ur_context_handle_t_::ur_context_handle_t_(ze_context_handle_t hContext,
8686
auto device = platform->getDeviceById(deviceId);
8787

8888
// TODO: just use per-context id?
89-
return std::make_unique<v2::provider_counter>(
90-
platform, context, v2::QUEUE_IMMEDIATE, device, flags);
89+
// Use counter-based events only if the extension is available
90+
if (platform->ZeDriverEventPoolCountingEventsExtensionFound) {
91+
return std::make_unique<v2::provider_counter>(
92+
platform, context, v2::QUEUE_IMMEDIATE, device, flags);
93+
} else {
94+
return std::make_unique<v2::provider_normal>(
95+
context, v2::QUEUE_IMMEDIATE, flags);
96+
}
9197
}),
9298
eventPoolCacheRegular(this, phDevices[0]->Platform->getNumDevices(),
9399
[context = this, platform = phDevices[0]->Platform](

0 commit comments

Comments
 (0)