Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

PatchMap Class Reference

#include <PatchMap.h>

List of all members.

Public Types

enum  { MaxTwoAway = 5*5*5 - 3*3*3 }
enum  { MaxOneAway = 3*3*3 - 1 }
enum  { MaxOneOrTwoAway = MaxOneAway + MaxTwoAway }

Public Member Functions

int sizeGrid (ScaledPosition xmin, ScaledPosition xmax, const Lattice &lattice, BigReal patchSize, double maxNumPatches, int staticAtomAssignment, int asplit, int bsplit, int csplit)
void makePatches (ScaledPosition xmin, ScaledPosition xmax, const Lattice &lattice, BigReal patchSize, double maxNumPatches, int staticAtomAssignment, int asplit, int bsplit, int csplit)
void checkMap ()
 ~PatchMap (void)
HomePatchListhomePatchList ()
void homePatchIDList (PatchIDList &)
void basePatchIDList (int pe, PatchIDList &)
int numHomePatches (void)
int numPatches (void) const
int numPatchesOnNode (int node)
int numNodesWithPatches (void)
int gridsize_a (void) const
int gridsize_b (void) const
int gridsize_c (void) const
int numaway_a (void) const
int numaway_b (void) const
int numaway_c (void) const
int periodic_a (void) const
int periodic_b (void) const
int periodic_c (void) const
ScaledPosition origin (void) const
int pid (int aIndex, int bIndex, int cIndex)
int index_a (int pid) const
int index_b (int pid) const
int index_c (int pid) const
BigReal min_a (int pid) const
BigReal max_a (int pid) const
BigReal min_b (int pid) const
BigReal max_b (int pid) const
BigReal min_c (int pid) const
BigReal max_c (int pid) const
ScaledPosition center (int pid) const
PatchID assignToPatch (Position p, const Lattice &l)
int downstream (int pid1, int pid2)
int node (int pid) const
int basenode (int pid) const
int numCids (int pid) const
int cid (int pid, int i) const
void assignNode (PatchID, NodeID)
void assignBaseNode (PatchID, NodeID)
void assignBaseNode (PatchID)
void newCid (int pid, int cid)
int oneAwayNeighbors (int pid, PatchID *neighbor_ids=0)
int oneOrTwoAwayNeighbors (int pid, PatchID *neighbor_ids, PatchID *downstream_ids=0, int *transform_ids=0)
int getPatchesInOctet (int pid, PatchID *pids, int *transform_ids=0)
int upstreamNeighbors (int pid, PatchID *neighbor_ids)
int downstreamNeighbors (int pid, PatchID *neighbor_ids)
void printPatchMap (void)
Patchpatch (PatchID pid)
HomePatchhomePatch (PatchID pid)
void registerPatch (PatchID pid, HomePatch *pptr)
void unregisterPatch (PatchID pid, HomePatch *pptr)
void registerPatch (PatchID pid, Patch *pptr)
void unregisterPatch (PatchID pid, Patch *pptr)
void initTmpPatchAtomsList ()
void delTmpPatchAtomsList ()
std::vector< int > * getTmpPatchAtomsList ()

Static Public Member Functions

PatchMapInstance ()
PatchMapObject ()
PatchMapObjectOnPe (int pe)
void registerPatchMgr (PatchMgr *pmgr)

Protected Member Functions

int packSize (void)
void pack (char *buf)
void unpack (char *buf)
 PatchMap (void)

Friends

class WorkDistrib


Member Enumeration Documentation

anonymous enum
 

Enumeration values:
MaxTwoAway 

Definition at line 44 of file PatchMap.h.

00044 { MaxTwoAway = 5*5*5 - 3*3*3 };

anonymous enum
 

Enumeration values:
MaxOneAway 

Definition at line 45 of file PatchMap.h.

00045 { MaxOneAway = 3*3*3 - 1 };

anonymous enum
 

Enumeration values:
MaxOneOrTwoAway 

Definition at line 46 of file PatchMap.h.


Constructor & Destructor Documentation

PatchMap::~PatchMap void   ) 
 

Definition at line 270 of file PatchMap.C.

00271 {
00272   if ( ! CkMyRank() ) {
00273     if (patchData && ! computeIdArena ) {
00274       for (int i=0; i<nPatches; i++) {
00275         delete [] patchData[i].cids;
00276       }
00277     }
00278     delete [] patchData;
00279     delete [] nPatchesOnNode;
00280     delete computeIdArena;
00281   }
00282   delete [] patchBounds_a;
00283   delete [] patchBounds_b;
00284   delete [] patchBounds_c;
00285   delete [] myPatch;
00286   delete [] myHomePatch;
00287 }

PatchMap::PatchMap void   )  [protected]
 

Definition at line 38 of file PatchMap.C.

00039 {
00040   nPatches = 0;
00041   nNodesWithPatches = 0;
00042   int npes = CkNumPes();
00043   if ( ! CkMyRank() ) {
00044     nPatchesOnNode = new int[npes];
00045     memset(nPatchesOnNode,0,npes*sizeof(int));
00046     patchData = NULL;
00047     computeIdArena = NULL;
00048   }
00049   patchBounds_a = 0;
00050   patchBounds_b = 0;
00051   patchBounds_c = 0;
00052   myPatch = 0;
00053   myHomePatch = 0;
00054 
00055   aDim = bDim = cDim = 0;
00056   aAway = bAway = cAway = 1;
00057   aPeriodic = bPeriodic = cPeriodic = 0;
00058   aMaxIndex = bMaxIndex = cMaxIndex = 0;
00059 }


Member Function Documentation

void PatchMap::assignBaseNode PatchID   ) 
 

Definition at line 452 of file PatchMap.C.

References node(), and NodeID.

00452                                          {
00453   
00454   int i = 1;
00455 
00456   NodeID node = patchData[pid].node;
00457 
00458   if ( CkNumPes() > 2*nPatches+1 ) {
00459 
00460     int newnode =  ( CkNumPes() + node - 1 ) % CkNumPes();    
00461     bool success = 0;
00462 
00463     while ( i < CkNumPes() && !success) {
00464       if ( nPatchesOnNode[newnode] == 0 )
00465         success = 1;
00466 
00467       //we know till pid, we have assigned all base nodes
00468       for (int count = 0; count < pid; count ++)
00469         if (patchData[count].basenode > 0 && patchData[count].basenode == newnode) {
00470           success = 0;
00471           break;
00472         }
00473           
00474       //no patch or a patche's base node on this newnode. this is a good node
00475       if (success) break;
00476 
00477       newnode = ( CkNumPes() + node - i - 1 ) % CkNumPes();
00478       i ++;
00479     }
00480     patchData[pid].basenode = newnode;
00481 
00482   } else {
00483     patchData[pid].basenode=node;
00484   }
00485 }

void PatchMap::assignBaseNode PatchID  ,
NodeID 
 

Definition at line 448 of file PatchMap.C.

00448                                                       {
00449   patchData[pid].basenode=node;
00450 }

void PatchMap::assignNode PatchID  ,
NodeID 
 

Definition at line 441 of file PatchMap.C.

00441                                                   {
00442   patchData[pid].node=node;
00443   if ( nPatchesOnNode[node] == 0 ) nNodesWithPatches += 1;
00444   nPatchesOnNode[node] += 1;
00445 }

PatchID PatchMap::assignToPatch Position  p,
const Lattice l
[inline]
 

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

Definition at line 14 of file PatchMap.inl.

References BigReal, PatchID, pid(), Position, Lattice::scale(), ScaledPosition, Vector::x, Vector::y, and Vector::z.

Referenced by ParallelIOMgr::calcAtomsInEachPatch(), and WorkDistrib::createAtomLists().

00015 {
00016   int ai, bi, ci;
00017   ScaledPosition s = l.scale(p);
00018   ai = (int)floor(((BigReal)aDim)*((s.x-aOrigin)/aLength));
00019   bi = (int)floor(((BigReal)bDim)*((s.y-bOrigin)/bLength));
00020   ci = (int)floor(((BigReal)cDim)*((s.z-cOrigin)/cLength));
00021   return pid(ai,bi,ci);
00022 }

