diff --git a/configure.ac b/configure.ac index 2fa871e22f08065527904eaa5838ac3afe725220..13e1fa9842611a34146aeb7f2b39fef4f7e63c31 100644 --- a/configure.ac +++ b/configure.ac @@ -1376,6 +1376,7 @@ with_subgrid_pressure_floor=none with_subgrid_stars=none with_subgrid_star_formation=none with_subgrid_feedback=none +with_subgrid_task_order=none case "$with_subgrid" in yes) @@ -1391,6 +1392,7 @@ case "$with_subgrid" in with_subgrid_star_formation=GEAR with_subgrid_feedback=none with_subgrid_black_holes=none + with_subgrid_task_order=GEAR enable_fof=no ;; EAGLE) @@ -1402,6 +1404,7 @@ case "$with_subgrid" in with_subgrid_star_formation=EAGLE with_subgrid_feedback=EAGLE with_subgrid_black_holes=EAGLE + with_subgrid_task_order=EAGLE enable_fof=yes ;; *) @@ -1882,6 +1885,38 @@ case "$with_black_holes" in ;; esac +# Task order +AC_ARG_WITH([task-order], +[AS_HELP_STRING([--with-task-order=<model>], +[Task order to use @<:@none, EAGLE, GEAR default: none@:>@] +)], +[with_task_order="$withval"], +[with_task_order="none"] +) + +if test "$with_subgrid" != "none"; then +if test "$with_task_order" != "none"; then +AC_MSG_ERROR([Cannot provide with-subgrid and with-task-order together]) +else +with_task_order="$with_subgrid_task_order" +fi +fi + +case "$with_task_order" in +EAGLE) +AC_DEFINE([TASK_ORDER_EAGLE], [1], [EAGLE task order]) +;; +none) +AC_DEFINE([TASK_ORDER_NONE], [1], [Default task order]) +;; +GEAR) +AC_DEFINE([TASK_ORDER_GEAR], [1], [GEAR task order]) +;; +*) +AC_MSG_ERROR([Unknown feedback model: $with_feedback]) +;; +esac + # External potential AC_ARG_WITH([ext-potential], [AS_HELP_STRING([--with-ext-potential=<pot>], @@ -2117,6 +2152,7 @@ AC_MSG_RESULT([ Star formation model : $with_star_formation Star feedback model : $with_feedback Black holes model : $with_black_holes + Task order : $with_task_order Individual timers : $enable_timers Task debugging : $enable_task_debugging diff --git a/src/Makefile.am b/src/Makefile.am index c2a3a7755a188de6c907afe99e5ae1c4dfc5f3a8..0223a5b65cd29266467cb1a83738c3bab7e8fb4f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -55,7 +55,7 @@ include_HEADERS = space.h runner.h queue.h task.h lock.h cell.h part.h const.h \ pressure_floor.h pressure_floor_struct.h pressure_floor_iact.h \ velociraptor_struct.h velociraptor_io.h random.h memuse.h mpiuse.h memuse_rnodes.h \ black_holes.h black_holes_io.h black_holes_properties.h black_holes_struct.h \ - feedback.h feedback_struct.h feedback_properties.h + feedback.h feedback_struct.h feedback_properties.h task_order.h # source files for EAGLE cooling EAGLE_COOLING_SOURCES = @@ -236,7 +236,8 @@ nobase_noinst_HEADERS = align.h approx_math.h atomic.h barrier.h cycle.h error.h black_holes/EAGLE/black_holes_struct.h \ pressure_floor/GEAR/pressure_floor.h pressure_floor/none/pressure_floor.h \ pressure_floor/GEAR/pressure_floor_iact.h pressure_floor/none/pressure_floor_iact.h \ - pressure_floor/GEAR/pressure_floor_struct.h pressure_floor/none/pressure_floor_struct.h + pressure_floor/GEAR/pressure_floor_struct.h pressure_floor/none/pressure_floor_struct.h \ + task_order/GEAR/task_order.h task_order/EAGLE/task_order.h task_order/none/task_order.h # Sources and flags for regular library diff --git a/src/cell.c b/src/cell.c index 9c88cc0fc625928385cbe274b8a6a2b05f503e83..6dee61ecc95be3f4bb17946379640847e00ece11 100644 --- a/src/cell.c +++ b/src/cell.c @@ -67,6 +67,7 @@ #include "space_getsid.h" #include "star_formation.h" #include "stars.h" +#include "task_order.h" #include "timers.h" #include "tools.h" #include "tracers.h" @@ -2476,7 +2477,9 @@ void cell_activate_star_formation_tasks(struct cell *c, struct scheduler *s) { scheduler_activate(s, c->hydro.star_formation); /* Activate the star resort tasks at whatever level they are */ - cell_activate_star_resort_tasks(c, s); + if (task_order_need_resort_stars) { + cell_activate_star_resort_tasks(c, s); + } } /** diff --git a/src/engine_maketasks.c b/src/engine_maketasks.c index 42590cb5f41539d11ca39639c369ea68472e9826..a210746489fbaebd282e9b405ce7dc217c3b65e7 100644 --- a/src/engine_maketasks.c +++ b/src/engine_maketasks.c @@ -50,6 +50,7 @@ #include "debug.h" #include "error.h" #include "proxy.h" +#include "task_order.h" #include "timers.h" extern int engine_max_parts_per_ghost; @@ -1022,7 +1023,8 @@ void engine_make_hierarchical_tasks_hydro(struct engine *e, struct 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) && + if (task_order_need_resort_stars && + (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) { @@ -1131,8 +1133,7 @@ void engine_make_hierarchical_tasks_hydro(struct engine *e, struct cell *c, scheduler_addunlock(s, c->stars.stars_out, c->super->timestep); if (with_star_formation && c->hydro.count > 0) { - scheduler_addunlock(s, star_resort_cell->hydro.stars_resort, - c->stars.stars_in); + task_order_addunlock_star_formation_feedback(s, c, star_resort_cell); } } diff --git a/src/runner_sort.c b/src/runner_sort.c index 914b64f93b970000885b1b578d762d3f15455332..22c541926f624dbccdc30b0362be62d1638659b8 100644 --- a/src/runner_sort.c +++ b/src/runner_sort.c @@ -45,6 +45,7 @@ void runner_do_stars_resort(struct runner *r, struct cell *c, const int timer) { #ifdef SWIFT_DEBUG_CHECKS if (c->nodeID != r->e->nodeID) error("Task must be run locally!"); + if (!task_order_need_resort_stars) error("Resorting when not needed"); #endif TIMER_TIC; diff --git a/src/swift.h b/src/swift.h index d8221080b1179b8bddc5441cdd4ae19a3fca5b74..0b8ac214f1a3a5184673991271f5d24bff850b23 100644 --- a/src/swift.h +++ b/src/swift.h @@ -83,6 +83,7 @@ #include "stars.h" #include "stars_io.h" #include "task.h" +#include "task_order.h" #include "threadpool.h" #include "timeline.h" #include "timers.h" diff --git a/src/task_order.h b/src/task_order.h new file mode 100644 index 0000000000000000000000000000000000000000..e1752b79d4869f0e63103ced6adca162de390457 --- /dev/null +++ b/src/task_order.h @@ -0,0 +1,31 @@ +/******************************************************************************* + * This file is part of SWIFT. + * Copyright (c) 2019 Loic Hausammann (loic.hausammann@epfl.ch) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + ******************************************************************************/ + +#ifndef SWIFT_TASK_ORDER_H +#define SWIFT_TASK_ORDER_H + +#include "../config.h" + +#ifdef TASK_ORDER_NONE +#include "task_order/none/task_order.h" +#else +#error undefined task order +#endif + +#endif // SWIFT_TASK_ORDER_H diff --git a/src/task_order/EAGLE/task_order.h b/src/task_order/EAGLE/task_order.h new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/task_order/GEAR/task_order.h b/src/task_order/GEAR/task_order.h new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/task_order/none/task_order.h b/src/task_order/none/task_order.h new file mode 100644 index 0000000000000000000000000000000000000000..97f6d1140c8347b56be0500daa83914c6d70a333 --- /dev/null +++ b/src/task_order/none/task_order.h @@ -0,0 +1,36 @@ +/******************************************************************************* + * This file is part of SWIFT. + * Copyright (c) 2019 Loic Hausammann (loic.hausammann@epfl.ch) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + ******************************************************************************/ + +#ifndef SWIFT_TASK_ORDER_NONE_H +#define SWIFT_TASK_ORDER_NONE_H + +#include "cell.h" + +#define task_order_need_resort_stars 1 + + +__attribute__((always_inline)) INLINE static void task_order_addunlock_star_formation_feedback( + struct scheduler *s, struct cell *c, struct cell *star_resort_cell) { + + scheduler_addunlock(s, star_resort_cell->hydro.stars_resort, + c->stars.stars_in); + +} + +#endif // SWIFT_TASK_ORDER_NONE_H