Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pmtool
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Merge Requests
0
Merge Requests
0
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
EYRAUD-DUBOIS Lionel
pmtool
Commits
164699cb
Commit
164699cb
authored
Aug 22, 2019
by
EYRAUD-DUBOIS Lionel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More efficient code, same behavior
parent
db866d89
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
21 deletions
+15
-21
schedulers/TrueHeteroPrio.cpp
schedulers/TrueHeteroPrio.cpp
+15
-21
No files found.
schedulers/TrueHeteroPrio.cpp
View file @
164699cb
...
...
@@ -48,24 +48,26 @@ int TrueHeteroPrio::chooseTask(int worker, double now) {
if
(
resultTask
!=
-
1
)
unfavorable
=
ins
->
execType
(
wType
,
resultTask
)
>
ins
->
execType
(
1
-
wType
,
resultTask
);
bool
otherTypeHasAnIdleProc
=
false
;
int
chosenVictim
=
-
1
;
if
(
resultTask
==
-
1
||
unfavorable
)
{
int
bestTask
=
-
1
;
// Steal: copy/paste from GreedyPerType
for
(
int
victim
=
0
;
victim
<
ins
->
totalWorkers
;
victim
++
)
{
int
victimType
=
ins
->
getType
(
victim
);
// ins->getType not efficient, but easier to read
if
(
victimType
!=
wType
&&
runningTasks
[
victim
]
!=
-
1
&&
ins
->
isValidType
(
wType
,
runningTasks
[
victim
])
&&
now
+
ins
->
execType
(
wType
,
runningTasks
[
victim
])
<
endTimesWorkers
[
victim
])
{
int
task
=
runningTasks
[
victim
];
if
(
bestTask
==
-
1
||
isBetterSteal
(
task
,
endTimesWorkers
[
victim
],
bestTask
,
endTimesWorkers
[
chosenVictim
],
wType
))
{
bestTask
=
task
;
chosenVictim
=
victim
;
}
}
}
int
victim
=
wType
==
1
?
0
:
ins
->
nbWorkers
[
0
];
for
(
int
i
=
0
;
i
<
ins
->
nbWorkers
[
1
-
wType
];
++
i
,
++
victim
){
int
&
task
=
runningTasks
[
victim
];
if
(
task
<
0
)
otherTypeHasAnIdleProc
=
true
;
else
if
(
ins
->
isValidType
(
wType
,
task
)
&&
now
+
ins
->
execType
(
wType
,
task
)
<
endTimesWorkers
[
victim
])
{
if
(
bestTask
==
-
1
||
isBetterSteal
(
task
,
endTimesWorkers
[
victim
],
bestTask
,
endTimesWorkers
[
chosenVictim
],
wType
))
{
bestTask
=
task
;
chosenVictim
=
victim
;
}
}
}
if
(
bestTask
!=
-
1
)
{
resultTask
=
bestTask
;
chosenFromQueue
=
false
;
...
...
@@ -77,14 +79,6 @@ int TrueHeteroPrio::chooseTask(int worker, double now) {
if
(
resultTask
==
-
1
)
return
-
1
;
int
k
=
wType
==
1
?
0
:
ins
->
nbWorkers
[
0
];
bool
otherTypeHasAnIdleProc
=
false
;
for
(
int
i
=
0
;
i
<
ins
->
nbWorkers
[
1
-
wType
];
++
i
,
++
k
){
if
(
runningTasks
[
k
]
<
0
){
otherTypeHasAnIdleProc
=
true
;
break
;
}
}
if
(
otherTypeHasAnIdleProc
&&
unfavorable
)
// Stay idle if another processor could do better than me
return
-
1
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment