From patchwork Thu Jun 5 07:31:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 356198 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 2FF5014009C for ; Thu, 5 Jun 2014 17:32:07 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:reply-to:references:mime-version :content-type:content-transfer-encoding:in-reply-to; q=dns; s= default; b=s6KQoZpGL9gnial0Yk1Qf9bHnl2fy9477YDrDogmWz7gDaGWJ5B7A eLULLrdFMxwfJEhGEJGrlrZypbxzG2QnDYr1hdxgTt7IV7VLR7XxvXium6LCE2OU 17Lfhrk2Le5ROriIb5Ni4clY5R+sGHYP04f7tcH6m1NgKvZ+kKn3SE= 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:date :from:to:cc:subject:message-id:reply-to:references:mime-version :content-type:content-transfer-encoding:in-reply-to; s=default; bh=66/0lTcQMxn/L/AoWNMdjSJJAhs=; b=pbJ2JQ1OK3QwFJsdEbMGfu6BGNlM 8f9wrhnLXm5YDbtagbH6Qs8ASv+kYzHOb979b3AeoDPwoYrqEgRiF16jXB94/KnS JDvt4MsFOwWl7zn5XjsdOhshzvLkx2FSdp6j6GoIq1uKGLJfcjc8HtGKbm9jjRbO mEG9bkQrBCpe508= Received: (qmail 12117 invoked by alias); 5 Jun 2014 07:31:54 -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 12095 invoked by uid 89); 5 Jun 2014 07:31:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.8 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients 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 ESMTP; Thu, 05 Jun 2014 07:31:52 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s557VooI008862 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 5 Jun 2014 03:31:50 -0400 Received: from tucnak.zalov.cz (ovpn-116-17.ams2.redhat.com [10.36.116.17]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s557VmFl021229 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 5 Jun 2014 03:31:49 -0400 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.14.8/8.14.7) with ESMTP id s557Vkg2027235; Thu, 5 Jun 2014 09:31:46 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.14.8/8.14.8/Submit) id s557Vism027234; Thu, 5 Jun 2014 09:31:44 +0200 Date: Thu, 5 Jun 2014 09:31:44 +0200 From: Jakub Jelinek To: FX Cc: gcc-patches , gfortran Subject: Re: [PATCH] Add support for OpenMP fortran user defined reductions Message-ID: <20140605073144.GD10386@tucnak.redhat.com> Reply-To: Jakub Jelinek References: <00DBE047-6400-47B3-9C0A-03A98244C6E9@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <00DBE047-6400-47B3-9C0A-03A98244C6E9@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes On Tue, Jun 03, 2014 at 09:42:39AM +0200, FX wrote: > > As discussed with Tobias on IRC yesterday, the fact that I'd like to > > eventually backport the Fortran OpenMP 4.0 support to 4.9 branch > > poses a problem with the module.c changes > > But this is by design, because we’re not supposed to add new features > (especially API-changing or module-changing ones) in a release branch. > The compatibility fixes you propose will increase the complexity of the > module reader code, and creates some precedent. > > I don’t think there’s much pressure from the “general public” for Fortran > OpenMP 4.0, so having it in 4.10 only rather than 4.9 is probably not such > a big deal. We have some precedents already, e.g. 4.8.1 adding remaining C++11 bits to complete C++11 support, instead of waiting for 4.9.0, and IMHO this is similar, OpenMP 4.0 shipped only incomplete support in 4.9.0 (everything but Fortran), and shouldn't be that risky to backport. For the conditional MOD_VERSION I meant something like (incremental patch), MOD_VERSION_OMP4 content is open for bikeshedding, can be "13" etc. If it is "13", then perhaps such a patch could be applied only to 4.9.x, but we'd need to make sure that if any new extensions to module.c are added on the trunk, then MOD_VERSION is bumped there to "14". Jakub --- gcc/fortran/module.c.jj 2014-06-02 16:23:21.000000000 +0200 +++ gcc/fortran/module.c 2014-06-05 09:28:39.616639930 +0200 @@ -82,7 +82,8 @@ along with GCC; see the file COPYING3. /* Don't put any single quote (') in MOD_VERSION, if you want it to be recognized. */ -#define MOD_VERSION "13" +#define MOD_VERSION "12" +#define MOD_VERSION_OMP4 "12 OpenMP 4" /* Structure that describes a position within a module file. */ @@ -196,6 +197,7 @@ static char* module_content; static long module_pos; static int module_line, module_column, only_flag; static int prev_module_line, prev_module_column; +static bool module_omp4; static enum { IO_INPUT, IO_OUTPUT } @@ -4064,7 +4066,13 @@ mio_symbol (gfc_symbol *sym) if (sym->formal_ns && sym->formal_ns->proc_name == sym && sym->formal_ns->entries == NULL) - mio_omp_declare_simd (sym->formal_ns, &sym->formal_ns->omp_declare_simd); + { + if (module_omp4) + mio_omp_declare_simd (sym->formal_ns, + &sym->formal_ns->omp_declare_simd); + else if (iomode == IO_OUTPUT) + gcc_assert (sym->formal_ns->omp_declare_simd == NULL); + } mio_rparen (); } @@ -4871,7 +4879,8 @@ read_module (void) /* Skip OpenMP UDRs. */ get_module_locus (&omp_udrs); - skip_list (); + if (module_omp4) + skip_list (); mio_lparen (); @@ -5138,9 +5147,12 @@ read_module (void) load_commons (); load_equiv (); - /* Load OpenMP user defined reductions. */ - set_module_locus (&omp_udrs); - load_omp_udrs (); + if (module_omp4) + { + /* Load OpenMP user defined reductions. */ + set_module_locus (&omp_udrs); + load_omp_udrs (); + } /* At this point, we read those symbols that are needed but haven't been loaded yet. If one symbol requires another, the other gets @@ -5842,11 +5854,16 @@ write_module (void) write_char ('\n'); write_char ('\n'); - mio_lparen (); - write_omp_udrs (gfc_current_ns->omp_udr_root); - mio_rparen (); - write_char ('\n'); - write_char ('\n'); + if (module_omp4) + { + mio_lparen (); + write_omp_udrs (gfc_current_ns->omp_udr_root); + mio_rparen (); + write_char ('\n'); + write_char ('\n'); + } + else + gcc_assert (gfc_current_ns->omp_udr_root == NULL); /* Write symbol information. First we traverse all symbols in the primary namespace, writing those that need to be written. @@ -5916,6 +5933,19 @@ read_crc32_from_module_file (const char* } +/* Set module_omp4 if any symbol has !$OMP DECLARE SIMD directives. */ + +static void +find_omp_declare_simd (gfc_symtree *st) +{ + gfc_symbol *sym = st->n.sym; + if (sym->formal_ns + && sym->formal_ns->proc_name == sym + && sym->formal_ns->omp_declare_simd) + module_omp4 = true; +} + + /* Given module, dump it to disk. If there was an error while processing the module, dump_flag will be set to zero and we delete the module file, even if it was already there. */ @@ -5958,6 +5988,12 @@ gfc_dump_module (const char *name, int d if (gfc_cpp_makedep ()) gfc_cpp_add_target (filename); + module_omp4 = false; + if (gfc_current_ns->omp_udr_root) + module_omp4 = true; + else + gfc_traverse_symtree (gfc_current_ns->sym_root, find_omp_declare_simd); + /* Write the module to the temporary file. */ module_fp = gzopen (filename_tmp, "w"); if (module_fp == NULL) @@ -5965,7 +6001,7 @@ gfc_dump_module (const char *name, int d filename_tmp, xstrerror (errno)); gzprintf (module_fp, "GFORTRAN module version '%s' created from %s\n", - MOD_VERSION, gfc_source_file); + module_omp4 ? MOD_VERSION_OMP4 : MOD_VERSION, gfc_source_file); /* Write the module itself. */ iomode = IO_OUTPUT; @@ -6756,6 +6792,8 @@ gfc_use_module (gfc_use_list *module) read_module_to_tmpbuf (); gzclose (module_fp); + module_omp4 = false; + /* Skip the first line of the module, after checking that this is a gfortran module file. */ line = 0; @@ -6775,11 +6813,15 @@ gfc_use_module (gfc_use_list *module) if (strcmp (atom_name, " version") != 0 || module_char () != ' ' || parse_atom () != ATOM_STRING - || strcmp (atom_string, MOD_VERSION)) + || (strcmp (atom_string, MOD_VERSION) + && strcmp (atom_string, MOD_VERSION_OMP4))) gfc_fatal_error ("Cannot read module file '%s' opened at %C," " because it was created by a different" " version of GNU Fortran", filename); + if (strcmp (atom_string, MOD_VERSION_OMP4) == 0) + module_omp4 = true; + free (atom_string); }