1 /*
2     Copyright (c) 2005-2020 Intel Corporation
3 
4     Licensed under the Apache License, Version 2.0 (the "License");
5     you may not use this file except in compliance with the License.
6     You may obtain a copy of the License at
7 
8         http://www.apache.org/licenses/LICENSE-2.0
9 
10     Unless required by applicable law or agreed to in writing, software
11     distributed under the License is distributed on an "AS IS" BASIS,
12     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13     See the License for the specific language governing permissions and
14     limitations under the License.
15 */
16 
17 #if DO_ITT_NOTIFY
18 
19 #if _WIN32||_WIN64
20     #ifndef UNICODE
21         #define UNICODE
22     #endif
23 #else
24     #pragma weak dlopen
25     #pragma weak dlsym
26     #pragma weak dlerror
27 #endif /* WIN */
28 
29 #if __TBB_BUILD
30 
31 extern "C" void ITT_DoOneTimeInitialization();
32 #define __itt_init_ittlib_name(x,y) (ITT_DoOneTimeInitialization(), true)
33 
34 #elif __TBBMALLOC_BUILD
35 
36 extern "C" void MallocInitializeITT();
37 #define __itt_init_ittlib_name(x,y) (MallocInitializeITT(), true)
38 
39 #else
40 #error This file is expected to be used for either TBB or TBB allocator build.
41 #endif // __TBB_BUILD
42 
43 #include "tools_api/ittnotify_static.c"
44 
45 namespace tbb {
46 namespace internal {
__TBB_load_ittnotify()47 int __TBB_load_ittnotify() {
48 #if !(_WIN32||_WIN64)
49     // tool_api crashes without dlopen, check that it's present. Common case
50     // for lack of dlopen is static binaries, i.e. ones build with -static.
51     if (dlopen == NULL)
52         return 0;
53 #endif
54     return __itt_init_ittlib(NULL,          // groups for:
55       (__itt_group_id)(__itt_group_sync     // prepare/cancel/acquired/releasing
56                        | __itt_group_thread // name threads
57                        | __itt_group_stitch // stack stitching
58                        | __itt_group_structure
59                            ));
60 }
61 
62 }} // namespaces
63 
64 #endif /* DO_ITT_NOTIFY */
65 
66 #define __TBB_NO_IMPLICIT_LINKAGE 1
67 #include "itt_notify.h"
68 
69 namespace tbb {
70 
71 #if DO_ITT_NOTIFY
72     const tchar
73             *SyncType_GlobalLock = _T("TbbGlobalLock"),
74             *SyncType_Scheduler = _T("%Constant")
75             ;
76     const tchar
77             *SyncObj_SchedulerInitialization = _T("TbbSchedulerInitialization"),
78             *SyncObj_SchedulersList = _T("TbbSchedulersList"),
79             *SyncObj_WorkerLifeCycleMgmt = _T("TBB Scheduler"),
80             *SyncObj_TaskStealingLoop = _T("TBB Scheduler"),
81             *SyncObj_WorkerTaskPool = _T("TBB Scheduler"),
82             *SyncObj_MasterTaskPool = _T("TBB Scheduler"),
83             *SyncObj_TaskPoolSpinning = _T("TBB Scheduler"),
84             *SyncObj_Mailbox = _T("TBB Scheduler"),
85             *SyncObj_TaskReturnList = _T("TBB Scheduler"),
86             *SyncObj_TaskStream = _T("TBB Scheduler"),
87 #if __TBB_PREVIEW_CRITICAL_TASKS
88             *SyncObj_CriticalTaskStream = _T("TBB Scheduler"),
89 #endif
90             *SyncObj_ContextsList = _T("TBB Scheduler")
91             ;
92 #endif /* DO_ITT_NOTIFY */
93 
94 } // namespace tbb
95 
96