2 * include/omp-tools.h.var
5 //===----------------------------------------------------------------------===//
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
11 //===----------------------------------------------------------------------===//
16 /*****************************************************************************
17 * system include files
18 *****************************************************************************/
23 #ifdef DEPRECATION_WARNINGS
25 # define DEPRECATED_51 [[deprecated("as of 5.1")]]
27 # define DEPRECATED_51 __attribute__((deprecated("as of 5.1")))
33 /*****************************************************************************
35 *****************************************************************************/
37 #define FOREACH_OMPT_INQUIRY_FN(macro) \
38 macro (ompt_enumerate_states) \
39 macro (ompt_enumerate_mutex_impls) \
41 macro (ompt_set_callback) \
42 macro (ompt_get_callback) \
44 macro (ompt_get_state) \
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) \
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) \
60 macro(ompt_get_target_info) \
61 macro(ompt_get_num_devices)
63 #define FOREACH_OMPT_STATE(macro) \
65 /* first available state */ \
66 macro (ompt_state_undefined, 0x102) /* undefined thread state */ \
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 */ \
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 macro (ompt_state_wait_barrier_implementation, 0x015) /* implementation barrier */ \
82 macro (ompt_state_wait_barrier_teams, 0x016) /* teams barrier */ \
84 /* task wait states (32..63) */ \
85 macro (ompt_state_wait_taskwait, 0x020) /* waiting at a taskwait */ \
86 macro (ompt_state_wait_taskgroup, 0x021) /* waiting at a taskgroup */ \
88 /* mutex wait states (64..127) */ \
89 macro (ompt_state_wait_mutex, 0x040) \
90 macro (ompt_state_wait_lock, 0x041) /* waiting for lock */ \
91 macro (ompt_state_wait_critical, 0x042) /* waiting for critical */ \
92 macro (ompt_state_wait_atomic, 0x043) /* waiting for atomic */ \
93 macro (ompt_state_wait_ordered, 0x044) /* waiting for ordered */ \
95 /* target wait states (128..255) */ \
96 macro (ompt_state_wait_target, 0x080) /* waiting for target region */ \
97 macro (ompt_state_wait_target_map, 0x081) /* waiting for target data mapping operation */ \
98 macro (ompt_state_wait_target_update, 0x082) /* waiting for target update operation */ \
100 /* misc (256..511) */ \
101 macro (ompt_state_idle, 0x100) /* waiting for work */ \
102 macro (ompt_state_overhead, 0x101) /* overhead excluding wait states */ \
104 /* implementation-specific states (512..) */
107 #define FOREACH_KMP_MUTEX_IMPL(macro) \
108 macro (kmp_mutex_impl_none, 0) /* unknown implementation */ \
109 macro (kmp_mutex_impl_spin, 1) /* based on spin */ \
110 macro (kmp_mutex_impl_queuing, 2) /* based on some fair policy */ \
111 macro (kmp_mutex_impl_speculative, 3) /* based on HW-supported speculation */
113 #define FOREACH_OMPT_HOST_EVENT(macro) \
115 /*--- Mandatory Events ---*/ \
116 macro (ompt_callback_thread_begin, ompt_callback_thread_begin_t, 1) /* thread begin */ \
117 macro (ompt_callback_thread_end, ompt_callback_thread_end_t, 2) /* thread end */ \
119 macro (ompt_callback_parallel_begin, ompt_callback_parallel_begin_t, 3) /* parallel begin */ \
120 macro (ompt_callback_parallel_end, ompt_callback_parallel_end_t, 4) /* parallel end */ \
122 macro (ompt_callback_task_create, ompt_callback_task_create_t, 5) /* task begin */ \
123 macro (ompt_callback_task_schedule, ompt_callback_task_schedule_t, 6) /* task schedule */ \
124 macro (ompt_callback_implicit_task, ompt_callback_implicit_task_t, 7) /* implicit task */ \
126 macro (ompt_callback_control_tool, ompt_callback_control_tool_t, 11) /* control tool */ \
128 /* Optional Events */ \
129 macro (ompt_callback_sync_region_wait, ompt_callback_sync_region_t, 16) /* sync region wait begin or end */ \
131 macro (ompt_callback_mutex_released, ompt_callback_mutex_t, 17) /* mutex released */ \
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 */ \
136 macro (ompt_callback_work, ompt_callback_work_t, 20) /* task at work begin or end */ \
138 macro (ompt_callback_masked, ompt_callback_masked_t, 21) /* task at masked begin or end */ \
140 macro (ompt_callback_sync_region, ompt_callback_sync_region_t, 23) /* sync region begin or end */ \
142 macro (ompt_callback_lock_init, ompt_callback_mutex_acquire_t, 24) /* lock init */ \
143 macro (ompt_callback_lock_destroy, ompt_callback_mutex_t, 25) /* lock destroy */ \
145 macro (ompt_callback_mutex_acquire, ompt_callback_mutex_acquire_t, 26) /* mutex acquire */ \
146 macro (ompt_callback_mutex_acquired, ompt_callback_mutex_t, 27) /* mutex acquired */ \
148 macro (ompt_callback_nest_lock, ompt_callback_nest_lock_t, 28) /* nest lock */ \
150 macro (ompt_callback_flush, ompt_callback_flush_t, 29) /* after executing flush */ \
152 macro (ompt_callback_cancel, ompt_callback_cancel_t, 30) /* cancel innermost binding region */ \
154 macro (ompt_callback_reduction, ompt_callback_sync_region_t, 31) /* reduction */ \
156 macro (ompt_callback_dispatch, ompt_callback_dispatch_t, 32) /* dispatch of work */ \
157 macro (ompt_callback_error, ompt_callback_error_t, 37) /* error */
159 #define FOREACH_OMPT_DEVICE_EVENT(macro) \
160 /*--- Mandatory Events ---*/ \
161 macro (ompt_callback_device_initialize, ompt_callback_device_initialize_t, 12) /* device initialize */ \
162 macro (ompt_callback_device_finalize, ompt_callback_device_finalize_t, 13) /* device finalize */ \
164 macro (ompt_callback_device_load, ompt_callback_device_load_t, 14) /* device load */ \
165 macro (ompt_callback_device_unload, ompt_callback_device_unload_t, 15) /* device unload */
167 #define FOREACH_OMPT_NOEMI_EVENT(macro) \
168 /*--- Mandatory Events ---*/ \
169 macro (ompt_callback_target, ompt_callback_target_t, 8) /* target */ \
170 macro (ompt_callback_target_data_op, ompt_callback_target_data_op_t, 9) /* target data op */ \
171 macro (ompt_callback_target_submit, ompt_callback_target_submit_t, 10) /* target submit */ \
172 /* Optional Events */ \
173 macro (ompt_callback_target_map, ompt_callback_target_map_t, 22) /* target map */
175 #define FOREACH_OMPT_EMI_EVENT(macro) \
176 /*--- Mandatory Events ---*/ \
177 macro (ompt_callback_target_emi, ompt_callback_target_emi_t, 33) /* target */ \
178 macro (ompt_callback_target_data_op_emi,ompt_callback_target_data_op_emi_t,34) /* target data op */ \
179 macro (ompt_callback_target_submit_emi, ompt_callback_target_submit_emi_t, 35) /* target submit */ \
180 /* Optional Events */ \
181 macro (ompt_callback_target_map_emi, ompt_callback_target_map_emi_t, 36) /* target map */
183 #define FOREACH_OMPT_50_TARGET_EVENT(macro) \
184 FOREACH_OMPT_DEVICE_EVENT(macro) \
185 FOREACH_OMPT_NOEMI_EVENT(macro)
187 #define FOREACH_OMPT_51_TARGET_EVENT(macro) \
188 FOREACH_OMPT_DEVICE_EVENT(macro) \
189 FOREACH_OMPT_EMI_EVENT(macro)
191 #define FOREACH_OMPT_EVENT(macro) \
192 FOREACH_OMPT_HOST_EVENT(macro) \
193 FOREACH_OMPT_DEVICE_EVENT(macro) \
194 FOREACH_OMPT_NOEMI_EVENT(macro) \
195 FOREACH_OMPT_EMI_EVENT(macro)
197 #define FOREACH_OMPT_51_EVENT(macro) \
198 FOREACH_OMPT_HOST_EVENT(macro) \
199 FOREACH_OMPT_DEVICE_EVENT(macro) \
200 FOREACH_OMPT_EMI_EVENT(macro)
202 /*****************************************************************************
203 * implementation specific types
204 *****************************************************************************/
206 typedef enum kmp_mutex_impl_t {
207 #define kmp_mutex_impl_macro(impl, code) impl = code,
208 FOREACH_KMP_MUTEX_IMPL(kmp_mutex_impl_macro)
209 #undef kmp_mutex_impl_macro
212 /*****************************************************************************
213 * definitions generated from spec
214 *****************************************************************************/
216 #if defined(__cplusplus)
220 typedef enum ompt_callbacks_t {
221 ompt_callback_thread_begin = 1,
222 ompt_callback_thread_end = 2,
223 ompt_callback_parallel_begin = 3,
224 ompt_callback_parallel_end = 4,
225 ompt_callback_task_create = 5,
226 ompt_callback_task_schedule = 6,
227 ompt_callback_implicit_task = 7,
228 ompt_callback_target = 8,
229 ompt_callback_target_data_op = 9,
230 ompt_callback_target_submit = 10,
231 ompt_callback_control_tool = 11,
232 ompt_callback_device_initialize = 12,
233 ompt_callback_device_finalize = 13,
234 ompt_callback_device_load = 14,
235 ompt_callback_device_unload = 15,
236 ompt_callback_sync_region_wait = 16,
237 ompt_callback_mutex_released = 17,
238 ompt_callback_dependences = 18,
239 ompt_callback_task_dependence = 19,
240 ompt_callback_work = 20,
241 ompt_callback_master DEPRECATED_51 = 21,
242 ompt_callback_masked = 21,
243 ompt_callback_target_map = 22,
244 ompt_callback_sync_region = 23,
245 ompt_callback_lock_init = 24,
246 ompt_callback_lock_destroy = 25,
247 ompt_callback_mutex_acquire = 26,
248 ompt_callback_mutex_acquired = 27,
249 ompt_callback_nest_lock = 28,
250 ompt_callback_flush = 29,
251 ompt_callback_cancel = 30,
252 ompt_callback_reduction = 31,
253 ompt_callback_dispatch = 32,
254 ompt_callback_target_emi = 33,
255 ompt_callback_target_data_op_emi = 34,
256 ompt_callback_target_submit_emi = 35,
257 ompt_callback_target_map_emi = 36,
258 ompt_callback_error = 37
261 typedef enum ompt_record_t {
262 ompt_record_ompt = 1,
263 ompt_record_native = 2,
264 ompt_record_invalid = 3
267 typedef enum ompt_record_native_t {
268 ompt_record_native_info = 1,
269 ompt_record_native_event = 2
270 } ompt_record_native_t;
272 typedef enum ompt_set_result_t {
275 ompt_set_impossible = 2,
276 ompt_set_sometimes = 3,
277 ompt_set_sometimes_paired = 4,
281 typedef uint64_t ompt_id_t;
283 typedef uint64_t ompt_device_time_t;
285 typedef uint64_t ompt_buffer_cursor_t;
287 typedef enum ompt_thread_t {
288 ompt_thread_initial = 1,
289 ompt_thread_worker = 2,
290 ompt_thread_other = 3,
291 ompt_thread_unknown = 4
294 typedef enum ompt_scope_endpoint_t {
295 ompt_scope_begin = 1,
297 ompt_scope_beginend = 3
298 } ompt_scope_endpoint_t;
300 typedef enum ompt_dispatch_t {
301 ompt_dispatch_iteration = 1,
302 ompt_dispatch_section = 2,
303 ompt_dispatch_ws_loop_chunk = 3,
304 ompt_dispatch_taskloop_chunk = 4,
305 ompt_dispatch_distribute_chunk = 5
308 typedef enum ompt_sync_region_t {
309 ompt_sync_region_barrier DEPRECATED_51 = 1,
310 ompt_sync_region_barrier_implicit DEPRECATED_51 = 2,
311 ompt_sync_region_barrier_explicit = 3,
312 ompt_sync_region_barrier_implementation = 4,
313 ompt_sync_region_taskwait = 5,
314 ompt_sync_region_taskgroup = 6,
315 ompt_sync_region_reduction = 7,
316 ompt_sync_region_barrier_implicit_workshare = 8,
317 ompt_sync_region_barrier_implicit_parallel = 9,
318 ompt_sync_region_barrier_teams = 10
319 } ompt_sync_region_t;
321 typedef enum ompt_target_data_op_t {
322 ompt_target_data_alloc = 1,
323 ompt_target_data_transfer_to_device = 2,
324 ompt_target_data_transfer_from_device = 3,
325 ompt_target_data_delete = 4,
326 ompt_target_data_associate = 5,
327 ompt_target_data_disassociate = 6,
328 ompt_target_data_alloc_async = 17,
329 ompt_target_data_transfer_to_device_async = 18,
330 ompt_target_data_transfer_from_device_async = 19,
331 ompt_target_data_delete_async = 20
332 } ompt_target_data_op_t;
334 typedef enum ompt_work_t {
336 ompt_work_sections = 2,
337 ompt_work_single_executor = 3,
338 ompt_work_single_other = 4,
339 ompt_work_workshare = 5,
340 ompt_work_distribute = 6,
341 ompt_work_taskloop = 7,
343 ompt_work_loop_static = 10,
344 ompt_work_loop_dynamic = 11,
345 ompt_work_loop_guided = 12,
346 ompt_work_loop_other = 13
349 typedef enum ompt_mutex_t {
351 ompt_mutex_test_lock = 2,
352 ompt_mutex_nest_lock = 3,
353 ompt_mutex_test_nest_lock = 4,
354 ompt_mutex_critical = 5,
355 ompt_mutex_atomic = 6,
356 ompt_mutex_ordered = 7
359 typedef enum ompt_native_mon_flag_t {
360 ompt_native_data_motion_explicit = 0x01,
361 ompt_native_data_motion_implicit = 0x02,
362 ompt_native_kernel_invocation = 0x04,
363 ompt_native_kernel_execution = 0x08,
364 ompt_native_driver = 0x10,
365 ompt_native_runtime = 0x20,
366 ompt_native_overhead = 0x40,
367 ompt_native_idleness = 0x80
368 } ompt_native_mon_flag_t;
370 typedef enum ompt_task_flag_t {
371 ompt_task_initial = 0x00000001,
372 ompt_task_implicit = 0x00000002,
373 ompt_task_explicit = 0x00000004,
374 ompt_task_target = 0x00000008,
375 ompt_task_taskwait = 0x00000010,
376 ompt_task_undeferred = 0x08000000,
377 ompt_task_untied = 0x10000000,
378 ompt_task_final = 0x20000000,
379 ompt_task_mergeable = 0x40000000,
380 ompt_task_merged = 0x80000000
383 typedef enum ompt_task_status_t {
384 ompt_task_complete = 1,
386 ompt_task_cancel = 3,
387 ompt_task_detach = 4,
388 ompt_task_early_fulfill = 5,
389 ompt_task_late_fulfill = 6,
390 ompt_task_switch = 7,
391 ompt_taskwait_complete = 8
392 } ompt_task_status_t;
394 typedef enum ompt_target_t {
396 ompt_target_enter_data = 2,
397 ompt_target_exit_data = 3,
398 ompt_target_update = 4,
399 ompt_target_nowait = 9,
400 ompt_target_enter_data_nowait = 10,
401 ompt_target_exit_data_nowait = 11,
402 ompt_target_update_nowait = 12
405 typedef enum ompt_parallel_flag_t {
406 ompt_parallel_invoker_program = 0x00000001,
407 ompt_parallel_invoker_runtime = 0x00000002,
408 ompt_parallel_league = 0x40000000,
409 ompt_parallel_team = 0x80000000
410 } ompt_parallel_flag_t;
412 typedef enum ompt_target_map_flag_t {
413 ompt_target_map_flag_to = 0x01,
414 ompt_target_map_flag_from = 0x02,
415 ompt_target_map_flag_alloc = 0x04,
416 ompt_target_map_flag_release = 0x08,
417 ompt_target_map_flag_delete = 0x10,
418 ompt_target_map_flag_implicit = 0x20
419 } ompt_target_map_flag_t;
421 typedef enum ompt_dependence_type_t {
422 ompt_dependence_type_in = 1,
423 ompt_dependence_type_out = 2,
424 ompt_dependence_type_inout = 3,
425 ompt_dependence_type_mutexinoutset = 4,
426 ompt_dependence_type_source = 5,
427 ompt_dependence_type_sink = 6,
428 ompt_dependence_type_inoutset = 7,
429 ompt_dependence_type_out_all_memory = 34,
430 ompt_dependence_type_inout_all_memory = 35
431 } ompt_dependence_type_t;
433 typedef enum ompt_severity_t {
438 typedef enum ompt_cancel_flag_t {
439 ompt_cancel_parallel = 0x01,
440 ompt_cancel_sections = 0x02,
441 ompt_cancel_loop = 0x04,
442 ompt_cancel_taskgroup = 0x08,
443 ompt_cancel_activated = 0x10,
444 ompt_cancel_detected = 0x20,
445 ompt_cancel_discarded_task = 0x40
446 } ompt_cancel_flag_t;
448 typedef uint64_t ompt_hwid_t;
450 typedef uint64_t ompt_wait_id_t;
452 typedef enum ompt_frame_flag_t {
453 ompt_frame_runtime = 0x00,
454 ompt_frame_application = 0x01,
455 ompt_frame_cfa = 0x10,
456 ompt_frame_framepointer = 0x20,
457 ompt_frame_stackaddress = 0x30
460 typedef enum ompt_state_t {
461 ompt_state_work_serial = 0x000,
462 ompt_state_work_parallel = 0x001,
463 ompt_state_work_reduction = 0x002,
465 ompt_state_wait_barrier DEPRECATED_51 = 0x010,
466 ompt_state_wait_barrier_implicit_parallel = 0x011,
467 ompt_state_wait_barrier_implicit_workshare = 0x012,
468 ompt_state_wait_barrier_implicit DEPRECATED_51 = 0x013,
469 ompt_state_wait_barrier_explicit = 0x014,
470 ompt_state_wait_barrier_implementation = 0x015,
471 ompt_state_wait_barrier_teams = 0x016,
473 ompt_state_wait_taskwait = 0x020,
474 ompt_state_wait_taskgroup = 0x021,
476 ompt_state_wait_mutex = 0x040,
477 ompt_state_wait_lock = 0x041,
478 ompt_state_wait_critical = 0x042,
479 ompt_state_wait_atomic = 0x043,
480 ompt_state_wait_ordered = 0x044,
482 ompt_state_wait_target = 0x080,
483 ompt_state_wait_target_map = 0x081,
484 ompt_state_wait_target_update = 0x082,
486 ompt_state_idle = 0x100,
487 ompt_state_overhead = 0x101,
488 ompt_state_undefined = 0x102
491 typedef uint64_t (*ompt_get_unique_id_t) (void);
493 typedef uint64_t ompd_size_t;
495 typedef uint64_t ompd_wait_id_t;
497 typedef uint64_t ompd_addr_t;
498 typedef int64_t ompd_word_t;
499 typedef uint64_t ompd_seg_t;
501 typedef uint64_t ompd_device_t;
503 typedef uint64_t ompd_thread_id_t;
505 typedef enum ompd_scope_t {
506 ompd_scope_global = 1,
507 ompd_scope_address_space = 2,
508 ompd_scope_thread = 3,
509 ompd_scope_parallel = 4,
510 ompd_scope_implicit_task = 5,
514 typedef uint64_t ompd_icv_id_t;
516 typedef enum ompd_rc_t {
518 ompd_rc_unavailable = 1,
519 ompd_rc_stale_handle = 2,
520 ompd_rc_bad_input = 3,
522 ompd_rc_unsupported = 5,
523 ompd_rc_needs_state_tracking = 6,
524 ompd_rc_incompatible = 7,
525 ompd_rc_device_read_error = 8,
526 ompd_rc_device_write_error = 9,
528 ompd_rc_incomplete = 11,
529 ompd_rc_callback_error = 12
532 typedef void (*ompt_interface_fn_t) (void);
534 typedef ompt_interface_fn_t (*ompt_function_lookup_t) (
535 const char *interface_function_name
538 typedef union ompt_data_t {
543 typedef struct ompt_frame_t {
544 ompt_data_t exit_frame;
545 ompt_data_t enter_frame;
546 int exit_frame_flags;
547 int enter_frame_flags;
550 typedef void (*ompt_callback_t) (void);
552 typedef void ompt_device_t;
554 typedef void ompt_buffer_t;
556 typedef void (*ompt_callback_buffer_request_t) (
558 ompt_buffer_t **buffer,
562 typedef void (*ompt_callback_buffer_complete_t) (
564 ompt_buffer_t *buffer,
566 ompt_buffer_cursor_t begin,
570 typedef void (*ompt_finalize_t) (
571 ompt_data_t *tool_data
574 typedef int (*ompt_initialize_t) (
575 ompt_function_lookup_t lookup,
576 int initial_device_num,
577 ompt_data_t *tool_data
580 typedef struct ompt_start_tool_result_t {
581 ompt_initialize_t initialize;
582 ompt_finalize_t finalize;
583 ompt_data_t tool_data;
584 } ompt_start_tool_result_t;
586 typedef struct ompt_record_abstract_t {
587 ompt_record_native_t rclass;
589 ompt_device_time_t start_time;
590 ompt_device_time_t end_time;
592 } ompt_record_abstract_t;
594 typedef struct ompt_dependence_t {
595 ompt_data_t variable;
596 ompt_dependence_type_t dependence_type;
599 typedef struct ompt_dispatch_chunk_t {
602 } ompt_dispatch_chunk_t;
604 typedef int (*ompt_enumerate_states_t) (
607 const char **next_state_name
610 typedef int (*ompt_enumerate_mutex_impls_t) (
613 const char **next_impl_name
616 typedef ompt_set_result_t (*ompt_set_callback_t) (
617 ompt_callbacks_t event,
618 ompt_callback_t callback
621 typedef int (*ompt_get_callback_t) (
622 ompt_callbacks_t event,
623 ompt_callback_t *callback
626 typedef ompt_data_t *(*ompt_get_thread_data_t) (void);
628 typedef int (*ompt_get_num_procs_t) (void);
630 typedef int (*ompt_get_num_places_t) (void);
632 typedef int (*ompt_get_place_proc_ids_t) (
638 typedef int (*ompt_get_place_num_t) (void);
640 typedef int (*ompt_get_partition_place_nums_t) (
645 typedef int (*ompt_get_proc_id_t) (void);
647 typedef int (*ompt_get_state_t) (
648 ompt_wait_id_t *wait_id
651 typedef int (*ompt_get_parallel_info_t) (
653 ompt_data_t **parallel_data,
657 typedef int (*ompt_get_task_info_t) (
660 ompt_data_t **task_data,
661 ompt_frame_t **task_frame,
662 ompt_data_t **parallel_data,
666 typedef int (*ompt_get_task_memory_t)(
672 typedef int (*ompt_get_target_info_t) (
673 uint64_t *device_num,
674 ompt_id_t *target_id,
675 ompt_id_t *host_op_id
678 typedef int (*ompt_get_num_devices_t) (void);
680 typedef void (*ompt_finalize_tool_t) (void);
682 typedef int (*ompt_get_device_num_procs_t) (
683 ompt_device_t *device
686 typedef ompt_device_time_t (*ompt_get_device_time_t) (
687 ompt_device_t *device
690 typedef double (*ompt_translate_time_t) (
691 ompt_device_t *device,
692 ompt_device_time_t time
695 typedef ompt_set_result_t (*ompt_set_trace_ompt_t) (
696 ompt_device_t *device,
701 typedef ompt_set_result_t (*ompt_set_trace_native_t) (
702 ompt_device_t *device,
707 typedef int (*ompt_start_trace_t) (
708 ompt_device_t *device,
709 ompt_callback_buffer_request_t request,
710 ompt_callback_buffer_complete_t complete
713 typedef int (*ompt_pause_trace_t) (
714 ompt_device_t *device,
718 typedef int (*ompt_flush_trace_t) (
719 ompt_device_t *device
722 typedef int (*ompt_stop_trace_t) (
723 ompt_device_t *device
726 typedef int (*ompt_advance_buffer_cursor_t) (
727 ompt_device_t *device,
728 ompt_buffer_t *buffer,
730 ompt_buffer_cursor_t current,
731 ompt_buffer_cursor_t *next
734 typedef ompt_record_t (*ompt_get_record_type_t) (
735 ompt_buffer_t *buffer,
736 ompt_buffer_cursor_t current
739 typedef void *(*ompt_get_record_native_t) (
740 ompt_buffer_t *buffer,
741 ompt_buffer_cursor_t current,
742 ompt_id_t *host_op_id
745 typedef ompt_record_abstract_t *
746 (*ompt_get_record_abstract_t) (
750 typedef void (*ompt_callback_thread_begin_t) (
751 ompt_thread_t thread_type,
752 ompt_data_t *thread_data
755 typedef struct ompt_record_thread_begin_t {
756 ompt_thread_t thread_type;
757 } ompt_record_thread_begin_t;
759 typedef void (*ompt_callback_thread_end_t) (
760 ompt_data_t *thread_data
763 typedef void (*ompt_callback_parallel_begin_t) (
764 ompt_data_t *encountering_task_data,
765 const ompt_frame_t *encountering_task_frame,
766 ompt_data_t *parallel_data,
767 unsigned int requested_parallelism,
769 const void *codeptr_ra
772 typedef struct ompt_record_parallel_begin_t {
773 ompt_id_t encountering_task_id;
774 ompt_id_t parallel_id;
775 unsigned int requested_parallelism;
777 const void *codeptr_ra;
778 } ompt_record_parallel_begin_t;
780 typedef void (*ompt_callback_parallel_end_t) (
781 ompt_data_t *parallel_data,
782 ompt_data_t *encountering_task_data,
784 const void *codeptr_ra
787 typedef struct ompt_record_parallel_end_t {
788 ompt_id_t parallel_id;
789 ompt_id_t encountering_task_id;
791 const void *codeptr_ra;
792 } ompt_record_parallel_end_t;
794 typedef void (*ompt_callback_work_t) (
795 ompt_work_t work_type,
796 ompt_scope_endpoint_t endpoint,
797 ompt_data_t *parallel_data,
798 ompt_data_t *task_data,
800 const void *codeptr_ra
803 typedef struct ompt_record_work_t {
804 ompt_work_t work_type;
805 ompt_scope_endpoint_t endpoint;
806 ompt_id_t parallel_id;
809 const void *codeptr_ra;
810 } ompt_record_work_t;
812 typedef void (*ompt_callback_dispatch_t) (
813 ompt_data_t *parallel_data,
814 ompt_data_t *task_data,
815 ompt_dispatch_t kind,
819 typedef struct ompt_record_dispatch_t {
820 ompt_id_t parallel_id;
822 ompt_dispatch_t kind;
823 ompt_data_t instance;
824 } ompt_record_dispatch_t;
826 typedef void (*ompt_callback_task_create_t) (
827 ompt_data_t *encountering_task_data,
828 const ompt_frame_t *encountering_task_frame,
829 ompt_data_t *new_task_data,
832 const void *codeptr_ra
835 typedef struct ompt_record_task_create_t {
836 ompt_id_t encountering_task_id;
837 ompt_id_t new_task_id;
840 const void *codeptr_ra;
841 } ompt_record_task_create_t;
843 typedef void (*ompt_callback_dependences_t) (
844 ompt_data_t *task_data,
845 const ompt_dependence_t *deps,
849 typedef struct ompt_record_dependences_t {
851 ompt_dependence_t dep;
853 } ompt_record_dependences_t;
855 typedef void (*ompt_callback_task_dependence_t) (
856 ompt_data_t *src_task_data,
857 ompt_data_t *sink_task_data
860 typedef struct ompt_record_task_dependence_t {
861 ompt_id_t src_task_id;
862 ompt_id_t sink_task_id;
863 } ompt_record_task_dependence_t;
865 typedef void (*ompt_callback_task_schedule_t) (
866 ompt_data_t *prior_task_data,
867 ompt_task_status_t prior_task_status,
868 ompt_data_t *next_task_data
871 typedef struct ompt_record_task_schedule_t {
872 ompt_id_t prior_task_id;
873 ompt_task_status_t prior_task_status;
874 ompt_id_t next_task_id;
875 } ompt_record_task_schedule_t;
877 typedef void (*ompt_callback_implicit_task_t) (
878 ompt_scope_endpoint_t endpoint,
879 ompt_data_t *parallel_data,
880 ompt_data_t *task_data,
881 unsigned int actual_parallelism,
886 typedef struct ompt_record_implicit_task_t {
887 ompt_scope_endpoint_t endpoint;
888 ompt_id_t parallel_id;
890 unsigned int actual_parallelism;
893 } ompt_record_implicit_task_t;
895 typedef void (*ompt_callback_masked_t) (
896 ompt_scope_endpoint_t endpoint,
897 ompt_data_t *parallel_data,
898 ompt_data_t *task_data,
899 const void *codeptr_ra
902 typedef ompt_callback_masked_t ompt_callback_master_t DEPRECATED_51;
904 typedef struct ompt_record_masked_t {
905 ompt_scope_endpoint_t endpoint;
906 ompt_id_t parallel_id;
908 const void *codeptr_ra;
909 } ompt_record_masked_t;
911 typedef void (*ompt_callback_sync_region_t) (
912 ompt_sync_region_t kind,
913 ompt_scope_endpoint_t endpoint,
914 ompt_data_t *parallel_data,
915 ompt_data_t *task_data,
916 const void *codeptr_ra
919 typedef struct ompt_record_sync_region_t {
920 ompt_sync_region_t kind;
921 ompt_scope_endpoint_t endpoint;
922 ompt_id_t parallel_id;
924 const void *codeptr_ra;
925 } ompt_record_sync_region_t;
927 typedef void (*ompt_callback_mutex_acquire_t) (
931 ompt_wait_id_t wait_id,
932 const void *codeptr_ra
935 typedef struct ompt_record_mutex_acquire_t {
939 ompt_wait_id_t wait_id;
940 const void *codeptr_ra;
941 } ompt_record_mutex_acquire_t;
943 typedef void (*ompt_callback_mutex_t) (
945 ompt_wait_id_t wait_id,
946 const void *codeptr_ra
949 typedef struct ompt_record_mutex_t {
951 ompt_wait_id_t wait_id;
952 const void *codeptr_ra;
953 } ompt_record_mutex_t;
955 typedef void (*ompt_callback_nest_lock_t) (
956 ompt_scope_endpoint_t endpoint,
957 ompt_wait_id_t wait_id,
958 const void *codeptr_ra
961 typedef struct ompt_record_nest_lock_t {
962 ompt_scope_endpoint_t endpoint;
963 ompt_wait_id_t wait_id;
964 const void *codeptr_ra;
965 } ompt_record_nest_lock_t;
967 typedef void (*ompt_callback_flush_t) (
968 ompt_data_t *thread_data,
969 const void *codeptr_ra
972 typedef struct ompt_record_flush_t {
973 const void *codeptr_ra;
974 } ompt_record_flush_t;
976 typedef void (*ompt_callback_cancel_t) (
977 ompt_data_t *task_data,
979 const void *codeptr_ra
982 typedef struct ompt_record_cancel_t {
985 const void *codeptr_ra;
986 } ompt_record_cancel_t;
988 typedef void (*ompt_callback_device_initialize_t) (
991 ompt_device_t *device,
992 ompt_function_lookup_t lookup,
993 const char *documentation
996 typedef void (*ompt_callback_device_finalize_t) (
1000 typedef void (*ompt_callback_device_load_t) (
1002 const char *filename,
1003 int64_t offset_in_file,
1011 typedef void (*ompt_callback_device_unload_t) (
1016 typedef void (*ompt_callback_target_data_op_emi_t) (
1017 ompt_scope_endpoint_t endpoint,
1018 ompt_data_t *target_task_data,
1019 ompt_data_t *target_data,
1020 ompt_id_t *host_op_id,
1021 ompt_target_data_op_t optype,
1025 int dest_device_num,
1027 const void *codeptr_ra
1030 typedef void (*ompt_callback_target_data_op_t) (
1031 ompt_id_t target_id,
1032 ompt_id_t host_op_id,
1033 ompt_target_data_op_t optype,
1037 int dest_device_num,
1039 const void *codeptr_ra
1042 typedef struct ompt_record_target_data_op_t {
1043 ompt_id_t host_op_id;
1044 ompt_target_data_op_t optype;
1048 int dest_device_num;
1050 ompt_device_time_t end_time;
1051 const void *codeptr_ra;
1052 } ompt_record_target_data_op_t;
1054 typedef void (*ompt_callback_target_emi_t) (
1056 ompt_scope_endpoint_t endpoint,
1058 ompt_data_t *task_data,
1059 ompt_data_t *target_task_data,
1060 ompt_data_t *target_data,
1061 const void *codeptr_ra
1064 typedef void (*ompt_callback_target_t) (
1066 ompt_scope_endpoint_t endpoint,
1068 ompt_data_t *task_data,
1069 ompt_id_t target_id,
1070 const void *codeptr_ra
1073 typedef struct ompt_record_target_t {
1075 ompt_scope_endpoint_t endpoint;
1078 ompt_id_t target_id;
1079 const void *codeptr_ra;
1080 } ompt_record_target_t;
1082 typedef void (*ompt_callback_target_map_emi_t) (
1083 ompt_data_t *target_data,
1084 unsigned int nitems,
1088 unsigned int *mapping_flags,
1089 const void *codeptr_ra
1092 typedef void (*ompt_callback_target_map_t) (
1093 ompt_id_t target_id,
1094 unsigned int nitems,
1098 unsigned int *mapping_flags,
1099 const void *codeptr_ra
1102 typedef struct ompt_record_target_map_t {
1103 ompt_id_t target_id;
1104 unsigned int nitems;
1108 unsigned int *mapping_flags;
1109 const void *codeptr_ra;
1110 } ompt_record_target_map_t;
1112 typedef void (*ompt_callback_target_submit_emi_t) (
1113 ompt_scope_endpoint_t endpoint,
1114 ompt_data_t *target_data,
1115 ompt_id_t *host_op_id,
1116 unsigned int requested_num_teams
1119 typedef void (*ompt_callback_target_submit_t) (
1120 ompt_id_t target_id,
1121 ompt_id_t host_op_id,
1122 unsigned int requested_num_teams
1125 typedef struct ompt_record_target_kernel_t {
1126 ompt_id_t host_op_id;
1127 unsigned int requested_num_teams;
1128 unsigned int granted_num_teams;
1129 ompt_device_time_t end_time;
1130 } ompt_record_target_kernel_t;
1132 typedef int (*ompt_callback_control_tool_t) (
1136 const void *codeptr_ra
1139 typedef struct ompt_record_control_tool_t {
1142 const void *codeptr_ra;
1143 } ompt_record_control_tool_t;
1145 typedef void (*ompt_callback_error_t) (
1146 ompt_severity_t severity,
1147 const char *message, size_t length,
1148 const void *codeptr_ra
1151 typedef struct ompt_record_error_t {
1152 ompt_severity_t severity;
1153 const char *message;
1155 const void *codeptr_ra;
1156 } ompt_record_error_t;
1158 typedef struct ompd_address_t {
1160 ompd_addr_t address;
1163 typedef struct ompd_frame_info_t {
1164 ompd_address_t frame_address;
1165 ompd_word_t frame_flag;
1166 } ompd_frame_info_t;
1168 typedef struct _ompd_aspace_handle ompd_address_space_handle_t;
1169 typedef struct _ompd_thread_handle ompd_thread_handle_t;
1170 typedef struct _ompd_parallel_handle ompd_parallel_handle_t;
1171 typedef struct _ompd_task_handle ompd_task_handle_t;
1173 typedef struct _ompd_aspace_cont ompd_address_space_context_t;
1174 typedef struct _ompd_thread_cont ompd_thread_context_t;
1176 typedef struct ompd_device_type_sizes_t {
1177 uint8_t sizeof_char;
1178 uint8_t sizeof_short;
1180 uint8_t sizeof_long;
1181 uint8_t sizeof_long_long;
1182 uint8_t sizeof_pointer;
1183 } ompd_device_type_sizes_t;
1185 void ompd_dll_locations_valid(void);
1187 typedef ompd_rc_t (*ompd_callback_memory_alloc_fn_t)(ompd_size_t nbytes,
1190 typedef ompd_rc_t (*ompd_callback_memory_free_fn_t)(void *ptr);
1192 typedef ompd_rc_t (*ompd_callback_get_thread_context_for_thread_id_fn_t)(
1193 ompd_address_space_context_t *address_space_context, ompd_thread_id_t kind,
1194 ompd_size_t sizeof_thread_id, const void *thread_id,
1195 ompd_thread_context_t **thread_context);
1197 typedef ompd_rc_t (*ompd_callback_sizeof_fn_t)(
1198 ompd_address_space_context_t *address_space_context,
1199 ompd_device_type_sizes_t *sizes);
1201 typedef ompd_rc_t (*ompd_callback_symbol_addr_fn_t)(
1202 ompd_address_space_context_t *address_space_context,
1203 ompd_thread_context_t *thread_context, const char *symbol_name,
1204 ompd_address_t *symbol_addr, const char *file_name);
1206 typedef ompd_rc_t (*ompd_callback_memory_read_fn_t)(
1207 ompd_address_space_context_t *address_space_context,
1208 ompd_thread_context_t *thread_context, const ompd_address_t *addr,
1209 ompd_size_t nbytes, void *buffer);
1211 typedef ompd_rc_t (*ompd_callback_memory_write_fn_t)(
1212 ompd_address_space_context_t *address_space_context,
1213 ompd_thread_context_t *thread_context, const ompd_address_t *addr,
1214 ompd_size_t nbytes, const void *buffer);
1216 typedef ompd_rc_t (*ompd_callback_device_host_fn_t)(
1217 ompd_address_space_context_t *address_space_context, const void *input,
1218 ompd_size_t unit_size, ompd_size_t count, void *output);
1220 typedef ompd_rc_t (*ompd_callback_print_string_fn_t)(const char *string,
1223 typedef struct ompd_callbacks_t {
1224 ompd_callback_memory_alloc_fn_t alloc_memory;
1225 ompd_callback_memory_free_fn_t free_memory;
1226 ompd_callback_print_string_fn_t print_string;
1227 ompd_callback_sizeof_fn_t sizeof_type;
1228 ompd_callback_symbol_addr_fn_t symbol_addr_lookup;
1229 ompd_callback_memory_read_fn_t read_memory;
1230 ompd_callback_memory_write_fn_t write_memory;
1231 ompd_callback_memory_read_fn_t read_string;
1232 ompd_callback_device_host_fn_t device_to_host;
1233 ompd_callback_device_host_fn_t host_to_device;
1234 ompd_callback_get_thread_context_for_thread_id_fn_t
1235 get_thread_context_for_thread_id;
1238 void ompd_bp_parallel_begin(void);
1240 void ompd_bp_parallel_end(void);
1242 void ompd_bp_task_begin(void);
1244 void ompd_bp_task_end(void);
1246 void ompd_bp_thread_begin(void);
1248 void ompd_bp_thread_end(void);
1250 void ompd_bp_device_begin(void);
1252 void ompd_bp_device_end(void);
1254 ompd_rc_t ompd_initialize(ompd_word_t api_version,
1255 const ompd_callbacks_t *callbacks);
1257 ompd_rc_t ompd_get_api_version(ompd_word_t *version);
1259 ompd_rc_t ompd_get_version_string(const char **string);
1261 ompd_rc_t ompd_finalize(void);
1263 ompd_rc_t ompd_process_initialize(ompd_address_space_context_t *context,
1264 ompd_address_space_handle_t **handle);
1266 ompd_rc_t ompd_device_initialize(ompd_address_space_handle_t *process_handle,
1267 ompd_address_space_context_t *device_context,
1268 ompd_device_t kind, ompd_size_t sizeof_id,
1270 ompd_address_space_handle_t **device_handle);
1272 ompd_rc_t ompd_rel_address_space_handle(ompd_address_space_handle_t *handle);
1274 ompd_rc_t ompd_get_omp_version(ompd_address_space_handle_t *address_space,
1275 ompd_word_t *omp_version);
1278 ompd_get_omp_version_string(ompd_address_space_handle_t *address_space,
1279 const char **string);
1281 ompd_rc_t ompd_get_thread_in_parallel(ompd_parallel_handle_t *parallel_handle,
1283 ompd_thread_handle_t **thread_handle);
1285 ompd_rc_t ompd_get_thread_handle(ompd_address_space_handle_t *handle,
1286 ompd_thread_id_t kind,
1287 ompd_size_t sizeof_thread_id,
1288 const void *thread_id,
1289 ompd_thread_handle_t **thread_handle);
1291 ompd_rc_t ompd_rel_thread_handle(ompd_thread_handle_t *thread_handle);
1293 ompd_rc_t ompd_thread_handle_compare(ompd_thread_handle_t *thread_handle_1,
1294 ompd_thread_handle_t *thread_handle_2,
1297 ompd_rc_t ompd_get_thread_id(ompd_thread_handle_t *thread_handle,
1298 ompd_thread_id_t kind,
1299 ompd_size_t sizeof_thread_id, void *thread_id);
1302 ompd_get_curr_parallel_handle(ompd_thread_handle_t *thread_handle,
1303 ompd_parallel_handle_t **parallel_handle);
1305 ompd_rc_t ompd_get_enclosing_parallel_handle(
1306 ompd_parallel_handle_t *parallel_handle,
1307 ompd_parallel_handle_t **enclosing_parallel_handle);
1310 ompd_get_task_parallel_handle(ompd_task_handle_t *task_handle,
1311 ompd_parallel_handle_t **task_parallel_handle);
1313 ompd_rc_t ompd_rel_parallel_handle(ompd_parallel_handle_t *parallel_handle);
1316 ompd_parallel_handle_compare(ompd_parallel_handle_t *parallel_handle_1,
1317 ompd_parallel_handle_t *parallel_handle_2,
1320 ompd_rc_t ompd_get_curr_task_handle(ompd_thread_handle_t *thread_handle,
1321 ompd_task_handle_t **task_handle);
1324 ompd_get_generating_task_handle(ompd_task_handle_t *task_handle,
1325 ompd_task_handle_t **generating_task_handle);
1328 ompd_get_scheduling_task_handle(ompd_task_handle_t *task_handle,
1329 ompd_task_handle_t **scheduling_task_handle);
1331 ompd_rc_t ompd_get_task_in_parallel(ompd_parallel_handle_t *parallel_handle,
1333 ompd_task_handle_t **task_handle);
1335 ompd_rc_t ompd_rel_task_handle(ompd_task_handle_t *task_handle);
1337 ompd_rc_t ompd_task_handle_compare(ompd_task_handle_t *task_handle_1,
1338 ompd_task_handle_t *task_handle_2,
1341 ompd_rc_t ompd_get_task_function(ompd_task_handle_t *task_handle,
1342 ompd_address_t *entry_point);
1344 ompd_rc_t ompd_get_task_frame(ompd_task_handle_t *task_handle,
1345 ompd_frame_info_t *exit_frame,
1346 ompd_frame_info_t *enter_frame);
1349 ompd_enumerate_states(ompd_address_space_handle_t *address_space_handle,
1350 ompd_word_t current_state, ompd_word_t *next_state,
1351 const char **next_state_name, ompd_word_t *more_enums);
1353 ompd_rc_t ompd_get_state(ompd_thread_handle_t *thread_handle,
1354 ompd_word_t *state, ompd_wait_id_t *wait_id);
1357 ompd_get_display_control_vars(ompd_address_space_handle_t *address_space_handle,
1358 const char *const **control_vars);
1360 ompd_rc_t ompd_rel_display_control_vars(const char *const **control_vars);
1362 ompd_rc_t ompd_enumerate_icvs(ompd_address_space_handle_t *handle,
1363 ompd_icv_id_t current, ompd_icv_id_t *next_id,
1364 const char **next_icv_name,
1365 ompd_scope_t *next_scope, int *more);
1367 ompd_rc_t ompd_get_icv_from_scope(void *handle, ompd_scope_t scope,
1368 ompd_icv_id_t icv_id, ompd_word_t *icv_value);
1370 ompd_rc_t ompd_get_icv_string_from_scope(void *handle, ompd_scope_t scope,
1371 ompd_icv_id_t icv_id,
1372 const char **icv_string);
1374 ompd_rc_t ompd_get_tool_data(void *handle, ompd_scope_t scope,
1375 ompd_word_t *value, ompd_address_t *ptr);
1377 typedef struct ompt_record_ompt_t {
1378 ompt_callbacks_t type;
1379 ompt_device_time_t time;
1380 ompt_id_t thread_id;
1381 ompt_id_t target_id;
1383 ompt_record_thread_begin_t thread_begin;
1384 ompt_record_parallel_begin_t parallel_begin;
1385 ompt_record_parallel_end_t parallel_end;
1386 ompt_record_work_t work;
1387 ompt_record_dispatch_t dispatch;
1388 ompt_record_task_create_t task_create;
1389 ompt_record_dependences_t dependences;
1390 ompt_record_task_dependence_t task_dependence;
1391 ompt_record_task_schedule_t task_schedule;
1392 ompt_record_implicit_task_t implicit_task;
1393 ompt_record_masked_t masked;
1394 ompt_record_sync_region_t sync_region;
1395 ompt_record_mutex_acquire_t mutex_acquire;
1396 ompt_record_mutex_t mutex;
1397 ompt_record_nest_lock_t nest_lock;
1398 ompt_record_flush_t flush;
1399 ompt_record_cancel_t cancel;
1400 ompt_record_target_t target;
1401 ompt_record_target_data_op_t target_data_op;
1402 ompt_record_target_map_t target_map;
1403 ompt_record_target_kernel_t target_kernel;
1404 ompt_record_control_tool_t control_tool;
1406 } ompt_record_ompt_t;
1408 typedef ompt_record_ompt_t *(*ompt_get_record_ompt_t) (
1409 ompt_buffer_t *buffer,
1410 ompt_buffer_cursor_t current
1414 __declspec(dllexport)
1416 __attribute__((visibility("default")))
1418 ompt_start_tool_result_t *ompt_start_tool(unsigned int omp_version,
1419 const char *runtime_version);
1421 #define ompt_id_none 0
1422 #define ompt_data_none {0}
1423 #define ompt_time_none 0
1424 #define ompt_hwid_none 0
1425 #define ompt_addr_none ~0
1426 #define ompt_mutex_impl_none 0
1427 #define ompt_wait_id_none 0
1429 #define ompd_segment_none 0
1431 #if defined(__cplusplus)
1435 #endif /* __OMPT__ */