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 3BA0C3856267 for ; Wed, 15 Jun 2022 20:58:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3BA0C3856267 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.91,302,1647331200"; d="scan'208";a="77343885" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa2.mentor.iphmx.com with ESMTP; 15 Jun 2022 12:58:54 -0800 IronPort-SDR: pZqv3GRlb53SC/K1QD3f/5W6+ShU+fjHDL8TC6Vnky8CGqGYj08R0TkToQea2QXo1HM4H7UZos gNLRoqopFqWdJblv9WrpdYOLGLKk9X5OMP4FrA4R/IY1JI4leW7BevzP2zTP3LDFo5pgvQZ1AE lhulIjVrIqNgmYDNEXRhAU4MY2YE9uPuSqqhOxJ3vp+y9q8m68EUCGQ9WZLB85RclglLfiiqhy crMoWqQtPxhvhL9QOk3/5FSS6VG9huKLmBxn/bllv2mYdGZ+bV2iDOCfwRB9wEzmltmZZUxzfJ qmw= From: Thomas Schwinge To: Jakub Jelinek CC: , Tobias Burnus , "Marcel Vollweiler" Subject: Re: [committed] openmp: Conforming device numbers and omp_{initial,invalid}_device In-Reply-To: References: <87r13ri4e6.fsf@dem-tschwing-1.ger.mentorg.com> User-Agent: Notmuch/0.29.3+94~g74c3f1b (https://notmuchmail.org) Emacs/27.1 (x86_64-pc-linux-gnu) Date: Wed, 15 Jun 2022 22:58:49 +0200 Message-ID: <878rpx7ieu.fsf@euler.schwinge.homeip.net> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-06.mgc.mentorg.com (139.181.222.6) To svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no 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: , X-List-Received-Date: Wed, 15 Jun 2022 20:58:58 -0000 Hi Jakub! On 2022-06-15T10:46:30+0200, Jakub Jelinek wrote: > On Tue, Jun 14, 2022 at 06:41:37PM +0200, Thomas Schwinge wrote: >> On 2022-06-13T14:06:39+0200, Jakub Jelinek via Gcc-patches wrote: >> > OpenMP 5.2 changed once more what device numbers are allowed. >> >> > libgomp/ >> >> > * testsuite/libgomp.c-c++-common/target-is-accessible-1.c (main)= : Add >> > test with omp_initial_device. Use -5 instead of -1 for negative= value >> > test. >> > * testsuite/libgomp.fortran/target-is-accessible-1.f90 (main): >> > Likewise. Reorder stop numbers. >> >> In an offloading configuration, I'm seeing: >> >> PASS: libgomp.fortran/get-mapped-ptr-1.f90 -O (test for excess er= rors) >> [-PASS:-]{+FAIL:+} libgomp.fortran/get-mapped-ptr-1.f90 -O execut= ion test >> >> Does that one need similar treatment? > > I assume not just that but libgomp.c-c++-common/get-mapped-ptr-1.c too? No, that one I've not seen FAIL, tested in several different configurations/systems/GPUs. Maybe we were just lucky -- or would there be a more fundamental problem, when it was in fact "to be expected" that it'd FAIL, but didn't? > It both needs the same treatment, and in the get-mapped-ptr-1.c > case there is even UB, while the Fortran version was using c_loc (q) > as the host pointer, in C/C++ it was using q which was value of > uninitialized pointer. > > Tested on x86_64-linux, committed to trunk. ACK, thanks. Gr=C3=BC=C3=9Fe Thomas > 2022-06-15 Jakub Jelinek > > * testsuite/libgomp.c-c++-common/get-mapped-ptr-1.c (main): Initial= ize > q to ddress of an automatic variable. Use -5 instead of -1 in > omp_get_mapped_ptr call. Add test with omp_initial_device. > * testsuite/libgomp.fortran/get-mapped-ptr-1.f90 (main): Use -5 ins= tead > of -1 in omp_get_mapped_ptr call. Add test with omp_initial_device= . > Renumber stop arguments afterwards. > > --- libgomp/testsuite/libgomp.c-c++-common/get-mapped-ptr-1.c.jj 202= 2-05-09 09:09:20.963464303 +0200 > +++ libgomp/testsuite/libgomp.c-c++-common/get-mapped-ptr-1.c 2022-06-15 = 09:39:17.518746512 +0200 > @@ -6,7 +6,10 @@ main () > { > int d =3D omp_get_default_device (); > int id =3D omp_get_initial_device (); > - void *p , *q; > + int x; > + void *p, *q; > + > + q =3D (void *) &x; > > if (d < 0 || d >=3D omp_get_num_devices ()) > d =3D id; > @@ -18,7 +21,7 @@ main () > if (omp_target_associate_ptr (q, p, sizeof (int), 0, d) !=3D 0) > return 0; > > - if (omp_get_mapped_ptr (q, -1) !=3D NULL) > + if (omp_get_mapped_ptr (q, -5) !=3D NULL) > abort (); > > if (omp_get_mapped_ptr (q, omp_get_num_devices () + 1) !=3D NULL) > @@ -27,6 +30,9 @@ main () > if (omp_get_mapped_ptr (q, id) !=3D q) > abort (); > > + if (omp_get_mapped_ptr (q, omp_initial_device) !=3D q) > + abort (); > + > if (omp_get_mapped_ptr (q, d) !=3D p) > abort (); > > --- libgomp/testsuite/libgomp.fortran/get-mapped-ptr-1.f90.jj 2022-05-09 = 09:09:20.963464303 +0200 > +++ libgomp/testsuite/libgomp.fortran/get-mapped-ptr-1.f90 2022-06-15 = 09:43:11.632338293 +0200 > @@ -19,7 +19,7 @@ program main > if (omp_target_associate_ptr (c_loc (q), p, c_sizeof (q), & > 0_c_size_t, d) =3D=3D 0) then > > - if(c_associated (omp_get_mapped_ptr (c_loc (q), -1))) & > + if(c_associated (omp_get_mapped_ptr (c_loc (q), -5))) & > stop 1 > > if(c_associated (omp_get_mapped_ptr (c_loc (q), & > @@ -29,14 +29,18 @@ program main > if(.not. c_associated (omp_get_mapped_ptr (c_loc (q), id), c_loc (q)= )) & > stop 3 > > - if(.not. c_associated (omp_get_mapped_ptr (c_loc (q), d), p)) & > + if(.not. c_associated (omp_get_mapped_ptr (c_loc (q), omp_initial_de= vice), & > + c_loc (q))) & > stop 4 > > - if (omp_target_disassociate_ptr (c_loc (q), d) /=3D 0) & > + if(.not. c_associated (omp_get_mapped_ptr (c_loc (q), d), p)) & > stop 5 > > - if(c_associated (omp_get_mapped_ptr (c_loc (q), d))) & > + if (omp_target_disassociate_ptr (c_loc (q), d) /=3D 0) & > stop 6 > + > + if(c_associated (omp_get_mapped_ptr (c_loc (q), d))) & > + stop 7 > end if > > call omp_target_free (p, d) > > > Jakub ----------------- 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