e.run();
- XBT_INFO("Simulation time %g", simgrid::s4u::Engine::getClock());
+ XBT_INFO("Simulation time %g", simgrid::s4u::Engine::get_clock());
return 0;
}
// Getting peer data from the tracker.
if (getPeersFromTracker()) {
XBT_DEBUG("Got %zu peers from the tracker. Current status is: %s", connected_peers.size(), getStatus().c_str());
- begin_receive_time = simgrid::s4u::Engine::getClock();
+ begin_receive_time = simgrid::s4u::Engine::get_clock();
mailbox_->setReceiver(simgrid::s4u::Actor::self());
if (hasFinished()) {
sendHandshakeToAllPeers();
void Peer::leech()
{
- double next_choked_update = simgrid::s4u::Engine::getClock() + UPDATE_CHOKED_INTERVAL;
+ double next_choked_update = simgrid::s4u::Engine::get_clock() + UPDATE_CHOKED_INTERVAL;
XBT_DEBUG("Start downloading.");
/* Send a "handshake" message to all the peers it got (since it couldn't have gotten more than 50 peers) */
XBT_DEBUG("Starting main leech loop listening on mailbox: %s", mailbox_->get_cname());
void* data = nullptr;
- while (simgrid::s4u::Engine::getClock() < deadline && countPieces(bitfield_) < FILE_PIECES) {
+ while (simgrid::s4u::Engine::get_clock() < deadline && countPieces(bitfield_) < FILE_PIECES) {
if (comm_received == nullptr) {
comm_received = mailbox_->get_async(&data);
}
comm_received = nullptr;
} else {
// We don't execute the choke algorithm if we don't already have a piece
- if (simgrid::s4u::Engine::getClock() >= next_choked_update && countPieces(bitfield_) > 0) {
+ if (simgrid::s4u::Engine::get_clock() >= next_choked_update && countPieces(bitfield_) > 0) {
updateChokedPeers();
next_choked_update += UPDATE_CHOKED_INTERVAL;
} else {
void Peer::seed()
{
- double next_choked_update = simgrid::s4u::Engine::getClock() + UPDATE_CHOKED_INTERVAL;
+ double next_choked_update = simgrid::s4u::Engine::get_clock() + UPDATE_CHOKED_INTERVAL;
XBT_DEBUG("Start seeding.");
// start the main seed loop
void* data = nullptr;
- while (simgrid::s4u::Engine::getClock() < deadline) {
+ while (simgrid::s4u::Engine::get_clock() < deadline) {
if (comm_received == nullptr) {
comm_received = mailbox_->get_async(&data);
}
delete message;
comm_received = nullptr;
} else {
- if (simgrid::s4u::Engine::getClock() >= next_choked_update) {
+ if (simgrid::s4u::Engine::get_clock() >= next_choked_update) {
updateChokedPeers();
// TODO: Change the choked peer algorithm when seeding.
next_choked_update += UPDATE_CHOKED_INTERVAL;
}
// Update the peer speed.
if (remote_peer) {
- remote_peer->addSpeedValue(1.0 / (simgrid::s4u::Engine::getClock() - begin_receive_time));
+ remote_peer->addSpeedValue(1.0 / (simgrid::s4u::Engine::get_clock() - begin_receive_time));
}
- begin_receive_time = simgrid::s4u::Engine::getClock();
+ begin_receive_time = simgrid::s4u::Engine::get_clock();
}
/** Selects the appropriate piece to download and requests it to the remote_peer */
/**If we are currently seeding, we unchoke the peer which has been unchoked the last time.*/
if (hasFinished()) {
Connection* remote_peer;
- double unchoke_time = simgrid::s4u::Engine::getClock() + 1;
+ double unchoke_time = simgrid::s4u::Engine::get_clock() + 1;
for (auto const& kv : connected_peers) {
remote_peer = kv.second;
if (remote_peer->last_unchoke < unchoke_time && remote_peer->interested && remote_peer->choked_upload) {
xbt_assert((chosen_peer->choked_upload), "Tries to unchoked an unchoked peer");
chosen_peer->choked_upload = false;
active_peers.insert(chosen_peer);
- chosen_peer->last_unchoke = simgrid::s4u::Engine::getClock();
+ chosen_peer->last_unchoke = simgrid::s4u::Engine::get_clock();
XBT_DEBUG("(%d) Sending a UNCHOKE to %d", id, chosen_peer->id);
updateActivePeersSet(chosen_peer);
sendMessage(chosen_peer->mailbox_, MESSAGE_UNCHOKE, MESSAGE_UNCHOKE_SIZE);
{
simgrid::s4u::CommPtr comm = nullptr;
void* received = nullptr;
- while (simgrid::s4u::Engine::getClock() < deadline) {
+ while (simgrid::s4u::Engine::get_clock() < deadline) {
if (comm == nullptr)
comm = mailbox->get_async(&received);
if (comm->test()) {
Peer* p = new Peer();
- double start_time = simgrid::s4u::Engine::getClock();
+ double start_time = simgrid::s4u::Engine::get_clock();
p->joinChain();
p->forwardFile();
simgrid::s4u::Comm::wait_all(&p->pending_sends);
- double end_time = simgrid::s4u::Engine::getClock();
+ double end_time = simgrid::s4u::Engine::get_clock();
XBT_INFO("### %f %llu bytes (Avg %f MB/s); copy finished (simulated).", end_time - start_time, p->received_bytes,
p->received_bytes / 1024.0 / 1024.0 / (end_time - start_time));
simgrid::s4u::Actor::create("peer", simgrid::s4u::Host::by_name("node-8.acme.org"), peer);
e.run();
- XBT_INFO("Total simulation time: %e", simgrid::s4u::Engine::getClock());
+ XBT_INFO("Total simulation time: %e", simgrid::s4u::Engine::get_clock());
return 0;
}
e.run(); /** - Run the simulation */
- XBT_INFO("Simulation time %g", e.getClock());
+ XBT_INFO("Simulation time %g", e.get_clock());
return 0;
}
/* - Do the ping with a 1-Byte task (latency bound) ... */
double* payload = new double();
- *payload = simgrid::s4u::Engine::getClock();
+ *payload = simgrid::s4u::Engine::get_clock();
simgrid::s4u::Mailbox::byName(args[0])->put(payload, 1);
/* - ... then wait for the (large) pong */
double* sender_time =
static_cast<double*>(simgrid::s4u::Mailbox::byName(simgrid::s4u::this_actor::get_host()->get_name())->get());
- double communication_time = simgrid::s4u::Engine::getClock() - *sender_time;
+ double communication_time = simgrid::s4u::Engine::get_clock() - *sender_time;
XBT_INFO("Task received : large communication (bandwidth bound)");
XBT_INFO("Pong time (bandwidth bound): %.3f", communication_time);
delete sender_time;
/* - Receive the (small) ping first ....*/
double* sender_time =
static_cast<double*>(simgrid::s4u::Mailbox::byName(simgrid::s4u::this_actor::get_host()->get_name())->get());
- double communication_time = simgrid::s4u::Engine::getClock() - *sender_time;
+ double communication_time = simgrid::s4u::Engine::get_clock() - *sender_time;
XBT_INFO("Task received : small communication (latency bound)");
XBT_INFO(" Ping time (latency bound) %f", communication_time);
delete sender_time;
/* - ... Then send a 1GB pong back (bandwidth bound) */
double* payload = new double();
- *payload = simgrid::s4u::Engine::getClock();
+ *payload = simgrid::s4u::Engine::get_clock();
XBT_INFO("task_bw->data = %.3f", *payload);
simgrid::s4u::Mailbox::byName(args[0])->put(payload, 1e9);
e.run();
- XBT_INFO("Total simulation time: %.3f", e.getClock());
+ XBT_INFO("Total simulation time: %.3f", e.get_clock());
return 0;
}
id++;
}
e.run();
- XBT_INFO("Simulation time %g", e.getClock());
+ XBT_INFO("Simulation time %g", e.get_clock());
return 0;
}
static void worker(double computation_amount, bool use_bound, double bound)
{
- double clock_start = simgrid::s4u::Engine::getClock();
+ double clock_start = simgrid::s4u::Engine::get_clock();
simgrid::s4u::ExecPtr exec = simgrid::s4u::this_actor::exec_init(computation_amount);
}
exec->start();
exec->wait();
- double clock_end = simgrid::s4u::Engine::getClock();
+ double clock_end = simgrid::s4u::Engine::get_clock();
double duration = clock_end - clock_start;
double flops_per_sec = computation_amount / duration;
simgrid::s4u::Actor::create("master_", simgrid::s4u::Host::by_name("Fafard"), master_main);
e.run();
- XBT_INFO("Bye (simulation time %g)", simgrid::s4u::Engine::getClock());
+ XBT_INFO("Bye (simulation time %g)", simgrid::s4u::Engine::get_clock());
return 0;
}
static void vm_migrate(simgrid::s4u::VirtualMachine* vm, simgrid::s4u::Host* dst_pm)
{
simgrid::s4u::Host* src_pm = vm->getPm();
- double mig_sta = simgrid::s4u::Engine::getClock();
+ double mig_sta = simgrid::s4u::Engine::get_clock();
sg_vm_migrate(vm, dst_pm);
- double mig_end = simgrid::s4u::Engine::getClock();
+ double mig_end = simgrid::s4u::Engine::get_clock();
XBT_INFO("%s migrated: %s->%s in %g s", vm->get_cname(), src_pm->get_cname(), dst_pm->get_cname(), mig_end - mig_sta);
}
e.run();
- XBT_INFO("Bye (simulation time %g)", simgrid::s4u::Engine::getClock());
+ XBT_INFO("Bye (simulation time %g)", simgrid::s4u::Engine::get_clock());
return 0;
}
static void computation_fun()
{
- double clock_sta = simgrid::s4u::Engine::getClock();
+ double clock_sta = simgrid::s4u::Engine::get_clock();
simgrid::s4u::this_actor::execute(1000000);
- double clock_end = simgrid::s4u::Engine::getClock();
+ double clock_end = simgrid::s4u::Engine::get_clock();
XBT_INFO("%s:%s task executed %g", simgrid::s4u::this_actor::get_host()->get_cname(),
simgrid::s4u::this_actor::get_cname(), clock_end - clock_sta);
s_payload* payload = new s_payload;
payload->tx_actor_name = simgrid::s4u::Actor::self()->get_cname();
payload->tx_host = simgrid::s4u::this_actor::get_host();
- payload->clock_sta = simgrid::s4u::Engine::getClock();
+ payload->clock_sta = simgrid::s4u::Engine::get_clock();
mbox->put(payload, 1000000);
}
simgrid::s4u::MailboxPtr mbox = simgrid::s4u::Mailbox::byName(args.at(0));
struct s_payload* payload = static_cast<struct s_payload*>(mbox->get());
- double clock_end = simgrid::s4u::Engine::getClock();
+ double clock_end = simgrid::s4u::Engine::get_clock();
XBT_INFO("%s:%s to %s:%s => %g sec", payload->tx_host->get_cname(), payload->tx_actor_name, host_name, actor_name,
clock_end - payload->clock_sta);
e.run();
- XBT_INFO("Simulation time %g", e.getClock());
+ XBT_INFO("Simulation time %g", e.get_clock());
return 0;
}
if (args.size() == 3) { // first ring
deadline_ = std::stod(args[2]);
- start_time_ = simgrid::s4u::Engine::getClock();
+ start_time_ = simgrid::s4u::Engine::get_clock();
XBT_DEBUG("Create a new Chord ring...");
} else {
known_id_ = std::stoi(args[2]);
e.run();
- XBT_INFO("Simulated time: %g", e.getClock());
+ XBT_INFO("Simulated time: %g", e.get_clock());
chord_exit();
if (not joined)
return;
void* data = nullptr;
- double now = simgrid::s4u::Engine::getClock();
+ double now = simgrid::s4u::Engine::get_clock();
double next_stabilize_date = start_time_ + PERIODIC_STABILIZE_DELAY;
double next_fix_fingers_date = start_time_ + PERIODIC_FIX_FINGERS_DELAY;
double next_check_predecessor_date = start_time_ + PERIODIC_CHECK_PREDECESSOR_DELAY;
// no task was received: make some periodic calls
if (now >= next_stabilize_date) {
stabilize();
- next_stabilize_date = simgrid::s4u::Engine::getClock() + PERIODIC_STABILIZE_DELAY;
+ next_stabilize_date = simgrid::s4u::Engine::get_clock() + PERIODIC_STABILIZE_DELAY;
} else if (now >= next_fix_fingers_date) {
fixFingers();
- next_fix_fingers_date = simgrid::s4u::Engine::getClock() + PERIODIC_FIX_FINGERS_DELAY;
+ next_fix_fingers_date = simgrid::s4u::Engine::get_clock() + PERIODIC_FIX_FINGERS_DELAY;
} else if (now >= next_check_predecessor_date) {
checkPredecessor();
- next_check_predecessor_date = simgrid::s4u::Engine::getClock() + PERIODIC_CHECK_PREDECESSOR_DELAY;
+ next_check_predecessor_date = simgrid::s4u::Engine::get_clock() + PERIODIC_CHECK_PREDECESSOR_DELAY;
} else if (now >= next_lookup_date) {
randomLookup();
- next_lookup_date = simgrid::s4u::Engine::getClock() + PERIODIC_LOOKUP_DELAY;
+ next_lookup_date = simgrid::s4u::Engine::get_clock() + PERIODIC_LOOKUP_DELAY;
} else {
// nothing to do: sleep for a while
simgrid::s4u::this_actor::sleep_for(SLEEP_DELAY);
}
- now = simgrid::s4u::Engine::getClock();
+ now = simgrid::s4u::Engine::get_clock();
}
if (data != nullptr) {
comm_receive = nullptr;
data = nullptr;
}
- now = simgrid::s4u::Engine::getClock();
+ now = simgrid::s4u::Engine::get_clock();
}
if (comm_receive != nullptr) {
if (comm_receive->test())
unsigned int answers;
bool destination_found = false;
unsigned int nodes_added = 0;
- double global_timeout = simgrid::s4u::Engine::getClock() + find_node_global_timeout;
+ double global_timeout = simgrid::s4u::Engine::get_clock() + find_node_global_timeout;
unsigned int steps = 0;
/* First we build a list of who we already know */
answers = 0;
queries = sendFindNodeToBest(node_list);
nodes_added = 0;
- double timeout = simgrid::s4u::Engine::getClock() + find_node_timeout;
+ double timeout = simgrid::s4u::Engine::get_clock() + find_node_timeout;
steps++;
- double time_beginreceive = simgrid::s4u::Engine::getClock();
+ double time_beginreceive = simgrid::s4u::Engine::get_clock();
simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::byName(std::to_string(id_));
do {
handleFindNode(msg);
}
// Update the timeout if we didn't have our answer
- timeout += simgrid::s4u::Engine::getClock() - time_beginreceive;
- time_beginreceive = simgrid::s4u::Engine::getClock();
+ timeout += simgrid::s4u::Engine::get_clock() - time_beginreceive;
+ time_beginreceive = simgrid::s4u::Engine::get_clock();
}
delete msg->answer_;
delete msg;
} else {
simgrid::s4u::this_actor::sleep_for(1);
}
- } while (simgrid::s4u::Engine::getClock() < timeout && answers < queries);
+ } while (simgrid::s4u::Engine::get_clock() < timeout && answers < queries);
destination_found = node_list->destinationFound();
} while (not destination_found && (nodes_added > 0 || answers == 0) &&
- simgrid::s4u::Engine::getClock() < global_timeout && steps < MAX_STEPS);
+ simgrid::s4u::Engine::get_clock() < global_timeout && steps < MAX_STEPS);
if (destination_found) {
if (count_in_stats)
if (join_success) {
XBT_VERB("Ok, I'm joining the network with id %u", node->getId());
// We start the main loop
- double next_lookup_time = simgrid::s4u::Engine::getClock() + random_lookup_interval;
+ double next_lookup_time = simgrid::s4u::Engine::get_clock() + random_lookup_interval;
XBT_VERB("Main loop start");
simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::byName(std::to_string(node->getId()));
- while (simgrid::s4u::Engine::getClock() < deadline) {
+ while (simgrid::s4u::Engine::get_clock() < deadline) {
if (node->receive_comm == nullptr)
node->receive_comm = mailbox->get_async(&node->received_msg);
simgrid::s4u::this_actor::sleep_for(1);
} else {
/* We search for a pseudo random node */
- if (simgrid::s4u::Engine::getClock() >= next_lookup_time) {
+ if (simgrid::s4u::Engine::get_clock() >= next_lookup_time) {
node->randomLookup();
next_lookup_time += random_lookup_interval;
} else {
e.run();
- XBT_INFO("Simulated time: %g", simgrid::s4u::Engine::getClock());
+ XBT_INFO("Simulated time: %g", simgrid::s4u::Engine::get_clock());
return 0;
}
XBT_INFO("Initial peak speed=%.0E flop/s; Energy dissipated =%.0E J", host1->getSpeed(),
sg_host_get_consumed_energy(host1));
- double start = simgrid::s4u::Engine::getClock();
+ double start = simgrid::s4u::Engine::get_clock();
XBT_INFO("Sleep for 10 seconds");
simgrid::s4u::this_actor::sleep_for(10);
XBT_INFO("Done sleeping (duration: %.2f s). Current peak speed=%.0E; Energy dissipated=%.2f J",
- simgrid::s4u::Engine::getClock() - start, host1->getSpeed(), sg_host_get_consumed_energy(host1));
+ simgrid::s4u::Engine::get_clock() - start, host1->getSpeed(), sg_host_get_consumed_energy(host1));
// Execute something
- start = simgrid::s4u::Engine::getClock();
+ start = simgrid::s4u::Engine::get_clock();
double flopAmount = 100E6;
XBT_INFO("Run a task of %.0E flops", flopAmount);
simgrid::s4u::this_actor::execute(flopAmount);
XBT_INFO("Task done (duration: %.2f s). Current peak speed=%.0E flop/s; Current consumption: from %.0fW to %.0fW"
" depending on load; Energy dissipated=%.0f J",
- simgrid::s4u::Engine::getClock() - start, host1->getSpeed(),
+ simgrid::s4u::Engine::get_clock() - start, host1->getSpeed(),
sg_host_get_wattmin_at(host1, host1->getPstate()), sg_host_get_wattmax_at(host1, host1->getPstate()),
sg_host_get_consumed_energy(host1));
host1->getPstateSpeed(pstate), host1->getSpeed());
// Run another task
- start = simgrid::s4u::Engine::getClock();
+ start = simgrid::s4u::Engine::get_clock();
XBT_INFO("Run a task of %.0E flops", flopAmount);
simgrid::s4u::this_actor::execute(flopAmount);
XBT_INFO("Task done (duration: %.2f s). Current peak speed=%.0E flop/s; Energy dissipated=%.0f J",
- simgrid::s4u::Engine::getClock() - start, host1->getSpeed(), sg_host_get_consumed_energy(host1));
+ simgrid::s4u::Engine::get_clock() - start, host1->getSpeed(), sg_host_get_consumed_energy(host1));
- start = simgrid::s4u::Engine::getClock();
+ start = simgrid::s4u::Engine::get_clock();
XBT_INFO("Sleep for 4 seconds");
simgrid::s4u::this_actor::sleep_for(4);
XBT_INFO("Done sleeping (duration: %.2f s). Current peak speed=%.0E flop/s; Energy dissipated=%.0f J",
- simgrid::s4u::Engine::getClock() - start, host1->getSpeed(), sg_host_get_consumed_energy(host1));
+ simgrid::s4u::Engine::get_clock() - start, host1->getSpeed(), sg_host_get_consumed_energy(host1));
// =========== Turn the other host off ==========
XBT_INFO("Turning MyHost2 off, and sleeping another 10 seconds. MyHost2 dissipated %.0f J so far.",
sg_host_get_consumed_energy(host2));
host2->turnOff();
- start = simgrid::s4u::Engine::getClock();
+ start = simgrid::s4u::Engine::get_clock();
simgrid::s4u::this_actor::sleep_for(10);
XBT_INFO("Done sleeping (duration: %.2f s). Current peak speed=%.0E flop/s; Energy dissipated=%.0f J",
- simgrid::s4u::Engine::getClock() - start, host1->getSpeed(), sg_host_get_consumed_energy(host1));
+ simgrid::s4u::Engine::get_clock() - start, host1->getSpeed(), sg_host_get_consumed_energy(host1));
}
int main(int argc, char* argv[])
XBT_INFO("Total simulation time: %.2f; Host2 and Host3 must have the exact same energy consumption; Host1 is "
"multi-core and will differ.",
- simgrid::s4u::Engine::getClock());
+ simgrid::s4u::Engine::get_clock());
return 0;
}
e.run();
- XBT_INFO("Simulation time %g", e.getClock());
+ XBT_INFO("Simulation time %g", e.get_clock());
return 0;
}
// Run a task
simgrid::s4u::this_actor::execute(workload);
- double task_time = simgrid::s4u::Engine::getClock();
+ double task_time = simgrid::s4u::Engine::get_clock();
XBT_INFO("Task1 simulation time: %e", task_time);
// Change power peak
// Run a second task
simgrid::s4u::this_actor::execute(workload);
- task_time = simgrid::s4u::Engine::getClock() - task_time;
+ task_time = simgrid::s4u::Engine::get_clock() - task_time;
XBT_INFO("Task2 simulation time: %e", task_time);
// Verify that the default pstate is set to 0
e.run();
- XBT_INFO("Total simulation time: %e", e.getClock());
+ XBT_INFO("Total simulation time: %e", e.get_clock());
return 0;
}
e.load_platform(argv[1]);
e.register_function("host", host);
e.load_deployment(argv[2]);
- std::vector<simgrid::s4u::Storage*> allStorages = e.getAllStorages();
+ std::vector<simgrid::s4u::Storage*> allStorages = e.get_all_storages();
for (auto const& s : allStorages) {
XBT_INFO("Init: %llu/%llu MiB used/free on '%s'", sg_storage_get_size_used(s) / INMEGA,
sg_storage_get_size_free(s) / INMEGA, s->get_cname());
}
- XBT_INFO("Simulation time %g", simgrid::s4u::Engine::getClock());
+ XBT_INFO("Simulation time %g", simgrid::s4u::Engine::get_clock());
return 0;
}
simgrid::s4u::Actor::create("", simgrid::s4u::Host::by_name("denise"), host);
e.run();
- XBT_INFO("Simulated time: %g", simgrid::s4u::Engine::getClock());
+ XBT_INFO("Simulated time: %g", simgrid::s4u::Engine::get_clock());
return 0;
}
XBT_INFO("Initial peak speed: %.0E flop/s; number of flops computed so far: %.0E (should be 0) and current average load: %.5f (should be 0)", host->getSpeed(),
sg_host_get_computed_flops(host), sg_host_get_avg_load(host));
- double start = simgrid::s4u::Engine::getClock();
+ double start = simgrid::s4u::Engine::get_clock();
XBT_INFO("Sleep for 10 seconds");
simgrid::s4u::this_actor::sleep_for(10);
double speed = host->getSpeed();
XBT_INFO("Done sleeping %.2fs; peak speed: %.0E flop/s; number of flops computed so far: %.0E (nothing should have "
"changed)",
- simgrid::s4u::Engine::getClock() - start, host->getSpeed(), sg_host_get_computed_flops(host));
+ simgrid::s4u::Engine::get_clock() - start, host->getSpeed(), sg_host_get_computed_flops(host));
// Run a task
- start = simgrid::s4u::Engine::getClock();
+ start = simgrid::s4u::Engine::get_clock();
XBT_INFO("Run a task of %.0E flops at current speed of %.0E flop/s", 200E6, host->getSpeed());
simgrid::s4u::this_actor::execute(200E6);
- XBT_INFO("Done working on my task; this took %.2fs; current peak speed: %.0E flop/s (when I started the computation, the speed was set to %.0E flop/s); number of flops computed so "
+ XBT_INFO("Done working on my task; this took %.2fs; current peak speed: %.0E flop/s (when I started the computation, "
+ "the speed was set to %.0E flop/s); number of flops computed so "
"far: %.2E, average load as reported by the HostLoad plugin: %.5f (should be %.5f)",
- simgrid::s4u::Engine::getClock() - start, host->getSpeed(), speed, sg_host_get_computed_flops(host), sg_host_get_avg_load(host),
- static_cast<double>(200E6)/(10.5*speed*host->getCoreCount()+(simgrid::s4u::Engine::getClock()-start-0.5)*host->getSpeed()*host->getCoreCount()));
+ simgrid::s4u::Engine::get_clock() - start, host->getSpeed(), speed, sg_host_get_computed_flops(host),
+ sg_host_get_avg_load(host),
+ static_cast<double>(200E6) /
+ (10.5 * speed * host->getCoreCount() +
+ (simgrid::s4u::Engine::get_clock() - start - 0.5) * host->getSpeed() * host->getCoreCount()));
// ========= Change power peak =========
int pstate = 1;
host->getPstateSpeed(pstate), host->getSpeed(), sg_host_get_avg_load(host));
// Run a second task
- start = simgrid::s4u::Engine::getClock();
+ start = simgrid::s4u::Engine::get_clock();
XBT_INFO("Run a task of %.0E flops", 100E6);
simgrid::s4u::this_actor::execute(100E6);
XBT_INFO("Done working on my task; this took %.2fs; current peak speed: %.0E flop/s; number of flops computed so "
"far: %.2E",
- simgrid::s4u::Engine::getClock() - start, host->getSpeed(), sg_host_get_computed_flops(host));
+ simgrid::s4u::Engine::get_clock() - start, host->getSpeed(), sg_host_get_computed_flops(host));
- start = simgrid::s4u::Engine::getClock();
+ start = simgrid::s4u::Engine::get_clock();
XBT_INFO("========= Requesting a reset of the computation and load counters");
sg_host_load_reset(host);
XBT_INFO("After reset: %.0E flops computed; load is %.5f", sg_host_get_computed_flops(host), sg_host_get_avg_load(host));
XBT_INFO("Sleep for 4 seconds");
simgrid::s4u::this_actor::sleep_for(4);
XBT_INFO("Done sleeping %.2f s; peak speed: %.0E flop/s; number of flops computed so far: %.0E",
- simgrid::s4u::Engine::getClock() - start, host->getSpeed(), sg_host_get_computed_flops(host));
+ simgrid::s4u::Engine::get_clock() - start, host->getSpeed(), sg_host_get_computed_flops(host));
// =========== Turn the other host off ==========
s4u_Host* host2 = simgrid::s4u::Host::by_name("MyHost2");
XBT_INFO("Turning MyHost2 off, and sleeping another 10 seconds. MyHost2 computed %.0f flops so far and has an average load of %.5f.",
sg_host_get_computed_flops(host2), sg_host_get_avg_load(host2));
host2->turnOff();
- start = simgrid::s4u::Engine::getClock();
+ start = simgrid::s4u::Engine::get_clock();
simgrid::s4u::this_actor::sleep_for(10);
XBT_INFO("Done sleeping %.2f s; peak speed: %.0E flop/s; number of flops computed so far: %.0E",
- simgrid::s4u::Engine::getClock() - start, host->getSpeed(), sg_host_get_computed_flops(host));
+ simgrid::s4u::Engine::get_clock() - start, host->getSpeed(), sg_host_get_computed_flops(host));
}
static void change_speed()
e.run();
- XBT_INFO("Total simulation time: %.2f", simgrid::s4u::Engine::getClock());
+ XBT_INFO("Total simulation time: %.2f", simgrid::s4u::Engine::get_clock());
return 0;
}
static void compute(simgrid::xbt::ReplayAction& action)
{
double amount = std::stod(action[2]);
- double clock = simgrid::s4u::Engine::getClock();
+ double clock = simgrid::s4u::Engine::get_clock();
ACT_DEBUG("Entering %s", NAME.c_str());
simgrid::s4u::this_actor::execute(amount);
- log_action(action, simgrid::s4u::Engine::getClock() - clock);
+ log_action(action, simgrid::s4u::Engine::get_clock() - clock);
}
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::getClock();
+ double clock = simgrid::s4u::Engine::get_clock();
simgrid::s4u::MailboxPtr to = simgrid::s4u::Mailbox::byName(simgrid::s4u::this_actor::get_name() + "_" + action[2]);
ACT_DEBUG("Entering Send: %s (size: %g) -- Actor %s on mailbox %s", NAME.c_str(), size,
simgrid::s4u::this_actor::get_cname(), to->get_cname());
to->put(payload, size);
delete payload;
- log_action(action, simgrid::s4u::Engine::getClock() - clock);
+ log_action(action, simgrid::s4u::Engine::get_clock() - clock);
}
static void recv(simgrid::xbt::ReplayAction& action)
{
- double clock = simgrid::s4u::Engine::getClock();
+ double clock = simgrid::s4u::Engine::get_clock();
simgrid::s4u::MailboxPtr from =
simgrid::s4u::Mailbox::byName(std::string(action[2]) + "_" + simgrid::s4u::this_actor::get_name());
ACT_DEBUG("Receiving: %s -- Actor %s on mailbox %s", NAME.c_str(), simgrid::s4u::this_actor::get_cname(),
from->get_cname());
from->get();
- log_action(action, simgrid::s4u::Engine::getClock() - clock);
+ log_action(action, simgrid::s4u::Engine::get_clock() - clock);
}
};
simgrid::xbt::action_fs = nullptr;
}
- XBT_INFO("Simulation time %g", e.getClock());
+ XBT_INFO("Simulation time %g", e.get_clock());
return 0;
}
static void open(simgrid::xbt::ReplayAction& action)
{
std::string file_name = action[2];
- double clock = simgrid::s4u::Engine::getClock();
+ double clock = simgrid::s4u::Engine::get_clock();
std::string full_name = simgrid::s4u::this_actor::get_name() + ":" + file_name;
ACT_DEBUG("Entering Open: %s (filename: %s)", NAME.c_str(), file_name.c_str());
opened_files.insert({full_name, file});
- log_action(action, simgrid::s4u::Engine::getClock() - clock);
+ log_action(action, simgrid::s4u::Engine::get_clock() - clock);
}
static void read(simgrid::xbt::ReplayAction& action)
{
std::string file_name = action[2];
sg_size_t size = std::stoul(action[3]);
- double clock = simgrid::s4u::Engine::getClock();
+ double clock = simgrid::s4u::Engine::get_clock();
simgrid::s4u::File* file = get_file_descriptor(file_name);
ACT_DEBUG("Entering Read: %s (size: %llu)", NAME.c_str(), size);
file->read(size);
- log_action(action, simgrid::s4u::Engine::getClock() - clock);
+ log_action(action, simgrid::s4u::Engine::get_clock() - clock);
}
static void close(simgrid::xbt::ReplayAction& action)
{
std::string file_name = action[2];
- double clock = simgrid::s4u::Engine::getClock();
+ double clock = simgrid::s4u::Engine::get_clock();
simgrid::s4u::File* file = get_file_descriptor(file_name);
ACT_DEBUG("Entering Close: %s (filename: %s)", NAME.c_str(), file_name.c_str());
delete file;
- log_action(action, simgrid::s4u::Engine::getClock() - clock);
+ log_action(action, simgrid::s4u::Engine::get_clock() - clock);
}
};
simgrid::xbt::action_fs = nullptr;
}
- XBT_INFO("Simulation time %g", e.getClock());
+ XBT_INFO("Simulation time %g", e.get_clock());
return 0;
}
void del_storage(std::string name);
public:
- simgrid::s4u::Host* host_by_name(std::string name);
- simgrid::s4u::Host* host_by_name_or_null(std::string name);
- simgrid::s4u::Storage* storage_by_name(std::string name);
- simgrid::s4u::Storage* storage_by_name_or_null(std::string name);
-
size_t get_host_count();
- void get_host_list(std::vector<Host*>* whereTo);
std::vector<Host*> get_all_hosts();
+ simgrid::s4u::Host* host_by_name(std::string name);
+ simgrid::s4u::Host* host_by_name_or_null(std::string name);
- size_t getLinkCount();
- void getLinkList(std::vector<Link*> * list);
- std::vector<Link*> getAllLinks();
+ size_t get_link_count();
+ std::vector<Link*> get_all_links();
- std::vector<Storage*> getAllStorages();
+ size_t get_storage_count();
+ std::vector<Storage*> get_all_storages();
+ simgrid::s4u::Storage* storage_by_name(std::string name);
+ simgrid::s4u::Storage* storage_by_name_or_null(std::string name);
/** @brief Run the simulation */
void run();
/** @brief Retrieve the simulation time */
- static double getClock();
+ static double get_clock();
/** @brief Retrieve the engine singleton */
static s4u::Engine* getInstance();
}
XBT_ATTRIB_DEPRECATED_v323("Please use Engine::get_host_count()") size_t getHostCount() { return get_host_count(); }
- XBT_ATTRIB_DEPRECATED_v323("Please use Engine::get_host_list()") void getHostList(std::vector<Host*>* whereTo)
- {
- get_host_list(whereTo);
- }
+ XBT_ATTRIB_DEPRECATED_v322("Engine::getHostList() is deprecated in favor of Engine::get_all_hosts(). Please switch "
+ "before v3.22") void getHostList(std::vector<Host*>* whereTo);
XBT_ATTRIB_DEPRECATED_v323("Please use Engine::get_all_hosts()") std::vector<Host*> getAllHosts()
{
return get_all_hosts();
}
+ XBT_ATTRIB_DEPRECATED_v323("Please use Engine::get_link_count()") size_t getLinkCount() { return get_link_count(); }
+ XBT_ATTRIB_DEPRECATED_v323("Please use Engine::get_link_list()")
+ XBT_ATTRIB_DEPRECATED_v322("Engine::getLinkList() is deprecated in favor of Engine::get_all_links(). Please "
+ "switch before v3.22") void getLinkList(std::vector<Link*>* list);
+ XBT_ATTRIB_DEPRECATED_v323("Please use Engine::get_link_list()") std::vector<Link*> getAllLinks()
+ {
+ return get_all_links();
+ }
+ XBT_ATTRIB_DEPRECATED_v323("Please use Engine::get_all_storages()") std::vector<Storage*> getAllStorages()
+ {
+ return get_all_storages();
+ }
+ XBT_ATTRIB_DEPRECATED_v323("Please use Engine::get_clock()") static double getClock() { return get_clock(); }
simgrid::kernel::EngineImpl* pimpl;
*msg = *msg + std::to_string(stage) + ":" + vm_->get_cname() + "(" + src_pm_->get_cname() + "-" +
dst_pm_->get_cname() + ")";
- double clock_sta = s4u::Engine::getClock();
+ double clock_sta = s4u::Engine::get_clock();
s4u::Activity* comm = nullptr;
try {
delete msg;
}
- double clock_end = s4u::Engine::getClock();
+ double clock_end = s4u::Engine::get_clock();
double duration = clock_end - clock_sta;
double actual_speed = size / duration;
sg_vm_start_dirty_page_tracking(vm_);
double computed_during_stage1 = 0;
- double clock_prev_send = s4u::Engine::getClock();
+ double clock_prev_send = s4u::Engine::get_clock();
try {
/* At stage 1, we do not need timeout. We have to send all the memory pages even though the duration of this
return;
}
- double clock_post_send = s4u::Engine::getClock();
+ double clock_post_send = s4u::Engine::get_clock();
mig_timeout -= (clock_post_send - clock_prev_send);
if (mig_timeout < 0) {
XBT_VERB("The duration of stage 1 exceeds the timeout value, skip stage 2");
break;
sg_size_t sent = 0;
- double clock_prev_send = s4u::Engine::getClock();
+ double clock_prev_send = s4u::Engine::get_clock();
try {
XBT_DEBUG("Stage 2, gonna send %llu", updated_size);
sent = sendMigrationData(updated_size, 2, stage2_round, mig_speed, mig_timeout);
sg_vm_stop_dirty_page_tracking(vm_);
return;
}
- double clock_post_send = s4u::Engine::getClock();
+ double clock_post_send = s4u::Engine::get_clock();
if (sent == updated_size) {
/* timeout did not happen */
s4u::Engine::instance_ = nullptr;
}
-double Engine::getClock()
+double Engine::get_clock()
{
return SIMIX_get_clock();
}
/** @brief Fills the passed list with all hosts found in the platform
* @deprecated Please prefer Engine::getAllHosts()
*/
-void XBT_ATTRIB_DEPRECATED_v322(
- "Engine::getHostList() is deprecated in favor of Engine::get_all_hosts(). Please switch before v3.22")
- Engine::get_host_list(std::vector<Host*>* list)
+void Engine::getHostList(std::vector<Host*>* list)
{
for (auto const& kv : pimpl->hosts_)
list->push_back(kv.second);
return host == pimpl->hosts_.end() ? nullptr : host->second;
}
+/** @brief Returns the amount of storages in the platform */
+size_t Engine::get_storage_count()
+{
+ return pimpl->storages_.size();
+}
+
/** @brief Returns the list of all storages found in the platform */
-std::vector<Storage*> Engine::getAllStorages()
+std::vector<Storage*> Engine::get_all_storages()
{
std::vector<Storage*> res;
for (auto const& kv : pimpl->storages_)
}
/** @brief Returns the amount of links in the platform */
-size_t Engine::getLinkCount()
+size_t Engine::get_link_count()
{
return kernel::resource::LinkImpl::linksCount();
}
-/** @brief Fills the passed list with all links found in the platform
- *
- * @deprecated. Prefer Engine::getAllLinks() */
-void XBT_ATTRIB_DEPRECATED_v322(
- "Engine::getLinkList() is deprecated in favor of Engine::getAllLinks(). Please switch before v3.22")
- Engine::getLinkList(std::vector<Link*>* list)
-{
- kernel::resource::LinkImpl::linksList(list);
-}
-
/** @brief Returns the list of all links found in the platform */
-std::vector<Link*> Engine::getAllLinks()
+std::vector<Link*> Engine::get_all_links()
{
std::vector<Link*> res;
kernel::resource::LinkImpl::linksList(&res);
"simgrid::s4u::getStorageList() is deprecated in favor of Engine::getAllStorages(). Please switch before v3.22")
getStorageList(std::map<std::string, Storage*>* whereTo)
{
- for (auto const& s : simgrid::s4u::Engine::getInstance()->getAllStorages())
+ for (auto const& s : simgrid::s4u::Engine::getInstance()->get_all_storages())
whereTo->insert({s->get_name(), s});
}
*/
xbt_dynar_t sg_storages_as_dynar()
{
- std::vector<simgrid::s4u::Storage*> storage_list = simgrid::s4u::Engine::getInstance()->getAllStorages();
+ std::vector<simgrid::s4u::Storage*> storage_list = simgrid::s4u::Engine::getInstance()->get_all_storages();
xbt_dynar_t res = xbt_dynar_new(sizeof(sg_storage_t), nullptr);
for (auto const& s : storage_list)
xbt_dynar_push(res, &s);
static void onSimulationEnd()
{
- std::vector<simgrid::s4u::Link*> links = simgrid::s4u::Engine::getInstance()->getAllLinks();
+ std::vector<simgrid::s4u::Link*> links = simgrid::s4u::Engine::getInstance()->get_all_links();
double total_energy = 0.0; // Total dissipated energy (whole platform)
for (const auto link : links) {
static void check_disk_attachment()
{
- for (auto const& s : simgrid::s4u::Engine::getInstance()->getAllStorages()) {
+ for (auto const& s : simgrid::s4u::Engine::getInstance()->get_all_storages()) {
simgrid::kernel::routing::NetPoint* host_elm = sg_netpoint_by_name_or_null(s->getImpl()->getHost().c_str());
if (not host_elm)
surf_parse_error(std::string("Unable to attach storage ") + s->get_cname() + ": host " +
simgrid::s4u::Actor::create("worker", simgrid::s4u::Host::by_name("Tremblay"), worker);
e.run();
- XBT_INFO("Simulation time %g", e.getClock());
+ XBT_INFO("Simulation time %g", e.get_clock());
return 0;
}
static void vm_migrate(simgrid::s4u::VirtualMachine* vm, simgrid::s4u::Host* dst_pm)
{
simgrid::s4u::Host* src_pm = vm->getPm();
- double mig_sta = simgrid::s4u::Engine::getClock();
+ double mig_sta = simgrid::s4u::Engine::get_clock();
sg_vm_migrate(vm, dst_pm);
- double mig_end = simgrid::s4u::Engine::getClock();
+ double mig_end = simgrid::s4u::Engine::get_clock();
XBT_INFO("%s migrated: %s->%s in %g s", vm->get_cname(), src_pm->get_cname(), dst_pm->get_cname(), mig_end - mig_sta);
}
e.run();
- XBT_INFO("Bye (simulation time %g)", simgrid::s4u::Engine::getClock());
+ XBT_INFO("Bye (simulation time %g)", simgrid::s4u::Engine::get_clock());
return 0;
}
simgrid::s4u::Actor::create("recver", hosts[1], receiver, argRecv);
e.run();
- XBT_INFO("Simulation time %g", e.getClock());
+ XBT_INFO("Simulation time %g", e.get_clock());
return 0;
}
simgrid::s4u::Actor::create("host", simgrid::s4u::Host::by_name("bob"), host);
e.run();
- XBT_INFO("Simulation time %g", e.getClock());
+ XBT_INFO("Simulation time %g", e.get_clock());
return 0;
}
simgrid::s4u::Actor::create("worker", simgrid::s4u::Host::by_name("Jupiter"), worker);
e.run();
- XBT_INFO("Simulation time %g", e.getClock());
+ XBT_INFO("Simulation time %g", e.get_clock());
return 0;
}
static void dump_platform_storages()
{
- std::vector<simgrid::s4u::Storage*> storages = simgrid::s4u::Engine::getInstance()->getAllStorages();
+ std::vector<simgrid::s4u::Storage*> storages = simgrid::s4u::Engine::getInstance()->get_all_storages();
for (auto const& s : storages) {
XBT_INFO("Storage %s is attached to %s", s->get_cname(), s->getHost()->get_cname());
e.run();
- XBT_INFO("Simulated time: %g", e.getClock());
+ XBT_INFO("Simulated time: %g", e.get_clock());
return 0;
}