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:
@@ -98,7 +98,7 @@ set(game_STAT_SRCS
|
||||
|
||||
include_directories(
|
||||
${CMAKE_BINARY_DIR}
|
||||
${CMAKE_SOURCE_DIR}/dep/mersennetwister
|
||||
${CMAKE_SOURCE_DIR}/dep/SFMT
|
||||
${CMAKE_SOURCE_DIR}/dep/zlib
|
||||
${CMAKE_SOURCE_DIR}/src/server/collision
|
||||
${CMAKE_SOURCE_DIR}/src/server/collision/Management
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#include "SharedDefines.h"
|
||||
#include "GridRefManager.h"
|
||||
#include "MapRefManager.h"
|
||||
#include "MersenneTwister.h"
|
||||
#include "sfmt.h"
|
||||
|
||||
#include <bitset>
|
||||
#include <list>
|
||||
@@ -427,13 +427,13 @@ class Map : public GridRefManager<NGridType>
|
||||
void UpdateIteratorBack(Player *player);
|
||||
|
||||
#ifdef MAP_BASED_RAND_GEN
|
||||
MTRand mtRand;
|
||||
int32 irand(int32 min, int32 max) { return int32 (mtRand.randInt(max - min)) + min; }
|
||||
uint32 urand(uint32 min, uint32 max) { return mtRand.randInt(max - min) + min; }
|
||||
int32 rand32() { return mtRand.randInt(); }
|
||||
double rand_norm() { return mtRand.randExc(); }
|
||||
double rand_chance() { return mtRand.randExc(100.0); }
|
||||
#endif
|
||||
SFMTRand sfmtRand;
|
||||
int32 irand(int32 min, int32 max) { return int32(sfmtRand.IRandom(min, max)); }
|
||||
uint32 urand(uint32 min, uint32 max) { return uint32(sfmtRand.URandom(min, max)); }
|
||||
int32 rand32() { return int32(sfmtRand.BRandom()); }
|
||||
double rand_norm() { return sfmtRand.Random(); }
|
||||
double rand_chance() { return sfmtRand.Random() * 100.0; }
|
||||
#endif // MAP_BASED_RAND_GEN
|
||||
|
||||
TempSummon *SummonCreature(uint32 entry, const Position &pos, SummonPropertiesEntry const *properties = NULL, uint32 duration = 0, Unit *summoner = NULL, uint32 vehId = 0);
|
||||
Creature* GetCreature(uint64 guid);
|
||||
|
||||
@@ -52,7 +52,6 @@ set(shared_STAT_SRCS
|
||||
|
||||
include_directories(
|
||||
${CMAKE_BINARY_DIR}
|
||||
${CMAKE_SOURCE_DIR}/dep/mersennetwister
|
||||
${CMAKE_SOURCE_DIR}/dep/SFMT
|
||||
${CMAKE_SOURCE_DIR}/dep/sockets/include
|
||||
${CMAKE_SOURCE_DIR}/dep/utf8cpp
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -46,7 +46,7 @@ include_directories(
|
||||
${CMAKE_BINARY_DIR}
|
||||
${CMAKE_SOURCE_DIR}/dep/gsoap
|
||||
${CMAKE_SOURCE_DIR}/dep/sockets/include
|
||||
${CMAKE_SOURCE_DIR}/dep/mersennetwister
|
||||
${CMAKE_SOURCE_DIR}/dep/sfmt
|
||||
${CMAKE_SOURCE_DIR}/src/server/collision
|
||||
${CMAKE_SOURCE_DIR}/src/server/collision/Management
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared
|
||||
|
||||
Reference in New Issue
Block a user