* Auto-vectorization of dot-product
@ 2008-03-30 12:00 Christoph Bartoschek
2008-03-31 5:49 ` Ira Rosen
0 siblings, 1 reply; 2+ messages in thread
From: Christoph Bartoschek @ 2008-03-30 12:00 UTC (permalink / raw)
To: gcc-help
Hi,
I have a simple implementation of a dot-product:
inline double dot(int dim,
double const * __restrict x,
double const * __restrict y)
{
double sum = 0.0;
for (int i = 0; i < dim; ++i) {
sum += x[i] * y[i];
}
return sum;
}
Although the Auto-vectorization site
http://gcc.gnu.org/projects/tree-ssa/vectorization.html mentions that GCC
supports auto-vectorization of the dot-product, I get the following
information from GCC 4.3
dot.C:63: note: not vectorized: unsupported use in stmt.
Other simpler loops get vectorized.
What could be wrong?
Christoph
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Auto-vectorization of dot-product
2008-03-30 12:00 Auto-vectorization of dot-product Christoph Bartoschek
@ 2008-03-31 5:49 ` Ira Rosen
0 siblings, 0 replies; 2+ messages in thread
From: Ira Rosen @ 2008-03-31 5:49 UTC (permalink / raw)
To: Christoph Bartoschek; +Cc: gcc-help
gcc-help-owner@gcc.gnu.org wrote on 30/03/2008 15:01:59:
> Hi,
>
> I have a simple implementation of a dot-product:
>
> inline double dot(int dim,
> double const * __restrict x,
> double const * __restrict y)
> {
> double sum = 0.0;
> for (int i = 0; i < dim; ++i) {
> sum += x[i] * y[i];
> }
> return sum;
> }
>
> Although the Auto-vectorization site
> http://gcc.gnu.org/projects/tree-ssa/vectorization.html mentions that GCC
> supports auto-vectorization of the dot-product, I get the following
> information from GCC 4.3
>
> dot.C:63: note: not vectorized: unsupported use in stmt.
>
> Other simpler loops get vectorized.
>
> What could be wrong?
The types. To vectorize dot-product the vectorizer looks for a specific
pattern. Here is how it is explained in tree-vect-patterns.c:
Try to find the following pattern:
type x_t, y_t;
TYPE1 prod;
TYPE2 sum = init;
loop:
sum_0 = phi <init, sum_1>
S1 x_t = ...
S2 y_t = ...
S3 x_T = (TYPE1) x_t;
S4 y_T = (TYPE1) y_t;
S5 prod = x_T * y_T;;
[S6 prod = (TYPE2) prod; #optional]
S7 sum_1 = prod + sum_0;
where 'TYPE1' is exactly double the size of type 'type', and 'TYPE2' is
the
same size of 'TYPE1' or bigger. This is a special case of a reduction
computation.
You are welcome to open a missed-optimization PR in GCC Bugzilla.
Ira
>
> Christoph
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-03-31 5:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-30 12:00 Auto-vectorization of dot-product Christoph Bartoschek
2008-03-31 5:49 ` Ira Rosen
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).