Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
henricasanova committed Jan 8, 2025
1 parent ee6e31f commit f76f9d8
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion include/wrench/action/Action.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ namespace wrench {

virtual bool usesScratch() const;

void setPriority(double priority);
void setPriority(double p);
double getPriority() const;

static std::string getActionTypeAsString(const std::shared_ptr<Action> &action);
Expand Down
4 changes: 2 additions & 2 deletions include/wrench/action/ComputeAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ namespace wrench {
ComputeAction(const std::string &name,
double flops,
sg_size_t ram,
unsigned long min_core,
unsigned long max_core,
unsigned long min_num_cores,
unsigned long max_num_cores,
std::shared_ptr<ParallelModel> parallel_model);

void execute(const std::shared_ptr<ActionExecutor> &action_executor) override;
Expand Down
8 changes: 4 additions & 4 deletions src/wrench/action/ComputeAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ namespace wrench {
* @param parallel_model: the parallel model (to determine speedup vs. number of cores)
*/
ComputeAction::ComputeAction(const std::string &name,
double flops,
sg_size_t ram,
unsigned long min_num_cores,
unsigned long max_num_cores,
const double flops,
const sg_size_t ram,
const unsigned long min_num_cores,
const unsigned long max_num_cores,
std::shared_ptr<ParallelModel> parallel_model) : Action(name, "compute_") {

if ((flops < 0) || (min_num_cores < 1) || (max_num_cores < min_num_cores)) {
Expand Down
2 changes: 1 addition & 1 deletion src/wrench/communicator/Communicator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ namespace wrench {
* @param config: the SMPI config option
*/
void Communicator::MPI_Bcast(int root_rank, sg_size_t bytes, std::string config) {
if ((bytes < 1) or (root_rank < 0) or (root_rank >= (int) this->size)) {
if ((bytes < 1) or (root_rank < 0) or (root_rank >= static_cast<int>(this->size))) {
throw std::runtime_error("Communicator::MPI_Bcast(): invalid argument");
}
this->performSMPIOperation("Bcast", this->participating_hosts, this->rank_to_host[root_rank], bytes, "smpi/bcast:" + std::move(config));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace wrench {
this->max_num_nodes = max_num_nodes;
this->max_num_cores_per_node = max_num_cores_per_node;

for (int i = 0; i < (int) this->max_num_nodes; i++) {
for (int i = 0; i < static_cast<int>(this->max_num_nodes); i++) {
this->integer_sequence.insert(this->integer_sequence.end(), i);
}
}
Expand Down Expand Up @@ -90,7 +90,7 @@ namespace wrench {
std::cerr << "------ SCHEDULE -----\n";
for (auto &availability_timeslot: this->availability_timeslots) {
std::cerr << availability_timeslot.first << "(";
for (int i = 0; i < (int) this->max_num_nodes; i++) {
for (int i = 0; i < static_cast<int>(this->max_num_nodes); i++) {
std::cerr << availability_timeslot.second.core_utilization[i] << " ";
}
std::cerr << ") | ";
Expand Down Expand Up @@ -141,7 +141,7 @@ namespace wrench {
// std::cerr << "LOOKING AT A TIME SLOT " << availability_timeslot.first << "\n";
// std::cerr << " RIGHT NOW POSSIBLE NODES: " << possible_node_indices.size() << "\n";
// Remove infeasible hosts
for (int i = 0; i < (int) this->max_num_nodes; i++) {
for (int i = 0; i < static_cast<int>(this->max_num_nodes); i++) {
// std::cerr << " - " << availability_timeslot.second.core_utilization[i] << "\n";
if (availability_timeslot.second.core_utilization[i] + num_cores_per_node > this->max_num_cores_per_node) {
possible_node_indices.erase(i);
Expand Down
10 changes: 5 additions & 5 deletions src/wrench/simgrid_S4U_util/S4U_Simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,14 +520,14 @@ namespace wrench {
double sequential_work,
double parallel_per_thread_work) {
// Overhead
S4U_Simulation::sleep((int) num_threads * thread_creation_overhead);
S4U_Simulation::sleep(static_cast<int>(num_threads) * thread_creation_overhead);
if (num_threads == 1) {
simgrid::s4u::this_actor::execute(sequential_work + parallel_per_thread_work);
} else {
// Launch compute-heavy thread
auto bottleneck_thread = simgrid::s4u::this_actor::exec_async(sequential_work + parallel_per_thread_work);
// Launch all other threads
simgrid::s4u::this_actor::thread_execute(simgrid::s4u::this_actor::get_host(), parallel_per_thread_work, (int) num_threads - 1);
simgrid::s4u::this_actor::thread_execute(simgrid::s4u::this_actor::get_host(), parallel_per_thread_work, static_cast<int>(num_threads) - 1);
// Wait for the compute-heavy thread
bottleneck_thread->wait();
}
Expand Down Expand Up @@ -872,7 +872,7 @@ namespace wrench {
throw std::invalid_argument("Unknown hostname " + hostname);
}
try {
return (int) (host->get_pstate_count());
return static_cast<int>(host->get_pstate_count());
} catch (std::exception &e) {
throw std::runtime_error(
"S4U_Simulation::getNumberofPstates():: Was not able to get the energy consumed by the host. "
Expand Down Expand Up @@ -910,7 +910,7 @@ namespace wrench {
throw std::invalid_argument("Unknown hostname " + hostname);
}
try {
return sg_host_get_wattmin_at(host, (int) (host->get_pstate()));
return sg_host_get_wattmin_at(host, static_cast<int>(host->get_pstate()));
} catch (std::exception &e) {
throw std::runtime_error(
"S4U_Simulation::getMinPowerConsumption(): Was not able to get the min power available to the host. "
Expand All @@ -930,7 +930,7 @@ namespace wrench {
}
try {
return sg_host_get_wattmax_at(simgrid::s4u::Host::by_name(hostname),
(int) ((simgrid::s4u::Host::by_name(hostname))->get_pstate()));
static_cast<int>((simgrid::s4u::Host::by_name(hostname))->get_pstate()));
} catch (std::exception &e) {
throw std::runtime_error(
"S4U_Simulation::getMaxPowerConsumption():: Was not able to get the max power possible for the host. "
Expand Down
2 changes: 1 addition & 1 deletion src/wrench/simgrid_S4U_util/S4U_VirtualMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ namespace wrench {
}

this->vm = physical_host->create_vm(this->vm_name,
(int) this->num_cores,
static_cast<int>(this->num_cores),
(size_t) this->ram_memory);

// this->vm = new simgrid::s4u::VirtualMachine(this->vm_name,
Expand Down
2 changes: 1 addition & 1 deletion src/wrench/simulation/Simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1280,7 +1280,7 @@ namespace wrench {
* @return The index of the current pstate of the host (as specified in the platform xml description file)
*/
int Simulation::getCurrentPstate(const std::string &hostname) {
return (int) S4U_Simulation::getCurrentPstate(hostname);
return static_cast<int>(S4U_Simulation::getCurrentPstate(hostname));
}

/**
Expand Down

0 comments on commit f76f9d8

Please sign in to comment.