ComputeMap Class Reference

#include <ComputeMap.h>

List of all members.

Public Types

 numPidsAllocated = 8
enum  { numPidsAllocated = 8 }

Public Member Functions

void checkMap ()
 ~ComputeMap (void)
void registerCompute (ComputeID cid, Compute *c)
int numComputes (void)
int node (ComputeID cid)
void setNode (ComputeID cid, NodeID node)
NodeID newNode (ComputeID cid)
void setNewNode (ComputeID cid, NodeID node)
int numPids (ComputeID cid)
int pid (ComputeID cid, int i)
int trans (ComputeID cid, int i)
ComputeType type (ComputeID cid)
int partition (ComputeID cid)
int numPartitions (ComputeID cid)
void setNumPartitions (ComputeID cid, char numPartitions)
char newNumPartitions (ComputeID cid)
void setNewNumPartitions (ComputeID cid, char numPartitions)
int allocateCids ()
ComputeID storeCompute (int node, int maxPids, ComputeType type, int partition=-1, int numPartitions=0)
void newPid (ComputeID cid, int pid, int trans=13)
ComputeID cloneCompute (ComputeID src, int partition)
void printComputeMap (void)
void saveComputeMap (const char *fname)
void loadComputeMap (const char *fname)
Computecompute (ComputeID cid)

Static Public Member Functions

static ComputeMapInstance ()
static ComputeMapObject ()

Protected Member Functions

void pack (MOStream *msg)
void unpack (MIStream *msg)
void initPtrs ()
void extendPtrs ()
 ComputeMap (void)

Friends

class ComputeMgr
class WorkDistrib

Classes

struct  ComputeData
struct  PatchRec


Detailed Description

Definition at line 86 of file ComputeMap.h.


Member Enumeration Documentation

anonymous enum

Enumerator:
numPidsAllocated 

Definition at line 184 of file ComputeMap.h.

00184 { numPidsAllocated=8 };


Constructor & Destructor Documentation

ComputeMap::~ComputeMap ( void   ) 

Definition at line 42 of file ComputeMap.C.

00043 {
00044   delete [] computePtrs;
00045 }

ComputeMap::ComputeMap ( void   )  [protected]

Definition at line 35 of file ComputeMap.C.

00036 {
00037   nComputes=0;
00038   computePtrs=0;
00039 }


Member Function Documentation

int ComputeMap::allocateCids (  ) 

Definition at line 143 of file ComputeMap.C.

Referenced by WorkDistrib::mapComputes().

00144 {
00145   nComputes = 0;
00146   computeData.resize(500);
00147   computeData.resize(0);
00148 
00149   return 0;
00150 }

void ComputeMap::checkMap (  ) 

Definition at line 48 of file ComputeMap.C.

References DebugM.

Referenced by ComputeMgr::updateLocalComputes5().

00049 {
00050   int computeCount = nComputes;
00051   for (int i=0; i<nComputes; i++) {
00052     if (computePtrs[i]) {
00053       computeCount++;
00054       if (! (computePtrs[i]->cid == i)) {
00055         DebugM(4, "ComputeID("<<computePtrs[i]->cid<<") != ComputeID("
00056           << i <<")\n");
00057       }
00058     }
00059   }
00060   DebugM(4, "Compute Count = " << computeCount << "\n");
00061 }

ComputeID ComputeMap::cloneCompute ( ComputeID  src,
int  partition 
)

Definition at line 185 of file ComputeMap.C.

Referenced by ComputeMgr::splitComputes().

00186 {
00187   const int cid = computeData.size();
00188   computeData.resize(cid+1);
00189 
00190   computeData[cid] = computeData[src];
00191   computeData[cid].partition = partition;
00192   computeData[cid].node = -1;
00193 
00194   return cid;
00195 }

Compute* ComputeMap::compute ( ComputeID  cid  )  [inline]

Definition at line 172 of file ComputeMap.h.

Referenced by LdbCoordinator::initialize(), and ComputeMgr::updateLocalComputes().

00172 { return computePtrs[cid]; };

void ComputeMap::extendPtrs (  )  [protected]

Definition at line 89 of file ComputeMap.C.

References NAMD_bug().

Referenced by ComputeMgr::splitComputes().

00089                             {
00090   if ( ! computePtrs ) NAMD_bug("ComputeMap::extendPtrs() 1");
00091   int oldN = nComputes;
00092   nComputes = computeData.size();
00093   if ( nComputes > oldN ) {
00094     Compute **oldPtrs = computePtrs;
00095     computePtrs = new Compute*[nComputes];
00096     memcpy(computePtrs, oldPtrs, oldN*sizeof(Compute*));
00097     memset(computePtrs+oldN, 0, (nComputes-oldN)*sizeof(Compute*));
00098     delete [] oldPtrs;
00099   }
00100 }

