28 importantLimit(0),weakMode(false),gridMode(false),
29 effMode(false),dataColumn(2), plotColumn(3) {};
38 min(inVal.min), max(inVal.max), mean(inVal.mean) {};
51 pcruninfo() : numproc(0), numgrids(0), numthreads(0), numsteps(0),totalRuntime(0),ngridpointstotal(0) {};
54 typedef std::map<std::string,struct pctimervalue>
pcruntimes;
67 std::ostringstream Ostr;
70 int numProcs = pcRunInfo.
numproc;
73 for(
int i = 0;i < numGrids;i++){
75 size_t numGridPoints = 1;
76 for(
int j = i*3;j < i*3+3;j++)
78 numPoints += numGridPoints;
91 Ostr << (timerSettings.
weakMode ?
"Weak " :
"Strong ")
98 Ostr <<
"on " << numProcs;
101 Ostr <<
" processors ";
110 Ostr << numPoints <<
"points/";
111 Ostr << numGrids <<
"grids)";
112 }
else if (numPoints > 0){
113 Ostr <<
" (" << numPoints <<
"grid points) ";
121 const std::string &idString,
bool toDisplay =
false)
133 outStream <<
".png'";
138 outStream <<
".jpg'";
140 outStream <<
".pdf'";
141 outStream << std::endl;
150 const std::vector<struct pcrun> &pcRuns,
int runIndex,
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 <<
"'";
164 outStream <<
" every 1::1 using " << (i+1)*3 <<
":xtic(1) with boxes notitle" << std::endl;
168 const std::vector<struct pcrun> &pcRuns,
const timersettings &timerSettings,
169 bool toDisplay =
false)
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;
178 outStream <<
"set xlabel 'Number of grid points'" << std::endl;
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++){
189 outStream <<
" using " << (i+1)*3;
191 outStream <<
":key(1) ti col";
193 outStream <<
" ti col,";
195 outStream << std::endl;
200 const std::vector<struct pcrun> &pcRuns,
const timersettings &timerSettings,
201 bool toDisplay=
false,
bool linScale=
false)
203 int numTimers = timerList.size();
204 const pcruninfo pcRunInfo(pcRuns[0].pcRunInfo);
205 int numProcs = pcRunInfo.
numproc;
211 SetupGnuPlot(outStream,timerSettings,
"_Efficiency",toDisplay);
213 SetupGnuPlot(outStream,timerSettings,
"_Speedup",toDisplay);
215 std::string plotTitle(
MakePlotTitle(pcRunInfo,timerSettings));
217 outStream <<
"set title 'Grid Scaling on " << timerSettings.
platformName 220 outStream <<
"set title '" << plotTitle <<
"'" << std::endl;
222 outStream <<
"set ylabel 'Normalized Time'" << std::endl;
225 outStream <<
"set ylabel 'Parallel Efficiency'" << std::endl;
227 outStream <<
"set ylabel 'Speedup'" << std::endl;
231 outStream <<
"set xlabel 'Number of Grid Points'" << std::endl;
233 outStream <<
"set xlabel 'Number of threads'" << std::endl;
234 outStream <<
"set key autotitle columnhead" << std::endl
235 <<
"set key left" << std::endl;
237 outStream <<
"f(x) = x/" << numProcs << std::endl;
240 outStream <<
"f(x) = 1" << std::endl;
242 outStream <<
"f(x) = x/" << numProcs << std::endl;
246 outStream <<
"set logscale x" << std::endl;
248 outStream <<
"set logscale y" << std::endl;
250 outStream <<
"plot ";
252 outStream <<
"f(x) lc 'black' ti 'Ideal',";
253 outStream <<
"'" << dataFileName <<
"'";
254 for(
int i = 0;i < numTimers;i++){
257 outStream <<
" using 1:" << i+2 <<
" w lp";
258 if(i != numTimers - 1)
261 outStream << std::endl;
266 std::string outName(inName);
267 std::string::size_type
x = outName.find(
"_");
268 while(x != std::string::npos){
270 x = outName.find(
"_");
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()){
285 outStream << std::endl;
286 std::map<std::string,double> yScales;
287 std::map<std::string,int> yProcs;
289 while(pcRunIt != pcRuns.end()){
290 int runIndex = pcRunIt - pcRuns.begin();
291 const pcruninfo ¤tRunInfo(pcRunIt->pcRunInfo);
292 const pcruntimes &pcRunTimes(pcRunIt++->pcRunTimes);
293 int numThreads = currentRunInfo.
numproc;
296 double weakScale = 1.0;
298 weakScale = numThreads;
305 outStream << numThreads;
306 timerIt = timerList.begin();
307 while(timerIt != timerList.end()){
308 const std::string &timerName(*timerIt++);
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];
318 yScale *= (scaleProc/(float)numThreads);
320 yScale = timerValue.
max;
322 std::cout <<
"WARNING: Found no scale value for " << timerName << std::endl;
325 yScales[timerName] = yScale;
326 yProcs[timerName] = numThreads;
327 std::cout <<
"Setting scale for " << timerName <<
" = " 328 << yScale <<
" @ " << numThreads <<
" procs." 333 outStream <<
"\t" << yScale*weakScale/timerValue.
max;
335 outStream <<
"\t" << weakScale*timerValue.
max/yScale;
340 outStream <<
"\t" << weakScale;
346 outStream << std::endl;
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;
361 numProc = pcRunIt->pcRunInfo.ngridpointstotal;
362 outStream <<
"\t" << numProc <<
"\t" << numProc <<
"\t" << numProc;
365 outStream << std::endl;
366 while(timerIt != timerList.end()){
367 const std::string &timerName(*timerIt++);
369 pcRunIt = pcRuns.begin();
370 while(pcRunIt != pcRuns.end()){
371 const pcruntimes &pcRunTimes(pcRunIt++->pcRunTimes);
373 if(pcRunTimes.find(timerName) != pcRunTimes.end()){
374 timerValue = pcRunTimes.at(timerName);
376 outStream <<
"\t" << timerValue.
min <<
"\t" << timerValue.
max <<
"\t" << timerValue.
mean;
378 outStream << std::endl;
384 timerlist::const_iterator listIt = timerList.begin();
385 while(listIt != timerList.end()){
386 std::string timerPattern(*listIt++);
387 if(timerPattern ==
"*")
389 if(timerPattern[0] ==
'-')
390 timerPattern = timerPattern.substr(1);
391 if(timerPattern == routineName)
400 derivedtimers::const_iterator derivedIt = derivedTimers.begin();
403 while(derivedIt != derivedTimers.end() && !found){
404 const std::string &derivedTimerName(derivedIt->first);
405 if(timerName == derivedTimerName){
407 derivedTimerNames = derivedIt->second;
414 timerlist::iterator listIt = derivedTimerNames.begin();
415 while(listIt != derivedTimerNames.end()){
416 std::string &timerPattern(*listIt++);
418 if(timerPattern[0] ==
'-'){
419 timerPattern = timerPattern.substr(1);
422 if(routineName == timerPattern)
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);
437 derivedTimerNames.push_back(derivedTimerName);
439 return(derivedTimerNames);
449 pcruntimes::const_iterator totalTimeIt;
451 totalTimeIt = rawRunTimes.find(timerSettings.
totalTimer);
452 if(totalTimeIt != rawRunTimes.end()){
453 pcTotal = rawRunTimes.at(timerSettings.
totalTimer);
456 if(pcTotal.
max <= 0.0){
458 if(totalTimeIt != rawRunTimes.end()){
462 if(pcTotal.
max <= 0.0){
468 assert(pcTotal.
max > 0.0);
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);
475 if(timerNames.empty()){
479 timerNames.push_back(routineName);
481 timerNames.push_back(
"Other");
484 timedTotal.
min += timerValue.
min;
485 timedTotal.
max += timerValue.
max;
487 std::vector<std::string>::iterator timerNameIt = timerNames.begin();
488 while(timerNameIt != timerNames.end()){
489 std::string &timerName(*timerNameIt++);
494 pcTimerValue.
min += timerValue.
min;
495 pcTimerValue.
max += timerValue.
max;
496 pcTimerValue.
mean += timerValue.
mean;
498 pcTimerValue.
min -= timerValue.
min;
499 pcTimerValue.
max -= timerValue.
max;
500 pcTimerValue.
mean -= timerValue.
mean;
502 std::cerr <<
"ERROR: Undefined operation for derived timer/routine = " 503 << timerName <<
"/" << routineName << std::endl;
508 timingDelta.
min = pcTotal.
min - timedTotal.
min;
509 timingDelta.
max = pcTotal.
max - timedTotal.
max;
512 return(processedTimers);
516 std::ifstream &inFile,
int dataColumn)
519 while(std::getline(inFile,line)){
524 std::string routineName;
526 std::istringstream Istr(line);
527 Istr >> routineName >> pcTimerValue.
min >> pcTimerValue.
max >> pcTimerValue.
mean;
529 double holdVal = pcTimerValue.
min;
530 pcTimerValue.
min = pcTimerValue.
max;
531 pcTimerValue.
max = holdVal;
533 routineTimes[routineName] = pcTimerValue;
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")));
558 while(line.empty() && inFile)
559 std::getline(inFile,line);
561 while(line[0] ==
'#'){
562 int streamPos = inFile.tellg();
564 std::getline(inFile,line);
565 while(line.empty() && inFile)
566 std::getline(inFile,line);
570 std::string::size_type
y = line.find(
":");
571 if(y == std::string::npos)
573 std::istringstream Istr(line.substr(y+1));
574 if(line.find(
"Number of procs:") != std::string::npos){
576 }
else if (line.find(
"Number of grids:") != std::string::npos) {
578 }
else if (line.find(
"Number of threads:") != std::string::npos) {
580 }
else if (line.find(
"Number of steps:") != std::string::npos){
582 }
else if (line.find(
"Number of points:") != std::string::npos){
584 size_t npointstotal = 1;
585 while(Istr >> npoints){
588 npointstotal *= npoints;
592 std::cout <<
"Num grid points total: " << pcRunInfo.
ngridpointstotal << std::endl;
593 }
else if (line.find(
"Procs per grid:") != std::string::npos){
595 while(Istr >> nprocs){
599 }
else if (line.find(
"Total Execution Time:") != std::string::npos){
603 inFile.seekg(streamPos);
617 const std::string settingKey(
"TimerSetting::");
619 if(inConfig.
IsSet(settingKey+
"ImportantLimit"))
621 if(inConfig.
IsSet(settingKey+
"WeakMode"))
623 if(inConfig.
IsSet(settingKey+
"GridMode"))
625 if(inConfig.
IsSet(settingKey+
"PlatformName"))
627 if(inConfig.
IsSet(settingKey+
"ApplicationName"))
629 if(inConfig.
IsSet(settingKey+
"DataColumn"))
631 const std::string gpKey(
"GNUPlot::");
632 if(inConfig.
IsSet(gpKey+
"DisplayTerm"))
634 if(inConfig.
IsSet(gpKey+
"FileTerm"))
636 if(inConfig.
IsSet(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;
658 excludedTimers = inConfig.
GetValueList(
"ExcludedTimer::Names");
664 const std::string configKey(
"DerivedTimer::");
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]);
std::vector< int > ngridproc
std::string applicationName
void const size_t * numPoints
apptools::parameters ConfigType
void SetConfigurationDefaults(ConfigType &inConfig)
void SingleRunPlotCommands(std::ostream &outStream, const std::string &dataFileName, const std::vector< struct pcrun > &pcRuns, int runIndex, const timersettings &timerSettings, bool toDisplay=false)
void SetupGnuPlot(std::ostream &outStream, const timersettings &timerSettings, const std::string &idString, bool toDisplay=false)
void const size_t const size_t const size_t const double const double double * y
std::string MakePlotTitle(const pcruninfo &pcRunInfo, const timersettings &timerSettings, int mode=0)
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)
int GetDerivedOperationForRoutine(const std::string &timerName, const std::string &routineName, const derivedtimers &derivedTimers)
pctimervalue(const pctimervalue &inVal)
bool TimerIncluded(const std::string &routineName, const timerlist &timerList)
void PopulateRunInfo(pcruninfo &pcRunInfo, std::ifstream &inFile)
std::map< std::string, timerlist > derivedtimers
void ReadTimers(pcruntimes &routineTimes, std::ifstream &inFile, int dataColumn)
apptools::comlinehandler CommandLineType
void SetupTimerSettings(timersettings &timerSettings, const ConfigType &inConfig)
void SummarizeScalabilityData(std::ostream &outStream, const std::vector< struct pcrun > &pcRuns, const timerlist &timerList, const timersettings &timerSettings)
std::map< std::string, struct pctimervalue > pcruntimes
std::list< std::string > timerlist
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)
std::string gpDisplayTerm
void SetupDerivedTimers(derivedtimers &derivedTimers, const ConfigType &inConfig)
static const char * timerNames[]
std::vector< std::string > GetDerivedTimerNames(const std::string &routineName, const derivedtimers &derivedTimers)
std::string gpCustomConfig
void SummarizeTimingData(std::ostream &outStream, const std::vector< struct pcrun > &pcRuns, const timerlist &timerList, const timersettings &timerSettings)
void SetupExcludedTimers(timerlist &excludedTimers, const ConfigType &inConfig)
std::vector< std::vector< size_t > > gridsizes
std::vector< std::string > plotTitles
pcruntimes ProcessRun(const pcruninfo &pcRunInfo, const pcruntimes &rawRunTimes, const derivedtimers &derivedTimers, const timerlist &excludedTimers, const timersettings &timerSettings, pctimervalue &timingDelta)
std::vector< size_t > ngridpoints
std::string FormatName(const std::string &inName)