1// RUN: %libomp-tool -DFIRST_TOOL -o %t.first.tool.so %s && \
2// RUN: %libomp-tool -DSECOND_TOOL -o %t.second.tool.so %s && \
3// RUN: %libomp-compile && \
4// RUN: env OMP_TOOL_LIBRARIES=%t.first.tool.so \
5// RUN: PRINT_TOOL_LIBRARIES=%t.second.tool.so \
6// RUN: %libomp-run | %sort-threads | FileCheck %s
7
8// For GCC we don't get an event for master,
9// see runtime/test/ompt/sycnchronization/master.c
10// UNSUPPORTED: gcc
11
12#if defined(FIRST_TOOL)
13#include "first-tool.h"
14#elif defined(SECOND_TOOL)
15#include "second-tool.h"
16#else /* APP */
17
18#include "../ompt-signal.h"
19#include "omp.h"
20#include <stdio.h>
21
22int main() {
23 int x, s = 0;
24#pragma omp parallel num_threads(2) shared(s)
25 {
26#pragma omp master
27 {
28#pragma omp task shared(s)
29 {
30 omp_control_tool(5, 1, NULL);
31 OMPT_SIGNAL(s);
32 }
33 }
34 if (omp_get_thread_num() == 1)
35 OMPT_WAIT(s, 1);
36 }
37 return 0;
38}
39
40// Check if libomp supports the callbacks for this test.
41// CHECK-NOT: {{^}}0: Could not register callback
42
43// CHECK: {{^}}0: NULL_POINTER=[[NULL:.*$]]
44// CHECK: {{^}}0: NULL_POINTER=[[NULL]]
45// CHECK: {{^}}0: ompt_event_runtime_shutdown
46// CHECK: {{^}}0: ompt_event_runtime_shutdown
47
48// CHECK: {{^}}[[_1ST_MSTR_TID:[0-9]+]]: _first_tool: ompt_event_thread_begin:
49// CHECK-SAME: thread_type=ompt_thread_initial=1, thread_id=[[_1ST_MSTR_TID]]
50
51// CHECK: {{^}}[[_1ST_MSTR_TID]]: _first_tool: ompt_event_initial_task_begin:
52// CHECK-SAME: parallel_id=[[_FIRST_INIT_PARALLEL_ID:[0-9]+]],
53// CHECK-SAME: task_id=[[_FIRST_INITIAL_TASK_ID:[0-9]+]],
54// CHECK-SAME: actual_parallelism=1, index=1, flags=1
55
56// CHECK: {{^}}[[_1ST_MSTR_TID]]: _first_tool: ompt_event_parallel_begin:
57// CHECK-SAME: parent_task_id=[[_FIRST_INITIAL_TASK_ID]],
58// CHECK-SAME: parent_task_frame.exit=(nil),
59// CHECK-SAME: parent_task_frame.reenter={{0x[0-f]+}},
60// CHECK-SAME: parallel_id=[[_FIRST_PARALLEL_ID:[0-9]+]],
61// CHECK-SAME: requested_team_size=2, codeptr_ra={{0x[0-f]+}}, invoker
62
63// CHECK: {{^}}[[_1ST_MSTR_TID]]: _first_tool: ompt_event_implicit_task_begin:
64// CHECK-SAME: parallel_id=[[_FIRST_PARALLEL_ID]],
65// CHECK-SAME: task_id=[[_FIRST_MASTER_IMPLICIT_TASK_ID:[0-9]+]], team_size=2,
66// CHECK-SAME: thread_num=0
67
68// CHECK: {{^}}[[_1ST_MSTR_TID]]: _first_tool: ompt_event_masked_begin:
69// CHECK-SAME: parallel_id=[[_FIRST_PARALLEL_ID]],
70// CHECK-SAME: task_id=[[_FIRST_MASTER_IMPLICIT_TASK_ID]],
71// CHECK-SAME: codeptr_ra={{0x[0-f]+}}
72
73// CHECK: {{^}}[[_1ST_MSTR_TID]]: _first_tool: ompt_event_task_create:
74// CHECK-SAME: parent_task_id=[[_FIRST_MASTER_IMPLICIT_TASK_ID]],
75// CHECK-SAME: parent_task_frame.exit={{0x[0-f]+}},
76// CHECK-SAME: parent_task_frame.reenter={{0x[0-f]+}},
77// CHECK-SAME: new_task_id=[[_FIRST_EXPLICIT_TASK_ID:[0-9]+]],
78// CHECK-SAME: codeptr_ra={{0x[0-f]+}}, task_type=ompt_task_explicit=4,
79// CHECK-SAME: has_dependences=no
80
81// CHECK: {{^}}[[_1ST_MSTR_TID]]: _first_tool: ompt_event_masked_end:
82// CHECK-SAME: parallel_id=[[_FIRST_PARALLEL_ID]],
83// CHECK-SAME: task_id=[[_FIRST_MASTER_IMPLICIT_TASK_ID]],
84// CHECK-SAME: codeptr_ra={{0x[0-f]+}}
85
86// CHECK: {{^}}[[_1ST_MSTR_TID]]: _first_tool: ompt_event_barrier_begin:
87// CHECK-SAME: parallel_id=[[_FIRST_PARALLEL_ID]],
88// CHECK-SAME: task_id=[[_FIRST_MASTER_IMPLICIT_TASK_ID]],
89// CHECK-SAME: codeptr_ra={{0x[0-f]+}}
90
91// CHECK: {{^}}[[_1ST_MSTR_TID]]: _first_tool: ompt_event_wait_barrier_begin:
92// CHECK-SAME: parallel_id=[[_FIRST_PARALLEL_ID]],
93// CHECK-SAME: task_id=[[_FIRST_MASTER_IMPLICIT_TASK_ID]],
94// CHECK-SAME: codeptr_ra={{0x[0-f]+}}
95
96// CHECK: {{^}}[[_1ST_MSTR_TID]]: _first_tool: ompt_event_task_schedule:
97// CHECK-SAME: first_task_id=[[_FIRST_MASTER_IMPLICIT_TASK_ID]],
98// CHECK-SAME: second_task_id=[[_FIRST_EXPLICIT_TASK_ID]],
99// CHECK-SAME: prior_task_status=ompt_task_switch=7
100
101// CHECK: {{^}}[[_1ST_MSTR_TID]]: _first_tool: ompt_event_control_tool:
102// CHECK-SAME: command=5, modifier=1, arg=(nil), codeptr_ra={{0x[0-f]+}}
103
104// CHECK: {{^}}[[_1ST_MSTR_TID]]: _first_tool: task level 0:
105// CHECK-SAME: task_id=[[_FIRST_EXPLICIT_TASK_ID]]
106
107// CHECK: {{^}}[[_1ST_MSTR_TID]]: _first_tool: task level 1:
108// CHECK-SAME: task_id=[[_FIRST_MASTER_IMPLICIT_TASK_ID]]
109
110// CHECK: {{^}}[[_1ST_MSTR_TID]]: _first_tool: task level 2:
111// CHECK-SAME: task_id=[[_FIRST_INITIAL_TASK_ID]]
112
113// CHECK: {{^}}[[_1ST_MSTR_TID]]: _first_tool: parallel level 0:
114// CHECK-SAME: parallel_id=[[_FIRST_PARALLEL_ID]]
115
116// CHECK: {{^}}[[_1ST_MSTR_TID]]: _first_tool: parallel level 1:
117// CHECK-SAME: parallel_id={{[0-9]+}}
118
119// CHECK: {{^}}[[_1ST_MSTR_TID]]: _first_tool: ompt_event_task_schedule:
120// CHECK-SAME: first_task_id=[[_FIRST_EXPLICIT_TASK_ID]],
121// CHECK-SAME: second_task_id=[[_FIRST_MASTER_IMPLICIT_TASK_ID]],
122// CHECK-SAME: prior_task_status=ompt_task_complete=1
123
124// CHECK: {{^}}[[_1ST_MSTR_TID]]: _first_tool: ompt_event_task_end:
125// CHECK-SAME: task_id=[[_FIRST_EXPLICIT_TASK_ID]]
126
127// CHECK: {{^}}[[_1ST_MSTR_TID]]: _first_tool: ompt_event_wait_barrier_end:
128// CHECK-SAME: parallel_id=0, task_id=[[_FIRST_MASTER_IMPLICIT_TASK_ID]],
129// CHECK-SAME: codeptr_ra=(nil)
130
131// CHECK: {{^}}[[_1ST_MSTR_TID]]: _first_tool: ompt_event_barrier_end:
132// CHECK-SAME: parallel_id=0, task_id=[[_FIRST_MASTER_IMPLICIT_TASK_ID]],
133// CHECK-SAME: codeptr_ra=(nil)
134
135// CHECK: {{^}}[[_1ST_MSTR_TID]]: _first_tool: ompt_event_implicit_task_end:
136// CHECK-SAME: parallel_id=0, task_id=[[_FIRST_MASTER_IMPLICIT_TASK_ID]],
137// CHECK-SAME: team_size=2, thread_num=0
138
139// CHECK: {{^}}[[_1ST_MSTR_TID]]: _first_tool: ompt_event_parallel_end:
140// CHECK-SAME: parallel_id=[[_FIRST_PARALLEL_ID]],
141// CHECK-SAME: task_id=[[_FIRST_INITIAL_TASK_ID]], invoker
142// CHECK-SAME: codeptr_ra={{0x[0-f]+}}
143
144// CHECK: {{^}}[[_1ST_MSTR_TID]]: _first_tool: ompt_event_thread_end:
145// CHECK-SAME: thread_id=[[_1ST_MSTR_TID]]
146// CHECK: {{^}}[[_2ND_MSTR_TID:[0-9]+]]: second_tool: ompt_event_thread_begin:
147// CHECK-SAME: thread_type=ompt_thread_initial=1, thread_id=[[_2ND_MSTR_TID]]
148
149// CHECK: {{^}}[[_2ND_MSTR_TID]]: second_tool: ompt_event_initial_task_begin:
150// CHECK-SAME: parallel_id=[[SECOND_INIT_PARALLEL_ID:[0-9]+]],
151// CHECK-SAME: task_id=[[SECOND_INITIAL_TASK_ID:[0-9]+]],
152// CHECK-SAME: actual_parallelism=1, index=1, flags=1
153
154// CHECK: {{^}}[[_2ND_MSTR_TID]]: second_tool: ompt_event_parallel_begin:
155// CHECK-SAME: parent_task_id=[[SECOND_INITIAL_TASK_ID]],
156// CHECK-SAME: parent_task_frame.exit=(nil),
157// CHECK-SAME: parent_task_frame.reenter={{0x[0-f]+}},
158// CHECK-SAME: parallel_id=[[SECOND_PARALLEL_ID:[0-9]+]],
159// CHECK-SAME: requested_team_size=2, codeptr_ra={{0x[0-f]+}}, invoker
160
161// CHECK: {{^}}[[_2ND_MSTR_TID]]: second_tool: ompt_event_implicit_task_begin:
162// CHECK-SAME: parallel_id=[[SECOND_PARALLEL_ID]],
163// CHECK-SAME: task_id=[[SECOND_MASTER_IMPLICIT_TASK_ID:[0-9]+]], team_size=2,
164// CHECK-SAME: thread_num=0
165
166// CHECK: {{^}}[[_2ND_MSTR_TID]]: second_tool: ompt_event_masked_begin:
167// CHECK-SAME: parallel_id=[[SECOND_PARALLEL_ID]],
168// CHECK-SAME: task_id=[[SECOND_MASTER_IMPLICIT_TASK_ID]],
169// CHECK-SAME: codeptr_ra={{0x[0-f]+}}
170
171// CHECK: {{^}}[[_2ND_MSTR_TID]]: second_tool: ompt_event_task_create:
172// CHECK-SAME: parent_task_id=[[SECOND_MASTER_IMPLICIT_TASK_ID]],
173// CHECK-SAME: parent_task_frame.exit={{0x[0-f]+}},
174// CHECK-SAME: parent_task_frame.reenter={{0x[0-f]+}},
175// CHECK-SAME: new_task_id=[[SECOND_EXPLICIT_TASK_ID:[0-9]+]],
176// CHECK-SAME: codeptr_ra={{0x[0-f]+}}, task_type=ompt_task_explicit=4,
177// CHECK-SAME: has_dependences=no
178
179// CHECK: {{^}}[[_2ND_MSTR_TID]]: second_tool: ompt_event_masked_end:
180// CHECK-SAME: parallel_id=[[SECOND_PARALLEL_ID]],
181// CHECK-SAME: task_id=[[SECOND_MASTER_IMPLICIT_TASK_ID]],
182// CHECK-SAME: codeptr_ra={{0x[0-f]+}}
183
184// CHECK: {{^}}[[_2ND_MSTR_TID]]: second_tool: ompt_event_barrier_begin:
185// CHECK-SAME: parallel_id=[[SECOND_PARALLEL_ID]],
186// CHECK-SAME: task_id=[[SECOND_MASTER_IMPLICIT_TASK_ID]],
187// CHECK-SAME: codeptr_ra={{0x[0-f]+}}
188
189// CHECK: {{^}}[[_2ND_MSTR_TID]]: second_tool: ompt_event_wait_barrier_begin:
190// CHECK-SAME: parallel_id=[[SECOND_PARALLEL_ID]],
191// CHECK-SAME: task_id=[[SECOND_MASTER_IMPLICIT_TASK_ID]],
192// CHECK-SAME: codeptr_ra={{0x[0-f]+}}
193
194// CHECK: {{^}}[[_2ND_MSTR_TID]]: second_tool: ompt_event_task_schedule:
195// CHECK-SAME: first_task_id=[[SECOND_MASTER_IMPLICIT_TASK_ID]],
196// CHECK-SAME: second_task_id=[[SECOND_EXPLICIT_TASK_ID]],
197// CHECK-SAME: prior_task_status=ompt_task_switch=7
198
199// CHECK: {{^}}[[_2ND_MSTR_TID]]: second_tool: ompt_event_control_tool:
200// CHECK-SAME: command=5, modifier=1, arg=(nil), codeptr_ra={{0x[0-f]+}}
201
202// CHECK: {{^}}[[_2ND_MSTR_TID]]: second_tool: task level 0:
203// CHECK-SAME: task_id=[[SECOND_EXPLICIT_TASK_ID]]
204
205// CHECK: {{^}}[[_2ND_MSTR_TID]]: second_tool: task level 1:
206// CHECK-SAME: task_id=[[SECOND_MASTER_IMPLICIT_TASK_ID]]
207
208// CHECK: {{^}}[[_2ND_MSTR_TID]]: second_tool: task level 2:
209// CHECK-SAME: task_id=[[SECOND_INITIAL_TASK_ID]]
210
211// CHECK: {{^}}[[_2ND_MSTR_TID]]: second_tool: parallel level 0:
212// CHECK-SAME: parallel_id=[[SECOND_PARALLEL_ID]]
213
214// CHECK: {{^}}[[_2ND_MSTR_TID]]: second_tool: parallel level 1:
215// CHECK-SAME: parallel_id={{[0-9]+}}
216
217// CHECK: {{^}}[[_2ND_MSTR_TID]]: second_tool: ompt_event_task_schedule:
218// CHECK-SAME: first_task_id=[[SECOND_EXPLICIT_TASK_ID]],
219// CHECK-SAME: second_task_id=[[SECOND_MASTER_IMPLICIT_TASK_ID]],
220// CHECK-SAME: prior_task_status=ompt_task_complete=1
221
222// CHECK: {{^}}[[_2ND_MSTR_TID]]: second_tool: ompt_event_task_end:
223// CHECK-SAME: task_id=[[SECOND_EXPLICIT_TASK_ID]]
224
225// CHECK: {{^}}[[_2ND_MSTR_TID]]: second_tool: ompt_event_wait_barrier_end:
226// CHECK-SAME: parallel_id=0, task_id=[[SECOND_MASTER_IMPLICIT_TASK_ID]],
227// CHECK-SAME: codeptr_ra=(nil)
228
229// CHECK: {{^}}[[_2ND_MSTR_TID]]: second_tool: ompt_event_barrier_end:
230// CHECK-SAME: parallel_id=0, task_id=[[SECOND_MASTER_IMPLICIT_TASK_ID]],
231// CHECK-SAME: codeptr_ra=(nil)
232
233// CHECK: {{^}}[[_2ND_MSTR_TID]]: second_tool: ompt_event_implicit_task_end:
234// CHECK-SAME: parallel_id=0, task_id=[[SECOND_MASTER_IMPLICIT_TASK_ID]],
235// CHECK-SAME: team_size=2, thread_num=0
236
237// CHECK: {{^}}[[_2ND_MSTR_TID]]: second_tool: ompt_event_parallel_end:
238// CHECK-SAME: parallel_id=[[SECOND_PARALLEL_ID]],
239// CHECK-SAME: task_id=[[SECOND_INITIAL_TASK_ID]], invoker
240// CHECK-SAME: codeptr_ra={{0x[0-f]+}}
241
242// CHECK: {{^}}[[_2ND_MSTR_TID]]: second_tool: ompt_event_thread_end:
243// CHECK-SAME: thread_id=[[_2ND_MSTR_TID]]
244
245// CHECK: {{^}}[[_1ST_WRKR_TID:[0-9]+]]: _first_tool: ompt_event_thread_begin:
246// CHECK-SAME: thread_type=ompt_thread_worker=2, thread_id=[[_1ST_WRKR_TID]]
247
248// CHECK: {{^}}[[_1ST_WRKR_TID]]: _first_tool: ompt_event_implicit_task_begin:
249// CHECK-SAME: parallel_id=[[_FIRST_PARALLEL_ID]],
250// CHECK-SAME: task_id=[[_FIRST_WORKER_IMPLICIT_TASK_ID:[0-9]+]], team_size=2,
251// CHECK-SAME: thread_num=1
252
253// CHECK: {{^}}[[_1ST_WRKR_TID]]: _first_tool: ompt_event_barrier_begin:
254// CHECK-SAME: parallel_id=[[_FIRST_PARALLEL_ID]],
255// CHECK-SAME: task_id=[[_FIRST_WORKER_IMPLICIT_TASK_ID]], codeptr_ra=(nil)
256
257// CHECK: {{^}}[[_1ST_WRKR_TID]]: _first_tool: ompt_event_wait_barrier_begin:
258// CHECK-SAME: parallel_id=[[_FIRST_PARALLEL_ID]],
259// CHECK-SAME: task_id=[[_FIRST_WORKER_IMPLICIT_TASK_ID]], codeptr_ra=(nil)
260
261// CHECK: {{^}}[[_1ST_WRKR_TID]]: _first_tool: ompt_event_wait_barrier_end:
262// CHECK-SAME: parallel_id=0, task_id=[[_FIRST_WORKER_IMPLICIT_TASK_ID]],
263// CHECK-SAME: codeptr_ra=(nil)
264
265// CHECK: {{^}}[[_1ST_WRKR_TID]]: _first_tool: ompt_event_barrier_end:
266// CHECK-SAME: parallel_id=0, task_id=[[_FIRST_WORKER_IMPLICIT_TASK_ID]],
267// CHECK-SAME: codeptr_ra=(nil)
268
269// CHECK: {{^}}[[_1ST_WRKR_TID]]: _first_tool: ompt_event_implicit_task_end:
270// CHECK-SAME: parallel_id=0, task_id=[[_FIRST_WORKER_IMPLICIT_TASK_ID]],
271// CHECK-SAME: team_size=0, thread_num=1
272
273// CHECK: {{^}}[[_1ST_WRKR_TID]]: _first_tool: ompt_event_thread_end:
274// CHECK-SAME: thread_id=[[_1ST_WRKR_TID]]
275
276// CHECK: {{^}}[[_2ND_WRKR_TID:[0-9]+]]: second_tool: ompt_event_thread_begin:
277// CHECK-SAME: thread_type=ompt_thread_worker=2,
278// CHECK-SAME: thread_id=[[_2ND_WRKR_TID]]
279
280// CHECK: {{^}}[[_2ND_WRKR_TID]]: second_tool: ompt_event_implicit_task_begin:
281// CHECK-SAME: parallel_id=[[SECOND_PARALLEL_ID]],
282// CHECK-SAME: task_id=[[SECOND_WORKER_IMPLICIT_TASK_ID:[0-9]+]],
283// CHECK-SAME: team_size=2, thread_num=1
284
285// CHECK: {{^}}[[_2ND_WRKR_TID]]: second_tool: ompt_event_barrier_begin:
286// CHECK-SAME: parallel_id=[[SECOND_PARALLEL_ID]],
287// CHECK-SAME: task_id=[[SECOND_WORKER_IMPLICIT_TASK_ID]], codeptr_ra=(nil)
288
289// CHECK: {{^}}[[_2ND_WRKR_TID]]: second_tool: ompt_event_wait_barrier_begin:
290// CHECK-SAME: parallel_id=[[SECOND_PARALLEL_ID]],
291// CHECK-SAME: task_id=[[SECOND_WORKER_IMPLICIT_TASK_ID]], codeptr_ra=(nil)
292
293// CHECK: {{^}}[[_2ND_WRKR_TID]]: second_tool: ompt_event_wait_barrier_end:
294// CHECK-SAME: parallel_id=0, task_id=[[SECOND_WORKER_IMPLICIT_TASK_ID]],
295// CHECK-SAME: codeptr_ra=(nil)
296
297// CHECK: {{^}}[[_2ND_WRKR_TID]]: second_tool: ompt_event_barrier_end:
298// CHECK-SAME: parallel_id=0, task_id=[[SECOND_WORKER_IMPLICIT_TASK_ID]],
299// CHECK-SAME: codeptr_ra=(nil)
300
301// CHECK: {{^}}[[_2ND_WRKR_TID]]: second_tool: ompt_event_implicit_task_end:
302// CHECK-SAME: parallel_id=0, task_id=[[SECOND_WORKER_IMPLICIT_TASK_ID]],
303// CHECK-SAME: team_size=0, thread_num=1
304
305// CHECK: {{^}}[[_2ND_WRKR_TID]]: second_tool: ompt_event_thread_end:
306// CHECK-SAME: thread_id=[[_2ND_WRKR_TID]]
307
308#endif /* APP */
309

source code of openmp/tools/multiplex/tests/print/print.c