From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa1.mentor.iphmx.com (esa1.mentor.iphmx.com [68.232.129.153]) by sourceware.org (Postfix) with ESMTPS id C3C9E385734B for ; Wed, 5 Apr 2023 12:31:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C3C9E385734B 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.98,319,1673942400"; d="scan'208";a="1691541" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa1.mentor.iphmx.com with ESMTP; 05 Apr 2023 04:31:25 -0800 IronPort-SDR: MBaBmnfRMuCkhHTe83EtbHNtmEwaQu80eJo9lDGfxoHZhYkj4Oc8NIm4LENbg9wvcC38OMi9uP UPaV7aKqf/+AC2h6cw2VZuCoV9yG1pkHNWKCW9oUm2HkB5T1AUMUU21ak4jhfk11gWqDylBico zsZ3ZyBEGUsH0nhOyi1n5Eoivu0KqamrGAiN/Pkdy3ebOPVSInzgaDsnbCSfBNjYCo+OnKBkJd mt/wmDy84Bqo16tgH3yHmNj0pL03NSiES77QWTq9lhzWxnM3nWTlcSIjzFPNVXlnHsftyrthf7 Zr8= Date: Wed, 5 Apr 2023 13:31:14 +0100 From: Julian Brown To: Thomas Schwinge CC: , Jakub Jelinek , "Tobias Burnus" Subject: Re: [PATCH] [og12] OpenMP: Constructors and destructors for "declare target" static aggregates Message-ID: <20230405133114.6810fc7e@squid.athome> In-Reply-To: <87ttxyd3od.fsf@euler.schwinge.homeip.net> References: <20230327185430.3217374-1-julian@codesourcery.com> <87ttxyd3od.fsf@euler.schwinge.homeip.net> Organization: Siemens Embedded X-Mailer: Claws Mail 4.1.1git1 (GTK 3.24.36; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: svr-orw-mbx-14.mgc.mentorg.com (147.34.90.214) To svr-ies-mbx-11.mgc.mentorg.com (139.181.222.11) X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,KAM_SHORT,SPF_HELO_PASS,SPF_PASS,TXREP,WEIRD_PORT 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: On Sun, 2 Apr 2023 11:38:42 +0200 Thomas Schwinge wrote: > Hi Julian! > > On 2023-03-27T18:54:30+0000, Julian Brown > wrote: > > This patch adds support for running constructors and destructors for > > static (file-scope) aggregates for C++ objects which are marked with > > "declare target" directives on OpenMP offload targets. > > > > At present, space is allocated on the target for such aggregates, > > but nothing ever constructs them properly, so they end up > > zero-initialised. > > So you've settled that on-device construction is the way to go, and > not on-host construction before host-to-device copy? Yes, I think there's less potential for surprises, e.g. if the constructed object contains pointers to other "declare target" data, or similar. (I think it only matters otherwise if the constructor has side-effects unrelated to the initialisation of the object -- but I don't think the spec has anything to say about that, at least as of 5.2.) > I now wonder if we didn't once have a similar issue with Fortran array > constructors, and how we solved that one. (I may be misremembering.) Not sure about that... > > Tested with offloading to AMD GCN. I will apply to the og12 branch > > shortly. > > I've pushed to devel/omp/gcc-12 branch > commit 472783f3137475b82baadac31cca31021b69aba9 > "Resolve 'error: unused parameter' in > 'gcc/cp/decl2.cc:one_static_initialization_or_destruction'", see > attached. Thank you. > But glancing at test results, I also see a good number of ICEs. > That's with '--enable-checking=yes,extra,rtl'. > > build-gcc/gcc/testsuite/g++/g++.sum | 924 > ++++++++++++--------- .../libgomp/testsuite/libgomp.sum > | 438 ++++++---- > > Those are mostly instances of: > > internal compiler error: tree check: expected omp_clause, have > tree_list in c_parse_final_cleanups, at cp/decl2.cc:5291 > > ..., but also: > > FAIL: libgomp.c++/static-aggr-constructor-destructor-1.C > (internal compiler error: tree check: expected omp_clause, have > tree_list in c_parse_final_cleanups, at cp/decl2.cc:5289) FAIL: > libgomp.c++/static-aggr-constructor-destructor-1.C (test for excess > errors) UNRESOLVED: > libgomp.c++/static-aggr-constructor-destructor-1.C compilation failed > to produce executable FAIL: > libgomp.c++/static-aggr-constructor-destructor-2.C (internal compiler > error: tree check: expected omp_clause, have tree_list in > c_parse_final_cleanups, at cp/decl2.cc:5289) FAIL: > libgomp.c++/static-aggr-constructor-destructor-2.C (test for excess > errors) UNRESOLVED: > libgomp.c++/static-aggr-constructor-destructor-2.C compilation failed > to produce executable > > That's in new 'gcc/cp/decl2.cc' code that you've added: > > 5283 while (*fvarsp) > 5284 { > 5285 tree decl = TREE_VALUE (*fvarsp); > 5286 > 5287 if (lookup_attribute ("omp declare > target", 5288 > DECL_ATTRIBUTES (decl))) 5289 fvarsp = > &OMP_CLAUSE_CHAIN (*fvarsp); 5290 else > 5291 *fvarsp = OMP_CLAUSE_CHAIN (*fvarsp); > 5292 } > > Please have a look. I believe these are fixed by: https://gcc.gnu.org/pipermail/gcc-patches/2023-April/615144.html Thanks, Julian