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 {
public:
kernel k;
parameter p;
simple_lut_graph() {
k = kernel::create(simple);
p = parameter::array(lutarray);
connect(p,k);
std::vector<std::string> myheaders;
myheaders.push_back("./user_parameter.h");
headers(k) = myheaders;
location<parameter>(p)={address(0,1,0x1000)};
...
}
}
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.