diff --git a/src/cell.h b/src/cell.h index 97ca22e584c67de20ca0826425f60523b8158ffa..66dbdd37d1b9c324833435440a180df8f1e61162 100644 --- a/src/cell.h +++ b/src/cell.h @@ -504,6 +504,9 @@ struct cell { /*! Linked list of the tasks computing this cell's star density. */ struct link *density; + + // ALEXEI: DOES THIS NEED TO BE HERE? + struct link *feedback; /*! Number of #spart updated in this cell. */ int updated; diff --git a/src/engine_maketasks.c b/src/engine_maketasks.c index 68841aa5999441e6a2621f867038a44e9f52794c..4a6344d102a30b82ce9b10704bd1125cfa1e048c 100644 --- a/src/engine_maketasks.c +++ b/src/engine_maketasks.c @@ -1022,6 +1022,8 @@ void engine_count_and_link_tasks_mapper(void *map_data, int num_elements, engine_addlink(e, &ci->grav.grav, t); } else if (t->subtype == task_subtype_stars_density) { engine_addlink(e, &ci->stars.density, t); + } else if (t->subtype == task_subtype_stars_feedback) { + engine_addlink(e, &ci->stars.feedback, t); } /* Link pair tasks to cells. */ @@ -1038,6 +1040,9 @@ void engine_count_and_link_tasks_mapper(void *map_data, int num_elements, } else if (t->subtype == task_subtype_stars_density) { engine_addlink(e, &ci->stars.density, t); engine_addlink(e, &cj->stars.density, t); + } else if (t->subtype == task_subtype_stars_feedback) { + engine_addlink(e, &ci->stars.feedback, t); + engine_addlink(e, &cj->stars.feedback, t); } #ifdef SWIFT_DEBUG_CHECKS else if (t_subtype == task_subtype_external_grav) { @@ -1057,6 +1062,8 @@ void engine_count_and_link_tasks_mapper(void *map_data, int num_elements, engine_addlink(e, &ci->grav.grav, t); } else if (t->subtype == task_subtype_stars_density) { engine_addlink(e, &ci->stars.density, t); + } else if (t->subtype == task_subtype_stars_feedback) { + engine_addlink(e, &ci->stars.feedback, t); } /* Link sub-pair tasks to cells. */ @@ -1073,6 +1080,9 @@ void engine_count_and_link_tasks_mapper(void *map_data, int num_elements, } else if (t->subtype == task_subtype_stars_density) { engine_addlink(e, &ci->stars.density, t); engine_addlink(e, &cj->stars.density, t); + } else if (t->subtype == task_subtype_stars_feedback) { + engine_addlink(e, &ci->stars.feedback, t); + engine_addlink(e, &cj->stars.feedback, t); } #ifdef SWIFT_DEBUG_CHECKS else if (t_subtype == task_subtype_external_grav) { @@ -1601,9 +1611,16 @@ void engine_link_stars_tasks_mapper(void *map_data, int num_elements, /* Now, build all the dependencies for the stars */ engine_make_stars_loops_dependencies(sched, t, t->ci); - if (t->ci == t->ci->super) - scheduler_addunlock(sched, t->ci->super->stars.ghost_out, - t->ci->super->end_force); + } + if (t->type == task_type_self && t->subtype == task_subtype_stars_feedback) { + + /* Make the self-feedback tasks depend on the stars ghost task. */ + scheduler_addunlock(sched, t->ci->super->stars.ghost_out, t); + + /* Make end_force depend on feedback */ + if (t->ci == t->ci->super) { + scheduler_addunlock(sched, t, t->ci->super->end_force); + } } /* Otherwise, pair interaction? */ @@ -1640,6 +1657,16 @@ void engine_link_stars_tasks_mapper(void *map_data, int num_elements, } } + else if (t->type == task_type_pair && + t->subtype == task_subtype_stars_feedback) { + /* Make feedback task depend on ghost */ + scheduler_addunlock(sched, t->ci->super->stars.ghost_out, t); + + /* Make end_force depend on feedback */ + if (t->ci == t->ci->super) { + scheduler_addunlock(sched, t, t->ci->super->end_force); + } + } /* Otherwise, sub-self interaction? */ else if (t->type == task_type_sub_self && @@ -1658,6 +1685,22 @@ void engine_link_stars_tasks_mapper(void *map_data, int num_elements, } else error("oo"); } + else if (t->type == task_type_sub_self && + t->subtype == task_subtype_stars_feedback) { + + /* Make all feedback tasks depend on the drift and sorts. */ + //scheduler_addunlock(sched, t->ci->super->hydro.drift, t); + //scheduler_addunlock(sched, t->ci->super->hydro.sorts, t); + //scheduler_addunlock(sched, t->ci->super->grav.drift, t); + //scheduler_addunlock(sched, t->ci->super->stars.sorts, t); + + /* Now, build all the dependencies for the stars for the cells */ + /* that are local and are not descendant of the same super-cells */ + //if (t->ci->nodeID == nodeID) { + // engine_make_stars_loops_dependencies(sched, t, t->ci); + //} else + // error("oo"); + } /* Otherwise, sub-pair interaction? */ else if (t->type == task_type_sub_pair && @@ -1692,6 +1735,38 @@ void engine_link_stars_tasks_mapper(void *map_data, int num_elements, engine_make_stars_loops_dependencies(sched, t, t->cj); } } + else if (t->type == task_type_sub_pair && + t->subtype == task_subtype_stars_feedback) { + + /* Make all feedback tasks depend on the drift. */ + //if (t->cj->nodeID == engine_rank) + // scheduler_addunlock(sched, t->cj->super->hydro.drift, t); + //scheduler_addunlock(sched, t->cj->super->hydro.sorts, t); + + //if (t->cj->nodeID == engine_rank) + // scheduler_addunlock(sched, t->cj->super->grav.drift, t); + //scheduler_addunlock(sched, t->ci->super->stars.sorts, t); + + //if (t->ci->super != t->cj->super) { + // if (t->ci->nodeID == engine_rank) + // scheduler_addunlock(sched, t->ci->super->hydro.drift, t); + // scheduler_addunlock(sched, t->ci->super->hydro.sorts, t); + + // if (t->ci->nodeID == engine_rank) + // scheduler_addunlock(sched, t->ci->super->grav.drift, t); + // scheduler_addunlock(sched, t->cj->super->stars.sorts, t); + //} + + /* Now, build all the dependencies for the stars for the cells */ + /* that are local and are not descendant of the same super-cells */ + //if (t->ci->nodeID == nodeID) { + // engine_make_stars_loops_dependencies(sched, t, t->ci); + //} + //if (t->cj->nodeID == nodeID) { + // if (t->ci->super != t->cj->super) + // engine_make_stars_loops_dependencies(sched, t, t->cj); + //} + } } } @@ -1736,9 +1811,12 @@ void engine_make_starsloop_tasks_mapper(void *map_data, int num_elements, if (ci->stars.count == 0 && ci->hydro.count == 0) continue; /* If the cells is local build a self-interaction */ - if (ci->nodeID == nodeID) + if (ci->nodeID == nodeID) { scheduler_addtask(sched, task_type_self, task_subtype_stars_density, 0, 0, ci, NULL); + scheduler_addtask(sched, task_type_self, task_subtype_stars_feedback, 0, 0, + ci, NULL); + } /* Now loop over all the neighbours of this cell */ for (int ii = -1; ii < 2; ii++) { @@ -1767,6 +1845,8 @@ void engine_make_starsloop_tasks_mapper(void *map_data, int num_elements, const int sid = sortlistID[(kk + 1) + 3 * ((jj + 1) + 3 * (ii + 1))]; scheduler_addtask(sched, task_type_pair, task_subtype_stars_density, sid, 0, ci, cj); + scheduler_addtask(sched, task_type_pair, task_subtype_stars_feedback, + sid, 0, ci, cj); } } } diff --git a/src/runner.c b/src/runner.c index f14f8d8bc2721d0edfaca542b68af645bd5ac1a0..6f88d417f1931957e5299f1904098432fb6579ae 100644 --- a/src/runner.c +++ b/src/runner.c @@ -2765,6 +2765,8 @@ void *runner_main(void *data) { runner_do_grav_external(r, ci, 1); else if (t->subtype == task_subtype_stars_density) runner_doself_stars_density(r, ci, 1); + else if (t->subtype == task_subtype_stars_feedback) + runner_doself_stars_feedback(r, ci, 1); else error("Unknown/invalid task subtype (%d).", t->subtype); break; @@ -2782,6 +2784,8 @@ void *runner_main(void *data) { runner_dopair_recursive_grav(r, ci, cj, 1); else if (t->subtype == task_subtype_stars_density) runner_dopair_stars_density(r, ci, cj, 1); + else if (t->subtype == task_subtype_stars_feedback) + runner_dopair_stars_feedback(r, ci, cj, 1); else error("Unknown/invalid task subtype (%d).", t->subtype); break; @@ -2797,6 +2801,8 @@ void *runner_main(void *data) { runner_dosub_self2_force(r, ci, 1); else if (t->subtype == task_subtype_stars_density) runner_dosub_self_stars_density(r, ci, 1); + else if (t->subtype == task_subtype_stars_feedback) + runner_dosub_self_stars_feedback(r, ci, 1); else error("Unknown/invalid task subtype (%d).", t->subtype); break; @@ -2812,6 +2818,8 @@ void *runner_main(void *data) { runner_dosub_pair2_force(r, ci, cj, t->flags, 1); else if (t->subtype == task_subtype_stars_density) runner_dosub_pair_stars_density(r, ci, cj, t->flags, 1); + else if (t->subtype == task_subtype_stars_feedback) + runner_dosub_pair_stars_feedback(r, ci, cj, t->flags, 1); else error("Unknown/invalid task subtype (%d).", t->subtype); break; diff --git a/src/stars/Default/stars_iact.h b/src/stars/Default/stars_iact.h index 9e27f86028245a230cfd777dfc46da7b7d2f3915..c7a6a466d550be35ae6b7f3d697db702bde7bf3c 100644 --- a/src/stars/Default/stars_iact.h +++ b/src/stars/Default/stars_iact.h @@ -37,6 +37,7 @@ runner_iact_nonsym_stars_density(float r2, const float *dx, float hi, float hj, si->ids_ngbs_density[si->num_ngb_density] = pj->id; ++si->num_ngb_density; #endif + message("here"); } /** @@ -54,4 +55,6 @@ runner_iact_nonsym_stars_density(float r2, const float *dx, float hi, float hj, __attribute__((always_inline)) INLINE static void runner_iact_nonsym_stars_feedback(float r2, const float *dx, float hi, float hj, struct spart *restrict si, - struct part *restrict pj, float a, float H) {} + struct part *restrict pj, float a, float H) { + message("here"); +} diff --git a/src/task.c b/src/task.c index 3918dad3b713c6c226e5dacf3e38756910c1dd27..e87b297ece03fd23cee7d24bd37cc77bda9ce52f 100644 --- a/src/task.c +++ b/src/task.c @@ -86,7 +86,7 @@ const char *taskID_names[task_type_count] = {"none", const char *subtaskID_names[task_subtype_count] = { "none", "density", "gradient", "force", "grav", "external_grav", "tend", "xv", "rho", "gpart", - "multipole", "spart", "stars_density"}; + "multipole", "spart", "stars_density", "stars_feedback" }; #ifdef WITH_MPI /* MPI communicators for the subtypes. */ diff --git a/src/task.h b/src/task.h index 994b2b14c05965b71e877feac5cb9827a1d1b4bb..d9ee70d5e5ae6fa07496111077e64f1237ac97a6 100644 --- a/src/task.h +++ b/src/task.h @@ -93,6 +93,7 @@ enum task_subtypes { task_subtype_multipole, task_subtype_spart, task_subtype_stars_density, + task_subtype_stars_feedback, task_subtype_count } __attribute__((packed));