void ComputeMap::initPtrs (  )  [protected]

Definition at line 82 of file ComputeMap.C.

Referenced by WorkDistrib::sendComputeMap().

00082                           {
00083   if ( ! computePtrs ) {
00084     computePtrs = new Compute*[nComputes];
00085     memset(computePtrs, 0, nComputes*sizeof(Compute*));
00086   }
00087 }

ComputeMap * ComputeMap::Instance (  )  [static]

Definition at line 26 of file ComputeMap.C.

Referenced by Node::Node().

00026                                  {
00027   if (instance == 0) {
00028     instance = new ComputeMap;  // this is never deleted
00029   }
00030   return instance;
00031 }

void ComputeMap::loadComputeMap ( const char *  fname  ) 

Definition at line 278 of file ComputeMap.C.

References node().

Referenced by WorkDistrib::mapComputes().

00279 {
00280   FILE *fp = fopen(fname, "r");
00281   CmiAssert(fp != NULL);
00282   int n;
00283   fscanf(fp, "%d\n", &n);
00284   CmiAssert(n == nComputes);
00285   for(int i=0; i < nComputes; i++)
00286   {
00287     fscanf(fp, "%d\n", &computeData[i].node);
00288   }
00289   fclose(fp);
00290 }

NodeID ComputeMap::newNode ( ComputeID  cid  )  [inline]

Definition at line 117 of file ComputeMap.h.

Referenced by WorkDistrib::recvComputeMapChanges(), ComputeMgr::splitComputes(), ComputeMgr::updateLocalComputes(), and ComputeMgr::updateLocalComputes3().

00117                                        {
00118     return (computeData[cid].moveToNode);
00119   }

char ComputeMap::newNumPartitions ( ComputeID  cid  )  [inline]

Definition at line 142 of file ComputeMap.h.

Referenced by WorkDistrib::recvComputeMapChanges(), ComputeMgr::splitComputes(), and ComputeMgr::updateLocalComputes().

00142                                               {
00143     return (computeData[cid].newNumPartitions);
00144   }

void ComputeMap::newPid ( ComputeID  cid,
int  pid,
int  trans = 13 
)

Definition at line 198 of file ComputeMap.C.

00199 {
00200   computeData[cid].pids[computeData[cid].numPids].pid=pid;
00201   computeData[cid].pids[computeData[cid].numPids].trans=trans;
00202   computeData[cid].numPids++;
00203 }

int ComputeMap::node ( ComputeID  cid  )  [inline]

Definition at line 107 of file ComputeMap.h.

Referenced by ProxyMgr::createProxies(), LdbCoordinator::initialize(), loadComputeMap(), Node::outputPatchComputeMaps(), printComputeMap(), saveComputeMap(), ComputeMgr::splitComputes(), and ComputeMgr::updateLocalComputes().

00107                                  {
00108     return computeData[cid].node;
00109   }

int ComputeMap::numComputes ( void   )  [inline]

Definition at line 102 of file ComputeMap.h.

Referenced by ProxyMgr::createProxies(), dumpbench(), LdbCoordinator::initialize(), Node::outputPatchComputeMaps(), WorkDistrib::recvComputeMapChanges(), registerUserEventsForAllComputeObjs(), ComputeMgr::splitComputes(), Node::startup(), NamdCentLB::Strategy(), ComputeMgr::updateLocalComputes(), and ComputeMgr::updateLocalComputes3().

00102                                {
00103     return nComputes;
00104   }

int ComputeMap::numPartitions ( ComputeID  cid  ) 

Definition at line 135 of file ComputeMap.C.

References computeErrorType.

Referenced by ComputeMgr::splitComputes(), and NamdCentLB::Strategy().

00136 {
00137   if (nComputes)
00138     return computeData[cid].numPartitions;
00139   else return computeErrorType;
00140 }

int ComputeMap::numPids ( ComputeID  cid  ) 

Definition at line 103 of file ComputeMap.C.

Referenced by ProxyMgr::createProxies(), LdbCoordinator::initialize(), printComputeMap(), and ComputeMgr::updateLocalComputes().

00104 {
00105     return computeData[cid].numPids;
00106 }

static ComputeMap* ComputeMap::Object (  )  [inline, static]

Definition at line 90 of file ComputeMap.h.

