*mtmap is disabled by default. To use it, define MULTI_THREAD_MAP in define.h
*mtmap support is not provided for windows users. Because there is no free openmp lib for windows. If you have openmp lib and want to use openmp, you need to manually change the setting.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-06-18 19:27:17 -05:00
10 changed files with 110 additions and 5 deletions
+3
View File
@@ -137,7 +137,10 @@ typedef uint32 DWORD;
typedef uint64 OBJECT_HANDLE;
//#define MULTI_THREAD_MAP
#ifdef MULTI_THREAD_MAP
#define MAP_BASED_RAND_GEN
#endif
#define MaNGOS Trinity
#define MANGOS_DLL_DECL TRINITY_DLL_DECL
+1 -1
View File
@@ -294,6 +294,6 @@ SET(game_STAT_SRCS
Wintergrasp.cpp
ZoneScript.h
)
add_definitions(-fopenmp)
add_library(game STATIC ${game_STAT_SRCS})
ADD_DEPENDENCIES(game revision.h)
+38 -3
View File
@@ -18,6 +18,9 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifdef MULTI_THREAD_MAP
#include <omp.h>
#endif
#include "MapManager.h"
#include "InstanceSaveMgr.h"
#include "Policies/SingletonImp.h"
@@ -251,12 +254,33 @@ MapManager::Update(uint32 diff)
if( !i_timer.Passed() )
return;
for(MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter)
#ifdef MULTI_THREAD_MAP
uint32 i=0;
MapMapType::iterator iter;
std::vector<Map*> update_queue(i_maps.size());
omp_set_num_threads(sWorld.getConfig(CONFIG_NUMTHREADS));
for(iter = i_maps.begin(), i=0;iter != i_maps.end(); ++iter, i++)
update_queue[i]=iter->second;
/*
gomp in gcc <4.4 version cannot parallelise loops using random access iterators
so until gcc 4.4 isnt standard, we need the update_queue workaround
*/
#pragma omp parallel for schedule(dynamic) private(i) shared(update_queue)
for(int32 i = 0; i < i_maps.size(); ++i)
{
checkAndCorrectGridStatesArray(); // debugging code, should be deleted some day
update_queue[i]->Update(i_timer.GetCurrent());
sWorld.RecordTimeDiff("UpdateMap %u", update_queue[i]->GetId());
// sLog.outError("This is thread %d out of %d threads,updating map %u",omp_get_thread_num(),omp_get_num_threads(),iter->second->GetId());
}
#else
for(MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter)
{
iter->second->Update(i_timer.GetCurrent());
sWorld.RecordTimeDiff("UpdateMap %u", iter->second->GetId());
}
#endif
ObjectAccessor::Instance().Update(i_timer.GetCurrent());
sWorld.RecordTimeDiff("UpdateObjectAccessor");
@@ -269,8 +293,19 @@ MapManager::Update(uint32 diff)
void MapManager::DoDelayedMovesAndRemoves()
{
for(MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter)
iter->second->RelocationNotify();
/*
int i =0;
std::vector<Map*> update_queue(i_maps.size());
MapMapType::iterator iter;
for(iter = i_maps.begin();iter != i_maps.end(); ++iter, i++)
update_queue[i] = iter->second;
omp_set_num_threads(sWorld.getConfig(CONFIG_NUMTHREADS));
#pragma omp parallel for schedule(dynamic) private(i) shared(update_queue)
for(i=0;i<i_maps.size();i++)
update_queue[i]->DoDelayedMovesAndRemoves();
*/
}
bool MapManager::ExistMapAndVMap(uint32 mapid, float x,float y)
+3
View File
@@ -1088,6 +1088,7 @@ void World::LoadConfigSettings(bool reload)
m_configs[CONFIG_INTERVAL_LOG_UPDATE] = sConfig.GetIntDefault("RecordUpdateTimeDiffInterval", 60000);
m_configs[CONFIG_MIN_LOG_UPDATE] = sConfig.GetIntDefault("MinRecordUpdateTimeDiff", 10);
m_configs[CONFIG_CHECK_DB] = sConfig.GetBoolDefault("CheckDB", true);
m_configs[CONFIG_NUMTHREADS] = sConfig.GetIntDefault("MapUpdate.Threads",1);
std::string forbiddenmaps = sConfig.GetStringDefault("ForbiddenMaps", "");
char * forbiddenMaps = new char[forbiddenmaps.length() + 1];
@@ -1784,9 +1785,11 @@ void World::Update(uint32 diff)
sBattleGroundMgr.Update(diff);
RecordTimeDiff("UpdateBattleGroundMgr");
sOutdoorPvPMgr.Update(diff);
RecordTimeDiff("UpdateOutdoorPvPMgr");
// execute callbacks from sql queries that were queued recently
UpdateResultQueue();
RecordTimeDiff("UpdateResultQueue");
+1
View File
@@ -235,6 +235,7 @@ enum WorldConfigs
CONFIG_CHECK_DB,
CONFIG_ENABLE_SINFO_LOGIN,
CONFIG_PET_LOS,
CONFIG_NUMTHREADS,
CONFIG_OFFHAND_CHECK_AT_TALENTS_RESET,
CONFIG_CHATLOG_CHANNEL,
CONFIG_CHATLOG_WHISPER,
+1 -1
View File
@@ -21,7 +21,7 @@ SET(shared_STAT_SRCS
WorldPacket.h
SystemConfig.h
)
add_definitions(-fopenmp)
add_library(shared STATIC ${shared_STAT_SRCS})
target_link_libraries(
shared
+56
View File
@@ -28,6 +28,60 @@
typedef ACE_TSS<MTRand> MTRandTSS;
static MTRandTSS mtRand;
#ifdef MULTI_THREAD_MAP
int32 irand (int32 min, int32 max)
{
int32 result;
#pragma omp critical (mtrand)
{
result = int32 (mtRand->randInt (max - min)) + min;
}
return result;
}
uint32 urand (uint32 min, uint32 max)
{
uint32 result;
#pragma omp critical (mtrand)
{
result = mtRand->randInt (max - min) + min;
}
return result;
}
int32 rand32 ()
{
int32 result;
#pragma omp critical (mtrand)
{
result = mtRand->randInt ();
}
return result;
}
double rand_norm(void)
{
double result;
#pragma omp critical (mtrand)
{
result = mtRand->randExc ();
}
return result;
}
double rand_chance (void)
{
double result;
#pragma omp critical (mtrand)
{
result = mtRand->randExc (100.0);
}
return result;
}
#else
int32 irand (int32 min, int32 max)
{
return int32 (mtRand->randInt (max - min)) + min;
@@ -53,6 +107,8 @@ double rand_chance (void)
return mtRand->randExc (100.0);
}
#endif
Tokens StrSplit(const std::string &src, const std::string &sep)
{
Tokens r;
+1
View File
@@ -45,6 +45,7 @@ vmaps
ZThread
g3dlite
readline
gomp
${SCRIPT_LIB}
${MYSQL_LIBRARIES}
${POSTGRE_LIBS}
+5
View File
@@ -188,6 +188,10 @@ EAIErrorLevel = 2
# Default: 1 (permit addon channel)
# 0 (do not permit addon channel)
#
# MapUpdate.Threads
# Number of threads to update maps.
# Default: 1
#
###################################################################################################################
UseProcessors = 0
@@ -214,6 +218,7 @@ LogDB.Opt.ClearInterval = 10
LogDB.Opt.ClearTime = 1209600
MaxCoreStuckTime = 0
AddonChannel = 1
MapUpdate.Threads = 1
###################################################################################################################
# SERVER LOGGING
+1
View File
@@ -38,6 +38,7 @@ trinityauth
trinityconfig
ZThread
zlib
gomp
${SSLLIB}
${MYSQL_LIBRARIES}
${OSX_LIBS}