diff --git a/src/scheduler.c b/src/scheduler.c index f121f21d579611b76f2b4438bae560863dae727d..bb35527a7ad9980149a595b3540382fa6327a439 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -763,8 +763,9 @@ void scheduler_set_unlocks(struct scheduler *s) { t->unlock_tasks = &s->unlocks[offsets[k]]; } +#ifdef SWIFT_DEBUG_CHECKS /* Verify that there are no duplicate unlocks. */ - /* for (int k = 0; k < s->nr_tasks; k++) { + for (int k = 0; k < s->nr_tasks; k++) { struct task *t = &s->tasks[k]; for (int i = 0; i < t->nr_unlock_tasks; i++) { for (int j = i + 1; j < t->nr_unlock_tasks; j++) { @@ -772,7 +773,8 @@ void scheduler_set_unlocks(struct scheduler *s) { error("duplicate unlock!"); } } - } */ + } +#endif /* Clean up. */ free(counts); @@ -861,9 +863,11 @@ void scheduler_reset(struct scheduler *s, int size) { if (s->tasks_ind != NULL) free(s->tasks_ind); /* Allocate the new lists. */ - if ((s->tasks = (struct task *)malloc(sizeof(struct task) * size)) == - NULL || - (s->tasks_ind = (int *)malloc(sizeof(int) * size)) == NULL) + if (posix_memalign((void *)&s->tasks, task_align, + size * sizeof(struct task)) != 0) + error("Failed to allocate task array."); + + if ((s->tasks_ind = (int *)malloc(sizeof(int) * size)) == NULL) error("Failed to allocate task lists."); } diff --git a/src/task.h b/src/task.h index ac326fa1cf069eeb6159806b284396d251ff604f..f3e04007fae1bee07e208dbded87ebce5a9e4db4 100644 --- a/src/task.h +++ b/src/task.h @@ -29,6 +29,8 @@ #include "cell.h" #include "cycle.h" +#define task_align 32 + /** * @brief The different task types. */ @@ -103,6 +105,16 @@ struct task { /*! Start and end time of this task */ ticks tic, toc; +#ifdef WITH_MPI + + /*! Buffer for this task's communications */ + void *buff; + + /*! MPI request corresponding to this task */ + MPI_Request req; + +#endif + /*! Flags used to carry additional information (e.g. sort directions) */ int flags; @@ -121,16 +133,6 @@ struct task { /*! Number of unsatisfied dependencies */ short int wait; -#ifdef WITH_MPI - - /*! Buffer for this task's communications */ - void *buff; - - /*! MPI request corresponding to this task */ - MPI_Request req; - -#endif - /*! Type of the task */ enum task_types type; @@ -145,7 +147,8 @@ struct task { /*! Is this task implicit (i.e. does not do anything) ? */ char implicit; -}; + +} __attribute__((aligned(task_align))); /* Function prototypes. */ void task_unlock(struct task *t);