00001
00007 #include <stddef.h>
00008 #if !defined(WIN32) || defined(__CYGWIN__)
00009 #include <unistd.h>
00010 #endif
00011 #include <stdio.h>
00012
00013 #include "InfoStream.h"
00014 #include "ObjectArena.h"
00015 #include "PatchMgr.h"
00016 #include "PatchMap.inl"
00017 #include "Patch.h"
00018 #include "Lattice.h"
00019 #include "HomePatchList.h"
00020 #include "AtomMap.h"
00021
00022
00023 #define MIN_DEBUG_LEVEL 5
00024 #include "Debug.h"
00025
00026
00027 PatchMap *PatchMap::Instance() {
00028 if (CkpvAccess(PatchMap_instance) == 0) {
00029 CkpvAccess(PatchMap_instance) = new PatchMap;
00030 }
00031 return(CkpvAccess(PatchMap_instance));
00032 }
00033
00034
00035 PatchMap::PatchMap(void)
00036 {
00037 nPatches = 0;
00038 nNodesWithPatches = 0;
00039 int npes = CkNumPes();
00040 nPatchesOnNode = new int[npes];
00041 for ( int i=0; i<npes; ++i ) {
00042 nPatchesOnNode[i] = 0;
00043 }
00044 patchData = NULL;
00045 computeIdArena = NULL;
00046 aDim = bDim = cDim = 0;
00047 aAway = bAway = cAway = 1;
00048 aPeriodic = bPeriodic = cPeriodic = 0;
00049 aMaxIndex = bMaxIndex = cMaxIndex = 0;
00050 }
00051
00052 int PatchMap::sizeGrid(ScaledPosition xmin, ScaledPosition xmax,
00053 const Lattice &lattice, BigReal patchSize,
00054 double maxNumPatches,
00055 int asplit, int bsplit, int csplit)
00056 {
00057 aPeriodic = lattice.a_p();
00058 bPeriodic = lattice.b_p();
00059 cPeriodic = lattice.c_p();
00060
00061 aAway = asplit;
00062 bAway = bsplit;
00063 cAway = csplit;
00064
00065 maxNumPatches *= aAway * bAway * cAway;
00066
00067 int minNumPatches = 1;
00068 if ( aPeriodic ) minNumPatches *= aAway;
00069 if ( bPeriodic ) minNumPatches *= bAway;
00070 if ( cPeriodic ) minNumPatches *= cAway;
00071 if ( maxNumPatches < minNumPatches ) maxNumPatches = minNumPatches;
00072
00073 do {
00074
00075 if ( aPeriodic ) {
00076 BigReal sysDim = lattice.a_r().unit() * lattice.a();
00077 aDim = (int)(sysDim * aAway / patchSize);
00078 } else {
00079 BigReal sysDim = xmax.x - xmin.x;
00080 aDim = (int)(sysDim * aAway / patchSize);
00081 if ((aDim * patchSize) < (sysDim * aAway)) aDim++;
00082 }
00083
00084 if ( bPeriodic ) {
00085 BigReal sysDim = lattice.b_r().unit() * lattice.b();
00086 bDim = (int)(sysDim * bAway / patchSize);
00087 } else {
00088 BigReal sysDim = xmax.y - xmin.y;
00089 bDim = (int)(sysDim * bAway / patchSize);
00090 if ((bDim * patchSize) < (sysDim * bAway)) bDim++;
00091 }
00092
00093 if ( cPeriodic ) {
00094 BigReal sysDim = lattice.c_r().unit() * lattice.c();
00095 cDim = (int)(sysDim * cAway / patchSize);
00096 } else {
00097 BigReal sysDim = xmax.z - xmin.z;
00098 cDim = (int)(sysDim * cAway / patchSize);
00099 if ((cDim * patchSize) < (sysDim * cAway)) cDim++;
00100 }
00101
00102 if ( aDim < 0 || bDim < 0 || cDim < 0 ) {
00103 NAMD_die("Bug in PatchMap::sizeGrid - negative grid dimension.");
00104 }
00105
00106 if ( aDim == 0 ) aDim = 1;
00107 if ( bDim == 0 ) bDim = 1;
00108 if ( cDim == 0 ) cDim = 1;
00109
00110 if ( aPeriodic && aDim < aAway ) aDim = aAway;
00111 if ( bPeriodic && bDim < bAway ) bDim = bAway;
00112 if ( cPeriodic && cDim < cAway ) cDim = cAway;
00113
00114 } while ( ( aDim*bDim*cDim > maxNumPatches ) && ( patchSize *= 1.01 ) );
00115
00116 return aDim*bDim*cDim;
00117 }
00118
00119 void PatchMap::makePatches(ScaledPosition xmin, ScaledPosition xmax,
00120 const Lattice &lattice, BigReal patchSize,
00121 double maxNumPatches,
00122 int asplit, int bsplit, int csplit)
00123 {
00124 sizeGrid(xmin,xmax,lattice,patchSize,maxNumPatches,asplit,bsplit,csplit);
00125
00126 iout << iINFO << "PATCH GRID IS ";
00127 iout << aDim;
00128 if ( aPeriodic ) iout << " (PERIODIC)";
00129 iout << " BY ";
00130 iout << bDim;
00131 if ( bPeriodic ) iout << " (PERIODIC)";
00132 iout << " BY ";
00133 iout << cDim;
00134 if ( cPeriodic ) iout << " (PERIODIC)";
00135 iout << "\n";
00136 iout << iINFO << "PATCH GRID IS ";
00137 iout << aAway << "-AWAY BY ";
00138 iout << bAway << "-AWAY BY ";
00139 iout << cAway << "-AWAY\n";
00140 iout << endi;
00141
00142 aMaxIndex = ( ! aPeriodic || aDim == 2 ) ? 10000 : aDim;
00143 bMaxIndex = ( ! bPeriodic || bDim == 2 ) ? 10000 : bDim;
00144 cMaxIndex = ( ! cPeriodic || cDim == 2 ) ? 10000 : cDim;
00145
00146 aLength = aPeriodic ? 1.0 : aDim * patchSize;
00147 bLength = bPeriodic ? 1.0 : bDim * patchSize;
00148 cLength = cPeriodic ? 1.0 : cDim * patchSize;
00149
00150 aOrigin = aPeriodic ? -0.5 : 0.5 * (xmin.x + xmax.x - aLength);
00151 bOrigin = bPeriodic ? -0.5 : 0.5 * (xmin.y + xmax.y - bLength);
00152 cOrigin = cPeriodic ? -0.5 : 0.5 * (xmin.z + xmax.z - cLength);
00153
00154 nPatches=aDim*bDim*cDim;
00155 patchData = new PatchData[nPatches];
00156
00157 for(int i=0; i<nPatches; ++i)
00158 {
00159 PatchData &p = patchData[i];
00160 p.basenode = -1;
00161 p.numCids = 0;
00162 p.aIndex = index_a(i);
00163 p.bIndex = index_b(i);
00164 p.cIndex = index_c(i);
00165 p.myPatch = 0;
00166 p.myHomePatch = 0;
00167 p.aMin = ((float)p.aIndex/(float)aDim) * aLength + aOrigin;
00168 p.bMin = ((float)p.bIndex/(float)bDim) * bLength + bOrigin;
00169 p.cMin = ((float)p.cIndex/(float)cDim) * cLength + cOrigin;
00170 p.aMax = ((float)(p.aIndex+1)/(float)aDim) * aLength + aOrigin;
00171 p.bMax = ((float)(p.bIndex+1)/(float)bDim) * bLength + bOrigin;
00172 p.cMax = ((float)(p.cIndex+1)/(float)cDim) * cLength + cOrigin;
00173 p.numCids = 0;
00174 int max_computes = 200;
00175 p.cids = new int[max_computes];
00176 for ( int j = 0; j < max_computes; ++j ) p.cids[j] = -1;
00177 p.numCidsAllocated = max_computes;
00178 }
00179
00180 }
00181
00182 void PatchMap::checkMap(void)
00183 {
00184 int patchCount=0;
00185 for (int i=0; i<nPatches; i++) {
00186 if (patchData[i].myPatch) {
00187 patchCount++;
00188 if ( patchData[i].myPatch->getPatchID() != i) {
00189 DebugM(4, "patchID("<<patchData[i].myPatch->getPatchID()
00190 <<") != patchID("
00191 <<i<<")\n");
00192 }
00193 }
00194 }
00195 DebugM(4, "Patch Count = " <<patchCount<<"\n");
00196 }
00197
00198
00199 PatchMap::~PatchMap(void)
00200 {
00201 if (patchData)
00202 {
00203 int i;
00204
00205 if ( ! computeIdArena ) {
00206 for (i=0; i<nPatches; i++) {
00207 delete [] patchData[i].cids;
00208 }
00209 }
00210 delete [] patchData;
00211 patchData=NULL;
00212 nPatches=0;
00213 }
00214 delete [] nPatchesOnNode;
00215 delete computeIdArena;
00216 }
00217
00218 #undef PACK
00219 #define PACK(type,data) { memcpy(b, &data,sizeof(type)); b += sizeof(type); }
00220 #define PACKN(type,data,cnt) { memcpy(b, data,(cnt)*sizeof(type)); b += (cnt)*sizeof(type); }
00221
00222 int PatchMap::packSize(void)
00223 {
00224 int i, size = 0;
00225 size += 14 * sizeof(int) + 6 * sizeof(BigReal);
00226 size += CkNumPes() * sizeof(int);
00227 for(i=0;i<nPatches;++i)
00228 {
00229 size += sizeof(PatchData);
00230 size += patchData[i].numCidsAllocated * sizeof(ComputeID);
00231 }
00232 return size;
00233 }
00234
00235 void PatchMap::pack (char *buffer)
00236 {
00237 DebugM(4,"Packing PatchMap on node " << CkMyPe() << std::endl);
00238 int i,j;
00239
00240
00241 char *b = buffer;
00242 PACK(int,nPatches);
00243 DebugM(3,"nPatches = " << nPatches << std::endl);
00244 PACK(int,aDim); PACK(int,bDim); PACK(int,cDim);
00245 PACK(int,aAway); PACK(int,bAway); PACK(int,cAway);
00246 PACK(int,aPeriodic); PACK(int,bPeriodic); PACK(int,cPeriodic);
00247 PACK(int,aMaxIndex); PACK(int,bMaxIndex); PACK(int,cMaxIndex);
00248 PACK(BigReal,aOrigin); PACK(BigReal,bOrigin); PACK(BigReal,cOrigin);
00249 PACK(BigReal,aLength); PACK(BigReal,bLength); PACK(BigReal,cLength);
00250 PACK(int,nNodesWithPatches);
00251 PACKN(int,nPatchesOnNode,CkNumPes());
00252 for(i=0;i<nPatches;++i)
00253 {
00254 DebugM(3,"Packing Patch " << i << " is on node " << patchData[i].node <<
00255 " with " << patchData[i].numCidsAllocated << " allocated.\n");
00256 PACK(PatchData,patchData[i]);
00257 for(j=0;j<patchData[i].numCidsAllocated;++j)
00258 PACK(ComputeID,patchData[i].cids[j]);
00259 }
00260
00261 }
00262
00263 #undef UNPACK
00264 #define UNPACK(type,data) { memcpy(&data, b, sizeof(type)); b += sizeof(type); }
00265 #define UNPACKN(type,data,cnt) { memcpy(data, b, (cnt)*sizeof(type)); b += (cnt)*sizeof(type); }
00266
00267 void PatchMap::unpack (char *ptr)
00268 {
00269 DebugM(4,"Unpacking PatchMap on node " << CkMyPe() << std::endl);
00270 int i,j;
00271 char *b = (char*)ptr;
00272 {
00273
00274 int nPatches_tmp;
00275 UNPACK(int,nPatches_tmp);
00276 nPatches = nPatches_tmp;
00277 }
00278 DebugM(3,"nPatches = " << nPatches << std::endl);
00279 UNPACK(int,aDim); UNPACK(int,bDim); UNPACK(int,cDim);
00280 UNPACK(int,aAway); UNPACK(int,bAway); UNPACK(int,cAway);
00281 UNPACK(int,aPeriodic); UNPACK(int,bPeriodic); UNPACK(int,cPeriodic);
00282 UNPACK(int,aMaxIndex); UNPACK(int,bMaxIndex); UNPACK(int,cMaxIndex);
00283 UNPACK(BigReal,aOrigin); UNPACK(BigReal,bOrigin); UNPACK(BigReal,cOrigin);
00284 UNPACK(BigReal,aLength); UNPACK(BigReal,bLength); UNPACK(BigReal,cLength);
00285 UNPACK(int,nNodesWithPatches);
00286 UNPACKN(int,nPatchesOnNode,CkNumPes());
00287 patchData = new PatchData[nPatches];
00288
00289 delete computeIdArena;
00290 computeIdArena = new ObjectArena<ComputeID>;
00291 computeIdArena->setBlockSize(256);
00292
00293 for(i=0;i<nPatches;++i)
00294 {
00295 UNPACK(PatchData,patchData[i]);
00296 if (CkMyPe()) {
00297 patchData[i].myPatch = 0;
00298 patchData[i].myHomePatch = 0;
00299 }
00300 DebugM(3,"Unpacking Patch " << i << " is on node " << patchData[i].node <<
00301 " with " << patchData[i].numCidsAllocated << " allocated.\n");
00302 patchData[i].cids = computeIdArena->getNewArray(patchData[i].numCidsAllocated);
00303
00304 for(j=0;j<patchData[i].numCidsAllocated;++j)
00305 UNPACK(ComputeID,patchData[i].cids[j]);
00306 }
00307 }
00308
00309
00310 int PatchMap::numHomePatches(void)
00311 {
00312 return CkpvAccess(PatchMap_patchMgr)->homePatches.size();
00313 }
00314
00315
00316 HomePatchList *PatchMap::homePatchList() {
00317 return &(CkpvAccess(PatchMap_patchMgr)->homePatches);
00318 }
00319
00320
00321 void PatchMap::homePatchIDList(PatchIDList &pids) {
00322 pids.resize(0);
00323 int i;
00324 for ( i=0; i<nPatches; ++i ) {
00325 if ( patchData[i].node == CkMyPe() ) {
00326 pids.add(i);
00327 }
00328 }
00329 }
00330
00331
00332 void PatchMap::basePatchIDList(int pe, PatchIDList &pids) {
00333 pids.resize(0);
00334 int i;
00335 for ( i=0; i<nPatches; ++i ) {
00336 if ( patchData[i].basenode == pe ) {
00337 pids.add(i);
00338 }
00339 }
00340 }
00341
00342
00343 void PatchMap::assignNode(PatchID pid, NodeID node) {
00344 patchData[pid].node=node;
00345 if ( nPatchesOnNode[node] == 0 ) nNodesWithPatches += 1;
00346 nPatchesOnNode[node] += 1;
00347 }
00348
00349
00350 void PatchMap::assignBaseNode(PatchID pid, NodeID node) {
00351 patchData[pid].basenode=node;
00352 }
00353
00354 void PatchMap::assignBaseNode(PatchID pid) {
00355
00356 int i = 1;
00357
00358 NodeID node = patchData[pid].node;
00359
00360 if ( CkNumPes() > 2*nPatches+1 ) {
00361
00362 int newnode = ( CkNumPes() + node - 1 ) % CkNumPes();
00363 bool success = 0;
00364
00365 while ( i < CkNumPes() && !success) {
00366 if ( nPatchesOnNode[newnode] == 0 )
00367 success = 1;
00368
00369
00370 for (int count = 0; count < pid; count ++)
00371 if (patchData[count].basenode > 0 && patchData[count].basenode == newnode) {
00372 success = 0;
00373 break;
00374 }
00375
00376
00377 if (success) break;
00378
00379 newnode = ( CkNumPes() + node - i - 1 ) % CkNumPes();
00380 i ++;
00381 }
00382 patchData[pid].basenode = newnode;
00383
00384 } else {
00385 patchData[pid].basenode=node;
00386 }
00387 }
00388
00389
00390 void PatchMap::newCid(int pid, int cid)
00391 {
00392 if (patchData[pid].numCids >= patchData[pid].numCidsAllocated)
00393 {
00394
00395 ComputeID *old = patchData[pid].cids;
00396 patchData[pid].numCidsAllocated += 200;
00397 patchData[pid].cids = new int[patchData[pid].numCidsAllocated];
00398 int i;
00399 for (i=0; i<patchData[pid].numCids; i++)
00400 patchData[pid].cids[i] = old[i];
00401 for (i=patchData[pid].numCids; i<patchData[pid].numCidsAllocated; i++)
00402 patchData[pid].cids[i] = -1;
00403 delete [] old;
00404 }
00405 patchData[pid].cids[patchData[pid].numCids]=cid;
00406 patchData[pid].numCids++;
00407 }
00408
00409
00410 int PatchMap::oneAwayNeighbors(int pid, PatchID *neighbor_ids, int *transform_ids)
00411 {
00412 int xi, yi, zi;
00413 int xinc, yinc, zinc;
00414 int n=0;
00415
00416 for(zinc=-1;zinc<=1;zinc++)
00417 {
00418 zi = patchData[pid].cIndex + zinc;
00419 if ((zi < 0) || (zi >= cDim))
00420 if ( ! cPeriodic ) continue;
00421 for(yinc=-1;yinc<=1;yinc++)
00422 {
00423 yi = patchData[pid].bIndex + yinc;
00424 if ((yi < 0) || (yi >= bDim))
00425 if ( ! bPeriodic ) continue;
00426 for(xinc=-1;xinc<=1;xinc++)
00427 {
00428 if ((xinc==0) && (yinc==0) && (zinc==0))
00429 continue;
00430
00431 xi = patchData[pid].aIndex + xinc;
00432 if ((xi < 0) || (xi >= aDim))
00433 if ( ! aPeriodic ) continue;
00434
00435 if (neighbor_ids)
00436 neighbor_ids[n]=this->pid(xi,yi,zi);
00437 if ( transform_ids )
00438 {
00439 int xt = 0; if ( xi < 0 ) xt = -1; if ( xi >= aDim ) xt = 1;
00440 int yt = 0; if ( yi < 0 ) yt = -1; if ( yi >= bDim ) yt = 1;
00441 int zt = 0; if ( zi < 0 ) zt = -1; if ( zi >= cDim ) zt = 1;
00442 transform_ids[n] = Lattice::index(xt,yt,zt);
00443 }
00444 n++;
00445 }
00446 }
00447 }
00448 DebugM(3,"Patch " << pid << " has " << n << " first neighbors.\n");
00449 return n;
00450 }
00451
00452
00453
00454
00455 int PatchMap::oneOrTwoAwayNeighbors(int pid, PatchID *neighbor_ids, int *transform_ids)
00456 {
00457 int xi, yi, zi;
00458 int xinc, yinc, zinc;
00459 int n=0;
00460
00461 for(zinc=0;zinc<=cAway;zinc++)
00462 {
00463 zi = patchData[pid].cIndex + zinc;
00464 if ((zi < 0) || (zi >= cDim))
00465 if ( ! cPeriodic ) continue;
00466 for(yinc=(zinc>0 ? -bAway : 0);yinc<=bAway;yinc++)
00467 {
00468 yi = patchData[pid].bIndex + yinc;
00469 if ((yi < 0) || (yi >= bDim))
00470 if ( ! bPeriodic ) continue;
00471 for(xinc=((zinc>0 || yinc>0) ? -aAway : 0);xinc<=aAway;xinc++)
00472 {
00473 if ((xinc==0) && (yinc==0) && (zinc==0))
00474 continue;
00475
00476 xi = patchData[pid].aIndex + xinc;
00477 if ((xi < 0) || (xi >= aDim))
00478 if ( ! aPeriodic ) continue;
00479
00480 neighbor_ids[n]=this->pid(xi,yi,zi);
00481 if ( transform_ids )
00482 {
00483 int xt = 0; if ( xi < 0 ) xt = -1; if ( xi >= aDim ) xt = 1;
00484 int yt = 0; if ( yi < 0 ) yt = -1; if ( yi >= bDim ) yt = 1;
00485 int zt = 0; if ( zi < 0 ) zt = -1; if ( zi >= cDim ) zt = 1;
00486 transform_ids[n] = Lattice::index(xt,yt,zt);
00487 }
00488 n++;
00489 }
00490 }
00491 }
00492 DebugM(3,"Patch " << pid << " has " << n << " second neighbors.\n");
00493 return n;
00494 }
00495
00496 int PatchMap::upstreamNeighbors(int pid, PatchID *neighbor_ids, int *transform_ids)
00497 {
00498 int xi, yi, zi;
00499 int xinc, yinc, zinc;
00500 int n=0;
00501
00502 for(zinc=0;zinc<=1;zinc++)
00503 {
00504 zi = patchData[pid].cIndex + zinc;
00505 if ((zi < 0) || (zi >= cDim))
00506 if ( ! cPeriodic ) continue;
00507 for(yinc=0;yinc<=1;yinc++)
00508 {
00509 yi = patchData[pid].bIndex + yinc;
00510 if ((yi < 0) || (yi >= bDim))
00511 if ( ! bPeriodic ) continue;
00512 for(xinc=0;xinc<=1;xinc++)
00513 {
00514 if ((xinc==0) && (yinc==0) && (zinc==0))
00515 continue;
00516
00517 xi = patchData[pid].aIndex + xinc;
00518 if ((xi < 0) || (xi >= aDim))
00519 if ( ! aPeriodic ) continue;
00520
00521 if (neighbor_ids)
00522 neighbor_ids[n]=this->pid(xi,yi,zi);
00523 if ( transform_ids )
00524 {
00525 int xt = 0; if ( xi < 0 ) xt = -1; if ( xi >= aDim ) xt = 1;
00526 int yt = 0; if ( yi < 0 ) yt = -1; if ( yi >= bDim ) yt = 1;
00527 int zt = 0; if ( zi < 0 ) zt = -1; if ( zi >= cDim ) zt = 1;
00528 transform_ids[n] = Lattice::index(xt,yt,zt);
00529 }
00530 n++;
00531 }
00532 }
00533 }
00534 DebugM(3,"Patch " << pid << " has " << n << " upstream neighbors.\n");
00535 return n;
00536 }
00537
00538
00539 int PatchMap::downstreamNeighbors(int pid, PatchID *neighbor_ids,
00540 int *transform_ids)
00541 {
00542 int xi, yi, zi;
00543 int xinc, yinc, zinc;
00544 int n=0;
00545
00546 for(zinc=-1;zinc<=0;zinc++)
00547 {
00548 zi = patchData[pid].cIndex + zinc;
00549 if ((zi < 0) || (zi >= cDim))
00550 if ( ! cPeriodic ) continue;
00551 for(yinc=-1;yinc<=0;yinc++)
00552 {
00553 yi = patchData[pid].bIndex + yinc;
00554 if ((yi < 0) || (yi >= bDim))
00555 if ( ! bPeriodic ) continue;
00556 for(xinc=-1;xinc<=0;xinc++)
00557 {
00558 if ((xinc==0) && (yinc==0) && (zinc==0))
00559 continue;
00560
00561 xi = patchData[pid].aIndex + xinc;
00562 if ((xi < 0) || (xi >= aDim))
00563 if ( ! aPeriodic ) continue;
00564
00565 if (neighbor_ids)
00566 neighbor_ids[n]=this->pid(xi,yi,zi);
00567 if ( transform_ids )
00568 {
00569 int xt = 0; if ( xi < 0 ) xt = -1; if ( xi >= aDim ) xt = 1;
00570 int yt = 0; if ( yi < 0 ) yt = -1; if ( yi >= bDim ) yt = 1;
00571 int zt = 0; if ( zi < 0 ) zt = -1; if ( zi >= cDim ) zt = 1;
00572 transform_ids[n] = Lattice::index(xt,yt,zt);
00573 }
00574 n++;
00575 }
00576 }
00577 }
00578 DebugM(3,"Patch " << pid << " has " << n << " upstream neighbors.\n");
00579 return n;
00580 }
00581
00582
00583 void PatchMap::printPatchMap(void)
00584 {
00585 CkPrintf("---------------------------------------");
00586 CkPrintf("---------------------------------------\n");
00587
00588 CkPrintf("nPatches = %d\n",nPatches);
00589 for(int i=0;i<nPatches;i++)
00590 {
00591 CkPrintf("Patch %d:\n",i);
00592 CkPrintf(" node = %d\n",patchData[i].node);
00593 CkPrintf(" xi,yi,zi = %d, %d, %d\n",
00594 patchData[i].aIndex,patchData[i].bIndex,patchData[i].cIndex);
00595 CkPrintf(" x0,y0,z0 = %f, %f, %f\n",
00596 patchData[i].aMin,patchData[i].bMin,patchData[i].cMin);
00597 CkPrintf(" x1,y1,z1 = %f, %f, %f\n",
00598 patchData[i].aMax,patchData[i].bMax,patchData[i].cMax);
00599 CkPrintf(" numCids = %d\n",patchData[i].numCids);
00600 CkPrintf(" numCidsAllocated = %d\n",patchData[i].numCidsAllocated);
00601 for(int j=0; j < patchData[i].numCids; j++)
00602 {
00603 CkPrintf(" %10d ",patchData[i].cids[j]);
00604 if (!((j+1) % 6))
00605 CkPrintf("\n");
00606 }
00607 CkPrintf("\n---------------------------------------");
00608 CkPrintf("---------------------------------------\n");
00609 }
00610
00611 }
00612
00613
00614 void PatchMap::registerPatch(PatchID pid, HomePatch *pptr) {
00615 registerPatch(pid,(Patch*)pptr);
00616 if (patchData[pid].myHomePatch != 0) {
00617 iout << iPE << iERRORF
00618 << "homePatchID("<<pid<<") is being re-registered!\n" << endi;
00619 }
00620 patchData[pid].myHomePatch = pptr;
00621 }
00622
00623
00624 void PatchMap::unregisterPatch(PatchID pid, HomePatch *pptr) {
00625 unregisterPatch(pid,(Patch*)pptr);
00626 if (pptr == patchData[pid].myHomePatch) {
00627 DebugM(4, "UnregisterHomePatch("<<pid<<") at " << pptr << "\n");
00628 patchData[pid].myHomePatch = NULL;
00629 }
00630 }
00631
00632
00633 void PatchMap::registerPatch(PatchID pid, Patch *pptr)
00634 {
00635 if (patchData[pid].myPatch != 0) {
00636 iout << iPE << iERRORF
00637 << "patchID("<<pid<<") is being re-registered!\n" << endi;
00638 }
00639 patchData[pid].myPatch = pptr;
00640 }
00641
00642
00643 void PatchMap::unregisterPatch(PatchID pid, Patch *pptr)
00644 {
00645 if (pptr == patchData[pid].myPatch) {
00646 DebugM(4, "UnregisterPatch("<<pid<<") at " << pptr << "\n");
00647 patchData[pid].myPatch = NULL;
00648 }
00649 }
00650
00651
00652 HomePatch *PatchMap::homePatch(PatchID pid)
00653 {
00654 return patchData[pid].myHomePatch;
00655 }
00656