Index: openmp/tools/multiplex/CMakeLists.txt =================================================================== --- /dev/null +++ openmp/tools/multiplex/CMakeLists.txt @@ -0,0 +1,12 @@ +project(OMPT-Multiplex) + +if(LIBOMP_OMPT_SUPPORT) + include_directories(${LIBOMP_INCLUDE_DIR}) + + add_library(ompt-multiplex INTERFACE) + target_include_directories(ompt-multiplex INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) + + install(FILES ompt-multiplex.h DESTINATION include) + + add_subdirectory(tests) +endif() Index: openmp/tools/multiplex/README.md =================================================================== --- /dev/null +++ openmp/tools/multiplex/README.md @@ -0,0 +1,60 @@ +# OMPT-Multiplexing +The OMPT-Multiplexing header file allows a tool to load a second tool to +overcome the restriction of the OpenMP to only load one tool at a time. +The header file can also be used to load more than two tools using a cascade +of tools that include the header file. OMPT-Multiplexing takes care of the +multiplexing of OMPT callbacks, data pointers and runtime entry functions. + +Examples can be found under ./tests + +## Prerequisits +- LLVM/OpenMP runtime with OMPT (https://github.com/OpenMPToolsInterface/LLVM-openmp) +- LLVM-lit + +### Getting LLVM-lit +Either build llvm and find lit+FileCheck in build directory of llvm or install using `pip`: +``` + $ pip install --upgrade --user pip + $ export PATH=$HOME/.local/bin:$PATH + $ export PYTHONPATH=$HOME/.local/lib/python2.7/site-packages/ + $ pip install --user lit +``` + +## How to test +``` + $ make check-ompt-multiplex +``` + +## How to compile and use your OpenMP tools +Code of first tool must include the following with the convention, that the environment variable containing the path to the client tool is the tool name with the suffix "_TOOL_LIBRARIES": +``` +#define CLIENT_TOOL_LIBRARIES_VAR "EXAMPLE_TOOL_LIBRARIES" +#include +``` +Note that functions and variables with prefix "ompt_multiplexing" are reserved by the tool + + +To use both tools execute the following: +``` + $ clang -fopenmp -o program.exe + $ OMP_TOOL_LIBRARIES=/path/to/first/tool.so EXAMPLE_TOOL_LBRARIES=/path/to/second/tool.so ./program.exe +``` +Note that EXAMPLE_TOOL_LIBRARIES may also contain a list of paths to tools which will be tried to load in order (similar to lists in OMP_TOOL_LIBRARIES). + +## Advanced usage +To reduce the amount of memorz allocations, the user can define macros before including the ompt-multiplex.h file, that specify custom data access handlers: + +``` +#define OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_THREAD_DATA get_client_thread_data +#define OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_PARALLEL_DATA get_client_parallel_data +#define OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_TASK_DATA get_client_task_data +``` + +This will reverse the calling order of the current tool and its client. In order to avoid this, one can specify a custom delete handler as well: + +``` +#define OMPT_MULTIPLEX_CUSTOM_DELETE_THREAD_DATA delete_thread_data +#define OMPT_MULTIPLEX_CUSTOM_DELETE_PARALLEL_DATA delete_parallel_data +#define OMPT_MULTIPLEX_CUSTOM_DELETE_TASK_DATA delete_task_data +``` + Index: openmp/tools/multiplex/ompt-multiplex.h =================================================================== --- /dev/null +++ openmp/tools/multiplex/ompt-multiplex.h @@ -0,0 +1,901 @@ +/* + * ompt-multiplex.h -- header-only multiplexing of OMPT tools + */ + +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef OMPT_MULTIPLEX_H +#define OMPT_MULTIPLEX_H + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif +#include +#include +#include +#include +#include +#include +#include + +static ompt_set_callback_t ompt_multiplex_set_callback; +static ompt_get_task_info_t ompt_multiplex_get_task_info; +static ompt_get_thread_data_t ompt_multiplex_get_thread_data; +static ompt_get_parallel_info_t ompt_multiplex_get_parallel_info; + +//contains name of the environment var in which the tool path is specified +#ifndef CLIENT_TOOL_LIBRARIES_VAR +#error CLIENT_TOOL_LIBRARIES_VAR should be defined before including of ompt-multiplex.h +#endif + +#if defined(CUSTOM_DELETE_DATA) && !defined(CUSTOM_GET_CLIENT_DATA) +#error CUSTOM_GET_CLIENT_DATA must be set if CUSTOM_DELETE_DATA is set +#endif + +#define OMPT_API_ROUTINE static + +#define OMPT_LOAD_CLIENT_FOREACH_OMPT_EVENT(macro) \ + \ + \ + /*--- Mandatory Events ---*/ \ + macro (callback_thread_begin, ompt_callback_thread_begin_t, 1) /* thread begin */ \ + macro (callback_thread_end, ompt_callback_thread_end_t, 2) /* thread end */ \ + \ + macro (callback_parallel_begin, ompt_callback_parallel_begin_t, 3) /* parallel begin */ \ + macro (callback_parallel_end, ompt_callback_parallel_end_t, 4) /* parallel end */ \ + \ + macro (callback_task_create, ompt_callback_task_create_t, 5) /* task begin */ \ + macro (callback_task_schedule, ompt_callback_task_schedule_t, 6) /* task schedule */ \ + macro (callback_implicit_task, ompt_callback_implicit_task_t, 7) /* implicit task */ \ + \ + /*macro (callback_target, ompt_callback_target_t, 8)*/ /* target */ \ + /*macro (callback_target_data_op, ompt_callback_target_data_op_t, 9)*/ /* target data op */ \ + /*macro (callback_target_submit, ompt_callback_target_submit_t, 10)*/ /* target submit */ \ + \ + macro (callback_control_tool, ompt_callback_control_tool_t, 11) /* control tool */ \ + \ + /*macro (callback_device_initialize, ompt_callback_device_initialize_t, 12)*/ /* device initialize */ \ + /*macro (callback_device_finalize, ompt_callback_device_finalize_t, 13)*/ /* device finalize */ \ + \ + /*macro (callback_device_load, ompt_callback_device_load_t, 14)*/ /* device load */ \ + /*macro (callback_device_unload, ompt_callback_device_unload_t, 15)*/ /* device unload */ \ + \ + /* Optional Events */ \ + macro (callback_sync_region_wait, ompt_callback_sync_region_t, 16) /* sync region wait begin or end */ \ + \ + macro (callback_mutex_released, ompt_callback_mutex_t, 17) /* mutex released */ \ + \ + macro (callback_dependences, ompt_callback_dependences_t, 18) /* report task dependences */ \ + macro (callback_task_dependence, ompt_callback_task_dependence_t, 19) /* report task dependence */ \ + \ + macro (callback_work, ompt_callback_work_t, 20) /* task at work begin or end */ \ + \ + macro (callback_master, ompt_callback_master_t, 21) /* task at master begin or end */ \ + \ + /*macro (callback_target_map, ompt_callback_target_map_t, 22)*/ /* target map */ \ + \ + macro (callback_sync_region, ompt_callback_sync_region_t, 23) /* sync region begin or end */ \ + \ + macro (callback_lock_init, ompt_callback_mutex_acquire_t, 24) /* lock init */ \ + macro (callback_lock_destroy, ompt_callback_mutex_t, 25) /* lock destroy */ \ + \ + macro (callback_mutex_acquire, ompt_callback_mutex_acquire_t, 26) /* mutex acquire */ \ + macro (callback_mutex_acquired, ompt_callback_mutex_t, 27) /* mutex acquired */ \ + \ + macro (callback_nest_lock, ompt_callback_nest_lock_t, 28) /* nest lock */ \ + \ + macro (callback_flush, ompt_callback_flush_t, 29) /* after executing flush */ \ + \ + macro (callback_cancel, ompt_callback_cancel_t, 30) /* cancel innermost binding region */ \ + \ + /*macro (callback_reduction, ompt_callback_sync_region_t, 31)*/ /* reduction */ \ + \ + /*macro (callback_dispatch, ompt_callback_dispatch_t, 32)*/ /* dispatch of work */ + +typedef struct ompt_multiplex_callbacks_s { +#define ompt_event_macro(event, callback, eventid) \ + callback ompt_##event; + + OMPT_LOAD_CLIENT_FOREACH_OMPT_EVENT(ompt_event_macro) + +#undef ompt_event_macro +} ompt_multiplex_callbacks_t; + +typedef struct ompt_multiplex_callback_implementation_status_s { +#define ompt_event_macro(event, callback, eventid) \ + int ompt_##event; + + OMPT_LOAD_CLIENT_FOREACH_OMPT_EVENT(ompt_event_macro) + +#undef ompt_event_macro +} ompt_multiplex_callback_implementation_status_t; + +ompt_start_tool_result_t* ompt_multiplex_own_fns; +ompt_start_tool_result_t* ompt_multiplex_client_fns; +ompt_function_lookup_t ompt_multiplex_lookup_function; +ompt_multiplex_callbacks_t ompt_multiplex_own_callbacks, ompt_multiplex_client_callbacks; +ompt_multiplex_callback_implementation_status_t ompt_multiplex_implementation_status; + +typedef struct ompt_multiplex_data_pair_s +{ + ompt_data_t own_data; + ompt_data_t client_data; +} ompt_multiplex_data_pair_t; + + +#if !defined(OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_THREAD_DATA) || !defined(OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_PARALLEL_DATA) || !defined(OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_TASK_DATA) +static ompt_multiplex_data_pair_t* ompt_multiplex_allocate_data_pair(ompt_data_t* data_pointer) +{ + data_pointer->ptr = malloc(sizeof(ompt_multiplex_data_pair_t)); + if(!data_pointer->ptr) + { + printf("Malloc ERROR\n"); + exit(-1); + } + ompt_multiplex_data_pair_t* data_pair = (ompt_multiplex_data_pair_t*) data_pointer->ptr; + data_pair->own_data.ptr = NULL; + data_pair->client_data.ptr = NULL; + return data_pair; +} + +static void ompt_multiplex_free_data_pair(ompt_data_t* data_pointer) +{ + free((*data_pointer).ptr); +} + +static ompt_data_t* ompt_multiplex_get_own_ompt_data(ompt_data_t* data) +{ + if(!data) + return NULL; + ompt_multiplex_data_pair_t* data_pair = (ompt_multiplex_data_pair_t*) data->ptr; + return &(data_pair->own_data); +} + +static ompt_data_t* ompt_multiplex_get_client_ompt_data(ompt_data_t* data) +{ + if(!data) + return NULL; + ompt_multiplex_data_pair_t* data_pair = (ompt_multiplex_data_pair_t*) data->ptr; + return &(data_pair->client_data); +} +#endif //!defined(OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_THREAD_DATA) || !defined(OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_PARALLEL_DATA) || !defined(OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_TASK_DATA) + + +static ompt_data_t* ompt_multiplex_get_own_thread_data(ompt_data_t* data) { +#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_THREAD_DATA + return ompt_multiplex_get_own_ompt_data(data); +#else + return data; +#endif +} + +static ompt_data_t* ompt_multiplex_get_own_parallel_data(ompt_data_t* data) { +#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_PARALLEL_DATA + return ompt_multiplex_get_own_ompt_data(data); +#else + return data; +#endif +} + +static ompt_data_t* ompt_multiplex_get_own_task_data(ompt_data_t* data) { +#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_TASK_DATA + return ompt_multiplex_get_own_ompt_data(data); +#else + return data; +#endif +} + + +static ompt_data_t* ompt_multiplex_get_client_thread_data(ompt_data_t* data) { +#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_THREAD_DATA + return ompt_multiplex_get_client_ompt_data(data); +#else + return OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_THREAD_DATA(data); +#endif +} + +static ompt_data_t* ompt_multiplex_get_client_parallel_data(ompt_data_t* data) { +#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_PARALLEL_DATA + return ompt_multiplex_get_client_ompt_data(data); +#else + return OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_PARALLEL_DATA(data); +#endif +} + +static ompt_data_t* ompt_multiplex_get_client_task_data(ompt_data_t* data) { +#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_TASK_DATA + return ompt_multiplex_get_client_ompt_data(data); +#else + return OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_TASK_DATA(data); +#endif +} + +static void +ompt_multiplex_callback_mutex_acquire( + ompt_mutex_t kind, + unsigned int hint, + unsigned int impl, + ompt_wait_id_t wait_id, + const void *codeptr_ra) +{ + if(ompt_multiplex_own_callbacks.ompt_callback_mutex_acquire){ + ompt_multiplex_own_callbacks.ompt_callback_mutex_acquire(kind,hint,impl,wait_id,codeptr_ra);} + if(ompt_multiplex_client_callbacks.ompt_callback_mutex_acquire){ + ompt_multiplex_client_callbacks.ompt_callback_mutex_acquire(kind,hint,impl,wait_id,codeptr_ra);} +} + +static void +ompt_multiplex_callback_mutex_acquired( + ompt_mutex_t kind, + ompt_wait_id_t wait_id, + const void *codeptr_ra) +{ + if(ompt_multiplex_own_callbacks.ompt_callback_mutex_acquired){ + ompt_multiplex_own_callbacks.ompt_callback_mutex_acquired(kind,wait_id,codeptr_ra);} + if(ompt_multiplex_client_callbacks.ompt_callback_mutex_acquired){ + ompt_multiplex_client_callbacks.ompt_callback_mutex_acquired(kind,wait_id,codeptr_ra);} +} + +static void +ompt_multiplex_callback_mutex_released( + ompt_mutex_t kind, + ompt_wait_id_t wait_id, + const void *codeptr_ra) +{ + if(ompt_multiplex_own_callbacks.ompt_callback_mutex_released){ + ompt_multiplex_own_callbacks.ompt_callback_mutex_released(kind,wait_id,codeptr_ra);} + if(ompt_multiplex_client_callbacks.ompt_callback_mutex_released){ + ompt_multiplex_client_callbacks.ompt_callback_mutex_released(kind,wait_id,codeptr_ra);} +} + +static void +ompt_multiplex_callback_nest_lock( + ompt_scope_endpoint_t endpoint, + ompt_wait_id_t wait_id, + const void *codeptr_ra) +{ + if(ompt_multiplex_own_callbacks.ompt_callback_nest_lock){ + ompt_multiplex_own_callbacks.ompt_callback_nest_lock(endpoint,wait_id,codeptr_ra);} + if(ompt_multiplex_client_callbacks.ompt_callback_nest_lock){ + ompt_multiplex_client_callbacks.ompt_callback_nest_lock(endpoint,wait_id,codeptr_ra);} +} + +static void +ompt_multiplex_callback_sync_region( + ompt_sync_region_t kind, + ompt_scope_endpoint_t endpoint, + ompt_data_t *parallel_data, + ompt_data_t *task_data, + const void *codeptr_ra) +{ + if(ompt_multiplex_own_callbacks.ompt_callback_sync_region){ + ompt_multiplex_own_callbacks.ompt_callback_sync_region(kind,endpoint,ompt_multiplex_get_own_parallel_data(parallel_data),ompt_multiplex_get_own_task_data(task_data),codeptr_ra);} + if(ompt_multiplex_client_callbacks.ompt_callback_sync_region){ + ompt_multiplex_client_callbacks.ompt_callback_sync_region(kind,endpoint,ompt_multiplex_get_client_parallel_data(parallel_data),ompt_multiplex_get_client_task_data(task_data),codeptr_ra);} +} + +static void +ompt_multiplex_callback_sync_region_wait( + ompt_sync_region_t kind, + ompt_scope_endpoint_t endpoint, + ompt_data_t *parallel_data, + ompt_data_t *task_data, + const void *codeptr_ra) +{ + if(ompt_multiplex_own_callbacks.ompt_callback_sync_region_wait){ + ompt_multiplex_own_callbacks.ompt_callback_sync_region_wait(kind,endpoint,ompt_multiplex_get_own_parallel_data(parallel_data),ompt_multiplex_get_own_task_data(task_data),codeptr_ra);} + if(ompt_multiplex_client_callbacks.ompt_callback_sync_region_wait){ + ompt_multiplex_client_callbacks.ompt_callback_sync_region_wait(kind,endpoint,ompt_multiplex_get_client_parallel_data(parallel_data),ompt_multiplex_get_client_task_data(task_data),codeptr_ra);} +} + +static void +ompt_multiplex_callback_flush( + ompt_data_t *thread_data, + const void *codeptr_ra) +{ + if(ompt_multiplex_own_callbacks.ompt_callback_flush){ + ompt_multiplex_own_callbacks.ompt_callback_flush(ompt_multiplex_get_own_thread_data(thread_data),codeptr_ra);} + if(ompt_multiplex_client_callbacks.ompt_callback_flush){ + ompt_multiplex_client_callbacks.ompt_callback_flush(ompt_multiplex_get_client_thread_data(thread_data),codeptr_ra);} +} + +static void +ompt_multiplex_callback_cancel( + ompt_data_t *task_data, + int flags, + const void *codeptr_ra) +{ + if(ompt_multiplex_own_callbacks.ompt_callback_cancel){ + ompt_multiplex_own_callbacks.ompt_callback_cancel(ompt_multiplex_get_own_task_data(task_data),flags,codeptr_ra);} + if(ompt_multiplex_client_callbacks.ompt_callback_cancel){ + ompt_multiplex_client_callbacks.ompt_callback_cancel(ompt_multiplex_get_client_task_data(task_data),flags,codeptr_ra);} +} + +static void +ompt_multiplex_callback_implicit_task( + ompt_scope_endpoint_t endpoint, + ompt_data_t *parallel_data, + ompt_data_t *task_data, + unsigned int team_size, + unsigned int thread_num, + int flags) +{ + if(endpoint == ompt_scope_begin) + { +#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_TASK_DATA + ompt_multiplex_allocate_data_pair(task_data); +#endif +#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_PARALLEL_DATA + if (flags & ompt_task_initial) + ompt_multiplex_allocate_data_pair(parallel_data); +#endif + if(ompt_multiplex_own_callbacks.ompt_callback_implicit_task){ + ompt_multiplex_own_callbacks.ompt_callback_implicit_task(endpoint,ompt_multiplex_get_own_parallel_data(parallel_data),ompt_multiplex_get_own_task_data(task_data),team_size,thread_num,flags);} + if(ompt_multiplex_client_callbacks.ompt_callback_implicit_task){ + ompt_multiplex_client_callbacks.ompt_callback_implicit_task(endpoint,ompt_multiplex_get_client_parallel_data(parallel_data),ompt_multiplex_get_client_task_data(task_data),team_size,thread_num,flags);} + } + else + { +// defines to make sure, callbacks are called in correct order depending on defines set by the user +#if defined(OMPT_MULTIPLEX_CUSTOM_DELETE_TASK_DATA) || !defined(OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_TASK_DATA) + if(ompt_multiplex_own_callbacks.ompt_callback_implicit_task){ + ompt_multiplex_own_callbacks.ompt_callback_implicit_task(endpoint,ompt_multiplex_get_own_parallel_data(parallel_data),ompt_multiplex_get_own_task_data(task_data),team_size,thread_num,flags);} +#endif + + if(ompt_multiplex_client_callbacks.ompt_callback_implicit_task){ + ompt_multiplex_client_callbacks.ompt_callback_implicit_task(endpoint,ompt_multiplex_get_client_parallel_data(parallel_data),ompt_multiplex_get_client_task_data(task_data),team_size,thread_num,flags);} + +#if defined(OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_TASK_DATA) && !defined(OMPT_MULTIPLEX_CUSTOM_DELETE_TASK_DATA) + if(ompt_multiplex_own_callbacks.ompt_callback_implicit_task){ + ompt_multiplex_own_callbacks.ompt_callback_implicit_task(endpoint,ompt_multiplex_get_own_parallel_data(parallel_data),ompt_multiplex_get_own_task_data(task_data),team_size,thread_num,flags);} +#endif + +#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_TASK_DATA + ompt_multiplex_free_data_pair(task_data); +#endif + +#if defined(OMPT_MULTIPLEX_CUSTOM_DELETE_PARALLEL_DATA) + if (flags & ompt_task_initial) + OMPT_MULTIPLEX_CUSTOM_DELETE_PARALLEL_DATA(parallel_data); +#endif +#if defined(OMPT_MULTIPLEX_CUSTOM_DELETE_TASK_DATA) + OMPT_MULTIPLEX_CUSTOM_DELETE_TASK_DATA(task_data); +#endif + } +} + +static void +ompt_multiplex_callback_lock_init( + ompt_mutex_t kind, + unsigned int hint, + unsigned int impl, + ompt_wait_id_t wait_id, + const void *codeptr_ra) +{ + if(ompt_multiplex_own_callbacks.ompt_callback_lock_init){ + ompt_multiplex_own_callbacks.ompt_callback_lock_init(kind,hint,impl,wait_id,codeptr_ra);} + if(ompt_multiplex_client_callbacks.ompt_callback_lock_init){ + ompt_multiplex_client_callbacks.ompt_callback_lock_init(kind,hint,impl,wait_id,codeptr_ra);} +} + +static void +ompt_multiplex_callback_lock_destroy( + ompt_mutex_t kind, + ompt_wait_id_t wait_id, + const void *codeptr_ra) +{ + if(ompt_multiplex_own_callbacks.ompt_callback_lock_destroy){ + ompt_multiplex_own_callbacks.ompt_callback_lock_destroy(kind,wait_id,codeptr_ra);} + if(ompt_multiplex_client_callbacks.ompt_callback_lock_destroy){ + ompt_multiplex_client_callbacks.ompt_callback_lock_destroy(kind,wait_id,codeptr_ra);} +} + +static void +ompt_multiplex_callback_work( + ompt_work_t wstype, + ompt_scope_endpoint_t endpoint, + ompt_data_t *parallel_data, + ompt_data_t *task_data, + uint64_t count, + const void *codeptr_ra) +{ + if(ompt_multiplex_own_callbacks.ompt_callback_work){ + ompt_multiplex_own_callbacks.ompt_callback_work(wstype,endpoint,ompt_multiplex_get_own_parallel_data(parallel_data),ompt_multiplex_get_own_task_data(task_data),count,codeptr_ra);} + if(ompt_multiplex_client_callbacks.ompt_callback_work){ + ompt_multiplex_client_callbacks.ompt_callback_work(wstype,endpoint,ompt_multiplex_get_client_parallel_data(parallel_data),ompt_multiplex_get_client_task_data(task_data),count,codeptr_ra);} +} + +static void +ompt_multiplex_callback_master( + ompt_scope_endpoint_t endpoint, + ompt_data_t *parallel_data, + ompt_data_t *task_data, + const void *codeptr_ra) +{ + if(ompt_multiplex_own_callbacks.ompt_callback_master){ + ompt_multiplex_own_callbacks.ompt_callback_master(endpoint,ompt_multiplex_get_own_parallel_data(parallel_data),ompt_multiplex_get_own_task_data(task_data),codeptr_ra);} + if(ompt_multiplex_client_callbacks.ompt_callback_master){ + ompt_multiplex_client_callbacks.ompt_callback_master(endpoint,ompt_multiplex_get_client_parallel_data(parallel_data),ompt_multiplex_get_client_task_data(task_data),codeptr_ra);} +} + +static void +ompt_multiplex_callback_parallel_begin( + ompt_data_t *parent_task_data, + const ompt_frame_t *parent_task_frame, + ompt_data_t* parallel_data, + uint32_t requested_team_size, + int flag, + const void *codeptr_ra) +{ +#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_PARALLEL_DATA + ompt_multiplex_allocate_data_pair(parallel_data); +#endif + if(ompt_multiplex_own_callbacks.ompt_callback_parallel_begin){ + ompt_multiplex_own_callbacks.ompt_callback_parallel_begin(ompt_multiplex_get_own_task_data(parent_task_data),parent_task_frame,ompt_multiplex_get_own_parallel_data(parallel_data),requested_team_size,flag,codeptr_ra);} + if(ompt_multiplex_client_callbacks.ompt_callback_parallel_begin){ + ompt_multiplex_client_callbacks.ompt_callback_parallel_begin(ompt_multiplex_get_client_task_data(parent_task_data),parent_task_frame,ompt_multiplex_get_client_parallel_data(parallel_data),requested_team_size,flag,codeptr_ra);} +} + +static void +ompt_multiplex_callback_parallel_end( + ompt_data_t *parallel_data, + ompt_data_t *task_data, + int flag, + const void *codeptr_ra) +{ +// defines to make sure, callbacks are called in correct order depending on defines set by the user +#if defined(OMPT_MULTIPLEX_CUSTOM_DELETE_PARALLEL_DATA) || !defined(OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_PARALLEL_DATA) + if(ompt_multiplex_own_callbacks.ompt_callback_parallel_end){ + ompt_multiplex_own_callbacks.ompt_callback_parallel_end(ompt_multiplex_get_own_parallel_data(parallel_data),ompt_multiplex_get_own_task_data(task_data),flag,codeptr_ra);} +#endif + + if(ompt_multiplex_client_callbacks.ompt_callback_parallel_end){ + ompt_multiplex_client_callbacks.ompt_callback_parallel_end(ompt_multiplex_get_client_parallel_data(parallel_data),ompt_multiplex_get_client_task_data(task_data),flag,codeptr_ra);} + +#if defined(OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_PARALLEL_DATA) && !defined(OMPT_MULTIPLEX_CUSTOM_DELETE_PARALLEL_DATA) + if(ompt_multiplex_own_callbacks.ompt_callback_parallel_end){ + ompt_multiplex_own_callbacks.ompt_callback_parallel_end(ompt_multiplex_get_own_parallel_data(parallel_data),ompt_multiplex_get_own_task_data(task_data),flag,codeptr_ra);} +#endif + +#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_PARALLEL_DATA + ompt_multiplex_free_data_pair(parallel_data); +#endif + +#if defined(OMPT_MULTIPLEX_CUSTOM_DELETE_PARALLEL_DATA) + OMPT_MULTIPLEX_CUSTOM_DELETE_PARALLEL_DATA(parallel_data); +#endif +} + +static void +ompt_multiplex_callback_task_create( + ompt_data_t *parent_task_data, + const ompt_frame_t *parent_frame, + ompt_data_t* new_task_data, + int type, + int has_dependences, + const void *codeptr_ra) +{ +#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_TASK_DATA + ompt_multiplex_allocate_data_pair(new_task_data); +#endif + +#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_PARALLEL_DATA + if(type & ompt_task_initial) + { + ompt_data_t *parallel_data; + ompt_multiplex_get_parallel_info(0, ¶llel_data, NULL); + ompt_multiplex_allocate_data_pair(parallel_data); + } +#endif + + if(ompt_multiplex_own_callbacks.ompt_callback_task_create){ + ompt_multiplex_own_callbacks.ompt_callback_task_create(ompt_multiplex_get_own_task_data(parent_task_data),parent_frame,ompt_multiplex_get_own_task_data(new_task_data),type,has_dependences,codeptr_ra);} + if(ompt_multiplex_client_callbacks.ompt_callback_task_create){ + ompt_multiplex_client_callbacks.ompt_callback_task_create(ompt_multiplex_get_client_task_data(parent_task_data),parent_frame,ompt_multiplex_get_client_task_data(new_task_data),type,has_dependences,codeptr_ra);} +} + +static void +ompt_multiplex_callback_task_schedule( + ompt_data_t *first_task_data, + ompt_task_status_t prior_task_status, + ompt_data_t *second_task_data) +{ + if(prior_task_status != ompt_task_complete) + { + if(ompt_multiplex_own_callbacks.ompt_callback_task_schedule){ + ompt_multiplex_own_callbacks.ompt_callback_task_schedule(ompt_multiplex_get_own_task_data(first_task_data),prior_task_status,ompt_multiplex_get_own_task_data(second_task_data));} + if(ompt_multiplex_client_callbacks.ompt_callback_task_schedule){ + ompt_multiplex_client_callbacks.ompt_callback_task_schedule(ompt_multiplex_get_client_task_data(first_task_data),prior_task_status,ompt_multiplex_get_client_task_data(second_task_data));} + } + else + { +// defines to make sure, callbacks are called in correct order depending on defines set by the user +#if defined(OMPT_MULTIPLEX_CUSTOM_DELETE_TASK_DATA) || !defined(OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_TASK_DATA) + if(ompt_multiplex_own_callbacks.ompt_callback_task_schedule){ + ompt_multiplex_own_callbacks.ompt_callback_task_schedule(ompt_multiplex_get_own_task_data(first_task_data),prior_task_status,ompt_multiplex_get_own_task_data(second_task_data));} +#endif + + if(ompt_multiplex_client_callbacks.ompt_callback_task_schedule){ + ompt_multiplex_client_callbacks.ompt_callback_task_schedule(ompt_multiplex_get_client_task_data(first_task_data),prior_task_status,ompt_multiplex_get_client_task_data(second_task_data));} + +#if defined(OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_TASK_DATA) && !defined(OMPT_MULTIPLEX_CUSTOM_DELETE_TASK_DATA) + if(ompt_multiplex_own_callbacks.ompt_callback_task_schedule){ + ompt_multiplex_own_callbacks.ompt_callback_task_schedule(ompt_multiplex_get_own_task_data(first_task_data),prior_task_status,ompt_multiplex_get_own_task_data(second_task_data));} +#endif + +#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_TASK_DATA + ompt_multiplex_free_data_pair(first_task_data); +#endif + +#if defined(OMPT_MULTIPLEX_CUSTOM_DELETE_TASK_DATA) + OMPT_MULTIPLEX_CUSTOM_DELETE_TASK_DATA(first_task_data); +#endif + } +} + +static void +ompt_multiplex_callback_dependences( + ompt_data_t *task_data, + const ompt_dependence_t *deps, + int ndeps) +{ + if(ompt_multiplex_own_callbacks.ompt_callback_dependences){ + ompt_multiplex_own_callbacks.ompt_callback_dependences(ompt_multiplex_get_own_task_data(task_data),deps,ndeps);} + if(ompt_multiplex_client_callbacks.ompt_callback_dependences){ + ompt_multiplex_client_callbacks.ompt_callback_dependences(ompt_multiplex_get_client_task_data(task_data),deps,ndeps);} +} + +static void +ompt_multiplex_callback_task_dependence( + ompt_data_t *first_task_data, + ompt_data_t *second_task_data) +{ + if(ompt_multiplex_own_callbacks.ompt_callback_task_dependence){ + ompt_multiplex_own_callbacks.ompt_callback_task_dependence(ompt_multiplex_get_own_task_data(first_task_data),ompt_multiplex_get_own_task_data(second_task_data));} + if(ompt_multiplex_client_callbacks.ompt_callback_task_dependence){ + ompt_multiplex_client_callbacks.ompt_callback_task_dependence(ompt_multiplex_get_client_task_data(first_task_data),ompt_multiplex_get_client_task_data(second_task_data));} +} + +static void +ompt_multiplex_callback_thread_begin( + ompt_thread_t thread_type, + ompt_data_t *thread_data) +{ +#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_THREAD_DATA + ompt_multiplex_allocate_data_pair(thread_data); +#endif + if(ompt_multiplex_own_callbacks.ompt_callback_thread_begin){ + ompt_multiplex_own_callbacks.ompt_callback_thread_begin(thread_type,ompt_multiplex_get_own_thread_data(thread_data));} + if(ompt_multiplex_client_callbacks.ompt_callback_thread_begin){ + ompt_multiplex_client_callbacks.ompt_callback_thread_begin(thread_type,ompt_multiplex_get_client_thread_data(thread_data));} +} + +static void +ompt_multiplex_callback_thread_end( + ompt_data_t *thread_data) +{ +// defines to make sure, callbacks are called in correct order depending on defines set by the user +#if defined(OMPT_MULTIPLEX_CUSTOM_DELETE_THREAD_DATA) || !defined(OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_THREAD_DATA) + if(ompt_multiplex_own_callbacks.ompt_callback_thread_end){ + ompt_multiplex_own_callbacks.ompt_callback_thread_end(ompt_multiplex_get_own_thread_data(thread_data));} +#endif + + if(ompt_multiplex_client_callbacks.ompt_callback_thread_end){ + ompt_multiplex_client_callbacks.ompt_callback_thread_end(ompt_multiplex_get_client_thread_data(thread_data));} + +#if defined(OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_THREAD_DATA) && !defined(OMPT_MULTIPLEX_CUSTOM_DELETE_THREAD_DATA) + if(ompt_multiplex_own_callbacks.ompt_callback_thread_end){ + ompt_multiplex_own_callbacks.ompt_callback_thread_end(ompt_multiplex_get_own_thread_data(thread_data));} +#endif + +#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_THREAD_DATA + ompt_multiplex_free_data_pair(thread_data); +#endif + +#if defined(OMPT_MULTIPLEX_CUSTOM_DELETE_THREAD_DATA) + OMPT_MULTIPLEX_CUSTOM_DELETE_THREAD_DATA(thread_data); +#endif +} + +static int +ompt_multiplex_callback_control_tool( + uint64_t command, + uint64_t modifier, + void *arg, + const void *codeptr_ra) +{ + int ownRet=0, clientRet=0; + if(ompt_multiplex_own_callbacks.ompt_callback_control_tool){ + ownRet = ompt_multiplex_own_callbacks.ompt_callback_control_tool(command,modifier,arg,codeptr_ra);} + if(ompt_multiplex_client_callbacks.ompt_callback_control_tool){ + clientRet = ompt_multiplex_client_callbacks.ompt_callback_control_tool(command,modifier,arg,codeptr_ra);} + return ownRet < clientRet ? ownRet : clientRet; +} + +//runtime entry functions + +int ompt_multiplex_own_get_task_info( + int ancestor_level, + int *type, + ompt_data_t **task_data, + ompt_frame_t **task_frame, + ompt_data_t **parallel_data, + int *thread_num) +{ + int ret = ompt_multiplex_get_task_info(ancestor_level, + type, + task_data, + task_frame, + parallel_data, + thread_num); + +#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_TASK_DATA + if(task_data) + *task_data = ompt_multiplex_get_own_ompt_data(*task_data); +#endif +#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_PARALLEL_DATA + if(parallel_data) + *parallel_data = ompt_multiplex_get_own_ompt_data(*parallel_data); +#endif + return ret; +} + +int ompt_multiplex_client_get_task_info( + int ancestor_level, + int *type, + ompt_data_t **task_data, + ompt_frame_t **task_frame, + ompt_data_t **parallel_data, + int *thread_num) +{ + int ret = ompt_multiplex_get_task_info(ancestor_level, + type, + task_data, + task_frame, + parallel_data, + thread_num); + + if(task_data) +#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_TASK_DATA + *task_data = ompt_multiplex_get_client_ompt_data(*task_data); +#else + *task_data = OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_TASK_DATA(*task_data); +#endif + + if(parallel_data) +#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_PARALLEL_DATA + *parallel_data = ompt_multiplex_get_client_ompt_data(*parallel_data); +#else + *parallel_data = OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_PARALLEL_DATA(*parallel_data); +#endif + return ret; +} + +ompt_data_t* ompt_multiplex_own_get_thread_data() +{ + ompt_data_t* ret; +#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_THREAD_DATA + ret = ompt_multiplex_get_own_ompt_data(ompt_multiplex_get_thread_data()); +#else + ret = ompt_multiplex_get_thread_data(); +#endif + return ret; +} + +ompt_data_t* ompt_multiplex_client_get_thread_data() +{ + ompt_data_t* ret; +#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_THREAD_DATA + ret = ompt_multiplex_get_client_ompt_data(ompt_multiplex_get_thread_data()); +#else + ret = OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_THREAD_DATA(ompt_multiplex_get_thread_data()); +#endif + return ret; +} + +int ompt_multiplex_own_get_parallel_info( + int ancestor_level, + ompt_data_t **parallel_data, + int *team_size) +{ + int ret = ompt_multiplex_get_parallel_info(ancestor_level, + parallel_data, + team_size); + if(parallel_data) + *parallel_data = ompt_multiplex_get_own_parallel_data(*parallel_data); + return ret; +} + +int ompt_multiplex_client_get_parallel_info( + int ancestor_level, + ompt_data_t **parallel_data, + int *team_size) +{ + int ret = ompt_multiplex_get_parallel_info(ancestor_level, + parallel_data, + team_size); + if(parallel_data) +#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_PARALLEL_DATA + *parallel_data = ompt_multiplex_get_client_ompt_data(*parallel_data); +#else + *parallel_data = OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_PARALLEL_DATA(*parallel_data); +#endif + return ret; +} + +OMPT_API_ROUTINE int ompt_multiplex_own_set_callback(ompt_callbacks_t which, + ompt_callback_t callback) { + switch (which) { + +#define ompt_event_macro(event_name, callback_type, event_id) \ + case ompt_##event_name: \ + ompt_multiplex_own_callbacks.ompt_##event_name = (callback_type)callback; \ + if(ompt_multiplex_implementation_status.ompt_##event_name == -1) \ + return ompt_multiplex_set_callback(ompt_##event_name, (ompt_callback_t)&ompt_multiplex_##event_name); \ + else \ + return ompt_multiplex_implementation_status.ompt_##event_name; + + OMPT_LOAD_CLIENT_FOREACH_OMPT_EVENT(ompt_event_macro) + +#undef ompt_event_macro + + default: + return ompt_set_error; + } +} + +OMPT_API_ROUTINE int ompt_multiplex_client_set_callback(ompt_callbacks_t which, + ompt_callback_t callback) { + switch (which) { + +#define ompt_event_macro(event_name, callback_type, event_id) \ + case ompt_##event_name: \ + ompt_multiplex_client_callbacks.ompt_##event_name = (callback_type)callback; \ + if(ompt_multiplex_implementation_status.ompt_##event_name == -1) \ + return ompt_multiplex_set_callback(ompt_##event_name, (ompt_callback_t)&ompt_multiplex_##event_name); \ + else \ + return ompt_multiplex_implementation_status.ompt_##event_name; + + OMPT_LOAD_CLIENT_FOREACH_OMPT_EVENT(ompt_event_macro) + +#undef ompt_event_macro + + default: + return ompt_set_error; + } +} + + +ompt_interface_fn_t ompt_multiplex_own_lookup(const char* name) +{ + if(!strcmp(name, "ompt_set_callback")) + return (ompt_interface_fn_t)&ompt_multiplex_own_set_callback; + else if(!strcmp(name, "ompt_get_task_info")) + return (ompt_interface_fn_t)&ompt_multiplex_own_get_task_info; + else if(!strcmp(name, "ompt_get_thread_data")) + return (ompt_interface_fn_t)&ompt_multiplex_own_get_thread_data; + else if(!strcmp(name, "ompt_get_parallel_info")) + return (ompt_interface_fn_t)&ompt_multiplex_own_get_parallel_info; + else + return ompt_multiplex_lookup_function(name); +} + +ompt_interface_fn_t ompt_multiplex_client_lookup(const char* name) +{ + if(!strcmp(name, "ompt_set_callback")) + return (ompt_interface_fn_t)&ompt_multiplex_client_set_callback; + else if(!strcmp(name, "ompt_get_task_info")) + return (ompt_interface_fn_t)&ompt_multiplex_client_get_task_info; + else if(!strcmp(name, "ompt_get_thread_data")) + return (ompt_interface_fn_t)&ompt_multiplex_client_get_thread_data; + else if(!strcmp(name, "ompt_get_parallel_info")) + return (ompt_interface_fn_t)&ompt_multiplex_client_get_parallel_info; + else + return ompt_multiplex_lookup_function(name); +} + + +int ompt_multiplex_initialize( + ompt_function_lookup_t lookup, + int initial_device_num, + ompt_data_t* data) +{ + ompt_multiplex_lookup_function = lookup; + ompt_multiplex_set_callback = (ompt_set_callback_t) lookup("ompt_set_callback"); + ompt_multiplex_get_task_info = (ompt_get_task_info_t) lookup("ompt_get_task_info"); + ompt_multiplex_get_thread_data = (ompt_get_thread_data_t) lookup("ompt_get_thread_data"); + ompt_multiplex_get_parallel_info = (ompt_get_parallel_info_t) lookup("ompt_get_parallel_info"); + + //initialize ompt_multiplex_implementation_status +#define ompt_event_macro(event_name, callback_type, event_id) \ + ompt_multiplex_implementation_status.ompt_##event_name = -1; + + OMPT_LOAD_CLIENT_FOREACH_OMPT_EVENT(ompt_event_macro) + +#undef ompt_event_macro + + int ownRet = ompt_multiplex_own_fns->initialize(ompt_multiplex_own_lookup, initial_device_num, &(ompt_multiplex_own_fns->tool_data)); + int clientRet = 0; + if(ompt_multiplex_client_fns) + clientRet= ompt_multiplex_client_fns->initialize(ompt_multiplex_client_lookup, initial_device_num, &(ompt_multiplex_client_fns->tool_data)); + + return ownRet > clientRet ? ownRet : clientRet; +} + +#undef register_callback_t +#undef register_callback + +void ompt_multiplex_finalize(ompt_data_t* fns) +{ + if(ompt_multiplex_client_fns) + ompt_multiplex_client_fns->finalize(&(ompt_multiplex_client_fns->tool_data)); + ompt_multiplex_own_fns->finalize(&(ompt_multiplex_own_fns->tool_data)); +} + +#ifdef __cplusplus +extern "C" { +#endif +ompt_start_tool_result_t* ompt_multiplex_own_start_tool(unsigned int omp_version, const char *runtime_version); + +ompt_start_tool_result_t* ompt_start_tool( + unsigned int omp_version, + const char *runtime_version) +{ + //try loading client tool + ompt_multiplex_client_fns = NULL; + ompt_start_tool_result_t *(*client_start_tool)(unsigned int, const char *) = NULL; + + const char *tool_libs = getenv(CLIENT_TOOL_LIBRARIES_VAR); + if (tool_libs) { + //copy environement variable + char* tool_libs_buffer = (char*)malloc(sizeof(char)*strlen(tool_libs)); + if(!tool_libs_buffer) + { + printf("malloc Error\n"); + exit(-1); + } + strcpy(tool_libs_buffer, tool_libs); + + int progress = 0; + while (progress < strlen(tool_libs)) { + int tmp_progress = progress; + while(tmp_progress < strlen(tool_libs) && tool_libs_buffer[tmp_progress] != ':') + tmp_progress++; + if(tmp_progress < strlen(tool_libs)) + tool_libs_buffer[tmp_progress] = 0; + void *h = dlopen(tool_libs_buffer+progress, RTLD_LAZY); + if (h) { + client_start_tool = (ompt_start_tool_result_t * (*)(unsigned int, const char *))dlsym( + h, "ompt_start_tool"); + if (client_start_tool && (ompt_multiplex_client_fns = (*client_start_tool)(omp_version, runtime_version))) { + break; + } + } + else{ + printf("Loading %s from %s failed with: %s\n" ,tool_libs_buffer+progress, CLIENT_TOOL_LIBRARIES_VAR, dlerror()); + } + progress = tmp_progress+1; + } + free(tool_libs_buffer); + } + //load own tool + ompt_multiplex_own_fns = ompt_multiplex_own_start_tool(omp_version, runtime_version); + + //return multiplexed versions + static ompt_start_tool_result_t ompt_start_tool_result = {&ompt_multiplex_initialize,&ompt_multiplex_finalize,{0}}; + return &ompt_start_tool_result; +} +#ifdef __cplusplus +} +#endif + +//macro to avoid double declaration +#define ompt_start_tool ompt_multiplex_own_start_tool + +#endif /* OMPT_MULTIPLEX_H */ Index: openmp/tools/multiplex/tests/CMakeLists.txt =================================================================== --- /dev/null +++ openmp/tools/multiplex/tests/CMakeLists.txt @@ -0,0 +1,21 @@ +# CMakeLists.txt file for unit testing OMPT multiplex header. +include(CheckFunctionExists) +include(CheckLibraryExists) + +macro(pythonize_bool var) + if (${var}) + set(${var} True) + else() + set(${var} False) + endif() +endmacro() + +set(OMPT_LOAD_CLIENT_TEST_CFLAGS "" CACHE STRING + "Extra compiler flags to send to the test compiler") + +get_target_property(OMPT_PRINT_CALLBACKS_DIR ompt-print-callback INTERFACE_INCLUDE_DIRECTORIES) +add_openmp_testsuite(check-ompt-multiplex "Running OMPT multiplex tests" ${CMAKE_CURRENT_BINARY_DIR} DEPENDS omp) + +# Configure the lit.site.cfg.in file +set(AUTO_GEN_COMMENT "## Autogenerated by OMPT_LOAD_CLIENT configuration.\n# Do not edit!") +configure_file(lit.site.cfg.in lit.site.cfg @ONLY) Index: openmp/tools/multiplex/tests/custom_data_storage/custom_data_storage.c =================================================================== --- /dev/null +++ openmp/tools/multiplex/tests/custom_data_storage/custom_data_storage.c @@ -0,0 +1,98 @@ +// RUN: %libomp-tool -o %t.first.tool.so %s.first.tool.c && %libomp-tool %s.second.tool.c -o %t.second.tool.so && %libomp-compile && env OMP_TOOL_LIBRARIES=%t.first.tool.so CUSTOM_DATA_STORAGE_TOOL_LIBRARIES=%t.second.tool.so %libomp-run | %sort-threads | FileCheck %s + +#include "omp.h" +#include "../ompt-signal.h" +#include + +int main() +{ + int x, s=0; + #pragma omp parallel num_threads(2) shared(s) + { + #pragma omp master + { + #pragma omp task shared(s) + { + omp_control_tool(5, 1, NULL); + OMPT_SIGNAL(s); + } + } + if(omp_get_thread_num() == 1) + OMPT_WAIT(s,1); + } + + + // Check if libomp supports the callbacks for this test. + // CHECK-NOT: {{^}}0: Could not register callback + + // CHECK: {{^}}0: NULL_POINTER=[[NULL:.*$]] + // CHECK: {{^}}0: NULL_POINTER=[[NULL]] + // CHECK: {{^}}0: ompt_event_runtime_shutdown + // CHECK: {{^}}0: ompt_event_runtime_shutdown + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID:[0-9]+]]: _first_tool: ompt_event_thread_begin: thread_type=ompt_thread_initial=1, thread_id=[[_FIRST_MASTER_THREAD_ID]] + // CHECK--: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: ompt_event_task_create: parent_task_id=0, parent_task_frame.exit=(nil), parent_task_frame.reenter=(nil), new_task_id=[[_FIRST_INITIAL_TASK_ID:[0-9]+]], codeptr_ra=(nil), task_type=ompt_task_initial=1, has_dependences=no + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: ompt_event_implicit_task_begin: parallel_id=[[_FIRST_INIT_PARALLEL_ID:[0-9]+]], task_id=[[_FIRST_INITIAL_TASK_ID:[0-9]+]], team_size=1, thread_num= + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: ompt_event_parallel_begin: parent_task_id=[[_FIRST_INITIAL_TASK_ID]], parent_task_frame.exit=(nil), parent_task_frame.reenter={{0x[0-f]+}}, parallel_id=[[_FIRST_PARALLEL_ID:[0-9]+]], requested_team_size=2, codeptr_ra={{0x[0-f]+}}, invoker=2 + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: ompt_event_implicit_task_begin: parallel_id=[[_FIRST_PARALLEL_ID]], task_id=[[_FIRST_MASTER_IMPLICIT_TASK_ID:[0-9]+]], team_size=2, thread_num=0 + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: ompt_event_master_begin: parallel_id=[[_FIRST_PARALLEL_ID]], task_id=[[_FIRST_MASTER_IMPLICIT_TASK_ID]], codeptr_ra={{0x[0-f]+}} + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: ompt_event_task_create: parent_task_id=[[_FIRST_MASTER_IMPLICIT_TASK_ID]], parent_task_frame.exit={{0x[0-f]+}}, parent_task_frame.reenter={{0x[0-f]+}}, new_task_id=[[_FIRST_EXPLICIT_TASK_ID:[0-9]+]], codeptr_ra={{0x[0-f]+}}, task_type=ompt_task_explicit=4, has_dependences=no + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: ompt_event_master_end: parallel_id=[[_FIRST_PARALLEL_ID]], task_id=[[_FIRST_MASTER_IMPLICIT_TASK_ID]], codeptr_ra={{0x[0-f]+}} + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: ompt_event_barrier_begin: parallel_id=[[_FIRST_PARALLEL_ID]], task_id=[[_FIRST_MASTER_IMPLICIT_TASK_ID]], codeptr_ra={{0x[0-f]+}} + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: ompt_event_wait_barrier_begin: parallel_id=[[_FIRST_PARALLEL_ID]], task_id=[[_FIRST_MASTER_IMPLICIT_TASK_ID]], codeptr_ra={{0x[0-f]+}} + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: ompt_event_task_schedule: first_task_id=[[_FIRST_MASTER_IMPLICIT_TASK_ID]], second_task_id=[[_FIRST_EXPLICIT_TASK_ID]], prior_task_status=ompt_task_switch=7 + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: ompt_event_control_tool: command=5, modifier=1, arg=(nil), codeptr_ra={{0x[0-f]+}} + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: task level 0: task_id=[[_FIRST_EXPLICIT_TASK_ID]] + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: task level 1: task_id=[[_FIRST_MASTER_IMPLICIT_TASK_ID]] + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: task level 2: task_id=[[_FIRST_INITIAL_TASK_ID]] + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: parallel level 0: parallel_id=[[_FIRST_PARALLEL_ID]] + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: parallel level 1: parallel_id={{[0-9]+}} + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: ompt_event_task_schedule: first_task_id=[[_FIRST_EXPLICIT_TASK_ID]], second_task_id=[[_FIRST_MASTER_IMPLICIT_TASK_ID]], prior_task_status=ompt_task_complete=1 + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: ompt_event_task_end: task_id=[[_FIRST_EXPLICIT_TASK_ID]] + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: ompt_event_wait_barrier_end: parallel_id=0, task_id=[[_FIRST_MASTER_IMPLICIT_TASK_ID]], codeptr_ra=(nil) + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: ompt_event_barrier_end: parallel_id=0, task_id=[[_FIRST_MASTER_IMPLICIT_TASK_ID]], codeptr_ra=(nil) + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: ompt_event_implicit_task_end: parallel_id=0, task_id=[[_FIRST_MASTER_IMPLICIT_TASK_ID]], team_size=2, thread_num=0 + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: ompt_event_parallel_end: parallel_id=[[_FIRST_PARALLEL_ID]], task_id=[[_FIRST_INITIAL_TASK_ID]], invoker=2, codeptr_ra={{0x[0-f]+}} + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: ompt_event_thread_end: thread_id=[[_FIRST_MASTER_THREAD_ID]] + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID:[0-9]+]]: second_tool: ompt_event_thread_begin: thread_type=ompt_thread_initial=1, thread_id=[[SECOND_MASTER_THREAD_ID]] + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: ompt_event_initial_task_begin: parallel_id=[[SECOND_INIT_PARALLEL_ID:[0-9]+]], task_id=[[SECOND_INITIAL_TASK_ID:[0-9]+]], actual_parallelism=1, index=1, flags=1 + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: ompt_event_parallel_begin: parent_task_id=[[SECOND_INITIAL_TASK_ID]], parent_task_frame.exit=(nil), parent_task_frame.reenter={{0x[0-f]+}}, parallel_id=[[SECOND_PARALLEL_ID:[0-9]+]], requested_team_size=2, codeptr_ra={{0x[0-f]+}}, invoker=2 + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: ompt_event_implicit_task_begin: parallel_id=[[SECOND_PARALLEL_ID]], task_id=[[SECOND_MASTER_IMPLICIT_TASK_ID:[0-9]+]], team_size=2, thread_num=0 + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: ompt_event_master_begin: parallel_id=[[SECOND_PARALLEL_ID]], task_id=[[SECOND_MASTER_IMPLICIT_TASK_ID]], codeptr_ra={{0x[0-f]+}} + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: ompt_event_task_create: parent_task_id=[[SECOND_MASTER_IMPLICIT_TASK_ID]], parent_task_frame.exit={{0x[0-f]+}}, parent_task_frame.reenter={{0x[0-f]+}}, new_task_id=[[SECOND_EXPLICIT_TASK_ID:[0-9]+]], codeptr_ra={{0x[0-f]+}}, task_type=ompt_task_explicit=4, has_dependences=no + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: ompt_event_master_end: parallel_id=[[SECOND_PARALLEL_ID]], task_id=[[SECOND_MASTER_IMPLICIT_TASK_ID]], codeptr_ra={{0x[0-f]+}} + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: ompt_event_barrier_begin: parallel_id=[[SECOND_PARALLEL_ID]], task_id=[[SECOND_MASTER_IMPLICIT_TASK_ID]], codeptr_ra={{0x[0-f]+}} + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: ompt_event_wait_barrier_begin: parallel_id=[[SECOND_PARALLEL_ID]], task_id=[[SECOND_MASTER_IMPLICIT_TASK_ID]], codeptr_ra={{0x[0-f]+}} + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: ompt_event_task_schedule: first_task_id=[[SECOND_MASTER_IMPLICIT_TASK_ID]], second_task_id=[[SECOND_EXPLICIT_TASK_ID]], prior_task_status=ompt_task_switch=7 + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: ompt_event_control_tool: command=5, modifier=1, arg=(nil), codeptr_ra={{0x[0-f]+}} + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: task level 0: task_id=[[SECOND_EXPLICIT_TASK_ID]] + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: task level 1: task_id=[[SECOND_MASTER_IMPLICIT_TASK_ID]] + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: task level 2: task_id=[[SECOND_INITIAL_TASK_ID]] + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: parallel level 0: parallel_id=[[SECOND_PARALLEL_ID]] + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: parallel level 1: parallel_id={{[0-9]+}} + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: ompt_event_task_schedule: first_task_id=[[SECOND_EXPLICIT_TASK_ID]], second_task_id=[[SECOND_MASTER_IMPLICIT_TASK_ID]], prior_task_status=ompt_task_complete=1 + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: ompt_event_task_end: task_id=[[SECOND_EXPLICIT_TASK_ID]] + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: ompt_event_wait_barrier_end: parallel_id=0, task_id=[[SECOND_MASTER_IMPLICIT_TASK_ID]], codeptr_ra=(nil) + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: ompt_event_barrier_end: parallel_id=0, task_id=[[SECOND_MASTER_IMPLICIT_TASK_ID]], codeptr_ra=(nil) + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: ompt_event_implicit_task_end: parallel_id=0, task_id=[[SECOND_MASTER_IMPLICIT_TASK_ID]], team_size=2, thread_num=0 + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: ompt_event_parallel_end: parallel_id=[[SECOND_PARALLEL_ID]], task_id=[[SECOND_INITIAL_TASK_ID]], invoker=2, codeptr_ra={{0x[0-f]+}} + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: ompt_event_thread_end: thread_id=[[SECOND_MASTER_THREAD_ID]] + // CHECK: {{^}}[[_FIRST_WORKER_THREAD_ID:[0-9]+]]: _first_tool: ompt_event_thread_begin: thread_type=ompt_thread_worker=2, thread_id=[[_FIRST_WORKER_THREAD_ID]] + // CHECK: {{^}}[[_FIRST_WORKER_THREAD_ID]]: _first_tool: ompt_event_implicit_task_begin: parallel_id=[[_FIRST_PARALLEL_ID]], task_id=[[_FIRST_WORKER_IMPLICIT_TASK_ID:[0-9]+]], team_size=2, thread_num=1 + // CHECK: {{^}}[[_FIRST_WORKER_THREAD_ID]]: _first_tool: ompt_event_barrier_begin: parallel_id=[[_FIRST_PARALLEL_ID]], task_id=[[_FIRST_WORKER_IMPLICIT_TASK_ID]], codeptr_ra=(nil) + // CHECK: {{^}}[[_FIRST_WORKER_THREAD_ID]]: _first_tool: ompt_event_wait_barrier_begin: parallel_id=[[_FIRST_PARALLEL_ID]], task_id=[[_FIRST_WORKER_IMPLICIT_TASK_ID]], codeptr_ra=(nil) + // CHECK: {{^}}[[_FIRST_WORKER_THREAD_ID]]: _first_tool: ompt_event_wait_barrier_end: parallel_id=0, task_id=[[_FIRST_WORKER_IMPLICIT_TASK_ID]], codeptr_ra=(nil) + // CHECK: {{^}}[[_FIRST_WORKER_THREAD_ID]]: _first_tool: ompt_event_barrier_end: parallel_id=0, task_id=[[_FIRST_WORKER_IMPLICIT_TASK_ID]], codeptr_ra=(nil) + // CHECK: {{^}}[[_FIRST_WORKER_THREAD_ID]]: _first_tool: ompt_event_implicit_task_end: parallel_id=0, task_id=[[_FIRST_WORKER_IMPLICIT_TASK_ID]], team_size=0, thread_num=1 + // CHECK: {{^}}[[_FIRST_WORKER_THREAD_ID]]: _first_tool: ompt_event_thread_end: thread_id=[[_FIRST_WORKER_THREAD_ID]] + // CHECK: {{^}}[[SECOND_WORKER_THREAD_ID:[0-9]+]]: second_tool: ompt_event_thread_begin: thread_type=ompt_thread_worker=2, thread_id=[[SECOND_WORKER_THREAD_ID]] + // CHECK: {{^}}[[SECOND_WORKER_THREAD_ID]]: second_tool: ompt_event_implicit_task_begin: parallel_id=[[SECOND_PARALLEL_ID]], task_id=[[SECOND_WORKER_IMPLICIT_TASK_ID:[0-9]+]], team_size=2, thread_num=1 + // CHECK: {{^}}[[SECOND_WORKER_THREAD_ID]]: second_tool: ompt_event_barrier_begin: parallel_id=[[SECOND_PARALLEL_ID]], task_id=[[SECOND_WORKER_IMPLICIT_TASK_ID]], codeptr_ra=(nil) + // CHECK: {{^}}[[SECOND_WORKER_THREAD_ID]]: second_tool: ompt_event_wait_barrier_begin: parallel_id=[[SECOND_PARALLEL_ID]], task_id=[[SECOND_WORKER_IMPLICIT_TASK_ID]], codeptr_ra=(nil) + // CHECK: {{^}}[[SECOND_WORKER_THREAD_ID]]: second_tool: ompt_event_wait_barrier_end: parallel_id=0, task_id=[[SECOND_WORKER_IMPLICIT_TASK_ID]], codeptr_ra=(nil) + // CHECK: {{^}}[[SECOND_WORKER_THREAD_ID]]: second_tool: ompt_event_barrier_end: parallel_id=0, task_id=[[SECOND_WORKER_IMPLICIT_TASK_ID]], codeptr_ra=(nil) + // CHECK: {{^}}[[SECOND_WORKER_THREAD_ID]]: second_tool: ompt_event_implicit_task_end: parallel_id=0, task_id=[[SECOND_WORKER_IMPLICIT_TASK_ID]], team_size=0, thread_num=1 + // CHECK: {{^}}[[SECOND_WORKER_THREAD_ID]]: second_tool: ompt_event_thread_end: thread_id=[[SECOND_WORKER_THREAD_ID]] + + + return 0; +} Index: openmp/tools/multiplex/tests/custom_data_storage/custom_data_storage.c.first.tool.c =================================================================== --- /dev/null +++ openmp/tools/multiplex/tests/custom_data_storage/custom_data_storage.c.first.tool.c @@ -0,0 +1,700 @@ +// RUN: true + +#include "omp-tools.h" + +#define CLIENT_TOOL_LIBRARIES_VAR "CUSTOM_DATA_STORAGE_TOOL_LIBRARIES" +static ompt_data_t* custom_get_client_ompt_data(ompt_data_t*); +static void free_data_pair(ompt_data_t*); +#define OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_THREAD_DATA custom_get_client_ompt_data +#define OMPT_MULTIPLEX_CUSTOM_DELETE_THREAD_DATA free_data_pair +#define OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_PARALLEL_DATA custom_get_client_ompt_data +#define OMPT_MULTIPLEX_CUSTOM_DELETE_PARALLEL_DATA free_data_pair +#define OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_TASK_DATA custom_get_client_ompt_data +#define OMPT_MULTIPLEX_CUSTOM_DELETE_TASK_DATA free_data_pair +#include "ompt-multiplex.h" + +#define USE_PRIVATE_TOOL +#include "callback.h" + + +typedef struct custom_data_pair_s +{ + ompt_data_t own_data; + ompt_data_t client_data; +} custom_data_pair_t; + +static ompt_data_t* custom_get_client_ompt_data(ompt_data_t* data) +{ + if(data) + return &(((custom_data_pair_t*) (data->ptr))->client_data); + else + return NULL; +} + +static ompt_data_t* get_own_ompt_data(ompt_data_t* data) +{ + if(data) + return &(((custom_data_pair_t*) (data->ptr))->own_data); + else + return NULL; +} + +static ompt_multiplex_data_pair_t* allocate_data_pair(ompt_data_t* data_pointer) +{ + data_pointer->ptr = malloc(sizeof(ompt_multiplex_data_pair_t)); + if(!data_pointer->ptr) + { + printf("Malloc ERROR\n"); + exit(-1); + } + ompt_multiplex_data_pair_t* data_pair = (ompt_multiplex_data_pair_t*) data_pointer->ptr; + data_pair->own_data.ptr = NULL; + data_pair->client_data.ptr = NULL; + return data_pair; +} + +static void free_data_pair(ompt_data_t* data_pointer) +{ + free((*data_pointer).ptr); +} + +static void +on_ompt_callback_mutex_acquire( + ompt_mutex_t kind, + unsigned int hint, + unsigned int impl, + ompt_wait_id_t wait_id, + const void *codeptr_ra) +{ + switch(kind) + { + case ompt_mutex_lock: + printf("%" PRIu64 ": _first_tool: ompt_event_wait_lock: wait_id=%" PRIu64 ", hint=%" PRIu32 ", impl=%" PRIu32 ", codeptr_ra=%p \n", get_own_ompt_data(ompt_get_thread_data())->value, wait_id, hint, impl, codeptr_ra); + break; + case ompt_mutex_nest_lock: + printf("%" PRIu64 ": _first_tool: ompt_event_wait_nest_lock: wait_id=%" PRIu64 ", hint=%" PRIu32 ", impl=%" PRIu32 ", codeptr_ra=%p \n", get_own_ompt_data(ompt_get_thread_data())->value, wait_id, hint, impl, codeptr_ra); + break; + case ompt_mutex_critical: + printf("%" PRIu64 ": _first_tool: ompt_event_wait_critical: wait_id=%" PRIu64 ", hint=%" PRIu32 ", impl=%" PRIu32 ", codeptr_ra=%p \n", get_own_ompt_data(ompt_get_thread_data())->value, wait_id, hint, impl, codeptr_ra); + break; + case ompt_mutex_atomic: + printf("%" PRIu64 ": _first_tool: ompt_event_wait_atomic: wait_id=%" PRIu64 ", hint=%" PRIu32 ", impl=%" PRIu32 ", codeptr_ra=%p \n", get_own_ompt_data(ompt_get_thread_data())->value, wait_id, hint, impl, codeptr_ra); + break; + case ompt_mutex_ordered: + printf("%" PRIu64 ": _first_tool: ompt_event_wait_ordered: wait_id=%" PRIu64 ", hint=%" PRIu32 ", impl=%" PRIu32 ", codeptr_ra=%p \n", get_own_ompt_data(ompt_get_thread_data())->value, wait_id, hint, impl, codeptr_ra); + break; + default: + break; + } +} + +static void +on_ompt_callback_mutex_acquired( + ompt_mutex_t kind, + ompt_wait_id_t wait_id, + const void *codeptr_ra) +{ + switch(kind) + { + case ompt_mutex_lock: + printf("%" PRIu64 ": _first_tool: ompt_event_acquired_lock: wait_id=%" PRIu64 ", codeptr_ra=%p \n", get_own_ompt_data(ompt_get_thread_data())->value, wait_id, codeptr_ra); + break; + case ompt_mutex_nest_lock: + printf("%" PRIu64 ": _first_tool: ompt_event_acquired_nest_lock_first: wait_id=%" PRIu64 ", codeptr_ra=%p \n", get_own_ompt_data(ompt_get_thread_data())->value, wait_id, codeptr_ra); + break; + case ompt_mutex_critical: + printf("%" PRIu64 ": _first_tool: ompt_event_acquired_critical: wait_id=%" PRIu64 ", codeptr_ra=%p \n", get_own_ompt_data(ompt_get_thread_data())->value, wait_id, codeptr_ra); + break; + case ompt_mutex_atomic: + printf("%" PRIu64 ": _first_tool: ompt_event_acquired_atomic: wait_id=%" PRIu64 ", codeptr_ra=%p \n", get_own_ompt_data(ompt_get_thread_data())->value, wait_id, codeptr_ra); + break; + case ompt_mutex_ordered: + printf("%" PRIu64 ": _first_tool: ompt_event_acquired_ordered: wait_id=%" PRIu64 ", codeptr_ra=%p \n", get_own_ompt_data(ompt_get_thread_data())->value, wait_id, codeptr_ra); + break; + default: + break; + } +} + +static void +on_ompt_callback_mutex_released( + ompt_mutex_t kind, + ompt_wait_id_t wait_id, + const void *codeptr_ra) +{ + switch(kind) + { + case ompt_mutex_lock: + printf("%" PRIu64 ": _first_tool: ompt_event_release_lock: wait_id=%" PRIu64 ", codeptr_ra=%p \n", get_own_ompt_data(ompt_get_thread_data())->value, wait_id, codeptr_ra); + break; + case ompt_mutex_nest_lock: + printf("%" PRIu64 ": _first_tool: ompt_event_release_nest_lock_last: wait_id=%" PRIu64 ", codeptr_ra=%p \n", get_own_ompt_data(ompt_get_thread_data())->value, wait_id, codeptr_ra); + break; + case ompt_mutex_critical: + printf("%" PRIu64 ": _first_tool: ompt_event_release_critical: wait_id=%" PRIu64 ", codeptr_ra=%p \n", get_own_ompt_data(ompt_get_thread_data())->value, wait_id, codeptr_ra); + break; + case ompt_mutex_atomic: + printf("%" PRIu64 ": _first_tool: ompt_event_release_atomic: wait_id=%" PRIu64 ", codeptr_ra=%p \n", get_own_ompt_data(ompt_get_thread_data())->value, wait_id, codeptr_ra); + break; + case ompt_mutex_ordered: + printf("%" PRIu64 ": _first_tool: ompt_event_release_ordered: wait_id=%" PRIu64 ", codeptr_ra=%p \n", get_own_ompt_data(ompt_get_thread_data())->value, wait_id, codeptr_ra); + break; + default: + break; + } +} + +static void +on_ompt_callback_nest_lock( + ompt_scope_endpoint_t endpoint, + ompt_wait_id_t wait_id, + const void *codeptr_ra) +{ + switch(endpoint) + { + case ompt_scope_begin: + printf("%" PRIu64 ": _first_tool: ompt_event_acquired_nest_lock_next: wait_id=%" PRIu64 ", codeptr_ra=%p \n", get_own_ompt_data(ompt_get_thread_data())->value, wait_id, codeptr_ra); + break; + case ompt_scope_end: + printf("%" PRIu64 ": _first_tool: ompt_event_release_nest_lock_prev: wait_id=%" PRIu64 ", codeptr_ra=%p \n", get_own_ompt_data(ompt_get_thread_data())->value, wait_id, codeptr_ra); + break; + } +} + +static void +on_ompt_callback_sync_region( + ompt_sync_region_t kind, + ompt_scope_endpoint_t endpoint, + ompt_data_t *parallel_data, + ompt_data_t *task_data, + const void *codeptr_ra) +{ + parallel_data = get_own_ompt_data(parallel_data); + task_data = get_own_ompt_data(task_data); + switch(endpoint) + { + case ompt_scope_begin: + switch(kind) + { + case ompt_sync_region_barrier: + case ompt_sync_region_barrier_implicit: + case ompt_sync_region_barrier_explicit: + case ompt_sync_region_barrier_implementation: + printf("%" PRIu64 ": _first_tool: ompt_event_barrier_begin: parallel_id=%" PRIu64 ", task_id=%" PRIu64 ", codeptr_ra=%p\n", get_own_ompt_data(ompt_get_thread_data())->value, parallel_data->value, task_data->value, codeptr_ra); + //print_ids(0); + break; + case ompt_sync_region_taskwait: + printf("%" PRIu64 ": _first_tool: ompt_event_taskwait_begin: parallel_id=%" PRIu64 ", task_id=%" PRIu64 ", codeptr_ra=%p\n", get_own_ompt_data(ompt_get_thread_data())->value, parallel_data->value, task_data->value, codeptr_ra); + break; + case ompt_sync_region_taskgroup: + printf("%" PRIu64 ": _first_tool: ompt_event_taskgroup_begin: parallel_id=%" PRIu64 ", task_id=%" PRIu64 ", codeptr_ra=%p\n", get_own_ompt_data(ompt_get_thread_data())->value, parallel_data->value, task_data->value, codeptr_ra); + break; + case ompt_sync_region_reduction: + printf("ompt_sync_region_reduction should never be passed to " + "on_ompt_callback_sync_region\n"); + exit(-1); + break; + } + break; + case ompt_scope_end: + switch(kind) + { + case ompt_sync_region_barrier: + case ompt_sync_region_barrier_implicit: + case ompt_sync_region_barrier_explicit: + case ompt_sync_region_barrier_implementation: + printf("%" PRIu64 ": _first_tool: ompt_event_barrier_end: parallel_id=%" PRIu64 ", task_id=%" PRIu64 ", codeptr_ra=%p\n", get_own_ompt_data(ompt_get_thread_data())->value, (parallel_data)?parallel_data->value:0, task_data->value, codeptr_ra); + break; + case ompt_sync_region_taskwait: + printf("%" PRIu64 ": _first_tool: ompt_event_taskwait_end: parallel_id=%" PRIu64 ", task_id=%" PRIu64 ", codeptr_ra=%p\n", get_own_ompt_data(ompt_get_thread_data())->value, (parallel_data)?parallel_data->value:0, task_data->value, codeptr_ra); + break; + case ompt_sync_region_taskgroup: + printf("%" PRIu64 ": _first_tool: ompt_event_taskgroup_end: parallel_id=%" PRIu64 ", task_id=%" PRIu64 ", codeptr_ra=%p\n", get_own_ompt_data(ompt_get_thread_data())->value, (parallel_data)?parallel_data->value:0, task_data->value, codeptr_ra); + break; + case ompt_sync_region_reduction: + printf("ompt_sync_region_reduction should never be passed to " + "on_ompt_callback_sync_region\n"); + exit(-1); + break; + } + break; + } +} + +static void +on_ompt_callback_sync_region_wait( + ompt_sync_region_t kind, + ompt_scope_endpoint_t endpoint, + ompt_data_t *parallel_data, + ompt_data_t *task_data, + const void *codeptr_ra) +{ + parallel_data = get_own_ompt_data(parallel_data); + task_data = get_own_ompt_data(task_data); + switch(endpoint) + { + case ompt_scope_begin: + switch(kind) + { + case ompt_sync_region_barrier: + case ompt_sync_region_barrier_implicit: + case ompt_sync_region_barrier_explicit: + case ompt_sync_region_barrier_implementation: + printf("%" PRIu64 ": _first_tool: ompt_event_wait_barrier_begin: parallel_id=%" PRIu64 ", task_id=%" PRIu64 ", codeptr_ra=%p\n", get_own_ompt_data(ompt_get_thread_data())->value, parallel_data->value, task_data->value, codeptr_ra); + break; + case ompt_sync_region_taskwait: + printf("%" PRIu64 ": _first_tool: ompt_event_wait_taskwait_begin: parallel_id=%" PRIu64 ", task_id=%" PRIu64 ", codeptr_ra=%p\n", get_own_ompt_data(ompt_get_thread_data())->value, parallel_data->value, task_data->value, codeptr_ra); + break; + case ompt_sync_region_taskgroup: + printf("%" PRIu64 ": _first_tool: ompt_event_wait_taskgroup_begin: parallel_id=%" PRIu64 ", task_id=%" PRIu64 ", codeptr_ra=%p\n", get_own_ompt_data(ompt_get_thread_data())->value, parallel_data->value, task_data->value, codeptr_ra); + break; + case ompt_sync_region_reduction: + printf("ompt_sync_region_reduction should never be passed to " + "on_ompt_callback_sync_region\n"); + exit(-1); + break; + } + break; + case ompt_scope_end: + switch(kind) + { + case ompt_sync_region_barrier: + case ompt_sync_region_barrier_implicit: + case ompt_sync_region_barrier_explicit: + case ompt_sync_region_barrier_implementation: + printf("%" PRIu64 ": _first_tool: ompt_event_wait_barrier_end: parallel_id=%" PRIu64 ", task_id=%" PRIu64 ", codeptr_ra=%p\n", get_own_ompt_data(ompt_get_thread_data())->value, (parallel_data)?parallel_data->value:0, task_data->value, codeptr_ra); + break; + case ompt_sync_region_taskwait: + printf("%" PRIu64 ": _first_tool: ompt_event_wait_taskwait_end: parallel_id=%" PRIu64 ", task_id=%" PRIu64 ", codeptr_ra=%p\n", get_own_ompt_data(ompt_get_thread_data())->value, (parallel_data)?parallel_data->value:0, task_data->value, codeptr_ra); + break; + case ompt_sync_region_taskgroup: + printf("%" PRIu64 ": _first_tool: ompt_event_wait_taskgroup_end: parallel_id=%" PRIu64 ", task_id=%" PRIu64 ", codeptr_ra=%p\n", get_own_ompt_data(ompt_get_thread_data())->value, (parallel_data)?parallel_data->value:0, task_data->value, codeptr_ra); + break; + case ompt_sync_region_reduction: + printf("ompt_sync_region_reduction should never be passed to " + "on_ompt_callback_sync_region\n"); + exit(-1); + break; + } + break; + } +} + +static void +on_ompt_callback_flush( + ompt_data_t *thread_data, + const void *codeptr_ra) +{ + thread_data = get_own_ompt_data(thread_data); + printf("%" PRIu64 ": _first_tool: ompt_event_flush: codeptr_ra=%p\n", thread_data->value, codeptr_ra); +} + +static void +on_ompt_callback_cancel( + ompt_data_t *task_data, + int flags, + const void *codeptr_ra) +{ + task_data = get_own_ompt_data(task_data); + const char* first_flag_value; + const char* second_flag_value; + if(flags & ompt_cancel_parallel) + first_flag_value = ompt_cancel_flag_t_values[0]; + else if(flags & ompt_cancel_sections) + first_flag_value = ompt_cancel_flag_t_values[1]; + else if(flags & ompt_cancel_loop) + first_flag_value = ompt_cancel_flag_t_values[2]; + else if(flags & ompt_cancel_taskgroup) + first_flag_value = ompt_cancel_flag_t_values[3]; + + if(flags & ompt_cancel_activated) + second_flag_value = ompt_cancel_flag_t_values[4]; + else if(flags & ompt_cancel_detected) + second_flag_value = ompt_cancel_flag_t_values[5]; + else if(flags & ompt_cancel_discarded_task) + second_flag_value = ompt_cancel_flag_t_values[6]; + + printf("%" PRIu64 ": _first_tool: ompt_event_cancel: task_data=%" PRIu64 ", flags=%s|%s=%" PRIu32 ", codeptr_ra=%p\n", get_own_ompt_data(ompt_get_thread_data())->value, task_data->value, first_flag_value, second_flag_value, flags, codeptr_ra); +} + +static void +on_ompt_callback_implicit_task( + ompt_scope_endpoint_t endpoint, + ompt_data_t *pdata, + ompt_data_t *task_data, + unsigned int team_size, + unsigned int thread_num, + int type) +{ + ompt_data_t *parallel_data; + if (endpoint==ompt_scope_begin && (type & ompt_task_initial)) + { + allocate_data_pair(pdata); + parallel_data = get_own_ompt_data(pdata); + parallel_data->value = ompt_get_unique_id(); + } + parallel_data = get_own_ompt_data(pdata); + ompt_data_t *original_task_data; + switch(endpoint) + { + case ompt_scope_begin: + if(task_data->ptr) + printf("%s\n", "0: task_data initially not null"); + allocate_data_pair(task_data); + task_data = get_own_ompt_data(task_data); + task_data->value = ompt_get_unique_id(); + printf("%" PRIu64 ": _first_tool: ompt_event_implicit_task_begin: parallel_id=%" PRIu64 ", task_id=%" PRIu64 ", team_size=%" PRIu32 ", thread_num=%" PRIu32 "\n", get_own_ompt_data(ompt_get_thread_data())->value, parallel_data->value, task_data->value, team_size, thread_num); + break; + case ompt_scope_end: + original_task_data = task_data; + task_data = get_own_ompt_data(task_data); + printf("%" PRIu64 ": _first_tool: ompt_event_implicit_task_end: parallel_id=%" PRIu64 ", task_id=%" PRIu64 ", team_size=%" PRIu32 ", thread_num=%" PRIu32 "\n", get_own_ompt_data(ompt_get_thread_data())->value, (parallel_data)?parallel_data->value:0, task_data->value, team_size, thread_num); + break; + } +} + +static void +on_ompt_callback_lock_init( + ompt_mutex_t kind, + unsigned int hint, + unsigned int impl, + ompt_wait_id_t wait_id, + const void *codeptr_ra) +{ + switch(kind) + { + case ompt_mutex_lock: + printf("%" PRIu64 ": _first_tool: ompt_event_init_lock: wait_id=%" PRIu64 ", hint=%" PRIu32 ", impl=%" PRIu32 ", codeptr_ra=%p \n", get_own_ompt_data(ompt_get_thread_data())->value, wait_id, hint, impl, codeptr_ra); + break; + case ompt_mutex_nest_lock: + printf("%" PRIu64 ": _first_tool: ompt_event_init_nest_lock: wait_id=%" PRIu64 ", hint=%" PRIu32 ", impl=%" PRIu32 ", codeptr_ra=%p \n", get_own_ompt_data(ompt_get_thread_data())->value, wait_id, hint, impl, codeptr_ra); + break; + default: + break; + } +} + +static void +on_ompt_callback_lock_destroy( + ompt_mutex_t kind, + ompt_wait_id_t wait_id, + const void *codeptr_ra) +{ + switch(kind) + { + case ompt_mutex_lock: + printf("%" PRIu64 ": _first_tool: ompt_event_destroy_lock: wait_id=%" PRIu64 ", codeptr_ra=%p \n", get_own_ompt_data(ompt_get_thread_data())->value, wait_id, codeptr_ra); + break; + case ompt_mutex_nest_lock: + printf("%" PRIu64 ": _first_tool: ompt_event_destroy_nest_lock: wait_id=%" PRIu64 ", codeptr_ra=%p \n", get_own_ompt_data(ompt_get_thread_data())->value, wait_id, codeptr_ra); + break; + default: + break; + } +} + +static void +on_ompt_callback_work( + ompt_work_t wstype, + ompt_scope_endpoint_t endpoint, + ompt_data_t *parallel_data, + ompt_data_t *task_data, + uint64_t count, + const void *codeptr_ra) +{ + parallel_data = get_own_ompt_data(parallel_data); + task_data = get_own_ompt_data(task_data); + switch(endpoint) + { + case ompt_scope_begin: + switch(wstype) + { + case ompt_work_loop: + printf("%" PRIu64 ": _first_tool: ompt_event_loop_begin: parallel_id=%" PRIu64 ", parent_task_id=%" PRIu64 ", codeptr_ra=%p, count=%" PRIu64 "\n", get_own_ompt_data(ompt_get_thread_data())->value, parallel_data->value, task_data->value, codeptr_ra, count); + break; + case ompt_work_sections: + //impl + break; + case ompt_work_single_executor: + printf("%" PRIu64 ": _first_tool: ompt_event_single_in_block_begin: parallel_id=%" PRIu64 ", parent_task_id=%" PRIu64 ", codeptr_ra=%p, count=%" PRIu64 "\n", get_own_ompt_data(ompt_get_thread_data())->value, parallel_data->value, task_data->value, codeptr_ra, count); + break; + case ompt_work_single_other: + printf("%" PRIu64 ": _first_tool: ompt_event_single_others_begin: parallel_id=%" PRIu64 ", task_id=%" PRIu64 ", codeptr_ra=%p, count=%" PRIu64 "\n", get_own_ompt_data(ompt_get_thread_data())->value, parallel_data->value, task_data->value, codeptr_ra, count); + break; + case ompt_work_workshare: + //impl + break; + case ompt_work_distribute: + //impl + break; + case ompt_work_taskloop: + //impl + break; + } + break; + case ompt_scope_end: + switch(wstype) + { + case ompt_work_loop: + printf("%" PRIu64 ": _first_tool: ompt_event_loop_end: parallel_id=%" PRIu64 ", task_id=%" PRIu64 ", codeptr_ra=%p, count=%" PRIu64 "\n", get_own_ompt_data(ompt_get_thread_data())->value, parallel_data->value, task_data->value, codeptr_ra, count); + break; + case ompt_work_sections: + //impl + break; + case ompt_work_single_executor: + printf("%" PRIu64 ": _first_tool: ompt_event_single_in_block_end: parallel_id=%" PRIu64 ", task_id=%" PRIu64 ", codeptr_ra=%p, count=%" PRIu64 "\n", get_own_ompt_data(ompt_get_thread_data())->value, parallel_data->value, task_data->value, codeptr_ra, count); + break; + case ompt_work_single_other: + printf("%" PRIu64 ": _first_tool: ompt_event_single_others_end: parallel_id=%" PRIu64 ", task_id=%" PRIu64 ", codeptr_ra=%p, count=%" PRIu64 "\n", get_own_ompt_data(ompt_get_thread_data())->value, parallel_data->value, task_data->value, codeptr_ra, count); + break; + case ompt_work_workshare: + //impl + break; + case ompt_work_distribute: + //impl + break; + case ompt_work_taskloop: + //impl + break; + } + break; + } +} + +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) +{ + parallel_data = get_own_ompt_data(parallel_data); + task_data = get_own_ompt_data(task_data); + switch(endpoint) + { + case ompt_scope_begin: + printf("%" PRIu64 ": _first_tool: ompt_event_master_begin: parallel_id=%" PRIu64 ", task_id=%" PRIu64 ", codeptr_ra=%p\n", get_own_ompt_data(ompt_get_thread_data())->value, parallel_data->value, task_data->value, codeptr_ra); + break; + case ompt_scope_end: + printf("%" PRIu64 ": _first_tool: ompt_event_master_end: parallel_id=%" PRIu64 ", task_id=%" PRIu64 ", codeptr_ra=%p\n", get_own_ompt_data(ompt_get_thread_data())->value, parallel_data->value, task_data->value, codeptr_ra); + break; + } +} + +static void +on_ompt_callback_parallel_begin( + ompt_data_t *parent_task_data, + const ompt_frame_t *parent_task_frame, + ompt_data_t* parallel_data, + uint32_t requested_team_size, + int invoker, + const void *codeptr_ra) +{ + parent_task_data = get_own_ompt_data(parent_task_data); + if(parallel_data->ptr) + printf("%s\n", "0: parallel_data initially not null"); + allocate_data_pair(parallel_data); + parallel_data = get_own_ompt_data(parallel_data); + parallel_data->value = ompt_get_unique_id(); + printf("%" PRIu64 ": _first_tool: ompt_event_parallel_begin: parent_task_id=%" PRIu64 ", parent_task_frame.exit=%p, parent_task_frame.reenter=%p, parallel_id=%" PRIu64 ", requested_team_size=%" PRIu32 ", codeptr_ra=%p, invoker=%d\n", get_own_ompt_data(ompt_get_thread_data())->value, parent_task_data->value, parent_task_frame->exit_frame.ptr, parent_task_frame->enter_frame.ptr, parallel_data->value, requested_team_size, codeptr_ra, invoker& 0xF); +} + +static void +on_ompt_callback_parallel_end( + ompt_data_t *parallel_data, + ompt_data_t *task_data, + int invoker, + const void *codeptr_ra) +{ + task_data = get_own_ompt_data(task_data); + ompt_data_t *original_parallel_data = parallel_data; + parallel_data = get_own_ompt_data(parallel_data); + printf("%" PRIu64 ": _first_tool: ompt_event_parallel_end: parallel_id=%" PRIu64 ", task_id=%" PRIu64 ", invoker=%d, codeptr_ra=%p\n", get_own_ompt_data(ompt_get_thread_data())->value, parallel_data->value, task_data->value, invoker& 0xF, 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 */ + int type, + int has_dependences, + const void *codeptr_ra) /* pointer to outlined function */ +{ + parent_task_data = get_own_ompt_data(parent_task_data); + if(new_task_data->ptr) + printf("%s\n", "0: new_task_data initially not null"); + allocate_data_pair(new_task_data); + new_task_data = get_own_ompt_data(new_task_data); + + if(type & ompt_task_initial) + { + ompt_data_t *parallel_data; + ompt_multiplex_get_parallel_info(0, ¶llel_data, NULL); + allocate_data_pair(parallel_data); + } + + new_task_data->value = ompt_get_unique_id(); + char buffer[2048]; + + format_task_type(type, buffer); + + //there is no paralllel_begin callback for implicit parallel region + //thus it is initialized in initial task + if(type & ompt_task_initial) + { + ompt_data_t *parallel_data; + ompt_get_parallel_info(0, ¶llel_data, NULL); + allocate_data_pair(parallel_data); + parallel_data = get_own_ompt_data(parallel_data); + parallel_data->value = ompt_get_unique_id(); + } + + printf("%" PRIu64 ": _first_tool: ompt_event_task_create: parent_task_id=%" PRIu64 ", parent_task_frame.exit=%p, parent_task_frame.reenter=%p, new_task_id=%" PRIu64 ", codeptr_ra=%p, task_type=%s=%d, has_dependences=%s\n", get_own_ompt_data(ompt_get_thread_data())->value, parent_task_data ? parent_task_data->value : 0, parent_frame ? parent_frame->exit_frame.ptr : NULL, parent_frame ? parent_frame->enter_frame.ptr : NULL, new_task_data->value, codeptr_ra, buffer, type, has_dependences ? "yes" : "no"); +} + +static void +on_ompt_callback_task_schedule( + ompt_data_t *first_task_data, + ompt_task_status_t prior_task_status, + ompt_data_t *second_task_data) +{ + ompt_data_t *original_first_task_data = first_task_data; + first_task_data = get_own_ompt_data(first_task_data); + second_task_data = get_own_ompt_data(second_task_data); + printf("%" PRIu64 ": _first_tool: ompt_event_task_schedule: first_task_id=%" PRIu64 ", second_task_id=%" PRIu64 ", prior_task_status=%s=%d\n", get_own_ompt_data(ompt_get_thread_data())->value, first_task_data->value, second_task_data->value, ompt_task_status_t_values[prior_task_status], prior_task_status); + if(prior_task_status == ompt_task_complete) + { + printf("%" PRIu64 ": _first_tool: ompt_event_task_end: task_id=%" PRIu64 "\n", get_own_ompt_data(ompt_get_thread_data())->value, first_task_data->value); + } +} + +static void +on_ompt_callback_dependences( + ompt_data_t *task_data, + const ompt_dependence_t *deps, + int ndeps) +{ + task_data = get_own_ompt_data(task_data); + printf("%" PRIu64 ": _first_tool: ompt_event_task_dependences: task_id=%" PRIu64 ", deps=%p, ndeps=%d\n", get_own_ompt_data(ompt_get_thread_data())->value, task_data->value, (void *)deps, ndeps); +} + +static void +on_ompt_callback_task_dependence( + ompt_data_t *first_task_data, + ompt_data_t *second_task_data) +{ + first_task_data = get_own_ompt_data(first_task_data); + second_task_data = get_own_ompt_data(second_task_data); + printf("%" PRIu64 ": _first_tool: ompt_event_task_dependence_pair: first_task_id=%" PRIu64 ", second_task_id=%" PRIu64 "\n", get_own_ompt_data(ompt_get_thread_data())->value, first_task_data->value, second_task_data->value); +} + +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"); + allocate_data_pair(thread_data); + thread_data = get_own_ompt_data(thread_data); + thread_data->value = ompt_get_unique_id(); + printf("%" PRIu64 ": _first_tool: ompt_event_thread_begin: thread_type=%s=%d, thread_id=%" PRIu64 "\n", get_own_ompt_data(ompt_get_thread_data())->value, ompt_thread_t_values[thread_type], thread_type, thread_data->value); +} + +static void +on_ompt_callback_thread_end( + ompt_data_t *thread_data) +{ + ompt_data_t *own_thread_data = get_own_ompt_data(thread_data); + printf("%" PRIu64 ": _first_tool: ompt_event_thread_end: thread_id=%" PRIu64 "\n", get_own_ompt_data(ompt_get_thread_data())->value, own_thread_data->value); +} + +static int +on_ompt_callback_control_tool( + uint64_t command, + uint64_t modifier, + void *arg, + const void *codeptr_ra) +{ + printf("%" PRIu64 ": _first_tool: ompt_event_control_tool: command=%" PRIu64 ", modifier=%" PRIu64 ", arg=%p, codeptr_ra=%p \n", get_own_ompt_data(ompt_get_thread_data())->value, command, modifier, arg, codeptr_ra); + + //print task data + int task_level = 0; + ompt_data_t *task_data; + while(ompt_get_task_info(task_level, NULL, (ompt_data_t**) &task_data, NULL, NULL, NULL)) + { + task_data = get_own_ompt_data(task_data); + printf("%" PRIu64 ": _first_tool: task level %d: task_id=%" PRIu64 "\n", get_own_ompt_data(ompt_get_thread_data())->value, task_level, task_data->value); + task_level++; + } + + //print parallel data + int parallel_level = 0; + ompt_data_t *parallel_data; + while(ompt_get_parallel_info(parallel_level, (ompt_data_t**) ¶llel_data, NULL)) + { + parallel_data = get_own_ompt_data(parallel_data); + printf("%" PRIu64 ": _first_tool: parallel level %d: parallel_id=%" PRIu64 "\n", get_own_ompt_data(ompt_get_thread_data())->value, parallel_level, parallel_data->value); + parallel_level++; + } + return 0; //success +} + +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_task_info = (ompt_get_task_info_t) lookup("ompt_get_task_info"); + ompt_get_thread_data = (ompt_get_thread_data_t) lookup("ompt_get_thread_data"); + ompt_get_parallel_info = (ompt_get_parallel_info_t) lookup("ompt_get_parallel_info"); + ompt_get_unique_id = (ompt_get_unique_id_t) lookup("ompt_get_unique_id"); + + ompt_get_num_places = (ompt_get_num_places_t) lookup("ompt_get_num_places"); + ompt_get_place_proc_ids = (ompt_get_place_proc_ids_t) lookup("ompt_get_place_proc_ids"); + ompt_get_place_num = (ompt_get_place_num_t) lookup("ompt_get_place_num"); + ompt_get_partition_place_nums = (ompt_get_partition_place_nums_t) lookup("ompt_get_partition_place_nums"); + ompt_get_proc_id = (ompt_get_proc_id_t) lookup("ompt_get_proc_id"); + ompt_enumerate_states = (ompt_enumerate_states_t) lookup("ompt_enumerate_states"); + ompt_enumerate_mutex_impls = (ompt_enumerate_mutex_impls_t) lookup("ompt_enumerate_mutex_impls"); + + register_callback(ompt_callback_mutex_acquire); + register_callback_t(ompt_callback_mutex_acquired, ompt_callback_mutex_t); + register_callback_t(ompt_callback_mutex_released, ompt_callback_mutex_t); + register_callback(ompt_callback_nest_lock); + register_callback(ompt_callback_sync_region); + register_callback_t(ompt_callback_sync_region_wait, ompt_callback_sync_region_t); + register_callback(ompt_callback_control_tool); + register_callback(ompt_callback_flush); + register_callback(ompt_callback_cancel); + register_callback(ompt_callback_implicit_task); + 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_parallel_begin); + register_callback(ompt_callback_parallel_end); + register_callback(ompt_callback_task_create); + register_callback(ompt_callback_task_schedule); + register_callback(ompt_callback_dependences); + register_callback(ompt_callback_task_dependence); + register_callback(ompt_callback_thread_begin); + register_callback(ompt_callback_thread_end); + printf("0: NULL_POINTER=%p\n", (void*)NULL); + return 1; //success +} + +void ompt_finalize(ompt_data_t* tool_data) +{ + printf("0: ompt_event_runtime_shutdown\n"); +} + +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; +} Index: openmp/tools/multiplex/tests/custom_data_storage/custom_data_storage.c.second.tool.c =================================================================== --- /dev/null +++ openmp/tools/multiplex/tests/custom_data_storage/custom_data_storage.c.second.tool.c @@ -0,0 +1,6 @@ +// RUN: true +#define CLIENT_TOOL_LIBRARIES_VAR "PRINT_EMBEDDED_TOOL_LIBRARIES" +#include "ompt-multiplex.h" +#define TOOL_PREFIX " second_tool:" +#include "callback.h" + Index: openmp/tools/multiplex/tests/lit.cfg =================================================================== --- /dev/null +++ openmp/tools/multiplex/tests/lit.cfg @@ -0,0 +1,92 @@ +# -*- Python -*- vim: set ft=python ts=4 sw=4 expandtab tw=79: +# Configuration file for the 'lit' test runner. + +import os +import re +import subprocess +import lit.formats + +# Tell pylint that we know config and lit_config exist somewhere. +if 'PYLINT_IMPORT' in os.environ: + config = object() + lit_config = object() + +def append_dynamic_library_path(path): + if config.operating_system == 'Windows': + name = 'PATH' + sep = ';' + elif config.operating_system == 'Darwin': + name = 'DYLD_LIBRARY_PATH' + sep = ':' + else: + name = 'LD_LIBRARY_PATH' + sep = ':' + if name in config.environment: + config.environment[name] = path + sep + config.environment[name] + else: + config.environment[name] = path + +# name: The name of this test suite. +config.name = 'OMPT multiplex' + +# suffixes: A list of file extensions to treat as test files. +config.suffixes = ['.c'] + +# test_source_root: The root path where tests are located. +config.test_source_root = os.path.dirname(__file__) + +# test_exec_root: The root object directory where output is placed +config.test_exec_root = config.test_obj_root + +# test format +config.test_format = lit.formats.ShTest() + +# compiler flags +config.test_flags = " -I " + config.test_source_root + "/.."\ + " -I " + config.omp_header_dir + \ + " -L " + config.omp_library_dir + \ + " -I " + config.ompt_print_callback_dir + \ + " -Wl,-rpath," + config.omp_library_dir + \ + " " + config.test_openmp_flags + +# Allow XFAIL to work +config.target_triple = [ ] +for feature in config.test_compiler_features: + config.available_features.add(feature) + +# Setup environment to find dynamic library at runtime +append_dynamic_library_path(config.omp_library_dir) +append_dynamic_library_path(config.test_obj_root+"/..") + +# Rpath modifications for Darwin +if config.operating_system == 'Darwin': + config.test_flags += " -Wl,-rpath," + config.omp_library_dir + +# Find the SDK on Darwin +if config.operating_system == 'Darwin': + cmd = subprocess.Popen(['xcrun', '--show-sdk-path'], + stdout=subprocess.PIPE, stderr=subprocess.PIPE) + out, err = cmd.communicate() + out = out.strip() + res = cmd.wait() + if res == 0 and out: + config.test_flags += " -isysroot " + out + +if 'Linux' in config.operating_system: + config.available_features.add("linux") + +# substitutions +config.substitutions.append(("FileCheck", config.test_filecheck)) +config.substitutions.append(("%sort-threads", "sort --numeric-sort --stable")) + +config.substitutions.append(("%libomp-compile-and-run", \ + "%libomp-compile && %libomp-run")) +config.substitutions.append(("%libomp-compile", \ + "%clang %cflags %s -o %t")) +config.substitutions.append(("%libomp-tool", \ + "%clang %cflags -shared -fPIC -g")) +config.substitutions.append(("%libomp-run", "%t")) +config.substitutions.append(("%clang", config.test_c_compiler)) +config.substitutions.append(("%openmp_flag", config.test_openmp_flags)) +config.substitutions.append(("%cflags", config.test_flags)) + Index: openmp/tools/multiplex/tests/lit.site.cfg.in =================================================================== --- /dev/null +++ openmp/tools/multiplex/tests/lit.site.cfg.in @@ -0,0 +1,16 @@ +@AUTO_GEN_COMMENT@ + +config.test_c_compiler = "@OPENMP_TEST_C_COMPILER@" +config.test_cxx_compiler = "@OPENMP_TEST_CXX_COMPILER@" +config.test_compiler_features = @OPENMP_TEST_COMPILER_FEATURES@ +config.test_filecheck = "@OPENMP_FILECHECK_EXECUTABLE@" +config.test_openmp_flags = "@OPENMP_TEST_OPENMP_FLAGS@" +config.test_extra_flags = "@OPENMP_TEST_FLAGS@" +config.test_obj_root = "@CMAKE_CURRENT_BINARY_DIR@" +config.omp_library_dir = "@LIBOMP_LIBRARY_DIR@" +config.omp_header_dir = "@LIBOMP_INCLUDE_DIR@" +config.ompt_print_callback_dir = "@OMPT_PRINT_CALLBACKS_DIR@" +config.operating_system = "@CMAKE_SYSTEM_NAME@" + +# Let the main config do the real work. +lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg") Index: openmp/tools/multiplex/tests/ompt-signal.h =================================================================== --- /dev/null +++ openmp/tools/multiplex/tests/ompt-signal.h @@ -0,0 +1,24 @@ +// These functions are used to provide a signal-wait mechanism to enforce expected scheduling for the test cases. +// Conditional variable (s) needs to be shared! Initialize to 0 +#include + +#define OMPT_SIGNAL(s) ompt_signal(&s) +//inline +void ompt_signal(int* s) +{ + #pragma omp atomic + (*s)++; +} + +#define OMPT_WAIT(s,v) ompt_wait(&s,v) +// wait for s >= v +//inline +void ompt_wait(int *s, int v) +{ + int wait=0; + do{ + usleep(10); + #pragma omp atomic read + wait = (*s); + }while(wait + +int main() +{ + int x, s=0; + #pragma omp parallel num_threads(2) shared(s) + { + #pragma omp master + { + #pragma omp task shared(s) + { + omp_control_tool(5, 1, NULL); + OMPT_SIGNAL(s); + } + } + if(omp_get_thread_num() == 1) + OMPT_WAIT(s,1); + } + + + // Check if libomp supports the callbacks for this test. + // CHECK-NOT: {{^}}0: Could not register callback + + // CHECK: {{^}}0: NULL_POINTER=[[NULL:.*$]] + // CHECK: {{^}}0: NULL_POINTER=[[NULL]] + // CHECK: {{^}}0: ompt_event_runtime_shutdown + // CHECK: {{^}}0: ompt_event_runtime_shutdown + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID:[0-9]+]]: _first_tool: ompt_event_thread_begin: thread_type=ompt_thread_initial=1, thread_id=[[_FIRST_MASTER_THREAD_ID]] + // CHECK--: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: ompt_event_task_create: parent_task_id=0, parent_task_frame.exit=(nil), parent_task_frame.reenter=(nil), new_task_id=[[_FIRST_INITIAL_TASK_ID:[0-9]+]], codeptr_ra=(nil), task_type=ompt_task_initial=1, has_dependences=no + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: ompt_event_initial_task_begin: parallel_id=[[_FIRST_INIT_PARALLEL_ID:[0-9]+]], task_id=[[_FIRST_INITIAL_TASK_ID:[0-9]+]], actual_parallelism=1, index=1, flags=1 + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: ompt_event_parallel_begin: parent_task_id=[[_FIRST_INITIAL_TASK_ID]], parent_task_frame.exit=(nil), parent_task_frame.reenter={{0x[0-f]+}}, parallel_id=[[_FIRST_PARALLEL_ID:[0-9]+]], requested_team_size=2, codeptr_ra={{0x[0-f]+}}, invoker=2 + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: ompt_event_implicit_task_begin: parallel_id=[[_FIRST_PARALLEL_ID]], task_id=[[_FIRST_MASTER_IMPLICIT_TASK_ID:[0-9]+]], team_size=2, thread_num=0 + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: ompt_event_master_begin: parallel_id=[[_FIRST_PARALLEL_ID]], task_id=[[_FIRST_MASTER_IMPLICIT_TASK_ID]], codeptr_ra={{0x[0-f]+}} + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: ompt_event_task_create: parent_task_id=[[_FIRST_MASTER_IMPLICIT_TASK_ID]], parent_task_frame.exit={{0x[0-f]+}}, parent_task_frame.reenter={{0x[0-f]+}}, new_task_id=[[_FIRST_EXPLICIT_TASK_ID:[0-9]+]], codeptr_ra={{0x[0-f]+}}, task_type=ompt_task_explicit=4, has_dependences=no + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: ompt_event_master_end: parallel_id=[[_FIRST_PARALLEL_ID]], task_id=[[_FIRST_MASTER_IMPLICIT_TASK_ID]], codeptr_ra={{0x[0-f]+}} + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: ompt_event_barrier_begin: parallel_id=[[_FIRST_PARALLEL_ID]], task_id=[[_FIRST_MASTER_IMPLICIT_TASK_ID]], codeptr_ra={{0x[0-f]+}} + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: ompt_event_wait_barrier_begin: parallel_id=[[_FIRST_PARALLEL_ID]], task_id=[[_FIRST_MASTER_IMPLICIT_TASK_ID]], codeptr_ra={{0x[0-f]+}} + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: ompt_event_task_schedule: first_task_id=[[_FIRST_MASTER_IMPLICIT_TASK_ID]], second_task_id=[[_FIRST_EXPLICIT_TASK_ID]], prior_task_status=ompt_task_switch=7 + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: ompt_event_control_tool: command=5, modifier=1, arg=(nil), codeptr_ra={{0x[0-f]+}} + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: task level 0: task_id=[[_FIRST_EXPLICIT_TASK_ID]] + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: task level 1: task_id=[[_FIRST_MASTER_IMPLICIT_TASK_ID]] + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: task level 2: task_id=[[_FIRST_INITIAL_TASK_ID]] + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: parallel level 0: parallel_id=[[_FIRST_PARALLEL_ID]] + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: parallel level 1: parallel_id={{[0-9]+}} + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: ompt_event_task_schedule: first_task_id=[[_FIRST_EXPLICIT_TASK_ID]], second_task_id=[[_FIRST_MASTER_IMPLICIT_TASK_ID]], prior_task_status=ompt_task_complete=1 + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: ompt_event_task_end: task_id=[[_FIRST_EXPLICIT_TASK_ID]] + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: ompt_event_wait_barrier_end: parallel_id=0, task_id=[[_FIRST_MASTER_IMPLICIT_TASK_ID]], codeptr_ra=(nil) + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: ompt_event_barrier_end: parallel_id=0, task_id=[[_FIRST_MASTER_IMPLICIT_TASK_ID]], codeptr_ra=(nil) + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: ompt_event_implicit_task_end: parallel_id=0, task_id=[[_FIRST_MASTER_IMPLICIT_TASK_ID]], team_size=2, thread_num=0 + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: ompt_event_parallel_end: parallel_id=[[_FIRST_PARALLEL_ID]], task_id=[[_FIRST_INITIAL_TASK_ID]], invoker=2, codeptr_ra={{0x[0-f]+}} + // CHECK: {{^}}[[_FIRST_MASTER_THREAD_ID]]: _first_tool: ompt_event_thread_end: thread_id=[[_FIRST_MASTER_THREAD_ID]] + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID:[0-9]+]]: second_tool: ompt_event_thread_begin: thread_type=ompt_thread_initial=1, thread_id=[[SECOND_MASTER_THREAD_ID]] + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: ompt_event_initial_task_begin: parallel_id=[[SECOND_INIT_PARALLEL_ID:[0-9]+]], task_id=[[SECOND_INITIAL_TASK_ID:[0-9]+]], actual_parallelism=1, index=1, flags=1 + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: ompt_event_parallel_begin: parent_task_id=[[SECOND_INITIAL_TASK_ID]], parent_task_frame.exit=(nil), parent_task_frame.reenter={{0x[0-f]+}}, parallel_id=[[SECOND_PARALLEL_ID:[0-9]+]], requested_team_size=2, codeptr_ra={{0x[0-f]+}}, invoker=2 + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: ompt_event_implicit_task_begin: parallel_id=[[SECOND_PARALLEL_ID]], task_id=[[SECOND_MASTER_IMPLICIT_TASK_ID:[0-9]+]], team_size=2, thread_num=0 + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: ompt_event_master_begin: parallel_id=[[SECOND_PARALLEL_ID]], task_id=[[SECOND_MASTER_IMPLICIT_TASK_ID]], codeptr_ra={{0x[0-f]+}} + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: ompt_event_task_create: parent_task_id=[[SECOND_MASTER_IMPLICIT_TASK_ID]], parent_task_frame.exit={{0x[0-f]+}}, parent_task_frame.reenter={{0x[0-f]+}}, new_task_id=[[SECOND_EXPLICIT_TASK_ID:[0-9]+]], codeptr_ra={{0x[0-f]+}}, task_type=ompt_task_explicit=4, has_dependences=no + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: ompt_event_master_end: parallel_id=[[SECOND_PARALLEL_ID]], task_id=[[SECOND_MASTER_IMPLICIT_TASK_ID]], codeptr_ra={{0x[0-f]+}} + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: ompt_event_barrier_begin: parallel_id=[[SECOND_PARALLEL_ID]], task_id=[[SECOND_MASTER_IMPLICIT_TASK_ID]], codeptr_ra={{0x[0-f]+}} + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: ompt_event_wait_barrier_begin: parallel_id=[[SECOND_PARALLEL_ID]], task_id=[[SECOND_MASTER_IMPLICIT_TASK_ID]], codeptr_ra={{0x[0-f]+}} + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: ompt_event_task_schedule: first_task_id=[[SECOND_MASTER_IMPLICIT_TASK_ID]], second_task_id=[[SECOND_EXPLICIT_TASK_ID]], prior_task_status=ompt_task_switch=7 + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: ompt_event_control_tool: command=5, modifier=1, arg=(nil), codeptr_ra={{0x[0-f]+}} + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: task level 0: task_id=[[SECOND_EXPLICIT_TASK_ID]] + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: task level 1: task_id=[[SECOND_MASTER_IMPLICIT_TASK_ID]] + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: task level 2: task_id=[[SECOND_INITIAL_TASK_ID]] + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: parallel level 0: parallel_id=[[SECOND_PARALLEL_ID]] + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: parallel level 1: parallel_id={{[0-9]+}} + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: ompt_event_task_schedule: first_task_id=[[SECOND_EXPLICIT_TASK_ID]], second_task_id=[[SECOND_MASTER_IMPLICIT_TASK_ID]], prior_task_status=ompt_task_complete=1 + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: ompt_event_task_end: task_id=[[SECOND_EXPLICIT_TASK_ID]] + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: ompt_event_wait_barrier_end: parallel_id=0, task_id=[[SECOND_MASTER_IMPLICIT_TASK_ID]], codeptr_ra=(nil) + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: ompt_event_barrier_end: parallel_id=0, task_id=[[SECOND_MASTER_IMPLICIT_TASK_ID]], codeptr_ra=(nil) + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: ompt_event_implicit_task_end: parallel_id=0, task_id=[[SECOND_MASTER_IMPLICIT_TASK_ID]], team_size=2, thread_num=0 + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: ompt_event_parallel_end: parallel_id=[[SECOND_PARALLEL_ID]], task_id=[[SECOND_INITIAL_TASK_ID]], invoker=2, codeptr_ra={{0x[0-f]+}} + // CHECK: {{^}}[[SECOND_MASTER_THREAD_ID]]: second_tool: ompt_event_thread_end: thread_id=[[SECOND_MASTER_THREAD_ID]] + // CHECK: {{^}}[[_FIRST_WORKER_THREAD_ID:[0-9]+]]: _first_tool: ompt_event_thread_begin: thread_type=ompt_thread_worker=2, thread_id=[[_FIRST_WORKER_THREAD_ID]] + // CHECK: {{^}}[[_FIRST_WORKER_THREAD_ID]]: _first_tool: ompt_event_implicit_task_begin: parallel_id=[[_FIRST_PARALLEL_ID]], task_id=[[_FIRST_WORKER_IMPLICIT_TASK_ID:[0-9]+]], team_size=2, thread_num=1 + // CHECK: {{^}}[[_FIRST_WORKER_THREAD_ID]]: _first_tool: ompt_event_barrier_begin: parallel_id=[[_FIRST_PARALLEL_ID]], task_id=[[_FIRST_WORKER_IMPLICIT_TASK_ID]], codeptr_ra=(nil) + // CHECK: {{^}}[[_FIRST_WORKER_THREAD_ID]]: _first_tool: ompt_event_wait_barrier_begin: parallel_id=[[_FIRST_PARALLEL_ID]], task_id=[[_FIRST_WORKER_IMPLICIT_TASK_ID]], codeptr_ra=(nil) + // CHECK: {{^}}[[_FIRST_WORKER_THREAD_ID]]: _first_tool: ompt_event_wait_barrier_end: parallel_id=0, task_id=[[_FIRST_WORKER_IMPLICIT_TASK_ID]], codeptr_ra=(nil) + // CHECK: {{^}}[[_FIRST_WORKER_THREAD_ID]]: _first_tool: ompt_event_barrier_end: parallel_id=0, task_id=[[_FIRST_WORKER_IMPLICIT_TASK_ID]], codeptr_ra=(nil) + // CHECK: {{^}}[[_FIRST_WORKER_THREAD_ID]]: _first_tool: ompt_event_implicit_task_end: parallel_id=0, task_id=[[_FIRST_WORKER_IMPLICIT_TASK_ID]], team_size=0, thread_num=1 + // CHECK: {{^}}[[_FIRST_WORKER_THREAD_ID]]: _first_tool: ompt_event_thread_end: thread_id=[[_FIRST_WORKER_THREAD_ID]] + // CHECK: {{^}}[[SECOND_WORKER_THREAD_ID:[0-9]+]]: second_tool: ompt_event_thread_begin: thread_type=ompt_thread_worker=2, thread_id=[[SECOND_WORKER_THREAD_ID]] + // CHECK: {{^}}[[SECOND_WORKER_THREAD_ID]]: second_tool: ompt_event_implicit_task_begin: parallel_id=[[SECOND_PARALLEL_ID]], task_id=[[SECOND_WORKER_IMPLICIT_TASK_ID:[0-9]+]], team_size=2, thread_num=1 + // CHECK: {{^}}[[SECOND_WORKER_THREAD_ID]]: second_tool: ompt_event_barrier_begin: parallel_id=[[SECOND_PARALLEL_ID]], task_id=[[SECOND_WORKER_IMPLICIT_TASK_ID]], codeptr_ra=(nil) + // CHECK: {{^}}[[SECOND_WORKER_THREAD_ID]]: second_tool: ompt_event_wait_barrier_begin: parallel_id=[[SECOND_PARALLEL_ID]], task_id=[[SECOND_WORKER_IMPLICIT_TASK_ID]], codeptr_ra=(nil) + // CHECK: {{^}}[[SECOND_WORKER_THREAD_ID]]: second_tool: ompt_event_wait_barrier_end: parallel_id=0, task_id=[[SECOND_WORKER_IMPLICIT_TASK_ID]], codeptr_ra=(nil) + // CHECK: {{^}}[[SECOND_WORKER_THREAD_ID]]: second_tool: ompt_event_barrier_end: parallel_id=0, task_id=[[SECOND_WORKER_IMPLICIT_TASK_ID]], codeptr_ra=(nil) + // CHECK: {{^}}[[SECOND_WORKER_THREAD_ID]]: second_tool: ompt_event_implicit_task_end: parallel_id=0, task_id=[[SECOND_WORKER_IMPLICIT_TASK_ID]], team_size=0, thread_num=1 + // CHECK: {{^}}[[SECOND_WORKER_THREAD_ID]]: second_tool: ompt_event_thread_end: thread_id=[[SECOND_WORKER_THREAD_ID]] + + return 0; +} Index: openmp/tools/multiplex/tests/print/print.c.first.tool.c =================================================================== --- /dev/null +++ openmp/tools/multiplex/tests/print/print.c.first.tool.c @@ -0,0 +1,6 @@ +// RUN: true +#define CLIENT_TOOL_LIBRARIES_VAR "PRINT_TOOL_LIBRARIES" +#include "ompt-multiplex.h" +#define TOOL_PREFIX " _first_tool:" +#include "callback.h" + Index: openmp/tools/multiplex/tests/print/print.c.second.tool.c =================================================================== --- /dev/null +++ openmp/tools/multiplex/tests/print/print.c.second.tool.c @@ -0,0 +1,6 @@ +// RUN: true +#define CLIENT_TOOL_LIBRARIES_VAR "PRINT_EMBEDDED_TOOL_LIBRARIES" +#include "ompt-multiplex.h" +#define TOOL_PREFIX " second_tool:" +#include "callback.h" +