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
d439130a
Commit
d439130a
authored
Jul 31, 2017
by
Peter W. Draper
Browse files
Recover more missed updates from original threadpool_task_plots
parent
c8d31089
Changes
9
Hide whitespace changes
Inline
Side-by-side
src/engine.c
View file @
d439130a
...
...
@@ -2402,21 +2402,6 @@ void engine_make_gravityrecursive_tasks(struct engine *e) {
/* } */
}
void
engine_check_sort_tasks
(
struct
engine
*
e
,
struct
cell
*
c
)
{
/* Find the parent sort task, if any, and copy its flags. */
if
(
c
->
sorts
!=
NULL
)
{
struct
cell
*
parent
=
c
->
parent
;
while
(
parent
!=
NULL
&&
parent
->
sorts
==
NULL
)
parent
=
parent
->
parent
;
if
(
parent
!=
NULL
)
c
->
sorts
->
flags
|=
parent
->
sorts
->
flags
;
}
/* Recurse? */
if
(
c
->
split
)
for
(
int
k
=
0
;
k
<
8
;
k
++
)
if
(
c
->
progeny
[
k
]
!=
NULL
)
engine_check_sort_tasks
(
e
,
c
->
progeny
[
k
]);
}
/**
* @brief Fill the #space's task list.
*
...
...
@@ -2495,9 +2480,6 @@ void engine_maketasks(struct engine *e) {
for
(
int
k
=
0
;
k
<
nr_cells
;
k
++
)
engine_make_hierarchical_tasks
(
e
,
&
cells
[
k
]);
/* Append hierarchical tasks to each cell. */
for
(
int
k
=
0
;
k
<
nr_cells
;
k
++
)
engine_check_sort_tasks
(
e
,
&
cells
[
k
]);
/* 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
of its super-cell. */
...
...
@@ -2792,7 +2774,7 @@ int engine_marktasks(struct engine *e) {
/* Run through the tasks and mark as skip or not. */
size_t
extra_data
[
3
]
=
{(
size_t
)
e
,
rebuild_space
,
(
size_t
)
&
e
->
sched
};
threadpool_map
(
&
e
->
threadpool
,
engine_marktasks_mapper
,
s
->
tasks
,
s
->
nr_tasks
,
sizeof
(
struct
task
),
1000
0
,
extra_data
);
sizeof
(
struct
task
),
0
,
extra_data
);
rebuild_space
=
extra_data
[
1
];
if
(
e
->
verbose
)
...
...
@@ -3696,7 +3678,7 @@ void engine_drift_all(struct engine *e) {
#endif
threadpool_map
(
&
e
->
threadpool
,
engine_do_drift_all_mapper
,
e
->
s
->
cells_top
,
e
->
s
->
nr_cells
,
sizeof
(
struct
cell
),
1
,
e
);
e
->
s
->
nr_cells
,
sizeof
(
struct
cell
),
0
,
e
);
/* Synchronize particle positions */
space_synchronize_particle_positions
(
e
->
s
);
...
...
@@ -3748,7 +3730,7 @@ void engine_drift_top_multipoles(struct engine *e) {
const
ticks
tic
=
getticks
();
threadpool_map
(
&
e
->
threadpool
,
engine_do_drift_top_multipoles_mapper
,
e
->
s
->
cells_top
,
e
->
s
->
nr_cells
,
sizeof
(
struct
cell
),
1
0
,
e
);
e
->
s
->
cells_top
,
e
->
s
->
nr_cells
,
sizeof
(
struct
cell
),
0
,
e
);
#ifdef SWIFT_DEBUG_CHECKS
/* Check that all cells have been drifted to the current time. */
...
...
@@ -3786,7 +3768,7 @@ void engine_reconstruct_multipoles(struct engine *e) {
const
ticks
tic
=
getticks
();
threadpool_map
(
&
e
->
threadpool
,
engine_do_reconstruct_multipoles_mapper
,
e
->
s
->
cells_top
,
e
->
s
->
nr_cells
,
sizeof
(
struct
cell
),
1
0
,
e
);
e
->
s
->
cells_top
,
e
->
s
->
nr_cells
,
sizeof
(
struct
cell
),
0
,
e
);
if
(
e
->
verbose
)
message
(
"took %.3f %s."
,
clocks_from_ticks
(
getticks
()
-
tic
),
...
...
src/engine.h
View file @
d439130a
...
...
@@ -77,7 +77,7 @@ extern const char *engine_policy_names[];
#define engine_queue_scale 1.2
#define engine_maxtaskspercell 96
#define engine_maxproxies 64
#define engine_tasksreweight 1
0
#define engine_tasksreweight 1
#define engine_parts_size_grow 1.05
#define engine_redistribute_alloc_margin 1.2
#define engine_default_energy_file_name "energy"
...
...
src/gravity.c
View file @
d439130a
...
...
@@ -207,7 +207,7 @@ void gravity_exact_force_compute(struct space *s, const struct engine *e) {
data
.
const_G
=
e
->
physical_constants
->
const_newton_G
;
threadpool_map
(
&
s
->
e
->
threadpool
,
gravity_exact_force_compute_mapper
,
s
->
gparts
,
s
->
nr_gparts
,
sizeof
(
struct
gpart
),
100
0
,
&
data
);
s
->
gparts
,
s
->
nr_gparts
,
sizeof
(
struct
gpart
),
0
,
&
data
);
message
(
"Computed exact gravity for %d gparts (took %.3f %s). "
,
data
.
counter_global
,
clocks_from_ticks
(
getticks
()
-
tic
),
...
...
src/queue.h
View file @
d439130a
...
...
@@ -29,7 +29,7 @@
#define queue_sizeinit 100
#define queue_sizegrow 2
#define queue_search_window 8
#define queue_incoming_size 1024
#define queue_incoming_size 1024
0
#define queue_struct_align 64
/* Counters. */
...
...
src/scheduler.c
View file @
d439130a
...
...
@@ -759,7 +759,7 @@ void scheduler_splittasks(struct scheduler *s) {
/* Call the mapper on each current task. */
threadpool_map
(
s
->
threadpool
,
scheduler_splittasks_mapper
,
s
->
tasks
,
s
->
nr_tasks
,
sizeof
(
struct
task
),
100
0
,
s
);
s
->
nr_tasks
,
sizeof
(
struct
task
),
0
,
s
);
}
/**
...
...
@@ -1174,7 +1174,7 @@ void scheduler_start(struct scheduler *s) {
/* Re-wait the tasks. */
if
(
s
->
active_count
>
1000
)
{
threadpool_map
(
s
->
threadpool
,
scheduler_rewait_mapper
,
s
->
tid_active
,
s
->
active_count
,
sizeof
(
int
),
100
0
,
s
);
s
->
active_count
,
sizeof
(
int
),
0
,
s
);
}
else
{
scheduler_rewait_mapper
(
s
->
tid_active
,
s
->
active_count
,
s
);
}
...
...
@@ -1250,7 +1250,7 @@ void scheduler_start(struct scheduler *s) {
/* Loop over the tasks and enqueue whoever is ready. */
if
(
s
->
active_count
>
1000
)
{
threadpool_map
(
s
->
threadpool
,
scheduler_enqueue_mapper
,
s
->
tid_active
,
s
->
active_count
,
sizeof
(
int
),
100
0
,
s
);
s
->
active_count
,
sizeof
(
int
),
0
,
s
);
}
else
{
scheduler_enqueue_mapper
(
s
->
tid_active
,
s
->
active_count
,
s
);
}
...
...
src/space.c
View file @
d439130a
...
...
@@ -378,7 +378,7 @@ void space_regrid(struct space *s, int verbose) {
/* Free the old cells, if they were allocated. */
if
(
s
->
cells_top
!=
NULL
)
{
threadpool_map
(
&
s
->
e
->
threadpool
,
space_rebuild_recycle_mapper
,
s
->
cells_top
,
s
->
nr_cells
,
sizeof
(
struct
cell
),
10
0
,
s
);
s
->
cells_top
,
s
->
nr_cells
,
sizeof
(
struct
cell
),
0
,
s
);
free
(
s
->
cells_top
);
free
(
s
->
multipoles_top
);
s
->
maxdepth
=
0
;
...
...
@@ -491,7 +491,7 @@ void space_regrid(struct space *s, int verbose) {
/* Free the old cells, if they were allocated. */
threadpool_map
(
&
s
->
e
->
threadpool
,
space_rebuild_recycle_mapper
,
s
->
cells_top
,
s
->
nr_cells
,
sizeof
(
struct
cell
),
10
0
,
s
);
s
->
cells_top
,
s
->
nr_cells
,
sizeof
(
struct
cell
),
0
,
s
);
s
->
maxdepth
=
0
;
}
...
...
@@ -970,7 +970,7 @@ void space_split(struct space *s, struct cell *cells, int nr_cells,
const
ticks
tic
=
getticks
();
threadpool_map
(
&
s
->
e
->
threadpool
,
space_split_mapper
,
cells
,
nr_cells
,
sizeof
(
struct
cell
),
1
,
s
);
sizeof
(
struct
cell
),
0
,
s
);
if
(
verbose
)
message
(
"took %.3f %s."
,
clocks_from_ticks
(
getticks
()
-
tic
),
...
...
@@ -1004,7 +1004,7 @@ void space_sanitize(struct space *s) {
if
(
s
->
e
->
nodeID
==
0
)
message
(
"Cleaning up unreasonable values of h"
);
threadpool_map
(
&
s
->
e
->
threadpool
,
space_sanitize_mapper
,
s
->
cells_top
,
s
->
nr_cells
,
sizeof
(
struct
cell
),
1
,
NULL
);
s
->
nr_cells
,
sizeof
(
struct
cell
),
0
,
NULL
);
}
/**
...
...
@@ -1187,7 +1187,7 @@ void space_parts_get_cell_index(struct space *s, int *ind, struct cell *cells,
data
.
ind
=
ind
;
threadpool_map
(
&
s
->
e
->
threadpool
,
space_parts_get_cell_index_mapper
,
s
->
parts
,
s
->
nr_parts
,
sizeof
(
struct
part
),
100
0
,
&
data
);
s
->
nr_parts
,
sizeof
(
struct
part
),
0
,
&
data
);
if
(
verbose
)
message
(
"took %.3f %s."
,
clocks_from_ticks
(
getticks
()
-
tic
),
...
...
@@ -1214,7 +1214,7 @@ void space_gparts_get_cell_index(struct space *s, int *gind, struct cell *cells,
data
.
ind
=
gind
;
threadpool_map
(
&
s
->
e
->
threadpool
,
space_gparts_get_cell_index_mapper
,
s
->
gparts
,
s
->
nr_gparts
,
sizeof
(
struct
gpart
),
100
0
,
&
data
);
s
->
gparts
,
s
->
nr_gparts
,
sizeof
(
struct
gpart
),
0
,
&
data
);
if
(
verbose
)
message
(
"took %.3f %s."
,
clocks_from_ticks
(
getticks
()
-
tic
),
...
...
@@ -1241,7 +1241,7 @@ void space_sparts_get_cell_index(struct space *s, int *sind, struct cell *cells,
data
.
ind
=
sind
;
threadpool_map
(
&
s
->
e
->
threadpool
,
space_sparts_get_cell_index_mapper
,
s
->
sparts
,
s
->
nr_sparts
,
sizeof
(
struct
spart
),
100
0
,
&
data
);
s
->
sparts
,
s
->
nr_sparts
,
sizeof
(
struct
spart
),
0
,
&
data
);
if
(
verbose
)
message
(
"took %.3f %s."
,
clocks_from_ticks
(
getticks
()
-
tic
),
...
...
@@ -2501,7 +2501,7 @@ void space_synchronize_particle_positions(struct space *s) {
(
s
->
nr_gparts
>
0
&&
s
->
nr_sparts
>
0
))
threadpool_map
(
&
s
->
e
->
threadpool
,
space_synchronize_particle_positions_mapper
,
s
->
gparts
,
s
->
nr_gparts
,
sizeof
(
struct
gpart
),
100
0
,
(
void
*
)
s
);
s
->
nr_gparts
,
sizeof
(
struct
gpart
),
0
,
(
void
*
)
s
);
}
/**
...
...
src/statistics.c
View file @
d439130a
...
...
@@ -271,12 +271,12 @@ void stats_collect(const struct space *s, struct statistics *stats) {
/* Run parallel collection of statistics for parts */
if
(
s
->
nr_parts
>
0
)
threadpool_map
(
&
s
->
e
->
threadpool
,
stats_collect_part_mapper
,
s
->
parts
,
s
->
nr_parts
,
sizeof
(
struct
part
),
1000
0
,
&
extra_data
);
s
->
nr_parts
,
sizeof
(
struct
part
),
0
,
&
extra_data
);
/* Run parallel collection of statistics for gparts */
if
(
s
->
nr_gparts
>
0
)
threadpool_map
(
&
s
->
e
->
threadpool
,
stats_collect_gpart_mapper
,
s
->
gparts
,
s
->
nr_gparts
,
sizeof
(
struct
gpart
),
1000
0
,
&
extra_data
);
s
->
nr_gparts
,
sizeof
(
struct
gpart
),
0
,
&
extra_data
);
}
/**
...
...
src/swift.h
View file @
d439130a
...
...
@@ -57,6 +57,7 @@
#include
"sourceterms.h"
#include
"space.h"
#include
"task.h"
#include
"threadpool.h"
#include
"timeline.h"
#include
"timers.h"
#include
"tools.h"
...
...
tests/testThreadpool.c
View file @
d439130a
...
...
@@ -17,6 +17,8 @@
*
******************************************************************************/
include
"../config.h"
// Standard includes.
#include
<stdio.h>
#include
<stdlib.h>
...
...
@@ -78,6 +80,11 @@ int main(int argc, char *argv[]) {
threadpool_map
(
&
tp
,
map_function_first
,
data
,
N
,
sizeof
(
int
),
2
,
NULL
);
}
/* If logging was enabled, dump the log. */
#ifdef SWIFT_DEBUG_THREADPOOL
threadpool_dump_log
(
&
tp
,
"threadpool_log.txt"
,
1
);
#endif
/* Be clean */
threadpool_clean
(
&
tp
);
...
...
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