You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update Tracing Layer Documentation for the expanded support (#414)
- Fix the Tracing Layer Readme to outline the full feature set as of
additions including dynamic tracing enable/disable and query of
tracing state and additional clarifications.
Signed-off-by: Neil R. Spruit <[email protected]>
Copy file name to clipboardExpand all lines: source/layers/tracing/README.md
+89-3Lines changed: 89 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,50 @@ Tracing provides for a tool to create one or more __tracers__. A __tracer__ is
8
8
In summary, this tracing implementation provides functions to create one or more __tracers__, acquiring a __tracer handle__ for each, then registering a set of __prologue__ and __epilogue__ functions for each __tracer handle__, enabling and disabling a __tracer__, and for destroying a __tracer__.
9
9
10
10
## Enabling Tracing in the Loader
11
-
Tracing is implemented as a layer in the loader. This tracing layer must be enabled by setting the environment variable **ZE_ENABLE_TRACING_LAYER** to 1. This environment variable must be defined in the application process's context before that process calls _zeInit()_.
11
+
Tracing is implemented as a layer in the loader. There are two ways to enable the tracing layer:
The tracing layer can be enabled for the entire process runtime by setting the environment variable **ZE_ENABLE_TRACING_LAYER** to 1. This environment variable must be defined in the application process's context before that process calls _zeInitDrivers()_. When enabled this way, the tracing layer remains active for the entire duration of the application.
The tracing layer can also be enabled and disabled dynamically at runtime using the following APIs:
18
+
19
+
-**zelEnableTracingLayer()** - Enables the tracing layer at runtime. Can be called at any point during application execution, but will only affect subsequent API calls made after the call to this function.
20
+
21
+
-**zelDisableTracingLayer()** - Disables the tracing layer at runtime. After calling this function, subsequent API calls will not be intercepted by the tracing layer.
22
+
23
+
-**zelGetTracingLayerState(bool* enabled)** - Queries the current state of the tracing layer. Sets the boolean pointed to by `enabled` to `true` if the tracing layer is currently active, or `false` if it is disabled.
24
+
25
+
These functions are defined in `include/loader/ze_loader.h`.
26
+
27
+
Dynamic tracing control provides the flexibility to:
28
+
- Enable tracing only for specific regions of code
29
+
- Reduce performance overhead by disabling tracing when not needed
30
+
- Programmatically control tracing based on runtime conditions
31
+
32
+
### Tracing Layer vs Tracer Enable/Disable
33
+
34
+
It is important to understand the distinction between **enabling/disabling the tracing layer** and **enabling/disabling individual tracers**:
35
+
36
+
#### Tracing Layer Enable/Disable
37
+
- Controls whether the tracing layer infrastructure is active in the loader
38
+
- Affects **all** Level Zero API calls globally
39
+
- When the tracing layer is disabled, **no** API calls are intercepted regardless of individual tracer states
40
+
- Controlled via `zelEnableTracingLayer()`, `zelDisableTracingLayer()`, and the `ZE_ENABLE_TRACING_LAYER` environment variable
41
+
- Represents a global on/off switch for the entire tracing infrastructure
42
+
43
+
#### Individual Tracer Enable/Disable
44
+
- Controls whether a specific tracer's callbacks are invoked
45
+
- Requires the tracing layer to be enabled first
46
+
- Controlled via `zelTracerSetEnabled()` for each tracer handle
47
+
- Multiple tracers can coexist, each with their own enabled/disabled state
48
+
- A tracer being enabled has no effect if the tracing layer itself is disabled
49
+
50
+
**In summary:**
51
+
- The **tracing layer** must be enabled for any tracing to occur
52
+
- Individual **tracers** must also be enabled for their callbacks to be invoked
53
+
- Disabling the tracing layer stops all tracing regardless of individual tracer states
54
+
- When the tracing layer is enabled, only those tracers that are also enabled will have their callbacks invoked
12
55
13
56
## Tracing API
14
57
The API for using this tracing implementation is this header file below. Please examine that header file for tracing API details.
@@ -89,6 +132,7 @@ The following pseudo-code demonstrates a basic usage of API tracing:
0 commit comments