Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
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
SWIFT
SWIFTsim
Commits
bc2d9889
Commit
bc2d9889
authored
9 years ago
by
Pedro Gonnet
Browse files
Options
Downloads
Patches
Plain Diff
use a sliding window to find the task with the highest overlap with the previous task.
parent
c8f8bb0b
No related branches found
No related tags found
2 merge requests
!136
Master
,
!75
Overlapping tasks
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/queue.c
+61
-36
61 additions, 36 deletions
src/queue.c
src/queue.h
+2
-1
2 additions, 1 deletion
src/queue.h
with
63 additions
and
37 deletions
src/queue.c
+
61
−
36
View file @
bc2d9889
...
...
@@ -126,15 +126,14 @@ void queue_init(struct queue *q, struct task *tasks) {
* @brief Get a task free of dependencies and conflicts.
*
* @param q The task #queue.
* @param
super The super-cell tat might conflict with
th
e
#queue
* @param
prev The previous #task extracted from
th
is
#queue
.
* @param blocking Block until access to the queue is granted.
*/
struct
task
*
queue_gettask
(
struct
queue
*
q
,
struct
cell
*
super
,
int
blocking
)
{
struct
task
*
queue_gettask
(
struct
queue
*
q
,
const
struct
task
*
prev
,
int
blocking
)
{
int
k
,
qcount
,
*
qtid
,
gotcha
;
lock_type
*
qlock
=
&
q
->
lock
;
struct
task
*
qtasks
,
*
res
=
NULL
;
struct
task
*
res
=
NULL
;
/* If there are no tasks, leave immediately. */
if
(
q
->
count
==
0
)
return
NULL
;
...
...
@@ -147,49 +146,75 @@ struct task *queue_gettask(struct queue *q, struct cell *super, int blocking) {
}
/* Set some pointers we will use often. */
qtid
=
q
->
tid
;
qtasks
=
q
->
tasks
;
qcount
=
q
->
count
;
gotcha
=
0
;
/* Loop over the task IDs looking for tasks with the same super-cell. */
if
(
super
!=
NULL
)
{
for
(
k
=
0
;
k
<
qcount
&&
k
<
queue_maxsuper
;
k
++
)
{
/* Put a finger on the task. */
res
=
&
qtasks
[
qtid
[
k
]];
/* Try to lock the task and exit if successful. */
if
((
res
->
ci
->
super
==
super
||
(
res
->
cj
!=
NULL
&&
res
->
cj
->
super
==
super
))
&&
task_lock
(
res
))
{
gotcha
=
1
;
int
*
qtid
=
q
->
tid
;
struct
task
*
qtasks
=
q
->
tasks
;
const
int
qcount
=
q
->
count
;
/* Data for the sliding window in which to try the task with the
best overlap with the previous task. */
struct
{
int
ind
,
tid
;
float
score
;
}
window
[
queue_search_window
];
int
window_count
=
0
;
int
tid
=
-
1
;
int
ind
=
-
1
;
/* Loop over the queue entries. */
for
(
int
k
=
0
;
k
<
qcount
;
k
++
)
{
if
(
k
<
queue_search_window
)
{
window
[
window_count
].
ind
=
k
;
window
[
window_count
].
tid
=
qtid
[
k
];
window
[
window_count
].
score
=
task_overlap
(
prev
,
&
qtasks
[
qtid
[
k
]]);
window_count
+=
1
;
}
else
{
/* Find the task with the largest overlap. */
int
ind_max
=
0
;
for
(
int
i
=
1
;
i
<
window_count
;
i
++
)
if
(
window
[
i
].
score
>
window
[
ind_max
].
score
)
ind_max
=
i
;
/* Try to lock that task. */
if
(
task_lock
(
&
qtasks
[
window
[
ind_max
].
tid
]))
{
tid
=
window
[
ind_max
].
tid
;
ind
=
window
[
ind_max
].
ind
;
// message("best task has overlap %f.", window[ind_max].score);
break
;
}
}
/* loop over the task IDs. */
/* Otherwise, replace it with a new one from the queue. */
}
else
{
window
[
ind_max
].
ind
=
k
;
window
[
ind_max
].
tid
=
qtid
[
k
];
window
[
ind_max
].
score
=
task_overlap
(
prev
,
&
qtasks
[
qtid
[
k
]]);
}
}
}
/* Loop over the task IDs again if nothing was found, take anything. */
if
(
!
gotcha
)
{
for
(
k
=
0
;
k
<
qcount
;
k
++
)
{
/* Put a finger on the task. */
res
=
&
qtasks
[
qtid
[
k
]];
/* Try to lock the task and exit if successful. */
if
(
task_lock
(
res
))
break
;
}
/* loop over the task IDs. */
/* If we didn't get a task, loop through whatever is left in the window. */
if
(
tid
<
0
)
{
while
(
window_count
>
0
)
{
int
ind_max
=
0
;
for
(
int
i
=
1
;
i
<
window_count
;
i
++
)
if
(
window
[
i
].
score
>
window
[
ind_max
].
score
)
ind_max
=
i
;
if
(
task_lock
(
&
qtasks
[
window
[
ind_max
].
tid
]))
{
tid
=
window
[
ind_max
].
tid
;
ind
=
window
[
ind_max
].
ind
;
// message("best task has overlap %f.", window[ind_max].score);
break
;
}
else
{
window_count
-=
1
;
window
[
ind_max
]
=
window
[
window_count
];
}
}
}
/* Did we get a task? */
if
(
k
<
qcount
)
{
if
(
ind
>=
0
)
{
/* Another one bites the dust. */
qcount
=
q
->
count
-=
1
;
const
int
qcount
=
q
->
count
-=
1
;
/* Swap this task with the last task and re-heap. */
int
k
=
ind
;
if
(
k
<
qcount
)
{
qtid
[
k
]
=
qtid
[
qcount
];
int
w
=
qtasks
[
qtid
[
k
]].
weight
;
...
...
This diff is collapsed.
Click to expand it.
src/queue.h
+
2
−
1
View file @
bc2d9889
...
...
@@ -28,6 +28,7 @@
#define queue_maxsuper 50
#define queue_sizeinit 100
#define queue_sizegrow 2
#define queue_search_window 8
/* Counters. */
enum
{
...
...
@@ -54,7 +55,7 @@ struct queue {
}
__attribute__
((
aligned
(
64
)));
/* Function prototypes. */
struct
task
*
queue_gettask
(
struct
queue
*
q
,
struct
cell
*
super
,
int
blocking
);
struct
task
*
queue_gettask
(
struct
queue
*
q
,
const
struct
task
*
prev
,
int
blocking
);
void
queue_init
(
struct
queue
*
q
,
struct
task
*
tasks
);
void
queue_insert
(
struct
queue
*
q
,
struct
task
*
t
);
...
...
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