From 743bb7276796145a60382daf6708d2fcee77a679 Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <schaller@strw.leidenuniv.nl>
Date: Tue, 19 May 2020 14:10:15 +0200
Subject: [PATCH] No need to lock the tree for the grav-mesh task

---
 src/task.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/task.c b/src/task.c
index f821eed5e6..9440bf8887 100644
--- a/src/task.c
+++ b/src/task.c
@@ -443,7 +443,6 @@ void task_unlock(struct task *t) {
       break;
 
     case task_type_drift_gpart:
-    case task_type_grav_mesh:
     case task_type_end_grav_force:
       cell_gunlocktree(ci);
       break;
@@ -538,6 +537,12 @@ void task_unlock(struct task *t) {
 #endif
       break;
 
+    case task_type_grav_mesh:
+#ifdef SWIFT_TASKS_WITHOUT_ATOMICS
+      cell_gunlocktree(ci);
+#endif
+      break;
+
     case task_type_star_formation:
       cell_unlocktree(ci);
       cell_sunlocktree(ci);
@@ -623,7 +628,6 @@ int task_lock(struct task *t) {
 
     case task_type_drift_gpart:
     case task_type_end_grav_force:
-    case task_type_grav_mesh:
       if (ci->grav.phold) return 0;
       if (cell_glocktree(ci) != 0) return 0;
       break;
@@ -800,6 +804,14 @@ int task_lock(struct task *t) {
 #endif
       break;
 
+    case task_type_grav_mesh:
+#ifdef SWIFT_TASKS_WITHOUT_ATOMICS
+      /* Lock the gparts */
+      if (ci->grav.phold) return 0;
+      if (cell_glocktree(ci) != 0) return 0;
+#endif
+      break;
+
     case task_type_star_formation:
       /* Lock the gas, gravity and star particles */
       if (ci->hydro.hold || ci->stars.hold || ci->grav.phold) return 0;
-- 
GitLab