]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/openmp/runtime/src/ompt-internal.h
MFS r353563:
[FreeBSD/FreeBSD.git] / contrib / openmp / runtime / src / ompt-internal.h
1 /*
2  * ompt-internal.h - header of OMPT internal data structures
3  */
4
5 //===----------------------------------------------------------------------===//
6 //
7 //                     The LLVM Compiler Infrastructure
8 //
9 // This file is dual licensed under the MIT and the University of Illinois Open
10 // Source Licenses. See LICENSE.txt for details.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef __OMPT_INTERNAL_H__
15 #define __OMPT_INTERNAL_H__
16
17 #include "ompt-event-specific.h"
18 #include "omp-tools.h"
19
20 #define OMPT_VERSION 1
21
22 #define _OMP_EXTERN extern "C"
23
24 #define OMPT_INVOKER(x)                                                        \
25   ((x == fork_context_gnu) ? ompt_parallel_invoker_program                     \
26                            : ompt_parallel_invoker_runtime)
27
28 #define ompt_callback(e) e##_callback
29
30 typedef struct ompt_callbacks_internal_s {
31 #define ompt_event_macro(event, callback, eventid)                             \
32   callback ompt_callback(event);
33
34   FOREACH_OMPT_EVENT(ompt_event_macro)
35
36 #undef ompt_event_macro
37 } ompt_callbacks_internal_t;
38
39 typedef struct ompt_callbacks_active_s {
40   unsigned int enabled : 1;
41 #define ompt_event_macro(event, callback, eventid) unsigned int event : 1;
42
43   FOREACH_OMPT_EVENT(ompt_event_macro)
44
45 #undef ompt_event_macro
46 } ompt_callbacks_active_t;
47
48 #define TASK_TYPE_DETAILS_FORMAT(info)                                         \
49   ((info->td_flags.task_serial || info->td_flags.tasking_ser)                  \
50        ? ompt_task_undeferred                                                  \
51        : 0x0) |                                                                \
52       ((!(info->td_flags.tiedness)) ? ompt_task_untied : 0x0) |                \
53       (info->td_flags.final ? ompt_task_final : 0x0) |                         \
54       (info->td_flags.merged_if0 ? ompt_task_mergeable : 0x0)
55
56 typedef struct {
57   ompt_frame_t frame;
58   ompt_data_t task_data;
59   struct kmp_taskdata *scheduling_parent;
60   int thread_num;
61 #if OMP_40_ENABLED
62   int ndeps;
63   ompt_dependence_t *deps;
64 #endif /* OMP_40_ENABLED */
65 } ompt_task_info_t;
66
67 typedef struct {
68   ompt_data_t parallel_data;
69   void *master_return_address;
70 } ompt_team_info_t;
71
72 typedef struct ompt_lw_taskteam_s {
73   ompt_team_info_t ompt_team_info;
74   ompt_task_info_t ompt_task_info;
75   int heap;
76   struct ompt_lw_taskteam_s *parent;
77 } ompt_lw_taskteam_t;
78
79 typedef struct {
80   ompt_data_t thread_data;
81   ompt_data_t task_data; /* stored here from implicit barrier-begin until
82                             implicit-task-end */
83   void *return_address; /* stored here on entry of runtime */
84   ompt_state_t state;
85   ompt_wait_id_t wait_id;
86   int ompt_task_yielded;
87   void *idle_frame;
88 } ompt_thread_info_t;
89
90 extern ompt_callbacks_internal_t ompt_callbacks;
91
92 #if OMP_40_ENABLED && OMPT_SUPPORT && OMPT_OPTIONAL
93 #if USE_FAST_MEMORY
94 #define KMP_OMPT_DEPS_ALLOC __kmp_fast_allocate
95 #define KMP_OMPT_DEPS_FREE __kmp_fast_free
96 #else
97 #define KMP_OMPT_DEPS_ALLOC __kmp_thread_malloc
98 #define KMP_OMPT_DEPS_FREE __kmp_thread_free
99 #endif
100 #endif /* OMP_40_ENABLED && OMPT_SUPPORT && OMPT_OPTIONAL */
101
102 #ifdef __cplusplus
103 extern "C" {
104 #endif
105
106 void ompt_pre_init(void);
107 void ompt_post_init(void);
108 void ompt_fini(void);
109
110 #define OMPT_GET_RETURN_ADDRESS(level) __builtin_return_address(level)
111 #define OMPT_GET_FRAME_ADDRESS(level) __builtin_frame_address(level)
112
113 int __kmp_control_tool(uint64_t command, uint64_t modifier, void *arg);
114
115 extern ompt_callbacks_active_t ompt_enabled;
116
117 #if KMP_OS_WINDOWS
118 #define UNLIKELY(x) (x)
119 #define OMPT_NOINLINE __declspec(noinline)
120 #else
121 #define UNLIKELY(x) __builtin_expect(!!(x), 0)
122 #define OMPT_NOINLINE __attribute__((noinline))
123 #endif
124
125 #ifdef __cplusplus
126 };
127 #endif
128
129 #endif