You can 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. You can define either the kernels or the graphs 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. You can pass both scalar and array values as runtime parameters.
Consider the following example which defines a kernel function 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 a controlling processor writes the runtime parameter. Upon a write, the kernel executes once, reading the new updated value. After completion, it cannot execute again until the parameter is updated. This allows for a different type of execution model from the normal streaming model. It 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. You can use these types of parameters, for example, to pass new filter coefficients to a filter kernel that changes infrequently.