MsmBlock Class Reference

Inheritance diagram for MsmBlock:

MsmBlockKernel< Vtype, Mtype > List of all members.

Public Member Functions

 MsmBlock (int level)
 MsmBlock (CkMigrateMessage *m)
void setupSections ()
void sumReducedPotential (CkReductionMsg *msg)
void addCharge (GridMsg *)
void restriction ()
void sendUpCharge ()
void gridCutoff ()
void addPotential (GridMsg *)
void prolongation ()
void sendDownPotential ()
void sendPatch ()

Public Attributes

CProxySection_MsmGridCutoff msmGridCutoffBroadcast
CProxySection_MsmGridCutoff msmGridCutoffReduction

Detailed Description

Definition at line 3071 of file ComputeMsm.C.


Constructor & Destructor Documentation

MsmBlock::MsmBlock ( int  level  )  [inline]

Definition at line 3079 of file ComputeMsm.C.

References msm::Map::gc, msm::Map::grespro, MsmBlockKernel< Vtype, Mtype >::map, and MsmBlockKernel< Vtype, Mtype >::setupStencils().

03079                         :
03080       MsmBlockKernel<Float,Float>(
03081           msm::BlockIndex(level,
03082             msm::Ivec(thisIndex.x, thisIndex.y, thisIndex.z))
03083           )
03084     {
03085 #ifndef MSM_GRID_CUTOFF_DECOMP
03086       setupStencils(&(map->grespro), &(map->grespro), &(map->gc[level]));
03087 #else
03088       setupStencils(&(map->grespro), &(map->grespro));
03089 #endif
03090     }
    MsmBlock(CkMigrateMessage *m) : MsmBlockKernel<Float,Float>(m) { }

MsmBlock::MsmBlock ( CkMigrateMessage *  m  )  [inline]

Definition at line 3091 of file ComputeMsm.C.


Member Function Documentation

void MsmBlock::addCharge ( GridMsg  ) 

Definition at line 3200 of file ComputeMsm.C.

References MsmBlockKernel< Vtype, Mtype >::bd, MsmBlockKernel< Vtype, Mtype >::blockIndex, MsmBlockKernel< Vtype, Mtype >::cntRecvsCharge, MsmTimer::COMM, GridMsg::get(), gridCutoff(), msm::BlockIndex::level, MsmBlockKernel< Vtype, Mtype >::mgrLocal, ComputeMsmMgr::numLevels(), msm::BlockDiagram::numRecvsCharge, MsmBlockKernel< Vtype, Mtype >::qh, restriction(), MsmBlockKernel< Vtype, Mtype >::sequence, and MsmBlockKernel< Vtype, Mtype >::subgrid.

Referenced by sendUpCharge().

03201 {
03202 #ifdef MSM_TIMING
03203   double startTime, stopTime;
03204   startTime = CkWallTimer();
03205 #endif
03206   int pid;
03207   gm->get(subgrid, pid, sequence);
03208   delete gm;
03209   qh += subgrid;
03210 #ifdef MSM_TIMING
03211   stopTime = CkWallTimer();
03212   mgrLocal->msmTiming[MsmTimer::COMM] += stopTime - startTime;
03213 #endif
03214   if (++cntRecvsCharge == bd->numRecvsCharge) {
03215     int nlevels = mgrLocal->numLevels();
03216     if (blockIndex.level < nlevels-1) {
03217       restriction();
03218     }
03219     gridCutoff();
03220   }
03221 } // MsmBlock::addCharge()

void MsmBlock::addPotential ( GridMsg  ) 

Definition at line 3351 of file ComputeMsm.C.

References MsmBlockKernel< Vtype, Mtype >::bd, MsmBlockKernel< Vtype, Mtype >::blockIndex, MsmBlockKernel< Vtype, Mtype >::cntRecvsPotential, MsmTimer::COMM, MsmBlockKernel< Vtype, Mtype >::eh, GridMsg::get(), msm::BlockIndex::level, MsmBlockKernel< Vtype, Mtype >::mgrLocal, msm::BlockDiagram::numRecvsPotential, prolongation(), sendPatch(), and MsmBlockKernel< Vtype, Mtype >::subgrid.

