Core concepts
Compiler Plugins
In the following sections, we want to discuss how the Co-Pilot connects to compilers.
Lifting of Stateful Dataflow Multigraphs
Our Co-Pilot speaks the language of compilers, which is the intermediate representation (IR)
of programs. To apply powerful data-centric analysis, the Co-Pilot uses a specific IR called stateful dataflow multigraph (SDFG). Since programs are usually not directly written as an SDFG, this representation must be translated directly from another IR or the source code. In many cases, the SDFG contains richer information than the original representation. That's why this translation is also called lifting
.
Partial Lifting
Many parts of a program are usually not performance-critical. For instance, calls to external functions or interactions with the user are usually less attractive for optimization. However, such parts of the code are hard to analyze since they are impure
. If the program uses many impurities, a good strategy is partial lifting
, where only performance-critical parts of the code are translated into an SDFG and optimized by the Co-Pilot.
With this method, suitable regions of the program, so-called Single-Entry-Single-Exit (SESE) regions
, are detected and lifted. The lifted SDFGs are then compiled into an optimized library and the original regions are replaced by function calls to this library.
Translation
The second strategy is translating the original source code to an SDFG. For this approach to work, organizing the source code into modules, which should be optimized and others, is a good practice. We can then translate the relevant modules with one of DaCe's frontends and optimize it with the Co-Pilot. The optimized parts are again compiled into libraries and must be linked to the other parts later.