int PatchMap::basenode int  pid  )  const [inline]
 

Definition at line 116 of file PatchMap.h.

Referenced by initializePmeMap(), and LdbCoordinator::requiredProxies().

00116 { return patchData[pid].basenode; }

void PatchMap::basePatchIDList int  pe,
PatchIDList
 

Definition at line 430 of file PatchMap.C.

References ResizeArray< Elem >::add(), PatchIDList, and ResizeArray< Elem >::resize().

Referenced by ProxyMgr::createProxies().

00430                                                         {
00431   pids.resize(0);
00432   int i;
00433   for ( i=0; i<nPatches; ++i ) {
00434     if ( patchData[i].basenode == pe ) {
00435       pids.add(i);
00436     }
00437   }
00438 }

ScaledPosition PatchMap::center int  pid  )  const [inline]
 

Definition at line 98 of file PatchMap.h.

References ScaledPosition.

Referenced by ComputeNonbondedCUDA::doWork(), and register_cuda_compute_pair().

00098                                               {
00099     const PatchData &pd = patchData[pid];
00100     return ScaledPosition(patchBounds_a[pd.aIndex*2+1],
00101                           patchBounds_b[pd.bIndex*2+1],
00102                           patchBounds_c[pd.cIndex*2+1]);
00103   }

void PatchMap::checkMap  ) 
 

Definition at line 253 of file PatchMap.C.

References DebugM, and Patch::getPatchID().

Referenced by ComputeMgr::updateLocalComputes5().

00254 {
00255   int patchCount=0;
00256   for (int i=0; i<nPatches; i++) {
00257     if (myPatch[i]) {
00258       patchCount++;
00259       if ( myPatch[i]->getPatchID() != i) {
00260         DebugM(4, "patchID("<<myPatch[i]->getPatchID()
00261           <<") != patchID(" 
00262           <<i<<")\n");
00263       }
00264     }
00265   }
00266   DebugM(4, "Patch Count = " <<patchCount<<"\n");
00267 }

int PatchMap::cid int  pid,
int  i
const [inline]
 

Definition at line 122 of file PatchMap.h.

Referenced by Sync::holdComputes().

00122 { return patchData[pid].cids[i]; }

void PatchMap::delTmpPatchAtomsList  )  [inline]
 

Definition at line 218 of file PatchMap.h.

Referenced by ParallelIOMgr::sendAtomsToHomePatchProcs().

00218                               {
00219       for(int i=0; i<nPatches; i++){
00220           tmpPatchAtomsList[i].clear();
00221       }
00222       delete [] tmpPatchAtomsList;
00223       tmpPatchAtomsList = NULL;
00224   }

int PatchMap::downstream int  pid1,
int  pid2
[inline]
 

Definition at line 51 of file PatchMap.inl.

References j, and notUsed.

Referenced by ComputeHomeTuples< TholeElem, Thole, TholeValue >::loadTuples().

00052 {
00053   register int ds;
00054 
00055   if ( pid1 == pid2 ) { ds = pid1; }
00056 
00057   else if ( pid1 == notUsed || pid2 == notUsed ) { ds =  notUsed; }
00058 
00059   else {
00060     register PatchData *pdat1 = &(patchData[pid1]);
00061     register PatchData *pdat2 = &(patchData[pid2]);
00062 
00063     // c
00064     register int k = pdat1->cIndex;
00065     register int k2 = pdat2->cIndex;
00066     if ( ( k ? k : cMaxIndex ) == k2 + 1 ) k = k2;
00067 
00068     // b
00069     register int j = pdat1->bIndex;
00070     register int j2 = pdat2->bIndex;
00071     if ( ( j ? j : bMaxIndex ) == j2 + 1 ) j = j2;
00072 
00073     // a
00074     register int i = pdat1->aIndex;
00075     register int i2 = pdat2->aIndex;
00076     if ( ( i ? i : aMaxIndex ) == i2 + 1 ) i = i2;
00077 
00078     ds = ((k*bDim)+j)*aDim + i;
00079   }
00080 
00081   return ds;
00082 }

int PatchMap::downstreamNeighbors int  pid,
PatchID neighbor_ids
 

Definition at line 690 of file PatchMap.C.

References DebugM, Lattice::index(), and pid().

Referenced by LdbCoordinator::requiredProxies().

00691 {
00692   int xi, yi, zi;
00693   int xinc, yinc, zinc;
00694   int n=0;
00695 
00696   for(zinc=-1;zinc<=0;zinc++)
00697   {
00698     zi = patchData[pid].cIndex + zinc;
00699     if ((zi < 0) || (zi >= cDim))
00700       if ( ! cPeriodic ) continue;
00701     for(yinc=-1;yinc<=0;yinc++)
00702     {
00703       yi = patchData[pid].bIndex + yinc;
00704       if ((yi < 0) || (yi >= bDim))
00705         if ( ! bPeriodic ) continue;
00706       for(xinc=-1;xinc<=0;xinc++)
00707       {
00708         if ((xinc==0) && (yinc==0) && (zinc==0))
00709           continue;
00710 
00711         xi = patchData[pid].aIndex + xinc;
00712         if ((xi < 0) || (xi >= aDim))
00713           if ( ! aPeriodic ) continue;
00714 
00715         if (neighbor_ids)
00716           neighbor_ids[n]=this->pid(xi,yi,zi);
00717 #if 0
00718         if ( transform_ids )
00719         {
00720           int xt = 0; if ( xi < 0 ) xt = -1; if ( xi >= aDim ) xt = 1;
00721           int yt = 0; if ( yi < 0 ) yt = -1; if ( yi >= bDim ) yt = 1;
00722           int zt = 0; if ( zi < 0 ) zt = -1; if ( zi >= cDim ) zt = 1;
00723           transform_ids[n] = Lattice::index(xt,yt,zt);
00724         }
00725 #endif
00726         n++;
00727       }
00728     }
00729   }
00730   DebugM(3,"Patch " << pid << " has " << n << " upstream neighbors.\n");
00731   return n;
00732 }

int PatchMap::getPatchesInOctet int  pid,
PatchID pids,
int *  transform_ids = 0
 

Definition at line 610 of file PatchMap.C.

References DebugM, Lattice::index(), and MODULO.

00611 {
00612   int xi, yi, zi;
00613   int xinc, yinc, zinc;
00614   int n=0;
00615   const int xs = patchData[pid].aIndex;
00616   const int ys = patchData[pid].bIndex;
00617   const int zs = patchData[pid].cIndex;
00618 
00619   for(zinc=0; zinc<2; zinc++) {
00620     zi = zs + zinc;
00621     for(yinc=0; yinc<2; yinc++) {
00622       yi = ys + yinc;
00623       for(xinc=0; xinc<2; xinc++) {
00624               xi = xs + xinc;
00625         int aIndex = MODULO(xi,aDim);
00626         int bIndex = MODULO(yi,bDim);
00627         int cIndex = MODULO(zi,cDim);
00628         pids[n] = ((cIndex*bDim)+bIndex)*aDim + aIndex;
00629         if ( transform_ids ) {
00630                 int xt = 0; if ( xi < 0 ) xt = -1; if ( xi >= aDim ) xt = 1;
00631                 int yt = 0; if ( yi < 0 ) yt = -1; if ( yi >= bDim ) yt = 1;
00632                 int zt = 0; if ( zi < 0 ) zt = -1; if ( zi >= cDim ) zt = 1;
00633                 transform_ids[n] = Lattice::index(xt,yt,zt);
00634               }
00635               n++;
00636       } // for x
00637     } // for y
00638   } // for z
00639   DebugM(3,"Patch " << pid << " has " << n << " second neighbors.\n");
00640   return n;
00641 }

std::vector<int>* PatchMap::getTmpPatchAtomsList  )  [inline]
 

Definition at line 225 of file PatchMap.h.

Referenced by ParallelIOMgr::calcAtomsInEachPatch(), and ParallelIOMgr::sendAtomsToHomePatchProcs().

00225                                         {
00226       return tmpPatchAtomsList;
00227   }

int PatchMap::gridsize_a void   )  const [inline]
 

Definition at line 63 of file PatchMap.h.

Referenced by WorkDistrib::createAtomLists(), ComputeLCPO::initialize(), Node::outputPatchComputeMaps(), RecBisection::partition(), and registerUserEventsForAllComputeObjs().

00063 { return aDim; }

int PatchMap::gridsize_b void   )  const [inline]
 

Definition at line 64 of file PatchMap.h.

Referenced by WorkDistrib::createAtomLists(), ComputeLCPO::initialize(), Node::outputPatchComputeMaps(), RecBisection::partition(), and registerUserEventsForAllComputeObjs().

00064 { return bDim; }

int PatchMap::gridsize_c void   )  const [inline]
 

Definition at line 65 of file PatchMap.h.

Referenced by WorkDistrib::createAtomLists(), ComputeLCPO::initialize(), Node::outputPatchComputeMaps(), RecBisection::partition(), and registerUserEventsForAllComputeObjs().

00065 { return cDim; }

HomePatch * PatchMap::homePatch PatchID  pid  )  [inline]
 

Definition at line 239 of file PatchMap.h.

Referenced by ProxyMgr::buildProxySpanningTree(), ProxyMgr::buildProxySpanningTree2(), MigrateAtomsCombinedMsg::distribute(), dumpbench(), PatchMgr::fillHomePatchAtomList(), LdbCoordinator::initialize(), ComputeHomePatch::initialize(), PatchMgr::moveAtom(), PatchMgr::recvAtoms(), NodeProxyMgr::recvImmediateResults(), ProxyMgr::recvImmediateResults(), ProxyMgr::recvNodeAwareSpanningTree(), ProxyMgr::recvNodeAwareSpanningTreeOnHomePatch(), ProxyMgr::recvRegisterProxy(), ProxyMgr::recvResult(), ProxyMgr::recvResults(), ProxyMgr::recvSpanningTree(), ProxyMgr::recvSpanningTreeOnHomePatch(), ProxyMgr::recvUnregisterProxy(), and PatchMgr::setHomePatchFixedAtomNum().

00240 {
00241   return myHomePatch[pid];
00242 }

void PatchMap::homePatchIDList PatchIDList  ) 
 

Definition at line 419 of file PatchMap.C.

References ResizeArray< Elem >::add(), PatchIDList, and ResizeArray< Elem >::resize().

Referenced by ProxyMgr::buildProxySpanningTree(), and ProxyMgr::buildProxySpanningTree2().

00419                                                 {
00420   pids.resize(0);
00421   int i;
00422   for ( i=0; i<nPatches; ++i ) {
00423     if ( patchData[i].node == CkMyPe() ) {
00424       pids.add(i);
00425     }
00426   }
00427 }

HomePatchList * PatchMap::homePatchList  ) 
 

Definition at line 414 of file PatchMap.C.

References HomePatchList.

Referenced by ProxyMgr::buildProxySpanningTree2(), ComputeHomePatches::initialize(), and Node::run().

00414                                        {
00415   return &(CkpvAccess(PatchMap_patchMgr)->homePatches);
00416 }

int PatchMap::index_a int  pid  )  const [inline]
 

Definition at line 85 of file PatchMap.h.

Referenced by WorkDistrib::createAtomLists(), ComputeLCPO::initialize(), makePatches(), registerUserEventsForAllComputeObjs(), and ComputeNonbondedCUDA::requirePatch().

00085 { return pid % aDim; }

int PatchMap::index_b int  pid  )  const [inline]
 

Definition at line 86 of file PatchMap.h.

Referenced by WorkDistrib::createAtomLists(), ComputeLCPO::initialize(), makePatches(), registerUserEventsForAllComputeObjs(), and ComputeNonbondedCUDA::requirePatch().

00086 { return (pid / aDim) % bDim; }

int PatchMap::index_c int  pid  )  const [inline]
 

Definition at line 87 of file PatchMap.h.

Referenced by WorkDistrib::createAtomLists(), ComputeLCPO::initialize(), makePatches(), registerUserEventsForAllComputeObjs(), and ComputeNonbondedCUDA::requirePatch().

00087 { return pid / (aDim*bDim); }

void PatchMap::initTmpPatchAtomsList  )  [inline]
 

Definition at line 215 of file PatchMap.h.

Referenced by ParallelIOMgr::calcAtomsInEachPatch().

00215                               {
00216       tmpPatchAtomsList = new std::vector<int>[nPatches];
00217   }

PatchMap * PatchMap::Instance  )  [static]
 

Definition at line 31 of file PatchMap.C.

Referenced by Node::Node(), and PatchMgr::PatchMgr().

00031                              {
00032   if (CkpvAccess(PatchMap_instance) == 0) {
00033      CkpvAccess(PatchMap_instance) = new PatchMap;
00034   }
00035   return(CkpvAccess(PatchMap_instance));
00036 }

void PatchMap::makePatches ScaledPosition  xmin,
ScaledPosition  xmax,
const Lattice lattice,
BigReal  patchSize,
double  maxNumPatches,
int  staticAtomAssignment,
int  asplit,
int  bsplit,
int  csplit
 

Definition at line 170 of file PatchMap.C.

References BigReal, iINFO(), index_a(), index_b(), index_c(), iout, j, ScaledPosition, sizeGrid(), Vector::x, Vector::y, and Vector::z.

Referenced by WorkDistrib::patchMapInit().

00174 {
00175   sizeGrid(xmin,xmax,lattice,patchSize,maxNumPatches,staticAtomAssignment,asplit,bsplit,csplit);
00176 
00177   iout << iINFO << "PATCH GRID IS ";
00178   iout << aDim;
00179   if ( aPeriodic ) iout << " (PERIODIC)";
00180   iout << " BY ";
00181   iout << bDim;
00182   if ( bPeriodic ) iout << " (PERIODIC)";
00183   iout << " BY ";
00184   iout << cDim;
00185   if ( cPeriodic ) iout << " (PERIODIC)";
00186   iout << "\n";
00187   iout << iINFO << "PATCH GRID IS ";
00188   iout << aAway << "-AWAY BY ";
00189   iout << bAway << "-AWAY BY ";
00190   iout << cAway << "-AWAY\n";
00191   iout << endi;
00192 
00193   aMaxIndex = ( ! aPeriodic || aDim == 2 ) ? 10000 : aDim;
00194   bMaxIndex = ( ! bPeriodic || bDim == 2 ) ? 10000 : bDim;
00195   cMaxIndex = ( ! cPeriodic || cDim == 2 ) ? 10000 : cDim;
00196 
00197   aLength = aPeriodic ? 1.0 :
00198       ( aDim > aAway + 1 ? aDim * (patchSize / aAway) : xmax.x - xmin.x );
00199   bLength = bPeriodic ? 1.0 :
00200       ( bDim > bAway + 1 ? bDim * (patchSize / bAway) : xmax.y - xmin.y );
00201   cLength = cPeriodic ? 1.0 :
00202       ( cDim > cAway + 1 ? cDim * (patchSize / cAway) : xmax.z - xmin.z );
00203 
00204   aOrigin = aPeriodic ? -0.5 : 0.5 * (xmin.x + xmax.x - aLength);
00205   bOrigin = bPeriodic ? -0.5 : 0.5 * (xmin.y + xmax.y - bLength);
00206   cOrigin = cPeriodic ? -0.5 : 0.5 * (xmin.z + xmax.z - cLength);
00207 
00208   nPatches=aDim*bDim*cDim;
00209   patchData = new PatchData[nPatches];
00210 
00211   patchBounds_a = new BigReal[2*aDim+1];
00212   patchBounds_b = new BigReal[2*bDim+1];
00213   patchBounds_c = new BigReal[2*cDim+1];
00214   for ( int i=0; i<(2*aDim+1); ++i ) {
00215     patchBounds_a[i] = ((0.5*(double)i)/(double)aDim) * aLength + aOrigin;
00216   }
00217   for ( int i=0; i<(2*bDim+1); ++i ) {
00218     patchBounds_b[i] = ((0.5*(double)i)/(double)bDim) * bLength + bOrigin;
00219   }
00220   for ( int i=0; i<(2*cDim+1); ++i ) {
00221     patchBounds_c[i] = ((0.5*(double)i)/(double)cDim) * cLength + cOrigin;
00222   }
00223 
00224   for(int i=0; i<nPatches; ++i)
00225   {
00226     PatchData &p = patchData[i];
00227     p.basenode = -1;
00228     p.numCids = 0;
00229     p.aIndex = index_a(i);
00230     p.bIndex = index_b(i);
00231     p.cIndex = index_c(i);
00232 #ifdef MEM_OPT_VERSION
00233     p.numAtoms = 0;
00234     p.numFixedAtoms = 0;
00235 #endif
00236     p.numCids = 0;
00237     int max_computes = 30;
00238     p.cids = new int[max_computes];
00239     for ( int j = 0; j < max_computes; ++j ) p.cids[j] = -1;
00240     p.numCidsAllocated = max_computes;
00241   }
00242 
00243   if ( ! myPatch ) {
00244     myPatch = new Patch*[nPatches];
00245   }
00246   memset(myPatch,0,nPatches*sizeof(Patch*));
00247   if ( ! myHomePatch ) {
00248     myHomePatch = new HomePatch*[nPatches];
00249   }
00250   memset(myHomePatch,0,nPatches*sizeof(HomePatch*));
00251 }