Referenced by sendDownPotential(), and sumReducedPotential().

03352 {
03353 #ifdef MSM_TIMING
03354   double startTime, stopTime;
03355   startTime = CkWallTimer();
03356 #endif
03357   int pid;
03358   int pseq;
03359   gm->get(subgrid, pid, pseq);  // receive sender's level
03360   delete gm;
03361   eh += subgrid;
03362 #ifdef MSM_TIMING
03363   stopTime = CkWallTimer();
03364   mgrLocal->msmTiming[MsmTimer::COMM] += stopTime - startTime;
03365 #endif
03366   if (++cntRecvsPotential == bd->numRecvsPotential) {
03367     if (blockIndex.level > 0) {
03368       prolongation();
03369     }
03370     else {
03371       sendPatch();
03372     }
03373   }
03374 } // MsmBlock::addPotential()

void MsmBlock::gridCutoff (  ) 

Definition at line 3259 of file ComputeMsm.C.

References MsmBlockKernel< Vtype, Mtype >::bd, MsmBlockKernel< Vtype, Mtype >::blockIndex, MsmTimer::COMM, msm::Grid< T >::data(), msm::BlockDiagram::indexGridCutoff, msm::BlockIndex::level, MsmBlockKernel< Vtype, Mtype >::mgrLocal, MSM_PRIORITY, MSM_TIMING, ComputeMsmMgr::msmGridCutoff, msmGridCutoffBroadcast, msm::BlockIndex::n, ComputeMsmMgr::nlevels, GridMsg::put(), MsmBlockKernel< Vtype, Mtype >::qh, MsmBlockKernel< Vtype, Mtype >::sequence, and SET_PRIORITY.

Referenced by addCharge().

03260 {
03261 #ifdef DEBUG_MSM_GRID
03262   printf("MsmBlock level=%d, id=%d %d %d:  grid cutoff\n",
03263       blockIndex.level, blockIndex.n.i, blockIndex.n.j, blockIndex.n.k);
03264 #endif
03265 #ifndef MSM_GRID_CUTOFF_DECOMP
03266   gridCutoffKernel();
03267   sendAcrossPotential();
03268 #else // MSM_GRID_CUTOFF_DECOMP
03269 
03270   // send charge block to MsmGridCutoff compute objects
03271 #ifdef MSM_TIMING
03272   double startTime, stopTime;
03273   startTime = CkWallTimer();
03274 #endif
03275   int priority = mgrLocal->nlevels + 2*(mgrLocal->nlevels - blockIndex.level)-1;
03276   int msgsz = qh.data().len() * sizeof(Float);
03277   int len = bd->indexGridCutoff.len();
03278 
03279 #if 0
03280   // send charge message to each MsmGridCutoff compute element in list
03281   for (int n = 0;  n < len;  n++) {
03282 #ifdef MSM_TIMING
03283     startTime = CkWallTimer();
03284 #endif
03285     int index = bd->indexGridCutoff[n];
03286     GridMsg *gm = new(msgsz, sizeof(int)) GridMsg;
03287     SET_PRIORITY(gm, sequence, MSM_PRIORITY + priority);
03288     gm->put(qh, blockIndex.level, sequence);  // send my level
03289 #ifdef MSM_TIMING
03290     stopTime = CkWallTimer();
03291     mgrLocal->msmTiming[MsmTimer::COMM] += stopTime - startTime;
03292 #endif
03293     mgrLocal->msmGridCutoff[index].compute(gm);
03294   }
03295 #else
03296 
03297   // broadcast charge message to section
03298   GridMsg *gm = new(msgsz, sizeof(int)) GridMsg;
03299   SET_PRIORITY(gm, sequence, MSM_PRIORITY + priority);
03300   gm->put(qh, blockIndex.level, sequence);  // send my level
03301   msmGridCutoffBroadcast.compute(gm);
03302 #ifdef MSM_TIMING
03303   stopTime = CkWallTimer();
03304   mgrLocal->msmTiming[MsmTimer::COMM] += stopTime - startTime;
03305 #endif
03306 
03307 #endif // 0
03308 
03309 #endif // MSM_GRID_CUTOFF_DECOMP
03310 
03311 } // MsmBlock::gridCutoff()

