irregular_stream_buffer.cc (13828:73addeac3dd3) irregular_stream_buffer.cc (13963:94555f0223ba)
1/**
2 * Copyright (c) 2018 Metempsy Technology Consulting
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

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

31#include "mem/cache/prefetch/irregular_stream_buffer.hh"
32
33#include "debug/HWPrefetch.hh"
34#include "mem/cache/prefetch/associative_set_impl.hh"
35#include "params/IrregularStreamBufferPrefetcher.hh"
36
37IrregularStreamBufferPrefetcher::IrregularStreamBufferPrefetcher(
38 const IrregularStreamBufferPrefetcherParams *p)
1/**
2 * Copyright (c) 2018 Metempsy Technology Consulting
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

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

31#include "mem/cache/prefetch/irregular_stream_buffer.hh"
32
33#include "debug/HWPrefetch.hh"
34#include "mem/cache/prefetch/associative_set_impl.hh"
35#include "params/IrregularStreamBufferPrefetcher.hh"
36
37IrregularStreamBufferPrefetcher::IrregularStreamBufferPrefetcher(
38 const IrregularStreamBufferPrefetcherParams *p)
39 : QueuedPrefetcher(p), maxCounterValue(p->max_counter_value),
39 : QueuedPrefetcher(p),
40 chunkSize(p->chunk_size),
41 prefetchCandidatesPerEntry(p->prefetch_candidates_per_entry),
42 degree(p->degree),
43 trainingUnit(p->training_unit_assoc, p->training_unit_entries,
44 p->training_unit_indexing_policy,
45 p->training_unit_replacement_policy),
46 psAddressMappingCache(p->address_map_cache_assoc,
47 p->address_map_cache_entries,
48 p->ps_address_map_cache_indexing_policy,
49 p->ps_address_map_cache_replacement_policy,
40 chunkSize(p->chunk_size),
41 prefetchCandidatesPerEntry(p->prefetch_candidates_per_entry),
42 degree(p->degree),
43 trainingUnit(p->training_unit_assoc, p->training_unit_entries,
44 p->training_unit_indexing_policy,
45 p->training_unit_replacement_policy),
46 psAddressMappingCache(p->address_map_cache_assoc,
47 p->address_map_cache_entries,
48 p->ps_address_map_cache_indexing_policy,
49 p->ps_address_map_cache_replacement_policy,
50 AddressMappingEntry(prefetchCandidatesPerEntry)),
50 AddressMappingEntry(prefetchCandidatesPerEntry,
51 p->num_counter_bits)),
51 spAddressMappingCache(p->address_map_cache_assoc,
52 p->address_map_cache_entries,
53 p->sp_address_map_cache_indexing_policy,
54 p->sp_address_map_cache_replacement_policy,
52 spAddressMappingCache(p->address_map_cache_assoc,
53 p->address_map_cache_entries,
54 p->sp_address_map_cache_indexing_policy,
55 p->sp_address_map_cache_replacement_policy,
55 AddressMappingEntry(prefetchCandidatesPerEntry)),
56 AddressMappingEntry(prefetchCandidatesPerEntry,
57 p->num_counter_bits)),
56 structuralAddressCounter(0)
57{
58 assert(isPowerOf2(prefetchCandidatesPerEntry));
59}
60
61void
62IrregularStreamBufferPrefetcher::calculatePrefetch(const PrefetchInfo &pfi,
63 std::vector<AddrPriority> &addresses)

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

95 if (correlated_addr_found) {
96 // If a correlation was found, update the Physical-to-Structural
97 // table accordingly
98 AddressMapping &mapping_A = getPSMapping(correlated_addr_A, is_secure);
99 AddressMapping &mapping_B = getPSMapping(correlated_addr_B, is_secure);
100 if (mapping_A.counter > 0 && mapping_B.counter > 0) {
101 // Entry for A and B
102 if (mapping_B.address == (mapping_A.address + 1)) {
58 structuralAddressCounter(0)
59{
60 assert(isPowerOf2(prefetchCandidatesPerEntry));
61}
62
63void
64IrregularStreamBufferPrefetcher::calculatePrefetch(const PrefetchInfo &pfi,
65 std::vector<AddrPriority> &addresses)

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

97 if (correlated_addr_found) {
98 // If a correlation was found, update the Physical-to-Structural
99 // table accordingly
100 AddressMapping &mapping_A = getPSMapping(correlated_addr_A, is_secure);
101 AddressMapping &mapping_B = getPSMapping(correlated_addr_B, is_secure);
102 if (mapping_A.counter > 0 && mapping_B.counter > 0) {
103 // Entry for A and B
104 if (mapping_B.address == (mapping_A.address + 1)) {
103 if (mapping_B.counter < maxCounterValue) {
104 mapping_B.counter += 1;
105 }
105 mapping_B.counter++;
106 } else {
107 if (mapping_B.counter == 1) {
106 } else {
107 if (mapping_B.counter == 1) {
108 // counter would hit 0, reassign address
109 mapping_B.counter = 1;
108 // Counter would hit 0, reassign address while keeping
109 // counter at 1
110 mapping_B.address = mapping_A.address + 1;
111 addStructuralToPhysicalEntry(mapping_B.address, is_secure,
112 correlated_addr_B);
113 } else {
110 mapping_B.address = mapping_A.address + 1;
111 addStructuralToPhysicalEntry(mapping_B.address, is_secure,
112 correlated_addr_B);
113 } else {
114 mapping_B.counter -= 1;
114 mapping_B.counter--;
115 }
116 }
117 } else {
118 if (mapping_A.counter == 0) {
119 // if A is not valid, generate a new structural address
115 }
116 }
117 } else {
118 if (mapping_A.counter == 0) {
119 // if A is not valid, generate a new structural address
120 mapping_A.counter = 1;
120 mapping_A.counter++;
121 mapping_A.address = structuralAddressCounter;
122 structuralAddressCounter += chunkSize;
123 addStructuralToPhysicalEntry(mapping_A.address,
124 is_secure, correlated_addr_A);
125 }
121 mapping_A.address = structuralAddressCounter;
122 structuralAddressCounter += chunkSize;
123 addStructuralToPhysicalEntry(mapping_A.address,
124 is_secure, correlated_addr_A);
125 }
126 mapping_B.counter = 1;
126 mapping_B.counter.reset();
127 mapping_B.counter++;
127 mapping_B.address = mapping_A.address + 1;
128 // update SP-AMC
129 addStructuralToPhysicalEntry(mapping_B.address, is_secure,
130 correlated_addr_B);
131 }
132 }
133
134 // Use the PS mapping to predict future accesses using the current address

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

198 } else {
199 sp_entry = spAddressMappingCache.findVictim(amc_address);
200 assert(sp_entry != nullptr);
201
202 spAddressMappingCache.insertEntry(amc_address, is_secure, sp_entry);
203 }
204 AddressMapping &mapping = sp_entry->mappings[map_index];
205 mapping.address = physical_address;
128 mapping_B.address = mapping_A.address + 1;
129 // update SP-AMC
130 addStructuralToPhysicalEntry(mapping_B.address, is_secure,
131 correlated_addr_B);
132 }
133 }
134
135 // Use the PS mapping to predict future accesses using the current address

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

199 } else {
200 sp_entry = spAddressMappingCache.findVictim(amc_address);
201 assert(sp_entry != nullptr);
202
203 spAddressMappingCache.insertEntry(amc_address, is_secure, sp_entry);
204 }
205 AddressMapping &mapping = sp_entry->mappings[map_index];
206 mapping.address = physical_address;
206 mapping.counter = 1;
207 mapping.counter.reset();
208 mapping.counter++;
207}
208
209IrregularStreamBufferPrefetcher*
210IrregularStreamBufferPrefetcherParams::create()
211{
212 return new IrregularStreamBufferPrefetcher(this);
213}
209}
210
211IrregularStreamBufferPrefetcher*
212IrregularStreamBufferPrefetcherParams::create()
213{
214 return new IrregularStreamBufferPrefetcher(this);
215}