diff --git a/src/engine.c b/src/engine.c index ee48d6565dc62f725b0159dc44e8d9d92d7a4adf..6bd2fb5ade526e4ff7fd363fa655fd096afcd827 100644 --- a/src/engine.c +++ b/src/engine.c @@ -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), 10000, 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), 10, 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), 10, 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), diff --git a/src/engine.h b/src/engine.h index c7aaa08b57eb2e61b311deae7a7ccb102f7e3cf8..79ff45a69a39ee7d4d45589df51ce2d53f810fda 100644 --- a/src/engine.h +++ b/src/engine.h @@ -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 10 +#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" diff --git a/src/gravity.c b/src/gravity.c index 97b2955b32e1513c3d86d1d1f4da2169130feb77..49bbaca39b5278009543204a0d9f5e72d69806c4 100644 --- a/src/gravity.c +++ b/src/gravity.c @@ -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), 1000, &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), diff --git a/src/queue.h b/src/queue.h index 951a3e5a056d7ad0c3935f98341a0d93c805e3ad..c85cf0cabe30a03d163e2564fdc216c19495761a 100644 --- a/src/queue.h +++ b/src/queue.h @@ -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 10240 #define queue_struct_align 64 /* Counters. */ diff --git a/src/scheduler.c b/src/scheduler.c index 161be418046636c473362f061d4afa1c64ace04a..6b60419cd579e3dbec28fc8d9345adf376ac85d5 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -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), 1000, 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), 1000, 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), 1000, s); + s->active_count, sizeof(int), 0, s); } else { scheduler_enqueue_mapper(s->tid_active, s->active_count, s); } diff --git a/src/space.c b/src/space.c index 23902a37501c7b13992f5423a3f002d526ba2c27..8ad571be3800fbeebd280dfd09b9ee29158bfdf8 100644 --- a/src/space.c +++ b/src/space.c @@ -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), 100, 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), 100, 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), 1000, &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), 1000, &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), 1000, &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), 1000, (void *)s); + s->nr_gparts, sizeof(struct gpart), 0, (void *)s); } /** diff --git a/src/statistics.c b/src/statistics.c index 57d60bcb1b247c9616c859b7ac8a475acdcd878f..5a3f1ff4f9a2232a14817e7e55fd2cff5bdcd80e 100644 --- a/src/statistics.c +++ b/src/statistics.c @@ -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), 10000, &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), 10000, &extra_data); + s->nr_gparts, sizeof(struct gpart), 0, &extra_data); } /** diff --git a/src/swift.h b/src/swift.h index 20397eb24df478cba65a0e35d686b402f1d8ee70..1d1a7c7d04b3662c524504c292aa7d9eee2c3d09 100644 --- a/src/swift.h +++ b/src/swift.h @@ -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" diff --git a/tests/testThreadpool.c b/tests/testThreadpool.c index aa65d533a29afbe4e7e8384fb887281822a31e58..0fe212d5ca2db733ec9db2fa61bb58cb40516378 100644 --- a/tests/testThreadpool.c +++ b/tests/testThreadpool.c @@ -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);