[OpenMP][OMPT] Update the omp-tools header file to reflect 5.1 changes

This doesn't add functionality, but just adds the new types and renames the
master callback to masked callback.

Differential Revision: https://reviews.llvm.org/D90752
This commit is contained in:
Joachim Protze 2020-11-04 12:16:25 +01:00
parent 3597fba4e5
commit 6213ed062b
14 changed files with 301 additions and 62 deletions

View File

@ -20,6 +20,16 @@
#include <stdint.h>
#include <stddef.h>
#ifdef DEPRECATION_WARNINGS
# ifdef __cplusplus
# define DEPRECATED_51 [[deprecated("as of 5.1")]]
# else
# define DEPRECATED_51 __attribute__((deprecated("as of 5.1")))
#endif
#else
#define DEPRECATED_51
#endif
/*****************************************************************************
* iteration macros
*****************************************************************************/
@ -133,7 +143,7 @@
\
macro (ompt_callback_work, ompt_callback_work_t, 20) /* task at work begin or end */ \
\
macro (ompt_callback_master, ompt_callback_master_t, 21) /* task at master begin or end */ \
macro (ompt_callback_masked, ompt_callback_masked_t, 21) /* task at masked begin or end */ \
\
macro (ompt_callback_target_map, ompt_callback_target_map_t, 22) /* target map */ \
\
@ -153,7 +163,12 @@
\
macro (ompt_callback_reduction, ompt_callback_sync_region_t, 31) /* reduction */ \
\
macro (ompt_callback_dispatch, ompt_callback_dispatch_t, 32) /* dispatch of work */
macro (ompt_callback_dispatch, ompt_callback_dispatch_t, 32) /* dispatch of work */ \
macro (ompt_callback_target_emi, ompt_callback_target_emi_t, 33) /* target */ \
macro (ompt_callback_target_data_op_emi,ompt_callback_target_data_op_emi_t,34) /* target data op */ \
macro (ompt_callback_target_submit_emi, ompt_callback_target_submit_emi_t, 35) /* target submit */ \
macro (ompt_callback_target_map_emi, ompt_callback_target_map_emi_t, 36) /* target map */ \
macro (ompt_callback_error, ompt_callback_error_t, 37) /* error */
/*****************************************************************************
* implementation specific types
@ -190,7 +205,8 @@ typedef enum ompt_callbacks_t {
ompt_callback_dependences = 18,
ompt_callback_task_dependence = 19,
ompt_callback_work = 20,
ompt_callback_master = 21,
ompt_callback_master DEPRECATED_51 = 21,
ompt_callback_masked = 21,
ompt_callback_target_map = 22,
ompt_callback_sync_region = 23,
ompt_callback_lock_init = 24,
@ -201,7 +217,12 @@ typedef enum ompt_callbacks_t {
ompt_callback_flush = 29,
ompt_callback_cancel = 30,
ompt_callback_reduction = 31,
ompt_callback_dispatch = 32
ompt_callback_dispatch = 32,
ompt_callback_target_emi = 33,
ompt_callback_target_data_op_emi = 34,
ompt_callback_target_submit_emi = 35,
ompt_callback_target_map_emi = 36,
ompt_callback_error = 37
} ompt_callbacks_t;
typedef enum ompt_record_t {
@ -239,7 +260,8 @@ typedef enum ompt_thread_t {
typedef enum ompt_scope_endpoint_t {
ompt_scope_begin = 1,
ompt_scope_end = 2
ompt_scope_end = 2,
ompt_scope_beginend = 3
} ompt_scope_endpoint_t;
typedef enum ompt_dispatch_t {
@ -248,22 +270,29 @@ typedef enum ompt_dispatch_t {
} ompt_dispatch_t;
typedef enum ompt_sync_region_t {
ompt_sync_region_barrier = 1,
ompt_sync_region_barrier_implicit = 2,
ompt_sync_region_barrier DEPRECATED_51 = 1,
ompt_sync_region_barrier_implicit DEPRECATED_51 = 2,
ompt_sync_region_barrier_explicit = 3,
ompt_sync_region_barrier_implementation = 4,
ompt_sync_region_taskwait = 5,
ompt_sync_region_taskgroup = 6,
ompt_sync_region_reduction = 7
ompt_sync_region_reduction = 7,
ompt_sync_region_barrier_implicit_workshare = 8,
ompt_sync_region_barrier_implicit_parallel = 9,
ompt_sync_region_barrier_teams = 10
} ompt_sync_region_t;
typedef enum ompt_target_data_op_t {
ompt_target_data_alloc = 1,
ompt_target_data_transfer_to_device = 2,
ompt_target_data_transfer_from_device = 3,
ompt_target_data_delete = 4,
ompt_target_data_associate = 5,
ompt_target_data_disassociate = 6
ompt_target_data_alloc = 1,
ompt_target_data_transfer_to_device = 2,
ompt_target_data_transfer_from_device = 3,
ompt_target_data_delete = 4,
ompt_target_data_associate = 5,
ompt_target_data_disassociate = 6,
ompt_target_data_alloc_async = 17,
ompt_target_data_transfer_to_device_async = 18,
ompt_target_data_transfer_from_device_async = 19,
ompt_target_data_delete_async = 20
} ompt_target_data_op_t;
typedef enum ompt_work_t {
@ -273,7 +302,8 @@ typedef enum ompt_work_t {
ompt_work_single_other = 4,
ompt_work_workshare = 5,
ompt_work_distribute = 6,
ompt_work_taskloop = 7
ompt_work_taskloop = 7,
ompt_work_scope = 8
} ompt_work_t;
typedef enum ompt_mutex_t {
@ -302,6 +332,7 @@ typedef enum ompt_task_flag_t {
ompt_task_implicit = 0x00000002,
ompt_task_explicit = 0x00000004,
ompt_task_target = 0x00000008,
ompt_task_taskwait = 0x00000010,
ompt_task_undeferred = 0x08000000,
ompt_task_untied = 0x10000000,
ompt_task_final = 0x20000000,
@ -316,14 +347,19 @@ typedef enum ompt_task_status_t {
ompt_task_detach = 4,
ompt_task_early_fulfill = 5,
ompt_task_late_fulfill = 6,
ompt_task_switch = 7
ompt_task_switch = 7,
ompt_taskwait_complete = 8
} ompt_task_status_t;
typedef enum ompt_target_t {
ompt_target = 1,
ompt_target_enter_data = 2,
ompt_target_exit_data = 3,
ompt_target_update = 4
ompt_target_update = 4,
ompt_target_nowait = 9,
ompt_target_enter_data_nowait = 10,
ompt_target_exit_data_nowait = 11,
ompt_target_update_nowait = 12
} ompt_target_t;
typedef enum ompt_parallel_flag_t {
@ -348,9 +384,15 @@ typedef enum ompt_dependence_type_t {
ompt_dependence_type_inout = 3,
ompt_dependence_type_mutexinoutset = 4,
ompt_dependence_type_source = 5,
ompt_dependence_type_sink = 6
ompt_dependence_type_sink = 6,
ompt_dependence_type_inoutset = 7
} ompt_dependence_type_t;
typedef enum ompt_severity_t {
ompt_warning = 1,
ompt_fatal = 2
} ompt_severity_t;
typedef enum ompt_cancel_flag_t {
ompt_cancel_parallel = 0x01,
ompt_cancel_sections = 0x02,
@ -378,11 +420,13 @@ typedef enum ompt_state_t {
ompt_state_work_parallel = 0x001,
ompt_state_work_reduction = 0x002,
ompt_state_wait_barrier = 0x010,
ompt_state_wait_barrier DEPRECATED_51 = 0x010,
ompt_state_wait_barrier_implicit_parallel = 0x011,
ompt_state_wait_barrier_implicit_workshare = 0x012,
ompt_state_wait_barrier_implicit = 0x013,
ompt_state_wait_barrier_implicit DEPRECATED_51 = 0x013,
ompt_state_wait_barrier_explicit = 0x014,
ompt_state_wait_barrier_implementation = 0x015,
ompt_state_wait_barrier_teams = 0x016,
ompt_state_wait_taskwait = 0x020,
ompt_state_wait_taskgroup = 0x021,
@ -799,19 +843,21 @@ typedef struct ompt_record_implicit_task_t {
int flags;
} ompt_record_implicit_task_t;
typedef void (*ompt_callback_master_t) (
typedef void (*ompt_callback_masked_t) (
ompt_scope_endpoint_t endpoint,
ompt_data_t *parallel_data,
ompt_data_t *task_data,
const void *codeptr_ra
);
typedef struct ompt_record_master_t {
typedef ompt_callback_masked_t ompt_callback_master_t DEPRECATED_51;
typedef struct ompt_record_masked_t {
ompt_scope_endpoint_t endpoint;
ompt_id_t parallel_id;
ompt_id_t task_id;
const void *codeptr_ra;
} ompt_record_master_t;
} ompt_record_masked_t;
typedef void (*ompt_callback_sync_region_t) (
ompt_sync_region_t kind,
@ -918,6 +964,20 @@ typedef void (*ompt_callback_device_unload_t) (
uint64_t module_id
);
typedef void (*ompt_callback_target_data_op_emi_t) (
ompt_scope_endpoint_t endpoint,
ompt_data_t *target_task_data,
ompt_data_t *target_data,
ompt_id_t *host_op_id,
ompt_target_data_op_t optype,
void *src_addr,
int src_device_num,
void *dest_addr,
int dest_device_num,
size_t bytes,
const void *codeptr_ra
);
typedef void (*ompt_callback_target_data_op_t) (
ompt_id_t target_id,
ompt_id_t host_op_id,
@ -942,6 +1002,16 @@ typedef struct ompt_record_target_data_op_t {
const void *codeptr_ra;
} ompt_record_target_data_op_t;
typedef void (*ompt_callback_target_emi_t) (
ompt_target_t kind,
ompt_scope_endpoint_t endpoint,
int device_num,
ompt_data_t *task_data,
ompt_data_t *target_task_data,
ompt_data_t *target_data,
const void *codeptr_ra
);
typedef void (*ompt_callback_target_t) (
ompt_target_t kind,
ompt_scope_endpoint_t endpoint,
@ -960,6 +1030,16 @@ typedef struct ompt_record_target_t {
const void *codeptr_ra;
} ompt_record_target_t;
typedef void (*ompt_callback_target_map_emi_t) (
ompt_data_t *target_data,
unsigned int nitems,
void **host_addr,
void **device_addr,
size_t *bytes,
unsigned int *mapping_flags,
const void *codeptr_ra
);
typedef void (*ompt_callback_target_map_t) (
ompt_id_t target_id,
unsigned int nitems,
@ -980,6 +1060,13 @@ typedef struct ompt_record_target_map_t {
const void *codeptr_ra;
} ompt_record_target_map_t;
typedef void (*ompt_callback_target_submit_emi_t) (
ompt_scope_endpoint_t endpoint,
ompt_data_t *target_data,
ompt_id_t *host_op_id,
unsigned int requested_num_teams
);
typedef void (*ompt_callback_target_submit_t) (
ompt_id_t target_id,
ompt_id_t host_op_id,
@ -1006,6 +1093,12 @@ typedef struct ompt_record_control_tool_t {
const void *codeptr_ra;
} ompt_record_control_tool_t;
typedef void (*ompt_callback_error_t) (
ompt_severity_t severity,
const char *message, size_t length,
const void *codeptr_ra
);
typedef struct ompd_address_t {
ompd_seg_t segment;
ompd_addr_t address;
@ -1049,7 +1142,7 @@ typedef struct ompt_record_ompt_t {
ompt_record_task_dependence_t task_dependence;
ompt_record_task_schedule_t task_schedule;
ompt_record_implicit_task_t implicit_task;
ompt_record_master_t master;
ompt_record_masked_t masked;
ompt_record_sync_region_t sync_region;
ompt_record_mutex_acquire_t mutex_acquire;
ompt_record_mutex_t mutex;

View File

@ -756,12 +756,12 @@ kmp_int32 __kmpc_master(ident_t *loc, kmp_int32 global_tid) {
#if OMPT_SUPPORT && OMPT_OPTIONAL
if (status) {
if (ompt_enabled.ompt_callback_master) {
if (ompt_enabled.ompt_callback_masked) {
kmp_info_t *this_thr = __kmp_threads[global_tid];
kmp_team_t *team = this_thr->th.th_team;
int tid = __kmp_tid_from_gtid(global_tid);
ompt_callbacks.ompt_callback(ompt_callback_master)(
ompt_callbacks.ompt_callback(ompt_callback_masked)(
ompt_scope_begin, &(team->t.ompt_team_info.parallel_data),
&(team->t.t_implicit_task_taskdata[tid].ompt_task_info.task_data),
OMPT_GET_RETURN_ADDRESS(0));
@ -803,9 +803,9 @@ void __kmpc_end_master(ident_t *loc, kmp_int32 global_tid) {
#if OMPT_SUPPORT && OMPT_OPTIONAL
kmp_info_t *this_thr = __kmp_threads[global_tid];
kmp_team_t *team = this_thr->th.th_team;
if (ompt_enabled.ompt_callback_master) {
if (ompt_enabled.ompt_callback_masked) {
int tid = __kmp_tid_from_gtid(global_tid);
ompt_callbacks.ompt_callback(ompt_callback_master)(
ompt_callbacks.ompt_callback(ompt_callback_masked)(
ompt_scope_end, &(team->t.ompt_team_info.parallel_data),
&(team->t.t_implicit_task_taskdata[tid].ompt_task_info.task_data),
OMPT_GET_RETURN_ADDRESS(0));

View File

@ -56,8 +56,11 @@
#define ompt_callback_implicit_task_implemented ompt_event_MAY_ALWAYS
#define ompt_callback_target_implemented ompt_event_UNIMPLEMENTED
#define ompt_callback_target_emi_implemented ompt_event_UNIMPLEMENTED
#define ompt_callback_target_data_op_implemented ompt_event_UNIMPLEMENTED
#define ompt_callback_target_data_op_emi_implemented ompt_event_UNIMPLEMENTED
#define ompt_callback_target_submit_implemented ompt_event_UNIMPLEMENTED
#define ompt_callback_target_submit_emi_implemented ompt_event_UNIMPLEMENTED
#define ompt_callback_control_tool_implemented ompt_event_MAY_ALWAYS
@ -82,9 +85,10 @@
#define ompt_callback_work_implemented ompt_event_MAY_ALWAYS_OPTIONAL
#define ompt_callback_master_implemented ompt_event_MAY_ALWAYS_OPTIONAL
#define ompt_callback_masked_implemented ompt_event_MAY_ALWAYS_OPTIONAL
#define ompt_callback_target_map_implemented ompt_event_UNIMPLEMENTED
#define ompt_callback_target_map_emi_implemented ompt_event_UNIMPLEMENTED
#define ompt_callback_sync_region_implemented ompt_event_MAY_ALWAYS_OPTIONAL
@ -103,4 +107,6 @@
#define ompt_callback_dispatch_implemented ompt_event_UNIMPLEMENTED
#define ompt_callback_error_implemented ompt_event_UNIMPLEMENTED
#endif

View File

@ -393,6 +393,9 @@ on_ompt_callback_nest_lock(
", codeptr_ra=%p \n",
ompt_get_thread_data()->value, wait_id, codeptr_ra);
break;
case ompt_scope_beginend:
printf("ompt_scope_beginend should never be passed to %s\n", __func__);
exit(-1);
}
}
@ -411,6 +414,9 @@ on_ompt_callback_sync_region(
{
case ompt_sync_region_barrier:
case ompt_sync_region_barrier_implicit:
case ompt_sync_region_barrier_implicit_workshare:
case ompt_sync_region_barrier_implicit_parallel:
case ompt_sync_region_barrier_teams:
case ompt_sync_region_barrier_explicit:
case ompt_sync_region_barrier_implementation:
printf("%" PRIu64 ":" _TOOL_PREFIX
@ -447,6 +453,9 @@ on_ompt_callback_sync_region(
case ompt_sync_region_barrier:
case ompt_sync_region_barrier_implicit:
case ompt_sync_region_barrier_explicit:
case ompt_sync_region_barrier_implicit_workshare:
case ompt_sync_region_barrier_implicit_parallel:
case ompt_sync_region_barrier_teams:
case ompt_sync_region_barrier_implementation:
printf("%" PRIu64 ":" _TOOL_PREFIX
" ompt_event_barrier_end: parallel_id=%" PRIu64
@ -478,6 +487,9 @@ on_ompt_callback_sync_region(
break;
}
break;
case ompt_scope_beginend:
printf("ompt_scope_beginend should never be passed to %s\n", __func__);
exit(-1);
}
}
@ -496,6 +508,9 @@ on_ompt_callback_sync_region_wait(
{
case ompt_sync_region_barrier:
case ompt_sync_region_barrier_implicit:
case ompt_sync_region_barrier_implicit_workshare:
case ompt_sync_region_barrier_implicit_parallel:
case ompt_sync_region_barrier_teams:
case ompt_sync_region_barrier_explicit:
case ompt_sync_region_barrier_implementation:
printf("%" PRIu64 ":" _TOOL_PREFIX
@ -530,6 +545,9 @@ on_ompt_callback_sync_region_wait(
{
case ompt_sync_region_barrier:
case ompt_sync_region_barrier_implicit:
case ompt_sync_region_barrier_implicit_workshare:
case ompt_sync_region_barrier_implicit_parallel:
case ompt_sync_region_barrier_teams:
case ompt_sync_region_barrier_explicit:
case ompt_sync_region_barrier_implementation:
printf("%" PRIu64 ":" _TOOL_PREFIX
@ -562,6 +580,9 @@ on_ompt_callback_sync_region_wait(
break;
}
break;
case ompt_scope_beginend:
printf("ompt_scope_beginend should never be passed to %s\n", __func__);
exit(-1);
}
}
@ -587,6 +608,9 @@ static void on_ompt_callback_reduction(ompt_sync_region_t kind,
(parallel_data) ? parallel_data->value : 0, task_data->value,
codeptr_ra);
break;
case ompt_scope_beginend:
printf("ompt_scope_beginend should never be passed to %s\n", __func__);
exit(-1);
}
}
@ -691,6 +715,9 @@ on_ompt_callback_implicit_task(
team_size, thread_num);
}
break;
case ompt_scope_beginend:
printf("ompt_scope_beginend should never be passed to %s\n", __func__);
exit(-1);
}
}
@ -810,6 +837,14 @@ on_ompt_callback_work(
ompt_get_thread_data()->value, parallel_data->value,
task_data->value, codeptr_ra, count);
break;
case ompt_work_scope:
printf("%" PRIu64 ":" _TOOL_PREFIX
" ompt_event_scope_begin: parallel_id=%" PRIu64
", parent_task_id=%" PRIu64 ", codeptr_ra=%p, count=%" PRIu64
"\n",
ompt_get_thread_data()->value, parallel_data->value,
task_data->value, codeptr_ra, count);
break;
}
break;
case ompt_scope_end:
@ -863,34 +898,45 @@ on_ompt_callback_work(
ompt_get_thread_data()->value, parallel_data->value,
task_data->value, codeptr_ra, count);
break;
case ompt_work_scope:
printf("%" PRIu64 ":" _TOOL_PREFIX
" ompt_event_scope_end: parallel_id=%" PRIu64
", parent_task_id=%" PRIu64 ", codeptr_ra=%p, count=%" PRIu64
"\n",
ompt_get_thread_data()->value, parallel_data->value,
task_data->value, codeptr_ra, count);
break;
}
break;
case ompt_scope_beginend:
printf("ompt_scope_beginend should never be passed to %s\n", __func__);
exit(-1);
}
}
static void
on_ompt_callback_master(
ompt_scope_endpoint_t endpoint,
ompt_data_t *parallel_data,
ompt_data_t *task_data,
const void *codeptr_ra)
{
static void on_ompt_callback_masked(ompt_scope_endpoint_t endpoint,
ompt_data_t *parallel_data,
ompt_data_t *task_data,
const void *codeptr_ra) {
switch(endpoint)
{
case ompt_scope_begin:
printf("%" PRIu64 ":" _TOOL_PREFIX
" ompt_event_master_begin: parallel_id=%" PRIu64
" ompt_event_masked_begin: parallel_id=%" PRIu64
", task_id=%" PRIu64 ", codeptr_ra=%p\n",
ompt_get_thread_data()->value, parallel_data->value,
task_data->value, codeptr_ra);
break;
case ompt_scope_end:
printf("%" PRIu64 ":" _TOOL_PREFIX
" ompt_event_master_end: parallel_id=%" PRIu64 ", task_id=%" PRIu64
" ompt_event_masked_end: parallel_id=%" PRIu64 ", task_id=%" PRIu64
", codeptr_ra=%p\n",
ompt_get_thread_data()->value, parallel_data->value,
task_data->value, codeptr_ra);
break;
case ompt_scope_beginend:
printf("ompt_scope_beginend should never be passed to %s\n", __func__);
exit(-1);
}
}
@ -1116,7 +1162,7 @@ int ompt_initialize(
register_callback_t(ompt_callback_lock_init, ompt_callback_mutex_acquire_t);
register_callback_t(ompt_callback_lock_destroy, ompt_callback_mutex_t);
register_callback(ompt_callback_work);
register_callback(ompt_callback_master);
register_callback(ompt_callback_masked);
register_callback(ompt_callback_parallel_begin);
register_callback(ompt_callback_parallel_end);
register_callback(ompt_callback_task_create);

View File

@ -58,17 +58,18 @@ int main()
#pragma omp barrier
}
// Check if libomp supports the callbacks for this test.
// CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_master'
// CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_masked'
// CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_task_create'
// CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_task_schedule'
// CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_cancel'
// CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_task_schedule'
// CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_cancel'
// CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_thread_begin'
// CHECK: {{^}}0: NULL_POINTER=[[NULL:.*$]]
// CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_master_begin: parallel_id=[[PARALLEL_ID:[0-9]+]], task_id=[[PARENT_TASK_ID:[0-9]+]], codeptr_ra={{0x[0-f]*}}
// CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_masked_begin:
// CHECK-SAME: parallel_id=[[PARALLEL_ID:[0-9]+]],
// CHECK-SAME: task_id=[[PARENT_TASK_ID:[0-9]+]],
// CHECK-SAME: codeptr_ra={{0x[0-f]*}}
// CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_create: parent_task_id=[[PARENT_TASK_ID]], parent_task_frame.exit={{0x[0-f]*}}, parent_task_frame.reenter={{0x[0-f]*}}, new_task_id=[[FIRST_TASK_ID:[0-9]+]], codeptr_ra={{0x[0-f]*}}, task_type=ompt_task_explicit=4, has_dependences=no
// CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_create: parent_task_id=[[PARENT_TASK_ID]], parent_task_frame.exit={{0x[0-f]*}}, parent_task_frame.reenter={{0x[0-f]*}}, new_task_id=[[SECOND_TASK_ID:[0-9]+]], codeptr_ra={{0x[0-f]*}}, task_type=ompt_task_explicit=4, has_dependences=no

View File

@ -51,10 +51,8 @@ int main()
#include <stdio.h>
#include <omp-tools.h>
int ompt_initialize(
ompt_function_lookup_t lookup,
ompt_data_t* tool_data)
{
int ompt_initialize(ompt_function_lookup_t lookup, int initial_device_num,
ompt_data_t *tool_data) {
printf("0: NULL_POINTER=%p\n", (void*)NULL);
return 1; //success
}

View File

@ -76,10 +76,8 @@ on_ompt_callback_thread_begin(
printf("0: ompt_event_thread_begin\n");
}
int ompt_initialize(
ompt_function_lookup_t lookup,
ompt_data_t *tool_data)
{
int ompt_initialize(ompt_function_lookup_t lookup, int initial_device_num,
ompt_data_t *tool_data) {
ompt_set_callback_t ompt_set_callback = (ompt_set_callback_t) lookup("ompt_set_callback");
ompt_set_callback(ompt_callback_thread_begin, (ompt_callback_t)on_ompt_callback_thread_begin);
printf("0: Tool initialized\n");

View File

@ -109,7 +109,8 @@ int main() {
return 0;
}
int ompt_initialize(ompt_function_lookup_t lookup, ompt_data_t *tool_data) {
int ompt_initialize(ompt_function_lookup_t lookup, int initial_device_num,
ompt_data_t *tool_data) {
ompt_set_callback = (ompt_set_callback_t)lookup("ompt_set_callback");
ompt_get_callback = (ompt_get_callback_t)lookup("ompt_get_callback");
ompt_get_state = (ompt_get_state_t)lookup("ompt_get_state");

View File

@ -87,6 +87,9 @@ on_ompt_callback_sync_region(
if (kind == ompt_sync_region_barrier_implicit)
printf("%" PRIu64 ": ompt_event_barrier_end: parallel_id=%" PRIu64 ", task_id=%" PRIu64 ", codeptr_ra=%p\n", ompt_get_thread_data()->value, (parallel_data)?parallel_data->value:0, task_data->value, codeptr_ra);
break;
case ompt_scope_beginend:
printf("ompt_scope_beginend should never be passed to %s\n", __func__);
exit(-1);
}
}
@ -112,6 +115,9 @@ on_ompt_callback_sync_region_wait(
if (kind == ompt_sync_region_barrier_implicit)
printf("%" PRIu64 ": ompt_event_wait_barrier_end: parallel_id=%" PRIu64 ", task_id=%" PRIu64 ", codeptr_ra=%p\n", ompt_get_thread_data()->value, (parallel_data)?parallel_data->value:0, task_data->value, codeptr_ra);
break;
case ompt_scope_beginend:
printf("ompt_scope_beginend should never be passed to %s\n", __func__);
exit(-1);
}
}
@ -125,10 +131,8 @@ do{ \
#define register_callback(name) register_callback_t(name, name##_t)
int ompt_initialize(
ompt_function_lookup_t lookup,
ompt_data_t *tool_data)
{
int ompt_initialize(ompt_function_lookup_t lookup, int initial_device_num,
ompt_data_t *tool_data) {
ompt_set_callback_t ompt_set_callback;
ompt_set_callback = (ompt_set_callback_t) lookup("ompt_set_callback");
ompt_get_unique_id = (ompt_get_unique_id_t) lookup("ompt_get_unique_id");

View File

@ -0,0 +1,38 @@
// RUN: %libomp-compile-and-run | FileCheck %s
// REQUIRES: ompt
// GCC generates code that does not call the runtime for the master construct
// XFAIL: gcc
#include "callback.h"
#include <omp.h>
int main() {
int x = 0;
#pragma omp parallel num_threads(2)
{
#pragma omp master
{
print_fuzzy_address(1);
x++;
}
print_current_address(2);
}
printf("%" PRIu64 ": x=%d\n", ompt_get_thread_data()->value, x);
return 0;
}
// Check if libomp supports the callbacks for this test.
// CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_masked'
// CHECK: 0: NULL_POINTER=[[NULL:.*$]]
// CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_masked_begin:
// CHECK-SAME: parallel_id=[[PARALLEL_ID:[0-9]+]], task_id=[[TASK_ID:[0-9]+]],
// CHECK-SAME: codeptr_ra=[[RETURN_ADDRESS:0x[0-f]+]]{{[0-f][0-f]}}
// CHECK: {{^}}[[MASTER_ID]]: fuzzy_address={{.*}}[[RETURN_ADDRESS]]
// CHECK: {{^}}[[MASTER_ID]]: ompt_event_masked_end:
// CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[TASK_ID]],
// CHECK-SAME: codeptr_ra=[[RETURN_ADDRESS_END:0x[0-f]+]]
// CHECK: {{^}}[[MASTER_ID]]: current_address={{.*}}[[RETURN_ADDRESS_END]]

View File

@ -3,6 +3,7 @@
// GCC generates code that does not call the runtime for the master construct
// XFAIL: gcc
#define USE_PRIVATE_TOOL 1
#include "callback.h"
#include <omp.h>
@ -23,16 +24,66 @@ int main() {
return 0;
}
static void on_ompt_callback_master(ompt_scope_endpoint_t endpoint,
ompt_data_t *parallel_data,
ompt_data_t *task_data,
const void *codeptr_ra) {
switch (endpoint) {
case ompt_scope_begin:
printf("%" PRIu64 ":" _TOOL_PREFIX
" ompt_event_master_begin: codeptr_ra=%p\n",
ompt_get_thread_data()->value, codeptr_ra);
break;
case ompt_scope_end:
printf("%" PRIu64 ":" _TOOL_PREFIX
" ompt_event_master_end: codeptr_ra=%p\n",
ompt_get_thread_data()->value, codeptr_ra);
break;
case ompt_scope_beginend:
printf("ompt_scope_beginend should never be passed to %s\n", __func__);
exit(-1);
}
}
static void on_ompt_callback_thread_begin(ompt_thread_t thread_type,
ompt_data_t *thread_data) {
if (thread_data->ptr)
printf("%s\n", "0: thread_data initially not null");
thread_data->value = ompt_get_unique_id();
printf("%" PRIu64 ":" _TOOL_PREFIX
" ompt_event_thread_begin: thread_type=%s=%d, thread_id=%" PRIu64 "\n",
ompt_get_thread_data()->value, ompt_thread_t_values[thread_type],
thread_type, thread_data->value);
}
int ompt_initialize(ompt_function_lookup_t lookup, int initial_device_num,
ompt_data_t *tool_data) {
ompt_set_callback = (ompt_set_callback_t)lookup("ompt_set_callback");
ompt_get_unique_id = (ompt_get_unique_id_t)lookup("ompt_get_unique_id");
ompt_get_thread_data = (ompt_get_thread_data_t)lookup("ompt_get_thread_data");
register_callback(ompt_callback_master);
printf("0: NULL_POINTER=%p\n", (void *)NULL);
return 1; // success
}
void ompt_finalize(ompt_data_t *tool_data) {}
ompt_start_tool_result_t *ompt_start_tool(unsigned int omp_version,
const char *runtime_version) {
static ompt_start_tool_result_t ompt_start_tool_result = {&ompt_initialize,
&ompt_finalize, 0};
return &ompt_start_tool_result;
}
// Check if libomp supports the callbacks for this test.
// CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_master'
// CHECK: 0: NULL_POINTER=[[NULL:.*$]]
// CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_master_begin:
// CHECK-SAME: parallel_id=[[PARALLEL_ID:[0-9]+]], task_id=[[TASK_ID:[0-9]+]],
// CHECK-SAME: codeptr_ra=[[RETURN_ADDRESS:0x[0-f]+]]{{[0-f][0-f]}}
// CHECK: {{^}}[[MASTER_ID]]: fuzzy_address={{.*}}[[RETURN_ADDRESS]]
// CHECK: {{^}}[[MASTER_ID]]: ompt_event_master_end:
// CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[TASK_ID]],
// CHECK-SAME: codeptr_ra=[[RETURN_ADDRESS_END:0x[0-f]+]]
// CHECK: {{^}}[[MASTER_ID]]: current_address={{.*}}[[RETURN_ADDRESS_END]]

View File

@ -10,7 +10,8 @@ int main()
print_ids(0);
omp_nest_lock_t nest_lock;
printf("%" PRIu64 ": &nest_lock: %lli\n", ompt_get_thread_data()->value, (ompt_wait_id_t)(uintptr_t) &nest_lock);
printf("%" PRIu64 ": &nest_lock: %" PRIu64 "\n",
ompt_get_thread_data()->value, (ompt_wait_id_t)(uintptr_t)&nest_lock);
omp_init_nest_lock(&nest_lock);
print_fuzzy_address(1);
omp_set_nest_lock(&nest_lock);

View File

@ -29,7 +29,6 @@ int main()
// Check if libomp supports the callbacks for this test.
// CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_master'
// CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_task_create'
// CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_task_schedule'
// CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_cancel'

View File

@ -41,6 +41,9 @@ static void on_ompt_callback_implicit_task(ompt_scope_endpoint_t endpoint,
", memory_addr=%p, memory_size=%lu, result=%d \n",
task_data->value, addr, size, result);
break;
case ompt_scope_beginend:
printf("ompt_scope_beginend should never be passed to %s\n", __func__);
exit(-1);
}
}