示例#1
0
文件: e2.c 项目: cemsbr/simgrid
int dvfs(int argc, char *argv[])
{
  msg_host_t host = NULL;
  msg_task_t task1 = NULL;
  double task_time = 0;
  host = MSG_get_host_by_name("MyHost1");


  double current_peak = MSG_get_host_current_power_peak(host);
  XBT_INFO("Current power peak=%lf", current_peak);

  double consumed_energy = MSG_get_host_consumed_energy(host);
  XBT_INFO("Total energy (Joules): %lf", consumed_energy);

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

  task_time = MSG_get_clock();
  XBT_INFO("Task1 simulation time: %le", task_time);
  consumed_energy = MSG_get_host_consumed_energy(host);
  XBT_INFO("Total energy (Joules): %lf", consumed_energy);

  // ========= Change power peak =========
  int peak_index=2;
  double peak_at = MSG_get_host_power_peak_at(host, peak_index);
  XBT_INFO("=========Changing power peak value to %lf (at index %d)", peak_at, peak_index);

  MSG_set_host_power_peak_at(host, peak_index);

  // Run a second task
  task1 = MSG_task_create ("t2", 100E6, 0, NULL);
  MSG_task_execute (task1);
  MSG_task_destroy(task1);

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

  consumed_energy = MSG_get_host_consumed_energy(host);
  XBT_INFO("Total energy (Joules): %lf", consumed_energy);


  MSG_process_sleep(3);

  task_time = MSG_get_clock() - task_time;
  XBT_INFO("Task3 (sleep) simulation time: %le", task_time);
  consumed_energy = MSG_get_host_consumed_energy(host);
  XBT_INFO("Total energy (Joules): %lf", consumed_energy);


  return 0;
}
示例#2
0
文件: e3.c 项目: Julio-Anjos/simgrid
static int dvfs(int argc, char *argv[])
{
  msg_host_t host = NULL;
  double task_time = 0;
  host = MSG_host_self();

  double current_peak = MSG_get_host_current_power_peak(host);

  XBT_INFO("Current power peak=%f", current_peak);
  double consumed_energy = MSG_get_host_consumed_energy(host);
  XBT_INFO("Total energy (Joules): %f", consumed_energy);

  // Process 1 - long CPU task
  int argc1 = 1;
  char** params1 = xbt_malloc0(sizeof(char *) * argc1);
  params1[0] = xbt_strdup("400.0E6");
  MSG_process_create_with_arguments("proc1", process_code, NULL, host, argc1, params1);

  // Process 2 - sleep 2 sec + CPU task
  int argc2 = 2;
  char** params2 = xbt_malloc0(sizeof(char *) * argc2);
  params2[0] = xbt_strdup("100.0E6");
  params2[1] = xbt_strdup("2");
  MSG_process_create_with_arguments("proc2", process_code, NULL, host, argc2, params2);

  // Process 3 - sleep 2 sec + CPU task
  int argc3 = 2;
  char** params3 = xbt_malloc0(sizeof(char *) * argc3);
  params3[0] = xbt_strdup("100.0E6");
  params3[1] = xbt_strdup("2");
  MSG_process_create_with_arguments("proc3", process_code, NULL, host, argc3, params3);


  // Main process
  MSG_process_sleep(8);

  task_time = MSG_get_clock() - task_time;
  XBT_INFO("Task simulation time: %e", task_time);
  consumed_energy = MSG_get_host_consumed_energy(host);
  XBT_INFO("Total energy (Joules): %f", consumed_energy);

  return 0;
}