35#include <unordered_set>
49 numStores(num_stores),
103 while ((num_loads + num_stores) > 0) {
113 if (num_stores > 0) {
131 for (
int lane = 0; lane <
numLanes; ++lane) {
145 switch (action->getType()) {
158 normal_loc,
false) ||
161 panic(
"TestTh %d - Data race detected. STOPPED!\n",
166 action->setLocation(lane, normal_loc);
180 panic(
"TestTh %d - Data race detected. STOPPED!\n",
185 action->setLocation(lane, normal_loc);
192 panic(
"Invalid action type\n");
205 for (
int lane = 0; lane <
numLanes; ++lane) {
209 std::unordered_set<Location> unique_loc_set;
214 if (action->isAtomicAction()) {
216 atomic_loc = action->getLocation(lane);
220 assert(atomic_loc == action->getLocation(lane));
222 }
else if (!action->isMemFenceAction()) {
223 assert(atomic_loc >= 0);
224 normal_loc = action->getLocation(lane);
227 unique_loc_set.insert(normal_loc);
248 for (
int lane = 0; lane < max_lane; ++lane) {
251 if (!action->isAtomicAction() &&
252 !action->isMemFenceAction()) {
253 if (isStore && loc == action->getLocation(lane)) {
254 warn(
"ST at location %d races against thread %d\n",
257 }
else if (!isStore &&
259 loc == action->getLocation(lane)) {
260 warn(
"LD at location %d races against thread %d\n",
285 assert(lane >= 0 && lane <
numLanes);
286 locations[lane] = loc;
292 assert(lane >= 0 && lane <
numLanes);
293 return locations[lane];
299 return (
type == Type::ATOMIC);
305 return (
type == Type::ACQUIRE ||
type == Type::RELEASE);
311 if (
type == Type::ACQUIRE)
313 else if (
type == Type::RELEASE)
315 else if (
type == Type::ATOMIC)
317 else if (
type == Type::LOAD)
319 else if (
type == Type::STORE)
322 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
std::enable_if_t< std::is_integral_v< T >, T > random()
Use the SFINAE idiom to choose an implementation based on whether the type is integral or floating po...
#define panic(...)
This implements a cprintf based panic() function.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.