1 // RUN: %libomp-cxx-compile -fopenmp-version=51
2 // RUN: %libomp-run | FileCheck %s --check-prefix OMP51
8 #pragma omp parallel num_threads(10)
9 { printf("\ntarget: foo(): parallel num_threads(10)"); }
15 printf("\nmain: thread_limit = %d", omp_get_thread_limit());
16 // OMP51: main: thread_limit = {{[0-9]+}}
18 #pragma omp target thread_limit(tl)
20 printf("\ntarget: thread_limit = %d", omp_get_thread_limit());
22 // OMP51: target: thread_limit = 4
23 // check whether thread_limit is honoured
24 #pragma omp parallel reduction(+:count)
26 printf("\ntarget: parallel: count = %d", count
);
27 // OMP51: target: parallel: count = {{(1|2|3|4)$}}
29 // check whether num_threads is honoured
30 #pragma omp parallel num_threads(2)
31 { printf("\ntarget: parallel num_threads(2)"); }
32 // OMP51: target: parallel num_threads(2)
33 // OMP51: target: parallel num_threads(2)
34 // OMP51-NOT: target: parallel num_threads(2)
36 // check whether thread_limit is honoured when there is a conflicting
38 #pragma omp parallel num_threads(10)
39 { printf("\ntarget: parallel num_threads(10)"); }
40 // OMP51: target: parallel num_threads(10)
41 // OMP51: target: parallel num_threads(10)
42 // OMP51: target: parallel num_threads(10)
43 // OMP51: target: parallel num_threads(10)
44 // OMP51-NOT: target: parallel num_threads(10)
46 // check whether threads are limited across functions
48 // OMP51: target: foo(): parallel num_threads(10)
49 // OMP51: target: foo(): parallel num_threads(10)
50 // OMP51: target: foo(): parallel num_threads(10)
51 // OMP51: target: foo(): parallel num_threads(10)
52 // OMP51-NOT: target: foo(): parallel num_threads(10)
54 // check if user can set num_threads at runtime
55 omp_set_num_threads(2);
57 { printf("\ntarget: parallel with omp_set_num_thread(2)"); }
58 // OMP51: target: parallel with omp_set_num_thread(2)
59 // OMP51: target: parallel with omp_set_num_thread(2)
60 // OMP51-NOT: target: parallel with omp_set_num_thread(2)
62 // make sure thread_limit is unaffected by omp_set_num_threads
63 printf("\ntarget: thread_limit = %d", omp_get_thread_limit());
64 // OMP51: target: thread_limit = 4
67 // checking consecutive target regions with different thread_limits
68 #pragma omp target thread_limit(3)
70 printf("\nsecond target: thread_limit = %d", omp_get_thread_limit());
72 // OMP51: second target: thread_limit = 3
73 #pragma omp parallel reduction(+:count)
75 printf("\nsecond target: parallel: count = %d", count
);
76 // OMP51: second target: parallel: count = {{(1|2|3)$}}
79 // confirm that thread_limit's effects are limited to target region
80 printf("\nmain: thread_limit = %d", omp_get_thread_limit());
81 // OMP51: main: thread_limit = {{[0-9]+}}
82 #pragma omp parallel num_threads(10)
83 { printf("\nmain: parallel num_threads(10)"); }
84 // OMP51: main: parallel num_threads(10)
85 // OMP51: main: parallel num_threads(10)
86 // OMP51: main: parallel num_threads(10)
87 // OMP51: main: parallel num_threads(10)
88 // OMP51: main: parallel num_threads(10)
89 // OMP51: main: parallel num_threads(10)
90 // OMP51: main: parallel num_threads(10)
91 // OMP51: main: parallel num_threads(10)
92 // OMP51: main: parallel num_threads(10)
93 // OMP51: main: parallel num_threads(10)
94 // OMP51-NOT: main: parallel num_threads(10)
96 // check combined target directives which support thread_limit
98 #pragma omp target parallel thread_limit(2)
99 printf("\ntarget parallel thread_limit(2)");
100 // OMP51: target parallel thread_limit(2)
101 // OMP51: target parallel thread_limit(2)
102 // OMP51-NOT: target parallel thread_limit(2)
104 #pragma omp target parallel num_threads(2) thread_limit(3)
105 printf("\ntarget parallel num_threads(2) thread_limit(3)");
106 // OMP51: target parallel num_threads(2) thread_limit(3)
107 // OMP51: target parallel num_threads(2) thread_limit(3)
108 // OMP51-NOT: target parallel num_threads(2) thread_limit(3)
110 #pragma omp target parallel num_threads(3) thread_limit(2)
111 printf("\ntarget parallel num_threads(3) thread_limit(2)");
112 // OMP51: target parallel num_threads(3) thread_limit(2)
113 // OMP51: target parallel num_threads(3) thread_limit(2)
114 // OMP51-NOT: target parallel num_threads(3) thread_limit(2)
116 // target parallel for
117 #pragma omp target parallel for thread_limit(2)
118 for (int i
= 0; i
< 5; ++i
)
119 printf("\ntarget parallel for thread_limit(2) : thread num = %d",
120 omp_get_thread_num());
121 // OMP51: target parallel for thread_limit(2) : thread num = {{0|1}}
122 // OMP51: target parallel for thread_limit(2) : thread num = {{0|1}}
123 // OMP51: target parallel for thread_limit(2) : thread num = {{0|1}}
124 // OMP51: target parallel for thread_limit(2) : thread num = {{0|1}}
125 // OMP51: target parallel for thread_limit(2) : thread num = {{0|1}}
126 // OMP51-NOT: target parallel for thread_limit(3) : thread num = {{0|1}}
128 // target parallel for simd
129 #pragma omp target parallel for simd thread_limit(2)
130 for (int i
= 0; i
< 5; ++i
)
131 printf("\ntarget parallel for simd thread_limit(2) : thread num = %d",
132 omp_get_thread_num());
133 // OMP51: target parallel for simd thread_limit(2) : thread num = {{0|1}}
134 // OMP51: target parallel for simd thread_limit(2) : thread num = {{0|1}}
135 // OMP51: target parallel for simd thread_limit(2) : thread num = {{0|1}}
136 // OMP51: target parallel for simd thread_limit(2) : thread num = {{0|1}}
137 // OMP51: target parallel for simd thread_limit(2) : thread num = {{0|1}}
138 // OMP51-NOT: target parallel for simd thread_limit(2) : thread num =
142 #pragma omp target simd thread_limit(2)
143 for (int i
= 0; i
< 5; ++i
)
144 printf("\ntarget simd thread_limit(2) : thread num = %d",
145 omp_get_thread_num());
146 // OMP51: target simd thread_limit(2) : thread num = {{0|1}}
147 // OMP51: target simd thread_limit(2) : thread num = {{0|1}}
148 // OMP51: target simd thread_limit(2) : thread num = {{0|1}}
149 // OMP51: target simd thread_limit(2) : thread num = {{0|1}}
150 // OMP51: target simd thread_limit(2) : thread num = {{0|1}}
151 // OMP51-NOT: target simd thread_limit(2) : thread num = {{0|1}}
153 // target parallel loop
154 #pragma omp target parallel loop thread_limit(2)
155 for (int i
= 0; i
< 5; ++i
)
156 printf("\ntarget parallel loop thread_limit(2) : thread num = %d",
157 omp_get_thread_num());
158 // # OMP51: target parallel loop thread_limit(2) : thread num = {{0|1}}
159 // # OMP51: target parallel loop thread_limit(2) : thread num = {{0|1}}
160 // # OMP51: target parallel loop thread_limit(2) : thread num = {{0|1}}
161 // # OMP51: target parallel loop thread_limit(2) : thread num = {{0|1}}
162 // # OMP51: target parallel loop thread_limit(2) : thread num = {{0|1}}
163 // # OMP51-NOT: target parallel loop thread_limit(2) : thread num = {{0|1}}