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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgomp/] [testsuite/] [libgomp.c/] [sections-1.c] - Blame information for rev 810

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

Line No. Rev Author Line
1 735 jeremybenn
/* Test that all sections are touched.  */
2
 
3
/* { dg-require-effective-target sync_int_long } */
4
 
5
#include <omp.h>
6
#include <string.h>
7
#include <assert.h>
8
#include "libgomp_g.h"
9
 
10
 
11
#define N 100
12
static int data[N];
13
static int NTHR;
14
 
15
static void clean_data (void)
16
{
17
  memset (data, -1, sizeof (data));
18
}
19
 
20
static void test_data (void)
21
{
22
  int i;
23
 
24
  for (i = 0; i < N; ++i)
25
    assert (data[i] != -1);
26
}
27
 
28
static void set_data (unsigned i, int val)
29
{
30
  int old;
31
  assert (i >= 1 && i <= N);
32
  old = __sync_lock_test_and_set (data+i-1, val);
33
  assert (old == -1);
34
}
35
 
36
 
37
static void f_1 (void *dummy)
38
{
39
  int iam = omp_get_thread_num ();
40
  unsigned long s;
41
 
42
  for (s = GOMP_sections_start (N); s ; s = GOMP_sections_next ())
43
    set_data (s, iam);
44
  GOMP_sections_end ();
45
}
46
 
47
static void test_1 (void)
48
{
49
  clean_data ();
50
  GOMP_parallel_start (f_1, NULL, NTHR);
51
  f_1 (NULL);
52
  GOMP_parallel_end ();
53
  test_data ();
54
}
55
 
56
static void f_2 (void *dummy)
57
{
58
  int iam = omp_get_thread_num ();
59
  unsigned s;
60
 
61
  while ((s = GOMP_sections_next ()))
62
    set_data (s, iam);
63
  GOMP_sections_end_nowait ();
64
}
65
 
66
static void test_2 (void)
67
{
68
  clean_data ();
69
  GOMP_parallel_sections_start (f_2, NULL, NTHR, N);
70
  f_2 (NULL);
71
  GOMP_parallel_end ();
72
  test_data ();
73
}
74
 
75
int main()
76
{
77
  omp_set_dynamic (0);
78
 
79
  NTHR = 4;
80
 
81
  test_1 ();
82
  test_2 ();
83
 
84
  return 0;
85
}

powered by: WebSVN 2.1.0

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