statistics.cc revision 11321
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) {
1836026Snate@binkert.org        // using other->name instead of just name to avoid a compiler
1846026Snate@binkert.org        // 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
224388SN/A        panic("Not all stats have been initialized");
225388SN/A        return false;
226388SN/A    }
2272SN/A
2287462Snate@binkert.org    if ((flags & display) && name.empty()) {
229388SN/A        panic("all printable stats must be named");
230388SN/A        return false;
231388SN/A    }
2322SN/A
233388SN/A    return true;
2342SN/A}
2352SN/A
2366001Snate@binkert.orgvoid
2376001Snate@binkert.orgInfo::enable()
2386001Snate@binkert.org{
2396001Snate@binkert.org}
2406001Snate@binkert.org
2416001Snate@binkert.orgvoid
2426128Snate@binkert.orgVectorInfo::enable()
2436001Snate@binkert.org{
2446001Snate@binkert.org    size_type s = size();
2456001Snate@binkert.org    if (subnames.size() < s)
2466001Snate@binkert.org        subnames.resize(s);
2476001Snate@binkert.org    if (subdescs.size() < s)
2486001Snate@binkert.org        subdescs.resize(s);
2496001Snate@binkert.org}
2506001Snate@binkert.org
2516001Snate@binkert.orgvoid
2526128Snate@binkert.orgVectorDistInfo::enable()
2536001Snate@binkert.org{
2546001Snate@binkert.org    size_type s = size();
2556001Snate@binkert.org    if (subnames.size() < s)
2566001Snate@binkert.org        subnames.resize(s);
2576001Snate@binkert.org    if (subdescs.size() < s)
2586001Snate@binkert.org        subdescs.resize(s);
2596001Snate@binkert.org}
2606001Snate@binkert.org
2616001Snate@binkert.orgvoid
2626128Snate@binkert.orgVector2dInfo::enable()
2636001Snate@binkert.org{
2646001Snate@binkert.org    if (subnames.size() < x)
2656001Snate@binkert.org        subnames.resize(x);
2666001Snate@binkert.org    if (subdescs.size() < x)
2676001Snate@binkert.org        subdescs.resize(x);
2686001Snate@binkert.org    if (y_subnames.size() < y)
2696001Snate@binkert.org        y_subnames.resize(y);
2706001Snate@binkert.org}
271695SN/A
2727831Snate@binkert.orgvoid
2737831Snate@binkert.orgHistStor::grow_out()
2747831Snate@binkert.org{
2757831Snate@binkert.org    int size = cvec.size();
2767831Snate@binkert.org    int zero = size / 2; // round down!
2777831Snate@binkert.org    int top_half = zero + (size - zero + 1) / 2; // round up!
2787831Snate@binkert.org    int bottom_half = (size - zero) / 2; // round down!
2797831Snate@binkert.org
2807831Snate@binkert.org    // grow down
2817831Snate@binkert.org    int low_pair = zero - 1;
2827831Snate@binkert.org    for (int i = zero - 1; i >= bottom_half; i--) {
2837831Snate@binkert.org        cvec[i] = cvec[low_pair];
2847831Snate@binkert.org        if (low_pair - 1 >= 0)
2857831Snate@binkert.org            cvec[i] += cvec[low_pair - 1];
2867831Snate@binkert.org        low_pair -= 2;
2877831Snate@binkert.org    }
2887831Snate@binkert.org    assert(low_pair == 0 || low_pair == -1 || low_pair == -2);
2897831Snate@binkert.org
2907831Snate@binkert.org    for (int i = bottom_half - 1; i >= 0; i--)
2917831Snate@binkert.org        cvec[i] = Counter();
2927831Snate@binkert.org
2937831Snate@binkert.org    // grow up
2947831Snate@binkert.org    int high_pair = zero;
2957831Snate@binkert.org    for (int i = zero; i < top_half; i++) {
2967831Snate@binkert.org        cvec[i] = cvec[high_pair];
2977831Snate@binkert.org        if (high_pair + 1 < size)
2987831Snate@binkert.org            cvec[i] += cvec[high_pair + 1];
2997831Snate@binkert.org        high_pair += 2;
3007831Snate@binkert.org    }
3017831Snate@binkert.org    assert(high_pair == size || high_pair == size + 1);
3027831Snate@binkert.org
3037831Snate@binkert.org    for (int i = top_half; i < size; i++)
3047831Snate@binkert.org        cvec[i] = Counter();
3057831Snate@binkert.org
3067831Snate@binkert.org    max_bucket *= 2;
3077831Snate@binkert.org    min_bucket *= 2;
3087831Snate@binkert.org    bucket_size *= 2;
3097831Snate@binkert.org}
3107831Snate@binkert.org
3117831Snate@binkert.orgvoid
3127831Snate@binkert.orgHistStor::grow_convert()
3137831Snate@binkert.org{
3147831Snate@binkert.org    int size = cvec.size();
3157831Snate@binkert.org    int half = (size + 1) / 2; // round up!
3167831Snate@binkert.org    //bool even = (size & 1) == 0;
3177831Snate@binkert.org
3187831Snate@binkert.org    int pair = size - 1;
3197831Snate@binkert.org    for (int i = size - 1; i >= half; --i) {
3207831Snate@binkert.org        cvec[i] = cvec[pair];
3217831Snate@binkert.org        if (pair - 1 >= 0)
3227831Snate@binkert.org            cvec[i] += cvec[pair - 1];
3237831Snate@binkert.org        pair -= 2;
3247831Snate@binkert.org    }
3257831Snate@binkert.org
3267831Snate@binkert.org    for (int i = half - 1; i >= 0; i--)
3277831Snate@binkert.org        cvec[i] = Counter();
3287831Snate@binkert.org
3297831Snate@binkert.org    min_bucket = -max_bucket;// - (even ? bucket_size : 0);
3307831Snate@binkert.org    bucket_size *= 2;
3317831Snate@binkert.org}
3327831Snate@binkert.org
3337831Snate@binkert.orgvoid
3347831Snate@binkert.orgHistStor::grow_up()
3357831Snate@binkert.org{
3367831Snate@binkert.org    int size = cvec.size();
3377831Snate@binkert.org    int half = (size + 1) / 2; // round up!
3387831Snate@binkert.org
3397831Snate@binkert.org    int pair = 0;
3407831Snate@binkert.org    for (int i = 0; i < half; i++) {
3417831Snate@binkert.org        cvec[i] = cvec[pair];
3427831Snate@binkert.org        if (pair + 1 < size)
3437831Snate@binkert.org            cvec[i] += cvec[pair + 1];
3447831Snate@binkert.org        pair += 2;
3457831Snate@binkert.org    }
3467831Snate@binkert.org    assert(pair == size || pair == size + 1);
3477831Snate@binkert.org
3487831Snate@binkert.org    for (int i = half; i < size; i++)
3497831Snate@binkert.org        cvec[i] = Counter();
3507831Snate@binkert.org
3517831Snate@binkert.org    max_bucket *= 2;
3527831Snate@binkert.org    bucket_size *= 2;
3537831Snate@binkert.org}
3547831Snate@binkert.org
35510011Snilay@cs.wisc.eduvoid
35610011Snilay@cs.wisc.eduHistStor::add(HistStor *hs)
35710011Snilay@cs.wisc.edu{
35810011Snilay@cs.wisc.edu    int b_size = hs->size();
35910011Snilay@cs.wisc.edu    assert(size() == b_size);
36010011Snilay@cs.wisc.edu    assert(min_bucket == hs->min_bucket);
36110011Snilay@cs.wisc.edu
36210011Snilay@cs.wisc.edu    sum += hs->sum;
36310011Snilay@cs.wisc.edu    logs += hs->logs;
36410011Snilay@cs.wisc.edu    squares += hs->squares;
36510011Snilay@cs.wisc.edu    samples += hs->samples;
36610011Snilay@cs.wisc.edu
36711321Ssteve.reinhardt@amd.com    while (bucket_size > hs->bucket_size)
36810011Snilay@cs.wisc.edu        hs->grow_up();
36911321Ssteve.reinhardt@amd.com    while (bucket_size < hs->bucket_size)
37010011Snilay@cs.wisc.edu        grow_up();
37110011Snilay@cs.wisc.edu
37210011Snilay@cs.wisc.edu    for (uint32_t i = 0; i < b_size; i++)
37310011Snilay@cs.wisc.edu        cvec[i] += hs->cvec[i];
37410011Snilay@cs.wisc.edu}
37510011Snilay@cs.wisc.edu
376388SN/AFormula::Formula()
377388SN/A{
378388SN/A}
379388SN/A
380388SN/AFormula::Formula(Temp r)
381388SN/A{
38210491Sandreas.hansson@arm.com    root = r.getNodePtr();
3837461Snate@binkert.org    setInit();
384388SN/A    assert(size());
385388SN/A}
386388SN/A
387388SN/Aconst Formula &
388388SN/AFormula::operator=(Temp r)
389388SN/A{
390388SN/A    assert(!root && "Can't change formulas");
39110491Sandreas.hansson@arm.com    root = r.getNodePtr();
3927461Snate@binkert.org    setInit();
393388SN/A    assert(size());
394388SN/A    return *this;
395388SN/A}
396388SN/A
397388SN/Aconst Formula &
398388SN/AFormula::operator+=(Temp r)
399388SN/A{
400388SN/A    if (root)
401695SN/A        root = NodePtr(new BinaryNode<std::plus<Result> >(root, r));
4027461Snate@binkert.org    else {
40310491Sandreas.hansson@arm.com        root = r.getNodePtr();
4047461Snate@binkert.org        setInit();
4057461Snate@binkert.org    }
4067461Snate@binkert.org
407388SN/A    assert(size());
408388SN/A    return *this;
409388SN/A}
410388SN/A
4119857Snilay@cs.wisc.educonst Formula &
4129857Snilay@cs.wisc.eduFormula::operator/=(Temp r)
4139857Snilay@cs.wisc.edu{
4149857Snilay@cs.wisc.edu    assert (root);
4159857Snilay@cs.wisc.edu    root = NodePtr(new BinaryNode<std::divides<Result> >(root, r));
4169857Snilay@cs.wisc.edu
4179857Snilay@cs.wisc.edu    assert(size());
4189857Snilay@cs.wisc.edu    return *this;
4199857Snilay@cs.wisc.edu}
4209857Snilay@cs.wisc.edu
421142SN/Avoid
4226000Snate@binkert.orgFormula::result(VResult &vec) const
4236000Snate@binkert.org{
4246000Snate@binkert.org    if (root)
4256000Snate@binkert.org        vec = root->result();
4266000Snate@binkert.org}
4276000Snate@binkert.org
4286000Snate@binkert.orgResult
4296000Snate@binkert.orgFormula::total() const
4306000Snate@binkert.org{
4316000Snate@binkert.org    return root ? root->total() : 0.0;
4326000Snate@binkert.org}
4336000Snate@binkert.org
4346000Snate@binkert.orgsize_type
4356000Snate@binkert.orgFormula::size() const
4366000Snate@binkert.org{
4376000Snate@binkert.org    if (!root)
4386000Snate@binkert.org        return 0;
4396000Snate@binkert.org    else
4406000Snate@binkert.org        return root->size();
4416000Snate@binkert.org}
4426000Snate@binkert.org
4436000Snate@binkert.orgvoid
4446000Snate@binkert.orgFormula::reset()
4456000Snate@binkert.org{
4466000Snate@binkert.org}
4476000Snate@binkert.org
4486000Snate@binkert.orgbool
4496000Snate@binkert.orgFormula::zero() const
4506000Snate@binkert.org{
4516000Snate@binkert.org    VResult vec;
4526000Snate@binkert.org    result(vec);
4536227Snate@binkert.org    for (VResult::size_type i = 0; i < vec.size(); ++i)
4546000Snate@binkert.org        if (vec[i] != 0.0)
4556000Snate@binkert.org            return false;
4566000Snate@binkert.org    return true;
4576000Snate@binkert.org}
4586000Snate@binkert.org
4596000Snate@binkert.orgstring
4606000Snate@binkert.orgFormula::str() const
4616000Snate@binkert.org{
4626000Snate@binkert.org    return root ? root->str() : "";
4636000Snate@binkert.org}
4646000Snate@binkert.org
46510453SAndrew.Bardsley@arm.comHandler resetHandler = NULL;
46610453SAndrew.Bardsley@arm.comHandler dumpHandler = NULL;
46710453SAndrew.Bardsley@arm.com
46810453SAndrew.Bardsley@arm.comvoid
46910453SAndrew.Bardsley@arm.comregisterHandlers(Handler reset_handler, Handler dump_handler)
47010453SAndrew.Bardsley@arm.com{
47110453SAndrew.Bardsley@arm.com    resetHandler = reset_handler;
47210453SAndrew.Bardsley@arm.com    dumpHandler = dump_handler;
47310453SAndrew.Bardsley@arm.com}
47410453SAndrew.Bardsley@arm.com
4759042SMitchell.Hayenga@ARM.comCallbackQueue dumpQueue;
476695SN/ACallbackQueue resetQueue;
4772SN/A
478456SN/Avoid
47910453SAndrew.Bardsley@arm.comprocessResetQueue()
48010453SAndrew.Bardsley@arm.com{
48110453SAndrew.Bardsley@arm.com    resetQueue.process();
48210453SAndrew.Bardsley@arm.com}
48310453SAndrew.Bardsley@arm.com
48410453SAndrew.Bardsley@arm.comvoid
48510453SAndrew.Bardsley@arm.comprocessDumpQueue()
48610453SAndrew.Bardsley@arm.com{
48710453SAndrew.Bardsley@arm.com    dumpQueue.process();
48810453SAndrew.Bardsley@arm.com}
48910453SAndrew.Bardsley@arm.com
49010453SAndrew.Bardsley@arm.comvoid
491394SN/AregisterResetCallback(Callback *cb)
492148SN/A{
493148SN/A    resetQueue.add(cb);
494148SN/A}
495148SN/A
4968986SAli.Saidi@ARM.combool _enabled = false;
4978986SAli.Saidi@ARM.com
4988986SAli.Saidi@ARM.combool
4998986SAli.Saidi@ARM.comenabled()
5008986SAli.Saidi@ARM.com{
5018986SAli.Saidi@ARM.com    return _enabled;
5028986SAli.Saidi@ARM.com}
5038986SAli.Saidi@ARM.com
5048986SAli.Saidi@ARM.comvoid
5058986SAli.Saidi@ARM.comenable()
5068986SAli.Saidi@ARM.com{
5078986SAli.Saidi@ARM.com    if (_enabled)
5088986SAli.Saidi@ARM.com        fatal("Stats are already enabled");
5098986SAli.Saidi@ARM.com
5108986SAli.Saidi@ARM.com    _enabled = true;
5118986SAli.Saidi@ARM.com}
5128986SAli.Saidi@ARM.com
5139042SMitchell.Hayenga@ARM.comvoid
51410453SAndrew.Bardsley@arm.comdump()
51510453SAndrew.Bardsley@arm.com{
51610453SAndrew.Bardsley@arm.com    if (dumpHandler)
51710453SAndrew.Bardsley@arm.com        dumpHandler();
51810453SAndrew.Bardsley@arm.com    else
51910453SAndrew.Bardsley@arm.com        fatal("No registered Stats::dump handler");
52010453SAndrew.Bardsley@arm.com}
52110453SAndrew.Bardsley@arm.com
52210453SAndrew.Bardsley@arm.comvoid
52310453SAndrew.Bardsley@arm.comreset()
52410453SAndrew.Bardsley@arm.com{
52510453SAndrew.Bardsley@arm.com    if (resetHandler)
52610453SAndrew.Bardsley@arm.com        resetHandler();
52710453SAndrew.Bardsley@arm.com    else
52810453SAndrew.Bardsley@arm.com        fatal("No registered Stats::reset handler");
52910453SAndrew.Bardsley@arm.com}
53010453SAndrew.Bardsley@arm.com
53110453SAndrew.Bardsley@arm.comvoid
5329042SMitchell.Hayenga@ARM.comregisterDumpCallback(Callback *cb)
5339042SMitchell.Hayenga@ARM.com{
5349042SMitchell.Hayenga@ARM.com    dumpQueue.add(cb);
5359042SMitchell.Hayenga@ARM.com}
5369042SMitchell.Hayenga@ARM.com
5377811Ssteve.reinhardt@amd.com} // namespace Stats
5388296Snate@binkert.org
5398296Snate@binkert.orgvoid
5408296Snate@binkert.orgdebugDumpStats()
5418296Snate@binkert.org{
5428296Snate@binkert.org    Stats::dump();
5438296Snate@binkert.org}
544