public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [RFC]: Vectorization cost benefit changes.
@ 2015-08-21  5:29 Ajit Kumar Agarwal
  2015-08-21  8:35 ` Richard Biener
  0 siblings, 1 reply; 3+ messages in thread
From: Ajit Kumar Agarwal @ 2015-08-21  5:29 UTC (permalink / raw)
  To: Jeff Law, Richard Biener, GCC Patches, gcc
  Cc: Vinod Kathail, Shail Aditya Gupta, Vidhumouli Hunsigida, Nagaraju Mekala

[-- Attachment #1: Type: text/plain, Size: 2422 bytes --]

All:

I have done the vectorization cost changes as given below. I have considered only the cost associated with the inner instead of outside.
The consideration of inside scalar and vector cost is done as the inner cost are the most cost effective than the outside cost.

         min_profitable_iters = ((scalar_single_iter_cost
                                    - vec_inside_cost) *vf);

The Scalar_single_iter_cost consider the hardcoded value 50 which is used for most of the targets and the scalar cost is multiplied
With 50. This scalar cost is subtracted with vector cost and as the scalar cost is increased the chances of vectorization is more with same
Vectorization factor  and more loops will be vectorized.

I have not changed the iteration count which is hardcoded with 50 and I will do the changes to replace the 50 with the static
Estimates of iteration count if you agree upon the below changes. 

I have ran the SPEC cpu 2000 benchmarks with the below changes for i386 targets and the significant gains are achieved with respect
To INT and FP benchmarks.

Here is the data.

Ratio of vectorization cost changes(FP benchmarks) vs Ratio of without vectorization cost changes( FP benchmarks)  = 4640.102 vs 4583.379.
Ratio of vectorization cost changes (INT benchmarks ) vs Ratio of without vectorization cost changes( INT benchmarks0 = 3812.883 vs 3778.558

Please give your feedback on the below changes for vectorization cost benefit.

diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index 422b883..35d538f 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -2987,11 +2987,8 @@ vect_estimate_min_profitable_iters (loop_vec_info loop_vinfo,
         min_profitable_iters = 1;
       else
         {
-          min_profitable_iters = ((vec_outside_cost - scalar_outside_cost) * vf
-                                 - vec_inside_cost * peel_iters_prologue
-                                  - vec_inside_cost * peel_iters_epilogue)
-                                 / ((scalar_single_iter_cost * vf)
-                                    - vec_inside_cost);
+          min_profitable_iters = ((scalar_single_iter_cost
+                                    - vec_inside_cost) *vf);

           if ((scalar_single_iter_cost * vf * min_profitable_iters)
               <= (((int) vec_inside_cost * min_profitable_iters)

Thanks & Regards
Ajit

[-- Attachment #2: vect.diff --]
[-- Type: application/octet-stream, Size: 874 bytes --]

diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index 422b883..35d538f 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -2987,11 +2987,8 @@ vect_estimate_min_profitable_iters (loop_vec_info loop_vinfo,
         min_profitable_iters = 1;
       else
         {
-          min_profitable_iters = ((vec_outside_cost - scalar_outside_cost) * vf
-				  - vec_inside_cost * peel_iters_prologue
-                                  - vec_inside_cost * peel_iters_epilogue)
-                                 / ((scalar_single_iter_cost * vf)
-                                    - vec_inside_cost);
+          min_profitable_iters = ((scalar_single_iter_cost  
+                                    - vec_inside_cost) *vf);
 
           if ((scalar_single_iter_cost * vf * min_profitable_iters)
               <= (((int) vec_inside_cost * min_profitable_iters)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC]: Vectorization cost benefit changes.
  2015-08-21  5:29 [RFC]: Vectorization cost benefit changes Ajit Kumar Agarwal
@ 2015-08-21  8:35 ` Richard Biener
  2015-08-21  9:23   ` Ajit Kumar Agarwal
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Biener @ 2015-08-21  8:35 UTC (permalink / raw)
  To: Ajit Kumar Agarwal
  Cc: Jeff Law, GCC Patches, gcc, Vinod Kathail, Shail Aditya Gupta,
	Vidhumouli Hunsigida, Nagaraju Mekala

On Fri, Aug 21, 2015 at 7:18 AM, Ajit Kumar Agarwal
<ajit.kumar.agarwal@xilinx.com> wrote:
> All:
>
> I have done the vectorization cost changes as given below. I have considered only the cost associated with the inner instead of outside.
> The consideration of inside scalar and vector cost is done as the inner cost are the most cost effective than the outside cost.

I think you are confused about what the variables cost are associated
to.  You are changing a place that computes also the cost
for non-outer-loop-vectorization so your patch is clearly not applicable.

vec_outside_cost is the cost of setting up invariants for example.
All costs apply to the "outer" loop - if there is a nested loop
inside that loop its costs are folded into the "outer" loop cost
already at this stage.

So I think your analysis is simply wrong and thus your patch.

You need to find another place to fix inner loop cost.

Richard.

>          min_profitable_iters = ((scalar_single_iter_cost
>                                     - vec_inside_cost) *vf);
>
> The Scalar_single_iter_cost consider the hardcoded value 50 which is used for most of the targets and the scalar cost is multiplied
> With 50. This scalar cost is subtracted with vector cost and as the scalar cost is increased the chances of vectorization is more with same
> Vectorization factor  and more loops will be vectorized.
>
> I have not changed the iteration count which is hardcoded with 50 and I will do the changes to replace the 50 with the static
> Estimates of iteration count if you agree upon the below changes.
>
> I have ran the SPEC cpu 2000 benchmarks with the below changes for i386 targets and the significant gains are achieved with respect
> To INT and FP benchmarks.
>
> Here is the data.
>
> Ratio of vectorization cost changes(FP benchmarks) vs Ratio of without vectorization cost changes( FP benchmarks)  = 4640.102 vs 4583.379.
> Ratio of vectorization cost changes (INT benchmarks ) vs Ratio of without vectorization cost changes( INT benchmarks0 = 3812.883 vs 3778.558
>
> Please give your feedback on the below changes for vectorization cost benefit.
>
> diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
> index 422b883..35d538f 100644
> --- a/gcc/tree-vect-loop.c
> +++ b/gcc/tree-vect-loop.c
> @@ -2987,11 +2987,8 @@ vect_estimate_min_profitable_iters (loop_vec_info loop_vinfo,
>          min_profitable_iters = 1;
>        else
>          {
> -          min_profitable_iters = ((vec_outside_cost - scalar_outside_cost) * vf
> -                                 - vec_inside_cost * peel_iters_prologue
> -                                  - vec_inside_cost * peel_iters_epilogue)
> -                                 / ((scalar_single_iter_cost * vf)
> -                                    - vec_inside_cost);
> +          min_profitable_iters = ((scalar_single_iter_cost
> +                                    - vec_inside_cost) *vf);
>
>            if ((scalar_single_iter_cost * vf * min_profitable_iters)
>                <= (((int) vec_inside_cost * min_profitable_iters)
>
> Thanks & Regards
> Ajit

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [RFC]: Vectorization cost benefit changes.
  2015-08-21  8:35 ` Richard Biener
