Boost logo

Boost :

Subject: Re: [boost] [xint] Boost.XInt formal review
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2011-03-03 14:31:05


On 03/03/2011 19:34, Jeremy Maitin-Shepard wrote:
> On 03/03/2011 05:46 AM, Mathias Gaunard wrote:
> > [snip]
>> Imagine something similar to the mpn component of the GMP library, but
>> with a generic and easy-to-use C++ interface.
>> Through genericity, you could make the algorithms accept ranges of
>> integers and have them work regardless of digit size, with the digit
>> chosen at the discretion of the user. If the user provides a SIMD type
>> as a digit, you'll get optimized SIMD code for free, for example, in a
>> completely externalized way.
>> Now *that* would be awesome.
>
> This whole explicitly passing simd<T> in place of T, which seems to be
> the same thing done in nt2, in order to make use of certain
> optimizations seems like a poor interface choice.

I'm talking of passing a range of 128-bit or 256-bit integers, with an
integer type that would use the SIMD unit for its implementation,
instead of a range of 32-bit or 64-bit integers that would use the
standard built-in types that probably use the ALU.

Of course, this is just an idea. I don't know if that is a sensible way
to exploit SIMD in a bigint scenario, maybe you need a more global SIMD
awareness.

> I also don't see how the optimization can be externalized in the
(quite common) case of doing more than element-wise operations.

A C primitive only receives a pointer to raw memory, and has to decide
what code to invoke itself. Templates allow to externalize those
operations to functions that depend on the types of its arguments.

---------------

Also, in nt2, simd_<T> is a notation to do pattern matching on simd
vector types whose elements are T.
It's not something you "pass" to functions.
You could also write simd_< integer_<T> > to only match simd vector
types whose elements are integers.

NT2 uses a hierarchical concept-based overloading system. I understand
this can make code quite confusing in the absence of any docs.


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