1 // RUN: %libomp-compile-and-run | FileCheck %s
3 // UNSUPPORTED: gcc-4, gcc-5, gcc-6, gcc-7
4 #define USE_PRIVATE_TOOL 1
10 #pragma omp parallel num_threads(2)
16 #pragma omp task firstprivate(x)
24 static void on_ompt_callback_implicit_task(ompt_scope_endpoint_t endpoint
,
25 ompt_data_t
*parallel_data
,
26 ompt_data_t
*task_data
,
27 unsigned int team_size
,
28 unsigned int thread_num
, int flag
) {
31 int result
= ompt_get_task_memory(&addr
, &size
, 0);
33 case ompt_scope_begin
:
34 task_data
->value
= ompt_get_unique_id();
35 printf("ompt_event_implicit_task_begin: task_id=%" PRIu64
36 ", memory_addr=%p, memory_size=%lu, result=%d \n",
37 task_data
->value
, addr
, size
, result
);
40 printf("ompt_event_implicit_task_end: task_id=%" PRIu64
41 ", memory_addr=%p, memory_size=%lu, result=%d \n",
42 task_data
->value
, addr
, size
, result
);
44 case ompt_scope_beginend
:
45 printf("ompt_scope_beginend should never be passed to %s\n", __func__
);
51 on_ompt_callback_task_create(ompt_data_t
*encountering_task_data
,
52 const ompt_frame_t
*encountering_task_frame
,
53 ompt_data_t
*new_task_data
, int flags
,
54 int has_dependences
, const void *codeptr_ra
) {
55 if (flags
& ompt_task_initial
)
56 return; // not interested in the initial task
57 new_task_data
->value
= ompt_get_unique_id();
60 printf("ompt_event_task_create: task_id=%" PRIu64
"\n", new_task_data
->value
);
63 static void on_ompt_callback_task_schedule(ompt_data_t
*first_task_data
,
64 ompt_task_status_t prior_task_status
,
65 ompt_data_t
*second_task_data
) {
68 int result
= ompt_get_task_memory(&addr
, &size
, 0);
69 printf("ompt_event_task_schedule: task_id=%" PRIu64
70 ", memory_addr=%p, memory_size=%lu, result=%d\n",
71 first_task_data
->value
, addr
, size
, result
);
74 int ompt_initialize(ompt_function_lookup_t lookup
, int initial_device_num
,
75 ompt_data_t
*tool_data
) {
76 ompt_set_callback
= (ompt_set_callback_t
)lookup("ompt_set_callback");
77 ompt_get_unique_id
= (ompt_get_unique_id_t
)lookup("ompt_get_unique_id");
78 ompt_get_task_memory
= (ompt_get_task_memory_t
)lookup("ompt_get_task_memory");
80 register_ompt_callback(ompt_callback_implicit_task
);
81 register_ompt_callback(ompt_callback_task_create
);
82 register_ompt_callback(ompt_callback_task_schedule
);
83 printf("0: NULL_POINTER=%p\n", (void *)NULL
);
87 void ompt_finalize(ompt_data_t
*tool_data
) {}
89 ompt_start_tool_result_t
*ompt_start_tool(unsigned int omp_version
,
90 const char *runtime_version
) {
91 static ompt_start_tool_result_t ompt_start_tool_result
= {&ompt_initialize
,
93 return &ompt_start_tool_result
;
96 // CHECK: {{^}}0: NULL_POINTER=[[NULL:.*$]]
98 // CHECK: ompt_event_implicit_task_begin: task_id=[[TASK_ID:[0-9]+]]
99 // CHECK-SAME: memory_addr=[[NULL]], memory_size=0, result=0
101 // CHECK: ompt_event_task_create: task_id=[[TASK_ID_0:[0-9]+]]
102 // CHECK-DAG: ompt_event_task_create: task_id=[[TASK_ID_1:[0-9]+]]
104 // Expects non-zero address, size, and result
105 // CHECK-DAG: ompt_event_task_schedule: task_id=[[TASK_ID_0]],
106 // memory_addr=0x{{[0-f]+}}, memory_size={{[1-9][0-9]*}}, result=1
107 // CHECK-DAG: ompt_event_task_schedule: task_id=[[TASK_ID_1]],
108 // memory_addr=0x{{[0-f]+}}, memory_size={{[1-9][0-9]*}}, result=1
110 // CHECK: ompt_event_implicit_task_end: task_id=[[TASK_ID]]
111 // CHECK-SAME: memory_addr=[[NULL]], memory_size=0, result=0