LLVM OpenMP* Runtime Library
ompt-internal.h
1 #ifndef __OMPT_INTERNAL_H__
2 #define __OMPT_INTERNAL_H__
3 
4 #include "ompt-event-specific.h"
5 #include "ompt.h"
6 
7 #define OMPT_VERSION 1
8 
9 #define _OMP_EXTERN extern "C"
10 
11 #define OMPT_INVOKER(x) \
12  ((x == fork_context_gnu) ? ompt_invoker_program : ompt_invoker_runtime)
13 
14 #define ompt_callback(e) e##_callback
15 
16 typedef struct ompt_callbacks_internal_s {
17 #define ompt_event_macro(event, callback, eventid) \
18  callback ompt_callback(event);
19 
20  FOREACH_OMPT_EVENT(ompt_event_macro)
21 
22 #undef ompt_event_macro
23 } ompt_callbacks_internal_t;
24 
25 typedef 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)
41 
42 typedef struct {
43  ompt_frame_t frame;
44  ompt_data_t task_data;
45  struct kmp_taskdata *scheduling_parent;
46 #if OMP_40_ENABLED
47  int ndeps;
48  ompt_task_dependence_t *deps;
49 #endif /* OMP_40_ENABLED */
50 } ompt_task_info_t;
51 
52 typedef struct {
53  ompt_data_t parallel_data;
54  void *master_return_address;
55 } ompt_team_info_t;
56 
57 typedef struct ompt_lw_taskteam_s {
58  ompt_team_info_t ompt_team_info;
59  ompt_task_info_t ompt_task_info;
60  int heap;
61  struct ompt_lw_taskteam_s *parent;
62 } ompt_lw_taskteam_t;
63 
64 typedef struct {
65  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;
70  ompt_wait_id_t wait_id;
71  int ompt_task_yielded;
72  void *idle_frame;
73 } ompt_thread_info_t;
74 
75 extern ompt_callbacks_internal_t ompt_callbacks;
76 
77 #if OMP_40_ENABLED && OMPT_SUPPORT && OMPT_OPTIONAL
78 #if USE_FAST_MEMORY
79 #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
85 #endif /* OMP_40_ENABLED && OMPT_SUPPORT && OMPT_OPTIONAL */
86 
87 #ifdef __cplusplus
88 extern "C" {
89 #endif
90 
91 void ompt_pre_init(void);
92 void ompt_post_init(void);
93 void ompt_fini(void);
94 
95 #define OMPT_GET_RETURN_ADDRESS(level) __builtin_return_address(level)
96 #define OMPT_GET_FRAME_ADDRESS(level) __builtin_frame_address(level)
97 
98 int __kmp_control_tool(uint64_t command, uint64_t modifier, void *arg);
99 
100 extern 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
109 
110 #ifdef __cplusplus
111 };
112 #endif
113 
114 #endif