blob: 28905bb5dc4d3f1761a4d1125e91644728a19b88 [file] [log] [blame]
Joachim Protze3865c692018-04-12 17:23:26 +00001/*
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 Churbanove5f44922015-04-29 16:22:07 +000014#ifndef OMPT_SPECIFIC_H
15#define OMPT_SPECIFIC_H
16
17#include "kmp.h"
18
Jonathan Peyton95246e72015-11-05 16:54:55 +000019/*****************************************************************************
20 * types
21 ****************************************************************************/
22
Jonathan Peyton82a13bf2015-09-21 18:01:02 +000023typedef kmp_info_t ompt_thread_t;
24
Jonathan Peyton95246e72015-11-05 16:54:55 +000025/*****************************************************************************
26 * forward declarations
27 ****************************************************************************/
28
Joachim Protze82e94a52017-11-01 10:08:30 +000029void __ompt_team_assign_id(kmp_team_t *team, ompt_data_t ompt_pid);
Andrey Churbanove5f44922015-04-29 16:22:07 +000030void __ompt_thread_assign_wait_id(void *variable);
31
Jonathan Peyton82a13bf2015-09-21 18:01:02 +000032void __ompt_lw_taskteam_init(ompt_lw_taskteam_t *lwt, ompt_thread_t *thr,
Joachim Protze82e94a52017-11-01 10:08:30 +000033 int gtid, ompt_data_t *ompt_pid, void *codeptr);
Andrey Churbanove5f44922015-04-29 16:22:07 +000034
Joachim Protze82e94a52017-11-01 10:08:30 +000035void __ompt_lw_taskteam_link(ompt_lw_taskteam_t *lwt, ompt_thread_t *thr,
36 int on_heap);
Andrey Churbanove5f44922015-04-29 16:22:07 +000037
Joachim Protze82e94a52017-11-01 10:08:30 +000038void __ompt_lw_taskteam_unlink(ompt_thread_t *thr);
Andrey Churbanove5f44922015-04-29 16:22:07 +000039
40ompt_team_info_t *__ompt_get_teaminfo(int depth, int *size);
41
Joachim Protze82e94a52017-11-01 10:08:30 +000042ompt_task_info_t *__ompt_get_task_info_object(int depth);
Andrey Churbanove5f44922015-04-29 16:22:07 +000043
Joachim Protze82e94a52017-11-01 10:08:30 +000044int __ompt_get_parallel_info_internal(int ancestor_level,
45 ompt_data_t **parallel_data,
46 int *team_size);
Jonathan Peyton82a13bf2015-09-21 18:01:02 +000047
Joachim Protze82e94a52017-11-01 10:08:30 +000048int __ompt_get_task_info_internal(int ancestor_level, int *type,
49 ompt_data_t **task_data,
Joachim Protzec5836064b2018-05-28 08:14:58 +000050 omp_frame_t **task_frame,
Joachim Protze82e94a52017-11-01 10:08:30 +000051 ompt_data_t **parallel_data, int *thread_num);
Jonathan Peyton82a13bf2015-09-21 18:01:02 +000052
Joachim Protze82e94a52017-11-01 10:08:30 +000053ompt_data_t *__ompt_get_thread_data_internal();
Jonathan Peyton82a13bf2015-09-21 18:01:02 +000054
Jonathan Peytonbaad3f62018-08-09 22:04:30 +000055/*
56 * Unused currently
Joachim Protze82e94a52017-11-01 10:08:30 +000057static uint64_t __ompt_get_get_unique_id_internal();
Jonathan Peytonbaad3f62018-08-09 22:04:30 +000058*/
Jonathan Peyton82a13bf2015-09-21 18:01:02 +000059
Jonathan Peyton69e596a2015-10-29 20:56:24 +000060/*****************************************************************************
61 * macros
62 ****************************************************************************/
Jonathan Peyton95246e72015-11-05 16:54:55 +000063
Joachim Protze82e94a52017-11-01 10:08:30 +000064#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 Peyton69e596a2015-10-29 20:56:24 +000071#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 Protze82e94a52017-11-01 10:08:30 +000075inline 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 Peyton82a13bf2015-09-21 18:01:02 +000089//******************************************************************************
90// inline functions
91//******************************************************************************
92
Jonathan Peyton30419822017-05-12 18:01:32 +000093inline ompt_thread_t *ompt_get_thread_gtid(int gtid) {
94 return (gtid >= 0) ? __kmp_thread_from_gtid(gtid) : NULL;
Andrey Churbanove5f44922015-04-29 16:22:07 +000095}
96
Jonathan Peyton30419822017-05-12 18:01:32 +000097inline ompt_thread_t *ompt_get_thread() {
98 int gtid = __kmp_get_gtid();
99 return ompt_get_thread_gtid(gtid);
Andrey Churbanove5f44922015-04-29 16:22:07 +0000100}
101
Joachim Protze82e94a52017-11-01 10:08:30 +0000102inline void ompt_set_thread_state(ompt_thread_t *thread, omp_state_t state) {
Jonathan Peyton30419822017-05-12 18:01:32 +0000103 thread->th.ompt_thread_info.state = state;
Jonathan Peyton82a13bf2015-09-21 18:01:02 +0000104}
Andrey Churbanove5f44922015-04-29 16:22:07 +0000105
Jonathan Peyton30419822017-05-12 18:01:32 +0000106inline const char *ompt_get_runtime_version() {
107 return &__kmp_version_lib_ver[KMP_VERSION_MAGIC_LEN];
Jonathan Peyton82a13bf2015-09-21 18:01:02 +0000108}
Andrey Churbanove5f44922015-04-29 16:22:07 +0000109
110#endif