Referenced by Compute::Compute(), ProxyMgr::createProxies(), dumpbench(), WorkDistrib::mapComputes(), Node::outputPatchComputeMaps(), WorkDistrib::recvComputeMapChanges(), registerUserEventsForAllComputeObjs(), LdbCoordinator::resume(), WorkDistrib::sendComputeMap(), NamdHybridLB::splitComputes(), ComputeMgr::splitComputes(), Node::startup(), NamdCentLB::Strategy(), ComputeMgr::updateLocalComputes(), ComputeMgr::updateLocalComputes3(), ComputeMgr::updateLocalComputes4(), ComputeMgr::updateLocalComputes5(), and NamdHybridLB::UpdateLocalLBInfo().

00090 { return instance; }

void ComputeMap::pack ( MOStream msg  )  [protected]

Definition at line 63 of file ComputeMap.C.

References DebugM, and MOStream::put().

Referenced by WorkDistrib::sendComputeMap().

00064 {
00065   DebugM(4,"Packing ComputeMap\n");
00066   msg->put(nComputes);
00067   msg->put(nComputes,computeData.begin());
00068 }

int ComputeMap::partition ( ComputeID  cid  ) 

Definition at line 128 of file ComputeMap.C.

References computeErrorType.

Referenced by dumpbench().

00129 {
00130   if (nComputes)
00131     return computeData[cid].partition;
00132   else return computeErrorType;
00133 }

int ComputeMap::pid ( ComputeID  cid,
int  i 
)

Definition at line 109 of file ComputeMap.C.

Referenced by ProxyMgr::createProxies(), dumpbench(), LdbCoordinator::initialize(), Node::outputPatchComputeMaps(), printComputeMap(), registerUserEventsForAllComputeObjs(), and ComputeMgr::updateLocalComputes().

00110 {
00111     return computeData[cid].pids[i].pid;
00112 }

void ComputeMap::printComputeMap ( void   ) 

Definition at line 206 of file ComputeMap.C.

References DebugM, j, node(), numPids(), pid(), and type().

00207 {
00208   DebugM(2,"---------------------------------------");
00209   DebugM(2,"---------------------------------------\n");
00210 
00211   DebugM(2,"nComputes = " << nComputes << '\n');
00212   DebugM(2,"nAllocated = " << nComputes << '\n');
00213   for(int i=0; i < nComputes; i++)
00214   {
00215     DebugM(2,"Compute " << i << '\n');
00216     DebugM(2,"  node = " << computeData[i].node << '\n');
00217     DebugM(2,"  numPids = " << computeData[i].numPids << '\n');
00218     for(int j=0; j < computeData[i].numPids; j++)
00219     {
00220       DebugM(2,computeData[i].pids[j].pid);
00221       if (!((j+1) % 6))
00222         DebugM(2,'\n');
00223     }
00224     DebugM(2,"\n---------------------------------------");
00225     DebugM(2,"---------------------------------------\n");
00226 
00227   }
00228 
00229 #ifdef MEM_OPT_VERSION
00230 const char *fname = "computeMap.opt";
00231 #else
00232 const char *fname = "computeMap.orig";
00233 #endif
00234 
00235   FILE *ofp = fopen(fname, "w");
00236   fprintf(ofp,"---------------------------------------");
00237   fprintf(ofp,"---------------------------------------\n");
00238 
00239   fprintf(ofp,"nComputes = %d\n", nComputes);
00240   fprintf(ofp,"nAllocated = %d\n", nComputes);
00241   for(int i=0; i < nComputes; i++)
00242   {
00243     fprintf(ofp,"Compute %d\n", i);
00244     fprintf(ofp,"  node = %d\n",computeData[i].node);
00245     fprintf(ofp,"  numPids = %d\n",computeData[i].numPids);
00246         fprintf(ofp,"  type = %d\n",computeData[i].type);
00247     for(int j=0; j < computeData[i].numPids; j++)
00248     {
00249       fprintf(ofp,"%d ",computeData[i].pids[j].pid);
00250       if (!((j+1) % 6))
00251         fprintf(ofp,"\n");
00252     }
00253     fprintf(ofp,"\n---------------------------------------");
00254     fprintf(ofp,"---------------------------------------\n");
00255 
00256   }
00257 
00258 fclose(ofp);
00259 
00260 }

void ComputeMap::registerCompute ( ComputeID  cid,
Compute c 
) [inline]

Definition at line 96 of file ComputeMap.h.

Referenced by ComputeMgr::updateLocalComputes().

00096                                                   {
00097     computePtrs[cid] = c;
00098   }

void ComputeMap::saveComputeMap ( const char *  fname  ) 

Definition at line 262 of file ComputeMap.C.

References f, and node().

Referenced by WorkDistrib::mapComputes(), and ComputeMgr::updateLocalComputes4().

