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 4640 of file ComputePme.C.


Constructor & Destructor Documentation

PmeYPencil_SDAG_CODE PmeYPencil::PmeYPencil (  )  [inline]

Definition at line 4643 of file ComputePme.C.

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

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

PmeYPencil::PmeYPencil ( CkMigrateMessage *   )  [inline]

Definition at line 4644 of file ComputePme.C.

04644 { __sdag_init(); }


Member Function Documentation

void PmeYPencil::backward_fft (  ) 

Definition at line 5991 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().

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

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

Definition at line 5979 of file ComputePme.C.

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

Referenced by PmeYPencilBackwardFFT().

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

void PmeYPencil::fft_init (  ) 

Definition at line 4869 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.

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

void PmeYPencil::forward_fft (  ) 

Definition at line 5419 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().

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

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

Definition at line 5407 of file ComputePme.C.

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

Referenced by PmeYPencilForwardFFT().

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

void PmeYPencil::node_process_trans ( PmeTransMsg  ) 

Definition at line 4940 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().

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

void PmeYPencil::node_process_untrans ( PmeUntransMsg  ) 

Definition at line 4962 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().

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

void PmeYPencil::recv_trans ( const PmeTransMsg  ) 

Definition at line 5366 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().

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

void PmeYPencil::recv_untrans ( const PmeUntransMsg  ) 

Definition at line 5950 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().

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

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

Definition at line 5460 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().

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

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

Definition at line 6039 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().

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

void PmeYPencil::send_trans (  ) 

Definition at line 5517 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().

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

void PmeYPencil::send_untrans (  ) 

Definition at line 6147 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().

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


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