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
24545b4f
Commit
24545b4f
authored
1 month ago
by
Simon Bjurek
Browse files
Options
Downloads
Patches
Plain Diff
Update ILP split_on_ports to consider ports instead of PEs
parent
cfd0b5e4
No related branches found
No related tags found
1 merge request
!514
Update ILP split_on_port to consider ports
Pipeline
#160987
passed
1 month ago
Stage: test
Stage: deploy
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
b_asic/resources.py
+59
-30
59 additions, 30 deletions
b_asic/resources.py
with
59 additions
and
30 deletions
b_asic/resources.py
+
59
−
30
View file @
24545b4f
...
...
@@ -109,27 +109,32 @@ def _sanitize_port_option(
return
read_ports
,
write_ports
,
total_ports
def
_get_source
(
var
:
MemoryVariable
,
pes
:
list
[
"
ProcessingElement
"
]
)
->
"
ProcessingElement
"
:
name
=
var
.
name
.
split
(
"
.
"
)[
0
]
def
_get_source
_port
(
var
:
MemoryVariable
,
pes
:
list
[
"
ProcessingElement
"
])
->
str
:
split_var
=
iter
(
var
.
name
.
split
(
"
.
"
))
var_name
=
next
(
split_var
)
port_index
=
int
(
next
(
split_var
))
for
pe
in
pes
:
pe_names
=
[
proc
.
name
for
proc
in
pe
.
collection
]
if
name
in
pe_names
:
return
pe
for
process
in
pe
:
if
var_name
==
process
.
name
:
for
output_port
in
process
.
operation
.
outputs
:
if
output_port
.
index
==
port_index
:
return
f
"
{
pe
.
entity_name
}
.out.
{
output_port
.
index
}
"
raise
ValueError
(
"
Source could not be found for the given variable.
"
)
def
_get_destination
(
var
:
MemoryVariable
,
pes
:
list
[
"
ProcessingElement
"
]
)
->
"
ProcessingElement
"
:
name
=
var
.
name
.
split
(
"
.
"
)[
0
]
def
_get_destination
_port
(
var
:
MemoryVariable
,
pes
:
list
[
"
ProcessingElement
"
])
->
str
:
split_var
=
iter
(
var
.
name
.
split
(
"
.
"
))
var_name
=
next
(
split_var
)
port_index
=
int
(
next
(
split_var
))
for
pe
in
pes
:
for
process
in
pe
.
processes
:
for
process
in
pe
:
for
input_port
in
process
.
operation
.
inputs
:
input_op
=
input_port
.
connected_source
.
operation
if
input_op
.
graph_id
==
name
:
return
pe
if
(
input_op
.
graph_id
==
var_name
and
input_port
.
connected_source
.
index
==
port_index
):
return
f
"
{
pe
.
entity_name
}
.in.
{
input_port
.
index
}
"
raise
ValueError
(
"
Destination could not be found for the given variable.
"
)
...
...
@@ -1517,6 +1522,12 @@ class ProcessCollection:
colors
=
range
(
amount_of_colors
)
pe_out_ports
=
[
f
"
{
pe
.
entity_name
}
.out.
{
port_index
}
"
for
pe
in
processing_elements
for
port_index
in
range
(
pe
.
output_count
)
]
# minimize the amount of input muxes connecting PEs to memories
# by minimizing the amount of PEs connected to each memory
...
...
@@ -1526,9 +1537,10 @@ class ProcessCollection:
# y[pe, color] - whether a color has nodes generated from a certain pe
x
=
LpVariable
.
dicts
(
"
x
"
,
(
nodes
,
colors
),
cat
=
LpBinary
)
c
=
LpVariable
.
dicts
(
"
c
"
,
colors
,
cat
=
LpBinary
)
y
=
LpVariable
.
dicts
(
"
y
"
,
(
processing_elements
,
colors
),
cat
=
LpBinary
)
y
=
LpVariable
.
dicts
(
"
y
"
,
(
pe_out_ports
,
colors
),
cat
=
LpBinary
)
problem
=
LpProblem
()
problem
+=
lpSum
(
y
[
p
e
][
i
]
for
p
e
in
p
rocessing_elemen
ts
for
i
in
colors
)
problem
+=
lpSum
(
y
[
p
ort
][
i
]
for
p
ort
in
p
e_out_por
ts
for
i
in
colors
)
# constraints:
# (1) - nodes have exactly one color
...
...
@@ -1547,9 +1559,9 @@ class ProcessCollection:
for
color
in
colors
:
problem
+=
x
[
node
][
color
]
<=
c
[
color
]
for
node
in
nodes
:
p
e
=
_get_source
(
node
,
processing_elements
)
p
ort
=
_get_source
_port
(
node
,
processing_elements
)
for
color
in
colors
:
problem
+=
x
[
node
][
color
]
<=
y
[
p
e
][
color
]
problem
+=
x
[
node
][
color
]
<=
y
[
p
ort
][
color
]
max_clique
=
next
(
nx
.
find_cliques
(
exclusion_graph
))
for
color
,
node
in
enumerate
(
max_clique
):
problem
+=
x
[
node
][
color
]
==
c
[
color
]
==
1
...
...
@@ -1601,6 +1613,12 @@ class ProcessCollection:
colors
=
range
(
amount_of_colors
)
pe_in_ports
=
[
f
"
{
pe
.
entity_name
}
.in.
{
port_index
}
"
for
pe
in
processing_elements
for
port_index
in
range
(
pe
.
input_count
)
]
# minimize the amount of output muxes connecting PEs to memories
# by minimizing the amount of PEs connected to each memory
...
...
@@ -1610,9 +1628,9 @@ class ProcessCollection:
# y[pe, color] - whether a color has nodes writing to a certain PE
x
=
LpVariable
.
dicts
(
"
x
"
,
(
nodes
,
colors
),
cat
=
LpBinary
)
c
=
LpVariable
.
dicts
(
"
c
"
,
colors
,
cat
=
LpBinary
)
y
=
LpVariable
.
dicts
(
"
y
"
,
(
p
rocessing_elemen
ts
,
colors
),
cat
=
LpBinary
)
y
=
LpVariable
.
dicts
(
"
y
"
,
(
p
e_in_por
ts
,
colors
),
cat
=
LpBinary
)
problem
=
LpProblem
()
problem
+=
lpSum
(
y
[
p
e
][
i
]
for
p
e
in
p
rocessing_elemen
ts
for
i
in
colors
)
problem
+=
lpSum
(
y
[
p
ort
][
i
]
for
p
ort
in
p
e_in_por
ts
for
i
in
colors
)
# constraints:
# (1) - nodes have exactly one color
...
...
@@ -1631,9 +1649,9 @@ class ProcessCollection:
for
color
in
colors
:
problem
+=
x
[
node
][
color
]
<=
c
[
color
]
for
node
in
nodes
:
p
e
=
_get_destination
(
node
,
processing_elements
)
p
ort
=
_get_destination
_port
(
node
,
processing_elements
)
for
color
in
colors
:
problem
+=
x
[
node
][
color
]
<=
y
[
p
e
][
color
]
problem
+=
x
[
node
][
color
]
<=
y
[
p
ort
][
color
]
max_clique
=
next
(
nx
.
find_cliques
(
exclusion_graph
))
for
color
,
node
in
enumerate
(
max_clique
):
problem
+=
x
[
node
][
color
]
==
c
[
color
]
==
1
...
...
@@ -1685,6 +1703,17 @@ class ProcessCollection:
colors
=
range
(
amount_of_colors
)
pe_in_ports
=
[
f
"
{
pe
.
entity_name
}
.in.
{
port_index
}
"
for
pe
in
processing_elements
for
port_index
in
range
(
pe
.
input_count
)
]
pe_out_ports
=
[
f
"
{
pe
.
entity_name
}
.out.
{
port_index
}
"
for
pe
in
processing_elements
for
port_index
in
range
(
pe
.
output_count
)
]
# minimize the amount of total muxes connecting PEs to memories
# by minimizing the amount of PEs connected to each memory (input & output)
...
...
@@ -1695,11 +1724,11 @@ class ProcessCollection:
# z[pe, color] - whether a color has nodes writing to a certain PE
x
=
LpVariable
.
dicts
(
"
x
"
,
(
nodes
,
colors
),
cat
=
LpBinary
)
c
=
LpVariable
.
dicts
(
"
c
"
,
colors
,
cat
=
LpBinary
)
y
=
LpVariable
.
dicts
(
"
y
"
,
(
p
rocessing_elemen
ts
,
colors
),
cat
=
LpBinary
)
z
=
LpVariable
.
dicts
(
"
z
"
,
(
p
rocessing_elemen
ts
,
colors
),
cat
=
LpBinary
)
y
=
LpVariable
.
dicts
(
"
y
"
,
(
p
e_out_por
ts
,
colors
),
cat
=
LpBinary
)
z
=
LpVariable
.
dicts
(
"
z
"
,
(
p
e_in_por
ts
,
colors
),
cat
=
LpBinary
)
problem
=
LpProblem
()
problem
+=
lpSum
(
y
[
pe
][
i
]
+
z
[
pe
][
i
]
for
p
e
in
p
rocessing_elemen
ts
for
i
in
colors
problem
+=
lpSum
(
[
y
[
port
][
i
]
for
port
in
pe_out_ports
for
i
in
colors
])
+
lpSum
(
[
z
[
port
][
i
]
for
p
ort
in
p
e_in_por
ts
for
i
in
colors
]
)
# constraints:
...
...
@@ -1720,13 +1749,13 @@ class ProcessCollection:
for
color
in
colors
:
problem
+=
x
[
node
][
color
]
<=
c
[
color
]
for
node
in
nodes
:
p
e
=
_get_source
(
node
,
processing_elements
)
p
ort
=
_get_source
_port
(
node
,
processing_elements
)
for
color
in
colors
:
problem
+=
x
[
node
][
color
]
<=
y
[
p
e
][
color
]
problem
+=
x
[
node
][
color
]
<=
y
[
p
ort
][
color
]
for
node
in
nodes
:
p
e
=
_get_destination
(
node
,
processing_elements
)
p
ort
=
_get_destination
_port
(
node
,
processing_elements
)
for
color
in
colors
:
problem
+=
x
[
node
][
color
]
<=
z
[
p
e
][
color
]
problem
+=
x
[
node
][
color
]
<=
z
[
p
ort
][
color
]
max_clique
=
next
(
nx
.
find_cliques
(
exclusion_graph
))
for
color
,
node
in
enumerate
(
max_clique
):
problem
+=
x
[
node
][
color
]
==
c
[
color
]
==
1
...
...
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