});
sg4::Activity::on_completion_cb([](sg4::Activity const& activity) {
- const auto* exec = dynamic_cast<sg4::Exec const*>(&activity);
- if (exec != nullptr)
+ if (const auto* exec = dynamic_cast<sg4::Exec const*>(&activity))
XBT_INFO("Activity '%s' is complete (start time: %f, finish time: %f)", exec->get_cname(), exec->get_start_time(),
exec->get_finish_time());
- const auto* comm = dynamic_cast<sg4::Comm const*>(&activity);
- if (comm != nullptr)
+ if (const auto* comm = dynamic_cast<sg4::Comm const*>(&activity))
XBT_INFO("Activity '%s' is complete", comm->get_cname());
});
exec->set_host(hosts[cursor % count]);
cursor++;
}
- auto* comm = dynamic_cast<sg4::Comm*>(a.get());
- if (comm != nullptr) {
+ if (auto* comm = dynamic_cast<sg4::Comm*>(a.get())) {
auto pred = dynamic_cast<sg4::Exec*>((*comm->get_dependencies().begin()).get());
auto succ = dynamic_cast<sg4::Exec*>(comm->get_successors().front().get());
comm->set_source(pred->get_host())->set_destination(succ->get_host());
XBT_INFO("-------------- Summary of executed schedule ------------------");
for (const auto& a : dag) {
- const auto* exec = dynamic_cast<sg4::Exec*>(a.get());
- if (exec != nullptr) {
+ if (const auto* exec = dynamic_cast<sg4::Exec*>(a.get())) {
XBT_INFO("[%f->%f] '%s' executed on %s", exec->get_start_time(), exec->get_finish_time(), exec->get_cname(),
exec->get_host()->get_cname());
}
- const auto* comm = dynamic_cast<sg4::Comm*>(a.get());
- if (comm != nullptr) {
+ if (const auto* comm = dynamic_cast<sg4::Comm*>(a.get())) {
XBT_INFO("[%f->%f] '%s' transferred from %s to %s", comm->get_start_time(), comm->get_finish_time(),
comm->get_cname(), comm->get_source()->get_cname(), comm->get_destination()->get_cname());
}
exec->set_host(hosts[cursor % count]);
cursor++;
}
- auto* comm = dynamic_cast<sg4::Comm*>(a.get());
- if (comm != nullptr) {
+ if (auto* comm = dynamic_cast<sg4::Comm*>(a.get())) {
auto pred = dynamic_cast<sg4::Exec*>((*comm->get_dependencies().begin()).get());
auto succ = dynamic_cast<sg4::Exec*>(comm->get_successors().front().get());
comm->set_source(pred->get_host())->set_destination(succ->get_host());
XBT_INFO("-------------- Summary of executed schedule ------------------");
for (const auto& a : dag) {
- const auto* exec = dynamic_cast<sg4::Exec*>(a.get());
- if (exec != nullptr) {
+ if (const auto* exec = dynamic_cast<sg4::Exec*>(a.get())) {
XBT_INFO("[%f->%f] '%s' executed on %s", exec->get_start_time(), exec->get_finish_time(), exec->get_cname(),
exec->get_host()->get_cname());
}
- const auto* comm = dynamic_cast<sg4::Comm*>(a.get());
- if (comm != nullptr) {
+ if (const auto* comm = dynamic_cast<sg4::Comm*>(a.get())) {
XBT_INFO("[%f->%f] '%s' transferred from %s to %s", comm->get_start_time(), comm->get_finish_time(),
comm->get_cname(), comm->get_source()->get_cname(), comm->get_destination()->get_cname());
}
// Only look at activity that have their dependencies solved but are not assigned
if (a->dependencies_solved() && not a->is_assigned()) {
// if it is an exec, it's ready
- auto* exec = dynamic_cast<sg4::Exec*>(a.get());
- if (exec != nullptr)
+ if (auto* exec = dynamic_cast<sg4::Exec*>(a.get()))
ready_tasks.push_back(exec);
// if it a comm, we consider its successor as a candidate. If a candidate solves all its dependencies,
// i.e., get all its input data, it's ready
- const auto* comm = dynamic_cast<sg4::Comm*>(a.get());
- if (comm != nullptr) {
+ if (const auto* comm = dynamic_cast<sg4::Comm*>(a.get())) {
auto* next_exec = static_cast<sg4::Exec*>(comm->get_successors().front().get());
candidate_execs[next_exec]++;
if (next_exec->get_dependencies().size() == candidate_execs[next_exec])
last_data_available = -1.0;
for (const auto& parent : parents) {
/* normal case */
- const auto* comm = dynamic_cast<sg4::Comm*>(parent.get());
- if (comm != nullptr) {
+ if (const auto* comm = dynamic_cast<sg4::Comm*>(parent.get())) {
auto source = comm->get_source();
XBT_DEBUG("transfer from %s to %s", source->get_cname(), host->get_cname());
/* Estimate the redistribution time from this parent */
data_available = *comm->get_data<double>() + redist_time;
}
- const auto* exec = dynamic_cast<sg4::Exec*>(parent.get());
/* no transfer, control dependency */
- if (exec != nullptr) {
+ if (const auto* exec = dynamic_cast<sg4::Exec*>(parent.get())) {
data_available = exec->get_finish_time();
}
XBT_DEBUG("Received an answer from the node I know.");
got_answer = true;
// retrieve the node list and ping them.
- const Answer* node_list = msg->answer_.get();
- if (node_list) {
+ if (const Answer* node_list = msg->answer_.get()) {
for (auto const& [contact, _] : node_list->getNodes())
routingTableUpdate(contact);
} else {
T* get()
{
T* data;
- s4u::CommPtr comm = get_async(&data);
- if (comm) {
+ if (s4u::CommPtr comm = get_async(&data)) {
XBT_CDEBUG(producer_consumer, "Waiting for the data to arrive");
comm->wait();
}
double value = action.get_rate() * 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();
- const kernel::resource::CpuImpl* cpu = dynamic_cast<kernel::resource::CpuImpl*>(resource);
-
- if (cpu != nullptr)
+ if (const auto* cpu = dynamic_cast<kernel::resource::CpuImpl*>(resource))
resource_set_utilization("HOST", "speed_used", cpu->get_cname(), action.get_category(), value,
action.get_last_update(), simgrid_get_clock() - action.get_last_update());
- const kernel::resource::StandardLinkImpl* link = dynamic_cast<kernel::resource::StandardLinkImpl*>(resource);
-
- if (link != nullptr)
+ if (const auto* link = dynamic_cast<kernel::resource::StandardLinkImpl*>(resource))
resource_set_utilization("LINK", "bandwidth_used", link->get_cname(), action.get_category(), value,
action.get_last_update(), simgrid_get_clock() - action.get_last_update());
}
return link_it->second;
for (const auto* child : children_) {
- auto* link = child->get_link_by_name_or_null(name);
- if (link)
+ if (auto* link = child->get_link_by_name_or_null(name))
return link;
}
return link_it->second.get();
for (const auto* child : children_) {
- auto* link = child->get_split_duplex_link_by_name_or_null(name);
- if (link)
+ if (auto* link = child->get_split_duplex_link_by_name_or_null(name))
return link;
}
static Elf64_Half get_type(Elf* elf)
{
- const Elf64_Ehdr* ehdr64 = elf64_getehdr(elf);
- if (ehdr64)
+ if (const Elf64_Ehdr* ehdr64 = elf64_getehdr(elf))
return ehdr64->e_type;
- const Elf32_Ehdr* ehdr32 = elf32_getehdr(elf);
- if (ehdr32)
+ if (const Elf32_Ehdr* ehdr32 = elf32_getehdr(elf))
return ehdr32->e_type;
xbt_die("Could not get ELF heeader");
}
info->flags |= simgrid::mc::ObjectInformation::Executable;
// Read DWARF debug information in the file:
- Dwarf* dwarf = dwarf_begin_elf(elf, DWARF_C_READ, nullptr);
- if (dwarf != nullptr) {
+ if (Dwarf* dwarf = dwarf_begin_elf(elf, DWARF_C_READ, nullptr)) {
read_dwarf_info(info, dwarf);
dwarf_end(dwarf);
elf_end(elf);
close(fd);
return;
}
- dwarf_end(dwarf);
// If there was no DWARF in the file, try to find it in a separate file.
// Different methods might be used to store the DWARF information:
// Load the DWARF info from this file:
XBT_DEBUG("Load DWARF for %s", info->file_name.c_str());
- dwarf = dwarf_begin(fd, DWARF_C_READ);
+ Dwarf* dwarf = dwarf_begin(fd, DWARF_C_READ);
xbt_assert(dwarf != nullptr, "No DWARF info for %s", info->file_name.c_str());
read_dwarf_info(info, dwarf);
dwarf_end(dwarf);
// Try to find a more complete description of the type:
// We need to fix in order to support C++.
- simgrid::mc::Type** subtype = simgrid::util::find_map_ptr(info->full_types_by_name, type->name);
- if (subtype)
+ if (simgrid::mc::Type** subtype = simgrid::util::find_map_ptr(info->full_types_by_name, type->name))
type = *subtype;
return type;
}
continue;
xbt_assert(c > 0, "Could not read string from remote process");
- const void* p = memchr(res.data() + off, '\0', c);
- if (p)
+ if (const void* p = memchr(res.data() + off, '\0', c))
return std::string(res.data());
off += c;
xbt_assert(type >= 0 && type <= static_cast<short>(Transition::Type::UNKNOWN), "Invalid transition type %d received",
type);
- auto simcall = static_cast<Transition::Type>(type);
-
- switch (simcall) {
+ switch (auto simcall = static_cast<Transition::Type>(type)) {
case Transition::Type::BARRIER_LOCK:
case Transition::Type::BARRIER_WAIT:
return new BarrierTransition(issuer, times_considered, simcall, stream);
FileSystemDiskExt::FileSystemDiskExt(const Disk* ptr)
{
- const char* size_str = ptr->get_property("size");
- std::string dummyfile;
- if (size_str)
+ if (const char* size_str = ptr->get_property("size")) {
+ std::string dummyfile;
size_ = xbt_parse_get_size(dummyfile, -1, size_str, "disk size " + ptr->get_name());
+ }
- const char* current_mount_str = ptr->get_property("mount");
- if (current_mount_str)
+ if (const char* current_mount_str = ptr->get_property("mount"))
mount_point_ = std::string(current_mount_str);
else
mount_point_ = std::string("/");
- const char* content_str = ptr->get_property("content");
- if (content_str)
+ if (const char* content_str = ptr->get_property("content"))
content_.reset(parse_content(content_str));
}
void init()
{
- const char* local_sampling_rate_config = host_->get_property(cfg_sampling_rate.get_name());
- if (local_sampling_rate_config != nullptr) {
+ if (const char* local_sampling_rate_config = host_->get_property(cfg_sampling_rate.get_name())) {
sampling_rate_ = std::stod(local_sampling_rate_config);
} else {
sampling_rate_ = cfg_sampling_rate;
}
- const char* local_min_pstate_config = host_->get_property(cfg_min_pstate.get_name());
- if (local_min_pstate_config != nullptr) {
+ if (const char* local_min_pstate_config = host_->get_property(cfg_min_pstate.get_name())) {
min_pstate = std::stoul(local_min_pstate_config);
}
- const char* local_max_pstate_config = host_->get_property(cfg_max_pstate.get_name());
- if (local_max_pstate_config != nullptr) {
+ if (const char* local_max_pstate_config = host_->get_property(cfg_max_pstate.get_name())) {
max_pstate = std::stoul(local_max_pstate_config);
}
xbt_assert(max_pstate <= host_->get_pstate_count() - 1, "Value for max_pstate too large!");
XBT_DEBUG("DVFS process on %s is a daemon: %d", daemon_proc->get_host()->get_cname(), daemon_proc->is_daemon());
std::string dvfs_governor;
- const char* host_conf = daemon_proc->get_host()->get_property("plugin/dvfs/governor");
- if (host_conf != nullptr) {
+ if (const char* host_conf = daemon_proc->get_host()->get_property("plugin/dvfs/governor")) {
dvfs_governor = std::string(host_conf);
boost::algorithm::to_lower(dvfs_governor);
} else {
simgrid::s4u::Host* host = cpu->get_iface();
if (host != nullptr) {
// If it's a VM, take the corresponding PM
- const simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(host);
- if (vm) // If it's a VM, take the corresponding PM
+ if (const auto* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(host))
host = vm->get_pm();
// Get the host_energy extension for the relevant host
simgrid::s4u::Exec::on_start_cb([](simgrid::s4u::Exec const& activity) {
if (activity.get_host_number() == 1) { // We only run on one host
simgrid::s4u::Host* host = activity.get_host();
- const simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(host);
- if (vm != nullptr)
+ if (const auto* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(host))
host = vm->get_pm();
xbt_assert(host != nullptr);
host->extension<HostEnergy>()->update();
simgrid::s4u::Exec::on_start_cb([](simgrid::s4u::Exec const& activity) {
if (activity.get_host_number() == 1) { // We only run on one host
simgrid::s4u::Host* host = activity.get_host();
- const simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(host);
- if (vm != nullptr)
+ if (const auto* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(host))
host = vm->get_pm();
xbt_assert(host != nullptr);
host->extension<HostLoad>()->add_activity(static_cast<simgrid::kernel::activity::ExecImpl*>(activity.get_impl()));
return;
if (exec->get_host_number() == 1) { // We only run on one host
simgrid::s4u::Host* host = exec->get_host();
- const simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(host);
- if (vm != nullptr)
+ if (const auto* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(host))
host = vm->get_pm();
xbt_assert(host != nullptr);
host->extension<HostLoad>()->update();
Set to 0 if you do not want to compute beacons,
otherwise to the duration of beacons transmissions per second
*/
- const char* beacons_factor = this->link_->get_property("control_duration");
- if(beacons_factor != nullptr) {
+ if (const char* beacons_factor = this->link_->get_property("control_duration")) {
try {
control_duration_ = std::stod(beacons_factor);
} catch (const std::invalid_argument&) {
static smpi_entry_point_type smpi_resolve_function(void* handle)
{
- auto* entry_point_fortran = reinterpret_cast<smpi_fortran_entry_point_type>(dlsym(handle, "user_main_"));
- if (entry_point_fortran != nullptr) {
+ if (auto* entry_point_fortran = reinterpret_cast<smpi_fortran_entry_point_type>(dlsym(handle, "user_main_"))) {
return [entry_point_fortran](int, char**) {
entry_point_fortran();
return 0;
};
}
- auto* entry_point = reinterpret_cast<smpi_c_entry_point_type>(dlsym(handle, "main"));
- if (entry_point != nullptr) {
+ if (auto* entry_point = reinterpret_cast<smpi_c_entry_point_type>(dlsym(handle, "main"))) {
return entry_point;
}
smpi::Host::EXTENSION_ID = s4u::Host::extension_create<Host>();
check_factor_configs("smpi/or");
- const char* orecv_string = host->get_property("smpi/or");
- if (orecv_string != nullptr) {
+ if (const char* orecv_string = host->get_property("smpi/or")) {
orecv_parsed_values = simgrid::smpi::utils::parse_factor(orecv_string);
} else {
orecv_parsed_values = simgrid::smpi::utils::parse_factor(config::get_value<std::string>("smpi/or"));
}
check_factor_configs("smpi/os");
- const char* osend_string = host->get_property("smpi/os");
- if (osend_string != nullptr) {
+ if (const char* osend_string = host->get_property("smpi/os")) {
osend_parsed_values = simgrid::smpi::utils::parse_factor(osend_string);
} else {
osend_parsed_values = simgrid::smpi::utils::parse_factor(config::get_value<std::string>("smpi/os"));
}
check_factor_configs("smpi/ois");
- const char* oisend_string = host->get_property("smpi/ois");
- if (oisend_string != nullptr) {
+ if (const char* oisend_string = host->get_property("smpi/ois")) {
oisend_parsed_values = simgrid::smpi::utils::parse_factor(oisend_string);
} else {
oisend_parsed_values = simgrid::smpi::utils::parse_factor(config::get_value<std::string>("smpi/ois"));
detached_sender_ = nullptr;
real_src_ = 0;
// get src_host if it's available (src is valid)
- auto src_process = simgrid::s4u::Actor::by_pid(src);
- if (src_process)
+ if (auto src_process = simgrid::s4u::Actor::by_pid(src))
src_host_ = src_process->get_host();
truncated_ = false;
unmatched_types_ = false;
default:
THROW_UNIMPLEMENTED;
}
- const auto& factor_cb = disk->get_factor_cb();
- if (factor_cb) { // handling disk variability
+ if (const auto& factor_cb = disk->get_factor_cb()) { // handling disk variability
action->set_rate_factor(factor_cb(size, type));
}
return action;
static void sg_platf_new_cluster_flat(simgrid::kernel::routing::ClusterCreationArgs* cluster)
{
auto* zone = simgrid::s4u::create_star_zone(cluster->id);
- simgrid::s4u::NetZone const* parent = current_routing ? current_routing->get_iface() : nullptr;
- if (parent)
+ if (const auto* parent = current_routing ? current_routing->get_iface() : nullptr)
zone->set_parent(parent);
/* set properties */
"Priority %d is greater than the biggest allowed value", ev->priority);
while (true) {
- const s_xbt_log_appender_t* appender = cat->appender;
-
- if (appender != nullptr) {
+ if (const s_xbt_log_appender_t* appender = cat->appender) {
xbt_assert(cat->layout, "No valid layout for the appender of category %s", cat->name);
/* First, try with a static buffer */