Flowgraphs [Experimental]#

Primary APIs#

pystencils.flow.operator(func=None, /, preds=None, name=None, ispace=None, config=None, **kwargs)#
Overloads:
  • preds (Iterable[FlowgraphNode] | None), name (str | None), ispace (PatchSliceSpec | PatchSlice | None), config (CreateKernelConfig | None), kwargs → Callable[[FlowgraphNode | _SingleBlockOperatorFunc | _ComplexGraphOperatorFunc], Operator]

  • func (_SingleBlockOperatorFunc | _ComplexGraphOperatorFunc) → Operator

Parameters:
pystencils.flow.block(func=None, /, preds=None, name=None)#

Define a flowgraph block using let syntax.

Overloads:
  • preds (Iterable[FlowgraphNode] | None), name (str | None) → Callable[[Callable[[EquationsBlockBuilder], None]], EquationsBlock]

  • func (Callable[[EquationsBlockBuilder], None]) → EquationsBlock

Parameters:

block is a decorator used to define flowgraph blocks using Python function syntax.

Parameters:
pystencils.flow.guarded_block(cond, *, preds=None, name=None)#

Define a guarded block that is protected by a condition.

Return type:

Callable[[Callable[[EquationsBlockBuilder], None]], EquationsBlock | Cases]

Parameters:
pystencils.flow.cases(func=None, /, preds=None, name=None)#

Define a flowgraph cases block.

Overloads:
  • preds (Iterable[FlowgraphNode] | None), name (str | None) → Callable[[Callable[[CasesBuilder], None]], Cases]

  • func (Callable[[CasesBuilder], None]) → Cases

Parameters:

cases is a decorator used to define flowgraph case blocks using Python function syntax.

pystencils.flow.tie(*nodes, name=None)#

Tie multiple nodes together into a flowgraph

Return type:

Flowgraph

Parameters:
pystencils.flow.subgraph(*args, preds=(), name=None)#
Overloads:
  • graph (Flowgraph), preds (Sequence[FlowgraphNode]) → Subgraph

  • nodes (FlowgraphNode), preds (Sequence[FlowgraphNode]), name (str | None) → Subgraph

Parameters:
Return type:

Subgraph

pystencils.flow.guarded_subgraph(cond, *, preds=None, name=None)#

Create a guarded subgraph.

guarded_subgraph is a function decorator; the decorated function should constuct and return the output nodes of the guarded graph.

Example:

@ps.flow.guarded_subgraph(condition)
def mygraph():
    # ... define subgraph

    #   return output nodes
    return block1, block2
Parameters:

Flowgraph Nodes#

Inheritance Diagram#

Inheritance diagram of pystencils.flow.flowgraph

Classes#

pystencils.flow.flowgraph.SymbolicMemoryLoc = pystencils.field.Field.Access | pystencils.sympyextensions.pointers.mem_acc | pystencils.grids.protocols.IFieldAccess#

Expression types that are valid memory locations and can be used on the LHS of Store.

Flowgraph

A closed flowgraph in canonical form.

FlowgraphAssignment

Base class for assignments.

Let

Let assignments define subexpressions to be used within the same EquationsBlock.

Export

Export assignments define subexpressions that can be used within the same EquationsBlock and its direct successors in the flowgraph.

Store

Store assignments represent writing a value to an abstract memory location.

Reduce

Reduce assignments perform reductions onto a target typed symbol with a given operation.

FlowgraphNode

Base class for data-flow graph nodes in pystencils.flow.

Top

A flowgraph's top node.

Bottom

A flowgraph's bottom node.

EquationsBlock

A block of symbol assignments in static single-assignment form.

Subgraph

Another flowgraph embedded as a subgraph.

Cases

Case distinction.

Builders#

EquationsBlockBuilder

Builder for equation blocks.

CasesBuilder

Canonicalization#

CanonicalizeFlowgraph

Check a flowgraph for consistency and transform it into canonical form.

CanonicalizationResult

Result of the flowgraph canonicalizer

CanonicalizationError

Indicates that a flowgraph violates a canonicality condition.