Skip to content

Commit be9d600

Browse files
authored
Merge pull request #2354 from igchor/event_native
[L0 v2] implement native handle API for event
2 parents 6d4eec8 + 8c76917 commit be9d600

20 files changed

+541
-256
lines changed

source/adapters/level_zero/v2/api.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -188,21 +188,6 @@ ur_result_t urKernelGetSuggestedLocalWorkSize(ur_kernel_handle_t hKernel,
188188
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
189189
}
190190

191-
ur_result_t urEventGetNativeHandle(ur_event_handle_t hEvent,
192-
ur_native_handle_t *phNativeEvent) {
193-
logger::error("{} function not implemented!", __FUNCTION__);
194-
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
195-
}
196-
197-
ur_result_t
198-
urEventCreateWithNativeHandle(ur_native_handle_t hNativeEvent,
199-
ur_context_handle_t hContext,
200-
const ur_event_native_properties_t *pProperties,
201-
ur_event_handle_t *phEvent) {
202-
logger::error("{} function not implemented!", __FUNCTION__);
203-
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
204-
}
205-
206191
ur_result_t urEventSetCallback(ur_event_handle_t hEvent,
207192
ur_execution_info_t execStatus,
208193
ur_event_callback_t pfnNotify, void *pUserData) {

source/adapters/level_zero/v2/context.cpp

Lines changed: 13 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,22 @@ 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+
std::ignore = platform;
60+
5561
// TODO: just use per-context id?
5662
return std::make_unique<v2::provider_normal>(
57-
context, device, v2::QUEUE_IMMEDIATE, flags);
63+
context, v2::QUEUE_IMMEDIATE, flags);
5864
}),
65+
nativeEventsPool(this, std::make_unique<v2::provider_normal>(
66+
this, v2::QUEUE_IMMEDIATE,
67+
v2::EVENT_FLAGS_PROFILING_ENABLED)),
5968
hContext(hContext, ownZeContext),
6069
hDevices(phDevices, phDevices + numDevices),
6170
p2pAccessDevices(populateP2PDevices(

source/adapters/level_zero/v2/context.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ 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+
// (uses non-counter based events to allow for signaling from host)
43+
v2::event_pool nativeEventsPool;
44+
4145
private:
4246
const v2::raii::ze_context_handle_t hContext;
4347
const std::vector<ur_device_handle_t> hDevices;

0 commit comments

Comments
 (0)