From patchwork Fri Feb 26 15:57:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 589154 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 7290A1402D6 for ; Sat, 27 Feb 2016 02:57:34 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=lOZBGhtp; 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:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=sKsOYyqTsWrhhMVk5YPWx1hCjyK99QrblQn2O1M/lAPSG9bLv5 TPh4MCgE0oKaGNtS0xae4fijGAM7aUxg1WnL/n9IDe7T9h2EZdp+31eODciHJ7tz ul2ByCrBJ5jmSpDItINoXK3IkuVRE+RIVx7YcNgnQW+m+jCn4WRIZCjss= 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:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=Nylwr6lZfJ+LB8N1wEzjyg3ussA=; b=lOZBGhtpgYVK32he9s69 8NTyZeiuVmmy9UuLsBHqOiJltqtjJ9gDiWx3eJciM27ayV4ftwVYLZxND4gCdj62 rkGH0euv7yLEzhHDcSX6XerMnvsSScUgN6ynIeTkVj82Aava+H37vDbkz544g9eC vPl3jBO4DYijbJ6Dp38Voqc= Received: (qmail 113509 invoked by alias); 26 Feb 2016 15:57:26 -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 113473 invoked by uid 89); 26 Feb 2016 15:57:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=grid, MSG_NOTE, msg_note, Hx-languages-length:3337 X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Fri, 26 Feb 2016 15:57:23 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 44127ACEC; Fri, 26 Feb 2016 15:57:19 +0000 (UTC) Date: Fri, 26 Feb 2016 16:57:19 +0100 From: Martin Jambor To: GCC Patches Cc: Jakub Jelinek Subject: [omp, hsa] Do not gridify simd constructs Message-ID: <20160226155719.GB3094@virgil.suse.cz> Mail-Followup-To: GCC Patches , Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes Hi, unfortunately, I have missed two execution failures when using HSA (teams-6.f90 and target1.f90), both of which are caused by not handling the simd part of combined target teams distribute parallel for simd construct. I have not really thought through how exactly should GPUs teat the simd construct in a combined construct but of course we must not miscompile. So I'd like to commit the following patch which just disallows gridification of such cases to trunk now and am working on a fix that removes the simd loop for the hsa branch. Eventually we might also want to hsa-vectorize the body even though the explicit loop is missing, but that will also mean that the HSA grid size has to shrink appropriately. Bootstrapped and tested on x86_64-linux, with and without HSA enabled. OK for trunk? Thanks, Martin 2016-02-17 Martin Jambor * omp-low.c (grid_find_ungridifiable_statement): Store problematic statements to wi->info. Also disallow omp simd constructs. (grid_target_follows_gridifiable_pattern): Use wi.info to dump reason for not gridifying. Dump special string for omp_for. --- gcc/omp-low.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/gcc/omp-low.c b/gcc/omp-low.c index fcbb3e0..989d03e 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -17241,7 +17241,7 @@ grid_find_single_omp_among_assignments (gimple_seq seq, location_t target_loc, static tree grid_find_ungridifiable_statement (gimple_stmt_iterator *gsi, bool *handled_ops_p, - struct walk_stmt_info *) + struct walk_stmt_info *wi) { *handled_ops_p = false; gimple *stmt = gsi_stmt (*gsi); @@ -17251,6 +17251,7 @@ grid_find_ungridifiable_statement (gimple_stmt_iterator *gsi, if (gimple_call_noreturn_p (as_a (stmt))) { *handled_ops_p = true; + wi->info = stmt; return error_mark_node; } break; @@ -17266,8 +17267,19 @@ grid_find_ungridifiable_statement (gimple_stmt_iterator *gsi, case GIMPLE_OMP_TARGET: case GIMPLE_OMP_ORDERED: *handled_ops_p = true; + wi->info = stmt; return error_mark_node; + case GIMPLE_OMP_FOR: + if ((gimple_omp_for_kind (stmt) & GF_OMP_FOR_SIMD) + && gimple_omp_for_combined_into_p (stmt)) + { + *handled_ops_p = true; + wi->info = stmt; + return error_mark_node; + } + break; + default: break; } @@ -17509,10 +17521,11 @@ grid_target_follows_gridifiable_pattern (gomp_target *target, tree *group_size_p struct walk_stmt_info wi; memset (&wi, 0, sizeof (wi)); - if (gimple *bad = walk_gimple_seq (gimple_omp_body (gfor), - grid_find_ungridifiable_statement, - NULL, &wi)) + if (walk_gimple_seq (gimple_omp_body (gfor), + grid_find_ungridifiable_statement, + NULL, &wi)) { + gimple *bad = (gimple *) wi.info; if (dump_enabled_p ()) { if (is_gimple_call (bad)) @@ -17520,6 +17533,11 @@ grid_target_follows_gridifiable_pattern (gomp_target *target, tree *group_size_p "Will not turn target construct into a gridified " " GPGPU kernel because the inner loop contains " "call to a noreturn function\n"); + if (gimple_code (bad) == GIMPLE_OMP_FOR) + dump_printf_loc (MSG_NOTE, tloc, + "Will not turn target construct into a gridified " + " GPGPU kernel because the inner loop contains " + "a simd construct\n"); else dump_printf_loc (MSG_NOTE, tloc, "Will not turn target construct into a gridified "