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
;
28 kmp_itthash_t __kmp_itt_barrier_domains
= {{0}, 0};
29 kmp_itthash_t __kmp_itt_region_domains
= {{0}, 0};
30 __itt_domain
*metadata_domain
= NULL
;
31 __itt_string_handle
*string_handle_imbl
= NULL
;
32 __itt_string_handle
*string_handle_loop
= NULL
;
33 __itt_string_handle
*string_handle_sngl
= NULL
;
37 #include "kmp_version.h"
39 KMP_BUILD_ASSERT(sizeof(kmp_itt_mark_t
) == sizeof(__itt_mark_type
));
41 /* Previously used warnings:
43 KMP_WARNING( IttAllNotifDisabled );
44 KMP_WARNING( IttObjNotifDisabled );
45 KMP_WARNING( IttMarkNotifDisabled );
46 KMP_WARNING( IttUnloadLibFailed, libittnotify );
49 kmp_int32 __kmp_itt_prepare_delay
= 0;
50 kmp_bootstrap_lock_t __kmp_itt_debug_lock
=
51 KMP_BOOTSTRAP_LOCK_INITIALIZER(__kmp_itt_debug_lock
);
53 #endif // USE_ITT_NOTIFY
55 void __kmp_itt_reset() {
57 __kmp_itt__ittapi_global
= __kmp_ittapi_clean_global
;
61 void __kmp_itt_initialize() {
63 // ITTNotify library is loaded and initialized at first call to any ittnotify
64 // function, so we do not need to explicitly load it any more. Just report OMP
65 // RTL version to ITTNotify.
68 // Backup a clean global state
69 __kmp_ittapi_clean_global
= __kmp_itt__ittapi_global
;
71 // Report OpenMP RTL version.
73 __itt_mark_type version
;
74 __kmp_str_buf_init(&buf
);
75 __kmp_str_buf_print(&buf
, "OMP RTL Version %d.%d.%d", __kmp_version_major
,
76 __kmp_version_minor
, __kmp_version_build
);
77 if (__itt_api_version_ptr
!= NULL
) {
78 __kmp_str_buf_print(&buf
, ":%s", __itt_api_version());
80 version
= __itt_mark_create(buf
.str
);
81 __itt_mark(version
, NULL
);
82 __kmp_str_buf_free(&buf
);
85 } // __kmp_itt_initialize
87 void __kmp_itt_destroy() {
89 __kmp_itt_fini_ittlib();
91 } // __kmp_itt_destroy
93 extern "C" void __itt_error_handler(__itt_error_code err
, va_list args
) {
96 case __itt_error_no_module
: {
97 char const *library
= va_arg(args
, char const *);
99 int sys_err
= va_arg(args
, int);
100 kmp_msg_t err_code
= KMP_SYSERRCODE(sys_err
);
101 __kmp_msg(kmp_ms_warning
, KMP_MSG(IttLoadLibFailed
, library
), err_code
,
103 if (__kmp_generate_warnings
== kmp_warnings_off
) {
104 __kmp_str_free(&err_code
.str
);
107 char const *sys_err
= va_arg(args
, char const *);
108 kmp_msg_t err_code
= KMP_SYSERRMESG(sys_err
);
109 __kmp_msg(kmp_ms_warning
, KMP_MSG(IttLoadLibFailed
, library
), err_code
,
111 if (__kmp_generate_warnings
== kmp_warnings_off
) {
112 __kmp_str_free(&err_code
.str
);
116 case __itt_error_no_symbol
: {
117 char const *library
= va_arg(args
, char const *);
118 char const *symbol
= va_arg(args
, char const *);
119 KMP_WARNING(IttLookupFailed
, symbol
, library
);
121 case __itt_error_unknown_group
: {
122 char const *var
= va_arg(args
, char const *);
123 char const *group
= va_arg(args
, char const *);
124 KMP_WARNING(IttUnknownGroup
, var
, group
);
126 case __itt_error_env_too_long
: {
127 char const *var
= va_arg(args
, char const *);
128 size_t act_len
= va_arg(args
, size_t);
129 size_t max_len
= va_arg(args
, size_t);
130 KMP_WARNING(IttEnvVarTooLong
, var
, (unsigned long)act_len
,
131 (unsigned long)max_len
);
133 case __itt_error_cant_read_env
: {
134 char const *var
= va_arg(args
, char const *);
135 int sys_err
= va_arg(args
, int);
136 kmp_msg_t err_code
= KMP_ERR(sys_err
);
137 __kmp_msg(kmp_ms_warning
, KMP_MSG(CantGetEnvVar
, var
), err_code
,
139 if (__kmp_generate_warnings
== kmp_warnings_off
) {
140 __kmp_str_free(&err_code
.str
);
143 case __itt_error_system
: {
144 char const *func
= va_arg(args
, char const *);
145 int sys_err
= va_arg(args
, int);
146 kmp_msg_t err_code
= KMP_SYSERRCODE(sys_err
);
147 __kmp_msg(kmp_ms_warning
, KMP_MSG(IttFunctionError
, func
), err_code
,
149 if (__kmp_generate_warnings
== kmp_warnings_off
) {
150 __kmp_str_free(&err_code
.str
);
154 KMP_WARNING(IttUnknownError
, err
);
157 } // __itt_error_handler
159 #endif /* USE_ITT_BUILD */