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

Exact rational are used for some computations

parent 3e5b8251
......@@ -53,6 +53,10 @@ include_directories(${SIMGRID_INCLUDE_DIR})
find_package(Boost 1.48 REQUIRED COMPONENTS system filesystem regex locale)
include_directories(${Boost_INCLUDE_DIR})
## GMP
find_package(GMP REQUIRED)
include_directories(${GMP_INCLUDE_DIR})
## Rapidjson dependency
find_package(rapidjson REQUIRED)
include_directories(${RAPIDJSON_INCLUDE_DIRS})
......@@ -87,6 +91,7 @@ add_executable(batsim ${batsim_SRC})
# Libraries to link
target_link_libraries(batsim
${HAVE_SIMGRID_LIB}
${GMP_LIBRARIES}
${Boost_FILESYSTEM_LIBRARY_DEBUG}
${Boost_LOCALE_LIBRARY_DEBUG}
${Boost_REGEX_LIBRARY_DEBUG}
......
# Try to find the GMP librairies
# GMP_FOUND - system has GMP lib
# GMP_INCLUDE_DIR - the GMP include directory
# GMP_LIBRARIES - Libraries needed to use GMP
if (GMP_INCLUDE_DIR AND GMP_LIBRARIES)
# Already in cache, be silent
set(GMP_FIND_QUIETLY TRUE)
endif (GMP_INCLUDE_DIR AND GMP_LIBRARIES)
find_path(GMP_INCLUDE_DIR NAMES gmp.h )
find_library(GMP_LIBRARIES NAMES gmp libgmp )
find_library(GMPXX_LIBRARIES NAMES gmpxx libgmpxx )
MESSAGE(STATUS "GMP libs: " ${GMP_LIBRARIES} " " ${GMPXX_LIBRARIES} )
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GMP DEFAULT_MSG GMP_INCLUDE_DIR GMP_LIBRARIES)
mark_as_advanced(GMP_INCLUDE_DIR GMP_LIBRARIES)
......@@ -5,18 +5,19 @@
#pragma once
#include <vector>
#include <chrono>
#include <vector>
#include "network.hpp"
#include "machines.hpp"
#include "exact_numbers.hpp"
#include "export.hpp"
#include "jobs.hpp"
#include "machines.hpp"
#include "network.hpp"
#include "profiles.hpp"
#include "export.hpp"
#include "pstate.hpp"
#include "storage.hpp"
#include "workload.hpp"
#include "workflow.hpp"
#include "workload.hpp"
/**
* @brief Stores a high-resolution timestamp
......@@ -40,10 +41,10 @@ struct BatsimContext
bool terminate_with_last_workflow = false; //!< If true, allows to ignore the jobs submitted after the last workflow termination
long double energy_first_job_submission = -1; //!< The amount of consumed energy (J) when the first job is submitted
long double energy_last_job_completion; //!< The amount of consumed energy (J) when the last job is completed
Rational energy_first_job_submission = -1; //!< The amount of consumed energy (J) when the first job is submitted
Rational energy_last_job_completion = -1; //!< The amount of consumed energy (J) when the last job is completed
long long microseconds_used_by_scheduler = 0; //!< The number of microseconds used by the scheduler
Rational microseconds_used_by_scheduler = 0; //!< The number of microseconds used by the scheduler
my_timestamp simulation_start_time; //!< The moment in time at which the simulation has started
my_timestamp simulation_end_time; //!< The moment in time at which the simulation has ended
......
#pragma once
#include <boost/multiprecision/gmp.hpp>
typedef boost::multiprecision::mpq_rational Rational;
......@@ -743,11 +743,11 @@ void export_schedule_to_csv(const std::string &filename, const BatsimContext *co
double min_job_execution_time = DBL_MAX;
double max_job_execution_time = DBL_MIN;
long double seconds_used_by_scheduler = context->microseconds_used_by_scheduler / (long double)1e6;
Rational seconds_used_by_scheduler = context->microseconds_used_by_scheduler / (Rational)1e6;
// Let's compute the simulation time
chrono::duration<long double> diff = context->simulation_end_time - context->simulation_start_time;
long double seconds_used_by_the_whole_simulation = diff.count();
Rational seconds_used_by_the_whole_simulation = diff.count();
for (const auto mit : context->workloads.workloads())
{
......@@ -789,16 +789,16 @@ void export_schedule_to_csv(const std::string &filename, const BatsimContext *co
XBT_INFO("Makespan=%lf, scheduling_time=%Lf", makespan, seconds_used_by_scheduler);
long double total_consumed_energy = context->energy_last_job_completion - context->energy_first_job_submission;
Rational total_consumed_energy = context->energy_last_job_completion - context->energy_first_job_submission;
char * buf;
int ret = asprintf(&buf, "%d,%d,%d,%d,%lf,%lf,%lf,%Lf,%Lf,%lf,%Lg\n",
int ret = asprintf(&buf, "%d,%d,%d,%d,%lf,%lf,%lf,%lf,%lf,%lf,%g\n",
nb_jobs, nb_jobs_finished, nb_jobs_success, nb_jobs_killed,
(double)nb_jobs_success/nb_jobs, makespan, max_turnaround_time,
seconds_used_by_the_whole_simulation,
seconds_used_by_scheduler,
(double) seconds_used_by_the_whole_simulation,
(double) seconds_used_by_scheduler,
max_job_execution_time / min_job_execution_time,
total_consumed_energy);
(double) total_consumed_energy);
(void) ret; // Avoids a warning if assertions are ignored
xbt_assert(ret != -1, "asprintf failed (not enough memory?)");
......
......@@ -192,7 +192,7 @@ int request_reply_scheduler_process(int argc, char *argv[])
}
auto end = chrono::steady_clock::now();
long long elapsed_microseconds = chrono::duration <double, micro> (end - start).count();
Rational elapsed_microseconds = chrono::duration <long double, micro> (end - start).count();
context->microseconds_used_by_scheduler += elapsed_microseconds;
/*
......
Supports Markdown
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