diff --git a/src/engine.c b/src/engine.c index 1248783bf18e125fdc66b6729c953f647fa61c54..8be7975fe59f3fdad5bcd33065113b34c09f32ee 100644 --- a/src/engine.c +++ b/src/engine.c @@ -5868,10 +5868,11 @@ void engine_do_drift_all_mapper(void *map_data, int num_elements, const struct engine *e = (const struct engine *)extra_data; struct space *s = e->s; + struct cell *cells_top = s->cells_top; int *local_cells = (int *)map_data; for (int ind = 0; ind < num_elements; ind++) { - struct cell *c = &s->cells_top[local_cells[ind]]; + struct cell *c = &cells_top[local_cells[ind]]; if (c->nodeID == e->nodeID) { diff --git a/src/space.c b/src/space.c index e0e4d3810f22bf77e899e9c9c62e2a8f9964ea12..180a013d857c37ea77177302f7978b0923886f7e 100644 --- a/src/space.c +++ b/src/space.c @@ -1122,7 +1122,7 @@ void space_rebuild(struct space *s, int repartitioned, int verbose) { /* At this point, we have the upper-level cells, old or new. Now make sure that the parts in each cell are ok. */ - space_split(s, cells_top, s->nr_cells, verbose); + space_split(s, verbose); #ifdef SWIFT_DEBUG_CHECKS /* Check that the multipole construction went OK */ @@ -1149,12 +1149,12 @@ void space_rebuild(struct space *s, int repartitioned, int verbose) { * @param nr_cells The number of cells. * @param verbose Are we talkative ? */ -void space_split(struct space *s, struct cell *cells, int nr_cells, - int verbose) { +void space_split(struct space *s, int verbose) { const ticks tic = getticks(); - threadpool_map(&s->e->threadpool, space_split_mapper, cells, nr_cells, + threadpool_map(&s->e->threadpool, space_split_mapper, + s->cells_with_particles_top, s->nr_cells_with_particles, sizeof(struct cell), 0, s); if (verbose) @@ -2391,10 +2391,12 @@ void space_split_mapper(void *map_data, int num_cells, void *extra_data) { /* Unpack the inputs. */ struct space *s = (struct space *)extra_data; - struct cell *restrict cells_top = (struct cell *)map_data; + struct cell *cells_top = s->cells_top; + int *cells_with_particles = (int *)map_data; + /* Loop over the non-empty cells */ for (int ind = 0; ind < num_cells; ind++) { - struct cell *c = &cells_top[ind]; + struct cell *c = &cells_top[cells_with_particles[ind]]; space_split_recursive(s, c, NULL, NULL, NULL); } diff --git a/src/space.h b/src/space.h index cc8f62659e7b7306d77808d4d2a435066f37c29e..c2160895b0c6fb96ecce82a399135563a2974f48 100644 --- a/src/space.h +++ b/src/space.h @@ -253,8 +253,7 @@ void space_recycle_list(struct space *s, struct cell *cell_list_begin, struct cell *cell_list_end, struct gravity_tensors *multipole_list_begin, struct gravity_tensors *multipole_list_end); -void space_split(struct space *s, struct cell *cells, int nr_cells, - int verbose); +void space_split(struct space *s, int verbose); void space_split_mapper(void *map_data, int num_elements, void *extra_data); void space_list_cells_with_tasks(struct space *s); void space_parts_get_cell_index(struct space *s, int *ind, int *cell_counts,