Task¶
A task represents the code executed by a node in the data flow graph. In other languages, a task can be referred to as a job or a filter. A task is defined by its input and output data and the code to execute when triggered. In other words, a task comes with a set of data called sockets (not to be confused with network and system sockets). The sockets model the data that are consumed (input socket) and produced (output socket) by the current task. Finally, the code to execute is stored in a so-called codelet.
A task is a C++ object of the spu::runtime::Task class. The following
sections try to give an overview of the most important attributes and methods
to facilitate the code understanding.
Main Attributes¶
The list of sockets that are attached to this task. The allocated data of the output sockets of this task. If theautoalloc 
attribute is set to true (see below) then the data are allocated here, 
otherwise this vector is left empty.
The function called by _exec() method (see below), thus dictating the 
task's behavior. Usually set in the module's constructor and should 
return a status_t.
Fake input sockets are used when specifying dependencies between tasks
directly. Thus, internally, these dependencies are managed through "fake input
sockets" that are created on-the-fly over the current task. The data of these
sockets are ignored during the codelet execution.
If set to true, let StreamPU allocate and reallocate memory needed by 
the task. Data are only allocated in the output sockets. By default this 
attribute is set to true.
If true, records statistics regarding the task's execution, such as the 
duration. By default this attribute is set to false.
If true, skips can_exec() runtime check, thus, improving performance. 
Sockets bound to this task will also be set to fast. By default this 
attribute is set to false.
If set to true, displays the task's sockets data and its status upon 
execution (on the standard output). By default this attribute is set to 
false.
A pointer to the corresponding module. See the Module section for 
more information about what is a module.
A name to identify the task. This name is unique in the module.
Main Methods¶
Calls_exec() method, records execution statistics (if stats == true) and 
prints the debug logs (if debug == true).
Executes the task's codelet and sets the status for this specific call.
Called by exec() (see the above method).
Returns true if all the sockets are associated to an allocated buffer, 
otherwise returns false. Called by exec() method if fast is set to 
false, skipped otherwise.
Add a fake input socket to the current task (see above fake_input_sockets 
attribute) and binds it to the output status socket of the t_out task in 
parameter. The new socket's datatype and databytes match the output 
status socket of t_out. fake_input_sockets is always fast. This 
method has to be manually called by the user.
Unbinds and deletes the corresponding input socket in the 
fake_input_sockets attribute. Can be called by Sequence::set_n_frames() 
or manually by the user.
Resets the task's statistics. Not to be confused with Module::reset().
Manually called by the user.