PmeYPencil Class Reference

Inheritance diagram for PmeYPencil:

PmePencil< CBase_PmeYPencil > CBase_PmeYPencil List of all members.

Public Member Functions

PmeYPencil_SDAG_CODE PmeYPencil ()
 PmeYPencil (CkMigrateMessage *)
void fft_init ()
void recv_trans (const PmeTransMsg *)
void forward_fft ()
void forward_subset_fft (int fromIdx, int toIdx)
void send_trans ()
void send_subset_trans (int fromIdx, int toIdx)
void recv_untrans (const PmeUntransMsg *)
void node_process_trans (PmeTransMsg *)
void node_process_untrans (PmeUntransMsg *)
void backward_fft ()
void backward_subset_fft (int fromIdx, int toIdx)
void send_untrans ()
void send_subset_untrans (int fromIdx, int toIdx, int evirIdx)

Detailed Description

Definition at line 4641 of file ComputePme.C.


Constructor & Destructor Documentation

PmeYPencil_SDAG_CODE PmeYPencil::PmeYPencil (  )  [inline]

Definition at line 4644 of file ComputePme.C.

References PmePencil< CBase_PmeYPencil >::imsg, and PmePencil< CBase_PmeYPencil >::imsgb.

04644 { __sdag_init(); setMigratable(false); imsg=imsgb=0;}

PmeYPencil::PmeYPencil ( CkMigrateMessage *   )  [inline]

Definition at line 4645 of file ComputePme.C.

04645 { __sdag_init(); }


Member Function Documentation

void PmeYPencil::backward_fft (  ) 

Definition at line 5992 of file ComputePme.C.

References CKLOOP_CTRL_PME_BACKWARDFFT, PmePencil< CBase_PmeYPencil >::data, PmePencilInitMsgData::grid, PmePencil< CBase_PmeYPencil >::initdata, PmeGrid::K2, Node::Object(), PmeYPencilBackwardFFT(), Node::simParameters, SimParameters::useCkLoop, PmePencil< CBase_PmeYPencil >::work, PmePencilInitMsgData::xBlocks, and PmePencilInitMsgData::zBlocks.

Referenced by node_process_untrans().

05992                               {
05993 #ifdef NAMD_FFTW
05994 #ifdef MANUAL_DEBUG_FFTW3
05995   dumpMatrixFloat3("bw_y_b", data, nx, initdata.grid.K2, nz, thisIndex.x, thisIndex.y, thisIndex.z);
05996 #endif
05997 
05998 #ifdef NAMD_FFTW_3
05999 #if     CMK_SMP && USE_CKLOOP
06000   int useCkLoop = Node::Object()->simParameters->useCkLoop;
06001   if(useCkLoop>=CKLOOP_CTRL_PME_BACKWARDFFT
06002      && CkNumPes() >= 2 * initdata.xBlocks * initdata.zBlocks) {
06003           CkLoop_Parallelize(PmeYPencilBackwardFFT, 1, (void *)this, CkMyNodeSize(), 0, nx-1); //sync
06004           return;
06005   }
06006 #endif
06007   //the above is a transformation of the following loop using CkLoop
06008   for ( int i=0; i<nx; ++i ) {
06009 #if CMK_BLUEGENEL
06010         CmiNetworkProgress();
06011 #endif
06012     fftwf_execute_dft(backward_plan,    
06013                                           ((fftwf_complex *) data) + i * nz * initdata.grid.K2,
06014                                           ((fftwf_complex *) data) + i * nz * initdata.grid.K2);
06015   }
06016 #else
06017         for ( int i=0; i<nx; ++i ) {
06018 #if CMK_BLUEGENEL
06019           CmiNetworkProgress();
06020 #endif
06021                 fftw(backward_plan, nz,
06022                 ((fftw_complex *) data) + i * nz * initdata.grid.K2,
06023                 nz, 1, (fftw_complex *) work, 1, 0);
06024         }
06025 #endif
06026 
06027 #ifdef MANUAL_DEBUG_FFTW3
06028   dumpMatrixFloat3("bw_y_a", data, nx, initdata.grid.K2, nz, thisIndex.x, thisIndex.y, thisIndex.z);
06029 #endif
06030 
06031 #endif
06032 }

void PmeYPencil::backward_subset_fft ( int  fromIdx,
int  toIdx 
)

Definition at line 5980 of file ComputePme.C.

References PmePencil< CBase_PmeYPencil >::data, PmePencilInitMsgData::grid, PmePencil< CBase_PmeYPencil >::initdata, and PmeGrid::K2.

Referenced by PmeYPencilBackwardFFT().

05980                                                            {
05981 #ifdef NAMD_FFTW
05982 #ifdef NAMD_FFTW_3
05983         for(int i=fromIdx; i<=toIdx; i++){
05984                 fftwf_execute_dft(backward_plan,        
05985                                                   ((fftwf_complex *) data) + i * nz * initdata.grid.K2,         
05986                                                   ((fftwf_complex *) data) + i * nz * initdata.grid.K2);
05987         }
05988 #endif
05989 #endif
05990 }

void PmeYPencil::fft_init (  ) 

Definition at line 4870 of file ComputePme.C.

References PmeGrid::block1, PmeGrid::block3, PmePencil< CBase_PmeYPencil >::data, PmeGrid::dim2, PmeGrid::dim3, PmePencil< CBase_PmeYPencil >::evir, fftwf_malloc, PmePencilInitMsgData::grid, PmePencil< CBase_PmeYPencil >::initdata, PmeGrid::K1, PmeGrid::K2, NAMD_die(), PmePencil< CBase_PmeYPencil >::order_init(), PmePencilInitMsgData::pmeNodeProxy, Node::simParameters, simParams, PmePencil< CBase_PmeYPencil >::work, and PmePencilInitMsgData::yBlocks.

04870                           {
04871   CProxy_Node nd(CkpvAccess(BOCclass_group).node);
04872   Node *node = nd.ckLocalBranch();
04873   SimParameters *simParams = node->simParameters;
04874 
04875 #if USE_NODE_PAR_RECEIVE
04876   ((NodePmeMgr *)CkLocalNodeBranch(initdata.pmeNodeProxy))->registerYPencil(thisIndex,this);
04877 #endif
04878 
04879   int K1 = initdata.grid.K1;
04880   int K2 = initdata.grid.K2;
04881   int dim2 = initdata.grid.dim2;
04882   int dim3 = initdata.grid.dim3;
04883   int block1 = initdata.grid.block1;
04884   int block3 = initdata.grid.block3;
04885 
04886   nx = block1;
04887   if ( (thisIndex.x + 1) * block1 > K1 ) nx = K1 - thisIndex.x * block1;
04888   nz = block3;
04889   if ( (thisIndex.z+1)*block3 > dim3/2 ) nz = dim3/2 - thisIndex.z*block3;
04890 
04891 #ifdef NAMD_FFTW
04892   CmiLock(ComputePmeMgr::fftw_plan_lock);
04893 
04894   data = (float *) fftwf_malloc( sizeof(float) * nx*dim2*nz*2);
04895   work = new float[2*K2];
04896 
04897   order_init(initdata.yBlocks);
04898 
04899 #ifdef NAMD_FFTW_3
04900   /* need array of sizes for the dimensions */
04901   /* ideally this should be implementable as a single multidimensional
04902    *  plan, but that has proven tricky to implement, so we maintain the
04903    *  loop of 1d plan executions. */
04904   int sizeLines=nz;
04905   int planLineSizes[1];
04906   planLineSizes[0]=K2;
04907   int fftwFlags = simParams->FFTWPatient ? FFTW_PATIENT  : simParams->FFTWEstimate ? FFTW_ESTIMATE  : FFTW_MEASURE ;
04908   forward_plan = fftwf_plan_many_dft(1, planLineSizes, sizeLines, 
04909                                      (fftwf_complex *) data, NULL, sizeLines, 1,
04910                                      (fftwf_complex *) data, NULL, sizeLines, 1,
04911                                      FFTW_FORWARD, 
04912                                      fftwFlags);
04913   backward_plan = fftwf_plan_many_dft(1, planLineSizes, sizeLines, 
04914                                      (fftwf_complex *) data, NULL, sizeLines, 1,
04915                                      (fftwf_complex *) data, NULL, sizeLines, 1,
04916                                      FFTW_BACKWARD, 
04917                                       fftwFlags);
04918   CkAssert(forward_plan != NULL);
04919   CkAssert(backward_plan != NULL);
04920 #else
04921   forward_plan = fftw_create_plan_specific(K2, FFTW_FORWARD,
04922         ( simParams->FFTWEstimate ? FFTW_ESTIMATE : FFTW_MEASURE )
04923         | FFTW_IN_PLACE | FFTW_USE_WISDOM, (fftw_complex *) data,
04924         nz, (fftw_complex *) work, 1);
04925   backward_plan = fftw_create_plan_specific(K2, FFTW_BACKWARD,
04926         ( simParams->FFTWEstimate ? FFTW_ESTIMATE : FFTW_MEASURE )
04927         | FFTW_IN_PLACE | FFTW_USE_WISDOM, (fftw_complex *) data,
04928         nz, (fftw_complex *) work, 1);
04929 #endif
04930   CmiUnlock(ComputePmeMgr::fftw_plan_lock);
04931 #else
04932   NAMD_die("Sorry, FFTW must be compiled in to use PME.");
04933 #endif
04934 
04935 #if USE_NODE_PAR_RECEIVE
04936   evir = 0;
04937   CmiMemoryWriteFence();
04938 #endif
04939 }

void PmeYPencil::forward_fft (  ) 

Definition at line 5420 of file ComputePme.C.

References CKLOOP_CTRL_PME_FORWARDFFT, PmePencil< CBase_PmeYPencil >::data, PmeGrid::dim2, PmePencil< CBase_PmeYPencil >::evir, PmePencilInitMsgData::grid, PmePencil< CBase_PmeYPencil >::initdata, PmeGrid::K2, Node::Object(), PmeYPencilForwardFFT(), Node::simParameters, SimParameters::useCkLoop, PmePencil< CBase_PmeYPencil >::work, PmePencilInitMsgData::xBlocks, and PmePencilInitMsgData::zBlocks.

