diff --git a/src/cell.c b/src/cell.c index 54a4cc85f7996ba6b09c2ee0b56b7365bb75c790..b08d9ce8b10b01e2f107ecaae5fb56936a4688e6 100644 --- a/src/cell.c +++ b/src/cell.c @@ -486,8 +486,7 @@ void cell_split(struct cell *c, ptrdiff_t parts_offset, struct cell_buff *buff, #ifdef SWIFT_DEBUG_CHECKS /* Check that the buffs are OK. */ for (int k = 0; k < count; k++) { - if (buff[k].x[0] != parts[k].x[0] || - buff[k].x[1] != parts[k].x[1] || + if (buff[k].x[0] != parts[k].x[0] || buff[k].x[1] != parts[k].x[1] || buff[k].x[2] != parts[k].x[2]) error("Inconsistent buff contents."); } @@ -549,10 +548,8 @@ void cell_split(struct cell *c, ptrdiff_t parts_offset, struct cell_buff *buff, #ifdef SWIFT_DEBUG_CHECKS /* Check that the buffs are OK. */ for (int k = 1; k < count; k++) { - if (buff[k].ind < buff[k - 1].ind) - error("Buff not sorted."); - if (buff[k].x[0] != parts[k].x[0] || - buff[k].x[1] != parts[k].x[1] || + if (buff[k].ind < buff[k - 1].ind) error("Buff not sorted."); + if (buff[k].x[0] != parts[k].x[0] || buff[k].x[1] != parts[k].x[1] || buff[k].x[2] != parts[k].x[2]) error("Inconsistent buff contents (k=%i).", k); } diff --git a/src/queue.h b/src/queue.h index c0a2fb1da6e6e3cbea813a0ef53841084ab0f933..951a3e5a056d7ad0c3935f98341a0d93c805e3ad 100644 --- a/src/queue.h +++ b/src/queue.h @@ -30,6 +30,7 @@ #define queue_sizegrow 2 #define queue_search_window 8 #define queue_incoming_size 1024 +#define queue_struct_align 64 /* Counters. */ enum { @@ -57,7 +58,7 @@ struct queue { int *tid_incoming; volatile unsigned int first_incoming, last_incoming, count_incoming; -} __attribute__((aligned(64))); +} __attribute__((aligned(queue_struct_align))); /* Function prototypes. */ struct task *queue_gettask(struct queue *q, const struct task *prev, diff --git a/src/scheduler.c b/src/scheduler.c index 0d7c8c4754bac931c7886200176e3e9441c63c53..6dc7d67a1467333ea08ed2c72795c172d9a942e1 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -1408,8 +1408,8 @@ void scheduler_init(struct scheduler *s, struct space *space, int nr_tasks, lock_init(&s->lock); /* Allocate the queues. */ - if ((s->queues = (struct queue *)malloc(sizeof(struct queue) * nr_queues)) == - NULL) + if (posix_memalign((void **)&s->queues, queue_struct_align, + sizeof(struct queue) * nr_queues) != 0) error("Failed to allocate queues."); /* Initialize each queue. */ diff --git a/src/space.c b/src/space.c index 5ef0ee1df094f70433d9b963c958338b334ac439..2a46eecb23f12a361af21c40e1bdec0002a91b1b 100644 --- a/src/space.c +++ b/src/space.c @@ -1482,7 +1482,7 @@ void space_split_recursive(struct space *s, struct cell *c, if (allocate_buffer) { if (count > 0) { if (posix_memalign((void *)&buff, SWIFT_STRUCT_ALIGNMENT, - sizeof(struct cell_buff) * count) != 0) + sizeof(struct cell_buff) * count) != 0) error("Failed to allocate temporary indices."); for (int k = 0; k < count; k++) { buff[k].x[0] = parts[k].x[0]; @@ -1492,7 +1492,7 @@ void space_split_recursive(struct space *s, struct cell *c, } if (gcount > 0) { if (posix_memalign((void *)&gbuff, SWIFT_STRUCT_ALIGNMENT, - sizeof(struct cell_buff) * gcount) != 0) + sizeof(struct cell_buff) * gcount) != 0) error("Failed to allocate temporary indices."); for (int k = 0; k < gcount; k++) { gbuff[k].x[0] = gparts[k].x[0];