PlasCom2  1.0
XPACC Multi-physics simluation application
RunPlasCom2.C
Go to the documentation of this file.
1 #include <iomanip>
2 
3 #include "PlasCom2.H"
4 #include "EulerRHS.H"
5 #include "RK4Advancer.H"
6 #include "PCPPCommUtil.H"
7 #include "PCPPReport.H"
8 #include "PCPPIntervalUtils.H"
9 #include "Initialization.H"
10 
11 void ReportTimings(std::vector<std::vector<double> > &inTimers,const char **timerNames,
12  unsigned int nTimes,std::ostream &outStream);
13 
14 #ifdef USE_PAPI
15 void ReportCounters(long long **inCounters,const char **timerNames,
16  std::vector<std::string> &papiCounterNames,
17  unsigned int nTimes,std::ostream &outStream);
18 #endif
19 
21 {
22 
23  // typedef plascom2::operators::sbp::base operator_t;
24  typedef DomainBaseType::OperatorType operator_t;
25  // typedef DomainBaseType::RHSType rhs_t;
26 
32 
33  // typedef euler::rhs<grid_t,state_t,operator_t> rhs_t;
34 
35  std::ostringstream messageStream;
36 
37  int myRank = globalCommunicator.Rank();
39  numThreads = 1;
40 
41  // operator_t sbpOperator;
42 
43  FunctionEntry("SimSetup");
44 
45  std::string &domainName(domainInfo.domainNames[0]);
46  bool restartStep = Restart();
47  DomainBaseType &simDomain(appDomains[0]);
48 
49  DomainBaseType::gridvector &simGrids(simDomain.Grids());
50  DomainBaseType::statevector &gridStates(simDomain.States());
51  DomainBaseType::statevector &gridParams(simDomain.Params());
52  DomainBaseType::statevector &gridTargets(simDomain.Targets());
53 
54  operator_t &sbpOperator(simDomain.Operator());
55 
56  int numLocalGrids = simDomain.NumberOfLocalGrids();
57  int spatialOrder = simDomain.SpatialOrder();
58  int interiorOrder = (spatialOrder - 1)*2;
59 
60  const std::vector<std::string> &domainGridNames(simDomain.GridNames());
61 
62  if(numLocalGrids <= 0){
63  ErrOut("Error: no local grids.\n");
64  return(1);
65  }
66  std::vector<std::vector<int> > numThreadsGridDim(numLocalGrids);
67  comm_t &domainCommunicator(simDomain.Communicator());
68  int startStep = 0;
69  double startTime = 0;
70 
71  for(int iLocalGrid = 0;iLocalGrid < numLocalGrids;iLocalGrid++){
72 
73  // std::vector<int> &localGridIndices(simDomain.LocalGridIndices());
74 
75  int iGrid = simDomain.LocalGridIndex(iLocalGrid);
76 
77  grid_t &simGrid(*simGrids[iGrid]);
78  state_t &simState(*gridStates[iGrid]);
79  state_t &paramState(*gridParams[iGrid]);
80  state_t &targetState(*gridTargets[iGrid]);
81 
82  const std::string &gridName(domainGridNames[iGrid]);
83 
84  StdOut(messageStream.str());
85  pcpp::io::RenewStream(messageStream);
86 
87  std::vector<size_t> &gridSizes(simGrid.GridSizes());
88 
89  pcpp::IndexIntervalType &partitionInterval(simGrid.PartitionInterval());
90  pcpp::IndexIntervalType &partitionBufferInterval(simGrid.PartitionBufferInterval());
91  halo_t &simHalo(simGrid.Halo());
92 
94  if(!Restart()){
95 
96  FunctionEntry("InitSoln");
97 
98  if(euler::util::InitializeQuiescentState(simGrid,simState,paramState,0,&messageStream)){
99  ErrOut("Could not initialize flow. Messages:\n");
100  ErrOut(messageStream.str());
101  pcpp::io::RenewStream(messageStream);
102  domainCommunicator.SetExit(1);
103  } else {
104  StdOut(messageStream.str());
105  pcpp::io::RenewStream(messageStream);
106  }
107 
108  if(appConfig.IsSet(ConfigKey(simDomain.Name(),"Init:CaseName"))){
109 
110  std::string initName(appConfig.GetValue(ConfigKey(simDomain.Name(),"Init:CaseName")));
111  std::string initKey(ConfigKey(ConfigKey(simDomain.Name(),"Init"),initName));
112  std::vector<double> initParams(appConfig.GetValueVector<double>(ConfigKey(initKey,"Params")));
113  std::vector<int> initFlags(appConfig.GetValueVector<int>(ConfigKey(initKey,"Flags")));
114 
115 
116  messageStream << "Initializing flow on Domain (" << simDomain.Name()
117  << ") with initialization case (" << initName << ")." << std::endl
118  << "Parameters: (";
119  pcpp::io::DumpContents(messageStream,initParams,",");
120  messageStream << ")" << std::endl
121  << "Flags: (";
122  pcpp::io::DumpContents(messageStream,initFlags,",");
123  messageStream << ")" << std::endl;
124  StdOut(messageStream.str(),2);
125  pcpp::io::RenewStream(messageStream);
126 
127  if(InitializeSolution(simGrid,simState,paramState,simDomain.DomainBoundary(iGrid),
128  initName,initParams,initFlags,0,&messageStream)){
129  ErrOut("Solution initialization failed. Messages:\n");
130  ErrOut(messageStream.str());
131  pcpp::io::RenewStream(messageStream);
132  domainCommunicator.SetExit(1);
133  } else {
134  StdOut(messageStream.str());
135  pcpp::io::RenewStream(messageStream);
136  }
137 
138  }
139  FunctionExit("InitSoln");
140 
141  if(domainCommunicator.Check())
142  return(1);
143 
144  } else {
145  FunctionEntry("RestartSoln");
146  StdOut("Processing restart.\n");
147  // Read the grid, state *and target state* from restart file
148  if(!appConfig.IsSet("RestartFileName")){
149  ErrOut("Restart file name not set. Aborting.\n");
150  FunctionExit("RestartSoln");
151  return(1);
152  }
153  std::string restartFileName(appConfig.GetValue("RestartFileName"));
154  std::ostringstream messageOut;
155  messageOut << "Restart File Name = " << restartFileName << std::endl;
156  StdOut(messageOut.str());
157  pcpp::io::RenewStream(messageOut);
158  pcpp::io::simfileinfo restartFileInfo;
159  if(myRank == 0){
160  if(pcpp::io::hdf5::FileInfo(restartFileName,restartFileInfo,messageOut)){
161  ErrOut(std::string("ERROR: FileInfo failed for ")+
162  restartFileName+std::string("\nMessages:\n")+
163  messageOut.str()+std::string("\n"));
164  domainCommunicator.SetExit(1);
165  }
166  }
167  if(domainCommunicator.Check())
168  return(1);
169  domainCommunicator.StreamBroadCast(restartFileInfo);
170 
171  if(restartFileInfo.simStep > 0)
172  startStep = restartFileInfo.simStep;
173  if(restartFileInfo.simTime > 0)
174  startTime = restartFileInfo.simTime;
175 
176  std::ostringstream domainPathStream;
177  if(restartFileInfo.formatBits.test(pcpp::io::ISLEGACY)){
178  domainPathStream << "Group" << (iGrid < 9 ? "00" :
179  iGrid < 99 ? "0" :
180  "") << iGrid+1;
181  restartStep = false;
182  } else {
183  domainPathStream << domainName << "/grid" << iGrid+1;
184  }
185  std::string dataPath = domainPathStream.str();
186  if(pcpp::io::hdf5::FetchStateData(restartFileName,dataPath,simGrid,simState,messageOut)){
187  std::string fetchMessages(messageOut.str());
188  pcpp::io::RenewStream(messageOut);
189  messageOut << "Failed to get state data from " << restartFileName
190  << ". Aborting with messages:" << std::endl
191  << fetchMessages << std::endl;
192  ErrOut(messageOut.str());
193  FunctionExit("RestartSoln");
194  return(1);
195  }
196 
197  FunctionExit("RestartSoln");
198  }
199 
200  simState.InitializeFieldHandles();
201  paramState.InitializeFieldHandles();
202  targetState.InitializeFieldHandles();
203 
204  // Set up the target if needed
205  std::string targetFileName;
206  if(appConfig.IsSet("TargetFileName")){
207  targetFileName = appConfig.GetValue("TargetFileName");
208  }
209  if(!targetFileName.empty()){
210  state_t readTarget(simState);
211  std::ostringstream messageOut;
212  pcpp::io::simfileinfo targetFileInfo;
213  if(myRank == 0){
214  if(pcpp::io::hdf5::FileInfo(targetFileName,targetFileInfo,messageOut)){
215  ErrOut(std::string("ERROR: FileInfo failed for ")+
216  targetFileName+std::string("\nMessages:\n")+
217  messageOut.str()+std::string("\n"));
218  domainCommunicator.SetExit(1);
219  }
220  }
221  if(domainCommunicator.Check())
222  return(1);
223  domainCommunicator.StreamBroadCast(targetFileInfo);
224  std::ostringstream domainPathStream;
225  if(targetFileInfo.formatBits.test(pcpp::io::ISLEGACY)){
226  domainPathStream << "Group" << (iGrid < 9 ? "00" :
227  iGrid < 99 ? "0" :
228  "") << iGrid+1;
229  } else {
230  domainPathStream << domainName << "/grid" << iGrid+1;
231  }
232  std::string dataPath = domainPathStream.str();
233  if(pcpp::io::hdf5::FetchStateData(targetFileName,dataPath,simGrid,readTarget,messageOut)){
234  std::string fetchMessages(messageOut.str());
235  pcpp::io::RenewStream(messageOut);
236  messageOut << "Failed to get target data from " << targetFileName
237  << ". Aborting with messages:" << std::endl
238  << fetchMessages << std::endl;
239  ErrOut(messageOut.str());
240  FunctionExit("RestartSoln");
241  return(1);
242  }
243  targetState.CopyStateData(readTarget);
244  } else {
245  targetState.CopyStateData(simState);
246  }
247 
248  // -- Set up the RHS --
249  rhs_t *nsRHS = new rhs_t;
250  nsRHS->SetGlobal(*this);
251 
252  FunctionEntry("InitRHS");
253 
256  if(nsRHS->Initialize(simGrid,simState,paramState,targetState,sbpOperator)){
257  return(1);
258  }
259 
260  // FunctionEntry("SetDomainBCs");
261  // // nsRHS.SetDomainBoundaries(simDomain.DomainBoundary(0));
262  // nsRHS.SetDomainBCs(simDomain.DomainBoundary(iGrid),simDomain.BCs());
263  // FunctionExit("SetDomainBCs");
264 
265  simDomain.SetRHS(iGrid,*nsRHS);
266 
267  FunctionExit("InitRHS");
268  }
269 
270  FunctionEntry("SetDomainBCs");
271  // nsRHS.SetDomainBoundaries(simDomain.DomainBoundary(0));
272  simDomain.SetDomainBCs();
273  FunctionExit("SetDomainBCs");
274 
275  rk4advancer<domain_t> simAdvancer;
276 
277  FunctionEntry("InitAdvancer");
278  simAdvancer.SetCommunication(false);
279  simAdvancer.InitializeAdvancer(simDomain,*this,messageStream);
280  FunctionExit("InitAdvancer");
281 
282  StdOut(messageStream.str(),2);
283  pcpp::io::RenewStream(messageStream);
284 
285 
286 #ifdef USE_OMP
287  numThreads = omp_get_max_threads();
288 #endif
289 
290 #pragma omp parallel
291  {
292  int myThreadId = 0;
293  bool masterThread = true;
294 
295 #ifdef USE_OMP
296  myThreadId = omp_get_thread_num();
297  masterThread = (myThreadId == 0);
298 #endif
299 
300 // #pragma omp master
301 // {
302 // // SyncIO();
303 // }
304 
305 #pragma omp barrier
306 #pragma omp master
307  {
308  StdOut("Partitioning grids among threads.\n",3);
309  }
310 
311  simDomain.InitThreads();
312 
313 #pragma omp barrier
314 #pragma omp master
315  {
316  StdOut("Partitioning grid among threads done.\n",3);
317  }
318 
319 
320  if(errorState)
321  ErrOut("Grid threading setup failed.\n");
322 
323 #pragma omp barrier
324 #pragma omp master
325  {
326  StdOut("Threads set up, syncing advancer intervals.\n",3);
327  FunctionEntry("SyncIntervals");
328  }
329 
330 #pragma omp barrier
331 
332  simAdvancer.SyncIntervals();
333 
334 #pragma omp barrier
335 
336 #pragma omp master
337  {
338  StdOut("Intervals sync'd, syncing states.\n",3);
339  FunctionExit("SyncIntervals");
340  FunctionEntry("SyncStates");
341  }
342 
343 #pragma omp barrier
344 
345  simAdvancer.SyncStates();
346 
347 #pragma omp barrier
348 #pragma omp master
349  {
350  StdOut("States sync'd.\n",3);
351  FunctionExit("SyncStates");
352  FunctionExit("SimSetup");
353  }
354 
355  simDomain.SetTime(startTime);
356 
357 #pragma omp barrier
358 #pragma omp master
359  {
360  messageStream << "Running PlasCom2 using PBS grids." << std::endl
361  << "DomainName: " << domainName << std::endl
362  << "SBP Order: " << interiorOrder << std::endl
363  << "Current Step: " << startStep << std::endl
364  << "Current Time: " << startTime << std::endl
365  << "NumStepsMax: " << numStepsMax << std::endl
366  << "NumStepsIO : " << numStepsIO << std::endl
367  << "NumStepsStat: " << numStepsStatus << std::endl
368  << "Number of Local Grids: " << numLocalGrids << std::endl;
369 
370  for(int iLocalGrid = 0;iLocalGrid < numLocalGrids;iLocalGrid++){
371 
372  int iGrid = simDomain.LocalGridIndex(iLocalGrid);
373  grid_t &simGrid(*simGrids[iGrid]);
374  const std::string &gridName(domainGridNames[iGrid]);
375  const std::vector<size_t> &gridSizes(simGrid.GridSizes());
376  pcpp::IndexIntervalType &partitionInterval(simGrid.PartitionInterval());
377  pcpp::IndexIntervalType &partitionBufferInterval(simGrid.PartitionBufferInterval());
378 
379  messageStream << "GridName: " << gridName << std::endl
380  << "GridSizes: (";
381  pcpp::io::DumpContents(messageStream,gridSizes,",");
382  messageStream << ")" << std::endl
383  << "Partition: ";
384  partitionInterval.PrettyPrint(messageStream);
385  messageStream << std::endl
386  << "Buffer Sizes: (";
387  pcpp::io::DumpContents(messageStream,simGrid.BufferSizes(),",");
388  messageStream << ")" << std::endl
389  << "PBI:";
390  partitionBufferInterval.PrettyPrint(messageStream);
391  messageStream << std::endl
392  << "Number of Threads: (";
393  pcpp::io::DumpContents(messageStream,numThreadsGridDim[iGrid],",");
394  messageStream << ")" << std::endl;
395  StdOut(messageStream.str(),2);
396  pcpp::io::RenewStream(messageStream);
397  }
398 
399  }
400 #pragma omp barrier
401 #pragma omp master
402  {
403  FunctionEntry("Stepping");
404  StdOut("Beginning stepping.\n",3);
405  }
406 
407 #pragma omp barrier
408 
409  // ========= Time Stepping ===========
410  // errorState = 0;
411  // int iStep = 0;
413  for(int iiStep = startStep;iiStep < numStepsMax;iiStep++){
414 
415 #pragma omp master
416  {
417  iStep = iiStep;
418  simDomain.SetStep(iStep);
419  }
420 
421 #pragma omp barrier
422 
423  if(numStepsStatus > 0){
424  if(!(iiStep%numStepsStatus)){
425 #pragma omp master
426  {
427  messageStream << " Step = " << iiStep
428  << " Time = " << simDomain.Time()
429  << std::endl;
430  StdOut(messageStream.str(),1);
431  pcpp::io::RenewStream(messageStream);
432  }
433  }
434  }
435 
436  if(numStepsIO > 0){
437  if(!(iiStep%numStepsIO) && !restartStep){
438 
439 #pragma omp barrier
440 #pragma omp master
441  {
442  messageStream << "Computing DV before IO" << std::endl;
443  StdOut(messageStream.str(),1);
444  pcpp::io::RenewStream(messageStream);
445  }
446 
447  simDomain.ComputeDV(myThreadId);
448 
449 #pragma omp barrier
450 
451  if(errorState){
452  ErrOut("ComputeDV failed.\n");
453 #pragma omp master
454  {
455  FunctionExit("Stepping");
456  }
457  break;
458  }
459 
460 #pragma omp master
461  {
462  messageStream << "Performing IO at step " << iiStep << std::endl;
463  StdOut(messageStream.str(),1);
464  pcpp::io::RenewStream(messageStream);
465  FunctionEntry("IO");
467  FunctionExit("IO");
468  }
469 
470 #pragma omp barrier
471 
472  if(errorState){
473  ErrOut("IO failed.\n");
474 #pragma omp master
475  {
476  FunctionExit("Stepping");
477  }
478  break;
479  }
480 
481  }
482  }
483  restartStep = false;
484 #pragma omp barrier
485 #pragma omp master
486  {
487  FunctionEntry("AdvanceDomain");
488  }
489 
490 
491  // This must be called for each domain being simulated
492  int advanceCode = simAdvancer.AdvanceDomain();
493  if(advanceCode){
494  std::ostringstream errMsg;
495  errMsg << "Advancer returned error code (" << advanceCode
496  << "):" << std::endl << messageStream.str()
497  << std::endl;
498  ErrOut(errMsg.str());
499  errorState = 1;
500  }
501 
502 #pragma omp barrier
503 #pragma omp master
504  {
505  FunctionExit("AdvanceDomain");
506  }
507 
508  if(errorState)
509  break;
510 
512  // if (domain.Status()) {
513  // Check on domain health and stopping condition
514  // }
515 
516 #pragma omp master
517  {
518  if(iiStep == 1) // this starts advancer timers after 2 steps
519  simAdvancer.SetTimers(true);
520  }
521 
522 #pragma omp barrier
523 #pragma omp master
524  {
525  iStep++;
526  }
527  }
528 
529 #pragma omp barrier
530  } // End OMP parllel section
531 
532  // Important: reset grid/rhs thread environment
533  simDomain.SetNumThreads(1);
534  simDomain.SetStep(iStep);
535 
536  int myThreadId = 0;
537 
538  if(errorState)
539  return(1);
540 
541  FunctionExit("Stepping");
542 
543  messageStream << "Ending at step(" << iStep
544  << ") time( " << simDomain.Time()
545  << ")" << std::endl;
546 
547  StdOut(messageStream.str());
548  pcpp::io::RenewStream(messageStream);
549 
550  // Check domain status to see if IO should be done
551  messageStream << "Computing DV before final IO" << std::endl;
552  StdOut(messageStream.str(),1);
553  pcpp::io::RenewStream(messageStream);
554 
555  simDomain.ComputeDV(myThreadId);
556 
557  if(errorState){
558  ErrOut("EulerPBSPeriodic: ComputeDV failed.\n");
559  }
560 
561  messageStream << "Writing final dump." << std::endl;
562  StdOut(messageStream.str(),1);
563  pcpp::io::RenewStream(messageStream);
564 
565  FunctionEntry("IO");
567  FunctionExit("IO");
568 
569  if(errorState)
570  return(1);
571 
572  // Set up for correct profiling output
573  int numGrids = simDomain.NumberOfGrids();
574  this->SetNumGrids(numGrids);
575  for(int iGrid = 0;iGrid < numGrids;iGrid++){
576  int gridDimension = simGrids[iGrid]->Dimension();
577  size_t numPointsGrid = 1;
578  std::vector<size_t> &gridSizes(simGrids[iGrid]->GridSizes());
579  for(int iDim = 0;iDim < gridDimension;iDim++)
580  numPointsGrid *= gridSizes[iDim];
581  this->SetNumPointsGrid(iGrid,numPointsGrid);
582  }
583  this->SetNumSteps(iStep - startStep);
584 
585  double *processTimes;
586  unsigned int nTimes;
587  std::vector<std::vector<double> > parallelTimes;
588  std::vector<std::vector<long long> > parallelCounts;
589  const char **timerNames;
590  simAdvancer.GetTimers(&processTimes,&timerNames,&nTimes);
591  pcpp::comm::ReduceTimers(processTimes,nTimes,parallelTimes,globalCommunicator);
592  if(myRank == 0){
593  std::ostringstream profileStream;
594  ReportTimings(parallelTimes,timerNames,nTimes,profileStream);
595  StdOut(profileStream.str(),2);
596  // std::string profileFileName(profileName+processorTagOut.str());
597  // std::ofstream profileFile;
598  // profileFile.open(profileFileName.c_str());
599  // profileFile << profileStream.str() << std::endl;
600  // profileFile.close();
601  }
602 
603  // #ifdef USE_PAPI
604  // long long **advancerCounters;
605  // testAdvancer.GetCounters(&advancerCounters);
606  // pcpp::io::RenewStream(profileStream);
607  // ReportCounters(advancerCounters,timerNames,papiCounterNames,nTimes,profileStream);
608  // std::string counterProfileName(std::string("PAPICounters")+processorTagOut.str());
609  // if(myRank == 0){
610  // std::ofstream counterFile;
611  // counterFile.open(counterProfileName.c_str());
612  // counterFile << profileStream.str() << std::endl;
613  // counterFile.close();
614  // }
615  // #endif
616  // }
617 
618 
619  return(0);
620 }
621 
622 
623 
624 
625 // #ifdef USE_PAPI
626 // PAPI_library_init(PAPI_VER_CURRENT);
627 // if(PAPI_create_eventset(&papiEventSet) != PAPI_OK){
628 // PAPI_perror("PAPI event creation failed");
629 // exit(1);
630 // }
631 // numCounters = 0;
632 // std::vector<std::string>::iterator papiNameIt = papiEventNames.begin();
633 // while(papiNameIt != papiEventNames.end()){
634 // std::string eventName(*papiNameIt++);
635 // int eventId = 0;
636 // if(PAPI_event_name_to_code(const_cast<char *>(eventName.c_str()),&eventId) != PAPI_OK){
637 // std::ostringstream papiErrStream;
638 // papiErrStream << "Event not found (" << eventName << ")\n";
639 // myGlobal.ErrOut(papiErrStream.str());
640 // continue;
641 // }
642 // if(PAPI_add_event(papiEventSet,eventId) != PAPI_OK){
643 // std::ostringstream papiErrStream;
644 // papiErrStream << "Event could not be added (" << eventName << ")\n";
645 // PAPI_perror(const_cast<char *>(papiErrStream.str().c_str()));
646 // continue;
647 // } else {
648 // papiCounterNames.push_back(eventName);
649 // numCounters++;
650 // }
651 // }
652 // if(PAPI_start(papiEventSet) != PAPI_OK){
653 // PAPI_perror("Could not start PAPI");
654 // exit(1);
655 // }
656 // std::vector<long long> counterValues(numCounters,0);
657 // // std::vector<long long> counterTicks(numCounters,0);
658 // #endif
659 
660 // // Remove the previous probe file
661 // pcpp::io::Remove("euler3d.probe");
662 
663 // int numThreads = 1;
664 // int errorState = 0;
665 
666 // #ifdef USE_OMP
667 // numThreads = omp_get_max_threads();
668 // #endif
669 // processorTagOut << "_"
670 // << (numThreads < 10 ? "000" :
671 // numThreads < 100 ? "00" :
672 // numThreads < 1000 ? "0" : "")
673 // << numThreads;
674 // // profileName = profileName + processorTagOut.str();
675 
676 
677 // #ifdef USE_PAPI
678 // std::ostringstream papiDriverReport;
679 // PAPI_stop(papiEventSet,&counterValues[0]);
680 // papiDriverReport << "Driver PAPI Counters: " << std::endl;
681 // for(int iCounter = 0;iCounter < numCounters;iCounter++)
682 // papiDriverReport << papiCounterNames[iCounter] << ":\t\t" << counterValues[iCounter] << std::endl;
683 // myGlobal.StdOut(papiDriverReport.str());
684 // #endif
685 
686 // messageStream << "Final Time: " << t << std::endl;
687 
688 // // if(numStepsIO > 0){
689 // // domainState.Report(messageStream);
690 // // myGlobal.StdOut(messageStream.str());
691 // // pcpp::io::RenewStream(messageStream);
692 // // }
693 
694 // if(profLevel > 0){
695 // std::ostringstream profileStream;
696 // profileStream << "#Number of grids: " << 1 << std::endl
697 // << "#Number of procs: " << nProc << std::endl
698 // << "#Number of threads: " << numThreads << std::endl
699 // << "#Number of points: " << numGlobalNodes[0] << " "
700 // << numGlobalNodes[1] << " " << numGlobalNodes[2]
701 // << std::endl
702 // << "#Number of steps: " << numSteps << std::endl;
703 // myGlobal.Report(profileStream);
704 // double *processTimes;
705 // unsigned int nTimes;
706 // std::vector<std::vector<double> > parallelTimes;
707 // std::vector<std::vector<long long> > parallelCounts;
708 // const char **timerNames;
709 // testAdvancer.GetTimers(&processTimes,&timerNames,&nTimes);
710 // pcpp::comm::ReduceTimers(processTimes,nTimes,parallelTimes,simComm);
711 // if(myRank == 0){
712 // ReportTimings(parallelTimes,timerNames,nTimes,profileStream);
713 // std::string profileFileName(profileName+processorTagOut.str());
714 // std::ofstream profileFile;
715 // profileFile.open(profileFileName.c_str());
716 // profileFile << profileStream.str() << std::endl;
717 // profileFile.close();
718 // }
719 // #ifdef USE_PAPI
720 // long long **advancerCounters;
721 // testAdvancer.GetCounters(&advancerCounters);
722 // pcpp::io::RenewStream(profileStream);
723 // ReportCounters(advancerCounters,timerNames,papiCounterNames,nTimes,profileStream);
724 // std::string counterProfileName(std::string("PAPICounters")+processorTagOut.str());
725 // if(myRank == 0){
726 // std::ofstream counterFile;
727 // counterFile.open(counterProfileName.c_str());
728 // counterFile << profileStream.str() << std::endl;
729 // counterFile.close();
730 // }
731 // #endif
732 // }
733 
734 // myGlobal.Finalize();
735 
736 // return(0);
737 
738 void ReportTimings(std::vector<std::vector<double> > &inTimers,const char **timerNames,unsigned int nTimes,
739  std::ostream &outStream)
740 {
741  outStream << "# -------------------------------------------------------------------" << std::endl
742  << "# Routine\tMin\t\tMax\t\tMean" << std::endl
743  << "# ___________________________________________________________________" << std::endl;
744  outStream.setf(std::ios::left);
745  for(int iTimer = 0;iTimer < nTimes;iTimer++){
746  outStream << std::setw(12) << timerNames[iTimer]
747  << "\t" << std::setw(14) << inTimers[0][iTimer]
748  << "\t" << std::setw(14) << inTimers[1][iTimer]
749  << "\t" << std::setw(14) << inTimers[2][iTimer]
750  << std::endl;
751  }
752 }
753 
754 #ifdef USE_PAPI
755 void ReportCounters(long long **inCounters,const char **timerNames,std::vector<std::string> &papiCounterNames,
756  unsigned int nTimes,std::ostream &outStream)
757 {
758  outStream << "# -----------------------------------------------------------------" << std::endl
759  << "# Routine";
760  for(int iCount = 0;iCount < numCounters;iCount++)
761  outStream << "\t" << papiCounterNames[iCount];
762  outStream << std::endl
763  << "# _________________________________________________________________" << std::endl;
764  outStream.setf(std::ios::left);
765  for(int iTimer = 0;iTimer < nTimes;iTimer++){
766  outStream << std::setw(12) << timerNames[iTimer];
767  for(int iCount = 0;iCount < numCounters;iCount++){
768  outStream << "\t" << std::setw(14) << inCounters[iTimer][iCount];
769  }
770  outStream << std::endl;
771  }
772 }
773 #endif
virtual int ErrOut(const std::string &outstr)
Definition: Global.H:456
void SetCommunication(bool onoff)
Definition: RK4Advancer.H:109
std::vector< size_t > numPointsGrid
Definition: PlasCom2.H:94
plascom2::operators::sbp::base operator_t
int InitializeSolution(const GridType &inGrid, StateType &inState, StateType &inParam, std::vector< BoundaryType > &inBoundaries, const std::string &initName, const std::vector< double > &inParams, const std::vector< int > &inFlags, int threadId, std::ostream *messageStream=NULL)
pcpp::IndexIntervalType & PartitionInterval()
Definition: Grid.H:500
virtual void FunctionExit(const StackType &stackentry)
FunctionExit updates the Stack as well as the Profiler.
Definition: Global.H:609
void const size_t const size_t * gridSizes
Definition: EulerKernels.H:10
int FileInfo(const std::string &hdfFileName, pcpp::io::simfileinfo &fileInfo, std::ostream &messageStream)
Definition: PCPPHDF5.C:621
void RenewStream(std::ostringstream &outStream)
virtual void CopyStateData(const base &inBase)
Definition: State.H:208
domainvector appDomains
Definition: Simulation.H:47
int InitializeQuiescentState(const GridType &inGrid, StateType &inState, StateType &inParam, int threadId, std::ostream *messageStream=NULL)
Definition: EulerUtil.H:563
virtual int Restart()
Definition: PlasCom2.H:58
pcpp::CommunicatorType comm_t
virtual int AdvanceDomain()
Advances domain, grid, and state by one step.
Definition: RK4Advancer.H:455
pcpp::IndexIntervalType interval_t
pcpp::ParallelGlobalType global_t
Definition: TestHDF5.C:16
std::bitset< NUMFORMATBITS > formatBits
Definition: PCPPIO.H:42
const std::vector< size_t > & BufferSizes() const
Definition: Grid.H:459
int numProcessors
Number of processors.
Definition: PCPPProgram.H:146
DomainBaseT DomainBaseType
Definition: Simulation.H:29
void SetNumGrids(int nGrids)
Definition: PlasCom2.H:64
void ReduceTimers(double *processTimes, unsigned int nTimes, std::vector< std::vector< double > > &parallelTimes, pcpp::CommunicatorType &inCommunicator)
Definition: PCPPCommUtil.C:9
virtual void FunctionEntry(const StackType &stackentry)
FunctionEntry updates the Stack as well as the Profiler.
Definition: Global.H:604
pcpp::IndexIntervalType & PartitionBufferInterval()
Definition: Grid.H:519
const std::vector< size_t > & GridSizes() const
Definition: Grid.H:469
virtual int StdOut(const std::string &outstr, unsigned char inlev=1)
Definition: Global.H:439
Main encapsulation of MPI.
Definition: COMM.H:62
std::string GetValue(const std::string &key) const
Definition: Parameters.C:24
virtual int WriteDomains()
void SetNumSteps(size_t nSteps)
Definition: PlasCom2.H:76
std::vector< std::string > GetValueVector(const std::string &key) const
Definition: Parameters.C:36
DomainInfoType domainInfo
Definition: Simulation.H:45
void DumpContents(std::ostream &Ostr, const ContainerType &c, std::string del="\)
Dump container contents.
Definition: AppTools.H:117
int SetNumPointsGrid(int iGrid, size_t numPoints)
Definition: PlasCom2.H:69
static const char * timerNames[]
Definition: RK4Advancer.H:30
void GetTimers(double **timersPtr, const char ***namesPtr, unsigned int *numTimers)
Definition: RK4Advancer.H:879
std::string ConfigKey(const std::string &configName, const std::string &keyName)
Definition: PCPPUtil.C:191
CommunicatorType globalCommunicator
Definition: Global.H:531
virtual int InitializeAdvancer(DomainType &inDomain, pcpp::ParallelGlobalType &inGlobal, std::ostream &inStream)
Initializes the advancer object.
Definition: RK4Advancer.H:168
void ReportTimings(std::vector< std::vector< double > > &inTimers, const char **timerNames, unsigned int nTimes, std::ostream &outStream)
Definition: RunPlasCom2.C:738
int SyncStates()
Definition: RK4Advancer.H:354
simulation::grid::halo halo_t
Definition: PlasCom2.H:18
Simple Block Structured Mesh object.
Definition: IndexUtil.H:21
fixtures::ConfigurationType appConfig
Definition: Simulation.H:42
std::vector< std::string > domainNames
Definition: Domain.H:26
int numThreads
Number of threads.
Definition: PCPPProgram.H:148
void SyncIntervals()
Definition: RK4Advancer.H:896
bool IsSet(const std::string &Key) const
Definition: Parameters.C:115
void SetTimers(bool onoff)
Definition: RK4Advancer.H:111
int FetchStateData(const std::string &fileName, const std::string &domainName, GridType &inGrid, StateType &inState, std::ostream &messageStream)
Definition: PCPPHDF5.H:1816