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