Пример #1
0
static int execute_load_test(int argc, char* argv[])
{
  msg_host_t host = MSG_host_by_name("MyHost1");

  XBT_INFO("Initial peak speed: %.0E flop/s; number of flops computed so far: %.0E (should be 0)",
           MSG_host_get_speed(host), sg_host_get_computed_flops(host));

  double start = MSG_get_clock();
  XBT_INFO("Sleep for 10 seconds");
  MSG_process_sleep(10);

  XBT_INFO("Done sleeping %.2fs; peak speed: %.0E flop/s; number of flops computed so far: %.0E (nothing should have "
           "changed)",
           MSG_get_clock() - start, MSG_host_get_speed(host), sg_host_get_computed_flops(host));

  // Run a task
  start            = MSG_get_clock();
  msg_task_t task1 = MSG_task_create("t1", 100E6, 0, NULL);
  XBT_INFO("Run a task of %.0E flops", MSG_task_get_flops_amount(task1));
  MSG_task_execute(task1);
  MSG_task_destroy(task1);

  XBT_INFO("Done working on my task; this took %.2fs; current peak speed: %.0E flop/s; number of flops computed so "
           "far: %.0E",
           MSG_get_clock() - start, MSG_host_get_speed(host), sg_host_get_computed_flops(host));

  // ========= Change power peak =========
  int pstate = 2;
  sg_host_set_pstate(host, pstate);
  XBT_INFO("========= Requesting pstate %d (speed should be of %.0E flop/s and is of %.0E flop/s)", pstate,
           MSG_host_get_power_peak_at(host, pstate), MSG_host_get_speed(host));

  // Run a second task
  start = MSG_get_clock();
  task1 = MSG_task_create("t2", 100E6, 0, NULL);
  XBT_INFO("Run a task of %.0E flops", MSG_task_get_flops_amount(task1));
  MSG_task_execute(task1);
  MSG_task_destroy(task1);
  XBT_INFO("Done working on my task; this took %.2fs; current peak speed: %.0E flop/s; number of flops computed so "
           "far: %.0E",
           MSG_get_clock() - start, MSG_host_get_speed(host), sg_host_get_computed_flops(host));

  start = MSG_get_clock();
  XBT_INFO("========= Requesting a reset of the computation counter");
  sg_host_load_reset(host);
  XBT_INFO("Sleep for 4 seconds");
  MSG_process_sleep(4);
  XBT_INFO("Done sleeping %.2f s; peak speed: %.0E flop/s; number of flops computed so far: %.0E",
           MSG_get_clock() - start, MSG_host_get_speed(host), sg_host_get_computed_flops(host));

  // =========== Turn the other host off ==========
  XBT_INFO("Turning MyHost2 off, and sleeping another 10 seconds. MyHost2 computed %.0f flops so far.",
           MSG_host_get_computed_flops(MSG_host_by_name("MyHost2")));
  MSG_host_off(MSG_host_by_name("MyHost2"));
  start = MSG_get_clock();
  MSG_process_sleep(10);
  XBT_INFO("Done sleeping %.2f s; peak speed: %.0E flop/s; number of flops computed so far: %.0E",
           MSG_get_clock() - start, MSG_host_get_speed(host), sg_host_get_computed_flops(host));
  return 0;
}
Пример #2
0
static int dvfs(int argc, char* argv[])
{
  double workload = 100E6;
  msg_host_t host = MSG_host_self();

  int nb = MSG_host_get_nb_pstates(host);
  XBT_INFO("Count of Processor states=%d", nb);

  double current_peak = MSG_host_get_speed(host);
  XBT_INFO("Current power peak=%f", current_peak);

  // Run a task
  msg_task_t task1 = MSG_task_create("t1", workload, 0, NULL);
  MSG_task_execute(task1);
  MSG_task_destroy(task1);

  double task_time = MSG_get_clock();
  XBT_INFO("Task1 simulation time: %e", task_time);

  // Change power peak
  int new_pstate = 2;
  xbt_assert(new_pstate < nb, "Cannot set the host %s at pstate %d because it only provides %d pstates.",
             MSG_host_get_name(host), new_pstate, nb);

  double peak_at = MSG_host_get_power_peak_at(host, new_pstate);
  XBT_INFO("Changing power peak value to %f (at index %d)", peak_at, new_pstate);

  MSG_host_set_pstate(host, new_pstate);

  current_peak = MSG_host_get_speed(host);
  XBT_INFO("Current power peak=%f", current_peak);

  // Run a second task
  task1 = MSG_task_create("t1", workload, 0, NULL);
  MSG_task_execute(task1);
  MSG_task_destroy(task1);

  task_time = MSG_get_clock() - task_time;
  XBT_INFO("Task2 simulation time: %e", task_time);

  // Verify the default pstate is set to 0
  host    = MSG_host_by_name("MyHost2");
  int nb2 = MSG_host_get_nb_pstates(host);
  XBT_INFO("Count of Processor states=%d", nb2);

  double current_peak2 = MSG_host_get_speed(host);
  XBT_INFO("Current power peak=%f", current_peak2);
  return 0;
}