Commit 589cfb8f authored by Pedro Gonnet's avatar Pedro Gonnet
Browse files

fix allocation of struct queue, i.e. if the struct uses...

fix allocation of struct queue, i.e. if the struct uses __attribute__((aligned(*))), then we should allocate it with posix_memalign.
parent 868c773f
......@@ -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);
}
......
......@@ -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,
......
......@@ -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. */
......
......@@ -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];
......
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