Compare commits

...
7 Commits
Author SHA1 Message Date
Jonathan Peyton f38e0ce0f1 Merging r285703:
------------------------------------------------------------------------
r285703 | achurbanov | 2016-11-01 11:19:04 -0500 (Tue, 01 Nov 2016) | 9 lines

Fixed problem introduced by part of https://reviews.llvm.org/D21196.

Check Task Scheduling Constraint (TSC) on stealing of untied task.
This is needed because the untied task can produce tied children
those can break TSC if untied is not a descendant of current task.
This can cause live lock on complex tyasking tests
(e.g. kastors/strassen-task-dep).

Differential Revision: https://reviews.llvm.org/D26182
------------------------------------------------------------------------


git-svn-id: https://llvm.org/svn/llvm-project/openmp/branches/release_39@287561 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-21 18:49:41 +00:00
Jonathan Peyton b402abdbbf Merging r287551:
------------------------------------------------------------------------
r287551 | jlpeyton | 2016-11-21 10:18:57 -0600 (Mon, 21 Nov 2016) | 8 lines

Fix for D25504 - segfault because of double free()-ing in shutdown code.

Paul Osmialowski pointed out a double free bug in shutdown code.  This patch
Moves the freeing of the implicit task to above the freeing of all fast memory
to prevent the double-free issue.

Differential Revision: https://reviews.llvm.org/D26860

------------------------------------------------------------------------


git-svn-id: https://llvm.org/svn/llvm-project/openmp/branches/release_39@287560 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-21 18:47:18 +00:00
Jonathan Peyton ae6d028427 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.

------------------------------------------------------------------------


git-svn-id: https://llvm.org/svn/llvm-project/openmp/branches/release_39@287559 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-21 18:45:39 +00:00
Jonathan Peyton 91b0f59656 Merging r280138:
------------------------------------------------------------------------
r280138 | jlpeyton | 2016-08-30 14:28:58 -0500 (Tue, 30 Aug 2016) | 5 lines

Appease older gcc compilers for the many-microtask-args.c test

Older gcc compilers error out with the C99 syntax of: for (int i =...)
so this change just moves the int i; declaration up above.

------------------------------------------------------------------------


git-svn-id: https://llvm.org/svn/llvm-project/openmp/branches/release_39@287558 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-21 18:43:38 +00:00
Jonathan Peyton 05cf7728d5 Merging r278332:
------------------------------------------------------------------------
r278332 | achurbanov | 2016-08-11 08:04:00 -0500 (Thu, 11 Aug 2016) | 3 lines

Fixes for hierarchical barrier (possible hang if team size changed).

Differential Revision: http://reviews.llvm.org/D23175
------------------------------------------------------------------------


git-svn-id: https://llvm.org/svn/llvm-project/openmp/branches/release_39@287557 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-21 18:42:31 +00:00
Hans Wennborg 168b27e91b Merging r278036:
------------------------------------------------------------------------
r278036 | dim | 2016-08-08 11:34:05 -0700 (Mon, 08 Aug 2016) | 18 lines

Fix linking of omp_foreign_thread_team_reuse test on FreeBSD

Summary:
On FreeBSD, linking the misc_bugs/omp_foreign_thread_team_reuse.c test
case fails with:

   /usr/local/bin/ld: /tmp/omp_foreign_thread_team_reuse-c5e71b.o: undefined reference to symbol 'pthread_create@@FBSD_1.0'

This is because the program is linked without `-lpthread`.  Since the
%libomp-compile-and-run macro does not allow that option to be added to
the compile command line, split it up and add the required `-lpthread`
between %libomp-compile and %libomp-run.

Reviewers: jlpeyton, hfinkel, Hahnfeld

Subscribers: Hahnfeld, emaste, openmp-commits

Differential Revision: https://reviews.llvm.org/D23084
------------------------------------------------------------------------


git-svn-id: https://llvm.org/svn/llvm-project/openmp/branches/release_39@278059 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-08 22:11:41 +00:00
Hans Wennborg 82fb5e6198 Creating release_39 branch off revision 275826
git-svn-id: https://llvm.org/svn/llvm-project/openmp/branches/release_39@275839 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-18 17:53:16 +00:00
6 changed files with 85 additions and 17 deletions
+14 -6
View File
@@ -3327,6 +3327,8 @@ extern kmp_task_t* __kmp_task_alloc( ident_t *loc_ref, kmp_int32 gtid,
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 *loc_ref, kmp_int32 gtid, kmp_task_t *tas
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 );
+18
View File
@@ -4848,6 +4848,19 @@ __kmp_allocate_team( kmp_root_t *root, int new_nproc, int max_nproc,
}
#if KMP_NESTED_HOT_TEAMS
} // (__kmp_hot_teams_mode == 0)
else {
// When keeping extra threads in team, switch threads to wait on own b_go flag
for (f=new_nproc; f<team->t.t_nproc; ++f) {
KMP_DEBUG_ASSERT(team->t.t_threads[f]);
kmp_balign_t *balign = team->t.t_threads[f]->th.th_bar;
for (int b=0; b<bs_last_barrier; ++b) {
if (balign[b].bb.wait_flag == KMP_BARRIER_PARENT_FLAG) {
balign[b].bb.wait_flag = KMP_BARRIER_SWITCH_TO_OWN_FLAG;
}
KMP_CHECK_UPDATE(balign[b].bb.leaf_kids, 0);
}
}
}
#endif // KMP_NESTED_HOT_TEAMS
team->t.t_nproc = new_nproc;
// TODO???: team->t.t_max_active_levels = new_max_active_levels;
@@ -5331,6 +5344,7 @@ __kmp_free_thread( kmp_info_t *this_th )
if (balign[b].bb.wait_flag == KMP_BARRIER_PARENT_FLAG)
balign[b].bb.wait_flag = KMP_BARRIER_SWITCH_TO_OWN_FLAG;
balign[b].bb.team = NULL;
balign[b].bb.leaf_kids = 0;
}
this_th->th.th_task_state = 0;
@@ -5674,6 +5688,8 @@ __kmp_reap_thread(
--__kmp_thread_pool_nth;
}; // if
__kmp_free_implicit_task(thread);
// Free the fast memory for tasking
#if USE_FAST_MEMORY
__kmp_free_fast_memory( thread );
@@ -6770,6 +6786,8 @@ __kmp_run_after_invoked_task( int gtid, int tid, kmp_info_t *this_thr,
{
if( __kmp_env_consistency_check )
__kmp_pop_parallel( gtid, team->t.t_ident );
__kmp_finish_implicit_task(this_thr);
}
int
+14 -6
View File
@@ -97,7 +97,8 @@ __kmp_dephash_create ( kmp_info_t *thread, kmp_taskdata_t *current_task )
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 *thread, kmp_taskdata_t *current_task )
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_dephash_t *h )
__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
+36 -3
View File
@@ -852,7 +852,6 @@ __kmp_init_implicit_task( ident_t *loc_ref, kmp_info_t *this_thr, kmp_team_t *te
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_ref, kmp_info_t *this_thr, kmp_team_t *te
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_ref, kmp_info_t *this_thr, kmp_team_t *te
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
@@ -1755,8 +1788,8 @@ __kmp_steal_task( kmp_info_t *victim, kmp_int32 gtid, kmp_task_team_t *task_team
parent = parent->td_parent; // check generation up to the level of the current task
KMP_DEBUG_ASSERT(parent != NULL);
}
if ( parent != current && (taskdata->td_flags.tiedness == TASK_TIED) ) { // untied is always allowed to be stolen
// If the tail task is not a child, then no other childs can appear in the deque (?).
if ( parent != current ) {
// If the tail task is not a descendant of the current task then do not steal it.
__kmp_release_bootstrap_lock( & victim_td -> td.td_deque_lock );
KA_TRACE(10, ("__kmp_steal_task(exit #2): T#%d could not steal from T#%d: task_team=%p "
"ntasks=%d head=%u tail=%u\n",
+2 -1
View File
@@ -4,6 +4,7 @@
int main()
{
int i;
int i1 = 0;
int i2 = 1;
int i3 = 2;
@@ -23,7 +24,7 @@ int main()
int r = 0;
#pragma omp parallel for firstprivate(i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16) reduction(+:r)
for (int i = 0; i < i16; i++) {
for (i = 0; i < i16; i++) {
r += i + i1 + i2 + i3 + i4 + i5 + i6 + i7 + i8 + i9 + i10 + i11 + i12 + i13 + i14 + i15 + i16;
}
@@ -1,4 +1,4 @@
// RUN: %libomp-compile-and-run
// RUN: %libomp-compile -lpthread && %libomp-run
#include <stdio.h>
#include "omp_testsuite.h"