Skip to content
Snippets Groups Projects
Commit 9e4c9f80 authored by Millian Poquet's avatar Millian Poquet
Browse files

update simgrid simulator

parent 366e88f9
No related branches found
No related tags found
No related merge requests found
...@@ -15,7 +15,11 @@ deps = [ ...@@ -15,7 +15,11 @@ deps = [
protocol_dep protocol_dep
] ]
simulator = executable('simulator', ['src/main.cpp', 'src/orchestrator.cpp', 'src/orchestrator.hpp'], simulator = executable('simulator', [
'src/main.cpp',
'src/orchestrator.cpp', 'src/orchestrator.hpp',
'src/compute.cpp', 'src/compute.hpp'
],
include_directories: 'src', include_directories: 'src',
dependencies: deps, dependencies: deps,
install: true install: true
......
#include <simgrid/s4u.hpp>
float desired_flops_to_simulated_flops(float flops)
{
return flops * 1.0f;
}
#pragma once
float desired_flops_to_simulated_flops(float flops);
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
#include <protocol/hello.pb.h> #include <protocol/hello.pb.h>
#include "compute.hpp"
XBT_LOG_NEW_DEFAULT_CATEGORY(orchestrator, "The logging channel used by this module"); XBT_LOG_NEW_DEFAULT_CATEGORY(orchestrator, "The logging channel used by this module");
const char * orchestrator_name(void) const char * orchestrator_name(void)
...@@ -41,6 +43,29 @@ void orchestrator(void) ...@@ -41,6 +43,29 @@ void orchestrator(void)
zmq_msg_init(&msg); zmq_msg_init(&msg);
if (zmq_msg_recv(&msg, socket, 0) == -1) if (zmq_msg_recv(&msg, socket, 0) == -1)
throw std::runtime_error(std::string("cannot read message on socket (errno=") + strerror(errno) + ")"); throw std::runtime_error(std::string("cannot read message on socket (errno=") + strerror(errno) + ")");
hello::Order order;
if (order.ParseFromArray(zmq_msg_data(&msg), zmq_msg_size(&msg)) != true)
throw std::runtime_error("cannot parse received message as an Order");
switch (order.order_case())
{
case hello::Order::kHello:
XBT_INFO("received hello from %s", order.hello().name().c_str());
break;
case hello::Order::kBye:
XBT_INFO("received bye");
bye_received = true;
break;
case hello::Order::kComputeFlops: {
float desired_flops = order.compute_flops().flop_amount();
float actual_flops = desired_flops_to_simulated_flops(desired_flops);
XBT_INFO("computing %g flops", actual_flops);
simgrid::s4u::this_actor::execute(actual_flops);
} break;
default:
throw std::runtime_error("unhandled order case received");
}
} }
zmq_close(socket); zmq_close(socket);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment