Multithreading on Minuit

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
//--set fitter to Minuit2 for multithreading

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);

_ROOT Version: _6.24.00
Platform: Ubuntu 20.04
Compiler: gcc 9.3.0

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:
Can you tell me what is the output if you type root-config --has-imt ?


therefore have I to specify:


Sort of?
By typing that command i receive response “yes”.
Best regards,


No, you should do:


but as I said it should be the default. How are you sure that the fit is not run in multithread ?


I use htop to check if my macro is running in multithread or not:

In this first screenshot, i am running my app with the fitting function:

In this second one, I am running my app without fitting:

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, thanks for your help, but modifying the line as you wrote does not enable the multithreading of the fitting function.

I guess you need to post a small “standalone reproducer”, which one can run (and which demonstrates your problem).

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:
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.


macro.C (2.0 KB)

The “MULTITHREAD” option works only for histograms.

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

Best regards


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



Yes we can implement this option for fitting TGraphErrors. It can be added in the next release. I will create a GitHub issue to not forgetting this



Dear Lorenzo,

is there a news on multithreading for TGraphErrors fitting?


It is not yet implemented. A new issue, i open to track this.