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
b1b1af2d
Commit
b1b1af2d
authored
4 months ago
by
Simon Bjurek
Committed by
Oscar Gustafsson
4 months ago
Browse files
Options
Downloads
Patches
Plain Diff
added optional type argument to Schedule.print_slacks()
parent
a033e3bc
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
b_asic/schedule.py
+12
-2
12 additions, 2 deletions
b_asic/schedule.py
test/unit/test_schedule.py
+22
-0
22 additions, 0 deletions
test/unit/test_schedule.py
with
34 additions
and
2 deletions
b_asic/schedule.py
+
12
−
2
View file @
b1b1af2d
...
...
@@ -405,7 +405,7 @@ class Schedule:
raise
ValueError
(
f
"
No operation with graph_id
{
graph_id
!r}
in schedule
"
)
return
self
.
backward_slack
(
graph_id
),
self
.
forward_slack
(
graph_id
)
def
print_slacks
(
self
,
order
:
int
=
0
)
->
None
:
def
print_slacks
(
self
,
order
:
int
=
0
,
type_name
:
TypeName
|
None
=
None
)
->
None
:
"""
Print the slack times for all operations in the schedule.
...
...
@@ -417,14 +417,24 @@ class Schedule:
* 0: alphabetical on Graph ID
* 1: backward slack
* 2: forward slack
type_name : TypeName, optional
If given, only the slack times for operations of this type will be printed.
"""
if
type_name
is
None
:
operations
=
self
.
_sfg
.
operations
else
:
operations
=
[
op
for
op
in
self
.
_sfg
.
operations
if
isinstance
(
op
,
type_name
)
]
res
:
list
[
tuple
[
GraphID
,
int
,
int
]]
=
[
(
op
.
graph_id
,
cast
(
int
,
self
.
backward_slack
(
op
.
graph_id
)),
self
.
forward_slack
(
op
.
graph_id
),
)
for
op
in
self
.
_sfg
.
operations
for
op
in
operations
]
res
.
sort
(
key
=
lambda
tup
:
tup
[
order
])
res_str
=
[
...
...
This diff is collapsed.
Click to expand it.
test/unit/test_schedule.py
+
22
−
0
View file @
b1b1af2d
...
...
@@ -404,6 +404,28 @@ class TestSlacks:
)
assert
captured
.
err
==
""
def
test_print_slacks_type_name_given
(
self
,
capsys
,
precedence_sfg_delays
):
precedence_sfg_delays
.
set_latency_of_type_name
(
Addition
.
type_name
(),
1
)
precedence_sfg_delays
.
set_latency_of_type_name
(
ConstantMultiplication
.
type_name
(),
3
)
schedule
=
Schedule
(
precedence_sfg_delays
,
scheduler
=
ASAPScheduler
())
schedule
.
print_slacks
(
1
,
type_name
=
ConstantMultiplication
)
captured
=
capsys
.
readouterr
()
assert
captured
.
out
==
(
"
Graph ID | Backward | Forward
\n
"
"
---------|----------|---------
\n
"
"
cmul0 | 0 | 1
\n
"
"
cmul1 | 0 | 0
\n
"
"
cmul2 | 0 | 0
\n
"
"
cmul3 | 4 | 0
\n
"
"
cmul6 | 4 | 0
\n
"
"
cmul4 | 16 | 0
\n
"
"
cmul5 | 16 | 0
\n
"
)
assert
captured
.
err
==
""
def
test_slacks_errors
(
self
,
precedence_sfg_delays
):
precedence_sfg_delays
.
set_latency_of_type_name
(
Addition
.
type_name
(),
1
)
precedence_sfg_delays
.
set_latency_of_type_name
(
...
...
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