Referenced by node_process_trans().

05420                              {
05421     evir = 0.;
05422 #ifdef NAMD_FFTW
05423 #ifdef MANUAL_DEBUG_FFTW3
05424   dumpMatrixFloat3("fw_y_b", data, nx, initdata.grid.K2, nz, thisIndex.x, thisIndex.y, thisIndex.z);
05425 #endif
05426   
05427 #ifdef NAMD_FFTW_3
05428 #if     CMK_SMP && USE_CKLOOP
05429   int useCkLoop = Node::Object()->simParameters->useCkLoop;
05430   if(useCkLoop>=CKLOOP_CTRL_PME_FORWARDFFT
05431      && CkNumPes() >= 2 * initdata.xBlocks * initdata.zBlocks) {
05432           CkLoop_Parallelize(PmeYPencilForwardFFT, 1, (void *)this, CkMyNodeSize(), 0, nx-1); //sync
05433           return;
05434   }
05435 #endif
05436   //the above is a transformation of the following loop using CkLoop
05437   for ( int i=0; i<nx; ++i ) {
05438     fftwf_execute_dft(forward_plan, ((fftwf_complex *) data) + i 
05439                       * nz * initdata.grid.K2,  
05440                       ((fftwf_complex *) data) + i * nz * initdata.grid.K2);
05441   }
05442 #else
05443   for ( int i=0; i<nx; ++i ) {
05444     fftw(forward_plan, nz,
05445         ((fftw_complex *) data) + i * nz * initdata.grid.K2,
05446         nz, 1, (fftw_complex *) work, 1, 0);
05447   }
05448 #endif
05449 #ifdef MANUAL_DEBUG_FFTW3
05450   dumpMatrixFloat3("fw_y_a", data, nx, initdata.grid.dim2, nz, thisIndex.x, thisIndex.y, thisIndex.z);
05451 #endif
05452 
05453 #endif
05454 }

void PmeYPencil::forward_subset_fft ( int  fromIdx,
int  toIdx 
)

Definition at line 5408 of file ComputePme.C.

References PmePencil< CBase_PmeYPencil >::data, PmePencilInitMsgData::grid, PmePencil< CBase_PmeYPencil >::initdata, and PmeGrid::K2.

Referenced by PmeYPencilForwardFFT().

05408                                                           {
05409 #ifdef NAMD_FFTW
05410 #ifdef NAMD_FFTW_3
05411         for(int i=fromIdx; i<=toIdx; i++){
05412                 fftwf_execute_dft(forward_plan, ((fftwf_complex *) data) + i 
05413                       * nz * initdata.grid.K2,  
05414                       ((fftwf_complex *) data) + i * nz * initdata.grid.K2);
05415         }
05416 #endif
05417 #endif
05418 }

void PmeYPencil::node_process_trans ( PmeTransMsg  ) 

Definition at line 4941 of file ComputePme.C.

References forward_fft(), PmePencil< CBase_PmeYPencil >::hasData, PmeTransMsg::hasData, PmePencil< CBase_PmeYPencil >::imsg, PmePencil< CBase_PmeYPencil >::initdata, PmePencil< CBase_PmeYPencil >::needs_reply, recv_trans(), send_trans(), send_untrans(), PmeTransMsg::sourceNode, and PmePencilInitMsgData::yBlocks.

Referenced by NodePmeMgr::recvYTrans().

04942 {
04943   if ( msg->hasData ) hasData = 1;
04944   needs_reply[msg->sourceNode] = msg->hasData;
04945   recv_trans(msg);
04946   int limsg;
04947   CmiMemoryAtomicFetchAndInc(imsg,limsg);
04948   if(limsg+1 == initdata.yBlocks)
04949     {
04950       if ( hasData ) {
04951         forward_fft();
04952       }
04953       send_trans();
04954       if( ! hasData)
04955         {
04956           send_untrans(); //todo, what is up with the recvAck in SDAG version?
04957         }
04958       imsg=0;
04959       CmiMemoryWriteFence();
04960     }
04961 }

void PmeYPencil::node_process_untrans ( PmeUntransMsg  ) 

Definition at line 4963 of file ComputePme.C.

References backward_fft(), PmePencil< CBase_PmeYPencil >::imsgb, PmePencil< CBase_PmeYPencil >::initdata, recv_untrans(), send_untrans(), and PmePencilInitMsgData::yBlocks.

Referenced by NodePmeMgr::recvYUntrans().

04964 {
04965   recv_untrans(msg);
04966   int limsg;
04967   CmiMemoryAtomicFetchAndInc(imsgb,limsg);
04968   if(limsg+1 == initdata.yBlocks)
04969     {
04970       backward_fft();
04971       send_untrans();
04972       imsgb=0;
04973       CmiMemoryWriteFence();
04974     }
04975 }

void PmeYPencil::recv_trans ( const PmeTransMsg  ) 

Definition at line 5367 of file ComputePme.C.

