Commit c83f6d0c authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Lock the gravity and limiter tasks when SWIFT_TASKS_WITHOUT_ATOMICS is defined

parent a984ae3f
...@@ -456,6 +456,10 @@ void task_unlock(struct task *t) { ...@@ -456,6 +456,10 @@ void task_unlock(struct task *t) {
case task_type_self: case task_type_self:
case task_type_sub_self: case task_type_sub_self:
if (subtype == task_subtype_grav) { if (subtype == task_subtype_grav) {
#ifdef SWIFT_TASKS_WITHOUT_ATOMICS
cell_gunlocktree(ci);
cell_munlocktree(ci);
#endif
} else if ((subtype == task_subtype_stars_density) || } else if ((subtype == task_subtype_stars_density) ||
(subtype == task_subtype_stars_feedback)) { (subtype == task_subtype_stars_feedback)) {
cell_sunlocktree(ci); cell_sunlocktree(ci);
...@@ -469,6 +473,9 @@ void task_unlock(struct task *t) { ...@@ -469,6 +473,9 @@ void task_unlock(struct task *t) {
} else if (subtype == task_subtype_do_bh_swallow) { } else if (subtype == task_subtype_do_bh_swallow) {
cell_bunlocktree(ci); cell_bunlocktree(ci);
} else if (subtype == task_subtype_limiter) { } else if (subtype == task_subtype_limiter) {
#ifdef SWIFT_TASKS_WITHOUT_ATOMICS
cell_unlocktree(ci);
#endif
} else { /* hydro */ } else { /* hydro */
cell_unlocktree(ci); cell_unlocktree(ci);
} }
...@@ -477,6 +484,12 @@ void task_unlock(struct task *t) { ...@@ -477,6 +484,12 @@ void task_unlock(struct task *t) {
case task_type_pair: case task_type_pair:
case task_type_sub_pair: case task_type_sub_pair:
if (subtype == task_subtype_grav) { if (subtype == task_subtype_grav) {
#ifdef SWIFT_TASKS_WITHOUT_ATOMICS
cell_gunlocktree(ci);
cell_gunlocktree(cj);
cell_munlocktree(ci);
cell_munlocktree(cj);
#endif
} else if ((subtype == task_subtype_stars_density) || } else if ((subtype == task_subtype_stars_density) ||
(subtype == task_subtype_stars_feedback)) { (subtype == task_subtype_stars_feedback)) {
cell_sunlocktree(ci); cell_sunlocktree(ci);
...@@ -495,6 +508,10 @@ void task_unlock(struct task *t) { ...@@ -495,6 +508,10 @@ void task_unlock(struct task *t) {
cell_bunlocktree(ci); cell_bunlocktree(ci);
cell_bunlocktree(cj); cell_bunlocktree(cj);
} else if (subtype == task_subtype_limiter) { } else if (subtype == task_subtype_limiter) {
#ifdef SWIFT_TASKS_WITHOUT_ATOMICS
cell_unlocktree(ci);
cell_unlocktree(cj);
#endif
} else { /* hydro */ } else { /* hydro */
cell_unlocktree(ci); cell_unlocktree(ci);
cell_unlocktree(cj); cell_unlocktree(cj);
...@@ -502,12 +519,23 @@ void task_unlock(struct task *t) { ...@@ -502,12 +519,23 @@ void task_unlock(struct task *t) {
break; break;
case task_type_grav_down: case task_type_grav_down:
#ifdef SWIFT_TASKS_WITHOUT_ATOMICS
cell_gunlocktree(ci);
cell_munlocktree(ci);
#endif
break; break;
case task_type_grav_long_range: case task_type_grav_long_range:
#ifdef SWIFT_TASKS_WITHOUT_ATOMICS
cell_munlocktree(ci);
#endif
break; break;
case task_type_grav_mm: case task_type_grav_mm:
#ifdef SWIFT_TASKS_WITHOUT_ATOMICS
cell_munlocktree(ci);
cell_munlocktree(cj);
#endif
break; break;
case task_type_star_formation: case task_type_star_formation:
...@@ -603,7 +631,16 @@ int task_lock(struct task *t) { ...@@ -603,7 +631,16 @@ int task_lock(struct task *t) {
case task_type_self: case task_type_self:
case task_type_sub_self: case task_type_sub_self:
if (subtype == task_subtype_grav) { if (subtype == task_subtype_grav) {
return 1; #ifdef SWIFT_TASKS_WITHOUT_ATOMICS
/* Lock the gparts and the m-pole */
if (ci->grav.phold || ci->grav.mhold) return 0;
if (cell_glocktree(ci) != 0)
return 0;
else if (cell_mlocktree(ci) != 0) {
cell_gunlocktree(ci);
return 0;
}
#endif
} else if ((subtype == task_subtype_stars_density) || } else if ((subtype == task_subtype_stars_density) ||
(subtype == task_subtype_stars_feedback)) { (subtype == task_subtype_stars_feedback)) {
if (ci->stars.hold) return 0; if (ci->stars.hold) return 0;
...@@ -628,7 +665,10 @@ int task_lock(struct task *t) { ...@@ -628,7 +665,10 @@ int task_lock(struct task *t) {
if (ci->black_holes.hold) return 0; if (ci->black_holes.hold) return 0;
if (cell_blocktree(ci) != 0) return 0; if (cell_blocktree(ci) != 0) return 0;
} else if (subtype == task_subtype_limiter) { } else if (subtype == task_subtype_limiter) {
return 1; #ifdef SWIFT_TASKS_WITHOUT_ATOMICS
if (ci->hydro.hold) return 0;
if (cell_locktree(ci) != 0) return 0;
#endif
} else { /* subtype == hydro */ } else { /* subtype == hydro */
if (ci->hydro.hold) return 0; if (ci->hydro.hold) return 0;
if (cell_locktree(ci) != 0) return 0; if (cell_locktree(ci) != 0) return 0;
...@@ -638,7 +678,24 @@ int task_lock(struct task *t) { ...@@ -638,7 +678,24 @@ int task_lock(struct task *t) {
case task_type_pair: case task_type_pair:
case task_type_sub_pair: case task_type_sub_pair:
if (subtype == task_subtype_grav) { if (subtype == task_subtype_grav) {
return 1; #ifdef SWIFT_TASKS_WITHOUT_ATOMICS
/* Lock the gparts and the m-pole in both cells */
if (ci->grav.phold || cj->grav.phold) return 0;
if (cell_glocktree(ci) != 0) return 0;
if (cell_glocktree(cj) != 0) {
cell_gunlocktree(ci);
return 0;
} else if (cell_mlocktree(ci) != 0) {
cell_gunlocktree(ci);
cell_gunlocktree(cj);
return 0;
} else if (cell_mlocktree(cj) != 0) {
cell_gunlocktree(ci);
cell_gunlocktree(cj);
cell_munlocktree(ci);
return 0;
}
#endif
} else if ((subtype == task_subtype_stars_density) || } else if ((subtype == task_subtype_stars_density) ||
(subtype == task_subtype_stars_feedback)) { (subtype == task_subtype_stars_feedback)) {
/* Lock the stars and the gas particles in both cells */ /* Lock the stars and the gas particles in both cells */
...@@ -691,7 +748,14 @@ int task_lock(struct task *t) { ...@@ -691,7 +748,14 @@ int task_lock(struct task *t) {
return 0; return 0;
} }
} else if (subtype == task_subtype_limiter) { } else if (subtype == task_subtype_limiter) {
return 1; #ifdef SWIFT_TASKS_WITHOUT_ATOMICS
if (ci->hydro.hold || cj->hydro.hold) return 0;
if (cell_locktree(ci) != 0) return 0;
if (cell_locktree(cj) != 0) {
cell_unlocktree(ci);
return 0;
}
#endif
} else { /* subtype == hydro */ } else { /* subtype == hydro */
/* Lock the parts in both cells */ /* Lock the parts in both cells */
if (ci->hydro.hold || cj->hydro.hold) return 0; if (ci->hydro.hold || cj->hydro.hold) return 0;
...@@ -704,15 +768,36 @@ int task_lock(struct task *t) { ...@@ -704,15 +768,36 @@ int task_lock(struct task *t) {
break; break;
case task_type_grav_down: case task_type_grav_down:
return 1; #ifdef SWIFT_TASKS_WITHOUT_ATOMICS
/* Lock the gparts and the m-poles */
if (ci->grav.phold || ci->grav.mhold) return 0;
if (cell_glocktree(ci) != 0)
return 0;
else if (cell_mlocktree(ci) != 0) {
cell_gunlocktree(ci);
return 0;
}
#endif
break; break;
case task_type_grav_long_range: case task_type_grav_long_range:
return 1; #ifdef SWIFT_TASKS_WITHOUT_ATOMICS
/* Lock the m-poles */
if (ci->grav.mhold) return 0;
if (cell_mlocktree(ci) != 0) return 0;
#endif
break; break;
case task_type_grav_mm: case task_type_grav_mm:
return 1; #ifdef SWIFT_TASKS_WITHOUT_ATOMICS
/* Lock both m-poles */
if (ci->grav.mhold || cj->grav.mhold) return 0;
if (cell_mlocktree(ci) != 0) return 0;
if (cell_mlocktree(cj) != 0) {
cell_munlocktree(ci);
return 0;
}
#endif
break; break;
case task_type_star_formation: case task_type_star_formation:
...@@ -1276,10 +1361,6 @@ enum task_categories task_get_category(const struct task *t) { ...@@ -1276,10 +1361,6 @@ enum task_categories task_get_category(const struct task *t) {
case task_type_end_grav_force: case task_type_end_grav_force:
return task_category_gravity; return task_category_gravity;
case task_type_fof_self:
case task_type_fof_pair:
return task_category_fof;
case task_type_self: case task_type_self:
case task_type_pair: case task_type_pair:
case task_type_sub_self: case task_type_sub_self:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment