PmeXPencil Class Reference

Inheritance diagram for PmeXPencil:

PmePencil< CBase_PmeXPencil > CBase_PmeXPencil List of all members.

Public Member Functions

PmeXPencil_SDAG_CODE PmeXPencil ()
 PmeXPencil (CkMigrateMessage *)
 ~PmeXPencil ()
void fft_init ()
void recv_trans (const PmeTransMsg *)
void forward_fft ()
void pme_kspace ()
void backward_fft ()
void send_untrans ()
void send_subset_untrans (int fromIdx, int toIdx, int evirIdx)
void node_process_trans (PmeTransMsg *)
void evir_init ()

Public Attributes

fftw_plan forward_plan
fftw_plan backward_plan
int ny
int nz
int recipEvirPe
PmeKSpacemyKSpace

Detailed Description

Definition at line 4703 of file ComputePme.C.


Constructor & Destructor Documentation

PmeXPencil_SDAG_CODE PmeXPencil::PmeXPencil (  )  [inline]

Definition at line 4706 of file ComputePme.C.

References PmePencil< CBase_PmeXPencil >::imsg, PmePencil< CBase_PmeXPencil >::imsgb, myKSpace, and recipEvirPe.

04706 { __sdag_init();  myKSpace = 0; setMigratable(false); imsg=imsgb=0; recipEvirPe = -999; }

PmeXPencil::PmeXPencil ( CkMigrateMessage *   )  [inline]

Definition at line 4707 of file ComputePme.C.

04707 { __sdag_init(); }

PmeXPencil::~PmeXPencil (  )  [inline]

Definition at line 4708 of file ComputePme.C.

04708                       {
04709         #ifdef NAMD_FFTW
04710         #ifdef NAMD_FFTW_3
04711                 delete [] forward_plans;
04712                 delete [] backward_plans;
04713         #endif
04714         #endif
04715         }


Member Function Documentation

void PmeXPencil::backward_fft (  ) 

Definition at line 5709 of file ComputePme.C.

References backward_plan, CKLOOP_CTRL_PME_BACKWARDFFT, PmePencil< CBase_PmeXPencil >::data, PmePencilInitMsgData::grid, PmePencil< CBase_PmeXPencil >::initdata, PmeGrid::K1, Node::Object(), PmeXZPencilFFT(), Node::simParameters, SimParameters::useCkLoop, PmePencil< CBase_PmeXPencil >::work, PmePencilInitMsgData::yBlocks, and PmePencilInitMsgData::zBlocks.

Referenced by node_process_trans().

05709                               {
05710 #ifdef NAMD_FFTW
05711 #ifdef MANUAL_DEBUG_FFTW3
05712   dumpMatrixFloat3("bw_x_b", data, initdata.grid.K1, ny, nz, thisIndex.x, thisIndex.y, thisIndex.z);
05713 #endif
05714 
05715 #ifdef NAMD_FFTW_3
05716 #if     CMK_SMP && USE_CKLOOP
05717   int useCkLoop = Node::Object()->simParameters->useCkLoop;
05718   if(useCkLoop>=CKLOOP_CTRL_PME_BACKWARDFFT
05719      && CkNumPes() >= 2 * initdata.yBlocks * initdata.zBlocks) {
05720           //for(int i=0; i<numPlans; i++) fftwf_execute(backward_plans[i]);
05721           //transform the above loop
05722           CkLoop_Parallelize(PmeXZPencilFFT, 1, (void *)backward_plans, CkMyNodeSize(), 0, numPlans-1); //sync
05723           return;
05724   }
05725 #endif
05726   fftwf_execute(backward_plan);
05727 #else
05728   fftw(backward_plan, ny*nz,
05729         ((fftw_complex *) data), ny*nz, 1, (fftw_complex *) work, 1, 0);
05730 #endif
05731 #ifdef MANUAL_DEBUG_FFTW3
05732   dumpMatrixFloat3("bw_x_a", data, initdata.grid.K1, ny, nz, thisIndex.x, thisIndex.y, thisIndex.z);
05733 #endif
05734 #endif
05735 }

