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 A72923858D32 for ; Thu, 7 Jul 2022 11:54:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A72923858D32 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.92,252,1650960000"; d="scan'208";a="81116783" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa1.mentor.iphmx.com with ESMTP; 07 Jul 2022 03:54:15 -0800 IronPort-SDR: /BEb8cNCOQG/MGCwua3yS4b4TrTLSDc0+W8o08IqN+7sUur55NGNVOqx6TNU9/wCUxs7zEePLY 069NrRGLsINnAUgZEwtOEsvREdlIsA8ouuFv08P4dx5iBp4SJImfRzantF7BMEOXYrY38mqwev QrzVvV3QVzro3CV0DnulPgmqgGvTogMaNm+VAPcpdvoqYXaXHMiSbA94cZYGW/wl9rKeQSUivr v3rW3/1daQiDzE1fvtK61yJ0YOBSfqu4cpwBuOKIqJtr/tcQh2AvxkOfGY55wtw/yggM7NOPMK 5I0= Message-ID: Date: Thu, 7 Jul 2022 13:54:09 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH 08/17] openmp: -foffload-memory=pinned Content-Language: en-US To: Andrew Stubbs , References: <8011a994bb38db60f37127880b0fc682564f6e8d.1657188329.git.ams@codesourcery.com> From: Tobias Burnus In-Reply-To: <8011a994bb38db60f37127880b0fc682564f6e8d.1657188329.git.ams@codesourcery.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: quoted-printable X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) To svr-ies-mbx-12.mgc.mentorg.com (139.181.222.12) X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, NICE_REPLY_A, 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: Thu, 07 Jul 2022 11:54:18 -0000 Hi Andrew, On 07.07.22 12:34, Andrew Stubbs wrote: > Implement the -foffload-memory=3Dpinned option such that libgomp is > instructed to enable fully-pinned memory at start-up. The option is > intended to provide a performance boost to certain offload programs witho= ut > modifying the code. ... > gcc/ChangeLog: > > * omp-builtins.def (BUILT_IN_GOMP_ENABLE_PINNED_MODE): New. > * omp-low.cc (omp_enable_pinned_mode): New function. > (execute_lower_omp): Call omp_enable_pinned_mode. > > libgomp/ChangeLog: > > * config/linux/allocator.c (always_pinned_mode): New variable. > (GOMP_enable_pinned_mode): New function. > (linux_memspace_alloc): Disable pinning when always_pinned_mode set= . > (linux_memspace_calloc): Likewise. > (linux_memspace_free): Likewise. > (linux_memspace_realloc): Likewise. > * libgomp.map: Add GOMP_enable_pinned_mode. > * testsuite/libgomp.c/alloc-pinned-7.c: New test. > ... ... > --- a/gcc/omp-low.cc > +++ b/gcc/omp-low.cc > @@ -14620,6 +14620,68 @@ lower_omp (gimple_seq *body, omp_context *ctx) > input_location =3D saved_location; > } > > +/* Emit a constructor function to enable -foffload-memory=3Dpinned > + at runtime. Libgomp handles the OS mode setting, but we need to trig= ger > + it by calling GOMP_enable_pinned mode before the program proper runs.= */ > + > +static void > +omp_enable_pinned_mode () Is there a reason not to use the mechanism of OpenMP's 'requires' directive for this? (Okay, I have to admit that the final patch was only committed on Monday. But still ...) It looks very similar in spirit. I don't know whether there are issues of having -foffload-memory=3Dpinned in some TU and not, but that could be handled in a similar way to GOMP_REQUIRES_TARGET_USED. For requires, omp_requires_mask is streamed out if OMP_REQUIRES_TARGET_USED and g->have_offload. (For completeness, it also requires ENABLE_OFFLOADING.) This data is read in by all lto1 (in lto-cgraph.cc) and checked for consistency. This data is then also passed on to *mkoffload.cc. And in libgomp, it is processed by GOMP_register_ver. Likewise, the 'requires' mechanism could then also be used in '[PATCH 16/17] amdgcn, openmp: Auto-detect USM mode and set HSA_XNACK'. 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