diff --git a/simgrid-simulator/meson.build b/simgrid-simulator/meson.build index 451f2dba9626729e13fe439602b7c0af8943bd7e..6de27345adb2a435a692efa6ee00c762e3f0542e 100644 --- a/simgrid-simulator/meson.build +++ b/simgrid-simulator/meson.build @@ -15,7 +15,11 @@ deps = [ 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', dependencies: deps, install: true diff --git a/simgrid-simulator/src/compute.cpp b/simgrid-simulator/src/compute.cpp new file mode 100644 index 0000000000000000000000000000000000000000..49f3463fa883269dcc1f8ebe1bd2c41dae8f0957 --- /dev/null +++ b/simgrid-simulator/src/compute.cpp @@ -0,0 +1,6 @@ +#include <simgrid/s4u.hpp> + +float desired_flops_to_simulated_flops(float flops) +{ + return flops * 1.0f; +} diff --git a/simgrid-simulator/src/compute.hpp b/simgrid-simulator/src/compute.hpp new file mode 100644 index 0000000000000000000000000000000000000000..a10f160ddb043bb604f789658062aaa35f964c34 --- /dev/null +++ b/simgrid-simulator/src/compute.hpp @@ -0,0 +1,3 @@ +#pragma once + +float desired_flops_to_simulated_flops(float flops); diff --git a/simgrid-simulator/src/orchestrator.cpp b/simgrid-simulator/src/orchestrator.cpp index 703fe93d28a7ab1b3c1fa91ad4e39ba675beb4ae..ca453e5d6f7cd86eb5632b3969f067a05d8e924f 100644 --- a/simgrid-simulator/src/orchestrator.cpp +++ b/simgrid-simulator/src/orchestrator.cpp @@ -3,6 +3,8 @@ #include <protocol/hello.pb.h> +#include "compute.hpp" + XBT_LOG_NEW_DEFAULT_CATEGORY(orchestrator, "The logging channel used by this module"); const char * orchestrator_name(void) @@ -41,6 +43,29 @@ void orchestrator(void) zmq_msg_init(&msg); if (zmq_msg_recv(&msg, socket, 0) == -1) 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);