NAMD
Public Member Functions | List of all members
GlobalMasterServer Class Reference

#include <GlobalMasterServer.h>

Public Member Functions

 GlobalMasterServer (ComputeMgr *m, int theNumDataSenders)
 
virtual ~GlobalMasterServer ()
 
void recvData (ComputeGlobalDataMsg *)
 
void addClient (GlobalMaster *newClient)
 

Detailed Description

Definition at line 22 of file GlobalMasterServer.h.

Constructor & Destructor Documentation

GlobalMasterServer::GlobalMasterServer ( ComputeMgr m,
int  theNumDataSenders 
)

Definition at line 580 of file GlobalMasterServer.C.

References DebugM, SimParameters::lattice, Node::Object(), and Node::simParameters.

581  {
582  DebugM(3,"Constructing GlobalMasterServer\n");
583  myComputeManager = m;
584  numDataSenders = 0; // theNumDataSenders;
585  numForceSenders = 0;
586  latticeCount = 0;
587  lattice = Node::Object()->simParameters->lattice;
588  recvCount = 0; /* we haven't gotten any messages yet */
589  recvPatchesCount = 0;
590  firstTime = 1; /* XXX temporary */
591  step = -1;
592  totalAtomsRequested = 0;
593  totalGroupsRequested = 0;
594  forceSendEnabled = 0;
595  if ( Node::Object()->simParameters->tclForcesOn ) forceSendEnabled = 1;
596  if ( Node::Object()->simParameters->colvarsOn ) forceSendEnabled = 1;
597  DebugM(3,"done constructing\n");
598 }
static Node * Object()
Definition: Node.h:86
SimParameters * simParameters
Definition: Node.h:178
#define DebugM(x, y)
Definition: Debug.h:59
GlobalMasterServer::~GlobalMasterServer ( )
virtual

Definition at line 600 of file GlobalMasterServer.C.

600  {
601  GlobalMaster *m_i = *clientList.begin();
602  GlobalMaster *m_e = *clientList.end();
603 
604  /* delete each of the masters */
605  while(m_i != m_e) {
606  delete m_i;
607  m_i++;
608  }
609 }
iterator end(void)
Definition: ResizeArray.h:37
iterator begin(void)
Definition: ResizeArray.h:36

Member Function Documentation

void GlobalMasterServer::addClient ( GlobalMaster newClient)

Definition at line 31 of file GlobalMasterServer.C.

References DebugM, and GlobalMaster::setLattice().

Referenced by ComputeMgr::createComputes().

31  {
32  DebugM(3,"Adding client\n");
33  clientList.add(newClient);
34  newClient->setLattice(&lattice);
35  DebugM(2,"Added.\n");
36 }
#define DebugM(x, y)
Definition: Debug.h:59
void setLattice(const Lattice *lat)
Definition: GlobalMaster.h:77
int add(const Elem &elem)
Definition: ResizeArray.h:97
void GlobalMasterServer::recvData ( ComputeGlobalDataMsg msg)

Definition at line 38 of file GlobalMasterServer.C.

References ComputeGlobalDataMsg::aid, ResizeArray< T >::begin(), ComputeGlobalDataMsg::count, DebugM, ResizeArray< T >::end(), endi(), ComputeGlobalDataMsg::fid, ComputeGlobalDataMsg::gcom, ComputeGlobalDataMsg::gmass, ComputeGlobalDataMsg::gridobjindex, ComputeGlobalDataMsg::gridobjvalue, ComputeGlobalDataMsg::gtf, ComputeGlobalDataMsg::lat, NAMD_bug(), PatchMap::numPatches(), numPatches, PatchMap::Object(), ComputeGlobalDataMsg::p, ComputeGlobalDataMsg::patchcount, ResizeArray< T >::size(), ComputeGlobalDataMsg::step, and ComputeGlobalDataMsg::tf.

Referenced by ComputeMgr::recvComputeGlobalData().

