xref: /freebsd/lib/libomp/omp-tools.h (revision 25ecdc7d52770caf1c9b44b5ec11f468f6b636f3)
1 // $FreeBSD$
2 /*
3  * include/omp-tools.h.var
4  */
5 
6 //===----------------------------------------------------------------------===//
7 //
8 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
9 // See https://llvm.org/LICENSE.txt for license information.
10 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef __OMPT__
15 #define __OMPT__
16 
17 /*****************************************************************************
18  * system include files
19  *****************************************************************************/
20 
21 #include <stdint.h>
22 #include <stddef.h>
23 
24 /*****************************************************************************
25  * iteration macros
26  *****************************************************************************/
27 
28 #define FOREACH_OMPT_INQUIRY_FN(macro)      \
29     macro (ompt_enumerate_states)           \
30     macro (ompt_enumerate_mutex_impls)      \
31                                             \
32     macro (ompt_set_callback)               \
33     macro (ompt_get_callback)               \
34                                             \
35     macro (ompt_get_state)                  \
36                                             \
37     macro (ompt_get_parallel_info)          \
38     macro (ompt_get_task_info)              \
39     macro (ompt_get_task_memory)            \
40     macro (ompt_get_thread_data)            \
41     macro (ompt_get_unique_id)              \
42     macro (ompt_finalize_tool)              \
43                                             \
44     macro(ompt_get_num_procs)               \
45     macro(ompt_get_num_places)              \
46     macro(ompt_get_place_proc_ids)          \
47     macro(ompt_get_place_num)               \
48     macro(ompt_get_partition_place_nums)    \
49     macro(ompt_get_proc_id)                 \
50                                             \
51     macro(ompt_get_target_info)             \
52     macro(ompt_get_num_devices)
53 
54 #define FOREACH_OMPT_STATE(macro)                                                                \
55                                                                                                 \
56     /* first available state */                                                                 \
57     macro (ompt_state_undefined, 0x102)      /* undefined thread state */                        \
58                                                                                                 \
59     /* work states (0..15) */                                                                   \
60     macro (ompt_state_work_serial, 0x000)    /* working outside parallel */                      \
61     macro (ompt_state_work_parallel, 0x001)  /* working within parallel */                       \
62     macro (ompt_state_work_reduction, 0x002) /* performing a reduction */                        \
63                                                                                                 \
64     /* barrier wait states (16..31) */                                                          \
65     macro (ompt_state_wait_barrier, 0x010)   /* waiting at a barrier */                          \
66     macro (ompt_state_wait_barrier_implicit_parallel, 0x011)                                     \
67                                             /* implicit barrier at the end of parallel region */\
68     macro (ompt_state_wait_barrier_implicit_workshare, 0x012)                                    \
69                                             /* implicit barrier at the end of worksharing */    \
70     macro (ompt_state_wait_barrier_implicit, 0x013)  /* implicit barrier */                      \
71     macro (ompt_state_wait_barrier_explicit, 0x014)  /* explicit barrier */                      \
72                                                                                                 \
73     /* task wait states (32..63) */                                                             \
74     macro (ompt_state_wait_taskwait, 0x020)  /* waiting at a taskwait */                         \
75     macro (ompt_state_wait_taskgroup, 0x021) /* waiting at a taskgroup */                        \
76                                                                                                 \
77     /* mutex wait states (64..127) */                                                           \
78     macro (ompt_state_wait_mutex, 0x040)                                                         \
79     macro (ompt_state_wait_lock, 0x041)      /* waiting for lock */                              \
80     macro (ompt_state_wait_critical, 0x042)  /* waiting for critical */                          \
81     macro (ompt_state_wait_atomic, 0x043)    /* waiting for atomic */                            \
82     macro (ompt_state_wait_ordered, 0x044)   /* waiting for ordered */                           \
83                                                                                                 \
84     /* target wait states (128..255) */                                                         \
85     macro (ompt_state_wait_target, 0x080)        /* waiting for target region */                 \
86     macro (ompt_state_wait_target_map, 0x081)    /* waiting for target data mapping operation */ \
87     macro (ompt_state_wait_target_update, 0x082) /* waiting for target update operation */       \
88                                                                                                 \
89     /* misc (256..511) */                                                                       \
90     macro (ompt_state_idle, 0x100)           /* waiting for work */                              \
91     macro (ompt_state_overhead, 0x101)       /* overhead excluding wait states */                \
92                                                                                                 \
93     /* implementation-specific states (512..) */
94 
95 
96 #define FOREACH_KMP_MUTEX_IMPL(macro)                                                \
97     macro (kmp_mutex_impl_none, 0)         /* unknown implementation */              \
98     macro (kmp_mutex_impl_spin, 1)         /* based on spin */                       \
99     macro (kmp_mutex_impl_queuing, 2)      /* based on some fair policy */           \
100     macro (kmp_mutex_impl_speculative, 3)  /* based on HW-supported speculation */
101 
102 #define FOREACH_OMPT_EVENT(macro)                                                                                        \
103                                                                                                                          \
104     /*--- Mandatory Events ---*/                                                                                         \
105     macro (ompt_callback_thread_begin,      ompt_callback_thread_begin_t,       1) /* thread begin                    */ \
106     macro (ompt_callback_thread_end,        ompt_callback_thread_end_t,         2) /* thread end                      */ \
107                                                                                                                          \
108     macro (ompt_callback_parallel_begin,    ompt_callback_parallel_begin_t,     3) /* parallel begin                  */ \
109     macro (ompt_callback_parallel_end,      ompt_callback_parallel_end_t,       4) /* parallel end                    */ \
110                                                                                                                          \
111     macro (ompt_callback_task_create,       ompt_callback_task_create_t,        5) /* task begin                      */ \
112     macro (ompt_callback_task_schedule,     ompt_callback_task_schedule_t,      6) /* task schedule                   */ \
113     macro (ompt_callback_implicit_task,     ompt_callback_implicit_task_t,      7) /* implicit task                   */ \
114                                                                                                                          \
115     macro (ompt_callback_target,            ompt_callback_target_t,             8) /* target                          */ \
116     macro (ompt_callback_target_data_op,    ompt_callback_target_data_op_t,     9) /* target data op                  */ \
117     macro (ompt_callback_target_submit,     ompt_callback_target_submit_t,     10) /* target  submit                  */ \
118                                                                                                                          \
119     macro (ompt_callback_control_tool,      ompt_callback_control_tool_t,      11) /* control tool                    */ \
120                                                                                                                          \
121     macro (ompt_callback_device_initialize, ompt_callback_device_initialize_t, 12) /* device initialize               */ \
122     macro (ompt_callback_device_finalize,   ompt_callback_device_finalize_t,   13) /* device finalize                 */ \
123                                                                                                                          \
124     macro (ompt_callback_device_load,       ompt_callback_device_load_t,       14) /* device load                     */ \
125     macro (ompt_callback_device_unload,     ompt_callback_device_unload_t,     15) /* device unload                   */ \
126                                                                                                                          \
127     /* Optional Events */                                                                                                \
128     macro (ompt_callback_sync_region_wait,  ompt_callback_sync_region_t,       16) /* sync region wait begin or end   */ \
129                                                                                                                          \
130     macro (ompt_callback_mutex_released,    ompt_callback_mutex_t,             17) /* mutex released                  */ \
131                                                                                                                          \
132     macro (ompt_callback_dependences,       ompt_callback_dependences_t,       18) /* report task dependences         */ \
133     macro (ompt_callback_task_dependence,   ompt_callback_task_dependence_t,   19) /* report task dependence          */ \
134                                                                                                                          \
135     macro (ompt_callback_work,              ompt_callback_work_t,              20) /* task at work begin or end       */ \
136                                                                                                                          \
137     macro (ompt_callback_master,            ompt_callback_master_t,            21) /* task at master begin or end     */ \
138                                                                                                                          \
139     macro (ompt_callback_target_map,        ompt_callback_target_map_t,        22) /* target map                      */ \
140                                                                                                                          \
141     macro (ompt_callback_sync_region,       ompt_callback_sync_region_t,       23) /* sync region begin or end        */ \
142                                                                                                                          \
143     macro (ompt_callback_lock_init,         ompt_callback_mutex_acquire_t,     24) /* lock init                       */ \
144     macro (ompt_callback_lock_destroy,      ompt_callback_mutex_t,             25) /* lock destroy                    */ \
145                                                                                                                          \
146     macro (ompt_callback_mutex_acquire,     ompt_callback_mutex_acquire_t,     26) /* mutex acquire                   */ \
147     macro (ompt_callback_mutex_acquired,    ompt_callback_mutex_t,             27) /* mutex acquired                  */ \
148                                                                                                                          \
149     macro (ompt_callback_nest_lock,         ompt_callback_nest_lock_t,         28) /* nest lock                       */ \
150                                                                                                                          \
151     macro (ompt_callback_flush,             ompt_callback_flush_t,             29) /* after executing flush           */ \
152                                                                                                                          \
153     macro (ompt_callback_cancel,            ompt_callback_cancel_t,            30) /* cancel innermost binding region */ \
154                                                                                                                          \
155     macro (ompt_callback_reduction,         ompt_callback_sync_region_t,       31) /* reduction                       */ \
156                                                                                                                          \
157     macro (ompt_callback_dispatch,          ompt_callback_dispatch_t,          32) /* dispatch of work                */
158 
159 /*****************************************************************************
160  * implementation specific types
161  *****************************************************************************/
162 
163 typedef enum kmp_mutex_impl_t {
164 #define kmp_mutex_impl_macro(impl, code) impl = code,
165     FOREACH_KMP_MUTEX_IMPL(kmp_mutex_impl_macro)
166 #undef kmp_mutex_impl_macro
167 } kmp_mutex_impl_t;
168 
169 /*****************************************************************************
170  * definitions generated from spec
171  *****************************************************************************/
172 
173 typedef enum ompt_callbacks_t {
174   ompt_callback_thread_begin             = 1,
175   ompt_callback_thread_end               = 2,
176   ompt_callback_parallel_begin           = 3,
177   ompt_callback_parallel_end             = 4,
178   ompt_callback_task_create              = 5,
179   ompt_callback_task_schedule            = 6,
180   ompt_callback_implicit_task            = 7,
181   ompt_callback_target                   = 8,
182   ompt_callback_target_data_op           = 9,
183   ompt_callback_target_submit            = 10,
184   ompt_callback_control_tool             = 11,
185   ompt_callback_device_initialize        = 12,
186   ompt_callback_device_finalize          = 13,
187   ompt_callback_device_load              = 14,
188   ompt_callback_device_unload            = 15,
189   ompt_callback_sync_region_wait         = 16,
190   ompt_callback_mutex_released           = 17,
191   ompt_callback_dependences              = 18,
192   ompt_callback_task_dependence          = 19,
193   ompt_callback_work                     = 20,
194   ompt_callback_master                   = 21,
195   ompt_callback_target_map               = 22,
196   ompt_callback_sync_region              = 23,
197   ompt_callback_lock_init                = 24,
198   ompt_callback_lock_destroy             = 25,
199   ompt_callback_mutex_acquire            = 26,
200   ompt_callback_mutex_acquired           = 27,
201   ompt_callback_nest_lock                = 28,
202   ompt_callback_flush                    = 29,
203   ompt_callback_cancel                   = 30,
204   ompt_callback_reduction                = 31,
205   ompt_callback_dispatch                 = 32
206 } ompt_callbacks_t;
207 
208 typedef enum ompt_record_t {
209   ompt_record_ompt               = 1,
210   ompt_record_native             = 2,
211   ompt_record_invalid            = 3
212 } ompt_record_t;
213 
214 typedef enum ompt_record_native_t {
215   ompt_record_native_info  = 1,
216   ompt_record_native_event = 2
217 } ompt_record_native_t;
218 
219 typedef enum ompt_set_result_t {
220   ompt_set_error            = 0,
221   ompt_set_never            = 1,
222   ompt_set_impossible       = 2,
223   ompt_set_sometimes        = 3,
224   ompt_set_sometimes_paired = 4,
225   ompt_set_always           = 5
226 } ompt_set_result_t;
227 
228 typedef uint64_t ompt_id_t;
229 
230 typedef uint64_t ompt_device_time_t;
231 
232 typedef uint64_t ompt_buffer_cursor_t;
233 
234 typedef enum ompt_thread_t {
235   ompt_thread_initial                 = 1,
236   ompt_thread_worker                  = 2,
237   ompt_thread_other                   = 3,
238   ompt_thread_unknown                 = 4
239 } ompt_thread_t;
240 
241 typedef enum ompt_scope_endpoint_t {
242   ompt_scope_begin                    = 1,
243   ompt_scope_end                      = 2
244 } ompt_scope_endpoint_t;
245 
246 typedef enum ompt_dispatch_t {
247   ompt_dispatch_iteration             = 1,
248   ompt_dispatch_section               = 2
249 } ompt_dispatch_t;
250 
251 typedef enum ompt_sync_region_t {
252   ompt_sync_region_barrier                = 1,
253   ompt_sync_region_barrier_implicit       = 2,
254   ompt_sync_region_barrier_explicit       = 3,
255   ompt_sync_region_barrier_implementation = 4,
256   ompt_sync_region_taskwait               = 5,
257   ompt_sync_region_taskgroup              = 6,
258   ompt_sync_region_reduction              = 7
259 } ompt_sync_region_t;
260 
261 typedef enum ompt_target_data_op_t {
262   ompt_target_data_alloc                = 1,
263   ompt_target_data_transfer_to_device   = 2,
264   ompt_target_data_transfer_from_device = 3,
265   ompt_target_data_delete               = 4,
266   ompt_target_data_associate            = 5,
267   ompt_target_data_disassociate         = 6
268 } ompt_target_data_op_t;
269 
270 typedef enum ompt_work_t {
271   ompt_work_loop               = 1,
272   ompt_work_sections           = 2,
273   ompt_work_single_executor    = 3,
274   ompt_work_single_other       = 4,
275   ompt_work_workshare          = 5,
276   ompt_work_distribute         = 6,
277   ompt_work_taskloop           = 7
278 } ompt_work_t;
279 
280 typedef enum ompt_mutex_t {
281   ompt_mutex_lock                     = 1,
282   ompt_mutex_test_lock                = 2,
283   ompt_mutex_nest_lock                = 3,
284   ompt_mutex_test_nest_lock           = 4,
285   ompt_mutex_critical                 = 5,
286   ompt_mutex_atomic                   = 6,
287   ompt_mutex_ordered                  = 7
288 } ompt_mutex_t;
289 
290 typedef enum ompt_native_mon_flag_t {
291   ompt_native_data_motion_explicit    = 0x01,
292   ompt_native_data_motion_implicit    = 0x02,
293   ompt_native_kernel_invocation       = 0x04,
294   ompt_native_kernel_execution        = 0x08,
295   ompt_native_driver                  = 0x10,
296   ompt_native_runtime                 = 0x20,
297   ompt_native_overhead                = 0x40,
298   ompt_native_idleness                = 0x80
299 } ompt_native_mon_flag_t;
300 
301 typedef enum ompt_task_flag_t {
302   ompt_task_initial                   = 0x00000001,
303   ompt_task_implicit                  = 0x00000002,
304   ompt_task_explicit                  = 0x00000004,
305   ompt_task_target                    = 0x00000008,
306   ompt_task_undeferred                = 0x08000000,
307   ompt_task_untied                    = 0x10000000,
308   ompt_task_final                     = 0x20000000,
309   ompt_task_mergeable                 = 0x40000000,
310   ompt_task_merged                    = 0x80000000
311 } ompt_task_flag_t;
312 
313 typedef enum ompt_task_status_t {
314   ompt_task_complete      = 1,
315   ompt_task_yield         = 2,
316   ompt_task_cancel        = 3,
317   ompt_task_detach        = 4,
318   ompt_task_early_fulfill = 5,
319   ompt_task_late_fulfill  = 6,
320   ompt_task_switch        = 7
321 } ompt_task_status_t;
322 
323 typedef enum ompt_target_t {
324   ompt_target                         = 1,
325   ompt_target_enter_data              = 2,
326   ompt_target_exit_data               = 3,
327   ompt_target_update                  = 4
328 } ompt_target_t;
329 
330 typedef enum ompt_parallel_flag_t {
331   ompt_parallel_invoker_program = 0x00000001,
332   ompt_parallel_invoker_runtime = 0x00000002,
333   ompt_parallel_league          = 0x40000000,
334   ompt_parallel_team            = 0x80000000
335 } ompt_parallel_flag_t;
336 
337 typedef enum ompt_target_map_flag_t {
338   ompt_target_map_flag_to             = 0x01,
339   ompt_target_map_flag_from           = 0x02,
340   ompt_target_map_flag_alloc          = 0x04,
341   ompt_target_map_flag_release        = 0x08,
342   ompt_target_map_flag_delete         = 0x10,
343   ompt_target_map_flag_implicit       = 0x20
344 } ompt_target_map_flag_t;
345 
346 typedef enum ompt_dependence_type_t {
347   ompt_dependence_type_in              = 1,
348   ompt_dependence_type_out             = 2,
349   ompt_dependence_type_inout           = 3,
350   ompt_dependence_type_mutexinoutset   = 4,
351   ompt_dependence_type_source          = 5,
352   ompt_dependence_type_sink            = 6
353 } ompt_dependence_type_t;
354 
355 typedef enum ompt_cancel_flag_t {
356   ompt_cancel_parallel       = 0x01,
357   ompt_cancel_sections       = 0x02,
358   ompt_cancel_loop           = 0x04,
359   ompt_cancel_taskgroup      = 0x08,
360   ompt_cancel_activated      = 0x10,
361   ompt_cancel_detected       = 0x20,
362   ompt_cancel_discarded_task = 0x40
363 } ompt_cancel_flag_t;
364 
365 typedef uint64_t ompt_hwid_t;
366 
367 typedef uint64_t ompt_wait_id_t;
368 
369 typedef enum ompt_frame_flag_t {
370   ompt_frame_runtime        = 0x00,
371   ompt_frame_application    = 0x01,
372   ompt_frame_cfa            = 0x10,
373   ompt_frame_framepointer   = 0x20,
374   ompt_frame_stackaddress   = 0x30
375 } ompt_frame_flag_t;
376 
377 typedef enum ompt_state_t {
378   ompt_state_work_serial                      = 0x000,
379   ompt_state_work_parallel                    = 0x001,
380   ompt_state_work_reduction                   = 0x002,
381 
382   ompt_state_wait_barrier                     = 0x010,
383   ompt_state_wait_barrier_implicit_parallel   = 0x011,
384   ompt_state_wait_barrier_implicit_workshare  = 0x012,
385   ompt_state_wait_barrier_implicit            = 0x013,
386   ompt_state_wait_barrier_explicit            = 0x014,
387 
388   ompt_state_wait_taskwait                    = 0x020,
389   ompt_state_wait_taskgroup                   = 0x021,
390 
391   ompt_state_wait_mutex                       = 0x040,
392   ompt_state_wait_lock                        = 0x041,
393   ompt_state_wait_critical                    = 0x042,
394   ompt_state_wait_atomic                      = 0x043,
395   ompt_state_wait_ordered                     = 0x044,
396 
397   ompt_state_wait_target                      = 0x080,
398   ompt_state_wait_target_map                  = 0x081,
399   ompt_state_wait_target_update               = 0x082,
400 
401   ompt_state_idle                             = 0x100,
402   ompt_state_overhead                         = 0x101,
403   ompt_state_undefined                        = 0x102
404 } ompt_state_t;
405 
406 typedef uint64_t (*ompt_get_unique_id_t) (void);
407 
408 typedef uint64_t ompd_size_t;
409 
410 typedef uint64_t ompd_wait_id_t;
411 
412 typedef uint64_t ompd_addr_t;
413 typedef int64_t  ompd_word_t;
414 typedef uint64_t ompd_seg_t;
415 
416 typedef uint64_t ompd_device_t;
417 
418 typedef uint64_t ompd_thread_id_t;
419 
420 typedef enum ompd_scope_t {
421   ompd_scope_global = 1,
422   ompd_scope_address_space = 2,
423   ompd_scope_thread = 3,
424   ompd_scope_parallel = 4,
425   ompd_scope_implicit_task = 5,
426   ompd_scope_task = 6
427 } ompd_scope_t;
428 
429 typedef uint64_t ompd_icv_id_t;
430 
431 typedef enum ompd_rc_t {
432   ompd_rc_ok = 0,
433   ompd_rc_unavailable = 1,
434   ompd_rc_stale_handle = 2,
435   ompd_rc_bad_input = 3,
436   ompd_rc_error = 4,
437   ompd_rc_unsupported = 5,
438   ompd_rc_needs_state_tracking = 6,
439   ompd_rc_incompatible = 7,
440   ompd_rc_device_read_error = 8,
441   ompd_rc_device_write_error = 9,
442   ompd_rc_nomem = 10,
443 } ompd_rc_t;
444 
445 typedef void (*ompt_interface_fn_t) (void);
446 
447 typedef ompt_interface_fn_t (*ompt_function_lookup_t) (
448   const char *interface_function_name
449 );
450 
451 typedef union ompt_data_t {
452   uint64_t value;
453   void *ptr;
454 } ompt_data_t;
455 
456 typedef struct ompt_frame_t {
457   ompt_data_t exit_frame;
458   ompt_data_t enter_frame;
459   int exit_frame_flags;
460   int enter_frame_flags;
461 } ompt_frame_t;
462 
463 typedef void (*ompt_callback_t) (void);
464 
465 typedef void ompt_device_t;
466 
467 typedef void ompt_buffer_t;
468 
469 typedef void (*ompt_callback_buffer_request_t) (
470   int device_num,
471   ompt_buffer_t **buffer,
472   size_t *bytes
473 );
474 
475 typedef void (*ompt_callback_buffer_complete_t) (
476   int device_num,
477   ompt_buffer_t *buffer,
478   size_t bytes,
479   ompt_buffer_cursor_t begin,
480   int buffer_owned
481 );
482 
483 typedef void (*ompt_finalize_t) (
484   ompt_data_t *tool_data
485 );
486 
487 typedef int (*ompt_initialize_t) (
488   ompt_function_lookup_t lookup,
489   int initial_device_num,
490   ompt_data_t *tool_data
491 );
492 
493 typedef struct ompt_start_tool_result_t {
494   ompt_initialize_t initialize;
495   ompt_finalize_t finalize;
496   ompt_data_t tool_data;
497 } ompt_start_tool_result_t;
498 
499 typedef struct ompt_record_abstract_t {
500   ompt_record_native_t rclass;
501   const char *type;
502   ompt_device_time_t start_time;
503   ompt_device_time_t end_time;
504   ompt_hwid_t hwid;
505 } ompt_record_abstract_t;
506 
507 typedef struct ompt_dependence_t {
508   ompt_data_t variable;
509   ompt_dependence_type_t dependence_type;
510 } ompt_dependence_t;
511 
512 typedef int (*ompt_enumerate_states_t) (
513   int current_state,
514   int *next_state,
515   const char **next_state_name
516 );
517 
518 typedef int (*ompt_enumerate_mutex_impls_t) (
519   int current_impl,
520   int *next_impl,
521   const char **next_impl_name
522 );
523 
524 typedef ompt_set_result_t (*ompt_set_callback_t) (
525   ompt_callbacks_t event,
526   ompt_callback_t callback
527 );
528 
529 typedef int (*ompt_get_callback_t) (
530   ompt_callbacks_t event,
531   ompt_callback_t *callback
532 );
533 
534 typedef ompt_data_t *(*ompt_get_thread_data_t) (void);
535 
536 typedef int (*ompt_get_num_procs_t) (void);
537 
538 typedef int (*ompt_get_num_places_t) (void);
539 
540 typedef int (*ompt_get_place_proc_ids_t) (
541   int place_num,
542   int ids_size,
543   int *ids
544 );
545 
546 typedef int (*ompt_get_place_num_t) (void);
547 
548 typedef int (*ompt_get_partition_place_nums_t) (
549   int place_nums_size,
550   int *place_nums
551 );
552 
553 typedef int (*ompt_get_proc_id_t) (void);
554 
555 typedef int (*ompt_get_state_t) (
556   ompt_wait_id_t *wait_id
557 );
558 
559 typedef int (*ompt_get_parallel_info_t) (
560   int ancestor_level,
561   ompt_data_t **parallel_data,
562   int *team_size
563 );
564 
565 typedef int (*ompt_get_task_info_t) (
566   int ancestor_level,
567   int *flags,
568   ompt_data_t **task_data,
569   ompt_frame_t **task_frame,
570   ompt_data_t **parallel_data,
571   int *thread_num
572 );
573 
574 typedef int (*ompt_get_task_memory_t)(
575   void **addr,
576   size_t *size,
577   int block
578 );
579 
580 typedef int (*ompt_get_target_info_t) (
581   uint64_t *device_num,
582   ompt_id_t *target_id,
583   ompt_id_t *host_op_id
584 );
585 
586 typedef int (*ompt_get_num_devices_t) (void);
587 
588 typedef void (*ompt_finalize_tool_t) (void);
589 
590 typedef int (*ompt_get_device_num_procs_t) (
591   ompt_device_t *device
592 );
593 
594 typedef ompt_device_time_t (*ompt_get_device_time_t) (
595   ompt_device_t *device
596 );
597 
598 typedef double (*ompt_translate_time_t) (
599   ompt_device_t *device,
600   ompt_device_time_t time
601 );
602 
603 typedef ompt_set_result_t (*ompt_set_trace_ompt_t) (
604   ompt_device_t *device,
605   unsigned int enable,
606   unsigned int etype
607 );
608 
609 typedef ompt_set_result_t (*ompt_set_trace_native_t) (
610   ompt_device_t *device,
611   int enable,
612   int flags
613 );
614 
615 typedef int (*ompt_start_trace_t) (
616   ompt_device_t *device,
617   ompt_callback_buffer_request_t request,
618   ompt_callback_buffer_complete_t complete
619 );
620 
621 typedef int (*ompt_pause_trace_t) (
622   ompt_device_t *device,
623   int begin_pause
624 );
625 
626 typedef int (*ompt_flush_trace_t) (
627   ompt_device_t *device
628 );
629 
630 typedef int (*ompt_stop_trace_t) (
631   ompt_device_t *device
632 );
633 
634 typedef int (*ompt_advance_buffer_cursor_t) (
635   ompt_device_t *device,
636   ompt_buffer_t *buffer,
637   size_t size,
638   ompt_buffer_cursor_t current,
639   ompt_buffer_cursor_t *next
640 );
641 
642 typedef ompt_record_t (*ompt_get_record_type_t) (
643   ompt_buffer_t *buffer,
644   ompt_buffer_cursor_t current
645 );
646 
647 typedef void *(*ompt_get_record_native_t) (
648   ompt_buffer_t *buffer,
649   ompt_buffer_cursor_t current,
650   ompt_id_t *host_op_id
651 );
652 
653 typedef ompt_record_abstract_t *
654 (*ompt_get_record_abstract_t) (
655   void *native_record
656 );
657 
658 typedef void (*ompt_callback_thread_begin_t) (
659   ompt_thread_t thread_type,
660   ompt_data_t *thread_data
661 );
662 
663 typedef struct ompt_record_thread_begin_t {
664   ompt_thread_t thread_type;
665 } ompt_record_thread_begin_t;
666 
667 typedef void (*ompt_callback_thread_end_t) (
668   ompt_data_t *thread_data
669 );
670 
671 typedef void (*ompt_callback_parallel_begin_t) (
672   ompt_data_t *encountering_task_data,
673   const ompt_frame_t *encountering_task_frame,
674   ompt_data_t *parallel_data,
675   unsigned int requested_parallelism,
676   int flags,
677   const void *codeptr_ra
678 );
679 
680 typedef struct ompt_record_parallel_begin_t {
681   ompt_id_t encountering_task_id;
682   ompt_id_t parallel_id;
683   unsigned int requested_parallelism;
684   int flags;
685   const void *codeptr_ra;
686 } ompt_record_parallel_begin_t;
687 
688 typedef void (*ompt_callback_parallel_end_t) (
689   ompt_data_t *parallel_data,
690   ompt_data_t *encountering_task_data,
691   int flags,
692   const void *codeptr_ra
693 );
694 
695 typedef struct ompt_record_parallel_end_t {
696   ompt_id_t parallel_id;
697   ompt_id_t encountering_task_id;
698   int flags;
699   const void *codeptr_ra;
700 } ompt_record_parallel_end_t;
701 
702 typedef void (*ompt_callback_work_t) (
703   ompt_work_t wstype,
704   ompt_scope_endpoint_t endpoint,
705   ompt_data_t *parallel_data,
706   ompt_data_t *task_data,
707   uint64_t count,
708   const void *codeptr_ra
709 );
710 
711 typedef struct ompt_record_work_t {
712   ompt_work_t wstype;
713   ompt_scope_endpoint_t endpoint;
714   ompt_id_t parallel_id;
715   ompt_id_t task_id;
716   uint64_t count;
717   const void *codeptr_ra;
718 } ompt_record_work_t;
719 
720 typedef void (*ompt_callback_dispatch_t) (
721   ompt_data_t *parallel_data,
722   ompt_data_t *task_data,
723   ompt_dispatch_t kind,
724   ompt_data_t instance
725 );
726 
727 typedef struct ompt_record_dispatch_t {
728   ompt_id_t parallel_id;
729   ompt_id_t task_id;
730   ompt_dispatch_t kind;
731   ompt_data_t instance;
732 } ompt_record_dispatch_t;
733 
734 typedef void (*ompt_callback_task_create_t) (
735   ompt_data_t *encountering_task_data,
736   const ompt_frame_t *encountering_task_frame,
737   ompt_data_t *new_task_data,
738   int flags,
739   int has_dependences,
740   const void *codeptr_ra
741 );
742 
743 typedef struct ompt_record_task_create_t {
744   ompt_id_t encountering_task_id;
745   ompt_id_t new_task_id;
746   int flags;
747   int has_dependences;
748   const void *codeptr_ra;
749 } ompt_record_task_create_t;
750 
751 typedef void (*ompt_callback_dependences_t) (
752   ompt_data_t *task_data,
753   const ompt_dependence_t *deps,
754   int ndeps
755 );
756 
757 typedef struct ompt_record_dependences_t {
758   ompt_id_t task_id;
759   ompt_dependence_t dep;
760   int ndeps;
761 } ompt_record_dependences_t;
762 
763 typedef void (*ompt_callback_task_dependence_t) (
764   ompt_data_t *src_task_data,
765   ompt_data_t *sink_task_data
766 );
767 
768 typedef struct ompt_record_task_dependence_t {
769   ompt_id_t src_task_id;
770   ompt_id_t sink_task_id;
771 } ompt_record_task_dependence_t;
772 
773 typedef void (*ompt_callback_task_schedule_t) (
774   ompt_data_t *prior_task_data,
775   ompt_task_status_t prior_task_status,
776   ompt_data_t *next_task_data
777 );
778 
779 typedef struct ompt_record_task_schedule_t {
780   ompt_id_t prior_task_id;
781   ompt_task_status_t prior_task_status;
782   ompt_id_t next_task_id;
783 } ompt_record_task_schedule_t;
784 
785 typedef void (*ompt_callback_implicit_task_t) (
786   ompt_scope_endpoint_t endpoint,
787   ompt_data_t *parallel_data,
788   ompt_data_t *task_data,
789   unsigned int actual_parallelism,
790   unsigned int index,
791   int flags
792 );
793 
794 typedef struct ompt_record_implicit_task_t {
795   ompt_scope_endpoint_t endpoint;
796   ompt_id_t parallel_id;
797   ompt_id_t task_id;
798   unsigned int actual_parallelism;
799   unsigned int index;
800   int flags;
801 } ompt_record_implicit_task_t;
802 
803 typedef void (*ompt_callback_master_t) (
804   ompt_scope_endpoint_t endpoint,
805   ompt_data_t *parallel_data,
806   ompt_data_t *task_data,
807   const void *codeptr_ra
808 );
809 
810 typedef struct ompt_record_master_t {
811   ompt_scope_endpoint_t endpoint;
812   ompt_id_t parallel_id;
813   ompt_id_t task_id;
814   const void *codeptr_ra;
815 } ompt_record_master_t;
816 
817 typedef void (*ompt_callback_sync_region_t) (
818   ompt_sync_region_t kind,
819   ompt_scope_endpoint_t endpoint,
820   ompt_data_t *parallel_data,
821   ompt_data_t *task_data,
822   const void *codeptr_ra
823 );
824 
825 typedef struct ompt_record_sync_region_t {
826   ompt_sync_region_t kind;
827   ompt_scope_endpoint_t endpoint;
828   ompt_id_t parallel_id;
829   ompt_id_t task_id;
830   const void *codeptr_ra;
831 } ompt_record_sync_region_t;
832 
833 typedef void (*ompt_callback_mutex_acquire_t) (
834   ompt_mutex_t kind,
835   unsigned int hint,
836   unsigned int impl,
837   ompt_wait_id_t wait_id,
838   const void *codeptr_ra
839 );
840 
841 typedef struct ompt_record_mutex_acquire_t {
842   ompt_mutex_t kind;
843   unsigned int hint;
844   unsigned int impl;
845   ompt_wait_id_t wait_id;
846   const void *codeptr_ra;
847 } ompt_record_mutex_acquire_t;
848 
849 typedef void (*ompt_callback_mutex_t) (
850   ompt_mutex_t kind,
851   ompt_wait_id_t wait_id,
852   const void *codeptr_ra
853 );
854 
855 typedef struct ompt_record_mutex_t {
856   ompt_mutex_t kind;
857   ompt_wait_id_t wait_id;
858   const void *codeptr_ra;
859 } ompt_record_mutex_t;
860 
861 typedef void (*ompt_callback_nest_lock_t) (
862   ompt_scope_endpoint_t endpoint,
863   ompt_wait_id_t wait_id,
864   const void *codeptr_ra
865 );
866 
867 typedef struct ompt_record_nest_lock_t {
868   ompt_scope_endpoint_t endpoint;
869   ompt_wait_id_t wait_id;
870   const void *codeptr_ra;
871 } ompt_record_nest_lock_t;
872 
873 typedef void (*ompt_callback_flush_t) (
874   ompt_data_t *thread_data,
875   const void *codeptr_ra
876 );
877 
878 typedef struct ompt_record_flush_t {
879   const void *codeptr_ra;
880 } ompt_record_flush_t;
881 
882 typedef void (*ompt_callback_cancel_t) (
883   ompt_data_t *task_data,
884   int flags,
885   const void *codeptr_ra
886 );
887 
888 typedef struct ompt_record_cancel_t {
889   ompt_id_t task_id;
890   int flags;
891   const void *codeptr_ra;
892 } ompt_record_cancel_t;
893 
894 typedef void (*ompt_callback_device_initialize_t) (
895   int device_num,
896   const char *type,
897   ompt_device_t *device,
898   ompt_function_lookup_t lookup,
899   const char *documentation
900 );
901 
902 typedef void (*ompt_callback_device_finalize_t) (
903   int device_num
904 );
905 
906 typedef void (*ompt_callback_device_load_t) (
907   int device_num,
908   const char *filename,
909   int64_t offset_in_file,
910   void *vma_in_file,
911   size_t bytes,
912   void *host_addr,
913   void *device_addr,
914   uint64_t module_id
915 );
916 
917 typedef void (*ompt_callback_device_unload_t) (
918   int device_num,
919   uint64_t module_id
920 );
921 
922 typedef void (*ompt_callback_target_data_op_t) (
923   ompt_id_t target_id,
924   ompt_id_t host_op_id,
925   ompt_target_data_op_t optype,
926   void *src_addr,
927   int src_device_num,
928   void *dest_addr,
929   int dest_device_num,
930   size_t bytes,
931   const void *codeptr_ra
932 );
933 
934 typedef struct ompt_record_target_data_op_t {
935   ompt_id_t host_op_id;
936   ompt_target_data_op_t optype;
937   void *src_addr;
938   int src_device_num;
939   void *dest_addr;
940   int dest_device_num;
941   size_t bytes;
942   ompt_device_time_t end_time;
943   const void *codeptr_ra;
944 } ompt_record_target_data_op_t;
945 
946 typedef void (*ompt_callback_target_t) (
947   ompt_target_t kind,
948   ompt_scope_endpoint_t endpoint,
949   int device_num,
950   ompt_data_t *task_data,
951   ompt_id_t target_id,
952   const void *codeptr_ra
953 );
954 
955 typedef struct ompt_record_target_t {
956   ompt_target_t kind;
957   ompt_scope_endpoint_t endpoint;
958   int device_num;
959   ompt_id_t task_id;
960   ompt_id_t target_id;
961   const void *codeptr_ra;
962 } ompt_record_target_t;
963 
964 typedef void (*ompt_callback_target_map_t) (
965   ompt_id_t target_id,
966   unsigned int nitems,
967   void **host_addr,
968   void **device_addr,
969   size_t *bytes,
970   unsigned int *mapping_flags,
971   const void *codeptr_ra
972 );
973 
974 typedef struct ompt_record_target_map_t {
975   ompt_id_t target_id;
976   unsigned int nitems;
977   void **host_addr;
978   void **device_addr;
979   size_t *bytes;
980   unsigned int *mapping_flags;
981   const void *codeptr_ra;
982 } ompt_record_target_map_t;
983 
984 typedef void (*ompt_callback_target_submit_t) (
985   ompt_id_t target_id,
986   ompt_id_t host_op_id,
987   unsigned int requested_num_teams
988 );
989 
990 typedef struct ompt_record_target_kernel_t {
991   ompt_id_t host_op_id;
992   unsigned int requested_num_teams;
993   unsigned int granted_num_teams;
994   ompt_device_time_t end_time;
995 } ompt_record_target_kernel_t;
996 
997 typedef int (*ompt_callback_control_tool_t) (
998   uint64_t command,
999   uint64_t modifier,
1000   void *arg,
1001   const void *codeptr_ra
1002 );
1003 
1004 typedef struct ompt_record_control_tool_t {
1005   uint64_t command;
1006   uint64_t modifier;
1007   const void *codeptr_ra;
1008 } ompt_record_control_tool_t;
1009 
1010 typedef struct ompd_address_t {
1011   ompd_seg_t segment;
1012   ompd_addr_t address;
1013 } ompd_address_t;
1014 
1015 typedef struct ompd_frame_info_t {
1016   ompd_address_t frame_address;
1017   ompd_word_t frame_flag;
1018 } ompd_frame_info_t;
1019 
1020 typedef struct _ompd_aspace_handle ompd_address_space_handle_t;
1021 typedef struct _ompd_thread_handle ompd_thread_handle_t;
1022 typedef struct _ompd_parallel_handle ompd_parallel_handle_t;
1023 typedef struct _ompd_task_handle ompd_task_handle_t;
1024 
1025 typedef struct _ompd_aspace_cont ompd_address_space_context_t;
1026 typedef struct _ompd_thread_cont ompd_thread_context_t;
1027 
1028 typedef struct ompd_device_type_sizes_t {
1029   uint8_t sizeof_char;
1030   uint8_t sizeof_short;
1031   uint8_t sizeof_int;
1032   uint8_t sizeof_long;
1033   uint8_t sizeof_long_long;
1034   uint8_t sizeof_pointer;
1035 } ompd_device_type_sizes_t;
1036 
1037 typedef struct ompt_record_ompt_t {
1038   ompt_callbacks_t type;
1039   ompt_device_time_t time;
1040   ompt_id_t thread_id;
1041   ompt_id_t target_id;
1042   union {
1043     ompt_record_thread_begin_t thread_begin;
1044     ompt_record_parallel_begin_t parallel_begin;
1045     ompt_record_parallel_end_t parallel_end;
1046     ompt_record_work_t work;
1047     ompt_record_dispatch_t dispatch;
1048     ompt_record_task_create_t task_create;
1049     ompt_record_dependences_t dependences;
1050     ompt_record_task_dependence_t task_dependence;
1051     ompt_record_task_schedule_t task_schedule;
1052     ompt_record_implicit_task_t implicit_task;
1053     ompt_record_master_t master;
1054     ompt_record_sync_region_t sync_region;
1055     ompt_record_mutex_acquire_t mutex_acquire;
1056     ompt_record_mutex_t mutex;
1057     ompt_record_nest_lock_t nest_lock;
1058     ompt_record_flush_t flush;
1059     ompt_record_cancel_t cancel;
1060     ompt_record_target_t target;
1061     ompt_record_target_data_op_t target_data_op;
1062     ompt_record_target_map_t target_map;
1063     ompt_record_target_kernel_t target_kernel;
1064     ompt_record_control_tool_t control_tool;
1065   } record;
1066 } ompt_record_ompt_t;
1067 
1068 typedef ompt_record_ompt_t *(*ompt_get_record_ompt_t) (
1069   ompt_buffer_t *buffer,
1070   ompt_buffer_cursor_t current
1071 );
1072 
1073 #define ompt_id_none 0
1074 #define ompt_data_none {0}
1075 #define ompt_time_none 0
1076 #define ompt_hwid_none 0
1077 #define ompt_addr_none ~0
1078 #define ompt_mutex_impl_none 0
1079 #define ompt_wait_id_none 0
1080 
1081 #define ompd_segment_none 0
1082 
1083 #endif /* __OMPT__ */
1084