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 #ifndef _TBB_ITT_NOTIFY 18 #define _TBB_ITT_NOTIFY 19 20 #include "tbb/tbb_stddef.h" 21 22 #if DO_ITT_NOTIFY 23 24 #if _WIN32||_WIN64 25 #ifndef UNICODE 26 #define UNICODE 27 #endif 28 #endif /* WIN */ 29 30 #ifndef INTEL_ITTNOTIFY_API_PRIVATE 31 #define INTEL_ITTNOTIFY_API_PRIVATE 32 #endif 33 34 #include "tools_api/ittnotify.h" 35 #include "tools_api/legacy/ittnotify.h" 36 extern "C" void __itt_fini_ittlib(void); 37 38 #if _WIN32||_WIN64 39 #undef _T 40 #endif /* WIN */ 41 42 #endif /* DO_ITT_NOTIFY */ 43 44 #if !ITT_CALLER_NULL 45 #define ITT_CALLER_NULL ((__itt_caller)0) 46 #endif 47 48 namespace tbb { 49 //! Unicode support 50 #if (_WIN32||_WIN64) && !__MINGW32__ 51 //! Unicode character type. Always wchar_t on Windows. 52 /** We do not use typedefs from Windows TCHAR family to keep consistence of TBB coding style. **/ 53 typedef wchar_t tchar; 54 //! Standard Windows macro to markup the string literals. 55 #define _T(string_literal) L ## string_literal 56 #else /* !WIN */ 57 typedef char tchar; 58 //! Standard Windows style macro to markup the string literals. 59 #define _T(string_literal) string_literal 60 #endif /* !WIN */ 61 } // namespace tbb 62 63 #if DO_ITT_NOTIFY 64 namespace tbb { 65 //! Display names of internal synchronization types 66 extern const tchar 67 *SyncType_GlobalLock, 68 *SyncType_Scheduler; 69 //! Display names of internal synchronization components/scenarios 70 extern const tchar 71 *SyncObj_SchedulerInitialization, 72 *SyncObj_SchedulersList, 73 *SyncObj_WorkerLifeCycleMgmt, 74 *SyncObj_TaskStealingLoop, 75 *SyncObj_WorkerTaskPool, 76 *SyncObj_MasterTaskPool, 77 *SyncObj_TaskPoolSpinning, 78 *SyncObj_Mailbox, 79 *SyncObj_TaskReturnList, 80 *SyncObj_TaskStream, 81 #if __TBB_PREVIEW_CRITICAL_TASKS 82 *SyncObj_CriticalTaskStream, 83 #endif 84 *SyncObj_ContextsList 85 ; 86 87 namespace internal { 88 void __TBB_EXPORTED_FUNC itt_set_sync_name_v3( void* obj, const tchar* name); 89 90 } // namespace internal 91 } // namespace tbb 92 93 // const_cast<void*>() is necessary to cast off volatility 94 #define ITT_NOTIFY(name,obj) __itt_##name(const_cast<void*>(static_cast<volatile void*>(obj))) 95 #define ITT_THREAD_SET_NAME(name) __itt_thread_set_name(name) 96 #define ITT_FINI_ITTLIB() __itt_fini_ittlib() 97 #define ITT_SYNC_CREATE(obj, type, name) __itt_sync_create((void*)(obj), type, name, 2) 98 #define ITT_SYNC_RENAME(obj, name) __itt_sync_rename(obj, name) 99 #define ITT_STACK_CREATE(obj) obj = __itt_stack_caller_create() 100 #if __TBB_TASK_GROUP_CONTEXT 101 #define ITT_STACK(precond, name, obj) (precond) ? __itt_stack_##name(obj) : ((void)0); 102 #else 103 #define ITT_STACK(precond, name, obj) ((void)0) 104 #endif /* !__TBB_TASK_GROUP_CONTEXT */ 105 106 #define ITT_TASK_GROUP(obj,name,parent) itt_make_task_group_v7(internal::ITT_DOMAIN_MAIN,(void*)(obj),ALGORITHM,(void*)(parent),(parent!=NULL) ? ALGORITHM : FLOW_NULL,name) 107 #define ITT_TASK_BEGIN(obj,name,id) itt_task_begin_v7(internal::ITT_DOMAIN_MAIN,(void*)(id),ALGORITHM,(void*)(obj),ALGORITHM,name) 108 #define ITT_TASK_END itt_task_end_v7(internal::ITT_DOMAIN_MAIN) 109 110 #else /* !DO_ITT_NOTIFY */ 111 112 #define ITT_NOTIFY(name,obj) ((void)0) 113 #define ITT_THREAD_SET_NAME(name) ((void)0) 114 #define ITT_FINI_ITTLIB() ((void)0) 115 #define ITT_SYNC_CREATE(obj, type, name) ((void)0) 116 #define ITT_SYNC_RENAME(obj, name) ((void)0) 117 #define ITT_STACK_CREATE(obj) ((void)0) 118 #define ITT_STACK(precond, name, obj) ((void)0) 119 120 #define ITT_TASK_GROUP(type,name,parent) ((void)0) 121 #define ITT_TASK_BEGIN(type,name,id) ((void)0) 122 #define ITT_TASK_END ((void)0) 123 124 #endif /* !DO_ITT_NOTIFY */ 125 126 namespace tbb { 127 namespace internal { 128 int __TBB_load_ittnotify(); 129 }} 130 131 #endif /* _TBB_ITT_NOTIFY */ 132