From patchwork Wed Apr 21 17:04:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 1468772 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Received: from 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FQRjz2Y5Xz9sVt for ; Thu, 22 Apr 2021 03:04:39 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A16763891C3E; Wed, 21 Apr 2021 17:04:35 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa1.mentor.iphmx.com (esa1.mentor.iphmx.com [68.232.129.153]) by sourceware.org (Postfix) with ESMTPS id BC2D03891C3E for ; Wed, 21 Apr 2021 17:04:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BC2D03891C3E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Tobias_Burnus@mentor.com IronPort-SDR: JTBQkdlE/kluDzsEQhbxUSNekv9+PQdp98/vtXiaH1OW9kzhExdCZR6bY5r7zK6YJ0nJoIhbiG JzPnJKi/aB4rwj6QJ391ssMXIOhfp0E09zw6uQ07BchUDmTEDiIloGBI1rkD6hL4fWsI3A3yIW 2kT899n3e8ZtBI5FHEBHhEz9XVUQHuUENZr8e+D0ZnO2uB6yzi/K9PuQUBoLQfxmExHu9VWXVd XKLsTSAhz5XUSqmutB3DpAevP++zYiyPT+tHlQ5d8Rb1+twNiVQaI7WAvI5zKiQGjTAtnIX9p0 QG8= X-IronPort-AV: E=Sophos;i="5.82,240,1613462400"; d="diff'?scan'208";a="62754552" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa1.mentor.iphmx.com with ESMTP; 21 Apr 2021 09:04:30 -0800 IronPort-SDR: 58A+Jh4IechbwCLtLg35lhyrZUhflwVNZYZnP5ELyyD7FcI+6TUHHAJpZB0XHobZP2ve/fYMuS yQIIiED7In6yC5rXIdaRubWW3JyA3jWBk0qXXSWKi7F+Bta5qsMy2LdLXHR9eicTLzu0s8ai5Y n/q52XO/Phw+rpqdGcxYzWzWSMRWUCXgeVEf/6mWVn3/GvlGTjpmqh3OCUpuZ6v5xGk6q6mnoY g5Ssrd3n+l0Tjp/r17sif/++1SXToEMluO4PsZqI4Iebd4U9YWI875YhfsgcA90klV/ITWLFY6 K3M= To: gcc-patches , Jakub Jelinek From: Tobias Burnus Subject: [Patch] libgomp/testsuite: Fix checks for dg-excess-errors Message-ID: <92151547-dad5-c127-4cde-c9bbd27217f5@codesourcery.com> Date: Wed, 21 Apr 2021 19:04:17 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.9.1 MIME-Version: 1.0 Content-Language: en-US X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-02.mgc.mentorg.com (139.181.222.2) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) 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.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: , Cc: Richard Biener Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" This was brought up by Richard when testing libgomp with the GCC 11 distribution compiler, which has both nvptx and gcn enabled – but no offloading device was available. This lead to fails for: * testsuite/libgomp.c-c++-common/function-not-offloaded.c: → function (on purpose) not marked for offline → issue: dg-excess-errors by lto1/mkoffload not ignored * testsuite/libgomp.c-c++-common/variable-not-offloaded.c → likewise for variables, except that this would succeed with unified-shared memory → issue: dg-excess-errors by lto1/mkoffload not ignored * libgomp/testsuite/libgomp.c/pr86416-1.c + *-2.c → expected fail when offloading compiler does not support long double or float128 → issue: error output but dg-error/dg-excess-error not active The reason for those fails is that used effective target checks do not cover those cases correctly. Namely: * offload_device - check whether an offloading device is available & used at run time. → problem: compilation was done for the device but here no device is available * offload_device_nonshared_as → Likewise and same issue, except that also 0 is returned if the device has unified shared memory. Solution: Explicitly check for nvptx/gcn offload compilation (but ignore device availability). [Uses 'gcc -v |grep ^OFFLOAD_TARGET_NAMES=', which honors -foffload=, including -foffload=disable.] OK for mainline and GCC 11? Tested without offloading support & with nvptx & offload support (with an offloading device available). @Richard: I would be happy if you could confirm that this fixes your issue. Note: I don't know what's needed for *intelmic* - but I wouldn't be surprised if the current settings were wrong as well. (long double/float128 supported? unified shared memory? Only needed for function-not-offloaded.c? - if the latter, a check whether any OFFLOAD_TARGET_NAMES=* exists would be one option.) Tobias ----------------- Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 München Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Frank Thürauf libgomp/testsuite: Fix checks for dg-excess-errors For the tests modified below, the effective target line has to be effective when compiling for an offload target, except that variable-not-offloaded.c would compile with unified-share memory and pr86416-*.c if long double/float128 is supported. The previous check used a run-time device ability check. This new variant now enables those dg- lines when _compiling_ for nvptx or gcn. libgomp/ChangeLog: * testsuite/lib/libgomp.exp (offload_target_to_openacc_device_type): New, based on check_effective_target_offload_target_nvptx. (check_effective_target_offload_target_nvptx): Call it. (check_effective_target_offload_target_amdgcn): New. * testsuite/libgomp.c-c++-common/function-not-offloaded.c: Require target offload_target_nvptx || offload_target_amdgcn. * testsuite/libgomp.c-c++-common/variable-not-offloaded.c: Likewise. * testsuite/libgomp.c/pr86416-1.c: Likewise. * testsuite/libgomp.c/pr86416-2.c: Likewise. libgomp/testsuite/lib/libgomp.exp | 20 ++++++++++++++++---- .../libgomp.c-c++-common/function-not-offloaded.c | 2 +- .../libgomp.c-c++-common/variable-not-offloaded.c | 4 ++-- libgomp/testsuite/libgomp.c/pr86416-1.c | 4 ++-- libgomp/testsuite/libgomp.c/pr86416-2.c | 4 ++-- 5 files changed, 23 insertions(+), 11 deletions(-) diff --git a/libgomp/testsuite/lib/libgomp.exp b/libgomp/testsuite/lib/libgomp.exp index 14dcfdfd00a..467cb3cf255 100644 --- a/libgomp/testsuite/lib/libgomp.exp +++ b/libgomp/testsuite/lib/libgomp.exp @@ -340,8 +340,10 @@ proc offload_target_to_openacc_device_type { offload_target } { } } -# Return 1 if compiling for offload target nvptx. -proc check_effective_target_offload_target_nvptx { } { +# Return 1 if compiling for the specified offload target +# Takes -foffload=... into account by checking OFFLOAD_TARGET_NAMES= +# in the -v compiler output. +proc libgomp_check_effective_target_offload_target { target_name } { # Consider all actual options, including the flags passed to # 'gcc-dg-runtest', or 'gfortran-dg-runtest' (see the 'libgomp.*/*.exp' # files; in particular, '-foffload', 'libgomp.oacc-*/*.exp'), which don't @@ -354,13 +356,23 @@ proc check_effective_target_offload_target_nvptx { } { set gcc_output [libgomp_target_compile "" "" "none" $options] if [regexp "(?n)^OFFLOAD_TARGET_NAMES=(.*)" $gcc_output dummy offload_targets] { verbose "compiling for offload targets: $offload_targets" - return [string match "*:nvptx*:*" ":$offload_targets:"] + return [string match "*:$target_name*:*" ":$offload_targets:"] } - verbose "not compiling for any offload targets" + verbose "not compiling for $target_name offload target" return 0 } +# Return 1 if compiling for offload target nvptx. +proc check_effective_target_offload_target_nvptx { } { + return [libgomp_check_effective_target_offload_target "nvptx"] +} + +# Return 1 if compiling for offload target amdgcn +proc check_effective_target_offload_target_amdgcn { } { + return [libgomp_check_effective_target_offload_target "amdgcn"] +} + # Return 1 if offload device is available. proc check_effective_target_offload_device { } { return [check_runtime_nocache offload_device_available_ { diff --git a/libgomp/testsuite/libgomp.c-c++-common/function-not-offloaded.c b/libgomp/testsuite/libgomp.c-c++-common/function-not-offloaded.c index 9e59ef8864e..bc1ae68941a 100644 --- a/libgomp/testsuite/libgomp.c-c++-common/function-not-offloaded.c +++ b/libgomp/testsuite/libgomp.c-c++-common/function-not-offloaded.c @@ -1,5 +1,5 @@ /* { dg-do link } */ -/* { dg-excess-errors "unresolved symbol foo, lto1, mkoffload and lto-wrapper fatal errors" { target offload_device_nonshared_as } } */ +/* { dg-excess-errors "unresolved symbol foo, lto1, mkoffload and lto-wrapper fatal errors" { target { offload_target_nvptx || offload_target_amdgcn } } } */ /* { dg-additional-sources "function-not-offloaded-aux.c" } */ #pragma omp declare target diff --git a/libgomp/testsuite/libgomp.c-c++-common/variable-not-offloaded.c b/libgomp/testsuite/libgomp.c-c++-common/variable-not-offloaded.c index bc4b916e9a4..fe2a8b26242 100644 --- a/libgomp/testsuite/libgomp.c-c++-common/variable-not-offloaded.c +++ b/libgomp/testsuite/libgomp.c-c++-common/variable-not-offloaded.c @@ -1,7 +1,7 @@ /* { dg-do link } */ -/* { dg-excess-errors "lto1, mkoffload and lto-wrapper fatal errors" { target offload_device_nonshared_as } } */ +/* { dg-excess-errors "lto1, mkoffload and lto-wrapper fatal errors" { target { offload_target_nvptx || offload_target_amdgcn } } } */ -int var; /* { dg-error "variable 'var' has been referenced in offloaded code but hasn't been marked to be included in the offloaded code" "" { target offload_device_nonshared_as } } */ +int var; /* { dg-error "variable 'var' has been referenced in offloaded code but hasn't been marked to be included in the offloaded code" "" { target { offload_target_nvptx || offload_target_amdgcn } } } */ #pragma omp declare target void __attribute__((noinline, noclone)) diff --git a/libgomp/testsuite/libgomp.c/pr86416-1.c b/libgomp/testsuite/libgomp.c/pr86416-1.c index ad9370f78f3..6d3869264fd 100644 --- a/libgomp/testsuite/libgomp.c/pr86416-1.c +++ b/libgomp/testsuite/libgomp.c/pr86416-1.c @@ -2,8 +2,8 @@ /* { dg-require-effective-target large_long_double } */ /* PR middle-end/86416 */ -/* { dg-error "bit-precision floating-point numbers unsupported .mode '.F'." "" { target offload_device } 0 } */ -/* { dg-excess-errors "Follow-up errors from mkoffload and lto-wrapper" { target offload_device } } */ +/* { dg-error "bit-precision floating-point numbers unsupported .mode '.F'." "" { target { offload_target_nvptx || offload_target_amdgcn } } 0 } */ +/* { dg-excess-errors "Follow-up errors from mkoffload and lto-wrapper" { target { offload_target_nvptx || offload_target_amdgcn } } } */ #include /* For abort. */ diff --git a/libgomp/testsuite/libgomp.c/pr86416-2.c b/libgomp/testsuite/libgomp.c/pr86416-2.c index ec45e400f95..cffeb3f7107 100644 --- a/libgomp/testsuite/libgomp.c/pr86416-2.c +++ b/libgomp/testsuite/libgomp.c/pr86416-2.c @@ -2,8 +2,8 @@ /* { dg-add-options __float128 } */ /* PR middle-end/86416 */ -/* { dg-error "bit-precision floating-point numbers unsupported .mode '.F'." "" { target offload_device } 0 } */ -/* { dg-excess-errors "Follow-up errors from mkoffload and lto-wrapper" { target offload_device } } */ +/* { dg-error "bit-precision floating-point numbers unsupported .mode '.F'." "" { target { offload_target_nvptx || offload_target_amdgcn } } 0 } */ +/* { dg-excess-errors "Follow-up errors from mkoffload and lto-wrapper" { target { offload_target_nvptx || offload_target_amdgcn } } } */ #include /* For abort. */