LLVM OpenMP* Runtime Library
ompt-specific.h
1 #ifndef OMPT_SPECIFIC_H
2 #define OMPT_SPECIFIC_H
3 
4 #include "kmp.h"
5 
6 /*****************************************************************************
7  * types
8  ****************************************************************************/
9 
10 typedef kmp_info_t ompt_thread_t;
11 
12 /*****************************************************************************
13  * forward declarations
14  ****************************************************************************/
15 
16 void __ompt_team_assign_id(kmp_team_t *team, ompt_data_t ompt_pid);
17 void __ompt_thread_assign_wait_id(void *variable);
18 
19 void __ompt_lw_taskteam_init(ompt_lw_taskteam_t *lwt, ompt_thread_t *thr,
20  int gtid, ompt_data_t *ompt_pid, void *codeptr);
21 
22 void __ompt_lw_taskteam_link(ompt_lw_taskteam_t *lwt, ompt_thread_t *thr,
23  int on_heap);
24 
25 void __ompt_lw_taskteam_unlink(ompt_thread_t *thr);
26 
27 ompt_team_info_t *__ompt_get_teaminfo(int depth, int *size);
28 
29 ompt_task_info_t *__ompt_get_task_info_object(int depth);
30 
31 int __ompt_get_parallel_info_internal(int ancestor_level,
32  ompt_data_t **parallel_data,
33  int *team_size);
34 
35 int __ompt_get_task_info_internal(int ancestor_level, int *type,
36  ompt_data_t **task_data,
37  ompt_frame_t **task_frame,
38  ompt_data_t **parallel_data, int *thread_num);
39 
40 ompt_data_t *__ompt_get_thread_data_internal();
41 
42 static uint64_t __ompt_get_get_unique_id_internal();
43 
44 /*****************************************************************************
45  * macros
46  ****************************************************************************/
47 
48 #define OMPT_CUR_TASK_INFO(thr) (&(thr->th.th_current_task->ompt_task_info))
49 #define OMPT_CUR_TASK_DATA(thr) \
50  (&(thr->th.th_current_task->ompt_task_info.task_data))
51 #define OMPT_CUR_TEAM_INFO(thr) (&(thr->th.th_team->t.ompt_team_info))
52 #define OMPT_CUR_TEAM_DATA(thr) \
53  (&(thr->th.th_team->t.ompt_team_info.parallel_data))
54 
55 #define OMPT_HAVE_WEAK_ATTRIBUTE KMP_HAVE_WEAK_ATTRIBUTE
56 #define OMPT_HAVE_PSAPI KMP_HAVE_PSAPI
57 #define OMPT_STR_MATCH(haystack, needle) __kmp_str_match(haystack, 0, needle)
58 
59 inline void *__ompt_load_return_address(int gtid) {
60  kmp_info_t *thr = __kmp_threads[gtid];
61  void *return_address = thr->th.ompt_thread_info.return_address;
62  thr->th.ompt_thread_info.return_address = NULL;
63  return return_address;
64 }
65 
66 #define OMPT_STORE_RETURN_ADDRESS(gtid) \
67  if (ompt_enabled.enabled && gtid >= 0 && __kmp_threads[gtid] && \
68  !__kmp_threads[gtid]->th.ompt_thread_info.return_address) \
69  __kmp_threads[gtid]->th.ompt_thread_info.return_address = \
70  __builtin_return_address(0)
71 #define OMPT_LOAD_RETURN_ADDRESS(gtid) __ompt_load_return_address(gtid)
72 
73 //******************************************************************************
74 // inline functions
75 //******************************************************************************
76 
77 inline ompt_thread_t *ompt_get_thread_gtid(int gtid) {
78  return (gtid >= 0) ? __kmp_thread_from_gtid(gtid) : NULL;
79 }
80 
81 inline ompt_thread_t *ompt_get_thread() {
82  int gtid = __kmp_get_gtid();
83  return ompt_get_thread_gtid(gtid);
84 }
85 
86 inline void ompt_set_thread_state(ompt_thread_t *thread, omp_state_t state) {
87  thread->th.ompt_thread_info.state = state;
88 }
89 
90 inline const char *ompt_get_runtime_version() {
91  return &__kmp_version_lib_ver[KMP_VERSION_MAGIC_LEN];
92 }
93 
94 #endif