Skip to content
Snippets Groups Projects
Commit 2ec11c1b authored by Millian Poquet's avatar Millian Poquet
Browse files

Merge branch 'feature/loguru-logs'

parents 70aea015 aaa5b5f4
No related branches found
No related tags found
No related merge requests found
Showing
with 230 additions and 193 deletions
......@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning][semver].
[//]: =========================================================================
## [Unreleased]
### Added
- CLI: logging verbosity can now be set with `--verbosity`.
### Changed
- Dependencies: added [intervalset](https://framagit.org/batsim/intervalset).
......
......@@ -34,6 +34,14 @@ include_directories(${Boost_INCLUDE_DIR})
find_package(intervalset REQUIRED)
include_directories(${INTERVALSET_INCLUDE_DIR})
## loguru
find_package(loguru REQUIRED)
include_directories(${LOGURU_INCLUDE_DIR})
## pthread (for loguru)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
## GMP
find_package(GMP REQUIRED)
include_directories(${GMP_INCLUDE_DIR})
......@@ -69,6 +77,7 @@ target_link_libraries(batsched ${GMP_LIBRARIES}
${Boost_REGEX_LIBRARY_DEBUG}
${Boost_LOCALE_LIBRARY_DEBUG}
${INTERVALSET_LIBRARY}
Threads::Threads
${REDOX_LIBRARY}
${LIBEV_LIBRARY}
${HIREDIS_LIBRARY}
......
# Find the loguru library (https://github.com/emilk/loguru)
#
# Sets the usual variables expected for find_package scripts:
#
# LOGURU_INCLUDE_DIR - header location
# LOGURU_FOUND - true if loguru was found.
find_path(LOGURU_INCLUDE_DIR loguru.hpp)
# Support the REQUIRED and QUIET arguments, and set LOGURU_FOUND if found.
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args(loguru DEFAULT_MSG LOGURU_INCLUDE_DIR)
mark_as_advanced(LOGURU_INCLUDE_DIR)
......@@ -8,6 +8,8 @@
#include <stdexcept>
#include <loguru.hpp>
Crasher::CrashType Crasher::crash_type_from_string(const std::string &str)
{
if (str == "segmentation_fault") return CrashType::SEGMENTATION_FAULT;
......@@ -85,11 +87,12 @@ Crasher::Crasher(Workload *workload,
_crash_type = crash_type_from_string(crash_type_str);
}
printf("crash_on_start: %d\n", _crash_on_start);
printf("crash_on_end: %d\n", _crash_on_end);
printf("crash_on_decision_call: %d\n", _crash_on_decision_call);
printf("crash_on_decision_call_number: %d\n", _crash_on_decision_call_number);
printf("crash_type: %s\n", crash_type_to_string(_crash_type).c_str());
LOG_SCOPE_FUNCTION(INFO);
LOG_F(INFO, "crash_on_start: %d", _crash_on_start);
LOG_F(INFO, "crash_on_end: %d", _crash_on_end);
LOG_F(INFO, "crash_on_decision_call: %d", _crash_on_decision_call);
LOG_F(INFO, "crash_on_decision_call_number: %d", _crash_on_decision_call_number);
LOG_F(INFO, "crash_type: %s", crash_type_to_string(_crash_type).c_str());
}
Crasher::~Crasher()
......
#include "easy_bf.hpp"
#include <loguru.hpp>
#include "../pempek_assert.hpp"
using namespace std;
......@@ -139,7 +141,7 @@ void EasyBackfilling::sort_queue_while_handling_priority_job(const Job * priorit
SortableJobOrder::CompareInformation * compare_info)
{
if (_debug)
printf("sort_queue_while_handling_priority_job beginning, %s\n", _schedule.to_string().c_str());
LOG_F(1, "sort_queue_while_handling_priority_job beginning, %s", _schedule.to_string().c_str());
// Let's sort the queue
_queue->sort_queue(update_info, compare_info);
......@@ -174,5 +176,5 @@ void EasyBackfilling::sort_queue_while_handling_priority_job(const Job * priorit
}
if (_debug)
printf("sort_queue_while_handling_priority_job ending, %s\n", _schedule.to_string().c_str());
LOG_F(1, "sort_queue_while_handling_priority_job ending, %s", _schedule.to_string().c_str());
}
#include "energy_bf.hpp"
#include <iostream>
#include <boost/algorithm/string.hpp>
#include <boost/regex.hpp>
#include <loguru.hpp>
#include "../pempek_assert.hpp"
using namespace std;
......@@ -183,8 +183,7 @@ void EnergyBackfilling::on_machine_state_changed(double date, IntervalSet machin
{
if (_debug)
{
printf("on_machine_state_changed beginning, schedule : %s\n", _schedule.to_string().c_str());
fflush(stdout);
LOG_F(1, "on_machine_state_changed beginning, schedule : %s", _schedule.to_string().c_str());
}
// Let's update the current schedule to take the machine state change into account
......@@ -274,8 +273,7 @@ void EnergyBackfilling::on_machine_state_changed(double date, IntervalSet machin
if (_debug)
{
printf("on_machine_state_changed, before sleep jobs translation. %s\n", _schedule.to_string().c_str());
fflush(stdout);
LOG_F(1, "on_machine_state_changed, before sleep jobs translation. %s", _schedule.to_string().c_str());
}
// Let's translate to the left (-> present) the sleep jobs that comes from newly asleep machines
......@@ -299,8 +297,7 @@ void EnergyBackfilling::on_machine_state_changed(double date, IntervalSet machin
if (_debug)
{
printf("on_machine_state_changed before update_first_slice, schedule : %s\n", _schedule.to_string().c_str());
fflush(stdout);
LOG_F(1, "on_machine_state_changed before update_first_slice, schedule : %s", _schedule.to_string().c_str());
}
}
......@@ -417,7 +414,7 @@ void EnergyBackfilling::generate_machine_informations(int nb_machines)
_machine_informations[minfo->machine_number] = minfo;
}
printf("Ensured sleep length of the first machine : %g seconds.\n",
LOG_F(INFO, "Ensured sleep length of the first machine : %g seconds.",
(double) _machine_informations[0]->ensured_sleep_job->walltime);
}
......@@ -488,16 +485,14 @@ void EnergyBackfilling::make_decisions(double date,
if (_debug)
{
printf("Schedule before put_jobs_into_schedule: %s\n", current_schedule.to_string().c_str());
fflush(stdout);
LOG_F(1, "Schedule before put_jobs_into_schedule: %s", current_schedule.to_string().c_str());
}
put_jobs_into_schedule(current_schedule);
if (_debug)
{
printf("Schedule before sedate_machines_at_the_furthest_moment: %s\n", current_schedule.to_string().c_str());
fflush(stdout);
LOG_F(1, "Schedule before sedate_machines_at_the_furthest_moment: %s", current_schedule.to_string().c_str());
}
sedate_machines_at_the_furthest_moment(current_schedule, _awake_machines);
......@@ -625,7 +620,7 @@ void EnergyBackfilling::update_first_slice_taking_sleep_jobs_into_account(Ration
PPK_ASSERT_ERROR(_schedule.nb_slices() > 0);
if (_debug)
printf("update_first_slice... Date=%f\n%s\n",
LOG_F(1, "update_first_slice... Date=%f\n%s",
(double) date, _schedule.to_string().c_str());
// Since we are not only using "real" jobs, the usual assumption that a slice cannot
......@@ -723,8 +718,8 @@ void EnergyBackfilling::update_first_slice_taking_sleep_jobs_into_account(Ration
if (_debug)
{
printf("The slice will be removed because everything seems fine.\n"
"sleeping_machines = %s\nnon_sleep_jobs=%s\n%s\n",
LOG_F(1, "The slice will be removed because everything seems fine.\n"
"sleeping_machines = %s\nnon_sleep_jobs=%s\n%s",
sleeping_machines.to_string_brackets().c_str(),
boost::algorithm::join(non_sleep_jobs, ",").c_str(),
slice.to_string().c_str());
......@@ -815,9 +810,8 @@ void EnergyBackfilling::put_jobs_into_schedule(Schedule &schedule) const
if (_debug)
{
printf("schedule before job insertion: %s\n", schedule.to_string().c_str());
printf("job : (id='%s', walltime=%g)\n", job->id.c_str(), (double) job->walltime);
fflush(stdout);
LOG_F(1, "schedule before job insertion: %s", schedule.to_string().c_str());
LOG_F(1, "job : (id='%s', walltime=%g)", job->id.c_str(), (double) job->walltime);
}
// Let's finally insert the job
......@@ -825,8 +819,7 @@ void EnergyBackfilling::put_jobs_into_schedule(Schedule &schedule) const
if (_debug)
{
printf("schedule after job insertion: %s\n", schedule.to_string().c_str());
fflush(stdout);
LOG_F(1, "schedule after job insertion: %s", schedule.to_string().c_str());
}
// Let's make sure the machine awakening was not useless
......@@ -866,10 +859,8 @@ Rational EnergyBackfilling::sedate_machines_at_the_furthest_moment(Schedule &sch
if (_debug)
{
printf("Schedule : %s\n", schedule.to_string().c_str());
fflush(stdout);
printf("Current time slice : %s\n", time_slice_it->to_string().c_str());
fflush(stdout);
LOG_F(1, "Schedule : %s", schedule.to_string().c_str());
LOG_F(1, "Current time slice : %s", time_slice_it->to_string().c_str());
}
......@@ -952,10 +943,9 @@ void EnergyBackfilling::sedate_machine(Schedule &schedule,
if (_debug)
{
printf("\n-----\n\n");
printf("Machine to sedate: %d\n", machine_id);
printf("Schedule before switch_off_alloc : %s\n", schedule.to_string().c_str());
fflush(stdout);
LOG_F(1, "\n-----\n");
LOG_F(1, "Machine to sedate: %d", machine_id);
LOG_F(1, "Schedule before switch_off_alloc : %s", schedule.to_string().c_str());
}
// Let's add the switch OFF job into the schedule
......@@ -963,8 +953,7 @@ void EnergyBackfilling::sedate_machine(Schedule &schedule,
if (_debug)
{
printf("Schedule after switch_off_alloc : %s\n", schedule.to_string().c_str());
fflush(stdout);
LOG_F(1, "Schedule after switch_off_alloc : %s", schedule.to_string().c_str());
}
if (insert_in_slice)
......@@ -995,8 +984,7 @@ void EnergyBackfilling::sedate_machine_without_switch(Schedule &schedule,
if (_debug)
{
printf("Schedule after ensured_sleep_alloc : %s\n", schedule.to_string().c_str());
fflush(stdout);
LOG_F(1, "Schedule after ensured_sleep_alloc : %s", schedule.to_string().c_str());
}
PPK_ASSERT_ERROR(ensured_sleep_alloc.begin == when_it_should_start,
......@@ -1015,8 +1003,7 @@ void EnergyBackfilling::sedate_machine_without_switch(Schedule &schedule,
if (_debug)
{
printf("Schedule after potential_sleep_alloc : %s\n", schedule.to_string().c_str());
fflush(stdout);
LOG_F(1, "Schedule after potential_sleep_alloc : %s", schedule.to_string().c_str());
}
PPK_ASSERT_ERROR(potential_sleep_alloc.begin == when_ensured_sleep_job_finishes);
......@@ -1041,11 +1028,10 @@ void EnergyBackfilling::awaken_machine(Schedule &schedule, int machine_id, Ratio
if (_debug)
{
printf("EnergyBackfilling::awaken_machine.\n"
"potential_sleep_maximum_length = %f\n%s\n",
LOG_F(1, "EnergyBackfilling::awaken_machine.\n"
"potential_sleep_maximum_length = %f\n%s",
(double) potential_sleep_maximum_length,
schedule.to_string().c_str());
fflush(stdout);
}
if (potential_sleep_maximum_length > 0)
......@@ -1057,10 +1043,9 @@ void EnergyBackfilling::awaken_machine(Schedule &schedule, int machine_id, Ratio
if (_debug)
{
printf("EnergyBackfilling::awaken_machine.\n"
"The potential job has been inserted back into the schedule.\n%s\n",
LOG_F(1, "EnergyBackfilling::awaken_machine.\n"
"The potential job has been inserted back into the schedule.\n%s",
schedule.to_string().c_str());
fflush(stdout);
}
}
......@@ -1070,9 +1055,8 @@ void EnergyBackfilling::awaken_machine(Schedule &schedule, int machine_id, Ratio
if (_debug)
{
printf("EnergyBackfilling::awaken_machine after wake up\n%s\n",
LOG_F(1, "EnergyBackfilling::awaken_machine after wake up\n%s",
schedule.to_string().c_str());
fflush(stdout);
}
}
......
#include "energy_bf_dicho.hpp"
#include <iostream>
#include <loguru.hpp>
#include "../pempek_assert.hpp"
......@@ -26,8 +26,6 @@ EnergyBackfillingDichotomy::EnergyBackfillingDichotomy(Workload *workload, Sched
if (variant_options->HasMember("comparison_type"))
{
cout << "Comparison type found in options!" << endl;
PPK_ASSERT_ERROR((*variant_options)["comparison_type"].IsString(),
"Invalid options JSON object: Member 'comparison_type' should be a string");
string comp_type = (*variant_options)["comparison_type"].GetString();
......@@ -161,7 +159,7 @@ void EnergyBackfillingDichotomy::make_decisions(double date,
// Let's do a dichotomy on the number of machines to awaken/sedate to find the best solution
// *****************************************************************************************
cout << "should_sedate_machines " << should_sedate_machines << endl;
LOG_F(INFO, "should_sedate_machines=%d", should_sedate_machines);
if (should_sedate_machines)
{
......@@ -207,9 +205,9 @@ void EnergyBackfillingDichotomy::make_decisions(double date,
Rational best_sched_energy = estimate_energy_of_schedule(best_schedule, comparison_horizon);
Rational sched_energy = estimate_energy_of_schedule(schedule, comparison_horizon);
cout << "Current schedule respects the mean slowdown constraint. "
<< "(best_energy, curr_energy) : (" << (double) best_sched_energy
<< ", " << (double)sched_energy << ")" << endl;
LOG_F(INFO, "Current schedule respects the mean slowdown constraint. "
"(best_energy, curr_energy) : (%g, %g)",
(double)best_sched_energy, (double)sched_energy);
// Let's update the best solution if needed
if ((sched_energy < best_sched_energy) ||
......@@ -269,9 +267,9 @@ void EnergyBackfillingDichotomy::make_decisions(double date,
Rational best_sched_energy = estimate_energy_of_schedule(best_schedule, comparison_horizon);
Rational sched_energy = estimate_energy_of_schedule(schedule, comparison_horizon);
cout << "Current schedule respects the mean slowdown constraint. "
<< "(best_energy, curr_energy) : (" << (double) best_sched_energy
<< ", " << (double)sched_energy << ")" << endl;
LOG_F(INFO, "Current schedule respects the mean slowdown constraint. "
"(best_energy, curr_energy) : (%g, %g)",
(double)best_sched_energy, (double)sched_energy);
// Let's update the best solution if needed
if ((sched_energy < best_sched_energy) ||
......
#include "energy_bf_idle_sleeper.hpp"
#include <loguru.hpp>
#include "../pempek_assert.hpp"
using namespace std;
......@@ -219,10 +221,10 @@ void EnergyBackfillingIdleSleeper::make_idle_sleep_decisions(double date)
machines_sedated_this_turn, machines_awakened_this_turn);
if (machines_sedated_this_turn.size() > 0)
printf("Date=%g. Those machines should be put to sleep now: %s\n",
LOG_F(INFO, "Date=%g. Those machines should be put to sleep now: %s",
date, machines_sedated_this_turn.to_string_brackets().c_str());
if (machines_awakened_this_turn.size() > 0)
printf("Date=%g. Those machines should be awakened now: %s\n",
LOG_F(INFO, "Date=%g. Those machines should be awakened now: %s",
date, machines_awakened_this_turn.to_string_brackets().c_str());
_machines_to_sedate -= machines_sedated_this_turn;
......
#include "energy_bf_machine_subpart_sleeper.hpp"
#include <loguru.hpp>
#include "energy_bf_idle_sleeper.hpp"
#include "../pempek_assert.hpp"
......@@ -21,7 +23,8 @@ EnergyBackfillingMachineSubpartSleeper::EnergyBackfillingMachineSubpartSleeper(W
"Invalid options JSON object: Member 'fraction_of_machines_to_let_awake' has an invalid "
"value (%g)", (double) _fraction_of_machines_to_let_awake);
printf("Fraction of machines to let awake: %g\n",
LOG_SCOPE_FUNCTION(INFO);
LOG_F(INFO, "Fraction of machines to let awake: %g",
(double) _fraction_of_machines_to_let_awake);
}
......@@ -88,7 +91,7 @@ void EnergyBackfillingMachineSubpartSleeper::on_monitoring_stage(double date)
+ _machines_to_awaken - _machines_to_sedate;
int nb_machines_to_let_awakened = (int) (_fraction_of_machines_to_let_awake * _all_machines.size());
if (_inertial_shutdown_debug)
printf("Date=%g. nb_machines_to_let_awakened=%d\n", date, nb_machines_to_let_awakened);
LOG_F(1, "Date=%g. nb_machines_to_let_awakened=%d", date, nb_machines_to_let_awakened);
IntervalSet machines_that_can_be_used_by_the_priority_job;
Schedule::JobAlloc priority_job_alloc;
......@@ -96,7 +99,7 @@ void EnergyBackfillingMachineSubpartSleeper::on_monitoring_stage(double date)
bool priority_job_needs_awakenings = false;
if (_inertial_shutdown_debug)
printf("Schedule without priority_job.%s\n", _inertial_schedule.to_string().c_str());
LOG_F(1, "Schedule without priority_job.%s", _inertial_schedule.to_string().c_str());
compute_priority_job_and_related_stuff(_inertial_schedule, _queue, priority_job,
_selector,
......@@ -112,12 +115,12 @@ void EnergyBackfillingMachineSubpartSleeper::on_monitoring_stage(double date)
int nb_machines_to_sedate = (int)machines_awake_soon.size() - nb_machines_to_let_awakened;
if (_inertial_shutdown_debug)
printf("Date=%g. nb_machines_to_sedate=%d\n", date, nb_machines_to_sedate);
LOG_F(1, "Date=%g. nb_machines_to_sedate=%d", date, nb_machines_to_sedate);
if (nb_machines_to_sedate > 0)
{
if (_inertial_shutdown_debug)
printf("Date=%g. nb_machines_to_sedate=%d. machines_awake_soon=%s. "
"machines_that_can_be_used_by_the_priority_job=%s\n",
LOG_F(1, "Date=%g. nb_machines_to_sedate=%d. machines_awake_soon=%s. "
"machines_that_can_be_used_by_the_priority_job=%s",
date, nb_machines_to_sedate,
machines_awake_soon.to_string_brackets().c_str(),
machines_that_can_be_used_by_the_priority_job.to_string_brackets().c_str());
......@@ -136,19 +139,19 @@ void EnergyBackfillingMachineSubpartSleeper::on_monitoring_stage(double date)
select_machines_to_sedate(nb_machines_to_sedate, machines_awake_soon,
machines_that_can_be_used_by_the_priority_job,
machines_to_sedate, priority_job);
printf("Date=%g. Machines to sedate were %s\n", date,
LOG_F(INFO, "Date=%g. Machines to sedate were %s", date,
_machines_to_sedate.to_string_brackets().c_str());
printf("Date=%g. Machines asleep soon were %s", date,
LOG_F(INFO, "Date=%g. Machines asleep soon were %s", date,
machines_asleep_soon.to_string_brackets().c_str());
if (_inertial_shutdown_debug)
printf("Date=%g. machines_to_sedate=%s",
LOG_F(1, "Date=%g. machines_to_sedate=%s",
date, machines_to_sedate.to_string_brackets().c_str());
_machines_to_sedate += machines_to_sedate;
_nb_machines_sedated_by_inertia += (int) machines_to_sedate.size();
printf("Machines to sedate are now %s\n", _machines_to_sedate.to_string_brackets().c_str());
LOG_F(INFO, "Machines to sedate are now %s", _machines_to_sedate.to_string_brackets().c_str());
IntervalSet machines_sedated_this_turn, machines_awakened_this_turn, empty_range;
handle_queued_switches(_inertial_schedule, _machines_to_sedate,
......@@ -158,7 +161,7 @@ void EnergyBackfillingMachineSubpartSleeper::on_monitoring_stage(double date)
PPK_ASSERT_ERROR(machines_awakened_this_turn == IntervalSet::empty_interval_set());
if (machines_sedated_this_turn.size() > 0)
printf("Date=%g. Those machines should be put to sleep now: %s\n",
LOG_F(INFO, "Date=%g. Those machines should be put to sleep now: %s",
date, machines_sedated_this_turn.to_string_brackets().c_str());
_machines_to_sedate -= machines_sedated_this_turn;
......@@ -217,7 +220,7 @@ void EnergyBackfillingMachineSubpartSleeper::on_monitoring_stage(double date)
machines_awakened_this_turn.to_string_brackets().c_str(),
IntervalSet::empty_interval_set().to_string_brackets().c_str());
printf("Date=%g. Those machines should be put to sleep now for being idle: %s\n",
LOG_F(INFO, "Date=%g. Those machines should be put to sleep now for being idle: %s",
date, machines_sedated_this_turn.to_string_brackets().c_str());
......@@ -225,7 +228,7 @@ void EnergyBackfillingMachineSubpartSleeper::on_monitoring_stage(double date)
if (_inertial_shutdown_debug)
{
printf("Date=%g. Before make_decisions_of_schedule. %s\n",
LOG_F(1, "Date=%g. Before make_decisions_of_schedule. %s",
date, _inertial_schedule.to_string().c_str());
write_schedule_debug("_on_monitoring_before_make_decisions_of_schedule");
}
......
This diff is collapsed.
#include "energy_bf_monitoring_period.hpp"
#include <loguru.hpp>
#include "../pempek_assert.hpp"
using namespace std;
......@@ -33,7 +35,7 @@ void EnergyBackfillingMonitoringPeriod::on_simulation_end(double date)
PPK_ASSERT_ERROR(_simulation_finished == false);
_simulation_finished = true;
printf("EnergyBackfillingMonitoringPeriod: 'End of simulation' message received from Batsim. date=%g\n", date);
LOG_F(INFO, "EnergyBackfillingMonitoringPeriod: 'End of simulation' message received from Batsim. date=%g", date);
}
void EnergyBackfillingMonitoringPeriod::on_job_release(double date, const std::vector<string> &job_ids)
......@@ -42,7 +44,7 @@ void EnergyBackfillingMonitoringPeriod::on_job_release(double date, const std::v
{
_next_monitoring_period_expected_date = date + _period_between_monitoring_stages;
printf("EnergyBackfillingMonitoringPeriod: First monitoring nop is expected to be at date=%g\n",
LOG_F(INFO, "EnergyBackfillingMonitoringPeriod: First monitoring nop is expected to be at date=%g",
(double) _next_monitoring_period_expected_date);
_decision->add_call_me_later((double)(_next_monitoring_period_expected_date), date);
......@@ -56,7 +58,7 @@ void EnergyBackfillingMonitoringPeriod::on_job_release(double date, const std::v
void EnergyBackfillingMonitoringPeriod::on_requested_call(double date)
{
EnergyBackfilling::on_requested_call(date);
printf("on_requested_call, date = %g\n", date);
LOG_F(INFO, "on_requested_call, date = %g", date);
if (!_simulation_finished)
{
......@@ -68,14 +70,14 @@ void EnergyBackfillingMonitoringPeriod::on_requested_call(double date)
_decision->add_call_me_later((double)(_next_monitoring_period_expected_date), date);
_nb_nop_me_later_running++;
printf("EnergyBackfillingMonitoringPeriod: 'Chose to launch a nop_me_later at %g\n",
LOG_F(INFO, "EnergyBackfillingMonitoringPeriod: 'Chose to launch a nop_me_later at %g",
(double)_next_monitoring_period_expected_date);
}
}
void EnergyBackfillingMonitoringPeriod::on_monitoring_stage(double date)
{
cout << "EnergyBackfillingMonitoringPeriod: Monitoring stage at date=" << date << endl;
LOG_F(INFO, "EnergyBackfillingMonitoringPeriod: Monitoring stage at date=%g", date);
}
Rational EnergyBackfillingMonitoringPeriod::period() const
......
#include "energy_watcher.hpp"
#include <loguru.hpp>
#include "../pempek_assert.hpp"
using namespace std;
......@@ -53,7 +55,7 @@ void EnergyWatcher::make_decisions(double date,
"Energy consumption inconsistency: it should be non-decreasing. "
"Received %g but previous value is %g.",
_consumed_joules, _previous_energy);
printf("Updating consumed joules. Now=%g. Before=%g.\n",
LOG_F(INFO, "Updating consumed joules. Now=%g. Before=%g.",
_consumed_joules, _previous_energy);
_previous_energy = _consumed_joules;
}
......
#include "filler.hpp"
#include <loguru.hpp>
#include "../json_workload.hpp"
#include "../decision.hpp"
#include "../pempek_assert.hpp"
......@@ -34,9 +36,10 @@ Filler::Filler(Workload *workload, SchedulingDecision * decision, Queue * queue,
set_job_metadata = (*variant_options)["set_job_metadata"].GetBool();
}
printf("custom_mapping: %s\n", custom_mapping?"true":"false");
printf("fraction_of_machines_to_use: %g\n", fraction_of_machines_to_use);
printf("set_job_metadata: %d\n", set_job_metadata);
LOG_SCOPE_FUNCTION(INFO);
LOG_F(INFO, "custom_mapping: %s", custom_mapping?"true":"false");
LOG_F(INFO, "fraction_of_machines_to_use: %g", fraction_of_machines_to_use);
LOG_F(INFO, "set_job_metadata: %d", set_job_metadata);
}
Filler::~Filler()
......@@ -92,7 +95,7 @@ void Filler::make_decisions(double date,
void Filler::fill(double date)
{
if (_debug)
printf("fill, availableMachines=%s\n", available_machines.to_string_hyphen().c_str());
LOG_F(1, "fill, availableMachines=%s", available_machines.to_string_hyphen().c_str());
int nb_available = available_machines.size();
for (auto job_it = _queue->begin(); job_it != _queue->end() && nb_available > 0; )
......
#include "killer.hpp"
#include <loguru.hpp>
#include "../pempek_assert.hpp"
using namespace std;
......@@ -32,8 +34,9 @@ Killer::Killer(Workload *workload,
delay_before_kill);
}
printf("nb_kills_per_job: %d\n", nb_kills_per_job);
printf("delay_before_kill: %g\n", delay_before_kill);
LOG_SCOPE_FUNCTION(INFO);
LOG_F(INFO, "nb_kills_per_job: %d", nb_kills_per_job);
LOG_F(INFO, "delay_before_kill: %g", delay_before_kill);
}
Killer::~Killer()
......@@ -59,7 +62,7 @@ void Killer::make_decisions(double date,
SortableJobOrder::UpdateInformation *update_info,
SortableJobOrder::CompareInformation *compare_info)
{
printf("Date: %g. Available machines: %s\n", date, available_machines.to_string_brackets().c_str());
LOG_F(1, "Date: %g. Available machines: %s", date, available_machines.to_string_brackets().c_str());
// Let's update available machines
for (const string & ended_job_id : _jobs_ended_recently)
......@@ -70,7 +73,7 @@ void Killer::make_decisions(double date,
current_allocations.erase(ended_job_id);
}
printf("Date: %g. Available machines: %s\n", date, available_machines.to_string_brackets().c_str());
LOG_F(1, "Date: %g. Available machines: %s", date, available_machines.to_string_brackets().c_str());
// Let's handle recently released jobs
for (const string & new_job_id : _jobs_released_recently)
......@@ -114,5 +117,5 @@ void Killer::make_decisions(double date,
}
}
printf("Date: %g. Available machines: %s\n", date, available_machines.to_string_brackets().c_str());
LOG_F(1, "Date: %g. Available machines: %s", date, available_machines.to_string_brackets().c_str());
}
#include "killer2.hpp"
#include <loguru.hpp>
#include "../pempek_assert.hpp"
using namespace std;
......@@ -38,7 +40,7 @@ void Killer2::make_decisions(double date,
SortableJobOrder::UpdateInformation *update_info,
SortableJobOrder::CompareInformation *compare_info)
{
printf("Date: %g. Available machines: %s\n", date, available_machines.to_string_brackets().c_str());
LOG_F(1, "Date: %g. Available machines: %s", date, available_machines.to_string_brackets().c_str());
// Let's update available machines
for (const string & ended_job_id : _jobs_ended_recently)
......@@ -49,7 +51,7 @@ void Killer2::make_decisions(double date,
current_allocations.erase(ended_job_id);
}
printf("Date: %g. Available machines: %s\n", date, available_machines.to_string_brackets().c_str());
LOG_F(1, "Date: %g. Available machines: %s", date, available_machines.to_string_brackets().c_str());
// Let's handle recently released jobs
for (const string & new_job_id : _jobs_released_recently)
......@@ -93,5 +95,5 @@ void Killer2::make_decisions(double date,
_queue->remove_job(job);
}
printf("Date: %g. Available machines: %s\n", date, available_machines.to_string_brackets().c_str());
LOG_F(1, "Date: %g. Available machines: %s", date, available_machines.to_string_brackets().c_str());
}
#include "submitter.hpp"
#include <loguru.hpp>
#include "../pempek_assert.hpp"
using namespace std;
......@@ -47,11 +49,12 @@ Submitter::Submitter(Workload *workload, SchedulingDecision *decision, Queue *qu
set_job_metadata = (*variant_options)["set_job_metadata"].GetBool();
}
printf("nb_jobs_to_submit: %d\n", nb_jobs_to_submit);
printf("increase_jobs_duration: %d\n", increase_jobs_duration);
printf("send_profile_if_already_sent: %d\n", send_profile_if_already_sent);
printf("send_profiles_in_separate_event: %d\n", send_profiles_in_separate_event);
printf("set_job_metadata: %d\n", set_job_metadata);
LOG_SCOPE_FUNCTION(INFO);
LOG_F(INFO, "nb_jobs_to_submit: %d", nb_jobs_to_submit);
LOG_F(INFO, "increase_jobs_duration: %d", increase_jobs_duration);
LOG_F(INFO, "send_profile_if_already_sent: %d", send_profile_if_already_sent);
LOG_F(INFO, "send_profiles_in_separate_event: %d", send_profiles_in_separate_event);
LOG_F(INFO, "set_job_metadata: %d", set_job_metadata);
}
Submitter::~Submitter()
......
......@@ -2,6 +2,8 @@
#include <boost/locale.hpp>
#include <loguru.hpp>
#include "pempek_assert.hpp"
using namespace std;
......@@ -64,7 +66,6 @@ std::string RedisStorage::get(const std::string & key)
string RedisStorage::get_job_json_string(const string &job_id)
{
string job_key = "job_" + job_id;
//cout << "job_key = \"" + build_key(job_key) + "\"" << endl;
return _redox.get(build_key(job_key));
}
......@@ -86,11 +87,11 @@ bool RedisStorage::set(const std::string &key, const std::string &value)
bool ret = _redox.set(real_key, real_value);
if (ret)
{
printf("Set: '%s'='%s'", real_key.c_str(), real_value.c_str());
LOG_F(1, "Redis: Set '%s'='%s'", real_key.c_str(), real_value.c_str());
PPK_ASSERT_ERROR(get(key) == value, "Batsim <-> Redis communications are inconsistent!");
}
else
printf("Couldn't set: '%s'='%s'", real_key.c_str(), real_value.c_str());
LOG_F(WARNING, "Redis: Couldn't set: '%s'='%s'", real_key.c_str(), real_value.c_str());
return ret;
}
......
#include <stdio.h>
#include <vector>
#include <iostream>
#include <fstream>
#include <set>
......@@ -10,6 +9,9 @@
#include <rapidjson/document.h>
#define LOGURU_IMPLEMENTATION 1
#include <loguru.hpp>
#include "external/taywee_args.hpp"
#include "isalgorithm.hpp"
......@@ -83,10 +85,12 @@ int main(int argc, char ** argv)
const set<string> policies_set = {"basic", "contiguous"};
const set<string> queue_orders_set = {"fcfs", "lcfs", "desc_bounded_slowdown", "desc_slowdown",
"asc_size", "desc_size", "asc_walltime", "desc_walltime"};
const set<string> verbosity_levels_set = {"debug", "info", "quiet", "silent"};
const string variants_string = "{" + boost::algorithm::join(variants_set, ", ") + "}";
const string policies_string = "{" + boost::algorithm::join(policies_set, ", ") + "}";
const string queue_orders_string = "{" + boost::algorithm::join(queue_orders_set, ", ") + "}";
const string verbosity_levels_string = "{" + boost::algorithm::join(verbosity_levels_set, ", ") + "}";
ISchedulingAlgorithm * algo = nullptr;
ResourceSelector * selector = nullptr;
......@@ -104,6 +108,7 @@ int main(int argc, char ** argv)
args::ValueFlag<string> flag_variant_options(parser, "options", "Sets the scheduling variant options. Must be formatted as a JSON object.", {"variant_options"}, "{}");
args::ValueFlag<string> flag_variant_options_filepath(parser, "options-filepath", "Sets the scheduling variant options as the content of the given filepath. Overrides the variant_options options.", {"variant_options_filepath"}, "");
args::ValueFlag<string> flag_queue_order(parser, "order", "Sets the queue order. Available values are " + queue_orders_string, {'o', "queue_order"}, "fcfs");
args::ValueFlag<string> flag_verbosity_level(parser, "verbosity-level", "Sets the verbosity level. Available values are " + verbosity_levels_string, {"verbosity"}, "info");
args::ValueFlag<bool> flag_call_make_decisions_on_single_nop(parser, "flag", "If set to true, make_decisions will be called after single NOP messages.", {"call_make_decisions_on_single_nop"}, true);
args::Flag flag_version(parser, "version", "Shows batsched version", {"version"});
......@@ -127,6 +132,12 @@ int main(int argc, char ** argv)
% flag_scheduling_variant.Name()
% flag_scheduling_variant.Get()
% variants_string));
if (verbosity_levels_set.find(flag_verbosity_level.Get()) == verbosity_levels_set.end())
throw args::ValidationError(str(format("Invalid '%1%' value (%2%): Not in %3%")
% flag_verbosity_level.Name()
% flag_verbosity_level.Get()
% verbosity_levels_string));
}
catch(args::Help)
{
......@@ -162,11 +173,22 @@ int main(int argc, char ** argv)
string queue_order = flag_queue_order.Get();
string variant_options = flag_variant_options.Get();
string variant_options_filepath = flag_variant_options_filepath.Get();
string verbosity_level = flag_verbosity_level.Get();
double rjms_delay = flag_rjms_delay.Get();
bool call_make_decisions_on_single_nop = flag_call_make_decisions_on_single_nop.Get();
try
{
// Logging configuration
if (verbosity_level == "debug")
loguru::g_stderr_verbosity = loguru::Verbosity_1;
else if (verbosity_level == "quiet")
loguru::g_stderr_verbosity = loguru::Verbosity_WARNING;
else if (verbosity_level == "silent")
loguru::g_stderr_verbosity = loguru::Verbosity_OFF;
else
loguru::g_stderr_verbosity = loguru::Verbosity_INFO;
// Workload creation
Workload w;
w.set_rjms_delay(rjms_delay);
......@@ -234,7 +256,7 @@ int main(int argc, char ** argv)
printf("Invalid variant options: Not a JSON object. variant_options='%s'\n", variant_options.c_str());
return 1;
}
printf("variant_options = '%s'\n", variant_options.c_str());
LOG_F(1, "variant_options = '%s'", variant_options.c_str());
// Scheduling variant
if (scheduling_variant == "filler")
......@@ -295,11 +317,11 @@ int main(int argc, char ** argv)
if (what == "Connection lost")
{
cout << what << endl;
LOG_F(ERROR, "%s", what);
}
else
{
cout << "Error: " << e.what() << endl;
LOG_F(ERROR, "%s", what);
delete queue;
delete order;
......
......@@ -9,6 +9,8 @@
#include <sys/socket.h>
#include <sys/un.h>
#include <loguru.hpp>
#include "pempek_assert.hpp"
using namespace std;
......@@ -33,8 +35,7 @@ void Network::write(const string &content)
// Let's make sure the sent message is in UTF-8
string msg_utf8 = boost::locale::conv::to_utf<char>(content, "UTF-8");
printf("Sending '%s'\n", msg_utf8.c_str());
fflush(stdout);
LOG_F(INFO, "Sending '%s'", msg_utf8.c_str());
_socket->send(msg_utf8.data(), msg_utf8.size());
}
......@@ -49,6 +50,5 @@ void Network::read(string &received_content)
string received_utf8 = boost::locale::conv::from_utf(received_content, "UTF-8");
received_content = received_utf8;
printf("Received '%s'\n", received_content.c_str());
fflush(stdout);
LOG_F(INFO, "Received '%s'", received_content.c_str());
}
......@@ -29,7 +29,7 @@ void JsonProtocolWriter::append_query_consumed_energy(double date)
}
} */
PPK_ASSERT(date >= _last_date, "Date inconsistency");
PPK_ASSERT_ERROR(date >= _last_date, "Date inconsistency");
_last_date = date;
_is_empty = false;
......@@ -110,7 +110,7 @@ void JsonProtocolWriter::append_submit_job(const string &job_id,
}
} */
PPK_ASSERT(date >= _last_date, "Date inconsistency");
PPK_ASSERT_ERROR(date >= _last_date, "Date inconsistency");
_last_date = date;
_is_empty = false;
......@@ -165,7 +165,7 @@ void JsonProtocolWriter::append_submit_profile(const string &workload_name,
}
} */
PPK_ASSERT(date >= _last_date, "Date inconsistency");
PPK_ASSERT_ERROR(date >= _last_date, "Date inconsistency");
_last_date = date;
_is_empty = false;
......@@ -206,7 +206,7 @@ void JsonProtocolWriter::append_execute_job(const string &job_id,
}
} */
PPK_ASSERT(date >= _last_date, "Date inconsistency");
PPK_ASSERT_ERROR(date >= _last_date, "Date inconsistency");
_last_date = date;
_is_empty = false;
......@@ -246,7 +246,7 @@ void JsonProtocolWriter::append_reject_job(const string &job_id,
"data": { "job_id": "w12!45" }
} */
PPK_ASSERT(date >= _last_date, "Date inconsistency");
PPK_ASSERT_ERROR(date >= _last_date, "Date inconsistency");
_last_date = date;
_is_empty = false;
......@@ -270,7 +270,7 @@ void JsonProtocolWriter::append_kill_job(const vector<string> &job_ids,
"data": {"job_ids": ["w0!1", "w0!2"]}
} */
PPK_ASSERT(date >= _last_date, "Date inconsistency");
PPK_ASSERT_ERROR(date >= _last_date, "Date inconsistency");
_last_date = date;
_is_empty = false;
......@@ -300,7 +300,7 @@ void JsonProtocolWriter::append_set_resource_state(IntervalSet resources,
"data": {"resources": "1 2 3-5", "state": "42"}
} */
PPK_ASSERT(date >= _last_date, "Date inconsistency");
PPK_ASSERT_ERROR(date >= _last_date, "Date inconsistency");
_last_date = date;
_is_empty = false;
......@@ -329,7 +329,7 @@ void JsonProtocolWriter::append_set_job_metadata(const string & job_id,
}
} */
PPK_ASSERT(date >= _last_date, "Date inconsistency");
PPK_ASSERT_ERROR(date >= _last_date, "Date inconsistency");
_last_date = date;
_is_empty = false;
......@@ -354,7 +354,7 @@ void JsonProtocolWriter::append_call_me_later(double future_date,
"data": {"timestamp": 25.5}
} */
PPK_ASSERT(date >= _last_date, "Date inconsistency");
PPK_ASSERT_ERROR(date >= _last_date, "Date inconsistency");
_last_date = date;
_is_empty = false;
......@@ -377,7 +377,7 @@ void JsonProtocolWriter::append_scheduler_finished_submitting_jobs(double date)
"data": { "type": "submission_finished" }
} */
PPK_ASSERT(date >= _last_date, "Date inconsistency");
PPK_ASSERT_ERROR(date >= _last_date, "Date inconsistency");
_last_date = date;
_is_empty = false;
......@@ -404,8 +404,8 @@ void JsonProtocolWriter::clear()
string JsonProtocolWriter::generate_current_message(double date)
{
PPK_ASSERT(date >= _last_date, "Date inconsistency");
PPK_ASSERT(_events.IsArray(),
PPK_ASSERT_ERROR(date >= _last_date, "Date inconsistency");
PPK_ASSERT_ERROR(_events.IsArray(),
"Successive calls to JsonProtocolWriter::generate_current_message without calling "
"the clear() method is not supported");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment