43 #include "src_piny_physics_v1.0/include/class_defs/CP_OPERATIONS/class_cpxcfnctls.h"
50 extern CProxy_TimeKeeper TimeKeeperProxy;
51 extern CkVec <CProxy_CP_State_RealSpacePlane> UrealSpacePlaneProxy;
52 extern CkVec <CProxy_CP_State_RealParticlePlane> UrealParticlePlaneProxy;
53 extern CkVec <CProxy_CP_Rho_RealSpacePlane> UrhoRealProxy;
54 extern CkVec <CProxy_CP_Rho_GSpacePlane> UrhoGProxy;
55 extern CkVec <CProxy_FFTcache> UfftCacheProxy;
56 extern CkVec <CProxy_CP_Rho_RHartExt> UrhoRHartExtProxy;
57 extern CkVec <CProxy_GSpaceDriver> UgSpaceDriverProxy;
59 extern ComlibInstanceHandle commRealInstance;
60 extern ComlibInstanceHandle commRealIGXInstance;
61 extern ComlibInstanceHandle commRealIGYInstance;
62 extern ComlibInstanceHandle commRealIGZInstance;
63 extern CkVec <ComlibInstanceHandle> mcastInstance;
85 CP_Rho_RealSpacePlane::CP_Rho_RealSpacePlane(
int xdim,
bool _useCommlib,
86 int _ees_eext_on,
int _ngridcEext,
89 thisInstance(_instance)
94 #ifdef _CP_DEBUG_RHOR_VERBOSE_
95 CkPrintf(
"[%d %d] RhoR constructs \n",thisIndex.x, thisIndex.y);
103 ngridcEext = _ngridcEext;
107 nplane_rho_x = sim->nplane_rho_x;
108 listSubFlag = sim->listSubFlag;
110 iplane_ind = thisIndex.y*ngridc + thisIndex.x;
112 rhoRsubplanes = config.rhoRsubplanes;
113 CkAssert(nplane_rho_x >= rhoRsubplanes);
115 cp_grad_corr_on = sim->cp_grad_corr_on;
116 ees_eext_on = _ees_eext_on;
117 rhoKeeperId = _rhokeeperid;
119 double vol = sim->vol;
120 int numFFT = config.numFFTPoints;
121 FFTscale = 1.0/((double)numFFT);
122 volumeFactor = vol*FFTscale;
129 int nchareRhoG=sim->nchareRhoG;
131 recvCountFromGRho = 0;
132 for(
int i=0;i<nchareRhoG;i++){
133 if(sim->nline_send_rho_y[i][thisIndex.y]>0){recvCountFromGRho++;}
136 recvCountFromGRho=nchareRhoG;
139 int nchareRhoGEext=sim->nchareRhoGEext;
141 recvCountFromGHartExt = 0;
142 for(
int i=0;i<nchareRhoGEext;i++){
143 if(sim->nline_send_eext_y[i][thisIndex.y]>0)recvCountFromGHartExt++;
146 recvCountFromGHartExt=nchareRhoGEext;
153 int div = (ngridb/rhoRsubplanes);
154 int rem = (ngridb % rhoRsubplanes);
155 int max = (thisIndex.y < rem ? thisIndex.y : rem);
156 myNgridb = (thisIndex.y<rem ? div+1 : div);
157 myBoff = div*thisIndex.y + max;
158 nptsB = ngrida*myNgridb;
159 nptsExpndB = (ngrida+2)*myNgridb;
163 myNplane_rho = sim->numSubGx[thisIndex.y];
165 myNplane_rho = nplane_rho_x;
167 nptsA = 2*myNplane_rho*ngridb;
168 nptsExpndA = 2*myNplane_rho*ngridb;
173 initRhoRealSlab(&rho_rs,ngrida,myNgridb,ngridc,myNplane_rho,ngridb,
174 thisIndex.x,thisIndex.y,rhoRsubplanes);
186 countRHartValue = 1;
if(thisIndex.x<(ngridcEext-rho_rs.sizeZ)){countRHartValue=2;}
187 countRHartValue*=(config.nchareHartAtmT);
191 doneWhiteByrd =
false;
192 for(
int i=0;i<5;i++){countGradVks[i]=0;}
193 for(
int i=0;i<5;i++){countIntGtoR[i]=0;}
194 for(
int i=0;i<5;i++){countIntRtoG[i]=0;}
204 setMigratable(
false);
220 CkMulticastMgr *mcastGrp = CProxy_CkMulticastMgr(
mCastGrpId).ckLocalBranch();
221 CkArrayIndexMax *elems =
new CkArrayIndexMax[nstates];
225 CkArrayIndex2D idx(0, thisIndex.x);
227 for (j = 0; j < nstates; j++) {
228 idx.index[0] = j^((thisIndex.x+thisIndex.y)%nstates);
232 for (j = 0; j < nstates; j++) {
233 idx.index[0] = (j+thisIndex.x+thisIndex.y)%nstates;
241 realSpaceSectionProxyA=
new CProxySection_CP_State_RealSpacePlane[config.UberJmax];
242 realSpaceSectionCProxyA=
new CProxySection_CP_State_RealSpacePlane[config.UberJmax];
243 for(
int kp=0;kp<config.UberJmax;kp++)
246 RhoReductionSource.idxU.y=kp;
247 RhoReductionSource.setPO();
248 realSpaceSectionProxyA[kp] = CProxySection_CP_State_RealSpacePlane::
249 ckNew(UrealSpacePlaneProxy[RhoReductionSource.proxyOffset].ckGetArrayID(), elems, nstates);
251 realSpaceSectionCProxyA[kp] = CProxySection_CP_State_RealSpacePlane::
252 ckNew(UrealSpacePlaneProxy[RhoReductionSource.proxyOffset].ckGetArrayID(), elems, nstates);
254 realSpaceSectionProxyA[kp].ckDelegate
255 (CProxy_CkMulticastMgr(
mCastGrpId).ckLocalBranch());
256 mcastGrp->setSection(realSpaceSectionProxyA[kp]);
259 ComlibAssociateProxy(mcastInstance[kp],realSpaceSectionCProxyA[kp]);
263 dummyProductMessage->subplane=thisIndex.y;
264 realSpaceSectionProxyA[kp].init(dummyProductMessage);
267 rhoGProxy_com = UrhoGProxy[thisInstance.proxyOffset];
268 rhoGProxyIGX_com = UrhoGProxy[thisInstance.proxyOffset];
269 rhoGProxyIGY_com = UrhoGProxy[thisInstance.proxyOffset];
270 rhoGProxyIGZ_com = UrhoGProxy[thisInstance.proxyOffset];
273 if (config.useRInsRhoGP)
274 ComlibAssociateProxy(commRealInstance,rhoGProxy_com);
275 if (config.useRInsIGXRhoGP)
276 ComlibAssociateProxy(commRealIGXInstance,rhoGProxyIGX_com);
277 if (config.useRInsIGYRhoGP)
278 ComlibAssociateProxy(commRealIGYInstance,rhoGProxyIGY_com);
279 if (config.useRInsIGZRhoGP)
280 ComlibAssociateProxy(commRealIGZInstance,rhoGProxyIGZ_com);
288 CP_Rho_RealSpacePlane::~CP_Rho_RealSpacePlane(){
299 ArrayElement2D::pup(p);
327 PUParray(p,countGradVks,5);
328 PUParray(p,countIntGtoR,5);
329 PUParray(p,countIntGtoR,5);
334 PUParray(p,realSpaceSectionProxyA, config.UberJmax);
335 PUParray(p,realSpaceSectionCProxyA, config.UberJmax);
337 rhoGProxy_com = UrhoGProxy[thisInstance.proxyOffset];
338 rhoGProxyIGX_com = UrhoGProxy[thisInstance.proxyOffset];
339 rhoGProxyIGY_com = UrhoGProxy[thisInstance.proxyOffset];
340 rhoGProxyIGZ_com = UrhoGProxy[thisInstance.proxyOffset];
343 if (config.useRInsRhoGP)
344 ComlibAssociateProxy(commRealInstance,rhoGProxy_com);
345 if (config.useRInsIGXRhoGP)
346 ComlibAssociateProxy(commRealIGXInstance,rhoGProxyIGX_com);
347 if (config.useRInsIGYRhoGP)
348 ComlibAssociateProxy(commRealIGYInstance,rhoGProxyIGY_com);
349 if (config.useRInsIGZRhoGP)
350 ComlibAssociateProxy(commRealIGZInstance,rhoGProxyIGZ_com);
377 #ifdef _CP_DEBUG_RHOR_VERBOSE_
378 CkPrintf(
"RhoReal accepting Density %d %d %d\n",
379 thisIndex.x,thisIndex.y,CkMyPe());
383 for(
int i=0;i<msg->getSize()/
sizeof(double) ;i++){
384 CkAssert(isnan(((
double*) msg->getData())[i])==0);
391 if(redCount<=config.UberJmax){
394 double *indata=(
double*) msg->getData();
395 double *outdata=(
double*) RedMsg->getData();
396 int size=msg->getSize()/
sizeof(double);
397 for(
int i=0;i<size ;i++)
398 outdata[i]+=indata[i];
403 if(redCount==config.UberJmax){
420 #ifdef _CP_SUBSTEP_TIMING_
422 double rhostart=CmiWallTimer();
423 CkCallback cb(CkIndex_TimeKeeper::collectStart(NULL),0,TimeKeeperProxy);
424 contribute(
sizeof(
double),&rhostart,CkReduction::min_double, cb ,rhoKeeperId);
433 doneWhiteByrd =
false;
435 if(cp_grad_corr_on==0){doneWhiteByrd =
true;}
436 if(ees_eext_on==0) {doneRHart =
true;}
438 #ifdef _CP_DEBUG_HARTEEXT_OFF_
446 double *realValues = (
double *) RedMsg->getData();
447 double *density = rho_rs.density;
448 CkAssert(RedMsg->getSize() == nptsB *
sizeof(double));
450 rho_rs.uPackScaleGrow(density,realValues,probScale);
457 #ifdef _CP_DEBUG_RHOR_RHO_
458 char myFileName[MAX_CHAR_ARRAY_LENGTH];
459 sprintf(myFileName,
"Rho_Real_%d_%d.out", thisIndex.x,thisIndex.y);
460 FILE *fp = fopen(myFileName,
"w");
461 for (
int i = 0; i <nptsB; i++){
462 fprintf(fp,
"%g\n",realValues[i]*probScale);
497 #ifndef _CP_DEBUG_HARTEEXT_OFF_
499 int div = (ngridcEext / ngridc);
500 int rem = (ngridcEext % ngridc);
501 int ind = thisIndex.x+ngridc;
503 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
504 CkPrintf(
"Eext Grid size too large for launch Scheme\n");
505 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
508 #ifdef _CP_RHO_RSP_VERBOSE_
509 CkPrintf(
"HI, I am r-rho chare %d lauchning %d : ngrids %d %d : %d\n",
510 thisIndex.x,thisIndex.x,ngridcEext,ngridc,rem);
512 for(
int j=0;j<config.nchareHartAtmT;j++){
513 UrhoRHartExtProxy[thisInstance.proxyOffset](thisIndex.x,thisIndex.y,j).startEextIter();
515 #ifdef _CP_RHO_RSP_VERBOSE_
516 CkPrintf(
"HI, I am r-rho chare %d also lauchning %d\n",thisIndex.x,ind);
518 UrhoRHartExtProxy[thisInstance.proxyOffset](ind,thisIndex.y,j).startEextIter();
530 if(sim->ees_nloc_on==1 && config.launchNLeesFromRho==1 && sim->natm_nl>0){
532 CkAssert(rho_rs.sizeZ>=config.nchareG);
533 if(thisIndex.x<config.nchareG){
534 int nstates = config.nstates;
535 int div = (nstates/rhoRsubplanes);
536 int rem = (nstates % rhoRsubplanes);
537 int add = (thisIndex.y < rem ? 1 : 0);
538 int max = (thisIndex.y < rem ? thisIndex.y : rem);
539 int ist = div*thisIndex.y + max;
540 int iend = ist + div + add;
541 for(
int kpoint=0;kpoint < config.UberJmax;kpoint++)
544 destKpointInstance.idxU.y=kpoint;
545 int proxyOffset=destKpointInstance.setPO();
547 for(
int ns=ist;ns<iend;ns++){
551 CkAssert(ns<config.nstates);
553 UgSpaceDriverProxy[proxyOffset](ns,thisIndex.x).startNonLocalEes(myTime);
576 #ifdef _CP_DEBUG_RHOR_VERBOSE_
577 CkPrintf(
"In RhoRealSpacePlane[%d] energyComp %d %d\n",thisIndex.x,
578 CkMyPe(),CmiMemoryUsage());
583 double *density = rho_rs.density;
584 double *Vks = rho_rs.Vks;
588 int npts = config.numFFTPoints;
589 double *exc_ret = &(rho_rs.exc_ret);
590 double *muxc_ret = &(rho_rs.muxc_ret);
595 CPXCFNCTS::CP_exc_calc(npts,nf1,nf2,nf3,density,Vks,exc_ret,muxc_ret,config.
nfreq_xcfnctl);
597 if(cp_grad_corr_on==0){
599 exc[0]=rho_rs.exc_ret;
601 contribute(2*
sizeof(
double),exc,CkReduction::sum_double);
629 #ifdef _CP_DEBUG_RHOR_VERBOSE_
630 CkPrintf(
"In RhoRealSpacePlane[%d %d] FFT_RSpacetoGSpace %d %d\n",thisIndex.x,
631 thisIndex.y, CkMyPe(),CmiMemoryUsage());
637 FFTcache *fftcache = UfftCacheProxy[thisInstance.proxyOffset].ckLocalBranch();
638 double *density = rho_rs.density;
639 double *dataR = rho_rs.rhoIRX;
640 complex *dataC = rho_rs.rhoIRXC;
642 #if CMK_TRACE_ENABLED
643 double StartTime=CmiWallTimer();
646 rho_rs.uPackScale(dataR,density,volumeFactor);
653 #if CMK_TRACE_ENABLED
654 traceUserBracketEvent(RhoRtoGFFT_, StartTime, CmiWallTimer());
666 #ifndef DEBUG_INT_TRANS_FWD
670 sprintf(name,
"partFFTGxGyZ%d.out.%d.%d",rhoRsubplanes,thisIndex.x,thisIndex.y);
671 FILE *fp = fopen(name,
"w");
672 for(
int ix =0;ix<nplane_rho_x;ix++){
673 for(
int iy =0;iy<ngridb;iy++){
674 int i = iy*(ngrida/2+1) + ix;
675 fprintf(fp,
"%d %d : %g %g\n",iy,ix,dataC[i].re,dataC[i].im);
709 if(sim->ees_nloc_on==1){
710 CkAssert(rho_rs.sizeZ>=sim->ngrid_nloc_c);;
711 if(thisIndex.x < sim->ngrid_nloc_c){
712 int nstates = config.nstates;
713 int div = (nstates/rhoRsubplanes);
714 int rem = (nstates % rhoRsubplanes);
715 int add = (thisIndex.y < rem ? 1 : 0);
716 int max = (thisIndex.y < rem ? thisIndex.y : rem);
717 int ist = div*thisIndex.y + max;
718 int iend = ist + div + add;
719 for(
int kpoint=0;kpoint < config.UberJmax;kpoint++)
722 destKpointInstance.idxU.y=kpoint;
723 int proxyOffset=destKpointInstance.setPO();
724 for(
int ns=ist;ns<iend;ns++){
725 CkAssert(ns<config.nstates);
726 UrealParticlePlaneProxy[proxyOffset](ns,thisIndex.x).launchFFTControl(myTime);
728 CmiNetworkProgress();
756 int **listSubGx = sim->listSubGx;
757 int *numSubGx = sim->numSubGx;
759 CkAssert(rhoRsubplanes>1);
762 case 0 : FFTresult = rho_rs.rhoIRXC;
break;
763 case 1 : FFTresult = rho_rs.rhoIRXC;
break;
764 case 2 : FFTresult = rho_rs.rhoIRYC;
break;
765 case 3 : FFTresult = rho_rs.rhoIRZC;
break;
766 default: CkAbort(
"impossible iopt");
break;
776 #ifdef _ERIC_SETS_UP_COMMLIB_
778 case 0 :
if(config.useRInsRhoRP) commRealInstanceRx.beginIteration();
break;
779 case 1 :
if(config.useRInsIGXRhoRP) commRealIGXInstanceRx.beginIteration();
break;
780 case 2 :
if(config.useRInsIGYRhoRP) commRealIGYInstanceRx.beginIteration();
break;
781 case 3 :
if(config.useRInsIGZRhoRP) commRealIGZInstanceRx.beginIteration();
break;
782 default: CkAbort(
"impossible iopt");
break;
791 int stride = ngrida/2+1;
792 int ix = thisIndex.x;
793 for(
int ic = 0; ic < rhoRsubplanes; ic ++) {
794 int num = numSubGx[ic];
795 int size = num*myNgridb;
797 int sendFFTDataSize = size;
801 msg->offset = myBoff;
805 if(config.prioFFTMsg){
806 CkSetQueueing(msg, CK_QUEUEING_IFIFO);
807 *(
int*)CkPriorityPtr(msg) = config.rhogpriority+thisIndex.y;
811 for(
int i=0,koff=0;i<num;i++,koff+=myNgridb){
812 for(
int k=koff,ii=listSubGx[ic][i];k<myNgridb+koff;k++,ii+=stride){
813 data[k] = FFTresult[ii];
817 int nst=listSubGx[ic][0];
818 for(
int i=0,ist=nst,koff=0;i<num;i++,koff+=myNgridb,ist++){
819 for(
int k=koff,ii=ist;k<myNgridb+koff;k++,ii+=stride){
820 data[k] = FFTresult[ii];
830 default: CkAbort(
"impossible iopt");
break;
833 #ifdef _ERIC_SETS_UP_COMMLIB_
836 default: CkAbort(
"impossible iopt");
break;
845 #ifdef _ERIC_SETS_UP_COMMLIB_
847 case 0 :
if(config.useRInsRhoRP) commRealInstanceRx.endIteration();
break;
848 case 1 :
if(config.useRInsIGXRhoRP) commRealIGXInstanceRx.endIteration();
break;
849 case 2 :
if(config.useRInsIGYRhoRP) commRealIGYInstanceRx.endIteration();
break;
850 case 3 :
if(config.useRInsIGZRhoRP) commRealIGZInstanceRx.endIteration();
break;
851 default: CkAbort(
"impossible iopt");
break;
875 int size = msg->size;
876 int iopt = msg->iopt;
878 int offset = msg->offset;
881 CkAssert(size==myNplane_rho*num);
882 CkAssert(rhoRsubplanes>1);
886 case 0: dataC = rho_rs.rhoIRXCint;
break;
887 case 1: dataC = rho_rs.rhoIRXCint;
break;
888 case 2: dataC = rho_rs.rhoIRYCint;
break;
889 case 3: dataC = rho_rs.rhoIRZCint;
break;
890 default: CkAbort(
"Impossible option\n");
break;
893 for(
int js=0,j=offset;js<size;js+=num,j+=ngridb){
894 for(
int is=js,i=j;is<num+js;is++,i++){
895 dataC[i] = msgData[is];
901 countIntRtoG[iopt]++;
902 if(countIntRtoG[iopt]==rhoRsubplanes){
903 countIntRtoG[iopt]=0;
927 CkAssert(rhoRsubplanes>1);
931 case 0: dataC = rho_rs.rhoIRXCint; dataR = rho_rs.rhoIRXint;
break;
932 case 1: dataC = rho_rs.rhoIRXCint; dataR = rho_rs.rhoIRXint;
break;
933 case 2: dataC = rho_rs.rhoIRYCint; dataR = rho_rs.rhoIRYint;
break;
934 case 3: dataC = rho_rs.rhoIRZCint; dataR = rho_rs.rhoIRZint;
break;
935 default: CkAbort(
"Impossible option\n");
break;
938 FFTcache *fftcache = UfftCacheProxy[thisInstance.proxyOffset].ckLocalBranch();
939 #if CMK_TRACE_ENABLED
940 double StartTime=CmiWallTimer();
943 #if CMK_TRACE_ENABLED
944 traceUserBracketEvent(doRhoFFTRytoGy_, StartTime, CmiWallTimer());
951 if(iopt>=1 && iopt <= 3){countFFTRyToGy++; igo=1;}
953 #ifndef DEBUG_INT_TRANS_FWD
955 if(config.rhoGToRhoRMsgComb==1 && countFFTRyToGy==3 && igo==1){
961 int **listSubGx = sim->listSubGx;
962 int ic = thisIndex.y;
963 CkPrintf(
"%d %d : %d\n",thisIndex.x,thisIndex.y,myNplane_rho);
965 sprintf(name,
"partFFTGxGyZ%d.out.%d.%d",rhoRsubplanes,thisIndex.x,thisIndex.y);
966 FILE *fp = fopen(name,
"w");
967 for(
int ix =0;ix<myNplane_rho;ix++){
968 for(
int iy =0;iy<ngridb;iy++){
969 int i = ix*ngridb + iy;
970 fprintf(fp,
"%d %d : %g %g\n",iy,listSubGx[ic][ix],dataC[i].re,dataC[i].im);
1008 int nchareRhoG = sim->nchareRhoG;
1009 int **tranpack_rho = sim->index_tran_upack_rho;
1010 int *nlines_per_chareRhoG = sim->nlines_per_chareRhoG;
1011 int ***tranupack_rhoY = sim->index_tran_upack_rho_y;
1012 int **nlines_per_chareRhoGY = sim->nline_send_rho_y;
1015 if(rhoRsubplanes==1){
1017 case 0 : FFTresult = rho_rs.rhoIRXC;
break;
1018 case 1 : FFTresult = rho_rs.rhoIRXC;
break;
1019 case 2 : FFTresult = rho_rs.rhoIRYC;
break;
1020 case 3 : FFTresult = rho_rs.rhoIRZC;
break;
1021 default: CkAbort(
"impossible iopt");
break;
1025 case 0 : FFTresult = rho_rs.rhoIRXCint;
break;
1026 case 1 : FFTresult = rho_rs.rhoIRXCint;
break;
1027 case 2 : FFTresult = rho_rs.rhoIRYCint;
break;
1028 case 3 : FFTresult = rho_rs.rhoIRZCint;
break;
1029 default: CkAbort(
"impossible iopt");
break;
1037 if(rhoRsubplanes==1){
1040 case 0 :
if(config.useRInsRhoGP) commRealInstance.beginIteration();
break;
1041 case 1 :
if(config.useRInsIGXRhoGP) commRealIGXInstance.beginIteration();
break;
1042 case 2 :
if(config.useRInsIGYRhoGP) commRealIGYInstance.beginIteration();
break;
1043 case 3 :
if(config.useRInsIGZRhoGP) commRealIGZInstance.beginIteration();
break;
1045 case 0 :
if(config.useRInsRhoGP) ComlibBegin(rhoGProxy_com,0);
break;
1046 case 1 :
if(config.useRInsIGXRhoGP) ComlibBegin(rhoGProxyIGX_com,0);
break;
1047 case 2 :
if(config.useRInsIGYRhoGP) ComlibBegin(rhoGProxyIGY_com,0);
break;
1048 case 3 :
if(config.useRInsIGZRhoGP) ComlibBegin(rhoGProxyIGZ_com,0);
break;
1050 default: CkAbort(
"impossible iopt");
break;
1058 int iy = thisIndex.y;
1059 for(
int ic = 0; ic < nchareRhoG; ic ++) {
1063 int sendFFTDataSize = nlines_per_chareRhoG[ic];
1064 if(rhoRsubplanes!=1){sendFFTDataSize = nlines_per_chareRhoGY[ic][iy];}
1065 if(sendFFTDataSize>0)
1071 msg->size = sendFFTDataSize;
1073 msg->offset = thisIndex.x;
1074 msg->offsetGx = thisIndex.y;
1076 if(config.prioFFTMsg){
1077 CkSetQueueing(msg, CK_QUEUEING_IFIFO);
1078 *(
int*)CkPriorityPtr(msg) = config.rhogpriority+thisIndex.x;
1081 if(rhoRsubplanes==1){
1082 for(
int i=0;i<sendFFTDataSize;i++){
1083 data[i] = FFTresult[tranpack_rho[ic][i]];
1086 for(
int i=0;i<sendFFTDataSize;i++){
1087 data[i] = FFTresult[tranupack_rhoY[ic][iy][i]];
1093 if(rhoRsubplanes==1){
1095 case 0 : rhoGProxy_com(ic,0).acceptRhoData(msg);
break;
1096 case 1 : rhoGProxyIGX_com(ic,0).acceptWhiteByrd(msg);
break;
1097 case 2 : rhoGProxyIGY_com(ic,0).acceptWhiteByrd(msg);
break;
1098 case 3 : rhoGProxyIGZ_com(ic,0).acceptWhiteByrd(msg);
break;
1099 default: CkAbort(
"impossible iopt");
break;
1103 case 0 : UrhoGProxy[thisInstance.proxyOffset](ic,0).acceptRhoData(msg);
break;
1104 case 1 : UrhoGProxy[thisInstance.proxyOffset](ic,0).
acceptWhiteByrd(msg);
break;
1105 case 2 : UrhoGProxy[thisInstance.proxyOffset](ic,0).
acceptWhiteByrd(msg);
break;
1106 case 3 : UrhoGProxy[thisInstance.proxyOffset](ic,0).
acceptWhiteByrd(msg);
break;
1107 default: CkAbort(
"impossible iopt");
break;
1117 if(rhoRsubplanes==1){
1120 case 0 :
if(config.useRInsRhoGP) commRealInstance.endIteration();
break;
1121 case 1 :
if(config.useRInsIGXRhoGP) commRealIGXInstance.endIteration();
break;
1122 case 2 :
if(config.useRInsIGYRhoGP) commRealIGYInstance.endIteration();
break;
1123 case 3 :
if(config.useRInsIGZRhoGP) commRealIGZInstance.endIteration();
break;
1125 case 0 :
if(config.useRInsRhoGP) ComlibEnd(rhoGProxy_com,0);
break;
1126 case 1 :
if(config.useRInsIGXRhoGP) ComlibEnd(rhoGProxyIGX_com,0);
break;
1127 case 2 :
if(config.useRInsIGYRhoGP) ComlibEnd(rhoGProxyIGY_com,0);
break;
1128 case 3 :
if(config.useRInsIGZRhoGP) ComlibEnd(rhoGProxyIGZ_com,0);
break;
1130 default: CkAbort(
"impossible iopt");
break;
1148 int nchareRhoG = sim->nchareRhoG;
1149 int **tranpack_rho = sim->index_tran_upack_rho;
1150 int *nlines_per_chareRhoG = sim->nlines_per_chareRhoG;
1151 int ***tranupack_rhoY = sim->index_tran_upack_rho_y;
1152 int **nlines_per_chareRhoGY = sim->nline_send_rho_y;
1157 if(rhoRsubplanes==1){
1158 FFTresultX = rho_rs.rhoIRXC;
1159 FFTresultY = rho_rs.rhoIRYC;
1160 FFTresultZ = rho_rs.rhoIRZC;
1162 FFTresultX = rho_rs.rhoIRXCint;
1163 FFTresultY = rho_rs.rhoIRYCint;
1164 FFTresultZ = rho_rs.rhoIRZCint;
1170 int iy = thisIndex.y;
1171 for(
int ic = 0; ic < nchareRhoG; ic ++) {
1175 int sendFFTDataSize = nlines_per_chareRhoG[ic];
1176 if(rhoRsubplanes!=1){sendFFTDataSize = nlines_per_chareRhoGY[ic][iy];}
1178 if(sendFFTDataSize>0){
1182 msg->size = sendFFTDataSize;
1184 msg->offset = thisIndex.x;
1185 msg->offsetGx = thisIndex.y;
1187 if(config.prioFFTMsg){
1188 CkSetQueueing(msg, CK_QUEUEING_IFIFO);
1189 *(
int*)CkPriorityPtr(msg) = config.rhogpriority+thisIndex.x;
1192 if(rhoRsubplanes==1){
1193 for(
int i=0,ii=0;ii<sendFFTDataSize;i+=3,ii++){
1194 int j = tranpack_rho[ic][ii];
1195 data[i] = FFTresultX[j];
1196 data[i+1] = FFTresultY[j];
1197 data[i+2] = FFTresultZ[j];
1200 for(
int i=0,ii=0;ii<sendFFTDataSize;i+=3,ii++){
1201 int j = tranupack_rhoY[ic][iy][ii];
1202 data[i] = FFTresultX[j];
1203 data[i+1] = FFTresultY[j];
1204 data[i+2] = FFTresultZ[j];
1209 UrhoGProxy[thisInstance.proxyOffset](ic,0).acceptWhiteByrdAll(msg);
1238 int nchareG = sim->nchareRhoG;
1239 int **tranUnpack = sim->index_tran_upack_rho;
1240 int *nlines_per_chareG = sim->nlines_per_chareRhoG;
1241 int ***tranupack_rhoY = sim->index_tran_upack_rho_y;
1242 int **nlines_per_chareRhoGY = sim->nline_send_rho_y;
1243 int iy = thisIndex.y;
1245 int size = msg->size;
1246 int Index = msg->senderIndex;
1247 int iopt = msg->iopt;
1248 complex *partiallyFFTd = msg->data;
1252 if(rhoRsubplanes==1){
1253 mySize = nlines_per_chareG[Index];
1254 nptsExpnd = nptsExpndB;
1256 mySize = nlines_per_chareRhoGY[Index][iy];
1257 nptsExpnd = nptsExpndA;
1261 for(
int i=0;i<msg->size ;i++){
1262 CkAssert(isnan(msg->data[i].re)==0);
1263 CkAssert(isnan(msg->data[i].im)==0);
1266 #ifdef _CP_DEBUG_RHOR_VERBOSE_
1267 CkPrintf(
"Data from RhoG arriving at RhoR : %d %d %d %d\n",
1268 thisIndex.x,thisIndex.y,iopt,countGradVks[iopt]);
1274 countGradVks[iopt]++;
1275 if (countGradVks[iopt] > recvCountFromGRho) {
1276 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
1277 CkPrintf(
"Mismatch in allowed rho_gspace chare arrays : %d %d %d %d\n",
1278 countGradVks[iopt],nchareG,thisIndex.x,thisIndex.y);
1279 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
1284 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
1285 CkPrintf(
"Dude.1, %d != %d for rho chare %d %d %d\n",size,mySize,
1286 thisIndex.y,Index,iopt);
1287 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
1291 if(1> iopt || iopt >3){
1292 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
1293 CkPrintf(
"Wrong option in rhoR \n",iopt);
1294 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
1303 if(rhoRsubplanes==1){
1305 case 1 : dataC = rho_rs.rhoIRXC; dataR = rho_rs.rhoIRX;
break;
1306 case 2 : dataC = rho_rs.rhoIRYC; dataR = rho_rs.rhoIRY;
break;
1307 case 3 : dataC = rho_rs.rhoIRZC; dataR = rho_rs.rhoIRZ;
break;
1308 default: CkAbort(
"impossible iopt");
break;
1312 case 1 : dataC = rho_rs.rhoIRXCint; dataR = rho_rs.rhoIRXint;
break;
1313 case 2 : dataC = rho_rs.rhoIRYCint; dataR = rho_rs.rhoIRYint;
break;
1314 case 3 : dataC = rho_rs.rhoIRZCint; dataR = rho_rs.rhoIRZint;
break;
1315 default: CkAbort(
"impossible iopt");
break;
1320 if(countGradVks[iopt]==1){bzero(dataR,
sizeof(
double)*nptsExpnd);}
1322 if(rhoRsubplanes==1){
1323 for(
int i=0;i<size;i++){
1324 dataC[tranUnpack[Index][i]] = partiallyFFTd[i]*probScale;
1327 for(
int i=0;i<size;i++){
1328 dataC[tranupack_rhoY[Index][iy][i]] = partiallyFFTd[i]*probScale;
1337 if (countGradVks[iopt] == recvCountFromGRho){
1339 countGradVks[iopt]=0;
1340 if(rhoRsubplanes==1){doneGradRhoVks++;}
1342 #if CMK_TRACE_ENABLED
1343 double StartTime=CmiWallTimer();
1346 FFTcache *fftcache = UfftCacheProxy[thisInstance.proxyOffset].ckLocalBranch();
1347 if(rhoRsubplanes==1){
1354 #if CMK_TRACE_ENABLED
1355 traceUserBracketEvent(fwFFTGtoRnot0_, StartTime, CmiWallTimer());
1363 if(doneGradRhoVks==3 && rhoRsubplanes==1){
1394 int nchareG = sim->nchareRhoG;
1395 int **tranUnpack = sim->index_tran_upack_rho;
1396 int *nlines_per_chareG = sim->nlines_per_chareRhoG;
1397 int ***tranupack_rhoY = sim->index_tran_upack_rho_y;
1398 int **nlines_per_chareRhoGY = sim->nline_send_rho_y;
1399 int iy = thisIndex.y;
1401 int size = msg->size;
1402 int Index = msg->senderIndex;
1403 int iopt = msg->iopt;
1404 complex *partiallyFFTd = msg->data;
1408 if(rhoRsubplanes==1){
1409 mySize = nlines_per_chareG[Index];
1410 nptsExpnd = nptsExpndB;
1412 mySize = nlines_per_chareRhoGY[Index][iy];
1413 nptsExpnd = nptsExpndA;
1417 for(
int i=0;i<msg->size ;i++){
1418 CkAssert(isnan(msg->data[i].re)==0);
1419 CkAssert(isnan(msg->data[i].im)==0);
1423 #ifdef _CP_DEBUG_RHOR_VERBOSE_
1424 CkPrintf(
"Data from RhoG arriving at RhoR : %d %d %d %d\n",
1425 thisIndex.x,thisIndex.y,iopt,countGradVks[iopt]);
1431 countGradVks[iopt]++;
1433 if (countGradVks[iopt] > recvCountFromGRho) {
1434 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
1435 CkPrintf(
"Mismatch in allowed rho_gspace chare arrays : %d %d %d %d\n",
1436 countGradVks[iopt],nchareG,thisIndex.x,thisIndex.y);
1437 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
1442 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
1443 CkPrintf(
"Dude.1, %d != %d for rho chare %d %d %d\n",size,mySize,
1444 thisIndex.y,Index,iopt);
1445 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
1450 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
1451 CkPrintf(
"Wrong option in rhoR \n",iopt);
1452 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
1459 complex *dataCX,*dataCY,*dataCZ;
1460 double *dataRX,*dataRY,*dataRZ;
1461 if(rhoRsubplanes==1){
1462 dataCX = rho_rs.rhoIRXC; dataRX = rho_rs.rhoIRX;
1463 dataCY = rho_rs.rhoIRYC; dataRY = rho_rs.rhoIRY;
1464 dataCZ = rho_rs.rhoIRZC; dataRZ = rho_rs.rhoIRZ;
1466 dataCX = rho_rs.rhoIRXCint; dataRX = rho_rs.rhoIRXint;
1467 dataCY = rho_rs.rhoIRYCint; dataRY = rho_rs.rhoIRYint;
1468 dataCZ = rho_rs.rhoIRZCint; dataRZ = rho_rs.rhoIRZint;
1472 if(countGradVks[iopt]==1){
1473 bzero(dataRX,
sizeof(
double)*nptsExpnd);
1474 bzero(dataRY,
sizeof(
double)*nptsExpnd);
1475 bzero(dataRZ,
sizeof(
double)*nptsExpnd);
1478 if(rhoRsubplanes==1){
1479 for(
int i=0,ii=0;ii<size;i+=3,ii++){
1480 int j = tranUnpack[Index][ii];
1481 dataCX[j] = partiallyFFTd[i]*probScale;
1482 dataCY[j] = partiallyFFTd[i+1]*probScale;
1483 dataCZ[j] = partiallyFFTd[i+2]*probScale;
1486 for(
int i=0,ii=0;ii<size;i+=3,ii++){
1487 int j = tranupack_rhoY[Index][iy][ii];
1488 dataCX[j] = partiallyFFTd[i]*probScale;
1489 dataCY[j] = partiallyFFTd[i+1]*probScale;
1490 dataCZ[j] = partiallyFFTd[i+2]*probScale;
1499 if (countGradVks[iopt] == recvCountFromGRho){
1501 countGradVks[iopt]=0;
1502 if(rhoRsubplanes==1){doneGradRhoVks+=3;}
1504 #if CMK_TRACE_ENABLED
1505 double StartTime=CmiWallTimer();
1508 FFTcache *fftcache = UfftCacheProxy[thisInstance.proxyOffset].ckLocalBranch();
1509 if(rhoRsubplanes==1){
1522 #if CMK_TRACE_ENABLED
1523 traceUserBracketEvent(fwFFTGtoRnot0_, StartTime, CmiWallTimer());
1531 if(doneGradRhoVks==3 && rhoRsubplanes==1){
1557 CkAssert(rhoRsubplanes>1);
1561 case 0 : FFTresult = rho_rs.rhoIRXCint;
break;
1562 case 1 : FFTresult = rho_rs.rhoIRXCint;
break;
1563 case 2 : FFTresult = rho_rs.rhoIRYCint;
break;
1564 case 3 : FFTresult = rho_rs.rhoIRZCint;
break;
1565 case 4 : FFTresult = rho_rs.VksHartCint;
break;
1566 default: CkAbort(
"impossible iopt");
break;
1575 #ifdef _ERIC_SETS_UP_COMMLIB_
1577 case 0 :
if(config.useRInsRhoRP) commRealInstanceRx.beginIteration();
break;
1578 case 1 :
if(config.useRInsIGXRhoRP) commRealIGXInstanceRx.beginIteration();
break;
1579 case 2 :
if(config.useRInsIGYRhoRP) commRealIGYInstanceRx.beginIteration();
break;
1580 case 3 :
if(config.useRInsIGZRhoRP) commRealIGZInstanceRx.beginIteration();
break;
1581 default: CkAbort(
"impossible iopt");
break;
1589 int ix = thisIndex.x;
1590 for(
int ic = 0; ic < rhoRsubplanes; ic ++) {
1591 int div = (ngridb/rhoRsubplanes);
1592 int rem = (ngridb % rhoRsubplanes);
1593 int add = (ic < rem ? 1 : 0);
1594 int max = (ic < rem ? ic : rem);
1595 int ist = div*ic + max;
1596 int iend = ist + div + add;
1597 int size = (iend-ist)*myNplane_rho;
1599 int sendFFTDataSize = size;
1603 msg->offset = thisIndex.y;
1604 msg->num = myNplane_rho;
1607 if(config.prioFFTMsg){
1608 CkSetQueueing(msg, CK_QUEUEING_IFIFO);
1609 *(
int*)CkPriorityPtr(msg) = config.rhogpriority+thisIndex.y;
1612 for(
int i=ist,koff=0;i<iend;i++,koff+=myNplane_rho){
1613 for(
int k=koff,ii=i;k<myNplane_rho+koff;k++,ii+=ngridb){
1614 data[k] = FFTresult[ii];
1624 default: CkAbort(
"impossible iopt");
break;
1627 #ifdef _ERIC_SETS_UP_COMMLIB_
1629 case 0 : UrhoGProxy[thisInstance.proxyOffset]_com(ic,0).acceptRhoGradVksGxToRx(msg);
break;
1630 case 1 : UrhoGProxy[thisInstance.proxyOffset]IGX_com(ic,0).acceptRhoGradVksGxToRx(msg);
break;
1631 case 2 : UrhoGProxy[thisInstance.proxyOffset]IGY_com(ic,0).acceptRhoGradVksGxToRx(msg);
break;
1632 case 3 : UrhoGProxy[thisInstance.proxyOffset]IGZ_com(ic,0).acceptRhoGradVksGxToRx(msg);
break;
1633 default: CkAbort(
"impossible iopt");
break;
1642 #ifdef _ERIC_SETS_UP_COMMLIB_
1644 case 0 :
if(config.useRInsRhoRP) commRealInstanceRx.endIteration();
break;
1645 case 1 :
if(config.useRInsIGXRhoRP) commRealIGXInstanceRx.endIteration();
break;
1646 case 2 :
if(config.useRInsIGYRhoRP) commRealIGYInstanceRx.endIteration();
break;
1647 case 3 :
if(config.useRInsIGZRhoRP) commRealIGZInstanceRx.endIteration();
break;
1648 default: CkAbort(
"impossible iopt");
break;
1675 int **listSubGx = sim->listSubGx;
1676 int *numSubGx = sim->numSubGx;
1678 int size = msg->size;
1679 int iopt = msg->iopt;
1681 int offset = msg->offset;
1684 CkAssert(size==myNgridb*num);
1685 CkAssert(rhoRsubplanes>1);
1690 case 0: dataC = rho_rs.densityC; dataR = rho_rs.density;
break;
1691 case 1: dataC = rho_rs.rhoIRXC; dataR = rho_rs.rhoIRX;
break;
1692 case 2: dataC = rho_rs.rhoIRYC; dataR = rho_rs.rhoIRY;
break;
1693 case 3: dataC = rho_rs.rhoIRZC; dataR = rho_rs.rhoIRZ;
break;
1694 case 4: dataC = rho_rs.VksHartC; dataR = rho_rs.VksHart;
break;
1695 default: CkAbort(
"Impossible option\n");
break;
1701 countIntGtoR[iopt]++;
1702 if(countIntGtoR[iopt]==1){bzero(dataR,
sizeof(
double)*nptsExpndB);}
1704 int stride = ngrida/2+1;
1706 for(
int js=0,j=0;js<size;js+=num,j++){
1708 for(
int is=js,i=0;is<(num+js);is++,i++){
1709 dataC[(listSubGx[offset][i]+jj)] = msgData[is];
1713 int nst = listSubGx[offset][0];
1714 for(
int js=0,j=0;js<size;js+=num,j++){
1715 int jj = j*stride+nst;
1716 for(
int is=js,i=jj;is<(num+js);is++,i++){
1717 dataC[i] = msgData[is];
1728 if(countIntGtoR[iopt]==rhoRsubplanes){
1730 countIntGtoR[iopt]=0;
1731 FFTcache *fftcache = UfftCacheProxy[thisInstance.proxyOffset].ckLocalBranch();
1732 #if CMK_TRACE_ENABLED
1733 double StartTime=CmiWallTimer();
1736 #if CMK_TRACE_ENABLED
1737 traceUserBracketEvent(doRhoFFTGxtoRx_, StartTime, CmiWallTimer());
1751 if(1 <= iopt && iopt <=3){
1753 if(doneGradRhoVks==3){
1791 if(cp_grad_corr_on==0){
1792 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
1793 CkPrintf(
"Don't come in the grad corr routines when\n");
1794 CkPrintf(
"gradient corrections are off\n");
1795 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
1799 double *density = rho_rs.density;
1800 double *Vks = rho_rs.Vks;
1801 double *rhoIRX = rho_rs.rhoIRX;
1802 double *rhoIRY = rho_rs.rhoIRY;
1803 double *rhoIRZ = rho_rs.rhoIRZ;
1808 int npts = config.numFFTPoints;
1809 double *exc_gga_ret = &(rho_rs.exc_gga_ret);
1813 #ifdef _CP_DEBUG_RHOR_VKSC_
1814 char myFileName[MAX_CHAR_ARRAY_LENGTH];
1815 sprintf(myFileName,
"BGradRho_Real_%d_%d.out", thisIndex.x,thisIndex.y);
1816 FILE *fp = fopen(myFileName,
"w");
1817 for (
int i = 0; i <ngridb*ngrida; i++){
1818 fprintf(fp,
"%g %g %g %g\n",rho_rs.rhoIRX[i],rho_rs.rhoIRY[i],rho_rs.rhoIRZ[i],
1827 rho_rs.exc_gga_ret = 0.0;
1831 #if CMK_TRACE_ENABLED
1832 double StartTime=CmiWallTimer();
1834 CPXCFNCTS::CP_getGGAFunctional(npts,nf1,nf2,nf3,density,rhoIRX,rhoIRY,rhoIRZ,
1836 #if CMK_TRACE_ENABLED
1837 traceUserBracketEvent(GradCorrGGA_, StartTime, CmiWallTimer());
1846 exc[0]=rho_rs.exc_ret;
1847 exc[1]=rho_rs.exc_gga_ret;
1848 contribute(2*
sizeof(
double),exc,CkReduction::sum_double);
1853 #ifdef _CP_DEBUG_RHOR_VKSD_
1854 myFileName[MAX_CHAR_ARRAY_LENGTH];
1855 sprintf(myFileName,
"AGradRho_Real_%d_%d.out", thisIndex.x,thisIndex.y);
1856 fp = fopen(myFileName,
"w");
1857 for (
int i = 0; i <ngridb*ngrida; i++){
1858 fprintf(fp,
"%g %g %g %g\n",rho_rs.rhoIRX[i],rho_rs.rhoIRY[i],rho_rs.rhoIRZ[i],
1890 FFTcache *fftcache = UfftCacheProxy[thisInstance.proxyOffset].ckLocalBranch();
1891 double *rhoIRX = rho_rs.rhoIRX;
1892 double *rhoIRY = rho_rs.rhoIRY;
1893 double *rhoIRZ = rho_rs.rhoIRZ;
1894 complex *rhoIRXC = rho_rs.rhoIRXC;
1895 complex *rhoIRYC = rho_rs.rhoIRYC;
1896 complex *rhoIRZC = rho_rs.rhoIRZC;
1905 #if CMK_TRACE_ENABLED
1906 double StartTime=CmiWallTimer();
1909 rho_rs.scale(rhoIRX,FFTscale);
1911 if(rhoRsubplanes==1){
1919 #if CMK_TRACE_ENABLED
1920 traceUserBracketEvent(WhiteByrdFFTX_, StartTime, CmiWallTimer());
1926 #if CMK_TRACE_ENABLED
1927 StartTime=CmiWallTimer();
1930 rho_rs.scale(rhoIRY,FFTscale);
1932 if(rhoRsubplanes==1){
1940 #if CMK_TRACE_ENABLED
1941 traceUserBracketEvent(WhiteByrdFFTY_, StartTime, CmiWallTimer());
1947 #if CMK_TRACE_ENABLED
1948 StartTime=CmiWallTimer();
1951 rho_rs.scale(rhoIRZ,FFTscale);
1952 if(rhoRsubplanes==1){
1960 #if CMK_TRACE_ENABLED
1961 traceUserBracketEvent(WhiteByrdFFTZ_, StartTime, CmiWallTimer());
1967 if(rhoRsubplanes==1 && config.rhoGToRhoRMsgComb==1){
1992 #ifdef _CP_DEBUG_RHOR_VERBOSE_
1993 CkPrintf(
"WhiteByrd Data from RhoG arriving at RhoR : %d %d\n",
1994 thisIndex.x,thisIndex.y);
2001 int nchareG = sim->nchareRhoG;
2002 int **tranUnpack = sim->index_tran_upack_rho;
2003 int *nlines_per_chareG = sim->nlines_per_chareRhoG;
2004 int ***tranupack_rhoY = sim->index_tran_upack_rho_y;
2005 int **nlines_per_chareRhoGY = sim->nline_send_rho_y;
2006 int iy = thisIndex.y;
2008 int size = msg->size;
2009 int Index = msg->senderIndex;
2010 int iopt = msg->iopt;
2011 complex *partiallyFFTd = msg->data;
2015 if(rhoRsubplanes==1){
2016 mySize = nlines_per_chareG[Index];
2017 nptsExpnd = nptsExpndB;
2019 mySize = nlines_per_chareRhoGY[Index][iy];
2020 nptsExpnd = nptsExpndA;
2027 if (countWhiteByrd > recvCountFromGRho) {
2028 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
2029 CkPrintf(
"Mismatch in allowed rho_gspace chare arrays : %d %d %d %d\n",
2030 countWhiteByrd,nchareG,thisIndex.x,thisIndex.y);
2031 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
2036 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
2037 CkPrintf(
"Dude.2, %d != %d for rho chare %d %d\n",size,mySize,
2039 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
2048 if(rhoRsubplanes==1){
2049 dataR = rho_rs.density;
2050 dataC = rho_rs.densityC;
2052 dataR = rho_rs.rhoIRXint;
2053 dataC = rho_rs.rhoIRXCint;
2057 if(countWhiteByrd==1){bzero(dataR,
sizeof(
double)*nptsExpnd);}
2059 if(rhoRsubplanes==1){
2060 for(
int i=0;i<size;i++){
2061 dataC[tranUnpack[Index][i]] = partiallyFFTd[i];
2064 for(
int i=0;i<size;i++){
2065 dataC[tranupack_rhoY[Index][iy][i]] = partiallyFFTd[i];
2074 if(countWhiteByrd == recvCountFromGRho){
2077 #if CMK_TRACE_ENABLED
2078 double StartTime=CmiWallTimer();
2080 FFTcache *fftcache = UfftCacheProxy[thisInstance.proxyOffset].ckLocalBranch();
2081 if(rhoRsubplanes==1){
2088 #if CMK_TRACE_ENABLED
2089 traceUserBracketEvent(PostByrdfwFFTGtoR_, StartTime, CmiWallTimer());
2111 int nptsExpnd = nptsExpndB;
2112 double *dataR = rho_rs.density;
2113 double *Vks = rho_rs.Vks;
2114 for(
int i=0;i<nptsExpnd;i++){Vks[i] -= dataR[i];}
2119 doneWhiteByrd =
true;
2149 int nchareG = sim->nchareRhoG;
2150 int **tranUnpack = sim->index_tran_upack_rho;
2151 int *nlines_per_chareG = sim->nlines_per_chareRhoG;
2152 int ***tranupack_rhoY = sim->index_tran_upack_eext_ys;
2153 int **nlines_per_chareRhoGY = sim->nline_send_eext_y;
2154 int iy = thisIndex.y;
2156 int size = msg->size;
2157 int IndexS = msg->index;
2158 int Index = msg->senderBigIndex;
2159 int istrt_lines = msg->senderStrtLine;
2160 int iopt = msg->iopt;
2161 complex *partiallyFFTd = msg->data;
2167 if(rhoRsubplanes==1){
2168 dataR = rho_rs.VksHart;
2169 dataC = rho_rs.VksHartC;
2170 nptsExpnd = nptsExpndB;
2173 dataR = rho_rs.VksHartint;
2174 dataC = rho_rs.VksHartCint;
2175 nptsExpnd = nptsExpndA;
2176 mySize = nlines_per_chareRhoGY[IndexS][iy];
2179 CkAssert(size==mySize);
2183 #ifdef _CP_DEBUG_RHOR_VERBOSE_
2184 CkPrintf(
"Data from RhoG arriving at RhoR : %d %d %d %d\n",
2185 thisIndex.x,thisIndex.y,iopt,countGradVks[iopt]);
2190 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
2191 CkPrintf(
"Dude.2, %d != %d for rho chare %d %d : %d\n",size,mySize,
2192 thisIndex.y,IndexS,Index);
2193 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
2200 countGradVks[iopt]++;
2201 if(countGradVks[iopt]==1){bzero(dataR,
sizeof(
double)*nptsExpnd);}
2203 if(rhoRsubplanes==1){
2204 for(
int i=0,j=istrt_lines;i<size;i++,j++){
2205 dataC[tranUnpack[Index][j]] = partiallyFFTd[i];
2208 for(
int i=0;i<size;i++){
2209 dataC[tranupack_rhoY[IndexS][iy][i]] = partiallyFFTd[i];
2218 if (countGradVks[iopt] == recvCountFromGHartExt){
2219 countGradVks[iopt]=0;
2221 FFTcache *fftcache = UfftCacheProxy[thisInstance.proxyOffset].ckLocalBranch();
2222 #if CMK_TRACE_ENABLED
2223 double StartTime=CmiWallTimer();
2225 if(rhoRsubplanes==1){
2233 #if CMK_TRACE_ENABLED
2234 traceUserBracketEvent(fwFFTGtoR0_, StartTime, CmiWallTimer());
2255 int nptsExpnd = nptsExpndB;
2256 double *dataR = rho_rs.VksHart;
2257 double *Vks = rho_rs.Vks;
2258 for(
int i=0;i<nptsExpnd;i++){Vks[i]+=dataR[i];}
2280 if(countRHart==countRHartValue){
2299 if(doneWhiteByrd && doneRHart && doneHartVks){
doMulticast();}
2315 if(!doneWhiteByrd || !doneHartVks || !doneRHart){
2316 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
2317 CkPrintf(
"Flow of Control Error : Attempting to rho multicast\n");
2318 CkPrintf(
"without harteext or gradcorr (whitebyrd) \n");
2319 CkPrintf(
"without rhodensity or rhart \n");
2320 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
2326 doneWhiteByrd =
false;
2327 doneHartVks =
false;
2333 int dataSize = ngrida*myNgridb;
2334 double *Vks = rho_rs.Vks;
2336 if ((config.useGMulticast+config.useCommlibMulticast)!=1) {
2337 CkAbort(
"No multicast strategy\n");
2340 if (config.useGMulticast || config.useCommlibMulticast) {
2345 msg->idx = thisIndex.x;
2346 msg->datalen = dataSize;
2348 msg->subplane = thisIndex.y;
2349 double *dataR = msg->data;
2351 rho_rs.uPackShrink(dataR,Vks);
2353 #ifdef _CP_DEBUG_RHOR_VKSE_
2354 char myFileName[MAX_CHAR_ARRAY_LENGTH];
2355 sprintf(myFileName,
"vks_rho_Real_%d_%d.out", thisIndex.x,thisIndex.y);
2356 FILE *fp = fopen(myFileName,
"w");
2357 for (
int j = 0, iii=0; j <myNgridb; j++){
2358 for (
int i = 0; i <ngrida; i++,iii++){
2359 fprintf(fp,
"%d %d %g\n",i,j+myBoff,dataR[iii]);
2371 for(
int kp=0;kp<config.UberJmax;kp++)
2374 if(kp+1<config.UberJmax)
2379 loopm->idx = thisIndex.x;
2380 loopm->datalen = dataSize;
2382 loopm->subplane = thisIndex.y;
2383 memcpy(loopm->data, msg->data, msg->datalen*
sizeof(
double));
2387 if(config.useCommlibMulticast){
2388 realSpaceSectionCProxyA[kp].acceptProduct(loopm);
2390 realSpaceSectionProxyA[kp].acceptProduct(loopm);
2401 #ifdef _CP_SUBSTEP_TIMING_
2404 double rhoend=CmiWallTimer();
2405 contribute(
sizeof(
double), &rhoend, CkReduction::max_double, CkCallback(CkIndex_TimeKeeper::collectEnd(NULL),0,TimeKeeperProxy),rhoKeeperId);
2424 if(countDebug==(rhoRsubplanes*ngridc)){
2426 CkPrintf(
"I am in the exitfordebuging rhoreal puppy. Bye-bye\n");
2437 void CP_Rho_RealSpacePlane::ResumeFromSync(){
2457 for(
int x=0;x<32;x++){
2459 if(y==input){
return true;}
void acceptRhoGradVksGxToRx(RhoGSFFTMsg *msg)
Double Transpose Bck Recv : A(gx,y,z) on the way to A(x,y,z) Recv (gx,z) parallel -> (y...
void acceptDensity(CkReductionMsg *)
Data comes from StateRspacePlane once an algorithm step.
void sendPartlyFFTtoRhoG(int)
The Tranpose to G-space : A(gx,gy,z) on the way to A(gx,gy,gz) Change parallel by gx...
holds the UberIndex and the offset for proxies
void addHartEextVks()
Add the VksHartEext to VksTot : Set the done flag.
int nfreq_xcfnctl
CPXCFNCTS::CP_exc_calc, CPXCFNCTS::CP_getGGAFunctional ////////////////////////////////=.
void doRhoFFTGtoR_Rchare(complex *, double *, int, int, int, int)
void addWhiteByrdVks()
Add the VksWhiteByrd to VksTot : Set the done flag.
void doRhoFFTRxToGx_Rchare(complex *, double *, int, int, int, int)
void exitForDebugging()
Glenn's RhoReal exit.
void whiteByrdFFT()
The white-bird term : First fwfft redefined delrho(r) to delrho(g) then send to RhoGspacePlane.
void doMulticastCheck()
If all the parts of exc-eext-hart are done, invoke blast of vks to states.
void acceptWhiteByrd(RhoRSFFTMsg *msg)
The white bird vks correction is returned from RhoG : VksW(gx,gy,z) This routine recvs the transpose ...
void launchEextRNlG()
The density is here : Launch ees NL and ees Ext routines.
void fftRhoRyToGy(int iopt)
Double Transpose Fwd FFT : A(gx,y,z) -> A(gx,gy,z)
void GradCorr()
The gradient of the density is now completed.
CkGroupID mCastGrpId
Multicast manager group that handles many mcast/redns in the code. Grep for info. ...
Add type declarations for simulationConstants class (readonly vars) and once class for each type of o...
void doRhoFFTGyToRy_Rchare(complex *, double *, int, int, int, int)
void doMulticast()
Send vks back to the states /////////////////////////////////////////////////////////////////////////...
void acceptHartVks(RhoHartRSFFTMsg *)
Accept hartExt transpose data : receive VksHartEext(gx,gy,z) gx,z is parallel.
void acceptGradRhoVks(RhoRSFFTMsg *)
Accept transpose data from RhoG : receive grad_rho(gy,gx,z)
void launchNLRealFFT()
Launch ees-nonlocal real here.
void handleDensityReduction()
Handle the memory cleanup and setting of flags when density has all arrived.
void init()
post constructor initialization
void sendPartlyFFTGxToRx(int)
Double Transpose Bck Send : A(gx,y,z) on the way to A(x,y,z) Send so (gx,z) parallel -> (y...
bool is_pow2(int)
return tru if input is power of 2
void energyComputation()
Compute one part of the EXC energy using PINY CP_exc_calc.
Some basic data structures and the array map classes are defined here.
void acceptRhoGradVksRyToGy(RhoGSFFTMsg *msg)
Double Transpose Fwd Recv : A(gx,y,z) on the way to A(gx,gy,z) Recv so that (y,z) parallel switched t...
void fftRhoRtoRhoG()
1) Perform FFT of density: Single Transpose method rho(x,y,z) —> rho(gx,gy,z) Double Transpose method...
void acceptGradRhoVksAll(RhoRSFFTMsg *msg)
Accept transpose data from RhoG : receive grad_rho(gy,gx,z)
void sendPartlyFFTRyToGy(int iopt)
Double Transpose Fwd Send : A(gx,y,z) on the way to A(gx,gy,z) Send so that (y,z) parallelism is swit...
void doRhoFFTGxToRx_Rchare(complex *, double *, int, int, int, int)
void doRhoFFTRtoG_Rchare(complex *, double *, int, int, int, int)
void sendPartlyFFTtoRhoGall()
void RHartReport()
Under ees-eext Rhart chare reports its completion : Set the done flag.
void doRhoFFTRyToGy_Rchare(complex *, double *, int, int, int, int)
void pup(PUP::er &)
Pup my variables for migration.