From patchwork Fri Nov 24 12:46:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 1868144 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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 4ScFB26VBNz1yR8 for ; Fri, 24 Nov 2023 23:47:22 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6BF263857C50 for ; Fri, 24 Nov 2023 12:47:16 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id 0E2D53858D3C for ; Fri, 24 Nov 2023 12:47:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0E2D53858D3C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0E2D53858D3C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=68.232.141.98 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700830027; cv=none; b=Tyxd1/fi2MlM0FQuuGoLSsg9NseYaO4K0ENGvEtjoKUoNDPBuifMjjdKImKNcnHUTReKLMyqRyMSwqyOV++m6RCu+tTtWiUaI6uOkzxraRhi9di86in6HZMfUPG9T8Ll/rebz+/2WGLhFEHImmQ2lW/Qpvjkxl9SYROhL9P1B9Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700830027; c=relaxed/simple; bh=ckqJIUVAOLcvD19rsjtwQ+QVYUnuvrNeHe2mxEDs5Q8=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=h0d9zpUETBxV+CUbrXXkxRzSA/scuI1R6J86LpXK9CxOA2kilYl/1wd9/ANs2ayotI+ZfU+vJ/IDAX5AxSYX1dKPcF3YEHaFVt+LvJFhT+9CyP6USNhC7hHDqfclnykSetRGE6jHeb+00uZWalR50F6Us05zA+OWWa4xtbJ6aBI= ARC-Authentication-Results: i=1; server2.sourceware.org X-CSE-ConnectionGUID: NC1T9hq3Q+yxPXIoopfwYA== X-CSE-MsgGUID: ZODJ4mcuRf6CtVztmrAwmQ== X-IronPort-AV: E=Sophos;i="6.04,224,1695715200"; d="scan'208,223";a="26433609" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa2.mentor.iphmx.com with ESMTP; 24 Nov 2023 04:47:03 -0800 IronPort-SDR: OyCrqTHRNzdgr5iy4m8yU9ep81TBNWdo5YrWwg6AfStc+aFOJoKGf1bikqZLxzukVBMDbyu4BT uJokcqAKEulFMNPRzsA09MjJU50aUJaS/vemlWpB0iNCVF1mxufH/FgwrJNKMHsf09QFU0BheA wuBNaoLCO/iCLtUI59hnkXb/PqPFV2vf3SxTuqUWV3XaicXcU1WMvnh9ZYcnwTChn0F45BF4TV BuM9PLXOBx/EwUKFDocolM85O8b9+iWLUDJpl85kr9E3sSwiPjIl/fdmlGSn4xETMpFSnQBNBx 2LE= From: Thomas Schwinge To: Alexandre Oliva , CC: Tobias Burnus , Jakub Jelinek Subject: testsuite: Add 'only_for_offload_target' wrapper for 'scan-offload-tree-dump' etc. (was: drop -aux{dir,base}, revamp -dump{dir,base}) In-Reply-To: References: <874krkqte6.fsf@euler.schwinge.homeip.net> <2b76fcd8-aaa6-7f7d-9c33-0c41381df658@mentor.com> <1035fcc6-5204-9a09-a61f-4b719c82cd7f@codesourcery.com> User-Agent: Notmuch/0.29.3+94~g74c3f1b (https://notmuchmail.org) Emacs/28.2 (x86_64-pc-linux-gnu) Date: Fri, 24 Nov 2023 13:46:57 +0100 Message-ID: <87y1ens4hq.fsf@euler.schwinge.homeip.net> MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-12.mgc.mentorg.com (139.181.222.12) To svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, 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 Hi! On 2020-06-22T11:32:46-0300, Alexandre Oliva wrote: > handle dumpbase in offloading, adjust testsuite > Adjust the testsuite offload dump scanning machinery to look for dump > files named under the new conventions, iterating internally over all > configured offload targets, or recognizing libgomp's testsuite's own > iteration. Unless anyone has any suggestions, I'll early next week push the attached "testsuite: Add 'only_for_offload_target' wrapper for 'scan-offload-tree-dump' etc.". (..., and then use this in a few applicable places, to get rid of UNRESOLVEDs for GCN plus nvptx offload configurations.) 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 71d0905fb09b4eef5a2bb36287b99c04b3c00f03 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Tue, 21 Nov 2023 17:31:37 +0100 Subject: [PATCH] testsuite: Add 'only_for_offload_target' wrapper for 'scan-offload-tree-dump' etc. This allows restricting scans to one specific offload target only. gcc/ * doc/sourcebuild.texi (Final Actions): Document 'only_for_offload_target' wrapper. gcc/testsuite/ * lib/scanoffload.exp (only_for_offload_target): New 'proc'. --- gcc/doc/sourcebuild.texi | 37 +++++++++++++++++++++++++++++-- gcc/testsuite/lib/scanoffload.exp | 21 ++++++++++++++++++ 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi index eaa75f00f5c..bf8f26a080e 100644 --- a/gcc/doc/sourcebuild.texi +++ b/gcc/doc/sourcebuild.texi @@ -3431,8 +3431,8 @@ stands for zero or more unmatched lines; the whitespace after @subsubsection Scan optimization dump files These commands are available for @var{kind} of @code{tree}, @code{ltrans-tree}, -@code{offload-tree}, @code{rtl}, @code{offload-rtl}, @code{ipa}, and -@code{wpa-ipa}. +@code{offload-tree}, @code{rtl}, @code{offload-rtl}, @code{ipa}, +@code{offload-ipa}, and @code{wpa-ipa}. @table @code @item scan-@var{kind}-dump @var{regex} @var{suffix} [@{ target/xfail @var{selector} @}] @@ -3467,6 +3467,39 @@ occurrences of the string ``code has been optimized'', use: /* @{ dg-final @{ scan-tree-dump "code has been optimized" "mypass\[1-3\]" @} @} */ @end smallexample +The @code{offload-@dots{}} ones by default separately scan the dump +file of each enabled offload target. +You may use the @code{only_for_offload_target} wrapper to restrict the +scanning to one specific offload target: + +@smallexample +/* @{ dg-do link @{ target offload_target_amdgcn @} @} */ +/* @{ dg-additional-options -foffload-options=-fdump-ipa-simdclone-details @} */ +/* @{ dg-final @{ only_for_offload_target amdgcn-amdhsa scan-offload-ipa-dump @var{regex_amdgcn} simdclone @} @} */ +@end smallexample + +This test case is active if GCN offload compilation is enabled (but +potentially also additional offload targets). +The @code{simdclone} IPA dump file is (potentially) produced for all +offload targets, but only the GCN offload one is scanned. + +If a test case doesn't have a @samp{@{ target @var{selector} @}}, and +you need to scan, for example, for different @var{regex}es for each of +host and potentially several offload targets, use a pattern like this: + +@smallexample +/* @{ dg-final @{ scan-tree-dump @var{regex_host} optimized @} @} + @{ dg-final @{ only_for_offload_target amdgcn-amdhsa scan-offload-tree-dump @var{regex_amdgcn} optimized @{ target offload_target_amdgcn @} @} @} + @{ dg-final @{ only_for_offload_target nvptx-none scan-offload-tree-dump @var{regex_nvptx} optimized @{ target offload_target_nvptx @} @} @} */ +@end smallexample + +Here, unconditionally @var{regex_host} is scanned for in the host dump +file. +If GCN offloading compilation is actually enabled, @var{regex_amdgcn} +is scanned for in the GCN offload compilation dump file. +If nvptx offloading compilation is actually enabled, @var{regex_nvptx} +is scanned for in the nvptx offload compilation dump file. + @subsubsection Check for output files diff --git a/gcc/testsuite/lib/scanoffload.exp b/gcc/testsuite/lib/scanoffload.exp index 8315820d44a..c1997985528 100644 --- a/gcc/testsuite/lib/scanoffload.exp +++ b/gcc/testsuite/lib/scanoffload.exp @@ -38,6 +38,8 @@ proc scoff-adjust { args idx target } { # Wrapper for scan procs. # Argument 0 is the index of the argument to replace when calling # argument 1 with the remaining arguments. Use end-1 or end or so. +# If set, the 'global offload_target' specifies one specific offload target to +# test, otherwise iterate over all 'global offload_targets'. proc scoff { args } { set idx [lindex $args 0] set prc [lindex $args 1] @@ -59,3 +61,22 @@ proc scoff { args } { } } } + +# Wrapper so that only for a specific offload target (first argument) we +# execute a 'dg-final' command (remaining arguments). +proc only_for_offload_target { args } { + set override_offload_target [lindex $args 0] + set cmd [lreplace $args 0 0] + + global offload_target + if [info exists offload_target] { + set original_offload_target $offload_target + } + set offload_target $override_offload_target + eval $cmd + if [info exists original_offload_target] { + set offload_target $original_offload_target + } else { + unset offload_target + } +} -- 2.34.1