This is the mail archive of the
glibc-bugs@sources.redhat.com
mailing list for the glibc project.
[Bug libc/206] malloc does not align memory correctly for sse capable systems
- From: "wg at malloc dot de" <sourceware-bugzilla at sources dot redhat dot com>
- To: glibc-bugs at sources dot redhat dot com
- Date: 6 Jun 2004 19:17:36 -0000
- Subject: [Bug libc/206] malloc does not align memory correctly for sse capable systems
- References: <20040605142238.206.ma1flfs@bath.ac.uk>
- Reply-to: sourceware-bugzilla at sources dot redhat dot com
------- Additional Comments From wg at malloc dot de 2004-06-06 19:17 -------
Subject: Re: malloc does not align memory correctly for sse capable systems
Hello,
> As for the implications: the C standard says that the pointer returned by
> malloc needs to be sufficiently aligned for _all_ data types. This alignment
> is specified in the ABI of a system, and for systems that allow the creation
> of SSE data types, this means that malloc needs to return 16-byte aligned
> pointers.
Ok, surely _the_ C standard doesn't specify "SSE data types". Some
extension of the C standard for an SSE system should of course specify
this exactly as you say, however, so I am not against supplying an
additional libmalloc16 to be used with SSE applications. I'll look
into creating one within glibc.
> I know that this is unfortunate, but there really is no other
> way of fixing malloc; for example, consider a program that uses
> std::vector<__m128> x(13);
> Here, std::vector has to call 'operator new' which itself has to call
> malloc(). If malloc doesn't return sufficiently aligned pointers, the
> resulting std::vector is unusable. Note that here the memory allocation
> has to happen inside gcc's libstdc++, and is this out of user's control
> -- so one can't use posix_memalign here.
Couldn't you use a non-default allocator?
(I know it is not as convenient.)
Regards,
Wolfram.
--
http://sources.redhat.com/bugzilla/show_bug.cgi?id=206
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.