void MsmBlock::prolongation (  )  [inline]

Definition at line 3131 of file ComputeMsm.C.

References MsmBlockKernel< Vtype, Mtype >::prolongationKernel(), and sendDownPotential().

Referenced by addPotential().

03131                         {
03132       prolongationKernel();
03133       sendDownPotential();
03134     }

void MsmBlock::restriction (  )  [inline]

Definition at line 3119 of file ComputeMsm.C.

References MsmBlockKernel< Vtype, Mtype >::restrictionKernel(), and sendUpCharge().

Referenced by addCharge().

03119                        {
03120       restrictionKernel();
03121       sendUpCharge();
03122     }

void MsmBlock::sendDownPotential (  ) 

Definition at line 3377 of file ComputeMsm.C.

References addPotential(), ASSERT, MsmBlockKernel< Vtype, Mtype >::bd, MsmBlockKernel< Vtype, Mtype >::blockIndex, MsmTimer::COMM, MsmBlockKernel< Vtype, Mtype >::ehProlongated, msm::Grid< T >::extract(), MsmBlockKernel< Vtype, Mtype >::init(), msm::Grid< T >::init(), msm::BlockIndex::level, MsmBlockKernel< Vtype, Mtype >::mgrLocal, MSM_PRIORITY, ComputeMsmMgr::msmBlock, msm::BlockIndex::n, ComputeMsmMgr::nlevels, msm::IndexRange::nn(), GridMsg::put(), msm::BlockDiagram::sendDown, MsmBlockKernel< Vtype, Mtype >::sequence, SET_PRIORITY, MsmBlockKernel< Vtype, Mtype >::subgrid, and msm::Grid< T >::updateLower().

Referenced by prolongation().

03378 {
03379 #ifdef MSM_TIMING
03380   double startTime, stopTime;
03381   startTime = CkWallTimer();
03382 #endif
03383   int lnext = blockIndex.level - 1;
03384   int priority = mgrLocal->nlevels + 2*(mgrLocal->nlevels - blockIndex.level);
03385   // buffer portions of grid to send to Blocks on next level
03386   for (int n = 0;  n < bd->sendDown.len();  n++) {
03387     // initialize the proper subgrid indexing range
03388     subgrid.init( bd->sendDown[n].nrange );
03389     // extract the values from the larger grid into the subgrid
03390     ehProlongated.extract(subgrid);
03391     // translate the subgrid indexing range to match the MSM block
03392     subgrid.updateLower( bd->sendDown[n].nrange_wrap.lower() );
03393     // add the subgrid charges into the block
03394     msm::BlockIndex& bindex = bd->sendDown[n].nblock_wrap;
03395     ASSERT(bindex.level == lnext);
03396     // place subgrid into message
03397     int msgsz = subgrid.nn() * sizeof(Float);
03398     GridMsg *gm = new(msgsz, sizeof(int)) GridMsg;
03399     SET_PRIORITY(gm, sequence, MSM_PRIORITY + priority);
03400     gm->put(subgrid, blockIndex.level, sequence);  // send my level
03401     // lookup in ComputeMsmMgr proxy array by level
03402     mgrLocal->msmBlock[lnext](
03403         bindex.n.i, bindex.n.j, bindex.n.k).addPotential(gm);
03404   } // for
03405 #ifdef MSM_TIMING
03406   stopTime = CkWallTimer();
03407   mgrLocal->msmTiming[MsmTimer::COMM] += stopTime - startTime;
03408   mgrLocal->doneTiming();
03409 #endif
03410   init();  // reinitialize for next computation
03411 } // MsmBlock::sendDownPotential()

