OptPmeYPencil Class Reference

#include <fftlib.h>

Inheritance diagram for OptPmeYPencil:

OptPmePencil< CBase_OptPmeYPencil > CBase_OptPmeYPencil List of all members.

Public Member Functions

OptPmeYPencil_SDAG_CODE OptPmeYPencil ()
 OptPmeYPencil (CkMigrateMessage *)
void fft_init ()
void recv_trans (const OptPmeFFTMsg *)
void forward_fft ()
void send_trans ()
void many_to_many_send (int phase)
void recv_untrans (const OptPmeFFTMsg *)
void many_to_many_recv_trans ()
void backward_fft ()
void send_untrans ()
void many_to_many_recv_untrans ()

Detailed Description

Definition at line 142 of file fftlib.h.


Constructor & Destructor Documentation

OptPmeYPencil_SDAG_CODE OptPmeYPencil::OptPmeYPencil (  )  [inline]

Definition at line 145 of file fftlib.h.

00145 { __sdag_init(); setMigratable(false); }

OptPmeYPencil::OptPmeYPencil ( CkMigrateMessage *   )  [inline]

Definition at line 146 of file fftlib.h.

00146 { __sdag_init(); }


Member Function Documentation

void OptPmeYPencil::backward_fft (  ) 

Definition at line 569 of file fftlib.C.

References OptPmePencil< CBase_OptPmeYPencil >::data, OptPmePencilInitMsgData::grid, OptPmePencil< CBase_OptPmeYPencil >::initdata, PmeGrid::K2, and OptPmePencil< CBase_OptPmeYPencil >::work.

00569                                  {
00570 #ifdef NAMD_FFTW
00571 #ifdef NAMD_FFTW_3
00572   fftwf_execute(backward_plan);
00573 #else
00574   for ( int i=0; i<nx; ++i ) {
00575 #if CMK_BLUEGENEL
00576     CmiNetworkProgress();
00577 #endif
00578 
00579     fftw(backward_plan, nz,
00580          ((fftw_complex *) data) + i * nz * initdata.grid.K2,
00581          nz, 1, (fftw_complex *) work, 1, 0);
00582   }
00583 #endif
00584 #endif
00585 }

void OptPmeYPencil::fft_init (  ) 

Definition at line 113 of file fftlib.C.

References PmeGrid::block1, PmeGrid::block3, OptPmePencil< CBase_OptPmeYPencil >::data, PmeGrid::dim2, PmeGrid::dim3, fftw_plan_lock, OptPmePencilInitMsgData::grid, OptPmePencil< CBase_OptPmeYPencil >::handle, OptPmePencil< CBase_OptPmeYPencil >::initdata, PmeGrid::K1, PmeGrid::K2, OptPmePencil< CBase_OptPmeYPencil >::many_to_many_data, OptPmePencil< CBase_OptPmeYPencil >::many_to_many_nb, NAMD_die(), OptPmePencil< CBase_OptPmeYPencil >::order_init(), Node::simParameters, simParams, OptPmePencil< CBase_OptPmeYPencil >::work, and OptPmePencilInitMsgData::yBlocks.

