From patchwork Tue Dec 13 16:38:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 32873 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp229471wrn; Tue, 13 Dec 2022 08:39:08 -0800 (PST) X-Google-Smtp-Source: AA0mqf7AdnKwmN9GmZh1xQ/D0/8+0lna+OTe2ul5DQr61lJKr8dH8tzxMntY9j/aPAknrXgXzQa9 X-Received: by 2002:a17:906:4c4b:b0:7c1:1ada:5e1e with SMTP id d11-20020a1709064c4b00b007c11ada5e1emr17939826ejw.26.1670949548202; Tue, 13 Dec 2022 08:39:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670949548; cv=none; d=google.com; s=arc-20160816; b=RuNW/tCvFA3E5oRlASLNlZlRbRXdGZ2fJroD1j+1052BSTmXPriEpB1650jJcOEszF pkh2fxUYUVv2zrFvSkhUJpirH0jYKlLu9b3wcAQhb7s3OfVv7TWoXXgnOc4wtKBBE7wD 3/YVO8pgY+yOYU+0jqZJxmCoYozbXLuh8BvpznVBWmIZv0PbFzPQOZ77LJi3jPW1BRZT miIm0C57kdTCpvys6rEtyLy0XBRJ9GVowczGU6wJpJJIQPrLk+07zI0JvC6BtkUoP9fh 5NeyfbrGa82MUQ65sJ9mdB5E24Ie12AmBiNvCdqzi9tuoFgD6GTaT4+ccCmLZ8ClzKf8 FgqA== 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=2zDrB+W1to2tmt7ORCTH6MVf4Zb/LiOBl8nqqBZ90CI=; b=sFFFFqnfP8cRO4zxGcl+8JGazCCCw4VY4CX9vn7NmfkiHDW3YJiCEUB67M9GeU/I7G U0j5p1ERypO2SdPcsc63tLLx9ypJPzAT4kdXIfeIWiqjasAEj5auoGtk9556D73ziKjN MFudsWRWO9TgGlkYvEPhR+5/byL8CF2d+Q6CPU5Q7SgvxOTDaGUWDdt4wRAFWY6rLv4f /hACqru2gOcJthWPmuFIHErkFafbZLKQpraVhwNsUgl1wrMELxlvaC3jlaBNGsPKR5fW RVYm1tzJJMtE9Cqfo9BK4go7daHxs0aMzK6SBJfSA7TaY7ESv8Tim8qkx2ZV9PrjGw6i TJ1Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id hx9-20020a170906846900b007ab1b8b71a6si7273497ejc.40.2022.12.13.08.39.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 08:39:08 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 837BF383AB7D for ; Tue, 13 Dec 2022 16:38:55 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id 197B03842307; Tue, 13 Dec 2022 16:38:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 197B03842307 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.96,241,1665475200"; d="diff'?scan'208";a="90075674" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa2.mentor.iphmx.com with ESMTP; 13 Dec 2022 08:38:27 -0800 IronPort-SDR: vrY1e4cEPIzqkbCdGkL0Dj8gg3W9f1JKMmic+UlPAoWZsShmq2fuMB1UlNBxVz9SCfPf2j73Ro Px2suhjpzP1MqWIoM1N98HXJZ2u3WsVMSYhPc/6ft6v++S14g1aBcK1hP666635aCBsLgyzstM MOMUHgMIyVBQsJS/HYbPZqfEIq3l8ZBBadUmO9T//6IJ7QjKBzgx5ucG8kx1JHR5HVtzZOCHqb ihcri4Fol7tUjTkiZkI56xTNF5XOCjIubSKiPHIXqQZ72TZTg5d/mhL+QSt8COIq/aAXkwa1pt eBk= Message-ID: Date: Tue, 13 Dec 2022 17:38:22 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Content-Language: en-US To: Jakub Jelinek , gcc-patches , fortran From: Tobias Burnus Subject: [Patch] Fortran: Extend align-clause checks of OpenMP's allocate clause X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-12.mgc.mentorg.com (139.181.222.12) 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, RCVD_IN_MSPIKE_H2, 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?1752117593762831086?= X-GMAIL-MSGID: =?utf-8?q?1752117593762831086?= I missed that 'align' needs to be a power of 2 - contrary to 'aligned', which does not have this restriction for some odd reason. 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 Fortran: Extend align-clause checks of OpenMP's allocate directive gcc/fortran/ChangeLog: * openmp.cc (resolve_omp_clauses): Check also for power of two. libgomp/ChangeLog: * testsuite/libgomp.fortran/allocate-3.f90: Fix ALIGN usage, remove unused -fdump-tree-original. * testsuite/libgomp.fortran/allocate-4.f90: New. diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc index 686f924b47a..5468cc97969 100644 --- a/gcc/fortran/openmp.cc +++ b/gcc/fortran/openmp.cc @@ -7315,11 +7315,12 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses, || n->u.align->ts.type != BT_INTEGER || n->u.align->rank != 0 || gfc_extract_int (n->u.align, &alignment) - || alignment <= 0) + || alignment <= 0 + || !pow2p_hwi (alignment)) { - gfc_error ("ALIGN modifier requires a scalar positive " - "constant integer alignment expression at %L", - &n->u.align->where); + gfc_error ("ALIGN modifier requires at %L a scalar positive " + "constant integer alignment expression that is a " + "power of two", &n->u.align->where); break; } } diff --git a/libgomp/testsuite/libgomp.fortran/allocate-3.f90 b/libgomp/testsuite/libgomp.fortran/allocate-3.f90 index a39819164d6..1fa0bb932c3 100644 --- a/libgomp/testsuite/libgomp.fortran/allocate-3.f90 +++ b/libgomp/testsuite/libgomp.fortran/allocate-3.f90 @@ -1,5 +1,4 @@ ! { dg-do compile } -! { dg-additional-options "-fdump-tree-original" } use omp_lib implicit none @@ -23,6 +22,7 @@ integer :: q, x,y,z ! { dg-error "Object 'omp_high_bw_mem_alloc' is not a variable" "" { target *-*-* } .-1 } !$omp end parallel -!$omp parallel allocate( align(q) : x) firstprivate(x) ! { dg-error "31:ALIGN modifier requires a scalar positive constant integer alignment expression at" } +!$omp parallel allocate( align(128) : x) firstprivate(x) ! OK !$omp end parallel + end diff --git a/libgomp/testsuite/libgomp.fortran/allocate-4.f90 b/libgomp/testsuite/libgomp.fortran/allocate-4.f90 new file mode 100644 index 00000000000..ddb507ba8e4 --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/allocate-4.f90 @@ -0,0 +1,42 @@ +! { dg-do compile } + + +subroutine test() +use iso_c_binding, only: c_intptr_t +implicit none +integer, parameter :: omp_allocator_handle_kind = 1 !! <<< +integer (kind=omp_allocator_handle_kind), & + parameter :: omp_high_bw_mem_alloc = 4 +integer :: q, x,y,z +integer, parameter :: cnst(2) = [64, 101] + +!$omp parallel allocate( omp_high_bw_mem_alloc : x) firstprivate(x) ! { dg-error "Expected integer expression of the 'omp_allocator_handle_kind' kind" } +!$omp end parallel + +!$omp parallel allocate( allocator (omp_high_bw_mem_alloc) : x) firstprivate(x) ! { dg-error "Expected integer expression of the 'omp_allocator_handle_kind' kind" } +!$omp end parallel + +!$omp parallel allocate( align (q) : x) firstprivate(x) ! { dg-error "32:ALIGN modifier requires at \\(1\\) a scalar positive constant integer alignment expression that is a power of two" } +!$omp end parallel + +!$omp parallel allocate( align (32) : x) firstprivate(x) ! OK +!$omp end parallel + +!$omp parallel allocate( align(q) : x) firstprivate(x) ! { dg-error "31:ALIGN modifier requires at \\(1\\) a scalar positive constant integer alignment expression that is a power of two" } +!$omp end parallel + +!$omp parallel allocate( align(cnst(1)) : x ) firstprivate(x) ! OK +!$omp end parallel + +!$omp parallel allocate( align(cnst(2)) : x) firstprivate(x) ! { dg-error "31:ALIGN modifier requires at \\(1\\) a scalar positive constant integer alignment expression that is a power of two" } +!$omp end parallel + +!$omp parallel allocate( align( 31) :x) firstprivate(x) ! { dg-error "32:ALIGN modifier requires at \\(1\\) a scalar positive constant integer alignment expression that is a power of two" } +!$omp end parallel + +!$omp parallel allocate( align (32.0): x) firstprivate(x) ! { dg-error "32:ALIGN modifier requires at \\(1\\) a scalar positive constant integer alignment expression that is a power of two" } +!$omp end parallel + +!$omp parallel allocate( align(cnst ) : x ) firstprivate(x) ! { dg-error "31:ALIGN modifier requires at \\(1\\) a scalar positive constant integer alignment expression that is a power of two" } +!$omp end parallel +end