aboutsummaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.c/target-6.c
blob: 1c4d8caf0a6b9fc85f08cb81b2fd49616104dd0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/* { dg-additional-options "-Wno-deprecated-declarations" } */

#include <omp.h>
#include <stdlib.h>

int
main ()
{
  omp_set_dynamic (0);
  omp_set_nested (1);
  if (omp_in_parallel ())
    abort ();
  #pragma omp parallel num_threads (3)
    if (omp_get_thread_num () == 2)
      {
	if (!omp_in_parallel ())
	  abort ();
	#pragma omp parallel num_threads (3)
	  if (omp_get_thread_num () == 1)
	    {
	      if (!omp_in_parallel ()
		  || omp_get_level () != 2
		  || omp_get_ancestor_thread_num (0) != 0
		  || omp_get_ancestor_thread_num (1) != 2
		  || omp_get_ancestor_thread_num (2) != 1
		  || omp_get_ancestor_thread_num (3) != -1)
		abort ();
	      #pragma omp target if (0)
		{
		  if (omp_in_parallel ()
		      || omp_get_level () != 0
		      || omp_get_ancestor_thread_num (0) != 0
		      || omp_get_ancestor_thread_num (1) != -1)
		    abort ();
		  #pragma omp parallel num_threads (2)
		  {
		    if (!omp_in_parallel ()
			|| omp_get_level () != 1
			|| omp_get_ancestor_thread_num (0) != 0
			|| omp_get_ancestor_thread_num (1)
			   != omp_get_thread_num ()
			|| omp_get_ancestor_thread_num (2) != -1)
		      abort ();
		  }
		}
	      #pragma omp target if (0)
		{
		  #pragma omp teams thread_limit (2)
		    {
		      #pragma omp distribute dist_schedule(static,1)
		      for (int i = 0; i < 1; ++i)
			if (omp_in_parallel ()
			    || omp_get_level () != 0
			    || omp_get_ancestor_thread_num (0) != 0
			    || omp_get_ancestor_thread_num (1) != -1)
			  abort ();
		      #pragma omp parallel num_threads (2)
		      {
			if (!omp_in_parallel ()
			    || omp_get_level () != 1
			    || omp_get_ancestor_thread_num (0) != 0
			    || omp_get_ancestor_thread_num (1)
			       != omp_get_thread_num ()
			    || omp_get_ancestor_thread_num (2) != -1)
			  abort ();
		      }
		    }
		}
	    }
      }
  return 0;
}