00113                              {
00114   CProxy_Node nd(CkpvAccess(BOCclass_group).node);
00115   Node *node = nd.ckLocalBranch();
00116   SimParameters *simParams = node->simParameters;
00117 
00118   //  printf ("Initialize ypencil [%d,%d], on pd %d\n", thisIndex.x, thisIndex.y, CkMyPe());
00119 
00120   int K1 = initdata.grid.K1;
00121   int K2 = initdata.grid.K2;
00122   int dim2 = initdata.grid.dim2;
00123   int dim3 = initdata.grid.dim3;
00124   int block1 = initdata.grid.block1;
00125   int block3 = initdata.grid.block3;
00126 
00127   nx = block1;
00128   if ( (thisIndex.x + 1) * block1 > K1 ) nx = K1 - thisIndex.x * block1;
00129   nz = block3;
00130   if ( (thisIndex.z+1)*block3 > dim3/2 ) nz = dim3/2 - thisIndex.z*block3;
00131 
00132   data = new float[nx*dim2*nz*2];
00133   many_to_many_data = new float[nx*dim2*nz*2];
00134   many_to_many_nb = new int [initdata.yBlocks];
00135   work = new float[2*K2];
00136 
00137   memset(many_to_many_data, 0, sizeof(float) * nx*dim2*nz*2);
00138 
00139   order_init(initdata.yBlocks);
00140 
00141 #ifdef NAMD_FFTW
00142   CmiLock(fftw_plan_lock);
00143 #ifdef NAMD_FFTW_3
00144   /* need array of sizes for the dimensions */
00145   int numLines=nz;
00146   int planLineSizes[2];
00147   planLineSizes[0]=initdata.grid.K2;
00148   planLineSizes[1]=nz;
00149   forward_plan = fftwf_plan_many_dft(2, planLineSizes, numLines, 
00150                                      (fftwf_complex *) data, NULL, nz, 1,
00151                                      (fftwf_complex *) data, NULL, 1, 0,
00152                                      FFTW_FORWARD, 
00153                                      ( simParams->FFTWEstimate 
00154                                        ? FFTW_ESTIMATE : FFTW_MEASURE ));
00155   backward_plan = fftwf_plan_many_dft(2, planLineSizes, numLines, 
00156                                      (fftwf_complex *) data, NULL, nz, 1,
00157                                      (fftwf_complex *) data, NULL, 1, 0,
00158                                      FFTW_FORWARD, 
00159                                      ( simParams->FFTWEstimate 
00160                                        ? FFTW_ESTIMATE : FFTW_MEASURE ));
00161 #else
00162 
00163   forward_plan = fftw_create_plan_specific(K2, FFTW_FORWARD,
00164         ( simParams->FFTWEstimate ? FFTW_ESTIMATE : FFTW_MEASURE )
00165         | FFTW_IN_PLACE | FFTW_USE_WISDOM, (fftw_complex *) data,
00166         nz, (fftw_complex *) work, 1);
00167   backward_plan = fftw_create_plan_specific(K2, FFTW_BACKWARD,
00168         ( simParams->FFTWEstimate ? FFTW_ESTIMATE : FFTW_MEASURE )
00169         | FFTW_IN_PLACE | FFTW_USE_WISDOM, (fftw_complex *) data,
00170         nz, (fftw_complex *) work, 1);
00171 #endif
00172   CmiUnlock(fftw_plan_lock);
00173 #else
00174   NAMD_die("Sorry, FFTW must be compiled in to use PME.");
00175 #endif
00176 
00177   handle = CmiDirect_manytomany_allocate_handle();
00178   initialize_manytomany();
00179 }

void OptPmeYPencil::forward_fft (  ) 

Definition at line 396 of file fftlib.C.

References OptPmePencil< CBase_OptPmeYPencil >::data, OptPmePencilInitMsgData::grid, OptPmePencil< CBase_OptPmeYPencil >::initdata, PmeGrid::K2, and OptPmePencil< CBase_OptPmeYPencil >::work.

00396                                 {
00397 #ifdef NAMD_FFTW
00398 #ifdef NAMD_FFTW_3
00399   fftwf_execute(forward_plan);
00400 #else
00401   for ( int i=0; i<nx; ++i ) {
00402     fftw(forward_plan, nz,
00403          ((fftw_complex *) data) + i * nz * initdata.grid.K2,
00404          nz, 1, (fftw_complex *) work, 1, 0);
00405   }
00406 #endif
00407 #endif
00408 }

void OptPmeYPencil::many_to_many_recv_trans (  ) 

Definition at line 798 of file fftlib.C.

