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
692bb903
Commit
692bb903
authored
Jun 23, 2013
by
Pedro Gonnet
Browse files
revert to fast queues.
Former-commit-id: e5b9ea23660c4e597bf7513e865d642560987e8b
parent
4e9b5b63
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/queue.c
View file @
692bb903
...
...
@@ -103,19 +103,19 @@ void queue_insert ( struct queue *q , struct task *t ) {
q
->
count
+=
1
;
/* Shuffle up. */
/*
for ( int k = q->count - 1 ; k > 0 ; k = (k-1)/2 )
for
(
int
k
=
q
->
count
-
1
;
k
>
0
;
k
=
(
k
-
1
)
/
2
)
if
(
q
->
tasks
[
q
->
tid
[
k
]
].
weight
>
q
->
tasks
[
q
->
tid
[(
k
-
1
)
/
2
]
].
weight
)
{
int
temp
=
q
->
tid
[
k
];
q
->
tid
[
k
]
=
q
->
tid
[(
k
-
1
)
/
2
];
q
->
tid
[(
k
-
1
)
/
2
]
=
temp
;
}
else
break;
*/
for
(
int
k
=
q
->
count
-
1
;
k
>
0
&&
q
->
tasks
[
q
->
tid
[
k
-
1
]
].
weight
<
q
->
tasks
[
q
->
tid
[
k
]
].
weight
;
k
--
)
{
break
;
/*
for ( int k = q->count - 1 ; k > 0 && q->tasks[ q->tid[k-1] ].weight < q->tasks[ q->tid[k] ].weight ; k-- ) {
int temp = q->tid[k];
q->tid[k] = q->tid[k-1];
q->tid[k-1] = temp;
}
}
*/
/* Verify queue consistency. */
/* for ( int k = 1 ; k < q->count ; k++ )
...
...
@@ -238,7 +238,7 @@ struct task *queue_gettask ( struct queue *q , int qid , int blocking ) {
cj
->
super
->
owner
=
qid
;
/* Swap this task with the last task and re-heap. */
/*
if ( k < qcount ) {
if
(
k
<
qcount
)
{
qtid
[
k
]
=
qtid
[
qcount
];
while
(
qtasks
[
qtid
[
k
]
].
weight
>
qtasks
[
qtid
[(
k
-
1
)
/
2
]
].
weight
)
{
int
temp
=
q
->
tid
[
k
];
...
...
@@ -246,6 +246,7 @@ struct task *queue_gettask ( struct queue *q , int qid , int blocking ) {
q
->
tid
[(
k
-
1
)
/
2
]
=
temp
;
k
=
(
k
-
1
)
/
2
;
}
int
i
;
while
(
(
i
=
2
*
k
+
1
)
<
qcount
)
{
if
(
i
+
1
<
qcount
&&
qtasks
[
qtid
[
i
+
1
]
].
weight
>
qtasks
[
qtid
[
i
]
].
weight
)
i
+=
1
;
...
...
@@ -258,14 +259,14 @@ struct task *queue_gettask ( struct queue *q , int qid , int blocking ) {
else
break
;
}
}
*/
qtid
[
k
]
=
qtid
[
qcount
];
}
/*
qtid[ k ] = qtid[ qcount ];
while ( k < qcount-1 && qtasks[ qtid[k+1] ].weight > qtasks[ qtid[k] ].weight ) {
temp = qtid[k];
qtid[k] = qtid[k+1];
qtid[k+1] = temp;
k += 1;
}
}
*/
/* Verify queue consistency. */
/* for ( k = 1 ; k < q->count ; k++ )
...
...
src/scheduler.c
View file @
692bb903
...
...
@@ -563,47 +563,47 @@ void scheduler_start ( struct scheduler *s , unsigned int mask ) {
// #pragma omp parallel for schedule(static) private(t,j)
for
(
k
=
s
->
nr_tasks
-
1
;
k
>=
0
;
k
--
)
{
t
=
&
tasks
[
tid
[
k
]
];
if
(
(
(
1
<<
t
->
type
)
&
mask
)
&&
!
t
->
skip
)
{
for
(
j
=
0
;
j
<
t
->
nr_unlock_tasks
;
j
++
)
atomic_inc
(
&
t
->
unlock_tasks
[
j
]
->
wait
);
t
->
maxdepth
=
0
;
t
->
weight
=
0
;
for
(
j
=
0
;
j
<
t
->
nr_unlock_tasks
;
j
++
)
{
if
(
t
->
unlock_tasks
[
j
]
->
weight
>
t
->
weight
)
t
->
weight
=
t
->
unlock_tasks
[
j
]
->
weight
;
if
(
t
->
unlock_tasks
[
j
]
->
maxdepth
>
t
->
maxdepth
)
t
->
maxdepth
=
t
->
unlock_tasks
[
j
]
->
maxdepth
;
}
t
->
maxdepth
+=
1
;
if
(
t
->
tic
>
0
)
t
->
weight
+=
t
->
toc
-
t
->
tic
;
else
switch
(
t
->
type
)
{
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
:
if
(
!
(
(
1
<<
t
->
type
)
&
mask
)
||
!
t
->
skip
)
continue
;
for
(
j
=
0
;
j
<
t
->
nr_unlock_tasks
;
j
++
)
atomic_inc
(
&
t
->
unlock_tasks
[
j
]
->
wait
);
t
->
maxdepth
=
0
;
t
->
weight
=
0
;
for
(
j
=
0
;
j
<
t
->
nr_unlock_tasks
;
j
++
)
{
if
(
t
->
unlock_tasks
[
j
]
->
weight
>
t
->
weight
)
t
->
weight
=
t
->
unlock_tasks
[
j
]
->
weight
;
if
(
t
->
unlock_tasks
[
j
]
->
maxdepth
>
t
->
maxdepth
)
t
->
maxdepth
=
t
->
unlock_tasks
[
j
]
->
maxdepth
;
}
t
->
maxdepth
+=
1
;
if
(
t
->
tic
>
0
)
t
->
weight
+=
t
->
toc
-
t
->
tic
;
else
switch
(
t
->
type
)
{
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
;
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
;
break
;
case
task_type_kick1
:
case
task_type_kick2
:
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
;
break
;
}
}
break
;
case
task_type_kick1
:
case
task_type_kick2
:
t
->
weight
+=
t
->
ci
->
count
;
break
;
}
}
/* Loop over the tasks and enqueue whoever is ready. */
...
...
@@ -636,7 +636,6 @@ void scheduler_enqueue ( struct scheduler *s , struct task *t ) {
case
task_type_self
:
case
task_type_sort
:
case
task_type_ghost
:
case
task_type_kick1
:
case
task_type_kick2
:
qid
=
t
->
ci
->
super
->
owner
;
break
;
...
...
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