Commit 6253661d authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Make the depth of the resort task a user-defined parameter.

parent 18eab64f
......@@ -70,6 +70,8 @@
#include "tools.h"
#include "tracers.h"
extern int engine_star_resort_task_depth;
/* Global variables. */
int cell_next_tag = 0;
......@@ -2397,6 +2399,19 @@ void cell_clear_limiter_flags(struct cell *c, void *data) {
cell_flag_do_hydro_limiter | cell_flag_do_hydro_sub_limiter);
}
void cell_activate_star_resort_tasks(struct cell *c, struct scheduler *s) {
if (c->depth == engine_star_resort_task_depth || c->hydro.super == c) {
scheduler_activate(s, c->hydro.stars_resort);
} else {
for (int k = 0; k < 8; ++k) {
if (c->progeny[k] != NULL) {
cell_activate_star_resort_tasks(c->progeny[k], s);
}
}
}
}
void cell_activate_star_formation_tasks(struct cell *c, struct scheduler *s) {
if (c->depth != 0) error("Function should be called at the top-level only");
......@@ -2407,20 +2422,8 @@ void cell_activate_star_formation_tasks(struct cell *c, struct scheduler *s) {
/* Activate the star formation task */
scheduler_activate(s, c->hydro.star_formation);
/* Shallow tree case -> the resort task is at this level */
if (c->hydro.super == c) {
scheduler_activate(s, c->hydro.stars_resort);
}
/* Deep tree case -> the resort is in the progenies */
else {
for (int k = 0; k < 8; ++k) {
if (c->progeny[k] != NULL) {
scheduler_activate(s, c->progeny[k]->hydro.stars_resort);
}
}
}
/* Activate the star resort tasks at whatever level they are */
cell_activate_star_resort_tasks(c, s);
}
/**
......
......@@ -113,6 +113,7 @@ enum engine_step_properties {
#define engine_default_timesteps_file_name "timesteps"
#define engine_max_parts_per_ghost_default 1000
#define engine_max_sparts_per_ghost_default 1000
#define engine_star_resort_task_depth_default 2
#define engine_tasks_per_cell_margin 1.2
/**
......
......@@ -54,6 +54,7 @@
extern int engine_max_parts_per_ghost;
extern int engine_max_sparts_per_ghost;
extern int engine_star_resort_task_depth;
/**
* @brief Add send tasks for the gravity pairs to a hierarchy of cells.
......@@ -987,29 +988,17 @@ void engine_make_hierarchical_tasks_hydro(struct engine *e, struct cell *c,
const int with_star_formation = (e->policy & engine_policy_star_formation);
const int with_black_holes = (e->policy & engine_policy_black_holes);
/* Are we at the top-level but this is also the super-level? */
if (c->top == c && c->nodeID == e->nodeID) {
/* Record this is the level where we re-sort */
star_resort_cell = c;
/* Are we are the level where we create the stars' resort tasks?
* If the tree is shallow, we need to do this at the super-level if the
* super-level is above the level we want */
if ((c->nodeID == e->nodeID) && (star_resort_cell == NULL) &&
(c->depth == engine_star_resort_task_depth || c->hydro.super == c)) {
if (with_star_formation && c->hydro.count > 0) {
if (c->hydro.super == c) {
c->hydro.stars_resort = scheduler_addtask(
s, task_type_stars_resort, task_subtype_none, 0, 0, c, NULL);
scheduler_addunlock(s, c->hydro.star_formation, c->hydro.stars_resort);
}
}
}
if (c->depth == 1 && c->nodeID == e->nodeID) {
/* Record this is the level where we re-sort */
star_resort_cell = c;
if (with_star_formation && c->hydro.count > 0) {
c->hydro.stars_resort = scheduler_addtask(
s, task_type_stars_resort, task_subtype_none, 0, 0, c, NULL);
......
......@@ -91,6 +91,7 @@ int space_extra_gparts = space_extra_gparts_default;
/*! Maximum number of particles per ghost */
int engine_max_parts_per_ghost = engine_max_parts_per_ghost_default;
int engine_max_sparts_per_ghost = engine_max_sparts_per_ghost_default;
int engine_star_resort_task_depth = engine_star_resort_task_depth_default;
/*! Expected maximal number of strays received at a rebuild */
int space_expected_max_nr_strays = space_expected_max_nr_strays_default;
......
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