@ 2015-08-21  9:23   ` Ajit Kumar Agarwal
  0 siblings, 0 replies; 3+ messages in thread
From: Ajit Kumar Agarwal @ 2015-08-21  9:23 UTC (permalink / raw)
  To: Richard Biener
  Cc: Jeff Law, GCC Patches, gcc, Vinod Kathail, Shail Aditya Gupta,
	Vidhumouli Hunsigida, Nagaraju Mekala



-----Original Message-----
From: Richard Biener [mailto:richard.guenther@gmail.com] 
Sent: Friday, August 21, 2015 2:03 PM
To: Ajit Kumar Agarwal
Cc: Jeff Law; GCC Patches; gcc@gcc.gnu.org; Vinod Kathail; Shail Aditya Gupta; Vidhumouli Hunsigida; Nagaraju Mekala
Subject: Re: [RFC]: Vectorization cost benefit changes.

On Fri, Aug 21, 2015 at 7:18 AM, Ajit Kumar Agarwal <ajit.kumar.agarwal@xilinx.com> wrote:
> All:
>
> I have done the vectorization cost changes as given below. I have considered only the cost associated with the inner instead of outside.
> The consideration of inside scalar and vector cost is done as the inner cost are the most cost effective than the outside cost.

>>I think you are confused about what the variables cost are associated to.  You are changing a place that computes also the cost for non-outer-loop->>vectorization so your patch is clearly not applicable.

>>vec_outside_cost is the cost of setting up invariants for example.
>>All costs apply to the "outer" loop - if there is a nested loop inside that loop its costs are folded into the "outer" loop cost already at this stage.

>>So I think your analysis is simply wrong and thus your patch.

>>You need to find another place to fix inner loop cost.

Thanks for your valuable suggestions and feedback. I will certainly look into it.

Thanks & Regards
Ajit
Richard.

>          min_profitable_iters = ((scalar_single_iter_cost
>                                     - vec_inside_cost) *vf);
>
> The Scalar_single_iter_cost consider the hardcoded value 50 which is 
> used for most of the targets and the scalar cost is multiplied With 
> 50. This scalar cost is subtracted with vector cost and as the scalar cost is increased the chances of vectorization is more with same Vectorization factor  and more loops will be vectorized.
>
> I have not changed the iteration count which is hardcoded with 50 and 
> I will do the changes to replace the 50 with the static Estimates of iteration count if you agree upon the below changes.
>
> I have ran the SPEC cpu 2000 benchmarks with the below changes for 
> i386 targets and the significant gains are achieved with respect To INT and FP benchmarks.
>
> Here is the data.
>
> Ratio of vectorization cost changes(FP benchmarks) vs Ratio of without vectorization cost changes( FP benchmarks)  = 4640.102 vs 4583.379.
> Ratio of vectorization cost changes (INT benchmarks ) vs Ratio of 
> without vectorization cost changes( INT benchmarks0 = 3812.883 vs 
> 3778.558
>
> Please give your feedback on the below changes for vectorization cost benefit.
>
> diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index 
> 422b883..35d538f 100644
> --- a/gcc/tree-vect-loop.c
> +++ b/gcc/tree-vect-loop.c
> @@ -2987,11 +2987,8 @@ vect_estimate_min_profitable_iters (loop_vec_info loop_vinfo,
>          min_profitable_iters = 1;
>        else
>          {
> -          min_profitable_iters = ((vec_outside_cost - scalar_outside_cost) * vf
> -                                 - vec_inside_cost * peel_iters_prologue
> -                                  - vec_inside_cost * peel_iters_epilogue)
> -                                 / ((scalar_single_iter_cost * vf)
> -                                    - vec_inside_cost);
> +          min_profitable_iters = ((scalar_single_iter_cost
> +                                    - vec_inside_cost) *vf);
>
>            if ((scalar_single_iter_cost * vf * min_profitable_iters)
>                <= (((int) vec_inside_cost * min_profitable_iters)
>
> Thanks & Regards
> Ajit

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-08-21  9:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-21  5:29 [RFC]: Vectorization cost benefit changes Ajit Kumar Agarwal
2015-08-21  8:35 ` Richard Biener
2015-08-21  9:23   ` Ajit Kumar Agarwal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).