With a stream-based access model, the kernels receive an input stream or an output stream of typed data as an argument. Each access to these streams is synchronized, i.e., reads stall if the data is not available in the stream and writes stall if the stream is unable to accept new data.
1and two 32-bit output stream ports with
1. This ID is supplied as an argument to the stream object constructors. The AI Engine compiler automatically allocates the input and output stream port IDs from left to right in the argument list of a kernel. Multiple kernels mapped to the same AI Engine are not allowed to share stream ports unless the streams are packet switched (see Explicit Packet Switching).
public: input_plio din; output_plio dout; adf::kernel k0,k1; ... connect <stream> (din.out, k1.in); connect <stream> (k1.out, k2.in); connect <stream> (k2.out, dout.in);
connect <cascade> (k1.out, k2.in);
The stream data structures are automatically inferred by the AI Engine compiler from data flow graph connections, and are automatically declared in the wrapper code implementing the graph control. The kernel functions merely operate on pointers to stream data structures that are passed to them as arguments. There is no need to declare these stream data structures in data flow graph or kernel program.
Stream Connection for Multi-Rate Processing
// constraint to specify samples per iteration for stream/pktstream ports to support multirate connections constraint<uint32_t> samples_per_iteration(adf::port<adf::input>& p); constraint<uint32_t> samples_per_iteration(adf::port<adf::output>& p);
constraintkeyword need the sample datatype as a template value and the function
samples_per_iterationis applied to the input or the output of the kernel. The related stream can be connected to another stream of a buffer.
adf::samples_per_iteration (>0)is specified.