References PmeGrid::block2, PmePencil< CBase_PmeYPencil >::data, PmePencilInitMsgData::grid, PmeTransMsg::hasData, PmePencil< CBase_PmeYPencil >::imsg, PmePencil< CBase_PmeYPencil >::initdata, j, PmeGrid::K2, PmeTransMsg::lattice, PmePencil< CBase_PmeYPencil >::lattice, PmeTransMsg::nx, PmeTransMsg::qgrid, PmeTransMsg::sequence, PmePencil< CBase_PmeYPencil >::sequence, and PmeTransMsg::sourceNode.

Referenced by node_process_trans().

05367                                                   {
05368   if ( imsg == 0 ) {
05369     lattice = msg->lattice;
05370     sequence = msg->sequence;
05371   }
05372   int block2 = initdata.grid.block2;
05373   int K2 = initdata.grid.K2;
05374   int jb = msg->sourceNode;
05375   int ny = msg->nx;
05376  if ( msg->hasData ) {
05377   const float *md = msg->qgrid;
05378   float *d = data;
05379   for ( int i=0; i<nx; ++i, d += K2*nz*2 ) {
05380    for ( int j=jb*block2; j<(jb*block2+ny); ++j ) {
05381     for ( int k=0; k<nz; ++k ) {
05382 #ifdef ZEROCHECK
05383       if ( (*md) == 0. ) CkPrintf("0 in ZY at %d %d %d %d %d %d %d %d %d\n",
05384         thisIndex.x, jb, thisIndex.z, i, j, k, nx, ny, nz);
05385 #endif
05386       d[2*(j*nz+k)] = *(md++);
05387       d[2*(j*nz+k)+1] = *(md++);
05388     }
05389    }
05390   }
05391  } else {
05392   float *d = data;
05393   for ( int i=0; i<nx; ++i, d += K2*nz*2 ) {
05394    for ( int j=jb*block2; j<(jb*block2+ny); ++j ) {
05395     for ( int k=0; k<nz; ++k ) {
05396       d[2*(j*nz+k)] = 0;
05397       d[2*(j*nz+k)+1] = 0;
05398     }
05399    }
05400   }
05401  }
05402 }

void PmeYPencil::recv_untrans ( const PmeUntransMsg  ) 

Definition at line 5951 of file ComputePme.C.

References PmeGrid::block2, PmePencil< CBase_PmeYPencil >::data, PmePencilInitMsgData::grid, PmePencil< CBase_PmeYPencil >::initdata, j, PmeGrid::K2, PmeUntransMsg::ny, PmeUntransMsg::qgrid, and PmeUntransMsg::sourceNode.

Referenced by node_process_untrans().

05951                                                       {
05952   int block2 = initdata.grid.block2;
05953   int K2 = initdata.grid.K2;
05954   int jb = msg->sourceNode;
05955   int ny = msg->ny;
05956   const float *md = msg->qgrid;
05957   float *d = data;
05958   for ( int i=0; i<nx; ++i, d += K2*nz*2 ) {
05959 #if CMK_BLUEGENEL
05960     CmiNetworkProgress();
05961 #endif   
05962     for ( int j=jb*block2; j<(jb*block2+ny); ++j ) {
05963       for ( int k=0; k<nz; ++k ) {
05964 #ifdef ZEROCHECK
05965         if ( (*md) == 0. ) CkPrintf("0 in XY at %d %d %d %d %d %d %d %d %d\n",
05966                                     thisIndex.x, jb, thisIndex.z, i, j, k, nx, ny, nz);
05967 #endif
05968         d[2*(j*nz+k)] = *(md++);
05969         d[2*(j*nz+k)+1] = *(md++);
05970       }
05971     }
05972   }
05973 }

void PmeYPencil::send_subset_trans ( int  fromIdx,
int  toIdx 
)

Definition at line 5461 of file ComputePme.C.

References PmeGrid::block2, PmePencil< CBase_PmeYPencil >::data, PmeTransMsg::destElem, PmePencilInitMsgData::grid, PmeTransMsg::hasData, PmePencil< CBase_PmeYPencil >::hasData, PmePencil< CBase_PmeYPencil >::initdata, j, PmeGrid::K2, PmePencil< CBase_PmeYPencil >::lattice, PmeTransMsg::lattice, PmeTransMsg::nx, PME_TRANS2_PRIORITY, PmePencilInitMsgData::pmeNodeProxy, PRIORITY_SIZE, PmeTransMsg::qgrid, PmePencil< CBase_PmeYPencil >::send_order, PmePencil< CBase_PmeYPencil >::sequence, PmeTransMsg::sequence, SET_PRIORITY, PmeTransMsg::sourceNode, PmePencilInitMsgData::xm, PmePencilInitMsgData::xPencil, and PmePencilInitMsgData::yBlocks.

Referenced by PmeYPencilSendTrans().

