Commit f54da0a9 authored by Millian Poquet's avatar Millian Poquet
Browse files

New output file when energy is enabled: OUT_pstate_changes.csv stores when...

New output file when energy is enabled: OUT_pstate_changes.csv stores when pstates are changed on every machine."o
parent 6aa4da5b
......@@ -209,7 +209,7 @@ int main(int argc, char * argv[])
load_json_workload(&context, mainArgs.workloadFilename);
context.jobs.setProfiles(&context.profiles);
context.tracer.setFilename(mainArgs.exportPrefix + "_schedule.trace");
context.paje_tracer.setFilename(mainArgs.exportPrefix + "_schedule.trace");
//context.jobs.displayDebug();
XBT_INFO("Checking whether SMPI is used or not...");
......@@ -229,10 +229,17 @@ int main(int argc, char * argv[])
context.machines.createMachines(hosts, &context, mainArgs.masterHostName);
xbt_dynar_free(&hosts);
const Machine * masterMachine = context.machines.masterMachine();
context.machines.setTracer(&context.tracer);
context.tracer.initialize(&context, MSG_get_clock());
context.machines.setTracer(&context.paje_tracer);
context.paje_tracer.initialize(&context, MSG_get_clock());
XBT_INFO("Machines created successfully. There are %lu computing machines.", context.machines.machines().size());
if (context.energy_used)
{
context.pstate_tracer.setFilename(mainArgs.exportPrefix + "_pstate_changes.csv");
for (const Machine * machine : context.machines.machines())
context.pstate_tracer.add_pstate_change(MSG_get_clock(), machine->id, MSG_host_get_pstate(machine->host));
}
// Socket
context.socket.create_socket(mainArgs.socketFilename);
context.socket.accept_pending_connection();
......@@ -253,7 +260,7 @@ int main(int argc, char * argv[])
msg_error_t res = MSG_main();
// Finalization
context.tracer.finalize(&context, MSG_get_clock());
context.paje_tracer.finalize(&context, MSG_get_clock());
exportScheduleToCSV(mainArgs.exportPrefix + "_schedule.csv", MSG_get_clock(), &context);
exportJobsToCSV(mainArgs.exportPrefix + "_jobs.csv", &context);
......
......@@ -16,7 +16,8 @@ struct BatsimContext
Machines machines;
Jobs jobs;
Profiles profiles;
PajeTracer tracer;
PajeTracer paje_tracer;
PStateChangeTracer pstate_tracer;
long long microseconds_used_by_scheduler = 0;
bool energy_used;
......
......@@ -624,3 +624,34 @@ void exportScheduleToCSV(const string &filename, double scheduling_time, BatsimC
f << buf;
free(buf);
}
PStateChangeTracer::PStateChangeTracer()
{
}
void PStateChangeTracer::setFilename(const string &filename)
{
xbt_assert(_wbuf == nullptr, "Double call of PStateChangeTracer::setFilename");
_wbuf = new WriteBuffer(filename);
_wbuf->appendText("time,machine_id,new_pstate\n");
}
PStateChangeTracer::~PStateChangeTracer()
{
if (_wbuf != nullptr)
{
delete _wbuf;
_wbuf = nullptr;
}
}
void PStateChangeTracer::add_pstate_change(double time, int machine_id, int pstate_after)
{
const int bufSize = 64;
char buf[bufSize];
snprintf(buf, bufSize, "%lg,%d,%d\n", time, machine_id, pstate_after);
_wbuf->appendText(buf);
}
......@@ -223,3 +223,18 @@ private:
SET_VARIABLE,
};
};
class PStateChangeTracer
{
public:
PStateChangeTracer();
void setFilename(const std::string & filename);
~PStateChangeTracer();
void add_pstate_change(double time, int machine_id, int pstate_after);
private:
WriteBuffer * _wbuf = nullptr;
};
......@@ -258,7 +258,7 @@ int execute_job_process(int argc, char *argv[])
{
XBT_INFO("Job %d had been killed (walltime %lf reached", job->id, job->walltime);
job->state = JobState::JOB_STATE_COMPLETED_KILLED;
args->context->tracer.addJobKill(job->id, args->allocation.machine_ids, MSG_get_clock(), true);
args->context->paje_tracer.addJobKill(job->id, args->allocation.machine_ids, MSG_get_clock(), true);
}
args->context->machines.updateMachinesOnJobEnd(job->id, args->allocation.machine_ids);
......
......@@ -82,8 +82,8 @@ void Machines::createMachines(xbt_dynar_t hosts, BatsimContext *context, const s
boost::trim(pstates[2]);
sleep_ps = boost::lexical_cast<unsigned int>(pstates[0]);
on_ps = boost::lexical_cast<unsigned int>(pstates[1]);
off_ps = boost::lexical_cast<unsigned int>(pstates[2]);
off_ps = boost::lexical_cast<unsigned int>(pstates[1]);
on_ps = boost::lexical_cast<unsigned int>(pstates[2]);
}
catch(boost::bad_lexical_cast& e)
{
......
......@@ -32,6 +32,7 @@ int switch_on_machine_process(int argc, char *argv[])
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);
args->context->pstate_tracer.add_pstate_change(MSG_get_clock(), machine->id, on_ps);
msg_host_t host_list[1] = {machine->host};
// double flop_amount[1] = {1};
......@@ -49,6 +50,7 @@ int switch_on_machine_process(int argc, char *argv[])
XBT_INFO("1 flop has been computed. Switching machine %d ('%s') to computing pstate %d",
machine->id, machine->name.c_str(), pstate);
MSG_host_set_pstate(machine->host, pstate);
args->context->pstate_tracer.add_pstate_change(MSG_get_clock(), machine->id, pstate);
machine->state = MachineState::IDLE;
......@@ -81,6 +83,7 @@ int switch_off_machine_process(int argc, char *argv[])
XBT_INFO("Switching machine %d ('%s') OFF. Passing in virtual pstate %d to do so", machine->id,
machine->name.c_str(), off_ps);
MSG_host_set_pstate(machine->host, off_ps);
args->context->pstate_tracer.add_pstate_change(MSG_get_clock(), machine->id, off_ps);
msg_host_t host_list[1] = {machine->host};
// double flop_amount[1] = {1};
......@@ -98,6 +101,7 @@ int switch_off_machine_process(int argc, char *argv[])
XBT_INFO("1 flop has been computed. Switching machine %d ('%s') to sleeping pstate %d",
machine->id, machine->name.c_str(), pstate);
MSG_host_set_pstate(machine->host, pstate);
args->context->pstate_tracer.add_pstate_change(MSG_get_clock(), machine->id, pstate);
machine->state = MachineState::SLEEPING;
......
......@@ -132,7 +132,10 @@ int uds_server_process(int argc, char *argv[])
{
if (machine->pstates[message->new_pstate] == PStateType::COMPUTATION_PSTATE)
{
XBT_INFO("Switching machine %d ('%s') pstate : %d -> %d.", machine->id,
machine->name.c_str(), curr_pstate, message->new_pstate);
MSG_host_set_pstate(machine->host, message->new_pstate);
context->pstate_tracer.add_pstate_change(MSG_get_clock(), machine->id, message->new_pstate);
xbt_assert(MSG_host_get_pstate(machine->host) == message->new_pstate);
send_buffer += "|" + std::to_string(MSG_get_clock()) + ":p:" +
......
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