From patchwork Tue Oct 27 22:15:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 537104 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 DAAD314136F for ; Wed, 28 Oct 2015 09:15:25 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=HTL8fK4y; 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=NZtZxdBuEzfgv4ew9 2HPMGuTOzFFF6q4em3qwdN1LecU0sIM2wl1jpWw9oB9zjhbeOmqiTdGOmm+ZAVVP Gp5mgSqnsVLJ6h62XVl8Q6tYAl3FSHkeewTijV9mKFGQrOL0a4RjjjldAb3knAE2 lSADZq+eqTOaEUmoySnLUtn8EY= 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=4Mnmj5V3LhpA8xkLb1XyR/0 RFNo=; b=HTL8fK4yMN7JP+d7q0Pf5xJEB5lV9HWvqD0WNyUmWhpajS3jZsFxt49 2XqCtsMRRAm3B7YziRCTAFJBdJaAkOwmy9M6iJBYe07wXs7U9mU4MYmJb+FARh92 IOEEdThq1oeUfHe0QKixyHahwhSwAmd+odSgkBtoI3jTV2NcNwkc= Received: (qmail 38542 invoked by alias); 27 Oct 2015 22:15:17 -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 38528 invoked by uid 89); 27 Oct 2015 22:15:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.9 required=5.0 tests=BAYES_50, FREEMAIL_FROM, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-pa0-f52.google.com Received: from mail-pa0-f52.google.com (HELO mail-pa0-f52.google.com) (209.85.220.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 27 Oct 2015 22:15:15 +0000 Received: by pabla5 with SMTP id la5so41556712pab.0 for ; Tue, 27 Oct 2015 15:15:13 -0700 (PDT) X-Received: by 10.68.228.200 with SMTP id sk8mr31289203pbc.115.1445984113435; Tue, 27 Oct 2015 15:15:13 -0700 (PDT) Received: from ?IPv6:2600:1012:b115:101e:a2a8:cdff:fe3e:b48? ([2600:1012:b115:101e:a2a8:cdff:fe3e:b48]) by smtp.googlemail.com with ESMTPSA id im9sm41469837pbc.1.2015.10.27.15.15.11 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Oct 2015 15:15:12 -0700 (PDT) Subject: Re: [OpenACC 3/11] new target hook To: Jakub Jelinek References: <5627DD78.9040302@acm.org> <5627E3D6.5080100@acm.org> <20151022081558.GE478@tucnak.redhat.com> Cc: GCC Patches , Bernd Schmidt , Jason Merrill , "Joseph S. Myers" From: Nathan Sidwell Message-ID: <562FF76F.4020404@acm.org> Date: Tue, 27 Oct 2015 15:15:11 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <20151022081558.GE478@tucnak.redhat.com> On 10/22/15 01:15, Jakub Jelinek wrote: > On Wed, Oct 21, 2015 at 03:13:26PM -0400, Nathan Sidwell wrote: >> 2015-10-20 Nathan Sidwell >> >> * target.def (fork_join): New GOACC hook. >> * targhooks.h (default_goacc_fork_join): Declare. >> * omp-low.c (default_goacc_forkjoin): New. >> * doc/tm.texi.in (TARGET_GOACC_FORK_JOIN): Add. >> * doc/tm.texi: Regenerate. >> * config/nvptx/nvptx.c (nvptx_xform_fork_join): New. >> (TARGET_GOACC_FOR_JOIN): Override. this is what I've committed. Other than nits, the changes are 1) use targetm.have_... rather than #ifdef HAVE_... 2) don't include the nvptx hunk. I'll apply that with the nvptx bits to turn all this stuff on. nathan 2015-10-27 Nathan Sidwell * target-insns.def (oacc_fork, oacc_join): Define. * target.def (goacc.validate_dims): Adjust doc to avoid warning. (goacc.fork_join): New GOACC hook. * targhooks.h (default_goacc_fork_join): Declare. * omp-low.c (default_goacc_forkjoin): New. * doc/tm.texi.in (TARGET_GOACC_FORK_JOIN): Add. * doc/tm.texi: Regenerate. Index: gcc/doc/tm.texi =================================================================== --- gcc/doc/tm.texi (revision 229447) +++ gcc/doc/tm.texi (working copy) @@ -5754,7 +5754,7 @@ usable. In that case, the smaller the n to use it. @end deftypefn -@deftypefn {Target Hook} bool TARGET_GOACC_VALIDATE_DIMS (tree @var{decl}, int @var{dims[]}, int @var{fn_level}) +@deftypefn {Target Hook} bool TARGET_GOACC_VALIDATE_DIMS (tree @var{decl}, int *@var{dims}, int @var{fn_level}) This hook should check the launch dimensions provided for an OpenACC compute region, or routine. Defaulted values are represented as -1 and non-constant values as 0. The @var{fn_level} is negative for the @@ -5766,6 +5766,14 @@ true, if changes have been made. You mu provide dimensions larger than 1. @end deftypefn +@deftypefn {Target Hook} bool TARGET_GOACC_FORK_JOIN (gcall *@var{call}, const int *@var{dims}, bool @var{is_fork}) +This hook should convert IFN_GOACC_FORK and IFN_GOACC_JOIN function +calls to target-specific gimple. It is executed during the +oacc_device_lower pass. It should return true, if the functions +should be deleted. The default hook returns true, if there are no +RTL expanders for them. +@end deftypefn + @node Anchored Addresses @section Anchored Addresses @cindex anchored addresses Index: gcc/doc/tm.texi.in =================================================================== --- gcc/doc/tm.texi.in (revision 229447) +++ gcc/doc/tm.texi.in (working copy) @@ -4251,6 +4251,8 @@ address; but often a machine-dependent @hook TARGET_GOACC_VALIDATE_DIMS +@hook TARGET_GOACC_FORK_JOIN + @node Anchored Addresses @section Anchored Addresses @cindex anchored addresses Index: gcc/omp-low.c =================================================================== --- gcc/omp-low.c (revision 229462) +++ gcc/omp-low.c (working copy) @@ -17571,6 +17642,19 @@ oacc_validate_dims (tree fn, tree attrs, return fn_level; } +/* Default fork/join early expander. Delete the function calls if + there is no RTL expander. */ + +bool +default_goacc_fork_join (gcall *ARG_UNUSED (call), + const int *ARG_UNUSED (dims), bool is_fork) +{ + if (is_fork) + return targetm.have_oacc_fork (); + else + return targetm.have_oacc_join (); +} + /* Main entry point for oacc transformations which run on the device compiler after LTO, so we know what the target device is at this point (including the host fallback). */ Index: gcc/target-insns.def =================================================================== --- gcc/target-insns.def (revision 229459) +++ gcc/target-insns.def (working copy) @@ -64,6 +64,8 @@ DEF_TARGET_INSN (memory_barrier, (void)) DEF_TARGET_INSN (movstr, (rtx x0, rtx x1, rtx x2)) DEF_TARGET_INSN (nonlocal_goto, (rtx x0, rtx x1, rtx x2, rtx x3)) DEF_TARGET_INSN (nonlocal_goto_receiver, (void)) +DEF_TARGET_INSN (oacc_fork, (rtx x0, rtx x1, rtx x2)) +DEF_TARGET_INSN (oacc_join, (rtx x0, rtx x1, rtx x2)) DEF_TARGET_INSN (prefetch, (rtx x0, rtx x1, rtx x2)) DEF_TARGET_INSN (probe_stack, (rtx x0)) DEF_TARGET_INSN (probe_stack_address, (rtx x0)) Index: gcc/target.def =================================================================== --- gcc/target.def (revision 229447) +++ gcc/target.def (working copy) @@ -1655,9 +1655,19 @@ should fill in anything that needs to de non-defaults. Diagnostics should be issued as appropriate. Return\n\ true, if changes have been made. You must override this hook to\n\ provide dimensions larger than 1.", -bool, (tree decl, int dims[], int fn_level), +bool, (tree decl, int *dims, int fn_level), default_goacc_validate_dims) +DEFHOOK +(fork_join, +"This hook should convert IFN_GOACC_FORK and IFN_GOACC_JOIN function\n\ +calls to target-specific gimple. It is executed during the\n\ +oacc_device_lower pass. It should return true, if the functions\n\ +should be deleted. The default hook returns true, if there are no\n\ +RTL expanders for them.", +bool, (gcall *call, const int *dims, bool is_fork), +default_goacc_fork_join) + HOOK_VECTOR_END (goacc) /* Functions relating to vectorization. */ Index: gcc/targhooks.h =================================================================== --- gcc/targhooks.h (revision 229447) +++ gcc/targhooks.h (working copy) @@ -110,6 +110,7 @@ extern void default_destroy_cost_data (v /* OpenACC hooks. */ extern bool default_goacc_validate_dims (tree, int [], int); +extern bool default_goacc_fork_join (gcall *, const int [], bool); /* These are here, and not in hooks.[ch], because not all users of hooks.h include tm.h, and thus we don't have CUMULATIVE_ARGS. */