axis_merge
CartesianAxisMerge
Bases: ScheduleNodeTransformer
Merge a cartesian axis if they are contiguous in code-flow.
Can do
- merge a given axis with the next maps at the same recursion level
- can overcompute to allow for more merging at the cost of an if
It expects
- All Maps and ForLoop are on a single axis - but doesn't check for it.
This pass has been designed to work in coordination with OffGridConditional and
OffGridTasklet passes to allow to align maps for merge
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
axis
|
AxisIterator
|
AxisIterator to be merged |
required |
overcompute
|
bool
|
merge at the cost of an if statement. |
required |
visit_ScheduleTreeRoot(node)
Merge consecutive maps of the same cartesian axis.
Dev NOTE: this pass has been implemented in coordination with the rest of the passes
deployed in CartesianMerge. Some of the other passes aim to surface maps in a way to maximize
the efficiency of this pass.
The algorithm works as follows
- Try to merge the surfaced maps
- When done, count the number of actual merges
- If NO merges - restore the previous children (undo potential changes that didn't lead to map merge)
- If merges - go again since we have modified the tree Then exit.
ToDo
- ForLoop are not merge at the moment, only Maps.
- Non-cartesian ForLoop could be merged down if the maps below are unique (e.g. if everything has been merged) and the hint is PARALLEL. This is relevant for linear solvers and other iteration-dependent algorithmics
InsertOvercomputationGuard
Bases: ScheduleNodeTransformer
Recurse down the cartesian-block of maps before patching the inner maps with the if-guard.
Recursing down allows to surface the maps for more subsequent merging. Recursing down also ensures that maximum parallelization is conserved.