From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa3.mentor.iphmx.com (esa3.mentor.iphmx.com [68.232.137.180]) by sourceware.org (Postfix) with ESMTPS id B3F283858000 for ; Mon, 24 Oct 2022 19:11:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B3F283858000 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.95,210,1661846400"; d="scan'208";a="85163297" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa3.mentor.iphmx.com with ESMTP; 24 Oct 2022 11:11:12 -0800 IronPort-SDR: i8Uxj6ifSOg/3qEqQ8YwAzUmguwfkm8FUSexSZNUX89RU8Na2gFf9d2WIKlizoKhSXmslsWAXK apcZHdvs4Sdb00zAs5NPyhK26zg8rsD4VrGpbZzeqZss361d33Bips5u3rmb+hGEXhB/+zxTgo RqUMojo+YgGglfv5IwSpHz7JMUA8M1rhzwofeQ14EnYbFeqeuPQjWGOMGPKPhP0ID+5yUIeWbU 3TeyP26lNrXFMU9l78pRMyEOGLkBms/v8o47VcHPQzJDHFqIONWKp+e7ZSSWy+W20FzHNjh8qg Hvg= From: Thomas Schwinge To: Jakub Jelinek , Tobias Burnus CC: Alexander Monakov , Subject: Re: [Patch][v5] libgomp/nvptx: Prepare for reverse-offload callback handling In-Reply-To: <87r0yxoxdh.fsf@euler.schwinge.homeip.net> References: <3f0fc49f-b07f-bee2-51a8-a5d03f1c33ed@codesourcery.com> <30e3ed49-0d14-8015-57ef-3d70b1dea69a@codesourcery.com> <3ebce406-46e4-8f98-8c53-83b61423644e@codesourcery.com> <798d7ee1-2ffa-a591-38cb-a9ad421265d0@codesourcery.com> <832946f-bb12-23d7-7d64-47b85c95125@ispras.ru> <1e56b27f-3c74-8bc2-028b-9091fa1ae7b1@codesourcery.com> <87r0yxoxdh.fsf@euler.schwinge.homeip.net> User-Agent: Notmuch/0.29.3+94~g74c3f1b (https://notmuchmail.org) Emacs/27.1 (x86_64-pc-linux-gnu) Date: Mon, 24 Oct 2022 21:11:04 +0200 Message-ID: <87o7u1ox4n.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-07.mgc.mentorg.com (139.181.222.7) To svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Tobias! On 2022-10-24T21:05:46+0200, I wrote: > On 2022-10-24T16:07:25+0200, Jakub Jelinek via Gcc-patches wrote: >> On Wed, Oct 12, 2022 at 10:55:26AM +0200, Tobias Burnus wrote: >>> libgomp/nvptx: Prepare for reverse-offload callback handling > >> Ok, thanks. > > Per commit r13-3460-g131d18e928a3ea1ab2d3bf61aa92d68a8a254609 > "libgomp/nvptx: Prepare for reverse-offload callback handling", > I'm seeing a lot of libgomp execution test regressions. Random > example, 'libgomp.c-c++-common/error-1.c': > > [...] > GOMP_OFFLOAD_run: kernel main$_omp_fn$0: launch [(teams: 1), 1, 1] = [(lanes: 32), (threads: 8), 1] > > Thread 1 "a.out" received signal SIGSEGV, Segmentation fault. > 0x00007ffff793b87d in GOMP_OFFLOAD_run (ord=3D, tgt_fn= =3D, tgt_vars=3D, args=3D) at = [...]/source-gcc/libgomp/plugin/plugin-nvptx.c:2127 > 2127 if (__atomic_load_n (&ptx_dev->rev_data->fn, __ATOMIC= _ACQUIRE) !=3D 0) > (gdb) print ptx_dev > $1 =3D (struct ptx_device *) 0x6a55a0 > (gdb) print ptx_dev->rev_data > $2 =3D (struct rev_offload *) 0xffffffff00000000 > (gdb) print ptx_dev->rev_data->fn > Cannot access memory at address 0xffffffff00000000 > > Why is it even taking this 'if (reverse_offload)' code path, which isn't > applicable to this test case (as far as I understand)? (Well, the answer > is 'bool reverse_offload =3D ptx_dev->rev_data !=3D NULL;', but why is th= at?) Well. --- a/libgomp/plugin/plugin-nvptx.c +++ b/libgomp/plugin/plugin-nvptx.c @@ -329,6 +332,7 @@ struct ptx_device pthread_mutex_t lock; } omp_stacks; + struct rev_offload *rev_data; struct ptx_device *next; }; ... but as far as I can tell, this is never initialized in 'nvptx_open_device', which does 'ptx_dev =3D GOMP_PLUGIN_malloc ([...]);'. Would the following be the correct fix (currently testing)? --- libgomp/plugin/plugin-nvptx.c +++ libgomp/plugin/plugin-nvptx.c @@ -546,6 +546,8 @@ nvptx_open_device (int n) ptx_dev->omp_stacks.size =3D 0; pthread_mutex_init (&ptx_dev->omp_stacks.lock, NULL); + ptx_dev->rev_data =3D NULL; + return ptx_dev; } Gr=C3=BC=C3=9Fe Thomas ----------------- 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