LLVM OpenMP 19.0.0git
api_calls_misc.c
Go to the documentation of this file.
1// RUN: %libomp-compile && %libomp-run | FileCheck %s
2// REQUIRES: ompt
3#include "callback.h"
4#include <omp.h>
5
6int main() {
7#pragma omp parallel num_threads(1)
8 {
9 // ompt_get_callback()
10 ompt_callback_t callback;
11 ompt_get_callback(ompt_callback_thread_begin, &callback);
12 printf("%" PRIu64 ": &on_ompt_callback_thread_begin=%p\n",
14 printf("%" PRIu64 ": ompt_get_callback() result=%p\n",
15 ompt_get_thread_data()->value, callback);
16
17 // ompt_get_state()
18 printf("%" PRIu64 ": ompt_get_state()=%d\n", ompt_get_thread_data()->value,
19 ompt_get_state(NULL));
20
21 // ompt_enumerate_states()
22 int state = ompt_state_undefined;
23 const char *state_name;
24 int steps = 0;
25 while (ompt_enumerate_states(state, &state, &state_name) && steps < 1000) {
26 steps++;
27 if (!state_name)
28 printf("%" PRIu64 ": state_name is NULL\n",
30 }
31 if (steps >= 1000) {
32 // enumeration did not end after 1000 steps
33 printf("%" PRIu64 ": states enumeration did not end\n",
35 }
36
37 // ompt_enumerate_mutex_impls()
38 int impl = ompt_mutex_impl_none;
39 const char *impl_name;
40 steps = 0;
41 while (ompt_enumerate_mutex_impls(impl, &impl, &impl_name) &&
42 steps < 1000) {
43 steps++;
44 if (!impl_name)
45 printf("%" PRIu64 ": impl_name is NULL\n",
47 }
48 if (steps >= 1000) {
49 // enumeration did not end after 1000 steps
50 printf("%" PRIu64 ": mutex_impls enumeration did not end\n",
52 }
53 }
54
55 // Check if libomp supports the callbacks for this test.
56
57 // CHECK: 0: NULL_POINTER=[[NULL:.*$]]
58
59 // CHECK: {{^}}[[THREAD_ID:[0-9]+]]: &on_ompt_callback_thread_begin
60 // CHECK-SAME: =[[FUNCTION_POINTER:0x[0-f]+]]
61 // CHECK: {{^}}[[THREAD_ID]]: ompt_get_callback() result=[[FUNCTION_POINTER]]
62
63 // CHECK: {{^}}[[THREAD_ID]]: ompt_get_state()=1
64
65 // CHECK-NOT: {{^}}[[THREAD_ID]]: state_name is NULL
66 // CHECK-NOT: {{^}}[[THREAD_ID]]: states enumeration did not end
67
68 // CHECK-NOT: {{^}}[[THREAD_ID]]: impl_name is NULL
69 // CHECK-NOT: {{^}}[[THREAD_ID]]: mutex_impls enumeration did not end
70
71 return 0;
72}
int main()
Definition: api_calls_misc.c:6
static ompt_enumerate_states_t ompt_enumerate_states
Definition: callback.h:105
static ompt_get_callback_t ompt_get_callback
Definition: callback.h:91
static ompt_get_state_t ompt_get_state
Definition: callback.h:92
static void on_ompt_callback_thread_begin(ompt_thread_t thread_type, ompt_data_t *thread_data)
Definition: callback.h:1181
static ompt_get_thread_data_t ompt_get_thread_data
Definition: callback.h:95
static ompt_enumerate_mutex_impls_t ompt_enumerate_mutex_impls
Definition: callback.h:106
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