OSDN Git Service

* acinclude.m4 (LIBGOMP_CHECK_SYNC_BUILTINS): Remove set but
[pf3gnuchains/gcc-fork.git] / libgomp / task.c
index 903948c..95f163d 100644 (file)
@@ -1,29 +1,26 @@
-/* Copyright (C) 2007, 2008 Free Software Foundation, Inc.
+/* Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
    Contributed by Richard Henderson <rth@redhat.com>.
 
    This file is part of the GNU OpenMP Library (libgomp).
 
    Libgomp is free software; you can redistribute it and/or modify it
-   under the terms of the GNU Lesser General Public License as published by
-   the Free Software Foundation; either version 2.1 of the License, or
-   (at your option) any later version.
+   under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
 
    Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-   FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
+   FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
    more details.
 
-   You should have received a copy of the GNU Lesser General Public License 
-   along with libgomp; see the file COPYING.LIB.  If not, write to the
-   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-   MA 02110-1301, USA.  */
+   Under Section 7 of GPL version 3, you are granted additional
+   permissions described in the GCC Runtime Library Exception, version
+   3.1, as published by the Free Software Foundation.
 
-/* As a special exception, if you link this library with other files, some
-   of which are compiled with GCC, to produce an executable, this library
-   does not by itself cause the resulting executable to be covered by the
-   GNU General Public License.  This exception does not however invalidate
-   any other reasons why the executable file might be covered by the GNU
-   General Public License.  */
+   You should have received a copy of the GNU General Public License and
+   a copy of the GCC Runtime Library Exception along with this program;
+   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+   <http://www.gnu.org/licenses/>.  */
 
 /* This file handles the maintainence of tasks in response to task
    creation and termination.  */
@@ -43,6 +40,7 @@ gomp_init_task (struct gomp_task *task, struct gomp_task *parent_task,
   task->icv = *prev_icv;
   task->kind = GOMP_TASK_IMPLICIT;
   task->in_taskwait = false;
+  task->in_tied_task = false;
   task->children = NULL;
   gomp_sem_init (&task->taskwait_sem, 0);
 }
@@ -103,6 +101,8 @@ GOMP_task (void (*fn) (void *), void *data, void (*cpyfn) (void *, void *),
 
       gomp_init_task (&task, thr->task, gomp_icv (false));
       task.kind = GOMP_TASK_IFFALSE;
+      if (thr->task)
+       task.in_tied_task = thr->task->in_tied_task;
       thr->task = &task;
       if (__builtin_expect (cpyfn != NULL, 0))
        {
@@ -134,6 +134,7 @@ GOMP_task (void (*fn) (void *), void *data, void (*cpyfn) (void *, void *),
                      & ~(uintptr_t) (arg_align - 1));
       gomp_init_task (task, parent, gomp_icv (false));
       task->kind = GOMP_TASK_IFFALSE;
+      task->in_tied_task = parent->in_tied_task;
       thr->task = task;
       if (cpyfn)
        cpyfn (arg, data);
@@ -143,6 +144,7 @@ GOMP_task (void (*fn) (void *), void *data, void (*cpyfn) (void *, void *),
       task->kind = GOMP_TASK_WAITING;
       task->fn = fn;
       task->fn_data = arg;
+      task->in_tied_task = true;
       gomp_mutex_lock (&team->task_lock);
       if (parent->children)
        {
@@ -170,9 +172,10 @@ GOMP_task (void (*fn) (void *), void *data, void (*cpyfn) (void *, void *),
          task->prev_queue = task;
          team->task_queue = task;
        }
-      if (team->task_count++ == 0)
-       gomp_team_barrier_set_task_pending (&team->barrier);
-      do_wake = team->task_running_count < team->nthreads;
+      ++team->task_count;
+      gomp_team_barrier_set_task_pending (&team->barrier);
+      do_wake = team->task_running_count + !parent->in_tied_task
+               < team->nthreads;
       gomp_mutex_unlock (&team->task_lock);
       if (do_wake)
        gomp_team_barrier_wake (&team->barrier, 1);