communicator::~communicator()
{
- m_task_t task;
+ msg_task_t task;
XBT_DEBUG("send finalize to receiver/ctrl");
task = MSG_task_create("finalize", 0.0, 0, NULL);
msg_comm_t communicator::real_send(const char* dest, message* msg)
{
XBT_DEBUG("send %s to %s", msg->to_string().c_str(), dest);
- m_task_t task = MSG_task_create("message", 0.0, msg->get_size(), msg);
+ msg_task_t task = MSG_task_create("message", 0.0, msg->get_size(), msg);
// MSG_task_set_category(task,
// msg->get_type() == message::DATA ?
// TRACE_CAT_DATA : TRACE_CAT_CTRL);
xbt_dynar_t comms = xbt_dynar_new(sizeof(msg_comm_t), NULL);
struct channel {
msg_comm_t comm;
- m_task_t task;
+ msg_task_t task;
const char* mbox;
message_queue& received;
};
#include "hostdata.h"
#include "messages.h"
#include "msg_thread.h"
+#include "simgrid_features.h"
class communicator {
public:
// Try to get a message. Returns true on success.
// Parameter "timeout" may be 0 for non-blocking operation, -1 for
// infinite waiting, or any positive timeout.
- bool ctrl_recv(message*& msg, m_host_t& from, double timeout) {
+ bool ctrl_recv(message*& msg, msg_host_t& from, double timeout) {
return ctrl_received.pop(msg, from, timeout);
}
- bool data_recv(message*& msg, m_host_t& from, double timeout) {
+ bool data_recv(message*& msg, msg_host_t& from, double timeout) {
return data_received.pop(msg, from, timeout);
}
#if SIMGRID_VERSION < MAKE_SIMGRID_VERSION(3, 7, 0)
int nhosts = MSG_get_host_number();
- m_host_t* host_list = MSG_get_host_table();
+ msg_host_t* host_list = MSG_get_host_table();
#else // API changed with SG 3.7.0
xbt_dynar_t host_dynar = MSG_hosts_as_dynar();
int nhosts = xbt_dynar_length(host_dynar);
- m_host_t* host_list = static_cast<m_host_t*>(xbt_dynar_to_array(host_dynar));
+ msg_host_t* host_list = static_cast<msg_host_t*>(xbt_dynar_to_array(host_dynar));
#endif
// only sort hosts for automatically created deployment
if (opt::auto_depl::enabled)
// hosts are automatically destroyed...
}
-hostdata::hostdata(m_host_t host)
+hostdata::hostdata(msg_host_t host)
: name(MSG_host_get_name(host))
, ctrl_mbox(std::string(name) + "_ctrl")
, data_mbox(std::string(name) + "_data")
#include <string>
#include <vector>
#include <msg/msg.h>
+#include "simgrid_features.h"
// Helper class that associates instances of itself with each host.
// Facilitate global operations on hosts, and retreiving of host name
static size_t size() { return hosts.size(); }
static const hostdata& at(size_t i) { return hosts[i]; }
- hostdata(m_host_t host);
+ hostdata(msg_host_t host);
~hostdata();
const char* get_name() const { return name; }
double simulated_time = -1.0;
timestamp elapsed_time(timestamp::wallclock_time);
timestamp simulation_time(timestamp::cpu_time);
- MSG_error_t res;
+ msg_error_t res;
elapsed_time.start();
simulation_time.start();
return oss.str();
}
-void message_queue::push(m_task_t task)
+void message_queue::push(msg_task_t task)
{
if (queue.push(task)) {
// list was empty, the push must be signaled
}
}
-bool message_queue::pop(message*& msg, m_host_t& from, double timeout)
+bool message_queue::pop(message*& msg, msg_host_t& from, double timeout)
{
- m_task_t task;
+ msg_task_t task;
if (!queue.try_pop(task)) {
if (timeout == 0.0)
return false;
#include <queue>
#include <string>
#include <msg/msg.h>
+#include "simgrid_features.h"
#include "synchro.h"
#include "sync_queue.h"
class message_queue {
public:
// Push a message on queue
- void push(m_task_t task);
+ void push(msg_task_t task);
// Try to pop a message. Returns true on success.
// Parameter "timeout" may be 0 for non-blocking operation, -1 for
// infinite waiting, or any positive timeout.
- bool pop(message*& msg, m_host_t& from, double timeout);
+ bool pop(message*& msg, msg_host_t& from, double timeout);
bool empty() const { return queue.empty(); }
size_t size() const { return queue.size(); }
private:
mutex_t mutex;
condition_t cond;
- sync_queue<m_task_t> queue;
+ sync_queue<msg_task_t> queue;
};
#endif // !MESSAGES_H
#include <string>
#include <msg/msg.h>
+#include "simgrid_features.h"
#include "synchro.h"
class msg_thread {
bool started;
mutex_t mutex;
condition_t cond;
- m_process_t thread;
+ msg_process_t thread;
std::string thread_name;
void run_wrapper();
pneigh.reserve(neigh.size());
for (unsigned i = 0 ; i < neigh.size() ; i++) {
neighbor* ptr = &neigh[i];
- m_host_t host = MSG_get_host_by_name(ptr->get_name());
+ msg_host_t host = MSG_get_host_by_name(ptr->get_name());
pneigh.push_back(ptr);
rev_neigh.insert(std::make_pair(host, ptr));
}
idle_duration += MSG_get_clock() - idle_since_date;
++comp_iter;
double flops = opt::comp_cost(real_load);
- m_task_t task = MSG_task_create("computation", flops, 0.0, NULL);
+ msg_task_t task = MSG_task_create("computation", flops, 0.0, NULL);
// MSG_task_set_category(task, TRACE_CAT_COMP);
XBT_DEBUG("compute %g flop%s", flops, ESSE(flops));
MSG_task_execute(task);
void process::ctrl_receive(double timeout)
{
message* msg;
- m_host_t from;
+ msg_host_t from;
XBT_DEBUG("%sblocking receive on ctrl (%g)", "\0non-" + !timeout, timeout);
while (ctrl_close_pending && comm.ctrl_recv(msg, from, timeout)) {
void process::data_receive(double timeout)
{
message* msg;
- m_host_t from;
+ msg_host_t from;
XBT_DEBUG("%sblocking receive on data (%g)", "\0non-" + !timeout, timeout);
while (data_close_pending && comm.data_recv(msg, from, timeout)) {
}
}
-void process::handle_message(message* msg, m_host_t from)
+void process::handle_message(message* msg, msg_host_t from)
{
switch (msg->get_type()) {
case message::CTRL: {
#include "msg_thread.h"
#include "neighbor.h"
#include "options.h"
+#include "simgrid_features.h"
#include "synchro.h"
class process {
static std::atomic<int> convergence_counter;
- typedef MAP_TEMPLATE<m_host_t, neighbor*> rev_neigh_type;
+ typedef MAP_TEMPLATE<msg_host_t, neighbor*> rev_neigh_type;
neigh_type neigh; // list of neighbors (do not alter
// after construction!)
- rev_neigh_type rev_neigh; // map m_host_t -> neighbor
+ rev_neigh_type rev_neigh; // map msg_host_t -> neighbor
communicator comm; // communicator for this process
int ctrl_close_pending; // number of "close" messages to wait
// infinite waiting, or any positive timeout.
void ctrl_receive(double timeout);
void data_receive(double timeout);
- void handle_message(message* msg, m_host_t from);
+ void handle_message(message* msg, msg_host_t from);
};
template <typename Compare>
#if SIMGRID_VERSION < MAKE_SIMGRID_VERSION(3, 8, 0) // ==== SG < 3.8 === //
# define MSG_init(argc, argv) MSG_global_init(argc, argv)
+# define msg_error_t MSG_error_t
+# define msg_host_t m_host_t
+# define msg_process_t m_process_t
+# define msg_task_t m_task_t
#endif // ============================================================== //
#endif // !SIMGRID_FEATURES_H