main
test-branch
| Line | |
|---|
| 1 | #include <stdio.h>
|
|---|
| 2 | #include <assert.h>
|
|---|
| 3 | #include <concurrency.cvh>
|
|---|
| 4 | #define N 6
|
|---|
| 5 |
|
|---|
| 6 | void func(int n, double A[restrict]) {
|
|---|
| 7 | double s = 0.0;
|
|---|
| 8 | #pragma omp simd simdlen(2)
|
|---|
| 9 | for (int i = 0; i < 2*n; ++i) {
|
|---|
| 10 | #pragma civl depend source(A)
|
|---|
| 11 | S1:
|
|---|
| 12 | s += A[i];
|
|---|
| 13 | #pragma civl depend target(A)
|
|---|
| 14 | S2:
|
|---|
| 15 | A[i] = 10.0*i;
|
|---|
| 16 | }
|
|---|
| 17 | printf("s=%lf\n", s);
|
|---|
| 18 | assert(s == 2*N*(2*N-1)/2);
|
|---|
| 19 | }
|
|---|
| 20 |
|
|---|
| 21 | int main(void) {
|
|---|
| 22 | double A[2*N];
|
|---|
| 23 | for (int i=0; i<2*N; i++)
|
|---|
| 24 | A[i] = i;
|
|---|
| 25 | func(N, A);
|
|---|
| 26 | for (int i=0; i<2*N; i++)
|
|---|
| 27 | assert(A[i] == 10.0*i);
|
|---|
| 28 | } |
|---|
Note:
See
TracBrowser
for help on using the repository browser.