diff --git a/examples/main.c b/examples/main.c index 1fb23bfbe714a9d88259f593f8da2c1a31a0b390..fe1a209ca4acf84e76e453a35033846702513ef3 100644 --- a/examples/main.c +++ b/examples/main.c @@ -91,14 +91,12 @@ int main(int argc, char *argv[]) { #ifdef WITH_MPI /* Start by initializing MPI. */ int res, prov; - if ((res = MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &prov)) != - MPI_SUCCESS) + if ((res = MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &prov)) != MPI_SUCCESS) error("Call to MPI_Init failed with error %i.", res); if (prov != MPI_THREAD_MULTIPLE) - error( - "MPI does not provide the level of threading required " - "(MPI_THREAD_MULTIPLE)."); - if ((res = MPI_Comm_size(MPI_COMM_WORLD, &nr_nodes) != MPI_SUCCESS)) + error("MPI does not provide the level of threading required " + "(MPI_THREAD_MULTIPLE)."); + if ((res = MPI_Comm_size(MPI_COMM_WORLD, &nr_nodes)) != MPI_SUCCESS) error("MPI_Comm_size failed with error %i.", res); if ((res = MPI_Comm_rank(MPI_COMM_WORLD, &myrank)) != MPI_SUCCESS) error("Call to MPI_Comm_rank failed with error %i.", res); @@ -154,7 +152,7 @@ int main(int argc, char *argv[]) { break; case 'o': with_outputs = 0; - break; + break; case 'q': if (sscanf(optarg, "%d", &nr_queues) != 1) error("Error parsing number of queues."); @@ -193,17 +191,20 @@ int main(int argc, char *argv[]) { } #if defined(WITH_MPI) - if (myrank == 0) message("Running with %i thread(s) per node.", nr_threads); + if (myrank == 0) { + message("Running with %i thread(s) per node.", nr_threads); + message("grid set to [ %i %i %i ].", grid[0], grid[1], grid[2]); + + if (nr_nodes == 1) { + message("WARNING: you are running with one MPI rank."); + message("WARNING: you should use the non-MPI version of this program." ); + } + fflush(stdout); + } #else if (myrank == 0) message("Running with %i thread(s).", nr_threads); #endif -#if defined(WITH_MPI) - if (myrank == 0) - message("grid set to [ %i %i %i ].", grid[0], grid[1], grid[2]); - fflush(stdout); -#endif - /* How large are the parts? */ if (myrank == 0) { message("sizeof(struct part) is %li bytes.", (long int)sizeof(struct part)); diff --git a/src/engine.c b/src/engine.c index 9f1953fd3661a3fa54f167d28743de0d8c4cf26b..967fcd9fc6634dddbc240d36180adbd622746b7b 100644 --- a/src/engine.c +++ b/src/engine.c @@ -277,7 +277,7 @@ void engine_redistribute(struct engine *e) { free(dest); #else - error("SWIFT was not compiled with MPI and METIS support."); + error("SWIFT was not compiled with MPI support."); #endif } @@ -308,6 +308,10 @@ void engine_repartition(struct engine *e) { /* Clear the repartition flag. */ e->forcerepart = 0; + /* Nothing to do if only using a single node. Also avoids METIS + * bug that doesn't handle this case well. */ + if ( nr_nodes == 1 ) return; + /* Allocate the inds and weights. */ if ((inds = (idx_t *)malloc(sizeof(idx_t) * 26 *nr_cells)) == NULL || (weights_v = (idx_t *)malloc(sizeof(idx_t) *nr_cells)) == NULL ||