Ciro Santilli has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/31895 )

Change subject: sim: add UNSERIALIZE_ARRAY_INCOMPLETE
......................................................................

sim: add UNSERIALIZE_ARRAY_INCOMPLETE

This new serialization method allows the number of unserialized array
elements to be smaller than the new number of elements.

This allows new entries to be added to the end of arrays without breaking
checkpoints.

Change-Id: Ia9588dde24d1eb988d34789fca2883a1c9e7b39d
---
M src/sim/serialize.hh
1 file changed, 22 insertions(+), 5 deletions(-)



diff --git a/src/sim/serialize.hh b/src/sim/serialize.hh
index 1f31dd2..b8c0c8c 100644
--- a/src/sim/serialize.hh
+++ b/src/sim/serialize.hh
@@ -586,7 +586,7 @@
 template <class T>
 void
 arrayParamIn(CheckpointIn &cp, const std::string &name,
-             T *param, unsigned size)
+             T *param, unsigned size, bool exact_size = true)
 {
     const std::string &section(Serializable::currentSection());
     std::string str;
@@ -604,9 +604,15 @@
     // Need this if we were doing a vector
     // value.resize(tokens.size());

-    fatal_if(tokens.size() != size,
-             "Array size mismatch on %s:%s (Got %u, expected %u)'\n",
-             section, name, tokens.size(), size);
+    if (exact_size) {
+        fatal_if(tokens.size() != size,
+                 "Array size mismatch on %s:%s (Got %u, expected %u)'\n",
+                 section, name, tokens.size(), size);
+    } else {
+        fatal_if(tokens.size() > size,
+                 "Array size smaller on %s:%s (Got %u, expected %u)'\n",
+                 section, name, tokens.size(), size);
+    }

for (std::vector<std::string>::size_type i = 0; i < tokens.size(); i++) {
         // need to parse into local variable to handle vector<bool>,
@@ -717,8 +723,8 @@
     std::string str;
     if (!cp.find(section, name, str)) {
         fatal("Can't unserialize '%s:%s'\n", section, name);
-    }
     param.clear();
+    }

     std::vector<std::string> tokens;
     tokenize(tokens, str, ' ');
@@ -814,6 +820,17 @@
         arrayParamIn(cp, #member, member, size)

 /**
+ * \def UNSERIALIZE_ARRAY_INCOMPLETE(member, size)
+ *
+ * Unserialize an array, and allow the serialization data to be
+ * smaller than the container size.
+ *
+ * @ingroup api_serialize
+ */
+#define UNSERIALIZE_ARRAY_INCOMPLETE(member, size)         \
+        arrayParamIn(cp, #member, member, size, false)
+
+/**
  * \def SERIALIZE_CONTAINER(member)
  *
  * @ingroup api_serialize

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/31895
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Ia9588dde24d1eb988d34789fca2883a1c9e7b39d
Gerrit-Change-Number: 31895
Gerrit-PatchSet: 1
Gerrit-Owner: Ciro Santilli <ciro.santi...@arm.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to