05461                                                         {
05462         int yBlocks = initdata.yBlocks;
05463         int block2 = initdata.grid.block2;
05464         int K2 = initdata.grid.K2;
05465     for ( int isend=fromIdx; isend<=toIdx; ++isend ) {
05466           int jb = send_order[isend];
05467           int ny = block2;
05468           if ( (jb+1)*block2 > K2 ) ny = K2 - jb*block2;
05469           int hd = ( hasData ? 1 : 0 );
05470           PmeTransMsg *msg = new (hd*nx*ny*nz*2,PRIORITY_SIZE) PmeTransMsg;
05471           msg->lattice = lattice;
05472           msg->sourceNode = thisIndex.x;
05473           msg->hasData = hasData;
05474           msg->nx = nx;
05475          if ( hasData ) {
05476           float *md = msg->qgrid;
05477           const float *d = data;
05478           for ( int i=0; i<nx; ++i, d += K2*nz*2 ) {
05479            for ( int j=jb*block2; j<(jb*block2+ny); ++j ) {
05480                 for ( int k=0; k<nz; ++k ) {
05481                   *(md++) = d[2*(j*nz+k)];
05482                   *(md++) = d[2*(j*nz+k)+1];
05483   #ifdef ZEROCHECK
05484                   if ( *(md-2) == 0. ) CkPrintf("send 0 in YX at %d %d %d %d %d %d %d %d %d\n",
05485           thisIndex.x, jb, thisIndex.z, i, j, k, nx, ny, nz);
05486   #endif
05487                 }
05488            }
05489           }
05490           if ( md != msg->qgrid + nx*ny*nz*2 ) CkPrintf("error in YX at %d %d %d\n",
05491           thisIndex.x, jb, thisIndex.z);
05492          }
05493           msg->sequence = sequence;
05494           SET_PRIORITY(msg,sequence,PME_TRANS2_PRIORITY)
05495       CmiEnableUrgentSend(1);
05496 #if USE_NODE_PAR_RECEIVE
05497       msg->destElem=CkArrayIndex3D(0,jb,thisIndex.z);
05498 #if X_PERSIST 
05499       CmiUsePersistentHandle(&trans_handle[isend], 1);
05500 #endif
05501       initdata.pmeNodeProxy[CmiNodeOf(initdata.xm.ckLocalBranch()->procNum(0,msg->destElem))].recvXTrans(msg);   
05502 #if X_PERSIST 
05503       CmiUsePersistentHandle(NULL, 0);
05504 #endif
05505 #else      
05506 #if X_PERSIST 
05507       CmiUsePersistentHandle(&trans_handle[isend], 1);
05508 #endif
05509       initdata.xPencil(0,jb,thisIndex.z).recvTrans(msg);
05510 #if X_PERSIST 
05511       CmiUsePersistentHandle(NULL, 0);
05512 #endif
05513 #endif
05514       CmiEnableUrgentSend(0);
05515         }
05516 }

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

Definition at line 6040 of file ComputePme.C.

References PmeGrid::block2, PmePencil< CBase_PmeYPencil >::data, PmeUntransMsg::destElem, PmePencilInitMsgData::grid, PmePencil< CBase_PmeYPencil >::initdata, j, PmeGrid::K2, PmeUntransMsg::ny, PME_UNTRANS2_PRIORITY, PmePencilInitMsgData::pmeNodeProxy, PRIORITY_SIZE, PmeUntransMsg::qgrid, PmePencil< CBase_PmeYPencil >::send_order, PmePencil< CBase_PmeYPencil >::sequence, SET_PRIORITY, PmeUntransMsg::sourceNode, PmePencilInitMsgData::yBlocks, PmePencilInitMsgData::zm, and PmePencilInitMsgData::zPencil.

Referenced by PmeYPencilSendUntrans().

