Could not create the Minuit minimizer : OpenMP parallelizm

Hello!

I want to increase the speed of my programm.
Fiting is the most hard CPU process.

I know, that there is PROOF system, but I am a noob and it is difficult for me to understand this system quickly.
I have tried to use OpenMP for my task.
I use VS2013 and root_v5.34.32 on windows7.
You can see the simple example below.

Main.cpp

#include <iostream>
#include <vector>
#include <omp.h> 

#include "TRandom.h"
#include "TMath.h"
#include "TGraphErrors.h"
#include  "TF1.h"
#include "Math/MinimizerOptions.h"

#include "MyClass.h"

using namespace std;

int main()
{
	int i;
	#pragma omp parallel private(i)
	{
		#pragma omp for schedule (static) 
		for (int i = 0; i < 8; i++)
		{
			MyClass *obj = new MyClass();
			obj->SetParameters();
			obj->DoFit();
		}
	}

	system("pause");
	return 0;
}

MyClass.h

#pragma once
#include <vector>
#include "TRandom.h"
#include "TMath.h"
#include "TGraphErrors.h"
#include  "TF1.h"
#include "Math/MinimizerOptions.h"

using namespace std;

class MyClass
{
public:
	MyClass();
	~MyClass();

	void DoFit();
	void SetParameters();	

private:
	vector<double> xv;
	vector<double> yv;

	vector<double> xverr;
	vector<double> yverr;
	
	static TF1 *fitFcn;
	static Double_t fitFunction(Double_t *x, Double_t *par);
	TGraphErrors * gr;

};

MyClass.cpp

#include "MyClass.h"

TF1 *MyClass::fitFcn; 

MyClass::MyClass()
{
	fitFcn = new TF1("fitFcn", MyClass::fitFunction, -10, 20, 3);
	const double noise_amp = 300;	

	//fill vectors ...
	for (int i = -10; i < 20; i++)
	{
		xv.push_back(i);
		yv.push_back((pow((i - 3.5) * 5, 2.0) + 3) + noise_amp*gRandom->Uniform(-1, 1));

		xverr.push_back(0);
		yverr.push_back(noise_amp);
	}

	gr = new TGraphErrors(xv.size(), &xv[0], &yv[0], &xverr[0], &yverr[0]);
	gr->SetMarkerColor(4);
	gr->SetMarkerStyle(kFullCircle);
}

MyClass::~MyClass()
{
}

Double_t MyClass::fitFunction(Double_t *x, Double_t *par)
{
	return pow((x[0] - par[2])*par[0], 2.0) + par[1];
}

void MyClass::SetParameters()
{
	//set statr parameters and limits
	fitFcn->SetParameter(0, 1);
	fitFcn->SetParLimits(0, 0, 10);

	fitFcn->SetParameter(1, 1);
	fitFcn->SetParLimits(1, -100, 100);

	fitFcn->SetParameter(2, 1);
	fitFcn->SetParLimits(2, -10, 10);
}

void MyClass::DoFit()
{
	gr->Fit("fitFcn", "R");
}

If I use more than one thread I have error:

Warning in <ROOT::Math::FitConfig::CreateMinimizer>: Could not create the Minuit minimizer. Try using the minimizer Minuit2 

Error in <ROOT::Math::FitConfig::CreateMinimizer>: Could not create the Minuit2 minimizer 

Error in <ROOT::Math::Fitter::FitFCN>: Minimizer cannot be created 

Warning in <Fit>: Abnormal termination of minimization

This error appears when gr->Fit(“fitFcn”, “R”); line is being doing.
Could you help me to overcome this error?
Or could you give me simplest way in order to parallelize this programm?

Yours sincerely, Vladislav.

Hello!

I can not solve this problem.

I have the next runtime out put from start to start (OpenMP is the name of my project):

  1. Unhandled exception at 0x630A5BC7 (libCore.dll) in OpenMP.exe: 0xC0000005: Access violation reading location 0x00000000.

  2. Unhandled exception at 0x619CDBF0 (libCint.dll) in OpenMP.exe: 0xC0000005: Access violation reading location 0xBAADF011.

  3. Unhandled exception at 0x640C45AC (msvcr120.dll) in OpenMP.exe: 0xC0000005: Access violation writing location 0x00000000.

  4. no errors and right fit

  5. Warning in ROOT::Math::FitConfig::CreateMinimizer: Could not create the Minuit minimizer. Try using the minimizer Minuit2 etc. for the first fit and no errors for the second fit.

If I use Minuit2, I have errors too.
I have hypothesis that Minuit or Minuit2 use global variable or static objest and this lead to data race.

Maybe you have any ideas how to overcome this problem.
Yours sincerely, Vladislav.

Perhaps this thread gives some answers:
[url=Multi-threaded fitting fitting[/url]

What comes to Minuit, in bug report ROOT-7173 the reporter wrote