References PmeGrid::block2, OptPmePencil< CBase_OptPmeYPencil >::data, OptPmePencilInitMsgData::grid, OptPmePencil< CBase_OptPmeYPencil >::initdata, j, PmeGrid::K2, OptPmePencil< CBase_OptPmeYPencil >::many_to_many_data, OptPmePencil< CBase_OptPmeYPencil >::many_to_many_nb, OptPmePencil< CBase_OptPmeYPencil >::single_pencil, and OptPmePencilInitMsgData::yBlocks.

00798                                              {  
00799   int block2 = initdata.grid.block2;
00800   int K2 = initdata.grid.K2;
00801   
00802   const float *md = many_to_many_data;
00803   if (single_pencil) {
00804     float *d = data;
00805     for (int jb = 0; jb < initdata.yBlocks; jb++ ) {
00806       d[2*jb]    = *(md++);
00807       d[2*jb +1] = *(md++);
00808     }
00809   }
00810   else {
00811     for (int jb = 0; jb < initdata.yBlocks; jb++ ) {
00812       int ny = many_to_many_nb[jb];  
00813       float *d = data;
00814       for ( int i=0; i<nx; ++i, d += K2*nz*2 ) {
00815         for ( int j=jb*block2; j<(jb*block2+ny); ++j ) {
00816           for ( int k=0; k<nz; ++k ) {
00817             d[2*(j*nz+k)] = *(md++);
00818             d[2*(j*nz+k)+1] = *(md++);
00819           }
00820         }
00821       }
00822     }
00823   }
00824 }

void OptPmeYPencil::many_to_many_recv_untrans (  ) 

Definition at line 921 of file fftlib.C.

References PmeGrid::block2, OptPmePencil< CBase_OptPmeYPencil >::data, OptPmePencilInitMsgData::grid, OptPmePencil< CBase_OptPmeYPencil >::initdata, j, PmeGrid::K2, OptPmePencil< CBase_OptPmeYPencil >::many_to_many_data, OptPmePencil< CBase_OptPmeYPencil >::many_to_many_nb, OptPmePencil< CBase_OptPmeYPencil >::single_pencil, and OptPmePencilInitMsgData::yBlocks.

00921                                                {  
00922   int block2 = initdata.grid.block2;
00923   int K2 = initdata.grid.K2;
00924   
00925   const float *md = many_to_many_data;
00926   if (single_pencil) {
00927     float *d = data;
00928     for (int jb = 0; jb < initdata.yBlocks; jb++ ) {        
00929       d[2*jb]   = *(md++);
00930       d[2*jb+1] = *(md++);
00931     }
00932   }
00933   else {
00934     for (int jb = 0; jb < initdata.yBlocks; jb++ ) {
00935       int ny = many_to_many_nb[jb];  
00936       float *d = data;
00937       for ( int i=0; i<nx; ++i, d += K2*nz*2 ) {
00938         for ( int j=jb*block2; j<(jb*block2+ny); ++j ) {
00939           for ( int k=0; k<nz; ++k ) {
00940             d[2*(j*nz+k)] = *(md++);
00941             d[2*(j*nz+k)+1] = *(md++);
00942           }
00943         }
00944       }
00945     }
00946   }
00947 }

void OptPmeYPencil::many_to_many_send ( int  phase  ) 

Definition at line 826 of file fftlib.C.

References PmeGrid::block2, OptPmePencil< CBase_OptPmeYPencil >::data, OptPmePencilInitMsgData::grid, OptPmePencil< CBase_OptPmeYPencil >::handle, OptPmePencil< CBase_OptPmeYPencil >::initdata, j, PmeGrid::K2, OptPmePencil< CBase_OptPmeYPencil >::many_to_many_data, OptPmePencil< CBase_OptPmeYPencil >::single_pencil, and OptPmePencilInitMsgData::yBlocks.

