diff --git a/doc/RTD/source/Task/adding_your_own.rst b/doc/RTD/source/Task/adding_your_own.rst index d7ddd3e9a9b4d5791297f519b3827c3eac333dd1..fe89807e2531d64c399064b05280ffc677204002 100644 --- a/doc/RTD/source/Task/adding_your_own.rst +++ b/doc/RTD/source/Task/adding_your_own.rst @@ -234,6 +234,26 @@ and give the task an estimate of the computational cost that it will have in This activates your tasks once they've been created. + +If your task has some computational weight, i.e. does some actual computation +on particles, you'll also need to add it to the list of task types checked for +weights in ``partition.c:partition_gather_weights(...)``:: + + /* Get the cell IDs. */ + int cid = ci - cells; + + /* Different weights for different tasks. */ + if (t->type == task_type_init_grav || t->type == task_type_ghost || + ... long list of task types ... + add your new task type here ) + + do stuff + +And the same needs to be done in the ``check_weights(...)`` function further +down in the same file ``partition.c``, where the same list of task types +is being checked for. + + Initially, the engine will need to skip the task that updates the particles. It is the case for the cooling, therefore you will need to add it in ``engine_skip_force_and_kick()``. @@ -244,11 +264,16 @@ don't need to be recreated every time step. In order to be unskipped however, you need to add the unskipping manually to ``engine_do_unskip_mapper()`` in ``engine_unskip.c``. + + Finally, you also need to initialize your new variables and pointers in ``space_rebuild_recycle_mapper`` in ``space_recycle.c``. + + + Implementing your Task ---------------------- diff --git a/src/partition.c b/src/partition.c index 00b8d0c2c360f085e3a45ac2353db5bab03e79b0..2030451dadcf0ff686c0c9966ee8b5d362394059 100644 --- a/src/partition.c +++ b/src/partition.c @@ -1429,19 +1429,23 @@ void partition_gather_weights(void *map_data, int num_elements, int cid = ci - cells; /* Different weights for different tasks. */ - if (t->type == task_type_drift_part || t->type == task_type_drift_gpart || - t->type == task_type_drift_spart || t->type == task_type_drift_bpart || - t->type == task_type_ghost || t->type == task_type_extra_ghost || - t->type == task_type_stars_ghost || - t->type == task_type_bh_density_ghost || t->type == task_type_kick1 || + if (t->type == task_type_init_grav || t->type == task_type_ghost || + t->type == task_type_extra_ghost || t->type == task_type_drift_part || + t->type == task_type_drift_spart || t->type == task_type_drift_sink || + t->type == task_type_drift_bpart || t->type == task_type_drift_gpart || + t->type == task_type_end_hydro_force || t->type == task_type_kick1 || t->type == task_type_kick2 || t->type == task_type_timestep || t->type == task_type_timestep_limiter || - t->type == task_type_timestep_sync || t->type == task_type_kick1 || - t->type == task_type_kick2 || t->type == task_type_end_hydro_force || - t->type == task_type_end_grav_force || t->type == task_type_cooling || - t->type == task_type_star_formation || t->type == task_type_timestep || - t->type == task_type_init_grav || t->type == task_type_grav_down || - t->type == task_type_grav_long_range) { + t->type == task_type_timestep_sync || + t->type == task_type_grav_long_range || t->type == task_type_grav_mm || + t->type == task_type_grav_down || t->type == task_type_end_grav_force || + t->type == task_type_cooling || t->type == task_type_star_formation || + t->type == task_type_stars_ghost || + t->type == task_type_bh_density_ghost || + t->type == task_type_bh_swallow_ghost2 || + t->type == task_type_neutrino_weight || + t->type == task_type_sink_formation || t->type == task_type_rt_ghost1 || + t->type == task_type_rt_ghost2 || t->type == task_type_rt_tchem) { /* Particle updates add only to vertex weight. */ if (vweights) atomic_add_d(&weights_v[cid], w); @@ -2354,14 +2358,23 @@ static void check_weights(struct task *tasks, int nr_tasks, int cid = ci - cells; /* Different weights for different tasks. */ - if (t->type == task_type_drift_part || t->type == task_type_drift_gpart || - t->type == task_type_ghost || t->type == task_type_extra_ghost || - t->type == task_type_kick1 || t->type == task_type_kick2 || - t->type == task_type_end_hydro_force || - t->type == task_type_end_grav_force || t->type == task_type_cooling || - t->type == task_type_star_formation || t->type == task_type_timestep || - t->type == task_type_init_grav || t->type == task_type_grav_down || - t->type == task_type_grav_long_range) { + if (t->type == task_type_init_grav || t->type == task_type_ghost || + t->type == task_type_extra_ghost || t->type == task_type_drift_part || + t->type == task_type_drift_spart || t->type == task_type_drift_sink || + t->type == task_type_drift_bpart || t->type == task_type_drift_gpart || + t->type == task_type_end_hydro_force || t->type == task_type_kick1 || + t->type == task_type_kick2 || t->type == task_type_timestep || + t->type == task_type_timestep_limiter || + t->type == task_type_timestep_sync || + t->type == task_type_grav_long_range || t->type == task_type_grav_mm || + t->type == task_type_grav_down || t->type == task_type_end_grav_force || + t->type == task_type_cooling || t->type == task_type_star_formation || + t->type == task_type_stars_ghost || + t->type == task_type_bh_density_ghost || + t->type == task_type_bh_swallow_ghost2 || + t->type == task_type_neutrino_weight || + t->type == task_type_sink_formation || t->type == task_type_rt_ghost1 || + t->type == task_type_rt_ghost2 || t->type == task_type_rt_tchem) { /* Particle updates add only to vertex weight. */ if (vweights) weights_v[cid] += w;