[Openmp-commits] [openmp] r287559 - Merging r285283:
Jonathan Peyton via Openmp-commits
openmp-commits at lists.llvm.org
Mon Nov 21 10:45:39 PST 2016
Author: jlpeyton
Date: Mon Nov 21 12:45:39 2016
New Revision: 287559
URL: http://llvm.org/viewvc/llvm-project?rev=287559&view=rev
Log:
Merging r285283:
------------------------------------------------------------------------
r285283 | achurbanov | 2016-10-27 06:43:07 -0500 (Thu, 27 Oct 2016) | 6 lines
Fixed a memory leak related to task dependencies.
Differential Revision: http://reviews.llvm.org/D25504
Patch by Alex Duran.
------------------------------------------------------------------------
Modified:
openmp/branches/release_39/ (props changed)
openmp/branches/release_39/runtime/src/kmp.h
openmp/branches/release_39/runtime/src/kmp_runtime.c
openmp/branches/release_39/runtime/src/kmp_taskdeps.cpp
openmp/branches/release_39/runtime/src/kmp_tasking.c
Propchange: openmp/branches/release_39/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Nov 21 12:45:39 2016
@@ -1 +1 @@
-/openmp/trunk:278036,278332,280138
+/openmp/trunk:278036,278332,280138,285283
Modified: openmp/branches/release_39/runtime/src/kmp.h
URL: http://llvm.org/viewvc/llvm-project/openmp/branches/release_39/runtime/src/kmp.h?rev=287559&r1=287558&r2=287559&view=diff
==============================================================================
--- openmp/branches/release_39/runtime/src/kmp.h (original)
+++ openmp/branches/release_39/runtime/src/kmp.h Mon Nov 21 12:45:39 2016
@@ -3327,6 +3327,8 @@ extern kmp_task_t* __kmp_task_alloc( ide
kmp_routine_entry_t task_entry );
extern void __kmp_init_implicit_task( ident_t *loc_ref, kmp_info_t *this_thr,
kmp_team_t *team, int tid, int set_curr_task );
+extern void __kmp_finish_implicit_task(kmp_info_t *this_thr);
+extern void __kmp_free_implicit_task(kmp_info_t *this_thr);
int __kmp_execute_tasks_32(kmp_info_t *thread, kmp_int32 gtid, kmp_flag_32 *flag, int final_spin,
int *thread_finished,
@@ -3496,12 +3498,18 @@ void __kmpc_omp_task_complete( ident_t *
KMP_EXPORT void __kmpc_taskgroup( ident_t * loc, int gtid );
KMP_EXPORT void __kmpc_end_taskgroup( ident_t * loc, int gtid );
-KMP_EXPORT kmp_int32 __kmpc_omp_task_with_deps ( ident_t *loc_ref, kmp_int32 gtid, kmp_task_t * new_task,
- kmp_int32 ndeps, kmp_depend_info_t *dep_list,
- kmp_int32 ndeps_noalias, kmp_depend_info_t *noalias_dep_list );
-KMP_EXPORT void __kmpc_omp_wait_deps ( ident_t *loc_ref, kmp_int32 gtid, kmp_int32 ndeps, kmp_depend_info_t *dep_list,
- kmp_int32 ndeps_noalias, kmp_depend_info_t *noalias_dep_list );
-extern void __kmp_release_deps ( kmp_int32 gtid, kmp_taskdata_t *task );
+KMP_EXPORT kmp_int32 __kmpc_omp_task_with_deps(
+ ident_t *loc_ref, kmp_int32 gtid, kmp_task_t *new_task, kmp_int32 ndeps,
+ kmp_depend_info_t *dep_list, kmp_int32 ndeps_noalias,
+ kmp_depend_info_t *noalias_dep_list);
+KMP_EXPORT void __kmpc_omp_wait_deps(ident_t *loc_ref, kmp_int32 gtid,
+ kmp_int32 ndeps,
+ kmp_depend_info_t *dep_list,
+ kmp_int32 ndeps_noalias,
+ kmp_depend_info_t *noalias_dep_list);
+extern void __kmp_release_deps(kmp_int32 gtid, kmp_taskdata_t *task);
+extern void __kmp_dephash_free_entries(kmp_info_t *thread, kmp_dephash_t *h);
+extern void __kmp_dephash_free(kmp_info_t *thread, kmp_dephash_t *h);
extern kmp_int32 __kmp_omp_task( kmp_int32 gtid, kmp_task_t * new_task, bool serialize_immediate );
Modified: openmp/branches/release_39/runtime/src/kmp_runtime.c
URL: http://llvm.org/viewvc/llvm-project/openmp/branches/release_39/runtime/src/kmp_runtime.c?rev=287559&r1=287558&r2=287559&view=diff
==============================================================================
--- openmp/branches/release_39/runtime/src/kmp_runtime.c (original)
+++ openmp/branches/release_39/runtime/src/kmp_runtime.c Mon Nov 21 12:45:39 2016
@@ -5743,6 +5743,7 @@ __kmp_reap_thread(
}; // if
#endif /* KMP_AFFINITY_SUPPORTED */
+ __kmp_free_implicit_task(thread);
__kmp_reap_team( thread->th.th_serial_team );
thread->th.th_serial_team = NULL;
__kmp_free( thread );
@@ -6784,6 +6785,8 @@ __kmp_run_after_invoked_task( int gtid,
{
if( __kmp_env_consistency_check )
__kmp_pop_parallel( gtid, team->t.t_ident );
+
+ __kmp_finish_implicit_task(this_thr);
}
int
Modified: openmp/branches/release_39/runtime/src/kmp_taskdeps.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/branches/release_39/runtime/src/kmp_taskdeps.cpp?rev=287559&r1=287558&r2=287559&view=diff
==============================================================================
--- openmp/branches/release_39/runtime/src/kmp_taskdeps.cpp (original)
+++ openmp/branches/release_39/runtime/src/kmp_taskdeps.cpp Mon Nov 21 12:45:39 2016
@@ -97,7 +97,8 @@ __kmp_dephash_create ( kmp_info_t *threa
else
h_size = KMP_DEPHASH_OTHER_SIZE;
- kmp_int32 size = h_size * sizeof(kmp_dephash_entry_t) + sizeof(kmp_dephash_t);
+ kmp_int32 size =
+ h_size * sizeof(kmp_dephash_entry_t *) + sizeof(kmp_dephash_t);
#if USE_FAST_MEMORY
h = (kmp_dephash_t *) __kmp_fast_allocate( thread, size );
@@ -118,13 +119,13 @@ __kmp_dephash_create ( kmp_info_t *threa
return h;
}
-static void
-__kmp_dephash_free ( kmp_info_t *thread, kmp_dephash_t *h )
+void
+__kmp_dephash_free_entries(kmp_info_t *thread, kmp_dephash_t *h)
{
- for ( size_t i=0; i < h->size; i++ ) {
- if ( h->buckets[i] ) {
+ for (size_t i = 0; i < h->size; i++) {
+ if (h->buckets[i]) {
kmp_dephash_entry_t *next;
- for ( kmp_dephash_entry_t *entry = h->buckets[i]; entry; entry = next ) {
+ for (kmp_dephash_entry_t *entry = h->buckets[i]; entry; entry = next) {
next = entry->next_in_bucket;
__kmp_depnode_list_free(thread,entry->last_ins);
__kmp_node_deref(thread,entry->last_out);
@@ -134,8 +135,15 @@ __kmp_dephash_free ( kmp_info_t *thread,
__kmp_thread_free(thread,entry);
#endif
}
+ h->buckets[i] = 0;
}
}
+}
+
+void
+__kmp_dephash_free(kmp_info_t *thread, kmp_dephash_t *h)
+{
+ __kmp_dephash_free_entries(thread, h);
#if USE_FAST_MEMORY
__kmp_fast_free(thread,h);
#else
Modified: openmp/branches/release_39/runtime/src/kmp_tasking.c
URL: http://llvm.org/viewvc/llvm-project/openmp/branches/release_39/runtime/src/kmp_tasking.c?rev=287559&r1=287558&r2=287559&view=diff
==============================================================================
--- openmp/branches/release_39/runtime/src/kmp_tasking.c (original)
+++ openmp/branches/release_39/runtime/src/kmp_tasking.c Mon Nov 21 12:45:39 2016
@@ -852,7 +852,6 @@ __kmp_init_implicit_task( ident_t *loc_r
task->td_flags.freed = 0;
#if OMP_40_ENABLED
- task->td_dephash = NULL;
task->td_depnode = NULL;
#endif
@@ -861,6 +860,7 @@ __kmp_init_implicit_task( ident_t *loc_r
task->td_allocated_child_tasks = 0; // Not used because do not need to deallocate implicit task
#if OMP_40_ENABLED
task->td_taskgroup = NULL; // An implicit task does not have taskgroup
+ task->td_dephash = NULL;
#endif
__kmp_push_current_task_to_thread( this_thr, team, tid );
} else {
@@ -876,6 +876,39 @@ __kmp_init_implicit_task( ident_t *loc_r
tid, team, task ) );
}
+
+//-----------------------------------------------------------------------------
+//// __kmp_finish_implicit_task: Release resources associated to implicit tasks
+//// at the end of parallel regions. Some resources are kept for reuse in the
+//// next parallel region.
+////
+//// thread: thread data structure corresponding to implicit task
+//
+void
+__kmp_finish_implicit_task(kmp_info_t *thread)
+{
+ kmp_taskdata_t *task = thread->th.th_current_task;
+ if (task->td_dephash)
+ __kmp_dephash_free_entries(thread, task->td_dephash);
+}
+
+
+//-----------------------------------------------------------------------------
+//// __kmp_free_implicit_task: Release resources associated to implicit tasks
+//// when these are destroyed regions
+////
+//// thread: thread data structure corresponding to implicit task
+//
+void
+__kmp_free_implicit_task(kmp_info_t *thread)
+{
+ kmp_taskdata_t *task = thread->th.th_current_task;
+ if (task->td_dephash)
+ __kmp_dephash_free(thread, task->td_dephash);
+ task->td_dephash = NULL;
+}
+
+
// Round up a size to a power of two specified by val
// Used to insert padding between structures co-allocated using a single malloc() call
static size_t
More information about the Openmp-commits
mailing list