From 4de65bbd573a00a5be8ec5b8231a29d130f866bd Mon Sep 17 00:00:00 2001 From: Arthur perais Date: Sun, 15 Sep 2024 20:46:00 +0200 Subject: [PATCH 1/2] misc: Remove Serialize-related code in Random The Random ser/des support has been non-existent since 2014. Removing it will enable the Random class to be unit tested without having a dependency on the src/sim code. --- src/base/random.cc | 28 ---------------------------- src/base/random.hh | 8 +------- 2 files changed, 1 insertion(+), 35 deletions(-) diff --git a/src/base/random.cc b/src/base/random.cc index 0315b6e6e6..3077bcd92f 100644 --- a/src/base/random.cc +++ b/src/base/random.cc @@ -43,7 +43,6 @@ #include #include "base/logging.hh" -#include "sim/serialize.hh" namespace gem5 { @@ -69,33 +68,6 @@ Random::init(uint32_t s) gen.seed(s); } -void -Random::serialize(CheckpointOut &cp) const -{ - panic("Currently not used anywhere.\n"); - - // get the state from the generator - std::ostringstream oss; - oss << gen; - std::string state = oss.str(); - paramOut(cp, "mt_state", state); -} - -void -Random::unserialize(CheckpointIn &cp) -{ - panic("Currently not used anywhere.\n"); - - // the random generator state did not use to be part of the - // checkpoint state, so be forgiving in the unserialization and - // keep on going if the parameter is not there - std::string state; - if (optParamIn(cp, "mt_state", state)) { - std::istringstream iss(state); - iss >> gen; - } -} - Random random_mt; } // namespace gem5 diff --git a/src/base/random.hh b/src/base/random.hh index 5e6cf23f90..bc692411bd 100644 --- a/src/base/random.hh +++ b/src/base/random.hh @@ -51,14 +51,11 @@ #include "base/compiler.hh" #include "base/types.hh" -#include "sim/serialize.hh" namespace gem5 { -class Checkpoint; - -class Random : public Serializable +class Random { public: @@ -115,9 +112,6 @@ class Random : public Serializable std::uniform_int_distribution dist(min, max); return dist(gen); } - - void serialize(CheckpointOut &cp) const override; - void unserialize(CheckpointIn &cp) override; }; /** From 85210cf51daf35514823ddcda4ad45bd33a853b9 Mon Sep 17 00:00:00 2001 From: Arthur perais Date: Wed, 18 Sep 2024 13:43:37 +0200 Subject: [PATCH 2/2] misc: Remove unecessary include in random.hh --- src/base/random.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/base/random.cc b/src/base/random.cc index 3077bcd92f..e861767c1e 100644 --- a/src/base/random.cc +++ b/src/base/random.cc @@ -42,8 +42,6 @@ #include -#include "base/logging.hh" - namespace gem5 {