PlasCom2  1.0
XPACC Multi-physics simluation application
PerfPlot.H
Go to the documentation of this file.
1 #include "AppTools.H"
2 #include <iostream>
3 
7 
8 struct gpconfig {
9  std::string gpDisplayTerm;
10  std::string gpFileTerm;
11  std::string gpFileName;
12  std::string gpCustomConfig;
13 };
14 
15 struct timersettings {
17  bool weakMode;
20  bool gridMode;
21  bool effMode;
22  std::string platformName;
23  std::string applicationName;
24  std::string totalTimer;
25  std::vector<std::string> plotTitles;
26  struct gpconfig gpConfig;
28  importantLimit(0),weakMode(false),gridMode(false),
29  effMode(false),dataColumn(2), plotColumn(3) {};
30 };
31 
32 struct pctimervalue {
33  double min;
34  double max;
35  double mean;
36  pctimervalue() : min(0), max(0), mean(0) {};
37  pctimervalue(const pctimervalue &inVal) :
38  min(inVal.min), max(inVal.max), mean(inVal.mean) {};
39 };
40 
41 struct pcruninfo {
42  int numproc;
43  int numgrids;
45  int numsteps;
46  double totalRuntime;
48  std::vector<size_t> ngridpoints;
49  std::vector<int> ngridproc;
50  std::vector<std::vector<size_t> > gridsizes;
51  pcruninfo() : numproc(0), numgrids(0), numthreads(0), numsteps(0),totalRuntime(0),ngridpointstotal(0) {};
52 };
53 
54 typedef std::map<std::string,struct pctimervalue> pcruntimes;
55 
56 struct pcrun {
59 };
60 typedef std::list<std::string> timerlist;
61 typedef std::map<std::string,timerlist> derivedtimers;
62 
63 std::string MakePlotTitle(const pcruninfo &pcRunInfo,
64  const timersettings &timerSettings,
65  int mode = 0)
66 {
67  std::ostringstream Ostr;
68  int numGrids = pcRunInfo.numgrids;
69  size_t numPoints = 0;
70  int numProcs = pcRunInfo.numproc;
71  if(pcRunInfo.numthreads > 0)
72  numProcs *= pcRunInfo.numthreads;
73  for(int i = 0;i < numGrids;i++){
74  if(pcRunInfo.ngridpoints.size() > numGrids){
75  size_t numGridPoints = 1;
76  for(int j = i*3;j < i*3+3;j++)
77  numGridPoints *= pcRunInfo.ngridpoints[j];
78  numPoints += numGridPoints;
79  } else {
80  numPoints += pcRunInfo.ngridpoints[i];
81  }
82  }
83  if(!timerSettings.plotTitles.empty()){
84  if(!timerSettings.plotTitles[mode].empty())
85  Ostr << timerSettings.plotTitles[mode];
86  return(Ostr.str());
87  } else {
88  if(!timerSettings.applicationName.empty())
89  Ostr << timerSettings.applicationName << " ";
90  if(!mode){ // scaling title
91  Ostr << (timerSettings.weakMode ? "Weak " : "Strong ")
92  << "Scaling";
93  if(!timerSettings.platformName.empty())
94  Ostr << " on " << timerSettings.platformName;
95  } else if(mode == 1){
96  Ostr << "Timing ";
97  if(numProcs > 0){ // single run title
98  Ostr << "on " << numProcs;
99  if(!timerSettings.platformName.empty())
100  Ostr << timerSettings.platformName;
101  Ostr << " processors ";
102  } else if(!timerSettings.platformName.empty()){
103  Ostr << "on " << timerSettings.platformName << " ";
104  }
105  }
106  if(!timerSettings.gridMode){
107  if(numGrids > 0){
108  Ostr << "(";
109  if(numPoints > 0)
110  Ostr << numPoints << "points/";
111  Ostr << numGrids << "grids)";
112  } else if (numPoints > 0){
113  Ostr << " (" << numPoints << "grid points) ";
114  }
115  }
116  }
117  return(Ostr.str());
118 }
119 
120 void SetupGnuPlot(std::ostream &outStream,const timersettings &timerSettings,
121  const std::string &idString,bool toDisplay = false)
122 {
123  if(toDisplay){
124  if(!timerSettings.gpConfig.gpDisplayTerm.empty())
125  outStream << "set term " << timerSettings.gpConfig.gpDisplayTerm << std::endl;
126  } else {
127  if(!timerSettings.gpConfig.gpFileTerm.empty())
128  outStream << "set term " << timerSettings.gpConfig.gpFileTerm << std::endl;
129  if(!timerSettings.gpConfig.gpFileName.empty()){
130  outStream << "set output '" << timerSettings.gpConfig.gpFileName
131  << idString;
132  if(timerSettings.gpConfig.gpFileTerm == "png")
133  outStream << ".png'";
134  else if(timerSettings.gpConfig.gpFileTerm == "eps" ||
135  timerSettings.gpConfig.gpFileTerm == "ps")
136  outStream << ".ps'";
137  else if(timerSettings.gpConfig.gpFileTerm == "jpeg")
138  outStream << ".jpg'";
139  else if(timerSettings.gpConfig.gpFileTerm == "pdf")
140  outStream << ".pdf'";
141  outStream << std::endl;
142  }
143  }
144  if(!timerSettings.gpConfig.gpCustomConfig.empty()){
145  outStream << timerSettings.gpConfig.gpCustomConfig;
146  }
147 }
148 
149 void SingleRunPlotCommands(std::ostream &outStream,const std::string &dataFileName,
150  const std::vector<struct pcrun> &pcRuns,int runIndex,
151  const timersettings &timerSettings,bool toDisplay=false)
152 {
153 
154  const pcruninfo pcRunInfo(pcRuns[runIndex].pcRunInfo);
155  std::string plotTitle(MakePlotTitle(pcRunInfo,timerSettings,1));
156  SetupGnuPlot(outStream,timerSettings,"_Timing",toDisplay);
157  outStream << "set title '" << plotTitle << "'" << std::endl
158  << "set ylabel 'Time (GigaCycles)'" << std::endl
159  << "set xlabel 'Routine'" << std::endl
160  << "set boxwidth 0.75 absolute" << std::endl
161  << "set style fill solid" << std::endl
162  << "plot '" << dataFileName << "'";
163  int i = runIndex;
164  outStream << " every 1::1 using " << (i+1)*3 << ":xtic(1) with boxes notitle" << std::endl;
165 }
166 
167 void MultiRunPlotCommands(std::ostream &outStream,const std::string &dataFileName,
168  const std::vector<struct pcrun> &pcRuns,const timersettings &timerSettings,
169  bool toDisplay = false)
170 {
171  const pcruninfo pcRunInfo(pcRuns[0].pcRunInfo);
172  std::string plotTitle(MakePlotTitle(pcRunInfo,timerSettings));
173  int numRuns = pcRuns.size();
174  SetupGnuPlot(outStream,timerSettings,"_Timing",toDisplay);
175  outStream << "set title '" << plotTitle << "'" << std::endl
176  << "set ylabel 'Time (GigaCycles)'" << std::endl;
177  if(timerSettings.gridMode)
178  outStream << "set xlabel 'Number of grid points'" << std::endl;
179  else
180  outStream << "set xlabel 'Number of PE'" << std::endl;
181  outStream << "set boxwidth 0.75 absolute" << std::endl
182  << "set style histogram columnstack" << std::endl
183  << "set style fill solid" << std::endl
184  << "set style data histogram" << std::endl
185  << "plot '" << dataFileName << "'";
186  for(int i = 0;i < numRuns;i++){
187  if(i > 0)
188  outStream << "''";
189  outStream << " using " << (i+1)*3;
190  if(i == numRuns - 1)
191  outStream << ":key(1) ti col";
192  else
193  outStream << " ti col,";
194  }
195  outStream << std::endl;
196 }
197 
198 void SpeedUpPlotCommands(std::ostream &outStream,const std::string &dataFileName,
199  const timerlist &timerList,
200  const std::vector<struct pcrun> &pcRuns,const timersettings &timerSettings,
201  bool toDisplay=false,bool linScale=false)
202 {
203  int numTimers = timerList.size();
204  const pcruninfo pcRunInfo(pcRuns[0].pcRunInfo);
205  int numProcs = pcRunInfo.numproc;
206  if(pcRunInfo.numthreads > 0)
207  numProcs *= pcRunInfo.numthreads;
208  if(timerSettings.gridMode)
209  numProcs = pcRunInfo.ngridpointstotal;
210  if(timerSettings.effMode){
211  SetupGnuPlot(outStream,timerSettings,"_Efficiency",toDisplay);
212  } else {
213  SetupGnuPlot(outStream,timerSettings,"_Speedup",toDisplay);
214  }
215  std::string plotTitle(MakePlotTitle(pcRunInfo,timerSettings));
216  if(timerSettings.gridMode)
217  outStream << "set title 'Grid Scaling on " << timerSettings.platformName
218  << "'" << std::endl;
219  else
220  outStream << "set title '" << plotTitle << "'" << std::endl;
221  if(timerSettings.gridMode)
222  outStream << "set ylabel 'Normalized Time'" << std::endl;
223  else {
224  if(timerSettings.effMode){
225  outStream << "set ylabel 'Parallel Efficiency'" << std::endl;
226  } else {
227  outStream << "set ylabel 'Speedup'" << std::endl;
228  }
229  }
230  if(timerSettings.gridMode)
231  outStream << "set xlabel 'Number of Grid Points'" << std::endl;
232  else
233  outStream << "set xlabel 'Number of threads'" << std::endl;
234  outStream << "set key autotitle columnhead" << std::endl
235  << "set key left" << std::endl;
236  if(timerSettings.gridMode)
237  outStream << "f(x) = x/" << numProcs << std::endl;
238  else {
239  if(timerSettings.effMode){
240  outStream << "f(x) = 1" << std::endl;
241  } else {
242  outStream << "f(x) = x/" << numProcs << std::endl;
243  }
244  }
245  if(!linScale){
246  outStream << "set logscale x" << std::endl;
247  if(!timerSettings.effMode)
248  outStream << "set logscale y" << std::endl;
249  }
250  outStream << "plot ";
251  // if(!timerSettings.gridMode)
252  outStream << "f(x) lc 'black' ti 'Ideal',";
253  outStream << "'" << dataFileName << "'";
254  for(int i = 0;i < numTimers;i++){
255  if(i > 0)
256  outStream << "''";
257  outStream << " using 1:" << i+2 << " w lp";
258  if(i != numTimers - 1)
259  outStream << ",";
260  }
261  outStream << std::endl;
262 }
263 
264 std::string FormatName(const std::string &inName)
265 {
266  std::string outName(inName);
267  std::string::size_type x = outName.find("_");
268  while(x != std::string::npos){
269  outName.erase(x,1);
270  x = outName.find("_");
271  }
272  return(outName);
273 }
274 
275 void SummarizeScalabilityData(std::ostream &outStream,const std::vector<struct pcrun> &pcRuns,
276  const timerlist &timerList, const timersettings &timerSettings)
277 {
278 
279  timerlist::const_iterator timerIt = timerList.begin();
280  std::vector<struct pcrun>::const_iterator pcRunIt = pcRuns.begin();
281  outStream << "Routine";
282  while(timerIt != timerList.end()){
283  outStream << "\t" << FormatName(*timerIt++);
284  }
285  outStream << std::endl;
286  std::map<std::string,double> yScales;
287  std::map<std::string,int> yProcs;
288  // double xScale = -1.0;
289  while(pcRunIt != pcRuns.end()){
290  int runIndex = pcRunIt - pcRuns.begin();
291  const pcruninfo &currentRunInfo(pcRunIt->pcRunInfo);
292  const pcruntimes &pcRunTimes(pcRunIt++->pcRunTimes);
293  int numThreads = currentRunInfo.numproc;
294  if(currentRunInfo.numthreads > 0)
295  numThreads *= currentRunInfo.numthreads;
296  double weakScale = 1.0;
297  if(timerSettings.weakMode)
298  weakScale = numThreads;
299  if(timerSettings.gridMode){
300  numThreads = currentRunInfo.ngridpointstotal;
301  if(timerSettings.weakMode)
302  weakScale = 1.0/(currentRunInfo.ngridpointstotal);
303  }
304  // if(xScale < 0.0) xScale = 1.0/((double)numThreads);
305  outStream << numThreads; // << "\t" << xScale*numThreads;
306  timerIt = timerList.begin();
307  while(timerIt != timerList.end()){
308  const std::string &timerName(*timerIt++);
309  double yScale = 0.0;
310  pctimervalue timerValue;
311  if(pcRunTimes.find(timerName) != pcRunTimes.end()){
312  timerValue = pcRunTimes.at(timerName);
313  std::map<std::string,double>::const_iterator scaleIt = yScales.find(timerName);
314  if(scaleIt != yScales.end()){
315  yScale = scaleIt->second;
316  float scaleProc = yProcs[timerName];
317  if(timerSettings.effMode)
318  yScale *= (scaleProc/(float)numThreads);
319  } else {
320  yScale = timerValue.max;
321  if(yScale == 0){
322  std::cout << "WARNING: Found no scale value for " << timerName << std::endl;
323  yScale = 1.0;
324  }
325  yScales[timerName] = yScale;
326  yProcs[timerName] = numThreads;
327  std::cout << "Setting scale for " << timerName << " = "
328  << yScale << " @ " << numThreads << " procs."
329  << std::endl;
330  }
331  // weakScale /= yProcs[timerName];
332  if(!timerSettings.gridMode){
333  outStream << "\t" << yScale*weakScale/timerValue.max;
334  } else {
335  outStream << "\t" << weakScale*timerValue.max/yScale;
336  }
337  } else {
338  if(!timerSettings.gridMode){
339  // outStream << "\t" << weakScale/yProcs[timerName];
340  outStream << "\t" << weakScale;
341  } else {
342  outStream << "\t1";
343  }
344  }
345  }
346  outStream << std::endl;
347  }
348 }
349 
350 void SummarizeTimingData(std::ostream &outStream,const std::vector<struct pcrun> &pcRuns,
351  const timerlist &timerList,const timersettings &timerSettings)
352 {
353  timerlist::const_iterator timerIt = timerList.begin();
354  std::vector<struct pcrun>::const_iterator pcRunIt = pcRuns.begin();
355  outStream << "Routine";
356  while(pcRunIt != pcRuns.end()){
357  int numProc = pcRunIt->pcRunInfo.numproc;
358  if(pcRunIt->pcRunInfo.numthreads > 0)
359  numProc *= pcRunIt->pcRunInfo.numthreads;
360  if(timerSettings.gridMode)
361  numProc = pcRunIt->pcRunInfo.ngridpointstotal;
362  outStream << "\t" << numProc << "\t" << numProc << "\t" << numProc;
363  pcRunIt++;
364  }
365  outStream << std::endl;
366  while(timerIt != timerList.end()){
367  const std::string &timerName(*timerIt++);
368  outStream << FormatName(timerName);
369  pcRunIt = pcRuns.begin();
370  while(pcRunIt != pcRuns.end()){
371  const pcruntimes &pcRunTimes(pcRunIt++->pcRunTimes);
372  pctimervalue timerValue;
373  if(pcRunTimes.find(timerName) != pcRunTimes.end()){
374  timerValue = pcRunTimes.at(timerName);
375  }
376  outStream << "\t" << timerValue.min << "\t" << timerValue.max << "\t" << timerValue.mean;
377  }
378  outStream << std::endl;
379  }
380 }
381 
382 bool TimerIncluded(const std::string &routineName,const timerlist &timerList)
383 {
384  timerlist::const_iterator listIt = timerList.begin();
385  while(listIt != timerList.end()){
386  std::string timerPattern(*listIt++);
387  if(timerPattern == "*")
388  return(true);
389  if(timerPattern[0] == '-')
390  timerPattern = timerPattern.substr(1);
391  if(timerPattern == routineName)
392  return(true);
393  // if(routineName.find(timerPattern) != std::string::npos)
394  }
395  return(false);
396 }
397 
398 int GetDerivedOperationForRoutine(const std::string &timerName,const std::string &routineName,const derivedtimers &derivedTimers)
399 {
400  derivedtimers::const_iterator derivedIt = derivedTimers.begin();
401  bool found = false;
402  timerlist derivedTimerNames;
403  while(derivedIt != derivedTimers.end() && !found){
404  const std::string &derivedTimerName(derivedIt->first);
405  if(timerName == derivedTimerName){
406  found = true;
407  derivedTimerNames = derivedIt->second;
408  } else {
409  derivedIt++;
410  }
411  }
412  if(!found)
413  return(-1);
414  timerlist::iterator listIt = derivedTimerNames.begin();
415  while(listIt != derivedTimerNames.end()){
416  std::string &timerPattern(*listIt++);
417  int op = 0;
418  if(timerPattern[0] == '-'){
419  timerPattern = timerPattern.substr(1);
420  op = 1;
421  }
422  if(routineName == timerPattern)
423  return(op);
424  }
425  return(-1);
426 }
427 
428 std::vector<std::string> GetDerivedTimerNames(const std::string &routineName,const derivedtimers &derivedTimers)
429 {
430  std::vector<std::string> derivedTimerNames;
431  derivedtimers::const_iterator derivedIt = derivedTimers.begin();
432  std::string emptyString;
433  while(derivedIt != derivedTimers.end()){
434  const std::string &derivedTimerName(derivedIt->first);
435  const timerlist &timerNames(derivedIt++->second);
436  if(TimerIncluded(routineName,timerNames))
437  derivedTimerNames.push_back(derivedTimerName);
438  }
439  return(derivedTimerNames);
440 }
441 
442 pcruntimes ProcessRun(const pcruninfo &pcRunInfo,const pcruntimes &rawRunTimes,const derivedtimers &derivedTimers,
443  const timerlist &excludedTimers,const timersettings &timerSettings,
444  pctimervalue &timingDelta)
445 {
446  pcruntimes processedTimers;
447  pctimervalue timedTotal;
448  pctimervalue pcTotal;
449  pcruntimes::const_iterator totalTimeIt;
450  if(!timerSettings.totalTimer.empty()){
451  totalTimeIt = rawRunTimes.find(timerSettings.totalTimer);
452  if(totalTimeIt != rawRunTimes.end()){
453  pcTotal = rawRunTimes.at(timerSettings.totalTimer);
454  }
455  }
456  if(pcTotal.max <= 0.0){
457  totalTimeIt = rawRunTimes.find(timerSettings.applicationName);
458  if(totalTimeIt != rawRunTimes.end()){
459  pcTotal = rawRunTimes.at(timerSettings.applicationName);
460  }
461  }
462  if(pcTotal.max <= 0.0){
463  // std::cout << "Setting pcTotal runtime to " << pcRunInfo.totalRuntime << std::endl;
464  pcTotal.max = pcRunInfo.totalRuntime;
465  pcTotal.min = pcRunInfo.totalRuntime;
466  pcTotal.mean = pcRunInfo.totalRuntime;
467  }
468  assert(pcTotal.max > 0.0);
469  // const pctimervalue &pcTotal(rawRunTimes.at("PlasComCM"));
470  pcruntimes::const_iterator rawRunTimesIt = rawRunTimes.begin();
471  while(rawRunTimesIt != rawRunTimes.end()){
472  const std::string &routineName(rawRunTimesIt->first);
473  const pctimervalue &timerValue(rawRunTimesIt++->second);
474  std::vector<std::string> timerNames(GetDerivedTimerNames(routineName,derivedTimers));
475  if(timerNames.empty()){
476  if(TimerIncluded(routineName,excludedTimers))
477  continue;
478  if(timerValue.max/pcTotal.max >= timerSettings.importantLimit){
479  timerNames.push_back(routineName);
480  } else {
481  timerNames.push_back("Other");
482  }
483  }
484  timedTotal.min += timerValue.min;
485  timedTotal.max += timerValue.max;
486  timedTotal.mean += timerValue.mean;
487  std::vector<std::string>::iterator timerNameIt = timerNames.begin();
488  while(timerNameIt != timerNames.end()){
489  std::string &timerName(*timerNameIt++);
490  // std::cout << "Found timer name " << timerName << " for " << routineName << std::endl;
491  pctimervalue &pcTimerValue(processedTimers[timerName]);
492  int op = GetDerivedOperationForRoutine(timerName,routineName,derivedTimers);
493  if(op == 0){
494  pcTimerValue.min += timerValue.min;
495  pcTimerValue.max += timerValue.max;
496  pcTimerValue.mean += timerValue.mean;
497  } else if(op == 1){
498  pcTimerValue.min -= timerValue.min;
499  pcTimerValue.max -= timerValue.max;
500  pcTimerValue.mean -= timerValue.mean;
501  } else {
502  std::cerr << "ERROR: Undefined operation for derived timer/routine = "
503  << timerName << "/" << routineName << std::endl;
504  exit(1);
505  }
506  }
507  }
508  timingDelta.min = pcTotal.min - timedTotal.min;
509  timingDelta.max = pcTotal.max - timedTotal.max;
510  timingDelta.mean = pcTotal.mean - timedTotal.mean;
511 
512  return(processedTimers);
513 }
514 
515 void ReadTimers(pcruntimes &routineTimes,
516  std::ifstream &inFile,int dataColumn)
517 {
518  std::string line;
519  while(std::getline(inFile,line)){
520  if(line.empty())
521  continue;
522  if(line[0] == '#')
523  continue;
524  std::string routineName;
525  pctimervalue pcTimerValue;
526  std::istringstream Istr(line);
527  Istr >> routineName >> pcTimerValue.min >> pcTimerValue.max >> pcTimerValue.mean;
528  if(dataColumn == 1){
529  double holdVal = pcTimerValue.min;
530  pcTimerValue.min = pcTimerValue.max;
531  pcTimerValue.max = holdVal;
532  }
533  routineTimes[routineName] = pcTimerValue;
534  }
535 }
537 {
538  inConfig.push_back(std::make_pair(std::string("DerivedTimer::RHS"),std::string("rhs_total")));
539  inConfig.push_back(std::make_pair(std::string("DerivedTimer::ReadInterp"),std::string("interp_setup")));
540  inConfig.push_back(std::make_pair(std::string("DerivedTimer::ReadGrids"),std::string("InitGrids")));
541  inConfig.push_back(std::make_pair(std::string("DerivedTimer::ReadState"),std::string("InitState")));
542  inConfig.push_back(std::make_pair(std::string("DerivedTimer::Interpolation"),std::string("interp_vol")));
543  inConfig.push_back(std::make_pair(std::string("DerivedTimer::Write"),std::string("io_write_restart io_write_soln")));
544  inConfig.push_back(std::make_pair(std::string("TimerSetting::ImportantLimit"),std::string("0.05")));
545  inConfig.push_back(std::make_pair(std::string("DerivedTimer::Names"),
546  std::string("RHS Interpolation ReadGrids ReadState ReadInterp Write")));
547  inConfig.push_back(std::make_pair(std::string("ExcludedTimer::Names"),
548  std::string("PlasComCM RunTime MainLoop RungeKutta SpecificRKTime operator rhs io_total InitTotal")));
549 }
550 
551 void PopulateRunInfo(pcruninfo &pcRunInfo,std::ifstream &inFile)
552 {
553  pcRunInfo.numproc = 0;
554  pcRunInfo.numgrids = 0;
555  pcRunInfo.numsteps = 0;
556  inFile.seekg(0);
557  std::string line;
558  while(line.empty() && inFile)
559  std::getline(inFile,line);
560  int nline = 0;
561  while(line[0] == '#'){
562  int streamPos = inFile.tellg();
563  if(nline > 0){
564  std::getline(inFile,line);
565  while(line.empty() && inFile)
566  std::getline(inFile,line);
567  }
568  if(line[0] == '#'){
569  nline++;
570  std::string::size_type y = line.find(":");
571  if(y == std::string::npos)
572  continue;
573  std::istringstream Istr(line.substr(y+1));
574  if(line.find("Number of procs:") != std::string::npos){
575  Istr >> pcRunInfo.numproc;
576  } else if (line.find("Number of grids:") != std::string::npos) {
577  Istr >> pcRunInfo.numgrids;
578  } else if (line.find("Number of threads:") != std::string::npos) {
579  Istr >> pcRunInfo.numthreads;
580  } else if (line.find("Number of steps:") != std::string::npos){
581  Istr >> pcRunInfo.numsteps;
582  } else if (line.find("Number of points:") != std::string::npos){
583  size_t npoints = 0;
584  size_t npointstotal = 1;
585  while(Istr >> npoints){
586  if(npoints > 0){
587  pcRunInfo.ngridpoints.push_back(npoints);
588  npointstotal *= npoints;
589  }
590  }
591  pcRunInfo.ngridpointstotal = npointstotal;
592  std::cout << "Num grid points total: " << pcRunInfo.ngridpointstotal << std::endl;
593  } else if (line.find("Procs per grid:") != std::string::npos){
594  int nprocs = 0;
595  while(Istr >> nprocs){
596  if(nprocs > 0)
597  pcRunInfo.ngridproc.push_back(nprocs);
598  }
599  } else if (line.find("Total Execution Time:") != std::string::npos){
600  Istr >> pcRunInfo.totalRuntime;
601  }
602  } else {
603  inFile.seekg(streamPos);
604  }
605  }
606  if(pcRunInfo.numproc == 0)
607  pcRunInfo.numproc = 1;
608  if(pcRunInfo.numgrids == 0)
609  pcRunInfo.numgrids = 1;
610  if(pcRunInfo.numthreads == 0)
611  pcRunInfo.numthreads = 1;
612 }
613 
614 void SetupTimerSettings(timersettings &timerSettings,
615  const ConfigType &inConfig)
616 {
617  const std::string settingKey("TimerSetting::");
618  timerSettings.importantLimit = 0.05;
619  if(inConfig.IsSet(settingKey+"ImportantLimit"))
620  timerSettings.importantLimit = inConfig.GetValue<double>(settingKey+"ImportantLimit");
621  if(inConfig.IsSet(settingKey+"WeakMode"))
622  timerSettings.weakMode = inConfig.GetFlagValue(settingKey+"WeakMode");
623  if(inConfig.IsSet(settingKey+"GridMode"))
624  timerSettings.gridMode = inConfig.GetFlagValue(settingKey+"GridMode");
625  if(inConfig.IsSet(settingKey+"PlatformName"))
626  timerSettings.platformName = inConfig.GetValue(settingKey+"PlatformName");
627  if(inConfig.IsSet(settingKey+"ApplicationName"))
628  timerSettings.applicationName = inConfig.GetValue(settingKey+"ApplicationName");
629  if(inConfig.IsSet(settingKey+"DataColumn"))
630  timerSettings.dataColumn = inConfig.GetValue<int>(settingKey+"DataColumn");
631  const std::string gpKey("GNUPlot::");
632  if(inConfig.IsSet(gpKey+"DisplayTerm"))
633  timerSettings.gpConfig.gpDisplayTerm = inConfig.GetValue(gpKey+"DisplayTerm");
634  if(inConfig.IsSet(gpKey+"FileTerm"))
635  timerSettings.gpConfig.gpFileTerm = inConfig.GetValue(gpKey+"FileTerm");
636  if(inConfig.IsSet(gpKey+"FileName"))
637  timerSettings.gpConfig.gpFileName = inConfig.GetValue(gpKey+"FileName");
638  const std::string gpConfigKey(gpKey+"CustomConfig::");
639  if(inConfig.IsSet(gpConfigKey+"Names")){
640  std::ostringstream customConfigStream;
641  std::vector<std::string> customConfigNames(inConfig.GetValueVector(gpConfigKey+"Names"));
642  std::vector<std::string>::iterator configIt = customConfigNames.begin();
643  while(configIt != customConfigNames.end()){
644  std::string &configName(*configIt++);
645  std::string configKey(gpConfigKey+configName);
646  if(inConfig.IsSet(configKey)){
647  customConfigStream << inConfig.Param(configKey) << std::endl;
648  }
649  }
650  timerSettings.gpConfig.gpCustomConfig = customConfigStream.str();
651  }
652 }
653 
654 
655 void SetupExcludedTimers(timerlist &excludedTimers,
656  const ConfigType &inConfig)
657 {
658  excludedTimers = inConfig.GetValueList("ExcludedTimer::Names");
659 }
660 
661 void SetupDerivedTimers(derivedtimers &derivedTimers,
662  const ConfigType &inConfig)
663 {
664  const std::string configKey("DerivedTimer::");
665  timerlist derivedTimerNames(inConfig.GetValueList("DerivedTimer::Names"));
666  timerlist::iterator timerNameIt = derivedTimerNames.begin();
667  while(timerNameIt != derivedTimerNames.end()){
668  std::string &timerName(*timerNameIt++);
669  std::string timerKey(configKey+timerName);
670  timerlist &derivedTimerLabels(derivedTimers[timerName]);
671  derivedTimerLabels = inConfig.GetValueList(timerKey);
672  }
673 }
std::vector< int > ngridproc
Definition: PerfPlot.H:49
std::string applicationName
Definition: PerfPlot.H:23
std::list< std::string > GetValueList(const std::string &key) const
Definition: AppTools.H:278
int numthreads
Definition: PerfPlot.H:44
std::string platformName
Definition: PerfPlot.H:22
pctimervalue()
Definition: PerfPlot.H:36
void const size_t * numPoints
Definition: EulerKernels.H:10
double max
Definition: PerfPlot.H:34
int plotColumn
Definition: PerfPlot.H:19
apptools::parameters ConfigType
Definition: PerfPlot.H:4
void SetConfigurationDefaults(ConfigType &inConfig)
Definition: PerfPlot.H:536
int numsteps
Definition: PerfPlot.H:45
bool weakMode
Definition: PerfPlot.H:17
void SingleRunPlotCommands(std::ostream &outStream, const std::string &dataFileName, const std::vector< struct pcrun > &pcRuns, int runIndex, const timersettings &timerSettings, bool toDisplay=false)
Definition: PerfPlot.H:149
void SetupGnuPlot(std::ostream &outStream, const timersettings &timerSettings, const std::string &idString, bool toDisplay=false)
Definition: PerfPlot.H:120
pcruninfo pcRunInfo
Definition: PerfPlot.H:57
void const size_t const size_t const size_t const double const double double * y
pcruntimes pcRunTimes
Definition: PerfPlot.H:58
double totalRuntime
Definition: PerfPlot.H:46
int dataColumn
Definition: PerfPlot.H:18
pcruninfo()
Definition: PerfPlot.H:51
std::string gpFileName
Definition: PerfPlot.H:11
std::string MakePlotTitle(const pcruninfo &pcRunInfo, const timersettings &timerSettings, int mode=0)
Definition: PerfPlot.H:63
void const size_t const size_t const size_t const double const double * x
void MultiRunPlotCommands(std::ostream &outStream, const std::string &dataFileName, const std::vector< struct pcrun > &pcRuns, const timersettings &timerSettings, bool toDisplay=false)
Definition: PerfPlot.H:167
int GetDerivedOperationForRoutine(const std::string &timerName, const std::string &routineName, const derivedtimers &derivedTimers)
Definition: PerfPlot.H:398
pctimervalue(const pctimervalue &inVal)
Definition: PerfPlot.H:37
bool TimerIncluded(const std::string &routineName, const timerlist &timerList)
Definition: PerfPlot.H:382
bool gridMode
Definition: PerfPlot.H:20
void PopulateRunInfo(pcruninfo &pcRunInfo, std::ifstream &inFile)
Definition: PerfPlot.H:551
std::map< std::string, timerlist > derivedtimers
Definition: PerfPlot.H:61
void ReadTimers(pcruntimes &routineTimes, std::ifstream &inFile, int dataColumn)
Definition: PerfPlot.H:515
int OpenFile(std::ifstream &Inf, const std::string &filename)
File opener.
Definition: AppTools.H:144
apptools::comlinehandler CommandLineType
Definition: PerfPlot.H:5
void SetupTimerSettings(timersettings &timerSettings, const ConfigType &inConfig)
Definition: PerfPlot.H:614
bool GetFlagValue(const std::string &key) const
Definition: AppTools.H:171
void SummarizeScalabilityData(std::ostream &outStream, const std::vector< struct pcrun > &pcRuns, const timerlist &timerList, const timersettings &timerSettings)
Definition: PerfPlot.H:275
std::vector< std::string > GetValueVector(const std::string &key) const
Definition: AppTools.H:265
std::string gpFileTerm
Definition: PerfPlot.H:10
std::map< std::string, struct pctimervalue > pcruntimes
Definition: PerfPlot.H:54
std::string totalTimer
Definition: PerfPlot.H:24
std::string GetValue(const std::string &key) const
Definition: AppTools.H:254
std::list< std::string > timerlist
Definition: PerfPlot.H:60
void SpeedUpPlotCommands(std::ostream &outStream, const std::string &dataFileName, const timerlist &timerList, const std::vector< struct pcrun > &pcRuns, const timersettings &timerSettings, bool toDisplay=false, bool linScale=false)
Definition: PerfPlot.H:198
double min
Definition: PerfPlot.H:33
double mean
Definition: PerfPlot.H:35
int numgrids
Definition: PerfPlot.H:43
struct gpconfig gpConfig
Definition: PerfPlot.H:26
size_t ngridpointstotal
Definition: PerfPlot.H:47
bool effMode
Definition: PerfPlot.H:21
std::string gpDisplayTerm
Definition: PerfPlot.H:9
void SetupDerivedTimers(derivedtimers &derivedTimers, const ConfigType &inConfig)
Definition: PerfPlot.H:661
static const char * timerNames[]
Definition: RK4Advancer.H:30
std::vector< std::string > GetDerivedTimerNames(const std::string &routineName, const derivedtimers &derivedTimers)
Definition: PerfPlot.H:428
std::string Param(const std::string &Key) const
Definition: AppTools.H:324
std::string gpCustomConfig
Definition: PerfPlot.H:12
void SummarizeTimingData(std::ostream &outStream, const std::vector< struct pcrun > &pcRuns, const timerlist &timerList, const timersettings &timerSettings)
Definition: PerfPlot.H:350
void SetupExcludedTimers(timerlist &excludedTimers, const ConfigType &inConfig)
Definition: PerfPlot.H:655
std::vector< std::vector< size_t > > gridsizes
Definition: PerfPlot.H:50
double importantLimit
Definition: PerfPlot.H:16
std::vector< std::string > plotTitles
Definition: PerfPlot.H:25
int numproc
Definition: PerfPlot.H:42
pcruntimes ProcessRun(const pcruninfo &pcRunInfo, const pcruntimes &rawRunTimes, const derivedtimers &derivedTimers, const timerlist &excludedTimers, const timersettings &timerSettings, pctimervalue &timingDelta)
Definition: PerfPlot.H:442
Definition: PerfPlot.H:56
Command line processing.
Definition: AppTools.H:411
std::vector< size_t > ngridpoints
Definition: PerfPlot.H:48
std::string FormatName(const std::string &inName)
Definition: PerfPlot.H:264
bool IsSet(const std::string &Key) const
Definition: AppTools.H:336