Revert "[InstCombine] Support gep nuw in icmp folds" (#118698)
[llvm-project.git] / openmp / runtime / test / ompt / misc / interoperability.cpp
blob6f17a94c1f40422b1ca2682d54958a788e18d8d1
1 // RUN: %libomp-cxx-compile-and-run | %sort-threads | FileCheck %s
2 // REQUIRES: ompt
4 #include <iostream>
5 #include <thread>
6 #if !defined(__FreeBSD__) && !defined(__NetBSD__)
7 #include <alloca.h>
8 #else
9 #include <cstdlib>
10 #endif
12 #include "callback.h"
13 #include "omp.h"
15 int condition = 0;
17 void f() {
18 // Call OpenMP API function to force initialization of OMPT.
19 // (omp_get_thread_num() does not work because it just returns 0 if the
20 // runtime isn't initialized yet...)
21 omp_get_num_threads();
23 // Call alloca() to force availability of frame pointer
24 void *p = alloca(0);
26 OMPT_SIGNAL(condition);
27 // Wait for both initial threads to arrive that will eventually become the
28 // master threads in the following parallel region.
29 OMPT_WAIT(condition, 2);
31 #pragma omp parallel num_threads(2)
33 // Wait for all threads to arrive so that no worker thread can be reused...
34 OMPT_SIGNAL(condition);
35 OMPT_WAIT(condition, 6);
39 int main() {
40 std::thread t1(f);
41 std::thread t2(f);
42 t1.join();
43 t2.join();
46 // Check if libomp supports the callbacks for this test.
47 // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_task_schedule'
48 // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_parallel_begin'
49 // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_parallel_end'
50 // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_implicit_task'
51 // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_thread_begin'
53 // CHECK: 0: NULL_POINTER=[[NULL:.*$]]
55 // first master thread
56 // CHECK: {{^}}[[MASTER_ID_1:[0-9]+]]: ompt_event_thread_begin:
57 // CHECK-SAME: thread_type=ompt_thread_initial=1, thread_id=[[MASTER_ID_1]]
60 // CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_initial_task_begin: parallel_id={{[0-9]+}}
61 // CHECK-SAME: task_id=[[PARENT_TASK_ID_1:[0-9]+]], actual_parallelism=1,
62 // CHECK-SAME: index=1, flags=1
64 // CHECK: {{^}}[[MASTER_ID_1]]: ompt_event_parallel_begin:
65 // CHECK-SAME: parent_task_id=[[PARENT_TASK_ID_1]]
66 // CHECK-SAME: parent_task_frame.exit=[[NULL]]
67 // CHECK-SAME: parent_task_frame.reenter={{0x[0-f]+}}
68 // CHECK-SAME: parallel_id=[[PARALLEL_ID_1:[0-9]+]], requested_team_size=2
69 // CHECK-SAME: codeptr_ra=0x{{[0-f]+}}, invoker={{.*}}
71 // CHECK: {{^}}[[MASTER_ID_1]]: ompt_event_parallel_end:
72 // CHECK-SAME: parallel_id=[[PARALLEL_ID_1]], task_id=[[PARENT_TASK_ID_1]]
73 // CHECK-SAME: invoker={{[0-9]+}}
75 // CHECK: {{^}}[[MASTER_ID_1]]: ompt_event_initial_task_end:
76 // CHECK-SAME: parallel_id={{[0-9]+}}, task_id=[[PARENT_TASK_ID_1]],
77 // CHECK-SAME: actual_parallelism=0, index=1
79 // CHECK: {{^}}[[MASTER_ID_1]]: ompt_event_thread_end:
80 // CHECK-SAME: thread_id=[[MASTER_ID_1]]
82 // second master thread
83 // CHECK: {{^}}[[MASTER_ID_2:[0-9]+]]: ompt_event_thread_begin:
84 // CHECK-SAME: thread_type=ompt_thread_initial=1, thread_id=[[MASTER_ID_2]]
86 // CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_initial_task_begin: parallel_id={{[0-9]+}}
87 // CHECK-SAME: task_id=[[PARENT_TASK_ID_2:[0-9]+]], actual_parallelism=1,
88 // CHECK-SAME: index=1, flags=1
90 // CHECK: {{^}}[[MASTER_ID_2]]: ompt_event_parallel_begin:
91 // CHECK-SAME: parent_task_id=[[PARENT_TASK_ID_2]]
92 // CHECK-SAME: parent_task_frame.exit=[[NULL]]
93 // CHECK-SAME: parent_task_frame.reenter={{0x[0-f]+}}
94 // CHECK-SAME: parallel_id=[[PARALLEL_ID_2:[0-9]+]]
95 // CHECK-SAME: requested_team_size=2, codeptr_ra=0x{{[0-f]+}}
96 // CHECK-SAME: invoker={{.*}}
98 // CHECK: {{^}}[[MASTER_ID_2]]: ompt_event_parallel_end:
99 // CHECK-SAME: parallel_id=[[PARALLEL_ID_2]], task_id=[[PARENT_TASK_ID_2]]
100 // CHECK-SAME: invoker={{[0-9]+}}
102 // CHECK: {{^}}[[MASTER_ID_2]]: ompt_event_initial_task_end:
103 // CHECK-SAME: parallel_id={{[0-9]+}}, task_id=[[PARENT_TASK_ID_2]],
104 // CHECK-SAME: actual_parallelism=0, index=1
106 // CHECK: {{^}}[[MASTER_ID_2]]: ompt_event_thread_end:
107 // CHECK-SAME: thread_id=[[MASTER_ID_2]]
109 // first worker thread
110 // CHECK: {{^}}[[THREAD_ID_1:[0-9]+]]: ompt_event_thread_begin:
111 // CHECK-SAME: thread_type=ompt_thread_worker=2, thread_id=[[THREAD_ID_1]]
112 // CHECK-NOT: {{^}}[[THREAD_ID_1:[0-9]+]]: ompt_event_initial_task_end:
114 // CHECK: {{^}}[[THREAD_ID_1]]: ompt_event_thread_end:
115 // CHECK-SAME: thread_id=[[THREAD_ID_1]]
117 // second worker thread
118 // CHECK: {{^}}[[THREAD_ID_2:[0-9]+]]: ompt_event_thread_begin:
119 // CHECK-SAME: thread_type=ompt_thread_worker=2, thread_id=[[THREAD_ID_2]]
121 // CHECK: {{^}}[[THREAD_ID_2]]: ompt_event_thread_end:
122 // CHECK-SAME: thread_id=[[THREAD_ID_2]]