source: CIVL/examples/omp/simd_simple.c@ bb03188

main test-branch
Last change on this file since bb03188 was 6140a5e, checked in by Wenhao Wu <wuwenhao@…>, 2 years ago

Add one simd_simple.c example

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5900 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 512 bytes
RevLine 
[c864f11]1#include <stdio.h>
2#include <assert.h>
[6140a5e]3#include <concurrency.cvh>
[c864f11]4#define N 6
5
6void 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
21int 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.