This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


I see, so you want the function to be compiled as though the pointers
are guaranteed to point to 16-byte-aligned addresses.  This is an
interesting question.  I'll be following this too :)

  Brian

On Thu, Dec 31, 2009 at 12:27 PM, Benjamin Redelings I
<benjamin_redelings@ncsu.edu> wrote:
> On 12/31/2009 08:41 AM, Brian Budge wrote:
>>
>> The reason it won't work is that you're saying the pointer itself
>> needs to be 16 (or 8) byte aligned. ?You need the address that the
>> pointer points to to be aligned.
>>
>> On the stack:
>>
>> __attribute__ ((aligned(16)) real myArray[32];
>>
>> On the heap (*nix):
>> real *myArray;
>> posix_memalign((void**)&myArray, 16, 32 * sizeof(real));
>>
>> or for more portability you could use the SSE intrinsic mm_malloc.
>>
>> To know why the one version you posted works, we'd need to see the
>> calling code of f. ? In general, it shouldn't work if malloc or new
>> are used to allocate the memory passed in, but it might be that the
>> memory is allocated on the stack?
>>
>> ? Brian
>
> Hi Brian,
>
> ? ?I think there are two different issues:
>
> 1. First, how to actually allocate memory that is 16-byte aligned.
> 2. Second, how to inform the compiler that a pointer to that memory is in
> fact has the property p&15L == 0L
>
> I am interested in the second question, whereas I think you are answering
> the first one.
>
>> To know why the one version you posted works, we'd need to see the
>> calling code of f. ? In general, it shouldn't work if malloc or new
>> are used to allocate the memory passed in, but it might be that the
>> memory is allocated on the stack?
>>
>
> There is no calling code. ?That is, I'm not saying that it works when I run
> it. ?I am saying that it works (that is, the compiler makes use of the
> 16-byte alignment of the pointer target) when I compile it.
>
> -BenRI
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]