blob: 6139e002f79349b2ca7c42a5f0c894f2707be23e [file] [log] [blame]
Andrey Churbanove5f44922015-04-29 16:22:07 +00001#ifndef __OMPT_INTERNAL_H__
2#define __OMPT_INTERNAL_H__
3
Andrey Churbanove5f44922015-04-29 16:22:07 +00004#include "ompt-event-specific.h"
Jonathan Peyton30419822017-05-12 18:01:32 +00005#include "ompt.h"
Andrey Churbanove5f44922015-04-29 16:22:07 +00006
7#define OMPT_VERSION 1
8
9#define _OMP_EXTERN extern "C"
10
Jonathan Peyton30419822017-05-12 18:01:32 +000011#define OMPT_INVOKER(x) \
Jonathan Peyton3fdf3292015-07-21 18:03:30 +000012 ((x == fork_context_gnu) ? ompt_invoker_program : ompt_invoker_runtime)
Andrey Churbanove5f44922015-04-29 16:22:07 +000013
Jonathan Peyton30419822017-05-12 18:01:32 +000014#define ompt_callback(e) e##_callback
Andrey Churbanove5f44922015-04-29 16:22:07 +000015
Joachim Protze82e94a52017-11-01 10:08:30 +000016typedef struct ompt_callbacks_internal_s {
Jonathan Peyton30419822017-05-12 18:01:32 +000017#define ompt_event_macro(event, callback, eventid) \
18 callback ompt_callback(event);
Andrey Churbanove5f44922015-04-29 16:22:07 +000019
Jonathan Peyton30419822017-05-12 18:01:32 +000020 FOREACH_OMPT_EVENT(ompt_event_macro)
Andrey Churbanove5f44922015-04-29 16:22:07 +000021
22#undef ompt_event_macro
Joachim Protze82e94a52017-11-01 10:08:30 +000023} ompt_callbacks_internal_t;
24
25typedef struct ompt_callbacks_active_s {
26 unsigned int enabled : 1;
27#define ompt_event_macro(event, callback, eventid) unsigned int event : 1;
28
29 FOREACH_OMPT_EVENT(ompt_event_macro)
30
31#undef ompt_event_macro
32} ompt_callbacks_active_t;
33
34#define TASK_TYPE_DETAILS_FORMAT(info) \
35 ((info->td_flags.task_serial || info->td_flags.tasking_ser) \
36 ? ompt_task_undeferred \
37 : 0x0) | \
38 ((!(info->td_flags.tiedness)) ? ompt_task_untied : 0x0) | \
39 (info->td_flags.final ? ompt_task_final : 0x0) | \
40 (info->td_flags.merged_if0 ? ompt_task_mergeable : 0x0)
Andrey Churbanove5f44922015-04-29 16:22:07 +000041
Andrey Churbanove5f44922015-04-29 16:22:07 +000042typedef struct {
Jonathan Peyton30419822017-05-12 18:01:32 +000043 ompt_frame_t frame;
Joachim Protze82e94a52017-11-01 10:08:30 +000044 ompt_data_t task_data;
45 struct kmp_taskdata *scheduling_parent;
Jonas Hahnfeld39b68622016-01-28 10:39:52 +000046#if OMP_40_ENABLED
Jonathan Peyton30419822017-05-12 18:01:32 +000047 int ndeps;
48 ompt_task_dependence_t *deps;
Jonas Hahnfeld39b68622016-01-28 10:39:52 +000049#endif /* OMP_40_ENABLED */
Andrey Churbanove5f44922015-04-29 16:22:07 +000050} ompt_task_info_t;
51
Andrey Churbanove5f44922015-04-29 16:22:07 +000052typedef struct {
Joachim Protze82e94a52017-11-01 10:08:30 +000053 ompt_data_t parallel_data;
54 void *master_return_address;
Andrey Churbanove5f44922015-04-29 16:22:07 +000055} ompt_team_info_t;
56
Andrey Churbanove5f44922015-04-29 16:22:07 +000057typedef struct ompt_lw_taskteam_s {
Jonathan Peyton30419822017-05-12 18:01:32 +000058 ompt_team_info_t ompt_team_info;
59 ompt_task_info_t ompt_task_info;
Joachim Protze82e94a52017-11-01 10:08:30 +000060 int heap;
Jonathan Peyton30419822017-05-12 18:01:32 +000061 struct ompt_lw_taskteam_s *parent;
Andrey Churbanove5f44922015-04-29 16:22:07 +000062} ompt_lw_taskteam_t;
63
Andrey Churbanove5f44922015-04-29 16:22:07 +000064typedef struct {
Joachim Protze82e94a52017-11-01 10:08:30 +000065 ompt_data_t thread_data;
66 ompt_data_t task_data; /* stored here from implicit barrier-begin until
67 implicit-task-end */
68 void *return_address; /* stored here on entry of runtime */
69 omp_state_t state;
Jonathan Peyton30419822017-05-12 18:01:32 +000070 ompt_wait_id_t wait_id;
Joachim Protze82e94a52017-11-01 10:08:30 +000071 int ompt_task_yielded;
Jonathan Peyton30419822017-05-12 18:01:32 +000072 void *idle_frame;
Andrey Churbanove5f44922015-04-29 16:22:07 +000073} ompt_thread_info_t;
74
Joachim Protze82e94a52017-11-01 10:08:30 +000075extern ompt_callbacks_internal_t ompt_callbacks;
Andrey Churbanove5f44922015-04-29 16:22:07 +000076
Joachim Protze82e94a52017-11-01 10:08:30 +000077#if OMP_40_ENABLED && OMPT_SUPPORT && OMPT_OPTIONAL
Jonas Hahnfeld39b68622016-01-28 10:39:52 +000078#if USE_FAST_MEMORY
Jonathan Peyton30419822017-05-12 18:01:32 +000079#define KMP_OMPT_DEPS_ALLOC __kmp_fast_allocate
80#define KMP_OMPT_DEPS_FREE __kmp_fast_free
81#else
82#define KMP_OMPT_DEPS_ALLOC __kmp_thread_malloc
83#define KMP_OMPT_DEPS_FREE __kmp_thread_free
84#endif
Joachim Protze82e94a52017-11-01 10:08:30 +000085#endif /* OMP_40_ENABLED && OMPT_SUPPORT && OMPT_OPTIONAL */
Jonas Hahnfeld39b68622016-01-28 10:39:52 +000086
Andrey Churbanove5f44922015-04-29 16:22:07 +000087#ifdef __cplusplus
88extern "C" {
89#endif
90
Jonathan Peyton82a13bf2015-09-21 18:01:02 +000091void ompt_pre_init(void);
92void ompt_post_init(void);
Andrey Churbanove5f44922015-04-29 16:22:07 +000093void ompt_fini(void);
94
Joachim Protze82e94a52017-11-01 10:08:30 +000095#define OMPT_GET_RETURN_ADDRESS(level) __builtin_return_address(level)
96#define OMPT_GET_FRAME_ADDRESS(level) __builtin_frame_address(level)
97
98int __kmp_control_tool(uint64_t command, uint64_t modifier, void *arg);
99
100extern ompt_callbacks_active_t ompt_enabled;
101
102#if KMP_OS_WINDOWS
103#define UNLIKELY(x) (x)
104#define OMPT_NOINLINE __declspec(noinline)
105#else
106#define UNLIKELY(x) __builtin_expect(!!(x), 0)
107#define OMPT_NOINLINE __attribute__((noinline))
108#endif
Jonathan Peytonb68a85d2015-09-21 18:11:22 +0000109
Andrey Churbanove5f44922015-04-29 16:22:07 +0000110#ifdef __cplusplus
111};
112#endif
113
114#endif