Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot//simgrid/simgrid
authorMarion Guthmuller <marion.guthmuller@loria.fr>
Tue, 21 Feb 2012 14:05:42 +0000 (15:05 +0100)
committerMarion Guthmuller <marion.guthmuller@loria.fr>
Tue, 21 Feb 2012 14:05:42 +0000 (15:05 +0100)
buildtools/Cmake/DefinePackages.cmake
examples/platforms/generation_scripts/create_hierarchical_clusters.pl
src/include/surf/surf.h
src/simix/smx_io.c
src/surf/storage.c [new file with mode: 0644]
src/surf/surf_routing_full.c
src/surf/surf_routing_generic.c
src/surf/workstation.c

index 2d5507d..73dd6ac 100644 (file)
@@ -244,6 +244,7 @@ set(SURF_SRC
        src/surf/cpu_ti.c
        src/surf/cpu_cas01.c
        src/surf/sg_platf.c
+       src/surf/storage.c
        src/xbt/xbt_sg_stubs.c
 )
 
index 5ddfe9c..2378e7e 100755 (executable)
@@ -69,11 +69,11 @@ if ( $height->bcmp(Math::BigInt->new("1")) != 0 && ($height->copy()->bpow($d))->
        $height++; #will have to deal with empty set of clusters.       
        }
 # debug stuff  
-#print "Computed : \n";
-#print STDERR "height: " . $height . "\n";
-#print STDERR "totalnumberofhosts: " . $totalnumberofhosts . "\n";
-#print STDERR "totalnumberofcluster: " .  $totalnumberofCluster . "\n";
-#print STDERR "last cluster size (if equals to cluster size, then all clusters will be homogeneous) : " . $last . "\n";
+# print "Computed : \n";
+# print STDERR "height: " . $height . "\n";
+# print STDERR "totalnumberofhosts: " . $totalnumberofhosts . "\n";
+# print STDERR "totalnumberofcluster: " .  $totalnumberofCluster . "\n";
+# print STDERR "last cluster size (if equals to cluster size, then all clusters will be homogeneous) : " . $last . "\n";
 
 # Counter for giving unique IDs to ASes.
 $ASnumber;
@@ -82,7 +82,7 @@ $ASnumber = 0;
 # Printing preamble
 print "<?xml version='1.0'?>\n";
 print "<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid.dtd\">\n";
-print "<platform version=\"3\">\n";
+print "<platform version=\"3\">\n\n";
 
        
 # Initiate recursion ...
@@ -91,6 +91,7 @@ print "<platform version=\"3\">\n";
 # Closing tag, and then back home
 print "</platform>\n"; 
 