void PmeXPencil::evir_init (  ) 

Definition at line 4761 of file ComputePme.C.

References findRecipEvirPe(), PmePencil< CBase_PmeXPencil >::initdata, PmePencilInitMsgData::pmeProxy, and recipEvirPe.

04761                            {
04762   recipEvirPe = findRecipEvirPe();
04763   initdata.pmeProxy[recipEvirPe].addRecipEvirClient();
04764 }

void PmeXPencil::fft_init (  ) 

Definition at line 5032 of file ComputePme.C.

References backward_plan, PmeGrid::block2, PmeGrid::block3, PmePencil< CBase_PmeXPencil >::data, PmeGrid::dim3, fftwf_malloc, forward_plan, PmePencilInitMsgData::grid, PmePencil< CBase_PmeXPencil >::initdata, PmeGrid::K1, PmeGrid::K2, myKSpace, NAMD_die(), PmePencil< CBase_PmeXPencil >::order_init(), PmePencilInitMsgData::pmeNodeProxy, Node::simParameters, simParams, PmePencil< CBase_PmeXPencil >::work, and PmePencilInitMsgData::xBlocks.

05032                           {
05033   CProxy_Node nd(CkpvAccess(BOCclass_group).node);
05034   Node *node = nd.ckLocalBranch();
05035   SimParameters *simParams = node->simParameters;
05036 #if USE_NODE_PAR_RECEIVE
05037   ((NodePmeMgr *)CkLocalNodeBranch(initdata.pmeNodeProxy))->registerXPencil(thisIndex,this);
05038 #endif
05039 
05040   int K1 = initdata.grid.K1;
05041   int K2 = initdata.grid.K2;
05042   int dim3 = initdata.grid.dim3;
05043   int block2 = initdata.grid.block2;
05044   int block3 = initdata.grid.block3;
05045 
05046   ny = block2;
05047   if ( (thisIndex.y + 1) * block2 > K2 ) ny = K2 - thisIndex.y * block2;
05048   nz = block3;
05049   if ( (thisIndex.z+1)*block3 > dim3/2 ) nz = dim3/2 - thisIndex.z*block3;
05050 
05051 #ifdef NAMD_FFTW
05052   CmiLock(ComputePmeMgr::fftw_plan_lock);
05053 
05054   data = (float *) fftwf_malloc( sizeof(float) * K1*ny*nz*2);
05055   work = new float[2*K1];
05056 
05057   order_init(initdata.xBlocks);
05058 
05059 #ifdef NAMD_FFTW_3
05060   /* need array of sizes for the how many */
05061   int fftwFlags = simParams->FFTWPatient ? FFTW_PATIENT  : simParams->FFTWEstimate ? FFTW_ESTIMATE  : FFTW_MEASURE ;
05062   int sizeLines=ny*nz;
05063   int planLineSizes[1];
05064   planLineSizes[0]=K1;
05065   forward_plan = fftwf_plan_many_dft(1, planLineSizes, sizeLines,
05066                                      (fftwf_complex *) data, NULL, sizeLines, 1,
05067                                      (fftwf_complex *) data, NULL, sizeLines, 1,
05068                                    FFTW_FORWARD,
05069                                      fftwFlags);
05070   backward_plan = fftwf_plan_many_dft(1, planLineSizes, sizeLines,
05071                                      (fftwf_complex *) data, NULL, sizeLines, 1,
05072                                      (fftwf_complex *) data, NULL, sizeLines, 1,
05073                                           FFTW_BACKWARD,
05074                                       fftwFlags);
05075 
05076 #if     CMK_SMP && USE_CKLOOP
05077   if(simParams->useCkLoop) {
05078           //How many FFT plans to be created? The grain-size issue!!.
05079           //Currently, I am choosing the min(nx, ny) to be coarse-grain
05080           numPlans = (ny<=nz?ny:nz);
05081           // limit attempted parallelism due to false sharing
05082           //if ( numPlans < CkMyNodeSize() ) numPlans = (ny>=nz?ny:nz);
05083           //if ( numPlans < CkMyNodeSize() ) numPlans = sizeLines;
05084           if ( sizeLines/numPlans < 4 ) numPlans = 1;
05085           int howmany = sizeLines/numPlans;
05086           forward_plans = new fftwf_plan[numPlans];
05087           backward_plans = new fftwf_plan[numPlans];
05088           for(int i=0; i<numPlans; i++) {
05089                   int curStride = i*howmany;              
05090                   forward_plans[i] = fftwf_plan_many_dft(1, planLineSizes, howmany,
05091                                                                                                          ((fftwf_complex *)data)+curStride, NULL, sizeLines, 1,
05092                                                                                                          ((fftwf_complex *)data)+curStride, NULL, sizeLines, 1,
05093                                                                                                         FFTW_FORWARD,
05094                                                                                                          fftwFlags);
05095 
05096                   backward_plans[i] = fftwf_plan_many_dft(1, planLineSizes, howmany,
05097                                                                                                          ((fftwf_complex *)data)+curStride, NULL, sizeLines, 1,
05098                                                                                                          ((fftwf_complex *)data)+curStride, NULL, sizeLines, 1,
05099                                                                                                           FFTW_BACKWARD,
05100                                                                                                          fftwFlags);
05101           }
05102   }else
05103 #endif
05104   {
05105           forward_plans = NULL;
05106           backward_plans = NULL;
05107   }
05108 #else
05109   forward_plan = fftw_create_plan_specific(K1, FFTW_FORWARD,
05110         ( simParams->FFTWEstimate ? FFTW_ESTIMATE : FFTW_MEASURE )
05111         | FFTW_IN_PLACE | FFTW_USE_WISDOM, (fftw_complex *) data,
05112         ny*nz, (fftw_complex *) work, 1);
05113   backward_plan = fftw_create_plan_specific(K1, FFTW_BACKWARD,
05114         ( simParams->FFTWEstimate ? FFTW_ESTIMATE : FFTW_MEASURE )
05115         | FFTW_IN_PLACE | FFTW_USE_WISDOM, (fftw_complex *) data,
05116         ny*nz, (fftw_complex *) work, 1);
05117 #endif
05118   CmiUnlock(ComputePmeMgr::fftw_plan_lock);
05119 #else
05120   NAMD_die("Sorry, FFTW must be compiled in to use PME.");
05121 #endif
05122 
05123   myKSpace = new PmeKSpace(initdata.grid,
05124                 thisIndex.y*block2, thisIndex.y*block2 + ny,
05125                 thisIndex.z*block3, thisIndex.z*block3 + nz);
05126 
05127 }

