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
a84a7a88
Commit
a84a7a88
authored
9 years ago
by
Pedro Gonnet
Browse files
Options
Downloads
Patches
Plain Diff
made engine_count_and_link_tasks parallel with the threadpool.
parent
00c70a1d
No related branches found
No related tags found
1 merge request
!176
Tasks cleanup
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/engine.c
+52
-53
52 additions, 53 deletions
src/engine.c
with
52 additions
and
53 deletions
src/engine.c
+
52
−
53
View file @
a84a7a88
...
...
@@ -1152,65 +1152,62 @@ void engine_make_hydroloop_tasks(struct engine *e) {
*
* @param e The #engine.
*/
void
engine_count_and_link_tasks
(
struct
engine
*
e
)
{
void
engine_count_and_link_tasks
_mapper
(
void
*
map_data
,
void
*
extra_data
)
{
struct
engine
*
e
=
(
struct
engine
*
)
extra_data
;
struct
task
*
t
=
(
struct
task
*
)
map_data
;
struct
scheduler
*
sched
=
&
e
->
sched
;
const
int
nr_tasks
=
sched
->
nr_tasks
;
for
(
int
k
=
0
;
k
<
nr_tasks
;
k
++
)
{
/* Get the current task. */
struct
task
*
t
=
&
sched
->
tasks
[
k
];
if
(
t
->
skip
)
continue
;
/* Link sort tasks together. */
if
(
t
->
type
==
task_type_sort
&&
t
->
ci
->
split
)
for
(
int
j
=
0
;
j
<
8
;
j
++
)
if
(
t
->
ci
->
progeny
[
j
]
!=
NULL
&&
t
->
ci
->
progeny
[
j
]
->
sorts
!=
NULL
)
{
t
->
ci
->
progeny
[
j
]
->
sorts
->
skip
=
0
;
scheduler_addunlock
(
sched
,
t
->
ci
->
progeny
[
j
]
->
sorts
,
t
);
}
if
(
t
->
skip
)
return
;
/* Link
density
tasks to
cells
. */
if
(
t
->
type
==
task_type_s
elf
)
{
atomic_inc
(
&
t
->
ci
->
nr_tasks
);
if
(
t
->
subtype
==
task_subtype_density
)
{
t
->
ci
->
density
=
engine_addlink
(
e
,
t
->
ci
->
density
,
t
)
;
atomic_inc
(
&
t
->
ci
->
nr_density
);
/* Link
sort
tasks to
gether
. */
if
(
t
->
type
==
task_type_s
ort
&&
t
->
ci
->
split
)
for
(
int
j
=
0
;
j
<
8
;
j
++
)
if
(
t
->
ci
->
progeny
[
j
]
!=
NULL
&&
t
->
ci
->
progeny
[
j
]
->
sorts
!=
NULL
)
{
t
->
ci
->
progeny
[
j
]
->
sorts
->
skip
=
0
;
scheduler_addunlock
(
sched
,
t
->
ci
->
progeny
[
j
]
->
sorts
,
t
);
}
}
else
if
(
t
->
type
==
task_type_pair
)
{
atomic_inc
(
&
t
->
ci
->
nr_tasks
);
atomic_inc
(
&
t
->
cj
->
nr_tasks
);
if
(
t
->
subtype
==
task_subtype_density
)
{
t
->
ci
->
density
=
engine_addlink
(
e
,
t
->
ci
->
density
,
t
);
atomic_inc
(
&
t
->
ci
->
nr_density
);
/* Link density tasks to cells. */
/* TODO(pedro): Instead of locking the cell, re-write engine_addlink to
directly modify the second argument using the __atomic_exchange_n
intrinsic. */
if
(
t
->
type
==
task_type_self
)
{
atomic_inc
(
&
t
->
ci
->
nr_tasks
);
if
(
t
->
subtype
==
task_subtype_density
)
{
lock_lock
(
&
t
->
ci
->
lock
);
t
->
ci
->
density
=
engine_addlink
(
e
,
t
->
ci
->
density
,
t
);
atomic_inc
(
&
t
->
ci
->
nr_density
);
lock_unlock_blind
(
&
t
->
ci
->
lock
);
}
}
else
if
(
t
->
type
==
task_type_pair
)
{
atomic_inc
(
&
t
->
ci
->
nr_tasks
);
atomic_inc
(
&
t
->
cj
->
nr_tasks
);
if
(
t
->
subtype
==
task_subtype_density
)
{
lock_lock
(
&
t
->
ci
->
lock
);
t
->
ci
->
density
=
engine_addlink
(
e
,
t
->
ci
->
density
,
t
);
atomic_inc
(
&
t
->
ci
->
nr_density
);
lock_unlock_blind
(
&
t
->
ci
->
lock
);
lock_lock
(
&
t
->
cj
->
lock
);
t
->
cj
->
density
=
engine_addlink
(
e
,
t
->
cj
->
density
,
t
);
atomic_inc
(
&
t
->
cj
->
nr_density
);
lock_unlock_blind
(
&
t
->
cj
->
lock
);
}
}
else
if
(
t
->
type
==
task_type_sub
)
{
atomic_inc
(
&
t
->
ci
->
nr_tasks
);
if
(
t
->
cj
!=
NULL
)
atomic_inc
(
&
t
->
cj
->
nr_tasks
);
if
(
t
->
subtype
==
task_subtype_density
)
{
lock_lock
(
&
t
->
ci
->
lock
);
t
->
ci
->
density
=
engine_addlink
(
e
,
t
->
ci
->
density
,
t
);
atomic_inc
(
&
t
->
ci
->
nr_density
);
lock_unlock_blind
(
&
t
->
ci
->
lock
);
if
(
t
->
cj
!=
NULL
)
{
lock_lock
(
&
t
->
cj
->
lock
);
t
->
cj
->
density
=
engine_addlink
(
e
,
t
->
cj
->
density
,
t
);
atomic_inc
(
&
t
->
cj
->
nr_density
);
}
}
else
if
(
t
->
type
==
task_type_sub
)
{
atomic_inc
(
&
t
->
ci
->
nr_tasks
);
if
(
t
->
cj
!=
NULL
)
atomic_inc
(
&
t
->
cj
->
nr_tasks
);
if
(
t
->
subtype
==
task_subtype_density
)
{
t
->
ci
->
density
=
engine_addlink
(
e
,
t
->
ci
->
density
,
t
);
atomic_inc
(
&
t
->
ci
->
nr_density
);
if
(
t
->
cj
!=
NULL
)
{
t
->
cj
->
density
=
engine_addlink
(
e
,
t
->
cj
->
density
,
t
);
atomic_inc
(
&
t
->
cj
->
nr_density
);
}
lock_unlock_blind
(
&
t
->
cj
->
lock
);
}
}
/* /\* Link gravity multipole tasks to the up/down tasks. *\/ */
/* if (t->type == task_type_grav_mm || */
/* (t->type == task_type_sub && t->subtype == task_subtype_grav)) { */
/* atomic_inc(&t->ci->nr_tasks); */
/* scheduler_addunlock(sched, t->ci->grav_up, t); */
/* scheduler_addunlock(sched, t, t->ci->grav_down); */
/* if (t->cj != NULL && t->ci->grav_up != t->cj->grav_up) { */
/* scheduler_addunlock(sched, t->cj->grav_up, t); */
/* scheduler_addunlock(sched, t, t->cj->grav_down); */
/* } */
/* } */
}
}
...
...
@@ -1249,7 +1246,8 @@ static inline void engine_make_hydro_loops_dependencies(struct scheduler *sched,
*
* @param e The #engine.
*/
void
engine_make_extra_hydroloop_tasks_mapper
(
void
*
map_data
,
void
*
extra_data
)
{
void
engine_make_extra_hydroloop_tasks_mapper
(
void
*
map_data
,
void
*
extra_data
)
{
struct
engine
*
e
=
(
struct
engine
*
)
extra_data
;
struct
scheduler
*
sched
=
&
e
->
sched
;
...
...
@@ -1446,7 +1444,8 @@ void engine_maketasks(struct engine *e) {
/* Count the number of tasks associated with each cell and
store the density tasks in each cell, and make each sort
depend on the sorts of its progeny. */
engine_count_and_link_tasks
(
e
);
threadpool_map
(
&
e
->
threadpool
,
engine_count_and_link_tasks_mapper
,
sched
->
tasks
,
sched
->
nr_tasks
,
sizeof
(
struct
task
),
e
);
/* Append hierarchical tasks to each cells */
for
(
int
k
=
0
;
k
<
nr_cells
;
k
++
)
...
...
@@ -1456,7 +1455,7 @@ void engine_maketasks(struct engine *e) {
Each force task depends on the cell ghosts and unlocks the kick task
of its super-cell. */
threadpool_map
(
&
e
->
threadpool
,
engine_make_extra_hydroloop_tasks_mapper
,
sched
->
tasks
,
sched
->
nr_tasks
,
sizeof
(
struct
task
),
e
);
sched
->
tasks
,
sched
->
nr_tasks
,
sizeof
(
struct
task
),
e
);
// engine_make_extra_hydroloop_tasks(e);
/* Add the communication tasks if MPI is being used. */
...
...
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