moved hardware info to the place where it is needed.
This commit is contained in:
parent
58148581ba
commit
122db33efc
@ -32,6 +32,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
#include <sys/utsname.h>
|
||||||
|
|
||||||
#ifdef HAVE_GOMP
|
#ifdef HAVE_GOMP
|
||||||
#include <omp.h>
|
#include <omp.h>
|
||||||
@ -80,10 +81,9 @@ using namespace std;
|
|||||||
* \param runInfo pointer of the msr-file handler
|
* \param runInfo pointer of the msr-file handler
|
||||||
* \param runListCollection pointer of the run list collection (pre-processed historgrams)
|
* \param runListCollection pointer of the run list collection (pre-processed historgrams)
|
||||||
* \param chisq_only flag: true=calculate chisq only (no fitting)
|
* \param chisq_only flag: true=calculate chisq only (no fitting)
|
||||||
* \param hardwareInfo string containing CPU/GPU information
|
|
||||||
*/
|
*/
|
||||||
PFitter::PFitter(PMsrHandler *runInfo, PRunListCollection *runListCollection, Bool_t chisq_only, TString hardwareInfo) :
|
PFitter::PFitter(PMsrHandler *runInfo, PRunListCollection *runListCollection, Bool_t chisq_only) :
|
||||||
fChisqOnly(chisq_only), fHardwareInfo(hardwareInfo), fRunInfo(runInfo), fRunListCollection(runListCollection)
|
fChisqOnly(chisq_only), fRunInfo(runInfo), fRunListCollection(runListCollection)
|
||||||
{
|
{
|
||||||
// initialize variables
|
// initialize variables
|
||||||
fDKSReady = false;
|
fDKSReady = false;
|
||||||
@ -1756,22 +1756,34 @@ Bool_t PFitter::ExecuteSave(Bool_t firstSave)
|
|||||||
fout << endl << "*************************************************************************";
|
fout << endl << "*************************************************************************";
|
||||||
fout << endl;
|
fout << endl;
|
||||||
|
|
||||||
// write CPU/GPU info
|
// write CPU/GPU info
|
||||||
|
string hwInfo("??");
|
||||||
|
int status=0;
|
||||||
switch (fDKSTag) {
|
switch (fDKSTag) {
|
||||||
case DKS_CPU_OPENMP:
|
case DKS_CPU_OPENMP:
|
||||||
fout << endl << " CPU info : " << fHardwareInfo;
|
fout << endl << " CPU info : " << GetCPUInfo();
|
||||||
fout << endl << " OpenMP" << endl;
|
#ifdef HAVE_GOMP
|
||||||
|
fout << endl << " OpenMP" << endl;
|
||||||
|
#else
|
||||||
|
fout << endl << " CPU, i.e. single threaded" << endl;
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
case DKS_CPU_OPENCL:
|
case DKS_CPU_OPENCL:
|
||||||
fout << endl << " CPU info : " << fHardwareInfo;
|
if (fFitterFcnDKS)
|
||||||
|
status = fFitterFcnDKS->GetDeviceName(hwInfo);
|
||||||
|
fout << endl << " CPU info : " << hwInfo;
|
||||||
fout << endl << " OpenCL" << endl;
|
fout << endl << " OpenCL" << endl;
|
||||||
break;
|
break;
|
||||||
case DKS_GPU_CUDA:
|
case DKS_GPU_CUDA:
|
||||||
fout << endl << " GPU info : " << fHardwareInfo;
|
if (fFitterFcnDKS)
|
||||||
|
status = fFitterFcnDKS->GetDeviceName(hwInfo);
|
||||||
|
fout << endl << " GPU info : " << hwInfo;
|
||||||
fout << endl << " Cuda" << endl;
|
fout << endl << " Cuda" << endl;
|
||||||
break;
|
break;
|
||||||
case DKS_GPU_OPENCL:
|
case DKS_GPU_OPENCL:
|
||||||
fout << endl << " GPU info : " << fHardwareInfo;
|
if (fFitterFcnDKS)
|
||||||
|
status = fFitterFcnDKS->GetDeviceName(hwInfo);
|
||||||
|
fout << endl << " GPU info : " << hwInfo;
|
||||||
fout << endl << " OpenCL" << endl;
|
fout << endl << " OpenCL" << endl;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -2123,6 +2135,59 @@ Double_t PFitter::MilliTime()
|
|||||||
return ((Double_t)now.tv_sec * 1.0e6 + (Double_t)now.tv_usec)/1.0e3;
|
return ((Double_t)now.tv_sec * 1.0e6 + (Double_t)now.tv_usec)/1.0e3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------
|
||||||
|
// GetCPUInfo (private)
|
||||||
|
//--------------------------------------------------------------------------
|
||||||
|
/**
|
||||||
|
* <p> extract CPU information from the system.
|
||||||
|
*
|
||||||
|
* @return the CPU information or ?? if this was not possible.
|
||||||
|
*/
|
||||||
|
string PFitter::GetCPUInfo()
|
||||||
|
{
|
||||||
|
string 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, "Darwin")) {
|
||||||
|
system("sysctl -n machdep.cpu.brand_string >> /tmp/_musrfit_cpu_info.txt");
|
||||||
|
sleep(1);
|
||||||
|
|
||||||
|
char line[128], result[128];
|
||||||
|
ifstream fin("/tmp/_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 /tmp/_musrfit_cpu_info.txt");
|
||||||
|
cpuInfo = result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return cpuInfo;
|
||||||
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------
|
||||||
// end
|
// end
|
||||||
//-------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------
|
||||||
|
@ -219,6 +219,29 @@ void PFitterFcnDKS::CalcExpectedChiSquare(const std::vector<Double_t> &par, Doub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------
|
||||||
|
// GetDeviceName (public)
|
||||||
|
//--------------------------------------------------------------------------
|
||||||
|
/**
|
||||||
|
* <p> get from DKS the device name used.
|
||||||
|
*
|
||||||
|
* \param devName deivce name, if status == 0
|
||||||
|
*
|
||||||
|
* \return 0 if OK, 1 otherwise
|
||||||
|
*/
|
||||||
|
int PFitterFcnDKS::GetDeviceName(string &devName)
|
||||||
|
{
|
||||||
|
int status = 1;
|
||||||
|
|
||||||
|
devName = "??";
|
||||||
|
if (!fValid)
|
||||||
|
return status;
|
||||||
|
|
||||||
|
status = fDKS.getDeviceName(devName);
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
// InitDKS (private)
|
// InitDKS (private)
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
@ -251,7 +274,7 @@ void PFitterFcnDKS::InitDKS(const UInt_t dksTag)
|
|||||||
|
|
||||||
// init chisq buffer on the GPU
|
// init chisq buffer on the GPU
|
||||||
|
|
||||||
// 1) calculated the maximum size for the data needed.
|
// 1) calculate the maximum size for the data needed.
|
||||||
Int_t parSize = -1, mapSize = -1, funSize = -1;
|
Int_t parSize = -1, mapSize = -1, funSize = -1;
|
||||||
Int_t maxSize = 0, size = -1;
|
Int_t maxSize = 0, size = -1;
|
||||||
for (UInt_t i=0; i<fRunListCollection->GetNoOfSingleHisto(); i++) {
|
for (UInt_t i=0; i<fRunListCollection->GetNoOfSingleHisto(); i++) {
|
||||||
@ -296,7 +319,7 @@ void PFitterFcnDKS::InitDKS(const UInt_t dksTag)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// now ready to init the chisq buffer on the GPU
|
// now ready to init the chisq buffer on the GPU
|
||||||
cout << "debug> maximal packed histo size=" << maxSize << ", parSize=" << parSize << ", funSize=" << funSize << ", mapSize=" << mapSize << endl;
|
// cout << "debug> maximal packed histo size=" << maxSize << ", parSize=" << parSize << ", funSize=" << funSize << ", mapSize=" << mapSize << endl;
|
||||||
ierr = fDKS.initChiSquare(maxSize, parSize, funSize, mapSize);
|
ierr = fDKS.initChiSquare(maxSize, parSize, funSize, mapSize);
|
||||||
if (ierr != 0) {
|
if (ierr != 0) {
|
||||||
cerr << ">> PFitterFcnDKS::InitDKS: **ERROR** failed to allocate the necessary chisq buffer on the GPU." << endl;
|
cerr << ">> PFitterFcnDKS::InitDKS: **ERROR** failed to allocate the necessary chisq buffer on the GPU." << endl;
|
||||||
|
@ -68,7 +68,7 @@
|
|||||||
class PFitter
|
class PFitter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PFitter(PMsrHandler *runInfo, PRunListCollection *runListCollection, Bool_t chisq_only = false, TString hardwareInfo = TString("??"));
|
PFitter(PMsrHandler *runInfo, PRunListCollection *runListCollection, Bool_t chisq_only = false);
|
||||||
virtual ~PFitter();
|
virtual ~PFitter();
|
||||||
|
|
||||||
Bool_t IsValid() { return fIsValid; }
|
Bool_t IsValid() { return fIsValid; }
|
||||||
@ -85,7 +85,6 @@ class PFitter
|
|||||||
Bool_t fChisqOnly; ///< flag. true: calculate chi^2 only (no fitting).
|
Bool_t fChisqOnly; ///< flag. true: calculate chi^2 only (no fitting).
|
||||||
Bool_t fUseChi2; ///< flag. true: chi^2 fit. false: log-max-likelihood
|
Bool_t fUseChi2; ///< flag. true: chi^2 fit. false: log-max-likelihood
|
||||||
UInt_t fPrintLevel; ///< tag, showing the level of messages whished. 0=minimum, 1=standard, 2=maximum
|
UInt_t fPrintLevel; ///< tag, showing the level of messages whished. 0=minimum, 1=standard, 2=maximum
|
||||||
TString fHardwareInfo; ///< string containing the CPU/GPU information.
|
|
||||||
|
|
||||||
UInt_t fStrategy; ///< fitting strategy (see minuit2 manual).
|
UInt_t fStrategy; ///< fitting strategy (see minuit2 manual).
|
||||||
|
|
||||||
@ -134,7 +133,9 @@ class PFitter
|
|||||||
Bool_t ExecuteSave(Bool_t first);
|
Bool_t ExecuteSave(Bool_t first);
|
||||||
Bool_t ExecuteSimplex();
|
Bool_t ExecuteSimplex();
|
||||||
|
|
||||||
Double_t MilliTime();
|
Double_t MilliTime();
|
||||||
|
|
||||||
|
string GetCPUInfo();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _PFITTER_H_
|
#endif // _PFITTER_H_
|
||||||
|
@ -58,6 +58,8 @@ class PFitterFcnDKS : public ROOT::Minuit2::FCNBase
|
|||||||
virtual UInt_t GetTotalNoOfFittedBins() { return fRunListCollection->GetTotalNoOfBinsFitted(); }
|
virtual UInt_t GetTotalNoOfFittedBins() { return fRunListCollection->GetTotalNoOfBinsFitted(); }
|
||||||
virtual UInt_t GetNoOfFittedBins(const UInt_t idx) { return fRunListCollection->GetNoOfBinsFitted(idx); }
|
virtual UInt_t GetNoOfFittedBins(const UInt_t idx) { return fRunListCollection->GetNoOfBinsFitted(idx); }
|
||||||
virtual void CalcExpectedChiSquare(const std::vector<Double_t> &par, Double_t &totalExpectedChisq, std::vector<Double_t> &expectedChisqPerRun);
|
virtual void CalcExpectedChiSquare(const std::vector<Double_t> &par, Double_t &totalExpectedChisq, std::vector<Double_t> &expectedChisqPerRun);
|
||||||
|
|
||||||
|
virtual int GetDeviceName(string &devName);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Bool_t fValid; ///< flag needed to ensure a valid state
|
Bool_t fValid; ///< flag needed to ensure a valid state
|
||||||
|
104
src/musrfit.cpp
104
src/musrfit.cpp
@ -35,7 +35,6 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
//#include <string.h>
|
//#include <string.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/utsname.h>
|
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
@ -122,87 +121,6 @@ void musrfit_syntax()
|
|||||||
cout << endl << endl;
|
cout << endl << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* <p> extract CPU information from the system.
|
|
||||||
*
|
|
||||||
* @return the CPU information or ?? if this was not possible.
|
|
||||||
*/
|
|
||||||
TString musrfit_get_cpu_info()
|
|
||||||
{
|
|
||||||
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, "Darwin")) {
|
|
||||||
system("sysctl -n machdep.cpu.brand_string >> _musrfit_cpu_info.txt");
|
|
||||||
sleep(1);
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* <p> extract GPU information from the system.
|
|
||||||
*
|
|
||||||
* @return the GPU information or ?? if this was not possible.
|
|
||||||
*/
|
|
||||||
TString musrfit_get_gpu_info()
|
|
||||||
{
|
|
||||||
TString gpuInfo = "??";
|
|
||||||
|
|
||||||
system("nvidia-smi -L > _nv.txt");
|
|
||||||
sleep(1);
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* <p>Writes the fitted data- and theory-set in ascii format to disc.
|
* <p>Writes the fitted data- and theory-set in ascii format to disc.
|
||||||
@ -694,23 +612,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get CPU/GPU information
|
|
||||||
UInt_t dksTag = msrHandler->GetDKSTag();
|
|
||||||
TString hardwareInfo = TString("??");
|
|
||||||
switch (dksTag) {
|
|
||||||
case DKS_CPU_OPENMP:
|
|
||||||
case DKS_CPU_OPENCL:
|
|
||||||
hardwareInfo = musrfit_get_cpu_info();
|
|
||||||
break;
|
|
||||||
case DKS_GPU_CUDA:
|
|
||||||
case DKS_GPU_OPENCL:
|
|
||||||
hardwareInfo = musrfit_get_gpu_info();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// read all the necessary runs (raw data)
|
// read all the necessary runs (raw data)
|
||||||
PRunDataHandler *dataHandler;
|
PRunDataHandler *dataHandler;
|
||||||
if (startupHandler)
|
if (startupHandler)
|
||||||
@ -761,7 +663,7 @@ int main(int argc, char *argv[])
|
|||||||
// do fitting
|
// do fitting
|
||||||
PFitter *fitter = 0;
|
PFitter *fitter = 0;
|
||||||
if (success) {
|
if (success) {
|
||||||
fitter = new PFitter(msrHandler, runListCollection, chisq_only, hardwareInfo);
|
fitter = new PFitter(msrHandler, runListCollection, chisq_only);
|
||||||
if (fitter->IsValid()) {
|
if (fitter->IsValid()) {
|
||||||
fitter->DoFit();
|
fitter->DoFit();
|
||||||
if (!fitter->IsScanOnly())
|
if (!fitter->IsScanOnly())
|
||||||
@ -769,7 +671,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cout << "debug> after fit ..." << endl;
|
// cout << "debug> after fit ..." << endl;
|
||||||
|
|
||||||
// write log file
|
// write log file
|
||||||
if (success && !chisq_only) {
|
if (success && !chisq_only) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user