This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: vectorization cost macro TARGET_VECTORIZE_ADD_STMT_COST
- From: Ajit Kumar Agarwal <ajit dot kumar dot agarwal at xilinx dot com>
- To: Richard Biener <richard dot guenther at gmail dot com>
- Cc: Jeff Law <law at redhat dot com>, "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>, "Vinod Kathail" <vinodk at xilinx dot com>, Shail Aditya Gupta <shailadi at xilinx dot com>, Vidhumouli Hunsigida <vidhum at xilinx dot com>, Nagaraju Mekala <nmekala at xilinx dot com>
- Date: Fri, 14 Aug 2015 15:03:58 +0000
- Subject: RE: vectorization cost macro TARGET_VECTORIZE_ADD_STMT_COST
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=temperror (sender IP is 149.199.60.100) smtp.mailfrom=xilinx.com; gcc.gnu.org; dkim=none (message not signed) header.d=none;
- References: <37378DC5BCD0EE48BA4B082E0B55DFAA4295355B at XAP-PVEXMBX02 dot xlnx dot xilinx dot com> <CAFiYyc0U_wXihDFWNA3nT6zyQcJ0Rx4DY0jV9m63NwNWK08Hbw at mail dot gmail dot com>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:23
- Spamdiagnosticoutput: 1:23
-----Original Message-----
From: Richard Biener [mailto:richard.guenther@gmail.com]
Sent: Monday, August 03, 2015 2:59 PM
To: Ajit Kumar Agarwal
Cc: Jeff Law; gcc@gcc.gnu.org; Vinod Kathail; Shail Aditya Gupta; Vidhumouli Hunsigida; Nagaraju Mekala
Subject: Re: vectorization cost macro TARGET_VECTORIZE_ADD_STMT_COST
On Sun, Aug 2, 2015 at 4:13 PM, Ajit Kumar Agarwal <ajit.kumar.agarwal@xilinx.com> wrote:
> All:
>
> The definition of the following macro that determine the statement cost that adds to vectorization cost.
>
> #define TARGET_VECTORIZE_ADD_STMT_COST.
>
> In the implementation of the above macro the following is done for many vectorization supported architectures like i386, ARM.
>
> if (where == vect_body && stmt_info && stmt_in_inner_loop_p (stmt_info))
> count *= 50; /* FIXME. */
>
> I have the following questions.
>
> 1. Why the multiplication factor of 50 is choosen?
>>It's a wild guess. See tree-vect-loop.c:vect_get_single_scalar_iteration_cost.
> 2. The comment mentions that the inner loop relative to the loop being
> vectorized is added more weight. If more weight is added to the inner
> loop for the loop being vectorized, the chances of vectorizing the inner loop decreases. Why the inner loop cost is increased with relative to the loop being vectorized?
>>In fact adding more weight to the inner loop increases the chance of vectorizing it (if vectorizing the inner loop is profitable).
>>Both scalar and vector cost get biased by a factor of 50 (we assume 50 iterations of the inner loop for one iteration of the outer loop), so a non-profitable >>vectorization in the outer loop can be offsetted by profitable inner loop vectorization.
>>Yes, '50' can be improved if we actually know the iteration count of the inner loop or if we have profile-feedback.
Instead of vector and scalar cost get biased by a factor of 50, Can the benefit of vectorization calculated as follows
Benefit = scalar cost - vector cost/VF;
Cost = 0;
For ( I = 1; I < N; i++)
{
Cost = cost + (final_value - Initial value)/steps;
}
Benefit = Benefit * cost;
Where
N = No. of levels of the loop;
Final_value = Final iteration count of the loop.
Initial_value = Initial Iteration count of the loop.
Steps = steps of the iteration for the loop.
VF = vectorization factor.
Thus increase in the Levels of the loops increases the benefit of vectorization. Also if the scalar cost is more than the vectorization cost then the
Scalar cost - vector cost /VF increases with the same vectorization Factor thus increasing the benefit of vectorization.
Thanks & Regards
Ajit
Richard.
> Thanks & Regards
> Ajit