From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa4.mentor.iphmx.com (esa4.mentor.iphmx.com [68.232.137.252]) by sourceware.org (Postfix) with ESMTPS id 38B7A3857809; Fri, 21 Jan 2022 17:43:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 38B7A3857809 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com IronPort-SDR: LXrDfi56tVLyIcxe7y7yUObL30bDWjhW+5Wu6NADOdfZ+2pkCWETXj/y/lf18FGIVEquHALJV1 u3rRg+AcdH56VviNfy9QvUAVlGxQ0QvmQZ+c681cBmfRYoEOdcCxDQ+s+iq8loDVh6zkw/JHLr fAif5QFaGaEP6jitip4s6B66AfZcUto8kRLbEMDgFJfgupehUsKqQzxrqwpHqH/jItte2W2UXj 4ZRECYgwEfSJJ8uZ9DFJAXOj4vpIml8ybR28JnBWVbJXvoYmXqD6n75K34c3v69NIkRunuCyrF cxzOY8bL6Oz62hLPNEvUyk9x X-IronPort-AV: E=Sophos;i="5.88,306,1635235200"; d="scan'208";a="71037358" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa4.mentor.iphmx.com with ESMTP; 21 Jan 2022 09:43:52 -0800 IronPort-SDR: iYrw8TQfxEwBeAJyJOmNnOLlWZN0sAIXooNpPz75NvMp7lgHqj8JLsddx0p7N6SDtzrD+SOWqM AEGtiKK+byDbgDA389jSLyfebGNGvGlxTR510ZJ4gsftq5crQPDSLCi9RPXTvnMmkTdujv0Gev 9KY56ZN9JJyu779w3T9IRgktVcdAbyzNtXN6bns5JZfJD1BQWWstmRlmnJ9nlNCqqTWG3LnbX7 lYkQyU+MwetugWuXCekc4oHWDfNv6kzRrcTIby83Wo9OLxWBhSfnK1hJfIzj/4IrEunLzyqXYI 2xM= Message-ID: <48d8c123-fa4f-d4a3-17de-b082de32f0bf@codesourcery.com> Date: Fri, 21 Jan 2022 18:43:45 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH] [gfortran] Add support for allocate clause (OpenMP 5.0). Content-Language: en-US To: Thomas Schwinge , Hafiz Abid Qadeer CC: Jakub Jelinek , Tobias Burnus , , References: <20211022130502.2211568-1-abidh@codesourcery.com> <20211102162714.GF304296@tucnak> <20211220200650.GN2646553@tucnak> <8735lh6mcx.fsf@euler.schwinge.homeip.net> From: Tobias Burnus In-Reply-To: <8735lh6mcx.fsf@euler.schwinge.homeip.net> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: quoted-printable X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-13.mgc.mentorg.com (139.181.222.13) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, NICE_REPLY_A, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: fortran@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Fortran mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Jan 2022 17:43:54 -0000 On 21.01.22 18:15, Thomas Schwinge wrote: > source-gcc/libgomp/testsuite/libgomp.fortran/allocate-1.f90:11:47: > > 11 | integer(c_int) function is_64bit_aligned (a) bind(C) > | 1 > Warning: Variable =E2=80=98a=E2=80=99 at (1) is a dummy argument of = the BIND(C) procedure =E2=80=98is_64bit_aligned=E2=80=99 but may not be C i= nteroperable [-Wc-binding-type] > > Is that something to worry about? I think it is not very elegant =E2=80=93 but should be okay. On the Fortran side: integer(c_int) function is_64bit_aligned (a) bind(C) import :: c_int integer :: a end that matches 'int is_64bit_aligned (int *a);' While 'integer' in principle may not be 'int', the call by reference makes this independent of the actually used integer kind. HOWEVER: That interface it not used! While it defines that interface in 'module m', there is no 'use m' in 'subroutine foo'. (or alternatively: 'foo' being after 'contains' inside the 'module m' - and then 'use m' in the main program) That means that 'is_64bit_aligned(...)' gets implicitly types as 'integer' with unknown arguments, which get passed by value. By gfortran convention, that function has a tailing underscore. That matches the C side, which such an underscore: int is_64bit_aligned_ (uintptr_t a) { return ( (a & 0x3f) =3D=3D 0); } With pass by reference, a pointer is passed, which should be handled by 'uintptr_t'. * * * Side remark: I really recommend 'implicit none' when writing Fortran code - which disables implicit typing. I personally have started to use implicit none (type, external) which also rejects 'call something()' unless 'something' has been explicitly declared, e.g. by an interface block. * * * Side remark: A Fortran-only variant has been used in libgomp/testsuite/libgomp.fortran/alloc-11.f90: if (mod (TRANSFER (p, iptr), 64) /=3D 0) As optimization, also 'iand(..., z'3f') =3D=3D 0' would work ;-) Tobias ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstra=C3=9Fe 201= , 80634 M=C3=BCnchen; Gesellschaft mit beschr=C3=A4nkter Haftung; Gesch=C3= =A4ftsf=C3=BChrer: Thomas Heurung, Frank Th=C3=BCrauf; Sitz der Gesellschaf= t: M=C3=BCnchen; Registergericht M=C3=BCnchen, HRB 106955