void MsmBlock::sendPatch (  ) 

Definition at line 3414 of file ComputeMsm.C.

References ASSERT, MsmBlockKernel< Vtype, Mtype >::bd, MsmBlockKernel< Vtype, Mtype >::blockIndex, MsmTimer::COMM, MsmBlockKernel< Vtype, Mtype >::eh, msm::Grid< T >::extract(), MsmBlockKernel< Vtype, Mtype >::init(), msm::Grid< T >::init(), msm::BlockIndex::level, MsmBlockKernel< Vtype, Mtype >::mgrLocal, MsmBlockKernel< Vtype, Mtype >::mgrProxy, MSM_PRIORITY, ComputeMsmMgr::nlevels, msm::IndexRange::nn(), PatchMap::node(), PatchMap::Object(), GridMsg::put(), msm::BlockDiagram::sendPatch, MsmBlockKernel< Vtype, Mtype >::sequence, SET_PRIORITY, MsmBlockKernel< Vtype, Mtype >::subgrid, and msm::Grid< T >::updateLower().

Referenced by addPotential().

03415 {
03416 #ifdef MSM_TIMING
03417   double startTime, stopTime;
03418   startTime = CkWallTimer();
03419 #endif
03420   int lnext = blockIndex.level;
03421   int priority = mgrLocal->nlevels + 2*(mgrLocal->nlevels - blockIndex.level);
03422   ASSERT(lnext == 0);
03423   // buffer portions of grid to send to Blocks on next level
03424   for (int n = 0;  n < bd->sendPatch.len();  n++) {
03425     // initialize the proper subgrid indexing range
03426     subgrid.init( bd->sendPatch[n].nrange );
03427     // extract the values from the larger grid into the subgrid
03428     eh.extract(subgrid);
03429     // translate the subgrid indexing range to match the MSM block
03430     subgrid.updateLower( bd->sendPatch[n].nrange_unwrap.lower() );
03431     // add the subgrid charges into the block, need its patch ID
03432     int pid = bd->sendPatch[n].patchID;
03433     // place subgrid into message
03434     int msgsz = subgrid.nn() * sizeof(Float);
03435     GridMsg *gm = new(msgsz, sizeof(int)) GridMsg;
03436     SET_PRIORITY(gm, sequence, MSM_PRIORITY + priority);
03437     gm->put(subgrid, pid, sequence);  // send patch ID
03438     // lookup which PE has this patch
03439     PatchMap *pm = PatchMap::Object();
03440     int pe = pm->node(pid);
03441     mgrProxy[pe].addPotential(gm);
03442   }
03443 #ifdef MSM_TIMING
03444   stopTime = CkWallTimer();
03445   mgrLocal->msmTiming[MsmTimer::COMM] += stopTime - startTime;
03446   mgrLocal->doneTiming();
03447 #endif
03448   init();  // reinitialize for next computation
03449 } // MsmBlock::sendPatch()

void MsmBlock::sendUpCharge (  ) 

Definition at line 3224 of file ComputeMsm.C.

References addCharge(), ASSERT, MsmBlockKernel< Vtype, Mtype >::bd, MsmBlockKernel< Vtype, Mtype >::blockIndex, MsmTimer::COMM, msm::Grid< T >::extract(), msm::Grid< T >::init(), msm::BlockIndex::level, MsmBlockKernel< Vtype, Mtype >::mgrLocal, MSM_PRIORITY, ComputeMsmMgr::msmBlock, msm::BlockIndex::n, msm::IndexRange::nn(), GridMsg::put(), MsmBlockKernel< Vtype, Mtype >::qhRestricted, msm::BlockDiagram::sendUp, MsmBlockKernel< Vtype, Mtype >::sequence, SET_PRIORITY, MsmBlockKernel< Vtype, Mtype >::subgrid, and msm::Grid< T >::updateLower().

