[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Vectorization in gcc 4.1.1
From: |
Lionel B |
Subject: |
Re: Vectorization in gcc 4.1.1 |
Date: |
Wed, 4 Jul 2007 12:42:59 +0000 (UTC) |
User-agent: |
Pan/0.131 (Ghosts: First Variation) |
On Mon, 02 Jul 2007 14:27:11 -0700, rameshk wrote:
> Hi,
>
> I was trying to get gcc to vectorize a simple loop:
>
> #include <vector>
>
> int test(double *x , int size);
Don't know what this is for.
> int test(double *x, int size)
> {
>
> int ret = 1;
> std::vector<double> v;
> v.resize(size);
> double *a = &v[0];
>
> for(int i = 0;i < size; ++i )
> {
> a[i ] = 1/x[i];
> }
Why not just:
std::vector<double> v(size);
for(int i = 0;i < size; ++i )
{
v[i] = 1/x[i];
}
>
> }
>
> I get the following message:
>
> test.cpp:13: note: not vectorized: can't determine dependence between
> *D.11390_169 and *D.11389_164
> test.cpp:13: note: vectorized 0 loops in function.
I think the problem is that x could be aliased to &v[0]. Try it with
std::valarray<double> (which is guaranteed not to be aliased) and it
should vectorise.
--
Lionel B