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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [libgomp/] [testsuite/] [libgomp.c/] [reduction-2.c] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 38 julius
#include <omp.h>
2
#include <stdlib.h>
3
 
4
int
5
main (void)
6
{
7
  int i = 0, j = 0, k = ~0, l;
8
  double d = 1.0;
9
#pragma omp parallel num_threads(4)
10
  {
11
#pragma omp single
12
    {
13
      i = 16;
14
      k ^= (1 << 16);
15
      d += 32.0;
16
    }
17
 
18
#pragma omp for reduction(+:i) reduction(*:d) reduction(&:k)
19
    for (l = 0; l < 4; l++)
20
      {
21
        if (omp_get_num_threads () == 4 && (i != 0 || d != 1.0 || k != ~0))
22
#pragma omp atomic
23
          j |= 1;
24
 
25
        if (l == omp_get_thread_num ())
26
          {
27
            i = omp_get_thread_num ();
28
            d = i + 1;
29
            k = ~(1 << (2 * i));
30
          }
31
      }
32
 
33
    if (omp_get_num_threads () == 4)
34
      {
35
        if (i != (16 + 0 + 1 + 2 + 3))
36
#pragma omp atomic
37
          j |= 2;
38
        if (d != (33.0 * 1.0 * 2.0 * 3.0 * 4.0))
39
#pragma omp atomic
40
          j |= 4;
41
        if (k != (~0 ^ 0x55 ^ (1 << 16)))
42
#pragma omp atomic
43
          j |= 8;
44
      }
45
  }
46
 
47
  if (j)
48
    abort ();
49
  return 0;
50
}

powered by: WebSVN 2.1.0

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