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
d7f2d111
Commit
d7f2d111
authored
7 years ago
by
Pedro Gonnet
Browse files
Options
Downloads
Patches
Plain Diff
use a threadpool_map for engine_make_hydro_tasks.
parent
b82a8ab4
No related branches found
No related tags found
1 merge request
!384
Threadpoolize all the things
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/engine.c
+61
-52
61 additions, 52 deletions
src/engine.c
with
61 additions
and
52 deletions
src/engine.c
+
61
−
52
View file @
d7f2d111
...
...
@@ -1809,9 +1809,15 @@ void engine_make_external_gravity_tasks(struct engine *e) {
* Additional loop over neighbours can later be added by simply duplicating
* all the tasks created by this function.
*
* @param e The #engine.
* @param map_data Offset of first two indices disguised as a pointer.
* @param num_elements Number of cells to traverse.
* @param extra_data The #engine.
*/
void
engine_make_hydroloop_tasks
(
struct
engine
*
e
)
{
void
engine_make_hydroloop_tasks_mapper
(
void
*
map_data
,
int
num_elements
,
void
*
extra_data
)
{
/* Extract the engine pointer. */
struct
engine
*
e
=
(
struct
engine
*
)
extra_data
;
struct
space
*
s
=
e
->
s
;
struct
scheduler
*
sched
=
&
e
->
sched
;
...
...
@@ -1819,13 +1825,16 @@ void engine_make_hydroloop_tasks(struct engine *e) {
const
int
*
cdim
=
s
->
cdim
;
struct
cell
*
cells
=
s
->
cells_top
;
/* Run through the highest level of cells and add pairs. */
for
(
int
i
=
0
;
i
<
cdim
[
0
];
i
++
)
{
for
(
int
j
=
0
;
j
<
cdim
[
1
];
j
++
)
{
for
(
int
k
=
0
;
k
<
cdim
[
2
];
k
++
)
{
/* Loop through the elements, which are just byte offsets from NULL. */
for
(
int
ind
=
0
;
ind
<
num_elements
;
ind
++
)
{
/* Get the cell index. */
const
int
cid
=
(
size_t
)(
map_data
+
ind
);
const
int
i
=
cid
/
(
cdim
[
1
]
*
cdim
[
0
]);
const
int
j
=
(
cid
/
cdim
[
0
])
%
cdim
[
1
];
const
int
k
=
cid
%
(
cdim
[
0
]
*
cdim
[
1
]);
/* Get the cell */
const
int
cid
=
cell_getid
(
cdim
,
i
,
j
,
k
);
struct
cell
*
ci
=
&
cells
[
cid
];
/* Skip cells without hydro particles */
...
...
@@ -1833,8 +1842,8 @@ void engine_make_hydroloop_tasks(struct engine *e) {
/* If the cells is local build a self-interaction */
if
(
ci
->
nodeID
==
nodeID
)
scheduler_addtask
(
sched
,
task_type_self
,
task_subtype_density
,
0
,
0
,
ci
,
NULL
);
scheduler_addtask
(
sched
,
task_type_self
,
task_subtype_density
,
0
,
0
,
ci
,
NULL
);
/* Now loop over all the neighbours of this cell */
for
(
int
ii
=
-
1
;
ii
<
2
;
ii
++
)
{
...
...
@@ -1860,12 +1869,9 @@ void engine_make_hydroloop_tasks(struct engine *e) {
continue
;
/* Construct the pair task */
const
int
sid
=
sortlistID
[(
kk
+
1
)
+
3
*
((
jj
+
1
)
+
3
*
(
ii
+
1
))];
scheduler_addtask
(
sched
,
task_type_pair
,
task_subtype_density
,
sid
,
0
,
ci
,
cj
);
}
}
const
int
sid
=
sortlistID
[(
kk
+
1
)
+
3
*
((
jj
+
1
)
+
3
*
(
ii
+
1
))];
scheduler_addtask
(
sched
,
task_type_pair
,
task_subtype_density
,
sid
,
0
,
ci
,
cj
);
}
}
}
...
...
@@ -2170,7 +2176,7 @@ void engine_make_extra_hydroloop_tasks(struct engine *e) {
scheduler_addunlock
(
sched
,
t
->
ci
->
super
->
sorts
,
t
);
#ifdef EXTRA_HYDRO_LOOP
/* Start by constructing the task for the second and third hydro loop */
/* Start by constructing the task for the second and third hydro loop
.
*/
struct
task
*
t2
=
scheduler_addtask
(
sched
,
task_type_self
,
task_subtype_gradient
,
0
,
0
,
t
->
ci
,
NULL
);
struct
task
*
t3
=
scheduler_addtask
(
...
...
@@ -2419,7 +2425,10 @@ void engine_maketasks(struct engine *e) {
scheduler_reset
(
sched
,
s
->
tot_cells
*
engine_maxtaskspercell
);
/* Construct the firt hydro loop over neighbours */
if
(
e
->
policy
&
engine_policy_hydro
)
engine_make_hydroloop_tasks
(
e
);
if
(
e
->
policy
&
engine_policy_hydro
)
{
threadpool_map
(
&
e
->
threadpool
,
engine_make_hydroloop_tasks_mapper
,
NULL
,
s
->
nr_cells
,
1
,
0
,
e
);
}
/* Add the self gravity tasks. */
if
(
e
->
policy
&
engine_policy_self_gravity
)
engine_make_self_gravity_tasks
(
e
);
...
...
@@ -2636,8 +2645,8 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
scheduler_activate
(
s
,
l
->
t
);
/* Drift the cell which will be sent at the level at which it is
sent,
i.e. drift the cell specified in the send task (l->t)
itself. */
sent,
i.e. drift the cell specified in the send task (l->t)
itself. */
cell_activate_drift_part
(
l
->
t
->
ci
,
s
);
if
(
cell_is_active
(
cj
,
e
))
{
...
...
@@ -2694,8 +2703,8 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
scheduler_activate
(
s
,
l
->
t
);
/* Drift the cell which will be sent at the level at which it is
sent,
i.e. drift the cell specified in the send task (l->t)
itself. */
sent,
i.e. drift the cell specified in the send task (l->t)
itself. */
cell_activate_drift_part
(
l
->
t
->
ci
,
s
);
if
(
cell_is_active
(
ci
,
e
))
{
...
...
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