base.hh revision 8831:6c08a877af8f
112885Sspwilson2@wisc.edu/* 212885Sspwilson2@wisc.edu * Copyright (c) 2005 The Regents of The University of Michigan 312885Sspwilson2@wisc.edu * All rights reserved. 412885Sspwilson2@wisc.edu * 512885Sspwilson2@wisc.edu * Redistribution and use in source and binary forms, with or without 612885Sspwilson2@wisc.edu * modification, are permitted provided that the following conditions are 712885Sspwilson2@wisc.edu * met: redistributions of source code must retain the above copyright 812885Sspwilson2@wisc.edu * notice, this list of conditions and the following disclaimer; 912885Sspwilson2@wisc.edu * redistributions in binary form must reproduce the above copyright 1012885Sspwilson2@wisc.edu * notice, this list of conditions and the following disclaimer in the 1112885Sspwilson2@wisc.edu * documentation and/or other materials provided with the distribution; 1212885Sspwilson2@wisc.edu * neither the name of the copyright holders nor the names of its 1312885Sspwilson2@wisc.edu * contributors may be used to endorse or promote products derived from 1412885Sspwilson2@wisc.edu * this software without specific prior written permission. 1512885Sspwilson2@wisc.edu * 1612885Sspwilson2@wisc.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1712885Sspwilson2@wisc.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1812885Sspwilson2@wisc.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1912885Sspwilson2@wisc.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2012885Sspwilson2@wisc.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2112885Sspwilson2@wisc.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2212885Sspwilson2@wisc.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2312885Sspwilson2@wisc.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2412885Sspwilson2@wisc.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2512885Sspwilson2@wisc.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2612885Sspwilson2@wisc.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2712885Sspwilson2@wisc.edu * 2812885Sspwilson2@wisc.edu * Authors: Ron Dreslinski 2912885Sspwilson2@wisc.edu */ 3012885Sspwilson2@wisc.edu 3112885Sspwilson2@wisc.edu/** 3212885Sspwilson2@wisc.edu * @file 3312885Sspwilson2@wisc.edu * Miss and writeback queue declarations. 3412885Sspwilson2@wisc.edu */ 3512885Sspwilson2@wisc.edu 3612885Sspwilson2@wisc.edu#ifndef __MEM_CACHE_PREFETCH_BASE_PREFETCHER_HH__ 3712885Sspwilson2@wisc.edu#define __MEM_CACHE_PREFETCH_BASE_PREFETCHER_HH__ 3812885Sspwilson2@wisc.edu 3914142Snikos.nikoleris@arm.com#include <list> 4012885Sspwilson2@wisc.edu 4112885Sspwilson2@wisc.edu#include "base/statistics.hh" 4212885Sspwilson2@wisc.edu#include "mem/packet.hh" 4314142Snikos.nikoleris@arm.com#include "params/BaseCache.hh" 4414142Snikos.nikoleris@arm.com#include "sim/sim_object.hh" 4514142Snikos.nikoleris@arm.com 4614142Snikos.nikoleris@arm.comclass BaseCache; 4712885Sspwilson2@wisc.edu 4812885Sspwilson2@wisc.educlass BasePrefetcher : public SimObject 4912885Sspwilson2@wisc.edu{ 5012885Sspwilson2@wisc.edu protected: 5112885Sspwilson2@wisc.edu 5212885Sspwilson2@wisc.edu /** The Prefetch Queue. */ 5312885Sspwilson2@wisc.edu std::list<PacketPtr> pf; 5412885Sspwilson2@wisc.edu 5512885Sspwilson2@wisc.edu // PARAMETERS 5612885Sspwilson2@wisc.edu 5712885Sspwilson2@wisc.edu /** The number of MSHRs in the Prefetch Queue. */ 5812885Sspwilson2@wisc.edu const unsigned size; 5914142Snikos.nikoleris@arm.com 6012885Sspwilson2@wisc.edu /** Pointr to the parent cache. */ 6112885Sspwilson2@wisc.edu BaseCache* cache; 62 63 /** The block size of the parent cache. */ 64 int blkSize; 65 66 /** The latency before a prefetch is issued */ 67 Tick latency; 68 69 /** The number of prefetches to issue */ 70 unsigned degree; 71 72 /** If patterns should be found per context id */ 73 bool useContextId; 74 /** Do we prefetch across page boundaries. */ 75 bool pageStop; 76 77 /** Do we remove prefetches with later times than a new miss.*/ 78 bool serialSquash; 79 80 /** Do we prefetch on only data reads, or on inst reads as well. */ 81 bool onlyData; 82 83 public: 84 85 Stats::Scalar pfIdentified; 86 Stats::Scalar pfMSHRHit; 87 Stats::Scalar pfCacheHit; 88 Stats::Scalar pfBufferHit; 89 Stats::Scalar pfRemovedFull; 90 Stats::Scalar pfRemovedMSHR; 91 Stats::Scalar pfIssued; 92 Stats::Scalar pfSpanPage; 93 Stats::Scalar pfSquashed; 94 95 void regStats(); 96 97 public: 98 typedef BasePrefetcherParams Params; 99 BasePrefetcher(const Params *p); 100 101 virtual ~BasePrefetcher() {} 102 103 void setCache(BaseCache *_cache); 104 105 /** 106 * Notify prefetcher of cache access (may be any access or just 107 * misses, depending on cache parameters.) 108 * @retval Time of next prefetch availability, or 0 if none. 109 */ 110 Tick notify(PacketPtr &pkt, Tick time); 111 112 bool inCache(Addr addr); 113 114 bool inMissQueue(Addr addr); 115 116 PacketPtr getPacket(); 117 118 bool havePending() 119 { 120 return !pf.empty(); 121 } 122 123 Tick nextPrefetchReadyTime() 124 { 125 return pf.empty() ? MaxTick : pf.front()->time; 126 } 127 128 virtual void calculatePrefetch(PacketPtr &pkt, 129 std::list<Addr> &addresses, 130 std::list<Tick> &delays) = 0; 131 132 std::list<PacketPtr>::iterator inPrefetch(Addr address); 133 134 /** 135 * Utility function: are addresses a and b on the same VM page? 136 */ 137 bool samePage(Addr a, Addr b); 138 public: 139 const Params* 140 params() const 141 { 142 return dynamic_cast<const Params *>(_params); 143 } 144 145}; 146#endif //__MEM_CACHE_PREFETCH_BASE_PREFETCHER_HH__ 147