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:
537 bytes
|
| Line | |
|---|
| 1 | #include <omp.h>
|
|---|
| 2 | #include <stdio.h>
|
|---|
| 3 |
|
|---|
| 4 | int main() {
|
|---|
| 5 | int i;
|
|---|
| 6 | int ctr = 0;
|
|---|
| 7 | int a[6] = {0,0,0,0,0,0};
|
|---|
| 8 |
|
|---|
| 9 | #pragma omp parallel for collapse(2) ordered
|
|---|
| 10 | for(int n=1; n < 3; n++)
|
|---|
| 11 | for (i=2; i<8; i+=2) {
|
|---|
| 12 | int v = 0;
|
|---|
| 13 | // ctr += 1;
|
|---|
| 14 | #pragma omp ordered
|
|---|
| 15 | {
|
|---|
| 16 | v = ctr + 1;
|
|---|
| 17 | ctr = v;
|
|---|
| 18 | }
|
|---|
| 19 | a[(n-1)*3 + i/2 - 1] = v;
|
|---|
| 20 | // printf("%d: %d, %d\n", omp_get_thread_num(), n, i);
|
|---|
| 21 | }
|
|---|
| 22 |
|
|---|
| 23 | for (int i=0; i<6; i++) {
|
|---|
| 24 | $assert(a[i] == i+1);
|
|---|
| 25 | printf("%d, ", a[i]);
|
|---|
| 26 | }
|
|---|
| 27 | printf("\n");
|
|---|
| 28 | return 0;
|
|---|
| 29 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.