Commit 2ee9b056 authored by neverlord's avatar neverlord

benchmark update

parent ba07120a
#!/bin/bash #!/bin/bash
IFLAGS="-I../../Theron/Include/" IFLAGS="-I../../Theron/Include/"
LFLAGS="-L../../Theron/Lib -ltheron -lboost_thread" LFLAGS="-L../../Theron/Lib -ltheron -lboost_thread"
FLAGS="-O2 -fno-strict-aliasing -DNDEBUG" FLAGS="-O2 -fno-strict-aliasing -DNDEBUG -DTHERON_MAX_ACTORS=530000"
for i in theron_*.cpp ; do for i in theron_*.cpp ; do
echo "compile $i"
out_file=$(echo $i | sed 's/\(.*\)\..*/\1/') out_file=$(echo $i | sed 's/\(.*\)\..*/\1/')
echo "out_file = $out_file" echo "g++ -std=c++0x $i -o $out_file $FLAGS $LFLAGS $IFLAGS"
g++ -std=c++0x $i -o $out_file $FLAGS $LFLAGS $IFLAGS g++ -std=c++0x $i -o $out_file $FLAGS $LFLAGS $IFLAGS
done done
...@@ -15,18 +15,13 @@ using std::endl; ...@@ -15,18 +15,13 @@ using std::endl;
using std::int64_t; using std::int64_t;
using std::uint32_t; using std::uint32_t;
using namespace Theron;
struct spread { int value; }; struct spread { int value; };
struct result { uint32_t value; }; struct result { uint32_t value; };
THERON_REGISTER_MESSAGE(spread); using namespace Theron;
THERON_REGISTER_MESSAGE(result);
template<typename RefType>
struct testee_base : Actor;
struct testee : testee_base<RefType> struct testee : Actor
{ {
typedef struct { Address arg0; } Parameters; typedef struct { Address arg0; } Parameters;
...@@ -34,7 +29,7 @@ struct testee : testee_base<RefType> ...@@ -34,7 +29,7 @@ struct testee : testee_base<RefType>
Address m_parent; Address m_parent;
bool m_first_result_received; bool m_first_result_received;
uint32_t m_first_result; uint32_t m_first_result;
std::vector<RefType> m_children; std::vector<ActorRef> m_children;
void spread_handler(spread const& arg, const Address) void spread_handler(spread const& arg, const Address)
{ {
...@@ -48,7 +43,7 @@ struct testee : testee_base<RefType> ...@@ -48,7 +43,7 @@ struct testee : testee_base<RefType>
Parameters params = {GetAddress()}; Parameters params = {GetAddress()};
for (int i = 0; i < 2; ++i) for (int i = 0; i < 2; ++i)
{ {
m_children.push_back(GetFramework().CreateActor<testee<RefType>>(params)); m_children.push_back(GetFramework().CreateActor<testee>(params));
m_children.back().Push(msg, GetAddress()); m_children.back().Push(msg, GetAddress());
} }
} }
...@@ -63,15 +58,15 @@ struct testee : testee_base<RefType> ...@@ -63,15 +58,15 @@ struct testee : testee_base<RefType>
} }
else else
{ {
Send(result{m_first_result + arg.value}); Send(result{m_first_result + arg.value}, m_parent);
m_children.clear(); m_children.clear();
} }
} }
send_testee(Parameters const& p) : m_parent(p.arg0), m_first_result_received(false) testee(Parameters const& p) : m_parent(p.arg0), m_first_result_received(false)
{ {
RegisterHandler(this, &send_testee::spread_handler); RegisterHandler(this, &testee::spread_handler);
RegisterHandler(this, &send_testee::result_handler); RegisterHandler(this, &testee::result_handler);
} }
}; };
...@@ -92,8 +87,9 @@ int main(int argc, char** argv) ...@@ -92,8 +87,9 @@ int main(int argc, char** argv)
} }
int num = rd<int>(argv[2]); int num = rd<int>(argv[2]);
Receiver r; Receiver r;
Framework framework; Framework framework(num_cores());
ActorRef aref(framework.CreateActor<testee>(teste::Parameters{r.GetAddress()})); ActorRef aref(framework.CreateActor<testee>(testee::Parameters{r.GetAddress()}));
aref.Push(spread{num}, r.GetAddress()); aref.Push(spread{num}, r.GetAddress());
r.Wait(); r.Wait();
} }
...@@ -70,7 +70,7 @@ int main(int argc, char** argv) ...@@ -70,7 +70,7 @@ int main(int argc, char** argv)
Receiver r; Receiver r;
t_max = num_sender * num_msgs; t_max = num_sender * num_msgs;
auto receiverAddr = r.GetAddress(); auto receiverAddr = r.GetAddress();
Framework framework; Framework framework(num_cores());
ActorRef aref(framework.CreateActor<receiver>()); ActorRef aref(framework.CreateActor<receiver>());
std::list<std::thread> threads; std::list<std::thread> threads;
auto impl_fun = (impl == push_impl) ? send_sender : push_sender; auto impl_fun = (impl == push_impl) ? send_sender : push_sender;
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#define UTILITY_HPP #define UTILITY_HPP
#include <stdexcept> #include <stdexcept>
#include <algorithm>
template<typename T> template<typename T>
T rd(char const* cstr) T rd(char const* cstr)
...@@ -52,12 +53,15 @@ T rd(char const* cstr) ...@@ -52,12 +53,15 @@ T rd(char const* cstr)
int num_cores() int num_cores()
{ {
char cbuf[100]; char cbuf[100];
FILE* cmd = popen("cat /proc/cpuinfo | grep processor | wc -l", "r"); FILE* cmd = popen("/bin/cat /proc/cpuinfo | /bin/grep processor | /usr/bin/wc -l", "r");
if (fgets(cbuf, 100, get_uuid_cmd) != 0) if (fgets(cbuf, 100, cmd) == 0)
{ {
throw std::runtime_error("cannot determine number of cores"); throw std::runtime_error("cannot determine number of cores");
} }
pclose(cmd); pclose(cmd);
// erase trailing newline
auto i = std::find(cbuf, cbuf + 100, '\n');
*i = '\0';
return rd<int>(cbuf); return rd<int>(cbuf);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment