From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16236 invoked by alias); 6 Aug 2015 08:45:24 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 16227 invoked by uid 89); 6 Aug 2015 08:45:23 -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-wi0-f175.google.com Received: from mail-wi0-f175.google.com (HELO mail-wi0-f175.google.com) (209.85.212.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 06 Aug 2015 08:45:22 +0000 Received: by wibxm9 with SMTP id xm9so14082752wib.1 for ; Thu, 06 Aug 2015 01:45:19 -0700 (PDT) X-Received: by 10.194.57.232 with SMTP id l8mr1263514wjq.48.1438850719243; Thu, 06 Aug 2015 01:45:19 -0700 (PDT) Received: from [192.168.10.82] (11.52.broadband16.iol.cz. [90.183.52.11]) by smtp.googlemail.com with ESMTPSA id nb9sm2090261wic.10.2015.08.06.01.45.18 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Aug 2015 01:45:18 -0700 (PDT) To: GCC Patches From: Nathan Sidwell Subject: [gomp4] fork/join target hook Message-ID: <55C31E9D.3060403@acm.org> Date: Thu, 06 Aug 2015 08:45:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------060902020302030609010005" X-SW-Source: 2015-08/txt/msg00328.txt.bz2 This is a multi-part message in MIME format. --------------060902020302030609010005 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 248 I realized other targets might need to do different things with the openacc fork and join buitins. I created a new target hook and default implementation. The default deletes the internal functions if there is no RTL expander for them. nathan --------------060902020302030609010005 Content-Type: text/x-patch; name="fork-join.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="fork-join.patch" Content-length: 5884 2015-08-06 Nathan Sidwell * doc/tm.texi.in (TARGET_GOACC_FORK_JOIN): New. * doc/tm.texi: Regenerate. * omp-low.c (execute_oacc_transform): Forward fork and join to target hook. (default_goacc_fork_join): New. * target.def (fork_join): New OpenACC hook. * targhooks.h (default_goacc_fork_join): Declare. Index: doc/tm.texi =================================================================== --- doc/tm.texi (revision 226665) +++ doc/tm.texi (working copy) @@ -5741,11 +5741,18 @@ to use it. @end deftypefn @deftypefn {Target Hook} tree TARGET_GOACC_VALIDATE_DIMS (tree, @var{tree}) -This hook should check the launch dimensions provided/ It should fill +This hook should check the launch dimensions provided. It should fill in default values and verify non-defaults. The TREE_LIST is unshared and may be overwritten. Diagnostics should be issued as appropriate. @end deftypefn +@deftypefn {Target Hook} bool TARGET_GOACC_FORK_JOIN (bool, gimple_stmt_iterator *@var{}, @var{gimple}) +This hook should convert IFN_GOACC_FORK and IFN_GOACC_JOIN function +calls to target-specific gimple. It is executed during the oacc_xform +pass. It should return true, if the functions should be deleted. The +default hook returns true, if there is no RTL expanders for them. +@end deftypefn + @node Anchored Addresses @section Anchored Addresses @cindex anchored addresses Index: doc/tm.texi.in =================================================================== --- doc/tm.texi.in (revision 226665) +++ doc/tm.texi.in (working copy) @@ -4247,6 +4247,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: omp-low.c =================================================================== --- omp-low.c (revision 226665) +++ omp-low.c (working copy) @@ -14638,30 +14638,35 @@ execute_oacc_transform () oacc_xform_on_device (&gsi, stmt); if (gimple_call_internal_p (stmt)) - switch (gimple_call_internal_fn (stmt)) - { - default: break; - - case IFN_GOACC_DIM_SIZE: - if (dims) - oacc_xform_dim (&gsi, stmt, dims, false); - break; - - case IFN_GOACC_DIM_POS: - if (dims) - oacc_xform_dim (&gsi, stmt, dims, true); - break; - -#ifndef ACCEL_COMPILER - case IFN_GOACC_FORK: - case IFN_GOACC_JOIN: - /* These are irrelevant on the host. */ - replace_uses_by (gimple_vdef (stmt), gimple_vuse (stmt)); - gsi_remove (&gsi, true); - /* Removal will have advanced the iterator. */ - continue; -#endif - } + { + unsigned ifn_code = gimple_call_internal_fn (stmt); + switch (ifn_code) + { + default: break; + + case IFN_GOACC_DIM_SIZE: + if (dims) + oacc_xform_dim (&gsi, stmt, dims, false); + break; + + case IFN_GOACC_DIM_POS: + if (dims) + oacc_xform_dim (&gsi, stmt, dims, true); + break; + + case IFN_GOACC_FORK: + case IFN_GOACC_JOIN: + if (targetm.goacc.fork_join + (ifn_code == IFN_GOACC_FORK, &gsi, stmt)) + { + replace_uses_by (gimple_vdef (stmt), + gimple_vuse (stmt)); + gsi_remove (&gsi, true); + /* Removal will have advanced the iterator. */ + continue; + } + } + } } gsi_next (&gsi); } @@ -14670,7 +14675,8 @@ execute_oacc_transform () return 0; } -/* Default launch dimension validator. */ +/* Default launch dimension validator. Force everything to 1 on the + host and default to 1 otherwise. */ tree default_goacc_validate_dims (tree ARG_UNUSED (decl), tree dims) @@ -14693,6 +14699,30 @@ default_goacc_validate_dims (tree ARG_UN return dims; } +/* Default fork/join early expander. Delete the function calls if + there is no RTL expander. */ + +bool +default_goacc_fork_join (bool is_fork, gimple_stmt_iterator *ARG_UNUSED (gsi), + gimple ARG_UNUSED (stmt)) +{ + if (is_fork) + { +#ifdef HAVE_oacc_fork + return false; +#endif + } + else + { +#ifdef HAVE_oacc_join + return false; +#endif + } + + /* We have no expander, so delete the functions now. */ + return true; +} + namespace { const pass_data pass_data_oacc_transform = Index: target.def =================================================================== --- target.def (revision 226665) +++ target.def (working copy) @@ -1646,12 +1646,21 @@ HOOK_VECTOR (TARGET_GOACC, goacc) DEFHOOK (validate_dims, -"This hook should check the launch dimensions provided/ It should fill\n\ +"This hook should check the launch dimensions provided. It should fill\n\ in default values and verify non-defaults. The TREE_LIST is unshared\n\ and may be overwritten. Diagnostics should be issued as appropriate.", tree, (tree, tree), 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 oacc_xform\n\ +pass. It should return true, if the functions should be deleted. The\n\ +default hook returns true, if there is no RTL expanders for them.", +bool, (bool, gimple_stmt_iterator *, gimple), +default_goacc_fork_join) + HOOK_VECTOR_END (goacc) /* Functions relating to vectorization. */ Index: targhooks.h =================================================================== --- targhooks.h (revision 226665) +++ targhooks.h (working copy) @@ -108,6 +108,7 @@ extern void default_finish_cost (void *, extern void default_destroy_cost_data (void *); extern tree default_goacc_validate_dims (tree, tree); +extern bool default_goacc_fork_join (bool, gimple_stmt_iterator *, gimple); /* 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. */ --------------060902020302030609010005--