// Add the peers the tracker gave us to our peer list.
for (auto const& peer_id : answer->getPeers())
if (id != peer_id)
- connected_peers.emplace(peer_id, Connection(peer_id));
+ connected_peers.try_emplace(peer_id, Connection(peer_id));
} catch (const simgrid::TimeoutException&) {
XBT_DEBUG("Timeout expired when requesting peers to tracker");
return false;
// Check if the peer is in our connection list.
if (remote_peer == nullptr) {
XBT_DEBUG("This peer %d was unknown, answer to its handshake", message->peer_id);
- connected_peers.emplace(message->peer_id, Connection(message->peer_id));
+ connected_peers.try_emplace(message->peer_id, Connection(message->peer_id));
sendMessage(message->return_mailbox, MessageType::HANDSHAKE, message_size(MessageType::HANDSHAKE));
}
// Send our bitfield to the peer
ACT_DEBUG("Entering Open: %s (filename: %s)", NAME.c_str(), file_name.c_str());
auto* file = sg4::File::open(file_name, nullptr);
- opened_files.emplace(full_name, file);
+ opened_files.try_emplace(full_name, file);
log_action(action, sg4::Engine::get_clock() - clock);
}
std::map<std::string, sg_size_t, std::less<>>* get_content() const { return content_.get(); }
const char* get_mount_point() const { return mount_point_.c_str(); }
const char* get_mount_point(s4u::Host* remote_host) { return remote_mount_points_[remote_host].c_str(); }
- void add_remote_mount(Host* host, const std::string& mount_point)
- {
- remote_mount_points_.insert({host, mount_point});
- }
+ void add_remote_mount(Host* host, const std::string& mount_point);
sg_size_t get_size() const { return size_; }
sg_size_t get_used_size() const { return used_size_; }
void decr_used_size(sg_size_t size);
if (activities.find(name) == activities.end()) {
XBT_DEBUG("See <Exec id = %s amount = %.0f>", name.c_str(), amount);
act = Exec::init()->set_name(name)->set_flops_amount(amount)->vetoable_start();
- activities.insert({name, act});
+ activities.try_emplace(name, act);
if (name != "root" && name != "end")
dag.push_back(act);
} else {
act = Comm::sendto_init()->set_name(name)->set_payload_size(size)->vetoable_start();
src->add_successor(act);
act->add_successor(dst);
- activities.insert({name, act});
+ activities.try_emplace(name, act);
dag.push_back(act);
} else {
XBT_WARN("Comm '%s' is defined more than once", name.c_str());
runtime *= 4200000000.; /* Assume that timings were done on a 4.2GFlops machine. I mean, why not? */
XBT_DEBUG("See <job id=%s runtime=%s %.0f>", A_dax__job_id, A_dax__job_runtime, runtime);
simgrid::s4u::current_job = simgrid::s4u::Exec::init()->set_name(name)->set_flops_amount(runtime)->vetoable_start();
- simgrid::s4u::jobs.insert({A_dax__job_id, simgrid::s4u::current_job});
+ simgrid::s4u::jobs.try_emplace(A_dax__job_id, simgrid::s4u::current_job);
simgrid::s4u::result.push_back(simgrid::s4u::current_job);
} catch (const std::invalid_argument&) {
throw std::invalid_argument(std::string("Parse error: ") + A_dax__job_runtime + " is not a double");
if (parent_) {
std::string type_name = std::string("L") + std::to_string(level);
type_ = parent_->type_->by_name_or_create<ContainerType>(type_name);
- parent_->children_.insert({get_name(), this});
+ parent_->children_.try_emplace(get_name(), this);
on_creation(*this);
} else {
type_ = new ContainerType("0");
if (not type_name.empty()) {
type_ = parent_->type_->by_name_or_create<ContainerType>(type_name);
- parent_->children_.insert({name_, this});
+ parent_->children_.try_emplace(name_, this);
on_creation(*this);
}
}
//register all kinds by name
- if (not all_containers_.emplace(name_, this).second)
+ if (not all_containers_.try_emplace(name_, this).second)
throw TracingError(XBT_THROW_POINT,
xbt::string_printf("container %s already present in all_containers_", get_cname()));
auto it = values_.find(name);
if (it == values_.end()) {
XBT_DEBUG("new value %s, child of %s", name.c_str(), get_cname());
- values_.emplace(name, EntityValue(name, color, this));
+ values_.try_emplace(name, EntityValue(name, color, this));
}
}
void WifiLinkImpl::set_host_rate(const s4u::Host* host, int rate_level)
{
- auto insert_done = host_rates_.insert(std::make_pair(host->get_name(), rate_level));
+ auto insert_done = host_rates_.try_emplace(host->get_name(), rate_level);
if (not insert_done.second)
insert_done.first->second = rate_level;
: name(name), cb(cb), repeat_delay(repeat_delay)
{
xbt_assert(trace_list.find(name) == trace_list.end(), "Refusing to define trace %s twice", name.c_str());
- trace_list.insert({name,this});
+ trace_list.try_emplace(name, this);
get_enough_events(0);
}
void ClusterBase::add_private_link_at(unsigned long position,
std::pair<resource::StandardLinkImpl*, resource::StandardLinkImpl*> link)
{
- private_links_.insert({position, link});
+ private_links_.try_emplace(position, link);
}
void ClusterBase::set_gateway(unsigned long position, NetPoint* gateway)
insert_link_latency(route->link_list_, e_route->link_list_, lat);
}
- auto elm = route_cache_.emplace(src_id, std::vector<unsigned long>());
+ auto elm = route_cache_.try_emplace(src_id, std::vector<unsigned long>());
std::vector<unsigned long>& pred_arr = elm.first->second;
if (elm.second) { /* new element was inserted (not cached mode, or cache miss) */
position++;
newNode->parents.resize(static_cast<size_t>(this->num_parents_per_node_[0]) * this->num_port_lower_level_[0]);
newNode->label.resize(this->levels_);
- this->compute_nodes_.insert(make_pair(id, newNode));
+ this->compute_nodes_.try_emplace(id, newNode);
this->nodes_.emplace_back(newNode);
}
newRoute->links.insert(newRoute->links.end(), begin(converted_list), end(converted_list));
/* Store it */
- bypass_routes_.insert({{src, dst}, newRoute});
+ bypass_routes_.try_emplace({src, dst}, newRoute);
}
/** @brief Get the common ancestor and its first children in each line leading to src and dst
{
/* add default empty links if nothing was configured by user */
for (auto const& node : get_vertices()) {
- auto route = routes_.emplace(node->id(), StarRoute());
+ auto route = routes_.try_emplace(node->id(), StarRoute());
if (route.second) {
route.first->second.links_down_set = true;
route.first->second.links_up_set = true;
return parse_content;
}
+void FileSystemDiskExt::add_remote_mount(Host* host, const std::string& mount_point)
+{
+ remote_mount_points_.try_emplace(host, mount_point);
+}
+
void FileSystemDiskExt::decr_used_size(sg_size_t size)
{
simgrid::kernel::actor::simcall_answered([this, size] { used_size_ -= size; });
{
/* two actors may have pushed the same mbox_create simcall at the same time */
kernel::activity::MailboxImpl* mbox = kernel::actor::simcall_answered([&name, this] {
- auto m = pimpl->mailboxes_.emplace(name, nullptr);
+ auto m = pimpl->mailboxes_.try_emplace(name, nullptr);
if (m.second) {
m.first->second = new kernel::activity::MailboxImpl(name);
XBT_DEBUG("Creating a mailbox at %p with name %s", m.first->second, name.c_str());
smpi_process()->set_sampling(1);
}
- auto insert = samples.emplace(loc, LocalData{
- threshold, // threshold
- 0.0, // relstderr
- 0.0, // mean
- 0.0, // sum
- 0.0, // sum_pow2
- iters, // iters
- 0, // count
- true // benching (if we have no data, we need at least one)
- });
+ auto insert = samples.try_emplace(loc, LocalData{
+ threshold, // threshold
+ 0.0, // relstderr
+ 0.0, // mean
+ 0.0, // sum
+ 0.0, // sum_pow2
+ iters, // iters
+ 0, // count
+ true // benching (if we have no data, we need at least one)
+ });
if (insert.second) {
XBT_DEBUG("XXXXX First time ever on benched nest %s.", loc.c_str());
xbt_assert(threshold > 0 || iters > 0,
auto end = std::next(tok.begin());
std::string location = *it;
boost::trim(location);
- location2speedup.insert(std::pair<std::string, double>(location, std::stod(*end)));
+ location2speedup.try_emplace(location, std::stod(*end));
}
}
}};
if (code != nullptr) // When started with smpirun, we will not execute a function
simgrid::s4u::Engine::get_instance()->register_function(name, code);
- Instance instance(num_processes);
-
- smpi_instances.insert(std::pair<std::string, Instance>(name, instance));
+ smpi_instances.try_emplace(name, Instance(num_processes));
}
void smpi_deployment_register_process(const std::string& instance_id, int rank, const simgrid::s4u::Actor* actor)
std::string unit_name = *(event_tokens.begin());
papi_process_data config = {.counter_data = std::move(counters2values), .event_set = event_set};
- units2papi_setup.insert(std::make_pair(unit_name, std::move(config)));
+ units2papi_setup.try_emplace(unit_name, std::move(config));
}
#endif
}
{
void* mem;
smpi_source_location loc(file, line);
- auto res = allocs.insert(std::make_pair(loc, shared_data_t()));
+ auto res = allocs.try_emplace(loc, shared_data_t());
auto data = res.first;
if (res.second) {
// The new element was inserted.
metadata.line = line;
metadata.numcall = 1;
metadata.file = file;
- allocs.emplace(ptr, metadata);
+ allocs.try_emplace(ptr, metadata);
total_malloc_size += size;
if(size > max_malloc.size){
key += " at " + elem.second->call_location();
else
display_advice = true;
- auto result = count.emplace(key, 1);
+ auto result = count.try_emplace(key, 1);
if (result.second == false)
result.first->second++;
}
std::string key = "leaked allocations";
if (not xbt_log_no_loc)
key = elem.second.file + ":" + std::to_string(elem.second.line) + ": " + key;
- auto result = leaks_aggreg.emplace(key, buff_leak{1, elem.second.size, elem.second.size, elem.second.size});
+ auto result = leaks_aggreg.try_emplace(key, buff_leak{1, elem.second.size, elem.second.size, elem.second.size});
if (result.second == false) {
result.first->second.count++;
result.first->second.total_size += elem.second.size;
comm->increment_collectives_count();
auto vec = collective_calls.find(comm->id());
if (vec == collective_calls.end()) {
- collective_calls.emplace(comm->id(), std::vector<std::string>{call});
+ collective_calls.try_emplace(comm->id(), std::vector<std::string>{call});
} else {
// are we the first ? add the call
if (vec->second.size() == count) {
Datatype::Datatype(const char* name, int ident, int size, MPI_Aint lb, MPI_Aint ub, int flags)
: name_(name), id(std::to_string(ident)), size_(size), lb_(lb), ub_(ub), flags_(flags), refcount_(0)
{
- id2type_lookup.insert({id, this});
+ id2type_lookup.try_emplace(id, this);
#if SIMGRID_HAVE_MC
if(MC_is_active())
MC_ignore(&refcount_, sizeof refcount_);
{
static int id = 0;
auto* ibModel = static_cast<NetworkIBModel*>(host.get_netpoint()->get_englobing_zone()->get_network_model().get());
- ibModel->active_nodes.emplace(host.get_name(), IBNode(id));
+ ibModel->active_nodes.try_emplace(host.get_name(), IBNode(id));
id++;
}
XBT_DEBUG("Create socket %s for a flow of %.0f Bytes from %s to %s with Interface %s",
transform_socket_ptr(sock).c_str(), totalBytes, src->get_cname(), dst->get_cname(), addr.c_str());
- flow_from_sock.insert({transform_socket_ptr(sock), new SgFlow(static_cast<uint32_t>(totalBytes), this)});
- sink_from_sock.insert({transform_socket_ptr(sock), apps});
+ flow_from_sock.try_emplace(transform_socket_ptr(sock), new SgFlow(static_cast<uint32_t>(totalBytes), this));
+ sink_from_sock.try_emplace(transform_socket_ptr(sock), apps);
sock->Bind(ns3::InetSocketAddress(port_number));
ns3::Simulator::ScheduleNow(&start_flow, sock, addr.c_str(), port_number);
args->id.c_str());
profile = simgrid::kernel::profile::ProfileBuilder::from_string(args->id, args->pc_data, args->periodicity);
}
- traces_set_list.insert({args->id, profile});
+ traces_set_list.try_emplace(args->id, profile);
}
void STag_surfxml_prop()
{
- property_sets.back().insert({A_surfxml_prop_id, A_surfxml_prop_value});
+ property_sets.back().try_emplace(A_surfxml_prop_id, A_surfxml_prop_value);
XBT_DEBUG("add prop %s=%s into current property set %p", A_surfxml_prop_id, A_surfxml_prop_value,
&(property_sets.back()));
}
xbt_assert(aliases.find(aliasname) == aliases.end(), "Alias '%s' already.", aliasname.c_str());
ConfigurationElement* element = this->get_dict_element(realname);
xbt_assert(element, "Cannot define an alias to the non-existing option '%s'.", realname.c_str());
- this->aliases.insert({aliasname, element});
+ this->aliases.try_emplace(aliasname, element);
}
/** @brief Displays the declared aliases and their replacement */
otherqueue = act->second;
} else { // Damn. Create the queue of that guy
otherqueue = new std::queue<ReplayAction*>();
- action_queues.insert({evtname, otherqueue});
+ action_queues.try_emplace(evtname, otherqueue);
}
otherqueue->push(action);
}