Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

Rebalancer Class Reference

#include <Rebalancer.h>

Inheritance diagram for Rebalancer:

Alg7 AlgNbor AlgRecBisection RefineOnly RefineTorusLB TorusLB List of all members.

Public Member Functions

 Rebalancer (computeInfo *computeArray, patchInfo *patchArray, processorInfo *processorArray, int nComps, int nPatches, int nPes)
 ~Rebalancer ()

Protected Types

typedef pcpair pcgrid [3][3][2]

Protected Member Functions

int isAvailableOn (patchInfo *patch, processorInfo *p)
void numAvailable (computeInfo *c, processorInfo *p, int *nPatches, int *nProxies, int *isBadForCommunication)
void refine_togrid (pcgrid &grid, double thresholdLoad, processorInfo *p, computeInfo *c)
void strategy ()
void makeHeaps ()
void makeTwoHeaps ()
void assign (computeInfo *c, processorInfo *pRec)
void assign (computeInfo *c, int p)
void deAssign (computeInfo *c, processorInfo *pRec)
int refine ()
void multirefine (double overload_start=1.02)
void printSummary ()
void printResults ()
void printLoads ()
double computeAverage ()
void adjustBackgroundLoadAndComputeAverage ()
double computeMax ()
void createSpanningTree ()
void decrSTLoad ()
void incrSTLoad ()
void InitProxyUsage ()
void brickDim (int a, int b, int dim, int &min, int &max)
int withinBrick (int x, int y, int z, int xm, int xM, int dimX, int ym, int yM, int dimY, int zm, int zM, int dimZ)

Protected Attributes

int bytesPerAtom
ProxyUsage proxyUsage
const char * strategyName
computeInfocomputes
patchInfopatches
processorInfoprocessors
minHeappes
maxHeapcomputePairHeap
maxHeapcomputeSelfHeap
maxHeapcomputeBgPairHeap
maxHeapcomputeBgSelfHeap
int P
int numPatches
int numComputes
int numProxies
int numPesAvailable
double averageLoad
int firstAssignInRefine
double overLoad

Member Typedef Documentation

typedef pcpair Rebalancer::pcgrid[3][3][2] [protected]
 

Definition at line 124 of file Rebalancer.h.

Referenced by refine(), and refine_togrid().


Constructor & Destructor Documentation

Rebalancer::Rebalancer computeInfo computeArray,
patchInfo patchArray,
processorInfo processorArray,
int  nComps,
int  nPatches,
int  nPes
 

Definition at line 24 of file Rebalancer.C.

References processorInfo::available, processorInfo::backgroundLoad, bytesPerAtom, computeBgPairHeap, computeBgSelfHeap, processorInfo::computeLoad, computePairHeap, computes, computeSelfHeap, Set::find(), firstAssignInRefine, InitProxyUsage(), Set::insert(), InfoRecord::load, numComputes, numPatches, numPesAvailable, computeInfo::oldProcessor, overLoad, P, patches, processorInfo::patchSet, pes, printLoads(), computeInfo::processor, patchInfo::processor, processors, processorInfo::proxies, patchInfo::proxiesOn, and strategyName.

00026 {
00027    bytesPerAtom = 32;
00028    strategyName = "None";
00029    computes = computeArray;
00030    patches =  patchArray;
00031    processors =  processorArray;
00032    numComputes = nComps;
00033    numPatches = nPatches;
00034    P = nPes;
00035    pes = NULL;
00036    computePairHeap = NULL;
00037    computeSelfHeap = NULL;
00038    computeBgPairHeap = NULL;
00039    computeBgSelfHeap = NULL;
00040    overLoad = 0.;
00041    numPesAvailable = 0;
00042    firstAssignInRefine = 0;
00043 
00044    int i;
00045    for (i=0; i<P; i++)
00046    {
00047       // For testing only...
00048       // processors[i].backgroundLoad = 0;
00049       // End of test section
00050       processors[i].load = processors[i].backgroundLoad;
00051       processors[i].computeLoad = 0;
00052       if (processors[i].available) {
00053         numPesAvailable += 1;
00054       }
00055    }
00056 
00057    for (i=0; i<nPatches; i++)
00058    {
00059       if (!patches[i].proxiesOn.find(&(processors[patches[i].processor]))) 
00060       {
00061          patches[i].proxiesOn.insert(&(processors[patches[i].processor]));
00062          processors[patches[i].processor].proxies.insert(&(patches[i]));
00063       }
00064       processors[patches[i].processor].patchSet.insert(&patches[i]);
00065    }                      
00066 
00067    InitProxyUsage();
00068 
00069    for (i=0; i<numComputes; i++)
00070       computeArray[i].processor = -1;
00071 
00072    for (i=0; i < numComputes; i++)
00073       processors[computes[i].oldProcessor].computeLoad += computes[i].load;
00074 
00075    // Added 4-29-98: Temporarily adds the compute load to the background
00076    // load so that the correct value for the total load can be displayed.
00077    float *temploads = new float[P];
00078    for(i=0; i<P; i++)
00079    {
00080       temploads[i] = processors[i].load;
00081       processors[i].load += processors[i].computeLoad;
00082    }
00083 
00084    // iout << iINFO << "Initial load" << "\n";
00085    printLoads();
00086 
00087    for(i=0;i<P; i++)
00088    {
00089       processors[i].load = temploads[i];
00090       processors[i].computeLoad = 0;
00091    }
00092    
00093    delete [] temploads;
00094 
00095    // int count1=0, count2=0;
00096    // for (i=0; i<nPatches; i++)
00097    // {
00098    //    if (patches[i].proxiesOn.numElements() <= 1)
00099    //    count1++;
00100    //    else count2++;
00101    // }                   
00102    // iout << iINFO << "Count1 = " << count1
00103    //      << "Count2 = " << count2
00104    //      << "\n" << std::endl;
00105    // 
00106    // for (i=0; i <P; i++) 
00107    // {
00108    //    iout << iINFO << "\n proxies on proc. " << i << " are for patches:";
00109    //    processorArray[i].proxies->print();
00110    // }
00111    // 
00112    // iout << iINFO <<"\n" << endi;
00113    // strategy();
00114 
00115    // for (i=0; i<nPatches; i++)
00116    // {
00117    //    iout << "patch " << i << " on processor " << patches[i].processor << "\n" << endi;
00118    // }
00119 }

Rebalancer::~Rebalancer  ) 
 

Definition at line 121 of file Rebalancer.C.

00122 {
00123   //for(int i=0; i<P; i++)
00124   //  delete [] processors[i].proxyUsage;
00125    delete pes;
00126    delete computePairHeap;
00127    delete computeSelfHeap;
00128    delete computeBgPairHeap;
00129    delete computeBgSelfHeap;
00130 }


Member Function Documentation

void Rebalancer::adjustBackgroundLoadAndComputeAverage  )  [protected]
 

Definition at line 903 of file Rebalancer.C.

References processorInfo::available, processorInfo::backgroundLoad, computeAverage(), iINFO(), iout, numPesAvailable, and processors.

