Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
reduce the amount of mallocs (and plug a memleak)
[simgrid.git] / src / surf / xml / surfxml_sax_cb.cpp
index a5b3edf..e426c40 100644 (file)
@@ -137,19 +137,27 @@ double surf_parse_get_time(const char *string, const char *entity_kind, const ch
 double surf_parse_get_size(const char *string, const char *entity_kind, const char *name)
 {
   const struct unit_scale units[] = {
+    { "EiB", pow(1024, 6) },
+    { "PiB", pow(1024, 5) },
     { "TiB", pow(1024, 4) },
     { "GiB", pow(1024, 3) },
     { "MiB", pow(1024, 2) },
     { "KiB", 1024 },
+    { "EB",  1e18 },
+    { "PB",  1e15 },
     { "TB",  1e12 },
     { "GB",  1e9 },
     { "MB",  1e6 },
     { "kB",  1e3 },
     { "B",   1.0 },
+    { "Eib", 0.125 * pow(1024, 6) },
+    { "Pib", 0.125 * pow(1024, 5) },
     { "Tib", 0.125 * pow(1024, 4) },
     { "Gib", 0.125 * pow(1024, 3) },
     { "Mib", 0.125 * pow(1024, 2) },
     { "Kib", 0.125 * 1024 },
+    { "Eb",  0.125 * 1e18 },
+    { "Pb",  0.125 * 1e15 },
     { "Tb",  0.125 * 1e12 },
     { "Gb",  0.125 * 1e9 },
     { "Mb",  0.125 * 1e6 },
@@ -164,15 +172,21 @@ double surf_parse_get_size(const char *string, const char *entity_kind, const ch
 double surf_parse_get_bandwidth(const char *string, const char *entity_kind, const char *name)
 {
   const struct unit_scale units[] = {
+    { "EiBps", pow(1024, 6) },
+    { "PiBps", pow(1024, 5) },
     { "TiBps", pow(1024, 4) },
     { "GiBps", pow(1024, 3) },
     { "MiBps", pow(1024, 2) },
     { "KiBps", 1024 },
+    { "EBps",  1e18 },
+    { "PBps",  1e15 },
     { "TBps",  1e12 },
     { "GBps",  1e9 },
     { "MBps",  1e6 },
     { "kBps",  1e3 },
     { "Bps",   1.0 },
+    { "Eibps", 0.125 * pow(1024, 6) },
+    { "Pibps", 0.125 * pow(1024, 5) },
     { "Tibps", 0.125 * pow(1024, 4) },
     { "Gibps", 0.125 * pow(1024, 3) },
     { "Mibps", 0.125 * pow(1024, 2) },
@@ -442,10 +456,9 @@ void ETag_surfxml_host()    {
 
   buf = A_surfxml_host_speed;
   XBT_DEBUG("Buffer: %s", buf);
-  host.speed_per_pstate = xbt_dynar_new(sizeof(double), nullptr);
   if (strchr(buf, ',') == nullptr){
     double speed = surf_parse_get_speed(A_surfxml_host_speed,"speed of host", host.id);
-    xbt_dynar_push_as(host.speed_per_pstate,double, speed);
+    host.speed_per_pstate.push_back(speed);
   }
   else {
     xbt_dynar_t pstate_list = xbt_str_split(buf, ",");
@@ -454,7 +467,7 @@ void ETag_surfxml_host()    {
     xbt_dynar_foreach(pstate_list, i, speed_str) {
       xbt_str_trim(speed_str, nullptr);
       double speed = surf_parse_get_speed(speed_str,"speed of host", host.id);
-      xbt_dynar_push_as(host.speed_per_pstate, double, speed);
+      host.speed_per_pstate.push_back(speed);
       XBT_DEBUG("Speed value: %f", speed);
     }
     xbt_dynar_free(&pstate_list);
@@ -468,7 +481,6 @@ void ETag_surfxml_host()    {
   host.coord       = A_surfxml_host_coordinates;
 
   sg_platf_new_host(&host);
-  xbt_dynar_free(&host.speed_per_pstate);
   current_property_set = nullptr;
 }