diff options
Diffstat (limited to 'openmp/runtime/src/kmp_cancel.cpp')
| -rw-r--r-- | openmp/runtime/src/kmp_cancel.cpp | 75 |
1 files changed, 65 insertions, 10 deletions
diff --git a/openmp/runtime/src/kmp_cancel.cpp b/openmp/runtime/src/kmp_cancel.cpp index efc67fcb57f..71c71ec082f 100644 --- a/openmp/runtime/src/kmp_cancel.cpp +++ b/openmp/runtime/src/kmp_cancel.cpp @@ -12,6 +12,9 @@ #include "kmp_i18n.h" #include "kmp_io.h" #include "kmp_str.h" +#if OMPT_SUPPORT +#include "ompt-specific.h" +#endif #if OMP_40_ENABLED @@ -51,11 +54,25 @@ kmp_int32 __kmpc_cancel(ident_t *loc_ref, kmp_int32 gtid, kmp_int32 cncl_kind) { kmp_int32 old = KMP_COMPARE_AND_STORE_RET32( &(this_team->t.t_cancel_request), cancel_noreq, cncl_kind); if (old == cancel_noreq || old == cncl_kind) { - // printf("__kmpc_cancel: this_team->t.t_cancel_request=%d @ %p\n", - // this_team->t.t_cancel_request, - // &(this_team->t.t_cancel_request)); - // we do not have a cancellation request in this team or we do have - // one that matches the current request -> cancel +// we do not have a cancellation request in this team or we do have +// one that matches the current request -> cancel +#if OMPT_SUPPORT && OMPT_OPTIONAL + if (ompt_enabled.ompt_callback_cancel) { + ompt_data_t *task_data; + __ompt_get_task_info_internal(0, NULL, &task_data, NULL, NULL, + NULL); + ompt_cancel_flag_t type = ompt_cancel_parallel; + if (cncl_kind == cancel_parallel) + type = ompt_cancel_parallel; + else if (cncl_kind == cancel_loop) + type = ompt_cancel_do; + else if (cncl_kind == cancel_sections) + type = ompt_cancel_sections; + ompt_callbacks.ompt_callback(ompt_callback_cancel)( + task_data, type | ompt_cancel_activated, + OMPT_GET_RETURN_ADDRESS(0)); + } +#endif return 1 /* true */; } break; @@ -75,8 +92,18 @@ kmp_int32 __kmpc_cancel(ident_t *loc_ref, kmp_int32 gtid, kmp_int32 cncl_kind) { kmp_int32 old = KMP_COMPARE_AND_STORE_RET32( &(taskgroup->cancel_request), cancel_noreq, cncl_kind); if (old == cancel_noreq || old == cncl_kind) { - // we do not have a cancellation request in this taskgroup or we do - // have one that matches the current request -> cancel +// we do not have a cancellation request in this taskgroup or we do +// have one that matches the current request -> cancel +#if OMPT_SUPPORT && OMPT_OPTIONAL + if (ompt_enabled.ompt_callback_cancel) { + ompt_data_t *task_data; + __ompt_get_task_info_internal(0, NULL, &task_data, NULL, NULL, + NULL); + ompt_callbacks.ompt_callback(ompt_callback_cancel)( + task_data, ompt_cancel_taskgroup | ompt_cancel_activated, + OMPT_GET_RETURN_ADDRESS(0)); + } +#endif return 1 /* true */; } } else { @@ -134,8 +161,25 @@ kmp_int32 __kmpc_cancellationpoint(ident_t *loc_ref, kmp_int32 gtid, KMP_DEBUG_ASSERT(this_team); if (this_team->t.t_cancel_request) { if (cncl_kind == this_team->t.t_cancel_request) { - // the request in the team structure matches the type of - // cancellation point so we can cancel +// the request in the team structure matches the type of +// cancellation point so we can cancel +#if OMPT_SUPPORT && OMPT_OPTIONAL + if (ompt_enabled.ompt_callback_cancel) { + ompt_data_t *task_data; + __ompt_get_task_info_internal(0, NULL, &task_data, NULL, NULL, + NULL); + ompt_cancel_flag_t type = ompt_cancel_parallel; + if (cncl_kind == cancel_parallel) + type = ompt_cancel_parallel; + else if (cncl_kind == cancel_loop) + type = ompt_cancel_do; + else if (cncl_kind == cancel_sections) + type = ompt_cancel_sections; + ompt_callbacks.ompt_callback(ompt_callback_cancel)( + task_data, type | ompt_cancel_detected, + OMPT_GET_RETURN_ADDRESS(0)); + } +#endif return 1 /* true */; } KMP_ASSERT(0 /* false */); @@ -158,7 +202,18 @@ kmp_int32 __kmpc_cancellationpoint(ident_t *loc_ref, kmp_int32 gtid, taskgroup = task->td_taskgroup; if (taskgroup) { - // return the current status of cancellation for the taskgroup +// return the current status of cancellation for the taskgroup +#if OMPT_SUPPORT && OMPT_OPTIONAL + if (ompt_enabled.ompt_callback_cancel && + !!taskgroup->cancel_request) { + ompt_data_t *task_data; + __ompt_get_task_info_internal(0, NULL, &task_data, NULL, NULL, + NULL); + ompt_callbacks.ompt_callback(ompt_callback_cancel)( + task_data, ompt_cancel_taskgroup | ompt_cancel_detected, + OMPT_GET_RETURN_ADDRESS(0)); + } +#endif return !!taskgroup->cancel_request; } else { // if a cancellation point is encountered by a task that does not |

