diego sandoval wrote:
int main(int argc, char *argv[])
{
double start, stop; /* times of beginning and end of procedure */
double e, pi, factorial, product;
int i;
for (i = 1; i<num_steps; i++) {
factorial *= i;
e += 1.0/factorial;
}
for (i = 0; i < num_steps*10; i++) {
/* we want 1/1 - 1/3 + 1/5 - 1/7 etc.
therefore we count by fours (0, 4, 8, 12...) and take
1/(0+1) = 1/1
- 1/(0+3) = -1/3
1/(4+1) = 1/5
- 1/(4+3) = -1/7 and so on */
pi += 1.0/(i*4.0 + 1.0);
pi -= 1.0/(i*4.0 + 3.0);
}
Aren't they both competing for i? Admittedly I don't know how OpenMP
does it's threading (I'd just use pthreads) but both are using "i".
Try bringing it inside the blocks and see if that changes anything.
Tom