Switch to using SIMD-oriented Fast Mersenne Twister for random number generation.

In testing, reduced random number generation time by a factor of 8-10.
Drops support for processors older than Pentium 4.
Drop Mersenne Twister library; use a C++ SFMT library.

--HG--
branch : trunk
This commit is contained in:
silinoron
2010-08-19 16:13:10 -07:00
parent 21cf500cb1
commit ac59ff802b
13 changed files with 372 additions and 1561 deletions

View File

@@ -22,36 +22,35 @@
#include "socket_include.h"
#include "utf8.h"
//#include "SFMT.h"
#include "MersenneTwister.h"
#include "sfmt.h"
#include <ace/TSS_T.h>
typedef ACE_TSS<MTRand> MTRandTSS;
static MTRandTSS mtRand;
typedef ACE_TSS<SFMTRand> SFMTRandTSS;
static SFMTRandTSS sfmtRand;
int32 irand (int32 min, int32 max)
{
return int32 (mtRand->randInt (max - min)) + min;
return int32(sfmtRand->IRandom(min, max));
}
uint32 urand (uint32 min, uint32 max)
{
return mtRand->randInt (max - min) + min;
return sfmtRand->URandom(min, max);
}
int32 rand32 ()
{
return mtRand->randInt ();
return int32(sfmtRand->BRandom());
}
double rand_norm(void)
{
return mtRand->randExc ();
return sfmtRand->Random();
}
double rand_chance (void)
{
return mtRand->randExc (100.0);
return sfmtRand->Random() * 100.0;
}
Tokens StrSplit(const std::string &src, const std::string &sep)