Skip to content

Commit

Permalink
[OMPT] Update types according to TR7
Browse files Browse the repository at this point in the history
Some types and callback signatures have changed from TR6 to TR7.
Major changes (only adding signatures and stubs):
(-remove idle callback) done by D48362
-add reduction and dispatch callback
-add get_task_memory and finalize_tool runtime entry points
-ompt_invoker_t  becomes ompt_parallel_flag_t
-more types of sync_regions

Patch provided by Simon Convent

Reviewers: hbae, protze.joachim

Differential Revision: https://reviews.llvm.org/D50774

llvm-svn: 341834
  • Loading branch information
jprotze committed Sep 10, 2018
1 parent 659c871 commit 489cdb7
Show file tree
Hide file tree
Showing 16 changed files with 198 additions and 129 deletions.
150 changes: 94 additions & 56 deletions openmp/runtime/src/include/50/ompt.h.var
Expand Up @@ -38,8 +38,10 @@
\
macro (ompt_get_parallel_info) \
macro (ompt_get_task_info) \
macro (ompt_get_task_memory) \
macro (ompt_get_thread_data) \
macro (ompt_get_unique_id) \
macro (ompt_finalize_tool) \
\
macro(ompt_get_num_procs) \
macro(ompt_get_num_places) \
Expand Down Expand Up @@ -151,6 +153,10 @@
macro (ompt_callback_flush, ompt_callback_flush_t, 29) /* after executing flush */ \
\
macro (ompt_callback_cancel, ompt_callback_cancel_t, 30) /* cancel innermost binding region */ \
\
macro (ompt_callback_reduction, ompt_callback_sync_region_t, 31) /* reduction */ \
\
macro (ompt_callback_dispatch, ompt_callback_dispatch_t, 32) /* dispatch of work */



