Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
TTool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mbe-tools
TTool
Commits
993dad55
Commit
993dad55
authored
5 years ago
by
Emna Gharbi
Browse files
Options
Downloads
Patches
Plain Diff
added mapping channels to controllers variables
parent
6ab172b2
No related branches found
No related tags found
1 merge request
!126
added mapping channels to controllers variables
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/tmltranslator/dsez3engine/OptimizationModel.java
+76
-0
76 additions, 0 deletions
...ain/java/tmltranslator/dsez3engine/OptimizationModel.java
with
76 additions
and
0 deletions
src/main/java/tmltranslator/dsez3engine/OptimizationModel.java
+
76
−
0
View file @
993dad55
...
...
@@ -6,6 +6,7 @@ import tmltranslator.*;
import
javax.swing.*
;
import
java.lang.reflect.Array
;
import
java.nio.channels.Channel
;
import
java.util.*
;
...
...
@@ -469,6 +470,9 @@ public class OptimizationModel {
//Definition of start time variable for each task
IntExpr
[]
start
=
new
IntExpr
[
inputInstance
.
getModeling
().
getTasks
().
size
()];
//Definition of Y1: mapping variable of channel --> PE for transfer
IntExpr
[][]
Y1
=
new
IntExpr
[
inputInstance
.
getModeling
().
getChannels
().
size
()][
inputInstance
.
getArchitecture
().
getCPUs
().
size
()];
//Mapping Constraints :
BoolExpr
mapping_constraints
=
ctx
.
mkTrue
();
...
...
@@ -510,8 +514,45 @@ public class OptimizationModel {
//TraceManager.addDev(c_bound_start[t].toString());
}
//Matrix of constraints to define the interval of Y1 : 0 <= Y1 <= 1
BoolExpr
[][]
c_bound_y1
=
new
BoolExpr
[
inputInstance
.
getModeling
().
getChannels
().
size
()][
inputInstance
.
getArchitecture
().
getCPUs
().
size
()];
for
(
Object
channel
:
inputInstance
.
getModeling
().
getChannels
())
{
int
c
=
inputInstance
.
getModeling
().
getChannels
().
indexOf
(
channel
);
TMLChannel
channelCast
=
(
TMLChannel
)
channel
;
for
(
HwNode
hwNode
:
inputInstance
.
getArchitecture
().
getCPUs
())
{
int
p
=
inputInstance
.
getArchitecture
().
getCPUs
().
indexOf
(
hwNode
);
Y1
[
c
][
p
]
=
ctx
.
mkIntConst
(
"Y1_"
+
channelCast
.
getName
()
+
"_"
+
hwNode
.
getName
());
// Constraints: 0 <= Y1 <= 1
c_bound_y1
[
c
][
p
]
=
ctx
.
mkAnd
(
ctx
.
mkLe
(
ctx
.
mkInt
(
0
),
Y1
[
c
][
p
]),
ctx
.
mkLe
(
Y1
[
c
][
p
],
ctx
.
mkInt
(
1
)));
mapping_constraints
=
ctx
.
mkAnd
(
mapping_constraints
,
c_bound_y1
[
c
][
p
]);
}
}
//CONSTRAINTS//
//Each channel must be mapped to exactly 1 processing unit:
// ∀ch, SUM p (Y 1) = 1
BoolExpr
[]
c_unique_y1
=
new
BoolExpr
[
inputInstance
.
getModeling
().
getChannels
().
size
()];
for
(
Object
channel
:
inputInstance
.
getModeling
().
getChannels
())
{
int
c
=
inputInstance
.
getModeling
().
getChannels
().
indexOf
(
channel
);
TMLChannel
channelCast
=
(
TMLChannel
)
channel
;
ArithExpr
sum_Y1
=
ctx
.
mkAdd
(
Y1
[
c
]);
c_unique_y1
[
c
]
=
ctx
.
mkEq
(
sum_Y1
,
ctx
.
mkInt
(
1
));
mapping_constraints
=
ctx
.
mkAnd
(
mapping_constraints
,
c_unique_y1
[
c
]);
}
//Each task must be mapped to exactly 1 processing unit in its eligibility set:
// ∀t, SUM p (X tp) ≤ 1
...
...
@@ -779,6 +820,8 @@ public class OptimizationModel {
Model
m
=
opt
.
getModel
();
Expr
[][]
optimized_result_X
=
new
Expr
[
inputInstance
.
getModeling
().
getTasks
().
size
()][
inputInstance
.
getArchitecture
().
getCPUs
().
size
()];
Expr
[]
optimized_result_start
=
new
Expr
[
inputInstance
.
getModeling
().
getTasks
().
size
()];
Expr
[][]
optimized_result_Y1
=
new
Expr
[
inputInstance
.
getModeling
().
getChannels
().
size
()][
inputInstance
.
getArchitecture
().
getCPUs
().
size
()];
tmlMapping
=
new
TMLMapping
<>(
inputInstance
.
getModeling
(),
inputInstance
.
getArchitecture
(),
false
);
...
...
@@ -868,6 +911,39 @@ public class OptimizationModel {
outputToDisplay
=
outputToDisplay
+
entry
.
getKey
()
+
" = "
+
entry
.
getValue
()
+
"\n"
;
}
//mapping of communication channels
outputToDisplay
=
outputToDisplay
+
"\n\n(3) Spatial mapping of channels onto controllers:\n"
;
for
(
Object
channel
:
inputInstance
.
getModeling
().
getChannels
())
{
int
c
=
inputInstance
.
getModeling
().
getChannels
().
indexOf
(
channel
);
TMLChannel
channelCast
=
(
TMLChannel
)
channel
;
for
(
HwNode
hwNode
:
inputInstance
.
getArchitecture
().
getCPUs
())
{
int
p
=
inputInstance
.
getArchitecture
().
getCPUs
().
indexOf
(
hwNode
);
//evaluate optimal solution
optimized_result_Y1
[
c
][
p
]
=
m
.
evaluate
(
Y1
[
c
][
p
],
true
);
if
(
Integer
.
parseInt
(
optimized_result_Y1
[
c
][
p
].
toString
())
==
1
)
{
//TODO Add this mapping in tmlmapping
// mapping of R/W channels on local memory of hwExecutionNode TODO get(0)
/* if (!taskCast.getReadChannels().isEmpty())
tmlMapping.addCommToHwCommNode(taskCast.getReadChannels().get(0), inputInstance.getLocalMemoryOfHwExecutionNode(hwNode));
if (!taskCast.getWriteChannels().isEmpty())
tmlMapping.addCommToHwCommNode(taskCast.getWriteChannels().get(0), inputInstance.getLocalMemoryOfHwExecutionNode(hwNode));
outputToDisplay = outputToDisplay + "\n" + taskCast.getName() + " --> " + hwNode.getName();
}*/
outputToDisplay
+=
"\nChannel("
+
channelCast
.
getOriginTask
().
getTaskName
()
+
","
+
channelCast
.
getDestinationTask
().
getTaskName
()
+
") --> "
+
hwNode
.
getName
();
}
}
}
TraceManager
.
addDev
(
outputToDisplay
);
result
.
mappingFound
=
true
;
...
...
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