diff options
| author | Vladimir Makarov <vmakarov@gcc.gnu.org> | 2019-12-12 20:46:39 +0000 |
|---|---|---|
| committer | Vladimir Makarov <vmakarov@gcc.gnu.org> | 2019-12-12 20:46:39 +0000 |
| commit | 3a8c69ecd95f708f5d489d92ff12dfbe2a93b00b (patch) | |
| tree | 1596316424f3ab3df4c378a866d87ddca07e342f /libgomp/parallel.c | |
| parent | 3fceb4462a7484503f3048a2c402e7996c72cc7c (diff) | |
| parent | bdaf8be1b2e3514b8bbcdd1042136e7d91b3c3f3 (diff) | |
Merged latest trunk changes to ira-select.devel/ira-select
From-SVN: r279316
Diffstat (limited to 'libgomp/parallel.c')
| -rw-r--r-- | libgomp/parallel.c | 53 |
1 files changed, 43 insertions, 10 deletions
diff --git a/libgomp/parallel.c b/libgomp/parallel.c index 803e8b770c8..7173883b2c1 100644 --- a/libgomp/parallel.c +++ b/libgomp/parallel.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2005-2018 Free Software Foundation, Inc. +/* Copyright (C) 2005-2019 Free Software Foundation, Inc. Contributed by Richard Henderson <rth@redhat.com>. This file is part of the GNU Offloading and Multi Processing Library @@ -123,7 +123,8 @@ void GOMP_parallel_start (void (*fn) (void *), void *data, unsigned num_threads) { num_threads = gomp_resolve_num_threads (num_threads, 0); - gomp_team_start (fn, data, num_threads, 0, gomp_new_team (num_threads)); + gomp_team_start (fn, data, num_threads, 0, gomp_new_team (num_threads), + NULL); } void @@ -161,14 +162,33 @@ GOMP_parallel_end (void) ialias (GOMP_parallel_end) void -GOMP_parallel (void (*fn) (void *), void *data, unsigned num_threads, unsigned int flags) +GOMP_parallel (void (*fn) (void *), void *data, unsigned num_threads, + unsigned int flags) { num_threads = gomp_resolve_num_threads (num_threads, 0); - gomp_team_start (fn, data, num_threads, flags, gomp_new_team (num_threads)); + gomp_team_start (fn, data, num_threads, flags, gomp_new_team (num_threads), + NULL); fn (data); ialias_call (GOMP_parallel_end) (); } +unsigned +GOMP_parallel_reductions (void (*fn) (void *), void *data, + unsigned num_threads, unsigned int flags) +{ + struct gomp_taskgroup *taskgroup; + num_threads = gomp_resolve_num_threads (num_threads, 0); + uintptr_t *rdata = *(uintptr_t **)data; + taskgroup = gomp_parallel_reduction_register (rdata, num_threads); + gomp_team_start (fn, data, num_threads, flags, gomp_new_team (num_threads), + taskgroup); + fn (data); + ialias_call (GOMP_parallel_end) (); + gomp_sem_destroy (&taskgroup->taskgroup_sem); + free (taskgroup); + return num_threads; +} + bool GOMP_cancellation_point (int which) { @@ -185,8 +205,15 @@ GOMP_cancellation_point (int which) } else if (which & GOMP_CANCEL_TASKGROUP) { - if (thr->task->taskgroup && thr->task->taskgroup->cancelled) - return true; + if (thr->task->taskgroup) + { + if (thr->task->taskgroup->cancelled) + return true; + if (thr->task->taskgroup->workshare + && thr->task->taskgroup->prev + && thr->task->taskgroup->prev->cancelled) + return true; + } /* FALLTHRU into the GOMP_CANCEL_PARALLEL case, as #pragma omp cancel parallel also cancels all explicit tasks. */ @@ -218,11 +245,17 @@ GOMP_cancel (int which, bool do_cancel) } else if (which & GOMP_CANCEL_TASKGROUP) { - if (thr->task->taskgroup && !thr->task->taskgroup->cancelled) + if (thr->task->taskgroup) { - gomp_mutex_lock (&team->task_lock); - thr->task->taskgroup->cancelled = true; - gomp_mutex_unlock (&team->task_lock); + struct gomp_taskgroup *taskgroup = thr->task->taskgroup; + if (taskgroup->workshare && taskgroup->prev) + taskgroup = taskgroup->prev; + if (!taskgroup->cancelled) + { + gomp_mutex_lock (&team->task_lock); + taskgroup->cancelled = true; + gomp_mutex_unlock (&team->task_lock); + } } return true; } |