void PmeXPencil::forward_fft (  ) 

Definition at line 5650 of file ComputePme.C.

References CKLOOP_CTRL_PME_FORWARDFFT, PmePencil< CBase_PmeXPencil >::data, forward_plan, PmePencilInitMsgData::grid, PmePencil< CBase_PmeXPencil >::initdata, PmeGrid::K1, Node::Object(), PmeXZPencilFFT(), Node::simParameters, SimParameters::useCkLoop, PmePencil< CBase_PmeXPencil >::work, PmePencilInitMsgData::yBlocks, and PmePencilInitMsgData::zBlocks.

Referenced by node_process_trans().

05650                              {
05651 #ifdef NAMD_FFTW
05652 
05653 #ifdef MANUAL_DEBUG_FFTW3
05654   dumpMatrixFloat3("fw_x_b", data, initdata.grid.K1, ny, nz, thisIndex.x, thisIndex.y, thisIndex.z);
05655 #endif
05656 
05657 #ifdef NAMD_FFTW_3
05658 #if     CMK_SMP && USE_CKLOOP
05659   int useCkLoop = Node::Object()->simParameters->useCkLoop;
05660   if(useCkLoop>=CKLOOP_CTRL_PME_FORWARDFFT
05661      && CkNumPes() >= 2 * initdata.yBlocks * initdata.zBlocks) {
05662           //for(int i=0; i<numPlans; i++) fftwf_execute(forward_plans[i]);
05663           //transform the above loop
05664           CkLoop_Parallelize(PmeXZPencilFFT, 1, (void *)forward_plans, CkMyNodeSize(), 0, numPlans-1); //sync
05665           return;
05666   }
05667 #endif
05668   fftwf_execute(forward_plan);
05669 #else
05670   fftw(forward_plan, ny*nz,
05671         ((fftw_complex *) data), ny*nz, 1, (fftw_complex *) work, 1, 0);
05672 #endif
05673 #ifdef MANUAL_DEBUG_FFTW3
05674   dumpMatrixFloat3("fw_x_a", data, initdata.grid.K1, ny, nz, thisIndex.x, thisIndex.y, thisIndex.z);
05675 #endif
05676 
05677 #endif
05678 }

