Пример #1
0
int main(int argc, char **argv)
{
  double communication_amount1[] = { 0.0, 1.0, 0.0, 0.0 };
  double communication_amount2[] = { 0.0, 0.0, 1.0, 0.0 };
  double no_cost1[] = { 0.0 };
  double no_cost[] = { 0.0, 0.0 };

  SD_init(&argc, argv);
  SD_create_environment(argv[1]);

  SD_task_t root = SD_task_create("Root", NULL, 1.0);
  SD_task_t task1 = SD_task_create("Comm 1", NULL, 1.0);
  SD_task_t task2 = SD_task_create("Comm 2", NULL, 1.0);

  SD_task_schedule(root, 1, sg_host_list(), no_cost1, no_cost1, -1.0);
  SD_task_schedule(task1, 2, sg_host_list(), no_cost, communication_amount1, -1.0);
  SD_task_schedule(task2, 2, sg_host_list(), no_cost, communication_amount2, -1.0);

  SD_task_dependency_add(NULL, NULL, root, task1);
  SD_task_dependency_add(NULL, NULL, root, task2);

  SD_simulate(-1.0);

  printf("%g\n", SD_get_clock());
  fflush(stdout);

  SD_task_destroy(root);
  SD_task_destroy(task1);
  SD_task_destroy(task2);

  SD_exit();
  return 0;
}
Пример #2
0
int main(int argc, char **argv)
{
  int i, j;
  xbt_os_timer_t timer = xbt_os_timer_new();

  SD_init(&argc, argv);
  SD_create_environment(argv[1]);

  sg_host_t *hosts = sg_host_list();
  int host_count = sg_host_count();

  /* Random number initialization */
  srand( (int) (xbt_os_time()*1000) );

  do {
    i = rand()%host_count;
    j = rand()%host_count;
  } while(i==j);

  sg_host_t h1 = hosts[i];
  sg_host_t h2 = hosts[j];
  printf("%d\tand\t%d\t\t",i,j);

  xbt_os_cputimer_start(timer);
  SD_route_get_list(h1, h2);
  xbt_os_cputimer_stop(timer);

  printf("%f\n", xbt_os_timer_elapsed(timer) );

  xbt_free(hosts);
  SD_exit();

  return 0;
}
Пример #3
0
int main(int argc, char **argv)
{
  double communication_amount[] = { 0.0, 1.0, 0.0, 0.0 };
  double no_cost[] = { 0.0, 0.0 };

  SD_task_t task[TASK_NUM];

  SD_init(&argc, argv);
  SD_create_environment(argv[1]);

  SD_task_t root = SD_task_create("Root", NULL, 1.0);

  sg_host_t *hosts = sg_host_list();
  SD_task_schedule(root, 1, hosts, no_cost, no_cost, -1.0);

  for (int i = 0; i < TASK_NUM; i++) {
    task[i] = SD_task_create("Comm", NULL, 1.0);
    SD_task_schedule(task[i], 2, hosts, no_cost, communication_amount, -1.0);
    SD_task_dependency_add(NULL, NULL, root, task[i]);
  }
  xbt_free(hosts);

  SD_simulate(-1.0);

  printf("%g\n", SD_get_clock());
  fflush(stdout);

  for (int i = 0; i < TASK_NUM; i++) {
    SD_task_destroy(task[i]);
  }
  SD_task_destroy(root);

  SD_exit();
  return 0;
}
Пример #4
0
int main(int argc, char **argv)
{
  char *platformFile = NULL;
  unsigned int totalHosts, totalLinks;
  int timings=0;
  int version = 4;
  const char *link_ctn = "link_ctn";
  unsigned int i;
  xbt_dict_t props = NULL;
  xbt_dict_cursor_t cursor = NULL;
  xbt_lib_cursor_t cursor_src = NULL;
  xbt_lib_cursor_t cursor_dst = NULL;
  char *src,*dst,*key,*data;
  sg_netcard_t value1;
  sg_netcard_t value2;

  const sg_host_t *hosts;
  const SD_link_t *links;
  xbt_os_timer_t parse_time = xbt_os_timer_new();

  SD_init(&argc, argv);

  if (parse_cmdline(&timings, &platformFile, argc, argv) || !platformFile) {
    xbt_die("Invalid command line arguments: expected [--timings] platformFile");
  }

  XBT_DEBUG("%d,%s", timings, platformFile);

  create_environment(parse_time, platformFile);

  if (timings) {
    XBT_INFO("Parsing time: %fs (%zu hosts, %d links)", xbt_os_timer_elapsed(parse_time),
             sg_host_count(), sg_link_count());
  } else {
    printf("<?xml version='1.0'?>\n");
    printf("<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd\">\n");
    printf("<platform version=\"%d\">\n", version);
    printf("<AS id=\"AS0\" routing=\"Full\">\n");

    // Hosts
    totalHosts = sg_host_count();
    hosts = sg_host_list();
    qsort((void *) hosts, totalHosts, sizeof(sg_host_t), name_compare_hosts);

    for (i = 0; i < totalHosts; i++) {
      printf("  <host id=\"%s\" speed=\"%.0f\"", sg_host_get_name(hosts[i]), sg_host_speed(hosts[i]));
      props = sg_host_get_properties(hosts[i]);
      if (sg_host_core_count(hosts[i])>1) {
        printf(" core=\"%d\"", sg_host_core_count(hosts[i]));
      }
      if (props && !xbt_dict_is_empty(props)) {
        printf(">\n");
        xbt_dict_foreach(props, cursor, key, data) {
          printf("    <prop id=\"%s\" value=\"%s\"/>\n", key, data);
        }
        printf("  </host>\n");
      } else {
Пример #5
0
/* SimDag Incomplete Test
 * Scenario:
 *   - Create a bunch of tasks
 *   - schedule only a subset of them (init, A and D)
 *   - run the simulation
 *   - Verify that we detect which tasks are not scheduled and show their state.
 * The scheduled task A sends 1GB. Simulation time should be
 *          1e9/1.25e8 + 1e-4 = 8.0001 seconds
 * Task D is scheduled but depends on unscheduled task C.
 */
int main(int argc, char **argv)
{
  /* scheduling parameters */
  double communication_amount1 = 1e9;
  double no_cost = 0.0;

  /* initialization of SD */
  SD_init(&argc, argv);

  /* creation of the environment */
  SD_create_environment(argv[1]);

  /* creation of the tasks and their dependencies */
  SD_task_t taskInit = SD_task_create("Init", NULL, 1.0);
  SD_task_t taskA = SD_task_create("Task A", NULL, 1.0);
  SD_task_t taskB = SD_task_create("Task B", NULL, 1.0);
  SD_task_t taskC = SD_task_create("Task C", NULL, 1.0);
  SD_task_t taskD = SD_task_create("Task D", NULL, 1.0);

  SD_task_dependency_add(NULL, NULL, taskInit, taskA);
  SD_task_dependency_add(NULL, NULL, taskInit, taskB);
  SD_task_dependency_add(NULL, NULL, taskC, taskD);

  const sg_host_t *hosts = sg_host_list();

  SD_task_schedule(taskInit, 1, sg_host_list(), &no_cost, &no_cost, -1.0);
  SD_task_schedule(taskA, 1, &hosts[0], &no_cost, &communication_amount1, -1.0);
  SD_task_schedule(taskD, 1, &hosts[0], &no_cost, &communication_amount1, -1.0);

  /* let's launch the simulation! */
  SD_simulate(-1.);

  SD_task_destroy(taskA);
  SD_task_destroy(taskB);
  SD_task_destroy(taskC);
  SD_task_destroy(taskD);
  SD_task_destroy(taskInit);

  XBT_INFO("Simulation time: %f", SD_get_clock());

  SD_exit();
  return 0;
}
Пример #6
0
int main(int argc, char **argv)
{
  unsigned int ctr;
  SD_task_t task;
  xbt_dynar_t changed_tasks;

  SD_init(&argc, argv);
  SD_create_environment(argv[1]);
  const sg_host_t *hosts = sg_host_list();

  SD_task_t t1 = SD_task_create_comp_seq("t1", NULL, 25000000);
  SD_task_t c1 = SD_task_create_comm_e2e("c1", NULL, 125000000);
  SD_task_t t2 = SD_task_create_comp_seq("t2", NULL, 25000000);
  SD_task_t c2 = SD_task_create_comm_e2e("c2", NULL, 62500000);
  SD_task_t t3 = SD_task_create_comp_seq("t3", NULL, 25000000);
  SD_task_t c3 = SD_task_create_comm_e2e("c3", NULL, 31250000);
  SD_task_t t4 = SD_task_create_comp_seq("t4", NULL, 25000000);

  /* Add dependencies: t1->c1->t2->c2->t3 */
  SD_task_dependency_add(NULL, NULL, t1, c1);
  SD_task_dependency_add(NULL, NULL, c1, t2);
  SD_task_dependency_add(NULL, NULL, t2, c2);
  SD_task_dependency_add(NULL, NULL, c2, t3);
  SD_task_dependency_add(NULL, NULL, t3, c3);
  SD_task_dependency_add(NULL, NULL, c3, t4);

  /* Schedule tasks t1 and w3 on first host, t2 on second host */
  /* Transfers are auto-scheduled */
  SD_task_schedulel(t1, 1, hosts[0]);
  SD_task_schedulel(t2, 1, hosts[1]);
  SD_task_schedulel(t3, 1, hosts[0]);
  SD_task_schedulel(t4, 1, hosts[1]);

  /* Add some watchpoint upon task completion */
  SD_task_watch(t1, SD_DONE);
  SD_task_watch(c1, SD_DONE);
  SD_task_watch(t2, SD_DONE);
  SD_task_watch(c2, SD_DONE);
  SD_task_watch(t3, SD_DONE);
  SD_task_watch(c3, SD_DONE);
  SD_task_watch(t4, SD_DONE);

  while (!xbt_dynar_is_empty((changed_tasks = SD_simulate(-1.0)))) {
    XBT_INFO("link1: bw=%.0f, lat=%f", SD_route_get_bandwidth(hosts[0], hosts[1]),
             SD_route_get_latency(hosts[0], hosts[1]));
    XBT_INFO("Jupiter: speed=%.0f", sg_host_speed(hosts[0])* sg_host_get_available_speed(hosts[0]));
    XBT_INFO("Tremblay: speed=%.0f", sg_host_speed(hosts[1])* sg_host_get_available_speed(hosts[1]));
    xbt_dynar_foreach(changed_tasks, ctr, task) {
      XBT_INFO("Task '%s' start time: %f, finish time: %f", SD_task_get_name(task),
           SD_task_get_start_time(task), SD_task_get_finish_time(task));
      if (SD_task_get_state(task)==SD_DONE)
        SD_task_destroy(task);
    }
  }
Пример #7
0
/* Build an array that contains all the idle hosts/VMs in the platform */
xbt_dynar_t get_idle_VMs(){
  int i;
  const sg_host_t *hosts = sg_host_list();
  int nhosts = sg_host_count();
  xbt_dynar_t idleVMs = xbt_dynar_new(sizeof(sg_host_t), NULL);

  for (i = 0; i < nhosts; i++){
    if (is_on_and_idle(hosts[i]))
      xbt_dynar_push(idleVMs, &(hosts[i]));
  }

  return idleVMs;
}
Пример #8
0
int main(int argc, char **argv)
{
  unsigned int ctr;
  SD_task_t task;
  xbt_dynar_t changed_tasks;

  SD_init(&argc, argv);
  xbt_assert(argc > 1, "Usage: %s platform_file\n\nExample: %s two_clusters.xml", argv[0], argv[0]);

  SD_create_environment(argv[1]);

  sg_host_t *hosts = sg_host_list();

  /* creation of some typed tasks and their dependencies */
  /* chain of five tasks, three compute tasks with two data transfers in between */
  SD_task_t taskA = SD_task_create_comp_seq("Task A", NULL, 5e9);
  SD_task_t taskB = SD_task_create_comm_e2e("Task B", NULL, 1e7);
  SD_task_t taskC = SD_task_create_comp_seq("Task C", NULL, 5e9);
  SD_task_t taskD = SD_task_create_comm_e2e("Task D", NULL, 1e7);
  SD_task_t taskE = SD_task_create_comp_seq("Task E", NULL, 5e9);

  SD_task_dependency_add(NULL, NULL, taskA, taskB);
  SD_task_dependency_add(NULL, NULL, taskB, taskC);
  SD_task_dependency_add(NULL, NULL, taskC, taskD);
  SD_task_dependency_add(NULL, NULL, taskD, taskE);

  /* Add watchpoints on completion of compute tasks */
  SD_task_watch(taskA, SD_DONE);
  SD_task_watch(taskC, SD_DONE);
  SD_task_watch(taskE, SD_DONE);

  /* Auto-schedule the compute tasks on three different workstations */
  /* Data transfer tasks taskB and taskD are automagically scheduled */
  SD_task_schedulel(taskA, 1, hosts[0]);
  SD_task_schedulel(taskC, 1, hosts[1]);
  SD_task_schedulel(taskE, 1, hosts[0]);
  while (!xbt_dynar_is_empty((changed_tasks = SD_simulate(-1.0)))) {
    XBT_INFO("Simulation stopped after %.4f seconds", SD_get_clock());
    xbt_dynar_foreach(changed_tasks, ctr, task) {
      XBT_INFO("Task '%s' start time: %f, finish time: %f", SD_task_get_name(task), SD_task_get_start_time(task),
               SD_task_get_finish_time(task));
    }

    /* let throttle the communication for taskD if its parent is SD_DONE */
    /* the bandwidth is 1.25e8, the data size is 1e7, and we want to throttle the bandwidth by a factor 2.
     * The rate is then 1.25e8/(2*1e7)=6.25
     * Changing the rate is possible before the task execution starts (in SD_RUNNING state).
     */
    if (SD_task_get_state(taskC) == SD_DONE && SD_task_get_state(taskD) < SD_RUNNING)
      SD_task_set_rate(taskD, 6.25);
  }
Пример #9
0
/* Build an array that contains all the busy hosts/VMs in the platform */
xbt_dynar_t get_running_VMs(){
  int i;
  const sg_host_t *hosts = sg_host_list ();
  int nhosts = sg_host_count ();
  HostAttribute attr;
  xbt_dynar_t runningVMs = xbt_dynar_new(sizeof(sg_host_t), NULL);

  for (i = 0; i < nhosts; i++){
    attr = sg_host_user(hosts[i]);
    if (attr->on_off)
      xbt_dynar_push(runningVMs, &(hosts[i]));
  }

  return runningVMs;
}
Пример #10
0
/* Basic SimDag Test 0
 * Scenario:
 *   - Create a no-op Init task
 *   - Create two communication tasks: 100MB and 1B
 *   - Schedule them concurrently on the two hosts of the platform
 * The two communications occur simultaneously but one is so short that it has no impact on the other.
 * Simulated time should be:
 *          1e8/1.25e8 + 1e-4 = 0.8001 seconds
 * This corresponds to paying latency once and having the full bandwidth for the big message.
 */
int main(int argc, char **argv)
{
  /* scheduling parameters */
  double communication_amount1[] = { 0, 1e8, 0, 0 };
  double communication_amount2[] = { 0, 1, 0, 0 };
  const double no_cost[] = { 0.0, 0.0 };

  /* initialization of SD */
  SD_init(&argc, argv);

  /* creation of the environment */
  SD_create_environment(argv[1]);

  /* creation of the tasks and their dependencies */
  SD_task_t taskInit = SD_task_create("Init", NULL, 1.0);
  SD_task_t taskA = SD_task_create("Task Comm 1", NULL, 1.0);
  SD_task_t taskB = SD_task_create("Task Comm 2", NULL, 1.0);

  SD_task_dependency_add(NULL, NULL, taskInit, taskA);
  SD_task_dependency_add(NULL, NULL, taskInit, taskB);

  SD_task_schedule(taskInit, 1, sg_host_list(), no_cost, no_cost, -1.0);
  SD_task_schedule(taskA, 2, sg_host_list(), no_cost, communication_amount1, -1.0);
  SD_task_schedule(taskB, 2, sg_host_list(), no_cost, communication_amount2, -1.0);

  /* let's launch the simulation! */
  SD_simulate(-1.0);
  SD_task_destroy(taskInit);
  SD_task_destroy(taskA);
  SD_task_destroy(taskB);

  XBT_INFO("Simulation time: %f", SD_get_clock());

  SD_exit();
  return 0;
}
Пример #11
0
/* Determine the current utilization of VM in the system. This utilization is defined in the paper by Malawski et al.
 * as "the percentage of idle VMs over time".
 * The source code shows that it is the number of busy VMs divided by the total number of active VMs (busy and idle)
 */
double compute_current_VM_utilization(){
  int i=0;
  const sg_host_t *hosts = sg_host_list ();
  int nhosts = sg_host_count ();
  HostAttribute attr;
  int nActiveVMs = 0, nBusyVMs = 0;

  for (i = 0; i < nhosts; i++){
    attr = sg_host_user(hosts[i]);
    if (attr->on_off){
      nActiveVMs++;
      if (!attr->idle_busy)
        nBusyVMs++;
    }
  }
  return (100.*nBusyVMs)/nActiveVMs;
}
Пример #12
0
/* Determine how much money has already been spent. Each host/VM has an attribute that sums the cost (#hours*price)
 * for each period in which the VM is on.
 */
double compute_budget_consumption(){
  double consumed_budget = 0.0;
  int i=0;
  HostAttribute attr;
  const sg_host_t *hosts = sg_host_list ();
  int nhosts = sg_host_count ();

  for(i=0;i<nhosts;i++){
    attr = sg_host_user(hosts[i]);
    consumed_budget += attr->total_cost;
    if (attr->on_off){
      XBT_DEBUG("%s : Account for %d consumed hours", sg_host_get_name(hosts[i]),
          (int)(SD_get_clock()-attr->start_time)/3600);
      consumed_budget += (((int)(SD_get_clock()-attr->start_time)/3600))*attr->price;
    }
  }

  return consumed_budget;
}
Пример #13
0
/* Build an array that contains all the hosts/VMs that are "approaching their hourly billing cycle" in the platform
 * Remark: In the paper by Malawski et al., no details are provided about when a VM is "approaching" the end of a
 * paid hour. This is hard coded in the source code of cloudworkflowsim: 90s (provisioner interval, a.k.a period) +
 * 1s (optimistic deprovisioning delay)
 */
xbt_dynar_t get_ending_billing_cycle_VMs(double period, double margin){
  int i;
  const sg_host_t *hosts = sg_host_list ();
  int nhosts = sg_host_count ();
  HostAttribute attr;
  xbt_dynar_t endingVMs = xbt_dynar_new(sizeof(sg_host_t), NULL);

  for (i = 0; i < nhosts; i++){
    attr = sg_host_user(hosts[i]);
    /* To determine how far a VM is from the end of a hourly billing cycle, we compute the time spent between the
     * start of the VM and the current, and keep the time spent in the last hour. As times are expressed in seconds,
     * it amounts to computing the modulo to 3600s=1h. Then the current VM is selected if this modulo is greater than
     * 3600-period-margin.
     */
    if (attr->on_off && ((int)(SD_get_clock() - attr->start_time) % 3600) > (3600-period-margin))
      xbt_dynar_push(endingVMs, &(hosts[i]));
  }

  return endingVMs;
}
Пример #14
0
int main(int argc, char **argv) {
  xbt_os_timer_t timer = xbt_os_timer_new();

  /* initialization of SD */
  SD_init(&argc, argv);

  if (argc > 1) {
    SD_create_environment(argv[1]);
  } else {
    SD_create_environment("../../platforms/One_cluster_no_backbone.xml");
  }

  ws_list = sg_host_list();
  reclaimed = xbt_dynar_new(sizeof(bcast_task_t),xbt_free_ref);
  xbt_dynar_t done = NULL;

  xbt_os_cputimer_start(timer);
  send_one(0,sg_host_count());
  do {
    if (done != NULL && !xbt_dynar_is_empty(done)) {
      unsigned int cursor;
      SD_task_t task;

      xbt_dynar_foreach(done, cursor, task) {
        bcast_task_t bt = SD_task_get_data(task);

        if (bt->i != bt->j -1)
          send_one(bt->i,bt->j);
        if (bt->j != bt->k -1)
          send_one(bt->j,bt->k);

        if (xbt_dynar_length(reclaimed)<100) {
          xbt_dynar_push_as(reclaimed,bcast_task_t,bt);
        } else {
          free(bt);
        }
        SD_task_destroy(task);
      }
      xbt_dynar_free(&done);
    }
Пример #15
0
/* Return the first inactive host/VM (currently set to OFF) that we find in the platform.
 * Remarks:
 * 1) Straightforward selection, all VMs are assumed to be similar
 * 2) It may happen that no such VM is found. This means that the platform file given as input of the simulator was
 *    too small. The simulation cannot continue while the size of the resource pool represented by the platform file
 *    is not increased.
 */
sg_host_t find_inactive_VM_to_start(){
  int i=0;
  const sg_host_t *hosts = sg_host_list ();
  int nhosts = sg_host_count ();
  HostAttribute attr;
  sg_host_t host = NULL;

  while (i < nhosts){
    attr = sg_host_user(hosts[i]);
    if (!attr->on_off){
      host = hosts[i];
      break;
    }
    i++;
  }

  if (!host){
    xbt_die("Argh. We reached the pool limit. Have to increase the size of the cluster in the platform file.");
  }

  return host;
}
Пример #16
0
/*
 * simple latency test
 * send one byte from 0 to 1 
 * 
 * this is a test for multiple platforms
 * see tesh file for expected output
 */
int main(int argc, char **argv)
{
  double communication_amount[] = { 0.0, 1.0, 0.0, 0.0 };
  const double no_cost[] = { 0.0, 0.0 };

  SD_init(&argc, argv);
  SD_create_environment(argv[1]);

  SD_task_t task = SD_task_create("Comm 1", NULL, 1.0);

  SD_task_schedule(task, 2, sg_host_list(), no_cost, communication_amount, -1.0);

  SD_simulate(-1.0);

  printf("%g\n", SD_get_clock());
  fflush(stdout);

  SD_task_destroy(task);

  SD_exit();
  return 0;
}
Пример #17
0
/* Basic SimDag Test 4
 * Scenario:
 *   - Create a chain of tasks (Init, A, Fin)
 *   - Have a 1B communication between two no-op tasks.
 * Verify that the tasks are actually simulated in the right order.
 * The simulated time should be equal to the network latency: 0.0001 seconds.
 */
int main(int argc, char **argv)
{
  /* scheduling parameters */
  double no_cost[] = { 0., 0., 0., 0. };
  double amount[] = { 0., 1., 0., 0. };

  /* SD initialization */
  SD_init(&argc, argv);

  /* creation of the environment */
  SD_create_environment(argv[1]);

  /* creation of the tasks and their dependencies */
  SD_task_t taskInit = SD_task_create("Task Init", NULL, 1.0);
  SD_task_t taskA = SD_task_create("Task A", NULL, 1.0);
  SD_task_t taskFin = SD_task_create("Task Fin", NULL, 1.0);

  SD_task_dependency_add(NULL, NULL, taskInit, taskA);
  SD_task_dependency_add(NULL, NULL, taskA, taskFin);

  sg_host_t *hosts = sg_host_list();
  SD_task_schedule(taskInit, 1, hosts, no_cost, no_cost, -1.0);
  SD_task_schedule(taskA, 2, hosts, no_cost, amount, -1.0);
  SD_task_schedule(taskFin, 1, hosts, no_cost, no_cost, -1.0);
  xbt_free(hosts);

  /* let's launch the simulation! */
  SD_simulate(-1.0);
  SD_task_destroy(taskInit);
  SD_task_destroy(taskA);
  SD_task_destroy(taskFin);

  XBT_INFO("Simulation time: %f", SD_get_clock());

  SD_exit();
  return 0;
}
Пример #18
0
int main(int argc, char **argv)
{

  double comm_amount[] = { 0.0 };
  double comp_cost[] = { 1.0 };

  SD_init(&argc, argv);
  SD_create_environment(argv[1]);

  SD_task_t task = SD_task_create("seqtask", NULL, 1.0);
  sg_host_t *hosts = sg_host_list();
  SD_task_schedule(task, 1, hosts, comp_cost, comm_amount, -1.0);
  xbt_free(hosts);

  SD_simulate(-1.0);

  printf("%g\n", SD_get_clock());
  fflush(stdout);

  SD_task_destroy(task);

  SD_exit();
  return 0;
}
Пример #19
0
  XBT_INFO("------------------- Display all tasks of the loaded DAG ---------------------------");
  xbt_dynar_foreach(dax, cursor, task) {
    SD_task_dump(task);
  }

  FILE *dotout = fopen("dax.dot", "w");
  fprintf(dotout, "digraph A {\n");
  xbt_dynar_foreach(dax, cursor, task) {
    SD_task_dotty(task, dotout);
  }
  fprintf(dotout, "}\n");
  fclose(dotout);

  /* Schedule them all on the first host */
  XBT_INFO("------------------- Schedule tasks ---------------------------");
  const sg_host_t *ws_list = sg_host_list();
  int hosts_count = sg_host_count();
  qsort((void *) ws_list, hosts_count, sizeof(sg_host_t), name_compare_hosts);

  xbt_dynar_foreach(dax, cursor, task) {
    if (SD_task_get_kind(task) == SD_TASK_COMP_SEQ) {
      if (!strcmp(SD_task_get_name(task), "end"))
        SD_task_schedulel(task, 1, ws_list[0]);
      else
        SD_task_schedulel(task, 1, ws_list[cursor % hosts_count]);
    }
  }

  XBT_INFO("------------------- Run the schedule ---------------------------");
  SD_simulate(-1);
  XBT_INFO("------------------- Produce the trace file---------------------------");
Пример #20
0
  XBT_INFO("------------------- Display all tasks of the loaded DAG ---------------------------");
  xbt_dynar_foreach(dax, cursor, task) {
    SD_task_dump(task);
  }

  FILE *dotout = fopen("dax.dot", "w");
  fprintf(dotout, "digraph A {\n");
  xbt_dynar_foreach(dax, cursor, task) {
    SD_task_dotty(task, dotout);
  }
  fprintf(dotout, "}\n");
  fclose(dotout);

  /* Schedule them all on the first host */
  XBT_INFO("------------------- Schedule tasks ---------------------------");
  sg_host_t *host_list = sg_host_list();
  int hosts_count = sg_host_count();
  qsort((void *) host_list, hosts_count, sizeof(sg_host_t), name_compare_hosts);

  xbt_dynar_foreach(dax, cursor, task) {
    if (SD_task_get_kind(task) == SD_TASK_COMP_SEQ) {
      if (!strcmp(SD_task_get_name(task), "end"))
        SD_task_schedulel(task, 1, host_list[0]);
      else
        SD_task_schedulel(task, 1, host_list[cursor % hosts_count]);
    }
  }
  xbt_free(host_list);

  XBT_INFO("------------------- Run the schedule ---------------------------");
  SD_simulate(-1);
Пример #21
0
int main(int argc, char **argv)
{
  sg_host_t host_list[2];
  double computation_amount[2];
  double communication_amount[4] = { 0 };

  /* initialization of SD */
  SD_init(&argc, argv);

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

  /* test the estimation functions */
  const sg_host_t *hosts = sg_host_list();
  sg_host_t h1 = hosts[0];
  sg_host_t h2 = hosts[1];
  const char *name1 = sg_host_get_name(h1);
  const char *name2 = sg_host_get_name(h2);
  double comp_amount1 = 2000000;
  double comp_amount2 = 1000000;
  double comm_amount12 = 2000000;
  double comm_amount21 = 3000000;
  XBT_INFO("Computation time for %f flops on %s: %f", comp_amount1, name1, comp_amount1/sg_host_speed(h1));
  XBT_INFO("Computation time for %f flops on %s: %f", comp_amount2, name2, comp_amount2/sg_host_speed(h2));

  XBT_INFO("Route between %s and %s:", name1, name2);
  SD_link_t *route = SD_route_get_list(h1, h2);
  int route_size = SD_route_get_size(h1, h2);
  for (int i = 0; i < route_size; i++)
    XBT_INFO("   Link %s: latency = %f, bandwidth = %f", sg_link_name(route[i]), sg_link_latency(route[i]),
             sg_link_bandwidth(route[i]));
  xbt_free(route);
  XBT_INFO("Route latency = %f, route bandwidth = %f", SD_route_get_latency(h1, h2), SD_route_get_bandwidth(h1, h2));
  XBT_INFO("Communication time for %f bytes between %s and %s: %f", comm_amount12, name1, name2,
        SD_route_get_latency(h1, h2) + comm_amount12 / SD_route_get_bandwidth(h1, h2));
  XBT_INFO("Communication time for %f bytes between %s and %s: %f", comm_amount21, name2, name1,
        SD_route_get_latency(h2, h1) + comm_amount21 / SD_route_get_bandwidth(h2, h1));

  /* creation of the tasks and their dependencies */
  SD_task_t taskA = SD_task_create("Task A", NULL, 10.0);
  SD_task_t taskB = SD_task_create("Task B", NULL, 40.0);
  SD_task_t taskC = SD_task_create("Task C", NULL, 30.0);
  SD_task_t taskD = SD_task_create("Task D", NULL, 60.0);

  /* try to attach and retrieve user data to a task */
  SD_task_set_data(taskA, static_cast<void*>(&comp_amount1));
  if (fabs(comp_amount1 - (*(static_cast<double*>(SD_task_get_data(taskA))))) > 1e-12)
      XBT_ERROR("User data was corrupted by a simple set/get");

  SD_task_dependency_add(NULL, NULL, taskB, taskA);
  SD_task_dependency_add(NULL, NULL, taskC, taskA);
  SD_task_dependency_add(NULL, NULL, taskD, taskB);
  SD_task_dependency_add(NULL, NULL, taskD, taskC);
  SD_task_dependency_add(NULL, NULL, taskB, taskC);

  try {
    SD_task_dependency_add(NULL, NULL, taskA, taskA);   /* shouldn't work and must raise an exception */
    xbt_die("Hey, I can add a dependency between Task A and Task A!");
  } catch (xbt_ex& ex) {
    if (ex.category != arg_error)
      throw;                  /* this is a serious error */
  }

  try {
    SD_task_dependency_add(NULL, NULL, taskB, taskA);   /* shouldn't work and must raise an exception */
    xbt_die("Oh oh, I can add an already existing dependency!");
  } catch (xbt_ex& ex) {
    if (ex.category != arg_error)
      throw;
  }

  try {
    SD_task_dependency_remove(taskA, taskC);    /* shouldn't work and must raise an exception */
    xbt_die("Dude, I can remove an unknown dependency!");
  } catch (xbt_ex& ex) {
    if (ex.category != arg_error)
      throw;
  }

  try {
    SD_task_dependency_remove(taskC, taskC);    /* shouldn't work and must raise an exception */
    xbt_die("Wow, I can remove a dependency between Task C and itself!");
  } catch (xbt_ex& ex) {
    if (ex.category != arg_error)
      throw;
  }

  /* if everything is ok, no exception is forwarded or rethrown by main() */

  /* watch points */
  SD_task_watch(taskD, SD_DONE);
  SD_task_watch(taskB, SD_DONE);
  SD_task_unwatch(taskD, SD_DONE);

  /* scheduling parameters */
  host_list[0] = h1;
  host_list[1] = h2;
  computation_amount[0] = comp_amount1;
  computation_amount[1] = comp_amount2;

  communication_amount[1] = comm_amount12;
  communication_amount[2] = comm_amount21;

  /* estimated time */
  SD_task_t task = taskD;
  XBT_INFO("Estimated time for '%s': %f", SD_task_get_name(task), SD_task_get_execution_time(task, 2, host_list,
           computation_amount, communication_amount));

  SD_task_schedule(taskA, 2, host_list, computation_amount, communication_amount, -1);
  SD_task_schedule(taskB, 2, host_list, computation_amount, communication_amount, -1);
  SD_task_schedule(taskC, 2, host_list, computation_amount, communication_amount, -1);
  SD_task_schedule(taskD, 2, host_list, computation_amount, communication_amount, -1);

  std::set<SD_task_t> *changed_tasks = simgrid::sd::simulate(-1.0);
  for (auto task: *changed_tasks){
    XBT_INFO("Task '%s' start time: %f, finish time: %f", SD_task_get_name(task),
          SD_task_get_start_time(task), SD_task_get_finish_time(task));
  }

  XBT_DEBUG("Destroying tasks...");
  SD_task_destroy(taskA);
  SD_task_destroy(taskB);
  SD_task_destroy(taskC);
  SD_task_destroy(taskD);

  XBT_DEBUG("Tasks destroyed. Exiting SimDag...");
  SD_exit();
  return 0;
}
Пример #22
0
  /* load the DOT file */
  dot = SD_PTG_dotload(argv[2]);
  if(dot == NULL){
    SD_exit();
    xbt_die("No dot load may be you have a cycle in your graph");
  }

  /* Display all the tasks */
  XBT_INFO("------------------- Display all tasks of the loaded DAG ---------------------------");
  xbt_dynar_foreach(dot, cursor, task) {
    SD_task_dump(task);
  }

  /* Schedule them all on all the first host*/
  XBT_INFO("------------------- Schedule tasks ---------------------------");
  sg_host_t *hosts = sg_host_list();
  int count = sg_host_count();
  xbt_dynar_foreach(dot, cursor, task) {
    if (SD_task_get_kind(task) == SD_TASK_COMP_PAR_AMDAHL) {
        SD_task_schedulev(task, count, hosts);
    }
  }
  xbt_free(hosts);

  XBT_INFO("------------------- Run the schedule ---------------------------");
  SD_simulate(-1);
  XBT_INFO("Makespan: %f", SD_get_clock());
  xbt_dynar_foreach(dot, cursor, task) {
    SD_task_destroy(task);
  }
  xbt_dynar_free_container(&dot);