Skip to content
Snippets Groups Projects
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
Branches
Tags
1 merge request!294Buffered cell_split
...@@ -486,8 +486,7 @@ void cell_split(struct cell *c, ptrdiff_t parts_offset, struct cell_buff *buff, ...@@ -486,8 +486,7 @@ void cell_split(struct cell *c, ptrdiff_t parts_offset, struct cell_buff *buff,
#ifdef SWIFT_DEBUG_CHECKS #ifdef SWIFT_DEBUG_CHECKS
/* Check that the buffs are OK. */ /* Check that the buffs are OK. */
for (int k = 0; k < count; k++) { for (int k = 0; k < count; k++) {
if (buff[k].x[0] != parts[k].x[0] || if (buff[k].x[0] != parts[k].x[0] || buff[k].x[1] != parts[k].x[1] ||
buff[k].x[1] != parts[k].x[1] ||
buff[k].x[2] != parts[k].x[2]) buff[k].x[2] != parts[k].x[2])
error("Inconsistent buff contents."); error("Inconsistent buff contents.");
} }
...@@ -549,10 +548,8 @@ void cell_split(struct cell *c, ptrdiff_t parts_offset, struct cell_buff *buff, ...@@ -549,10 +548,8 @@ void cell_split(struct cell *c, ptrdiff_t parts_offset, struct cell_buff *buff,
#ifdef SWIFT_DEBUG_CHECKS #ifdef SWIFT_DEBUG_CHECKS
/* Check that the buffs are OK. */ /* Check that the buffs are OK. */
for (int k = 1; k < count; k++) { for (int k = 1; k < count; k++) {
if (buff[k].ind < buff[k - 1].ind) if (buff[k].ind < buff[k - 1].ind) error("Buff not sorted.");
error("Buff not sorted."); 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]) buff[k].x[2] != parts[k].x[2])
error("Inconsistent buff contents (k=%i).", k); error("Inconsistent buff contents (k=%i).", k);
} }
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#define queue_sizegrow 2 #define queue_sizegrow 2
#define queue_search_window 8 #define queue_search_window 8
#define queue_incoming_size 1024 #define queue_incoming_size 1024
#define queue_struct_align 64
/* Counters. */ /* Counters. */
enum { enum {
...@@ -57,7 +58,7 @@ struct queue { ...@@ -57,7 +58,7 @@ struct queue {
int *tid_incoming; int *tid_incoming;
volatile unsigned int first_incoming, last_incoming, count_incoming; volatile unsigned int first_incoming, last_incoming, count_incoming;
} __attribute__((aligned(64))); } __attribute__((aligned(queue_struct_align)));
/* Function prototypes. */ /* Function prototypes. */
struct task *queue_gettask(struct queue *q, const struct task *prev, 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, ...@@ -1408,8 +1408,8 @@ void scheduler_init(struct scheduler *s, struct space *space, int nr_tasks,
lock_init(&s->lock); lock_init(&s->lock);
/* Allocate the queues. */ /* Allocate the queues. */
if ((s->queues = (struct queue *)malloc(sizeof(struct queue) * nr_queues)) == if (posix_memalign((void **)&s->queues, queue_struct_align,
NULL) sizeof(struct queue) * nr_queues) != 0)
error("Failed to allocate queues."); error("Failed to allocate queues.");
/* Initialize each queue. */ /* Initialize each queue. */
......
...@@ -1482,7 +1482,7 @@ void space_split_recursive(struct space *s, struct cell *c, ...@@ -1482,7 +1482,7 @@ void space_split_recursive(struct space *s, struct cell *c,
if (allocate_buffer) { if (allocate_buffer) {
if (count > 0) { if (count > 0) {
if (posix_memalign((void *)&buff, SWIFT_STRUCT_ALIGNMENT, 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."); error("Failed to allocate temporary indices.");
for (int k = 0; k < count; k++) { for (int k = 0; k < count; k++) {
buff[k].x[0] = parts[k].x[0]; buff[k].x[0] = parts[k].x[0];
...@@ -1492,7 +1492,7 @@ void space_split_recursive(struct space *s, struct cell *c, ...@@ -1492,7 +1492,7 @@ void space_split_recursive(struct space *s, struct cell *c,
} }
if (gcount > 0) { if (gcount > 0) {
if (posix_memalign((void *)&gbuff, SWIFT_STRUCT_ALIGNMENT, 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."); error("Failed to allocate temporary indices.");
for (int k = 0; k < gcount; k++) { for (int k = 0; k < gcount; k++) {
gbuff[k].x[0] = gparts[k].x[0]; gbuff[k].x[0] = gparts[k].x[0];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment