"Filtering netzones is only possible for subclasses of kernel::routing::NetZoneImpl");
for (auto const& elem : current->get_children()) {
get_filtered_netzones_recursive(elem, whereto);
- T* elem_impl = dynamic_cast<T*>(elem->get_impl());
+ auto* elem_impl = dynamic_cast<T*>(elem->get_impl());
if (elem_impl != nullptr)
whereto->push_back(elem_impl);
}
*/
template <class F> xbt_automaton_propositional_symbol_t add_proposition(const_xbt_automaton_t a, const char* id, F f)
{
- F* callback = new F(std::move(f));
+ auto* callback = new F(std::move(f));
return xbt_automaton_propositional_symbol_new_callback(
a, id,
[](void* callback) -> int { return (*(F*)callback)(); },
found = true;
}
if (not found || std::string(val) == "help") {
- std::string mesg = std::string("\n");
+ std::string mesg = "\n";
if (std::string(val) == "help")
mesg += std::string("Possible values for option ") + name + ":\n";
else
const static TaskVtable vtable {
// Call:
[](TaskUnion& buffer, Args... args) {
- F* src = reinterpret_cast<F*>(&buffer);
+ auto* src = reinterpret_cast<F*>(&buffer);
F code = std::move(*src);
src->~F();
// NOTE: std::forward<Args>(args)... is correct.
std::is_trivially_destructible<F>::value ?
static_cast<destroy_function>(nullptr) :
[](TaskUnion& buffer) {
- F* code = reinterpret_cast<F*>(&buffer);
+ auto* code = reinterpret_cast<F*>(&buffer);
code->~F();
},
// Move:
[](TaskUnion& dst, TaskUnion& src) {
- F* src_code = reinterpret_cast<F*>(&src);
- F* dst_code = reinterpret_cast<F*>(&dst);
+ auto* src_code = reinterpret_cast<F*>(&src);
+ auto* dst_code = reinterpret_cast<F*>(&dst);
new(dst_code) F(std::move(*src_code));
src_code->~F();
}
{
luaL_checktype(L, index, LUA_TTABLE);
lua_getfield(L, index, HOST_FIELDNAME);
- sg_host_t *pi = (sg_host_t *) luaL_checkudata(L, lua_gettop(L), HOST_MODULE_NAME);
+ auto* pi = static_cast<sg_host_t*>(luaL_checkudata(L, lua_gettop(L), HOST_MODULE_NAME));
lua_pop(L, 1);
xbt_assert(pi != nullptr, "luaL_checkudata() returned nullptr");
sg_host_t ht = *pi;
lua_ensure(host, "No host name '%s' found.", name);
lua_newtable(L); /* table */
- sg_host_t *lua_host = (sg_host_t *) lua_newuserdata(L, sizeof(sg_host_t)); /* table userdatum */
+ auto* lua_host = static_cast<sg_host_t*>(lua_newuserdata(L, sizeof(sg_host_t))); /* table userdatum */
*lua_host = host;
luaL_getmetatable(L, HOST_MODULE_NAME); /* table userdatum metatable */
lua_setmetatable(L, -2); /* table userdatum */
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 */
- sg_host_t *lua_host = (sg_host_t *) lua_newuserdata(L, sizeof(sg_host_t));
+ auto* lua_host = static_cast<sg_host_t*>(lua_newuserdata(L, sizeof(sg_host_t)));
*lua_host = host;
luaL_getmetatable(L, HOST_MODULE_NAME);
lua_setmetatable(L, -2);
/* Build a Lua representation of the new AS on the stack */
lua_newtable(L);
- simgrid::kernel::routing::NetZoneImpl** lua_as = (simgrid::kernel::routing::NetZoneImpl**)lua_newuserdata(
- L, sizeof(simgrid::kernel::routing::NetZoneImpl*)); /* table userdatum */
+ auto* lua_as = static_cast<simgrid::kernel::routing::NetZoneImpl**>(
+ lua_newuserdata(L, sizeof(simgrid::kernel::routing::NetZoneImpl*))); /* table userdatum */
*lua_as = new_as;
luaL_getmetatable(L, PLATF_MODULE_NAME); /* table userdatum metatable */
lua_setmetatable(L, -2); /* table userdatum */
py::class_<Engine>(m, "Engine", "Simulation Engine")
.def(py::init([](std::vector<std::string> args) {
static char noarg[] = {'\0'};
- int argc = static_cast<int>(args.size());
+ auto argc = static_cast<int>(args.size());
auto argv = std::make_unique<char*[]>(argc + 1);
for (int i = 0; i != argc; ++i)
argv[i] = args[i].empty() ? noarg : &args[i].front();
this->workers[0] = nullptr;
for (unsigned i = 1; i < num_workers; i++) {
- ThreadData* data = new ThreadData(*this, i);
+ auto* data = new ThreadData(*this, i);
this->workers[i] = new std::thread(worker_main, data);
/* Bind the worker to a core if possible */
}
}
- xbt_graph_t graph = xbt_graph_new_graph(0, nullptr);
- std::map<std::string, xbt_node_t>* nodes = new std::map<std::string, xbt_node_t>();
- std::map<std::string, xbt_edge_t>* edges = new std::map<std::string, xbt_edge_t>();
+ auto* graph = xbt_graph_new_graph(0, nullptr);
+ auto* nodes = new std::map<std::string, xbt_node_t>();
+ auto* edges = new std::map<std::string, xbt_edge_t>();
netzone->get_impl()->get_graph(graph, nodes, edges);
for (auto elm : *edges) {
void platform_graph_export_graphviz(const std::string& output_filename)
{
- xbt_graph_t g = xbt_graph_new_graph(0, nullptr);
- std::map<std::string, xbt_node_t>* nodes = new std::map<std::string, xbt_node_t>();
- std::map<std::string, xbt_edge_t>* edges = new std::map<std::string, xbt_edge_t>();
+ auto* g = xbt_graph_new_graph(0, nullptr);
+ auto* nodes = new std::map<std::string, xbt_node_t>();
+ auto* edges = new std::map<std::string, xbt_edge_t>();
s4u::Engine::get_instance()->get_netzone_root()->extract_xbt_graph(g, nodes, edges);
std::ofstream fs;
{
std::string id = netzone.get_name();
if (Container::get_root() == nullptr) {
- NetZoneContainer* root = new NetZoneContainer(id, 0, nullptr);
+ auto* root = new NetZoneContainer(id, 0, nullptr);
xbt_assert(Container::get_root() == root);
if (TRACE_smpi_is_enabled()) {
}
if (TRACE_needs_platform()) {
- unsigned level = static_cast<unsigned>(currentContainer.size());
- NetZoneContainer* container = new NetZoneContainer(id, level, currentContainer.back());
+ auto level = static_cast<unsigned>(currentContainer.size());
+ auto* container = new NetZoneContainer(id, level, currentContainer.back());
currentContainer.push_back(container);
}
}
if (currentContainer.empty()) // No ongoing parsing. Are you creating the loopback?
return;
- Container* container = new Container(link.get_name(), "LINK", currentContainer.back());
+ auto* container = new Container(link.get_name(), "LINK", currentContainer.back());
if ((TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) && (not TRACE_disable_link())) {
VariableType* bandwidth = container->type_->by_name_or_create("bandwidth", "");
static void on_action_state_change(kernel::resource::Action const& action,
kernel::resource::Action::State /* previous */)
{
- unsigned n = static_cast<unsigned>(action.get_variable()->get_number_of_constraint());
+ auto n = static_cast<unsigned>(action.get_variable()->get_number_of_constraint());
for (unsigned i = 0; i < n; i++) {
double value = action.get_variable()->get_value() * action.get_variable()->get_constraint_weight(i);
static void on_platform_created()
{
currentContainer.clear();
- std::set<std::string>* filter = new std::set<std::string>();
+ auto* filter = new std::set<std::string>();
XBT_DEBUG("Starting graph extraction.");
recursiveGraphExtraction(s4u::Engine::get_instance()->get_netzone_root(), Container::get_root(), filter);
XBT_DEBUG("Graph extraction finished.");
this->add_resources(table);
} else {
for (auto const& nz : from_as->get_children()) {
- jed_container_t child_container = new simgrid::jedule::Container(nz->get_name());
+ auto* child_container = new simgrid::jedule::Container(nz->get_name());
this->add_child(child_container);
child_container->create_hierarchy(nz);
}
XBT_DEBUG("send from mailbox %p", mbox);
/* Prepare a synchro describing us, so that it gets passed to the user-provided filter of other side */
- simgrid::kernel::activity::CommImplPtr this_comm =
- simgrid::kernel::activity::CommImplPtr(new simgrid::kernel::activity::CommImpl());
+ simgrid::kernel::activity::CommImplPtr this_comm(new simgrid::kernel::activity::CommImpl());
this_comm->set_type(simgrid::kernel::activity::CommImpl::Type::SEND);
/* Look for communication synchro matching our needs. We also provide a description of
void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t), void* data,
double rate)
{
- simgrid::kernel::activity::CommImplPtr this_synchro =
- simgrid::kernel::activity::CommImplPtr(new simgrid::kernel::activity::CommImpl());
+ simgrid::kernel::activity::CommImplPtr this_synchro(new simgrid::kernel::activity::CommImpl());
this_synchro->set_type(simgrid::kernel::activity::CommImpl::Type::RECEIVE);
XBT_DEBUG("recv from mbox %p. this_synchro=%p", mbox, this_synchro.get());
/* two processes may have pushed the same mbox_create simcall at the same time */
auto m = mailboxes.find(name);
if (m == mailboxes.end()) {
- MailboxImpl* mbox = new MailboxImpl(name);
+ auto* mbox = new MailboxImpl(name);
XBT_DEBUG("Creating a mailbox at %p with name %s", mbox, name.c_str());
mailboxes[name] = mbox;
return mbox;
{
XBT_DEBUG("Wait semaphore %p (timeout:%f)", this, timeout);
if (value_ <= 0) {
- RawImplPtr synchro = RawImplPtr(new RawImpl());
+ RawImplPtr synchro(new RawImpl());
synchro->set_host(issuer->get_host()).set_timeout(timeout).start();
synchro->register_simcall(&issuer->simcall_);
sleeping_.push_back(*issuer);
throw HostFailureException(XBT_THROW_POINT, "Cannot attach actor on failed host.");
}
- ActorImpl* actor = new ActorImpl(xbt::string(name), host);
+ auto* actor = new ActorImpl(xbt::string(name), host);
/* Actor data */
actor->set_user_data(data);
actor->code_ = nullptr;
ActorImplPtr ActorImpl::init(const std::string& name, s4u::Host* host) const
{
- ActorImpl* actor = new ActorImpl(xbt::string(name), host);
+ auto* actor = new ActorImpl(xbt::string(name), host);
actor->set_ppid(this->pid_);
intrusive_ptr_add_ref(actor);
void create_maestro(const std::function<void()>& code)
{
/* Create maestro actor and initialize it */
- ActorImpl* maestro = new ActorImpl(xbt::string(""), /*host*/ nullptr);
+ auto* maestro = new ActorImpl(xbt::string(""), /*host*/ nullptr);
if (not code) {
maestro->context_.reset(simix_global->context_factory->create_context(ActorCode(), maestro));
protected:
template <class T, class... Args> T* new_context(Args&&... args)
{
- T* context = new T(std::forward<Args>(args)...);
+ auto* context = new T(std::forward<Args>(args)...);
context->declare_context(sizeof(T));
return context;
}
void BoostContext::swap_into_for_real(SwappedContext* to_)
{
- BoostContext* to = static_cast<BoostContext*>(to_);
+ auto* to = static_cast<BoostContext*>(to_);
#if BOOST_VERSION < 106100
boost::context::jump_fcontext(&this->fc_, to->fc_, reinterpret_cast<intptr_t>(to));
#else
#if SIMGRID_HAVE_MC
/* Cannot use posix_memalign when SIMGRID_HAVE_MC. Align stack by hand, and save the
* pointer returned by xbt_malloc0. */
- unsigned char* alloc = static_cast<unsigned char*>(xbt_malloc0(size + xbt_pagesize));
+ auto* alloc = static_cast<unsigned char*>(xbt_malloc0(size + xbt_pagesize));
stack_ = alloc - (reinterpret_cast<uintptr_t>(alloc) & (xbt_pagesize - 1)) + xbt_pagesize;
reinterpret_cast<unsigned char**>(stack_)[-1] = alloc;
#elif !defined(_WIN32)
// - So, resume() is only launched from the parmap for the first job of each minion.
parmap_->apply(
[](const actor::ActorImpl* process) {
- SwappedContext* context = static_cast<SwappedContext*>(process->context_.get());
+ auto* context = static_cast<SwappedContext*>(process->context_.get());
context->resume();
},
simix_global->actors_to_run);
*/
void SwappedContext::resume()
{
- SwappedContext* old = static_cast<SwappedContext*>(self());
+ auto* old = static_cast<SwappedContext*>(self());
if (SIMIX_context_is_parallel()) {
// Save my current soul (either maestro, or one of the minions) in a thread-specific area
worker_context_ = old;
void ThreadContext::attach_start()
{
// We're breaking the layers here by depending on the upper layer:
- ThreadContext* maestro = static_cast<ThreadContext*>(simix_global->maestro_->context_.get());
+ auto* maestro = static_cast<ThreadContext*>(simix_global->maestro_->context_.get());
maestro->begin_.release();
xbt_assert(not this->is_maestro());
this->start();
xbt_assert(not this->is_maestro());
this->yield();
- ThreadContext* maestro = static_cast<ThreadContext*>(simix_global->maestro_->context_.get());
+ auto* maestro = static_cast<ThreadContext*>(simix_global->maestro_->context_.get());
maestro->end_.acquire();
Context::set_current(nullptr);
{
for (smx_actor_t const& actor : simix_global->actors_to_run) {
XBT_DEBUG("Handling %p", actor);
- ThreadContext* context = static_cast<ThreadContext*>(actor->context_.get());
+ auto* context = static_cast<ThreadContext*>(actor->context_.get());
context->release();
context->wait();
}
Constraint* System::constraint_new(resource::Resource* id, double bound_value)
{
- Constraint* cnst = new Constraint(id, bound_value);
+ auto* cnst = new Constraint(id, bound_value);
insert_constraint(cnst);
return cnst;
}
XBT_IN("(sys=%p, id=%p, penalty=%f, bound=%f, num_cons =%zu)", this, id, sharing_penalty, bound,
number_of_constraints);
- Variable* var = static_cast<Variable*>(xbt_mallocator_get(variable_mallocator_));
+ auto* var = static_cast<Variable*>(xbt_mallocator_get(variable_mallocator_));
var->initialize(id, sharing_penalty, bound, number_of_constraints, visited_counter_ - 1);
if (sharing_penalty > 0)
variable_set.push_front(*var);
void System::print() const
{
- std::string buf = std::string("MAX-MIN ( ");
+ std::string buf = "MAX-MIN ( ";
/* Printing Objective */
for (Variable const& var : variable_set)
* and get an iterator over the integrated trace */
Event* Profile::schedule(FutureEvtSet* fes, resource::Resource* resource)
{
- Event* event = new Event();
+ auto* event = new Event();
event->profile = this;
event->idx = 0;
event->resource = resource;
Profile* Profile::from_string(const std::string& name, const std::string& input, double periodicity)
{
int linecount = 0;
- simgrid::kernel::profile::Profile* profile = new simgrid::kernel::profile::Profile();
+ auto* profile = new simgrid::kernel::profile::Profile();
simgrid::kernel::profile::DatedValue* last_event = &(profile->event_list.back());
xbt_assert(trace_list.find(name) == trace_list.end(), "Refusing to define trace %s twice", name.c_str());
}
if (not found) {
- RouteCreationArgs* route = new simgrid::kernel::routing::RouteCreationArgs();
+ auto* route = new simgrid::kernel::routing::RouteCreationArgs();
route->link_list.push_back(network_model_->loopback_);
xbt_graph_new_edge(route_graph_.get(), node, node, route);
}
const_xbt_dynar_t nodes = xbt_graph_get_nodes(route_graph_.get());
xbt_dynar_foreach (nodes, cursor, node) {
- GraphNodeData* data = static_cast<GraphNodeData*>(xbt_graph_node_get_data(node));
+ auto* data = static_cast<GraphNodeData*>(xbt_graph_node_get_data(node));
data->graph_id_ = cursor;
}
}
int k = 0;
for (unsigned int i = 0; i < this->levels_; i++) {
for (unsigned int j = 0; j < this->nodes_by_level_[i + 1]; j++) {
- FatTreeNode* newNode = new FatTreeNode(this->cluster_, --k, i + 1, j);
+ auto* newNode = new FatTreeNode(this->cluster_, --k, i + 1, j);
XBT_DEBUG("We create the switch %d(%u,%u)", newNode->id, newNode->level, newNode->position);
newNode->children.resize(this->num_children_per_node_[i] * this->num_port_lower_level_[i]);
if (i != this->levels_ - 1) {
s4u::Host* NetZoneImpl::create_host(const std::string& name, const std::vector<double>& speed_per_pstate,
int coreAmount, const std::map<std::string, std::string>* props)
{
- s4u::Host* res = new s4u::Host(name);
+ auto* res = new s4u::Host(name);
if (hierarchy_ == RoutingMode::unset)
hierarchy_ = RoutingMode::base;
}
/* Build a copy that will be stored in the dict */
- BypassRoute* newRoute = new BypassRoute(gw_src, gw_dst);
+ auto* newRoute = new BypassRoute(gw_src, gw_dst);
for (auto const& link : link_list)
newRoute->links.push_back(link);
xbt_edge_t new_xbt_graph_edge(const s_xbt_graph_t* graph, xbt_node_t s, xbt_node_t d,
std::map<std::string, xbt_edge_t>* edges)
{
- const char* sn = static_cast<const char*>(xbt_graph_node_get_data(s));
- const char* dn = static_cast<const char*>(xbt_graph_node_get_data(d));
+ const auto* sn = static_cast<const char*>(xbt_graph_node_get_data(s));
+ const auto* dn = static_cast<const char*>(xbt_graph_node_get_data(d));
std::string name = std::string(sn) + dn;
auto elm = edges->find(name);
if (my_src == my_dst)
continue;
- RouteCreationArgs* route = new RouteCreationArgs();
+ auto* route = new RouteCreationArgs();
get_local_route(my_src, my_dst, route, nullptr);
std::vector<resource::LinkImpl*>& link_list, bool /* symmetrical */,
bool change_order)
{
- RouteCreationArgs* result = new RouteCreationArgs();
+ auto* result = new RouteCreationArgs();
xbt_assert(hierarchy == RoutingMode::base || hierarchy == RoutingMode::recursive,
"The hierarchy of this netzone is neither BASIC nor RECURSIVE, I'm lost here.");
* both arrays, we can easily assess whether we need to route into this dimension or not.
*/
const unsigned int dsize = dimensions_.size();
- unsigned int* myCoords = new unsigned int[dsize];
- unsigned int* targetCoords= new unsigned int[dsize];
+ auto* myCoords = new unsigned int[dsize];
+ auto* targetCoords = new unsigned int[dsize];
unsigned int dim_size_product = 1;
for (unsigned i = 0; i < dsize; i++) {
unsigned cur_dim_size = dimensions_[i];
}
/* Create file on remote host, write it and close it */
- File* fd = new File(fullpath, dst_host, nullptr);
+ auto* fd = new File(fullpath, dst_host, nullptr);
if (local_storage_) {
sg_size_t write_size = fd->local_storage_->write(read_size);
fd->local_storage_->extension<FileSystemStorageExt>()->incr_used_size(write_size);
if (filename.empty())
return nullptr;
- std::map<std::string, sg_size_t>* parse_content = new std::map<std::string, sg_size_t>();
+ auto* parse_content = new std::map<std::string, sg_size_t>();
std::ifstream* fs = surf_ifsopen(filename);
xbt_assert(not fs->fail(), "Cannot open file '%s' (path=%s)", filename.c_str(),
if (filename.empty())
return nullptr;
- std::map<std::string, sg_size_t>* parse_content = new std::map<std::string, sg_size_t>();
+ auto* parse_content = new std::map<std::string, sg_size_t>();
std::ifstream* fs = surf_ifsopen(filename);
xbt_assert(not fs->fail(), "Cannot open file '%s' (path=%s)", filename.c_str(),
xbt_dict_t content_as_dict = xbt_dict_new_homogeneous(::operator delete);
for (auto const& entry : *content) {
- sg_size_t* psize = new sg_size_t;
- *psize = entry.second;
+ auto* psize = new sg_size_t(entry.second);
xbt_dict_set(content_as_dict, entry.first.c_str(), psize);
}
return content_as_dict;
host_->get_pstate_count());
// XBT_ATTRIB_DEPRECATED_v328: putting this macro name here so that we find it during the deprecation cleanups
- std::string msg = std::string("DEPRECATION WARNING: Property 'watt_per_state' will only work until v3.28.\n");
+ std::string msg = "DEPRECATION WARNING: Property 'watt_per_state' will only work until v3.28.\n";
msg += std::string("The old syntax 'Idle:OneCore:AllCores' must be converted into 'Idle:Epsilon:AllCores' to "
"properly model the consumption of non-whole tasks on mono-core hosts. Here are the values to "
"use for host '") +
instr::Container::get_root()->get_link("VM_LINK")->end_event(msg, "M", key);
}
// Inform the SRC that the migration has been correctly performed
- std::string* payload = new std::string("__mig_stage4:");
- *payload = *payload + vm_->get_cname() + "(" + src_pm_->get_cname() + "-" + dst_pm_->get_cname() + ")";
+ auto* payload = new std::string("__mig_stage4:");
+ *payload = *payload + vm_->get_cname() + "(" + src_pm_->get_cname() + "-" + dst_pm_->get_cname() + ")";
mbox_ctl->put(payload, 0);
static sg_size_t get_updated_size(double computed, double dp_rate, sg_size_t dp_cap)
{
- sg_size_t updated_size = static_cast<sg_size_t>(computed * dp_rate);
+ auto updated_size = static_cast<sg_size_t>(computed * dp_rate);
XBT_DEBUG("updated_size %llu dp_rate %f", updated_size, dp_rate);
if (updated_size > dp_cap) {
updated_size = dp_cap;
sg_size_t MigrationTx::sendMigrationData(sg_size_t size, int stage, int stage2_round, double mig_speed, double timeout)
{
sg_size_t sent = size;
- std::string* msg = new std::string("__mig_stage");
+ auto* msg = new std::string("__mig_stage");
*msg = *msg + std::to_string(stage) + ":" + vm_->get_cname() + "(" + src_pm_->get_cname() + "-" +
dst_pm_->get_cname() + ")";
try {
comm->wait_for(timeout);
} catch (const Exception&) {
- sg_size_t remaining = static_cast<sg_size_t>(comm->get_remaining());
+ auto remaining = static_cast<sg_size_t>(comm->get_remaining());
XBT_VERB("timeout (%lf s) in sending_migration_data, remaining %llu bytes of %llu", timeout, remaining, size);
sent -= remaining;
delete msg;
/* For the moment, intensity_rate is the percentage against the migration bandwidth */
- sg_vm_t vm = new simgrid::s4u::VirtualMachine(name, pm, coreAmount, static_cast<sg_size_t>(ramsize) * 1024 * 1024);
+ auto* vm = new simgrid::s4u::VirtualMachine(name, pm, coreAmount, static_cast<sg_size_t>(ramsize) * 1024 * 1024);
sg_vm_set_dirty_page_intensity(vm, dp_intensity / 100.0);
sg_vm_set_working_set_memory(vm, vm->get_ramsize() * 0.9); // assume working set memory is 90% of ramsize
sg_vm_set_migration_speed(vm, mig_netspeed * 1024 * 1024.0);
xbt_assert(autorestart && not pimpl_->has_to_auto_restart()); // FIXME: handle all cases
pimpl_->set_auto_restart(autorestart);
- kernel::actor::ProcessArg* arg = new kernel::actor::ProcessArg(pimpl_->get_host(), pimpl_);
+ auto* arg = new kernel::actor::ProcessArg(pimpl_->get_host(), pimpl_);
XBT_DEBUG("Adding %s to the actors_at_boot_ list of Host %s", arg->name.c_str(), arg->host->get_cname());
pimpl_->get_host()->pimpl_->add_actor_at_boot(arg);
});
ExecPtr exec_init(double flops_amount)
{
- ExecPtr exec = ExecPtr(new Exec());
+ ExecPtr exec(new Exec());
exec->set_flops_amount(flops_amount)->set_host(get_host());
return exec;
}
xbt_assert(std::all_of(bytes_amounts.begin(), bytes_amounts.end(), [](double elm) { return std::isfinite(elm); }),
"flops_amounts comprises infinite values!");
- ExecPtr exec = ExecPtr(new Exec());
+ ExecPtr exec(new Exec());
exec->set_flops_amounts(flops_amounts)->set_bytes_amounts(bytes_amounts)->set_hosts(hosts);
return exec;
}
if (bytes_amount != nullptr)
bytes = std::vector<double>(bytes_amount, bytes_amount + host_nb * host_nb);
- simgrid::s4u::ExecPtr exec = simgrid::s4u::ExecPtr(new simgrid::s4u::Exec());
+ simgrid::s4u::ExecPtr exec(new simgrid::s4u::Exec());
exec->set_flops_amounts(flops)->set_bytes_amounts(bytes)->set_hosts(hosts);
exec->add_ref();
return exec.get();
CommPtr Mailbox::put_init()
{
- CommPtr res = CommPtr(new Comm());
+ CommPtr res(new Comm());
res->sender_ = kernel::actor::ActorImpl::self();
res->mailbox_ = this;
return res;
CommPtr Mailbox::get_init()
{
- CommPtr res = CommPtr(new Comm());
+ CommPtr res(new Comm());
res->receiver_ = kernel::actor::ActorImpl::self();
res->mailbox_ = this;
return res;
for (auto const& model : all_existing_models) {
const simgrid::kernel::resource::Action* action = model->extract_done_action();
while (action != nullptr && action->get_data() != nullptr) {
- SD_task_t task = static_cast<SD_task_t>(action->get_data());
+ auto* task = static_cast<SD_task_t>(action->get_data());
XBT_VERB("Task '%s' done", SD_task_get_name(task));
SD_task_set_state(task, SD_DONE);
/* let's see which tasks have just failed */
action = model->extract_failed_action();
while (action != nullptr) {
- SD_task_t task = static_cast<SD_task_t>(action->get_data());
+ auto* task = static_cast<SD_task_t>(action->get_data());
XBT_VERB("Task '%s' failed", SD_task_get_name(task));
SD_task_set_state(task, SD_FAILED);
sd_global->return_set.insert(task);
/** @brief Dumps the task in dotty formalism into the FILE* passed as second argument */
void SD_task_dotty(const_SD_task_t task, void* out)
{
- FILE *fout = static_cast<FILE*>(out);
+ auto* fout = static_cast<FILE*>(out);
fprintf(fout, " T%p [label=\"%.20s\"", task, task->name);
switch (task->kind) {
case SD_TASK_COMM_E2E:
void SD_task_schedulel(SD_task_t task, int count, ...)
{
va_list ap;
- sg_host_t* list = new sg_host_t[count];
+ auto* list = new sg_host_t[count];
va_start(ap, count);
for (int i=0; i<count; i++)
list[i] = va_arg(ap, sg_host_t);
Timer* Timer::set(double date, xbt::Task<void()>&& callback)
{
- Timer* timer = new Timer(date, std::move(callback));
+ auto* timer = new Timer(date, std::move(callback));
timer->handle_ = simix_timers.emplace(std::make_pair(date, timer));
return timer;
}
{
/* All actors should be gone when the host is turned off (by the end of the simulation). */
if (not actor_list_.empty()) {
- std::string msg = std::string("Shutting down host, but it's not empty:");
+ std::string msg = "Shutting down host, but it's not empty:";
for (auto const& actor : actor_list_)
msg += "\n\t" + std::string(actor.get_name());
}
std::unordered_map<std::string, s4u::Storage*>* HostImpl::get_mounted_storages()
{
- std::unordered_map<std::string, s4u::Storage*>* mounts = new std::unordered_map<std::string, s4u::Storage*>();
+ auto* mounts = new std::unordered_map<std::string, s4u::Storage*>();
for (auto const& m : storage_) {
mounts->insert({m.first, m.second->get_iface()});
}
/* Beware of composite actions: ptasks put links and cpus together */
// extra pb: we cannot dynamic_cast from void*...
Resource* resource = get_variable()->get_constraint(i)->get_id();
- Cpu* cpu = dynamic_cast<Cpu*>(resource);
+ auto* cpu = dynamic_cast<Cpu*>(resource);
if (cpu != nullptr)
retlist.push_back(cpu);
}
void NetworkCm02Model::update_actions_state_full(double /*now*/, double delta)
{
for (auto it = std::begin(*get_started_action_set()); it != std::end(*get_started_action_set());) {
- NetworkCm02Action& action = static_cast<NetworkCm02Action&>(*it);
+ auto& action = static_cast<NetworkCm02Action&>(*it);
++it; // increment iterator here since the following calls to action.finish() may invalidate it
XBT_DEBUG("Something happened to action %p", &action);
double deltap = delta;
static void IB_action_init_callback(simgrid::kernel::resource::NetworkAction& action)
{
- simgrid::kernel::resource::NetworkIBModel* ibModel = (simgrid::kernel::resource::NetworkIBModel*)surf_network_model;
- simgrid::kernel::resource::IBNode* act_src = &ibModel->active_nodes.at(action.get_src().get_name());
- simgrid::kernel::resource::IBNode* act_dst = &ibModel->active_nodes.at(action.get_dst().get_name());
+ auto* ibModel = static_cast<simgrid::kernel::resource::NetworkIBModel*>(surf_network_model);
+ auto* act_src = &ibModel->active_nodes.at(action.get_src().get_name());
+ auto* act_dst = &ibModel->active_nodes.at(action.get_dst().get_name());
ibModel->active_comms[&action] = std::make_pair(act_src, act_dst);
ibModel->updateIBfactors(&action, act_src, act_dst, 0);
action->unref();
} else {
action->ref();
- ActiveComm* comm = new ActiveComm();
+ auto* comm = new ActiveComm();
comm->action = action;
comm->destination = to;
from->ActiveCommsUp.push_back(comm);
double minRes = Model::next_occurring_event_full(now);
for (Action const& action : *get_started_action_set()) {
- const NetworkAction& net_action = static_cast<const NetworkAction&>(action);
+ const auto& net_action = static_cast<const NetworkAction&>(action);
if (net_action.latency_ > 0)
minRes = (minRes < 0) ? net_action.latency_ : std::min(minRes, net_action.latency_);
}
/* Beware of composite actions: ptasks put links and cpus together */
// extra pb: we cannot dynamic_cast from void*...
Resource* resource = get_variable()->get_constraint(i)->get_id();
- LinkImpl* link = dynamic_cast<LinkImpl*>(resource);
+ auto* link = dynamic_cast<LinkImpl*>(resource);
if (link != nullptr)
retlist.push_back(link);
}
void NetworkWifiLink::refresh_decay_bandwidths(){
// Compute number of STAtion on the Access Point
- int nSTA = static_cast<int>(host_rates_.size());
+ size_t nSTA = host_rates_.size();
std::vector<Metric> new_bandwidths;
for (auto bandwidth : bandwidths_){
{
double min = HostModel::next_occurring_event_full(now);
for (kernel::resource::Action const& action : *get_started_action_set()) {
- const L07Action& net_action = static_cast<const L07Action&>(action);
+ const auto& net_action = static_cast<const L07Action&>(action);
if (net_action.get_latency() > 0 && (min < 0 || net_action.get_latency() < min)) {
min = net_action.get_latency();
XBT_DEBUG("Updating min with %p (start %f): %f", &net_action, net_action.get_start_time(), min);
void HostL07Model::update_actions_state(double /*now*/, double delta)
{
for (auto it = std::begin(*get_started_action_set()); it != std::end(*get_started_action_set());) {
- L07Action& action = static_cast<L07Action&>(*it);
+ auto& action = static_cast<L07Action&>(*it);
++it; // increment iterator here since the following calls to action.finish() may invalidate it
if (action.get_latency() > 0) {
if (action.get_latency() > delta) {
kernel::resource::Action* NetworkL07Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate)
{
std::vector<s4u::Host*> host_list = {src, dst};
- const double* flops_amount = new double[2]();
- double* bytes_amount = new double[4]();
+ const auto* flops_amount = new double[2]();
+ auto* bytes_amount = new double[4]();
bytes_amount[1] = size;
{
std::vector<s4u::Host*> host_list = {get_host()};
- double* flops_amount = new double[host_list.size()]();
+ auto* flops_amount = new double[host_list.size()]();
flops_amount[0] = size;
kernel::resource::CpuAction* res =
kernel::resource::CpuAction* CpuL07::sleep(double duration)
{
- L07Action *action = static_cast<L07Action*>(execution_start(1.0));
+ auto* action = static_cast<L07Action*>(execution_start(1.0));
action->set_max_duration(duration);
action->set_suspend_state(kernel::resource::Action::SuspendStates::SLEEPING);
get_model()->get_maxmin_system()->update_variable_penalty(action->get_variable(), 0.0);
xbt_assert(nullptr == simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(name),
"Refusing to create a router named '%s': this name already describes a node.", name.c_str());
- simgrid::kernel::routing::NetPoint* netpoint =
+ auto* netpoint =
new simgrid::kernel::routing::NetPoint(name, simgrid::kernel::routing::NetPoint::Type::Router, current_routing);
XBT_DEBUG("Router '%s' has the id %u", netpoint->get_cname(), netpoint->id());
break;
}
sg_platf_new_Zone_begin(&zone);
- simgrid::kernel::routing::ClusterZone* current_as = static_cast<ClusterZone*>(routing_get_current());
+ auto* current_as = static_cast<ClusterZone*>(routing_get_current());
current_as->parse_specific_arguments(cluster);
if (cluster->properties != nullptr)
for (auto const& elm : *cluster->properties)
void routing_cluster_add_backbone(simgrid::kernel::resource::LinkImpl* bb)
{
- simgrid::kernel::routing::ClusterZone* cluster =
- dynamic_cast<simgrid::kernel::routing::ClusterZone*>(current_routing);
+ auto* cluster = dynamic_cast<simgrid::kernel::routing::ClusterZone*>(current_routing);
xbt_assert(cluster, "Only hosts from Cluster can get a backbone.");
xbt_assert(nullptr == cluster->backbone_, "Cluster %s already has a backbone link!", cluster->get_cname());
xbt_assert(storage_types.find(storage_type->id) == storage_types.end(),
"Reading a storage type, processing unit \"%s\" already exists", storage_type->id.c_str());
- simgrid::kernel::resource::StorageType* stype = new simgrid::kernel::resource::StorageType(
- storage_type->id, storage_type->model, storage_type->content, storage_type->properties,
- storage_type->model_properties, storage_type->size);
+ auto* stype = new simgrid::kernel::resource::StorageType(storage_type->id, storage_type->model, storage_type->content,
+ storage_type->properties, storage_type->model_properties,
+ storage_type->size);
XBT_DEBUG("Create a storage type id '%s' with model '%s', content '%s'", storage_type->id.c_str(),
storage_type->model.c_str(), storage_type->content.c_str());
simgrid::kernel::actor::ActorCode code = factory(std::move(actor->args));
std::shared_ptr<std::unordered_map<std::string, std::string>> properties(actor->properties);
- simgrid::kernel::actor::ProcessArg* arg =
+ auto* arg =
new simgrid::kernel::actor::ProcessArg(actor_name, code, nullptr, host, kill_time, properties, auto_restart);
host->pimpl_->add_actor_at_boot(arg);
void sg_platf_new_peer(const simgrid::kernel::routing::PeerCreationArgs* peer)
{
- simgrid::kernel::routing::VivaldiZone* as = dynamic_cast<simgrid::kernel::routing::VivaldiZone*>(current_routing);
+ auto* as = dynamic_cast<simgrid::kernel::routing::VivaldiZone*>(current_routing);
xbt_assert(as, "<peer> tag can only be used in Vivaldi netzones.");
std::vector<double> speed_per_pstate;
{
xbt_assert(not name.empty());
- std::ifstream* fs = new std::ifstream();
+ auto* fs = new std::ifstream();
if (is_absolute_file_path(name)) { /* don't mess with absolute file names */
fs->open(name.c_str(), std::ifstream::in);
}
/* Turn something like "1-4,6,9-11" into the vector {1,2,3,4,6,9,10,11} */
static std::vector<int>* explodesRadical(const std::string& radicals)
{
- std::vector<int>* exploded = new std::vector<int>();
+ auto* exploded = new std::vector<int>();
// Make all hosts
std::vector<std::string> radical_elements;
{
xbt_assert(options.find(name) == options.end(), "Refusing to register the config element '%s' twice.",
name.c_str());
- TypedConfigurationElement<T>* variable = new TypedConfigurationElement<T>(name, std::forward<A>(a)...);
+ auto* variable = new TypedConfigurationElement<T>(name, std::forward<A>(a)...);
XBT_DEBUG("Register cfg elm %s (%s) of type %s @%p in set %p)", name.c_str(), variable->get_description().c_str(),
variable->get_type_name(), variable, this);
options[name].reset(variable);
const unsigned oldsize = dict->table_size + 1;
unsigned newsize = oldsize * 2;
- xbt_dictelm_t* newtable = (xbt_dictelm_t*)xbt_realloc((char*)dict->table, newsize * sizeof(xbt_dictelm_t));
+ auto* newtable = static_cast<xbt_dictelm_t*>(xbt_realloc((char*)dict->table, newsize * sizeof(xbt_dictelm_t)));
memset(&newtable[oldsize], 0, oldsize * sizeof(xbt_dictelm_t)); /* zero second half */
newsize--;
dict->table_size = newsize;
static void search_ext(const_xbt_dict_t head, const char* key, const char* data)
{
INFO("Search " << STR(key));
- char* found = (char*)xbt_dict_get_or_null(head, key);
+ auto* found = static_cast<char*>(xbt_dict_get_or_null(head, key));
INFO("Found " << STR(found));
if (data) {
REQUIRE(found); // data do not match expectations: found null while searching for data
xbt_dict_t head = xbt_dict_new_homogeneous(free);
for (int j = 0; j < 1000; j++) {
const char* data = nullptr;
- char* key = (char*)xbt_malloc(SIZEOFKEY);
+ auto* key = static_cast<char*>(xbt_malloc(SIZEOFKEY));
do {
for (int k = 0; k < SIZEOFKEY - 1; k++) {
xbt_dict_t head = xbt_dict_new_homogeneous(&free);
INFO("Fill " << NB_ELM << " elements, with keys being the number of element");
for (int j = 0; j < NB_ELM; j++) {
- char* key = (char*)xbt_malloc(10);
+ auto* key = static_cast<char*>(xbt_malloc(10));
snprintf(key, 10, "%d", j);
xbt_dict_set(head, key, key);
INFO("There is " << countelems(head) << " elements");
INFO("Search my " << NB_ELM << " elements 20 times");
- char* key = (char*)xbt_malloc(10);
+ auto* key = static_cast<char*>(xbt_malloc(10));
for (int i = 0; i < 20; i++) {
for (int j = 0; j < NB_ELM; j++) {
snprintf(key, 10, "%d", j);
static inline void* _xbt_dynar_elm(const_xbt_dynar_t dynar, unsigned long idx)
{
- char *const data = (char *) dynar->data;
+ auto* const data = static_cast<char*>(dynar->data);
const unsigned long elmsize = dynar->elmsize;
return data + idx * elmsize;
*/
void xbt_dynar_map(const_xbt_dynar_t dynar, void_f_pvoid_t op)
{
- char *const data = (char *) dynar->data;
+ auto* const data = static_cast<char*>(dynar->data);
const unsigned long elmsize = dynar->elmsize;
const unsigned long used = dynar->used;
static void append2_file(const s_xbt_log_appender_t* this_, const char* str)
{
- xbt_log_append2_file_t d = (xbt_log_append2_file_t)this_->data;
+ auto* d = static_cast<xbt_log_append2_file_t>(this_->data);
xbt_assert(d->file);
if (ftell(d->file) >= d->limit) {
open_append2_file(d);
static void free_append2_(const s_xbt_log_appender_t* this_)
{
- xbt_log_append2_file_t data = static_cast<xbt_log_append2_file_t>(this_->data);
+ auto* data = static_cast<xbt_log_append2_file_t>(this_->data);
if (data->file)
fclose(data->file);
xbt_free(data->filename);
int precision = -1;
int length = -1;
- char* q = static_cast<char*>(l->data);
+ auto* q = static_cast<char*>(l->data);
while (*q != '\0') {
if (*q == '%') {
q++;
template <typename F, typename T> void test_parse_ok(F function, const std::string& name, const char* str, T value)
{
INFO(name);
- T variable = static_cast<T>(-9999);
+ auto variable = static_cast<T>(-9999);
REQUIRE_NOTHROW(variable = function(str, "Parse error"));
REQUIRE(variable == value); /* Fail to parse str */
}