From patchwork Fri Jul 29 09:47:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 303 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:b5d6:b0:2b9:3548:2db5 with SMTP id v22csp713051pxt; Fri, 29 Jul 2022 02:48:50 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s7fngvy9/TcO6w9Tfn04gjISvRhjM5CvnWgKsWUJd0eqxViMIz31QV+7YTN7sRgPH2hdF5 X-Received: by 2002:a05:6402:3907:b0:431:6776:64e7 with SMTP id fe7-20020a056402390700b00431677664e7mr2708341edb.0.1659088129865; Fri, 29 Jul 2022 02:48:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659088129; cv=none; d=google.com; s=arc-20160816; b=HxN2b7UpyCDiwuyhK+SiPULUl/eZO2JyZvh6dFX/drQYpz4rhy583jYYj/Dc2j/hoi 0L3ldVz2o0CQoNS4x3X4zqCO4uWI2rOmqh4X79RtCt0RkRaBbbp5y14IJrbWm0ua/oyT 6e47d4SoRSgXTCizzyCVWc684pfNBCesOz1ZEIjV7qLee9nNo9+QBMQ3YjeNaHTagWKL ruGFaTj4zQbLlVHlxyXFuRvNMYodFSzyMgO7QGmphXwq7BrWr7oywTLCEwJPjDzf2gGk 2iF9wJQSYHRy2NTrCSWgAtU6d6vDGV5yet0nc6pIt83NkLPCS7aOnt2/6G6hu6z4Ssin tsvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:from:to :content-language:user-agent:mime-version:date:message-id :ironport-sdr:dmarc-filter:delivered-to; bh=4ZOgCOrfYNXexU3JWisxyLpGMh0/B/44VYMS/fzPnWE=; b=yN1h+bgrN6Oy7UlyZO2tym3vl8k3grGF7LFlktIrld3KY7Z3wukXJ+gfuHheKqvw3j 2UMwsdirRz04WU97yYPNsMlc797aw8QQ9ywvsfrfya/frVdOydqmw47KtzkhfdAxKrYc cakrC1cDDNix7IEQNcNEZOzDka4BP3rVzoSVPG6dbSZo94s/HdUtsqSCCOxEK14KrH53 xijz7h+a76tqb21l9rGVt1uQpbxsuNkLBFDVWHbR34E2TyJAg7s3JKhqURlJBlCfk0Xx zzCJ2QTpC+wANdUaaKjnKG/oy2SAyY/L0d5ygR9XfIEQf6B9m1jVI82a/R1CmQo6wmdw EmOA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id ds8-20020a0564021cc800b0043a991c182fsi2503392edb.129.2022.07.29.02.48.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Jul 2022 02:48:49 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 100903854143 for ; Fri, 29 Jul 2022 09:48:26 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa4.mentor.iphmx.com (esa4.mentor.iphmx.com [68.232.137.252]) by sourceware.org (Postfix) with ESMTPS id E68283858429; Fri, 29 Jul 2022 09:48:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E68283858429 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="5.93,201,1654588800"; d="diff'?scan'208";a="80511274" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa4.mentor.iphmx.com with ESMTP; 29 Jul 2022 01:48:01 -0800 IronPort-SDR: 5Qob4DfvB7yFLeScXh8KSzm5Vxz4nQl7tbR2Rkmk3C4ETN5tGwUHnfitnbx+O1i3ODdNol8tHx vq+riE3rJErP6uaImujBzwSgcsEmUhQCQUm8AXwzjMmaYfb7qqkmbnaO8NmNFPG3R7N2OEx8Iy 1cL2qYl13fnd8Xdt1MQ5doMB9o2rqbegXezi3iHrhs7Cw/51JFX2vRGRUQE1mBA61/lJ3cVLeX 7GX46l91jF145143f9UBaTJ4SmOTzSIcxJfzXX9fhB5bhEtkwFen5scNZm8d3MThm4b4G9xW/S 9fM= Message-ID: Date: Fri, 29 Jul 2022 11:47:54 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Content-Language: en-US To: gcc-patches , fortran From: Tobias Burnus Subject: [Patch] OpenMP/Fortran: Permit assumed-size arrays in uniform clause X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-13.mgc.mentorg.com (139.181.222.13) To svr-ies-mbx-12.mgc.mentorg.com (139.181.222.12) X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1739679994952282483?= X-GMAIL-MSGID: =?utf-8?q?1739679994952282483?= Testcase wise, the run-time testcase libgomp.fortran/examples-4/simd-2.f90 checks essentially the same, except that it uses an array-descriptor array (assumed shape) while this testcase uses an assumed-size array. I decided for an extra compile-time only testcase, but it could be also be moved to libgomp as run-time test or the other test could be extended to also test assumed-size arrays. The OpenMP examples document contains two testcases which now pass, but are reject without this patch: - SIMD/sources/SIMD.2.f90 (for OpenMP 4.0) - SIMD/sources/linear_modifier.3.f90 (for OpenMP 5.2) OK for mainline? Tobias ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955 OpenMP/Fortran: Permit assumed-size arrays in uniform clause gcc/fortran/ChangeLog: * openmp.cc (resolve_omp_clauses): Permit assumed-size arrays in uniform clause. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/declare-simd-3.f90: New test. gcc/fortran/openmp.cc | 3 ++- gcc/testsuite/gfortran.dg/gomp/declare-simd-3.f90 | 30 +++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc index df9cdf43eb7..a7eb6c3e8f4 100644 --- a/gcc/fortran/openmp.cc +++ b/gcc/fortran/openmp.cc @@ -7386,7 +7386,8 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses, || code->op == EXEC_OACC_PARALLEL || code->op == EXEC_OACC_SERIAL)) check_array_not_assumed (n->sym, n->where, name); - else if (n->sym->as && n->sym->as->type == AS_ASSUMED_SIZE) + else if (list != OMP_LIST_UNIFORM + && n->sym->as && n->sym->as->type == AS_ASSUMED_SIZE) gfc_error ("Assumed size array %qs in %s clause at %L", n->sym->name, name, &n->where); if (n->sym->attr.in_namelist && !is_reduction) diff --git a/gcc/testsuite/gfortran.dg/gomp/declare-simd-3.f90 b/gcc/testsuite/gfortran.dg/gomp/declare-simd-3.f90 new file mode 100644 index 00000000000..b94587ef35a --- /dev/null +++ b/gcc/testsuite/gfortran.dg/gomp/declare-simd-3.f90 @@ -0,0 +1,30 @@ +! { dg-do compile } + +module m + implicit none (type, external) +contains + real function add(x, y, j) result(res) + !$omp declare simd(add) uniform(x, y) linear(j : 1) simdlen(4) + integer, value :: j + real, intent(in) :: x(*), y(*) + res = x(j) + y(j) + end function +end module m + +program main + use m + implicit none (type, external) + real, allocatable :: A(:), B(:), C(:) + integer :: i, N + N = 128 + A = [(3*i, i = 1, N)] + B = [(7*i, i = 1, N)] + allocate (C(N)) + + !$omp simd + do i = 1, N + C(i) = add(A, B, i) + end do + + if (any (C /= [(10*i, i = 1, N)])) error stop +end program main