Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / openmp / tools / multiplex / tests / print / print.c
blobc492899c69f8cabcdb931a711b4fe78391f8331a
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
8 // For GCC we don't get an event for master,
9 // see runtime/test/ompt/sycnchronization/master.c
10 // UNSUPPORTED: gcc
12 #if defined(FIRST_TOOL)
13 #include "first-tool.h"
14 #elif defined(SECOND_TOOL)
15 #include "second-tool.h"
16 #else /* APP */
18 #include "../ompt-signal.h"
19 #include "omp.h"
20 #include <stdio.h>
22 int main() {
23 int x, s = 0;
24 #pragma omp parallel num_threads(2) shared(s)
26 #pragma omp master
28 #pragma omp task shared(s)
30 omp_control_tool(5, 1, NULL);
31 OMPT_SIGNAL(s);
34 if (omp_get_thread_num() == 1)
35 OMPT_WAIT(s, 1);
37 return 0;
40 // Check if libomp supports the callbacks for this test.
41 // CHECK-NOT: {{^}}0: Could not register callback
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
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]]
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
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
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
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]+}}
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
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]+}}
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]+}}
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]+}}
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
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]+}}
104 // CHECK: {{^}}[[_1ST_MSTR_TID]]: _first_tool: task level 0:
105 // CHECK-SAME: task_id=[[_FIRST_EXPLICIT_TASK_ID]]
107 // CHECK: {{^}}[[_1ST_MSTR_TID]]: _first_tool: task level 1:
108 // CHECK-SAME: task_id=[[_FIRST_MASTER_IMPLICIT_TASK_ID]]
110 // CHECK: {{^}}[[_1ST_MSTR_TID]]: _first_tool: task level 2:
111 // CHECK-SAME: task_id=[[_FIRST_INITIAL_TASK_ID]]
113 // CHECK: {{^}}[[_1ST_MSTR_TID]]: _first_tool: parallel level 0:
114 // CHECK-SAME: parallel_id=[[_FIRST_PARALLEL_ID]]
116 // CHECK: {{^}}[[_1ST_MSTR_TID]]: _first_tool: parallel level 1:
117 // CHECK-SAME: parallel_id={{[0-9]+}}
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
124 // CHECK: {{^}}[[_1ST_MSTR_TID]]: _first_tool: ompt_event_task_end:
125 // CHECK-SAME: task_id=[[_FIRST_EXPLICIT_TASK_ID]]
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)
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)
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
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]+}}
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]]
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
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
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
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]+}}
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
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]+}}
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]+}}
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]+}}
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
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]+}}
202 // CHECK: {{^}}[[_2ND_MSTR_TID]]: second_tool: task level 0:
203 // CHECK-SAME: task_id=[[SECOND_EXPLICIT_TASK_ID]]
205 // CHECK: {{^}}[[_2ND_MSTR_TID]]: second_tool: task level 1:
206 // CHECK-SAME: task_id=[[SECOND_MASTER_IMPLICIT_TASK_ID]]
208 // CHECK: {{^}}[[_2ND_MSTR_TID]]: second_tool: task level 2:
209 // CHECK-SAME: task_id=[[SECOND_INITIAL_TASK_ID]]
211 // CHECK: {{^}}[[_2ND_MSTR_TID]]: second_tool: parallel level 0:
212 // CHECK-SAME: parallel_id=[[SECOND_PARALLEL_ID]]
214 // CHECK: {{^}}[[_2ND_MSTR_TID]]: second_tool: parallel level 1:
215 // CHECK-SAME: parallel_id={{[0-9]+}}
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
222 // CHECK: {{^}}[[_2ND_MSTR_TID]]: second_tool: ompt_event_task_end:
223 // CHECK-SAME: task_id=[[SECOND_EXPLICIT_TASK_ID]]
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)
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)
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
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]+}}
242 // CHECK: {{^}}[[_2ND_MSTR_TID]]: second_tool: ompt_event_thread_end:
243 // CHECK-SAME: thread_id=[[_2ND_MSTR_TID]]
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]]
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
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)
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)
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)
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)
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
273 // CHECK: {{^}}[[_1ST_WRKR_TID]]: _first_tool: ompt_event_thread_end:
274 // CHECK-SAME: thread_id=[[_1ST_WRKR_TID]]
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]]
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
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)
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)
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)
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)
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
305 // CHECK: {{^}}[[_2ND_WRKR_TID]]: second_tool: ompt_event_thread_end:
306 // CHECK-SAME: thread_id=[[_2ND_WRKR_TID]]
308 #endif /* APP */