BigReal PatchMap::max_a int  pid  )  const [inline]
 

Definition at line 91 of file PatchMap.h.

References BigReal.

Referenced by WorkDistrib::createAtomLists(), ComputeNonbondedPair::doForce(), ComputePmeMgr::initialize(), ComputeLCPO::initialize(), OptPmeMgr::initialize_pencils(), and ComputePmeMgr::initialize_pencils().

00091 { return patchBounds_a[patchData[pid].aIndex*2+2]; }

BigReal PatchMap::max_b int  pid  )  const [inline]
 

Definition at line 93 of file PatchMap.h.

References BigReal.

Referenced by WorkDistrib::createAtomLists(), ComputeNonbondedPair::doForce(), ComputeLCPO::initialize(), OptPmeMgr::initialize_pencils(), and ComputePmeMgr::initialize_pencils().

00093 { return patchBounds_b[patchData[pid].bIndex*2+2]; }

BigReal PatchMap::max_c int  pid  )  const [inline]
 

Definition at line 95 of file PatchMap.h.

References BigReal.

Referenced by WorkDistrib::createAtomLists(), ComputeNonbondedPair::doForce(), and ComputeLCPO::initialize().

00095 { return patchBounds_c[patchData[pid].cIndex*2+2]; }

BigReal PatchMap::min_a int  pid  )  const [inline]
 

Definition at line 90 of file PatchMap.h.

References BigReal.

Referenced by WorkDistrib::createAtomLists(), ComputeNonbondedPair::doForce(), ComputePmeMgr::initialize(), ComputeLCPO::initialize(), OptPmeMgr::initialize_pencils(), and ComputePmeMgr::initialize_pencils().

00090 { return patchBounds_a[patchData[pid].aIndex*2]; }

BigReal PatchMap::min_b int  pid  )  const [inline]
 

Definition at line 92 of file PatchMap.h.

References BigReal.

Referenced by WorkDistrib::createAtomLists(), ComputeNonbondedPair::doForce(), ComputeLCPO::initialize(), OptPmeMgr::initialize_pencils(), and ComputePmeMgr::initialize_pencils().

00092 { return patchBounds_b[patchData[pid].bIndex*2]; }

BigReal PatchMap::min_c int  pid  )  const [inline]
 

Definition at line 94 of file PatchMap.h.

References BigReal.

Referenced by WorkDistrib::createAtomLists(), ComputeNonbondedPair::doForce(), and ComputeLCPO::initialize().

00094 { return patchBounds_c[patchData[pid].cIndex*2]; }

void PatchMap::newCid int  pid,
int  cid
 

Definition at line 488 of file PatchMap.C.

References ComputeID.

00489 {
00490   if (patchData[pid].numCids >= patchData[pid].numCidsAllocated)
00491   { // allocate more
00492 //    NAMD_die("PatchMap::newCid - not enough compute ID's allocated.");
00493     ComputeID *old = patchData[pid].cids;
00494     patchData[pid].numCidsAllocated += 10;
00495     patchData[pid].cids = new int[patchData[pid].numCidsAllocated];
00496     int i;
00497     for (i=0; i<patchData[pid].numCids; i++) 
00498         patchData[pid].cids[i] = old[i];
00499     for (i=patchData[pid].numCids; i<patchData[pid].numCidsAllocated; i++) 
00500         patchData[pid].cids[i] = -1;
00501     delete [] old;
00502   }
00503   patchData[pid].cids[patchData[pid].numCids]=cid;
00504   patchData[pid].numCids++;
00505 }

int PatchMap::node int  pid  )  const [inline]
 

Definition at line 113 of file PatchMap.h.

Referenced by assignBaseNode(), WorkDistrib::assignNodeToPatch(), ComputeNonbondedCUDA::assignPatches(), ProxyMgr::buildSpanningTree0(), ParallelIOMgr::createHomePatches(), ProxyMgr::createProxies(), Rebalancer::createSpanningTree(), WorkDistrib::distributeHomePatches(), LdbCoordinator::initialize(), ComputeSelfTuples< TholeElem, Thole, TholeValue >::initialize(), ComputePmeMgr::initialize(), ComputePatchPair::initialize(), ComputePatch::initialize(), OptPmeMgr::initialize_pencils(), ComputePmeMgr::initialize_pencils(), Node::outputPatchComputeMaps(), pack(), Patch::positionsReady(), printPatchMap(), ProxyMgr::registerProxy(), LdbCoordinator::requiredProxies(), ComputeNonbondedCUDA::requirePatch(), PatchMgr::sendAtoms(), ParallelIOMgr::sendAtomsToHomePatchProcs(), ProxyMgr::sendNodeAwareSpanningTreeToHomePatch(), ProxyMgr::sendResult(), ProxyMgr::sendResults(), ProxyMgr::sendSpanningTreeToHomePatch(), unpack(), and ProxyMgr::unregisterProxy().

00113 { return patchData[pid].node; }

int PatchMap::numaway_a void   )  const [inline]
 

Definition at line 67 of file PatchMap.h.

00067 { return aAway; }

int PatchMap::numaway_b void   )  const [inline]
 

Definition at line 68 of file PatchMap.h.

00068 { return bAway; }

int PatchMap::numaway_c void   )  const [inline]
 

Definition at line 69 of file PatchMap.h.

00069 { return cAway; }

int PatchMap::numCids int  pid  )  const [inline]
 

Definition at line 119 of file PatchMap.h.

Referenced by pack(), printPatchMap(), and unpack().

00119 { return patchData[pid].numCids; }

int PatchMap::numHomePatches void   ) 
 

Definition at line 408 of file PatchMap.C.

Referenced by LdbCoordinator::initialize(), Sync::openSync(), CollectionMgr::CollectVectorInstance::reset(), ComputeMgr::sendComputeEwaldData(), and PatchMgr::sendMigrationMsgs().

00409 {
00410   return CkpvAccess(PatchMap_patchMgr)->homePatches.size();
00411 }

int PatchMap::numNodesWithPatches void   )  [inline]
 

Definition at line 60 of file PatchMap.h.

Referenced by HomePatch::buildSpanningTree(), ComputePmeMgr::initialize(), and HomePatch::positionsReady().

00060 { return nNodesWithPatches; }

int PatchMap::numPatches void   )  const [inline]
 

Definition at line 58 of file PatchMap.h.

