PageRenderTime 28ms CodeModel.GetById 16ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 1ms

/gcc/testsuite/gcc.dg/gomp/openmp-simd-2.c

https://gitlab.com/sortix/gcc
C | 43 lines | 31 code | 5 blank | 7 comment | 7 complexity | 681061302cbaa30c56b96e9743f9bcf5 MD5 | raw file
 1/* { dg-do compile } */
 2/* { dg-options "-fopenmp-simd -fdump-tree-original" } */
 3
 4extern void abort ();
 5int a[1024] __attribute__((aligned (32))) = { 1 };
 6struct S { int s; };
 7#pragma omp declare reduction (+:struct S:omp_out.s += omp_in.s)
 8#pragma omp declare reduction (foo:struct S:omp_out.s += omp_in.s)
 9#pragma omp declare reduction (foo:int:omp_out += omp_in)
10
11__attribute__((noinline, noclone)) int
12foo (void)
13{
14  int i, u = 0;
15  struct S s, t;
16  s.s = 0; t.s = 0;
17  #pragma omp simd aligned(a : 32) reduction(+:s) reduction(foo:t, u)
18  for (i = 0; i < 1024; i++)
19    {
20      int x = a[i];
21      s.s += x;
22      t.s += x;
23      u += x;
24    }
25  if (t.s != s.s || u != s.s)
26    abort ();
27  return s.s;
28}
29
30
31void bar(int n, float *a, float *b)
32{
33  int i; 
34#pragma omp parallel for simd num_threads(4) safelen(64)
35  for (i = 0; i < n ; i++)
36    a[i] = b[i];
37}
38
39/* { dg-final { scan-tree-dump-times "pragma omp simd reduction\\(u\\) reduction\\(t\\) reduction\\(\\+:s\\) aligned\\(a:32\\)" 1 "original" } } */
40/* { dg-final { scan-tree-dump-times "pragma omp simd safelen\\(64\\)" 1 "original" } } */
41/* { dg-final { scan-tree-dump-not "omp parallel" "original" } } */
42/* { dg-final { scan-tree-dump-not "omp for" "original" } } */
43/* { dg-final { cleanup-tree-dump "original" } } */