OpenAtom  Version1.5a
InstanceController.C
1 #include "charm++.h"
2 #include "utility/util.h"
3 #include "cpaimd.h"
4 #include "AtomsCache.h"
5 #include "AtomsCompute.h"
6 #include "InstanceController.h"
7 extern int nstates;
8 
9 //////////////////////////////////////////////////////////////////////////////
10 //////////////////////////////////////////////////////////////////////////////
11 //////////////////////////////////////////////////////////////////////////////
12 /* ostensibly the InstanceController may need to know about everything */
13 extern CkVec < CkVec <int> > UplaneUsedByNLZ;
14 extern CkVec <CProxy_CP_State_GSpacePlane> UgSpacePlaneProxy;
15 extern CkVec <CProxy_GSpaceDriver> UgSpaceDriverProxy;
16 extern CkVec <CProxy_CP_State_ParticlePlane> UparticlePlaneProxy;
17 extern CkVec <CProxy_CP_State_RealParticlePlane> UrealParticlePlaneProxy;
18 extern CkVec <CProxy_CP_State_RealSpacePlane> UrealSpacePlaneProxy;
19 extern CkVec <CProxy_CP_Rho_RealSpacePlane> UrhoRealProxy;
20 extern CkVec <CProxy_CP_Rho_GSpacePlane> UrhoGProxy;
21 extern CkVec <CProxy_CP_Rho_RHartExt> UrhoRHartExtProxy;
22 extern CkVec <CProxy_CP_Rho_GHartExt> UrhoGHartExtProxy;
23 extern CkVec <CProxy_AtomsCache> UatomsCacheProxy;
24 extern CkVec <CProxy_AtomsCompute> UatomsComputeProxy;
25 extern CkVec <CProxy_EnergyGroup> UegroupProxy;
26 extern CkVec <CProxy_FFTcache> UfftCacheProxy;
27 extern CkVec <CProxy_StructFactCache> UsfCacheProxy;
28 extern CkVec <CProxy_StructureFactor> UsfCompProxy;
29 extern CkVec <CProxy_eesCache> UeesCacheProxy;
30 extern CkVec <CProxy_OrthoHelper> UorthoHelperProxy;
31 extern CProxy_TimeKeeper TimeKeeperProxy;
32 extern CkGroupID mCastGrpId;
33 extern CkVec <UberCollection> UberAlles;
34 extern CProxy_ENL_EKE_Collector ENLEKECollectorProxy;
35 //////////////////////////////////////////////////////////////////////////////
36 
37 
38 
39 InstanceController::InstanceController() {
40 
41  done_init=0;Timer=CmiWallTimer(); numKpointforces=0;
42  UberCollection instance=UberCollection(thisIndex);
43  // 0th k, 0th spin makes this to lockdown everyone so the atoms
44  // shared across all k and spin can start sanely
45  if((config.UberMmax >1 || config.UberJmax>1) && instance.idxU.y==0 && instance.idxU.s==0)
46  {
47  // make section for k-points and spins
48  CkVec <CkArrayIndex1D> elems;
49  for(int kp =0; kp<config.UberJmax; kp++)
50  {
51  instance.idxU.y=kp;
52  for(int spin =0; spin<config.UberMmax; spin++)
53  {
54  instance.idxU.s=spin;
55  instance.setPO();
56  elems.push_back(CkArrayIndex1D(instance.proxyOffset));
57  }
58  }
59 
60  CProxySection_InstanceController sectProxy=CProxySection_InstanceController::ckNew(thisProxy.ckGetArrayID(),elems.getVec(),elems.size());
61  CkMulticastMgr *mcastGrp = CProxy_CkMulticastMgr(mCastGrpId).ckLocalBranch();
62  sectProxy.ckSectionDelegate(mcastGrp);
63  ICCookieMsg *cookieme=new ICCookieMsg;
64  sectProxy.initCookie(cookieme);
65  }
66 }
67 
68 //////////////////////////////////////////////////////////////////////////////
69 //////////////////////////////////////////////////////////////////////////////
70 //////////////////////////////////////////////////////////////////////////////
71 void InstanceController::init(){
72  UberCollection instance=UberCollection(thisIndex);
73  // 0th bead, 0th temper makes this to sync beads and tempers
74  if((config.UberImax >1 || config.UberKmax>1) && instance.idxU.x==0 && instance.idxU.z==0)
75  {
76  // make section for beads and tempers
77  int numDestinations=config.UberImax*config.UberKmax;
78  CkArrayID *beadArrayIds= new CkArrayID[numDestinations];
79  CkArrayIndex **elems = new CkArrayIndex*[numDestinations];
80  int *naelems = new int[numDestinations];
81  for(int bead =0; bead<config.UberImax; bead++)
82  {
83  instance.idxU.x=bead;
84  for(int temper =0; temper<config.UberKmax; temper++)
85  {
86  int index=bead*config.UberKmax+temper;
87  elems[index]= new CkArrayIndex2D[1];
88  naelems[index]=1;
89  instance.idxU.z=temper;
90  instance.setPO();
91  CkPrintf("fmag sync section adding bead %d temper %d index %d proxyOffset %d\n",bead, temper, index, instance.proxyOffset);
92  beadArrayIds[index]=UgSpacePlaneProxy[instance.proxyOffset].ckGetArrayID();
93  elems[index][0]=CkArrayIndex2D(0,0);
94  }
95  }
96  //finish setting this up
97  gTemperBeadProxy=CProxySection_CP_State_GSpacePlane(numDestinations, beadArrayIds, elems, naelems);
98  CkMulticastMgr *mcastGrp = CProxy_CkMulticastMgr(mCastGrpId).ckLocalBranch();
99  gTemperBeadProxy.ckSectionDelegate(mcastGrp);
100  ICCookieMsg *cookieme=new ICCookieMsg;
101  CkCallback *cb = new CkCallback(CkIndex_InstanceController::fmagMinTest(NULL),CkArrayIndex1D(0),thisProxy);
102  mcastGrp->setReductionClient(gTemperBeadProxy,cb);
103  gTemperBeadProxy.initBeadCookie(cookieme);
104 
105  }
106 }
107 //////////////////////////////////////////////////////////////////////////////
108 
109 //////////////////////////////////////////////////////////////////////////////
110 //////////////////////////////////////////////////////////////////////////////
111 //////////////////////////////////////////////////////////////////////////////
112 void InstanceController::fmagMinTest(CkReductionMsg *m){
113 
114 
115  int result=( (int *) (m->getData()) )[0];
116  // CkPrintf("[%d] fmagMinTest %d\n",thisIndex, result);
117  ICCookieMsg *out=new ICCookieMsg;
118  out->junk = result;
119  delete m;
120  gTemperBeadProxy.minimizeSync(out);
121 
122 }
123 //////////////////////////////////////////////////////////////////////////////
124 
125 //////////////////////////////////////////////////////////////////////////////
126 //////////////////////////////////////////////////////////////////////////////
127 //////////////////////////////////////////////////////////////////////////////
128 /** \addtogroup startup
129  # Parallel Startup Phases:
130 
131 1. Phase 0 is kicked off by reaching the end of main. This turns
132  execution completely over to the Charm++ scheduler, at which point it
133  will process the object constructor messages that we triggered in the
134  proxy creation in main. Object construction will occur
135  in this order + all readonlies will be initialized. + all groups
136  will be constructed + all arrays will be constructed
137 
138  The ordering within those phases is non-deterministic, so we don't
139  expect to have control over the ordering of chare array
140  construction. The upshot of this is that in order to safely make
141  array sections we wait until the objects are constructed and then
142  call a second phase of initialization. In practice this means
143  that arrays will contribute to reductions during construction and
144  the completion of those reductions will trigger a chain of section
145  creation which will eventually feed back into a reduction that
146  reports to the global startup phase ordering in
147  InstanceController.
148 2. Phase 2 and 3 are automatically triggered during the construction
149  process. These phases are ortho constructing proxies to sections
150  of the paircalculators. In each case they construct a section and
151  send a message on that section to its elements to initialize a
152  cookie. Receipt of that cookie increments a counter and when each
153  PC element has received all the cookies it expects, it contributes
154  to a reduction which reports to InstanceController::doneInit().
155  There is a phase for symmetric and asymmetric calculator, they
156  could complete in either order.
157 3. Phase 4 triggers the post construction initialization of section
158  proxies and cache registrations in RhoReal RhoG RhoGHartExt. The
159  big ticket item here is the sections of RealSpace made by RhoReal.
160  These operate in the previously described fashion wherein you make
161  a section, initialize the cookies with a dummy message and report
162  on completion via a reduction along the section. When realspace
163  has received as many cookies as there are rhoreal subplanes, it
164  contributes to a reduction reporting to
165  InstanceController::doneInit.
166 4. Phase 5 is triggered by the completion of the RS sections. When
167  EES is enabled, phase 5 will launch the section construction and
168  registration process in RealParticlePlane. The coalesced
169  completion of eesCache, enlSection, and planeRedSection
170  initialization contributes to a single reduction reporting to
171  InstanceController::doneInit. This phase always triggers the
172  loading and multicasting of the gspace state data from the
173  statefiles. When all elements of gspace are initialized with that
174  data they contribute to a reduction which reports to
175  InstanceController::doneInit.
176 5. Phase 6 happens only if EES is enabled, it broadcasts
177  registrationDone to all RealParticlePlane elements.
178 6. Phase 7 (or 6 if no realparticleplane) means that all
179  initialization is complete and startup is effectively over.
180  Control is then turned over to the gSpaceDriver::startControl.
181  Some chares will do a little local first iteration initialization
182  after this. Semantically it should now be safe to engage in any
183  operation as the previous phases should have taken care of any
184  synchronized initialization issues. */
185 /**@{*/
186 void InstanceController::doneInit(CkReductionMsg *msg){
187  CPcharmParaInfo *sim = CPcharmParaInfo::get();
188  CkPrintf("{%d} Done_init for %d userflag %d\n",thisIndex, (int)((int *)msg->getData())[0],msg->getUserFlag());
189  // This assert should be a formality.
190  // Also, when paircalc becomes completely instance unaware, it will fail. This single assert is not enough motivation
191  // to provide instance info to the pc/ortho bubble. @todo: remove this assert
192  CkAssert(msg->getUserFlag()==thisIndex);
193  int numPhases=5;
194  if(CPcharmParaInfo::get()->ees_nloc_on==1)
195  numPhases++;
196  delete msg;
197  double newtime=CmiWallTimer();
198  CkAssert(done_init<numPhases+1);
199 
200  if(done_init<numPhases){
201  CkPrintf("{%d} Completed chare instantiation phase %d in %g\n",thisIndex,done_init+1,newtime-Timer);
202  }
203  if (done_init==3)
204  { // kick off post constructor inits
205  if(thisIndex==0) init();
206  UberCollection thisInstance(thisIndex);
207  if(thisInstance.idxU.y==0)
208  {
209  UrhoRealProxy[thisIndex].init();
210  UrhoGProxy[thisIndex].init();
211  UrhoGHartExtProxy[thisIndex].init();
212  if(sim->ees_eext_on)
213  {UrhoRHartExtProxy[thisIndex].init();}
214  }
215  }
216  if (done_init == 4){
217  // We do this after we know gsp, pp, rp, rpp exist
218  if(CPcharmParaInfo::get()->ees_nloc_on==1)
219  {UrealParticlePlaneProxy[thisIndex].init();}
220  // kick off file reading in gspace
221  CkPrintf("{%d} Initiating import of states\n",thisIndex);
222  CkPrintf("{%d} IC uGSpacePlaneProxy[%d] is %d\n",thisIndex,thisIndex, CkGroupID(UgSpacePlaneProxy[thisIndex].ckGetArrayID()).idx);
223  for(int s=0;s<nstates;s++) {
224  UgSpacePlaneProxy[thisIndex](s,UplaneUsedByNLZ[thisIndex][s]).readFile();
225  } //endfor
226 
227  }//endif
228  if (done_init == 5 && CPcharmParaInfo::get()->ees_nloc_on==1){
229  CkPrintf("{%d} Completed chare data acquisition phase %d in %g\n",thisIndex, done_init+1,newtime-Timer);
230  UrealParticlePlaneProxy[thisIndex].registrationDone();
231  }
232 
233  if (done_init >= numPhases) {
234  if (done_init == numPhases){
235  // PRINT_LINE_STAR;
236  CkPrintf("{%d} Chare array launch and initialization complete \n",thisIndex);
237  if(CPcharmParaInfo::get()->cp_min_opt==1){
238  CkPrintf("{%d} Running Open Atom CP Minimization: \n",thisIndex);
239  }else{
240  CkPrintf("{%d} Running Open Atom CP Dynamics: \n",thisIndex);
241  }//endif
242  // PRINT_LINE_STAR; CkPrintf("\n");
243  // PRINT_LINE_STAR;
244  UgSpaceDriverProxy[thisIndex].startControl();
245  }//endif
246  }
247  Timer=newtime;
248  ++done_init;
249 }
250 //////////////////////////////////////////////////////////////////////////////
251 /**@}*/
252 
253 //////////////////////////////////////////////////////////////////////////////
254 //////////////////////////////////////////////////////////////////////////////
255 //////////////////////////////////////////////////////////////////////////////
256 void InstanceController::initCookie(ICCookieMsg *msg){
257  CkGetSectionInfo(allKPcookie, msg);
258  // delete msg; nokeep
259 }
260 //////////////////////////////////////////////////////////////////////////////
261 
262 
263 //////////////////////////////////////////////////////////////////////////////
264 //////////////////////////////////////////////////////////////////////////////
265 //////////////////////////////////////////////////////////////////////////////
266 void InstanceController::printEnergyHart(CkReductionMsg *msg){
267 //////////////////////////////////////////////////////////////////////////////
268  // double ehart = 0, eext = 0.0, ewd = 0.0;
269  void *data=msg->getData();
270  double ehart = ((double *)data)[0];
271  double eext = ((double *)data)[1];
272  double ewd = ((double *)data)[2];
273  FILE *temperScreenFile = UatomsCacheProxy[thisIndex].ckLocalBranch()->temperScreenFile;
274  int iteration= UatomsCacheProxy[thisIndex].ckLocalBranch()->iteration;
275  fprintf(temperScreenFile,"Iter [%d] EHART = %5.8lf\n", iteration, ehart);
276  fprintf(temperScreenFile,"Iter [%d] EExt = %5.8lf\n", iteration, eext);
277  fprintf(temperScreenFile, "Iter [%d] EWALD_recip = %5.8lf\n", iteration, ewd);
278 
279  UgSpacePlaneProxy[thisIndex](0, 0).computeEnergies(ENERGY_EHART, ehart);
280  UgSpacePlaneProxy[thisIndex](0, 0).computeEnergies(ENERGY_EEXT, eext);
281  UgSpacePlaneProxy[thisIndex](0, 0).computeEnergies(ENERGY_EWD, ewd);
282  delete msg;
283 
284 //////////////////////////////////////////////////////////////////////////////
285  }//end routine
286 //////////////////////////////////////////////////////////////////////////////
287 
288 
289 
290 //////////////////////////////////////////////////////////////////////////////
291 //////////////////////////////////////////////////////////////////////////////
292 //////////////////////////////////////////////////////////////////////////////
293 void InstanceController::printEnergyEexc(CkReductionMsg *msg){
294 //////////////////////////////////////////////////////////////////////////////
295 
296  double eexc = 0;
297  double egga = 0;
298  void *data=msg->getData();
299  eexc += ((double *)data)[0];
300  egga += ((double *)data)[1];
301  FILE *temperScreenFile = UatomsCacheProxy[thisIndex].ckLocalBranch()->temperScreenFile;
302  int iteration= UatomsCacheProxy[thisIndex].ckLocalBranch()->iteration;
303 
304  fprintf(temperScreenFile,"Iter [%d] EEXC = %5.8lf\n", iteration, eexc);
305  fprintf(temperScreenFile,"Iter [%d] EGGA = %5.8lf\n", iteration, egga);
306  fprintf(temperScreenFile,"Iter [%d] EEXC+EGGA = %5.8lf\n", iteration, eexc+egga);
307 
308  UgSpacePlaneProxy[thisIndex](0, 0).computeEnergies(ENERGY_EEXC, eexc);
309  UgSpacePlaneProxy[thisIndex](0, 0).computeEnergies(ENERGY_EGGA, egga);
310 
311 #define _GLENN_STUFF_OFF_
312 #ifdef _GLENN_STUFF_
313  CkPrintf("exiting in printEnergyEexc\n");CkExit();
314 #endif
315  delete msg;
316 
317 //////////////////////////////////////////////////////////////////////////////
318  }//end routine
319 //////////////////////////////////////////////////////////////////////////////
320 
321 //////////////////////////////////////////////////////////////////////////////
322 /// Print out Quantum KE and put all the energies into the message group
323 //////////////////////////////////////////////////////////////////////////////
324 //////////////////////////////////////////////////////////////////////////////
325 //////////////////////////////////////////////////////////////////////////////
326  void InstanceController::printEnergyEke(CkReductionMsg *m){
327 //////////////////////////////////////////////////////////////////////////////
328  double d = ((double *)m->getData())[0];
329  delete m;
330 #ifdef _CP_DEBUG_SFNL_OFF_
331  CkPrintf("EKE = OFF FOR DEBUGGING\n");
332 #endif
333  UberCollection thisInstance(thisIndex);
334  if(config.UberKmax>1) // report to temper master
335  ENLEKECollectorProxy[thisInstance.idxU.z].acceptEKE(d);
336  FILE *temperScreenFile = UatomsCacheProxy[thisIndex].ckLocalBranch()->temperScreenFile;
337  int iteration= UatomsCacheProxy[thisIndex].ckLocalBranch()->iteration;
338  fprintf(temperScreenFile,"Iter [%d] EKE = %5.8lf\n", iteration, d);
339  fflush(temperScreenFile);
340  UgSpacePlaneProxy[thisIndex](0,0).computeEnergies(ENERGY_EKE, d);
341 }
342 
343 
344 
345 //////////////////////////////////////////////////////////////////////////////
346 /// Print out Fict CP KE and send it to the energy group
347 //////////////////////////////////////////////////////////////////////////////
348 //////////////////////////////////////////////////////////////////////////////
349 //////////////////////////////////////////////////////////////////////////////
350  void InstanceController::printFictEke(CkReductionMsg *m){
351 //////////////////////////////////////////////////////////////////////////////
352  CPcharmParaInfo *sim = CPcharmParaInfo::get();
353  double d0 = ((double *)m->getData())[0];
354  double d1 = ((double *)m->getData())[1];
355  double d2 = ((double *)m->getData())[2];
356  double d3 = ((double *)m->getData())[3];
357  double d4 = ((double *)m->getData())[4];
358  delete m;
359 
360  if(CPcharmParaInfo::get()->cp_min_opt==0){
361  FILE *temperScreenFile = UatomsCacheProxy[thisIndex].ckLocalBranch()->temperScreenFile;
362  int iteration= UatomsCacheProxy[thisIndex].ckLocalBranch()->iteration;
363 
364  fprintf(temperScreenFile,"Iter [%d] Fict Temp = %.10g K\n", iteration, d0); // per g-chare temp
365  fprintf(temperScreenFile,"Iter [%d] Fict Eke = %.10g K\n", iteration, d2); // total kinetic energy
366  fprintf(temperScreenFile,"Iter [%d] Fict TempNHC= %.10g K\n", iteration, d1); // per g-chare tempNHC
367  fprintf(temperScreenFile,"Iter [%d] Fict EkeNHC = %.10g K\n", iteration, d3); // total NHC kinetic energy
368  fprintf(temperScreenFile,"Iter [%d] Fict PotNHC = %.10g K\n", iteration, d4); // total potNHC
369  fprintf(temperScreenFile,"Iter [%d] Fict EConv = %.10g K\n", iteration, d2+d3+d4);
370  }//endif
371  UgSpacePlaneProxy[thisIndex](0,0).computeEnergies(ENERGY_FICTEKE, d0);
372 
373 //////////////////////////////////////////////////////////////////////////////
374  }//end routine
375 //////////////////////////////////////////////////////////////////////////////
376 
377 
378 //////////////////////////////////////////////////////////////////////////////
379 /// When ALL the cp forces are done, you can integrate the atoms.
380 /// Could be made slicker by using knowledge of which gpsace chares
381 /// are on each processor and coordinating that with atom launch.
382 /// cklocalbranch->count_psi_forc++; zeroed in atms grp constructor
383 /// and incremented could be incremented in launch atoms.
384 /// If(cklocalbranch->count_psi_forc==numgspacethisproc){
385 /// atomsgrpproxy(myid).startrealspaceforces();
386 /// }
387 /// That is, you only need to know that all the forces are complete
388 /// on each PROCECESSOR and you can go ahead to the atoms. The atoms
389 /// are a group which needs to contribute atom forces to a reduction.
390 /// If all the forces aren't in there, you can't start the reduction
391 //////////////////////////////////////////////////////////////////////////////
392 //////////////////////////////////////////////////////////////////////////////
393 //////////////////////////////////////////////////////////////////////////////
394 void InstanceController::allDoneCPForces(CkReductionMsg *m){
395 //////////////////////////////////////////////////////////////////////////////
396  delete m;
397  // only the 0th instance of each k-point and spin is allowed to do this
398 
399  UberCollection thisInstance(thisIndex);
400  if(config.UberJmax>1 || config.UberMmax >1 )
401  {
402  // contribute to the section which includes all k-points of this
403  // bead
404  long unsigned int foo(1);
405  UberCollection instance=thisInstance;
406  instance.idxU.y=0;
407  int offset=instance.calcPO();
408 
409  CkMulticastMgr *mcastGrp = CProxy_CkMulticastMgr(mCastGrpId).ckLocalBranch();
410  CkCallback cb(CkIndex_InstanceController::allDoneCPForcesAllKPoint(NULL),CkArrayIndex1D(offset),thisProxy);
411  mcastGrp->contribute(sizeof(long unsigned int),&foo,CkReduction::sum_int, allKPcookie, cb);
412  }
413  else
414  {
415  FILE *temperScreenFile = UatomsCacheProxy[thisIndex].ckLocalBranch()->temperScreenFile;
416  int iteration= UatomsCacheProxy[thisIndex].ckLocalBranch()->iteration;
417 
418  fprintf(temperScreenFile,"Iter [%d] allDoneCPForces bead %d\n",iteration,thisInstance.idxU.x);
419  UatomsComputeProxy[thisIndex].startRealSpaceForces();
420  }
421 
422 //////////////////////////////////////////////////////////////////////////////
423 }//end routine
424 //////////////////////////////////////////////////////////////////////////////
425 
426 
427 //////////////////////////////////////////////////////////////////////////////
428 //////////////////////////////////////////////////////////////////////////////
429 //////////////////////////////////////////////////////////////////////////////
430 void InstanceController::allDoneCPForcesAllKPoint(CkReductionMsg *m){
431  UberCollection thisInstance(thisIndex);
432  FILE *temperScreenFile = UatomsCacheProxy[thisIndex].ckLocalBranch()->temperScreenFile;
433  int iteration= UatomsCacheProxy[thisIndex].ckLocalBranch()->iteration;
434 
435  fprintf(temperScreenFile,"Iter [%d] allDoneCPForces bead %d\n",iteration,thisInstance.idxU.x);
436  UatomsComputeProxy[thisIndex].startRealSpaceForces();
437 }
438 
439 //////////////////////////////////////////////////////////////////////////////
440 
441 /// When the simulation is done on each instance, make a clean exit
442 /// this gets called by each instance
443 void InstanceController::cleanExit(CkReductionMsg *m)
444 {
445  FILE *temperScreenFile = UatomsCacheProxy[thisIndex].ckLocalBranch()->temperScreenFile;
446  int iteration= UatomsCacheProxy[thisIndex].ckLocalBranch()->iteration;
447  fprintf(temperScreenFile,"Iter [%d] called cleanExit\n",iteration);
448  delete m;
449  int exited=1;
450  contribute(sizeof(int), &exited, CkReduction::sum_int,
451  CkCallback(CkIndex_InstanceController::cleanExitAll(NULL),CkArrayIndex1D(0),thisProxy), 0);
452 }
453 
454 
455 //////////////////////////////////////////////////////////////////////////////
456 //////////////////////////////////////////////////////////////////////////////
457 //////////////////////////////////////////////////////////////////////////////
458 void InstanceController::acceptNewTemperature(double temperature){
459  // you are the instance controller for [temper,0,0.0] tell the rest of your
460  // minions about this new temperature
461  // NOTE: this should be done using a section
462  // CkPrintf("[%d] acceptNewTemperature\n",thisIndex);
463  UberCollection anIndex(thisIndex);
464  for(int integral=0; integral< config.UberImax; integral++)
465  {
466  anIndex.idxU.x=integral;
467  for(int kpoint=0; kpoint< config.UberJmax; kpoint++)
468  {
469  anIndex.idxU.y=kpoint;
470  for(int spin=0; spin< config.UberMmax; spin++) {
471  anIndex.idxU.s=spin;
472  anIndex.setPO();
473  thisProxy[anIndex.proxyOffset].useNewTemperature(temperature);
474  }
475  }
476  }
477 
478 }
479 //////////////////////////////////////////////////////////////////////////////
480 
481 //////////////////////////////////////////////////////////////////////////////
482 //////////////////////////////////////////////////////////////////////////////
483 //////////////////////////////////////////////////////////////////////////////
484 void InstanceController::useNewTemperature(double temperature){
485  // broadcast the temp to your atoms and GSPs
486  // CkPrintf("[%d] useNewTemperature\n",thisIndex);
487  atomsTempDone=false;
488  gspTempDone=false;
489  UatomsComputeProxy[thisIndex].acceptNewTemperature(temperature);
490  UgSpacePlaneProxy[thisIndex].acceptNewTemperature(temperature);
491 
492 }
493 //////////////////////////////////////////////////////////////////////////////
494 
495 
496 //////////////////////////////////////////////////////////////////////////////
497 //////////////////////////////////////////////////////////////////////////////
498 //////////////////////////////////////////////////////////////////////////////
499 void InstanceController::atomsDoneNewTemp(CkReductionMsg *m)
500 {
501  atomsTempDone=true;
502  if(gspTempDone)
503  UegroupProxy[thisIndex].resumeFromTemper();
504  delete m;
505 }
506 
507 //////////////////////////////////////////////////////////////////////////////
508 //////////////////////////////////////////////////////////////////////////////
509 //////////////////////////////////////////////////////////////////////////////
510 void InstanceController::gspDoneNewTemp(CkReductionMsg *m)
511 {
512  gspTempDone=true;
513  if(atomsTempDone)
514  UegroupProxy[thisIndex].resumeFromTemper();
515  delete m;
516 }
517 
518 
519 
520 /// When the simulation is done, make a clean exit
521 /// this gets called on the 0th element when everyone calls cleanExit
522 void InstanceController::cleanExitAll(CkReductionMsg *m)
523 {
524  delete m;
525  CkPrintf("********************************************************************************\n");
526  CkPrintf("\n"); CkPrintf("\n");
527  CkPrintf("********************************************************************************\n");
528  CkPrintf(" Open Atom Simulation Complete \n");
529  CkPrintf("********************************************************************************\n");
530  CkExit();
531 }
532 
533 #include "instanceController.def.h"
534 
holds the UberIndex and the offset for proxies
Definition: Uber.h:68
Accepts reduction of forces from AtomsCache, integrates forces to produce new coordinates, distributes new coordinates to AtomsCache.
void allDoneCPForces(CkReductionMsg *m)
When ALL the cp forces are done, you can integrate the atoms.
void printEnergyEke(CkReductionMsg *m)
Print out Quantum KE and put all the energies into the message group ////////////////////////////////...
CkGroupID mCastGrpId
Multicast manager group that handles many mcast/redns in the code. Grep for info. ...
Definition: cpaimd.C:216
Some basic data structures and the array map classes are defined here.
void cleanExit(CkReductionMsg *m)
When the simulation is done on each instance, make a clean exit this gets called by each instance...
void cleanExitAll(CkReductionMsg *m)
When the simulation is done, make a clean exit this gets called on the 0th element when everyone call...
void printFictEke(CkReductionMsg *msg)
Print out Fict CP KE and send it to the energy group ////////////////////////////////////////////////...