NAMD
Classes | Public Member Functions | Static Public Member Functions | List of all members
Sync Class Reference

#include <Sync.h>

Inheritance diagram for Sync:

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

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

42  : INCREASE(600), step(0), counter(0), homeReady(0)
43 {
44  if (CkpvAccess(Sync_instance) == NULL) {
45  CkpvAccess(Sync_instance) = this;
46  } else {
47  NAMD_bug("Sync instanced twice on same processor!");
48  }
49  capacity = INCREASE;
50  clist = new _clist[capacity];
51  cnum = 0;
52  nPatcheReady = 0;
53  numPatches = -1;
54  eventHoldComputes = traceRegisterUserEvent("Sync::holdComputes", 133);
55  eventReleaseComputes = traceRegisterUserEvent("Sync::releaseComputes", 134);
56 }
static int eventReleaseComputes
Definition: Sync.C:40
void NAMD_bug(const char *err_msg)
Definition: common.C:129
__global__ void const int const TileList *__restrict__ TileExcl *__restrict__ const int *__restrict__ const int const float2 *__restrict__ cudaTextureObject_t const int *__restrict__ const float3 const float3 const float3 const float4 *__restrict__ const float cudaTextureObject_t cudaTextureObject_t float const PatchPairRecord *__restrict__ const int *__restrict__ const int2 *__restrict__ const unsigned int *__restrict__ unsigned int *__restrict__ int *__restrict__ int *__restrict__ TileListStat *__restrict__ const BoundingBox *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ const int numPatches
static int eventHoldComputes
Definition: Sync.C:39
Sync::~Sync ( void  )

Definition at line 58 of file Sync.C.

59 {
60  delete [] clist;
61 }

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

104 {
105  if (!useSync) return 0;
106  if (step < 0) step = seq;
107  if (!useProxySync) {
108  // only hold when homepatches are not ready
109  PatchMap *patchMap = PatchMap::Object();
110  if (homeReady && seq == step) {
111  nPatcheReady++;
112  triggerCompute();
113  return 0;
114  }
115  }
116  traceUserEvent(eventHoldComputes);
117 
118  int slot = 0;
119  for (; slot < cnum; slot++)
120  if (clist[slot].pid == -1) break;
121  if (slot == cnum) {
122  cnum++;
123  // table is full, expand the list
124  if (cnum == capacity) {
125  capacity += INCREASE;
126  struct _clist *tmp = new _clist[capacity];
127  memcpy(tmp, clist, cnum*sizeof(_clist));
128  delete [] clist;
129  clist = tmp;
130  //CmiPrintf("[%d] Info:: Sync buffer overflow and expanded!\n", CkMyPe());
131  }
132  }
133 
134  clist[slot].cbegin = cbegin;
135  clist[slot].cend = cend;
136  clist[slot].pid = pid;
137  clist[slot].doneMigration = doneMigration;
138  clist[slot].step = seq;
139 
140 // CkPrintf("REG[%d]: patch:%d step:%d-%d slot:%d\n", CkMyPe(), pid, patchMap->patch(pid)->flags.sequence, step, slot);
141 
142  if (clist[slot].step == step) {
143  nPatcheReady++;
144  triggerCompute();
145  }
146  return 1;
147 }
static PatchMap * Object()
Definition: PatchMap.h:27
static int eventHoldComputes
Definition: Sync.C:39
static Sync* Sync::Object ( void  )
inlinestatic

Definition at line 50 of file Sync.h.

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

50 { return CkpvAccess(Sync_instance); }
void Sync::openSync ( void  )

Definition at line 63 of file Sync.C.

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

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

64 {
65  int reportPe = 1;
66  while ( 2 * reportPe < CkNumPes() ) reportPe *= 2;
67  step = -1;
68  useSync = 1;
69  if ( PatchMap::Object()->numPatches() >= 4 * CkNumPes() ) useSync = 0;
70  if ( CmiNumNodes() < 2 ) useSync = 0;
71  if ( CmiNumPhysicalNodes() < 2 ) useSync = 0;
72 #if defined(NAMD_CUDA) || defined(NAMD_HIP) || defined(NAMD_MIC)
73  useSync = 0;
74 #endif
75  useProxySync = 0;
76  if (useSync) {
77  // if use proxy spanning tree, proxy sync is forced
78  if (!useProxySync && (proxySendSpanning || proxyRecvSpanning)
79  && PatchMap::Object()->numPatches() < 4 * CkNumPes() ) {
80  // If on BG/P, useProxySync should not be turned on for better performance
81  #if ! (CMK_BLUEGENEQ || CMK_BLUEGENEP)
82  // CmiPrintf("[%d] useProxySync is turned on. \n", CkMyPe());
83  useProxySync = 1;
84  #endif
85  }
86 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)
87  // immediate messages can be processed by any PE
88  if (CkMyNodeSize() > 2) useProxySync = 0;
89 #endif
90  // no proxies on this node, no need to use proxy sync.
91  if (useProxySync && ProxyMgr::Object()->numProxies() == 0) {
92  // CmiPrintf("[%d] useProxySync is turned off because no proxy. \n", CkMyPe());
93  useProxySync = 0;
94  }
95  // if no proxy sync and no home patch, then disable home patch sync as well
96  if (!useProxySync && PatchMap::Object()->numHomePatches() == 0) useSync = 0;
97  }
98  if(CkMyPe() == reportPe)
99  iout << iINFO << "useSync: " << useSync << " useProxySync: " << useProxySync << "\n" << endi;
100 }
std::ostream & iINFO(std::ostream &s)
Definition: InfoStream.C:81
int proxyRecvSpanning
Definition: ProxyMgr.C:46
static ProxyMgr * Object()
Definition: ProxyMgr.h:394
static PatchMap * Object()
Definition: PatchMap.h:27
std::ostream & endi(std::ostream &s)
Definition: InfoStream.C:54
#define iout
Definition: InfoStream.h:51
__global__ void const int const TileList *__restrict__ TileExcl *__restrict__ const int *__restrict__ const int const float2 *__restrict__ cudaTextureObject_t const int *__restrict__ const float3 const float3 const float3 const float4 *__restrict__ const float cudaTextureObject_t cudaTextureObject_t float const PatchPairRecord *__restrict__ const int *__restrict__ const int2 *__restrict__ const unsigned int *__restrict__ unsigned int *__restrict__ int *__restrict__ int *__restrict__ TileListStat *__restrict__ const BoundingBox *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ const int numPatches
int proxySendSpanning
Definition: ProxyMgr.C:45
void Sync::PatchReady ( void  )

Definition at line 150 of file Sync.C.

Referenced by HomePatch::positionsReady().

151 {
152  if ( useSync ) {
153  counter ++;
154  triggerCompute();
155  }
156 }

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