00826                                                {
00827   int yBlocks = initdata.yBlocks;
00828   int block2 = initdata.grid.block2;
00829   int K2 = initdata.grid.K2;
00830   
00831   float *md = many_to_many_data;
00832   int ny = block2;
00833   if (single_pencil) {
00834     const float *d = data;
00835     for ( int jb=0; jb<yBlocks; ++jb ) {
00836       *(md++) = d[2*jb];
00837       *(md++) = d[2*jb+1];
00838     }
00839   }
00840   else {
00841     for ( int jb=0; jb<yBlocks; ++jb ) {
00842       ny = block2;
00843       if ( (jb+1)*block2 > K2 ) ny = K2 - jb*block2;
00844       
00845       const float *d = data;
00846       for ( int i=0; i<nx; ++i, d += K2*nz*2 ) {
00847         for ( int j=jb*block2; j<(jb*block2+ny); ++j ) {
00848           for ( int k=0; k<nz; ++k ) {
00849             *(md++) = d[2*(j*nz+k)];
00850             *(md++) = d[2*(j*nz+k)+1];
00851           }
00852         }
00853       }
00854     }
00855   }
00856 
00857   CmiDirect_manytomany_start (handle, phase);  
00858 }

void OptPmeYPencil::recv_trans ( const OptPmeFFTMsg  ) 

Definition at line 378 of file fftlib.C.

References PmeGrid::block2, OptPmePencil< CBase_OptPmeYPencil >::data, OptPmePencilInitMsgData::grid, OptPmePencil< CBase_OptPmeYPencil >::initdata, j, PmeGrid::K2, OptPmeFFTMsg::nx, OptPmeFFTMsg::qgrid, and OptPmeFFTMsg::sourceNode.

00378                                                       {
00379 
00380   int block2 = initdata.grid.block2;
00381   int K2 = initdata.grid.K2;
00382   int jb = msg->sourceNode;
00383   int ny = msg->nx;
00384   const float *md = msg->qgrid;
00385   float *d = data;
00386   for ( int i=0; i<nx; ++i, d += K2*nz*2 ) {
00387     for ( int j=jb*block2; j<(jb*block2+ny); ++j ) {
00388       for ( int k=0; k<nz; ++k ) {
00389         d[2*(j*nz+k)] = *(md++);
00390         d[2*(j*nz+k)+1] = *(md++);
00391       }
00392     }
00393   }
00394 } 

void OptPmeYPencil::recv_untrans ( const OptPmeFFTMsg  ) 

Definition at line 549 of file fftlib.C.

References PmeGrid::block2, OptPmePencil< CBase_OptPmeYPencil >::data, OptPmePencilInitMsgData::grid, OptPmePencil< CBase_OptPmeYPencil >::initdata, j, PmeGrid::K2, OptPmeFFTMsg::nx, OptPmeFFTMsg::qgrid, and OptPmeFFTMsg::sourceNode.

00549                                                         {
00550 
00551   int block2 = initdata.grid.block2;
00552   int K2 = initdata.grid.K2;
00553   int jb = msg->sourceNode;
00554   int ny = msg->nx;
00555   const float *md = msg->qgrid;
00556   float *d = data;
00557   for ( int i=0; i<nx; ++i, d += K2*nz*2 ) {
00558     for ( int j=jb*block2; j<(jb*block2+ny); ++j ) {
00559       for ( int k=0; k<nz; ++k ) {
00560         d[2*(j*nz+k)] = *(md++);
00561         d[2*(j*nz+k)+1] = *(md++);
00562       }
00563     }
00564   }
00565 } 

void OptPmeYPencil::send_trans (  ) 

Definition at line 410 of file fftlib.C.

References PmeGrid::block2, OptPmePencil< CBase_OptPmeYPencil >::data, OptPmePencilInitMsgData::grid, OptPmePencil< CBase_OptPmeYPencil >::initdata, j, PmeGrid::K2, OptPmeFFTMsg::nx, PRIORITY_SIZE, OptPmeFFTMsg::qgrid, OptPmePencil< CBase_OptPmeYPencil >::send_order, OptPmeFFTMsg::sourceNode, OptPmePencilInitMsgData::xPencil, and OptPmePencilInitMsgData::yBlocks.

