diff --git a/src/engine.c b/src/engine.c index b7819716a6afc5f070515e0d0a7caf0121862a6c..b3eed4f4717ae012234ff0a2eda0d8864aeef402 100644 --- a/src/engine.c +++ b/src/engine.c @@ -1631,6 +1631,9 @@ int engine_estimate_nr_tasks(const struct engine *e) { n1 += 1; } #endif + if (e->policy & engine_policy_rt) { + n1 += 14; + } #ifdef WITH_MPI diff --git a/src/engine_maketasks.c b/src/engine_maketasks.c index 4220268b88e9bd95404584a2510b538c447d4aa3..18feabc931eab1e7a82150c875470342a832708e 100644 --- a/src/engine_maketasks.c +++ b/src/engine_maketasks.c @@ -3548,4 +3548,7 @@ void engine_maketasks(struct engine *e) { if (e->verbose) message("took %.3f %s (including reweight).", clocks_from_ticks(getticks() - tic), clocks_getunit()); + + scheduler_write_dependencies(sched, 1); + } diff --git a/src/engine_marktasks.c b/src/engine_marktasks.c index e1ea518599967e46555e5f03818da521a686e81e..127c030b089c4bf50be6e97140d6ed70e3fba7c5 100644 --- a/src/engine_marktasks.c +++ b/src/engine_marktasks.c @@ -261,6 +261,13 @@ void engine_marktasks_mapper(void *map_data, int num_elements, } } + /* Activate RT injection */ + else if (t_subtype == task_subtype_rt_inject) { + if (ci_active_hydro) { + scheduler_activate(s, t); + } + } + #ifdef SWIFT_DEBUG_CHECKS else { error("Invalid task type / sub-type encountered"); @@ -463,6 +470,7 @@ void engine_marktasks_mapper(void *map_data, int num_elements, cell_activate_subcell_grav_tasks(t->ci, t->cj, s); } + #ifdef SWIFT_DEBUG_CHECKS else if (t_type == task_type_sub_pair && t_subtype == task_subtype_grav) { @@ -471,6 +479,24 @@ void engine_marktasks_mapper(void *map_data, int num_elements, #endif } + /* RT injection tasks */ + else if (t_subtype == task_subtype_rt_inject) { + /* We only want to activate the task if the cell is active and is + going to update some gas on the *local* node */ + if ((ci_nodeID == nodeID && cj_nodeID == nodeID) && + (ci_active_hydro || cj_active_hydro)) { + scheduler_activate(s, t); + + } else if ((ci_nodeID == nodeID && cj_nodeID != nodeID) && + (cj_active_hydro)) { + scheduler_activate(s, t); + + } else if ((ci_nodeID != nodeID && cj_nodeID == nodeID) && + (ci_active_hydro)) { + scheduler_activate(s, t); + } + } + /* Only interested in density tasks as of here. */ if (t_subtype == task_subtype_density) { @@ -858,6 +884,11 @@ void engine_marktasks_mapper(void *map_data, int num_elements, scheduler_activate_send(s, ci->mpi.send, task_subtype_tend_gpart, cj_nodeID); } +#endif + } /* Only interested in RT tasks as of here. */ + else if (t_subtype == task_subtype_rt_inject) { +#ifdef WITH_MPI + error("RT doesn't work with MPI yet."); #endif } } diff --git a/src/runner_doiact_functions_rt.h b/src/runner_doiact_functions_rt.h index 2c87da8308032e4cd6557e44368c3b4a93b317d2..5e9031dc0324be0ffd69bb361482fa3d7d3ef193 100644 --- a/src/runner_doiact_functions_rt.h +++ b/src/runner_doiact_functions_rt.h @@ -1,36 +1,101 @@ -/* TODO: dox, license, etc */ -#include "runner_doiact_rt.h" - +/******************************************************************************* + * This file is part of SWIFT. + * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk) + * 2016 Matthieu Schaller (matthieu.schaller@durham.ac.uk) + * 2020 Mladen Ivkovic (mladen.ivkovic@hotmail.com) + * + * 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/>. + * + ******************************************************************************/ -/* TODO: TEMPORARY */ -#include <stdio.h> +/* Before including this file, define FUNCTION, which is the + name of the interaction function. This creates the interaction functions + runner_dopair_FUNCTION, runner_dopair_FUNCTION_naive, runner_doself_FUNCTION, + and runner_dosub_FUNCTION calling the pairwise interaction function + runner_iact_FUNCTION. */ +#include "runner_doiact_rt.h" +/** + * @brief TODO + * + * @param r runner task + * @param c cell + * @param timer 1 if the time is to be recorded. + */ void DOSELF1_RT(struct runner *r, struct cell *c, int timer){ TIMER_TIC; - printf("called DOSELF1_RT for cell %p\n", c); + message("message from DOSELF1_RT"); if (timer) TIMER_TOC(TIMER_DOSELF_RT); } -void DOPAIR1_RT(struct runner *r, struct cell *ci, struct cell *cj, int timer){ +/** + * @brief TODO + * + * @param r runner task + * @param c cell + * @param timer 1 if the time is to be recorded. + */ +void DOPAIR1_SYM_RT(struct runner *r, struct cell *ci, struct cell *cj, int timer){ TIMER_TIC; - printf("called DOPAIR1_RT for cells %p, %p\n", ci, cj); + message("message from DOPAIR1_RT"); if (timer) TIMER_TOC(TIMER_DOPAIR_RT); } +/** + * @brief Determine which version of DOSELF1_RT needs to be called depending + * on the optimisation level. + * + * @param r #runner + * @param c #cell c + * @param timer 1 if the time is to be recorded. + */ void DOSELF1_BRANCH_RT(struct runner *r, struct cell *c, int timer) { DOSELF1_RT(r, c, timer); } +/** + * @brief Determine which version of DOPAIR1_RT needs to be called depending + * on the optimisation level. + * + * @param r #runner + * @param c #cell c + * @param timer 1 if the time is to be recorded. + */ void DOPAIR1_BRANCH_RT(struct runner *r, struct cell *ci, struct cell *cj, int timer) { - DOPAIR1_RT(r, ci, cj, timer); + DOPAIR1_SYM_RT(r, ci, cj, timer); } +/** + * @brief Compute grouped sub-cell interactions for self tasks + * + * @param r The #runner. + * @param ci The first #cell. + * @param gettimer Do we have a timer ? + */ void DOSUB_SELF1_RT(struct runner *r, struct cell *c, int timer) { DOSELF1_RT(r, c, timer); } +/** + * @brief Compute grouped sub-cell interactions for pair tasks + * + * @param r The #runner. + * @param ci The first #cell. + * @param gettimer Do we have a timer ? + */ void DOSUB_PAIR1_RT(struct runner *r, struct cell *ci, struct cell *cj, int timer) { - DOPAIR1_RT(r, ci, cj, timer); + DOPAIR1_SYM_RT(r, ci, cj, timer); } diff --git a/src/runner_doiact_rt.h b/src/runner_doiact_rt.h index b4206f00b0c936b3ae32acb0b3beec9c60daea0c..434990fddce9c2149be5eca80c69c09c7830f61e 100644 --- a/src/runner_doiact_rt.h +++ b/src/runner_doiact_rt.h @@ -1,6 +1,7 @@ /******************************************************************************* * This file is part of SWIFT. * Copyright (c) 2016 Matthieu Schaller (matthieu.schaller@durham.ac.uk) + * 2018 Loic Hausammann (loic.hausammann@epfl.ch) * 2020 Mladen Ivkovic (mladen.ivkovic@hotmail.com) * * This program is free software: you can redistribute it and/or modify @@ -28,15 +29,20 @@ #define _DOSELF1_RT(f) PASTE(runner_doself_rt, f) #define DOSELF1_RT _DOSELF1_RT(FUNCTION) -#define _DO_SYM_PAIR1_RT(f) PASTE(runner_do_sym_pair_rt, f) -#define DO_SYM_PAIR1_RT _DO_SYM_PAIR1_RT(FUNCTION) +#define _DOPAIR1_SYM_RT(f) PASTE(runner_dopair_rt, f) +#define DOPAIR1_SYM_RT _DOPAIR1_SYM_RT(FUNCTION) -#define _DO_NONSYM_PAIR1_RT_NAIVE(f) \ - PASTE(runner_do_nonsym_pair_rt_naive, f) -#define DO_NONSYM_PAIR1_RT_NAIVE _DO_NONSYM_PAIR1_RT_NAIVE(FUNCTION) +#define _DOPAIR1_NONSYM_RT(f) PASTE(runner_dopair_nonsym_rt, f) +#define DOPAIR1_NONSYM_RT _DOPAIR1_NONSYM_RT(FUNCTION) -#define _DOPAIR1_RT_NAIVE(f) PASTE(runner_dopair_rt_naive, f) -#define DOPAIR1_RT_NAIVE _DOPAIR1_RT_NAIVE(FUNCTION) +#define _DOPAIR1_SYM_NAIVE_RT(f) PASTE(runner_dopair_naive_rt, f) +#define DOPAIR1_SYM_NAIVE_RT _DOPAIR1_SYM_NAIVE_RT(FUNCTION) + +#define _DOPAIR1_NONSYM_NAIVE_RT(f) PASTE(runner_dopair_nonsym_naive_rt, f) +#define DOPAIR1_NONSYM_NAIVE_RT _DOPAIR1_NONSYM_NAIVE_RT(FUNCTION) + +#define _DOPAIR1_RT(f) PASTE(runner_dopair_rt, f) +#define DOPAIR1_RT_DOPAIR1_RT(FUNCTION) #define _DOSELF1_BRANCH_RT(f) PASTE(runner_doself_branch_rt, f) #define DOSELF1_BRANCH_RT _DOSELF1_BRANCH_RT(FUNCTION)