Here is a patch to accelerate the __generate function for the
normal_distribution<double> class.  The speed-up is quite significant,
the amount depending on which random number engine is used.

mt19937        +20%

mt19937_64     +30%

sfmt19937      +30%

sfmt19937_64   +30%


This patch introduces a header with optimizations for <random>.  No
changes to existing code needed, this is a straight-forward
specialization.  Tested on x86_64-linux.  More optimizations follow,
there is still quite a bit of inefficiency in the existing interfaces.
 OK to commit?


2012-09-21  Ulrich Drepper  <drep...@gmail.com>

        Optimize bulk mode for normal_distribution<double> for SSE3.
        * configure.host: Define cpu_opt_bits_random.
        * configure.ac: Substitute CPU_OPT_BITS_RANDOM.
        * configure: Regenerated.
        * include/Makefile.am (bits_headers): Add ${bits_host_headers}.
        (bits_host_headers): Define.
        * include/bits/random.tcc: Move __details::_Power_of_2 to...
        * include/bits/random.h: ...here.
        * include/std/random: Include <bits/opt_random.h>.
        * config/cpu/i486/opt/bits/opt_random.h: New file.
        * config/cpu/generic/opt/bits/opt_random.h: New file.

Attachment: d-random-opt-normal-sse
Description: Binary data

Reply via email to