1 /*
2  * ompd-specific.h -- OpenMP debug support
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 #include "kmp.h"
14 #include "omp-tools.h"
15 #include <stdint.h>
16 
17 #ifndef __OMPD_SPECIFIC_H__
18 #define __OMPD_SPECIFIC_H__
19 
20 #if OMPD_SUPPORT
21 
22 void ompd_init();
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 extern char *ompd_env_block;
28 extern ompd_size_t ompd_env_block_size;
29 extern char *__kmp_tool_verbose_init;
30 #ifdef __cplusplus
31 } /* extern "C" */
32 #endif
33 
34 extern uint64_t ompd_state;
35 #define OMPD_ENABLE_BP 0x1
36 
37 #define OMPD_FOREACH_ACCESS(OMPD_ACCESS)                                       \
38   OMPD_ACCESS(kmp_base_info_t, th_current_task)                                \
39   OMPD_ACCESS(kmp_base_info_t, th_team)                                        \
40   OMPD_ACCESS(kmp_base_info_t, th_info)                                        \
41   OMPD_ACCESS(kmp_base_info_t, ompt_thread_info)                               \
42                                                                                \
43   OMPD_ACCESS(kmp_base_root_t, r_in_parallel)                                  \
44                                                                                \
45   OMPD_ACCESS(kmp_base_team_t, ompt_team_info)                                 \
46   OMPD_ACCESS(kmp_base_team_t, ompt_serialized_team_info)                      \
47   OMPD_ACCESS(kmp_base_team_t, t_active_level)                                 \
48   OMPD_ACCESS(kmp_base_team_t, t_implicit_task_taskdata)                       \
49   OMPD_ACCESS(kmp_base_team_t, t_master_tid)                                   \
50   OMPD_ACCESS(kmp_base_team_t, t_nproc)                                        \
51   OMPD_ACCESS(kmp_base_team_t, t_level)                                        \
52   OMPD_ACCESS(kmp_base_team_t, t_parent)                                       \
53   OMPD_ACCESS(kmp_base_team_t, t_pkfn)                                         \
54   OMPD_ACCESS(kmp_base_team_t, t_threads)                                      \
55                                                                                \
56   OMPD_ACCESS(kmp_desc_t, ds)                                                  \
57                                                                                \
58   OMPD_ACCESS(kmp_desc_base_t, ds_thread)                                      \
59   OMPD_ACCESS(kmp_desc_base_t, ds_tid)                                         \
60                                                                                \
61   OMPD_ACCESS(kmp_info_t, th)                                                  \
62                                                                                \
63   OMPD_ACCESS(kmp_r_sched_t, r_sched_type)                                     \
64   OMPD_ACCESS(kmp_r_sched_t, chunk)                                            \
65                                                                                \
66   OMPD_ACCESS(kmp_root_t, r)                                                   \
67                                                                                \
68   OMPD_ACCESS(kmp_internal_control_t, dynamic)                                 \
69   OMPD_ACCESS(kmp_internal_control_t, max_active_levels)                       \
70   OMPD_ACCESS(kmp_internal_control_t, nproc)                                   \
71   OMPD_ACCESS(kmp_internal_control_t, proc_bind)                               \
72   OMPD_ACCESS(kmp_internal_control_t, sched)                                   \
73   OMPD_ACCESS(kmp_internal_control_t, default_device)                          \
74   OMPD_ACCESS(kmp_internal_control_t, thread_limit)                            \
75                                                                                \
76   OMPD_ACCESS(kmp_taskdata_t, ompt_task_info)                                  \
77   OMPD_ACCESS(kmp_taskdata_t, td_flags)                                        \
78   OMPD_ACCESS(kmp_taskdata_t, td_icvs)                                         \
79   OMPD_ACCESS(kmp_taskdata_t, td_parent)                                       \
80   OMPD_ACCESS(kmp_taskdata_t, td_team)                                         \
81                                                                                \
82   OMPD_ACCESS(kmp_task_t, routine)                                             \
83                                                                                \
84   OMPD_ACCESS(kmp_team_p, t)                                                   \
85                                                                                \
86   OMPD_ACCESS(kmp_nested_nthreads_t, used)                                     \
87   OMPD_ACCESS(kmp_nested_nthreads_t, nth)                                      \
88                                                                                \
89   OMPD_ACCESS(kmp_nested_proc_bind_t, used)                                    \
90   OMPD_ACCESS(kmp_nested_proc_bind_t, bind_types)                              \
91                                                                                \
92   OMPD_ACCESS(ompt_task_info_t, frame)                                         \
93   OMPD_ACCESS(ompt_task_info_t, scheduling_parent)                             \
94   OMPD_ACCESS(ompt_task_info_t, task_data)                                     \
95                                                                                \
96   OMPD_ACCESS(ompt_team_info_t, parallel_data)                                 \
97                                                                                \
98   OMPD_ACCESS(ompt_thread_info_t, state)                                       \
99   OMPD_ACCESS(ompt_thread_info_t, wait_id)                                     \
100   OMPD_ACCESS(ompt_thread_info_t, thread_data)                                 \
101                                                                                \
102   OMPD_ACCESS(ompt_data_t, value)                                              \
103   OMPD_ACCESS(ompt_data_t, ptr)                                                \
104                                                                                \
105   OMPD_ACCESS(ompt_frame_t, exit_frame)                                        \
106   OMPD_ACCESS(ompt_frame_t, enter_frame)                                       \
107                                                                                \
108   OMPD_ACCESS(ompt_lw_taskteam_t, parent)                                      \
109   OMPD_ACCESS(ompt_lw_taskteam_t, ompt_team_info)                              \
110   OMPD_ACCESS(ompt_lw_taskteam_t, ompt_task_info)
111 
112 #define OMPD_FOREACH_BITFIELD(OMPD_BITFIELD)                                   \
113   OMPD_BITFIELD(kmp_tasking_flags_t, final)                                    \
114   OMPD_BITFIELD(kmp_tasking_flags_t, tiedness)                                 \
115   OMPD_BITFIELD(kmp_tasking_flags_t, tasktype)                                 \
116   OMPD_BITFIELD(kmp_tasking_flags_t, task_serial)                              \
117   OMPD_BITFIELD(kmp_tasking_flags_t, tasking_ser)                              \
118   OMPD_BITFIELD(kmp_tasking_flags_t, team_serial)                              \
119   OMPD_BITFIELD(kmp_tasking_flags_t, started)                                  \
120   OMPD_BITFIELD(kmp_tasking_flags_t, executing)                                \
121   OMPD_BITFIELD(kmp_tasking_flags_t, complete)                                 \
122   OMPD_BITFIELD(kmp_tasking_flags_t, freed)                                    \
123   OMPD_BITFIELD(kmp_tasking_flags_t, native)
124 
125 #define OMPD_FOREACH_SIZEOF(OMPD_SIZEOF)                                       \
126   OMPD_SIZEOF(kmp_info_t)                                                      \
127   OMPD_SIZEOF(kmp_taskdata_t)                                                  \
128   OMPD_SIZEOF(kmp_task_t)                                                      \
129   OMPD_SIZEOF(kmp_tasking_flags_t)                                             \
130   OMPD_SIZEOF(kmp_thread_t)                                                    \
131   OMPD_SIZEOF(ompt_data_t)                                                     \
132   OMPD_SIZEOF(ompt_id_t)                                                       \
133   OMPD_SIZEOF(__kmp_avail_proc)                                                \
134   OMPD_SIZEOF(__kmp_max_nth)                                                   \
135   OMPD_SIZEOF(__kmp_stksize)                                                   \
136   OMPD_SIZEOF(__kmp_omp_cancellation)                                          \
137   OMPD_SIZEOF(__kmp_max_task_priority)                                         \
138   OMPD_SIZEOF(__kmp_display_affinity)                                          \
139   OMPD_SIZEOF(__kmp_affinity_format)                                           \
140   OMPD_SIZEOF(__kmp_tool_libraries)                                            \
141   OMPD_SIZEOF(__kmp_tool_verbose_init)                                         \
142   OMPD_SIZEOF(__kmp_tool)                                                      \
143   OMPD_SIZEOF(ompd_state)                                                      \
144   OMPD_SIZEOF(kmp_nested_nthreads_t)                                           \
145   OMPD_SIZEOF(__kmp_nested_nth)                                                \
146   OMPD_SIZEOF(kmp_nested_proc_bind_t)                                          \
147   OMPD_SIZEOF(__kmp_nested_proc_bind)                                          \
148   OMPD_SIZEOF(int)                                                             \
149   OMPD_SIZEOF(char)                                                            \
150   OMPD_SIZEOF(__kmp_gtid)                                                      \
151   OMPD_SIZEOF(__kmp_nth)
152 
153 #endif /* OMPD_SUPPORT */
154 #endif
155