queued.hh revision 13422
110623Smitch.hayenga@arm.com/* 211439SRekai.GonzalezAlberquilla@arm.com * Copyright (c) 2014-2015 ARM Limited 310623Smitch.hayenga@arm.com * All rights reserved 410623Smitch.hayenga@arm.com * 510623Smitch.hayenga@arm.com * The license below extends only to copyright in the software and shall 610623Smitch.hayenga@arm.com * not be construed as granting a license to any other intellectual 710623Smitch.hayenga@arm.com * property including but not limited to intellectual property relating 810623Smitch.hayenga@arm.com * to a hardware implementation of the functionality of the software 910623Smitch.hayenga@arm.com * licensed hereunder. You may use the software subject to the license 1010623Smitch.hayenga@arm.com * terms below provided that you ensure that this notice is replicated 1110623Smitch.hayenga@arm.com * unmodified and in its entirety in all distributions of the software, 1210623Smitch.hayenga@arm.com * modified or unmodified, in source code or in binary form. 1310623Smitch.hayenga@arm.com * 1410623Smitch.hayenga@arm.com * Redistribution and use in source and binary forms, with or without 1510623Smitch.hayenga@arm.com * modification, are permitted provided that the following conditions are 1610623Smitch.hayenga@arm.com * met: redistributions of source code must retain the above copyright 1710623Smitch.hayenga@arm.com * notice, this list of conditions and the following disclaimer; 1810623Smitch.hayenga@arm.com * redistributions in binary form must reproduce the above copyright 1910623Smitch.hayenga@arm.com * notice, this list of conditions and the following disclaimer in the 2010623Smitch.hayenga@arm.com * documentation and/or other materials provided with the distribution; 2110623Smitch.hayenga@arm.com * neither the name of the copyright holders nor the names of its 2210623Smitch.hayenga@arm.com * contributors may be used to endorse or promote products derived from 2310623Smitch.hayenga@arm.com * this software without specific prior written permission. 2410623Smitch.hayenga@arm.com * 2510623Smitch.hayenga@arm.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2610623Smitch.hayenga@arm.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 2710623Smitch.hayenga@arm.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 2810623Smitch.hayenga@arm.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2910623Smitch.hayenga@arm.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 3010623Smitch.hayenga@arm.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 3110623Smitch.hayenga@arm.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 3210623Smitch.hayenga@arm.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 3310623Smitch.hayenga@arm.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3410623Smitch.hayenga@arm.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 3510623Smitch.hayenga@arm.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3610623Smitch.hayenga@arm.com * 3710623Smitch.hayenga@arm.com * Authors: Mitch Hayenga 3810623Smitch.hayenga@arm.com */ 3910623Smitch.hayenga@arm.com 4010623Smitch.hayenga@arm.com#ifndef __MEM_CACHE_PREFETCH_QUEUED_HH__ 4110623Smitch.hayenga@arm.com#define __MEM_CACHE_PREFETCH_QUEUED_HH__ 4210623Smitch.hayenga@arm.com 4312727Snikos.nikoleris@arm.com#include <cstdint> 4410623Smitch.hayenga@arm.com#include <list> 4512727Snikos.nikoleris@arm.com#include <utility> 4610623Smitch.hayenga@arm.com 4712727Snikos.nikoleris@arm.com#include "base/statistics.hh" 4812727Snikos.nikoleris@arm.com#include "base/types.hh" 4910623Smitch.hayenga@arm.com#include "mem/cache/prefetch/base.hh" 5012727Snikos.nikoleris@arm.com#include "mem/packet.hh" 5112727Snikos.nikoleris@arm.com 5212727Snikos.nikoleris@arm.comstruct QueuedPrefetcherParams; 5310623Smitch.hayenga@arm.com 5410623Smitch.hayenga@arm.comclass QueuedPrefetcher : public BasePrefetcher 5510623Smitch.hayenga@arm.com{ 5610623Smitch.hayenga@arm.com protected: 5710623Smitch.hayenga@arm.com struct DeferredPacket { 5810623Smitch.hayenga@arm.com Tick tick; 5910623Smitch.hayenga@arm.com PacketPtr pkt; 6011439SRekai.GonzalezAlberquilla@arm.com int32_t priority; 6111439SRekai.GonzalezAlberquilla@arm.com DeferredPacket(Tick t, PacketPtr p, int32_t pr) : tick(t), pkt(p), 6211439SRekai.GonzalezAlberquilla@arm.com priority(pr) {} 6311439SRekai.GonzalezAlberquilla@arm.com bool operator>(const DeferredPacket& that) const 6411439SRekai.GonzalezAlberquilla@arm.com { 6511439SRekai.GonzalezAlberquilla@arm.com return priority > that.priority; 6611439SRekai.GonzalezAlberquilla@arm.com } 6711439SRekai.GonzalezAlberquilla@arm.com bool operator<(const DeferredPacket& that) const 6811439SRekai.GonzalezAlberquilla@arm.com { 6911439SRekai.GonzalezAlberquilla@arm.com return priority < that.priority; 7011439SRekai.GonzalezAlberquilla@arm.com } 7111439SRekai.GonzalezAlberquilla@arm.com bool operator<=(const DeferredPacket& that) const 7211439SRekai.GonzalezAlberquilla@arm.com { 7311439SRekai.GonzalezAlberquilla@arm.com return !(*this > that); 7411439SRekai.GonzalezAlberquilla@arm.com } 7510623Smitch.hayenga@arm.com }; 7611439SRekai.GonzalezAlberquilla@arm.com using AddrPriority = std::pair<Addr, int32_t>; 7710623Smitch.hayenga@arm.com 7810623Smitch.hayenga@arm.com std::list<DeferredPacket> pfq; 7910623Smitch.hayenga@arm.com 8010623Smitch.hayenga@arm.com // PARAMETERS 8110623Smitch.hayenga@arm.com 8210623Smitch.hayenga@arm.com /** Maximum size of the prefetch queue */ 8310623Smitch.hayenga@arm.com const unsigned queueSize; 8410623Smitch.hayenga@arm.com 8510623Smitch.hayenga@arm.com /** Cycles after generation when a prefetch can first be issued */ 8610623Smitch.hayenga@arm.com const Cycles latency; 8710623Smitch.hayenga@arm.com 8810623Smitch.hayenga@arm.com /** Squash queued prefetch if demand access observed */ 8910623Smitch.hayenga@arm.com const bool queueSquash; 9010623Smitch.hayenga@arm.com 9110623Smitch.hayenga@arm.com /** Filter prefetches if already queued */ 9210623Smitch.hayenga@arm.com const bool queueFilter; 9310623Smitch.hayenga@arm.com 9410623Smitch.hayenga@arm.com /** Snoop the cache before generating prefetch (cheating basically) */ 9510623Smitch.hayenga@arm.com const bool cacheSnoop; 9610623Smitch.hayenga@arm.com 9710623Smitch.hayenga@arm.com /** Tag prefetch with PC of generating access? */ 9810623Smitch.hayenga@arm.com const bool tagPrefetch; 9910623Smitch.hayenga@arm.com 10011439SRekai.GonzalezAlberquilla@arm.com using const_iterator = std::list<DeferredPacket>::const_iterator; 10113422Sodanrc@yahoo.com.br const_iterator inPrefetch(Addr address, bool is_secure) const; 10211439SRekai.GonzalezAlberquilla@arm.com using iterator = std::list<DeferredPacket>::iterator; 10313422Sodanrc@yahoo.com.br iterator inPrefetch(Addr address, bool is_secure); 10410623Smitch.hayenga@arm.com 10510623Smitch.hayenga@arm.com // STATS 10610623Smitch.hayenga@arm.com Stats::Scalar pfIdentified; 10710623Smitch.hayenga@arm.com Stats::Scalar pfBufferHit; 10810623Smitch.hayenga@arm.com Stats::Scalar pfInCache; 10910623Smitch.hayenga@arm.com Stats::Scalar pfRemovedFull; 11010623Smitch.hayenga@arm.com Stats::Scalar pfSpanPage; 11110623Smitch.hayenga@arm.com 11210623Smitch.hayenga@arm.com public: 11310623Smitch.hayenga@arm.com QueuedPrefetcher(const QueuedPrefetcherParams *p); 11410623Smitch.hayenga@arm.com virtual ~QueuedPrefetcher(); 11510623Smitch.hayenga@arm.com 11613416Sjavier.bueno@metempsy.com void notify(const PacketPtr &pkt) override; 11713422Sodanrc@yahoo.com.br 11811439SRekai.GonzalezAlberquilla@arm.com PacketPtr insert(AddrPriority& info, bool is_secure); 11910623Smitch.hayenga@arm.com 12010623Smitch.hayenga@arm.com virtual void calculatePrefetch(const PacketPtr &pkt, 12111439SRekai.GonzalezAlberquilla@arm.com std::vector<AddrPriority> &addresses) = 0; 12213422Sodanrc@yahoo.com.br PacketPtr getPacket() override; 12310623Smitch.hayenga@arm.com 12413422Sodanrc@yahoo.com.br Tick nextPrefetchReadyTime() const override 12510623Smitch.hayenga@arm.com { 12610623Smitch.hayenga@arm.com return pfq.empty() ? MaxTick : pfq.front().tick; 12710623Smitch.hayenga@arm.com } 12810623Smitch.hayenga@arm.com 12913422Sodanrc@yahoo.com.br void regStats() override; 13010623Smitch.hayenga@arm.com}; 13110623Smitch.hayenga@arm.com 13210623Smitch.hayenga@arm.com#endif //__MEM_CACHE_PREFETCH_QUEUED_HH__ 13310623Smitch.hayenga@arm.com 134