LDLT matrix inversion algorithm

This provides some examples of the different list-based schedulers that are available in B-ASIC.

from b_asic.architecture import Memory, ProcessingElement
from b_asic.core_operations import MADS, Reciprocal
from b_asic.list_schedulers import (
    EarliestDeadlineScheduler,
    HybridScheduler,
    LeastSlackTimeScheduler,
    MaxFanOutScheduler,
)
from b_asic.schedule import Schedule
from b_asic.scheduler import ALAPScheduler, ASAPScheduler
from b_asic.sfg_generators import ldlt_matrix_inverse
from b_asic.special_operations import Input, Output

sfg = ldlt_matrix_inverse(N=3)

The SFG is

sfg
%3 in0 in0 rec0 rec0 in0->rec0 rec0.0 rec0->rec0.0 in1 in1 in1.0 in1->in1.0 mads0 mads0 in1.0->mads0 1 mads14 mads14 in1.0->mads14 1 mads13 mads13 in1.0->mads13 1 mads0.0 mads0->mads0.0 rec1 rec1 mads14->rec1 mads13.0 mads13->mads13.0 in2 in2 in2.0 in2->in2.0 mads1 mads1 in2.0->mads1 1 mads12 mads12 in2.0->mads12 1 mads1.0 mads1->mads1.0 mads10 mads10 mads12->mads10 0 in3 in3 in3->mads14 0 in4 in4 in4->mads13 0 in5 in5 in5->mads12 0 out0 out0 mads4 mads4 mads4->out0 out1 out1 mads5.0 mads5.0->mads4 2 mads5.0->out1 mads5 mads5 mads5->mads5.0 out2 out2 mads3.0 mads3.0->out2 mads2 mads2 mads3.0->mads2 2 mads3 mads3 mads3->mads3.0 out3 out3 mads7.0 mads7.0->mads5 2 mads7.0->out3 mads7 mads7 mads7->mads7.0 out4 out4 mads9.0 mads9.0->mads3 2 mads9.0->mads7 2 mads9.0->out4 mads6 mads6 mads9.0->mads6 2 mads9 mads9 mads9->mads9.0 out5 out5 rec2.0 rec2.0->mads9 2 rec2.0->out5 mads11 mads11 rec2.0->mads11 2 rec2 rec2 rec2->rec2.0 rec0.0->mads0 2 rec0.0->mads1 2 rec0.0->mads2 0 mads2->mads4 0 mads1.0->mads13 2 mads1.0->mads12 2 mads1.0->mads2 1 mads1.0->mads6 1 mads1.0->mads11 1 mads0.0->mads14 2 mads0.0->mads4 1 mads0.0->mads5 1 mads0.0->mads3 1 mads6->mads5 0 rec1.0 rec1.0->mads7 0 mads8 mads8 rec1.0->mads8 2 rec1->rec1.0 mads8.0 mads8.0->mads7 1 mads8.0->mads9 1 mads8.0->mads10 2 mads8->mads8.0 dontcare0 dontcare0 dontcare0->mads9 0 mads10->rec2 mads11->mads3 0 dontcare1 dontcare1 dontcare1->mads11 0 mads13.0->mads8 1 mads13.0->mads10 1 dontcare2 dontcare2 dontcare2->mads8 0 dontcare3 dontcare3 dontcare3->mads6 0 dontcare4 dontcare4 dontcare4->mads1 0 dontcare5 dontcare5 dontcare5->mads0 0


Set latencies and execution times.

sfg.set_latency_of_type(MADS, 3)
sfg.set_latency_of_type(Reciprocal, 2)
sfg.set_execution_time_of_type(MADS, 1)
sfg.set_execution_time_of_type(Reciprocal, 1)

Create an ASAP schedule.

schedule = Schedule(sfg, scheduler=ASAPScheduler())
print("Scheduling time:", schedule.schedule_time)
schedule.show()
ldlt matrix inverse
Scheduling time: 30

Create an ALAP schedule.

schedule = Schedule(sfg, scheduler=ALAPScheduler())
print("Scheduling time:", schedule.schedule_time)
schedule.show()
ldlt matrix inverse
Scheduling time: 30

Create an earliest deadline schedule that uses one MADS and one Reciprocal PE.

resources = {MADS.type_name(): 1, Reciprocal.type_name(): 1}
schedule = Schedule(sfg, scheduler=EarliestDeadlineScheduler(resources))
print("Scheduling time:", schedule.schedule_time)
schedule.show()
ldlt matrix inverse
Scheduling time: 32

Create a least slack-time schedule that uses one MADS and one Reciprocal PE.

schedule = Schedule(sfg, scheduler=LeastSlackTimeScheduler(resources))
print("Scheduling time:", schedule.schedule_time)
schedule.show()
ldlt matrix inverse
Scheduling time: 32

Create a max fan-out schedule that uses one MADS and one Reciprocal PE.

schedule = Schedule(sfg, scheduler=MaxFanOutScheduler(resources))
print("Scheduling time:", schedule.schedule_time)
schedule.show()
ldlt matrix inverse
Scheduling time: 36

Create a HybridScheduler schedule that one MADS and one Reciprocal PE with custom IO times. This is the schedule we will synthesize an architecture for.

input_times = {
    "in0": 0,
    "in1": 1,
    "in2": 2,
    "in3": 3,
    "in4": 4,
    "in5": 5,
}
output_delta_times = {
    "out0": 0,
    "out1": 1,
    "out2": 2,
    "out3": 3,
    "out4": 4,
    "out5": 5,
}
schedule = Schedule(
    sfg,
    scheduler=HybridScheduler(
        resources, input_times=input_times, output_delta_times=output_delta_times
    ),
    schedule_time=32,
    cyclic=True,
)
print("Scheduling time:", schedule.schedule_time)
schedule.show()
ldlt matrix inverse
Scheduling time: 32
operations = schedule.get_operations()
mads = operations.get_by_type_name(MADS.type_name())
mads.show(title="MADS executions")
reciprocals = operations.get_by_type_name(Reciprocal.type_name())
reciprocals.show(title="Reciprocal executions")
inputs = operations.get_by_type_name(Input.type_name())
inputs.show(title="Input executions")
outputs = operations.get_by_type_name(Output.type_name())
outputs.show(title="Output executions")

mads_pe = ProcessingElement(mads, entity_name="mad")
reciprocal_pe = ProcessingElement(reciprocals, entity_name="rec")

pe_in = ProcessingElement(inputs, entity_name='input')
pe_out = ProcessingElement(outputs, entity_name='output')

mem_vars = schedule.get_memory_variables()
mem_vars.show(title="All memory variables")
direct, mem_vars = mem_vars.split_on_length()
mem_vars.show(title="Non-zero time memory variables")
mem_vars_set = mem_vars.split_on_ports(
    read_ports=1, write_ports=1, total_ports=2, strategy="greedy_graph_color"
)
  • MADS executions
  • Reciprocal executions
  • Input executions
  • Output executions
  • All memory variables
  • Non-zero time memory variables
memories = []
for i, mem in enumerate(mem_vars_set):
    memory = Memory(mem, memory_type="RAM", entity_name=f"memory{i}")
    memories.append(memory)
    mem.show(title=f"{memory.entity_name}")
    memory.assign("left_edge")
    memory.show_content(title=f"Assigned {memory.entity_name}")

direct.show(title="Direct interconnects")
  • memory0
  • Assigned memory0
  • memory1
  • Assigned memory1
  • memory2
  • Assigned memory2
  • Direct interconnects

Total running time of the script: (0 minutes 6.537 seconds)

Gallery generated by Sphinx-Gallery