Article View: comp.std.c
Article #4571Re: Alignment of malloc()
From: Peter Curran
Date: Fri, 05 Jan 1996 22:23
Date: Fri, 05 Jan 1996 22:23
31 lines
2199 bytes
2199 bytes
On Thu, 4 Jan 1996 19:26:16 GMT in article <DKo8ns.8A9@midway.uchicago.edu>
Michael Spertus<mps@geodesic.com> (Michael Spertus<mps@geodesic.com>) wrote:
> ... The problem is that Win32 GlobalAlloc(), which is
>what most allocators use to get their arenas, returns a 32-bit aligned
>pointer. ... They may also be unaware
>that Pentium PCs use 64 bits data buses). This problem is magnified
>because the Pentium (apparently) drops into microcode on nonaligned
>loads, so that nonaligned floating point benchmarks are over 300%
>slower.
>Therefore, any code using floats must align all floating point malloc()
>to avoid running with abysmal efficiency on many of the most popular
>C/C++ compilers. I would like to believe that there should be an
>expectation that "malloc(float)" is a suitable or proper way to
>portably allocate a float ("suitable" and "proper" are the words used
>in the standard and reference documents to describe how malloc() should
>be aligned).
...
The problem here is, of course, that your idea of what is "suitable" and
"proper" is different from other people's. A large program I am developing does
many malloc()'s, almost all of which are for character-oriented or
short-oriented data. I do not want to pay the overhead for 64-bit alignment
that would just waste space. (My program needs all the memory it can get its
hands on.) So what's the vendor to do? Compiler options can fix some things,
but it gets trickier at run time. There are solutions, but the right answer is
a lot more complex than you are suggesting, I think.
--
Peter Curran pcurran@inforamp.net
Technical Details
Message-ID:
<4ck7k2$2eb@sam.inforamp.net>Path:
arc1-ca.pugleaf.net!inforamp.net!usenetReferences:
<DKDA7D.Kw7@midway.uchicago.edu> <j66Sx*FRe@yaps.rhein.de> <DKKHCH.L6r@midway.uchicago.edu> <4ccbdb$5v6@fg70.rz.uni-karlsruhe.de> <DKo8ns.8A9@midway.uchicago.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!inforamp.net!usenet From: pcurran@inforamp.net (Peter Curran) Newsgroups: comp.std.c Subject: Re: Alignment of malloc() Date: Fri, 05 Jan 1996 22:23:15 GMT Organization: PSC Enterprises Message-ID: <4ck7k2$2eb@sam.inforamp.net> References: <DKDA7D.Kw7@midway.uchicago.edu> <j66Sx*FRe@yaps.rhein.de> <DKKHCH.L6r@midway.uchicago.edu> <4ccbdb$5v6@fg70.rz.uni-karlsruhe.de> <DKo8ns.8A9@midway.uchicago.edu> Reply-To: pcurran@inforamp.net NNTP-Posting-Host: ts5-07.tor.inforamp.net X-Newsreader: Forte Free Agent 1.0.82