48 : numAtomicLocs(n_atomic_locs),
49 numLocsPerAtomic(n_normal_locs_per_atomic)
70 std::default_random_engine(
rng->random<
unsigned>(0,UINT_MAX - 1))
99 assert(loc < numAtomicLocs + numNormalLocs && loc >= 0);
109 return ret_atomic_loc;
152 assert(loc_begin <= loc_end);
184 assert(firstMark >= 0);
185 assert(firstMark <= secondMark);
186 assert(secondMark <= arraySize);
188 assert(loadStoreMap.empty());
194 expectedValues.insert(requestCount - 1);
195 expectedValues.insert(requestCount - 2);
201 assert(firstMark >= 0);
202 assert(firstMark <= secondMark);
203 assert(secondMark <= arraySize);
205 if (firstMark == arraySize) {
211 int range_size = arraySize - firstMark;
213 firstMark +
rng->random<
unsigned int>() % range_size
217 LdStMap::iterator it = loadStoreMap.find(ret_loc);
219 if (it == loadStoreMap.end()) {
226 (it->second).first =
true;
236 assert(firstMark >= 0);
237 assert(firstMark <= secondMark);
238 assert(secondMark <= arraySize);
240 if (firstMark == secondMark) {
245 int range_size = secondMark - firstMark;
247 firstMark +
rng->random<
unsigned int>() % range_size
251 LdStMap::iterator it = loadStoreMap.find(ret_loc);
253 if (it == loadStoreMap.end()) {
260 (it->second).second =
true;
277 assert(firstMark >= 0);
278 assert(firstMark <= secondMark);
279 assert(secondMark <= arraySize);
281 for (
auto& it : loadStoreMap) {
285 assert(loc >= locationBase && loc < locationBase + arraySize);
286 LocProperty& loc_prop = locProps[loc - locationBase];
288 if (
p.first && !
p.second) {
291 assert(inSecondRegion(loc_prop.first) ||
292 inThirdRegion(loc_prop.first));
294 if (inSecondRegion(loc_prop.first)) {
296 assert(loc_prop.second == 0);
299 Location swapped_loc = locArray[secondMark - 1];
301 locProps[swapped_loc - locationBase];
304 swap(loc_prop, swapped_loc_prop);
312 }
else if (
p.second) {
315 assert(inSecondRegion(loc_prop.first) && loc_prop.second == 0);
318 Location swapped_loc = locArray[firstMark];
320 locProps[swapped_loc - locationBase];
323 swap(loc_prop, swapped_loc_prop);
331 panic(
"Location in loadStoreMap but wasn't picked in any"
337 loadStoreMap.clear();
343 assert(loc >= locationBase && loc < locationBase + arraySize);
345 LocProperty& loc_prop = locProps[loc - locationBase];
347 if (inFirstRegion(loc_prop.first)) {
349 assert(loc_prop.second == 1);
352 Location swapped_loc = locArray[firstMark - 1];
353 LocProperty& swapped_loc_prop = locProps[swapped_loc - locationBase];
356 swap(loc_prop, swapped_loc_prop);
363 }
else if (inThirdRegion(loc_prop.first)) {
365 assert(loc_prop.second >= 1);
367 if (loc_prop.second == 1) {
369 Location swapped_loc = locArray[secondMark];
371 locProps[swapped_loc - locationBase];
374 swap(loc_prop, swapped_loc_prop);
383 assert(inSecondRegion(loc_prop.first) && loc_prop.second == 0);
390 ExpectedValueSet::iterator it = expectedValues.find(
val);
392 if (it == expectedValues.end()) {
393 std::stringstream exp_val_ss;
394 for (
auto&
val : expectedValues) {
395 exp_val_ss <<
" " <<
val;
398 warn(
"Expected return values are:\n\t%s\n", exp_val_ss.str());
404 expectedValues.erase(it);
412 int new_idx_1 = prop_2.first;
413 int new_idx_2 = prop_1.first;
416 Location tmp = locArray[prop_1.first];
417 locArray[prop_1.first] = locArray[prop_2.first];
418 locArray[prop_2.first] = tmp;
421 prop_1.first = new_idx_1;
422 prop_2.first = new_idx_2;
428 Value new_value,
Tick cur_tick,
int cu_id)
431 logTable[loc]->update(thread_id, cu_id, episode_id, new_value, cur_tick);
438 return logTable[loc]->getLastStoredValue();
void releaseLoc(Location loc)
std::pair< int, int > LocProperty
AtomicStruct(Location atom_loc, Location loc_begin, Location loc_end)
bool isExpectedValue(Value val)
void swap(LocProperty &prop_1, LocProperty &prop_2)
Addr getAddress(Location loc)
AtomicStructTable atomicStructs
Location getStoreLoc(Location atomic_loc)
Value getLoggedValue(Location loc) const
AddressManager(int n_atomic_locs, int numNormalLocsPerAtomic)
AddressMap randAddressMap
std::string printLastWriter(Location loc) const
void updateLogTable(Location loc, int threadId, int episodeId, Value new_value, Tick curTick, int cuId=-1)
static const int INVALID_LOCATION
Location getLoadLoc(Location atomic_loc)
static const int INVALID_VALUE
void finishLocSelection(Location atomic_loc)
void releaseLocation(Location atomic_loc, Location loc)
bool validateAtomicResp(Location loc, Value ret_val)
static constexpr std::enable_if_t< std::is_integral_v< T >, int > floorLog2(T x)
#define panic(...)
This implements a cprintf based panic() function.
Copyright (c) 2024 Arm Limited All rights reserved.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
uint64_t Tick
Tick count type.