From patchwork Mon Feb 20 14:59:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 65278 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 50BE5383FDC2 for ; Mon, 20 Feb 2023 14:59:53 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa4.mentor.iphmx.com (esa4.mentor.iphmx.com [68.232.137.252]) by sourceware.org (Postfix) with ESMTPS id E84D53846934 for ; Mon, 20 Feb 2023 14:59:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E84D53846934 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.97,312,1669104000"; d="scan'208,223";a="97596158" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa4.mentor.iphmx.com with ESMTP; 20 Feb 2023 06:59:27 -0800 IronPort-SDR: E5DGdbLxTRySsHG+kk/9QWe02IJxWLF/zJAiK7ZAaFqoJWZVpsFN2KlwAQNBJo1KnMs0hFLacK BePVaPc5e5ArBqqwmTE8sTqoPC/vaityHa3v7WkHd2hTCioKbDzQ3VXHpTMQhbad8Gpc2PxU8p maGYO+JbpbQe0BVU1hLYyZmx1ssRrj1Ygm+1a2bXcKN20GSkCfloNz+TRJAvlUgfvllgYAnX6Y pCQNVwBYRGEW0xJG1kn00+SmtHu/yffx0NaAP+v5kdlYi1JKIfBIDx5ySuV7d7EQ0RgYYxS/vr SKk= From: Thomas Schwinge To: Andrew Stubbs , Tobias Burnus , Subject: Prototype 'GOMP_enable_pinned_mode' (was: [PATCH 08/17] openmp: -foffload-memory=pinned) In-Reply-To: <397f6b84-9d45-379a-5402-76a8ac11f08e@codesourcery.com> References: <8011a994bb38db60f37127880b0fc682564f6e8d.1657188329.git.ams@codesourcery.com> <397f6b84-9d45-379a-5402-76a8ac11f08e@codesourcery.com> User-Agent: Notmuch/0.29.3+94~g74c3f1b (https://notmuchmail.org) Emacs/28.2 (x86_64-pc-linux-gnu) Date: Mon, 20 Feb 2023 15:59:21 +0100 Message-ID: <87ilfwxu0m.fsf@euler.schwinge.homeip.net> MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-11.mgc.mentorg.com (139.181.222.11) To svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham 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: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi! On 2022-07-07T23:18:03+0100, Andrew Stubbs wrote: > On 07/07/2022 12:54, Tobias Burnus wrote: >> 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? I agree. (But I'm not working on that, for avoidance of doubt.) >> (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. Until then, let's at least document/verify 'GOMP_enable_pinned_mode'; I've pushed to devel/omp/gcc-12 commit 9657d906869e098340c23118c2eb8592d9e77ac5 "Prototype 'GOMP_enable_pinned_mode'", see attached. Grüße Thomas ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955 From 9657d906869e098340c23118c2eb8592d9e77ac5 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Mon, 20 Feb 2023 15:29:44 +0100 Subject: [PATCH] Prototype 'GOMP_enable_pinned_mode' Fix-up for og12 commit 842df187487f5b16ae29bbe7e9acd79661a9df48 "openmp: -foffload-memory=pinned". No functional change. libgomp/ * libgomp_g.h (GOMP_enable_pinned_mode): New. --- libgomp/ChangeLog.omp | 2 ++ libgomp/libgomp_g.h | 1 + 2 files changed, 3 insertions(+) diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp index c5a7860478e..e4475093055 100644 --- a/libgomp/ChangeLog.omp +++ b/libgomp/ChangeLog.omp @@ -1,5 +1,7 @@ 2023-02-20 Thomas Schwinge + * libgomp_g.h (GOMP_enable_pinned_mode): New. + * config/linux/allocator.c (linux_memspace_alloc): Add 'init0' formal parameter. Adjust all users. (linux_memspace_alloc, linux_memspace_free): Attempt to allocate diff --git a/libgomp/libgomp_g.h b/libgomp/libgomp_g.h index ece1f97a61f..fe66a53d94a 100644 --- a/libgomp/libgomp_g.h +++ b/libgomp/libgomp_g.h @@ -375,6 +375,7 @@ extern void GOMP_teams_reg (void (*) (void *), void *, unsigned, unsigned, extern void *GOMP_alloc (size_t, size_t, uintptr_t); extern void GOMP_free (void *, uintptr_t); +extern void GOMP_enable_pinned_mode (void); /* error.c */ -- 2.25.1