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 E32173858CDA for ; Wed, 14 Jun 2023 08:09:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E32173858CDA 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="6.00,242,1681200000"; d="scan'208,223";a="9786065" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa2.mentor.iphmx.com with ESMTP; 14 Jun 2023 00:09:17 -0800 IronPort-SDR: g9QFRDTNcYX8UfJpMzdjrLtGOf4BMbg3QE3i9uu6uSYibGb7CJlqdwTyfBuG5CfguGVWWwGyH9 Y2kdeUB/dKinR21pakkct8KbPTfDlQ1zl+cU2uqQRJMI8A1xYJSkbM9Y1H8x/n+4jBVis41dmz OmsXseT77wJCIrukZDFeuJ2GWmT0SQhj0BO7Ixgqzsperla8qGek+hG855BsfJZDLWqjxYLEPl oI1kyMX5DzZ4DAjMuztFrr+ZN6ik/O+3y94W0cIpwNHtskikeSZl+4KqDZVZzjpou+mikbSv2m pzE= From: Thomas Schwinge To: Tobias Burnus , Subject: Fix typo in 'libgomp.c/target-51.c' (was: [patch] OpenMP: Set default-device-var with OMP_TARGET_OFFLOAD=mandatory) In-Reply-To: <1487d7d4-8611-0d78-6bf2-9bffdd4daa64@codesourcery.com> References: <1487d7d4-8611-0d78-6bf2-9bffdd4daa64@codesourcery.com> User-Agent: Notmuch/0.29.3+94~g74c3f1b (https://notmuchmail.org) Emacs/28.2 (x86_64-pc-linux-gnu) Date: Wed, 14 Jun 2023 10:09:09 +0200 Message-ID: <87pm5y31p6.fsf@euler.schwinge.homeip.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-11.mgc.mentorg.com (139.181.222.11) To svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00,GIT_PATCH_0,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,KAM_SHORT,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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: --=-=-= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hi! On 2023-06-13T20:44:39+0200, Tobias Burnus wrote: > I intent to commit this tomorrow, unless there are comments. I'm sorry I'm late. ;-P > It does as it says (see commit log): It initializes default-device-var > to the value using the algorithm described in OpenMP 5.2, which > depends on whether OMP_TARGET_OFFLOAD=3Dmandatory was set. > > NOTE: With -foffload=3Ddisable there is no binary code but still > devices get found - such that default-device-var =3D=3D 0 (=3D first > nonhost device). Thus, in that case, libgomp runs the code on that > device but as no binary data is available, host fallback is used. > (Even if there would be executable code for another device on > the system.) > With mandatory, this unintended host fallback is detected and an > error is diagnosed. One can argue whether keeping the devices > makes sense (e.g. because in a dynamic library device code will > be loaded later) or not (don't list if no code is available). This reminds me of the (unresolved) "Means to determine at runtime foffload targets specified at compile time". > Note that TR11 (future OpenMP 6.0) extends OMP_DEFAULT_DEVICE and > adds OMP_AVAILABLE_DEVICES which permit a finer-grained control about > the device, including OMP_DEFAULT_DEVICE=3Dinitial (and 'invalid') which > the current scheme does not permit. (Well, there is > OMP_TARGET_OFFLOAD=3Ddisabled, but that's a too big hammer.) > PS: DejaGNU testing was done without offloading configured > and with remote testing on a system having an offload device, > which which does not support setting environment variables. > Manual testing was done with offloading enabled and depending > on the testcase, running on a system with and/or without offloading > hardware. > --- a/libgomp/target.c > +++ b/libgomp/target.c > @@ -150,7 +150,11 @@ resolve_device (int device_id, bool remapped) > if (device_id =3D=3D (remapped ? GOMP_DEVICE_HOST_FALLBACK > : omp_initial_device)) > return NULL; > - if (device_id =3D=3D omp_invalid_device) > + if (gomp_target_offload_var =3D=3D GOMP_TARGET_OFFLOAD_MANDATORY > + && gomp_get_num_devices () =3D=3D 0) > + gomp_fatal ("OMP_TARGET_OFFLOAD is set to MANDATORY but only the ho= st " > + "device is available"); > + else if (device_id =3D=3D omp_invalid_device) > gomp_fatal ("omp_invalid_device encountered"); > else if (gomp_target_offload_var =3D=3D GOMP_TARGET_OFFLOAD_MANDAT= ORY) > gomp_fatal ("OMP_TARGET_OFFLOAD is set to MANDATORY, " | "but device not found"); | | return NULL; | } | else if (device_id >=3D gomp_get_num_devices ()) | { | if (gomp_target_offload_var =3D=3D GOMP_TARGET_OFFLOAD_MANDATORY | && device_id !=3D num_devices_openmp) | gomp_fatal ("OMP_TARGET_OFFLOAD is set to MANDATORY, " | "but device not found"); | | return NULL; | } | | gomp_mutex_lock (&devices[device_id].lock); | if (devices[device_id].state =3D=3D GOMP_DEVICE_UNINITIALIZED) | gomp_init_device (&devices[device_id]); | else if (devices[device_id].state =3D=3D GOMP_DEVICE_FINALIZED) | { | gomp_mutex_unlock (&devices[device_id].lock); | | if (gomp_target_offload_var =3D=3D GOMP_TARGET_OFFLOAD_MANDATORY) | gomp_fatal ("OMP_TARGET_OFFLOAD is set to MANDATORY, " | "but device is finalized"); | | return NULL; | } | gomp_mutex_unlock (&devices[device_id].lock); | | return &devices[device_id]; | } > --- /dev/null > +++ b/libgomp/testsuite/libgomp.c/target-51.c > @@ -0,0 +1,24 @@ > +/* Check OMP_TARGET_OFFLOAD on systems with no available non-host device= s, > + which is enforced by using -foffload=3Ddisable. */ > + > +/* { dg-do run } */ > +/* { dg-additional-options "-foffload=3Ddisable" } */ > +/* { dg-set-target-env-var OMP_TARGET_OFFLOAD "mandatory" } */ > + > +/* { dg-shouldfail "OMP_TARGET_OFFLOAD=3Dmandatory and no available devi= ce" } */ > + > +/* See comment in target-50.c/target-50.c for why the output differs. *= / > + > +/* { dg-output ".*libgomp: OMP_TARGET_OFFLOAD is set to MANDATORY but on= ly the host device is available.*" { target { ! offload_device } } } */ > +/* { dg-output ".*libgomp: OMP_TARGET_OFFLOAD is set to MANDATORY but de= vice not found.*" { target offload_device } } */ I intend to push the attached "Fix typo in 'libgomp.c/target-51.c'" after testing. Let me know if I should also adjust the new 'target { ! offload_device }' diagnostic "[...] MANDATORY but only the host device is available" to include a comma before 'but', for consistency with the other existing diagnostics (cited above)? Gr=C3=BC=C3=9Fe Thomas > + > +int > +main () > +{ > + int x; > + #pragma omp target map(tofrom:x) > + x =3D 5; > + if (x !=3D 5) > + __builtin_abort (); > + return 0; > +} ----------------- 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 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename="0001-Fix-typo-in-libgomp.c-target-51.c.patch" >From 2464d87db542b87a1d276637f334e9c6eb35be64 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Wed, 14 Jun 2023 09:25:15 +0200 Subject: [PATCH] Fix typo in 'libgomp.c/target-51.c' ..., and therefore, given 'target offload_device': PASS: libgomp.c/target-51.c (test for excess errors) PASS: libgomp.c/target-51.c execution test [-FAIL:-]{+PASS:+} libgomp.c/target-51.c output pattern test Fix-up for recent commit 18c8b56c7d67a9e37acf28822587786f0fc0efbc "OpenMP: Set default-device-var with OMP_TARGET_OFFLOAD=mandatory". libgomp/ * testsuite/libgomp.c/target-51.c: Fix typo. --- libgomp/testsuite/libgomp.c/target-51.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libgomp/testsuite/libgomp.c/target-51.c b/libgomp/testsuite/libgomp.c/target-51.c index 7d09bceacd58..cf9e690263e9 100644 --- a/libgomp/testsuite/libgomp.c/target-51.c +++ b/libgomp/testsuite/libgomp.c/target-51.c @@ -10,7 +10,7 @@ /* See comment in target-50.c/target-50.c for why the output differs. */ /* { dg-output ".*libgomp: OMP_TARGET_OFFLOAD is set to MANDATORY but only the host device is available.*" { target { ! offload_device } } } */ -/* { dg-output ".*libgomp: OMP_TARGET_OFFLOAD is set to MANDATORY but device not found.*" { target offload_device } } */ +/* { dg-output ".*libgomp: OMP_TARGET_OFFLOAD is set to MANDATORY, but device not found.*" { target offload_device } } */ int main () -- 2.39.2 --=-=-=--