From 93ed68eaedbd4f779d232519beb754041a030068 Mon Sep 17 00:00:00 2001 From: Rafael Ravedutti <rafaelravedutti@gmail.com> Date: Tue, 28 Nov 2023 03:21:41 +0100 Subject: [PATCH] Fix copper lattice setup when using several ranks Signed-off-by: Rafael Ravedutti <rafaelravedutti@gmail.com> --- runtime/copper_fcc_lattice.hpp | 8 +------- runtime/pairs.hpp | 5 +++++ runtime/thermo.hpp | 6 +++--- runtime/timing.hpp | 2 +- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/runtime/copper_fcc_lattice.hpp b/runtime/copper_fcc_lattice.hpp index e1b063b..c883d65 100644 --- a/runtime/copper_fcc_lattice.hpp +++ b/runtime/copper_fcc_lattice.hpp @@ -73,7 +73,7 @@ double copper_fcc_lattice(PairsSimulation *ps, int nx, int ny, int nz, double xp double ylo = 0.0, yhi = yprd; double zlo = 0.0, zhi = zprd; int natoms = 0; - int natoms_expected = 4 * nx * ny * nz; + //int natoms_expected = 4 * nx * ny * nz; double alat = pow((4.0 / rho), (1.0 / 3.0)); int ilo = (int) (xlo / (0.5 * alat) - 1); @@ -142,12 +142,6 @@ double copper_fcc_lattice(PairsSimulation *ps, int nx, int ny, int nz, double xp if(oy * subboxdim > jhi) { oy = 0; oz++; } } - if(natoms != natoms_expected) { - std::cerr << "copper_fcc_lattice(): incorrect number of atoms " - << "(" << natoms << " / " << natoms_expected << ")" << std::endl; - exit(-1); - } - return natoms; } diff --git a/runtime/pairs.hpp b/runtime/pairs.hpp index 74aa5ed..aa6be15 100644 --- a/runtime/pairs.hpp +++ b/runtime/pairs.hpp @@ -171,6 +171,11 @@ public: void fillCommunicationArrays(int neighbor_ranks[], int pbc[], real_t subdom[]); void sync() { device_synchronize(); } + void printTimers() { + if(this->getDomainPartitioner()->getRank() == 0) { + this->getTimers()->print(); + } + } }; template<typename T_ptr> diff --git a/runtime/thermo.hpp b/runtime/thermo.hpp index 7c999d6..8f00fd2 100644 --- a/runtime/thermo.hpp +++ b/runtime/thermo.hpp @@ -15,7 +15,7 @@ double compute_thermo(PairsSimulation *ps, int nlocal, double xprd, double yprd, if(ps->getDomainPartitioner()->getWorldSize() > 1) { int global_natoms; - MPI_Reduce(&natoms, &global_natoms, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD); + MPI_Allreduce(&natoms, &global_natoms, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD); natoms = global_natoms; } @@ -37,7 +37,7 @@ double compute_thermo(PairsSimulation *ps, int nlocal, double xprd, double yprd, if(ps->getDomainPartitioner()->getWorldSize() > 1) { double global_t; - MPI_Reduce(&t, &global_t, 1, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD); + MPI_Allreduce(&t, &global_t, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); t = global_t; } @@ -66,7 +66,7 @@ void adjust_thermo(PairsSimulation *ps, int nlocal, double xprd, double yprd, do if(ps->getDomainPartitioner()->getWorldSize() > 1) { int global_natoms; - MPI_Reduce(&natoms, &global_natoms, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD); + MPI_Allreduce(&natoms, &global_natoms, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD); natoms = global_natoms; MPI_Allreduce(&vxtot, &tmp, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); vxtot = tmp / natoms; diff --git a/runtime/timing.hpp b/runtime/timing.hpp index 671a48b..6c35e22 100644 --- a/runtime/timing.hpp +++ b/runtime/timing.hpp @@ -19,7 +19,7 @@ void stop_timer(PairsSimulation *ps, int id) { } void print_timers(PairsSimulation *ps) { - ps->getTimers()->print(); + ps->printTimers(); } } -- GitLab