Skip to content

Commit

Permalink
A step at time: replace comment with readable code
Browse files Browse the repository at this point in the history
  • Loading branch information
hassansalehe committed Jun 20, 2021
1 parent 05ce798 commit 2012a0b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
28 changes: 14 additions & 14 deletions src/common/MemoryActions.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class MemoryActions {
Action action;

int taskId;
ADDRESS addr; // destination address
ADDRESS destination_address;

// Default constructor
MemoryActions() {
Expand All @@ -42,27 +42,27 @@ class MemoryActions {
// (b) is last write action
inline void storeAction(Action & act) {
if ( isEmpty || act.isWrite ) {
action = act;
isEmpty = false;
taskId = action.taskId;
addr = action.addr;
action = act;
isEmpty = false;
taskId = action.taskId;
destination_address = action.destination_address;
}
}

inline void storeAction(uint & taskID, ADDRESS & adr,
INTEGER & val, INTEGER & linNo,
INTEGER & funcID, bool isWrite_) {
if ( isEmpty || isWrite_) {
action.taskId = taskID;
action.addr = adr;
action.funcId = funcID;
action.value = val;
action.lineNo = linNo;
action.isWrite = isWrite_;
action.taskId = taskID;
action.destination_address = adr;
action.funcId = funcID;
action.value = val;
action.lineNo = linNo;
action.isWrite = isWrite_;

isEmpty = false;
taskId = action.taskId;
addr = action.addr;
isEmpty = false;
taskId = action.taskId;
destination_address = action.destination_address;
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/common/action.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
class Action {
public:
INTEGER taskId; // task id of writter
ADDRESS addr; // destination address
ADDRESS destination_address;
VALUE value; // value written
VALUE lineNo; // source-line number
INTEGER funcId; // the identifier of corresponding function
Expand All @@ -34,10 +34,10 @@ class Action {
taskId(tskId), value(val), lineNo(ln), funcId(fuId) {}

Action(INTEGER tskId, ADDRESS adr, VALUE val, VALUE ln, INTEGER fuId):
taskId(tskId), addr(adr), value(val), lineNo(ln), funcId(fuId) { }
taskId(tskId), destination_address(adr), value(val), lineNo(ln), funcId(fuId) { }

Action(INTEGER tskId, address adr, lint val, int ln, INTEGER fuId ):
taskId(tskId), addr(adr), value(val), lineNo(ln), funcId(fuId) { }
taskId(tskId), destination_address(adr), value(val), lineNo(ln), funcId(fuId) { }

Action() { }

Expand All @@ -53,7 +53,7 @@ class Action {
void printActionNN(std::ostringstream & buff) {
std::string type = " R ";
if ( isWrite ) type = " W ";
buff << taskId << type << addr << " " << value
buff << taskId << type << destination_address << " " << value
<< " " << lineNo << " " << funcId;
}

Expand Down
10 changes: 5 additions & 5 deletions src/detector/determinacy/checker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,11 @@ void Checker::saveTaskActions( const MemoryActions & taskActions ) {
// write in the parallel writes,update and take it forward
// 4.2.1 check conflicts with other parallel tasks

auto perAddrActions = writes.find( taskActions.addr );
auto perAddrActions = writes.find(taskActions.destination_address);
if (perAddrActions == writes.end()) {// 1. first action
writes[taskActions.addr] = std::list<MemoryActions>();
writes[taskActions.destination_address] = std::list<MemoryActions>();
}
std::list<MemoryActions> & AddrActions = writes[taskActions.addr];
std::list<MemoryActions> & AddrActions = writes[taskActions.destination_address];
for (auto lastWrt = AddrActions.begin();
lastWrt != AddrActions.end(); lastWrt++) {
// actions of same task
Expand Down Expand Up @@ -185,7 +185,7 @@ void Checker::saveTaskActions( const MemoryActions & taskActions ) {
AddrActions.pop_front(); // remove oldest element
}

writes[taskActions.addr].push_back( taskActions ); // save
writes[taskActions.destination_address].push_back( taskActions ); // save
}

// Records the determinacy race warning to the conflicts table.
Expand Down Expand Up @@ -227,7 +227,7 @@ void Checker::constructMemoryAction(std::stringstream & ssin,
Action & action) {
std::string tempBuff;
ssin >> tempBuff; // address
action.addr = (ADDRESS)stoul(tempBuff, 0, 16);
action.destination_address = (ADDRESS)stoul(tempBuff, 0, 16);

ssin >> tempBuff; // value
action.value = stol(tempBuff);
Expand Down
2 changes: 1 addition & 1 deletion src/detector/determinacy/conflict.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Conflict {
Conflict(const Action& curMemAction, const Action& prevMemAction) {
action1 = curMemAction;
action2 = prevMemAction;
addr = curMemAction.addr;
addr = curMemAction.destination_address;
}

inline int getTask1Id() {
Expand Down

0 comments on commit 2012a0b

Please sign in to comment.