NAMD
Public Member Functions | List of all members
NamdHybridLB Class Reference

#include <NamdHybridLB.h>

Inheritance diagram for NamdHybridLB:

Public Member Functions

 NamdHybridLB (const CkLBOptions &opt)
 Default constructor. More...
 
 NamdHybridLB (CkMigrateMessage *m)
 
void UpdateLocalLBInfo (LocalLBInfoMsg *msg)
 
void splitComputes (SplitComputesMsg *)
 

Detailed Description

Definition at line 56 of file NamdHybridLB.h.

Constructor & Destructor Documentation

NamdHybridLB::NamdHybridLB ( const CkLBOptions &  opt)

Default constructor.

Definition at line 65 of file NamdHybridLB.C.

References AllocateNamdCentLB(), AllocateNamdDummyLB(), SimParameters::hybridGroupSize, Node::Object(), Node::simParameters, and simParams.

65  : HybridBaseLB(opt)
66 {
67  // setting the name
68  lbname = (char *)"NamdHybridLB";
69 
70  delete tree; // delete the tree built from the base class
72  if (CkNumPes() <= simParams->hybridGroupSize) {
73  tree = new TwoLevelTree; // similar to centralized load balancing
74  }
75  else {
76  tree = new ThreeLevelTree(simParams->hybridGroupSize);
77  initTree();
78  // can only do shrink strategy on levels > 1
79  statsStrategy = SHRINK_NULL;
80  }
81 
82  // initializing thisProxy
83  thisProxy = CProxy_NamdHybridLB(thisgroup);
84 
85  // initializing the central LB
86  centralLB = AllocateNamdCentLB();
87 
88  // initializing the dummy LB
89  dummyLB = AllocateNamdDummyLB();
90 
91  // assigning initial values to variables
92  from_procs = NULL;
93  computeArray = NULL;
94  patchArray = NULL;
95  processorArray = NULL;
96  updateCount = 0;
97  splitCount = 0;
98  splitComputesMsgs = 0;
99  updateFlag = false;
100  collectFlag = false;
101 
102 }
static Node * Object()
Definition: Node.h:86
NamdDummyLB * AllocateNamdDummyLB()
Definition: NamdDummyLB.C:20
NamdCentLB * AllocateNamdCentLB()
Definition: NamdCentLB.C:38
SimParameters * simParameters
Definition: Node.h:178
#define simParams
Definition: Output.C:127
NamdHybridLB::NamdHybridLB ( CkMigrateMessage *  m)
inline

Definition at line 60 of file NamdHybridLB.h.

60 :HybridBaseLB(m) {}

Member Function Documentation

void NamdHybridLB::splitComputes ( SplitComputesMsg msg)

Definition at line 219 of file NamdHybridLB.C.

References SplitComputesMsg::averageLoad, averageLoad, SplitComputesMsg::avgCompute, SplitComputesMsg::cid, SimParameters::LCPOOn, SimParameters::ldbRelativeGrainsize, SplitComputesMsg::load, SplitComputesMsg::maxCompute, SplitComputesMsg::maxComputeId, SplitComputesMsg::maxUnsplit, SplitComputesMsg::n, SplitComputesMsg::nMoveableComputes, SplitComputesMsg::numPesAvailable, Node::Object(), ComputeMap::Object(), ComputeMap::setNewNumPartitions(), Node::simParameters, and simParams.

219  {
220  const int children = tree->numNodes(1);
221 
222  if ( ! splitComputesMsgs ) {
223  splitComputesMsgs = new SplitComputesMsg*[children];
224  }
225 
226  splitComputesMsgs[splitCount] = msg;
227 
228  if ( ++splitCount == children ) {
229  splitCount = 0;
230 
232  ComputeMap *computeMap = ComputeMap::Object();
233 
234  double maxUnsplit = 0.;
235  double averageLoad = 0.;
236  double avgCompute = 0.;
237  double maxCompute = 0.;
238  int maxComputeId = -1;
239  int nMoveableComputes = 0;
240  int numPesAvailable = 0;
241  int nToSplit = 0;
242 
243  for ( int j=0; j < children; ++j ) {
244  SplitComputesMsg *msg = splitComputesMsgs[j];
245  if ( msg->maxUnsplit > maxUnsplit ) { maxUnsplit = msg->maxUnsplit; }
246  if ( msg->maxCompute > maxCompute ) { maxCompute = msg->maxCompute; maxComputeId = msg->maxComputeId; }
247  averageLoad += msg->averageLoad * msg->numPesAvailable;
248  numPesAvailable += msg->numPesAvailable;
249  avgCompute += msg->avgCompute * msg->nMoveableComputes;
250  nMoveableComputes += msg->nMoveableComputes;
251  nToSplit += msg->n;
252  }
253 
254  averageLoad /= numPesAvailable;
255  if ( nMoveableComputes ) avgCompute /= nMoveableComputes; else avgCompute = 0.;
256 
257  CkPrintf("LDB: Largest compute %d load %f is %.1f%% of average load %f\n",
258  maxComputeId, maxCompute, 100. * maxCompute / averageLoad, averageLoad);
259  CkPrintf("LDB: Average compute %f is %.1f%% of average load %f\n",
260  avgCompute, 100. * avgCompute / averageLoad, averageLoad);
261 
262  if ( ! nToSplit ) {
263  for ( int j=0; j < children; ++j ) {
264  delete splitComputesMsgs[j];
265  }
266  } else {
267  // partitions are stored as char but mostly limited by
268  // high load noise at low outer-loop iteration counts
269  int maxParts = 10;
270 #if defined(NAMD_CUDA) || defined(NAMD_HIP)
271 //split LCPO compute very small, else CUDA compute is delayed
272  if (simParams->LCPOOn) {
273  maxParts = 20;
274  }
275 #endif
276  int totalAddedParts = 0;
277  maxCompute = averageLoad / 10.;
278  if ( maxCompute < 2. * avgCompute ) maxCompute = 2. * avgCompute;
279  if ( simParams->ldbRelativeGrainsize > 0. ) {
280  maxCompute = averageLoad * simParams->ldbRelativeGrainsize;
281  }
282  CkPrintf("LDB: Partitioning computes with target load %f\n", maxCompute);
283 
284  for ( int j=0; j < children; ++j ) {
285  SplitComputesMsg *msg = splitComputesMsgs[j];
286  for (int i=0; i < msg->n; ++i) {
287  int nparts = (int) ceil(msg->load[i] / maxCompute);
288  if ( nparts > maxParts ) nparts = maxParts;
289  if ( nparts < 1 ) nparts = 1;
290  computeMap->setNewNumPartitions(msg->cid[i],nparts);
291  totalAddedParts += nparts - 1;
292  }
293  delete msg;
294  }
295 
296  CkPrintf("LDB: Increased migratable compute count from %d to %d\n",
297  nMoveableComputes,nMoveableComputes+totalAddedParts);
298  CkPrintf("LDB: Largest unpartitionable compute is %f\n", maxUnsplit);
299  }
300  }
301 }
static Node * Object()
Definition: Node.h:86
void setNewNumPartitions(ComputeID cid, char numPartitions)
Definition: ComputeMap.h:144
BigReal ldbRelativeGrainsize
SimParameters * simParameters
Definition: Node.h:178
static double averageLoad
Definition: ProxyMgr.C:696
#define simParams
Definition: Output.C:127
static ComputeMap * Object()
Definition: ComputeMap.h:89
void NamdHybridLB::UpdateLocalLBInfo ( LocalLBInfoMsg msg)

Updates the compute map with the migration information from its children.

Definition at line 178 of file NamdHybridLB.C.

References cpuloads, LocalLBInfoMsg::cpuloads, LdbIdField(), LocalLBInfoMsg::moves, LocalLBInfoMsg::n_moves, ComputeMap::Object(), ComputeMap::setNewNode(), and LocalLBInfoMsg::startPE.

178  {
179  int children;
180  int i;
181 
182  // getting the number of children
183  children = tree->numNodes(currentLevel);
184  // CkPrintf("[%d] Updating compute map, total %d\n",CkMyPe(),siblings);
185 
186  // getting the compute map to insert the changes coming from the children
187  ComputeMap *computeMap = ComputeMap::Object();
188 
189  // traversing the set of moves in msg
190  for(i=0; i<msg->n_moves; i++){
191  if (msg->moves[i].to_pe != -1)
192  computeMap->setNewNode(LdbIdField(msg->moves[i].obj.id, 0),msg->moves[i].to_pe);
193  }
194 
195  // CODING
196  // updating cpuloads array
197  for(i=msg->startPE; i<=msg->endPE; i++){
198  cpuloads[i] = msg->cpuloads[i-msg->startPE];
199  }
200 
201  // checking if all children have sent the update
202  updateCount++;
203  if(updateCount == children){
204  updateCount = 0;
205  updateFlag = true;
206  // CkPrintf("[%d] UPDATE READY\n",CkMyPe());
207  }
208 
209  // checking if the collect info is ready
210  if(updateFlag && collectFlag){
211  updateFlag = false;
212  collectFlag = false;
213  thisProxy[parent_backup].CollectInfo(loc_backup, n_backup, fromlevel_backup);
214  }
215 
216  delete msg;
217 }
double * cpuloads
Definition: NamdCentLB.C:24
double * cpuloads
Definition: NamdHybridLB.h:37
void setNewNode(ComputeID cid, NodeID node)
Definition: ComputeMap.h:120
const int & LdbIdField(const LdbId &id, const int index)
MigrateInfo * moves
Definition: NamdHybridLB.h:36
static ComputeMap * Object()
Definition: ComputeMap.h:89

The documentation for this class was generated from the following files: