main
|
Last change
on this file 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:
610 bytes
|
| Line | |
|---|
| 1 | #include <civlc.cvh>
|
|---|
| 2 | #include <stdio.h>
|
|---|
| 3 |
|
|---|
| 4 | int main () {
|
|---|
| 5 | int sum0 = 0;
|
|---|
| 6 | int sum1 = 1000;
|
|---|
| 7 | int sub = 0;
|
|---|
| 8 | int prod = 10;
|
|---|
| 9 |
|
|---|
| 10 | #pragma omp parallel num_threads(3) reduction(+: sum0, sum1) reduction(-: sub) reduction(*: prod)
|
|---|
| 11 | {
|
|---|
| 12 | sum0 += 1;
|
|---|
| 13 | sum1 += -100;
|
|---|
| 14 | sub -= 1;
|
|---|
| 15 | prod *= 10;
|
|---|
| 16 | }
|
|---|
| 17 | $assert(prod <= 10000);
|
|---|
| 18 |
|
|---|
| 19 | int max_val = -100;
|
|---|
| 20 | int min_val = 100;
|
|---|
| 21 |
|
|---|
| 22 | #pragma omp parallel num_threads(3) reduction(max: max_val) reduction(min: min_val)
|
|---|
| 23 | {
|
|---|
| 24 | if (max_val < sum0) max_val = sum0;
|
|---|
| 25 | if (min_val > sum0) min_val = sum0;
|
|---|
| 26 | }
|
|---|
| 27 | $assert(max_val == sum0);
|
|---|
| 28 | $assert(min_val == sum0);
|
|---|
| 29 |
|
|---|
| 30 | return 0;
|
|---|
| 31 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.