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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [libgomp/] [testsuite/] [libgomp.c/] [lib-1.c] - Blame information for rev 861

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

Line No. Rev Author Line
1 273 jeremybenn
#include <stdlib.h>
2
#include <omp.h>
3
 
4
int
5
main (void)
6
{
7
  double d, e;
8
  int l;
9
  omp_lock_t lck;
10
  omp_nest_lock_t nlck;
11
 
12
  d = omp_get_wtime ();
13
 
14
  omp_init_lock (&lck);
15
  omp_set_lock (&lck);
16
  if (omp_test_lock (&lck))
17
    abort ();
18
  omp_unset_lock (&lck);
19
  if (! omp_test_lock (&lck))
20
    abort ();
21
  if (omp_test_lock (&lck))
22
    abort ();
23
  omp_unset_lock (&lck);
24
  omp_destroy_lock (&lck);
25
 
26
  omp_init_nest_lock (&nlck);
27
  if (omp_test_nest_lock (&nlck) != 1)
28
    abort ();
29
  omp_set_nest_lock (&nlck);
30
  if (omp_test_nest_lock (&nlck) != 3)
31
    abort ();
32
  omp_unset_nest_lock (&nlck);
33
  omp_unset_nest_lock (&nlck);
34
  if (omp_test_nest_lock (&nlck) != 2)
35
    abort ();
36
  omp_unset_nest_lock (&nlck);
37
  omp_unset_nest_lock (&nlck);
38
  omp_destroy_nest_lock (&nlck);
39
 
40
  omp_set_dynamic (1);
41
  if (! omp_get_dynamic ())
42
    abort ();
43
  omp_set_dynamic (0);
44
  if (omp_get_dynamic ())
45
    abort ();
46
 
47
  omp_set_nested (1);
48
  if (! omp_get_nested ())
49
    abort ();
50
  omp_set_nested (0);
51
  if (omp_get_nested ())
52
    abort ();
53
 
54
  omp_set_num_threads (5);
55
  if (omp_get_num_threads () != 1)
56
    abort ();
57
  if (omp_get_max_threads () != 5)
58
    abort ();
59
  if (omp_get_thread_num () != 0)
60
    abort ();
61
  omp_set_num_threads (3);
62
  if (omp_get_num_threads () != 1)
63
    abort ();
64
  if (omp_get_max_threads () != 3)
65
    abort ();
66
  if (omp_get_thread_num () != 0)
67
    abort ();
68
  l = 0;
69
#pragma omp parallel reduction (|:l)
70
  {
71
    l = omp_get_num_threads () != 3;
72
    l |= omp_get_thread_num () < 0;
73
    l |= omp_get_thread_num () >= 3;
74
#pragma omp master
75
    l |= omp_get_thread_num () != 0;
76
  }
77
  if (l)
78
    abort ();
79
 
80
  if (omp_get_num_procs () <= 0)
81
    abort ();
82
  if (omp_in_parallel ())
83
    abort ();
84
#pragma omp parallel reduction (|:l)
85
  l = ! omp_in_parallel ();
86
#pragma omp parallel reduction (|:l) if (1)
87
  l = ! omp_in_parallel ();
88
 
89
  e = omp_get_wtime ();
90
  if (d > e)
91
    abort ();
92
  d = omp_get_wtick ();
93
  /* Negative precision is definitely wrong,
94
     bigger than 1s clock resolution is also strange.  */
95
  if (d <= 0 || d > 1)
96
    abort ();
97
 
98
  return 0;
99
}

powered by: WebSVN 2.1.0

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