示例#1
0
static void scheduleDAX(xbt_dynar_t dax)
{
  unsigned int cursor;
  SD_task_t task;

  const SD_workstation_t *ws_list = SD_workstation_get_list();
  int totalHosts = SD_workstation_get_number();
  qsort((void *) ws_list, totalHosts, sizeof(SD_workstation_t),
        name_compare_hosts);

  int count = SD_workstation_get_number();
  //fprintf(stdout, "No. workstations: %d, %d\n", count, (dax != NULL));

  xbt_dynar_foreach(dax, cursor, task) {
    if (SD_task_get_kind(task) == SD_TASK_COMP_SEQ) {
      if (!strcmp(SD_task_get_name(task), "end")
          || !strcmp(SD_task_get_name(task), "root")) {
        fprintf(stdout, "Scheduling %s to node: %s\n", SD_task_get_name(task),
                SD_workstation_get_name(ws_list[0]));
        SD_task_schedulel(task, 1, ws_list[0]);
      } else {
        fprintf(stdout, "Scheduling %s to node: %s\n", SD_task_get_name(task),
                SD_workstation_get_name(ws_list[(cursor) % count]));
        SD_task_schedulel(task, 1, ws_list[(cursor) % count]);
      }
    }
  }
}
示例#2
0
/*
 * Sort the global list workstations with regard to their availability dates and
 * the simulated time given as input (that corresponds to the estimated minimal
 * start time of a task).
 * All the workstations that are available before this minimal start are sorted
 * in decreasing order of available_at values and placed at the beginning of the
 * set. Those that are available after are sorted in increasing order of
 * available_at values and placed at the end of the set. This way idle times are
 * minimize, and the earliest available workstations are selected, whether the
 * task has to wait or not.
 */
SD_workstation_t * get_best_workstation_set(double time){
  int i, nfirst=0;
  int nworkstations = SD_workstation_get_number();
  const SD_workstation_t *workstations = SD_workstation_get_list();
  SD_workstation_t *best_workstation_set = NULL;

  best_workstation_set = (SD_workstation_t*) calloc (nworkstations,
      sizeof(SD_workstation_t));

  for (i = 0; i < nworkstations; i++){
    if (SD_workstation_get_available_at(workstations[i]) > time){
      best_workstation_set[nworkstations-nfirst-1] = workstations[i];
      nfirst++;
    } else {
      best_workstation_set[i - nfirst] = workstations[i];
    }
  }

  /* Order hosts that are available before the end of node's parent
   * in a decreasing order w.r.t. their availability date*/
  qsort(best_workstation_set,nworkstations-nfirst,sizeof(SD_workstation_t),
      availableAtCompareWorkstations);

  /* Order hosts that are available after the end of node's parent
   * in a increasing order w.r.t. their availability date */
  qsort(&(best_workstation_set[nworkstations-nfirst]), nfirst,
      sizeof(SD_workstation_t), NavailableAtCompareWorkstations);

  return best_workstation_set;
}
示例#3
0
文件: sd_io.c 项目: congfairy/simgrid
int main(int argc, char **argv)
{
  unsigned int ctr;
  const SD_workstation_t *workstations;
  int total_nworkstations;
  xbt_dict_t current_storage_list;
  char *mount_name;
  char *storage_name;
  xbt_dict_cursor_t cursor = NULL;

  SD_init(&argc, argv);
  /* Set the workstation model to default, as storage is not supported by the
   * ptask_L07 model yet.
   */
  SD_config("host/model", "default");
  SD_create_environment(argv[1]);
  workstations = SD_workstation_get_list();
  total_nworkstations = SD_workstation_get_number();

  for (ctr=0; ctr<total_nworkstations;ctr++){
    current_storage_list = SD_workstation_get_mounted_storage_list(workstations[ctr]);
    xbt_dict_foreach(current_storage_list,cursor,mount_name,storage_name)
      XBT_INFO("Workstation '%s' mounts '%s'",
         SD_workstation_get_name(workstations[ctr]), mount_name);
    xbt_dict_free(&current_storage_list);
  }
  SD_exit();
  return 0;
}
示例#4
0
文件: task.c 项目: frs69wq/biCPA
void SD_task_allocate_attribute(SD_task_t task){
  const int nworkstations = SD_workstation_get_number();
  TaskAttribute attr = calloc(1,sizeof(struct _TaskAttribute));
  attr->marked = 0;
  attr->allocation_size = 1;
  attr->iterative_allocations = (int*) calloc (nworkstations, sizeof(int));
  SD_task_set_data(task, attr);
}
示例#5
0
/**
 * \brief Returns the workstation list
 *
 * Use SD_workstation_get_number() to know the array size.
 * 
 * \return an array of \ref SD_workstation_t containing all workstations
 * \remark The workstation order in the returned array is generally different from the workstation creation/declaration order in the XML platform (we use a hash table internally).
 * \see SD_workstation_get_number()
 */
