flow/network: handle default endpoints correctly in _infer_plumbing_layout

This commit is contained in:
Sebastien Bourdeauducq 2012-06-16 22:41:15 +02:00
parent 9af87367eb
commit 98c9da95d1
1 changed files with 13 additions and 10 deletions

View File

@ -161,15 +161,22 @@ class DataFlowGraph(MultiDiGraph):
edges = self.in_edges(a, data=True) edges = self.in_edges(a, data=True)
assert(len(edges) == 1) assert(len(edges) == 1)
other, me, data = edges[0] other, me, data = edges[0]
if other.is_abstract():
continue
other_ep = data["source"] other_ep = data["source"]
if other_ep is None:
other_ep = other.actor.single_source()
elif a.actor_class in plumbing.layout_source: elif a.actor_class in plumbing.layout_source:
edges = self.out_edges(a, data=True) edges = self.out_edges(a, data=True)
assert(len(edges) == 1) assert(len(edges) == 1)
me, other, data = edges[0] me, other, data = edges[0]
if other.is_abstract():
continue
other_ep = data["sink"] other_ep = data["sink"]
if other_ep is None:
other_ep = other.actor.single_sink()
else: else:
raise AssertionError raise AssertionError
if not other.is_abstract():
layout = other.actor.token(other_ep).layout() layout = other.actor.token(other_ep).layout()
a.parameters["layout"] = layout a.parameters["layout"] = layout
a.instantiate() a.instantiate()
@ -184,13 +191,9 @@ class DataFlowGraph(MultiDiGraph):
# 3. resolve default eps # 3. resolve default eps
for u, v, d in self.edges_iter(data=True): for u, v, d in self.edges_iter(data=True):
if d["source"] is None: if d["source"] is None:
source_eps = u.actor.sources() d["source"] = u.actor.single_source()
assert(len(source_eps) == 1)
d["source"] = source_eps[0]
if d["sink"] is None: if d["sink"] is None:
sink_eps = v.actor.sinks() d["sink"] = v.actor.single_sink()
assert(len(sink_eps) == 1)
d["sink"] = sink_eps[0]
# Elaboration turns an abstract DFG into a concrete one. # Elaboration turns an abstract DFG into a concrete one.
# Pass 1: eliminate subrecords and divergences # Pass 1: eliminate subrecords and divergences