NamdHybridLB Class Reference

#include <NamdHybridLB.h>

List of all members.

Public Member Functions

 NamdHybridLB ()
 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 (  ) 

Default constructor.

Definition at line 64 of file NamdHybridLB.C.

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

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

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

Definition at line 60 of file NamdHybridLB.h.

00060 :HybridBaseLB(m) {}


Member Function Documentation

void NamdHybridLB::splitComputes ( SplitComputesMsg  ) 

Definition at line 218 of file NamdHybridLB.C.

References SplitComputesMsg::averageLoad, averageLoad, SplitComputesMsg::avgCompute, j, SplitComputesMsg::maxCompute, SplitComputesMsg::maxComputeId, SplitComputesMsg::maxUnsplit, SplitComputesMsg::n, SplitComputesMsg::nMoveableComputes, SplitComputesMsg::numPesAvailable, ComputeMap::Object(), Node::Object(), Node::simParameters, and simParams.

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

void NamdHybridLB::UpdateLocalLBInfo ( LocalLBInfoMsg msg  ) 

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

Definition at line 177 of file NamdHybridLB.C.

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

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


The documentation for this class was generated from the following files:
Generated on Mon Sep 25 01:17:19 2017 for NAMD by  doxygen 1.4.7