moved hardware info to the place where it is needed.
This commit is contained in:
104
src/musrfit.cpp
104
src/musrfit.cpp
@@ -35,7 +35,6 @@
|
||||
#include <cstdlib>
|
||||
//#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
@@ -122,87 +121,6 @@ void musrfit_syntax()
|
||||
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.
|
||||
@@ -694,23 +612,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
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)
|
||||
PRunDataHandler *dataHandler;
|
||||
if (startupHandler)
|
||||
@@ -761,7 +663,7 @@ int main(int argc, char *argv[])
|
||||
// do fitting
|
||||
PFitter *fitter = 0;
|
||||
if (success) {
|
||||
fitter = new PFitter(msrHandler, runListCollection, chisq_only, hardwareInfo);
|
||||
fitter = new PFitter(msrHandler, runListCollection, chisq_only);
|
||||
if (fitter->IsValid()) {
|
||||
fitter->DoFit();
|
||||
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
|
||||
if (success && !chisq_only) {
|
||||
|
||||
Reference in New Issue
Block a user