main
test-branch
|
Last change
on this file since 978afe7 was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago |
|
Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.
git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c
|
-
Property mode
set to
100755
|
|
File size:
950 bytes
|
| Line | |
|---|
| 1 | #include <omp.h>
|
|---|
| 2 |
|
|---|
| 3 | #define N 10
|
|---|
| 4 |
|
|---|
| 5 | int main (int argc, char *argv[]) {
|
|---|
| 6 | double a[N], b[N];
|
|---|
| 7 | int i, sum;
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 | #pragma omp parallel
|
|---|
| 11 | #pragma omp single
|
|---|
| 12 | for (i=0; i < N; i++)
|
|---|
| 13 | a[i] = 0;
|
|---|
| 14 |
|
|---|
| 15 | /*
|
|---|
| 16 | // This omp construct is completely eliminated
|
|---|
| 17 | #pragma omp parallel for
|
|---|
| 18 | for (i=0; i < N-1; i++)
|
|---|
| 19 | b[i+1] = a[i+1] + 2*i;
|
|---|
| 20 |
|
|---|
| 21 | // These nested omp constructs are completely eliminated
|
|---|
| 22 | #pragma omp parallel
|
|---|
| 23 | {
|
|---|
| 24 | #pragma omp for
|
|---|
| 25 | for (i=0; i < N-1; i++)
|
|---|
| 26 | b[i+1] = a[i+1] + 2*i;
|
|---|
| 27 | }
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 | #pragma omp parallel for
|
|---|
| 31 | for (i=0; i < N; i++) {
|
|---|
| 32 | a[i] = 0.0;
|
|---|
| 33 | b[i] = a[i];
|
|---|
| 34 | b[i] = a[i] + b[i];
|
|---|
| 35 | }
|
|---|
| 36 |
|
|---|
| 37 | #pragma omp parallel for
|
|---|
| 38 | for (i=0; i < N-1; i++) {
|
|---|
| 39 | //a[i+1] = a[1+i] + 1;
|
|---|
| 40 | a[i+2-1] = a[(-2*3) + 2*i - i + 7] + 1;
|
|---|
| 41 | }
|
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 | #pragma omp parallel for private(sum)
|
|---|
| 45 | for (i=0; i < N; i++)
|
|---|
| 46 | sum = sum + i;
|
|---|
| 47 |
|
|---|
| 48 | #pragma omp parallel for
|
|---|
| 49 | for (i=0; i < N; i++)
|
|---|
| 50 | sum = sum + i;
|
|---|
| 51 | */
|
|---|
| 52 |
|
|---|
| 53 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.