It is possible to modify the behavior of the AI Engine program or data-flow graph based on a dynamic condition or event using the run-time parameter. The modification could be in the data being processed, for example a modified mode of operation or a new coefficient table, or it could be in the control flow of the graph such as conditional execution or dynamically reconfiguring a graph. Either the kernels or the graphs can be defined to execute with parameters.
If an integer scalar value appears in the formal arguments of a kernel function, then that parameter becomes a run-time parameter. Run-time parameters are processed as ports alongside those created by streams and windows. Both scalar and array values can be passed as run-time parameters.
Consider the following example where a kernel function is defined with run-time
parameters. Here, select
is a scalar RTP port and
coefficients
is a vector RTP with 32 integers.
#ifndef RTP_KERNEL_H
#define RTP_KERNEL_H
void simple_param(input_window_cint16 * in,
output_window_cint16 *outw,
int select,
const int32 (&coefficients)[32]);
#endif
- Synchronous Parameters (or triggering parameters)
- The kernel does not execute until the run-time parameter is written by a controlling processor. Upon a write, the kernel executes once, reading the new updated value. After completion, it is blocked from executing again until the parameter is updated. This allows for a different type of execution model from the normal streaming model, and can be useful for certain updating operations where blocking synchronization is important.
- Asynchronous Parameters
- These parameters can be changed any time by either a controlling processor such as ArmĀ® . They are read each time a kernel is invoked without any specific synchronization. These types of parameters can be used, for example, to pass new filter coefficients to a filter kernel that changes infrequently.