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

检测应用程序

Graphics Trace Analyzer 是一种基于检测的工具。它从 gpa_trace 文件获取其数据,该文件由 Intel® GPA 在分析已利用 ITT API 调用检测的应用程序时生成。
要充分发挥 ITT API 的功能,需要将 API 调用添加到代码中来指定逻辑任务。这有助于可视化代码中各任务之间的关系,包括它们相对于其他 CPU 和 GPU 任务的开始和结束时间。
在最高层次,一项任务是在一个特定线程上执行的工作的逻辑组,并且可与程序中被视为重要代码的任何分组相对应。可通过识别各个逻辑执行块的开始和结束标记代码。
要解决大部分的性能瓶颈,使用下述 API 调用即可:
  • __itt_domain_create()
    创建大多数 ITT API 调用所需要的域。至少需要定义一个域。
  • __itt_string_handle_create()
    创建字符串句柄用于标识任务。字符串句柄用于标识踪迹比字符串效率更高。
  • __itt_task_begin()
    标记任务的起始位置。
  • __itt_task_end()
    标记任务的结束位置。
以下示例显示如何在多线程应用程序中使用这四个基本 ITT API 函数。
#include <windows.h> #include <ittnotify.h> // Forward declaration of a thread function. DWORD WINAPI workerthread(LPVOID); bool g_done = false; // Create a domain that is visible globally: we will use it in our example. __itt_domain* domain = __itt_domain_create(__TEXT("Example.Domain.Global")); // Create string handles which associates with the "main" task. __itt_string_handle* handle_main = __itt_string_handle_create(__TEXT("main")); __itt_string_handle* handle_createthread = __itt_string_handle_create(__TEXT("CreateThread")); void main(int, char* argv[]) { // Create a task associated with the "main" routine. __itt_task_begin(domain, __itt_null, __itt_null, handle_main); // Now we'll create 4 worker threads for (int i = 0; i < 4; i++) { // We might be curious about the cost of CreateThread. We add tracing to do the measurement. __itt_task_begin(domain, __itt_null, __itt_null, handle_createthread); ::CreateThread(NULL, 0, workerthread, (LPVOID)i, 0, NULL); __itt_task_end(domain); } // Wait a while,... ::Sleep(5000); g_done = true; // Mark the end of the main task __itt_task_end(domain); } // Create string handle for the work task. __itt_string_handle* handle_work = __itt_string_handle_create(__TEXT("work")); DWORD WINAPI workerthread(LPVOID data) { // Set the name of this thread so it shows up in the UI as something meaningful char threadname[32]; wsprintf(threadname, "Worker Thread %d", data); __itt_thread_set_name(threadname); // Each worker thread does some number of "work" tasks while(!g_done) { __itt_task_begin(domain, __itt_null, __itt_null, handle_work); ::Sleep(150); __itt_task_end(domain); } 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