From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4759 invoked by alias); 18 Oct 2005 07:01:47 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 4737 invoked by uid 22791); 18 Oct 2005 07:01:42 -0000 Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Tue, 18 Oct 2005 07:01:42 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.11) with ESMTP id j9I71e8j019667; Tue, 18 Oct 2005 03:01:40 -0400 Received: from devserv.devel.redhat.com (devserv.devel.redhat.com [172.16.58.1]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id j9I71eV26412; Tue, 18 Oct 2005 03:01:40 -0400 Received: from devserv.devel.redhat.com (localhost.localdomain [127.0.0.1]) by devserv.devel.redhat.com (8.12.11/8.12.11) with ESMTP id j9I71exd032638; Tue, 18 Oct 2005 03:01:40 -0400 Received: (from jakub@localhost) by devserv.devel.redhat.com (8.12.11/8.12.11/Submit) id j9I71e5v032636; Tue, 18 Oct 2005 03:01:40 -0400 Date: Tue, 18 Oct 2005 07:01:00 -0000 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org, fortran@gcc.gnu.org Subject: [gomp] Add langhook, so that Fortran can privatize variables by reference Message-ID: <20051018070140.GB16034@devserv.devel.redhat.com> Reply-To: Jakub Jelinek Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.1i X-SW-Source: 2005-10/txt/msg01029.txt.bz2 Hi! >From my testing so far, all Fortran user vars that have POINTER_TYPE type (in addition to the already handled REFERENCE_TYPE) are supposed to be privatized with the type they point to rather than just as a pointer type (Fortran POINTER, ALLOCATABLE and from what I saw, also Cray pointers in the patch that is floating around, use either an aggregate type or a simple INTEGER_TYPE). Fixes reference2.f90 (and some tests in openmpbench_F_v2, though there are still unrelated problems), approved privately by Richard, committed. 2005-10-18 Jakub Jelinek * langhooks.h (struct lang_hooks_for_decls): Add omp_privatize_by_reference hook. * langhooks-def.h (lhd_omp_privatize_by_reference): New prototype. (LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE): Define. (LANG_HOOKS_DECLS): Add LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE. * langhooks.c (lhd_omp_privatize_by_reference): New function. * omp-low.c (is_reference): Call omp_privatize_by_reference langhook. fortran/ * trans.h (gfc_omp_privatize_by_reference): New prototype. * f95-lang.c (LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE): Redefine to gfc_omp_privatize_by_reference. * trans-openmp.c (gfc_omp_privatize_by_reference): New function. * trans-stmt.h (gfc_trans_omp_directive): Add comment. --- gcc/omp-low.c.jj 2005-10-15 12:00:06.000000000 +0200 +++ gcc/omp-low.c 2005-10-18 08:46:23.000000000 +0200 @@ -126,7 +126,7 @@ is_variable_sized (tree expr) static inline bool is_reference (tree decl) { - return TREE_CODE (TREE_TYPE (decl)) == REFERENCE_TYPE; + return lang_hooks.decls.omp_privatize_by_reference (decl); } /* Lookup variables in the decl or field splay trees. The "maybe" form --- gcc/langhooks.h.jj 2005-09-13 15:12:55.000000000 +0200 +++ gcc/langhooks.h 2005-10-18 08:46:23.000000000 +0200 @@ -192,6 +192,10 @@ struct lang_hooks_for_decls value will be the string already stored in an IDENTIFIER_NODE.) */ const char * (*comdat_group) (tree); + + /* True if OpenMP should privatize what this DECL points to rather + than the DECL itself. */ + bool (*omp_privatize_by_reference) (tree); }; /* Language-specific hooks. See langhooks-def.h for defaults. */ --- gcc/fortran/trans.h.jj 2005-10-17 09:04:27.000000000 +0200 +++ gcc/fortran/trans.h 2005-10-18 08:46:23.000000000 +0200 @@ -440,6 +440,9 @@ tree gfc_truthvalue_conversion (tree); tree builtin_function (const char *, tree, int, enum built_in_class, const char *, tree); +/* In trans-openmp.c */ +bool gfc_omp_privatize_by_reference (tree); + /* Runtime library function decls. */ extern GTY(()) tree gfor_fndecl_internal_malloc; extern GTY(()) tree gfor_fndecl_internal_malloc64; --- gcc/fortran/trans-openmp.c.jj 2005-10-12 15:29:25.000000000 +0200 +++ gcc/fortran/trans-openmp.c 2005-10-18 08:46:23.000000000 +0200 @@ -37,6 +37,24 @@ Software Foundation, 51 Franklin Street, #include "arith.h" +/* True if OpenMP should privatize what this DECL points to rather + than the DECL itself. */ + +bool +gfc_omp_privatize_by_reference (tree decl) +{ + tree type = TREE_TYPE (decl); + + if (TREE_CODE (type) == REFERENCE_TYPE) + return true; + + /* POINTER/ALLOCATABLE have aggregate types, all user variables + that have POINTER_TYPE type are supposed to be privatized + by reference. */ + return !DECL_ARTIFICIAL (decl) && TREE_CODE (type) == POINTER_TYPE; +} + + static inline tree gfc_trans_add_clause (tree node, tree tail) { --- gcc/fortran/trans-stmt.h.jj 2005-09-20 10:25:18.000000000 +0200 +++ gcc/fortran/trans-stmt.h 2005-10-18 08:46:23.000000000 +0200 @@ -50,6 +50,8 @@ tree gfc_trans_where (gfc_code *); tree gfc_trans_allocate (gfc_code *); tree gfc_trans_deallocate (gfc_code *); tree gfc_trans_deallocate_array (tree); + +/* trans-openmp.c */ tree gfc_trans_omp_directive (gfc_code *); /* trans-io.c */ --- gcc/fortran/f95-lang.c.jj 2005-10-17 09:04:26.000000000 +0200 +++ gcc/fortran/f95-lang.c 2005-10-18 08:46:23.000000000 +0200 @@ -116,6 +116,7 @@ static void gfc_expand_function (tree); #undef LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE #undef LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION #undef LANG_HOOKS_CLEAR_BINDING_STACK +#undef LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE /* Define lang hooks. */ #define LANG_HOOKS_NAME "GNU F95" @@ -134,6 +135,7 @@ static void gfc_expand_function (tree); #define LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE gfc_signed_or_unsigned_type #define LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION gfc_expand_function #define LANG_HOOKS_CLEAR_BINDING_STACK gfc_clear_binding_stack +#define LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE gfc_omp_privatize_by_reference const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER; --- gcc/langhooks.c.jj 2005-09-17 20:43:39.000000000 +0200 +++ gcc/langhooks.c 2005-10-18 08:50:13.000000000 +0200 @@ -456,6 +456,15 @@ lhd_comdat_group (tree decl) return IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); } +/* True if OpenMP should privatize what this DECL points to rather + than the DECL itself. */ + +bool +lhd_omp_privatize_by_reference (tree decl ATTRIBUTE_UNUSED) +{ + return false; +} + /* lang_hooks.decls.final_write_globals: perform final processing on global variables. */ void --- gcc/langhooks-def.h.jj 2005-09-13 15:12:55.000000000 +0200 +++ gcc/langhooks-def.h 2005-10-18 08:46:23.000000000 +0200 @@ -70,6 +70,7 @@ extern tree lhd_expr_size (tree); extern size_t lhd_tree_size (enum tree_code); extern HOST_WIDE_INT lhd_to_target_charset (HOST_WIDE_INT); extern tree lhd_expr_to_decl (tree, bool *, bool *, bool *); +extern bool lhd_omp_privatize_by_reference (tree); /* Declarations of default tree inlining hooks. */ extern tree lhd_tree_inlining_walk_subtrees (tree *, int *, walk_tree_fn, @@ -239,6 +240,7 @@ extern tree lhd_make_node (enum tree_cod #define LANG_HOOKS_PREPARE_ASSEMBLE_VARIABLE NULL #define LANG_HOOKS_DECL_OK_FOR_SIBCALL lhd_decl_ok_for_sibcall #define LANG_HOOKS_COMDAT_GROUP lhd_comdat_group +#define LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE lhd_omp_privatize_by_reference #define LANG_HOOKS_DECLS { \ LANG_HOOKS_GLOBAL_BINDINGS_P, \ @@ -249,7 +251,8 @@ extern tree lhd_make_node (enum tree_cod LANG_HOOKS_WRITE_GLOBALS, \ LANG_HOOKS_PREPARE_ASSEMBLE_VARIABLE, \ LANG_HOOKS_DECL_OK_FOR_SIBCALL, \ - LANG_HOOKS_COMDAT_GROUP \ + LANG_HOOKS_COMDAT_GROUP, \ + LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE \ } /* The whole thing. The structure is defined in langhooks.h. */ Jakub