Jump to content

mtmaps (OpenMP)


Recommended Posts

  • Replies 319
  • Created
  • Last Reply

Top Posters In This Topic

  • 2 weeks later...
  • 2 weeks later...

Just tried patch. Core sturtup fine, but realmd-demon can't start

./mangos-realmd: error while loading shared libraries: libtbb.so.2: cannot open shared object file: No such file or directory
, but in /lib file exis =\\

How related tbb to realmd?

P.S. Ubuntu 8.10 amd64

Link to comment
Share on other sites

admin@ks308761:/root$ sudo mv tbb22_20090809oss_src.tgz tbb

admin@ks308761:/root$ cd tbb/src

admin@ks308761:/root/tbb/src$ make

cd "../build/linux_ia32_gcc_cc4.2.4_libc2.7_kernel2.6.31.5_release" && sh ../../build/generate_tbbvars.sh linux_ia32_gcc_cc4.2.4_libc2.7_kernel2.6.31.5_release

/bin/sh: line 0: cd: ../build/linux_ia32_gcc_cc4.2.4_libc2.7_kernel2.6.31.5_release: No such file or directory

Link to comment
Share on other sites

  • 2 weeks later...

I tested on the lastest 0.12 mangos (with scriptdev and relaxed anticheat patch), you need to modify some parts of the patch to have it works.

I posted my diff to caerulueaus because I'm not sure of the quality and the rightness of my code.

Link to comment
Share on other sites

Hello all,

I have this error when i try to compil.

../../../src/game/Spell.cpp: In member function ‘void Spell::cast(bool)’:

../../../src/game/Spell.cpp:2892: error: conversion from ‘tbb::internal::vector_iterator<tbb::concurrent_vecto r<Spell::TargetInfo, tbb::cache_aligned_allocator<Spell::TargetInfo> >, Spell::TargetInfo>’ to non-scalar type ‘std::_List_iterator<Spell::TargetInfo>’ requested

../../../src/game/Spell.cpp:2892: error: no match for ‘operator!=’ in ‘ihit != tbb::concurrent_vector<T, A>::e nd() [with T = Spell::TargetInfo, A = tbb::cache_aligned_allocator<Spell::TargetInfo>]()’

/usr/include/c++/4.3/bits/stl_list.h:173: note: candidates are: bool std::_List_iterator<_Tp>::operator!=(cons t std::_List_iterator<_Tp>&) const [with _Tp = Spell::TargetInfo]

/usr/local/include/ace/Time_Value.inl:313: note: bool operator!=(const ACE_Time_Value&, const ACE_Time_Value&)

In advance thx.

Link to comment
Share on other sites

I tested on the lastest 0.12 mangos (with scriptdev and relaxed anticheat patch), you need to modify some parts of the patch to have it works.

I posted my diff to caerulueaus because I'm not sure of the quality and the rightness of my code.

Could you post it anyway? It is currently better then no patch at a ll.

Link to comment
Share on other sites

you didn't include body of those 4 new files ;-)

omg sorry :P

