[PATCH v2][Aarch64] Add vectorized mersenne twister

Michael Collison Michael.Collison@arm.com
Tue Jul 18 05:55:00 GMT 2017


This is the second version of a patch for Aarc64 to add a vectorized mersenne twister to libstdc++. The first version used intrinsics and included "arm_neon.h". After feedback from the community this version uses only GCC vector extensions and Aarch64 simd data types.

This patch adds an vectorized implementation of the mersenne twister random number generator. This implementation is approximately 2.6 times faster than the non-vectorized implementation.

Sample code to use the new generator would look like this:

#include <random>
#include <ext/random>
#include <iostream>

int
main()
{
  __gnu_cxx::sfmt19937 mt(1729);

  std::uniform_int_distribution<int> dist(0,1008);

  for (int i = 0; i < 16; ++i)
    {
      std::cout << dist(mt) << " ";
    }
}

Okay for trunk?

2017-07-16  Michael Collison  <michael.collison@arm.com>

	Add optimized implementation of mersenne twister for aarch64
	* config/cpu/aarch64/opt/ext/opt_random.h: New file.
	(__arch64_recursion): New function.
	(__aarch64_lsr_128): New function.
	(__aarch64_lsl_128): New function.
	(operator==): New function.
	(simd_fast_mersenne_twister_engine): Implement
	method _M_gen_rand.
	* config/cpu/aarch64/opt/bits/opt_random.h: New file.
	* include/ext/random: (simd_fast_mersenne_twister_engine):
	add _M_state private array.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr4218v2.patch
Type: application/octet-stream
Size: 8523 bytes
Desc: pr4218v2.patch
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20170718/4f982db5/attachment.obj>


More information about the Libstdc++ mailing list