Daniel Carvalho has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/45435 )
Change subject: sim,misc: Rename Float namespace as as_double
......................................................................
sim,misc: Rename Float namespace as as_double
As part of recent decisions regarding namespace
naming conventions, all namespaces will be changed
to snake case.
sim_clock::Float became sim_clock::as_double.
"as_double" was chosen because "float" and "double"
are reserved keywords, and this namespace acts as
a selector of how to read the internal variables.
Another possibility to resolve this would be to
remove the namespaces "Float" and "Int" and use
unions instead.
Change-Id: I7b3d9c6e9ab547493d5596c7eda080a25509a730
Signed-off-by: Daniel R. Carvalho <[email protected]>
---
M src/arch/arm/semihosting.cc
M src/base/time.cc
M src/cpu/kvm/timer.hh
M src/cpu/kvm/x86_cpu.cc
M src/dev/arm/rv_ctrl.cc
M src/dev/intel_8254_timer.cc
M src/mem/comm_monitor.cc
M src/mem/qos/mem_ctrl.cc
M src/sim/core.cc
M src/sim/core.hh
M src/systemc/core/sc_time.cc
M src/systemc/utils/vcd.cc
12 files changed, 36 insertions(+), 35 deletions(-)
diff --git a/src/arch/arm/semihosting.cc b/src/arch/arm/semihosting.cc
index 00c8396..f2a7280 100644
--- a/src/arch/arm/semihosting.cc
+++ b/src/arch/arm/semihosting.cc
@@ -506,7 +506,7 @@
ArmSemihosting::RetErrno
ArmSemihosting::callTime(ThreadContext *tc)
{
- return retOK(timeBase + round(curTick() / sim_clock::Float::s));
+ return retOK(timeBase + round(curTick() / sim_clock::as_double::s));
}
ArmSemihosting::RetErrno
diff --git a/src/base/time.cc b/src/base/time.cc
index 35e1260..66d9f1e 100644
--- a/src/base/time.cc
+++ b/src/base/time.cc
@@ -55,7 +55,7 @@
{
uint64_t secs = ticks / sim_clock::Frequency;
ticks -= secs * sim_clock::Frequency;
- uint64_t nsecs = static_cast<uint64_t>(ticks * sim_clock::Float::GHz);
+ uint64_t nsecs = static_cast<uint64_t>(ticks *
sim_clock::as_double::GHz);
set(secs, nsecs);
}
@@ -63,7 +63,7 @@
Time::getTick() const
{
return sec() * sim_clock::Frequency +
- static_cast<uint64_t>(nsec() * sim_clock::Float::ns);
+ static_cast<uint64_t>(nsec() * sim_clock::as_double::ns);
}
std::string
diff --git a/src/cpu/kvm/timer.hh b/src/cpu/kvm/timer.hh
index cbfc9e4..c43bb46 100644
--- a/src/cpu/kvm/timer.hh
+++ b/src/cpu/kvm/timer.hh
@@ -129,7 +129,7 @@
* @return Nanoseconds executed in VM converted to simulation ticks
*/
Tick ticksFromHostNs(uint64_t ns) {
- return ns * hostFactor * sim_clock::Float::ns;
+ return ns * hostFactor * sim_clock::as_double::ns;
}
protected:
@@ -147,7 +147,7 @@
* @return Simulation ticks converted into nanoseconds on the host
*/
uint64_t hostNs(Tick ticks) {
- return ticks / (sim_clock::Float::ns * hostFactor);
+ return ticks / (sim_clock::as_double::ns * hostFactor);
}
/**
diff --git a/src/cpu/kvm/x86_cpu.cc b/src/cpu/kvm/x86_cpu.cc
index 8d8b777..a69f904 100644
--- a/src/cpu/kvm/x86_cpu.cc
+++ b/src/cpu/kvm/x86_cpu.cc
@@ -1247,7 +1247,7 @@
// Limit the run to 1 millisecond. That is hopefully enough to
// reach an interrupt window. Otherwise, we'll just try again
// later.
- return BaseKvmCPU::kvmRun(1 * sim_clock::Float::ms);
+ return BaseKvmCPU::kvmRun(1 * sim_clock::as_double::ms);
} else {
DPRINTF(Drain, "kvmRunDrain: Delivering pending IO\n");
diff --git a/src/dev/arm/rv_ctrl.cc b/src/dev/arm/rv_ctrl.cc
index 63000bf..6daf9e7 100644
--- a/src/dev/arm/rv_ctrl.cc
+++ b/src/dev/arm/rv_ctrl.cc
@@ -66,12 +66,12 @@
break;
case Clock24:
Tick clk;
- clk = sim_clock::Float::MHz * curTick() * 24;
+ clk = sim_clock::as_double::MHz * curTick() * 24;
pkt->setLE((uint32_t)(clk));
break;
case Clock100:
Tick clk100;
- clk100 = sim_clock::Float::MHz * curTick() * 100;
+ clk100 = sim_clock::as_double::MHz * curTick() * 100;
pkt->setLE((uint32_t)(clk100));
break;
case Flash:
@@ -239,9 +239,9 @@
RealViewCtrl::Device(*p.parent, RealViewCtrl::FUNC_OSC,
p.site, p.position, p.dcc, p.device)
{
- if (sim_clock::Float::s / p.freq > UINT32_MAX) {
+ if (sim_clock::as_double::s / p.freq > UINT32_MAX) {
fatal("Oscillator frequency out of range: %f\n",
- sim_clock::Float::s / p.freq / 1E6);
+ sim_clock::as_double::s / p.freq / 1E6);
}
_clockPeriod = p.freq;
@@ -286,7 +286,7 @@
uint32_t
RealViewOsc::read() const
{
- const uint32_t freq(sim_clock::Float::s / _clockPeriod);
+ const uint32_t freq(sim_clock::as_double::s / _clockPeriod);
DPRINTF(RVCTRL, "Reading OSC frequency: %f MHz\n", freq / 1E6);
return freq;
}
@@ -295,7 +295,7 @@
RealViewOsc::write(uint32_t freq)
{
DPRINTF(RVCTRL, "Setting new OSC frequency: %f MHz\n", freq / 1E6);
- clockPeriod(sim_clock::Float::s / freq);
+ clockPeriod(sim_clock::as_double::s / freq);
}
uint32_t
diff --git a/src/dev/intel_8254_timer.cc b/src/dev/intel_8254_timer.cc
index 6035639..4f9ddb7 100644
--- a/src/dev/intel_8254_timer.cc
+++ b/src/dev/intel_8254_timer.cc
@@ -271,7 +271,7 @@
Intel8254Timer::Counter::CounterEvent::CounterEvent(Counter* c_ptr)
{
- interval = (Tick)(sim_clock::Float::s / 1193180.0);
+ interval = (Tick)(sim_clock::as_double::s / 1193180.0);
counter = c_ptr;
}
diff --git a/src/mem/comm_monitor.cc b/src/mem/comm_monitor.cc
index 32fed10..3c51257 100644
--- a/src/mem/comm_monitor.cc
+++ b/src/mem/comm_monitor.cc
@@ -49,7 +49,7 @@
cpuSidePort(name() + "-cpu_side_port", *this),
samplePeriodicEvent([this]{ samplePeriodic(); }, name()),
samplePeriodTicks(params.sample_period),
- samplePeriod(params.sample_period / sim_clock::Float::s),
+ samplePeriod(params.sample_period / sim_clock::as_double::s),
stats(this, params)
{
DPRINTF(CommMonitor,
diff --git a/src/mem/qos/mem_ctrl.cc b/src/mem/qos/mem_ctrl.cc
index 1dbef1c..3deef0d 100644
--- a/src/mem/qos/mem_ctrl.cc
+++ b/src/mem/qos/mem_ctrl.cc
@@ -184,7 +184,7 @@
}
// Compute latency
double latency = (double) (curTick() + delay - requestTime)
- / sim_clock::Float::s;
+ / sim_clock::as_double::s;
if (latency > 0) {
// Record per-priority latency stats
diff --git a/src/sim/core.cc b/src/sim/core.cc
index 68ed7b9..0b7e647 100644
--- a/src/sim/core.cc
+++ b/src/sim/core.cc
@@ -42,7 +42,7 @@
/// The simulated frequency of curTick(). (In ticks per second)
Tick Frequency;
-namespace Float {
+namespace as_double {
double s;
double ms;
double us;
@@ -53,7 +53,7 @@
double kHz;
double MHz;
double GHz;
-} // namespace Float
+} // namespace as_double
namespace Int {
Tick s;
@@ -61,7 +61,7 @@
Tick us;
Tick ns;
Tick ps;
-} // namespace Float
+} // namespace as_double
} // namespace sim_clock
@@ -82,16 +82,16 @@
using namespace sim_clock;
Frequency = _ticksPerSecond;
- Float::s = static_cast<double>(Frequency);
- Float::ms = Float::s / 1.0e3;
- Float::us = Float::s / 1.0e6;
- Float::ns = Float::s / 1.0e9;
- Float::ps = Float::s / 1.0e12;
+ as_double::s = static_cast<double>(Frequency);
+ as_double::ms = as_double::s / 1.0e3;
+ as_double::us = as_double::s / 1.0e6;
+ as_double::ns = as_double::s / 1.0e9;
+ as_double::ps = as_double::s / 1.0e12;
- Float::Hz = 1.0 / Float::s;
- Float::kHz = 1.0 / Float::ms;
- Float::MHz = 1.0 / Float::us;
- Float::GHz = 1.0 / Float::ns;
+ as_double::Hz = 1.0 / as_double::s;
+ as_double::kHz = 1.0 / as_double::ms;
+ as_double::MHz = 1.0 / as_double::us;
+ as_double::GHz = 1.0 / as_double::ns;
Int::s = Frequency;
Int::ms = Int::s / 1000;
diff --git a/src/sim/core.hh b/src/sim/core.hh
index 6561bea..2c28c09 100644
--- a/src/sim/core.hh
+++ b/src/sim/core.hh
@@ -50,7 +50,8 @@
namespace sim_clock {
extern Tick Frequency; ///< The number of ticks that equal one second
-namespace Float {
+GEM5_DEPRECATED_NAMESPACE(Float, as_double);
+namespace as_double {
/** These variables equal the number of ticks in the unit of time they're
* named after in a double.
@@ -71,7 +72,7 @@
extern double MHz; ///< MHz
extern double GHz; ///< GHz
/** @}*/
-} // namespace Float
+} // namespace as_double
/** These variables equal the number of ticks in the unit of time they're
* named after in a 64 bit integer.
diff --git a/src/systemc/core/sc_time.cc b/src/systemc/core/sc_time.cc
index 0c7e3a5..b9732da 100644
--- a/src/systemc/core/sc_time.cc
+++ b/src/systemc/core/sc_time.cc
@@ -50,7 +50,7 @@
if (d != 0)
fixClockFrequency();
- double scale = sc_gem5::TimeUnitScale[tu] * sim_clock::Float::s;
+ double scale = sc_gem5::TimeUnitScale[tu] * sim_clock::as_double::s;
// Accellera claims there is a linux bug, and that these next two
// lines work around them.
volatile double tmp = d * scale + 0.5;
@@ -94,13 +94,13 @@
sc_time::sc_time(double d, bool scale)
{
- double scaler = scale ? defaultUnit : sim_clock::Float::Hz;
+ double scaler = scale ? defaultUnit : sim_clock::as_double::Hz;
set(this, d * scaler, SC_SEC);
}
sc_time::sc_time(sc_dt::uint64 v, bool scale)
{
- double scaler = scale ? defaultUnit : sim_clock::Float::Hz;
+ double scaler = scale ? defaultUnit : sim_clock::as_double::Hz;
set(this, static_cast<double>(v) * scaler, SC_SEC);
}
@@ -125,7 +125,7 @@
double
sc_time::to_seconds() const
{
- return to_double() * sim_clock::Float::Hz;
+ return to_double() * sim_clock::as_double::Hz;
}
const std::string
@@ -377,7 +377,7 @@
defaultUnit = d * sc_gem5::TimeUnitScale[tu];
specified = true;
- double resolution = sim_clock::Float::Hz;
+ double resolution = sim_clock::as_double::Hz;
if (resolution == 0.0)
resolution = sc_gem5::TimeUnitScale[SC_PS];
if (defaultUnit < resolution) {
diff --git a/src/systemc/utils/vcd.cc b/src/systemc/utils/vcd.cc
index 7fd9ba1..c43639f 100644
--- a/src/systemc/utils/vcd.cc
+++ b/src/systemc/utils/vcd.cc
@@ -254,7 +254,7 @@
std::string timedump_comment =
csprintf("All initial values are dumped below at time "
"%g sec = %g timescale units.",
- static_cast<double>(now) / sim_clock::Float::s,
+ static_cast<double>(now) / sim_clock::as_double::s,
static_cast<double>(now / timeUnitTicks));
writeComment(timedump_comment);
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/45435
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: I7b3d9c6e9ab547493d5596c7eda080a25509a730
Gerrit-Change-Number: 45435
Gerrit-PatchSet: 1
Gerrit-Owner: Daniel Carvalho <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s