Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F83565529
imbalance_time.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Sep 17, 20:28
Size
2 KB
Mime Type
text/x-c
Expires
Thu, Sep 19, 20:28 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
20856333
Attached To
rLAMMPS lammps
imbalance_time.cpp
View Options
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#include <mpi.h>
#include "imbalance_time.h"
#include "atom.h"
#include "comm.h"
#include "force.h"
#include "timer.h"
#include "error.h"
using namespace LAMMPS_NS;
/* -------------------------------------------------------------------- */
ImbalanceTime::ImbalanceTime(LAMMPS *lmp) : Imbalance(lmp) {}
/* -------------------------------------------------------------------- */
int ImbalanceTime::options(int narg, char **arg)
{
if (narg < 1) error->all(FLERR,"Illegal balance weight command");
factor = force->numeric(FLERR,arg[0]);
if (factor < 0.0) error->all(FLERR,"Illegal balance weight command");
return 1;
}
/* ----------------------------------------------------------------------
reset last, needed for fix balance caller
------------------------------------------------------------------------- */
void ImbalanceTime::init()
{
last = 0.0;
}
/* -------------------------------------------------------------------- */
void ImbalanceTime::compute(double *weight)
{
const int nlocal = atom->nlocal;
const bigint natoms = atom->natoms;
if (factor == 0.0) return;
// compute the cost function of based on relevant timers
if (timer->has_normal()) {
double cost = -last;
cost += timer->get_wall(Timer::PAIR);
cost += timer->get_wall(Timer::NEIGH);
cost += timer->get_wall(Timer::BOND);
cost += timer->get_wall(Timer::KSPACE);
double allcost;
MPI_Allreduce(&cost,&allcost,1,MPI_DOUBLE,MPI_SUM,world);
if ((allcost > 0.0) && (nlocal > 0)) {
const double avgcost = allcost/natoms;
const double localcost = cost/nlocal;
const double scale = (1.0-factor) + factor*localcost/avgcost;
for (int i = 0; i < nlocal; ++i) weight[i] *= scale;
}
// record time up to this point
last += cost;
}
}
/* -------------------------------------------------------------------- */
void ImbalanceTime::info(FILE *fp)
{
fprintf(fp," time weight factor: %g\n",factor);
}
Event Timeline
Log In to Comment