From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id EDD403858D1E; Fri, 30 Sep 2022 11:40:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EDD403858D1E 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,358,1654588800"; d="scan'208,217";a="83986935" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa2.mentor.iphmx.com with ESMTP; 30 Sep 2022 03:40:21 -0800 IronPort-SDR: PkjcBv2qDSy6SxHgnAanx8nvYnIHAh9rHW3MejecP4bE2IJzAW91vKE7g7vBu4vXzJhLK55tNl vI/HUL/4EIHcqwxbHcHRmaDPPt3mw5k7N/z1be3sKiUDX2b4IV2NnPASCofw/Q7txENByVDJm8 Q1otxrFgM6kCVldosFxwL51VpY7pbxLewWxiASeyMp+XNqqhmeXo1Wyqw8jl7BwvvnF6X5qQip sE9eOiM6xwV5QG1V8t5FnmR3y5hRbvtjzWgHQLCfwTLMJcIXRpkekNHvfiKyEkpV7AQ4ywwDZ3 uvE= Content-Type: multipart/alternative; boundary="------------QEMkxovYtoheBTBIj3G0j7wD" Message-ID: <248c53d8-04bf-8bef-8e6c-170e4e3311a6@codesourcery.com> Date: Fri, 30 Sep 2022 13:40:16 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1 Subject: Re: [Patch] Fortran: Update use_device_ptr for OpenMP 5.1 [PR105318] Content-Language: en-US To: Jakub Jelinek CC: gcc-patches , fortran References: <6005cea4-c89e-0c31-1c61-d322dcf072e7@codesourcery.com> From: Tobias Burnus In-Reply-To: X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-11.mgc.mentorg.com (139.181.222.11) To svr-ies-mbx-12.mgc.mentorg.com (139.181.222.12) X-Spam-Status: No, score=-5.7 required=5.0 tests=BAYES_00,HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,KAM_DMARC_STATUS,KAM_SHORT,NICE_REPLY_A,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 List-Id: --------------QEMkxovYtoheBTBIj3G0j7wD Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: quoted-printable Hi Jakub, On 30.09.22 13:04, Jakub Jelinek via Fortran wrote: On Fri, Sep 30, 2022 at 12:41:19PM +0200, Tobias Burnus wrote: And 'device(omp_initial_device)' printed a warning in Fortran. (BTW: C/C++ silently accepts any negative value.) I think that is what the standard wants. E.g. in 5.2 device Clause chapter, there is just "If the device_num device-modifier is specified and target-offload-var is n= ot mandatory, device-description must evaluate to a conforming device number." restriction, which is something that can't be checked at compile time, you don't know if target-offload-var is mandatory or not. Admittedly, it is valid to use a non-conforming device number with target-offload-var being 'mandatory'; however, the result is still it it has a "non-conforming device number, is as if the omp_invalid_device device number was used." (Which implies error termination.) Thus, while not invalid (iff using 'mandatory'), it is still odd code and using 'device(omp_invalid_device)' is more sensible. I think it is legitimate to warn in this case - but not to print an error. It is likewise fine to accept it silently. if (omp_clauses->device) - resolve_nonnegative_int_expr (omp_clauses->device, "DEVICE"); + { + resolve_scalar_int_expr (omp_clauses->device, "DEVICE"); + /* omp_initial_device =3D=3D 1, omp_invalid_device =3D -4 (in GCC). = */ + if (omp_clauses->device->expr_type =3D=3D EXPR_CONSTANT + && omp_clauses->device->ts.type =3D=3D BT_INTEGER + && mpz_cmp_si (omp_clauses->device->value.integer, -1) < 0 + && mpz_cmp_si (omp_clauses->device->value.integer, -4) !=3D 0) + gfc_warning (0, + "INTEGER expression of DEVICE clause at %L must be non= -" + "negative or omp_initial_device or omp_invalid_device", + &omp_clauses->device->where); + } So I think we should just resolve_scalar_int_expr and be done with that. Otherwise LGTM. I have now done as suggested - and committed it as https://gcc.gnu.org/r13-= 2980-g10a116104969b3ecc9ea4abdd5436c66fd78d537 Thanks for the review! 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 --------------QEMkxovYtoheBTBIj3G0j7wD--