The following directory structure and coding practices are recommended for organizing your AI Engine projects to provide clarity and reuse.
- All adaptive data flow (ADF) graph class definitions, that is, all
the ADF graphs that are derived from graph class
adf::graph, must be located in a header file. Multiple ADF graph definitions can be included in the same header file. This class header file should be included in themainapplication file where the actual top-level graph is declared in the file scope. - There should be no dependencies on the order that the header files are included. All header files must be self-contained and include all the other header files that they need.
- There should be no file scoped variable or data-structure
definitions in the graph header files. Any definitions (including
static) must be declared in a separate source file that can be identified in theheaderproperty of the kernel where they are referenced (see Look-up Tables). - There is no need to declare the kernels under
extern "C" {...}. However, this declaration can be used in an application meant to run full-program simulation, but it must adhere to the following conditions:- If the kernel-function declaration is wrapped with
extern "C", then the definition must know about it. This can be done by either including the header file inside the definition file, or wrapping the definition withextern "C". - The
extern "C"must be wrapped with#ifdef __cplusplus. This is synonymous to howextern "C"is used in stdio.h.
- If the kernel-function declaration is wrapped with
- Only one source file is allowed to be specified as kernel source via
adf::source. When sub-functions are defined as a library in separate source files (for example,util.hppandutil.cpp), the workaround is to:- Include all the library source files in a header file (for example,
lib.hpp):#pragma once #include <util.hpp> #include <util.cpp> - And then include the header file
lib.hppin the kernel source file.
- Include all the library source files in a header file (for example,