Joachim Protze | 3865c69 | 2018-04-12 17:23:26 +0000 | [diff] [blame] | 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 | |
Andrey Churbanov | e5f4492 | 2015-04-29 16:22:07 +0000 | [diff] [blame] | 14 | #ifndef OMPT_SPECIFIC_H |
| 15 | #define OMPT_SPECIFIC_H |
| 16 | |
| 17 | #include "kmp.h" |
| 18 | |
Jonathan Peyton | 95246e7 | 2015-11-05 16:54:55 +0000 | [diff] [blame] | 19 | /***************************************************************************** |
| 20 | * types |
| 21 | ****************************************************************************/ |
| 22 | |
Jonathan Peyton | 82a13bf | 2015-09-21 18:01:02 +0000 | [diff] [blame] | 23 | typedef kmp_info_t ompt_thread_t; |
| 24 | |
Jonathan Peyton | 95246e7 | 2015-11-05 16:54:55 +0000 | [diff] [blame] | 25 | /***************************************************************************** |
| 26 | * forward declarations |
| 27 | ****************************************************************************/ |
| 28 | |
Joachim Protze | 82e94a5 | 2017-11-01 10:08:30 +0000 | [diff] [blame] | 29 | void __ompt_team_assign_id(kmp_team_t *team, ompt_data_t ompt_pid); |
Andrey Churbanov | e5f4492 | 2015-04-29 16:22:07 +0000 | [diff] [blame] | 30 | void __ompt_thread_assign_wait_id(void *variable); |
| 31 | |
Jonathan Peyton | 82a13bf | 2015-09-21 18:01:02 +0000 | [diff] [blame] | 32 | void __ompt_lw_taskteam_init(ompt_lw_taskteam_t *lwt, ompt_thread_t *thr, |
Joachim Protze | 82e94a5 | 2017-11-01 10:08:30 +0000 | [diff] [blame] | 33 | int gtid, ompt_data_t *ompt_pid, void *codeptr); |
Andrey Churbanov | e5f4492 | 2015-04-29 16:22:07 +0000 | [diff] [blame] | 34 | |
Joachim Protze | 82e94a5 | 2017-11-01 10:08:30 +0000 | [diff] [blame] | 35 | void __ompt_lw_taskteam_link(ompt_lw_taskteam_t *lwt, ompt_thread_t *thr, |
| 36 | int on_heap); |
Andrey Churbanov | e5f4492 | 2015-04-29 16:22:07 +0000 | [diff] [blame] | 37 | |
Joachim Protze | 82e94a5 | 2017-11-01 10:08:30 +0000 | [diff] [blame] | 38 | void __ompt_lw_taskteam_unlink(ompt_thread_t *thr); |
Andrey Churbanov | e5f4492 | 2015-04-29 16:22:07 +0000 | [diff] [blame] | 39 | |
| 40 | ompt_team_info_t *__ompt_get_teaminfo(int depth, int *size); |
| 41 | |
Joachim Protze | 82e94a5 | 2017-11-01 10:08:30 +0000 | [diff] [blame] | 42 | ompt_task_info_t *__ompt_get_task_info_object(int depth); |
Andrey Churbanov | e5f4492 | 2015-04-29 16:22:07 +0000 | [diff] [blame] | 43 | |
Joachim Protze | 82e94a5 | 2017-11-01 10:08:30 +0000 | [diff] [blame] | 44 | int __ompt_get_parallel_info_internal(int ancestor_level, |
| 45 | ompt_data_t **parallel_data, |
| 46 | int *team_size); |
Jonathan Peyton | 82a13bf | 2015-09-21 18:01:02 +0000 | [diff] [blame] | 47 | |
Joachim Protze | 82e94a5 | 2017-11-01 10:08:30 +0000 | [diff] [blame] | 48 | int __ompt_get_task_info_internal(int ancestor_level, int *type, |
| 49 | ompt_data_t **task_data, |
Joachim Protze | c5836064b | 2018-05-28 08:14:58 +0000 | [diff] [blame] | 50 | omp_frame_t **task_frame, |
Joachim Protze | 82e94a5 | 2017-11-01 10:08:30 +0000 | [diff] [blame] | 51 | ompt_data_t **parallel_data, int *thread_num); |
Jonathan Peyton | 82a13bf | 2015-09-21 18:01:02 +0000 | [diff] [blame] | 52 | |
Joachim Protze | 82e94a5 | 2017-11-01 10:08:30 +0000 | [diff] [blame] | 53 | ompt_data_t *__ompt_get_thread_data_internal(); |
Jonathan Peyton | 82a13bf | 2015-09-21 18:01:02 +0000 | [diff] [blame] | 54 | |
Jonathan Peyton | baad3f6 | 2018-08-09 22:04:30 +0000 | [diff] [blame] | 55 | /* |
| 56 | * Unused currently |
Joachim Protze | 82e94a5 | 2017-11-01 10:08:30 +0000 | [diff] [blame] | 57 | static uint64_t __ompt_get_get_unique_id_internal(); |
Jonathan Peyton | baad3f6 | 2018-08-09 22:04:30 +0000 | [diff] [blame] | 58 | */ |
Jonathan Peyton | 82a13bf | 2015-09-21 18:01:02 +0000 | [diff] [blame] | 59 | |
Jonathan Peyton | 69e596a | 2015-10-29 20:56:24 +0000 | [diff] [blame] | 60 | /***************************************************************************** |
| 61 | * macros |
| 62 | ****************************************************************************/ |
Jonathan Peyton | 95246e7 | 2015-11-05 16:54:55 +0000 | [diff] [blame] | 63 | |
Joachim Protze | 82e94a5 | 2017-11-01 10:08:30 +0000 | [diff] [blame] | 64 | #define OMPT_CUR_TASK_INFO(thr) (&(thr->th.th_current_task->ompt_task_info)) |
| 65 | #define OMPT_CUR_TASK_DATA(thr) \ |
| 66 | (&(thr->th.th_current_task->ompt_task_info.task_data)) |
| 67 | #define OMPT_CUR_TEAM_INFO(thr) (&(thr->th.th_team->t.ompt_team_info)) |
| 68 | #define OMPT_CUR_TEAM_DATA(thr) \ |
| 69 | (&(thr->th.th_team->t.ompt_team_info.parallel_data)) |
| 70 | |
Jonathan Peyton | 69e596a | 2015-10-29 20:56:24 +0000 | [diff] [blame] | 71 | #define OMPT_HAVE_WEAK_ATTRIBUTE KMP_HAVE_WEAK_ATTRIBUTE |
| 72 | #define OMPT_HAVE_PSAPI KMP_HAVE_PSAPI |
| 73 | #define OMPT_STR_MATCH(haystack, needle) __kmp_str_match(haystack, 0, needle) |
| 74 | |
Joachim Protze | 82e94a5 | 2017-11-01 10:08:30 +0000 | [diff] [blame] | 75 | inline void *__ompt_load_return_address(int gtid) { |
| 76 | kmp_info_t *thr = __kmp_threads[gtid]; |
| 77 | void *return_address = thr->th.ompt_thread_info.return_address; |
| 78 | thr->th.ompt_thread_info.return_address = NULL; |
| 79 | return return_address; |
| 80 | } |
| 81 | |
| 82 | #define OMPT_STORE_RETURN_ADDRESS(gtid) \ |
| 83 | if (ompt_enabled.enabled && gtid >= 0 && __kmp_threads[gtid] && \ |
| 84 | !__kmp_threads[gtid]->th.ompt_thread_info.return_address) \ |
| 85 | __kmp_threads[gtid]->th.ompt_thread_info.return_address = \ |
| 86 | __builtin_return_address(0) |
| 87 | #define OMPT_LOAD_RETURN_ADDRESS(gtid) __ompt_load_return_address(gtid) |
| 88 | |
Jonathan Peyton | 82a13bf | 2015-09-21 18:01:02 +0000 | [diff] [blame] | 89 | //****************************************************************************** |
| 90 | // inline functions |
| 91 | //****************************************************************************** |
| 92 | |
Jonathan Peyton | 3041982 | 2017-05-12 18:01:32 +0000 | [diff] [blame] | 93 | inline ompt_thread_t *ompt_get_thread_gtid(int gtid) { |
| 94 | return (gtid >= 0) ? __kmp_thread_from_gtid(gtid) : NULL; |
Andrey Churbanov | e5f4492 | 2015-04-29 16:22:07 +0000 | [diff] [blame] | 95 | } |
| 96 | |
Jonathan Peyton | 3041982 | 2017-05-12 18:01:32 +0000 | [diff] [blame] | 97 | inline ompt_thread_t *ompt_get_thread() { |
| 98 | int gtid = __kmp_get_gtid(); |
| 99 | return ompt_get_thread_gtid(gtid); |
Andrey Churbanov | e5f4492 | 2015-04-29 16:22:07 +0000 | [diff] [blame] | 100 | } |
| 101 | |
Joachim Protze | 82e94a5 | 2017-11-01 10:08:30 +0000 | [diff] [blame] | 102 | inline void ompt_set_thread_state(ompt_thread_t *thread, omp_state_t state) { |
Jonathan Peyton | 3041982 | 2017-05-12 18:01:32 +0000 | [diff] [blame] | 103 | thread->th.ompt_thread_info.state = state; |
Jonathan Peyton | 82a13bf | 2015-09-21 18:01:02 +0000 | [diff] [blame] | 104 | } |
Andrey Churbanov | e5f4492 | 2015-04-29 16:22:07 +0000 | [diff] [blame] | 105 | |
Jonathan Peyton | 3041982 | 2017-05-12 18:01:32 +0000 | [diff] [blame] | 106 | inline const char *ompt_get_runtime_version() { |
| 107 | return &__kmp_version_lib_ver[KMP_VERSION_MAGIC_LEN]; |
Jonathan Peyton | 82a13bf | 2015-09-21 18:01:02 +0000 | [diff] [blame] | 108 | } |
Andrey Churbanov | e5f4492 | 2015-04-29 16:22:07 +0000 | [diff] [blame] | 109 | |
| 110 | #endif |