From 3d025b517fb75de9e1ed509735c5bfb5fe214007 Mon Sep 17 00:00:00 2001 From: Davide Basilio Bartolini Date: Tue, 28 Sep 2021 12:00:13 +0200 Subject: [PATCH] misc: Fix hdf5 stats + test HDF5 stats file creation was not completing correctly due to name clashes. Change-Id: Ifc2d52f4bbc62b0c6798ce92f4d027b0ec69a373 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/51061 Reviewed-by: Bobby R. Bruce Maintainer: Bobby R. Bruce Tested-by: kokoro --- src/base/stats/hdf5.cc | 4 ++++ src/cpu/o3/iew.cc | 2 +- src/mem/mem_interface.cc | 8 -------- tests/gem5/stats/test_hdf5.py | 14 +++++++++++--- tests/gem5/verifier.py | 15 +++++++++++++++ 5 files changed, 31 insertions(+), 12 deletions(-) diff --git a/src/base/stats/hdf5.cc b/src/base/stats/hdf5.cc index 90bd8cd51b..d5b7f1ecf4 100644 --- a/src/base/stats/hdf5.cc +++ b/src/base/stats/hdf5.cc @@ -39,6 +39,8 @@ #include "base/logging.hh" #include "base/stats/info.hh" +#include "base/trace.hh" +#include "debug/Stats.hh" namespace gem5 { @@ -254,6 +256,8 @@ Hdf5::appendStat(const Info &info, int rank, hsize_t *dims, const double *data) fspace = H5::DataSpace(rank, dims, max_dims.data()); try { + DPRINTF(Stats, "Creating dataset %s in group %s\n", + info.name, group.getObjName()); data_set = group.createDataSet(info.name, H5::PredType::NATIVE_DOUBLE, fspace, props); } catch (const H5::Exception &e) { diff --git a/src/cpu/o3/iew.cc b/src/cpu/o3/iew.cc index 7cdc8d8fc6..d899e8b128 100644 --- a/src/cpu/o3/iew.cc +++ b/src/cpu/o3/iew.cc @@ -143,7 +143,7 @@ IEW::regProbePoints() } IEW::IEWStats::IEWStats(CPU *cpu) - : statistics::Group(cpu), + : statistics::Group(cpu, "iew"), ADD_STAT(idleCycles, statistics::units::Cycle::get(), "Number of cycles IEW is idle"), ADD_STAT(squashCycles, statistics::units::Cycle::get(), diff --git a/src/mem/mem_interface.cc b/src/mem/mem_interface.cc index 8036acad6f..a3e5963a1a 100644 --- a/src/mem/mem_interface.cc +++ b/src/mem/mem_interface.cc @@ -1893,10 +1893,6 @@ DRAMInterface::DRAMStats::DRAMStats(DRAMInterface &_dram) ADD_STAT(bytesPerActivate, statistics::units::Byte::get(), "Bytes accessed per row activation"), - ADD_STAT(bytesRead, statistics::units::Byte::get(), - "Total number of bytes read from DRAM"), - ADD_STAT(bytesWritten, statistics::units::Byte::get(), - "Total number of bytes written to DRAM"), ADD_STAT(avgRdBW, statistics::units::Rate< statistics::units::Byte, statistics::units::Second>::get(), "Average DRAM read bandwidth in MiBytes/s"), @@ -2548,10 +2544,6 @@ NVMInterface::NVMStats::NVMStats(NVMInterface &_nvm) statistics::units::Tick, statistics::units::Count>::get(), "Average memory access latency per NVM burst"), - ADD_STAT(bytesRead, statistics::units::Byte::get(), - "Total number of bytes read from NVM"), - ADD_STAT(bytesWritten, statistics::units::Byte::get(), - "Total number of bytes written to NVM"), ADD_STAT(avgRdBW, statistics::units::Rate< statistics::units::Byte, statistics::units::Second>::get(), "Average DRAM read bandwidth in MiBytes/s"), diff --git a/tests/gem5/stats/test_hdf5.py b/tests/gem5/stats/test_hdf5.py index ad730f3bec..545ef58ede 100644 --- a/tests/gem5/stats/test_hdf5.py +++ b/tests/gem5/stats/test_hdf5.py @@ -44,7 +44,6 @@ import re import os from testlib import * - if config.bin_path: resource_path = config.bin_path else: @@ -68,12 +67,20 @@ if have_hdf5(): ok_exit_regex = re.compile( r"Exiting @ tick \d+ because exiting with last active thread context" ) + ok_verifier = verifier.MatchRegex(ok_exit_regex) + + # FIXME: flaky, should check return code instead... + # See: https://gem5.atlassian.net/browse/GEM5-1099 + err_regex = re.compile( + r'RuntimeError: Failed creating H5::DataSet \w+; .*' + ) + err_verifier = verifier.NoMatchRegex(err_regex, True, False) - stdout_verifier = verifier.MatchRegex(ok_exit_regex) h5_verifier = verifier.CheckH5StatsExist() + gem5_verify_config( name="hdf5_test", - verifiers=[stdout_verifier, h5_verifier], + verifiers=[ok_verifier, err_verifier, h5_verifier], fixtures=(), config=joinpath( config.base_dir, @@ -92,3 +99,4 @@ if have_hdf5(): gem5_args=["--stats-file=h5://stats.h5"], valid_isas=(constants.arm_tag,), ) + diff --git a/tests/gem5/verifier.py b/tests/gem5/verifier.py index f6687f58e5..c947a62825 100644 --- a/tests/gem5/verifier.py +++ b/tests/gem5/verifier.py @@ -229,6 +229,21 @@ class MatchRegex(MatchFileRegex): filenames.append(constants.gem5_simulation_stderr) super(MatchRegex, self).__init__(regex, filenames) +class NoMatchRegex(MatchRegex): + """ + Checks that the given pattern does *not* match + """ + def __init__(self, regex, match_stderr=True, match_stdout=True): + super(NoMatchRegex, self).__init__(regex, match_stderr, match_stdout) + + def test(self, params): + fixtures = params.fixtures + tempdir = fixtures[constants.tempdir_fixture_name].path + + for fname in self.filenames: + if self.parse_file(joinpath(tempdir, fname)): + test_util.fail('Could not match regex.') + _re_type = type(re.compile('')) def _iterable_regex(regex): if isinstance(regex, _re_type) or isinstance(regex, str):