06040                                                                        {
06041         int yBlocks = initdata.yBlocks;
06042         int block2 = initdata.grid.block2;      
06043         int K2 = initdata.grid.K2;
06044 
06045         int ackL=0, ackH=-1;
06046         int unL=0, unH=-1;
06047         int send_evir=0;
06048         if(fromIdx >= evirIdx+1) {
06049                 //send PmeUntransMsg with has_evir=0
06050                 unL = fromIdx;
06051                 unH = toIdx;            
06052         } else if(toIdx <= evirIdx-1) {
06053                 //send PmeAckMsg
06054                 ackL=fromIdx;
06055                 ackH=toIdx;             
06056         } else {
06057                 //partially send PmeAckMsg and partially send PmeUntransMsg
06058                 ackL=fromIdx;
06059                 ackH=evirIdx-1;
06060                 send_evir=1;
06061                 unL=evirIdx+1;
06062                 unH=toIdx;
06063         }
06064 
06065         for(int isend=ackL; isend<=ackH; isend++) {
06066                 //send PmeAckMsg
06067         CmiEnableUrgentSend(1);
06068                 int jb = send_order[isend];
06069                 PmeAckMsg *msg = new (PRIORITY_SIZE) PmeAckMsg;
06070                 SET_PRIORITY(msg,sequence,PME_UNTRANS2_PRIORITY)
06071                 initdata.zPencil(thisIndex.x,jb,0).recvAck(msg);
06072         CmiEnableUrgentSend(0);
06073         }
06074 
06075     CmiEnableUrgentSend(1);
06076         //send PmeUntransMsg with has_evir=1
06077         if(send_evir) {
06078                 int jb = send_order[evirIdx];
06079                 int ny = block2;
06080                 if ( (jb+1)*block2 > K2 ) ny = K2 - jb*block2;
06081                 PmeUntransMsg *msg = new (nx*ny*nz*2,PRIORITY_SIZE) PmeUntransMsg;              
06082                 msg->sourceNode = thisIndex.z;
06083                 msg->ny = nz;
06084                 float *md = msg->qgrid;
06085                 const float *d = data;
06086                 for ( int i=0; i<nx; ++i, d += K2*nz*2 ) {
06087                         for ( int j=jb*block2; j<(jb*block2+ny); ++j ) {
06088                                 for ( int k=0; k<nz; ++k ) {
06089                                         *(md++) = d[2*(j*nz+k)];
06090                                         *(md++) = d[2*(j*nz+k)+1];
06091                                 }
06092                         }
06093                 }
06094                 SET_PRIORITY(msg,sequence,PME_UNTRANS2_PRIORITY)
06095 #if USE_NODE_PAR_RECEIVE
06096         msg->destElem=CkArrayIndex3D( thisIndex.x, jb, 0);
06097     //    CkPrintf("[%d] sending to %d %d %d recvZUntrans on node %d\n", CkMyPe(), thisIndex.x, jb, 0, CmiNodeOf(initdata.zm.ckLocalBranch()->procNum(0,msg->destElem)));
06098         initdata.pmeNodeProxy[CmiNodeOf(initdata.zm.ckLocalBranch()->procNum(0,msg->destElem))].recvZUntrans(msg);
06099 #else
06100         initdata.zPencil(thisIndex.x,jb,0).recvUntrans(msg);
06101 #endif
06102         }
06103 
06104     CmiEnableUrgentSend(0);
06105         //send PmeUntransMsg with has_evir=0
06106         for(int isend=unL; isend<=unH; isend++) {
06107                 int jb = send_order[isend];
06108                 int ny = block2;
06109                 if ( (jb+1)*block2 > K2 ) ny = K2 - jb*block2;
06110                 PmeUntransMsg *msg = new (nx*ny*nz*2,PRIORITY_SIZE) PmeUntransMsg;
06111                 msg->sourceNode = thisIndex.z;
06112                 msg->ny = nz;
06113                 float *md = msg->qgrid;
06114                 const float *d = data;
06115                 for ( int i=0; i<nx; ++i, d += K2*nz*2 ) {
06116                         for ( int j=jb*block2; j<(jb*block2+ny); ++j ) {
06117                                 for ( int k=0; k<nz; ++k ) {
06118                                         *(md++) = d[2*(j*nz+k)];
06119                                         *(md++) = d[2*(j*nz+k)+1];
06120                                 }
06121                         }
06122                 }
06123                 SET_PRIORITY(msg,sequence,PME_UNTRANS2_PRIORITY)
06124             CmiEnableUrgentSend(1);
06125 #if USE_NODE_PAR_RECEIVE
06126         msg->destElem=CkArrayIndex3D( thisIndex.x, jb, 0);
06127         //    CkPrintf("[%d] sending to %d %d %d recvZUntrans on node %d\n", CkMyPe(), thisIndex.x, jb, 0, CmiNodeOf(initdata.zm.ckLocalBranch()->procNum(0,msg->destElem)));
06128 #if Z_PERSIST 
06129         CmiUsePersistentHandle(&untrans_handle[isend], 1);
06130 #endif
06131         initdata.pmeNodeProxy[CmiNodeOf(initdata.zm.ckLocalBranch()->procNum(0,msg->destElem))].recvZUntrans(msg);
06132 #if Z_PERSIST 
06133         CmiUsePersistentHandle(NULL, 0);
06134 #endif
06135 #else
06136 #if Z_PERSIST 
06137         CmiUsePersistentHandle(&untrans_handle[isend], 1);
06138 #endif
06139         initdata.zPencil(thisIndex.x,jb,0).recvUntrans(msg);
06140 #if Z_PERSIST 
06141         CmiUsePersistentHandle(NULL, 0);
06142 #endif
06143 #endif
06144     CmiEnableUrgentSend(0);
06145         }
06146 }

void PmeYPencil::send_trans (  ) 

Definition at line 5518 of file ComputePme.C.

References PmeGrid::block2, CKLOOP_CTRL_PME_SENDTRANS, PmePencil< CBase_PmeYPencil >::data, PmeTransMsg::destElem, PmePencilInitMsgData::grid, PmeTransMsg::hasData, PmePencil< CBase_PmeYPencil >::hasData, PmePencil< CBase_PmeYPencil >::initdata, j, PmeGrid::K2, PmePencil< CBase_PmeYPencil >::lattice, PmeTransMsg::lattice, PmeTransMsg::nx, Node::Object(), PME_TRANS2_PRIORITY, PmePencilInitMsgData::pmeNodeProxy, PmeYPencilSendTrans(), PRIORITY_SIZE, PmeTransMsg::qgrid, PmePencil< CBase_PmeYPencil >::send_order, PmePencil< CBase_PmeYPencil >::sequence, PmeTransMsg::sequence, SET_PRIORITY, Node::simParameters, PmeTransMsg::sourceNode, SimParameters::useCkLoop, PmePencilInitMsgData::xBlocks, PmePencilInitMsgData::xm, PmePencilInitMsgData::xPencil, PmePencilInitMsgData::yBlocks, and PmePencilInitMsgData::zBlocks.

