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 (ComputeData *buf)
void unpack (int n, ComputeData *buf)
void initPtrs ()
void extendPtrs ()
 ComputeMap (void)

Friends

class ComputeMgr
class WorkDistrib

Classes

struct  ComputeData
struct  PatchRec


Detailed Description

Definition at line 84 of file ComputeMap.h.


Member Enumeration Documentation

anonymous enum

Enumerator:
numPidsAllocated 

Definition at line 182 of file ComputeMap.h.

00182 { numPidsAllocated=8 };


Constructor & Destructor Documentation

ComputeMap::~ComputeMap ( void   ) 

Definition at line 41 of file ComputeMap.C.

00042 {
00043   delete [] computePtrs;
00044 }

ComputeMap::ComputeMap ( void   )  [protected]

Definition at line 34 of file ComputeMap.C.

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


Member Function Documentation

int ComputeMap::allocateCids (  ) 

Definition at line 142 of file ComputeMap.C.

Referenced by WorkDistrib::mapComputes().

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

void ComputeMap::checkMap (  ) 

Definition at line 47 of file ComputeMap.C.

References DebugM.

Referenced by ComputeMgr::updateLocalComputes5().

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

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

Definition at line 184 of file ComputeMap.C.

Referenced by ComputeMgr::splitComputes().

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

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

Definition at line 170 of file ComputeMap.h.

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

00170 { return computePtrs[cid]; };

void ComputeMap::extendPtrs (  )  [protected]

Definition at line 88 of file ComputeMap.C.

References NAMD_bug().

Referenced by ComputeMgr::splitComputes().

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

void ComputeMap::initPtrs (  )  [protected]

Definition at line 81 of file ComputeMap.C.

Referenced by WorkDistrib::saveComputeMap(), and WorkDistrib::sendComputeMap().

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

ComputeMap * ComputeMap::Instance (  )  [static]

Definition at line 25 of file ComputeMap.C.

Referenced by Node::Node().

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

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 115 of file ComputeMap.h.

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

00115                                        {
00116     return (computeData[cid].moveToNode);
00117   }

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

Definition at line 140 of file ComputeMap.h.

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

00140                                               {
00141     return (computeData[cid].newNumPartitions);
00142   }

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

Definition at line 197 of file ComputeMap.C.

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

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

Definition at line 105 of file ComputeMap.h.

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

00105                                  {
00106     return computeData[cid].node;
00107   }

int ComputeMap::numComputes ( void   )  [inline]

Definition at line 100 of file ComputeMap.h.

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

00100                                {
00101     return nComputes;
00102   }

int ComputeMap::numPartitions ( ComputeID  cid  ) 

Definition at line 134 of file ComputeMap.C.

References computeErrorType.

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

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

int ComputeMap::numPids ( ComputeID  cid  ) 

Definition at line 102 of file ComputeMap.C.

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

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

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

Definition at line 88 of file ComputeMap.h.

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

00088 { return instance; }

void ComputeMap::pack ( ComputeData buf  )  [protected]

Definition at line 62 of file ComputeMap.C.

References DebugM.

Referenced by WorkDistrib::sendComputeMap().

00063 {
00064   DebugM(4,"Packing ComputeMap\n");
00065   memcpy(buffer, computeData.begin(), nComputes * sizeof(ComputeData));
00066 }

int ComputeMap::partition ( ComputeID  cid  ) 

Definition at line 127 of file ComputeMap.C.

References computeErrorType.

Referenced by dumpbench().

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

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

Definition at line 108 of file ComputeMap.C.

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

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

void ComputeMap::printComputeMap ( void   ) 

Definition at line 205 of file ComputeMap.C.

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

00206 {
00207   DebugM(2,"---------------------------------------");
00208   DebugM(2,"---------------------------------------\n");
00209 
00210   DebugM(2,"nComputes = " << nComputes << '\n');
00211   DebugM(2,"nAllocated = " << nComputes << '\n');
00212   for(int i=0; i < nComputes; i++)
00213   {
00214     DebugM(2,"Compute " << i << '\n');
00215     DebugM(2,"  node = " << computeData[i].node << '\n');
00216     DebugM(2,"  numPids = " << computeData[i].numPids << '\n');
00217     for(int j=0; j < computeData[i].numPids; j++)
00218     {
00219       DebugM(2,computeData[i].pids[j].pid);
00220       if (!((j+1) % 6))
00221         DebugM(2,'\n');
00222     }
00223     DebugM(2,"\n---------------------------------------");
00224     DebugM(2,"---------------------------------------\n");
00225 
00226   }
00227 
00228 char *fname;
00229 #ifdef MEM_OPT_VERSION
00230 fname = "computeMap.opt";
00231 #else
00232 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 94 of file ComputeMap.h.

Referenced by ComputeMgr::updateLocalComputes().

00094                                                   {
00095     computePtrs[cid] = c;
00096   }

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 119 of file ComputeMap.h.

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

00119                                                      {
00120     computeData[cid].moveToNode = node;
00121   }

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

Definition at line 143 of file ComputeMap.h.

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

00143                                                                      {
00144     computeData[cid].newNumPartitions = numPartitions;
00145   }

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

Definition at line 109 of file ComputeMap.h.

Referenced by ComputeMgr::updateLocalComputes3().

00109                                                   {
00110     computeData[cid].node = node;
00111   }

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

Definition at line 137 of file ComputeMap.h.

Referenced by ComputeMgr::splitComputes().

00137                                                                   {
00138     computeData[cid].numPartitions = numPartitions;
00139   }

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

Definition at line 152 of file ComputeMap.C.

References NAMD_bug(), and numPidsAllocated.

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

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

Definition at line 113 of file ComputeMap.C.

Referenced by dumpbench(), and registerUserEventsForAllComputeObjs().

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

ComputeType ComputeMap::type ( ComputeID  cid  ) 

Definition at line 119 of file ComputeMap.C.

References computeErrorType.

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

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

void ComputeMap::unpack ( int  n,
ComputeData buf 
) [protected]

Definition at line 68 of file ComputeMap.C.

References DebugM, and NAMD_bug().

Referenced by WorkDistrib::saveComputeMap().

00069 {
00070   DebugM(4,"Unpacking ComputeMap\n");
00071 
00072   if ( nComputes && n != nComputes ) {
00073     NAMD_bug("number of computes in new ComputeMap has changed!\n");
00074   }
00075 
00076   nComputes = n;
00077   computeData.resize(nComputes);
00078   memcpy(computeData.begin(), ptr, nComputes * sizeof(ComputeData));
00079 }


Friends And Related Function Documentation

friend class ComputeMgr [friend]

Definition at line 170 of file ComputeMap.h.

friend class WorkDistrib [friend]

Definition at line 207 of file ComputeMap.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 23 01:17:17 2017 for NAMD by  doxygen 1.4.7