base.cc revision 6978
12810SN/A/*
22810SN/A * Copyright (c) 2003-2005 The Regents of The University of Michigan
32810SN/A * All rights reserved.
42810SN/A *
52810SN/A * Redistribution and use in source and binary forms, with or without
62810SN/A * modification, are permitted provided that the following conditions are
72810SN/A * met: redistributions of source code must retain the above copyright
82810SN/A * notice, this list of conditions and the following disclaimer;
92810SN/A * redistributions in binary form must reproduce the above copyright
102810SN/A * notice, this list of conditions and the following disclaimer in the
112810SN/A * documentation and/or other materials provided with the distribution;
122810SN/A * neither the name of the copyright holders nor the names of its
132810SN/A * contributors may be used to endorse or promote products derived from
142810SN/A * this software without specific prior written permission.
152810SN/A *
162810SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172810SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182810SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192810SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202810SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212810SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222810SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232810SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242810SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252810SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262810SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272810SN/A *
282810SN/A * Authors: Erik Hallnor
292810SN/A *          Ron Dreslinski
302810SN/A */
312810SN/A
322810SN/A/**
332810SN/A * @file
342810SN/A * Definitions of BaseTags.
352810SN/A */
362810SN/A
375338Sstever@gmail.com#include "mem/cache/tags/base.hh"
382810SN/A
395338Sstever@gmail.com#include "mem/cache/base.hh"
402810SN/A#include "cpu/smt.hh" //maxThreadsPerCPU
412810SN/A#include "sim/sim_exit.hh"
422810SN/A
432810SN/Ausing namespace std;
442810SN/A
452810SN/Avoid
462810SN/ABaseTags::setCache(BaseCache *_cache)
472810SN/A{
482810SN/A    cache = _cache;
492810SN/A    objName = cache->name();
502810SN/A}
512810SN/A
522810SN/Avoid
532810SN/ABaseTags::regStats(const string &name)
542810SN/A{
552810SN/A    using namespace Stats;
562810SN/A    replacements
572810SN/A        .init(maxThreadsPerCPU)
582810SN/A        .name(name + ".replacements")
592810SN/A        .desc("number of replacements")
602810SN/A        .flags(total)
612810SN/A        ;
622810SN/A
632810SN/A    tagsInUse
642810SN/A        .name(name + ".tagsinuse")
652810SN/A        .desc("Cycle average of tags in use")
662810SN/A        ;
672810SN/A
682810SN/A    totalRefs
692810SN/A        .name(name + ".total_refs")
702810SN/A        .desc("Total number of references to valid blocks.")
712810SN/A        ;
722810SN/A
732810SN/A    sampledRefs
742810SN/A        .name(name + ".sampled_refs")
752810SN/A        .desc("Sample count of references to valid blocks.")
762810SN/A        ;
772810SN/A
782810SN/A    avgRefs
792810SN/A        .name(name + ".avg_refs")
802810SN/A        .desc("Average number of references to valid blocks.")
812810SN/A        ;
822810SN/A
832810SN/A    avgRefs = totalRefs/sampledRefs;
842810SN/A
852810SN/A    warmupCycle
862810SN/A        .name(name + ".warmup_cycle")
872810SN/A        .desc("Cycle when the warmup percentage was hit.")
882810SN/A        ;
892810SN/A
906978SLisa.Hsu@amd.com    occupancies
916978SLisa.Hsu@amd.com        .init(cache->numCpus())
926978SLisa.Hsu@amd.com        .name(name + ".occ_blocks")
936978SLisa.Hsu@amd.com        .desc("Average occupied blocks per context")
946978SLisa.Hsu@amd.com        .flags(nozero | nonan)
956978SLisa.Hsu@amd.com        ;
966978SLisa.Hsu@amd.com
976978SLisa.Hsu@amd.com    avgOccs
986978SLisa.Hsu@amd.com        .name(name + ".occ_%")
996978SLisa.Hsu@amd.com        .desc("Average percentage of cache occupancy")
1006978SLisa.Hsu@amd.com        .flags(nozero)
1016978SLisa.Hsu@amd.com        ;
1026978SLisa.Hsu@amd.com
1036978SLisa.Hsu@amd.com    avgOccs = occupancies / Stats::constant(numBlocks);
1046978SLisa.Hsu@amd.com
1052810SN/A    registerExitCallback(new BaseTagsCallback(this));
1062810SN/A}
107