Skip to content

Commit 2b30942

Browse files
author
Jaime Arteaga
authored
Add experimental extension for counter-based events (#221)
Resolves #145 Signed-off-by: Jaime Arteaga <[email protected]>
1 parent c0eb2c9 commit 2b30942

File tree

3 files changed

+125
-0
lines changed

3 files changed

+125
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<%
2+
import re
3+
from templates import helper as th
4+
%><%
5+
OneApi=tags['$OneApi']
6+
x=tags['$x']
7+
X=x.upper()
8+
%>
9+
:orphan:
10+
11+
.. _ZE_experimental_event_pool_counter_based:
12+
13+
=====================================
14+
Counter-Based Event Pools Extension
15+
=====================================
16+
17+
API
18+
----
19+
20+
* Enumerations
21+
22+
* ${x}_event_pool_counter_based_exp_flags_t
23+
* ${x}_event_pool_counter_based_exp_version_t
24+
25+
* Structures
26+
27+
* ${x}_event_pool_counter_based_exp_desc_t
28+
29+
Counter-Based Events
30+
~~~~~~~~~~~~~~~~~~~~~~~~~~
31+
32+
By default, events in Level Zero contains one of two states: signaled or not signaled.
33+
Signaling of an event, as well as resetting its state, can be done from either host or
34+
device.
35+
36+
Another way of tracking the state of an event is by using a counter, which is incremented
37+
every time a task has completed in the device. Using a counter-based event may provide
38+
Level Zero driver implementations with the opportunity for both functional and performance
39+
optimizations.
40+
41+
The following recommendations and restrictions apply to counter-based events:
42+
43+
- Counter-based events can be used only with in-orders lists, whether those are regular or immediate.
44+
- Counter-based events must not be reset, i.e., a call to ${x}EventHostReset or ${x}CommandListAppendEventReset
45+
is not allowed.
46+
- Counter-based events must not be signaled from host, i.e., a call to ${x}EventHostSignal is not allowed.
47+
- Counter-based events may be reused multiple times without a need for reset.
48+
- Counter-based events may be used on multiple command lists.
49+
- Querying a counter-based event queries only the last saved counter value from the last command list that incremented it,
50+
i.e., a signaled counter-based event always represents the completion of the last call to which it was passed as signal event.
51+
- Synchronizing on a counter-based event waits only for the last saved counter value from the last command list that incremented it.
52+
- A counter-based event may be passed as signaling event for a new append call without needing to wait for the signaling of
53+
the last call where it was used.
54+
55+
Counter-based events can be created by passing ${x}_event_pool_counter_based_exp_desc_t to ${x}EventPoolCreate
56+
as pNext member of ${x}_event_pool_desc_t.
57+
58+
.. parsed-literal::
59+
60+
uint32_t numEvents = 2;
61+
${x}_event_pool_handle_t eventPool = {};
62+
${x}_event_pool_desc_t eventPoolDesc = {${X}_STRUCTURE_TYPE_EVENT_POOL_DESC};
63+
eventPoolDesc.count = numEvents;
64+
65+
${x}_event_pool_counter_based_exp_desc_t counterBasedDesc = {${X}_STRUCTURE_TYPE_COUNTER_BASED_EVENT_POOL_EXP_DESC};
66+
counterBasedDesc.flags = ${X}_EVENT_POOL_COUNTER_BASED_EXP_FLAG_IMMEDIATE;
67+
eventPoolDesc.pNext = &counterBasedDesc;
68+
69+
${x}_result_t = zeEventPoolCreate(context, &eventPoolDesc, 1, &device, &eventPool));

scripts/core/common.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,10 @@ etors:
508508
desc: $x_rtas_geometry_aabbs_exp_cb_params_t
509509
version: "1.7"
510510
value: "0x00020013"
511+
- name: COUNTER_BASED_EVENT_POOL_EXP_DESC
512+
desc: $x_event_pool_counter_based_exp_desc_t
513+
version: "1.8"
514+
value: "0x00020014"
511515
- name: COMMAND_GRAPH_EXP_DESC
512516
desc: $x_command_graph_exp_desc_t
513517
version: "2.0"
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#
2+
# Copyright (C) 2019-2022 Intel Corporation
3+
#
4+
# SPDX-License-Identifier: MIT
5+
#
6+
# See YaML.md for syntax definition
7+
#
8+
--- #--------------------------------------------------------------------------
9+
type: header
10+
desc: "Intel $OneApi Level-Zero Extension APIs for Counter-based Event Pools"
11+
version: "1.8"
12+
--- #--------------------------------------------------------------------------
13+
type: macro
14+
desc: "Counter-based Event Pools Extension Name"
15+
version: "1.8"
16+
name: $X_EVENT_POOL_COUNTER_BASED_EXP_NAME
17+
value: '"$X_experimental_event_pool_counter_based"'
18+
--- #--------------------------------------------------------------------------
19+
type: enum
20+
desc: "Counter-based Event Pools Extension Version(s)"
21+
version: "1.8"
22+
name: $x_event_pool_counter_based_exp_version_t
23+
etors:
24+
- name: "1_0"
25+
value: "$X_MAKE_VERSION( 1, 0 )"
26+
desc: "version 1.0"
27+
--- #--------------------------------------------------------------------------
28+
type: enum
29+
desc: "Supported event flags for defining counter-based event pools."
30+
class: $xEventPool
31+
name: $x_event_pool_counter_based_exp_flags_t
32+
version: "1.8"
33+
etors:
34+
- name: IMMEDIATE
35+
desc: "Counter-based event pool is used for immediate command lists (default)"
36+
- name: NON_IMMEDIATE
37+
desc: "Counter-based event pool is for non-immediate command lists"
38+
--- #--------------------------------------------------------------------------
39+
type: struct
40+
desc: "Event pool descriptor for counter-based events. This structure may be passed to $xEventPoolCreate as pNext member of $x_event_pool_desc_t."
41+
class: $xEventPool
42+
version: "1.8"
43+
name: $x_event_pool_counter_based_exp_desc_t
44+
base: $x_base_desc_t
45+
members:
46+
- type: $x_event_pool_counter_based_exp_flags_t
47+
name: flags
48+
desc: |
49+
[in] mode flags.
50+
must be 0 (default) or a valid value of $x_event_pool_counter_based_exp_flag_t
51+
default behavior is counter-based event pool is only used for immediate command lists.
52+
init: "0"

0 commit comments

Comments
 (0)