00410                                {
00411   int yBlocks = initdata.yBlocks;
00412   int block2 = initdata.grid.block2;
00413   int K2 = initdata.grid.K2;
00414   
00415   for ( int isend=0; isend<yBlocks; ++isend ) {
00416     int jb = send_order[isend];
00417     int ny = block2;
00418     if ( (jb+1)*block2 > K2 ) ny = K2 - jb*block2;
00419     OptPmeFFTMsg *msg = new (nx*ny*nz*2,PRIORITY_SIZE) OptPmeFFTMsg;
00420     msg->sourceNode = thisIndex.x;
00421     msg->nx = nx;
00422     float *md = msg->qgrid;
00423     const float *d = data;
00424     for ( int i=0; i<nx; ++i, d += K2*nz*2 ) {
00425       for ( int j=jb*block2; j<(jb*block2+ny); ++j ) {
00426         for ( int k=0; k<nz; ++k ) {
00427           *(md++) = d[2*(j*nz+k)];
00428           *(md++) = d[2*(j*nz+k)+1];
00429         }
00430       }
00431     }
00432     if ( md != msg->qgrid + nx*ny*nz*2 ) CkPrintf("error in YX at %d %d %d\n",
00433                                                   thisIndex.x, jb, thisIndex.z);
00434     
00435     //printf ("%d, %d: Ypencil Sending trans to %d, %d\n", thisIndex.z, thisIndex.x, jb, thisIndex.z);
00436     initdata.xPencil(0,jb,thisIndex.z).recvTrans(msg);
00437   }
00438 }

void OptPmeYPencil::send_untrans (  ) 

Definition at line 587 of file fftlib.C.

References PmeGrid::block2, OptPmePencil< CBase_OptPmeYPencil >::data, OptPmePencilInitMsgData::grid, OptPmePencil< CBase_OptPmeYPencil >::initdata, j, PmeGrid::K2, OptPmeFFTMsg::nx, PRIORITY_SIZE, OptPmeFFTMsg::qgrid, OptPmePencil< CBase_OptPmeYPencil >::send_order, OptPmeFFTMsg::sourceNode, OptPmePencilInitMsgData::yBlocks, and OptPmePencilInitMsgData::zPencil.

00587                                  {
00588   //printf ("%d, %d: In ypencil send_untrans called once \n", thisIndex.x, thisIndex.z);
00589 
00590   int yBlocks = initdata.yBlocks;
00591   int block2 = initdata.grid.block2;
00592   int K2 = initdata.grid.K2;
00593 
00594   for ( int isend=0; isend<yBlocks; ++isend ) {
00595     int jb = send_order[isend];
00596     //if ( ! needs_reply[jb] ) continue;
00597     int ny = block2;
00598     if ( (jb+1)*block2 > K2 ) ny = K2 - jb*block2;
00599     OptPmeFFTMsg *msg = new (nx*ny*nz*2,PRIORITY_SIZE) OptPmeFFTMsg;
00600     msg->sourceNode = thisIndex.z;
00601     msg->nx = nz;
00602     float *md = msg->qgrid;
00603     const float *d = data;
00604     for ( int i=0; i<nx; ++i, d += K2*nz*2 ) {
00605      for ( int j=jb*block2; j<(jb*block2+ny); ++j ) {
00606       for ( int k=0; k<nz; ++k ) {
00607         *(md++) = d[2*(j*nz+k)];
00608         *(md++) = d[2*(j*nz+k)+1];
00609       }
00610      }
00611     }
00612 
00613     //printf ("%d, %d: Sending untrans to %d, %d\n", thisIndex.z, thisIndex.x, thisIndex.x, jb);
00614     initdata.zPencil(thisIndex.x,jb,0).recvUntrans(msg);
00615   }
00616 }


The documentation for this class was generated from the following files:
Generated on Wed Nov 22 01:17:21 2017 for NAMD by  doxygen 1.4.7