1 | // RUN: %libomp-cxx-compile-and-run | FileCheck %s |
2 | // REQUIRES: ompt, linux |
3 | |
4 | #include <thread> |
5 | #include "callback.h" |
6 | |
7 | void f() { |
8 | ompt_data_t *tdata = ompt_get_thread_data(); |
9 | uint64_t tvalue = tdata ? tdata->value : 0; |
10 | |
11 | printf("%" PRIu64 ": ompt_get_num_places()=%d\n" , tvalue, |
12 | ompt_get_num_places()); |
13 | |
14 | printf("%" PRIu64 ": ompt_get_place_proc_ids()=%d\n" , tvalue, |
15 | ompt_get_place_proc_ids(0, 0, NULL)); |
16 | |
17 | printf("%" PRIu64 ": ompt_get_place_num()=%d\n" , tvalue, |
18 | ompt_get_place_num()); |
19 | |
20 | printf("%" PRIu64 ": ompt_get_partition_place_nums()=%d\n" , tvalue, |
21 | ompt_get_partition_place_nums(0, NULL)); |
22 | |
23 | printf("%" PRIu64 ": ompt_get_proc_id()=%d\n" , tvalue, ompt_get_proc_id()); |
24 | |
25 | printf("%" PRIu64 ": ompt_get_num_procs()=%d\n" , tvalue, |
26 | ompt_get_num_procs()); |
27 | |
28 | ompt_callback_t callback; |
29 | printf("%" PRIu64 ": ompt_get_callback()=%d\n" , tvalue, |
30 | ompt_get_callback(ompt_callback_thread_begin, &callback)); |
31 | |
32 | printf("%" PRIu64 ": ompt_get_state()=%d\n" , tvalue, ompt_get_state(NULL)); |
33 | |
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)); |
38 | |
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)); |
43 | |
44 | printf("%" PRIu64 ": ompt_get_thread_data()=%p\n" , tvalue, |
45 | ompt_get_thread_data()); |
46 | |
47 | printf("%" PRIu64 ": ompt_get_parallel_info()=%d\n" , tvalue, |
48 | ompt_get_parallel_info(0, NULL, NULL)); |
49 | |
50 | printf("%" PRIu64 ": ompt_get_task_info()=%d\n" , tvalue, |
51 | ompt_get_task_info(0, NULL, NULL, NULL, NULL, NULL)); |
52 | } |
53 | |
54 | int main() { |
55 | #pragma omp parallel num_threads(1) |
56 | {} |
57 | |
58 | std::thread t1(f); |
59 | t1.join(); |
60 | |
61 | // Check if libomp supports the callbacks for this test. |
62 | |
63 | // CHECK: 0: NULL_POINTER=[[NULL:.*$]] |
64 | |
65 | // CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_get_num_places()={{[0-9]+}} |
66 | |
67 | // CHECK: {{^}}[[MASTER_ID]]: ompt_get_place_proc_ids()={{[0-9]+}} |
68 | |
69 | // CHECK: {{^}}[[MASTER_ID]]: ompt_get_place_num()=-1 |
70 | |
71 | // CHECK: {{^}}[[MASTER_ID]]: ompt_get_partition_place_nums()=0 |
72 | |
73 | // CHECK: {{^}}[[MASTER_ID]]: ompt_get_proc_id()=-1 |
74 | |
75 | // CHECK: {{^}}[[MASTER_ID]]: ompt_get_num_procs()={{[0-9]+}} |
76 | |
77 | // CHECK: {{^}}[[MASTER_ID]]: ompt_get_callback()=1 |
78 | |
79 | // CHECK: {{^}}[[MASTER_ID]]: ompt_get_state()=0 |
80 | |
81 | // CHECK: {{^}}[[MASTER_ID]]: ompt_enumerate_states()=1 |
82 | |
83 | // CHECK: {{^}}[[MASTER_ID]]: ompt_enumerate_mutex_impls()=1 |
84 | |
85 | // CHECK: {{^}}[[MASTER_ID]]: ompt_get_thread_data()=[[NULL]] |
86 | |
87 | // CHECK: {{^}}[[MASTER_ID]]: ompt_get_parallel_info()=0 |
88 | |
89 | // CHECK: {{^}}[[MASTER_ID]]: ompt_get_task_info()=0 |
90 | |
91 | return 0; |
92 | } |
93 | |