From patchwork Thu Apr 5 08:41:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 895309 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-475904-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mentor.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="u1iHtz1k"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40GxCP5B3mz9ry1 for ; Thu, 5 Apr 2018 18:42:08 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=sR4uhVknfbRZ+GJwwWpRZnmM68PPZAD2XV/G7a8qrcA2ZL9Idu Y1/V71EJL/V7PH+UHmle8SJQKwb3vxenXYRYl/xWYXqVsgYCVpoc8UTQSstG0r0Q PXpWc2phuM3uURc7dTQx5eg6KTIY1lxumn09Sm3Pb1QbKkqP/GjpCI3yw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=RfMdXBuPU5UsDhgbYO9mFBnLoHs=; b=u1iHtz1k2It32T1+jyWI mnOCbLKkkrFYouKYdKgV3bPNPN3wF3eDv2sjsWQQc6LTtXtwaA7hJOKOSvKoJInp 0e7NER1E67YJnlXf0b1TQMNkTcmZGUFQrM86CLbLRBF+8Ds7OjEp/cmVhRuW5yo/ 1gFvJMHnUpWxukTcTyGXRLo= Received: (qmail 96386 invoked by alias); 5 Apr 2018 08:41:59 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 96307 invoked by uid 89); 5 Apr 2018 08:41:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS, URIBL_RED autolearn=ham version=3.3.2 spammy= X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 05 Apr 2018 08:41:54 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-MBX-04.mgc.mentorg.com) by relay1.mentorg.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) id 1f40Su-0004Ac-D4 from Tom_deVries@mentor.com for gcc-patches@gcc.gnu.org; Thu, 05 Apr 2018 01:41:52 -0700 Received: from [137.202.13.181] (137.202.0.87) by SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) with Microsoft SMTP Server (TLS) id 15.0.1320.4; Thu, 5 Apr 2018 09:41:48 +0100 To: GCC Patches From: Tom de Vries Subject: [nvptx, PR85204] Fix neutering of bb with only cond jump Message-ID: Date: Thu, 5 Apr 2018 10:41:48 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) Hi, When compiling the test-case in the patch, the following ptx code is generated: ... $L4: @ %r91 bra.uni $L24; selp.u32 %r95,1,0,%r80; st.shared.u32 [__worker_bcast],%r95; $L25: $L24: @ %r92 bra $L25; ... There's an eternal loop starting at the last insn, and unsurprisingly the test-case hangs. The last insn is a vector neutering branch, which should have been inserted after the worker neutering branch (the first insn). In other words, we want: ... $L4: @ %r91 bra.uni $L24; + @ %r92 bra $L25; selp.u32 %r95,1,0,%r80; st.shared.u32 [__worker_bcast],%r95; $L25: $L24: - @ %r92 bra $L25; ... This minimal stage4 patch fixes this problem. [ I filed a PR85223 "[nvptx] nvptx_single needs rewrite" for a stage1 rewrite of nvptx_single. ] Build x86_64 with nvptx accelerator, and tested libgomp. Committed to stage4 trunk. Thanks, - Tom [nvptx] Fix neutering of bb with only cond jump 2018-04-05 Tom de Vries PR target/85204 * config/nvptx/nvptx.c (nvptx_single): Fix neutering of bb with only cond jump. * testsuite/libgomp.oacc-c-c++-common/broadcast-1.c: New test. --- gcc/config/nvptx/nvptx.c | 6 ++- .../libgomp.oacc-c-c++-common/broadcast-1.c | 49 ++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c index b2b150f..a9a3053 100644 --- a/gcc/config/nvptx/nvptx.c +++ b/gcc/config/nvptx/nvptx.c @@ -4048,6 +4048,7 @@ nvptx_single (unsigned mask, basic_block from, basic_block to) /* Insert the vector test inside the worker test. */ unsigned mode; rtx_insn *before = tail; + rtx_insn *neuter_start = NULL; for (mode = GOMP_DIM_WORKER; mode <= GOMP_DIM_VECTOR; mode++) if (GOMP_DIM_MASK (mode) & skip_mask) { @@ -4065,7 +4066,10 @@ nvptx_single (unsigned mask, basic_block from, basic_block to) br = gen_br_true (pred, label); else br = gen_br_true_uni (pred, label); - emit_insn_before (br, head); + if (neuter_start) + neuter_start = emit_insn_after (br, neuter_start); + else + neuter_start = emit_insn_before (br, head); LABEL_NUSES (label)++; if (tail_branch) diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/broadcast-1.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/broadcast-1.c new file mode 100644 index 0000000..ca0d37b --- /dev/null +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/broadcast-1.c @@ -0,0 +1,49 @@ +/* Ensure that worker-vector state conditional expressions are + properly handled by the nvptx backend. */ + +#include +#include + + +#define N 1024 + +int A[N][N] ; + +void test(int x) +{ +#pragma acc parallel num_gangs(16) num_workers(4) vector_length(32) copyout(A) + { +#pragma acc loop gang + for(int j=0;j