moved hardware info to the place where it is needed.
This commit is contained in:
@ -32,6 +32,7 @@
|
||||
#endif
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <sys/utsname.h>
|
||||
|
||||
#ifdef HAVE_GOMP
|
||||
#include <omp.h>
|
||||
@ -80,10 +81,9 @@ using namespace std;
|
||||
* \param runInfo pointer of the msr-file handler
|
||||
* \param runListCollection pointer of the run list collection (pre-processed historgrams)
|
||||
* \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) :
|
||||
fChisqOnly(chisq_only), fHardwareInfo(hardwareInfo), fRunInfo(runInfo), fRunListCollection(runListCollection)
|
||||
PFitter::PFitter(PMsrHandler *runInfo, PRunListCollection *runListCollection, Bool_t chisq_only) :
|
||||
fChisqOnly(chisq_only), fRunInfo(runInfo), fRunListCollection(runListCollection)
|
||||
{
|
||||
// initialize variables
|
||||
fDKSReady = false;
|
||||
@ -1756,22 +1756,34 @@ Bool_t PFitter::ExecuteSave(Bool_t firstSave)
|
||||
fout << endl << "*************************************************************************";
|
||||
fout << endl;
|
||||
|
||||
// write CPU/GPU info
|
||||
// write CPU/GPU info
|
||||
string hwInfo("??");
|
||||
int status=0;
|
||||
switch (fDKSTag) {
|
||||
case DKS_CPU_OPENMP:
|
||||
fout << endl << " CPU info : " << fHardwareInfo;
|
||||
fout << endl << " OpenMP" << endl;
|
||||
fout << endl << " CPU info : " << GetCPUInfo();
|
||||
#ifdef HAVE_GOMP
|
||||
fout << endl << " OpenMP" << endl;
|
||||
#else
|
||||
fout << endl << " CPU, i.e. single threaded" << endl;
|
||||
#endif
|
||||
break;
|
||||
case DKS_CPU_OPENCL:
|
||||
fout << endl << " CPU info : " << fHardwareInfo;
|
||||
case DKS_CPU_OPENCL:
|
||||
if (fFitterFcnDKS)
|
||||
status = fFitterFcnDKS->GetDeviceName(hwInfo);
|
||||
fout << endl << " CPU info : " << hwInfo;
|
||||
fout << endl << " OpenCL" << endl;
|
||||
break;
|
||||
case DKS_GPU_CUDA:
|
||||
fout << endl << " GPU info : " << fHardwareInfo;
|
||||
case DKS_GPU_CUDA:
|
||||
if (fFitterFcnDKS)
|
||||
status = fFitterFcnDKS->GetDeviceName(hwInfo);
|
||||
fout << endl << " GPU info : " << hwInfo;
|
||||
fout << endl << " Cuda" << endl;
|
||||
break;
|
||||
case DKS_GPU_OPENCL:
|
||||
fout << endl << " GPU info : " << fHardwareInfo;
|
||||
case DKS_GPU_OPENCL:
|
||||
if (fFitterFcnDKS)
|
||||
status = fFitterFcnDKS->GetDeviceName(hwInfo);
|
||||
fout << endl << " GPU info : " << hwInfo;
|
||||
fout << endl << " OpenCL" << endl;
|
||||
break;
|
||||
default:
|
||||
@ -2123,6 +2135,59 @@ Double_t PFitter::MilliTime()
|
||||
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
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user