Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

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 ()

Constructor & Destructor Documentation

OptPmeYPencil_SDAG_CODE OptPmeYPencil::OptPmeYPencil  )  [inline]
 

Definition at line 139 of file fftlib.h.

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

OptPmeYPencil::OptPmeYPencil CkMigrateMessage *   )  [inline]
 

Definition at line 140 of file fftlib.h.

00140 { __sdag_init(); }


Member Function Documentation

void OptPmeYPencil::backward_fft  ) 
 

Definition at line 449 of file fftlib.C.

References OptPmePencilInitMsgData::grid, and PmeGrid::K2.

00449                                  {
00450 #ifdef NAMD_FFTW
00451   for ( int i=0; i<nx; ++i ) {
00452 #if CMK_BLUEGENEL
00453     CmiNetworkProgress();
00454 #endif
00455 
00456     fftw(backward_plan, nz,
00457          ((fftw_complex *) data) + i * nz * initdata.grid.K2,
00458          nz, 1, (fftw_complex *) work, 1, 0);
00459   }
00460 #endif
00461 }

void OptPmeYPencil::fft_init  ) 
 

Definition at line 62 of file fftlib.C.

References PmeGrid::block1, PmeGrid::block3, PmeGrid::dim2, PmeGrid::dim3, SimParameters::FFTWEstimate, OptPmePencilInitMsgData::grid, PmeGrid::K1, PmeGrid::K2, NAMD_die(), OptPmePencil< CBase_OptPmeYPencil >::order_init(), Node::simParameters, simParams, and OptPmePencilInitMsgData::yBlocks.

00062                              {
00063   CProxy_Node nd(CkpvAccess(BOCclass_group).node);
00064   Node *node = nd.ckLocalBranch();
00065   SimParameters *simParams = node->simParameters;
00066 
00067   //  printf ("Initialize ypencil [%d,%d], on pd %d\n", thisIndex.x, thisIndex.y, CkMyPe());
00068 
00069   int K1 = initdata.grid.K1;
00070   int K2 = initdata.grid.K2;
00071   int dim2 = initdata.grid.dim2;
00072   int dim3 = initdata.grid.dim3;
00073   int block1 = initdata.grid.block1;
00074   int block3 = initdata.grid.block3;
00075 
00076   nx = block1;
00077   if ( (thisIndex.x + 1) * block1 > K1 ) nx = K1 - thisIndex.x * block1;
00078   nz = block3;
00079   if ( (thisIndex.z+1)*block3 > dim3/2 ) nz = dim3/2 - thisIndex.z*block3;
00080 
00081   data = new float[nx*dim2*nz*2];
00082   many_to_many_data = new float[nx*dim2*nz*2];
00083   many_to_many_nb = new int [initdata.yBlocks];
00084   work = new float[2*K2];
00085 
00086   memset(many_to_many_data, 0, sizeof(float) * nx*dim2*nz*2);
00087 
00088   order_init(initdata.yBlocks);
00089 
00090 #ifdef NAMD_FFTW
00091   CmiLock(fftw_plan_lock);
00092 
00093   forward_plan = fftw_create_plan_specific(K2, FFTW_FORWARD,
00094         ( simParams->FFTWEstimate ? FFTW_ESTIMATE : FFTW_MEASURE )
00095         | FFTW_IN_PLACE | FFTW_USE_WISDOM, (fftw_complex *) data,
00096         nz, (fftw_complex *) work, 1);
00097   backward_plan = fftw_create_plan_specific(K2, FFTW_BACKWARD,
00098         ( simParams->FFTWEstimate ? FFTW_ESTIMATE : FFTW_MEASURE )
00099         | FFTW_IN_PLACE | FFTW_USE_WISDOM, (fftw_complex *) data,
00100         nz, (fftw_complex *) work, 1);
00101 
00102   CmiUnlock(fftw_plan_lock);
00103 #else
00104   NAMD_die("Sorry, FFTW must be compiled in to use PME.");
00105 #endif
00106 
00107   handle = NULL; 
00108 #if CHARM_VERSION > 60000
00109   handle = CmiDirect_manytomany_allocate_handle();
00110 #endif
00111   initialize_manytomany();
00112 }

void OptPmeYPencil::forward_fft  ) 
 

Definition at line 308 of file fftlib.C.

References OptPmePencilInitMsgData::grid, and PmeGrid::K2.

00308                                 {
00309 #ifdef NAMD_FFTW
00310   for ( int i=0; i<nx; ++i ) {
00311     fftw(forward_plan, nz,
00312          ((fftw_complex *) data) + i * nz * initdata.grid.K2,
00313          nz, 1, (fftw_complex *) work, 1, 0);
00314   }
00315 #endif
00316 }

