Runtime Generator

Overview

The Runtime Generator (AKA RTG) is a complementary tool in the Audio Framework toolchain.

The purpose of the runtime generator is to take mapped graph and generate GAP C code, allowing the graph to execute on GAP hardware (or in gvsoc).

Arguments

Command

Short

Type

Explanation –

-input

-i

str

Input mapped graph file to generate code for. –

-outputdir

-o

str

Output directory. –

Usage

To run the Runtime Generator on a mapped graph, do as follows:

./runtime_generator -i my_mapped_graph.mt.graph -o output

This will generate graph source, build files and a simple test program in the folder named output.

Test

To test, execute the test suites:

./tests/tests_rtg.py

That will execute all RTG tests, including:

  • Regression test on code generation

  • Regression test on templating files

  • Full end2end test: Generate code, build it, run the test, verify the output.

Operation

The RTG work as follows:

../../../../../_images/rtg_overview.drawio.png

RTG consists of the following modules:

runtime_generator/
├─ runtime_generator.py        - Main application entry point
├─ src/
│  ├─ content_writer.py        - Generic code generation module
│  ├─ code_elements.py         - Graph specific code elements and definitions
│  ├─ component_deps.py        - List of specific component dependencies not captured by mapping tool (yet)  ├─ templating.py            - Templating functions for build and test files
│  ├─ rtg_utils.py             - Various helpers for RTG
│  ├─ runtime_generator.py     - Class which will parse graph and trigger code generation using above modules

Upon execution, RTG will parse the graph and initialize any nescessary code elements (function prototypes, struct types, names, etc). Afterwards, rtg will begin to generate code matching the default audio framework graph API:

component_my_graph *my_graph_construct();
void                my_graph_destruct(component *component_head);
void                my_graph_init(component *component_head);
gwt_audio_errors    my_graph_set_parameter(component *component_head, my_graph_configuration *my_graph_configuration);
void                my_graph_start(component *component_head);
int32_t             my_graph_wait_for_completion(component *component_head);

Code is generated using graph specific C code defined in code_elements and generic C code from ContentWriter.

Once all graph code is generated, the templating functions are used to generate build files (CMakelists.txt, Kconfig, etc) as well as a simple test program. The test program is simiilar to the programs used to test components.