From patchwork Mon Oct 14 08:57:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 1996727 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=0fpXA3HI; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4XRrj83tTJz1xv6 for ; Mon, 14 Oct 2024 19:57:48 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 738763857000 for ; Mon, 14 Oct 2024 08:57:46 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by sourceware.org (Postfix) with ESMTPS id 7B4CC3858C66 for ; Mon, 14 Oct 2024 08:57:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7B4CC3858C66 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 7B4CC3858C66 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::335 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728896238; cv=none; b=vB5KgR+5jaGzWM8rXurK1uxppt69qeSwMRWQHtK5SW91d5el2TktlFnNYUMytwXrydelf5OSvqS0DA185U9agWO4TBljF4sr9kIrFLiCtH0Ymy2D12feuVuTc+ReKRZkiMWaQZzLoqT3VtZHYC4mOTzExNHv3V3+jAssIpMnk80= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728896238; c=relaxed/simple; bh=UWQ98l/yGVpI/PBuNm5s5KPSUp1GIEXFEhYtDC1CkJ8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=kgU/CIomZsH4EJ0lP7uXumZALowV5q+8nIY0yETUxLDAFOW06WYBnvur/bUSEeMA9733lxG30X3PApqWJoAsCy46K8RUs+uVgKE7+j7cO0U40z9SKJlZkjTmhT1B9f77DONAh+E29YLROo+1hENhvk99kH7UcM1a7xJ9bEMyUuU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-43115887867so26723115e9.0 for ; Mon, 14 Oct 2024 01:57:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1728896226; x=1729501026; darn=gcc.gnu.org; h=mime-version:message-id:date:user-agent:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=JTSAlbN6IUOTpyOu5it4GYGnpP/FbW3GE9BflHe9AUo=; b=0fpXA3HIUJTzUTSPYt1nEQ8x5V/fVFnIPpqRQzf2YWEjmyOcDQKdUe/m5NUeW9By5m AkT7rrgo/39ptyTd8z+tbuVcsT4X0On6oqNjFuoz5OWHlXpobpSaAJWv+cgr+dpC9OdG WxKCVlkgW9/VMeiSdfxOAIMIA9YcEXyICP9s+jEnmNkY9hwPu7p8TCD9Mc6nuIqVsLLR 9NNZOsfg4OoQn4AWCGRwakDTCpsgNdPqaiMFclv3YEPYiBFhG11o3yabDwVryGCyPOHb BxDm1bTsAoOqaLB1aIUX04DlSwPVD+fV9Plwk85Wi73rq/ThvfSb8c9jmkKdNhHPvm6e Ew+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728896226; x=1729501026; h=mime-version:message-id:date:user-agent:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=JTSAlbN6IUOTpyOu5it4GYGnpP/FbW3GE9BflHe9AUo=; b=W/RcGPku6r/a0ig1B8l2XRA8HXYCoLZkl79nHINKoEgjZIyM4WEmfbmRI03SZuzO8P 7sprhQFZVqbreF1otUqz8r7qg/r+Likh/ppdpclxmvGoiBxArXq4WlQSM5Nhv7ZjIJRj sMPby+0/vwrZx75192g9iKl0sMdtw7dwGPeCEfLJrkDCEH/5aFo/OT966HBGrRxo/WV2 mlreFTghufz2A99XJhFHb/1/ZwzfsP1VlJmf7rcG2qiQoD0fh0dQ3WAcN3QhB5X94CXJ DILMGauKaO5o2JpEDF+/IwMHRZPKG2/ClBF2Ho/mLLw5Wvht3a9KtPHbA2RhmuFw5JsU 3q2A== X-Forwarded-Encrypted: i=1; AJvYcCXMA6Mtq7hsXwNZvTAaXJAGt3IChhML7nZ7l14WNKmbhxCyzVM8jcXoV7QEKd29iI1UK13rSTGT6/BxKQ==@gcc.gnu.org X-Gm-Message-State: AOJu0YxmxqIL5G11L/NiLUkoQggOC1DgB6QEGE3GKDFutS00vECRyMSg mt9yFhXgvEmX926TvV+4X+aGE/28ca4llTcBVsCOlaI9yuYbm+kn8ZWj2fuOiu0= X-Google-Smtp-Source: AGHT+IEmfu1qlSC+8gihFK6LQWI3FlCAumQkZwtA9NmQWRi2+1ipafKZW7TVoVbx7TVBbGJ/nXQifw== X-Received: by 2002:a05:600c:1d99:b0:42c:b68f:38fb with SMTP id 5b1f17b1804b1-4311d89150cmr88555255e9.7.1728896226118; Mon, 14 Oct 2024 01:57:06 -0700 (PDT) Received: from euler.schwinge.ddns.net (p200300c8b733b9005e8fc6f38b6af531.dip0.t-ipconnect.de. [2003:c8:b733:b900:5e8f:c6f3:8b6a:f531]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-431183565b9sm114537325e9.29.2024.10.14.01.57.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 01:57:05 -0700 (PDT) From: Thomas Schwinge To: Tobias Burnus , gcc-patches@gcc.gnu.org Cc: fortran@gcc.gnu.org, Jakub Jelinek Subject: Fortran: Use OpenACC's acc_on_device builtin, fix OpenMP' __builtin_is_initial_device: Revert 'gimple_fold_builtin_acc_on_device' change In-Reply-To: <87jzeb8543.fsf@euler.schwinge.ddns.net> References: <27b9bc80-8a5a-43c1-a528-04cdf08a1bf7@baylibre.com> <26fba4a3-a601-40a7-95d9-d9178de6ec52@baylibre.com> <7ad21f30-cdc4-4842-bd6c-2f845fc4dd74@baylibre.com> <87jzeb8543.fsf@euler.schwinge.ddns.net> User-Agent: Notmuch/0.30+8~g47a4bad (https://notmuchmail.org) Emacs/29.4 (x86_64-pc-linux-gnu) Date: Mon, 14 Oct 2024 10:57:03 +0200 Message-ID: <87bjzn83kw.fsf@euler.schwinge.ddns.net> MIME-Version: 1.0 X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, 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.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 Hi! On 2024-10-14T10:23:56+0200, I wrote: > On 2024-10-13T10:21:01+0200, Tobias Burnus wrote: >> Now pushed as r15-4298-g3269a722b7a036. >>>>> * (new) For OpenACC, use a builtin for acc_on_device + actually do >>>>> compile-time optimization when offloading is not configured. > > No. 2. This resolved > PR82250 "Fortran OpenACC acc_on_device early folding", right? > (..., which you recently had duplicated as > PR116269 "[OpenACC] acc_on_device – compile-time optimization fails", > right?) > > Please: > > git mv gfortran.dg/goacc/acc_on_device-2{-off,_-fno-openacc}.f95 > > ..., and add a 's%-fno-openacc%-fno-builtin-acc_on_device' variant. > > Hmm, why can't 'gfortran.dg/goacc/acc_on_device-2.f95' be un-XFAILed? >>>>> PS: The testsuite/libgomp.oacc-c-c++-common/routine-nohost-1.c >>>>> example is not completely clear to me; however, the new optimization >>>>> causes that without offloading enabled, the dump message is not >>>>> shown. I tried to understand it better with >>>>> -fno-builtin-acc_on_device, but that then caused link errors as the >>>>> device function wasn't optimizated away, leaving me puzzled. — At >>>>> the end, I just changed the dg-* and did not try to understand the >>>>> issue. > > Why then not wait for someone else to help look into that? :-) > On 2024-10-10T10:31:13+0200, Tobias Burnus wrote: >> Fortran: Use OpenACC's acc_on_device builtin, fix OpenMP' __builtin_is_initial_device >> Extend the code to also use the builtin acc_on_device with OpenACC, >> which was previously only used in C/C++. Additionally, fix folding >> when offloading is not enabled. I don't understand the latter part: what needs to be fixed? >> gcc/ChangeLog: >> >> * gimple-fold.cc (gimple_fold_builtin_acc_on_device): Also fold >> when offloading is not configured. We already did fold, didn't we? >> --- a/gcc/gimple-fold.cc >> +++ b/gcc/gimple-fold.cc >> @@ -4190,7 +4190,7 @@ static bool >> gimple_fold_builtin_acc_on_device (gimple_stmt_iterator *gsi, tree arg0) >> { >> /* Defer folding until we know which compiler we're in. */ >> - if (symtab->state != EXPANSION) >> + if (ENABLE_OFFLOADING && symtab->state != EXPANSION) >> return false; >> >> unsigned val_host = GOMP_DEVICE_HOST; That is, I don't understand the rationale for diverging GCC's (default) '--disable-offload-targets' vs. '--enable-offload-targets=[...]' configurations here? >> --- a/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-nohost-1.c >> +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-nohost-1.c >> @@ -36,8 +36,7 @@ static int fact_nohost(int n) >> >> return fact(n); >> } >> -/* { dg-final { scan-tree-dump-times {(?n)^OpenACC routine 'fact_nohost' has 'nohost' clause\.$} 1 oaccloops { target c } } } >> - { dg-final { scan-tree-dump-times {(?n)^OpenACC routine 'int fact_nohost\(int\)' has 'nohost' clause\.$} 1 oaccloops { target { c++ && { ! offloading_enabled } } } } } >> +/* { dg-final { scan-tree-dump-times {(?n)^OpenACC routine 'fact_nohost' has 'nohost' clause\.$} 1 oaccloops { target { c && offloading_enabled } } } } >> { dg-final { scan-tree-dump-times {(?n)^OpenACC routine 'fact_nohost\(int\)' has 'nohost' clause\.$} 1 oaccloops { target { c++ && offloading_enabled } } } } >> TODO See PR101551 for 'offloading_enabled' differences. */ OK to push the attached "Fortran: Use OpenACC's acc_on_device builtin, fix OpenMP' __builtin_is_initial_device: Revert 'gimple_fold_builtin_acc_on_device' change"? Grüße Thomas From d4cf1d795a70b35082ec33315efe9e49fa6b0cbf Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Mon, 14 Oct 2024 10:45:06 +0200 Subject: [PATCH] Fortran: Use OpenACC's acc_on_device builtin, fix OpenMP' __builtin_is_initial_device: Revert 'gimple_fold_builtin_acc_on_device' change The motivation of the 'gimple_fold_builtin_acc_on_device' change in commit 3269a722b7a03613e9c4e2862bc5088c4a17cc11 "Fortran: Use OpenACC's acc_on_device builtin, fix OpenMP' __builtin_is_initial_device" is unclear, and it unnecessarily diverges GCC's (default) '--disable-offload-targets' vs. '--enable-offload-targets=[...]' configurations. PR testsuite/82250 gcc/ * gimple-fold.cc (gimple_fold_builtin_acc_on_device): Revert last change. libgomp/ * testsuite/libgomp.oacc-c-c++-common/routine-nohost-1.c: Revert last change. --- gcc/gimple-fold.cc | 2 +- libgomp/testsuite/libgomp.oacc-c-c++-common/routine-nohost-1.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc index 9a84483f9bf..942de7720fd 100644 --- a/gcc/gimple-fold.cc +++ b/gcc/gimple-fold.cc @@ -4190,7 +4190,7 @@ static bool gimple_fold_builtin_acc_on_device (gimple_stmt_iterator *gsi, tree arg0) { /* Defer folding until we know which compiler we're in. */ - if (ENABLE_OFFLOADING && symtab->state != EXPANSION) + if (symtab->state != EXPANSION) return false; unsigned val_host = GOMP_DEVICE_HOST; diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-nohost-1.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-nohost-1.c index e64711b536b..7dc7459e5fe 100644 --- a/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-nohost-1.c +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-nohost-1.c @@ -36,7 +36,8 @@ static int fact_nohost(int n) return fact(n); } -/* { dg-final { scan-tree-dump-times {(?n)^OpenACC routine 'fact_nohost' has 'nohost' clause\.$} 1 oaccloops { target { c && offloading_enabled } } } } +/* { dg-final { scan-tree-dump-times {(?n)^OpenACC routine 'fact_nohost' has 'nohost' clause\.$} 1 oaccloops { target c } } } + { dg-final { scan-tree-dump-times {(?n)^OpenACC routine 'int fact_nohost\(int\)' has 'nohost' clause\.$} 1 oaccloops { target { c++ && { ! offloading_enabled } } } } } { dg-final { scan-tree-dump-times {(?n)^OpenACC routine 'fact_nohost\(int\)' has 'nohost' clause\.$} 1 oaccloops { target { c++ && offloading_enabled } } } } TODO See PR101551 for 'offloading_enabled' differences. */ -- 2.34.1