Referenced by restriction().

03225 {
03226 #ifdef MSM_TIMING
03227   double startTime, stopTime;
03228   startTime = CkWallTimer();
03229 #endif
03230   int lnext = blockIndex.level + 1;
03231   // buffer portions of grid to send to Blocks on next level
03232   for (int n = 0;  n < bd->sendUp.len();  n++) {
03233     // initialize the proper subgrid indexing range
03234     subgrid.init( bd->sendUp[n].nrange );
03235     // extract the values from the larger grid into the subgrid
03236     qhRestricted.extract(subgrid);
03237     // translate the subgrid indexing range to match the MSM block
03238     subgrid.updateLower( bd->sendUp[n].nrange_wrap.lower() );
03239     // add the subgrid charges into the block
03240     msm::BlockIndex& bindex = bd->sendUp[n].nblock_wrap;
03241     ASSERT(bindex.level == lnext);
03242     // place subgrid into message
03243     // SET MESSAGE PRIORITY
03244     int msgsz = subgrid.nn() * sizeof(Float);
03245     GridMsg *gm = new(msgsz, sizeof(int)) GridMsg;
03246     SET_PRIORITY(gm, sequence, MSM_PRIORITY + lnext);
03247     gm->put(subgrid, blockIndex.level, sequence);  // send my level
03248     // lookup in ComputeMsmMgr proxy array by level
03249     mgrLocal->msmBlock[lnext](
03250         bindex.n.i, bindex.n.j, bindex.n.k).addCharge(gm);
03251   } // for
03252 #ifdef MSM_TIMING
03253   stopTime = CkWallTimer();
03254   mgrLocal->msmTiming[MsmTimer::COMM] += stopTime - startTime;
03255 #endif
03256 } // MsmBlock::sendUpCharge()

void MsmBlock::setupSections (  ) 

Definition at line 3140 of file ComputeMsm.C.

References MsmBlockKernel< Vtype, Mtype >::bd, MsmBlockKernel< Vtype, Mtype >::blockIndex, DEBUG_MSM_GRID, msm::BlockDiagram::indexGridCutoff, msm::BlockIndex::level, MsmBlockKernel< Vtype, Mtype >::mgrLocal, ComputeMsmMgr::msmGridCutoff, msmGridCutoffBroadcast, msmGridCutoffReduction, MsmGridCutoffSetupMsg::put(), and msm::BlockDiagram::recvGridCutoff.

