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: 1715415 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NWkhl2Fpqz23ym for ; Wed, 14 Dec 2022 03:38:46 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 36364383C7DA for ; Tue, 13 Dec 2022 16:38:43 +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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" 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