rocprofiler-sdk/ompt/api_args.h Source File

rocprofiler-sdk/ompt/api_args.h Source File#

ROCprofiler-SDK developer API: rocprofiler-sdk/ompt/api_args.h Source File
ROCprofiler-SDK developer API 1.0.0
ROCm Profiling API and tools
api_args.h
1// MIT License
2//
3// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
4//
5// Permission is hereby granted, free of charge, to any person obtaining a copy
6// of this software and associated documentation files (the "Software"), to deal
7// in the Software without restriction, including without limitation the rights
8// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9// copies of the Software, and to permit persons to whom the Software is
10// furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in
13// all copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21// THE SOFTWARE.
22
23#pragma once
24
25#include <rocprofiler-sdk/defines.h>
26
27#include <rocprofiler-sdk/ompt/omp-tools.h>
28
29#include <stdint.h>
30
31ROCPROFILER_EXTERN_C_INIT
32
33// all the available callback interface runtime entry points
34typedef struct rocprofiler_ompt_callback_functions_t
35{
36 ompt_enumerate_states_t ompt_enumerate_states;
37 ompt_enumerate_mutex_impls_t ompt_enumerate_mutex_impls;
38 ompt_get_thread_data_t ompt_get_thread_data;
39 ompt_get_num_places_t ompt_get_num_places;
40 ompt_get_place_proc_ids_t ompt_get_place_proc_ids;
41 ompt_get_place_num_t ompt_get_place_num;
42 ompt_get_partition_place_nums_t ompt_get_partition_place_nums;
43 ompt_get_proc_id_t ompt_get_proc_id;
44 ompt_get_state_t ompt_get_state;
45 ompt_get_parallel_info_t ompt_get_parallel_info;
46 ompt_get_task_info_t ompt_get_task_info;
47 ompt_get_task_memory_t ompt_get_task_memory;
48 ompt_get_num_devices_t ompt_get_num_devices;
49 ompt_get_num_procs_t ompt_get_num_procs;
50 ompt_get_target_info_t ompt_get_target_info;
51 ompt_get_unique_id_t ompt_get_unique_id;
52} rocprofiler_ompt_callback_functions_t;
53
54// Empty struct has a size of 0 in C but size of 1 in C++.
55// This struct is added to the union members which represent
56// functions with no arguments to ensure ABI compatibility
57typedef struct rocprofiler_ompt_no_args
58{
59 char empty;
60} rocprofiler_ompt_no_args;
61
62typedef union rocprofiler_ompt_args_t
63{
64 // The ompt_data_t* values passed to the client tool are proxies.
65 // This allows the client tool to use them as it would in their own
66 // OMPT tool.
67 // We keepa a map from the address of the ompt_data_t passed to the SDK's
68 // callback to the proxy object and keep it in sync when a callback is done
69 // to the client tool.
70 struct
71 {
72 ompt_thread_t thread_type;
73 ompt_data_t* thread_data;
74 } thread_begin;
75
76 struct
77 {
78 ompt_data_t* thread_data;
79 } thread_end;
80
81 struct
82 {
83 ompt_data_t* encountering_task_data;
84 const ompt_frame_t* encountering_task_frame;
85 ompt_data_t* parallel_data;
86 unsigned int requested_parallelism;
87 int flags;
88 const void* codeptr_ra;
89 } parallel_begin;
90
91 struct
92 {
93 ompt_data_t* parallel_data;
94 ompt_data_t* encountering_task_data;
95 int flags;
96 const void* codeptr_ra;
97 } parallel_end;
98
99 struct
100 {
101 ompt_data_t* encountering_task_data;
102 const ompt_frame_t* encountering_task_frame;
103 ompt_data_t* new_task_data;
104 int flags;
105 int has_dependences;
106 const void* codeptr_ra;
107 } task_create;
108
109 struct
110 {
111 ompt_data_t* prior_task_data;
112 ompt_task_status_t prior_task_status;
113 ompt_data_t* next_task_data;
114 } task_schedule;
115
116 struct
117 {
118 ompt_scope_endpoint_t endpoint;
119 ompt_data_t* parallel_data;
120 ompt_data_t* task_data;
121 unsigned int actual_parallelism;
122 unsigned int index;
123 int flags;
124 } implicit_task;
125
126 struct
127 {
128 int device_num;
129 const char* type;
130 ompt_device_t* device;
131 ompt_function_lookup_t lookup;
132 const char* documentation;
133 } device_initialize;
134
135 struct
136 {
137 int device_num;
138 } device_finalize;
139
140 struct
141 {
142 int device_num;
143 const char* filename;
144 int64_t offset_in_file;
145 void* vma_in_file;
146 size_t bytes;
147 void* host_addr;
148 void* device_addr;
149 uint64_t module_id;
150 } device_load;
151
152 // struct
153 // {
154 // int device_num;
155 // uint64_t module_id;
156 // } device_unload;
157
158 struct
159 {
160 ompt_sync_region_t kind;
161 ompt_scope_endpoint_t endpoint;
162 ompt_data_t* parallel_data;
163 ompt_data_t* task_data;
164 const void* codeptr_ra;
165 } sync_region_wait;
166
167 struct
168 {
169 ompt_mutex_t kind;
170 ompt_wait_id_t wait_id;
171 const void* codeptr_ra;
172 } mutex_released;
173
174 struct
175 {
176 ompt_data_t* task_data;
177 const ompt_dependence_t* deps;
178 int ndeps;
179 } dependences;
180
181 struct
182 {
183 ompt_data_t* src_task_data;
184 ompt_data_t* sink_task_data;
185 } task_dependence;
186
187 struct
188 {
189 ompt_work_t work_type;
190 ompt_scope_endpoint_t endpoint;
191 ompt_data_t* parallel_data;
192 ompt_data_t* task_data;
193 uint64_t count;
194 const void* codeptr_ra;
195 } work;
196
197 struct
198 {
199 ompt_scope_endpoint_t endpoint;
200 ompt_data_t* parallel_data;
201 ompt_data_t* task_data;
202 const void* codeptr_ra;
203 } masked;
204
205 struct
206 {
207 ompt_sync_region_t kind;
208 ompt_scope_endpoint_t endpoint;
209 ompt_data_t* parallel_data;
210 ompt_data_t* task_data;
211 const void* codeptr_ra;
212 } sync_region;
213
214 struct
215 {
216 ompt_mutex_t kind;
217 unsigned int hint;
218 unsigned int impl;
219 ompt_wait_id_t wait_id;
220 const void* codeptr_ra;
221 } lock_init;
222
223 struct
224 {
225 ompt_mutex_t kind;
226 ompt_wait_id_t wait_id;
227 const void* codeptr_ra;
228 } lock_destroy;
229
230 struct
231 {
232 ompt_mutex_t kind;
233 unsigned int hint;
234 unsigned int impl;
235 ompt_wait_id_t wait_id;
236 const void* codeptr_ra;
237 } mutex_acquire;
238
239 struct
240 {
241 ompt_mutex_t kind;
242 ompt_wait_id_t wait_id;
243 const void* codeptr_ra;
244 } mutex_acquired;
245
246 struct
247 {
248 ompt_scope_endpoint_t endpoint;
249 ompt_wait_id_t wait_id;
250 const void* codeptr_ra;
251 } nest_lock;
252
253 struct
254 {
255 ompt_data_t* thread_data;
256 const void* codeptr_ra;
257 } flush;
258
259 struct
260 {
261 ompt_data_t* task_data;
262 int flags;
263 const void* codeptr_ra;
264 } cancel;
265
266 struct
267 {
268 ompt_sync_region_t kind;
269 ompt_scope_endpoint_t endpoint;
270 ompt_data_t* parallel_data;
271 ompt_data_t* task_data;
272 const void* codeptr_ra;
273 } reduction;
274
275 struct
276 {
277 ompt_data_t* parallel_data;
278 ompt_data_t* task_data;
279 ompt_dispatch_t kind;
280 ompt_data_t instance;
281 } dispatch;
282
283 struct
284 {
285 ompt_target_t kind;
286 ompt_scope_endpoint_t endpoint;
287 int device_num;
288 ompt_data_t* task_data;
289 ompt_data_t* target_task_data;
290 ompt_data_t* target_data;
291 const void* codeptr_ra;
292 } target_emi;
293
294 struct
295 {
296 ompt_scope_endpoint_t endpoint;
297 ompt_data_t* target_task_data;
298 ompt_data_t* target_data;
299 ompt_data_t* host_op_id;
300 ompt_target_data_op_t optype;
301 void* src_address;
302 int src_device_num;
303 void* dst_address;
304 int dst_device_num;
305 size_t bytes;
306 const void* codeptr_ra;
307 } target_data_op_emi;
308
309 struct
310 {
311 ompt_scope_endpoint_t endpoint;
312 ompt_data_t* target_data;
313 ompt_data_t* host_op_id;
314 unsigned int requested_num_teams;
315 } target_submit_emi;
316
317 // struct
318 // {
319 // unsigned int nitems;
320 // void** host_addr;
321 // void** device_addr;
322 // size_t* bytes;
323 // unsigned int* mapping_flags;
324 // const void* codeptr_ra;
325 // } target_map_emi;
326
327 struct
328 {
329 ompt_severity_t severity;
330 const char* message;
331 size_t length;
332 const void* codeptr_ra;
333 } error;
334
335 rocprofiler_ompt_callback_functions_t callback_functions;
336
337} rocprofiler_ompt_args_t;
338
339ROCPROFILER_EXTERN_C_FINI