gakushin logo
MTGP logo

Mersenne Twister for Graphic Processors (MTGP):
a new variant of Mersenne Twister*1.

Japanese Version


What is MTGP?

MTGP is a new variant of Mersenne Twister (MT) introduced by Mutsuo Saito and Makoto Matsumoto in 2009. MTGP is designed with some features of Graphic Processors, such as parallel execution and hi-speed constant reference. It supports 32-bit and 64-bit integers, as well as single and double precision floating point as output.

The periods of generated sequence are 11213-1,223209-1 and 244497-1 for 32-bit version, and 223209-1, 244497-1, 2110503-1 for 64-bit version. It support 128 parameter sets for each period, in other words, it can generate 128 independent pseudorandom number sequences for each period. We have developed Dynamic Creator for MTGP, which generates more parameter sets.

Preprint in arXiv.
A paper of MTGP (under review, coauthored with Makoto Matsumoto).

A PDF slide 'A deviation of XORWOW of CURAND' in MCQMC 2012.

There are sample implementations on CUDA in an archive source. There are no samples on OpenCL or on ATI Stream in it. But we think MTGP is also fast on RADEONs.

Download MTGP

This code is released on November 17th in 2009, so it may contain some bugs. Any feedback is welcome (send an email to Mutsuo Saito, saito "at sign" and m-mat "at sign"

new! 1.1.2
CUDA samples are fixed to run on CUDA 5.0. (2012/10/24)
add jump function. add OpenCL sample with jump.
Does not run correctly on CUDA 5.0.(2012/10/18)
Parameter files of mtgp32 are changed for better dimension of equidistributions. This change cause changes of outputs, but this not cause effect on floating point outputs. The changes affect only on 9 LSB bits of unsigned integers and the 9 LSB bits are discarded when converting to floating points. You can also use old paramter files instead of new ones. This change reflects the improvement of MTGPDC ver. 0.3.
Sample files for cuda now can be compiled in CUDA 4.0 environment. (2011/6/6)
change MEXPs of CUDA-sample from 23209 and 44497 to 11213. This is because CUDA occupancy of the latter is larger than those of the formers. (2010/3/26)
64-bit initialization bug fixed. (2010/1/5)
First version. (2009/11/17)

If you have some trouble to download, try this page.

MTGP Dynamic Creator (MTGPDC)

MTGPDC creates parameter sets for MTGP. MTGP has 128 parameter sets for each period. If you need more parameter sets, use MTGPDC to create them. MTGPDC can create 232 parameter sets for each period.

MTGPDC can create parameter sets of MTGPs which have period of 23217,24423,211213, 223209 or 244497.

MTGPDC requires some libraries.

And MTGP requires UNIX like Operating System with GNU C++ compiler(g++).

Download MTGP

This code is released on March 26th in 2010, so it may contain some bugs. Any feedback is welcome (send an email to Mutsuo Saito, saito "at sign" and m-mat "at sign"

new! 0.3.1
Fix the bug in mtgp64dc mentioned below. (2011/3/9)

A small bug in search_temper.hpp is fixed. The bug effects only on the least significant 5 bits, but it makes the dimension of equidistribution of the LSBs smaller than they should be.

In addition, we modified the algorithm of searching tempering parameters, so that the algorithm tempers the dimensions of equidistribution of LSBs too, in addition to those of MSBs. This is to address a report on some statistical tests of these LSBs due to Jonathan Passerat-Palmbach, David R.C. Hill and Claude Mazel. We thank them. (2011/3/4)

The 64 bit version, mtgp64dc in this version has a serious bug, and should not be used. BUG:All tempering parameters searched by mtgp64dc are zeros. This bug exists only in this version 0.3. It does not exist in the earlier versions, and it is fixed in the version 0.3.1 above. (2011/3/9)

some bug fixes. (2010/6/8)
First version. (2010/3/26)

If you have some trouble to download, try this page.


MTGP, as well as MT, can be used freely for any purpose, including commercial use. See LICENSE.txt for detail.


Back to Mersenne Twister Home Page
Back to SFMT Home Page

*1 This work is supported in part by JSPS Core-to-Core Program No. 18005: "New Developments of Arithmetic Geometry, Motive, Galois Theory, and Their Practical Applications."
This work is also partially supported by JSPS Grant-in-Aid for Scientific Research No. 19204002, No. 18654021 and No. 21654004.