Skip to content
Snippets Groups Projects

Refactored ListScheduler, made it non-abstract and added better checks to...

Merged Simon Bjurek requested to merge refactor-list-scheduler into master
@@ -614,86 +614,109 @@ class TestHybridScheduler:
@@ -614,86 +614,109 @@ class TestHybridScheduler:
# This schedule that this test is checking against is faulty and will yield a non-working
# This schedule that this test is checking against is faulty and will yield a non-working
# fft implementation, however, it is kept commented out for reference
# fft implementation, however, it is kept commented out for reference
# def test_radix_2_fft_8_points_specified_IO_times_cyclic(self):
def test_radix_2_fft_8_points_specified_IO_times_cyclic(self):
# sfg = radix_2_dif_fft(points=8)
sfg = radix_2_dif_fft(points=8)
# sfg.set_latency_of_type(Butterfly.type_name(), 3)
sfg.set_latency_of_type(Butterfly.type_name(), 3)
# sfg.set_latency_of_type(ConstantMultiplication.type_name(), 2)
sfg.set_latency_of_type(ConstantMultiplication.type_name(), 2)
# sfg.set_execution_time_of_type(Butterfly.type_name(), 1)
sfg.set_execution_time_of_type(Butterfly.type_name(), 1)
# sfg.set_execution_time_of_type(ConstantMultiplication.type_name(), 1)
sfg.set_execution_time_of_type(ConstantMultiplication.type_name(), 1)
# resources = {
resources = {
# Butterfly.type_name(): 1,
Butterfly.type_name(): 1,
# ConstantMultiplication.type_name(): 1,
ConstantMultiplication.type_name(): 1,
# Input.type_name(): sys.maxsize,
Input.type_name(): sys.maxsize,
# Output.type_name(): sys.maxsize,
Output.type_name(): sys.maxsize,
# }
}
# input_times = {
input_times = {
# "in0": 0,
"in0": 0,
# "in1": 1,
"in1": 1,
# "in2": 2,
"in2": 2,
# "in3": 3,
"in3": 3,
# "in4": 4,
"in4": 4,
# "in5": 5,
"in5": 5,
# "in6": 6,
"in6": 6,
# "in7": 7,
"in7": 7,
# }
}
# output_times = {
output_times = {
# "out0": 0,
"out0": 0,
# "out1": 1,
"out1": 1,
# "out2": 2,
"out2": 2,
# "out3": 3,
"out3": 3,
# "out4": 4,
"out4": 4,
# "out5": 5,
"out5": 5,
# "out6": 6,
"out6": 6,
# "out7": 7,
"out7": 7,
# }
}
# schedule = Schedule(
schedule = Schedule(
# sfg,
sfg,
# scheduler=HybridScheduler(
scheduler=HybridScheduler(
# resources, input_times=input_times, output_delta_times=output_times
resources, input_times=input_times, output_delta_times=output_times
# ),
),
# schedule_time=20,
schedule_time=20,
# cyclic=True,
cyclic=True,
# )
)
# assert schedule.start_times == {
assert schedule.start_times == {
# "in0": 0,
"in0": 0,
# "in1": 1,
"in1": 1,
# "in2": 2,
"in2": 2,
# "in3": 3,
"in3": 3,
# "in4": 4,
"in4": 4,
# "in5": 5,
"in5": 5,
# "in6": 6,
"in6": 6,
# "in7": 7,
"in7": 7,
# "bfly0": 4,
"bfly0": 4,
# "bfly8": 5,
"bfly8": 5,
# "bfly11": 6,
"bfly11": 6,
# "bfly6": 7,
"bfly6": 7,
# "cmul2": 8,
"cmul2": 8,
# "cmul0": 9,
"cmul0": 9,
# "bfly1": 9,
"bfly1": 9,
# "cmul3": 10,
"cmul3": 10,
# "bfly7": 10,
"bfly7": 10,
# "bfly2": 11,
"bfly2": 11,
# "bfly5": 12,
"bfly5": 12,
# "cmul4": 13,
"cmul4": 13,
# "bfly9": 13,
"bfly9": 13,
# "bfly3": 15,
"bfly3": 15,
# "cmul1": 15,
"cmul1": 15,
# "bfly10": 16,
"bfly10": 16,
# "bfly4": 17,
"bfly4": 17,
# "out0": 17,
"out0": 17,
# "out1": 18,
"out1": 18,
# "out2": 19,
"out2": 19,
# "out3": 20,
"out3": 20,
# "out4": 1,
"out4": 1,
# "out5": 2,
"out5": 2,
# "out6": 3,
"out6": 3,
# "out7": 4,
"out7": 4,
# }
}
# assert schedule.schedule_time == 20
assert schedule.schedule_time == 20
# _validate_recreated_sfg_fft(schedule, 8)
 
# impulse input -> constant output
 
sim = Simulation(schedule.sfg, [Impulse()] + [0 for i in range(7)])
 
sim.run_for(2)
 
assert np.allclose(sim.results["0"], [1, 0])
 
assert np.allclose(sim.results["1"], [1, 0])
 
assert np.allclose(sim.results["2"], [1, 0])
 
assert np.allclose(sim.results["3"], [1, 0])
 
assert np.allclose(sim.results["4"], [0, 1])
 
assert np.allclose(sim.results["5"], [0, 1])
 
assert np.allclose(sim.results["6"], [0, 1])
 
assert np.allclose(sim.results["7"], [0, 1])
 
 
# constant input -> impulse (with weight=points) output
 
sim = Simulation(schedule.sfg, [Impulse() for i in range(8)])
 
sim.run_for(2)
 
assert np.allclose(sim.results["0"], [8, 0])
 
assert np.allclose(sim.results["1"], [0, 0])
 
assert np.allclose(sim.results["2"], [0, 0])
 
assert np.allclose(sim.results["3"], [0, 0])
 
assert np.allclose(sim.results["4"], [0, 0])
 
assert np.allclose(sim.results["5"], [0, 0])
 
assert np.allclose(sim.results["6"], [0, 0])
 
assert np.allclose(sim.results["7"], [0, 0])
def test_radix_2_fft_8_points_specified_IO_times_non_cyclic(self):
def test_radix_2_fft_8_points_specified_IO_times_non_cyclic(self):
sfg = radix_2_dif_fft(points=8)
sfg = radix_2_dif_fft(points=8)
Loading