19 #include "src_piny_physics_v1.0/include/class_defs/Interface_ctrl.h"
20 #include "PhysScratchCache.h"
24 #include "src_piny_physics_v1.0/include/class_defs/CP_OPERATIONS/class_cpnonlocal.h"
25 #include "src_piny_physics_v1.0/include/class_defs/CP_OPERATIONS/class_cplocal.h"
26 #include "src_piny_physics_v1.0/include/class_defs/CP_OPERATIONS/class_cpintegrate.h"
31 extern CkVec <CProxy_CP_State_ParticlePlane> UparticlePlaneProxy;
32 extern CkVec <CProxy_CP_State_RealParticlePlane> UrealParticlePlaneProxy;
33 extern CkVec <CProxy_CP_Rho_RHartExt> UrhoRHartExtProxy;
34 extern CkVec <CProxy_CP_Rho_GHartExt> UrhoGHartExtProxy;
35 extern CProxy_PhysScratchCache pScratchProxy;
36 extern CkVec <CProxy_AtomsCache> UatomsCacheProxy;
37 extern CkVec <CProxy_eesCache> UeesCacheProxy;
39 #define _EESCACHE_VERBOSE_OFF_
50 eesCache::eesCache(
int _nchareRPP,
int _nchareGPP,
int _nchareRHart,
51 int _nchareGHart,
int _nstates,
int _nchareRhoG,
int _nkpoint,
63 nchareRPP = _nchareRPP;
64 nchareGPP = _nchareGPP;
65 nchareRHart = _nchareRHart;
66 nchareGHart = _nchareGHart;
67 nchareGSP = _nchareGPP;
68 nchareRhoG = _nchareRhoG;
78 gspStateInd =
new int [nMallSize];
79 gspPlaneInd =
new int [nMallSize];
81 allowedRppChares =
new int[nchareRPP];
82 allowedGppChares =
new int[nchareGPP];
83 allowedRhoRHartChares =
new int[nchareRHart];
84 allowedRhoGHartChares =
new int[nchareGHart];
85 allowedGspChares =
new int[nchareGSP];
86 allowedRhoGChares =
new int[nchareRhoG];
88 for(
int i=0;i<nchareRPP ;i++){allowedRppChares[i] = 0;}
89 for(
int i=0;i<nchareGPP ;i++){allowedGppChares[i] = 0;}
90 for(
int i=0;i<nchareRHart;i++){allowedRhoRHartChares[i] = 0;}
91 for(
int i=0;i<nchareGHart;i++){allowedRhoGHartChares[i] = 0;}
92 for(
int i=0;i<nchareGSP; i++){allowedGspChares[i] = 0;}
93 for(
int i=0;i<nchareRhoG ;i++){allowedRhoGChares[i] = 0;}
95 indGppChares =
new int[nchareGPP];
96 indRppChares =
new int[nchareRPP];
97 indRhoRHartChares =
new int[nchareRHart];
98 indRhoGHartChares =
new int[nchareGHart];
99 indGspChares =
new int[nchareGSP];
100 indRhoGChares =
new int[nchareRhoG];
102 GppData =
new GPPDATA * [nchareGPP];
103 RppData =
new RPPDATA * [nchareRPP];
106 GspData =
new GSPDATA*[nchareGSP];
122 if(allowedRppChares[index]==0){
124 allowedRppChares[index] = 1;
125 RppData[index] =
new RPPDATA();
126 RppData[index]->
init(index);
142 if(allowedGppChares[index]==0){
144 allowedGppChares[index] = 1;
145 GppData[index] =
new GPPDATA();
146 GppData[index]->
init(nkpoint,index,ncoef,ka,kb,kc);
162 if(allowedRhoRHartChares[index]==0){
163 #ifdef _EESCACHE_VERBOSE_
164 CkPrintf(
"Registering Rhart %d\n",index);
166 nchareRHartProc += 1;
167 allowedRhoRHartChares[index] = 1;
169 RhoRHartData[index]->
init(index);
185 if(allowedRhoGHartChares[index]==0){
186 nchareGHartProc += 1;
187 allowedRhoGHartChares[index] = 1;
189 RhoGHartData[index]->
init(index,ncoef,ka,kb,kc);
199 void eesCache::registerCacheGSP(
int is ,
int ip){
201 if(allowedGspChares[ip]==0){
203 allowedGspChares[ip] = 1;
205 GspData[ip]->
init(ip,nkpoint);
208 int i = nchareGSPProcT;
210 CkPrintf(
"Bad Mall size in registerCacheGSP %d %d\n",nMallSize,i);
218 if(2*nchareGSPProcT >= nMallSize){
220 int *tempS =
new int [nMallSize];
221 int *tempP =
new int [nMallSize];
222 for(
int j=0;j<nchareGSPProcT;j++){
223 tempS[j] = gspStateInd[j];
224 tempP[j] = gspPlaneInd[j];
226 delete [] gspStateInd;
227 delete [] gspPlaneInd;
242 #define _CP_BRK_BETTER_OFF // must flip cp_ees_nonlocal.h too
244 CPNONLOCAL::getEesPrms(&ngrid_a,&ngrid_b,&ngrid_c,&n_interp,&natm);
247 int n_interp2 = n_interp*n_interp;
249 plane_index = (
int *)fftw_malloc(natm*
sizeof(
int));
250 nBreakJ = (
int *)fftw_malloc(natm*
sizeof(
int));
252 igrid = (
int **)fftw_malloc(natm*
sizeof(
int*));
253 #ifdef _CP_BRK_BETTER_
254 sBreakJ = (
int **)fftw_malloc(natm*
sizeof(
int*));
256 mn = (
double **)fftw_malloc(natm*
sizeof(
double*));
257 dmn_x = (
double **)fftw_malloc(natm*
sizeof(
double*));
258 dmn_y = (
double **)fftw_malloc(natm*
sizeof(
double*));
259 dmn_z = (
double **)fftw_malloc(natm*
sizeof(
double*));
260 for(
int i=0;i<natm;i++){
261 igrid[i] = (
int *)fftw_malloc(n_interp2*
sizeof(
int))-1;
262 #ifdef _CP_BRK_BETTER_
263 sBreakJ[i] = (
int *)fftw_malloc((n_interp2+1)*
sizeof(int))-1;
265 double *tmp = (
double *)fftw_malloc(4*n_interp2*
sizeof(
double));
267 mn[i] = &tmp[ioff]-1; ioff+=n_interp2;
268 dmn_x[i] = &tmp[ioff]-1; ioff+=n_interp2;
269 dmn_y[i] = &tmp[ioff]-1; ioff+=n_interp2;
270 dmn_z[i] = &tmp[ioff]-1;
282 void GPPDATA::init(
int nkpoint_in,
int index_in,
int ncoef_in,
int *ka,
int *kb,
int *kc){
284 nkpoint = nkpoint_in;
287 b_re = (
double *)fftw_malloc((ncoef+1)*
sizeof(double));
288 b_im = (
double *)fftw_malloc((ncoef+1)*
sizeof(double));
290 h_gspl = cmall_mat(0,nkpoint,0,ncoef,
"CPPDATA:init");
291 ind_gspl = cmall_int_mat(0,nkpoint,0,ncoef,
"CPPDATA:init");
293 CPNONLOCAL::getEesPrms(&ngrid_a,&ngrid_b,&ngrid_c,&n_interp,&natm);
294 CPNONLOCAL::eesSetEesWghtGgrp(ncoef,ka,kb,kc,b_re,b_im,ngrid_a,ngrid_b,ngrid_c,
296 CPNONLOCAL::eesSplProjectorGgrp(ncoef,ka,kb,kc,h_gspl,ind_gspl);
312 rhoRsubplanes = config.rhoRsubplanes;
314 CPLOCAL::getEesPrms(&ngrid_a,&ngrid_b,&ngrid_c,&n_interp,&natm);
319 subStr = (
int *)fftw_malloc(rhoRsubplanes*
sizeof(
int));
320 subEnd = (
int *)fftw_malloc(rhoRsubplanes*
sizeof(
int));
321 subSiz = (
int *)fftw_malloc(rhoRsubplanes*
sizeof(
int));
322 ntemp = (
int *)fftw_malloc(rhoRsubplanes*
sizeof(
int));
323 itemp = (
int **)fftw_malloc(rhoRsubplanes*
sizeof(
int*));
324 for(
int s=0;s<rhoRsubplanes;s++){itemp[s] = (
int *)fftw_malloc(n_interp*
sizeof(
int))-1;}
326 for(
int s=0; s<rhoRsubplanes; s++){
327 int div = (ngrid_b / rhoRsubplanes);
328 int rem = (ngrid_b % rhoRsubplanes);
329 int add = (s < rem ? 1 : 0);
330 int max = (s < rem ? s : rem);
331 subStr[s] = div*s + max;
332 subSiz[s] = div + add;
333 subEnd[s] = subStr[s] + subSiz[s];
339 plane_index = (
int *)fftw_malloc(natm*
sizeof(
int));
341 nSub = (
int **)fftw_malloc(rhoRsubplanes*
sizeof(
int *));
342 igrid = (
int ***)fftw_malloc(rhoRsubplanes*
sizeof(
int **));
343 mn = (
double ***)fftw_malloc(rhoRsubplanes*
sizeof(
double**));
344 dmn_x = (
double ***)fftw_malloc(rhoRsubplanes*
sizeof(
double**));
345 dmn_y = (
double ***)fftw_malloc(rhoRsubplanes*
sizeof(
double**));
346 dmn_z = (
double ***)fftw_malloc(rhoRsubplanes*
sizeof(
double**));
348 int n_interp21 = n_interp*n_interp+1;
349 for(
int s=0;s<rhoRsubplanes;s++){
350 nSub[s] = (
int *)fftw_malloc (natm*
sizeof(
int *));
351 igrid[s] = (
int **)fftw_malloc(natm*
sizeof(
int *));
352 mn[s] = (
double **)fftw_malloc(natm*
sizeof(
double*));
353 dmn_x[s] = (
double **)fftw_malloc(natm*
sizeof(
double*));
354 dmn_y[s] = (
double **)fftw_malloc(natm*
sizeof(
double*));
355 dmn_z[s] = (
double **)fftw_malloc(natm*
sizeof(
double*));
356 for(
int i=0;i<natm;i++){
357 igrid[s][i] = (
int *)fftw_malloc(n_interp21*
sizeof(
int ))-1;
358 mn[s][i] = (
double *)fftw_malloc(n_interp21*
sizeof(
double))-1;
359 dmn_x[s][i] = (
double *)fftw_malloc(n_interp21*
sizeof(
double))-1;
360 dmn_y[s][i] = (
double *)fftw_malloc(n_interp21*
sizeof(
double))-1;
361 dmn_z[s][i] = (
double *)fftw_malloc(n_interp21*
sizeof(
double))-1;
379 b_re = (
double *)fftw_malloc((ncoef+1)*
sizeof(double));
380 b_im = (
double *)fftw_malloc((ncoef+1)*
sizeof(double));
382 CPLOCAL::getEesPrms(&ngrid_a,&ngrid_b,&ngrid_c,&n_interp,&natm);
383 CPLOCAL::eesSetEesWghtGgrp(ncoef,ka,kb,kc,b_re,b_im,ngrid_a,ngrid_b,ngrid_c,
398 if(itime != itimeRPP && iter==1){
400 if(itime!=itimeRPP+1 || iter != 1 || allowedRppChares[index]!=1){
401 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
402 CkPrintf(
"Broken RPP cache query by %d at %d %d %d\n",index,itime,itimeRPP,iter);
403 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
408 #ifdef _EESCACHE_VERBOSE_
409 CkPrintf(
"HI, I am rPP %d in query : %d\n",index,iter);
412 AtomsCache *ag = UatomsCacheProxy[thisInstance.proxyOffset].ckLocalBranch();
415 CkAssert(fastAtoms!=NULL);
416 CkAssert(fastAtoms->x!=NULL);
417 #if CMK_TRACE_ENABLED
418 double StartTime=CmiWallTimer();
421 CPNONLOCAL::eesAtmBsplineRgrp(fastAtoms,allowedRppChares,RppData, pScratchProxy.ckLocalBranch()->psscratch);
423 #if CMK_TRACE_ENABLED
424 traceUserBracketEvent(eesAtmBspline_, StartTime, CmiWallTimer());
442 #ifdef _EESCACHE_VERBOSE_
443 CkPrintf(
"Querying Rhart by %d at t= %d %d\n",index,itime,itimeRHart);
446 if(itime != itimeRHart){
448 if(itime!=itimeRHart+1 || iter != 1 || allowedRhoRHartChares[index] != 1){
449 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
450 CkPrintf(
"Broken HartR cache query by %d at %d %d %d\n",index,itime,itimeRHart,iter);
451 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
456 #ifdef _EESCACHE_VERBOSE_
457 CkPrintf(
"Computing eesAtmBspline\n");
460 AtomsCache *ag = UatomsCacheProxy[thisInstance.proxyOffset].ckLocalBranch();
462 #if CMK_TRACE_ENABLED
463 double StartTime=CmiWallTimer();
466 CPLOCAL::eesAtmBsplineRgrp(fastAtoms,allowedRhoRHartChares,RhoRHartData, pScratchProxy.ckLocalBranch()->psscratch);
468 #if CMK_TRACE_ENABLED
469 traceUserBracketEvent(eesAtmBspline_, StartTime, CmiWallTimer());
492 ngrid_a = sim->sizeX;
493 ngrid_b = sim->sizeY;
494 ngrid_c = sim->sizeZ;
495 ncoef = sim->npts_per_chareG[index];
496 numLines = sim->nlines_per_chareG[index];
497 numRuns = 2*numLines;
498 nkpoint = nkpoint_in;
503 CkVec <RunDescriptor> *sortedRunDescriptors = sim->sortedRunDescriptors;
506 if(sortedRunDescriptors[x].size()!=numRuns){
507 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
508 CkPrintf(
"Broken run descriptor for plane %d : %d %d\n",
509 x,numRuns,sortedRunDescriptors[x].size());
510 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
513 for(
int j=0;j<numRuns;j++){runs[j] = sortedRunDescriptors[x][j];}
518 ka = (
int *)fftw_malloc(ncoef*
sizeof(
int));
519 kb = (
int *)fftw_malloc(ncoef*
sizeof(
int));
520 kc = (
int *)fftw_malloc(ncoef*
sizeof(
int));
521 g2 = cmall_mat(0,nkpoint,0,ncoef,
"eesCache.C");
522 g = cmall_mat(0,nkpoint,0,ncoef,
"eesCache.C");
524 CPNONLOCAL::genericSetKvector(ncoef,ka,kb,kc,numRuns,runs,&gCharePkg,1,
525 ngrid_a,ngrid_b,ngrid_c,g2,g);
530 int mydoublePack = config.doublePack;
531 coef_mass = (
double *)fftw_malloc(ncoef*
sizeof(
double));
532 CPINTEGRATE::CP_create_mass(ncoef,ka,kb,kc,coef_mass,mydoublePack);
void registerCacheRHart(int)
= RhoRhart Cache Management tool
holds the UberIndex and the offset for proxies
void queryCacheRHart(int, int, int)
= RhoGhart Cache Management tool
void init(int, int, int, int *, int *, int *)
= Initialize the GParticlePlane Cache Data class
void init(int)
= Initialize the RealParticlePlane Cache Data class
void init(int, int)
= Initialize the GstatePlane Cache Data class
void init(int, int, int *, int *, int *)
= Initialize the RhoGhart Cache Data class
Data class : Minimal copies of big redundant data sets.
void registerCacheGHart(int, int, int *, int *, int *)
= RhoGhart Cache Management tool
Add type declarations for simulationConstants class (readonly vars) and once class for each type of o...
void queryCacheRPP(int, int, int)
= realParticlePlane Cache Management tool
== Index logic for lines of constant x,y in gspace.
Some basic data structures and the array map classes are defined here.
void registerCacheGPP(int, int, int *, int *, int *)
= GParticlePlane Cache Management tool
void init(int)
= Initialize the RhoRhart Cache Data class
void registerCacheRPP(int)
= realParticlePlane Cache Management tool