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

Subversion Repositories openrisc

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

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

Line No. Rev Author Line
1 735 jeremybenn
/* Trivial test of single.  */
2
 
3
/* { dg-require-effective-target sync_int_long } */
4
 
5
#include <omp.h>
6
#include <sys/time.h>
7
#include <unistd.h>
8
#include <assert.h>
9
#include "libgomp_g.h"
10
 
11
 
12
static int test;
13
 
14
static void f_nocopy (void *dummy)
15
{
16
  if (GOMP_single_start ())
17
    {
18
      int iam = omp_get_thread_num ();
19
      int old = __sync_lock_test_and_set (&test, iam);
20
      assert (old == -1);
21
    }
22
}
23
 
24
static void f_copy (void *dummy)
25
{
26
  int *x = GOMP_single_copy_start ();
27
  if (x == NULL)
28
    {
29
      int iam = omp_get_thread_num ();
30
      int old = __sync_lock_test_and_set (&test, iam);
31
      assert (old == -1);
32
      GOMP_single_copy_end (&test);
33
    }
34
  else
35
    assert (x == &test);
36
}
37
 
38
int main()
39
{
40
  omp_set_dynamic (0);
41
 
42
  test = -1;
43
  GOMP_parallel_start (f_nocopy, NULL, 3);
44
  f_nocopy (NULL);
45
  GOMP_parallel_end ();
46
 
47
  test = -1;
48
  GOMP_parallel_start (f_copy, NULL, 3);
49
  f_copy (NULL);
50
  GOMP_parallel_end ();
51
 
52
  return 0;
53
}

powered by: WebSVN 2.1.0

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