Sync Class Reference

#include <Sync.h>

List of all members.

Public Member Functions

 Sync (void)
 ~Sync (void)
void openSync ()
int holdComputes (PatchID pid, Compute **cbegin, Compute **cend, int doneMigration, int seq)
void PatchReady (void)

Static Public Member Functions

static SyncObject ()

Classes

struct  _clist


Detailed Description

Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000 by The Board of Trustees of the University of Illinois. All rights reserved.

Definition at line 22 of file Sync.h.


Constructor & Destructor Documentation

Sync::Sync ( void   ) 

Definition at line 42 of file Sync.C.

References eventHoldComputes, eventReleaseComputes, and NAMD_bug().

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

Sync::~Sync ( void   ) 

Definition at line 58 of file Sync.C.

00059 {
00060   delete [] clist;
00061 }


Member Function Documentation

int Sync::holdComputes ( PatchID  pid,
Compute **  cbegin,
Compute **  cend,
int  doneMigration,
int  seq 
)

Definition at line 103 of file Sync.C.

References eventHoldComputes, and PatchMap::Object().

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

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

Definition at line 50 of file Sync.h.

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

00050 { return CkpvAccess(Sync_instance); }

void Sync::openSync (  ) 

Definition at line 63 of file Sync.C.

References endi(), iINFO(), iout, ProxyMgr::Object(), PatchMap::Object(), proxyRecvSpanning, and proxySendSpanning.

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

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

void Sync::PatchReady ( void   ) 

Definition at line 150 of file Sync.C.

00151 {
00152  if ( useSync ) {
00153   counter ++;
00154   triggerCompute();
00155  }
00156 }


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