source:
CIVL/examples/omp/DataRaceBench/micro-benchmarks/pireduction-orig-no.c@
af3b8e4
| Last change on this file since af3b8e4 was 36a61f3, checked in by , 9 years ago | |
|---|---|
|
|
| File size: 288 bytes | |
| Rev | Line | |
|---|---|---|
| [36a61f3] | 1 | // Classic PI calculation using reduction |
| 2 | #define num_steps 2000000000 | |
| 3 | ||
| 4 | int main(int argc, char** argv) | |
| 5 | { | |
| 6 | double pi = 0; | |
| 7 | int i; | |
| 8 | #pragma omp parallel for reduction(+:pi) | |
| 9 | for (i = 0; i < num_steps; i++) { | |
| 10 | pi += 1.0 / (i * 4.0 + 1.0); | |
| 11 | } | |
| 12 | pi = pi * 4.0; | |
| 13 | return 0; | |
| 14 | } | |
| 15 |
Note:
See TracBrowser
for help on using the repository browser.