void PmeXPencil::node_process_trans ( PmeTransMsg  ) 

Definition at line 5593 of file ComputePme.C.

References backward_fft(), forward_fft(), PmePencil< CBase_PmeXPencil >::hasData, PmeTransMsg::hasData, PmePencil< CBase_PmeXPencil >::imsg, PmePencil< CBase_PmeXPencil >::initdata, PmePencil< CBase_PmeXPencil >::needs_reply, pme_kspace(), recv_trans(), send_untrans(), PmeTransMsg::sourceNode, and PmePencilInitMsgData::xBlocks.

Referenced by NodePmeMgr::recvXTrans().

05594 {
05595   if(msg->hasData) hasData=1;
05596   needs_reply[msg->sourceNode] = msg->hasData;
05597   recv_trans(msg);
05598   int limsg;
05599   CmiMemoryAtomicFetchAndInc(imsg,limsg);
05600   if(limsg+1 == initdata.xBlocks)
05601     {
05602       if(hasData){
05603         forward_fft();
05604         pme_kspace();
05605         backward_fft();
05606       }
05607       send_untrans();
05608       imsg=0;
05609       CmiMemoryWriteFence();
05610     }
05611 }

void PmeXPencil::pme_kspace (  ) 

Definition at line 5680 of file ComputePme.C.

References CKLOOP_CTRL_PME_KSPACE, PmeKSpace::compute_energy(), PmePencil< CBase_PmeXPencil >::data, PmePencil< CBase_PmeXPencil >::evir, ComputeNonbondedUtil::ewaldcof, PmePencil< CBase_PmeXPencil >::initdata, PmePencil< CBase_PmeXPencil >::lattice, myKSpace, Node::Object(), PmePencilInitMsgData::yBlocks, and PmePencilInitMsgData::zBlocks.

Referenced by node_process_trans().

05680                             {
05681 
05682   evir = 0.;
05683 
05684 #ifdef FFTCHECK
05685   return;
05686 #endif
05687 
05688   BigReal ewaldcof = ComputeNonbondedUtil::ewaldcof;
05689 
05690   int useCkLoop = 0;
05691 #if CMK_SMP && USE_CKLOOP
05692   if ( Node::Object()->simParameters->useCkLoop >= CKLOOP_CTRL_PME_KSPACE
05693        && CkNumPes() >= 2 * initdata.yBlocks * initdata.zBlocks ) {
05694     useCkLoop = 1;
05695   }
05696 #endif
05697 
05698   int numGrids = 1;
05699   for ( int g=0; g<numGrids; ++g ) {
05700     evir[0] = myKSpace->compute_energy(data+0*g,
05701                 lattice, ewaldcof, &(evir[1]), useCkLoop);
05702   }
05703   
05704 #if USE_NODE_PAR_RECEIVE
05705     CmiMemoryWriteFence();
05706 #endif
05707 }

void PmeXPencil::recv_trans ( const PmeTransMsg  ) 

Definition at line 5613 of file ComputePme.C.

