From patchwork Thu Aug 27 14:55:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 511323 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B04E1401EF for ; Fri, 28 Aug 2015 00:55:56 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=T023M3R3; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=cVcp6jd5S16jWE/LQ LYdK7Tb5frKcRTLOWLapxwLAw1Kt3ULuxzug8RV5vUVoQWppcRDb0TJ0LyO5uYEN JEgMXvmgjZmesYlQq26eTcsGuLAWyNdMueS19Q102if3HTH8NAipZ0V/buEPAiw4 0Vo5Lq+sXmxXEVS5tfdgG9vSe8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=zSQVAmFTqStvMTj4LVFtjmD v6Pw=; b=T023M3R37Ap62APlTm1lnd3wG82YFGEbWSbFM2qD2I4sZJRMyypFnEg /LVS9xgQ/S9p1DWGL6U/BiGeWUWnGyfc0F0WpzsE2yWI8EGKTydE1Pf6U9qQajoX zJ6Kz2Iu3Reh9r5Suktc25uGBSg54h3PhzDvf5soa80p4pbWwvAk= Received: (qmail 27136 invoked by alias); 27 Aug 2015 14:55:48 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 27119 invoked by uid 89); 27 Aug 2015 14:55:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-6.2 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 27 Aug 2015 14:55:43 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 96FF8373F33 for ; Thu, 27 Aug 2015 14:55:41 +0000 (UTC) Received: from reynosa.quesejoda.com (vpn-55-128.rdu2.redhat.com [10.10.55.128]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t7REteKo019581; Thu, 27 Aug 2015 10:55:40 -0400 Subject: Re: [gomp4.1] document more things To: Jakub Jelinek References: <55DF184C.5070209@redhat.com> <20150827141426.GG9425@tucnak.redhat.com> Cc: gcc-patches From: Aldy Hernandez Message-ID: <55DF24EB.5090605@redhat.com> Date: Thu, 27 Aug 2015 07:55:39 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <20150827141426.GG9425@tucnak.redhat.com> On 08/27/2015 07:14 AM, Jakub Jelinek wrote: > On Thu, Aug 27, 2015 at 07:01:48AM -0700, Aldy Hernandez wrote: >> commit 45fdbc84123fefde6bf99aaf87099317aaa38f24 >> Author: Aldy Hernandez >> Date: Wed Aug 26 07:28:39 2015 -0700 >> >> * libgomp.h (enum gomp_task_kind): Comment fields. >> (struct gomp_task): Comment some fields. >> * task.c (GOMP_task): Add comments. >> (gomp_task_run_pre): Same. >> >> diff --git a/libgomp/libgomp.h b/libgomp/libgomp.h >> index 3d705ef..34f064c 100644 >> --- a/libgomp/libgomp.h >> +++ b/libgomp/libgomp.h >> @@ -263,9 +263,13 @@ extern char *goacc_device_type; >> >> enum gomp_task_kind >> { >> + /* Thread not directly created by user. For instance, when creating >> + a team of threads or an ICV. */ > > That is misleading, especially with the (possibly) upcoming thread task. > "implicit task" is an OpenMP tasking term: Ah, fixed. > "A task generated by an implicit parallel region or generated when a parallel > construct is encountered during execution." > but there is really no reason to explain what it is, so you should just say > in the comment > /* Implicit task. */ > >> GOMP_TASK_IMPLICIT, >> GOMP_TASK_IFFALSE, > > This is for if (0) tasks. The right OpenMP tasking term is "undeferred > task", perhaps we should just replace GOMP_TASK_IFFALSE with > GOMP_TASK_UNDEFERRED everywhere. Done. > >> + /* Task created by GOMP_task and waiting to be run. */ >> GOMP_TASK_WAITING, >> + /* Task currently scheduled and about to execute. */ > > Well, not just about to execute, that kind is used even for the task that is > already executing. Fixed. > > Otherwise LGTM. Committed. commit 862e81ee2d71f33eb09041061d3b1db1671495f8 Author: Aldy Hernandez Date: Wed Aug 26 07:28:39 2015 -0700 * libgomp.h (enum gomp_task_kind): Comment fields. (struct gomp_task): Comment some fields. * task.c (GOMP_task): Add comments. Rename GOMP_TASK_IFFALSE to GOMP_TASK_UNDEFERRED. (gomp_task_run_pre): Add comments. (GOMP_taskgroup_start): Rename GOMP_TASK_IFFALSE to GOMP_TASK_UNDEFERRED. * taskloop.c (GOMP_taskloop): Same. diff --git a/libgomp/libgomp.h b/libgomp/libgomp.h index 3d705ef..f855813 100644 --- a/libgomp/libgomp.h +++ b/libgomp/libgomp.h @@ -263,9 +263,13 @@ extern char *goacc_device_type; enum gomp_task_kind { + /* Implicit task. */ GOMP_TASK_IMPLICIT, - GOMP_TASK_IFFALSE, + /* Undeferred task. */ + GOMP_TASK_UNDEFERRED, + /* Task created by GOMP_task and waiting to be run. */ GOMP_TASK_WAITING, + /* Task currently executing or scheduled and about to execute. */ GOMP_TASK_TIED }; @@ -313,8 +317,11 @@ struct gomp_task struct gomp_task *prev_child; struct gomp_task *next_queue; struct gomp_task *prev_queue; + /* Next task in the current taskgroup. */ struct gomp_task *next_taskgroup; + /* Previous task in the current taskgroup. */ struct gomp_task *prev_taskgroup; + /* Taskgroup this task belongs in. */ struct gomp_taskgroup *taskgroup; struct gomp_dependers_vec *dependers; struct htab *depend_hash; diff --git a/libgomp/task.c b/libgomp/task.c index 009a9f8..aa7ae4d 100644 --- a/libgomp/task.c +++ b/libgomp/task.c @@ -165,7 +165,7 @@ GOMP_task (void (*fn) (void *), void *data, void (*cpyfn) (void *, void *), gomp_task_maybe_wait_for_dependencies (depend); gomp_init_task (&task, thr->task, gomp_icv (false)); - task.kind = GOMP_TASK_IFFALSE; + task.kind = GOMP_TASK_UNDEFERRED; task.final_task = (thr->task && thr->task->final_task) || (flags & GOMP_TASK_FLAG_FINAL); if (thr->task) @@ -218,7 +218,7 @@ GOMP_task (void (*fn) (void *), void *data, void (*cpyfn) (void *, void *), arg = (char *) (((uintptr_t) (task + 1) + depend_size + arg_align - 1) & ~(uintptr_t) (arg_align - 1)); gomp_init_task (task, parent, gomp_icv (false)); - task->kind = GOMP_TASK_IFFALSE; + task->kind = GOMP_TASK_UNDEFERRED; task->in_tied_task = parent->in_tied_task; task->taskgroup = taskgroup; thr->task = task; @@ -388,6 +388,7 @@ GOMP_task (void (*fn) (void *), void *data, void (*cpyfn) (void *, void *), parent->children = task; if (taskgroup) { + /* If applicable, place task into its taskgroup. */ if (taskgroup->children) { task->next_taskgroup = taskgroup->children; @@ -451,7 +452,14 @@ gomp_task_run_pre (struct gomp_task *child_task, struct gomp_task *parent, { if (parent) { - /* Remove child_task from parent. */ + /* Adjust children such that it will point to a next child, + while the current one is scheduled to be executed. This way, + GOMP_taskwait (and others) can schedule a next task while + waiting. + + Do not remove it entirely from the circular list, as it is + still a child, though not one we should consider first (say + by GOMP_taskwait). */ if (parent->children == child_task) parent->children = child_task->next_child; @@ -465,10 +473,14 @@ gomp_task_run_pre (struct gomp_task *child_task, struct gomp_task *parent, parent->taskwait->last_parent_depends_on = NULL; } } - /* Remove child_task from taskgroup. */ + + /* Adjust taskgroup to point to the next taskgroup. See note above + regarding adjustment of children as to why the child_task is not + removed entirely from the circular list. */ if (taskgroup && taskgroup->children == child_task) taskgroup->children = child_task->next_taskgroup; + /* Remove child_task from the task_queue. */ child_task->prev_queue->next_queue = child_task->next_queue; child_task->next_queue->prev_queue = child_task->prev_queue; if (team->task_queue == child_task) @@ -479,6 +491,7 @@ gomp_task_run_pre (struct gomp_task *child_task, struct gomp_task *parent, team->task_queue = NULL; } child_task->kind = GOMP_TASK_TIED; + if (--team->task_queued_count == 0) gomp_team_barrier_clear_task_pending (&team->barrier); if ((gomp_team_barrier_cancelled (&team->barrier) @@ -1137,7 +1150,7 @@ GOMP_taskgroup_start (void) struct gomp_taskgroup *taskgroup; /* If team is NULL, all tasks are executed as - GOMP_TASK_IFFALSE tasks and thus all children tasks of + GOMP_TASK_UNDEFERRED tasks and thus all children tasks of taskgroup and their descendant tasks will be finished by the time GOMP_taskgroup_end is called. */ if (team == NULL) diff --git a/libgomp/taskloop.c b/libgomp/taskloop.c index 1a2b85d..f57a5a1 100644 --- a/libgomp/taskloop.c +++ b/libgomp/taskloop.c @@ -175,7 +175,7 @@ GOMP_taskloop (void (*fn) (void *), void *data, void (*cpyfn) (void *, void *), for (i = 0; i < num_tasks; i++) { gomp_init_task (&task[i], parent, gomp_icv (false)); - task[i].kind = GOMP_TASK_IFFALSE; + task[i].kind = GOMP_TASK_UNDEFERRED; task[i].final_task = (thr->task && thr->task->final_task) || (flags & GOMP_TASK_FLAG_FINAL); if (thr->task) @@ -213,7 +213,7 @@ GOMP_taskloop (void (*fn) (void *), void *data, void (*cpyfn) (void *, void *), struct gomp_task task; gomp_init_task (&task, thr->task, gomp_icv (false)); - task.kind = GOMP_TASK_IFFALSE; + task.kind = GOMP_TASK_UNDEFERRED; task.final_task = (thr->task && thr->task->final_task) || (flags & GOMP_TASK_FLAG_FINAL); if (thr->task) @@ -254,7 +254,7 @@ GOMP_taskloop (void (*fn) (void *), void *data, void (*cpyfn) (void *, void *), arg = (char *) (((uintptr_t) (task + 1) + arg_align - 1) & ~(uintptr_t) (arg_align - 1)); gomp_init_task (task, parent, gomp_icv (false)); - task->kind = GOMP_TASK_IFFALSE; + task->kind = GOMP_TASK_UNDEFERRED; task->in_tied_task = parent->in_tied_task; task->taskgroup = taskgroup; thr->task = task;