#include "TFile.h" #include "TList.h" #include "TH1.h" #include "TH2.h" #include "TKey.h" #include "TDirectory.h" #include "TObjArray.h" #include "TClass.h" #include "PlotDrawer/DCanvasInstructions.h" #include "PlotDrawer/DPadInstructions.h" #include "PlotDrawer/DPlotDrawer.h" #include "PlotFitter/DPlotFitter.h" #include "PlotFitter/DFitControl.h" #include "PlotFitter/DFitFunctors_Miscellaneous.h" #include "PlotData/DStatUtilities.h" #include #include #include #include #include //INTERFACE void Draw_Jobs_OneLaunch(string locJobFileName, int locNThreadsRequirement); void Draw_LaunchComparison(string locJobFileName); void Draw_LaunchComparison_ByFile(string locJobFileName); //WORKERS void Get_LaunchStats(string locJobFileName, int locTestNumber, int locNThreads, TH2* locVMemHist, TH2* locMemHist, TH2* locWallHist, TH2* locCPUTimeHist, TH2* locEventRateHist, vector& locScalingVector, TObjArray* locScalingArray); map, vector > Import_JobData(string locJobFileName, int locNThreadsRequirement); //UTILS double* Convert_ToArray(map, vector >& locJobData, int locIndex); bool Get_IntFromFileStream(ifstream& locFileStream, int& locInt); bool Get_FloatFromFileStream(ifstream& locFileStream, float& locFloat); bool Get_StringFromFileStream(ifstream& locFileStream, string& locString); double Fit_Slope(TGraph* locGraph, int locLineWidth = 3); void Get_MinMax(TGraph* locGraph, double& locMinX, double& locMaxX); void Get_MinMax(Double_t* locArray, Int_t locN, double& locMin, double& locMax); double Find_MaxCutoff(TH1* locHist, double locIntegralCutoff); void Draw_Jobs_OneLaunch(string locJobFileName, int locNThreadsRequirement) { DPlotDrawer locPlotDrawer; TCanvas* locCanvas = NULL; DCanvasInstructions* locCanvasInstructions = new DCanvasInstructions("GraphIt"); // locCanvasInstructions->dStyle->SetMarkerSize(0.5); map, vector > locJobData = Import_JobData(locJobFileName, locNThreadsRequirement); //file, cpu, wall double* locCPUArray = Convert_ToArray(locJobData, 0); double* locWallArray = Convert_ToArray(locJobData, 1); double* locCopyArray = Convert_ToArray(locJobData, 2); double* locJANAWallArray = Convert_ToArray(locJobData, 3); double* locNonJANAArray = Convert_ToArray(locJobData, 4); double* locMiscArray = Convert_ToArray(locJobData, 5); double* locCPUJANAArray = Convert_ToArray(locJobData, 6); double* locMemoryArray = Convert_ToArray(locJobData, 7); double* locVMemoryArray = Convert_ToArray(locJobData, 8); double* locEventRateArray = Convert_ToArray(locJobData, 9); TH1I* locCPUTime = new TH1I("CPU Time", ";CPU time (hrs)", 1200, 0.0, 100.0); TH1I* locWallTimeHist = new TH1I("Wall Time", ";Wall time (hrs)", 864, 0.0, 72.0); TH1I* locCopyTime = new TH1I("Input File Copy Time", ";Copy time (mins)", 200, 0.0, 20.0); TH1I* locJANAWallTime = new TH1I("JANA Wall Time", ";JANA Wall Time (hrs)", 864, 0.0, 72.0); TH1I* locJANACPUTime = new TH1I("JANA CPU Time", ";JANA CPU Time (hrs)", 1200, 0.0, 100.0); TH1I* locNonJANAWallTime = new TH1I("Non-JANA Wall Time", ";Non-JANA Wall Time (mins)", 300, 0.0, 30.0); TH1I* locMiscWallTime = new TH1I("Misc Wall Time", ";Misc. Wall Time (non-JANA, non-input-copy) (mins)", 300, 0.0, 30.0); TH1I* locMemoryHist = new TH1I("Memory", ";Memory (MB)", 3200, 0.0, 32000.0); TH1I* locVMemoryHist = new TH1I("VMemory", ";Virtual Memory (MB)", 3200, 0.0, 32000.0); TH1I* locEventRateHist = new TH1I("EventRate", ";Event Rate (Hz)", 10000, 0.0, 1000.0); //fill hists for(size_t loc_i = 0; loc_i < locJobData.size(); ++loc_i) { locCPUTime->Fill(locCPUArray[loc_i]); locWallTimeHist->Fill(locWallArray[loc_i]); locCopyTime->Fill(locCopyArray[loc_i]); locJANAWallTime->Fill(locJANAWallArray[loc_i]); locJANACPUTime->Fill(locCPUJANAArray[loc_i]); locNonJANAWallTime->Fill(locNonJANAArray[loc_i]); locMiscWallTime->Fill(locMiscArray[loc_i]); locMemoryHist->Fill(locMemoryArray[loc_i]); locVMemoryHist->Fill(locVMemoryArray[loc_i]); locEventRateHist->Fill(locEventRateArray[loc_i]); } // locCanvas = locPlotDrawer.Draw_Object(locCPUTime); locCanvas = locPlotDrawer.Draw_Object(locWallTimeHist); // locCanvas = locPlotDrawer.Draw_Object(locCopyTime); // locCanvas = locPlotDrawer.Draw_Object(locJANAWallTime); // locCanvas = locPlotDrawer.Draw_Object(locJANACPUTime); // locCanvas = locPlotDrawer.Draw_Object(locNonJANAWallTime); // locCanvas = locPlotDrawer.Draw_Object(locMiscWallTime); locCanvas = locPlotDrawer.Draw_Object(locMemoryHist); locCanvas = locPlotDrawer.Draw_Object(locVMemoryHist); locCanvas = locPlotDrawer.Draw_Object(locEventRateHist); // TGraph* locJobGraph = new TGraph(locJobData.size(), locWallArray, locCPUArray); TGraph* locJANAGraph = new TGraph(locJobData.size(), locJANAWallArray, locCPUJANAArray); locJANAGraph->SetName("JANAGraph"); locJANAGraph->SetTitle("2016_02 ver02"); locJANAGraph->GetXaxis()->SetTitle("Wall Time (hrs)"); locJANAGraph->GetYaxis()->SetTitle("CPU Time (hrs)"); double locMaxVMem = Find_MaxCutoff(locVMemoryHist, 0.9); double locMaxWallTime = Find_MaxCutoff(locWallTimeHist, 0.9); cout << "cutoff vmem (MB), wall time (hrs) = " << locMaxVMem << ", " << locMaxWallTime << endl; //Fit JANA slope double locScaling = Fit_Slope(locJANAGraph); cout << "scaling = " << locScaling << endl; locCanvas = locPlotDrawer.Draw_Object(locJANAGraph, locCanvasInstructions); // locCanvas->Write(); } void Draw_LaunchComparison(string locJobFileName) { TH2D* locVMemHist = new TH2D("2DVMemHist", ";Num Threads;Virtual Memory (MB)", 48, 0.5, 48.5, 320, 0.0, 32000.0); TH2D* locMemHist = new TH2D("2DMemHist", ";Num Threads;Memory (MB)", 48, 0.5, 48.5, 320, 0.0, 32000.0); TH2D* locWallTimeHist = new TH2D("2DWallTimeHist", ";Num Threads;JANA Wall Time (hrs)", 48, 0.5, 48.5, 72*60, 0.0, 72.0); TH2D* locEventRateHist = new TH2D("2DEventRate", ";Num Threads;Event Rate (Hz)", 48, 0.5, 48.5, 1000, 0.0, 500.0); TH2D* locCPUTimeHist = new TH2D("2DCPUTimeHist", ";Num Threads;JANA CPU Time (hrs)", 48, 0.5, 48.5, 2000, 0.0, 200.0); TObjArray* locScalingArray = new TObjArray(); vector locNThreads; locNThreads.push_back(1); locNThreads.push_back(2); locNThreads.push_back(6); locNThreads.push_back(8); locNThreads.push_back(10); locNThreads.push_back(12); locNThreads.push_back(16); locNThreads.push_back(20); locNThreads.push_back(24); locNThreads.push_back(30); locNThreads.push_back(36); locNThreads.push_back(42); locNThreads.push_back(48); vector locScalingVector; for(size_t loc_i = 0; loc_i < locNThreads.size(); ++loc_i) Get_LaunchStats(locJobFileName, loc_i, int(locNThreads[loc_i] + 0.01), locVMemHist, locMemHist, locWallTimeHist, locCPUTimeHist, locEventRateHist, locScalingVector, locScalingArray); TGraph* locScalingGraph = new TGraph(locNThreads.size(), &(locNThreads[0]), &(locScalingVector[0])); locScalingGraph->SetName("ScalingGraph"); locScalingGraph->GetXaxis()->SetTitle("Num Threads"); locScalingGraph->GetYaxis()->SetTitle("Scaling"); //DRAW DPlotDrawer locPlotDrawer; TCanvas* locCanvas = NULL; TObjArray* locCanvasArray = NULL; DCanvasInstructions* locCanvasInstructions = new DCanvasInstructions("GraphIt"); locCanvasInstructions->dStyle->SetMarkerSize(1.0); locCanvasInstructions->dStyle->SetFuncWidth(2); locCanvas = locPlotDrawer.Draw_Object(locVMemHist); locCanvas = locPlotDrawer.Draw_Object(locMemHist); locCanvas = locPlotDrawer.Draw_Object(locWallTimeHist); locCanvas = locPlotDrawer.Draw_Object(locCPUTimeHist); locCanvas = locPlotDrawer.Draw_Object(locEventRateHist); locCanvas = locPlotDrawer.Draw_Object(locScalingGraph); locCanvasArray = locPlotDrawer.Draw_Array(locScalingArray, locCanvasInstructions); } void Draw_LaunchComparison_ByFile(string locJobFileName) { vector locNThreadsVector; locNThreadsVector.push_back(1); locNThreadsVector.push_back(2); locNThreadsVector.push_back(6); locNThreadsVector.push_back(8); locNThreadsVector.push_back(10); locNThreadsVector.push_back(12); locNThreadsVector.push_back(16); locNThreadsVector.push_back(20); locNThreadsVector.push_back(24); locNThreadsVector.push_back(30); locNThreadsVector.push_back(36); locNThreadsVector.push_back(42); locNThreadsVector.push_back(48); vector locNThreadsSans1 = locNThreadsVector; locNThreadsSans1.erase(locNThreadsSans1.begin()); //nthreads vector locScalingVector; map, vector > > locStudyData; for(size_t loc_i = 0; loc_i < locNThreadsVector.size(); ++loc_i) locStudyData[locNThreadsVector[loc_i]] = Import_JobData(locJobFileName, int(locNThreadsVector[loc_i] + 0.001)); //get event rates, etc. //key is file, vector is values, vector index goes by nthreads map, vector > locEventRateMap, locWallTimeMap, locJANAWallTimeMap, locMemMap, locVMemMap, locJANACPUTimeMap, locScalingMap; map, double> locSingleThreadRateMap; map, vector > >::const_iterator locThreadsIterator = locStudyData.begin(); size_t locExpectedSize = 0; map, vector > locNThreadsByFile; for(; locThreadsIterator != locStudyData.end(); ++locThreadsIterator) { double locNThreads = locThreadsIterator->first; const map, vector >& locNThreadsData = locThreadsIterator->second; map, vector >::const_iterator locFileIterator = locNThreadsData.begin(); for(; locFileIterator != locNThreadsData.end(); ++locFileIterator) { const pair& locFilePair = locFileIterator->first; /* //if the job failed, the data is missing: fill 0's while(locEventRateMap[locFilePair].size() < locExpectedSize) { locScalingMap[locFilePair].push_back(0.0); locEventRateMap[locFilePair].push_back(0.0); locWallTimeMap[locFilePair].push_back(0.0); locJANAWallTimeMap[locFilePair].push_back(0.0); locMemMap[locFilePair].push_back(0.0); locVMemMap[locFilePair].push_back(0.0); locJANACPUTimeMap[locFilePair].push_back(0.0); } */ locNThreadsByFile[locFilePair].push_back(locNThreads); const vector& locJobData = locFileIterator->second; if(locSingleThreadRateMap.find(locFilePair) == locSingleThreadRateMap.end()) locSingleThreadRateMap[locFilePair] = locJobData[9]/locNThreads; else locScalingMap[locFilePair].push_back(locJobData[9]/locSingleThreadRateMap[locFilePair]); locEventRateMap[locFilePair].push_back(locJobData[9]); locWallTimeMap[locFilePair].push_back(locJobData[1]); locJANAWallTimeMap[locFilePair].push_back(locJobData[3]); locMemMap[locFilePair].push_back(locJobData[7]); locVMemMap[locFilePair].push_back(locJobData[8]); locJANACPUTimeMap[locFilePair].push_back(locJobData[6]); } ++locExpectedSize; } //make tgraphs TObjArray* locGraphArray_EventRate = new TObjArray(); TObjArray* locGraphArray_WallTime = new TObjArray(); TObjArray* locGraphArray_JANAWallTime = new TObjArray(); TObjArray* locGraphArray_Mem = new TObjArray(); TObjArray* locGraphArray_VMem = new TObjArray(); TObjArray* locGraphArray_JANACPUTime = new TObjArray(); TObjArray* locGraphArray_Scaling = new TObjArray(); vector locLegend; map, vector >::iterator locFileIterator = locEventRateMap.begin(); for(; locFileIterator != locEventRateMap.end(); ++locFileIterator) { const pair& locFilePair = locFileIterator->first; string locFileName = locFilePair.first + string("_") + locFilePair.second; locLegend.push_back(locFileName); /* //if the job failed, the data is missing: fill 0's while(locEventRateMap[locFilePair].size() < locExpectedSize) { locScalingMap[locFilePair].push_back(0.0); locEventRateMap[locFilePair].push_back(0.0); locWallTimeMap[locFilePair].push_back(0.0); locJANAWallTimeMap[locFilePair].push_back(0.0); locMemMap[locFilePair].push_back(0.0); locVMemMap[locFilePair].push_back(0.0); locJANACPUTimeMap[locFilePair].push_back(0.0); } */ vector& locNThreadsThisFile = locNThreadsByFile[locFilePair]; //event rate { TGraph* locGraph = new TGraph(locNThreadsThisFile.size(), &(locNThreadsThisFile[0]), &(locEventRateMap[locFilePair][0])); locGraph->SetName((string("EventRate_") + locFileName).c_str()); locGraph->SetTitle(""); locGraph->GetXaxis()->SetTitle("# Threads"); locGraph->GetYaxis()->SetTitle("JANA Event Rate (Hz)"); locGraphArray_EventRate->AddLast(locGraph); } //wall time { TGraph* locGraph = new TGraph(locNThreadsThisFile.size(), &(locNThreadsThisFile[0]), &(locWallTimeMap[locFilePair][0])); locGraph->SetName((string("WallTime_") + locFileName).c_str()); locGraph->SetTitle(""); locGraph->GetXaxis()->SetTitle("# Threads"); locGraph->GetYaxis()->SetTitle("Wall Time (hrs)"); locGraphArray_WallTime->AddLast(locGraph); } //JANA wall time { TGraph* locGraph = new TGraph(locNThreadsThisFile.size(), &(locNThreadsThisFile[0]), &(locJANAWallTimeMap[locFilePair][0])); locGraph->SetName((string("JANAWallTime_") + locFileName).c_str()); locGraph->SetTitle(""); locGraph->GetXaxis()->SetTitle("# Threads"); locGraph->GetYaxis()->SetTitle("JANA Wall Time (hrs)"); locGraphArray_JANAWallTime->AddLast(locGraph); } //JANA CPU time { TGraph* locGraph = new TGraph(locNThreadsThisFile.size(), &(locNThreadsThisFile[0]), &(locJANACPUTimeMap[locFilePair][0])); locGraph->SetName((string("JANACPUTime_") + locFileName).c_str()); locGraph->SetTitle(""); locGraph->GetXaxis()->SetTitle("# Threads"); locGraph->GetYaxis()->SetTitle("JANA CPU Time (hrs)"); locGraphArray_JANACPUTime->AddLast(locGraph); } //Memory { TGraph* locGraph = new TGraph(locNThreadsThisFile.size(), &(locNThreadsThisFile[0]), &(locMemMap[locFilePair][0])); locGraph->SetName((string("Memory_") + locFileName).c_str()); locGraph->SetTitle(""); locGraph->GetXaxis()->SetTitle("# Threads"); locGraph->GetYaxis()->SetTitle("Memory (MBs)"); locGraphArray_Mem->AddLast(locGraph); } //Memory { TGraph* locGraph = new TGraph(locNThreadsThisFile.size(), &(locNThreadsThisFile[0]), &(locVMemMap[locFilePair][0])); locGraph->SetName((string("VirtualMemory_") + locFileName).c_str()); locGraph->SetTitle(""); locGraph->GetXaxis()->SetTitle("# Threads"); locGraph->GetYaxis()->SetTitle("Virtual Memory (MBs)"); locGraphArray_VMem->AddLast(locGraph); } //Scaling { TGraph* locGraph = new TGraph(locNThreadsThisFile.size() - 1, &(locNThreadsThisFile[1]), &(locScalingMap[locFilePair][0])); locGraph->SetName((string("Scaling_") + locFileName).c_str()); locGraph->SetTitle(""); locGraph->GetXaxis()->SetTitle("# Threads"); locGraph->GetYaxis()->SetTitle("Event Rate Scaling"); locGraphArray_Scaling->AddLast(locGraph); } } //calculate average scaling, memory, vmem vector locAverageScaling, locSigmaScaling, locAverageMemory, locSigmaMemory, locAverageVMemory, locSigmaVMemory; vector locNThreads_Memory, locNThreads_Scaling; for(size_t loc_i = 0; loc_i < locNThreadsVector.size(); ++loc_i) { vector locDataPoints_Scaling, locDataPoints_Memory, locDataPoints_VMemory; for(locFileIterator = locEventRateMap.begin(); locFileIterator != locEventRateMap.end(); ++locFileIterator) { const pair& locFilePair = locFileIterator->first; vector& locNThreadsThisFile = locNThreadsByFile[locFilePair]; //find the index for this nthreads int locIndex = -1; for(size_t loc_j = 0; loc_j < locNThreadsThisFile.size(); ++loc_j) { if(fabs(locNThreadsThisFile[loc_j] - locNThreadsVector[loc_i]) > 0.5) continue; locIndex = loc_j; break; } if(locIndex == -1) continue; //not present locMemMap[locFilePair][locIndex]; if(locIndex != 0) locDataPoints_Scaling.push_back(locScalingMap[locFilePair][locIndex - 1]); locDataPoints_Memory.push_back(locMemMap[locFilePair][locIndex]); locDataPoints_VMemory.push_back(locVMemMap[locFilePair][locIndex]); } if(locDataPoints_Memory.empty()) continue; locNThreads_Memory.push_back(locNThreadsVector[loc_i]); if(!locDataPoints_Scaling.empty()) { locNThreads_Scaling.push_back(locNThreadsVector[loc_i]); locAverageScaling.push_back(DStatUtilities::Calc_Average(locDataPoints_Scaling)); locSigmaScaling.push_back(DStatUtilities::Calc_SampleSigma(locDataPoints_Scaling)); } locAverageMemory.push_back(DStatUtilities::Calc_Average(locDataPoints_Memory)); locSigmaMemory.push_back(DStatUtilities::Calc_SampleSigma(locDataPoints_Memory)); locAverageVMemory.push_back(DStatUtilities::Calc_Average(locDataPoints_VMemory)); locSigmaVMemory.push_back(DStatUtilities::Calc_SampleSigma(locDataPoints_VMemory)); } //MAKE AVERAGE TGRAPHERRORS //Average Scaling TGraphErrors* locAvgScalingGraph = new TGraphErrors(locNThreads_Scaling.size(), &(locNThreads_Scaling[0]), &(locAverageScaling[0]), NULL, &(locSigmaScaling[0])); locAvgScalingGraph->SetName("AvgScaling"); locAvgScalingGraph->SetTitle(""); locAvgScalingGraph->GetXaxis()->SetTitle("# Threads"); locAvgScalingGraph->GetYaxis()->SetTitle("Average Event-Rate Scaling"); //Average Memory TGraphErrors* locAvgMemoryGraph = new TGraphErrors(locNThreads_Memory.size(), &(locNThreads_Memory[0]), &(locAverageMemory[0]), NULL, &(locSigmaMemory[0])); locAvgMemoryGraph->SetName("AvgMemory"); locAvgMemoryGraph->GetXaxis()->SetTitle("# Threads"); locAvgMemoryGraph->GetYaxis()->SetTitle("Average Memory (MBs)"); { double locSlope = Fit_Slope(locAvgMemoryGraph); ostringstream locGraphTitle; locGraphTitle << "Memory Scaling: " << locSlope << " MBs / Thread"; locAvgMemoryGraph->SetTitle(locGraphTitle.str().c_str()); } //Average VMemory TGraphErrors* locAvgVMemoryGraph = new TGraphErrors(locNThreads_Memory.size(), &(locNThreads_Memory[0]), &(locAverageVMemory[0]), NULL, &(locSigmaVMemory[0])); locAvgVMemoryGraph->SetName("AvgVMemory"); locAvgVMemoryGraph->SetTitle(""); locAvgVMemoryGraph->GetXaxis()->SetTitle("# Threads"); locAvgVMemoryGraph->GetYaxis()->SetTitle("Average Virtual Memory (MBs)"); { double locSlope = Fit_Slope(locAvgVMemoryGraph); ostringstream locGraphTitle; locGraphTitle << "Virtual Memory Scaling: " << locSlope << " MBs / Thread"; locAvgVMemoryGraph->SetTitle(locGraphTitle.str().c_str()); } //DRAW: SETUP DPlotDrawer locPlotDrawer; TCanvas* locCanvas = NULL; TObjArray* locCanvasArray = NULL; DCanvasInstructions* locCanvasInstructions = new DCanvasInstructions("GraphIt"); locCanvasInstructions->dStyle->SetMarkerSize(1.0); locCanvasInstructions->dStyle->SetFuncWidth(2); locCanvasInstructions->Get_PadInstructions(0)->dLegendNames = locLegend; locCanvasInstructions->Get_PadInstructions(0)->dDrawOptions.push_back("apl"); locCanvasInstructions->dStyle->SetPalette(55); //rainbow //DRAW: ACTUAL locCanvas = locPlotDrawer.Draw_Superimpose(locGraphArray_EventRate, locCanvasInstructions); locCanvas = locPlotDrawer.Draw_Superimpose(locGraphArray_WallTime, locCanvasInstructions); locCanvas = locPlotDrawer.Draw_Superimpose(locGraphArray_JANAWallTime, locCanvasInstructions); locCanvas = locPlotDrawer.Draw_Superimpose(locGraphArray_Mem, locCanvasInstructions); locCanvas = locPlotDrawer.Draw_Superimpose(locGraphArray_VMem, locCanvasInstructions); locCanvas = locPlotDrawer.Draw_Superimpose(locGraphArray_JANACPUTime, locCanvasInstructions); locCanvas = locPlotDrawer.Draw_Superimpose(locGraphArray_Scaling, locCanvasInstructions); locCanvas = locPlotDrawer.Draw_Object(locAvgScalingGraph); locCanvas = locPlotDrawer.Draw_Object(locAvgMemoryGraph); locCanvas = locPlotDrawer.Draw_Object(locAvgVMemoryGraph); } void Get_LaunchStats(string locJobFileName, int locTestNumber, int locNThreads, TH2* locVMemHist, TH2* locMemHist, TH2* locWallHist, TH2* locCPUTimeHist, TH2* locEventRateHist, vector& locScalingVector, TObjArray* locScalingArray) { map, vector > locJobData = Import_JobData(locJobFileName, locNThreads); double* locWallArray = Convert_ToArray(locJobData, 1); double* locJANAWallArray = Convert_ToArray(locJobData, 3); double* locCPUJANAArray = Convert_ToArray(locJobData, 6); double* locMemoryArray = Convert_ToArray(locJobData, 7); double* locVMemoryArray = Convert_ToArray(locJobData, 8); double* locEventRateArray = Convert_ToArray(locJobData, 9); //fill hists for(size_t loc_i = 0; loc_i < locJobData.size(); ++loc_i) { locVMemHist->Fill(locNThreads, locVMemoryArray[loc_i]); locMemHist->Fill(locNThreads, locMemoryArray[loc_i]); locWallHist->Fill(locNThreads, locWallArray[loc_i]); locCPUTimeHist->Fill(locNThreads, locCPUJANAArray[loc_i]); locEventRateHist->Fill(locNThreads, locEventRateArray[loc_i]); } TGraph* loc2DTimeGraph = new TGraph(locJobData.size(), locJANAWallArray, locCPUJANAArray); ostringstream locGraphName; locGraphName << "Scaling_" << locNThreads; loc2DTimeGraph->SetName(locGraphName.str().c_str()); loc2DTimeGraph->GetXaxis()->SetTitle("JANA Wall Time (hrs)"); loc2DTimeGraph->GetYaxis()->SetTitle("JANA CPU Time (hrs)"); double locMaxVMem = Find_MaxCutoff(locVMemHist, 0.9); double locMaxWallTime = Find_MaxCutoff(locWallHist, 0.9); // cout << "cutoff vmem (MB), wall time (hrs) = " << locMaxVMem << ", " << locMaxWallTime << endl; //Fit JANA slope double locScaling = Fit_Slope(loc2DTimeGraph, 2); ostringstream locGraphTitle; locGraphTitle << locNThreads << " Threads, Scaling: " << locScaling; loc2DTimeGraph->SetTitle(locGraphTitle.str().c_str()); // cout << "scaling = " << locScaling << endl; locScalingVector.push_back(locScaling); locScalingArray->AddLast(loc2DTimeGraph); } double Find_MaxCutoff(TH1* locHist, double locCutoffFraction) { //locIntegralCutoff = 0.9 (e.g.) double locIntegral = locHist->GetEntries(); double locIntegralCutoff = locCutoffFraction*locIntegral; for(int loc_i = locHist->GetNbinsX(); loc_i >= 1; --loc_i) { locIntegral -= locHist->GetBinContent(loc_i); if(locIntegral < locIntegralCutoff) return locHist->GetXaxis()->GetBinUpEdge(loc_i); } return -1.0; } double Fit_Slope(TGraph* locGraph, int locLineWidth) { DPlotFitter locPlotFitter; // locPlotFitter.dQuietFitFlag = false; vector locInitParams(2, 0); double locFitRangeMin = 0.0, locFitRangeMax = 0.0; Get_MinMax(locGraph, locFitRangeMin, locFitRangeMax); locFitRangeMin -= 0.01*locFitRangeMin; locFitRangeMax += 0.01*locFitRangeMax; DFitFunctor_Polynomial* locPolynomial = new DFitFunctor_Polynomial(locInitParams, kRed); DFitControl* locFitControl = new DFitControl(locFitRangeMin, locFitRangeMax, locPolynomial); int locFitStatus = locPlotFitter.Fit_Graph(locGraph, locFitControl); if(locFitStatus != 0) return -1.0; locPolynomial->dFunc->SetLineWidth(locLineWidth); return locPolynomial->dFunc->GetParameter(1); } void Get_MinMax(TGraph* locGraph, double& locMinX, double& locMaxX) { Get_MinMax(locGraph->GetX(), locGraph->GetN(), locMinX, locMaxX); } void Get_MinMax(Double_t* locArray, Int_t locN, double& locMin, double& locMax) { locMin = 9.99E99; locMax = -9.99E99; for(Int_t loc_i = 0; loc_i < locN; ++loc_i) { if(locArray[loc_i] < locMin) locMin = locArray[loc_i]; if(locArray[loc_i] > locMax) locMax = locArray[loc_i]; } } map, vector > Import_JobData(string locJobFileName, int locNThreadsRequirement) { string locInput; int locCPUTime, locWallTime, locCopyTime, locJANAWallTime, locNThreads, locMemory, locVMemory; string locFileNumber, locRunNumber; float locEventRate; map, vector > locJobData; ifstream locJobStream(locJobFileName.c_str()); if(!locJobStream.is_open()) cout << "uh oh" << endl; //INPUT times in seconds! while(true) { //run, file, nthreads if(!Get_StringFromFileStream(locJobStream, locRunNumber)) break; Get_StringFromFileStream(locJobStream, locFileNumber); Get_IntFromFileStream(locJobStream, locNThreads); //cpu, wall times Get_IntFromFileStream(locJobStream, locCPUTime); Get_IntFromFileStream(locJobStream, locWallTime); //mem, vmem Get_IntFromFileStream(locJobStream, locMemory); Get_IntFromFileStream(locJobStream, locVMemory); //copy, jana wall times Get_IntFromFileStream(locJobStream, locCopyTime); Get_IntFromFileStream(locJobStream, locJANAWallTime); //event rate Get_FloatFromFileStream(locJobStream, locEventRate); if(locNThreads == locNThreadsRequirement) { pair locFilePair(locRunNumber, locFileNumber); int locNonJANATime = locWallTime - locJANAWallTime; int locMiscTime = locNonJANATime - locCopyTime; int locCPUJANA = locCPUTime - locNonJANATime; vector locJobValues(10, 0); locJobValues[0] = double(locCPUTime)/3600.0; locJobValues[1] = double(locWallTime)/3600.0; //hours locJobValues[2] = double(locCopyTime)/60.0; locJobValues[3] = double(locJANAWallTime)/3600.0; //mins, hours locJobValues[4] = double(locNonJANATime)/60.0; locJobValues[5] = double(locMiscTime)/60.0; //minutes locJobValues[6] = double(locCPUJANA)/3600.0; locJobValues[7] = double(locMemory)/1024.0; locJobValues[8] = double(locVMemory)/1024.0; //MBs locJobValues[9] = locEventRate; locJobData[locFilePair] = locJobValues; } } locJobStream.close(); return locJobData; } bool Get_IntFromFileStream(ifstream& locFileStream, int& locInt) { string locInput; locFileStream >> locInput; if(locFileStream.eof()) return false; istringstream locIStream; locIStream.str(locInput.c_str()); (locIStream >> locInt); return true; } bool Get_StringFromFileStream(ifstream& locFileStream, string& locString) { locFileStream >> locString; return (!locFileStream.eof()); } bool Get_FloatFromFileStream(ifstream& locFileStream, float& locFloat) { string locInput; locFileStream >> locInput; if(locFileStream.eof()) return false; istringstream locIStream; locIStream.str(locInput.c_str()); (locIStream >> locFloat); return true; } double* Convert_ToArray(map, vector >& locJobData, int locIndex) { double* locArray = new double[locJobData.size()]; map, vector >::iterator locIterator = locJobData.begin(); int locArrayIndex = 0; for(; locIterator != locJobData.end(); ++locIterator) { locArray[locArrayIndex] = (locIterator->second)[locIndex]; ++locArrayIndex; } return locArray; }