void OptPmeYPencil::many_to_many_recv_trans  ) 
 

Definition at line 663 of file fftlib.C.

References PmeGrid::block2, OptPmePencilInitMsgData::grid, j, PmeGrid::K2, and OptPmePencilInitMsgData::yBlocks.

00663                                              {  
00664   int block2 = initdata.grid.block2;
00665   int K2 = initdata.grid.K2;
00666   
00667   const float *md = many_to_many_data;
00668   for (int jb = 0; jb < initdata.yBlocks; jb++ ) {
00669     int ny = many_to_many_nb[jb];  
00670     float *d = data;
00671     for ( int i=0; i<nx; ++i, d += K2*nz*2 ) {
00672       for ( int j=jb*block2; j<(jb*block2+ny); ++j ) {
00673         for ( int k=0; k<nz; ++k ) {
00674           d[2*(j*nz+k)] = *(md++);
00675           d[2*(j*nz+k)+1] = *(md++);
00676         }
00677       }
00678     }
00679   }
00680 }

void OptPmeYPencil::many_to_many_recv_untrans  ) 
 

Definition at line 755 of file fftlib.C.

References PmeGrid::block2, OptPmePencilInitMsgData::grid, j, PmeGrid::K2, and OptPmePencilInitMsgData::yBlocks.

00755                                                {  
00756   int block2 = initdata.grid.block2;
00757   int K2 = initdata.grid.K2;
00758   
00759   const float *md = many_to_many_data;
00760   for (int jb = 0; jb < initdata.yBlocks; jb++ ) {
00761     int ny = many_to_many_nb[jb];  
00762     float *d = data;
00763     for ( int i=0; i<nx; ++i, d += K2*nz*2 ) {
00764       for ( int j=jb*block2; j<(jb*block2+ny); ++j ) {
00765         for ( int k=0; k<nz; ++k ) {
00766           d[2*(j*nz+k)] = *(md++);
00767           d[2*(j*nz+k)+1] = *(md++);
00768         }
00769       }
00770     }
00771   }
00772 }

void OptPmeYPencil::many_to_many_send int  phase  ) 
 

Definition at line 682 of file fftlib.C.

References PmeGrid::block2, OptPmePencilInitMsgData::grid, j, PmeGrid::K2, and OptPmePencilInitMsgData::yBlocks.

00682                                                {
00683   int yBlocks = initdata.yBlocks;
00684   int block2 = initdata.grid.block2;
00685   int K2 = initdata.grid.K2;
00686   
00687   float *md = many_to_many_data;
00688   int ny = block2;
00689   for ( int jb=0; jb<yBlocks; ++jb ) {
00690     ny = block2;
00691     if ( (jb+1)*block2 > K2 ) ny = K2 - jb*block2;
00692     
00693     const float *d = data;
00694     for ( int i=0; i<nx; ++i, d += K2*nz*2 ) {
00695       for ( int j=jb*block2; j<(jb*block2+ny); ++j ) {
00696         for ( int k=0; k<nz; ++k ) {
00697           *(md++) = d[2*(j*nz+k)];
00698           *(md++) = d[2*(j*nz+k)+1];
00699         }
00700       }
00701     }
00702   }
00703 
00704 #if CHARM_VERSION > 60000
00705   CmiDirect_manytomany_start (handle, phase);  
00706 #endif
00707 }

void OptPmeYPencil::recv_trans const OptPmeFFTMsg  ) 
 

Definition at line 290 of file fftlib.C.

References PmeGrid::block2, OptPmePencilInitMsgData::grid, j, PmeGrid::K2, OptPmeFFTMsg::nx, OptPmeFFTMsg::qgrid, and OptPmeFFTMsg::sourceNode.

00290                                                       {
00291 
00292   int block2 = initdata.grid.block2;
00293   int K2 = initdata.grid.K2;
00294   int jb = msg->sourceNode;
00295   int ny = msg->nx;
00296   const float *md = msg->qgrid;
00297   float *d = data;
00298   for ( int i=0; i<nx; ++i, d += K2*nz*2 ) {
00299     for ( int j=jb*block2; j<(jb*block2+ny); ++j ) {
00300       for ( int k=0; k<nz; ++k ) {
00301         d[2*(j*nz+k)] = *(md++);
00302         d[2*(j*nz+k)+1] = *(md++);
00303       }
00304     }
00305   }
00306 } 

void OptPmeYPencil::recv_untrans const OptPmeFFTMsg  ) 
 

Definition at line 429 of file fftlib.C.

References PmeGrid::block2, OptPmePencilInitMsgData::grid, j, PmeGrid::K2, OptPmeFFTMsg::nx, OptPmeFFTMsg::qgrid, and OptPmeFFTMsg::sourceNode.

