Single Kernel Graph - 2022.2 English

AI Engine Kernel and Graph Programming Guide (UG1079)

Document ID
UG1079
Release Date
2022-10-19
Version
2022.2 English

The simplest basic graph is a single kernel that is instantiated in a class that inherits from the adf::graph class with specified inputs and outputs.

class SimplestGraph: public adf::graph {
private:
  adf::kernel k;

public:
  adf::port<input> din;
  adf::port<output> dout;

SimplestGraph() {
  k = adf::kernel::create(passthrough);
  adf::source(k) = "passthrough.cpp";
  adf::runtime<ratio>(k) = 0.9;
  adf::connect<window<FRAME_LENGTH*4>>(din, k.in[0]);
  adf::connect<window<FRAME_LENGTH*4>>(k.out[0], dout);
  };
};
This simple graph above can be embedded into another graph. Data input file Input_64.txt represents the data from a PLIO connection to the embedded graph input. Data output file Output1.txt represents the data from the embedded graph output to the PLIO connection. The Simple graph is a sub-graph within the TestGraph.

class TestGraph: public adf::graph {
public:
  adf::input_plio plin1;
  adf::output_plio plout1;

  SimplestGraph Simple;

  TestGraph()
  {
    plin1 = adf::input_plio::create("input1",adf::plio_64_bits,"data/Input_64.txt",500);
    adf::connect(plin1.out[0],Simple.din);

    plout1 = adf::output_plio::create("output1",adf::plio_64_bits,"data/Output1.txt",500);
    adf::connect(Simple.dout,plout1.in[0]);
  };
};

The testbench program instantiates the test graph and calls the control commands to initialize run and end the graph.

#include "graph.h"

TestGraph UnitTest;

int main(int argc, char ** argv) {
  UnitTest.init();
  UnitTest.run(NFRAMES*NITERATIONS);
  UnitTest.end();
  return 0;
}

The resulting graph can be seen in Vitis Analyzer:

Figure 1. Graph View