48 #include "CP_State_ParticlePlane.h"
49 #include "CP_State_GSpacePlane.h"
52 #include "structure_factor/StructFactorCache.h"
58 #include "ckmulticast.h"
60 #include "src_piny_physics_v1.0/include/class_defs/CP_OPERATIONS/class_cpnonlocal.h"
61 #include "src_piny_physics_v1.0/include/class_defs/CP_OPERATIONS/class_cplocal.h"
62 extern CProxy_ENL_EKE_Collector ENLEKECollectorProxy;
65 extern CProxy_main mainProxy;
66 extern CProxy_InstanceController instControllerProxy;
67 extern CkVec <CProxy_CP_State_GSpacePlane> UgSpacePlaneProxy;
68 extern CkVec <CProxy_GSpaceDriver> UgSpaceDriverProxy;
69 extern CkVec <CProxy_AtomsCache> UatomsCacheProxy;
70 extern CkVec <CProxy_CP_State_ParticlePlane> UparticlePlaneProxy;
71 extern CkVec <CProxy_CP_State_RealParticlePlane> UrealParticlePlaneProxy;
72 extern CkVec <CProxy_StructFactCache> UsfCacheProxy;
73 extern CkVec <CProxy_eesCache> UeesCacheProxy;
74 extern CkVec <CProxy_FFTcache> UfftCacheProxy;
77 extern ComlibInstanceHandle gssPInstance;
95 void CP_State_ParticlePlane::CP_State_ParticlePlane::printEnl(CkReductionMsg *msg){
97 double d = ((
double *)msg->getData())[0];
100 ENLEKECollectorProxy[thisInstance.idxU.z].acceptENL(d);
103 UgSpacePlaneProxy[thisInstance.proxyOffset](0,0).computeEnergies(ENERGY_ENL, d);
114 CP_State_ParticlePlane::CP_State_ParticlePlane(
115 int x,
int y,
int z,
int xNL,
int yNL,
int zNL,
116 int _gSpacePPC,
int numSfGrps_in,
int natm_nl_in,
int natm_nl_grp_max_in,
117 int _nstates,
int _nchareG,
int _Gstates_per_pe,
int _numNLiter,
119 sizeX(x), sizeY(y), sizeZ(z), ngridaNL(xNL), ngridbNL(yNL), ngridcNL(zNL),
120 ees_nonlocal(_ees_nonlocal), nstates(_nstates), nchareG(_nchareG),
121 Gstates_per_pe(_Gstates_per_pe), numNLiter(_numNLiter),
122 gSpacePlanesPerChare(_gSpacePPC), thisInstance(_instance)
127 myChareG = thisIndex.y;
128 ibead_ind = thisInstance.idxU.x;
129 kpoint_ind = thisInstance.idxU.y;
130 itemper_ind = thisInstance.idxU.z;
140 istate_ind = thisIndex.x;
142 numSfGrps = numSfGrps_in;
143 natm_nl = natm_nl_in;
144 natm_nl_grp_max = natm_nl_grp_max_in;
145 count =
new int[numSfGrps];
146 haveSFAtmGrp =
new int[numSfGrps];
147 memset(haveSFAtmGrp,-1,numSfGrps*
sizeof(
int));
148 bzero(count,numSfGrps*
sizeof(
int));
150 zsize = numSfGrps*natm_nl_grp_max;
154 zmatrix_fx = NULL; zmatrix_fy = NULL; zmatrix_fz = NULL;
155 zmatrixSum_fx = NULL; zmatrixSum_fy = NULL; zmatrixSum_fz = NULL;
162 setMigratable(
false);
169 contribute(
sizeof(
int), &constructed, CkReduction::sum_int,
170 CkCallback(CkIndex_InstanceController::doneInit(NULL),CkArrayIndex1D(thisInstance.proxyOffset),instControllerProxy), thisInstance.proxyOffset);
171 #ifdef _CP_GS_DEBUG_COMPARE_VKS_
173 savedprojpsiBfsend=NULL;
174 savedprojpsiGBf=NULL;
191 if(ees_nonlocal == 1)
193 realPP_proxy = UrealParticlePlaneProxy[thisInstance.proxyOffset];
195 if (config.useGssInsRealPP)
196 ComlibAssociateProxy(gssPInstance,realPP_proxy);
204 #ifdef _CP_DEBUG_SF_CACHE_
205 CkPrintf(
"PP [%d,%d] has %d numSfGrps\n",thisIndex.x, thisIndex.y, numSfGrps);
207 StructFactCache *sfcache = UsfCacheProxy[thisInstance.proxyOffset].ckLocalBranch();
208 for(
int i=0;i<numSfGrps;i++){
209 #ifdef _CP_DEBUG_SF_CACHE_
210 CkPrintf(
"PP [%d,%d] registers grp %i with SFC[%d]\n",
211 thisIndex.x, thisIndex.y,i, CkMyPe());
213 sfcache->
registerPP(thisIndex.x, thisIndex.y,i);
226 int *red_pl =
new int[nstates];
227 int numProcs=CkNumPes();
228 int *usedProc=
new int[numProcs];
229 memset(usedProc,0,
sizeof(
int)*numProcs);
230 int charperpe=nstates/numProcs;
231 if(nstates%numProcs!=0) charperpe++;
232 if(charperpe<1) charperpe=1;
233 for(
int state=0; state<nstates;state++){
238 int thisstateplaneproc = GSImaptable[thisInstance.proxyOffset].get(state, plane)%numProcs;
239 if(usedProc[thisstateplaneproc]>=charperpe);
243 if(!used || plane==0)
246 (usedProc[thisstateplaneproc])++;
252 for(
int state=0; state<nstates;state++){
257 int thisstateplaneproc = GSImaptable[thisInstance.proxyOffset].get(state, plane)%CkNumPes();
258 if(usedProc[thisstateplaneproc]>=charperpe);
262 if(!used || (plane+1==nchareG))
264 usedProc[thisstateplaneproc]++;
271 reductionPlaneNum = red_pl[thisIndex.x];
277 if(thisIndex.x==0 && thisIndex.y==reductionPlaneNum){
279 CkArrayIndexMax *elems =
new CkArrayIndexMax[nstates];
281 CkArrayIndex2D idx(0, reductionPlaneNum);
282 for (
int j = 0; j < nstates; j++) {
284 idx.index[1] = red_pl[j];
289 particlePlaneENLProxy =
290 CProxySection_CP_State_ParticlePlane::ckNew(UparticlePlaneProxy[thisInstance.proxyOffset].ckGetArrayID(),
292 CkMulticastMgr *mcastGrp = CProxy_CkMulticastMgr(
mCastGrpId).ckLocalBranch();
293 particlePlaneENLProxy.ckDelegate(mcastGrp);
295 mcastGrp->setSection(particlePlaneENLProxy);
296 particlePlaneENLProxy.setEnlCookie(emsg);
302 GStateSlab *gss = &( UgSpacePlaneProxy[thisInstance.proxyOffset](thisIndex.x, thisIndex.y).ckLocal()->gs );
303 numLines = gss->numLines;
304 numFullNL = gss->numFullNL;
305 ees_nonlocal = gss->ees_nonlocal;
306 gSpaceNumPoints = gss->numPoints;
308 myForces = (
complex *)fftw_malloc(gSpaceNumPoints*
sizeof(
complex));
309 bzero(myForces,gSpaceNumPoints *
sizeof(
complex));
312 dyp_re = (
double *)fftw_malloc(gSpaceNumPoints*
sizeof(
double));
313 dyp_im = (
double *)fftw_malloc(gSpaceNumPoints*
sizeof(
double));
315 bzero(projPsiG, numFullNL *
sizeof(
complex));
319 registrationFlag = 0;
321 eesCache *eesData = UeesCacheProxy[thisInstance.proxyOffset].ckLocalBranch ();
322 int ncoef = gSpaceNumPoints;
323 int *k_x = eesData->GspData[myChareG]->ka;
324 int *k_y = eesData->GspData[myChareG]->kb;
325 int *k_z = eesData->GspData[myChareG]->kc;
326 int mycoef= eesData->GspData[myChareG]->ncoef;
327 if(eesData->allowedGspChares[myChareG]==0 || mycoef != ncoef){
328 CkPrintf(
"Plane %d of state %d toasy %d %d\n",myChareG,thisIndex.x,mycoef,ncoef);
333 CkCallback cb(CkIndex_CP_State_ParticlePlane::registrationDone(NULL),UparticlePlaneProxy[thisInstance.proxyOffset]);
334 contribute(
sizeof(
int),&i,CkReduction::sum_int,cb);
356 fftw_free(zmatrix_fx);
357 fftw_free(zmatrix_fy);
358 fftw_free(zmatrix_fz);
360 delete [] haveSFAtmGrp;
373 ArrayElement2D::pup(p);
375 p|ibead_ind; p|kpoint_ind; p|itemper_ind;
395 if (p.isUnpacking()) {
396 myForces = (
complex *)fftw_malloc(gSpaceNumPoints*
sizeof(
complex));
398 dyp_re = (
double *)fftw_malloc(gSpaceNumPoints*
sizeof(
double));
399 dyp_im = (
double *)fftw_malloc(gSpaceNumPoints*
sizeof(
double));
411 count =
new int[numSfGrps];
412 haveSFAtmGrp =
new int[numSfGrps];
415 p((
char*)myForces,gSpaceNumPoints*
sizeof(
complex));
417 p((
char*)projPsiG,numFullNL*
sizeof(
complex));
418 p(dyp_re,gSpaceNumPoints);
419 p(dyp_im,gSpaceNumPoints);
423 p(haveSFAtmGrp,numSfGrps);
424 p((
char*)zmatrixSum,zsize *
sizeof(
complex));
425 p((
char*)zmatrixSum_fx,zsize *
sizeof(
complex));
426 p((
char*)zmatrixSum_fy,zsize *
sizeof(
complex));
427 p((
char*)zmatrixSum_fz,zsize *
sizeof(
complex));
428 p((
char*)zmatrix,zsize *
sizeof(
complex));
429 p((
char*)zmatrix_fx,zsize *
sizeof(
complex));
430 p((
char*)zmatrix_fy,zsize *
sizeof(
complex));
431 p((
char*)zmatrix_fz,zsize *
sizeof(
complex));
436 p|gSpacePlanesPerChare;
445 p|particlePlaneENLProxy;
461 #ifdef _CP_DEBUG_STATE_GPP_VERBOSE_
462 CkPrintf(
"ParticlePlane[%d,%d] launching computeZs()\n",thisIndex.x,thisIndex.y);
464 for(
int i=0;i<config.numSfGrps;i++)
466 if(haveSFAtmGrp[i]>=0)
470 pmsg->sfindex = haveSFAtmGrp[i];
471 CkSetQueueing(pmsg, CK_QUEUEING_IFIFO);
472 *(
int*)CkPriorityPtr(pmsg) = config.sfpriority+i+config.numSfGrps;
474 thisProxy(thisIndex.x,thisIndex.y).computeZ(pmsg);
489 #ifdef _CP_DEBUG_STATE_GPP_VERBOSE_
491 CkPrintf(
"HI, I am gPP %d %d in computeZ \n",thisIndex.x,thisIndex.y);
495 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
496 CkPrintf(
"Homes, ees nonlocal is on. You can't call computeZ\n");
497 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
501 CP_State_GSpacePlane *gsp = UgSpacePlaneProxy[thisInstance.proxyOffset](thisIndex.x, thisIndex.y).ckLocal();
503 int atmIndex = m->atmGrp;
504 int sfindex = m->sfindex;
512 if(gsp->acceptedPsi && gsp->doneNewIter){
514 eesCache *eesData = UeesCacheProxy[thisInstance.proxyOffset].ckLocalBranch();
515 int *k_x = eesData->GspData[myChareG]->ka;
516 int *k_y = eesData->GspData[myChareG]->kb;
517 int *k_z = eesData->GspData[myChareG]->kc;
520 StructFactCache *sfcache = UsfCacheProxy[thisInstance.proxyOffset].ckLocalBranch();
521 complex *structureFactor,*structureFactor_fx,*structureFactor_fy,*structureFactor_fz;
522 sfcache->getStructFact(thisIndex.y, atmIndex, &structureFactor,
523 &structureFactor_fx, &structureFactor_fy, &structureFactor_fz);
529 memset(zmatrix, 0,
sizeof(
complex)*zsize);
530 memset(zmatrix_fx, 0,
sizeof(
complex)*zsize);
531 memset(zmatrix_fy, 0,
sizeof(
complex)*zsize);
532 memset(zmatrix_fz, 0,
sizeof(
complex)*zsize);
536 int mydoublePack = config.doublePack;
537 int zoffset = natm_nl_grp_max * atmIndex;
539 #if CMK_TRACE_ENABLED
540 double StartTime=CmiWallTimer();
543 CPNONLOCAL::CP_enl_matrix_calc(gSpaceNumPoints,gss->packedPlaneData, k_x,k_y,k_z,
544 structureFactor,structureFactor_fx,structureFactor_fy,
545 structureFactor_fz,&zmatrix[zoffset],&zmatrix_fx[zoffset],&zmatrix_fy[zoffset],
546 &zmatrix_fz[zoffset],thisIndex.x,mydoublePack,numSfGrps,atmIndex);
547 #if CMK_TRACE_ENABLED
548 traceUserBracketEvent(enlMatrixCalc_, StartTime, CmiWallTimer());
552 thisProxy(thisIndex.x, reductionPlaneNum).reduceZ(natm_nl_grp_max, atmIndex,
553 &zmatrix[zoffset],&zmatrix_fx[zoffset],&zmatrix_fy[zoffset],&zmatrix_fz[zoffset]);
555 haveSFAtmGrp[atmIndex]=-1;
561 haveSFAtmGrp[atmIndex]=sfindex;
583 #ifdef _CP_DEBUG_STATE_GPP_VERBOSE_
585 CkPrintf(
"HI, I am gPP %d %d in redZ \n",thisIndex.x,thisIndex.y);
589 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
590 CkPrintf(
"Homes, ees nonlocal is on. You can't call reduceZ\n");
591 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
597 int zoffset= natm_nl_grp_max * atmIndex;
598 if (zmatrixSum==NULL) {
600 memset(zmatrixSum, 0, zsize *
sizeof(
complex));
603 if (zmatrixSum_fx==NULL) {
605 memset(zmatrixSum_fx, 0, zsize *
sizeof(
complex));
608 if (zmatrixSum_fy==NULL) {
610 memset(zmatrixSum_fy, 0, zsize *
sizeof(
complex));
613 if (zmatrixSum_fz==NULL) {
615 memset(zmatrixSum_fz, 0, zsize *
sizeof(
complex));
618 for (i = 0,j=zoffset; i < size; i++,j++){
619 zmatrixSum[j] += zmatrix_[i];
620 zmatrixSum_fx[j] += zmatrix_fx_[i];
621 zmatrixSum_fy[j] += zmatrix_fy_[i];
622 zmatrixSum_fz[j] += zmatrix_fz_[i];
629 if( ((count[atmIndex] == (sizeX/gSpacePlanesPerChare)/2 - 1)&&(!config.doublePack)) ||
630 ((count[atmIndex] == nchareG)&&(config.doublePack)) ){
635 if(doneEnl==0){enl=0.0;}
640 AtomsCache *ag = UatomsCacheProxy[thisInstance.proxyOffset].ckLocalBranch();
642 int mydoublePack = config.doublePack;
645 #if CMK_TRACE_ENABLED
646 double StartTime=CmiWallTimer();
649 CPNONLOCAL::CP_enl_atm_forc_calc(numSfGrps,atmIndex,fastAtoms,&zmatrixSum[zoffset],
650 &zmatrixSum_fx[zoffset],&zmatrixSum_fy[zoffset],&zmatrixSum_fz[zoffset],
651 &myenl,mydoublePack,istate_ind);
652 #if CMK_TRACE_ENABLED
653 traceUserBracketEvent(enlAtmForcCalc_, StartTime, CmiWallTimer());
658 #ifdef _CP_DEBUG_NLMAT_
659 for (i = 0; i < zsize; i++){
660 CkPrintf(
"Non-local matrix[%d][%d]={%g, %g}\n",i,thisIndex.x,
661 zmatrix_[i].re,zmatrix_[i].im );}
667 for (i = 0; i < nchareG; i ++){
668 thisProxy(thisIndex.x, i).getForces(size,atmIndex, &zmatrixSum[zoffset]);
673 if(thisIndex.y==reductionPlaneNum && doneEnl==numSfGrps){
674 CkMulticastMgr *mcastGrp = CProxy_CkMulticastMgr(
mCastGrpId).ckLocalBranch();
676 CkCallback cb=CkCallback(CkIndex_CP_State_ParticlePlane::printEnl(NULL),CkArrayIndex2D(0,0), UparticlePlaneProxy[thisInstance.proxyOffset]);
677 mcastGrp->contribute(
sizeof(
double),(
void*) &enl,
678 CkReduction::sum_double, enlCookie, cb);
681 bzero(zmatrixSum, zsize *
sizeof(
complex));
682 bzero(zmatrixSum_fx, zsize *
sizeof(
complex));
683 bzero(zmatrixSum_fy, zsize *
sizeof(
complex));
684 bzero(zmatrixSum_fz, zsize *
sizeof(
complex));
707 #ifdef _CP_DEBUG_STATE_GPP_VERBOSE_
709 CkPrintf(
"HI, I am gPP %d %d in getforces \n",thisIndex.x,thisIndex.y);
712 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
713 CkPrintf(
"Homes, ees nonlocal is on. You can't call getForces\n");
714 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
723 CP_State_GSpacePlane *gsp = UgSpacePlaneProxy[thisInstance.proxyOffset](thisIndex.x, thisIndex.y).ckLocal();
725 eesCache *eesData = UeesCacheProxy[thisInstance.proxyOffset].ckLocalBranch();
726 StructFactCache *sfcache = UsfCacheProxy[thisInstance.proxyOffset].ckLocalBranch();
728 int mydoublePack = config.doublePack;
729 int state_ind = gss->istate_ind;
730 int *k_x = eesData->GspData[myChareG]->ka;
731 int *k_y = eesData->GspData[myChareG]->kb;
732 int *k_z = eesData->GspData[myChareG]->kc;
733 complex *structureFactor,*structureFactor_fx,*structureFactor_fy,*structureFactor_fz;
735 sfcache->getStructFact(thisIndex.y, atmIndex, &structureFactor, &structureFactor_fx,
736 &structureFactor_fy, &structureFactor_fz);
738 if (gSpaceNumPoints != 0){
740 #if CMK_TRACE_ENABLED
741 double StartTime=CmiWallTimer();
744 CPNONLOCAL::CP_enl_force_calc(zmatrixSum_loc,gSpaceNumPoints, k_x, k_y, k_z,
745 structureFactor,myForces,state_ind,mydoublePack,
746 numSfGrps, atmIndex);
747 #if CMK_TRACE_ENABLED
748 traceUserBracketEvent(enlForcCalc_, StartTime, CmiWallTimer());
756 if(doneForces==numSfGrps){
759 #ifdef BARRIER_CP_PARTICLEPLANE_NONLOCAL
761 contribute(
sizeof(
int),&nonLocDone,CkReduction::sum_int,
762 CkCallback(CkIndex_GSpaceDriver::allDoneNLForces(NULL),UgSpaceDriverProxy[thisInstance.proxyOffset]));
765 UgSpaceDriverProxy[thisInstance.proxyOffset](thisIndex.x,thisIndex.y).doneNLForces();
783 CkGetSectionInfo(enlCookie,m);
785 #ifdef _CP_DEBUG_STATE_GPP_VERBOSE_
786 CkPrintf(
"PP [%d %d] get enl cookie\n",thisIndex.x, thisIndex.y);
804 int nstatemax=nstates-1;
805 int ncharemax=nchareG-1;
806 int planeNum= state %ncharemax;
808 CkPrintf(
" PP [%d %d] calc nstatemax %d ncharemax %d state %d planenum %d\n",
809 thisIndex.x, thisIndex.y,nstatemax, ncharemax, state, planeNum);
823 if(thisIndex.x==0 && thisIndex.y==reductionPlaneNum){
824 CkMulticastMgr *mcastGrp = CProxy_CkMulticastMgr(
mCastGrpId).ckLocalBranch();
825 mcastGrp->resetSection(particlePlaneENLProxy);
837 int iteration_in=msg->iteration;
853 iterNL++;
if(iterNL==1){iteration++;}
856 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
857 CkPrintf(
"Duuuuude, natm_nl==0 don't start NL Ees\n");
858 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
863 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
864 CkPrintf(
"Yo dawg, ees nonlocal is off. You can't call startNLEes\n");
865 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
869 if(iteration!=iteration_in){
870 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
871 CkPrintf(
"Mismatch in time step between Gstate and Gpart %d %d for chare %d %d\n",
872 iteration_in,iteration,thisIndex.y,thisIndex.x);
873 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
877 if(iterNL>numNLiter){
878 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
879 CkPrintf(
"Too many non-local iterations encountered %d %d for Gchare %d %d\n",
880 iterNL,numNLiter,thisIndex.y,thisIndex.x);
881 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
885 if(iterNL>1 && registrationFlag==0){
886 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
887 CkPrintf(
"Why am I not registered! PP chare %d %d\n",thisIndex.x,thisIndex.y);
888 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
895 #ifdef _CP_DEBUG_STATE_GPP_VERBOSE_
897 CkPrintf(
"HI, I am gPP %d %d in startNLees : %d\n",thisIndex.x,thisIndex.y,iterNL);
905 if(iteration>config.maxIter){
907 CP_State_GSpacePlane *gsp = UgSpacePlaneProxy[thisInstance.proxyOffset](thisIndex.x,thisIndex.y).ckLocal();
910 #ifdef BARRIER_CP_PARTICLEPLANE_NONLOCAL
912 contribute(
sizeof(
int),&nonLocDone,CkReduction::sum_int,
913 CkCallback(CkIndex_GSpaceDriver::allDoneNLForces(NULL),UgSpaceDriverProxy[thisInstance.proxyOffset]));
916 UgSpaceDriverProxy[thisInstance.proxyOffset](thisIndex.x,thisIndex.y).doneNLForces();
936 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
937 CkPrintf(
"Yo dawg, ees nonlocal is off. You can't createNLEesFFTdata\n");
938 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
942 CP_State_GSpacePlane *gsp = UgSpacePlaneProxy[thisInstance.proxyOffset](thisIndex.x, thisIndex.y).ckLocal();
944 eesCache *eesData = UeesCacheProxy[thisInstance.proxyOffset].ckLocalBranch ();
945 FFTcache *fftcache = UfftCacheProxy[thisInstance.proxyOffset].ckLocalBranch();
950 double *d_re = eesData->GppData[myChareG]->b_re;
951 double *d_im = eesData->GppData[myChareG]->b_im;
952 int **ind_gspl = eesData->GppData[myChareG]->ind_gspl;
953 double **h_gspl= eesData->GppData[myChareG]->h_gspl;
954 int *k_x = eesData->GspData[myChareG]->ka;
955 int *k_y = eesData->GspData[myChareG]->kb;
956 int *k_z = eesData->GspData[myChareG]->kc;
958 int ncoef = gSpaceNumPoints;
959 complex *psi = gss->packedPlaneData;
960 int ihave_g0 = gss->ihave_g000;
961 int ind_g0 = gss->ind_g000;
963 #ifdef _CP_DEBUG_STATE_GPP_VERBOSE_
965 CkPrintf(
"HI, I am gPP %d %d in createNLEes : %d\n",thisIndex.x,thisIndex.y,iterNL);
968 fftcache->getCacheMem(
"CP_State_ParticlePlane::createNLEesFFTdata");
969 complex *projPsiGTmp = fftcache->tmpData;
971 #if CMK_TRACE_ENABLED
972 double StartTime=CmiWallTimer();
975 CPNONLOCAL::eesProjGchare(ncoef,psi,k_x,k_y,k_z,ihave_g0,ind_g0,iterNL,
976 d_re,d_im,dyp_re,dyp_im,projPsiGTmp,ind_gspl,h_gspl,
978 #if CMK_TRACE_ENABLED
979 traceUserBracketEvent(eesProjG_, StartTime, CmiWallTimer());
997 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
998 CkPrintf(
"Yo dawg, ees nonlocal is off. You can't FFTNLEesFwd\n");
999 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
1004 CP_State_GSpacePlane *gsp = UgSpacePlaneProxy[thisInstance.proxyOffset](thisIndex.x, thisIndex.y).ckLocal();
1006 FFTcache *fftcache = UfftCacheProxy[thisInstance.proxyOffset].ckLocalBranch();
1007 eesCache *eesData = UeesCacheProxy[thisInstance.proxyOffset].ckLocalBranch ();
1012 #ifdef _CP_DEBUG_STATE_GPP_VERBOSE_
1014 CkPrintf(
"HI, I am gPP %d %d in FFTNLFwd : %d\n",thisIndex.x,thisIndex.y,iterNL);
1018 complex *projPsiGTmp = fftcache->tmpData;
1019 #if CMK_TRACE_ENABLED
1020 double StartTime=CmiWallTimer();
1023 fftcache->
doNlFFTGtoR_Gchare(projPsiGTmp,projPsiG,numFullNL,gSpaceNumPoints,numLines,
1024 (gss->numRuns),runs,ngridcNL,myChareG);
1025 fftcache->freeCacheMem(
"CP_State_ParticlePlane::FFTNLEesFwd");
1027 #if CMK_TRACE_ENABLED
1028 traceUserBracketEvent(doNlFFTGtoR_, StartTime, CmiWallTimer());
1031 #ifdef _CP_GS_DUMP_VKS_
1032 dumpMatrix(
"projPsiGb4send",(
double *)projPsiG, 1, gSpaceNumPoints*2,thisIndex.y,thisIndex.x,thisIndex.x,0,
false);
1035 #ifdef _CP_GS_DEBUG_COMPARE_VKS_
1036 if(savedprojpsiBfsend==NULL)
1038 savedprojpsiBfsend=
new complex[gSpaceNumPoints];
1039 loadMatrix(
"projPsiGb4send",(
double *)savedprojpsiBfsend, 1, gSpaceNumPoints*2,thisIndex.y,thisIndex.x,thisIndex.x,0,
false);
1041 for(
int i=0;i<gSpaceNumPoints;i++)
1043 if(fabs(projPsiG[i].re-savedprojpsiBfsend[i].re)>0.0001)
1045 fprintf(stderr,
"PP [%d,%d] %d element projpsi %.10g not %.10g\n",thisIndex.x, thisIndex.y,i, projPsiG[i].re, savedprojpsiBfsend[i].re);
1047 CkAssert(fabs(projPsiG[i].re-savedprojpsiBfsend[i].re)<0.0001);
1048 CkAssert(fabs(projPsiG[i].im-savedprojpsiBfsend[i].im)<0.0001);
1068 if(ees_nonlocal==0){
1069 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
1070 CkPrintf(
"Yo dawg, ees nonlocal is off. You can't sendtoEesRPP\n");
1071 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
1075 #ifdef _CP_DEBUG_STATE_GPP_VERBOSE_
1077 CkPrintf(
"HI, I am gPP %d %d in sendtoEesRPP : %d\n",thisIndex.x,thisIndex.y,iterNL);
1082 if (config.useGssInsRealPP){gssPInstance.beginIteration();}
1084 if (config.useGssInsRealPP){ComlibBegin(realPP_proxy, iterNL);}
1091 for(
int z=0; z < ngridcNL; z++) {
1094 msg->size = numLines;
1095 msg->senderIndex = thisIndex.y;
1098 if(config.prioNLFFTMsg){
1099 CkSetQueueing(msg, CK_QUEUEING_IFIFO);
1100 *(
int*)CkPriorityPtr(msg) = config.rsNLfftpriority +
1101 thisIndex.x + thisIndex.y;
1107 for (
int i=0,j=z; i<numLines; i++,j+=ngridcNL){data[i] = projPsiG[j];}
1108 realPP_proxy(thisIndex.x, z).recvFromEesGPP(msg);
1116 if (config.useGssInsRealPP){gssPInstance.endIteration();}
1118 if (config.useGssInsRealPP){ComlibEnd(realPP_proxy, iterNL);}
1137 if(ees_nonlocal==0){
1138 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
1139 CkPrintf(
"Yo dawg, ees nonlocal is off. You can't recvFromEesRPP\n");
1140 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
1144 #ifdef _CP_DEBUG_STATE_GPP_VERBOSE_
1146 CkPrintf(
"HI, I am gPP %d %d in recvFromEesRPP : %d\n",thisIndex.x,thisIndex.y,iterNL);
1152 int size = msg->size;
1153 int offset = msg->offset;
1154 int iterNLnow = msg->iterNL;
1155 complex *partlyIFFTd = msg->data;
1157 CkAssert(numLines == size);
1158 if(iterNLnow != iterNL || sendDone==0){
1159 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
1160 CkPrintf(
"Iteration mismatch in ParticlePlane %d %d %d\n",iterNL,iterNLnow,sendDone);
1161 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
1170 for(
int i=0,j=offset; i< numLines; i++,j+=ngridcNL){projPsiG[j] = partlyIFFTd[i];}
1179 if (countNLIFFT == ngridcNL) {
1181 #ifdef _CP_DEBUG_STATE_GPP_VERBOSE_
1183 CkPrintf(
"HI, I am gPP %d %d in recvFromEesRPP : %d\n",thisIndex.x,thisIndex.y,iterNL);
1202 if(ees_nonlocal==0){
1203 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
1204 CkPrintf(
"Yo dawg, ees nonlocal is off. You can't FFTEeesBck\n");
1205 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
1210 CP_State_GSpacePlane *gsp = UgSpacePlaneProxy[thisInstance.proxyOffset](thisIndex.x, thisIndex.y).ckLocal();
1212 FFTcache *fftcache = UfftCacheProxy[thisInstance.proxyOffset].ckLocalBranch();
1213 eesCache *eesData = UeesCacheProxy[thisInstance.proxyOffset].ckLocalBranch ();
1218 #ifdef _CP_DEBUG_STATE_GPP_VERBOSE_
1220 CkPrintf(
"HI, I am gPP %d %d in FFTNLeesBck : %d\n",thisIndex.x,thisIndex.y,iterNL);
1224 fftcache->getCacheMem(
"CP_State_ParticlePlane::FFTNLEesBck");
1225 complex *projPsiGTmp = fftcache->tmpData;
1227 #ifdef _CP_GS_DUMP_VKS_
1228 dumpMatrix(
"projPsiGb4",(
double *)projPsiG, 1, numFullNL*2,thisIndex.y,thisIndex.x,thisIndex.x,0,
false);
1231 #ifdef _CP_GS_DEBUG_COMPARE_VKS_
1232 if(savedprojpsiGBf==NULL)
1234 savedprojpsiGBf=
new complex[numFullNL];
1235 loadMatrix(
"projPsiGb4",(
double *)savedprojpsiGBf, 1, numFullNL*2,thisIndex.y,thisIndex.x,thisIndex.x,0,
false);
1237 for(
int i=0;i<numFullNL;i++)
1239 if(fabs(projPsiG[i].re-savedprojpsiGBf[i].re)>0.0001)
1241 fprintf(stderr,
"PP [%d,%d] %d element projpsi %.10g not %.10g\n",thisIndex.x, thisIndex.y,i, projPsiG[i].re, savedprojpsiGBf[i].re);
1243 CkAssert(fabs(projPsiG[i].re-savedprojpsiGBf[i].re)<0.0001);
1244 CkAssert(fabs(projPsiG[i].im-savedprojpsiGBf[i].im)<0.0001);
1248 #if CMK_TRACE_ENABLED
1249 double StartTime=CmiWallTimer();
1252 fftcache->
doNlFFTRtoG_Gchare(projPsiG,projPsiGTmp,numFullNL,gSpaceNumPoints,numLines,
1253 eesData->GspData[myChareG]->numRuns,runs,ngridcNL,myChareG);
1254 #if CMK_TRACE_ENABLED
1255 traceUserBracketEvent(doNlFFTRtoG_, StartTime, CmiWallTimer());
1273 CP_State_GSpacePlane *gsp = UgSpacePlaneProxy[thisInstance.proxyOffset](thisIndex.x, thisIndex.y).ckLocal();
1275 eesCache *eesData = UeesCacheProxy[thisInstance.proxyOffset].ckLocalBranch ();
1276 FFTcache *fftcache = UfftCacheProxy[thisInstance.proxyOffset].ckLocalBranch();
1278 int ncoef = gSpaceNumPoints;
1279 int *k_x = eesData->GspData[myChareG]->ka;
1280 int *k_y = eesData->GspData[myChareG]->kb;
1281 int *k_z = eesData->GspData[myChareG]->kc;
1282 int ihave_g0 = gss->ihave_g000;
1283 int ind_g0 = gss->ind_g000;
1284 int nkx0 = gss->nkx0;
1287 #ifdef _CP_DEBUG_STATE_GPP_VERBOSE_
1289 CkPrintf(
"HI, I am gPP %d %d in computeNLeesForc : %d\n",thisIndex.x,thisIndex.y,iterNL);
1291 complex *projPsiGTmp = fftcache->tmpData;
1293 #ifdef _CP_GS_DUMP_VKS_
1294 dumpMatrix(
"projPsiGtmpb4",(
double *)projPsiGTmp, 1, ncoef*2,thisIndex.y,thisIndex.x,thisIndex.x,0,
false);
1297 #ifdef _CP_GS_DEBUG_COMPARE_VKS_
1298 if(savedprojpsiBf==NULL)
1300 savedprojpsiBf=
new complex[ncoef];
1301 loadMatrix(
"projPsiGtmpb4",(
double *)savedprojpsiBf, 1, ncoef*2,thisIndex.y,thisIndex.x,thisIndex.x,0,
false);
1303 for(
int i=0;i<ncoef;i++)
1305 if(fabs(projPsiGTmp[i].re-savedprojpsiBf[i].re)>0.0001)
1307 fprintf(stderr,
"PP [%d,%d] %d element projpsi %.10g not %.10g\n",thisIndex.x, thisIndex.y,i, projPsiGTmp[i].re, savedprojpsiBf[i].re);
1309 CkAssert(fabs(projPsiGTmp[i].re-savedprojpsiBf[i].re)<0.0001);
1310 CkAssert(fabs(projPsiGTmp[i].im-savedprojpsiBf[i].im)<0.0001);
1314 #if CMK_TRACE_ENABLED
1315 double StartTime=CmiWallTimer();
1318 CPNONLOCAL::eesPsiForcGspace(ncoef,ihave_g0,ind_g0,nkx0,projPsiGTmp,fPsiG,dyp_re,dyp_im,
1320 fftcache->freeCacheMem(
"CP_State_ParticlePlane::computeNLEesForces");
1322 #if CMK_TRACE_ENABLED
1323 traceUserBracketEvent(eesPsiForcGspace_, StartTime, CmiWallTimer());
1328 if(iterNL==numNLiter){
1329 #ifdef _CP_DEBUG_STATE_GPP_VERBOSE_
1331 CkPrintf(
"HI, I am gPP %d %d done! : %d\n",thisIndex.x,thisIndex.y,iterNL);
1335 #ifdef BARRIER_CP_PARTICLEPLANE_NONLOCAL
1337 contribute(
sizeof(
int),&nonLocDone,CkReduction::sum_int,
1338 CkCallback(CkIndex_GSpaceDriver::allDoneNLForces(NULL),UgSpaceDriverProxy[thisInstance.proxyOffset]));
1341 UgSpaceDriverProxy[thisInstance.proxyOffset](thisIndex.x,thisIndex.y).doneNLForces();
1346 CkSetQueueing(msg, CK_QUEUEING_IFIFO);
1347 *(
int*)CkPriorityPtr(msg) = config.sfpriority;
1348 msg->iteration=iteration;
1349 thisProxy(thisIndex.x, thisIndex.y).lPrioStartNLEes(msg);
1365 int sum = ((
int *)msg->getData())[0];
1368 #ifdef _CP_DEBUG_STATE_GPP_VERBOSE_
1370 CkPrintf(
"HI, I am gPP %d %d in reg : %d\n",thisIndex.x,thisIndex.y,sum);
1373 registrationFlag = 1;
1377 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
1378 CkPrintf(
"Homes, registeration must occur before the 1st time step in GPP\n");
1379 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
1386 #include "gParticlePlane.def.h"
void pup(PUP::er &)
pup for migration /////////////////////////////////////////////////////////////////////////// ///////...
holds the UberIndex and the offset for proxies
void FFTNLEesFwd()
FFT projPsi(gx,gy,gz) -> projPsi(gx,gy,z) ///////////////////////////////////////////////////////////...
int nfreq_cpnonlocal_eesbk
CPNONLOCAL::eesPsiForcGspace.
void createNLEesFFTdata()
In gspace, create the projector, projPsi ////////////////////////////////////////////////////////////...
void computeZ(PPDummyMsg *m)
Entry Method.
void initKVectors()
InitKVectors creates local k vectors for this chare and mallocs some memory.
void reduceZ(int, int, complex *, complex *, complex *, complex *)
ReduceZ reduces Zmat over gspace for a particular state for N^3 method //////////////////////////////...
void computeNLEesForces()
Compute the Psi forces : If not done, start a new iteration /////////////////////////////////////////...
CkGroupID mCastGrpId
Multicast manager group that handles many mcast/redns in the code. Grep for info. ...
2D chare array [nchareG][nstates] Handles the electronic structure in Fourier space (referred to as G...
Add type declarations for simulationConstants class (readonly vars) and once class for each type of o...
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 FFTNLEesBck()
Complete the FFT : projPsif(gx,gy,z) -> projPsif(gx,gy,gz) //////////////////////////////////////////...
== Index logic for lines of constant x,y in gspace.
int nfreq_cpnonlocal_eesfwd
CPNONLOCAL::eesProjGchare, CPNONLOCAL::eesYlmOnD.
int calcReductionPlaneNum(int)
Spread the reduction plane numbers around to minimize map collisions for the N^3 method.
void ResumeFromSync()
Resume from Sync which is a general routine /////////////////////////////////////////////////////////...
Some basic data structures and the array map classes are defined here.
void recvFromEesRPP(GSPPIFFTMsg *msg)
Receive the projector back modified to generate psi forces A message cannot come back until I have se...
void registerCacheGPP(int, int, int *, int *, int *)
= GParticlePlane Cache Management tool
void getForces(int, int, complex *)
Compute psi forces for the N^3 method ///////////////////////////////////////////////////////////////...
void startNLEes(int)
= The entry point to the Euler Exponential Spline non-local method.
Group Container class : Only allowed chare data classes have data.
int registerPP(int state, int plane, int atmGrp)
local particle planes register themselves with the cache so they can be launched by the arrival of an...
void registrationDone(CkReductionMsg *msg)
= Make sure everyone is registered on the 1st time step
void setEnlCookie(EnlCookieMsg *m)
Section reduction cookie N^3 method /////////////////////////////////////////////////////////////////...
void sendToEesRPP()
send projPsi(gx,gy,z) to Rspace chare where FFT is completed ////////////////////////////////////////...
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 lPrioStartNLEes(NLDummyMsg *m)
= The entry point to the Euler Exponential Spline non-local method.
void launchComputeZs()
Entry Method. GSpaceDriver calls this to trigger the launch of the computeZ()s to compute the Z matri...
~CP_State_ParticlePlane()
The destructor : Carefully about what it malloced and what is not ///////////////////////////////////...