diff --git a/src/scheduler.c b/src/scheduler.c index 0d50a4e7af70982ef2ad4088b0a80fc09bf5ca6d..0b70bd93d8b9e0e22e5b8e80faac99b6dbfbdb9d 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -764,8 +764,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++) { @@ -773,7 +774,8 @@ void scheduler_set_unlocks(struct scheduler *s) { error("duplicate unlock!"); } } - } */ + } +#endif /* Clean up. */ free(counts); @@ -862,9 +864,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 c0c9e47ee4ca221f9f960256e9208c749ae523ea..5f26ec05b026518de1234162d1f5f1d195672507 100644 --- a/src/task.h +++ b/src/task.h @@ -29,6 +29,8 @@ #include "cell.h" #include "cycle.h" +#define task_align 128 + /** * @brief The different task types. */ @@ -52,7 +54,7 @@ enum task_types { task_type_grav_up, task_type_grav_external, task_type_count -}; +} __attribute__((packed)); /** * @brief The different task sub-types (for pairs, selfs and sub-tasks). @@ -65,7 +67,7 @@ enum task_subtypes { task_subtype_grav, task_subtype_tend, task_subtype_count -}; +} __attribute__((packed)); /** * @brief The type of particles/objects this task acts upon in a given cell. @@ -94,48 +96,48 @@ extern const char *subtaskID_names[]; */ struct task { - /*! Type of the task */ - enum task_types type; + /*! Pointers to the cells this task acts upon */ + struct cell *ci, *cj; - /*! Sub-type of the task (for the tasks that have one */ - enum task_subtypes subtype; + /*! List of tasks unlocked by this one */ + struct task **unlock_tasks; + + /*! 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; - /*! Number of unsatisfied dependencies */ - int wait; - /*! Rank of a task in the order */ int rank; /*! Weight of the task */ int weight; - /*! Pointers to the cells this task acts upon */ - struct cell *ci, *cj; - /*! ID of the queue or runner owning this task */ - int rid; + short int rid; /*! Number of tasks unlocked by this one */ - int nr_unlock_tasks; - - /*! List of tasks unlocked by this one */ - struct task **unlock_tasks; - -#ifdef WITH_MPI - - /*! Buffer for this task's communications */ - void *buff; + short int nr_unlock_tasks; - /*! MPI request corresponding to this task */ - MPI_Request req; + /*! Number of unsatisfied dependencies */ + short int wait; -#endif + /*! Type of the task */ + enum task_types type; - /*! Start and end time of this task */ - ticks tic, toc; + /*! Sub-type of the task (for the tasks that have one */ + enum task_subtypes subtype; /*! Should the scheduler skip this task ? */ char skip; @@ -145,7 +147,8 @@ struct task { /*! Is this task implicit (i.e. does not do anything) ? */ char implicit; -}; + +} __attribute__((aligned(32))); /* Function prototypes. */ void task_unlock(struct task *t);