sim,misc: Rename Float namespace as as_float

As part of recent decisions regarding namespace
naming conventions, all namespaces will be changed
to snake case.

sim_clock::Float became sim_clock::as_float.

"as_float" was chosen because "float" is a 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 <odanrc@yahoo.com.br>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/45435
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Hoa Nguyen <hoanguyen@ucdavis.edu>
Maintainer: Gabe Black <gabe.black@gmail.com>
This commit is contained in:
Daniel R. Carvalho
2021-05-07 15:54:51 -03:00
committed by Daniel Carvalho
parent d5ad966da5
commit c487767cff
12 changed files with 39 additions and 35 deletions

View File

@@ -506,7 +506,7 @@ ArmSemihosting::callClock(ThreadContext *tc)
ArmSemihosting::RetErrno
ArmSemihosting::callTime(ThreadContext *tc)
{
return retOK(timeBase + round(curTick() / sim_clock::Float::s));
return retOK(timeBase + round(curTick() / sim_clock::as_float::s));
}
ArmSemihosting::RetErrno

View File

@@ -55,7 +55,7 @@ Time::setTick(Tick ticks)
{
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_float::GHz);
set(secs, nsecs);
}
@@ -63,7 +63,7 @@ Tick
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_float::ns);
}
std::string

View File

@@ -129,7 +129,7 @@ class BaseKvmTimer
* @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_float::ns;
}
protected:
@@ -147,7 +147,7 @@ class BaseKvmTimer
* @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_float::ns * hostFactor);
}
/**

View File

@@ -1248,7 +1248,7 @@ X86KvmCPU::kvmRunDrain()
// 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_float::ms);
} else {
DPRINTF(Drain, "kvmRunDrain: Delivering pending IO\n");

View File

@@ -66,12 +66,12 @@ RealViewCtrl::read(PacketPtr pkt)
break;
case Clock24:
Tick clk;
clk = sim_clock::Float::MHz * curTick() * 24;
clk = sim_clock::as_float::MHz * curTick() * 24;
pkt->setLE((uint32_t)(clk));
break;
case Clock100:
Tick clk100;
clk100 = sim_clock::Float::MHz * curTick() * 100;
clk100 = sim_clock::as_float::MHz * curTick() * 100;
pkt->setLE((uint32_t)(clk100));
break;
case Flash:
@@ -239,9 +239,9 @@ RealViewOsc::RealViewOsc(const RealViewOscParams &p)
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_float::s / p.freq > UINT32_MAX) {
fatal("Oscillator frequency out of range: %f\n",
sim_clock::Float::s / p.freq / 1E6);
sim_clock::as_float::s / p.freq / 1E6);
}
_clockPeriod = p.freq;
@@ -286,7 +286,7 @@ RealViewOsc::clockPeriod(Tick clock_period)
uint32_t
RealViewOsc::read() const
{
const uint32_t freq(sim_clock::Float::s / _clockPeriod);
const uint32_t freq(sim_clock::as_float::s / _clockPeriod);
DPRINTF(RVCTRL, "Reading OSC frequency: %f MHz\n", freq / 1E6);
return freq;
}
@@ -295,7 +295,7 @@ void
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_float::s / freq);
}
uint32_t

View File

@@ -271,7 +271,7 @@ Intel8254Timer::Counter::startup()
Intel8254Timer::Counter::CounterEvent::CounterEvent(Counter* c_ptr)
{
interval = (Tick)(sim_clock::Float::s / 1193180.0);
interval = (Tick)(sim_clock::as_float::s / 1193180.0);
counter = c_ptr;
}

View File

@@ -49,7 +49,7 @@ CommMonitor::CommMonitor(const Params &params)
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_float::s),
stats(this, params)
{
DPRINTF(CommMonitor,

View File

@@ -184,7 +184,7 @@ MemCtrl::logResponse(BusState dir, RequestorID id, uint8_t qos,
}
// Compute latency
double latency = (double) (curTick() + delay - requestTime)
/ sim_clock::Float::s;
/ sim_clock::as_float::s;
if (latency > 0) {
// Record per-priority latency stats

View File

@@ -44,7 +44,9 @@ namespace sim_clock
/// The simulated frequency of curTick(). (In ticks per second)
Tick Frequency;
namespace Float {
GEM5_DEPRECATED_NAMESPACE(Float, as_float);
namespace as_float
{
double s;
double ms;
double us;
@@ -55,7 +57,7 @@ double Hz;
double kHz;
double MHz;
double GHz;
} // namespace Float
} // namespace as_float
namespace Int {
Tick s;
@@ -63,7 +65,7 @@ Tick ms;
Tick us;
Tick ns;
Tick ps;
} // namespace Float
} // namespace as_float
} // namespace sim_clock
@@ -84,16 +86,16 @@ fixClockFrequency()
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_float::s = static_cast<double>(Frequency);
as_float::ms = as_float::s / 1.0e3;
as_float::us = as_float::s / 1.0e6;
as_float::ns = as_float::s / 1.0e9;
as_float::ps = as_float::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_float::Hz = 1.0 / as_float::s;
as_float::kHz = 1.0 / as_float::ms;
as_float::MHz = 1.0 / as_float::us;
as_float::GHz = 1.0 / as_float::ns;
Int::s = Frequency;
Int::ms = Int::s / 1000;

View File

@@ -51,7 +51,9 @@ namespace sim_clock
{
extern Tick Frequency; ///< The number of ticks that equal one second
namespace Float {
GEM5_DEPRECATED_NAMESPACE(Float, as_float);
namespace as_float
{
/** These variables equal the number of ticks in the unit of time they're
* named after in a double.
@@ -72,7 +74,7 @@ extern double kHz; ///< kHz
extern double MHz; ///< MHz
extern double GHz; ///< GHz
/** @}*/
} // namespace Float
} // namespace as_float
/** These variables equal the number of ticks in the unit of time they're
* named after in a 64 bit integer.

View File

@@ -50,7 +50,7 @@ set(::sc_core::sc_time *time, double d, ::sc_core::sc_time_unit tu)
if (d != 0)
fixClockFrequency();
double scale = sc_gem5::TimeUnitScale[tu] * sim_clock::Float::s;
double scale = sc_gem5::TimeUnitScale[tu] * sim_clock::as_float::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, const char *unit)
sc_time::sc_time(double d, bool scale)
{
double scaler = scale ? defaultUnit : sim_clock::Float::Hz;
double scaler = scale ? defaultUnit : sim_clock::as_float::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_float::Hz;
set(this, static_cast<double>(v) * scaler, SC_SEC);
}
@@ -125,7 +125,7 @@ sc_time::to_double() const
double
sc_time::to_seconds() const
{
return to_double() * sim_clock::Float::Hz;
return to_double() * sim_clock::as_float::Hz;
}
const std::string
@@ -377,7 +377,7 @@ sc_set_default_time_unit(double d, sc_time_unit tu)
defaultUnit = d * sc_gem5::TimeUnitScale[tu];
specified = true;
double resolution = sim_clock::Float::Hz;
double resolution = sim_clock::as_float::Hz;
if (resolution == 0.0)
resolution = sc_gem5::TimeUnitScale[SC_PS];
if (defaultUnit < resolution) {

View File

@@ -254,7 +254,7 @@ VcdTraceFile::initialize()
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_float::s,
static_cast<double>(now / timeUnitTicks));
writeComment(timedump_comment);