OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [libgomp/] [testsuite/] [libgomp.c/] [pr30494.c] - Blame information for rev 533

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

Line No. Rev Author Line
1 273 jeremybenn
/* PR middle-end/30494 */
2
/* { dg-do run } */
3
 
4
#include <omp.h>
5
 
6
int errors;
7
 
8
int
9
check (int m, int i, int *v, int *w)
10
{
11
  int j;
12
  int n = omp_get_thread_num ();
13
  for (j = 0; j < m; j++)
14
    if (v[j] != j + n)
15
      #pragma omp atomic
16
        errors += 1;
17
  for (j = 0; j < m * 3 + i; j++)
18
    if (w[j] != j + 10 + n)
19
      #pragma omp atomic
20
        errors += 1;
21
}
22
 
23
int
24
foo (int n, int m)
25
{
26
  int i;
27
#pragma omp for
28
  for (i = 0; i < 6; i++)
29
    {
30
      int v[n], w[n * 3 + i], j;
31
      for (j = 0; j < n; j++)
32
        v[j] = j + omp_get_thread_num ();
33
      for (j = 0; j < n * 3 + i; j++)
34
        w[j] = j + 10 + omp_get_thread_num ();
35
      check (m, i, v, w);
36
    }
37
  return 0;
38
}
39
 
40
int
41
bar (int n, int m)
42
{
43
  int i;
44
#pragma omp parallel for num_threads (4)
45
  for (i = 0; i < 6; i++)
46
    {
47
      int v[n], w[n * 3 + i], j;
48
      for (j = 0; j < n; j++)
49
        v[j] = j + omp_get_thread_num ();
50
      for (j = 0; j < n * 3 + i; j++)
51
        w[j] = j + 10 + omp_get_thread_num ();
52
      check (m, i, v, w);
53
    }
54
  return 0;
55
}
56
 
57
int
58
main (void)
59
{
60
#pragma omp parallel num_threads (3)
61
  foo (128, 128);
62
  bar (256, 256);
63
  return 0;
64
}

powered by: WebSVN 2.1.0

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