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 runtime 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 runtime parameter. Runtime parameters are processed as ports alongside those created by streams and windows. Both scalar and array values can be passed as runtime parameters.
Consider the following example where a kernel function is defined with runtime
parameters. Here, select
is a scalar RTP port and
coefficients
is a vector RTP with 32 integers.
#ifndef FUNCTION_KERNELS_H
#define FUNCTION_KERNELS_H
void filter_with_array_param(input_buffer<cint16> & in, output_buffer<cint16> * out, int32 select, const int32 (&coefficients)[32]);
#endif
- Synchronous Parameters (or triggering parameters)
- The kernel does not execute until the runtime 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 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.