From 4ef3e774f0c2f36291328d5b81fee79eab5f9216 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <matthieu.schaller@durham.ac.uk> Date: Mon, 22 Aug 2016 22:02:04 +0100 Subject: [PATCH] Better documentation of the task structure. All fields are now correctly labelled and documented. --- examples/main.c | 4 +-- src/runner.c | 3 +- src/scheduler.c | 1 - src/task.c | 7 ++++- src/task.h | 77 +++++++++++++++++++++++++++++++++++++++---------- src/units.h | 27 ++++++++--------- 6 files changed, 85 insertions(+), 34 deletions(-) diff --git a/examples/main.c b/examples/main.c index 2abbef1e5d..8d7e613d4f 100644 --- a/examples/main.c +++ b/examples/main.c @@ -535,7 +535,7 @@ int main(int argc, char *argv[]) { if (!e.sched.tasks[l].skip && !e.sched.tasks[l].implicit) { fprintf( file_thread, " %03i %i %i %i %i %lli %lli %i %i %i %i %i\n", - myrank, e.sched.tasks[l].last_rid, e.sched.tasks[l].type, + myrank, e.sched.tasks[l].rid, e.sched.tasks[l].type, e.sched.tasks[l].subtype, (e.sched.tasks[l].cj == NULL), e.sched.tasks[l].tic, e.sched.tasks[l].toc, (e.sched.tasks[l].ci != NULL) ? e.sched.tasks[l].ci->count @@ -571,7 +571,7 @@ int main(int argc, char *argv[]) { if (!e.sched.tasks[l].skip && !e.sched.tasks[l].implicit) fprintf( file_thread, " %i %i %i %i %lli %lli %i %i %i %i\n", - e.sched.tasks[l].last_rid, e.sched.tasks[l].type, + e.sched.tasks[l].rid, e.sched.tasks[l].type, e.sched.tasks[l].subtype, (e.sched.tasks[l].cj == NULL), e.sched.tasks[l].tic, e.sched.tasks[l].toc, (e.sched.tasks[l].ci == NULL) ? 0 : e.sched.tasks[l].ci->count, diff --git a/src/runner.c b/src/runner.c index f7c061c145..96027b4588 100644 --- a/src/runner.c +++ b/src/runner.c @@ -1132,7 +1132,6 @@ void *runner_main(void *data) { struct cell *ci = t->ci; struct cell *cj = t->cj; t->rid = r->cpuid; - t->last_rid = r->cpuid; /* Different types of tasks... */ switch (t->type) { @@ -1211,6 +1210,7 @@ void *runner_main(void *data) { case task_type_kick_fixdt: runner_do_kick_fixdt(r, ci, 1); break; +#ifdef WITH_MPI case task_type_send: if (t->subtype == task_subtype_tend) { free(t->buff); @@ -1224,6 +1224,7 @@ void *runner_main(void *data) { runner_do_recv_cell(r, ci, 1); } break; +#endif case task_type_grav_mm: runner_do_grav_mm(r, t->ci, 1); break; diff --git a/src/scheduler.c b/src/scheduler.c index 88e448b504..ef4d19107f 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -704,7 +704,6 @@ struct task *scheduler_addtask(struct scheduler *s, enum task_types type, t->toc = 0; t->nr_unlock_tasks = 0; t->rid = -1; - t->last_rid = -1; /* Add an index for it. */ // lock_lock( &s->lock ); diff --git a/src/task.c b/src/task.c index f80068d465..2cecce9f06 100644 --- a/src/task.c +++ b/src/task.c @@ -46,7 +46,6 @@ #include "inline.h" #include "lock.h" -/* Task type names. */ const char *taskID_names[task_type_count] = { "none", "sort", "self", "pair", "sub_self", "sub_pair", "init", "ghost", "extra_ghost", "kick", @@ -58,6 +57,9 @@ const char *subtaskID_names[task_subtype_count] = { /** * @brief Computes the overlap between the parts array of two given cells. + * + * @param ci The first #cell. + * @param cj The second #cell. */ __attribute__((always_inline)) INLINE static size_t task_cell_overlap_part( const struct cell *ci, const struct cell *cj) { @@ -77,6 +79,9 @@ __attribute__((always_inline)) INLINE static size_t task_cell_overlap_part( /** * @brief Computes the overlap between the gparts array of two given cells. + * + * @param ci The first #cell. + * @param cj The second #cell. */ __attribute__((always_inline)) INLINE static size_t task_cell_overlap_gpart( const struct cell *ci, const struct cell *cj) { diff --git a/src/task.h b/src/task.h index d174bad4fa..c0c9e47ee4 100644 --- a/src/task.h +++ b/src/task.h @@ -23,15 +23,15 @@ #ifndef SWIFT_TASK_H #define SWIFT_TASK_H +#include "../config.h" + /* Includes. */ #include "cell.h" #include "cycle.h" -/* Some constants. */ -#define task_maxwait 3 -#define task_maxunlock 15 - -/* The different task types. */ +/** + * @brief The different task types. + */ enum task_types { task_type_none = 0, task_type_sort, @@ -54,9 +54,9 @@ enum task_types { task_type_count }; -extern const char *taskID_names[]; - -/* The different task sub-types. */ +/** + * @brief The different task sub-types (for pairs, selfs and sub-tasks). + */ enum task_subtypes { task_subtype_none = 0, task_subtype_density, @@ -67,7 +67,9 @@ enum task_subtypes { task_subtype_count }; -/* The kind of action the task perform */ +/** + * @brief The type of particles/objects this task acts upon in a given cell. + */ enum task_actions { task_action_none, task_action_part, @@ -77,29 +79,72 @@ enum task_actions { task_action_count }; +/** + * @brief Names of the task types. + */ +extern const char *taskID_names[]; + +/** + * @brief Names of the task sub-types. + */ extern const char *subtaskID_names[]; -/* Data of a task. */ +/** + * @brief A task to be run by the #scheduler. + */ struct task { + /*! Type of the task */ enum task_types type; + + /*! Sub-type of the task (for the tasks that have one */ enum task_subtypes subtype; - char skip, tight, implicit; - int flags, wait, rank, weight; + /*! 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; - void *buff; + /*! ID of the queue or runner owning this task */ + 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; + + /*! MPI request corresponding to this task */ MPI_Request req; + #endif - int rid, last_rid; + /*! Start and end time of this task */ ticks tic, toc; - int nr_unlock_tasks; - struct task **unlock_tasks; + /*! Should the scheduler skip this task ? */ + char skip; + + /*! Does this task require the particles to be tightly in the cell ? */ + char tight; + + /*! Is this task implicit (i.e. does not do anything) ? */ + char implicit; }; /* Function prototypes. */ diff --git a/src/units.h b/src/units.h index d189933993..9adaa7dc62 100644 --- a/src/units.h +++ b/src/units.h @@ -29,25 +29,26 @@ * @brief The unit system used internally. * * This structure contains the conversion factors to the 7 cgs base units to the - *internal units. - * It is used everytime a conversion is performed or an i/o function is called. - * + * internal units. It is used everytime a conversion is performed or an i/o + * function is called. **/ struct UnitSystem { - double UnitMass_in_cgs; /*< Conversion factor from grams to internal mass - units */ - double UnitLength_in_cgs; /*< Conversion factor from centimeters to internal - length units. */ + /*! Conversion factor from grams to internal mass units */ + double UnitMass_in_cgs; + + /*! Conversion factor from centimeters to internal length unit */ + double UnitLength_in_cgs; - double UnitTime_in_cgs; /*< Conversion factor from seconds to internal time - units. */ + /*! Conversion factor from seconds to internal time units */ + double UnitTime_in_cgs; - double UnitCurrent_in_cgs; /*< Conversion factor from Ampere to internal - current units. */ + /*! Conversion factor from Ampere to internal current units */ + double UnitCurrent_in_cgs; - double UnitTemperature_in_cgs; /*< Conversion factor from Kelvins to internal - temperature units. */ + /*! Conversion factor from Kelvins to internal temperature units. */ + double UnitTemperature_in_cgs; + }; /** -- GitLab