Skip to content
Snippets Groups Projects
Commit d06890e5 authored by Maël Madon's avatar Maël Madon Committed by jgatt
Browse files

dev: added the number of cores as an argument in the CLI. Closes #16

parent 5bc8f4a9
No related branches found
No related tags found
1 merge request!16Merge request multibehavior
Pipeline #5703 passed
...@@ -10,6 +10,12 @@ void ISchedulingAlgorithm::set_nb_machines(int nb_machines) ...@@ -10,6 +10,12 @@ void ISchedulingAlgorithm::set_nb_machines(int nb_machines)
_nb_machines = nb_machines; _nb_machines = nb_machines;
} }
void ISchedulingAlgorithm::set_nb_cores_per_machine(int nb_core)
{
PPK_ASSERT_ERROR(_nb_cores_per_machine == -1);
_nb_cores_per_machine = nb_core;
}
void ISchedulingAlgorithm::clear_recent_data_structures() void ISchedulingAlgorithm::clear_recent_data_structures()
{ {
_jobs_released_recently.clear(); _jobs_released_recently.clear();
......
...@@ -135,6 +135,14 @@ public: ...@@ -135,6 +135,14 @@ public:
*/ */
void set_nb_machines(int nb_machines); void set_nb_machines(int nb_machines);
/**
* @brief Allows to set the number of cores per machine in the platform
* @details For now, the number of cores per machine is retrieved from batmen CLI. In the future (batsim v5) it
* will be retrieved from the platform file.
* @param[in] nb_core The number of cores per machine in the platform
*/
void set_nb_cores_per_machine(int nb_core);
/** /**
* @brief Clears data structures used to store what happened between two make_decisions calls * @brief Clears data structures used to store what happened between two make_decisions calls
* @details This function should be called between make_decisions calls! * @details This function should be called between make_decisions calls!
...@@ -149,6 +157,7 @@ protected: ...@@ -149,6 +157,7 @@ protected:
double _rjms_delay = 0.0; double _rjms_delay = 0.0;
rapidjson::Document * _variant_options = nullptr; rapidjson::Document * _variant_options = nullptr;
int _nb_machines = -1; int _nb_machines = -1;
int _nb_cores_per_machine = -1;
bool _no_more_static_job_to_submit_received = false; bool _no_more_static_job_to_submit_received = false;
bool _no_more_external_event_to_occur_received = false; bool _no_more_external_event_to_occur_received = false;
......
...@@ -76,8 +76,10 @@ int main(int argc, char **argv) ...@@ -76,8 +76,10 @@ int main(int argc, char **argv)
"Sets the scheduling variant options. Must be formatted as a JSON object.", { "variant_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", 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 " "Sets the scheduling variant options as the content of the given filepath. Overrides the variant_options "
"options.", "options.", { "variant_options_filepath" }, "");
{ "variant_options_filepath" }, ""); args::ValueFlag<int> flag_nb_cores_per_machine(parser, "nb_cores_per_machine",
"Sets the number of cores per machine in the plateform (warning: must match the platform file)",
{ "nb_cores" }, DEFAULT_NB_CORE_PER_MACHINE);
args::ValueFlag<string> flag_verbosity_level(parser, "verbosity-level", args::ValueFlag<string> flag_verbosity_level(parser, "verbosity-level",
"Sets the verbosity level. Available values are " + verbosity_levels_string, { "verbosity" }, "info"); "Sets the verbosity level. Available values are " + verbosity_levels_string, { "verbosity" }, "info");
args::ValueFlag<bool> flag_call_make_decisions_on_single_nop(parser, "flag", args::ValueFlag<bool> flag_call_make_decisions_on_single_nop(parser, "flag",
...@@ -92,6 +94,10 @@ int main(int argc, char **argv) ...@@ -92,6 +94,10 @@ int main(int argc, char **argv)
throw args::ValidationError(str(format("Invalid '%1%' parameter value (%2%): Must be non-negative.") throw args::ValidationError(str(format("Invalid '%1%' parameter value (%2%): Must be non-negative.")
% flag_rjms_delay.Name() % flag_rjms_delay.Get())); % flag_rjms_delay.Name() % flag_rjms_delay.Get()));
if (flag_nb_cores_per_machine.Get() < 0)
throw args::ValidationError(str(format("Invalid '%1%' parameter value (%2%): Must be non-negative.")
% flag_nb_cores_per_machine.Name() % flag_nb_cores_per_machine.Get()));
if (variants_set.find(flag_scheduling_variant.Get()) == variants_set.end()) if (variants_set.find(flag_scheduling_variant.Get()) == variants_set.end())
throw args::ValidationError(str(format("Invalid '%1%' value (%2%): Not in %3%") throw args::ValidationError(str(format("Invalid '%1%' value (%2%): Not in %3%")
% flag_scheduling_variant.Name() % flag_scheduling_variant.Get() % variants_string)); % flag_scheduling_variant.Name() % flag_scheduling_variant.Get() % variants_string));
...@@ -125,6 +131,7 @@ int main(int argc, char **argv) ...@@ -125,6 +131,7 @@ int main(int argc, char **argv)
string variant_options_filepath = flag_variant_options_filepath.Get(); string variant_options_filepath = flag_variant_options_filepath.Get();
string verbosity_level = flag_verbosity_level.Get(); string verbosity_level = flag_verbosity_level.Get();
double rjms_delay = flag_rjms_delay.Get(); double rjms_delay = flag_rjms_delay.Get();
int nb_cores_per_machine = flag_nb_cores_per_machine.Get();
bool call_make_decisions_on_single_nop = flag_call_make_decisions_on_single_nop.Get(); bool call_make_decisions_on_single_nop = flag_call_make_decisions_on_single_nop.Get();
try try
...@@ -214,6 +221,9 @@ int main(int argc, char **argv) ...@@ -214,6 +221,9 @@ int main(int argc, char **argv)
else if (scheduling_variant == "bin_packing_energy") else if (scheduling_variant == "bin_packing_energy")
algo = new BinPackingEnergy(&w, &decision, queue, selector, rjms_delay, &json_doc_variant_options); algo = new BinPackingEnergy(&w, &decision, queue, selector, rjms_delay, &json_doc_variant_options);
// Nb_core_per_machine
// TODO (wait for batsim5.0): retrieve it from the platform file at SIMULATION_BEGIN */
algo->set_nb_cores_per_machine(nb_cores_per_machine);
// Network // Network
Network n; Network n;
......
#define PLATFORM_COMPUTING_SPEED 11.77e9 #define PLATFORM_COMPUTING_SPEED 11.77e9
#define NB_CORE_PER_MACHINE 16 #define DEFAULT_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
...@@ -65,12 +65,9 @@ void BinPacking::on_simulation_start( ...@@ -65,12 +65,9 @@ void BinPacking::on_simulation_start(
// PPK_ASSERT_ERROR(batsim_config["dynamic-jobs-enabled"].GetBool(), // PPK_ASSERT_ERROR(batsim_config["dynamic-jobs-enabled"].GetBool(),
// "This algorithm only works if dynamic job are enabled!"); // "This algorithm only works if dynamic job are enabled!");
// TODO (wait batsim5.0): retrieve the nb of cores per machine from the
// platform file and compute the max_nb_core
max_nb_core = NB_CORE_PER_MACHINE;
for (int i = 0; i < _nb_machines; i++) for (int i = 0; i < _nb_machines; i++)
{ {
listofHosts.push_back(new SortableHost(i, max_nb_core)); listofHosts.push_back(new SortableHost(i, _nb_cores_per_machine));
} }
if (_debug) if (_debug)
LOG_F(1, "binpacking, list of hosts=%s", LOG_F(1, "binpacking, list of hosts=%s",
...@@ -102,7 +99,7 @@ void BinPacking::make_decisions(double date, ...@@ -102,7 +99,7 @@ void BinPacking::make_decisions(double date,
{ {
const Job *new_job = (*_workload)[new_job_id]; const Job *new_job = (*_workload)[new_job_id];
if (new_job->nb_requested_resources > max_nb_core) if (new_job->nb_requested_resources > _nb_cores_per_machine)
{ {
_decision->add_reject_job(new_job_id, date); _decision->add_reject_job(new_job_id, date);
if (broker_enabled) if (broker_enabled)
......
...@@ -59,7 +59,6 @@ public: ...@@ -59,7 +59,6 @@ public:
SortableJobOrder::CompareInformation *compare_info); SortableJobOrder::CompareInformation *compare_info);
private: private:
int max_nb_core;
// list of hosts, to be sorted with listofHosts.sort(HostComparator()) // list of hosts, to be sorted with listofHosts.sort(HostComparator())
std::list<SortableHost *> listofHosts; std::list<SortableHost *> listofHosts;
std::map<std::string, SortableHost *> current_allocations; std::map<std::string, SortableHost *> current_allocations;
......
...@@ -115,13 +115,10 @@ void BinPackingEnergy::on_simulation_start( ...@@ -115,13 +115,10 @@ void BinPackingEnergy::on_simulation_start(
// works if dynamic job are enabled!"); // works if dynamic job are enabled!");
/* TODO (wait for batsim5.0): /* TODO (wait for batsim5.0):
* - retrieve the nb of cores per machine from the platform file and
* compute the max_nb_core
* - get the initial machine state (AWAKE, ASLEEP, ...) of each machine * - get the initial machine state (AWAKE, ASLEEP, ...) of each machine
* from the platform file * from the platform file
* - get the pstates from the variant_option file * - get the pstates from the variant_option file
*/ */
max_nb_core = NB_CORE_PER_MACHINE;
MachineState initial_machine_state = INITIAL_MACHINE_STATE; MachineState initial_machine_state = INITIAL_MACHINE_STATE;
int pstate_awake = PSTATE_AWAKE; int pstate_awake = PSTATE_AWAKE;
int pstate_asleep = PSTATE_ASLEEP; int pstate_asleep = PSTATE_ASLEEP;
...@@ -131,7 +128,7 @@ void BinPackingEnergy::on_simulation_start( ...@@ -131,7 +128,7 @@ void BinPackingEnergy::on_simulation_start(
for (int i = 0; i < _nb_machines; i++) for (int i = 0; i < _nb_machines; i++)
{ {
auto host = new SortableHost( auto host = new SortableHost(
i, max_nb_core, initial_machine_state, pstate_awake, pstate_asleep); i, _nb_cores_per_machine, initial_machine_state, pstate_awake, pstate_asleep);
listofHosts.push_back(host); listofHosts.push_back(host);
vectorofHosts[i] = host; vectorofHosts[i] = host;
} }
...@@ -242,7 +239,7 @@ void BinPackingEnergy::make_decisions(double date, ...@@ -242,7 +239,7 @@ void BinPackingEnergy::make_decisions(double date,
{ {
const Job *new_job = (*_workload)[new_job_id]; const Job *new_job = (*_workload)[new_job_id];
if (new_job->nb_requested_resources > max_nb_core) if (new_job->nb_requested_resources > _nb_cores_per_machine)
{ {
_decision->add_reject_job(new_job_id, date); _decision->add_reject_job(new_job_id, date);
if (broker_enabled) if (broker_enabled)
......
...@@ -83,7 +83,6 @@ protected: ...@@ -83,7 +83,6 @@ protected:
void update_machine_states(double date); void update_machine_states(double date);
private: private:
int max_nb_core;
// list of hosts, to be sorted with listofHosts.sort(HostComparator()) // list of hosts, to be sorted with listofHosts.sort(HostComparator())
std::list<SortableHost *> listofHosts; std::list<SortableHost *> listofHosts;
std::vector<SortableHost *> vectorofHosts; std::vector<SortableHost *> vectorofHosts;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment