[PATCH] normal_distribution<double> performance improvement with SSE

Ulrich Drepper drepper@gmail.com
Wed Sep 26 11:16:00 GMT 2012


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  <drepper@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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: d-random-opt-normal-sse
Type: application/octet-stream
Size: 12670 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20120926/4cf030ee/attachment.obj>


More information about the Libstdc++ mailing list