+
 # Recursive stuff for depth first Se... Creation
 sub DF_creation {
        my($currDepth) = @_;
@@ -105,7 +106,7 @@ sub DF_creation {
        # Saving my current number to return it to my father
        my $toReturn = $ASnumber;
        $ASnumber++;
-       if ($currDepth<$height && $totalnumberofCluster > 0)
+       if ($currDepth<=$height && $totalnumberofCluster > 0)
                {               
                # Creating current AS inner stuff
                # I should have a table of sons numbers.
index 7b40a75..aff8a88 100644 (file)
@@ -193,6 +193,28 @@ typedef struct surf_network_model_extension_public {
                            xbt_dict_t properties);
 } s_surf_model_extension_network_t;
 
+typedef struct s_surf_file {
+  char *name;                   /**< @brief host name if any */
+  void *data;                   /**< @brief user data */
+} s_surf_file_t;
+typedef struct s_surf_file *surf_file_t;
+
+/* Storage model */
+
+/** \brief Storage model extension public
+ *  \ingroup SURF_models
+ *
+ *  Public functions specific to the Storage model.
+ */
+typedef struct surf_storage_model_extension_public {
+  surf_action_t(*open) (void *workstation, const char* path, const char* mode);
+  surf_action_t(*close) (void *workstation, surf_file_t fp);
+  surf_action_t(*read) (void *workstation, void* ptr, size_t size, size_t nmemb, surf_file_t stream);
+  surf_action_t(*write) (void *workstation, const void* ptr, size_t size, size_t nmemb, surf_file_t stream);
+  surf_action_t(*stat) (void *workstation, int fd, void* buf);
+void* (*create_resource) (const char *name);
+} s_surf_model_extension_storage_t;
+
      /** \brief Workstation model extension public
       *  \ingroup SURF_models
       *
@@ -218,6 +240,11 @@ typedef struct surf_workstation_model_extension_public {
                                           double amount, double rate);
   double (*get_link_bandwidth) (const void *link);                                         /**< Return the current bandwidth of a network link */
   double (*get_link_latency) (const void *link);                                           /**< Return the current latency of a network link */
+  surf_action_t(*open) (void *workstation, const char* path, const char* mode);
+  surf_action_t(*close) (void *workstation, surf_file_t fp);
+  surf_action_t(*read) (void *workstation, void* ptr, size_t size, size_t nmemb, surf_file_t stream);
+  surf_action_t(*write) (void *workstation, const void* ptr, size_t size, size_t nmemb, surf_file_t stream);
+  surf_action_t(*stat) (void *workstation, int fd, void* buf);
   int (*link_shared) (const void *link);
    xbt_dict_t(*get_properties) (const void *resource);
   void* (*link_create_resource) (const char *name,
@@ -283,6 +310,7 @@ typedef struct surf_model {
   union extension {
     s_surf_model_extension_cpu_t cpu;
     s_surf_model_extension_network_t network;
+    s_surf_model_extension_storage_t storage;
     s_surf_model_extension_workstation_t workstation;
   } extension;
 } s_surf_model_t;
index a19b309..60fe284 100644 (file)
@@ -46,9 +46,7 @@ smx_action_t SIMIX_file_read(smx_process_t process, void* ptr, size_t size, size
 #endif
 
   action->io.host = host;
-  //  TODO in surf model disk???
-  //  action->io.surf_io = surf_workstation_model->extension.storage.read(host->host, name),
-  action->io.surf_io = surf_workstation_model->extension.workstation.sleep(host->host, 1.0);
+  action->io.surf_io = surf_workstation_model->extension.workstation.read(host->host, ptr, size, nmemb, (surf_file_t)stream),
 
   surf_workstation_model->action_data_set(action->io.surf_io, action);
   XBT_DEBUG("Create io action %p", action);
@@ -88,9 +86,7 @@ smx_action_t SIMIX_file_write(smx_process_t process, const void* ptr, size_t siz
 #endif
 
   action->io.host = host;
-  //  TODO in surf model disk???
-  //  action->io.surf_io = surf_workstation_model->extension.storage.write(host->host, name),
-  action->io.surf_io = surf_workstation_model->extension.workstation.sleep(host->host, 2.0);
+  action->io.surf_io = surf_workstation_model->extension.workstation.write(host->host, ptr, size, nmemb, (surf_file_t)stream);
 
   surf_workstation_model->action_data_set(action->io.surf_io, action);
   XBT_DEBUG("Create io action %p", action);
@@ -128,9 +124,7 @@ smx_action_t SIMIX_file_open(smx_process_t process, const char* path, const char
 #endif
 
   action->io.host = host;
-  //  TODO in surf model disk???
-  //  action->io.surf_io = surf_workstation_model->extension.storage.open(host->host, name),
-  action->io.surf_io = surf_workstation_model->extension.workstation.sleep(host->host, 3.0);
+  action->io.surf_io = surf_workstation_model->extension.workstation.open(host->host, path, mode);
 
   surf_workstation_model->action_data_set(action->io.surf_io, action);
   XBT_DEBUG("Create io action %p", action);
@@ -167,9 +161,7 @@ smx_action_t SIMIX_file_close(smx_process_t process, smx_file_t fp)
 #endif
 
   action->io.host = host;
-  //  TODO in surf model disk???
-  //  action->io.surf_io = surf_workstation_model->extension.storage.close(host->host, name),
-  action->io.surf_io = surf_workstation_model->extension.workstation.sleep(host->host, 4.0);
+  action->io.surf_io = surf_workstation_model->extension.workstation.close(host->host, (surf_file_t)fp);
 
   surf_workstation_model->action_data_set(action->io.surf_io, action);
   XBT_DEBUG("Create io action %p", action);
@@ -207,9 +199,7 @@ smx_action_t SIMIX_file_stat(smx_process_t process, int fd, void* buf)
 #endif
 
   action->io.host = host;
-  //  TODO in surf model disk???
-  //  action->io.surf_io = surf_workstation_model->extension.storage.stat(host->host, name),
-  action->io.surf_io = surf_workstation_model->extension.workstation.sleep(host->host, 5.0);
+  action->io.surf_io = surf_workstation_model->extension.workstation.stat(host->host, fd, buf);
 
   surf_workstation_model->action_data_set(action->io.surf_io, action);
   XBT_DEBUG("Create io action %p", action);
diff --git a/src/surf/storage.c b/src/surf/storage.c
new file mode 100644 (file)
index 0000000..c471d8f
--- /dev/null
@@ -0,0 +1,54 @@
+/* Copyright (c) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012. 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 "xbt/ex.h"
+#include "xbt/dict.h"
+#include "portable.h"
+#include "surf_private.h"
+#include "surf/surf_resource.h"
+
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_storage, surf,
+                                "Logging specific to the SURF storage module");
+
+surf_model_t surf_storage_model = NULL;
+
+static surf_action_t storage_action_open(void *workstation, const char* path, const char* mode)
+{
+  return NULL;
+}
+
+static surf_action_t storage_action_close(void *workstation, surf_file_t fp)
+{
+  return NULL;
+}
+
+static surf_action_t storage_action_read(void *workstation, void* ptr, size_t size, size_t nmemb, surf_file_t stream)
+{
+  return NULL;
+}
+
+static surf_action_t storage_action_write(void *workstation, const void* ptr, size_t size, size_t nmemb, surf_file_t stream)
+{
+  return NULL;
+}
+
+static surf_action_t storage_action_stat(void *workstation, int fd, void* buf)
+{
+  return NULL;
+}
+
+static void surf_storage_model_init_internal(void)
+{
+  surf_storage_model = surf_model_init();
+
+  surf_storage_model->name = "Storage";
+
+  surf_storage_model->extension.workstation.open = storage_action_open;
+  surf_storage_model->extension.workstation.close = storage_action_close;
+  surf_storage_model->extension.workstation.read = storage_action_read;
+  surf_storage_model->extension.workstation.write = storage_action_write;
+  surf_storage_model->extension.workstation.stat = storage_action_stat;
+}
index 59fe6de..c4a4c9f 100644 (file)
@@ -202,31 +202,32 @@ void model_full_set_route(AS_t rc, const char *src,
     if (!route->dst_gateway && !route->src_gateway)
       XBT_DEBUG("Load Route from \"%s\" to \"%s\"", src, dst);
     else {
-      AS_t subas = xbt_dict_get_or_null(rc->routing_sons, src);
-      if (subas == NULL)
-        surf_parse_error("The source of an ASroute must be a sub-AS "
-                         "declared within the current AS, "
-                         "but '%s' is not an AS within '%s'", src, rc->name);
-      if (subas->to_index
-          && xbt_dict_get_or_null(subas->to_index, route->src_gateway) == NULL)
-        surf_parse_error("In an ASroute, source gateway must be part of "
-                         "the source sub-AS (in particular, being in a "
-                         "sub-sub-AS is not allowed), "
-                         "but '%s' is not in '%s'.",
-                         route->src_gateway, subas->name);
-
-      subas = xbt_dict_get_or_null(rc->routing_sons, dst);
-      if (subas == NULL)
-        surf_parse_error("The destination of an ASroute must be a sub-AS "
-                         "declared within the current AS, "
-                         "but '%s' is not an AS within '%s'", dst, rc->name);
-      if (subas->to_index
-          && xbt_dict_get_or_null(subas->to_index, route->dst_gateway) == NULL)
-        surf_parse_error("In an ASroute, destination gateway must be "
-                         "part of the destination sub-AS (in particular, "
-                         "in a sub-sub-AS is not allowed), "
-                         "but '%s' is not in '%s'.",
-                         route->dst_gateway, subas->name);
+// FIXME We can call a gw wich is down the current AS (cf g5k.xml) but not upper.
+//      AS_t subas = xbt_dict_get_or_null(rc->routing_sons, src);
+//      if (subas == NULL)
+//        surf_parse_error("The source of an ASroute must be a sub-AS "
+//                         "declared within the current AS, "
+//                         "but '%s' is not an AS within '%s'", src, rc->name);
+//      if (subas->to_index
+//          && xbt_dict_get_or_null(subas->to_index, route->src_gateway) == NULL)
+//        surf_parse_error("In an ASroute, source gateway must be part of "
+//                         "the source sub-AS (in particular, being in a "
+//                         "sub-sub-AS is not allowed), "
+//                         "but '%s' is not in '%s'.",
+//                         route->src_gateway, subas->name);
+//
+//      subas = xbt_dict_get_or_null(rc->routing_sons, dst);
+//      if (subas == NULL)
+//        surf_parse_error("The destination of an ASroute must be a sub-AS "
+//                         "declared within the current AS, "
+//                         "but '%s' is not an AS within '%s'", dst, rc->name);
+//      if (subas->to_index
+//          && xbt_dict_get_or_null(subas->to_index, route->dst_gateway) == NULL)
+//        surf_parse_error("In an ASroute, destination gateway must be "
+//                         "part of the destination sub-AS (in particular, "
+//                         "in a sub-sub-AS is not allowed), "
+//                         "but '%s' is not in '%s'.",
+//                         route->dst_gateway, subas->name);
 
       XBT_DEBUG("Load ASroute from \"%s(%s)\" to \"%s(%s)\"",
                 src, route->src_gateway, dst, route->dst_gateway);
index bfb16f9..55be68e 100644 (file)
@@ -14,6 +14,8 @@
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_routing_generic, surf_route, "Generic implementation of the surf routing");
 
+static int having_set_bypassroute = 0;
+
 AS_t model_generic_create_sized(size_t childsize) {
   AS_t new_component = model_none_create_sized(childsize);
 
@@ -81,6 +83,7 @@ void generic_parse_bypassroute(AS_t rc,
   xbt_free(e_route);
 
   xbt_dict_set(dict_bypassRoutes, route_name, new_e_route, NULL);
+  having_set_bypassroute = 1;
   xbt_free(route_name);
 }
 
@@ -94,6 +97,10 @@ xbt_dynar_t generic_get_onelink_routes(AS_t rc) { // FIXME: kill that stub
 
 route_t generic_get_bypassroute(AS_t rc, const char *src, const char *dst)
 {
+  // If never set a bypass route return NULL
+  if(!having_set_bypassroute)
+    return NULL;
+
   xbt_dict_t dict_bypassRoutes = rc->bypassRoutes;
   AS_t src_as, dst_as;
   int index_src, index_dst;
index eb89b6f..2c73194 100644 (file)
@@ -290,6 +290,36 @@ static xbt_dict_t ws_get_properties(const void *ws)
   return surf_resource_properties(((workstation_CLM03_t) ws)->cpu);
 }
 
+static surf_action_t ws_action_open(void *workstation, const char* path, const char* mode)
+{
+  return surf_cpu_model->extension.cpu.
+      sleep(((workstation_CLM03_t) workstation)->cpu, 1);
+}
+
+static surf_action_t ws_action_close(void *workstation, surf_file_t fp)
+{
+  return surf_cpu_model->extension.cpu.
+      sleep(((workstation_CLM03_t) workstation)->cpu, 2);
+}
+
+static surf_action_t ws_action_read(void *workstation, void* ptr, size_t size, size_t nmemb, surf_file_t stream)
+{
+  return surf_cpu_model->extension.cpu.
+      sleep(((workstation_CLM03_t) workstation)->cpu, 3);
+}
+
+static surf_action_t ws_action_write(void *workstation, const void* ptr, size_t size, size_t nmemb, surf_file_t stream)
+{
+  return surf_cpu_model->extension.cpu.
+      sleep(((workstation_CLM03_t) workstation)->cpu, 4);
+}
+
+static surf_action_t ws_action_stat(void *workstation, int fd, void* buf)
+{
+  return surf_cpu_model->extension.cpu.
+      sleep(((workstation_CLM03_t) workstation)->cpu, 5);
+}
+
 static void surf_workstation_model_init_internal(void)
 {
   surf_workstation_model = surf_model_init();
@@ -342,6 +372,11 @@ static void surf_workstation_model_init_internal(void)
   surf_workstation_model->extension.workstation.get_properties =
       ws_get_properties;
 
+  surf_workstation_model->extension.workstation.open = ws_action_open;
+  surf_workstation_model->extension.workstation.close = ws_action_close;
+  surf_workstation_model->extension.workstation.read = ws_action_read;
+  surf_workstation_model->extension.workstation.write = ws_action_write;
+  surf_workstation_model->extension.workstation.stat = ws_action_stat;
 }
 
 void surf_workstation_model_init_current_default(void)