|Re: [eigen] Re: platform detection for aligned malloc|
[ Thread Index |
| More lists.tuxfamily.org/eigen Archives
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Re: platform detection for aligned malloc
- From: "Gael Guennebaud" <gael.guennebaud@xxxxxxxxx>
- Date: Fri, 9 Jan 2009 00:32:14 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=pD1r72W9ABcS3anaEDsDz8Bl/6TUj/+9s/odlwf4eGU=; b=YdZkxyDq7g142YXjr9HMD6piY40Q1xts7H5AGRLiq6KMM6rj6bkf2m3+o/J2kUpP+k D/umMSh6VISLrS1E6mFlNlpSxcgslSQjhh4a5iTtFR/ARHI8W3ztgjzXC8+Dhs+V4JJZ FurGSpok3uyy3Oru8pK6vO0/Ts0w5fTY4sFVk=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=dkS+3VzyKblk9556yxFFBEiblcwKM8d6lBJNvTF0Y4uSVQRZ+BU1YznZLQPQrggPLl 0hc3aLA4kDPHaAM6VOtODIj6RunPlNlfCQqY55z9UbI1rKpPmKCNXUIdBPKSpzvhBCuv NrmdL7FsjttoNJgmc12rc7qt4EGo2lAzPPkac=
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
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>:
>> 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.
>> --> 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
>> ---> need to check especially with GCC 3...
>> *Mac OSX and FreeBSD:
>> ---> Problem solved, we use malloc()
>> *Other BSDs:
>> ---> no clue
>> ----> no clue
>> ----> problem solved, we use _aligned_malloc
>> ---> 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.
>> ---> Gael formerly made it use _mm_malloc, so same question as ICC,
>> which header to include?
>> Old GCC: