Skip to content
Snippets Groups Projects
Commit 5580dc74 authored by Mikael Henriksson's avatar Mikael Henriksson :runner:
Browse files

add max and min lifetime plot test, and multi-read memory variable test (closes #245)

parent d1af9c2e
No related branches found
No related tags found
1 merge request!361add max and min lifetime plot test, and multi-read memory variable test (closes #245)
Pipeline #96848 passed
......@@ -550,8 +550,8 @@ class ProcessCollection:
else bar_start % self._schedule_time
)
bar_end = (
bar_end
if bar_end == self._schedule_time
self.schedule_time
if bar_end and bar_end % self._schedule_time == 0
else bar_end % self._schedule_time
)
if show_markers:
......@@ -564,8 +564,8 @@ class ProcessCollection:
)
for end_time in process.read_times:
end_time = (
end_time
if end_time == self._schedule_time
self.schedule_time
if end_time and end_time % self.schedule_time == 0
else end_time % self._schedule_time
)
_ax.scatter( # type: ignore
......@@ -583,15 +583,19 @@ class ProcessCollection:
color=_WARNING_COLOR,
)
elif process.execution_time == 0:
# Execution time zero, don't draw the bar
pass
# Execution time zero, draw a slim bar
_ax.broken_barh( # type: ignore
[(PAD_L + bar_start, bar_end - bar_start - PAD_L - PAD_R)],
(bar_row + 0.55, 0.9),
color=bar_color,
)
elif bar_end > bar_start:
_ax.broken_barh( # type: ignore
[(PAD_L + bar_start, bar_end - bar_start - PAD_L - PAD_R)],
(bar_row + 0.55, 0.9),
color=bar_color,
)
else: # bar_end < bar_start
else: # bar_end <= bar_start
_ax.broken_barh( # type: ignore
[
(
......@@ -1224,7 +1228,7 @@ class ProcessCollection:
Forward-Backward Register Allocation [1].
[1]: K. Parhi: VLSI Digital Signal Processing Systems: Design and
Implementation, Ch. 6.3.2
Implementation, Ch. 6.3.2
Parameters
----------
......
test/baseline/test_max_min_lifetime_bar_plot.png

10.8 KiB

import pickle
import re
import matplotlib.pyplot as plt
......@@ -145,3 +144,57 @@ class TestProcessCollectionPlainMemoryVariable:
simple_collection.remove_process(new_proc)
assert len(simple_collection) == 7
assert new_proc not in simple_collection
@pytest.mark.mpl_image_compare(style='mpl20')
def test_max_min_lifetime_bar_plot(self):
fig, ax = plt.subplots()
collection = ProcessCollection(
{
# Process starting exactly at scheudle start
PlainMemoryVariable(0, 0, {0: 0}, "S1"),
PlainMemoryVariable(0, 0, {0: 5}, "S2"),
# Process starting somewhere between schedule start and end
PlainMemoryVariable(2, 0, {0: 0}, "M1"),
PlainMemoryVariable(2, 0, {0: 5}, "M2"),
# Process starting at the schedule end
PlainMemoryVariable(5, 0, {0: 0}, "E1"),
PlainMemoryVariable(5, 0, {0: 5}, "E2"),
},
schedule_time=5,
)
collection.plot(ax)
return fig
def test_multiple_reads_exclusion_greaph(self):
# Initial collection
p0 = PlainMemoryVariable(0, 0, {0: 3}, 'P0')
p1 = PlainMemoryVariable(1, 0, {0: 2}, 'P1')
p2 = PlainMemoryVariable(2, 0, {0: 2}, 'P2')
p3 = PlainMemoryVariable(3, 0, {0: 3}, 'P3')
collection = ProcessCollection({p0, p1, p2, p3}, 5, cyclic=True)
exclusion_graph = collection.create_exclusion_graph_from_ports(
read_ports=1,
write_ports=1,
total_ports=1,
)
for p in [p0, p1, p2, p3]:
assert p in exclusion_graph
assert exclusion_graph.degree(p0) == 2
assert exclusion_graph.degree(p1) == 2
assert exclusion_graph.degree(p2) == 0
assert exclusion_graph.degree(p3) == 2
# Add multi-read process
p4 = PlainMemoryVariable(0, 0, {0: 1, 1: 2, 2: 3, 3: 4}, 'P4')
collection.add_process(p4)
exclusion_graph = collection.create_exclusion_graph_from_ports(
read_ports=1,
write_ports=1,
total_ports=1,
)
for p in [p0, p1, p2, p3, p4]:
assert p in exclusion_graph
assert exclusion_graph.degree(p0) == 3
assert exclusion_graph.degree(p1) == 3
assert exclusion_graph.degree(p2) == 1
assert exclusion_graph.degree(p3) == 3
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment