diff --git a/runtime/stats.hpp b/runtime/stats.hpp new file mode 100644 index 0000000000000000000000000000000000000000..413ffab8425bc31d877e263d29fdfa4f9f343405 --- /dev/null +++ b/runtime/stats.hpp @@ -0,0 +1,33 @@ +#include "pairs.hpp" + +#pragma once + +using namespace std; + +namespace pairs { + +void print_stats(PairsSimulation *ps, int nlocal, int nghost) { + int min_nlocal = nlocal; + int max_nlocal = nlocal; + int min_nghost = nghost; + int max_nghost = nghost; + int nglobal; + + if(ps->getDomainPartitioner()->getWorldSize() > 1) { + MPI_Allreduce(&nlocal, &nglobal, 1, MPI_INT, MPI_MIN, MPI_COMM_WORLD); + min_nlocal = nglobal; + MPI_Allreduce(&nlocal, &nglobal, 1, MPI_INT, MPI_MAX, MPI_COMM_WORLD); + max_nlocal = nglobal; + MPI_Allreduce(&nghost, &nglobal, 1, MPI_INT, MPI_MIN, MPI_COMM_WORLD); + min_nghost = nglobal; + MPI_Allreduce(&nghost, &nglobal, 1, MPI_INT, MPI_MAX, MPI_COMM_WORLD); + max_nghost = nglobal; + } + + if(ps->getDomainPartitioner()->getRank() == 0) { + std::cout << "Number of local particles: " << min_nlocal << " / " << max_nlocal << std::endl; + std::cout << "Number of ghost particles: " << min_nghost << " / " << max_nghost << std::endl; + } +} + +} diff --git a/src/pairs/code_gen/cgen.py b/src/pairs/code_gen/cgen.py index 03c52993bf4dbf408a0ad0cce3cf99d6f425179b..a053d942e72fabf44dba726c8bd6c4e93a919f5e 100644 --- a/src/pairs/code_gen/cgen.py +++ b/src/pairs/code_gen/cgen.py @@ -77,6 +77,7 @@ class CGen: self.print("#include \"runtime/dem_sc_grid.hpp\"") self.print("#include \"runtime/pairs.hpp\"") self.print("#include \"runtime/read_from_file.hpp\"") + self.print("#include \"runtime/stats.hpp\"") self.print("#include \"runtime/timing.hpp\"") self.print("#include \"runtime/thermo.hpp\"") self.print("#include \"runtime/vtk.hpp\"") @@ -135,6 +136,7 @@ class CGen: self.print(" LIKWID_MARKER_CLOSE;") self.print(" pairs::print_timers(pairs);") + self.print(" pairs::print_stats(pairs, nlocal, nghost);") self.print(" delete pairs;") self.print(" return 0;") self.print("}")