main
test-branch
|
Last change
on this file since bb03188 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
100644
|
|
File size:
466 bytes
|
| Line | |
|---|
| 1 | #include <omp.h>
|
|---|
| 2 | #include <assert.h>
|
|---|
| 3 | #define N 10
|
|---|
| 4 |
|
|---|
| 5 | int main (int argc, char * argv[]){
|
|---|
| 6 | int i;
|
|---|
| 7 | int a[N];
|
|---|
| 8 | int sum = 0;
|
|---|
| 9 |
|
|---|
| 10 | #pragma omp parallel
|
|---|
| 11 | {
|
|---|
| 12 | int max = N;
|
|---|
| 13 |
|
|---|
| 14 | #pragma omp for
|
|---|
| 15 | for(i=0; i<max; i++)
|
|---|
| 16 | a[i] = 0;
|
|---|
| 17 |
|
|---|
| 18 | max = 0;
|
|---|
| 19 | }
|
|---|
| 20 |
|
|---|
| 21 | #pragma omp parallel
|
|---|
| 22 | if (i>0) {
|
|---|
| 23 | sum = N;
|
|---|
| 24 | } else {
|
|---|
| 25 | #pragma omp for reduction(+:sum)
|
|---|
| 26 | for(i=0; i<N; i++)
|
|---|
| 27 | sum = sum + a[i];
|
|---|
| 28 | }
|
|---|
| 29 |
|
|---|
| 30 | {
|
|---|
| 31 | int counter = 0;
|
|---|
| 32 | #pragma omp parallel
|
|---|
| 33 | if (counter == 0) counter++;
|
|---|
| 34 |
|
|---|
| 35 | assert(counter == 1);
|
|---|
| 36 | }
|
|---|
| 37 |
|
|---|
| 38 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.