diff --git a/src/game/MapUpdater.cpp b/src/game/MapUpdater.cpp
new file mode 100644
index 0000000..1a37d7e
--- /dev/null
+++ b/src/game/MapUpdater.cpp
@@ -0,0 +1,140 @@
+#include "MapUpdater.h"
+
+#include "DelayExecutor.h"
+#include "Map.h"
+#include "Database/DatabaseEnv.h"
+
+#include <ace/Guard_T.h>
+#include <ace/Method_Request.h>
+
+//the reason this things are here is that i want to make
+//the netcode patch and the multithreaded maps independant
+//once they are merged 1 class should be used
+class  WDBThreadStartReq1 : public ACE_Method_Request
+{
+public:
+  WDBThreadStartReq1 () { }
+  virtual int
+  call (void)
+  {
+    WorldDatabase.ThreadStart ();
+    return 0;
+  }
+};
+
+class  WDBThreadEndReq1 : public ACE_Method_Request
+{
+public:
+  WDBThreadEndReq1 () { }
+  virtual int
+  call (void)
+  {
+    WorldDatabase.ThreadEnd ();
+    return 0;
+  }
+};
+
+class MapUpdateRequest : public ACE_Method_Request
+{
+public:
+  Map& m_map;
+  MapUpdater& m_updater;
+  ACE_UINT32 m_diff;
+  MapUpdateRequest (Map& m,MapUpdater& u,ACE_UINT32 d) : m_map(m),m_updater(u),m_diff(d) { }
+  virtual int
+  call (void)
+  {
+    m_map.Update (m_diff);
+    m_updater.update_finished ();
+    return 0;
+  }
+};
+
+MapUpdater::MapUpdater () :
+m_mutex (),
+m_condition (m_mutex),
+m_executor (),
+pedning_requests (0)
+{
+  return;
+}
+
+MapUpdater::~MapUpdater ()
+{
+  this->deactivate ();
+}
+
+int
+MapUpdater::activate (size_t num_threads)
+{
+  return this->m_executor.activate (static_cast<int> (num_threads),
+                                    new WDBThreadStartReq1,
+                                    new WDBThreadEndReq1);
+}
+
+int
+MapUpdater::Deactivate (void)
+{
+  this->wait ();
+
+  return this->m_executor.deactivate ();
+}
+
+int
+MapUpdater::wait ()
+{
+  ACE_GUARD_RETURN(ACE_Thread_Mutex,guard,this->m_mutex,-1);
+
+  while(this->pedning_requests > 0)
+    this->m_condition.wait ();
+
+  return 0;
+}
+
+int
+MapUpdater::schedule_update(Map& map, ACE_UINT32 diff)
+{
+  ACE_GUARD_RETURN(ACE_Thread_Mutex,guard,this->m_mutex,-1);
+
+  ++this->pedning_requests;
+
+  if( this->m_executor.execute (new MapUpdateRequest(map,*this,diff)) == -1)
+    {
+      ACE_DEBUG ((LM_ERROR,
+                  ACE_TEXT ("(%t) \\n"),
+                  ACE_TEXT ("Failed to schedule Map Update")));
+
+      --this->pedning_requests;
+      return -1;
+    }
+
+  return 0;
+}
+
+bool
+MapUpdater::activated ()
+{
+  return m_executor.activated();
+}
+
+void
+MapUpdater::update_finished ()
+{
+  ACE_GUARD (ACE_Thread_Mutex, guard, this->m_mutex);
+
+  if (this->pedning_requests == 0)
+    {
+      ACE_ERROR ((LM_ERROR,
+                  ACE_TEXT ("(%t)\\n"),
+                  ACE_TEXT ("MapUpdater::update_finished BUG, report to devs")));
+
+      return;
+    }
+
+  --this->pedning_requests;
+
+  //TODO can more than one thread call wait (), it shouldnt happen
+  //however I ensure if in future more than 1 thread call it by
+  //using broadcast instead of signal ()
+  this->m_condition.broadcast ();
+}
diff --git a/src/game/MapUpdater.h b/src/game/MapUpdater.h
new file mode 100644
index 0000000..d4d4be5
--- /dev/null
+++ b/src/game/MapUpdater.h
@@ -0,0 +1,46 @@
+#ifndef _MAP_UPDATER_H_INCLUDED
+#define _MAP_UPDATER_H_INCLUDED
+
+
+#include <ace/Thread_Mutex.h>
+#include <ace/Condition_Thread_Mutex.h>
+
+#include "DelayExecutor.h"
+
+class Map;
+
+class MapUpdater
+{
+public:
+  MapUpdater ();
+  virtual ~MapUpdater ();
+
+  friend class MapUpdateRequest;
+
+  /// schedule update on a map, the update will start
+  /// as soon as possible ,
+  /// it may even start before the call returns
+  int schedule_update(Map& map, ACE_UINT32 diff);
+
+  /// Wait untill all pending updates finish
+  int wait ();
+
+  /// Start the worker threads
+  int activate (size_t num_threads);
+
+  /// Stop the worker threads
+  int deactivate (void);
+
+  bool activated ();
+
+private:
+  /// hook called by worker threads
+  void update_finished ();
+
+  DelayExecutor m_executor;
+  ACE_Condition_Thread_Mutex m_condition;
+  ACE_Thread_Mutex m_mutex;
+  size_t pedning_requests;
+};
+
+#endif //_MAP_UPDATER_H_INCLUDED
diff --git a/src/shared/DelayExecutor.cpp b/src/shared/DelayExecutor.cpp
new file mode 100644
index 0000000..d567ceb
--- /dev/null
+++ b/src/shared/DelayExecutor.cpp
@@ -0,0 +1,130 @@
+#include <ace/Singleton.h>
+#include <ace/Thread_Mutex.h>
+
+#include "DelayExecutor.h"
+
+#include <ace/Log_Msg.h>
+
+DelayExecutor*
+DelayExecutor::instance ()
+{
+  return ACE_Singleton<DelayExecutor, ACE_Thread_Mutex>::instance ();
+}
+
+DelayExecutor::DelayExecutor () :
+activated_ (false),
+pre_svc_hook_ (0),
+post_svc_hook_ (0) { }
+
+DelayExecutor::~DelayExecutor ()
+{
+  if (pre_svc_hook_)
+    delete pre_svc_hook_;
+
+  if (post_svc_hook_)
+    delete post_svc_hook_;
+
+  this->deactivate ();
+
+  //todo probably free the queue ??
+}
+
+int
+DelayExecutor::Deactivate ()
+{
+  if (!this->activated ())
+    return -1;
+
+  this->activated (false);
+
+  this->queue_.queue ()->deactivate ();
+
+  this->wait ();
+
+  return 0;
+}
+
+int
+DelayExecutor::svc (void)
+{
+  if (pre_svc_hook_)
+    pre_svc_hook_->call ();
+
+  for (;
+    {
+      ACE_Method_Request* rq = this->queue_.dequeue ();
+
+      if (!rq)
+        break;
+
+      rq->call ();
+
+      delete rq;
+    }
+
+  if (post_svc_hook_)
+    post_svc_hook_->call ();
+
+  return 0;
+}
+
+int
+DelayExecutor::activate (int num_threads,
+                         ACE_Method_Request* pre_svc_hook,
+                         ACE_Method_Request* post_svc_hook)
+{
+  if (this->activated ())
+    return -1;
+
+  if (num_threads < 1)
+    return -1;
+
+  if (pre_svc_hook_)
+    delete pre_svc_hook_;
+
+  if (post_svc_hook_)
+    delete post_svc_hook_;
+
+  this->pre_svc_hook_ = pre_svc_hook;
+  this->post_svc_hook_ = post_svc_hook;
+
+  this->queue_.queue ()->activate ();
+
+  if( ACE_Task_Base::activate (THR_NEW_LWP | THR_JOINABLE | THR_INHERIT_SCHED,
+                                  num_threads) == -1)
+    return -1;
+
+  this->activated(true);
+
+  return true;
+}
+
+int
+DelayExecutor::execute (ACE_Method_Request* new_req)
+{
+  if(new_req == NULL)
+    return -1;
+
+  if(this->queue_.enqueue (new_req,
+                           (ACE_Time_Value*)&ACE_Time_Value::zero) == -1)
+    {
+      delete new_req;
+      ACE_ERROR_RETURN ((LM_ERROR,
+                         ACE_TEXT ("(%t) %p\\n"),
+                         ACE_TEXT ("DelayExecutor::execute enqueue")),
+                        -1);
+    }
+  return 0;
+}
+
+bool
+DelayExecutor::activated ()
+{
+  return this->activated_;
+}
+
+void
+DelayExecutor::activated (bool s)
+{
+  this->activated_ = s;
+}
diff --git a/src/shared/DelayExecutor.h b/src/shared/DelayExecutor.h
new file mode 100644
index 0000000..18c6a1b
--- /dev/null
+++ b/src/shared/DelayExecutor.h
@@ -0,0 +1,39 @@
+#ifndef _M_DELAY_EXECUTOR_H
+#define    _M_DELAY_EXECUTOR_H
+
+#include <ace/Task.h>
+#include <ace/Activation_Queue.h>
+#include <ace/Method_Request.h>
+
+class DelayExecutor : protected ACE_Task_Base
+{
+public:
+  DelayExecutor ();
+  virtual ~DelayExecutor ();
+
+  static DelayExecutor* instance ();
+
+  /// example
+  /// DelayExecutor::instance ()->execute(new MyRequest(myarg));
+  /// returns -1 on failures
+  int execute (ACE_Method_Request* new_req);
+
+  int activate (int num_threads = 1,
+                ACE_Method_Request* pre_svc_hook = 0,
+                ACE_Method_Request* post_svc_hook = 0);
+
+  int deactivate ();
+
+  bool activated ();
+
+  virtual int svc (void);
+private:
+  ACE_Activation_Queue queue_;
+  ACE_Method_Request* pre_svc_hook_;
+  ACE_Method_Request* post_svc_hook_;
+
+  void activated (bool s);
+  bool activated_;
+};
+
+#endif // _M_DELAY_EXECUTOR_H

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use