const SD_workstation_t *SD_workstation_get_list(void) {
  xbt_assert(SD_workstation_get_number() > 0, "There is no workstation!");

  if (sd_global->workstation_list == NULL)     /* this is the first time the function is called */
    sd_global->workstation_list = xbt_dynar_to_array(sg_hosts_as_dynar());

  return sd_global->workstation_list;
}
示例#6
0
int main(int argc, char **argv)
{

  const char *platform_file;
  const SD_workstation_t *workstations;
  int ws_nr;
  SD_workstation_t w1 = NULL;
  SD_workstation_t w2 = NULL;
  const char *name1, *name2;
  int i, j, k;

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

  /*  xbt_log_control_set("sd.thres=debug"); */

  if (argc < 2) {
    XBT_INFO("Usage: %s platform_file", argv[0]);
    XBT_INFO("example: %s sd_platform.xml", argv[0]);
    exit(1);
  }

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

  /* test the estimation functions */
  workstations = SD_workstation_get_list();
  ws_nr = SD_workstation_get_number();


  /* Show routes between all workstation */

  for (i = 0; i < ws_nr; i++) {
    for (j = 0; j < ws_nr; j++) {
      const SD_link_t *route;
      int route_size;
      w1 = workstations[i];
      w2 = workstations[j];
      name1 = SD_workstation_get_name(w1);
      name2 = SD_workstation_get_name(w2);
      XBT_INFO("Route between %s and %s:", name1, name2);
      route = SD_route_get_list(w1, w2);
      route_size = SD_route_get_size(w1, w2);
      for (k = 0; k < route_size; k++) {
        XBT_INFO("\tLink %s: latency = %f, bandwidth = %f",
              SD_link_get_name(route[k]),
              SD_link_get_current_latency(route[k]),
              SD_link_get_current_bandwidth(route[k]));
      }
    }
  }

  SD_exit();
  return 0;
}
示例#7
0
/*
 * Used to start a new simulation within the same run on the fresh basis.
 * This function browses the list of workstations and set back attributes to
 * their initial values:
 *   - available_at = 0.0
 *   - last_scheduled_task = NULL
 */
void reset_workstation_attributes() {
  int i;
  int nworkstations = SD_workstation_get_number();
  const SD_workstation_t *workstations = SD_workstation_get_list();

  for (i = 0; i < nworkstations; i++){
    SD_workstation_set_available_at(workstations[i], 0.0);
    SD_workstation_set_last_scheduled_task(workstations[i], NULL);
  }
}
示例#8
0
/*
 * Determine how many distinct workstations have been used by a given schedule.
 * This function is called once the simulation is over. It simply browses the
 * list of all workstations and check the 'available_at' attribute. If its
 * value is greater than 0.0 this means that at least one has been executed
 * there, thus incrementing the peak value.
 */
