removed debug information. Added CPU/GPU information to the MINUIT2.OUTPUT file.

This commit is contained in:
2016-04-07 13:06:02 +02:00
parent 6fa7bb5764
commit 2a041d4878
6 changed files with 125 additions and 47 deletions

View File

@ -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
//-------------------------------------------------------------------------------------------------