Data Flow Graph Construction - 2024.1 English

Vitis Libraries

Release Date
2024-08-06
Version
2024.1 English

Once AIE kernels have been prepared, next step is to create a Data Flow Graph class which defines the top level ports, Run time parameters, connectivity, constraints etc. This consists of the following steps:

  1. Create graph.h and include Adaptive Data Flow (ADF) header file (adf.h). Also include header file with kernel function prototypes (kernel.h)

    #include <adf.h>
    #include "kernels.h"
    
  2. Define your graph class by using the objects which are defined in the adf name space. All user graphs are derived from the class graph.

    include <adf.h>
    #include "kernels.h"
    
    using namespace adf;
    
    class myGraph : public graph {
    private:
        kernel k1;
    };
    
  3. Add top level ports to graph. These ports will be responsible to data transfers to / from the kernels.

    #include <adf.h>
    #include "kernels.h"
    
    using namespace adf;
    
    class simpleGraph : public graph {
    private:
        kernel k1;
    
    public:
        port<input> inptr;
        port<output> outptr;
        port<input> kernelCoefficients;
    };
    
  4. Specify connections of top level ports to kernels. Primary connections type are `Window`_, Stream, Run time parameters. Below is example code specifying connectivity.

    class myGraph : public adf::graph {
    private:
        kernel k1;
    public:
        port<input> inptr;
        port<output> outptr;
        port<input> kernelCoefficients;
    
        myGraph() {
            k1 = kernel::create(filter2D);
            adf::connect(inptr, k1.in[0]);
            adf::connect<parameter>(kernelCoefficients, async(k1.in[1]));
            adf::connect(k1.out[0], outptr);
        }
    };
    
  5. Specify the source file location and other constraints for each kernel.

    class myGraph : public adf::graph {
    private:
        kernel k1;
    public:
        port<input> inptr;
        port<output> outptr;
        port<input> kernelCoefficients;
    
        myGraph() {
            k1 = kernel::create(filter2D);
            adf::connect(inptr, k1.in[0]);
            adf::connect<parameter>(kernelCoefficients, async(k1.in[1]));
            adf::connect(k1.out[0], outptr);
            source(k1) = "xf_filter2d.cc";
            // Initial mapping
            runtime<ratio>(k1) = 0.5;
        }
    };