Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Start the SimDag revolution: function factoring
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 19 Jan 2016 13:56:15 +0000 (14:56 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 19 Jan 2016 14:05:35 +0000 (15:05 +0100)
    + SD_link_get_ -> sg_link_
       for count/bandwidth/latency/name/data
    + SD_link_set_data -> sg_link_data_set
    + SD_link_is_shared -> sg_link_is_shared

examples/simdag/metaxml/sd_meta.c
examples/simdag/sd_test.c
include/simgrid/simdag.h
src/simdag/sd_global.cpp
src/simdag/sd_workstation.cpp
teshsuite/simdag/platforms/Evaluate_parse_time.c
teshsuite/simdag/platforms/basic_link_test.c
teshsuite/simdag/platforms/basic_parsing_test.c
teshsuite/simdag/platforms/flatifier.cpp
teshsuite/simdag/platforms/is_router_test.c

index 34f7d2e..170a265 100644 (file)
@@ -65,9 +65,9 @@ int main(int argc, char **argv)
       route_size = SD_route_get_size(w1, w2);
       for (k = 0; k < route_size; k++) {
         XBT_INFO("\tLink %s: latency = %f, bandwidth = %f",
       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_latency(route[k]),
-              SD_link_get_bandwidth(route[k]));
+              sg_link_name(route[k]),
+              sg_link_latency(route[k]),
+              sg_link_bandwidth(route[k]));
       }
     }
   }
       }
     }
   }
index ce59643..20f6c47 100644 (file)
@@ -75,9 +75,9 @@ int main(int argc, char **argv)
   route_size = SD_route_get_size(w1, w2);
   for (i = 0; i < route_size; i++) {
     XBT_INFO("   Link %s: latency = %f, bandwidth = %f",
   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_latency(route[i]),
-          SD_link_get_bandwidth(route[i]));
+          sg_link_name(route[i]),
+          sg_link_latency(route[i]),
+          sg_link_bandwidth(route[i]));
   }
   XBT_INFO("Route latency = %f, route bandwidth = %f",
         SD_route_get_latency(w1, w2),
   }
   XBT_INFO("Route latency = %f, route bandwidth = %f",
         SD_route_get_latency(w1, w2),
index 0dfb6d5..fe649ed 100644 (file)
@@ -67,7 +67,7 @@ typedef struct SD_task *SD_task_t;
     @see SD_task_management */
 typedef enum {
   SD_NOT_SCHEDULED = 0,      /**< @brief Initial state (not valid for SD_watch and SD_unwatch). */
     @see SD_task_management */
 typedef enum {
   SD_NOT_SCHEDULED = 0,      /**< @brief Initial state (not valid for SD_watch and SD_unwatch). */
-  SD_SCHEDULABLE = 0x0001,               /**< @brief A task becomes SD_SCHEDULABLE as soon as its dependencies are satisfied */
+  SD_SCHEDULABLE = 0x0001,   /**< @brief A task becomes SD_SCHEDULABLE as soon as its dependencies are satisfied */
   SD_SCHEDULED = 0x0002,     /**< @brief A task becomes SD_SCHEDULED when you call function
                                   SD_task_schedule. SD_simulate will execute it when it becomes SD_RUNNABLE. */
   SD_RUNNABLE = 0x0004,      /**< @brief A scheduled task becomes runnable is SD_simulate as soon as its dependencies are satisfied. */
   SD_SCHEDULED = 0x0002,     /**< @brief A task becomes SD_SCHEDULED when you call function
                                   SD_task_schedule. SD_simulate will execute it when it becomes SD_RUNNABLE. */
   SD_RUNNABLE = 0x0004,      /**< @brief A scheduled task becomes runnable is SD_simulate as soon as its dependencies are satisfied. */
@@ -112,42 +112,7 @@ typedef xbt_dictelm_t SD_storage_t;
  *  @{
  */
 XBT_PUBLIC(const SD_link_t *) SD_link_get_list(void);
  *  @{
  */
 XBT_PUBLIC(const SD_link_t *) SD_link_get_list(void);
-/** @brief Returns the number of links in the whole platform */
-static inline int SD_link_get_count(void) {
-  return sg_link_count();
-}
 
 
-/** @brief Returns the user data of a link */
-static inline void *SD_link_get_data(SD_link_t link) {
-  return sg_link_data(link);
-}
-
-/** @brief Sets the user data of a link
- *
- * The new data can be \c NULL. The old data should have been freed first
- * if it was not \c NULL.
- */
-static inline void SD_link_set_data(SD_link_t link, void *data) {
-       sg_link_data_set(link, data);
-}
-/** @brief Returns the name of a link  */
-static inline const char *SD_link_get_name(SD_link_t link) {
-  return sg_link_name(link);
-}
-/** @brief Returns the current bandwidth of a link (in bytes per second) */
-static inline double SD_link_get_bandwidth(SD_link_t link) {
-  return sg_link_bandwidth(link);
-}
-/** @brief Returns the current latency of a link (in seconds) */
-static inline double SD_link_get_latency(SD_link_t link){
-  return sg_link_latency(link);
-}
-/** @brief Returns the sharing policy of this workstation.
- *  @return true if the link is shared, and false if it's a fatpipe
- */
-static inline int SD_link_is_shared(SD_link_t link) {
-  return sg_link_is_shared(link);
-}
 /** @} */
 
 /************************** Workstation handling ****************************/
 /** @} */
 
 /************************** Workstation handling ****************************/
index f83e9a0..0eb1691 100644 (file)
@@ -187,7 +187,7 @@ void SD_create_environment(const char *platform_file)
 
 
   XBT_DEBUG("Workstation number: %d, link number: %d",
 
 
   XBT_DEBUG("Workstation number: %d, link number: %d",
-         SD_workstation_get_count(), SD_link_get_count());
+         SD_workstation_get_count(), sg_link_count());
 #ifdef HAVE_JEDULE
   jedule_setup_platform();
 #endif
 #ifdef HAVE_JEDULE
   jedule_setup_platform();
 #endif
index 06eb2bd..f959d3e 100644 (file)
@@ -222,7 +222,7 @@ const SD_link_t *SD_route_get_list(SD_workstation_t src,
 
   if (sd_global->recyclable_route == NULL) {
     /* first run */
 
   if (sd_global->recyclable_route == NULL) {
     /* first run */
-    sd_global->recyclable_route = xbt_new(SD_link_t, SD_link_get_count());
+    sd_global->recyclable_route = xbt_new(SD_link_t, sg_link_count());
   }
 
   surf_route = surf_host_model_get_route((surf_host_model_t)surf_host_model, src, dst);
   }
 
   surf_route = surf_host_model_get_route((surf_host_model_t)surf_host_model, src, dst);
@@ -338,7 +338,7 @@ double SD_route_get_bandwidth(SD_workstation_t src, SD_workstation_t dst)
   min_bandwidth = -1.0;
 
   for (i = 0; i < nb_links; i++) {
   min_bandwidth = -1.0;
 
   for (i = 0; i < nb_links; i++) {
-    bandwidth = SD_link_get_bandwidth(links[i]);
+    bandwidth = sg_link_bandwidth(links[i]);
     if (bandwidth < min_bandwidth || min_bandwidth == -1.0)
       min_bandwidth = bandwidth;
   }
     if (bandwidth < min_bandwidth || min_bandwidth == -1.0)
       min_bandwidth = bandwidth;
   }
@@ -386,7 +386,7 @@ double SD_route_get_communication_time(SD_workstation_t src,
   min_bandwidth = -1.0;
 
   for (i = 0; i < nb_links; i++) {
   min_bandwidth = -1.0;
 
   for (i = 0; i < nb_links; i++) {
-    bandwidth = SD_link_get_bandwidth(links[i]);
+    bandwidth = sg_link_bandwidth(links[i]);
     if (bandwidth < min_bandwidth || min_bandwidth == -1.0)
       min_bandwidth = bandwidth;
   }
     if (bandwidth < min_bandwidth || min_bandwidth == -1.0)
       min_bandwidth = bandwidth;
   }
index 3256886..0a96873 100644 (file)
@@ -29,7 +29,7 @@ int main(int argc, char **argv)
   /* Display the result and exit after cleanup */
   printf( "%f\n", xbt_os_timer_elapsed(timer) );
     printf("Workstation number: %d, link number: %d\n",
   /* Display the result and exit after cleanup */
   printf( "%f\n", xbt_os_timer_elapsed(timer) );
     printf("Workstation number: %d, link number: %d\n",
-           SD_workstation_get_count(), SD_link_get_count());
+           SD_workstation_get_count(), sg_link_count());
   if(argv[2]){
     printf("Wait for %ss\n",argv[2]);
     sleep(atoi(argv[2]));
   if(argv[2]){
     printf("Wait for %ss\n",argv[2]);
     sleep(atoi(argv[2]));
index 2493e63..67e2b42 100644 (file)
@@ -13,8 +13,8 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(basic_link_test, sd,
                                 "SimDag test basic_link_test");
 
 static int cmp_link(const void*a, const void*b) {
                                 "SimDag test basic_link_test");
 
 static int cmp_link(const void*a, const void*b) {
-       const char *nameA = SD_link_get_name(*(SD_link_t*)a);
-       const char *nameB = SD_link_get_name(*(SD_link_t*)b);
+       const char *nameA = sg_link_name(*(SD_link_t*)a);
+       const char *nameB = sg_link_name(*(SD_link_t*)b);
   return strcmp( nameA, nameB );
 }
 
   return strcmp( nameA, nameB );
 }
 
@@ -30,17 +30,17 @@ int main(int argc, char **argv)
   /* creation of the environment */
   SD_create_environment(argv[1]);
   links = SD_link_get_list();
   /* creation of the environment */
   SD_create_environment(argv[1]);
   links = SD_link_get_list();
-  int count = SD_link_get_count();
+  int count = sg_link_count();
   XBT_INFO("Link count: %d", count);
   qsort((void *)links, count, sizeof(SD_link_t), cmp_link);
    
   for(i=0; i < count; i++){
     XBT_INFO("%s: latency = %.5f, bandwidth = %f",
   XBT_INFO("Link count: %d", count);
   qsort((void *)links, count, sizeof(SD_link_t), cmp_link);
    
   for(i=0; i < count; i++){
     XBT_INFO("%s: latency = %.5f, bandwidth = %f",
-             SD_link_get_name(links[i]),
-             SD_link_get_latency(links[i]),
-             SD_link_get_bandwidth(links[i]));
-    SD_link_set_data(links[i], (void*) user_data);
-    if(strcmp(user_data, (const char*)SD_link_get_data(links[i]))){
+             sg_link_name(links[i]),
+             sg_link_latency(links[i]),
+             sg_link_bandwidth(links[i]));
+    sg_link_data_set(links[i], (void*) user_data);
+    if(strcmp(user_data, (const char*)sg_link_data(links[i]))){
       XBT_ERROR("User data was corrupted.");
     }
   }
       XBT_ERROR("User data was corrupted.");
     }
   }
index 9f6b022..8998c09 100644 (file)
@@ -32,7 +32,7 @@ int main(int argc, char **argv)
   /* creation of the environment */
   SD_create_environment(argv[1]);
   printf("Workstation number: %d, link number: %d\n",
   /* creation of the environment */
   SD_create_environment(argv[1]);
   printf("Workstation number: %d, link number: %d\n",
-         SD_workstation_get_count(), SD_link_get_count());
+         SD_workstation_get_count(), sg_link_count());
 
   if (argc >= 3) {
     if (!strcmp(argv[2], "ONE_LINK")) {
 
   if (argc >= 3) {
     if (!strcmp(argv[2], "ONE_LINK")) {
@@ -48,9 +48,9 @@ int main(int argc, char **argv)
       printf("Route size %d\n", route_size);
       for (i = 0; i < route_size; i++) {
       printf("  Link %s: latency = %f, bandwidth = %f\n",
       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_latency(route[i]),
-           SD_link_get_bandwidth(route[i]));
+           sg_link_name(route[i]),
+           sg_link_latency(route[i]),
+           sg_link_bandwidth(route[i]));
       }
       printf("Route latency = %f, route bandwidth = %f\n",
          SD_route_get_latency(w1, w2),
       }
       printf("Route latency = %f, route bandwidth = %f\n",
          SD_route_get_latency(w1, w2),
@@ -71,9 +71,9 @@ int main(int argc, char **argv)
         printf("  Route size %d\n", route_size);
         for (k = 0; k < route_size; k++) {
         printf("  Link %s: latency = %f, bandwidth = %f\n",
         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_latency(route[k]),
-             SD_link_get_bandwidth(route[k]));
+             sg_link_name(route[k]),
+             sg_link_latency(route[k]),
+             sg_link_bandwidth(route[k]));
         }
         printf("  Route latency = %f, route bandwidth = %f\n",
            SD_route_get_latency(w1, w2),
         }
         printf("  Route latency = %f, route bandwidth = %f\n",
            SD_route_get_latency(w1, w2),
index 34c2888..9e5bb84 100644 (file)
@@ -41,8 +41,8 @@ static int name_compare_hosts(const void *n1, const void *n2)
 static int name_compare_links(const void *n1, const void *n2)
 {
   char name1[80], name2[80];
 static int name_compare_links(const void *n1, const void *n2)
 {
   char name1[80], name2[80];
-  strcpy(name1, SD_link_get_name(*((SD_link_t *) n1)));
-  strcpy(name2, SD_link_get_name(*((SD_link_t *) n2)));
+  strcpy(name1, sg_link_name(*((SD_link_t *) n1)));
+  strcpy(name2, sg_link_name(*((SD_link_t *) n2)));
 
   return strcmp(name1, name2);
 }
 
   return strcmp(name1, name2);
 }
@@ -129,7 +129,7 @@ int main(int argc, char **argv)
   if (timings) {
     XBT_INFO("Parsing time: %fs (%d hosts, %d links)",
           xbt_os_timer_elapsed(parse_time),SD_workstation_get_count(),
   if (timings) {
     XBT_INFO("Parsing time: %fs (%d hosts, %d links)",
           xbt_os_timer_elapsed(parse_time),SD_workstation_get_count(),
-          SD_link_get_count());
+          sg_link_count());
   } else {
     printf("<?xml version='1.0'?>\n");
     printf("<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid.dtd\">\n");
   } else {
     printf("<?xml version='1.0'?>\n");
     printf("<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid.dtd\">\n");
@@ -172,7 +172,7 @@ int main(int argc, char **argv)
     }
 
     // Links
     }
 
     // Links
-    totalLinks = SD_link_get_count();
+    totalLinks = sg_link_count();
     links = SD_link_get_list();
 
     qsort((void *) links, totalLinks, sizeof(SD_link_t), name_compare_links);
     links = SD_link_get_list();
 
     qsort((void *) links, totalLinks, sizeof(SD_link_t), name_compare_links);
@@ -181,10 +181,10 @@ int main(int argc, char **argv)
       printf("  <link id=\"");
 
       printf("%s\" bandwidth=\"%.0f\" latency=\"%.9f\"",
       printf("  <link id=\"");
 
       printf("%s\" bandwidth=\"%.0f\" latency=\"%.9f\"",
-          SD_link_get_name(links[i]),
-          SD_link_get_bandwidth(links[i]),
-          SD_link_get_latency(links[i]));
-      if (SD_link_is_shared(links[i])) {
+          sg_link_name(links[i]),
+          sg_link_bandwidth(links[i]),
+          sg_link_latency(links[i]));
+      if (sg_link_is_shared(links[i])) {
         printf("/>\n");
       } else {
         printf(" sharing_policy=\"FATPIPE\"/>\n");
         printf("/>\n");
       } else {
         printf(" sharing_policy=\"FATPIPE\"/>\n");
index f6abd93..5014b76 100644 (file)
@@ -30,7 +30,7 @@ int main(int argc, char **argv)
   size = xbt_dict_length(host_list) + xbt_lib_length(as_router_lib);
 
   printf("Workstation number: %d, link number: %d, elmts number: %d\n",
   size = xbt_dict_length(host_list) + xbt_lib_length(as_router_lib);
 
   printf("Workstation number: %d, link number: %d, elmts number: %d\n",
-         SD_workstation_get_count(), SD_link_get_count(), size);
+         SD_workstation_get_count(), sg_link_count(), size);
 
   xbt_dict_foreach(host_list, cursor, key, data) {
     printf("   - Seen: \"%s\" is type : %d\n", key,
 
   xbt_dict_foreach(host_list, cursor, key, data) {
     printf("   - Seen: \"%s\" is type : %d\n", key,