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
db866d89
Commit
db866d89
authored
Aug 22, 2019
by
EYRAUD-DUBOIS Lionel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement HeteroPrioDep: steal tasks when queue contains only unfavorable tasks
parent
9c30d67e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
43 deletions
+71
-43
include/TrueHeteroPrio.h
include/TrueHeteroPrio.h
+3
-2
schedulers/TrueHeteroPrio.cpp
schedulers/TrueHeteroPrio.cpp
+68
-41
No files found.
include/TrueHeteroPrio.h
View file @
db866d89
...
...
@@ -16,9 +16,10 @@ private:
std
::
vector
<
double
>
priorities
;
StealType
stealType
=
LATEST
;
std
::
string
rankString
=
"min"
;
int
GPUindex
=
1
;
// bool stealIfNonEmpty = false;
bool
isBetterSteal
(
int
taskA
,
double
endA
,
int
taskB
,
double
endB
,
int
wType
);
public:
public:
double
compute
(
Instance
&
ins
,
SchedAction
*
action
)
override
;
TrueHeteroPrio
(
const
AlgOptions
&
options
);
...
...
schedulers/TrueHeteroPrio.cpp
View file @
db866d89
...
...
@@ -3,31 +3,55 @@
//
#include <iostream>
#include <limits>
#include "TrueHeteroPrio.h"
using
namespace
std
;
bool
TrueHeteroPrio
::
isBetterSteal
(
int
taskA
,
double
endA
,
int
taskB
,
double
endB
,
int
wType
)
{
double
scoreA
,
scoreB
;
if
(
stealType
==
AF
)
{
scoreA
=
ins
->
execType
(
1
-
wType
,
taskA
)
/
ins
->
execType
(
wType
,
taskA
);
scoreB
=
ins
->
execType
(
1
-
wType
,
taskB
)
/
ins
->
execType
(
wType
,
taskB
);
if
(
scoreA
==
scoreB
)
{
scoreA
=
priorities
[
taskA
];
scoreB
=
priorities
[
taskB
];
}
}
else
if
(
stealType
==
LATEST
)
{
scoreA
=
endA
;
scoreB
=
endB
;
}
else
{
/* Steal by priority */
scoreA
=
priorities
[
taskA
];
scoreB
=
priorities
[
taskB
];
}
return
scoreA
>
scoreB
;
}
int
TrueHeteroPrio
::
chooseTask
(
int
worker
,
double
now
)
{
int
wType
=
ins
->
getType
(
worker
);
if
(
wType
==
0
)
{
// CPUs wait until GPUs have been served
int
k
=
ins
->
nbWorkers
[
0
];
bool
idleGPU
=
false
;
for
(
int
i
=
0
;
i
<
ins
->
nbWorkers
[
1
];
++
i
,
++
k
){
if
(
runningTasks
[
k
]
<
0
){
idleGPU
=
true
;
break
;
}
}
if
(
idleGPU
&&
!
taskSet
->
empty
())
return
-
1
;
bool
chosenFromQueue
=
false
;
int
resultTask
=
-
1
;
auto
positionInQueue
=
taskSet
->
begin
();
if
(
!
taskSet
->
empty
())
{
if
(
wType
==
0
)
{
positionInQueue
=
taskSet
->
end
();
--
positionInQueue
;
}
chosenFromQueue
=
true
;
resultTask
=
*
positionInQueue
;
}
if
(
taskSet
->
empty
())
{
bool
unfavorable
=
false
;
if
(
resultTask
!=
-
1
)
unfavorable
=
ins
->
execType
(
wType
,
resultTask
)
>
ins
->
execType
(
1
-
wType
,
resultTask
);
int
chosenVictim
=
-
1
;
if
(
resultTask
==
-
1
||
unfavorable
)
{
int
bestTask
=
-
1
;
double
bestScore
=
-
1
;
int
chosenVictim
=
-
1
;
// Steal: copy/paste from GreedyPerType
for
(
int
victim
=
0
;
victim
<
ins
->
totalWorkers
;
victim
++
)
{
int
victimType
=
ins
->
getType
(
victim
);
...
...
@@ -36,37 +60,41 @@ int TrueHeteroPrio::chooseTask(int worker, double now) {
&&
ins
->
isValidType
(
wType
,
runningTasks
[
victim
])
&&
now
+
ins
->
execType
(
wType
,
runningTasks
[
victim
])
<
endTimesWorkers
[
victim
])
{
int
task
=
runningTasks
[
victim
];
double
score
;
if
(
stealType
==
AF
)
score
=
ins
->
execType
(
victimType
,
task
)
/
ins
->
execType
(
wType
,
task
);
else
if
(
stealType
==
LATEST
)
score
=
endTimesWorkers
[
victim
];
else
/* Steal by priority */
score
=
priorities
[
task
];
if
(
bestTask
==
-
1
||
(
score
>
bestScore
)
)
{
if
(
bestTask
==
-
1
||
isBetterSteal
(
task
,
endTimesWorkers
[
victim
],
bestTask
,
endTimesWorkers
[
chosenVictim
],
wType
))
{
bestTask
=
task
;
bestScore
=
score
;
chosenVictim
=
victim
;
}
}
}
if
(
bestTask
!=
-
1
)
{
runningTasks
[
chosenVictim
]
=
-
1
;
return
bestTask
;
}
else
{
return
-
1
;
}
}
else
{
auto
pos
=
taskSet
->
begin
();
if
(
wType
==
0
)
{
pos
=
taskSet
->
end
();
--
pos
;
}
int
task
=
*
pos
;
taskSet
->
erase
(
pos
);
if
(
bestTask
!=
-
1
)
{
resultTask
=
bestTask
;
chosenFromQueue
=
false
;
unfavorable
=
false
;
}
}
return
task
;
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
;
if
(
chosenFromQueue
)
taskSet
->
erase
(
positionInQueue
);
else
if
(
chosenVictim
!=
-
1
)
runningTasks
[
chosenVictim
]
=
-
1
;
return
resultTask
;
}
void
TrueHeteroPrio
::
onTaskPush
(
int
task
,
double
now
)
{
...
...
@@ -102,7 +130,7 @@ double TrueHeteroPrio::compute(Instance &ins, SchedAction *action) {
strictCompare
strict
(
&
combined
,
true
);
taskSet
=
new
set
<
int
,
strictCompare
>
(
strict
);
this
->
ins
=
&
ins
;
return
GreedyAlgorithm
::
compute
(
ins
,
action
);
}
...
...
@@ -118,7 +146,6 @@ TrueHeteroPrio::TrueHeteroPrio(const AlgOptions &options) : GreedyAlgorithm(opti
cerr
<<
"TrueHP: unknown steal type "
<<
steal
<<
", defaulting to latest"
<<
endl
;
stealType
=
LATEST
;
}
GPUindex
=
options
.
asInt
(
"gpu"
,
1
);
rankString
=
options
.
asString
(
"rank"
,
"min"
);
}
...
...
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