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 108AD3858CDA for ; Thu, 7 Jul 2022 22:18:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 108AD3858CDA 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,253,1650960000"; d="scan'208";a="81149951" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa1.mentor.iphmx.com with ESMTP; 07 Jul 2022 14:18:07 -0800 IronPort-SDR: CovQgvJS5WxU29CeLVObmMlyhQPgoO4kMa+aJYwcYTlGbCENBn5TGb0cnhSeJp4OB4rOSG/Ncu +a3w3qqvVgdWhUyoRcQD5XEnaouhAEwiuBZ9O28HmB/Jbp4RHegblGhHPT45O3shu8ic6y5shW LeECFYTyoJlEim5tjP6vqYDuvOLshKq3W/fZ+7umZNCeCGhCoQjKaHtCK//jRQ8Uh1w84866F4 B/dGCNqy73gKunrwsdLdKjtbTtv1pyHlGac7bZxTZcAcsSfnvgBXkMc+FBtvniqcWV5FdlvZQp GkI= Message-ID: <397f6b84-9d45-379a-5402-76a8ac11f08e@codesourcery.com> Date: Thu, 7 Jul 2022 23:18:03 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH 08/17] openmp: -foffload-memory=pinned Content-Language: en-GB To: Tobias Burnus , References: <8011a994bb38db60f37127880b0fc682564f6e8d.1657188329.git.ams@codesourcery.com> From: Andrew Stubbs In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: SVR-IES-MBX-07.mgc.mentorg.com (139.181.222.7) To svr-ies-mbx-11.mgc.mentorg.com (139.181.222.11) X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00, BODY_8BITS, 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 22:18:11 -0000 On 07/07/2022 12:54, Tobias Burnus wrote: > Hi Andrew, > > On 07.07.22 12:34, Andrew Stubbs wrote: >> Implement the -foffload-memory=pinned 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 >> without >> 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 = saved_location; >>   } >> +/* Emit a constructor function to enable -foffload-memory=pinned >> +   at runtime.  Libgomp handles the OS mode setting, but we need to >> trigger >> +   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 ...) Possibly, I had most of this done before then. I'll have a look next time I visit this patch. The Cuda-specific solution can't work this way anyway, because there's no mlockall equivalent, so I will make conditional adjustments anyway. > Likewise, the 'requires' mechanism could then also be used in '[PATCH > 16/17] amdgcn, openmp: Auto-detect USM mode and set HSA_XNACK'. No, I don't think so; that environment variable needs to be set before the libraries are loaded or it's too late. There are other ways to achieve the same thing, by leaving messages for the libgomp plugin to pick up, perhaps, but it's all extra complexity for no real gain. Andrew