xref: /freebsd/lib/libomp/omp-tools.h (revision 535af610)
1 /*
2  * include/omp-tools.h.var
3  */
4 
5 //===----------------------------------------------------------------------===//
6 //
7 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
8 // See https://llvm.org/LICENSE.txt for license information.
9 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef __OMPT__
14 #define __OMPT__
15 
16 /*****************************************************************************
17  * system include files
18  *****************************************************************************/
19 
20 #include <stdint.h>
21 #include <stddef.h>
22 
23 #ifdef DEPRECATION_WARNINGS
24 # ifdef __cplusplus
25 # define DEPRECATED_51 [[deprecated("as of 5.1")]]
26 # else
27 # define DEPRECATED_51 __attribute__((deprecated("as of 5.1")))
28 #endif
29 #else
30 #define DEPRECATED_51
31 #endif
32 
33 /*****************************************************************************
34  * iteration macros
35  *****************************************************************************/
36 
37 #define FOREACH_OMPT_INQUIRY_FN(macro)      \
38     macro (ompt_enumerate_states)           \
39     macro (ompt_enumerate_mutex_impls)      \
40                                             \
41     macro (ompt_set_callback)               \
42     macro (ompt_get_callback)               \
43                                             \
44     macro (ompt_get_state)                  \
45                                             \
46     macro (ompt_get_parallel_info)          \
47     macro (ompt_get_task_info)              \
48     macro (ompt_get_task_memory)            \
49     macro (ompt_get_thread_data)            \
50     macro (ompt_get_unique_id)              \
51     macro (ompt_finalize_tool)              \
52                                             \
53     macro(ompt_get_num_procs)               \
54     macro(ompt_get_num_places)              \
55     macro(ompt_get_place_proc_ids)          \
56     macro(ompt_get_place_num)               \
57     macro(ompt_get_partition_place_nums)    \
58     macro(ompt_get_proc_id)                 \
59                                             \
60     macro(ompt_get_target_info)             \
61     macro(ompt_get_num_devices)
62 
63 #define FOREACH_OMPT_STATE(macro)                                                                \
64                                                                                                 \
65     /* first available state */                                                                 \
66     macro (ompt_state_undefined, 0x102)      /* undefined thread state */                        \
67                                                                                                 \
68     /* work states (0..15) */                                                                   \
69     macro (ompt_state_work_serial, 0x000)    /* working outside parallel */                      \
70     macro (ompt_state_work_parallel, 0x001)  /* working within parallel */                       \
71     macro (ompt_state_work_reduction, 0x002) /* performing a reduction */                        \
72                                                                                                 \
73     /* barrier wait states (16..31) */                                                          \
74     macro (ompt_state_wait_barrier, 0x010)   /* waiting at a barrier */                          \
75     macro (ompt_state_wait_barrier_implicit_parallel, 0x011)                                     \
76                                             /* implicit barrier at the end of parallel region */\
77     macro (ompt_state_wait_barrier_implicit_workshare, 0x012)                                    \
78                                             /* implicit barrier at the end of worksharing */    \
79     macro (ompt_state_wait_barrier_implicit, 0x013)  /* implicit barrier */                      \
80     macro (ompt_state_wait_barrier_explicit, 0x014)  /* explicit barrier */                      \
81                                                                                                 \
82     /* task wait states (32..63) */                                                             \
83     macro (ompt_state_wait_taskwait, 0x020)  /* waiting at a taskwait */                         \
84     macro (ompt_state_wait_taskgroup, 0x021) /* waiting at a taskgroup */                        \
85                                                                                                 \
86     /* mutex wait states (64..127) */                                                           \
87     macro (ompt_state_wait_mutex, 0x040)                                                         \
88     macro (ompt_state_wait_lock, 0x041)      /* waiting for lock */                              \
89     macro (ompt_state_wait_critical, 0x042)  /* waiting for critical */                          \
90     macro (ompt_state_wait_atomic, 0x043)    /* waiting for atomic */                            \
91     macro (ompt_state_wait_ordered, 0x044)   /* waiting for ordered */                           \
92                                                                                                 \
93     /* target wait states (128..255) */                                                         \
94     macro (ompt_state_wait_target, 0x080)        /* waiting for target region */                 \
95     macro (ompt_state_wait_target_map, 0x081)    /* waiting for target data mapping operation */ \
96     macro (ompt_state_wait_target_update, 0x082) /* waiting for target update operation */       \
97                                                                                                 \
98     /* misc (256..511) */                                                                       \
99     macro (ompt_state_idle, 0x100)           /* waiting for work */                              \
100     macro (ompt_state_overhead, 0x101)       /* overhead excluding wait states */                \
101                                                                                                 \
102     /* implementation-specific states (512..) */
103 
104 
105 #define FOREACH_KMP_MUTEX_IMPL(macro)                                                \
106     macro (kmp_mutex_impl_none, 0)         /* unknown implementation */              \
107     macro (kmp_mutex_impl_spin, 1)         /* based on spin */                       \
108     macro (kmp_mutex_impl_queuing, 2)      /* based on some fair policy */           \
109     macro (kmp_mutex_impl_speculative, 3)  /* based on HW-supported speculation */
110 
111 #define FOREACH_OMPT_HOST_EVENT(macro)                                                                                   \
112                                                                                                                          \
113     /*--- Mandatory Events ---*/                                                                                         \
114     macro (ompt_callback_thread_begin,      ompt_callback_thread_begin_t,       1) /* thread begin                    */ \
115     macro (ompt_callback_thread_end,        ompt_callback_thread_end_t,         2) /* thread end                      */ \
116                                                                                                                          \
117     macro (ompt_callback_parallel_begin,    ompt_callback_parallel_begin_t,     3) /* parallel begin                  */ \
118     macro (ompt_callback_parallel_end,      ompt_callback_parallel_end_t,       4) /* parallel end                    */ \
119                                                                                                                          \
120     macro (ompt_callback_task_create,       ompt_callback_task_create_t,        5) /* task begin                      */ \
121     macro (ompt_callback_task_schedule,     ompt_callback_task_schedule_t,      6) /* task schedule                   */ \
122     macro (ompt_callback_implicit_task,     ompt_callback_implicit_task_t,      7) /* implicit task                   */ \
123                                                                                                                          \
124     macro (ompt_callback_control_tool,      ompt_callback_control_tool_t,      11) /* control tool                    */ \
125                                                                                                                          \
126     /* Optional Events */                                                                                                \
127     macro (ompt_callback_sync_region_wait,  ompt_callback_sync_region_t,       16) /* sync region wait begin or end   */ \
128                                                                                                                          \
129     macro (ompt_callback_mutex_released,    ompt_callback_mutex_t,             17) /* mutex released                  */ \
130                                                                                                                          \
131     macro (ompt_callback_dependences,       ompt_callback_dependences_t,       18) /* report task dependences         */ \
132     macro (ompt_callback_task_dependence,   ompt_callback_task_dependence_t,   19) /* report task dependence          */ \
133                                                                                                                          \
134     macro (ompt_callback_work,              ompt_callback_work_t,              20) /* task at work begin or end       */ \
135                                                                                                                          \
136     macro (ompt_callback_masked,            ompt_callback_masked_t,            21) /* task at masked begin or end     */ \
137                                                                                                                          \
138     macro (ompt_callback_sync_region,       ompt_callback_sync_region_t,       23) /* sync region begin or end        */ \
139                                                                                                                          \
140     macro (ompt_callback_lock_init,         ompt_callback_mutex_acquire_t,     24) /* lock init                       */ \
141     macro (ompt_callback_lock_destroy,      ompt_callback_mutex_t,             25) /* lock destroy                    */ \
142                                                                                                                          \
143     macro (ompt_callback_mutex_acquire,     ompt_callback_mutex_acquire_t,     26) /* mutex acquire                   */ \
144     macro (ompt_callback_mutex_acquired,    ompt_callback_mutex_t,             27) /* mutex acquired                  */ \
145                                                                                                                          \
146     macro (ompt_callback_nest_lock,         ompt_callback_nest_lock_t,         28) /* nest lock                       */ \
147                                                                                                                          \
148     macro (ompt_callback_flush,             ompt_callback_flush_t,             29) /* after executing flush           */ \
149                                                                                                                          \
150     macro (ompt_callback_cancel,            ompt_callback_cancel_t,            30) /* cancel innermost binding region */ \
151                                                                                                                          \
152     macro (ompt_callback_reduction,         ompt_callback_sync_region_t,       31) /* reduction                       */ \
153                                                                                                                          \
154     macro (ompt_callback_dispatch,          ompt_callback_dispatch_t,          32) /* dispatch of work                */ \
155     macro (ompt_callback_error,             ompt_callback_error_t,             37) /* error                           */
156 
157 #define FOREACH_OMPT_DEVICE_EVENT(macro)                                                                                 \
158     /*--- Mandatory Events ---*/                                                                                         \
159     macro (ompt_callback_device_initialize, ompt_callback_device_initialize_t, 12) /* device initialize               */ \
160     macro (ompt_callback_device_finalize,   ompt_callback_device_finalize_t,   13) /* device finalize                 */ \
161                                                                                                                          \
162     macro (ompt_callback_device_load,       ompt_callback_device_load_t,       14) /* device load                     */ \
163     macro (ompt_callback_device_unload,     ompt_callback_device_unload_t,     15) /* device unload                   */
164 
165 #define FOREACH_OMPT_NOEMI_EVENT(macro)                                                                                  \
166     /*--- Mandatory Events ---*/                                                                                         \
167     macro (ompt_callback_target,            ompt_callback_target_t,             8) /* target                          */ \
168     macro (ompt_callback_target_data_op,    ompt_callback_target_data_op_t,     9) /* target data op                  */ \
169     macro (ompt_callback_target_submit,     ompt_callback_target_submit_t,     10) /* target  submit                  */ \
170     /* Optional Events */                                                                                                \
171     macro (ompt_callback_target_map,        ompt_callback_target_map_t,        22) /* target map                      */
172 
173 #define FOREACH_OMPT_EMI_EVENT(macro)                                                                                    \
174     /*--- Mandatory Events ---*/                                                                                         \
175     macro (ompt_callback_target_emi,        ompt_callback_target_emi_t,        33) /* target                          */ \
176     macro (ompt_callback_target_data_op_emi,ompt_callback_target_data_op_emi_t,34) /* target data op                  */ \
177     macro (ompt_callback_target_submit_emi, ompt_callback_target_submit_emi_t, 35) /* target submit                   */ \
178     /* Optional Events */                                                                                                \
179     macro (ompt_callback_target_map_emi,    ompt_callback_target_map_emi_t,    36) /* target map                      */
180 
181 #define FOREACH_OMPT_50_TARGET_EVENT(macro)                                                                              \
182     FOREACH_OMPT_DEVICE_EVENT(macro)                                                                                     \
183     FOREACH_OMPT_NOEMI_EVENT(macro)
184 
185 #define FOREACH_OMPT_51_TARGET_EVENT(macro)                                                                              \
186     FOREACH_OMPT_DEVICE_EVENT(macro)                                                                                     \
187     FOREACH_OMPT_EMI_EVENT(macro)
188 
189 #define FOREACH_OMPT_EVENT(macro)                                                                                        \
190     FOREACH_OMPT_HOST_EVENT(macro)                                                                                       \
191     FOREACH_OMPT_DEVICE_EVENT(macro)                                                                                     \
192     FOREACH_OMPT_NOEMI_EVENT(macro)                                                                                      \
193     FOREACH_OMPT_EMI_EVENT(macro)
194 
195 #define FOREACH_OMPT_51_EVENT(macro)                                                                                     \
196     FOREACH_OMPT_HOST_EVENT(macro)                                                                                       \
197     FOREACH_OMPT_DEVICE_EVENT(macro)                                                                                     \
198     FOREACH_OMPT_EMI_EVENT(macro)
199 
200 /*****************************************************************************
201  * implementation specific types
202  *****************************************************************************/
203 
204 typedef enum kmp_mutex_impl_t {
205 #define kmp_mutex_impl_macro(impl, code) impl = code,
206     FOREACH_KMP_MUTEX_IMPL(kmp_mutex_impl_macro)
207 #undef kmp_mutex_impl_macro
208 } kmp_mutex_impl_t;
209 
210 /*****************************************************************************
211  * definitions generated from spec
212  *****************************************************************************/
213 
214 typedef enum ompt_callbacks_t {
215   ompt_callback_thread_begin             = 1,
216   ompt_callback_thread_end               = 2,
217   ompt_callback_parallel_begin           = 3,
218   ompt_callback_parallel_end             = 4,
219   ompt_callback_task_create              = 5,
220   ompt_callback_task_schedule            = 6,
221   ompt_callback_implicit_task            = 7,
222   ompt_callback_target                   = 8,
223   ompt_callback_target_data_op           = 9,
224   ompt_callback_target_submit            = 10,
225   ompt_callback_control_tool             = 11,
226   ompt_callback_device_initialize        = 12,
227   ompt_callback_device_finalize          = 13,
228   ompt_callback_device_load              = 14,
229   ompt_callback_device_unload            = 15,
230   ompt_callback_sync_region_wait         = 16,
231   ompt_callback_mutex_released           = 17,
232   ompt_callback_dependences              = 18,
233   ompt_callback_task_dependence          = 19,
234   ompt_callback_work                     = 20,
235   ompt_callback_master     DEPRECATED_51 = 21,
236   ompt_callback_masked                   = 21,
237   ompt_callback_target_map               = 22,
238   ompt_callback_sync_region              = 23,
239   ompt_callback_lock_init                = 24,
240   ompt_callback_lock_destroy             = 25,
241   ompt_callback_mutex_acquire            = 26,
242   ompt_callback_mutex_acquired           = 27,
243   ompt_callback_nest_lock                = 28,
244   ompt_callback_flush                    = 29,
245   ompt_callback_cancel                   = 30,
246   ompt_callback_reduction                = 31,
247   ompt_callback_dispatch                 = 32,
248   ompt_callback_target_emi               = 33,
249   ompt_callback_target_data_op_emi       = 34,
250   ompt_callback_target_submit_emi        = 35,
251   ompt_callback_target_map_emi           = 36,
252   ompt_callback_error                    = 37
253 } ompt_callbacks_t;
254 
255 typedef enum ompt_record_t {
256   ompt_record_ompt               = 1,
257   ompt_record_native             = 2,
258   ompt_record_invalid            = 3
259 } ompt_record_t;
260 
261 typedef enum ompt_record_native_t {
262   ompt_record_native_info  = 1,
263   ompt_record_native_event = 2
264 } ompt_record_native_t;
265 
266 typedef enum ompt_set_result_t {
267   ompt_set_error            = 0,
268   ompt_set_never            = 1,
269   ompt_set_impossible       = 2,
270   ompt_set_sometimes        = 3,
271   ompt_set_sometimes_paired = 4,
272   ompt_set_always           = 5
273 } ompt_set_result_t;
274 
275 typedef uint64_t ompt_id_t;
276 
277 typedef uint64_t ompt_device_time_t;
278 
279 typedef uint64_t ompt_buffer_cursor_t;
280 
281 typedef enum ompt_thread_t {
282   ompt_thread_initial                 = 1,
283   ompt_thread_worker                  = 2,
284   ompt_thread_other                   = 3,
285   ompt_thread_unknown                 = 4
286 } ompt_thread_t;
287 
288 typedef enum ompt_scope_endpoint_t {
289   ompt_scope_begin                    = 1,
290   ompt_scope_end                      = 2,
291   ompt_scope_beginend                 = 3
292 } ompt_scope_endpoint_t;
293 
294 typedef enum ompt_dispatch_t {
295   ompt_dispatch_iteration             = 1,
296   ompt_dispatch_section               = 2,
297   ompt_dispatch_ws_loop_chunk         = 3,
298   ompt_dispatch_taskloop_chunk        = 4,
299   ompt_dispatch_distribute_chunk      = 5
300 } ompt_dispatch_t;
301 
302 typedef enum ompt_sync_region_t {
303   ompt_sync_region_barrier                DEPRECATED_51 = 1,
304   ompt_sync_region_barrier_implicit       DEPRECATED_51 = 2,
305   ompt_sync_region_barrier_explicit       = 3,
306   ompt_sync_region_barrier_implementation = 4,
307   ompt_sync_region_taskwait               = 5,
308   ompt_sync_region_taskgroup              = 6,
309   ompt_sync_region_reduction              = 7,
310   ompt_sync_region_barrier_implicit_workshare = 8,
311   ompt_sync_region_barrier_implicit_parallel = 9,
312   ompt_sync_region_barrier_teams = 10
313 } ompt_sync_region_t;
314 
315 typedef enum ompt_target_data_op_t {
316   ompt_target_data_alloc                      = 1,
317   ompt_target_data_transfer_to_device         = 2,
318   ompt_target_data_transfer_from_device       = 3,
319   ompt_target_data_delete                     = 4,
320   ompt_target_data_associate                  = 5,
321   ompt_target_data_disassociate               = 6,
322   ompt_target_data_alloc_async                = 17,
323   ompt_target_data_transfer_to_device_async   = 18,
324   ompt_target_data_transfer_from_device_async = 19,
325   ompt_target_data_delete_async               = 20
326 } ompt_target_data_op_t;
327 
328 typedef enum ompt_work_t {
329   ompt_work_loop               = 1,
330   ompt_work_sections           = 2,
331   ompt_work_single_executor    = 3,
332   ompt_work_single_other       = 4,
333   ompt_work_workshare          = 5,
334   ompt_work_distribute         = 6,
335   ompt_work_taskloop           = 7,
336   ompt_work_scope              = 8,
337   ompt_work_loop_static        = 10,
338   ompt_work_loop_dynamic       = 11,
339   ompt_work_loop_guided        = 12,
340   ompt_work_loop_other         = 13
341 } ompt_work_t;
342 
343 typedef enum ompt_mutex_t {
344   ompt_mutex_lock                     = 1,
345   ompt_mutex_test_lock                = 2,
346   ompt_mutex_nest_lock                = 3,
347   ompt_mutex_test_nest_lock           = 4,
348   ompt_mutex_critical                 = 5,
349   ompt_mutex_atomic                   = 6,
350   ompt_mutex_ordered                  = 7
351 } ompt_mutex_t;
352 
353 typedef enum ompt_native_mon_flag_t {
354   ompt_native_data_motion_explicit    = 0x01,
355   ompt_native_data_motion_implicit    = 0x02,
356   ompt_native_kernel_invocation       = 0x04,
357   ompt_native_kernel_execution        = 0x08,
358   ompt_native_driver                  = 0x10,
359   ompt_native_runtime                 = 0x20,
360   ompt_native_overhead                = 0x40,
361   ompt_native_idleness                = 0x80
362 } ompt_native_mon_flag_t;
363 
364 typedef enum ompt_task_flag_t {
365   ompt_task_initial                   = 0x00000001,
366   ompt_task_implicit                  = 0x00000002,
367   ompt_task_explicit                  = 0x00000004,
368   ompt_task_target                    = 0x00000008,
369   ompt_task_taskwait                  = 0x00000010,
370   ompt_task_undeferred                = 0x08000000,
371   ompt_task_untied                    = 0x10000000,
372   ompt_task_final                     = 0x20000000,
373   ompt_task_mergeable                 = 0x40000000,
374   ompt_task_merged                    = 0x80000000
375 } ompt_task_flag_t;
376 
377 typedef enum ompt_task_status_t {
378   ompt_task_complete      = 1,
379   ompt_task_yield         = 2,
380   ompt_task_cancel        = 3,
381   ompt_task_detach        = 4,
382   ompt_task_early_fulfill = 5,
383   ompt_task_late_fulfill  = 6,
384   ompt_task_switch        = 7,
385   ompt_taskwait_complete  = 8
386 } ompt_task_status_t;
387 
388 typedef enum ompt_target_t {
389   ompt_target                         = 1,
390   ompt_target_enter_data              = 2,
391   ompt_target_exit_data               = 3,
392   ompt_target_update                  = 4,
393   ompt_target_nowait                  = 9,
394   ompt_target_enter_data_nowait       = 10,
395   ompt_target_exit_data_nowait        = 11,
396   ompt_target_update_nowait           = 12
397 } ompt_target_t;
398 
399 typedef enum ompt_parallel_flag_t {
400   ompt_parallel_invoker_program = 0x00000001,
401   ompt_parallel_invoker_runtime = 0x00000002,
402   ompt_parallel_league          = 0x40000000,
403   ompt_parallel_team            = 0x80000000
404 } ompt_parallel_flag_t;
405 
406 typedef enum ompt_target_map_flag_t {
407   ompt_target_map_flag_to             = 0x01,
408   ompt_target_map_flag_from           = 0x02,
409   ompt_target_map_flag_alloc          = 0x04,
410   ompt_target_map_flag_release        = 0x08,
411   ompt_target_map_flag_delete         = 0x10,
412   ompt_target_map_flag_implicit       = 0x20
413 } ompt_target_map_flag_t;
414 
415 typedef enum ompt_dependence_type_t {
416   ompt_dependence_type_in              = 1,
417   ompt_dependence_type_out             = 2,
418   ompt_dependence_type_inout           = 3,
419   ompt_dependence_type_mutexinoutset   = 4,
420   ompt_dependence_type_source          = 5,
421   ompt_dependence_type_sink            = 6,
422   ompt_dependence_type_inoutset        = 7
423 } ompt_dependence_type_t;
424 
425 typedef enum ompt_severity_t {
426   ompt_warning                         = 1,
427   ompt_fatal                           = 2
428 } ompt_severity_t;
429 
430 typedef enum ompt_cancel_flag_t {
431   ompt_cancel_parallel       = 0x01,
432   ompt_cancel_sections       = 0x02,
433   ompt_cancel_loop           = 0x04,
434   ompt_cancel_taskgroup      = 0x08,
435   ompt_cancel_activated      = 0x10,
436   ompt_cancel_detected       = 0x20,
437   ompt_cancel_discarded_task = 0x40
438 } ompt_cancel_flag_t;
439 
440 typedef uint64_t ompt_hwid_t;
441 
442 typedef uint64_t ompt_wait_id_t;
443 
444 typedef enum ompt_frame_flag_t {
445   ompt_frame_runtime        = 0x00,
446   ompt_frame_application    = 0x01,
447   ompt_frame_cfa            = 0x10,
448   ompt_frame_framepointer   = 0x20,
449   ompt_frame_stackaddress   = 0x30
450 } ompt_frame_flag_t;
451 
452 typedef enum ompt_state_t {
453   ompt_state_work_serial                      = 0x000,
454   ompt_state_work_parallel                    = 0x001,
455   ompt_state_work_reduction                   = 0x002,
456 
457   ompt_state_wait_barrier                     DEPRECATED_51 = 0x010,
458   ompt_state_wait_barrier_implicit_parallel   = 0x011,
459   ompt_state_wait_barrier_implicit_workshare  = 0x012,
460   ompt_state_wait_barrier_implicit            DEPRECATED_51 = 0x013,
461   ompt_state_wait_barrier_explicit            = 0x014,
462   ompt_state_wait_barrier_implementation      = 0x015,
463   ompt_state_wait_barrier_teams               = 0x016,
464 
465   ompt_state_wait_taskwait                    = 0x020,
466   ompt_state_wait_taskgroup                   = 0x021,
467 
468   ompt_state_wait_mutex                       = 0x040,
469   ompt_state_wait_lock                        = 0x041,
470   ompt_state_wait_critical                    = 0x042,
471   ompt_state_wait_atomic                      = 0x043,
472   ompt_state_wait_ordered                     = 0x044,
473 
474   ompt_state_wait_target                      = 0x080,
475   ompt_state_wait_target_map                  = 0x081,
476   ompt_state_wait_target_update               = 0x082,
477 
478   ompt_state_idle                             = 0x100,
479   ompt_state_overhead                         = 0x101,
480   ompt_state_undefined                        = 0x102
481 } ompt_state_t;
482 
483 typedef uint64_t (*ompt_get_unique_id_t) (void);
484 
485 typedef uint64_t ompd_size_t;
486 
487 typedef uint64_t ompd_wait_id_t;
488 
489 typedef uint64_t ompd_addr_t;
490 typedef int64_t  ompd_word_t;
491 typedef uint64_t ompd_seg_t;
492 
493 typedef uint64_t ompd_device_t;
494 
495 typedef uint64_t ompd_thread_id_t;
496 
497 typedef enum ompd_scope_t {
498   ompd_scope_global = 1,
499   ompd_scope_address_space = 2,
500   ompd_scope_thread = 3,
501   ompd_scope_parallel = 4,
502   ompd_scope_implicit_task = 5,
503   ompd_scope_task = 6
504 } ompd_scope_t;
505 
506 typedef uint64_t ompd_icv_id_t;
507 
508 typedef enum ompd_rc_t {
509   ompd_rc_ok = 0,
510   ompd_rc_unavailable = 1,
511   ompd_rc_stale_handle = 2,
512   ompd_rc_bad_input = 3,
513   ompd_rc_error = 4,
514   ompd_rc_unsupported = 5,
515   ompd_rc_needs_state_tracking = 6,
516   ompd_rc_incompatible = 7,
517   ompd_rc_device_read_error = 8,
518   ompd_rc_device_write_error = 9,
519   ompd_rc_nomem = 10,
520   ompd_rc_incomplete = 11,
521   ompd_rc_callback_error = 12
522 } ompd_rc_t;
523 
524 typedef void (*ompt_interface_fn_t) (void);
525 
526 typedef ompt_interface_fn_t (*ompt_function_lookup_t) (
527   const char *interface_function_name
528 );
529 
530 typedef union ompt_data_t {
531   uint64_t value;
532   void *ptr;
533 } ompt_data_t;
534 
535 typedef struct ompt_frame_t {
536   ompt_data_t exit_frame;
537   ompt_data_t enter_frame;
538   int exit_frame_flags;
539   int enter_frame_flags;
540 } ompt_frame_t;
541 
542 typedef void (*ompt_callback_t) (void);
543 
544 typedef void ompt_device_t;
545 
546 typedef void ompt_buffer_t;
547 
548 typedef void (*ompt_callback_buffer_request_t) (
549   int device_num,
550   ompt_buffer_t **buffer,
551   size_t *bytes
552 );
553 
554 typedef void (*ompt_callback_buffer_complete_t) (
555   int device_num,
556   ompt_buffer_t *buffer,
557   size_t bytes,
558   ompt_buffer_cursor_t begin,
559   int buffer_owned
560 );
561 
562 typedef void (*ompt_finalize_t) (
563   ompt_data_t *tool_data
564 );
565 
566 typedef int (*ompt_initialize_t) (
567   ompt_function_lookup_t lookup,
568   int initial_device_num,
569   ompt_data_t *tool_data
570 );
571 
572 typedef struct ompt_start_tool_result_t {
573   ompt_initialize_t initialize;
574   ompt_finalize_t finalize;
575   ompt_data_t tool_data;
576 } ompt_start_tool_result_t;
577 
578 typedef struct ompt_record_abstract_t {
579   ompt_record_native_t rclass;
580   const char *type;
581   ompt_device_time_t start_time;
582   ompt_device_time_t end_time;
583   ompt_hwid_t hwid;
584 } ompt_record_abstract_t;
585 
586 typedef struct ompt_dependence_t {
587   ompt_data_t variable;
588   ompt_dependence_type_t dependence_type;
589 } ompt_dependence_t;
590 
591 typedef struct ompt_dispatch_chunk_t {
592   uint64_t start;
593   uint64_t iterations;
594 } ompt_dispatch_chunk_t;
595 
596 typedef int (*ompt_enumerate_states_t) (
597   int current_state,
598   int *next_state,
599   const char **next_state_name
600 );
601 
602 typedef int (*ompt_enumerate_mutex_impls_t) (
603   int current_impl,
604   int *next_impl,
605   const char **next_impl_name
606 );
607 
608 typedef ompt_set_result_t (*ompt_set_callback_t) (
609   ompt_callbacks_t event,
610   ompt_callback_t callback
611 );
612 
613 typedef int (*ompt_get_callback_t) (
614   ompt_callbacks_t event,
615   ompt_callback_t *callback
616 );
617 
618 typedef ompt_data_t *(*ompt_get_thread_data_t) (void);
619 
620 typedef int (*ompt_get_num_procs_t) (void);
621 
622 typedef int (*ompt_get_num_places_t) (void);
623 
624 typedef int (*ompt_get_place_proc_ids_t) (
625   int place_num,
626   int ids_size,
627   int *ids
628 );
629 
630 typedef int (*ompt_get_place_num_t) (void);
631 
632 typedef int (*ompt_get_partition_place_nums_t) (
633   int place_nums_size,
634   int *place_nums
635 );
636 
637 typedef int (*ompt_get_proc_id_t) (void);
638 
639 typedef int (*ompt_get_state_t) (
640   ompt_wait_id_t *wait_id
641 );
642 
643 typedef int (*ompt_get_parallel_info_t) (
644   int ancestor_level,
645   ompt_data_t **parallel_data,
646   int *team_size
647 );
648 
649 typedef int (*ompt_get_task_info_t) (
650   int ancestor_level,
651   int *flags,
652   ompt_data_t **task_data,
653   ompt_frame_t **task_frame,
654   ompt_data_t **parallel_data,
655   int *thread_num
656 );
657 
658 typedef int (*ompt_get_task_memory_t)(
659   void **addr,
660   size_t *size,
661   int block
662 );
663 
664 typedef int (*ompt_get_target_info_t) (
665   uint64_t *device_num,
666   ompt_id_t *target_id,
667   ompt_id_t *host_op_id
668 );
669 
670 typedef int (*ompt_get_num_devices_t) (void);
671 
672 typedef void (*ompt_finalize_tool_t) (void);
673 
674 typedef int (*ompt_get_device_num_procs_t) (
675   ompt_device_t *device
676 );
677 
678 typedef ompt_device_time_t (*ompt_get_device_time_t) (
679   ompt_device_t *device
680 );
681 
682 typedef double (*ompt_translate_time_t) (
683   ompt_device_t *device,
684   ompt_device_time_t time
685 );
686 
687 typedef ompt_set_result_t (*ompt_set_trace_ompt_t) (
688   ompt_device_t *device,
689   unsigned int enable,
690   unsigned int etype
691 );
692 
693 typedef ompt_set_result_t (*ompt_set_trace_native_t) (
694   ompt_device_t *device,
695   int enable,
696   int flags
697 );
698 
699 typedef int (*ompt_start_trace_t) (
700   ompt_device_t *device,
701   ompt_callback_buffer_request_t request,
702   ompt_callback_buffer_complete_t complete
703 );
704 
705 typedef int (*ompt_pause_trace_t) (
706   ompt_device_t *device,
707   int begin_pause
708 );
709 
710 typedef int (*ompt_flush_trace_t) (
711   ompt_device_t *device
712 );
713 
714 typedef int (*ompt_stop_trace_t) (
715   ompt_device_t *device
716 );
717 
718 typedef int (*ompt_advance_buffer_cursor_t) (
719   ompt_device_t *device,
720   ompt_buffer_t *buffer,
721   size_t size,
722   ompt_buffer_cursor_t current,
723   ompt_buffer_cursor_t *next
724 );
725 
726 typedef ompt_record_t (*ompt_get_record_type_t) (
727   ompt_buffer_t *buffer,
728   ompt_buffer_cursor_t current
729 );
730 
731 typedef void *(*ompt_get_record_native_t) (
732   ompt_buffer_t *buffer,
733   ompt_buffer_cursor_t current,
734   ompt_id_t *host_op_id
735 );
736 
737 typedef ompt_record_abstract_t *
738 (*ompt_get_record_abstract_t) (
739   void *native_record
740 );
741 
742 typedef void (*ompt_callback_thread_begin_t) (
743   ompt_thread_t thread_type,
744   ompt_data_t *thread_data
745 );
746 
747 typedef struct ompt_record_thread_begin_t {
748   ompt_thread_t thread_type;
749 } ompt_record_thread_begin_t;
750 
751 typedef void (*ompt_callback_thread_end_t) (
752   ompt_data_t *thread_data
753 );
754 
755 typedef void (*ompt_callback_parallel_begin_t) (
756   ompt_data_t *encountering_task_data,
757   const ompt_frame_t *encountering_task_frame,
758   ompt_data_t *parallel_data,
759   unsigned int requested_parallelism,
760   int flags,
761   const void *codeptr_ra
762 );
763 
764 typedef struct ompt_record_parallel_begin_t {
765   ompt_id_t encountering_task_id;
766   ompt_id_t parallel_id;
767   unsigned int requested_parallelism;
768   int flags;
769   const void *codeptr_ra;
770 } ompt_record_parallel_begin_t;
771 
772 typedef void (*ompt_callback_parallel_end_t) (
773   ompt_data_t *parallel_data,
774   ompt_data_t *encountering_task_data,
775   int flags,
776   const void *codeptr_ra
777 );
778 
779 typedef struct ompt_record_parallel_end_t {
780   ompt_id_t parallel_id;
781   ompt_id_t encountering_task_id;
782   int flags;
783   const void *codeptr_ra;
784 } ompt_record_parallel_end_t;
785 
786 typedef void (*ompt_callback_work_t) (
787   ompt_work_t work_type,
788   ompt_scope_endpoint_t endpoint,
789   ompt_data_t *parallel_data,
790   ompt_data_t *task_data,
791   uint64_t count,
792   const void *codeptr_ra
793 );
794 
795 typedef struct ompt_record_work_t {
796   ompt_work_t work_type;
797   ompt_scope_endpoint_t endpoint;
798   ompt_id_t parallel_id;
799   ompt_id_t task_id;
800   uint64_t count;
801   const void *codeptr_ra;
802 } ompt_record_work_t;
803 
804 typedef void (*ompt_callback_dispatch_t) (
805   ompt_data_t *parallel_data,
806   ompt_data_t *task_data,
807   ompt_dispatch_t kind,
808   ompt_data_t instance
809 );
810 
811 typedef struct ompt_record_dispatch_t {
812   ompt_id_t parallel_id;
813   ompt_id_t task_id;
814   ompt_dispatch_t kind;
815   ompt_data_t instance;
816 } ompt_record_dispatch_t;
817 
818 typedef void (*ompt_callback_task_create_t) (
819   ompt_data_t *encountering_task_data,
820   const ompt_frame_t *encountering_task_frame,
821   ompt_data_t *new_task_data,
822   int flags,
823   int has_dependences,
824   const void *codeptr_ra
825 );
826 
827 typedef struct ompt_record_task_create_t {
828   ompt_id_t encountering_task_id;
829   ompt_id_t new_task_id;
830   int flags;
831   int has_dependences;
832   const void *codeptr_ra;
833 } ompt_record_task_create_t;
834 
835 typedef void (*ompt_callback_dependences_t) (
836   ompt_data_t *task_data,
837   const ompt_dependence_t *deps,
838   int ndeps
839 );
840 
841 typedef struct ompt_record_dependences_t {
842   ompt_id_t task_id;
843   ompt_dependence_t dep;
844   int ndeps;
845 } ompt_record_dependences_t;
846 
847 typedef void (*ompt_callback_task_dependence_t) (
848   ompt_data_t *src_task_data,
849   ompt_data_t *sink_task_data
850 );
851 
852 typedef struct ompt_record_task_dependence_t {
853   ompt_id_t src_task_id;
854   ompt_id_t sink_task_id;
855 } ompt_record_task_dependence_t;
856 
857 typedef void (*ompt_callback_task_schedule_t) (
858   ompt_data_t *prior_task_data,
859   ompt_task_status_t prior_task_status,
860   ompt_data_t *next_task_data
861 );
862 
863 typedef struct ompt_record_task_schedule_t {
864   ompt_id_t prior_task_id;
865   ompt_task_status_t prior_task_status;
866   ompt_id_t next_task_id;
867 } ompt_record_task_schedule_t;
868 
869 typedef void (*ompt_callback_implicit_task_t) (
870   ompt_scope_endpoint_t endpoint,
871   ompt_data_t *parallel_data,
872   ompt_data_t *task_data,
873   unsigned int actual_parallelism,
874   unsigned int index,
875   int flags
876 );
877 
878 typedef struct ompt_record_implicit_task_t {
879   ompt_scope_endpoint_t endpoint;
880   ompt_id_t parallel_id;
881   ompt_id_t task_id;
882   unsigned int actual_parallelism;
883   unsigned int index;
884   int flags;
885 } ompt_record_implicit_task_t;
886 
887 typedef void (*ompt_callback_masked_t) (
888   ompt_scope_endpoint_t endpoint,
889   ompt_data_t *parallel_data,
890   ompt_data_t *task_data,
891   const void *codeptr_ra
892 );
893 
894 typedef ompt_callback_masked_t ompt_callback_master_t DEPRECATED_51;
895 
896 typedef struct ompt_record_masked_t {
897   ompt_scope_endpoint_t endpoint;
898   ompt_id_t parallel_id;
899   ompt_id_t task_id;
900   const void *codeptr_ra;
901 } ompt_record_masked_t;
902 
903 typedef void (*ompt_callback_sync_region_t) (
904   ompt_sync_region_t kind,
905   ompt_scope_endpoint_t endpoint,
906   ompt_data_t *parallel_data,
907   ompt_data_t *task_data,
908   const void *codeptr_ra
909 );
910 
911 typedef struct ompt_record_sync_region_t {
912   ompt_sync_region_t kind;
913   ompt_scope_endpoint_t endpoint;
914   ompt_id_t parallel_id;
915   ompt_id_t task_id;
916   const void *codeptr_ra;
917 } ompt_record_sync_region_t;
918 
919 typedef void (*ompt_callback_mutex_acquire_t) (
920   ompt_mutex_t kind,
921   unsigned int hint,
922   unsigned int impl,
923   ompt_wait_id_t wait_id,
924   const void *codeptr_ra
925 );
926 
927 typedef struct ompt_record_mutex_acquire_t {
928   ompt_mutex_t kind;
929   unsigned int hint;
930   unsigned int impl;
931   ompt_wait_id_t wait_id;
932   const void *codeptr_ra;
933 } ompt_record_mutex_acquire_t;
934 
935 typedef void (*ompt_callback_mutex_t) (
936   ompt_mutex_t kind,
937   ompt_wait_id_t wait_id,
938   const void *codeptr_ra
939 );
940 
941 typedef struct ompt_record_mutex_t {
942   ompt_mutex_t kind;
943   ompt_wait_id_t wait_id;
944   const void *codeptr_ra;
945 } ompt_record_mutex_t;
946 
947 typedef void (*ompt_callback_nest_lock_t) (
948   ompt_scope_endpoint_t endpoint,
949   ompt_wait_id_t wait_id,
950   const void *codeptr_ra
951 );
952 
953 typedef struct ompt_record_nest_lock_t {
954   ompt_scope_endpoint_t endpoint;
955   ompt_wait_id_t wait_id;
956   const void *codeptr_ra;
957 } ompt_record_nest_lock_t;
958 
959 typedef void (*ompt_callback_flush_t) (
960   ompt_data_t *thread_data,
961   const void *codeptr_ra
962 );
963 
964 typedef struct ompt_record_flush_t {
965   const void *codeptr_ra;
966 } ompt_record_flush_t;
967 
968 typedef void (*ompt_callback_cancel_t) (
969   ompt_data_t *task_data,
970   int flags,
971   const void *codeptr_ra
972 );
973 
974 typedef struct ompt_record_cancel_t {
975   ompt_id_t task_id;
976   int flags;
977   const void *codeptr_ra;
978 } ompt_record_cancel_t;
979 
980 typedef void (*ompt_callback_device_initialize_t) (
981   int device_num,
982   const char *type,
983   ompt_device_t *device,
984   ompt_function_lookup_t lookup,
985   const char *documentation
986 );
987 
988 typedef void (*ompt_callback_device_finalize_t) (
989   int device_num
990 );
991 
992 typedef void (*ompt_callback_device_load_t) (
993   int device_num,
994   const char *filename,
995   int64_t offset_in_file,
996   void *vma_in_file,
997   size_t bytes,
998   void *host_addr,
999   void *device_addr,
1000   uint64_t module_id
1001 );
1002 
1003 typedef void (*ompt_callback_device_unload_t) (
1004   int device_num,
1005   uint64_t module_id
1006 );
1007 
1008 typedef void (*ompt_callback_target_data_op_emi_t) (
1009   ompt_scope_endpoint_t endpoint,
1010   ompt_data_t *target_task_data,
1011   ompt_data_t *target_data,
1012   ompt_id_t *host_op_id,
1013   ompt_target_data_op_t optype,
1014   void *src_addr,
1015   int src_device_num,
1016   void *dest_addr,
1017   int dest_device_num,
1018   size_t bytes,
1019   const void *codeptr_ra
1020 );
1021 
1022 typedef void (*ompt_callback_target_data_op_t) (
1023   ompt_id_t target_id,
1024   ompt_id_t host_op_id,
1025   ompt_target_data_op_t optype,
1026   void *src_addr,
1027   int src_device_num,
1028   void *dest_addr,
1029   int dest_device_num,
1030   size_t bytes,
1031   const void *codeptr_ra
1032 );
1033 
1034 typedef struct ompt_record_target_data_op_t {
1035   ompt_id_t host_op_id;
1036   ompt_target_data_op_t optype;
1037   void *src_addr;
1038   int src_device_num;
1039   void *dest_addr;
1040   int dest_device_num;
1041   size_t bytes;
1042   ompt_device_time_t end_time;
1043   const void *codeptr_ra;
1044 } ompt_record_target_data_op_t;
1045 
1046 typedef void (*ompt_callback_target_emi_t) (
1047   ompt_target_t kind,
1048   ompt_scope_endpoint_t endpoint,
1049   int device_num,
1050   ompt_data_t *task_data,
1051   ompt_data_t *target_task_data,
1052   ompt_data_t *target_data,
1053   const void *codeptr_ra
1054 );
1055 
1056 typedef void (*ompt_callback_target_t) (
1057   ompt_target_t kind,
1058   ompt_scope_endpoint_t endpoint,
1059   int device_num,
1060   ompt_data_t *task_data,
1061   ompt_id_t target_id,
1062   const void *codeptr_ra
1063 );
1064 
1065 typedef struct ompt_record_target_t {
1066   ompt_target_t kind;
1067   ompt_scope_endpoint_t endpoint;
1068   int device_num;
1069   ompt_id_t task_id;
1070   ompt_id_t target_id;
1071   const void *codeptr_ra;
1072 } ompt_record_target_t;
1073 
1074 typedef void (*ompt_callback_target_map_emi_t) (
1075   ompt_data_t *target_data,
1076   unsigned int nitems,
1077   void **host_addr,
1078   void **device_addr,
1079   size_t *bytes,
1080   unsigned int *mapping_flags,
1081   const void *codeptr_ra
1082 );
1083 
1084 typedef void (*ompt_callback_target_map_t) (
1085   ompt_id_t target_id,
1086   unsigned int nitems,
1087   void **host_addr,
1088   void **device_addr,
1089   size_t *bytes,
1090   unsigned int *mapping_flags,
1091   const void *codeptr_ra
1092 );
1093 
1094 typedef struct ompt_record_target_map_t {
1095   ompt_id_t target_id;
1096   unsigned int nitems;
1097   void **host_addr;
1098   void **device_addr;
1099   size_t *bytes;
1100   unsigned int *mapping_flags;
1101   const void *codeptr_ra;
1102 } ompt_record_target_map_t;
1103 
1104 typedef void (*ompt_callback_target_submit_emi_t) (
1105   ompt_scope_endpoint_t endpoint,
1106   ompt_data_t *target_data,
1107   ompt_id_t *host_op_id,
1108   unsigned int requested_num_teams
1109 );
1110 
1111 typedef void (*ompt_callback_target_submit_t) (
1112   ompt_id_t target_id,
1113   ompt_id_t host_op_id,
1114   unsigned int requested_num_teams
1115 );
1116 
1117 typedef struct ompt_record_target_kernel_t {
1118   ompt_id_t host_op_id;
1119   unsigned int requested_num_teams;
1120   unsigned int granted_num_teams;
1121   ompt_device_time_t end_time;
1122 } ompt_record_target_kernel_t;
1123 
1124 typedef int (*ompt_callback_control_tool_t) (
1125   uint64_t command,
1126   uint64_t modifier,
1127   void *arg,
1128   const void *codeptr_ra
1129 );
1130 
1131 typedef struct ompt_record_control_tool_t {
1132   uint64_t command;
1133   uint64_t modifier;
1134   const void *codeptr_ra;
1135 } ompt_record_control_tool_t;
1136 
1137 typedef void (*ompt_callback_error_t) (
1138   ompt_severity_t severity,
1139   const char *message, size_t length,
1140   const void *codeptr_ra
1141 );
1142 
1143 typedef struct ompt_record_error_t {
1144   ompt_severity_t severity;
1145   const char *message;
1146   size_t length;
1147   const void *codeptr_ra;
1148 } ompt_record_error_t;
1149 
1150 typedef struct ompd_address_t {
1151   ompd_seg_t segment;
1152   ompd_addr_t address;
1153 } ompd_address_t;
1154 
1155 typedef struct ompd_frame_info_t {
1156   ompd_address_t frame_address;
1157   ompd_word_t frame_flag;
1158 } ompd_frame_info_t;
1159 
1160 typedef struct _ompd_aspace_handle ompd_address_space_handle_t;
1161 typedef struct _ompd_thread_handle ompd_thread_handle_t;
1162 typedef struct _ompd_parallel_handle ompd_parallel_handle_t;
1163 typedef struct _ompd_task_handle ompd_task_handle_t;
1164 
1165 typedef struct _ompd_aspace_cont ompd_address_space_context_t;
1166 typedef struct _ompd_thread_cont ompd_thread_context_t;
1167 
1168 typedef struct ompd_device_type_sizes_t {
1169   uint8_t sizeof_char;
1170   uint8_t sizeof_short;
1171   uint8_t sizeof_int;
1172   uint8_t sizeof_long;
1173   uint8_t sizeof_long_long;
1174   uint8_t sizeof_pointer;
1175 } ompd_device_type_sizes_t;
1176 
1177 void ompd_dll_locations_valid(void);
1178 
1179 typedef ompd_rc_t (*ompd_callback_memory_alloc_fn_t)(ompd_size_t nbytes,
1180                                                      void **ptr);
1181 
1182 typedef ompd_rc_t (*ompd_callback_memory_free_fn_t)(void *ptr);
1183 
1184 typedef ompd_rc_t (*ompd_callback_get_thread_context_for_thread_id_fn_t)(
1185     ompd_address_space_context_t *address_space_context, ompd_thread_id_t kind,
1186     ompd_size_t sizeof_thread_id, const void *thread_id,
1187     ompd_thread_context_t **thread_context);
1188 
1189 typedef ompd_rc_t (*ompd_callback_sizeof_fn_t)(
1190     ompd_address_space_context_t *address_space_context,
1191     ompd_device_type_sizes_t *sizes);
1192 
1193 typedef ompd_rc_t (*ompd_callback_symbol_addr_fn_t)(
1194     ompd_address_space_context_t *address_space_context,
1195     ompd_thread_context_t *thread_context, const char *symbol_name,
1196     ompd_address_t *symbol_addr, const char *file_name);
1197 
1198 typedef ompd_rc_t (*ompd_callback_memory_read_fn_t)(
1199     ompd_address_space_context_t *address_space_context,
1200     ompd_thread_context_t *thread_context, const ompd_address_t *addr,
1201     ompd_size_t nbytes, void *buffer);
1202 
1203 typedef ompd_rc_t (*ompd_callback_memory_write_fn_t)(
1204     ompd_address_space_context_t *address_space_context,
1205     ompd_thread_context_t *thread_context, const ompd_address_t *addr,
1206     ompd_size_t nbytes, const void *buffer);
1207 
1208 typedef ompd_rc_t (*ompd_callback_device_host_fn_t)(
1209     ompd_address_space_context_t *address_space_context, const void *input,
1210     ompd_size_t unit_size, ompd_size_t count, void *output);
1211 
1212 typedef ompd_rc_t (*ompd_callback_print_string_fn_t)(const char *string,
1213                                                      int category);
1214 
1215 typedef struct ompd_callbacks_t {
1216   ompd_callback_memory_alloc_fn_t alloc_memory;
1217   ompd_callback_memory_free_fn_t free_memory;
1218   ompd_callback_print_string_fn_t print_string;
1219   ompd_callback_sizeof_fn_t sizeof_type;
1220   ompd_callback_symbol_addr_fn_t symbol_addr_lookup;
1221   ompd_callback_memory_read_fn_t read_memory;
1222   ompd_callback_memory_write_fn_t write_memory;
1223   ompd_callback_memory_read_fn_t read_string;
1224   ompd_callback_device_host_fn_t device_to_host;
1225   ompd_callback_device_host_fn_t host_to_device;
1226   ompd_callback_get_thread_context_for_thread_id_fn_t
1227       get_thread_context_for_thread_id;
1228 } ompd_callbacks_t;
1229 
1230 void ompd_bp_parallel_begin(void);
1231 
1232 void ompd_bp_parallel_end(void);
1233 
1234 void ompd_bp_task_begin(void);
1235 
1236 void ompd_bp_task_end(void);
1237 
1238 void ompd_bp_thread_begin(void);
1239 
1240 void ompd_bp_thread_end(void);
1241 
1242 void ompd_bp_device_begin(void);
1243 
1244 void ompd_bp_device_end(void);
1245 
1246 ompd_rc_t ompd_initialize(ompd_word_t api_version,
1247                           const ompd_callbacks_t *callbacks);
1248 
1249 ompd_rc_t ompd_get_api_version(ompd_word_t *version);
1250 
1251 ompd_rc_t ompd_get_version_string(const char **string);
1252 
1253 ompd_rc_t ompd_finalize(void);
1254 
1255 ompd_rc_t ompd_process_initialize(ompd_address_space_context_t *context,
1256                                   ompd_address_space_handle_t **handle);
1257 
1258 ompd_rc_t ompd_device_initialize(ompd_address_space_handle_t *process_handle,
1259                                  ompd_address_space_context_t *device_context,
1260                                  ompd_device_t kind, ompd_size_t sizeof_id,
1261                                  void *id,
1262                                  ompd_address_space_handle_t **device_handle);
1263 
1264 ompd_rc_t ompd_rel_address_space_handle(ompd_address_space_handle_t *handle);
1265 
1266 ompd_rc_t ompd_get_omp_version(ompd_address_space_handle_t *address_space,
1267                                ompd_word_t *omp_version);
1268 
1269 ompd_rc_t
1270 ompd_get_omp_version_string(ompd_address_space_handle_t *address_space,
1271                             const char **string);
1272 
1273 ompd_rc_t ompd_get_thread_in_parallel(ompd_parallel_handle_t *parallel_handle,
1274                                       int thread_num,
1275                                       ompd_thread_handle_t **thread_handle);
1276 
1277 ompd_rc_t ompd_get_thread_handle(ompd_address_space_handle_t *handle,
1278                                  ompd_thread_id_t kind,
1279                                  ompd_size_t sizeof_thread_id,
1280                                  const void *thread_id,
1281                                  ompd_thread_handle_t **thread_handle);
1282 
1283 ompd_rc_t ompd_rel_thread_handle(ompd_thread_handle_t *thread_handle);
1284 
1285 ompd_rc_t ompd_thread_handle_compare(ompd_thread_handle_t *thread_handle_1,
1286                                      ompd_thread_handle_t *thread_handle_2,
1287                                      int *cmp_value);
1288 
1289 ompd_rc_t ompd_get_thread_id(ompd_thread_handle_t *thread_handle,
1290                              ompd_thread_id_t kind,
1291                              ompd_size_t sizeof_thread_id, void *thread_id);
1292 
1293 ompd_rc_t
1294 ompd_get_curr_parallel_handle(ompd_thread_handle_t *thread_handle,
1295                               ompd_parallel_handle_t **parallel_handle);
1296 
1297 ompd_rc_t ompd_get_enclosing_parallel_handle(
1298     ompd_parallel_handle_t *parallel_handle,
1299     ompd_parallel_handle_t **enclosing_parallel_handle);
1300 
1301 ompd_rc_t
1302 ompd_get_task_parallel_handle(ompd_task_handle_t *task_handle,
1303                               ompd_parallel_handle_t **task_parallel_handle);
1304 
1305 ompd_rc_t ompd_rel_parallel_handle(ompd_parallel_handle_t *parallel_handle);
1306 
1307 ompd_rc_t
1308 ompd_parallel_handle_compare(ompd_parallel_handle_t *parallel_handle_1,
1309                              ompd_parallel_handle_t *parallel_handle_2,
1310                              int *cmp_value);
1311 
1312 ompd_rc_t ompd_get_curr_task_handle(ompd_thread_handle_t *thread_handle,
1313                                     ompd_task_handle_t **task_handle);
1314 
1315 ompd_rc_t
1316 ompd_get_generating_task_handle(ompd_task_handle_t *task_handle,
1317                                 ompd_task_handle_t **generating_task_handle);
1318 
1319 ompd_rc_t
1320 ompd_get_scheduling_task_handle(ompd_task_handle_t *task_handle,
1321                                 ompd_task_handle_t **scheduling_task_handle);
1322 
1323 ompd_rc_t ompd_get_task_in_parallel(ompd_parallel_handle_t *parallel_handle,
1324                                     int thread_num,
1325                                     ompd_task_handle_t **task_handle);
1326 
1327 ompd_rc_t ompd_rel_task_handle(ompd_task_handle_t *task_handle);
1328 
1329 ompd_rc_t ompd_task_handle_compare(ompd_task_handle_t *task_handle_1,
1330                                    ompd_task_handle_t *task_handle_2,
1331                                    int *cmp_value);
1332 
1333 ompd_rc_t ompd_get_task_function(ompd_task_handle_t *task_handle,
1334                                  ompd_address_t *entry_point);
1335 
1336 ompd_rc_t ompd_get_task_frame(ompd_task_handle_t *task_handle,
1337                               ompd_frame_info_t *exit_frame,
1338                               ompd_frame_info_t *enter_frame);
1339 
1340 ompd_rc_t
1341 ompd_enumerate_states(ompd_address_space_handle_t *address_space_handle,
1342                       ompd_word_t current_state, ompd_word_t *next_state,
1343                       const char **next_state_name, ompd_word_t *more_enums);
1344 
1345 ompd_rc_t ompd_get_state(ompd_thread_handle_t *thread_handle,
1346                          ompd_word_t *state, ompd_wait_id_t *wait_id);
1347 
1348 ompd_rc_t
1349 ompd_get_display_control_vars(ompd_address_space_handle_t *address_space_handle,
1350                               const char *const **control_vars);
1351 
1352 ompd_rc_t ompd_rel_display_control_vars(const char *const **control_vars);
1353 
1354 ompd_rc_t ompd_enumerate_icvs(ompd_address_space_handle_t *handle,
1355                               ompd_icv_id_t current, ompd_icv_id_t *next_id,
1356                               const char **next_icv_name,
1357                               ompd_scope_t *next_scope, int *more);
1358 
1359 ompd_rc_t ompd_get_icv_from_scope(void *handle, ompd_scope_t scope,
1360                                   ompd_icv_id_t icv_id, ompd_word_t *icv_value);
1361 
1362 ompd_rc_t ompd_get_icv_string_from_scope(void *handle, ompd_scope_t scope,
1363                                          ompd_icv_id_t icv_id,
1364                                          const char **icv_string);
1365 
1366 ompd_rc_t ompd_get_tool_data(void *handle, ompd_scope_t scope,
1367                              ompd_word_t *value, ompd_address_t *ptr);
1368 
1369 typedef struct ompt_record_ompt_t {
1370   ompt_callbacks_t type;
1371   ompt_device_time_t time;
1372   ompt_id_t thread_id;
1373   ompt_id_t target_id;
1374   union {
1375     ompt_record_thread_begin_t thread_begin;
1376     ompt_record_parallel_begin_t parallel_begin;
1377     ompt_record_parallel_end_t parallel_end;
1378     ompt_record_work_t work;
1379     ompt_record_dispatch_t dispatch;
1380     ompt_record_task_create_t task_create;
1381     ompt_record_dependences_t dependences;
1382     ompt_record_task_dependence_t task_dependence;
1383     ompt_record_task_schedule_t task_schedule;
1384     ompt_record_implicit_task_t implicit_task;
1385     ompt_record_masked_t masked;
1386     ompt_record_sync_region_t sync_region;
1387     ompt_record_mutex_acquire_t mutex_acquire;
1388     ompt_record_mutex_t mutex;
1389     ompt_record_nest_lock_t nest_lock;
1390     ompt_record_flush_t flush;
1391     ompt_record_cancel_t cancel;
1392     ompt_record_target_t target;
1393     ompt_record_target_data_op_t target_data_op;
1394     ompt_record_target_map_t target_map;
1395     ompt_record_target_kernel_t target_kernel;
1396     ompt_record_control_tool_t control_tool;
1397   } record;
1398 } ompt_record_ompt_t;
1399 
1400 typedef ompt_record_ompt_t *(*ompt_get_record_ompt_t) (
1401   ompt_buffer_t *buffer,
1402   ompt_buffer_cursor_t current
1403 );
1404 
1405 #define ompt_id_none 0
1406 #define ompt_data_none {0}
1407 #define ompt_time_none 0
1408 #define ompt_hwid_none 0
1409 #define ompt_addr_none ~0
1410 #define ompt_mutex_impl_none 0
1411 #define ompt_wait_id_none 0
1412 
1413 #define ompd_segment_none 0
1414 
1415 #endif /* __OMPT__ */
1416