Re: [eigen] Re: platform detection for aligned malloc

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


well, here is my proposal:

1 -  since _mm_malloc is only available when vectorization is enabled
we can forget about it.

2 - for all platforms which make problem let's eventually implement
our own "_mm_malloc" using the common trick to allocate 16bytes more
and store the original pointer in front of the aligned pointer. This
is exactly how GCC's _mm_malloc is implemented: use posix_memalign if
available, otherwise do the trick. Sounds reasonable, no ?

This tricks holds for cygwin and all other systems for which we are
still unsure.

Gael.

On Fri, Jan 9, 2009 at 12:04 AM, Benoit Jacob <jacob.benoit.1@xxxxxxxxx> wrote:
> Forgot to attach the patch...
>
> 2009/1/9 Benoit Jacob <jacob.benoit.1@xxxxxxxxx>:
>> Hi,
>>
>> I'm reworking the platform detection for aligned malloc.
>> One recent change is that we now need aligned malloc even if
>> vectorization is not used. So if we want to use _mm_malloc we need to
>> use it from another header than emmintrin.h. I heard there's a
>> mm_malloc.h on some platforms but i'm not too sure.
>>
>> Another finding i made is that on freebsd too, malloc() is 16 byte aligned.
>>
>> Please find attached a patch, it's the best i can do but it needs improvements.
>> *Linux:
>>  --> question: in current SVN we always add manually the prototype of
>> posix_memalign. with this patch, we do it only if not declared by
>> <cstdlib> that is if _XOPEN_SOURCE<600. Anyway, is this really good
>> practice? If XOPEN_SOURCE<600 then maybe we really can't use
>> posix_memalign, i mean, there's got to be a reason why it's not
>> declared....
>> ---> need to check especially with GCC 3...
>> *Mac OSX and FreeBSD:
>> ---> Problem solved, we use malloc()
>> *Other BSDs:
>> ---> no clue
>> *Solaris:
>> ----> no clue
>> MSVC:
>> ----> problem solved, we use _aligned_malloc
>> ICC:
>> ---> we use _mm_malloc. Question: do we need to #include some header,
>> like <mm_malloc.h>? When vectorization is not enabled we can't count
>> on emmintrin.h.
>> Cygwin:
>> ---> Gael formerly made it use _mm_malloc, so same question as ICC,
>> which header to include?
>> Old GCC:
>>
>> Cheers,
>> Benoit
>>
>

---


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/