Commit 873d4abd authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Correctly lock and unlock tasks using multipoles.

parent e8bec0ca
...@@ -276,8 +276,8 @@ float task_overlap(const struct task *restrict ta, ...@@ -276,8 +276,8 @@ float task_overlap(const struct task *restrict ta,
*/ */
void task_unlock(struct task *t) { void task_unlock(struct task *t) {
const int type = t->type; const enum task_types type = t->type;
const int subtype = t->subtype; const enum task_subtypes subtype = t->subtype;
struct cell *ci = t->ci, *cj = t->cj; struct cell *ci = t->ci, *cj = t->cj;
/* Act based on task type. */ /* Act based on task type. */
...@@ -296,6 +296,7 @@ void task_unlock(struct task *t) { ...@@ -296,6 +296,7 @@ void task_unlock(struct task *t) {
case task_type_sub_self: case task_type_sub_self:
if (subtype == task_subtype_grav) { if (subtype == task_subtype_grav) {
cell_gunlocktree(ci); cell_gunlocktree(ci);
cell_munlocktree(ci);
} else { } else {
cell_unlocktree(ci); cell_unlocktree(ci);
} }
...@@ -306,15 +307,25 @@ void task_unlock(struct task *t) { ...@@ -306,15 +307,25 @@ void task_unlock(struct task *t) {
if (subtype == task_subtype_grav) { if (subtype == task_subtype_grav) {
cell_gunlocktree(ci); cell_gunlocktree(ci);
cell_gunlocktree(cj); cell_gunlocktree(cj);
cell_munlocktree(ci);
cell_munlocktree(cj);
} else { } else {
cell_unlocktree(ci); cell_unlocktree(ci);
cell_unlocktree(cj); cell_unlocktree(cj);
} }
break; break;
case task_type_grav_mm: case task_type_grav_down:
cell_gunlocktree(ci); cell_gunlocktree(ci);
cell_munlocktree(ci);
break;
case task_type_grav_top_level:
case task_type_grav_long_range:
case task_type_grav_mm:
cell_munlocktree(ci);
break; break;
default: default:
break; break;
} }
...@@ -327,8 +338,8 @@ void task_unlock(struct task *t) { ...@@ -327,8 +338,8 @@ void task_unlock(struct task *t) {
*/ */
int task_lock(struct task *t) { int task_lock(struct task *t) {
const int type = t->type; const enum task_types type = t->type;
const int subtype = t->subtype; const enum task_subtypes subtype = t->subtype;
struct cell *ci = t->ci, *cj = t->cj; struct cell *ci = t->ci, *cj = t->cj;
#ifdef WITH_MPI #ifdef WITH_MPI
int res = 0, err = 0; int res = 0, err = 0;
...@@ -371,7 +382,14 @@ int task_lock(struct task *t) { ...@@ -371,7 +382,14 @@ 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) {
if (cell_glocktree(ci) != 0) return 0; /* Lock the gparts and the m-pole */
if (ci->ghold || ci->mhold) return 0;
if (cell_glocktree(ci) != 0)
return 0;
else if (cell_mlocktree(ci) != 0) {
cell_gunlocktree(ci);
return 0;
}
} else { } else {
if (cell_locktree(ci) != 0) return 0; if (cell_locktree(ci) != 0) return 0;
} }
...@@ -380,13 +398,24 @@ int task_lock(struct task *t) { ...@@ -380,13 +398,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) {
/* Lock the gparts and the m-pole in both cells */
if (ci->ghold || cj->ghold) return 0; if (ci->ghold || cj->ghold) return 0;
if (cell_glocktree(ci) != 0) return 0; if (cell_glocktree(ci) != 0) return 0;
if (cell_glocktree(cj) != 0) { if (cell_glocktree(cj) != 0) {
cell_gunlocktree(ci); cell_gunlocktree(ci);
return 0; 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;
} }
} else { } else {
/* Lock the parts in both cells */
if (ci->hold || cj->hold) return 0; if (ci->hold || cj->hold) return 0;
if (cell_locktree(ci) != 0) return 0; if (cell_locktree(ci) != 0) return 0;
if (cell_locktree(cj) != 0) { if (cell_locktree(cj) != 0) {
...@@ -396,8 +425,23 @@ int task_lock(struct task *t) { ...@@ -396,8 +425,23 @@ int task_lock(struct task *t) {
} }
break; break;
case task_type_grav_down:
/* Lock the gparts and the m-poles */
if (ci->ghold || ci->mhold) return 0;
if (cell_glocktree(ci) != 0)
return 0;
else if (cell_mlocktree(ci) != 0) {
cell_gunlocktree(ci);
return 0;
}
break;
case task_type_grav_top_level:
case task_type_grav_long_range:
case task_type_grav_mm: case task_type_grav_mm:
cell_glocktree(ci); /* Lock the m-poles */
if (ci->mhold) return 0;
if (cell_mlocktree(ci) != 0) return 0;
break; break;
default: default:
......
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