Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
kill old cruft
[simgrid.git] / teshsuite / simdag / platforms / flatifier.cpp
index 408876f..ccda631 100644 (file)
@@ -14,7 +14,7 @@
 #include <string.h>
 #include <math.h>
 
-
+#include "src/surf/network_interface.hpp"
 #include "simgrid/simdag.h"
 #include "xbt/log.h"
 #include "xbt/dict.h"
@@ -31,20 +31,18 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(flatifier,
 
 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);
+  return strcmp(
+      sg_host_get_name(*(sg_host_t *) n1),
+      sg_host_get_name(*(sg_host_t *) n2)
+  );
 }
 
 static int name_compare_links(const void *n1, const void *n2)
 {
-  char name1[80], name2[80];
-  strcpy(name1, sg_link_name(*((SD_link_t *) n1)));
-  strcpy(name2, sg_link_name(*((SD_link_t *) n2)));
-
-  return strcmp(name1, name2);
+  return strcmp(
+      sg_link_name(*(SD_link_t *) n1),
+      sg_link_name(*(SD_link_t *) n2)
+  );
 }
 
 static int parse_cmdline(int *timings, int *downgrade, char **platformFile, int argc, char **argv)
@@ -100,17 +98,10 @@ int main(int argc, char **argv)
   sg_netcard_t value1;
   sg_netcard_t value2;
 
-  const SD_workstation_t *hosts;
+  const sg_host_t *hosts;
   const SD_link_t *links;
   xbt_os_timer_t parse_time = xbt_os_timer_new();
 
-#ifdef _XBT_WIN32
-  setbuf(stderr, NULL);
-  setbuf(stdout, NULL);
-#else
-  setvbuf(stdout, NULL, _IOLBF, 0);
-#endif
-
   SD_init(&argc, argv);
 
   if (parse_cmdline(&timings, &downgrade, &platformFile, argc, argv) || !platformFile) {
@@ -127,8 +118,8 @@ int main(int argc, char **argv)
   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_count(),
+    XBT_INFO("Parsing time: %fs (%zu hosts, %d links)",
+          xbt_os_timer_elapsed(parse_time),sg_host_count(),
           sg_link_count());
   } else {
     printf("<?xml version='1.0'?>\n");
@@ -138,18 +129,18 @@ int main(int argc, char **argv)
       printf("<AS id=\"AS0\" routing=\"Full\">\n");
 
     // Hosts
-    totalHosts = SD_workstation_get_count();
-    hosts = SD_workstation_get_list();
-    qsort((void *) hosts, totalHosts, sizeof(SD_workstation_t),
+    totalHosts = sg_host_count();
+    hosts = sg_host_list();
+    qsort((void *) hosts, totalHosts, sizeof(sg_host_t),
         name_compare_hosts);
 
     for (i = 0; i < totalHosts; i++) {
       printf("  <host id=\"%s\" power=\"%.0f\"",
-          SD_workstation_get_name(hosts[i]),
-          SD_workstation_get_speed(hosts[i]));
-      props = SD_workstation_get_properties(hosts[i]);
-      if (SD_workstation_get_cores(hosts[i])>1) {
-        printf(" core=\"%d\"", SD_workstation_get_cores(hosts[i]));
+          sg_host_get_name(hosts[i]),
+          sg_host_speed(hosts[i]));
+      props = sg_host_get_properties(hosts[i]);
+      if (sg_host_core_count(hosts[i])>1) {
+        printf(" core=\"%d\"", sg_host_core_count(hosts[i]));
       }
       if (props && !xbt_dict_is_empty(props)) {
         printf(">\n");
@@ -173,7 +164,7 @@ int main(int argc, char **argv)
 
     // Links
     totalLinks = sg_link_count();
-    links = SD_link_get_list();
+    links = sg_link_list();
 
     qsort((void *) links, totalLinks, sizeof(SD_link_t), name_compare_links);
 
@@ -202,7 +193,7 @@ int main(int argc, char **argv)
             ,dst);
         xbt_dynar_t route=NULL;
         value2 = sg_host_by_name(dst)->pimpl_netcard;
-        routing_get_route_and_latency(value1, value2, &route,NULL);
+        routing_platf->getRouteAndLatency(value1, value2, &route,NULL);
         for(i=0;i<xbt_dynar_length(route) ;i++)
         {
           void *link = xbt_dynar_get_as(route,i,void *);
@@ -221,7 +212,7 @@ int main(int argc, char **argv)
               ,dst);
           xbt_dynar_t route=NULL;
           value2 = (sg_netcard_t)xbt_lib_get_or_null(as_router_lib,dst,ROUTING_ASR_LEVEL);
-          routing_get_route_and_latency((sg_netcard_t)value1,(sg_netcard_t)value2,&route,NULL);
+          routing_platf->getRouteAndLatency((sg_netcard_t)value1,(sg_netcard_t)value2,&route,NULL);
           for(i=0;i<xbt_dynar_length(route) ;i++)
           {
             void *link = xbt_dynar_get_as(route,i,void *);
@@ -247,7 +238,7 @@ int main(int argc, char **argv)
                 ,dst);
             xbt_dynar_t route=NULL;
             value2 = (sg_netcard_t)xbt_lib_get_or_null(as_router_lib,dst,ROUTING_ASR_LEVEL);
-            routing_get_route_and_latency((sg_netcard_t)value1,(sg_netcard_t)value2,&route,NULL);
+            routing_platf->getRouteAndLatency((sg_netcard_t)value1,(sg_netcard_t)value2,&route,NULL);
             for(i=0;i<xbt_dynar_length(route) ;i++)
             {
               void *link = xbt_dynar_get_as(route,i,void *);
@@ -265,7 +256,7 @@ int main(int argc, char **argv)
               ,src, dst);
           xbt_dynar_t route=NULL;
           value2 = sg_host_by_name(dst)->pimpl_netcard;
-          routing_get_route_and_latency((sg_netcard_t)value1,(sg_netcard_t)value2,&route, NULL);
+          routing_platf->getRouteAndLatency((sg_netcard_t)value1,(sg_netcard_t)value2,&route, NULL);
           for(i=0;i<xbt_dynar_length(route) ;i++)
           {
             void *link = xbt_dynar_get_as(route,i,void *);