1 #include "kmp_config.h"
5 * kmp_itt.cpp -- ITT Notify interface.
8 //===----------------------------------------------------------------------===//
10 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
11 // See https://llvm.org/LICENSE.txt for license information.
12 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
14 //===----------------------------------------------------------------------===//
19 #include "kmp_itt.inl"
24 #include "ittnotify_config.h"
25 __itt_global __kmp_ittapi_clean_global
;
26 extern __itt_global __kmp_itt__ittapi_global
;
27 kmp_int32 __kmp_barrier_domain_count
;
28 kmp_int32 __kmp_region_domain_count
;
29 __itt_domain
*__kmp_itt_barrier_domains
[KMP_MAX_FRAME_DOMAINS
];
30 __itt_domain
*__kmp_itt_region_domains
[KMP_MAX_FRAME_DOMAINS
];
31 __itt_domain
*__kmp_itt_imbalance_domains
[KMP_MAX_FRAME_DOMAINS
];
32 kmp_int32 __kmp_itt_region_team_size
[KMP_MAX_FRAME_DOMAINS
];
33 __itt_domain
*metadata_domain
= NULL
;
34 __itt_string_handle
*string_handle_imbl
= NULL
;
35 __itt_string_handle
*string_handle_loop
= NULL
;
36 __itt_string_handle
*string_handle_sngl
= NULL
;
40 #include "kmp_version.h"
42 KMP_BUILD_ASSERT(sizeof(kmp_itt_mark_t
) == sizeof(__itt_mark_type
));
44 /* Previously used warnings:
46 KMP_WARNING( IttAllNotifDisabled );
47 KMP_WARNING( IttObjNotifDisabled );
48 KMP_WARNING( IttMarkNotifDisabled );
49 KMP_WARNING( IttUnloadLibFailed, libittnotify );
52 kmp_int32 __kmp_itt_prepare_delay
= 0;
53 kmp_bootstrap_lock_t __kmp_itt_debug_lock
=
54 KMP_BOOTSTRAP_LOCK_INITIALIZER(__kmp_itt_debug_lock
);
56 #endif // USE_ITT_NOTIFY
58 void __kmp_itt_reset() {
60 __kmp_itt__ittapi_global
= __kmp_ittapi_clean_global
;
64 void __kmp_itt_initialize() {
66 // ITTNotify library is loaded and initialized at first call to any ittnotify
67 // function, so we do not need to explicitly load it any more. Just report OMP
68 // RTL version to ITTNotify.
71 // Backup a clean global state
72 __kmp_ittapi_clean_global
= __kmp_itt__ittapi_global
;
74 // Report OpenMP RTL version.
76 __itt_mark_type version
;
77 __kmp_str_buf_init(&buf
);
78 __kmp_str_buf_print(&buf
, "OMP RTL Version %d.%d.%d", __kmp_version_major
,
79 __kmp_version_minor
, __kmp_version_build
);
80 if (__itt_api_version_ptr
!= NULL
) {
81 __kmp_str_buf_print(&buf
, ":%s", __itt_api_version());
83 version
= __itt_mark_create(buf
.str
);
84 __itt_mark(version
, NULL
);
85 __kmp_str_buf_free(&buf
);
88 } // __kmp_itt_initialize
90 void __kmp_itt_destroy() {
92 __kmp_itt_fini_ittlib();
94 } // __kmp_itt_destroy
96 extern "C" void __itt_error_handler(__itt_error_code err
, va_list args
) {
99 case __itt_error_no_module
: {
100 char const *library
= va_arg(args
, char const *);
102 int sys_err
= va_arg(args
, int);
103 kmp_msg_t err_code
= KMP_SYSERRCODE(sys_err
);
104 __kmp_msg(kmp_ms_warning
, KMP_MSG(IttLoadLibFailed
, library
), err_code
,
106 if (__kmp_generate_warnings
== kmp_warnings_off
) {
107 __kmp_str_free(&err_code
.str
);
110 char const *sys_err
= va_arg(args
, char const *);
111 kmp_msg_t err_code
= KMP_SYSERRMESG(sys_err
);
112 __kmp_msg(kmp_ms_warning
, KMP_MSG(IttLoadLibFailed
, library
), err_code
,
114 if (__kmp_generate_warnings
== kmp_warnings_off
) {
115 __kmp_str_free(&err_code
.str
);
119 case __itt_error_no_symbol
: {
120 char const *library
= va_arg(args
, char const *);
121 char const *symbol
= va_arg(args
, char const *);
122 KMP_WARNING(IttLookupFailed
, symbol
, library
);
124 case __itt_error_unknown_group
: {
125 char const *var
= va_arg(args
, char const *);
126 char const *group
= va_arg(args
, char const *);
127 KMP_WARNING(IttUnknownGroup
, var
, group
);
129 case __itt_error_env_too_long
: {
130 char const *var
= va_arg(args
, char const *);
131 size_t act_len
= va_arg(args
, size_t);
132 size_t max_len
= va_arg(args
, size_t);
133 KMP_WARNING(IttEnvVarTooLong
, var
, (unsigned long)act_len
,
134 (unsigned long)max_len
);
136 case __itt_error_cant_read_env
: {
137 char const *var
= va_arg(args
, char const *);
138 int sys_err
= va_arg(args
, int);
139 kmp_msg_t err_code
= KMP_ERR(sys_err
);
140 __kmp_msg(kmp_ms_warning
, KMP_MSG(CantGetEnvVar
, var
), err_code
,
142 if (__kmp_generate_warnings
== kmp_warnings_off
) {
143 __kmp_str_free(&err_code
.str
);
146 case __itt_error_system
: {
147 char const *func
= va_arg(args
, char const *);
148 int sys_err
= va_arg(args
, int);
149 kmp_msg_t err_code
= KMP_SYSERRCODE(sys_err
);
150 __kmp_msg(kmp_ms_warning
, KMP_MSG(IttFunctionError
, func
), err_code
,
152 if (__kmp_generate_warnings
== kmp_warnings_off
) {
153 __kmp_str_free(&err_code
.str
);
156 default: { KMP_WARNING(IttUnknownError
, err
); }
158 } // __itt_error_handler
160 #endif /* USE_ITT_BUILD */