OpenAtom  Version1.5a
CP_Rho_GSpacePlane.C
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////
2 //////////////////////////////////////////////////////////////////////////////
3 //////////////////////////////////////////////////////////////////////////////
4 /** \file CP_Rho_GSpacePlane.C
5  ** @addtogroup Density
6  * @{
7  *
8  * This is a description of the "life" of a CP_Rho_GSpacePlane object
9  *
10  * At the start of the program, the constructor CP_Rho_GSpacePlane is called.
11  * The RealSpaceDensity objects send data to CP_Rho_GSpacePlane using the
12  * acceptData() method. Inverse ffts in z and x directions are performed
13  * before the data is received, so here inverse fft in y direction is
14  * performed. This data is processed using the CP_hart_eext_calc. Then forward
15  * fft in the y direction is performed and data is send back to
16  * RealSpaceDensity objects.
17  *
18  * The CP_Rho_GSpacePlaneHelper objects essentially help to split the work involved
19  * in g-space density computation. They receive their share of the work
20  * through the method recvCP_Rho_GSpacePlanePart() and send the processed
21  * data back to CP_Rho_GSpacePlane objects using the recvProcessedPart() method.
22  *
23  */
24 //////////////////////////////////////////////////////////////////////////////
25 
26 #include "charm++.h"
27 #include <iostream>
28 #include <fstream>
29 #include <cmath>
30 
31 #include "debug_flags.h"
32 #include "utility/util.h"
33 #include "main/cpaimd.h"
36 
37 #include "src_piny_physics_v1.0/include/class_defs/CP_OPERATIONS/class_cplocal.h"
38 #include "src_piny_physics_v1.0/include/class_defs/CP_OPERATIONS/class_cpxcfnctls.h"
39 
40 //////////////////////////////////////////////////////////////////////////////
41 
42 extern Config config;
43 extern CkVec <CProxy_CP_Rho_RealSpacePlane> UrhoRealProxy;
44 extern CkVec <CProxy_CP_Rho_GHartExt> UrhoGHartExtProxy;
45 extern CkVec <CProxy_CP_State_GSpacePlane> UgSpacePlaneProxy;
46 extern CkVec <CProxy_GSpaceDriver> UgSpaceDriverProxy;
47 
48 extern ComlibInstanceHandle commGInstance0;
49 extern ComlibInstanceHandle commGInstance1;
50 extern ComlibInstanceHandle commGInstance2;
51 extern ComlibInstanceHandle commGInstance3;
52 extern ComlibInstanceHandle commGByrdInstance;
53 extern CProxy_ComlibManager mgrProxy;
54 
55 extern CkVec <CProxy_CP_Rho_GSpacePlane> UrhoGProxy;
56 extern CkVec <CProxy_FFTcache> UfftCacheProxy;
57 ///extern ComlibInstanceHandle mssInstance;
58 
59 //#define _CP_DEBUG_RHOG_VERBOSE_
60 //////////////////////////////////////////////////////////////////////////////
61 
62 //////////////////////////////////////////////////////////////////////////////
63 //////////////////////////////////////////////////////////////////////////////
64 //////////////////////////////////////////////////////////////////////////////
65 CP_Rho_GSpacePlane::CP_Rho_GSpacePlane(int sizeX,
66  int numRealSpace,
67  int numRealSpaceDensity,
68  bool _useCommlib,
69  UberCollection _instance) :
70  thisInstance(_instance)
71 //////////////////////////////////////////////////////////////////////////////
72  {//begin routine
73 //////////////////////////////////////////////////////////////////////////////
74 #ifdef _CP_DEBUG_RHOG_VERBOSE_
75  CkPrintf("[%d %d] Rho GS constructor\n",thisIndex.x,thisIndex.y);
76 #endif
77 //////////////////////////////////////////////////////////////////////////////
78 /// Set counters local variables
79 
80  CPcharmParaInfo *sim = CPcharmParaInfo::get();
81  cp_grad_corr_on = sim->cp_grad_corr_on;
82 
83  iplane_ind = thisIndex.x;
84  rhoRsubplanes = config.rhoRsubplanes;
85  count = 0;
86  countDebug = 0;
87  count = 0;
88  myTime = 1;
89 
90  doneWhiteByrd = 0;
91  for(int i=1;i<=3;i++){countWhiteByrd[i]=0;}
92 
93  int sizeZ=sim->sizeZ;
94  if(rhoRsubplanes>1){
95  recvCountFromRRho = 0;
96  for(int i=0;i<rhoRsubplanes;i++){
97  if(sim->nline_send_rho_y[thisIndex.x][i]>0){recvCountFromRRho++;}
98  }//endfor
99  recvCountFromRRho*=sizeZ;
100  }else{
101  recvCountFromRRho=sizeZ;
102  }//endif
103 
104 
105 //////////////////////////////////////////////////////////////////////////////
106 /// Deal with the run descriptors then malloc
107 
108  //------------------------------------------------------------------------
109  // Run descriptors
110  CkVec <RunDescriptor> *sortedRunDescriptors = sim->RhosortedRunDescriptors;
111 
112  rho_gs.sizeX = sizeX;
113  rho_gs.sizeY = sim->sizeY;
114  rho_gs.sizeZ = sim->sizeZ;
115 
116  int x = thisIndex.x;
117 
118  rho_gs.numRuns = sortedRunDescriptors[x].size();
119  rho_gs.numLines = sortedRunDescriptors[x].size()/2;
120  rho_gs.numFull = (rho_gs.numLines)*rho_gs.sizeZ;
121  rho_gs.size = rho_gs.numFull;
122  rho_gs.runs = new RunDescriptor[rho_gs.numRuns];
123  rho_gs.numPoints = 0;
124  for (int r = 0; r < rho_gs.numRuns; r++) {
125  rho_gs.numPoints += sortedRunDescriptors[x][r].length;
126  rho_gs.runs[r] = sortedRunDescriptors[x][r];
127  }//endfor
128 
129  //------------------------------------------------------------------------
130  // Malloc and set your kvectors
131  rho_gs.setKVectors(&nPacked); // consistency with numPoints checked within
132  rho_gs.nPacked = nPacked;
133 
134  //------------------------------------------------------------------------
135  // Malloc density (packed Rho) and a master scratch array (Rho)
136 
137  int numFull = rho_gs.numFull;
138  // Full size Needed to receive from realSpace whenever it feels like sending
139  rho_gs.divRhoX = (complex *)fftw_malloc(numFull*sizeof(complex));
140  rho_gs.divRhoY = (complex *)fftw_malloc(numFull*sizeof(complex));
141  rho_gs.divRhoZ = (complex *)fftw_malloc(numFull*sizeof(complex));
142 
143  rho_gs.Rho = NULL; // clean out my memory
144  rho_gs.packedVks = NULL;
145  rho_gs.packedRho = NULL;
146 
147 //////////////////////////////////////////////////////////////////////////////
148 /// Decompose your g-space further to create/define GHartEext Chare
149 
150  rhoGHelpers = config.rhoGHelpers;
151  int num_line_tot = rho_gs.numLines;
152  numSplit = new int [rhoGHelpers];
153  istrtSplit = new int [rhoGHelpers];
154  iendSplit = new int [rhoGHelpers];
155 
156  x = thisIndex.x;
157  int istrt_pts = 0;
158  for(int i=0;i<rhoGHelpers;i++){
159 
160  int istrt_line,iend_line,num_line;
161  getSplitDecomp(&istrt_line,&iend_line,&num_line,num_line_tot,rhoGHelpers,i);
162 
163  int num_pts=0;
164  for (int r=(2*istrt_line);r<(2*iend_line);r++){
165  num_pts += sortedRunDescriptors[x][r].length;
166  }//endif
167 
168  istrtSplit[i] = istrt_pts;
169  numSplit[i] = num_pts;
170  iendSplit[i] = istrt_pts+num_pts;
171 
172  istrt_pts += num_pts;
173  }//endfor
174 
175 
176  usesAtSync = true;
177  if(config.lbdensity){
178  setMigratable(true);
179  }else{
180  setMigratable(false);
181  }//endif
182 
183 //---------------------------------------------------------------------------
184  }//end routine
185 //////////////////////////////////////////////////////////////////////////////
186 
187 ///post constructor initialization
188 //////////////////////////////////////////////////////////////////////////////
189 //////////////////////////////////////////////////////////////////////////////
190 //////////////////////////////////////////////////////////////////////////////
192 {
193  CPcharmParaInfo *sim = CPcharmParaInfo::get();
194  //make section proxy
195  if(sim->ees_nloc_on==1 && config.launchNLeesFromRho==2){
196  // haven't written support for kpoint rhog nl launch yet
197  // not that hard to do, but also probably not worth doing unless
198  // we clearly need this feature to work.
199  CkAssert(config.UberJmax<=1);
200 
201  if(config.nchareRhoG<config.nchareG)
202  {
203  // just divvy them up as well as we can
204  int gperrho=config.nchareG/config.nchareRhoG;
205  int grem= config.nchareG%config.nchareRhoG;
206  int startplane=thisIndex.x*gperrho;
207  int endplane=startplane;
208  if(gperrho>1)
209  endplane=startplane+gperrho;
210  //dump the remainders into the 0th section
211  if(grem>0 && thisIndex.x<grem)
212  { // manual section creation for our share plus remainder
213  CkArrayIndexMax *elems= new CkArrayIndexMax[config.nstates*(gperrho+grem)];
214  int ecount=0;
215  //our usual share
216  for(int plane=startplane;plane<=endplane;plane++)
217  for(int state =0; state<config.nstates;state++)
218  {
219  CkArrayIndex2D idx2d(state,plane);
220  elems[ecount++]=idx2d;
221  }
222  // the overflow
223  int plane=config.nchareRhoG+thisIndex.x;
224  for(int state =0; state<config.nstates;state++)
225  {
226  CkArrayIndex2D idx2d(state,plane);
227  elems[ecount++]=idx2d;
228  }
229  // for(int i=0;i<ecount;i++)
230  // CkPrintf("nl sect %d %d\n",elems[i].data()[0],elems[i].data()[1]);
231  nlsectproxy = CProxySection_GSpaceDriver::ckNew(UgSpaceDriverProxy[thisInstance.proxyOffset].ckGetArrayID(),elems,ecount);
232  delete [] elems;
233  }
234  else
235  {
236  nlsectproxy = CProxySection_GSpaceDriver::ckNew(UgSpaceDriverProxy[thisInstance.proxyOffset].ckGetArrayID(),
237  0, config.nstates-1, 1,startplane, endplane, 1);
238  // CkPrintf("nl sect state 0 through %d plane %d through %d\n",config.nstates-1,startplane, endplane);
239  }
240  }
241  else
242  {
243  if(thisIndex.x<config.nchareG){
244  nlsectproxy = CProxySection_GSpaceDriver::ckNew(UgSpaceDriverProxy[thisInstance.proxyOffset].ckGetArrayID(),
245  0, config.nstates-1, 1,thisIndex.x, thisIndex.x, 1);
246  }//endif
247  }
248  }//endif
249 //////////////////////////////////////////////////////////////////////////////
250 /// Set up proxies and set migration options
251 
252  rhoRealProxy0_com = UrhoRealProxy[thisInstance.proxyOffset];
253  rhoRealProxy1_com = UrhoRealProxy[thisInstance.proxyOffset];
254  rhoRealProxy2_com = UrhoRealProxy[thisInstance.proxyOffset];
255  rhoRealProxy3_com = UrhoRealProxy[thisInstance.proxyOffset];
256  rhoRealProxyByrd_com = UrhoRealProxy[thisInstance.proxyOffset];
257 
258 #ifdef USE_COMLIB
259  if(config.useGIns0RhoRP)
260  ComlibAssociateProxy(commGInstance0,rhoRealProxy0_com);
261  if(config.useGIns1RhoRP)
262  ComlibAssociateProxy(commGInstance1,rhoRealProxy1_com);
263  if(config.useGIns2RhoRP)
264  ComlibAssociateProxy(commGInstance2,rhoRealProxy2_com);
265  if(config.useGIns3RhoRP)
266  ComlibAssociateProxy(commGInstance3,rhoRealProxy3_com);
267  if(config.useGByrdInsRhoRBP)
268  ComlibAssociateProxy(commGByrdInstance,rhoRealProxyByrd_com);
269 #endif
270 
271 }
272 
273 
274 //////////////////////////////////////////////////////////////////////////////
275 //////////////////////////////////////////////////////////////////////////////
276 //////////////////////////////////////////////////////////////////////////////
277 CP_Rho_GSpacePlane::~CP_Rho_GSpacePlane(){
278  if(numSplit!=NULL)
279  delete [] numSplit;
280  if(istrtSplit!=NULL)
281  delete [] istrtSplit;
282  if(iendSplit != NULL)
283  delete [] iendSplit;
284 }
285 //////////////////////////////////////////////////////////////////////////////
286 
287 //////////////////////////////////////////////////////////////////////////////
288 //////////////////////////////////////////////////////////////////////////////
289 //////////////////////////////////////////////////////////////////////////////
290 void CP_Rho_GSpacePlane::pup(PUP::er &p){
291  ArrayElement2D::pup(p);
292  p|iplane_ind;
293  p|nPacked;
294  p|count;
295  PUParray(p,countWhiteByrd,4);
296  p|doneWhiteByrd;
297  p|rhoGHelpers;
298  p|rhoRsubplanes;
299  rho_gs.pup(p); // I pup my data class
300  if(p.isUnpacking()){
301  numSplit = new int[rhoGHelpers];
302  istrtSplit = new int[rhoGHelpers];
303  iendSplit = new int[rhoGHelpers];
304  }//endif
305  PUParray(p,numSplit,rhoGHelpers);
306  PUParray(p,istrtSplit,rhoGHelpers);
307  PUParray(p,iendSplit,rhoGHelpers);
308  if(p.isUnpacking()){
309  //pupping of comlib proxies unreliable
310  rhoRealProxy0_com = UrhoRealProxy[thisInstance.proxyOffset];
311  rhoRealProxy1_com = UrhoRealProxy[thisInstance.proxyOffset];
312  rhoRealProxy2_com = UrhoRealProxy[thisInstance.proxyOffset];
313  rhoRealProxy3_com = UrhoRealProxy[thisInstance.proxyOffset];
314  rhoRealProxyByrd_com = UrhoRealProxy[thisInstance.proxyOffset];
315 
316 #ifdef USE_COMLIB
317  if(config.useGIns0RhoRP)
318  ComlibAssociateProxy(commGInstance0,rhoRealProxy0_com);
319  if(config.useGIns1RhoRP)
320  ComlibAssociateProxy(commGInstance1,rhoRealProxy1_com);
321  if(config.useGIns2RhoRP)
322  ComlibAssociateProxy(commGInstance2,rhoRealProxy2_com);
323  if(config.useGIns3RhoRP)
324  ComlibAssociateProxy(commGInstance3,rhoRealProxy3_com);
325  if(config.useGByrdInsRhoRBP)
326  ComlibAssociateProxy(commGByrdInstance,rhoRealProxyByrd_com);
327 #endif
328 
329  }//endif
330 
331 //--------------------------------------------------------------------------
332  }//end routine
333 //////////////////////////////////////////////////////////////////////////////
334 
335 
336 //////////////////////////////////////////////////////////////////////////////
337 /// RhoReal sends rho(gx,gy,z) here such that it is now decomposed
338 /// with lines of constant gx,gy in funny order to load balance.
339 /// Nothing can return to this chare UNTIL this message is fully received
340 /// and processed. Thus, we can receive into divRhox and use cache to post
341 /// process
342 //////////////////////////////////////////////////////////////////////////////
343 //////////////////////////////////////////////////////////////////////////////
344 //////////////////////////////////////////////////////////////////////////////
346 //////////////////////////////////////////////////////////////////////////////
347 #ifdef _CP_DEBUG_RHOG_VERBOSE_
348  CkPrintf("RGS [%d %d] receives message size %d offset %d numlines %d\n",
349  thisIndex.x,thisIndex.y,msg->size,msg->offset,rho_gs.numLines);
350 #endif
351 //////////////////////////////////////////////////////////////////////////////
352 /// Set local pointers, constants,
353 
354  int size = msg->size;
355  int offset = msg->offset; // z index
356  int isub = msg->offsetGx; // subplane index
357  complex *partlyIFFTd = msg->data;
358 
359  CPcharmParaInfo *sim = CPcharmParaInfo::get();
360  int ix = thisIndex.x; // chare array index
361  int sizeZ = rho_gs.sizeZ;
362  int numLines = rho_gs.numLines;
363  int ***index_pack;
364 
365  if(rhoRsubplanes>1){
366  int **nline_send = sim->nline_send_rho_y;
367  index_pack = sim->index_tran_pack_rho_y;
368  numLines = nline_send[ix][isub];
369  }//endif
370 
371 //////////////////////////////////////////////////////////////////////////////
372 /// Check for errors
373 
374 #ifdef _NAN_CHECK_
375  for(int i=0;i<msg->size ;i++){
376  CkAssert(isnan(msg->data[i].re)==0);
377  CkAssert(isnan(msg->data[i].im)==0);
378  }//endfor
379 #endif
380  if(size!=numLines){
381  CkPrintf("@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
382  CkPrintf("size %d != numLines %d\n",size,numLines);
383  CkPrintf("RGS [%d %d] receives message size %d offset %d numlines %d\n",
384  thisIndex.x,thisIndex.y,msg->size,msg->offset,rho_gs.numLines);
385  CkPrintf("@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
386  CkExit();
387  }//endif
388 
389 //////////////////////////////////////////////////////////////////////////////
390 /// upack the message : No need to zero, every value is set
391 
392  complex *chunk = rho_gs.divRhoX;
393 
394  if(rhoRsubplanes==1){
395  for(int i=0,j=offset; i< size; i++,j+=sizeZ){chunk[j] = partlyIFFTd[i];}
396  }else{
397  for(int i=0; i< size; i++){
398  chunk[(offset+index_pack[ix][isub][i])] = partlyIFFTd[i];
399  }//endif
400  }//endif
401 
402  delete msg;
403 
404  if(count==0){count_stuff=0;}
405  count_stuff += size;
406 
407 //////////////////////////////////////////////////////////////////////////////
408 /// when you have all the data, get moving
409 
410  count++;
411  if(count== recvCountFromRRho){
412  if(count_stuff!=rho_gs.numLines*sizeZ){
413  CkPrintf("Not enough stuff %d %d on %d\n",count_stuff,rho_gs.numLines,thisIndex.x);
414  CkExit();
415  }//endif
416  count=0;
417 #ifndef _DEBUG_INT_TRANS_FWD
418  thisProxy(thisIndex.x,thisIndex.y).doRhoFFT();
419 #else
420  char name[100];
421  sprintf(name,"partFFTGxGyZT%d.out.%d",rhoRsubplanes,thisIndex.x);
422  FILE *fp = fopen(name,"w");
423  numLines = rho_gs.numLines;
424  for(int ix =0;ix<numLines;ix++){
425  for(int iy =0;iy<sizeZ;iy++){
426  int i = ix*sizeZ + iy;
427  fprintf(fp,"%d %d : %g %g\n",iy,ix,chunk[i].re,chunk[i].im);
428  }//endfor
429  }//endof
430  fclose(fp);
431  UrhoGProxy[thisInstance.proxyOffset](0,0).exitForDebugging();
432 #endif
433  }//endif
434 
435 //////////////////////////////////////////////////////////////////////////////
436  }//end routine
437 //////////////////////////////////////////////////////////////////////////////
438 
439 
440 //////////////////////////////////////////////////////////////////////////////
441 /// Complete the FFT to give use Rho(gx,gy,gz)
442 //////////////////////////////////////////////////////////////////////////////
443 //////////////////////////////////////////////////////////////////////////////
444 //////////////////////////////////////////////////////////////////////////////
446 //////////////////////////////////////////////////////////////////////////////
447 
448 #ifdef _CP_DEBUG_RHOG_VERBOSE_
449  CkPrintf("Data has arrive in rhogs : peforming FFT %d %d\n",
450  thisIndex.x,thisIndex.y);
451 #endif
452 
453 //////////////////////////////////////////////////////////////////////////////
454 /// I) Finish ffting the density into g-space :
455 /// a)FFT b) Compress to sphere and store in data_out
456 
457  int ioptRho=0;
458 #if CMK_TRACE_ENABLED
459  double StartTime=CmiWallTimer();
460 #endif
461  FFTcache *fftcache = UfftCacheProxy[thisInstance.proxyOffset].ckLocalBranch();
462  fftcache->getCacheMem("CP_Rho_GSpacePlane::acceptRhoData");
463  complex *data_out = fftcache->tmpData;
464  complex *data_in = rho_gs.divRhoX;
465  fftcache->doRhoFFTRtoG_Gchare(data_in,data_out,
466  rho_gs.numFull,rho_gs.numPoints,
467  rho_gs.numLines,rho_gs.numRuns,rho_gs.runs,
468  rho_gs.sizeZ,1,iplane_ind);
469 #if CMK_TRACE_ENABLED
470  traceUserBracketEvent(BwFFTRtoG_, StartTime, CmiWallTimer());
471 #endif
472 
473 //////////////////////////////////////////////////////////////////////////////
474 /// II) Debug output
475 
476 #ifdef _CP_DEBUG_RHOG_RHOG_
477  char myFileName[100];
478  sprintf(myFileName, "Rho_Gspace_%d%d.out", thisIndex.x,thisIndex.y);
479  FILE *fp = fopen(myFileName,"w");
480  for (int i = 0; i < rho_gs.numPoints; i++){
481  fprintf(fp," %d %d %d : %g %g\n",
482  rho_gs.k_x[i],rho_gs.k_y[i],rho_gs.k_z[i],
483  rho_gs.packedRho[i].re,rho_gs.packedRho[i].im);
484  }//endfor
485  fclose(fp);
486 #endif
487 
488 //////////////////////////////////////////////////////////////////////////////
489 /// II) Communicate rho(g) to RHoGHartExt to compute eext and hart part of vks
490 /// or print out that you are taking the day off
491 
492  //------------------------------------------------
493  // Hartree is on, send rhoG to the harteext-G chare
494 #ifndef _CP_DEBUG_HARTEEXT_OFF_ // hartree is cooking
495  int nchareHartAtmT=config.nchareHartAtmT;
496  for(int i=0;i<rhoGHelpers;i++){
497  for(int j=0;j<nchareHartAtmT;j++){
498  RhoGHartMsg *msg = new (numSplit[i],8*sizeof(int)) RhoGHartMsg;
499  msg->size = numSplit[i];
500  msg->senderIndex = thisIndex.x;
501  CmiMemcpy(msg->data,&data_out[istrtSplit[i]],numSplit[i]*sizeof(complex));
502 
503  if(config.prioFFTMsg){
504  CkSetQueueing(msg, CK_QUEUEING_IFIFO);
505  *(int*)CkPriorityPtr(msg) = config.rhorpriority + thisIndex.x+ thisIndex.y;
506  }//endif
507 
508  int index = thisIndex.x*rhoGHelpers + i;
509  UrhoGHartExtProxy[thisInstance.proxyOffset](index,j).acceptData(msg);
510  }//endfor : atmType parallelization
511  }//endfor : helper parallelization
512 #endif
513 
514  //------------------------------------------------
515  // Hartree is off, chill
516 #ifdef _CP_DEBUG_HARTEEXT_OFF_ //hartree is sitting this one out
517  if(thisIndex.x==0 && thisIndex.y==0){
518  CkPrintf("EHART = OFF FOR DEBUGGING\n");
519  CkPrintf("EExt = OFF FOR DEBUGGING\n");
520  CkPrintf("EWALD_recip = OFF FOR DEBUGGING\n");
521  }//endif
522 #endif
523 
524 //////////////////////////////////////////////////////////////////////////////
525 /// III) Start grad corr computations if necessary
526 
527 #if CMK_TRACE_ENABLED
528  StartTime=CmiWallTimer();
529 #endif
530  if(cp_grad_corr_on!=0){
531  divRhoVksGspace();
532  }else{
533  fftcache->freeCacheMem("CP_Rho_GSpacePlane::acceptRhoData");
534  }//endif
535 #if CMK_TRACE_ENABLED
536  traceUserBracketEvent(divRhoVksGspace_, StartTime, CmiWallTimer());
537 #endif
538 
539 //////////////////////////////////////////////////////////////////////////////
540 ///kick off NL if its our job
541 
542  launchNlG();
543 
544 //---------------------------------------------------------------------------
545  }//end routine
546 //////////////////////////////////////////////////////////////////////////////
547 
548 
549 //////////////////////////////////////////////////////////////////////////////
550 //////////////////////////////////////////////////////////////////////////////
551 //////////////////////////////////////////////////////////////////////////////
552 ///
553 /// The density is here : Launch ees NL
554 ///
555 /// Do this once an algorithm step
556 ///
557 //////////////////////////////////////////////////////////////////////////////
559 //////////////////////////////////////////////////////////////////////////////
560 /// Launch the nonlocal energy computation
561 
562  CPcharmParaInfo *sim = CPcharmParaInfo::get();
563 
564  if(sim->ees_nloc_on==1 && config.launchNLeesFromRho==2){
565  /* if(config.nchareRhoG<config.nchareG){
566  // there aren't enough rhoG's so
567  CkPrintf("@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
568  CkPrintf("Bad chare sizes %d %d\n",config.nchareRhoG,config.nchareG);
569  CkPrintf("@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
570  CkExit();
571  }//endif
572  CkAssert(config.nchareRhoG>=config.nchareG);
573  */
574  if(thisIndex.x<config.nchareG){
575  nlsectproxy.startNonLocalEes(myTime);
576  }//endif
577  }//endif
578 
579 //////////////////////////////////////////////////////////////////////////////
580  }//end routine
581 //////////////////////////////////////////////////////////////////////////////
582 
583 //////////////////////////////////////////////////////////////////////////////
584 //////////////////////////////////////////////////////////////////////////////
585 //////////////////////////////////////////////////////////////////////////////
586 /// invoke fft subroutine : doFwFFT() unpack do an FFT 1D along z rho(gx,gy,gz)
587 /// parallelized in full z-lines with constant (gx,gy)
588 /// invoke a transpose back to r-space
589 //////////////////////////////////////////////////////////////////////////////
590 
592 
593 //////////////////////////////////////////////////////////////////////////////
594 /// Setup up options, get box and -i*rho(g)
595 
596  FFTcache *fftcache = UfftCacheProxy[thisInstance.proxyOffset].ckLocalBranch();
597  complex *packedRho = fftcache->tmpData;
598  complex *divRhoX = rho_gs.divRhoX;
599  complex *divRhoY = rho_gs.divRhoY;
600  complex *divRhoZ = rho_gs.divRhoZ;
601  int ioptx = 1;
602  int iopty = 2;
603  int ioptz = 3;
604  double tpi,*hmati;
605 
606  CPXCFNCTS::CP_fetch_hmati(&hmati,&tpi);
607  rho_gs.divRhoGdot(hmati,tpi,packedRho); //divRhoAlpha's are class variable
608  fftcache->freeCacheMem("CP_Rho_GSpacePlane::divRhoVksGspace");
609 
610 //////////////////////////////////////////////////////////////////////////////
611 /// I) fft_gz(divRhoX), launch transpose to R-space
612 
613  fftcache->doRhoFFTGtoR_Gchare(divRhoX,divRhoX,rho_gs.numFull,rho_gs.numPoints,
614  rho_gs.numLines,rho_gs.numRuns,rho_gs.runs,
615  rho_gs.sizeZ,0,iplane_ind);
616  if(config.rhoGToRhoRMsgComb==0){RhoGSendRhoR(ioptx);}
617 
618 //////////////////////////////////////////////////////////////////////////////
619 /// II) fft_gz(divRhoY), launch transpose to R-space
620 
621  fftcache->doRhoFFTGtoR_Gchare(divRhoY,divRhoY,rho_gs.numFull,rho_gs.numPoints,
622  rho_gs.numLines,rho_gs.numRuns,rho_gs.runs,
623  rho_gs.sizeZ,0,iplane_ind);
624  if(config.rhoGToRhoRMsgComb==0){RhoGSendRhoR(iopty);}
625 
626 //////////////////////////////////////////////////////////////////////////////
627 /// III) fft_gz(divRhoZ), launch transpose to R-space
628 
629  fftcache->doRhoFFTGtoR_Gchare(divRhoZ,divRhoZ,rho_gs.numFull,rho_gs.numPoints,
630  rho_gs.numLines,rho_gs.numRuns,rho_gs.runs,
631  rho_gs.sizeZ,0,iplane_ind);
632  if(config.rhoGToRhoRMsgComb==0){RhoGSendRhoR(ioptz);}
633 
634 //////////////////////////////////////////////////////////////////////////////
635 
636  if(config.rhoGToRhoRMsgComb==1){RhoGSendRhoRall();}
637 
638 //---------------------------------------------------------------------------
639  }//end routine
640 //////////////////////////////////////////////////////////////////////////////
641 
642 
643 
644 //////////////////////////////////////////////////////////////////////////////
645 //////////////////////////////////////////////////////////////////////////////
646 //////////////////////////////////////////////////////////////////////////////
648 //////////////////////////////////////////////////////////////////////////////
649 
650 #ifdef _CP_DEBUG_RHOG_VERBOSE_
651  CkPrintf("Communicating data from RhoG to RhoR : %d %d %d\n",
652  thisIndex.x,thisIndex.y,iopt);
653 #endif
654 
655 //////////////////////////////////////////////////////////////////////////////
656 /// Local Pointers and Variables
657 
658  CPcharmParaInfo *sim = CPcharmParaInfo::get();
659  int sizeZ = rho_gs.sizeZ;
660  int ix = thisIndex.x;
661  int numLines = rho_gs.numLines;
662  int ***index_pack;
663  int **nline_send;
664  if(rhoRsubplanes>1){
665  nline_send = sim->nline_send_rho_y;
666  index_pack = sim->index_tran_pack_rho_y;
667  }//endif
668 
669  complex *ffttempdata;
670  switch(iopt){
671  case 1 : ffttempdata = rho_gs.divRhoX; break;
672  case 2 : ffttempdata = rho_gs.divRhoY; break;
673  case 3 : ffttempdata = rho_gs.divRhoZ; break;
674  case 4 : ffttempdata = rho_gs.divRhoX; break; //its whitebyrd
675  default: CkAbort("impossible iopt"); break;
676  }//end switch
677 
678 //////////////////////////////////////////////////////////////////////////////
679 /// Do a Comlib Dance
680 
681 #ifdef USE_COMLIB
682  if(rhoRsubplanes==1){
683  switch(iopt){
684 #ifdef OLD_COMMLIB
685  case 1 : if(config.useGIns1RhoRP) commGInstance1.beginIteration(); break;
686  case 2 : if(config.useGIns2RhoRP) commGInstance2.beginIteration(); break;
687  case 3 : if(config.useGIns3RhoRP) commGInstance3.beginIteration(); break;
688  case 4 : if(config.useGByrdInsRhoRBP) commGByrdInstance.beginIteration();break;
689 #else
690  case 1 :if(config.useGIns1RhoRP) ComlibBegin(rhoRealProxy1_com,0); break;
691  case 2 :if(config.useGIns2RhoRP) ComlibBegin(rhoRealProxy2_com,0); break;
692  case 3 :if(config.useGIns3RhoRP) ComlibBegin(rhoRealProxy3_com,0); break;
693  case 4 :if(config.useGByrdInsRhoRBP) ComlibBegin(rhoRealProxyByrd_com,0); break;
694 #endif
695  default: CkAbort("impossible iopt"); break;
696  }//end switc
697  }//endif
698 #endif
699 
700 
701 //////////////////////////////////////////////////////////////////////////////
702 /// Send the message
703 
704  for(int z=0;z<sizeZ;z++) {
705  for(int s=0;s<rhoRsubplanes;s++){
706 
707  if(rhoRsubplanes>1){numLines = nline_send[ix][s];}
708  if(numLines>0){
709  RhoRSFFTMsg *msg = new (numLines,8*sizeof(int)) RhoRSFFTMsg;
710  msg->size = numLines; // number of z-lines in this batch
711  msg->senderIndex = thisIndex.x; // line batch index
712  msg->iopt = iopt; // iopt
713 
714  if(config.prioFFTMsg){
715  CkSetQueueing(msg, CK_QUEUEING_IFIFO);
716  *(int*)CkPriorityPtr(msg) = config.rhorpriority + thisIndex.x+ thisIndex.y;
717  }//endif
718 
719  // beam out all points with same z to chare array index z
720  complex *data = msg->data;
721  if(rhoRsubplanes==1){
722  for (int i=0,j=z; i<numLines; i++,j+=sizeZ){data[i] = ffttempdata[j];}
723  }else{
724  for(int i=0; i< numLines; i++){
725  data[i] = ffttempdata[(z+index_pack[ix][s][i])];
726  }//endif
727  }//endif
728 
729  if(rhoRsubplanes==1){
730  switch(iopt){
731  case 1 : rhoRealProxy1_com(z,0).acceptGradRhoVks(msg); break;
732  case 2 : rhoRealProxy2_com(z,0).acceptGradRhoVks(msg); break;
733  case 3 : rhoRealProxy3_com(z,0).acceptGradRhoVks(msg); break;
734  case 4 : rhoRealProxyByrd_com(z,0).acceptWhiteByrd(msg); break;
735  default: CkAbort("impossible iopt"); break;
736  }//end switch
737  }else{
738  switch(iopt){
739  case 1 : UrhoRealProxy[thisInstance.proxyOffset](z,s).acceptGradRhoVks(msg); break;
740  case 2 : UrhoRealProxy[thisInstance.proxyOffset](z,s).acceptGradRhoVks(msg); break;
741  case 3 : UrhoRealProxy[thisInstance.proxyOffset](z,s).acceptGradRhoVks(msg); break;
742  case 4 : UrhoRealProxy[thisInstance.proxyOffset](z,s).acceptWhiteByrd(msg); break;
743  default: CkAbort("impossible iopt"); break;
744  }//end switch
745  }//endif
746  }// endif
747  }//endfor
748  }//endfor
749 
750 //////////////////////////////////////////////////////////////////////////////
751 /// Complete the commlib dance
752 
753 #ifdef USE_COMLIB
754  if(rhoRsubplanes==1){
755  switch(iopt){
756 #ifdef OLD_COMMLIB
757  case 1 : if(config.useGIns1RhoRP) commGInstance1.endIteration();break;
758  case 2 : if(config.useGIns2RhoRP) commGInstance2.endIteration();break;
759  case 3 : if(config.useGIns3RhoRP) commGInstance3.endIteration();break;
760  case 4 : if(config.useGByrdInsRhoRBP) commGByrdInstance.endIteration();break;
761 #else
762  case 1 :if(config.useGIns1RhoRP) ComlibEnd(rhoRealProxy1_com,0); break;
763  case 2 :if(config.useGIns2RhoRP) ComlibEnd(rhoRealProxy2_com,0); break;
764  case 3 :if(config.useGIns3RhoRP) ComlibEnd(rhoRealProxy3_com,0); break;
765  case 4 :if(config.useGByrdInsRhoRBP) ComlibEnd(rhoRealProxyByrd_com,0); break;
766 #endif
767  default: CkAbort("impossible iopt"); break;
768  }//end switc
769  }//endif
770 
771 #endif
772 
773 //---------------------------------------------------------------------------
774  }//end routine
775 //////////////////////////////////////////////////////////////////////////////
776 
777 
778 //////////////////////////////////////////////////////////////////////////////
779 //////////////////////////////////////////////////////////////////////////////
780 //////////////////////////////////////////////////////////////////////////////
782 //////////////////////////////////////////////////////////////////////////////
783 
784 #ifdef _CP_DEBUG_RHOG_VERBOSE_
785  CkPrintf("Communicating data from RhoG to RhoR : %d %d\n",
786  thisIndex.x,thisIndex.y);
787 #endif
788 
789 //////////////////////////////////////////////////////////////////////////////
790 /// Local Pointers and Variables
791 
792  CPcharmParaInfo *sim = CPcharmParaInfo::get();
793  int sizeZ = rho_gs.sizeZ;
794  int ix = thisIndex.x;
795  int numLines = rho_gs.numLines;
796  int ***index_pack;
797  int **nline_send;
798  if(rhoRsubplanes>1){
799  nline_send = sim->nline_send_rho_y;
800  index_pack = sim->index_tran_pack_rho_y;
801  }//endif
802 
803  complex *ffttempdataX = rho_gs.divRhoX;
804  complex *ffttempdataY = rho_gs.divRhoY;
805  complex *ffttempdataZ = rho_gs.divRhoZ;
806 
807 //////////////////////////////////////////////////////////////////////////////
808 /// Send the message : no comlib
809 
810  for(int z=0;z<sizeZ;z++) {
811  for(int s=0;s<rhoRsubplanes;s++){
812 
813  if(rhoRsubplanes>1){numLines = nline_send[ix][s];}
814  if(numLines>0){
815  RhoRSFFTMsg *msg = new (3*numLines,8*sizeof(int)) RhoRSFFTMsg;
816  msg->size = numLines; // number of z-lines in this batch
817  msg->senderIndex = thisIndex.x; // line batch index
818  msg->iopt = 1; // iopt
819 
820  if(config.prioFFTMsg){
821  CkSetQueueing(msg, CK_QUEUEING_IFIFO);
822  *(int*)CkPriorityPtr(msg) = config.rhorpriority + thisIndex.x+ thisIndex.y;
823  }//endif
824 
825  // beam out all points with same z to chare array index z
826  complex *data = msg->data;
827  if(rhoRsubplanes==1){
828  for (int i=0,j=z; i<3*numLines; i+=3,j+=sizeZ){
829  data[i] = ffttempdataX[j];
830  data[i+1] = ffttempdataY[j];
831  data[i+2] = ffttempdataZ[j];
832  }//endfor
833  }else{
834  for(int i=0,ii=0; ii< numLines; i+=3,ii++){
835  int j = (z+index_pack[ix][s][ii]);
836  data[i] = ffttempdataX[j];
837  data[i+1] = ffttempdataY[j];
838  data[i+2] = ffttempdataZ[j];
839  }//endfor
840  }//endif
841  UrhoRealProxy[thisInstance.proxyOffset](z,s).acceptGradRhoVksAll(msg);
842  }//endif : the subplane recvs a message from us
843  }//endfor : subplanes
844  }//endfor : planes
845 
846 //---------------------------------------------------------------------------
847  }//end routine
848 //////////////////////////////////////////////////////////////////////////////
849 
850 
851 
852 //////////////////////////////////////////////////////////////////////////////
853 /// RhoReal sends rho(gx,gy,z) here such that it is now decomposed
854 /// with lines of constant gx,gy in funny order to load balance.
855 ///
856 /// We cannot receive whitebyrds until every divRho sent above has been received
857 /// and processed by RhoReal. Therefore, our divRho memory is safe and warm
858 /// while it it processing in the routines before the send. It is also safe
859 /// during the send
860 ///
861 //////////////////////////////////////////////////////////////////////////////
862 //////////////////////////////////////////////////////////////////////////////
863 //////////////////////////////////////////////////////////////////////////////
865 //////////////////////////////////////////////////////////////////////////////
866 
867 #ifdef _CP_DEBUG_RHOG_VERBOSE_
868  CkPrintf("RGS [%d %d] receives white-byrd message size %d offset %d numlines %d\n",
869  thisIndex.x,thisIndex.y,msg->size,msg->offset,rho_gs.numLines);
870 #endif
871 
872 //////////////////////////////////////////////////////////////////////////////
873 
874  int iopt = msg->iopt;
875  int size = msg->size;
876  int offset = msg->offset; // z index
877  int isub = msg->offsetGx; // subplane index
878  complex *partlyIFFTd = msg->data;
879 
880  CPcharmParaInfo *sim = CPcharmParaInfo::get();
881  int ix = thisIndex.x; // chare array index
882  int sizeZ = rho_gs.sizeZ;
883  int numLines = rho_gs.numLines;
884  int ***index_pack;
885  if(rhoRsubplanes>1){
886  int **nline_send = sim->nline_send_rho_y;
887  index_pack = sim->index_tran_pack_rho_y;
888  numLines = nline_send[ix][isub];
889  }//endif
890 
891 //////////////////////////////////////////////////////////////////////////////
892 /// Error checking
893 
894 #ifdef _NAN_CHECK_
895  for(int i=0;i<msg->size ;i++){
896  CkAssert(isnan(msg->data[i].re)==0);
897  CkAssert(isnan(msg->data[i].im)==0);
898  }
899 #endif
900  if(size!=numLines){
901  CkPrintf("@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
902  CkPrintf("size %d != numLines %d\n",size,numLines);
903  CkPrintf("RGS [%d %d] receives message size %d offset %d numlines %d opt %d\n",
904  thisIndex.x,thisIndex.y,size,offset,numLines,iopt);
905  CkPrintf("@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
906  CkExit();
907  }//endif
908 
909 //////////////////////////////////////////////////////////////////////////////
910 /// unpack the message
911 
912  complex *chunk;
913  switch(iopt){
914  case 1 : chunk = rho_gs.divRhoX; break;
915  case 2 : chunk = rho_gs.divRhoY; break;
916  case 3 : chunk = rho_gs.divRhoZ; break;
917  default: CkAbort("impossible iopt"); break;
918  }//end switch
919 
920  if(rhoRsubplanes==1){
921  for(int i=0,j=offset; i< size; i++,j+=sizeZ){chunk[j] = partlyIFFTd[i];}
922  }else{
923  for(int i=0; i< size; i++){
924  chunk[(offset+index_pack[ix][isub][i])] = partlyIFFTd[i];
925  }//endif
926  }//endif
927 
928  delete msg;
929 
930 //////////////////////////////////////////////////////////////////////////////
931 /// If all chares for a gradient report, perform final FFT.
932 
933  countWhiteByrd[iopt]++;
934  if(countWhiteByrd[iopt]==recvCountFromRRho){
935  countWhiteByrd[iopt]=0;
936  doneWhiteByrd++;
937 
938 #if CMK_TRACE_ENABLED
939  double StartTime=CmiWallTimer();
940 #endif
941  FFTcache *fftcache = UfftCacheProxy[thisInstance.proxyOffset].ckLocalBranch();
942  fftcache->doRhoFFTRtoG_Gchare(chunk,chunk,rho_gs.numFull,rho_gs.numPoints,
943  rho_gs.numLines,rho_gs.numRuns,rho_gs.runs,
944  rho_gs.sizeZ,0,iplane_ind);
945 #if CMK_TRACE_ENABLED
946  traceUserBracketEvent(BwFFTRtoG_, StartTime, CmiWallTimer());
947 #endif
948 
949  }//endif
950 
951 //////////////////////////////////////////////////////////////////////////////
952 /// When all 3 gradients are in g-space, then you will ready for the next step.
953 
954  if(doneWhiteByrd==3){
955  doneWhiteByrd=0;
956  acceptWhiteByrd();
957  }//endif
958 
959 //////////////////////////////////////////////////////////////////////////////
960  }//end routine
961 //////////////////////////////////////////////////////////////////////////////
962 
963 
964 
965 //////////////////////////////////////////////////////////////////////////////
966 /// RhoReal sends rho(gx,gy,z) here such that it is now decomposed
967 /// with lines of constant gx,gy in funny order to load balance.
968 ///
969 /// We cannot receive whitebyrds until every divRho sent above has been received
970 /// and processed by RhoReal. Therefore, our divRho memory is safe and warm
971 /// while it it processing in the routines before the send. It is also safe
972 /// during the send
973 ///
974 //////////////////////////////////////////////////////////////////////////////
975 //////////////////////////////////////////////////////////////////////////////
976 //////////////////////////////////////////////////////////////////////////////
978 //////////////////////////////////////////////////////////////////////////////
979 
980 #ifdef _CP_DEBUG_RHOG_VERBOSE_
981  CkPrintf("RGS [%d %d] receives white-byrd message size %d offset %d numlines %d\n",
982  thisIndex.x,thisIndex.y,msg->size,msg->offset,rho_gs.numLines);
983 #endif
984 
985 //////////////////////////////////////////////////////////////////////////////
986 
987  int iopt = msg->iopt;
988  int size = msg->size;
989  int offset = msg->offset; // z index
990  int isub = msg->offsetGx; // subplane index
991  complex *partlyIFFTd = msg->data;
992 
993  CPcharmParaInfo *sim = CPcharmParaInfo::get();
994  int ix = thisIndex.x; // chare array index
995  int sizeZ = rho_gs.sizeZ;
996  int numLines = rho_gs.numLines;
997 
998  int ***index_pack;
999  if(rhoRsubplanes>1){
1000  int **nline_send = sim->nline_send_rho_y;
1001  index_pack = sim->index_tran_pack_rho_y;
1002  numLines = nline_send[ix][isub];
1003  }//endif
1004 
1005 //////////////////////////////////////////////////////////////////////////////
1006 /// Error checking
1007 
1008 #ifdef _NAN_CHECK_
1009  for(int i=0;i<3*(msg->size) ;i++){
1010  CkAssert(isnan(msg->data[i].re)==0);
1011  CkAssert(isnan(msg->data[i].im)==0);
1012  }
1013 #endif
1014 
1015  if(size!=numLines){
1016  CkPrintf("@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
1017  CkPrintf("size %d != numLines %d\n",size,numLines);
1018  CkPrintf("RGS [%d %d] receives message size %d offset %d numlines %d opt %d\n",
1019  thisIndex.x,thisIndex.y,size,offset,numLines,iopt);
1020  CkPrintf("@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
1021  CkExit();
1022  }//endif
1023 
1024 //////////////////////////////////////////////////////////////////////////////
1025 /// unpack the message
1026 
1027  complex *chunkX = rho_gs.divRhoX;
1028  complex *chunkY = rho_gs.divRhoY;
1029  complex *chunkZ = rho_gs.divRhoZ;
1030 
1031  if(rhoRsubplanes==1){
1032  for(int i=0,j=offset; i< 3*size; i+=3,j+=sizeZ){
1033  chunkX[j] = partlyIFFTd[i];
1034  chunkY[j] = partlyIFFTd[i+1];
1035  chunkZ[j] = partlyIFFTd[i+2];
1036  }//endfor
1037  }else{
1038  for(int i=0,ii=0; ii< size; i+=3,ii++){
1039  int j=offset+index_pack[ix][isub][ii];
1040  chunkX[j] = partlyIFFTd[i];
1041  chunkY[j] = partlyIFFTd[i+1];
1042  chunkZ[j] = partlyIFFTd[i+2];
1043  }//endfor
1044  }//endif
1045 
1046  delete msg;
1047 
1048 //////////////////////////////////////////////////////////////////////////////
1049 /// If all chares for a gradient report, perform final FFT.
1050 
1051  countWhiteByrd[1]++;
1052  if(countWhiteByrd[1]==recvCountFromRRho){
1053  countWhiteByrd[1]=0;
1054  doneWhiteByrd+=3;
1055 
1056 #if CMK_TRACE_ENABLED
1057  double StartTime=CmiWallTimer();
1058 #endif
1059  FFTcache *fftcache = UfftCacheProxy[thisInstance.proxyOffset].ckLocalBranch();
1060  fftcache->doRhoFFTRtoG_Gchare(chunkX,chunkX,rho_gs.numFull,rho_gs.numPoints,
1061  rho_gs.numLines,rho_gs.numRuns,rho_gs.runs,
1062  rho_gs.sizeZ,0,iplane_ind);
1063  fftcache->doRhoFFTRtoG_Gchare(chunkY,chunkY,rho_gs.numFull,rho_gs.numPoints,
1064  rho_gs.numLines,rho_gs.numRuns,rho_gs.runs,
1065  rho_gs.sizeZ,0,iplane_ind);
1066  fftcache->doRhoFFTRtoG_Gchare(chunkZ,chunkZ,rho_gs.numFull,rho_gs.numPoints,
1067  rho_gs.numLines,rho_gs.numRuns,rho_gs.runs,
1068  rho_gs.sizeZ,0,iplane_ind);
1069 #if CMK_TRACE_ENABLED
1070  traceUserBracketEvent(BwFFTRtoG_, StartTime, CmiWallTimer());
1071 #endif
1072  }//endif
1073 
1074 //////////////////////////////////////////////////////////////////////////////
1075 /// When all 3 gradients are in g-space, then you will ready for the next step.
1076 
1077  if(doneWhiteByrd==3){
1078  doneWhiteByrd=0;
1079  acceptWhiteByrd();
1080  }//endif
1081 
1082 //////////////////////////////////////////////////////////////////////////////
1083  }//end routine
1084 //////////////////////////////////////////////////////////////////////////////
1085 
1086 
1087 
1088 //////////////////////////////////////////////////////////////////////////////
1089 //////////////////////////////////////////////////////////////////////////////
1090 //////////////////////////////////////////////////////////////////////////////
1092 //////////////////////////////////////////////////////////////////////////////
1093 /// Set the timer and some options
1094 
1095 #if CMK_TRACE_ENABLED
1096  double StartTime=CmiWallTimer();
1097 #endif
1098 
1099  int ioptSendWhite = 4;
1100 
1101 //////////////////////////////////////////////////////////////////////////////
1102 /// Compute my whiteByrd : store it in divrhox
1103 
1104  double tpi,*hmati;
1105  CPXCFNCTS::CP_fetch_hmati(&hmati,&tpi);
1106  rho_gs.createWhiteByrd(hmati,tpi);
1107 
1108 //////////////////////////////////////////////////////////////////////////////
1109 /// FFT my whitebyrd : which is stored in divRhox
1110 
1111  FFTcache *fftcache = UfftCacheProxy[thisInstance.proxyOffset].ckLocalBranch();
1112  complex *white = rho_gs.divRhoX;
1113  fftcache->doRhoFFTGtoR_Gchare(white,white,rho_gs.numFull,rho_gs.numPoints,
1114  rho_gs.numLines,rho_gs.numRuns,rho_gs.runs,
1115  rho_gs.sizeZ,0,iplane_ind);
1116 
1117 //////////////////////////////////////////////////////////////////////////////
1118 /// End tracing and send whitebyrd back to Rhoreal space
1119 
1120 #if CMK_TRACE_ENABLED
1121  traceUserBracketEvent(ByrdanddoFwFFTGtoR_, StartTime, CmiWallTimer());
1122 #endif
1123 
1124  RhoGSendRhoR(ioptSendWhite);
1125  myTime++;
1126 //---------------------------------------------------------------------------
1127  }//end routine
1128 //////////////////////////////////////////////////////////////////////////////
1129 
1130 
1131 //////////////////////////////////////////////////////////////////////////////
1132 //////////////////////////////////////////////////////////////////////////////
1133 //////////////////////////////////////////////////////////////////////////////
1134 void CP_Rho_GSpacePlane::ResumeFromSync(){
1135 
1136 #ifdef USE_COMLIB
1137 /*
1138  if (config.useGIns0RhoRP)
1139  ComlibResetProxy(rhoRealProxy0_com);
1140  if (config.useGIns1RhoRP)
1141  ComlibResetProxy(rhoRealProxy1_com);
1142  if (config.useGIns2RhoRP)
1143  ComlibResetProxy(rhoRealProxy2_com);
1144  if (config.useGIns3RhoRP)
1145  ComlibResetProxy(rhoRealProxy3_com);
1146  if (config.useGByrdInsRhoRBP)
1147  ComlibResetProxy(rhoRealProxyByrd_com);
1148 */
1149 #endif
1150 
1151 }
1152 //////////////////////////////////////////////////////////////////////////////
1153 
1154 
1155 
1156 //////////////////////////////////////////////////////////////////////////////
1157 ///////////////////////////////////////////////////////////////////////////cc
1158 //////////////////////////////////////////////////////////////////////////////
1159 /// Glenn's RhoReal exit
1160 //////////////////////////////////////////////////////////////////////////////
1162  countDebug++;
1163  CPcharmParaInfo *sim = CPcharmParaInfo::get();
1164  int nchareG = sim->nchareRhoG;
1165  if(countDebug==nchareG){
1166  countDebug=0;
1167  CkPrintf("I am in the exitfordebuging rhoG puppy. Bye-bye\n");
1168  CkExit();
1169  }//endif
1170 }//end routine
1171 //////////////////////////////////////////////////////////////////////////////
1172 /*@}*/
holds the UberIndex and the offset for proxies
Definition: Uber.h:68
void divRhoVksGspace()
invoke fft subroutine : doFwFFT() unpack do an FFT 1D along z rho(gx,gy,gz) parallelized in full z-li...
void setKVectors(int *n)
Definition: rhoSlab.C:371
Add type declarations for simulationConstants class (readonly vars) and once class for each type of o...
void createWhiteByrd(double *, double)
= packed g-space of size numPoints is expanded to numFull =numRuns/2*nfftz
Definition: rhoSlab.C:315
void acceptWhiteByrdAll(RhoGSFFTMsg *msg)
RhoReal sends rho(gx,gy,z) here such that it is now decomposed with lines of constant gx...
== Index logic for lines of constant x,y in gspace.
Definition: RunDescriptor.h:22
Some basic data structures and the array map classes are defined here.
void divRhoGdot(double *, double, complex *)
= packed g-space of size numPoints is expanded to numFull =numRuns/2*nfftz
Definition: rhoSlab.C:258
void getSplitDecomp(int *, int *, int *, int, int, int)
Initialization Function /////////////////////////////////////////////////////////////////////////// /...
Definition: util.C:2250
void launchNlG()
The density is here : Launch ees NL.
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 /////////////////////////////////////...
Definition: fftCache.C:1401
void doRhoFFTGtoR_Gchare(complex *, complex *, int, int, int, int, RunDescriptor *, int, int, int)
rho Gchare : data(gx,gy,gz) -> data(gx,gy,z) : forward //////////////////////////////////////////////...
Definition: fftCache.C:1365
void acceptRhoData(RhoGSFFTMsg *msg)
RhoReal sends rho(gx,gy,z) here such that it is now decomposed with lines of constant gx...
Useful debugging flags.
void doRhoFFT()
Complete the FFT to give use Rho(gx,gy,gz) //////////////////////////////////////////////////////////...
void init()
post constructor initialization /////////////////////////////////////////////////////////////////////...
void exitForDebugging()
Glenn's RhoReal exit.