11 #include "uber/Uber.h"
13 #ifndef _fftcacheslab_h_
14 #define _fftcacheslab_h_
18 #ifdef _CP_USE_BLAS_GATHER_
19 include
"src_mathlib/mathlib.h"
34 int numRuns, numLines;
43 int ngridaNL,ngridbNL,ngridcNL;
51 int nkx0,nkx0_uni,nkx0_red;
82 double *v0NHC,*a2NHC,*a4NHC;
87 GStateSlab() {packedPlaneData=NULL; packedPlaneDataTemp=NULL;
88 packedForceData=NULL; packedPlaneDataScr=NULL;
92 void initNHC(
int _len_nhc_cp,
int _num_nhc_cp,
int _nck_nhc_cp){
93 nck_nhc_cp = _nck_nhc_cp;
94 num_nhc_cp = _num_nhc_cp;
95 len_nhc_cp = _len_nhc_cp;
96 xNHC =
new double **[nck_nhc_cp];
97 xNHCP =
new double **[nck_nhc_cp];
98 vNHC =
new double **[nck_nhc_cp];
99 fNHC =
new double **[nck_nhc_cp];
100 for(
int k = 0;k<nck_nhc_cp;k++){
101 xNHC[k] =
new double *[num_nhc_cp];
102 xNHCP[k] =
new double *[num_nhc_cp];
103 vNHC[k] =
new double *[num_nhc_cp];
104 fNHC[k] =
new double *[num_nhc_cp];
105 for(
int i=0;i<num_nhc_cp;i++){
106 xNHC[k][i] =
new double[len_nhc_cp];
107 xNHCP[k][i] =
new double[len_nhc_cp];
108 vNHC[k][i] =
new double[len_nhc_cp];
109 fNHC[k][i] =
new double[len_nhc_cp];
112 degFreeSplt =
new double[nck_nhc_cp];
113 istrNHC =
new int [nck_nhc_cp];
114 iendNHC =
new int [nck_nhc_cp];
115 mNHC =
new double[len_nhc_cp];
116 v0NHC =
new double[num_nhc_cp];
117 a2NHC =
new double[num_nhc_cp];
118 a4NHC =
new double[num_nhc_cp];
119 for(
int k=0;k<nck_nhc_cp;k++){
120 for(
int i=0;i<num_nhc_cp;i++){
121 for(
int j=0;j<len_nhc_cp;j++){
123 xNHCP[k][i][j] = 0.0;
130 for(
int k=0;k<nck_nhc_cp;k++){
131 for(
int i=0;i<num_nhc_cp;i++){
133 delete []xNHCP[k][i];
146 delete []degFreeSplt;
155 void setKRange(
int ,
int *,
int *,
int *);
156 void addForces(
complex *,
const int *);
174 int numPlanesToExpect;
181 void zeroOutPlanes();
199 int sizeX, sizeY, sizeZ;
203 double exc_ret, muxc_ret, exc_gga_ret;
207 double *rhoIRX,*rhoIRY,*rhoIRZ;
217 complex *rhoIRXC,*rhoIRYC,*rhoIRZC;
225 sizeX=sizeY=sizeZ=size=trueSize=0;
226 exc_ret=muxc_ret=exc_gga_ret=0.0;
242 void uPackScaleGrow(
double *,
double *,
double );
243 void uPackScaleShrink(
double *,
double *,
double );
244 void uPackShrink(
double *,
double *);
245 void uPackScale(
double *,
double *,
double );
246 void scale(
double *,
double );
261 int sizeX, sizeY, sizeZ;
280 int *k_x, *k_y, *k_z;
283 double ehart_ret, eext_ret, ewd_ret;
287 int xdim, ydim, zdim;
290 sizeX= sizeY= sizeZ=runsToBeSent= numRuns= numLines=numFull=0;
291 numPoints= nPacked=size=xdim=ydim= zdim=0;
314 void pup(PUP::er &p);
327 double *work1, *work2;
343 double *work1, *work2;
360 double *work1, *work2;
361 rfftwnd_plan rfftwPlan;
399 char cacheMemName[1000];
400 static CmiNodeLock fftw_plan_lock;
438 FFTcache(
int _ngrida,
int _ngridb,
int _ngridc,
439 int _ngridaEext,
int _ngridbEext,
int _ngridcEext,
440 int _ees_eext_on,
int _ngridaNL,
int _ngridbNL,
int _ngridcNL,
441 int _ees_NL_on,
int _nlines_max,
int _nlines_max_rho,
442 int _nchareGState,
int _nchareRState,
443 int _nchareGNL,
int _nchareRNL,
444 int _nchareGRho,
int _nchareRRho,
int _nchareRRhoTot,
445 int _nchareGEext,
int _nchareREext,
int _nchareREextTot,
446 int *numGState,
int *numRXState,
int *numRYState,
int *numRYStateLower,
447 int *numGNL,
int *numRXNL,
int *numRYNL,
int *numRYNLLower,
448 int *numGRho,
int *numRXRho,
int *numRYRho ,
449 int *numGEext,
int *numRXEext,
int *numRYEext ,
450 int _fftopt,
int _nsplitR,
int _nsplitG,
454 void getCacheMem(
const char *name){
456 CkPrintf(
"%s stealing from %s\n",cacheMemName,name);
460 strcpy(cacheMemName,name);
462 void freeCacheMem(
const char *name){
464 CkPrintf(
"Bad cache memory free from %s\n",name);
474 int numPoints,
int nfftz);
477 int numPoints,
int nfftz);
537 index.x = info.index.x; index.y = info.index.y;
538 numPoints = info.numPoints;
539 numPlanes = info.numPlanes;
541 GSlabInfo(CkIndex2D idx,
int _numPoints,
int _numPlanes){
542 index.x = idx.x; index.y = idx.x;
543 numPoints = _numPoints;
544 numPlanes = _numPlanes;
556 int realSpaceUnits,
int s_grain,
int iplane_ind,
int istate_ind,
557 int len_nhc_cp,
int num_nhc_cp,
int nck_nhc_cp);
559 int gSpaceUnits,
int realSpaceUnits,
int stateIndex,
int thisPlane);
560 void initRhoRealSlab(
RhoRealSlab *rho_rs,
int xdim,
int ydim,
int zdim,
561 int xdimA,
int ydimA,
int myIndexX,
int myIndexY,
568 fftw_complex *in,
int istride,
int idist,
569 fftw_complex *out,
int ostride,
int odist,
int split,
int index);
572 fftw_complex *in,
int istride,
int idist,
573 fftw_real *out,
int ostride,
int odist,
int split,
int index);
576 fftw_real *in,
int istride,
int idist,
577 fftw_complex *out,
int ostride,
int odist,
int split,
int index);
579 void initFFTholder (
FFTplanHolder *,
int *,
int *,
int *,
double *,
int *,
int *,
int *,
int *,
581 void initRCFFTholder(
RFFTplanHolder *,
int *,
int *,
int *,
double *,
int *,
int *,
int *,
int *,
583 void initCRFFTholder(
RFFTplanHolder *,
int *,
int *,
int *,
double *,
int *,
int *,
int *,
int *,
585 void make_essl_work_map(
int ,
int *,
int *,
int *,
int *,
int *,
int *,
int);
void doNlFFTRtoG_Rchare(complex *, double *, int, int, int, int)
non-local : Rchare : data(x,y,z) -> data(gx,gy,z) : backward ////////////////////////////////////////...
void pup(PUP::er &)
= data
void rfftwnd_complex_to_real_split(RFFTplanHolder *rfftplanholder, int howmany, fftw_complex *in, int istride, int idist, fftw_real *out, int ostride, int odist, int split, int index)
split up an fft call into multiple invocations with cmiprogress calls between them.
holds the UberIndex and the offset for proxies
== Size or location in a regular 2D array
void doStpFFTGtoR_Gchare(complex *, complex *, int, int, int, int, RunDescriptor *, int, int)
StatePlane : Gchare : data(gx,gy,gz) -> data(gx,gy,z) : forward /////////////////////////////////////...
void doEextFFTGxToRx_Rchare(complex *, double *, int, int, int, int)
Eext : Rchare : data(gx,gy,z) -> data(x,y,z) : forward //////////////////////////////////////////////...
void doStpFFTRtoG_Rchare(complex *, double *, int, int, int, int)
////////////////////////////////////////////////////////////////////////////= ///////////////////////...
void doStpFFTRtoG_Gchare(complex *, complex *, int, int, int, int, RunDescriptor *, int, int)
StatePlane : Gchare : data(gx,gy,z) -> data(gx,gy,gz) : backward ////////////////////////////////////...
void initGStateSlab(GStateSlab *gs, int sizeX, int sizeY, int sizeZ, int gSpaceUnits, int realSpaceUnits, int s_grain, int iplane_ind, int istate_ind, int len_nhc_cp, int num_nhc_cp, int nck_nhc_cp)
= slab initialization helpers
GStateSlab()
= Constuctor, Destructor and utilities
void doStpFFTGtoR_Rchare(complex *, double *, int, int, int, int)
void doEextFFTGtoR_Gchare(complex *, complex *, int, int, int, int, RunDescriptor *, int, int)
Eext : Gchare : data(gx,gy,gz) -> data(gx,gy,z) : forward ///////////////////////////////////////////...
void setKRange(int, int *, int *, int *)
void doRhoFFTGtoR_Rchare(complex *, double *, int, int, int, int)
void rfftwnd_real_to_complex_split(RFFTplanHolder *rfftplanholder, int howmany, fftw_real *in, int istride, int idist, fftw_complex *out, int ostride, int odist, int split, int index)
split up an fft call into multiple invocations with cmiprogress calls between them.
= Holder classes for the plans : Allows many fft libaries to be used
void doEextFFTGtoR_Rchare(complex *, double *, int, int, int, int)
Eext : Rchare : data(gx,gy,z) -> data(x,y,z) : forward //////////////////////////////////////////////...
void doRhoFFTRxToGx_Rchare(complex *, double *, int, int, int, int)
void doEextFFTRtoG_Rchare(complex *, double *, int, int, int, int)
Eext : Rchare : data(x,y,z) -> data(gx,gy,z) : Backward /////////////////////////////////////////////...
void expandGSpace(complex *data, complex *packedData, RunDescriptor *runs, int numRuns, int numFull, int numPoints, int nfftz)
packed g-space of size numPoints is expanded to numFull =numRuns/2*nfftz ////////////////////////////...
void doNlFFTRtoG_Gchare(complex *, complex *, int, int, int, int, RunDescriptor *, int, int)
non-local : Gchare : data(gx,gy,z) -> data(gx,gy,gz) : backward /////////////////////////////////////...
void doRhoFFTGyToRy_Rchare(complex *, double *, int, int, int, int)
void createWhiteByrd(double *, double)
= packed g-space of size numPoints is expanded to numFull =numRuns/2*nfftz
void doEextFFTRtoG_Gchare(complex *, int, int, int, int, RunDescriptor *, int, int)
Eext : Gchare : data(gx,gy,z) -> data(gx,gy,gz) : backward //////////////////////////////////////////...
void doNlFFTGtoR_Rchare(complex *, double *, int, int, int, int)
non-local : Rchare : data(gx,gy,z) -> data(x,y,z) : Forward /////////////////////////////////////////...
struct essl_work ESSL_WORK
= Holder classes for the plans : Allows many fft libaries to be used
FFTcache(int _ngrida, int _ngridb, int _ngridc, int _ngridaEext, int _ngridbEext, int _ngridcEext, int _ees_eext_on, int _ngridaNL, int _ngridbNL, int _ngridcNL, int _ees_NL_on, int _nlines_max, int _nlines_max_rho, int _nchareGState, int _nchareRState, int _nchareGNL, int _nchareRNL, int _nchareGRho, int _nchareRRho, int _nchareRRhoTot, int _nchareGEext, int _nchareREext, int _nchareREextTot, int *numGState, int *numRXState, int *numRYState, int *numRYStateLower, int *numGNL, int *numRXNL, int *numRYNL, int *numRYNLLower, int *numGRho, int *numRXRho, int *numRYRho, int *numGEext, int *numRXEext, int *numRYEext, int _fftopt, int _nsplitR, int _nsplitG, int _rhoRsubPlanes, UberCollection _thisInstance)
= FFTcache - sets up a fftcache on each processor
void packGSpace(complex *data, complex *packedPlaneData, RunDescriptor *runs, int numRuns, int numFull, int numPoints, int nfftz)
packed g-space of size numPoints is expanded to numFull =numRuns/2*nfftz ////////////////////////////...
== Index logic for lines of constant x,y in gspace.
void fft_split(FFTplanHolder *fftplanholder, int howmany, fftw_complex *in, int istride, int idist, fftw_complex *out, int ostride, int odist, int split, int index)
= Eric's really cool BG/L progress callers
void divRhoGdot(double *, double, complex *)
= packed g-space of size numPoints is expanded to numFull =numRuns/2*nfftz
void doRhoFFTRtoG_Gchare(complex *, complex *, int, int, int, int, RunDescriptor *, int, int, int)
Rho Plane : Gchare : data(gx,gy,z) -> data(gx,gy,gz) : backward /////////////////////////////////////...
void doRhoFFTGtoR_Gchare(complex *, complex *, int, int, int, int, RunDescriptor *, int, int, int)
rho Gchare : data(gx,gy,gz) -> data(gx,gy,z) : forward //////////////////////////////////////////////...
void doEextFFTRxToGx_Rchare(complex *, double *, int, int, int, int)
Eext : Rchare : data(x,y,z) -> data(gx,gy,z) : Backward /////////////////////////////////////////////...
void doEextFFTGyToRy_Rchare(complex *, double *, int, int, int, int)
Eext : Rchare : data(gx,gy,z) -> data(x,y,z) : forward //////////////////////////////////////////////...
void initRealStateSlab(RealStateSlab *rs, int ngrid_a, int ngrid_b, int ngrid_c, int gSpaceUnits, int realSpaceUnits, int stateIndex, int thisPlane)
void doRhoFFTGxToRx_Rchare(complex *, double *, int, int, int, int)
void doRhoFFTRtoG_Rchare(complex *, double *, int, int, int, int)
void doNlFFTGtoR_Gchare(complex *, complex *, int, int, int, int, RunDescriptor *, int, int)
non-local : Gchare : data(gx,gy,gz) -> data(gx,gy,z) : forward //////////////////////////////////////...
void doEextFFTRyToGy_Rchare(complex *, double *, int, int, int, int)
Eext : Rchare : data(x,y,z) -> data(gx,gy,z) : Backward /////////////////////////////////////////////...
void doHartFFTGtoR_Gchare(complex *, complex *, int, int, int, int, RunDescriptor *, int, int)
Hartree : Gchare : data(gx,gy,gz) -> data(gx,gy,z) : forward ////////////////////////////////////////...
void doRhoFFTRyToGy_Rchare(complex *, double *, int, int, int, int)