Ejemplo n.º 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;
}
Ejemplo n.º 2
0
/** The guy we will move from host to host. It move alone and then is moved by policeman back  */
static int emigrant(int argc, char *argv[])
{
  msg_task_t task;
  XBT_INFO
      ("I'll look for a new job on another machine where the grass is greener.");
  MSG_process_migrate(MSG_process_self(), MSG_host_by_name("Boivin"));
  
  XBT_INFO("Yeah, found something to do");
  task = MSG_task_create("job", 98095000, 0, NULL);
  MSG_task_execute(task);
  MSG_task_destroy(task);
  MSG_process_sleep(2);
  XBT_INFO("Moving back home after work");
  MSG_process_migrate(MSG_process_self(), MSG_host_by_name("Jacquelin"));
  MSG_process_migrate(MSG_process_self(), MSG_host_by_name("Boivin"));
  MSG_process_sleep(4);
  xbt_mutex_acquire(mutex);
  process_to_migrate = MSG_process_self();
  xbt_cond_broadcast(cond);
  xbt_mutex_release(mutex);
  MSG_process_suspend(MSG_process_self());
  msg_host_t h = MSG_process_get_host(MSG_process_self());
  XBT_INFO("I've been moved on this new host: %s", MSG_host_get_name(h));
  XBT_INFO("Uh, nothing to do here. Stopping now");
  return 0;
}                               /* end_of_emigrant */
Ejemplo n.º 3
0
static int master_main(int argc, char* argv[])
{
  msg_host_t pm0 = MSG_host_by_name("Fafard");
  msg_host_t pm1 = MSG_host_by_name("Tremblay");
  msg_host_t pm2 = MSG_host_by_name("Bourassa");

  msg_vm_t vm0 = MSG_vm_create_core(pm0, "VM0");
  MSG_vm_set_ramsize(vm0, 1e9); // 1Gbytes
  MSG_vm_start(vm0);

  XBT_INFO("Test: Migrate a VM with %zu Mbytes RAM", MSG_vm_get_ramsize(vm0) / 1000 / 1000);
  vm_migrate(vm0, pm1);

  MSG_vm_destroy(vm0);

  vm0 = MSG_vm_create_core(pm0, "VM0");
  MSG_vm_set_ramsize(vm0, 1e8); // 100Mbytes
  MSG_vm_start(vm0);

  XBT_INFO("Test: Migrate a VM with %zu Mbytes RAM", MSG_vm_get_ramsize(vm0) / 1000 / 1000);
  vm_migrate(vm0, pm1);

  MSG_vm_destroy(vm0);

  vm0          = MSG_vm_create_core(pm0, "VM0");
  msg_vm_t vm1 = MSG_vm_create_core(pm0, "VM1");

  MSG_vm_set_ramsize(vm0, 1e9); // 1Gbytes
  MSG_vm_set_ramsize(vm1, 1e9); // 1Gbytes
  MSG_vm_start(vm0);
  MSG_vm_start(vm1);

  XBT_INFO("Test: Migrate two VMs at once from PM0 to PM1");
  vm_migrate_async(vm0, pm1);
  vm_migrate_async(vm1, pm1);
  MSG_process_sleep(10000);

  MSG_vm_destroy(vm0);
  MSG_vm_destroy(vm1);

  vm0 = MSG_vm_create_core(pm0, "VM0");
  vm1 = MSG_vm_create_core(pm0, "VM1");

  MSG_vm_set_ramsize(vm0, 1e9); // 1Gbytes
  MSG_vm_set_ramsize(vm1, 1e9); // 1Gbytes
  MSG_vm_start(vm0);
  MSG_vm_start(vm1);

  XBT_INFO("Test: Migrate two VMs at once to different PMs");
  vm_migrate_async(vm0, pm1);
  vm_migrate_async(vm1, pm2);
  MSG_process_sleep(10000);

  MSG_vm_destroy(vm0);
  MSG_vm_destroy(vm1);

  return 0;
}
Ejemplo n.º 4
0
static int migration_worker_main(int argc, char *argv[])
{
  xbt_assert(argc == 3);
  char *vm_name = argv[1];
  char *dst_pm_name = argv[2];

  msg_vm_t vm = MSG_host_by_name(vm_name);
  msg_host_t dst_pm = MSG_host_by_name(dst_pm_name);

  vm_migrate(vm, dst_pm);

  return 0;
}
Ejemplo n.º 5
0
static int master(int argc, char *argv[])
{
  double task_comp_size = 5E7;
  double task_comm_size = 1E6;

  char mailbox[256];
  msg_task_t task = NULL;
  msg_host_t jupiter = MSG_host_by_name("Jupiter");
  sprintf(mailbox, "jupi");

  task = MSG_task_create("task on", task_comp_size, task_comm_size, NULL);
  XBT_INFO("Sending \"%s\"", task->name);
  if (MSG_task_send_with_timeout(task, mailbox, 1) != MSG_OK)
    MSG_task_destroy(task);

  MSG_process_sleep(1);
  MSG_host_off(jupiter);

  task = MSG_task_create("task off", task_comp_size, task_comm_size, NULL);
  XBT_INFO("Sending \"%s\"", task->name);
  if (MSG_task_send_with_timeout(task, mailbox, 1) != MSG_OK)
    MSG_task_destroy(task);

  MSG_host_on(jupiter);
  xbt_swag_t jupi_processes = MSG_host_get_process_list(jupiter);
  void *process;
  xbt_swag_foreach(process, jupi_processes) {
    MSG_process_kill(process);
  }
Ejemplo n.º 6
0
static int onoff(int argc, char *argv[]) {
  msg_host_t host1 = MSG_host_by_name("MyHost1");

  XBT_INFO("Energetic profile: %s", MSG_host_get_property_value(host1,"watt_per_state"));
  XBT_INFO("Initial peak speed=%.0E flop/s; Energy dissipated =%.0E J",
     MSG_host_get_current_power_peak(host1), sg_host_get_consumed_energy(host1));

  XBT_INFO("Sleep for 10 seconds");
  MSG_process_sleep(10);
  XBT_INFO("Done sleeping. Current peak speed=%.0E; Energy dissipated=%.2f J",
     MSG_host_get_current_power_peak(host1), sg_host_get_consumed_energy(host1));

  simulate_shutdown(host1);
  XBT_INFO("Host1 is now OFF. Current peak speed=%.0E flop/s; Energy dissipated=%.0f J",
     MSG_host_get_current_power_peak(host1), sg_host_get_consumed_energy(host1));

  XBT_INFO("Sleep for 10 seconds");
  MSG_process_sleep(10);
  XBT_INFO("Done sleeping. Current peak speed=%.0E; Energy dissipated=%.2f J",
     MSG_host_get_current_power_peak(host1), sg_host_get_consumed_energy(host1));

  simulate_bootup(host1);
  XBT_INFO("Host1 is now ON again. Current peak speed=%.0E flop/s; Energy dissipated=%.0f J",
     MSG_host_get_current_power_peak(host1), sg_host_get_consumed_energy(host1));

  return 0;
}
Ejemplo n.º 7
0
int uploader(int argc, char* argv[]){
	/**
		@type simgrid process
		Uploads output file to another host.

		Simgrid process parameters
		--------------------------
		UploadData* data -- pointer to object 
		which contains inforamation about how to replicate output file.
		(destination host, filename, etc.)
	*/

    std::string host_name = MSG_host_get_name(MSG_host_self());
    std::string curFilePath;
    std::string pathAtDest;
    std::string destHostName;
    std::string stor_type;

    msg_file_t file = NULL;

    UploadData* data = (UploadData*) MSG_process_get_data(MSG_process_self());

    destHostName = data->dest;
    destHostName.erase(destHostName.length()-5);
    stor_type = data->dest.back();

    if (destHostName.compare(host_name)) {

        curFilePath = "/" + host_name + "-DISK" + data->filename;
        pathAtDest = "/" + data->dest + data->filename;

        file = MSG_file_open(curFilePath.c_str(), NULL);
        msg_host_t dest = MSG_host_by_name(destHostName.c_str());

        //plusLinkCounter(MSG_host_get_name(MSG_host_self()), destHostName);

        msg_error_t a = MSG_file_rcopy(file, dest, pathAtDest.c_str());
        //if (!atoi(stor_type.c_str())) create_file_label(pathAtDest);

        //trace number of datasets and output traffic from site
        dataset_number_change(data->dest, 1);
        cumulative_output_per_site(host_name, (double) MSG_file_get_size(file));

        if (a == MSG_OK) {
            tracer_traffic(host_name, destHostName, (double) MSG_file_get_size(file));
            minusLinkCounter(host_name, destHostName);
            MSG_file_close(file);
            //XBT_INFO("Creating replica completed at %s", MSG_host_get_name(dest));
        }  else {
            minusLinkCounter(host_name, destHostName);
            MSG_file_close(file);
            XBT_INFO("Transfer fail occurred");
        }
    }

    delete data;

    return 0;

}
Ejemplo n.º 8
0
static int ponger(int argc, char *argv[])
{
  XBT_INFO("Pong -> %s", argv[1]);
  xbt_assert(MSG_host_by_name(argv[1]) != NULL, "Unknown host %s. Stopping Now! ", argv[1]);

  /* - Receive the (small) ping first ....*/
  msg_task_t ping_task = NULL;
  int a = MSG_task_receive(&ping_task, MSG_host_get_name(MSG_host_self()));
  xbt_assert(a == MSG_OK, "Unexpected behavior");

  double sender_time = *((double *) (ping_task->data));
  double communication_time = MSG_get_clock() - sender_time;
  XBT_INFO("Task received : %s", ping_task->name);
  xbt_free(ping_task->data);
  MSG_task_destroy(ping_task);
  XBT_INFO(" Ping time (latency bound) %e", communication_time);

  /*  - ... Then send a 1GB pong back (bandwidth bound) */
  double time = MSG_get_clock();
  msg_task_t pong_task = MSG_task_create("large communication (bandwidth bound)", 0.0, 1e9, NULL);
  pong_task->data = xbt_new(double, 1);
  *(double *) pong_task->data = time;
  XBT_INFO("task_bw->data = %e", *((double *) pong_task->data));
  MSG_task_send(pong_task, argv[1]);

  return 0;
}
Ejemplo n.º 9
0
/** Main function */
int main(int argc, char *argv[])
{
  root_id = std::this_thread::get_id();

  SIMIX_set_maestro(maestro, NULL);
  MSG_init(&argc, argv);

  if (argc != 2) {
    XBT_CRITICAL("Usage: %s platform_file\n", argv[0]);
    xbt_die("example: %s msg_platform.xml\n",argv[0]);
  }

  MSG_create_environment(argv[1]);

  /* Become one of the simulated process.
   *
   * This must be done after the creation of the platform because we are depending attaching to a host.*/
  MSG_process_attach("sender", NULL, MSG_host_by_name("Tremblay"), NULL);
  ensure_root_tid();

  // Execute the sender code:
  const char* subargv[3] = { "sender", "Jupiter", NULL };
  sender(2, (char**) subargv);

  MSG_process_detach(); // Become root thread again
  XBT_INFO("Detached");
  ensure_root_tid();

  return 0;
}
Ejemplo n.º 10
0
static int pinger(int argc, char *argv[])
{
  xbt_assert(argc==2, "The pinger function one argument from the XML deployment file");
  XBT_INFO("Ping -> %s", argv[1]);
  xbt_assert(MSG_host_by_name(argv[1]) != NULL, "Unknown host %s. Stopping Now! ", argv[1]);

  /* - Do the ping with a 1-Byte task (latency bound) ... */
  double now = MSG_get_clock();
  msg_task_t ping_task = MSG_task_create("small communication (latency bound)", 0.0, 1, NULL);
  ping_task->data = xbt_new(double, 1);
  *(double *) ping_task->data = now;
  MSG_task_send(ping_task, argv[1]);

  /* - ... then wait for the (large) pong */
  msg_task_t pong_task = NULL;
  int a = MSG_task_receive(&pong_task,MSG_host_get_name(MSG_host_self()));
  xbt_assert(a == MSG_OK, "Unexpected behavior");

  double sender_time = *((double *) (pong_task->data));
  double communication_time =  MSG_get_clock() - sender_time;
  XBT_INFO("Task received : %s", pong_task->name);
  xbt_free(pong_task->data);
  MSG_task_destroy(pong_task);
  XBT_INFO("Pong time (bandwidth bound): %e", communication_time);

  return 0;
}
Ejemplo n.º 11
0
int main(int argc, char *argv[])
{
   MSG_init(&argc, argv);
   xbt_assert(argc==2);
   MSG_create_environment(argv[1]);
   MSG_process_create("test", server, NULL, MSG_host_by_name("Tremblay"));
   MSG_main();

   return 0;
}
Ejemplo n.º 12
0
int main(int argc, char *argv[]){
  MSG_init(&argc, argv);

  xbt_assert(argc == 2);
  MSG_create_environment(argv[1]);

  launch_master(MSG_host_by_name("Fafard"));

  int res = MSG_main();
  XBT_INFO("Bye (simulation time %g)", MSG_get_clock());

  return !(res == MSG_OK);
}
Ejemplo n.º 13
0
/* This function move the emigrant on Jacquelin */
static int policeman(int argc, char *argv[])
{

  xbt_mutex_acquire(mutex);
  XBT_INFO("Wait a bit before migrating the emigrant.");
  while (process_to_migrate == NULL) xbt_cond_wait(cond, mutex);
  MSG_process_migrate(process_to_migrate, MSG_host_by_name("Jacquelin"));
  XBT_INFO("I moved the emigrant");
  MSG_process_resume(process_to_migrate);
  xbt_mutex_release(mutex);

  return 0;
}                               /* end_of_policeman */
Ejemplo n.º 14
0
static int dvfs(int argc, char *argv[])
{
  msg_host_t host1 = MSG_host_by_name("MyHost1");
  msg_host_t host2 = MSG_host_by_name("MyHost2");
  msg_host_t host3 = MSG_host_by_name("MyHost3");

  /* Host 1 */
  XBT_INFO("Creating and starting two VMs");
  msg_vm_t vm_host1 = MSG_vm_create(host1, "vm_host1", 4, 2048, 100, NULL, 1024 * 20, 10,50);
  MSG_vm_start(vm_host1);
  msg_vm_t vm_host3 = MSG_vm_create(host3, "vm_host3", 4, 2048, 100, NULL, 1024 * 20, 10,50);
  MSG_vm_start(vm_host3);

  XBT_INFO("Create two tasks on Host1: one inside a VM, the other directly on the host");
  MSG_process_create("p11", worker_func, NULL, vm_host1);
  MSG_process_create("p12", worker_func, NULL, host1);

  XBT_INFO("Create two tasks on Host2: both directly on the host");
  MSG_process_create("p21", worker_func, NULL, host2);
  MSG_process_create("p22", worker_func, NULL, host2);

  XBT_INFO("Create two tasks on Host3: both inside a VM");
  MSG_process_create("p31", worker_func, NULL, vm_host3);
  MSG_process_create("p32", worker_func, NULL, vm_host3);

  XBT_INFO("Wait 5 seconds. The tasks are still running (they run for 3 seconds, but 2 tasks are co-located, "
           "so they run for 6 seconds)");
  MSG_process_sleep(5);
  XBT_INFO("Wait another 5 seconds. The tasks stop at some point in between");
  MSG_process_sleep(5);

  MSG_vm_shutdown(vm_host1);
  MSG_vm_shutdown(vm_host3);
  MSG_vm_destroy(vm_host1);
  MSG_vm_destroy(vm_host3);

  return 0;
}
Ejemplo n.º 15
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;
}
Ejemplo n.º 16
0
static int killer(int argc, char *argv[])
{
  XBT_INFO("Hello!");         /* - First start a victim process */
  msg_process_t poor_victim = MSG_process_create("victim", victim, NULL, MSG_host_by_name("Fafard"));
  MSG_process_sleep(10.0);

  XBT_INFO("Resume process"); /* - Resume it from its suspended state */
  MSG_process_resume(poor_victim);

  XBT_INFO("Kill process");   /* - and then kill it */
  MSG_process_kill(poor_victim);

  XBT_INFO("OK, goodbye now.");
  return 0;
}
Ejemplo n.º 17
0
int main(int argc, char **argv)
{
  MSG_init(&argc, argv);
  MSG_create_environment(argv[1]);

  MSG_function_register("host", host);
  for(int i = 0 ; i < 5; i++){
    MSG_process_create("bob", host, NULL, MSG_host_by_name(xbt_strdup("bob")));
  }

  int res = MSG_main();
  XBT_INFO("Simulation time %g", MSG_get_clock());

  return res != MSG_OK;
}
Ejemplo n.º 18
0
JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Host_getByName(JNIEnv * env, jclass cls, jstring jname) {
  msg_host_t host;                /* native host                                          */
  jobject jhost;                /* global reference to the java host instance returned  */

  /* get the C string from the java string */
  if (jname == nullptr) {
    jxbt_throw_null(env,bprintf("No host can have a null name"));
    return nullptr;
  }
  const char *name = env->GetStringUTFChars(jname, 0);
  /* get the host by name       (the hosts are created during the grid resolution) */
  host = MSG_host_by_name(name);

  if (!host) {                  /* invalid name */
    jxbt_throw_host_not_found(env, name);
    env->ReleaseStringUTFChars(jname, name);
    return nullptr;
  }
  env->ReleaseStringUTFChars(jname, name);

  if (!host->extension(JAVA_HOST_LEVEL)) {       /* native host not associated yet with java host */
    /* Instantiate a new java host */
    jhost = jhost_new_instance(env);

    if (!jhost) {
      jxbt_throw_jni(env, "java host instantiation failed");
      return nullptr;
    }

    /* get a global reference to the newly created host */
    jhost = jhost_ref(env, jhost);

    if (!jhost) {
      jxbt_throw_jni(env, "new global ref allocation failed");
      return nullptr;
    }
    /* Sets the java host name */
    env->SetObjectField(jhost, jhost_field_Host_name, jname);
    /* bind the java host and the native host */
    jhost_bind(jhost, host, env);

    /* the native host data field is set with the global reference to the java host returned by this function */
    host->extension_set(JAVA_HOST_LEVEL, (void *)jhost);
  }

  /* return the global reference to the java host instance */
  return (jobject) host->extension(JAVA_HOST_LEVEL);
}
Ejemplo n.º 19
0
int main(int argc, char *argv[])
{
  msg_error_t res = MSG_OK;

  MSG_init(&argc, argv);
  xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]);

  MSG_create_environment(argv[1]);   /* - Load the platform description */
  /* - Create and deploy killer process, that will create the victim process  */
  MSG_process_create("killer", killer, NULL, MSG_host_by_name("Tremblay"));

  res = MSG_main();                 /* - Run the simulation */

  XBT_INFO("Simulation time %g", MSG_get_clock());
  return res != MSG_OK;
}
Ejemplo n.º 20
0
int main(int argc, char *argv[])
{
  /* Get the arguments */
  MSG_init(&argc, argv);

  /* load the platform file */
  MSG_create_environment(argv[1]);

  msg_host_t pm0 =  MSG_host_by_name("Fafard");
  launch_master(pm0);

  int res = MSG_main();
  XBT_INFO("Bye (simulation time %g)", MSG_get_clock());

  return !(res == MSG_OK);
}
Ejemplo n.º 21
0
/* This function creates a MSG process. It has the prototype enforced by SIMIX_function_register_process_create */
smx_process_t MSG_process_create_from_SIMIX(const char *name,
                                   xbt_main_func_t code, void *data,
                                   const char *hostname, double kill_time,
                                   int argc, char **argv,
                                   xbt_dict_t properties, int auto_restart,
                                   smx_process_t parent_process)
{
  msg_host_t host = MSG_host_by_name(hostname);
  msg_process_t p = MSG_process_create_with_environment(name, code, data,
                                                      host, argc, argv,
                                                      properties);
  if (p) {
    MSG_process_set_kill_time(p,kill_time);
    MSG_process_auto_restart_set(p,auto_restart);
  }
  return p;
}
Ejemplo n.º 22
0
int main(int argc, char *argv[])
{
  msg_error_t res = MSG_OK;
  sg_energy_plugin_init();
  MSG_init(&argc, argv);

  xbt_assert(argc > 1, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]);

  MSG_create_environment(argv[1]);

  MSG_process_create("dvfs",dvfs,NULL,MSG_host_by_name("MyHost1"));

  res = MSG_main();

  XBT_INFO("Total simulation time: %.2f; All hosts must have the exact same energy consumption.", MSG_get_clock());

  return res != MSG_OK;
}
Ejemplo n.º 23
0
int main(int argc, char *argv[])
{
  /* Get the arguments */
  MSG_init(&argc, argv);

  /* load the platform file */
  xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s ../platforms/small_platform.xml\n", argv[0], argv[0]);

  MSG_create_environment(argv[1]);

  msg_host_t pm0 = MSG_host_by_name("Fafard");
  launch_master(pm0);

  int res = MSG_main();
  XBT_INFO("Bye (simulation time %g)", MSG_get_clock());

  return !(res == MSG_OK);
}
Ejemplo n.º 24
0
static int master(int argc, char *argv[])
{
  xbt_ex_t e;
  TRY {
    msg_host_t jupiter = MSG_host_by_name("Jupiter");
    XBT_INFO("Master waiting");
    MSG_process_sleep(1);

    XBT_INFO("Turning off the slave host");
    MSG_host_off(jupiter);
    XBT_INFO("Master has finished");
  }
  CATCH(e) {
    xbt_die("Exception caught in the master");
    return 1;
  }
  return 0;
}
Ejemplo n.º 25
0
static void test_dynamic_change(void)
{
  msg_host_t pm0 = MSG_host_by_name("Fafard");

  msg_host_t vm0 = MSG_vm_create_core(pm0, "VM0");
  msg_host_t vm1 = MSG_vm_create_core(pm0, "VM1");
  MSG_vm_start(vm0);
  MSG_vm_start(vm1);

  msg_task_t task0 = MSG_task_create("Task0", DOUBLE_MAX, 0, NULL);
  msg_task_t task1 = MSG_task_create("Task1", DOUBLE_MAX, 0, NULL);
  MSG_process_create("worker0", worker_busy_loop_main, &task0, vm0);
  MSG_process_create("worker1", worker_busy_loop_main, &task1, vm1);

  double task0_remain_prev = MSG_task_get_flops_amount(task0);
  double task1_remain_prev = MSG_task_get_flops_amount(task1);

  const double cpu_speed = MSG_host_get_speed(pm0);
  for (int i = 0; i < 10; i++) {
    double new_bound = (cpu_speed / 10) * i;
    XBT_INFO("set bound of VM1 to %f", new_bound);
    MSG_vm_set_bound(vm1, new_bound);
    MSG_process_sleep(100);

    double task0_remain_now = MSG_task_get_flops_amount(task0);
    double task1_remain_now = MSG_task_get_flops_amount(task1);

    double task0_flops_per_sec = task0_remain_prev - task0_remain_now;
    double task1_flops_per_sec = task1_remain_prev - task1_remain_now;

    XBT_INFO("Task0@VM0: %f flops/s", task0_flops_per_sec / 100);
    XBT_INFO("Task1@VM1: %f flops/s", task1_flops_per_sec / 100);

    task0_remain_prev = task0_remain_now;
    task1_remain_prev = task1_remain_now;
  }

  MSG_process_sleep(2000); // let the tasks end

  MSG_vm_destroy(vm0);
  MSG_vm_destroy(vm1);
}
Ejemplo n.º 26
0
static int master_main(int argc, char *argv[])
{
  xbt_dynar_t hosts_dynar = MSG_hosts_as_dynar();
  msg_host_t pm0 = MSG_host_by_name("Fafard");
  msg_vm_t   vm0 = MSG_vm_create_core(pm0, "VM0");
  MSG_vm_start(vm0);

  launch_computation_worker(vm0);

  while(MSG_get_clock()<100) {
  if (atask != NULL)
    XBT_INFO("aTask remaining duration: %g", MSG_task_get_flops_amount(atask));
  MSG_process_sleep(1);
  }

  MSG_process_sleep(10000);
  MSG_vm_destroy(vm0);
  xbt_dynar_free(&hosts_dynar);
  return 1;
}
Ejemplo n.º 27
0
int main(int argc, char* argv[])
{
  MSG_init(&argc, argv);
  MSG_create_environment(argv[1]);

  msg_host_t h = MSG_host_by_name("Fafard");

  sem = MSG_sem_init(1);
  char** aliceTimes = xbt_new(char*, 9);
  int nbAlice = 0;
  aliceTimes[nbAlice++] = xbt_strdup("0"); 
  aliceTimes[nbAlice++] = xbt_strdup("1");
  aliceTimes[nbAlice++] = xbt_strdup("3");
  aliceTimes[nbAlice++] = xbt_strdup("5");
  aliceTimes[nbAlice++] = xbt_strdup("1");
  aliceTimes[nbAlice++] = xbt_strdup("2");
  aliceTimes[nbAlice++] = xbt_strdup("5");
  aliceTimes[nbAlice++] = xbt_strdup("0");
  aliceTimes[nbAlice++] = NULL;

  char** bobTimes = xbt_new(char*, 9);
  int nbBob = 0;
  bobTimes[nbBob++] = xbt_strdup("0.9"); 
  bobTimes[nbBob++] = xbt_strdup("1");
  bobTimes[nbBob++] = xbt_strdup("1");
  bobTimes[nbBob++] = xbt_strdup("2");
  bobTimes[nbBob++] = xbt_strdup("2");
  bobTimes[nbBob++] = xbt_strdup("0");
  bobTimes[nbBob++] = xbt_strdup("0");
  bobTimes[nbBob++] = xbt_strdup("5");
  bobTimes[nbBob++] = NULL;

  MSG_process_create_with_arguments(xbt_strdup("Alice"), peer, NULL, h, 8, aliceTimes);
  MSG_process_create_with_arguments(xbt_strdup("Bob"), peer, NULL, h, 8, bobTimes);

  msg_error_t res = MSG_main();
  XBT_INFO("Finished\n");
  return (res != MSG_OK);
}
Ejemplo n.º 28
0
/** Emitter function  */
int master(int argc, char *argv[])
{
  int slaves_count = 0;
  msg_host_t *slaves = NULL;
  msg_task_t *todo = NULL;
  int number_of_tasks = 0;
  double task_comp_size = 0;
  double task_comm_size = 0;
  int i;
  _XBT_GNUC_UNUSED int read;

  read = sscanf(argv[1], "%d", &number_of_tasks);
  xbt_assert(read, "Invalid argument %s\n", argv[1]);
  read = sscanf(argv[2], "%lg", &task_comp_size);
  xbt_assert(read, "Invalid argument %s\n", argv[2]);
  read = sscanf(argv[3], "%lg", &task_comm_size);
  xbt_assert(read, "Invalid argument %s\n", argv[3]);

  {                             /*  Task creation */
    char sprintf_buffer[64];

    todo = xbt_new0(msg_task_t, number_of_tasks);

    for (i = 0; i < number_of_tasks; i++) {
      sprintf(sprintf_buffer, "Task_%d", i);
      todo[i] =
          MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size,
                          NULL);
    }
  }

  {                             /* Process organization */
    slaves_count = argc - 4;
    slaves = xbt_new0(msg_host_t, slaves_count);

    for (i = 4; i < argc; i++) {
      slaves[i - 4] = MSG_host_by_name(argv[i]);
      if (slaves[i - 4] == NULL) {
        XBT_INFO("Unknown host %s. Stopping Now! ", argv[i]);
        abort();
      }
    }
  }

  XBT_INFO("Got %d slave(s) :", slaves_count);
  for (i = 0; i < slaves_count; i++)
    XBT_INFO("\t %s", MSG_host_get_name(slaves[i]));

  XBT_INFO("Got %d task to process :", number_of_tasks);

  for (i = 0; i < number_of_tasks; i++)
    XBT_INFO("\t\"%s\"", todo[i]->name);

  for (i = 0; i < number_of_tasks; i++) {
    XBT_INFO("Sending \"%s\" to \"%s\"",
          todo[i]->name, MSG_host_get_name(slaves[i % slaves_count]));
    if (MSG_host_self() == slaves[i % slaves_count]) {
      XBT_INFO("Hey ! It's me ! :)");
    }
    MSG_task_send(todo[i], MSG_host_get_name(slaves[i % slaves_count]));
    XBT_INFO("Send completed");
  }

  XBT_INFO
      ("All tasks have been dispatched. Let's tell everybody the computation is over.");
  for (i = 0; i < slaves_count; i++)
    MSG_task_send(MSG_task_create("finalize", 0, 0, FINALIZE),
        MSG_host_get_name(slaves[i]));

  XBT_INFO("Goodbye now!");
  free(slaves);
  free(todo);
  return 0;
}                               /* end_of_master */
Ejemplo n.º 29
0
static int master_main(int argc, char *argv[])
{
  msg_host_t pm0 = MSG_host_by_name("Fafard");
  msg_host_t pm1 = MSG_host_by_name("Tremblay");
  msg_host_t pm2 = MSG_host_by_name("Bourassa");
  msg_vm_t vm0, vm1;
  s_vm_params_t params;
  memset(&params, 0, sizeof(params));

  vm0 = MSG_vm_create_core(pm0, "VM0");
  params.ramsize = 1L * 1000 * 1000 * 1000; // 1Gbytes
  MSG_host_set_params(vm0, &params);
  MSG_vm_start(vm0);

  XBT_INFO("Test: Migrate a VM with %llu Mbytes RAM", params.ramsize / 1000 / 1000);
  vm_migrate(vm0, pm1);

  MSG_vm_destroy(vm0);

  vm0 = MSG_vm_create_core(pm0, "VM0");
  params.ramsize = 1L * 1000 * 1000 * 100; // 100Mbytes
  MSG_host_set_params(vm0, &params);
  MSG_vm_start(vm0);

  XBT_INFO("Test: Migrate a VM with %llu Mbytes RAM", params.ramsize / 1000 / 1000);
  vm_migrate(vm0, pm1);

  MSG_vm_destroy(vm0);

  vm0 = MSG_vm_create_core(pm0, "VM0");
  vm1 = MSG_vm_create_core(pm0, "VM1");

  params.ramsize = 1L * 1000 * 1000 * 1000; // 1Gbytes
  MSG_host_set_params(vm0, &params);
  MSG_host_set_params(vm1, &params);
  MSG_vm_start(vm0);
  MSG_vm_start(vm1);

  XBT_INFO("Test: Migrate two VMs at once from PM0 to PM1");
  vm_migrate_async(vm0, pm1);
  vm_migrate_async(vm1, pm1);
  MSG_process_sleep(10000);

  MSG_vm_destroy(vm0);
  MSG_vm_destroy(vm1);

  vm0 = MSG_vm_create_core(pm0, "VM0");
  vm1 = MSG_vm_create_core(pm0, "VM1");

  params.ramsize = 1L * 1000 * 1000 * 1000; // 1Gbytes
  MSG_host_set_params(vm0, &params);
  MSG_host_set_params(vm1, &params);
  MSG_vm_start(vm0);
  MSG_vm_start(vm1);

  XBT_INFO("Test: Migrate two VMs at once to different PMs");
  vm_migrate_async(vm0, pm1);
  vm_migrate_async(vm1, pm2);
  MSG_process_sleep(10000);

  MSG_vm_destroy(vm0);
  MSG_vm_destroy(vm1);

  return 0;
}
Ejemplo n.º 30
0
static int master_main(int argc, char *argv[])
{
  msg_host_t pm0 = MSG_host_by_name("Fafard");
  msg_host_t pm1 = MSG_host_by_name("Fafard");

  XBT_INFO("# 1. Put a single task on a PM. ");
  test_one_task(pm0);
  XBT_INFO(" ");

  XBT_INFO("# 2. Put two tasks on a PM.");
  test_two_tasks(pm0, pm0);
  XBT_INFO(" ");

  msg_host_t vm0 = MSG_vm_create_core(pm0, "VM0");
  MSG_vm_start(vm0);

  XBT_INFO("# 3. Put a single task on a VM. ");
  test_one_task(vm0);
  XBT_INFO(" ");

  XBT_INFO("# 4. Put two tasks on a VM.");
  test_two_tasks(vm0, vm0);
  XBT_INFO(" ");

  MSG_vm_destroy(vm0);

  vm0 = MSG_vm_create_core(pm0, "VM0");
  MSG_vm_start(vm0);

  XBT_INFO("# 6. Put a task on a PM and a task on a VM.");
  test_two_tasks(pm0, vm0);
  XBT_INFO(" ");

  MSG_vm_destroy(vm0);

  vm0 = MSG_vm_create_core(pm0, "VM0");
  double cpu_speed = MSG_host_get_speed(pm0);
  MSG_vm_set_bound(vm0, cpu_speed / 10);
  MSG_vm_start(vm0);

  XBT_INFO("# 7. Put a single task on the VM capped by 10%%.");
  test_one_task(vm0);
  XBT_INFO(" ");

  XBT_INFO("# 8. Put two tasks on the VM capped by 10%%.");
  test_two_tasks(vm0, vm0);
  XBT_INFO(" ");

  XBT_INFO("# 9. Put a task on a PM and a task on the VM capped by 10%%.");
  test_two_tasks(pm0, vm0);
  XBT_INFO(" ");

  MSG_vm_destroy(vm0);

  vm0 = MSG_vm_create_core(pm0, "VM0");

  s_vm_params_t params;
  memset(&params, 0, sizeof(params));
  params.ramsize = 1L * 1000 * 1000 * 1000; // 1Gbytes
  MSG_host_set_params(vm0, &params);
  MSG_vm_start(vm0);

  cpu_speed = MSG_host_get_speed(pm0);
  MSG_vm_start(vm0);

  XBT_INFO("# 10. Test migration");
  const double computation_amount = cpu_speed * 10;

  XBT_INFO("# 10. (a) Put a task on a VM without any bound.");
  launch_worker(vm0, "worker0", computation_amount, 0, 0);
  MSG_process_sleep(1000);
  XBT_INFO(" ");

  XBT_INFO("# 10. (b) set 10%% bound to the VM, and then put a task on the VM.");
  MSG_vm_set_bound(vm0, cpu_speed / 10);
  launch_worker(vm0, "worker0", computation_amount, 0, 0);
  MSG_process_sleep(1000);
  XBT_INFO(" ");

  XBT_INFO("# 10. (c) migrate");
  MSG_vm_migrate(vm0, pm1);
  XBT_INFO(" ");

  XBT_INFO("# 10. (d) Put a task again on the VM.");
  launch_worker(vm0, "worker0", computation_amount, 0, 0);
  MSG_process_sleep(1000);
  XBT_INFO(" ");

  MSG_vm_destroy(vm0);

  XBT_INFO("# 11. Change a bound dynamically.");
  test_dynamic_change();

  return 0;
}