Skip to content
Snippets Groups Projects
Commit 4dbf6d45 authored by Peter W. Draper's avatar Peter W. Draper
Browse files

Merge branch 'skip_relink' into 'master'

Only relink parts and gparts when we actually have parts and gparts

Any reason not do this ? We spend some time linking things even when we don't have anything to link. That would speed up `space_rebuild()` and `cell_split()` in the cases without gravity, the latter of those to two being a scalar part of the code this could be quite important.

See merge request !234
parents f62be6ac ebf2c31f
Loading
......@@ -580,7 +580,7 @@ void cell_split(struct cell *c, ptrdiff_t parts_offset) {
}
/* Re-link the gparts. */
part_relink_gparts(parts, count, parts_offset);
if (count > 0 && gcount > 0) part_relink_gparts(parts, count, parts_offset);
#ifdef SWIFT_DEBUG_CHECKS
/* Verify that _all_ the parts have been assigned to a cell. */
......@@ -675,7 +675,8 @@ void cell_split(struct cell *c, ptrdiff_t parts_offset) {
}
/* Re-link the parts. */
part_relink_parts(gparts, gcount, parts - parts_offset);
if (count > 0 && gcount > 0)
part_relink_parts(gparts, gcount, parts - parts_offset);
}
/**
......
......@@ -2936,7 +2936,8 @@ void engine_split(struct engine *e, struct partition *initial_partition) {
s->xparts = xparts_new;
/* Re-link the gparts. */
part_relink_gparts(s->parts, s->nr_parts, 0);
if (s->nr_parts > 0 && s->nr_gparts > 0)
part_relink_gparts(s->parts, s->nr_parts, 0);
/* Re-allocate the local gparts. */
if (e->verbose)
......@@ -2952,7 +2953,8 @@ void engine_split(struct engine *e, struct partition *initial_partition) {
s->gparts = gparts_new;
/* Re-link the parts. */
part_relink_parts(s->gparts, s->nr_gparts, s->parts);
if (s->nr_parts > 0 && s->nr_gparts > 0)
part_relink_parts(s->gparts, s->nr_gparts, s->parts);
#ifdef SWIFT_DEBUG_CHECKS
......
......@@ -589,7 +589,7 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
space_parts_sort(s, ind, nr_parts, 0, s->nr_cells - 1, verbose);
/* Re-link the gparts. */
part_relink_gparts(s->parts, nr_parts, 0);
if (nr_parts > 0 && nr_gparts > 0) part_relink_gparts(s->parts, nr_parts, 0);
#ifdef SWIFT_DEBUG_CHECKS
/* Verify space_sort_struct. */
......@@ -640,7 +640,8 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
space_gparts_sort(s, gind, nr_gparts, 0, s->nr_cells - 1, verbose);
/* Re-link the parts. */
part_relink_parts(s->gparts, nr_gparts, s->parts);
if (nr_parts > 0 && nr_gparts > 0)
part_relink_parts(s->gparts, nr_gparts, s->parts);
/* We no longer need the indices as of here. */
free(gind);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment