LLVM OpenMP 22.0.0git
api_calls_misc.c
Go to the documentation of this file.
1// clang-format off
2// RUN: %libomp-compile && %libomp-run | FileCheck %s
3// REQUIRES: ompt
4// clang-format on
5#include "callback.h"
6#include <omp.h>
7
8int main() {
9#pragma omp parallel num_threads(1)
10 {
11 // ompt_get_callback()
12 ompt_callback_t callback;
13 ompt_get_callback(ompt_callback_thread_begin, &callback);
14 printf("%" PRIu64 ": &on_ompt_callback_thread_begin=%p\n",
16 printf("%" PRIu64 ": ompt_get_callback() result=%p\n",
17 ompt_get_thread_data()->value, callback);
18
19 // ompt_get_state()
20 printf("%" PRIu64 ": ompt_get_state()=%d\n", ompt_get_thread_data()->value,
21 ompt_get_state(NULL));
22
23 // ompt_enumerate_states()
24 int state = ompt_state_undefined;
25 const char *state_name;
26 int steps = 0;
27 while (ompt_enumerate_states(state, &state, &state_name) && steps < 1000) {
28 steps++;
29 if (!state_name)
30 printf("%" PRIu64 ": state_name is NULL\n",
32 }
33 if (steps >= 1000) {
34 // enumeration did not end after 1000 steps
35 printf("%" PRIu64 ": states enumeration did not end\n",
37 }
38
39 // ompt_enumerate_mutex_impls()
40 int impl = ompt_mutex_impl_none;
41 const char *impl_name;
42 steps = 0;
43 while (ompt_enumerate_mutex_impls(impl, &impl, &impl_name) &&
44 steps < 1000) {
45 steps++;
46 if (!impl_name)
47 printf("%" PRIu64 ": impl_name is NULL\n",
49 }
50 if (steps >= 1000) {
51 // enumeration did not end after 1000 steps
52 printf("%" PRIu64 ": mutex_impls enumeration did not end\n",
54 }
55 }
56
57 // clang-format off
58 // Check if libomp supports the callbacks for this test.
59
60 // CHECK: 0: NULL_POINTER=[[NULL:.*$]]
61
62 // CHECK: {{^}}[[THREAD_ID:[0-9]+]]: &on_ompt_callback_thread_begin
63 // CHECK-SAME: =[[FUNCTION_POINTER:(0x)?[0-f]+]]
64 // CHECK: {{^}}[[THREAD_ID]]: ompt_get_callback() result=[[FUNCTION_POINTER]]
65
66 // CHECK: {{^}}[[THREAD_ID]]: ompt_get_state()=1
67
68 // CHECK-NOT: {{^}}[[THREAD_ID]]: state_name is NULL
69 // CHECK-NOT: {{^}}[[THREAD_ID]]: states enumeration did not end
70
71 // CHECK-NOT: {{^}}[[THREAD_ID]]: impl_name is NULL
72 // CHECK-NOT: {{^}}[[THREAD_ID]]: mutex_impls enumeration did not end
73 // clang-format on
74
75 return 0;
76}
int main()
static ompt_enumerate_states_t ompt_enumerate_states
Definition callback.h:168
static ompt_get_callback_t ompt_get_callback
Definition callback.h:154
static ompt_get_state_t ompt_get_state
Definition callback.h:155
static void on_ompt_callback_thread_begin(ompt_thread_t thread_type, ompt_data_t *thread_data)
Definition callback.h:958
static ompt_get_thread_data_t ompt_get_thread_data
Definition callback.h:158
static ompt_enumerate_mutex_impls_t ompt_enumerate_mutex_impls
Definition callback.h:169
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long value