Referenced by WorkDistrib::assignNodeToPatch(), LdbCoordinator::awakenSequencers(), ProxyMgr::buildSpanningTree0(), ParallelIOMgr::calcAtomsInEachPatch(), ComputeHomeTuples< TholeElem, Thole, TholeValue >::ComputeHomeTuples(), WorkDistrib::createAtomLists(), WorkDistrib::createHomePatches(), ParallelIOMgr::createHomePatches(), ProxyMgr::createProxies(), WorkDistrib::distributeHomePatches(), dumpbench(), OptPmeMgr::initialize(), LdbCoordinator::initialize(), ComputePmeMgr::initialize(), ComputeHomeTuples< TholeElem, Thole, TholeValue >::initialize(), OptPmeMgr::initialize_pencils(), ComputePmeMgr::initialize_pencils(), initializePmeMap(), Sync::openSync(), Node::outputPatchComputeMaps(), LdbCoordinator::printLocalLdbReport(), RecBisection::RecBisection(), ParallelIOMgr::recvAtomsCntPerPatch(), ProxyMgr::recvPatchProxyInfo(), ProxyMgr::recvProxies(), ComputeGlobal::recvResults(), WorkDistrib::reinitAtoms(), WorkDistrib::savePatchMap(), ParallelIOMgr::sendAtomsToHomePatchProcs(), WorkDistrib::sendPatchMap(), ProxyMgr::sendSpanningTrees(), Sequencer::Sequencer(), and NamdCentLB::Strategy().

00058 { return nPatches; }

int PatchMap::numPatchesOnNode int  node  )  [inline]
 

Definition at line 59 of file PatchMap.h.

Referenced by HomePatch::buildSpanningTree(), ParallelIOMgr::createHomePatches(), NodeProxyMgr::createSTForHomePatches(), ComputePmeMgr::initialize(), OptPmeMgr::initialize_pencils(), initializePmeMap(), and HomePatch::positionsReady().

00059 { return nPatchesOnNode[node]; }

PatchMap* PatchMap::Object  )  [inline, static]
 

Definition at line 27 of file PatchMap.h.

Referenced by WorkDistrib::assignNodeToPatch(), ProxyMgr::buildProxySpanningTree(), ProxyMgr::buildProxySpanningTree2(), HomePatch::buildSpanningTree(), ProxyMgr::buildSpanningTree0(), ParallelIOMgr::calcAtomsInEachPatch(), ComputeEwald::ComputeEwald(), ComputeHomePatches::ComputeHomePatches(), ComputeHomeTuples< TholeElem, Thole, TholeValue >::ComputeHomeTuples(), ComputeNonbondedCUDA::ComputeNonbondedCUDA(), WorkDistrib::createAtomLists(), WorkDistrib::createHomePatches(), ParallelIOMgr::createHomePatches(), ProxyMgr::createProxies(), ProxyMgr::createProxy(), Rebalancer::createSpanningTree(), MigrateAtomsCombinedMsg::distribute(), WorkDistrib::distributeHomePatches(), ComputeNonbondedPair::doForce(), ComputeFullDirect::doWork(), dumpbench(), Sync::holdComputes(), OptPmeMgr::initialize(), ComputeSelfTuples< TholeElem, Thole, TholeValue >::initialize(), ComputePmeMgr::initialize(), ComputePatchPair::initialize(), ComputePatch::initialize(), ComputeLCPO::initialize(), ComputeHomePatch::initialize(), OptPmeMgr::initialize_pencils(), ComputePmeMgr::initialize_pencils(), initializePmeMap(), WorkDistrib::mapComputes(), Sync::openSync(), Node::outputPatchComputeMaps(), WorkDistrib::patchMapInit(), Patch::positionsReady(), HomePatch::positionsReady(), ParallelIOMgr::recvAtomsCntPerPatch(), ComputeMgr::recvComputeDPMEData(), ComputeMgr::recvComputeDPMEResults(), ComputeMgr::recvComputeEwaldResults(), ComputeMgr::recvComputeGlobalResults(), ComputeMsmSerialMgr::recvCoord(), ComputeGBISserMgr::recvCoord(), ComputeExtMgr::recvCoord(), ProxyMgr::recvData(), ProxyMgr::recvImmediateProxyAll(), ProxyMgr::recvImmediateProxyData(), ProxyMgr::recvImmediateResults(), ProxyMgr::recvNodeAwareSpanningTree(), ProxyMgr::recvNodeAwareSpanningTreeOnHomePatch(), ProxyMgr::recvNodeAwareSTParent(), ProxyMgr::recvPatchProxyInfo(), ProxyMgr::recvProxies(), ProxyMgr::recvProxyAll(), ProxyMgr::recvProxyData(), ProxyMgr::recvRegisterProxy(), ProxyMgr::recvResult(), ProxyMgr::recvResults(), ComputeGlobal::recvResults(), ProxyMgr::recvSpanningTree(), ProxyMgr::recvSpanningTreeOnHomePatch(), ProxyMgr::recvUnregisterProxy(), ProxyMgr::registerProxy(), registerUserEventsForAllComputeObjs(), WorkDistrib::reinitAtoms(), ProxyMgr::removeProxy(), CollectionMgr::CollectVectorInstance::reset(), CollectionMaster::CollectVectorInstance::reset(), Node::run(), WorkDistrib::savePatchMap(), ParallelIOMgr::sendAtomsToHomePatchProcs(), ComputeMgr::sendComputeDPMEData(), ComputeMgr::sendComputeEwaldData(), ProxyMgr::sendNodeAwareSpanningTreeToHomePatch(), WorkDistrib::sendPatchMap(), ProxyMgr::sendResult(), ProxyMgr::sendResults(), ProxyMgr::sendSpanningTrees(), ProxyMgr::sendSpanningTreeToHomePatch(), Sequencer::Sequencer(), NamdCentLB::Strategy(), ProxyMgr::unregisterProxy(), ComputeMgr::updateLocalComputes5(), ComputeHomePatch::~ComputeHomePatch(), ComputeLCPO::~ComputeLCPO(), ComputePatch::~ComputePatch(), and ComputePatchPair::~ComputePatchPair().

00027 { return CkpvAccess(PatchMap_instance); }

PatchMap* PatchMap::ObjectOnPe int  pe  )  [inline, static]
 

Definition at line 28 of file PatchMap.h.

Referenced by ComputeNonbondedCUDA::assignPatches().

00028                                              {
00029     return CkpvAccessOther(PatchMap_instance, CmiRankOf(pe));
00030   }

int PatchMap::oneAwayNeighbors int  pid,
PatchID neighbor_ids = 0
 

Definition at line 508 of file PatchMap.C.

References DebugM, Lattice::index(), and pid().

00509 {
00510   int xi, yi, zi;
00511   int xinc, yinc, zinc;
00512   int n=0;
00513 
00514   for(zinc=-1;zinc<=1;zinc++)
00515   {
00516     zi = patchData[pid].cIndex + zinc;
00517     if ((zi < 0) || (zi >= cDim))
00518       if ( ! cPeriodic ) continue;
00519     for(yinc=-1;yinc<=1;yinc++)
00520     {
00521       yi = patchData[pid].bIndex + yinc;
00522       if ((yi < 0) || (yi >= bDim))
00523         if ( ! bPeriodic ) continue;
00524       for(xinc=-1;xinc<=1;xinc++)
00525       {
00526         if ((xinc==0) && (yinc==0) && (zinc==0))
00527           continue;
00528 
00529         xi = patchData[pid].aIndex + xinc;
00530         if ((xi < 0) || (xi >= aDim))
00531           if ( ! aPeriodic ) continue;
00532 
00533         if (neighbor_ids)
00534           neighbor_ids[n]=this->pid(xi,yi,zi);
00535 #if 0
00536         if ( transform_ids )
00537         {
00538           int xt = 0; if ( xi < 0 ) xt = -1; if ( xi >= aDim ) xt = 1;
00539           int yt = 0; if ( yi < 0 ) yt = -1; if ( yi >= bDim ) yt = 1;
00540           int zt = 0; if ( zi < 0 ) zt = -1; if ( zi >= cDim ) zt = 1;
00541           transform_ids[n] = Lattice::index(xt,yt,zt);
00542         }
00543 #endif
00544         n++;
00545       }
00546     }
00547   }
00548   DebugM(3,"Patch " << pid << " has " << n << " first neighbors.\n");
00549   return n;
00550 }

