removed debug information. Added CPU/GPU information to the MINUIT2.OUTPUT file.
This commit is contained in:
parent
6fa7bb5764
commit
2a041d4878
@ -31,6 +31,11 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
#ifdef HAVE_GOMP
|
||||
#include <omp.h>
|
||||
#endif
|
||||
@ -42,10 +47,10 @@
|
||||
#include <limits>
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "Minuit2/FunctionMinimum.h"
|
||||
#include "Minuit2/MnContours.h"
|
||||
#include "Minuit2/MnHesse.h"
|
||||
@ -121,11 +126,11 @@ PFitter::PFitter(PMsrHandler *runInfo, PRunListCollection *runListCollection, Bo
|
||||
}
|
||||
|
||||
// get the DKS tag from the commands block
|
||||
UInt_t dksTag = fRunInfo->GetDKSTag();
|
||||
fDKSTag = fRunInfo->GetDKSTag();
|
||||
|
||||
// check if the theory function can already run on the GPU
|
||||
string theo = fRunInfo->GetDKSTheoryString();
|
||||
if (dksTag != DKS_CPU_OPENMP) {
|
||||
if (fDKSTag != DKS_CPU_OPENMP) {
|
||||
if (!theo.compare("??")) { // theory not yet DKS ready
|
||||
cout << endl << ">> PFitter::PFitter(): **INFO** theory not yet DKS/GPU ready. Will run on the CPU." << endl;
|
||||
} else {
|
||||
@ -135,8 +140,8 @@ PFitter::PFitter(PMsrHandler *runInfo, PRunListCollection *runListCollection, Bo
|
||||
}
|
||||
|
||||
// create fit function object depending whether DKS/GPU can be used or not
|
||||
if (fDKSReady && (dksTag != DKS_CPU_OPENMP)) { // run on the GPU
|
||||
fFitterFcnDKS = new PFitterFcnDKS(runListCollection, fUseChi2, dksTag, theo);
|
||||
if (fDKSReady && (fDKSTag != DKS_CPU_OPENMP)) { // run on the GPU
|
||||
fFitterFcnDKS = new PFitterFcnDKS(runListCollection, fUseChi2, fDKSTag, theo);
|
||||
if (!fFitterFcnDKS) {
|
||||
fIsValid = false;
|
||||
}
|
||||
@ -1751,6 +1756,31 @@ Bool_t PFitter::ExecuteSave(Bool_t firstSave)
|
||||
fout << endl << "*************************************************************************";
|
||||
fout << endl;
|
||||
|
||||
// write CPU/GPU info
|
||||
switch (fDKSTag) {
|
||||
case DKS_CPU_OPENMP:
|
||||
fout << endl << " CPU info : " << GetCpuInfo().Data();
|
||||
fout << endl << " OpenMP" << endl;
|
||||
break;
|
||||
case DKS_CPU_OPENCL:
|
||||
fout << endl << " CPU info : " << GetCpuInfo().Data();
|
||||
fout << endl << " OpenCL" << endl;
|
||||
break;
|
||||
case DKS_GPU_CUDA:
|
||||
fout << endl << " GPU info : " << GetGpuInfo().Data();
|
||||
fout << endl << " Cuda" << endl;
|
||||
break;
|
||||
case DKS_GPU_OPENCL:
|
||||
fout << endl << " GPU info : " << GetGpuInfo().Data();
|
||||
fout << endl << " OpenCL" << endl;
|
||||
break;
|
||||
default:
|
||||
fout << endl << " CPU/GPU info : unkown" << endl;
|
||||
break;
|
||||
}
|
||||
fout << endl << "*************************************************************************";
|
||||
fout << endl;
|
||||
|
||||
// write elapsed times
|
||||
fout << endl << " elapsed times:";
|
||||
for (UInt_t i=0; i<fElapsedTime.size(); i++) {
|
||||
@ -2078,7 +2108,7 @@ Bool_t PFitter::ExecuteSimplex()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// MilliTime
|
||||
// MilliTime (private)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>
|
||||
@ -2093,6 +2123,89 @@ Double_t PFitter::MilliTime()
|
||||
return ((Double_t)now.tv_sec * 1.0e6 + (Double_t)now.tv_usec)/1.0e3;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// GetCpuInfo (private)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief PFitter::GetCpuInfo
|
||||
* @return
|
||||
*/
|
||||
TString PFitter::GetCpuInfo()
|
||||
{
|
||||
TString cpuInfo = "??";
|
||||
|
||||
// find out if linux or Mac OS X
|
||||
struct utsname sys_info;
|
||||
|
||||
uname(&sys_info);
|
||||
|
||||
if (strstr(sys_info.sysname, "Linux")) {
|
||||
char result[128];
|
||||
strcpy(result, "??");
|
||||
|
||||
char line[128], str[128], *pos;
|
||||
bool done = false;
|
||||
ifstream fin("/proc/cpuinfo", ifstream::in);
|
||||
while (fin.good() && !done) {
|
||||
fin.getline(line, 128);
|
||||
if (strstr(line, "model name")) {
|
||||
pos = strstr(line, ":");
|
||||
strcpy(str, pos+2);
|
||||
strncpy(result, str, sizeof(result));
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
fin.close();
|
||||
cpuInfo = result;
|
||||
} else if (strstr(sys_info.sysname, "Linux")) {
|
||||
system("sysctl -n machdep.cpu.brand_string >> _musrfit_cpu_info.txt");
|
||||
sleep(1000);
|
||||
|
||||
char line[128], result[128];
|
||||
ifstream fin("_musrfit_cpu_info.txt", ifstream::in);
|
||||
while (fin.good()) {
|
||||
fin.getline(line, 128);
|
||||
strncat(result, line, sizeof(result) - strlen(result) - 1);
|
||||
}
|
||||
fin.close();
|
||||
system("rm _musrfit_cpu_info.txt");
|
||||
cpuInfo = result;
|
||||
}
|
||||
|
||||
return cpuInfo;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// GetGpuInfo (private)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief PFitter::GetGpuInfo
|
||||
* @return
|
||||
*/
|
||||
TString PFitter::GetGpuInfo()
|
||||
{
|
||||
TString gpuInfo = "??";
|
||||
|
||||
system("nvidia-smi -L > _nv.txt");
|
||||
sleep(1000);
|
||||
|
||||
bool done=false;
|
||||
char line[128];
|
||||
ifstream fin("_nv.txt", ifstream::in);
|
||||
while (fin.good() && !done) {
|
||||
fin.getline(line, 128);
|
||||
if (strstr(line, "Tesla")) {
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
fin.close();
|
||||
gpuInfo = line;
|
||||
|
||||
system("rm _nv.txt");
|
||||
|
||||
return gpuInfo;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// end
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
|
@ -198,7 +198,6 @@ void PFitterFcnDKS::InitDKS(const UInt_t dksTag)
|
||||
fValid = false;
|
||||
return;
|
||||
}
|
||||
cout << "debug> minSize = " << minSize << endl;
|
||||
|
||||
// 2) get number of parameters / functions / maps
|
||||
parSize = fRunListCollection->GetNoOfParameters();
|
||||
@ -219,7 +218,6 @@ void PFitterFcnDKS::InitDKS(const UInt_t dksTag)
|
||||
fValid = false;
|
||||
return;
|
||||
}
|
||||
cout << "debug> parSize=" << parSize << ", funSize=" << funSize << ", mapSize=" << mapSize << endl;
|
||||
|
||||
// now ready to init the chisq buffer on the GPU
|
||||
ierr = fDKS.initChiSquare(minSize, parSize, funSize, mapSize);
|
||||
@ -251,8 +249,6 @@ void PFitterFcnDKS::InitDKS(const UInt_t dksTag)
|
||||
fValid = false;
|
||||
return;
|
||||
}
|
||||
cout << "debug> InitDKS: startTimeBin = " << startTimeBin << endl;
|
||||
cout << "debug> InitDKS: runData->GetValue()->size() - startTimeBin = " << runData->GetValue()->size() - startTimeBin << endl;
|
||||
fDKS.writeData<double>(fMemData[i], &runData->GetValue()->at(startTimeBin), minSize);
|
||||
}
|
||||
|
||||
|
@ -5675,7 +5675,6 @@ Bool_t PMsrHandler::CheckMaps()
|
||||
if (fNoOfMaps == 0)
|
||||
fNoOfMaps = -1;
|
||||
}
|
||||
cout << "debug> fNoOfMaps=" << fNoOfMaps << endl;
|
||||
|
||||
// clean up
|
||||
mapVec.clear();
|
||||
|
@ -1129,14 +1129,12 @@ Int_t PRunListCollection::GetSingleHistoParams(UInt_t idx, const std::vector<Dou
|
||||
// evaluate function
|
||||
shp.fN0 = fMsrInfo->EvalFunc(funNo, *runInfo.GetMap(), par);
|
||||
}
|
||||
// cout << "debug> shp.fN0 = " << shp.fN0 << endl;
|
||||
|
||||
// get tau
|
||||
if (runInfo.GetLifetimeParamNo() != -1)
|
||||
shp.fTau = par[runInfo.GetLifetimeParamNo()-1];
|
||||
else
|
||||
shp.fTau = PMUON_LIFETIME;
|
||||
// cout << "debug> shp.fTau = " << shp.fTau << endl;
|
||||
|
||||
// get background
|
||||
if (runInfo.GetBkgFitParamNo() == -1) { // bkg not fitted
|
||||
@ -1148,35 +1146,24 @@ Int_t PRunListCollection::GetSingleHistoParams(UInt_t idx, const std::vector<Dou
|
||||
} else { // bkg fitted
|
||||
shp.fNbkg = par[runInfo.GetBkgFitParamNo()-1];
|
||||
}
|
||||
// cout << "debug> shp.fNbkg = " << shp.fNbkg << endl;
|
||||
|
||||
// get packed time resolution
|
||||
shp.fPackedTimeResolution = fRunSingleHistoList[idx]->GetData()->GetDataTimeStep();
|
||||
|
||||
// cout << "debug> fPackedTimeResolution = " << shp.fPackedTimeResolution*1.0e3 << " (ns)" << endl;
|
||||
|
||||
// get start time
|
||||
// fRunSingleHistoList[idx]->GetData()->GetDataTimeStart() : time of fgb, which is 0-bin of the fit-data-set
|
||||
// fRunSingleHistoList[idx]->GetStartTimeBin() * shp.fPackedTimeResolution : time-offset from fgb-time to fit start time
|
||||
shp.fStartTime = fRunSingleHistoList[idx]->GetData()->GetDataTimeStart() + fRunSingleHistoList[idx]->GetStartTimeBin() * shp.fPackedTimeResolution;
|
||||
|
||||
// cout << "debug> startTime = " << shp.fStartTime << " (us)" << endl;
|
||||
|
||||
// get number of bins fitted
|
||||
shp.fNoOfFitBins = fRunSingleHistoList[idx]->GetNoOfFitBins();
|
||||
|
||||
// cout << "debug> startTimeBin = " << fRunSingleHistoList[idx]->GetStartTimeBin() << ", endTimeBin = " << fRunSingleHistoList[idx]->GetEndTimeBin() << ", noOfFittedBins = " << shp.fNoOfFitBins << endl;
|
||||
|
||||
// calculate functions
|
||||
Int_t funcNo = 0;
|
||||
for (Int_t i=0; i<fMsrInfo->GetNoOfFuncs(); i++) {
|
||||
funcNo = fMsrInfo->GetFuncNo(i);
|
||||
shp.fFun.push_back(fMsrInfo->EvalFunc(funcNo, *runInfo.GetMap(), par));
|
||||
}
|
||||
/*
|
||||
for (UInt_t i=0; i<shp.fFun.size(); i++)
|
||||
cout << "debug> fun" << i+1 << " = " << shp.fFun[i] << endl;
|
||||
*/
|
||||
|
||||
// get map vector
|
||||
shp.fMap = *runInfo.GetMap();
|
||||
@ -1184,10 +1171,6 @@ Int_t PRunListCollection::GetSingleHistoParams(UInt_t idx, const std::vector<Dou
|
||||
// need to reduce map indexes by 1 since in C/C++ arrays start at 0
|
||||
for (UInt_t i=0; i<shp.fMap.size(); i++)
|
||||
shp.fMap[i] -= 1;
|
||||
/*
|
||||
for (UInt_t i=0; i<shp.fMap.size(); i++)
|
||||
cout << "debug> map" << i+1 << " = " << shp.fMap[i] << endl;
|
||||
*/
|
||||
|
||||
return ierr;
|
||||
}
|
||||
|
@ -364,15 +364,6 @@ Double_t PRunSingleHisto::CalcMaxLikelihood(const std::vector<Double_t>& par)
|
||||
// For all other functions it means a tiny and acceptable overhead.
|
||||
time = fTheory->Func(time, par, fFuncValues);
|
||||
|
||||
/*
|
||||
cout << "debug> normalizer=" << normalizer << endl;
|
||||
for (i=fStartTimeBin; i<fStartTimeBin+20; i++) {
|
||||
time = fData.GetDataTimeStart() + (Double_t)i*fData.GetDataTimeStep();
|
||||
theo = N0*TMath::Exp(-time/tau)*(1.0+fTheory->Func(time, par, fFuncValues))+bkg;
|
||||
cout << "debug> " << i << ": time=" << time << ", data=" << fData.GetValue()->at(i) << ", theo=" << theo << endl;
|
||||
}
|
||||
*/
|
||||
|
||||
#ifdef HAVE_GOMP
|
||||
Int_t chunk = (fEndTimeBin - fStartTimeBin)/omp_get_num_procs();
|
||||
if (chunk < 10)
|
||||
@ -397,13 +388,6 @@ for (i=fStartTimeBin; i<fStartTimeBin+20; i++) {
|
||||
} else {
|
||||
mllh += (theo-data);
|
||||
}
|
||||
|
||||
if (i<20) {
|
||||
if (data > 1.0e-9)
|
||||
cout << "CPU> " << i << ": time=" << time << ", data=" << data << ", theo=" << theo << ", mlh=" << 2.0*((theo-data) + data*log(data/theo)) << endl;
|
||||
else
|
||||
cout << "CPU> " << i << ": time=" << time << ", mlh=" << 2.0*(theo-data) << endl;
|
||||
}
|
||||
}
|
||||
|
||||
return 2.0*mllh;
|
||||
@ -1278,8 +1262,6 @@ Bool_t PRunSingleHisto::PrepareViewData(PRawRunData* runData, const UInt_t histo
|
||||
// clean up
|
||||
par.clear();
|
||||
|
||||
//cout << "debug> fStartTimeBin = " << fStartTimeBin << ", fEndTimeBin = " << fEndTimeBin << endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,8 @@
|
||||
#ifndef _PFITTER_H_
|
||||
#define _PFITTER_H_
|
||||
|
||||
#include "TString.h"
|
||||
|
||||
#include "Minuit2/MnUserParameters.h"
|
||||
#include "Minuit2/FunctionMinimum.h"
|
||||
|
||||
@ -76,6 +78,7 @@ class PFitter
|
||||
|
||||
private:
|
||||
Bool_t fDKSReady; ///< flag. true: fit via DKS/GPU. false: fit on CPU
|
||||
Int_t fDKSTag; ///< tag. holding more detailed information about the DKS/CPU/GPU request
|
||||
Bool_t fIsValid; ///< flag. true: the fit is valid.
|
||||
Bool_t fIsScanOnly; ///< flag. true: scan along some parameters (no fitting).
|
||||
Bool_t fConverged; ///< flag. true: the fit has converged.
|
||||
@ -131,6 +134,8 @@ class PFitter
|
||||
Bool_t ExecuteSimplex();
|
||||
|
||||
Double_t MilliTime();
|
||||
TString GetCpuInfo();
|
||||
TString GetGpuInfo();
|
||||
};
|
||||
|
||||
#endif // _PFITTER_H_
|
||||
|
Loading…
x
Reference in New Issue
Block a user