00904 {
00905   // useful for AlgSeven when some loads start out as zero
00906 
00907    if (numPesAvailable == 0) {
00908      computeAverage();  // because otherwise someone will forget
00909      return;
00910    }
00911   
00912    int i;
00913    double bgtotal = 0.;
00914    for (i=0; i<P; i++) {
00915       if (processors[i].available) {
00916         bgtotal += processors[i].backgroundLoad;
00917       }
00918    }
00919    double bgavg = bgtotal / numPesAvailable;
00920 
00921    int nadjusted = 0;
00922    for (i=0; i<P; i++) {
00923       if (processors[i].available) {
00924         double bgload = processors[i].backgroundLoad;
00925         if ( bgload < bgavg ) {
00926           processors[i].backgroundLoad = bgavg;
00927           ++nadjusted;
00928         }
00929       }
00930    }
00931    iout << iINFO << "Adjusted background load on " << nadjusted
00932         << " nodes.\n" << endi;
00933 
00934    computeAverage();  // because otherwise someone will forget
00935 }

void Rebalancer::assign computeInfo c,
int  p
[protected]
 

Definition at line 336 of file Rebalancer.C.

References assign(), and processors.

00337 {
00338    assign(c, &(processors[processor]));
00339 }

void Rebalancer::assign computeInfo c,
processorInfo pRec
[protected]
 

Definition at line 341 of file Rebalancer.C.

References processorInfo::backgroundLoad, processorInfo::computeLoad, processorInfo::computeSet, Set::find(), InfoRecord::Id, ProxyUsage::increment(), Set::insert(), iout, InfoRecord::load, numProxies, patches, computeInfo::processor, processors, processorInfo::proxies, patchInfo::proxiesOn, and proxyUsage.

Referenced by assign(), and RefineTorusLB::newRefine().

00342 {
00343    c->processor = p->Id;
00344    p->computeSet.insert((InfoRecord *) c);
00345 #if COMPUTE_CORRECTION
00346    if(firstAssignInRefine)
00347      p->computeLoad += c->load + COMPUTE_LOAD;
00348    else
00349 #endif
00350      p->computeLoad += c->load;
00351      
00352    p->load = p->computeLoad + p->backgroundLoad;
00353    patchInfo* patch1 = (patchInfo *) &(patches[c->patch1]);
00354    patchInfo* patch2 = (patchInfo *) &(patches[c->patch2]);
00355 
00356    if (!p->proxies.find(patch1))   p->proxies.insert(patch1); 
00357    if (!patch1->proxiesOn.find(p)) {
00358      patch1->proxiesOn.insert(p); 
00359      numProxies++;
00360 #if PROXY_CORRECTION
00361      if(firstAssignInRefine) {
00362        processors[p->Id].load += PROXY_LOAD;
00363        processors[p->Id].backgroundLoad += PROXY_LOAD;
00364      }
00365 #endif
00366    }
00367 
00368    if (!p->proxies.find(patch2))   p->proxies.insert(patch2); 
00369    if (!patch2->proxiesOn.find(p)) {
00370      patch2->proxiesOn.insert(p);
00371      numProxies++;
00372 #if PROXY_CORRECTION
00373      if(firstAssignInRefine) {
00374        processors[p->Id].load += PROXY_LOAD;
00375        processors[p->Id].backgroundLoad += PROXY_LOAD;
00376      }
00377 #endif
00378    }
00379    
00380    // 4-29-98: Added the following code to keep track of how many proxies
00381    // on each processor are being used by a compute on that processor
00382    /* int n1 = */ //p->proxyUsage[c->patch1]++;
00383    proxyUsage.increment (p->Id, c->patch1);
00384    /* int n2 = */ //p->proxyUsage[c->patch2]++;
00385    proxyUsage.increment (p->Id, c->patch2);
00386 
00387    // iout << iINFO  
00388    // << "Assigning compute " << c->Id << " with work = " << c->load 
00389    // << " to processor " << p->Id << "\n"
00390    // << "\tproxyUsage[" << c->patch1 << "]: " << n1 << " --> " << n1+1 << "\n"
00391    // << "\tproxyUsage[" << c->patch2 << "]: " << n2 << " --> " << n2+1 << "\n"
00392    // << std::endl;
00393 
00394 #if 0
00395    iout << "Assign " << c->Id << " patches " << c->patch1 << " " << c->patch2
00396         << " load " << c->load << " to " << p->Id << " new load "
00397         << p->load << " background " << p->backgroundLoad
00398         << " nPatches " << nPatches << " nProxies " << nProxies;
00399    if ( nPatches + nProxies < 2 ) iout << " addProxy";
00400    if ( badForComm ) iout << " badForComm";
00401    iout << "\n" << endi;
00402 #endif
00403 }

void Rebalancer::brickDim int  a,
int  b,
int  dim,
int &  min,
int &  max
[inline, protected]
 

brickDim This function returns the coordinates of the inner brick between any two points on the torus. The coordinates need to be seen modulo the dimension in that direction

Definition at line 176 of file Rebalancer.h.

Referenced by RefineTorusLB::newRefine().

00176                                                                   {
00177     int x1, x2, x3, x4, temp, i;
00178     if(a < b)
00179       { x1 = a; x2 = b; } 
00180     else
00181       { x1 = b; x2 = a; }
00182 
00183     x3 = x2 - x1;
00184     x4 = dim - x3;
00185     if(x3 < x4) {
00186       min = x1; max = x2;
00187     } else {
00188       min = x2; max = x1 + dim;
00189     }
00190   }

double Rebalancer::computeAverage  )  [protected]
 

Definition at line 881 of file Rebalancer.C.

References processorInfo::available, averageLoad, processorInfo::backgroundLoad, computes, InfoRecord::load, numPesAvailable, and processors.

Referenced by adjustBackgroundLoadAndComputeAverage(), RefineTorusLB::binaryRefine(), multirefine(), printLoads(), RefineOnly::RefineOnly(), and RefineTorusLB::RefineTorusLB().

00882 {
00883    int i;
00884    double total = 0.;
00885    for (i=0; i<numComputes; i++)
00886       total += computes[i].load;
00887 
00888    for (i=0; i<P; i++) {
00889       if (processors[i].available) {
00890         total += processors[i].backgroundLoad;
00891       }
00892    }
00893   
00894    if (numPesAvailable == 0) {
00895      CmiPrintf("Warning: no processors available for load balancing!\n");
00896      averageLoad = 0.0;
00897    }
00898    else 
00899      averageLoad = total/numPesAvailable;
00900    return averageLoad;
00901 }

double Rebalancer::computeMax  )  [protected]
 

Definition at line 937 of file Rebalancer.C.

References InfoRecord::load, and processors.

Referenced by RefineTorusLB::binaryRefine(), multirefine(), and printLoads().

00938 {
00939    int i;
00940    double max = processors[0].load;
00941    for (i=1; i<P; i++)
00942    {
00943       if (processors[i].load > max) 
00944          max = processors[i].load;
00945    }
00946    return max;
00947 }

void Rebalancer::createSpanningTree  )  [protected]
 

Definition at line 1022 of file Rebalancer.C.

References ProxyMgr::buildSpanningTree0(), ProxyMgr::getPtree(), InfoRecord::Id, Iterator::id, Set::iterator(), j, Set::next(), PatchMap::node(), NodeIDList, PatchMap::Object(), ProxyMgr::Object(), patches, patchInfo::proxiesOn, ProxyTree::proxylist, ResizeArray< Elem >::resize(), and ProxyTree::sizes.

