From patchwork Fri Mar 1 15:23:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 1906752 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=UtA8rWWz; 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 4TmX1D47xFz23fC for ; Sat, 2 Mar 2024 02:23:43 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 30B663858401 for ; Fri, 1 Mar 2024 15:23:41 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by sourceware.org (Postfix) with ESMTPS id B6A293858C53 for ; Fri, 1 Mar 2024 15:23:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B6A293858C53 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 B6A293858C53 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::62c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709306600; cv=none; b=U/+t9vgbCzkycGtZI3x8JDHf61nRlex66cUwKwJpmNJVdfVAbmwwSzwyDTxBr/kXt14zmh56QiaamOvd1JS8Vegj0SccMpIhoePfafsD9ws5z9XATEevNXrjrw0sSqbsUI7nCMOaRyq1/Bjb+/CpmxvEvK4Mut8LXKonMLQ5NII= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709306600; c=relaxed/simple; bh=8BZGKf8HzyFRV6NnHvjfzYohAg1n9UhB30huicRb71o=; h=DKIM-Signature:Message-ID:Date:MIME-Version:To:From:Subject; b=jR5+X8pcOG/QFqvDcyR4ba07Y94kTSxOabVlQdaMvp7TwoxaZ4GtzwU66ypON+jG8SVuyI1+pj1XhULqshJtgr6ZNRFuJHb5vgXUF+PGHiV+g46HCEqqYNiywfHk+bkXpN/YTPHNytWMOLsXJFgPeXiLKr5E1C7DkZt5aoTTRsU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-a3122b70439so384298266b.3 for ; Fri, 01 Mar 2024 07:23:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1709306596; x=1709911396; darn=gcc.gnu.org; h=subject:from:to:content-language:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=JAC4NCnBvGZmZHAm+7hO9jNTS9VWDP5cFcEmhIgmvHE=; b=UtA8rWWzhhq2kap3HbURO4YLAgUlONbpl6CD4WIef1DNcKN3MnlDb/tbGjB2o/fpVz NJqDbQPye00Y1gAEClml0ug2fZoDK9S7IkGhwOoGIibYQGzVu15fOh0cyZvhSSobKoxk SG0C7PJ1I9uFVGjJ7QEugPl5709LTFyF4bYMlXaywl9+Cs4AtKZPZhdX9CXmJBuJOwe3 j3exx9liNk17/xZ1A+UeTdLmGhoHijAo2EUrF0P45oNS95kfBStqwDDN6B36DCDMZM5q kGmtCR9Vzx9US1ma4inWr/enshjflEsR/Sgy8CXTEvs2SagzdbQsZ5vfcuVQVOYR0cry cgjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709306596; x=1709911396; h=subject:from:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=JAC4NCnBvGZmZHAm+7hO9jNTS9VWDP5cFcEmhIgmvHE=; b=pcM1Nq+ObIuO8JCF791blSmyDHWR0Lfm8d7hwGyAA+Kc75YoBaqXzCJi7YR7pA/wEV ZsWjF/Ff6a3yq6drSRbvNFOw8MOdejD/OW86p0YVtc1n4nbOGQlF4MQCemP4I8+kKdfM lbMXG/ccQ4LxauvIxBdh68TarDdMsaJUd/3bfxhRzQKhSlKVdiYGllMkgG9z6gg1/44c 7dnpvu35OaU8EWgxEneT4cANo4PAZOWnZImW3S/dsyepGS62BSADkkWguxrCIKYaIOIM RgJ3sSuzXLzfBjHDOEJ8rQV7+S0zVEXSca/htaoF5VKdQR3XeZ1ou/w212iRygAdUUYz yPpQ== X-Gm-Message-State: AOJu0YwhLn0SvLnI2jmgN5/MY2RcIWd8yTE2eQGvR4oVsLZDKWnI8y0X CvfWk+8ljiGzGPwzHuz6hFEp0JiQ2s67WrxNXvIKgda/ovLtcu7vtT/81VscnNqrQjS4OWXlNOx F64Q= X-Google-Smtp-Source: AGHT+IFDPkZjGlo8dXVTc0q+bByW4mdRVGDr+DIcZhnWlbaH3V93iJ0oyjQd1verQeXtNwb638920w== X-Received: by 2002:a17:906:c289:b0:a44:bd2:c4a with SMTP id r9-20020a170906c28900b00a440bd20c4amr1444720ejz.51.1709306596178; Fri, 01 Mar 2024 07:23:16 -0800 (PST) Received: from ?IPV6:2001:16b8:2ad9:e300:5813:eeb6:c153:9368? (200116b82ad9e3005813eeb6c1539368.dip.versatel-1u1.de. [2001:16b8:2ad9:e300:5813:eeb6:c153:9368]) by smtp.gmail.com with ESMTPSA id gx9-20020a170906f1c900b00a42ec389486sm1783384ejb.207.2024.03.01.07.23.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 01 Mar 2024 07:23:15 -0800 (PST) Message-ID: <1553974e-f8ee-4b4c-9886-692d7328de87@baylibre.com> Date: Fri, 1 Mar 2024 16:23:14 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: gcc-patches , Jakub Jelinek , Sandra Loosemore From: Tobias Burnus Subject: [Patch] invoke.texi: Add note that -foffload= does not affect device detection X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_SHORT, 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 Not very often, but do I keep running into issues (fails, segfaults) related to testing programs compiled with a GCC without offload configured and then using the system libraries. - That's equivalent to having the system compiler (or any offload compiler) and compiling with -foffload=disable. The problem is that while the program only contains host code, the run-time library still initializes devices when an API routine - such as omp_get_num_devices - is invoked. This can lead to odd bugs as target regions, obviously, will use host fallback (for any device number) but the API routines will happily operate on the actual devices, which can lead to odd errors. (Likewise issue when compiling for one offload target type and running on a system which has devices of an other type.) I assume that that's not a very common problem, but it can be rather confusing when hitting this issue. Maybe the proposed wording will help others to avoid this pitfall. (Or is this superfluous as -foffload= is not much used and, even if, no one then remembers or finds this none?) Thoughts? * * * It was not clear to me how to refer to libgomp.texi - Should it be 'libgomp' as in 'info libgomp' or the URL https://gcc.gnu.org/onlinedocs/libgomp/ (or filename of the PDF) implies? - Or as 'GNU Offloading and Multi Processing Runtime Library Manual' as named linked to at https://gcc.gnu.org/onlinedocs or on the title page of the the PDF - but that name is not repeated in the info file or the HTML file. - Or even 'GNU libgomp' to mirror a substring in the of the HTML file. I now ended up only implicitly referring that document. Aside: Shouldn't all the HTML documents start with a <h1> and <title> before the table of content? Currently, it has: <title>Top (GNU libgomp) and the body starts with

