Dear all,
currently, I am working on a macro in which Minuit/Migrad is the default minimization engine for fitting and with big data matrices it is really slow. On both this forum, on many .ppt files across the internet and other documentation files I read that Minuit2 supports parallelization. Therefore, to speed up the fitting process, I tried this:
//--introduces implicit multithreading
ROOT::EnableImplicitMT();
//--set fitter to Minuit2 for multithreading
ROOT::Math::MinimizerOptions::SetDefaultMinimizer("Minuit2");
This piece of code speeded up all the other parts of the code, such as big for loop iterations, but not the fitting procedure. I checked if Minuit2 was correctly enabled and it is. Am I missing something?
Thank you in advance for the help. I leave here also the function and the fitting lines of code as maybe it can help.
fqua = new TF1("fqua",fquantExafsVar,fitxminActual,fitxmaxActual,npar);
grQua->Fit("fqua","menq","",fitxminActual,fitxmaxActual);
Hi,
By doing this the fitting (the evaluation of the chi2 function) should be happening in multithreads.
You can try to use the fit option MULTITHREAD in TH1::Fit to force this.
If it is not happening , it could be that your ROOT build does not support multithread
Dear Lorenzo,
I’m struggling to find documentation about this. Where can I specify the option MULTITHREAD? On the page belonging to class TH1 I can’t find the field in the Fit function where it can be specified.
Thank you again,
This option should be passed as a fit option in TH1::Fit. It is true it is not documented, but in principle it should not be needed. MULTITHREAD should be enabled automatically when you do: ROOT::EnableImplicitMT();
Can you tell me what is the output if you type root-config --has-imt ?
As you can see, the process is shared among the threads of my laptop. From my original post I changed the fitting procedure as suggested, but nothing changed.
fqua = new TF1("fqua",fquantExafsVar,fitxminActual,fitxmaxActual,npar);
rQua->Fit("fqua","menq","MULTITHREAD",fitxminActual,fitxmaxActual);
Dear Wile_E_Coyote,
I made this small macro that has the same problem. To reproduce the error you can just edit the following line: FF->Fit("f","MULTITHREAD");
If you specify just MULTITHREAD, it correctly works. If there is a space, like in MENQ MULTITHREAD, the fit is not performed and an error is printed out [L (Log Likelihood fit) is an invalid option when fitting a graph. It is ignored]. If you use just MENQ, the fit is performed, but not in multithread mode.
Hi,
This is correct the Multithread option is not implemented when fitting TGraphs. I will probably add an error message when the MULTITHREAD option is requested.
How many graph points are you fitting ? Are you fitting a Graph with errors in both x and y coordinates ?
If it is something needed, we could implement for next ROOT version
Dear Dr. Moneta,
I work on a ROOT-based data processing software which is used in crystallography for X-ray diffraction data. We only plot errors on the y coordinate. Usually data are 200-10’000 x,y pairs for multiple data files organized in data matrices. We tried to edit the software we are working on using the TH1 histograms instead of TGraph. However, we noticed that fit results change between TGraph and TH1 and, mainly for this reason, we would like to retain the use of TGraph for consistency for our users. Can MULTITHREAD option be implemented in TGraph as you suggested?
Best regards