for (auto const& id : bucket->nodes_) {
unsigned int distance = id ^ destination_id_;
- nodes_.push_back(std::pair<unsigned int, unsigned int>(id, distance));
+ nodes_.emplace_back(id, distance);
}
}
} // namespace kademlia
std::vector<std::string> argSender;
std::vector<std::string> argReceiver;
if (argc > 2) {
- argSender.push_back(argv[2]); // Take the amount of flows from the command line
- argReceiver.push_back(argv[2]);
+ argSender.emplace_back(argv[2]); // Take the amount of flows from the command line
+ argReceiver.emplace_back(argv[2]);
} else {
- argSender.push_back("1"); // Default value
- argReceiver.push_back("1");
+ argSender.emplace_back("1"); // Default value
+ argReceiver.emplace_back("1");
}
if (argc > 3) {
std::string size = std::to_string(simgrid::xbt::random::uniform_int(min_size, max_size));
argSender.push_back(size);
} else { // Not "random" ? Then it should be the size to use
- argSender.push_back(argv[3]); // Take the datasize from the command line
+ argSender.emplace_back(argv[3]); // Take the datasize from the command line
}
} else { // No parameter at all? Then use the default value
- argSender.push_back("25000");
+ argSender.emplace_back("25000");
}
simgrid::s4u::Actor::create("sender", simgrid::s4u::Host::by_name("MyHost1"), sender, argSender);
simgrid::s4u::Actor::create("receiver", simgrid::s4u::Host::by_name("MyHost2"), receiver, argReceiver);
void Event::add_characteristic(const char* characteristic)
{
xbt_assert( characteristic != nullptr );
- this->characteristics_list_.push_back(characteristic);
+ this->characteristics_list_.emplace_back(characteristic);
}
void Event::add_info(char* key, char* value)
other_comm->clean_fun = clean_fun;
} else {
other_comm->clean_fun = nullptr;
- src_proc->activities_.push_back(other_comm);
+ src_proc->activities_.emplace_back(other_comm);
}
/* Setup the communication synchro */
other_comm->state_ = simgrid::kernel::activity::State::READY;
other_comm->set_type(simgrid::kernel::activity::CommImpl::Type::READY);
}
- receiver->activities_.push_back(other_comm);
+ receiver->activities_.emplace_back(other_comm);
}
/* Setup communication synchro */
actor::ActorImpl* self = actor::ActorImpl::self();
if (self) {
actor_ = self;
- self->activities_.push_back(this);
+ self->activities_.emplace_back(this);
}
}
REQUIRE(it == insertedIt); // Check that we find what we've put
if (value >= 0) {
- res.push_back(simgrid::kernel::profile::DatedValue(thedate, value));
+ res.emplace_back(thedate, value);
} else {
XBT_DEBUG("%.1f: ignore an event (idx: %u)\n", thedate, it->idx);
}
std::vector<simgrid::kernel::profile::DatedValue> got = trace2vector("9.0 3.0\n");
std::vector<simgrid::kernel::profile::DatedValue> want;
- want.push_back(simgrid::kernel::profile::DatedValue(9, 3));
+ want.emplace_back(9, 3);
REQUIRE(want == got);
}
"9.0 3.0\n");
std::vector<simgrid::kernel::profile::DatedValue> want;
- want.push_back(simgrid::kernel::profile::DatedValue(3, 1));
- want.push_back(simgrid::kernel::profile::DatedValue(9, 3));
+ want.emplace_back(3, 1);
+ want.emplace_back(9, 3);
REQUIRE(want == got);
}
"9.0 3.0\n");
std::vector<simgrid::kernel::profile::DatedValue> want;
- want.push_back(simgrid::kernel::profile::DatedValue(3, 1));
- want.push_back(simgrid::kernel::profile::DatedValue(5, 2));
- want.push_back(simgrid::kernel::profile::DatedValue(9, 3));
+ want.emplace_back(3, 1);
+ want.emplace_back(5, 2);
+ want.emplace_back(9, 3);
REQUIRE(want == got);
}
"LOOPAFTER 2\n");
std::vector<simgrid::kernel::profile::DatedValue> want;
- want.push_back(simgrid::kernel::profile::DatedValue(1, 1));
- want.push_back(simgrid::kernel::profile::DatedValue(3, 3));
- want.push_back(simgrid::kernel::profile::DatedValue(6, 1));
- want.push_back(simgrid::kernel::profile::DatedValue(8, 3));
- want.push_back(simgrid::kernel::profile::DatedValue(11, 1));
- want.push_back(simgrid::kernel::profile::DatedValue(13, 3));
- want.push_back(simgrid::kernel::profile::DatedValue(16, 1));
- want.push_back(simgrid::kernel::profile::DatedValue(18, 3));
+ want.emplace_back(1, 1);
+ want.emplace_back(3, 3);
+ want.emplace_back(6, 1);
+ want.emplace_back(8, 3);
+ want.emplace_back(11, 1);
+ want.emplace_back(13, 3);
+ want.emplace_back(16, 1);
+ want.emplace_back(18, 3);
REQUIRE(want == got);
}
"LOOPAFTER 5\n");
std::vector<simgrid::kernel::profile::DatedValue> want;
- want.push_back(simgrid::kernel::profile::DatedValue(0, 1));
- want.push_back(simgrid::kernel::profile::DatedValue(5, 2));
- want.push_back(simgrid::kernel::profile::DatedValue(10, 1));
- want.push_back(simgrid::kernel::profile::DatedValue(15, 2));
- want.push_back(simgrid::kernel::profile::DatedValue(20, 1));
+ want.emplace_back(0, 1);
+ want.emplace_back(5, 2);
+ want.emplace_back(10, 1);
+ want.emplace_back(15, 2);
+ want.emplace_back(20, 1);
REQUIRE(want == got);
}
if (not host)
throw std::invalid_argument(simgrid::xbt::string_printf("Host '%s' unknown", process_host));
actor.host = process_host;
- actor.args.push_back(process_function);
+ actor.args.emplace_back(process_function);
/* add arguments */
unsigned int i;
char *arg;
xbt_dynar_foreach(arguments, i, arg) {
- actor.args.push_back(arg);
+ actor.args.emplace_back(arg);
}
// Check we know how to handle this function name:
// merge the ranges of every process
std::vector<std::pair<MPI_Offset, MPI_Offset>> ranges;
for (int i = 0; i < size; ++i)
- ranges.push_back(std::make_pair(min_offsets[i], max_offsets[i]));
+ ranges.emplace_back(min_offsets[i], max_offsets[i]);
std::sort(ranges.begin(), ranges.end());
std::vector<std::pair<MPI_Offset, MPI_Offset>> chunks;
chunks.push_back(ranges[0]);
}
else {
src_private_blocks.clear();
- src_private_blocks.push_back(std::make_pair(0, buff_size));
+ src_private_blocks.emplace_back(0, buff_size);
}
if (smpi_is_shared((char*)comm->dst_buff_, dst_private_blocks, &dst_offset)) {
dst_private_blocks = shift_and_frame_private_blocks(dst_private_blocks, dst_offset, buff_size);
}
else {
dst_private_blocks.clear();
- dst_private_blocks.push_back(std::make_pair(0, buff_size));
+ dst_private_blocks.emplace_back(0, buff_size);
}
check_blocks(src_private_blocks, buff_size);
check_blocks(dst_private_blocks, buff_size);
#else
xbt_die("smpi/privatize-libs is not (yet) compatible with OSX nor with Haiku");
#endif
- privatize_libs_paths.push_back(fullpath);
+ privatize_libs_paths.emplace_back(fullpath);
dlclose(libhandle);
}
}
req_storage.get_requests(reqs);
for (auto const& req : reqs) {
if (req && (req->flags() & MPI_REQ_RECV)) {
- sender_receiver.push_back({req->src(), req->dst()});
+ sender_receiver.emplace_back(req->src(), req->dst());
}
}
Request::waitall(count_requests, &(reqs.data())[0], MPI_STATUSES_IGNORE);
newmeta.allocated_ptr = allocated_ptr;
newmeta.allocated_size = allocated_size;
if(shared_block_offsets[0] > 0) {
- newmeta.private_blocks.push_back(std::make_pair(0, shared_block_offsets[0]));
+ newmeta.private_blocks.emplace_back(0, shared_block_offsets[0]);
}
int i_block;
for(i_block = 0; i_block < nb_shared_blocks-1; i_block ++) {
- newmeta.private_blocks.push_back(std::make_pair(shared_block_offsets[2*i_block+1], shared_block_offsets[2*i_block+2]));
+ newmeta.private_blocks.emplace_back(shared_block_offsets[2 * i_block + 1], shared_block_offsets[2 * i_block + 2]);
}
if(shared_block_offsets[2*i_block+1] < size) {
- newmeta.private_blocks.push_back(std::make_pair(shared_block_offsets[2*i_block+1], size));
+ newmeta.private_blocks.emplace_back(shared_block_offsets[2 * i_block + 1], size);
}
allocs_metadata[mem] = newmeta;
for (int j = i + 1; j < size; j++) {
if(recvbuf[2 * i] == recvbuf[2 * j]) {
recvbuf[2 * j] = MPI_UNDEFINED;
- rankmap.push_back({recvbuf[2 * j + 1], j});
+ rankmap.emplace_back(recvbuf[2 * j + 1], j);
}
}
/* Add self in the group */
recvbuf[2 * i] = MPI_UNDEFINED;
- rankmap.push_back({recvbuf[2 * i + 1], i});
+ rankmap.emplace_back(recvbuf[2 * i + 1], i);
std::sort(begin(rankmap), end(rankmap));
group_out = new Group(rankmap.size());
if (i == 0) {
{
std::vector<s4u::ActorPtr> res;
for (auto& actor : actor_list_)
- res.push_back(actor.ciface());
+ res.emplace_back(actor.ciface());
return res;
}
size_t HostImpl::get_actor_count() const
}
void STag_surfxml_argument(){
- arguments.push_back(A_surfxml_argument_value);
+ arguments.emplace_back(A_surfxml_argument_value);
}
void STag_surfxml_model___prop(){
simgrid::xbt::binary_name = argv[0];
for (int i = 0; i < *argc; i++)
- simgrid::xbt::cmdline.push_back(argv[i]);
+ simgrid::xbt::cmdline.emplace_back(argv[i]);
xbt_log_init(argc, argv);
}
if (argc >= 3) {
argSend.clear();
- argSend.push_back(argv[2]);
+ argSend.emplace_back(argv[2]);
}
if (argc >= 4) {
argRecv.clear();
- argRecv.push_back(argv[3]);
+ argRecv.emplace_back(argv[3]);
}
xbt_assert(argSend.front().size() == argRecv.front().size(), "Sender and receiver spec must be of the same size");