1 // RUN: %libomp-compile-and-run | FileCheck %s
4 #define USE_PRIVATE_TOOL 1
7 __attribute__((noinline
))
9 #pragma omp parallel num_threads(2)
17 __attribute__((noinline
))
19 #pragma omp parallel num_threads(2)
34 // CHECK-NOT: {{^}}0: Could not register callback
35 // CHECK: 0: NULL_POINTER=[[NULL:.*$]]
38 // CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_parallel_begin
39 // CHECK-SAME: {{.*}}codeptr_ra=[[RETURN_ADDRESS:0x[0-f]+]]
42 // CHECK: {{^}}[[MASTER_ID]]: ompt_event_parallel_begin
45 // CHECK: {{^}}[[MASTER_ID]]: ompt_event_parallel_begin
46 // CHECK-SAME: {{.*}}codeptr_ra=[[RETURN_ADDRESS]]
50 static void on_ompt_callback_thread_begin(
51 ompt_thread_t thread_type
,
52 ompt_data_t
*thread_data
) {
54 printf("%s\n", "0: thread_data initially not null");
55 thread_data
->value
= ompt_get_unique_id();
56 printf("%" PRIu64
":" _TOOL_PREFIX
57 " ompt_event_thread_begin: thread_type=%s=%d, thread_id=%" PRIu64
"\n",
58 ompt_get_thread_data()->value
, ompt_thread_t_values
[thread_type
],
59 thread_type
, thread_data
->value
);
62 static void on_ompt_callback_parallel_begin(
63 ompt_data_t
*encountering_task_data
,
64 const ompt_frame_t
*encountering_task_frame
, ompt_data_t
*parallel_data
,
65 uint32_t requested_team_size
, int flag
, const void *codeptr_ra
) {
66 if (parallel_data
->ptr
)
67 printf("0: parallel_data initially not null\n");
68 parallel_data
->value
= ompt_get_unique_id();
69 int invoker
= flag
& 0xF;
70 const char *event
= (flag
& ompt_parallel_team
) ? "parallel" : "teams";
71 const char *size
= (flag
& ompt_parallel_team
) ? "team_size" : "num_teams";
72 printf("%" PRIu64
":" _TOOL_PREFIX
73 " ompt_event_%s_begin: parent_task_id=%" PRIu64
74 ", parent_task_frame.exit=%p, parent_task_frame.reenter=%p, "
75 "parallel_id=%" PRIu64
", requested_%s=%" PRIu32
76 ", codeptr_ra=%p, invoker=%d\n",
77 ompt_get_thread_data()->value
, event
, encountering_task_data
->value
,
78 encountering_task_frame
->exit_frame
.ptr
,
79 encountering_task_frame
->enter_frame
.ptr
, parallel_data
->value
, size
,
80 requested_team_size
, codeptr_ra
, invoker
);
83 int ompt_initialize(ompt_function_lookup_t lookup
, int initial_device_num
,
84 ompt_data_t
*tool_data
) {
85 ompt_set_callback
= (ompt_set_callback_t
)lookup("ompt_set_callback");
86 ompt_get_unique_id
= (ompt_get_unique_id_t
)lookup("ompt_get_unique_id");
87 ompt_get_thread_data
= (ompt_get_thread_data_t
)lookup("ompt_get_thread_data");
89 register_ompt_callback(ompt_callback_thread_begin
);
90 register_ompt_callback(ompt_callback_parallel_begin
);
91 printf("0: NULL_POINTER=%p\n", (void *)NULL
);
95 void ompt_finalize(ompt_data_t
*tool_data
) {}
97 ompt_start_tool_result_t
*ompt_start_tool(unsigned int omp_version
,
98 const char *runtime_version
) {
99 static ompt_start_tool_result_t ompt_start_tool_result
= {&ompt_initialize
,
101 return &ompt_start_tool_result
;