Peano
Loading...
Searching...
No Matches
peano4.api.taskgraph.compiler.Sequential Namespace Reference

Functions

List["peano4.api.solversteps.Step"] translate (Graph graph, str identifier, "peano4.api.Project" peano_project)
 Simplest possible task graph compiler.
 

Function Documentation

◆ translate()

List["peano4.api.solversteps.Step"] peano4.api.taskgraph.compiler.Sequential.translate ( Graph  graph,
str  identifier,
"peano4.api.Project"  peano_project 
)

Simplest possible task graph compiler.

Linearises the task graph into one mesh traversal (Observer) per task, in an order that respects every dependency: a task's Observer always comes after the Observers of all tasks it depends on. This throws away any parallelism the task graph might encode - it is the "no fusion, no reordering" baseline compiler that smarter compilers can be measured against.

Implementation

A straightforward, direct mapping: graph.ordered_tasks() linearises the graph's tasks into a valid topological order (a task always comes after every task it depends on -

See also
Graph.ordered_tasks() for how), and every task in that order becomes exactly one Observer, populated with that task's action sets and the cell/face/vertex data it declared via use_cell()/use_face()/use_vertex().

Note that this function no longer derives any further use_cell()/ use_face()/use_vertex() declarations itself - that is the job of peano4.api.taskgraph.compiler.PropagateUseStatements.propagate_use_statements(), which has to run before translate() (it reasons about tasks, not the Steps translate() produces here, and about the composability of several graphs at once, which a single graph's own translate() call cannot see). By the time translate() runs, every task already carries every use_cell()/use_face()/use_vertex() declaration it will ever need.

A peano4.api.Logger().new_section() call brackets the translation, and peano4.api.taskgraph.compiler.ReportCompiledStepSequence.report_compiled_step_sequence() reports its outcome right after - a textual listing of the resulting sequence and its action sets under LoggerVerbosity.TEXT, or a flow chart in the same style as Graph.visualise() under LoggerVerbosity.VISUALISATION.

Parameters
graphpeano4.api.taskgraph.Graph The task graph to linearise. Assumed to be acyclic - translate() does not check for cycles and will recurse indefinitely on one.
identifierstr Identifies which of the surrounding project's algorithmic phases this graph belongs to (e.g. "SetupSimulation", "TimeStep", "Plot"). Every generated Observer's name is prefixed with this identifier, joined by an underscore, so Observers coming from different phases never clash even if their tasks happen to share a name.
peano_projectpeano4.api.Project Not used by this compiler. peano4.api.taskgraph.compiler
Returns
[peano4.api.solversteps.Step] One Observer per task, ordered so that every task's Observer comes after the Observers of all tasks it depends on, carrying that task's action_sets (in the order they were added to the Task) plus the cell/face/vertex data use_cell()/use_face()/use_vertex() determined. Each Step's cell_data_access/face_data_access/vertex_data_access is also populated as a copy of the originating Task's, purely for reporting (
See also
peano4.api.taskgraph.compiler.ReportCompiledStepSequence) - nothing about the generated Observer depends on it.

Definition at line 13 of file Sequential.py.