Commit 2ee9b056 authored by neverlord's avatar neverlord

benchmark update

parent ba07120a
#!/bin/bash
IFLAGS="-I../../Theron/Include/"
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
echo "compile $i"
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
done
......@@ -15,18 +15,13 @@ using std::endl;
using std::int64_t;
using std::uint32_t;
using namespace Theron;
struct spread { int value; };
struct result { uint32_t value; };
THERON_REGISTER_MESSAGE(spread);
THERON_REGISTER_MESSAGE(result);
template<typename RefType>
struct testee_base : Actor;
using namespace Theron;
struct testee : testee_base<RefType>
struct testee : Actor
{
typedef struct { Address arg0; } Parameters;
......@@ -34,7 +29,7 @@ struct testee : testee_base<RefType>
Address m_parent;
bool m_first_result_received;
uint32_t m_first_result;
std::vector<RefType> m_children;
std::vector<ActorRef> m_children;
void spread_handler(spread const& arg, const Address)
{
......@@ -48,7 +43,7 @@ struct testee : testee_base<RefType>
Parameters params = {GetAddress()};
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());
}
}
......@@ -63,15 +58,15 @@ struct testee : testee_base<RefType>
}
else
{
Send(result{m_first_result + arg.value});
Send(result{m_first_result + arg.value}, m_parent);
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, &send_testee::result_handler);
RegisterHandler(this, &testee::spread_handler);
RegisterHandler(this, &testee::result_handler);
}
};
......@@ -92,8 +87,9 @@ int main(int argc, char** argv)
}
int num = rd<int>(argv[2]);
Receiver r;
Framework framework;
ActorRef aref(framework.CreateActor<testee>(teste::Parameters{r.GetAddress()}));
Framework framework(num_cores());
ActorRef aref(framework.CreateActor<testee>(testee::Parameters{r.GetAddress()}));
aref.Push(spread{num}, r.GetAddress());
r.Wait();
}
......@@ -70,7 +70,7 @@ int main(int argc, char** argv)
Receiver r;
t_max = num_sender * num_msgs;
auto receiverAddr = r.GetAddress();
Framework framework;
Framework framework(num_cores());
ActorRef aref(framework.CreateActor<receiver>());
std::list<std::thread> threads;
auto impl_fun = (impl == push_impl) ? send_sender : push_sender;
......
......@@ -32,6 +32,7 @@
#define UTILITY_HPP
#include <stdexcept>
#include <algorithm>
template<typename T>
T rd(char const* cstr)
......@@ -52,12 +53,15 @@ T rd(char const* cstr)
int num_cores()
{
char cbuf[100];
FILE* cmd = popen("cat /proc/cpuinfo | grep processor | wc -l", "r");
if (fgets(cbuf, 100, get_uuid_cmd) != 0)
FILE* cmd = popen("/bin/cat /proc/cpuinfo | /bin/grep processor | /usr/bin/wc -l", "r");
if (fgets(cbuf, 100, cmd) == 0)
{
throw std::runtime_error("cannot determine number of cores");
}
pclose(cmd);
// erase trailing newline
auto i = std::find(cbuf, cbuf + 100, '\n');
*i = '\0';
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