Пример #1
0
    def from_clusters(cls, *clusters):
        """
        Build a new Cluster from a sequence of pre-existing Clusters with
        compatible IterationSpace.
        """
        assert len(clusters) > 0
        root = clusters[0]
        if not all(root.ispace.is_compatible(c.ispace) for c in clusters):
            raise ValueError("Cannot build a Cluster from Clusters with "
                             "incompatible IterationSpace")
        if not all(root.guards == c.guards for c in clusters):
            raise ValueError("Cannot build a Cluster from Clusters with "
                             "non-homogeneous guards")

        exprs = chain(*[c.exprs for c in clusters])
        ispace = IterationSpace.union(*[c.ispace for c in clusters])
        dspace = DataSpace.union(*[c.dspace for c in clusters])

        guards = root.guards

        properties = {}
        for c in clusters:
            for d, v in c.properties.items():
                properties[d] = normalize_properties(properties.get(d, v), v)

        try:
            syncs = normalize_syncs(*[c.syncs for c in clusters])
        except ValueError:
            raise ValueError("Cannot build a Cluster from Clusters with "
                             "non-compatible synchronization operations")

        return Cluster(exprs, ispace, dspace, guards, properties, syncs)
Пример #2
0
 def from_clusters(cls, *clusters):
     """
     Build a new Cluster from a sequence of pre-existing Clusters with
     compatible IterationSpace.
     """
     assert len(clusters) > 0
     root = clusters[0]
     assert all(root.ispace.is_compatible(c.ispace) for c in clusters)
     exprs = chain(*[c.exprs for c in clusters])
     ispace = IterationSpace.union(*[c.ispace for c in clusters])
     dspace = DataSpace.union(*[c.dspace for c in clusters])
     return Cluster(exprs, ispace, dspace)
Пример #3
0
 def from_clusters(cls, *clusters):
     """
     Build a new Cluster from a sequence of pre-existing Clusters with
     compatible IterationSpace.
     """
     assert len(clusters) > 0
     root = clusters[0]
     if not all(root.ispace.is_compatible(c.ispace) for c in clusters):
         raise ValueError("Cannot build a Cluster from Clusters with "
                          "incompatible IterationSpace")
     if not all(root.properties == c.properties for c in clusters):
         raise ValueError("Cannot build a Cluster from Clusters with "
                          "non-homogeneous properties")
     exprs = chain(*[c.exprs for c in clusters])
     ispace = IterationSpace.union(*[c.ispace for c in clusters])
     dspace = DataSpace.union(*[c.dspace for c in clusters])
     return Cluster(exprs, ispace, dspace, properties=root.properties)
Пример #4
0
 def dspace(self):
     """Return the DataSpace of this ClusterGroup."""
     return DataSpace.union(*[i.dspace.reset() for i in self])