A Simple Example of Using Task APIs in Your Code

Intel® VTune™ Amplifier XE 2013 provides a new feature which is a set of Task APIs. These Task APIs help to highlight your interest of Task and its sub-Task(s), in VTune Amplifier XE result.


Task APIs:

void ITTAPI__itt_task_begin ( const __itt_domain *domain, __itt_id taskid, __itt_id parentid, __itt_string_handle *name)

void ITTAPI__itt_task_end ( const __itt_domain *domain)


It is easier to use(insert) APIs in your code, I gave an example to help of your understandings on using Task APIs quickly.



1.     Write your code including Task APIs, refer to my example

2.     Add paths of ittnotify.h and libittnotify.lib in your environment

3.     Add libittnotify.lib  to additional LIB to link

4.     Create a VTune Amplifier XE project, and run Concurrency Analysis (for example, and don’t forget to select “Analyze user tasks” on

5.     In report, click on “Tasks and Frames” tab, your interest of Task and sub-Task(s) will be highlighted.    




#include <windows.h>
#include "ittnotify.h"
__itt_domain* domain;
__itt_string_handle* shMyTask;
__itt_string_handle* shMySubtask;
const int num_threads = 4;
 int myNum = *((int *)pArg);
// Only 3rd thread masked
if (myNum==2) __itt_task_begin(domain, __itt_null, __itt_null, shMySubtask);
 for (unsigned long i=0; i<600000000L; i++); // Should use "/Od" to avoid "zero" workload
if (myNum==2)__itt_task_end(domain);
return 1;
int main()
HANDLE threadHandles[num_threads];
int tNum[num_threads];
    domain = __itt_domain_create("MyTraces.MyDomain");
    shMyTask = __itt_string_handle_create("My Task");
    shMySubtask = __itt_string_handle_create("My SubTask");
    __itt_task_begin(domain, __itt_null, __itt_null, shMyTask);
 for ( int i=0; i<num_threads; ++i )
  tNum[i] = i;
  threadHandles[i] = CreateThread( NULL,            // Security attributes
                                   0,               // Stack size
                                   foo,      // Thread function
                                   (LPVOID)&tNum[i],// Data for thread func()
                                   0,               // Thread start mode
                                   NULL);           // Returned thread ID
 WaitForMultipleObjects(num_threads, threadHandles, TRUE, INFINITE);
  return 1;
Einzelheiten zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.