35#include <unordered_set>
48 numStores(num_stores),
102 while ((num_loads + num_stores) > 0) {
103 switch (
rng->random<
unsigned int>() % 2) {
112 if (num_stores > 0) {
130 for (
int lane = 0; lane <
numLanes; ++lane) {
144 switch (action->getType()) {
157 normal_loc,
false) ||
160 panic(
"TestTh %d - Data race detected. STOPPED!\n",
165 action->setLocation(lane, normal_loc);
179 panic(
"TestTh %d - Data race detected. STOPPED!\n",
184 action->setLocation(lane, normal_loc);
191 panic(
"Invalid action type\n");
204 for (
int lane = 0; lane <
numLanes; ++lane) {
208 std::unordered_set<Location> unique_loc_set;
213 if (action->isAtomicAction()) {
215 atomic_loc = action->getLocation(lane);
219 assert(atomic_loc == action->getLocation(lane));
221 }
else if (!action->isMemFenceAction()) {
222 assert(atomic_loc >= 0);
223 normal_loc = action->getLocation(lane);
226 unique_loc_set.insert(normal_loc);
247 for (
int lane = 0; lane < max_lane; ++lane) {
250 if (!action->isAtomicAction() &&
251 !action->isMemFenceAction()) {
252 if (isStore && loc == action->getLocation(lane)) {
253 warn(
"ST at location %d races against thread %d\n",
256 }
else if (!isStore &&
258 loc == action->getLocation(lane)) {
259 warn(
"LD at location %d races against thread %d\n",
284 assert(lane >= 0 && lane <
numLanes);
285 locations[lane] = loc;
291 assert(lane >= 0 && lane <
numLanes);
292 return locations[lane];
298 return (
type == Type::ATOMIC);
304 return (
type == Type::ACQUIRE ||
type == Type::RELEASE);
310 if (
type == Type::ACQUIRE)
312 else if (
type == Type::RELEASE)
314 else if (
type == Type::ATOMIC)
316 else if (
type == Type::LOAD)
318 else if (
type == Type::STORE)
321 panic(
"Invalid action type\n");
static const int INVALID_LOCATION
void finishLocSelection(Location atomic_loc)
void releaseLocation(Location atomic_loc, Location loc)
Action(Type t, int num_lanes)
Location getLocation(int lane) const
const std::string printType() const
bool isMemFenceAction() const
bool isAtomicAction() const
void setLocation(int lane, Location loc)
Episode(ProtocolTester *tester, TesterThread *thread, int num_loads, int num_stores)
AddressManager::Location Location
bool checkDRF(Location atomic_loc, Location loc, bool isStore, int max_lane) const
AddressManager * addrManager
const Action * peekCurAction() const
AtomicLocationList atomicLocs
bool checkDRF(Location atomic_loc, Location loc, bool isStore) const
AddressManager * getAddressManager() const
int getTesterThreadId() const
#define panic(...)
This implements a cprintf based panic() function.
Copyright (c) 2024 Arm Limited All rights reserved.