Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Introduce DTD v4
authorMartin Quinson <martin.quinson@loria.fr>
Mon, 8 Feb 2016 23:51:54 +0000 (00:51 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Mon, 8 Feb 2016 23:59:10 +0000 (00:59 +0100)
See ChangeLog

12 files changed:
ChangeLog
include/simgrid/forward.h
include/surf/surfxml_parse.h
src/bindings/lua/lua_platf.cpp
src/include/surf/surf.h
src/smpi/smpirun.in
src/surf/simgrid.dtd
src/surf/storage_n11.cpp
src/surf/surfxml_parse.cpp
src/surf/surfxml_parseplatf.cpp
tools/cmake/MaintainerMode.cmake
tools/simgrid_update_xml.pl

index efa83e4..6b04d3f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -13,8 +13,27 @@ SimGrid (3.13) UNRELEASED; urgency=low
  
    - We removed support for writing your simulation in Lua; you can use
      the Java bindings.
-    
  
+ XML platforms:
+ * Switch to platform v4 format.
+   - Rename (power->speed) the attributes describing the amount of flop
+     that a <host>, <peer>, <cluster> or <cabinet> can deliver per second.
+   - In <trace_connect>, attribute kind="POWER" is now kind="SPEED".
+   - The DOCTYPE points to the right URL (this file):
+     http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd
+   - A warning is emitted for unit-less values (they are still accepted).
+     - speed. Default: 'f' or 'flops'. Also defined:
+        'Yf',         'Zf',         'Ef',       'Pf',        'Tf',        'Gf',        'Mf',        'kf'
+        'yottaflops', 'zettaflops', 'exaflops', 'petaflops', 'teraflops', 'gigaflops', 'megaflops', 'kiloflops'
+     - bandwidth. Default: 'Bps' bytes per second (or 'bps' for bits but 1 Bps = 8 bps)
+       Also defined in bytes: 'TiBps', 'GiBps', 'MiBps', 'KiBps', 'TBps', 'GBps', 'MBps', 'kBps', 'Bps'
+       And the same in bits:  'Tibps', 'Gibps', 'Mibps', 'Kibps', 'Tbps', 'Gbps', 'Mbps', 'kbps', 'bps'
+     - latency. Default: 's' second. Also defined:
+       'w' week, 'd' day, 'h' hour, 'm' minute, 'ms' millisecond, 'us' microsecond, 'ns' nanosecond, 'ps' picosecond
+ * Use the tool simgrid_update_xml to upgrade your files. It does not
+   convert the unit-less values. Use tools/sg_xml_unit_converter.py
+   for that (or live with the warnings).
+
  S4U
  * s4u::Host is now the prefered public interface to the Host features.
    sg_host_* functions are C bindings to the exact same behavior
index 19082b7..54210ac 100644 (file)
@@ -65,7 +65,7 @@ typedef enum {
 
 typedef enum {
   SURF_TRACE_CONNECT_KIND_HOST_AVAIL = 4,
-  SURF_TRACE_CONNECT_KIND_POWER = 3,
+  SURF_TRACE_CONNECT_KIND_SPEED = 3,
   SURF_TRACE_CONNECT_KIND_LINK_AVAIL = 2,
   SURF_TRACE_CONNECT_KIND_BANDWIDTH = 1,
   SURF_TRACE_CONNECT_KIND_LATENCY = 0
index b270f5d..83957d1 100644 (file)
@@ -29,10 +29,10 @@ XBT_PUBLIC(void) XBT_ATTRIB_NORETURN surf_parse_error(const char *msg,...) XBT_A
 XBT_PUBLIC(void) surf_parse_warn(const char *msg,...) XBT_ATTRIB_PRINTF(1,2);
 XBT_PUBLIC(double) surf_parse_get_double(const char *string);
 XBT_PUBLIC(int) surf_parse_get_int(const char *string);
-XBT_PUBLIC(double) surf_parse_get_time(const char *string);
-XBT_PUBLIC(double) surf_parse_get_size(const char *string);
-XBT_PUBLIC(double) surf_parse_get_bandwidth(const char *string);
-XBT_PUBLIC(double) surf_parse_get_speed(const char *string);
+XBT_PUBLIC(double) surf_parse_get_time(const char *string, const char *entity_kind, const char *name);
+XBT_PUBLIC(double) surf_parse_get_size(const char *string, const char *entity_kind, const char *name);
+XBT_PUBLIC(double) surf_parse_get_bandwidth(const char *string, const char *entity_kind, const char *name);
+XBT_PUBLIC(double) surf_parse_get_speed(const char *string, const char *entity_kind, const char *name);
 
 /* Prototypes of the functions offered by flex */
 XBT_PUBLIC(int) surf_parse_lex(void);
index f5037bf..41c9a2c 100644 (file)
@@ -85,7 +85,7 @@ int console_add_backbone(lua_State *L) {
   if (type != LUA_TSTRING && type != LUA_TNUMBER) {
     XBT_ERROR("Attribute 'bandwidth' must be specified for backbone and must either be a string (in the right format; see docs) or a number.");
   }
-  link.bandwidth = surf_parse_get_bandwidth(lua_tostring(L, -1));
+  link.bandwidth = surf_parse_get_bandwidth(lua_tostring(L, -1),"bandwidth of backbone",link.id);
   lua_pop(L, 1);
 
   lua_pushstring(L, "lat");
@@ -93,7 +93,7 @@ int console_add_backbone(lua_State *L) {
   if (type != LUA_TSTRING && type != LUA_TNUMBER) {
     XBT_ERROR("Attribute 'lat' must be specified for backbone and must either be a string (in the right format; see docs) or a number.");
   }
-  link.latency = surf_parse_get_time(lua_tostring(L, -1));
+  link.latency = surf_parse_get_time(lua_tostring(L, -1),"latency of backbone",link.id);
   lua_pop(L, 1);
 
   link.initiallyOn = 1;
@@ -172,7 +172,7 @@ int console_add_host(lua_State *L) {
   // get Id Value
   lua_pushstring(L, "id");
   type = lua_gettable(L, -2);
-  if (type != LUA_TSTRING && type != LUA_TNUMBER) {
+  if (type != LUA_TSTRING) {
     XBT_ERROR("Attribute 'id' must be specified for any host and must be a string.");
   }
   host.id = lua_tostring(L, -1);
@@ -185,7 +185,10 @@ int console_add_host(lua_State *L) {
     XBT_ERROR("Attribute 'speed' must be specified for host and must either be a string (in the correct format; check documentation) or a number.");
   }
   host.speed_peak = xbt_dynar_new(sizeof(double), NULL);
-  xbt_dynar_push_as(host.speed_peak, double, parse_cpu_speed(lua_tostring(L, -1)));
+  if (type == LUA_TNUMBER)
+    xbt_dynar_push_as(host.speed_peak, double, lua_tointeger(L, -1));
+  else // LUA_TSTRING
+    xbt_dynar_push_as(host.speed_peak, double, surf_parse_get_speed(lua_tostring(L, -1), "speed of host", host.id));
   lua_pop(L, 1);
 
   // get core
@@ -263,7 +266,10 @@ int  console_add_link(lua_State *L) {
   if (type != LUA_TSTRING && type != LUA_TNUMBER) {
     XBT_ERROR("Attribute 'bandwidth' must be specified for any link and must either be either a string (in the right format; see docs) or a number.");
   }
-  link.bandwidth = surf_parse_get_bandwidth(lua_tostring(L, -1));
+  if (type == LUA_TNUMBER)
+    link.bandwidth = lua_tonumber(L, -1);
+  else // LUA_TSTRING
+    link.bandwidth = surf_parse_get_bandwidth(lua_tostring(L, -1),"bandwidth of link", link.id);
   lua_pop(L, 1);
 
   //get latency value
@@ -272,7 +278,10 @@ int  console_add_link(lua_State *L) {
   if (type != LUA_TSTRING && type != LUA_TNUMBER) {
     XBT_ERROR("Attribute 'lat' must be specified for any link and must either be a string (in the right format; see docs) or a number.");
   }
-  link.latency = surf_parse_get_time(lua_tostring(L, -1));
+  if (type == LUA_TNUMBER)
+    link.latency = lua_tonumber(L, -1);
+  else // LUA_TSTRING
+    link.latency = surf_parse_get_time(lua_tostring(L, -1),"latency of link", link.id);
   lua_pop(L, 1);
 
   /*Optional Arguments  */
index 2a5aeec..0b98b06 100644 (file)
@@ -976,8 +976,6 @@ XBT_PUBLIC(void) parse_platform_file(const char *file);
 /* For the trace and trace:connect tag (store their content till the end of the parsing) */
 XBT_PUBLIC_DATA(xbt_dict_t) traces_set_list;
 
-XBT_PUBLIC(double) parse_cpu_speed(const char *str_speed);
-
 XBT_PUBLIC(xbt_dict_t) get_as_router_properties(const char* name);
 
 /*
index fb1754a..895ed69 100755 (executable)
 SIMGRID_VERSION="@SIMGRID_VERSION_STRING@"
 SIMGRID_GITHASH="@SIMGRID_GITHASH@"
 
-DEFAULT_LOOPBACK_BANDWIDTH="498000000"
-DEFAULT_LOOPBACK_LATENCY="0.000004"
-DEFAULT_NETWORK_BANDWIDTH="$((26 * 1024 * 1024))"
-DEFAULT_NETWORK_LATENCY="0.000005"
+DEFAULT_LOOPBACK_BANDWIDTH="498000000Bps"
+DEFAULT_LOOPBACK_LATENCY="0.000004s"
+DEFAULT_NETWORK_BANDWIDTH="$((26 * 1024 * 1024))Bps"
+DEFAULT_NETWORK_LATENCY="0.000005s"
 DEFAULT_NUMPROCS="4"
-DEFAULT_POWER="100"
+DEFAULT_SPEED="100flops"
 
 LOOPBACK_BANDWIDTH="${DEFAULT_LOOPBACK_BANDWIDTH}"
 LOOPBACK_LATENCY="${DEFAULT_LOOPBACK_LATENCY}"
 NETWORK_BANDWIDTH="${DEFAULT_NETWORK_BANDWIDTH}"
 NETWORK_LATENCY="${DEFAULT_NETWORK_LATENCY}"
-POWER="${DEFAULT_POWER}"
+SPEED="${DEFAULT_SPEED}"
 
 SIMOPTS="--cfg=surf/precision:1e-9 --cfg=network/model:SMPI --cfg=network/TCP_gamma:4194304"
 
@@ -347,14 +347,14 @@ if [ -z "${PLATFORM}" ]; then
 
     cat > ${PLATFORMTMP} <<PLATFORMHEAD
 <?xml version='1.0'?>
-<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
-<platform version="3">
+<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd">
+<platform version="4">
 <AS id="AS0" routing="Full">
 PLATFORMHEAD
 
     i=${NUMPROCS}
     while [ $i -gt 0 ]; do
-        echo "  <host id=\"host$i\" power=\"${POWER}\"/>" >> ${PLATFORMTMP}
+        echo "  <host id=\"host$i\" speed=\"${SPEED}\"/>" >> ${PLATFORMTMP}
         echo "  <link id=\"loop$i\" bandwidth=\"${LOOPBACK_BANDWIDTH}\" latency=\"${LOOPBACK_LATENCY}\"/>" >> ${PLATFORMTMP}
         echo "  <link id=\"link$i\" bandwidth=\"${NETWORK_BANDWIDTH}\" latency=\"${NETWORK_LATENCY}\"/>" >> ${PLATFORMTMP}
         i=$((i - 1))
@@ -391,8 +391,8 @@ APPLICATIONTMP="$(mktemp smpitmp-appXXXXXX)"
 
 cat > ${APPLICATIONTMP} <<APPLICATIONHEAD
 <?xml version='1.0'?>
-<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
-<platform version="3">
+<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd">
+<platform version="4">
 APPLICATIONHEAD
 
 ##---- cache hostnames of hostfile---------------
index 70f5032..fff5eb3 100644 (file)
@@ -1,4 +1,54 @@
-<!-- Small DTD for SURF based tools. -->
+<!-- 
+             DTD of SimGrid platform and deployment files.
+
+More info: http://simgrid.gforge.inria.fr/simgrid/latest/doc/platform.html
+To upgrade your files, use the tool simgrid_update_xml
+
+* New in DTD version 4 (in SimGrid 3.13):
+   - Rename (power->speed) the attributes describing the amount of flop
+     that a <host>, <peer>, <cluster> or <cabinet> can deliver per second.
+
+   - In <trace_connect>, attribute kind="POWER" is now kind="SPEED".
+
+   - The DOCTYPE points to the right URL (this file):
+     http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd
+
+   - A warning is emited for unit-less values (they are still accepted).
+
+     - speed. Default: 'f' or 'flops'. Also defined:
+        'Yf',         'Zf',         'Ef',       'Pf',        'Tf',        'Gf',        'Mf',        'kf'
+        'yottaflops', 'zettaflops', 'exaflops', 'petaflops', 'teraflops', 'gigaflops', 'megaflops', 'kiloflops'
+
+     - bandwidth. Default: 'Bps' bytes per second (or 'bps' for bits but 1 Bps = 8 bps)
+       Also defined in bytes: 'TiBps', 'GiBps', 'MiBps', 'KiBps', 'TBps', 'GBps', 'MBps', 'kBps', 'Bps'
+       And the same in bits:  'Tibps', 'Gibps', 'Mibps', 'Kibps', 'Tbps', 'Gbps', 'Mbps', 'kbps', 'bps'
+
+     - latency. Default: 's' second. Also defined:
+       'w' week, 'd' day, 'h' hour, 'm' minute, 'ms' millisecond, 'us' microsecond, 'ns' nanosecond, 'ps' picosecond
+
+* New in DTD version 3 (in SimGrid 3.5):
+   - The AS tag were introduced. Every platform should now
+     contain an englobing AS tag.
+   - Routes are now symmetric by default.
+   - Renamed tags (for sake of XML sanity):
+     - LINK:CTN -> LINK_CTN
+     - TRACE:CONNECT -> TRACE_CONNECT
+
+* New in DTD version 2 (in SimGrid 3.4):
+   - Renamed tags:
+     - CPU -> HOST
+     - NETWORK_LINK -> LINK
+     - ROUTE_ELEMENT ->  LINK:CTN (changed again in v3)
+     - PLATFORM_DESCRIPTION -> PLATFORM
+
+* New in DTD version 1 (in SimGrid 3.3):
+   - DTD is now versionned with the version attribute of platform
+   - Unit change: 
+     - Link bandwidth: from Mb/s to b/s
+     - CPU speed: from MFlop/s to Flop/s
+
+-->
+
 <!ELEMENT platform ((config|random)*,(include|cluster|cabinet|peer|AS|trace|trace_connect)*,(process)*)>
 <!ATTLIST platform version CDATA "0.0">
 
@@ -21,7 +71,7 @@
 <!ATTLIST random generator (DRAND48|RAND|RNGSTREAM|NONE) "DRAND48">
 
 <!ELEMENT trace_connect EMPTY>
-<!ATTLIST trace_connect kind (HOST_AVAIL|POWER|LINK_AVAIL|BANDWIDTH|LATENCY) "HOST_AVAIL">
+<!ATTLIST trace_connect kind (HOST_AVAIL|SPEED|LINK_AVAIL|BANDWIDTH|LATENCY) "HOST_AVAIL">
 <!ATTLIST trace_connect trace CDATA #REQUIRED>
 <!ATTLIST trace_connect element CDATA #REQUIRED>
 
@@ -46,7 +96,7 @@
 
 <!ELEMENT host (prop|mount|mstorage)*>
 <!ATTLIST host id CDATA #REQUIRED>
-<!ATTLIST host power CDATA #REQUIRED>
+<!ATTLIST host speed CDATA #REQUIRED>
 <!ATTLIST host core  CDATA "1">
 <!ATTLIST host availability CDATA "1.0">
 <!ATTLIST host availability_file CDATA "">
 <!ATTLIST cluster prefix CDATA #REQUIRED>
 <!ATTLIST cluster suffix CDATA #REQUIRED>
 <!ATTLIST cluster radical CDATA #REQUIRED>
-<!ATTLIST cluster power CDATA #REQUIRED>
+<!ATTLIST cluster speed CDATA #REQUIRED>
 <!ATTLIST cluster core CDATA "1">
 <!ATTLIST cluster bw CDATA #REQUIRED>
 <!ATTLIST cluster lat CDATA #REQUIRED>
 <!ATTLIST cluster topology (FLAT|TORUS|FAT_TREE) "FLAT">
 <!ATTLIST cluster topo_parameters CDATA "">
 <!ATTLIST cluster bb_bw CDATA "">
-<!ATTLIST cluster bb_lat CDATA "">
+<!ATTLIST cluster bb_lat CDATA "0s">
 <!ATTLIST cluster bb_sharing_policy (SHARED|FATPIPE) "SHARED">
 <!ATTLIST cluster availability_file CDATA "">
 <!ATTLIST cluster state_file CDATA "">
 <!ATTLIST cabinet prefix CDATA #REQUIRED>
 <!ATTLIST cabinet suffix CDATA #REQUIRED>
 <!ATTLIST cabinet radical CDATA #REQUIRED>
-<!ATTLIST cabinet power CDATA #REQUIRED>
+<!ATTLIST cabinet speed CDATA #REQUIRED>
 <!ATTLIST cabinet bw CDATA #REQUIRED>
 <!ATTLIST cabinet lat CDATA #REQUIRED>
 
 <!ELEMENT peer EMPTY>
 <!ATTLIST peer id CDATA #REQUIRED>
-<!ATTLIST peer power CDATA #REQUIRED>
+<!ATTLIST peer speed CDATA #REQUIRED>
 <!ATTLIST peer bw_in CDATA #REQUIRED>
 <!ATTLIST peer bw_out CDATA #REQUIRED>
 <!ATTLIST peer lat CDATA #REQUIRED>
 <!ATTLIST link id CDATA #REQUIRED>
 <!ATTLIST link bandwidth CDATA  #REQUIRED>
 <!ATTLIST link bandwidth_file CDATA "">
-<!ATTLIST link latency CDATA "0.0">
+<!ATTLIST link latency CDATA "0">
 <!ATTLIST link latency_file CDATA "">
 <!ATTLIST link state (ON|OFF) "ON">
 <!ATTLIST link state_file CDATA "">
index 061023e..6fc77ae 100644 (file)
@@ -91,9 +91,12 @@ Storage *StorageN11Model::createStorage(const char* id, const char* type_id,
 
   storage_type_t storage_type = (storage_type_t) xbt_lib_get_or_null(storage_type_lib, type_id,ROUTING_STORAGE_TYPE_LEVEL);
 
-  double Bread  = surf_parse_get_bandwidth((char*)xbt_dict_get(storage_type->model_properties, "Bread"));
-  double Bwrite = surf_parse_get_bandwidth((char*)xbt_dict_get(storage_type->model_properties, "Bwrite"));
-  double Bconnection   = surf_parse_get_bandwidth((char*)xbt_dict_get(storage_type->model_properties, "Bconnection"));
+  double Bread  = surf_parse_get_bandwidth((char*)xbt_dict_get(storage_type->model_properties, "Bread"),
+      "property Bread, storage",type_id);
+  double Bwrite = surf_parse_get_bandwidth((char*)xbt_dict_get(storage_type->model_properties, "Bwrite"),
+      "property Bwrite, storage",type_id);
+  double Bconnection   = surf_parse_get_bandwidth((char*)xbt_dict_get(storage_type->model_properties, "Bconnection"),
+      "property Bconnection, storage",type_id);
 
   Storage *storage = new StorageN11(this, id, properties, p_maxminSystem,
       Bread, Bwrite, Bconnection, type_id, (char *)content_name,
index b440ea3..ddbb223 100644 (file)
@@ -72,10 +72,11 @@ struct unit_scale {
   double scale;
 };
 
-/* Note: field `unit' for the last element of parametre `units' should be
+/* Note: field `unit' for the last element of parameter `units' should be
  * NULL. */
-static double surf_parse_get_value_with_unit(const char *string,
-                                             const struct unit_scale *units)
+static double surf_parse_get_value_with_unit(const char *string, const struct unit_scale *units,
+    const char *entity_kind, const char *name,
+    const char *error_msg, const char *default_unit)
 {
   char* ptr;
   double res;
@@ -86,6 +87,13 @@ static double surf_parse_get_value_with_unit(const char *string,
     surf_parse_error("value out of range: %s", string);
   if (ptr == string)
     surf_parse_error("cannot parse number: %s", string);
+  if (ptr[0] == '\0') {
+    if (res == 0)
+      return res; // Ok, 0 can be unit-less
+
+    XBT_WARN("Deprecated unit-less value '%s' for %s %s. %s",string, entity_kind, name, error_msg);
+    ptr = (char*)default_unit;
+  }
   for (i = 0; units[i].unit != NULL && strcmp(ptr, units[i].unit) != 0; i++) {
   }
   if (units[i].unit != NULL)
@@ -95,7 +103,7 @@ static double surf_parse_get_value_with_unit(const char *string,
   return res;
 }
 
-double surf_parse_get_time(const char *string)
+double surf_parse_get_time(const char *string, const char *entity_kind, const char *name)
 {
   const struct unit_scale units[] = {
     { "w",  7 * 24 * 60 * 60 },
@@ -103,17 +111,17 @@ double surf_parse_get_time(const char *string)
     { "h",  60 * 60 },
     { "m",  60 },
     { "s",  1.0 },
-    { "",   1.0 },              /* default unit is seconds */
     { "ms", 1e-3 },
     { "us", 1e-6 },
     { "ns", 1e-9 },
     { "ps", 1e-12 },
     { NULL, 0 }
   };
-  return surf_parse_get_value_with_unit(string, units);
+  return surf_parse_get_value_with_unit(string, units, entity_kind, name,
+      "Append 's' to your time to get seconds", "s");
 }
 
-double surf_parse_get_size(const char *string)
+double surf_parse_get_size(const char *string, const char *entity_kind, const char *name)
 {
   const struct unit_scale units[] = {
     { "TiB", pow(1024, 4) },
@@ -125,7 +133,6 @@ double surf_parse_get_size(const char *string)
     { "MB",  1e6 },
     { "kB",  1e3 },
     { "B",   1.0 },
-    { "",      1.0 },           /* default unit is bytes*/
     { "Tib", 0.125 * pow(1024, 4) },
     { "Gib", 0.125 * pow(1024, 3) },
     { "Mib", 0.125 * pow(1024, 2) },
@@ -137,10 +144,11 @@ double surf_parse_get_size(const char *string)
     { "b",   0.125 },
     { NULL,    0 }
   };
-  return surf_parse_get_value_with_unit(string, units);
+  return surf_parse_get_value_with_unit(string, units, entity_kind, name,
+      "Append 'B' to get bytes (or 'b' for bits but 1B = 8b).", "B");
 }
 
-double surf_parse_get_bandwidth(const char *string)
+double surf_parse_get_bandwidth(const char *string, const char *entity_kind, const char *name)
 {
   const struct unit_scale units[] = {
     { "TiBps", pow(1024, 4) },
@@ -152,7 +160,6 @@ double surf_parse_get_bandwidth(const char *string)
     { "MBps",  1e6 },
     { "kBps",  1e3 },
     { "Bps",   1.0 },
-    { "",      1.0 },           /* default unit is bytes per second */
     { "Tibps", 0.125 * pow(1024, 4) },
     { "Gibps", 0.125 * pow(1024, 3) },
     { "Mibps", 0.125 * pow(1024, 2) },
@@ -164,10 +171,11 @@ double surf_parse_get_bandwidth(const char *string)
     { "bps",   0.125 },
     { NULL,    0 }
   };
-  return surf_parse_get_value_with_unit(string, units);
+  return surf_parse_get_value_with_unit(string, units, entity_kind, name,
+      "Append 'Bps' to get bytes per second (or 'bps' for bits but 1Bps = 8bps)", "Bps");
 }
 
-double surf_parse_get_speed(const char *string)
+double surf_parse_get_speed(const char *string, const char *entity_kind, const char *name)
 {
   const struct unit_scale units[] = {
     { "yottaflops", 1e24 },
@@ -188,10 +196,10 @@ double surf_parse_get_speed(const char *string)
     { "kf",         1e3 },
     { "flops",      1.0 },
     { "f",          1.0 },
-    { "",           1.0 },      /* default unit is flops */
     { NULL,         0 }
   };
-  return surf_parse_get_value_with_unit(string, units);
+  return surf_parse_get_value_with_unit(string, units, entity_kind, name,
+      "Append 'f' or 'flops' to your speed to get flop per second", "f");
 }
 
 /*
@@ -258,7 +266,8 @@ void ETag_surfxml_storage___type(void)
   storage_type.model            = A_surfxml_storage___type_model;
   storage_type.properties       = current_property_set;
   storage_type.model_properties = current_model_property_set;
-  storage_type.size             = surf_parse_get_size(A_surfxml_storage___type_size);
+  storage_type.size             = surf_parse_get_size(A_surfxml_storage___type_size,
+        "size of storage type", storage_type.id);
   sg_platf_new_storage_type(&storage_type);
   current_property_set       = NULL;
   current_model_property_set = NULL;
@@ -394,6 +403,16 @@ void STag_surfxml_platform(void) {
       "Use simgrid_update_xml to update your file automatically. "
       "This program is installed automatically with SimGrid, or "
       "available in the tools/ directory of the source archive.");
+  xbt_assert((version >= 4.0), "******* FILE %s IS TOO OLD (v:%.1f) *********\n "
+      "Changes introduced in SimGrid 3.13:\n"
+      "  - 'power' attribute of hosts (and others) got renamed to 'speed'.\n"
+      "  - In <trace_connect>, attribute kind=\"POWER\" is now kind=\"SPEED\".\n"
+      "  - DOCTYPE now point to the rignt URL: http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd\n"
+      "  - speed, bandwidth and latency attributes now MUST have an explicit unit (f, Bps, s by default)"
+      "\n\n"
+      "Use simgrid_update_xml to update your file automatically. "
+      "This program is installed automatically with SimGrid, or "
+      "available in the tools/ directory of the source archive.",surf_parsed_filename, version);
 
   sg_platf_begin();
 }
@@ -438,11 +457,11 @@ void ETag_surfxml_host(void)    {
 
   host.id = A_surfxml_host_id;
 
-  buf = A_surfxml_host_power;
+  buf = A_surfxml_host_speed;
   XBT_DEBUG("Buffer: %s", buf);
   host.speed_peak = xbt_dynar_new(sizeof(double), NULL);
   if (strchr(buf, ',') == NULL){
-    double speed = parse_cpu_speed(A_surfxml_host_power);
+    double speed = surf_parse_get_speed(A_surfxml_host_speed,"speed of host", host.id);
     xbt_dynar_push_as(host.speed_peak,double, speed);
   }
   else {
@@ -454,7 +473,7 @@ void ETag_surfxml_host(void)    {
 
       xbt_dynar_get_cpy(pstate_list, i, &speed_str);
       xbt_str_trim(speed_str, NULL);
-      speed = parse_cpu_speed(speed_str);
+      speed = surf_parse_get_speed(speed_str,"speed of host", host.id);
       xbt_dynar_push_as(host.speed_peak, double, speed);
       XBT_DEBUG("Speed value: %f", speed);
     }
@@ -511,20 +530,20 @@ void ETag_surfxml_cluster(void){
   cluster.prefix      = A_surfxml_cluster_prefix;
   cluster.suffix      = A_surfxml_cluster_suffix;
   cluster.radical     = A_surfxml_cluster_radical;
-  cluster.speed       = surf_parse_get_speed(A_surfxml_cluster_power);
+  cluster.speed       = surf_parse_get_speed(A_surfxml_cluster_speed, "speed of cluster", cluster.id);
   cluster.core_amount = surf_parse_get_int(A_surfxml_cluster_core);
-  cluster.bw          = surf_parse_get_bandwidth(A_surfxml_cluster_bw);
-  cluster.lat         = surf_parse_get_time(A_surfxml_cluster_lat);
+  cluster.bw          = surf_parse_get_bandwidth(A_surfxml_cluster_bw, "bw of cluster", cluster.id);
+  cluster.lat         = surf_parse_get_time(A_surfxml_cluster_lat, "lat of cluster", cluster.id);
   if(strcmp(A_surfxml_cluster_bb___bw,""))
-    cluster.bb_bw = surf_parse_get_bandwidth(A_surfxml_cluster_bb___bw);
+    cluster.bb_bw = surf_parse_get_bandwidth(A_surfxml_cluster_bb___bw, "bb_bw of cluster", cluster.id);
   if(strcmp(A_surfxml_cluster_bb___lat,""))
-    cluster.bb_lat = surf_parse_get_time(A_surfxml_cluster_bb___lat);
+    cluster.bb_lat = surf_parse_get_time(A_surfxml_cluster_bb___lat, "bb_lat of cluster", cluster.id);
   if(strcmp(A_surfxml_cluster_limiter___link,""))
     cluster.limiter_link = surf_parse_get_double(A_surfxml_cluster_limiter___link);
   if(strcmp(A_surfxml_cluster_loopback___bw,""))
-    cluster.loopback_bw = surf_parse_get_bandwidth(A_surfxml_cluster_loopback___bw);
+    cluster.loopback_bw = surf_parse_get_bandwidth(A_surfxml_cluster_loopback___bw, "loopback_bw of cluster", cluster.id);
   if(strcmp(A_surfxml_cluster_loopback___lat,""))
-    cluster.loopback_lat = surf_parse_get_time(A_surfxml_cluster_loopback___lat);
+    cluster.loopback_lat = surf_parse_get_time(A_surfxml_cluster_loopback___lat, "loopback_lat of cluster", cluster.id);
 
   switch(AX_surfxml_cluster_topology){
   case A_surfxml_cluster_topology_FLAT:
@@ -591,9 +610,9 @@ void STag_surfxml_cabinet(void){
   cabinet.id      = A_surfxml_cabinet_id;
   cabinet.prefix  = A_surfxml_cabinet_prefix;
   cabinet.suffix  = A_surfxml_cabinet_suffix;
-  cabinet.speed   = surf_parse_get_speed(A_surfxml_cabinet_power);
-  cabinet.bw      = surf_parse_get_bandwidth(A_surfxml_cabinet_bw);
-  cabinet.lat     = surf_parse_get_time(A_surfxml_cabinet_lat);
+  cabinet.speed   = surf_parse_get_speed(A_surfxml_cabinet_speed, "speed of cabinet", cabinet.id);
+  cabinet.bw      = surf_parse_get_bandwidth(A_surfxml_cabinet_bw, "bw of cabinet", cabinet.id);
+  cabinet.lat     = surf_parse_get_time(A_surfxml_cabinet_lat, "lat of cabinet", cabinet.id);
   cabinet.radical = A_surfxml_cabinet_radical;
 
   sg_platf_new_cabinet(&cabinet);
@@ -604,10 +623,10 @@ void STag_surfxml_peer(void){
   s_sg_platf_peer_cbarg_t peer = SG_PLATF_PEER_INITIALIZER;
   memset(&peer,0,sizeof(peer));
   peer.id                 = A_surfxml_peer_id;
-  peer.speed              = surf_parse_get_speed(A_surfxml_peer_power);
-  peer.bw_in              = surf_parse_get_bandwidth(A_surfxml_peer_bw___in);
-  peer.bw_out             = surf_parse_get_bandwidth(A_surfxml_peer_bw___out);
-  peer.lat                = surf_parse_get_time(A_surfxml_peer_lat);
+  peer.speed              = surf_parse_get_speed(A_surfxml_peer_speed, "speed of peer", peer.id);
+  peer.bw_in              = surf_parse_get_bandwidth(A_surfxml_peer_bw___in, "bw_in of peer", peer.id);
+  peer.bw_out             = surf_parse_get_bandwidth(A_surfxml_peer_bw___out, "bw_out of peer", peer.id);
+  peer.lat                = surf_parse_get_time(A_surfxml_peer_lat, "lat of peer", peer.id);
   peer.coord              = A_surfxml_peer_coordinates;
   peer.availability_trace = tmgr_trace_new_from_file(A_surfxml_peer_availability___file);
   peer.state_trace        = tmgr_trace_new_from_file(A_surfxml_peer_state___file);
@@ -627,10 +646,10 @@ void ETag_surfxml_link(void){
   link.properties = current_property_set;
 
   link.id                                            = A_surfxml_link_id;
-  link.bandwidth                                     = surf_parse_get_bandwidth(A_surfxml_link_bandwidth);
+  link.bandwidth                                     = surf_parse_get_bandwidth(A_surfxml_link_bandwidth, "bandwidth of link", link.id);
   //printf("Link bandwidth [%g]\n", link.bandwidth);
   link.bandwidth_trace                               = tmgr_trace_new_from_file(A_surfxml_link_bandwidth___file);
-  link.latency                                       = surf_parse_get_time(A_surfxml_link_latency);
+  link.latency                                       = surf_parse_get_time(A_surfxml_link_latency, "latency of link", link.id);
   //printf("Link latency [%g]\n", link.latency);
   link.latency_trace                                 = tmgr_trace_new_from_file(A_surfxml_link_latency___file);
 
@@ -695,8 +714,8 @@ void ETag_surfxml_backbone(void){
   link.properties = NULL;
 
   link.id = A_surfxml_backbone_id;
-  link.bandwidth = surf_parse_get_bandwidth(A_surfxml_backbone_bandwidth);
-  link.latency = surf_parse_get_time(A_surfxml_backbone_latency);
+  link.bandwidth = surf_parse_get_bandwidth(A_surfxml_backbone_bandwidth, "bandwidth of backbone", link.id);
+  link.latency = surf_parse_get_time(A_surfxml_backbone_latency, "latency of backbone", link.id);
   link.initiallyOn = 1;
   link.policy = SURF_LINK_SHARED;
 
@@ -851,8 +870,8 @@ void STag_surfxml_trace___connect(void){
 
   switch (A_surfxml_trace___connect_kind) {
   case AU_surfxml_trace___connect_kind:
-  case A_surfxml_trace___connect_kind_POWER:
-    trace_connect.kind =  SURF_TRACE_CONNECT_KIND_POWER;
+  case A_surfxml_trace___connect_kind_SPEED:
+    trace_connect.kind =  SURF_TRACE_CONNECT_KIND_SPEED;
     break;
   case A_surfxml_trace___connect_kind_BANDWIDTH:
     trace_connect.kind =  SURF_TRACE_CONNECT_KIND_BANDWIDTH;
@@ -1059,12 +1078,6 @@ int_f_void_t surf_parse = _surf_parse;
 /**
  * With XML parser
  */
-
-double parse_cpu_speed(const char *str_speed)
-{ // FIXME deadcode
-  return surf_parse_get_speed(str_speed);
-}
-
 xbt_dict_t get_as_router_properties(const char* name)
 {
   return (xbt_dict_t)xbt_lib_get_or_null(as_router_lib, name, ROUTING_PROP_ASR_LEVEL);
index ead4804..eaa30d6 100644 (file)
@@ -83,7 +83,7 @@ void sg_platf_trace_connect(sg_platf_trace_connect_cbarg_t trace_connect)
         trace_connect->trace,
         xbt_strdup(trace_connect->element), NULL);
     break;
-  case SURF_TRACE_CONNECT_KIND_POWER:
+  case SURF_TRACE_CONNECT_KIND_SPEED:
     xbt_dict_set(trace_connect_list_host_speed, trace_connect->trace,
         xbt_strdup(trace_connect->element), NULL);
     break;
index 836032f..712696c 100644 (file)
@@ -156,7 +156,7 @@ if(enable_maintainer_mode AND NOT WIN32)
       ${CMAKE_HOME_DIRECTORY}/src/simdag/dax.dtd
 
       #${CMAKE_HOME_DIRECTORY}/src/surf/simgrid_dtd.l: ${CMAKE_HOME_DIRECTORY}/src/surf/simgrid.dtd
-      COMMAND ${FLEXML_EXE} --root-tags platform -b 1000000 -P surfxml --sysid=http://simgrid.gforge.inria.fr/simgrid.dtd -S src/surf/simgrid_dtd.l -L src/surf/simgrid.dtd
+      COMMAND ${FLEXML_EXE} --root-tags platform -b 1000000 -P surfxml --sysid=http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd -S src/surf/simgrid_dtd.l -L src/surf/simgrid.dtd
       COMMAND ${SED_EXE} -i ${string14} src/surf/simgrid_dtd.l
       COMMAND ${CMAKE_COMMAND} -E echo "src/surf/simgrid_dtd.l"
 
@@ -173,7 +173,7 @@ if(enable_maintainer_mode AND NOT WIN32)
 
       #${CMAKE_HOME_DIRECTORY}/include/surf/simgrid_dtd.h: ${CMAKE_HOME_DIRECTORY}/src/surf/simgrid.dtd
       COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_HOME_DIRECTORY}/include/surf/simgrid.h
-      COMMAND ${FLEXML_EXE} --root-tags platform -P surfxml --sysid=http://simgrid.gforge.inria.fr/simgrid.dtd -H include/surf/simgrid_dtd.h -L src/surf/simgrid.dtd
+      COMMAND ${FLEXML_EXE} --root-tags platform -P surfxml --sysid=http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd -H include/surf/simgrid_dtd.h -L src/surf/simgrid.dtd
       COMMAND ${SED_EXE} -i ${string1} include/surf/simgrid_dtd.h
       COMMAND ${SED_EXE} -i ${string2} include/surf/simgrid_dtd.h
       COMMAND ${SED_EXE} -i ${string14} include/surf/simgrid_dtd.h
index 7ec9879..da3df3f 100755 (executable)
@@ -28,7 +28,7 @@ is modified in place, without any kind of backup. You may want to save a copy
 before running the script.
 
 In SimGrid XML files, the standard version is indicated in the version
-attribute of the platform tag. Current version is 3. Here is a list of major
+attribute of the platform tag. Current version is 4. Here is a list of major
 changes in each version.
 
 =over 4
@@ -65,7 +65,7 @@ Several tags were renamed:
 
 =back
 
-=item B<Version 3:> Introduced in SimGrid 3.5 (this is the current version)
+=item B<Version 3:> Introduced in SimGrid 3.5
 
 =over 4
 
@@ -87,6 +87,42 @@ Several tags were renamed (for sake of XML sanity):
 
 =back
 
+=item B<Version 4:> Introduced in SimGrid 3.13 (this is the current version)
+
+=over 4
+
+=item
+
+Rename the attributes describing the amount of flop that a host / peer / cluster / cabinet can deliver per second.
+
+  <host power=...> -> <host speed=...>
+
+=item
+
+In <trace_connect>, attribute kind="POWER" is now kind="SPEED".
+
+=item
+
+The DOCTYPE points to the right URL: http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd
+
+=item
+
+Units are now mandatory in attributes. USE THE SCRIPT sg_xml_unit_converter.py TO CONVERT THIS
+
+     - speed. Old default: 'f' or 'flops'. Also defined: 
+        'Yf',         'Zf',         'Ef',       'Pf',        'Tf',        'Gf',        'Mf',        'kf' 
+        'yottaflops', 'zettaflops', 'exaflops', 'petaflops', 'teraflops', 'gigaflops', 'megaflops', 'kiloflops'
+        
+     - bandwidth. Old default: 'Bps' bytes per second (or 'bps' but 1 Bps = 8 bps)
+       Also defined in bytes: 'TiBps', 'GiBps', 'MiBps', 'KiBps', 'TBps', 'GBps', 'MBps', 'kBps', 'Bps'
+       And the same in bits:  'Tibps', 'Gibps', 'Mibps', 'Kibps', 'Tbps', 'Gbps', 'Mbps', 'kbps', 'bps' 
+       
+     - latency. Old default: 's' second. Also defined:
+       'w' week, 'd' day, 'h' hour, 'm' minute, 'ms' millisecond, 'us' microsecond, 'ns' nanosecond, 'ps' picosecond   
+
+
+=back
+
 =back
 
 =head1 AUTHORS
@@ -95,7 +131,7 @@ Several tags were renamed (for sake of XML sanity):
   
 =head1 COPYRIGHT AND LICENSE
 
-Copyright (c) 2006-2014. The SimGrid Team. All rights reserved.
+Copyright (c) 2006-2016. The SimGrid Team. All rights reserved.
   
 This program is free software; you may redistribute it and/or modify it
 under the terms of GNU LGPL (v2.1) license.
@@ -106,15 +142,15 @@ under the terms of GNU LGPL (v2.1) license.
 use strict;
 
 my $fromversion=-1;
-my $toversion=3;
+my $toversion=4;
 
 my($output_string);
 
-$ARGV[0] or die "simgrid_update_xml.pl <platform.xml>\n";
-open INPUT, "$ARGV[0]" or die "Cannot open input file $ARGV[0]: $!\n";
+my $filename = $ARGV[0] or die "simgrid_update_xml.pl <platform.xml>\n";
+open INPUT, "$filename" or die "Cannot open input file $filename: $!\n";
 
 $output_string = "<?xml version='1.0'?>\n".
-    "<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid.dtd\">\n".
+    "<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd\">\n".
     "<platform version=\"$toversion\">\n";
 
 
@@ -129,18 +165,18 @@ while (defined($line = <INPUT>)) {
     
     if ($line =~ s/<platform(_description)? *>//) {
        $fromversion = 0;
-       print "version 0\n";
+       print "$filename was using version 0\n";
        next if !$line =~ /\S/;
     } elsif ($line =~ s/<platform.*version=["]*([0-9.])["]*>//) {
        $fromversion = $1;
-       print "version $fromversion\n";
        if ($fromversion == $toversion) {
-           die "Input platform file version is already $fromversion. This should be a no-op.\n";
+           die "Input platform file $filename is already conformant to version $fromversion. This should be a no-op.\n";
        }
        if ($fromversion > $toversion) {
-           die "Input platform file version is more recent than this script (file version: $fromversion; script version: $toversion)\n";
+           die "Input platform file $filename is more recent than this script (file version: $fromversion; script version: $toversion)\n";
        }
        next if !$line =~ /\S/;
+       print "$filename was using version $fromversion\n";
     }
     
     if ($fromversion == 0) {
@@ -185,18 +221,23 @@ while (defined($line = <INPUT>)) {
            $output_string .=  " <AS  id=\"AS0\"  routing=\"Full\">\n";
            $AS_opened=1;
        }
-    }
        
        if($line=~/<route /){$line =~ s/\<route/\<route symmetrical=\"NO\"/g;}
+    }
+    if ($fromversion < 4) {
+       $line =~ s/\bpower\b/speed/g;   
+       $line =~ s/\bkind="POWER"/kind="SPEED"/g;
+    }
+       
     $output_string .= "$line\n";
 }
 
 close INPUT;
 
 if ($fromversion == -1) {
-    die "Cannot retrieve the platform version\n";
+    die "Cannot retrieve the platform version of $filename\n";
 }
 
-open OUTPUT, "> $ARGV[0]";
+open OUTPUT, "> $filename";
 print OUTPUT $output_string;
 close OUTPUT;