From 7ce8acedaaa6e1449a88b9e88787ca7d92d1bf62 Mon Sep 17 00:00:00 2001 From: loikki <loic.hausammann@protonmail.ch> Date: Sun, 20 Oct 2019 19:12:08 +0200 Subject: [PATCH] Task order: implement structure --- configure.ac | 36 +++++++++++++++++++++++++++++++ src/Makefile.am | 5 +++-- src/cell.c | 5 ++++- src/engine_maketasks.c | 7 +++--- src/runner_sort.c | 1 + src/swift.h | 1 + src/task_order.h | 31 ++++++++++++++++++++++++++ src/task_order/EAGLE/task_order.h | 0 src/task_order/GEAR/task_order.h | 0 src/task_order/none/task_order.h | 36 +++++++++++++++++++++++++++++++ 10 files changed, 116 insertions(+), 6 deletions(-) create mode 100644 src/task_order.h create mode 100644 src/task_order/EAGLE/task_order.h create mode 100644 src/task_order/GEAR/task_order.h create mode 100644 src/task_order/none/task_order.h diff --git a/configure.ac b/configure.ac index 2fa871e22f..13e1fa9842 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 c2a3a7755a..0223a5b65c 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 9c88cc0fc6..6dee61ecc9 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 42590cb5f4..a210746489 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 914b64f93b..22c541926f 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 d8221080b1..0b8ac214f1 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 0000000000..e1752b79d4 --- /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 0000000000..e69de29bb2 diff --git a/src/task_order/GEAR/task_order.h b/src/task_order/GEAR/task_order.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/task_order/none/task_order.h b/src/task_order/none/task_order.h new file mode 100644 index 0000000000..97f6d1140c --- /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 -- GitLab