diff --git a/src/common_io.c b/src/common_io.c index 10d92b7220862cfad7a688d0912549aec1338ab8..458fe8229321f9fbd40b1b2c5a5bc70ebfe3417f 100644 --- a/src/common_io.c +++ b/src/common_io.c @@ -1593,8 +1593,8 @@ void io_copy_temp_buffer(void* temp, const struct engine* e, /* Copy the whole thing into a buffer */ threadpool_map((struct threadpool*)&e->threadpool, - io_convert_part_f_mapper, temp_f, N, copySize, threadpool_auto_chunk_size, - (void*)&props); + io_convert_part_f_mapper, temp_f, N, copySize, + threadpool_auto_chunk_size, (void*)&props); } else if (props.convert_part_i != NULL) { @@ -1605,8 +1605,8 @@ void io_copy_temp_buffer(void* temp, const struct engine* e, /* Copy the whole thing into a buffer */ threadpool_map((struct threadpool*)&e->threadpool, - io_convert_part_i_mapper, temp_i, N, copySize, threadpool_auto_chunk_size, - (void*)&props); + io_convert_part_i_mapper, temp_i, N, copySize, + threadpool_auto_chunk_size, (void*)&props); } else if (props.convert_part_d != NULL) { @@ -1617,8 +1617,8 @@ void io_copy_temp_buffer(void* temp, const struct engine* e, /* Copy the whole thing into a buffer */ threadpool_map((struct threadpool*)&e->threadpool, - io_convert_part_d_mapper, temp_d, N, copySize, threadpool_auto_chunk_size, - (void*)&props); + io_convert_part_d_mapper, temp_d, N, copySize, + threadpool_auto_chunk_size, (void*)&props); } else if (props.convert_part_l != NULL) { @@ -1629,8 +1629,8 @@ void io_copy_temp_buffer(void* temp, const struct engine* e, /* Copy the whole thing into a buffer */ threadpool_map((struct threadpool*)&e->threadpool, - io_convert_part_l_mapper, temp_l, N, copySize, threadpool_auto_chunk_size, - (void*)&props); + io_convert_part_l_mapper, temp_l, N, copySize, + threadpool_auto_chunk_size, (void*)&props); } else if (props.convert_gpart_f != NULL) { @@ -1641,8 +1641,8 @@ void io_copy_temp_buffer(void* temp, const struct engine* e, /* Copy the whole thing into a buffer */ threadpool_map((struct threadpool*)&e->threadpool, - io_convert_gpart_f_mapper, temp_f, N, copySize, threadpool_auto_chunk_size, - (void*)&props); + io_convert_gpart_f_mapper, temp_f, N, copySize, + threadpool_auto_chunk_size, (void*)&props); } else if (props.convert_gpart_i != NULL) { @@ -1653,8 +1653,8 @@ void io_copy_temp_buffer(void* temp, const struct engine* e, /* Copy the whole thing into a buffer */ threadpool_map((struct threadpool*)&e->threadpool, - io_convert_gpart_i_mapper, temp_i, N, copySize, threadpool_auto_chunk_size, - (void*)&props); + io_convert_gpart_i_mapper, temp_i, N, copySize, + threadpool_auto_chunk_size, (void*)&props); } else if (props.convert_gpart_d != NULL) { @@ -1665,8 +1665,8 @@ void io_copy_temp_buffer(void* temp, const struct engine* e, /* Copy the whole thing into a buffer */ threadpool_map((struct threadpool*)&e->threadpool, - io_convert_gpart_d_mapper, temp_d, N, copySize, threadpool_auto_chunk_size, - (void*)&props); + io_convert_gpart_d_mapper, temp_d, N, copySize, + threadpool_auto_chunk_size, (void*)&props); } else if (props.convert_gpart_l != NULL) { @@ -1677,8 +1677,8 @@ void io_copy_temp_buffer(void* temp, const struct engine* e, /* Copy the whole thing into a buffer */ threadpool_map((struct threadpool*)&e->threadpool, - io_convert_gpart_l_mapper, temp_l, N, copySize, threadpool_auto_chunk_size, - (void*)&props); + io_convert_gpart_l_mapper, temp_l, N, copySize, + threadpool_auto_chunk_size, (void*)&props); } else if (props.convert_spart_f != NULL) { @@ -1689,8 +1689,8 @@ void io_copy_temp_buffer(void* temp, const struct engine* e, /* Copy the whole thing into a buffer */ threadpool_map((struct threadpool*)&e->threadpool, - io_convert_spart_f_mapper, temp_f, N, copySize, threadpool_auto_chunk_size, - (void*)&props); + io_convert_spart_f_mapper, temp_f, N, copySize, + threadpool_auto_chunk_size, (void*)&props); } else if (props.convert_spart_i != NULL) { @@ -1701,8 +1701,8 @@ void io_copy_temp_buffer(void* temp, const struct engine* e, /* Copy the whole thing into a buffer */ threadpool_map((struct threadpool*)&e->threadpool, - io_convert_spart_i_mapper, temp_i, N, copySize, threadpool_auto_chunk_size, - (void*)&props); + io_convert_spart_i_mapper, temp_i, N, copySize, + threadpool_auto_chunk_size, (void*)&props); } else if (props.convert_spart_d != NULL) { @@ -1713,8 +1713,8 @@ void io_copy_temp_buffer(void* temp, const struct engine* e, /* Copy the whole thing into a buffer */ threadpool_map((struct threadpool*)&e->threadpool, - io_convert_spart_d_mapper, temp_d, N, copySize, threadpool_auto_chunk_size, - (void*)&props); + io_convert_spart_d_mapper, temp_d, N, copySize, + threadpool_auto_chunk_size, (void*)&props); } else if (props.convert_spart_l != NULL) { @@ -1725,8 +1725,8 @@ void io_copy_temp_buffer(void* temp, const struct engine* e, /* Copy the whole thing into a buffer */ threadpool_map((struct threadpool*)&e->threadpool, - io_convert_spart_l_mapper, temp_l, N, copySize, threadpool_auto_chunk_size, - (void*)&props); + io_convert_spart_l_mapper, temp_l, N, copySize, + threadpool_auto_chunk_size, (void*)&props); } else if (props.convert_bpart_f != NULL) { @@ -1737,8 +1737,8 @@ void io_copy_temp_buffer(void* temp, const struct engine* e, /* Copy the whole thing into a buffer */ threadpool_map((struct threadpool*)&e->threadpool, - io_convert_bpart_f_mapper, temp_f, N, copySize, threadpool_auto_chunk_size, - (void*)&props); + io_convert_bpart_f_mapper, temp_f, N, copySize, + threadpool_auto_chunk_size, (void*)&props); } else if (props.convert_bpart_i != NULL) { @@ -1749,8 +1749,8 @@ void io_copy_temp_buffer(void* temp, const struct engine* e, /* Copy the whole thing into a buffer */ threadpool_map((struct threadpool*)&e->threadpool, - io_convert_bpart_i_mapper, temp_i, N, copySize, threadpool_auto_chunk_size, - (void*)&props); + io_convert_bpart_i_mapper, temp_i, N, copySize, + threadpool_auto_chunk_size, (void*)&props); } else if (props.convert_bpart_d != NULL) { @@ -1761,8 +1761,8 @@ void io_copy_temp_buffer(void* temp, const struct engine* e, /* Copy the whole thing into a buffer */ threadpool_map((struct threadpool*)&e->threadpool, - io_convert_bpart_d_mapper, temp_d, N, copySize, threadpool_auto_chunk_size, - (void*)&props); + io_convert_bpart_d_mapper, temp_d, N, copySize, + threadpool_auto_chunk_size, (void*)&props); } else if (props.convert_bpart_l != NULL) { @@ -1773,8 +1773,8 @@ void io_copy_temp_buffer(void* temp, const struct engine* e, /* Copy the whole thing into a buffer */ threadpool_map((struct threadpool*)&e->threadpool, - io_convert_bpart_l_mapper, temp_l, N, copySize, threadpool_auto_chunk_size, - (void*)&props); + io_convert_bpart_l_mapper, temp_l, N, copySize, + threadpool_auto_chunk_size, (void*)&props); } else { error("Missing conversion function"); @@ -2068,7 +2068,8 @@ void io_duplicate_black_holes_gparts(struct threadpool* tp, data.Ndm = Ndm; threadpool_map(tp, io_duplicate_black_holes_gparts_mapper, bparts, - Nblackholes, sizeof(struct bpart), threadpool_auto_chunk_size, &data); + Nblackholes, sizeof(struct bpart), threadpool_auto_chunk_size, + &data); } /** diff --git a/src/engine.c b/src/engine.c index 38eecfd334c1a0e2b279dfd2f851268cf204057b..4261a78cf09978278ecd80ed562f043439f61a04 100644 --- a/src/engine.c +++ b/src/engine.c @@ -2716,7 +2716,8 @@ void engine_reconstruct_multipoles(struct engine *e) { #endif threadpool_map(&e->threadpool, engine_do_reconstruct_multipoles_mapper, - e->s->cells_top, e->s->nr_cells, sizeof(struct cell), threadpool_auto_chunk_size, e); + e->s->cells_top, e->s->nr_cells, sizeof(struct cell), + threadpool_auto_chunk_size, e); if (e->verbose) message("took %.3f %s.", clocks_from_ticks(getticks() - tic), diff --git a/src/engine_collect_end_of_step.c b/src/engine_collect_end_of_step.c index f6537b4c38db85c2182659f1b06774095d1387e0..0973399c11146baef3b3be60b3635426021b23cb 100644 --- a/src/engine_collect_end_of_step.c +++ b/src/engine_collect_end_of_step.c @@ -465,7 +465,7 @@ void engine_collect_end_of_step(struct engine *e, int apply) { /* Collect information from the local top-level cells */ threadpool_map(&e->threadpool, engine_collect_end_of_step_mapper, s->local_cells_with_tasks_top, s->nr_local_cells_with_tasks, - sizeof(int), 0, &data); + sizeof(int), threadpool_auto_chunk_size, &data); /* Get the number of inhibited particles from the space-wide counters * since these have been updated atomically during the time-steps. */ diff --git a/src/engine_drift.c b/src/engine_drift.c index fee9ed1f11de2d5e372bd70554bd053b8313ac80..26f8160200c5bdc51f7dab51b56e9a4d771d3d39 100644 --- a/src/engine_drift.c +++ b/src/engine_drift.c @@ -293,28 +293,28 @@ void engine_drift_all(struct engine *e, const int drift_mpoles) { if (e->s->nr_parts > 0) { threadpool_map(&e->threadpool, engine_do_drift_all_part_mapper, e->s->local_cells_top, e->s->nr_local_cells, sizeof(int), - /* default chunk */ 0, e); + threadpool_auto_chunk_size, e); } if (e->s->nr_gparts > 0) { threadpool_map(&e->threadpool, engine_do_drift_all_gpart_mapper, e->s->local_cells_top, e->s->nr_local_cells, sizeof(int), - /* default chunk */ 0, e); + threadpool_auto_chunk_size, e); } if (e->s->nr_sparts > 0) { threadpool_map(&e->threadpool, engine_do_drift_all_spart_mapper, e->s->local_cells_top, e->s->nr_local_cells, sizeof(int), - /* default chunk */ 0, e); + threadpool_auto_chunk_size, e); } if (e->s->nr_bparts > 0) { threadpool_map(&e->threadpool, engine_do_drift_all_bpart_mapper, e->s->local_cells_top, e->s->nr_local_cells, sizeof(int), - /* default chunk */ 0, e); + threadpool_auto_chunk_size, e); } if (drift_mpoles && (e->policy & engine_policy_self_gravity)) { threadpool_map(&e->threadpool, engine_do_drift_all_multipole_mapper, e->s->local_cells_with_tasks_top, e->s->nr_local_cells_with_tasks, sizeof(int), - /* default chunk */ 0, e); + threadpool_auto_chunk_size, e); } } else { @@ -325,27 +325,27 @@ void engine_drift_all(struct engine *e, const int drift_mpoles) { if (e->s->nr_parts > 0) { threadpool_map(&e->threadpool, engine_do_drift_all_part_mapper, e->s->cells_top, e->s->nr_cells, sizeof(struct cell), - /* default chunk */ 0, e); + threadpool_auto_chunk_size, e); } if (e->s->nr_sparts > 0) { threadpool_map(&e->threadpool, engine_do_drift_all_spart_mapper, e->s->cells_top, e->s->nr_cells, sizeof(struct cell), - /* default chunk */ 0, e); + threadpool_auto_chunk_size, e); } if (e->s->nr_bparts > 0) { threadpool_map(&e->threadpool, engine_do_drift_all_bpart_mapper, e->s->cells_top, e->s->nr_cells, sizeof(struct cell), - /* default chunk */ 0, e); + threadpool_auto_chunk_size, e); } if (e->s->nr_gparts > 0) { threadpool_map(&e->threadpool, engine_do_drift_all_gpart_mapper, e->s->cells_top, e->s->nr_cells, sizeof(struct cell), - /* default chunk */ 0, e); + threadpool_auto_chunk_size, e); } if (e->policy & engine_policy_self_gravity) { threadpool_map(&e->threadpool, engine_do_drift_all_multipole_mapper, e->s->cells_top, e->s->nr_cells, sizeof(struct cell), - /* default chunk */ 0, e); + threadpool_auto_chunk_size, e); } } @@ -401,7 +401,8 @@ 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), 0, e); + e->s->cells_top, e->s->nr_cells, sizeof(struct cell), + threadpool_auto_chunk_size, e); #ifdef SWIFT_DEBUG_CHECKS /* Check that all cells have been drifted to the current time. */ diff --git a/src/engine_maketasks.c b/src/engine_maketasks.c index 5d8d3a5fed14330776ccd835664804427d1cb370..9f907f33b4b0173a32292c58e9b1a1fd8bad3312 100644 --- a/src/engine_maketasks.c +++ b/src/engine_maketasks.c @@ -3123,7 +3123,7 @@ void engine_make_fof_tasks(struct engine *e) { /* Construct a FOF loop over neighbours */ if (e->policy & engine_policy_fof) threadpool_map(&e->threadpool, engine_make_fofloop_tasks_mapper, NULL, - s->nr_cells, 1, 0, e); + s->nr_cells, 1, threadpool_auto_chunk_size, e); if (e->verbose) message("Making FOF tasks took %.3f %s.", @@ -3180,7 +3180,7 @@ void engine_maketasks(struct engine *e) { /* Construct the first hydro loop over neighbours */ if (e->policy & engine_policy_hydro) threadpool_map(&e->threadpool, engine_make_hydroloop_tasks_mapper, NULL, - s->nr_cells, 1, 0, e); + s->nr_cells, 1, threadpool_auto_chunk_size, e); if (e->verbose) message("Making hydro tasks took %.3f %s.", @@ -3191,7 +3191,7 @@ void engine_maketasks(struct engine *e) { /* Add the self gravity tasks. */ if (e->policy & engine_policy_self_gravity) { threadpool_map(&e->threadpool, engine_make_self_gravity_tasks_mapper, NULL, - s->nr_cells, 1, 0, e); + s->nr_cells, 1, threadpool_auto_chunk_size, e); } if (e->verbose) @@ -3242,7 +3242,8 @@ void engine_maketasks(struct engine *e) { store the density tasks in each cell, and make each sort depend on the sorts of its progeny. */ threadpool_map(&e->threadpool, engine_count_and_link_tasks_mapper, - sched->tasks, sched->nr_tasks, sizeof(struct task), 0, e); + sched->tasks, sched->nr_tasks, sizeof(struct task), + threadpool_auto_chunk_size, e); if (e->verbose) message("Counting and linking tasks took %.3f %s.", @@ -3259,7 +3260,7 @@ void engine_maketasks(struct engine *e) { /* Now that the self/pair tasks are at the right level, set the super * pointers. */ threadpool_map(&e->threadpool, cell_set_super_mapper, cells, nr_cells, - sizeof(struct cell), 0, e); + sizeof(struct cell), threadpool_auto_chunk_size, e); if (e->verbose) message("Setting super-pointers took %.3f %s.", @@ -3267,7 +3268,7 @@ void engine_maketasks(struct engine *e) { /* Append hierarchical tasks to each cell. */ threadpool_map(&e->threadpool, engine_make_hierarchical_tasks_mapper, cells, - nr_cells, sizeof(struct cell), 0, e); + nr_cells, sizeof(struct cell), threadpool_auto_chunk_size, e); tic2 = getticks(); @@ -3276,7 +3277,8 @@ void engine_maketasks(struct engine *e) { of its super-cell. */ if (e->policy & engine_policy_hydro) threadpool_map(&e->threadpool, engine_make_extra_hydroloop_tasks_mapper, - sched->tasks, sched->nr_tasks, sizeof(struct task), 0, e); + sched->tasks, sched->nr_tasks, sizeof(struct task), + threadpool_auto_chunk_size, e); if (e->verbose) message("Making extra hydroloop tasks took %.3f %s.", @@ -3325,8 +3327,8 @@ void engine_maketasks(struct engine *e) { threadpool_map(&e->threadpool, engine_addtasks_send_mapper, send_cell_type_pairs, num_send_cells, - sizeof(struct cell_type_pair), - /*chunk=*/0, e); + sizeof(struct cell_type_pair), threadpool_auto_chunk_size, + e); free(send_cell_type_pairs); @@ -3366,8 +3368,8 @@ void engine_maketasks(struct engine *e) { } threadpool_map(&e->threadpool, engine_addtasks_recv_mapper, recv_cell_type_pairs, num_recv_cells, - sizeof(struct cell_type_pair), - /*chunk=*/0, e); + sizeof(struct cell_type_pair), threadpool_auto_chunk_size, + e); free(recv_cell_type_pairs); if (e->verbose) diff --git a/src/engine_marktasks.c b/src/engine_marktasks.c index e7da143404849799911d7ae4f20fd8532d04b5b8..d3d17bcdd6dbf09fb6586cd584c7fdfd6ebe21fd 100644 --- a/src/engine_marktasks.c +++ b/src/engine_marktasks.c @@ -1004,7 +1004,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, (size_t)rebuild_space, (size_t)&e->sched}; threadpool_map(&e->threadpool, engine_marktasks_mapper, s->tasks, s->nr_tasks, - sizeof(struct task), 0, extra_data); + sizeof(struct task), threadpool_auto_chunk_size, extra_data); rebuild_space = extra_data[1]; if (e->verbose) diff --git a/src/engine_redistribute.c b/src/engine_redistribute.c index e2c3ea056e57e5097785a9014e4e0d2500d52a52..9e9ce4842a88a65f446f12a74de5039912247516 100644 --- a/src/engine_redistribute.c +++ b/src/engine_redistribute.c @@ -664,7 +664,8 @@ void engine_redistribute(struct engine *e) { redist_data.base = (void *)parts; threadpool_map(&e->threadpool, engine_redistribute_dest_mapper_part, parts, - nr_parts, sizeof(struct part), 0, &redist_data); + nr_parts, sizeof(struct part), threadpool_auto_chunk_size, + &redist_data); /* Sort the particles according to their cell index. */ if (nr_parts > 0) @@ -711,7 +712,8 @@ void engine_redistribute(struct engine *e) { savelink_data.parts = (void *)parts; savelink_data.nodeID = nodeID; threadpool_map(&e->threadpool, engine_redistribute_savelink_mapper_part, - nodes, nr_nodes, sizeof(int), 0, &savelink_data); + nodes, nr_nodes, sizeof(int), threadpool_auto_chunk_size, + &savelink_data); } swift_free("dest", dest); @@ -729,7 +731,8 @@ void engine_redistribute(struct engine *e) { redist_data.base = (void *)sparts; threadpool_map(&e->threadpool, engine_redistribute_dest_mapper_spart, sparts, - nr_sparts, sizeof(struct spart), 0, &redist_data); + nr_sparts, sizeof(struct spart), threadpool_auto_chunk_size, + &redist_data); /* Sort the particles according to their cell index. */ if (nr_sparts > 0) @@ -775,7 +778,8 @@ void engine_redistribute(struct engine *e) { savelink_data.parts = (void *)sparts; savelink_data.nodeID = nodeID; threadpool_map(&e->threadpool, engine_redistribute_savelink_mapper_spart, - nodes, nr_nodes, sizeof(int), 0, &savelink_data); + nodes, nr_nodes, sizeof(int), threadpool_auto_chunk_size, + &savelink_data); } swift_free("s_dest", s_dest); @@ -793,7 +797,8 @@ void engine_redistribute(struct engine *e) { redist_data.base = (void *)bparts; threadpool_map(&e->threadpool, engine_redistribute_dest_mapper_bpart, bparts, - nr_bparts, sizeof(struct bpart), 0, &redist_data); + nr_bparts, sizeof(struct bpart), threadpool_auto_chunk_size, + &redist_data); /* Sort the particles according to their cell index. */ if (nr_bparts > 0) @@ -839,7 +844,8 @@ void engine_redistribute(struct engine *e) { savelink_data.parts = (void *)bparts; savelink_data.nodeID = nodeID; threadpool_map(&e->threadpool, engine_redistribute_savelink_mapper_bpart, - nodes, nr_nodes, sizeof(int), 0, &savelink_data); + nodes, nr_nodes, sizeof(int), threadpool_auto_chunk_size, + &savelink_data); } swift_free("b_dest", b_dest); @@ -857,7 +863,8 @@ void engine_redistribute(struct engine *e) { redist_data.base = (void *)gparts; threadpool_map(&e->threadpool, engine_redistribute_dest_mapper_gpart, gparts, - nr_gparts, sizeof(struct gpart), 0, &redist_data); + nr_gparts, sizeof(struct gpart), threadpool_auto_chunk_size, + &redist_data); /* Sort the gparticles according to their cell index. */ if (nr_gparts > 0) diff --git a/src/engine_unskip.c b/src/engine_unskip.c index 22bc55f34e0bc51711f770d4d7a0d2b2a629f778..9142ff447ac023d0428d466029110233cef37149 100644 --- a/src/engine_unskip.c +++ b/src/engine_unskip.c @@ -383,7 +383,8 @@ void engine_unskip(struct engine *e) { /* Activate all the regular tasks */ threadpool_map(&e->threadpool, engine_do_unskip_mapper, local_active_cells, - num_active_cells * multiplier, sizeof(int), 1, &data); + num_active_cells * multiplier, sizeof(int), /*chunk=*/1, + &data); #ifdef WITH_PROFILER ProfilerStop(); @@ -444,7 +445,8 @@ void engine_unskip_timestep_communications(struct engine *e) { /* Activate all the part and gpart ti_end tasks */ threadpool_map(&e->threadpool, engine_unskip_timestep_communications_mapper, - tasks, nr_tasks, sizeof(struct task), 0, s); + tasks, nr_tasks, sizeof(struct task), + threadpool_auto_chunk_size, s); if (e->verbose) message("took %.3f %s.", clocks_from_ticks(getticks() - tic), diff --git a/src/fof.c b/src/fof.c index 51f35227d4441971e25f46dbc6e57ccfaddb43b7..ff15262bab336f336af47d3cc2e3710b1bee355a 100644 --- a/src/fof.c +++ b/src/fof.c @@ -324,8 +324,8 @@ void fof_allocate(const struct space *s, const long long total_nr_DM_particles, /* Set initial group index */ threadpool_map(&s->e->threadpool, fof_set_initial_group_index_mapper, - props->group_index, s->nr_gparts, sizeof(size_t), 0, - props->group_index); + props->group_index, s->nr_gparts, sizeof(size_t), + threadpool_auto_chunk_size, props->group_index); if (verbose) message("Setting initial group index took: %.3f %s.", @@ -335,7 +335,8 @@ void fof_allocate(const struct space *s, const long long total_nr_DM_particles, /* Set initial group sizes */ threadpool_map(&s->e->threadpool, fof_set_initial_group_size_mapper, - props->group_size, s->nr_gparts, sizeof(size_t), 0, NULL); + props->group_size, s->nr_gparts, sizeof(size_t), + threadpool_auto_chunk_size, NULL); if (verbose) message("Setting initial group sizes took: %.3f %s.", @@ -1759,7 +1760,8 @@ void fof_calc_group_mass(struct fof_props *props, const struct space *s, /* Increment the group mass for groups above min_group_size. */ threadpool_map(&s->e->threadpool, fof_calc_group_mass_mapper, gparts, - nr_gparts, sizeof(struct gpart), 0, (struct space *)s); + nr_gparts, sizeof(struct gpart), threadpool_auto_chunk_size, + (struct space *)s); /* Loop over particles and find the densest particle in each group. */ /* JSW TODO: Parallelise with threadpool*/ @@ -2278,7 +2280,8 @@ void fof_search_foreign_cells(struct fof_props *props, const struct space *s) { data.nr_gparts = nr_gparts; data.space_gparts = s->gparts; threadpool_map(&e->threadpool, fof_set_outgoing_root_mapper, local_cells, - num_cells_out, sizeof(struct cell **), 0, &data); + num_cells_out, sizeof(struct cell **), + threadpool_auto_chunk_size, &data); if (verbose) message( @@ -2636,7 +2639,8 @@ void fof_search_tree(struct fof_props *props, ticks tic_calc_group_size = getticks(); threadpool_map(&s->e->threadpool, fof_calc_group_size_mapper, gparts, - nr_gparts, sizeof(struct gpart), 0, s); + nr_gparts, sizeof(struct gpart), threadpool_auto_chunk_size, + s); if (verbose) message("FOF calc group size took (FOF SCALING): %.3f %s.", clocks_from_ticks(getticks() - tic_calc_group_size), @@ -2778,7 +2782,7 @@ void fof_search_tree(struct fof_props *props, /* Set default group ID for all particles */ threadpool_map(&s->e->threadpool, fof_set_initial_group_id_mapper, s->gparts, - s->nr_gparts, sizeof(struct gpart), 0, + s->nr_gparts, sizeof(struct gpart), threadpool_auto_chunk_size, (void *)&group_id_default); if (verbose) diff --git a/src/gravity.c b/src/gravity.c index 53ab6b816f964e4e2b071df1e3192d972c5567de..da68796e68f748cfdcdf37688911aa03ca11f003 100644 --- a/src/gravity.c +++ b/src/gravity.c @@ -36,6 +36,7 @@ /* Local headers. */ #include "active.h" #include "error.h" +#include "threadpool.h" #include "version.h" struct exact_force_data { @@ -615,7 +616,8 @@ 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), 0, &data); + s->gparts, s->nr_gparts, sizeof(struct gpart), + threadpool_auto_chunk_size, &data); message("Computed exact gravity for %d gparts (took %.3f %s). ", data.counter_global, clocks_from_ticks(getticks() - tic), diff --git a/src/logger_io.c b/src/logger_io.c index e227db3b169767ad4a88514d136a9593b476b64d..8921304c062b75b67344d06ef3c4203a931eba13 100644 --- a/src/logger_io.c +++ b/src/logger_io.c @@ -54,6 +54,7 @@ #include "serial_io.h" #include "single_io.h" #include "stars_io.h" +#include "threadpool.h" #include "tracers_io.h" #include "units.h" #include "version.h" @@ -128,7 +129,7 @@ void writeIndexArray(const struct engine* e, FILE* f, struct io_props* props, /* Copy the whole thing into a buffer */ threadpool_map((struct threadpool*)&e->threadpool, logger_io_copy_mapper, - temp, N, typeSize, 0, props); + temp, N, typeSize, threadpool_auto_chunk_size, props); /* Write data to file */ fwrite(temp, typeSize, num_elements, f); diff --git a/src/mesh_gravity.c b/src/mesh_gravity.c index 3d417e978d81a81e9ba645abd40dd730fd7d8b37..caca895c28b3b120d43a78928fc4b64d7be4ef52 100644 --- a/src/mesh_gravity.c +++ b/src/mesh_gravity.c @@ -37,6 +37,7 @@ #include "part.h" #include "runner.h" #include "space.h" +#include "threadpool.h" #ifdef HAVE_FFTW @@ -470,7 +471,7 @@ void mesh_apply_Green_function(struct threadpool* tp, fftw_complex* frho, mesh_apply_Green_function_mapper(frho, N, &data); } else { threadpool_map(tp, mesh_apply_Green_function_mapper, frho, N, - sizeof(fftw_complex), 0, &data); + sizeof(fftw_complex), threadpool_auto_chunk_size, &data); } /* Correct singularity at (0,0,0) */ @@ -552,7 +553,8 @@ void pm_mesh_compute_potential(struct pm_mesh* mesh, const struct space* s, /* Do a parallel CIC mesh assignment of the gparts but only using the local top-level cells */ threadpool_map(tp, cell_gpart_to_mesh_CIC_mapper, (void*)local_cells, - nr_local_cells, sizeof(int), 0, (void*)&data); + nr_local_cells, sizeof(int), threadpool_auto_chunk_size, + (void*)&data); if (verbose) message("Gpart assignment took %.3f %s.", diff --git a/src/partition.c b/src/partition.c index 2ee321c872e6c34ff4ea82a9369c4637d56bb1d9..5c96eaba771a46a03eb04be715954be4459652ed 100644 --- a/src/partition.c +++ b/src/partition.c @@ -60,6 +60,7 @@ #include "partition.h" #include "restart.h" #include "space.h" +#include "threadpool.h" #include "tools.h" /* Simple descriptions of initial partition types for reports. */ @@ -1482,7 +1483,8 @@ static void repart_edge_metis(int vweights, int eweights, int timebins, ticks tic = getticks(); threadpool_map(&s->e->threadpool, partition_gather_weights, tasks, nr_tasks, - sizeof(struct task), 0, &weights_data); + sizeof(struct task), threadpool_auto_chunk_size, + &weights_data); if (s->e->verbose) message("weight mapper took %.3f %s.", clocks_from_ticks(getticks() - tic), clocks_getunit()); diff --git a/src/proxy.c b/src/proxy.c index 338f1beaa8734168d8139902a2746cd00250bffd..4b8fdfcbd8f6e96a0d32cad55d563cc809471d20 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -43,6 +43,7 @@ #include "error.h" #include "memuse.h" #include "space.h" +#include "threadpool.h" #ifdef WITH_MPI /* MPI data type for the communications */ @@ -394,7 +395,7 @@ void proxy_cells_exchange(struct proxy *proxies, int num_proxies, /* Run through the cells and get the size of the ones that will be sent off. */ threadpool_map(&s->e->threadpool, proxy_cells_count_mapper, s->cells_top, - s->nr_cells, sizeof(struct cell), /*chunk=*/0, + s->nr_cells, sizeof(struct cell), threadpool_auto_chunk_size, /*extra_data=*/NULL); int count_out = 0; int *offset = @@ -421,7 +422,8 @@ void proxy_cells_exchange(struct proxy *proxies, int num_proxies, /* Pack the cells. */ struct pack_mapper_data data = {s, offset, pcells, with_gravity}; threadpool_map(&s->e->threadpool, proxy_cells_pack_mapper, s->cells_top, - s->nr_cells, sizeof(struct cell), /*chunk=*/0, &data); + s->nr_cells, sizeof(struct cell), threadpool_auto_chunk_size, + &data); if (s->e->verbose) message("Packing cells took %.3f %s.", clocks_from_ticks(getticks() - tic2), @@ -429,7 +431,7 @@ void proxy_cells_exchange(struct proxy *proxies, int num_proxies, /* Launch the first part of the exchange. */ threadpool_map(&s->e->threadpool, proxy_cells_exchange_first_mapper, proxies, - num_proxies, sizeof(struct proxy), /*chunk=*/0, + num_proxies, sizeof(struct proxy), threadpool_auto_chunk_size, /*extra_data=*/NULL); for (int k = 0; k < num_proxies; k++) { reqs_in[k] = proxies[k].req_cells_count_in; diff --git a/src/scheduler.c b/src/scheduler.c index a4bc916757d4c1a34af3f034597b48bd00a28fb5..4f7af597cddf275892f33fa18b6ff3aed8d26cc5 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -53,6 +53,7 @@ #include "space.h" #include "space_getsid.h" #include "task.h" +#include "threadpool.h" #include "timers.h" #include "version.h" @@ -1059,12 +1060,14 @@ void scheduler_splittasks(struct scheduler *s, const int fof_tasks, if (fof_tasks) { /* Call the mapper on each current task. */ threadpool_map(s->threadpool, scheduler_splittasks_fof_mapper, s->tasks, - s->nr_tasks, sizeof(struct task), 0, s); + s->nr_tasks, sizeof(struct task), threadpool_auto_chunk_size, + s); } else { /* Call the mapper on each current task. */ threadpool_map(s->threadpool, scheduler_splittasks_mapper, s->tasks, - s->nr_tasks, sizeof(struct task), 0, s); + s->nr_tasks, sizeof(struct task), threadpool_auto_chunk_size, + s); } } @@ -1610,7 +1613,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), 0, s); + s->active_count, sizeof(int), threadpool_auto_chunk_size, s); } else { scheduler_rewait_mapper(s->tid_active, s->active_count, s); } @@ -1618,7 +1621,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), 0, s); + s->active_count, sizeof(int), threadpool_auto_chunk_size, s); } else { scheduler_enqueue_mapper(s->tid_active, s->active_count, s); } diff --git a/src/space.c b/src/space.c index 3fffafc4b7cd27827d6a24e116676581c8ae9413..4a128c7696519da93455c1d728bee4ab81fa109e 100644 --- a/src/space.c +++ b/src/space.c @@ -301,7 +301,8 @@ void space_free_cells(struct space *s) { ticks tic = getticks(); threadpool_map(&s->e->threadpool, space_rebuild_recycle_mapper, s->cells_top, - s->nr_cells, sizeof(struct cell), 0, s); + s->nr_cells, sizeof(struct cell), threadpool_auto_chunk_size, + s); s->maxdepth = 0; if (s->e->verbose) @@ -1996,7 +1997,8 @@ void space_split(struct space *s, int verbose) { threadpool_map(&s->e->threadpool, space_split_mapper, s->local_cells_with_particles_top, - s->nr_local_cells_with_particles, sizeof(int), 0, s); + s->nr_local_cells_with_particles, sizeof(int), + threadpool_auto_chunk_size, s); if (verbose) message("took %.3f %s.", clocks_from_ticks(getticks() - tic), @@ -2056,17 +2058,20 @@ void space_reorder_extras(struct space *s, int verbose) { /* Re-order the gas particles */ if (space_extra_parts) threadpool_map(&s->e->threadpool, space_reorder_extra_parts_mapper, - s->local_cells_top, s->nr_local_cells, sizeof(int), 0, s); + s->local_cells_top, s->nr_local_cells, sizeof(int), + threadpool_auto_chunk_size, s); /* Re-order the gravity particles */ if (space_extra_gparts) threadpool_map(&s->e->threadpool, space_reorder_extra_gparts_mapper, - s->local_cells_top, s->nr_local_cells, sizeof(int), 0, s); + s->local_cells_top, s->nr_local_cells, sizeof(int), + threadpool_auto_chunk_size, s); /* Re-order the star particles */ if (space_extra_sparts) threadpool_map(&s->e->threadpool, space_reorder_extra_sparts_mapper, - s->local_cells_top, s->nr_local_cells, sizeof(int), 0, s); + s->local_cells_top, s->nr_local_cells, sizeof(int), + threadpool_auto_chunk_size, s); /* Re-order the black hole particles */ if (space_extra_bparts) @@ -2100,7 +2105,8 @@ 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), 0, NULL); + s->nr_cells, sizeof(struct cell), threadpool_auto_chunk_size, + /*extra_data=*/NULL); } /** @@ -2684,7 +2690,8 @@ void space_parts_get_cell_index(struct space *s, int *ind, int *cell_counts, data.count_extra_bpart = 0; threadpool_map(&s->e->threadpool, space_parts_get_cell_index_mapper, s->parts, - s->nr_parts, sizeof(struct part), 0, &data); + s->nr_parts, sizeof(struct part), threadpool_auto_chunk_size, + &data); *count_inhibited_parts = data.count_inhibited_part; *count_extra_parts = data.count_extra_part; @@ -2732,7 +2739,8 @@ void space_gparts_get_cell_index(struct space *s, int *gind, int *cell_counts, data.count_extra_bpart = 0; threadpool_map(&s->e->threadpool, space_gparts_get_cell_index_mapper, - s->gparts, s->nr_gparts, sizeof(struct gpart), 0, &data); + s->gparts, s->nr_gparts, sizeof(struct gpart), + threadpool_auto_chunk_size, &data); *count_inhibited_gparts = data.count_inhibited_gpart; *count_extra_gparts = data.count_extra_gpart; @@ -2780,7 +2788,8 @@ void space_sparts_get_cell_index(struct space *s, int *sind, int *cell_counts, data.count_extra_bpart = 0; threadpool_map(&s->e->threadpool, space_sparts_get_cell_index_mapper, - s->sparts, s->nr_sparts, sizeof(struct spart), 0, &data); + s->sparts, s->nr_sparts, sizeof(struct spart), + threadpool_auto_chunk_size, &data); *count_inhibited_sparts = data.count_inhibited_spart; *count_extra_sparts = data.count_extra_spart; @@ -2828,7 +2837,8 @@ void space_bparts_get_cell_index(struct space *s, int *bind, int *cell_counts, data.count_extra_bpart = 0; threadpool_map(&s->e->threadpool, space_bparts_get_cell_index_mapper, - s->bparts, s->nr_bparts, sizeof(struct bpart), 0, &data); + s->bparts, s->nr_bparts, sizeof(struct bpart), + threadpool_auto_chunk_size, &data); *count_inhibited_bparts = data.count_inhibited_bpart; *count_extra_bparts = data.count_extra_bpart; @@ -4184,15 +4194,18 @@ void space_synchronize_particle_positions(struct space *s) { if (s->nr_gparts > 0 && s->nr_parts > 0) threadpool_map(&s->e->threadpool, space_synchronize_part_positions_mapper, - s->parts, s->nr_parts, sizeof(struct part), 0, (void *)s); + s->parts, s->nr_parts, sizeof(struct part), + threadpool_auto_chunk_size, (void *)s); if (s->nr_gparts > 0 && s->nr_sparts > 0) threadpool_map(&s->e->threadpool, space_synchronize_spart_positions_mapper, - s->sparts, s->nr_sparts, sizeof(struct spart), 0, NULL); + s->sparts, s->nr_sparts, sizeof(struct spart), + threadpool_auto_chunk_size, /*extra_data=*/NULL); if (s->nr_gparts > 0 && s->nr_bparts > 0) threadpool_map(&s->e->threadpool, space_synchronize_bpart_positions_mapper, - s->bparts, s->nr_bparts, sizeof(struct bpart), 0, NULL); + s->bparts, s->nr_bparts, sizeof(struct bpart), + threadpool_auto_chunk_size, /*extra_data=*/NULL); if (s->e->verbose) message("took %.3f %s.", clocks_from_ticks(getticks() - tic), @@ -4320,7 +4333,8 @@ void space_first_init_parts(struct space *s, int verbose) { const ticks tic = getticks(); if (s->nr_parts > 0) threadpool_map(&s->e->threadpool, space_first_init_parts_mapper, s->parts, - s->nr_parts, sizeof(struct part), 0, s); + s->nr_parts, sizeof(struct part), threadpool_auto_chunk_size, + s); if (verbose) message("took %.3f %s.", clocks_from_ticks(getticks() - tic), @@ -4381,7 +4395,8 @@ void space_first_init_gparts(struct space *s, int verbose) { const ticks tic = getticks(); if (s->nr_gparts > 0) threadpool_map(&s->e->threadpool, space_first_init_gparts_mapper, s->gparts, - s->nr_gparts, sizeof(struct gpart), 0, s); + s->nr_gparts, sizeof(struct gpart), + threadpool_auto_chunk_size, s); if (verbose) message("took %.3f %s.", clocks_from_ticks(getticks() - tic), @@ -4473,7 +4488,8 @@ void space_first_init_sparts(struct space *s, int verbose) { const ticks tic = getticks(); if (s->nr_sparts > 0) threadpool_map(&s->e->threadpool, space_first_init_sparts_mapper, s->sparts, - s->nr_sparts, sizeof(struct spart), 0, s); + s->nr_sparts, sizeof(struct spart), + threadpool_auto_chunk_size, s); if (verbose) message("took %.3f %s.", clocks_from_ticks(getticks() - tic), @@ -4555,7 +4571,8 @@ void space_first_init_bparts(struct space *s, int verbose) { const ticks tic = getticks(); if (s->nr_bparts > 0) threadpool_map(&s->e->threadpool, space_first_init_bparts_mapper, s->bparts, - s->nr_bparts, sizeof(struct bpart), 0, s); + s->nr_bparts, sizeof(struct bpart), + threadpool_auto_chunk_size, s); if (verbose) message("took %.3f %s.", clocks_from_ticks(getticks() - tic), @@ -4597,7 +4614,8 @@ void space_init_parts(struct space *s, int verbose) { if (s->nr_parts > 0) threadpool_map(&s->e->threadpool, space_init_parts_mapper, s->parts, - s->nr_parts, sizeof(struct part), 0, s->e); + s->nr_parts, sizeof(struct part), threadpool_auto_chunk_size, + s->e); if (verbose) message("took %.3f %s.", clocks_from_ticks(getticks() - tic), clocks_getunit()); @@ -4623,7 +4641,8 @@ void space_init_gparts(struct space *s, int verbose) { if (s->nr_gparts > 0) threadpool_map(&s->e->threadpool, space_init_gparts_mapper, s->gparts, - s->nr_gparts, sizeof(struct gpart), 0, NULL); + s->nr_gparts, sizeof(struct gpart), + threadpool_auto_chunk_size, /*extra_data=*/NULL); if (verbose) message("took %.3f %s.", clocks_from_ticks(getticks() - tic), clocks_getunit()); @@ -4649,7 +4668,8 @@ void space_init_sparts(struct space *s, int verbose) { if (s->nr_sparts > 0) threadpool_map(&s->e->threadpool, space_init_sparts_mapper, s->sparts, - s->nr_sparts, sizeof(struct spart), 0, NULL); + s->nr_sparts, sizeof(struct spart), + threadpool_auto_chunk_size, /*extra_data=*/NULL); if (verbose) message("took %.3f %s.", clocks_from_ticks(getticks() - tic), clocks_getunit()); @@ -4675,7 +4695,8 @@ void space_init_bparts(struct space *s, int verbose) { if (s->nr_bparts > 0) threadpool_map(&s->e->threadpool, space_init_bparts_mapper, s->bparts, - s->nr_bparts, sizeof(struct bpart), 0, NULL); + s->nr_bparts, sizeof(struct bpart), + threadpool_auto_chunk_size, /*extra_data=*/NULL); if (verbose) message("took %.3f %s.", clocks_from_ticks(getticks() - tic), clocks_getunit()); @@ -4710,7 +4731,8 @@ void space_convert_quantities(struct space *s, int verbose) { if (s->nr_parts > 0) threadpool_map(&s->e->threadpool, space_convert_quantities_mapper, s->parts, - s->nr_parts, sizeof(struct part), 0, s); + s->nr_parts, sizeof(struct part), threadpool_auto_chunk_size, + s); if (verbose) message("took %.3f %s.", clocks_from_ticks(getticks() - tic), @@ -5599,10 +5621,12 @@ void space_check_swallow(struct space *s) { #ifdef SWIFT_DEBUG_CHECKS threadpool_map(&s->e->threadpool, space_check_part_swallow_mapper, s->parts, - s->nr_parts, sizeof(struct part), 0, NULL); + s->nr_parts, sizeof(struct part), threadpool_auto_chunk_size, + /*extra_data=*/NULL); threadpool_map(&s->e->threadpool, space_check_bpart_swallow_mapper, s->bparts, - s->nr_bparts, sizeof(struct bpart), 0, NULL); + s->nr_bparts, sizeof(struct bpart), threadpool_auto_chunk_size, + /*extra_data=*/NULL); #else error("Calling debugging code without debugging flag activated."); #endif diff --git a/src/statistics.c b/src/statistics.c index 11b64acecb79d9466176ef91e4b9cd70e2ebb743..3a2e2831a1e2b436ae072a285259128740dbb5e5 100644 --- a/src/statistics.c +++ b/src/statistics.c @@ -325,12 +325,14 @@ 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), 0, &extra_data); + s->nr_parts, sizeof(struct part), threadpool_auto_chunk_size, + &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), 0, &extra_data); + s->nr_gparts, sizeof(struct gpart), + threadpool_auto_chunk_size, &extra_data); } /** diff --git a/src/threadpool.c b/src/threadpool.c index 9a29faab652077c3c0730d81c28d345c4fbece09..c4b6698e9eeb9a657ad66e7a1a7566626b9dc875 100644 --- a/src/threadpool.c +++ b/src/threadpool.c @@ -278,8 +278,11 @@ void threadpool_map(struct threadpool *tp, threadpool_map_function map_function, tp->map_data_stride = stride; tp->map_data_size = N; tp->map_data_count = 0; - tp->map_data_chunk = (chunk == threadpool_auto_chunk_size) ? - max((int)(N / (tp->num_threads * threadpool_default_chunk_ratio)), 1) : chunk; + tp->map_data_chunk = + (chunk == threadpool_auto_chunk_size) + ? max((int)(N / (tp->num_threads * threadpool_default_chunk_ratio)), + 1) + : chunk; tp->map_function = map_function; tp->map_data = map_data; tp->map_extra_data = extra_data; diff --git a/src/velociraptor_interface.c b/src/velociraptor_interface.c index 6f6f76bc12ea9a78fd661fe8664c054e500c2576..c1aa8573593f9ee47577b34871ad2d1a3e9bf157 100644 --- a/src/velociraptor_interface.c +++ b/src/velociraptor_interface.c @@ -35,6 +35,7 @@ #include "engine.h" #include "hydro.h" #include "swift_velociraptor_part.h" +#include "threadpool.h" #include "velociraptor_struct.h" #ifdef HAVE_VELOCIRAPTOR @@ -628,7 +629,8 @@ void velociraptor_invoke(struct engine *e, const int linked_with_snap) { struct velociraptor_copy_data copy_data = {e, swift_parts}; threadpool_map(&e->threadpool, velociraptor_convert_particles_mapper, - s->gparts, nr_gparts, sizeof(struct gpart), 0, ©_data); + s->gparts, nr_gparts, sizeof(struct gpart), + threadpool_auto_chunk_size, ©_data); /* Report timing */ if (e->verbose)