int PatchMap::oneOrTwoAwayNeighbors int  pid,
PatchID neighbor_ids,
PatchID downstream_ids = 0,
int *  transform_ids = 0
 

Definition at line 555 of file PatchMap.C.

References DebugM, Lattice::index(), and pid().

00556 {
00557   int xi, yi, zi;
00558   int xinc, yinc, zinc;
00559   int n=0;
00560   const int xs = patchData[pid].aIndex;
00561   const int ys = patchData[pid].bIndex;
00562   const int zs = patchData[pid].cIndex;
00563 
00564   for(zinc=0;zinc<=cAway;zinc++)
00565   {
00566     zi = zs + zinc;
00567     if ((zi < 0) || (zi >= cDim))
00568       if ( ! cPeriodic ) continue;
00569     for(yinc=(zinc>0 ? -bAway : 0);yinc<=bAway;yinc++)
00570     {
00571       yi = ys + yinc;
00572       if ((yi < 0) || (yi >= bDim))
00573         if ( ! bPeriodic ) continue;
00574       for(xinc=((zinc>0 || yinc>0) ? -aAway : 0);xinc<=aAway;xinc++)
00575       {
00576         if ((xinc==0) && (yinc==0) && (zinc==0))
00577           continue;
00578 
00579         xi = xs + xinc;
00580         if ((xi < 0) || (xi >= aDim))
00581           if ( ! aPeriodic ) continue;
00582 
00583         neighbor_ids[n] = this->pid(xi,yi,zi);
00584         if ( transform_ids )
00585         {
00586           int xt = 0; if ( xi < 0 ) xt = -1; if ( xi >= aDim ) xt = 1;
00587           int yt = 0; if ( yi < 0 ) yt = -1; if ( yi >= bDim ) yt = 1;
00588           int zt = 0; if ( zi < 0 ) zt = -1; if ( zi >= cDim ) zt = 1;
00589           transform_ids[n] = Lattice::index(xt,yt,zt);
00590         }
00591         if ( downstream_ids )
00592         {
00593           int xd = ( xi < xs ? xi : xs );
00594           int yd = ( yi < ys ? yi : ys );
00595           int zd = ( zi < zs ? zi : zs );
00596           downstream_ids[n] = this->pid(xd,yd,zd);
00597         }
00598         n++;
00599       }
00600     }
00601   }
00602   DebugM(3,"Patch " << pid << " has " << n << " second neighbors.\n");
00603   return n;
00604 }

ScaledPosition PatchMap::origin void   )  const [inline]
 

Definition at line 77 of file PatchMap.h.

References ScaledPosition.

00077                                            {
00078     return ScaledPosition(aOrigin,bOrigin,cOrigin);
00079   }

void PatchMap::pack char *  buf  )  [protected]
 

Definition at line 307 of file PatchMap.C.

References BigReal, ComputeID, DebugM, node(), numCids(), PACK, and PACKN.

Referenced by WorkDistrib::sendPatchMap().

00308 {
00309   DebugM(4,"Packing PatchMap on node " << CkMyPe() << std::endl);
00310   int i,j;
00311 
00312   // fill in the data
00313   char *b = buffer;
00314   PACK(int,nPatches);
00315   DebugM(3,"nPatches = " << nPatches << std::endl);
00316   PACK(int,aDim); PACK(int,bDim); PACK(int,cDim);
00317   PACK(int,aAway); PACK(int,bAway); PACK(int,cAway);
00318   PACK(int,aPeriodic); PACK(int,bPeriodic); PACK(int,cPeriodic);
00319   PACK(int,aMaxIndex); PACK(int,bMaxIndex); PACK(int,cMaxIndex);
00320   PACK(BigReal,aOrigin); PACK(BigReal,bOrigin); PACK(BigReal,cOrigin);
00321   PACK(BigReal,aLength); PACK(BigReal,bLength); PACK(BigReal,cLength);
00322   PACK(int,nNodesWithPatches);
00323   PACKN(BigReal,patchBounds_a,2*aDim+1);
00324   PACKN(BigReal,patchBounds_b,2*bDim+1);
00325   PACKN(BigReal,patchBounds_c,2*cDim+1);
00326   PACKN(int,nPatchesOnNode,CkNumPes());
00327   PACKN(PatchData,patchData,nPatches);
00328   for(i=0;i<nPatches;++i) {
00329     DebugM(3,"Packing Patch " << i << " is on node " << patchData[i].node << 
00330         " with " << patchData[i].numCids << " cids.\n");
00331     PACKN(ComputeID,patchData[i].cids,patchData[i].numCids);
00332   }
00333   //DebugM(3,buffer + size - b << " == 0 ?" << std::endl);
00334 }

int PatchMap::packSize void   )  [protected]
 

Definition at line 293 of file PatchMap.C.

Referenced by WorkDistrib::sendPatchMap().

00294 {
00295   int i, size = 0;
00296   size += 14 * sizeof(int) + 6 * sizeof(BigReal);
00297   size += (2*(aDim+bDim+cDim)+3) * sizeof(BigReal);
00298   size += CkNumPes() * sizeof(int);
00299   for(i=0;i<nPatches;++i)
00300   {
00301     size += sizeof(PatchData);
00302     size += patchData[i].numCidsAllocated * sizeof(ComputeID);
00303   }
00304   return size;
00305 }

Patch * PatchMap::patch PatchID  pid  )  [inline]
 

Definition at line 234 of file PatchMap.h.

Referenced by WorkDistrib::assignNodeToPatch(), ComputeNonbondedCUDA::assignPatches(), ProxyMgr::createProxy(), ComputeSelfTuples< TholeElem, Thole, TholeValue >::initialize(), ComputePatchPair::initialize(), ComputePatch::initialize(), ComputeLCPO::initialize(), ComputeHomeTuples< TholeElem, Thole, TholeValue >::initialize(), ComputeHomePatch::initialize(), Node::outputPatchComputeMaps(), ProxyMgr::recvData(), NodeProxyMgr::recvImmediateProxyAll(), ProxyMgr::recvImmediateProxyAll(), NodeProxyMgr::recvImmediateProxyData(), ProxyMgr::recvImmediateProxyData(), NodeProxyMgr::recvImmediateResults(), ProxyMgr::recvImmediateResults(), ProxyMgr::recvNodeAwareSpanningTree(), ProxyMgr::recvNodeAwareSTParent(), ProxyMgr::recvProxyAll(), ProxyMgr::recvProxyData(), ProxyMgr::recvSpanningTree(), ComputeNonbondedCUDA::registerPatches(), ProxyMgr::sendResults(), ComputeHomePatch::~ComputeHomePatch(), ComputeLCPO::~ComputeLCPO(), ComputePatch::~ComputePatch(), and ComputePatchPair::~ComputePatchPair().

00235 {
00236   return myPatch[pid];
00237 }

int PatchMap::periodic_a void   )  const [inline]
 

Definition at line 72 of file PatchMap.h.

00072 { return aPeriodic; }

int PatchMap::periodic_b void   )  const [inline]
 

Definition at line 73 of file PatchMap.h.

00073 { return bPeriodic; }

int PatchMap::periodic_c void   )  const [inline]
 

Definition at line 74 of file PatchMap.h.

00074 { return cPeriodic; }

int PatchMap::pid int  aIndex,
int  bIndex,
int  cIndex
[inline]
 

Definition at line 27 of file PatchMap.inl.

References MODULO.

Referenced by assignToPatch(), downstreamNeighbors(), oneAwayNeighbors(), oneOrTwoAwayNeighbors(), and upstreamNeighbors().