int compute_peak_resource_usage() {
  int i, peak=0;
  int nworkstations = SD_workstation_get_number();
  const SD_workstation_t *workstations = SD_workstation_get_list();
  for (i = 0; i < nworkstations; i++)
    if (SD_workstation_get_available_at(workstations[i]) > 0.0)
      peak++;

  return peak;
}
示例#9
0
int main(int argc, char **argv)
{
  char *platformFile = NULL;
  int totalHosts, totalLinks;
  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;
  char **value;
  xbt_ex_t e;

  const SD_workstation_t *hosts;
  const SD_link_t *links;

  SD_init(&argc, argv);

  platformFile = argv[1];
  XBT_DEBUG("%s", platformFile);
  TRY {
    SD_create_environment(platformFile);
  } CATCH(e) {
    xbt_die("Error while loading %s: %s",platformFile,e.msg);
  }

  printf("<?xml version='1.0'?>\n");
  printf("<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid.dtd\">\n");
  printf("<platform version=\"3\">\n");
  printf("<AS id=\"AS0\" routing=\"Full\">\n");

  // Hosts
  totalHosts = SD_workstation_get_number();
  hosts = SD_workstation_get_list();
  qsort((void *) hosts, totalHosts, sizeof(SD_workstation_t),
        name_compare_hosts);

  for (i = 0; i < totalHosts; i++) {
    printf("  <host id=\"%s\" power=\"%.0f\"",
           SD_workstation_get_name(hosts[i]),
           SD_workstation_get_power(hosts[i]));
    props = SD_workstation_get_properties(hosts[i]);
    if (props && xbt_dict_length(props) > 0) {
      printf(">\n");
      xbt_dict_foreach(props, cursor, key, data) {
        printf("    <prop id=\"%s\" value=\"%s\"/>\n", key, data);
      }
      printf("  </host>\n");
    } else {
示例#10
0
int main(int argc, char **argv)
{
  /* initialisation of SD */
  int size;
  SD_init(&argc, argv);
  xbt_lib_cursor_t cursor = NULL;
  char *key, *data;

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

  size = xbt_lib_length(host_lib) + xbt_lib_length(as_router_lib);

  printf("Workstation number: %d, link number: %d, elmts number: %d\n",
         SD_workstation_get_number(), SD_link_get_number(), size);

  xbt_lib_foreach(host_lib, cursor, key, data) {
    printf("   - Seen: \"%s\" is type : %d\n", key,
           (int) routing_get_network_element_type(key));
  }
示例#11
0
/**
 * \brief Returns the workstation list
 *
 * Use SD_workstation_get_number() to know the array size.
 *
 * \return an array of \ref SD_workstation_t containing all workstations
 * \see SD_workstation_get_number()
 */
const SD_workstation_t *SD_workstation_get_list(void)
{

  xbt_lib_cursor_t cursor;
  char *key;
  void **data;
  int i;

  xbt_assert(SD_workstation_get_number() > 0, "There is no workstation!");

  if (sd_global->workstation_list == NULL) {    /* this is the first time the function is called */
    sd_global->workstation_list =
      xbt_new(SD_workstation_t, xbt_lib_length(host_lib));

    i = 0;
    xbt_lib_foreach(host_lib, cursor, key, data) {
      if(data[SD_HOST_LEVEL])
        sd_global->workstation_list[i++] = xbt_dict_cursor_get_elm(cursor);
    }
  }
示例#12
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 = SD_workstation_get_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,SD_workstation_get_number());
  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);
    }
示例#13
0
int main(int argc, char **argv)
{
  /* initialisation of SD */

  SD_workstation_t w1, w2;
  const SD_workstation_t *workstations;
  const SD_link_t *route;
  const char *name1;
  const char *name2;
  int route_size, i, j, k;
  int list_size;

#ifdef _XBT_WIN32
  setbuf(stderr, NULL);
  setbuf(stdout, NULL);
#else
  setvbuf(stdout, NULL, _IOLBF, 0);
#endif

  SD_init(&argc, argv);

  /* creation of the environment */
  SD_create_environment(argv[1]);
  printf("Workstation number: %d, link number: %d\n",
         SD_workstation_get_number(), SD_link_get_number());

  if (argc >= 3) {
    if (!strcmp(argv[2], "ONE_LINK")) {
      workstations = SD_workstation_get_list();
      w1 = workstations[0];
      w2 = workstations[1];
      name1 = SD_workstation_get_name(w1);
      name2 = SD_workstation_get_name(w2);

      printf("Route between %s and %s\n", name1, name2);
      route = SD_route_get_list(w1, w2);
      route_size = SD_route_get_size(w1, w2);
      printf("Route size %d\n", route_size);
      for (i = 0; i < route_size; i++) {
      printf("  Link %s: latency = %f, bandwidth = %f\n",
           SD_link_get_name(route[i]),
           SD_link_get_current_latency(route[i]),
           SD_link_get_current_bandwidth(route[i]));
      }
      printf("Route latency = %f, route bandwidth = %f\n",
         SD_route_get_current_latency(w1, w2),
         SD_route_get_current_bandwidth(w1, w2));
    }
    if (!strcmp(argv[2], "FULL_LINK")) {
      workstations = SD_workstation_get_list();
      list_size = SD_workstation_get_number();
      for (i = 0; i < list_size; i++) {
      w1 = workstations[i];
      name1 = SD_workstation_get_name(w1);
      for (j = 0; j < list_size; j++) {
        w2 = workstations[j];
        name2 = SD_workstation_get_name(w2);
        printf("Route between %s and %s\n", name1, name2);
        route = SD_route_get_list(w1, w2);
        route_size = SD_route_get_size(w1, w2);
        printf("  Route size %d\n", route_size);
        for (k = 0; k < route_size; k++) {
        printf("  Link %s: latency = %f, bandwidth = %f\n",
             SD_link_get_name(route[k]),
             SD_link_get_current_latency(route[k]),
             SD_link_get_current_bandwidth(route[k]));
        }
        printf("  Route latency = %f, route bandwidth = %f\n",
           SD_route_get_current_latency(w1, w2),
           SD_route_get_current_bandwidth(w1, w2));
      }
      }
    }
    if (!strcmp(argv[2], "PROP")) {
      printf("SG_TEST_mem: %s\n",
          SD_workstation_get_property_value(SD_workstation_get_by_name("host1"),
          "SG_TEST_mem")
          );
      printf("Author: %s\n", SD_as_router_get_property_value("AS0", "author"));
      printf("AS1: %s\n", SD_as_router_get_property_value("AS1", "name"));
      printf("AS2: %s\n", SD_as_router_get_property_value("AS2", "name"));
    }
  }

  SD_exit();
  return 0;
}
示例#14
0
文件: sd_test2.c 项目: cemsbr/simgrid
int main(int argc, char **argv)
{
  int i, j;
  xbt_dynar_t changed_tasks;
  int n_hosts;
  const SD_workstation_t *hosts;
  SD_task_t taskInit;
  SD_task_t PtoPComm1;
  SD_task_t PtoPComm2;
  SD_task_t ParComp_wocomm;
  SD_task_t IntraRedist;
  SD_task_t ParComp_wcomm1;
  SD_task_t InterRedist;
  SD_task_t taskFinal;
  SD_task_t ParComp_wcomm2;
  SD_workstation_t PtoPcomm1_hosts[2];
  SD_workstation_t PtoPcomm2_hosts[2];
  double PtoPcomm1_table[] = { 0, 12500000, 0, 0 };     /* 100Mb */
  double PtoPcomm2_table[] = { 0, 1250000, 0, 0 };      /* 10Mb */
  double ParComp_wocomm_cost[] = { 1e+9, 1e+9, 1e+9, 1e+9, 1e+9 };      /* 1 Gflop per Proc */
  double *ParComp_wocomm_table;
  SD_workstation_t ParComp_wocomm_hosts[5];
  double *IntraRedist_cost;
  double *IntraRedist_table;
  SD_workstation_t IntraRedist_hosts[5];
  double ParComp_wcomm1_cost[] = { 1e+9, 1e+9, 1e+9, 1e+9, 1e+9 };      /* 1 Gflop per Proc */
  double *ParComp_wcomm1_table;
  SD_workstation_t ParComp_wcomm1_hosts[5];
  double *InterRedist_cost;
  double *InterRedist_table;
  double ParComp_wcomm2_cost[] = { 1e+8, 1e+8, 1e+8, 1e+8, 1e+8 };      /* 1 Gflop per Proc (0.02sec duration) */
  SD_workstation_t ParComp_wcomm2_hosts[5];
  double final_cost = 5e+9;
  double *ParComp_wcomm2_table;

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

  /* creation of the environment */
  if (strstr(argv[1],".xml"))
    SD_create_environment(argv[1]);
  else
    xbt_die("Unsupported platform description style (not XML): %s",
            argv[1]);

  /* getting platform infos */
  n_hosts = SD_workstation_get_number();
  hosts = SD_workstation_get_list();

  /* sorting hosts by hostname */
  qsort((void *) hosts, n_hosts, sizeof(SD_workstation_t),
        nameCompareHosts);

  /* creation of the tasks */
  taskInit = SD_task_create("Initial", NULL, 1.0);
  PtoPComm1 = SD_task_create("PtoP Comm 1", NULL, 1.0);
  PtoPComm2 = SD_task_create("PtoP Comm 2", NULL, 1.0);
  ParComp_wocomm = SD_task_create("Par Comp without comm", NULL, 1.0);
  IntraRedist = SD_task_create("intra redist", NULL, 1.0);
  ParComp_wcomm1 = SD_task_create("Par Comp with comm 1", NULL, 1.0);
  InterRedist = SD_task_create("inter redist", NULL, 1.0);
  taskFinal = SD_task_create("Final", NULL, 1.0);
  ParComp_wcomm2 = SD_task_create("Par Comp with comm 2", NULL, 1.0);


  /* creation of the dependencies */
  SD_task_dependency_add(NULL, NULL, taskInit, PtoPComm1);
  SD_task_dependency_add(NULL, NULL, taskInit, PtoPComm2);
  SD_task_dependency_add(NULL, NULL, PtoPComm1, ParComp_wocomm);
  SD_task_dependency_add(NULL, NULL, ParComp_wocomm, IntraRedist);
  SD_task_dependency_add(NULL, NULL, IntraRedist, ParComp_wcomm1);
  SD_task_dependency_add(NULL, NULL, ParComp_wcomm1, InterRedist);
  SD_task_dependency_add(NULL, NULL, InterRedist, ParComp_wcomm2);
  SD_task_dependency_add(NULL, NULL, ParComp_wcomm2, taskFinal);
  SD_task_dependency_add(NULL, NULL, PtoPComm2, taskFinal);


  /* scheduling parameters */

  /* large point-to-point communication (0.1 sec duration) */
  PtoPcomm1_hosts[0] = hosts[0];
  PtoPcomm1_hosts[1] = hosts[1];

  /* small point-to-point communication (0.01 sec duration) */
  PtoPcomm2_hosts[0] = hosts[0];
  PtoPcomm2_hosts[1] = hosts[2];

  /* parallel task without intra communications (1 sec duration) */
  ParComp_wocomm_table = xbt_new0(double, 25);

  for (i = 0; i < 5; i++) {
    ParComp_wocomm_hosts[i] = hosts[i];
  }

  /* redistribution within a cluster (small latencies) */
  /* each host send (4*2.5Mb =) 10Mb */
  /* bandwidth is shared between 5 flows (0.05sec duration) */
  IntraRedist_cost = xbt_new0(double, 5);
  IntraRedist_table = xbt_new0(double, 25);
  for (i = 0; i < 5; i++) {
    for (j = 0; j < 5; j++) {
      if (i == j)
        IntraRedist_table[i * 5 + j] = 0.;
      else
        IntraRedist_table[i * 5 + j] = 312500.; /* 2.5Mb */
    }
  }

  for (i = 0; i < 5; i++) {
    IntraRedist_hosts[i] = hosts[i];
  }

  /* parallel task with intra communications */
  /* Computation domination (1 sec duration) */
  ParComp_wcomm1_table = xbt_new0(double, 25);

  for (i = 0; i < 5; i++) {
    ParComp_wcomm1_hosts[i] = hosts[i];
  }

  for (i = 0; i < 5; i++) {
    for (j = 0; j < 5; j++) {
      if (i == j)
        ParComp_wcomm1_table[i * 5 + j] = 0.;
      else
        ParComp_wcomm1_table[i * 5 + j] = 312500.;      /* 2.5Mb */
    }
  }

  /* inter cluster redistribution (big latency on the backbone) */
  /* (0.5sec duration without latency impact) */
  InterRedist_cost = xbt_new0(double, 10);
  InterRedist_table = xbt_new0(double, 100);
  for (i = 0; i < 5; i++) {
    InterRedist_table[i * 10 + i + 5] = 1250000.;       /* 10Mb */
  }

  /* parallel task with intra communications */
  /* Communication domination (0.1 sec duration) */

  ParComp_wcomm2_table = xbt_new0(double, 25);

  for (i = 0; i < 5; i++) {
    ParComp_wcomm2_hosts[i] = hosts[i + 5];
  }

  for (i = 0; i < 5; i++) {
    for (j = 0; j < 5; j++) {
      if (i == j)
        ParComp_wcomm2_table[i * 5 + j] = 0.;
      else
        ParComp_wcomm2_table[i * 5 + j] = 625000.;      /* 5Mb */
    }
  }

  /* Sequential task */


  /* scheduling the tasks */
  SD_task_schedule(taskInit, 1, hosts, SD_SCHED_NO_COST, SD_SCHED_NO_COST,
                   -1.0);
  SD_task_schedule(PtoPComm1, 2, PtoPcomm1_hosts, SD_SCHED_NO_COST,
                   PtoPcomm1_table, -1.0);
  SD_task_schedule(PtoPComm2, 2, PtoPcomm2_hosts, SD_SCHED_NO_COST,
                   PtoPcomm2_table, -1.0);
  SD_task_schedule(ParComp_wocomm, 5, ParComp_wocomm_hosts,
                   ParComp_wocomm_cost, ParComp_wocomm_table, -1.0);
  SD_task_schedule(IntraRedist, 5, IntraRedist_hosts, IntraRedist_cost,
                   IntraRedist_table, -1.0);
  SD_task_schedule(ParComp_wcomm1, 5, ParComp_wcomm1_hosts,
                   ParComp_wcomm1_cost, ParComp_wcomm1_table, -1.0);
  SD_task_schedule(InterRedist, 10, hosts, InterRedist_cost,
                   InterRedist_table, -1.0);
  SD_task_schedule(ParComp_wcomm2, 5, ParComp_wcomm2_hosts,
                   ParComp_wcomm2_cost, ParComp_wcomm2_table, -1.0);
  SD_task_schedule(taskFinal, 1, &(hosts[9]), &final_cost,
                   SD_SCHED_NO_COST, -1.0);

  /* let's launch the simulation! */
  changed_tasks = SD_simulate(-1.0);

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

  xbt_dynar_free_container(&changed_tasks);

  free(ParComp_wocomm_table);
  free(IntraRedist_cost);
  free(IntraRedist_table);
  free(ParComp_wcomm1_table);
  free(InterRedist_cost);
  free(InterRedist_table);
  free(ParComp_wcomm2_table);

  SD_task_destroy(taskInit);
  SD_task_destroy(PtoPComm1);
  SD_task_destroy(PtoPComm2);
  SD_task_destroy(ParComp_wocomm);
  SD_task_destroy(IntraRedist);
  SD_task_destroy(ParComp_wcomm1);
  SD_task_destroy(InterRedist);
  SD_task_destroy(ParComp_wcomm2);
  SD_task_destroy(taskFinal);

  SD_exit();
  return 0;
}
示例#15
0
    SD_task_dump(task);
  }

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

  /* Schedule them all on the first workstation */
  XBT_INFO("------------------- Schedule tasks ---------------------------");
  const SD_workstation_t *ws_list = SD_workstation_get_list();

  int count = SD_workstation_get_number();
  xbt_dynar_foreach(dot, 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 % count]);
    }
  }

  XBT_INFO
      ("------------------- Run the schedule ---------------------------");
  changed = SD_simulate(-1);
  xbt_dynar_free_container(&changed);
  XBT_INFO
      ("------------------- Produce the trace file---------------------------");
