alignment issues for sse

Kimmo Fredriksson kfredrik@cs.joensuu.fi
Thu Feb 17 15:07:00 GMT 2005


Hi,

[Disclaimer: I haven't really been following this discussion...]

On Wed, 16 Feb 2005, corey taylor wrote:

>  However, after looking into the current public project I'm on, I
> realize that it doesn't use SSE for the allocation.  It simply
> advances to an aligned location and manually forces the alignment,
> hides the actual allocation pointer, and returns the aligned pointer.

Why not use:

void * _mm_malloc (size_t size, size_t alignment)
void _mm_free (void * ptr)

?

Defined in xmmintrin.h (I think).

> On Wed, 16 Feb 2005 17:58:15 +0100, Brian Budge <brian.budge@gmail.com> wrote:

>> On Wed, 16 Feb 2005 10:46:54 -0600, corey taylor <corey.taylor@gmail.com> wrote:
>>> Implementation's I've used and worked on always do aligned allocations
>>> manually.  Typically the hidden and real sizes of the allocation are
>>> put into the memory allocation itself and the returned pointer is
>>> incremented a few bytes.  The downside to this is that you must be
>>> strict in using the aligned free routine also.

See above.

>>> On Wed, 16 Feb 2005 10:09:27 -0600, Eljay Love-Jensen <eljay@adobe.com> wrote:

>>>> >But surely thousands of people are writing sse code... how do they make
>>>> it work?
>>>>
>>>> I presume by taking measures to assure the SSE structs are properly 
>>>> aligned.
>>>>
>>>> >Do I need to switch to the intel compiler/linker?
>>>>
>>>> I do not know.

I do not know either, but that was my solution...

But: my sse code used to work just fine with gcc. Then something happened, 
and I just get seg faults. Don't remember exactly anymore, but I think at 
the time it actually worked with gcc, I was using some early gcc 3.4 
snapshot, since it was the only one that worked. No version before, no 
version after (that I have tried, excluding e.g. 4.0)... And of course 
there is also the possibility that something else changed, I do/did 
something wrong, etc. Anyways, currently I use icc for sse code, and use 
_mm_malloc/_mm_free for dynamic allocation, statics are automagically 16 
byte aligned.

For other things, I still use mostly gcc.

K



More information about the Gcc-help mailing list