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
ec8c1de5
Commit
ec8c1de5
authored
May 16, 2016
by
Matthieu Schaller
Browse files
Removed all the gravity tasks apart from the 'up' ones.
parent
bced4c82
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
src/engine.c
View file @
ec8c1de5
...
...
@@ -1340,28 +1340,31 @@ void engine_make_extra_hydroloop_tasks(struct engine *e) {
void
engine_make_gravityinteraction_tasks
(
struct
engine
*
e
)
{
struct
space
*
s
=
e
->
s
;
struct
scheduler
*
sched
=
&
e
->
sched
;
/*
struct scheduler *sched = &e->sched;
*/
const
int
nr_cells
=
s
->
nr_cells
;
struct
cell
*
cells
=
s
->
cells
;
/*
struct cell *cells = s->cells;
*/
/* Loop over all cells. */
for
(
int
i
=
0
;
i
<
nr_cells
;
i
++
)
{
/* If it has gravity particles, add a self-task */
if
(
cells
[
i
].
gcount
>
0
)
{
scheduler_addtask
(
sched
,
task_type_grav_mm
,
task_subtype_none
,
-
1
,
0
,
&
cells
[
i
],
NULL
,
0
);
/* Loop over all remainding cells */
for
(
int
j
=
i
+
1
;
j
<
nr_cells
;
j
++
)
{
/* If that other cell has gravity parts, add a pair interaction */
if
(
cells
[
j
].
gcount
>
0
)
{
scheduler_addtask
(
sched
,
task_type_grav_mm
,
task_subtype_none
,
-
1
,
0
,
&
cells
[
i
],
&
cells
[
j
],
0
);
}
}
}
/* /\* If it has gravity particles, add a self-task *\/ */
/* if (cells[i].gcount > 0) { */
/* scheduler_addtask(sched, task_type_grav_mm, task_subtype_none, -1, 0,
*/
/* &cells[i], NULL, 0); */
/* /\* Loop over all remainding cells *\/ */
/* for (int j = i + 1; j < nr_cells; j++) { */
/* /\* If that other cell has gravity parts, add a pair interaction *\/
*/
/* if (cells[j].gcount > 0) { */
/* scheduler_addtask(sched, task_type_grav_mm, task_subtype_none, -1,
* 0, */
/* &cells[i], &cells[j], 0); */
/* } */
/* } */
/* } */
}
}
...
...
@@ -1390,9 +1393,12 @@ void engine_make_gravityrecursive_tasks(struct engine *e) {
struct
task
*
up
=
scheduler_addtask
(
sched
,
task_type_grav_up
,
task_subtype_none
,
0
,
0
,
&
cells
[
k
],
NULL
,
0
);
struct
task
*
down
=
scheduler_addtask
(
sched
,
task_type_grav_down
,
task_subtype_none
,
0
,
0
,
&
cells
[
k
],
NULL
,
0
);
struct
task
*
down
=
NULL
;
/* struct task *down = */
/* scheduler_addtask(sched, task_type_grav_down, task_subtype_none, 0,
* 0, */
/* &cells[k], NULL, 0); */
/* Push tasks down the cell hierarchy. */
engine_addtasks_grav
(
e
,
&
cells
[
k
],
up
,
down
);
...
...
@@ -1428,8 +1434,8 @@ void engine_maketasks(struct engine *e) {
engine_make_hydroloop_tasks
(
e
);
/* Add the gravity mm tasks. */
if
(
e
->
policy
&
engine_policy_self_gravity
)
engine_make_gravityinteraction_tasks
(
e
);
/*
if (e->policy & engine_policy_self_gravity)
*/
/*
engine_make_gravityinteraction_tasks(e);
*/
/* Split the tasks. */
scheduler_splittasks
(
sched
);
...
...
src/runner.c
View file @
ec8c1de5
...
...
@@ -1340,8 +1340,8 @@ void *runner_main(void *data) {
runner_dosub1_density
(
r
,
ci
,
cj
,
t
->
flags
,
1
);
else
if
(
t
->
subtype
==
task_subtype_force
)
runner_dosub2_force
(
r
,
ci
,
cj
,
t
->
flags
,
1
);
else
if
(
t
->
subtype
==
task_subtype_grav
)
runner_dosub_grav
(
r
,
ci
,
cj
,
1
);
/*
else if (t->subtype == task_subtype_grav)
*/
/*
runner_dosub_grav(r, ci, cj, 1);
*/
else
error
(
"Unknown task subtype."
);
break
;
...
...
@@ -1362,21 +1362,21 @@ void *runner_main(void *data) {
case
task_type_recv
:
runner_dorecv_cell
(
r
,
ci
,
1
);
break
;
case
task_type_grav_pp
:
if
(
t
->
cj
==
NULL
)
runner_doself_grav
(
r
,
t
->
ci
);
else
runner_dopair_grav
(
r
,
t
->
ci
,
t
->
cj
);
break
;
case
task_type_grav_mm
:
runner_dograv_mm
(
r
,
t
->
ci
,
t
->
cj
);
break
;
/*
case task_type_grav_pp:
*/
/*
if (t->cj == NULL)
*/
/*
runner_doself_grav(r, t->ci);
*/
/*
else
*/
/*
runner_dopair_grav(r, t->ci, t->cj);
*/
/*
break;
*/
/*
case task_type_grav_mm:
*/
/*
runner_dograv_mm(r, t->ci, t->cj);
*/
/*
break;
*/
case
task_type_grav_up
:
runner_dograv_up
(
r
,
t
->
ci
);
break
;
case
task_type_grav_down
:
runner_dograv_down
(
r
,
t
->
ci
);
break
;
/*
case task_type_grav_down:
*/
/*
runner_dograv_down(r, t->ci);
*/
/*
break;
*/
case
task_type_grav_external
:
runner_dograv_external
(
r
,
t
->
ci
,
1
);
break
;
...
...
src/runner_doiact_grav.h
View file @
ec8c1de5
This diff is collapsed.
Click to expand it.
src/scheduler.c
View file @
ec8c1de5
...
...
@@ -518,130 +518,138 @@ void scheduler_splittasks(struct scheduler *s) {
}
/* pair interaction? */
/* Gravity interaction? */
else
if
(
t
->
type
==
task_type_grav_mm
)
{
/* Get a handle on the cells involved. */
struct
cell
*
ci
=
t
->
ci
;
struct
cell
*
cj
=
t
->
cj
;
/* Self-interaction? */
if
(
cj
==
NULL
)
{
/* Ignore this task if the cell has no gparts. */
if
(
ci
->
gcount
==
0
)
t
->
type
=
task_type_none
;
/* If the cell is split, recurse. */
else
if
(
ci
->
split
)
{
/* Make a single sub-task? */
if
(
scheduler_dosub
&&
ci
->
gcount
<
space_subsize
/
ci
->
gcount
)
{
t
->
type
=
task_type_sub
;
t
->
subtype
=
task_subtype_grav
;
}
/* Otherwise, just split the task. */
else
{
/* Split this task into tasks on its progeny. */
t
->
type
=
task_type_none
;
for
(
int
j
=
0
;
j
<
8
;
j
++
)
if
(
ci
->
progeny
[
j
]
!=
NULL
&&
ci
->
progeny
[
j
]
->
gcount
>
0
)
{
if
(
t
->
type
==
task_type_none
)
{
t
->
type
=
task_type_grav_mm
;
t
->
ci
=
ci
->
progeny
[
j
];
t
->
cj
=
NULL
;
}
else
t
=
scheduler_addtask
(
s
,
task_type_grav_mm
,
task_subtype_none
,
0
,
0
,
ci
->
progeny
[
j
],
NULL
,
0
);
for
(
int
k
=
j
+
1
;
k
<
8
;
k
++
)
if
(
ci
->
progeny
[
k
]
!=
NULL
&&
ci
->
progeny
[
k
]
->
gcount
>
0
)
{
if
(
t
->
type
==
task_type_none
)
{
t
->
type
=
task_type_grav_mm
;
t
->
ci
=
ci
->
progeny
[
j
];
t
->
cj
=
ci
->
progeny
[
k
];
}
else
t
=
scheduler_addtask
(
s
,
task_type_grav_mm
,
task_subtype_none
,
0
,
0
,
ci
->
progeny
[
j
],
ci
->
progeny
[
k
],
0
);
}
}
redo
=
(
t
->
type
!=
task_type_none
);
}
}
/* Otherwise, just make a pp task out of it. */
else
t
->
type
=
task_type_grav_pp
;
}
/* Nope, pair. */
else
{
/* Make a sub-task? */
if
(
scheduler_dosub
&&
ci
->
gcount
<
space_subsize
/
cj
->
gcount
)
{
t
->
type
=
task_type_sub
;
t
->
subtype
=
task_subtype_grav
;
}
/* Otherwise, split the task. */
else
{
/* Get the opening angle theta. */
float
dx
[
3
],
theta
;
for
(
int
k
=
0
;
k
<
3
;
k
++
)
{
dx
[
k
]
=
fabs
(
ci
->
loc
[
k
]
-
cj
->
loc
[
k
]);
if
(
s
->
space
->
periodic
&&
dx
[
k
]
>
0
.
5
*
s
->
space
->
dim
[
k
])
dx
[
k
]
=
-
dx
[
k
]
+
s
->
space
->
dim
[
k
];
if
(
dx
[
k
]
>
0
.
0
f
)
dx
[
k
]
-=
ci
->
h
[
k
];
}
theta
=
(
dx
[
0
]
*
dx
[
0
]
+
dx
[
1
]
*
dx
[
1
]
+
dx
[
2
]
*
dx
[
2
])
/
(
ci
->
h
[
0
]
*
ci
->
h
[
0
]
+
ci
->
h
[
1
]
*
ci
->
h
[
1
]
+
ci
->
h
[
2
]
*
ci
->
h
[
2
]);
/* Ignore this task if the cell has no gparts. */
if
(
ci
->
gcount
==
0
||
cj
->
gcount
==
0
)
t
->
type
=
task_type_none
;
/* Split the interaction? */
else
if
(
theta
<
const_theta_max
*
const_theta_max
)
{
/* Are both ci and cj split? */
if
(
ci
->
split
&&
cj
->
split
)
{
/* Split this task into tasks on its progeny. */
t
->
type
=
task_type_none
;
for
(
int
j
=
0
;
j
<
8
;
j
++
)
if
(
ci
->
progeny
[
j
]
!=
NULL
&&
ci
->
progeny
[
j
]
->
gcount
>
0
)
{
for
(
int
k
=
0
;
k
<
8
;
k
++
)
if
(
cj
->
progeny
[
k
]
!=
NULL
&&
cj
->
progeny
[
k
]
->
gcount
>
0
)
{
if
(
t
->
type
==
task_type_none
)
{
t
->
type
=
task_type_grav_mm
;
t
->
ci
=
ci
->
progeny
[
j
];
t
->
cj
=
cj
->
progeny
[
k
];
}
else
t
=
scheduler_addtask
(
s
,
task_type_grav_mm
,
task_subtype_none
,
0
,
0
,
ci
->
progeny
[
j
],
cj
->
progeny
[
k
],
0
);
}
}
redo
=
(
t
->
type
!=
task_type_none
);
}
/* Otherwise, make a pp task out of it. */
else
t
->
type
=
task_type_grav_pp
;
}
}
}
/* gravity pair interaction? */
}
/* gravity interaction? */
/* else if (t->type == task_type_grav_mm) { */
/* /\* Get a handle on the cells involved. *\/ */
/* struct cell *ci = t->ci; */
/* struct cell *cj = t->cj; */
/* /\* Self-interaction? *\/ */
/* if (cj == NULL) { */
/* /\* Ignore this task if the cell has no gparts. *\/ */
/* if (ci->gcount == 0) t->type = task_type_none; */
/* /\* If the cell is split, recurse. *\/ */
/* else if (ci->split) { */
/* /\* Make a single sub-task? *\/ */
/* if (scheduler_dosub && ci->gcount < space_subsize / ci->gcount) {
*/
/* t->type = task_type_sub; */
/* t->subtype = task_subtype_grav; */
/* } */
/* /\* Otherwise, just split the task. *\/ */
/* else { */
/* /\* Split this task into tasks on its progeny. *\/ */
/* t->type = task_type_none; */
/* for (int j = 0; j < 8; j++) */
/* if (ci->progeny[j] != NULL && ci->progeny[j]->gcount > 0) { */
/* if (t->type == task_type_none) { */
/* t->type = task_type_grav_mm; */
/* t->ci = ci->progeny[j]; */
/* t->cj = NULL; */
/* } else */
/* t = scheduler_addtask(s, task_type_grav_mm,
* task_subtype_none, */
/* 0, 0, ci->progeny[j], NULL, 0); */
/* for (int k = j + 1; k < 8; k++) */
/* if (ci->progeny[k] != NULL && ci->progeny[k]->gcount > 0) {
*/
/* if (t->type == task_type_none) { */
/* t->type = task_type_grav_mm; */
/* t->ci = ci->progeny[j]; */
/* t->cj = ci->progeny[k]; */
/* } else */
/* t = scheduler_addtask(s, task_type_grav_mm, */
/* task_subtype_none, 0, 0, */
/* ci->progeny[j], ci->progeny[k],
* 0); */
/* } */
/* } */
/* redo = (t->type != task_type_none); */
/* } */
/* } */
/* /\* Otherwise, just make a pp task out of it. *\/ */
/* else */
/* t->type = task_type_grav_pp; */
/* } */
/* /\* Nope, pair. *\/ */
/* else { */
/* /\* Make a sub-task? *\/ */
/* if (scheduler_dosub && ci->gcount < space_subsize / cj->gcount) { */
/* t->type = task_type_sub; */
/* t->subtype = task_subtype_grav; */
/* } */
/* /\* Otherwise, split the task. *\/ */
/* else { */
/* /\* Get the opening angle theta. *\/ */
/* float dx[3], theta; */
/* for (int k = 0; k < 3; k++) { */
/* dx[k] = fabs(ci->loc[k] - cj->loc[k]); */
/* if (s->space->periodic && dx[k] > 0.5 * s->space->dim[k]) */
/* dx[k] = -dx[k] + s->space->dim[k]; */
/* if (dx[k] > 0.0f) dx[k] -= ci->h[k]; */
/* } */
/* theta = */
/* (dx[0] * dx[0] + dx[1] * dx[1] + dx[2] * dx[2]) / */
/* (ci->h[0] * ci->h[0] + ci->h[1] * ci->h[1] + ci->h[2] *
* ci->h[2]); */
/* /\* Ignore this task if the cell has no gparts. *\/ */
/* if (ci->gcount == 0 || cj->gcount == 0) t->type = task_type_none;
*/
/* /\* Split the interaction? *\/ */
/* else if (theta < const_theta_max * const_theta_max) { */
/* /\* Are both ci and cj split? *\/ */
/* if (ci->split && cj->split) { */
/* /\* Split this task into tasks on its progeny. *\/ */
/* t->type = task_type_none; */
/* for (int j = 0; j < 8; j++) */
/* if (ci->progeny[j] != NULL && ci->progeny[j]->gcount > 0) {
*/
/* for (int k = 0; k < 8; k++) */
/* if (cj->progeny[k] != NULL && cj->progeny[k]->gcount > 0)
* { */
/* if (t->type == task_type_none) { */
/* t->type = task_type_grav_mm; */
/* t->ci = ci->progeny[j]; */
/* t->cj = cj->progeny[k]; */
/* } else */
/* t = scheduler_addtask( */
/* s, task_type_grav_mm, task_subtype_none, 0, 0, */
/* ci->progeny[j], cj->progeny[k], 0); */
/* } */
/* } */
/* redo = (t->type != task_type_none); */
/* } */
/* /\* Otherwise, make a pp task out of it. *\/ */
/* else */
/* t->type = task_type_grav_pp; */
/* } */
/* } */
/* } /\* gravity pair interaction? *\/ */
/* } /\* gravity interaction? *\/ */
}
/* loop over all tasks. */
}
...
...
src/space.c
View file @
ec8c1de5
...
...
@@ -452,8 +452,7 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
const
int
t
=
ind
[
k
];
ind
[
k
]
=
ind
[
nr_parts
];
ind
[
nr_parts
]
=
t
;
}
else
{
}
else
{
/* Increment when not exchanging otherwise we need to retest "k".*/
k
++
;
}
...
...
@@ -488,8 +487,7 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
const
int
t
=
gind
[
k
];
gind
[
k
]
=
gind
[
nr_gparts
];
gind
[
nr_gparts
]
=
t
;
}
else
{
}
else
{
/* Increment when not exchanging otherwise we need to retest "k".*/
k
++
;
}
...
...
@@ -508,7 +506,6 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
}
}*/
/* Exchange the strays, note that this potentially re-allocates
the parts arrays. */
size_t
nr_parts_exchanged
=
s
->
nr_parts
-
nr_parts
;
...
...
src/task.c
View file @
ec8c1de5
...
...
@@ -47,10 +47,10 @@
/* Task type names. */
const
char
*
taskID_names
[
task_type_count
]
=
{
"none"
,
"sort"
,
"self"
,
"pair"
,
"sub"
,
"init"
,
"ghost"
,
"drift"
,
"kick"
,
"send"
,
"recv"
,
"grav_
p
p"
,
"grav_
mm"
,
"grav_up"
,
"grav_down
"
,
"grav_external"
,
"part_sort"
,
"gpart_sort"
,
"split_cell"
,
"rewait"
};
"none"
,
"sort"
,
"self"
,
"pair"
,
"sub"
,
"init"
,
"ghost"
,
"drift"
,
"kick"
,
"send"
,
"recv"
,
"grav_
u
p"
,
"grav_
external"
,
"part_sort"
,
"gpart_sort
"
,
"split_cell"
,
"rewait"
};
const
char
*
subtaskID_names
[
task_type_count
]
=
{
"none"
,
"density"
,
"force"
,
"grav"
};
...
...
@@ -124,12 +124,12 @@ void task_unlock(struct task *t) {
cell_unlocktree
(
t
->
ci
);
if
(
t
->
cj
!=
NULL
)
cell_unlocktree
(
t
->
cj
);
break
;
case
task_type_grav_pp
:
case
task_type_grav_mm
:
case
task_type_grav_down
:
cell_gunlocktree
(
t
->
ci
);
if
(
t
->
cj
!=
NULL
)
cell_gunlocktree
(
t
->
cj
);
break
;
/*
case task_type_grav_pp:
*/
/*
case task_type_grav_mm:
*/
/*
case task_type_grav_down:
*/
/*
cell_gunlocktree(t->ci);
*/
/*
if (t->cj != NULL) cell_gunlocktree(t->cj);
*/
/*
break;
*/
default:
break
;
}
...
...
@@ -184,15 +184,15 @@ int task_lock(struct task *t) {
}
/* Gravity tasks? */
else
if
(
type
==
task_type_grav_mm
||
type
==
task_type_grav_pp
||
type
==
task_type_grav_down
)
{
if
(
ci
->
ghold
||
(
cj
!=
NULL
&&
cj
->
ghold
))
return
0
;
if
(
cell_glocktree
(
ci
)
!=
0
)
return
0
;
if
(
cj
!=
NULL
&&
cell_glocktree
(
cj
)
!=
0
)
{
cell_gunlocktree
(
ci
);
return
0
;
}
}
/*
else if (type == task_type_grav_mm || type == task_type_grav_pp ||
*/
/*
type == task_type_grav_down) {
*/
/*
if (ci->ghold || (cj != NULL && cj->ghold)) return 0;
*/
/*
if (cell_glocktree(ci) != 0) return 0;
*/
/*
if (cj != NULL && cell_glocktree(cj) != 0) {
*/
/*
cell_gunlocktree(ci);
*/
/*
return 0;
*/
/* } */
/* } */
/* If we made it this far, we've got a lock. */
return
1
;
...
...
src/task.h
View file @
ec8c1de5
...
...
@@ -44,10 +44,10 @@ enum task_types {
task_type_kick
,
task_type_send
,
task_type_recv
,
task_type_grav_pp
,
task_type_grav_mm
,
/*
task_type_grav_pp,
*/
/*
task_type_grav_mm,
*/
task_type_grav_up
,
task_type_grav_down
,
/*
task_type_grav_down,
*/
task_type_grav_external
,
task_type_part_sort
,
task_type_gpart_sort
,
...
...
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