int main(int argc, char* argv[])
{
const char* instance_id = simgrid::s4u::Actor::self()->get_property("instance_id");
- const int rank = xbt_str_parse_int(simgrid::s4u::Actor::self()->get_property("rank"), "Cannot parse rank");
+ const int rank =
+ static_cast<int>(xbt_str_parse_int(simgrid::s4u::Actor::self()->get_property("rank"), "Cannot parse rank"));
const char* trace_filename = argv[1];
double start_delay_flops = 0;
*/
static int l_host_at(lua_State * L)
{
- int index = luaL_checkinteger(L, 1);
+ lua_Integer index = luaL_checkinteger(L, 1);
std::vector<sg_host_t> hosts = simgrid::s4u::Engine::get_instance()->get_all_hosts();
sg_host_t host = hosts[index - 1]; // lua indexing start by 1 (lua[1] <=> C[0])
lua_newtable(L); /* create a table, put the userdata on top of it */
lua_ensure(type == LUA_TSTRING || type == LUA_TNUMBER,
"Attribute 'speed' must be specified for host and must either be a string (in the correct format; check documentation) or a number.");
if (type == LUA_TNUMBER)
- host.speed_per_pstate.push_back(lua_tointeger(L, -1));
+ host.speed_per_pstate.push_back(lua_tonumber(L, -1));
else // LUA_TSTRING
host.speed_per_pstate.push_back(
xbt_parse_get_speed(ar.short_src, ar.currentline, lua_tostring(L, -1), "speed of host", host.id));
if (not lua_isnumber(L, -1))
host.core_amount = 1; // Default value
else
- host.core_amount = lua_tonumber(L, -1);
+ host.core_amount = static_cast<int>(lua_tointeger(L, -1));
if (host.core_amount == 0)
host.core_amount = 1;
lua_pop(L, 1);
py::class_<Engine>(m, "Engine", "Simulation Engine")
.def(py::init([](std::vector<std::string> args) {
static char noarg[] = {'\0'};
- int argc = args.size();
+ int argc = static_cast<int>(args.size());
std::unique_ptr<char* []> argv(new char*[argc + 1]);
for (int i = 0; i != argc; ++i)
argv[i] = args[i].empty() ? noarg : &args[i].front();
{
std::string str = std::string("--cfg=") + option + " ";
- int len = str.size();
+ int len = static_cast<int>(str.size());
XBT_HELP("%s%*.*s %s", str.c_str(), 30 - len, 30 - len, "", desc);
if (longdesc != nullptr) {
XBT_HELP("%s\n", longdesc);
// find the lowest ancestor
p = nullptr;
- int i = ancestors_a1.size() - 1;
- int j = ancestors_a2.size() - 1;
+ int i = static_cast<int>(ancestors_a1.size()) - 1;
+ int j = static_cast<int>(ancestors_a2.size()) - 1;
while (i >= 0 && j >= 0) {
container_t a1p = ancestors_a1.at(i);
const simgrid::instr::Container* a2p = ancestors_a2.at(j);
}
if (TRACE_needs_platform()) {
- NetZoneContainer* container = new NetZoneContainer(id, currentContainer.size(), currentContainer.back());
+ unsigned level = static_cast<unsigned>(currentContainer.size());
+ NetZoneContainer* container = new NetZoneContainer(id, level, currentContainer.back());
currentContainer.push_back(container);
}
}
static void on_action_state_change(kernel::resource::Action const& action,
kernel::resource::Action::State /* previous */)
{
- int n = action.get_variable()->get_number_of_constraint();
+ unsigned n = static_cast<unsigned>(action.get_variable()->get_number_of_constraint());
- for (int i = 0; i < n; i++) {
+ for (unsigned i = 0; i < n; i++) {
double value = action.get_variable()->get_value() * action.get_variable()->get_constraint_weight(i);
/* Beware of composite actions: ptasks put links and cpus together. Extra pb: we cannot dynamic_cast from void* */
kernel::resource::Resource* resource = action.get_variable()->get_constraint(i)->get_id();
{
// only trace resource utilization if resource is known by tracing mechanism
container_t container = Container::by_name_or_null(resource);
- if (not container || not value)
+ if (container == nullptr || value == 0.0)
return;
// trace uncategorized resource utilization
{
auto it = std::find_if(begin(children_), end(children_),
[&child](const std::unique_ptr<Container>& c) { return c.get() == child; });
- return it == end(children_) ? -1 : std::distance(begin(children_), it);
+ return it == end(children_) ? -1 : static_cast<int>(std::distance(begin(children_), it));
}
std::vector<int> Container::get_hierarchy()
std::vector<int> heir_list = this->get_hierarchy();
- unsigned int length = heir_list.size();
+ unsigned int length = static_cast<unsigned int>(heir_list.size());
unsigned int i = 0;
for (auto const& id : heir_list) {
output += std::to_string(id);
unsigned int i=0;
xbt_assert(not this->resource_list.empty());
- unsigned int res_nb = this->resource_list.size();
+ unsigned int res_nb = static_cast<unsigned int>(this->resource_list.size());
std::string resid = this->get_hierarchy_as_string();
fprintf(jed_file, " <rset id=\"%s\" nb=\"%u\" names=\"", resid.c_str(), res_nb);
unsigned int id = parent_cont->get_id_by_name(host_name);
id_list.push_back(id);
}
- unsigned int nb_ids = id_list.size();
+ unsigned int nb_ids = static_cast<unsigned int>(id_list.size());
std::sort(id_list.begin(), id_list.end());
if( nb_ids > 0 ) {
elem.constraint = cnst;
elem.variable = var;
- if (var->sharing_penalty_) {
+ if (var->sharing_penalty_ != 0.0) {
elem.constraint->enabled_element_set_.push_front(elem);
elem.increase_concurrency();
} else
std::find_if(begin(var->cnsts_), end(var->cnsts_), [&cnst](Element const& x) { return x.constraint == cnst; });
if (elem_it != end(var->cnsts_)) {
Element& elem = *elem_it;
- if (var->sharing_penalty_)
+ if (var->sharing_penalty_ != 0.0)
elem.decrease_concurrency();
if (cnst->sharing_policy_ != s4u::Link::SharingPolicy::FATPIPE)
elem.consumption_weight = std::max(elem.consumption_weight, value);
// We need to check that increasing value of the element does not cross the concurrency limit
- if (var->sharing_penalty_) {
+ if (var->sharing_penalty_ != 0.0) {
if (cnst->get_concurrency_slack() < elem.get_concurrency()) {
double penalty = var->sharing_penalty_;
disable_var(var);
int Constraint::get_variable_amount() const
{
- return std::count_if(std::begin(enabled_element_set_), std::end(enabled_element_set_),
- [](const Element& elem) { return elem.consumption_weight > 0; });
+ return static_cast<int>(std::count_if(std::begin(enabled_element_set_), std::end(enabled_element_set_),
+ [](const Element& elem) { return elem.consumption_weight > 0; }));
}
} // namespace lmm
: id(id), level(level), position(position)
{
LinkCreationArgs linkTemplate;
- if (cluster->limiter_link) {
+ if (cluster->limiter_link != 0.0) {
linkTemplate.bandwidths.push_back(cluster->limiter_link);
linkTemplate.latency = 0;
linkTemplate.policy = s4u::Link::SharingPolicy::SHARED;
sg_platf_new_link(&linkTemplate);
this->limiter_link_ = s4u::Link::by_name(linkTemplate.id)->get_impl();
}
- if (cluster->loopback_bw || cluster->loopback_lat) {
+ if (cluster->loopback_bw != 0.0 || cluster->loopback_lat != 0.0) {
linkTemplate.bandwidths.push_back(cluster->loopback_bw);
linkTemplate.latency = cluster->loopback_lat;
linkTemplate.policy = s4u::Link::SharingPolicy::FATPIPE;
double clock_end = s4u::Engine::get_clock();
double duration = clock_end - clock_sta;
- double actual_speed = size / duration;
+ double actual_speed = static_cast<double>(size) / duration;
if (stage == 2)
XBT_DEBUG("mig-stage%d.%d: sent %llu duration %f actual_speed %f (target %f)", stage, stage2_round, size, duration,
double host_speed = vm_->get_pm()->get_speed();
const sg_size_t ramsize = vm_->get_ramsize();
const double dp_rate =
- host_speed ? (sg_vm_get_migration_speed(vm_) * sg_vm_get_dirty_page_intensity(vm_)) / host_speed : 1;
+ host_speed != 0.0 ? (sg_vm_get_migration_speed(vm_) * sg_vm_get_dirty_page_intensity(vm_)) / host_speed : 1;
const sg_size_t dp_cap = sg_vm_get_working_set_memory(vm_);
const double mig_speed = sg_vm_get_migration_speed(vm_);
double max_downtime = sg_vm_get_max_downtime(vm_);
if (previous_task && not SD_task_dependency_exists(previous_task, cur_task))
SD_task_dependency_add(previous_task, cur_task);
- SD_task_schedulel(cur_task, 1, hosts[std::stod(elm.first)]);
+ SD_task_schedulel(cur_task, 1, hosts[std::stoi(elm.first)]);
previous_task = cur_task;
}
}
*/
int SD_task_get_workstation_count(const_SD_task_t task)
{
- return task->allocation->size();
+ return static_cast<int>(task->allocation->size());
}
/**
if (dst) {
return (src->successors->find(dst) != src->successors->end() || src->outputs->find(dst) != src->outputs->end());
} else {
- return src->successors->size() + src->outputs->size();
+ return static_cast<int>(src->successors->size() + src->outputs->size());
}
} else {
- return dst->predecessors->size() + dst->inputs->size();
+ return static_cast<int>(dst->predecessors->size() + dst->inputs->size());
}
}
/* Iterate over all inputs and outputs to say where I am located (and start them if runnable) */
for (auto const& input : *task->inputs) {
- int src_nb = input->allocation->size();
+ int src_nb = static_cast<int>(input->allocation->size());
int dst_nb = count;
if (input->allocation->empty())
XBT_VERB("Sender side of '%s' not scheduled. Set receiver side to '%s''s allocation", input->name, task->name);
for (auto const& output : *task->outputs) {
int src_nb = count;
- int dst_nb = output->allocation->size();
+ int dst_nb = static_cast<int>(output->allocation->size());
if (output->allocation->empty())
XBT_VERB("Receiver side of '%s' not scheduled. Set sender side to '%s''s allocation", output->name, task->name);
for (auto it = std::begin(*get_started_action_set()); it != std::end(*get_started_action_set());) {
auto& action = *it;
++it; // increment iterator here since the following calls to action.finish() may invalidate it
- action.update_remains(lrint(action.get_variable()->get_value() * delta));
+ action.update_remains(rint(action.get_variable()->get_value() * delta));
action.update_max_duration(delta);
if (((action.get_remains_no_update() <= 0) && (action.get_variable()->get_penalty() > 0)) ||
DiskAction* DiskS19::io_start(sg_size_t size, s4u::Io::OpType type)
{
- return new DiskS19Action(get_model(), size, not is_on(), this, type);
+ return new DiskS19Action(get_model(), static_cast<double>(size), not is_on(), this, type);
}
DiskAction* DiskS19::read(sg_size_t size)
{
- return new DiskS19Action(get_model(), size, not is_on(), this, s4u::Io::OpType::READ);
+ return new DiskS19Action(get_model(), static_cast<double>(size), not is_on(), this, s4u::Io::OpType::READ);
}
DiskAction* DiskS19::write(sg_size_t size)
{
- return new DiskS19Action(get_model(), size, not is_on(), this, s4u::Io::OpType::WRITE);
+ return new DiskS19Action(get_model(), static_cast<double>(size), not is_on(), this, s4u::Io::OpType::WRITE);
}
/**********
void NetworkWifiLink::refresh_decay_bandwidths(){
// Compute number of STAtion on the Access Point
- int nSTA=host_rates_.size();
-
+ int nSTA = static_cast<int>(host_rates_.size());
+
std::vector<Metric> new_bandwidths;
for (auto bandwidth : bandwidths_){
// Instantiate decay model relatively to the actual bandwidth
for (auto it = std::begin(*get_started_action_set()); it != std::end(*get_started_action_set());) {
auto& action = *it;
++it; // increment iterator here since the following calls to action.finish() may invalidate it
- action.update_remains(lrint(action.get_variable()->get_value() * delta));
+ action.update_remains(rint(action.get_variable()->get_value() * delta));
action.update_max_duration(delta);
if (((action.get_remains_no_update() <= 0) && (action.get_variable()->get_penalty() > 0)) ||
StorageAction* StorageN11::io_start(sg_size_t size, s4u::Io::OpType type)
{
- return new StorageN11Action(get_model(), size, not is_on(), this, type);
+ return new StorageN11Action(get_model(), static_cast<double>(size), not is_on(), this, type);
}
StorageAction* StorageN11::read(sg_size_t size)
{
- return new StorageN11Action(get_model(), size, not is_on(), this, s4u::Io::OpType::READ);
+ return new StorageN11Action(get_model(), static_cast<double>(size), not is_on(), this, s4u::Io::OpType::READ);
}
StorageAction* StorageN11::write(sg_size_t size)
{
- return new StorageN11Action(get_model(), size, not is_on(), this, s4u::Io::OpType::WRITE);
+ return new StorageN11Action(get_model(), static_cast<double>(size), not is_on(), this, s4u::Io::OpType::WRITE);
}
/**********