00429                                                         {
00430 
00431   int block2 = initdata.grid.block2;
00432   int K2 = initdata.grid.K2;
00433   int jb = msg->sourceNode;
00434   int ny = msg->nx;
00435   const float *md = msg->qgrid;
00436   float *d = data;
00437   for ( int i=0; i<nx; ++i, d += K2*nz*2 ) {
00438     for ( int j=jb*block2; j<(jb*block2+ny); ++j ) {
00439       for ( int k=0; k<nz; ++k ) {
00440         d[2*(j*nz+k)] = *(md++);
00441         d[2*(j*nz+k)+1] = *(md++);
00442       }
00443     }
00444   }
00445 } 

void OptPmeYPencil::send_trans  ) 
 

Definition at line 318 of file fftlib.C.

References PmeGrid::block2, OptPmePencilInitMsgData::grid, j, PmeGrid::K2, OptPmeFFTMsg::nx, OptPmeFFTMsg::qgrid, OptPmeFFTMsg::sourceNode, OptPmePencilInitMsgData::xPencil, and OptPmePencilInitMsgData::yBlocks.

00318                                {
00319   int yBlocks = initdata.yBlocks;
00320   int block2 = initdata.grid.block2;
00321   int K2 = initdata.grid.K2;
00322   
00323   for ( int isend=0; isend<yBlocks; ++isend ) {
00324     int jb = send_order[isend];
00325     int ny = block2;
00326     if ( (jb+1)*block2 > K2 ) ny = K2 - jb*block2;
00327     OptPmeFFTMsg *msg = new (nx*ny*nz*2,PRIORITY_SIZE) OptPmeFFTMsg;
00328     msg->sourceNode = thisIndex.x;
00329     msg->nx = nx;
00330     float *md = msg->qgrid;
00331     const float *d = data;
00332     for ( int i=0; i<nx; ++i, d += K2*nz*2 ) {
00333       for ( int j=jb*block2; j<(jb*block2+ny); ++j ) {
00334         for ( int k=0; k<nz; ++k ) {
00335           *(md++) = d[2*(j*nz+k)];
00336           *(md++) = d[2*(j*nz+k)+1];
00337         }
00338       }
00339     }
00340     if ( md != msg->qgrid + nx*ny*nz*2 ) CkPrintf("error in YX at %d %d %d\n",
00341                                                   thisIndex.x, jb, thisIndex.z);
00342     
00343     //printf ("%d, %d: Ypencil Sending trans to %d, %d\n", thisIndex.z, thisIndex.x, jb, thisIndex.z);
00344     initdata.xPencil(0,jb,thisIndex.z).recvTrans(msg);
00345   }
00346 }

void OptPmeYPencil::send_untrans  ) 
 

Definition at line 463 of file fftlib.C.

References PmeGrid::block2, OptPmePencilInitMsgData::grid, j, PmeGrid::K2, OptPmeFFTMsg::nx, OptPmeFFTMsg::qgrid, OptPmeFFTMsg::sourceNode, OptPmePencilInitMsgData::yBlocks, and OptPmePencilInitMsgData::zPencil.

00463                                  {
00464   //printf ("%d, %d: In ypencil send_untrans called once \n", thisIndex.x, thisIndex.z);
00465 
00466   int yBlocks = initdata.yBlocks;
00467   int block2 = initdata.grid.block2;
00468   int K2 = initdata.grid.K2;
00469 
00470   for ( int isend=0; isend<yBlocks; ++isend ) {
00471     int jb = send_order[isend];
00472     //if ( ! needs_reply[jb] ) continue;
00473     int ny = block2;
00474     if ( (jb+1)*block2 > K2 ) ny = K2 - jb*block2;
00475     OptPmeFFTMsg *msg = new (nx*ny*nz*2,PRIORITY_SIZE) OptPmeFFTMsg;
00476     msg->sourceNode = thisIndex.z;
00477     msg->nx = nz;
00478     float *md = msg->qgrid;
00479     const float *d = data;
00480     for ( int i=0; i<nx; ++i, d += K2*nz*2 ) {
00481      for ( int j=jb*block2; j<(jb*block2+ny); ++j ) {
00482       for ( int k=0; k<nz; ++k ) {
00483         *(md++) = d[2*(j*nz+k)];
00484         *(md++) = d[2*(j*nz+k)+1];
00485       }
00486      }
00487     }
00488 
00489     //printf ("%d, %d: Sending untrans to %d, %d\n", thisIndex.z, thisIndex.x, thisIndex.x, jb);
00490     initdata.zPencil(thisIndex.x,jb,0).recvUntrans(msg);
00491   }
00492 }


The documentation for this class was generated from the following files:
Generated on Mon Nov 23 05:00:03 2009 for NAMD by  doxygen 1.3.9.1