input_pktstream
and
output_pktstream
are introduced to represent the
multiplexed data streams as input to or output from a kernel, respectively. More details
on the packet headers and data types can be found in Packet Stream Operations.To explicitly control the multiplexing and de-multiplexing of packets,
two new templated node classes are added to the ADF graph library: pktsplit<n>
and pktmerge<n>
. A node instance of class pktmerge<n>
is a n:1 multiplexer of n packet streams producing a
single packet stream. A node instance of class pktsplit<n>
is a 1:n de-multiplexer of a packet stream producing n
different packet streams. The maximum number of allowable packet streams is four on a
single physical channel (n≤4). See Adaptive Data Flow Graph Specification Reference for
more details.
input_pktstream
and output_pktstream
. To connect a packet stream to a window of data meant for
an AI Engine kernel use the following graph
construct:
connect<pktstream, window<32>>
connect<window<32>, pktstream>
connect<pktstream, pktstream>
connect<pktstream, pktstream>
To connect a stream of data from/to a PLIO connection use the following graph construct:
connect<input_port, pktstream>
connect<pktstream, output_port>
When a kernel receives packets of data as a window of data, the header and TLAST are dropped prior to the kernel receiving the window of data. If the kernel writes an output window of data, the packet header and TLAST are automatically inserted.
input_pktstream
of data, the kernel needs to process the packer header and
TLAST, in addition to the packet data. Similarly if the kernel sends an output_pktstream
of data, the kernel needs to insert the
packer header and TLAST, in addition to the packet data into the output stream.These concepts are illustrated in the following example:
class ExplicitPacketSwitching: public adf::graph {
private:
adf:: kernel core[4];
adf:: pktsplit<4> sp;
adf:: pktmerge<4> mg;
public:
adf::port in;
adf::port out;
mygraph() {
core[0] = adf::kernel::create(aie_core1);
core[1] = adf::kernel::create(aie_core2);
core[2] = adf::kernel::create(aie_core3);
core[3] = adf::kernel::create(aie_core4);
adf::source(core[0]) = "aie_core1.cpp";
adf::source(core[1]) = "aie_core2.cpp";
adf::source(core[2]) = "aie_core3.cpp";
adf::source(core[3]) = "aie_core4.cpp";
sp = adf::pktsplit<4>::create();
mg = adf::pktmerge<4>::create();
for(int i=0;i<4;i++){
adf::runtime<ratio>(core[i]) = 0.9;
adf::connect<adf::pktstream, adf::window<32> > (sp.out[i], core[i].in[0]);
adf::connect<adf::window<32>, adf::pktstream > (core[i].out[0], mg.in[i]);
}
adf::connect (in, sp.in[0]);
adf::connect (mg.out[0], out);
}
};
The graph has one input PLIO port and one output PLIO port. The input packet stream from the PL is split four ways and input to four different AI Engine kernels. The output streams from the four AI Engine kernels are merged into one packet stream which is output to the PL. The Vitis analyzer Graph view of the code is shown as follows.