Skip to content
Snippets Groups Projects

Change: submission dates are now managed as long on the users' side

Merged Ghost User requested to merge issue12 into master
1 file
+ 3
3
Compare changes
  • Side-by-side
  • Inline
+ 58
41
#include "users/user_replay.hpp"
#include "../pempek_assert.hpp"
/******************************************************************************
******************************* Replay users *********************************
*****************************************************************************/
/* Master class ReplayUser */
void ReplayUser::init_ReplayUser(std::string name, const rapidjson::Value &param)
void ReplayUser::init_ReplayUser(
std::string name, const rapidjson::Value &param)
{
/* Parse some info from the json */
PPK_ASSERT_ERROR(param.HasMember("input_json"),
@@ -27,15 +27,16 @@ void ReplayUser::init_ReplayUser(std::string name, const rapidjson::Value &param
if (original_trace->is_empty())
date_of_next_submission = DATE_NEVER;
else
date_of_next_submission = original_trace->first_job()->submission_time;
date_of_next_submission
= lround(original_trace->first_job()->submission_time);
}
ReplayUser::~ReplayUser()
{
}
void ReplayUser::jobs_to_submit(
double date, std::list<shared_ptr<Job>> &jobs, std::list<const Profile *> &profiles)
void ReplayUser::jobs_to_submit(double date, std::list<shared_ptr<Job>> &jobs,
std::list<const Profile *> &profiles)
{
jobs = std::list<shared_ptr<Job>>();
profiles = std::list<const Profile *>();
@@ -43,17 +44,19 @@ void ReplayUser::jobs_to_submit(
PPK_ASSERT_ERROR(!original_trace->is_empty(),
"User %s has been called to sumbit but her job queue is empty",
user_name.c_str());
PPK_ASSERT_ERROR(original_trace->first_job()->submission_time < date + EPSILON,
"First job in user %s's queue has greater sumbmission time (%f) than "
PPK_ASSERT_ERROR(
lround(original_trace->first_job()->submission_time) == lround(date),
"First job in user %s's queue has different sumbmission time (%f) than "
"current date (%f)",
user_name.c_str(), original_trace->first_job()->submission_time, date);
/* Submit all jobs that have same submit time */
while (!original_trace->is_empty()
&& original_trace->first_job()->submission_time < date + EPSILON)
&& lround(original_trace->first_job()->submission_time) == lround(date))
{
/* Cast const Job * into Job * */
shared_ptr<Job> job = shared_ptr<Job>(new Job(*original_trace->first_job()));
shared_ptr<Job> job
= shared_ptr<Job>(new Job(*original_trace->first_job()));
Profile *job_profile = new Profile();
/* Handle the job according to the user behavior. */
@@ -77,7 +80,8 @@ void ReplayUser::jobs_to_submit(
if (original_trace->is_empty())
date_of_next_submission = DATE_NEVER;
else
date_of_next_submission = original_trace->first_job()->submission_time;
date_of_next_submission
= lround(original_trace->first_job()->submission_time);
}
int *ReplayUser::get_dm_stat()
@@ -85,7 +89,6 @@ int *ReplayUser::get_dm_stat()
return dm_stat;
}
/* ReplayUserRigid */
ReplayUserRigid::ReplayUserRigid(
std::string name, const rapidjson::Value &param, DMWindow *window)
@@ -99,16 +102,18 @@ ReplayUserRigid::~ReplayUserRigid()
delete original_trace;
}
void ReplayUserRigid::jobs_to_submit(
double date, std::list<shared_ptr<Job>> &jobs, std::list<const Profile *> &profiles)
void ReplayUserRigid::jobs_to_submit(double date,
std::list<shared_ptr<Job>> &jobs, std::list<const Profile *> &profiles)
{
ReplayUser::jobs_to_submit(date, jobs, profiles);
}
bool ReplayUserRigid::handle_job(double date, shared_ptr<Job>job, Profile *profile)
bool ReplayUserRigid::handle_job(
double date, shared_ptr<Job> job, Profile *profile)
{
/* Just generate the corresponding profile */
Parser::profile_from_duration(profile, job->profile, user_name, platform_computing_speed);
Parser::profile_from_duration(
profile, job->profile, user_name, platform_computing_speed);
/* If demande response mode: log if in dm_window */
if (dm_window && dm_window->date_in_dm_window(date))
@@ -121,7 +126,8 @@ bool ReplayUserRigid::handle_job(double date, shared_ptr<Job>job, Profile *profi
}
/* ReplayUserReconfig */
bool ReplayUserReconfig::handle_job(double date, shared_ptr<Job>job, Profile *profile)
bool ReplayUserReconfig::handle_job(
double date, shared_ptr<Job> job, Profile *profile)
{
int orig_nb_core = job->nb_requested_resources;
@@ -203,13 +209,12 @@ ReplayUserReconfig::~ReplayUserReconfig()
delete original_trace;
}
void ReplayUserReconfig::jobs_to_submit(
double date, std::list<shared_ptr<Job>> &jobs, std::list<const Profile *> &profiles)
void ReplayUserReconfig::jobs_to_submit(double date,
std::list<shared_ptr<Job>> &jobs, std::list<const Profile *> &profiles)
{
ReplayUser::jobs_to_submit(date, jobs, profiles);
}
/******************************************************************************
*********************** Users "demand response" ******************************
*****************************************************************************/
@@ -252,8 +257,8 @@ DMUserReconfig::~DMUserReconfig()
delete original_trace;
}
void DMUserReconfig::jobs_to_submit(
double date, std::list<shared_ptr<Job>> &jobs, std::list<const Profile *> &profiles)
void DMUserReconfig::jobs_to_submit(double date,
std::list<shared_ptr<Job>> &jobs, std::list<const Profile *> &profiles)
{
ReplayUser::jobs_to_submit(date, jobs, profiles);
}
@@ -270,8 +275,8 @@ DMUserDegrad::~DMUserDegrad()
delete original_trace;
}
void DMUserDegrad::jobs_to_submit(
double date, std::list<shared_ptr<Job>> &jobs, std::list<const Profile *> &profiles)
void DMUserDegrad::jobs_to_submit(double date, std::list<shared_ptr<Job>> &jobs,
std::list<const Profile *> &profiles)
{
ReplayUser::jobs_to_submit(date, jobs, profiles);
}
@@ -288,8 +293,8 @@ DMUserRenonce::~DMUserRenonce()
delete original_trace;
}
void DMUserRenonce::jobs_to_submit(
double date, std::list<shared_ptr<Job>> &jobs, std::list<const Profile *> &profiles)
void DMUserRenonce::jobs_to_submit(double date,
std::list<shared_ptr<Job>> &jobs, std::list<const Profile *> &profiles)
{
ReplayUser::jobs_to_submit(date, jobs, profiles);
}
@@ -306,13 +311,14 @@ DMUserDelay::~DMUserDelay()
delete original_trace;
}
void DMUserDelay::jobs_to_submit(
double date, std::list<shared_ptr<Job>> &jobs, std::list<const Profile *> &profiles)
void DMUserDelay::jobs_to_submit(double date, std::list<shared_ptr<Job>> &jobs,
std::list<const Profile *> &profiles)
{
ReplayUser::jobs_to_submit(date, jobs, profiles);
}
bool DMUserReconfig::handle_job(double date, shared_ptr<Job>job, Profile *profile)
bool DMUserReconfig::handle_job(
double date, shared_ptr<Job> job, Profile *profile)
{
if (dm_window->date_in_dm_window(date))
{
@@ -320,7 +326,8 @@ bool DMUserReconfig::handle_job(double date, shared_ptr<Job>job, Profile *profil
if (orig_nb_core == 1)
{
/* No reconfig */
Parser::profile_from_duration(profile, job->profile, user_name, platform_computing_speed);
Parser::profile_from_duration(
profile, job->profile, user_name, platform_computing_speed);
/* Log... */
dm_stat[2 * RIGID]++;
@@ -343,20 +350,23 @@ bool DMUserReconfig::handle_job(double date, shared_ptr<Job>job, Profile *profil
* => T_n = (orig_nb_core / n)^alpha * T_orig
*/
long T_orig = std::stol(job->profile);
long T_n = pow( (double) orig_nb_core / n, alpha) * T_orig;
Parser::profile_from_duration(profile, std::to_string(T_n), user_name, platform_computing_speed); // parallel_homogeneous
long T_n = pow((double)orig_nb_core / n, alpha) * T_orig;
Parser::profile_from_duration(profile, std::to_string(T_n),
user_name, platform_computing_speed); // parallel_homogeneous
job->nb_requested_resources = n;
job->profile = profile->name = 'r' + std::to_string(T_orig);
}
}
else
{
Parser::profile_from_duration(profile, job->profile, user_name, platform_computing_speed);
Parser::profile_from_duration(
profile, job->profile, user_name, platform_computing_speed);
}
return true;
}
bool DMUserDegrad::handle_job(double date, shared_ptr<Job>job, Profile *profile)
bool DMUserDegrad::handle_job(
double date, shared_ptr<Job> job, Profile *profile)
{
if (dm_window->date_in_dm_window(date))
{
@@ -365,7 +375,8 @@ bool DMUserDegrad::handle_job(double date, shared_ptr<Job>job, Profile *profile)
if (orig_nb_core == 1)
{
/* No reconfig */
Parser::profile_from_duration(profile, job->profile, user_name, platform_computing_speed);
Parser::profile_from_duration(
profile, job->profile, user_name, platform_computing_speed);
/* Log... */
dm_stat[2 * RIGID]++;
@@ -379,18 +390,21 @@ bool DMUserDegrad::handle_job(double date, shared_ptr<Job>job, Profile *profile)
/* Spatial degradiation: divide by two rounded up the nb or
* cores requested, and keep the original duration */
job->nb_requested_resources = (orig_nb_core + 1) / 2;
Parser::profile_from_duration(profile, job->profile, user_name, platform_computing_speed);
Parser::profile_from_duration(
profile, job->profile, user_name, platform_computing_speed);
job->profile = profile->name = 'd' + profile->name;
}
}
else
{
Parser::profile_from_duration(profile, job->profile, user_name, platform_computing_speed);
Parser::profile_from_duration(
profile, job->profile, user_name, platform_computing_speed);
}
return true;
}
bool DMUserRenonce::handle_job(double date, shared_ptr<Job>job, Profile *profile)
bool DMUserRenonce::handle_job(
double date, shared_ptr<Job> job, Profile *profile)
{
if (dm_window->date_in_dm_window(date))
{
@@ -406,12 +420,13 @@ bool DMUserRenonce::handle_job(double date, shared_ptr<Job>job, Profile *profile
}
else
{
Parser::profile_from_duration(profile, job->profile, user_name, platform_computing_speed);
Parser::profile_from_duration(
profile, job->profile, user_name, platform_computing_speed);
}
return true;
}
bool DMUserDelay::handle_job(double date, shared_ptr<Job>job, Profile *profile)
bool DMUserDelay::handle_job(double date, shared_ptr<Job> job, Profile *profile)
{
if (dm_window->date_in_dm_window(date))
{
@@ -425,7 +440,8 @@ bool DMUserDelay::handle_job(double date, shared_ptr<Job>job, Profile *profile)
/* Put job back in the queue and sort */
SortableJobOrder::UpdateInformation update_info(0);
Job *j = new Job(); *j = *job;
Job *j = new Job();
*j = *job;
original_trace->insert_job(j);
original_trace->sort_queue(&update_info);
@@ -434,7 +450,8 @@ bool DMUserDelay::handle_job(double date, shared_ptr<Job>job, Profile *profile)
}
else
{
Parser::profile_from_duration(profile, job->profile, user_name, platform_computing_speed);
Parser::profile_from_duration(
profile, job->profile, user_name, platform_computing_speed);
return true;
}
}
\ No newline at end of file
Loading