statistics.cc revision 11793
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
3111793Sbrandon.potter@amd.com#include "base/statistics.hh"
3211793Sbrandon.potter@amd.com
338229Snate@binkert.org#include <fstream>
342SN/A#include <iomanip>
352SN/A#include <list>
362SN/A#include <map>
372SN/A#include <string>
382SN/A
39148SN/A#include "base/callback.hh"
4056SN/A#include "base/cprintf.hh"
415889Snate@binkert.org#include "base/debug.hh"
42441SN/A#include "base/hostinfo.hh"
4356SN/A#include "base/misc.hh"
4456SN/A#include "base/str.hh"
45441SN/A#include "base/time.hh"
46433SN/A#include "base/trace.hh"
472SN/A
482SN/Ausing namespace std;
492SN/A
50729SN/Anamespace Stats {
51388SN/A
528243Sbradley.danofsky@amd.comstd::string Info::separatorString = "::";
535887Snate@binkert.org
545887Snate@binkert.org// We wrap these in a function to make sure they're built in time.
555887Snate@binkert.orglist<Info *> &
565887Snate@binkert.orgstatsList()
57388SN/A{
585887Snate@binkert.org    static list<Info *> the_list;
595887Snate@binkert.org    return the_list;
60388SN/A}
61388SN/A
625887Snate@binkert.orgMapType &
635887Snate@binkert.orgstatsMap()
64441SN/A{
655887Snate@binkert.org    static MapType the_map;
665887Snate@binkert.org    return the_map;
67441SN/A}
68441SN/A
69388SN/Avoid
705886Snate@binkert.orgInfoAccess::setInfo(Info *info)
71388SN/A{
725887Snate@binkert.org    if (statsMap().find(this) != statsMap().end())
735887Snate@binkert.org        panic("shouldn't register stat twice!");
745887Snate@binkert.org
755887Snate@binkert.org    statsList().push_back(info);
765887Snate@binkert.org
775887Snate@binkert.org#ifndef NDEBUG
785887Snate@binkert.org    pair<MapType::iterator, bool> result =
795887Snate@binkert.org#endif
805887Snate@binkert.org        statsMap().insert(make_pair(this, info));
815887Snate@binkert.org    assert(result.second && "this should never fail");
825887Snate@binkert.org    assert(statsMap().find(this) != statsMap().end());
83388SN/A}
84388SN/A
85388SN/Avoid
865889Snate@binkert.orgInfoAccess::setParams(const StorageParams *params)
875889Snate@binkert.org{
885889Snate@binkert.org    info()->storageParams = params;
895889Snate@binkert.org}
905889Snate@binkert.org
915889Snate@binkert.orgvoid
925886Snate@binkert.orgInfoAccess::setInit()
93388SN/A{
946130Snate@binkert.org    info()->flags.set(init);
95388SN/A}
96388SN/A
975886Snate@binkert.orgInfo *
985886Snate@binkert.orgInfoAccess::info()
99388SN/A{
1005887Snate@binkert.org    MapType::const_iterator i = statsMap().find(this);
1015887Snate@binkert.org    assert(i != statsMap().end());
1025887Snate@binkert.org    return (*i).second;
103388SN/A}
104388SN/A
1055886Snate@binkert.orgconst Info *
1065886Snate@binkert.orgInfoAccess::info() const
1075886Snate@binkert.org{
1085887Snate@binkert.org    MapType::const_iterator i = statsMap().find(this);
1095887Snate@binkert.org    assert(i != statsMap().end());
1105887Snate@binkert.org    return (*i).second;
1115886Snate@binkert.org}
1125886Snate@binkert.org
1135889Snate@binkert.orgStorageParams::~StorageParams()
1145889Snate@binkert.org{
1155889Snate@binkert.org}
1165889Snate@binkert.org
1176026Snate@binkert.orgNameMapType &
1186026Snate@binkert.orgnameMap()
1196026Snate@binkert.org{
1206026Snate@binkert.org    static NameMapType the_map;
1216026Snate@binkert.org    return the_map;
1226026Snate@binkert.org}
1236026Snate@binkert.org
1245889Snate@binkert.orgint Info::id_count = 0;
1255889Snate@binkert.org
1265889Snate@binkert.orgint debug_break_id = -1;
1275889Snate@binkert.org
1285886Snate@binkert.orgInfo::Info()
1295889Snate@binkert.org    : flags(none), precision(-1), prereq(0), storageParams(NULL)
130582SN/A{
1315889Snate@binkert.org    id = id_count++;
1325889Snate@binkert.org    if (debug_break_id >= 0 and debug_break_id == id)
1338231Snate@binkert.org        Debug::breakpoint();
134582SN/A}
135582SN/A
1365886Snate@binkert.orgInfo::~Info()
137388SN/A{
138388SN/A}
139388SN/A
1408248Snate@binkert.orgbool
1418248Snate@binkert.orgvalidateStatName(const string &name)
1428248Snate@binkert.org{
1438248Snate@binkert.org    if (name.empty())
1448248Snate@binkert.org        return false;
1458248Snate@binkert.org
1468248Snate@binkert.org    vector<string> vec;
1478248Snate@binkert.org    tokenize(vec, name, '.');
1488248Snate@binkert.org    vector<string>::const_iterator item = vec.begin();
1498248Snate@binkert.org    while (item != vec.end()) {
1508248Snate@binkert.org        if (item->empty())
1518248Snate@binkert.org            return false;
1528248Snate@binkert.org
1538248Snate@binkert.org        string::const_iterator c = item->begin();
1548248Snate@binkert.org
1558248Snate@binkert.org        // The first character is different
1568248Snate@binkert.org        if (!isalpha(*c) && *c != '_')
1578248Snate@binkert.org            return false;
1588248Snate@binkert.org
1598248Snate@binkert.org        // The rest of the characters have different rules.
1608248Snate@binkert.org        while (++c != item->end()) {
1618248Snate@binkert.org            if (!isalnum(*c) && *c != '_')
1628248Snate@binkert.org                return false;
1638248Snate@binkert.org        }
1648248Snate@binkert.org
1658248Snate@binkert.org        ++item;
1668248Snate@binkert.org    }
1678248Snate@binkert.org
1688248Snate@binkert.org    return true;
1698248Snate@binkert.org}
1708248Snate@binkert.org
1716026Snate@binkert.orgvoid
1726026Snate@binkert.orgInfo::setName(const string &name)
1736026Snate@binkert.org{
1748248Snate@binkert.org    if (!validateStatName(name))
1758248Snate@binkert.org        panic("invalid stat name '%s'", name);
1768248Snate@binkert.org
1776026Snate@binkert.org    pair<NameMapType::iterator, bool> p =
1786026Snate@binkert.org        nameMap().insert(make_pair(name, this));
1796026Snate@binkert.org
1806026Snate@binkert.org    Info *other = p.first->second;
1816026Snate@binkert.org    bool result = p.second;
18211320Ssteve.reinhardt@amd.com
1836026Snate@binkert.org    if (!result) {
18411666Stushar@ece.gatech.edu      // using other->name instead of just name to avoid a compiler
18511666Stushar@ece.gatech.edu      // warning.  They should be the same.
1866026Snate@binkert.org        panic("same statistic name used twice! name=%s\n", other->name);
1876026Snate@binkert.org    }
1886026Snate@binkert.org
1896026Snate@binkert.org    this->name = name;
1906026Snate@binkert.org}
1916026Snate@binkert.org
1922SN/Abool
1935886Snate@binkert.orgInfo::less(Info *stat1, Info *stat2)
1942SN/A{
195388SN/A    const string &name1 = stat1->name;
196388SN/A    const string &name2 = stat2->name;
1972SN/A
1982SN/A    vector<string> v1;
1992SN/A    vector<string> v2;
2002SN/A
2012SN/A    tokenize(v1, name1, '.');
2022SN/A    tokenize(v2, name2, '.');
2032SN/A
2045599Snate@binkert.org    size_type last = min(v1.size(), v2.size()) - 1;
2055599Snate@binkert.org    for (off_type i = 0; i < last; ++i)
2062SN/A        if (v1[i] != v2[i])
2072SN/A            return v1[i] < v2[i];
2082SN/A
2092SN/A    // Special compare for last element.
2102SN/A    if (v1[last] == v2[last])
2112SN/A        return v1.size() < v2.size();
2122SN/A    else
2132SN/A        return v1[last] < v2[last];
2142SN/A
2152SN/A    return false;
2162SN/A}
2172SN/A
218388SN/Abool
2195886Snate@binkert.orgInfo::baseCheck() const
2202SN/A{
2216000Snate@binkert.org    if (!(flags & Stats::init)) {
222582SN/A#ifdef DEBUG
223695SN/A        cprintf("this is stat number %d\n", id);
224388SN/A#endif
22511681Spowerjg@cs.wisc.edu        panic("Not all stats have been initialized.\n"
22611681Spowerjg@cs.wisc.edu              "You may need to add <ParentClass>::regStats() to a"
22711681Spowerjg@cs.wisc.edu              " new SimObject's regStats() function.");
228388SN/A        return false;
229388SN/A    }
2302SN/A
2317462Snate@binkert.org    if ((flags & display) && name.empty()) {
232388SN/A        panic("all printable stats must be named");
233388SN/A        return false;
234388SN/A    }
2352SN/A
236388SN/A    return true;
2372SN/A}
2382SN/A
2396001Snate@binkert.orgvoid
2406001Snate@binkert.orgInfo::enable()
2416001Snate@binkert.org{
2426001Snate@binkert.org}
2436001Snate@binkert.org
2446001Snate@binkert.orgvoid
2456128Snate@binkert.orgVectorInfo::enable()
2466001Snate@binkert.org{
2476001Snate@binkert.org    size_type s = size();
2486001Snate@binkert.org    if (subnames.size() < s)
2496001Snate@binkert.org        subnames.resize(s);
2506001Snate@binkert.org    if (subdescs.size() < s)
2516001Snate@binkert.org        subdescs.resize(s);
2526001Snate@binkert.org}
2536001Snate@binkert.org
2546001Snate@binkert.orgvoid
2556128Snate@binkert.orgVectorDistInfo::enable()
2566001Snate@binkert.org{
2576001Snate@binkert.org    size_type s = size();
2586001Snate@binkert.org    if (subnames.size() < s)
2596001Snate@binkert.org        subnames.resize(s);
2606001Snate@binkert.org    if (subdescs.size() < s)
2616001Snate@binkert.org        subdescs.resize(s);
2626001Snate@binkert.org}
2636001Snate@binkert.org
2646001Snate@binkert.orgvoid
2656128Snate@binkert.orgVector2dInfo::enable()
2666001Snate@binkert.org{
2676001Snate@binkert.org    if (subnames.size() < x)
2686001Snate@binkert.org        subnames.resize(x);
2696001Snate@binkert.org    if (subdescs.size() < x)
2706001Snate@binkert.org        subdescs.resize(x);
2716001Snate@binkert.org    if (y_subnames.size() < y)
2726001Snate@binkert.org        y_subnames.resize(y);
2736001Snate@binkert.org}
274695SN/A
2757831Snate@binkert.orgvoid
2767831Snate@binkert.orgHistStor::grow_out()
2777831Snate@binkert.org{
2787831Snate@binkert.org    int size = cvec.size();
2797831Snate@binkert.org    int zero = size / 2; // round down!
2807831Snate@binkert.org    int top_half = zero + (size - zero + 1) / 2; // round up!
2817831Snate@binkert.org    int bottom_half = (size - zero) / 2; // round down!
2827831Snate@binkert.org
2837831Snate@binkert.org    // grow down
2847831Snate@binkert.org    int low_pair = zero - 1;
2857831Snate@binkert.org    for (int i = zero - 1; i >= bottom_half; i--) {
2867831Snate@binkert.org        cvec[i] = cvec[low_pair];
2877831Snate@binkert.org        if (low_pair - 1 >= 0)
2887831Snate@binkert.org            cvec[i] += cvec[low_pair - 1];
2897831Snate@binkert.org        low_pair -= 2;
2907831Snate@binkert.org    }
2917831Snate@binkert.org    assert(low_pair == 0 || low_pair == -1 || low_pair == -2);
2927831Snate@binkert.org
2937831Snate@binkert.org    for (int i = bottom_half - 1; i >= 0; i--)
2947831Snate@binkert.org        cvec[i] = Counter();
2957831Snate@binkert.org
2967831Snate@binkert.org    // grow up
2977831Snate@binkert.org    int high_pair = zero;
2987831Snate@binkert.org    for (int i = zero; i < top_half; i++) {
2997831Snate@binkert.org        cvec[i] = cvec[high_pair];
3007831Snate@binkert.org        if (high_pair + 1 < size)
3017831Snate@binkert.org            cvec[i] += cvec[high_pair + 1];
3027831Snate@binkert.org        high_pair += 2;
3037831Snate@binkert.org    }
3047831Snate@binkert.org    assert(high_pair == size || high_pair == size + 1);
3057831Snate@binkert.org
3067831Snate@binkert.org    for (int i = top_half; i < size; i++)
3077831Snate@binkert.org        cvec[i] = Counter();
3087831Snate@binkert.org
3097831Snate@binkert.org    max_bucket *= 2;
3107831Snate@binkert.org    min_bucket *= 2;
3117831Snate@binkert.org    bucket_size *= 2;
3127831Snate@binkert.org}
3137831Snate@binkert.org
3147831Snate@binkert.orgvoid
3157831Snate@binkert.orgHistStor::grow_convert()
3167831Snate@binkert.org{
3177831Snate@binkert.org    int size = cvec.size();
3187831Snate@binkert.org    int half = (size + 1) / 2; // round up!
3197831Snate@binkert.org    //bool even = (size & 1) == 0;
3207831Snate@binkert.org
3217831Snate@binkert.org    int pair = size - 1;
3227831Snate@binkert.org    for (int i = size - 1; i >= half; --i) {
3237831Snate@binkert.org        cvec[i] = cvec[pair];
3247831Snate@binkert.org        if (pair - 1 >= 0)
3257831Snate@binkert.org            cvec[i] += cvec[pair - 1];
3267831Snate@binkert.org        pair -= 2;
3277831Snate@binkert.org    }
3287831Snate@binkert.org
3297831Snate@binkert.org    for (int i = half - 1; i >= 0; i--)
3307831Snate@binkert.org        cvec[i] = Counter();
3317831Snate@binkert.org
3327831Snate@binkert.org    min_bucket = -max_bucket;// - (even ? bucket_size : 0);
3337831Snate@binkert.org    bucket_size *= 2;
3347831Snate@binkert.org}
3357831Snate@binkert.org
3367831Snate@binkert.orgvoid
3377831Snate@binkert.orgHistStor::grow_up()
3387831Snate@binkert.org{
3397831Snate@binkert.org    int size = cvec.size();
3407831Snate@binkert.org    int half = (size + 1) / 2; // round up!
3417831Snate@binkert.org
3427831Snate@binkert.org    int pair = 0;
3437831Snate@binkert.org    for (int i = 0; i < half; i++) {
3447831Snate@binkert.org        cvec[i] = cvec[pair];
3457831Snate@binkert.org        if (pair + 1 < size)
3467831Snate@binkert.org            cvec[i] += cvec[pair + 1];
3477831Snate@binkert.org        pair += 2;
3487831Snate@binkert.org    }
3497831Snate@binkert.org    assert(pair == size || pair == size + 1);
3507831Snate@binkert.org
3517831Snate@binkert.org    for (int i = half; i < size; i++)
3527831Snate@binkert.org        cvec[i] = Counter();
3537831Snate@binkert.org
3547831Snate@binkert.org    max_bucket *= 2;
3557831Snate@binkert.org    bucket_size *= 2;
3567831Snate@binkert.org}
3577831Snate@binkert.org
35810011Snilay@cs.wisc.eduvoid
35910011Snilay@cs.wisc.eduHistStor::add(HistStor *hs)
36010011Snilay@cs.wisc.edu{
36110011Snilay@cs.wisc.edu    int b_size = hs->size();
36210011Snilay@cs.wisc.edu    assert(size() == b_size);
36310011Snilay@cs.wisc.edu    assert(min_bucket == hs->min_bucket);
36410011Snilay@cs.wisc.edu
36510011Snilay@cs.wisc.edu    sum += hs->sum;
36610011Snilay@cs.wisc.edu    logs += hs->logs;
36710011Snilay@cs.wisc.edu    squares += hs->squares;
36810011Snilay@cs.wisc.edu    samples += hs->samples;
36910011Snilay@cs.wisc.edu
37011321Ssteve.reinhardt@amd.com    while (bucket_size > hs->bucket_size)
37110011Snilay@cs.wisc.edu        hs->grow_up();
37211321Ssteve.reinhardt@amd.com    while (bucket_size < hs->bucket_size)
37310011Snilay@cs.wisc.edu        grow_up();
37410011Snilay@cs.wisc.edu
37510011Snilay@cs.wisc.edu    for (uint32_t i = 0; i < b_size; i++)
37610011Snilay@cs.wisc.edu        cvec[i] += hs->cvec[i];
37710011Snilay@cs.wisc.edu}
37810011Snilay@cs.wisc.edu
379388SN/AFormula::Formula()
380388SN/A{
381388SN/A}
382388SN/A
383388SN/AFormula::Formula(Temp r)
384388SN/A{
38510491Sandreas.hansson@arm.com    root = r.getNodePtr();
3867461Snate@binkert.org    setInit();
387388SN/A    assert(size());
388388SN/A}
389388SN/A
390388SN/Aconst Formula &
391388SN/AFormula::operator=(Temp r)
392388SN/A{
393388SN/A    assert(!root && "Can't change formulas");
39410491Sandreas.hansson@arm.com    root = r.getNodePtr();
3957461Snate@binkert.org    setInit();
396388SN/A    assert(size());
397388SN/A    return *this;
398388SN/A}
399388SN/A
400388SN/Aconst Formula &
401388SN/AFormula::operator+=(Temp r)
402388SN/A{
403388SN/A    if (root)
404695SN/A        root = NodePtr(new BinaryNode<std::plus<Result> >(root, r));
4057461Snate@binkert.org    else {
40610491Sandreas.hansson@arm.com        root = r.getNodePtr();
4077461Snate@binkert.org        setInit();
4087461Snate@binkert.org    }
4097461Snate@binkert.org
410388SN/A    assert(size());
411388SN/A    return *this;
412388SN/A}
413388SN/A
4149857Snilay@cs.wisc.educonst Formula &
4159857Snilay@cs.wisc.eduFormula::operator/=(Temp r)
4169857Snilay@cs.wisc.edu{
4179857Snilay@cs.wisc.edu    assert (root);
4189857Snilay@cs.wisc.edu    root = NodePtr(new BinaryNode<std::divides<Result> >(root, r));
4199857Snilay@cs.wisc.edu
4209857Snilay@cs.wisc.edu    assert(size());
4219857Snilay@cs.wisc.edu    return *this;
4229857Snilay@cs.wisc.edu}
4239857Snilay@cs.wisc.edu
424142SN/Avoid
4256000Snate@binkert.orgFormula::result(VResult &vec) const
4266000Snate@binkert.org{
4276000Snate@binkert.org    if (root)
4286000Snate@binkert.org        vec = root->result();
4296000Snate@binkert.org}
4306000Snate@binkert.org
4316000Snate@binkert.orgResult
4326000Snate@binkert.orgFormula::total() const
4336000Snate@binkert.org{
4346000Snate@binkert.org    return root ? root->total() : 0.0;
4356000Snate@binkert.org}
4366000Snate@binkert.org
4376000Snate@binkert.orgsize_type
4386000Snate@binkert.orgFormula::size() const
4396000Snate@binkert.org{
4406000Snate@binkert.org    if (!root)
4416000Snate@binkert.org        return 0;
4426000Snate@binkert.org    else
4436000Snate@binkert.org        return root->size();
4446000Snate@binkert.org}
4456000Snate@binkert.org
4466000Snate@binkert.orgvoid
4476000Snate@binkert.orgFormula::reset()
4486000Snate@binkert.org{
4496000Snate@binkert.org}
4506000Snate@binkert.org
4516000Snate@binkert.orgbool
4526000Snate@binkert.orgFormula::zero() const
4536000Snate@binkert.org{
4546000Snate@binkert.org    VResult vec;
4556000Snate@binkert.org    result(vec);
4566227Snate@binkert.org    for (VResult::size_type i = 0; i < vec.size(); ++i)
4576000Snate@binkert.org        if (vec[i] != 0.0)
4586000Snate@binkert.org            return false;
4596000Snate@binkert.org    return true;
4606000Snate@binkert.org}
4616000Snate@binkert.org
4626000Snate@binkert.orgstring
4636000Snate@binkert.orgFormula::str() const
4646000Snate@binkert.org{
4656000Snate@binkert.org    return root ? root->str() : "";
4666000Snate@binkert.org}
4676000Snate@binkert.org
46810453SAndrew.Bardsley@arm.comHandler resetHandler = NULL;
46910453SAndrew.Bardsley@arm.comHandler dumpHandler = NULL;
47010453SAndrew.Bardsley@arm.com
47110453SAndrew.Bardsley@arm.comvoid
47210453SAndrew.Bardsley@arm.comregisterHandlers(Handler reset_handler, Handler dump_handler)
47310453SAndrew.Bardsley@arm.com{
47410453SAndrew.Bardsley@arm.com    resetHandler = reset_handler;
47510453SAndrew.Bardsley@arm.com    dumpHandler = dump_handler;
47610453SAndrew.Bardsley@arm.com}
47710453SAndrew.Bardsley@arm.com
4789042SMitchell.Hayenga@ARM.comCallbackQueue dumpQueue;
479695SN/ACallbackQueue resetQueue;
4802SN/A
481456SN/Avoid
48210453SAndrew.Bardsley@arm.comprocessResetQueue()
48310453SAndrew.Bardsley@arm.com{
48410453SAndrew.Bardsley@arm.com    resetQueue.process();
48510453SAndrew.Bardsley@arm.com}
48610453SAndrew.Bardsley@arm.com
48710453SAndrew.Bardsley@arm.comvoid
48810453SAndrew.Bardsley@arm.comprocessDumpQueue()
48910453SAndrew.Bardsley@arm.com{
49010453SAndrew.Bardsley@arm.com    dumpQueue.process();
49110453SAndrew.Bardsley@arm.com}
49210453SAndrew.Bardsley@arm.com
49310453SAndrew.Bardsley@arm.comvoid
494394SN/AregisterResetCallback(Callback *cb)
495148SN/A{
496148SN/A    resetQueue.add(cb);
497148SN/A}
498148SN/A
4998986SAli.Saidi@ARM.combool _enabled = false;
5008986SAli.Saidi@ARM.com
5018986SAli.Saidi@ARM.combool
5028986SAli.Saidi@ARM.comenabled()
5038986SAli.Saidi@ARM.com{
5048986SAli.Saidi@ARM.com    return _enabled;
5058986SAli.Saidi@ARM.com}
5068986SAli.Saidi@ARM.com
5078986SAli.Saidi@ARM.comvoid
5088986SAli.Saidi@ARM.comenable()
5098986SAli.Saidi@ARM.com{
5108986SAli.Saidi@ARM.com    if (_enabled)
5118986SAli.Saidi@ARM.com        fatal("Stats are already enabled");
5128986SAli.Saidi@ARM.com
5138986SAli.Saidi@ARM.com    _enabled = true;
5148986SAli.Saidi@ARM.com}
5158986SAli.Saidi@ARM.com
5169042SMitchell.Hayenga@ARM.comvoid
51710453SAndrew.Bardsley@arm.comdump()
51810453SAndrew.Bardsley@arm.com{
51910453SAndrew.Bardsley@arm.com    if (dumpHandler)
52010453SAndrew.Bardsley@arm.com        dumpHandler();
52110453SAndrew.Bardsley@arm.com    else
52210453SAndrew.Bardsley@arm.com        fatal("No registered Stats::dump handler");
52310453SAndrew.Bardsley@arm.com}
52410453SAndrew.Bardsley@arm.com
52510453SAndrew.Bardsley@arm.comvoid
52610453SAndrew.Bardsley@arm.comreset()
52710453SAndrew.Bardsley@arm.com{
52810453SAndrew.Bardsley@arm.com    if (resetHandler)
52910453SAndrew.Bardsley@arm.com        resetHandler();
53010453SAndrew.Bardsley@arm.com    else
53110453SAndrew.Bardsley@arm.com        fatal("No registered Stats::reset handler");
53210453SAndrew.Bardsley@arm.com}
53310453SAndrew.Bardsley@arm.com
53410453SAndrew.Bardsley@arm.comvoid
5359042SMitchell.Hayenga@ARM.comregisterDumpCallback(Callback *cb)
5369042SMitchell.Hayenga@ARM.com{
5379042SMitchell.Hayenga@ARM.com    dumpQueue.add(cb);
5389042SMitchell.Hayenga@ARM.com}
5399042SMitchell.Hayenga@ARM.com
5407811Ssteve.reinhardt@amd.com} // namespace Stats
5418296Snate@binkert.org
5428296Snate@binkert.orgvoid
5438296Snate@binkert.orgdebugDumpStats()
5448296Snate@binkert.org{
5458296Snate@binkert.org    Stats::dump();
5468296Snate@binkert.org}
547