Commit 3da8de63 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Instead of listing local cells only, list cells that have a tasks associated...

Instead of listing local cells only, list cells that have a tasks associated with them on the local node.
parent f6afa976
...@@ -2071,6 +2071,24 @@ void cell_set_super_mapper(void *map_data, int num_elements, void *extra_data) { ...@@ -2071,6 +2071,24 @@ void cell_set_super_mapper(void *map_data, int num_elements, void *extra_data) {
} }
} }
int cell_has_tasks(struct cell *c) {
#ifdef WITH_MPI
if (c->timestep != NULL || c->recv_ti != NULL) return 1;
#else
if (c->timestep != NULL) return 1;
#endif /* WITH_MPI */
if (c->split) {
int count = 0;
for (int k = 0; k < 8; ++k)
if (c->progeny[k] != NULL) count += cell_has_tasks(c->progeny[k]);
return count;
} else {
return 0;
}
}
/** /**
* @brief Recursively drifts the #part in a cell hierarchy. * @brief Recursively drifts the #part in a cell hierarchy.
* *
......
...@@ -462,6 +462,7 @@ void cell_activate_drift_gpart(struct cell *c, struct scheduler *s); ...@@ -462,6 +462,7 @@ void cell_activate_drift_gpart(struct cell *c, struct scheduler *s);
void cell_activate_sorts(struct cell *c, int sid, struct scheduler *s); void cell_activate_sorts(struct cell *c, int sid, struct scheduler *s);
void cell_clear_drift_flags(struct cell *c, void *data); void cell_clear_drift_flags(struct cell *c, void *data);
void cell_set_super_mapper(void *map_data, int num_elements, void *extra_data); void cell_set_super_mapper(void *map_data, int num_elements, void *extra_data);
int cell_has_tasks(struct cell *c);
/* Inlined functions (for speed). */ /* Inlined functions (for speed). */
......
...@@ -3070,6 +3070,9 @@ void engine_rebuild(struct engine *e, int clean_h_values) { ...@@ -3070,6 +3070,9 @@ void engine_rebuild(struct engine *e, int clean_h_values) {
/* Re-build the tasks. */ /* Re-build the tasks. */
engine_maketasks(e); engine_maketasks(e);
/* Make the list of top-level cells that have tasks */
space_list_cells_with_tasks(e->s);
#ifdef SWIFT_DEBUG_CHECKS #ifdef SWIFT_DEBUG_CHECKS
/* Check that all cells have been drifted to the current time. /* Check that all cells have been drifted to the current time.
* That can include cells that have not * That can include cells that have not
......
...@@ -503,16 +503,6 @@ void space_regrid(struct space *s, int verbose) { ...@@ -503,16 +503,6 @@ void space_regrid(struct space *s, int verbose) {
} }
#endif /* WITH_MPI */ #endif /* WITH_MPI */
/* Let's rebuild the list of local top-level cells */
s->nr_local_cells = 0;
for (int i = 0; i < s->nr_cells; ++i)
if (s->cells_top[i].nodeID == s->nodeID) {
s->local_cells_top[s->nr_local_cells] = i;
++s->nr_local_cells;
}
if (verbose)
message("Have %d local cells (total=%d)", s->nr_local_cells, s->nr_cells);
// message( "rebuilding upper-level cells took %.3f %s." , // message( "rebuilding upper-level cells took %.3f %s." ,
// clocks_from_ticks(double)(getticks() - tic), clocks_getunit()); // clocks_from_ticks(double)(getticks() - tic), clocks_getunit());
...@@ -2483,6 +2473,19 @@ void space_getcells(struct space *s, int nr_cells, struct cell **cells) { ...@@ -2483,6 +2473,19 @@ void space_getcells(struct space *s, int nr_cells, struct cell **cells) {
} }
} }
void space_list_cells_with_tasks(struct space *s) {
/* Let's rebuild the list of local top-level cells */
s->nr_local_cells = 0;
for (int i = 0; i < s->nr_cells; ++i)
if (cell_has_tasks(&s->cells_top[i])) {
s->local_cells_top[s->nr_local_cells] = i;
++s->nr_local_cells;
}
if (s->e->verbose)
message("Have %d local cells (total=%d)", s->nr_local_cells, s->nr_cells);
}
void space_synchronize_particle_positions_mapper(void *map_data, int nr_gparts, void space_synchronize_particle_positions_mapper(void *map_data, int nr_gparts,
void *extra_data) { void *extra_data) {
/* Unpack the data */ /* Unpack the data */
......
...@@ -213,6 +213,7 @@ void space_recycle_list(struct space *s, struct cell *cell_list_begin, ...@@ -213,6 +213,7 @@ void space_recycle_list(struct space *s, struct cell *cell_list_begin,
void space_split(struct space *s, struct cell *cells, int nr_cells, void space_split(struct space *s, struct cell *cells, int nr_cells,
int verbose); int verbose);
void space_split_mapper(void *map_data, int num_elements, void *extra_data); 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, struct cell *cells, void space_parts_get_cell_index(struct space *s, int *ind, struct cell *cells,
int verbose); int verbose);
void space_gparts_get_cell_index(struct space *s, int *gind, struct cell *cells, void space_gparts_get_cell_index(struct space *s, int *gind, struct cell *cells,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment