Skip to content
Snippets Groups Projects
Commit 2c6a79cd authored by Maël Madon's avatar Maël Madon
Browse files

fix: floating point rounding issue with dates

parent c225da33
Branches
No related tags found
1 merge request!10Better memory management and float rounding issues
Pipeline #5407 passed
...@@ -2,4 +2,6 @@ ...@@ -2,4 +2,6 @@
#define NB_CORE_PER_MACHINE 16 #define NB_CORE_PER_MACHINE 16
#define INITIAL_MACHINE_STATE AWAKE #define INITIAL_MACHINE_STATE AWAKE
#define PSTATE_AWAKE 0 #define PSTATE_AWAKE 0
#define PSTATE_ASLEEP 1 #define PSTATE_ASLEEP 1
\ No newline at end of file
#define EPSILON 0.00001 /* For float rounding issues */
\ No newline at end of file
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
#include <limits> #include <limits>
#include <string> #include <string>
#define EPS 0.00001
/* FeedbackUser */ /* FeedbackUser */
void FeedbackUser::init_FeedbackUser( void FeedbackUser::init_FeedbackUser(
std::string name, const rapidjson::Value &param) std::string name, const rapidjson::Value &param)
...@@ -88,7 +86,7 @@ void FeedbackUser::jobs_to_submit( ...@@ -88,7 +86,7 @@ void FeedbackUser::jobs_to_submit(
profiles = std::list<const Profile *>(); profiles = std::list<const Profile *>();
/* Add the free sessions starting now to the list of active sessions */ /* Add the free sessions starting now to the list of active sessions */
while (!free_sessions.empty() && free_sessions.top()->start_time < date + EPS) while (!free_sessions.empty() && free_sessions.top()->start_time < date + EPSILON)
{ {
active_sessions.push_back(free_sessions.top()); active_sessions.push_back(free_sessions.top());
free_sessions.pop(); free_sessions.pop();
...@@ -110,7 +108,7 @@ void FeedbackUser::jobs_to_submit( ...@@ -110,7 +108,7 @@ void FeedbackUser::jobs_to_submit(
double offset = active_sess->start_time; double offset = active_sess->start_time;
while (!job_list->empty() while (!job_list->empty()
&& job_list->front()->submission_time + offset < date + EPS) && job_list->front()->submission_time + offset < date + EPSILON)
{ {
shared_ptr<Job> job = shared_ptr<Job>(new Job(*job_list->front())); // Cast const Job * -> shared_ptr<Job> shared_ptr<Job> job = shared_ptr<Job>(new Job(*job_list->front())); // Cast const Job * -> shared_ptr<Job>
Profile *job_profile = new Profile(); Profile *job_profile = new Profile();
......
...@@ -43,14 +43,14 @@ void ReplayUser::jobs_to_submit( ...@@ -43,14 +43,14 @@ void ReplayUser::jobs_to_submit(
PPK_ASSERT_ERROR(!original_trace->is_empty(), PPK_ASSERT_ERROR(!original_trace->is_empty(),
"User %s has been called to sumbit but her job queue is empty", "User %s has been called to sumbit but her job queue is empty",
user_name.c_str()); user_name.c_str());
PPK_ASSERT_ERROR(original_trace->first_job()->submission_time <= date, PPK_ASSERT_ERROR(original_trace->first_job()->submission_time < date + EPSILON,
"First job in user %s's queue has greater sumbmission time than " "First job in user %s's queue has greater sumbmission time (%f) than "
"current date", "current date (%f)",
user_name.c_str()); user_name.c_str(), original_trace->first_job()->submission_time, date);
/* Submit all jobs that have same submit time */ /* Submit all jobs that have same submit time */
while (!original_trace->is_empty() while (!original_trace->is_empty()
&& original_trace->first_job()->submission_time <= date) && original_trace->first_job()->submission_time < date + EPSILON)
{ {
/* Cast const Job * into Job * */ /* 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()));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment