Boost logo

Boost :

From: scleary_at_[hidden]
Date: 2000-12-04 10:22:14


> [Peter Dimov]
> In some cases I have felt the need to define an std::vector<float> that
> aligns their elements on, say, 128-bit boundaries (the Intel SSE, AMD
3DNow
> extensions like their floats aligned.) Is it possible to pass a stricter
> alignment requirement to pool_alloc?

No. There is no obvious way to allow this in pool. Pool will use operator
new[] for arrays of char; this is supposed to guarantee alignment.

I say "supposed to", because (according to "More C/C++ Memory Management
Benchmarks", by Ron Burk, in April 1997 issue of "Windows Developer's
Journal"), several popular Windows compilers do not return the best-aligned
data (note that on the Intel platform, misaligned data is not fatal; it is
only a speed penalty).
The table below shows the alignment guarantees for the compilers compared in
the article. On each compiler, float is 4-byte and double is 8-byte, so
slowdowns occur when only 4-byte alignment is provided and doubles/long
doubles are used:
        Symantic C++ v7.2 4-byte alignment
        Borland C++ v5.1 4-byte alignment
        Visual C++ v4.2 16-byte alignment if requested size is <=
480 bytes; otherwise 4-byte alignment (i.e., large arrays of doubles may be
out-of-alignment)
        Watcom C++ v10.6 8-byte alignment

Pool itself passes off the alignment issues to operator new[]. Thus, it
should be possible to tackle alignment issues by overloading operator new[],
if you know your compiler doesn't provide proper alignment.

        -Steve


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk