Infinite Graph Execution - 2024.1 English

AI Engine Kernel and Graph Programming Guide (UG1079)

Document ID
Release Date
2024.1 English

The following graph control API shows how to run the graph infinitely.

#include "project.h"
simpleGraph mygraph;

int main(void) {
  mygraph.init();  // load the graph;   // start the graph and return to main
  return 0;

A graph object mygraph is declared using a pre-defined graph class called simpleGraph. Then, in the main application, this graph object is initialized and run. The init() method loads the graph to the AI Engine array at prespecified AI Engine tiles. This includes loading the ELF binaries for each AI Engine, configuring the stream switches for routing, and configuring the DMAs for I/O. It leaves the processors in a disabled state. The run() method starts the graph execution by enabling the processors. This graph runs forever because the number of iterations to be run is not provided to the run() method.

graph::run() without an argument runs the AI Engine kernels for a previously specified number of iterations (which is infinity by default if the graph is run without any arguments). If the graph is run with a finite number of iterations, for example,; the second run call also runs for three iterations. Use graph::run(-1) to run the graph infinitely regardless of the previous run iteration setting.