Some of them were redundant.
Some of them became optional after the removal of xbt::string.
.. code-block:: cpp
for (int i = 0; i < tasks_count; i++) {
- std::string worker_rank = std::to_string(i % workers_count);
- std::string mailbox_name = std::string("worker-") + worker_rank;
+ std::string worker_rank = std::to_string(i % workers_count);
+ std::string mailbox_name = "worker-" + worker_rank;
simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name);
mailbox->put(...);
for (int i = 0; i < tasks_count; i++) { /* For each task to be executed: */
/* - Select a worker in a round-robin way */
- std::string worker_rank = std::to_string(i % workers_count);
- std::string mailbox_name = std::string("worker-") + worker_rank;
- simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name);
+ std::string worker_rank = std::to_string(i % workers_count);
+ std::string mailbox_name = "worker-" + worker_rank;
+ simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name);
/* - Send the computation cost to that worker */
XBT_INFO("Sending task %d of %ld to mailbox '%s'", i, tasks_count, mailbox->get_cname());
XBT_INFO("All tasks have been dispatched. Request all workers to stop.");
for (int i = 0; i < workers_count; i++) {
/* The workers stop when receiving a negative compute_cost */
- std::string mailbox_name = std::string("worker-") + std::to_string(i);
- simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name);
+ std::string mailbox_name = "worker-" + std::to_string(i);
+ simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name);
mailbox->put(new double(-1.0), 0);
}
xbt_assert(args.size() == 2, "The worker expects a single argument");
long id = std::stol(args[1]);
- const std::string mailbox_name = std::string("worker-") + std::to_string(id);
- simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name);
+ const std::string mailbox_name = "worker-" + std::to_string(id);
+ simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name);
double compute_cost;
do {
static void worker()
{
- const std::string mailbox_name = std::string("worker-") + std::to_string(simgrid::s4u::this_actor::get_pid());
- simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name);
+ const std::string mailbox_name = "worker-" + std::to_string(simgrid::s4u::this_actor::get_pid());
+ simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name);
double compute_cost;
do {
std::vector<simgrid::s4u::ActorPtr> actors;
for (auto* host : simgrid::s4u::Engine::get_instance()->get_all_hosts()) {
- simgrid::s4u::ActorPtr act = simgrid::s4u::Actor::create(std::string("Worker-") + host->get_name(), host, worker);
+ simgrid::s4u::ActorPtr act = simgrid::s4u::Actor::create("Worker-" + host->get_name(), host, worker);
actors.push_back(act);
}
for (int i = 0; i < tasks_count; i++) { /* For each task to be executed: */
/* - Select a worker in a round-robin way */
- aid_t worker_pid = actors.at(i % actors.size())->get_pid();
- std::string mailbox_name = std::string("worker-") + std::to_string(worker_pid);
- simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name);
+ aid_t worker_pid = actors.at(i % actors.size())->get_pid();
+ std::string mailbox_name = "worker-" + std::to_string(worker_pid);
+ simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name);
/* - Send the computation cost to that worker */
XBT_INFO("Sending task %d of %ld to mailbox '%s'", i, tasks_count, mailbox->get_cname());
XBT_INFO("All tasks have been dispatched. Request all workers to stop.");
for (unsigned long i = 0; i < actors.size(); i++) {
/* The workers stop when receiving a negative compute_cost */
- std::string mailbox_name = std::string("worker-") + std::to_string(actors.at(i)->get_pid());
- simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name);
+ std::string mailbox_name = "worker-" + std::to_string(actors.at(i)->get_pid());
+ simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name);
mailbox->put(new double(-1.0), 0);
}
static void worker()
{
- const std::string mailbox_name = std::string("worker-") + std::to_string(simgrid::s4u::this_actor::get_pid());
- simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name);
+ const std::string mailbox_name = "worker-" + std::to_string(simgrid::s4u::this_actor::get_pid());
+ simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name);
while (true) { // Master forcefully kills the workers by the end of the simulation
double* msg = mailbox->get<double>();
XBT_INFO("Asked to run for %.1f seconds", simulation_duration);
for (auto* host : e->get_all_hosts()) {
- simgrid::s4u::ActorPtr act = simgrid::s4u::Actor::create(std::string("Worker-") + host->get_name(), host, worker);
+ simgrid::s4u::ActorPtr act = simgrid::s4u::Actor::create("Worker-" + host->get_name(), host, worker);
actors.push_back(act);
}
int task_id = 0;
while (simgrid::s4u::Engine::get_clock() < simulation_duration) { /* For each task: */
/* - Select a worker in a round-robin way */
- aid_t worker_pid = actors.at(task_id % actors.size())->get_pid();
- std::string mailbox_name = std::string("worker-") + std::to_string(worker_pid);
- simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name);
+ aid_t worker_pid = actors.at(task_id % actors.size())->get_pid();
+ std::string mailbox_name = "worker-" + std::to_string(worker_pid);
+ simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name);
/* - Send the computation cost to that worker */
if (task_id % 100 == 0)
static void worker(std::string category)
{
- const std::string mailbox_name = std::string("worker-") + std::to_string(simgrid::s4u::this_actor::get_pid());
- simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name);
+ const std::string mailbox_name = "worker-" + std::to_string(simgrid::s4u::this_actor::get_pid());
+ simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name);
while (true) { // Master forcefully kills the workers by the end of the simulation
double* msg = mailbox->get<double>();
std::vector<simgrid::s4u::ActorPtr> actors;
simgrid::s4u::Engine* e = simgrid::s4u::Engine::get_instance();
- std::string my_name = std::string("master-") + std::to_string(simgrid::s4u::this_actor::get_pid());
+ std::string my_name = "master-" + std::to_string(simgrid::s4u::this_actor::get_pid());
XBT_INFO("Asked to run for %.1f seconds", simulation_duration);
for (auto* host : e->get_all_hosts()) {
- simgrid::s4u::ActorPtr act =
- simgrid::s4u::Actor::create(std::string("Worker-") + host->get_name(), host, worker, my_name);
+ simgrid::s4u::ActorPtr act = simgrid::s4u::Actor::create("Worker-" + host->get_name(), host, worker, my_name);
actors.push_back(act);
}
int task_id = 0;
while (simgrid::s4u::Engine::get_clock() < simulation_duration) { /* For each task: */
/* - Select a worker in a round-robin way */
- aid_t worker_pid = actors.at(task_id % actors.size())->get_pid();
- std::string mailbox_name = std::string("worker-") + std::to_string(worker_pid);
- simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name);
+ aid_t worker_pid = actors.at(task_id % actors.size())->get_pid();
+ std::string mailbox_name = "worker-" + std::to_string(worker_pid);
+ simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name);
/* - Send the computation cost to that worker */
XBT_DEBUG("Sending task %d to mailbox '%s'", task_id, mailbox->get_cname());
static void bob()
{
- sg4::Mailbox* mbox = sg4::Mailbox::by_name(std::string("mbox"));
+ sg4::Mailbox* mbox = sg4::Mailbox::by_name("mbox");
const sg4::Disk* disk = sg4::Host::current()->get_disks().front();
std::string* payload;
{
auto* payload = new std::string("Message");
XBT_INFO("Send '%s'", payload->c_str());
- sg4::Mailbox::by_name(std::string("mbox"))->put(payload, 6e8);
+ sg4::Mailbox::by_name("mbox")->put(payload, 6e8);
}
int main(int argc, char* argv[])
static void bob()
{
- sg4::Mailbox* mbox = sg4::Mailbox::by_name(std::string("mbox"));
+ sg4::Mailbox* mbox = sg4::Mailbox::by_name("mbox");
const sg4::Disk* disk = sg4::Host::current()->get_disks().front();
std::string* payload;
{
auto* payload = new std::string("Message");
XBT_INFO("Send '%s'", payload->c_str());
- sg4::Mailbox::by_name(std::string("mbox"))->put(payload, 6e8);
+ sg4::Mailbox::by_name("mbox")->put(payload, 6e8);
}
int main(int argc, char* argv[])
Broadcaster(int hostcount, unsigned int piece_count) : piece_count(piece_count)
{
for (int i = 1; i <= hostcount; i++) {
- std::string name = std::string("node-") + std::to_string(i) + ".simgrid.org";
+ std::string name = "node-" + std::to_string(i) + ".simgrid.org";
XBT_DEBUG("%s", name.c_str());
mailboxes.push_back(sg4::Mailbox::by_name(name));
}
static void launch_communication_worker(s4u_Host* tx_host, s4u_Host* rx_host)
{
- std::string mbox_name = std::string("MBOX:") + tx_host->get_cname() + "-" + rx_host->get_cname();
+ std::string mbox_name = "MBOX:" + tx_host->get_name() + "-" + rx_host->get_name();
std::vector<std::string> args;
args.push_back(mbox_name);
std::vector<sg4::Mailbox*> mboxes;
/* Start dispatching 1 message to all receivers */
- std::string msg_content =
- std::string("Hello, I'm alive and running on ") + std::string(sg4::this_actor::get_host()->get_name());
+ std::string msg_content = "Hello, I'm alive and running on " + sg4::this_actor::get_host()->get_name();
for (const auto* host : hosts_) {
/* Copy the data we send: the 'msg_content' variable is not a stable storage location.
* It will be destroyed when this actor leaves the loop, ie before the receiver gets it */
sg4::Actor::create("sender", host_list[0], Sender(host_list));
/* create receiver in every host */
for (auto* host : host_list) {
- sg4::Actor::create(std::string("receiver-") + std::string(host->get_name()), host, Receiver());
+ sg4::Actor::create("receiver-" + host->get_name(), host, Receiver());
}
/* runs the simulation */
{
/* Set myself as the persistent receiver of my mailbox so that messages start flowing to me as soon as they are put
* into it */
- sg4::Mailbox* my_mbox = sg4::Mailbox::by_name(std::string("peer-") + std::to_string(my_id));
+ sg4::Mailbox* my_mbox = sg4::Mailbox::by_name("peer-" + std::to_string(my_id));
my_mbox->set_receiver(sg4::Actor::self());
std::vector<sg4::CommPtr> pending_comms;
for (int i = 0; i < messages_count; i++) {
for (int peer_id = 0; peer_id < peers_count; peer_id++) {
if (peer_id != my_id) {
- sg4::Mailbox* mbox = sg4::Mailbox::by_name(std::string("peer-") + std::to_string(peer_id));
- std::string message = std::string("Message ") + std::to_string(i) + " from peer " + std::to_string(my_id);
+ sg4::Mailbox* mbox = sg4::Mailbox::by_name("peer-" + std::to_string(peer_id));
+ std::string message = "Message " + std::to_string(i) + " from peer " + std::to_string(my_id);
auto* payload = new std::string(message); // copy the data we send:
// 'message' is not a stable storage location
XBT_INFO("Send '%s' to '%s'", message.c_str(), mbox->get_cname());
/* Start sending messages to let peers know that they should stop */
for (int peer_id = 0; peer_id < peers_count; peer_id++) {
if (peer_id != my_id) {
- sg4::Mailbox* mbox = sg4::Mailbox::by_name(std::string("peer-") + std::to_string(peer_id));
+ sg4::Mailbox* mbox = sg4::Mailbox::by_name("peer-" + std::to_string(peer_id));
auto* payload = new std::string("finalize"); // Make a copy of the data we will send
pending_comms.push_back(mbox->put_async(payload, payload_size));
XBT_INFO("Send 'finalize' to 'peer-%d'", peer_id);
/* Start dispatching all messages to receiver */
for (int i = 0; i < messages_count; i++) {
- std::string msg_content = std::string("Message ") + std::to_string(i);
+ std::string msg_content = "Message " + std::to_string(i);
// Copy the data we send: the 'msg_content' variable is not a stable storage location.
// It will be destroyed when this actor leaves the loop, ie before the receiver gets it
auto* payload = new std::string(msg_content);
static void rank0()
{
- sg4::Mailbox* mbox = sg4::Mailbox::by_name(std::string("rank0"));
+ sg4::Mailbox* mbox = sg4::Mailbox::by_name("rank0");
std::string* msg1;
std::string* msg2;
std::string* msg3;
XBT_INFO("Send some data to rank-1");
for (int i = 0; i < 3; i++)
- sg4::Mailbox::by_name(std::string("rank1"))->put(new int(i), 1);
+ sg4::Mailbox::by_name("rank1")->put(new int(i), 1);
XBT_INFO("Test for completed comms");
while (not pending_comms.empty()) {
static void rank1()
{
- sg4::Mailbox* rank0_mbox = sg4::Mailbox::by_name(std::string("rank0"));
- sg4::Mailbox* rank1_mbox = sg4::Mailbox::by_name(std::string("rank1"));
+ sg4::Mailbox* rank0_mbox = sg4::Mailbox::by_name("rank0");
+ sg4::Mailbox* rank1_mbox = sg4::Mailbox::by_name("rank1");
for (int i = 0; i < 3; i++) {
auto res = rank1_mbox->get_unique<int>();
XBT_INFO("Received %d", *res);
- std::string msg_content = std::string("Message ") + std::to_string(i);
+ std::string msg_content = "Message " + std::to_string(i);
auto* payload = new std::string(msg_content);
XBT_INFO("Send '%s'", msg_content.c_str());
rank0_mbox->put(payload, 1e6);
sg4::this_actor::sleep_for(sleep_start_time);
for (int i = 0; i < messages_count; i++) {
- std::string msg_content = std::string("Message ") + std::to_string(i);
+ std::string msg_content = "Message " + std::to_string(i);
// Copy the data we send: the 'msg_content' variable is not a stable storage location.
// It will be destroyed when this actor leaves the loop, ie before the receiver gets the data
auto* payload = new std::string(msg_content);
/* Make a vector of the mailboxes to use */
std::vector<sg4::Mailbox*> mboxes;
for (unsigned int i = 0; i < receivers_count; i++)
- mboxes.push_back(sg4::Mailbox::by_name(std::string("receiver-") + std::to_string(i)));
+ mboxes.push_back(sg4::Mailbox::by_name("receiver-" + std::to_string(i)));
// sphinx-doc: init-end
/* Start dispatching all messages to receivers, in a round robin fashion */
for (unsigned int i = 0; i < messages_count; i++) {
- std::string msg_content = std::string("Message ") + std::to_string(i);
+ std::string msg_content = "Message " + std::to_string(i);
// Copy the data we send: the 'msg_content' variable is not a stable storage location.
// It will be destroyed when this actor leaves the loop, ie before the receiver gets it
auto* payload = new std::string(msg_content);
/* Receiver actor expects 1 argument: its ID */
static void receiver(int id)
{
- sg4::Mailbox* mbox = sg4::Mailbox::by_name(std::string("receiver-") + std::to_string(id));
+ sg4::Mailbox* mbox = sg4::Mailbox::by_name("receiver-" + std::to_string(id));
XBT_INFO("Wait for my first message");
for (bool cont = true; cont;) {
auto received = mbox->get_unique<std::string>();
/* Make a vector of the mailboxes to use */
std::vector<sg4::Mailbox*> mboxes;
for (unsigned int i = 0; i < receivers_count; i++)
- mboxes.push_back(sg4::Mailbox::by_name(std::string("receiver-") + std::to_string(i)));
+ mboxes.push_back(sg4::Mailbox::by_name("receiver-" + std::to_string(i)));
/* Start dispatching all messages to receivers, in a round robin fashion */
for (unsigned int i = 0; i < messages_count; i++) {
- std::string msg_content = std::string("Message ") + std::to_string(i);
+ std::string msg_content = "Message " + std::to_string(i);
// Copy the data we send: the 'msg_content' variable is not a stable storage location.
// It will be destroyed when this actor leaves the loop, ie before the receiver gets it
auto* payload = new std::string(msg_content);
/* Receiver actor expects 1 argument: its ID */
static void receiver(int id)
{
- sg4::Mailbox* mbox = sg4::Mailbox::by_name(std::string("receiver-") + std::to_string(id));
+ sg4::Mailbox* mbox = sg4::Mailbox::by_name("receiver-" + std::to_string(id));
XBT_INFO("Wait for my first message");
for (bool cont = true; cont;) {
auto received = mbox->get_unique<std::string>();
/* Start dispatching all messages to the receiver */
for (int i = 0; i < messages_count; i++) {
- std::string message = std::string("Message ") + std::to_string(i);
+ std::string message = "Message " + std::to_string(i);
auto* payload = new std::string(message); // copy the data we send:
// 'msgName' is not a stable storage location
long comm_size = std::stol(args.at(1));
XBT_INFO("Send %ld bytes, in %d flows", comm_size, flow_amount);
- sg4::Mailbox* mailbox = sg4::Mailbox::by_name(std::string("message"));
+ sg4::Mailbox* mailbox = sg4::Mailbox::by_name("message");
/* Sleep a while before starting the example */
sg4::this_actor::sleep_for(10);
XBT_INFO("Receiving %d flows ...", flow_amount);
- sg4::Mailbox* mailbox = sg4::Mailbox::by_name(std::string("message"));
+ sg4::Mailbox* mailbox = sg4::Mailbox::by_name("message");
if (flow_amount == 1) {
char* res = mailbox->get<char>();
std::vector<sg4::ExecPtr> pending_executions;
for (int i = 0; i < 3; i++) {
- std::string name = std::string("Exec-") + std::to_string(i);
+ std::string name = "Exec-" + std::to_string(i);
double amount = (6 * (i % 2) + i + 1) * sg4::this_actor::get_host()->get_speed();
sg4::ExecPtr exec = sg4::this_actor::exec_init(amount)->set_name(name);
sg4::Host* host = e.host_by_name("dahu-1.grid5000.fr");
sg4::Host* host_remote = e.host_by_name("dahu-10.grid5000.fr");
- sg4::Actor::create(std::string("receiver-local"), host, Receiver());
- sg4::Actor::create(std::string("receiver-remote"), host_remote, Receiver());
- sg4::Actor::create(std::string("sender") + std::string(host->get_name()), host,
- Sender({host, host_remote}, crosstraffic));
+ sg4::Actor::create("receiver-local", host, Receiver());
+ sg4::Actor::create("receiver-remote", host_remote, Receiver());
+ sg4::Actor::create("sender" + host->get_name(), host, Sender({host, host_remote}, crosstraffic));
/* runs the simulation */
e.run();
/* Start dispatching all messages to receiver */
for (int i = 0; i < messages_count; i++) {
- std::string msg_content = std::string("Message ") + std::to_string(i);
+ std::string msg_content = "Message " + std::to_string(i);
// Copy the data we send: the 'msg_content' variable is not a stable storage location.
// It will be destroyed when this actor leaves the loop, ie before the receiver gets it
auto* payload = new std::string(msg_content);
XBT_INFO("Got %ld workers and %ld tasks to process", workers_count, number_of_tasks);
for (int i = 0; i < number_of_tasks; i++) {
- mailbox = sg4::Mailbox::by_name(std::string("worker-") + std::to_string(i % workers_count));
+ mailbox = sg4::Mailbox::by_name("worker-" + std::to_string(i % workers_count));
auto* payload = new double(comp_size);
try {
XBT_INFO("Send a message to %s", mailbox->get_cname());
XBT_INFO("All tasks have been dispatched. Let's tell everybody the computation is over.");
for (int i = 0; i < workers_count; i++) {
/* - Eventually tell all the workers to stop by sending a "finalize" task */
- mailbox = sg4::Mailbox::by_name(std::string("worker-") + std::to_string(i));
+ mailbox = sg4::Mailbox::by_name("worker-" + std::to_string(i));
auto* payload = new double(-1.0);
try {
mailbox->put(payload, 0, 1.0);
{
xbt_assert(args.size() == 2, "Expecting one parameter");
long id = std::stol(args[1]);
- sg4::Mailbox* mailbox = sg4::Mailbox::by_name(std::string("worker-") + std::to_string(id));
+ sg4::Mailbox* mailbox = sg4::Mailbox::by_name("worker-" + std::to_string(id));
while (true) {
try {
XBT_INFO("Waiting a message on %s", mailbox->get_cname());
std::string path;
for (const auto* l : links)
- path += (path.empty() ? "" : ", ") + std::string("link '") + l->get_name() + std::string("'");
+ path += std::string(path.empty() ? "" : ", ") + "link '" + l->get_name() + "'";
XBT_INFO("Path from Jupiter to Fafard: %s (latency: %fs).", path.c_str(), lat);
for (int i = 0; i < 10; i++) {
// Platform creation
auto* cluster = sg4::create_star_zone("cluster");
for (int i = 0; i < 8; i++) {
- std::string hostname = std::string("node-") + std::to_string(i) + ".simgrid.org";
+ std::string hostname = "node-" + std::to_string(i) + ".simgrid.org";
const auto* host = cluster->create_host(hostname, "1Gf");
- std::string linkname = std::string("cluster") + "_link_" + std::to_string(i);
+ std::string linkname = "cluster_link_" + std::to_string(i);
const auto* link = cluster->create_split_duplex_link(linkname, "1Gbps");
cluster->add_route(host->get_netpoint(), nullptr, nullptr, nullptr, {{link, sg4::LinkInRoute::Direction::UP}},
XBT_INFO("Transfers are done in %s mode", pc->get_transfer_mode().c_str());
for (int i = 0; i < 3; i++) {
- std::string hostname = std::string("node-") + std::to_string(i) + ".simgrid.org";
+ std::string hostname = "node-" + std::to_string(i) + ".simgrid.org";
sg4::Actor::create("ingester-" + std::to_string(i), e.host_by_name(hostname), &ingester, i, pc);
- hostname = std::string("node-") + std::to_string(i + 3) + ".simgrid.org";
+ hostname = "node-" + std::to_string(i + 3) + ".simgrid.org";
sg4::Actor::create("retriever-" + std::to_string(i), e.host_by_name(hostname), &retriever, pc);
}
static void recv(simgrid::xbt::ReplayAction& action)
{
double clock = sg4::Engine::get_clock();
- sg4::Mailbox* from = sg4::Mailbox::by_name(std::string(action[2]) + "_" + sg4::this_actor::get_name());
+ sg4::Mailbox* from = sg4::Mailbox::by_name(action[2] + "_" + sg4::this_actor::get_name());
ACT_DEBUG("Receiving: %s -- Actor %s on mailbox %s", NAME.c_str(), sg4::this_actor::get_cname(), from->get_cname());
from->get_unique<std::string>();
std::unique_lock lock(*mutex);
XBT_INFO("Start processing data which is '%s'.", data.c_str());
- data += std::string(" after processing");
+ data += " after processing";
// Send data back to main()
XBT_INFO("Signal to master that the data processing is completed, and exit.");
{
auto mutex = sg4::Mutex::create();
auto cv = sg4::ConditionVariable::create();
- data = std::string("Example data");
+ data = "Example data";
auto worker = sg4::Actor::create("worker", sg4::Host::by_name("Jupiter"), worker_fun, cv, mutex);
// wait for the worker
*/
public:
ForcefulKillException() = default;
- explicit ForcefulKillException(const std::string& msg) : msg_(std::string("Actor killed (") + msg + std::string(")."))
- {
- }
+ explicit ForcefulKillException(const std::string& msg) : msg_("Actor killed (" + msg + ").") {}
~ForcefulKillException();
const char* what() const noexcept { return msg_.c_str(); }
static bool try_n_catch(const std::function<void()>& try_block);
private:
- std::string msg_ = std::string("Actor killed.");
+ std::string msg_ = "Actor killed.";
};
} // namespace simgrid
namespace instr {
/* User-variables related functions*/
/* for host variables */
-XBT_PUBLIC void declare_host_variable(const std::string& variable, const std::string& color = std::string(""));
+XBT_PUBLIC void declare_host_variable(const std::string& variable, const std::string& color = "");
XBT_PUBLIC void set_host_variable(const std::string& host, const std::string& variable, double value,
double time = simgrid_get_clock());
XBT_PUBLIC void add_host_variable(const std::string& host, const std::string& variable, double value,
XBT_PUBLIC const std::set<std::string, std::less<>>& get_host_variables();
/* for link variables */
-XBT_PUBLIC void declare_link_variable(const std::string& variable, const std::string& color = std::string(""));
+XBT_PUBLIC void declare_link_variable(const std::string& variable, const std::string& color = "");
XBT_PUBLIC void set_link_variable(const std::string& link, const std::string& variable, double value,
double time = simgrid_get_clock());
XBT_PUBLIC void add_link_variable(const std::string& link, const std::string& variable, double value,
XBT_PUBLIC const std::set<std::string, std::less<>>& get_link_variables();
/* for VM variables */
-XBT_PUBLIC void declare_vm_variable(const std::string& variable, const std::string& color = std::string(""));
+XBT_PUBLIC void declare_vm_variable(const std::string& variable, const std::string& color = "");
XBT_PUBLIC void set_vm_variable(const std::string& vm, const std::string& variable, double value,
double time = simgrid_get_clock());
XBT_PUBLIC void add_vm_variable(const std::string& vm, const std::string& variable, double value,
/* Functions to manage tracing marks (used for trace comparison experiments) */
XBT_PUBLIC void declare_mark(const std::string& mark_type);
XBT_PUBLIC void declare_mark_value(const std::string& mark_type, const std::string& mark_value,
- const std::string& mark_color = std::string("1 1 1"));
+ const std::string& mark_color = "1 1 1");
XBT_PUBLIC void mark(const std::string& mark_type, const std::string& mark_value);
XBT_PUBLIC const std::set<std::string, std::less<>>& get_marks();
{
xbt_assert(max_queue_size > 0, "Max queue size of 0 is not allowed");
- id = std::string("ProducerConsumer") + std::to_string(pc_id);
+ id = "ProducerConsumer" + std::to_string(pc_id);
pc_id++;
mutex_ = s4u::Mutex::create();
if (val == "help")
mesg += std::string("Possible values for option ") + name + ":\n";
else
- mesg += std::string("Invalid value '") + val + "' for option " + name + ". Possible values:\n";
+ mesg += "Invalid value '" + val + "' for option " + name + ". Possible values:\n";
for (auto const& kv : valid_values)
mesg += " - '" + kv.first + "': " + kv.second + (kv.first == value ? " <=== DEFAULT" : "") + "\n";
xbt_die("%s", mesg.c_str());
comms[i] = (msg_comm_t) (uintptr_t) env->GetLongField(jcomm, jcomm_field_Comm_bind);
if (not comms[i]) {
- jxbt_throw_null(env, std::string("comm at rank ") + std::to_string(i) + " is null");
+ jxbt_throw_null(env, "comm at rank " + std::to_string(i) + " is null");
return nullptr;
}
auto const* actor = sg_actor_by_pid(pid);
if (not actor) {
- jxbt_throw_process_not_found(env, std::string("PID = ") + std::to_string(static_cast<int>(pid)));
+ jxbt_throw_process_not_found(env, "PID = " + std::to_string(static_cast<int>(pid)));
return nullptr;
}
env_->ReleaseStringUTFChars(jstr_, value);
}
operator const char*() const { return value; }
- operator const std::string() const { return std::string(value); }
+ operator const std::string() const { return value; }
};
#endif
py::class_<simgrid::s4u::Mailbox, std::unique_ptr<Mailbox, py::nodelete>>(
m, "Mailbox", "Mailbox. See the C++ documentation for details.")
.def(
- "__str__", [](const Mailbox* self) { return std::string("Mailbox(") + self->get_cname() + ")"; },
+ "__str__", [](const Mailbox* self) { return "Mailbox(" + self->get_name() + ")"; },
"Textual representation of the Mailbox`")
.def_static("by_name", &Mailbox::by_name, py::call_guard<py::gil_scoped_release>(), py::arg("name"),
"Retrieve a Mailbox from its name")
"Retrieve the mailbox on which this comm acts.")
.def_property_readonly("sender", &Comm::get_sender,
py::call_guard<py::gil_scoped_release>())
- .def_property_readonly("state_str", [](const Comm* self){ return std::string(self->get_state_str()); },
+ .def_property_readonly("state_str", &Comm::get_state_str,
py::call_guard<py::gil_scoped_release>(),
"Retrieve the Comm state as string")
.def_property_readonly("remaining", &Comm::get_remaining,
void STag_dax__adag()
{
try {
- double version = std::stod(std::string(A_dax__adag_version));
+ double version = std::stod(A_dax__adag_version);
xbt_assert(version == 2.1, "Expected version 2.1 in <adag> tag, got %f. Fix the parser or your file", version);
} catch (const std::invalid_argument&) {
throw std::invalid_argument(std::string("Parse error: ") + A_dax__adag_version + " is not a double");
void STag_dax__job()
{
try {
- double runtime = std::stod(std::string(A_dax__job_runtime));
+ double runtime = std::stod(A_dax__job_runtime);
std::string name = std::string(A_dax__job_id) + "@" + A_dax__job_name;
runtime *= 4200000000.; /* Assume that timings were done on a 4.2GFlops machine. I mean, why not? */
{
double size;
try {
- size = std::stod(std::string(A_dax__uses_size));
+ size = std::stod(A_dax__uses_size);
} catch (const std::invalid_argument&) {
throw std::invalid_argument(std::string("Parse error: ") + A_dax__uses_size + " is not a double");
}
if (job != simgrid::s4u::jobs.end()) {
current_child = job->second;
} else {
- throw std::out_of_range(std::string("Parse error on line ") + std::to_string(dax_lineno) +
+ throw std::out_of_range("Parse error on line " + std::to_string(dax_lineno) +
": Asked to add dependencies to the non-existent " + A_dax__child_ref + "task");
}
}
parent->add_successor(current_child);
XBT_DEBUG("Control-flow dependency from %s to %s", current_child->get_cname(), parent->get_cname());
} else {
- throw std::out_of_range(std::string("Parse error on line ") + std::to_string(dax_lineno) +
- ": Asked to add a dependency from " + current_child->get_name() + " to " +
- A_dax__parent_ref + ", but " + A_dax__parent_ref + " does not exist");
+ throw std::out_of_range("Parse error on line " + std::to_string(dax_lineno) + ": Asked to add a dependency from " +
+ current_child->get_name() + " to " + A_dax__parent_ref + ", but " + A_dax__parent_ref +
+ " does not exist");
}
}
double blue = simgrid::xbt::random::uniform_real(0.0, std::nextafter(1.0, 2.0));
final_color = std::to_string(red) + " " + std::to_string(green) + " " + std::to_string(blue);
} else {
- final_color = std::string(color);
+ final_color = color;
}
XBT_DEBUG("CAT,declare %s, \"%s\" \"%s\"", name.c_str(), color.c_str(), final_color.c_str());
{
xbt_assert(s4u::Engine::get_instance()->netpoint_by_name_or_null(get_name()), "Element '%s' not found", get_cname());
if (parent_) {
- std::string type_name = std::string("L") + std::to_string(level);
+ std::string type_name = "L" + std::to_string(level);
type_ = parent_->type_->by_name_or_create<ContainerType>(type_name);
parent_->children_.try_emplace(get_name(), this);
on_creation(*this);
// create a key considering the resource and variable, and check if key exists in the global map:
// if it doesn't, set the variable to zero.
if (static std::set<std::string, std::less<>> platform_variables;
- platform_variables.emplace(std::string(resource) + get_name()).second)
+ platform_variables.emplace(resource + get_name()).second)
set_event(now, 0);
add_event(now, value);
std::string instr_pid(simgrid::s4u::Actor const& proc)
{
- return std::string(proc.get_name()) + "-" + std::to_string(proc.get_pid());
+ return proc.get_name() + "-" + std::to_string(proc.get_pid());
}
static simgrid::instr::Container* lowestCommonAncestor(const simgrid::instr::Container* a1,
simgrid::instr::Type* root)
{
if (root->get_name() == "HOST" || root->get_name() == "VM")
- root->by_name_or_create(std::string("p") + new_typename, color);
+ root->by_name_or_create("p" + new_typename, color);
if (root->get_name() == "LINK")
- root->by_name_or_create(std::string("b") + new_typename, color);
+ root->by_name_or_create("b" + new_typename, color);
for (auto const& [_, child] : root->get_children()) {
recursiveNewVariableType(new_typename, color, child.get());
if (TRACE_smpi_is_enabled() && TRACE_smpi_is_computing()) {
s4u::Exec::on_start_cb([](s4u::Exec const& exec) {
- Container::by_name(std::string("rank-") + std::to_string(s4u::Actor::self()->get_pid()))
+ Container::by_name("rank-" + std::to_string(s4u::Actor::self()->get_pid()))
->get_state("MPI_STATE")
->push_event("computing", new CpuTIData("compute", exec.get_cost()));
});
s4u::Activity::on_completion_cb([](const s4u::Activity&) {
- Container::by_name(std::string("rank-") + std::to_string(s4u::Actor::self()->get_pid()))
- ->get_state("MPI_STATE")
- ->pop_event();
+ Container::by_name("rank-" + std::to_string(s4u::Actor::self()->get_pid()))->get_state("MPI_STATE")->pop_event();
});
}
}
static config::Flag<std::string> context_factory_name("contexts/factory",
- (std::string("Possible values: ") + contexts_list()).c_str(),
+ ("Possible values: " + contexts_list()).c_str(),
context_factories.begin()->first);
} // namespace simgrid::kernel
throw HostFailureException(XBT_THROW_POINT, "Cannot attach actor on failed host.");
}
- auto* actor = new ActorImpl(std::string(name), host, /*ppid*/ -1);
+ auto* actor = new ActorImpl(name, host, /*ppid*/ -1);
/* Actor data */
actor->piface_.set_data(data);
actor->code_ = nullptr;
activity::ActivityImplPtr ActorImpl::sleep(double duration)
{
if (not host_->is_on())
- throw_exception(std::make_exception_ptr(HostFailureException(
- XBT_THROW_POINT, std::string("Host ") + host_->get_cname() + " failed, you cannot sleep there.")));
+ throw_exception(std::make_exception_ptr(
+ HostFailureException(XBT_THROW_POINT, "Host " + host_->get_name() + " failed, you cannot sleep there.")));
auto sleep_activity = new activity::SleepImpl();
sleep_activity->set_name("sleep").set_host(host_).set_duration(duration).start();
if (auto* comm = dynamic_cast<activity::CommImpl const*>(act)) {
const std::string src_buff_id = ptr_to_id<unsigned char>(comm->src_buff_);
const std::string dst_buff_id = ptr_to_id<unsigned char>(comm->dst_buff_);
- return std::string("CommTest(comm_id:") + ptr_to_id<activity::CommImpl const>(comm) +
+ return "CommTest(comm_id:" + ptr_to_id<activity::CommImpl const>(comm) +
" src:" + std::to_string(comm->src_actor_ != nullptr ? comm->src_actor_->get_pid() : -1) +
" dst:" + std::to_string(comm->dst_actor_ != nullptr ? comm->dst_actor_->get_pid() : -1) +
" mbox:" + std::to_string(comm->get_mailbox_id()) + " srcbuf:" + src_buff_id + " dstbuf:" + dst_buff_id +
if (auto* comm = dynamic_cast<activity::CommImpl const*>(act)) {
const std::string src_buff_id = ptr_to_id<unsigned char>(comm->src_buff_);
const std::string dst_buff_id = ptr_to_id<unsigned char>(comm->dst_buff_);
- return std::string("CommWait(comm_id:") + ptr_to_id<activity::CommImpl const>(comm) +
+ return "CommWait(comm_id:" + ptr_to_id<activity::CommImpl const>(comm) +
" src:" + std::to_string(comm->src_actor_ != nullptr ? comm->src_actor_->get_pid() : -1) +
" dst:" + std::to_string(comm->dst_actor_ != nullptr ? comm->dst_actor_->get_pid() : -1) +
- " mbox:" + std::string(comm->get_mailbox() == nullptr ? std::string("-") : comm->get_mailbox()->get_name()) +
+ " mbox:" + (comm->get_mailbox() == nullptr ? "-" : comm->get_mailbox()->get_name()) +
"(id:" + std::to_string(comm->get_mailbox_id()) + ") srcbuf:" + src_buff_id + " dstbuf:" + dst_buff_id +
" bufsize:" + std::to_string(comm->src_buff_size_) + ")";
} else {
}
std::string CommIsendSimcall::to_string() const
{
- return std::string("CommAsyncSend(comm_id: ") + std::to_string((uintptr_t)comm_) +
- " mbox:" + std::to_string(mbox_->get_id()) + " srcbuf:" + ptr_to_id<unsigned char>(src_buff_) +
- " bufsize:" + std::to_string(src_buff_size_) + " tag: " + std::to_string(tag_) + ")";
+ return "CommAsyncSend(comm_id: " + std::to_string((uintptr_t)comm_) + " mbox:" + std::to_string(mbox_->get_id()) +
+ " srcbuf:" + ptr_to_id<unsigned char>(src_buff_) + " bufsize:" + std::to_string(src_buff_size_) +
+ " tag: " + std::to_string(tag_) + ")";
}
void CommIrecvSimcall::serialize(std::stringstream& stream) const
}
std::string CommIrecvSimcall::to_string() const
{
- return std::string("CommAsyncRecv(comm_id: ") + ptr_to_id<activity::CommImpl const>(comm_) +
+ return "CommAsyncRecv(comm_id: " + ptr_to_id<activity::CommImpl const>(comm_) +
" mbox:" + std::to_string(mbox_->get_id()) + " dstbuf:" + ptr_to_id<unsigned char>(dst_buff_) +
" tag: " + std::to_string(tag_) + ")";
}
}
std::string RandomSimcall::to_string() const
{
- return std::string("Random(min:") + std::to_string(min_) + " max:" + std::to_string(max_) + ")";
+ return "Random(min:" + std::to_string(min_) + " max:" + std::to_string(max_) + ")";
}
void RandomSimcall::prepare(int times_considered)
}
std::string ActorJoinSimcall::to_string() const
{
- return std::string("ActorJoin(pid:") + std::to_string(other_->get_pid()) + ")";
+ return "ActorJoin(pid:" + std::to_string(other_->get_pid()) + ")";
}
void ObjectAccessSimcallObserver::serialize(std::stringstream& stream) const
}
std::string ObjectAccessSimcallObserver::to_string() const
{
- return std::string("ObjectAccess(obj:") + ptr_to_id<ObjectAccessSimcallItem const>(object_) +
+ return "ObjectAccess(obj:" + ptr_to_id<ObjectAccessSimcallItem const>(object_) +
" owner:" + std::to_string(get_owner()->get_pid()) + ")";
}
bool ObjectAccessSimcallObserver::is_visible() const
try {
fact.factor = std::stoi(*factor_iter);
} catch (const std::invalid_argument&) {
- throw std::invalid_argument(std::string("Invalid factor in chunk ") + std::to_string(factors_.size() + 1) +
- ": " + *factor_iter + " for " + name_);
+ throw std::invalid_argument("Invalid factor in chunk " + std::to_string(factors_.size() + 1) + ": " +
+ *factor_iter + " for " + name_);
}
} else {
try {
fact.values.push_back(xbt_parse_get_time(surf_parsed_filename, surf_parse_lineno, *factor_iter, ""));
} catch (const std::invalid_argument&) {
- throw std::invalid_argument(std::string("Invalid factor value ") + std::to_string(iteration) + " in chunk " +
+ throw std::invalid_argument("Invalid factor value " + std::to_string(iteration) + " in chunk " +
std::to_string(factors_.size() + 1) + ": " + *factor_iter + " for " + name_);
}
}
try {
n_groups = std::stoi(tmp[0]);
} catch (const std::invalid_argument&) {
- throw std::invalid_argument(std::string("Invalid number of groups:") + tmp[0]);
+ throw std::invalid_argument("Invalid number of groups:" + tmp[0]);
}
unsigned int n_blue;
try {
n_blue = std::stoi(tmp[1]);
} catch (const std::invalid_argument&) {
- throw std::invalid_argument(std::string("Invalid number of links for the blue level:") + tmp[1]);
+ throw std::invalid_argument("Invalid number of links for the blue level:" + tmp[1]);
}
// Black network : number of chassis/group, number of links between each router on the black network
try {
n_chassis = std::stoi(tmp[0]);
} catch (const std::invalid_argument&) {
- throw std::invalid_argument(std::string("Invalid number of chassis:") + tmp[0]);
+ throw std::invalid_argument("Invalid number of chassis:" + tmp[0]);
}
unsigned int n_black;
try {
n_black = std::stoi(tmp[1]);
} catch (const std::invalid_argument&) {
- throw std::invalid_argument(std::string("Invalid number of links for the black level:") + tmp[1]);
+ throw std::invalid_argument("Invalid number of links for the black level:" + tmp[1]);
}
// Green network : number of blades/chassis, number of links between each router on the green network
try {
n_routers = std::stoi(tmp[0]);
} catch (const std::invalid_argument&) {
- throw std::invalid_argument(std::string("Invalid number of routers:") + tmp[0]);
+ throw std::invalid_argument("Invalid number of routers:" + tmp[0]);
}
unsigned int n_green;
try {
n_green = std::stoi(tmp[1]);
} catch (const std::invalid_argument&) {
- throw std::invalid_argument(std::string("Invalid number of links for the green level:") + tmp[1]);
+ throw std::invalid_argument("Invalid number of links for the green level:" + tmp[1]);
}
// The last part of topo_parameters should be the number of nodes per blade
try {
n_nodes = std::stoi(parameters[3]);
} catch (const std::invalid_argument&) {
- throw std::invalid_argument(std::string("Last parameter is not the amount of nodes per blade:") + parameters[3]);
+ throw std::invalid_argument("Last parameter is not the amount of nodes per blade:" + parameters[3]);
}
return s4u::DragonflyParams({n_groups, n_blue}, {n_chassis, n_black}, {n_routers, n_green}, n_nodes);
}
this->nodes_by_level_[0] *= this->num_children_per_node_[i];
if (this->nodes_by_level_[0] != this->nodes_.size()) {
- surf_parse_error(std::string("The number of provided nodes does not fit with the wanted topology.") +
- " Please check your platform description (We need " + std::to_string(this->nodes_by_level_[0]) +
- "nodes, we got " + std::to_string(this->nodes_.size()));
+ surf_parse_error("The number of provided nodes does not fit with the wanted topology."
+ " Please check your platform description (We need " +
+ std::to_string(this->nodes_by_level_[0]) + "nodes, we got " + std::to_string(this->nodes_.size()));
}
for (unsigned int i = 0; i < this->levels_; i++) {
try {
n_lev = std::stoi(parameters[0]);
} catch (const std::invalid_argument&) {
- surf_parse_error(std::string("First parameter is not the amount of levels: ") + parameters[0]);
+ surf_parse_error("First parameter is not the amount of levels: " + parameters[0]);
}
// Then, a l-sized vector standing for the children number by level
boost::split(tmp, parameters[1], boost::is_any_of(","));
- surf_parse_assert(tmp.size() == n_lev, std::string("You specified ") + std::to_string(n_lev) +
+ surf_parse_assert(tmp.size() == n_lev, "You specified " + std::to_string(n_lev) +
" levels but the child count vector (the first one) contains " +
std::to_string(tmp.size()) + " levels.");
try {
down.push_back(std::stoi(level));
} catch (const std::invalid_argument&) {
- surf_parse_error(std::string("Invalid child count: ") + level);
+ surf_parse_error("Invalid child count: " + level);
}
}
// Then, a l-sized vector standing for the parents number by level
boost::split(tmp, parameters[2], boost::is_any_of(","));
- surf_parse_assert(tmp.size() == n_lev, std::string("You specified ") + std::to_string(n_lev) +
+ surf_parse_assert(tmp.size() == n_lev, "You specified " + std::to_string(n_lev) +
" levels but the parent count vector (the second one) contains " +
std::to_string(tmp.size()) + " levels.");
for (std::string const& parent : tmp) {
try {
up.push_back(std::stoi(parent));
} catch (const std::invalid_argument&) {
- surf_parse_error(std::string("Invalid parent count: ") + parent);
+ surf_parse_error("Invalid parent count: " + parent);
}
}
// Finally, a l-sized vector standing for the ports number with the lower level
boost::split(tmp, parameters[3], boost::is_any_of(","));
- surf_parse_assert(tmp.size() == n_lev, std::string("You specified ") + std::to_string(n_lev) +
+ surf_parse_assert(tmp.size() == n_lev, "You specified " + std::to_string(n_lev) +
" levels but the port count vector (the third one) contains " +
std::to_string(tmp.size()) + " levels.");
for (std::string const& port : tmp) {
try {
count.push_back(std::stoi(port));
} catch (const std::invalid_argument&) {
- throw std::invalid_argument(std::string("Invalid lower level port number:") + port);
+ throw std::invalid_argument("Invalid lower level port number:" + port);
}
}
return s4u::FatTreeParams(n_lev, down, up, count);
Channel& channel() { return checker_side_.get_channel(); }
PageStore& page_store() { return page_store_; }
- std::string const& get_host_name(const char* hostname)
- {
- return *this->hostnames_.insert(std::string(hostname)).first;
- }
+ std::string const& get_host_name(const char* hostname) { return *this->hostnames_.insert(hostname).first; }
void start();
void shutdown();
{
simgrid::mc::Type type;
type.type = dwarf_tag(die);
- type.name = std::string();
+ type.name = "";
type.element_count = -1;
// Global Offset
}
if (ns && variable->global)
- variable->name = std::string(ns) + "::" + variable->name;
+ variable->name.insert(0, std::string(ns) + "::");
// The current code needs a variable name,
// generate a fake one:
xbt_assert(c > 0, "Could not read string from remote process");
if (memchr(res.data() + off, '\0', c))
- return std::string(res.data());
+ return res.data();
off += c;
if (off == (off_t)res.size())
stack_frame.frame_base = (unw_word_t)frame->frame_base(c);
} else {
stack_frame.frame_base = 0;
- stack_frame.frame_name = std::string();
+ stack_frame.frame_name = "";
}
result.push_back(std::move(stack_frame));
void set_not_used() { this->is_used_ = false; }
const std::string& get_name() const { return name_; }
const char* get_cname() const { return name_.c_str(); }
- void set_name(const char* new_name) { name_ = std::string(new_name); }
+ void set_name(const char* new_name) { name_ = new_name; }
void set_tracing_category(const char* category) { tracing_category_ = category ? category : ""; }
const std::string& get_tracing_category() const { return tracing_category_; }
bool has_tracing_category() { return not tracing_category_.empty(); }
{
if (TRACE_actor_is_enabled()) {
auto* process_container = instr::Container::by_name(instr_pid(*MSG_process_self()));
- std::string key = std::string("p") + std::to_string(get_id());
+ std::string key = "p" + std::to_string(get_id());
instr::Container::get_root()->get_link("ACTOR_LINK")->start_event(process_container, "SR", key);
}
if (TRACE_actor_is_enabled() && ret != MSG_HOST_FAILURE && ret != MSG_TRANSFER_FAILURE && ret != MSG_TIMEOUT) {
auto* process_container = simgrid::instr::Container::by_name(instr_pid(*MSG_process_self()));
- std::string key = std::string("p") + std::to_string((*task)->get_id());
+ std::string key = "p" + std::to_string((*task)->get_id());
simgrid::instr::Container::get_root()->get_link("ACTOR_LINK")->end_event(process_container, "SR", key);
}
return ret;
host->get_cname());
/* Mount point found, split fullpath_ into mount_name and path+filename*/
mount_point_ = fullpath_.substr(0, longest_prefix_length);
- if (mount_point_ == std::string("/"))
+ if (mount_point_ == "/")
path_ = fullpath_;
else
path_ = fullpath_.substr(longest_prefix_length, fullpath_.length());
for (auto const& disk : host->get_disks()) {
std::string current_mount = disk->extension<FileSystemDiskExt>()->get_mount_point();
- std::string mount_point = std::string(fullpath).substr(0, current_mount.length());
+ std::string mount_point = fullpath.substr(0, current_mount.length());
if (mount_point == current_mount && current_mount.length() > longest_prefix_length) {
/* The current mount name is found in the full path and is bigger than the previous*/
longest_prefix_length = current_mount.length();
}
if (const char* current_mount_str = ptr->get_property("mount"))
- mount_point_ = std::string(current_mount_str);
+ mount_point_ = current_mount_str;
else
- mount_point_ = std::string("/");
+ mount_point_ = "/";
if (const char* content_str = ptr->get_property("content"))
content_.reset(parse_content(content_str));
if (dynamic_cast<simgrid::s4u::VirtualMachine*>(&host)) // Ignore virtual machines
return;
- std::string name = std::string("dvfs-daemon-") + host.get_cname();
+ std::string name = "dvfs-daemon-" + host.get_name();
simgrid::s4u::ActorPtr daemon = simgrid::s4u::Actor::create(name.c_str(), &host, []() {
/**
* This lambda function is the function the actor (daemon) will execute
std::string dvfs_governor;
if (const char* host_conf = daemon_proc->get_host()->get_property("plugin/dvfs/governor")) {
- dvfs_governor = std::string(host_conf);
+ dvfs_governor = host_conf;
boost::algorithm::to_lower(dvfs_governor);
} else {
dvfs_governor = cfg_governor;
const char* off_power_str = host_->get_property("wattage_off");
if (off_power_str != nullptr) {
try {
- this->watts_off_ = std::stod(std::string(off_power_str));
+ this->watts_off_ = std::stod(off_power_str);
} catch (const std::invalid_argument&) {
- throw std::invalid_argument(std::string("Invalid value for property wattage_off of host ") + host_->get_cname() +
- ": " + off_power_str);
+ throw std::invalid_argument("Invalid value for property wattage_off of host " + host_->get_name() + ": " +
+ off_power_str);
}
}
/* watts_off is 0 by default */
try {
idle_ = std::stod(current_power_values.front());
} catch (const std::invalid_argument&) {
- throw std::invalid_argument(std::string("Invalid idle power value for link ") + this->link_->get_cname());
+ throw std::invalid_argument("Invalid idle power value for link " + this->link_->get_name());
}
try {
busy_ = std::stod(current_power_values.back());
} catch (const std::invalid_argument&) {
- throw std::invalid_argument(std::string("Invalid busy power value for link ") + this->link_->get_cname());
+ throw std::invalid_argument("Invalid busy power value for link " + this->link_->get_name());
}
}
}
try {
control_duration_ = std::stod(beacons_factor);
} catch (const std::invalid_argument&) {
- throw std::invalid_argument(std::string("Invalid beacons factor value for link ") + this->link_->get_cname());
+ throw std::invalid_argument("Invalid beacons factor value for link " + this->link_->get_name());
}
}
try {
pSleep_ = std::stod(current_power_values.at(3));
} catch (const std::invalid_argument&) {
- throw std::invalid_argument(std::string("Invalid idle power value for link ") + this->link_->get_cname());
+ throw std::invalid_argument("Invalid idle power value for link " + this->link_->get_name());
}
try {
pRx_ = std::stod(current_power_values.at(2));
} catch (const std::invalid_argument&) {
- throw std::invalid_argument(std::string("Invalid idle power value for link ") + this->link_->get_cname());
+ throw std::invalid_argument("Invalid idle power value for link " + this->link_->get_name());
}
try {
pTx_ = std::stod(current_power_values.at(1));
} catch (const std::invalid_argument&) {
- throw std::invalid_argument(std::string("Invalid idle power value for link ") + this->link_->get_cname());
+ throw std::invalid_argument("Invalid idle power value for link " + this->link_->get_name());
}
try {
pIdle_ = std::stod(current_power_values.at(0));
} catch (const std::invalid_argument&) {
- throw std::invalid_argument(std::string("Invalid busy power value for link ") + this->link_->get_cname());
+ throw std::invalid_argument("Invalid busy power value for link " + this->link_->get_name());
}
XBT_DEBUG("Values aa initialized with: pSleep=%f pIdle=%f pTx=%f pRx=%f", pSleep_, pIdle_, pTx_, pRx_);
bool received_finalize = false;
std::string finalize_task_name =
- std::string("__mig_stage3:") + vm_->get_cname() + "(" + src_pm_->get_cname() + "-" + dst_pm_->get_cname() + ")";
+ "__mig_stage3:" + vm_->get_name() + "(" + src_pm_->get_name() + "-" + dst_pm_->get_name() + ")";
while (not received_finalize) {
auto payload = mbox->get_unique<std::string>();
}
// Inform the SRC that the migration has been correctly performed
auto* payload = new std::string("__mig_stage4:");
- *payload = *payload + vm_->get_cname() + "(" + src_pm_->get_cname() + "-" + dst_pm_->get_cname() + ")";
+ *payload = *payload + vm_->get_name() + "(" + src_pm_->get_name() + "-" + dst_pm_->get_name() + ")";
mbox_ctl->put(payload, 0);
vm->start_migration();
- std::string rx_name =
- std::string("__pr_mig_rx:") + vm->get_cname() + "(" + src_pm->get_cname() + "-" + dst_pm->get_cname() + ")";
- std::string tx_name =
- std::string("__pr_mig_tx:") + vm->get_cname() + "(" + src_pm->get_cname() + "-" + dst_pm->get_cname() + ")";
+ std::string rx_name = "__pr_mig_rx:" + vm->get_name() + "(" + src_pm->get_name() + "-" + dst_pm->get_name() + ")";
+ std::string tx_name = "__pr_mig_tx:" + vm->get_name() + "(" + src_pm->get_name() + "-" + dst_pm->get_name() + ")";
simgrid::s4u::ActorPtr rx =
simgrid::s4u::Actor::create(rx_name.c_str(), dst_pm, simgrid::plugin::vm::MigrationRx(vm, dst_pm));
/* wait until the migration have finished or on error has occurred */
XBT_DEBUG("wait for reception of the final ACK (i.e. migration has been correctly performed");
- simgrid::s4u::Mailbox* mbox_ctl = simgrid::s4u::Mailbox::by_name(
- std::string("__mbox_mig_ctl:") + vm->get_cname() + "(" + src_pm->get_cname() + "-" + dst_pm->get_cname() + ")");
+ simgrid::s4u::Mailbox* mbox_ctl = simgrid::s4u::Mailbox::by_name("__mbox_mig_ctl:" + vm->get_name() + "(" +
+ src_pm->get_name() + "-" + dst_pm->get_name() + ")");
mbox_ctl->get_unique<std::string>();
tx->join();
rx->join();
{
src_pm_ = vm_->get_pm();
- mbox_ctl = s4u::Mailbox::by_name(std::string("__mbox_mig_ctl:") + vm_->get_cname() + "(" + src_pm_->get_cname() +
- "-" + dst_pm_->get_cname() + ")");
- mbox = s4u::Mailbox::by_name(std::string("__mbox_mig_src_dst:") + vm_->get_cname() + "(" + src_pm_->get_cname() +
- "-" + dst_pm_->get_cname() + ")");
+ mbox_ctl = s4u::Mailbox::by_name("__mbox_mig_ctl:" + vm_->get_name() + "(" + src_pm_->get_name() + "-" +
+ dst_pm_->get_name() + ")");
+ mbox = s4u::Mailbox::by_name("__mbox_mig_src_dst:" + vm_->get_name() + "(" + src_pm_->get_name() + "-" +
+ dst_pm_->get_name() + ")");
}
void operator()();
};
explicit MigrationTx(s4u::VirtualMachine* vm, s4u::Host* dst_pm) : vm_(vm), dst_pm_(dst_pm)
{
src_pm_ = vm_->get_pm();
- mbox = s4u::Mailbox::by_name(std::string("__mbox_mig_src_dst:") + vm_->get_cname() + "(" + src_pm_->get_cname() +
- "-" + dst_pm_->get_cname() + ")");
+ mbox = s4u::Mailbox::by_name("__mbox_mig_src_dst:" + vm_->get_name() + "(" + src_pm_->get_name() + "-" +
+ dst_pm_->get_name() + ")");
}
void operator()();
sg_size_t sendMigrationData(sg_size_t size, int stage, int stage2_round, double mig_speed, double timeout);
{
auto* host = host_by_name_or_null(name);
if (not host)
- throw std::invalid_argument(std::string("Host not found: '") + name + std::string("'"));
+ throw std::invalid_argument("Host not found: '" + name + "'");
return host;
}
{
auto* link = link_by_name_or_null(name);
if (not link)
- throw std::invalid_argument(std::string("Link not found: ") + name);
+ throw std::invalid_argument("Link not found: " + name);
return link;
}
{
auto* link_impl = pimpl->netzone_root_ ? pimpl->netzone_root_->get_split_duplex_link_by_name_or_null(name) : nullptr;
if (not link_impl)
- throw std::invalid_argument(std::string("Link not found: ") + name);
+ throw std::invalid_argument("Link not found: " + name);
return link_impl->get_iface();
}
{
auto netp = netpoint_by_name_or_null(name);
if (netp == nullptr) {
- throw std::invalid_argument(std::string("Netpoint not found: %s") + name);
+ throw std::invalid_argument("Netpoint not found: " + name);
}
return netp;
}
double speed = xbt_parse_get_speed("", 0, speed_str, "");
speed_list.push_back(speed);
} catch (const simgrid::ParseError&) {
- throw std::invalid_argument(std::string("Invalid speed value: ") + speed_str);
+ throw std::invalid_argument("Invalid speed value: " + speed_str);
}
}
return speed_list;
try {
d_read = xbt_parse_get_bandwidth("", 0, read_bandwidth, "");
} catch (const simgrid::ParseError&) {
- throw std::invalid_argument(std::string("Impossible to create disk: ") + name +
- std::string(". Invalid read bandwidth: ") + read_bandwidth);
+ throw std::invalid_argument("Impossible to create disk: " + name + ". Invalid read bandwidth: " + read_bandwidth);
}
double d_write;
try {
d_write = xbt_parse_get_bandwidth("", 0, write_bandwidth, "");
} catch (const simgrid::ParseError&) {
- throw std::invalid_argument(std::string("Impossible to create disk: ") + name +
- std::string(". Invalid write bandwidth: ") + write_bandwidth);
+ throw std::invalid_argument("Impossible to create disk: " + name + ". Invalid write bandwidth: " + write_bandwidth);
}
return create_disk(name, d_read, d_write);
}
try {
d_value = xbt_parse_get_time("", 0, value, "");
} catch (const simgrid::ParseError&) {
- throw std::invalid_argument(std::string("Impossible to set latency for link: ") + get_name() +
- std::string(". Invalid value: ") + value);
+ throw std::invalid_argument("Impossible to set latency for link: " + get_name() + ". Invalid value: " + value);
}
return set_latency(d_value);
}
Link* Link::set_sharing_policy(Link::SharingPolicy policy, const NonLinearResourceCb& cb)
{
if (policy == SharingPolicy::SPLITDUPLEX || policy == SharingPolicy::WIFI)
- throw std::invalid_argument(std::string("Impossible to set wifi or split-duplex for the link: ") + get_name() +
- std::string(". Use appropriate create function in NetZone."));
+ throw std::invalid_argument("Impossible to set wifi or split-duplex for the link: " + get_name() +
+ ". Use appropriate create function in NetZone.");
kernel::actor::simcall_object_access(pimpl_, [this, policy, &cb] { pimpl_->set_sharing_policy(policy, cb); });
return this;
try {
speed = xbt_parse_get_bandwidth("", 0, bandwidth, "");
} catch (const simgrid::ParseError&) {
- throw std::invalid_argument(std::string("Impossible to create split-duplex link: ") + name +
- std::string(". Invalid bandwidth: ") + bandwidth);
+ throw std::invalid_argument("Impossible to create split-duplex link: " + name +
+ ". Invalid bandwidth: " + bandwidth);
}
return create_split_duplex_link(name, speed);
}
double speed = xbt_parse_get_bandwidth("", 0, speed_str, "");
bw.push_back(speed);
} catch (const simgrid::ParseError&) {
- throw std::invalid_argument(std::string("Impossible to create link: ") + name +
- std::string(". Invalid bandwidth: ") + speed_str);
+ throw std::invalid_argument("Impossible to create link: " + name + ". Invalid bandwidth: " + speed_str);
}
}
return create_link(name, bw);
if (not this_actor::is_maestro() && this_actor::get_host() == this) {
XBT_VERB("Launch another actor on physical host %s to destroy my own VM: %s", get_pm()->get_cname(), get_cname());
- simgrid::s4u::Actor::create(get_cname() + std::string("-vm_destroy"), get_pm(), destroy_code);
+ simgrid::s4u::Actor::create(get_name() + "-vm_destroy", get_pm(), destroy_code);
simgrid::s4u::this_actor::yield();
XBT_CRITICAL("I should be dead now!");
DIE_IMPOSSIBLE;
int PMPI_Get_processor_name(char *name, int *resultlen)
{
int len = std::min(static_cast<int>(sg_host_self()->get_name().size()), MPI_MAX_PROCESSOR_NAME - 1);
- std::string(sg_host_self()->get_name()).copy(name, len);
+ sg_host_self()->get_name().copy(name, len);
name[len] = '\0';
*resultlen = len;
}
CHECK_ROOT(7)
CHECK_REQUEST(9)
- CHECK_COLLECTIVE(comm, std::string(request == MPI_REQUEST_IGNORED ? "PMPI_Gather" : "PMPI_Igather") + +" with root " +
+ CHECK_COLLECTIVE(comm, std::string(request == MPI_REQUEST_IGNORED ? "PMPI_Gather" : "PMPI_Igather") + " with root " +
std::to_string(root))
const void* real_sendbuf = sendbuf;
simgrid::instr::Container::get_root()->get_type()->by_name_or_create<simgrid::instr::EventType>( \
_XBT_STRINGIFY(cat)); \
\
- std::string cont_name = std::string("rank-" + std::to_string(simgrid::s4u::this_actor::get_pid())); \
+ std::string cont_name = "rank-" + std::to_string(simgrid::s4u::this_actor::get_pid()); \
type->add_entity_value(desc->name, "1.0 1.0 1.0"); \
new simgrid::instr::NewEvent(simgrid::s4u::Engine::get_clock(), simgrid::instr::Container::by_name(cont_name), \
type, type->get_entity_value(desc->name)); \
namespace simgrid::smpi {
std::map<std::string, std::vector<s_mpi_coll_description_t>, std::less<>> smpi_coll_descriptions(
- {{std::string("gather"),
+ {{"gather",
{{"default", "gather default collective", (void*)gather__default},
{"ompi", "gather ompi collective", (void*)gather__ompi},
{"ompi_basic_linear", "gather ompi_basic_linear collective", (void*)gather__ompi_basic_linear},
Datatype(const Datatype&) = delete;
Datatype& operator=(const Datatype&) = delete;
~Datatype() override;
- std::string name() const override {return name_.empty() ? std::string("MPI_Datatype") : name_;}
+ std::string name() const override { return name_.empty() ? "MPI_Datatype" : name_; }
size_t size() const { return size_; }
MPI_Aint lb() const { return lb_; }
MPI_Aint ub() const { return ub_; }
int flags() const;
MPI_Datatype etype() const;
MPI_Comm comm() const;
- std::string name() const override {return file_ ? std::string("MPI_File: ")+ std::string(file_->get_path()): std::string("MPI_File");}
+ std::string name() const override { return file_ ? "MPI_File: " + std::string(file_->get_path()) : "MPI_File"; }
int sync();
int seek(MPI_Offset offset, int whence);
void set_mapping(aid_t pid, int rank);
int rank(aid_t pid) const;
aid_t actor(int rank) const;
- std::string name() const override {return std::string("MPI_Group");}
+ std::string name() const override { return "MPI_Group"; }
void ref();
static void unref(MPI_Group group);
int size() const { return static_cast<int>(rank_to_pid_map_.size()); }
static void unref(MPI_Info info);
void set(const char* key, const char* value) { map_[key] = value; }
int get(const char* key, int valuelen, char* value, int* flag) const;
- std::string name() const override {return std::string("MPI_Info");}
+ std::string name() const override { return "MPI_Info"; }
int remove(const char* key);
int get_nkeys(int* nkeys) const;
int get_nthkey(int n, char* key) const;
int tag() const { return tag_; }
int flags() const { return flags_; }
bool detached() const { return detached_; }
- std::string name() const override { return std::string("MPI_Request"); }
+ std::string name() const override { return "MPI_Request"; }
MPI_Datatype type() const { return type_; }
void print_request(const char* message) const;
void start();
int attach (void *base, MPI_Aint size);
int detach (const void *base);
void get_name(char* name, int* length) const;
- std::string name() const override {return name_.empty() ? std::string("MPI_Win") : name_;}
+ std::string name() const override { return name_.empty() ? "MPI_Win" : name_; }
void get_group( MPI_Group* group);
void set_name(const char* name);
int rank() const;
XBT_PRIVATE simgrid::instr::Container* smpi_container(aid_t pid)
{
- return simgrid::instr::Container::by_name(std::string("rank-") + std::to_string(pid));
+ return simgrid::instr::Container::by_name("rank-" + std::to_string(pid));
}
static std::string TRACE_smpi_put_key(aid_t src, aid_t dst, int tag, int send)
parent = simgrid::instr::Container::by_name_or_null(host->get_name());
xbt_assert(parent != nullptr, "Could not find a parent for mpi rank 'rank-%ld' at function %s", pid, __func__);
}
- parent->create_child(std::string("rank-") + std::to_string(pid), "MPI"); // This container is of type MPI
+ parent->create_child("rank-" + std::to_string(pid), "MPI"); // This container is of type MPI
}
void TRACE_smpi_init(aid_t pid, const std::string& calling_func)
void LocationParser::parse(simgrid::xbt::ReplayAction& action, const std::string&)
{
CHECK_ACTION_PARAMS(action, 2, 0)
- filename = std::string(action[2]);
+ filename = action[2];
line = std::stoi(action[3]);
}
std::array<char, MPI_MAX_NAME_STRING + 1> name;
this->get_name(name.data(), &size);
if (name[0]=='\0')
- return std::string("MPI_Comm");
+ return "MPI_Comm";
else
- return std::string(name.data());
+ return name.data();
}
{
etype_ = etype;
filetype_ = filetype;
- datarep_ = std::string(datarep);
+ datarep_ = datarep;
disp_ = disp;
if (comm_->rank() == 0){
if(disp != MPI_DISPLACEMENT_CURRENT)
try {
std::string actors;
for (auto const& actor : actor_list_)
- actors += "\n\t" + std::string(actor.get_name());
+ actors += "\n\t" + actor.get_name();
EngineImpl::get_instance()->display_all_actor_status();
xbt_die("%s:%s", msg, actors.c_str());
"(total = %zu). Check the 'radical' parameter in XML",
cluster->id.c_str(), id, cluster->radicals.size());
- std::string host_id = std::string(cluster->prefix) + std::to_string(cluster->radicals[id]) + cluster->suffix;
+ std::string host_id = cluster->prefix + std::to_string(cluster->radicals[id]) + cluster->suffix;
XBT_DEBUG("Cluster: creating host=%s speed=%f", host_id.c_str(), cluster->speeds.front());
const simgrid::s4u::Host* host = zone->create_host(host_id, cluster->speeds)
->set_core_count(cluster->core_amount)
"(total = %zu). Check the 'radical' parameter in XML",
cluster->id.c_str(), id, cluster->radicals.size());
- std::string link_id = std::string(cluster->id) + "_link_" + std::to_string(cluster->radicals[id]) + "_loopback";
+ std::string link_id = cluster->id + "_link_" + std::to_string(cluster->radicals[id]) + "_loopback";
XBT_DEBUG("Cluster: creating loopback link=%s bw=%f", link_id.c_str(), cluster->loopback_bw);
simgrid::s4u::Link* loopback = zone->create_link(link_id, cluster->loopback_bw)
const std::vector<unsigned long>& /*coord*/,
unsigned long id)
{
- std::string link_id = std::string(cluster->id) + "_link_" + std::to_string(id) + "_limiter";
+ std::string link_id = cluster->id + "_link_" + std::to_string(id) + "_limiter";
XBT_DEBUG("Cluster: creating limiter link=%s bw=%f", link_id.c_str(), cluster->limiter_link);
simgrid::s4u::Link* limiter = zone->create_link(link_id, cluster->limiter_link)->seal();
/* Make the backbone */
const simgrid::s4u::Link* backbone = nullptr;
if ((cluster->bb_bw > 0) || (cluster->bb_lat > 0)) {
- std::string bb_name = std::string(cluster->id) + "_backbone";
+ std::string bb_name = cluster->id + "_backbone";
XBT_DEBUG("<link\tid=\"%s\" bw=\"%f\" lat=\"%f\"/> <!--backbone -->", bb_name.c_str(), cluster->bb_bw,
cluster->bb_lat);
}
for (int const& i : cluster->radicals) {
- std::string host_id = std::string(cluster->prefix) + std::to_string(i) + cluster->suffix;
+ std::string host_id = cluster->prefix + std::to_string(i) + cluster->suffix;
XBT_DEBUG("<host\tid=\"%s\"\tspeed=\"%f\">", host_id.c_str(), cluster->speeds.front());
const auto* host = zone->create_host(host_id, cluster->speeds)
XBT_DEBUG("</host>");
- std::string link_id = std::string(cluster->id) + "_link_" + std::to_string(i);
+ std::string link_id = cluster->id + "_link_" + std::to_string(i);
XBT_DEBUG("<link\tid=\"%s\"\tbw=\"%f\"\tlat=\"%f\"/>", link_id.c_str(), cluster->bw, cluster->lat);
// add a loopback link
// add a limiter link (shared link to account for maximal bandwidth of the node)
const simgrid::s4u::Link* limiter = nullptr;
if (cluster->limiter_link > 0) {
- std::string limiter_name = std::string(link_id) + "_limiter";
+ std::string limiter_name = link_id + "_limiter";
XBT_DEBUG("<limiter\tid=\"%s\"\tbw=\"%f\"/>", limiter_name.c_str(), cluster->limiter_link);
limiter = zone->create_link(limiter_name, cluster->limiter_link)->seal();
XBT_DEBUG(" ");
XBT_DEBUG("<router id=\"%s\"/>", cluster->router_id.c_str());
if (cluster->router_id.empty())
- cluster->router_id = std::string(cluster->prefix) + cluster->id + "_router" + cluster->suffix;
+ cluster->router_id = cluster->prefix + cluster->id + "_router" + cluster->suffix;
auto* router = zone->create_router(cluster->router_id);
zone->add_route(router, nullptr, nullptr, nullptr, {});
void sg_platf_trace_connect(simgrid::kernel::routing::TraceConnectCreationArgs* trace_connect)
{
surf_parse_assert(traces_set_list.find(trace_connect->trace) != traces_set_list.end(),
- std::string("Cannot connect trace ") + trace_connect->trace + " to " + trace_connect->element +
+ "Cannot connect trace " + trace_connect->trace + " to " + trace_connect->element +
": trace unknown");
switch (trace_connect->kind) {
trace_connect_list_link_lat.try_emplace(trace_connect->trace, trace_connect->element);
break;
default:
- surf_parse_error(std::string("Cannot connect trace ") + trace_connect->trace + " to " + trace_connect->element +
+ surf_parse_error("Cannot connect trace " + trace_connect->trace + " to " + trace_connect->element +
": unknown kind of trace");
}
}
/* connect all profiles relative to hosts */
for (auto const& [trace, name] : trace_connect_list_host_avail) {
surf_parse_assert(traces_set_list.find(trace) != traces_set_list.end(),
- std::string("<trace_connect kind=\"HOST_AVAIL\">: Trace ") + trace + " undefined.");
+ "<trace_connect kind=\"HOST_AVAIL\">: Trace " + trace + " undefined.");
auto profile = traces_set_list.at(trace);
auto host = engine->host_by_name_or_null(name);
- surf_parse_assert(host, std::string("<trace_connect kind=\"HOST_AVAIL\">: Host ") + name + " undefined.");
+ surf_parse_assert(host, "<trace_connect kind=\"HOST_AVAIL\">: Host " + name + " undefined.");
host->set_state_profile(profile);
}
for (auto const& [trace, name] : trace_connect_list_host_speed) {
surf_parse_assert(traces_set_list.find(trace) != traces_set_list.end(),
- std::string("<trace_connect kind=\"SPEED\">: Trace ") + trace + " undefined.");
+ "<trace_connect kind=\"SPEED\">: Trace " + trace + " undefined.");
auto profile = traces_set_list.at(trace);
auto host = engine->host_by_name_or_null(name);
- surf_parse_assert(host, std::string("<trace_connect kind=\"SPEED\">: Host ") + name + " undefined.");
+ surf_parse_assert(host, "<trace_connect kind=\"SPEED\">: Host " + name + " undefined.");
host->set_speed_profile(profile);
}
for (auto const& [trace, name] : trace_connect_list_link_avail) {
surf_parse_assert(traces_set_list.find(trace) != traces_set_list.end(),
- std::string("<trace_connect kind=\"LINK_AVAIL\">: Trace ") + trace + " undefined.");
+ "<trace_connect kind=\"LINK_AVAIL\">: Trace " + trace + " undefined.");
auto profile = traces_set_list.at(trace);
auto link = engine->link_by_name_or_null(name);
- surf_parse_assert(link, std::string("<trace_connect kind=\"LINK_AVAIL\">: Link ") + name + " undefined.");
+ surf_parse_assert(link, "<trace_connect kind=\"LINK_AVAIL\">: Link " + name + " undefined.");
link->set_state_profile(profile);
}
for (auto const& [trace, name] : trace_connect_list_link_bw) {
surf_parse_assert(traces_set_list.find(trace) != traces_set_list.end(),
- std::string("<trace_connect kind=\"BANDWIDTH\">: Trace ") + trace + " undefined.");
+ "<trace_connect kind=\"BANDWIDTH\">: Trace " + trace + " undefined.");
auto profile = traces_set_list.at(trace);
auto link = engine->link_by_name_or_null(name);
- surf_parse_assert(link, std::string("<trace_connect kind=\"BANDWIDTH\">: Link ") + name + " undefined.");
+ surf_parse_assert(link, "<trace_connect kind=\"BANDWIDTH\">: Link " + name + " undefined.");
link->set_bandwidth_profile(profile);
}
for (auto const& [trace, name] : trace_connect_list_link_lat) {
surf_parse_assert(traces_set_list.find(trace) != traces_set_list.end(),
- std::string("<trace_connect kind=\"LATENCY\">: Trace ") + trace + " undefined.");
+ "<trace_connect kind=\"LATENCY\">: Trace " + trace + " undefined.");
auto profile = traces_set_list.at(trace);
auto link = engine->link_by_name_or_null(name);
- surf_parse_assert(link, std::string("<trace_connect kind=\"LATENCY\">: Link ") + name + " undefined.");
+ surf_parse_assert(link, "<trace_connect kind=\"LATENCY\">: Link " + name + " undefined.");
link->set_latency_profile(profile);
}
end = surf_parse_get_int(radical_ends.back());
break;
default:
- surf_parse_error(std::string("Malformed radical: ") + group);
+ surf_parse_error("Malformed radical: " + group);
}
for (int i = start; i <= end; i++)
exploded->push_back(i);
"available in the tools/ directory of the source archive.");
surf_parse_assert(
version >= 400L,
- std::string("******* THIS FILE IS TOO OLD (v:") + version_string +
+ "******* THIS FILE IS TOO OLD (v:" + version_string +
") *********\n "
"Changes introduced in SimGrid 3.13:\n"
" - 'power' attribute of hosts (and others) got renamed to 'speed'.\n"
"available in the tools/ directory of the source archive.",
version_string.c_str(), surf_parsed_filename.c_str());
}
- surf_parse_assert(version <= 410L, std::string("******* THIS FILE COMES FROM THE FUTURE (v:") + version_string +
+ surf_parse_assert(version <= 410L, "******* THIS FILE COMES FROM THE FUTURE (v:" + version_string +
") *********\n "
"The most recent formalism that this version of SimGrid understands is v4.1.\n"
"Please update your code, or use another, more adapted, file.");
cluster.topology = simgrid::kernel::routing::ClusterTopology::DRAGONFLY;
break;
default:
- surf_parse_error(std::string("Invalid cluster topology for cluster ") + cluster.id);
+ surf_parse_error("Invalid cluster topology for cluster " + cluster.id);
}
cluster.topo_parameters = A_surfxml_cluster_topo___parameters;
cluster.router_id = A_surfxml_cluster_router___id;
cluster.sharing_policy = simgrid::s4u::Link::SharingPolicy::FATPIPE;
break;
default:
- surf_parse_error(std::string("Invalid cluster sharing policy for cluster ") + cluster.id);
+ surf_parse_error("Invalid cluster sharing policy for cluster " + cluster.id);
}
switch (AX_surfxml_cluster_bb___sharing___policy) {
case A_surfxml_cluster_bb___sharing___policy_FATPIPE:
cluster.bb_sharing_policy = simgrid::s4u::Link::SharingPolicy::SHARED;
break;
default:
- surf_parse_error(std::string("Invalid bb sharing policy in cluster ") + cluster.id);
+ surf_parse_error("Invalid bb sharing policy in cluster " + cluster.id);
}
sg_platf_new_tag_cluster(&cluster);
void STag_surfxml_peer(){
simgrid::kernel::routing::PeerCreationArgs peer;
- peer.id = std::string(A_surfxml_peer_id);
+ peer.id = A_surfxml_peer_id;
peer.speed =
xbt_parse_get_speed(surf_parsed_filename, surf_parse_lineno, A_surfxml_peer_speed, "speed of peer " + peer.id);
peer.bw_in = xbt_parse_get_bandwidth(surf_parsed_filename, surf_parse_lineno, A_surfxml_peer_bw___in,
link.properties = property_sets.back();
property_sets.pop_back();
- link.id = std::string(A_surfxml_link_id);
+ link.id = A_surfxml_link_id;
link.bandwidths = xbt_parse_get_bandwidths(surf_parsed_filename, surf_parse_lineno, A_surfxml_link_bandwidth,
"bandwidth of link " + link.id);
link.bandwidth_trace = A_surfxml_link_bandwidth___file[0]
link.policy = simgrid::s4u::Link::SharingPolicy::WIFI;
break;
default:
- surf_parse_error(std::string("Invalid sharing policy in link ") + link.id);
+ surf_parse_error("Invalid sharing policy in link " + link.id);
}
sg_platf_new_link(&link);
switch (A_surfxml_link___ctn_direction) {
case AU_surfxml_link___ctn_direction:
case A_surfxml_link___ctn_direction_NONE:
- link = engine->link_by_name(std::string(A_surfxml_link___ctn_id));
+ link = engine->link_by_name(A_surfxml_link___ctn_id);
break;
case A_surfxml_link___ctn_direction_UP:
- link = engine->split_duplex_link_by_name(std::string(A_surfxml_link___ctn_id));
+ link = engine->split_duplex_link_by_name(A_surfxml_link___ctn_id);
direction = simgrid::s4u::LinkInRoute::Direction::UP;
break;
case A_surfxml_link___ctn_direction_DOWN:
- link = engine->split_duplex_link_by_name(std::string(A_surfxml_link___ctn_id));
+ link = engine->split_duplex_link_by_name(A_surfxml_link___ctn_id);
direction = simgrid::s4u::LinkInRoute::Direction::DOWN;
break;
default:
{
auto link = std::make_unique<simgrid::kernel::routing::LinkCreationArgs>();
- link->id = std::string(A_surfxml_backbone_id);
+ link->id = A_surfxml_backbone_id;
link->bandwidths.push_back(xbt_parse_get_bandwidth(
surf_parsed_filename, surf_parse_lineno, A_surfxml_backbone_bandwidth, "bandwidth of backbone " + link->id));
link->latency = xbt_parse_get_time(surf_parsed_filename, surf_parse_lineno, A_surfxml_backbone_latency,
surf_file_to_parse = surf_fopen(file, "r");
if (surf_file_to_parse == nullptr)
- throw std::invalid_argument(std::string("Unable to open '") + file + "' from '" + simgrid::xbt::Path().get_name() +
+ throw std::invalid_argument("Unable to open '" + file + "' from '" + simgrid::xbt::Path().get_name() +
"'. Does this file exist?");
surf_input_buffer = surf_parse__create_buffer(surf_file_to_parse, YY_BUF_SIZE);
surf_parse__switch_to_buffer(surf_input_buffer);
frame_name.find("simcall_run_answered") != std::string::npos ||
frame_name.find("simcall_run_blocking") != std::string::npos) {
frame_count = 0;
- ss.str(std::string()); // This is how you clear a stringstream in C++. clear() is something else :'(
+ ss.str(""); // This is how you clear a stringstream in C++. clear() is something else :'(
}
if (frame_name == "main")
break;
template <> class ConfigType<std::string> {
public:
static constexpr const char* type_name = "string";
- static inline std::string parse(const char* value)
- {
- return std::string(value);
- }
+ static inline std::string parse(const char* value) { return value; }
};
template <> class ConfigType<bool> {
public:
throw std::invalid_argument(simgrid::xbt::string_printf("Unknown appender log type: '%s'", value));
}
} else if (strncmp(option, "fmt", option_len) == 0) {
- set.fmt = std::string(value);
+ set.fmt = value;
} else {
xbt_die("Unknown setting of the log category: '%.*s'", static_cast<int>(option_len), option);
}
#elif defined __linux__
/* Open the actual process's proc maps file and create the memory_map_t */
/* to be returned. */
- std::string path = std::string("/proc/") + std::to_string(pid) + "/maps";
+ std::string path = "/proc/" + std::to_string(pid) + "/maps";
std::ifstream fp;
fp.rdbuf()->pubsetbuf(nullptr, 0);
fp.open(path);
std::array<char, 2048> buffer;
const char* cwd = getcwd(buffer.data(), 2048);
xbt_assert(cwd != nullptr, "Error during getcwd: %s", strerror(errno));
- path_ = std::string(cwd);
+ path_ = cwd;
#else
- path_ = std::string(".");
+ path_ = ".";
#endif
}
std::string simgrid::xbt::Path::get_dir_name() const
{
std::string p(path_);
- const char* res = dirname(&p[0]);
- return std::string(res, strlen(res));
+ return dirname(&p[0]);
}
std::string simgrid::xbt::Path::get_base_name() const
{
std::string p(path_);
- const char* res = basename(&p[0]);
- return std::string(res, strlen(res));
+ return basename(&p[0]);
}
double res = strtod(string.c_str(), &endptr);
const char* ptr = endptr; // for const-correctness
if (errno == ERANGE)
- throw simgrid::ParseError(filename, lineno, std::string("value out of range: ") + string);
+ throw simgrid::ParseError(filename, lineno, "value out of range: " + string);
if (ptr == string)
- throw simgrid::ParseError(filename, lineno, std::string("cannot parse number:") + string);
+ throw simgrid::ParseError(filename, lineno, "cannot parse number:" + string);
if (ptr[0] == '\0') {
// Ok, 0 can be unit-less
if (res != 0 && not entity_kind.empty())
static std::unique_ptr<ReplayAction> get_action(const char* name)
{
- if (auto queue_elt = action_queues.find(std::string(name)); queue_elt != action_queues.end()) {
+ if (auto queue_elt = action_queues.find(name); queue_elt != action_queues.end()) {
if (auto& my_queue = queue_elt->second; not my_queue.empty()) {
// Get something from my queue and return it
auto action = std::move(my_queue.front());
*/
void xbt_replay_action_register(const char* action_name, const action_fun& function)
{
- simgrid::xbt::action_funs[std::string(action_name)] = function;
+ simgrid::xbt::action_funs[action_name] = function;
}
/**
*/
action_fun xbt_replay_action_get(const char* action_name)
{
- return simgrid::xbt::action_funs.at(std::string(action_name));
+ return simgrid::xbt::action_funs.at(action_name);
}
void xbt_replay_set_tracefile(const std::string& filename)
"the only worker gets killed.");
sg4::Host* master_host = rootzone->create_host("lilibeth 0", 1e9); // Host where the master will stay
for (int i = 1; i < cfg_host_count; i++) {
- auto hostname = std::string("lilibeth ") + std::to_string(i);
+ auto hostname = "lilibeth " + std::to_string(i);
auto* host = rootzone->create_host(hostname, 1e9);
sg4::LinkInRoute link(rootzone->create_link(hostname, "1MBps")->set_latency("24us")->seal());
rootzone->add_route(master_host->get_netpoint(), host->get_netpoint(), nullptr, nullptr, {link}, true);
/* Make a vector of the mailboxes to use */
std::vector<sg4::Mailbox*> mboxes;
- std::string msg_content =
- std::string("Hello, I'm alive and running on ") + std::string(sg4::this_actor::get_host()->get_name());
+ std::string msg_content = "Hello, I'm alive and running on " + sg4::this_actor::get_host()->get_name();
for (const auto* host : hosts_) {
auto* payload = new std::string(msg_content);
/* Create a communication representing the ongoing communication, and store it in pending_comms */
sg4::Actor::create("sender", host_list[0], Sender(host_list));
/* create receiver in every host */
for (auto* host : host_list) {
- sg4::Actor::create(std::string("receiver-") + std::string(host->get_name()), host, Receiver());
+ sg4::Actor::create("receiver-" + host->get_name(), host, Receiver());
}
/* runs the simulation */