From 3742104d18f1349df03848f0260339e051726e37 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <schaller@strw.leidenuniv.nl> Date: Wed, 25 Mar 2020 14:26:40 +0100 Subject: [PATCH] Make the time-step limiter tasks lock-free --- src/task.c | 10 ++++++++-- src/timestep_limiter_iact.h | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/task.c b/src/task.c index 964c77feaf..4403f10296 100644 --- a/src/task.c +++ b/src/task.c @@ -468,7 +468,8 @@ void task_unlock(struct task *t) { cell_unlocktree(ci); } else if (subtype == task_subtype_do_bh_swallow) { cell_bunlocktree(ci); - } else { + } else if (subtype == task_subtype_limiter) { + } else { /* hydro */ cell_unlocktree(ci); } break; @@ -493,7 +494,8 @@ void task_unlock(struct task *t) { } else if (subtype == task_subtype_do_bh_swallow) { cell_bunlocktree(ci); cell_bunlocktree(cj); - } else { + } else if (subtype == task_subtype_limiter) { + } else { /* hydro */ cell_unlocktree(ci); cell_unlocktree(cj); } @@ -625,6 +627,8 @@ int task_lock(struct task *t) { } else if (subtype == task_subtype_do_bh_swallow) { if (ci->black_holes.hold) return 0; if (cell_blocktree(ci) != 0) return 0; + } else if (subtype == task_subtype_limiter) { + return 1; } else { /* subtype == hydro */ if (ci->hydro.hold) return 0; if (cell_locktree(ci) != 0) return 0; @@ -686,6 +690,8 @@ int task_lock(struct task *t) { cell_bunlocktree(ci); return 0; } + } else if (subtype == task_subtype_limiter) { + return 1; } else { /* subtype == hydro */ /* Lock the parts in both cells */ if (ci->hydro.hold || cj->hydro.hold) return 0; diff --git a/src/timestep_limiter_iact.h b/src/timestep_limiter_iact.h index a4f5c7c1af..8c8fa7cee6 100644 --- a/src/timestep_limiter_iact.h +++ b/src/timestep_limiter_iact.h @@ -88,7 +88,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_limiter( if (pj->time_bin > pi->time_bin + time_bin_neighbour_max_delta_bin) { /* Store the smallest time bin that woke up this particle */ - pj->limiter_data.wakeup = max(pj->limiter_data.wakeup, -pi->time_bin); + atomic_max_c(&pj->limiter_data.wakeup, -pi->time_bin); } } -- GitLab