This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: random numbers in bulk


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]