Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
phschaad committed Dec 11, 2024
1 parent e2a6466 commit 6f82fc6
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 26 deletions.
1 change: 0 additions & 1 deletion dace/sdfg/replace.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from dace import dtypes, properties, symbolic
from dace.codegen import cppunparse
from dace.frontend.python.astutils import ASTFindReplace
from dace.sdfg.state import ConditionalBlock, ControlFlowRegion, LoopRegion

if TYPE_CHECKING:
from dace.sdfg.state import StateSubgraphView
Expand Down
6 changes: 3 additions & 3 deletions dace/transformation/passes/pattern_matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def apply_pass(self, sdfg: SDFG, pipeline_results: Dict[str, Any]) -> Dict[str,
'not have `SDFG.using_explicit_control_flow` set to True. If ' +
xform.__class__.__name__ + ' is compatible with experimental blocks, ' +
'please annotate it with the class decorator ' +
'`@dace.transformation.experimental_cfg_block_compatible`. see ' +
'`@dace.transformation.explicit_cf_compatible`. see ' +
'`https://github.com/spcl/dace/wiki/Experimental-Control-Flow-Blocks` ' +
'for more information.')
continue
Expand Down Expand Up @@ -227,7 +227,7 @@ def _apply_pass(self, sdfg: SDFG, pipeline_results: Dict[str, Any], apply_once:
'not have `SDFG.using_explicit_control_flow` set to True. If ' +
xform.__class__.__name__ + ' is compatible with experimental blocks, ' +
'please annotate it with the class decorator ' +
'`@dace.transformation.experimental_cfg_block_compatible`. see ' +
'`@dace.transformation.explicit_cf_compatible`. see ' +
'`https://github.com/spcl/dace/wiki/Experimental-Control-Flow-Blocks` ' +
'for more information.')
continue
Expand Down Expand Up @@ -419,7 +419,7 @@ def _try_to_match_transformation(graph: Union[ControlFlowRegion, SDFGState], col
'not have `SDFG.using_explicit_control_flow` set to True. If ' +
match.__class__.__name__ + ' is compatible with experimental blocks, ' +
'please annotate it with the class decorator ' +
'`@dace.transformation.experimental_cfg_block_compatible`. see ' +
'`@dace.transformation.explicit_cf_compatible`. see ' +
'`https://github.com/spcl/dace/wiki/Experimental-Control-Flow-Blocks` ' +
'for more information.')
return None
Expand Down
13 changes: 1 addition & 12 deletions dace/transformation/passes/scalar_to_symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,18 +235,7 @@ def find_promotable_scalars(sdfg: sd.SDFG, transients_only: bool = True, integer
for edge in sdfg.all_interstate_edges():
interstate_symbols |= edge.data.free_symbols
for reg in sdfg.all_control_flow_regions():
if isinstance(reg, LoopRegion):
interstate_symbols |= reg.loop_condition.get_free_symbols()
if reg.loop_variable:
interstate_symbols.add(reg.loop_variable)
if reg.update_statement:
interstate_symbols |= reg.update_statement.get_free_symbols()
if reg.init_statement:
interstate_symbols |= reg.init_statement.get_free_symbols()
elif isinstance(reg, ConditionalBlock):
for c, _ in reg.branches:
if c is not None:
interstate_symbols |= c.get_free_symbols()
interstate_symbols |= reg.used_symbols(all_symbols=True, with_contents=False)
for candidate in (candidates - interstate_symbols):
if integers_only and sdfg.arrays[candidate].dtype not in dtypes.INTEGER_TYPES:
candidates.remove(candidate)
Expand Down
10 changes: 5 additions & 5 deletions dace/transformation/subgraph/gpu_persistent_fusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,11 @@ def apply(self, sdfg: SDFG):
if k in sdfg.symbols and k not in kernel_sdfg.symbols:
kernel_sdfg.add_symbol(k, sdfg.symbols[k])
for blk in subgraph_blocks:
if isinstance(blk, LoopRegion):
if blk.loop_variable and blk.init_statement:
new_symbols.add(blk.loop_variable)
if blk.loop_variable in sdfg.symbols and blk.loop_variable not in kernel_sdfg.symbols:
kernel_sdfg.add_symbol(blk.loop_variable, sdfg.symbols[blk.loop_variable])
if isinstance(blk, AbstractControlFlowRegion):
for k, v in blk.new_symbols(sdfg.symbols).items():
new_symbols.add(k)
if k not in kernel_sdfg.symbols:
kernel_sdfg.add_symbol(k, v)

# Setting entry node in nested SDFG if no entry guard was created
if entry_guard_state is None:
Expand Down
8 changes: 4 additions & 4 deletions doc/frontend/parsing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ Example:
:alt: Generated SDFG for-loop for the above Data-Centric Python program

If the :class:`~dace.frontend.python.parser.DaceProgram`'s
:attr:`~dace.frontend.python.parser.DaceProgram.use_experimental_cfg_blocks` attribute is set to true, this will utilize
:attr:`~dace.frontend.python.parser.DaceProgram.use_explicit_control_flow` attribute is set to true, this will utilize
:class:`~dace.sdfg.state.LoopRegion`s instead of the explicit state machine depicted above.
:func:`~dace.frontend.python.newast.ProgramVisitor.visit_While`
Expand All @@ -191,7 +191,7 @@ Parses `while <https://docs.python.org/3/library/ast.html#ast.While>`_ statement
:alt: Generated SDFG while-loop for the above Data-Centric Python program

If the :class:`~dace.frontend.python.parser.DaceProgram`'s
:attr:`~dace.frontend.python.parser.DaceProgram.use_experimental_cfg_blocks` attribute is set to true, this will utilize
:attr:`~dace.frontend.python.parser.DaceProgram.use_explicit_control_flow` attribute is set to true, this will utilize
:class:`~dace.sdfg.state.LoopRegion`s instead of the explicit state machine depicted above.
:func:`~dace.frontend.python.newast.ProgramVisitor.visit_Break`
Expand All @@ -214,7 +214,7 @@ behaves as an if-else statement. This is also evident from the generated dataflo
:alt: Generated SDFG for-loop with a break statement for the above Data-Centric Python program

If the :class:`~dace.frontend.python.parser.DaceProgram`'s
:attr:`~dace.frontend.python.parser.DaceProgram.use_experimental_cfg_blocks` attribute is set to true, loops are
:attr:`~dace.frontend.python.parser.DaceProgram.use_explicit_control_flow` attribute is set to true, loops are
represented with :class:`~dace.sdfg.state.LoopRegion`s, and a break is represented with a special
:class:`~dace.sdfg.state.LoopRegion.BreakState`.

Expand All @@ -238,7 +238,7 @@ of `continue` makes the ``A[i] = i`` statement unreachable. This is also evident
:alt: Generated SDFG for-loop with a continue statement for the above Data-Centric Python program

If the :class:`~dace.frontend.python.parser.DaceProgram`'s
:attr:`~dace.frontend.python.parser.DaceProgram.use_experimental_cfg_blocks` attribute is set to true, loops are
:attr:`~dace.frontend.python.parser.DaceProgram.use_explicit_control_flow` attribute is set to true, loops are
represented with :class:`~dace.sdfg.state.LoopRegion`s, and a continue is represented with a special
:class:`~dace.sdfg.state.LoopRegion.ContinueState`.

Expand Down
2 changes: 1 addition & 1 deletion tests/sdfg/work_depth_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def test_avg_par(test_name: str):
# NOTE: Until the W/D Analysis is changed to make use of the new blocks, inline control flow for the analysis.
inline_control_flow_regions(sdfg)
for sd in sdfg.all_sdfgs_recursive():
sd.using_experimental_blocks = False
sd.using_explicit_control_flow = False

analyze_sdfg(sdfg, w_d_map, get_tasklet_avg_par, [], False)
res = w_d_map[get_uuid(sdfg)][0] / w_d_map[get_uuid(sdfg)][1]
Expand Down

0 comments on commit 6f82fc6

Please sign in to comment.