Referenced by RefineOnly::RefineOnly(), and RefineTorusLB::RefineTorusLB().

01022                                     {
01023   ProxyTree &pt = ProxyMgr::Object()->getPtree();
01024   Iterator nextP;
01025   processorInfo *p;
01026 #ifndef NODEAWARE_PROXY_SPANNINGTREE
01027   if(pt.sizes==NULL)
01028     pt.sizes = new int[numPatches];
01029 #endif
01030  
01031   if (pt.proxylist == NULL)
01032     pt.proxylist = new NodeIDList[numPatches];
01033   for(int i=0; i<numPatches; i++)
01034   {
01035     pt.proxylist[i].resize(patches[i].proxiesOn.numElements());
01036     nextP.id = 0;
01037     p = (processorInfo *)(patches[i].proxiesOn.iterator((Iterator *)&nextP));
01038     int j = 0;
01039     while(p) {
01040       //if (p->Id < 0)
01041       //  printf ("Inserting proxy on -ve processor %d for patch %d\n", p->Id, i);
01042 
01043       if (p->Id == (PatchMap::Object()->node(i))) {
01044         p = (processorInfo *)(patches[i].proxiesOn.next((Iterator *)&nextP));
01045         continue;
01046       }
01047 
01048       pt.proxylist[i][j] = p->Id;
01049       nextP.id++;
01050       p = (processorInfo *)(patches[i].proxiesOn.next((Iterator *)&nextP));
01051       j++;
01052     }
01053     pt.proxylist[i].resize(j);
01054   }
01055   CkPrintf("Done intialising\n");
01056 #ifdef NODEAWARE_PROXY_SPANNINGTREE
01057   ProxyMgr::Object()->buildNodeAwareSpanningTree0();
01058 #else
01059   ProxyMgr::Object()->buildSpanningTree0();
01060 #endif
01061 }

void Rebalancer::deAssign computeInfo c,
processorInfo pRec
[protected]
 

Definition at line 405 of file Rebalancer.C.

References processorInfo::backgroundLoad, processorInfo::computeLoad, processorInfo::computeSet, ProxyUsage::decrement(), ProxyUsage::getVal(), InfoRecord::Id, iINFO(), iout, InfoRecord::load, numProxies, computeInfo::patch1, computeInfo::patch2, patches, patchInfo::processor, computeInfo::processor, processors, processorInfo::proxies, patchInfo::proxiesOn, proxyUsage, and Set::remove().

Referenced by RefineTorusLB::newRefine().

00406 {
00407    if (!p->computeSet.remove(c))  {
00408       iout << iINFO << "ERROR: Rebalancer tried to deAssign an object that is not on the processor.\n" << endi;
00409       return;
00410    }
00411 
00412    double temp_load = 0.0;
00413 
00414    c->processor = -1;
00415    p->computeLoad -= c->load;
00416    CmiAssert(p->computeLoad >= 0.0);
00417    temp_load = p->load - c->load;
00418    p->load = p->computeLoad + p->backgroundLoad;
00419    CmiAssert( fabs(temp_load - p->load) < 0.001 );
00420 
00421    // 4-29-98: Added the following code to keep track of how many proxies 
00422    // on each processor are being used by a compute on that processor.
00423    // If no computes are using the proxy, it should be removed if it is not
00424    // on the processor that its patch is on.
00425    /* int n1 = */ //p->proxyUsage[c->patch1]--;
00426    proxyUsage.decrement (p->Id, c->patch1);
00427    /* int n2 = */ //p->proxyUsage[c->patch2]--;
00428    proxyUsage.decrement (p->Id, c->patch2);
00429 
00430    // iout << iINFO
00431    // << "De-assigning compute " << c->Id << " from processor " << p->Id << "\n"
00432    // << "\tproxyUsage[" << c->patch1 << "]: " << n1 << " --> " << n1-1 << "\n"
00433    // << "\tproxyUsage[" << c->patch2 << "]: " << n2 << " --> " << n2-1 << "\n"
00434    // << std::endl;
00435 
00436    //if(p->proxyUsage[c->patch1] <= 0 && p->Id != patches[c->patch1].processor)
00437    if(proxyUsage.getVal(p->Id, c->patch1) <= 0 && p->Id != patches[c->patch1].processor)
00438    {
00439       // iout << iINFO 
00440       // << "REMOVING PROXY " << c->patch1 << " FROM PROCESSOR " << p->Id 
00441       // << std::endl << endl;
00442 
00443       patchInfo* patch1 = (patchInfo *) &(patches[c->patch1]);
00444       p->proxies.remove(patch1);
00445       patch1->proxiesOn.remove(p);
00446       numProxies--;
00447 #if PROXY_CORRECTION
00448       if(firstAssignInRefine) {
00449         processors[p->Id].load -= PROXY_LOAD;
00450         processors[p->Id].backgroundLoad -= PROXY_LOAD;
00451         if(processors[p->Id].backgroundLoad < 0.0) {
00452           processors[p->Id].backgroundLoad = 0.0;
00453           processors[p->Id].load += PROXY_LOAD;
00454         }
00455       }
00456 #endif
00457    }
00458    
00459    //if(p->proxyUsage[c->patch2] <= 0 && p->Id != patches[c->patch2].processor)
00460    if(proxyUsage.getVal(p->Id, c->patch2) <= 0 && p->Id != patches[c->patch2].processor)
00461    {
00462       // iout << iINFO
00463       // << "REMOVING PROXY " << c->patch1 << " FROM PROCESSOR " << p->Id 
00464       // << std::endl << endl;
00465 
00466       patchInfo* patch2 = (patchInfo *) &(patches[c->patch2]);
00467       p->proxies.remove(patch2);
00468       patch2->proxiesOn.remove(p);
00469       numProxies--;
00470 #if PROXY_CORRECTION
00471       if(firstAssignInRefine) {
00472         processors[p->Id].load -= PROXY_LOAD;
00473         processors[p->Id].backgroundLoad -= PROXY_LOAD;
00474         if(processors[p->Id].backgroundLoad < 0.0) {
00475           processors[p->Id].backgroundLoad = 0.0;
00476           processors[p->Id].load += PROXY_LOAD;
00477         }
00478       }
00479 #endif
00480    }
00481 }

void Rebalancer::decrSTLoad  )  [protected]
 

Definition at line 1063 of file Rebalancer.C.

References processorInfo::backgroundLoad, ProxyMgr::getPtree(), j, InfoRecord::load, ProxyMgr::Object(), processors, ProxyTree::proxylist, and ResizeArray< Elem >::size().

Referenced by RefineOnly::RefineOnly(), and RefineTorusLB::RefineTorusLB().

01063                             {
01064   int pe;
01065   ProxyTree &pt = ProxyMgr::Object()->getPtree();
01066   for(int i=0; i<numPatches; i++)
01067     for(int j=1; j<pt.proxylist[i].size() && j<proxySpanDim; j++) {
01068       pe = pt.proxylist[i][j];
01069       processors[pe].load -= ST_NODE_LOAD;
01070       processors[pe].backgroundLoad -= ST_NODE_LOAD;
01071       if(processors[pe].load < 0.0)
01072         processors[pe].load = 0.0;
01073       if(processors[pe].backgroundLoad < 0.0)
01074         processors[pe].backgroundLoad = 0.0;
01075     }
01076 }

