stride.cc (10627:63edd4a1243f) stride.cc (10771:ea35886cd847)
1/*
1/*
2 * Copyright (c) 2012-2013 ARM Limited
2 * Copyright (c) 2012-2013, 2015 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated

--- 43 unchanged lines hidden (view full) ---

54 : QueuedPrefetcher(p),
55 maxConf(p->max_conf),
56 threshConf(p->thresh_conf),
57 minConf(p->min_conf),
58 startConf(p->start_conf),
59 pcTableAssoc(p->table_assoc),
60 pcTableSets(p->table_sets),
61 useMasterId(p->use_master_id),
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated

--- 43 unchanged lines hidden (view full) ---

54 : QueuedPrefetcher(p),
55 maxConf(p->max_conf),
56 threshConf(p->thresh_conf),
57 minConf(p->min_conf),
58 startConf(p->start_conf),
59 pcTableAssoc(p->table_assoc),
60 pcTableSets(p->table_sets),
61 useMasterId(p->use_master_id),
62 degree(p->degree)
62 degree(p->degree),
63 pcTable(pcTableAssoc, pcTableSets, name())
63{
64 // Don't consult stride prefetcher on instruction accesses
65 onInst = false;
66
67 assert(isPowerOf2(pcTableSets));
64{
65 // Don't consult stride prefetcher on instruction accesses
66 onInst = false;
67
68 assert(isPowerOf2(pcTableSets));
69}
68
70
69 for (int c = 0; c < maxContexts; c++) {
70 pcTable[c] = new StrideEntry*[pcTableSets];
71 for (int s = 0; s < pcTableSets; s++) {
72 pcTable[c][s] = new StrideEntry[pcTableAssoc];
73 }
71StridePrefetcher::StrideEntry**
72StridePrefetcher::PCTable::allocateNewContext(int context)
73{
74 auto res = entries.insert(std::make_pair(context,
75 new StrideEntry*[pcTableSets]));
76 auto it = res.first;
77 chatty_assert(res.second, "Allocating an already created context\n");
78 assert(it->first == context);
79
80 DPRINTF(HWPrefetch, "Adding context %i with stride entries at %p\n",
81 context, it->second);
82
83 StrideEntry** entry = it->second;
84 for (int s = 0; s < pcTableSets; s++) {
85 entry[s] = new StrideEntry[pcTableAssoc];
74 }
86 }
87 return entry;
75}
76
88}
89
77StridePrefetcher::~StridePrefetcher()
78{
79 for (int c = 0; c < maxContexts; c++) {
90StridePrefetcher::PCTable::~PCTable() {
91 for (auto entry : entries) {
80 for (int s = 0; s < pcTableSets; s++) {
92 for (int s = 0; s < pcTableSets; s++) {
81 delete[] pcTable[c][s];
93 delete[] entry.second[s];
82 }
94 }
95 delete[] entry.second;
83 }
84}
85
86void
87StridePrefetcher::calculatePrefetch(const PacketPtr &pkt,
88 std::vector<Addr> &addresses)
89{
90 if (!pkt->req->hasPC()) {
91 DPRINTF(HWPrefetch, "Ignoring request with no PC.\n");
92 return;
93 }
94
95 // Get required packet info
96 Addr pkt_addr = pkt->getAddr();
97 Addr pc = pkt->req->getPC();
98 bool is_secure = pkt->isSecure();
99 MasterID master_id = useMasterId ? pkt->req->masterId() : 0;
100
96 }
97}
98
99void
100StridePrefetcher::calculatePrefetch(const PacketPtr &pkt,
101 std::vector<Addr> &addresses)
102{
103 if (!pkt->req->hasPC()) {
104 DPRINTF(HWPrefetch, "Ignoring request with no PC.\n");
105 return;
106 }
107
108 // Get required packet info
109 Addr pkt_addr = pkt->getAddr();
110 Addr pc = pkt->req->getPC();
111 bool is_secure = pkt->isSecure();
112 MasterID master_id = useMasterId ? pkt->req->masterId() : 0;
113
101 assert(master_id < maxContexts);
102
103 // Lookup pc-based information
104 StrideEntry *entry;
105
106 if(pcTableHit(pc, is_secure, master_id, entry)) {
107 // Hit in table
108 int new_stride = pkt_addr - entry->lastAddr;
109 bool stride_match = (new_stride == entry->stride);
110

--- 98 unchanged lines hidden ---
114 // Lookup pc-based information
115 StrideEntry *entry;
116
117 if(pcTableHit(pc, is_secure, master_id, entry)) {
118 // Hit in table
119 int new_stride = pkt_addr - entry->lastAddr;
120 bool stride_match = (new_stride == entry->stride);
121

--- 98 unchanged lines hidden ---