aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Peyton <jonathan.l.peyton@intel.com>2022-08-11 11:13:01 -0500
committerJonathan Peyton <jonathan.l.peyton@intel.com>2022-08-11 15:26:09 -0500
commit56f36f85e029d6947d07d7d174801104785149a7 (patch)
tree15bf703c51ebdf7cfa5b8b3089ac18f26431c9c1
parent6c7b049f6eb78edf83506a858c7b211a7c70afd8 (diff)
downloadllvm-56f36f85e029d6947d07d7d174801104785149a7.zip
llvm-56f36f85e029d6947d07d7d174801104785149a7.tar.gz
llvm-56f36f85e029d6947d07d7d174801104785149a7.tar.bz2
[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
-rw-r--r--openmp/runtime/src/kmp_runtime.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/openmp/runtime/src/kmp_runtime.cpp b/openmp/runtime/src/kmp_runtime.cpp
index b8d4705..a429ed1 100644
--- a/openmp/runtime/src/kmp_runtime.cpp
+++ b/openmp/runtime/src/kmp_runtime.cpp
@@ -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