Commit 2df8f6eb authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Removed the scheduler mask and submask.

parent f733b66d
......@@ -2506,11 +2506,8 @@ void engine_print_stats(struct engine *e) {
*
* @param e The #engine.
* @param nr_runners The number of #runner to let loose.
* @param mask The task mask to launch.
* @param submask The sub-task mask to launch.
*/
void engine_launch(struct engine *e, int nr_runners, unsigned int mask,
unsigned int submask) {
void engine_launch(struct engine *e, int nr_runners) {
const ticks tic = getticks();
......@@ -2525,7 +2522,7 @@ void engine_launch(struct engine *e, int nr_runners, unsigned int mask,
/* Load the tasks. */
pthread_mutex_unlock(&e->barrier_mutex);
scheduler_start(&e->sched, mask, submask);
scheduler_start(&e->sched);
pthread_mutex_lock(&e->barrier_mutex);
/* Remove the safeguard. */
......@@ -2565,61 +2562,60 @@ void engine_init_particles(struct engine *e, int flag_entropy_ICs) {
engine_marktasks(e);
/* Build the masks corresponding to the policy */
unsigned int mask = 0;
unsigned int submask = 0;
/* /\* Build the masks corresponding to the policy *\/ */
/* unsigned int mask = 0; */
/* unsigned int submask = 0; */
/* We always have sort tasks */
mask |= 1 << task_type_sort;
mask |= 1 << task_type_init;
/* /\* We always have sort tasks *\/ */
/* mask |= 1 << task_type_sort; */
/* mask |= 1 << task_type_init; */
/* Add the tasks corresponding to hydro operations to the masks */
if (e->policy & engine_policy_hydro) {
/* /\* Add the tasks corresponding to hydro operations to the masks *\/ */
/* if (e->policy & engine_policy_hydro) { */
/* mask |= 1 << task_type_self; */
/* mask |= 1 << task_type_pair; */
/* mask |= 1 << task_type_sub_self; */
/* mask |= 1 << task_type_sub_pair; */
/* mask |= 1 << task_type_ghost; */
mask |= 1 << task_type_self;
mask |= 1 << task_type_pair;
mask |= 1 << task_type_sub_self;
mask |= 1 << task_type_sub_pair;
mask |= 1 << task_type_ghost;
/* submask |= 1 << task_subtype_density; */
/* } */
submask |= 1 << task_subtype_density;
}
/* /\* Add the tasks corresponding to self-gravity to the masks *\/ */
/* if (e->policy & engine_policy_self_gravity) { */
/* Add the tasks corresponding to self-gravity to the masks */
if (e->policy & engine_policy_self_gravity) {
/* mask |= 1 << task_type_grav_up; */
/* mask |= 1 << task_type_grav_mm; */
/* mask |= 1 << task_type_grav_gather_m; */
/* mask |= 1 << task_type_grav_fft; */
/* mask |= 1 << task_type_self; */
/* mask |= 1 << task_type_pair; */
/* mask |= 1 << task_type_sub_self; */
/* mask |= 1 << task_type_sub_pair; */
mask |= 1 << task_type_grav_up;
mask |= 1 << task_type_grav_mm;
mask |= 1 << task_type_grav_gather_m;
mask |= 1 << task_type_grav_fft;
mask |= 1 << task_type_self;
mask |= 1 << task_type_pair;
mask |= 1 << task_type_sub_self;
mask |= 1 << task_type_sub_pair;
/* submask |= 1 << task_subtype_grav; */
/* } */
submask |= 1 << task_subtype_grav;
}
/* /\* Add the tasks corresponding to external gravity to the masks *\/ */
/* if (e->policy & engine_policy_external_gravity) { */
/* Add the tasks corresponding to external gravity to the masks */
if (e->policy & engine_policy_external_gravity) {
/* mask |= 1 << task_type_self; */
/* mask |= 1 << task_type_sub_self; */
mask |= 1 << task_type_self;
mask |= 1 << task_type_sub_self;
/* submask |= 1 << task_subtype_external_grav; */
/* } */
submask |= 1 << task_subtype_external_grav;
}
/* /\* Add MPI tasks if need be *\/ */
/* if (e->policy & engine_policy_mpi) { */
/* Add MPI tasks if need be */
if (e->policy & engine_policy_mpi) {
mask |= 1 << task_type_send;
mask |= 1 << task_type_recv;
submask |= 1 << task_subtype_tend;
}
/* mask |= 1 << task_type_send; */
/* mask |= 1 << task_type_recv; */
/* submask |= 1 << task_subtype_tend; */
/* } */
/* Now, launch the calculation */
TIMER_TIC;
engine_launch(e, e->nr_threads, mask, submask);
engine_launch(e, e->nr_threads);
TIMER_TOC(timer_runners);
/* Apply some conversions (e.g. internal energy -> entropy) */
......@@ -2629,8 +2625,7 @@ void engine_init_particles(struct engine *e, int flag_entropy_ICs) {
space_map_cells_pre(s, 0, cell_convert_hydro, NULL);
/* Correct what we did (e.g. in PE-SPH, need to recompute rho_bar) */
if (hydro_need_extra_init_loop)
engine_launch(e, e->nr_threads, mask, submask);
if (hydro_need_extra_init_loop) engine_launch(e, e->nr_threads);
}
clocks_gettime(&time2);
......@@ -2707,7 +2702,7 @@ void engine_step(struct engine *e) {
/* Drift only the necessary particles, that means all particles
* if we are about to repartition. */
int repart = (e->forcerepart != REPART_NONE);
const int repart = (e->forcerepart != REPART_NONE);
e->drift_all = repart || e->drift_all;
engine_drift(e);
......@@ -2720,85 +2715,85 @@ void engine_step(struct engine *e) {
/* Restore the default drifting policy */
e->drift_all = (e->policy & engine_policy_drift_all);
/* Build the masks corresponding to the policy */
unsigned int mask = 0, submask = 0;
/* /\* Build the masks corresponding to the policy *\/ */
/* unsigned int mask = 0, submask = 0; */
/* We always have sort tasks and init tasks */
mask |= 1 << task_type_sort;
mask |= 1 << task_type_init;
/* /\* We always have sort tasks and init tasks *\/ */
/* mask |= 1 << task_type_sort; */
/* mask |= 1 << task_type_init; */
/* Add the correct kick task */
if (e->policy & engine_policy_fixdt) {
mask |= 1 << task_type_kick_fixdt;
} else {
mask |= 1 << task_type_kick;
}
/* /\* Add the correct kick task *\/ */
/* if (e->policy & engine_policy_fixdt) { */
/* mask |= 1 << task_type_kick_fixdt; */
/* } else { */
/* mask |= 1 << task_type_kick; */
/* } */
/* Add the tasks corresponding to hydro operations to the masks */
if (e->policy & engine_policy_hydro) {
/* /\* Add the tasks corresponding to hydro operations to the masks *\/ */
/* if (e->policy & engine_policy_hydro) { */
mask |= 1 << task_type_self;
mask |= 1 << task_type_pair;
mask |= 1 << task_type_sub_self;
mask |= 1 << task_type_sub_pair;
mask |= 1 << task_type_ghost;
/* mask |= 1 << task_type_self; */
/* mask |= 1 << task_type_pair; */
/* mask |= 1 << task_type_sub_self; */
/* mask |= 1 << task_type_sub_pair; */
/* mask |= 1 << task_type_ghost; */
submask |= 1 << task_subtype_density;
submask |= 1 << task_subtype_force;
/* submask |= 1 << task_subtype_density; */
/* submask |= 1 << task_subtype_force; */
#ifdef EXTRA_HYDRO_LOOP
mask |= 1 << task_type_extra_ghost;
submask |= 1 << task_subtype_gradient;
#endif
}
/* #ifdef EXTRA_HYDRO_LOOP */
/* mask |= 1 << task_type_extra_ghost; */
/* submask |= 1 << task_subtype_gradient; */
/* #endif */
/* } */
/* Add the tasks corresponding to self-gravity to the masks */
if (e->policy & engine_policy_self_gravity) {
/* /\* Add the tasks corresponding to self-gravity to the masks *\/ */
/* if (e->policy & engine_policy_self_gravity) { */
mask |= 1 << task_type_grav_up;
mask |= 1 << task_type_grav_mm;
mask |= 1 << task_type_grav_gather_m;
mask |= 1 << task_type_grav_fft;
mask |= 1 << task_type_self;
mask |= 1 << task_type_pair;
mask |= 1 << task_type_sub_self;
mask |= 1 << task_type_sub_pair;
/* mask |= 1 << task_type_grav_up; */
/* mask |= 1 << task_type_grav_mm; */
/* mask |= 1 << task_type_grav_gather_m; */
/* mask |= 1 << task_type_grav_fft; */
/* mask |= 1 << task_type_self; */
/* mask |= 1 << task_type_pair; */
/* mask |= 1 << task_type_sub_self; */
/* mask |= 1 << task_type_sub_pair; */
submask |= 1 << task_subtype_grav;
}
/* submask |= 1 << task_subtype_grav; */
/* } */
/* Add the tasks corresponding to external gravity to the masks */
if (e->policy & engine_policy_external_gravity) {
/* /\* Add the tasks corresponding to external gravity to the masks *\/ */
/* if (e->policy & engine_policy_external_gravity) { */
mask |= 1 << task_type_self;
mask |= 1 << task_type_sub_self;
/* mask |= 1 << task_type_self; */
/* mask |= 1 << task_type_sub_self; */
submask |= 1 << task_subtype_external_grav;
}
/* submask |= 1 << task_subtype_external_grav; */
/* } */
/* Add the tasks corresponding to cooling to the masks */
if (e->policy & engine_policy_cooling) {
mask |= 1 << task_type_cooling;
}
/* /\* Add the tasks corresponding to cooling to the masks *\/ */
/* if (e->policy & engine_policy_cooling) { */
/* mask |= 1 << task_type_cooling; */
/* } */
/* Add the tasks corresponding to sourceterms to the masks */
if (e->policy & engine_policy_sourceterms) {
mask |= 1 << task_type_sourceterms;
}
/* /\* Add the tasks corresponding to sourceterms to the masks *\/ */
/* if (e->policy & engine_policy_sourceterms) { */
/* mask |= 1 << task_type_sourceterms; */
/* } */
/* Add MPI tasks if need be */
if (e->policy & engine_policy_mpi) {
/* /\* Add MPI tasks if need be *\/ */
/* if (e->policy & engine_policy_mpi) { */
mask |= 1 << task_type_send;
mask |= 1 << task_type_recv;
submask |= 1 << task_subtype_tend;
}
/* mask |= 1 << task_type_send; */
/* mask |= 1 << task_type_recv; */
/* submask |= 1 << task_subtype_tend; */
/* } */
if (e->verbose) engine_print_task_counts(e);
/* Send off the runners. */
TIMER_TIC;
engine_launch(e, e->nr_threads, mask, submask);
engine_launch(e, e->nr_threads);
TIMER_TOC(timer_runners);
/* Save some statistics */
......
......@@ -230,8 +230,7 @@ void engine_init(struct engine *e, struct space *s,
const struct external_potential *potential,
const struct cooling_function_data *cooling,
struct sourceterms *sourceterms);
void engine_launch(struct engine *e, int nr_runners, unsigned int mask,
unsigned int submask);
void engine_launch(struct engine *e, int nr_runners);
void engine_prepare(struct engine *e, int nodrift);
void engine_print(struct engine *e);
void engine_init_particles(struct engine *e, int flag_entropy_ICs);
......
......@@ -888,8 +888,6 @@ void scheduler_reset(struct scheduler *s, int size) {
s->nr_tasks = 0;
s->tasks_next = 0;
s->waiting = 0;
s->mask = 0;
s->submask = 0;
s->nr_unlocks = 0;
s->completed_unlock_writes = 0;
s->active_count = 0;
......@@ -996,15 +994,12 @@ void scheduler_reweight(struct scheduler *s, int verbose) {
void scheduler_rewait_mapper(void *map_data, int num_elements,
void *extra_data) {
struct scheduler *s = (struct scheduler *)extra_data;
struct task *tasks = (struct task *)map_data;
for (int ind = 0; ind < num_elements; ind++) {
struct task *t = &tasks[ind];
if (t->skip || !((1 << t->type) & s->mask) ||
!((1 << t->subtype) & s->submask))
continue;
if (t->skip) continue;
/* Skip sort tasks that have already been performed */
if (t->type == task_type_sort && t->flags == 0) {
......@@ -1026,8 +1021,7 @@ void scheduler_enqueue_mapper(void *map_data, int num_elements,
struct task *tasks = s->tasks;
for (int ind = 0; ind < num_elements; ind++) {
struct task *t = &tasks[tid[ind]];
if (atomic_dec(&t->wait) == 1 && !t->skip && ((1 << t->type) & s->mask) &&
((1 << t->subtype) & s->submask)) {
if (atomic_dec(&t->wait) == 1 && !t->skip) {
scheduler_enqueue(s, t);
}
}
......@@ -1038,16 +1032,8 @@ void scheduler_enqueue_mapper(void *map_data, int num_elements,
* @brief Start the scheduler, i.e. fill the queues with ready tasks.
*
* @param s The #scheduler.
* @param mask The task types to enqueue.
* @param submask The sub-task types to enqueue.
*/
void scheduler_start(struct scheduler *s, unsigned int mask,
unsigned int submask) {
/* Store the masks */
s->mask = mask;
s->submask = submask | (1 << task_subtype_none);
void scheduler_start(struct scheduler *s) {
/* Clear all the waits, rids, and times. */
for (int k = 0; k < s->nr_tasks; k++) {
......@@ -1055,14 +1041,11 @@ void scheduler_start(struct scheduler *s, unsigned int mask,
s->tasks[k].rid = -1;
s->tasks[k].tic = 0;
s->tasks[k].toc = 0;
if (((1 << s->tasks[k].type) & mask) == 0 ||
((1 << s->tasks[k].subtype) & s->submask) == 0)
s->tasks[k].skip = 1;
}
/* Re-wait the tasks. */
threadpool_map(s->threadpool, scheduler_rewait_mapper, s->tasks, s->nr_tasks,
sizeof(struct task), 1000, s);
sizeof(struct task), 1000, NULL);
/* Check we have not missed an active task */
#ifdef SWIFT_DEBUG_CHECKS
......@@ -1109,8 +1092,7 @@ void scheduler_start(struct scheduler *s, unsigned int mask,
/* Loop over the tasks and enqueue whoever is ready. */
for (int k = 0; k < s->active_count; k++) {
struct task *t = &s->tasks[s->tid_active[k]];
if (atomic_dec(&t->wait) == 1 && !t->skip && ((1 << t->type) & s->mask) &&
((1 << t->subtype) & s->submask)) {
if (atomic_dec(&t->wait) == 1 && !t->skip) {
scheduler_enqueue(s, t);
pthread_cond_signal(&s->sleep_cond);
}
......@@ -1140,11 +1122,8 @@ void scheduler_enqueue(struct scheduler *s, struct task *t) {
/* Fail if this task has already been enqueued before. */
if (t->rid >= 0) error("Task has already been enqueued.");
/* Ignore skipped tasks and tasks not in the masks. */
if (t->skip || (1 << t->type) & ~(s->mask) ||
(1 << t->subtype) & ~(s->submask)) {
return;
}
/* Ignore skipped tasks */
if (t->skip) return;
/* If this is an implicit task, just pretend it's done. */
if (t->implicit) {
......
......@@ -60,12 +60,6 @@ struct scheduler {
/* Scheduler flags. */
unsigned int flags;
/* Scheduler task mask */
unsigned int mask;
/* Scheduler sub-task mask */
unsigned int submask;
/* Number of queues in this scheduler. */
int nr_queues;
......@@ -117,7 +111,6 @@ struct scheduler {
* @param s The #scheduler.
* @param t The task to be added.
*/
__attribute__((always_inline)) INLINE static void scheduler_activate(
struct scheduler *s, struct task *t) {
if (atomic_cas(&t->skip, 1, 0)) {
......@@ -134,8 +127,7 @@ void scheduler_init(struct scheduler *s, struct space *space, int nr_tasks,
struct task *scheduler_gettask(struct scheduler *s, int qid,
const struct task *prev);
void scheduler_enqueue(struct scheduler *s, struct task *t);
void scheduler_start(struct scheduler *s, unsigned int mask,
unsigned int submask);
void scheduler_start(struct scheduler *s);
void scheduler_reset(struct scheduler *s, int nr_tasks);
void scheduler_ranktasks(struct scheduler *s);
void scheduler_reweight(struct scheduler *s, int verbose);
......
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