Updating implementation of OMPT as specified in OpenMP 5.0 Preview 2 (TR6)
authorJoachim Protze <protze@itc.rwth-aachen.de>
Sun, 5 Nov 2017 14:11:19 +0000 (14:11 +0000)
committerJoachim Protze <protze@itc.rwth-aachen.de>
Sun, 5 Nov 2017 14:11:19 +0000 (14:11 +0000)
The TR6 document is expected to be publically released around November 15.
This patch does not implement OMPT for libomptarget.

Patch by Simon Convent and Joachim Protze

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

llvm-svn: 317436

openmp/runtime/src/exports_so.txt
openmp/runtime/src/include/50/ompt.h.var
openmp/runtime/src/kmp_gsupport.cpp
openmp/runtime/src/ompt-event-specific.h
openmp/runtime/src/ompt-general.cpp
openmp/runtime/test/ompt/callback.h
openmp/runtime/test/ompt/loadtool/tool_available.c

index ff16fae..894f578 100644 (file)
@@ -30,15 +30,6 @@ VERSION {
         # icc drops weak attribute at linking step without the following line:
         Annotate*;           # TSAN annotation
 
-        #
-        # OMPT state placeholders
-        #
-        ompt_idle;
-        ompt_overhead;
-        ompt_barrier_wait;
-        ompt_task_wait;
-        ompt_mutex_wait;
-
         ompc_*;    # omp.h renames some standard functions to ompc_*.
         kmp_*;     # Intel extensions.
         kmpc_*;    # Intel extensions.
index a73662e..0cae6a0 100644 (file)
     macro(ompt_get_target_info)             \
     macro(ompt_get_num_devices)
 
-#define FOREACH_OMPT_PLACEHOLDER_FN(macro)  \
-    macro (ompt_idle)                       \
-    macro (ompt_overhead)                   \
-    macro (ompt_barrier_wait)               \
-    macro (ompt_task_wait)                  \
-    macro (ompt_mutex_wait)
-
 #define FOREACH_OMP_STATE(macro)                                                                \
                                                                                                 \
     /* first available state */                                                                 \
     macro (ompt_mutex_impl_queuing, 2)      /* based on some fair policy */           \
     macro (ompt_mutex_impl_speculative, 3)  /* based on HW-supported speculation */
 
-#define FOREACH_OMPT_EVENT(macro)                                                                               \
-                                                                                                                \
-    /*--- Mandatory Events ---*/                                                                                \
-    macro (ompt_callback_thread_begin,          ompt_callback_thread_begin_t,   1) /* thread begin */           \
-    macro (ompt_callback_thread_end,            ompt_callback_thread_end_t,     2) /* thread end */             \
-                                                                                                                \
-    macro (ompt_callback_parallel_begin,        ompt_callback_parallel_begin_t, 3) /* parallel begin */         \
-    macro (ompt_callback_parallel_end,          ompt_callback_parallel_end_t,   4) /* parallel end */           \
-                                                                                                                \
-    macro (ompt_callback_task_create,           ompt_callback_task_create_t,    5) /* task begin */             \
-    macro (ompt_callback_task_schedule,         ompt_callback_task_schedule_t,  6) /* task schedule */          \
-    macro (ompt_callback_implicit_task,         ompt_callback_implicit_task_t,  7) /* implicit task   */        \
-                                                                                                                \
-    macro (ompt_callback_target,                ompt_callback_target_t,         8) /* target */                 \
-    macro (ompt_callback_target_data_op,        ompt_callback_target_data_op_t, 9) /* target data op*/          \
-    macro (ompt_callback_target_submit,         ompt_callback_target_submit_t, 10) /* target  submit*/          \
-                                                                                                                \
-    macro (ompt_callback_control_tool,          ompt_callback_control_tool_t,  11) /* control tool */           \
-                                                                                                                \
-    macro (ompt_callback_device_initialize,     ompt_callback_device_initialize_t, 12) /* device initialize */  \
-    macro (ompt_callback_device_finalize,       ompt_callback_device_finalize_t, 13)   /* device finalize   */  \
-                                                                                                                \
-    /*--- Optional Events (blame shifting, ompt_event_unimplemented) ---*/                                      \
-                                                                                                                \
-    macro (ompt_callback_sync_region_wait,      ompt_callback_sync_region_t,   14) /* sync region wait begin or end*/  \
-                                                                                                                \
-    macro (ompt_callback_mutex_released,        ompt_callback_mutex_t,         15) /* mutex released */         \
-                                                                                                                \
-    /*--- Optional Events (synchronous events, ompt_event_unimplemented) --- */                                 \
-                                                                                                                \
-    macro (ompt_callback_task_dependences,      ompt_callback_task_dependences_t, 16) /* report task dependences  */\
-    macro (ompt_callback_task_dependence,       ompt_callback_task_dependence_t, 17) /* report task dependence  */\
-                                                                                                                \
-    macro (ompt_callback_work,                  ompt_callback_work_t,          18) /* task at work begin or end*/\
-                                                                                                                \
-    macro (ompt_callback_master,                ompt_callback_master_t,        19) /* task at master begin or end */\
-                                                                                                                \
-    macro (ompt_callback_target_map,            ompt_callback_target_map_t,    20) /* target map */             \
-                                                                                                                \
-    macro (ompt_callback_sync_region,           ompt_callback_sync_region_t,   21) /* sync region begin or end */ \
-                                                                                                                \
-    macro (ompt_callback_lock_init,             ompt_callback_mutex_acquire_t, 22) /* lock init */              \
-    macro (ompt_callback_lock_destroy,          ompt_callback_mutex_t,         23) /* lock destroy */           \
-                                                                                                                \
-    macro (ompt_callback_mutex_acquire,         ompt_callback_mutex_acquire_t, 24) /* mutex acquire */          \
-    macro (ompt_callback_mutex_acquired,        ompt_callback_mutex_t,         25) /* mutex acquired */         \
-                                                                                                                \
-    macro (ompt_callback_nest_lock,             ompt_callback_nest_lock_t,     26) /* nest lock */              \
-                                                                                                                \
-    macro (ompt_callback_flush,                 ompt_callback_flush_t,         27) /* after executing flush */  \
-                                                                                                                \
-    macro (ompt_callback_cancel,                ompt_callback_cancel_t,        28) /*cancel innermost binding region*/\
-    macro (ompt_callback_idle,                  ompt_callback_idle_t,          29) /* begin or end idle state */\
+#define FOREACH_OMPT_EVENT(macro)                                                                                        \
+                                                                                                                         \
+    /*--- Mandatory Events ---*/                                                                                         \
+    macro (ompt_callback_thread_begin,      ompt_callback_thread_begin_t,       1) /* thread begin                    */ \
+    macro (ompt_callback_thread_end,        ompt_callback_thread_end_t,         2) /* thread end                      */ \
+                                                                                                                         \
+    macro (ompt_callback_parallel_begin,    ompt_callback_parallel_begin_t,     3) /* parallel begin                  */ \
+    macro (ompt_callback_parallel_end,      ompt_callback_parallel_end_t,       4) /* parallel end                    */ \
+                                                                                                                         \
+    macro (ompt_callback_task_create,       ompt_callback_task_create_t,        5) /* task begin                      */ \
+    macro (ompt_callback_task_schedule,     ompt_callback_task_schedule_t,      6) /* task schedule                   */ \
+    macro (ompt_callback_implicit_task,     ompt_callback_implicit_task_t,      7) /* implicit task                   */ \
+                                                                                                                         \
+    macro (ompt_callback_target,            ompt_callback_target_t,             8) /* target                          */ \
+    macro (ompt_callback_target_data_op,    ompt_callback_target_data_op_t,     9) /* target data op                  */ \
+    macro (ompt_callback_target_submit,     ompt_callback_target_submit_t,     10) /* target  submit                  */ \
+                                                                                                                         \
+    macro (ompt_callback_control_tool,      ompt_callback_control_tool_t,      11) /* control tool                    */ \
+                                                                                                                         \
+    macro (ompt_callback_device_initialize, ompt_callback_device_initialize_t, 12) /* device initialize               */ \
+    macro (ompt_callback_device_finalize,   ompt_callback_device_finalize_t,   13) /* device finalize                 */ \
+                                                                                                                         \
+    macro (ompt_callback_device_load,       ompt_callback_device_load_t,       14) /* device load                     */ \
+    macro (ompt_callback_device_unload,     ompt_callback_device_unload_t,     15) /* device unload                   */ \
+                                                                                                                         \
+    /* Optional Events */                                                                                                \
+    macro (ompt_callback_sync_region_wait,  ompt_callback_sync_region_t,       16) /* sync region wait begin or end   */ \
+                                                                                                                         \
+    macro (ompt_callback_mutex_released,    ompt_callback_mutex_t,             17) /* mutex released                  */ \
+                                                                                                                         \
+    macro (ompt_callback_task_dependences,  ompt_callback_task_dependences_t,  18) /* report task dependences         */ \
+    macro (ompt_callback_task_dependence,   ompt_callback_task_dependence_t,   19) /* report task dependence          */ \
+                                                                                                                         \
+    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_target_map,        ompt_callback_target_map_t,        22) /* target map                      */ \
+                                                                                                                         \
+    macro (ompt_callback_sync_region,       ompt_callback_sync_region_t,       23) /* sync region begin or end        */ \
+                                                                                                                         \
+    macro (ompt_callback_lock_init,         ompt_callback_mutex_acquire_t,     24) /* lock init                       */ \
+    macro (ompt_callback_lock_destroy,      ompt_callback_mutex_t,             25) /* lock destroy                    */ \
+                                                                                                                         \
+    macro (ompt_callback_mutex_acquire,     ompt_callback_mutex_acquire_t,     26) /* mutex acquire                   */ \
+    macro (ompt_callback_mutex_acquired,    ompt_callback_mutex_t,             27) /* mutex acquired                  */ \
+                                                                                                                         \
+    macro (ompt_callback_nest_lock,         ompt_callback_nest_lock_t,         28) /* nest lock                       */ \
+                                                                                                                         \
+    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_idle,              ompt_callback_idle_t,              31) /* begin or end idle state         */
 
 
 
 typedef uint64_t ompt_id_t;
 #define ompt_id_none 0
 