void Rebalancer::incrSTLoad  )  [protected]
 

Definition at line 1078 of file Rebalancer.C.

References processorInfo::backgroundLoad, ProxyMgr::getPtree(), j, InfoRecord::load, ProxyMgr::Object(), processors, ProxyTree::proxylist, and ResizeArray< Elem >::size().

Referenced by RefineOnly::RefineOnly(), and RefineTorusLB::RefineTorusLB().

01078                             {
01079   int pe;
01080   ProxyTree &pt = ProxyMgr::Object()->getPtree();
01081   for(int i=0; i<numPatches; i++)
01082     for(int j=1; j<pt.proxylist[i].size() && j<proxySpanDim; j++) {
01083       pe = pt.proxylist[i][j];
01084       processors[pe].load += ST_NODE_LOAD;
01085       processors[pe].backgroundLoad += ST_NODE_LOAD;
01086     }
01087 }

void Rebalancer::InitProxyUsage  )  [protected]
 

Definition at line 135 of file Rebalancer.C.

References processorInfo::computeSet, InfoRecord::Id, Iterator::id, ProxyUsage::increment(), Set::iterator(), Set::next(), Set::numElements(), numProxies, computeInfo::patch1, computeInfo::patch2, patches, processors, patchInfo::proxiesOn, and proxyUsage.

Referenced by Rebalancer(), RefineOnly::RefineOnly(), and RefineTorusLB::RefineTorusLB().

00136 {
00137    int i;
00138    numProxies = 0;
00139 
00140    for(i=0; i<P; i++) {
00141      //processors[i].proxyUsage = new unsigned char [numPatches];
00142      //for(int j=0; j<numPatches; j++)
00143      //{
00144      //  processors[i].proxyUsage[j] = 0;
00145      //}
00146 
00147       Iterator nextCompute;
00148       nextCompute.id = 0;
00149 
00150       computeInfo *c = (computeInfo *)
00151          processors[i].computeSet.iterator((Iterator *)&nextCompute);
00152 
00153       while(c)
00154       {
00155         /* int n1 = */ //processors[i].proxyUsage[c->patch1]++;
00156         proxyUsage.increment (i, c->patch1); 
00157         /* int n2 = */ //processors[i].proxyUsage[c->patch2]++;
00158         proxyUsage.increment (i, c->patch2); 
00159 
00160          // iout << iINFO  
00161          // << "Assigning compute " << c->Id << " with work = " << c->load 
00162          // << " to processor " << processors[i].Id << "\n"
00163          // << "\tproxyUsage[" << c->patch1 << "]: " << n1 << " --> " << n1+1 << "\n";
00164          // << "\tproxyUsage[" << c->patch2 << "]: " << n2 << " --> " << n2+1 << "\n";
00165          // << std::endl;
00166 
00167          nextCompute.id++;
00168          c = (computeInfo *) processors[i].computeSet.next((Iterator *)&nextCompute);
00169       }
00170    }
00171 
00172   for (i=0; i<numPatches; i++)
00173   {
00174       numProxies += ( patches[i].proxiesOn.numElements() - 1 );
00175       Iterator nextProc;
00176       processorInfo *p = (processorInfo *)patches[i].proxiesOn.iterator((Iterator *)&nextProc);
00177       while (p) {
00178           //p->proxyUsage[i] += 1;
00179           proxyUsage.increment (p->Id, i);
00180           p = (processorInfo *)patches[i].proxiesOn.next((Iterator*)&nextProc);
00181       }
00182   }
00183 
00184 }

int Rebalancer::isAvailableOn patchInfo patch,
processorInfo p
[protected]
 

Definition at line 949 of file Rebalancer.C.

References Set::find(), and processorInfo::proxies.

00950 {
00951    return  p->proxies.find(patch);
00952 }

void Rebalancer::makeHeaps  )  [protected]
 

Definition at line 192 of file Rebalancer.C.

References processorInfo::backgroundLoad, computeBgPairHeap, computeBgSelfHeap, computePairHeap, computes, computeSelfHeap, maxHeap::insert(), minHeap::insert(), P, computeInfo::patch1, computeInfo::patch2, patches, pes, patchInfo::processor, and processors.

00193 {
00194    int i, j;
00195 
00196    delete pes;
00197    pes = new minHeap(P+2);
00198    for (i=0; i<P; i++)
00199       pes->insert((InfoRecord *) &(processors[i]));
00200 
00201    delete computePairHeap;
00202    delete computeSelfHeap;
00203    delete computeBgPairHeap;
00204    delete computeBgSelfHeap;
00205 
00206    double bgLoadLimit = 0.5 * averageLoad;
00207    /*
00208    iout << iINFO << "Background load limit = " << bgLoadLimit << "\n";
00209    for (i=0; i<P; i++)
00210      if ( processors[i].backgroundLoad > bgLoadLimit )
00211        iout << iINFO << "Processor " << i << " background load = "
00212             << processors[i].backgroundLoad << "\n";
00213    iout << endi;
00214    */
00215 
00216    int numSelfComputes, numPairComputes, numBgSelfComputes, numBgPairComputes;
00217 
00218    while ( 1 ) {
00219     numSelfComputes = 0;
00220     numPairComputes = 0;
00221     numBgSelfComputes = 0;
00222     numBgPairComputes = 0;
00223     for (i=0; i<numComputes; i++) {
00224      int pa1 = computes[i].patch1;
00225      int pa2 = computes[i].patch2;
00226      if ( pa1 == pa2 ) {
00227         if ( processors[patches[pa1].processor].backgroundLoad > bgLoadLimit) {
00228           ++numBgSelfComputes;
00229         } else {
00230           ++numSelfComputes;
00231         }
00232      } else {
00233         if ( processors[patches[pa1].processor].backgroundLoad > bgLoadLimit
00234           || processors[patches[pa2].processor].backgroundLoad > bgLoadLimit) {
00235           ++numBgPairComputes;
00236         } else {
00237           ++numPairComputes;
00238         }
00239      }
00240     }
00241 
00242     int numBgComputes = numBgPairComputes + numBgSelfComputes;
00243 
00244     /*if ( numBgComputes ) {
00245         iout << iINFO << numBgComputes << " of " << numComputes
00246         << " computes have background load > " << bgLoadLimit << "\n" << endi;
00247     }*/
00248 
00249     if ( numBgComputes < 0.3 * numComputes ) break;
00250     else bgLoadLimit += 0.1 * averageLoad;
00251    }
00252 
00253    computePairHeap = new maxHeap(numPairComputes+2);
00254    computeSelfHeap = new maxHeap(numSelfComputes+2);
00255    computeBgPairHeap = new maxHeap(numBgPairComputes+2);
00256    computeBgSelfHeap = new maxHeap(numBgSelfComputes+2);
00257 
00258    for (i=0; i<numComputes; i++) {
00259      int pa1 = computes[i].patch1;
00260      int pa2 = computes[i].patch2;
00261      if ( pa1 == pa2 ) {
00262         if ( processors[patches[pa1].processor].backgroundLoad > bgLoadLimit) {
00263           computeBgSelfHeap->insert( (InfoRecord *) &(computes[i]));
00264         } else {
00265           computeSelfHeap->insert( (InfoRecord *) &(computes[i]));
00266         }
00267      } else {
00268         if ( processors[patches[pa1].processor].backgroundLoad > bgLoadLimit
00269           || processors[patches[pa2].processor].backgroundLoad > bgLoadLimit) {
00270           computeBgPairHeap->insert( (InfoRecord *) &(computes[i]));
00271         } else {
00272           computePairHeap->insert( (InfoRecord *) &(computes[i]));
00273         }
00274      }
00275    }
00276 
00277 /*
00278    delete computePairHeap;
00279    delete computeSelfHeap;
00280 
00281    int numSelfComputes = 0;
00282    for (i=0; i<numComputes; i++)
00283       if ( computes[i].patch1 == computes[i].patch2 ) ++numSelfComputes;
00284 
00285    computeSelfHeap = new maxHeap(numSelfComputes+2);
00286    computePairHeap = new maxHeap(numComputes-numSelfComputes+2);
00287 
00288    for (i=0; i<numComputes; i++)
00289       if ( computes[i].patch1 == computes[i].patch2 )
00290          computeSelfHeap->insert( (InfoRecord *) &(computes[i]));
00291       else
00292          computePairHeap->insert( (InfoRecord *) &(computes[i]));
00293 */
00294 }

