This avoids unnecessary copies and saves a few milliseconds.
std::vector<simgrid::s4u::Host*> list;
simgrid::s4u::Engine::getInstance()->getHostList(&list);
- for (auto host : list)
+ for (auto const& host : list)
host->extension_set(new HostBittorrent(host));
e->registerFunction<Tracker>("tracker");
Peer::~Peer()
{
- for (auto peer : connected_peers)
+ for (auto const& peer : connected_peers)
delete peer.second;
delete[] pieces_count;
}
try {
TrackerAnswer* answer = static_cast<TrackerAnswer*>(mailbox_->get(GET_PEERS_TIMEOUT));
// Add the peers the tracker gave us to our peer list.
- for (auto peer_id : *answer->getPeers())
+ for (auto const& peer_id : *answer->getPeers())
if (id != peer_id)
connected_peers[peer_id] = new Connection(peer_id);
delete answer;
void Peer::sendHandshakeToAllPeers()
{
- for (auto kv : connected_peers) {
+ for (auto const& kv : connected_peers) {
Connection* remote_peer = kv.second;
Message* handshake = new Message(MESSAGE_HANDSHAKE, id, mailbox_);
remote_peer->mailbox_->put_init(handshake, MESSAGE_HANDSHAKE_SIZE)->detach();
void Peer::sendHaveToAllPeers(unsigned int piece)
{
XBT_DEBUG("Sending HAVE message to all my peers");
- for (auto kv : connected_peers) {
+ for (auto const& kv : connected_peers) {
Connection* remote_peer = kv.second;
remote_peer->mailbox_->put_init(new Message(MESSAGE_HAVE, id, mailbox_, piece), MESSAGE_HAVE_SIZE)->detach();
}
int Peer::nbInterestedPeers()
{
int nb = 0;
- for (auto kv : connected_peers)
+ for (auto const& kv : connected_peers)
if (kv.second->interested)
nb++;
return nb;
if (hasFinished()) {
Connection* remote_peer;
double unchoke_time = simgrid::s4u::Engine::getClock() + 1;
- for (auto kv : connected_peers) {
+ for (auto const& kv : connected_peers) {
remote_peer = kv.second;
if (remote_peer->last_unchoke < unchoke_time && remote_peer->interested && remote_peer->choked_upload) {
unchoke_time = remote_peer->last_unchoke;
} else {
// Use the "fastest download" policy.
double fastest_speed = 0.0;
- for (auto kv : connected_peers) {
+ for (auto const& kv : connected_peers) {
Connection* remote_peer = kv.second;
if (remote_peer->peer_speed > fastest_speed && remote_peer->choked_upload && remote_peer->interested) {
chosen_peer = remote_peer;
/** @brief Update "interested" state of peers: send "not interested" to peers that don't have any more pieces we want.*/
void Peer::updateInterestedAfterReceive()
{
- for (auto kv : connected_peers) {
+ for (auto const& kv : connected_peers) {
Connection* remote_peer = kv.second;
if (remote_peer->am_interested) {
bool interested = false;
int id = 0;
std::vector<simgrid::s4u::Host*> list;
e->getHostList(&list);
- for (auto host : list) {
+ for (auto const& host : list) {
/* - Give a unique rank to each host and create a @ref relay_runner process on each */
simgrid::s4u::Actor::createActor((std::to_string(id)).c_str(), host, RelayRunner());
id++;
std::vector<simgrid::s4u::Host*> list;
simgrid::s4u::Engine::getInstance()->getHostList(&list);
- for (auto host : list)
+ for (auto const& host : list)
host->extension_set(new HostChord(host));
}
double latency = 0;
h1->routeTo(h2, &route, &latency);
- for (auto link : route)
+ for (auto const& link : route)
XBT_INFO(" Link %s: latency = %f, bandwidth = %f", sg_link_name(link), sg_link_latency(link),
sg_link_bandwidth(link));
SD_task_schedule(taskD, 2, host_list, computation_amount, communication_amount, -1);
std::set<SD_task_t> *changed_tasks = simgrid::sd::simulate(-1.0);
- for (auto task: *changed_tasks){
+ for (auto const& task : *changed_tasks) {
XBT_INFO("Task '%s' start time: %f, finish time: %f", SD_task_get_name(task),
SD_task_get_start_time(task), SD_task_get_finish_time(task));
}
xbt_dynar_t comms = xbt_dynar_new(sizeof(simgrid::kernel::activity::ActivityImpl*), [](void*ptr){
intrusive_ptr_release(*(simgrid::kernel::activity::ActivityImpl**)ptr);
});
- for (auto comm : *comms_in) {
+ for (auto const& comm : *comms_in) {
if (comm->state_ == inited)
comm->start();
xbt_assert(comm->state_ == started);
-/* Copyright (c) 2014-2015. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2014-2017. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
}
R operator()(P... args) const
{
- for (auto& handler : handlers_)
+ for (auto const& handler : handlers_)
handler(args...);
}
void disconnect_all_slots()
void JavaContextFactory::run_all()
{
- for (smx_actor_t process : simgrid::simix::process_get_runnable()) {
+ for (smx_actor_t const& process : simgrid::simix::process_get_runnable()) {
static_cast<JavaContext*>(process->context)->resume();
}
}
xbt_dynar_free(&hosts);
/* Cleanup java storages */
- for (auto elm : java_storage_map)
+ for (auto const& elm : java_storage_map)
jstorage_unref(env, elm.second);
}
return nullptr;
}
- for (auto tmp_as : *self_as->getChildren()) {
+ for (auto const& tmp_as : *self_as->getChildren()) {
jobject tmp_jas = jnetzone_new_instance(env);
if (not tmp_jas) {
jxbt_throw_jni(env, "java As instantiation failed");
}
int index = 0;
- for (auto host : table) {
+ for (auto const& host : table) {
jhost = static_cast<jobject>(host->extension(JAVA_HOST_LEVEL));
if (not jhost) {
jname = env->NewStringUTF(host->getCname());
return nullptr;
}
- for (auto elm : mounted_storages) {
+ for (auto const& elm : mounted_storages) {
jname = env->NewStringUTF(elm.second->getName());
jstorage = Java_org_simgrid_msg_Storage_getByName(env,cls,jname);
env->SetObjectArrayElement(jtable, index, jstorage);
route.link_list->push_back(simgrid::surf::LinkImpl::byName(lua_tostring(L, -1)));
} else {
// Several names separated by , \t\r\n
- for (auto name : names) {
+ for (auto const& name : names) {
if (name.length() > 0) {
simgrid::surf::LinkImpl* link = simgrid::surf::LinkImpl::byName(name);
route.link_list->push_back(link);
ASroute.link_list->push_back(simgrid::surf::LinkImpl::byName(lua_tostring(L, -1)));
} else {
// Several names separated by , \t\r\n
- for (auto name : names) {
+ for (auto const& name : names) {
if (name.length() > 0) {
simgrid::surf::LinkImpl* link = simgrid::surf::LinkImpl::byName(name);
ASroute.link_list->push_back(link);
{
unsigned int i = created_categories.size();
fprintf (file, " values = (");
- for (auto cat : created_categories) {
+ for (auto const& cat : created_categories) {
--i;
fprintf(file, "\"%s%s\"", name, cat.c_str());
if (i > 0) {
return nullptr;
xbt_dynar_t ret = xbt_dynar_new (sizeof(char*), &xbt_free_ref);
- for (auto name : *filter)
+ for (auto const& name : *filter)
xbt_dynar_push_as(ret, char*, xbt_strdup(name.c_str()));
return ret;
std::vector<simgrid::surf::LinkImpl*> route;
simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(src_elm, dst_elm, &route, nullptr);
- for (auto link : route)
+ for (auto const& link : route)
instr_user_variable(time, link->cname(), variable, father_type, value, what, nullptr, &user_link_variables);
}
return;
XBT_DEBUG("%s: dump until %f. starts", __FUNCTION__, TRACE_last_timestamp_to_dump);
if (force){
- for (auto event : buffer){
+ for (auto const& event : buffer) {
event->print();
delete event;
}
buffer.clear();
}else{
std::vector<PajeEvent*>::iterator i = buffer.begin();
- for (auto event :buffer){
+ for (auto const& event : buffer) {
double head_timestamp = event->timestamp;
if (head_timestamp > TRACE_last_timestamp_to_dump)
break;
void buffer_debug(std::vector<PajeEvent*> *buf) {
return;
XBT_DEBUG(">>>>>> Dump the state of the buffer. %zu events", buf->size());
- for (auto event :*buf){
+ for (auto const& event : *buf) {
event->print();
XBT_DEBUG("%p %s", event, stream.str().c_str());
stream.str("");
Jedule::~Jedule() {
delete this->root_container;
- for (auto evt: this->event_set)
+ for (auto const& evt : this->event_set)
delete evt;
this->event_set.clear();
}
if (not this->meta_info.empty()) {
fprintf(file, " <jedule_meta>\n");
- for (auto elm: this->meta_info)
+ for (auto const& elm : this->meta_info)
fprintf(file, " <prop key=\"%s\" value=\"%s\" />\n",elm.first,elm.second);
fprintf(file, " </jedule_meta>\n");
}
fprintf(file, " </platform>\n");
fprintf(file, " <events>\n");
- for (auto event :this->event_set)
+ for (auto const& event : this->event_set)
event->print(file);
fprintf(file, " </events>\n");
Event::~Event()
{
if (not this->resource_subsets->empty()) {
- for (auto subset: *this->resource_subsets)
+ for (auto const& subset : *this->resource_subsets)
delete subset;
delete this->resource_subsets;
}
xbt_assert(not this->resource_subsets->empty());
fprintf(jed_file, " <res_util>\n");
- for (auto subset: *this->resource_subsets) {
+ for (auto const& subset : *this->resource_subsets) {
fprintf(jed_file, " <select resources=\"");
fprintf(jed_file, "%s", subset->parent->getHierarchyAsString().c_str());
fprintf(jed_file, ".[%d-%d]", subset->start_idx, subset->start_idx + subset->nres-1);
if (not this->characteristics_list.empty()) {
fprintf(jed_file, " <characteristics>\n");
- for (auto ch: this->characteristics_list)
+ for (auto const& ch : this->characteristics_list)
fprintf(jed_file, " <characteristic name=\"%s\" />\n", ch);
fprintf(jed_file, " </characteristics>\n");
}
if (not this->info_map.empty()) {
fprintf(jed_file, " <info>\n");
- for (auto elm: this->info_map)
+ for (auto const& elm : this->info_map)
fprintf(jed_file, " <prop key=\"%s\" value=\"%s\" />\n",elm.first,elm.second);
fprintf(jed_file, " </info>\n");
}
Container::~Container()
{
if (not this->children.empty())
- for (auto child: this->children)
+ for (auto const& child : this->children)
delete child;
}
//FIXME do we need to sort?: xbt_dynar_sort_strings(host_names);
- for (auto host : hosts) {
+ for (auto const& host : hosts) {
const char *host_name = sg_host_get_name(host);
this->name2id.insert({host_name, this->last_id});
(this->last_id)++;
from_as->getHosts(&table);
this->addResources(table);
} else {
- for (auto nz : *from_as->getChildren()) {
+ for (auto const& nz : *from_as->getChildren()) {
jed_container_t child_container = new simgrid::jedule::Container(std::string(nz->getCname()));
this->addChild(child_container);
child_container->createHierarchy(nz);
unsigned int i =0;
int child_nb = -1;
- for (auto child : this->parent->children) {
+ for (auto const& child : this->parent->children) {
if( child == this) {
child_nb = i;
break;
unsigned int length = heir_list.size();
unsigned int i = 0;
- for (auto id : heir_list) {
+ for (auto const& id : heir_list) {
output += std::to_string(id);
if( i != length-1 ) {
output += ".";
std::string resid = this->getHierarchyAsString();
fprintf(jed_file, " <rset id=\"%s\" nb=\"%u\" names=\"", resid.c_str(), res_nb);
- for (auto res: this->resource_list) {
+ for (auto const& res : this->resource_list) {
const char * res_name = sg_host_get_name(res);
fprintf(jed_file, "%s", res_name);
if( i != res_nb-1 ) {
{
fprintf(jed_file, " <res name=\"%s\">\n", this->name.c_str());
if (not this->children.empty()) {
- for (auto child: this->children) {
+ for (auto const& child : this->children) {
child->print(jed_file);
}
} else {
std::vector<unsigned int> id_list;
- for (auto host_name : hostgroup) {
+ for (auto const& host_name : hostgroup) {
xbt_assert( host_name != nullptr );
jed_container_t parent = host2_simgrid_parent_container.at(host_name);
unsigned int id = parent->name2id.at(host_name);
// find parent container
// group by parent container
std::unordered_map<const char*, std::vector<const char*>> parent2hostgroup;
- for (auto host: *host_list) {
+ for (auto const& host : *host_list) {
const char *host_name = sg_host_get_name(host);
jed_container_t parent = host2_simgrid_parent_container.at(host_name);
xbt_assert( parent != nullptr );
host_group->second.push_back(host_name);
}
- for (auto elm: parent2hostgroup) {
+ for (auto const& elm : parent2hostgroup) {
jed_container_t parent = container_name2container.at(elm.first);
add_subsets_to(subset_list, elm.second, parent);
}
{
sg_host_exit(); // Hosts should be part of the engine, at some point
delete netRoot_;
- for (auto kv : netpoints_)
+ for (auto const& kv : netpoints_)
delete kv.second;
}
}
void SIMIX_mailbox_exit()
{
- for (auto elm : *mailboxes)
+ for (auto const& elm : *mailboxes)
delete elm.second;
delete mailboxes;
}
void simgrid::kernel::activity::IoImpl::post()
{
- for (smx_simcall_t simcall : simcalls) {
+ for (smx_simcall_t const& simcall : simcalls) {
switch (simcall->call) {
case SIMCALL_FILE_WRITE:
simcall_file_write__set__result(simcall, surf_io->getCost());
{
if (smx_ctx_thread_sem == nullptr) {
// Serial execution
- for (smx_actor_t process : simix_global->process_to_run) {
+ for (smx_actor_t const& process : simix_global->process_to_run) {
XBT_DEBUG("Handling %p",process);
ThreadContext* context = static_cast<ThreadContext*>(process->context);
xbt_os_sem_release(context->begin_);
}
} else {
// Parallel execution
- for (smx_actor_t process : simix_global->process_to_run)
+ for (smx_actor_t const& process : simix_global->process_to_run)
xbt_os_sem_release(static_cast<ThreadContext*>(process->context)->begin_);
- for (smx_actor_t process : simix_global->process_to_run)
+ for (smx_actor_t const& process : simix_global->process_to_run)
xbt_os_sem_acquire(static_cast<ThreadContext*>(process->context)->end_);
}
}
new_xbt_graph_edge(graph, routerNode, backboneNode, edges);
}
- for (auto src : getVertices()) {
+ for (auto const& src : getVertices()) {
if (not src->isRouter()) {
xbt_node_t previous = new_xbt_graph_node(graph, src->cname(), nodes);
sg_platf_route_cbarg_t e_route = (sg_platf_route_cbarg_t)xbt_graph_edge_get_data(edge);
- for (auto link : *e_route->link_list) {
+ for (auto const& link : *e_route->link_list) {
route->link_list->insert(route->link_list->begin(), link);
if (lat)
*lat += static_cast<surf::LinkImpl*>(link)->latency();
NetPoint* prev_gw_src_net_elm = nullptr;
getGlobalRoute(gw_dst_net_elm, prev_gw_src_net_elm, &e_route_as_to_as, nullptr);
auto pos = route->link_list->begin();
- for (auto link : e_route_as_to_as) {
+ for (auto const& link : e_route_as_to_as) {
route->link_list->insert(pos, link);
if (lat)
*lat += link->latency();
}
}
- for (auto link : *e_route->link_list) {
+ for (auto const& link : *e_route->link_list) {
route->link_list->insert(route->link_list->begin(), link);
if (lat)
*lat += static_cast<surf::LinkImpl*>(link)->latency();
getGlobalRoute(prev_dst_gw, e_route->gw_src, route->link_list, lat);
}
- for (auto link : *e_route->link_list) {
+ for (auto const& link : *e_route->link_list) {
route->link_list->push_back(link);
if (lat)
*lat += link->latency();
if (e_route != nullptr) {
res->gw_src = e_route->gw_src;
res->gw_dst = e_route->gw_dst;
- for (auto link : *e_route->link_list) {
+ for (auto const& link : *e_route->link_list) {
res->link_list->push_back(link);
if (lat)
*lat += link->latency();
NetZoneImpl::~NetZoneImpl()
{
- for (auto& kv : bypassRoutes_)
+ for (auto const& kv : bypassRoutes_)
delete kv.second;
simgrid::s4u::Engine::getInstance()->netpointUnregister(netpoint_);
surf_cpu_model_pm->createCpu(res, speedPerPstate, coreAmount);
if (props != nullptr)
- for (auto kv : *props)
+ for (auto const& kv : *props)
res->setProperty(kv.first, kv.second);
simgrid::s4u::Host::onCreation(*res); // notify the signal
/* Build a copy that will be stored in the dict */
kernel::routing::BypassRoute* newRoute = new kernel::routing::BypassRoute(e_route->gw_src, e_route->gw_dst);
- for (auto link : *e_route->link_list)
+ for (auto const& link : *e_route->link_list)
newRoute->links.push_back(link);
/* Store it */
if (dst->netzone() == this && src->netzone() == this) {
if (bypassRoutes_.find({src, dst}) != bypassRoutes_.end()) {
BypassRoute* bypassedRoute = bypassRoutes_.at({src, dst});
- for (surf::LinkImpl* link : bypassedRoute->links) {
+ for (surf::LinkImpl* const& link : bypassedRoute->links) {
links->push_back(link);
if (latency)
*latency += link->latency();
src->cname(), dst->cname(), bypassedRoute->links.size());
if (src != key.first)
getGlobalRoute(src, bypassedRoute->gw_src, links, latency);
- for (surf::LinkImpl* link : bypassedRoute->links) {
+ for (surf::LinkImpl* const& link : bypassedRoute->links) {
links->push_back(link);
if (latency)
*latency += link->latency();
/* If source gateway is not our source, we have to recursively find our way up to this point */
if (src != route.gw_src)
getGlobalRoute(src, route.gw_src, links, latency);
- for (auto link : *route.link_list)
+ for (auto const& link : *route.link_list)
links->push_back(link);
delete route.link_list;
{
std::vector<kernel::routing::NetPoint*> vertices = getVertices();
- for (auto my_src : vertices) {
- for (auto my_dst : vertices) {
+ for (auto const& my_src : vertices) {
+ for (auto const& my_dst : vertices) {
if (my_src == my_dst)
continue;
previous_name = my_src->cname();
}
- for (auto link : *route->link_list) {
+ for (auto const& link : *route->link_list) {
const char* link_name = link->cname();
current = new_xbt_graph_node(graph, link_name, nodes);
current_name = link_name;
result->gw_dst = routearg->gw_dst;
}
- for (auto link : *routearg->link_list) {
+ for (auto const& link : *routearg->link_list) {
if (change_order)
result->link_list->push_back(link);
else
{
unsigned int dim_size_product = 1;
unsigned int i = 0;
- for (auto cur_dim_size: dimensions) {
+ for (auto const& cur_dim_size : dimensions) {
(*coords)[i] = (rankId / dim_size_product) % cur_dim_size;
dim_size_product *= cur_dim_size;
i++;
* Parse attribute dimensions="dim1,dim2,dim3,...,dimN" and save them into a vector.
* Additionally, we need to know how many ranks we have in total
*/
- for (auto group : dimensions)
+ for (auto const& group : dimensions)
dimensions_.push_back(surf_parse_get_int(group));
linkCountPerNode_ = dimensions_.size();
while (current_node != dst->id()) {
unsigned int dim_product = 1; // First, we will route in x-dimension
int j=0;
- for (auto cur_dim : dimensions_){
+ for (auto const& cur_dim : dimensions_) {
// current_node/dim_product = position in current dimension
if ((current_node / dim_product) % cur_dim != (dst->id() / dim_product) % cur_dim) {
boost::split(string_values, coordStr, boost::is_any_of(" "));
xbt_assert(string_values.size() == 3, "Coordinates of %s must have 3 dimensions", netpoint->cname());
- for (auto str : string_values)
+ for (auto const& str : string_values)
try {
coords.push_back(std::stod(str));
} catch (std::invalid_argument const& ia) {
ChunkedData() = default;
void clear()
{
- for (std::size_t pageno : pagenos_)
+ for (std::size_t const& pageno : pagenos_)
store_->unref_page(pageno);
pagenos_.clear();
}
: store_ (that.store_)
, pagenos_(that.pagenos_)
{
- for (std::size_t pageno : pagenos_)
+ for (std::size_t const& pageno : pagenos_)
store_->ref_page(pageno);
}
ChunkedData(ChunkedData&& that)
this->clear();
store_ = that.store_;
pagenos_ = that.pagenos_;
- for (std::size_t pageno : pagenos_)
+ for (std::size_t const& pageno : pagenos_)
store_->ref_page(pageno);
return *this;
}
XBT_INFO("No core dump was generated by the system.");
XBT_INFO("Counter-example execution trace:");
simgrid::mc::dumpRecordPath();
- for (auto& s : mc_model_checker->getChecker()->getTextualTrace())
+ for (auto const& s : mc_model_checker->getChecker()->getTextualTrace())
XBT_INFO("%s", s.c_str());
simgrid::mc::session->logState();
XBT_INFO("Stack trace:");
XBT_INFO("**************************");
XBT_INFO("Counter-example execution trace:");
simgrid::mc::dumpRecordPath();
- for (auto& s : mc_model_checker->getChecker()->getTextualTrace())
+ for (auto const& s : mc_model_checker->getChecker()->getTextualTrace())
XBT_INFO("%s", s.c_str());
simgrid::mc::session->logState();
}
// Try to find a duplicate in set of pages with the same hash:
page_set_type& page_set = this->hash_index_[hash];
- for (size_t pageno : page_set) {
+ for (size_t const& pageno : page_set) {
const void* snapshot_page = this->get_page(pageno);
if (memcmp(page, snapshot_page, xbt_pagesize) == 0) {
XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
XBT_INFO("Counter-example that violates formula :");
simgrid::mc::dumpRecordPath();
- for (auto& s : this->getTextualTrace())
+ for (auto const& s : this->getTextualTrace())
XBT_INFO("%s", s.c_str());
simgrid::mc::session->logState();
XBT_INFO("Counter-example depth : %zu", depth);
XBT_INFO("*** NON-PROGRESSIVE CYCLE DETECTED ***");
XBT_INFO("******************************************");
XBT_INFO("Counter-example execution trace:");
- for (auto& s : mc_model_checker->getChecker()->getTextualTrace())
+ for (auto const& s : mc_model_checker->getChecker()->getTextualTrace())
XBT_INFO("%s", s.c_str());
simgrid::mc::session->logState();
static inline
mc_mem_region_t MC_get_heap_region(simgrid::mc::Snapshot* snapshot)
{
- for (auto& region : snapshot->snapshot_regions)
+ for (auto const& region : snapshot->snapshot_regions)
if (region->region_type() == simgrid::mc::RegionType::Heap)
return region.get();
xbt_die("No heap region");
std::vector<simgrid::mc::Variable>& variables = object_info->global_variables;
- for (simgrid::mc::Variable& current_var : variables) {
+ for (simgrid::mc::Variable const& current_var : variables) {
// If the variable is not in this object, skip it:
// We do not expect to find a pointer to something which is not reachable
#endif
while (not simix_global->process_to_run.empty()) {
SIMIX_process_runall();
- for (smx_actor_t process : simix_global->process_that_ran) {
+ for (smx_actor_t const& process : simix_global->process_that_ran) {
smx_simcall_t req = &process->simcall;
if (req->call != SIMCALL_NONE && not simgrid::mc::request_is_visible(req))
SIMIX_simcall_handle(req, 0);
}
#if SIMGRID_HAVE_MC
xbt_dynar_reset(simix_global->actors_vector);
- for (std::pair<aid_t, smx_actor_t> kv : simix_global->process_list) {
+ for (std::pair<aid_t, smx_actor_t> const& kv : simix_global->process_list) {
xbt_dynar_push_as(simix_global->actors_vector, smx_actor_t, kv.second);
}
#endif
std::shared_ptr<simgrid::mc::Snapshot> snapshot = std::make_shared<simgrid::mc::Snapshot>(mc_process, num_state);
- for (auto& p : mc_model_checker->process().actors())
+ for (auto const& p : mc_model_checker->process().actors())
snapshot->enabled_processes.insert(p.copy.getBuffer()->pid);
snapshot_handle_ignore(snapshot.get());
{
std::string filename;
std::string hex = to_hex(id);
- for (const char* debug_path : debug_paths) {
+ for (const char* const& debug_path : debug_paths) {
// Example:
filename = std::string(debug_path) + ".build-id/"
+ to_hex(id.data(), 1) + '/'
simgrid::mc::processes_time.resize(SIMIX_process_get_maxpid());
MC_ignore_heap(simgrid::mc::processes_time.data(),
simgrid::mc::processes_time.size() * sizeof(simgrid::mc::processes_time[0]));
- for (auto kv : simix_global->process_list) {
+ for (auto const& kv : simix_global->process_list) {
smx_actor_t actor = kv.second;
MC_ignore_heap(&(actor->process_hookup), sizeof(actor->process_hookup));
}
XBT_INFO("*** DEAD-LOCK DETECTED ***");
XBT_INFO("**************************");
XBT_INFO("Counter-example execution trace:");
- for (auto& s : mc_model_checker->getChecker()->getTextualTrace())
+ for (auto const& s : mc_model_checker->getChecker()->getTextualTrace())
XBT_INFO("%s", s.c_str());
simgrid::mc::session->logState();
}
bool deadlock = false;
if (not simix_global->process_list.empty()) {
deadlock = true;
- for (auto kv : simix_global->process_list)
+ for (auto const& kv : simix_global->process_list)
if (simgrid::mc::actor_is_enabled(kv.second)) {
deadlock = false;
break;
static bool is_filtered_lib(const char* libname)
{
- for (const char* filtered_lib : filtered_libraries)
+ for (const char* const& filtered_lib : filtered_libraries)
if (strcmp(libname, filtered_lib) == 0)
return true;
return false;
XBT_WARN("Not all actions got consumed. If the simulation ended successfully (without deadlock),"
" you may want to add new processes to your deployment file.");
- for (auto actions_of : simgrid::xbt::action_queues) {
+ for (auto const& actions_of : simgrid::xbt::action_queues) {
XBT_WARN("Still %zu actions for %s", actions_of.second->size(), actions_of.first.c_str());
}
}
void MSG_zone_get_sons(msg_netzone_t netzone, xbt_dict_t whereto)
{
- for (auto elem : *netzone->getChildren()) {
+ for (auto const& elem : *netzone->getChildren()) {
xbt_dict_set(whereto, elem->getCname(), static_cast<void*>(elem), nullptr);
}
}
/* converts vector to dynar */
std::vector<simgrid::s4u::Host*> hosts;
netzone->getHosts(&hosts);
- for (auto host : hosts)
+ for (auto const& host : hosts)
xbt_dynar_push(whereto, &host);
}
std::map<std::string, std::string>* props = host->getProperties();
if (props == nullptr)
return nullptr;
- for (auto elm : *props) {
+ for (auto const& elm : *props) {
xbt_dict_set(as_dict, elm.first.c_str(), xbt_strdup(elm.second.c_str()), nullptr);
}
return as_dict;
{
xbt_assert((host != nullptr), "Invalid parameters");
xbt_dict_t contents = xbt_dict_new_homogeneous(nullptr);
- for (auto elm : host->getMountedStorages())
+ for (auto const& elm : host->getMountedStorages())
xbt_dict_set(contents, elm.first.c_str(), MSG_storage_get_content(elm.second), nullptr);
return contents;
msg_host_t dst_host;
size_t longest_prefix_length = 0;
- for (auto elm : host->getMountedStorages()) {
+ for (auto const& elm : host->getMountedStorages()) {
std::string mount_point = std::string(fullpath).substr(0, elm.first.size());
if (mount_point == elm.first && elm.first.length() > longest_prefix_length) {
/* The current mount name is found in the full path and is bigger than the previous*/
std::map<std::string, std::string>* props = storage->getProperties();
if (props == nullptr)
return nullptr;
- for (auto elm : *props) {
+ for (auto const& elm : *props) {
xbt_dict_set(as_dict, elm.first.c_str(), xbt_strdup(elm.second.c_str()), nullptr);
}
return as_dict;
{
std::map<std::string, simgrid::s4u::Storage*>* storage_map = simgrid::s4u::allStorages();
xbt_dynar_t res = xbt_dynar_new(sizeof(msg_storage_t),nullptr);
- for (auto s : *storage_map)
+ for (auto const& s : *storage_map)
xbt_dynar_push(res, &(s.second));
delete storage_map;
return res;
std::map<std::string, sg_size_t>* content = storage->getContent();
xbt_dict_t content_as_dict = xbt_dict_new_homogeneous(xbt_free_f);
- for (auto entry : *content) {
+ for (auto const& entry : *content) {
sg_size_t* psize = static_cast<sg_size_t*>(malloc(sizeof(sg_size_t)));
*psize = entry.second;
xbt_dict_set(content_as_dict, entry.first.c_str(), psize, nullptr);
/** @brief returns a list of all currently existing processes */
xbt_dynar_t MSG_processes_as_dynar() {
xbt_dynar_t res = xbt_dynar_new(sizeof(smx_actor_t), nullptr);
- for (auto kv : simix_global->process_list) {
+ for (auto const& kv : simix_global->process_list) {
smx_actor_t actor = kv.second;
xbt_dynar_push(res, &actor);
}
simgrid::simix::kernelImmediate([process] { return process->getImpl()->getProperties(); });
if (props == nullptr)
return nullptr;
- for (auto elm : *props) {
+ for (auto const& elm : *props) {
xbt_dict_set(as_dict, elm.first.c_str(), xbt_strdup(elm.second.c_str()), nullptr);
}
return as_dict;
if (vm->pimpl_vm_->dp_objs.empty())
return;
- for (auto elm : vm->pimpl_vm_->dp_objs) {
+ for (auto const& elm : vm->pimpl_vm_->dp_objs) {
dirty_page_t dp = elm.second;
double remaining = MSG_task_get_flops_amount(dp->task);
dp->prev_clock = MSG_get_clock();
{
double total = 0;
- for (auto elm : vm->pimpl_vm_->dp_objs) {
+ for (auto const& elm : vm->pimpl_vm_->dp_objs) {
const char* key = elm.first.c_str();
dirty_page_t dp = elm.second;
double remaining = MSG_task_get_flops_amount(dp->task);
**/
/* iterate for all virtual machines */
- for (s4u::VirtualMachine* ws_vm : VirtualMachineImpl::allVms_) {
+ for (s4u::VirtualMachine* const& ws_vm : VirtualMachineImpl::allVms_) {
surf::Cpu* cpu = ws_vm->pimpl_cpu;
xbt_assert(cpu, "cpu-less host");
-/* Copyright (c) 2015-2016. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2015-2017. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
if (pm_ramsize && not pm_overcommit) { /* Only verify that we don't overcommit on need */
/* Retrieve the memory occupied by the VMs on that host. Yep, we have to traverse all VMs of all hosts for that */
long total_ramsize_of_vms = 0;
- for (simgrid::s4u::VirtualMachine* ws_vm : simgrid::vm::VirtualMachineImpl::allVms_)
+ for (simgrid::s4u::VirtualMachine* const& ws_vm : simgrid::vm::VirtualMachineImpl::allVms_)
if (pm == ws_vm->pimpl_vm_->getPm())
total_ramsize_of_vms += ws_vm->pimpl_vm_->getRamsize();
/** @brief Fills the passed list with all hosts found in the platform */
void Engine::getHostList(std::vector<Host*>* list)
{
- for (auto kv : host_list)
+ for (auto const& kv : host_list)
list->push_back(kv.second);
}
if (not strcmp(current->getCname(), name))
return current;
- for (auto elem : *(current->getChildren())) {
+ for (auto const& elem : *(current->getChildren())) {
simgrid::s4u::NetZone* tmp = netzoneByNameRecursive(elem, name);
if (tmp != nullptr) {
return tmp;
/** @brief Fill the provided vector with all existing netpoints */
void Engine::getNetpointList(std::vector<simgrid::kernel::routing::NetPoint*>* list)
{
- for (auto kv : pimpl->netpoints_)
+ for (auto const& kv : pimpl->netpoints_)
list->push_back(kv.second);
}
/** @brief Register a new netpoint to the system */
std::string path;
XBT_DEBUG("Search for storage name for '%s' on '%s'", fullpath.c_str(), host->getCname());
- for (auto mnt : host->getMountedStorages()) {
+ for (auto const& mnt : host->getMountedStorages()) {
XBT_DEBUG("See '%s'", mnt.first.c_str());
mount_point = fullpath.substr(0, mnt.first.length());
{
std::vector<surf::LinkImpl*> linkImpls;
this->routeTo(dest, &linkImpls, latency);
- for (surf::LinkImpl* l : linkImpls)
+ for (surf::LinkImpl* const& l : linkImpls)
links->push_back(&l->piface_);
}
if (XBT_LOG_ISENABLED(surf_route, xbt_log_priority_debug)) {
XBT_CDEBUG(surf_route, "Route from '%s' to '%s' (latency: %f):", getCname(), dest->getCname(),
(latency == nullptr ? -1 : *latency));
- for (auto link : *links)
+ for (auto const& link : *links)
XBT_CDEBUG(surf_route, "Link %s", link->cname());
}
}
{
if (mounts == nullptr) {
mounts = new std::unordered_map<std::string, Storage*>();
- for (auto m : this->pimpl_->storage_) {
+ for (auto const& m : this->pimpl_->storage_) {
mounts->insert({m.first, &m.second->piface_});
}
}
NetZone::~NetZone()
{
- for (auto nz : *children_)
+ for (auto const& nz : *children_)
delete nz;
delete children_;
}
void NetZone::getHosts(std::vector<s4u::Host*>* whereto)
{
- for (auto card : vertices_) {
+ for (auto const& card : vertices_) {
s4u::Host* host = simgrid::s4u::Host::by_name_or_null(card->name());
if (host != nullptr)
whereto->push_back(host);
{
std::unordered_map<std::string, surf::StorageImpl*>* map = surf::StorageImpl::storagesMap();
std::map<std::string, Storage*>* res = new std::map<std::string, Storage*>;
- for (auto s : *map)
+ for (auto const& s : *map)
res->insert({s.first, &(s.second->piface_)}); // Convert each entry into its interface
return res;
}
static bool children_are_marked(SD_task_t task){
- for (SD_task_t it : *task->successors)
+ for (SD_task_t const& it : *task->successors)
if (it->marked == 0)
return false;
- for (SD_task_t it : *task->outputs)
+ for (SD_task_t const& it : *task->outputs)
if (it->marked == 0)
return false;
return true;
}
static bool parents_are_marked(SD_task_t task){
- for (SD_task_t it : *task->predecessors)
+ for (SD_task_t const& it : *task->predecessors)
if (it->marked == 0)
return false;
- for (SD_task_t it : *task->inputs)
+ for (SD_task_t const& it : *task->inputs)
if (it->marked == 0)
return false;
return true;
}
while (not current.empty()) {
std::vector<SD_task_t> next;
- for (auto t: current){
+ for (auto const& t : current) {
//Mark task
t->marked = 1;
- for (SD_task_t input : *t->inputs){
+ for (SD_task_t const& input : *t->inputs) {
input->marked=1;
// Inputs are communication, hence they can have only one predecessor
SD_task_t input_pred = *(input->predecessors->begin());
if (children_are_marked(input_pred))
next.push_back(input_pred);
}
- for (SD_task_t pred : *t->predecessors) {
+ for (SD_task_t const& pred : *t->predecessors) {
if (children_are_marked(pred))
next.push_back(pred);
}
while (not current.empty()) {
std::vector<SD_task_t> next;
//test if the current iteration is done
- for (auto t: current){
+ for (auto const& t : current) {
t->marked = 1;
- for (SD_task_t output : *t->outputs) {
+ for (SD_task_t const& output : *t->outputs) {
output->marked = 1;
// outputs are communication, hence they can have only one successor
SD_task_t output_succ = *(output->successors->begin());
if (parents_are_marked(output_succ))
next.push_back(output_succ);
}
- for (SD_task_t succ : *t->successors) {
+ for (SD_task_t const& succ : *t->successors) {
if (parents_are_marked(succ))
next.push_back(succ);
}
* Files not consumed in the system are said to be consumed by end task (bottom of DAG).
*/
- for (auto elm : files) {
+ for (auto const& elm : files) {
file = elm.second;
SD_task_t newfile;
if (file->predecessors->empty()) {
- for (SD_task_t it : *file->successors) {
+ for (SD_task_t const& it : *file->successors) {
newfile = SD_task_create_comm_e2e(file->name, nullptr, file->amount);
SD_task_dependency_add(nullptr, nullptr, root_task, newfile);
SD_task_dependency_add(nullptr, nullptr, newfile, it);
xbt_dynar_push(result, &newfile);
}
} else if (file->successors->empty()) {
- for (SD_task_t it : *file->predecessors){
+ for (SD_task_t const& it : *file->predecessors) {
newfile = SD_task_create_comm_e2e(file->name, nullptr, file->amount);
SD_task_dependency_add(nullptr, nullptr, it, newfile);
SD_task_dependency_add(nullptr, nullptr, newfile, end_task);
xbt_dynar_push(result, &newfile);
}
} else {
- for (SD_task_t it : *file->predecessors) {
- for (SD_task_t it2 : *file->successors) {
+ for (SD_task_t const& it : *file->predecessors) {
+ for (SD_task_t const& it2 : *file->successors) {
if (it == it2) {
XBT_WARN ("File %s is produced and consumed by task %s."
"This loop dependency will prevent the execution of the task.", file->name, it->name);
xbt_dynar_push(result, &end_task);
/* Free previous copy of the files */
- for (auto elm : files)
+ for (auto const& elm : files)
SD_task_destroy(elm.second);
unsigned int cpt;
xbt_dynar_foreach(result, cpt, file) {
if(schedule){
if (schedule_success) {
const sg_host_t *workstations = sg_host_list ();
- for (auto elm : computers) {
+ for (auto const& elm : computers) {
SD_task_t previous_task = nullptr;
- for (auto task : *elm.second) {
+ for (auto const& task : *elm.second) {
/* add dependency between the previous and the task to avoid parallel execution */
if(task){
if (previous_task && not SD_task_dependency_exists(previous_task, task))
}
} else {
XBT_WARN("The scheduling is ignored");
- for (auto elm : computers)
+ for (auto const& elm : computers)
delete elm.second;
xbt_dynar_free(&result);
result = nullptr;
{
xbt_dynar_t parents = xbt_dynar_new(sizeof(SD_task_t), nullptr);
- for (auto it : *task->predecessors)
+ for (auto const& it : *task->predecessors)
xbt_dynar_push(parents, &it);
- for (auto it : *task->inputs)
+ for (auto const& it : *task->inputs)
xbt_dynar_push(parents, &it);
return parents;
{
xbt_dynar_t children = xbt_dynar_new(sizeof(SD_task_t), nullptr);
- for (auto it : *task->successors)
+ for (auto const& it : *task->successors)
xbt_dynar_push(children, &it);
- for (auto it : *task->outputs)
+ for (auto const& it : *task->outputs)
xbt_dynar_push(children, &it);
return children;
XBT_INFO(" - Dependencies to satisfy: %zu", task->inputs->size()+ task->predecessors->size());
if ((task->inputs->size()+ task->predecessors->size()) > 0) {
XBT_INFO(" - pre-dependencies:");
- for (auto it : *task->predecessors)
+ for (auto const& it : *task->predecessors)
XBT_INFO(" %s", it->name);
- for (auto it: *task->inputs)
+ for (auto const& it : *task->inputs)
XBT_INFO(" %s", it->name);
}
if ((task->outputs->size() + task->successors->size()) > 0) {
XBT_INFO(" - post-dependencies:");
- for (auto it : *task->successors)
+ for (auto const& it : *task->successors)
XBT_INFO(" %s", it->name);
- for (auto it : *task->outputs)
+ for (auto const& it : *task->outputs)
XBT_INFO(" %s", it->name);
}
}
xbt_die("Unknown task type!");
}
fprintf(fout, "];\n");
- for (auto it : *task->predecessors)
+ for (auto const& it : *task->predecessors)
fprintf(fout, " T%p -> T%p;\n", it, task);
- for (auto it : *task->inputs)
+ for (auto const& it : *task->inputs)
fprintf(fout, " T%p -> T%p;\n", it, task);
}
int host_nb = task->allocation->size();
sg_host_t *hosts = xbt_new(sg_host_t, host_nb);
int i =0;
- for (auto host: *task->allocation){
+ for (auto const& host : *task->allocation) {
hosts[i] = host;
i++;
}
SD_task_do_schedule(task);
/* Iterate over all inputs and outputs to say where I am located (and start them if runnable) */
- for (auto input : *task->inputs){
+ for (auto const& input : *task->inputs) {
int src_nb = input->allocation->size();
int dst_nb = count;
if (input->allocation->empty())
}
}
- for (auto output : *task->outputs){
+ for (auto const& output : *task->outputs) {
int src_nb = count;
int dst_nb = output->allocation->size();
if (output->allocation->empty())
* the tests.
*/
std::vector<std::string> names = std::vector<std::string>();
- for (auto kv : simgrid::s4u::host_list)
+ for (auto const& kv : simgrid::s4u::host_list)
names.push_back(kv.second->getName());
std::sort(names.begin(), names.end());
- for (auto name : names)
+ for (auto const& name : names)
simgrid::s4u::host_list.at(name)->destroy();
// host_list.clear(); This would be sufficient if the dict would contain smart_ptr. It's now useless
{
xbt_dynar_t res = xbt_dynar_new(sizeof(sg_host_t),nullptr);
- for (auto kv : simgrid::s4u::host_list) {
+ for (auto const& kv : simgrid::s4u::host_list) {
simgrid::s4u::Host* host = kv.second;
if (host && host->pimpl_netpoint && host->pimpl_netpoint->isHost())
xbt_dynar_push(res, &host);
xbt_dict_t sg_host_get_mounted_storage_list(sg_host_t host){
xbt_assert((host != nullptr), "Invalid parameters");
xbt_dict_t res = xbt_dict_new_homogeneous(nullptr);
- for (auto elm : host->getMountedStorages()) {
+ for (auto const& elm : host->getMountedStorages()) {
const char* mount_name = elm.first.c_str();
sg_storage_t storage = elm.second;
xbt_dict_set(res, mount_name, (void*)storage->getName(), nullptr);
std::vector<const char*>* storage_vector = new std::vector<const char*>();
xbt_dynar_t storage_dynar = xbt_dynar_new(sizeof(const char*), nullptr);
host->getAttachedStorages(storage_vector);
- for (auto name : *storage_vector)
+ for (auto const& name : *storage_vector)
xbt_dynar_push(storage_dynar, &name);
delete storage_vector;
return storage_dynar;
std::map<std::string, std::string>* props = host->getProperties();
if (props == nullptr)
return nullptr;
- for (auto elm : *props) {
+ for (auto const& elm : *props) {
xbt_dict_set(as_dict, elm.first.c_str(), xbt_strdup(elm.second.c_str()), nullptr);
}
return as_dict;
{
std::vector<simgrid::s4u::Link*> vlinks;
from->routeTo(to, &vlinks, nullptr);
- for (auto link : vlinks)
+ for (auto const& link : vlinks)
xbt_dynar_push(links, &link);
}
/**
std::vector<simgrid::s4u::Link*> vlinks;
from->routeTo(to, &vlinks, nullptr);
- for (auto link : vlinks) {
+ for (auto const& link : vlinks) {
double bandwidth = link->bandwidth();
if (bandwidth < min_bandwidth || min_bandwidth < 0.0)
min_bandwidth = bandwidth;
if (not props->empty()) {
XBT_INFO(" - properties:");
- for (auto elm : *props) {
+ for (auto const& elm : *props) {
XBT_INFO(" %s->%s", elm.first.c_str(), elm.second.c_str());
}
}
/* Add properties */
if (properties != nullptr)
- for (auto kv : *properties)
+ for (auto const& kv : *properties)
process->setProperty(kv.first, kv.second);
/* Make sure that the process is initialized for simix, in case we are called from the Host::onCreation signal */
/* Add properties */
if (properties != nullptr)
- for (auto kv : *properties)
+ for (auto const& kv : *properties)
process->setProperty(kv.first, kv.second);
/* Add the process to it's host process list */
*/
void SIMIX_process_killall(smx_actor_t issuer, int reset_pid)
{
- for (auto kv : simix_global->process_list)
+ for (auto const& kv : simix_global->process_list)
if (kv.second != issuer)
SIMIX_process_kill(kv.second, issuer);
smx_actor_t SIMIX_process_get_by_name(const char* name)
{
- for (auto kv : simix_global->process_list)
+ for (auto const& kv : simix_global->process_list)
if (kv.second->name == name)
return kv.second;
return nullptr;
{
surf_action_t action;
- for(auto model : *all_existing_models) {
+ for (auto const& model : *all_existing_models) {
XBT_DEBUG("Handling the processes whose action failed (if any)");
while ((action = surf_model_extract_failed_action_set(model))) {
XBT_DEBUG(" Handling Action %p",action);
* That would thus be a pure waste of time.
*/
- for (smx_actor_t process : simix_global->process_that_ran) {
+ for (smx_actor_t const& process : simix_global->process_that_ran) {
if (process->simcall.call != SIMCALL_NONE) {
SIMIX_simcall_handle(&process->simcall, 0);
}
} while (again);
/* Autorestart all process */
- for (auto host: host_that_restart) {
+ for (auto const& host : host_that_restart) {
XBT_INFO("Restart processes on host %s", host->getCname());
SIMIX_host_autorestart(host);
}
XBT_INFO("%d processes are still running, waiting for something.", nbprocess);
/* List the process and their state */
XBT_INFO("Legend of the following listing: \"Process <pid> (<name>@<host>): <status>\"");
- for (auto kv : simix_global->process_list) {
+ for (auto const& kv : simix_global->process_list) {
smx_actor_t process = kv.second;
if (process->waiting_synchro) {
SIMIX_display_process_status();
THROWF(arg_error, 0, "%s", msg.c_str());
}
- for (auto arg : auto_restart_processes)
+ for (auto const& arg : auto_restart_processes)
delete arg;
auto_restart_processes.clear();
- for (auto arg : boot_processes)
+ for (auto const& arg : boot_processes)
delete arg;
boot_processes.clear();
xbt_swag_free(process_list);
*/
void Host::turnOn()
{
- for (auto arg : boot_processes) {
+ for (auto const& arg : boot_processes) {
XBT_DEBUG("Booting Process %s(%s) right now", arg->name.c_str(), arg->host->getCname());
smx_actor_t actor = simix_global->create_process_function(arg->name.c_str(), arg->code, nullptr, arg->host,
arg->properties, nullptr);
std::vector<simgrid::simix::ProcessArg*> process_list =
host->extension<simgrid::simix::Host>()->auto_restart_processes;
- for (auto arg : process_list) {
+ for (auto const& arg : process_list) {
XBT_DEBUG("Restarting Process %s@%s right now", arg->name.c_str(), arg->host->getCname());
smx_actor_t actor = simix_global->create_process_function(arg->name.c_str(), arg->code, nullptr, arg->host,
arg->properties, nullptr);
void SIMIX_execution_finish(simgrid::kernel::activity::ExecImplPtr exec)
{
- for (smx_simcall_t simcall : exec->simcalls) {
+ for (smx_simcall_t const& simcall : exec->simcalls) {
switch (exec->state) {
case SIMIX_DONE:
void SIMIX_io_finish(smx_activity_t synchro)
{
- for (smx_simcall_t simcall : synchro->simcalls) {
+ for (smx_simcall_t const& simcall : synchro->simcalls) {
switch (synchro->state) {
case SIMIX_DONE:
/* do nothing, synchro done */
template <typename T> void Keyval::cleanup_attr(){
if (not attributes()->empty()) {
int flag=0;
- for(auto it : attributes_){
+ for (auto const& it : attributes_) {
auto elm = T::keyvals_.find(it.first);
if (elm != T::keyvals_.end()) {
smpi_key_elem elem = elm->second;
// Iterate over all the sections that were specified and find the right value. (fact.factor represents the interval
// sizes; we want to find the section that has fact.factor <= size and no other such fact.factor <= size)
// Note: parse_factor() (used before) already sorts the vector we iterate over!
- for (auto fact : orecv_parsed_values) {
+ for (auto const& fact : orecv_parsed_values) {
if (size <= fact.factor) { // Values already too large, use the previously computed value of current!
XBT_DEBUG("or : %zu <= %zu return %.10f", size, fact.factor, current);
return current;
// value. (fact.factor represents the interval sizes; we want to find the
// section that has fact.factor <= size and no other such fact.factor <= size)
// Note: parse_factor() (used before) already sorts the vector we iterate over!
- for (auto& fact : osend_parsed_values) {
+ for (auto const& fact : osend_parsed_values) {
if (size <= fact.factor) { // Values already too large, use the previously computed value of current!
XBT_DEBUG("os : %zu <= %zu return %.10f", size, fact.factor, current);
return current;
// Iterate over all the sections that were specified and find the right value. (fact.factor represents the interval
// sizes; we want to find the section that has fact.factor <= size and no other such fact.factor <= size)
// Note: parse_factor() (used before) already sorts the vector we iterate over!
- for (auto& fact : oisend_parsed_values) {
+ for (auto const& fact : oisend_parsed_values) {
if (size <= fact.factor) { // Values already too large, use the previously computed value of current!
XBT_DEBUG("ois : %zu <= %zu return %.10f", size, fact.factor, current);
return current;
void TRACE_smpi_release()
{
- for (auto elm : keys)
+ for (auto const& elm : keys)
delete elm.second;
}
#if HAVE_PAPI
papi_counter_t counters = smpi_process()->papi_counters();
- for (auto& it : counters) {
+ for (auto const& it : counters) {
/**
* Check whether this variable already exists or not. Otherwise, it will be created
* multiple times but only the last one would be used...
container_t container = PJ_container_get(container_name);
papi_counter_t& counter_data = smpi_process()->papi_counters();
- for (auto& pair : counter_data) {
+ for (auto const& pair : counter_data) {
new_pajeSetVariable(surf_get_clock(), container,
PJ_type_get(/* countername */ pair.first.c_str(), container->type), pair.second);
}
void smpi_bench_destroy()
{
- for (auto elm : samples)
+ for (auto const& elm : samples)
xbt_free(elm.second);
}
static int already_called = 0;
if (not already_called) {
already_called = 1;
- for (auto& item : simgrid::s4u::host_list) {
+ for (auto const& item : simgrid::s4u::host_list) {
simgrid::s4u::Host* host = item.second;
host->extension_set(new simgrid::smpi::SmpiHost(host));
}
}
void smpi_deployment_cleanup_instances(){
- for (auto& item : smpi_instances) {
+ for (auto const& item : smpi_instances) {
Instance instance = item.second;
if (instance.comm_world != MPI_COMM_NULL)
delete instance.comm_world->group();
static void print(std::vector<std::pair<size_t, size_t>> vec) {
std::fprintf(stderr, "{");
- for (auto elt : vec) {
+ for (auto const& elt : vec) {
std::fprintf(stderr, "(0x%zx, 0x%zx),", elt.first, elt.second);
}
std::fprintf(stderr, "}\n");
}
static void memcpy_private(void* dest, const void* src, std::vector<std::pair<size_t, size_t>>& private_blocks)
{
- for (auto block : private_blocks)
+ for (auto const& block : private_blocks)
memcpy((uint8_t*)dest+block.first, (uint8_t*)src+block.first, block.second-block.first);
}
static void check_blocks(std::vector<std::pair<size_t, size_t>> &private_blocks, size_t buff_size) {
- for (auto block : private_blocks)
+ for (auto const& block : private_blocks)
xbt_assert(block.first <= block.second && block.second <= buff_size, "Oops, bug in shared malloc.");
}
// Iterate over all the computational units. This could be processes, hosts, threads, ranks... You name it.
// I'm not exactly sure what we will support eventually, so I'll leave it at the general term "units".
- for (auto& unit_it : tokens) {
+ for (auto const& unit_it : tokens) {
boost::char_separator<char> separator_events(":");
Tokenizer event_tokens(unit_it, separator_events);
int recvs_snd[count_requests];
int recvs_rcv[count_requests];
unsigned int i=0;
- for (auto req : *(get_reqq_self())){
+ for (auto const& req : *(get_reqq_self())) {
if (req && (req->flags () & RECV)){
recvs_snd[i]=req->src();
recvs_rcv[i]=req->dst();
MPI_Status status[count_requests];
unsigned int i=0;
- for (auto req: *get_reqq_self()){
+ for (auto const& req : *get_reqq_self()) {
requests[i] = req;
i++;
}
std::vector<std::pair<size_t, size_t>> shift_and_frame_private_blocks(const std::vector<std::pair<size_t, size_t>> vec, size_t offset, size_t buff_size) {
std::vector<std::pair<size_t, size_t>> result;
- for(auto block: vec) {
+ for (auto const& block : vec) {
auto new_block = std::make_pair(std::min(std::max((size_t)0, block.first-offset), buff_size),
std::min(std::max((size_t)0, block.second-offset), buff_size));
if(new_block.second > 0 && new_block.first < buff_size)
std::sort(smpi_factor.begin(), smpi_factor.end(), [](const s_smpi_factor_t &pa, const s_smpi_factor_t &pb) {
return (pa.factor < pb.factor);
});
- for (auto& fact : smpi_factor) {
+ for (auto const& fact : smpi_factor) {
XBT_DEBUG("smpi_factor:\t%zu : %zu values, first: %f", fact.factor, smpi_factor.size() ,fact.values[0]);
}
smpi_factor.shrink_to_fit();
if (not attributes()->empty()) {
int flag;
void* value_out;
- for(auto it : *attributes()){
+ for (auto const& it : *attributes()) {
smpi_key_elem elem = keyvals_.at(it.first);
if (elem != nullptr && elem->copy_fn.comm_copy_fn != MPI_NULL_COPY_FN) {
ret = elem->copy_fn.comm_copy_fn(this, it.first, nullptr, it.second, &value_out, &flag);
}
void Comm::finish_rma_calls(){
- for(auto it : rma_wins_){
+ for (auto const& it : rma_wins_) {
if(it->rank()==this->rank()){//is it ours (for MPI_COMM_WORLD)?
int finished = it->finish_comms();
XBT_DEBUG("Barrier for rank %d - Finished %d RMA calls",this->rank(), finished);
f2c_lookup_ = new std::unordered_map<std::string, F2C*>;
}
- for (auto elm : *f2c_lookup_)
+ for (auto const& elm : *f2c_lookup_)
if (elm.second == this)
return std::stoi(elm.first);
rank_to_index_map_[i] = origin->rank_to_index_map_[i];
}
- for (auto elm : origin->index_to_rank_map_) {
+ for (auto const& elm : origin->index_to_rank_map_) {
index_to_rank_map_.insert({elm.first, elm.second});
}
}
int Info::get_nthkey(int n, char *key){
int num=0;
- for (auto elm : map_) {
+ for (auto const& elm : map_) {
if (num == n) {
strncpy(key, elm.first.c_str(), elm.first.length() + 1);
return MPI_SUCCESS;
if (not accumulates.empty()) {
std::sort(accumulates.begin(), accumulates.end(), sort_accumulates);
- for (auto req : accumulates) {
+ for (auto& req : accumulates) {
finish_wait(&req, status);
}
}
if(opened_==0){//check that post/start has been done
// no fence or start .. lock ok ?
int locked=0;
- for(auto it : recv_win->lockers_)
+ for (auto const& it : recv_win->lockers_)
if (it == comm_->rank())
locked = 1;
if(locked != 1)
if(opened_==0){//check that post/start has been done
// no fence or start .. lock ok ?
int locked=0;
- for(auto it : send_win->lockers_)
+ for (auto const& it : send_win->lockers_)
if (it == comm_->rank())
locked = 1;
if(locked != 1)
if(opened_==0){//check that post/start has been done
// no fence or start .. lock ok ?
int locked=0;
- for(auto it : recv_win->lockers_)
+ for (auto const& it : recv_win->lockers_)
if (it == comm_->rank())
locked = 1;
if(locked != 1)
if(opened_==0){//check that post/start has been done
// no fence or start .. lock ok ?
int locked=0;
- for(auto it : send_win->lockers_)
+ for (auto const& it : send_win->lockers_)
if (it == comm_->rank())
locked = 1;
if(locked != 1)
if(opened_==0){//check that post/start has been done
// no fence or start .. lock ok ?
int locked=0;
- for(auto it : send_win->lockers_)
+ for (auto const& it : send_win->lockers_)
if (it == comm_->rank())
locked = 1;
if(locked != 1)
void HostModel::ignoreEmptyVmInPmLMM()
{
/* iterate for all virtual machines */
- for (s4u::VirtualMachine* ws_vm : vm::VirtualMachineImpl::allVms_) {
+ for (s4u::VirtualMachine* const& ws_vm : vm::VirtualMachineImpl::allVms_) {
Cpu* cpu = ws_vm->pimpl_cpu;
int active_tasks = lmm_constraint_get_variable_amount(cpu->constraint());
void HostImpl::getAttachedStorageList(std::vector<const char*>* storages)
{
- for (auto s : storage_)
+ for (auto const& s : storage_)
if (s.second->getHost() == piface_->getCname())
storages->push_back(s.second->piface_.getName());
}
xbt_assert(speed_.scale > 0, "Speed of host %s must be >0", host->getCname());
// Copy the power peak array:
- for (double value : *speedPerPstate) {
+ for (double const& value : *speedPerPstate) {
speedPerPstate_.push_back(value);
}
}
nbPoints_ = speedTrace->event_list.size() + 1;
timePoints_ = new double[nbPoints_];
integral_ = new double[nbPoints_];
- for (auto val : speedTrace->event_list) {
+ for (auto const& val : speedTrace->event_list) {
timePoints_[i] = time;
integral_[i] = integral;
integral += val.date_ * val.value_;
type_ = TRACE_DYNAMIC;
/* count the total time of trace file */
- for (auto val : speedTrace->event_list)
+ for (auto const& val : speedTrace->event_list)
total_time += val.date_;
trace_ = new CpuTiTrace(speedTrace);
XBT_DEBUG("Graph extraction for NetZone = %s", netzone->getCname());
if (not netzone->getChildren()->empty()) {
//bottom-up recursion
- for (auto nz_son : *netzone->getChildren()) {
+ for (auto const& nz_son : *netzone->getChildren()) {
container_t child_container = static_cast<container_t>(xbt_dict_get(container->children, nz_son->getCname()));
recursiveGraphExtraction(nz_son, child_container, filter);
}
{
if (not netzone->getChildren()->empty()) {
//bottom-up recursion
- for (auto netzone_child : *netzone->getChildren()) {
+ for (auto const& netzone_child : *netzone->getChildren()) {
container_t child_container =
static_cast<container_t>(xbt_dict_get(container->children, netzone_child->getCname()));
recursiveXBTGraphExtraction(graph, nodes, edges, netzone_child, child_container);
"You're trying to send data from %s to %s but there is no connecting path between these two hosts.",
src->getCname(), dst->getCname());
- for (auto link: *route)
+ for (auto const& link : *route)
if (link->isOff())
failed = 1;
if (sg_network_crosstraffic == 1) {
back_route = new std::vector<LinkImpl*>();
dst->routeTo(src, back_route, nullptr);
- for (auto link: *back_route)
+ for (auto const& link : *back_route)
if (link->isOff())
failed = 1;
}
double bandwidth_bound = -1.0;
if (sg_weight_S_parameter > 0)
- for (auto link : *route)
+ for (auto const& link : *route)
action->weight_ += sg_weight_S_parameter / link->bandwidth();
- for (auto link : *route) {
+ for (auto const& link : *route) {
double bb = bandwidthFactor(size) * link->bandwidth();
bandwidth_bound = (bandwidth_bound < 0.0) ? bb : std::min(bandwidth_bound, bb);
}
lmm_update_variable_bound(maxminSystem_, action->getVariable(), (action->latCurrent_ > 0) ? std::min(action->rate_, sg_tcp_gamma / (2.0 * action->latCurrent_)) : action->rate_);
}
- for (auto link: *route)
+ for (auto const& link : *route)
lmm_expand(maxminSystem_, link->constraint(), action->getVariable(), 1.0);
if (back_route != nullptr) { // sg_network_crosstraffic was activated
XBT_DEBUG("Fullduplex active adding backward flow using 5%%");
- for (auto link : *back_route)
+ for (auto const& link : *back_route)
lmm_expand(maxminSystem_, link->constraint(), action->getVariable(), .05);
//Change concurrency_share here, if you want that cross-traffic is included in the SURF concurrency
NetworkIBModel::~NetworkIBModel()
{
- for (auto instance : active_nodes)
+ for (auto const& instance : active_nodes)
delete instance.second;
}
{
LinkImpl** res = xbt_new(LinkImpl*, (int)links->size());
int i = 0;
- for (auto kv : *links) {
+ for (auto const& kv : *links) {
res[i] = kv.second;
i++;
}
/** @brief destructor of the static data */
void LinkImpl::linksExit()
{
- for (auto kv : *links)
+ for (auto const& kv : *links)
(kv.second)->destroy();
delete links;
}
static void clusterCreation_cb(ClusterCreationArgs* cluster)
{
- for (int i : *cluster->radicals) {
+ for (int const& i : *cluster->radicals) {
// Routers don't create a router on the other end of the private link by themselves.
// We just need this router to be given an ID so we create a temporary NetPointNS3 so that it gets one
NetPointNs3* host_dst = new NetPointNs3();
}
NetworkNS3Model::~NetworkNS3Model() {
- for (auto addr : IPV4addr)
+ for (auto const& addr : IPV4addr)
free(addr);
IPV4addr.clear();
xbt_dict_free(&flowFromSock);
std::vector<LinkImpl*> route = std::vector<LinkImpl*>();
action->src_->routeTo(action->dst_, &route, nullptr);
- for (auto link : route)
+ for (auto const& link : route)
TRACE_surf_link_set_utilization(link->cname(), action->getCategory(), (data_delta_sent) / delta, now - delta,
delta);
XBT_DEBUG("%s: profile: %s, cores: %d", host->getCname(), all_power_values_str, host->getCoreCount());
int i = 0;
- for (auto current_power_values_str : all_power_values) {
+ for (auto const& current_power_values_str : all_power_values) {
/* retrieve the power values associated with the current pstate */
std::vector<std::string> current_power_values;
boost::split(current_power_values, current_power_values_str, boost::is_any_of(":"));
static void onActionStateChange(simgrid::surf::CpuAction* action, simgrid::surf::Action::State previous)
{
- for (simgrid::surf::Cpu* cpu : action->cpus()) {
+ for (simgrid::surf::Cpu* const& cpu : action->cpus()) {
simgrid::s4u::Host* host = cpu->getHost();
if (host != nullptr) {
simgrid::simix::kernelImmediate([]() {
std::vector<simgrid::s4u::Host*> list;
simgrid::s4u::Engine::getInstance()->getHostList(&list);
- for (auto host : list)
+ for (auto const& host : list)
if (dynamic_cast<simgrid::s4u::VirtualMachine*>(host) == nullptr) // Ignore virtual machines
host->extension<HostEnergy>()->update();
});
/* This callback is called when an action (computation, idle, ...) terminates */
static void onActionStateChange(simgrid::surf::CpuAction* action, simgrid::surf::Action::State previous)
{
- for (simgrid::surf::Cpu* cpu : action->cpus()) {
+ for (simgrid::surf::Cpu* const& cpu : action->cpus()) {
simgrid::s4u::Host* host = cpu->getHost();
if (host != nullptr) {
hostList_->at(i)->routeTo(hostList_->at(j), &route, &lat);
latency = MAX(latency, lat);
- for (auto link : route)
+ for (auto const& link : route)
affected_links.insert(link->cname());
}
}
std::vector<LinkImpl*> route;
hostList_->at(i)->routeTo(hostList_->at(j), &route, nullptr);
- for (auto link : route)
+ for (auto const& link : route)
lmm_expand_add(model->getMaxminSystem(), link->constraint(), this->getVariable(),
bytes_amount[i * host_nb + j]);
}
{
std::map<std::string, std::string> props;
if (args->properties) {
- for (auto elm : *args->properties)
+ for (auto const& elm : *args->properties)
props.insert({elm.first, elm.second});
delete args->properties;
}
} else {
names.push_back(link->id);
}
- for (auto link_name : names) {
+ for (auto const& link_name : names) {
simgrid::surf::LinkImpl* l =
surf_network_model->createLink(link_name.c_str(), link->bandwidth, link->latency, link->policy);
if (link->properties) {
- for (auto elm : *link->properties)
+ for (auto const& elm : *link->properties)
l->setProperty(elm.first, elm.second);
delete link->properties;
}
current_as->hasLimiter_ = 1;
}
- for (int i : *cluster->radicals) {
+ for (int const& i : *cluster->radicals) {
std::string host_id = std::string(cluster->prefix) + std::to_string(i) + cluster->suffix;
std::string link_id = std::string(cluster->id) + "_link_" + std::to_string(i);
if ((cluster->properties != nullptr) && (not cluster->properties->empty())) {
host.properties = new std::map<std::string, std::string>;
- for (auto elm : *cluster->properties)
+ for (auto const& elm : *cluster->properties)
host.properties->insert({elm.first, elm.second});
}
void sg_platf_new_cabinet(CabinetCreationArgs* cabinet)
{
- for (int radical : *cabinet->radicals) {
+ for (int const& radical : *cabinet->radicals) {
std::string hostname = cabinet->prefix + std::to_string(radical) + cabinet->suffix;
s_sg_platf_host_cbarg_t host;
memset(&host, 0, sizeof(host));
auto s = surf_storage_model->createStorage(storage->id, stype->id, storage->content, storage->attach);
if (storage->properties) {
- for (auto elm : *storage->properties)
+ for (auto const& elm : *storage->properties)
s->setProperty(elm.first, elm.second);
delete storage->properties;
}
// The requested host does not exist. Do a nice message to the user
std::string msg = std::string("Cannot create process '") + process->function + "': host '" + process->host +
"' does not exist\nExisting hosts: '";
- for (auto kv : simgrid::s4u::host_list) {
+ for (auto const& kv : simgrid::s4u::host_list) {
simgrid::s4u::Host* host = kv.second;
msg += host->getName();
msg += "', '";
static void check_disk_attachment()
{
- for (auto s : *simgrid::surf::StorageImpl::storagesMap()) {
+ for (auto const& s : *simgrid::surf::StorageImpl::storagesMap()) {
simgrid::kernel::routing::NetPoint* host_elm = sg_netpoint_by_name_or_null(s.second->getHost().c_str());
if (not host_elm)
surf_parse_error(std::string("Unable to attach storage ") + s.second->cname() + ": host " + s.second->getHost() +
}
XBT_DEBUG ("Set every models in the right state by updating them to 0.");
- for (auto model : *all_existing_models)
+ for (auto const& model : *all_existing_models)
model->updateActionsState(NOW, 0.0);
}
NOW = NOW + time_delta;
// Inform the models of the date change
- for (auto model : *all_existing_models) {
+ for (auto const& model : *all_existing_models) {
model->updateActionsState(NOW, time_delta);
}
simgrid::s4u::onTimeAdvance(time_delta);
}
/* search relative files in the path */
- for (auto path_elm : surf_path) {
+ for (auto const& path_elm : surf_path) {
std::string buff = path_elm + FILE_DELIM + name;
fs->open(buff.c_str(), std::ifstream::in);
return fopen(name, mode);
/* search relative files in the path */
- for (auto path_elm : surf_path) {
+ for (auto const& path_elm : surf_path) {
std::string buff = path_elm + FILE_DELIM + name;
file = fopen(buff.c_str(), mode);
sg_host_exit();
sg_link_exit();
- for (auto e : storage_types) {
+ for (auto const& e : storage_types) {
simgrid::surf::StorageType* stype = e.second;
delete stype->properties;
delete stype->model_properties;
delete stype;
}
- for (auto s : *simgrid::surf::StorageImpl::storagesMap())
+ for (auto const& s : *simgrid::surf::StorageImpl::storagesMap())
delete s.second;
delete simgrid::surf::StorageImpl::storagesMap();
- for (auto model : *all_existing_models)
+ for (auto const& model : *all_existing_models)
delete model;
delete all_existing_models;
void tmgr_finalize()
{
- for (auto kv : trace_list)
+ for (auto const& kv : trace_list)
delete kv.second;
trace_list.clear();
}
simgrid::trace_mgr::trace* trace = tmgr_trace_new_from_string("TheName", str, 0);
XBT_VERB("---------------------------------------------------------");
XBT_VERB("data>>\n%s<<data\n", str);
- for (auto evt : trace->event_list)
+ for (auto const& evt : trace->event_list)
XBT_VERB("event: d:%lg v:%lg", evt.date_, evt.value_);
MockedResource daResource;
parse_status = surf_parse();
/* connect all traces relative to hosts */
- for (auto elm : trace_connect_list_host_avail) {
+ for (auto const& elm : trace_connect_list_host_avail) {
xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str());
tmgr_trace_t trace = traces_set_list.at(elm.first);
cpu->setStateTrace(trace);
}
- for (auto elm : trace_connect_list_host_speed) {
+ for (auto const& elm : trace_connect_list_host_speed) {
xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str());
tmgr_trace_t trace = traces_set_list.at(elm.first);
cpu->setSpeedTrace(trace);
}
- for (auto elm : trace_connect_list_link_avail) {
+ for (auto const& elm : trace_connect_list_link_avail) {
xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str());
tmgr_trace_t trace = traces_set_list.at(elm.first);
link->setStateTrace(trace);
}
- for (auto elm : trace_connect_list_link_bw) {
+ for (auto const& elm : trace_connect_list_link_bw) {
xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str());
tmgr_trace_t trace = traces_set_list.at(elm.first);
sg_link_t link = simgrid::s4u::Link::byName(elm.second.c_str());
link->setBandwidthTrace(trace);
}
- for (auto elm : trace_connect_list_link_lat) {
+ for (auto const& elm : trace_connect_list_link_lat) {
xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str());
tmgr_trace_t trace = traces_set_list.at(elm.first);
sg_link_t link = simgrid::s4u::Link::byName(elm.second.c_str());
return a->name() < b->name();
});
bool first = true;
- for (auto np : list) {
+ for (auto const& np : list) {
if (np->isNetZone())
continue;
// Make all hosts
std::vector<std::string> radical_elements;
boost::split(radical_elements, radicals, boost::is_any_of(","));
- for (auto group : radical_elements) {
+ for (auto const& group : radical_elements) {
std::vector<std::string> radical_ends;
boost::split(radical_ends, group, boost::is_any_of("-"));
int start = surf_parse_get_int(radical_ends.front());
route.link_list = new std::vector<simgrid::surf::LinkImpl*>();
route.symmetrical = (A_surfxml_route_symmetrical == A_surfxml_route_symmetrical_YES);
- for (auto link: parsed_link_list)
+ for (auto const& link : parsed_link_list)
route.link_list->push_back(link);
parsed_link_list.clear();
ASroute.link_list = new std::vector<simgrid::surf::LinkImpl*>();
- for (auto link: parsed_link_list)
+ for (auto const& link : parsed_link_list)
ASroute.link_list->push_back(link);
parsed_link_list.clear();
route.symmetrical = false;
route.link_list = new std::vector<simgrid::surf::LinkImpl*>();
- for (auto link: parsed_link_list)
+ for (auto const& link : parsed_link_list)
route.link_list->push_back(link);
parsed_link_list.clear();
ASroute.src = sg_netpoint_by_name_or_null(A_surfxml_bypassZoneRoute_src);
ASroute.dst = sg_netpoint_by_name_or_null(A_surfxml_bypassZoneRoute_dst);
ASroute.link_list = new std::vector<simgrid::surf::LinkImpl*>();
- for (auto link: parsed_link_list)
+ for (auto const& link : parsed_link_list)
ASroute.link_list->push_back(link);
parsed_link_list.clear();
void ETag_surfxml_config()
{
- for (auto elm : *current_property_set) {
+ for (auto const& elm : *current_property_set) {
if (xbt_cfg_is_default_value(elm.first.c_str())) {
std::string cfg = elm.first + ":" + elm.second;
xbt_cfg_set_parse(cfg.c_str());
static bool parseBool(const char* value)
{
- for (const char* true_value : true_values)
+ for (const char* const& true_value : true_values)
if (std::strcmp(true_value, value) == 0)
return true;
- for (const char* false_value : false_values)
+ for (const char* const& false_value : false_values)
if (std::strcmp(false_value, value) == 0)
return false;
throw std::range_error("not a boolean");
Config::~Config()
{
XBT_DEBUG("Frees cfg set %p", this);
- for (auto elm : options)
+ for (auto const& elm : options)
delete elm.second;
}
if (name)
printf("%s>> Dumping of the config set '%s':\n", indent, name);
- for (auto elm : options)
+ for (auto const& elm : options)
printf("%s %s: ()%s) %s", indent, elm.first.c_str(), elm.second->getTypeName(),
elm.second->getStringValue().c_str());
{
bool old_warn_for_aliases = false;
std::swap(warn_for_aliases, old_warn_for_aliases);
- for (auto elm : aliases)
+ for (auto const& elm : aliases)
printf(" %s: %s\n", elm.first.c_str(), (*this)[elm.first.c_str()].getDescription().c_str());
std::swap(warn_for_aliases, old_warn_for_aliases);
}
/** @brief Displays the declared options and their description */
void Config::help()
{
- for (auto elm : options) {
+ for (auto const& elm : options) {
simgrid::config::ConfigurationElement* variable = this->options.at(elm.first);
printf(" %s: %s\n", elm.first.c_str(), variable->getDescription().c_str());
printf(" Type: %s; ", variable->getTypeName());
char** c_action = new char*[action->size() + 1];
action_fun function = action_funs.at(action->at(1));
int i = 0;
- for (auto arg : *action) {
+ for (auto const& arg : *action) {
c_action[i] = xbt_strdup(arg.c_str());
i++;
}
std::vector<simgrid::s4u::ActorPtr>* actor_list = new std::vector<simgrid::s4u::ActorPtr>();
simgrid::s4u::this_actor::getHost()->actorList(actor_list);
- for (auto actor : *actor_list) {
+ for (auto const& actor : *actor_list) {
XBT_INFO("Actor (pid=%lu, ppid=%lu, name=%s)", actor->getPid(), actor->getPpid(), actor->getName().c_str());
if (simgrid::s4u::this_actor::getPid() != actor->getPid())
actor->kill();
if (not props->empty()) {
XBT_INFO("\tProperties of mounted storage: %s", storage->getName());
- for (auto elm : *props) {
+ for (auto const& elm : *props) {
XBT_INFO(" %s->%s", elm.first.c_str(), elm.second.c_str());
}
} else {
XBT_INFO("Print the content of the storage element: %s", storage->getName());
std::map<std::string, sg_size_t>* content = storage->getContent();
if (not content->empty()) {
- for (auto entry : *content)
+ for (auto const& entry : *content)
XBT_INFO("\t%s size: %llu bytes", entry.first.c_str(), entry.second);
} else {
XBT_INFO("\tNo content.");
{
std::map<std::string, simgrid::s4u::Storage*>* storages = simgrid::s4u::allStorages();
- for (auto storage : *storages) {
+ for (auto const& storage : *storages) {
XBT_INFO("Storage %s is attached to %s", storage.first.c_str(), storage.second->getHost()->getCname());
storage.second->setProperty("other usage", "gpfs");
}
{
XBT_INFO("*** Storage info on %s ***", host->getCname());
- for (auto elm : host->getMountedStorages()) {
+ for (auto const& elm : host->getMountedStorages()) {
const char* mount_name = elm.first.c_str();
simgrid::s4u::Storage* storage = elm.second;
XBT_INFO("\tStorage name: %s, mount name: %s", storage->getName(), mount_name);
}
if (props && not props->empty()) {
std::printf(">\n");
- for (auto kv : *props) {
+ for (auto const& kv : *props) {
std::printf(" <prop id=\"%s\" value=\"%s\"/>\n", kv.first.c_str(), kv.second.c_str());
}
std::printf(" </host>\n");
return a->name() < b->name();
});
- for (auto srcCard : netcardList)
+ for (auto const& srcCard : netcardList)
if (srcCard->isRouter())
std::printf(" <router id=\"%s\"/>\n", srcCard->cname());
simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(netcardSrc, netcardDst, &route, nullptr);
if (not route.empty()) {
std::printf(" <route src=\"%s\" dst=\"%s\">\n ", host1->getCname(), host2->getCname());
- for (auto link : route)
+ for (auto const& link : route)
std::printf("<link_ctn id=\"%s\"/>", link->cname());
std::printf("\n </route>\n");
}
}
- for (auto netcardDst : netcardList) { // to router
+ for (auto const& netcardDst : netcardList) { // to router
if (netcardDst->isRouter()) {
std::printf(" <route src=\"%s\" dst=\"%s\">\n ", host1->getCname(), netcardDst->cname());
std::vector<simgrid::surf::LinkImpl*> route;
simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(netcardSrc, netcardDst, &route, nullptr);
- for (auto link : route)
+ for (auto const& link : route)
std::printf("<link_ctn id=\"%s\"/>", link->cname());
std::printf("\n </route>\n");
}
}
}
- for (auto value1 : netcardList) { // Routes from router
+ for (auto const& value1 : netcardList) { // Routes from router
if (value1->isRouter()) {
- for (auto value2 : netcardList) { // to router
+ for (auto const& value2 : netcardList) { // to router
if (value2->isRouter()) {
std::printf(" <route src=\"%s\" dst=\"%s\">\n ", value1->cname(), value2->cname());
std::vector<simgrid::surf::LinkImpl*> route;
simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(value1, value2, &route, nullptr);
- for (auto link : route)
+ for (auto const& link : route)
std::printf("<link_ctn id=\"%s\"/>", link->cname());
std::printf("\n </route>\n");
}
std::vector<simgrid::surf::LinkImpl*> route;
simgrid::kernel::routing::NetPoint* netcardDst = host2->pimpl_netpoint;
simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(value1, netcardDst, &route, nullptr);
- for (auto link : route)
+ for (auto const& link : route)
std::printf("<link_ctn id=\"%s\"/>", link->cname());
std::printf("\n </route>\n");
}
xbt_dynar_free(&hosts);
std::printf("NetCards count: %zu\n", netcardList.size());
- for (auto nc : netcardList)
+ for (auto const& nc : netcardList)
std::printf(" - Seen: \"%s\". Type: %s\n", nc->cname(),
nc->isRouter() ? "router" : (nc->isNetZone() ? "netzone" : (nc->isHost() ? "host" : "buggy")));
double now = surf_get_clock();
XBT_INFO("Next Event : %g", now);
- for (auto model: *all_existing_models) {
+ for (auto const& model : *all_existing_models) {
if (surf_model_running_action_set_size(model)) {
XBT_DEBUG("\t Running that model");
running = 1;