# devito.ir.clusters package¶

## devito.ir.clusters.algorithms module¶

devito.ir.clusters.algorithms.clusterize(exprs)[source]

Group a sequence of :class:ir.Eqs into one or more :class:Clusters.

devito.ir.clusters.algorithms.groupby(clusters)[source]

Attempt grouping :class:PartialClusters together to create bigger :class:PartialClusters (i.e., containing more expressions).

Note

This function relies on advanced data dependency analysis tools based upon classic Lamport theory.

## devito.ir.clusters.cluster module¶

class devito.ir.clusters.cluster.Cluster(exprs, ispace, dspace, atomics=None, guards=None)[source]

Bases: devito.ir.clusters.cluster.PartialCluster

A Cluster is an immutable PartialCluster.

dspace
exprs
functions
is_dense
is_sparse
ispace
rebuild(exprs)[source]

Build a new cluster with expressions exprs having same iteration space and atomics as self.

squash(other)[source]

Concatenate the expressions in other to those in self. self and other must have same ispace. Duplicate expressions are dropped. The DataSpace is updated accordingly.

trace
class devito.ir.clusters.cluster.ClusterGroup[source]

Bases: list

An iterable of :class:PartialClusters.

dspace

Return the cumulative DataSpace of this ClusterGroup.

dtype

Return the arithmetic data type of this ClusterGroup. If at least one Cluster is performing floating point arithmetic, then any Cluster performing integer arithmetic is ignored. If two Clusters are performing floating point calculations with different precision, return the data type with highest precision.

finalize()[source]

Return a new ClusterGroup in which all of self’s PartialClusters have been turned into actual Clusters.

meta

Return the metadata carried by this ClusterGroup, a 2-tuple consisting of data type and data space.

unfreeze()[source]

Return a new ClusterGroup in which all of self’s Clusters have been promoted to PartialClusters. Any metadata attached to self is lost.

## devito.ir.clusters.graph module¶

class devito.ir.clusters.graph.FlowGraph(exprs, **kwargs)[source]

Bases: collections.OrderedDict

A FlowGraph represents an ordered sequence of operations. Operations, of type Node, are the nodes of the graph. An edge from n0 to n1 indicates that n1 reads from n0. For example, the sequence:

temp0 = a*b
temp1 = temp0*c
temp2 = temp0*d
temp3 = temp1 + temp2


is represented by the following FlowGraph:

temp0 ---> temp1
|          |
|          |
v          v
temp2 ---> temp3


The input and output edges of a node n are encoded in n.reads and n.readby, respectively.

Operations may involve scalars and indexed objects (arrays). The indices of the indexed objects represent either “space” or “time” dimensions.

extract(key, readby=False)[source]

Return the list of nodes appearing in key.reads, in program order (ie, based on the order in which the nodes appear in self). If readby is True, then return instead the list of nodes appearing key.readby, in program order.

Given the following sequence of operations:

t1 = ...
t0 = ...
u[i, j] = ... v ...
u[3, j] = ...
v = t0 + t1 + u[z, k]
t2 = ...


Assuming key == v and readby is False (as by default), return the following list of Node objects:

[t1, t0, u[i, j], u[3, j]]


If readby is True, return:

[v, t2]

is_index(key)[source]

Return True if key is used as array index in an expression of the FlowGraph, False otherwise.

tensors

Return all occurrences of the tensors in self keyed by function.

time_invariant(expr=None)[source]

Check if expr is time invariant. expr may be an expression e explicitly tracked by the FlowGraph or even a generic subexpression of e. If no expr is provided, then time invariance of the entire FlowGraph is assessed.

trace(key, readby=False, strict=False)[source]

Return the sequence of operations required to compute the node key. If readby = True, then return the sequence of operations that will depend on key, instead. With strict = True, drop key from the result.

unknown

Return all symbols appearing in self for which a node is not available.