fftlib.h

Go to the documentation of this file.
00001 
00002 #ifndef   __FFT_LIB_H__
00003 #define   __FFT_LIB_H__
00004 
00005 #include <cmidirectmanytomany.h>
00006 
00007 #define  MANY_TO_MANY_START  10
00008 #define  MANY_TO_MANY_SETUP  2
00009 
00010 #define  PHASE_YF  0   // Recv Y-Forward
00011 #define  PHASE_XF  1   // Recv X-Forward
00012 #define  PHASE_YB  2   // Recv Y-Backward
00013 #define  PHASE_ZB  3   // Recv Z-Backward
00014 #define  PHASE_GR  4   // Send Grid
00015 #define  PHASE_UG  5   // Recv Ungrid
00016 
00017 extern int many_to_many_start;
00018 
00019 class OptPmeGridMsg : public CMessage_OptPmeGridMsg {
00020 public:
00021   int sourceNode;
00022   int xstart;
00023   int xlen;
00024   int ystart;
00025   int ylen;
00026   int zstart;
00027   int zlen;
00028   int patchID;
00029   float *qgrid;
00030 };  //32 byte header on 32 bit architectures
00031 
00032 
00033 class OptPmeFFTMsg : public CMessage_OptPmeFFTMsg {
00034 public:
00035   int sourceNode;
00036   int nx;
00037   float *qgrid;
00038 };  //12 byte header on 32 bit architectures
00039 
00040 
00041 class OptPmeDummyMsg : public CMessage_OptPmeDummyMsg {
00042  public:
00043   int   to_pe;
00044 };
00045 
00046 // use this idiom since messages don't have copy constructors
00047 struct OptPmePencilInitMsgData {
00048   PmeGrid grid;
00049   int xBlocks, yBlocks, zBlocks;
00050   CProxy_OptPmeXPencil xPencil;
00051   CProxy_OptPmeYPencil yPencil;
00052   CProxy_OptPmeZPencil zPencil;
00053   CProxy_OptPmeMgr     pmeProxy;
00054   CkCallback           cb_energy;
00055   bool                 constant_pressure;
00056 };
00057 
00058 
00059 class OptPmePencilInitMsg : public CMessage_OptPmePencilInitMsg {
00060 public:
00061   OptPmePencilInitMsg(OptPmePencilInitMsgData &d) { data = d; }
00062   OptPmePencilInitMsgData data;
00063 };
00064 
00065 struct CkCallbackWrapper {
00066   CkCallback    cb;
00067   void        * msg;
00068   void        * array;
00069 };
00070 
00071 
00072 template <class T> class OptPmePencil : public T {
00073 public:
00074   OptPmePencil() {
00075     data = 0;
00076     work = 0;
00077     send_order = 0;
00078   }
00079   ~OptPmePencil() {
00080     delete [] data;
00081     delete [] work;
00082     delete [] send_order;
00083   }
00084   void base_init(OptPmePencilInitMsg *msg) {
00085     initdata = msg->data;
00086   }
00087   void order_init(int nBlocks) {
00088     send_order = new int[nBlocks];
00089     for ( int i=0; i<nBlocks; ++i ) send_order[i] = i;
00090     Random rand(CkMyPe());
00091     rand.reorder(send_order,nBlocks);
00092   }
00093   OptPmePencilInitMsgData initdata;
00094   Lattice lattice;
00095   PmeReduction evir;
00096   int imsg;  // used in sdag code
00097   int _iter; // used in sdag code
00098   float *data;
00099   float *many_to_many_data; //data in a differnt format
00100   int   *many_to_many_nb;
00101   float *work;
00102   int *send_order;
00103   void *handle;
00104   bool single_pencil;
00105 };
00106 
00107 
00108 class OptPmeZPencil : public OptPmePencil<CBase_OptPmeZPencil> {
00109 public:
00110     OptPmeZPencil_SDAG_CODE
00111     OptPmeZPencil() { __sdag_init(); setMigratable(false); }
00112     OptPmeZPencil(CkMigrateMessage *) { __sdag_init();  setMigratable (false); }
00113     void fft_init();
00114     void recv_grid(const OptPmeGridMsg *);
00115     void many_to_many_recv_grid();
00116     void forward_fft();
00117     void send_trans();
00118     void many_to_many_send_trans();
00119     void recv_untrans(const OptPmeFFTMsg *);
00120     void many_to_many_recv_untrans();
00121     void backward_fft();
00122     void send_ungrid(OptPmeGridMsg *);
00123     void many_to_many_send_ungrid ();
00124 private:
00125     ResizeArray<OptPmeGridMsg *> grid_msgs;
00126 #ifdef NAMD_FFTW
00127 #ifdef NAMD_FFTW_3
00128     fftwf_plan  forward_plan, backward_plan;
00129 #else
00130     rfftwnd_plan forward_plan, backward_plan;
00131 #endif
00132 #endif
00133     int nx, ny;
00134     PatchGridElem  * m2m_recv_grid;
00135     float          * many_to_many_gr_data;
00136     CkCallbackWrapper  cbw_recvgrid;
00137     CkCallbackWrapper  cbw_recvuntrans;
00138 
00139     void initialize_manytomany ();
00140 };
00141 
00142 class OptPmeYPencil : public OptPmePencil<CBase_OptPmeYPencil> {
00143 public:
00144     OptPmeYPencil_SDAG_CODE
00145     OptPmeYPencil() { __sdag_init(); setMigratable(false); }
00146     OptPmeYPencil(CkMigrateMessage *) { __sdag_init(); }
00147     void fft_init();
00148     void recv_trans(const OptPmeFFTMsg *);
00149     void forward_fft();
00150     void send_trans();
00151     void many_to_many_send(int phase);
00152     void recv_untrans(const OptPmeFFTMsg *);
00153     void many_to_many_recv_trans();
00154     void backward_fft();
00155     void send_untrans();
00156     void many_to_many_recv_untrans();   
00157 private:
00158 #ifdef NAMD_FFTW
00159 #ifdef NAMD_FFTW_3
00160     fftwf_plan  forward_plan, backward_plan;
00161 #else
00162     fftw_plan forward_plan, backward_plan;
00163 #endif
00164 #endif
00165     int nx, nz;
00166     CkCallbackWrapper  cbw_recvtrans;
00167     CkCallbackWrapper  cbw_recvuntrans;
00168 
00169     void initialize_manytomany ();
00170 };
00171 
00172 class OptPmeXPencil : public OptPmePencil<CBase_OptPmeXPencil> {
00173 public:
00174     OptPmeXPencil_SDAG_CODE
00175     OptPmeXPencil() { __sdag_init();  myKSpace = 0; setMigratable(false); }
00176     OptPmeXPencil(CkMigrateMessage *) { __sdag_init(); }
00177     void fft_init();
00178     void recv_trans(const OptPmeFFTMsg *);
00179     void many_to_many_recv_trans();     
00180     void forward_fft();
00181     void pme_kspace();
00182     void backward_fft();
00183     void send_untrans();
00184     void many_to_many_send_untrans();
00185     void submit_evir();
00186 #ifdef NAMD_FFTW
00187 #ifdef NAMD_FFTW_3
00188     fftwf_plan  forward_plan, backward_plan;
00189 #else
00190     fftw_plan forward_plan, backward_plan;
00191 #endif
00192 #endif
00193     int ny, nz;
00194     PmeKSpace *myKSpace;
00195     CkCallbackWrapper  cbw_recvtrans;
00196     bool               constant_pressure;
00197 
00198     SubmitReduction *reduction;
00199 
00200     void initialize_manytomany ();
00201 };
00202 
00203 #endif

Generated on Sat Nov 18 01:17:13 2017 for NAMD by  doxygen 1.4.7