Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B-ASIC - Better ASIC Toolbox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Computer Engineering
B-ASIC - Better ASIC Toolbox
Commits
2ce86e81
Commit
2ce86e81
authored
1 year ago
by
Oscar Gustafsson
Browse files
Options
Downloads
Patches
Plain Diff
Rewrite slack computation
parent
050a3eee
No related branches found
Branches containing commit
No related tags found
1 merge request
!402
Rewrite slack computation
Pipeline
#97731
passed
1 year ago
Stage: test
Stage: deploy
Changes
4
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
b_asic/resources.py
+15
-12
15 additions, 12 deletions
b_asic/resources.py
b_asic/schedule.py
+23
-17
23 additions, 17 deletions
b_asic/schedule.py
examples/fivepointwinograddft.py
+3
-0
3 additions, 0 deletions
examples/fivepointwinograddft.py
test/test_schedule.py
+2
-2
2 additions, 2 deletions
test/test_schedule.py
with
43 additions
and
31 deletions
b_asic/resources.py
+
15
−
12
View file @
2ce86e81
...
...
@@ -1409,11 +1409,13 @@ class ProcessCollection:
return
max
(
self
.
read_port_accesses
().
values
())
def
read_port_accesses
(
self
)
->
Dict
[
int
,
int
]:
reads
=
[]
for
process
in
self
.
_collection
:
reads
.
extend
(
set
(
read_time
%
self
.
schedule_time
for
read_time
in
process
.
read_times
)
)
reads
=
sum
(
(
[
read_time
%
self
.
schedule_time
for
read_time
in
process
.
read_times
]
for
process
in
self
.
_collection
),
[],
)
return
dict
(
sorted
(
Counter
(
reads
).
items
()))
def
write_ports_bound
(
self
)
->
int
:
...
...
@@ -1444,13 +1446,14 @@ class ProcessCollection:
return
max
(
self
.
total_port_accesses
().
values
())
def
total_port_accesses
(
self
)
->
Dict
[
int
,
int
]:
accesses
=
[
process
.
start_time
%
self
.
schedule_time
for
process
in
self
.
_collection
]
for
process
in
self
.
_collection
:
accesses
.
extend
(
set
(
read_time
%
self
.
schedule_time
for
read_time
in
process
.
read_times
)
)
accesses
=
sum
(
(
list
(
read_time
%
self
.
schedule_time
for
read_time
in
process
.
read_times
)
for
process
in
self
.
_collection
),
[
process
.
start_time
%
self
.
schedule_time
for
process
in
self
.
_collection
],
)
return
dict
(
sorted
(
Counter
(
accesses
).
items
()))
def
from_name
(
self
,
name
:
str
):
...
...
This diff is collapsed.
Click to expand it.
b_asic/schedule.py
+
23
−
17
View file @
2ce86e81
...
...
@@ -72,7 +72,7 @@ class Schedule:
algorithm.
cyclic : bool, default: False
If the schedule is cyclic.
algorithm : {
'
ASAP
'
,
'
ALAP
'
,
'
provided
'
},
optional
algorithm : {
'
ASAP
'
,
'
ALAP
'
,
'
provided
'
},
default:
'
ASAP
'
The scheduling algorithm to use. The following algorithm are available:
* ``
'
ASAP
'
``: As-soon-as-possible scheduling.
* ``
'
ALAP
'
``: As-late-as-possible scheduling.
...
...
@@ -84,10 +84,10 @@ class Schedule:
Dictionary with GraphIDs as keys and laps as values.
Used when *algorithm* is
'
provided
'
.
max_resources : dict, optional
Dictionary like ``{
'
cmul
'
: 2}`` denoting the maximum number of
resources
for a given operation type if the scheduling algorithm considers
that.
If not provided, or an operation type is not provided, at most one
resource is
used.
Dictionary like ``{
Addition.type_name()
: 2}`` denoting the maximum number of
resources
for a given operation type if the scheduling algorithm considers
that.
If not provided, or an operation type is not provided, at most one
resource is
used.
"""
_sfg
:
SFG
...
...
@@ -181,13 +181,16 @@ class Schedule:
"""
if
graph_id
not
in
self
.
_start_times
:
raise
ValueError
(
f
"
No operation with graph_id
{
graph_id
}
in schedule
"
)
slack
=
sys
.
maxsize
output_slacks
=
self
.
_forward_slacks
(
graph_id
)
# Make more pythonic
for
signal_slacks
in
output_slacks
.
values
():
for
signal_slack
in
signal_slacks
.
values
():
slack
=
min
(
slack
,
signal_slack
)
return
slack
return
min
(
sum
(
(
list
(
signal_slacks
.
values
())
for
signal_slacks
in
output_slacks
.
values
()
),
[
sys
.
maxsize
],
)
)
def
_forward_slacks
(
self
,
graph_id
:
GraphID
...
...
@@ -241,13 +244,16 @@ class Schedule:
"""
if
graph_id
not
in
self
.
_start_times
:
raise
ValueError
(
f
"
No operation with graph_id
{
graph_id
}
in schedule
"
)
slack
=
sys
.
maxsize
input_slacks
=
self
.
_backward_slacks
(
graph_id
)
# Make more pythonic
for
signal_slacks
in
input_slacks
.
values
():
for
signal_slack
in
signal_slacks
.
values
():
slack
=
min
(
slack
,
signal_slack
)
return
slack
return
min
(
sum
(
(
list
(
signal_slacks
.
values
())
for
signal_slacks
in
input_slacks
.
values
()
),
[
sys
.
maxsize
],
)
)
def
_backward_slacks
(
self
,
graph_id
:
GraphID
)
->
Dict
[
InputPort
,
Dict
[
Signal
,
int
]]:
ret
=
{}
...
...
This diff is collapsed.
Click to expand it.
examples/fivepointwinograddft.py
+
3
−
0
View file @
2ce86e81
...
...
@@ -130,6 +130,7 @@ schedule.move_operation('bfly3', -2)
schedule
.
move_operation
(
'
bfly4
'
,
-
1
)
schedule
.
show
()
# %%
# Extract memory variables and operation executions
operations
=
schedule
.
get_operations
()
adders
=
operations
.
get_by_type_name
(
AddSub
.
type_name
())
...
...
@@ -168,6 +169,8 @@ fig, ax = plt.subplots()
fig
.
suptitle
(
'
Exclusion graph based on ports
'
)
nx
.
draw
(
mem_vars
.
create_exclusion_graph_from_ports
(
1
,
1
,
2
),
ax
=
ax
)
# %%
# Create architecture
arch
=
Architecture
(
[
addsub
,
butterfly
,
multiplier
,
pe_in
,
pe_out
],
memories
,
...
...
This diff is collapsed.
Click to expand it.
test/test_schedule.py
+
2
−
2
View file @
2ce86e81
...
...
@@ -70,9 +70,9 @@ class TestInit:
print
(
op
.
latency_offsets
)
start_times_names
=
{}
for
op_id
,
start_time
in
schedule
.
_
start_times
.
items
()
:
for
op_id
in
schedule
.
start_times
:
op_name
=
precedence_sfg_delays
.
find_by_id
(
op_id
).
name
start_times_names
[
op_name
]
=
s
tart_time
start_times_names
[
op_name
]
=
s
chedule
.
start_time_of_operation
(
op_id
)
assert
start_times_names
==
{
"
IN1
"
:
4
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment