From afc76a8b2795180ff0f06ad96baa06a78209cfa6 Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Mon, 11 Nov 2019 12:36:03 +0100 Subject: [PATCH 1/3] Print number of MPI/OMP threads at start and end. --- opm/simulators/flow/FlowMainEbos.hpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/opm/simulators/flow/FlowMainEbos.hpp b/opm/simulators/flow/FlowMainEbos.hpp index 0acb23170..917e02f4c 100644 --- a/opm/simulators/flow/FlowMainEbos.hpp +++ b/opm/simulators/flow/FlowMainEbos.hpp @@ -219,6 +219,19 @@ namespace Opm std::cout << "* For more information, see https://opm-project.org *\n"; std::cout << "* *\n"; std::cout << "**********************************************************************\n\n"; + + int threads = 1; + int mpiSize = 1; + +#ifdef _OPENMP + threads = omp_get_max_threads(); +#endif + +#if HAVE_MPI + MPI_Comm_size(MPI_COMM_WORLD, &mpiSize); +#endif + + std::cout << "Using "<< mpiSize << " MPI processors with "<< threads <<" OMP threads on each \n\n"; } /// This is the main function of Flow. It runs a complete simulation with the @@ -470,6 +483,13 @@ namespace Opm if (output_cout) { std::ostringstream ss; ss << "\n\n================ End of simulation ===============\n\n"; + ss << "Number of MPI processors: " << std::setw(6) << mpi_size_ << "\n"; +#if _OPENMP + int threads = omp_get_max_threads(); +#else + int threads = 1; +#endif + ss << "Threads per MPI processor: " << std::setw(4) << threads << "\n"; successReport.reportFullyImplicit(ss, &failureReport); OpmLog::info(ss.str()); } From b4ec2f0611f22286c31b1a7753c7d1d91d4bf42c Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Tue, 12 Nov 2019 09:36:56 +0100 Subject: [PATCH 2/3] Use correct number of threads when printing banner. At that stage flow did not set the number of thread in the case where OMP_NUM_THREADS is not defined. That happens in setupParallelism which is called when the simulator is run. Hence we have to manually compute the number of threads similar to there. --- opm/simulators/flow/FlowMainEbos.hpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/opm/simulators/flow/FlowMainEbos.hpp b/opm/simulators/flow/FlowMainEbos.hpp index 917e02f4c..e17e561bb 100644 --- a/opm/simulators/flow/FlowMainEbos.hpp +++ b/opm/simulators/flow/FlowMainEbos.hpp @@ -224,7 +224,13 @@ namespace Opm int mpiSize = 1; #ifdef _OPENMP - threads = omp_get_max_threads(); + // This function is called before the parallel OpenMP stuff gets initialized. + // That initialization happends after the deck is read and we want this message. + // Hence we duplicate the code of setupParallelism to get the number of threads. + if (getenv("OMP_NUM_THREADS")) + threads = omp_get_max_threads(); + else + threads = std::min(2, omp_get_max_threads()); #endif #if HAVE_MPI From 5c34b843f19fc3ae3ea7e3b3b05efbf2f26eb7ef Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Tue, 19 Nov 2019 15:56:18 +0100 Subject: [PATCH 3/3] Use process instead of processor for MPI. --- opm/simulators/flow/FlowMainEbos.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/opm/simulators/flow/FlowMainEbos.hpp b/opm/simulators/flow/FlowMainEbos.hpp index e17e561bb..c21ad9521 100644 --- a/opm/simulators/flow/FlowMainEbos.hpp +++ b/opm/simulators/flow/FlowMainEbos.hpp @@ -237,7 +237,7 @@ namespace Opm MPI_Comm_size(MPI_COMM_WORLD, &mpiSize); #endif - std::cout << "Using "<< mpiSize << " MPI processors with "<< threads <<" OMP threads on each \n\n"; + std::cout << "Using "<< mpiSize << " MPI processes with "<< threads <<" OMP threads on each \n\n"; } /// This is the main function of Flow. It runs a complete simulation with the @@ -489,13 +489,13 @@ namespace Opm if (output_cout) { std::ostringstream ss; ss << "\n\n================ End of simulation ===============\n\n"; - ss << "Number of MPI processors: " << std::setw(6) << mpi_size_ << "\n"; + ss << "Number of MPI processes: " << std::setw(6) << mpi_size_ << "\n"; #if _OPENMP int threads = omp_get_max_threads(); #else int threads = 1; #endif - ss << "Threads per MPI processor: " << std::setw(4) << threads << "\n"; + ss << "Threads per MPI process: " << std::setw(5) << threads << "\n"; successReport.reportFullyImplicit(ss, &failureReport); OpmLog::info(ss.str()); }