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
d16867dc
Commit
d16867dc
authored
1 year ago
by
Mikael Henriksson
Browse files
Options
Downloads
Patches
Plain Diff
resources.py: fix maximum life-time left-edge algorithm bug (closes
#250
)
parent
c17c055f
No related branches found
No related tags found
No related merge requests found
Pipeline
#97103
passed
1 year ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
b_asic/resources.py
+52
-28
52 additions, 28 deletions
b_asic/resources.py
test/test_resources.py
+10
-0
10 additions, 0 deletions
test/test_resources.py
with
62 additions
and
28 deletions
b_asic/resources.py
+
52
−
28
View file @
d16867dc
...
...
@@ -1066,40 +1066,64 @@ class ProcessCollection:
Two or more processes can share a single resource if, and only if, they have no
overlaping execution time.
Raises :class:`ValueError` if any process in this collection has an execution
time which is greater than the collection schedule time.
Returns
-------
List[ProcessCollection]
"""
next_empty_cell
=
0
cell_assignment
:
Dict
[
int
,
ProcessCollection
]
=
dict
()
assignment
:
List
[
ProcessCollection
]
=
[]
for
next_process
in
sorted
(
self
):
insert_to_new_cell
=
True
for
cell
in
cell_assignment
:
insert_to_this_cell
=
True
for
process
in
cell_assignment
[
cell
]:
next_process_stop_time
=
(
next_process
.
start_time
+
next_process
.
execution_time
)
%
self
.
_schedule_time
if
(
next_process
.
start_time
<
process
.
start_time
+
process
.
execution_time
or
next_process
.
start_time
>
next_process_stop_time
>
process
.
start_time
):
insert_to_this_cell
=
False
break
if
insert_to_this_cell
:
cell_assignment
[
cell
].
add_process
(
next_process
)
insert_to_new_cell
=
False
break
if
insert_to_new_cell
:
cell_assignment
[
next_empty_cell
]
=
ProcessCollection
(
collection
=
[],
schedule_time
=
self
.
_schedule_time
if
next_process
.
execution_time
>
self
.
schedule_time
:
# Can not assign process to any cell
raise
ValueError
(
f
"
{
next_process
}
has execution time greater than the schedule time
"
)
cell_assignment
[
next_empty_cell
].
add_process
(
next_process
)
next_empty_cell
+=
1
return
[
pc
for
pc
in
cell_assignment
.
values
()]
elif
next_process
.
execution_time
==
self
.
schedule_time
:
# Always assign maximum lifetime process to new cell
assignment
.
append
(
ProcessCollection
(
(
next_process
,),
schedule_time
=
self
.
schedule_time
,
cyclic
=
self
.
_cyclic
,
)
)
continue
# Continue assigning next process
else
:
next_process_stop_time
=
(
next_process
.
start_time
+
next_process
.
execution_time
)
%
self
.
_schedule_time
insert_to_new_cell
=
True
for
cell_assignment
in
assignment
:
insert_to_this_cell
=
True
for
process
in
cell_assignment
:
# The next_process start_time is always greater than or equal to
# the start time of all other assigned processes
process_end_time
=
process
.
start_time
+
process
.
execution_time
if
next_process
.
start_time
<
process_end_time
:
insert_to_this_cell
=
False
break
if
(
next_process
.
start_time
>
next_process_stop_time
>
process
.
start_time
):
insert_to_this_cell
=
False
break
if
insert_to_this_cell
:
cell_assignment
.
add_process
(
next_process
)
insert_to_new_cell
=
False
break
if
insert_to_new_cell
:
assignment
.
append
(
ProcessCollection
(
(
next_process
,),
schedule_time
=
self
.
schedule_time
,
cyclic
=
self
.
_cyclic
,
)
)
return
assignment
def
generate_memory_based_storage_vhdl
(
self
,
...
...
This diff is collapsed.
Click to expand it.
test/test_resources.py
+
10
−
0
View file @
d16867dc
...
...
@@ -210,3 +210,13 @@ class TestProcessCollectionPlainMemoryVariable:
assert
exclusion_graph
.
degree
(
p1
)
==
3
assert
exclusion_graph
.
degree
(
p2
)
==
1
assert
exclusion_graph
.
degree
(
p3
)
==
3
def
test_left_edge_maximum_lifetime
(
self
):
a
=
PlainMemoryVariable
(
2
,
0
,
{
0
:
1
},
"
cmul1.0
"
)
b
=
PlainMemoryVariable
(
4
,
0
,
{
0
:
7
},
"
cmul4.0
"
)
c
=
PlainMemoryVariable
(
5
,
0
,
{
0
:
4
},
"
cmul5.0
"
)
collection
=
ProcessCollection
([
a
,
b
,
c
],
schedule_time
=
7
,
cyclic
=
True
)
assignment
=
collection
.
split_on_execution_time
(
heuristic
=
"
left_edge
"
)
assert
a
in
assignment
[
0
]
assert
b
in
assignment
[
1
]
assert
c
in
assignment
[
0
]
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