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
99e8c82a
Commit
99e8c82a
authored
Sep 13, 2017
by
Matthieu Schaller
Browse files
Reduced number of calls to cell_is_active() in the unskip routines by caching the result early on.
parent
9f88b224
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/cell.c
View file @
99e8c82a
...
...
@@ -1859,10 +1859,12 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) {
struct
task
*
t
=
l
->
t
;
struct
cell
*
ci
=
t
->
ci
;
struct
cell
*
cj
=
t
->
cj
;
const
int
ci_active
=
cell_is_active
(
ci
,
e
);
const
int
cj_active
=
(
cj
!=
NULL
)
?
cell_is_active
(
cj
,
e
)
:
0
;
/* Only activate tasks that involve a local active cell. */
if
((
c
ell_is
_active
(
ci
,
e
)
&&
ci
->
nodeID
==
engine_rank
)
||
(
cj
!=
NULL
&&
cell_is_active
(
cj
,
e
)
&&
cj
->
nodeID
==
engine_rank
))
{
if
((
c
i
_active
&&
ci
->
nodeID
==
engine_rank
)
||
(
cj
_active
&&
cj
->
nodeID
==
engine_rank
))
{
scheduler_activate
(
s
,
t
);
/* Activate hydro drift */
...
...
@@ -1904,9 +1906,9 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) {
if
(
ci
->
nodeID
!=
engine_rank
)
{
/* If the local cell is active, receive data from the foreign cell. */
if
(
c
ell_is
_active
(
cj
,
e
)
)
{
if
(
c
j
_active
)
{
scheduler_activate
(
s
,
ci
->
recv_xv
);
if
(
c
ell_is
_active
(
ci
,
e
)
)
{
if
(
c
i
_active
)
{
scheduler_activate
(
s
,
ci
->
recv_rho
);
#ifdef EXTRA_HYDRO_LOOP
scheduler_activate
(
s
,
ci
->
recv_gradient
);
...
...
@@ -1915,10 +1917,10 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) {
}
/* If the foreign cell is active, we want its ti_end values. */
if
(
c
ell_is
_active
(
ci
,
e
)
)
scheduler_activate
(
s
,
ci
->
recv_ti
);
if
(
c
i
_active
)
scheduler_activate
(
s
,
ci
->
recv_ti
);
/* Is the foreign cell active and will need stuff from us? */
if
(
c
ell_is
_active
(
ci
,
e
)
)
{
if
(
c
i
_active
)
{
scheduler_activate_send
(
s
,
cj
->
send_xv
,
ci
->
nodeID
);
...
...
@@ -1927,7 +1929,7 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) {
cell_activate_drift_part
(
cj
,
s
);
/* If the local cell is also active, more stuff will be needed. */
if
(
c
ell_is
_active
(
cj
,
e
)
)
{
if
(
c
j
_active
)
{
scheduler_activate_send
(
s
,
cj
->
send_rho
,
ci
->
nodeID
);
#ifdef EXTRA_HYDRO_LOOP
...
...
@@ -1937,15 +1939,14 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) {
}
/* If the local cell is active, send its ti_end values. */
if
(
cell_is_active
(
cj
,
e
))
scheduler_activate_send
(
s
,
cj
->
send_ti
,
ci
->
nodeID
);
if
(
cj_active
)
scheduler_activate_send
(
s
,
cj
->
send_ti
,
ci
->
nodeID
);
}
else
if
(
cj
->
nodeID
!=
engine_rank
)
{
/* If the local cell is active, receive data from the foreign cell. */
if
(
c
ell_is
_active
(
ci
,
e
)
)
{
if
(
c
i
_active
)
{
scheduler_activate
(
s
,
cj
->
recv_xv
);
if
(
c
ell_is
_active
(
cj
,
e
)
)
{
if
(
c
j
_active
)
{
scheduler_activate
(
s
,
cj
->
recv_rho
);
#ifdef EXTRA_HYDRO_LOOP
scheduler_activate
(
s
,
cj
->
recv_gradient
);
...
...
@@ -1954,10 +1955,10 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) {
}
/* If the foreign cell is active, we want its ti_end values. */
if
(
c
ell_is
_active
(
cj
,
e
)
)
scheduler_activate
(
s
,
cj
->
recv_ti
);
if
(
c
j
_active
)
scheduler_activate
(
s
,
cj
->
recv_ti
);
/* Is the foreign cell active and will need stuff from us? */
if
(
c
ell_is
_active
(
cj
,
e
)
)
{
if
(
c
j
_active
)
{
scheduler_activate_send
(
s
,
ci
->
send_xv
,
cj
->
nodeID
);
...
...
@@ -1966,7 +1967,7 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) {
cell_activate_drift_part
(
ci
,
s
);
/* If the local cell is also active, more stuff will be needed. */
if
(
c
ell_is
_active
(
ci
,
e
)
)
{
if
(
c
i
_active
)
{
scheduler_activate_send
(
s
,
ci
->
send_rho
,
cj
->
nodeID
);
...
...
@@ -1977,8 +1978,7 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) {
}
/* If the local cell is active, send its ti_end values. */
if
(
cell_is_active
(
ci
,
e
))
scheduler_activate_send
(
s
,
ci
->
send_ti
,
cj
->
nodeID
);
if
(
ci_active
)
scheduler_activate_send
(
s
,
ci
->
send_ti
,
cj
->
nodeID
);
}
#endif
}
...
...
src/engine.c
View file @
99e8c82a
...
...
@@ -2690,10 +2690,12 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
/* Local pointers. */
struct
cell
*
ci
=
t
->
ci
;
struct
cell
*
cj
=
t
->
cj
;
const
int
ci_active
=
cell_is_active
(
ci
,
e
);
const
int
cj_active
=
cell_is_active
(
cj
,
e
);
/* Only activate tasks that involve a local active cell. */
if
((
c
ell_is
_active
(
ci
,
e
)
&&
ci
->
nodeID
==
engine_rank
)
||
(
c
ell_is
_active
(
cj
,
e
)
&&
cj
->
nodeID
==
engine_rank
))
{
if
((
c
i
_active
&&
ci
->
nodeID
==
engine_rank
)
||
(
c
j
_active
&&
cj
->
nodeID
==
engine_rank
))
{
scheduler_activate
(
s
,
t
);
/* Set the correct sorting flags */
...
...
@@ -2741,9 +2743,9 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
if
(
ci
->
nodeID
!=
engine_rank
)
{
/* If the local cell is active, receive data from the foreign cell. */
if
(
c
ell_is
_active
(
cj
,
e
)
)
{
if
(
c
j
_active
)
{
scheduler_activate
(
s
,
ci
->
recv_xv
);
if
(
c
ell_is
_active
(
ci
,
e
)
)
{
if
(
c
i
_active
)
{
scheduler_activate
(
s
,
ci
->
recv_rho
);
#ifdef EXTRA_HYDRO_LOOP
scheduler_activate
(
s
,
ci
->
recv_gradient
);
...
...
@@ -2752,10 +2754,10 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
}
/* If the foreign cell is active, we want its ti_end values. */
if
(
c
ell_is
_active
(
ci
,
e
)
)
scheduler_activate
(
s
,
ci
->
recv_ti
);
if
(
c
i
_active
)
scheduler_activate
(
s
,
ci
->
recv_ti
);
/* Is the foreign cell active and will need stuff from us? */
if
(
c
ell_is
_active
(
ci
,
e
)
)
{
if
(
c
i
_active
)
{
struct
link
*
l
=
scheduler_activate_send
(
s
,
cj
->
send_xv
,
ci
->
nodeID
);
...
...
@@ -2766,7 +2768,7 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
cell_activate_drift_part
(
l
->
t
->
ci
,
s
);
/* If the local cell is also active, more stuff will be needed. */
if
(
c
ell_is
_active
(
cj
,
e
)
)
{
if
(
c
j
_active
)
{
scheduler_activate_send
(
s
,
cj
->
send_rho
,
ci
->
nodeID
);
#ifdef EXTRA_HYDRO_LOOP
...
...
@@ -2776,15 +2778,14 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
}
/* If the local cell is active, send its ti_end values. */
if
(
cell_is_active
(
cj
,
e
))
scheduler_activate_send
(
s
,
cj
->
send_ti
,
ci
->
nodeID
);
if
(
cj_active
)
scheduler_activate_send
(
s
,
cj
->
send_ti
,
ci
->
nodeID
);
}
else
if
(
cj
->
nodeID
!=
engine_rank
)
{
/* If the local cell is active, receive data from the foreign cell. */
if
(
c
ell_is
_active
(
ci
,
e
)
)
{
if
(
c
i
_active
)
{
scheduler_activate
(
s
,
cj
->
recv_xv
);
if
(
c
ell_is
_active
(
cj
,
e
)
)
{
if
(
c
j
_active
)
{
scheduler_activate
(
s
,
cj
->
recv_rho
);
#ifdef EXTRA_HYDRO_LOOP
scheduler_activate
(
s
,
cj
->
recv_gradient
);
...
...
@@ -2793,10 +2794,10 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
}
/* If the foreign cell is active, we want its ti_end values. */
if
(
c
ell_is
_active
(
cj
,
e
)
)
scheduler_activate
(
s
,
cj
->
recv_ti
);
if
(
c
j
_active
)
scheduler_activate
(
s
,
cj
->
recv_ti
);
/* Is the foreign cell active and will need stuff from us? */
if
(
c
ell_is
_active
(
cj
,
e
)
)
{
if
(
c
j
_active
)
{
struct
link
*
l
=
scheduler_activate_send
(
s
,
ci
->
send_xv
,
cj
->
nodeID
);
...
...
@@ -2807,7 +2808,7 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
cell_activate_drift_part
(
l
->
t
->
ci
,
s
);
/* If the local cell is also active, more stuff will be needed. */
if
(
c
ell_is
_active
(
ci
,
e
)
)
{
if
(
c
i
_active
)
{
scheduler_activate_send
(
s
,
ci
->
send_rho
,
cj
->
nodeID
);
...
...
@@ -2818,8 +2819,7 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
}
/* If the local cell is active, send its ti_end values. */
if
(
cell_is_active
(
ci
,
e
))
scheduler_activate_send
(
s
,
ci
->
send_ti
,
cj
->
nodeID
);
if
(
ci_active
)
scheduler_activate_send
(
s
,
ci
->
send_ti
,
cj
->
nodeID
);
}
#endif
}
...
...
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