1 | // RUN: %libomp-compile-and-run | %sort-threads | FileCheck %s |
2 | // REQUIRES: ompt |
3 | // UNSUPPORTED: gcc-4, gcc-5, gcc-6, gcc-7 |
4 | #define TEST_NEED_PRINT_FRAME_FROM_OUTLINED_FN |
5 | #include "callback.h" |
6 | #include <omp.h> |
7 | #include <math.h> |
8 | |
9 | int main() { |
10 | omp_set_nested(0); |
11 | print_frame(0); |
12 | #pragma omp parallel num_threads(2) |
13 | { |
14 | print_frame_from_outlined_fn(1); |
15 | print_ids(0); |
16 | print_ids(1); |
17 | print_frame(0); |
18 | #pragma omp master |
19 | { |
20 | print_ids(0); |
21 | void *creator_frame = get_frame_address(0); |
22 | int t = (int)sin(x: 0.1); |
23 | #pragma omp task if (t) |
24 | { |
25 | if (creator_frame == get_frame_address(0)) { |
26 | printf("Assume this code was inlined which the compiler is allowed to do:\n" ); |
27 | print_frame(0); |
28 | } else if (creator_frame == get_frame_address(1)) { |
29 | printf("Assume this code was called from the application:\n" ); |
30 | print_frame(1); |
31 | } else { |
32 | // The exit frame must be our parent! |
33 | printf("Assume this code was not inlined, exit frame must be our parent:\n" ); |
34 | print_frame_from_outlined_fn(1); |
35 | } |
36 | print_ids(0); |
37 | print_ids(1); |
38 | print_ids(2); |
39 | } |
40 | print_fuzzy_address(1); |
41 | print_ids(0); |
42 | } |
43 | print_ids(0); |
44 | } |
45 | |
46 | // Check if libomp supports the callbacks for this test. |
47 | // CHECK-NOT: {{^}}0: Could not register callback |
48 | |
49 | // CHECK: {{^}}0: NULL_POINTER=[[NULL:.*$]] |
50 | |
51 | // make sure initial data pointers are null |
52 | // CHECK-NOT: 0: new_task_data initially not null |
53 | |
54 | // CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_initial_task_begin: parallel_id={{[0-9]+}} |
55 | // CHECK-SAME: task_id={{[0-9]+}}, actual_parallelism=1, index=1, flags=1 |
56 | |
57 | // CHECK: {{^}}[[MASTER_ID]]: __builtin_frame_address(0) |
58 | // CHECK-SAME: =[[MAIN_REENTER:0x[0-f]+]] |
59 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_parallel_begin |
60 | // CHECK-SAME: parent_task_id=[[PARENT_TASK_ID:[0-9]+]] |
61 | // CHECK-SAME: parent_task_frame.exit=[[NULL]] |
62 | // CHECK-SAME: parent_task_frame.reenter=0x{{[0-f]+}} |
63 | // CHECK-SAME: parallel_id=[[PARALLEL_ID:[0-9]+]], requested_team_size=2 |
64 | // CHECK-SAME: codeptr_ra=0x{{[0-f]+}}, invoker={{[0-9]+}} |
65 | |
66 | // nested parallel masters |
67 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_implicit_task_begin |
68 | // CHECK-SAME: parallel_id=[[PARALLEL_ID]] |
69 | // CHECK-SAME: task_id=[[IMPLICIT_TASK_ID:[0-9]+]] |
70 | // CHECK: {{^}}[[MASTER_ID]]: __builtin_frame_address |
71 | // CHECK-SAME: =[[EXIT:0x[0-f]+]] |
72 | |
73 | // CHECK: {{^}}[[MASTER_ID]]: task level 0 |
74 | // CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID]] |
75 | // CHECK-SAME: exit_frame=[[EXIT]], reenter_frame=[[NULL]] |
76 | |
77 | // CHECK: {{^}}[[MASTER_ID]]: task level 1 |
78 | // CHECK-SAME: parallel_id=[[IMPLICIT_PARALLEL_ID:[0-9]+]] |
79 | // CHECK-SAME: task_id=[[PARENT_TASK_ID]], |
80 | // CHECK-SAME: exit_frame=[[NULL]], reenter_frame=0x{{[0-f]+}} |
81 | |
82 | // CHECK: {{^}}[[MASTER_ID]]: __builtin_frame_address(0)=[[REENTER:0x[0-f]+]] |
83 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_create |
84 | // CHECK-SAME: parent_task_id=[[IMPLICIT_TASK_ID]] |
85 | // CHECK-SAME: parent_task_frame.exit=[[EXIT]] |
86 | // CHECK-SAME: parent_task_frame.reenter=0x{{[0-f]+}} |
87 | // CHECK-SAME: new_task_id=[[TASK_ID:[0-9]+]] |
88 | // CHECK-SAME: codeptr_ra=[[RETURN_ADDRESS:0x[0-f]+]]{{[0-f][0-f]}} |
89 | |
90 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_schedule: |
91 | // CHECK-SAME: first_task_id=[[IMPLICIT_TASK_ID]], second_task_id=[[TASK_ID]] |
92 | // CHECK: {{^}}[[MASTER_ID]]: __builtin_frame_address |
93 | // CHECK-SAME: =[[TASK_EXIT:0x[0-f]+]] |
94 | // CHECK: {{^}}[[MASTER_ID]]: task level 0 |
95 | // CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[TASK_ID]] |
96 | // CHECK-SAME: exit_frame=[[TASK_EXIT]], reenter_frame=[[NULL]] |
97 | |
98 | // CHECK: {{^}}[[MASTER_ID]]: task level 1 |
99 | // CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID]] |
100 | // CHECK-SAME: exit_frame=[[EXIT]], reenter_frame=0x{{[0-f]+}} |
101 | |
102 | // CHECK: {{^}}[[MASTER_ID]]: task level 2 |
103 | // CHECK-SAME: parallel_id=[[IMPLICIT_PARALLEL_ID]] |
104 | // CHECK-SAME: task_id=[[PARENT_TASK_ID]] |
105 | // CHECK-SAME: exit_frame=[[NULL]], reenter_frame=0x{{[0-f]+}} |
106 | |
107 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_schedule |
108 | // CHECK-SAME: first_task_id=[[TASK_ID]], second_task_id=[[IMPLICIT_TASK_ID]] |
109 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_end: task_id=[[TASK_ID]] |
110 | // CHECK: {{^}}[[MASTER_ID]]: fuzzy_address={{.*}}[[RETURN_ADDRESS]] |
111 | |
112 | // CHECK: {{^}}[[MASTER_ID]]: task level 0 |
113 | // CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID]] |
114 | // CHECK-SAME: exit_frame=[[EXIT]], reenter_frame=[[NULL]] |
115 | |
116 | // implicit barrier parallel |
117 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_barrier_begin |
118 | // CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID]] |
119 | // CHECK: {{^}}[[MASTER_ID]]: task level 0 |
120 | // CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID]] |
121 | // CHECK-SAME: exit_frame=[[NULL]], reenter_frame=[[NULL]] |
122 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_barrier_end |
123 | // parallel_id is 0 because the region ended in the barrier! |
124 | // CHECK-SAME: parallel_id=0, task_id=[[IMPLICIT_TASK_ID]] |
125 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_implicit_task_end |
126 | // CHECK-SAME: parallel_id=0, task_id=[[IMPLICIT_TASK_ID]] |
127 | |
128 | // CHECK: {{^}}[[THREAD_ID:[0-9]+]]: ompt_event_implicit_task_begin |
129 | // CHECK-SAME: parallel_id=[[PARALLEL_ID]] |
130 | // CHECK-SAME: task_id=[[IMPLICIT_TASK_ID:[0-9]+]] |
131 | // CHECK: {{^}}[[THREAD_ID]]: __builtin_frame_address |
132 | // CHECK-SAME: =[[EXIT:0x[0-f]+]] |
133 | // CHECK: {{^}}[[THREAD_ID]]: task level 0 |
134 | // CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID]] |
135 | // CHECK-SAME: exit_frame=[[EXIT]], reenter_frame=[[NULL]] |
136 | // CHECK: {{^}}[[THREAD_ID]]: task level 1 |
137 | // CHECK-SAME: parallel_id=[[IMPLICIT_PARALLEL_ID]] |
138 | // CHECK-SAME: task_id=[[PARENT_TASK_ID]] |
139 | // CHECK-SAME: exit_frame=[[NULL]], reenter_frame=0x{{[0-f]+}} |
140 | |
141 | // CHECK: {{^}}[[THREAD_ID]]: __builtin_frame_address(0)={{0x[0-f]+}} |
142 | // CHECK: {{^}}[[THREAD_ID]]: ompt_event_barrier_begin |
143 | // CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID]] |
144 | // CHECK: {{^}}[[THREAD_ID]]: task level 0 |
145 | // CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID]] |
146 | // CHECK-SAME: exit_frame=[[NULL]], reenter_frame=[[NULL]] |
147 | // parallel_id is 0 because the region ended in the barrier! |
148 | // CHECK: {{^}}[[THREAD_ID]]: ompt_event_barrier_end |
149 | // CHECK-SAME: parallel_id=0, task_id=[[IMPLICIT_TASK_ID]] |
150 | |
151 | // CHECK: {{^}}[[THREAD_ID]]: ompt_event_implicit_task_end |
152 | // CHECK-SAME: parallel_id=0, task_id=[[IMPLICIT_TASK_ID]] |
153 | |
154 | return 0; |
155 | } |
156 | |