void Rebalancer::makeTwoHeaps  )  [protected]
 

Definition at line 296 of file Rebalancer.C.

References computePairHeap, computes, computeSelfHeap, maxHeap::insert(), minHeap::insert(), P, computeInfo::patch1, computeInfo::patch2, pes, and processors.

00297 {
00298    int i, j;
00299 
00300    delete pes;
00301    pes = new minHeap(P+2);
00302    for (i=0; i<P; i++)
00303       pes->insert((InfoRecord *) &(processors[i]));
00304 
00305    delete computePairHeap;
00306    delete computeSelfHeap;
00307    delete computeBgPairHeap;
00308    delete computeBgSelfHeap;
00309 
00310    int numSelfComputes, numPairComputes;
00311 
00312    numSelfComputes = 0;
00313    numPairComputes = 0;
00314    for (i=0; i<numComputes; i++) {
00315      int pa1 = computes[i].patch1;
00316      int pa2 = computes[i].patch2;
00317      if (pa1 == pa2)
00318        ++numSelfComputes;
00319      else
00320        ++numPairComputes;
00321    }
00322 
00323    computePairHeap = new maxHeap(numPairComputes+2);
00324    computeSelfHeap = new maxHeap(numSelfComputes+2);
00325 
00326    for (i=0; i<numComputes; i++) {
00327      int pa1 = computes[i].patch1;
00328      int pa2 = computes[i].patch2;
00329      if ( pa1 == pa2 )
00330        computeSelfHeap->insert( (InfoRecord *) &(computes[i]));
00331      else
00332        computePairHeap->insert( (InfoRecord *) &(computes[i]));
00333    }
00334 }

void Rebalancer::multirefine double  overload_start = 1.02  )  [protected]
 

Definition at line 723 of file Rebalancer.C.

References processorInfo::backgroundLoad, computeAverage(), processorInfo::computeLoad, computeMax(), processorInfo::computeSet, iINFO(), iout, iWARN(), InfoRecord::load, Set::numElements(), overLoad, processors, and refine().

Referenced by RefineOnly::RefineOnly().

00724 {
00725   // The New refinement procedure.  This is identical to the code in
00726   // RefineOnly.C, and probably should be merged with that code to form
00727   // a binary-search function
00728 
00729   double avg = computeAverage();
00730   double max = computeMax();
00731 
00732 #if LDB_DEBUG
00733   iout << "******** Processors with background load > average load ********" << "\n";
00734 #endif
00735 
00736   int numOverloaded = 0;
00737   for (int ip=0; ip<P; ip++) {
00738     if ( processors[ip].backgroundLoad > averageLoad ) {
00739       ++numOverloaded;
00740 #if LDB_DEBUG
00741       iout << iINFO << "Info about proc " << ip << ": Load: " << processors[ip].load << " Bg Load: " << processors[ip].backgroundLoad << " Compute Load: " << processors[ip].computeLoad << " No of computes: " << processors[ip].computeSet.numElements() << "\n";
00742 #endif
00743     }
00744   }
00745   if ( numOverloaded ) {
00746     iout << iWARN << numOverloaded
00747       << " processors are overloaded due to high background load.\n" << endi;
00748   }
00749 #if LDB_DEBUG
00750   iout << "******** Processor List Ends ********" << "\n\n";
00751 #endif
00752 
00753   const double overloadStep = 0.01;
00754   const double overloadStart = overload_start;       //1.05;
00755   double dCurOverload = max / avg;
00756   
00757   int minOverload = 0;   //Min overload should be 1.05 ?
00758   int maxOverload = (int)((dCurOverload - overloadStart)/overloadStep + 1);
00759   double dMinOverload = minOverload * overloadStep + overloadStart;
00760   double dMaxOverload = maxOverload * overloadStep + overloadStart;
00761 
00762 #if LDB_DEBUG 
00763   iout << iINFO
00764        << "Balancing from " << minOverload << " = " << dMinOverload 
00765        << " to " << maxOverload << "=" << dMaxOverload 
00766        << " dCurOverload=" << dCurOverload << " max=" << max << " avg=" << avg
00767        << "\n" << endi;
00768 #endif
00769 
00770   int curOverload;
00771   int refineDone = 0;
00772 
00773   overLoad = dMinOverload;
00774   if (refine())
00775     refineDone = 1;
00776   else {
00777     overLoad = dMaxOverload;
00778     if (!refine()) {
00779       iout << iINFO << "ERROR: Could not refine at max overload\n" << endi;
00780       refineDone = 1;
00781     }
00782   }
00783 
00784   // Scan up, until we find a refine that works
00785   while (!refineDone) {
00786     if (maxOverload - minOverload <= 1)
00787       refineDone = 1;
00788     else {
00789       curOverload = (maxOverload + minOverload ) / 2;
00790 
00791       overLoad = curOverload * overloadStep + overloadStart;
00792 #if LDB_DEBUG 
00793       iout << iINFO << "Testing curOverload " << curOverload 
00794            << "=" << overLoad << " [min,max]=" 
00795            << minOverload << ", " << maxOverload
00796            << "\n" << endi;
00797 #endif     
00798       if (refine())
00799         maxOverload = curOverload;
00800       else
00801         minOverload = curOverload;
00802     }
00803   }
00804 
00805 }

void Rebalancer::numAvailable computeInfo c,
processorInfo p,
int *  nPatches,
int *  nProxies,
int *  isBadForCommunication
[protected]
 

Definition at line 954 of file Rebalancer.C.

References processorInfo::backgroundLoad, Set::find(), InfoRecord::Id, Set::numElements(), numPatches, numPesAvailable, numProxies, computeInfo::patch1, computeInfo::patch2, patches, patchInfo::processor, processors, processorInfo::proxies, and patchInfo::proxiesOn.

