diff --git a/examples/main.c b/examples/main.c index 32ec730d34523c7df6a8ee15f09a027d22bde483..dcc113ab6af6a06e7c20ac1aac7c2d3b715f7ef3 100644 --- a/examples/main.c +++ b/examples/main.c @@ -548,7 +548,7 @@ int main(int argc, char *argv[]) { /* Repartition the space amongst the nodes? */ #ifdef WITH_MPI - if (j % 3 == 2) e.forcerepart = reparttype; + if (j % 100 == 2) e.forcerepart = reparttype; #endif /* Reset timers */ diff --git a/src/engine.c b/src/engine.c index a0b86722feda8ee3b6950a3b344119f570c8c7d9..77842658529ec85d140689d91dc711d2bc57139a 100644 --- a/src/engine.c +++ b/src/engine.c @@ -317,7 +317,9 @@ void engine_redistribute(struct engine *e) { MPI_COMM_WORLD) != MPI_SUCCESS) error("Failed to allreduce particle transfer counts."); - if (e->nodeID == 0) { + /* Report how many particles have been moved. */ + if (e->verbose) { + if (e->nodeID == 0) { size_t total = 0; size_t unmoved = 0; for (int p = 0, r = 0; p < nr_nodes; p++) { @@ -328,8 +330,9 @@ void engine_redistribute(struct engine *e) { r++; } } - message("total = %ld, unmoved = %ld, fraction = %f", total, unmoved, - (double)unmoved/(double)total); + message("of %ld particles %ld are not transferred (%.2f%%)", total, unmoved, + 100.0 * (double)unmoved / (double)total); + } } diff --git a/src/partition.c b/src/partition.c index 26f1ea151e24b0297d68138ae3b6881fb67fa973..cf5f8e0e53718c4e41ec1c24114ab88b2c513b2f 100644 --- a/src/partition.c +++ b/src/partition.c @@ -398,27 +398,15 @@ static void pick_metis(struct space *s, int nregions, int *vertexw, int *edgew, * preserved when possible, to avoid unneccesary particle movement. * So try mapping the current regions to the new regions and reassigning * those with the greatest number of common cells... */ - int keymax = nregions + nregions * nregions; + int keymax = nregions * nregions; struct indexval *ivs = malloc(sizeof(struct indexval) * keymax); bzero(ivs, sizeof(struct indexval) * keymax); for (int k = 0; k < ncells; k++) { int index = regionid[k] + nregions * s->cells_top[k].nodeID; ivs[index].count++; ivs[index].index = index; - //message( "incr: %d %d %d %d %d", index, ivs[index].count, - // regionid[k], nregions, s->cells_top[k].nodeID); } - - /* Need to keep indices..., not counts, just sort by counts. XXX */ - //message("unsorted"); - //for (int k = 0; k < keymax; k++) { - // message(" %d %d", ivs[k].index, ivs[k].count); - //} qsort(ivs, keymax, sizeof(struct indexval), indexvalcmp); - //message("sorted"); - //for (int k = 0; k < keymax; k++) { - // message(" %d %d", ivs[k].index, ivs[k].count); - //} /* Go through the ivs using the largest counts first, these are the * regions with the most cells in common, old partition to new. */ @@ -439,19 +427,16 @@ static void pick_metis(struct space *s, int nregions, int *vertexw, int *edgew, if (newmap[newregion] == -1 && oldmap[oldregion] == -1) { newmap[newregion] = oldregion; oldmap[oldregion] = newregion; - //message("mapping: %d to %d", newregion, oldregion); - //message(" : %d %d %d", ivs[k].index, ivs[k].count, nregions); } } - /* Need to handle any regions that did not get selected. */ + /* Handle any regions that did not get selected by picking an unused rank + * from oldmap and assigning to newmap. */ int spare = 0; for (int k = 0; k < nregions; k++) { if (newmap[k] == -1) { - //message("unmapped newmap[%d] = %d", k, newmap[k]); for (int j = spare; j < nregions; j++) { if (oldmap[j] == -1) { - //message("used oldmap[%d] = %d", j, j); newmap[k] = j; oldmap[j] = j; spare = j; @@ -463,9 +448,7 @@ static void pick_metis(struct space *s, int nregions, int *vertexw, int *edgew, /* Set the cell list to the region index. */ for (int k = 0; k < ncells; k++) { - //message("mapping: %d to %d", regionid[k], newmap[regionid[k]]); celllist[k] = newmap[regionid[k]]; - //celllist[k] = regionid[k]; } /* Clean up. */