Skip to content

Commit af0ede3

Browse files
committed
[UR] Declarations for graph record and replay
1 parent 704d56e commit af0ede3

File tree

4 files changed

+285
-0
lines changed

4 files changed

+285
-0
lines changed

unified-runtime/scripts/core/common.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,9 @@ etors:
284284
desc: "Device in question has `$X_DEVICE_INFO_AVAILABLE == false`"
285285
- name: ERROR_INVALID_SPEC_ID
286286
desc: "A specialization constant identifier is not valid."
287+
- name: ERROR_INVALID_GRAPH
288+
value: "0x7fff0002"
289+
desc: "A graph object is not valid."
287290
- name: ERROR_UNKNOWN
288291
value: "0x7ffffffe"
289292
desc: "Unknown or internal error"
Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
#
2+
# Copyright (C) 2025 Intel Corporation
3+
#
4+
# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions.
5+
# See LICENSE.TXT
6+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7+
#
8+
# See YaML.md for syntax definition
9+
#
10+
# TODO:
11+
# ZE_RESULT_ERROR_INVALID_GRAPH
12+
# ZE_RESULT_QUERY_TRUE
13+
# ZE_RESULT_QUERY_FALSE
14+
#
15+
--- #--------------------------------------------------------------------------
16+
type: header
17+
desc: "Intel $OneApi Unified Runtime Experimental APIs for Graph Record and Replay"
18+
--- #--------------------------------------------------------------------------
19+
type: handle
20+
desc: "Handle of record & replay graph object"
21+
class: $xGraph
22+
name: "$x_exp_graph_handle_t"
23+
--- #--------------------------------------------------------------------------
24+
type: handle
25+
desc: "Handle of record & replay executable graph object"
26+
class: $xGraph
27+
name: "$x_exp_executable_graph_handle_t"
28+
--- #--------------------------------------------------------------------------
29+
type: function
30+
desc: "Create a new record & replay graph instance explicitly."
31+
class: $xGraph
32+
name: CreateExp
33+
decl: static
34+
details:
35+
- "Create a new record & replay graph instance explicitly."
36+
params:
37+
- type: $x_context_handle_t
38+
name: hContext
39+
desc: "[in] Handle of the context object."
40+
- type: $x_exp_graph_handle_t*
41+
name: phGraph
42+
desc: "[out] Pointer to the handle of the created graph object."
43+
- type: void*
44+
name: pNext
45+
desc: "[out] pointer to extension-specific structure."
46+
returns:
47+
- $X_RESULT_SUCCESS
48+
- $X_RESULT_ERROR_INVALID_ARGUMENT
49+
--- #------------------------------------------k--------------------------------
50+
type: function
51+
desc: "Begin graph capture on the specified immediate command list."
52+
class: $xQueue
53+
name: BeginGraphCaptureExp
54+
params:
55+
- type: $x_queue_handle_t
56+
name: hQueue
57+
desc: "[in] Handle of the queue on which to begin graph capture."
58+
- type: void*
59+
name: pNext
60+
desc: "[in][optional] pointer to extension-specific structure."
61+
returns:
62+
- $X_RESULT_SUCCESS
63+
- $X_RESULT_ERROR_INVALID_ARGUMENT
64+
--- #--------------------------------------------------------------------------
65+
type: function
66+
desc: "Begin capturing commands into an existing graph on the specified immediate command list."
67+
class: $xQueue
68+
name: BeginCaptureIntoGraphExp
69+
params:
70+
- type: $x_queue_handle_t
71+
name: hQueue
72+
desc: "[in] Handle of the queue on which to begin graph capture."
73+
- type: $x_exp_graph_handle_t
74+
name: hGraph
75+
desc: "[in] Handle of the graph object to capture into."
76+
- type: void*
77+
name: pNext
78+
desc: "[in][optional] pointer to extension-specific structure."
79+
returns:
80+
- $X_RESULT_SUCCESS
81+
- $X_RESULT_ERROR_INVALID_ARGUMENT
82+
--- #--------------------------------------------------------------------------
83+
type: function
84+
desc: "End graph capture on the specified immediate command list."
85+
class: $xQueue
86+
name: EndGraphCaptureExp
87+
params:
88+
- type: $x_queue_handle_t
89+
name: hQueue
90+
desc: "[in] Handle of the queue on which to end graph capture."
91+
- type: $x_exp_graph_handle_t*
92+
name: phGraph
93+
desc: "[out] Pointer to the handle of the captured graph object."
94+
- type: void*
95+
name: pNext
96+
desc: "[out][optional] pointer to extension-specific structure."
97+
returns:
98+
- $X_RESULT_SUCCESS
99+
- $X_RESULT_ERROR_INVALID_ARGUMENT
100+
--- #--------------------------------------------------------------------------
101+
type: function
102+
desc: "Instantiate an executable graph from a recorded graph."
103+
class: $xQueue
104+
name: InstantiateGraphExp
105+
params:
106+
- type: $x_exp_graph_handle_t
107+
name: hGraph
108+
desc: "[in] Handle of the recorded graph to instantiate."
109+
- type: $x_exp_executable_graph_handle_t*
110+
name: phExecutableGraph
111+
desc: "[out] Pointer to the handle of the instantiated executable graph."
112+
- type: void*
113+
name: pNext
114+
desc: "[out][optional] pointer to extension-specific structure."
115+
returns:
116+
- $X_RESULT_SUCCESS
117+
- $X_RESULT_ERROR_INVALID_ARGUMENT
118+
--- #--------------------------------------------------------------------------
119+
type: function
120+
desc: "Append an executable graph to the queue."
121+
class: $xQueue
122+
name: AppendGraphExp
123+
params:
124+
- type: $x_queue_handle_t
125+
name: hQueue
126+
desc: "[in] Handle of the queue to append the graph to."
127+
- type: $x_exp_executable_graph_handle_t
128+
name: hGraph
129+
desc: "[in] Handle of the executable graph to append."
130+
- type: void*
131+
name: pNext
132+
desc: "[in][optional] pointer to extension-specific structure."
133+
- type: $x_event_handle_t
134+
name: hSignalEvent
135+
desc: "[in][optional] Event to be signaled on completion."
136+
- type: uint32_t
137+
name: numWaitEvents
138+
desc: "[in][optional] Number of events to wait on before executing."
139+
- type: $x_event_handle_t*
140+
name: phWaitEvents
141+
desc: "[in][optional][range(0, numWaitEvents)] Pointer to an array of events to wait on."
142+
returns:
143+
- $X_RESULT_SUCCESS
144+
- $X_RESULT_ERROR_INVALID_ARGUMENT
145+
--- #--------------------------------------------------------------------------
146+
type: function
147+
desc: "Destroy a recorded graph object."
148+
class: $xGraph
149+
name: DestroyExp
150+
params:
151+
- type: $x_exp_graph_handle_t
152+
name: hGraph
153+
desc: "[in] Handle of the graph object to destroy."
154+
returns:
155+
- $X_RESULT_SUCCESS
156+
- $X_RESULT_ERROR_INVALID_ARGUMENT
157+
--- #--------------------------------------------------------------------------
158+
type: function
159+
desc: "Destroy an instantiated executable graph object."
160+
class: $xGraph
161+
name: ExecutableGraphDestroyExp
162+
params:
163+
- type: $x_exp_executable_graph_handle_t
164+
name: hExecutableGraph
165+
desc: "[in] Handle of the executable graph object to destroy."
166+
returns:
167+
- $X_RESULT_SUCCESS
168+
- $X_RESULT_ERROR_INVALID_ARGUMENT
169+
--- #--------------------------------------------------------------------------
170+
type: function
171+
desc: "Query whether graph capture is currently enabled on the given queue."
172+
class: $xQueue
173+
name: IsGraphCaptureEnabledExp
174+
params:
175+
- type: $x_queue_handle_t
176+
name: hQueue
177+
desc: "[in] Native queue to query."
178+
- type: bool*
179+
name: hResult
180+
desc: "[out] Pointer to a boolean where the result will be stored."
181+
returns:
182+
- $X_RESULT_SUCCESS
183+
- $X_RESULT_ERROR_INVALID_ARGUMENT
184+
--- #--------------------------------------------------------------------------
185+
type: function
186+
desc: "Return whether the given recorded graph contains any nodes."
187+
class: $xGraph
188+
name: IsEmptyExp
189+
params:
190+
- type: $x_exp_graph_handle_t
191+
name: hGraph
192+
desc: "[in] Handle of the graph to query."
193+
returns:
194+
- $X_RESULT_ERROR_OUT_OF_HOST_MEMORY
195+
- $X_RESULT_ERROR_OUT_OF_RESOURCES
196+
--- #--------------------------------------------------------------------------
197+
type: function
198+
desc: "Dump the contents of the recorded graph to the provided file path."
199+
class: $xGraph
200+
name: DumpContentsExp
201+
params:
202+
- type: $x_exp_graph_handle_t
203+
name: hGraph
204+
desc: "[in] Handle of the graph to dump."
205+
- type: const char*
206+
name: filePath
207+
desc: "[in] Path to the file to write the dumped graph contents."
208+
- type: void*
209+
name: pNext
210+
desc: "[in][optional] pointer to extension-specific structure."
211+
returns:
212+
- $X_RESULT_ERROR_INVALID_VALUE
213+
- $X_RESULT_ERROR_OUT_OF_HOST_MEMORY
214+
- $X_RESULT_ERROR_OUT_OF_RESOURCES

unified-runtime/source/adapters/level_zero/v2/queue_immediate_in_order.hpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,40 @@ struct ur_queue_immediate_in_order_t : ur_object, ur_queue_t_ {
454454
createEventIfRequested(eventPool.get(), phEvent, this));
455455
}
456456

457+
// Graph capture experimental APIs - not supported on Level Zero adapter v2
458+
ur_result_t queueBeginGraphCapteExp(void *pNext) override {
459+
(void)pNext;
460+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
461+
}
462+
ur_result_t queueBeginCapteIntoGraphExp(ur_exp_graph_handle_t hGraph,
463+
void *pNext) override {
464+
(void)hGraph;
465+
(void)pNext;
466+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
467+
}
468+
ur_result_t queueEndGraphCapteExp(ur_exp_graph_handle_t *phGraph,
469+
void *pNext) override {
470+
(void)phGraph;
471+
(void)pNext;
472+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
473+
}
474+
ur_result_t queueAppendGraphExp(ur_exp_executable_graph_handle_t hGraph,
475+
void *pNext, ur_event_handle_t hSignalEvent,
476+
uint32_t numWaitEvents,
477+
ur_event_handle_t *phWaitEvents) override {
478+
(void)hGraph;
479+
(void)pNext;
480+
(void)hSignalEvent;
481+
(void)numWaitEvents;
482+
(void)phWaitEvents;
483+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
484+
}
485+
ur_result_t queueIsGraphCapteEnabledExp(bool *pResult) override {
486+
if (pResult)
487+
*pResult = false;
488+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
489+
}
490+
457491
ur::RefCount RefCount;
458492
};
459493