Referenced by refine_togrid().

00956 {
00957    //return the number of proxy/home patches available on p for c (0,1,2)
00958 
00959    int patch_count = 0;
00960    int proxy_count = 0;
00961 
00962    patchInfo &pa1 = patches[c->patch1];
00963    patchInfo &pa2 = patches[c->patch2];
00964 
00965    int pa1_avail = 1;
00966    int pa2_avail = 1;
00967 
00968    if (pa1.processor == p->Id) {
00969      patch_count++;
00970    } else if ( p->proxies.find(&pa1) ) {
00971      proxy_count++;
00972    } else {
00973      pa1_avail = 0;
00974    }
00975 
00976    // self computes get one patch for free here
00977    if (c->patch1 == c->patch2 || pa2.processor == p->Id) {
00978      patch_count++;
00979    } else if ( p->proxies.find(&pa2) ) {
00980      proxy_count++;
00981    } else {
00982      pa2_avail = 0;
00983    }
00984 
00985    *nPatches = patch_count;
00986    *nProxies = proxy_count;
00987 
00988    int bad = 0;
00989 
00990    if ( patch_count + proxy_count < 2 ) {
00991 
00992      double bgLoadLimit = 1.2 * averageLoad;
00993 
00994      if ( p->backgroundLoad > bgLoadLimit ) bad = 1;
00995 #if 1
00996      else {
00997 
00998       int proxiesPerPeLimit = numProxies / numPesAvailable + 3;
00999       if ( proxiesPerPeLimit < 6 ) proxiesPerPeLimit = 6;
01000 
01001       if ( p->proxies.numElements() > proxiesPerPeLimit ) bad = 1;
01002 
01003       int proxiesPerPatchLimit = numProxies / numPatches + 3;
01004       if ( proxiesPerPatchLimit < 6 ) proxiesPerPatchLimit = 6;
01005 
01006       if ( ! bad && ! pa1_avail ) {
01007         if ( processors[pa1.processor].backgroundLoad > bgLoadLimit) bad = 1;
01008         else if ( pa1.proxiesOn.numElements() > proxiesPerPatchLimit ) bad = 1;
01009       }
01010       if ( ! bad && ! pa2_avail ) {
01011         if ( processors[pa2.processor].backgroundLoad > bgLoadLimit) bad = 1;
01012         else if ( pa2.proxiesOn.numElements() > proxiesPerPatchLimit ) bad = 1;
01013       }
01014 
01015      }
01016 #endif
01017    }
01018 
01019    *isBadForCommunication = bad;
01020 }

void Rebalancer::printLoads  )  [protected]
 

Definition at line 813 of file Rebalancer.C.

References averageLoad, processorInfo::backgroundLoad, computeAverage(), computeMax(), iout, Set::iterator(), Set::next(), patchInfo::numAtoms, Set::numElements(), processorInfo::patchSet, processors, processorInfo::proxies, patchInfo::proxiesOn, and strategyName.

Referenced by Rebalancer(), RefineOnly::RefineOnly(), RefineTorusLB::RefineTorusLB(), and TorusLB::TorusLB().

00814 {
00815 
00816    int i, total = 0, numBytes = 0;
00817    double max;
00818    int maxproxies = 0;
00819    int maxpatchproxies = 0;
00820    double avgBgLoad =0.0;
00821 
00822    for (i=0; i<P; i++) {
00823       int nproxies = processors[i].proxies.numElements() - 
00824                         processors[i].patchSet.numElements();
00825       if ( nproxies > maxproxies ) maxproxies = nproxies;
00826       avgBgLoad += processors[i].backgroundLoad;
00827       Iterator p;
00828       int count = 0;
00829     
00830       patchInfo *patch = (patchInfo *) processors[i].patchSet.iterator(&p);
00831       while (patch)
00832       {
00833          int myProxies;
00834          myProxies = patch->proxiesOn.numElements()-1;
00835          if ( myProxies > maxpatchproxies ) maxpatchproxies = myProxies;
00836          numBytes += myProxies *patch->numAtoms*bytesPerAtom;
00837          count += myProxies;
00838          patch = (patchInfo *)processors[i].patchSet.next(&p);
00839       }
00840       total += count;
00841    }
00842 
00843    avgBgLoad /= P;
00844    computeAverage();
00845    max = computeMax();
00846 
00847    iout << "LDB: TIME " << CmiWallTimer() << " LOAD: AVG " << averageLoad 
00848      << " MAX " << max << "  PROXIES: TOTAL " << total << " MAXPE " << 
00849      maxproxies << " MAXPATCH " << maxpatchproxies << " " << strategyName 
00850      << " " << avgBgLoad << "\n" << endi;
00851    fflush(stdout);
00852 
00853 }

void Rebalancer::printResults  )  [protected]
 

Definition at line 807 of file Rebalancer.C.

References iINFO(), and iout.

00808 {
00809   iout << iINFO << "ready to print result \n" << "\n";
00810 }

void Rebalancer::printSummary  )  [protected]
 

Definition at line 855 of file Rebalancer.C.

References processorInfo::backgroundLoad, processorInfo::computeLoad, processorInfo::computeSet, iINFO(), iout, InfoRecord::load, Set::numElements(), processors, and processorInfo::proxies.

Referenced by RefineTorusLB::newRefine(), and refine().

00856 {
00857    int i;
00858    // After refining, compute min, max and avg processor load
00859    double total = processors[0].load;
00860    double min = processors[0].load;
00861    int min_proc = 0;
00862    double max = processors[0].load;
00863    int max_proc = 0;
00864    for (i=1; i<P; i++) {
00865      total += processors[i].load;
00866      if (processors[i].load < min) {
00867        min = processors[i].load;
00868        min_proc = i;
00869      }
00870      if (processors[i].load > max) {
00871        max = processors[i].load;
00872        max_proc = i;
00873      }
00874    }
00875    iout << iINFO << "  min = " << min << " processor " << min_proc << "\n";
00876    iout << iINFO << "  max = " << max << " processor " << max_proc << "\n";
00877    iout << iINFO << "  total = " << total << " average = " << total/P << "\n";
00878    iout << iINFO << "Info about most overloaded processor " << max_proc << ": Load: " << processors[max_proc].load << " Bg Load: " << processors[max_proc].backgroundLoad << " Compute Load: " << processors[max_proc].computeLoad << " No of computes: " << processors[max_proc].computeSet.numElements() << " No. of proxies: " << processors[max_proc].proxies.numElements() << "\n" << endi; 
00879 }

int Rebalancer::refine  )  [protected]
 

Definition at line 516 of file Rebalancer.C.

References processorInfo::computeSet, maxHeap::deleteMax(), InfoRecord::Id, Iterator::id, iINFO(), Set::insert(), maxHeap::insert(), iout, Set::iterator(), InfoRecord::load, Set::next(), next(), Set::numElements(), overLoad, P, computeInfo::patch1, computeInfo::patch2, patches, pcgrid, printSummary(), computeInfo::processor, patchInfo::processor, processors, REASSIGN, refine_togrid(), and Set::remove().

Referenced by multirefine().

00517 {
00518    int finish = 1;
00519    int no_new_proxies = 0;  // set to true if new proxies are futile
00520    maxHeap *heavyProcessors = new maxHeap(P);
00521 
00522    Set *lightProcessors = new Set();
00523    int i;
00524    double thresholdLoad = overLoad * averageLoad;
00525    for (i=0; i<P; i++)
00526    {
00527       // iout << iINFO << "\n Computes on processor " << i << " ";
00528       // processors[i].computeSet->print();
00529       // iout << iINFO << "\n" << endi;
00530       if (processors[i].load > thresholdLoad)
00531          heavyProcessors->insert((InfoRecord *) &(processors[i]));
00532       else lightProcessors->insert((InfoRecord *) &(processors[i]));
00533    }
00534 
00535 #if LDB_DEBUG
00536    iout << "\nBefore Refinement Summary" << "\n";
00537    printSummary();
00538 #endif
00539 
00540    int done = 0;
00541    while (!done)
00542    {
00543       // processorInfo *donor = (processorInfo *) heavyProcessors->deleteMax();
00544       /* Keep selecting new donors, until we find one with some compute to
00545        * migrate
00546        */
00547 /*
00548       computeInfo* c=0;
00549       while (donor && !c) {
00550         Iterator nextCompute;
00551         nextCompute.id = 0;
00552         c = (computeInfo *) donor->
00553             computeSet.iterator((Iterator *)&nextCompute);
00554         if (!c) {
00555           iout << iINFO << "Ignoring donor " << donor->Id
00556                << " because no computes\n" << endi;
00557           donor = (processorInfo*)heavyProcessors->deleteMax();
00558         }
00559       };
00560 */
00561 
00562       processorInfo *donor;
00563       while (donor = (processorInfo*)heavyProcessors->deleteMax()) {
00564         if (donor->computeSet.numElements()) break;
00565         if ( ! no_new_proxies ) {
00566           /*
00567           iout << iINFO << "Most-loaded processor " << donor->Id
00568                << " (" << donor->patchSet.numElements() << " patches, "
00569                << donor->proxies.numElements() << " proxies)"
00570                << " has no migratable work.\n" << endi;
00571           */
00572           no_new_proxies = 1;  // New proxies would not improve load balance.
00573         }
00574       }
00575   
00576       if (!donor) break;  // No donors found at all! Give up 
00577 
00578       pcgrid grid;
00579 #define REASSIGN(GRID) if (GRID.c) { \
00580            deAssign(GRID.c, donor); \
00581            assign(GRID.c, GRID.p); \
00582            bestP = GRID.p; \
00583         }
00584 
00585       // try for at least one proxy
00586       {
00587         Iterator nextCompute;
00588         nextCompute.id = 0;
00589         computeInfo *c = (computeInfo *) 
00590            donor->computeSet.iterator((Iterator *)&nextCompute);
00591         while (c)
00592         {
00593           Iterator nextProc;
00594           processorInfo *p;
00595 
00596           p = &processors[patches[c->patch1].processor];
00597           refine_togrid(grid, thresholdLoad, p, c);
00598 
00599           if (c->patch1 != c->patch2)
00600           {
00601           p = &processors[patches[c->patch2].processor];
00602           refine_togrid(grid, thresholdLoad, p, c);
00603           }
00604 
00605           p = (processorInfo *)patches[c->patch1].
00606                                 proxiesOn.iterator((Iterator *)&nextProc);
00607           while (p) {
00608             refine_togrid(grid, thresholdLoad, p, c);
00609             p = (processorInfo *)patches[c->patch1].
00610                                 proxiesOn.next((Iterator*)&nextProc);
00611           }
00612 
00613           if (c->patch1 != c->patch2) 
00614           {
00615           p = (processorInfo *)patches[c->patch2].
00616                                 proxiesOn.iterator((Iterator *)&nextProc);
00617           while (p) {
00618             refine_togrid(grid, thresholdLoad, p, c);
00619             p = (processorInfo *)patches[c->patch2].
00620                                 proxiesOn.next((Iterator*)&nextProc);
00621           }
00622           }
00623 
00624           nextCompute.id++;
00625           c = (computeInfo *) donor->computeSet.
00626             next((Iterator *)&nextCompute);
00627         }
00628         processorInfo* bestP = 0;
00629         // prefer proxies to home patches
00630         REASSIGN(grid[0][2][0])
00631         else REASSIGN(grid[1][1][0])
00632         else REASSIGN(grid[2][0][0])
00633         else if ( no_new_proxies ) { finish = 0; break; }
00634         else REASSIGN(grid[0][1][0])
00635         else REASSIGN(grid[1][0][0])
00636         else REASSIGN(grid[0][0][0])
00637         // else REASSIGN(grid[0][1][1])
00638         // else REASSIGN(grid[1][0][1])
00639         // else REASSIGN(grid[0][0][1])
00640         if (bestP) {
00641           if (bestP->load > averageLoad) lightProcessors->remove(bestP);
00642           if (donor->load > thresholdLoad)
00643                 heavyProcessors->insert((InfoRecord *) donor);
00644           else lightProcessors->insert((InfoRecord *) donor);
00645           continue;
00646         }
00647       }
00648 
00649       if ( no_new_proxies ) iout << iINFO
00650          << "ERROR: Rebalancer::refine() algorithm is broken.\n" << endi;
00651 
00652       // no luck, do it the long way
00653 
00654       //find the best pair (c,receiver)
00655       Iterator nextProcessor;
00656       processorInfo *p = (processorInfo *) 
00657       lightProcessors->iterator((Iterator *) &nextProcessor);
00658 
00659       while (p)
00660       {
00661          Iterator nextCompute;
00662          nextCompute.id = 0;
00663          computeInfo *c = (computeInfo *) 
00664             donor->computeSet.iterator((Iterator *)&nextCompute);
00665          while (c)
00666          {
00667 #if USE_TOPOMAP
00668            int flag = tmgr.areNeighbors(p->Id, patches[c->patch1].processor, 
00669                                      patches[c->patch2].processor, 8);
00670            if(flag)
00671 #endif
00672              {       
00673                refine_togrid(grid, thresholdLoad, p, c);
00674              }
00675            nextCompute.id++;
00676            c = (computeInfo *) donor->computeSet.
00677              next((Iterator *)&nextCompute);
00678          }
00679          p = (processorInfo *) 
00680            lightProcessors->next((Iterator *) &nextProcessor);
00681       }
00682 
00683       //we have narrowed the choice to 6 candidates.
00684       // prefer proxies to home patches
00685       {
00686         processorInfo* bestP = 0;
00687         REASSIGN(grid[0][2][0])
00688         else REASSIGN(grid[1][1][0])
00689         else REASSIGN(grid[2][0][0])
00690         else REASSIGN(grid[0][1][0])
00691         else REASSIGN(grid[1][0][0])
00692         else REASSIGN(grid[0][0][0])
00693         // else REASSIGN(grid[0][1][1])
00694         // else REASSIGN(grid[1][0][1])
00695         // else REASSIGN(grid[0][0][1])
00696         else { finish = 0; break; }
00697         if (bestP->load > averageLoad) lightProcessors->remove(bestP);
00698         if (donor->load > thresholdLoad)
00699                 heavyProcessors->insert((InfoRecord *) donor);
00700         else lightProcessors->insert((InfoRecord *) donor);
00701       }
00702 
00703    }  
00704 
00705 #if LDB_DEBUG
00706    iout << "After Refinement Summary" << "\n";
00707    printSummary();
00708 
00709    if (!finish) {
00710      iout << iINFO << "Refine: No solution found for overLoad = " 
00711           << overLoad << "\n" << endi;
00712    }
00713 #endif
00714 
00715    delete heavyProcessors;
00716    delete lightProcessors;
00717 
00718    return finish;
00719 }

