Tasks Overview

Tasks are the fundamental data elements in the Intel® ITT API. A task is a logical unit of work on a specific thread. Tasks can nest; thus, tasks typically correspond to functions, scopes, or a case block in a switch statement.

 

 // Create domain and a couple of tasks names at global scope

 __itt_domain* domain = __itt_domain_create(L”MyTraces.MyDomain”);

 __itt_string_handle* shMyTask = __itt_string_handle_create(L”My Task”);

 __itt_string_handle* shMySubtask = __itt_string_handle_create(L”My SubTask”);

 

 void BeginFrame() {

     __itt_task_begin(domain, __itt_null, __itt_null, shMyTask);

 }

 void DoWork() {

     __itt_task_begin(domain, __itt_null, __itt_null, shMySubtask);

     …

     __itt_task_end(domain);

 }

 void EndFrame() {

     __itt_task_end(domain);

 }

 void Main() {

     BeginFrame();

     DoWork();

     EndFrame();

 }

 

A task instance represents a piece of work performed by a particular thread for a period of time.
A call to __itt_task_begin() creates a task instance. This becomes the current task instance for that thread.
A call to __itt_task_end() on the same thread ends the current task instance.

It is possible to relate tasks to one another using IDs together with the Relations API functions.  

NOTE

The task is defined by the bracketing of __itt_task_begin() and __itt_task_end() on the same thread. The ITT API does not support scheduling mechanisms that cause task switching (the thread suspends the current task and switches to a different task) or task stealing (the task moves to a different thread).

See Also

__itt_task_begin
__itt_task_begin_fn
__itt_task_end  

Tasks Overview