[Omp] for loop
Breshears, Clay
clay.breshears at intel.com
Tue Apr 24 06:53:24 PDT 2007
The Reduction clause won't work in this case since there is a dependence
on the Sn variable. How about something like...
const double up = 1.1 ;
double Sn, origSn=1000.0;
double opt[N+1];
int n;
opt[0] = origSn;
#pragma omp parallel for default(none) private(n) shared(opt)
lastprivate(Sn)
for (n=1; n<=N; ++n) {
Sn = origSn * pow(up, n-1);
opt[n] = Sn;
}
The lastprivate would only be needed if the value of Sn was used after
the parallel region.
clay
-----Original Message-----
From: omp-bounces at openmp.org [mailto:omp-bounces at openmp.org] On Behalf
Of Hicham Mouline
Sent: Tuesday, April 24, 2007 8:39 AM
To: omp at openmp.org
Subject: [Omp] for loop
hello
const double up = 1.1 ;
double Sn=1000.0;
double opt[N+1];
int n;
for (n=0; n<=N; ++n) {
opt[n] = Sn;
Sn *= up;
}
how can this loop be parallelized? the problem is with the Sn variable.
const double up = 1.1 ;
double Sn=1000.0;
double opt[N+1];
int n;
#pragma omp for default(none) private(n) shared(opt) schedule(...)
for (n=0; n<=N; ++n) {
opt[n] = Sn;
Sn *= up;
}
?
rds,
_______________________________________________
Omp mailing list
Omp at openmp.org
http://openmp.org/mailman/listinfo/omp
More information about the Omp
mailing list