1// RUN: %libomp-compile-and-run | FileCheck %s
2// RUN: %libomp-compile-and-run | %sort-threads \
3// RUN: | FileCheck --check-prefix=THREADS %s
4// REQUIRES: ompt
5#include "callback.h"
6
7int main() {
8#pragma omp parallel num_threads(4)
9 {
10 print_ids(0);
11 print_ids(1);
12 }
13 print_fuzzy_address(1);
14
15 // Check if libomp supports the callbacks for this test.
16 // CHECK-NOT: {{^}}0: Could not register callback
17
18 // CHECK: 0: NULL_POINTER=[[NULL:.*$]]
19
20 // make sure initial data pointers are null
21 // CHECK-NOT: 0: parallel_data initially not null
22 // CHECK-NOT: 0: task_data initially not null
23 // CHECK-NOT: 0: thread_data initially not null
24
25 // Only check callback names, arguments are verified in THREADS below.
26 // CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_parallel_begin
27
28 // CHECK-DAG: {{^}}[[MASTER_ID]]: ompt_event_implicit_task_begin
29 // CHECK-DAG: {{^}}[[MASTER_ID]]: ompt_event_implicit_task_end
30
31 // Note that we cannot ensure that the worker threads have already called
32 // barrier_end and implicit_task_end before parallel_end!
33
34 // CHECK-DAG: {{^}}[[THREAD_ID:[0-9]+]]: ompt_event_implicit_task_begin
35 // CHECK-DAG: {{^}}[[THREAD_ID]]: ompt_event_barrier_begin
36
37 // CHECK-DAG: {{^}}[[THREAD_ID:[0-9]+]]: ompt_event_implicit_task_begin
38 // CHECK-DAG: {{^}}[[THREAD_ID]]: ompt_event_barrier_begin
39
40 // CHECK-DAG: {{^}}[[THREAD_ID:[0-9]+]]: ompt_event_implicit_task_begin
41 // CHECK-DAG: {{^}}[[THREAD_ID]]: ompt_event_barrier_begin
42
43 // CHECK: {{^}}[[MASTER_ID]]: ompt_event_parallel_end
44
45 // THREADS: 0: NULL_POINTER=[[NULL:.*$]]
46 // THREADS: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_thread_begin
47 // THREADS-SAME: thread_type=ompt_thread_initial=1, thread_id=[[MASTER_ID]]
48 // THREADS: {{^}}[[MASTER_ID]]: ompt_event_parallel_begin
49 // THREADS-SAME: parent_task_id=[[PARENT_TASK_ID:[0-9]+]]
50 // THREADS-SAME: parent_task_frame.exit=[[NULL]]
51 // THREADS-SAME: parent_task_frame.reenter={{0x[0-f]+}}
52 // THREADS-SAME: parallel_id=[[PARALLEL_ID:[0-9]+]], requested_team_size=4
53 // THREADS-SAME: codeptr_ra=[[RETURN_ADDRESS:0x[0-f]+]]{{[0-f][0-f]}}
54
55 // THREADS: {{^}}[[MASTER_ID]]: ompt_event_implicit_task_begin
56 // THREADS-SAME: parallel_id=[[PARALLEL_ID]]
57 // THREADS-SAME: task_id=[[IMPLICIT_TASK_ID:[0-9]+]]
58 // THREADS: {{^}}[[MASTER_ID]]: task level 0
59 // THREADS-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID]]
60 // THREADS: {{^}}[[MASTER_ID]]: task level 1
61 // THREADS-SAME: parallel_id=[[IMPLICIT_PARALLEL_ID:[0-9]+]]
62 // THREADS-SAME: task_id=[[PARENT_TASK_ID]]
63 // THREADS-NOT: ompt_event_implicit_task_end
64 // THREADS: {{^}}[[MASTER_ID]]: ompt_event_barrier_begin
65 // THREADS-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID]]
66 // THREADS-SAME: codeptr_ra=[[RETURN_ADDRESS]]{{[0-f][0-f]}}
67 // THREADS: {{^}}[[MASTER_ID]]: task level 0
68 // THREADS-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID]]
69 // THREADS-SAME: exit_frame=[[NULL]], reenter_frame=[[NULL]]
70 // THREADS: {{^}}[[MASTER_ID]]: ompt_event_barrier_end
71 // parallel_id is 0 because the region ended in the barrier!
72 // THREADS-SAME: parallel_id=0, task_id=[[IMPLICIT_TASK_ID]]
73 // THREADS-SAME: codeptr_ra=[[RETURN_ADDRESS]]{{[0-f][0-f]}}
74 // THREADS: {{^}}[[MASTER_ID]]: ompt_event_implicit_task_end
75 // THREADS-SAME: parallel_id=0, task_id=[[IMPLICIT_TASK_ID]]
76
77 // THREADS: {{^}}[[THREAD_ID:[0-9]+]]: ompt_event_thread_begin
78 // THREADS-SAME: thread_type=ompt_thread_worker=2, thread_id=[[THREAD_ID]]
79 // THREADS: {{^}}[[THREAD_ID]]: ompt_event_implicit_task_begin
80 // THREADS-SAME: parallel_id=[[PARALLEL_ID]]
81 // THREADS-SAME: task_id=[[IMPLICIT_TASK_ID:[0-9]+]]
82 // THREADS: {{^}}[[THREAD_ID]]: task level 0
83 // THREADS-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID]]
84 // THREADS: {{^}}[[THREAD_ID]]: task level 1
85 // THREADS-SAME: parallel_id=[[IMPLICIT_PARALLEL_ID]]
86 // THREADS-SAME: task_id=[[PARENT_TASK_ID]]
87 // THREADS-NOT: ompt_event_implicit_task_end
88 // THREADS: {{^}}[[THREAD_ID]]: ompt_event_barrier_begin
89 // THREADS-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID]]
90 // THREADS: {{^}}[[THREAD_ID]]: ompt_event_barrier_end
91 // parallel_id is 0 because the region ended in the barrier!
92 // THREADS-SAME: parallel_id=0, task_id=[[IMPLICIT_TASK_ID]]
93 // THREADS: {{^}}[[THREAD_ID]]: ompt_event_implicit_task_end
94 // THREADS-SAME: parallel_id=0, task_id=[[IMPLICIT_TASK_ID]]
95
96 // THREADS: {{^}}[[THREAD_ID:[0-9]+]]: ompt_event_thread_begin
97 // THREADS-SAME: thread_type=ompt_thread_worker=2, thread_id=[[THREAD_ID]]
98 // THREADS: {{^}}[[THREAD_ID]]: ompt_event_implicit_task_begin
99 // THREADS-SAME: parallel_id=[[PARALLEL_ID]]
100 // THREADS-SAME: task_id=[[IMPLICIT_TASK_ID:[0-9]+]]
101 // THREADS: {{^}}[[THREAD_ID]]: task level 0
102 // THREADS-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID]]
103 // THREADS: {{^}}[[THREAD_ID]]: task level 1
104 // THREADS-SAME: parallel_id=[[IMPLICIT_PARALLEL_ID]]
105 // THREADS-SAME: task_id=[[PARENT_TASK_ID]]
106 // THREADS-NOT: ompt_event_implicit_task_end
107 // THREADS: {{^}}[[THREAD_ID]]: ompt_event_barrier_begin
108 // THREADS-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID]]
109 // THREADS: {{^}}[[THREAD_ID]]: ompt_event_barrier_end
110 // parallel_id is 0 because the region ended in the barrier!
111 // THREADS-SAME: parallel_id=0, task_id=[[IMPLICIT_TASK_ID]]
112 // THREADS: {{^}}[[THREAD_ID]]: ompt_event_implicit_task_end
113 // THREADS-SAME: parallel_id=0, task_id=[[IMPLICIT_TASK_ID]]
114
115 // THREADS: {{^}}[[THREAD_ID:[0-9]+]]: ompt_event_thread_begin
116 // THREADS-SAME: thread_type=ompt_thread_worker=2, thread_id=[[THREAD_ID]]
117 // THREADS: {{^}}[[THREAD_ID]]: ompt_event_implicit_task_begin
118 // THREADS-SAME: parallel_id=[[PARALLEL_ID]]
119 // THREADS-SAME: task_id=[[IMPLICIT_TASK_ID:[0-9]+]]
120 // THREADS: {{^}}[[THREAD_ID]]: task level 0
121 // THREADS-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID]]
122 // THREADS: {{^}}[[THREAD_ID]]: task level 1
123 // THREADS-SAME: parallel_id=[[IMPLICIT_PARALLEL_ID]]
124 // THREADS-SAME: task_id=[[PARENT_TASK_ID]]
125 // THREADS-NOT: ompt_event_implicit_task_end
126 // THREADS: {{^}}[[THREAD_ID]]: ompt_event_barrier_begin
127 // THREADS-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID]]
128 // THREADS: {{^}}[[THREAD_ID]]: ompt_event_barrier_end
129 // parallel_id is 0 because the region ended in the barrier!
130 // THREADS-SAME: parallel_id=0, task_id=[[IMPLICIT_TASK_ID]]
131 // THREADS: {{^}}[[THREAD_ID]]: ompt_event_implicit_task_end
132 // THREADS-SAME: parallel_id=0, task_id=[[IMPLICIT_TASK_ID]]
133
134 return 0;
135}
136

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