示例#16
0
  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 workstation */
  XBT_INFO("------------------- Schedule tasks ---------------------------");
  const SD_workstation_t *ws_list = SD_workstation_get_list();
  int totalHosts = SD_workstation_get_number();
  qsort((void *) ws_list, totalHosts, sizeof(SD_workstation_t),
        name_compare_hosts);

  int count = SD_workstation_get_number();
  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 % count]);
    }
  }

  XBT_INFO
      ("------------------- Run the schedule ---------------------------");
示例#17
0
int main(int argc, char **argv) {
  unsigned int flag, cursor, cursor2;
  char *platform_file = NULL, *daxname = NULL, *priority=NULL;
  int total_nworkstations = 0;
  const SD_workstation_t *workstations = NULL;
  xbt_dynar_t daxes = NULL, current_dax = NULL;
  int completed_daxes = 0;
  SD_task_t task;
  scheduling_globals_t globals;
  WorkstationAttribute attr;
  double total_cost = 0.0, score = 0.0;

  SD_init(&argc, argv);

  /* get rid off some logs that are useless */
  xbt_log_control_set("sd_daxparse.thresh:critical");
  xbt_log_control_set("surf_workstation.thresh:critical");
  xbt_log_control_set("root.fmt:[%9.3r]%e[%13c/%7p]%e%m%n");

  globals = new_scheduling_globals();

  daxes = xbt_dynar_new(sizeof(xbt_dynar_t), NULL);
  opterr = 0;

  while (1){
    static struct option long_options[] = {
        {"alg", 1, 0, 'a'},
        {"platform", 1, 0, 'b'},
        {"dax", 1, 0, 'c'},
        {"priority", 1, 0, 'd'},
        {"deadline", 1, 0, 'e'},
        {"budget", 1, 0, 'f'},
        {"price", 1, 0, 'g'},
        {"period", 1, 0, 'h'},
        {"uh", 1, 0, 'i'},
        {"ul", 1, 0, 'j'},
        {"provisioning_delay", 1, 0, 'k'},
        {"silent", 0, 0, 'y'},
        {"dump", 1, 0, 'z'},
        {0, 0, 0, 0}
    };

    int option_index = 0;
    flag = getopt_long (argc, argv, "",
                        long_options, &option_index);

    /* Detect the end of the options. */
    if (flag == -1)
      break;

    switch (flag) {
    case 0:
      /* If this option set a flag, do nothing else now. */
      if (long_options[option_index].flag != 0)
        break;
      printf ("option %s", long_options[option_index].name);
      if (optarg)
        printf (" with arg %s", optarg);
        printf ("\n");
      break;
    case 'a': /* Algorithm name */
      /* DPDS, WA-DPDS, SPSS, Ours*/
      globals->alg = getAlgorithmByName(optarg);
      break;
    case 'b':
      platform_file = optarg;
      SD_create_environment(platform_file);
      total_nworkstations = SD_workstation_get_number();
      workstations = SD_workstation_get_list();

      /* Sort the hosts by name for sake of simplicity */
      qsort((void *)workstations,total_nworkstations, sizeof(SD_workstation_t),
          nameCompareWorkstations);

      for(cursor=0; cursor<total_nworkstations; cursor++){
        SD_workstation_allocate_attribute(workstations[cursor]);
      }
      break;
    case 'c':
      /* List of DAGs to schedule concurrently (just file names here) */
      daxname = optarg;
      XBT_DEBUG("Loading %s", daxname);
      current_dax = SD_daxload(daxname);
      xbt_dynar_foreach(current_dax,cursor,task) {
        if (SD_task_get_kind(task) == SD_TASK_COMP_SEQ){
          SD_task_watch(task, SD_DONE);
        }
        SD_task_allocate_attribute(task);
        SD_task_set_dax_name(task, daxname);
      }
      xbt_dynar_push(daxes,&current_dax);
      break;
    case 'd':
      priority = optarg;
      if (!strcmp(priority,"random"))
        globals->priority_method = RANDOM;
      else if (!strcmp(priority, "sorted"))
        globals->priority_method = SORTED;
      else {
        XBT_ERROR("Unknown priority setting method.");
        exit(1);
      }
      break;
    case 'e':
      globals->deadline = atof(optarg);
      break;
    case 'f':
      globals->budget = atof(optarg);
      break;
    case 'g':
      globals->price = atof(optarg);
      break;
    case 'h':
      globals->period = atof(optarg);
      break;
    case 'i':
      globals->uh = atof(optarg);
      break;
    case 'j':
      globals->ul = atof(optarg);
      break;
    case 'k':
      globals->provisioning_delay = atof(optarg);
      break;
    case 'y':
      xbt_log_control_set("root.thresh:critical");
      break;
    case 'z':
      break;
    }
  }
  /* Display some information about the current run */
  XBT_INFO("Algorithm: %s",getAlgorithmName(globals->alg));
  XBT_INFO("  Priority method: %s",
      globals->priority_method ? "SORTED" : "RANDOM");
  XBT_INFO("  Dynamic provisioning period: %.0fs", globals->period);
  XBT_INFO("  Lower utilization threshold: %.2f%%", globals->ul);
  XBT_INFO("  Upper utilization threshold: %.2f%%", globals->uh);

  XBT_INFO("Platform: %s (%d potential VMs)", platform_file,
      SD_workstation_get_number());
  XBT_INFO("  VM hourly cost: $%f", globals->price);
  XBT_INFO("  VM provisioning delay: %.0fs", globals->provisioning_delay);
  if (ceil(globals->budget/((globals->deadline/3600.)*globals->price))>
      SD_workstation_get_number()){
    XBT_ERROR("The platform file doesn't have enough nodes. Stop here");
    exit(1);
  }
  /* Assign price and provisioning delay to workstation/VM (for the sake of
   * simplicity) */
  for(cursor=0; cursor<total_nworkstations; cursor++){
    SD_workstation_set_price(workstations[cursor], globals->price);
    SD_workstation_set_provisioning_delay(workstations[cursor],
        globals->provisioning_delay);
  }

  XBT_INFO("Ensemble: %lu DAXes", xbt_dynar_length(daxes));
  /* Assign priorities to the DAXes composing the ensemble according to the
   * chosen method: RANDOM (default) or SORTED.
   * Then display the result.
   */
  assign_dax_priorities(daxes, globals->priority_method);
  xbt_dynar_foreach(daxes, cursor, current_dax){
     task = get_root(current_dax);
     XBT_INFO("  %s", SD_task_get_dax_name(task));
     XBT_INFO("    Priority: %d", SD_task_get_dax_priority(task));
  }
示例#18
0
int main(int argc, char **argv)
{
  char *platformFile = NULL;
  int totalHosts, totalLinks;
  int timings=0;
  int downgrade = 0;
  int version = 3;
  const char *link_ctn = link_ctn_v3;
  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_routing_edge_t value1;
  sg_routing_edge_t value2;

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

  setvbuf(stdout, NULL, _IOLBF, 0);

  SD_init(&argc, argv);

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

  if (downgrade) {
    version = 2;
    link_ctn = link_ctn_v2;
  }

  create_environment(parse_time, platformFile);

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

    // Hosts
    totalHosts = SD_workstation_get_number();
    hosts = SD_workstation_get_list();
    qsort((void *) hosts, totalHosts, sizeof(SD_workstation_t),
        name_compare_hosts);

    for (i = 0; i < totalHosts; i++) {
      printf("  <host id=\"%s\" power=\"%.0f\"",
          SD_workstation_get_name(hosts[i]),
          SD_workstation_get_power(hosts[i]));
      props = SD_workstation_get_properties(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 {