Skip to content

Commit 409aff1

Browse files
committed
[L0 v2] event improvements
- Implement native handle API for events - Always allocate events as multi-device when using provider_normal, as all events can be used on multiple devices
1 parent 3609cd6 commit 409aff1

17 files changed

+395
-220
lines changed

source/adapters/level_zero/v2/api.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -181,21 +181,6 @@ ur_result_t urKernelGetSuggestedLocalWorkSize(ur_kernel_handle_t hKernel,
181181
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
182182
}
183183

184-
ur_result_t urEventGetNativeHandle(ur_event_handle_t hEvent,
185-
ur_native_handle_t *phNativeEvent) {
186-
logger::error("{} function not implemented!", __FUNCTION__);
187-
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
188-
}
189-
190-
ur_result_t
191-
urEventCreateWithNativeHandle(ur_native_handle_t hNativeEvent,
192-
ur_context_handle_t hContext,
193-
const ur_event_native_properties_t *pProperties,
194-
ur_event_handle_t *phEvent) {
195-
logger::error("{} function not implemented!", __FUNCTION__);
196-
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
197-
}
198-
199184
ur_result_t urEventSetCallback(ur_event_handle_t hEvent,
200185
ur_execution_info_t execStatus,
201186
ur_event_callback_t pfnNotify, void *pUserData) {

source/adapters/level_zero/v2/context.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "../device.hpp"
1212

1313
#include "context.hpp"
14+
#include "event_provider_counter.hpp"
1415
#include "event_provider_normal.hpp"
1516

1617
static std::vector<ur_device_handle_t>
@@ -48,14 +49,21 @@ ur_context_handle_t_::ur_context_handle_t_(ze_context_handle_t hContext,
4849
const ur_device_handle_t *phDevices,
4950
bool ownZeContext)
5051
: commandListCache(hContext),
51-
eventPoolCache(phDevices[0]->Platform->getNumDevices(),
52+
eventPoolCache(this, phDevices[0]->Platform->getNumDevices(),
5253
[context = this, platform = phDevices[0]->Platform](
53-
DeviceId deviceId, v2::event_flags_t flags) {
54-
auto device = platform->getDeviceById(deviceId);
54+
DeviceId deviceId, v2::event_flags_t flags)
55+
-> std::unique_ptr<v2::event_provider> {
56+
assert((flags & v2::EVENT_FLAGS_COUNTER) != 0);
57+
58+
std::ignore = deviceId;
59+
5560
// TODO: just use per-context id?
5661
return std::make_unique<v2::provider_normal>(
57-
context, device, v2::QUEUE_IMMEDIATE, flags);
62+
context, v2::QUEUE_IMMEDIATE, flags);
5863
}),
64+
nativeEventsPool(this, std::make_unique<v2::provider_normal>(
65+
this, v2::QUEUE_IMMEDIATE,
66+
v2::EVENT_FLAGS_PROFILING_ENABLED)),
5967
hContext(hContext, ownZeContext),
6068
hDevices(phDevices, phDevices + numDevices),
6169
p2pAccessDevices(populateP2PDevices(

source/adapters/level_zero/v2/context.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ struct ur_context_handle_t_ : _ur_object {
3838
v2::command_list_cache_t commandListCache;
3939
v2::event_pool_cache eventPoolCache;
4040

41+
// pool used for urEventCreateWithNativeHandle when native handle is NULL
42+
v2::event_pool nativeEventsPool;
43+
4144
private:
4245
const v2::raii::ze_context_handle_t hContext;
4346
const std::vector<ur_device_handle_t> hDevices;

0 commit comments

Comments
 (0)