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
a5096a40
Commit
a5096a40
authored
Aug 02, 2018
by
Loic Hausammann
Browse files
Spliting hydro/stars
parent
561825dd
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/cell.c
View file @
a5096a40
...
...
@@ -2325,6 +2325,9 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) {
if
(
c
->
ghost_in
!=
NULL
)
scheduler_activate
(
s
,
c
->
ghost_in
);
if
(
c
->
ghost_out
!=
NULL
)
scheduler_activate
(
s
,
c
->
ghost_out
);
if
(
c
->
ghost
!=
NULL
)
scheduler_activate
(
s
,
c
->
ghost
);
if
(
c
->
star_ghost_in
!=
NULL
)
scheduler_activate
(
s
,
c
->
star_ghost_in
);
if
(
c
->
star_ghost_out
!=
NULL
)
scheduler_activate
(
s
,
c
->
star_ghost_out
);
if
(
c
->
star_ghost
!=
NULL
)
scheduler_activate
(
s
,
c
->
star_ghost
);
if
(
c
->
kick1
!=
NULL
)
scheduler_activate
(
s
,
c
->
kick1
);
if
(
c
->
kick2
!=
NULL
)
scheduler_activate
(
s
,
c
->
kick2
);
if
(
c
->
timestep
!=
NULL
)
scheduler_activate
(
s
,
c
->
timestep
);
...
...
src/engine.c
View file @
a5096a40
...
...
@@ -430,7 +430,7 @@ void engine_make_hierarchical_tasks_stars(struct engine *e, struct cell *c) {
struct
scheduler
*
s
=
&
e
->
sched
;
/* Are we in a super-cell ? */
if
(
c
->
super
_hydro
==
c
)
{
if
(
c
->
super
==
c
)
{
/* Local tasks only... */
if
(
c
->
nodeID
==
e
->
nodeID
)
{
...
...
@@ -2958,7 +2958,7 @@ static inline void engine_make_stars_loops_dependencies(struct scheduler *sched,
struct
task
*
density
,
struct
cell
*
c
)
{
/* density loop --> ghost */
scheduler_addunlock
(
sched
,
density
,
c
->
super
_hydro
->
star_ghost_in
);
scheduler_addunlock
(
sched
,
density
,
c
->
super
->
star_ghost_in
);
}
/**
...
...
@@ -2971,14 +2971,13 @@ static inline void engine_make_stars_loops_dependencies(struct scheduler *sched,
* With all the relevant tasks for a given cell available, we construct
* all the dependencies for that cell.
*/
void
engine_make_extra_loop_tasks_mapper
(
void
*
map_data
,
int
num_elements
,
void
engine_make_extra_
hydro
loop_tasks_mapper
(
void
*
map_data
,
int
num_elements
,
void
*
extra_data
)
{
struct
engine
*
e
=
(
struct
engine
*
)
extra_data
;
struct
scheduler
*
sched
=
&
e
->
sched
;
const
int
nodeID
=
e
->
nodeID
;
const
int
with_cooling
=
(
e
->
policy
&
engine_policy_cooling
);
const
int
with_stars
=
(
e
->
policy
&
engine_policy_stars
);
for
(
int
ind
=
0
;
ind
<
num_elements
;
ind
++
)
{
struct
task
*
t
=
&
((
struct
task
*
)
map_data
)[
ind
];
...
...
@@ -3008,8 +3007,6 @@ void engine_make_extra_loop_tasks_mapper(void *map_data, int num_elements,
/* Now, build all the dependencies for the hydro */
engine_make_hydro_loops_dependencies
(
sched
,
t
,
t2
,
t3
,
t
->
ci
,
with_cooling
);
if
(
with_stars
)
engine_make_stars_loops_dependencies
(
sched
,
t
,
t
->
ci
);
scheduler_addunlock
(
sched
,
t3
,
t
->
ci
->
super
->
end_force
);
#else
...
...
@@ -3021,8 +3018,7 @@ void engine_make_extra_loop_tasks_mapper(void *map_data, int num_elements,
engine_addlink
(
e
,
&
t
->
ci
->
force
,
t2
);
/* Now, build all the dependencies for the hydro */
if
(
with_stars
)
engine_make_stars_loops_dependencies
(
sched
,
t
,
t
->
ci
);
engine_make_hydro_loops_dependencies
(
sched
,
t
,
t2
,
t
->
ci
,
with_cooling
);
scheduler_addunlock
(
sched
,
t2
,
t
->
ci
->
super
->
end_force
);
#endif
}
...
...
@@ -3058,18 +3054,12 @@ void engine_make_extra_loop_tasks_mapper(void *map_data, int num_elements,
if
(
t
->
ci
->
nodeID
==
nodeID
)
{
engine_make_hydro_loops_dependencies
(
sched
,
t
,
t2
,
t3
,
t
->
ci
,
with_cooling
);
if
(
with_stars
)
engine_make_stars_loops_dependencies
(
sched
,
t
,
t
->
ci
);
scheduler_addunlock
(
sched
,
t3
,
t
->
ci
->
super
->
end_force
);
}
if
(
t
->
cj
->
nodeID
==
nodeID
)
{
if
(
t
->
ci
->
super_hydro
!=
t
->
cj
->
super_hydro
)
engine_make_hydro_loops_dependencies
(
sched
,
t
,
t2
,
t3
,
t
->
cj
,
with_cooling
);
if
(
with_stars
)
engine_make_stars_loops_dependencies
(
sched
,
t
,
t
->
ci
);
if
(
t
->
ci
->
super
!=
t
->
cj
->
super
)
scheduler_addunlock
(
sched
,
t3
,
t
->
cj
->
super
->
end_force
);
}
...
...
@@ -3088,16 +3078,12 @@ void engine_make_extra_loop_tasks_mapper(void *map_data, int num_elements,
/* that are local and are not descendant of the same super_hydro-cells */
if
(
t
->
ci
->
nodeID
==
nodeID
)
{
engine_make_hydro_loops_dependencies
(
sched
,
t
,
t2
,
t
->
ci
,
with_cooling
);
if
(
with_stars
)
engine_make_stars_loops_dependencies
(
sched
,
t
,
t
->
ci
);
scheduler_addunlock
(
sched
,
t2
,
t
->
ci
->
super
->
end_force
);
}
if
(
t
->
cj
->
nodeID
==
nodeID
)
{
if
(
t
->
ci
->
super_hydro
!=
t
->
cj
->
super_hydro
)
engine_make_hydro_loops_dependencies
(
sched
,
t
,
t2
,
t
->
cj
,
with_cooling
);
if
(
with_stars
)
engine_make_stars_loops_dependencies
(
sched
,
t
,
t
->
ci
);
if
(
t
->
ci
->
super
!=
t
->
cj
->
super
)
scheduler_addunlock
(
sched
,
t2
,
t
->
cj
->
super
->
end_force
);
}
...
...
@@ -3133,8 +3119,6 @@ void engine_make_extra_loop_tasks_mapper(void *map_data, int num_elements,
if
(
t
->
ci
->
nodeID
==
nodeID
)
{
engine_make_hydro_loops_dependencies
(
sched
,
t
,
t2
,
t3
,
t
->
ci
,
with_cooling
);
if
(
with_stars
)
engine_make_stars_loops_dependencies
(
sched
,
t
,
t
->
ci
);
scheduler_addunlock
(
sched
,
t3
,
t
->
ci
->
super
->
end_force
);
}
...
...
@@ -3151,8 +3135,6 @@ void engine_make_extra_loop_tasks_mapper(void *map_data, int num_elements,
/* that are local and are not descendant of the same super_hydro-cells */
if
(
t
->
ci
->
nodeID
==
nodeID
)
{
engine_make_hydro_loops_dependencies
(
sched
,
t
,
t2
,
t
->
ci
,
with_cooling
);
if
(
with_stars
)
engine_make_stars_loops_dependencies
(
sched
,
t
,
t
->
ci
);
scheduler_addunlock
(
sched
,
t2
,
t
->
ci
->
super
->
end_force
);
}
#endif
...
...
@@ -3193,16 +3175,12 @@ void engine_make_extra_loop_tasks_mapper(void *map_data, int num_elements,
if
(
t
->
ci
->
nodeID
==
nodeID
)
{
engine_make_hydro_loops_dependencies
(
sched
,
t
,
t2
,
t3
,
t
->
ci
,
with_cooling
);
if
(
with_stars
)
engine_make_stars_loops_dependencies
(
sched
,
t
,
t
->
ci
);
scheduler_addunlock
(
sched
,
t3
,
t
->
ci
->
super
->
end_force
);
}
if
(
t
->
cj
->
nodeID
==
nodeID
)
{
if
(
t
->
ci
->
super_hydro
!=
t
->
cj
->
super_hydro
)
engine_make_hydro_loops_dependencies
(
sched
,
t
,
t2
,
t3
,
t
->
cj
,
with_cooling
);
if
(
with_stars
)
engine_make_stars_loops_dependencies
(
sched
,
t
,
t
->
ci
);
if
(
t
->
ci
->
super
!=
t
->
cj
->
super
)
scheduler_addunlock
(
sched
,
t3
,
t
->
cj
->
super
->
end_force
);
}
...
...
@@ -3221,16 +3199,12 @@ void engine_make_extra_loop_tasks_mapper(void *map_data, int num_elements,
/* that are local and are not descendant of the same super_hydro-cells */
if
(
t
->
ci
->
nodeID
==
nodeID
)
{
engine_make_hydro_loops_dependencies
(
sched
,
t
,
t2
,
t
->
ci
,
with_cooling
);
if
(
with_stars
)
engine_make_stars_loops_dependencies
(
sched
,
t
,
t
->
ci
);
scheduler_addunlock
(
sched
,
t2
,
t
->
ci
->
super
->
end_force
);
}
if
(
t
->
cj
->
nodeID
==
nodeID
)
{
if
(
t
->
ci
->
super_hydro
!=
t
->
cj
->
super_hydro
)
engine_make_hydro_loops_dependencies
(
sched
,
t
,
t2
,
t
->
cj
,
with_cooling
);
if
(
with_stars
)
engine_make_stars_loops_dependencies
(
sched
,
t
,
t
->
ci
);
if
(
t
->
ci
->
super
!=
t
->
cj
->
super
)
scheduler_addunlock
(
sched
,
t2
,
t
->
cj
->
super
->
end_force
);
}
...
...
@@ -3298,6 +3272,7 @@ void engine_maketasks(struct engine *e) {
#endif
const
size_t
self_grav_tasks_per_cell
=
125
;
const
size_t
ext_grav_tasks_per_cell
=
1
;
const
size_t
star_tasks_per_cell
=
1
;
if
(
e
->
policy
&
engine_policy_hydro
)
e
->
size_links
+=
s
->
tot_cells
*
hydro_tasks_per_cell
;
...
...
@@ -3305,6 +3280,8 @@ void engine_maketasks(struct engine *e) {
e
->
size_links
+=
s
->
tot_cells
*
ext_grav_tasks_per_cell
;
if
(
e
->
policy
&
engine_policy_self_gravity
)
e
->
size_links
+=
s
->
tot_cells
*
self_grav_tasks_per_cell
;
if
(
e
->
policy
&
engine_policy_stars
)
e
->
size_links
+=
s
->
tot_cells
*
star_tasks_per_cell
;
/* Allocate the new link list */
if
((
e
->
links
=
(
struct
link
*
)
malloc
(
sizeof
(
struct
link
)
*
e
->
size_links
))
==
...
...
@@ -3827,6 +3804,12 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
scheduler_activate
(
s
,
t
);
}
/* Star ghost tasks ? */
else
if
(
t
->
type
==
task_type_star_ghost
||
t
->
type
==
task_type_star_ghost_in
||
t
->
type
==
task_type_star_ghost_out
)
{
if
(
cell_is_active_star
(
t
->
ci
,
e
))
scheduler_activate
(
s
,
t
);
}
/* Time-step? */
else
if
(
t
->
type
==
task_type_timestep
)
{
t
->
ci
->
updated
=
0
;
...
...
src/runner.c
View file @
a5096a40
...
...
@@ -224,7 +224,6 @@ void runner_do_star_ghost(struct runner *r, struct cell *c, int timer) {
/* Avoid floating point exception from f_prime = 0 */
h_new
=
h_old
-
f
/
(
f_prime
+
FLT_MIN
);
#ifdef SWIFT_DEBUG_CHECKS
if
((
f
>
0
.
f
&&
h_new
>
h_old
)
||
(
f
<
0
.
f
&&
h_new
<
h_old
))
error
(
...
...
@@ -2429,6 +2428,9 @@ void *runner_main(void *data) {
runner_do_extra_ghost
(
r
,
ci
,
1
);
break
;
#endif
case
task_type_star_ghost
:
runner_do_star_ghost
(
r
,
ci
,
1
);
break
;
case
task_type_drift_part
:
runner_do_drift_part
(
r
,
ci
,
1
);
break
;
...
...
src/runner_doiact_star.h
View file @
a5096a40
...
...
@@ -934,7 +934,7 @@ void runner_dosub_subset_star_density(struct runner *r, struct cell *ci, struct
}
/* Otherwise, compute the pair directly. */
else
if
(
cell_is_active_
hydro
(
ci
,
e
)
||
cell_is_active_
hydro
(
cj
,
e
))
{
else
if
(
cell_is_active_
star
(
ci
,
e
)
||
cell_is_active_
star
(
cj
,
e
))
{
/* Do any of the cells need to be drifted first? */
if
(
!
cell_are_part_drifted
(
cj
,
e
))
error
(
"Cell should be drifted!"
);
...
...
src/scheduler.c
View file @
a5096a40
...
...
@@ -1271,6 +1271,7 @@ void scheduler_reweight(struct scheduler *s, int verbose) {
const
float
count_j
=
(
t
->
cj
!=
NULL
)
?
t
->
cj
->
count
:
0
.
f
;
const
float
gcount_i
=
(
t
->
ci
!=
NULL
)
?
t
->
ci
->
gcount
:
0
.
f
;
const
float
gcount_j
=
(
t
->
cj
!=
NULL
)
?
t
->
cj
->
gcount
:
0
.
f
;
const
float
scount_i
=
(
t
->
ci
!=
NULL
)
?
t
->
ci
->
scount
:
0
.
f
;
switch
(
t
->
type
)
{
case
task_type_sort
:
...
...
@@ -1324,6 +1325,9 @@ void scheduler_reweight(struct scheduler *s, int verbose) {
case
task_type_extra_ghost
:
if
(
t
->
ci
==
t
->
ci
->
super_hydro
)
cost
=
wscale
*
count_i
;
break
;
case
task_type_star_ghost
:
if
(
t
->
ci
==
t
->
ci
->
super_hydro
)
cost
=
wscale
*
scount_i
;
break
;
case
task_type_drift_part
:
cost
=
wscale
*
count_i
;
break
;
...
...
src/space.c
View file @
a5096a40
...
...
@@ -182,6 +182,9 @@ void space_rebuild_recycle_mapper(void *map_data, int num_elements,
c
->
ghost_in
=
NULL
;
c
->
ghost_out
=
NULL
;
c
->
ghost
=
NULL
;
c
->
star_ghost_in
=
NULL
;
c
->
star_ghost_out
=
NULL
;
c
->
star_ghost
=
NULL
;
c
->
kick1
=
NULL
;
c
->
kick2
=
NULL
;
c
->
timestep
=
NULL
;
...
...
src/task.c
View file @
a5096a40
...
...
@@ -72,47 +72,32 @@ MPI_Comm subtaskMPI_comms[task_subtype_count];
/**
* @brief Computes the overlap between the parts array of two given cells.
*
* @param ci The first #cell.
* @param cj The second #cell.
*/
__attribute__
((
always_inline
))
INLINE
static
size_t
task_cell_overlap_part
(
const
struct
cell
*
restrict
ci
,
const
struct
cell
*
restrict
cj
)
{
if
(
ci
==
NULL
||
cj
==
NULL
)
return
0
;
if
(
ci
->
parts
<=
cj
->
parts
&&
ci
->
parts
+
ci
->
count
>=
cj
->
parts
+
cj
->
count
)
{
return
cj
->
count
;
}
else
if
(
cj
->
parts
<=
ci
->
parts
&&
cj
->
parts
+
cj
->
count
>=
ci
->
parts
+
ci
->
count
)
{
return
ci
->
count
;
}
return
0
;
}
/**
* @brief Computes the overlap between the gparts array of two given cells.
* TYPE is the type of parts (e.g. #part, #gpart, #spart)
*
* @param ci The first #cell.
* @param cj The second #cell.
*/
__attribute__
((
always_inline
))
INLINE
static
size_t
task_cell_overlap_gpart
(
const
struct
cell
*
restrict
ci
,
const
struct
cell
*
restrict
cj
)
{
if
(
ci
==
NULL
||
cj
==
NULL
)
return
0
;
if
(
ci
->
gparts
<=
cj
->
gparts
&&
ci
->
gparts
+
ci
->
gcount
>=
cj
->
gparts
+
cj
->
gcount
)
{
return
cj
->
gcount
;
}
else
if
(
cj
->
gparts
<=
ci
->
gparts
&&
cj
->
gparts
+
cj
->
gcount
>=
ci
->
gparts
+
ci
->
gcount
)
{
return
ci
->
gcount
;
}
return
0
;
#define TASK_CELL_OVERLAP(TYPE, ARRAY, COUNT) \
__attribute__((always_inline)) INLINE static size_t task_cell_overlap_##TYPE( \
const struct cell *restrict ci, const struct cell *restrict cj) { \
\
if (ci == NULL || cj == NULL) return 0; \
\
if (ci->ARRAY <= cj->ARRAY && \
ci->ARRAY + ci->COUNT >= cj->ARRAY + cj->COUNT) { \
return cj->COUNT; \
} else if (cj->ARRAY <= ci->ARRAY && \
cj->ARRAY + cj->COUNT >= ci->ARRAY + ci->COUNT) { \
return ci->COUNT; \
} \
\
return 0; \
}
TASK_CELL_OVERLAP
(
part
,
parts
,
count
);
TASK_CELL_OVERLAP
(
gpart
,
gparts
,
gcount
);
TASK_CELL_OVERLAP
(
spart
,
sparts
,
scount
);
/**
* @brief Returns the #task_actions for a given task.
*
...
...
@@ -136,6 +121,10 @@ __attribute__((always_inline)) INLINE static enum task_actions task_acts_on(
return
task_action_part
;
break
;
case
task_type_star_ghost
:
return
task_action_spart
;
break
;
case
task_type_self
:
case
task_type_pair
:
case
task_type_sub_self
:
...
...
@@ -221,9 +210,11 @@ float task_overlap(const struct task *restrict ta,
const
int
ta_part
=
(
ta_act
==
task_action_part
||
ta_act
==
task_action_all
);
const
int
ta_gpart
=
(
ta_act
==
task_action_gpart
||
ta_act
==
task_action_all
);
const
int
ta_spart
=
(
ta_act
==
task_action_spart
||
ta_act
==
task_action_all
);
const
int
tb_part
=
(
tb_act
==
task_action_part
||
tb_act
==
task_action_all
);
const
int
tb_gpart
=
(
tb_act
==
task_action_gpart
||
tb_act
==
task_action_all
);
const
int
tb_spart
=
(
tb_act
==
task_action_spart
||
tb_act
==
task_action_all
);
/* In the case where both tasks act on parts */
if
(
ta_part
&&
tb_part
)
{
...
...
@@ -262,6 +253,26 @@ float task_overlap(const struct task *restrict ta,
return
((
float
)
size_intersect
)
/
(
size_union
-
size_intersect
);
}
/* In the case where both tasks act on sparts */
else
if
(
ta_spart
&&
tb_spart
)
{
/* Compute the union of the cell data. */
size_t
size_union
=
0
;
if
(
ta
->
ci
!=
NULL
)
size_union
+=
ta
->
ci
->
scount
;
if
(
ta
->
cj
!=
NULL
)
size_union
+=
ta
->
cj
->
scount
;
if
(
tb
->
ci
!=
NULL
)
size_union
+=
tb
->
ci
->
scount
;
if
(
tb
->
cj
!=
NULL
)
size_union
+=
tb
->
cj
->
scount
;
/* Compute the intersection of the cell data. */
const
size_t
size_intersect
=
task_cell_overlap_spart
(
ta
->
ci
,
tb
->
ci
)
+
task_cell_overlap_spart
(
ta
->
ci
,
tb
->
cj
)
+
task_cell_overlap_spart
(
ta
->
cj
,
tb
->
ci
)
+
task_cell_overlap_spart
(
ta
->
cj
,
tb
->
cj
);
return
((
float
)
size_intersect
)
/
(
size_union
-
size_intersect
);
}
/* Else, no overlap */
return
0
.
f
;
...
...
src/task.h
View file @
a5096a40
...
...
@@ -99,6 +99,7 @@ enum task_actions {
task_action_none
,
task_action_part
,
task_action_gpart
,
task_action_spart
,
task_action_all
,
task_action_multipole
,
task_action_count
...
...
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