From patchwork Tue Nov 19 19:28:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Ostanevich X-Patchwork-Id: 292536 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 587BD2C00A4 for ; Wed, 20 Nov 2013 06:29:11 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; q=dns; s=default; b=eDDHgFzBrr4eeFl8/6 c/E9l1eW/JBVh6Va3i1BvAxyP3/g4ND4qaP0zi0lMO8M4yJdryGmvxEjDbmjpqUC 5qKgijWjEKumscdj3GwkNcnIANfeRFEidfNEY+SuFutTNGQexa0W57vkFG6DMUMh JdSLv/18Pd5zhEU+FXqG83p3o= 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 :mime-version:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; s=default; bh=fG6xjXuDxQl5Y9bXGTkz1T3L z0Y=; b=skrGGO9QiL3H9HxZCSX4aPngubKeCeK4Czpn2fmMAJeOh5eBaU39oQ8N 0VWbg5oSGLxKzAZuXR+wGaIKf8DwJTiUoMk7D0gZa8MfbyHGl31PdKejzj+w+xkC m8hJtjLe60tfZQeeJaSmnLGpBE3x7yKv5C05fXHtzgev57ClLnI= Received: (qmail 6887 invoked by alias); 19 Nov 2013 19:29:00 -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 6864 invoked by uid 89); 19 Nov 2013 19:29:00 -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_99, FREEMAIL_FROM, RDNS_NONE, SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-lb0-f181.google.com Received: from Unknown (HELO mail-lb0-f181.google.com) (209.85.217.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 19 Nov 2013 19:28:59 +0000 Received: by mail-lb0-f181.google.com with SMTP id q8so5181973lbi.26 for ; Tue, 19 Nov 2013 11:28:49 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.152.1.234 with SMTP id 10mr19567089lap.19.1384889329247; Tue, 19 Nov 2013 11:28:49 -0800 (PST) Received: by 10.112.137.196 with HTTP; Tue, 19 Nov 2013 11:28:49 -0800 (PST) In-Reply-To: <20131119144220.GU892@tucnak.redhat.com> References: <09964d5c-192d-4f5c-bffb-09fe052c79ab@email.android.com> <20131119141127.GT892@tucnak.redhat.com> <20131119144220.GU892@tucnak.redhat.com> Date: Tue, 19 Nov 2013 23:28:49 +0400 Message-ID: Subject: Re: [gomp4 simd, RFC] Simple fix to override vectorization cost estimation. From: Sergey Ostanevich To: Jakub Jelinek Cc: Richard Biener , Richard Henderson , Yuri Rumyantsev , gcc-patches , Igor Zamyatin , Areg Melik-Adamyan X-IsSubscribed: yes ok, got it. I'm not sure if C/C++ and FORTRAN are enough? * common.opt: Added new option -fsimd-cost-model * tree-vectorizer.h (unlimited_cost_model): Interface update to rely on particular loop info * tree-vect-data-refs.c (vect_peeling_hash_insert): Update to unlimited_cost_model call according to new interface (vect_peeling_hash_choose_best_peeling): Ditto (vect_enhance_data_refs_alignment): Ditto * tree-vect-slp.c: Ditto * tree-vect-loop.c (vect_estimate_min_profitable_iters): Ditto plus issue a warning in case cost model overrides users' directive * c-family/c.opt: add openmp-simd warning * fortran/lang.opt: Ditto /* Source location */ On Tue, Nov 19, 2013 at 6:42 PM, Jakub Jelinek wrote: > On Tue, Nov 19, 2013 at 06:39:48PM +0400, Sergey Ostanevich wrote: >> > pedwarn isn't really desirable for this, you want just warning, >> > but some warning you can actually also turn off. >> > -Wopenmp-simd (and we'd use it also when we ignore #pragma omp declare simd >> > because it wasn't useful/desirable). >> >> consider a user is interested in enabling warning-as-error for this case? > > -Werror=openmp-simd will work then, this works for any named warnings. > >> can we disable the pedwarn the same way? > > pedwarn is for pedantic warnings, no standard says that #pragma omp simd > must be vectorized, or that #pragma omp simd or #pragma omp declare simd > is anything but an optimization hint, so pedwarn isn't what you are looking > for. > > Jakub diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 0026683..84911a0 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -592,6 +592,10 @@ Wold-style-definition C ObjC Var(warn_old_style_definition) Warning Warn if an old-style parameter definition is used +Wopenmp-simd +C C++ Var(openmp_simd) Warning +Warn about omp simd construct is overridden by cost model + Woverlength-strings C ObjC C++ ObjC++ Var(warn_overlength_strings) Warning LangEnabledBy(C ObjC C++ ObjC++,Wpedantic) Warn if a string is longer than the maximum portable length specified by the standard diff --git a/gcc/common.opt b/gcc/common.opt index d5971df..9fab3ae 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -2296,6 +2296,10 @@ fvect-cost-model= Common Joined RejectNegative Enum(vect_cost_model) Var(flag_vect_cost_model) Init(VECT_COST_MODEL_DEFAULT) Specifies the cost model for vectorization +fsimd-cost-model= +Common Joined RejectNegative Enum(vect_cost_model) Var(flag_simd_cost_model) Init(VECT_COST_MODEL_DEFAULT) +Specifies the cost model for vectorization in loops marked with omp simd + Enum Name(vect_cost_model) Type(enum vect_cost_model) UnknownError(unknown vectorizer cost model %qs) diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt index 5e09cbd..3fc98a6 100644 --- a/gcc/fortran/lang.opt +++ b/gcc/fortran/lang.opt @@ -257,6 +257,10 @@ Wintrinsics-std Fortran Warning Warn on intrinsics not part of the selected standard +Wopenmp-simd +Fortran Warning +Warn about omp simd construct is overridden by cost model + Wreal-q-constant Fortran Warning Warn about real-literal-constants with 'q' exponent-letter diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c index 83d1f45..977db43 100644 --- a/gcc/tree-vect-data-refs.c +++ b/gcc/tree-vect-data-refs.c @@ -1090,7 +1090,8 @@ vect_peeling_hash_insert (loop_vec_info loop_vinfo, struct data_reference *dr, *new_slot = slot; } - if (!supportable_dr_alignment && unlimited_cost_model ()) + if (!supportable_dr_alignment + && unlimited_cost_model (LOOP_VINFO_LOOP (loop_vinfo))) slot->count += VECT_MAX_COST; } @@ -1200,7 +1201,7 @@ vect_peeling_hash_choose_best_peeling (loop_vec_info loop_vinfo, res.peel_info.dr = NULL; res.body_cost_vec = stmt_vector_for_cost (); - if (!unlimited_cost_model ()) + if (!unlimited_cost_model (LOOP_VINFO_LOOP (loop_vinfo))) { res.inside_cost = INT_MAX; res.outside_cost = INT_MAX; @@ -1429,7 +1430,7 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo) vectorization factor. We do this automtically for cost model, since we calculate cost for every peeling option. */ - if (unlimited_cost_model ()) + if (unlimited_cost_model (LOOP_VINFO_LOOP (loop_vinfo))) possible_npeel_number = vf /nelements; /* Handle the aligned case. We may decide to align some other @@ -1437,7 +1438,7 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo) if (DR_MISALIGNMENT (dr) == 0) { npeel_tmp = 0; - if (unlimited_cost_model ()) + if (unlimited_cost_model (LOOP_VINFO_LOOP (loop_vinfo))) possible_npeel_number++; } diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index 86ebbd2..d360f43 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -2696,7 +2696,7 @@ vect_estimate_min_profitable_iters (loop_vec_info loop_vinfo, void *target_cost_data = LOOP_VINFO_TARGET_COST_DATA (loop_vinfo); /* Cost model disabled. */ - if (unlimited_cost_model ()) + if (unlimited_cost_model (LOOP_VINFO_LOOP (loop_vinfo))) { dump_printf_loc (MSG_NOTE, vect_location, "cost model disabled.\n"); *ret_min_profitable_niters = 0; @@ -2929,6 +2929,12 @@ vect_estimate_min_profitable_iters (loop_vec_info loop_vinfo, /* vector version will never be profitable. */ else { + if (LOOP_VINFO_LOOP (loop_vinfo)->force_vect) + { + warning (OPT_Wopenmp_simd, "Vectorization did not happen for the loop ", + "labeled as simd"); + } + if (dump_enabled_p ()) dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, "cost model: the vector iteration cost = %d " diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index 247bdfd..4b25964 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -2171,7 +2171,7 @@ vect_slp_analyze_bb_1 (basic_block bb) } /* Cost model: check if the vectorization is worthwhile. */ - if (!unlimited_cost_model () + if (!unlimited_cost_model (NULL) && !vect_bb_vectorization_profitable_p (bb_vinfo)) { if (dump_enabled_p ()) diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h index a6c5b59..fd255db 100644 --- a/gcc/tree-vectorizer.h +++ b/gcc/tree-vectorizer.h @@ -919,9 +919,12 @@ known_alignment_for_access_p (struct data_reference *data_ref_info) /* Return true if the vect cost model is unlimited. */ static inline bool -unlimited_cost_model () +unlimited_cost_model (loop_p loop) { - return flag_vect_cost_model == VECT_COST_MODEL_UNLIMITED; + return (flag_vect_cost_model == VECT_COST_MODEL_UNLIMITED + || (loop != NULL + && loop->force_vect + && flag_simd_cost_model == VECT_COST_MODEL_UNLIMITED)); }