Skip to content
Snippets Groups Projects
Commit bc72b5d2 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Solve the dining philosopher problem in the locking of the cells' multipoles

parent c0768afa
No related branches found
No related tags found
1 merge request!1048Atomic gravity and time-step limiter
......@@ -1357,9 +1357,15 @@ static INLINE void runner_dopair_grav_mm_symmetric(struct runner *r,
cj->grav.ti_old_multipole, cj->nodeID, ci->nodeID, e->ti_current);
#endif
/* Lock the multipoles */
/* Lock the multipoles
* Note we impose a hierarchy to solve the dining philosopher problem */
if (ci < cj) {
lock_lock(&ci->grav.mlock);
lock_lock(&cj->grav.mlock);
} else {
lock_lock(&cj->grav.mlock);
lock_lock(&ci->grav.mlock);
}
/* Let's interact at this level */
gravity_M2L_symmetric(&ci->grav.multipole->pot, &cj->grav.multipole->pot,
......@@ -1381,8 +1387,8 @@ static INLINE void runner_dopair_grav_mm_symmetric(struct runner *r,
* @param ci The #cell with field tensor to interact.
* @param cj The #cell with the multipole.
*/
static INLINE void runner_dopair_grav_mm_nonsym(
struct runner *r, struct cell *restrict ci,
static INLINE void runner_dopair_grav_mm_nonsym(struct runner *r,
struct cell *restrict ci,
struct cell *restrict cj) {
/* Some constants */
......@@ -1416,9 +1422,15 @@ static INLINE void runner_dopair_grav_mm_nonsym(
cj->grav.ti_old_multipole, cj->nodeID, ci->nodeID, e->ti_current);
#endif
/* Lock the multipoles */
/* Lock the multipoles
* Note we impose a hierarchy to solve the dining philosopher problem */
if (ci < cj) {
lock_lock(&ci->grav.mlock);
lock_lock(&cj->grav.mlock);
} else {
lock_lock(&cj->grav.mlock);
lock_lock(&ci->grav.mlock);
}
/* Let's interact at this level */
gravity_M2L_nonsym(&ci->grav.multipole->pot, multi_j, ci->grav.multipole->CoM,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment