}
m_task_t communicator::recv()
-{
+{
m_task_t task = NULL;
if (comm_test_n_destroy(recv_comm)) {
task = recv_task;
simulation_time.start();
- // Set default logging threshold.
+ // Set default logging parameters
// xbt_log_control_set("simu.thres:verbose");
+ xbt_log_control_set("simu.fmt:'[%h %r] [%c/%p] %m%n'");
// Initialize some MSG internal data.
// Note: MSG_global_init() may throw an exception, but it seems
}
opt::print();
- TRY {
+ TRY {
exit_status = EXIT_FAILURE_INIT; // =====
// Register the main function of an agent in a global table.
int help_requested = 0;
bool version_requested = false;
- cost_func comp_cost("1, 0");
- cost_func comm_cost("1, 0");
+ cost_func comp_cost("1e9, 0"); // fixme: find better defaults
+ cost_func comm_cost("1e9, 0"); // fixme: find better defaults
} // namespace opt
return 1;
}
-
+
void opt::print()
{
INFO0(",----[ Simulation parameters ]");
int process::run()
{
INFO0("Coucou !");
- MSG_process_sleep(100.0); // xxx
+
+ int n = 100;
+ while (n--) {
+ compute();
+ receive();
+ }
+ // MSG_process_sleep(100.0); // xxx
/* xxx:
* while (there is something to do) {
* compute some task;
return 0;
}
+void process::receive()
+{
+ m_task_t task;
+ while ((task = comm.recv())) {
+ message *msg = (message *)MSG_task_get_data(task);
+ DEBUG3("Received load: %g, info: %g from %s",
+ msg->transfer, msg->measure,
+ MSG_host_get_name(MSG_task_get_source(task)));
+ load += msg->transfer;
+ // fixme: what is xxx ???
+ // neigh[xxx].setLoad(msg->measure);
+ }
+}
+
void process::compute()
{
double duration = opt::comp_cost(load);
m_task_t task = MSG_task_create("computation", duration, 0.0, NULL);
+ DEBUG2("Compute %g flop%s.", duration, duration > 1 ? "s" : "");
MSG_task_execute(task);
MSG_task_destroy(task);
}
std::vector<neighbor> neigh;
double load;
+ void receive();
void compute();
void print_loads(e_xbt_log_priority_t logp = xbt_log_priority_info);
};
MSG_global_init(&argc, argv);
exit_status = EXIT_FAILURE_ARGS; // =====
- TRY {
+ TRY {
// Parse global parameters
if (argc != 3) {
void start()
{
- getrusage(RUSAGE_SELF, &before);
+ getrusage(RUSAGE_SELF, &before);
}
void stop()
{
- getrusage(RUSAGE_SELF, &after);
+ getrusage(RUSAGE_SELF, &after);
difference = difference + ((after.ru_utime + after.ru_stime) -
(before.ru_utime + before.ru_stime));
}