Пример #1
0
 xbt_dynar_foreach(dax, cursor, task) {
   int kind = SD_task_get_kind(task);
   SD_workstation_t *wsl = SD_task_get_workstation_list(task);
   switch (kind) {
   case SD_TASK_COMP_SEQ:
     fprintf(out, "[%f] %s compute %f # %s\n",
             SD_task_get_start_time(task),
             SD_workstation_get_name(wsl[0]), SD_task_get_amount(task),
             SD_task_get_name(task));
     break;
   case SD_TASK_COMM_E2E:
     fprintf(out, "[%f] %s send %s %f # %s\n",
             SD_task_get_start_time(task),
             SD_workstation_get_name(wsl[0]),
             SD_workstation_get_name(wsl[1]), SD_task_get_amount(task),
             SD_task_get_name(task));
     fprintf(out, "[%f] %s recv %s %f # %s\n",
             SD_task_get_finish_time(task),
             SD_workstation_get_name(wsl[1]),
             SD_workstation_get_name(wsl[0]), SD_task_get_amount(task),
             SD_task_get_name(task));
     break;
   default:
     xbt_die("Task %s is of unknown kind %d", SD_task_get_name(task),
             SD_task_get_kind(task));
   }
   SD_task_destroy(task);
 }
Пример #2
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]);
      }
    }
  }
}
Пример #3
0
static int name_compare_hosts(const void *n1, const void *n2)
{
  char name1[80], name2[80];
  strcpy(name1, SD_workstation_get_name(*((SD_workstation_t *) n1)));
  strcpy(name2, SD_workstation_get_name(*((SD_workstation_t *) n2)));

  return strcmp(name1, name2);
}
Пример #4
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;
}
Пример #5
0
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;
}
Пример #6
0
/** @brief Displays debugging informations about a workstation */
void SD_workstation_dump(SD_workstation_t ws)
{
  xbt_dict_t props;
  xbt_dict_cursor_t cursor=NULL;
  char *key,*data;
  SD_task_t task = NULL;
  
  XBT_INFO("Displaying workstation %s", SD_workstation_get_name(ws));
  XBT_INFO("  - power: %.0f", SD_workstation_get_power(ws));
  XBT_INFO("  - available power: %.2f", SD_workstation_get_available_power(ws));
  switch (sg_host_sd(ws)->access_mode){
  case SD_WORKSTATION_SHARED_ACCESS:
      XBT_INFO("  - access mode: Space shared");
      break;
  case SD_WORKSTATION_SEQUENTIAL_ACCESS:
      XBT_INFO("  - access mode: Exclusive");
    task = SD_workstation_get_current_task(ws);
    if(task)
      XBT_INFO("    current running task: %s",
               SD_task_get_name(task));
    else
      XBT_INFO("    no task running");
      break;
  default: break;
  }
  props = SD_workstation_get_properties(ws);
  
  if (!xbt_dict_is_empty(props)){
    XBT_INFO("  - properties:");

    xbt_dict_foreach(props,cursor,key,data) {
      XBT_INFO("    %s->%s",key,data);
    }
Пример #7
0
int main(int argc, char **argv)
{
  const SD_workstation_t *workstations;
  SD_workstation_t w1;
  SD_workstation_t w2;
  const char *name1;
  const char *name2;
  xbt_dict_t props;
  xbt_dict_cursor_t cursor = NULL;
  char *key, *data;
  char noexist[] = "NoProp";
  const char *value;
  char exist[] = "Hdd";

  /* initialisation of SD */
  SD_init(&argc, argv);
  if (argc < 2) {
    XBT_INFO("Usage: %s platform_file", argv[0]);
    XBT_INFO("example: %s sd_platform.xml", argv[0]);
    exit(1);
  }
  SD_create_environment(argv[1]);

  /* init of platform elements */
  workstations = SD_workstation_get_list();
  w1 = workstations[0];
  w2 = workstations[1];
  SD_workstation_set_access_mode(w2, SD_WORKSTATION_SEQUENTIAL_ACCESS);
  name1 = SD_workstation_get_name(w1);
  name2 = SD_workstation_get_name(w2);


  /* The host properties can be retrived from all interfaces */

  XBT_INFO("Property list for workstation %s", name1);
  /* Get the property list of the workstation 1 */
  props = SD_workstation_get_properties(w1);


  /* Trying to set a new property */
  xbt_dict_set(props, "NewProp", strdup("newValue"), NULL);

  /* Print the properties of the workstation 1 */
  xbt_dict_foreach(props, cursor, key, data) {
    XBT_INFO("\tProperty: %s has value: %s", key, data);
  }
Пример #8
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 {
Пример #9
0
int main(int argc, char **argv)
{
  int i;
  const char *platform_file;
  const SD_workstation_t *workstations;
  int kind;
  SD_task_t task, taskA, taskB, taskC;
  xbt_dynar_t changed_tasks;
  SD_workstation_t workstation_list[2];
  double computation_amount[2];
  double communication_amount[4] = { 0 };
  double rate = -1.0;
  SD_workstation_t w1, w2;

  /* SD initialization */
  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);

  /* Change the access mode of the workstations */
  workstations = SD_workstation_get_list();
  w1 = workstations[0];
  w2 = workstations[1];
  for (i = 0; i < 2; i++) {
    SD_workstation_set_access_mode(workstations[i],
                                   SD_WORKSTATION_SEQUENTIAL_ACCESS);
    XBT_INFO("Access mode of %s is %s",
          SD_workstation_get_name(workstations[i]),
          (SD_workstation_get_access_mode(workstations[i]) ==
           SD_WORKSTATION_SEQUENTIAL_ACCESS) ? "sequential" : "shared");
  }

  /* creation of the tasks and their dependencies */
  taskA = SD_task_create_comp_seq("Task A", NULL, 2e9);
  taskB = SD_task_create_comm_e2e("Task B", NULL, 2e9);
  taskC = SD_task_create_comp_seq("Task C", NULL, 1e9);
  TRACE_category ("taskA");
  TRACE_category ("taskB");
  TRACE_category ("taskC");
  TRACE_sd_set_task_category (taskA, "taskA");
  TRACE_sd_set_task_category (taskB, "taskB");
  TRACE_sd_set_task_category (taskC, "taskC");

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

  /* watch points */
  SD_task_watch(taskA, SD_RUNNING);
  SD_task_watch(taskB, SD_RUNNING);
  SD_task_watch(taskC, SD_RUNNING);
  SD_task_watch(taskC, SD_DONE);


  /* scheduling parameters */
  workstation_list[0] = w1;
  workstation_list[1] = w2;
  computation_amount[0] = SD_task_get_amount(taskA);
  computation_amount[1] = SD_task_get_amount(taskB);

  communication_amount[1] = SD_task_get_amount(taskC);
  communication_amount[2] = 0.0;

  SD_task_schedule(taskA, 1, &w1,
                   &(computation_amount[0]), SD_SCHED_NO_COST, rate);
  SD_task_schedule(taskB, 2, workstation_list,
                   SD_SCHED_NO_COST, communication_amount, rate);
  SD_task_schedule(taskC, 1, &w1,
                   &(computation_amount[1]), SD_SCHED_NO_COST, rate);

  /* let's launch the simulation! */
  while (!xbt_dynar_is_empty(changed_tasks = SD_simulate(-1.0))) {
    for (i = 0; i < 2; i++) {
      task = SD_workstation_get_current_task(workstations[i]);
      if (task)
        kind = SD_task_get_kind(task);
      else {
        XBT_INFO("There is no task running on %s",
              SD_workstation_get_name(workstations[i]));
        continue;
      }

      switch (kind) {
      case SD_TASK_COMP_SEQ:
        XBT_INFO("%s is currently running on %s (SD_TASK_COMP_SEQ)",
              SD_task_get_name(task),
              SD_workstation_get_name(workstations[i]));
        break;
      case SD_TASK_COMM_E2E:
        XBT_INFO("%s is currently running on %s (SD_TASK_COMM_E2E)",
              SD_task_get_name(task),
              SD_workstation_get_name(workstations[i]));
        break;
      case SD_TASK_NOT_TYPED:
        XBT_INFO("Task running on %s has no type",
              SD_workstation_get_name(workstations[i]));
        break;
      default:
        XBT_ERROR("Shouldn't be here");
      }
    }
    xbt_dynar_free_container(&changed_tasks);
  }
  xbt_dynar_free_container(&changed_tasks);

  XBT_DEBUG("Destroying tasks...");

  SD_task_destroy(taskA);
  SD_task_destroy(taskB);
  SD_task_destroy(taskC);

  XBT_DEBUG("Tasks destroyed. Exiting SimDag...");

  SD_exit();
  return 0;
}
Пример #10
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;
}
Пример #11
0
/*
 * Return a rough estimation of the time needed to transfer 'size' bytes of data
 * between two allocated tasks 'src' and 'dst'. Two cases are distinguished:
 *   - both allocations are strictly identical, then the route from the first
 *     workstation to itself (down link, backbone, up link) is considered,
 *   - Otherwise, the function first find a pair of distinct workstations from
 *     the src and dst allocations.
 * In both cases, the estimation is the sum of
 *  - the time to send (1/src_allocation_size)th of the data on the private down
 *    link of one of the workstation in 'src_allocation'
 *  - the maximum time to send the entire data over each link in between
 *  - the time to send (1/dst_allocation_size)th of the data on the private up
 *    link of one of the workstation in 'dst_allocation'
 *  - the sum of the link's latencies on the route
 * This estimation doesn't take concurrent transfers (and then bandwidth sharing
 * between them) into account. Transfer times are thus underestimated.
*/
double SD_task_estimate_transfer_time_from(SD_task_t src, SD_task_t dst,
    double size){
  int src_allocation_size, dst_allocation_size;
  SD_workstation_t *src_allocation, *dst_allocation;
  const SD_link_t* route=NULL;
  int route_size;
  double transfer_time =0.0;
  int src_index = -1, dst_index=-1;
  int i, s, d;;

  src_allocation_size = SD_task_get_allocation_size(src);
  src_allocation = SD_task_get_allocation(src);
  dst_allocation_size = SD_task_get_allocation_size(dst);
  dst_allocation = SD_task_get_allocation(dst);

  qsort((void *)src_allocation,src_allocation_size, sizeof(SD_workstation_t),
      nameCompareWorkstations);
  qsort((void *)dst_allocation,dst_allocation_size, sizeof(SD_workstation_t),
      nameCompareWorkstations);

  i = 0;
  if (src_allocation_size == dst_allocation_size) {
    for (s = 0; s < src_allocation_size; s++) {
      for (d = 0; d < dst_allocation_size; d++) {
        if (!strcmp(SD_workstation_get_name (src_allocation[s]),
            SD_workstation_get_name (dst_allocation[d]))) {
          i++;
          break;
        }
      }
      if (i <= s)
        break;
    }
  }

  if (i == src_allocation_size) {
    /* both configurations are identical. Let just consider the transfer between
     * the first workstation of each set */
    route= SD_route_get_list (src_allocation[0], dst_allocation[0]);
    route_size = SD_route_get_size(src_allocation[0], dst_allocation[0]);
    src_index=dst_index=0;
  } else {
    /* Found 2 different hosts. The first host belongs to src
       and the second one belongs to dst. Then
       compute the transfer time walking through the route between
       them */
    for (s = 0; s < src_allocation_size; s++) {
      for (d = 0; d < dst_allocation_size; d++) {
        if (strcmp(SD_workstation_get_name (src_allocation[s]),
            SD_workstation_get_name (dst_allocation[d]))) {
          src_index = s;
          dst_index = d;
          break;
        }
      }
      if (src_index != -1)
        break;
    }
    route= SD_route_get_list (src_allocation[src_index],
        dst_allocation[dst_index]);
    route_size = SD_route_get_size(src_allocation[src_index],
        dst_allocation[dst_index]);
  }

 /* first link */
  transfer_time = size/
      (SD_link_get_current_bandwidth(route[0])*src_allocation_size);

  for (i = 1; i < route_size - 1; i++) {
    if (transfer_time < (size /
        SD_link_get_current_bandwidth(route[i])))
      transfer_time = size / SD_link_get_current_bandwidth(route[i]);
  }

  /* last link */
  if (transfer_time < size /
      (SD_link_get_current_bandwidth(route[route_size-1]) *
          dst_allocation_size)){
    transfer_time = size /
        (SD_link_get_current_bandwidth(route[route_size-1]) *
            dst_allocation_size);
  }

  transfer_time +=
      SD_route_get_current_latency (src_allocation[src_index],
          dst_allocation[dst_index]);
  XBT_VERB("Estimated transfer time between tasks '%s' and '%s': %.3f",
      SD_task_get_name(src), SD_task_get_name(dst),transfer_time);
  return transfer_time;
}
Пример #12
0
int main(int argc, char **argv)
{
  int i;
  const char *platform_file;
  const SD_workstation_t *workstations;
  SD_task_t taskA, taskB, taskC, taskD;
  xbt_dynar_t changed_tasks;

  /* initialization 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);

  /* Change the access mode of the workstations */
  workstations = SD_workstation_get_list();
  for (i = 0; i < 2; i++) {
    SD_workstation_dump(workstations[i]);
    
    SD_workstation_set_access_mode(workstations[i],
                                   SD_WORKSTATION_SEQUENTIAL_ACCESS);
    XBT_INFO(" Change access mode of %s to %s",
          SD_workstation_get_name(workstations[i]),
          (SD_workstation_get_access_mode(workstations[i]) ==
           SD_WORKSTATION_SEQUENTIAL_ACCESS) ? "sequential" : "shared");
  }
  /* Well I changed my mind, I want the second workstation to be shared */

  SD_workstation_set_access_mode(workstations[1],
                                     SD_WORKSTATION_SHARED_ACCESS);
  XBT_INFO(" Change access mode of %s to %s",
           SD_workstation_get_name(workstations[1]),
           (SD_workstation_get_access_mode(workstations[1]) ==
           SD_WORKSTATION_SEQUENTIAL_ACCESS) ? "sequential" : "shared");

  /* creation of the tasks and their dependencies */
  taskA = SD_task_create_comp_seq("Task A", NULL, 2e10);
  taskB = SD_task_create_comm_e2e("Task B", NULL, 2e8);
  taskC = SD_task_create_comp_seq("Task C", NULL, 1e10);
  taskD = SD_task_create_comp_seq("Task D", NULL, 1e11);

  SD_task_dependency_add("B->C", NULL,taskB, taskC);

  /* watch points */
  SD_task_watch(taskA, SD_RUNNING);
  SD_task_watch(taskB, SD_RUNNING);
  SD_task_watch(taskC, SD_RUNNING);
  SD_task_watch(taskC, SD_DONE);
  SD_task_watch(taskD, SD_DONE);


  /* scheduling parameters */
  SD_task_schedulel(taskA, 1, workstations[0]);
  SD_task_schedulel(taskB, 2, workstations[0], workstations[1]);
  SD_task_schedulel(taskC, 1, workstations[1]);
  SD_task_schedulel(taskD, 1, workstations[1]);

  /* let's launch the simulation! */
  while (!xbt_dynar_is_empty(changed_tasks = SD_simulate(-1.0))) {
    XBT_INFO(" Simulation was suspended, check workstation states"); 
    for (i = 0; i < 2; i++) {
      SD_workstation_dump(workstations[i]);
    }
    xbt_dynar_free(&changed_tasks);
  }
  xbt_dynar_free(&changed_tasks);

  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;
}
Пример #13
0
static int nameCompareHosts(const void *n1, const void *n2)
{
  return strcmp(SD_workstation_get_name(*((SD_workstation_t *) n1)),
                SD_workstation_get_name(*((SD_workstation_t *) n2)));
}
Пример #14
0
int main(int argc, char **argv)
{
  int i;
  unsigned int ctr;
  const char *platform_file;
  const SD_workstation_t *workstations;
  const char *name1;
  const char *name2;
  double computation_amount1;
  double computation_amount2;
  double communication_amount12;
  double communication_amount21;
  const SD_link_t *route;
  int route_size;
  SD_task_t task, taskA, taskB, taskC, taskD, checkB, checkD;
  xbt_dynar_t changed_tasks;
  xbt_ex_t ex;
  const int workstation_number = 2;
  SD_workstation_t workstation_list[2];
  double computation_amount[2];
  double communication_amount[4] = { 0 };
  double rate = -1.0;
  SD_workstation_t w1, w2;

  /* initialization 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();
  w1 = workstations[0];
  w2 = workstations[1];
  SD_workstation_set_access_mode(w2, SD_WORKSTATION_SEQUENTIAL_ACCESS);
  name1 = SD_workstation_get_name(w1);
  name2 = SD_workstation_get_name(w2);
  computation_amount1 = 2000000;
  computation_amount2 = 1000000;
  communication_amount12 = 2000000;
  communication_amount21 = 3000000;
  XBT_INFO("Computation time for %f flops on %s: %f", computation_amount1,
        name1, SD_workstation_get_computation_time(w1,
                                                   computation_amount1));
  XBT_INFO("Computation time for %f flops on %s: %f", computation_amount2,
        name2, SD_workstation_get_computation_time(w2,
                                                   computation_amount2));

  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 (i = 0; i < route_size; i++) {
    XBT_INFO("   Link %s: latency = %f, bandwidth = %f",
          SD_link_get_name(route[i]),
          SD_link_get_current_latency(route[i]),
          SD_link_get_current_bandwidth(route[i]));
  }
  XBT_INFO("Route latency = %f, route bandwidth = %f",
        SD_route_get_current_latency(w1, w2),
        SD_route_get_current_bandwidth(w1, w2));
  XBT_INFO("Communication time for %f bytes between %s and %s: %f",
        communication_amount12, name1, name2,
        SD_route_get_communication_time(w1, w2, communication_amount12));
  XBT_INFO("Communication time for %f bytes between %s and %s: %f",
        communication_amount21, name2, name1,
        SD_route_get_communication_time(w2, w1, communication_amount21));

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

  /* try to attach and retrieve user data to a task */
  SD_task_set_data(taskA, (void*) &computation_amount1);
  if (computation_amount1 != (*((double*) SD_task_get_data(taskA))))
      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, taskA, taskD); /\* deadlock */



  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(ex) {
    if (ex.category != arg_error)
      RETHROW;                  /* this is a serious error */
    xbt_ex_free(ex);
  }

  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(ex) {
    if (ex.category != arg_error)
      RETHROW;
    xbt_ex_free(ex);
  }

  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(ex) {
    if (ex.category != arg_error)
      RETHROW;
    xbt_ex_free(ex);
  }

  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(ex) {
    if (ex.category != arg_error)
      RETHROW;
    xbt_ex_free(ex);
  }


  /* 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 */
  workstation_list[0] = w1;
  workstation_list[1] = w2;
  computation_amount[0] = computation_amount1;
  computation_amount[1] = computation_amount2;

  communication_amount[1] = communication_amount12;
  communication_amount[2] = communication_amount21;

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

  /* let's launch the simulation! */

  SD_task_schedule(taskA, workstation_number, workstation_list,
                   computation_amount, communication_amount, rate);
  SD_task_schedule(taskB, workstation_number, workstation_list,
                   computation_amount, communication_amount, rate);
  SD_task_schedule(taskC, workstation_number, workstation_list,
                   computation_amount, communication_amount, rate);
  SD_task_schedule(taskD, workstation_number, workstation_list,
                   computation_amount, communication_amount, rate);

  changed_tasks = SD_simulate(-1.0);
  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));
  }
Пример #15
0
/*
 * Sort workstations by name in the LEXICOGRAPHIC order
 */
int nameCompareWorkstations(const void *w1, const void *w2){
  return strcmp(SD_workstation_get_name(*((SD_workstation_t *)w1)),
      SD_workstation_get_name(*((SD_workstation_t *)w2)));
}
Пример #16
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 {