From patchwork Thu Apr 25 10:51:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 88982 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BC5EA384641E for ; Thu, 25 Apr 2024 10:52:32 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by sourceware.org (Postfix) with ESMTPS id B32B73846410 for ; Thu, 25 Apr 2024 10:51:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B32B73846410 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 B32B73846410 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::632 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714042319; cv=none; b=iZpFofXmAmXfJr+UIwWgnGSwJi1ENHAJWekPKJ4+wARLHEMkHnc3BVhhNL5DgqST/iCn/hgRhESXoNk6JPwmUoj7tYDPsT10xXPH9CIwU+GgKQ8+9ETSEqVm9u2n8gv7tV6waGfL4NPy4cuUqChZgxK75IKvB58RUX1Zxba0nmA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714042319; c=relaxed/simple; bh=uWXyD1XHjSZS8lrJZwDoNqVGrtCGBEYLi1qz2rp2HLY=; h=DKIM-Signature:Message-ID:Date:MIME-Version:To:From:Subject; b=QEeWhJxIeBc9cHruTEfQITtcoZOqjP+XWJEXDW8++KuWTKsXs5rkthuScTY7DCvh+6MgJIjNECCBUkYkwd1FpFABxMBbTSno7hXuNRtj/UuJWU4xfwI2QWXtXrS3N6EHbgpsywxxDHA/DgKG1yoY2lLf9EIvnYnbRXSIEmMD0hI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-a5872b74c44so93477866b.3 for ; Thu, 25 Apr 2024 03:51:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1714042314; x=1714647114; 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=Xe6BLZtlmnewJtUZn4EiVFcUPYP+vx+7+SHmWouScRI=; b=MhqrmaljcUot9O1Ac9zkc+6XSaj0SpyoGppjvfrDFbFH1VE5A5U01UYrW44MThl8BD ey1HtlyKuJUPsbkkul2Rz7aSx/y351gJyRKpSoTkxaX2kPnmQjt8Q/W1gmPz9Vr5+w5X R9eY52XmrONf/9ewPx4Wt3zrSZFKDmXR5sCmQtXDTVz95eqieSOHemMG9UqW6mQ5d5af s03Kh/m13XCxgdsVnw0FFvolgc80ZXx0fN73zQwM6ho74xkHUFPHVE68SoE5TpOK7LGb ZfVW1jk4F5Qx18WMQRONJe3sf9ub+8KPI4Sfcm8LHYpaOHfnunJULqp+UYb5P7vUt86X L/fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714042314; x=1714647114; 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=Xe6BLZtlmnewJtUZn4EiVFcUPYP+vx+7+SHmWouScRI=; b=W62mGd45qaDydZBK37H98i6bI3H0CMZuErb9cNHmjqt6VQ2e4plOSvHylDLcEl/h3/ LgPPz6ZygzbIjw4pOVYkDQMAcMPWmuS9udYyaPC9gkHyew145E78tb0dBluJjjNIOsLa d25dzMo11xvY1VZ1z8Nyw9Y5X8qEsoGKaOU+jXycm8kuv3kd94ZOLF3YssUZ1EtJSRFU LP1yI0VSYYQvo9zj2Q6dIhPIsv6a2ls7dEj15v7lySIzOyg+oigE2pLt3LpyT+8dFKdH HgojEJFlU8XSZhQ/OWaHqO1bXQDtqXGtb+T0mWMZhnw07gyqUWr3LTPkZjb5lru+ft9h zRqw== X-Gm-Message-State: AOJu0YwqfX11JzhvnWU0A9dYYLlHQX7JLGXAvN7xA/uO7GQBsz3BnYI6 9hX9eLJa8td+VXQYcWv8W/AKs2GC1wjh7syTqSskSTguCEqqj77whbgWnVVlLNX6TuQJOYNE5Ak XKII= X-Google-Smtp-Source: AGHT+IG6wlGcXEIgcGRvq9lPx45/QjrZBx0LrE4NKamzkLiw+xpm6vVFJycoSD3M7/G+wOGaGEJnDQ== X-Received: by 2002:a17:906:1d51:b0:a58:9556:3258 with SMTP id o17-20020a1709061d5100b00a5895563258mr2789553ejh.65.1714042314124; Thu, 25 Apr 2024 03:51:54 -0700 (PDT) Received: from ?IPV6:2001:16b8:3f70:8900:4ae8:8f8e:de0:b264? ([2001:16b8:3f70:8900:4ae8:8f8e:de0:b264]) by smtp.gmail.com with ESMTPSA id bx16-20020a170906a1d000b00a588bcdaf98sm2240152ejb.183.2024.04.25.03.51.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 25 Apr 2024 03:51:53 -0700 (PDT) Message-ID: <575ee46d-748c-4f2c-8f24-1ec71155ec9e@baylibre.com> Date: Thu, 25 Apr 2024 12:51:52 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: gcc-patches , Andrew Stubbs , Thomas Schwinge , Jakub Jelinek From: Tobias Burnus Subject: [patch] [gcn][nvptx] Add warning to mkoffload for 32bit host code X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, HTML_MESSAGE, KAM_SHORT, 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+patchwork=sourceware.org@gcc.gnu.org Motivated by a surprise of a colleague that with -m32, no offload dumps were created; that's because mkoffload does not process host binaries when the are 32bit (i.e. ilp32). Internally, that done as follows: The host compiler passes to 'mkoffload' the used host ABI, i.e. -foffload-abi=ilp32 or -foffload-abi=lp64 That's done via TARGET_OFFLOAD_OPTIONS, which is supported by aarch64, i386, and rs6000. While it is sensible (albeit not strictly required) that GCC requires that the host and device side agree and that only 64bit is implemented for the device side, it can be confusing that silently no offloading code is generated. Hence, I propose to print a warning in that case - as implemented in the attached patch: $ gcc -fopenmp -m32 test.c nvptx mkoffload: warning: offload code generation skipped: offloading with 32-bit host code is currently not supported gcn mkoffload: warning: offload code generation skipped: offloading with 32-bit host code is currently not supported * * * This shouldn't have any effect on offload builds using -m64 and non-offload builds – while several testcases already have issues with '-m32' when offloading is enabled or an offloading device is available. To make it not worse, this patch adds some pruning and for a subset of the failing testcases, I added code to avoids FAILS. There are some more fails, but those aren't new. Comments, remarks, suggestions? Is the mkoffload.cc part is okay? Tobias [gcn][nvptx] Add warning to mkoffload for 32bit host code mkoffload in principle handles 32bit and 64bit offload targets, but 32bit support has no been implemented. Before this patch, offloading is then silently disabled for the respective target. With the patch, the user gets a warning by mkoffload (and the programm continues to be build with out offloading code). gcc/ChangeLog: * config/gcn/mkoffload.cc (main): Warn for -foffload-abi=ilp32 that no offload code will be generated. * config/nvptx/mkoffload.cc (main): Likewise. libgomp/ChangeLog: * testsuite/lib/libgomp-dg.exp (libgomp-dg-prune): Prune warning by mkoffload that 32-bit offloading is not supported. * testsuite/libgomp.c-c++-common/requires-1.c: Silence a FAIL for 'ia32' targets as for them no offload code is generated. * testsuite/libgomp.c-c++-common/requires-3.c: Likewise. * testsuite/libgomp.c-c++-common/requires-7.c: Likewise. * testsuite/libgomp.c-c++-common/variable-not-offloaded.c: Likewise. * testsuite/libgomp.fortran/requires-1.f90: Likewise. gcc/config/gcn/mkoffload.cc | 5 ++++- gcc/config/nvptx/mkoffload.cc | 5 ++++- libgomp/testsuite/lib/libgomp-dg.exp | 3 +++ libgomp/testsuite/libgomp.c-c++-common/requires-1.c | 8 +++++--- libgomp/testsuite/libgomp.c-c++-common/requires-3.c | 8 +++++--- libgomp/testsuite/libgomp.c-c++-common/requires-7.c | 10 ++++++---- .../testsuite/libgomp.c-c++-common/variable-not-offloaded.c | 4 ++-- libgomp/testsuite/libgomp.fortran/requires-1.f90 | 8 +++++--- 8 files changed, 34 insertions(+), 17 deletions(-) diff --git a/gcc/config/gcn/mkoffload.cc b/gcc/config/gcn/mkoffload.cc index 9a438de331a..c37c269d4d2 100644 --- a/gcc/config/gcn/mkoffload.cc +++ b/gcc/config/gcn/mkoffload.cc @@ -1143,7 +1143,10 @@ main (int argc, char **argv) fatal_error (input_location, "cannot open %qs", gcn_cfile_name); /* Currently, we only support offloading in 64-bit configurations. */ - if (offload_abi == OFFLOAD_ABI_LP64) + if (offload_abi == OFFLOAD_ABI_ILP32) + warning (0, "offload code generation skipped: offloading with 32-bit host " + "code is currently not supported"); + else if (offload_abi == OFFLOAD_ABI_LP64) { const char *mko_dumpbase = concat (dumppfx, ".mkoffload", NULL); const char *hsaco_dumpbase = concat (dumppfx, ".mkoffload.hsaco", NULL); diff --git a/gcc/config/nvptx/mkoffload.cc b/gcc/config/nvptx/mkoffload.cc index 503b1abcefd..a7ff32cf8bd 100644 --- a/gcc/config/nvptx/mkoffload.cc +++ b/gcc/config/nvptx/mkoffload.cc @@ -798,7 +798,10 @@ main (int argc, char **argv) /* PR libgomp/65099: Currently, we only support offloading in 64-bit configurations. */ - if (offload_abi == OFFLOAD_ABI_LP64) + if (offload_abi == OFFLOAD_ABI_ILP32) + warning (0, "offload code generation skipped: offloading with 32-bit host " + "code is currently not supported"); + else if (offload_abi == OFFLOAD_ABI_LP64) { char *mko_dumpbase = concat (dumppfx, ".mkoffload", NULL); if (save_temps) diff --git a/libgomp/testsuite/lib/libgomp-dg.exp b/libgomp/testsuite/lib/libgomp-dg.exp index ebf78e17e6d..9c9a5f2ed4b 100644 --- a/libgomp/testsuite/lib/libgomp-dg.exp +++ b/libgomp/testsuite/lib/libgomp-dg.exp @@ -3,5 +3,8 @@ proc libgomp-dg-test { prog do_what extra_tool_flags } { } proc libgomp-dg-prune { system text } { + global additional_prunes + lappend additional_prunes "offloading with 32-bit host code is currently not supported" + return [gcc-dg-prune $system $text] } diff --git a/libgomp/testsuite/libgomp.c-c++-common/requires-1.c b/libgomp/testsuite/libgomp.c-c++-common/requires-1.c index 31996f1ecf6..2168db476c2 100644 --- a/libgomp/testsuite/libgomp.c-c++-common/requires-1.c +++ b/libgomp/testsuite/libgomp.c-c++-common/requires-1.c @@ -20,7 +20,9 @@ main (void) return 0; } -/* { dg-error "OpenMP 'requires' directive with non-identical clauses in multiple compilation units: 'unified_shared_memory' vs. 'unified_address'" "" { target *-*-* } 0 } - { dg-note {requires-1\.c' has 'unified_shared_memory'} {} { target *-*-* } 0 } - { dg-note {requires-1-aux\.c' has 'unified_address'} {} { target *-*-* } 0 } */ +/* Skip for ia32 as mkoffload requires 64 bit (and warns otherwise); cf. PR libgomp/65099. */ + +/* { dg-error "OpenMP 'requires' directive with non-identical clauses in multiple compilation units: 'unified_shared_memory' vs. 'unified_address'" "" { target { ! ia32 } } 0 } + { dg-note {requires-1\.c' has 'unified_shared_memory'} {} { target { ! ia32 } } 0 } + { dg-note {requires-1-aux\.c' has 'unified_address'} {} { target { ! ia32 } } 0 } */ /* { dg-excess-errors "Ignore messages like: errors during merging of translation units|mkoffload returned 1 exit status" } */ diff --git a/libgomp/testsuite/libgomp.c-c++-common/requires-3.c b/libgomp/testsuite/libgomp.c-c++-common/requires-3.c index a549a19ebbb..694ea6965b3 100644 --- a/libgomp/testsuite/libgomp.c-c++-common/requires-3.c +++ b/libgomp/testsuite/libgomp.c-c++-common/requires-3.c @@ -20,7 +20,9 @@ main (void) return 0; } -/* { dg-error "OpenMP 'requires' directive with non-identical clauses in multiple compilation units: 'unified_address, unified_shared_memory' vs. 'unified_address'" "" { target *-*-* } 0 } - { dg-note {requires-3\.c' has 'unified_address, unified_shared_memory'} {} { target *-*-* } 0 } - { dg-note {requires-3-aux\.c' has 'unified_address'} {} { target *-*-* } 0 } */ +/* Skip for ia32 as mkoffload requires 64 bit (and warns otherwise); cf. PR libgomp/65099. */ + +/* { dg-error "OpenMP 'requires' directive with non-identical clauses in multiple compilation units: 'unified_address, unified_shared_memory' vs. 'unified_address'" "" { target { ! ia32 } } 0 } + { dg-note {requires-3\.c' has 'unified_address, unified_shared_memory'} {} { target { ! ia32 } } 0 } + { dg-note {requires-3-aux\.c' has 'unified_address'} {} { target { ! ia32 } } 0 } */ /* { dg-excess-errors "Ignore messages like: errors during merging of translation units|mkoffload returned 1 exit status" } */ diff --git a/libgomp/testsuite/libgomp.c-c++-common/requires-7.c b/libgomp/testsuite/libgomp.c-c++-common/requires-7.c index 63afcc92b9a..305f4b34e03 100644 --- a/libgomp/testsuite/libgomp.c-c++-common/requires-7.c +++ b/libgomp/testsuite/libgomp.c-c++-common/requires-7.c @@ -20,13 +20,15 @@ main (void) return 0; } -/* { dg-error "OpenMP 'requires' directive with non-identical clauses in multiple compilation units: 'unified_shared_memory' vs. 'unified_address'" "" { target *-*-* } 0 } - { dg-note {requires-7\.c' has 'unified_shared_memory'} {} { target *-*-* } 0 } +/* Skip for ia32 as mkoffload requires 64 bit (and warns otherwise); cf. PR libgomp/65099. */ + +/* { dg-error "OpenMP 'requires' directive with non-identical clauses in multiple compilation units: 'unified_shared_memory' vs. 'unified_address'" "" { target { ! ia32 } } 0 } + { dg-note {requires-7\.c' has 'unified_shared_memory'} {} { target { ! ia32 } } 0 } TODO We're currently not streaming location information for the OpenMP directives used in 'requires-7-aux.c', so we're not seeing the source file name here (but a temporary '*.o' instead; for details, see ): - { dg-note {requires-7-aux\.c' has 'unified_address'} {} { xfail *-*-* } 0 } + { dg-note {requires-7-aux\.c' has 'unified_address'} {} { xfail { *-*-* } } 0 } ..., but we may still verify that the rest of the diagnostic is correct: - { dg-note {' has 'unified_address'} {} { target *-*-* } 0 } */ + { dg-note {' has 'unified_address'} {} { target { ! ia32 } } 0 } */ /* { dg-excess-errors "Ignore messages like: errors during merging of translation units|mkoffload returned 1 exit status" } */ 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 fe2a8b26242..707ef1798e7 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_target_nvptx || offload_target_amdgcn } } } */ +/* { dg-excess-errors "lto1, mkoffload and lto-wrapper fatal errors" { target { { ! ia32 } && { 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_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 { { ! ia32 } && { offload_target_nvptx || offload_target_amdgcn } } } } */ #pragma omp declare target void __attribute__((noinline, noclone)) diff --git a/libgomp/testsuite/libgomp.fortran/requires-1.f90 b/libgomp/testsuite/libgomp.fortran/requires-1.f90 index 9a0c33461f8..3a2eb357ebc 100644 --- a/libgomp/testsuite/libgomp.fortran/requires-1.f90 +++ b/libgomp/testsuite/libgomp.fortran/requires-1.f90 @@ -22,13 +22,15 @@ program main call foo () end -! { dg-error "OpenMP 'requires' directive with non-identical clauses in multiple compilation units: 'unified_shared_memory' vs. 'unified_address'" "" { target *-*-* } 0 } -! { dg-note {requires-1\.f90' has 'unified_shared_memory'} {} { target *-*-* } 0 } +! Skip for ia32 as mkoffload requires 64 bit (and warns otherwise); cf. PR libgomp/65099. + +! { dg-error "OpenMP 'requires' directive with non-identical clauses in multiple compilation units: 'unified_shared_memory' vs. 'unified_address'" "" { target { ! ia32 } } 0 } +! { dg-note {requires-1\.f90' has 'unified_shared_memory'} {} { target { ! ia32 } } 0 } ! TODO We're currently not streaming location information for the OpenMP ! directives used in 'requires-7-aux.c', so we're not seeing the source file ! name here (but a temporary '*.o' instead; for details, see ! ): ! { dg-note {requires-1-aux\.f90' has 'unified_address'} {} { xfail *-*-* } 0 } ! ..., but we may still verify that the rest of the diagnostic is correct: -! { dg-note {' has 'unified_address'} {} { target *-*-* } 0 } +! { dg-note {' has 'unified_address'} {} { target { ! ia32 } } 0 } ! { dg-excess-errors "Ignore messages like: errors during merging of translation units|mkoffload returned 1 exit status" }