Referenced by node_process_trans().

05518                             {
05519 #if USE_PERSISTENT
05520     if (trans_handle == NULL) setup_persistent();
05521 #endif
05522 #if     CMK_SMP && USE_CKLOOP
05523         int useCkLoop = Node::Object()->simParameters->useCkLoop;
05524         if(useCkLoop>=CKLOOP_CTRL_PME_SENDTRANS
05525            && CkNumPes() >= 2 * initdata.xBlocks * initdata.zBlocks) {
05532                 //send_subset_trans(0, initdata.yBlocks-1);
05533                 CkLoop_Parallelize(PmeYPencilSendTrans, 1, (void *)this, CkMyNodeSize(), 0, initdata.yBlocks-1, 1); //not sync
05534                 return;
05535         }
05536 #endif
05537   int yBlocks = initdata.yBlocks;
05538   int block2 = initdata.grid.block2;
05539   int K2 = initdata.grid.K2;
05540   for ( int isend=0; isend<yBlocks; ++isend ) {
05541     int jb = send_order[isend];
05542     int ny = block2;
05543     if ( (jb+1)*block2 > K2 ) ny = K2 - jb*block2;
05544     int hd = ( hasData ? 1 : 0 );
05545     PmeTransMsg *msg = new (hd*nx*ny*nz*2,PRIORITY_SIZE) PmeTransMsg;
05546     msg->lattice = lattice;
05547     msg->sourceNode = thisIndex.x;
05548     msg->hasData = hasData;
05549     msg->nx = nx;
05550    if ( hasData ) {
05551     float *md = msg->qgrid;
05552     const float *d = data;
05553     for ( int i=0; i<nx; ++i, d += K2*nz*2 ) {
05554      for ( int j=jb*block2; j<(jb*block2+ny); ++j ) {
05555       for ( int k=0; k<nz; ++k ) {
05556         *(md++) = d[2*(j*nz+k)];
05557         *(md++) = d[2*(j*nz+k)+1];
05558 #ifdef ZEROCHECK
05559         if ( *(md-2) == 0. ) CkPrintf("send 0 in YX at %d %d %d %d %d %d %d %d %d\n",
05560         thisIndex.x, jb, thisIndex.z, i, j, k, nx, ny, nz);
05561 #endif
05562       }
05563      }
05564     }
05565     if ( md != msg->qgrid + nx*ny*nz*2 ) CkPrintf("error in YX at %d %d %d\n",
05566         thisIndex.x, jb, thisIndex.z);
05567    }
05568     msg->sequence = sequence;
05569     SET_PRIORITY(msg,sequence,PME_TRANS2_PRIORITY)
05570     CmiEnableUrgentSend(1);
05571 #if USE_NODE_PAR_RECEIVE
05572     msg->destElem=CkArrayIndex3D(0,jb,thisIndex.z);
05573 #if X_PERSIST 
05574         CmiUsePersistentHandle(&trans_handle[isend], 1);
05575 #endif
05576     initdata.pmeNodeProxy[CmiNodeOf(initdata.xm.ckLocalBranch()->procNum(0,msg->destElem))].recvXTrans(msg);   
05577 #if X_PERSIST 
05578         CmiUsePersistentHandle(NULL, 0);
05579 #endif
05580 #else
05581 #if X_PERSIST 
05582         CmiUsePersistentHandle(&trans_handle[isend], 1);
05583 #endif
05584     initdata.xPencil(0,jb,thisIndex.z).recvTrans(msg);
05585 #if X_PERSIST 
05586         CmiUsePersistentHandle(NULL, 0);
05587 #endif
05588     
05589 #endif
05590     CmiEnableUrgentSend(0);
05591   }
05592 }

void PmeYPencil::send_untrans (  ) 

Definition at line 6148 of file ComputePme.C.

References PmeGrid::block2, CKLOOP_CTRL_PME_SENDUNTRANS, PmePencil< CBase_PmeYPencil >::data, PmeUntransMsg::destElem, PmePencil< CBase_PmeYPencil >::evir, PmePencilInitMsgData::grid, PmePencil< CBase_PmeYPencil >::initdata, j, PmeGrid::K2, PmePencil< CBase_PmeYPencil >::needs_reply, PmeUntransMsg::ny, Node::Object(), PME_UNTRANS2_PRIORITY, PmePencilInitMsgData::pmeNodeProxy, PmeYPencilSendUntrans(), PRIORITY_SIZE, PmeUntransMsg::qgrid, PmePencil< CBase_PmeYPencil >::send_order, PmePencil< CBase_PmeYPencil >::sequence, SET_PRIORITY, Node::simParameters, PmeUntransMsg::sourceNode, SimParameters::useCkLoop, PmePencilInitMsgData::xBlocks, PmePencilInitMsgData::yBlocks, PmePencilInitMsgData::zBlocks, PmePencilInitMsgData::zm, and PmePencilInitMsgData::zPencil.

Referenced by node_process_trans(), and node_process_untrans().