00028 {
00029   if ( aPeriodic ) aIndex = MODULO(aIndex,aDim);
00030   else
00031   {
00032     if ( aIndex < 0 ) aIndex = 0;
00033     if ( aIndex >= aDim ) aIndex = aDim - 1;
00034   }
00035   if ( bPeriodic ) bIndex = MODULO(bIndex,bDim);
00036   else
00037   {
00038     if ( bIndex < 0 ) bIndex = 0;
00039     if ( bIndex >= bDim ) bIndex = bDim - 1;
00040   }
00041   if ( cPeriodic ) cIndex = MODULO(cIndex,cDim);
00042   else
00043   {
00044     if ( cIndex < 0 ) cIndex = 0;
00045     if ( cIndex >= cDim ) cIndex = cDim - 1;
00046   }
00047   return ((cIndex*bDim)+bIndex)*aDim + aIndex;
00048 }

void PatchMap::printPatchMap void   ) 
 

Definition at line 735 of file PatchMap.C.

References j, node(), and numCids().

00736 {
00737   CkPrintf("---------------------------------------");
00738   CkPrintf("---------------------------------------\n");
00739 
00740   CkPrintf("nPatches = %d\n",nPatches);
00741   for(int i=0;i<nPatches;i++)
00742   {
00743     CkPrintf("Patch %d:\n",i);
00744     CkPrintf("  node = %d\n",patchData[i].node);
00745     CkPrintf("  xi,yi,zi = %d, %d, %d\n",
00746             patchData[i].aIndex,patchData[i].bIndex,patchData[i].cIndex);
00747     CkPrintf("  numCids = %d\n",patchData[i].numCids);
00748     CkPrintf("  numCidsAllocated = %d\n",patchData[i].numCidsAllocated);
00749     for(int j=0; j < patchData[i].numCids; j++)
00750     {
00751       CkPrintf(" %10d ",patchData[i].cids[j]);
00752       if (!((j+1) % 6))
00753         CkPrintf("\n");
00754     }
00755     CkPrintf("\n---------------------------------------");
00756     CkPrintf("---------------------------------------\n");
00757   }
00758 
00759 }

void PatchMap::registerPatch PatchID  pid,
Patch pptr
 

Definition at line 781 of file PatchMap.C.

References iERRORF, iout, and iPE().

00782 {
00783   if (myPatch[pid] != 0) {
00784     iout << iPE << iERRORF 
00785       << "patchID("<<pid<<") is being re-registered!\n" << endi;
00786   }
00787   myPatch[pid] = pptr;
00788 }

void PatchMap::registerPatch PatchID  pid,
HomePatch pptr
 

Definition at line 762 of file PatchMap.C.

References iERRORF, iout, and iPE().

Referenced by PatchMgr::createHomePatch(), ProxyMgr::createProxies(), ProxyMgr::createProxy(), and PatchMgr::preCreateHomePatch().

00762                                                          {
00763   registerPatch(pid,(Patch*)pptr);
00764   if (myHomePatch[pid] != 0) {
00765     iout << iPE << iERRORF 
00766       << "homePatchID("<<pid<<") is being re-registered!\n" << endi;
00767   }
00768   myHomePatch[pid] = pptr;
00769 }

void PatchMap::registerPatchMgr PatchMgr pmgr  )  [inline, static]
 

Definition at line 48 of file PatchMap.h.

Referenced by PatchMgr::PatchMgr().

00048                                                {
00049     CkpvAccess(PatchMap_patchMgr) = pmgr;
00050   }

int PatchMap::sizeGrid ScaledPosition  xmin,
ScaledPosition  xmax,
const Lattice lattice,
BigReal  patchSize,
double  maxNumPatches,
int  staticAtomAssignment,
int  asplit,
int  bsplit,
int  csplit
 

Definition at line 61 of file PatchMap.C.

References Lattice::a(), Lattice::a_p(), Lattice::a_r(), Lattice::b(), Lattice::b_p(), Lattice::b_r(), BigReal, Lattice::c(), Lattice::c_p(), Lattice::c_r(), NAMD_die(), ScaledPosition, Vector::unit(), Vector::x, Vector::y, and Vector::z.

Referenced by makePatches(), and WorkDistrib::patchMapInit().

00065 {
00066   aPeriodic = lattice.a_p();
00067   bPeriodic = lattice.b_p();
00068   cPeriodic = lattice.c_p();
00069 
00070   aAway = asplit;
00071   bAway = bsplit;
00072   cAway = csplit;
00073 
00074   int minNumPatches = 1;
00075   if ( aPeriodic ) minNumPatches *= aAway;
00076   if ( bPeriodic ) minNumPatches *= bAway;
00077   if ( cPeriodic ) minNumPatches *= cAway;
00078   if ( maxNumPatches < minNumPatches ) maxNumPatches = minNumPatches;
00079 
00080   if ( aPeriodic ) {
00081     BigReal sysDim = lattice.a_r().unit() * lattice.a();
00082     aDim = (int)(sysDim * aAway / patchSize);
00083   } else {
00084     BigReal sysDim = xmax.x - xmin.x;
00085     aDim = (int)(sysDim * aAway / patchSize);
00086     if ((aDim * patchSize) < (sysDim * aAway)) aDim++;
00087     if ( aDim < aAway + 1 ) aDim = aAway + 1;
00088   }
00089 
00090   if ( bPeriodic ) {
00091     BigReal sysDim = lattice.b_r().unit() * lattice.b();
00092     bDim = (int)(sysDim * bAway / patchSize);
00093   } else {
00094     BigReal sysDim = xmax.y - xmin.y;
00095     bDim = (int)(sysDim * bAway / patchSize);
00096     if ((bDim * patchSize) < (sysDim * bAway)) bDim++;
00097     if ( bDim < bAway + 1 ) bDim = bAway + 1;
00098   }
00099 
00100   if ( cPeriodic ) {
00101     BigReal sysDim = lattice.c_r().unit() * lattice.c();
00102     cDim = (int)(sysDim * cAway / patchSize);
00103   } else {
00104     BigReal sysDim = xmax.z - xmin.z;
00105     cDim = (int)(sysDim * cAway / patchSize);
00106     if ((cDim * patchSize) < (sysDim * cAway)) cDim++;
00107     if ( cDim < cAway + 1 ) cDim = cAway + 1;
00108   }
00109 
00110   if ( aDim < 0 || bDim < 0 || cDim < 0 ) {
00111     NAMD_die("Bug in PatchMap::sizeGrid - negative grid dimension.");
00112   }
00113 
00114   if ( staticAtomAssignment ) {
00115     if ( aPeriodic || bPeriodic || cPeriodic )
00116       NAMD_die("Static atom assignment is incompatible with periodic boundary conditions.");
00117     aDim = aAway + 1;
00118     bDim = bAway + 1;
00119     cDim = cAway + 1;
00120   }
00121 
00122   const int amin = (aPeriodic ? aAway : 1);
00123   const int bmin = (bPeriodic ? bAway : 1);
00124   const int cmin = (cPeriodic ? cAway : 1);
00125 
00126   // CkPrintf("searching %d-away %d-away %d-away max %d\n",aAway,bAway,cAway,(int)maxNumPatches);
00127 
00128   if ( aDim < amin ) aDim = amin;
00129   if ( bDim < bmin ) bDim = bmin;
00130   if ( cDim < cmin ) cDim = cmin;
00131 
00132   if ( maxNumPatches > aDim*bDim*cDim ) {
00133     maxNumPatches = aDim*bDim*cDim;
00134   }
00135 
00136   int abest = amin;
00137   int bbest = bmin;
00138   int cbest = cmin;
00139   int cdim = maxNumPatches;
00140   cdim /= aDim;  cdim /= bDim;
00141   if ( cdim < cmin ) cdim = cmin;
00142   for ( ; cdim <= cDim; ++cdim ) {
00143     int bdim = maxNumPatches;
00144     bdim /= aDim;  bdim /= cdim;
00145     if ( bdim < bmin ) bdim = bmin;
00146     for ( ; bdim <= bDim; ++bdim ) {
00147       int adim = maxNumPatches;
00148       adim /= bdim;  adim /= cdim;
00149       if ( adim < amin ) adim = amin;
00150       for ( ; adim <= aDim; ++adim ) {
00151         if ( adim*bdim*cdim > maxNumPatches ) break;
00152         // CkPrintf("testing %d * %d * %d == %d\n",adim,bdim,cdim,adim*bdim*cdim);
00153         if ( adim*bdim*cdim > abest*bbest*cbest ) {
00154           abest = adim;  bbest = bdim;  cbest = cdim;
00155         }
00156         if ( abest*bbest*cbest == maxNumPatches ) break;
00157       }
00158       if ( abest*bbest*cbest == maxNumPatches ) break;
00159     }
00160     if ( abest*bbest*cbest == maxNumPatches ) break;
00161   }
00162   aDim = abest;
00163   bDim = bbest;
00164   cDim = cbest;
00165 
00166   // CkPrintf("found %d * %d * %d == %d\n",aDim,bDim,cDim,aDim*bDim*cDim);
00167   return aDim*bDim*cDim;
00168 }

