Wednesday, May 2, 2012

C++ PPL nested parallel_for loop and lambda capture clause

I am writing nested parallel_for loops, and I wonder whether syntax for lambda capture clause in nested inner loop is appropriate.



// outer loop
parallel_for(0,p,[&highPPL,&lowPPL,&highOneParam,&lowOneParam, &formulaPPL, &confciInputPPL, &methodPPL, confciInput, formula, p, N, &param, up, down](int i)
{
double min = highOneParam[i];
double max = lowOneParam[i];

formulaPPL.local() = formula;
confciInputPPL.local() = new SolverInput(confciInput);
methodPPL.local() = new MethodNMMS(confciInputPPL.local());

/* other things*/

// inner loop
parallel_for(0,N,[p,i,&confciInputPPL.local()](int k)
{
QString prm;
double *x1Pt = new double[1];
double *x2Pt = new double[1];
confciInputPPL.local().local()=new SolverInput(confciInputPPL.local());

/* other things*/
}
}


I don't trust that I have to set as capture member conciInputPPL.local(), and then call confciInputPPL.local().local() to instanciate a copy of the former.



Thanks and regards.





No comments:

Post a Comment