update load balancing output to use utils::logmesg() and {fmt}
This commit is contained in:
@ -39,6 +39,8 @@
|
|||||||
#include "imbalance_var.h"
|
#include "imbalance_var.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
@ -366,12 +368,10 @@ void Balance::command(int narg, char **arg)
|
|||||||
bigint natoms;
|
bigint natoms;
|
||||||
bigint nblocal = atom->nlocal;
|
bigint nblocal = atom->nlocal;
|
||||||
MPI_Allreduce(&nblocal,&natoms,1,MPI_LMP_BIGINT,MPI_SUM,world);
|
MPI_Allreduce(&nblocal,&natoms,1,MPI_LMP_BIGINT,MPI_SUM,world);
|
||||||
if (natoms != atom->natoms) {
|
if (natoms != atom->natoms)
|
||||||
char str[128];
|
error->all(FLERR,fmt::format("Lost atoms via balance: "
|
||||||
sprintf(str,"Lost atoms via balance: original " BIGINT_FORMAT
|
"original {} current {}",
|
||||||
" current " BIGINT_FORMAT,atom->natoms,natoms);
|
atom->natoms,natoms).c_str());
|
||||||
error->all(FLERR,str);
|
|
||||||
}
|
|
||||||
|
|
||||||
// imbfinal = final imbalance
|
// imbfinal = final imbalance
|
||||||
// set disable = 1, so weights no longer migrate with atoms
|
// set disable = 1, so weights no longer migrate with atoms
|
||||||
@ -382,60 +382,29 @@ void Balance::command(int narg, char **arg)
|
|||||||
|
|
||||||
// stats output
|
// stats output
|
||||||
|
|
||||||
double stop_time = MPI_Wtime();
|
|
||||||
|
|
||||||
if (me == 0) {
|
if (me == 0) {
|
||||||
if (screen) {
|
std::string mesg = fmt::format(" rebalancing time: {:.3f} seconds\n",
|
||||||
fprintf(screen," rebalancing time: %g seconds\n",stop_time-start_time);
|
MPI_Wtime()-start_time);
|
||||||
fprintf(screen," iteration count = %d\n",niter);
|
mesg += fmt::format(" iteration count = {}\n",niter);
|
||||||
for (int i = 0; i < nimbalance; ++i) imbalances[i]->info(screen);
|
for (int i = 0; i < nimbalance; ++i) mesg += imbalances[i]->info();
|
||||||
fprintf(screen," initial/final max load/proc = %g %g\n",
|
mesg += fmt::format(" initial/final maximal load/proc = {} {}\n"
|
||||||
maxinit,maxfinal);
|
" initial/final imbalance factor = {:.6g} {:.6g}\n",
|
||||||
fprintf(screen," initial/final imbalance factor = %g %g\n",
|
maxinit,maxfinal,imbinit,imbfinal);
|
||||||
imbinit,imbfinal);
|
|
||||||
}
|
|
||||||
if (logfile) {
|
|
||||||
fprintf(logfile," rebalancing time: %g seconds\n",stop_time-start_time);
|
|
||||||
fprintf(logfile," iteration count = %d\n",niter);
|
|
||||||
for (int i = 0; i < nimbalance; ++i) imbalances[i]->info(logfile);
|
|
||||||
fprintf(logfile," initial/final max load/proc = %g %g\n",
|
|
||||||
maxinit,maxfinal);
|
|
||||||
fprintf(logfile," initial/final imbalance factor = %g %g\n",
|
|
||||||
imbinit,imbfinal);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (style != BISECTION) {
|
if (style != BISECTION) {
|
||||||
if (me == 0) {
|
mesg += " x cuts:";
|
||||||
if (screen) {
|
for (int i = 0; i <= comm->procgrid[0]; i++)
|
||||||
fprintf(screen," x cuts:");
|
mesg += fmt::format(" {}",comm->xsplit[i]);
|
||||||
for (int i = 0; i <= comm->procgrid[0]; i++)
|
mesg += "\n y cuts:";
|
||||||
fprintf(screen," %g",comm->xsplit[i]);
|
for (int i = 0; i <= comm->procgrid[1]; i++)
|
||||||
fprintf(screen,"\n");
|
mesg += fmt::format(" {}",comm->ysplit[i]);
|
||||||
fprintf(screen," y cuts:");
|
mesg += "\n z cuts:";
|
||||||
for (int i = 0; i <= comm->procgrid[1]; i++)
|
for (int i = 0; i <= comm->procgrid[2]; i++)
|
||||||
fprintf(screen," %g",comm->ysplit[i]);
|
mesg += fmt::format(" {}",comm->zsplit[i]);
|
||||||
fprintf(screen,"\n");
|
mesg += "\n";
|
||||||
fprintf(screen," z cuts:");
|
|
||||||
for (int i = 0; i <= comm->procgrid[2]; i++)
|
|
||||||
fprintf(screen," %g",comm->zsplit[i]);
|
|
||||||
fprintf(screen,"\n");
|
|
||||||
}
|
|
||||||
if (logfile) {
|
|
||||||
fprintf(logfile," x cuts:");
|
|
||||||
for (int i = 0; i <= comm->procgrid[0]; i++)
|
|
||||||
fprintf(logfile," %g",comm->xsplit[i]);
|
|
||||||
fprintf(logfile,"\n");
|
|
||||||
fprintf(logfile," y cuts:");
|
|
||||||
for (int i = 0; i <= comm->procgrid[1]; i++)
|
|
||||||
fprintf(logfile," %g",comm->ysplit[i]);
|
|
||||||
fprintf(logfile,"\n");
|
|
||||||
fprintf(logfile," z cuts:");
|
|
||||||
for (int i = 0; i <= comm->procgrid[2]; i++)
|
|
||||||
fprintf(logfile," %g",comm->zsplit[i]);
|
|
||||||
fprintf(logfile,"\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
utils::logmesg(lmp,mesg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -587,7 +587,7 @@ void CreateAtoms::command(int narg, char **arg)
|
|||||||
MPI_Barrier(world);
|
MPI_Barrier(world);
|
||||||
if (me == 0)
|
if (me == 0)
|
||||||
utils::logmesg(lmp, fmt::format("Created {} atoms\n"
|
utils::logmesg(lmp, fmt::format("Created {} atoms\n"
|
||||||
" create_atoms CPU = {:.3g} seconds\n",
|
" create_atoms CPU = {:.3f} seconds\n",
|
||||||
atom->natoms - natoms_previous,
|
atom->natoms - natoms_previous,
|
||||||
MPI_Wtime() - time1));
|
MPI_Wtime() - time1));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,6 +15,7 @@
|
|||||||
#define LMP_IMBALANCE_H
|
#define LMP_IMBALANCE_H
|
||||||
|
|
||||||
#include "pointers.h" // IWYU pragma: export
|
#include "pointers.h" // IWYU pragma: export
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
@ -30,7 +31,7 @@ class Imbalance : protected Pointers {
|
|||||||
// compute and apply weight factors to local atom array (required)
|
// compute and apply weight factors to local atom array (required)
|
||||||
virtual void compute(double *) = 0;
|
virtual void compute(double *) = 0;
|
||||||
// print information about the state of this imbalance compute (required)
|
// print information about the state of this imbalance compute (required)
|
||||||
virtual void info(FILE *) = 0;
|
virtual std::string info() = 0;
|
||||||
|
|
||||||
// disallow default and copy constructor, assignment operator
|
// disallow default and copy constructor, assignment operator
|
||||||
// private:
|
// private:
|
||||||
|
|||||||
@ -16,6 +16,8 @@
|
|||||||
#include "force.h"
|
#include "force.h"
|
||||||
#include "group.h"
|
#include "group.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include <string>
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
@ -75,14 +77,17 @@ void ImbalanceGroup::compute(double *weight)
|
|||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
|
|
||||||
void ImbalanceGroup::info(FILE *fp)
|
std::string ImbalanceGroup::info()
|
||||||
{
|
{
|
||||||
|
std::string mesg = "";
|
||||||
|
|
||||||
if (num > 0) {
|
if (num > 0) {
|
||||||
const char * const * const names = group->names;
|
const char * const * const names = group->names;
|
||||||
|
|
||||||
fprintf(fp," group weights:");
|
mesg += " group weights:";
|
||||||
for (int i = 0; i < num; ++i)
|
for (int i = 0; i < num; ++i)
|
||||||
fprintf(fp," %s=%g",names[id[i]],factor[i]);
|
mesg += fmt::format(" {}={}",names[id[i]],factor[i]);
|
||||||
fputs("\n",fp);
|
mesg += "\n";
|
||||||
}
|
}
|
||||||
|
return mesg;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,11 +24,11 @@ class ImbalanceGroup : public Imbalance {
|
|||||||
virtual ~ImbalanceGroup();
|
virtual ~ImbalanceGroup();
|
||||||
|
|
||||||
// parse options, return number of arguments consumed
|
// parse options, return number of arguments consumed
|
||||||
virtual int options(int, char **);
|
virtual int options(int, char **) override;
|
||||||
// compute and apply weight factors to local atom array
|
// compute and apply weight factors to local atom array
|
||||||
virtual void compute(double *);
|
virtual void compute(double *) override;
|
||||||
// print information about the state of this imbalance compute
|
// print information about the state of this imbalance compute
|
||||||
virtual void info(FILE *);
|
virtual std::string info() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int num; // number of groups with weights
|
int num; // number of groups with weights
|
||||||
|
|||||||
@ -20,6 +20,7 @@
|
|||||||
#include "neigh_request.h"
|
#include "neigh_request.h"
|
||||||
#include "neigh_list.h"
|
#include "neigh_list.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
@ -106,7 +107,7 @@ void ImbalanceNeigh::compute(double *weight)
|
|||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
|
|
||||||
void ImbalanceNeigh::info(FILE *fp)
|
std::string ImbalanceNeigh::info()
|
||||||
{
|
{
|
||||||
fprintf(fp," neigh weight factor: %g\n",factor);
|
return fmt::format(" neighbor weight factor: {}\n",factor);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,11 +25,11 @@ class ImbalanceNeigh : public Imbalance {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// parse options, return number of arguments consumed
|
// parse options, return number of arguments consumed
|
||||||
virtual int options(int, char **);
|
virtual int options(int, char **) override;
|
||||||
// compute and apply weight factors to local atom array
|
// compute and apply weight factors to local atom array
|
||||||
virtual void compute(double *);
|
virtual void compute(double *) override;
|
||||||
// print information about the state of this imbalance compute
|
// print information about the state of this imbalance compute
|
||||||
virtual void info(FILE *);
|
virtual std::string info() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double factor; // weight factor for neighbor imbalance
|
double factor; // weight factor for neighbor imbalance
|
||||||
|
|||||||
@ -15,6 +15,7 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include "atom.h"
|
#include "atom.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
@ -62,7 +63,7 @@ void ImbalanceStore::compute(double *weight)
|
|||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
|
|
||||||
void ImbalanceStore::info(FILE *fp)
|
std::string ImbalanceStore::info()
|
||||||
{
|
{
|
||||||
fprintf(fp," storing weight in atom property d_%s\n",name);
|
return fmt::format(" storing weight in atom property d_{}\n",name);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,11 +25,11 @@ class ImbalanceStore : public Imbalance {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// parse options, return number of arguments consumed
|
// parse options, return number of arguments consumed
|
||||||
virtual int options(int, char **);
|
virtual int options(int, char **) override;
|
||||||
// compute per-atom imbalance and apply to weight array
|
// compute per-atom imbalance and apply to weight array
|
||||||
virtual void compute(double *);
|
virtual void compute(double *) override;
|
||||||
// print information about the state of this imbalance compute (required)
|
// print information about the state of this imbalance compute (required)
|
||||||
virtual void info(FILE *);
|
virtual std::string info() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char *name; // property name
|
char *name; // property name
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
#include "force.h"
|
#include "force.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
@ -104,7 +105,7 @@ void ImbalanceTime::compute(double *weight)
|
|||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
|
|
||||||
void ImbalanceTime::info(FILE *fp)
|
std::string ImbalanceTime::info()
|
||||||
{
|
{
|
||||||
fprintf(fp," time weight factor: %g\n",factor);
|
return fmt::format(" time weight factor: {}\n",factor);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,13 +25,13 @@ class ImbalanceTime : public Imbalance {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// parse options, return number of arguments consumed
|
// parse options, return number of arguments consumed
|
||||||
virtual int options(int, char **);
|
virtual int options(int, char **) override;
|
||||||
// reinitialize internal data
|
// reinitialize internal data
|
||||||
virtual void init(int);
|
virtual void init(int) override;
|
||||||
// compute and apply weight factors to local atom array
|
// compute and apply weight factors to local atom array
|
||||||
virtual void compute(double *);
|
virtual void compute(double *) override;
|
||||||
// print information about the state of this imbalance compute
|
// print information about the state of this imbalance compute
|
||||||
virtual void info(FILE *);
|
virtual std::string info() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double factor; // weight factor for time imbalance
|
double factor; // weight factor for time imbalance
|
||||||
|
|||||||
@ -20,6 +20,7 @@
|
|||||||
#include "variable.h"
|
#include "variable.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
@ -88,7 +89,7 @@ void ImbalanceVar::compute(double *weight)
|
|||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
|
|
||||||
void ImbalanceVar::info(FILE *fp)
|
std::string ImbalanceVar::info()
|
||||||
{
|
{
|
||||||
fprintf(fp," weight variable: %s\n",name);
|
return fmt::format(" weight variable: {}\n",name);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,13 +25,13 @@ class ImbalanceVar : public Imbalance {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// parse options. return number of arguments consumed.
|
// parse options. return number of arguments consumed.
|
||||||
virtual int options(int, char **);
|
virtual int options(int, char **) override;
|
||||||
// re-initialize internal data, e.g. variable ID
|
// re-initialize internal data, e.g. variable ID
|
||||||
virtual void init(int);
|
virtual void init(int) override;
|
||||||
// compute per-atom imbalance and apply to weight array
|
// compute per-atom imbalance and apply to weight array
|
||||||
virtual void compute(double *);
|
virtual void compute(double *) override;
|
||||||
// print information about the state of this imbalance compute (required)
|
// print information about the state of this imbalance compute (required)
|
||||||
virtual void info(FILE *);
|
virtual std::string info() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char *name; // variable name
|
char *name; // variable name
|
||||||
|
|||||||
Reference in New Issue
Block a user