Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTsim
Commits
9f03a0e1
Commit
9f03a0e1
authored
8 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Make all hierarchical tasks in a single pass.
parent
2c8754df
No related branches found
No related tags found
1 merge request
!259
Fix super pointer
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/cell.c
+5
-11
5 additions, 11 deletions
src/cell.c
src/engine.c
+66
-59
66 additions, 59 deletions
src/engine.c
with
71 additions
and
70 deletions
src/cell.c
+
5
−
11
View file @
9f03a0e1
...
@@ -840,7 +840,6 @@ int cell_is_drift_needed(struct cell *c, int ti_current) {
...
@@ -840,7 +840,6 @@ int cell_is_drift_needed(struct cell *c, int ti_current) {
return
0
;
return
0
;
}
}
/**
/**
* @brief Set the super-cell pointers for all cells in a hierarchy.
* @brief Set the super-cell pointers for all cells in a hierarchy.
*
*
...
@@ -850,20 +849,15 @@ int cell_is_drift_needed(struct cell *c, int ti_current) {
...
@@ -850,20 +849,15 @@ int cell_is_drift_needed(struct cell *c, int ti_current) {
void
cell_set_super
(
struct
cell
*
c
,
struct
cell
*
super
)
{
void
cell_set_super
(
struct
cell
*
c
,
struct
cell
*
super
)
{
/* Are we in a cell with some kind of self/pair task ? */
/* Are we in a cell with some kind of self/pair task ? */
if
(
c
->
nr_tasks
>
0
)
super
=
c
;
if
(
super
==
NULL
&&
c
->
nr_tasks
>
0
)
super
=
c
;
//message("depth=%d nr_tasks=%d super=%p", c->depth, c->nr_tasks, super);
/* Set the super-cell */
/* Set the super-cell */
c
->
super
=
super
;
c
->
super
=
super
;
if
(
c
->
super
==
NULL
)
//if (c->nr_tasks == 0 && super == NULL) message("No tasks here");
message
(
"depth=%d nr_tasks=%d super=%p count=%d loc=[%f %f %f], width=%f"
,
c
->
depth
,
c
->
nr_tasks
,
super
,
/* Recurse */
c
->
count
,
c
->
loc
[
0
],
c
->
loc
[
1
],
c
->
loc
[
2
],
c
->
width
[
0
]);
if
(
c
->
split
)
/* Recurse if we are not in a hierarchy without any tasks. */
if
(
c
->
split
&&
super
!=
NULL
)
for
(
int
k
=
0
;
k
<
8
;
k
++
)
for
(
int
k
=
0
;
k
<
8
;
k
++
)
if
(
c
->
progeny
[
k
]
!=
NULL
)
cell_set_super
(
c
->
progeny
[
k
],
super
);
if
(
c
->
progeny
[
k
]
!=
NULL
)
cell_set_super
(
c
->
progeny
[
k
],
super
);
}
}
This diff is collapsed.
Click to expand it.
src/engine.c
+
66
−
59
View file @
9f03a0e1
...
@@ -120,48 +120,55 @@ void engine_addlink(struct engine *e, struct link **l, struct task *t) {
...
@@ -120,48 +120,55 @@ void engine_addlink(struct engine *e, struct link **l, struct task *t) {
* @param c The #cell.
* @param c The #cell.
* @param gsuper The gsuper #cell.
* @param gsuper The gsuper #cell.
*/
*/
void
engine_make_gravity_hierarchical_tasks
(
struct
engine
*
e
,
struct
cell
*
c
)
{
/* void engine_make_gravity_hierarchical_tasks(struct engine *e, struct cell *c)
* { */
struct
scheduler
*
s
=
&
e
->
sched
;
const
int
is_with_external_gravity
=
/* struct scheduler *s = &e->sched; */
(
e
->
policy
&
engine_policy_external_gravity
);
/* const int is_with_external_gravity = */
const
int
is_fixdt
=
(
e
->
policy
&
engine_policy_fixdt
);
/* (e->policy & engine_policy_external_gravity); */
/* const int is_fixdt = (e->policy & engine_policy_fixdt); */
/* Are we in a cell with self/pair tasks ? */
if
(
c
->
super
==
c
)
{
/* /\* Are we in a cell with self/pair tasks ? *\/ */
/* if (c->super == c) { */
/* Local tasks only... */
if
(
c
->
nodeID
==
e
->
nodeID
)
{
/* /\* Local tasks only... *\/ */
/* if (c->nodeID == e->nodeID) { */
/* /\* Add the init task. *\/ */
/* if (c->init == NULL) */
/* c->init = scheduler_addtask(s, task_type_init, task_subtype_none, 0,
* 0, */
/* c, NULL, 0); */
/* /\* Add the kick task that matches the policy. *\/ */
/* if (is_fixdt) { */
/* if (c->kick == NULL) */
/* c->kick = scheduler_addtask(s, task_type_kick_fixdt, */
/* task_subtype_none, 0, 0, c, NULL, 0);
*/
/* } else { */
/* if (c->kick == NULL) */
/* c->kick = scheduler_addtask(s, task_type_kick, task_subtype_none,
* 0, */
/* 0, c, NULL, 0); */
/* } */
/* /\* External gravity task *\/ */
/* if (is_with_external_gravity && c->grav_external == NULL) */
/* c->grav_external = scheduler_addtask( */
/* s, task_type_grav_external, task_subtype_none, 0, 0, c, NULL, 0);
*/
/* } */
/* Add the init task. */
/* } else { */
if
(
c
->
init
==
NULL
)
c
->
init
=
scheduler_addtask
(
s
,
task_type_init
,
task_subtype_none
,
0
,
0
,
c
,
NULL
,
0
);
/* Add the kick task that matches the policy. */
/* /\* Recurse. *\/ */
if
(
is_fixdt
)
{
/* if (c->split) */
if
(
c
->
kick
==
NULL
)
/* for (int k = 0; k < 8; k++) */
c
->
kick
=
scheduler_addtask
(
s
,
task_type_kick_fixdt
,
/* if (c->progeny[k] != NULL) */
task_subtype_none
,
0
,
0
,
c
,
NULL
,
0
);
/* engine_make_gravity_hierarchical_tasks(e, c->progeny[k]); */
}
else
{
/* } */
if
(
c
->
kick
==
NULL
)
/* } */
c
->
kick
=
scheduler_addtask
(
s
,
task_type_kick
,
task_subtype_none
,
0
,
0
,
c
,
NULL
,
0
);
}
/* External gravity task */
if
(
is_with_external_gravity
)
c
->
grav_external
=
scheduler_addtask
(
s
,
task_type_grav_external
,
task_subtype_none
,
0
,
0
,
c
,
NULL
,
0
);
}
/* Recurse. */
if
(
c
->
split
)
for
(
int
k
=
0
;
k
<
8
;
k
++
)
if
(
c
->
progeny
[
k
]
!=
NULL
)
engine_make_gravity_hierarchical_tasks
(
e
,
c
->
progeny
[
k
]);
}
}
/**
/**
* @brief Generate the hydro hierarchical tasks for a hierarchy of cells -
* @brief Generate the hydro hierarchical tasks for a hierarchy of cells -
...
@@ -173,11 +180,13 @@ void engine_make_gravity_hierarchical_tasks(struct engine *e, struct cell *c) {
...
@@ -173,11 +180,13 @@ void engine_make_gravity_hierarchical_tasks(struct engine *e, struct cell *c) {
* @param c The #cell.
* @param c The #cell.
* @param super The super #cell.
* @param super The super #cell.
*/
*/
void
engine_make_
hydro_
hierarchical_tasks
(
struct
engine
*
e
,
struct
cell
*
c
)
{
void
engine_make_hierarchical_tasks
(
struct
engine
*
e
,
struct
cell
*
c
)
{
struct
scheduler
*
s
=
&
e
->
sched
;
struct
scheduler
*
s
=
&
e
->
sched
;
const
int
is_fixdt
=
(
e
->
policy
&
engine_policy_fixdt
);
const
int
is_fixdt
=
(
e
->
policy
&
engine_policy_fixdt
);
const
int
is_with_cooling
=
(
e
->
policy
&
engine_policy_cooling
);
const
int
is_with_cooling
=
(
e
->
policy
&
engine_policy_cooling
);
const
int
is_with_external_gravity
=
(
e
->
policy
&
engine_policy_external_gravity
);
/* Are we in a cell with self/pair tasks ? */
/* Are we in a cell with self/pair tasks ? */
if
(
c
->
super
==
c
)
{
if
(
c
->
super
==
c
)
{
...
@@ -186,19 +195,16 @@ void engine_make_hydro_hierarchical_tasks(struct engine *e, struct cell *c) {
...
@@ -186,19 +195,16 @@ void engine_make_hydro_hierarchical_tasks(struct engine *e, struct cell *c) {
if
(
c
->
nodeID
==
e
->
nodeID
)
{
if
(
c
->
nodeID
==
e
->
nodeID
)
{
/* Add the init task. */
/* Add the init task. */
if
(
c
->
init
==
NULL
)
c
->
init
=
scheduler_addtask
(
s
,
task_type_init
,
task_subtype_none
,
0
,
0
,
c
,
c
->
init
=
scheduler_addtask
(
s
,
task_type_init
,
task_subtype_none
,
0
,
0
,
NULL
,
0
);
c
,
NULL
,
0
);
/* Add the kick task that matches the policy. */
/* Add the kick task that matches the policy. */
if
(
is_fixdt
)
{
if
(
is_fixdt
)
{
if
(
c
->
kick
==
NULL
)
c
->
kick
=
scheduler_addtask
(
s
,
task_type_kick_fixdt
,
task_subtype_none
,
c
->
kick
=
scheduler_addtask
(
s
,
task_type_kick_fixdt
,
0
,
0
,
c
,
NULL
,
0
);
task_subtype_none
,
0
,
0
,
c
,
NULL
,
0
);
}
else
{
}
else
{
if
(
c
->
kick
==
NULL
)
c
->
kick
=
scheduler_addtask
(
s
,
task_type_kick
,
task_subtype_none
,
0
,
0
,
c
->
kick
=
scheduler_addtask
(
s
,
task_type_kick
,
task_subtype_none
,
0
,
c
,
NULL
,
0
);
0
,
c
,
NULL
,
0
);
}
}
/* Generate the ghost task. */
/* Generate the ghost task. */
...
@@ -211,16 +217,24 @@ void engine_make_hydro_hierarchical_tasks(struct engine *e, struct cell *c) {
...
@@ -211,16 +217,24 @@ void engine_make_hydro_hierarchical_tasks(struct engine *e, struct cell *c) {
task_subtype_none
,
0
,
0
,
c
,
NULL
,
0
);
task_subtype_none
,
0
,
0
,
c
,
NULL
,
0
);
#endif
#endif
/* External gravity task */
if
(
is_with_external_gravity
)
// && c->grav_external == NULL)
c
->
grav_external
=
scheduler_addtask
(
s
,
task_type_grav_external
,
task_subtype_none
,
0
,
0
,
c
,
NULL
,
0
);
/* Cooling task */
if
(
is_with_cooling
)
if
(
is_with_cooling
)
c
->
cooling
=
scheduler_addtask
(
s
,
task_type_cooling
,
task_subtype_none
,
c
->
cooling
=
scheduler_addtask
(
s
,
task_type_cooling
,
task_subtype_none
,
0
,
0
,
c
,
NULL
,
0
);
0
,
0
,
c
,
NULL
,
0
);
}
}
}
else
{
/* Recurse. */
/* Recurse. */
if
(
c
->
split
)
if
(
c
->
split
)
for
(
int
k
=
0
;
k
<
8
;
k
++
)
for
(
int
k
=
0
;
k
<
8
;
k
++
)
if
(
c
->
progeny
[
k
]
!=
NULL
)
if
(
c
->
progeny
[
k
]
!=
NULL
)
engine_make_
hydro_
hierarchical_tasks
(
e
,
c
->
progeny
[
k
]);
engine_make_hierarchical_tasks
(
e
,
c
->
progeny
[
k
]);
}
}
}
}
...
@@ -1874,14 +1888,7 @@ void engine_maketasks(struct engine *e) {
...
@@ -1874,14 +1888,7 @@ void engine_maketasks(struct engine *e) {
for
(
int
k
=
0
;
k
<
nr_cells
;
k
++
)
cell_set_super
(
&
cells
[
k
],
NULL
);
for
(
int
k
=
0
;
k
<
nr_cells
;
k
++
)
cell_set_super
(
&
cells
[
k
],
NULL
);
/* Append hierarchical tasks to each cells */
/* Append hierarchical tasks to each cells */
if
(
e
->
policy
&
engine_policy_hydro
)
for
(
int
k
=
0
;
k
<
nr_cells
;
k
++
)
engine_make_hierarchical_tasks
(
e
,
&
cells
[
k
]);
for
(
int
k
=
0
;
k
<
nr_cells
;
k
++
)
engine_make_hydro_hierarchical_tasks
(
e
,
&
cells
[
k
]);
if
((
e
->
policy
&
engine_policy_self_gravity
)
||
(
e
->
policy
&
engine_policy_external_gravity
))
for
(
int
k
=
0
;
k
<
nr_cells
;
k
++
)
engine_make_gravity_hierarchical_tasks
(
e
,
&
cells
[
k
]);
/* Run through the tasks and make force tasks for each density task.
/* Run through the tasks and make force tasks for each density task.
Each force task depends on the cell ghosts and unlocks the kick task
Each force task depends on the cell ghosts and unlocks the kick task
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment