NamdHybridLB Class Reference

#include <NamdHybridLB.h>

List of all members.

Public Member Functions

 NamdHybridLB (const CkLBOptions &opt)
 Default constructor.
 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.

00065                                                 : HybridBaseLB(opt)
00066 {
00067   // setting the name
00068   lbname = (char *)"NamdHybridLB";
00069 
00070   delete tree;        // delete the tree built from the base class
00071   const SimParameters* simParams = Node::Object()->simParameters;
00072   if (CkNumPes() <= simParams->hybridGroupSize)  {
00073     tree = new TwoLevelTree;   // similar to centralized load balancing
00074   }
00075   else {
00076     tree = new ThreeLevelTree(simParams->hybridGroupSize);
00077     initTree();
00078     // can only do shrink strategy on levels > 1
00079     statsStrategy = SHRINK_NULL;
00080   }
00081 
00082   // initializing thisProxy
00083   thisProxy = CProxy_NamdHybridLB(thisgroup);
00084   
00085   // initializing the central LB
00086   centralLB = AllocateNamdCentLB();
00087 
00088   // initializing the dummy LB
00089   dummyLB = AllocateNamdDummyLB();
00090 
00091   // assigning initial values to variables
00092   from_procs = NULL;
00093   computeArray = NULL;
00094   patchArray = NULL;
00095   processorArray = NULL;
00096   updateCount = 0;
00097   splitCount = 0;
00098   splitComputesMsgs = 0;
00099   updateFlag = false;
00100   collectFlag = false;
00101 
00102 }

NamdHybridLB::NamdHybridLB ( CkMigrateMessage *  m  )  [inline]

Definition at line 60 of file NamdHybridLB.h.

00060 :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, j, SimParameters::LCPOOn, SimParameters::ldbRelativeGrainsize, SplitComputesMsg::load, SplitComputesMsg::maxCompute, SplitComputesMsg::maxComputeId, SplitComputesMsg::maxUnsplit, SplitComputesMsg::n, SplitComputesMsg::nMoveableComputes, SplitComputesMsg::numPesAvailable, ComputeMap::Object(), Node::Object(), ComputeMap::setNewNumPartitions(), Node::simParameters, and simParams.

00219                                                       {
00220   const int children = tree->numNodes(1);
00221 
00222   if ( ! splitComputesMsgs ) {
00223     splitComputesMsgs = new SplitComputesMsg*[children];
00224   }
00225   
00226   splitComputesMsgs[splitCount] = msg;
00227 
00228   if ( ++splitCount == children ) {
00229     splitCount = 0;
00230 
00231     const SimParameters* simParams = Node::Object()->simParameters;
00232     ComputeMap *computeMap = ComputeMap::Object();
00233 
00234     double maxUnsplit = 0.;
00235     double averageLoad = 0.;
00236     double avgCompute = 0.;
00237     double maxCompute = 0.;
00238     int maxComputeId = -1;
00239     int nMoveableComputes = 0;
00240     int numPesAvailable = 0;
00241     int nToSplit = 0;
00242 
00243     for ( int j=0; j < children; ++j ) {
00244       SplitComputesMsg *msg = splitComputesMsgs[j];
00245       if ( msg->maxUnsplit > maxUnsplit ) { maxUnsplit = msg->maxUnsplit; }
00246       if ( msg->maxCompute > maxCompute ) { maxCompute = msg->maxCompute; maxComputeId = msg->maxComputeId; }
00247       averageLoad += msg->averageLoad * msg->numPesAvailable;
00248       numPesAvailable += msg->numPesAvailable;
00249       avgCompute += msg->avgCompute * msg->nMoveableComputes;
00250       nMoveableComputes += msg->nMoveableComputes;
00251       nToSplit += msg->n;
00252     }
00253     
00254     averageLoad /= numPesAvailable;
00255     if ( nMoveableComputes ) avgCompute /= nMoveableComputes; else avgCompute = 0.;
00256 
00257     CkPrintf("LDB: Largest compute %d load %f is %.1f%% of average load %f\n",
00258             maxComputeId, maxCompute, 100. * maxCompute / averageLoad, averageLoad);
00259     CkPrintf("LDB: Average compute %f is %.1f%% of average load %f\n",
00260             avgCompute, 100. * avgCompute / averageLoad, averageLoad);
00261 
00262     if ( ! nToSplit ) {
00263       for ( int j=0; j < children; ++j ) {
00264         delete splitComputesMsgs[j];
00265       }
00266     } else {
00267       // partitions are stored as char but mostly limited by
00268       // high load noise at low outer-loop iteration counts
00269       int maxParts = 10;
00270 #ifdef NAMD_CUDA
00271 //split LCPO compute very small, else CUDA compute is delayed
00272       if (simParams->LCPOOn) {
00273         maxParts = 20;
00274       }
00275 #endif
00276       int totalAddedParts = 0;
00277       maxCompute = averageLoad / 10.;
00278       if ( maxCompute < 2. * avgCompute ) maxCompute = 2. * avgCompute;
00279       if ( simParams->ldbRelativeGrainsize > 0. ) {
00280         maxCompute = averageLoad * simParams->ldbRelativeGrainsize;
00281       }
00282       CkPrintf("LDB: Partitioning computes with target load %f\n", maxCompute);
00283 
00284       for ( int j=0; j < children; ++j ) {
00285         SplitComputesMsg *msg = splitComputesMsgs[j];
00286         for (int i=0; i < msg->n; ++i) {
00287           int nparts = (int) ceil(msg->load[i] / maxCompute);
00288           if ( nparts > maxParts ) nparts = maxParts;
00289           if ( nparts < 1 ) nparts = 1;
00290           computeMap->setNewNumPartitions(msg->cid[i],nparts);
00291           totalAddedParts += nparts - 1;
00292         }
00293         delete msg;
00294       }
00295 
00296       CkPrintf("LDB: Increased migratable compute count from %d to %d\n",
00297               nMoveableComputes,nMoveableComputes+totalAddedParts);
00298       CkPrintf("LDB: Largest unpartitionable compute is %f\n", maxUnsplit);
00299     }
00300   }
00301 }

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 LocalLBInfoMsg::cpuloads, cpuloads, LdbIdField(), LocalLBInfoMsg::moves, LocalLBInfoMsg::n_moves, ComputeMap::Object(), ComputeMap::setNewNode(), and LocalLBInfoMsg::startPE.

00178                                                        {
00179         int children;
00180         int i;
00181 
00182         // getting the number of children
00183         children = tree->numNodes(currentLevel);
00184         // CkPrintf("[%d] Updating compute map, total %d\n",CkMyPe(),siblings);
00185 
00186         // getting the compute map to insert the changes coming from the children
00187         ComputeMap *computeMap = ComputeMap::Object();
00188 
00189         // traversing the set of moves in msg
00190         for(i=0; i<msg->n_moves; i++){
00191             if (msg->moves[i].to_pe != -1)
00192                 computeMap->setNewNode(LdbIdField(msg->moves[i].obj.id, 0),msg->moves[i].to_pe);
00193         }
00194 
00195         // CODING
00196         // updating cpuloads array
00197         for(i=msg->startPE; i<=msg->endPE; i++){
00198                 cpuloads[i] = msg->cpuloads[i-msg->startPE];
00199         }
00200 
00201         // checking if all children have sent the update
00202         updateCount++;
00203         if(updateCount == children){
00204                 updateCount = 0;
00205                 updateFlag = true;
00206                  // CkPrintf("[%d] UPDATE READY\n",CkMyPe());           
00207         }
00208 
00209         // checking if the collect info is ready
00210         if(updateFlag && collectFlag){
00211                 updateFlag = false;
00212                 collectFlag = false;    
00213                 thisProxy[parent_backup].CollectInfo(loc_backup, n_backup, fromlevel_backup);
00214         }
00215 
00216         delete msg;
00217 }


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

Generated on 21 Sep 2020 for NAMD by  doxygen 1.6.1