38  {
39  DebugM(3,"Storing data (" << msg->aid.size() << " positions) on master\n");
40 
41  if ( msg->step != -1 ) step = msg->step;
42 
43  /* get the beginning and end of the lists */
44  AtomIDList::iterator a_i = msg->aid.begin();
45  AtomIDList::iterator a_e = msg->aid.end();
46  PositionList::iterator p_i = msg->p.begin();
47  PositionList::iterator g_i = msg->gcom.begin();
48  PositionList::iterator g_e = msg->gcom.end();
49  BigRealList::iterator gm_i = msg->gmass.begin();
50 
51  /* iterate over each member of the atom lists */
52  for ( ; a_i != a_e; ++a_i, ++p_i ) {
53  receivedAtomIDs.add(*a_i);
54  receivedAtomPositions.add(*p_i);
55  }
56 
57  /* iterate over each member of "total force" lists */
58  a_e = msg->fid.end();
59  ForceList::iterator f_i=msg->tf.begin();
60  for (a_i=msg->fid.begin() ; a_i!=a_e; ++a_i,++f_i) {
61  receivedForceIDs.add(*a_i);
62  receivedTotalForces.add(*f_i);
63  }
64 
65  /* iterate over each member of the group position list */
66  int i=0;
67  for ( ; g_i != g_e; ++g_i, ++gm_i ) {
68  DebugM(1,"Received center of mass "<<*g_i<<"\n");
69  if(i >= totalGroupsRequested) NAMD_bug("Received too many groups.");
70  receivedGroupPositions[i] += (*g_i);
71  receivedGroupMasses[i] += (*gm_i);
72  i++;
73  }
74  if(i!=totalGroupsRequested) NAMD_bug("Received too few groups.");
75 
76  /* iterate over each member of group total force lists */
77  int ntf = msg->gtf.size();
78  if ( ntf && ntf != receivedGroupTotalForces.size() ) NAMD_bug("Received wrong number of group forces.");
79  ForceList::iterator gf_i=msg->gtf.begin();
80  ForceList::iterator gf_e=msg->gtf.end();
81  for ( i=0 ; gf_i != gf_e; ++gf_i, ++i ) {
82  receivedGroupTotalForces[i] += (*gf_i);
83  }
84 
85  // Get values of the GridForce objects
86  int ngov = msg->gridobjvalue.size();
87  IntList::iterator goi_i = msg->gridobjindex.begin();
89  BigRealList::iterator gov_e = msg->gridobjvalue.end();
90  for ( i=0 ; gov_i != gov_e; gov_i++, goi_i++, i++ ) {
91  receivedGridObjIndices[i] = (*goi_i);
92  receivedGridObjValues[i] += (*gov_i);
93  }
94  if (ngov && ngov != receivedGridObjValues.size()) {
95  NAMD_bug("Received wrong number of grid objects.");
96  }
97 
98  if ( msg->lat.size() ) {
99  if ( latticeCount ) {
100  NAMD_bug("GlobalMasterServer::recvData received lattice twice.");
101  }
102  lattice = msg->lat[0];
103  latticeCount = 1;
104  }
105 
106  recvCount += msg->count;
107  recvPatchesCount += msg->patchcount;
109 
110  /* done with the message, delete it */
111  delete msg;
112 
113  /* check whether we've gotten all the expected messages */
114 
115  DebugM(3, "received " << recvCount << " atom messages and "
116  << recvPatchesCount << " patch messages (out of " << numPatches
117  << " patches) from the ComputeGlobals\n" << endi);
118 
119  int numNeededPatches = totalGridObjsRequested ? numPatches : 0;
120  if (firstTime) numNeededPatches = 0;
121 
122  if (recvCount > numDataSenders + numForceSenders + 1) {
123  NAMD_bug("GlobalMasterServer::recvData recvCount too high.");
124  }
125 
126  if (recvPatchesCount > numPatches) {
127  NAMD_bug("GlobalMasterServer::recvData too many patches received.");
128  }
129 
130  if ((recvCount == numDataSenders + numForceSenders + 1) &&
131  (recvPatchesCount == numNeededPatches)) {
132 
133  if ( ! latticeCount ) {
134  NAMD_bug("GlobalMasterServer::recvData did not receive lattice.");
135  }
136 
137  DebugM(3, "Received all needed data\n" << endi);
138 
139 #ifdef DEBUGM
140  for (size_t ig = 0; ig < receivedGroupMasses.size(); ig++) {
141  // The groups' positions will be normalized later, in callClients()
142  DebugM(3, "Group mass " << ig << " = "
143  << receivedGroupMasses[ig] << "\n" << endi);
144  }
145  for (size_t ig = 0; ig < receivedGridObjValues.size(); ig++) {
146  DebugM(3, "Grid object " << receivedGridObjIndices[ig] << " = "
147  << receivedGridObjValues[ig] << "\n" << endi);
148  }
149 #endif
150 
151  int oldTotalGroupsRequested = totalGroupsRequested;
152 
153  int resendCoordinates = callClients();
154 
155  if (resendCoordinates) {
156  DebugM(3, "resendCoordinates\n" << endi);
157  }
158 
159  /* now restart */
160  step = -1;
161  receivedAtomIDs.resize(0);
162  receivedAtomPositions.resize(0);
163  receivedGroupPositions.resize(totalGroupsRequested);
164  receivedGroupPositions.setall(Vector(0,0,0));
165  receivedGroupMasses.resize(totalGroupsRequested);
166  receivedGroupMasses.setall(0);
167  receivedGridObjIndices.resize(totalGridObjsRequested);
168  receivedGridObjIndices.setall(-1);
169  receivedGridObjValues.resize(totalGridObjsRequested);
170  receivedGridObjValues.setall(0);
171  latticeCount = 0;
172  recvCount = 0;
173  recvPatchesCount = 0;
174  if ( resendCoordinates ) {
175  recvCount += numForceSenders;
176  } else {
177  receivedGroupTotalForces.resize(totalGroupsRequested);
178  receivedGroupTotalForces.setall(0);
179  receivedForceIDs.resize(0);
180  receivedTotalForces.resize(0);
181  }
182  }
183 }
static PatchMap * Object()
Definition: PatchMap.h:27
BigRealList gridobjvalue
Partial values of the GridForce objects from this message.
Definition: Vector.h:64
#define DebugM(x, y)
Definition: Debug.h:59
std::ostream & endi(std::ostream &s)
Definition: InfoStream.C:54
void NAMD_bug(const char *err_msg)
Definition: common.C:129
iterator end(void)
Definition: ResizeArray.h:37
ResizeArray< Lattice > lat
IntList gridobjindex
Indices of the GridForce objects contained in this message.
void setall(const Elem &elem)
Definition: ResizeArray.h:90
__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 add(const Elem &elem)
Definition: ResizeArray.h:97
int numPatches(void) const
Definition: PatchMap.h:59
void resize(int i)
Definition: ResizeArray.h:84
int count
Numer of atoms processed for this message.
int size(void) const
Definition: ResizeArray.h:127
int patchcount
Number of patches processed for this message.
iterator begin(void)
Definition: ResizeArray.h:36

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