From patchwork Mon Feb 6 17:22:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Stubbs X-Patchwork-Id: 53442 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2357162wrn; Mon, 6 Feb 2023 09:23:16 -0800 (PST) X-Google-Smtp-Source: AK7set/GGHI7p+k8n39h8XY8S4FFYFJboaUczt69KoQ0exDQqwph1RYbcFxa5y8ax36ZUcqd0JaE X-Received: by 2002:a17:906:3896:b0:87b:db53:3829 with SMTP id q22-20020a170906389600b0087bdb533829mr87302ejd.46.1675704195933; Mon, 06 Feb 2023 09:23:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675704195; cv=none; d=google.com; s=arc-20160816; b=zLI4tQ+68vxAyUtFJ45hfO0+Of21YbrA/jTX8Zj5DhkUdElm/Denikh82K56dfySjo k51g8TyuLq+ADQTYonwBU5DOEyYTIBKBMmzUy5wv0zFzu8PnYnUOh1r0XoxsVZcb2pLv 4VNVsK5mPIap2PwuOuDo7aSzlo5v8PNfKjk0rfMupTd8l/MMc/+cGm8AX0A7ILP77pE+ N7pAoV93eqAqcDl0RPdXbGs79ZMItsehR1Vlnf4DlNS9RqCv+pCTaeKTRvnBZD+1tqBX avHJBXIfDcFWHyZaRI/wANzjsjTPQONlkLIqfEvqeYuvCf3e2s4Qmo5bR3Gj834678ML 60aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:to:subject:from :content-language:user-agent:mime-version:date:message-id :ironport-sdr:dmarc-filter:delivered-to; bh=BY8Db14tRISMnVO1a8m2CklK3gekEiBvWnNEGa4eM68=; b=AmUIK+9KrSiSA9qmyAHUM1rmcoOLYhA/C7H6grQZKB08UqhFbby/qgz+UKM5mEg1n5 S3TcGLkxAgWLKvKNh5bq3CriLNOSnDzkj/ygtZDlXMHzypRGCj9iQhdR3O4mARTvn8yO +9rR+GVZoAUIYeWzNQsKAblGK76YO2bZnI8ZbcJrjpH+s4EknFmREE8n134gI2oWLiUa z//k1AMsPz2vqBRCiABHpZlIbZlL9FegRzz+UTJyh9v5wNwRcTK6T2xg0j3YoXrzKStq wpA7RdIcri7fFy2UqEGkUy8f+znzgf1M6+VeqJs5lICO5UA9PEsuelKgLvdWf2htEyTs b+4A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id gi21-20020a1709070c9500b0087873092de6si13099560ejc.97.2023.02.06.09.23.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Feb 2023 09:23:15 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 279683858023 for ; Mon, 6 Feb 2023 17:23:06 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa3.mentor.iphmx.com (esa3.mentor.iphmx.com [68.232.137.180]) by sourceware.org (Postfix) with ESMTPS id 9930F3858C50 for ; Mon, 6 Feb 2023 17:22:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9930F3858C50 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,276,1669104000"; d="scan'208";a="95823992" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa3.mentor.iphmx.com with ESMTP; 06 Feb 2023 09:22:37 -0800 IronPort-SDR: AO+YxFQv2DqNvkueRli6Sh6NbwV813jvwP6Bii2zX8w1JhURgY6Fnu1+FFCAhaS0TGXJSyFJsl nrxU3gmgVu+kDgWJRbnVloIJRv4yfVYxvXsR4jj3wvh0XxfSsXhpgVpkY4wn9dhESxf9Pc1i4t vIEBcP6mYc89v8HRUIct1A2kYcbcYIpdUOVW0iMwno6ko1EhkwU09BA6k2R8zAkZZB1yEtVhVa 8l+eh4GZFNl6+KMPsjpoXFN+SqMKwOt/b8OgU01Gc3ylZll3pyq4l/pNTnL0mVhipzlk66jHyD B8A= Message-ID: <03830517-e578-4ee7-b652-e82e6b5a6614@codesourcery.com> Date: Mon, 6 Feb 2023 17:22:31 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Content-Language: en-GB From: Andrew Stubbs Subject: [committed] amdgcn: Pass -mstack-size through to runtime To: "gcc-patches@gcc.gnu.org" X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) To svr-ies-mbx-11.mgc.mentorg.com (139.181.222.11) X-Spam-Status: No, score=-12.5 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.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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757103203122543075?= X-GMAIL-MSGID: =?utf-8?q?1757103203122543075?= The -mstack-size option has been marked obsolete in favour of setting an environment variable at runtime ("GCN_STACK_SIZE"), but some testcases still need the option set or they have stack overflow. I could change them to use the envvar, but my testing setup uses remote execute which doesn't support that yet, and means I would skip my own tests (not ideal). This patch causes the testcase to automatically set GCN_STACK_SIZE itself, in a hidden constructor (only if it's not already set), and therefore bypasses the problem. I'm leaving the documentation saying -mstack-size is obsolete because this fix only works for offload tests, and it's still not the preferred user solution. Committed to mainline. I'll backport to OG12 shortly. Andrew amdgcn: Pass -mstack-size through to runtime But only for the offload case. gcc/ChangeLog: * config/gcn/mkoffload.cc (gcn_stack_size): New global variable. (process_asm): Create a constructor for GCN_STACK_SIZE. (main): Parse the -mstack-size option. diff --git a/gcc/config/gcn/mkoffload.cc b/gcc/config/gcn/mkoffload.cc index 9c262f974be..9493f89fec3 100644 --- a/gcc/config/gcn/mkoffload.cc +++ b/gcc/config/gcn/mkoffload.cc @@ -117,6 +117,8 @@ uint32_t elf_arch = EF_AMDGPU_MACH_AMDGCN_GFX803; // Default GPU architecture. uint32_t elf_flags = (EF_AMDGPU_FEATURE_XNACK_ANY_V4 | EF_AMDGPU_FEATURE_SRAMECC_ANY_V4); +static int gcn_stack_size = 0; /* Zero means use default. */ + /* Delete tempfiles. */ void @@ -662,6 +664,18 @@ process_asm (FILE *in, FILE *out, FILE *cfile) } fprintf (cfile, "\n};\n\n"); + /* Set the stack size if the user configured a value. */ + if (gcn_stack_size) + fprintf (cfile, + "static __attribute__((constructor))\n" + "void configure_stack_size (void)\n" + "{\n" + " const char *val = getenv (\"GCN_STACK_SIZE\");\n" + " if (!val || val[0] == '\\0')\n" + " setenv (\"GCN_STACK_SIZE\", \"%d\", true);\n" + "}\n\n", + gcn_stack_size); + obstack_free (&fns_os, NULL); for (i = 0; i < dims_count; i++) free (dims[i].name); @@ -920,6 +934,10 @@ main (int argc, char **argv) elf_arch = EF_AMDGPU_MACH_AMDGCN_GFX908; else if (strcmp (argv[i], "-march=gfx90a") == 0) elf_arch = EF_AMDGPU_MACH_AMDGCN_GFX90a; +#define STR "-mstack-size=" + else if (startswith (argv[i], STR)) + gcn_stack_size = atoi (argv[i] + strlen (STR)); +#undef STR } if (!(fopenacc ^ fopenmp))