long number_of_yields;
public:
- explicit yielder(std::vector<std::string> args) { number_of_yields = std::stod(args[1]); }
+ explicit yielder(std::vector<std::string> args) { number_of_yields = std::stol(args[1]); }
void operator()() const
{
for (int i = 0; i < number_of_yields; i++)
xbt_assert(remote_peer->hasPiece(piece));
int block_index = getFirstMissingBlockFrom(piece);
if (block_index != -1) {
- int block_length = std::min(BLOCKS_REQUESTED, PIECES_BLOCKS - block_index);
+ int block_length = static_cast<int>(std::min(BLOCKS_REQUESTED, PIECES_BLOCKS - block_index));
XBT_DEBUG("Sending a REQUEST to %s for piece %u (%d,%d)", remote_peer->mailbox_->get_cname(), piece, block_index,
block_length);
remote_peer->mailbox_
do {
// We choose a random peer to unchoke.
std::unordered_map<int, Connection>::iterator chosen_peer_it = connected_peers.begin();
- std::advance(chosen_peer_it, random.uniform_int(0, connected_peers.size() - 1));
+ std::advance(chosen_peer_it, random.uniform_int(0, static_cast<int>(connected_peers.size() - 1)));
chosen_peer = &chosen_peer_it->second;
if (not chosen_peer->interested || not chosen_peer->choked_upload)
chosen_peer = nullptr;
// Sending back peers to the requesting peer
TrackerAnswer* ta = new TrackerAnswer(TRACKER_QUERY_INTERVAL);
std::set<int>::iterator next_peer;
- int nb_known_peers = known_peers.size();
+ int nb_known_peers = static_cast<int>(known_peers.size());
int max_tries = std::min(MAXIMUM_PEERS, nb_known_peers);
int tried = 0;
while (tried < max_tries) {
XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_app_masterworker, "Messages specific for this s4u example");
class Master {
- long tasks_count = 0;
- double compute_cost = 0;
- double communicate_cost = 0;
+ long tasks_count = 0;
+ double compute_cost = 0;
+ long communicate_cost = 0;
std::vector<simgrid::s4u::Mailbox*> workers;
public:
tasks_count = std::stol(args[1]);
compute_cost = std::stod(args[2]);
- communicate_cost = std::stod(args[3]);
+ communicate_cost = std::stol(args[3]);
for (unsigned int i = 4; i < args.size(); i++)
workers.push_back(simgrid::s4u::Mailbox::by_name(args[i]));
{
xbt_assert(args.size() > 4, "The master function expects at least 3 arguments");
- long tasks_count = std::stol(args[1]);
- double compute_cost = std::stod(args[2]);
- double communication_cost = std::stod(args[3]);
+ long tasks_count = std::stol(args[1]);
+ double compute_cost = std::stod(args[2]);
+ long communication_cost = std::stol(args[3]);
std::vector<simgrid::s4u::Mailbox*> workers;
for (unsigned int i = 4; i < args.size(); i++)
workers.push_back(simgrid::s4u::Mailbox::by_name(args[i]));
xbt_assert(argc == 5, "Expecting 4 parameters from the XML deployment file but got %d", argc);
int my_id = std::stoi(argv[1]); /* - my id */
long messages_count = std::stol(argv[2]); /* - number of message */
- double msg_size = std::stol(argv[3]); /* - message size in bytes */
- long peers_count = std::stod(argv[4]); /* - number of peers */
+ long msg_size = std::stol(argv[3]); /* - message size in bytes */
+ long peers_count = std::stol(argv[4]); /* - number of peers */
/* Set myself as the persistent receiver of my mailbox so that messages start flowing to me as soon as they are put
* into it */
/* Retrieve all the messages other peers have been sending to me until I receive all the corresponding "Finalize"
* messages */
- int pending_finalize_messages = peers_count - 1;
+ long pending_finalize_messages = peers_count - 1;
while (pending_finalize_messages > 0) {
if (my_mbox->ready()) {
double start = simgrid::s4u::Engine::get_clock();
{
xbt_assert(argc == 3, "Expecting 2 parameters from the XML deployment file but got %d", argc);
long messages_count = std::stol(argv[1]); /* - number of messages */
- double msg_size = std::stod(argv[2]); /* - message size in bytes */
+ long msg_size = std::stol(argv[2]); /* - message size in bytes */
double sleep_start_time = 5.0;
double sleep_test_time = 0;
class Sender {
long messages_count; /* - number of messages */
long receivers_count; /* - number of receivers */
- double msg_size; /* - message size in bytes */
+ long msg_size; /* - message size in bytes */
public:
explicit Sender(std::vector<std::string> args)
{
xbt_assert(args.size() == 4, "Expecting 3 parameters from the XML deployment file but got %zu", args.size());
messages_count = std::stol(args[1]);
- msg_size = std::stod(args[2]);
+ msg_size = std::stol(args[2]);
receivers_count = std::stol(args[3]);
}
void operator()() const
class Sender {
long messages_count; /* - number of messages */
long receivers_count; /* - number of receivers */
- double msg_size; /* - message size in bytes */
+ long msg_size; /* - message size in bytes */
public:
explicit Sender(std::vector<std::string> args)
{
xbt_assert(args.size() == 4, "Expecting 3 parameters from the XML deployment file but got %zu", args.size());
messages_count = std::stol(args[1]);
- msg_size = std::stod(args[2]);
+ msg_size = std::stol(args[2]);
receivers_count = std::stol(args[3]);
}
void operator()() const
{
xbt_assert(argc == 4, "Expecting 3 parameters from the XML deployment file but got %d", argc);
long messages_count = std::stol(argv[1]); /* - number of messages */
- double msg_size = std::stod(argv[2]); /* - message size in bytes */
+ long msg_size = std::stol(argv[2]); /* - message size in bytes */
long receivers_count = std::stol(argv[3]); /* - number of receivers */
std::vector<simgrid::s4u::CommPtr> pending_comms;
while (not strncmp(options[0], "-", 1)) {
unsigned int length = strlen("-nb_bits=");
if (not strncmp(options[0], "-nb_bits=", length) && strlen(options[0]) > length) {
- nb_bits = xbt_str_parse_int(options[0] + length, "Invalid nb_bits parameter: %s");
+ nb_bits = static_cast<int>(xbt_str_parse_int(options[0] + length, "Invalid nb_bits parameter: %s"));
XBT_DEBUG("Set nb_bits to %d", nb_bits);
} else {
length = strlen("-timeout=");
if (not strncmp(options[0], "-timeout=", length) && strlen(options[0]) > length) {
- timeout = xbt_str_parse_int(options[0] + length, "Invalid timeout parameter: %s");
+ timeout = static_cast<int>(xbt_str_parse_int(options[0] + length, "Invalid timeout parameter: %s"));
XBT_DEBUG("Set timeout to %d", timeout);
} else {
xbt_die("Invalid chord option '%s'", options[0]);
double deadline;
xbt_assert(argc == 3 || argc == 4, "Wrong number of arguments");
/* Node initialization */
- unsigned int node_id = strtoul(argv[1], nullptr, 0);
+ unsigned int node_id = static_cast<unsigned int>(strtoul(argv[1], nullptr, 0));
kademlia::Node node(node_id);
if (argc == 4) {
XBT_INFO("Hi, I'm going to join the network with id %u", node.getId());
- unsigned int known_id = strtoul(argv[2], NULL, 0);
+ unsigned int known_id = static_cast<unsigned int>(strtoul(argv[2], NULL, 0));
join_success = node.join(known_id);
deadline = std::stod(argv[3]);
} else {
static void sender(std::vector<std::string> args)
{
xbt_assert(args.size() == 2, "The master function expects 2 arguments.");
- int flow_amount = std::stoi(args.at(0));
- double comm_size = std::stod(args.at(1));
- XBT_INFO("Send %.0f bytes, in %d flows", comm_size, flow_amount);
+ int flow_amount = std::stoi(args.at(0));
+ long comm_size = std::stol(args.at(1));
+ XBT_INFO("Send %ld bytes, in %d flows", comm_size, flow_amount);
simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::string("message"));
if (flow_amount == 1) {
/* - Send the task to the @ref worker */
- char* payload = bprintf("%f", comm_size);
+ char* payload = bprintf("%ld", comm_size);
mailbox->put(payload, comm_size);
} else {
// Start all comms in parallel, and wait for all completions in one shot
static void client(int id)
{
- int my_pid = simgrid::s4u::this_actor::get_pid();
+ aid_t my_pid = simgrid::s4u::this_actor::get_pid();
simgrid::s4u::Mailbox* my_mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id));
simgrid::s4u::Mailbox::by_name("coordinator")->put(new Message(Message::Kind::RELEASE, my_mailbox), 1000);
- simgrid::s4u::this_actor::sleep_for(my_pid);
+ simgrid::s4u::this_actor::sleep_for(static_cast<double>(my_pid));
if (id == 1) {
cs = 0;
simgrid::s4u::Mailbox* mailbox;
long number_of_tasks = xbt_str_parse_int(argv[1], "Invalid amount of tasks: %s");
double comp_size = xbt_str_parse_double(argv[2], "Invalid computational size: %s");
- double comm_size = xbt_str_parse_double(argv[3], "Invalid communication size: %s");
+ long comm_size = xbt_str_parse_int(argv[3], "Invalid communication size: %s");
long workers_count = xbt_str_parse_int(argv[4], "Invalid amount of workers: %s");
XBT_INFO("Got %ld workers and %ld tasks to process", workers_count, number_of_tasks);
static void send(simgrid::xbt::ReplayAction& action)
{
- double size = std::stod(action[3]);
- std::string* payload = new std::string(action[3]);
- double clock = simgrid::s4u::Engine::get_clock();
+ long size = static_cast<long>(std::stod(action[3]));
+ std::string* payload = new std::string(action[3]);
+ double clock = simgrid::s4u::Engine::get_clock();
simgrid::s4u::Mailbox* to = simgrid::s4u::Mailbox::by_name(simgrid::s4u::this_actor::get_name() + "_" + action[2]);
- ACT_DEBUG("Entering Send: %s (size: %g) -- Actor %s on mailbox %s", NAME.c_str(), size,
+ ACT_DEBUG("Entering Send: %s (size: %ld) -- Actor %s on mailbox %s", NAME.c_str(), size,
simgrid::s4u::this_actor::get_cname(), to->get_cname());
to->put(payload, size);
delete payload;
{
xbt_assert(args.size() > 4, "The master function expects at least 3 arguments");
- long tasks_count = std::stol(args[1]);
- double compute_cost = std::stod(args[2]);
- double communication_cost = std::stod(args[3]);
+ long tasks_count = std::stol(args[1]);
+ double compute_cost = std::stod(args[2]);
+ long communication_cost = std::stol(args[3]);
std::vector<simgrid::s4u::Mailbox*> workers;
for (unsigned int i = 4; i < args.size(); i++)
workers.push_back(simgrid::s4u::Mailbox::by_name(args[i]));