Shared Graph-Scoped Tables - 2024.1 English

AI Engine-ML Kernel and Graph Programming Guide (UG1603)

Document ID
Release Date
2024.1 English

Sometimes, the same table definition is used in multiple kernels. Because the AI Engine-ML architecture is a distributed address-space architecture, each processor binary image that executes such a kernel needs to have that table defined in its own local memory. To get the correct graph linkage spread across multiple processors, you must declare the tables as extern within the kernel source file as well as the graph class definition file. Then, the actual table definition needs to be specified in a separate header file that is attached as a property to the kernel as shown below.

#include <adf.h>
extern int16 lutarray[8];
class simple_lut_graph : public adf::graph {
  kernel k;
  parameter p;

  simple_lut_graph() {
    k = kernel::create(simple);
    p = parameter::array(lutarray);

    std::vector<std::string> myheaders;
    headers(k) = myheaders;

This ensures that the header file that defines the table is included in the final binary link wherever this kernel is used without causing re-definition errors.

Note: Large lookup tables (>64 KB) are not supported.
Note: Shared data either has to be managed explicitly as runtime parameters or declared at the file scope, which is shared across all kernels mapped to the same AI Engine-ML.