From patchwork Fri Jan 20 20:30:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 63488 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 04A82385B538 for ; Fri, 20 Jan 2023 20:30:48 +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 55C733857C5A for ; Fri, 20 Jan 2023 20:30:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 55C733857C5A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="5.97,233,1669104000"; d="scan'208,223";a="97828828" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa1.mentor.iphmx.com with ESMTP; 20 Jan 2023 12:30:22 -0800 IronPort-SDR: hhZj2+VAG+/T8aKTtGb1mut7Zdkj5I6BRJmC92XyT+TW+F7CgW0YK/23Gp05pTm/onEeRhGlYs LEdhnH5s4mpCNqNZgOpA5k3pt0n6D4km5ZfWViiFdoJTQsXXbLuSGG3y7lIjm/pJOoGYbLSLrK Dhf1+o29BeA1M/fMXlBrVwGdy+m8Rsz8VreaQ6ixxVzziXUUWDlSppqKLD3T4NS5Qi7Zdgfw0D eKha9IZiAfMdsOTZuCHvW7kpBdVxdN9rnWbwRo0f/5zx3EkhtiRaxzso/o0RgrMTmyJ7bHej2y Tw8= From: Thomas Schwinge To: CC: , Subject: [og12] nvptx: Prevent emitting duplicate declarations for '__nvptx_stacks', '__nvptx_uni' In-Reply-To: <20221219204007.2818567-2-thomas@codesourcery.com> References: <20221219204007.2818567-1-thomas@codesourcery.com> <20221219204007.2818567-2-thomas@codesourcery.com> User-Agent: Notmuch/0.29.1+93~g67ed7df (https://notmuchmail.org) Emacs/26.3 (x86_64-pc-linux-gnu) Date: Fri, 20 Jan 2023 21:30:14 +0100 Message-ID: <874jsl2bl5.fsf@dem-tschwing-1.ger.mentorg.com> MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-15.mgc.mentorg.com (139.181.222.15) To svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_PASS, 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.29 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 Sender: "Gcc-patches" Hi! On 2022-12-19T21:40:07+0100, Thomas Schwinge wrote: > As I have reported to Nvidia in 2022-12-01 'NVIDIA Incident Report (3891704): > ptxas: Duplicate declaration error: "cannot be resolved by a '.static'"', > 'ptxas' has an inscrutable error mode for duplicate declarations: > > ptxas softstack-decl-1.o, line 11; error : '.extern' variable '__nvptx_stacks' cannot be resolved by a '.static' > ptxas fatal : Ptx assembly aborted due to errors > nvptx-as: ptxas returned 255 exit status > > ptxas uniform-simt-decl-1.o, line 12; error : '.extern' variable '__nvptx_uni' cannot be resolved by a '.static' > ptxas fatal : Ptx assembly aborted due to errors > nvptx-as: ptxas returned 255 exit status > > This is inscrutable, because (a) what is "cannot be resolved by a '.static'" > supposed to tell me (there is no '.static' in PTX?), and (b) why arent't > repeated declaration just verified to match the first, but otherwise a no-op > (like in other programming languages)? For now pushed to devel/omp/gcc-12 branch in commit ea52f1ca16870e4228f8044588b1bf958d4723b0 "nvptx: Prevent emitting duplicate declarations for '__nvptx_stacks', '__nvptx_uni'", see attached. 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 ea52f1ca16870e4228f8044588b1bf958d4723b0 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Mon, 19 Dec 2022 17:19:19 +0100 Subject: [PATCH] nvptx: Prevent emitting duplicate declarations for '__nvptx_stacks', '__nvptx_uni' As I have reported to Nvidia in 2022-12-01 'NVIDIA Incident Report (3891704): ptxas: Duplicate declaration error: "cannot be resolved by a '.static'"', 'ptxas' has an inscrutable error mode for duplicate declarations: ptxas softstack-decl-1.o, line 11; error : '.extern' variable '__nvptx_stacks' cannot be resolved by a '.static' ptxas fatal : Ptx assembly aborted due to errors nvptx-as: ptxas returned 255 exit status ptxas uniform-simt-decl-1.o, line 12; error : '.extern' variable '__nvptx_uni' cannot be resolved by a '.static' ptxas fatal : Ptx assembly aborted due to errors nvptx-as: ptxas returned 255 exit status This is inscrutable, because (a) what is "cannot be resolved by a '.static'" supposed to tell me (there is no '.static' in PTX?), and (b) why arent't repeated declaration just verified to match the first, but otherwise a no-op (like in other programming languages)? gcc/ * config/nvptx/nvptx.cc (nvptx_assemble_undefined_decl): Notice '__nvptx_stacks', '__nvptx_uni' declarations. (nvptx_file_end): Don't emit duplicate declarations for those. gcc/testsuite/ * gcc.target/nvptx/softstack-decl-1.c: Make 'dg-do assemble', adjust. * gcc.target/nvptx/uniform-simt-decl-1.c: Likewise. --- gcc/ChangeLog.omp | 4 ++++ gcc/config/nvptx/nvptx.cc | 14 ++++++++++++-- gcc/testsuite/ChangeLog.omp | 4 ++++ gcc/testsuite/gcc.target/nvptx/softstack-decl-1.c | 8 ++++---- .../gcc.target/nvptx/uniform-simt-decl-1.c | 8 ++++---- 5 files changed, 28 insertions(+), 10 deletions(-) diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp index 382cd5c80c2..127b450644b 100644 --- a/gcc/ChangeLog.omp +++ b/gcc/ChangeLog.omp @@ -1,5 +1,9 @@ 2023-01-20 Thomas Schwinge + * config/nvptx/nvptx.cc (nvptx_assemble_undefined_decl): Notice + '__nvptx_stacks', '__nvptx_uni' declarations. + (nvptx_file_end): Don't emit duplicate declarations for those. + * config/nvptx/nvptx.md (nvptx_uniform_warp_check): Make fit for non-full-warp execution. diff --git a/gcc/config/nvptx/nvptx.cc b/gcc/config/nvptx/nvptx.cc index da735cf82ff..9c284ed5b01 100644 --- a/gcc/config/nvptx/nvptx.cc +++ b/gcc/config/nvptx/nvptx.cc @@ -181,9 +181,11 @@ static GTY(()) tree global_lock_var; /* True if any function references __nvptx_stacks. */ static bool need_softstack_decl; +static bool have_softstack_decl; /* True if any function references __nvptx_uni. */ static bool need_unisimt_decl; +static bool have_unisimt_decl; static int nvptx_mach_max_workers (); @@ -2572,6 +2574,13 @@ nvptx_assemble_undefined_decl (FILE *file, const char *name, const_tree decl) TREE_TYPE (decl), size ? tree_to_shwi (size) : 0, DECL_ALIGN (decl), true); nvptx_assemble_decl_end (); + + static tree softstack_id = get_identifier ("__nvptx_stacks"); + static tree unisimt_id = get_identifier ("__nvptx_uni"); + if (DECL_NAME (decl) == softstack_id) + have_softstack_decl = true; + else if (DECL_NAME (decl) == unisimt_id) + have_unisimt_decl = true; } /* Output a pattern for a move instruction. */ @@ -6052,7 +6061,7 @@ nvptx_file_end (void) write_shared_buffer (asm_out_file, gang_private_shared_sym, gang_private_shared_align, gang_private_shared_size); - if (need_softstack_decl) + if (need_softstack_decl && !have_softstack_decl) { write_var_marker (asm_out_file, false, true, "__nvptx_stacks"); /* 32 is the maximum number of warps in a block. Even though it's an @@ -6061,7 +6070,8 @@ nvptx_file_end (void) fprintf (asm_out_file, ".extern .shared .u%d __nvptx_stacks[32];\n", POINTER_SIZE); } - if (need_unisimt_decl) + + if (need_unisimt_decl && !have_unisimt_decl) { write_var_marker (asm_out_file, false, true, "__nvptx_uni"); fprintf (asm_out_file, ".extern .shared .u32 __nvptx_uni[32];\n"); diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp index 5b3d9fe416b..c942c34dc70 100644 --- a/gcc/testsuite/ChangeLog.omp +++ b/gcc/testsuite/ChangeLog.omp @@ -1,5 +1,9 @@ 2023-01-20 Thomas Schwinge + * gcc.target/nvptx/softstack-decl-1.c: Make 'dg-do assemble', + adjust. + * gcc.target/nvptx/uniform-simt-decl-1.c: Likewise. + * gcc.target/nvptx/softstack-decl-1.c: New. * gcc.target/nvptx/uniform-simt-decl-1.c: Likewise. diff --git a/gcc/testsuite/gcc.target/nvptx/softstack-decl-1.c b/gcc/testsuite/gcc.target/nvptx/softstack-decl-1.c index c502eacc1b3..2415f6adb1f 100644 --- a/gcc/testsuite/gcc.target/nvptx/softstack-decl-1.c +++ b/gcc/testsuite/gcc.target/nvptx/softstack-decl-1.c @@ -1,4 +1,4 @@ -/* { dg-do compile } */ +/* { dg-do assemble } */ /* { dg-options {-save-temps -O0 -msoft-stack} } */ extern void *__nvptx_stacks[32] __attribute__((shared,nocommon)); @@ -14,7 +14,7 @@ void *f() return stack_array[5]; } -/* The implicit (via 'need_softstack_decl') and explicit declarations of - '__nvptx_stacks' are both emitted: - { dg-final { scan-assembler-times {(?n)\.extern .* __nvptx_stacks\[32\];} 2 } } +/* Of the implicit (via 'need_softstack_decl') and explicit declarations of + '__nvptx_stacks', only one is emitted: + { dg-final { scan-assembler-times {(?n)\.extern .* __nvptx_stacks\[32\];} 1 } } */ diff --git a/gcc/testsuite/gcc.target/nvptx/uniform-simt-decl-1.c b/gcc/testsuite/gcc.target/nvptx/uniform-simt-decl-1.c index 486456ab243..5a975bdb269 100644 --- a/gcc/testsuite/gcc.target/nvptx/uniform-simt-decl-1.c +++ b/gcc/testsuite/gcc.target/nvptx/uniform-simt-decl-1.c @@ -1,4 +1,4 @@ -/* { dg-do compile } */ +/* { dg-do assemble } */ /* { dg-options {-save-temps -O0 -muniform-simt} } */ extern unsigned __nvptx_uni[32] __attribute__((shared,nocommon)); @@ -23,7 +23,7 @@ int f (void) MEMMODEL_RELAXED); } -/* The implicit (via 'need_unisimt_decl') and explicit declarations of - '__nvptx_uni' are both emitted: - { dg-final { scan-assembler-times {(?n)\.extern .* __nvptx_uni\[32\];} 2 } } +/* Of the implicit (via 'need_unisimt_decl') and explicit declarations of + '__nvptx_uni', only one is emitted: + { dg-final { scan-assembler-times {(?n)\.extern .* __nvptx_uni\[32\];} 1 } } */ -- 2.25.1