unified-runtime/source/adapters/level_zero/v2/queue_immediate_out_of_order.hpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,40 @@ struct ur_queue_immediate_out_of_order_t : ur_object, ur_queue_t_ {
506506
createEventIfRequested(eventPool.get(), phEvent, this));
507507
}
508508

509+
// Graph capture experimental APIs - not supported on Level Zero adapter v2
510+
ur_result_t queueBeginGraphCapteExp(void *pNext) override {
511+
(void)pNext;
512+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
513+
}
514+
ur_result_t queueBeginCapteIntoGraphExp(ur_exp_graph_handle_t hGraph,
515+
void *pNext) override {
516+
(void)hGraph;
517+
(void)pNext;
518+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
519+
}
520+
ur_result_t queueEndGraphCapteExp(ur_exp_graph_handle_t *phGraph,
521+
void *pNext) override {
522+
(void)phGraph;
523+
(void)pNext;
524+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
525+
}
526+
ur_result_t queueAppendGraphExp(ur_exp_executable_graph_handle_t hGraph,
527+
void *pNext, ur_event_handle_t hSignalEvent,
528+
uint32_t numWaitEvents,
529+
ur_event_handle_t *phWaitEvents) override {
530+
(void)hGraph;
531+
(void)pNext;
532+
(void)hSignalEvent;
533+
(void)numWaitEvents;
534+
(void)phWaitEvents;
535+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
536+
}
537+
ur_result_t queueIsGraphCapteEnabledExp(bool *pResult) override {
538+
if (pResult)
539+
*pResult = false;
540+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
541+
}
542+
509543
ur::RefCount RefCount;
510544
};
511545

0 commit comments

Comments
 (0)