References PmeGrid::block1, PmePencil< CBase_PmeXPencil >::data, PmePencilInitMsgData::grid, PmeTransMsg::hasData, PmePencil< CBase_PmeXPencil >::imsg, PmePencil< CBase_PmeXPencil >::initdata, j, PmeGrid::K1, PmeTransMsg::lattice, PmePencil< CBase_PmeXPencil >::lattice, PmeTransMsg::nx, PmeTransMsg::qgrid, PmeTransMsg::sequence, PmePencil< CBase_PmeXPencil >::sequence, and PmeTransMsg::sourceNode.

Referenced by node_process_trans().

05613                                                   {
05614   if ( imsg == 0 ) {
05615     lattice = msg->lattice;
05616     sequence = msg->sequence;
05617   }
05618   int block1 = initdata.grid.block1;
05619   int K1 = initdata.grid.K1;
05620   int ib = msg->sourceNode;
05621   int nx = msg->nx;
05622  if ( msg->hasData ) {
05623   const float *md = msg->qgrid;
05624   for ( int i=ib*block1; i<(ib*block1+nx); ++i ) {
05625    float *d = data + i*ny*nz*2;
05626    for ( int j=0; j<ny; ++j, d += nz*2 ) {
05627     for ( int k=0; k<nz; ++k ) {
05628 #ifdef ZEROCHECK
05629       if ( (*md) == 0. ) CkPrintf("0 in YX at %d %d %d %d %d %d %d %d %d\n",
05630         ib, thisIndex.y, thisIndex.z, i, j, k, nx, ny, nz);
05631 #endif
05632       d[2*k] = *(md++);
05633       d[2*k+1] = *(md++);
05634     }
05635    }
05636   }
05637  } else {
05638   for ( int i=ib*block1; i<(ib*block1+nx); ++i ) {
05639    float *d = data + i*ny*nz*2;
05640    for ( int j=0; j<ny; ++j, d += nz*2 ) {
05641     for ( int k=0; k<nz; ++k ) {
05642       d[2*k] = 0;
05643       d[2*k+1] = 0;
05644     }
05645    }
05646   }
05647  }
05648 }

void PmeXPencil::send_subset_untrans ( int  fromIdx,
int  toIdx,
int  evirIdx 
)

Definition at line 5743 of file ComputePme.C.

References PmeGrid::block1, PmePencil< CBase_PmeXPencil >::data, PmeUntransMsg::destElem, PmePencilInitMsgData::grid, PmePencil< CBase_PmeXPencil >::initdata, j, PmeGrid::K1, PmeUntransMsg::ny, PME_UNTRANS_PRIORITY, PmePencilInitMsgData::pmeNodeProxy, PRIORITY_SIZE, PmeUntransMsg::qgrid, PmePencil< CBase_PmeXPencil >::send_order, PmePencil< CBase_PmeXPencil >::sequence, SET_PRIORITY, PmeUntransMsg::sourceNode, PmePencilInitMsgData::xBlocks, PmePencilInitMsgData::ym, and PmePencilInitMsgData::yPencil.

Referenced by PmeXPencilSendUntrans().