Expand Down Expand Up @@ -191,16 +197,17 @@ typedef struct omp_frame_t {
* dependences types
*---------------------*/

typedef enum ompt_task_dependence_flag_t {
typedef enum ompt_task_dependence_type_t {
// a two bit field for the dependence type
ompt_task_dependence_type_out = 1,
ompt_task_dependence_type_in = 2,
ompt_task_dependence_type_inout = 3,
} ompt_task_dependence_flag_t;
ompt_task_dependence_type_in = 1,
ompt_task_dependence_type_out = 2,
ompt_task_dependence_type_inout = 3,
ompt_task_dependence_type_mutexinoutset = 4
} ompt_task_dependence_type_t;

typedef struct ompt_task_dependence_t {
void *variable_addr;
unsigned int dependence_flags;
ompt_task_dependence_type_t dependence_type;
} ompt_task_dependence_t;


Expand Down Expand Up @@ -264,20 +271,22 @@ typedef ompt_interface_fn_t (*ompt_function_lookup_t)(
);

/* threads */
typedef enum ompt_thread_type_t {
typedef enum ompt_thread_t {
ompt_thread_initial = 1, // start the enumeration at 1
ompt_thread_worker = 2,
ompt_thread_other = 3,
ompt_thread_unknown = 4
} ompt_thread_type_t;
} ompt_thread_t;

typedef enum ompt_invoker_t {
ompt_invoker_program = 1, /* program invokes master task */
ompt_invoker_runtime = 2 /* runtime invokes master task */
} ompt_invoker_t;
typedef enum ompt_parallel_flag_t {
ompt_parallel_invoker_program = 0x00000001, /* program invokes master task */
ompt_parallel_invoker_runtime = 0x00000002, /* runtime invokes master task */
ompt_parallel_league = 0x40000000,
ompt_parallel_team = 0x80000000
} ompt_parallel_flag_t;

typedef void (*ompt_callback_thread_begin_t) (
ompt_thread_type_t thread_type, /* type of thread */
ompt_thread_t thread_type, /* type of thread */
ompt_data_t *thread_data /* data of thread */
);

Expand All @@ -301,28 +310,28 @@ typedef void (*ompt_callback_implicit_task_t) (
ompt_scope_endpoint_t endpoint, /* endpoint of implicit task */
ompt_data_t *parallel_data, /* data of parallel region */
ompt_data_t *task_data, /* data of implicit task */
unsigned int team_size, /* team size */
unsigned int thread_num /* thread number of calling thread */
unsigned int actual_parallelism, /* team size */
unsigned int index /* thread number of calling thread */
);

typedef void (*ompt_callback_parallel_begin_t) (
ompt_data_t *encountering_task_data, /* data of encountering task */
const omp_frame_t *encountering_task_frame, /* frame data of encountering task */
ompt_data_t *parallel_data, /* data of parallel region */
unsigned int requested_team_size, /* requested number of threads in team */
ompt_invoker_t invoker, /* invoker of master task */
int flag, /* flag for additional information */
const void *codeptr_ra /* return address of runtime call */
);

typedef void (*ompt_callback_parallel_end_t) (
ompt_data_t *parallel_data, /* data of parallel region */
ompt_data_t *encountering_task_data, /* data of encountering task */
ompt_invoker_t invoker, /* invoker of master task */
int flag, /* flag for additional information */
const void *codeptr_ra /* return address of runtime call */
);

/* tasks */
typedef enum ompt_task_type_t {
typedef enum ompt_task_flag_t {
ompt_task_initial = 0x1,
ompt_task_implicit = 0x2,
ompt_task_explicit = 0x4,
Expand All @@ -332,13 +341,13 @@ typedef enum ompt_task_type_t {
ompt_task_final = 0x20000000,
ompt_task_mergeable = 0x40000000,
ompt_task_merged = 0x80000000
} ompt_task_type_t;
} ompt_task_flag_t;

typedef enum ompt_task_status_t {
ompt_task_complete = 1,
ompt_task_yield = 2,
ompt_task_cancel = 3,
ompt_task_others = 4
ompt_task_switch = 4
} ompt_task_status_t;

typedef void (*ompt_callback_task_schedule_t) (
Expand All @@ -351,7 +360,7 @@ typedef void (*ompt_callback_task_create_t) (
ompt_data_t *encountering_task_data, /* data of parent task */
const omp_frame_t *encountering_task_frame, /* frame data for parent task */
ompt_data_t *new_task_data, /* data of created task */
int type, /* type of created task */
int flag, /* type of created task */
int has_dependences, /* created task has dependences */
const void *codeptr_ra /* return address of runtime call */
);
Expand All @@ -369,15 +378,15 @@ typedef void (*ompt_callback_task_dependence_t) (
);

/* target and device */
typedef enum ompt_target_type_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_type_t;
} ompt_target_t;

typedef void (*ompt_callback_target_t) (
ompt_target_type_t kind,
ompt_target_t kind,
ompt_scope_endpoint_t endpoint,
uint64_t device_num,
ompt_data_t *task_data,
Expand All @@ -396,14 +405,18 @@ typedef void (*ompt_callback_target_data_op_t) (
ompt_id_t target_id,
ompt_id_t host_op_id,
ompt_target_data_op_t optype,
void *host_addr,
void *device_addr,
size_t bytes
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_submit_t) (
ompt_id_t target_id,
ompt_id_t host_op_id
ompt_id_t host_op_id,
unsigned int requested_num_teams
);

typedef void (*ompt_callback_target_map_t) (
Expand All @@ -412,7 +425,8 @@ typedef void (*ompt_callback_target_map_t) (
void **host_addr,
void **device_addr,
size_t *bytes,
unsigned int *mapping_flags
unsigned int *mapping_flags,
const void *codeptr_ra
);

typedef void (*ompt_callback_device_initialize_t) (
Expand Down Expand Up @@ -453,32 +467,31 @@ typedef int (*ompt_callback_control_tool_t) (
const void *codeptr_ra /* return address of runtime call */
);

typedef enum ompt_mutex_kind_t {
ompt_mutex = 0x10,
ompt_mutex_lock = 0x11,
ompt_mutex_nest_lock = 0x12,
ompt_mutex_critical = 0x13,
ompt_mutex_atomic = 0x14,
ompt_mutex_ordered = 0x20
} ompt_mutex_kind_t;
typedef enum ompt_mutex_t {
ompt_mutex_lock = 1,
ompt_mutex_nest_lock = 2,
ompt_mutex_critical = 3,
ompt_mutex_atomic = 4,
ompt_mutex_ordered = 5
} ompt_mutex_t;

typedef void (*ompt_callback_mutex_acquire_t) (
ompt_mutex_kind_t kind, /* mutex kind */
ompt_mutex_t kind, /* mutex kind */
unsigned int hint, /* mutex hint */
unsigned int impl, /* mutex implementation */
omp_wait_id_t wait_id, /* id of object being awaited */
omp_wait_id_t wait_id, /* id of object being awaited */
const void *codeptr_ra /* return address of runtime call */
);

typedef void (*ompt_callback_mutex_t) (
ompt_mutex_kind_t kind, /* mutex kind */
omp_wait_id_t wait_id, /* id of object being awaited */
ompt_mutex_t kind, /* mutex kind */
omp_wait_id_t wait_id, /* id of object being awaited */
const void *codeptr_ra /* return address of runtime call */
);

typedef void (*ompt_callback_nest_lock_t) (
ompt_scope_endpoint_t endpoint, /* endpoint of nested lock */
omp_wait_id_t wait_id, /* id of object being awaited */
omp_wait_id_t wait_id, /* id of object being awaited */
const void *codeptr_ra /* return address of runtime call */
);

Expand All @@ -489,44 +502,48 @@ typedef void (*ompt_callback_master_t) (
const void *codeptr_ra /* return address of runtime call */
);

typedef enum ompt_work_type_t {
typedef enum ompt_work_t {
ompt_work_loop = 1,
ompt_work_sections = 2,
ompt_work_single_executor = 3,
ompt_work_single_other = 4,
ompt_work_workshare = 5,
ompt_work_distribute = 6,
ompt_work_taskloop = 7
} ompt_work_type_t;
} ompt_work_t;

typedef void (*ompt_callback_work_t) (
ompt_work_type_t wstype, /* type of work region */
ompt_work_t wstype, /* type of work region */
ompt_scope_endpoint_t endpoint, /* endpoint of work region */
ompt_data_t *parallel_data, /* data of parallel region */
ompt_data_t *task_data, /* data of task */
uint64_t count, /* quantity of work */
const void *codeptr_ra /* return address of runtime call */
);

typedef enum ompt_sync_region_kind_t {
ompt_sync_region_barrier = 1,
ompt_sync_region_taskwait = 2,
ompt_sync_region_taskgroup = 3
} ompt_sync_region_kind_t;
typedef enum ompt_sync_region_t {
ompt_sync_region_barrier = 1,
ompt_sync_region_barrier_implicit = 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_t;

typedef void (*ompt_callback_sync_region_t) (
ompt_sync_region_kind_t kind, /* kind of sync region */
ompt_sync_region_t kind, /* kind of sync region */
ompt_scope_endpoint_t endpoint, /* endpoint of sync region */
ompt_data_t *parallel_data, /* data of parallel region */
ompt_data_t *task_data, /* data of task */
const void *codeptr_ra /* return address of runtime call */
);

typedef enum ompt_cancel_flag_t {
ompt_cancel_parallel = 0x1,
ompt_cancel_sections = 0x2,
ompt_cancel_do = 0x4,
ompt_cancel_taskgroup = 0x8,
ompt_cancel_parallel = 0x01,
ompt_cancel_sections = 0x02,
ompt_cancel_loop = 0x04,
ompt_cancel_taskgroup = 0x08,
ompt_cancel_activated = 0x10,
ompt_cancel_detected = 0x20,
ompt_cancel_discarded_task = 0x40
Expand All @@ -543,6 +560,18 @@ typedef void (*ompt_callback_flush_t) (
const void *codeptr_ra /* return address of runtime call */
);

typedef enum ompt_dispatch_t {
ompt_dispatch_iteration = 1,
ompt_dispatch_section = 2
} ompt_dispatch_t;

typedef void (*ompt_callback_dispatch_t) (
ompt_data_t *parallel_data,
ompt_data_t *task_data,
ompt_dispatch_t kind,
ompt_data_t instance
);

/****************************************************************************
* ompt API
***************************************************************************/
Expand Down Expand Up @@ -587,6 +616,12 @@ OMPT_API_FUNCTION(int, ompt_get_task_info, (
int *thread_num
));

OMPT_API_FUNCTION(int, ompt_get_task_memory, (
void **addr,
size_t *size,
int block
));

/* procs */
OMPT_API_FUNCTION(int, ompt_get_num_procs, (void));

Expand Down Expand Up @@ -615,7 +650,7 @@ OMPT_API_FUNCTION(int, ompt_get_proc_id, (void));
***************************************************************************/

OMPT_API_FUNCTION(int, ompt_initialize, (
ompt_function_lookup_t ompt_fn_lookup,
ompt_function_lookup_t lookup,
ompt_data_t *tool_data
));

Expand Down Expand Up @@ -673,6 +708,9 @@ OMPT_API_FUNCTION(int, ompt_enumerate_mutex_impls, (
/* get_unique_id */
OMPT_API_FUNCTION(uint64_t, ompt_get_unique_id, (void));

/* finalize tool */
OMPT_API_FUNCTION(void, ompt_finalize_tool, (void));

#ifdef __cplusplus
};
#endif
Expand Down
6 changes: 3 additions & 3 deletions openmp/runtime/src/kmp_barrier.cpp
Expand Up @@ -1223,7 +1223,7 @@ int __kmp_barrier(enum barrier_type bt, int gtid, int is_split,
kmp_info_t *this_thr = __kmp_threads[gtid];
kmp_team_t *team = this_thr->th.th_team;
int status = 0;
#if OMPT_SUPPORT
#if OMPT_SUPPORT && OMPT_OPTIONAL
ompt_data_t *my_task_data;
ompt_data_t *my_parallel_data;
void *return_address;
Expand Down Expand Up @@ -1599,10 +1599,10 @@ void __kmp_join_barrier(int gtid) {

ANNOTATE_BARRIER_BEGIN(&team->t.t_bar);
#if OMPT_SUPPORT
ompt_data_t *my_task_data;
ompt_data_t *my_parallel_data;
if (ompt_enabled.enabled) {
#if OMPT_OPTIONAL
ompt_data_t *my_task_data;
ompt_data_t *my_parallel_data;
void *codeptr = NULL;
int ds_tid = this_thr->th.th_info.ds.ds_tid;
if (KMP_MASTER_TID(ds_tid) &&
Expand Down
4 changes: 2 additions & 2 deletions openmp/runtime/src/kmp_cancel.cpp
Expand Up @@ -65,7 +65,7 @@ kmp_int32 __kmpc_cancel(ident_t *loc_ref, kmp_int32 gtid, kmp_int32 cncl_kind) {
if (cncl_kind == cancel_parallel)
type = ompt_cancel_parallel;
else if (cncl_kind == cancel_loop)
type = ompt_cancel_do;
type = ompt_cancel_loop;
else if (cncl_kind == cancel_sections)
type = ompt_cancel_sections;
ompt_callbacks.ompt_callback(ompt_callback_cancel)(
Expand Down Expand Up @@ -172,7 +172,7 @@ kmp_int32 __kmpc_cancellationpoint(ident_t *loc_ref, kmp_int32 gtid,
if (cncl_kind == cancel_parallel)
type = ompt_cancel_parallel;
else if (cncl_kind == cancel_loop)
type = ompt_cancel_do;
type = ompt_cancel_loop;
else if (cncl_kind == cancel_sections)
type = ompt_cancel_sections;
ompt_callbacks.ompt_callback(ompt_callback_cancel)(
Expand Down

0 comments on commit 489cdb7

Please sign in to comment.