Adaptive Dataflow Graph - 2023.2 English

Vitis Tutorials: AI Engine

Document ID
Release Date
2023.2 English

The adaptive dataflow graph file looks something like this.


#ifndef __GRAPH_H__			// include guard to prevent multiple inclusion

	#define __GRAPH_H__

	#include <adf.h>		// Adaptive DataFlow header
	#include "kernel.hpp"

	using namespace adf;

	// dataflow graph declaration
	class the_graph : public graph {	// inherit all properties of the adaptive     dataflow graph

			kernel section1;

			input_plio in;		// input port for data to enter the kernel
			input_port cmtx1;	// input port for SIMD matrix coefficients
			output_plio out;	// output port for data to leave the kernel

			// constructor
			the_graph() {

				// associate the kernel with the function to be executed
				section1 = kernel::create(SecondOrderSection<1>);

				// declare data widths and files for simulation
				in = input_plio::create(plio_32_bits, "data/input.dat");
				out = output_plio::create(plio_32_bits, "output.dat");

				const unsigned num_samples = 8;

				// establish connections
				dimensions([0]) = {num_samples};
				connect<parameter>(cmtx1, adf::async([1]));
				dimensions(section1.out[0]) = {num_samples};

				// specify which source code file contains the kernel function
				source(section1) = "kernel.cpp";

				// !!! temporary value: assumes this kernel dominates the AI Engine tile !!!
				runtime<ratio>(section1) = 1.0;

			} // end the_graph()

	}; // end class the_graph

#endif // __GRAPH_H__


  • section1 = kernel::create(SecondOrderSection<1>) tells the tools that the AI Engine kernel program uses the templated function SecondOrderSection with a template parameter of 1.

  • [input|output]_plio declare input or output ports for simulation located in the programmable logic (PL) portion of the device.

  • [input|output]_plio::create() declares the width of the data bus used in the PL and the associated input/output file used during the simulation.

  • connect(in.out[0],[0]) tells the tools that kernel input is connected to the in port.

  • dimensions([0]) declares the number of samples required to be collected before the executing the kernel.

  • connect<parameter>(cmtx1, adf::async([1])) tells the tools that an asynchronous run-time parameter is required for the first execution of the kernel. Subsequent executions use the latest runtime parameter available, that is if the asynchronous parameter is only sent once, then that parameter is/ reused for the remaining life of the kernel.

  • connect(section1.out[0],[0]) tells the tools that the kernel output is connected to the out port.

  • dimensions(section1.out[0]) declares the number of samples the kernel generates during each invocation.

  • source(section1) = "kernel.cpp" tells the tools where to find the source code for the kernel.

  • runtime<ratio>(section1) = 1.0 tells the tools that only this kernel can be placed in the AI Engine. At this time, the actual execution time is unknown.