05743                                                                        {
05744         int xBlocks = initdata.xBlocks;
05745         int block1 = initdata.grid.block1;      
05746         int K1 = initdata.grid.K1;
05747 
05748         int ackL=0, ackH=-1;
05749         int unL=0, unH=-1;
05750         int send_evir=0;
05751         if(fromIdx >= evirIdx+1) {
05752                 //send PmeUntransMsg with has_evir=0
05753                 unL = fromIdx;
05754                 unH = toIdx;            
05755         } else if(toIdx <= evirIdx-1) {
05756                 //send PmeAckMsg
05757                 ackL=fromIdx;
05758                 ackH=toIdx;             
05759         } else {
05760                 //partially send PmeAckMsg and partially send PmeUntransMsg
05761                 ackL=fromIdx;
05762                 ackH=evirIdx-1;
05763                 send_evir=1;
05764                 unL=evirIdx+1;
05765                 unH=toIdx;
05766         }
05767 
05768         for(int isend=ackL; isend<=ackH; isend++) {
05769                 //send PmeAckMsg
05770         CmiEnableUrgentSend(1);
05771                 int ib = send_order[isend];
05772                 PmeAckMsg *msg = new (PRIORITY_SIZE) PmeAckMsg;
05773                 SET_PRIORITY(msg,sequence,PME_UNTRANS_PRIORITY)
05774                 initdata.yPencil(ib,0,thisIndex.z).recvAck(msg);
05775         CmiEnableUrgentSend(0);
05776     }
05777 
05778     CmiEnableUrgentSend(1);
05779         //send PmeUntransMsg with has_evir=1
05780         if(send_evir) {
05781                 int ib = send_order[evirIdx];
05782                 int nx = block1;
05783                 if ( (ib+1)*block1 > K1 ) nx = K1 - ib*block1;
05784                 PmeUntransMsg *msg = new (nx*ny*nz*2,PRIORITY_SIZE) PmeUntransMsg;              
05785                 msg->sourceNode = thisIndex.y;
05786                 msg->ny = ny;
05787                 float *md = msg->qgrid;
05788                 for ( int i=ib*block1; i<(ib*block1+nx); ++i ) {
05789                         float *d = data + i*ny*nz*2;
05790                         for ( int j=0; j<ny; ++j, d += nz*2 ) {
05791                                 for ( int k=0; k<nz; ++k ) {
05792                                         *(md++) = d[2*k];
05793                                         *(md++) = d[2*k+1];
05794                                 }
05795                         }
05796                 }
05797                 SET_PRIORITY(msg,sequence,PME_UNTRANS_PRIORITY)
05798 #if USE_NODE_PAR_RECEIVE
05799         msg->destElem=CkArrayIndex3D(ib,0, thisIndex.z);
05800         initdata.pmeNodeProxy[CmiNodeOf(initdata.ym.ckLocalBranch()->procNum(0,msg->destElem))].recvYUntrans(msg);
05801 #else
05802         initdata.yPencil(ib,0,thisIndex.z).recvUntrans(msg);
05803 #endif
05804          }
05805     CmiEnableUrgentSend(0);
05806         
05807         //send PmeUntransMsg with has_evir=0
05808         for(int isend=unL; isend<=unH; isend++) {
05809                 int ib = send_order[isend];
05810                 int nx = block1;
05811                 if ( (ib+1)*block1 > K1 ) nx = K1 - ib*block1;
05812                 PmeUntransMsg *msg = new (nx*ny*nz*2,PRIORITY_SIZE) PmeUntransMsg;
05813                 msg->sourceNode = thisIndex.y;
05814                 msg->ny = ny;
05815                 float *md = msg->qgrid;
05816                 for ( int i=ib*block1; i<(ib*block1+nx); ++i ) {
05817                         float *d = data + i*ny*nz*2;
05818                         for ( int j=0; j<ny; ++j, d += nz*2 ) {
05819                                 for ( int k=0; k<nz; ++k ) {
05820                                         *(md++) = d[2*k];
05821                                         *(md++) = d[2*k+1];
05822                                 }
05823                         }
05824                 }
05825                 SET_PRIORITY(msg,sequence,PME_UNTRANS_PRIORITY)
05826         CmiEnableUrgentSend(1);
05827 #if USE_NODE_PAR_RECEIVE
05828         msg->destElem=CkArrayIndex3D(ib,0, thisIndex.z);
05829 #if Y_PERSIST 
05830         CmiUsePersistentHandle(&untrans_handle[isend], 1);
05831 #endif
05832         initdata.pmeNodeProxy[CmiNodeOf(initdata.ym.ckLocalBranch()->procNum(0,msg->destElem))].recvYUntrans(msg);
05833 #if Y_PERSIST 
05834         CmiUsePersistentHandle(NULL, 0);
05835 #endif
05836 #else
05837 #if Y_PERSIST 
05838   //      CmiUsePersistentHandle(&untrans_handle[isend], 1);
05839 #endif
05840         initdata.yPencil(ib,0,thisIndex.z).recvUntrans(msg);
05841 #if Y_PERSIST 
05842    //     CmiUsePersistentHandle(NULL, 0);
05843 #endif
05844 #endif
05845         CmiEnableUrgentSend(0);
05846         }
05847 }

void PmeXPencil::send_untrans (  ) 

Definition at line 5849 of file ComputePme.C.

References PmeGrid::block1, CKLOOP_CTRL_PME_SENDUNTRANS, PmePencil< CBase_PmeXPencil >::data, PmeUntransMsg::destElem, PmePencil< CBase_PmeXPencil >::evir, PmeEvirMsg::evir, PmePencilInitMsgData::grid, PmePencil< CBase_PmeXPencil >::initdata, j, PmeGrid::K1, PmePencil< CBase_PmeXPencil >::needs_reply, PmeUntransMsg::ny, Node::Object(), PME_UNGRID_PRIORITY, PME_UNTRANS_PRIORITY, PmePencilInitMsgData::pmeNodeProxy, PmePencilInitMsgData::pmeProxy, PmeXPencilSendUntrans(), PRIORITY_SIZE, PmeUntransMsg::qgrid, recipEvirPe, PmePencil< CBase_PmeXPencil >::send_order, PmePencil< CBase_PmeXPencil >::sequence, SET_PRIORITY, Node::simParameters, PmeUntransMsg::sourceNode, SimParameters::useCkLoop, PmePencilInitMsgData::xBlocks, PmePencilInitMsgData::yBlocks, PmePencilInitMsgData::ym, PmePencilInitMsgData::yPencil, and PmePencilInitMsgData::zBlocks.

Referenced by node_process_trans().

05849                               {
05850 
05851   { // send energy and virial
05852     int numGrids = 1;
05853     PmeEvirMsg *newmsg = new (numGrids, PRIORITY_SIZE) PmeEvirMsg;
05854     newmsg->evir[0] = evir;
05855     SET_PRIORITY(newmsg,sequence,PME_UNGRID_PRIORITY)
05856     CmiEnableUrgentSend(1);
05857     initdata.pmeProxy[recipEvirPe].recvRecipEvir(newmsg);
05858     CmiEnableUrgentSend(0);
05859   }
05860 
05861 #if USE_PERSISTENT
05862   if (untrans_handle == NULL) setup_persistent();
05863 #endif
05864 #if     CMK_SMP && USE_CKLOOP
05865   int useCkLoop = Node::Object()->simParameters->useCkLoop;
05866   if(useCkLoop>=CKLOOP_CTRL_PME_SENDUNTRANS
05867      && CkNumPes() >= 2 * initdata.yBlocks * initdata.zBlocks) {
05868                 int xBlocks = initdata.xBlocks;
05869                 int evirIdx = 0;
05870                 for ( int isend=0; isend<xBlocks; ++isend ) {
05871                         int ib = send_order[isend];
05872                         if (needs_reply[ib]) {
05873                                 evirIdx = isend;
05874                                 break;
05875                         }
05876                 }
05877 
05878                 //basically: 
05879                 //[0,evirIdx-1]->send PmeAckMsg
05880                 //evirIdx->send PmeUntransMsg with has_evir=1
05881                 //[evirIdx+1, xBlocks-1]->send PmeUntransMsg with has_evir=0
05882                 //send_subset_untrans(0, xBlocks-1, evirIdx);
05883 #if USE_NODE_PAR_RECEIVE
05884                 //CkLoop_Parallelize(PmeXPencilSendUntrans, evirIdx, (void *)this, CkMyNodeSize(), 0, xBlocks-1, 1); //has to sync
05885                 CkLoop_Parallelize(PmeXPencilSendUntrans, evirIdx, (void *)this, xBlocks, 0, xBlocks-1, 1); //has to sync
05886 #else
05887         //CkLoop_Parallelize(PmeXPencilSendUntrans, evirIdx, (void *)this, CkMyNodeSize(), 0, xBlocks-1, 0); //not sync
05888                 CkLoop_Parallelize(PmeXPencilSendUntrans, evirIdx, (void *)this, xBlocks, 0, xBlocks-1, 0); //not sync
05889 #endif        
05890                 return;
05891   }
05892 #endif
05893   int xBlocks = initdata.xBlocks;
05894   int block1 = initdata.grid.block1;
05895   int K1 = initdata.grid.K1;
05896   int send_evir = 1;
05897   for ( int isend=0; isend<xBlocks; ++isend ) {
05898     int ib = send_order[isend];
05899     if ( ! needs_reply[ib] ) {
05900       PmeAckMsg *msg = new (PRIORITY_SIZE) PmeAckMsg;
05901       CmiEnableUrgentSend(1);
05902       SET_PRIORITY(msg,sequence,PME_UNTRANS_PRIORITY)
05903       initdata.yPencil(ib,0,thisIndex.z).recvAck(msg);
05904       CmiEnableUrgentSend(0);
05905       continue;
05906     }
05907     int nx = block1;
05908     if ( (ib+1)*block1 > K1 ) nx = K1 - ib*block1;
05909     PmeUntransMsg *msg = new (nx*ny*nz*2,PRIORITY_SIZE) PmeUntransMsg;
05910     if ( send_evir ) {
05911       send_evir = 0;
05912     }
05913     msg->sourceNode = thisIndex.y;
05914     msg->ny = ny;
05915     float *md = msg->qgrid;
05916     for ( int i=ib*block1; i<(ib*block1+nx); ++i ) {
05917      float *d = data + i*ny*nz*2;
05918      for ( int j=0; j<ny; ++j, d += nz*2 ) {
05919       for ( int k=0; k<nz; ++k ) {
05920         *(md++) = d[2*k];
05921         *(md++) = d[2*k+1];
05922       }
05923      }
05924     }
05925     SET_PRIORITY(msg,sequence,PME_UNTRANS_PRIORITY)
05926 
05927     CmiEnableUrgentSend(1);
05928 #if USE_NODE_PAR_RECEIVE
05929     msg->destElem=CkArrayIndex3D(ib,0, thisIndex.z);
05930 #if Y_PERSIST 
05931     CmiUsePersistentHandle(&untrans_handle[isend], 1);
05932 #endif
05933     initdata.pmeNodeProxy[CmiNodeOf(initdata.ym.ckLocalBranch()->procNum(0,msg->destElem))].recvYUntrans(msg);
05934 #if Y_PERSIST 
05935     CmiUsePersistentHandle(NULL, 0);
05936 #endif
05937 #else
05938 #if Y_PERSIST 
05939     CmiUsePersistentHandle(&untrans_handle[isend], 1);
05940 #endif
05941     initdata.yPencil(ib,0,thisIndex.z).recvUntrans(msg);
05942 #if Y_PERSIST 
05943     CmiUsePersistentHandle(NULL, 0);
05944 #endif
05945 #endif
05946     CmiEnableUrgentSend(0);
05947   }
05948 }


Member Data Documentation

fftw_plan PmeXPencil::backward_plan

Definition at line 4731 of file ComputePme.C.

Referenced by backward_fft(), and fft_init().

fftw_plan PmeXPencil::forward_plan

Definition at line 4731 of file ComputePme.C.

Referenced by fft_init(), and forward_fft().

PmeKSpace* PmeXPencil::myKSpace

Definition at line 4737 of file ComputePme.C.

Referenced by fft_init(), pme_kspace(), and PmeXPencil().

int PmeXPencil::ny

Definition at line 4734 of file ComputePme.C.

int PmeXPencil::nz

Definition at line 4734 of file ComputePme.C.

int PmeXPencil::recipEvirPe

Definition at line 4735 of file ComputePme.C.

Referenced by evir_init(), PmeXPencil(), and send_untrans().


The documentation for this class was generated from the following file:
Generated on Sat Feb 17 01:17:20 2018 for NAMD by  doxygen 1.4.7