Attention une mise à jour du serveur va être effectuée le vendredi 16 avril entre 12h et 12h30. Cette mise à jour va générer une interruption du service de quelques minutes.

Commit 6aa4da5b authored by Millian Poquet's avatar Millian Poquet

New field in output file OUT_jobs.csv: the consumed_energy field computes, for...

New field in output file OUT_jobs.csv: the consumed_energy field computes, for each job, the consumed energy by the allocated machines during the job execution. Beware:this metric might be invalid if space-sharing is enabled!
parent 2073f9b0
......@@ -512,7 +512,7 @@ void exportJobsToCSV(const string &filename, BatsimContext *context)
xbt_assert(f.is_open(), "Cannot write file '%s'", filename.c_str());
// write headers
f << "jobID,submission_time,requested_number_of_processors,requested_time,success,starting_time,execution_time,finish_time,waiting_time,turnaround_time,stretch,allocated_processors\n";
f << "jobID,submission_time,requested_number_of_processors,requested_time,success,starting_time,execution_time,finish_time,waiting_time,turnaround_time,stretch,consumed_energy,allocated_processors\n";
const auto & jobs = context->jobs.jobs();
for (const auto & mit : jobs)
......@@ -523,7 +523,8 @@ void exportJobsToCSV(const string &filename, BatsimContext *context)
{
char * buf;
int success = job->state == JobState::JOB_STATE_COMPLETED_SUCCESSFULLY;
int ret = asprintf(&buf, "%d,%lf,%d,%lf,%d,%lf,%lf,%lf,%lf,%lf,%lf,", job->id,
int ret = asprintf(&buf, "%d,%lf,%d,%lf,%d,%lf,%lf,%lf,%lf,%lf,%lf,%Lf,", // finished by a ',' because the next part is written after asprintf
job->id,
job->submission_time,
job->required_nb_res,
job->walltime,
......@@ -533,12 +534,15 @@ void exportJobsToCSV(const string &filename, BatsimContext *context)
job->starting_time + job->runtime, // finish_time
job->starting_time - job->submission_time, // waiting_time
job->starting_time + job->runtime - job->submission_time, // turnaround_time
(job->starting_time + job->runtime - job->submission_time) / job->runtime // stretch
(job->starting_time + job->runtime - job->submission_time) / job->runtime, // stretch
job->consumed_energy
);
xbt_assert(ret != -1, "asprintf failed (not enough memory?)");
f << buf;
free(buf);
// TODO: use boost::join for the following if
if (job->required_nb_res > 0)
{
int ret = asprintf(&buf, "%d", job->allocation[0]);
......
......@@ -29,6 +29,8 @@ struct Job
double walltime;
int required_nb_res;
long double consumed_energy; //! The sum, for each machine on which the job has been allocated, of the consumed energy (in Joules) during the job execution time (consumed_energy_after_job_completion - consumed_energy_before_job_start)
double starting_time;
double runtime;
std::vector<int> allocation;
......
......@@ -227,6 +227,7 @@ int execute_job_process(int argc, char *argv[])
(void) argc;
(void) argv;
// Retrieving input parameters
ExecuteJobProcessArguments * args = (ExecuteJobProcessArguments *) MSG_process_get_data(MSG_process_self());
Job * job = args->context->jobs[args->allocation.job_id];
......@@ -234,6 +235,19 @@ int execute_job_process(int argc, char *argv[])
job->allocation = args->allocation.machine_ids;
double remaining_time = job->walltime;
// If energy is enabled, let us compute the energy used by the machines before running the job
if (args->context->energy_used)
{
job->consumed_energy = 0;
for(const int & machine_id : job->allocation)
{
Machine * machine = args->context->machines[machine_id];
job->consumed_energy += MSG_host_get_consumed_energy(machine->host);
}
}
// Job computation
args->context->machines.updateMachinesOnJobRun(job->id, args->allocation.machine_ids);
if (execute_profile(args->context, job->profile, &args->allocation, &remaining_time) == 1)
{
......@@ -250,6 +264,23 @@ int execute_job_process(int argc, char *argv[])
args->context->machines.updateMachinesOnJobEnd(job->id, args->allocation.machine_ids);
job->runtime = MSG_get_clock() - job->starting_time;
// If energy is enabled, let us compute the energy used by the machines after running the job
if (args->context->energy_used)
{
long double consumed_energy_before = job->consumed_energy;
job->consumed_energy = 0;
for(const int & machine_id : job->allocation)
{
Machine * machine = args->context->machines[machine_id];
job->consumed_energy += MSG_host_get_consumed_energy(machine->host);
}
// The consumed energy is the difference (consumed_energy_after_job - consumed_energy_before_job)
job->consumed_energy = job->consumed_energy - consumed_energy_before;
}
// Let us tell the server that the job completed
JobCompletedMessage * message = new JobCompletedMessage;
message->job_id = job->id;
......
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