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

最大限度减少 ITT API 开销

ITT API 开销及其对应用程序整体性能的影响取决于添加到应用程序中的检测代码的量。用 ITT API 检测应用程序时,应该在应用程序性能与需要收集的性能数据的量之间达到平衡,以便尽量减少 API 开销,而同时又收集足够的性能数据。
遵照以下指引,以在检测的应用程序的整体性能与检测细节之间达到良好的平衡:
  • 只检测应用程序内对分析重要的路径。
  • 在关键路径之外创建 ITT 域和字符串句柄。
  • 按应用程序中可单独分析的不同方面过滤数据收集。禁用的 API 调用(从而过滤掉相关的调用)的开销始终小于 10 时钟计时周期数,与 API 无关。
用法示例:使用域和字符串句柄
ITT API 包括一个创建域和字符串句柄的函数子集。这些函数对同一个域名和字符串始终返回相同的句柄。这就要求这些函数执行字符串比较和表查找,而这会造成严重的性能损失。此外,这些函数的性能与创建域或字符串句柄的数量的对数成正比。最好在全域范围内或在应用程序启动时,创建域和字符串句柄。
以下代码部分在全局范围内创建两个域。可以使用这些域来控制写入踪迹文件的细节级别。
__itt_domain* basic = __itt_domain_create(__TEXT("MyFunction.Basic")); __itt_domain* detailed = __itt_domain_create(__TEXT("MyFunction.Detailed")); // Create string handles at global scope. __itt_string_handle* h_my_funcion = __itt_string_handle_create(__TEXT("MyFunction")); void MyFunction(int arg) { __itt_task_begin(basic, __itt_null, __itt_null, h_my_function); Foo(arg); FooEx(); __itt_task_end(basic); } __itt_string_handle* h_foo = __itt_string_handle_create(__TEXT("Foo")); void Foo(int arg) { // Skip tracing detailed data if the detailed domain is disabled. __itt_task_begin(detailed, __itt_null, __itt_null, h_foo); // Do some work here... __itt_task_end(detailed); } __itt_string_handle* h_foo_ex = __itt_string_handle_create(__TEXT("FooEx")); void FooEx() { // Skip tracing detailed data if the detailed domain is disabled. __itt_task_begin(detailed, __itt_null, __itt_null, h_foo_ex); // Do some work here... __itt_task_end(detailed); } // This is my entry point. int main(int argc, char** argv) { if(argc < 2) //Disable detailed domain if we do not need tracing from that in this //application run detailed ->flags = 0; MyFunction(atoi(argv[1])); }

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