Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SWIFT
SWIFTsim
Commits
63abecd0
Commit
63abecd0
authored
Jun 22, 2013
by
Pedro Gonnet
Browse files
rank tasks according to weight of sub-tree.
Former-commit-id: cc8b8ee0bf4d45a0bb60a0aa259454d3b8a25e18
parent
ed94ec26
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/queue.c
View file @
63abecd0
...
...
@@ -104,7 +104,7 @@ void queue_insert ( struct queue *q , struct task *t ) {
/* Shuffle up. */
for
(
int
k
=
q
->
count
-
1
;
k
>
0
;
k
/=
2
)
if
(
q
->
tasks
[
q
->
tid
[
k
]
].
maxdepth
>
q
->
tasks
[
q
->
tid
[
k
/
2
]
].
maxdepth
)
{
if
(
q
->
tasks
[
q
->
tid
[
k
]
].
weight
>
q
->
tasks
[
q
->
tid
[
k
/
2
]
].
weight
)
{
int
temp
=
q
->
tid
[
k
];
q
->
tid
[
k
]
=
q
->
tid
[
k
/
2
];
q
->
tid
[
k
/
2
]
=
temp
;
...
...
@@ -234,9 +234,9 @@ struct task *queue_gettask ( struct queue *q , int qid , int blocking ) {
int
i
=
2
*
k
;
if
(
i
>=
q
->
count
)
break
;
if
(
i
+
1
<
q
->
count
&&
qtasks
[
qtid
[
i
+
1
]
].
maxdepth
>
qtasks
[
qtid
[
i
]
].
maxdepth
)
if
(
i
+
1
<
q
->
count
&&
qtasks
[
qtid
[
i
+
1
]
].
weight
>
qtasks
[
qtid
[
i
]
].
weight
)
i
+=
1
;
if
(
qtasks
[
qtid
[
i
]
].
maxdepth
>
qtasks
[
qtid
[
k
]
].
maxdepth
)
{
if
(
qtasks
[
qtid
[
i
]
].
weight
>
qtasks
[
qtid
[
k
]
].
weight
)
{
int
temp
=
qtid
[
i
];
qtid
[
i
]
=
qtid
[
k
];
qtid
[
k
]
=
temp
;
...
...
src/scheduler.c
View file @
63abecd0
...
...
@@ -473,13 +473,44 @@ void scheduler_ranktasks ( struct scheduler *s ) {
}
/* Run throught the tasks backwards and set their maxdepth. */
/* Run throught the tasks backwards and set their
weight and
maxdepth. */
for
(
k
=
nr_tasks
-
1
;
k
>=
0
;
k
--
)
{
t
=
&
tasks
[
tid
[
k
]
];
t
->
maxdepth
=
0
;
for
(
j
=
0
;
j
<
t
->
nr_unlock_tasks
;
j
++
)
switch
(
t
->
type
)
{
case
task_type_none
:
t
->
weight
=
0
;
break
;
case
task_type_sort
:
t
->
weight
=
t
->
ci
->
count
*
(
sizeof
(
int
)
*
8
-
__builtin_clz
(
t
->
ci
->
count
)
);
break
;
case
task_type_self
:
t
->
weight
=
t
->
ci
->
count
*
t
->
ci
->
count
;
break
;
case
task_type_pair
:
t
->
weight
=
t
->
ci
->
count
*
t
->
cj
->
count
;
break
;
case
task_type_sub
:
if
(
t
->
cj
!=
NULL
)
t
->
weight
=
t
->
ci
->
count
*
t
->
cj
->
count
;
else
t
->
weight
=
t
->
ci
->
count
*
t
->
ci
->
count
;
break
;
case
task_type_ghost
:
if
(
t
->
ci
==
t
->
ci
->
super
)
t
->
weight
=
t
->
ci
->
count
;
else
t
->
weight
=
0
;
break
;
case
task_type_kick2
:
t
->
weight
=
t
->
ci
->
count
;
break
;
}
for
(
j
=
0
;
j
<
t
->
nr_unlock_tasks
;
j
++
)
{
t
->
weight
+=
t
->
unlock_tasks
[
j
]
->
weight
;
if
(
t
->
unlock_tasks
[
j
]
->
maxdepth
>
t
->
maxdepth
)
t
->
maxdepth
=
t
->
unlock_tasks
[
j
]
->
maxdepth
;
}
}
}
...
...
src/task.h
View file @
63abecd0
...
...
@@ -51,7 +51,7 @@ extern const char *taskID_names[];
struct
task
{
char
type
,
subtype
,
skip
,
tight
;
int
flags
,
wait
,
rank
,
maxdepth
;
int
flags
,
wait
,
rank
,
weight
,
maxdepth
;
lock_type
lock
;
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment