Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A step at time: replace comment with readable code #9

Merged
merged 1 commit into from
Jun 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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