}
/* Get the info about the worker processes (directly from SimGrid) */
- int workers_count = MSG_get_host_number();
+ int worker_count = MSG_get_host_number();
msg_host_t* workers = xbt_dynar_to_array(MSG_hosts_as_dynar());
- for (int i = 0; i < workers_count; i++)
+ for (int i = 0; i < worker_count; i++)
if (host_self == workers[i]) {
- workers[i] = workers[workers_count - 1];
- workers_count--;
+ workers[i] = workers[worker_count - 1];
+ worker_count--;
break;
}
- for (int i = 0; i < workers_count; i++)
+ for (int i = 0; i < worker_count; i++)
MSG_process_create("worker", worker, (void*)master_name, workers[i]);
- XBT_INFO("Got %d workers and %ld tasks to process", workers_count, number_of_tasks);
+ XBT_INFO("Got %d workers and %ld tasks to process", worker_count, number_of_tasks);
/* Dispatch the tasks */
for (int i = 0; i < number_of_tasks; i++) {
- build_channel_name(channel, master_name, MSG_host_get_name(workers[i % workers_count]));
+ build_channel_name(channel, master_name, MSG_host_get_name(workers[i % worker_count]));
XBT_INFO("Sending '%s' to channel '%s'", todo[i]->name, channel);
}
XBT_INFO("All tasks have been dispatched. Let's tell everybody the computation is over.");
- for (int i = 0; i < workers_count; i++) {
+ for (int i = 0; i < worker_count; i++) {
msg_task_t finalize = MSG_task_create("finalize", 0, 0, FINALIZE);
- MSG_task_send(finalize, build_channel_name(channel, master_name, MSG_host_get_name(workers[i % workers_count])));
+ MSG_task_send(finalize, build_channel_name(channel, master_name, MSG_host_get_name(workers[i % worker_count])));
}
XBT_INFO("Goodbye now!");
double comm_size = xbt_str_parse_double(argv[3], "Invalid communication size: %s"); /** - Task communication size */
/* Get the info about the worker processes (directly from SimGrid) */
- int workers_count = MSG_get_host_number();
+ int worker_count = MSG_get_host_number();
msg_host_t* workers = xbt_dynar_to_array(MSG_hosts_as_dynar());
- for (int i = 0; i < workers_count; i++) // Remove my host from the list
+ for (int i = 0; i < worker_count; i++) // Remove my host from the list
if (host_self == workers[i]) {
- workers[i] = workers[workers_count - 1];
- workers_count--;
+ workers[i] = workers[worker_count - 1];
+ worker_count--;
break;
}
- for (int i = 0; i < workers_count; i++)
+ for (int i = 0; i < worker_count; i++)
MSG_process_create("worker", worker, (void*)master_name, workers[i]);
- XBT_INFO("Got %d workers and will send tasks for %g seconds", workers_count, timeout);
+ XBT_INFO("Got %d workers and will send tasks for %g seconds", worker_count, timeout);
/* Dispatch the tasks */
int task_num = 0;
sprintf(sprintf_buffer, "Task_%d", task_num);
msg_task_t task = MSG_task_create(sprintf_buffer, comp_size, comm_size, NULL);
- build_channel_name(channel, master_name, MSG_host_get_name(workers[task_num % workers_count]));
+ build_channel_name(channel, master_name, MSG_host_get_name(workers[task_num % worker_count]));
XBT_DEBUG("Sending '%s' to channel '%s'", task->name, channel);
MSG_task_send(task, channel);
}
XBT_DEBUG("All tasks have been dispatched. Let's tell everybody the computation is over.");
- for (int i = 0; i < workers_count; i++) {
+ for (int i = 0; i < worker_count; i++) {
msg_task_t finalize = MSG_task_create("finalize", 0, 0, FINALIZE);
- MSG_task_send(finalize, build_channel_name(channel, master_name, MSG_host_get_name(workers[i % workers_count])));
+ MSG_task_send(finalize, build_channel_name(channel, master_name, MSG_host_get_name(workers[i % worker_count])));
}
XBT_DEBUG("Sent %d tasks in total!", task_num);
double comm_size = xbt_str_parse_double(argv[3], "Invalid communication size: %s"); /** - Task communication size */
/* Get the info about the worker processes */
- int workers_count = MSG_get_host_number();
+ int worker_count = MSG_get_host_number();
msg_host_t* workers = xbt_dynar_to_array(MSG_hosts_as_dynar());
- for (int i = 0; i < workers_count; i++) // Remove my host from the list
+ for (int i = 0; i < worker_count; i++) // Remove my host from the list
if (host_self == workers[i]) {
- workers[i] = workers[workers_count - 1];
- workers_count--;
+ workers[i] = workers[worker_count - 1];
+ worker_count--;
break;
}
- for (int i = 0; i < workers_count; i++)
+ for (int i = 0; i < worker_count; i++)
MSG_process_create("worker", worker, (void*)master_name, workers[i]);
- XBT_INFO("Got %d workers and will send tasks for %g seconds", workers_count, timeout);
+ XBT_INFO("Got %d workers and will send tasks for %g seconds", worker_count, timeout);
/* Dispatch the tasks */
int task_num = 0;
msg_task_t task = MSG_task_create(sprintf_buffer, comp_size, comm_size, NULL);
MSG_task_set_category(task, master_name);
- build_channel_name(channel, master_name, MSG_host_get_name(workers[task_num % workers_count]));
+ build_channel_name(channel, master_name, MSG_host_get_name(workers[task_num % worker_count]));
XBT_DEBUG("Sending '%s' to channel '%s'", task->name, channel);
MSG_task_send(task, channel);
}
XBT_DEBUG("All tasks have been dispatched. Let's tell everybody the computation is over.");
- for (int i = 0; i < workers_count; i++) {
+ for (int i = 0; i < worker_count; i++) {
msg_task_t finalize = MSG_task_create("finalize", 0, 0, FINALIZE);
- MSG_task_send(finalize, build_channel_name(channel, master_name, MSG_host_get_name(workers[i % workers_count])));
+ MSG_task_send(finalize, build_channel_name(channel, master_name, MSG_host_get_name(workers[i % worker_count])));
}
XBT_INFO("Sent %d tasks in total!", task_num);
double comm_size = xbt_str_parse_double(argv[3], "Invalid communication size: %s"); /** - Task communication size */
/* Get the info about the worker processes */
- int workers_count = MSG_get_host_number();
+ int worker_count = MSG_get_host_number();
msg_host_t* workers = xbt_dynar_to_array(MSG_hosts_as_dynar());
- for (int i = 0; i < workers_count; i++) // Remove my host from the list
+ for (int i = 0; i < worker_count; i++) // Remove my host from the list
if (host_self == workers[i]) {
- workers[i] = workers[workers_count - 1];
- workers_count--;
+ workers[i] = workers[worker_count - 1];
+ worker_count--;
break;
}
- for (int i = 0; i < workers_count; i++)
+ for (int i = 0; i < worker_count; i++)
MSG_process_create("worker", worker, (void*)master_name, workers[i]);
- XBT_INFO("Got %d workers and will send tasks for %g seconds", workers_count, timeout);
+ XBT_INFO("Got %d workers and will send tasks for %g seconds", worker_count, timeout);
/* Dispatch the tasks */
int task_num = 0;
}
XBT_DEBUG("Time is up. Let's tell everybody the computation is over.");
- for (int i = 0; i < workers_count; i++) { /* We don't write in order, but the total amount is right */
+ for (int i = 0; i < worker_count; i++) { /* We don't write in order, but the total amount is right */
/* Don't write to a worker that did not request for work, or it will deadlock: both would be sending something */
msg_task_t request = NULL;
}
/* Get the info about the worker processes from my parameters */
- int workers_count = argc - 4;
- msg_host_t* workers = xbt_new0(msg_host_t, workers_count);
+ int worker_count = argc - 4;
+ msg_host_t* workers = xbt_new0(msg_host_t, worker_count);
for (int i = 4; i < argc; i++) {
workers[i - 4] = MSG_get_host_by_name(argv[i]);
xbt_assert(workers[i - 4] != NULL, "Unknown host %s. Stopping Now! ", argv[i]);
}
- XBT_INFO("Got %d workers and %ld tasks to process", workers_count, number_of_tasks);
+ XBT_INFO("Got %d workers and %ld tasks to process", worker_count, number_of_tasks);
/* Dispatch the tasks */
for (int i = 0; i < number_of_tasks; i++) {
- XBT_INFO("Sending '%s' to '%s'", todo[i]->name, MSG_host_get_name(workers[i % workers_count]));
- if (MSG_host_self() == workers[i % workers_count]) {
+ XBT_INFO("Sending '%s' to '%s'", todo[i]->name, MSG_host_get_name(workers[i % worker_count]));
+ if (MSG_host_self() == workers[i % worker_count]) {
XBT_INFO("Hey ! It's me ! :)");
}
- MSG_task_send(todo[i], MSG_host_get_name(workers[i % workers_count]));
+ MSG_task_send(todo[i], MSG_host_get_name(workers[i % worker_count]));
XBT_INFO("Sent");
}
XBT_INFO("All tasks have been dispatched. Let's tell everybody the computation is over.");
- for (int i = 0; i < workers_count; i++) {
+ for (int i = 0; i < worker_count; i++) {
msg_task_t finalize = MSG_task_create("finalize", 0, 0, FINALIZE);
MSG_task_send(finalize, MSG_host_get_name(workers[i]));
}
int Host::get_pstate_count() const
{
- return this->pimpl_cpu->get_pstates_count();
+ return this->pimpl_cpu->get_pstate_count();
}
/**
/** @brief Returns the number of core of the processor. */
int Host::get_core_count()
{
- return this->pimpl_cpu->get_cores_count();
+ return this->pimpl_cpu->get_core_count();
}
/** @brief Set the pstate at which the host should run */
const kernel::lmm::Element* elem = nullptr;
get_model()->get_maxmin_system()->update_constraint_bound(get_constraint(),
- get_cores_count() * speed_.scale * speed_.peak);
+ get_core_count() * speed_.scale * speed_.peak);
while ((var = get_constraint()->get_variable(&elem))) {
CpuCas01Action* action = static_cast<CpuCas01Action*>(var->get_id());
{
if (event == speed_.event) {
/* TODO (Hypervisor): do the same thing for constraint_core[i] */
- xbt_assert(get_cores_count() == 1, "FIXME: add speed scaling code also for constraint_core[i]");
+ xbt_assert(get_core_count() == 1, "FIXME: add speed scaling code also for constraint_core[i]");
speed_.scale = value;
on_speed_change();
tmgr_trace_event_unref(&speed_.event);
} else if (event == state_event_) {
/* TODO (Hypervisor): do the same thing for constraint_core[i] */
- xbt_assert(get_cores_count() == 1, "FIXME: add state change code also for constraint_core[i]");
+ xbt_assert(get_core_count() == 1, "FIXME: add state change code also for constraint_core[i]");
if (value > 0) {
if (is_off())
Cpu::Cpu(kernel::resource::Model* model, simgrid::s4u::Host* host, kernel::lmm::Constraint* constraint,
std::vector<double>* speedPerPstate, int core)
- : Resource(model, host->get_cname(), constraint), cores_count_(core), host_(host)
+ : Resource(model, host->get_cname(), constraint), core_count_(core), host_(host)
{
xbt_assert(core > 0, "Host %s must have at least one core, not 0.", host->get_cname());
speed_per_pstate_.clear();
}
-int Cpu::get_pstates_count()
+int Cpu::get_pstate_count()
{
return speed_per_pstate_.size();
}
s4u::Host::on_speed_change(*host_);
}
-int Cpu::get_cores_count()
+int Cpu::get_core_count()
{
- return cores_count_;
+ return core_count_;
}
void Cpu::set_state_trace(tmgr_trace_t trace)
virtual simgrid::kernel::resource::Action* sleep(double duration) = 0;
/** @brief Get the amount of cores */
- virtual int get_cores_count();
+ virtual int get_core_count();
/** @brief Get a forecast of the speed (in flops/s) if the load were as provided.
*
/** @brief Get the peak processor speed (in flops/s), at the specified pstate */
virtual double get_pstate_peak_speed(int pstate_index);
- virtual int get_pstates_count();
+ virtual int get_pstate_count();
virtual void set_pstate(int pstate_index);
virtual int get_pstate();
simgrid::s4u::Host* get_host() { return host_; }
private:
- int cores_count_ = 1;
+ int core_count_ = 1;
simgrid::s4u::Host* host_;
int pstate_ = 0; /*< Current pstate (index in the speed_per_pstate_)*/
cpu_load = host->pimpl_cpu->get_constraint()->get_usage() / current_speed;
/** Divide by the number of cores here **/
- cpu_load /= host->pimpl_cpu->get_cores_count();
+ cpu_load /= host->pimpl_cpu->get_core_count();
if (cpu_load > 1) // A machine with a load > 1 consumes as much as a fully loaded machine, not more
cpu_load = 1;
static int runner(int argc, char* argv[])
{
/* Retrieve the list of all hosts as an array of hosts */
- int hosts_count = MSG_get_host_number();
+ int host_count = MSG_get_host_number();
msg_host_t* hosts = xbt_dynar_to_array(MSG_hosts_as_dynar());
XBT_INFO("First, build a classical parallel task, with 1 Gflop to execute on each node, "
"and 10MB to exchange between each pair");
- double* computation_amounts = xbt_new0(double, hosts_count);
- double* communication_amounts = xbt_new0(double, hosts_count* hosts_count);
+ double* computation_amounts = xbt_new0(double, host_count);
+ double* communication_amounts = xbt_new0(double, host_count* host_count);
- for (int i = 0; i < hosts_count; i++)
+ for (int i = 0; i < host_count; i++)
computation_amounts[i] = 1e9; // 1 Gflop
- for (int i = 0; i < hosts_count; i++)
- for (int j = i + 1; j < hosts_count; j++)
- communication_amounts[i * hosts_count + j] = 1e7; // 10 MB
+ for (int i = 0; i < host_count; i++)
+ for (int j = i + 1; j < host_count; j++)
+ communication_amounts[i * host_count + j] = 1e7; // 10 MB
msg_task_t ptask =
- MSG_parallel_task_create("parallel task", hosts_count, hosts, computation_amounts, communication_amounts, NULL);
+ MSG_parallel_task_create("parallel task", host_count, hosts, computation_amounts, communication_amounts, NULL);
MSG_parallel_task_execute(ptask);
MSG_task_destroy(ptask);
xbt_free(communication_amounts);
xbt_free(computation_amounts);
XBT_INFO("We can do the same with a timeout of one second enabled.");
- computation_amounts = xbt_new0(double, hosts_count);
- communication_amounts = xbt_new0(double, hosts_count* hosts_count);
- for (int i = 0; i < hosts_count; i++)
+ computation_amounts = xbt_new0(double, host_count);
+ communication_amounts = xbt_new0(double, host_count* host_count);
+ for (int i = 0; i < host_count; i++)
computation_amounts[i] = 1e9; // 1 Gflop
- for (int i = 0; i < hosts_count; i++)
- for (int j = i + 1; j < hosts_count; j++)
- communication_amounts[i * hosts_count + j] = 1e7; // 10 MB
+ for (int i = 0; i < host_count; i++)
+ for (int j = i + 1; j < host_count; j++)
+ communication_amounts[i * host_count + j] = 1e7; // 10 MB
ptask =
- MSG_parallel_task_create("parallel task", hosts_count, hosts, computation_amounts, communication_amounts, NULL);
+ MSG_parallel_task_create("parallel task", host_count, hosts, computation_amounts, communication_amounts, NULL);
msg_error_t errcode = MSG_parallel_task_execute_with_timeout(ptask, 1 /* timeout (in seconds)*/);
xbt_assert(errcode == MSG_TIMEOUT, "Woops, this did not timeout as expected... Please report that bug.");
MSG_task_destroy(ptask);
xbt_free(computation_amounts);
XBT_INFO("Then, build a parallel task involving only computations and no communication (1 Gflop per node)");
- computation_amounts = xbt_new0(double, hosts_count);
- for (int i = 0; i < hosts_count; i++)
+ computation_amounts = xbt_new0(double, host_count);
+ for (int i = 0; i < host_count; i++)
computation_amounts[i] = 1e9; // 1 Gflop
- ptask = MSG_parallel_task_create("parallel exec", hosts_count, hosts, computation_amounts, NULL /* no comm */, NULL);
+ ptask = MSG_parallel_task_create("parallel exec", host_count, hosts, computation_amounts, NULL /* no comm */, NULL);
MSG_parallel_task_execute(ptask);
MSG_task_destroy(ptask);
xbt_free(computation_amounts);
XBT_INFO("Then, build a parallel task with no computation nor communication (synchro only)");
- computation_amounts = xbt_new0(double, hosts_count);
- communication_amounts = xbt_new0(double, hosts_count* hosts_count); /* memset to 0 by xbt_new0 */
+ computation_amounts = xbt_new0(double, host_count);
+ communication_amounts = xbt_new0(double, host_count* host_count); /* memset to 0 by xbt_new0 */
ptask =
- MSG_parallel_task_create("parallel sync", hosts_count, hosts, computation_amounts, communication_amounts, NULL);
+ MSG_parallel_task_create("parallel sync", host_count, hosts, computation_amounts, communication_amounts, NULL);
MSG_parallel_task_execute(ptask);
MSG_task_destroy(ptask);
xbt_free(communication_amounts);