00263 {
00264   static int count = 0;
00265   char f[128];
00266   sprintf(f, "%s.%d", fname, count++);
00267   FILE *fp = fopen(f, "w");
00268   CmiAssert(fp != NULL);
00269   fprintf(fp, "%d\n", nComputes);
00270   for(int i=0; i < nComputes; i++)
00271   {
00272     fprintf(fp, "%d\n", computeData[i].node);
00273   }
00274   fclose(fp);
00275   CkPrintf("ComputeMap has been stored in %s.\n", f);
00276 }

void ComputeMap::setNewNode ( ComputeID  cid,
NodeID  node 
) [inline]

Definition at line 121 of file ComputeMap.h.

Referenced by WorkDistrib::recvComputeMapChanges(), ComputeMgr::splitComputes(), NamdCentLB::Strategy(), ComputeMgr::updateLocalComputes3(), and NamdHybridLB::UpdateLocalLBInfo().

00121                                                      {
00122     computeData[cid].moveToNode = node;
00123   }

void ComputeMap::setNewNumPartitions ( ComputeID  cid,
char  numPartitions 
) [inline]

Definition at line 145 of file ComputeMap.h.

Referenced by WorkDistrib::recvComputeMapChanges(), ComputeMgr::splitComputes(), NamdCentLB::Strategy(), and ComputeMgr::updateLocalComputes3().

00145                                                                      {
00146     computeData[cid].newNumPartitions = numPartitions;
00147   }

void ComputeMap::setNode ( ComputeID  cid,
NodeID  node 
) [inline]

Definition at line 111 of file ComputeMap.h.

Referenced by ComputeMgr::updateLocalComputes3().

00111                                                   {
00112     computeData[cid].node = node;
00113   }

void ComputeMap::setNumPartitions ( ComputeID  cid,
char  numPartitions 
) [inline]

Definition at line 139 of file ComputeMap.h.

Referenced by ComputeMgr::splitComputes().

00139                                                                   {
00140     computeData[cid].numPartitions = numPartitions;
00141   }

ComputeID ComputeMap::storeCompute ( int  node,
int  maxPids,
ComputeType  type,
int  partition = -1,
int  numPartitions = 0 
)

Definition at line 153 of file ComputeMap.C.

References NAMD_bug(), and numPidsAllocated.

00156 {
00157   if (maxPids > numPidsAllocated) {
00158     NAMD_bug("ComputeMap::storeCompute called with maxPids > numPidsAllocated");
00159   }
00160 
00161   int cid;
00162 
00163   cid = nComputes;
00164   nComputes++;
00165   computeData.resize(nComputes);
00166 
00167   computeData[cid].node=inode;
00168 
00169   computeData[cid].type = type;
00170   computeData[cid].partition = partition;
00171   computeData[cid].numPartitions = numPartitions;
00172 
00173   computeData[cid].numPids = 0;
00174 
00175   #if defined(NAMD_MIC)
00176     // Initially in MIC runs, all computes are mapped to the host.  The host vs
00177     //   device LDB scheme will change this mapping later.
00178     computeData[cid].directToDevice = 0;
00179   #endif
00180 
00181   return cid;
00182 }

int ComputeMap::trans ( ComputeID  cid,
int  i 
)

Definition at line 114 of file ComputeMap.C.

Referenced by dumpbench(), and registerUserEventsForAllComputeObjs().

00115 {
00116     return computeData[cid].pids[i].trans;
00117 }

ComputeType ComputeMap::type ( ComputeID  cid  ) 

Definition at line 120 of file ComputeMap.C.

References computeErrorType.

Referenced by Compute::Compute(), ComputeMgr::createComputes(), ProxyMgr::createProxies(), dumpbench(), LdbCoordinator::initialize(), Node::outputPatchComputeMaps(), printComputeMap(), and registerUserEventsForAllComputeObjs().

00121 {
00122   if (nComputes)
00123     return computeData[cid].type;
00124   else return computeErrorType;
00125 }

void ComputeMap::unpack ( MIStream msg  )  [protected]

Definition at line 70 of file ComputeMap.C.

References DebugM, MIStream::get(), and NAMD_bug().

Referenced by WorkDistrib::sendComputeMap().

00071 {
00072   DebugM(4,"Unpacking ComputeMap\n");
00073   int old = nComputes;
00074   msg->get(nComputes);
00075   if ( old && old != nComputes ) {
00076     NAMD_bug("number of computes in new ComputeMap has changed!\n");
00077   }
00078   computeData.resize(nComputes);
00079   msg->get(nComputes,computeData.begin());
00080 }


Friends And Related Function Documentation

friend class ComputeMgr [friend]

Definition at line 172 of file ComputeMap.h.

friend class WorkDistrib [friend]

Definition at line 209 of file ComputeMap.h.


The documentation for this class was generated from the following files:
Generated on Tue Jun 19 01:17:18 2018 for NAMD by  doxygen 1.4.7