Commit a4f97e08 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Formatting...

parent 9ba56f6e
......@@ -50,10 +50,10 @@
*/
void print_help_message() {
printf("\nUsage: swift [OPTIONS] PARAMFILE\n");
printf(" swift_mpi [OPTIONS] PARAMFILE\n");
printf(" swift_fixdt [OPTIONS] PARAMFILE\n");
printf(" swift_fixdt_mpi [OPTIONS] PARAMFILE\n\n");
printf("\nUsage: 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");
......
......@@ -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);
......
......@@ -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;
......
......@@ -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)))
......
......@@ -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++) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment