Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
get rid of sd_workstation.cpp
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 14 Feb 2017 10:14:05 +0000 (11:14 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 14 Feb 2017 10:14:05 +0000 (11:14 +0100)
fix sg_host_route_bandwidth function

examples/simdag/availability/sd_availability.c
examples/simdag/scheduling/sd_scheduling.c
examples/simdag/test/sd_test.cpp
include/simgrid/simdag.h
src/include/surf/datatypes.h
src/simdag/sd_task.cpp
src/simdag/sd_workstation.cpp [deleted file]
src/simgrid/host.cpp
teshsuite/simdag/basic-parsing-test/basic-parsing-test.c
teshsuite/simdag/evaluate-get-route-time/evaluate-get-route-time.c
tools/cmake/DefinePackages.cmake

index f5993ca..083c5d9 100644 (file)
@@ -79,8 +79,8 @@ int main(int argc, char **argv)
     xbt_dynar_t changed_tasks = SD_simulate(-1.0);
     if (xbt_dynar_is_empty(changed_tasks))
       break;
     xbt_dynar_t changed_tasks = SD_simulate(-1.0);
     if (xbt_dynar_is_empty(changed_tasks))
       break;
-    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("link1: bw=%.0f, lat=%f", sg_host_route_bandwidth(hosts[0], hosts[1]),
+             sg_host_route_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_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]));
      
index eca4354..a95be21 100644 (file)
@@ -84,8 +84,8 @@ static double finish_on_at(SD_task_t task, sg_host_t host)
         if (SD_task_get_amount(parent) <= 1e-6){
           redist_time= 0;
         } else {
         if (SD_task_get_amount(parent) <= 1e-6){
           redist_time= 0;
         } else {
-          redist_time = SD_route_get_latency(parent_host[0], host) +
-                        SD_task_get_amount(parent) / SD_route_get_bandwidth(parent_host[0], host);
+          redist_time = sg_host_route_latency(parent_host[0], host) +
+                        SD_task_get_amount(parent) / sg_host_route_bandwidth(parent_host[0], host);
         }
         data_available = SD_task_get_start_time(parent) + redist_time;
       }
         }
         data_available = SD_task_get_start_time(parent) + redist_time;
       }
index 8be5be9..37066ff 100644 (file)
@@ -5,6 +5,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simgrid/simdag.h"
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simgrid/simdag.h"
+#include "simgrid/s4u.hpp"
 #include "xbt/ex.h"
 #include <xbt/ex.hpp>
 #include "xbt/log.h"
 #include "xbt/ex.h"
 #include <xbt/ex.hpp>
 #include "xbt/log.h"
@@ -27,29 +28,29 @@ int main(int argc, char **argv)
 
   /* test the estimation functions */
   const sg_host_t *hosts = sg_host_list();
 
   /* test the estimation functions */
   const sg_host_t *hosts = sg_host_list();
-  sg_host_t h1           = hosts[4];
-  sg_host_t h2           = hosts[2];
-  const char *name1 = sg_host_get_name(h1);
-  const char *name2 = sg_host_get_name(h2);
+  simgrid::s4u::Host* h1           = hosts[4];
+  simgrid::s4u::Host* h2           = hosts[2];
   double comp_amount1 = 2000000;
   double comp_amount2 = 1000000;
   double comm_amount12 = 2000000;
   double comm_amount21 = 3000000;
   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));
+  XBT_INFO("Computation time for %f flops on %s: %f", comp_amount1, h1->cname(), comp_amount1/h1->speed());
+  XBT_INFO("Computation time for %f flops on %s: %f", comp_amount2, h2->cname(), comp_amount2/h2->speed());
+
+  XBT_INFO("Route between %s and %s:", h1->cname(), h2->cname());
+  std::vector<Link*> route;
+  double latency = 0;
+  h1->routeTo(h2, &route, &latency);
+
+  for (auto link : route)
+    XBT_INFO("   Link %s: latency = %f, bandwidth = %f", sg_link_name(link), sg_link_latency(link),
+             sg_link_bandwidth(link));
+
+  XBT_INFO("Route latency = %f, route bandwidth = %f", latency, sg_host_route_bandwidth(h1, h2));
+  XBT_INFO("Communication time for %f bytes between %s and %s: %f", comm_amount12,  h1->cname(), h2->cname(),
+        sg_host_route_latency(h1, h2) + comm_amount12 / sg_host_route_bandwidth(h1, h2));
+  XBT_INFO("Communication time for %f bytes between %s and %s: %f", comm_amount21,  h2->cname(), h1->cname(),
+        sg_host_route_latency(h2, h1) + comm_amount21 / sg_host_route_bandwidth(h2, h1));
 
   /* creation of the tasks and their dependencies */
   SD_task_t taskA = SD_task_create("Task A", NULL, 10.0);
 
   /* creation of the tasks and their dependencies */
   SD_task_t taskA = SD_task_create("Task A", NULL, 10.0);
index b41becd..eaf760a 100644 (file)
@@ -57,24 +57,6 @@ typedef enum {
   SD_TASK_COMM_PAR_MXN_1D_BLOCK = 4 /**< @brief MxN data redistribution (1D Block distribution) */
 } e_SD_task_kind_t;
 
   SD_TASK_COMM_PAR_MXN_1D_BLOCK = 4 /**< @brief MxN data redistribution (1D Block distribution) */
 } e_SD_task_kind_t;
 
-
-/************************** Workstation handling ****************************/
-/** @addtogroup SD_host_api
- *
- *  A host is a place where a task can be executed.
- *  A host is represented as a <em>physical resource with computing capabilities</em> and has a <em>name</em>.
- *
- *  The hosts are created from the description file when you call the function SD_create_environment.
- *
- *  @see sg_host_t
- *  @{
- */
-XBT_PUBLIC(SD_link_t *) SD_route_get_list(sg_host_t src, sg_host_t dst);
-XBT_PUBLIC(int) SD_route_get_size(sg_host_t src, sg_host_t dst);
-XBT_PUBLIC(double) SD_route_get_latency(sg_host_t src, sg_host_t dst);
-XBT_PUBLIC(double) SD_route_get_bandwidth(sg_host_t src, sg_host_t dst);
-/** @} */
-
 /************************** Task handling ************************************/
 /** @defgroup SD_task_api Tasks
  *  @brief Functions for managing the tasks
 /************************** Task handling ************************************/
 /** @defgroup SD_task_api Tasks
  *  @brief Functions for managing the tasks
index 1a19b75..3c7dc29 100644 (file)
@@ -7,9 +7,6 @@
 #ifndef MAXMIN_DATATYPES_H
 #define MAXMIN_DATATYPES_H
 
 #ifndef MAXMIN_DATATYPES_H
 #define MAXMIN_DATATYPES_H
 
-typedef struct surf_storage *surf_storage_t;
-typedef struct surf_stat *surf_stat_t;
-
 typedef struct lmm_element *lmm_element_t;
 typedef struct lmm_variable *lmm_variable_t;
 typedef struct lmm_constraint *lmm_constraint_t;
 typedef struct lmm_element *lmm_element_t;
 typedef struct lmm_variable *lmm_variable_t;
 typedef struct lmm_constraint *lmm_constraint_t;
index 8de2276..3cf0a0e 100644 (file)
@@ -690,8 +690,8 @@ double SD_task_get_execution_time(SD_task_t task, int host_count, const sg_host_
     if (bytes_amount != nullptr)
       for (int j = 0; j < host_count; j++)
         if (bytes_amount[i * host_count + j] != 0)
     if (bytes_amount != nullptr)
       for (int j = 0; j < host_count; j++)
         if (bytes_amount[i * host_count + j] != 0)
-          time += (SD_route_get_latency(host_list[i], host_list[j]) +
-                   bytes_amount[i * host_count + j] / SD_route_get_bandwidth(host_list[i], host_list[j]));
+          time += (sg_host_route_latency(host_list[i], host_list[j]) +
+                   bytes_amount[i * host_count + j] / sg_host_route_bandwidth(host_list[i], host_list[j]));
 
     if (time > max_time)
       max_time = time;
 
     if (time > max_time)
       max_time = time;
diff --git a/src/simdag/sd_workstation.cpp b/src/simdag/sd_workstation.cpp
deleted file mode 100644 (file)
index 5601bee..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-/* Copyright (c) 2006-2016. The SimGrid Team.
- * All rights reserved.                                                     */
-
-/* This program is free software; you can redistribute it and/or modify it
- * under the terms of the license (GNU LGPL) which comes with this package. */
-
-#include "simgrid/s4u/host.hpp"
-
-#include "simdag_private.hpp"
-#include "src/surf/HostImpl.hpp"
-#include "surf/surf.h"
-
-/** @brief Returns the route between two workstations
- *
- * Use SD_route_get_size() to know the array size.
- *
- * \param src a host
- * \param dst another host
- * \return an array of the \ref SD_link_t composing the route
- * \see SD_route_get_size(), SD_link_t
- */
-SD_link_t *SD_route_get_list(sg_host_t src, sg_host_t dst)
-{
-  std::vector<Link*> route;
-  src->routeTo(dst, &route, nullptr);
-
-  int cpt=0;
-  SD_link_t* list = xbt_new(SD_link_t, route.size());
-  for (const auto& link : route) {
-    list[cpt] = link;
-    cpt++;
-  }
-  return list;
-}
-
-/**
- * \brief Returns the number of links on the route between two workstations
- *
- * \param src a workstation
- * \param dst another workstation
- * \return the number of links on the route between these two workstations
- * \see SD_route_get_list()
- */
-int SD_route_get_size(sg_host_t src, sg_host_t dst)
-{
-  std::vector<Link*> route;
-  src->routeTo(dst, &route, nullptr);
-  int size = route.size();
-  return size;
-}
-
-/**
- * \brief Returns the latency of the route between two workstations.
- *
- * \param src the first workstation
- * \param dst the second workstation
- * \return the latency of the route between the two workstations (in seconds)
- * \see SD_route_get_bandwidth()
- */
-double SD_route_get_latency(sg_host_t src, sg_host_t dst)
-{
-  double latency = 0;
-  std::vector<Link*> route;
-  src->routeTo(dst, &route, &latency);
-
-  return latency;
-}
-
-/**
- * \brief Returns the bandwidth of the route between two workstations,
- * i.e. the minimum link bandwidth of all between the workstations.
- *
- * \param src the first workstation
- * \param dst the second workstation
- * \return the bandwidth of the route between the two workstations (in bytes/second)
- * \see SD_route_get_latency()
- */
-double SD_route_get_bandwidth(sg_host_t src, sg_host_t dst)
-{
-  double min_bandwidth = -1.0;
-
-  std::vector<Link*> route;
-  src->routeTo(dst, &route, nullptr);
-
-  for (const auto& link : route) {
-    double bandwidth = sg_link_bandwidth(link);
-    if (bandwidth < min_bandwidth || min_bandwidth < 0.0)
-      min_bandwidth = bandwidth;
-  }
-
-  return min_bandwidth;
-}
index f3c7b0b..5ab8cdc 100644 (file)
@@ -226,12 +226,16 @@ double sg_host_route_latency(sg_host_t from, sg_host_t to)
  */
 double sg_host_route_bandwidth(sg_host_t from, sg_host_t to)
 {
  */
 double sg_host_route_bandwidth(sg_host_t from, sg_host_t to)
 {
+  double min_bandwidth = -1.0;
+
   std::vector<simgrid::s4u::Link*> vlinks;
   from->routeTo(to, &vlinks, nullptr);
   std::vector<simgrid::s4u::Link*> vlinks;
   from->routeTo(to, &vlinks, nullptr);
-  double res = 0;
-  for (auto link : vlinks)
-    res += link->bandwidth();
-  return res;
+  for (auto link : vlinks) {
+    double bandwidth = link->bandwidth();
+    if (bandwidth < min_bandwidth || min_bandwidth < 0.0)
+      min_bandwidth = bandwidth;
+  }
+  return min_bandwidth;
 }
 
 /** @brief Displays debugging information about a host */
 }
 
 /** @brief Displays debugging information about a host */
index 5a3e621..e8a056c 100644 (file)
@@ -24,15 +24,17 @@ int main(int argc, char **argv)
       const char *name2 = sg_host_get_name(h2);
 
       fprintf(stderr, "Route between %s and %s\n", name1, name2);
       const char *name2 = sg_host_get_name(h2);
 
       fprintf(stderr, "Route between %s and %s\n", name1, name2);
-      SD_link_t *route = SD_route_get_list(h1, h2);
-      int route_size = SD_route_get_size(h1, h2);
-      fprintf(stderr, "Route size %d\n", route_size);
-      for (int i = 0; i < route_size; i++)
-        fprintf(stderr, "  Link %s: latency = %f, bandwidth = %f\n", sg_link_name(route[i]),
-               sg_link_latency(route[i]), sg_link_bandwidth(route[i]));
+      xbt_dynar_t route = xbt_dynar_new(sizeof(SD_link_t), NULL);
+      sg_host_route(h1, h2, route);
+      fprintf(stderr, "Route size %lu\n", xbt_dynar_length(route));
+      unsigned int i;
+      SD_link_t link;
+      xbt_dynar_foreach(route, i, link)
+        fprintf(stderr, "  Link %s: latency = %f, bandwidth = %f\n", sg_link_name(link),
+               sg_link_latency(link), sg_link_bandwidth(link));
       fprintf(stderr, "Route latency = %f, route bandwidth = %f\n",
       fprintf(stderr, "Route latency = %f, route bandwidth = %f\n",
-             SD_route_get_latency(h1, h2), SD_route_get_bandwidth(h1, h2));
-      xbt_free(route);
+             sg_host_route_latency(h1, h2), sg_host_route_bandwidth(h1, h2));
+      xbt_dynar_free_container(&route);
     }
     if (!strcmp(argv[2], "FULL_LINK")) {
       int list_size = sg_host_count();
     }
     if (!strcmp(argv[2], "FULL_LINK")) {
       int list_size = sg_host_count();
@@ -43,16 +45,17 @@ int main(int argc, char **argv)
           sg_host_t h2 = hosts[j];
           const char *name2 = sg_host_get_name(h2);
           fprintf(stderr, "Route between %s and %s\n", name1, name2);
           sg_host_t h2 = hosts[j];
           const char *name2 = sg_host_get_name(h2);
           fprintf(stderr, "Route between %s and %s\n", name1, name2);
-          SD_link_t *route = SD_route_get_list(h1, h2);
-          int route_size = SD_route_get_size(h1, h2);
-          fprintf(stderr, "  Route size %d\n", route_size);
-          for (int k = 0; k < route_size; k++) {
+          xbt_dynar_t route = xbt_dynar_new(sizeof(SD_link_t), NULL);
+          sg_host_route(h1, h2, route);
+          fprintf(stderr, "  Route size %lu\n", xbt_dynar_length(route));
+          unsigned int k;
+          SD_link_t link;
+          xbt_dynar_foreach(route, k, link)
             fprintf(stderr, "  Link %s: latency = %f, bandwidth = %f\n",
             fprintf(stderr, "  Link %s: latency = %f, bandwidth = %f\n",
-                sg_link_name(route[k]), sg_link_latency(route[k]), sg_link_bandwidth(route[k]));
-          }
+                sg_link_name(link), sg_link_latency(link), sg_link_bandwidth(link));
           fprintf(stderr, "  Route latency = %f, route bandwidth = %f\n",
           fprintf(stderr, "  Route latency = %f, route bandwidth = %f\n",
-                 SD_route_get_latency(h1, h2), SD_route_get_bandwidth(h1, h2));
-          xbt_free(route);
+                 sg_host_route_latency(h1, h2), sg_host_route_bandwidth(h1, h2));
+          xbt_dynar_free_container(&route);
         }
       }
     }
         }
       }
     }
index bb81c1c..ea122f3 100644 (file)
@@ -35,11 +35,14 @@ int main(int argc, char **argv)
   sg_host_t h1 = hosts[i];
   sg_host_t h2 = hosts[j];
   printf("%d\tand\t%d\t\t",i,j);
   sg_host_t h1 = hosts[i];
   sg_host_t h2 = hosts[j];
   printf("%d\tand\t%d\t\t",i,j);
+  xbt_dynar_t route = xbt_dynar_new(sizeof(SD_link_t), NULL);
 
   xbt_os_cputimer_start(timer);
 
   xbt_os_cputimer_start(timer);
-  SD_route_get_list(h1, h2);
+  sg_host_route(h1, h2, route);
   xbt_os_cputimer_stop(timer);
 
   xbt_os_cputimer_stop(timer);
 
+  xbt_dynar_free(&route);
+
   printf("%f\n", xbt_os_timer_elapsed(timer) );
 
   xbt_free(hosts);
   printf("%f\n", xbt_os_timer_elapsed(timer) );
 
   xbt_free(hosts);
index 28f94dd..e90c9ef 100644 (file)
@@ -432,7 +432,6 @@ set(SIMDAG_SRC
   src/simdag/sd_dotloader.cpp
   src/simdag/sd_global.cpp
   src/simdag/sd_task.cpp
   src/simdag/sd_dotloader.cpp
   src/simdag/sd_global.cpp
   src/simdag/sd_task.cpp
-  src/simdag/sd_workstation.cpp
   )
 
 set(BINDINGS_SRC
   )
 
 set(BINDINGS_SRC