void PatchMap::unpack char *  buf  )  [protected]
 

Definition at line 341 of file PatchMap.C.

References BigReal, ComputeID, DebugM, ObjectArena< Type >::getNewArray(), node(), numCids(), ObjectArena< Type >::setBlockSize(), UNPACK, and UNPACKN.

Referenced by WorkDistrib::savePatchMap().

00342 {
00343   DebugM(4,"Unpacking PatchMap on node " << CkMyPe() << std::endl);
00344 
00345   int i,j;
00346   char *b = (char*)ptr;
00347   {
00348     // defeat some over-zealous compilers
00349     int nPatches_tmp;
00350     UNPACK(int,nPatches_tmp);
00351     nPatches = nPatches_tmp;
00352   }
00353   DebugM(3,"nPatches = " << nPatches << std::endl);
00354 
00355   if ( ! myPatch ) {
00356     myPatch = new Patch*[nPatches];
00357   }
00358   memset(myPatch,0,nPatches*sizeof(Patch*));
00359   if ( ! myHomePatch ) {
00360     myHomePatch = new HomePatch*[nPatches];
00361   }
00362   memset(myHomePatch,0,nPatches*sizeof(HomePatch*));
00363 
00364   UNPACK(int,aDim); UNPACK(int,bDim); UNPACK(int,cDim);
00365   UNPACK(int,aAway); UNPACK(int,bAway); UNPACK(int,cAway);
00366   UNPACK(int,aPeriodic); UNPACK(int,bPeriodic); UNPACK(int,cPeriodic);
00367   UNPACK(int,aMaxIndex); UNPACK(int,bMaxIndex); UNPACK(int,cMaxIndex);
00368   UNPACK(BigReal,aOrigin); UNPACK(BigReal,bOrigin); UNPACK(BigReal,cOrigin);
00369   UNPACK(BigReal,aLength); UNPACK(BigReal,bLength); UNPACK(BigReal,cLength);
00370   UNPACK(int,nNodesWithPatches);
00371 
00372 
00373 //  CkPrintf("[%d] has bounds a %d b %d c %d npatches %d mem %d\n",CkMyPe(),aDim, bDim, cDim, nPatches, memusage_MB() );
00374 
00375   if ( ! patchBounds_a ) patchBounds_a = new BigReal[2*aDim+1];
00376   if ( ! patchBounds_b ) patchBounds_b = new BigReal[2*bDim+1];
00377   if ( ! patchBounds_c ) patchBounds_c = new BigReal[2*cDim+1];
00378   UNPACKN(BigReal,patchBounds_a,2*aDim+1);
00379   UNPACKN(BigReal,patchBounds_b,2*bDim+1);
00380   UNPACKN(BigReal,patchBounds_c,2*cDim+1);
00381  
00382   if ( CkMyRank() ) return;
00383 
00384   UNPACKN(int,nPatchesOnNode,CkNumPes());
00385 
00386   if ( ! patchData ) patchData = new PatchData[nPatches];
00387   else if ( ! computeIdArena ) {
00388     for(i=0;i<nPatches;++i) {
00389       delete [] patchData[i].cids;
00390     }
00391   }
00392   UNPACKN(PatchData,patchData,nPatches);
00393 
00394   delete computeIdArena;
00395   computeIdArena = new ObjectArena<ComputeID>;
00396   computeIdArena->setBlockSize(1024);
00397 
00398   for(i=0;i<nPatches;++i) {
00399     DebugM(3,"Unpacking Patch " << i << " is on node " << patchData[i].node << 
00400         " with " << patchData[i].numCids << " cids.\n");
00401     patchData[i].cids = computeIdArena->getNewArray(patchData[i].numCids);
00402     patchData[i].numCidsAllocated = patchData[i].numCids;
00403     UNPACKN(ComputeID,patchData[i].cids,patchData[i].numCids);
00404   }
00405 }

void PatchMap::unregisterPatch PatchID  pid,
Patch pptr
 

Definition at line 791 of file PatchMap.C.

References DebugM.

00792 {
00793   if (pptr == myPatch[pid]) {
00794       DebugM(4, "UnregisterPatch("<<pid<<") at " << pptr << "\n");
00795       myPatch[pid] = NULL;
00796   }
00797 }

void PatchMap::unregisterPatch PatchID  pid,
HomePatch pptr
 

Definition at line 772 of file PatchMap.C.

References DebugM.

Referenced by ProxyMgr::removeProxy(), PatchMgr::sendMovePatches(), and PatchMgr::sendOneHomePatch().

00772                                                            {
00773   unregisterPatch(pid,(Patch*)pptr);
00774   if (pptr == myHomePatch[pid]) {
00775       DebugM(4, "UnregisterHomePatch("<<pid<<") at " << pptr << "\n");
00776       myHomePatch[pid] = NULL;
00777   }
00778 }

int PatchMap::upstreamNeighbors int  pid,
PatchID neighbor_ids
 

Definition at line 645 of file PatchMap.C.

References DebugM, Lattice::index(), and pid().

Referenced by ProxyMgr::createProxies(), and ComputeHomeTuples< TholeElem, Thole, TholeValue >::initialize().

00646 {
00647   int xi, yi, zi;
00648   int xinc, yinc, zinc;
00649   int n=0;
00650 
00651   for(zinc=0;zinc<=1;zinc++)
00652   {
00653     zi = patchData[pid].cIndex + zinc;
00654     if ((zi < 0) || (zi >= cDim))
00655       if ( ! cPeriodic ) continue;
00656     for(yinc=0;yinc<=1;yinc++)
00657     {
00658       yi = patchData[pid].bIndex + yinc;
00659       if ((yi < 0) || (yi >= bDim))
00660         if ( ! bPeriodic ) continue;
00661       for(xinc=0;xinc<=1;xinc++)
00662       {
00663         if ((xinc==0) && (yinc==0) && (zinc==0))
00664           continue;
00665 
00666         xi = patchData[pid].aIndex + xinc;
00667         if ((xi < 0) || (xi >= aDim))
00668           if ( ! aPeriodic ) continue;
00669 
00670         if (neighbor_ids)
00671           neighbor_ids[n]=this->pid(xi,yi,zi);
00672 #if 0
00673         if ( transform_ids )
00674         {
00675           int xt = 0; if ( xi < 0 ) xt = -1; if ( xi >= aDim ) xt = 1;
00676           int yt = 0; if ( yi < 0 ) yt = -1; if ( yi >= bDim ) yt = 1;
00677           int zt = 0; if ( zi < 0 ) zt = -1; if ( zi >= cDim ) zt = 1;
00678           transform_ids[n] = Lattice::index(xt,yt,zt);
00679         }
00680 #endif
00681         n++;
00682       }
00683     }
00684   }
00685   DebugM(3,"Patch " << pid << " has " << n << " upstream neighbors.\n");
00686   return n;
00687 }


Friends And Related Function Documentation

friend class WorkDistrib [friend]
 

Definition at line 169 of file PatchMap.h.


The documentation for this class was generated from the following files:
Generated on Fri May 25 04:07:23 2012 for NAMD by  doxygen 1.3.9.1