From patchwork Tue Jul 10 07:31:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 941840 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-481262-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="n5yZsK7b"; dkim-atps=neutral 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 41Pv8l0wYSz9rvt for ; Tue, 10 Jul 2018 17:34:12 +1000 (AEST) 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:mime-version :content-type; q=dns; s=default; b=CnatugQ+TAgFemC5yvdFCoB3g9Uju QF5W9lsk5bYmKj6Pey3ZTZcEimj0MqU83BUgmZb0fX9AKzonByqnQZN8msoTb9WJ 0bw9xCDwI63tSEea4JepsFDoNTGpN+TVDQJSXWGDdgP9sLho+AcVNtke4A7k/3Op cUQb2peKG73caY= 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:mime-version :content-type; s=default; bh=tASmzqVY/ZyzLUfwyOVHSWicLic=; b=n5y ZsK7bSTSbR0X8/tdu4/uDfyll9BsFnNVKEi357SX9m4HJ4TTTEtlAOAGxK6YALgr sFwUomiH1zh1vubDIwy/1bynjqFFV3ecZR0llHvmroGdZCeUaV+5LF59u/kWQxm+ EpY6ZQeKSvM1Qbu+Re3m6uL88rBTWiU2EscdiYmA= Received: (qmail 64649 invoked by alias); 10 Jul 2018 07:33:59 -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 61152 invoked by uid 89); 10 Jul 2018 07:31:12 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=!$omp 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; Tue, 10 Jul 2018 07:31:10 +0000 Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 751E130832E0; Tue, 10 Jul 2018 07:31:09 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-117-71.ams2.redhat.com [10.36.117.71]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1ADFB6C524; Tue, 10 Jul 2018 07:31:08 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id w6A7V7po027441; Tue, 10 Jul 2018 09:31:07 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id w6A7V6mx027440; Tue, 10 Jul 2018 09:31:06 +0200 Date: Tue, 10 Jul 2018 09:31:06 +0200 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Cc: fortran@gcc.gnu.org Subject: [committed] Save/restore OpenMP linear clause modifiers in modules (PR fortran/86421) Message-ID: <20180710073106.GC7166@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.2 (2017-12-15) X-IsSubscribed: yes Hi! This patch (in a backwards compatible way) handles saving and restoring of linear clause modifiers. Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk. 2018-07-10 Jakub Jelinek PR fortran/86421 * module.c (omp_declare_simd_clauses): Add LINEAR with _REF, _VAL and _UVAL suffixes. (mio_omp_declare_simd): Save and restore ref, val and uval modifiers on linear clauses. Initialize n->where to gfc_current_locus. * gfortran.dg/vect/pr86421.f90: New test. Jakub --- gcc/fortran/module.c.jj 2018-02-13 09:28:10.000000000 +0100 +++ gcc/fortran/module.c 2018-07-09 18:56:49.595348962 +0200 @@ -4098,6 +4098,9 @@ static const mstring omp_declare_simd_cl minit ("UNIFORM", 3), minit ("LINEAR", 4), minit ("ALIGNED", 5), + minit ("LINEAR_REF", 33), + minit ("LINEAR_VAL", 34), + minit ("LINEAR_UVAL", 35), minit (NULL, -1) }; @@ -4140,7 +4143,10 @@ mio_omp_declare_simd (gfc_namespace *ns, } for (n = ods->clauses->lists[OMP_LIST_LINEAR]; n; n = n->next) { - mio_name (4, omp_declare_simd_clauses); + if (n->u.linear_op == OMP_LINEAR_DEFAULT) + mio_name (4, omp_declare_simd_clauses); + else + mio_name (32 + n->u.linear_op, omp_declare_simd_clauses); mio_symbol_ref (&n->sym); mio_expr (&n->expr); } @@ -4181,11 +4187,20 @@ mio_omp_declare_simd (gfc_namespace *ns, case 4: case 5: *ptrs[t - 3] = n = gfc_get_omp_namelist (); + finish_namelist: + n->where = gfc_current_locus; ptrs[t - 3] = &n->next; mio_symbol_ref (&n->sym); if (t != 3) mio_expr (&n->expr); break; + case 33: + case 34: + case 35: + *ptrs[1] = n = gfc_get_omp_namelist (); + n->u.linear_op = (enum gfc_omp_linear_op) (t - 32); + t = 4; + goto finish_namelist; } } } --- gcc/testsuite/gfortran.dg/vect/pr86421.f90.jj 2018-07-09 19:09:56.662398875 +0200 +++ gcc/testsuite/gfortran.dg/vect/pr86421.f90 2018-07-09 19:07:57.432240946 +0200 @@ -0,0 +1,35 @@ +! PR fortran/86421 +! { dg-require-effective-target vect_simd_clones } +! { dg-additional-options "-fopenmp-simd" } +! { dg-additional-options "-mavx" { target avx_runtime } } + +module mod86421 + implicit none +contains + subroutine foo(x, y, z) + real :: x + integer :: y, z + !$omp declare simd linear(ref(x)) linear(val(y)) linear(uval(z)) + x = x + y + z = z + 1 + end subroutine +end module mod86421 + +program pr86421 + use mod86421 + implicit none + integer :: i, j + real :: a(64) + j = 0 + do i = 1, 64 + a(i) = i + end do + !$omp simd + do i = 1, 64 + call foo (a(i), i, j) + end do + do i = 1, 64 + if (a(i) .ne. (2 * i)) stop 1 + end do + if (j .ne. 64) stop 2 +end program pr86421