From patchwork Wed Jun 12 11:42:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Stubbs X-Patchwork-Id: 1946815 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=JS11RszX; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VzkFF0GJnz20Wd for ; Wed, 12 Jun 2024 21:43:13 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 333FB3882053 for ; Wed, 12 Jun 2024 11:43:11 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by sourceware.org (Postfix) with ESMTPS id E46D13877021 for ; Wed, 12 Jun 2024 11:42:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E46D13877021 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=baylibre.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E46D13877021 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::334 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718192557; cv=none; b=tzBrh5lJOYT5emQYQq2T/kQRhfrWJjdXsEFL180Lm4fzQIksYCoQxlkt6wOIANqlhh7DpKa3Kzmodgczu39Ou7PW57mK82OnMvCI4azi0uEqNrkBXNMYU1YhdelNAlMxDEE3mW0ALaPO+1IF6GCOkSbeve8nVREeywYWC8yCo0k= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718192557; c=relaxed/simple; bh=rpp0wAJEZMVyW1+CD1UE8pgqceR8rFXhGtrNUh9pESw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=HVRm4IOVsabyIP0WT04MB+CDBTTepT/I+tEVoGZFXmKhtEAiKOu5jVCnDJV/4K1ZrLVU9e5zySc0hgKiMrOH68F53sL2wgcVsRKQEHAObA2+mtBlNST12kdr+REkCNdUwszN5006y1ziz4jrPuclxFe/wPwyITOgp9pSUTNCnIY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-421757d217aso47444435e9.3 for ; Wed, 12 Jun 2024 04:42:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1718192553; x=1718797353; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hD1PRTGrbjS5BO4hwunh8RPV8Q6+mTKV5OJby39ZosM=; b=JS11RszXu9wnFvljNLfyPpT8Hb5n8q15gyvcwI3YFnfsaHBhvgZXhEZAnWnaL2utJY bbs9IaLt0WjL036b/L8cylB7VZTpNJ6RaeoAak7mi96Lb+utdOaqqccjbZARQRmjBxOG fNJBKafK6L5EuH/M2PmBQN/6TGxFLxae0oyddIms+E08lSHTQnYsog1+KXurbqggqkXP Aqz33bBWB3aVBHcLFaPJUd14Nh8Y/EDtSO43J6ODwu+yoNt9ZNIbOKZYmEVjKfWkqeDY v6HOln4ksofQy3FHOjfY7wJ5ZD0uxe7dYs3QwT+o6mg7Tm5dSVrBka6qf/cr9aOqauAn zeJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718192553; x=1718797353; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hD1PRTGrbjS5BO4hwunh8RPV8Q6+mTKV5OJby39ZosM=; b=LkcJYPYLKQnglVFP3/fGXWdgVvHgIbThvglGU6ln1LoDq0/rX0lIYhMB1WkkMO+58A yiLqMXOloLBk4Hcwc59eRpEuvArjNqR4IW4ZbHcsIvvnZCDsMb2LKwQ8Pn3UpFENCPru fw6IE81uLz1pR9nCYkhAWboI3YcC9DEMULhaQjR2cKg0ggOWMeT5VouK9XUj57qHG/cV +RJdUwHytYs+oakroewrs1UIInfp63PZ7IzHNcaOiWs6cCSis/KB78fQaOVnKsln9IOm zA0nxTeXBal+nC1dgkx5hck8CzACgrgONk77CI5c2f48WfNsSeBfSv8V93NdQJKNhMEI L/yA== X-Gm-Message-State: AOJu0YwZl7lTX1vK8j4Ugjjq2u7333ILOMBFszoBsI25EUbvZpT/6mLn z8PD7zn5hQIXcLHmNcN47mfMKb9DdbsyFJjm26hvoch+LaCGOh0X8LX/mLyv7M1j/9FV32EUeoK LiZk= X-Google-Smtp-Source: AGHT+IFJL26jePNnnWW1XwR9pI0l0S7PxS+W56YSEqoae3dmAf9iMszWB1gyIN4JW7K1K67aHjBdRQ== X-Received: by 2002:a05:600c:42c4:b0:422:6755:17de with SMTP id 5b1f17b1804b1-422867c90f9mr15528375e9.41.1718192553346; Wed, 12 Jun 2024 04:42:33 -0700 (PDT) Received: from arnold.baylibre (laubervilliers-658-1-213-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-42286fe75ebsm23366235e9.9.2024.06.12.04.42.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 04:42:32 -0700 (PDT) From: Andrew Stubbs To: gcc-patches@gcc.gnu.org Cc: tburnus@baylibre.com, jakub@redhat.com Subject: [PATCH v5 3/6] openmp: Add -foffload-memory Date: Wed, 12 Jun 2024 11:42:20 +0000 Message-ID: <20240612114223.2206735-4-ams@baylibre.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240612114223.2206735-1-ams@baylibre.com> References: <20240612114223.2206735-1-ams@baylibre.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Add a new option. It's inactive until I add some follow-up patches. gcc/ChangeLog: * common.opt: Add -foffload-memory and its enum values. * coretypes.h (enum offload_memory): New. * doc/invoke.texi: Document -foffload-memory. --- gcc/common.opt | 16 ++++++++++++++++ gcc/coretypes.h | 7 +++++++ gcc/doc/invoke.texi | 16 +++++++++++++++- 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/gcc/common.opt b/gcc/common.opt index 2c078fdd1f8..e874e88d3e1 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -2349,6 +2349,22 @@ Enum(offload_abi) String(ilp32) Value(OFFLOAD_ABI_ILP32) EnumValue Enum(offload_abi) String(lp64) Value(OFFLOAD_ABI_LP64) +foffload-memory= +Common Joined RejectNegative Enum(offload_memory) Var(flag_offload_memory) Init(OFFLOAD_MEMORY_NONE) +-foffload-memory=[none|unified|pinned] Use an offload memory optimization. + +Enum +Name(offload_memory) Type(enum offload_memory) UnknownError(Unknown offload memory option %qs) + +EnumValue +Enum(offload_memory) String(none) Value(OFFLOAD_MEMORY_NONE) + +EnumValue +Enum(offload_memory) String(unified) Value(OFFLOAD_MEMORY_UNIFIED) + +EnumValue +Enum(offload_memory) String(pinned) Value(OFFLOAD_MEMORY_PINNED) + fomit-frame-pointer Common Var(flag_omit_frame_pointer) Optimization When possible do not generate stack frames. diff --git a/gcc/coretypes.h b/gcc/coretypes.h index 1ac6f0abea3..938cfa93753 100644 --- a/gcc/coretypes.h +++ b/gcc/coretypes.h @@ -218,6 +218,13 @@ enum offload_abi { OFFLOAD_ABI_ILP32 }; +/* Types of memory optimization for an offload device. */ +enum offload_memory { + OFFLOAD_MEMORY_NONE, + OFFLOAD_MEMORY_UNIFIED, + OFFLOAD_MEMORY_PINNED +}; + /* Types of profile update methods. */ enum profile_update { PROFILE_UPDATE_SINGLE, diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 45115b5fbed..eb0f8b4a58d 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -202,7 +202,7 @@ in the following sections. -fno-builtin -fno-builtin-@var{function} -fcond-mismatch -ffreestanding -fgimple -fgnu-tm -fgnu89-inline -fhosted -flax-vector-conversions -fms-extensions --foffload=@var{arg} -foffload-options=@var{arg} +-foffload=@var{arg} -foffload-options=@var{arg} -foffload-memory=@var{arg} -fopenacc -fopenacc-dim=@var{geom} -fopenmp -fopenmp-simd -fopenmp-target-simd-clone@r{[}=@var{device-type}@r{]} -fpermitted-flt-eval-methods=@var{standard} @@ -2786,6 +2786,20 @@ Typical command lines are -foffload-options=amdgcn-amdhsa=-march=gfx906 @end smallexample +@opindex foffload-memory +@cindex OpenMP offloading memory modes +@item -foffload-memory=none +@itemx -foffload-memory=unified +@itemx -foffload-memory=pinned +Enable a memory optimization mode to use with OpenMP. The default behavior, +@option{-foffload-memory=none}, is to do nothing special (unless enabled via +a requires directive in the code). @option{-foffload-memory=unified} is +equivalent to @code{#pragma omp requires unified_shared_memory}. +@option{-foffload-memory=pinned} forces all host memory to be pinned (this +mode may require the user to increase the ulimit setting for locked memory). +All translation units must select the same setting to avoid undefined +behavior. + @opindex fopenacc @cindex OpenACC accelerator programming @item -fopenacc