• Intel® Graphics Performance Analyzers 2020 R1
  • 12/20/2019
  • Public Content
Contents

Thread Naming API

默认情况下,应用程序中的每个线程在
timeline
轨迹中显示为一个由进程 ID 和线程 ID 或 OS 线程名称生成的默认标签。可在代码中使用 Thread Naming API(线程命名 API)来赋予线程有意义的名称。
要利用一个 char 或 UNICODE 字符串设定一个线程名称,请使用以下基元:
void __itt_thread_set_nameA (const __itt_char *name) void __itt_thread_set_nameW (const wchar_t *name)
或以如下方式使用宏:
void__itt_thread_set_name(__TEXT("Main"))
基元的参数:
[in]
name
线程名称
 
 
如果多次设置线程的名称,只有最后一个名称被使用。
使用示例
可使用以下线程命名示例,为要关注的线程提供有意义的名称。
DWORD WINAPI service_thread(LPVOID lpArg) { __itt_thread_set_name(__TEXT("My service thread")); // Do thread work here return 0; } DWORD WINAPI thread_function(LPVOID lpArg) { __itt_thread_set_name(__TEXT("My worker thread")); // Do thread work here return 0; } int main(int argc, char* argv[]) { ... CreateThread(NULL, 0, service_thread, NULL, 0, NULL); CreateThread(NULL, 0, thread_function, NULL, 0, NULL); ... return 0; }
另请参阅

Product and Performance Information

1

Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.

Notice revision #20110804