[OpenMP][OMPT] Fix memory leak when using GCC compatibility code

Serialized parallels allocate lightweight task teams on the heap
but never free them in the corresponding join. This patch adds a wrapper
around the allocation (if ompt enabled) and also adds the corresponding
free in the join call.

Differential Revision: https://reviews.llvm.org/D131690
This commit is contained in:
Jonathan Peyton 2022-08-11 11:13:01 -05:00
parent 6c7b049f6e
commit 56f36f85e0
1 changed files with 10 additions and 5 deletions

View File

@ -1947,12 +1947,14 @@ int __kmp_fork_call(ident_t *loc, int gtid,
}
} else if (call_context == fork_context_gnu) {
#if OMPT_SUPPORT
ompt_lw_taskteam_t lwt;
__ompt_lw_taskteam_init(&lwt, master_th, gtid, &ompt_parallel_data,
return_address);
if (ompt_enabled.enabled) {
ompt_lw_taskteam_t lwt;
__ompt_lw_taskteam_init(&lwt, master_th, gtid, &ompt_parallel_data,
return_address);
lwt.ompt_task_info.frame.exit_frame = ompt_data_none;
__ompt_lw_taskteam_link(&lwt, master_th, 1);
lwt.ompt_task_info.frame.exit_frame = ompt_data_none;
__ompt_lw_taskteam_link(&lwt, master_th, 1);
}
// don't use lw_taskteam after linking. content was swaped
#endif
@ -2396,6 +2398,9 @@ void __kmp_join_call(ident_t *loc, int gtid
#if OMPT_SUPPORT
if (ompt_enabled.enabled) {
if (fork_context == fork_context_gnu) {
__ompt_lw_taskteam_unlink(master_th);
}
__kmp_join_restore_state(master_th, parent_team);
}
#endif