random numbers in bulk

Paolo Carlini paolo.carlini@oracle.com
Sat Aug 25 21:32:00 GMT 2012


Hi,

(please remember to CC libstdc++ for discussions involving the library)

On 08/25/2012 10:31 PM, Ulrich Drepper wrote:
> The current <random> interface as defined in the standard is not well
> suited for heavy users such as simulations.  The only way to get a
> number is using the operator() one-by-one.  This can lead to
> significant overhead and, perhaps more importantly, prevents
> optimizations from being applied.  For instance, there are way to
> faster implement the various distribution functions but the overhead
> of setting it up is too high if it has to be done for every call.
> Also, in some of the existing distribution implementations there are
> tests which the compiler cannot hoist out of the loop and therefore
> has to execute every time.
>
> I propose to add a member function fill to all distribution classes.
> It has the same interface as the opeartor() except that it has two new
> parameters which specify the target buffer.  This means the return
> value can be void, too.
>
> I know this is not standardized but I hope the standard committee will
> recognize it is necessary.
>
> The question is: how to add this?  What is the practice to add new
> member functions?  #ifdef something?
Personally, assuming the name itself is already reserved / used 
elsewhere, like, eg, fill, and we are talking about things not affecting 
the ABI, I don't see any particular problem with just adding the member 
functions. With documentation.

Paolo.



More information about the Gcc-patches mailing list