Short Table of Contents

Tobias PS: In the testsuite, it mostly happens when iterating over omp_get_num_devices() or when mixing calls to API routines with device code ('omp target', compute constructs). invoke.texi: Add note that -foffload= does not affect device detection gcc/ChangeLog: * doc/invoke.texi (-foffload): Add note that the flag does not affect whether offload devices are detected. gcc/doc/invoke.texi | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index dc5fd863ca4..4153863020b 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -2736,38 +2736,45 @@ targets using ms-abi. @opindex foffload @cindex Offloading targets @cindex OpenACC offloading targets @cindex OpenMP offloading targets @item -foffload=disable @itemx -foffload=default @itemx -foffload=@var{target-list} Specify for which OpenMP and OpenACC offload targets code should be generated. The default behavior, equivalent to @option{-foffload=default}, is to generate code for all supported offload targets. The @option{-foffload=disable} form generates code only for the host fallback, while @option{-foffload=@var{target-list}} generates code only for the specified comma-separated list of offload targets. Offload targets are specified in GCC's internal target-triplet format. You can run the compiler with @option{-v} to show the list of configured offload targets under @code{OFFLOAD_TARGET_NAMES}. +Note that this option does not affect the available offload devices detected by +the run-time library and, hence, the values returned by the OpenMP/OpenACC API +routines or access to devices using those routines. The run-time library +itself can be tuned using environment variables; in particular, to fully disable +the device detection, set the @code{OMP_TARGET_OFFLOAD} environment variable to +@code{disabled}. + @opindex foffload-options @cindex Offloading options @cindex OpenACC offloading options @cindex OpenMP offloading options @item -foffload-options=@var{options} @itemx -foffload-options=@var{target-triplet-list}=@var{options} With @option{-foffload-options=@var{options}}, GCC passes the specified @var{options} to the compilers for all enabled offloading targets. You can specify options that apply only to a specific target or targets by using the @option{-foffload-options=@var{target-list}=@var{options}} form. The @var{target-list} is a comma-separated list in the same format as for the @option{-foffload=} option. Typical command lines are @smallexample -foffload-options='-fno-math-errno -ffinite-math-only' -foffload-options=nvptx-none=-latomic -foffload-options=amdgcn-amdhsa=-march=gfx906