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