Boost logo

Boost :

Subject: Re: [boost] Interest in multi-dimensional array class templates.
From: Brian Smith (bjs3141_at_[hidden])
Date: 2011-06-23 16:57:35


On 6/23/11, Frank Mori Hess <frank.hess_at_[hidden]> wrote:
> On Wednesday, June 22, 2011, Brian Smith wrote:
>> >
>> > There is also Boost.MultiArray, has the overlap with that library been
>> > addressed already?
>>
>> In terms of the way in which the two libraries create and manipulate
>> storage there's no overlap. Ultimately they serve the same purpose,
>> however, Boost.MultiArray doesn't provide statically allocated arrays
>
> I'm not sure that's true. I've never tried it, but multi_array_ref
> "provides the MultiArray interface over any contiguous block of elements" so
> it seems like you could create one of those which uses statically allocated
> storage.
>
Fair point, the static storage passed would be 1-dimensional and not
be owned by the multi_array_ref object.

>> and generally provides poorer performance.
>
> Is that assertion based on actual testing (with NDEBUG defined), or is there
> some by-design reason your performance would be better?
>
>
The design of the arrays closely follows that provided by the
language. For fixed-size static arrays the data member is an intrinsic
array whose type is determined from the template arguments passed, the
obvious difference for non-static arrays is the data member's type,
which for an N-dimensional array is the requested element type with N
pointer symbols appended. For these arrays all the information
necessary to construct the array is available at compile-time. The
resizeable arrays data member is also a pointer type, the number of
pointer symbols appended being determined from the dimensionality
argument passed in the template declaration, the size of each
dimension is subsequently passed in a supplementary array to the
constructor or resize method. Given the definition of the data member
we can rely on compiler generated pointer-arithmetic for indexing
expressions, implement indirection directly, or use recursion on a
supplementary array supplied set of indexes if bounds checking is
required. The data element access methods is the main contributing
factor in terms of performance, overwhelming the N memory requests
required to construct a non-static N-dimensional array. During
compartive testing against Boost.MultiArray this proves to be the
case, with construction times being slightly better for
Boost.MultiArray, but when data element access is included the
libraries non-static arrays perform significantly better. The
performance of the statically allocated arrays is superior to both.

-- 
www.maidsafe.net

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