06148                               {
06149 #if USE_PERSISTENT
06150   if (untrans_handle == NULL) setup_persistent();
06151 #endif
06152 #if     CMK_SMP && USE_CKLOOP
06153   int useCkLoop = Node::Object()->simParameters->useCkLoop;
06154   if(useCkLoop>=CKLOOP_CTRL_PME_SENDUNTRANS
06155      && CkNumPes() >= 2 * initdata.xBlocks * initdata.zBlocks) {
06156           int yBlocks = initdata.yBlocks;
06157           int evirIdx = 0;
06158           for ( int isend=0; isend<yBlocks; ++isend ) {
06159                   int jb = send_order[isend];
06160                   if (needs_reply[jb]) {
06161                           evirIdx = isend;
06162                           break;
06163                   }
06164           }
06165 
06166           //basically: 
06167           //[0,evirIdx-1]->send PmeAckMsg
06168           //evirIdx->send PmeUntransMsg with has_evir=1
06169           //[evirIdx+1, yBlocks-1]->send PmeUntransMsg with has_evir=0
06170           //send_subset_untrans(0, yBlocks-1, evirIdx);
06171 #if USE_NODE_PAR_RECEIVE      
06172           //CkLoop_Parallelize(PmeYPencilSendUntrans, evirIdx, (void *)this, CkMyNodeSize(), 0, yBlocks-1, 1); //sync
06173           CkLoop_Parallelize(PmeYPencilSendUntrans, evirIdx, (void *)this, yBlocks, 0, yBlocks-1, 1);
06174       evir = 0.;
06175       CmiMemoryWriteFence();
06176 #else
06177       //CkLoop_Parallelize(PmeYPencilSendUntrans, evirIdx, (void *)this, CkMyNodeSize(), 0, yBlocks-1, 0); //not sync
06178           CkLoop_Parallelize(PmeYPencilSendUntrans, evirIdx, (void *)this, yBlocks, 0, yBlocks-1, 0); //not sync
06179 #endif
06180           return;
06181   }
06182 #endif
06183   int yBlocks = initdata.yBlocks;
06184   int block2 = initdata.grid.block2;
06185   int K2 = initdata.grid.K2;
06186   int send_evir = 1;
06187   for ( int isend=0; isend<yBlocks; ++isend ) {
06188     int jb = send_order[isend];
06189     if ( ! needs_reply[jb] ) {
06190       PmeAckMsg *msg = new (PRIORITY_SIZE) PmeAckMsg;
06191       CmiEnableUrgentSend(1);
06192       SET_PRIORITY(msg,sequence,PME_UNTRANS2_PRIORITY)
06193       initdata.zPencil(thisIndex.x,jb,0).recvAck(msg);
06194       CmiEnableUrgentSend(0);
06195       continue;
06196     }
06197     int ny = block2;
06198     if ( (jb+1)*block2 > K2 ) ny = K2 - jb*block2;
06199     PmeUntransMsg *msg = new (nx*ny*nz*2,PRIORITY_SIZE) PmeUntransMsg;
06200     if ( send_evir ) {
06201       send_evir = 0;
06202     }
06203     msg->sourceNode = thisIndex.z;
06204     msg->ny = nz;
06205     float *md = msg->qgrid;
06206     const float *d = data;
06207     for ( int i=0; i<nx; ++i, d += K2*nz*2 ) {
06208      for ( int j=jb*block2; j<(jb*block2+ny); ++j ) {
06209       for ( int k=0; k<nz; ++k ) {
06210         *(md++) = d[2*(j*nz+k)];
06211         *(md++) = d[2*(j*nz+k)+1];
06212       }
06213      }
06214     }
06215     SET_PRIORITY(msg,sequence,PME_UNTRANS2_PRIORITY)
06216 
06217     CmiEnableUrgentSend(1);
06218 #if USE_NODE_PAR_RECEIVE
06219     msg->destElem=CkArrayIndex3D( thisIndex.x, jb, 0);
06220     //    CkPrintf("[%d] sending to %d %d %d recvZUntrans on node %d\n", CkMyPe(), thisIndex.x, jb, 0, CmiNodeOf(initdata.zm.ckLocalBranch()->procNum(0,msg->destElem)));
06221 #if Z_PERSIST 
06222     CmiUsePersistentHandle(&untrans_handle[isend], 1);
06223 #endif
06224     initdata.pmeNodeProxy[CmiNodeOf(initdata.zm.ckLocalBranch()->procNum(0,msg->destElem))].recvZUntrans(msg);
06225 #if Z_PERSIST
06226     CmiUsePersistentHandle(NULL, 0);
06227 #endif
06228 #else
06229 #if Z_PERSIST 
06230     CmiUsePersistentHandle(&untrans_handle[isend], 1);
06231 #endif
06232     initdata.zPencil(thisIndex.x,jb,0).recvUntrans(msg);
06233 #if Z_PERSIST 
06234     CmiUsePersistentHandle(NULL, 0);
06235 #endif
06236 #endif    
06237     CmiEnableUrgentSend(0);
06238   }
06239   
06240 #if USE_NODE_PAR_RECEIVE
06241   evir = 0.;
06242   CmiMemoryWriteFence();
06243 #endif
06244 }


The documentation for this class was generated from the following file:
Generated on Tue Jun 19 01:17:21 2018 for NAMD by  doxygen 1.4.7