-typedef union ompt_data_u {
+typedef union ompt_data_t {
   uint64_t value; /* data initialized by runtime to unique id */
   void *ptr;      /* pointer under tool control */
 } ompt_data_t;
@@ -189,16 +182,16 @@ typedef struct ompt_frame_t {
  * dependences types
  *---------------------*/
 
-typedef enum ompt_task_dependence_flag_e {
+typedef enum ompt_task_dependence_flag_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;
 
-typedef struct ompt_task_dependence_s {
+typedef struct ompt_task_dependence_t {
     void *variable_addr;
-    uint32_t  dependence_flags;
+    unsigned int dependence_flags;
 } ompt_task_dependence_t;
 
 
@@ -231,7 +224,7 @@ typedef enum ompt_callbacks_e{
 /*---------------------
  * set callback results
  *---------------------*/
-typedef enum ompt_set_result_e {
+typedef enum ompt_set_result_t {
     ompt_set_error = 0,
     ompt_set_never = 1,
     ompt_set_sometimes = 2,
@@ -243,7 +236,7 @@ typedef enum ompt_set_result_e {
 /*----------------------
  * mutex implementations
  *----------------------*/
-typedef enum ompt_mutex_impl_e {
+typedef enum ompt_mutex_impl_t {
 #define ompt_mutex_impl_macro(impl, code) impl = code,
     FOREACH_OMPT_MUTEX_IMPL(ompt_mutex_impl_macro)
 #undef ompt_mutex_impl_macro
@@ -262,13 +255,14 @@ typedef ompt_interface_fn_t (*ompt_function_lookup_t)(
 );
 
 /* threads */
-typedef enum {
+typedef enum ompt_thread_type_t {
     ompt_thread_initial = 1, // start the enumeration at 1
     ompt_thread_worker  = 2,
-    ompt_thread_other   = 3
+    ompt_thread_other   = 3,
+    ompt_thread_unknown = 4
 } ompt_thread_type_t;
 
-typedef enum {
+typedef enum ompt_invoker_t {
     ompt_invoker_program = 1,             /* program invokes master task         */
     ompt_invoker_runtime = 2              /* runtime invokes master task         */
 } ompt_invoker_t;
@@ -287,9 +281,9 @@ typedef void (*ompt_wait_callback_t) (
 );
 
 /* parallel and workshares */
-typedef enum ompt_scope_endpoint_e {
+typedef enum ompt_scope_endpoint_t {
     ompt_scope_begin = 1,
-    ompt_scope_end = 2
+    ompt_scope_end   = 2
 } ompt_scope_endpoint_t;
 
 
@@ -303,23 +297,23 @@ typedef void (*ompt_callback_implicit_task_t) (
 );
 
 typedef void (*ompt_callback_parallel_begin_t) (
-    ompt_data_t *parent_task_data,        /* data of parent task                 */
-    const ompt_frame_t *parent_frame,     /* frame data of parent 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              */
-    const void *codeptr_ra                /* return address of runtime call      */
+    ompt_data_t *encountering_task_data,         /* data of encountering task           */
+    const ompt_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              */
+    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 *task_data,               /* data of task                        */
+    ompt_data_t *encountering_task_data,  /* data of encountering task           */
     ompt_invoker_t invoker,               /* invoker of master task              */ 
     const void *codeptr_ra                /* return address of runtime call      */
 );
 
 /* tasks */
-typedef enum ompt_task_type_e {
+typedef enum ompt_task_type_t {
     ompt_task_initial    = 0x1,
     ompt_task_implicit   = 0x2,
     ompt_task_explicit   = 0x4,
@@ -331,7 +325,7 @@ typedef enum ompt_task_type_e {
     ompt_task_merged     = 0x80000000
 } ompt_task_type_t;
 
-typedef enum ompt_task_status_e {
+typedef enum ompt_task_status_t {
     ompt_task_complete = 1,
     ompt_task_yield    = 2,
     ompt_task_cancel   = 3,
@@ -345,12 +339,12 @@ typedef void (*ompt_callback_task_schedule_t) (
 );
 
 typedef void (*ompt_callback_task_create_t) (
-    ompt_data_t *parent_task_data,        /* data of parent task                 */
-    const ompt_frame_t *parent_frame,     /* frame data for parent task          */
-    ompt_data_t *new_task_data,           /* data of created task                */
-    int type,                             /* type of created task                */
-    int has_dependences,                  /* created task has dependences        */
-    const void *codeptr_ra                /* return address of runtime call      */
+    ompt_data_t *encountering_task_data,         /* data of parent task                 */
+    const ompt_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 has_dependences,                         /* created task has dependences        */
+    const void *codeptr_ra                       /* return address of runtime call      */
 );
 
 /* task dependences */
@@ -366,7 +360,7 @@ typedef void (*ompt_callback_task_dependence_t) (
 );
 
 /* target and device */
-typedef enum ompt_target_type_e {
+typedef enum ompt_target_type_t {
     ompt_target = 1,
     ompt_target_enter_data = 2,
     ompt_target_exit_data = 3,
@@ -382,7 +376,7 @@ typedef void (*ompt_callback_target_t) (
     const void *codeptr_ra
 );
 
-typedef enum ompt_target_data_op_e {
+typedef enum ompt_target_data_op_t {
     ompt_target_data_alloc = 1,
     ompt_target_data_transfer_to_dev = 2,
     ompt_target_data_transfer_from_dev = 3,
@@ -424,6 +418,24 @@ typedef void (*ompt_callback_device_finalize_t) (
     uint64_t device_num
 );
 
+typedef void (*ompt_callback_device_load_t) (
+    uint64_t device_num,
+    const char * filename,
+    int64_t offset_in_file,
+    void * vma_in_file,
+    size_t bytes,
+    void * host_addr,
+    void * device_addr,
+    uint64_t module_id
+);
+
+#define ompt_addr_unknown ((void *) ~0)
+
+typedef void (*ompt_callback_device_unload_t) (
+    uint64_t device_num,
+    uint64_t module_id
+);
+
 /* control_tool */
 typedef int (*ompt_callback_control_tool_t) (
     uint64_t command,                     /* command of control call             */
@@ -432,13 +444,13 @@ typedef int (*ompt_callback_control_tool_t) (
     const void *codeptr_ra                /* return address of runtime call      */
 );
 
-typedef enum ompt_mutex_kind_e {
-    ompt_mutex = 0x10,
-    ompt_mutex_lock = 0x11,
+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_critical  = 0x13,
+    ompt_mutex_atomic    = 0x14,
+    ompt_mutex_ordered   = 0x20
 } ompt_mutex_kind_t;
 
 typedef void (*ompt_callback_mutex_acquire_t) (
@@ -472,14 +484,14 @@ typedef void (*ompt_callback_idle_t) (
     ompt_scope_endpoint_t endpoint        /* endpoint of idle time               */
 );
 
-typedef enum ompt_work_type_e {
-    ompt_work_loop = 1,
-    ompt_work_sections = 2,
+typedef enum ompt_work_type_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_single_other    = 4,
+    ompt_work_workshare       = 5,
+    ompt_work_distribute      = 6,
+    ompt_work_taskloop        = 7
 } ompt_work_type_t;
 
 typedef void (*ompt_callback_work_t) (
@@ -491,9 +503,9 @@ typedef void (*ompt_callback_work_t) (
     const void *codeptr_ra                /* return address of runtime call      */
 );
 
-typedef enum ompt_sync_region_kind_e {
-    ompt_sync_region_barrier = 1,
-    ompt_sync_region_taskwait = 2,
+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;
 
@@ -505,7 +517,7 @@ typedef void (*ompt_callback_sync_region_t) (
     const void *codeptr_ra                /* return address of runtime call      */
 );
 
-typedef enum ompt_cancel_flag_e {
+typedef enum ompt_cancel_flag_t {
     ompt_cancel_parallel       = 0x1,
     ompt_cancel_sections       = 0x2,
     ompt_cancel_do             = 0x4,
@@ -591,61 +603,29 @@ OMPT_API_FUNCTION(int, ompt_get_proc_id, (void));
 
 
 /****************************************************************************
- * PLACEHOLDERS FOR PERFORMANCE REPORTING
- ***************************************************************************/
-
-/* idle */
-OMPT_API_FUNCTION(void, ompt_idle, (
-    void
-));
-
-/* overhead */
-OMPT_API_FUNCTION(void, ompt_overhead, (
-    void
-));
-
-/* barrier wait */
-OMPT_API_FUNCTION(void, ompt_barrier_wait, (
-    void
-));
-
-/* task wait */
-OMPT_API_FUNCTION(void, ompt_task_wait, (
-    void
-));
-
-/* mutex wait */
-OMPT_API_FUNCTION(void, ompt_mutex_wait, (
-    void
-));
-
-
-
-/****************************************************************************
  * INITIALIZATION FUNCTIONS
  ***************************************************************************/
 
-typedef struct ompt_fns_t ompt_fns_t;
-
 OMPT_API_FUNCTION(int, ompt_initialize, (
     ompt_function_lookup_t ompt_fn_lookup,
-    ompt_fns_t *fns
+    ompt_data_t *tool_data
 ));
 
 OMPT_API_FUNCTION(void, ompt_finalize, (
-    ompt_fns_t *fns
+    ompt_data_t *tool_data
 ));
 
-struct ompt_fns_t {
+typedef struct ompt_start_tool_result_t {
     ompt_initialize_t initialize;
     ompt_finalize_t finalize;
-};
+    ompt_data_t tool_data;
+} ompt_start_tool_result_t;
 
 /* initialization interface to be defined by tool */
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-ompt_fns_t * ompt_start_tool(
+ompt_start_tool_result_t * ompt_start_tool(
     unsigned int omp_version, 
     const char * runtime_version
 );
@@ -657,15 +637,6 @@ OMPT_API_FUNCTION(int, ompt_set_callback, (
     ompt_callback_t callback
 ));
 
-typedef enum ompt_set_callback_rc_e {  /* non-standard */
-    ompt_set_callback_error      = 0,
-    ompt_has_event_no_callback   = 1,
-    ompt_no_event_no_callback    = 2,
-    ompt_has_event_may_callback  = 3,
-    ompt_has_event_must_callback = 4,
-} ompt_set_callback_rc_t;
-
-
 OMPT_API_FUNCTION(int, ompt_get_callback, (
     ompt_callbacks_t which,
     ompt_callback_t *callback
index 9068163..b0b2349 100644 (file)
@@ -429,8 +429,8 @@ void xexpand(KMP_API_NAME_GOMP_PARALLEL_START)(void (*task)(void *), void *data,
   if (ompt_enabled.enabled) {
     __ompt_get_task_info_internal(0, NULL, NULL, &parent_frame, NULL, NULL);
     parent_frame->enter_frame = OMPT_GET_FRAME_ADDRESS(1);
+    OMPT_STORE_RETURN_ADDRESS(gtid);
   }
-  OMPT_STORE_RETURN_ADDRESS(gtid);
 #endif
 
   MKLOC(loc, "GOMP_parallel_start");
@@ -832,8 +832,8 @@ LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_NEXT),
   if (ompt_enabled.enabled) {                                                  \
     __ompt_get_task_info_internal(0, NULL, NULL, &parent_frame, NULL, NULL);   \
     parent_frame->enter_frame = OMPT_GET_FRAME_ADDRESS(1);                     \
-  }                                                                            \
-  OMPT_STORE_RETURN_ADDRESS(gtid);
+    OMPT_STORE_RETURN_ADDRESS(gtid);                                           \
+  }
 
 #define OMPT_LOOP_POST()                                                       \
   if (ompt_enabled.enabled) {                                                  \
@@ -1055,8 +1055,8 @@ void xexpand(KMP_API_NAME_GOMP_PARALLEL_SECTIONS_START)(void (*task)(void *),
   if (ompt_enabled.enabled) {
     __ompt_get_task_info_internal(0, NULL, NULL, &parent_frame, NULL, NULL);
     parent_frame->enter_frame = OMPT_GET_FRAME_ADDRESS(1);
+    OMPT_STORE_RETURN_ADDRESS(gtid);
   }
-  OMPT_STORE_RETURN_ADDRESS(gtid);
 #endif
 
   MKLOC(loc, "GOMP_parallel_sections_start");
@@ -1131,8 +1131,8 @@ void xexpand(KMP_API_NAME_GOMP_PARALLEL)(void (*task)(void *), void *data,
   if (ompt_enabled.enabled) {
     parent_task_info = __ompt_get_task_info_object(0);
     parent_task_info->frame.enter_frame = OMPT_GET_FRAME_ADDRESS(1);
+    OMPT_STORE_RETURN_ADDRESS(gtid);
   }
-  OMPT_STORE_RETURN_ADDRESS(gtid);
 #endif
   if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) {
     if (num_threads != 0) {
index 5f9a980..86ee699 100644 (file)
  | Mandatory Events
  +--------------------------------------------------------------------------*/
 
+#define ompt_callback_thread_begin_implemented ompt_event_MAY_ALWAYS
+#define ompt_callback_thread_end_implemented ompt_event_MAY_ALWAYS
+
 #define ompt_callback_parallel_begin_implemented ompt_event_MAY_ALWAYS
 #define ompt_callback_parallel_end_implemented ompt_event_MAY_ALWAYS
 
 #define ompt_callback_task_create_implemented ompt_event_MAY_ALWAYS
 #define ompt_callback_task_schedule_implemented ompt_event_MAY_ALWAYS
 
-#define ompt_callback_thread_begin_implemented ompt_event_MAY_ALWAYS
-#define ompt_callback_thread_end_implemented ompt_event_MAY_ALWAYS
-
-#define ompt_callback_control_tool_implemented ompt_event_MAY_ALWAYS
-
 #define ompt_callback_implicit_task_implemented ompt_event_MAY_ALWAYS
 
-/*----------------------------------------------------------------------------
- | Target Related Events (not yet implemented)
- +--------------------------------------------------------------------------*/
-
 #define ompt_callback_target_implemented ompt_event_UNIMPLEMENTED
 #define ompt_callback_target_data_op_implemented ompt_event_UNIMPLEMENTED
 #define ompt_callback_target_submit_implemented ompt_event_UNIMPLEMENTED
+
+#define ompt_callback_control_tool_implemented ompt_event_MAY_ALWAYS
+
 #define ompt_callback_device_initialize_implemented ompt_event_UNIMPLEMENTED
 #define ompt_callback_device_finalize_implemented ompt_event_UNIMPLEMENTED
 
-#define ompt_callback_target_map_implemented ompt_event_UNIMPLEMENTED
+#define ompt_callback_device_load_implemented ompt_event_UNIMPLEMENTED
+#define ompt_callback_device_unload_implemented ompt_event_UNIMPLEMENTED
 
 /*----------------------------------------------------------------------------
- | Optional Events (blame shifting)
+ | Optional Events
  +--------------------------------------------------------------------------*/
 
-#define ompt_callback_idle_implemented ompt_event_MAY_ALWAYS_OPTIONAL
-
 #define ompt_callback_sync_region_wait_implemented                             \
   ompt_event_MAY_ALWAYS_OPTIONAL
 
 #define ompt_callback_mutex_released_implemented ompt_event_MAY_ALWAYS_OPTIONAL
 
-/*----------------------------------------------------------------------------
- | Optional Events (synchronous events)
- +--------------------------------------------------------------------------*/
+#if OMP_40_ENABLED
+#define ompt_callback_task_dependences_implemented                             \
+  ompt_event_MAY_ALWAYS_OPTIONAL
+#define ompt_callback_task_dependence_implemented ompt_event_MAY_ALWAYS_OPTIONAL
+#else
+#define ompt_callback_task_dependences_implemented ompt_event_UNIMPLEMENTED
+#define ompt_callback_task_dependence_implemented ompt_event_UNIMPLEMENTED
+#endif /* OMP_40_ENABLED */
 
 #define ompt_callback_work_implemented ompt_event_MAY_ALWAYS_OPTIONAL
 
 #define ompt_callback_master_implemented ompt_event_MAY_ALWAYS_OPTIONAL
 
+#define ompt_callback_target_map_implemented ompt_event_UNIMPLEMENTED
+
 #define ompt_callback_sync_region_implemented ompt_event_MAY_ALWAYS_OPTIONAL
 
+#define ompt_callback_lock_init_implemented ompt_event_MAY_ALWAYS_OPTIONAL
+#define ompt_callback_lock_destroy_implemented ompt_event_MAY_ALWAYS_OPTIONAL
+
 #define ompt_callback_mutex_acquire_implemented ompt_event_MAY_ALWAYS_OPTIONAL
 #define ompt_callback_mutex_acquired_implemented ompt_event_MAY_ALWAYS_OPTIONAL
 #define ompt_callback_nest_lock_implemented ompt_event_MAY_ALWAYS_OPTIONAL
 
-#define ompt_callback_lock_init_implemented ompt_event_MAY_ALWAYS_OPTIONAL
-#define ompt_callback_lock_destroy_implemented ompt_event_MAY_ALWAYS_OPTIONAL
-
 #define ompt_callback_flush_implemented ompt_event_MAY_ALWAYS_OPTIONAL
 
 #define ompt_callback_cancel_implemented ompt_event_MAY_ALWAYS_OPTIONAL
 
-#if OMP_40_ENABLED
-#define ompt_callback_task_dependences_implemented                             \
-  ompt_event_MAY_ALWAYS_OPTIONAL
-#define ompt_callback_task_dependence_implemented ompt_event_MAY_ALWAYS_OPTIONAL
-#else
-#define ompt_callback_task_dependences_implemented ompt_event_UNIMPLEMENTED
-#define ompt_callback_task_dependence_implemented ompt_event_UNIMPLEMENTED
-#endif /* OMP_40_ENABLED */
+#define ompt_callback_idle_implemented ompt_event_MAY_ALWAYS_OPTIONAL
 
 #endif
index a6f0647..e9cb02c 100644 (file)
@@ -74,7 +74,7 @@ ompt_mutex_impl_info_t ompt_mutex_impl_info[] = {
 
 ompt_callbacks_internal_t ompt_callbacks;
 
-static ompt_fns_t *ompt_fns = NULL;
+static ompt_start_tool_result_t *ompt_start_tool_result = NULL;
 
 /*****************************************************************************
  * forward declarations
@@ -97,7 +97,8 @@ OMPT_API_ROUTINE ompt_data_t *ompt_get_thread_data(void);
  * found, ompt_tool's return value is used to initialize the tool. Otherwise,
  * NULL is returned and OMPT won't be enabled */
 
-typedef ompt_fns_t *(*ompt_start_tool_t)(unsigned int, const char *);
+typedef ompt_start_tool_result_t *(*ompt_start_tool_t)(unsigned int,
+                                                       const char *);
 
 #if KMP_OS_UNIX
 
@@ -109,13 +110,13 @@ _OMP_EXTERN
 #else
 #error Activation of OMPT is not supported on this platform.
 #endif
-ompt_fns_t *
+ompt_start_tool_result_t *
 ompt_start_tool(unsigned int omp_version, const char *runtime_version) {
 #ifdef KMP_DYNAMIC_LIB
-  ompt_fns_t *ret = NULL;
+  ompt_start_tool_result_t *ret = NULL;
   // Try next symbol in the address space
   ompt_start_tool_t next_tool = NULL;
-  next_tool = (ompt_start_tool_t)dlsym(RTLD_NEXT, "ompt_start_tool");
+  *(void **)(&next_tool) = dlsym(RTLD_NEXT, "ompt_start_tool");
   if (next_tool)
     ret = (next_tool)(omp_version, runtime_version);
   return ret;
@@ -136,8 +137,8 @@ ompt_start_tool(unsigned int omp_version, const char *runtime_version) {
 // The number of loaded modules to start enumeration with EnumProcessModules()
 #define NUM_MODULES 128
 
-static ompt_fns_t *ompt_tool_windows(unsigned int omp_version,
-                                     const char *runtime_version) {
+static ompt_start_tool_result_t *
+ompt_tool_windows(unsigned int omp_version, const char *runtime_version) {
   int i;
   DWORD needed, new_size;
   HMODULE *modules;
@@ -195,9 +196,9 @@ static ompt_fns_t *ompt_tool_windows(unsigned int omp_version,
 #error Either __attribute__((weak)) or psapi.dll are required for OMPT support
 #endif // OMPT_HAVE_WEAK_ATTRIBUTE
 
-static ompt_fns_t *ompt_try_start_tool(unsigned int omp_version,
-                                       const char *runtime_version) {
-  ompt_fns_t *ret = NULL;
+static ompt_start_tool_result_t *
+ompt_try_start_tool(unsigned int omp_version, const char *runtime_version) {
+  ompt_start_tool_result_t *ret = NULL;
   ompt_start_tool_t start_tool = NULL;
 #if KMP_OS_WINDOWS
   // Cannot use colon to describe a list of absolute paths on Windows
@@ -275,7 +276,7 @@ void ompt_pre_init() {
     //--------------------------------------------------
     // Load tool iff specified in environment variable
     //--------------------------------------------------
-    ompt_fns =
+    ompt_start_tool_result =
         ompt_try_start_tool(__kmp_openmp_version, ompt_get_runtime_version());
 
     memset(&ompt_enabled, 0, sizeof(ompt_enabled));
@@ -307,8 +308,9 @@ void ompt_post_init() {
   //--------------------------------------------------
   // Initialize the tool if so indicated.
   //--------------------------------------------------
-  if (ompt_fns) {
-    ompt_enabled.enabled = !!ompt_fns->initialize(ompt_fn_lookup, ompt_fns);
+  if (ompt_start_tool_result) {
+    ompt_enabled.enabled = !!ompt_start_tool_result->initialize(
+        ompt_fn_lookup, &(ompt_start_tool_result->tool_data));
 
     ompt_thread_t *root_thread = ompt_get_thread();
 
@@ -331,7 +333,7 @@ void ompt_post_init() {
 
 void ompt_fini() {
   if (ompt_enabled.enabled) {
-    ompt_fns->finalize(ompt_fns);
+    ompt_start_tool_result->finalize(&(ompt_start_tool_result->tool_data));
   }
 
   memset(&ompt_enabled, 0, sizeof(ompt_enabled));
@@ -577,56 +579,6 @@ OMPT_API_ROUTINE int ompt_get_proc_id(void) {
 }
 
 /*****************************************************************************
- * placeholders
- ****************************************************************************/
-
-// Don't define this as static. The loader may choose to eliminate the symbol
-// even though it is needed by tools.
-#define OMPT_API_PLACEHOLDER
-
-// Ensure that placeholders don't have mangled names in the symbol table.
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-OMPT_API_PLACEHOLDER void ompt_idle(void) {
-  // This function is a placeholder used to represent the calling context of
-  // idle OpenMP worker threads. It is not meant to be invoked.
-  assert(0);
-}
-
-OMPT_API_PLACEHOLDER void ompt_overhead(void) {
-  // This function is a placeholder used to represent the OpenMP context of
-  // threads working in the OpenMP runtime.  It is not meant to be invoked.
-  assert(0);
-}
-
-OMPT_API_PLACEHOLDER void ompt_barrier_wait(void) {
-  // This function is a placeholder used to represent the OpenMP context of
-  // threads waiting for a barrier in the OpenMP runtime. It is not meant
-  // to be invoked.
-  assert(0);
-}
-
-OMPT_API_PLACEHOLDER void ompt_task_wait(void) {
-  // This function is a placeholder used to represent the OpenMP context of
-  // threads waiting for a task in the OpenMP runtime. It is not meant
-  // to be invoked.
-  assert(0);
-}
-
-OMPT_API_PLACEHOLDER void ompt_mutex_wait(void) {
-  // This function is a placeholder used to represent the OpenMP context of
-  // threads waiting for a mutex in the OpenMP runtime. It is not meant
-  // to be invoked.
-  assert(0);
-}
-
-#ifdef __cplusplus
-};
-#endif
-
-/*****************************************************************************
  * compatability
  ****************************************************************************/
 
@@ -689,7 +641,5 @@ static ompt_interface_fn_t ompt_fn_lookup(const char *s) {
 
   FOREACH_OMPT_INQUIRY_FN(ompt_interface_fn)
 
-  FOREACH_OMPT_PLACEHOLDER_FN(ompt_interface_fn)
-
   return (ompt_interface_fn_t)0;
 }
index 69efd83..8e34d70 100755 (executable)
@@ -477,8 +477,8 @@ on_ompt_callback_master(
 
 static void
 on_ompt_callback_parallel_begin(
-  ompt_data_t *parent_task_data,
-  const ompt_frame_t *parent_task_frame,
+  ompt_data_t *encountering_task_data,
+  const ompt_frame_t *encountering_task_frame,
   ompt_data_t* parallel_data,
   uint32_t requested_team_size,
   ompt_invoker_t invoker,
@@ -493,21 +493,21 @@ on_ompt_callback_parallel_begin(
 static void
 on_ompt_callback_parallel_end(
   ompt_data_t *parallel_data,
-  ompt_data_t *task_data,
+  ompt_data_t *encountering_task_data,
   ompt_invoker_t invoker,
   const void *codeptr_ra)
 {
-  printf("%" PRIu64 ": ompt_event_parallel_end: parallel_id=%" PRIu64 ", task_id=%" PRIu64 ", invoker=%d, codeptr_ra=%p\n", ompt_get_thread_data()->value, parallel_data->value, task_data->value, invoker, codeptr_ra);
+  printf("%" PRIu64 ": ompt_event_parallel_end: parallel_id=%" PRIu64 ", task_id=%" PRIu64 ", invoker=%d, codeptr_ra=%p\n", ompt_get_thread_data()->value, parallel_data->value, encountering_task_data->value, invoker, codeptr_ra);
 }
 
 static void
 on_ompt_callback_task_create(
-    ompt_data_t *parent_task_data,     /* id of parent task            */
-    const ompt_frame_t *parent_frame,  /* frame data for parent task   */
-    ompt_data_t* new_task_data,        /* id of created task           */
+    ompt_data_t *encountering_task_data,
+    const ompt_frame_t *encountering_task_frame,
+    ompt_data_t* new_task_data,
     int type,
     int has_dependences,
-    const void *codeptr_ra)               /* pointer to outlined function */
+    const void *codeptr_ra)
 {
   if(new_task_data->ptr)
     printf("%s\n", "0: new_task_data initially not null");
@@ -516,7 +516,7 @@ on_ompt_callback_task_create(
 
   format_task_type(type, buffer);
 
-  //there is no paralllel_begin callback for implicit parallel region
+  //there is no parallel_begin callback for implicit parallel region
   //thus it is initialized in initial task
   if(type & ompt_task_initial)
   {
@@ -603,7 +603,7 @@ do{                                                           \
 
 int ompt_initialize(
   ompt_function_lookup_t lookup,
-  ompt_fns_t* fns)
+  ompt_data_t *tool_data)
 {
   ompt_set_callback = (ompt_set_callback_t) lookup("ompt_set_callback");
   ompt_get_task_info = (ompt_get_task_info_t) lookup("ompt_get_task_info");
@@ -646,15 +646,15 @@ int ompt_initialize(
   return 1; //success
 }
 
-void ompt_finalize(ompt_fns_t* fns)
+void ompt_finalize(ompt_data_t *tool_data)
 {
   printf("0: ompt_event_runtime_shutdown\n");
 }
 
-ompt_fns_t* ompt_start_tool(
+ompt_start_tool_result_t* ompt_start_tool(
   unsigned int omp_version,
   const char *runtime_version)
 {
-  static ompt_fns_t ompt_fns = {&ompt_initialize,&ompt_finalize};
-  return &ompt_fns;
+  static ompt_start_tool_result_t ompt_start_tool_result = {&ompt_initialize,&ompt_finalize, 0};
+  return &ompt_start_tool_result;
 }
index 0205193..22fdade 100644 (file)
@@ -38,22 +38,22 @@ int main()
 
 int ompt_initialize(
   ompt_function_lookup_t lookup,
-  ompt_fns_t* fns)
+  ompt_data_t* tool_data)
 {
   printf("0: NULL_POINTER=%p\n", (void*)NULL);
   return 1; //success
 }
 
-void ompt_finalize(ompt_fns_t* fns)
+void ompt_finalize(ompt_data_t* tool_data)
 {
   printf("%d: ompt_event_runtime_shutdown\n", omp_get_thread_num());
 }
 
-ompt_fns_t* ompt_start_tool(
+ompt_start_tool_result_t* ompt_start_tool(
   unsigned int omp_version,
   const char *runtime_version)
 {
-  static ompt_fns_t ompt_fns = {&ompt_initialize,&ompt_finalize};
-  return &ompt_fns;
+  static ompt_start_tool_result_t ompt_start_tool_result = {&ompt_initialize,&ompt_finalize, 0};
+  return &ompt_start_tool_result;
 }
 #endif /* TOOL */