diff --git a/examples/main.c b/examples/main.c index 2637789e323439d9f0e467451294707e4f095666..6422ccceef0a5f5c5f3b5acce9ba60b957986aac 100644 --- a/examples/main.c +++ b/examples/main.c @@ -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"); diff --git a/src/queue.c b/src/queue.c index 192df29a30ac38a3bdeba125d76f81385004c3aa..a62ded2561fc683bf2f44abcf1110b0fb7eebd0c 100644 --- a/src/queue.c +++ b/src/queue.c @@ -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); diff --git a/src/queue.h b/src/queue.h index 84d2a02e1d3e94096e16d788dc047dd5fc6a702e..5878866c890f53f22c3deaac7fe9b6bba75d499e 100644 --- a/src/queue.h +++ b/src/queue.h @@ -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; diff --git a/src/runner_doiact_grav.h b/src/runner_doiact_grav.h index ee9f2ba3233e022cb8c959ef84f30ed72438e1f3..13e6fe68ca223fa95a307fd063208e1f5d5efa6c 100644 --- a/src/runner_doiact_grav.h +++ b/src/runner_doiact_grav.h @@ -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))) diff --git a/src/scheduler.c b/src/scheduler.c index e28600ef685bbba7e052df58654153e327ab7fde..d58957f521f3b910e5360594aa1f0210c1dc4532 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -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++) {