first DKS running version. Still a lot of testing needed. Currently only single histogram fitting with a limited number of functions is supported to run on the GPU.

This commit is contained in:
2016-04-06 17:22:58 +02:00
parent a29b790e04
commit 6fa7bb5764
6 changed files with 171 additions and 66 deletions

View File

@ -87,8 +87,9 @@ Double_t PFitterFcnDKS::operator()(const std::vector<Double_t>& par) const
// loop over all data sets
PSingleHistoParams shp;
for (UInt_t i=0; i<fRunListCollection->GetNoOfSingleHisto(); i++) {
// get current values of N0, Nbkg, tau, the functions, and the maps
// get current values of N0, Nbkg, tau, the functions, the maps, the time resolution, the fit start time, etc.
ierr = fRunListCollection->GetSingleHistoParams(i, par, shp);
// set N0, Nbkg
ierr += fDKS.callSetConsts(shp.fN0, shp.fTau, shp.fNbkg);
@ -99,13 +100,12 @@ Double_t PFitterFcnDKS::operator()(const std::vector<Double_t>& par) const
ierr += fDKS.writeMaps(&shp.fMap[0], shp.fMap.size());
// calc chisq/log-mlh
/*
chisq = 0.0;
ierr += fDKS.callLauchChiSquare(fMemData[i], fMemData[i], fData.size(),
par.size(), shp.fFun.size(), shp.fMap.size(),
dt0 , dt, 0, chisq);
ierr += fDKS.callLaunchChiSquare(fMemData[i], fMemData[i], shp.fNoOfFitBins,
par.size(), shp.fFun.size(), shp.fMap.size(),
shp.fStartTime , shp.fPackedTimeResolution, chisq);
value += chisq;
*/
if (ierr != 0) {
cerr << "PFitterFcnDKS::operator(): **ERROR** Kernel launch failed!" << endl;
exit (EXIT_FAILURE);
@ -113,7 +113,11 @@ Double_t PFitterFcnDKS::operator()(const std::vector<Double_t>& par) const
}
return value;
Double_t norm = 1.0;
if (shp.fScaleN0AndBkg)
norm = shp.fPackedTimeResolution*1.0e3;
return norm*value;
}
//--------------------------------------------------------------------------
@ -176,24 +180,25 @@ void PFitterFcnDKS::InitDKS(const UInt_t dksTag)
// init chisq buffer on the GPU
// 1) calculated the maximum size for the data needed.
Int_t maxSize = -1, size = -1;
// 1) calculated the minimum size for the data needed.
Int_t minSize = 1e9, size = -1;
Int_t parSize = -1, mapSize = -1, funSize = -1;
for (UInt_t i=0; i<fRunListCollection->GetNoOfSingleHisto(); i++) {
size = fRunListCollection->GetSingleHisto(i)->GetValue()->size();
if (maxSize < size)
maxSize = size;
size = fRunListCollection->GetNoOfBinsFitted(i);
if (minSize > size)
minSize = size;
}
for (UInt_t i=0; i<fRunListCollection->GetNoOfAsymmetry(); i++) {
size = fRunListCollection->GetAsymmetry(i)->GetValue()->size();
if (maxSize < size)
maxSize = size;
size = fRunListCollection->GetNoOfBinsFitted(i);
if (minSize > size)
minSize = size;
}
if (maxSize == -1) {
if (minSize == 1e9) {
cerr << ">> PFitterFcnDKS::InitDKS: **ERROR** failed to get data size to be fitted." << endl;
fValid = false;
return;
}
cout << "debug> minSize = " << minSize << endl;
// 2) get number of parameters / functions / maps
parSize = fRunListCollection->GetNoOfParameters();
@ -217,7 +222,7 @@ void PFitterFcnDKS::InitDKS(const UInt_t dksTag)
cout << "debug> parSize=" << parSize << ", funSize=" << funSize << ", mapSize=" << mapSize << endl;
// now ready to init the chisq buffer on the GPU
ierr = fDKS.initChiSquare(maxSize, parSize, funSize, mapSize);
ierr = fDKS.initChiSquare(minSize, parSize, funSize, mapSize);
if (ierr != 0) {
cerr << ">> PFitterFcnDKS::InitDKS: **ERROR** failed to allocate the necessary chisq buffer on the GPU." << endl;
fValid = false;
@ -234,13 +239,21 @@ void PFitterFcnDKS::InitDKS(const UInt_t dksTag)
fValid = false;
return;
}
fMemData[i] = fDKS.allocateMemory<Double_t>(runData->GetValue()->size(), ierr);
fMemData[i] = fDKS.allocateMemory<Double_t>(minSize, ierr);
if (ierr != 0) {
cerr << ">> PFitterFcnDKS::InitDKS: **ERROR** failed to allocated data set memory (i=" << i << ") on the GPU" << endl;
fValid = false;
return;
}
fDKS.writeData<double>(fMemData[i], runData->GetValue(), runData->GetValue()->size());
Int_t startTimeBin = fRunListCollection->GetStartTimeBin(i);
if (startTimeBin < 0) {
cerr << ">> PFitterFcnDKS::InitDKS: **ERROR** startTimeBin undefind." << endl;
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);
}
// set the function string and compile the program