|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: "Benoit Jacob" <jacob.benoit.1@xxxxxxxxx>
- Date: Thu, 8 Jan 2009 22:38:41 -0500
- 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=ak6+iH54wxDdR3cZgH1PVKOJTK+VriOmMUu9wdZPUlI=; b=CsJP5ZSsf/wnRqFOZphizTtxwKgT0w5kORFnVeoTsgEch5mNbqV78ooitfsk47eSQC l3nsgTO8ndNcbZ34VniY5lUQNalR/lyhfCgPUAPjBXERmUAIxrg0lcgFNYgunkdwfBh1 8AWnCBVh3iyInDUK9gp2TwyHoYkWIzbXtJc8c=
- 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=lkmNx8JQ7rjFJJk0uft3x+nTsTt5VrpvdlO1PisNH02xmeBTHz6G/LBFs+x4SYkEPV 4cR60t8ZE5msSB6gyFXt+5bKcFGuA4Izbxa7RVnPWRJBUTHzBObwK9haExS3hKwkl1S2 75l8eqtjTjhZ7yDiQhW98BY2GdTmLKRS2JIes=
2009/1/8 Gael Guennebaud <gael.guennebaud@xxxxxxxxx>:
> 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.
I've been thinking the same actually. For a long time I was wary of
doing that because I wrongly believed that that would force us to keep
track of 2 ptrs instead of just 1 (the aligned ptr to use, and the
original ptr to free)
Actually there is a trick allowing to avoid doing that. I've seen
implementations of it but they're not LGPL-licensable so we can't use
them; but the idea is that the aligned ptr that you return is
guaranteed to be at an offset of at least sizeof(void*) bytes into the
actually allocated buffer, so that you may safely store another
pointer just before it; that latter storage space is where you store
the original ptr you'll have to free.
So yes, +1 from me.