source: CIVL/examples/omp/pi1.c@ 67bc1cf

1.23 2.0 main test-branch
Last change on this file since 67bc1cf was 65657d6, checked in by Matthew B. Dwyer <matthewbdwyer@…>, 11 years ago

Some improvements to the simplifier (nowait and reduction support). Partial sequentialization (for to single). A few new examples that should be able to be simplified (had to scale down some constants in them - left comments). New test suite for OpenMP2CIVL is put in test/dev and named with a suffix "Dev" to keep it out of regression run since they still take a bit of time - hopefully that will be reduced in the next few days and we'll shift this temporary test suite back to test/regress.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@1890 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 465 bytes
Line 
1#include <omp.h>
2static long num_steps = 100000;
3double step;
4#define NUM_THREADS 2
5void main ()
6{ int i; double x, sum, pi=0.0;
7 step = 1.0/(double) num_steps;
8 omp_set_num_threads(NUM_THREADS)
9#pragma omp parallel private (x, sum)
10 {
11 id = omp_get_thread_num();
12 for (i=id,sum=0.0;i< num_steps;i=i+NUM_THREADS){
13 x = (i+0.5)*step;
14 sum += 4.0/(1.0+x*x);
15 }
16#pragma omp critical
17 pi += sum
18 }
19}
Note: See TracBrowser for help on using the repository browser.