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.center.x = (((double)(p.aIndex)+0.5)/(double)aDim) * aLength + aOrigin;
00174 p.center.y = (((double)(p.bIndex)+0.5)/(double)bDim) * bLength + bOrigin;
00175 p.center.z = (((double)(p.cIndex)+0.5)/(double)cDim) * cLength + cOrigin;
00176 p.numCids = 0;
00177 int max_computes = 200;
00178 p.cids = new int[max_computes];
00179 for ( int j = 0; j < max_computes; ++j ) p.cids[j] = -1;
00180 p.numCidsAllocated = max_computes;
00181 }
00182
00183 }
00184
00185 void PatchMap::checkMap(void)
00186 {
00187 int patchCount=0;
00188 for (int i=0; i<nPatches; i++) {
00189 if (patchData[i].myPatch) {
00190 patchCount++;
00191 if ( patchData[i].myPatch->getPatchID() != i) {
00192 DebugM(4, "patchID("<<patchData[i].myPatch->getPatchID()
00193 <<") != patchID("
00194 <<i<<")\n");
00195 }
00196 }
00197 }
00198 DebugM(4, "Patch Count = " <<patchCount<<"\n");
00199 }
00200
00201
00202 PatchMap::~PatchMap(void)
00203 {
00204 if (patchData)
00205 {
00206 int i;
00207
00208 if ( ! computeIdArena ) {
00209 for (i=0; i<nPatches; i++) {
00210 delete [] patchData[i].cids;
00211 }
00212 }
00213 delete [] patchData;
00214 patchData=NULL;
00215 nPatches=0;
00216 }
00217 delete [] nPatchesOnNode;
00218 delete computeIdArena;
00219 }
00220
00221 #undef PACK
00222 #define PACK(type,data) { memcpy(b, &data,sizeof(type)); b += sizeof(type); }
00223 #define PACKN(type,data,cnt) { memcpy(b, data,(cnt)*sizeof(type)); b += (cnt)*sizeof(type); }
00224
00225 int PatchMap::packSize(void)
00226 {
00227 int i, size = 0;
00228 size += 14 * sizeof(int) + 6 * sizeof(BigReal);
00229 size += CkNumPes() * sizeof(int);
00230 for(i=0;i<nPatches;++i)
00231 {
00232 size += sizeof(PatchData);
00233 size += patchData[i].numCidsAllocated * sizeof(ComputeID);
00234 }
00235 return size;
00236 }
00237
00238 void PatchMap::pack (char *buffer)
00239 {
00240 DebugM(4,"Packing PatchMap on node " << CkMyPe() << std::endl);
00241 int i,j;
00242
00243
00244 char *b = buffer;
00245 PACK(int,nPatches);
00246 DebugM(3,"nPatches = " << nPatches << std::endl);
00247 PACK(int,aDim); PACK(int,bDim); PACK(int,cDim);
00248 PACK(int,aAway); PACK(int,bAway); PACK(int,cAway);
00249 PACK(int,aPeriodic); PACK(int,bPeriodic); PACK(int,cPeriodic);
00250 PACK(int,aMaxIndex); PACK(int,bMaxIndex); PACK(int,cMaxIndex);
00251 PACK(BigReal,aOrigin); PACK(BigReal,bOrigin); PACK(BigReal,cOrigin);
00252 PACK(BigReal,aLength); PACK(BigReal,bLength); PACK(BigReal,cLength);
00253 PACK(int,nNodesWithPatches);
00254 PACKN(int,nPatchesOnNode,CkNumPes());
00255 for(i=0;i<nPatches;++i)
00256 {
00257 DebugM(3,"Packing Patch " << i << " is on node " << patchData[i].node <<
00258 " with " << patchData[i].numCidsAllocated << " allocated.\n");
00259 PACK(PatchData,patchData[i]);
00260 for(j=0;j<patchData[i].numCidsAllocated;++j)
00261 PACK(ComputeID,patchData[i].cids[j]);
00262 }
00263
00264 }
00265
00266 #undef UNPACK
00267 #define UNPACK(type,data) { memcpy(&data, b, sizeof(type)); b += sizeof(type); }
00268 #define UNPACKN(type,data,cnt) { memcpy(data, b, (cnt)*sizeof(type)); b += (cnt)*sizeof(type); }
00269
00270 void PatchMap::unpack (char *ptr)
00271 {
00272 DebugM(4,"Unpacking PatchMap on node " << CkMyPe() << std::endl);
00273 int i,j;
00274 char *b = (char*)ptr;
00275 {
00276
00277 int nPatches_tmp;
00278 UNPACK(int,nPatches_tmp);
00279 nPatches = nPatches_tmp;
00280 }
00281 DebugM(3,"nPatches = " << nPatches << std::endl);
00282 UNPACK(int,aDim); UNPACK(int,bDim); UNPACK(int,cDim);
00283 UNPACK(int,aAway); UNPACK(int,bAway); UNPACK(int,cAway);
00284 UNPACK(int,aPeriodic); UNPACK(int,bPeriodic); UNPACK(int,cPeriodic);
00285 UNPACK(int,aMaxIndex); UNPACK(int,bMaxIndex); UNPACK(int,cMaxIndex);
00286 UNPACK(BigReal,aOrigin); UNPACK(BigReal,bOrigin); UNPACK(BigReal,cOrigin);
00287 UNPACK(BigReal,aLength); UNPACK(BigReal,bLength); UNPACK(BigReal,cLength);
00288 UNPACK(int,nNodesWithPatches);
00289 UNPACKN(int,nPatchesOnNode,CkNumPes());
00290 patchData = new PatchData[nPatches];
00291
00292 delete computeIdArena;
00293 computeIdArena = new ObjectArena<ComputeID>;
00294 computeIdArena->setBlockSize(256);
00295
00296 for(i=0;i<nPatches;++i)
00297 {
00298 UNPACK(PatchData,patchData[i]);
00299 if (CkMyPe()) {
00300 patchData[i].myPatch = 0;
00301 patchData[i].myHomePatch = 0;
00302 }
00303 DebugM(3,"Unpacking Patch " << i << " is on node " << patchData[i].node <<
00304 " with " << patchData[i].numCidsAllocated << " allocated.\n");
00305 patchData[i].cids = computeIdArena->getNewArray(patchData[i].numCidsAllocated);
00306
00307 for(j=0;j<patchData[i].numCidsAllocated;++j)
00308 UNPACK(ComputeID,patchData[i].cids[j]);
00309 }
00310 }
00311
00312
00313 int PatchMap::numHomePatches(void)
00314 {
00315 return CkpvAccess(PatchMap_patchMgr)->homePatches.size();
00316 }
00317
00318
00319 HomePatchList *PatchMap::homePatchList() {
00320 return &(CkpvAccess(PatchMap_patchMgr)->homePatches);
00321 }
00322
00323
00324 void PatchMap::homePatchIDList(PatchIDList &pids) {
00325 pids.resize(0);
00326 int i;
00327 for ( i=0; i<nPatches; ++i ) {
00328 if ( patchData[i].node == CkMyPe() ) {
00329 pids.add(i);
00330 }
00331 }
00332 }
00333
00334
00335 void PatchMap::basePatchIDList(int pe, PatchIDList &pids) {
00336 pids.resize(0);
00337 int i;
00338 for ( i=0; i<nPatches; ++i ) {
00339 if ( patchData[i].basenode == pe ) {
00340 pids.add(i);
00341 }
00342 }
00343 }
00344
00345
00346 void PatchMap::assignNode(PatchID pid, NodeID node) {
00347 patchData[pid].node=node;
00348 if ( nPatchesOnNode[node] == 0 ) nNodesWithPatches += 1;
00349 nPatchesOnNode[node] += 1;
00350 }
00351
00352
00353 void PatchMap::assignBaseNode(PatchID pid, NodeID node) {
00354 patchData[pid].basenode=node;
00355 }
00356
00357 void PatchMap::assignBaseNode(PatchID pid) {
00358
00359 int i = 1;
00360
00361 NodeID node = patchData[pid].node;
00362
00363 if ( CkNumPes() > 2*nPatches+1 ) {
00364
00365 int newnode = ( CkNumPes() + node - 1 ) % CkNumPes();
00366 bool success = 0;
00367
00368 while ( i < CkNumPes() && !success) {
00369 if ( nPatchesOnNode[newnode] == 0 )
00370 success = 1;
00371
00372
00373 for (int count = 0; count < pid; count ++)
00374 if (patchData[count].basenode > 0 && patchData[count].basenode == newnode) {
00375 success = 0;
00376 break;
00377 }
00378
00379
00380 if (success) break;
00381
00382 newnode = ( CkNumPes() + node - i - 1 ) % CkNumPes();
00383 i ++;
00384 }
00385 patchData[pid].basenode = newnode;
00386
00387 } else {
00388 patchData[pid].basenode=node;
00389 }
00390 }
00391
00392
00393 void PatchMap::newCid(int pid, int cid)
00394 {
00395 if (patchData[pid].numCids >= patchData[pid].numCidsAllocated)
00396 {
00397
00398 ComputeID *old = patchData[pid].cids;
00399 patchData[pid].numCidsAllocated += 200;
00400 patchData[pid].cids = new int[patchData[pid].numCidsAllocated];
00401 int i;
00402 for (i=0; i<patchData[pid].numCids; i++)
00403 patchData[pid].cids[i] = old[i];
00404 for (i=patchData[pid].numCids; i<patchData[pid].numCidsAllocated; i++)
00405 patchData[pid].cids[i] = -1;
00406 delete [] old;
00407 }
00408 patchData[pid].cids[patchData[pid].numCids]=cid;
00409 patchData[pid].numCids++;
00410 }
00411
00412
00413 int PatchMap::oneAwayNeighbors(int pid, PatchID *neighbor_ids, int *transform_ids)
00414 {
00415 int xi, yi, zi;
00416 int xinc, yinc, zinc;
00417 int n=0;
00418
00419 for(zinc=-1;zinc<=1;zinc++)
00420 {
00421 zi = patchData[pid].cIndex + zinc;
00422 if ((zi < 0) || (zi >= cDim))
00423 if ( ! cPeriodic ) continue;
00424 for(yinc=-1;yinc<=1;yinc++)
00425 {
00426 yi = patchData[pid].bIndex + yinc;
00427 if ((yi < 0) || (yi >= bDim))
00428 if ( ! bPeriodic ) continue;
00429 for(xinc=-1;xinc<=1;xinc++)
00430 {
00431 if ((xinc==0) && (yinc==0) && (zinc==0))
00432 continue;
00433
00434 xi = patchData[pid].aIndex + xinc;
00435 if ((xi < 0) || (xi >= aDim))
00436 if ( ! aPeriodic ) continue;
00437
00438 if (neighbor_ids)
00439 neighbor_ids[n]=this->pid(xi,yi,zi);
00440 if ( transform_ids )
00441 {
00442 int xt = 0; if ( xi < 0 ) xt = -1; if ( xi >= aDim ) xt = 1;
00443 int yt = 0; if ( yi < 0 ) yt = -1; if ( yi >= bDim ) yt = 1;
00444 int zt = 0; if ( zi < 0 ) zt = -1; if ( zi >= cDim ) zt = 1;
00445 transform_ids[n] = Lattice::index(xt,yt,zt);
00446 }
00447 n++;
00448 }
00449 }
00450 }
00451 DebugM(3,"Patch " << pid << " has " << n << " first neighbors.\n");
00452 return n;
00453 }
00454
00455
00456
00457
00458 int PatchMap::oneOrTwoAwayNeighbors(int pid, PatchID *neighbor_ids, int *transform_ids)
00459 {
00460 int xi, yi, zi;
00461 int xinc, yinc, zinc;
00462 int n=0;
00463
00464 for(zinc=0;zinc<=cAway;zinc++)
00465 {
00466 zi = patchData[pid].cIndex + zinc;
00467 if ((zi < 0) || (zi >= cDim))
00468 if ( ! cPeriodic ) continue;
00469 for(yinc=(zinc>0 ? -bAway : 0);yinc<=bAway;yinc++)
00470 {
00471 yi = patchData[pid].bIndex + yinc;
00472 if ((yi < 0) || (yi >= bDim))
00473 if ( ! bPeriodic ) continue;
00474 for(xinc=((zinc>0 || yinc>0) ? -aAway : 0);xinc<=aAway;xinc++)
00475 {
00476 if ((xinc==0) && (yinc==0) && (zinc==0))
00477 continue;
00478
00479 xi = patchData[pid].aIndex + xinc;
00480 if ((xi < 0) || (xi >= aDim))
00481 if ( ! aPeriodic ) continue;
00482
00483 neighbor_ids[n]=this->pid(xi,yi,zi);
00484 if ( transform_ids )
00485 {
00486 int xt = 0; if ( xi < 0 ) xt = -1; if ( xi >= aDim ) xt = 1;
00487 int yt = 0; if ( yi < 0 ) yt = -1; if ( yi >= bDim ) yt = 1;
00488 int zt = 0; if ( zi < 0 ) zt = -1; if ( zi >= cDim ) zt = 1;
00489 transform_ids[n] = Lattice::index(xt,yt,zt);
00490 }
00491 n++;
00492 }
00493 }
00494 }
00495 DebugM(3,"Patch " << pid << " has " << n << " second neighbors.\n");
00496 return n;
00497 }
00498
00499 int PatchMap::upstreamNeighbors(int pid, PatchID *neighbor_ids, int *transform_ids)
00500 {
00501 int xi, yi, zi;
00502 int xinc, yinc, zinc;
00503 int n=0;
00504
00505 for(zinc=0;zinc<=1;zinc++)
00506 {
00507 zi = patchData[pid].cIndex + zinc;
00508 if ((zi < 0) || (zi >= cDim))
00509 if ( ! cPeriodic ) continue;
00510 for(yinc=0;yinc<=1;yinc++)
00511 {
00512 yi = patchData[pid].bIndex + yinc;
00513 if ((yi < 0) || (yi >= bDim))
00514 if ( ! bPeriodic ) continue;
00515 for(xinc=0;xinc<=1;xinc++)
00516 {
00517 if ((xinc==0) && (yinc==0) && (zinc==0))
00518 continue;
00519
00520 xi = patchData[pid].aIndex + xinc;
00521 if ((xi < 0) || (xi >= aDim))
00522 if ( ! aPeriodic ) continue;
00523
00524 if (neighbor_ids)
00525 neighbor_ids[n]=this->pid(xi,yi,zi);
00526 if ( transform_ids )
00527 {
00528 int xt = 0; if ( xi < 0 ) xt = -1; if ( xi >= aDim ) xt = 1;
00529 int yt = 0; if ( yi < 0 ) yt = -1; if ( yi >= bDim ) yt = 1;
00530 int zt = 0; if ( zi < 0 ) zt = -1; if ( zi >= cDim ) zt = 1;
00531 transform_ids[n] = Lattice::index(xt,yt,zt);
00532 }
00533 n++;
00534 }
00535 }
00536 }
00537 DebugM(3,"Patch " << pid << " has " << n << " upstream neighbors.\n");
00538 return n;
00539 }
00540
00541
00542 int PatchMap::downstreamNeighbors(int pid, PatchID *neighbor_ids,
00543 int *transform_ids)
00544 {
00545 int xi, yi, zi;
00546 int xinc, yinc, zinc;
00547 int n=0;
00548
00549 for(zinc=-1;zinc<=0;zinc++)
00550 {
00551 zi = patchData[pid].cIndex + zinc;
00552 if ((zi < 0) || (zi >= cDim))
00553 if ( ! cPeriodic ) continue;
00554 for(yinc=-1;yinc<=0;yinc++)
00555 {
00556 yi = patchData[pid].bIndex + yinc;
00557 if ((yi < 0) || (yi >= bDim))
00558 if ( ! bPeriodic ) continue;
00559 for(xinc=-1;xinc<=0;xinc++)
00560 {
00561 if ((xinc==0) && (yinc==0) && (zinc==0))
00562 continue;
00563
00564 xi = patchData[pid].aIndex + xinc;
00565 if ((xi < 0) || (xi >= aDim))
00566 if ( ! aPeriodic ) continue;
00567
00568 if (neighbor_ids)
00569 neighbor_ids[n]=this->pid(xi,yi,zi);
00570 if ( transform_ids )
00571 {
00572 int xt = 0; if ( xi < 0 ) xt = -1; if ( xi >= aDim ) xt = 1;
00573 int yt = 0; if ( yi < 0 ) yt = -1; if ( yi >= bDim ) yt = 1;
00574 int zt = 0; if ( zi < 0 ) zt = -1; if ( zi >= cDim ) zt = 1;
00575 transform_ids[n] = Lattice::index(xt,yt,zt);
00576 }
00577 n++;
00578 }
00579 }
00580 }
00581 DebugM(3,"Patch " << pid << " has " << n << " upstream neighbors.\n");
00582 return n;
00583 }
00584
00585
00586 void PatchMap::printPatchMap(void)
00587 {
00588 CkPrintf("---------------------------------------");
00589 CkPrintf("---------------------------------------\n");
00590
00591 CkPrintf("nPatches = %d\n",nPatches);
00592 for(int i=0;i<nPatches;i++)
00593 {
00594 CkPrintf("Patch %d:\n",i);
00595 CkPrintf(" node = %d\n",patchData[i].node);
00596 CkPrintf(" xi,yi,zi = %d, %d, %d\n",
00597 patchData[i].aIndex,patchData[i].bIndex,patchData[i].cIndex);
00598 CkPrintf(" x0,y0,z0 = %f, %f, %f\n",
00599 patchData[i].aMin,patchData[i].bMin,patchData[i].cMin);
00600 CkPrintf(" x1,y1,z1 = %f, %f, %f\n",
00601 patchData[i].aMax,patchData[i].bMax,patchData[i].cMax);
00602 CkPrintf(" numCids = %d\n",patchData[i].numCids);
00603 CkPrintf(" numCidsAllocated = %d\n",patchData[i].numCidsAllocated);
00604 for(int j=0; j < patchData[i].numCids; j++)
00605 {
00606 CkPrintf(" %10d ",patchData[i].cids[j]);
00607 if (!((j+1) % 6))
00608 CkPrintf("\n");
00609 }
00610 CkPrintf("\n---------------------------------------");
00611 CkPrintf("---------------------------------------\n");
00612 }
00613
00614 }
00615
00616
00617 void PatchMap::registerPatch(PatchID pid, HomePatch *pptr) {
00618 registerPatch(pid,(Patch*)pptr);
00619 if (patchData[pid].myHomePatch != 0) {
00620 iout << iPE << iERRORF
00621 << "homePatchID("<<pid<<") is being re-registered!\n" << endi;
00622 }
00623 patchData[pid].myHomePatch = pptr;
00624 }
00625
00626
00627 void PatchMap::unregisterPatch(PatchID pid, HomePatch *pptr) {
00628 unregisterPatch(pid,(Patch*)pptr);
00629 if (pptr == patchData[pid].myHomePatch) {
00630 DebugM(4, "UnregisterHomePatch("<<pid<<") at " << pptr << "\n");
00631 patchData[pid].myHomePatch = NULL;
00632 }
00633 }
00634
00635
00636 void PatchMap::registerPatch(PatchID pid, Patch *pptr)
00637 {
00638 if (patchData[pid].myPatch != 0) {
00639 iout << iPE << iERRORF
00640 << "patchID("<<pid<<") is being re-registered!\n" << endi;
00641 }
00642 patchData[pid].myPatch = pptr;
00643 }
00644
00645
00646 void PatchMap::unregisterPatch(PatchID pid, Patch *pptr)
00647 {
00648 if (pptr == patchData[pid].myPatch) {
00649 DebugM(4, "UnregisterPatch("<<pid<<") at " << pptr << "\n");
00650 patchData[pid].myPatch = NULL;
00651 }
00652 }
00653
00654
00655 HomePatch *PatchMap::homePatch(PatchID pid)
00656 {
00657 return patchData[pid].myHomePatch;
00658 }
00659