Skip to content
Snippets Groups Projects
Commit 93ed68ea authored by Rafael Ravedutti's avatar Rafael Ravedutti
Browse files

Fix copper lattice setup when using several ranks

parent b6b9596a
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
......
......@@ -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>
......
......@@ -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;
......
......@@ -19,7 +19,7 @@ void stop_timer(PairsSimulation *ps, int id) {
}
void print_timers(PairsSimulation *ps) {
ps->getTimers()->print();
ps->printTimers();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment