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