Re: Correct way to make a 16-byte aligned double* for SSE vectorization?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On 12/31/2009 03:30 AM, Benjamin Redelings I wrote:
Hi,

I am trying to figure out how to make a double* that is 16-byte aligned
in the way that SSE instructions want. Hopefully this would allow GCC to
auto-vectorize loops in a better way. The problem that I am having is
that I want a pointer to an aligned double, not an aligned pointer to a
double.

I am compiling with these options:
% gcc -c test.C -O3 -ftree-vectorizer-verbose=3 -ffast-math

According to the output of the vectorizer, none of the three ways
(below) of declaring an aligned pointer actually work. They are treated
as unaligned accesses, so presumably the location of the pointer itself
is being aligned, but it does not point to an aligned location. In
contrast, if I define an aligned double, and then define a pointer to
it, this works. Is this recommended?

Below is just taken from the GCC Manual:
[quote]
As another example,

     char *__attribute__((aligned(8))) *f;

specifies the type “pointer to 8-byte-aligned pointer to char”. Note again that this does not work with most attributes; for example, the usage of `aligned' and `noreturn' attributes given above is not yet supported.
[/quote]

If it had been supported, you could use

> //typedef const real __attribute__((aligned(16))) *SSE_PTR;

But since it is not yet supported now, you have to use

typedef double real;

// these two lines work (together)
typedef real aligned_real __attribute__((aligned(16)));
typedef const aligned_real* SSE_PTR;


Jie

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux