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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [libgomp/] [testsuite/] [libgomp.c/] [appendix-a/] [a.40.1.c] - Blame information for rev 826

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 273 jeremybenn
/* { dg-do compile } */
2
 
3
#include <omp.h>
4
typedef struct
5
{
6
  int a, b;
7
  omp_nest_lock_t lck;
8
} pair;
9
int work1 ();
10
int work2 ();
11
int work3 ();
12
void
13
incr_a (pair * p, int a)
14
{
15
  /* Called only from incr_pair, no need to lock. */
16
  p->a += a;
17
}
18
 
19
void
20
incr_b (pair * p, int b)
21
{
22
  /* Called both from incr_pair and elsewhere, */
23
  /* so need a nestable lock. */
24
  omp_set_nest_lock (&p->lck);
25
  p->b += b;
26
  omp_unset_nest_lock (&p->lck);
27
}
28
 
29
void
30
incr_pair (pair * p, int a, int b)
31
{
32
  omp_set_nest_lock (&p->lck);
33
  incr_a (p, a);
34
  incr_b (p, b);
35
  omp_unset_nest_lock (&p->lck);
36
}
37
 
38
void
39
a40 (pair * p)
40
{
41
#pragma omp parallel sections
42
  {
43
#pragma omp section
44
    incr_pair (p, work1 (), work2 ());
45
#pragma omp section
46
    incr_b (p, work3 ());
47
  }
48
}

powered by: WebSVN 2.1.0

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