In the dataflow coding example you should notice the following:
- The is applied to instruct the compiler to enable dataflow optimization. This is not a data mover, which deals with interfacing between the PS and PL, but instead addresses how the data flows through the accelerator.
- The
stream
class is used as a data transferring channel between each of the functions in the dataflow region.Tip: Thestream
class infers a first-in first-out (FIFO) memory circuit in the programmable logic. This memory circuit, which acts as a queue in software programming, provides data-level synchronization between the functions and achieves better performance.
void compute_kernel(ap_int<256> *inx, ap_int<256> *outx, DTYPE alpha) {
hls::stream<unsigned int>inFifo;
#pragma HLS STREAM variable=inFifo depth=32
hls::stream<unsigned int>outFifo;
#pragma HLS STREAM variable=outFifo depth=32
#pragma HLS DATAFLOW
read_data(inx, inFifo);
// Do computation with the acquired data
compute(inFifo, outFifo, alpha);
write_data(outx, outFifo);
return;
}