03141 {
03142 #ifdef DEBUG_MSM_GRID
03143   CkPrintf("LEVEL %d MSM BLOCK (%d,%d,%d):  "
03144       "creating broadcast section on PE %d\n",
03145       blockIndex.level, thisIndex.x, thisIndex.y, thisIndex.z, CkMyPe());
03146 #endif
03147   CkVec<CkArrayIndex1D> elems;
03148   for (int n = 0;  n < bd->indexGridCutoff.len();  n++) {
03149     elems.push_back(CkArrayIndex1D( bd->indexGridCutoff[n] ));
03150   }
03151   msmGridCutoffBroadcast = CProxySection_MsmGridCutoff::ckNew(
03152       mgrLocal->msmGridCutoff, elems.getVec(), elems.size()
03153       );
03154   CProxy_CkMulticastMgr mcastProxy = CkpvAccess(BOCclass_group).multicastMgr;
03155   CkMulticastMgr *mcastPtr = CProxy_CkMulticastMgr(mcastProxy).ckLocalBranch();
03156   msmGridCutoffBroadcast.ckSectionDelegate(mcastPtr);
03157   
03158 #ifdef DEBUG_MSM_GRID
03159   char s[1024];
03160   sprintf(s, "LEVEL %d MSM BLOCK (%d,%d,%d):  "
03161       "creating reduction section on PE %d\n",
03162       blockIndex.level, thisIndex.x, thisIndex.y, thisIndex.z, CkMyPe());
03163 #endif
03164   CkVec<CkArrayIndex1D> elems2;
03165 #ifdef DEBUG_MSM_GRID
03166   strcat(s, "receiving from MsmGridCutoff ID:");
03167 #endif
03168   for (int n = 0;  n < bd->recvGridCutoff.len();  n++) {
03169 #ifdef DEBUG_MSM_GRID
03170     char t[20];
03171     sprintf(t, "  %d", bd->recvGridCutoff[n]);
03172     strcat(s, t);
03173 #endif
03174     elems2.push_back(CkArrayIndex1D( bd->recvGridCutoff[n] ));
03175   }
03176 #ifdef DEBUG_MSM_GRID
03177   strcat(s, "\n");
03178   CkPrintf(s);
03179 #endif
03180   msmGridCutoffReduction = CProxySection_MsmGridCutoff::ckNew(
03181       mgrLocal->msmGridCutoff, elems2.getVec(), elems2.size()
03182       );
03183   msmGridCutoffReduction.ckSectionDelegate(mcastPtr);
03184   MsmGridCutoffSetupMsg *msg = new MsmGridCutoffSetupMsg;
03185   CProxyElement_MsmBlock thisElementProxy = thisProxy(thisIndex);
03186   msg->put(&thisElementProxy);
03187 
03188   msmGridCutoffReduction.setupSections(msg);  // broadcast to entire section
03189 
03190   /* XXX alternatively, setup default reduction client
03191    *
03192   mcastPtr->setReductionClient(msmGridCutoffReduction,
03193       new CkCallback(CkIndex_MsmBlock::myReductionEntry(NULL),
03194         thisElementProxy));
03195    *
03196    */
03197 }

void MsmBlock::sumReducedPotential ( CkReductionMsg *  msg  )  [inline]

Definition at line 3095 of file ComputeMsm.C.

References addPotential(), MsmBlockKernel< Vtype, Mtype >::blockIndex, MsmTimer::COMM, msm::Grid< T >::data(), MsmBlockKernel< Vtype, Mtype >::eh, msm::Grid< T >::init(), msm::BlockIndex::level, MsmBlockKernel< Vtype, Mtype >::mgrLocal, MSM_PRIORITY, ComputeMsmMgr::nlevels, GridMsg::put(), MsmBlockKernel< Vtype, Mtype >::sequence, and SET_PRIORITY.

03095                                                   {
03096 #ifdef MSM_TIMING
03097       double startTime, stopTime;
03098       startTime = CkWallTimer();
03099 #endif
03100       msm::Grid<Float> ehfull;
03101       ehfull.init( msm::IndexRange(eh) );
03102       memcpy(ehfull.data().buffer(), msg->getData(), msg->getSize());
03103       delete msg;
03104       int priority = mgrLocal->nlevels
03105         + 2*(mgrLocal->nlevels - blockIndex.level)-1;
03106       int msgsz = ehfull.data().len() * sizeof(Float);
03107       GridMsg *gm = new(msgsz, sizeof(int)) GridMsg;
03108       SET_PRIORITY(gm, sequence, MSM_PRIORITY + priority);
03109       gm->put(ehfull, blockIndex.level, sequence);  // send my level
03110 #ifdef MSM_TIMING
03111       stopTime = CkWallTimer();
03112       mgrLocal->msmTiming[MsmTimer::COMM] += stopTime - startTime;
03113 #endif
03114       addPotential(gm);
03115     }


Member Data Documentation

CProxySection_MsmGridCutoff MsmBlock::msmGridCutoffBroadcast

Definition at line 3076 of file ComputeMsm.C.

Referenced by gridCutoff(), and setupSections().

CProxySection_MsmGridCutoff MsmBlock::msmGridCutoffReduction

Definition at line 3077 of file ComputeMsm.C.

Referenced by setupSections().


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