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

Sync Class Reference

#include <Sync.h>

Inheritance diagram for Sync:

BOCclass List of all members.

Public Member Functions

 Sync (void)
 ~Sync (void)
void openSync ()
int holdComputes (PatchID pid, ComputeIDListIter cid, int doneMigration, int seq)
void PatchReady (void)

Static Public Member Functions

SyncObject ()

Constructor & Destructor Documentation

Sync::Sync void   ) 
 

Definition at line 42 of file Sync.C.

References eventHoldComputes, eventReleaseComputes, iERROR(), iFILE, iout, and iPE().

00042           : INCREASE(600), step(0), counter(0), homeReady(0)
00043 {
00044     if (CkpvAccess(Sync_instance) == NULL) {
00045         CkpvAccess(Sync_instance) = this;
00046     } else {
00047         iout << iFILE << iERROR << iPE
00048           << "Sync instanced twice on same processor!" << endi;
00049         CkExit();
00050     }
00051     capacity = INCREASE;
00052     clist = new _clist[capacity];
00053     cnum = 0;
00054     nPatcheReady = 0;
00055     numPatches = -1;
00056     eventHoldComputes = traceRegisterUserEvent("Sync::holdComputes", 133);
00057     eventReleaseComputes = traceRegisterUserEvent("Sync::releaseComputes", 134);
00058 }

Sync::~Sync void   ) 
 

Definition at line 60 of file Sync.C.

00061 {
00062   delete [] clist;
00063 }


Member Function Documentation

int Sync::holdComputes PatchID  pid,
ComputeIDListIter  cid,
int  doneMigration,
int  seq
 

Definition at line 99 of file Sync.C.

References PatchMap::cid(), ComputeIDListIter, eventHoldComputes, and PatchMap::Object().

Referenced by Patch::positionsReady().

00100 {
00101   if (!useSync) return 0;
00102   if (step < 0) step = seq;
00103   if (!useProxySync) {
00104     // only hold when homepatches are not ready
00105     PatchMap *patchMap = PatchMap::Object();
00106     if (homeReady && seq == step) {
00107       nPatcheReady++;
00108       triggerCompute();
00109       return 0;
00110     }
00111   }
00112   traceUserEvent(eventHoldComputes);
00113 
00114   int slot = 0;
00115   for (; slot < cnum; slot++)
00116      if (clist[slot].pid == -1) break;
00117   if (slot == cnum) {
00118     cnum++;
00119     // table is full, expand the list
00120     if (cnum == capacity) {
00121       capacity += INCREASE;
00122       struct _clist *tmp = new _clist[capacity];
00123       memcpy(tmp, clist, cnum*sizeof(_clist));
00124       delete [] clist;
00125       clist = tmp;
00126       //CmiPrintf("[%d] Info:: Sync buffer overflow and expanded!\n", CkMyPe());
00127     }
00128   }
00129 
00130   clist[slot].cid = cid;
00131   clist[slot].pid = pid;
00132   clist[slot].doneMigration  = doneMigration;
00133   clist[slot].step = seq;
00134 
00135 //  CkPrintf("REG[%d]: patch:%d step:%d-%d slot:%d\n", CkMyPe(), pid, patchMap->patch(pid)->flags.sequence, step, slot);
00136 
00137   if (clist[slot].step == step) {
00138       nPatcheReady++;
00139       triggerCompute();
00140   }
00141   return 1;
00142 }

Sync* Sync::Object void   )  [inline, static]
 

Definition at line 52 of file Sync.h.

Referenced by Patch::positionsReady(), HomePatch::positionsReady(), LdbCoordinator::resume(), and Node::startup().

00052 { return CkpvAccess(Sync_instance); }

void Sync::openSync  ) 
 

Definition at line 65 of file Sync.C.

References iINFO(), iout, PatchMap::numHomePatches(), PatchMap::numPatches(), ProxyMgr::numProxies(), ProxyMgr::Object(), PatchMap::Object(), and proxySendSpanning.

Referenced by LdbCoordinator::resume(), and Node::startup().

00066 {
00067   int reportPe = 1;
00068   while ( 2 * reportPe < CkNumPes() ) reportPe *= 2;
00069   step = -1;
00070   useSync = 1;
00071   useProxySync = 0;
00072   if (useSync) {
00073     // if use proxy spanning tree, proxy sync is forced
00074     if (!useProxySync && (proxySendSpanning || proxyRecvSpanning)
00075         && PatchMap::Object()->numPatches() < 4 * CkNumPes() ) {
00076       // If on BG/P, useProxySync should not be turned on for better performance
00077       #if !CMK_BLUEGENEP
00078       // CmiPrintf("[%d] useProxySync is turned on. \n", CkMyPe());
00079       useProxySync = 1;
00080       #endif
00081     }
00082 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)
00083     // immediate messages can be processed by any PE
00084     if (CkMyNodeSize() > 2) useProxySync = 0;
00085 #endif
00086     // no proxies on this node, no need to use proxy sync.
00087     if (useProxySync && ProxyMgr::Object()->numProxies() == 0) {
00088       // CmiPrintf("[%d] useProxySync is turned off because no proxy. \n", CkMyPe());
00089       useProxySync = 0;
00090     }
00091     // if no proxy sync and no home patch, then disable home patch sync as well
00092     if (!useProxySync && PatchMap::Object()->numHomePatches() == 0) useSync = 0;
00093   }
00094   if(CkMyPe() == reportPe)
00095     iout << iINFO << "useSync: " << useSync << " useProxySync: " << useProxySync << "\n" << endi;
00096 }    

void Sync::PatchReady void   ) 
 

Definition at line 145 of file Sync.C.

Referenced by HomePatch::positionsReady().

00146 {
00147  if ( useSync ) {
00148   counter ++;
00149   triggerCompute();
00150  }
00151 }


The documentation for this class was generated from the following files:
Generated on Sun Feb 12 04:08:05 2012 for NAMD by  doxygen 1.3.9.1