Commit bbb1f5ef authored by Millian Poquet's avatar Millian Poquet

Bugfix: machine identification numbers were invalid due to the way the...

Bugfix: machine identification numbers were invalid due to the way the master_host was handled. Bugfix: changing the pstate of a sleeping machine was forbidden. Bugfix: switch_on_machine_process and switch_off_machine_process calls were inverted. Bugfix: private attribute id of hosts were called. Bugfix: in switch_on_machine_process, the wrong pstate was used to access to the virtual SWITCH_ON pstate in the sleep_pstates map. Bugfix: static arrays were used for computing the virtual task associated with every SWITCH_ON or SWITCH_OFF.
parent 180dc47a
......@@ -39,12 +39,11 @@ void Machines::createMachines(xbt_dynar_t hosts, BatsimContext *context, const s
_machines.reserve(nb_machines);
msg_host_t host;
unsigned int i;
unsigned int i, id=0;
xbt_dynar_foreach(hosts, i, host)
{
Machine * machine = new Machine;
machine->id = i;
machine->name = MSG_host_get_name(host);
machine->host = host;
machine->jobs_being_computed = {};
......@@ -173,10 +172,15 @@ void Machines::createMachines(xbt_dynar_t hosts, BatsimContext *context, const s
}
if (machine->name != masterHostName)
{
machine->id = id;
++id;
_machines.push_back(machine);
}
else
{
xbt_assert(_masterMachine == nullptr);
xbt_assert(_masterMachine == nullptr, "There are two master hosts...");
machine->id = -1;
_masterMachine = machine;
}
}
......
......@@ -308,8 +308,8 @@ int request_reply_scheduler_process(int argc, char *argv[])
{
xbt_assert(parts2.size() == 3, "Invalid event received ('%s'): pstate modifications must be composed of 3 parts separated by ':'",
event_string.c_str());
xbt_assert(context->energy_used, "A pstate modification message has been received alors energy is not used by Batsim."
" You can switch energy ON by a Batsim command-line option.");
xbt_assert(context->energy_used, "A pstate modification message has been received whereas energy is not currently used by Batsim."
" You can use the energy plugin of Batsim via a command-line option, try --help to display those options.");
PStateModificationMessage * message = new PStateModificationMessage;
......@@ -324,7 +324,9 @@ int request_reply_scheduler_process(int argc, char *argv[])
xbt_assert(context->machines.exists(machineID), "Invalid event received ('%s'): machine %d does not exist", event_string.c_str(), machineID);
Machine * machine = context->machines[machineID];
xbt_assert(machine->state == MachineState::IDLE, "Invalid event received ('%s'): machine %d's pstate can only be changed while the machine is idle, which is not the case now.", event_string.c_str(), machineID);
xbt_assert(machine->state == MachineState::IDLE || machine->state == MachineState::SLEEPING,
"Invalid event received ('%s'): machine %d's pstate can only be changed while the"
" machine is idle or sleeping, which is not the case now.", event_string.c_str(), machineID);
xbt_assert(context->machines[machineID]->has_pstate(pstate), "Invalid event received ('%s'): machine %d has no pstate %d", event_string.c_str(), machineID, pstate);
int current_pstate = MSG_host_get_pstate(machine->host);
......@@ -495,7 +497,7 @@ int uds_server_process(int argc, char *argv[])
args->message->new_pstate = message->new_pstate;
string pname = "switch ON " + to_string(message->machine);
MSG_process_create(pname.c_str(), switch_on_machine_process, (void*)args, machine->host);
MSG_process_create(pname.c_str(), switch_off_machine_process, (void*)args, machine->host);
}
else
XBT_CERROR(server, "Switching from a communication pstate to an invalid pstate on machine %d ('%s') : %d -> %d",
......@@ -503,7 +505,9 @@ int uds_server_process(int argc, char *argv[])
}
else if (machine->pstates[curr_pstate] == PStateType::SLEEP_PSTATE)
{
xbt_assert(machine->pstates[message->new_pstate] == PStateType::COMPUTATION_PSTATE);
xbt_assert(machine->pstates[message->new_pstate] == PStateType::COMPUTATION_PSTATE,
"Switching from a sleep pstate to a non-computation pstate on machine %d ('%s') : %d -> %d, which is forbidden",
machine->id, machine->name.c_str(), curr_pstate, message->new_pstate);
machine->state = MachineState::TRANSITING_FROM_SLEEPING_TO_COMPUTING;
SwitchPStateProcessArguments * args = new SwitchPStateProcessArguments;
......@@ -513,7 +517,7 @@ int uds_server_process(int argc, char *argv[])
args->message->new_pstate = message->new_pstate;
string pname = "switch OFF " + to_string(message->machine);
MSG_process_create(pname.c_str(), switch_off_machine_process, (void*)args, machine->host);
MSG_process_create(pname.c_str(), switch_on_machine_process, (void*)args, machine->host);
}
else
XBT_CERROR(server, "Machine %d ('%s') has an invalid pstate : %d", machine->id, machine->name.c_str(), curr_pstate);
......
......@@ -20,21 +20,26 @@ int switch_on_machine_process(int argc, char *argv[])
xbt_assert(args->context->machines.exists(machineID));
Machine * machine = args->context->machines[machineID];
xbt_assert(machine->host->id() == MSG_process_get_host(MSG_process_self())->id());
xbt_assert(machine->host == MSG_process_get_host(MSG_process_self()));
xbt_assert(machine->state == MachineState::TRANSITING_FROM_SLEEPING_TO_COMPUTING);
xbt_assert(machine->jobs_being_computed.empty());
xbt_assert(machine->has_pstate(pstate));
xbt_assert(machine->pstates[pstate] == PStateType::COMPUTATION_PSTATE);
int on_ps = machine->sleep_pstates[pstate]->switch_on_virtual_pstate;
int current_pstate = MSG_host_get_pstate(machine->host);
int on_ps = machine->sleep_pstates[current_pstate]->switch_on_virtual_pstate;
XBT_INFO("Switching machine %d ('%s') ON. Passing in virtual pstate %d to do so", machine->id,
machine->name.c_str(), on_ps);
MSG_host_set_pstate(machine->host, on_ps);
msg_host_t host_list[1] = {machine->host};
double flop_amount[1] = {1};
double bytes_amount[1] = {0};
// double flop_amount[1] = {1};
// double bytes_amount[1] = {0};
double * flop_amount = xbt_new(double, 1);
double * bytes_amount = xbt_new(double, 1);
flop_amount[0] = 1;
bytes_amount[0] = 0;
msg_task_t bootup = MSG_parallel_task_create("switch ON", 1, host_list, flop_amount, bytes_amount, NULL);
XBT_INFO("Computing 1 flop to simulate time & energy cost of switch ON");
......@@ -65,7 +70,7 @@ int switch_off_machine_process(int argc, char *argv[])
xbt_assert(args->context->machines.exists(machineID));
Machine * machine = args->context->machines[machineID];
xbt_assert(machine->host->id() == MSG_process_get_host(MSG_process_self())->id());
xbt_assert(machine->host == MSG_process_get_host(MSG_process_self()));
xbt_assert(machine->state == MachineState::TRANSITING_FROM_COMPUTING_TO_SLEEPING);
xbt_assert(machine->jobs_being_computed.empty());
xbt_assert(machine->has_pstate(pstate));
......@@ -78,8 +83,12 @@ int switch_off_machine_process(int argc, char *argv[])
MSG_host_set_pstate(machine->host, off_ps);
msg_host_t host_list[1] = {machine->host};
double flop_amount[1] = {1};
double bytes_amount[1] = {0};
// double flop_amount[1] = {1};
// double bytes_amount[1] = {0};
double * flop_amount = xbt_new(double, 1);
double * bytes_amount = xbt_new(double, 1);
flop_amount[0] = 1;
bytes_amount[0] = 0;
msg_task_t shutdown = MSG_parallel_task_create("switch OFF", 1, host_list, flop_amount, bytes_amount, NULL);
XBT_INFO("Computing 1 flop to simulate time & energy cost of switch OFF");
......
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