statistics.cc revision 11681
12SN/A/*
21762SN/A * Copyright (c) 2003-2005 The Regents of The University of Michigan
32SN/A * All rights reserved.
42SN/A *
52SN/A * Redistribution and use in source and binary forms, with or without
62SN/A * modification, are permitted provided that the following conditions are
72SN/A * met: redistributions of source code must retain the above copyright
82SN/A * notice, this list of conditions and the following disclaimer;
92SN/A * redistributions in binary form must reproduce the above copyright
102SN/A * notice, this list of conditions and the following disclaimer in the
112SN/A * documentation and/or other materials provided with the distribution;
122SN/A * neither the name of the copyright holders nor the names of its
132SN/A * contributors may be used to endorse or promote products derived from
142SN/A * this software without specific prior written permission.
152SN/A *
162SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272665Ssaidi@eecs.umich.edu *
282665Ssaidi@eecs.umich.edu * Authors: Nathan Binkert
292SN/A */
302SN/A
318229Snate@binkert.org#include <fstream>
322SN/A#include <iomanip>
332SN/A#include <list>
342SN/A#include <map>
352SN/A#include <string>
362SN/A
37148SN/A#include "base/callback.hh"
3856SN/A#include "base/cprintf.hh"
395889Snate@binkert.org#include "base/debug.hh"
40441SN/A#include "base/hostinfo.hh"
4156SN/A#include "base/misc.hh"
4256SN/A#include "base/statistics.hh"
4356SN/A#include "base/str.hh"
44441SN/A#include "base/time.hh"
45433SN/A#include "base/trace.hh"
462SN/A
472SN/Ausing namespace std;
482SN/A
49729SN/Anamespace Stats {
50388SN/A
518243Sbradley.danofsky@amd.comstd::string Info::separatorString = "::";
525887Snate@binkert.org
535887Snate@binkert.org// We wrap these in a function to make sure they're built in time.
545887Snate@binkert.orglist<Info *> &
555887Snate@binkert.orgstatsList()
56388SN/A{
575887Snate@binkert.org    static list<Info *> the_list;
585887Snate@binkert.org    return the_list;
59388SN/A}
60388SN/A
615887Snate@binkert.orgMapType &
625887Snate@binkert.orgstatsMap()
63441SN/A{
645887Snate@binkert.org    static MapType the_map;
655887Snate@binkert.org    return the_map;
66441SN/A}
67441SN/A
68388SN/Avoid
695886Snate@binkert.orgInfoAccess::setInfo(Info *info)
70388SN/A{
715887Snate@binkert.org    if (statsMap().find(this) != statsMap().end())
725887Snate@binkert.org        panic("shouldn't register stat twice!");
735887Snate@binkert.org
745887Snate@binkert.org    statsList().push_back(info);
755887Snate@binkert.org
765887Snate@binkert.org#ifndef NDEBUG
775887Snate@binkert.org    pair<MapType::iterator, bool> result =
785887Snate@binkert.org#endif
795887Snate@binkert.org        statsMap().insert(make_pair(this, info));
805887Snate@binkert.org    assert(result.second && "this should never fail");
815887Snate@binkert.org    assert(statsMap().find(this) != statsMap().end());
82388SN/A}
83388SN/A
84388SN/Avoid
855889Snate@binkert.orgInfoAccess::setParams(const StorageParams *params)
865889Snate@binkert.org{
875889Snate@binkert.org    info()->storageParams = params;
885889Snate@binkert.org}
895889Snate@binkert.org
905889Snate@binkert.orgvoid
915886Snate@binkert.orgInfoAccess::setInit()
92388SN/A{
936130Snate@binkert.org    info()->flags.set(init);
94388SN/A}
95388SN/A
965886Snate@binkert.orgInfo *
975886Snate@binkert.orgInfoAccess::info()
98388SN/A{
995887Snate@binkert.org    MapType::const_iterator i = statsMap().find(this);
1005887Snate@binkert.org    assert(i != statsMap().end());
1015887Snate@binkert.org    return (*i).second;
102388SN/A}
103388SN/A
1045886Snate@binkert.orgconst Info *
1055886Snate@binkert.orgInfoAccess::info() const
1065886Snate@binkert.org{
1075887Snate@binkert.org    MapType::const_iterator i = statsMap().find(this);
1085887Snate@binkert.org    assert(i != statsMap().end());
1095887Snate@binkert.org    return (*i).second;
1105886Snate@binkert.org}
1115886Snate@binkert.org
1125889Snate@binkert.orgStorageParams::~StorageParams()
1135889Snate@binkert.org{
1145889Snate@binkert.org}
1155889Snate@binkert.org
1166026Snate@binkert.orgNameMapType &
1176026Snate@binkert.orgnameMap()
1186026Snate@binkert.org{
1196026Snate@binkert.org    static NameMapType the_map;
1206026Snate@binkert.org    return the_map;
1216026Snate@binkert.org}
1226026Snate@binkert.org
1235889Snate@binkert.orgint Info::id_count = 0;
1245889Snate@binkert.org
1255889Snate@binkert.orgint debug_break_id = -1;
1265889Snate@binkert.org
1275886Snate@binkert.orgInfo::Info()
1285889Snate@binkert.org    : flags(none), precision(-1), prereq(0), storageParams(NULL)
129582SN/A{
1305889Snate@binkert.org    id = id_count++;
1315889Snate@binkert.org    if (debug_break_id >= 0 and debug_break_id == id)
1328231Snate@binkert.org        Debug::breakpoint();
133582SN/A}
134582SN/A
1355886Snate@binkert.orgInfo::~Info()
136388SN/A{
137388SN/A}
138388SN/A
1398248Snate@binkert.orgbool
1408248Snate@binkert.orgvalidateStatName(const string &name)
1418248Snate@binkert.org{
1428248Snate@binkert.org    if (name.empty())
1438248Snate@binkert.org        return false;
1448248Snate@binkert.org
1458248Snate@binkert.org    vector<string> vec;
1468248Snate@binkert.org    tokenize(vec, name, '.');
1478248Snate@binkert.org    vector<string>::const_iterator item = vec.begin();
1488248Snate@binkert.org    while (item != vec.end()) {
1498248Snate@binkert.org        if (item->empty())
1508248Snate@binkert.org            return false;
1518248Snate@binkert.org
1528248Snate@binkert.org        string::const_iterator c = item->begin();
1538248Snate@binkert.org
1548248Snate@binkert.org        // The first character is different
1558248Snate@binkert.org        if (!isalpha(*c) && *c != '_')
1568248Snate@binkert.org            return false;
1578248Snate@binkert.org
1588248Snate@binkert.org        // The rest of the characters have different rules.
1598248Snate@binkert.org        while (++c != item->end()) {
1608248Snate@binkert.org            if (!isalnum(*c) && *c != '_')
1618248Snate@binkert.org                return false;
1628248Snate@binkert.org        }
1638248Snate@binkert.org
1648248Snate@binkert.org        ++item;
1658248Snate@binkert.org    }
1668248Snate@binkert.org
1678248Snate@binkert.org    return true;
1688248Snate@binkert.org}
1698248Snate@binkert.org
1706026Snate@binkert.orgvoid
1716026Snate@binkert.orgInfo::setName(const string &name)
1726026Snate@binkert.org{
1738248Snate@binkert.org    if (!validateStatName(name))
1748248Snate@binkert.org        panic("invalid stat name '%s'", name);
1758248Snate@binkert.org
1766026Snate@binkert.org    pair<NameMapType::iterator, bool> p =
1776026Snate@binkert.org        nameMap().insert(make_pair(name, this));
1786026Snate@binkert.org
1796026Snate@binkert.org    Info *other = p.first->second;
1806026Snate@binkert.org    bool result = p.second;
18111320Ssteve.reinhardt@amd.com
1826026Snate@binkert.org    if (!result) {
18311666Stushar@ece.gatech.edu      // using other->name instead of just name to avoid a compiler
18411666Stushar@ece.gatech.edu      // warning.  They should be the same.
1856026Snate@binkert.org        panic("same statistic name used twice! name=%s\n", other->name);
1866026Snate@binkert.org    }
1876026Snate@binkert.org
1886026Snate@binkert.org    this->name = name;
1896026Snate@binkert.org}
1906026Snate@binkert.org
1912SN/Abool
1925886Snate@binkert.orgInfo::less(Info *stat1, Info *stat2)
1932SN/A{
194388SN/A    const string &name1 = stat1->name;
195388SN/A    const string &name2 = stat2->name;
1962SN/A
1972SN/A    vector<string> v1;
1982SN/A    vector<string> v2;
1992SN/A
2002SN/A    tokenize(v1, name1, '.');
2012SN/A    tokenize(v2, name2, '.');
2022SN/A
2035599Snate@binkert.org    size_type last = min(v1.size(), v2.size()) - 1;
2045599Snate@binkert.org    for (off_type i = 0; i < last; ++i)
2052SN/A        if (v1[i] != v2[i])
2062SN/A            return v1[i] < v2[i];
2072SN/A
2082SN/A    // Special compare for last element.
2092SN/A    if (v1[last] == v2[last])
2102SN/A        return v1.size() < v2.size();
2112SN/A    else
2122SN/A        return v1[last] < v2[last];
2132SN/A
2142SN/A    return false;
2152SN/A}
2162SN/A
217388SN/Abool
2185886Snate@binkert.orgInfo::baseCheck() const
2192SN/A{
2206000Snate@binkert.org    if (!(flags & Stats::init)) {
221582SN/A#ifdef DEBUG
222695SN/A        cprintf("this is stat number %d\n", id);
223388SN/A#endif
22411681Spowerjg@cs.wisc.edu        panic("Not all stats have been initialized.\n"
22511681Spowerjg@cs.wisc.edu              "You may need to add <ParentClass>::regStats() to a"
22611681Spowerjg@cs.wisc.edu              " new SimObject's regStats() function.");
227388SN/A        return false;
228388SN/A    }
2292SN/A
2307462Snate@binkert.org    if ((flags & display) && name.empty()) {
231388SN/A        panic("all printable stats must be named");
232388SN/A        return false;
233388SN/A    }
2342SN/A
235388SN/A    return true;
2362SN/A}
2372SN/A
2386001Snate@binkert.orgvoid
2396001Snate@binkert.orgInfo::enable()
2406001Snate@binkert.org{
2416001Snate@binkert.org}
2426001Snate@binkert.org
2436001Snate@binkert.orgvoid
2446128Snate@binkert.orgVectorInfo::enable()
2456001Snate@binkert.org{
2466001Snate@binkert.org    size_type s = size();
2476001Snate@binkert.org    if (subnames.size() < s)
2486001Snate@binkert.org        subnames.resize(s);
2496001Snate@binkert.org    if (subdescs.size() < s)
2506001Snate@binkert.org        subdescs.resize(s);
2516001Snate@binkert.org}
2526001Snate@binkert.org
2536001Snate@binkert.orgvoid
2546128Snate@binkert.orgVectorDistInfo::enable()
2556001Snate@binkert.org{
2566001Snate@binkert.org    size_type s = size();
2576001Snate@binkert.org    if (subnames.size() < s)
2586001Snate@binkert.org        subnames.resize(s);
2596001Snate@binkert.org    if (subdescs.size() < s)
2606001Snate@binkert.org        subdescs.resize(s);
2616001Snate@binkert.org}
2626001Snate@binkert.org
2636001Snate@binkert.orgvoid
2646128Snate@binkert.orgVector2dInfo::enable()
2656001Snate@binkert.org{
2666001Snate@binkert.org    if (subnames.size() < x)
2676001Snate@binkert.org        subnames.resize(x);
2686001Snate@binkert.org    if (subdescs.size() < x)
2696001Snate@binkert.org        subdescs.resize(x);
2706001Snate@binkert.org    if (y_subnames.size() < y)
2716001Snate@binkert.org        y_subnames.resize(y);
2726001Snate@binkert.org}
273695SN/A
2747831Snate@binkert.orgvoid
2757831Snate@binkert.orgHistStor::grow_out()
2767831Snate@binkert.org{
2777831Snate@binkert.org    int size = cvec.size();
2787831Snate@binkert.org    int zero = size / 2; // round down!
2797831Snate@binkert.org    int top_half = zero + (size - zero + 1) / 2; // round up!
2807831Snate@binkert.org    int bottom_half = (size - zero) / 2; // round down!
2817831Snate@binkert.org
2827831Snate@binkert.org    // grow down
2837831Snate@binkert.org    int low_pair = zero - 1;
2847831Snate@binkert.org    for (int i = zero - 1; i >= bottom_half; i--) {
2857831Snate@binkert.org        cvec[i] = cvec[low_pair];
2867831Snate@binkert.org        if (low_pair - 1 >= 0)
2877831Snate@binkert.org            cvec[i] += cvec[low_pair - 1];
2887831Snate@binkert.org        low_pair -= 2;
2897831Snate@binkert.org    }
2907831Snate@binkert.org    assert(low_pair == 0 || low_pair == -1 || low_pair == -2);
2917831Snate@binkert.org
2927831Snate@binkert.org    for (int i = bottom_half - 1; i >= 0; i--)
2937831Snate@binkert.org        cvec[i] = Counter();
2947831Snate@binkert.org
2957831Snate@binkert.org    // grow up
2967831Snate@binkert.org    int high_pair = zero;
2977831Snate@binkert.org    for (int i = zero; i < top_half; i++) {
2987831Snate@binkert.org        cvec[i] = cvec[high_pair];
2997831Snate@binkert.org        if (high_pair + 1 < size)
3007831Snate@binkert.org            cvec[i] += cvec[high_pair + 1];
3017831Snate@binkert.org        high_pair += 2;
3027831Snate@binkert.org    }
3037831Snate@binkert.org    assert(high_pair == size || high_pair == size + 1);
3047831Snate@binkert.org
3057831Snate@binkert.org    for (int i = top_half; i < size; i++)
3067831Snate@binkert.org        cvec[i] = Counter();
3077831Snate@binkert.org
3087831Snate@binkert.org    max_bucket *= 2;
3097831Snate@binkert.org    min_bucket *= 2;
3107831Snate@binkert.org    bucket_size *= 2;
3117831Snate@binkert.org}
3127831Snate@binkert.org
3137831Snate@binkert.orgvoid
3147831Snate@binkert.orgHistStor::grow_convert()
3157831Snate@binkert.org{
3167831Snate@binkert.org    int size = cvec.size();
3177831Snate@binkert.org    int half = (size + 1) / 2; // round up!
3187831Snate@binkert.org    //bool even = (size & 1) == 0;
3197831Snate@binkert.org
3207831Snate@binkert.org    int pair = size - 1;
3217831Snate@binkert.org    for (int i = size - 1; i >= half; --i) {
3227831Snate@binkert.org        cvec[i] = cvec[pair];
3237831Snate@binkert.org        if (pair - 1 >= 0)
3247831Snate@binkert.org            cvec[i] += cvec[pair - 1];
3257831Snate@binkert.org        pair -= 2;
3267831Snate@binkert.org    }
3277831Snate@binkert.org
3287831Snate@binkert.org    for (int i = half - 1; i >= 0; i--)
3297831Snate@binkert.org        cvec[i] = Counter();
3307831Snate@binkert.org
3317831Snate@binkert.org    min_bucket = -max_bucket;// - (even ? bucket_size : 0);
3327831Snate@binkert.org    bucket_size *= 2;
3337831Snate@binkert.org}
3347831Snate@binkert.org
3357831Snate@binkert.orgvoid
3367831Snate@binkert.orgHistStor::grow_up()
3377831Snate@binkert.org{
3387831Snate@binkert.org    int size = cvec.size();
3397831Snate@binkert.org    int half = (size + 1) / 2; // round up!
3407831Snate@binkert.org
3417831Snate@binkert.org    int pair = 0;
3427831Snate@binkert.org    for (int i = 0; i < half; i++) {
3437831Snate@binkert.org        cvec[i] = cvec[pair];
3447831Snate@binkert.org        if (pair + 1 < size)
3457831Snate@binkert.org            cvec[i] += cvec[pair + 1];
3467831Snate@binkert.org        pair += 2;
3477831Snate@binkert.org    }
3487831Snate@binkert.org    assert(pair == size || pair == size + 1);
3497831Snate@binkert.org
3507831Snate@binkert.org    for (int i = half; i < size; i++)
3517831Snate@binkert.org        cvec[i] = Counter();
3527831Snate@binkert.org
3537831Snate@binkert.org    max_bucket *= 2;
3547831Snate@binkert.org    bucket_size *= 2;
3557831Snate@binkert.org}
3567831Snate@binkert.org
35710011Snilay@cs.wisc.eduvoid
35810011Snilay@cs.wisc.eduHistStor::add(HistStor *hs)
35910011Snilay@cs.wisc.edu{
36010011Snilay@cs.wisc.edu    int b_size = hs->size();
36110011Snilay@cs.wisc.edu    assert(size() == b_size);
36210011Snilay@cs.wisc.edu    assert(min_bucket == hs->min_bucket);
36310011Snilay@cs.wisc.edu
36410011Snilay@cs.wisc.edu    sum += hs->sum;
36510011Snilay@cs.wisc.edu    logs += hs->logs;
36610011Snilay@cs.wisc.edu    squares += hs->squares;
36710011Snilay@cs.wisc.edu    samples += hs->samples;
36810011Snilay@cs.wisc.edu
36911321Ssteve.reinhardt@amd.com    while (bucket_size > hs->bucket_size)
37010011Snilay@cs.wisc.edu        hs->grow_up();
37111321Ssteve.reinhardt@amd.com    while (bucket_size < hs->bucket_size)
37210011Snilay@cs.wisc.edu        grow_up();
37310011Snilay@cs.wisc.edu
37410011Snilay@cs.wisc.edu    for (uint32_t i = 0; i < b_size; i++)
37510011Snilay@cs.wisc.edu        cvec[i] += hs->cvec[i];
37610011Snilay@cs.wisc.edu}
37710011Snilay@cs.wisc.edu
378388SN/AFormula::Formula()
379388SN/A{
380388SN/A}
381388SN/A
382388SN/AFormula::Formula(Temp r)
383388SN/A{
38410491Sandreas.hansson@arm.com    root = r.getNodePtr();
3857461Snate@binkert.org    setInit();
386388SN/A    assert(size());
387388SN/A}
388388SN/A
389388SN/Aconst Formula &
390388SN/AFormula::operator=(Temp r)
391388SN/A{
392388SN/A    assert(!root && "Can't change formulas");
39310491Sandreas.hansson@arm.com    root = r.getNodePtr();
3947461Snate@binkert.org    setInit();
395388SN/A    assert(size());
396388SN/A    return *this;
397388SN/A}
398388SN/A
399388SN/Aconst Formula &
400388SN/AFormula::operator+=(Temp r)
401388SN/A{
402388SN/A    if (root)
403695SN/A        root = NodePtr(new BinaryNode<std::plus<Result> >(root, r));
4047461Snate@binkert.org    else {
40510491Sandreas.hansson@arm.com        root = r.getNodePtr();
4067461Snate@binkert.org        setInit();
4077461Snate@binkert.org    }
4087461Snate@binkert.org
409388SN/A    assert(size());
410388SN/A    return *this;
411388SN/A}
412388SN/A
4139857Snilay@cs.wisc.educonst Formula &
4149857Snilay@cs.wisc.eduFormula::operator/=(Temp r)
4159857Snilay@cs.wisc.edu{
4169857Snilay@cs.wisc.edu    assert (root);
4179857Snilay@cs.wisc.edu    root = NodePtr(new BinaryNode<std::divides<Result> >(root, r));
4189857Snilay@cs.wisc.edu
4199857Snilay@cs.wisc.edu    assert(size());
4209857Snilay@cs.wisc.edu    return *this;
4219857Snilay@cs.wisc.edu}
4229857Snilay@cs.wisc.edu
423142SN/Avoid
4246000Snate@binkert.orgFormula::result(VResult &vec) const
4256000Snate@binkert.org{
4266000Snate@binkert.org    if (root)
4276000Snate@binkert.org        vec = root->result();
4286000Snate@binkert.org}
4296000Snate@binkert.org
4306000Snate@binkert.orgResult
4316000Snate@binkert.orgFormula::total() const
4326000Snate@binkert.org{
4336000Snate@binkert.org    return root ? root->total() : 0.0;
4346000Snate@binkert.org}
4356000Snate@binkert.org
4366000Snate@binkert.orgsize_type
4376000Snate@binkert.orgFormula::size() const
4386000Snate@binkert.org{
4396000Snate@binkert.org    if (!root)
4406000Snate@binkert.org        return 0;
4416000Snate@binkert.org    else
4426000Snate@binkert.org        return root->size();
4436000Snate@binkert.org}
4446000Snate@binkert.org
4456000Snate@binkert.orgvoid
4466000Snate@binkert.orgFormula::reset()
4476000Snate@binkert.org{
4486000Snate@binkert.org}
4496000Snate@binkert.org
4506000Snate@binkert.orgbool
4516000Snate@binkert.orgFormula::zero() const
4526000Snate@binkert.org{
4536000Snate@binkert.org    VResult vec;
4546000Snate@binkert.org    result(vec);
4556227Snate@binkert.org    for (VResult::size_type i = 0; i < vec.size(); ++i)
4566000Snate@binkert.org        if (vec[i] != 0.0)
4576000Snate@binkert.org            return false;
4586000Snate@binkert.org    return true;
4596000Snate@binkert.org}
4606000Snate@binkert.org
4616000Snate@binkert.orgstring
4626000Snate@binkert.orgFormula::str() const
4636000Snate@binkert.org{
4646000Snate@binkert.org    return root ? root->str() : "";
4656000Snate@binkert.org}
4666000Snate@binkert.org
46710453SAndrew.Bardsley@arm.comHandler resetHandler = NULL;
46810453SAndrew.Bardsley@arm.comHandler dumpHandler = NULL;
46910453SAndrew.Bardsley@arm.com
47010453SAndrew.Bardsley@arm.comvoid
47110453SAndrew.Bardsley@arm.comregisterHandlers(Handler reset_handler, Handler dump_handler)
47210453SAndrew.Bardsley@arm.com{
47310453SAndrew.Bardsley@arm.com    resetHandler = reset_handler;
47410453SAndrew.Bardsley@arm.com    dumpHandler = dump_handler;
47510453SAndrew.Bardsley@arm.com}
47610453SAndrew.Bardsley@arm.com
4779042SMitchell.Hayenga@ARM.comCallbackQueue dumpQueue;
478695SN/ACallbackQueue resetQueue;
4792SN/A
480456SN/Avoid
48110453SAndrew.Bardsley@arm.comprocessResetQueue()
48210453SAndrew.Bardsley@arm.com{
48310453SAndrew.Bardsley@arm.com    resetQueue.process();
48410453SAndrew.Bardsley@arm.com}
48510453SAndrew.Bardsley@arm.com
48610453SAndrew.Bardsley@arm.comvoid
48710453SAndrew.Bardsley@arm.comprocessDumpQueue()
48810453SAndrew.Bardsley@arm.com{
48910453SAndrew.Bardsley@arm.com    dumpQueue.process();
49010453SAndrew.Bardsley@arm.com}
49110453SAndrew.Bardsley@arm.com
49210453SAndrew.Bardsley@arm.comvoid
493394SN/AregisterResetCallback(Callback *cb)
494148SN/A{
495148SN/A    resetQueue.add(cb);
496148SN/A}
497148SN/A
4988986SAli.Saidi@ARM.combool _enabled = false;
4998986SAli.Saidi@ARM.com
5008986SAli.Saidi@ARM.combool
5018986SAli.Saidi@ARM.comenabled()
5028986SAli.Saidi@ARM.com{
5038986SAli.Saidi@ARM.com    return _enabled;
5048986SAli.Saidi@ARM.com}
5058986SAli.Saidi@ARM.com
5068986SAli.Saidi@ARM.comvoid
5078986SAli.Saidi@ARM.comenable()
5088986SAli.Saidi@ARM.com{
5098986SAli.Saidi@ARM.com    if (_enabled)
5108986SAli.Saidi@ARM.com        fatal("Stats are already enabled");
5118986SAli.Saidi@ARM.com
5128986SAli.Saidi@ARM.com    _enabled = true;
5138986SAli.Saidi@ARM.com}
5148986SAli.Saidi@ARM.com
5159042SMitchell.Hayenga@ARM.comvoid
51610453SAndrew.Bardsley@arm.comdump()
51710453SAndrew.Bardsley@arm.com{
51810453SAndrew.Bardsley@arm.com    if (dumpHandler)
51910453SAndrew.Bardsley@arm.com        dumpHandler();
52010453SAndrew.Bardsley@arm.com    else
52110453SAndrew.Bardsley@arm.com        fatal("No registered Stats::dump handler");
52210453SAndrew.Bardsley@arm.com}
52310453SAndrew.Bardsley@arm.com
52410453SAndrew.Bardsley@arm.comvoid
52510453SAndrew.Bardsley@arm.comreset()
52610453SAndrew.Bardsley@arm.com{
52710453SAndrew.Bardsley@arm.com    if (resetHandler)
52810453SAndrew.Bardsley@arm.com        resetHandler();
52910453SAndrew.Bardsley@arm.com    else
53010453SAndrew.Bardsley@arm.com        fatal("No registered Stats::reset handler");
53110453SAndrew.Bardsley@arm.com}
53210453SAndrew.Bardsley@arm.com
53310453SAndrew.Bardsley@arm.comvoid
5349042SMitchell.Hayenga@ARM.comregisterDumpCallback(Callback *cb)
5359042SMitchell.Hayenga@ARM.com{
5369042SMitchell.Hayenga@ARM.com    dumpQueue.add(cb);
5379042SMitchell.Hayenga@ARM.com}
5389042SMitchell.Hayenga@ARM.com
5397811Ssteve.reinhardt@amd.com} // namespace Stats
5408296Snate@binkert.org
5418296Snate@binkert.orgvoid
5428296Snate@binkert.orgdebugDumpStats()
5438296Snate@binkert.org{
5448296Snate@binkert.org    Stats::dump();
5458296Snate@binkert.org}
546