void Rebalancer::refine_togrid pcgrid grid,
double  thresholdLoad,
processorInfo p,
computeInfo c
[protected]
 

Definition at line 483 of file Rebalancer.C.

References processorInfo::available, Rebalancer::pcpair::c, InfoRecord::load, numAvailable(), Rebalancer::pcpair::p, and pcgrid.

Referenced by refine().

00484                                                           {
00485 
00486   if(p->available == CmiFalse) return;
00487 
00488   if ( c->load + p->load < thresholdLoad) {
00489     int nPatches, nProxies, badForComm;
00490     numAvailable(c,p,&nPatches,&nProxies,&badForComm);
00491 
00492     // if ( badForComm ) return;
00493 
00494     pcpair *pair = &grid[nPatches][nProxies][badForComm];
00495 
00496     if (! pair->c) {
00497       pair->c = c;
00498       pair->p = p;
00499     } else {
00500       double newval = p->load - c->load;
00501       if ( c->load + p->load < averageLoad ) {
00502          newval -= averageLoad;
00503       }
00504       double oldval = pair->p->load - pair->c->load;
00505       if ( pair->c->load + pair->p->load < averageLoad ) {
00506          oldval -= averageLoad;
00507       }
00508       if (newval < oldval) {
00509         pair->c = c;
00510         pair->p = p;
00511       }
00512     }
00513   }
00514 }

void Rebalancer::strategy  )  [protected]
 

Definition at line 187 of file Rebalancer.C.

References iINFO(), and iout.

Referenced by Alg7::Alg7(), AlgNbor::AlgNbor(), AlgRecBisection::AlgRecBisection(), RefineOnly::RefineOnly(), RefineTorusLB::RefineTorusLB(), and TorusLB::TorusLB().

00188 {
00189    iout << iINFO << "Strategy not implemented for the base class.\n" << "\n";
00190 }

int Rebalancer::withinBrick int  x,
int  y,
int  z,
int  xm,
int  xM,
int  dimX,
int  ym,
int  yM,
int  dimY,
int  zm,
int  zM,
int  dimZ
[inline, protected]
 

withinBrick This function returns whether a particular coordinate is within the region defined by xm, xM, ym, yM, zm, zM

Definition at line 196 of file Rebalancer.h.

00197                                                                              {
00198     int wbX, wbY, wbZ;
00199     if( ((x >= xm) && (x <= xM)) || ((x < xm) && (x+dimX <= xM)) ) wbX = 1; else return 0;
00200     if( ((y >= ym) && (y <= yM)) || ((y < ym) && (y+dimY <= yM)) ) wbY = 1; else return 0;
00201     if( ((z >= zm) && (z <= zM)) || ((z < zm) && (z+dimZ <= zM)) ) wbZ = 1; else return 0;
00202 
00203     //if( wbX && wbY && wbZ)
00204       return 1;
00205   }


Member Data Documentation

double Rebalancer::averageLoad [protected]
 

Definition at line 140 of file Rebalancer.h.

Referenced by computeAverage(), and printLoads().

int Rebalancer::bytesPerAtom [protected]
 

Definition at line 123 of file Rebalancer.h.

Referenced by Rebalancer().

maxHeap* Rebalancer::computeBgPairHeap [protected]
 

Definition at line 133 of file Rebalancer.h.

Referenced by makeHeaps(), and Rebalancer().

maxHeap* Rebalancer::computeBgSelfHeap [protected]
 

Definition at line 134 of file Rebalancer.h.

Referenced by makeHeaps(), and Rebalancer().

maxHeap* Rebalancer::computePairHeap [protected]
 

Definition at line 131 of file Rebalancer.h.

Referenced by makeHeaps(), makeTwoHeaps(), and Rebalancer().

computeInfo* Rebalancer::computes [protected]
 

Definition at line 127 of file Rebalancer.h.

Referenced by computeAverage(), makeHeaps(), makeTwoHeaps(), and Rebalancer().

maxHeap* Rebalancer::computeSelfHeap [protected]
 

Definition at line 132 of file Rebalancer.h.

Referenced by makeHeaps(), makeTwoHeaps(), and Rebalancer().

int Rebalancer::firstAssignInRefine [protected]
 

Definition at line 141 of file Rebalancer.h.

Referenced by Rebalancer().

int Rebalancer::numComputes [protected]
 

Definition at line 137 of file Rebalancer.h.

Referenced by Rebalancer().

int Rebalancer::numPatches [protected]
 

Definition at line 136 of file Rebalancer.h.

Referenced by numAvailable(), and Rebalancer().

int Rebalancer::numPesAvailable [protected]
 

Definition at line 139 of file Rebalancer.h.

Referenced by adjustBackgroundLoadAndComputeAverage(), computeAverage(), numAvailable(), and Rebalancer().

int Rebalancer::numProxies [protected]
 

Definition at line 138 of file Rebalancer.h.

Referenced by assign(), deAssign(), InitProxyUsage(), and numAvailable().

double Rebalancer::overLoad [protected]
 

Definition at line 165 of file Rebalancer.h.

Referenced by multirefine(), Rebalancer(), and refine().

int Rebalancer::P [protected]
 

Definition at line 135 of file Rebalancer.h.

Referenced by makeHeaps(), makeTwoHeaps(), Rebalancer(), and refine().

patchInfo* Rebalancer::patches [protected]
 

Definition at line 128 of file Rebalancer.h.

Referenced by assign(), createSpanningTree(), deAssign(), InitProxyUsage(), makeHeaps(), numAvailable(), Rebalancer(), and refine().

minHeap* Rebalancer::pes [protected]
 

Definition at line 130 of file Rebalancer.h.

Referenced by makeHeaps(), makeTwoHeaps(), and Rebalancer().

processorInfo* Rebalancer::processors [protected]
 

Definition at line 129 of file Rebalancer.h.

Referenced by adjustBackgroundLoadAndComputeAverage(), assign(), computeAverage(), computeMax(), deAssign(), decrSTLoad(), incrSTLoad(), InitProxyUsage(), makeHeaps(), makeTwoHeaps(), multirefine(), numAvailable(), printLoads(), printSummary(), Rebalancer(), and refine().

ProxyUsage Rebalancer::proxyUsage [protected]
 

Definition at line 125 of file Rebalancer.h.

Referenced by assign(), deAssign(), and InitProxyUsage().

const char* Rebalancer::strategyName [protected]
 

Definition at line 126 of file Rebalancer.h.

Referenced by printLoads(), and Rebalancer().


The documentation for this class was generated from the following files:
Generated on Mon Nov 23 05:00:08 2009 for NAMD by  doxygen 1.3.9.1