Module¶
A module is a container of tasks. It contains the tasks themselves and their inner data. Inner data can be useful to avoid useless buffers re-allocations each time a task is executed, or a to contain a state that is updated each time a task is triggered. Multiple tasks can be grouped into one module and can share data through the common module (as opposed to the use of sockets). By definition,
- a stateless task is a task that does not have any inner data
(see
module::Stateless
class), - a stateful task is a task that have inner data and, thus, a task that need to be part of a module.
Each time we need to create a stateful task, we will create a new C++ class
that inherit from the spu::module::Module
class. The Module
class
provides protected
methods to create new tasks and public
methods to
manipulate the module instances.
Main Attributes¶
The tasks list of the current module. All the tasks in the vector are allocated (nonullptr
).
The tasks list of the current module where the tasks have a fixed position in
the vector. This is useful when a task is conditionally created. In the case
of a task that is not created in the current module, its value is set to
nullptr
.
Number of frames/streams to process each time a task is executed. For
instance, if n_frames == 2
, all the tasks of the current module will
process 2 frames each time they are triggered.
Name of the Module. This name is the same for all the instances of one class.
Short name of the Module. This name is the same for all the instances of one
class.
Custom name of the Module. This name can be redefined by the user for each
instance.
Main Protected Methods¶
Sets the module name. Sets the module short name. Creates a new task, two tasks cannot share the samename
.
template <typename T>
size_t create_socket_in(runtime::Task& task, const std::string &name, const size_t n_elmts);
template <typename T>
size_t create_socket_out(runtime::Task& task, const std::string &name, const size_t n_elmts);
template <typename T>
size_t create_socket_fwd(runtime::Task& task, const std::string &name, const size_t n_elmts);
void create_codelet(runtime::Task& task, std::function<int(module::Module &m, runtime::Task &t, onst size_t frame_id)> codelet);
Main Public Methods¶
Returns the number of frames to process in this Module. Sets the number of frames to process each time a task is executed. Returns the module name. Returns the module short name. Sets the module custom name (each instance can have a different custom name). Gets the custom name. Returns the socket if it exists. The expected string format is"task_name::socket_name"
.
Returns the task if it exists. The input string has to match an existing task
name in this module.