Page 1 of 1

loop

Posted: Tue Jul 21, 2020 12:19 pm
by pdupre
Hello,

I started a parallel session and I cannot get the right value of a variable ("normal_fact").
Before the parallel sssion, normal_fact has a value which is modified in the parallel session (it depends on "param" with is also modified
in the parallel session)
By using firspriavte, the value of normal_fact is that when entering in the parallel session while I need the value calculated during the
parallel session (it only depends on "param")

Here is the example

double normal_fact = A ;
double x [nbpt], y [nbpt] ;
gsl_function fcn ;
#pragma omp parallel private (fcn) firstprivate (normal_fact)
{
cluster_V_str param ; // To declare inside the parallel section
fcn.function = (function_gsl) funct ;
fcn.params = &param ;
pre_init_crossover_V (&param, etc..) ;
#pragma omp for
for (unsigned int i = 0 ; i < nbpt ; i++) {
setting_V2 (&param, x ) ;
y = fcn.function (delta, fcn.params) ;
}
#pragma omp barrier
}

In theory, I could avoid to start the parallel session like it is, and start it only when entering in the for loop.
However, I am in trouble because param (and fcn) needs a copy in the parallel session.

Could you make some suggestions?

Thanks

Re: loop

Posted: Fri Jul 24, 2020 1:51 pm
by MarkB
Where is normal_fact modified? (Your code snippet doesn't show this).