some more work towards DKS/GPU support of musrfit
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
#include "PMusr.h"
|
||||
#include "PFitterFcnDKS.h"
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@@ -41,14 +42,20 @@ using namespace std;
|
||||
* \param runList run list collection
|
||||
* \param useChi2 if true, a chisq fit will be performed, otherwise a log max-likelihood fit will be carried out.
|
||||
*/
|
||||
PFitterFcnDKS::PFitterFcnDKS(PRunListCollection *runList, Bool_t useChi2) :
|
||||
fRunListCollection(runList),
|
||||
fUseChi2(useChi2)
|
||||
PFitterFcnDKS::PFitterFcnDKS(PRunListCollection *runList, const Bool_t useChi2, const UInt_t dksTag,
|
||||
const std::string theo) :
|
||||
fTheoStr(theo),
|
||||
fUseChi2(useChi2),
|
||||
fRunListCollection(runList)
|
||||
{
|
||||
fValid = false;
|
||||
|
||||
if (fUseChi2)
|
||||
fUp = 1.0;
|
||||
else
|
||||
fUp = 0.5;
|
||||
|
||||
InitDKS(dksTag);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@@ -78,7 +85,7 @@ Double_t PFitterFcnDKS::operator()(const std::vector<Double_t>& par) const
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// CalcExpectedChiSquare()
|
||||
// CalcExpectedChiSquare (public)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Calculates the expected chisq, expected chisq per run, and chisq per run, if applicable.
|
||||
@@ -105,3 +112,65 @@ void PFitterFcnDKS::CalcExpectedChiSquare(const std::vector<Double_t> &par, Doub
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// InitDKS (private)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>initializes the DKS interface
|
||||
*
|
||||
*/
|
||||
void PFitterFcnDKS::InitDKS(const UInt_t dksTag)
|
||||
{
|
||||
// if any device was allocated before, free the device resources
|
||||
FreeDKS();
|
||||
|
||||
// select framework
|
||||
if (dksTag == DKS_GPU_CUDA)
|
||||
fDKS.setAPI("Cuda");
|
||||
else
|
||||
fDKS.setAPI("OpenCL");
|
||||
|
||||
// select device
|
||||
if (dksTag == DKS_CPU_OPENCL)
|
||||
fDKS.setDevice("-cpu");
|
||||
else
|
||||
fDKS.setDevice("-gpu");
|
||||
|
||||
// init device
|
||||
fDKS.initDevice();
|
||||
|
||||
// init chisq buffer on the GPU
|
||||
|
||||
// allocate memory for the data on the GPU/CPU and transfer the data sets
|
||||
|
||||
// set the function string and compile the program
|
||||
Int_t ierr = fDKS.callCompileProgram(fTheoStr, !fUseChi2);
|
||||
if (ierr != 0) {
|
||||
cerr << ">> PFitterFcnDKS::InitDKS: **ERROR** failed to compile theory!" << endl;
|
||||
fValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// checks device properties if openCL
|
||||
ierr = fDKS.checkMuSRKernels();
|
||||
if (ierr != 0) {
|
||||
cerr << ">> PFitterFcnDKS::InitDKS: **ERROR** muSR kernel checks failed!" << endl;
|
||||
fValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
fValid = true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// FreeDKS (private)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>cleanup DKS/GPU memory
|
||||
*
|
||||
*/
|
||||
void PFitterFcnDKS::FreeDKS()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user