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
a4f97e08
Commit
a4f97e08
authored
9 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Formatting...
parent
9ba56f6e
No related branches found
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
examples/main.c
+4
-4
4 additions, 4 deletions
examples/main.c
src/queue.c
+13
-12
13 additions, 12 deletions
src/queue.c
src/queue.h
+1
-1
1 addition, 1 deletion
src/queue.h
src/runner_doiact_grav.h
+2
-2
2 additions, 2 deletions
src/runner_doiact_grav.h
src/scheduler.c
+2
-4
2 additions, 4 deletions
src/scheduler.c
with
22 additions
and
23 deletions
examples/main.c
+
4
−
4
View file @
a4f97e08
...
...
@@ -50,10 +50,10 @@
*/
void
print_help_message
()
{
printf
(
"
\n
Usage: swift [OPTION
S
] PARAMFILE
\n
"
);
printf
(
" swift_mpi [OPTION
S
] PARAMFILE
\n
"
);
printf
(
" swift_fixdt [OPTION
S
] PARAMFILE
\n
"
);
printf
(
" swift_fixdt_mpi [OPTION
S
] PARAMFILE
\n\n
"
);
printf
(
"
\n
Usage: swift [OPTION]
...
PARAMFILE
\n
"
);
printf
(
" swift_mpi [OPTION]
...
PARAMFILE
\n
"
);
printf
(
" swift_fixdt [OPTION]
...
PARAMFILE
\n
"
);
printf
(
" swift_fixdt_mpi [OPTION]
...
PARAMFILE
\n\n
"
);
printf
(
"Valid options are:
\n
"
);
printf
(
" %2s %8s %s
\n
"
,
"-a"
,
""
,
"Pin runners using processor affinity"
);
...
...
This diff is collapsed.
Click to expand it.
src/queue.c
+
13
−
12
View file @
a4f97e08
...
...
@@ -58,14 +58,14 @@ void queue_get_incoming(struct queue *q) {
int
*
tid
=
q
->
tid
;
struct
task
*
tasks
=
q
->
tasks
;
/* Loop over the incoming DEQ. */
while
(
1
)
{
/* Is there a next element? */
const
int
ind
=
q
->
first_incoming
%
queue_incoming_size
;
if
(
q
->
tid_incoming
[
ind
]
<
0
)
break
;
/* Get the next offset off the DEQ. */
const
int
offset
=
atomic_swap
(
&
q
->
tid_incoming
[
ind
],
-
1
);
atomic_inc
(
&
q
->
first_incoming
);
...
...
@@ -108,28 +108,28 @@ void queue_get_incoming(struct queue *q) {
* @param q The #queue.
* @param t The #task.
*/
void
queue_insert
(
struct
queue
*
q
,
struct
task
*
t
)
{
/* Get an index in the DEQ. */
const
int
ind
=
atomic_inc
(
&
q
->
last_incoming
)
%
queue_incoming_size
;
/* Spin until the new offset can be stored. */
while
(
atomic_cas
(
&
q
->
tid_incoming
[
ind
],
-
1
,
t
-
q
->
tasks
)
!=
-
1
)
{
/* Try to get the queue lock, non-blocking, ensures that at
least somebody is working on this queue. */
if
(
lock_trylock
(
&
q
->
lock
)
==
0
)
{
/* Clean up the incoming DEQ. */
queue_get_incoming
(
q
);
/* Release the queue lock. */
if
(
lock_unlock
(
&
q
->
lock
)
!=
0
)
{
error
(
"Unlocking the qlock failed.
\n
"
);
}
}
}
/* Increase the incoming count. */
atomic_inc
(
&
q
->
count_incoming
);
}
...
...
@@ -156,9 +156,10 @@ void queue_init(struct queue *q, struct task *tasks) {
/* Init the queue lock. */
if
(
lock_init
(
&
q
->
lock
)
!=
0
)
error
(
"Failed to init queue lock."
);
/* Init the incoming DEQ. */
if
((
q
->
tid_incoming
=
(
int
*
)
malloc
(
sizeof
(
int
)
*
queue_incoming_size
))
==
NULL
)
if
((
q
->
tid_incoming
=
(
int
*
)
malloc
(
sizeof
(
int
)
*
queue_incoming_size
))
==
NULL
)
error
(
"Failed to allocate queue incoming buffer."
);
for
(
int
k
=
0
;
k
<
queue_incoming_size
;
k
++
)
{
q
->
tid_incoming
[
k
]
=
-
1
;
...
...
@@ -188,7 +189,7 @@ struct task *queue_gettask(struct queue *q, const struct task *prev,
}
else
{
if
(
lock_trylock
(
qlock
)
!=
0
)
return
NULL
;
}
/* Fill any tasks from the incoming DEQ. */
queue_get_incoming
(
q
);
...
...
This diff is collapsed.
Click to expand it.
src/queue.h
+
1
−
1
View file @
a4f97e08
...
...
@@ -52,7 +52,7 @@ struct queue {
/* The task indices. */
int
*
tid
;
/* DEQ for incoming tasks. */
int
*
tid_incoming
;
volatile
unsigned
int
first_incoming
,
last_incoming
,
count_incoming
;
...
...
This diff is collapsed.
Click to expand it.
src/runner_doiact_grav.h
+
2
−
2
View file @
a4f97e08
...
...
@@ -60,8 +60,8 @@ void runner_dopair_grav_new(struct runner *r, struct cell *ci,
sid
=
space_getsid
(
e
->
s
,
&
ci
,
&
cj
,
shift
);
/* Make sure the cells are sorted. */
//runner_do_gsort(r, ci, (1 << sid), 0);
//runner_do_gsort(r, cj, (1 << sid), 0);
//
runner_do_gsort(r, ci, (1 << sid), 0);
//
runner_do_gsort(r, cj, (1 << sid), 0);
/* Have the cells been sorted? */
if
(
!
(
ci
->
gsorted
&
(
1
<<
sid
))
||
!
(
cj
->
gsorted
&
(
1
<<
sid
)))
...
...
This diff is collapsed.
Click to expand it.
src/scheduler.c
+
2
−
4
View file @
a4f97e08
...
...
@@ -1254,8 +1254,7 @@ struct task *scheduler_gettask(struct scheduler *s, int qid,
tries
++
)
{
/* Try to get a task from the suggested queue. */
if
(
s
->
queues
[
qid
].
count
>
0
||
s
->
queues
[
qid
].
count_incoming
>
0
)
{
if
(
s
->
queues
[
qid
].
count
>
0
||
s
->
queues
[
qid
].
count_incoming
>
0
)
{
TIMER_TIC
res
=
queue_gettask
(
&
s
->
queues
[
qid
],
prev
,
0
);
TIMER_TOC
(
timer_qget
);
...
...
@@ -1266,8 +1265,7 @@ struct task *scheduler_gettask(struct scheduler *s, int qid,
if
(
s
->
flags
&
scheduler_flag_steal
)
{
int
count
=
0
,
qids
[
nr_queues
];
for
(
int
k
=
0
;
k
<
nr_queues
;
k
++
)
if
(
s
->
queues
[
k
].
count
>
0
||
s
->
queues
[
k
].
count_incoming
>
0
)
{
if
(
s
->
queues
[
k
].
count
>
0
||
s
->
queues
[
k
].
count_incoming
>
0
)
{
qids
[
count
++
]
=
k
;
}
for
(
int
k
=
0
;
k
<
scheduler_maxsteal
&&
count
>
0
;
k
++
)
{
...
...
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