diff options
author | Joachim Protze <protze@itc.rwth-aachen.de> | 2017-11-01 10:08:30 +0000 |
---|---|---|
committer | Joachim Protze <protze@itc.rwth-aachen.de> | 2017-11-01 10:08:30 +0000 |
commit | 82e94a593433f36734e2d34898d353a2ecb65b8b (patch) | |
tree | d7ac69e35db74384a401862feb3eb31e78ca94ca /openmp/runtime/src/kmp_sched.cpp | |
parent | b93c06331ea77953e80bbd5ffb30167eade466f0 (diff) | |
download | bcm5719-llvm-82e94a593433f36734e2d34898d353a2ecb65b8b.tar.gz bcm5719-llvm-82e94a593433f36734e2d34898d353a2ecb65b8b.zip |
Update implementation of OMPT to the specification OpenMP 5.0 Preview 1 (TR4).
The code is tested to work with latest clang, GNU and Intel compiler. The implementation
is optimized for low overhead when no tool is attached shifting the cost to execution with
tool attached.
This patch does not implement OMPT for libomptarget.
Patch by Simon Convent and Joachim Protze
Differential Revision: https://reviews.llvm.org/D38185
llvm-svn: 317085
Diffstat (limited to 'openmp/runtime/src/kmp_sched.cpp')
-rw-r--r-- | openmp/runtime/src/kmp_sched.cpp | 92 |
1 files changed, 68 insertions, 24 deletions
diff --git a/openmp/runtime/src/kmp_sched.cpp b/openmp/runtime/src/kmp_sched.cpp index 0fa1a698a6c..4a878e3e944 100644 --- a/openmp/runtime/src/kmp_sched.cpp +++ b/openmp/runtime/src/kmp_sched.cpp @@ -44,7 +44,12 @@ static void __kmp_for_static_init(ident_t *loc, kmp_int32 global_tid, T *plower, T *pupper, typename traits_t<T>::signed_t *pstride, typename traits_t<T>::signed_t incr, - typename traits_t<T>::signed_t chunk) { + typename traits_t<T>::signed_t chunk +#if OMPT_SUPPORT && OMPT_OPTIONAL + , + void *codeptr +#endif + ) { KMP_COUNT_BLOCK(OMP_FOR_static); KMP_TIME_PARTITIONED_BLOCK(FOR_static_scheduling); @@ -58,14 +63,29 @@ static void __kmp_for_static_init(ident_t *loc, kmp_int32 global_tid, kmp_team_t *team; kmp_info_t *th = __kmp_threads[gtid]; -#if OMPT_SUPPORT && OMPT_TRACE +#if OMPT_SUPPORT && OMPT_OPTIONAL ompt_team_info_t *team_info = NULL; ompt_task_info_t *task_info = NULL; + ompt_work_type_t ompt_work_type; - if (ompt_enabled) { + if (ompt_enabled.enabled) { // Only fully initialize variables needed by OMPT if OMPT is enabled. team_info = __ompt_get_teaminfo(0, NULL); - task_info = __ompt_get_taskinfo(0); + task_info = __ompt_get_task_info_object(0); + // Determine workshare type + if (loc != NULL) { + if ((loc->flags & KMP_IDENT_WORK_LOOP) != 0) { + ompt_work_type = ompt_work_loop; + } else if ((loc->flags & KMP_IDENT_WORK_SECTIONS) != 0) { + ompt_work_type = ompt_work_sections; + } else if ((loc->flags & KMP_IDENT_WORK_DISTRIBUTE) != 0) { + ompt_work_type = ompt_work_distribute; + } else { + KMP_ASSERT2(0, + "__kmpc_for_static_init: can't determine workshare type"); + } + KMP_DEBUG_ASSERT(ompt_work_type); + } } #endif @@ -119,10 +139,11 @@ static void __kmp_for_static_init(ident_t *loc, kmp_int32 global_tid, #endif KE_TRACE(10, ("__kmpc_for_static_init: T#%d return\n", global_tid)); -#if OMPT_SUPPORT && OMPT_TRACE - if (ompt_enabled && ompt_callbacks.ompt_callback(ompt_event_loop_begin)) { - ompt_callbacks.ompt_callback(ompt_event_loop_begin)( - team_info->parallel_id, task_info->task_id, team_info->microtask); +#if OMPT_SUPPORT && OMPT_OPTIONAL + if (ompt_enabled.ompt_callback_work) { + ompt_callbacks.ompt_callback(ompt_callback_work)( + ompt_work_type, ompt_scope_begin, &(team_info->parallel_data), + &(task_info->task_data), 0, codeptr); } #endif KMP_COUNT_VALUE(FOR_static_iterations, 0); @@ -170,10 +191,11 @@ static void __kmp_for_static_init(ident_t *loc, kmp_int32 global_tid, #endif KE_TRACE(10, ("__kmpc_for_static_init: T#%d return\n", global_tid)); -#if OMPT_SUPPORT && OMPT_TRACE - if (ompt_enabled && ompt_callbacks.ompt_callback(ompt_event_loop_begin)) { - ompt_callbacks.ompt_callback(ompt_event_loop_begin)( - team_info->parallel_id, task_info->task_id, team_info->microtask); +#if OMPT_SUPPORT && OMPT_OPTIONAL + if (ompt_enabled.ompt_callback_work) { + ompt_callbacks.ompt_callback(ompt_callback_work)( + ompt_work_type, ompt_scope_begin, &(team_info->parallel_data), + &(task_info->task_data), *pstride, codeptr); } #endif return; @@ -198,10 +220,11 @@ static void __kmp_for_static_init(ident_t *loc, kmp_int32 global_tid, #endif KE_TRACE(10, ("__kmpc_for_static_init: T#%d return\n", global_tid)); -#if OMPT_SUPPORT && OMPT_TRACE - if (ompt_enabled && ompt_callbacks.ompt_callback(ompt_event_loop_begin)) { - ompt_callbacks.ompt_callback(ompt_event_loop_begin)( - team_info->parallel_id, task_info->task_id, team_info->microtask); +#if OMPT_SUPPORT && OMPT_OPTIONAL + if (ompt_enabled.ompt_callback_work) { + ompt_callbacks.ompt_callback(ompt_callback_work)( + ompt_work_type, ompt_scope_begin, &(team_info->parallel_data), + &(task_info->task_data), *pstride, codeptr); } #endif return; @@ -354,10 +377,11 @@ static void __kmp_for_static_init(ident_t *loc, kmp_int32 global_tid, #endif KE_TRACE(10, ("__kmpc_for_static_init: T#%d return\n", global_tid)); -#if OMPT_SUPPORT && OMPT_TRACE - if (ompt_enabled && ompt_callbacks.ompt_callback(ompt_event_loop_begin)) { - ompt_callbacks.ompt_callback(ompt_event_loop_begin)( - team_info->parallel_id, task_info->task_id, team_info->microtask); +#if OMPT_SUPPORT && OMPT_OPTIONAL + if (ompt_enabled.ompt_callback_work) { + ompt_callbacks.ompt_callback(ompt_callback_work)( + ompt_work_type, ompt_scope_begin, &(team_info->parallel_data), + &(task_info->task_data), trip_count, codeptr); } #endif @@ -745,7 +769,12 @@ void __kmpc_for_static_init_4(ident_t *loc, kmp_int32 gtid, kmp_int32 schedtype, kmp_int32 *pupper, kmp_int32 *pstride, kmp_int32 incr, kmp_int32 chunk) { __kmp_for_static_init<kmp_int32>(loc, gtid, schedtype, plastiter, plower, - pupper, pstride, incr, chunk); + pupper, pstride, incr, chunk +#if OMPT_SUPPORT && OMPT_OPTIONAL + , + OMPT_GET_RETURN_ADDRESS(0) +#endif + ); } /*! @@ -757,7 +786,12 @@ void __kmpc_for_static_init_4u(ident_t *loc, kmp_int32 gtid, kmp_int32 *pstride, kmp_int32 incr, kmp_int32 chunk) { __kmp_for_static_init<kmp_uint32>(loc, gtid, schedtype, plastiter, plower, - pupper, pstride, incr, chunk); + pupper, pstride, incr, chunk +#if OMPT_SUPPORT && OMPT_OPTIONAL + , + OMPT_GET_RETURN_ADDRESS(0) +#endif + ); } /*! @@ -768,7 +802,12 @@ void __kmpc_for_static_init_8(ident_t *loc, kmp_int32 gtid, kmp_int32 schedtype, kmp_int64 *pupper, kmp_int64 *pstride, kmp_int64 incr, kmp_int64 chunk) { __kmp_for_static_init<kmp_int64>(loc, gtid, schedtype, plastiter, plower, - pupper, pstride, incr, chunk); + pupper, pstride, incr, chunk +#if OMPT_SUPPORT && OMPT_OPTIONAL + , + OMPT_GET_RETURN_ADDRESS(0) +#endif + ); } /*! @@ -780,7 +819,12 @@ void __kmpc_for_static_init_8u(ident_t *loc, kmp_int32 gtid, kmp_int64 *pstride, kmp_int64 incr, kmp_int64 chunk) { __kmp_for_static_init<kmp_uint64>(loc, gtid, schedtype, plastiter, plower, - pupper, pstride, incr, chunk); + pupper, pstride, incr, chunk +#if OMPT_SUPPORT && OMPT_OPTIONAL + , + OMPT_GET_RETURN_ADDRESS(0) +#endif + ); } /*! @} |