151c0b2f7Stbbdev /*
2*c21e688aSSergey Zheltov Copyright (c) 2005-2022 Intel Corporation
351c0b2f7Stbbdev
451c0b2f7Stbbdev Licensed under the Apache License, Version 2.0 (the "License");
551c0b2f7Stbbdev you may not use this file except in compliance with the License.
651c0b2f7Stbbdev You may obtain a copy of the License at
751c0b2f7Stbbdev
851c0b2f7Stbbdev http://www.apache.org/licenses/LICENSE-2.0
951c0b2f7Stbbdev
1051c0b2f7Stbbdev Unless required by applicable law or agreed to in writing, software
1151c0b2f7Stbbdev distributed under the License is distributed on an "AS IS" BASIS,
1251c0b2f7Stbbdev WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1351c0b2f7Stbbdev See the License for the specific language governing permissions and
1451c0b2f7Stbbdev limitations under the License.
1551c0b2f7Stbbdev */
1651c0b2f7Stbbdev
1751c0b2f7Stbbdev #if __TBB_USE_ITT_NOTIFY
1851c0b2f7Stbbdev
1951c0b2f7Stbbdev #if _WIN32||_WIN64
2051c0b2f7Stbbdev #ifndef UNICODE
2151c0b2f7Stbbdev #define UNICODE
2251c0b2f7Stbbdev #endif
2351c0b2f7Stbbdev #else
2451c0b2f7Stbbdev #pragma weak dlopen
2551c0b2f7Stbbdev #pragma weak dlsym
2651c0b2f7Stbbdev #pragma weak dlerror
2751c0b2f7Stbbdev #endif /* WIN */
2851c0b2f7Stbbdev
2951c0b2f7Stbbdev #if __TBB_BUILD
3051c0b2f7Stbbdev
3151c0b2f7Stbbdev extern "C" void ITT_DoOneTimeInitialization();
3251c0b2f7Stbbdev #define __itt_init_ittlib_name(x,y) (ITT_DoOneTimeInitialization(), true)
3351c0b2f7Stbbdev
3451c0b2f7Stbbdev #elif __TBBMALLOC_BUILD
3551c0b2f7Stbbdev
3651c0b2f7Stbbdev extern "C" void MallocInitializeITT();
3751c0b2f7Stbbdev #define __itt_init_ittlib_name(x,y) (MallocInitializeITT(), true)
3851c0b2f7Stbbdev
3951c0b2f7Stbbdev #else
4051c0b2f7Stbbdev #error This file is expected to be used for either TBB or TBB allocator build.
4151c0b2f7Stbbdev #endif // __TBB_BUILD
4251c0b2f7Stbbdev
4351c0b2f7Stbbdev #include "tools_api/ittnotify_static.c"
4451c0b2f7Stbbdev
4551c0b2f7Stbbdev namespace tbb {
4651c0b2f7Stbbdev namespace detail {
4751c0b2f7Stbbdev namespace r1 {
4851c0b2f7Stbbdev
4951c0b2f7Stbbdev /** This extra proxy method is necessary since __itt_init_lib is declared as static **/
__TBB_load_ittnotify()5051c0b2f7Stbbdev int __TBB_load_ittnotify() {
5151c0b2f7Stbbdev #if !(_WIN32||_WIN64)
5251c0b2f7Stbbdev // tool_api crashes without dlopen, check that it's present. Common case
5351c0b2f7Stbbdev // for lack of dlopen is static binaries, i.e. ones build with -static.
5457f524caSIlya Isaev if (dlopen == nullptr)
5551c0b2f7Stbbdev return 0;
5651c0b2f7Stbbdev #endif
5757f524caSIlya Isaev return __itt_init_ittlib(nullptr, // groups for:
5851c0b2f7Stbbdev (__itt_group_id)(__itt_group_sync // prepare/cancel/acquired/releasing
5951c0b2f7Stbbdev | __itt_group_thread // name threads
6051c0b2f7Stbbdev | __itt_group_stitch // stack stitching
6151c0b2f7Stbbdev | __itt_group_structure
6251c0b2f7Stbbdev ));
6351c0b2f7Stbbdev }
6451c0b2f7Stbbdev
6551c0b2f7Stbbdev } //namespace r1
6651c0b2f7Stbbdev } //namespace detail
6751c0b2f7Stbbdev } // namespace tbb
6851c0b2f7Stbbdev
6951c0b2f7Stbbdev #endif /* __TBB_USE_ITT_NOTIFY */
70