Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SWIFT
SWIFTsim
Commits
873d4abd
Commit
873d4abd
authored
Mar 06, 2017
by
Matthieu Schaller
Browse files
Correctly lock and unlock tasks using multipoles.
parent
e8bec0ca
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/task.c
View file @
873d4abd
...
...
@@ -276,8 +276,8 @@ float task_overlap(const struct task *restrict ta,
*/
void
task_unlock
(
struct
task
*
t
)
{
const
int
type
=
t
->
type
;
const
int
subtype
=
t
->
subtype
;
const
enum
task_types
type
=
t
->
type
;
const
enum
task_subtypes
subtype
=
t
->
subtype
;
struct
cell
*
ci
=
t
->
ci
,
*
cj
=
t
->
cj
;
/* Act based on task type. */
...
...
@@ -296,6 +296,7 @@ void task_unlock(struct task *t) {
case
task_type_sub_self
:
if
(
subtype
==
task_subtype_grav
)
{
cell_gunlocktree
(
ci
);
cell_munlocktree
(
ci
);
}
else
{
cell_unlocktree
(
ci
);
}
...
...
@@ -306,15 +307,25 @@ void task_unlock(struct task *t) {
if
(
subtype
==
task_subtype_grav
)
{
cell_gunlocktree
(
ci
);
cell_gunlocktree
(
cj
);
cell_munlocktree
(
ci
);
cell_munlocktree
(
cj
);
}
else
{
cell_unlocktree
(
ci
);
cell_unlocktree
(
cj
);
}
break
;
case
task_type_grav_
mm
:
case
task_type_grav_
down
:
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
;
default:
break
;
}
...
...
@@ -327,8 +338,8 @@ void task_unlock(struct task *t) {
*/
int
task_lock
(
struct
task
*
t
)
{
const
int
type
=
t
->
type
;
const
int
subtype
=
t
->
subtype
;
const
enum
task_types
type
=
t
->
type
;
const
enum
task_subtypes
subtype
=
t
->
subtype
;
struct
cell
*
ci
=
t
->
ci
,
*
cj
=
t
->
cj
;
#ifdef WITH_MPI
int
res
=
0
,
err
=
0
;
...
...
@@ -371,7 +382,14 @@ int task_lock(struct task *t) {
case
task_type_self
:
case
task_type_sub_self
:
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
{
if
(
cell_locktree
(
ci
)
!=
0
)
return
0
;
}
...
...
@@ -380,13 +398,24 @@ int task_lock(struct task *t) {
case
task_type_pair
:
case
task_type_sub_pair
:
if
(
subtype
==
task_subtype_grav
)
{
/* Lock the gparts and the m-pole in both cells */
if
(
ci
->
ghold
||
cj
->
ghold
)
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
;
}
}
else
{
/* Lock the parts in both cells */
if
(
ci
->
hold
||
cj
->
hold
)
return
0
;
if
(
cell_locktree
(
ci
)
!=
0
)
return
0
;
if
(
cell_locktree
(
cj
)
!=
0
)
{
...
...
@@ -396,8 +425,23 @@ int task_lock(struct task *t) {
}
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
:
cell_glocktree
(
ci
);
/* Lock the m-poles */
if
(
ci
->
mhold
)
return
0
;
if
(
cell_mlocktree
(
ci
)
!=
0
)
return
0
;
break
;
default:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment