1// RUN: %libomp-compile-and-run | FileCheck %s
2// RUN: %libomp-compile-and-run | %sort-threads | FileCheck --check-prefix=THREADS %s
3// REQUIRES: ompt
4// UNSUPPORTED: gcc-4, gcc-5, gcc-6, gcc-7
5#define TEST_NEED_PRINT_FRAME_FROM_OUTLINED_FN
6#include "callback.h"
7#include <omp.h>
8#include <unistd.h>
9
10int main() {
11 int condition = 0;
12 omp_set_nested(1);
13 print_frame(0);
14
15#pragma omp parallel num_threads(2)
16 {
17 print_frame_from_outlined_fn(1);
18 print_ids(0);
19 print_ids(1);
20 print_frame(0);
21
22// get all implicit task events before starting nested:
23#pragma omp barrier
24
25#pragma omp parallel num_threads(2)
26 {
27 print_frame_from_outlined_fn(1);
28 print_ids(0);
29 print_ids(1);
30 print_ids(2);
31 print_frame(0);
32 OMPT_SIGNAL(condition);
33 OMPT_WAIT(condition, 4);
34#pragma omp barrier
35 print_fuzzy_address(1);
36 print_ids(0);
37 }
38 print_fuzzy_address(2);
39 print_ids(0);
40 }
41 print_fuzzy_address(3);
42
43 return 0;
44}
45// Check if libomp supports the callbacks for this test.
46// CHECK-NOT: {{^}}0: Could not register callback
47
48// CHECK: 0: NULL_POINTER=[[NULL:.*$]]
49
50// make sure initial data pointers are null
51// CHECK-NOT: 0: parallel_data initially not null
52// CHECK-NOT: 0: task_data initially not null
53// CHECK-NOT: 0: thread_data initially not null
54
55// CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_parallel_begin:
56// CHECK-SAME: parent_task_id=[[PARENT_TASK_ID:[0-9]+]],
57// CHECK-SAME: parent_task_frame.exit=[[NULL]],
58// CHECK-SAME: parent_task_frame.reenter={{0x[0-f]+}},
59// CHECK-SAME: parallel_id=[[PARALLEL_ID:[0-9]+]],
60// CHECK-SAME: requested_team_size=2,
61// CHECK-SAME: codeptr_ra=[[RETURN_ADDRESS:0x[0-f]+]]{{[0-f][0-f]}},
62// CHECK-SAME: invoker=[[PARALLEL_INVOKER:[0-9]+]]
63
64// CHECK-DAG: {{^}}[[MASTER_ID]]: ompt_event_implicit_task_begin:
65// CHECK-DAG: {{^}}[[MASTER_ID]]: ompt_event_implicit_task_end:
66
67// Note that we cannot ensure that the worker threads have already called
68// barrier_end and implicit_task_end before parallel_end!
69
70// CHECK-DAG: {{^}}[[THREAD_ID:[0-9]+]]: ompt_event_implicit_task_begin:
71// CHECK-DAG: {{^}}[[THREAD_ID]]: ompt_event_barrier_begin:
72
73
74// CHECK: ompt_event_parallel_end: parallel_id=[[PARALLEL_ID]],
75// CHECK-SAME: task_id=[[PARENT_TASK_ID]], invoker=[[PARALLEL_INVOKER]]
76// CHECK: {{^}}[[MASTER_ID]]: fuzzy_address={{.*}}[[RETURN_ADDRESS]]
77
78// THREADS: {{^}}0: NULL_POINTER=[[NULL:.*$]]
79// THREADS: __builtin_frame_address(0)=[[MAIN_REENTER:0x[0-f]+]]
80// THREADS: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_parallel_begin:
81// THREADS-SAME: parent_task_id=[[PARENT_TASK_ID:[0-9]+]],
82// THREADS-SAME: parent_task_frame.exit=[[NULL]],
83// THREADS-SAME: parent_task_frame.reenter=0x{{[0-f]+}},
84// THREADS-SAME: parallel_id=[[PARALLEL_ID:[0-9]+]], requested_team_size=2,
85// THREADS-SAME: codeptr_ra=[[RETURN_ADDRESS:0x[0-f]+]]{{[0-f][0-f]}},
86// THREADS-SAME: invoker=[[PARALLEL_INVOKER:[0-9]+]]
87
88// nested parallel masters
89// THREADS: {{^}}[[MASTER_ID]]: ompt_event_implicit_task_begin:
90// THREADS-SAME: parallel_id=[[PARALLEL_ID]],
91// THREADS-SAME: task_id=[[IMPLICIT_TASK_ID:[0-9]+]],
92// THREADS-SAME: team_size=2, thread_num=0
93
94// THREADS: __builtin_frame_address({{.}})=[[EXIT:0x[0-f]+]]
95
96// THREADS: {{^}}[[MASTER_ID]]: task level 0: parallel_id=[[PARALLEL_ID]],
97// THREADS-SAME: task_id=[[IMPLICIT_TASK_ID]], exit_frame=[[EXIT]],
98// THREADS-SAME: reenter_frame=[[NULL]],
99// THREADS-SAME: thread_num=0
100
101// THREADS: {{^}}[[MASTER_ID]]: task level 1:
102// THREADS-SAME: parallel_id=[[IMPLICIT_PARALLEL_ID:[0-9]+]],
103// THREADS-SAME: task_id=[[PARENT_TASK_ID]], exit_frame=[[NULL]],
104// THREADS-SAME: reenter_frame=0x{{[0-f]+}}
105
106// THREADS: __builtin_frame_address(0)=[[REENTER:0x[0-f]+]]
107
108// THREADS: {{^}}[[MASTER_ID]]: ompt_event_parallel_begin:
109// THREADS-SAME: parent_task_id=[[IMPLICIT_TASK_ID]],
110// THREADS-SAME: parent_task_frame.exit=[[EXIT]],
111// THREADS-SAME: parent_task_frame.reenter=0x{{[0-f]+}},
112// THREADS-SAME: parallel_id=[[NESTED_PARALLEL_ID:[0-9]+]],
113// THREADS-SAME: requested_team_size=2,
114// THREADS-SAME: codeptr_ra=[[NESTED_RETURN_ADDRESS:0x[0-f]+]]{{[0-f][0-f]}},
115// THREADS-SAME: invoker=[[PARALLEL_INVOKER]]
116
117// THREADS: {{^}}[[MASTER_ID]]: ompt_event_implicit_task_begin:
118// THREADS-SAME: parallel_id=[[NESTED_PARALLEL_ID]],
119// THREADS-SAME: task_id=[[NESTED_IMPLICIT_TASK_ID:[0-9]+]], team_size=2,
120// THREADS-SAME: thread_num=0
121
122// THREADS: __builtin_frame_address({{.}})=[[NESTED_EXIT:0x[0-f]+]]
123
124// THREADS: {{^}}[[MASTER_ID]]: task level 0:
125// THREADS-SAME: parallel_id=[[NESTED_PARALLEL_ID]],
126// THREADS-SAME: task_id=[[NESTED_IMPLICIT_TASK_ID]],
127// THREADS-SAME: exit_frame=[[NESTED_EXIT]], reenter_frame=[[NULL]],
128// THREADS-SAME: thread_num=0
129
130// THREADS: {{^}}[[MASTER_ID]]: task level 1: parallel_id=[[PARALLEL_ID]],
131// THREADS-SAME: task_id=[[IMPLICIT_TASK_ID]], exit_frame=[[EXIT]],
132// THREADS-SAME: reenter_frame=0x{{[0-f]+}}
133
134// THREADS: {{^}}[[MASTER_ID]]: task level 2:
135// THREADS-SAME: parallel_id=[[IMPLICIT_PARALLEL_ID]],
136// THREADS-SAME: task_id=[[PARENT_TASK_ID]], exit_frame=[[NULL]],
137// THREADS-SAME: reenter_frame=0x{{[0-f]+}}
138
139// THREADS: __builtin_frame_address(0)=[[NESTED_REENTER:0x[0-f]+]]
140
141// THREADS-NOT: {{^}}[[MASTER_ID]]: ompt_event_implicit_task_end
142// explicit barrier
143
144// THREADS: {{^}}[[MASTER_ID]]: ompt_event_barrier_begin:
145// THREADS-SAME: parallel_id=[[NESTED_PARALLEL_ID]],
146// THREADS-SAME: task_id=[[NESTED_IMPLICIT_TASK_ID]],
147// THREADS-SAME: codeptr_ra=[[BARRIER_RETURN_ADDRESS:0x[0-f]+]]{{[0-f][0-f]}}
148
149// THREADS: {{^}}[[MASTER_ID]]: task level 0:
150// THREADS-SAME: parallel_id=[[NESTED_PARALLEL_ID]],
151// THREADS-SAME: task_id=[[NESTED_IMPLICIT_TASK_ID]],
152// THREADS-SAME: exit_frame=[[NESTED_EXIT]], reenter_frame=0x{{[0-f]+}}
153
154// THREADS: {{^}}[[MASTER_ID]]: ompt_event_barrier_end:
155// THREADS-SAME: parallel_id=[[NESTED_PARALLEL_ID]],
156// THREADS-SAME: task_id=[[NESTED_IMPLICIT_TASK_ID]]
157
158// THREADS: {{^}}[[MASTER_ID]]: fuzzy_address={{.*}}[[BARRIER_RETURN_ADDRESS]]
159
160// THREADS: {{^}}[[MASTER_ID]]: task level 0:
161// THREADS-SAME: parallel_id=[[NESTED_PARALLEL_ID]],
162// THREADS-SAME: task_id=[[NESTED_IMPLICIT_TASK_ID]],
163// THREADS-SAME: exit_frame=[[NESTED_EXIT]], reenter_frame=[[NULL]]
164
165// implicit barrier
166// THREADS: {{^}}[[MASTER_ID]]: ompt_event_barrier_begin:
167// THREADS-SAME: parallel_id=[[NESTED_PARALLEL_ID]],
168// THREADS-SAME: task_id=[[NESTED_IMPLICIT_TASK_ID]],
169// THREADS-SAME: codeptr_ra=[[NESTED_RETURN_ADDRESS]]{{[0-f][0-f]}}
170
171// THREADS: {{^}}[[MASTER_ID]]: task level 0:
172// THREADS-SAME: parallel_id=[[NESTED_PARALLEL_ID]],
173// THREADS-SAME: task_id=[[NESTED_IMPLICIT_TASK_ID]],
174// THREADS-SAME: exit_frame=[[NULL]], reenter_frame=[[NULL]]
175
176// THREADS: {{^}}[[MASTER_ID]]: ompt_event_barrier_end:
177// THREADS-SAME: parallel_id={{[0-9]+}}, task_id=[[NESTED_IMPLICIT_TASK_ID]],
178// THREADS-SAME: codeptr_ra=[[NESTED_RETURN_ADDRESS]]{{[0-f][0-f]}}
179
180// THREADS: {{^}}[[MASTER_ID]]: ompt_event_implicit_task_end:
181// THREADS-SAME: parallel_id={{[0-9]+}}, task_id=[[NESTED_IMPLICIT_TASK_ID]]
182
183// THREADS: {{^}}[[MASTER_ID]]: ompt_event_parallel_end:
184// THREADS-SAME: parallel_id=[[NESTED_PARALLEL_ID]],
185// THREADS-SAME: task_id=[[IMPLICIT_TASK_ID]],
186// THREADS-SAME: invoker=[[PARALLEL_INVOKER]],
187// THREADS-SAME: codeptr_ra=[[NESTED_RETURN_ADDRESS]]{{[0-f][0-f]}}
188
189// THREADS: {{^}}[[MASTER_ID]]: fuzzy_address={{.*}}[[NESTED_RETURN_ADDRESS]]
190
191// THREADS-NOT: {{^}}[[MASTER_ID]]: ompt_event_implicit_task_end
192
193// THREADS: {{^}}[[MASTER_ID]]: task level 0: parallel_id=[[PARALLEL_ID]],
194// THREADS-SAME: task_id=[[IMPLICIT_TASK_ID]], exit_frame=[[EXIT]],
195// THREADS-SAME: reenter_frame=[[NULL]]
196
197// implicit barrier
198// THREADS: {{^}}[[MASTER_ID]]: ompt_event_barrier_begin:
199// THREADS-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID]],
200// THREADS-SAME: codeptr_ra=[[RETURN_ADDRESS]]{{[0-f][0-f]}}
201
202// THREADS: {{^}}[[MASTER_ID]]: task level 0: parallel_id=[[PARALLEL_ID]],
203// THREADS-SAME: task_id=[[IMPLICIT_TASK_ID]], exit_frame=[[NULL]],
204// THREADS-SAME: reenter_frame=[[NULL]]
205
206// THREADS: {{^}}[[MASTER_ID]]: ompt_event_barrier_end:
207// THREADS-SAME: parallel_id={{[0-9]+}}, task_id=[[IMPLICIT_TASK_ID]],
208// THREADS-SAME: codeptr_ra=[[RETURN_ADDRESS]]{{[0-f][0-f]}}
209
210// THREADS: {{^}}[[MASTER_ID]]: ompt_event_implicit_task_end:
211// THREADS-SAME: parallel_id={{[0-9]+}}, task_id=[[IMPLICIT_TASK_ID]]
212
213// THREADS: {{^}}[[MASTER_ID]]: ompt_event_parallel_end:
214// THREADS-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[PARENT_TASK_ID]],
215// THREADS-SAME: invoker=[[PARALLEL_INVOKER]],
216// THREADS-SAME: codeptr_ra=[[RETURN_ADDRESS]]{{[0-f][0-f]}}
217
218// THREADS: {{^}}[[MASTER_ID]]: fuzzy_address={{.*}}[[RETURN_ADDRESS]]
219
220// Worker of first nesting level
221
222// THREADS: {{^}}[[THREAD_ID:[0-9]+]]: ompt_event_implicit_task_begin:
223// THREADS-SAME: parallel_id=[[PARALLEL_ID]],
224// THREADS-SAME: task_id=[[IMPLICIT_TASK_ID:[0-9]+]], team_size=2,
225// THREADS-SAME: thread_num=[[OUTER_THREADNUM:[0-9]+]]
226
227// THREADS: {{^}}[[THREAD_ID]]: task level 0: parallel_id=[[PARALLEL_ID]],
228// THREADS-SAME: task_id=[[IMPLICIT_TASK_ID]],
229// THREADS-SAME: thread_num=[[OUTER_THREADNUM]]
230
231// THREADS: {{^}}[[THREAD_ID]]: task level 1:
232// THREADS-SAME: parallel_id=[[IMPLICIT_PARALLEL_ID]],
233// THREADS-SAME: task_id=[[PARENT_TASK_ID]]
234
235// THREADS: {{^}}[[THREAD_ID]]: ompt_event_parallel_begin:
236// THREADS-SAME: parent_task_id=[[IMPLICIT_TASK_ID]],
237// THREADS-SAME: parent_task_frame.exit={{0x[0-f]+}},
238// THREADS-SAME: parent_task_frame.reenter={{0x[0-f]+}},
239// THREADS-SAME: parallel_id=[[NESTED_PARALLEL_ID:[0-9]+]], requested_team_size=2,
240// THREADS-SAME: codeptr_ra=[[NESTED_RETURN_ADDRESS]]{{[0-f][0-f]}},
241// THREADS-SAME: invoker=[[PARALLEL_INVOKER]]
242
243// THREADS: {{^}}[[THREAD_ID]]: ompt_event_implicit_task_begin:
244// THREADS-SAME: parallel_id=[[NESTED_PARALLEL_ID]],
245// THREADS-SAME: task_id=[[NESTED_IMPLICIT_TASK_ID:[0-9]+]], team_size=2,
246// THREADS-SAME: thread_num=[[INNER_THREADNUM:[0-9]+]]
247
248// THREADS: {{^}}[[THREAD_ID]]: task level 0:
249// THREADS-SAME: parallel_id=[[NESTED_PARALLEL_ID]],
250// THREADS-SAME: task_id=[[NESTED_IMPLICIT_TASK_ID]],
251// THREADS-SAME: thread_num=[[INNER_THREADNUM]]
252
253// THREADS: {{^}}[[THREAD_ID]]: task level 1: parallel_id=[[PARALLEL_ID]],
254// THREADS-SAME: task_id=[[IMPLICIT_TASK_ID]],
255// THREADS-SAME: thread_num=[[OUTER_THREADNUM]]
256
257// THREADS: {{^}}[[THREAD_ID]]: task level 2:
258// THREADS-SAME: parallel_id=[[IMPLICIT_PARALLEL_ID]],
259// THREADS-SAME: task_id=[[PARENT_TASK_ID]]
260
261// THREADS-NOT: {{^}}[[THREAD_ID]]: ompt_event_implicit_task_end
262
263// THREADS: {{^}}[[THREAD_ID]]: ompt_event_barrier_begin:
264// THREADS-SAME: parallel_id=[[NESTED_PARALLEL_ID]],
265// THREADS-SAME: task_id=[[NESTED_IMPLICIT_TASK_ID]]
266
267// THREADS: {{^}}[[THREAD_ID]]: ompt_event_barrier_end:
268// THREADS-SAME: parallel_id={{[0-9]+}}, task_id=[[NESTED_IMPLICIT_TASK_ID]]
269
270// THREADS: {{^}}[[THREAD_ID]]: ompt_event_implicit_task_end:
271// THREADS-SAME: parallel_id={{[0-9]+}}, task_id=[[NESTED_IMPLICIT_TASK_ID]]
272
273// THREADS: {{^}}[[THREAD_ID]]: ompt_event_parallel_end:
274// THREADS-SAME: parallel_id=[[NESTED_PARALLEL_ID]],
275// THREADS-SAME: task_id=[[IMPLICIT_TASK_ID]], invoker=[[PARALLEL_INVOKER]]
276
277// THREADS-NOT: {{^}}[[THREAD_ID]]: ompt_event_implicit_task_end
278
279// THREADS: {{^}}[[THREAD_ID]]: ompt_event_barrier_begin:
280// THREADS-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID]]
281
282// THREADS: {{^}}[[THREAD_ID]]: ompt_event_barrier_end:
283// THREADS-SAME: parallel_id={{[0-9]+}}, task_id=[[IMPLICIT_TASK_ID]]
284
285// THREADS: {{^}}[[THREAD_ID]]: ompt_event_implicit_task_end:
286// THREADS-SAME: parallel_id={{[0-9]+}}, task_id=[[IMPLICIT_TASK_ID]]
287
288// nested parallel worker threads
289
290// THREADS: {{^}}[[THREAD_ID:[0-9]+]]: ompt_event_implicit_task_begin:
291// THREADS-SAME: parallel_id=[[NESTED_PARALLEL_ID:[0-9]+]],
292// THREADS-SAME: task_id=[[IMPLICIT_TASK_ID:[0-9]+]]
293// THREADS-SAME: thread_num=[[THREADNUM:[0-9]+]]
294
295// THREADS: {{^}}[[THREAD_ID]]: task level 0:
296// THREADS-SAME: parallel_id=[[NESTED_PARALLEL_ID]],
297// THREADS-SAME: task_id=[[IMPLICIT_TASK_ID]]
298// THREADS-SAME: thread_num=[[THREADNUM]]
299
300// can't reliably tell which parallel region is the parent...
301
302// THREADS: {{^}}[[THREAD_ID]]: task level 1: parallel_id={{[0-9]+}},
303// THREADS-SAME: task_id={{[0-9]+}}
304// THREADS-SAME: thread_num={{[01]}}
305
306// THREADS: {{^}}[[THREAD_ID]]: task level 2:
307// THREADS-SAME: parallel_id=[[IMPLICIT_PARALLEL_ID]],
308// THREADS-SAME: task_id=[[PARENT_TASK_ID]]
309// THREADS-SAME: thread_num=0
310
311// THREADS-NOT: {{^}}[[THREAD_ID]]: ompt_event_implicit_task_end
312
313// THREADS: {{^}}[[THREAD_ID]]: ompt_event_barrier_begin:
314// THREADS-SAME: parallel_id=[[NESTED_PARALLEL_ID]],
315// THREADS-SAME: task_id=[[IMPLICIT_TASK_ID]]
316
317// THREADS: {{^}}[[THREAD_ID]]: ompt_event_barrier_end:
318// THREADS-SAME: parallel_id={{[0-9]+}}, task_id=[[IMPLICIT_TASK_ID]]
319
320// THREADS: {{^}}[[THREAD_ID]]: ompt_event_implicit_task_end:
321// THREADS-SAME: parallel_id={{[0-9]+}}, task_id=[[IMPLICIT_TASK_ID]]
322
323// other nested parallel worker threads
324
325// THREADS: {{^}}[[THREAD_ID:[0-9]+]]: ompt_event_implicit_task_begin:
326// THREADS-SAME: parallel_id=[[NESTED_PARALLEL_ID:[0-9]+]],
327// THREADS-SAME: task_id=[[IMPLICIT_TASK_ID:[0-9]+]]
328// THREADS-SAME: thread_num=[[THREADNUM:[0-9]+]]
329
330// THREADS: {{^}}[[THREAD_ID]]: task level 0:
331// THREADS-SAME: parallel_id=[[NESTED_PARALLEL_ID]],
332// THREADS-SAME: task_id=[[IMPLICIT_TASK_ID]]
333// THREADS-SAME: thread_num=[[THREADNUM]]
334
335// can't reliably tell which parallel region is the parent...
336
337// THREADS: {{^}}[[THREAD_ID]]: task level 1: parallel_id={{[0-9]+}},
338// THREADS-SAME: task_id={{[0-9]+}}
339// THREADS-SAME: thread_num={{[01]}}
340
341// THREADS: {{^}}[[THREAD_ID]]: task level 2:
342// THREADS-SAME: parallel_id=[[IMPLICIT_PARALLEL_ID]],
343// THREADS-SAME: task_id=[[PARENT_TASK_ID]]
344// THREADS-SAME: thread_num=0
345
346// THREADS-NOT: {{^}}[[THREAD_ID]]: ompt_event_implicit_task_end
347
348// THREADS: {{^}}[[THREAD_ID]]: ompt_event_barrier_begin:
349// THREADS-SAME: parallel_id=[[NESTED_PARALLEL_ID]],
350// THREADS-SAME: task_id=[[IMPLICIT_TASK_ID]]
351
352// THREADS: {{^}}[[THREAD_ID]]: ompt_event_barrier_end:
353// THREADS-SAME: parallel_id={{[0-9]+}}, task_id=[[IMPLICIT_TASK_ID]]
354
355// THREADS: {{^}}[[THREAD_ID]]: ompt_event_implicit_task_end:
356// THREADS-SAME: parallel_id={{[0-9]+}}, task_id=[[IMPLICIT_TASK_ID]]
357
358

source code of openmp/runtime/test/ompt/parallel/nested_thread_num.c