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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgomp/] [testsuite/] [libgomp.c/] [appendix-a/] [a.16.1.c] - Blame information for rev 735

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 735 jeremybenn
/* { dg-do run } */
2
 
3
#include <stdio.h>
4
 
5
float
6
work1 (int i)
7
{
8
  return 1.0 * i;
9
}
10
 
11
float
12
work2 (int i)
13
{
14
  return 2.0 * i;
15
}
16
 
17
void
18
a16 (float *x, float *y, int *index, int n)
19
{
20
  int i;
21
#pragma omp parallel for shared(x, y, index, n)
22
  for (i = 0; i < n; i++)
23
    {
24
#pragma omp atomic
25
      x[index[i]] += work1 (i);
26
      y[i] += work2 (i);
27
    }
28
}
29
int
30
main ()
31
{
32
  float x[1000];
33
  float y[10000];
34
  int index[10000];
35
  int i;
36
  for (i = 0; i < 10000; i++)
37
    {
38
      index[i] = i % 1000;
39
      y[i] = 0.0;
40
    }
41
  for (i = 0; i < 1000; i++)
42
    x[i] = 0.0;
43
  a16 (x, y, index, 10000);
44
  for (i = 0; i < 10; i++)
45
    printf ("x[%d] = %f, y[%d] = %f\n", i, x[i], i, y[i]);
46
  return 0;
47
}

powered by: WebSVN 2.1.0

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