From patchwork Wed Jan 24 11:24:16 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: 865293 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-471944-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="w5FXiFvy"; 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 3zRN9j05bwz9s0g for ; Wed, 24 Jan 2018 22:24:39 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=Tja7c48AGel0vHZq1eLg+493mpI+DHshOgezq9V17A2WvyvVBM NRnPvJG9/8bU/3MSue8yo+5yRkL76KKd3h6sSwtk6SGmH7B3khHTRquW+P9SPRp4 tieh9W85ldDFh7BK+j6KAXLVMmbwtCpuoYeCTLh1Q6l7J8k7JI3BOCZ6o= 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:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=ZFpvRmEPKf47ayi55LHJJEBcnr8=; b=w5FXiFvyTIZLZ0WY/8od zF6ZXk2OlSf0CuG+DcApCDECqPO30Mzr9GRvdQ/sAFkGFMGi/4gdNnf4ec8X/xq0 iBfahN1F9SvSxaB+saaj9JDk254dXlHvhfs+fMueD6PTjWAw74f3abforjvG9EcJ f9wDh0tGey8OjlVUvHABNGg= Received: (qmail 128014 invoked by alias); 24 Jan 2018 11:24:32 -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 127936 invoked by uid 89); 24 Jan 2018 11:24:26 -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; Wed, 24 Jan 2018 11:24:22 +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 1eeJAC-0006kA-CV from Tom_deVries@mentor.com ; Wed, 24 Jan 2018 03:24:20 -0800 Received: from [137.202.13.177] (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; Wed, 24 Jan 2018 11:24:17 +0000 To: GCC Patches CC: Richard Biener From: Tom de Vries Subject: [nvptx, PR81352] Add exit insn after noreturn call for neutered threads in warp Message-ID: <61047ed2-e5e6-1b04-08d9-62b547001df2@mentor.com> Date: Wed, 24 Jan 2018 12:24:16 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.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, atm the test-case contained in this patch hangs. For the test-case we generate: ... @ %r79 bra $L18; { call _gfortran_abort; trap; exit; } $L18: ... which results in SASS code (at GOMP_NVPTX_JIT=-O4): ... /*05d8*/ @P0 BRA `(.L_18); /*05e8*/ JCAL `(_gfortran_abort); /*05f0*/ BPT.TRAP 0x1; /*05f8*/ EXIT; .L_18: ... There's no convergence point generated for the diverging branch, so we may end up executing random code after .L18 (a problem I long suspected could happen, but never observed until now). The patch adds an exit on the other path, making sure that all threads in the warp reach exit, and indeed fixing the hang: ... @ %r79 bra $L18; { call _gfortran_abort; trap; exit; } $L18: exit; ... Build and reg-tested on x86_64 with nvptx accelerator. I'll commit this shortly for stage4. Strictly speaking, this is not an 8 regression, but a wrong code bug. But I think that the code generation error seems fundamental enough, and the fix simple and localized enough, that it's stage4 permissible. Thanks, - Tom [nvptx, PR81352] Add exit insn after noreturn call for neutered threads in warp 2018-01-23 Tom de Vries PR target/81352 * config/nvptx/nvptx.c (nvptx_single): Add exit insn after noreturn call for neutered threads in warp. * config/nvptx/nvptx.md (define_insn "exit"): New insn. * testsuite/libgomp.oacc-fortran/pr81352.f90: New test. --- gcc/config/nvptx/nvptx.c | 7 ++++++- gcc/config/nvptx/nvptx.md | 5 +++++ libgomp/testsuite/libgomp.oacc-fortran/pr81352.f90 | 20 ++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c index f5bb438..3516740 100644 --- a/gcc/config/nvptx/nvptx.c +++ b/gcc/config/nvptx/nvptx.c @@ -4062,7 +4062,12 @@ nvptx_single (unsigned mask, basic_block from, basic_block to) if (tail_branch) before = emit_label_before (label, before); else - emit_label_after (label, tail); + { + rtx_insn *label_insn = emit_label_after (label, tail); + if (mode == GOMP_DIM_VECTOR && CALL_P (tail) + && find_reg_note (tail, REG_NORETURN, NULL)) + emit_insn_after (gen_exit (), label_insn); + } } /* Now deal with propagating the branch condition. */ diff --git a/gcc/config/nvptx/nvptx.md b/gcc/config/nvptx/nvptx.md index f9c087b..135479b 100644 --- a/gcc/config/nvptx/nvptx.md +++ b/gcc/config/nvptx/nvptx.md @@ -994,6 +994,11 @@ "" "") +(define_insn "exit" + [(const_int 1)] + "" + "exit;") + (define_insn "return" [(return)] "" diff --git a/libgomp/testsuite/libgomp.oacc-fortran/pr81352.f90 b/libgomp/testsuite/libgomp.oacc-fortran/pr81352.f90 new file mode 100644 index 0000000..f6969c8 --- /dev/null +++ b/libgomp/testsuite/libgomp.oacc-fortran/pr81352.f90 @@ -0,0 +1,20 @@ +! { dg-do run } + +program foo + integer :: a(3,3), l, ll + a = 0 + + !$acc parallel num_gangs (1) num_workers(1) + + do l=1,3 + !$acc loop vector + do ll=1,3 + a(l,ll) = 2 + enddo + enddo + + if (any(a(1:3,1:3).ne.2)) call abort + + !$acc end parallel + +end program foo