OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [libgomp/] [testsuite/] [libgomp.c/] [vla-1.c] - Blame information for rev 853

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 38 julius
/* { dg-do run } */
2
 
3
#include <omp.h>
4
#include <stdlib.h>
5
#include <string.h>
6
 
7
int
8
main (int argc, char **argv[])
9
{
10
  int n = argc < 5 ? 12 : 31, i, m, l;
11
  char a[n + 3];
12
  unsigned short b[n / 2 - 1];
13
  int c[n * 2 + 1];
14
 
15
  for (i = 0; i < n + 3; i++)
16
    a[i] = i;
17
  for (i = 0; i < n / 2 - 1; i++)
18
    b[i] = (i << 8) | i;
19
  for (i = 0; i < n * 2 + 1; i++)
20
    c[i] = (i << 24) | i;
21
  l = 0;
22
  m = n;
23
#pragma omp parallel default (shared) num_threads (4) \
24
  firstprivate (a, m) private (b, i) reduction (+:l)
25
  {
26
    for (i = 0; i < m + 3; i++)
27
      if (a[i] != i)
28
        l++;
29
    for (i = 0; i < m * 2 + 1; i++)
30
      if (c[i] != ((i << 24) | i))
31
        l++;
32
#pragma omp barrier
33
    memset (a, omp_get_thread_num (), m + 3);
34
    for (i = 0; i < m / 2 - 1; i++)
35
      b[i] = a[0] + 7;
36
#pragma omp master
37
    {
38
      for (i = 0; i < m * 2 + 1; i++)
39
        c[i] = a[0] + 16;
40
    }
41
#pragma omp barrier
42
    if (a[0] != omp_get_thread_num ())
43
      l++;
44
    for (i = 1; i < m + 3; i++)
45
      if (a[i] != a[0])
46
        l++;
47
    for (i = 0; i < m / 2 - 1; i++)
48
      if (b[i] != a[0] + 7)
49
        l++;
50
    for (i = 0; i < m * 2 + 1; i++)
51
      if (c[i] != 16)
52
        l++;
53
  }
54
  if (l)
55
    abort ();
56
  for (i = 0; i < n * 2 + 1; i++)
57
    if (c[i] != 16)
58
      l++;
59
  return 0;
60
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.