diff --git a/examples/main.c b/examples/main.c index d1a82bbdc38b865401ec7d71c0c85bd650abf9a2..37394421c7f3d3b2add55eab8549f78ca70a5bd0 100644 --- a/examples/main.c +++ b/examples/main.c @@ -492,12 +492,20 @@ int main(int argc, char *argv[]) { /* Let's report what we did */ if (myrank == 0) { - message("Using initial partition %s", +#if defined(HAVE_PARMETIS) + if (reparttype.usemetis) + message("Using METIS serial partitioning:"); + else + message("Using ParMETIS partitioning:"); +#else + message("Using METIS serial partitioning:"); +#endif + message(" initial partitioning: %s", initial_partition_name[initial_partition.type]); if (initial_partition.type == INITPART_GRID) - message("grid set to [ %i %i %i ].", initial_partition.grid[0], + message(" grid set to [ %i %i %i ].", initial_partition.grid[0], initial_partition.grid[1], initial_partition.grid[2]); - message("Using %s repartitioning", repartition_name[reparttype.type]); + message(" repartitioning: %s", repartition_name[reparttype.type]); } #endif diff --git a/examples/parameter_example.yml b/examples/parameter_example.yml index 59b4cb1894e7c325671d0dde40492b2cd45b2a1b..1e675cac8a98f3b1a36c41c9e9a869fa072d97af 100644 --- a/examples/parameter_example.yml +++ b/examples/parameter_example.yml @@ -125,7 +125,9 @@ DomainDecomposition: # new decomposition, or number of steps (>1) between decompositions minfrac: 0.9 # (Optional) Fractional of all particles that should be updated in previous step when # using CPU time trigger - itr 0.1 # Ratio of inter node communication time to data redistribution time, in the range 0.00001 to 10000000.0. + usemetis 0 # Use serial METIS when ParMETIS is also available. + adaptive 1 # Use adaptive repartition when ParMETIS is available, otherwise simple refinement. + itr 100 # When adaptive defines the ratio of inter node communication time to data redistribution time, in the range 0.00001 to 10000000.0. # Lower values give less data movement during redistributions, at the cost of global balance which may require more communication. # Parameters related to the equation of state ------------------------------------------ diff --git a/src/partition.c b/src/partition.c index 3b294e7ecbe0c2033a6477af551c51794337dca5..13b2a373bd78c95757c3c9dc1a20b5308e0381ac 100644 --- a/src/partition.c +++ b/src/partition.c @@ -60,17 +60,18 @@ /* Simple descriptions of initial partition types for reports. */ const char *initial_partition_name[] = { - "axis aligned grids of cells", "vectorized point associated cells", - "memory balanced, using METIS particle weighted cells", - "similar sized regions, using METIS unweighted cells"}; + "axis aligned grids of cells", + "vectorized point associated cells", + "memory balanced, using particle weighted cells", + "similar sized regions, using unweighted cells"}; /* Simple descriptions of repartition types for reports. */ const char *repartition_name[] = { - "no", - "METIS edge and vertex task cost weights", - "METIS task cost edge weights", - "METIS task cost vertex weights", - "METIS vertex task costs and edge delta timebin weights" + "none", + "edge and vertex task cost weights", + "task cost edge weights", + "task cost vertex weights", + "vertex task costs and edge delta timebin weights" }; /* Local functions, if needed. */ @@ -871,7 +872,7 @@ static void pick_parmetis(int nodeID, struct space *s, int nregions, } #endif -#if defined(WITH_MPI) && defined(HAVE_METIS) && !defined(HAVE_PARMETIS) +#if defined(WITH_MPI) && defined(HAVE_METIS) /** * @brief Partition the given space into a number of connected regions. * @@ -1246,9 +1247,13 @@ static void repart_edge_metis(int vweights, int eweights, int timebins, /* And repartition/ partition, using both weights or not as requested. */ #ifdef HAVE_PARMETIS - pick_parmetis(nodeID, s, nr_nodes, weights_v, weights_e, refine, - repartition->adaptive, repartition->itr, - repartition->celllist); + if (repartition->usemetis) { + pick_metis(nodeID, s, nr_nodes, weights_v, weights_e, repartition->celllist); + } else { + pick_parmetis(nodeID, s, nr_nodes, weights_v, weights_e, refine, + repartition->adaptive, repartition->itr, + repartition->celllist); + } #else pick_metis(nodeID, s, nr_nodes, weights_v, weights_e, repartition->celllist); #endif @@ -1423,7 +1428,11 @@ void partition_initial_partition(struct partition *initial_partition, if ((celllist = (int *)malloc(sizeof(int) * s->nr_cells)) == NULL) error("Failed to allocate celllist"); #ifdef HAVE_PARMETIS + if (initial_partition->usemetis) { + pick_metis(nodeID, s, nr_nodes, weights, NULL, celllist); + } else { pick_parmetis(nodeID, s, nr_nodes, weights, NULL, 0, 0, 0.0f, celllist); + } #else pick_metis(nodeID, s, nr_nodes, weights, NULL, celllist); #endif @@ -1595,13 +1604,18 @@ void partition_init(struct partition *partition, "Invalid DomainDecomposition:minfrac, must be greater than 0 and less " "than equal to 1"); + /* Use METIS or ParMETIS when ParMETIS is also available. */ + repartition->usemetis = + parser_get_opt_param_int(params, "DomainDecomposition:usemetis", 0); + partition->usemetis = repartition->usemetis; + /* Use adaptive or simple refinement when repartitioning. */ - repartition->adaptive = - parser_get_opt_param_int(params, "DomainDecomposition:adaptive", 1 ); + repartition->adaptive = + parser_get_opt_param_int(params, "DomainDecomposition:adaptive", 1); /* Ratio of interprocess communication time to data redistribution time. */ repartition->itr = - parser_get_opt_param_float(params, "DomainDecomposition:itr", 0.1f); + parser_get_opt_param_float(params, "DomainDecomposition:itr", 100.0f); /* Clear the celllist for use. */ repartition->ncelllist = 0; diff --git a/src/partition.h b/src/partition.h index 782d4f411be05c99177e30b780c9a3b8d48cc10f..1202a1d19ff18f83ed26464bade088990ed51db6 100644 --- a/src/partition.h +++ b/src/partition.h @@ -38,6 +38,7 @@ extern const char *initial_partition_name[]; struct partition { enum partition_type type; int grid[3]; + int usemetis; }; /* Repartition type to use. */ @@ -55,6 +56,7 @@ struct repartition { float trigger; float minfrac; float itr; + int usemetis; int adaptive; /* The partition as a cell-list. */