From patchwork Mon Oct 12 17:18:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 529261 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 93D2C1402B7 for ; Tue, 13 Oct 2015 04:19:28 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=ccUSWzeX; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=Twa1byJ/oT9B90AzE e0rk6XQAe3Lh4vrltryjPpcBum3pz8ACK++49D4H8h09cCiViL07S5LPvakg8qPU RJ5fufE5HMAMNWhxjxPPDZF24cv710Z+eLKECHziU3ad/81vu4oTWBHbflyLfxl/ RNlEy2A+AKXm1eGZQE+KmX9eW0= 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 :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=xksnYRlVSzhJoTeBhVkR8L8 e2Q8=; b=ccUSWzeXjV2ZqQaSOcr5aR+I0+Z8NuzJvLLR7KGmBsQ+7k/JQL9RwnT Wxv/EA8bStq+1lGoA2JCPEUBuQzUBqNk6KWtjanLhJhtrV0tQX3yez5Vr7ucGre/ f9KiAkzVJsZegZNNCzD3hYLoC+0ImU4qNlIvbk8Pu3IN/6cOTXbM= Received: (qmail 16801 invoked by alias); 12 Oct 2015 17:19:22 -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 16783 invoked by uid 89); 12 Oct 2015 17:19:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: fencepost.gnu.org Received: from fencepost.gnu.org (HELO fencepost.gnu.org) (208.118.235.10) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 12 Oct 2015 17:19:20 +0000 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53946) by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1Zlgkn-0003fy-KQ for gcc-patches@gnu.org; Mon, 12 Oct 2015 13:19:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zlgkj-0006bI-8y for gcc-patches@gnu.org; Mon, 12 Oct 2015 13:19:17 -0400 Received: from relay1.mentorg.com ([192.94.38.131]:54154) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zlgkj-0006Zn-3Z for gcc-patches@gnu.org; Mon, 12 Oct 2015 13:19:13 -0400 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1Zlgkh-0004Sr-9G from Tom_deVries@mentor.com ; Mon, 12 Oct 2015 10:19:11 -0700 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.3.224.2; Mon, 12 Oct 2015 18:19:09 +0100 Subject: Re: [committed, gomp4] Handle sequential code in kernels region patch series To: "gcc-patches@gnu.org" References: <561BEA02.6010808@mentor.com> CC: Jakub Jelinek From: Tom de Vries Message-ID: <561BEB5F.8090605@mentor.com> Date: Mon, 12 Oct 2015 19:18:23 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <561BEA02.6010808@mentor.com> X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 192.94.38.131 On 12/10/15 19:12, Tom de Vries wrote: > Hi, > > I've committed the following patch series. > > 1 Add get_bbs_in_oacc_kernels_region > 2 Handle sequential code in kernels region > 3 Handle sequential code in kernels region - Testcases > > The patch series adds detection of whether sequential code (that is, > code in the oacc kernels region before and after the loop that is to be > parallelized), is safe to execute in parallel. > > Bootstrapped and reg-tested on x86_64. > > I'll post the patches individually, in reply to this email. This patch adds an oacc kernels infrastructure function: extern vec get_bbs_in_oacc_kernels_region (basic_block, basic_block); Thanks, - Tom Add get_bbs_in_oacc_kernels_region 2015-10-12 Tom de Vries * omp-low.c (get_bbs_in_oacc_kernels_region): New function. * omp-low.h (get_bbs_in_oacc_kernels_region): Declare. --- gcc/omp-low.c | 40 ++++++++++++++++++++++++++++++++++++++++ gcc/omp-low.h | 2 ++ 2 files changed, 42 insertions(+) diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 2289486..f6e0247 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -9959,6 +9959,46 @@ mark_loops_in_oacc_kernels_region (basic_block region_entry, loop->in_oacc_kernels_region = true; } +/* Return blocks in oacc kernels region delimited by REGION_ENTRY and + REGION_EXIT. */ + +vec +get_bbs_in_oacc_kernels_region (basic_block region_entry, + basic_block region_exit) +{ + bitmap excludes_bitmap = BITMAP_GGC_ALLOC (); + unsigned di; + basic_block bb; + + bitmap_clear (excludes_bitmap); + + /* Get all the blocks dominated by the region entry. That will include the + entire region. */ + vec dominated + = get_all_dominated_blocks (CDI_DOMINATORS, region_entry); + + bitmap_set_bit (excludes_bitmap, region_entry->index); + + /* Exclude all the blocks which are not in the region: the blocks dominated by + the region exit. */ + if (region_exit != NULL) + { + vec excludes + = get_all_dominated_blocks (CDI_DOMINATORS, region_exit); + FOR_EACH_VEC_ELT (excludes, di, bb) + bitmap_set_bit (excludes_bitmap, bb->index); + bitmap_clear_bit (excludes_bitmap, region_exit->index); + } + + vec bbs = vNULL; + + FOR_EACH_VEC_ELT (dominated, di, bb) + if (!bitmap_bit_p (excludes_bitmap, bb->index)) + bbs.safe_push (bb); + + return bbs; +} + /* Return the entry basic block of the oacc kernels region containing LOOP. */ basic_block diff --git a/gcc/omp-low.h b/gcc/omp-low.h index 62a7d4a..9f09bbc 100644 --- a/gcc/omp-low.h +++ b/gcc/omp-low.h @@ -34,6 +34,8 @@ extern tree get_omp_data_i (basic_block); extern bool oacc_kernels_region_entry_p (basic_block, gomp_target **); extern basic_block get_oacc_kernels_region_exit (basic_block); extern basic_block loop_get_oacc_kernels_region_entry (struct loop *); +extern vec get_bbs_in_oacc_kernels_region (basic_block, + basic_block); extern void replace_oacc_fn_attrib (tree, tree); extern tree build_oacc_routine_dims (tree); extern tree get_oacc_fn_attrib (tree); -- 1.9.1