[llvm] Stop including unordered_map (NFC)
[llvm-project.git] / openmp / runtime / test / ompt / misc / api_calls_from_other_thread.cpp
blobe2ef1fcdcc77e4c002e8da05f451f797cd6999a9
1 // RUN: %libomp-cxx-compile-and-run | FileCheck %s
2 // REQUIRES: ompt, linux
4 #include <thread>
5 #include "callback.h"
7 void f() {
8 ompt_data_t *tdata = ompt_get_thread_data();
9 uint64_t tvalue = tdata ? tdata->value : 0;
11 printf("%" PRIu64 ": ompt_get_num_places()=%d\n", tvalue,
12 ompt_get_num_places());
14 printf("%" PRIu64 ": ompt_get_place_proc_ids()=%d\n", tvalue,
15 ompt_get_place_proc_ids(0, 0, NULL));
17 printf("%" PRIu64 ": ompt_get_place_num()=%d\n", tvalue,
18 ompt_get_place_num());
20 printf("%" PRIu64 ": ompt_get_partition_place_nums()=%d\n", tvalue,
21 ompt_get_partition_place_nums(0, NULL));
23 printf("%" PRIu64 ": ompt_get_proc_id()=%d\n", tvalue, ompt_get_proc_id());
25 printf("%" PRIu64 ": ompt_get_num_procs()=%d\n", tvalue,
26 ompt_get_num_procs());
28 ompt_callback_t callback;
29 printf("%" PRIu64 ": ompt_get_callback()=%d\n", tvalue,
30 ompt_get_callback(ompt_callback_thread_begin, &callback));
32 printf("%" PRIu64 ": ompt_get_state()=%d\n", tvalue, ompt_get_state(NULL));
34 int state = ompt_state_undefined;
35 const char *state_name;
36 printf("%" PRIu64 ": ompt_enumerate_states()=%d\n", tvalue,
37 ompt_enumerate_states(state, &state, &state_name));
39 int impl = ompt_mutex_impl_none;
40 const char *impl_name;
41 printf("%" PRIu64 ": ompt_enumerate_mutex_impls()=%d\n", tvalue,
42 ompt_enumerate_mutex_impls(impl, &impl, &impl_name));
44 printf("%" PRIu64 ": ompt_get_thread_data()=%p\n", tvalue,
45 ompt_get_thread_data());
47 printf("%" PRIu64 ": ompt_get_parallel_info()=%d\n", tvalue,
48 ompt_get_parallel_info(0, NULL, NULL));
50 printf("%" PRIu64 ": ompt_get_task_info()=%d\n", tvalue,
51 ompt_get_task_info(0, NULL, NULL, NULL, NULL, NULL));
54 int main() {
55 #pragma omp parallel num_threads(1)
58 std::thread t1(f);
59 t1.join();
61 // Check if libomp supports the callbacks for this test.
63 // CHECK: 0: NULL_POINTER=[[NULL:.*$]]
65 // CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_get_num_places()={{[0-9]+}}
67 // CHECK: {{^}}[[MASTER_ID]]: ompt_get_place_proc_ids()={{[0-9]+}}
69 // CHECK: {{^}}[[MASTER_ID]]: ompt_get_place_num()=-1
71 // CHECK: {{^}}[[MASTER_ID]]: ompt_get_partition_place_nums()=0
73 // CHECK: {{^}}[[MASTER_ID]]: ompt_get_proc_id()=-1
75 // CHECK: {{^}}[[MASTER_ID]]: ompt_get_num_procs()={{[0-9]+}}
77 // CHECK: {{^}}[[MASTER_ID]]: ompt_get_callback()=1
79 // CHECK: {{^}}[[MASTER_ID]]: ompt_get_state()=0
81 // CHECK: {{^}}[[MASTER_ID]]: ompt_enumerate_states()=1
83 // CHECK: {{^}}[[MASTER_ID]]: ompt_enumerate_mutex_impls()=1
85 // CHECK: {{^}}[[MASTER_ID]]: ompt_get_thread_data()=[[NULL]]
87 // CHECK: {{^}}[[MASTER_ID]]: ompt_get_parallel_info()=0
89 // CHECK: {{^}}[[MASTER_ID]]: ompt_get_task_info()=0
91 return 0;